@univerjs/sheets-data-validation-ui 0.10.9 → 0.10.10
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 +2 -2
- package/lib/es/index.js +763 -763
- package/lib/index.js +763 -763
- package/lib/umd/index.js +2 -2
- package/package.json +13 -13
package/lib/cjs/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
"use strict";var Lt=Object.defineProperty;var Pt=(e,t,a)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var L=(e,t,a)=>Pt(e,typeof t!="symbol"?t+"":t,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),P=require("@univerjs/engine-render"),H=require("@univerjs/sheets"),I=require("@univerjs/sheets-data-validation"),Y=require("@univerjs/data-validation"),E=require("@univerjs/ui"),oe=require("rxjs"),xt=require("@univerjs/sheets-numfmt"),N=require("@univerjs/sheets-ui"),V=require("@univerjs/design"),b=require("react"),p=require("react/jsx-runtime"),nt=require("@univerjs/engine-formula"),st=require("@univerjs/sheets-formula-ui");var jt=Object.getOwnPropertyDescriptor,Ut=(e,t,a,n)=>{for(var r=n>1?void 0:n?jt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},gt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends o.Disposable{constructor(t,a){super();L(this,"_open$",new oe.BehaviorSubject(!1));L(this,"open$",this._open$.pipe(oe.distinctUntilChanged()));L(this,"_activeRule");L(this,"_activeRule$",new oe.BehaviorSubject(void 0));L(this,"activeRule$",this._activeRule$.asObservable());L(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(oe.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===Fe&&(n.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)}};ue=Ut([gt(0,o.IUniverInstanceService),gt(1,E.ISidebarService)],ue);const me="#ECECEC",lt="sheets-data-validation-ui.config",Ue={};var Ft=Object.getOwnPropertyDescriptor,kt=(e,t,a,n)=>{for(var r=n>1?void 0:n?Ft(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ie=(e,t)=>(a,n)=>t(a,n,e);let we=class extends o.Disposable{constructor(e,t,a,n,r,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=r,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(H.VALIDATE_CELL,{handler:async(e,t,a)=>{const n=await e,{row:r,col:i,unitId:s,subUnitId:d}=t,l=this._dataValidationModel.getRuleIdByLocation(s,d,r,i),c=l?this._dataValidationModel.getRuleById(s,d,l):void 0;if(n===!1)return a(Promise.resolve(!1));if(!c||c.errorStyle!==o.DataValidationErrorStyle.STOP)return a(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,r,i)===o.DataValidationStatus.VALID?a(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:r,col:i,unitId:s,subUnitId:d})},footer:{title:b.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")}}),a(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:b.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")}})}};we=kt([Ie(0,o.Inject(H.SheetInterceptorService)),Ie(1,o.Inject(I.SheetDataValidationModel)),Ie(2,o.Inject(Y.DataValidatorRegistryService)),Ie(3,E.IDialogService),Ie(4,o.Inject(o.LocaleService)),Ie(5,o.Inject(I.SheetsDataValidationValidatorService))],we);var Nt=Object.getOwnPropertyDescriptor,Bt=(e,t,a,n)=>{for(var r=n>1?void 0:n?Nt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},le=(e,t)=>(a,n)=>t(a,n,e);const Ye=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 Wt(e,t){const a=xt.getPatternType(t);if(e===a)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 fe=class extends o.Disposable{constructor(t,a,n,r,i,s,d,l,c,h,g){super();L(this,"_activeDropdown");L(this,"_activeDropdown$",new oe.Subject);L(this,"_currentPopup",null);L(this,"activeDropdown$",this._activeDropdown$.asObservable());L(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=a,this._zenZoneService=n,this._dataValidationModel=r,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,a,n,r){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=a?i.getSheetBySheetId(a):i.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,r);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(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var T,M,m,f;const{location:a}=t,{row:n,col:r,unitId:i,subUnitId:s,workbook:d,worksheet:l}=a;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(i,s,n,r);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let g;const u=async(S,D)=>{var x,F,B;if(!S)return!0;const R=S,y=l.getCell(n,r),w=R.format(D==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),U=(x=o.numfmt.parseDate(w))==null?void 0:x.v,W=D==="time"?U%1:U,O=d.getStyles().getStyleByCell(y),j=(B=(F=O==null?void 0:O.n)==null?void 0:F.pattern)!=null?B:"";return c.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:W,unitId:i,subUnitId:s,row:n,column:r,worksheet:l,workbook:d,interceptValue:w.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(H.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:W,t:2,p:null,f:null,si:null,s:{n:{pattern:Wt(D,j)}}}}),await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0):(this._injector.has(we)&&this._injector.get(we).showReject(h.getRuleFinalError(c,{row:n,col:r,unitId:i,subUnitId:s})),!1)};let C;switch(h.dropdownType){case Y.DataValidatorDropdownType.DATE:{const S=I.getCellValueOrigin(l.getCellRaw(n,r)),D=Ye(S),R=!!((T=c.bizInfo)!=null&&T.showTime);C={location:a,type:"datepicker",props:{showTime:R,onChange:y=>u(y,R?"datetime":"date"),defaultValue:D,patternType:"date"}};break}case Y.DataValidatorDropdownType.TIME:{const S=I.getCellValueOrigin(l.getCellRaw(n,r)),D=Ye(S);C={location:a,type:"datepicker",props:{onChange:R=>u(R,"time"),defaultValue:D,patternType:"time"}};break}case Y.DataValidatorDropdownType.DATETIME:{const S=I.getCellValueOrigin(l.getCellRaw(n,r)),D=Ye(S);C={location:a,type:"datepicker",props:{onChange:R=>u(R,"datetime"),defaultValue:D,patternType:"datetime"}};break}case Y.DataValidatorDropdownType.LIST:case Y.DataValidatorDropdownType.MULTIPLE_LIST:{const S=h.dropdownType===Y.DataValidatorDropdownType.MULTIPLE_LIST,D=async O=>{const j=I.serializeListOptions(O),x={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:j,p:null,f:null,si:null}};return this._commandService.executeCommand(H.SetRangeValuesCommand.id,x),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!S},R=(c==null?void 0:c.renderMode)===o.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,y=h.getListWithColor(c,i,s),w=I.getDataValidationCellValue(l.getCellRaw(n,r)),U=()=>{this._commandService.executeCommand(Se.id,{ruleId:c.uid}),g==null||g.dispose()},W=y.map(O=>({label:O.label,value:O.label,color:R||O.color?O.color||me:"transparent"}));C={location:a,type:"list",props:{onChange:O=>D(O),options:W,onEdit:U,defaultValue:w,multiple:S,showEdit:(m=(M=this._configService.getConfig(lt))==null?void 0:M.showEditOnDropdown)!=null?m:!0}};break}case Y.DataValidatorDropdownType.CASCADE:{C={type:"cascader",props:{onChange:D=>{const R={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:D.join("/"),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,R),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0},defaultValue:I.getDataValidationCellValue(l.getCellRaw(n,r)).split("/"),options:JSON.parse((f=c.formula1)!=null?f:"[]")},location:a};break}case Y.DataValidatorDropdownType.COLOR:{C={type:"color",props:{onChange:D=>{const R={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:D,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,R),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0},defaultValue:I.getDataValidationCellValue(l.getCellRaw(n,r))},location:a};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(g=this._cellDropdownManagerService.showDropdown({...C,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 S,D;(D=(S=this._activeDropdown)==null?void 0:S.onHide)==null||D.call(S)}}),this._currentPopup=v}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,a,n,r,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(a);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,r);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:n,col:r,unitId:t,subUnitId:a},onHide:i})}};fe=Bt([le(0,o.IUniverInstanceService),le(1,o.Inject(Y.DataValidatorRegistryService)),le(2,E.IZenZoneService),le(3,o.Inject(I.SheetDataValidationModel)),le(4,o.Inject(H.SheetsSelectionsService)),le(5,o.Inject(N.ISheetCellDropdownManagerService)),le(6,o.Inject(I.SheetDataValidationModel)),le(7,o.ICommandService),le(8,N.IEditorBridgeService),le(9,o.Inject(o.Injector)),le(10,o.IConfigService)],fe);const Fe="DataValidationPanel",Se={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,r=e.get(ue),i=e.get(Y.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(E.ISidebarService),l=H.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,g=a?i.getRuleById(c,h,a):void 0;r.open(),r.setActiveRule(g&&{unitId:c,subUnitId:h,rule:g});const u=d.open({id:Fe,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Fe},width:312,onClose:()=>r.close()});return r.setCloseDisposable(u),!0}},dt={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},_t={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),a=e.get(ue);return a.open(),a.isOpen?t.executeCommand(dt.id):t.executeCommand(Se.id),!0}},He={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(fe),{unitId:n,subUnitId:r,row:i,column:s}=t,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===r&&l.row===i&&l.col===s||a.showDataValidationDropdown(n,r,i,s),!0}},It={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},$e={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),a=H.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:r}=a,i=I.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=r.getSheetId(),c={rule:i,unitId:d,subUnitId:l};return s.syncExecuteCommand(I.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(Se.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var Ht=Object.getOwnPropertyDescriptor,$t=(e,t,a,n)=>{for(var r=n>1?void 0:n?Ht(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ce=(e,t)=>(a,n)=>t(a,n,e);const pe="SHEET_DATA_VALIDATION_ALERT";let Ae=class extends o.Disposable{constructor(e,t,a,n,r,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=r,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(oe.debounceTime(100)).subscribe(e=>{var t;if(e){const a=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),n=a.getSheetBySheetId(e.location.subUnitId);if(!n)return;const r=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!r){this._cellAlertManagerService.removeAlert(pe);return}if(this._dataValidationModel.validator(r,{...e.location,workbook:a,worksheet:n})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(pe),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(pe);return}const l=this._dataValidationModel.getValidator(r.type);if(!l){this._cellAlertManagerService.removeAlert(pe);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:pe});return}}this._cellAlertManagerService.removeAlert(pe)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(pe)}))}};Ae=$t([Ce(0,o.Inject(N.HoverManagerService)),Ce(1,o.Inject(N.CellAlertManagerService)),Ce(2,o.IUniverInstanceService),Ce(3,o.Inject(o.LocaleService)),Ce(4,E.IZenZoneService),Ce(5,o.Inject(I.SheetDataValidationModel))],Ae);var Yt=Object.getOwnPropertyDescriptor,Xt=(e,t,a,n)=>{for(var r=n>1?void 0:n?Yt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Xe=(e,t)=>(a,n)=>t(a,n,e);let Ve=class extends o.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,r)=>{const{source:i,target:s,unitId:d,subUnitId:l}=n,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=N.virtualizeDiscreteRanges([i,s]),[g,u]=h.ranges,{mapFunc:C}=h,v={row:g.startRow,col:g.startColumn},T=N.getAutoFillRepeatRange(g,u),M=new o.ObjectMatrix,m=new Set;T.forEach(y=>{const w=y.repeatStartCell,U=y.relativeRange,W={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},O={startRow:w.row,startColumn:w.col,endColumn:w.col,endRow:w.row};o.Range.foreach(U,(j,x)=>{const F=o.Rectangle.getPositionRange({startRow:j,startColumn:x,endColumn:x,endRow:j},W),{row:B,col:K}=C(F.startRow,F.startColumn),z=this._sheetDataValidationModel.getRuleIdByLocation(d,l,B,K)||"",ee=o.Rectangle.getPositionRange({startRow:j,startColumn:x,endColumn:x,endRow:j},O),{row:ae,col:re}=C(ee.startRow,ee.startColumn);M.setValue(ae,re,z),m.add(z)})});const f=Array.from(m).map(y=>({id:y,ranges:o.queryObjectMatrix(M,w=>w===y)}));c.addRangeRules(f);const S=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:D,undoMutations:R}=I.getDataValidationDiffMutations(d,l,S,this._injector,"patched",r===N.APPLY_TYPE.ONLY_FORMAT);return{undos:R,redos:D}},a={id:I.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:r,unitId:i,subUnitId:s}=n;for(const d of r.rows)for(const l of r.cols){const c=this._sheetDataValidationModel.getRuleByLocation(i,s,d,l);if(c&&c.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(N.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,r,i)=>i===N.APPLY_TYPE.COPY||i===N.APPLY_TYPE.ONLY_FORMAT||i===N.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};Ve=Xt([Xe(0,N.IAutoFillService),Xe(1,o.Inject(I.SheetDataValidationModel)),Xe(2,o.Inject(o.Injector))],Ve);var zt=Object.getOwnPropertyDescriptor,Kt=(e,t,a,n)=>{for(var r=n>1?void 0:n?zt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ze=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends o.Disposable{constructor(t,a,n){super();L(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:I.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,r)=>{const{copyType:i=N.COPY_TYPE.COPY,pasteType:s}=r,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=a;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,a,n){const r=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:r};const i=this._injector.invoke(l=>H.rangeToDiscreteRange(n,l,t,a));if(!i)return;const{rows:s,cols:d}=i;s.forEach((l,c)=>{d.forEach((h,g)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,a,l,h);r.setValue(c,g,u!=null?u:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===N.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.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(a.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:i}=this._copyInfo;if(a.unitId!==r||i!==a.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:g}=N.virtualizeDiscreteRanges([a.copyRange,t]),u=N.getRepeatRange(c,h,!0),C=new Map;u.forEach(({startRange:m})=>{var f;(f=this._copyInfo)==null||f.matrix.forValue((S,D,R)=>{const y=o.Rectangle.getPositionRange({startRow:S,endRow:S,startColumn:D,endColumn:D},m),w=`${i}-${R}`,U=this._sheetDataValidationModel.getRuleById(r,i,R);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,w)&&U&&C.set(w,{...U,uid:w});const{row:W,col:O}=g(y.startRow,y.startColumn);l.add(w),d.setValue(W,O,w)})});const v=Array.from(l).map(m=>({id:m,ranges:o.queryObjectMatrix(d,f=>f===m)}));s.addRangeRules(v);const{redoMutations:T,undoMutations:M}=I.getDataValidationDiffMutations(a.unitId,a.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),C.values()),this._injector,"patched",!1);return{redos:T,undos:M}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(r,i).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:g}=N.virtualizeDiscreteRanges([a.copyRange,t]);N.getRepeatRange(c,h,!0).forEach(({startRange:M})=>{var m;(m=this._copyInfo)==null||m.matrix.forValue((f,S,D)=>{const R=o.Rectangle.getPositionRange({startRow:f,endRow:f,startColumn:S,endColumn:S},M),{row:y,col:w}=g(R.startRow,R.startColumn);d.setValue(y,w,D),l.add(D)})});const C=Array.from(l).map(M=>({id:M,ranges:o.queryObjectMatrix(d,m=>m===M)}));s.addRangeRules(C);const{redoMutations:v,undoMutations:T}=I.getDataValidationDiffMutations(r,i,s.diff(this._sheetDataValidationModel.getRules(r,i)),this._injector,"patched",!1);return{redos:v,undos:T}}}};Ee=Kt([ze(0,N.ISheetClipboardService),ze(1,o.Inject(I.SheetDataValidationModel)),ze(2,o.Inject(o.Injector))],Ee);var Zt=Object.getOwnPropertyDescriptor,Gt=(e,t,a,n)=>{for(var r=n>1?void 0:n?Zt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ke=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends o.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===I.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[H.WorkbookEditablePermission],rangeTypes:[H.RangeProtectionPermissionEditPoint],worksheetTypes:[H.WorksheetEditPermission,H.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===I.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[H.WorkbookEditablePermission],rangeTypes:[H.RangeProtectionPermissionEditPoint],worksheetTypes:[H.WorksheetEditPermission,H.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Me=Gt([Ke(0,o.Inject(o.LocaleService)),Ke(1,o.ICommandService),Ke(2,o.Inject(H.SheetPermissionCheckController))],Me);const Ct="sheet.menu.data-validation";function qt(e){return{id:Ct,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 Jt(e){return{id:Se.id,title:"dataValidation.panel.title",type:E.MenuItemType.BUTTON}}function Qt(e){return{id:$e.id,title:"dataValidation.panel.add",type:E.MenuItemType.BUTTON}}const en={[E.RibbonDataGroup.RULES]:{[Ct]:{order:0,menuItemFactory:qt,[Se.id]:{order:0,menuItemFactory:Jt},[$e.id]:{order:1,menuItemFactory:Qt}}}};var tn=Object.getOwnPropertyDescriptor,yt=(e,t,a,n)=>{for(var r=n>1?void 0:n?tn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},G=(e,t)=>(a,n)=>t(a,n,e);const Rt={tr:{size:6,color:"#fe4b4b"}};let be=class extends o.RxDisposable{constructor(e,t,a,n,r,i,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=r,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(en)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var a;if(!e.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:r,row:i,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,r,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===n&&u.subUnitId===r&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:r,row:i,col:s,workbook:d,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,a)=>{var m,f,S,D,R;const{row:n,col:r,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,r);if(!c)return a(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return a(e);const g=(m=this._dataValidationCacheService.getValue(i,s,n,r))!=null?m:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),C=t.rawData;let v;const T={get value(){var y;return v!==void 0||(v=(y=I.getCellValueOrigin(C))!=null?y:null),v}},M={get value(){var y;return`${(y=T.value)!=null?y:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...g===o.DataValidationStatus.INVALID?Rt:null},e.customRender=[...(f=e==null?void 0:e.customRender)!=null?f:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((S=e==null?void 0:e.fontRenderExtension)==null?void 0:S.isSkip)||((D=u==null?void 0:u.skipDefaultFontRender)==null?void 0:D.call(u,h,T.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,M.value,{get style(){const y=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?y.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,r)},e.interceptorAutoHeight=()=>{var W,O,j,x,F,B;const y=(O=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:O.skeleton;if(!y)return;const w=y.worksheet.getMergedCell(n,r),U={data:e,style:y.getStyles().getStyleByCell(e),primaryWithCoord:y.getCellWithCoordByIndex((j=w==null?void 0:w.startRow)!=null?j:n,(x=w==null?void 0:w.startColumn)!=null?x:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(B=(F=u==null?void 0:u.canvasRender)==null?void 0:F.calcCellAutoHeight)==null?void 0:B.call(F,U)},e.interceptorAutoWidth=()=>{var W,O,j,x,F,B;const y=(O=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:O.skeleton;if(!y)return;const w=y.worksheet.getMergedCell(n,r),U={data:e,style:y.getStyles().getStyleByCell(e),primaryWithCoord:y.getCellWithCoordByIndex((j=w==null?void 0:w.startRow)!=null?j:n,(x=w==null?void 0:w.startColumn)!=null?x:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(B=(F=u==null?void 0:u.canvasRender)==null?void 0:F.calcCellAutoWidth)==null?void 0:B.call(F,U)},e.coverable=((R=e==null?void 0:e.coverable)!=null?R:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),a(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(oe.filter(e=>e.source==="command"),oe.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(a=>{var n;(a.rule.type===o.DataValidationType.LIST_MULTIPLE||a.rule.type===o.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};be=yt([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(fe)),G(6,o.Inject(I.SheetDataValidationModel)),G(7,o.Inject(Y.DataValidatorRegistryService)),G(8,o.Inject(H.SheetInterceptorService)),G(9,o.Inject(I.DataValidationCacheService)),G(10,o.Optional(N.IEditorBridgeService))],be);let pt=class extends o.RxDisposable{constructor(e,t,a,n,r,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,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,a)=>{var M,m,f,S,D;const{row:n,col:r,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,r);if(!c)return a(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return a(e);const g=(M=this._dataValidationCacheService.getValue(i,s,n,r))!=null?M:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),C=l.getCellRaw(n,r),v=I.getCellValueOrigin(C),T=`${v!=null?v:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...g===o.DataValidationStatus.INVALID?Rt:null},e.customRender=[...(m=e==null?void 0:e.customRender)!=null?m:[],...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)||((S=u==null?void 0:u.skipDefaultFontRender)==null?void 0:S.call(u,h,v,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,T,{get style(){const R=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?R.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,r)},e.interceptorAutoHeight=()=>{var U,W,O,j,x,F;const R=(W=(U=this._renderManagerService.getRenderById(i))==null?void 0:U.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!R)return;const y=R.worksheet.getMergedCell(n,r),w={data:e,style:R.getStyles().getStyleByCell(e),primaryWithCoord:R.getCellWithCoordByIndex((O=y==null?void 0:y.startRow)!=null?O:n,(j=y==null?void 0:y.startColumn)!=null?j:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(F=(x=u==null?void 0:u.canvasRender)==null?void 0:x.calcCellAutoHeight)==null?void 0:F.call(x,w)},e.interceptorAutoWidth=()=>{var U,W,O,j,x,F;const R=(W=(U=this._renderManagerService.getRenderById(i))==null?void 0:U.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!R)return;const y=R.worksheet.getMergedCell(n,r),w={data:e,style:R.getStyles().getStyleByCell(e),primaryWithCoord:R.getCellWithCoordByIndex((O=y==null?void 0:y.startRow)!=null?O:n,(j=y==null?void 0:y.startColumn)!=null?j:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(F=(x=u==null?void 0:u.canvasRender)==null?void 0:x.calcCellAutoWidth)==null?void 0:F.call(x,w)},e.coverable=((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),a(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(oe.filter(e=>e.source==="command"),oe.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(a.rule.type===o.DataValidationType.LIST_MULTIPLE||a.rule.type===o.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};pt=yt([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(I.SheetDataValidationModel)),G(6,o.Inject(I.DataValidationCacheService))],pt);var nn=Object.getOwnPropertyDescriptor,an=(e,t,a,n)=>{for(var r=n>1?void 0:n?nn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},vt=(e,t)=>(a,n)=>t(a,n,e);let ke=class extends o.Disposable{constructor(e,t,a){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const a=new Set;t.forEach(r=>{a.add(r.subUnitId)}),a.forEach(r=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(r))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};ke=an([vt(1,o.Inject(I.SheetDataValidationModel)),vt(2,o.Inject(N.SheetSkeletonManagerService))],ke);var ie=function(){return ie=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},ie.apply(this,arguments)},rn=function(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(a[n[r]]=e[n[r]]);return a},_e=b.forwardRef(function(e,t){var a=e.icon,n=e.id,r=e.className,i=e.extend,s=rn(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),l=b.useRef("_".concat(ln()));return Dt(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},ie({ref:t,className:d},s),i)});function Dt(e,t,a,n,r){return b.createElement(e.tag,ie(ie({key:t},on(e,a,r)),n),(sn(e,a).children||[]).map(function(i,s){return Dt(i,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,r)}))}function on(e,t,a){var n=ie({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];s==="mask"&&typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var r=t.defIds;return!r||r.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function sn(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?ie(ie({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.includes(r.attrs.id)?ie(ie({},r),{attrs:ie(ie({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):e}function ln(){return Math.random().toString(36).substring(2,8)}_e.displayName="UniverIcon";var dn={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"}}]},wt=b.forwardRef(function(e,t){return b.createElement(_e,Object.assign({},e,{id:"data-validation-icon",ref:t,icon:dn}))});wt.displayName="DataValidationIcon";var 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:"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=b.forwardRef(function(e,t){return b.createElement(_e,Object.assign({},e,{id:"delete-icon",ref:t,icon:cn}))});ct.displayName="DeleteIcon";var 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:"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"}}]},Vt=b.forwardRef(function(e,t){return b.createElement(_e,Object.assign({},e,{id:"increase-icon",ref:t,icon:un}))});Vt.displayName="IncreaseIcon";var 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:"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"}}]},ut=b.forwardRef(function(e,t){return b.createElement(_e,Object.assign({},e,{id:"more-down-icon",ref:t,icon:hn}))});ut.displayName="MoreDownIcon";var gn={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"}}]},Et=b.forwardRef(function(e,t){return b.createElement(_e,Object.assign({},e,{id:"more-up-icon",ref:t,icon:gn}))});Et.displayName="MoreUpIcon";var pn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{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:{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:{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:{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:{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:{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"}}]}]},Mt=b.forwardRef(function(e,t){return b.createElement(_e,Object.assign({},e,{id:"sequence-icon",ref:t,icon:pn}))});Mt.displayName="SequenceIcon";function vn(e){var c;const t=E.useDependency(o.LocaleService),a=E.useDependency(E.ComponentManager),{value:n,onChange:r,extraComponent:i}=e,[s,d]=b.useState(!1),l=i?a.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(Et,{className:"univer-ml-1"}):p.jsx(ut,{className:"univer-ml-1"})]}),s&&p.jsxs(p.Fragment,{children:[l?p.jsx(l,{value:n,onChange:r}):null,p.jsx(V.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:p.jsxs(V.RadioGroup,{value:`${(c=n.errorStyle)!=null?c:o.DataValidationErrorStyle.WARNING}`,onChange:h=>r({...n,errorStyle:+h}),children:[p.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),p.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),p.jsx(V.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:p.jsx(V.Checkbox,{checked:n.showErrorMessage,onChange:()=>r({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?p.jsx(V.FormLayout,{children:p.jsx(V.Input,{value:n.error,onChange:h=>r({...n,error:h})})}):null]})]})}const mn=e=>o.debounce(async(t,a,n,r)=>{const i=await e.executeCommand(t,a,n);r==null||r(i)},1e3);function fn(e,t,a){var n,r,i,s;return t?((r=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:r.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Sn(){var A,$;const[e,t]=b.useState(0),a=E.useDependency(ue),n=E.useObservable(a.activeRule$,a.activeRule),{unitId:r,subUnitId:i,rule:s}=n||{},d=s.uid,l=E.useDependency(Y.DataValidatorRegistryService),c=E.useDependency(o.IUniverInstanceService),h=E.useDependency(E.ComponentManager),g=E.useDependency(o.ICommandService),u=E.useDependency(Y.DataValidationModel),C=E.useDependency(o.LocaleService),[v,T]=b.useState(s),M=l.getValidatorItem(v.type),[m,f]=b.useState(!1),S=l.getValidatorsByScope(Y.DataValidatorRegistryScope.SHEET),[D,R]=b.useState(()=>v.ranges.map(_=>({unitId:"",sheetId:"",range:_}))),y=b.useMemo(()=>mn(g),[g]),[w,U]=b.useState(!1),[W,O]=b.useState(!1),j=b.useRef(null),x=E.useDependency(H.SheetsSelectionsService);if(b.useEffect(()=>()=>{const _=x.getCurrentLastSelection();_&&x.setSelections([_])},[x]),b.useEffect(()=>{g.onCommandExecuted(_=>{(_.id===o.UndoCommand.id||_.id===o.RedoCommand.id)&&setTimeout(()=>{const k=u.getRuleById(r,i,d);t(X=>X+1),k&&(T(k),R(k.ranges.map(X=>({unitId:"",sheetId:"",range:X}))))},20)})},[g,u,d,i,r]),!M)return null;const F=M.operators,B=M.operatorNames,K=v.operator?Y.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,z=()=>{var _,k,X;(k=(_=j.current)==null?void 0:_.editor)!=null&&k.isFocus()&&ee((X=j.current)==null?void 0:X.getValue()),!(!v.ranges.length||w)&&(M.validatorFormula(v,r,i).success?a.setActiveRule(null):f(!0))},ee=E.useEvent(_=>{const k=_.split(",").filter(Boolean).map(nt.deserializeRangeWithSheet).map(ne=>{const ht=ne.sheetName;if(ht){const At=fn(c,ne.unitId,ht);return{...ne,sheetId:At}}return{...ne,sheetId:""}});if(o.isUnitRangesEqual(k,D))return;R(k);const X=k.filter(ne=>(!ne.unitId||ne.unitId===r)&&(!ne.sheetId||ne.sheetId===i)).map(ne=>ne.range);if(T({...v,ranges:X}),X.length===0)return;const he={unitId:r,subUnitId:i,ruleId:d,ranges:X};y(I.UpdateSheetDataValidationRangeCommand.id,he)}),ae=_=>{if(o.shallowEqual(_,Y.getRuleSetting(v)))return;T({...v,..._});const k={unitId:r,subUnitId:i,ruleId:d,setting:_};y(I.UpdateSheetDataValidationSettingCommand.id,k,void 0)},re=async()=>{await g.executeCommand(I.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:r,subUnitId:i}),a.setActiveRule(null)},se={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},J=_=>{const k=l.getValidatorItem(_);if(!k)return;const X=k.operators,he=u.getRuleById(r,i,d),ne=_===(he==null?void 0:he.type)||_.includes("list")&&(he!=null&&he.type.includes("list"))?{...he,type:_}:{...v,type:_,operator:X[0],formula1:void 0,formula2:void 0};T(ne),g.executeCommand(I.UpdateSheetDataValidationSettingCommand.id,{unitId:r,subUnitId:i,ruleId:v.uid,setting:Y.getRuleSetting(ne)})},Z=h.get(M.formulaInput),ce=b.useMemo(()=>D.map(_=>nt.serializeRange(_.range)).join(","),[]),te=Y.getRuleOptions(v),Q=_=>{o.shallowEqual(_,Y.getRuleOptions(v))||(T({...v,..._}),y(I.UpdateSheetDataValidationOptionsCommand.id,{unitId:r,subUnitId:i,ruleId:d,options:_}))},q=F.length&&!v.operator;return p.jsxs("div",{"data-u-comp":"data-validation-detail",className:"univer-py-2",children:[p.jsx(V.FormLayout,{label:C.t("dataValidation.panel.range"),error:!v.ranges.length||w?C.t("dataValidation.panel.rangeError"):"",children:p.jsx(st.RangeSelector,{selectorRef:j,unitId:r,subUnitId:i,initialValue:ce,onChange:(_,k)=>{var X;!W&&((X=j.current)!=null&&X.verify())&&ee(k)},onFocusChange:(_,k)=>{var X;O(_),!_&&k&&((X=j.current)!=null&&X.verify())&&ee(k)},onVerify:_=>U(!_)})}),p.jsx(V.FormLayout,{label:C.t("dataValidation.panel.type"),children:p.jsx(V.Select,{className:"univer-w-full",value:v.type,options:(A=S==null?void 0:S.sort((_,k)=>_.order-k.order))==null?void 0:A.map(_=>({label:C.t(_.title),value:_.id})),onChange:J})}),F!=null&&F.length?p.jsx(V.FormLayout,{label:C.t("dataValidation.panel.operator"),children:p.jsx(V.Select,{className:"univer-w-full",value:`${v.operator}`,options:[{value:"",label:C.t("dataValidation.operators.legal")},...F.map((_,k)=>({value:`${_}`,label:B[k]}))],onChange:_=>{ae({...se,operator:_})}})}):null,Z&&!q?p.jsx(Z,{isTwoFormula:K,value:{formula1:v.formula1,formula2:v.formula2},onChange:_=>{ae({...se,..._})},showError:m,validResult:M.validatorFormula(v,r,i),unitId:r,subUnitId:i,ruleId:d},e+v.type):null,p.jsx(V.FormLayout,{children:p.jsx(V.Checkbox,{checked:($=v.allowBlank)!=null?$:!0,onChange:()=>{var _;return ae({...se,allowBlank:!((_=v.allowBlank)==null||_)})},children:C.t("dataValidation.panel.allowBlank")})}),p.jsx(vn,{value:te,onChange:Q,extraComponent:M.optionsInput}),p.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[p.jsx(V.Button,{className:"univer-ml-3",onClick:re,children:C.t("dataValidation.panel.removeRule")}),p.jsx(V.Button,{className:"univer-ml-3",variant:"primary",onClick:z,children:C.t("dataValidation.panel.done")})]})]})}const _n=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:r,disable:i}=e,s=E.useDependency(Y.DataValidatorRegistryService),d=E.useDependency(o.ICommandService),l=E.useDependency(N.IMarkSelectionService),c=s.getValidatorItem(t.type),h=b.useRef(void 0),[g,u]=b.useState(!1),C=E.useDependency(o.ThemeService),v=E.useObservable(C.currentTheme$),T=b.useMemo(()=>{var R;const m=C.getColorFromTheme("primary.600"),f=C.getColorFromTheme("loop-color.2"),S=(R=C.getColorFromTheme(f))!=null?R:m,D=new o.ColorKit(S).toRgb();return{fill:`rgba(${D.r}, ${D.g}, ${D.b}, 0.1)`,stroke:S}},[v]),M=m=>{d.executeCommand(I.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:r}),m.stopPropagation()};return b.useEffect(()=>()=>{var m;h.current&&((m=h.current)==null||m.forEach(f=>{f&&l.removeShape(f)}))},[l]),p.jsxs("div",{className:V.clsx(`
|
1
|
+
"use strict";var Lt=Object.defineProperty;var Pt=(e,t,a)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var L=(e,t,a)=>Pt(e,typeof t!="symbol"?t+"":t,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),P=require("@univerjs/engine-render"),$=require("@univerjs/sheets"),C=require("@univerjs/sheets-data-validation"),Y=require("@univerjs/data-validation"),E=require("@univerjs/ui"),ie=require("rxjs"),xt=require("@univerjs/sheets-numfmt"),B=require("@univerjs/sheets-ui"),V=require("@univerjs/design"),T=require("react"),g=require("react/jsx-runtime"),nt=require("@univerjs/engine-formula"),st=require("@univerjs/sheets-formula-ui");var jt=Object.getOwnPropertyDescriptor,Ut=(e,t,a,n)=>{for(var r=n>1?void 0:n?jt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},gt=(e,t)=>(a,n)=>t(a,n,e);let ce=class extends o.Disposable{constructor(t,a){super();L(this,"_open$",new ie.BehaviorSubject(!1));L(this,"open$",this._open$.pipe(ie.distinctUntilChanged()));L(this,"_activeRule");L(this,"_activeRule$",new ie.BehaviorSubject(void 0));L(this,"activeRule$",this._activeRule$.asObservable());L(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(ie.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===Fe&&(n.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=Ut([gt(0,o.IUniverInstanceService),gt(1,E.ISidebarService)],ce);const me="#ECECEC",lt="sheets-data-validation-ui.config",Ue={};var Ft=Object.getOwnPropertyDescriptor,kt=(e,t,a,n)=>{for(var r=n>1?void 0:n?Ft(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ie=(e,t)=>(a,n)=>t(a,n,e);let we=class extends o.Disposable{constructor(e,t,a,n,r,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=r,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept($.VALIDATE_CELL,{handler:async(e,t,a)=>{const n=await e,{row:r,col:i,unitId:s,subUnitId:d}=t,l=this._dataValidationModel.getRuleIdByLocation(s,d,r,i),c=l?this._dataValidationModel.getRuleById(s,d,l):void 0;if(n===!1)return a(Promise.resolve(!1));if(!c||c.errorStyle!==o.DataValidationErrorStyle.STOP)return a(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,r,i)===o.DataValidationStatus.VALID?a(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:r,col:i,unitId:s,subUnitId:d})},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")}}),a(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")}})}};we=kt([Ie(0,o.Inject($.SheetInterceptorService)),Ie(1,o.Inject(C.SheetDataValidationModel)),Ie(2,o.Inject(Y.DataValidatorRegistryService)),Ie(3,E.IDialogService),Ie(4,o.Inject(o.LocaleService)),Ie(5,o.Inject(C.SheetsDataValidationValidatorService))],we);var Nt=Object.getOwnPropertyDescriptor,Bt=(e,t,a,n)=>{for(var r=n>1?void 0:n?Nt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},se=(e,t)=>(a,n)=>t(a,n,e);const Ye=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 Wt(e,t){const a=xt.getPatternType(t);if(e===a)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 fe=class extends o.Disposable{constructor(t,a,n,r,i,s,d,l,c,h,v){super();L(this,"_activeDropdown");L(this,"_activeDropdown$",new ie.Subject);L(this,"_currentPopup",null);L(this,"activeDropdown$",this._activeDropdown$.asObservable());L(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=a,this._zenZoneService=n,this._dataValidationModel=r,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,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,a,n,r){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=a?i.getSheetBySheetId(a):i.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,r);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(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var O,M,R,y;const{location:a}=t,{row:n,col:r,unitId:i,subUnitId:s,workbook:d,worksheet:l}=a;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(i,s,n,r);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let v;const u=async(m,D)=>{var A,j,N;if(!m)return!0;const I=m,f=l.getCell(n,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,W=D==="time"?F%1:F,x=d.getStyles().getStyleByCell(f),k=(N=(j=x==null?void 0:x.n)==null?void 0:j.pattern)!=null?N:"";return c.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:W,unitId:i,subUnitId:s,row:n,column:r,worksheet:l,workbook:d,interceptValue:w.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(await this._commandService.executeCommand($.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:W,t:2,p:null,f:null,si:null,s:{n:{pattern:Wt(D,k)}}}}),await this._commandService.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0):(this._injector.has(we)&&this._injector.get(we).showReject(h.getRuleFinalError(c,{row:n,col:r,unitId:i,subUnitId:s})),!1)};let S;switch(h.dropdownType){case Y.DataValidatorDropdownType.DATE:{const m=C.getCellValueOrigin(l.getCellRaw(n,r)),D=Ye(m),I=!!((O=c.bizInfo)!=null&&O.showTime);S={location:a,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(n,r)),D=Ye(m);S={location:a,type:"datepicker",props:{onChange:I=>u(I,"time"),defaultValue:D,patternType:"time"}};break}case Y.DataValidatorDropdownType.DATETIME:{const m=C.getCellValueOrigin(l.getCellRaw(n,r)),D=Ye(m);S={location:a,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 x=>{const k=C.serializeListOptions(x),A={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:k,p:null,f:null,si:null}};return this._commandService.executeCommand($.SetRangeValuesCommand.id,A),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!m},I=(c==null?void 0:c.renderMode)===o.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,f=h.getListWithColor(c,i,s),w=C.getDataValidationCellValue(l.getCellRaw(n,r)),F=()=>{this._commandService.executeCommand(Se.id,{ruleId:c.uid}),v==null||v.dispose()},W=f.map(x=>({label:x.label,value:x.label,color:I||x.color?x.color||me:"transparent"}));S={location:a,type:"list",props:{onChange:x=>D(x),options:W,onEdit:F,defaultValue:w,multiple:m,showEdit:(R=(M=this._configService.getConfig(lt))==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:n,endRow:n},value:{v:D.join("/"),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand($.SetRangeValuesCommand.id,I),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0},defaultValue:C.getDataValidationCellValue(l.getCellRaw(n,r)).split("/"),options:JSON.parse((y=c.formula1)!=null?y:"[]")},location:a};break}case Y.DataValidatorDropdownType.COLOR:{S={type:"color",props:{onChange:D=>{const I={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:D,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand($.SetRangeValuesCommand.id,I),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0},defaultValue:C.getDataValidationCellValue(l.getCellRaw(n,r))},location:a};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,a,n,r,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(a);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,r);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:n,col:r,unitId:t,subUnitId:a},onHide:i})}};fe=Bt([se(0,o.IUniverInstanceService),se(1,o.Inject(Y.DataValidatorRegistryService)),se(2,E.IZenZoneService),se(3,o.Inject(C.SheetDataValidationModel)),se(4,o.Inject($.SheetsSelectionsService)),se(5,o.Inject(B.ISheetCellDropdownManagerService)),se(6,o.Inject(C.SheetDataValidationModel)),se(7,o.ICommandService),se(8,B.IEditorBridgeService),se(9,o.Inject(o.Injector)),se(10,o.IConfigService)],fe);const Fe="DataValidationPanel",Se={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,r=e.get(ce),i=e.get(Y.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(E.ISidebarService),l=$.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,v=a?i.getRuleById(c,h,a):void 0;r.open(),r.setActiveRule(v&&{unitId:c,subUnitId:h,rule:v});const u=d.open({id:Fe,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Fe},width:312,onClose:()=>r.close()});return r.setCloseDisposable(u),!0}},dt={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ce).close(),!0}},_t={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),a=e.get(ce);return a.open(),a.isOpen?t.executeCommand(dt.id):t.executeCommand(Se.id),!0}},He={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(fe),{unitId:n,subUnitId:r,row:i,column:s}=t,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===r&&l.row===i&&l.col===s||a.showDataValidationDropdown(n,r,i,s),!0}},It={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},$e={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),a=$.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:r}=a,i=C.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=r.getSheetId(),c={rule:i,unitId:d,subUnitId:l};return s.syncExecuteCommand(C.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(Se.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var Ht=Object.getOwnPropertyDescriptor,$t=(e,t,a,n)=>{for(var r=n>1?void 0:n?Ht(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ce=(e,t)=>(a,n)=>t(a,n,e);const pe="SHEET_DATA_VALIDATION_ALERT";let Ae=class extends o.Disposable{constructor(e,t,a,n,r,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=r,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ie.debounceTime(100)).subscribe(e=>{var t;if(e){const a=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),n=a.getSheetBySheetId(e.location.subUnitId);if(!n)return;const r=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!r){this._cellAlertManagerService.removeAlert(pe);return}if(this._dataValidationModel.validator(r,{...e.location,workbook:a,worksheet:n})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(pe),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(pe);return}const l=this._dataValidationModel.getValidator(r.type);if(!l){this._cellAlertManagerService.removeAlert(pe);return}this._cellAlertManagerService.showAlert({type:B.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:pe});return}}this._cellAlertManagerService.removeAlert(pe)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(pe)}))}};Ae=$t([Ce(0,o.Inject(B.HoverManagerService)),Ce(1,o.Inject(B.CellAlertManagerService)),Ce(2,o.IUniverInstanceService),Ce(3,o.Inject(o.LocaleService)),Ce(4,E.IZenZoneService),Ce(5,o.Inject(C.SheetDataValidationModel))],Ae);var Yt=Object.getOwnPropertyDescriptor,Xt=(e,t,a,n)=>{for(var r=n>1?void 0:n?Yt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Xe=(e,t)=>(a,n)=>t(a,n,e);let Ve=class extends o.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,r)=>{const{source:i,target:s,unitId:d,subUnitId:l}=n,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=B.virtualizeDiscreteRanges([i,s]),[v,u]=h.ranges,{mapFunc:S}=h,p={row:v.startRow,col:v.startColumn},O=B.getAutoFillRepeatRange(v,u),M=new o.ObjectMatrix,R=new Set;O.forEach(f=>{const w=f.repeatStartCell,F=f.relativeRange,W={startRow:p.row,startColumn:p.col,endColumn:p.col,endRow:p.row},x={startRow:w.row,startColumn:w.col,endColumn:w.col,endRow:w.row};o.Range.foreach(F,(k,A)=>{const j=o.Rectangle.getPositionRange({startRow:k,startColumn:A,endColumn:A,endRow:k},W),{row:N,col:z}=S(j.startRow,j.startColumn),q=this._sheetDataValidationModel.getRuleIdByLocation(d,l,N,z)||"",te=o.Rectangle.getPositionRange({startRow:k,startColumn:A,endColumn:A,endRow:k},x),{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)}));c.addRangeRules(y);const m=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:D,undoMutations:I}=C.getDataValidationDiffMutations(d,l,m,this._injector,"patched",r===B.APPLY_TYPE.ONLY_FORMAT);return{undos:I,redos:D}},a={id:C.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:r,unitId:i,subUnitId:s}=n;for(const d of r.rows)for(const l of r.cols){const c=this._sheetDataValidationModel.getRuleByLocation(i,s,d,l);if(c&&c.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(B.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,r,i)=>i===B.APPLY_TYPE.COPY||i===B.APPLY_TYPE.ONLY_FORMAT||i===B.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};Ve=Xt([Xe(0,B.IAutoFillService),Xe(1,o.Inject(C.SheetDataValidationModel)),Xe(2,o.Inject(o.Injector))],Ve);var zt=Object.getOwnPropertyDescriptor,Kt=(e,t,a,n)=>{for(var r=n>1?void 0:n?zt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ze=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends o.Disposable{constructor(t,a,n){super();L(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:C.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,r)=>{const{copyType:i=B.COPY_TYPE.COPY,pasteType:s}=r,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=a;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,a,n){const r=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:r};const i=this._injector.invoke(l=>$.rangeToDiscreteRange(n,l,t,a));if(!i)return;const{rows:s,cols:d}=i;s.forEach((l,c)=>{d.forEach((h,v)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,a,l,h);r.setValue(c,v,u!=null?u:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===B.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:i}=this._copyInfo;if(a.unitId!==r||i!==a.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:v}=B.virtualizeDiscreteRanges([a.copyRange,t]),u=B.getRepeatRange(c,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(a.unitId,a.subUnitId,w)&&F&&S.set(w,{...F,uid:w});const{row:W,col:x}=v(f.startRow,f.startColumn);l.add(w),d.setValue(W,x,w)})});const p=Array.from(l).map(R=>({id:R,ranges:o.queryObjectMatrix(d,y=>y===R)}));s.addRangeRules(p);const{redoMutations:O,undoMutations:M}=C.getDataValidationDiffMutations(a.unitId,a.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),S.values()),this._injector,"patched",!1);return{redos:O,undos:M}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(r,i).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:v}=B.virtualizeDiscreteRanges([a.copyRange,t]);B.getRepeatRange(c,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);d.setValue(f,w,D),l.add(D)})});const S=Array.from(l).map(M=>({id:M,ranges:o.queryObjectMatrix(d,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}}}};Ee=Kt([ze(0,B.ISheetClipboardService),ze(1,o.Inject(C.SheetDataValidationModel)),ze(2,o.Inject(o.Injector))],Ee);var Zt=Object.getOwnPropertyDescriptor,Gt=(e,t,a,n)=>{for(var r=n>1?void 0:n?Zt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ke=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends o.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===C.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[$.WorkbookEditablePermission],rangeTypes:[$.RangeProtectionPermissionEditPoint],worksheetTypes:[$.WorksheetEditPermission,$.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===C.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[$.WorkbookEditablePermission],rangeTypes:[$.RangeProtectionPermissionEditPoint],worksheetTypes:[$.WorksheetEditPermission,$.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Me=Gt([Ke(0,o.Inject(o.LocaleService)),Ke(1,o.ICommandService),Ke(2,o.Inject($.SheetPermissionCheckController))],Me);const Ct="sheet.menu.data-validation";function qt(e){return{id:Ct,type:E.MenuItemType.SUBITEMS,icon:"DataValidationIcon",tooltip:"dataValidation.title",hidden$:E.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:B.getCurrentRangeDisable$(e,{workbookTypes:[$.WorkbookEditablePermission],worksheetTypes:[$.WorksheetSetCellStylePermission,$.WorksheetEditPermission],rangeTypes:[$.RangeProtectionPermissionEditPoint]})}}function Jt(e){return{id:Se.id,title:"dataValidation.panel.title",type:E.MenuItemType.BUTTON}}function Qt(e){return{id:$e.id,title:"dataValidation.panel.add",type:E.MenuItemType.BUTTON}}const en={[E.RibbonDataGroup.RULES]:{[Ct]:{order:0,menuItemFactory:qt,[Se.id]:{order:0,menuItemFactory:Jt},[$e.id]:{order:1,menuItemFactory:Qt}}}};var tn=Object.getOwnPropertyDescriptor,yt=(e,t,a,n)=>{for(var r=n>1?void 0:n?tn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},G=(e,t)=>(a,n)=>t(a,n,e);const Rt={tr:{size:6,color:"#fe4b4b"}};let be=class extends o.RxDisposable{constructor(e,t,a,n,r,i,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=r,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(en)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var a;if(!e.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:r,row:i,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,r,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 v=this._dropdownManagerService.activeDropdown,u=v==null?void 0:v.location;if(u&&u.unitId===n&&u.subUnitId===r&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:r,row:i,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept($.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:$.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var R,y,m,D,I;const{row:n,col:r,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,r);if(!c)return a(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return a(e);const v=(R=this._dataValidationCacheService.getValue(i,s,n,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?Rt: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=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?f.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,r)},e.interceptorAutoHeight=()=>{var W,x,k,A,j,N;const f=(x=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:x.skeleton;if(!f)return;const w=f.worksheet.getMergedCell(n,r),F={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:f.getCellWithCoordByIndex((k=w==null?void 0:w.startRow)!=null?k:n,(A=w==null?void 0:w.startColumn)!=null?A:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(N=(j=u==null?void 0:u.canvasRender)==null?void 0:j.calcCellAutoHeight)==null?void 0:N.call(j,F)},e.interceptorAutoWidth=()=>{var W,x,k,A,j,N;const f=(x=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:x.skeleton;if(!f)return;const w=f.worksheet.getMergedCell(n,r),F={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:f.getCellWithCoordByIndex((k=w==null?void 0:w.startRow)!=null?k:n,(A=w==null?void 0:w.startColumn)!=null?A:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(N=(j=u==null?void 0:u.canvasRender)==null?void 0:j.calcCellAutoWidth)==null?void 0:N.call(j,F)},e.coverable=((I=e==null?void 0:e.coverable)!=null?I:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),a(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(a=>{var n;(a.rule.type===o.DataValidationType.LIST_MULTIPLE||a.rule.type===o.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};be=yt([G(0,o.ICommandService),G(1,E.IMenuManagerService),G(2,P.IRenderManagerService),G(3,o.IUniverInstanceService),G(4,o.Inject(B.AutoHeightController)),G(5,o.Inject(fe)),G(6,o.Inject(C.SheetDataValidationModel)),G(7,o.Inject(Y.DataValidatorRegistryService)),G(8,o.Inject($.SheetInterceptorService)),G(9,o.Inject(C.DataValidationCacheService)),G(10,o.Optional(B.IEditorBridgeService))],be);let pt=class extends o.RxDisposable{constructor(e,t,a,n,r,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=r,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept($.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:$.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var M,R,y,m,D;const{row:n,col:r,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,r);if(!c)return a(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return a(e);const v=(M=this._dataValidationCacheService.getValue(i,s,n,r))!=null?M:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=l.getCellRaw(n,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?Rt: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=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)||{}}},n,r)},e.interceptorAutoHeight=()=>{var F,W,x,k,A,j;const I=(W=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!I)return;const f=I.worksheet.getMergedCell(n,r),w={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((x=f==null?void 0:f.startRow)!=null?x:n,(k=f==null?void 0:f.startColumn)!=null?k:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(j=(A=u==null?void 0:u.canvasRender)==null?void 0:A.calcCellAutoHeight)==null?void 0:j.call(A,w)},e.interceptorAutoWidth=()=>{var F,W,x,k,A,j;const I=(W=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!I)return;const f=I.worksheet.getMergedCell(n,r),w={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((x=f==null?void 0:f.startRow)!=null?x:n,(k=f==null?void 0:f.startColumn)!=null?k:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(j=(A=u==null?void 0:u.canvasRender)==null?void 0:A.calcCellAutoWidth)==null?void 0:j.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),a(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(a.rule.type===o.DataValidationType.LIST_MULTIPLE||a.rule.type===o.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};pt=yt([G(0,o.ICommandService),G(1,P.IRenderManagerService),G(2,o.Inject(B.AutoHeightController)),G(3,o.Inject(Y.DataValidatorRegistryService)),G(4,o.Inject($.SheetInterceptorService)),G(5,o.Inject(C.SheetDataValidationModel)),G(6,o.Inject(C.DataValidationCacheService))],pt);var nn=Object.getOwnPropertyDescriptor,an=(e,t,a,n)=>{for(var r=n>1?void 0:n?nn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},vt=(e,t)=>(a,n)=>t(a,n,e);let ke=class extends o.Disposable{constructor(e,t,a){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const a=new Set;t.forEach(r=>{a.add(r.subUnitId)}),a.forEach(r=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(r))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};ke=an([vt(1,o.Inject(C.SheetDataValidationModel)),vt(2,o.Inject(B.SheetSkeletonManagerService))],ke);var re=function(){return re=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},re.apply(this,arguments)},rn=function(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(a[n[r]]=e[n[r]]);return a},_e=T.forwardRef(function(e,t){var a=e.icon,n=e.id,r=e.className,i=e.extend,s=rn(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),l=T.useRef("_".concat(ln()));return Dt(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},re({ref:t,className:d},s),i)});function Dt(e,t,a,n,r){return T.createElement(e.tag,re(re({key:t},on(e,a,r)),n),(sn(e,a).children||[]).map(function(i,s){return Dt(i,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,r)}))}function on(e,t,a){var n=re({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];s==="mask"&&typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var r=t.defIds;return!r||r.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function sn(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?re(re({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.includes(r.attrs.id)?re(re({},r),{attrs:re(re({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):e}function ln(){return Math.random().toString(36).substring(2,8)}_e.displayName="UniverIcon";var dn={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"}}]},wt=T.forwardRef(function(e,t){return T.createElement(_e,Object.assign({},e,{id:"data-validation-icon",ref:t,icon:dn}))});wt.displayName="DataValidationIcon";var 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:"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(e,t){return T.createElement(_e,Object.assign({},e,{id:"delete-icon",ref:t,icon:cn}))});ct.displayName="DeleteIcon";var 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:"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"}}]},Vt=T.forwardRef(function(e,t){return T.createElement(_e,Object.assign({},e,{id:"increase-icon",ref:t,icon:un}))});Vt.displayName="IncreaseIcon";var 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:"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"}}]},ut=T.forwardRef(function(e,t){return T.createElement(_e,Object.assign({},e,{id:"more-down-icon",ref:t,icon:hn}))});ut.displayName="MoreDownIcon";var gn={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"}}]},Et=T.forwardRef(function(e,t){return T.createElement(_e,Object.assign({},e,{id:"more-up-icon",ref:t,icon:gn}))});Et.displayName="MoreUpIcon";var pn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{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:{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:{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:{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:{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:{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"}}]}]},Mt=T.forwardRef(function(e,t){return T.createElement(_e,Object.assign({},e,{id:"sequence-icon",ref:t,icon:pn}))});Mt.displayName="SequenceIcon";function vn(e){var c;const t=E.useDependency(o.LocaleService),a=E.useDependency(E.ComponentManager),{value:n,onChange:r,extraComponent:i}=e,[s,d]=T.useState(!1),l=i?a.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:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?g.jsx(Et,{className:"univer-ml-1"}):g.jsx(ut,{className:"univer-ml-1"})]}),s&&g.jsxs(g.Fragment,{children:[l?g.jsx(l,{value:n,onChange:r}):null,g.jsx(V.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:g.jsxs(V.RadioGroup,{value:`${(c=n.errorStyle)!=null?c:o.DataValidationErrorStyle.WARNING}`,onChange:h=>r({...n,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:n.showErrorMessage,onChange:()=>r({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?g.jsx(V.FormLayout,{children:g.jsx(V.Input,{value:n.error,onChange:h=>r({...n,error:h})})}):null]})]})}const mn=e=>o.debounce(async(t,a,n,r)=>{const i=await e.executeCommand(t,a,n);r==null||r(i)},1e3);function fn(e,t,a){var n,r,i,s;return t?((r=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:r.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Sn(){var b,H;const[e,t]=T.useState(0),a=E.useDependency(ce),n=E.useObservable(a.activeRule$,a.activeRule),{unitId:r,subUnitId:i,rule:s}=n||{},d=s.uid,l=E.useDependency(Y.DataValidatorRegistryService),c=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(()=>mn(v),[v]),[w,F]=T.useState(!1),[W,x]=T.useState(!1),k=T.useRef(null),A=E.useDependency($.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,d);t(X=>X+1),U&&(O(U),I(U.ranges.map(X=>({unitId:"",sheetId:"",range:X}))))},20)})},[v,u,d,i,r]),!M)return null;const j=M.operators,N=M.operatorNames,z=p.operator?Y.TWO_FORMULA_OPERATOR_COUNT.includes(p.operator):!1,q=()=>{var _,U,X;(U=(_=k.current)==null?void 0:_.editor)!=null&&U.isFocus()&&te((X=k.current)==null?void 0:X.getValue()),!(!p.ranges.length||w)&&(M.validatorFormula(p,r,i).success?a.setActiveRule(null):y(!0))},te=E.useEvent(_=>{const U=_.split(",").filter(Boolean).map(nt.deserializeRangeWithSheet).map(ee=>{const ht=ee.sheetName;if(ht){const At=fn(c,ee.unitId,ht);return{...ee,sheetId:At}}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 oe={unitId:r,subUnitId:i,ruleId:d,ranges:X};f(C.UpdateSheetDataValidationRangeCommand.id,oe)}),K=_=>{if(o.shallowEqual(_,Y.getRuleSetting(p)))return;O({...p,..._});const U={unitId:r,subUnitId:i,ruleId:d,setting:_};f(C.UpdateSheetDataValidationSettingCommand.id,U,void 0)},ne=async()=>{await v.executeCommand(C.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:r,subUnitId:i}),a.setActiveRule(null)},ae={type:p.type,operator:p.operator,formula1:p.formula1,formula2:p.formula2,allowBlank:p.allowBlank},ue=_=>{const U=l.getValidatorItem(_);if(!U)return;const X=U.operators,oe=u.getRuleById(r,i,d),ee=_===(oe==null?void 0:oe.type)||_.includes("list")&&(oe!=null&&oe.type.includes("list"))?{...oe,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)})},he=h.get(M.formulaInput),J=T.useMemo(()=>D.map(_=>nt.serializeRange(_.range)).join(","),[]),Z=Y.getRuleOptions(p),de=_=>{o.shallowEqual(_,Y.getRuleOptions(p))||(O({...p,..._}),f(C.UpdateSheetDataValidationOptionsCommand.id,{unitId:r,subUnitId:i,ruleId:d,options:_}))},Q=j.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(st.RangeSelector,{selectorRef:k,unitId:r,subUnitId:i,initialValue:J,onChange:(_,U)=>{var X;!W&&((X=k.current)!=null&&X.verify())&&te(U)},onFocusChange:(_,U)=>{var X;x(_),!_&&U&&((X=k.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:ue})}),j!=null&&j.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")},...j.map((_,U)=>({value:`${_}`,label:N[U]}))],onChange:_=>{K({...ae,operator:_})}})}):null,he&&!Q?g.jsx(he,{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:d},e+p.type):null,g.jsx(V.FormLayout,{children:g.jsx(V.Checkbox,{checked:(H=p.allowBlank)!=null?H:!0,onChange:()=>{var _;return K({...ae,allowBlank:!((_=p.allowBlank)==null||_)})},children:S.t("dataValidation.panel.allowBlank")})}),g.jsx(vn,{value:Z,onChange:de,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 _n=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:r,disable:i}=e,s=E.useDependency(Y.DataValidatorRegistryService),d=E.useDependency(o.ICommandService),l=E.useDependency(B.IMarkSelectionService),c=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=>{d.executeCommand(C.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,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
|
5
|
-
`,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!i,"univer-opacity-50":i}),onClick:a,onMouseEnter:()=>{i||(u(!0),h.current=t.ranges.map(m=>l.addShape({range:m,style:T,primary:null})))},onMouseLeave:()=>{var m;u(!1),(m=h.current)==null||m.forEach(f=>{f&&l.removeShape(f)}),h.current=void 0},children:[p.jsx("div",{className:"univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-white",children:c==null?void 0:c.generateRuleName(t)}),p.jsx("div",{className:"univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300",children:t.ranges.map(m=>nt.serializeRange(m)).join(",")}),g?p.jsx("div",{className:"univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-h-5 univer-w-5 univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-200 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700",onClick:M,children:p.jsx(ct,{})}):null]})};function In(e){const t=E.useDependency(I.SheetDataValidationModel),a=E.useDependency(o.IUniverInstanceService),n=E.useDependency(o.ICommandService),r=E.useDependency(o.Injector),i=E.useDependency(ue),s=E.useDependency(o.LocaleService),[d,l]=b.useState([]),{workbook:c}=e,h=E.useObservable(c.activeSheet$,void 0,!0),g=c.getUnitId(),u=h==null?void 0:h.getSheetId();b.useEffect(()=>{l(t.getRules(g,u));const f=t.ruleChange$.subscribe(S=>{S.unitId===g&&S.subUnitId===u&&l(t.getRules(g,u))});return()=>{f.unsubscribe()}},[g,u,t]);const C=async()=>{const f=I.createDefaultNewRule(r),S={unitId:g,subUnitId:u,rule:f};await n.executeCommand(I.AddSheetDataValidationCommand.id,S),i.setActiveRule({unitId:g,subUnitId:u,rule:f})},v=()=>{n.executeCommand(I.RemoveSheetAllDataValidationCommand.id,{unitId:g,subUnitId:u})},M=(f=>{const S=a.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),D=S.getActiveSheet(),R=S.getUnitId(),y=D.getSheetId();return f.map(U=>H.checkRangesEditablePermission(r,R,y,U.ranges)?{...U}:{...U,disable:!0})})(d),m=M==null?void 0:M.some(f=>f.disable);return p.jsxs("div",{className:"univer-pb-4",children:[M==null?void 0:M.map(f=>{var S;return p.jsx(_n,{unitId:g,subUnitId:u,onClick:()=>{f.disable||i.setActiveRule({unitId:g,subUnitId:u,rule:f})},rule:f,disable:(S=f.disable)!=null?S:!1},f.uid)}),p.jsxs("div",{className:"univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[d.length&&!m?p.jsx(V.Button,{onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,p.jsx(V.Button,{variant:"primary",onClick:C,children:s.t("dataValidation.panel.add")})]})]})}const Cn=()=>{const e=E.useDependency(ue),t=E.useObservable(e.activeRule$,e.activeRule),a=E.useDependency(o.IUniverInstanceService),n=E.useObservable(()=>a.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),r=E.useObservable(()=>{var i;return(i=n==null?void 0:n.activeSheet$)!=null?i:oe.of(null)},void 0,void 0,[]);return!n||!r?null:t&&t.subUnitId===r.getSheetId()?p.jsx(Sn,{},t.rule.uid):p.jsx(In,{workbook:n})},yn=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:r,validResult:i}=e,s=E.useDependency(o.LocaleService),d=r?i==null?void 0:i.formula1:"",l=r?i==null?void 0:i.formula2:"";return t?p.jsxs(p.Fragment,{children:[p.jsx(V.FormLayout,{error:d,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:c=>{n==null||n({...a,formula1:c})}})}),p.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),p.jsx(V.FormLayout,{error:l,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:c=>{n==null||n({...a,formula2:c})}})})]}):p.jsx(V.FormLayout,{error:d,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:c=>{n==null||n({formula1:c})}})})};function Rn(e){const{value:t,onChange:a,showError:n,validResult:r}=e,i=E.useDependency(o.LocaleService),s=n?r==null?void 0:r.formula1:"",d=n?r==null?void 0:r.formula2:"",[l,c]=b.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return p.jsxs(p.Fragment,{children:[p.jsx(V.FormLayout,{children:p.jsx(V.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?p.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{a==null||a({...t,formula1:h||void 0})}})}):null,l?p.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:d,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{a==null||a({...t,formula2:h||void 0})}})}):null]})}function Dn(e){var g;const{unitId:t,subUnitId:a,value:n,onChange:r,showError:i,validResult:s}=e,d=i?s==null?void 0:s.formula1:void 0,l=b.useRef(null),[c,h]=b.useState(!1);return E.useSidebarClick(u=>{var v;((v=l.current)==null?void 0:v.isClickOutSide(u))&&h(!1)}),p.jsx(V.FormLayout,{error:d,children:p.jsx(st.FormulaEditor,{ref:l,className:V.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",V.borderClassName),initValue:(g=n==null?void 0:n.formula1)!=null?g:"=",unitId:t,subUnitId:a,isFocus:c,isSupportAcrossSheet:!0,onChange:u=>{const C=(u!=null?u:"").trim();C!==(n==null?void 0:n.formula1)&&(r==null||r({...n,formula1:C}))},onFocus:()=>h(!0)})})}const wn=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Vn=e=>{const{value:t,onChange:a,disabled:n}=e,[r,i]=b.useState(!1);return p.jsx(V.Dropdown,{align:"start",disabled:n,open:r,onOpenChange:i,overlay:p.jsx("div",{className:"univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2 univer-p-1.5",children:wn.map(s=>p.jsx("div",{className:V.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",V.borderClassName),style:{background:s},onClick:()=>{a(s),i(!1)}},s))}),children:p.jsxs("div",{className:V.clsx("univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-white univer-px-2.5 univer-transition-colors univer-duration-200 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white",V.borderClassName),children:[p.jsx("div",{className:"univer-box-border univer-h-4 univer-w-4 univer-rounded univer-text-base",style:{background:t}}),p.jsx(ut,{})]})})},mt=e=>{const{item:t,commonProps:a,className:n}=e,{onItemChange:r,onItemDelete:i}=a;return p.jsxs("div",{className:V.clsx("univer-flex univer-items-center univer-gap-2",n),children:[!t.isRef&&p.jsx("div",{className:V.clsx("univer-cursor-move","draggableHandle"),children:p.jsx(Mt,{})}),p.jsx(Vn,{value:t.color,onChange:s=>{r(t.id,t.label,s)}}),p.jsx(V.Input,{disabled:t.isRef,value:t.label,onChange:s=>{r(t.id,s,t.color)}}),t.isRef?null:p.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:p.jsx(ct,{onClick:()=>i(t.id)})})]})};function En(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:r,validResult:i,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},[h,g]=b.useState(()=>o.isFormulaString(l)?"1":"0"),[u,C]=b.useState(h==="1"?l:"="),[v,T]=b.useState(h==="1"?l:"="),M=E.useDependency(o.LocaleService),m=E.useDependency(Y.DataValidatorRegistryService),f=E.useDependency(Y.DataValidationModel),S=E.useDependency(I.DataValidationFormulaController),[D,R]=b.useState(()=>c.split(",")),y=m.getValidatorItem(o.DataValidationType.LIST),[w,U]=b.useState([]),[W,O]=b.useState(""),j=s?i==null?void 0:i.formula1:"",x=b.useMemo(()=>f.ruleChange$.pipe(oe.debounceTime(16)),[]),F=E.useObservable(x),B=E.useEvent(a);b.useEffect(()=>{(async()=>{await new Promise(_=>{setTimeout(()=>_(!0),100)});const A=f.getRuleById(n,r,d),$=A==null?void 0:A.formula1;if(o.isFormulaString($)&&y&&A){const _=await y.getListAsync(A,n,r);U(_)}})()},[f,F,y,d,r,n]),b.useEffect(()=>{o.isFormulaString(l)&&l!==v&&(C(l),T(v))},[v,l]);const[K,z]=b.useState(()=>{const A=h!=="1"?I.deserializeListOptions(l):[],$=c.split(",");return A.map((_,k)=>({label:_,color:$[k]||me,isRef:!1,id:o.generateRandomId(4)}))}),ee=(A,$,_)=>{const k=K.find(X=>X.id===A);k&&(k.label=$,k.color=_,z([...K]))},ae=A=>{const $=K.findIndex(_=>_.id===A);$!==-1&&(K.splice($,1),z([...K]))},re=c.split(","),se=b.useMemo(()=>w.map((A,$)=>({label:A,color:re[$]||me,id:`${$}`,isRef:!0})),[re,w]),J=(A,$,_)=>{const k=[...D];k[+A]=_,R(k),B({formula1:l,formula2:k.join(",")})},Z=()=>{z([...K,{label:"",color:me,isRef:!1,id:o.generateRandomId(4)}])};b.useEffect(()=>{if(h==="1")return;const A=new Set,$=[];K.map(_=>({labelList:_.label.split(","),item:_})).forEach(({item:_,labelList:k})=>{k.forEach(X=>{A.has(X)||(A.add(X),$.push({label:X,color:_.color}))})}),B({formula1:I.serializeListOptions($.map(_=>_.label)),formula2:$.map(_=>_.color===me?"":_.color).join(",")})},[K,B,h,v,D]);const ce=E.useEvent(async A=>{if(!o.isFormulaString(A)){B==null||B({formula1:"",formula2:c});return}S.getFormulaRefCheck(A)?(B==null||B({formula1:o.isFormulaString(A)?A:"",formula2:c}),O("")):(B==null||B({formula1:"",formula2:c}),C("="),O(M.t("dataValidation.validFail.formulaError")))}),te=b.useRef(null),[Q,q]=b.useState(!1);return E.useSidebarClick(A=>{var _;((_=te.current)==null?void 0:_.isClickOutSide(A))&&q(!1)}),p.jsxs(p.Fragment,{children:[p.jsx(V.FormLayout,{label:M.t("dataValidation.list.options"),children:p.jsxs(V.RadioGroup,{value:h,onChange:A=>{g(A),C(v),A==="1"&&B({formula1:v==="="?"":v,formula2:D.join(",")})},children:[p.jsx(V.Radio,{value:"0",children:M.t("dataValidation.list.customOptions")}),p.jsx(V.Radio,{value:"1",children:M.t("dataValidation.list.refOptions")})]})}),h==="1"?p.jsxs(V.FormLayout,{error:j||W||void 0,children:[p.jsx(st.FormulaEditor,{ref:te,className:V.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",V.borderClassName),initValue:u,unitId:n,subUnitId:r,isFocus:Q,isSupportAcrossSheet:!0,onFocus:()=>q(!0),onChange:(A="")=>{const $=(A!=null?A:"").trim();T($),ce($)}}),se.length>0&&p.jsx("div",{className:"univer-mt-3",children:se.map(A=>p.jsx(mt,{className:"univer-mb-3",item:A,commonProps:{onItemChange:J}},A.id))})]}):p.jsx(V.FormLayout,{error:j,children:p.jsxs("div",{className:"-univer-mt-3",children:[p.jsx(V.DraggableList,{list:K,onListChange:z,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:A=>p.jsx(mt,{item:A,commonProps:{onItemChange:ee,onItemDelete:ae}},A.id),idKey:"id"}),p.jsxs("a",{className:"univer-text-primary univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm hover:univer-bg-primary-50 dark:hover:!univer-bg-gray-800",onClick:Z,children:[p.jsx(Vt,{className:"univer-mr-1"}),M.t("dataValidation.list.add")]})]})})]})}const Mn=[[I.CUSTOM_FORMULA_INPUT_NAME,Dn],[I.BASE_FORMULA_INPUT_NAME,yn],[I.LIST_FORMULA_INPUT_NAME,En],[I.CHECKBOX_FORMULA_INPUT_NAME,Rn]],bn="LIST_RENDER_MODE_OPTION_INPUT";function Ne(e){var r;const{value:t,onChange:a}=e,n=E.useDependency(o.LocaleService);return p.jsx(V.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:p.jsxs(V.RadioGroup,{value:`${(r=t.renderMode)!=null?r:o.DataValidationRenderMode.CUSTOM}`,onChange:i=>a({...t,renderMode:+i}),children:[p.jsx(V.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),p.jsx(V.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),p.jsx(V.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}Ne.componentKey=bn;const Tn="DATE_SHOW_TIME_OPTION";function Be(e){var r;const{value:t,onChange:a}=e,n=E.useDependency(o.LocaleService);return p.jsx(V.FormLayout,{children:p.jsx(V.Checkbox,{checked:(r=t.bizInfo)==null?void 0:r.showTime,onChange:i=>{a({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:n.t("dataValidation.showTime.label")})})}Be.componentKey=Tn;var On=Object.getOwnPropertyDescriptor,An=(e,t,a,n)=>{for(var r=n>1?void 0:n?On(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ye=(e,t)=>(a,n)=>t(a,n,e);const Le=6;let at=class{constructor(e,t,a,n,r,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=a,this._themeService=n,this._renderManagerService=r,this._dataValidationModel=i}_calc(e,t){var c,h,g;const{vt:a,ht:n}=t||{},r=e.endX-e.startX-Le*2,i=e.endY-e.startY,s=((c=t==null?void 0:t.fs)!=null?c:10)*1.6;let d=0,l=0;switch(a){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(i-s);break;default:l=0+(i-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:d=Le;break;case o.HorizontalAlign.RIGHT:d=Le+(r-s);break;default:d=Le+(r-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((g=t==null?void 0:t.fs)!=null?g:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var c,h,g,u,C,v,T,M,m;const{formula1:n=I.CHECKBOX_FORMULA_1,formula2:r=I.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=I.getFormulaResult((g=(h=(c=i==null?void 0:i[0])==null?void 0:c.result)==null?void 0:h[0])==null?void 0:g[0]),d=I.getFormulaResult((v=(C=(u=i==null?void 0:i[1])==null?void 0:u.result)==null?void 0:C[0])==null?void 0:v[0]),l=I.isLegalFormulaResult(String(s))&&I.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(n)?I.getFormulaResult((m=(M=(T=i==null?void 0:i[0])==null?void 0:T.result)==null?void 0:M[0])==null?void 0:m[0]):n,formula2:o.isFormulaString(r)?d:r,isFormulaValid:l}}drawWith(e,t){var j,x,F,B;const{style:a,primaryWithCoord:n,unitId:r,subUnitId:i,worksheet:s,row:d,col:l}=t,c=n.isMergedMainCell?n.mergeInfo:n,h=I.getCellValueOrigin(s.getCellRaw(d,l)),g=this._dataValidationModel.getRuleByLocation(r,i,d,l);if(!g)return;const u=this._dataValidationModel.getValidator(g.type);if(!u||!((j=u.skipDefaultFontRender)!=null&&j.call(u,g,h,{unitId:r,subUnitId:i,row:d,column:l})))return;const C=u.parseFormulaSync(g,r,i),{formula1:v}=C,T=this._calc(c,a),{a:M,d:m}=e.getTransform(),f=P.fixLineWidthByScale(T.left,M),S=P.fixLineWidthByScale(T.top,m),D=P.Transform.create().composeMatrix({left:f,top:S,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),R=c.endX-c.startX,y=c.endY-c.startY;e.save(),e.beginPath(),e.rect(c.startX,c.startY,R,y),e.clip();const w=D.getMatrix();e.transform(w[0],w[1],w[2],w[3],w[4],w[5]);const U=((x=a==null?void 0:a.fs)!=null?x:10)*1.6,W=String(h)===String(v),O=this._themeService.getColorFromTheme("primary.600");P.CheckboxShape.drawWith(e,{checked:W,width:U,height:U,fill:(B=(F=a==null?void 0:a.cl)==null?void 0:F.rgb)!=null?B:O}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),r=n.top,i=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:c}=e;return l<=d&&l>=s&&c<=i&&c>=r}async onPointerDown(e,t){var v;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:r,worksheet:i,row:s,col:d}=e,l=I.getCellValueOrigin(i.getCellRaw(s,d)),c=this._dataValidationModel.getRuleByLocation(n,r,s,d);if(!c)return;const h=this._dataValidationModel.getValidator(c.type);if(!h||!((v=h.skipDefaultFontRender)!=null&&v.call(h,c,l,{unitId:n,subUnitId:r,row:s,column:d})))return;const{formula1:g,formula2:u}=await this._parseFormula(c,n,r),C={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(l)===I.transformCheckboxValue(String(g))?u:g,p:null}};this._commandService.executeCommand(H.SetRangeValuesCommand.id,C)}onPointerEnter(e,t){var a,n;(n=(a=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(P.CURSOR_TYPE.DEFAULT)}};at=An([ye(0,o.ICommandService),ye(1,o.IUniverInstanceService),ye(2,o.Inject(I.DataValidationFormulaService)),ye(3,o.Inject(o.ThemeService)),ye(4,o.Inject(P.IRenderManagerService)),ye(5,o.Inject(I.SheetDataValidationModel))],at);var Ln=Object.getOwnPropertyDescriptor,Pn=(e,t,a,n)=>{for(var r=n>1?void 0:n?Ln(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},xn=(e,t)=>(a,n)=>t(a,n,e);exports.BaseSheetDataValidatorView=class{constructor(t){L(this,"canvasRender",null);L(this,"dropdownType");L(this,"optionsInput");L(this,"formulaInput",I.LIST_FORMULA_INPUT_NAME);this.injector=t}};exports.BaseSheetDataValidatorView=Pn([xn(0,o.Inject(o.Injector))],exports.BaseSheetDataValidatorView);class jn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CHECKBOX);L(this,"canvasRender",this.injector.createInstance(at));L(this,"formulaInput",I.CHECKBOX_FORMULA_INPUT_NAME)}}class Un extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CUSTOM);L(this,"formulaInput",I.CUSTOM_FORMULA_INPUT_NAME)}}const Fn="data-validation.formula-input";class kn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DATE);L(this,"formulaInput",Fn);L(this,"optionsInput",Be.componentKey);L(this,"dropdownType",Y.DataValidatorDropdownType.DATE)}}class Nn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DECIMAL);L(this,"formulaInput",I.BASE_FORMULA_INPUT_NAME)}}const bt=4,Bn=0,Ze=4,Tt=4,rt=6,We=6,ve=14;function Wn(e,t){const a=P.FontCache.getTextSize(e,t),n=a.width+bt*2,{ba:r,bd:i}=a,s=r+i;return{width:n,height:s+Bn*2,ba:r}}function Ge(e,t,a,n){const r=ve+rt*2,i=a-r,s=n-We*2,d=e.map(u=>({layout:Wn(u,t),text:u}));let l;const c=[];d.forEach(u=>{const{layout:C}=u,{width:v,height:T}=C;!l||l.width+v+Ze>i?(l={width:v,height:T,items:[{...u,left:0}]},c.push(l)):(l.items.push({...u,left:l.width+Ze}),l.width=l.width+v+Ze)});let h=0,g=0;return c.forEach((u,C)=>{g=Math.max(g,u.width),C===c.length-1?h+=u.height:h+=u.height+Tt}),{lines:c,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+We*2,calcAutoWidth:g+r}}const Hn=8;class $n extends P.Shape{static drawWith(t,a){const{fontString:n,info:r,fill:i,color:s}=a,{layout:d,text:l}=r;t.save(),P.Rect.drawWith(t,{width:d.width,height:d.height,radius:Hn,fill:i||me}),t.translateWithPrecision(bt,d.ba),t.font=n,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var Yn=Object.getOwnPropertyDescriptor,Xn=(e,t,a,n)=>{for(var r=n>1?void 0:n?Yn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Pe=(e,t)=>(a,n)=>t(a,n,e);const zn=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let it=class{constructor(e,t,a,n){L(this,"zIndex");L(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=a,this._dataValidationModel=n}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,r){const i=a-ve+4;let s=4;switch(r){case o.VerticalAlign.MIDDLE:s=(n-ve)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-ve+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(zn),e.restore()}drawWith(e,t,a,n){var ae,re;const{primaryWithCoord:r,row:i,col:s,style:d,data:l,subUnitId:c}=t,h=r.isMergedMainCell?r.mergeInfo:r,g=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:C=0,topOffset:v=0,downOffset:T=0}=g||{},M=this._ensureMap(c),m=this._generateKey(i,s),f=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,s);if(!f)return;const S=this._dataValidationModel.getValidator(f.type);if(!S)return;const D={startX:h.startX+u,endX:h.endX-C,startY:h.startY+v,endY:h.endY-T},R=D.endX-D.startX,y=D.endY-D.startY,{cl:w}=d||{},U=(ae=typeof w=="object"?w==null?void 0:w.rgb:w)!=null?ae:"#000",W=P.getFontStyleString(d!=null?d:void 0),{vt:O,ht:j}=d||{},x=O!=null?O:o.VerticalAlign.MIDDLE,F=(re=I.getCellValueOrigin(l))!=null?re:"",B=S.parseCellValue(F),K=S.getListWithColorMap(f),z=Ge(B,W,R,y);this._drawDownIcon(e,D,R,y,x),e.save(),e.translateWithPrecision(D.startX,D.startY),e.beginPath(),e.rect(0,0,R-ve,y),e.clip(),e.translateWithPrecision(rt,We);let ee=0;switch(x){case o.VerticalAlign.MIDDLE:ee=(z.contentHeight-z.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:ee=z.contentHeight-z.totalHeight;break}e.translateWithPrecision(0,ee),z.lines.forEach((se,J)=>{e.save();const{width:Z,height:ce,items:te}=se;let Q=0;switch(j){case o.HorizontalAlign.RIGHT:Q=z.contentWidth-Z;break;case o.HorizontalAlign.CENTER:Q=(z.contentWidth-Z)/2;break}e.translate(Q,J*(ce+Tt)),te.forEach(q=>{e.save(),e.translateWithPrecision(q.left,0),$n.drawWith(e,{...W,info:q,color:U,fill:K[q.text]}),e.restore()}),e.restore()}),e.restore(),M.set(m,{left:D.startX,top:D.startY,width:z.contentWidth+rt+ve,height:z.contentHeight+We*2})}calcCellAutoHeight(e){var R;const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,u={startX:g.startX+d,endX:g.endX-l,startY:g.startY+c,endY:g.endY-h},C=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!C)return;const v=this._dataValidationModel.getValidator(C.type);if(!v)return;const T=u.endX-u.startX,M=u.endY-u.startY,m=(R=I.getCellValueOrigin(n))!=null?R:"",f=v.parseCellValue(m),S=P.getFontStyleString(a!=null?a:void 0);return Ge(f,S,T,M).cellAutoHeight}calcCellAutoWidth(e){var R;const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,u={startX:g.startX+d,endX:g.endX-l,startY:g.startY+c,endY:g.endY-h},C=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!C)return;const v=this._dataValidationModel.getValidator(C.type);if(!v)return;const T=u.endX-u.startX,M=u.endY-u.startY,m=(R=I.getCellValueOrigin(n))!=null?R:"",f=v.parseCellValue(m),S=P.getFontStyleString(a!=null?a:void 0);return Ge(f,S,T,M).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:r}=n,{x:i}=e;return i>=r-ve&&i<=r}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:r,col:i}=e,s={unitId:a,subUnitId:n,row:r,column:i};this._commandService.executeCommand(He.id,s)}onPointerEnter(e,t){var a,n;return(n=(a=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;return(n=(a=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(P.CURSOR_TYPE.DEFAULT)}};it=Xn([Pe(0,o.ICommandService),Pe(1,o.IUniverInstanceService),Pe(2,o.Inject(P.IRenderManagerService)),Pe(3,o.Inject(I.SheetDataValidationModel))],it);class Kn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST_MULTIPLE);L(this,"canvasRender",this.injector.createInstance(it));L(this,"dropdownType",Y.DataValidatorDropdownType.MULTIPLE_LIST)}}var Zn=Object.getOwnPropertyDescriptor,Gn=(e,t,a,n)=>{for(var r=n>1?void 0:n?Zn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Oe=(e,t)=>(a,n)=>t(a,n,e);const Re=4,xe=4,de=14,qe=1,ge=6,De=3,Je=8,qn="#565656",ft=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function St(e,t,a,n,r,i,s=!0){let d=0;const l=s?De:0;switch(r){case o.VerticalAlign.BOTTOM:d=t-n-l;break;case o.VerticalAlign.MIDDLE:d=(t-n)/2;break;default:d=l;break}d=Math.max(De,d);let c=0;switch(i){case o.HorizontalAlign.CENTER:c=(e-a)/2;break;case o.HorizontalAlign.RIGHT:c=e-a;break}return c=Math.max(ge,c),{paddingLeft:c,paddingTop:d}}let ot=class{constructor(e,t,a,n,r){L(this,"_dropdownInfoMap",new Map);L(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=a,this._renderManagerService=n,this._dataValidationModel=r}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,r,i,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,c=a-de;let h;switch(i){case o.VerticalAlign.MIDDLE:h=(n-xe)/2;break;case o.VerticalAlign.BOTTOM:h=n-l-r-De+(r/2-xe/2);break;default:h=d+De+(r/2-xe/2);break}e.save(),e.translateWithPrecision(t.startX+c,t.startY+h),e.fillStyle="#565656",e.fill(ft),e.restore()}drawWith(e,t,a){var K,z,ee,ae,re,se;const{primaryWithCoord:n,row:r,col:i,style:s,data:d,subUnitId:l}=t,c=n.isMergedMainCell?n.mergeInfo:n,h=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,r,i);if(!h)return;const g=this._dataValidationModel.getValidator(h.type);if(!g)return;const u=d==null?void 0:d.fontRenderExtension,{leftOffset:C=0,rightOffset:v=0,topOffset:T=0,downOffset:M=0}=u||{};if(!h||!g||!g||g.id.indexOf(o.DataValidationType.LIST)!==0||!g.skipDefaultFontRender(h))return;const m={startX:c.startX+C,endX:c.endX-v,startY:c.startY+T,endY:c.endY-M},f=m.endX-m.startX,S=m.endY-m.startY,D=this._ensureMap(l),R=this._generateKey(r,i),y=g.getListWithColor(h),w=I.getCellValueOrigin(d),U=`${w!=null?w:""}`,W=y.find(J=>J.label===U);let{tb:O,vt:j,ht:x,pd:F}=s||{};O=O!=null?O:o.WrapStrategy.WRAP,j=j!=null?j:o.VerticalAlign.BOTTOM,x=x!=null?x:o.DEFAULT_STYLES.ht,F=F!=null?F:o.DEFAULT_STYLES.pd;const B=P.getFontStyleString(s).fontCache;if(h.renderMode===o.DataValidationRenderMode.ARROW){const{l:J=o.DEFAULT_STYLES.pd.l,t:Z=o.DEFAULT_STYLES.pd.t,r:ce=o.DEFAULT_STYLES.pd.r,b:te=o.DEFAULT_STYLES.pd.b}=F,Q=f-J-ce-de-4,q=new P.DocSimpleSkeleton(U,B,O===o.WrapStrategy.WRAP,Q,1/0);q.calculate();const A=q.getTotalWidth(),$=q.getTotalHeight(),{paddingTop:_,paddingLeft:k}=St(Q,S-Z-te,A,$,j,x,!0);this._drawDownIcon(e,m,f,S,$,j,F),e.save(),e.translateWithPrecision(m.startX+J,m.startY+Z),e.beginPath(),e.rect(0,0,f-J-ce,S-Z-te),e.clip(),e.translateWithPrecision(0,_),e.save(),e.translateWithPrecision(k,0),e.beginPath(),e.rect(0,0,Q,$),e.clip(),P.Text.drawWith(e,{text:U,fontStyle:B,width:Q,height:$,color:(K=s==null?void 0:s.cl)==null?void 0:K.rgb,strokeLine:!!((z=s==null?void 0:s.st)!=null&&z.s),underline:!!((ee=s==null?void 0:s.ul)!=null&&ee.s),warp:O===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},q),e.restore(),e.restore(),D.set(R,{left:m.endX-de+a.rowHeaderWidth,top:m.startY+Z+a.columnHeaderHeight,width:de,height:S-Z-te})}else{e.save(),e.translateWithPrecision(m.startX,m.startY),e.beginPath(),e.rect(0,0,f,S),e.clip();const J=f-ge*2-Re-de-4,Z=new P.DocSimpleSkeleton(U,B,O===o.WrapStrategy.WRAP,J,1/0);Z.calculate();const ce=Z.getTotalWidth(),te=Z.getTotalHeight(),Q=te+qe*2,q=Math.max(f-ge*2,1),{paddingTop:A}=St(q,S,ce,Q,j,x);e.translateWithPrecision(ge,A),P.Rect.drawWith(e,{width:q,height:Q,fill:(W==null?void 0:W.color)||me,radius:Je}),e.save(),e.translateWithPrecision(Re,qe),e.beginPath(),e.rect(0,0,J,te),e.clip(),P.Text.drawWith(e,{text:U,fontStyle:B,width:J,height:te,color:(ae=s==null?void 0:s.cl)==null?void 0:ae.rgb,strokeLine:!!((re=s==null?void 0:s.st)!=null&&re.s),underline:!!((se=s==null?void 0:s.ul)!=null&&se.s),warp:O===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},Z),e.restore(),e.translateWithPrecision(J+Re+4,(te-xe)/2),e.fillStyle=qn,e.fill(ft),e.restore(),D.set(R,{left:m.startX+ge+a.rowHeaderWidth,top:m.startY+A+a.columnHeaderHeight,width:q,height:Q})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:g=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const C={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-g},v=C.endX-C.startX,T=I.getCellValueOrigin(n),M=`${T!=null?T:""}`;let{tb:m,pd:f}=a||{};const{t:S=o.DEFAULT_STYLES.pd.t,b:D=o.DEFAULT_STYLES.pd.b}=f!=null?f:{};if(m=m!=null?m:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const{l:R=o.DEFAULT_STYLES.pd.l,r:y=o.DEFAULT_STYLES.pd.r}=f!=null?f:{},w=v-R-y-de-4,U=new P.DocSimpleSkeleton(M,P.getFontStyleString(a).fontCache,m===o.WrapStrategy.WRAP,w,1/0);return U.calculate(),U.getTotalHeight()+S+D+De*2}else{const R=Math.max(v-ge*2-Re-de-4,10),y=new P.DocSimpleSkeleton(M,P.getFontStyleString(a).fontCache,m===o.WrapStrategy.WRAP,R,1/0);return y.calculate(),y.getTotalHeight()+De*2+qe*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:g=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const C={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-g},v=C.endX-C.startX,T=I.getCellValueOrigin(n),M=`${T!=null?T:""}`;let{tb:m,pd:f}=a||{};const{l:S=o.DEFAULT_STYLES.pd.l,r:D=o.DEFAULT_STYLES.pd.r}=f!=null?f:{};m=m!=null?m:o.WrapStrategy.WRAP;let R=ge*2+de;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:R=de+4+D+S;break;case o.DataValidationRenderMode.CUSTOM:R=de+ge*2+Re*2+D+S+Je/2+1;break;default:R=de+ge*2+Re*2+D+S+Je/2+1}const y=v-R,w=new P.DocSimpleSkeleton(M,P.getFontStyleString(a).fontCache,m===o.WrapStrategy.WRAP,y,1/0);return w.calculate(),w.getTotalWidth()+R}isHit(e,t){const{subUnitId:a,row:n,col:r}=t,s=this._ensureMap(a).get(this._generateKey(n,r)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,r);if(!d||!s||d.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:c,width:h,height:g}=s,{x:u,y:C}=e;return u>=c&&u<=c+h&&C>=l&&C<=l+g}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:r,col:i}=e,s={unitId:a,subUnitId:n,row:r,column:i};this._commandService.executeCommand(He.id,s)}onPointerEnter(e,t){var a,n;(n=(a=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(P.CURSOR_TYPE.DEFAULT)}};ot=Gn([Oe(0,o.IUniverInstanceService),Oe(1,o.Inject(o.LocaleService)),Oe(2,o.ICommandService),Oe(3,o.Inject(P.IRenderManagerService)),Oe(4,o.Inject(I.SheetDataValidationModel))],ot);class Jn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST);L(this,"canvasRender",this.injector.createInstance(ot));L(this,"dropdownType",Y.DataValidatorDropdownType.LIST);L(this,"optionsInput",Ne.componentKey);L(this,"formulaInput",I.LIST_FORMULA_INPUT_NAME)}}class Qn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.TEXT_LENGTH);L(this,"formulaInput",I.BASE_FORMULA_INPUT_NAME)}}class ea extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.WHOLE);L(this,"formulaInput",I.BASE_FORMULA_INPUT_NAME)}}var ta=Object.getOwnPropertyDescriptor,na=(e,t,a,n)=>{for(var r=n>1?void 0:n?ta(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Qe=(e,t)=>(a,n)=>t(a,n,e);let Te=class extends o.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[["DataValidationIcon",wt],[Fe,Cn],[Ne.componentKey,Ne],[Be.componentKey,Be],...Mn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Nn,ea,Qn,kn,jn,Jn,Kn,Un].forEach(e=>{const t=this._injector.createInstance(e),a=this._dataValidatorRegistryService.getValidatorItem(t.id);a&&(a.formulaInput=t.formulaInput,a.canvasRender=t.canvasRender,a.dropdownType=t.dropdownType,a.optionsInput=t.optionsInput)})}};Te=na([Qe(0,o.Inject(o.Injector)),Qe(1,o.Inject(E.ComponentManager)),Qe(2,o.Inject(Y.DataValidatorRegistryService))],Te);var aa=Object.getOwnPropertyDescriptor,ra=(e,t,a,n)=>{for(var r=n>1?void 0:n?aa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},et=(e,t)=>(a,n)=>t(a,n,e);const ia="SHEET_DATA_VALIDATION_UI_PLUGIN";var je;exports.UniverSheetsDataValidationMobileUIPlugin=(je=class extends o.Plugin{constructor(t=Ue,a,n,r){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=r;const{menu:i,...s}=o.merge({},Ue,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(lt,s)}onStarting(){[[ue],[fe],[Ae],[Ve],[be],[Me],[Ee],[Te]].forEach(t=>{this._injector.add(t)}),[$e,He,It,dt,Se,_t].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(P.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(Te),this._injector.get(be)}onSteady(){this._injector.get(Ve)}},L(je,"pluginName",ia),L(je,"type",o.UniverInstanceType.UNIVER_SHEET),je);exports.UniverSheetsDataValidationMobileUIPlugin=ra([et(1,o.Inject(o.Injector)),et(2,o.ICommandService),et(3,o.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);var oa=Object.defineProperty,sa=Object.getOwnPropertyDescriptor,la=(e,t,a)=>t in e?oa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,da=(e,t,a,n)=>{for(var r=n>1?void 0:n?sa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},tt=(e,t)=>(a,n)=>t(a,n,e),Ot=(e,t,a)=>la(e,typeof t!="symbol"?t+"":t,a);const ca="SHEET_DATA_VALIDATION_UI_PLUGIN";exports.UniverSheetsDataValidationUIPlugin=class extends o.Plugin{constructor(t=Ue,a,n,r){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=r;const{menu:i,...s}=o.merge({},Ue,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(lt,s)}onStarting(){[[ue],[fe],[Ae],[Ve],[be],[Me],[Ee],[we],[Te]].forEach(t=>{this._injector.add(t)}),[$e,He,It,dt,Se,_t].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(we),this._injector.get(Ae),this._injector.get(P.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(Te),this._injector.get(be)}onSteady(){this._injector.get(Ve)}};Ot(exports.UniverSheetsDataValidationUIPlugin,"pluginName",ca);Ot(exports.UniverSheetsDataValidationUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsDataValidationUIPlugin=da([o.DependentOn(I.UniverSheetsDataValidationPlugin),tt(1,o.Inject(o.Injector)),tt(2,o.ICommandService),tt(3,o.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);
|
5
|
+
`,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!i,"univer-opacity-50":i}),onClick:a,onMouseEnter:()=>{i||(u(!0),h.current=t.ranges.map(R=>l.addShape({range:R,style:O,primary:null})))},onMouseLeave:()=>{var R;u(!1),(R=h.current)==null||R.forEach(y=>{y&&l.removeShape(y)}),h.current=void 0},children:[g.jsx("div",{className:"univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-white",children:c==null?void 0:c.generateRuleName(t)}),g.jsx("div",{className:"univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300",children:t.ranges.map(R=>nt.serializeRange(R)).join(",")}),v?g.jsx("div",{className:"univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-h-5 univer-w-5 univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-200 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700",onClick:M,children:g.jsx(ct,{})}):null]})};function In(e){const t=E.useDependency(C.SheetDataValidationModel),a=E.useDependency(o.IUniverInstanceService),n=E.useDependency(o.ICommandService),r=E.useDependency(o.Injector),i=E.useDependency(ce),s=E.useDependency(o.LocaleService),[d,l]=T.useState([]),{workbook:c}=e,h=E.useObservable(c.activeSheet$,void 0,!0),v=c.getUnitId(),u=h==null?void 0:h.getSheetId();T.useEffect(()=>{l(t.getRules(v,u));const y=t.ruleChange$.subscribe(m=>{m.unitId===v&&m.subUnitId===u&&l(t.getRules(v,u))});return()=>{y.unsubscribe()}},[v,u,t]);const S=async()=>{const y=C.createDefaultNewRule(r),m={unitId:v,subUnitId:u,rule:y};await n.executeCommand(C.AddSheetDataValidationCommand.id,m),i.setActiveRule({unitId:v,subUnitId:u,rule:y})},p=()=>{n.executeCommand(C.RemoveSheetAllDataValidationCommand.id,{unitId:v,subUnitId:u})},M=(y=>{const m=a.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),D=m.getActiveSheet(),I=m.getUnitId(),f=D.getSheetId();return y.map(F=>$.checkRangesEditablePermission(r,I,f,F.ranges)?{...F}:{...F,disable:!0})})(d),R=M==null?void 0:M.some(y=>y.disable);return g.jsxs("div",{className:"univer-pb-4",children:[M==null?void 0:M.map(y=>{var m;return g.jsx(_n,{unitId:v,subUnitId:u,onClick:()=>{y.disable||i.setActiveRule({unitId:v,subUnitId:u,rule:y})},rule:y,disable:(m=y.disable)!=null?m:!1},y.uid)}),g.jsxs("div",{className:"univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[d.length&&!R?g.jsx(V.Button,{onClick:p,children:s.t("dataValidation.panel.removeAll")}):null,g.jsx(V.Button,{variant:"primary",onClick:S,children:s.t("dataValidation.panel.add")})]})]})}const Cn=()=>{const e=E.useDependency(ce),t=E.useObservable(e.activeRule$,e.activeRule),a=E.useDependency(o.IUniverInstanceService),n=E.useObservable(()=>a.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),r=E.useObservable(()=>{var i;return(i=n==null?void 0:n.activeSheet$)!=null?i:ie.of(null)},void 0,void 0,[]);return!n||!r?null:t&&t.subUnitId===r.getSheetId()?g.jsx(Sn,{},t.rule.uid):g.jsx(In,{workbook:n})},yn=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:r,validResult:i}=e,s=E.useDependency(o.LocaleService),d=r?i==null?void 0:i.formula1:"",l=r?i==null?void 0:i.formula2:"";return t?g.jsxs(g.Fragment,{children:[g.jsx(V.FormLayout,{error:d,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:c=>{n==null||n({...a,formula1:c})}})}),g.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),g.jsx(V.FormLayout,{error:l,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:c=>{n==null||n({...a,formula2:c})}})})]}):g.jsx(V.FormLayout,{error:d,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:c=>{n==null||n({formula1:c})}})})};function Rn(e){const{value:t,onChange:a,showError:n,validResult:r}=e,i=E.useDependency(o.LocaleService),s=n?r==null?void 0:r.formula1:"",d=n?r==null?void 0:r.formula2:"",[l,c]=T.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return g.jsxs(g.Fragment,{children:[g.jsx(V.FormLayout,{children:g.jsx(V.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?g.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{a==null||a({...t,formula1:h||void 0})}})}):null,l?g.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:d,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{a==null||a({...t,formula2:h||void 0})}})}):null]})}function Dn(e){var v;const{unitId:t,subUnitId:a,value:n,onChange:r,showError:i,validResult:s}=e,d=i?s==null?void 0:s.formula1:void 0,l=T.useRef(null),[c,h]=T.useState(!1);return E.useSidebarClick(u=>{var p;((p=l.current)==null?void 0:p.isClickOutSide(u))&&h(!1)}),g.jsx(V.FormLayout,{error:d,children:g.jsx(st.FormulaEditor,{ref:l,className:V.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",V.borderClassName),initValue:(v=n==null?void 0:n.formula1)!=null?v:"=",unitId:t,subUnitId:a,isFocus:c,isSupportAcrossSheet:!0,onChange:u=>{const S=(u!=null?u:"").trim();S!==(n==null?void 0:n.formula1)&&(r==null||r({...n,formula1:S}))},onFocus:()=>h(!0)})})}const wn=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Vn=e=>{const{value:t,onChange:a,disabled:n}=e,[r,i]=T.useState(!1);return g.jsx(V.Dropdown,{align:"start",disabled:n,open:r,onOpenChange:i,overlay:g.jsx("div",{className:"univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2 univer-p-1.5",children:wn.map(s=>g.jsx("div",{className:V.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",V.borderClassName),style:{background:s},onClick:()=>{a(s),i(!1)}},s))}),children:g.jsxs("div",{className:V.clsx("univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-white univer-px-2.5 univer-transition-colors univer-duration-200 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white",V.borderClassName),children:[g.jsx("div",{className:"univer-box-border univer-h-4 univer-w-4 univer-rounded univer-text-base",style:{background:t}}),g.jsx(ut,{})]})})},mt=e=>{const{item:t,commonProps:a,className:n}=e,{onItemChange:r,onItemDelete:i}=a;return g.jsxs("div",{className:V.clsx("univer-flex univer-items-center univer-gap-2",n),children:[!t.isRef&&g.jsx("div",{className:V.clsx("univer-cursor-move","draggableHandle"),children:g.jsx(Mt,{})}),g.jsx(Vn,{value:t.color,onChange:s=>{r(t.id,t.label,s)}}),g.jsx(V.Input,{disabled:t.isRef,value:t.label,onChange:s=>{r(t.id,s,t.color)}}),t.isRef?null:g.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:g.jsx(ct,{onClick:()=>i(t.id)})})]})};function En(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:r,validResult:i,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},[h,v]=T.useState(()=>o.isFormulaString(l)?"1":"0"),[u,S]=T.useState(h==="1"?l:"="),[p,O]=T.useState(h==="1"?l:"="),M=E.useDependency(o.LocaleService),R=E.useDependency(Y.DataValidatorRegistryService),y=E.useDependency(Y.DataValidationModel),m=E.useDependency(C.DataValidationFormulaController),[D,I]=T.useState(()=>c.split(",")),f=R.getValidatorItem(o.DataValidationType.LIST),[w,F]=T.useState([]),[W,x]=T.useState(""),k=s?i==null?void 0:i.formula1:"",A=T.useMemo(()=>y.ruleChange$.pipe(ie.debounceTime(16)),[]),j=E.useObservable(A),N=E.useEvent(a);T.useEffect(()=>{(async()=>{await new Promise(_=>{setTimeout(()=>_(!0),100)});const b=y.getRuleById(n,r,d),H=b==null?void 0:b.formula1;if(o.isFormulaString(H)&&f&&b){const _=await f.getListAsync(b,n,r);F(_)}})()},[y,j,f,d,r,n]),T.useEffect(()=>{o.isFormulaString(l)&&l!==p&&(S(l),O(p))},[p,l]);const[z,q]=T.useState(()=>{const b=h!=="1"?C.deserializeListOptions(l):[],H=c.split(",");return b.map((_,U)=>({label:_,color:H[U]||me,isRef:!1,id:o.generateRandomId(4)}))}),te=(b,H,_)=>{const U=z.find(X=>X.id===b);U&&(U.label=H,U.color=_,q([...z]))},K=b=>{const H=z.findIndex(_=>_.id===b);H!==-1&&(z.splice(H,1),q([...z]))},ne=c.split(","),ae=T.useMemo(()=>w.map((b,H)=>({label:b,color:ne[H]||me,id:`${H}`,isRef:!0})),[ne,w]),ue=(b,H,_)=>{const U=[...D];U[+b]=_,I(U),N({formula1:l,formula2:U.join(",")})},he=()=>{q([...z,{label:"",color:me,isRef:!1,id:o.generateRandomId(4)}])};T.useEffect(()=>{if(h==="1")return;const b=new Set,H=[];z.map(_=>({labelList:_.label.split(","),item:_})).forEach(({item:_,labelList:U})=>{U.forEach(X=>{b.has(X)||(b.add(X),H.push({label:X,color:_.color}))})}),N({formula1:C.serializeListOptions(H.map(_=>_.label)),formula2:H.map(_=>_.color===me?"":_.color).join(",")})},[z,N,h,p,D]);const J=E.useEvent(async b=>{if(!o.isFormulaString(b)){N==null||N({formula1:"",formula2:c});return}m.getFormulaRefCheck(b)?(N==null||N({formula1:o.isFormulaString(b)?b:"",formula2:c}),x("")):(N==null||N({formula1:"",formula2:c}),S("="),x(M.t("dataValidation.validFail.formulaError")))}),Z=T.useRef(null),[de,Q]=T.useState(!1);return E.useSidebarClick(b=>{var _;((_=Z.current)==null?void 0:_.isClickOutSide(b))&&Q(!1)}),g.jsxs(g.Fragment,{children:[g.jsx(V.FormLayout,{label:M.t("dataValidation.list.options"),children:g.jsxs(V.RadioGroup,{value:h,onChange:b=>{v(b),S(p),b==="1"&&N({formula1:p==="="?"":p,formula2:D.join(",")})},children:[g.jsx(V.Radio,{value:"0",children:M.t("dataValidation.list.customOptions")}),g.jsx(V.Radio,{value:"1",children:M.t("dataValidation.list.refOptions")})]})}),h==="1"?g.jsxs(V.FormLayout,{error:k||W||void 0,children:[g.jsx(st.FormulaEditor,{ref:Z,className:V.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",V.borderClassName),initValue:u,unitId:n,subUnitId:r,isFocus:de,isSupportAcrossSheet:!0,onFocus:()=>Q(!0),onChange:(b="")=>{const H=(b!=null?b:"").trim();O(H),J(H)}}),ae.length>0&&g.jsx("div",{className:"univer-mt-3",children:ae.map(b=>g.jsx(mt,{className:"univer-mb-3",item:b,commonProps:{onItemChange:ue}},b.id))})]}):g.jsx(V.FormLayout,{error:k,children:g.jsxs("div",{className:"-univer-mt-3",children:[g.jsx(V.DraggableList,{list:z,onListChange:q,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:b=>g.jsx(mt,{item:b,commonProps:{onItemChange:te,onItemDelete:K}},b.id),idKey:"id"}),g.jsxs("a",{className:"univer-text-primary univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm hover:univer-bg-primary-50 dark:hover:!univer-bg-gray-800",onClick:he,children:[g.jsx(Vt,{className:"univer-mr-1"}),M.t("dataValidation.list.add")]})]})})]})}const Mn=[[C.CUSTOM_FORMULA_INPUT_NAME,Dn],[C.BASE_FORMULA_INPUT_NAME,yn],[C.LIST_FORMULA_INPUT_NAME,En],[C.CHECKBOX_FORMULA_INPUT_NAME,Rn]],bn="LIST_RENDER_MODE_OPTION_INPUT";function Ne(e){var r;const{value:t,onChange:a}=e,n=E.useDependency(o.LocaleService);return g.jsx(V.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:g.jsxs(V.RadioGroup,{value:`${(r=t.renderMode)!=null?r:o.DataValidationRenderMode.CUSTOM}`,onChange:i=>a({...t,renderMode:+i}),children:[g.jsx(V.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),g.jsx(V.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),g.jsx(V.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}Ne.componentKey=bn;const Tn="DATE_SHOW_TIME_OPTION";function Be(e){var r;const{value:t,onChange:a}=e,n=E.useDependency(o.LocaleService);return g.jsx(V.FormLayout,{children:g.jsx(V.Checkbox,{checked:(r=t.bizInfo)==null?void 0:r.showTime,onChange:i=>{a({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:n.t("dataValidation.showTime.label")})})}Be.componentKey=Tn;var On=Object.getOwnPropertyDescriptor,An=(e,t,a,n)=>{for(var r=n>1?void 0:n?On(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ye=(e,t)=>(a,n)=>t(a,n,e);const Le=6;let at=class{constructor(e,t,a,n,r,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=a,this._themeService=n,this._renderManagerService=r,this._dataValidationModel=i}_calc(e,t){var c,h,v;const{vt:a,ht:n}=t||{},r=e.endX-e.startX-Le*2,i=e.endY-e.startY,s=((c=t==null?void 0:t.fs)!=null?c:10)*1.6;let d=0,l=0;switch(a){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(i-s);break;default:l=0+(i-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:d=Le;break;case o.HorizontalAlign.RIGHT:d=Le+(r-s);break;default:d=Le+(r-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((v=t==null?void 0:t.fs)!=null?v:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var c,h,v,u,S,p,O,M,R;const{formula1:n=C.CHECKBOX_FORMULA_1,formula2:r=C.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=C.getFormulaResult((v=(h=(c=i==null?void 0:i[0])==null?void 0:c.result)==null?void 0:h[0])==null?void 0:v[0]),d=C.getFormulaResult((p=(S=(u=i==null?void 0:i[1])==null?void 0:u.result)==null?void 0:S[0])==null?void 0:p[0]),l=C.isLegalFormulaResult(String(s))&&C.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(n)?C.getFormulaResult((R=(M=(O=i==null?void 0:i[0])==null?void 0:O.result)==null?void 0:M[0])==null?void 0:R[0]):n,formula2:o.isFormulaString(r)?d:r,isFormulaValid:l}}drawWith(e,t){var k,A,j,N;const{style:a,primaryWithCoord:n,unitId:r,subUnitId:i,worksheet:s,row:d,col:l}=t,c=n.isMergedMainCell?n.mergeInfo:n,h=C.getCellValueOrigin(s.getCellRaw(d,l)),v=this._dataValidationModel.getRuleByLocation(r,i,d,l);if(!v)return;const u=this._dataValidationModel.getValidator(v.type);if(!u||!((k=u.skipDefaultFontRender)!=null&&k.call(u,v,h,{unitId:r,subUnitId:i,row:d,column:l})))return;const S=u.parseFormulaSync(v,r,i),{formula1:p}=S,O=this._calc(c,a),{a:M,d:R}=e.getTransform(),y=P.fixLineWidthByScale(O.left,M),m=P.fixLineWidthByScale(O.top,R),D=P.Transform.create().composeMatrix({left:y,top:m,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),I=c.endX-c.startX,f=c.endY-c.startY;e.save(),e.beginPath(),e.rect(c.startX,c.startY,I,f),e.clip();const w=D.getMatrix();e.transform(w[0],w[1],w[2],w[3],w[4],w[5]);const F=((A=a==null?void 0:a.fs)!=null?A:10)*1.6,W=String(h)===String(p),x=this._themeService.getColorFromTheme("primary.600");P.CheckboxShape.drawWith(e,{checked:W,width:F,height:F,fill:(N=(j=a==null?void 0:a.cl)==null?void 0:j.rgb)!=null?N:x}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),r=n.top,i=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:c}=e;return l<=d&&l>=s&&c<=i&&c>=r}async onPointerDown(e,t){var p;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:r,worksheet:i,row:s,col:d}=e,l=C.getCellValueOrigin(i.getCellRaw(s,d)),c=this._dataValidationModel.getRuleByLocation(n,r,s,d);if(!c)return;const h=this._dataValidationModel.getValidator(c.type);if(!h||!((p=h.skipDefaultFontRender)!=null&&p.call(h,c,l,{unitId:n,subUnitId:r,row:s,column:d})))return;const{formula1:v,formula2:u}=await this._parseFormula(c,n,r),S={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(l)===C.transformCheckboxValue(String(v))?u:v,p:null}};this._commandService.executeCommand($.SetRangeValuesCommand.id,S)}onPointerEnter(e,t){var a,n;(n=(a=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(P.CURSOR_TYPE.DEFAULT)}};at=An([ye(0,o.ICommandService),ye(1,o.IUniverInstanceService),ye(2,o.Inject(C.DataValidationFormulaService)),ye(3,o.Inject(o.ThemeService)),ye(4,o.Inject(P.IRenderManagerService)),ye(5,o.Inject(C.SheetDataValidationModel))],at);var Ln=Object.getOwnPropertyDescriptor,Pn=(e,t,a,n)=>{for(var r=n>1?void 0:n?Ln(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},xn=(e,t)=>(a,n)=>t(a,n,e);exports.BaseSheetDataValidatorView=class{constructor(t){L(this,"canvasRender",null);L(this,"dropdownType");L(this,"optionsInput");L(this,"formulaInput",C.LIST_FORMULA_INPUT_NAME);this.injector=t}};exports.BaseSheetDataValidatorView=Pn([xn(0,o.Inject(o.Injector))],exports.BaseSheetDataValidatorView);class jn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CHECKBOX);L(this,"canvasRender",this.injector.createInstance(at));L(this,"formulaInput",C.CHECKBOX_FORMULA_INPUT_NAME)}}class Un extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CUSTOM);L(this,"formulaInput",C.CUSTOM_FORMULA_INPUT_NAME)}}const Fn="data-validation.formula-input";class kn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DATE);L(this,"formulaInput",Fn);L(this,"optionsInput",Be.componentKey);L(this,"dropdownType",Y.DataValidatorDropdownType.DATE)}}class Nn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DECIMAL);L(this,"formulaInput",C.BASE_FORMULA_INPUT_NAME)}}const bt=4,Bn=0,Ze=4,Tt=4,rt=6,We=6,ve=14;function Wn(e,t){const a=P.FontCache.getTextSize(e,t),n=a.width+bt*2,{ba:r,bd:i}=a,s=r+i;return{width:n,height:s+Bn*2,ba:r}}function Ge(e,t,a,n){const r=ve+rt*2,i=a-r,s=n-We*2,d=e.map(u=>({layout:Wn(u,t),text:u}));let l;const c=[];d.forEach(u=>{const{layout:S}=u,{width:p,height:O}=S;!l||l.width+p+Ze>i?(l={width:p,height:O,items:[{...u,left:0}]},c.push(l)):(l.items.push({...u,left:l.width+Ze}),l.width=l.width+p+Ze)});let h=0,v=0;return c.forEach((u,S)=>{v=Math.max(v,u.width),S===c.length-1?h+=u.height:h+=u.height+Tt}),{lines:c,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+We*2,calcAutoWidth:v+r}}const Hn=8;class $n extends P.Shape{static drawWith(t,a){const{fontString:n,info:r,fill:i,color:s}=a,{layout:d,text:l}=r;t.save(),P.Rect.drawWith(t,{width:d.width,height:d.height,radius:Hn,fill:i||me}),t.translateWithPrecision(bt,d.ba),t.font=n,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var Yn=Object.getOwnPropertyDescriptor,Xn=(e,t,a,n)=>{for(var r=n>1?void 0:n?Yn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Pe=(e,t)=>(a,n)=>t(a,n,e);const zn=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let it=class{constructor(e,t,a,n){L(this,"zIndex");L(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=a,this._dataValidationModel=n}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,r){const i=a-ve+4;let s=4;switch(r){case o.VerticalAlign.MIDDLE:s=(n-ve)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-ve+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(zn),e.restore()}drawWith(e,t,a,n){var ae,ue;const{primaryWithCoord:r,row:i,col:s,style:d,data:l,subUnitId:c}=t,h=r.isMergedMainCell?r.mergeInfo:r,v=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:S=0,topOffset:p=0,downOffset:O=0}=v||{},M=this._ensureMap(c),R=this._generateKey(i,s),y=r.isMergedMainCell?r.mergeInfo.startRow:i,m=r.isMergedMainCell?r.mergeInfo.startColumn:s,D=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,y,m);if(!D)return;const I=this._dataValidationModel.getValidator(D.type);if(!I)return;const f={startX:h.startX+u,endX:h.endX-S,startY:h.startY+p,endY:h.endY-O},w=f.endX-f.startX,F=f.endY-f.startY,{cl:W}=d||{},x=(ae=typeof W=="object"?W==null?void 0:W.rgb:W)!=null?ae:"#000",k=P.getFontStyleString(d!=null?d:void 0),{vt:A,ht:j}=d||{},N=A!=null?A:o.VerticalAlign.MIDDLE,z=(ue=C.getCellValueOrigin(l))!=null?ue:"",q=I.parseCellValue(z),te=I.getListWithColorMap(D),K=Ge(q,k,w,F);this._drawDownIcon(e,f,w,F,N),e.save(),e.translateWithPrecision(f.startX,f.startY),e.beginPath(),e.rect(0,0,w-ve,F),e.clip(),e.translateWithPrecision(rt,We);let ne=0;switch(N){case o.VerticalAlign.MIDDLE:ne=(K.contentHeight-K.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:ne=K.contentHeight-K.totalHeight;break}e.translateWithPrecision(0,ne),K.lines.forEach((he,J)=>{e.save();const{width:Z,height:de,items:Q}=he;let b=0;switch(j){case o.HorizontalAlign.RIGHT:b=K.contentWidth-Z;break;case o.HorizontalAlign.CENTER:b=(K.contentWidth-Z)/2;break}e.translate(b,J*(de+Tt)),Q.forEach(H=>{e.save(),e.translateWithPrecision(H.left,0),$n.drawWith(e,{...k,info:H,color:x,fill:te[H.text]}),e.restore()}),e.restore()}),e.restore(),M.set(R,{left:f.startX,top:f.startY,width:K.contentWidth+rt+ve,height:K.contentHeight+We*2})}calcCellAutoHeight(e){var I;const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,u={startX:v.startX+d,endX:v.endX-l,startY:v.startY+c,endY:v.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!S)return;const p=this._dataValidationModel.getValidator(S.type);if(!p)return;const O=u.endX-u.startX,M=u.endY-u.startY,R=(I=C.getCellValueOrigin(n))!=null?I:"",y=p.parseCellValue(R),m=P.getFontStyleString(a!=null?a:void 0);return Ge(y,m,O,M).cellAutoHeight}calcCellAutoWidth(e){var I;const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,u={startX:v.startX+d,endX:v.endX-l,startY:v.startY+c,endY:v.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!S)return;const p=this._dataValidationModel.getValidator(S.type);if(!p)return;const O=u.endX-u.startX,M=u.endY-u.startY,R=(I=C.getCellValueOrigin(n))!=null?I:"",y=p.parseCellValue(R),m=P.getFontStyleString(a!=null?a:void 0);return Ge(y,m,O,M).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:r}=n,{x:i}=e;return i>=r-ve&&i<=r}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:r,col:i}=e,s={unitId:a,subUnitId:n,row:r,column:i};this._commandService.executeCommand(He.id,s)}onPointerEnter(e,t){var a,n;return(n=(a=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;return(n=(a=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(P.CURSOR_TYPE.DEFAULT)}};it=Xn([Pe(0,o.ICommandService),Pe(1,o.IUniverInstanceService),Pe(2,o.Inject(P.IRenderManagerService)),Pe(3,o.Inject(C.SheetDataValidationModel))],it);class Kn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST_MULTIPLE);L(this,"canvasRender",this.injector.createInstance(it));L(this,"dropdownType",Y.DataValidatorDropdownType.MULTIPLE_LIST)}}var Zn=Object.getOwnPropertyDescriptor,Gn=(e,t,a,n)=>{for(var r=n>1?void 0:n?Zn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Oe=(e,t)=>(a,n)=>t(a,n,e);const Re=4,xe=4,le=14,qe=1,ge=6,De=3,Je=8,qn="#565656",ft=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function St(e,t,a,n,r,i,s=!0){let d=0;const l=s?De:0;switch(r){case o.VerticalAlign.BOTTOM:d=t-n-l;break;case o.VerticalAlign.MIDDLE:d=(t-n)/2;break;default:d=l;break}d=Math.max(De,d);let c=0;switch(i){case o.HorizontalAlign.CENTER:c=(e-a)/2;break;case o.HorizontalAlign.RIGHT:c=e-a;break}return c=Math.max(ge,c),{paddingLeft:c,paddingTop:d}}let ot=class{constructor(e,t,a,n,r){L(this,"_dropdownInfoMap",new Map);L(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=a,this._renderManagerService=n,this._dataValidationModel=r}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,r,i,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,c=a-le;let h;switch(i){case o.VerticalAlign.MIDDLE:h=(n-xe)/2;break;case o.VerticalAlign.BOTTOM:h=n-l-r-De+(r/2-xe/2);break;default:h=d+De+(r/2-xe/2);break}e.save(),e.translateWithPrecision(t.startX+c,t.startY+h),e.fillStyle="#565656",e.fill(ft),e.restore()}drawWith(e,t,a){var te,K,ne,ae,ue,he;const{primaryWithCoord:n,row:r,col:i,style:s,data:d,subUnitId:l}=t,c=n.isMergedMainCell?n.mergeInfo:n,h=n.isMergedMainCell?n.mergeInfo.startRow:r,v=n.isMergedMainCell?n.mergeInfo.startColumn:i,u=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,h,v);if(!u)return;const S=this._dataValidationModel.getValidator(u.type);if(!S)return;const p=d==null?void 0:d.fontRenderExtension,{leftOffset:O=0,rightOffset:M=0,topOffset:R=0,downOffset:y=0}=p||{};if(!u||!S||!S||S.id.indexOf(o.DataValidationType.LIST)!==0||!S.skipDefaultFontRender(u))return;const m={startX:c.startX+O,endX:c.endX-M,startY:c.startY+R,endY:c.endY-y},D=m.endX-m.startX,I=m.endY-m.startY,f=this._ensureMap(l),w=this._generateKey(r,i),F=S.getListWithColor(u),W=C.getCellValueOrigin(d),x=`${W!=null?W:""}`,k=F.find(J=>J.label===x);let{tb:A,vt:j,ht:N,pd:z}=s||{};A=A!=null?A:o.WrapStrategy.WRAP,j=j!=null?j:o.VerticalAlign.BOTTOM,N=N!=null?N:o.DEFAULT_STYLES.ht,z=z!=null?z:o.DEFAULT_STYLES.pd;const q=P.getFontStyleString(s).fontCache;if(u.renderMode===o.DataValidationRenderMode.ARROW){const{l:J=o.DEFAULT_STYLES.pd.l,t:Z=o.DEFAULT_STYLES.pd.t,r:de=o.DEFAULT_STYLES.pd.r,b:Q=o.DEFAULT_STYLES.pd.b}=z,b=D-J-de-le-4,H=new P.DocSimpleSkeleton(x,q,A===o.WrapStrategy.WRAP,b,1/0);H.calculate();const _=H.getTotalWidth(),U=H.getTotalHeight(),{paddingTop:X,paddingLeft:oe}=St(b,I-Z-Q,_,U,j,N,!0);this._drawDownIcon(e,m,D,I,U,j,z),e.save(),e.translateWithPrecision(m.startX+J,m.startY+Z),e.beginPath(),e.rect(0,0,D-J-de,I-Z-Q),e.clip(),e.translateWithPrecision(0,X),e.save(),e.translateWithPrecision(oe,0),e.beginPath(),e.rect(0,0,b,U),e.clip(),P.Text.drawWith(e,{text:x,fontStyle:q,width:b,height:U,color:(te=s==null?void 0:s.cl)==null?void 0:te.rgb,strokeLine:!!((K=s==null?void 0:s.st)!=null&&K.s),underline:!!((ne=s==null?void 0:s.ul)!=null&&ne.s),warp:A===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},H),e.restore(),e.restore(),f.set(w,{left:m.endX-le+a.rowHeaderWidth,top:m.startY+Z+a.columnHeaderHeight,width:le,height:I-Z-Q})}else{e.save(),e.translateWithPrecision(m.startX,m.startY),e.beginPath(),e.rect(0,0,D,I),e.clip();const J=D-ge*2-Re-le-4,Z=new P.DocSimpleSkeleton(x,q,A===o.WrapStrategy.WRAP,J,1/0);Z.calculate();const de=Z.getTotalWidth(),Q=Z.getTotalHeight(),b=Q+qe*2,H=Math.max(D-ge*2,1),{paddingTop:_}=St(H,I,de,b,j,N);e.translateWithPrecision(ge,_),P.Rect.drawWith(e,{width:H,height:b,fill:(k==null?void 0:k.color)||me,radius:Je}),e.save(),e.translateWithPrecision(Re,qe),e.beginPath(),e.rect(0,0,J,Q),e.clip(),P.Text.drawWith(e,{text:x,fontStyle:q,width:J,height:Q,color:(ae=s==null?void 0:s.cl)==null?void 0:ae.rgb,strokeLine:!!((ue=s==null?void 0:s.st)!=null&&ue.s),underline:!!((he=s==null?void 0:s.ul)!=null&&he.s),warp:A===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},Z),e.restore(),e.translateWithPrecision(J+Re+4,(Q-xe)/2),e.fillStyle=qn,e.fill(ft),e.restore(),f.set(w,{left:m.startX+ge+a.rowHeaderWidth,top:m.startY+_+a.columnHeaderHeight,width:H,height:b})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:v=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-v},p=S.endX-S.startX,O=C.getCellValueOrigin(n),M=`${O!=null?O:""}`;let{tb:R,pd:y}=a||{};const{t:m=o.DEFAULT_STYLES.pd.t,b:D=o.DEFAULT_STYLES.pd.b}=y!=null?y:{};if(R=R!=null?R:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const{l:I=o.DEFAULT_STYLES.pd.l,r:f=o.DEFAULT_STYLES.pd.r}=y!=null?y:{},w=p-I-f-le-4,F=new P.DocSimpleSkeleton(M,P.getFontStyleString(a).fontCache,R===o.WrapStrategy.WRAP,w,1/0);return F.calculate(),F.getTotalHeight()+m+D+De*2}else{const I=Math.max(p-ge*2-Re-le-4,10),f=new P.DocSimpleSkeleton(M,P.getFontStyleString(a).fontCache,R===o.WrapStrategy.WRAP,I,1/0);return f.calculate(),f.getTotalHeight()+De*2+qe*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:v=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-v},p=S.endX-S.startX,O=C.getCellValueOrigin(n),M=`${O!=null?O:""}`;let{tb:R,pd:y}=a||{};const{l:m=o.DEFAULT_STYLES.pd.l,r:D=o.DEFAULT_STYLES.pd.r}=y!=null?y:{};R=R!=null?R:o.WrapStrategy.WRAP;let I=ge*2+le;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:I=le+4+D+m;break;case o.DataValidationRenderMode.CUSTOM:I=le+ge*2+Re*2+D+m+Je/2+1;break;default:I=le+ge*2+Re*2+D+m+Je/2+1}const f=p-I,w=new P.DocSimpleSkeleton(M,P.getFontStyleString(a).fontCache,R===o.WrapStrategy.WRAP,f,1/0);return w.calculate(),w.getTotalWidth()+I}isHit(e,t){const{subUnitId:a,row:n,col:r}=t,s=this._ensureMap(a).get(this._generateKey(n,r)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,r);if(!d||!s||d.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:c,width:h,height:v}=s,{x:u,y:S}=e;return u>=c&&u<=c+h&&S>=l&&S<=l+v}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:r,col:i}=e,s={unitId:a,subUnitId:n,row:r,column:i};this._commandService.executeCommand(He.id,s)}onPointerEnter(e,t){var a,n;(n=(a=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(P.CURSOR_TYPE.DEFAULT)}};ot=Gn([Oe(0,o.IUniverInstanceService),Oe(1,o.Inject(o.LocaleService)),Oe(2,o.ICommandService),Oe(3,o.Inject(P.IRenderManagerService)),Oe(4,o.Inject(C.SheetDataValidationModel))],ot);class Jn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST);L(this,"canvasRender",this.injector.createInstance(ot));L(this,"dropdownType",Y.DataValidatorDropdownType.LIST);L(this,"optionsInput",Ne.componentKey);L(this,"formulaInput",C.LIST_FORMULA_INPUT_NAME)}}class Qn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.TEXT_LENGTH);L(this,"formulaInput",C.BASE_FORMULA_INPUT_NAME)}}class ea extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.WHOLE);L(this,"formulaInput",C.BASE_FORMULA_INPUT_NAME)}}var ta=Object.getOwnPropertyDescriptor,na=(e,t,a,n)=>{for(var r=n>1?void 0:n?ta(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Qe=(e,t)=>(a,n)=>t(a,n,e);let Te=class extends o.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[["DataValidationIcon",wt],[Fe,Cn],[Ne.componentKey,Ne],[Be.componentKey,Be],...Mn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Nn,ea,Qn,kn,jn,Jn,Kn,Un].forEach(e=>{const t=this._injector.createInstance(e),a=this._dataValidatorRegistryService.getValidatorItem(t.id);a&&(a.formulaInput=t.formulaInput,a.canvasRender=t.canvasRender,a.dropdownType=t.dropdownType,a.optionsInput=t.optionsInput)})}};Te=na([Qe(0,o.Inject(o.Injector)),Qe(1,o.Inject(E.ComponentManager)),Qe(2,o.Inject(Y.DataValidatorRegistryService))],Te);var aa=Object.getOwnPropertyDescriptor,ra=(e,t,a,n)=>{for(var r=n>1?void 0:n?aa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},et=(e,t)=>(a,n)=>t(a,n,e);const ia="SHEET_DATA_VALIDATION_UI_PLUGIN";var je;exports.UniverSheetsDataValidationMobileUIPlugin=(je=class extends o.Plugin{constructor(t=Ue,a,n,r){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=r;const{menu:i,...s}=o.merge({},Ue,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(lt,s)}onStarting(){[[ce],[fe],[Ae],[Ve],[be],[Me],[Ee],[Te]].forEach(t=>{this._injector.add(t)}),[$e,He,It,dt,Se,_t].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(P.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(Te),this._injector.get(be)}onSteady(){this._injector.get(Ve)}},L(je,"pluginName",ia),L(je,"type",o.UniverInstanceType.UNIVER_SHEET),je);exports.UniverSheetsDataValidationMobileUIPlugin=ra([et(1,o.Inject(o.Injector)),et(2,o.ICommandService),et(3,o.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);var oa=Object.defineProperty,sa=Object.getOwnPropertyDescriptor,la=(e,t,a)=>t in e?oa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,da=(e,t,a,n)=>{for(var r=n>1?void 0:n?sa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},tt=(e,t)=>(a,n)=>t(a,n,e),Ot=(e,t,a)=>la(e,typeof t!="symbol"?t+"":t,a);const ca="SHEET_DATA_VALIDATION_UI_PLUGIN";exports.UniverSheetsDataValidationUIPlugin=class extends o.Plugin{constructor(t=Ue,a,n,r){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=r;const{menu:i,...s}=o.merge({},Ue,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(lt,s)}onStarting(){[[ce],[fe],[Ae],[Ve],[be],[Me],[Ee],[we],[Te]].forEach(t=>{this._injector.add(t)}),[$e,He,It,dt,Se,_t].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(we),this._injector.get(Ae),this._injector.get(P.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(Te),this._injector.get(be)}onSteady(){this._injector.get(Ve)}};Ot(exports.UniverSheetsDataValidationUIPlugin,"pluginName",ca);Ot(exports.UniverSheetsDataValidationUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsDataValidationUIPlugin=da([o.DependentOn(C.UniverSheetsDataValidationPlugin),tt(1,o.Inject(o.Injector)),tt(2,o.ICommandService),tt(3,o.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);
|