@univerjs/sheets-data-validation-ui 0.5.0-nightly.202411221606 → 0.5.0-nightly.202411230627

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.
@@ -1,4 +1,5 @@
1
1
  import { Disposable, IUniverInstanceService, LocaleService } from '@univerjs/core';
2
+ import { SheetDataValidationModel } from '@univerjs/sheets-data-validation';
2
3
  import { CellAlertManagerService, HoverManagerService } from '@univerjs/sheets-ui';
3
4
  import { IZenZoneService } from '@univerjs/ui';
4
5
  export declare class DataValidationAlertController extends Disposable {
@@ -7,7 +8,8 @@ export declare class DataValidationAlertController extends Disposable {
7
8
  private readonly _univerInstanceService;
8
9
  private readonly _localeService;
9
10
  private readonly _zenZoneService;
10
- constructor(_hoverManagerService: HoverManagerService, _cellAlertManagerService: CellAlertManagerService, _univerInstanceService: IUniverInstanceService, _localeService: LocaleService, _zenZoneService: IZenZoneService);
11
+ private readonly _dataValidationModel;
12
+ constructor(_hoverManagerService: HoverManagerService, _cellAlertManagerService: CellAlertManagerService, _univerInstanceService: IUniverInstanceService, _localeService: LocaleService, _zenZoneService: IZenZoneService, _dataValidationModel: SheetDataValidationModel);
11
13
  private _init;
12
14
  private _initCellAlertPopup;
13
15
  private _initZenService;
@@ -1,3 +1,3 @@
1
1
  import { IDropdownComponentProps } from '../../../services/dropdown-manager.service';
2
2
  import { default as React } from 'react';
3
- export declare function DateDropdown(props: IDropdownComponentProps): React.JSX.Element | undefined;
3
+ export declare function DateDropdown(props: IDropdownComponentProps): React.JSX.Element | null | undefined;
@@ -1,14 +1,15 @@
1
1
  import { ICellRenderContext, ICommandService, ThemeService } from '@univerjs/core';
2
2
  import { IBaseDataValidationWidget } from '@univerjs/data-validation';
3
3
  import { IMouseEvent, IPointerEvent, UniverRenderingContext2D, IRenderManagerService } from '@univerjs/engine-render';
4
- import { DataValidationFormulaService } from '@univerjs/sheets-data-validation';
4
+ import { DataValidationFormulaService, SheetDataValidationModel } from '@univerjs/sheets-data-validation';
5
5
  export declare class CheckboxRender implements IBaseDataValidationWidget {
6
6
  private readonly _commandService;
7
7
  private readonly _formulaService;
8
8
  private readonly _themeService;
9
9
  private readonly _renderManagerService;
10
+ private readonly _dataValidationModel;
10
11
  private _calc;
11
- constructor(_commandService: ICommandService, _formulaService: DataValidationFormulaService, _themeService: ThemeService, _renderManagerService: IRenderManagerService);
12
+ constructor(_commandService: ICommandService, _formulaService: DataValidationFormulaService, _themeService: ThemeService, _renderManagerService: IRenderManagerService, _dataValidationModel: SheetDataValidationModel);
12
13
  calcCellAutoHeight(info: ICellRenderContext): number | undefined;
13
14
  calcCellAutoWidth(info: ICellRenderContext): number | undefined;
14
15
  private _parseFormula;
@@ -1,12 +1,14 @@
1
1
  import { ICellRenderContext, ICommandService } from '@univerjs/core';
2
2
  import { IBaseDataValidationWidget } from '@univerjs/data-validation';
3
3
  import { IMouseEvent, IPointerEvent, Spreadsheet, SpreadsheetSkeleton, UniverRenderingContext2D, IRenderManagerService } from '@univerjs/engine-render';
4
+ import { SheetDataValidationModel } from '@univerjs/sheets-data-validation';
4
5
  export declare class DropdownMultipleWidget implements IBaseDataValidationWidget {
5
6
  private readonly _commandService;
6
7
  private readonly _renderManagerService;
8
+ private readonly _dataValidationModel;
7
9
  zIndex?: number | undefined;
8
10
  private _dropdownInfoMap;
9
- constructor(_commandService: ICommandService, _renderManagerService: IRenderManagerService);
11
+ constructor(_commandService: ICommandService, _renderManagerService: IRenderManagerService, _dataValidationModel: SheetDataValidationModel);
10
12
  private _ensureMap;
11
13
  private _generateKey;
12
14
  private _drawDownIcon;
@@ -1,6 +1,7 @@
1
1
  import { ICellRenderContext, ICommandService, LocaleService } from '@univerjs/core';
2
2
  import { IBaseDataValidationWidget } from '@univerjs/data-validation';
3
3
  import { IMouseEvent, IPointerEvent, SpreadsheetSkeleton, UniverRenderingContext2D, IRenderManagerService } from '@univerjs/engine-render';
4
+ import { SheetDataValidationModel } from '@univerjs/sheets-data-validation';
4
5
  export interface IDropdownInfo {
5
6
  top: number;
6
7
  left: number;
@@ -11,8 +12,9 @@ export declare class DropdownWidget implements IBaseDataValidationWidget {
11
12
  private readonly _localeService;
12
13
  private readonly _commandService;
13
14
  private readonly _renderManagerService;
15
+ private readonly _dataValidationModel;
14
16
  private _dropdownInfoMap;
15
- constructor(_localeService: LocaleService, _commandService: ICommandService, _renderManagerService: IRenderManagerService);
17
+ constructor(_localeService: LocaleService, _commandService: ICommandService, _renderManagerService: IRenderManagerService, _dataValidationModel: SheetDataValidationModel);
16
18
  zIndex?: number | undefined;
17
19
  private _ensureMap;
18
20
  private _generateKey;
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(H,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("react"),require("@univerjs/core"),require("@univerjs/design"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("@univerjs/data-validation"),require("@univerjs/docs"),require("rxjs"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","react","@univerjs/core","@univerjs/design","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-data-validation","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/ui","@univerjs/data-validation","@univerjs/docs","rxjs","@univerjs/engine-formula","@univerjs/sheets-formula-ui"],g):(H=typeof globalThis<"u"?globalThis:H||self,g(H.UniverSheetsDataValidationUi={},H.React,H.UniverCore,H.UniverDesign,H.UniverEngineRender,H.UniverSheets,H.UniverSheetsDataValidation,H.UniverSheetsNumfmt,H.UniverSheetsUi,H.UniverUi,H.UniverDataValidation,H.UniverDocs,H.rxjs,H.UniverEngineFormula,H.UniverSheetsFormulaUi))})(this,function(H,g,o,T,B,X,R,Jt,N,z,Q,Qt,se,Je,Qe){"use strict";var ii=Object.defineProperty;var oi=(H,g,o)=>g in H?ii(H,g,{enumerable:!0,configurable:!0,writable:!0,value:o}):H[g]=o;var L=(H,g,o)=>oi(H,typeof g!="symbol"?g+"":g,o);var qe,Ze;var Ct={exports:{}},je={};/**
1
+ (function(Y,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("react"),require("@univerjs/core"),require("@univerjs/design"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("@univerjs/data-validation"),require("@univerjs/docs"),require("rxjs"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","react","@univerjs/core","@univerjs/design","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-data-validation","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/ui","@univerjs/data-validation","@univerjs/docs","rxjs","@univerjs/engine-formula","@univerjs/sheets-formula-ui"],f):(Y=typeof globalThis<"u"?globalThis:Y||self,f(Y.UniverSheetsDataValidationUi={},Y.React,Y.UniverCore,Y.UniverDesign,Y.UniverEngineRender,Y.UniverSheets,Y.UniverSheetsDataValidation,Y.UniverSheetsNumfmt,Y.UniverSheetsUi,Y.UniverUi,Y.UniverDataValidation,Y.UniverDocs,Y.rxjs,Y.UniverEngineFormula,Y.UniverSheetsFormulaUi))})(this,function(Y,f,o,O,B,X,E,Jt,N,z,Q,Qt,re,Qe,et){"use strict";var ii=Object.defineProperty;var oi=(Y,f,o)=>f in Y?ii(Y,f,{enumerable:!0,configurable:!0,writable:!0,value:o}):Y[f]=o;var L=(Y,f,o)=>oi(Y,typeof f!="symbol"?f+"":f,o);var Ze,Je;var Dt={exports:{}},Ae={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var en=g,tn=Symbol.for("react.element"),nn=Symbol.for("react.fragment"),an=Object.prototype.hasOwnProperty,on=en.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,rn={key:!0,ref:!0,__self:!0,__source:!0};function Dt(e,t,a){var n,i={},r=null,s=null;a!==void 0&&(r=""+a),t.key!==void 0&&(r=""+t.key),t.ref!==void 0&&(s=t.ref);for(n in t)an.call(t,n)&&!rn.hasOwnProperty(n)&&(i[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)i[n]===void 0&&(i[n]=t[n]);return{$$typeof:tn,type:e,key:r,ref:s,props:i,_owner:on.current}}je.Fragment=nn,je.jsx=Dt,je.jsxs=Dt,Ct.exports=je;var h=Ct.exports,sn=Object.defineProperty,ln=Object.getOwnPropertyDescriptor,dn=(e,t,a,n)=>{for(var i=n>1?void 0:n?ln(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&sn(t,a,i),i},Oe=(e,t)=>(a,n)=>t(a,n,e);let Te=class extends o.Disposable{constructor(e,t,a,n,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(X.AFTER_CELL_EDIT_ASYNC,{handler:async(e,t,a)=>{var f;const n=await e,{worksheet:i,row:r,col:s,unitId:d,subUnitId:l,workbook:p}=t,u=this._dataValidationModel.getRuleIdByLocation(d,l,r,s),m=u?this._dataValidationModel.getRuleById(d,l,u):void 0;if(!m||m.errorStyle!==o.DataValidationErrorStyle.STOP)return a(Promise.resolve(n));const c=await this._dataValidatorRegistryService.getValidatorItem(m.type);if(!c||await c.validator({value:R.getCellValueOrigin(n),interceptValue:R.getCellValueOrigin((f=t==null?void 0:t.origin)!=null?f:n),row:r,column:s,unitId:d,subUnitId:l,worksheet:i,workbook:p,t:n==null?void 0:n.t},m))return a(Promise.resolve(n));const v=i.getCellRaw(r,s);return this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:c.getRuleFinalError(m,{row:r,col:s,unitId:d,subUnitId:l})},footer:{title:g.createElement(T.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(Promise.resolve(v))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:g.createElement(T.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Te=dn([Oe(0,o.Inject(X.SheetInterceptorService)),Oe(1,o.Inject(R.SheetDataValidationModel)),Oe(2,o.Inject(Q.DataValidatorRegistryService)),Oe(3,z.IDialogService),Oe(4,o.Inject(o.LocaleService))],Te);const wt={dvDateDropdown:"univer-dv-date-dropdown",dvDateDropdownBtns:"univer-dv-date-dropdown-btns"},cn=e=>{if(e==null||typeof e=="boolean")return;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 un(e){var b,I,V;const{location:t,hideFn:a}=e,{worksheet:n,row:i,col:r,unitId:s,subUnitId:d,workbook:l}=t,p=o.useDependency(o.ICommandService),u=o.useDependency(Te),m=n.getCell(i,r),c=(b=m==null?void 0:m.dataValidation)==null?void 0:b.rule,S=(I=m==null?void 0:m.dataValidation)==null?void 0:I.validator,v=R.getCellValueOrigin(n.getCellRaw(i,r)),f=cn(v),[D,C]=g.useState(f),w=!!((V=c==null?void 0:c.bizInfo)!=null&&V.showTime),_=D&&D.isValid()?D:o.dayjs(),M=o.useDependency(o.LocaleService);if(!m||!c||!S)return;const E=async()=>{var U,k,K;if(!_)return;const Y=_.format(w?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),F=(U=o.numfmt.parseDate(Y))==null?void 0:U.v,P=l.getStyles().getStyleByCell(m),j=(K=(k=P==null?void 0:P.n)==null?void 0:k.pattern)!=null?K:"",x=Jt.getPatternType(j);c.errorStyle!==o.DataValidationErrorStyle.STOP||await S.validator({value:F,unitId:s,subUnitId:d,row:i,column:r,worksheet:n,workbook:l,interceptValue:Y.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(a(),await p.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:B.DeviceInputEventType.Keyboard,unitId:s,keycode:z.KeyCode.ESC}),await p.executeCommand(X.SetRangeValuesCommand.id,{unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:F,t:2,p:null,f:null,si:null,s:{n:{pattern:w?x==="datetime"?j:"yyyy-MM-dd hh:mm:ss":x==="date"?j:"yyyy-MM-dd"}}}})):u.showReject(S.getRuleFinalError(c,{row:i,col:r,unitId:s,subUnitId:d}))};return h.jsxs("div",{className:wt.dvDateDropdown,children:[h.jsx(T.DatePanel,{defaultValue:_,pickerValue:_,showTime:w||void 0,onSelect:async A=>{C(A)},onPanelChange:A=>{C(A)},disabledDate:A=>!o.numfmt.parseDate(A.format("YYYY-MM-DD"))}),h.jsx("div",{className:wt.dvDateDropdownBtns,children:h.jsx(T.Button,{size:"small",type:"primary",onClick:E,disabled:!_.isValid(),children:M.t("dataValidation.alert.ok")})})]})}var le=function(){return le=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},le.apply(this,arguments)},pn=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 i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(a[n[i]]=e[n[i]]);return a},ve=g.forwardRef(function(e,t){var a=e.icon,n=e.id,i=e.className,r=e.extend,s=pn(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),l=g.useRef("_".concat(vn()));return yt(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},le({ref:t,className:d},s),r)});function yt(e,t,a,n,i){return g.createElement(e.tag,le(le({key:t},hn(e,a,i)),n),(mn(e,a).children||[]).map(function(r,s){return yt(r,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,i)}))}function hn(e,t,a){var n=le({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1);var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],d=r[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function mn(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)?le(le({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?le(le({},i),{attrs:le(le({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function vn(){return Math.random().toString(36).substring(2,8)}ve.displayName="UniverIcon";var fn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Vt=g.forwardRef(function(e,t){return g.createElement(ve,Object.assign({},e,{id:"check-mark-single",ref:t,icon:fn}))});Vt.displayName="CheckMarkSingle";var gn={tag:"svg",attrs:{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.83062 8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767 13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279zM14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217 14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046 13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703 10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046 9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217 9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746 9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732 13.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"}}]},Et=g.forwardRef(function(e,t){return g.createElement(ve,Object.assign({},e,{id:"data-validation-single",ref:t,icon:gn}))});Et.displayName="DataValidationSingle";var Sn={tag:"svg",attrs:{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.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.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.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.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"}}]},et=g.forwardRef(function(e,t){return g.createElement(ve,Object.assign({},e,{id:"delete-single",ref:t,icon:Sn}))});et.displayName="DeleteSingle";var _n={tag:"svg",attrs:{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"}}]},Rt=g.forwardRef(function(e,t){return g.createElement(ve,Object.assign({},e,{id:"increase-single",ref:t,icon:_n}))});Rt.displayName="IncreaseSingle";var In={tag:"svg",attrs:{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"}}]},Mt=g.forwardRef(function(e,t){return g.createElement(ve,Object.assign({},e,{id:"more-down-single",ref:t,icon:In}))});Mt.displayName="MoreDownSingle";var Cn={tag:"svg",attrs:{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"}}]},bt=g.forwardRef(function(e,t){return g.createElement(ve,Object.assign({},e,{id:"more-up-single",ref:t,icon:Cn}))});bt.displayName="MoreUpSingle";var Dn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},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 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},Ot=g.forwardRef(function(e,t){return g.createElement(ve,Object.assign({},e,{id:"sequence-single",ref:t,icon:Dn}))});Ot.displayName="SequenceSingle";var wn=Object.defineProperty,yn=Object.getOwnPropertyDescriptor,Vn=(e,t,a,n)=>{for(var i=n>1?void 0:n?yn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&wn(t,a,i),i},Tt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends o.Disposable{constructor(t,a){super();L(this,"_open$",new se.BehaviorSubject(!1));L(this,"open$",this._open$.pipe(se.distinctUntilChanged()));L(this,"_activeRule");L(this,"_activeRule$",new se.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(se.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===tt&&(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=Vn([Tt(0,o.IUniverInstanceService),Tt(1,z.ISidebarService)],ue);function En(){const e=o.useDependency(fe),t=z.useObservable(e.activeDropdown$,e.activeDropdown),a=o.useDependency(z.ComponentManager);if(!t)return null;const{location:n,componentKey:i}=t,r=a.get(i),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!r)return null;const d=()=>{e.hideDropdown()};return h.jsx(r,{location:n,hideFn:d},s)}const Lt="sheet.ui.dropdown";var Rn=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,bn=(e,t,a,n)=>{for(var i=n>1?void 0:n?Mn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Rn(t,a,i),i},Se=(e,t)=>(a,n)=>t(a,n,e);let fe=class extends o.Disposable{constructor(t,a,n,i,r,s,d){super();L(this,"_activeDropdown");L(this,"_activeDropdown$",new se.Subject);L(this,"_currentPopup",null);L(this,"activeDropdown$",this._activeDropdown$.asObservable());L(this,"_zenVisible",!1);this._canvasPopupManagerService=t,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=i,this._renderManagerService=r,this._dataValidationModel=s,this._sheetsSelectionsService=d,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,i){const r=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!r)return;const s=a?r.getSheetBySheetId(a):r.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(r.getUnitId(),s.getSheetId(),n,i);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdown}_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,a=!0){const{location:n}=t,{row:i,col:r,unitId:s,subUnitId:d}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const l=this._renderManagerService.getRenderById(o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),p=this._canvasPopupManagerService.attachPopupToCell(i,r,{componentKey:Lt,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[l==null?void 0:l.engine.getCanvasElement()].filter(Boolean)},s,d);if(!p)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const u=new o.DisposableCollection;u.add(p),u.add({dispose:()=>{var m,c;(c=(m=this._activeDropdown)==null?void 0:m.onHide)==null||c.call(m)}}),this._currentPopup=u}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,a,n,i,r){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,i);if(!l)return;const p=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!p||!p.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:i,unitId:t,subUnitId:a},componentKey:p.dropdown,onHide:r})}};fe=bn([Se(0,o.Inject(N.SheetCanvasPopManagerService)),Se(1,o.IUniverInstanceService),Se(2,o.Inject(Q.DataValidatorRegistryService)),Se(3,z.IZenZoneService),Se(4,B.IRenderManagerService),Se(5,o.Inject(R.SheetDataValidationModel)),Se(6,o.Inject(X.SheetsSelectionsService))],fe);const tt="DataValidationPanel",_e={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,i=e.get(ue),r=e.get(Q.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(z.ISidebarService),l=X.getSheetCommandTarget(s);if(!l)return!1;const{unitId:p,subUnitId:u}=l,m=a?r.getRuleById(p,u,a):void 0;i.open(),i.setActiveRule(m&&{unitId:p,subUnitId:u,rule:m});const c=d.open({header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:tt},width:312,onClose:()=>i.close()});return i.setCloseDisposable(c),!0}},nt={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},Pt={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(nt.id):t.executeCommand(_e.id),!0}},Ae={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:i,row:r,column:s}=t,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===i&&l.row===r&&l.col===s||a.showDataValidationDropdown(n,i,r,s),!0}},jt={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},Ie="#ECECEC",at="sheets-data-validation-ui.config",At={},me={dvListDropdown:"univer-dv-list-dropdown",dvListDropdownTitle:"univer-dv-list-dropdown-title",dvListDropdownList:"univer-dv-list-dropdown-list",dvListDropdownListContainer:"univer-dv-list-dropdown-list-container",dvListDropdownSelectedIcon:"univer-dv-list-dropdown-selected-icon",dvListDropdownItemContainer:"univer-dv-list-dropdown-item-container",dvListDropdownItem:"univer-dv-list-dropdown-item",dvListDropdownSplit:"univer-dv-list-dropdown-split",dvListDropdownEdit:"univer-dv-list-dropdown-edit"},On=e=>{var E,b;const{value:t,onChange:a,multiple:n,options:i,title:r,onEdit:s,style:d,filter:l,location:p}=e,u=o.useDependency(o.LocaleService),m=o.useDependency(o.IConfigService),c=l==null?void 0:l.toLowerCase(),{row:S,col:v,unitId:f,subUnitId:D}=p,C=i.filter(I=>c?I.label.toLowerCase().includes(c):!0),w=(b=(E=m.getConfig(at))==null?void 0:E.showEditOnDropdown)!=null?b:!0,_=o.useDependency(N.SheetPermissionInterceptorBaseController),M=g.useMemo(()=>_.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission]},[{startColumn:v,startRow:S,endColumn:v,endRow:S}],f,D),[_,v,S,f,D]);return h.jsxs("div",{className:me.dvListDropdown,style:d,children:[h.jsx("div",{className:me.dvListDropdownTitle,children:r}),h.jsx("div",{className:me.dvListDropdownList,children:h.jsx(T.Scrollbar,{children:h.jsx("div",{className:me.dvListDropdownListContainer,children:C.map((I,V)=>{const A=t.indexOf(I.value)>-1,Y=()=>{let P;A?P=new Set(t.filter(x=>x!==I.value)):P=new Set(n?[...t,I.value]:[I.value]);const j=[];i.forEach(x=>{P.has(x.value)&&j.push(x.value)}),a(j)},F=I.label.toLocaleLowerCase().indexOf(c);return h.jsxs("div",{className:me.dvListDropdownItemContainer,onClick:Y,children:[h.jsx("div",{className:me.dvListDropdownItem,style:{background:I.color||Ie},children:c&&I.label.toLowerCase().includes(c)?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:I.label.substring(0,F)}),h.jsx("span",{style:{fontWeight:"bold"},children:I.label.substring(F,F+c.length)}),h.jsx("span",{children:I.label.substring(F+c.length)})]}):I.label}),h.jsx("div",{className:me.dvListDropdownSelectedIcon,children:A?h.jsx(Vt,{}):null})]},V)})})},l)}),w&&M?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:me.dvListDropdownSplit}),h.jsx("div",{className:me.dvListDropdownEdit,children:h.jsx("a",{onClick:s,children:u.t("dataValidation.list.edit")})})]}):null]})};function Tn(e){var x,U,k,K,G,te;const{location:t,hideFn:a}=e,{worksheet:n,row:i,col:r,unitId:s,subUnitId:d}=t,l=o.useDependency(Q.DataValidationModel),[p,u]=g.useState(""),m=o.useDependency(o.ICommandService),c=o.useDependency(o.LocaleService),[S,v]=g.useState(""),f=o.useDependency(N.IEditorBridgeService),D=o.useDependency(o.IUniverInstanceService),C=g.useMemo(()=>l.ruleChange$.pipe(se.debounceTime(16)),[]);z.useObservable(C);const w=z.RectPopup.useContext(),_=((U=(x=w.current)==null?void 0:x.right)!=null?U:0)-((K=(k=w.current)==null?void 0:k.left)!=null?K:0);if(g.useEffect(()=>{const Z=m.onCommandExecuted(J=>{var ne,re;if(J.id===Qt.RichTextEditingMutation.id){const de=J.params,{unitId:ae}=de,oe=D.getUnit(ae,o.UniverInstanceType.UNIVER_DOC);if(!oe)return;const O=o.BuildTextUtils.transform.getPlainText((re=(ne=oe.getSnapshot().body)==null?void 0:ne.dataStream)!=null?re:"");u(O)}});return()=>{Z.dispose()}},[m,D]),!n)return null;const M=n.getCell(i,r),E=(G=M==null?void 0:M.dataValidation)==null?void 0:G.rule,b=(te=M==null?void 0:M.dataValidation)==null?void 0:te.validator,I=(E==null?void 0:E.renderMode)===o.DataValidationRenderMode.CUSTOM||(E==null?void 0:E.renderMode)===void 0;if(!M||!E||!b||b.id.indexOf(o.DataValidationType.LIST)!==0)return;const V=E.type===o.DataValidationType.LIST_MULTIPLE,A=b.getListWithColor(E,s,d),Y=S||R.getDataValidationCellValue(n.getCellRaw(i,r)),F=R.deserializeListOptions(Y),P=()=>{m.executeCommand(_e.id,{ruleId:E.uid}),a()},j=A.map(Z=>({label:Z.label,value:Z.label,color:I||Z.color?Z.color:"transparent"}));return h.jsx(On,{style:{minWidth:_,maxWidth:Math.max(_,200)},title:V?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:F,multiple:V,onChange:async Z=>{const J=R.serializeListOptions(Z),ne={unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:J,p:null,f:null,si:null}};f.isVisible()&&f.changeVisible({visible:!1,keycode:z.KeyCode.ESC,eventType:B.DeviceInputEventType.Keyboard,unitId:s}),v(J),V||a(),f.isVisible().visible&&await m.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:B.DeviceInputEventType.Keyboard,unitId:s,keycode:z.KeyCode.ESC}),m.executeCommand(X.SetRangeValuesCommand.id,ne)},options:j,onEdit:P,filter:p,location:t})}const it={dataValidationOptionsButton:"univer-data-validation-options-button",dataValidationOptionsButtonIcon:"univer-data-validation-options-button-icon"};function Ln(e){var p;const t=o.useDependency(o.LocaleService),a=o.useDependency(z.ComponentManager),{value:n,onChange:i,extraComponent:r}=e,[s,d]=g.useState(!1),l=r?a.get(r):null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:it.dataValidationOptionsButton,onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?h.jsx(bt,{className:it.dataValidationOptionsButtonIcon}):h.jsx(Mt,{className:it.dataValidationOptionsButtonIcon})]}),s&&h.jsxs(h.Fragment,{children:[l?h.jsx(l,{value:n,onChange:i}):null,h.jsx(T.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:h.jsxs(T.RadioGroup,{value:`${(p=n.errorStyle)!=null?p:o.DataValidationErrorStyle.WARNING}`,onChange:u=>i({...n,errorStyle:+u}),children:[h.jsx(T.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),h.jsx(T.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),h.jsx(T.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:h.jsx(T.Checkbox,{checked:n.showErrorMessage,onChange:()=>i({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?h.jsx(T.FormLayout,{children:h.jsx(T.Input,{value:n.error,onChange:u=>i({...n,error:u})})}):null]})]})}const we={dataValidationDetail:"univer-data-validation-detail",dataValidationDetailFormItem:"univer-data-validation-detail-form-item",dataValidationDetailButtons:"univer-data-validation-detail-buttons",dataValidationDetailButton:"univer-data-validation-detail-button"},Pn=e=>o.debounce(async(t,a,n,i)=>{const r=await e.executeCommand(t,a,n);i==null||i(r)},1e3);function jn(e,t,a){var n,i,r,s;return t?((i=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:i.getSheetId())||"":((s=(r=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function An(){var oe;const[e,t]=g.useState(0),a=o.useDependency(ue),n=z.useObservable(a.activeRule$,a.activeRule),{unitId:i,subUnitId:r,rule:s}=n||{},d=s.uid,l=o.useDependency(Q.DataValidatorRegistryService),p=o.useDependency(o.IUniverInstanceService),u=o.useDependency(z.ComponentManager),m=o.useDependency(o.ICommandService),c=o.useDependency(Q.DataValidationModel),S=o.useDependency(o.LocaleService),[v,f]=g.useState(s),D=l.getValidatorItem(v.type),[C,w]=g.useState(!1),_=l.getValidatorsByScope(Q.DataValidatorRegistryScope.SHEET),[M,E]=g.useState(()=>v.ranges.map(O=>({unitId:"",sheetId:"",range:O}))),b=g.useMemo(()=>Pn(m),[m]),[I,V]=g.useState(!1),A=g.useRef({}),[Y,F]=g.useState(!1),P=o.useDependency(X.SheetsSelectionsService);if(g.useEffect(()=>()=>{const O=P.getCurrentLastSelection();O&&P.setSelections([O])},[P]),g.useEffect(()=>{m.onCommandExecuted(O=>{(O.id===o.UndoCommand.id||O.id===o.RedoCommand.id)&&setTimeout(()=>{const y=c.getRuleById(i,r,d);t(W=>W+1),y&&(f(y),E(y.ranges.map(W=>({unitId:"",sheetId:"",range:W}))))},20)})},[m,c,d,r,i]),!D)return null;const j=D.operators,x=D.operatorNames,U=v.operator?Q.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,k=()=>{!v.ranges.length||I||(D.validatorFormula(v,i,r).success?a.setActiveRule(null):w(!0))},K=z.useEvent(O=>{const y=O.split(",").map(Je.deserializeRangeWithSheet).map(q=>{const ge=q.sheetName;if(ge){const ai=jn(p,q.unitId,ge);return{...q,sheetId:ai}}return{...q,sheetId:""}});if(o.isUnitRangesEqual(y,M))return;E(y);const W=y.filter(q=>(!q.unitId||q.unitId===i)&&(!q.sheetId||q.sheetId===r)).map(q=>q.range);if(f({...v,ranges:W}),W.length===0)return;const $={unitId:i,subUnitId:r,ruleId:d,ranges:W};b(R.UpdateSheetDataValidationRangeCommand.id,$)}),G=O=>{if(o.shallowEqual(O,Q.getRuleSetting(v)))return;f({...v,...O});const y={unitId:i,subUnitId:r,ruleId:d,setting:O};b(R.UpdateSheetDataValidationSettingCommand.id,y,void 0)},te=async()=>{await m.executeCommand(R.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:i,subUnitId:r}),a.setActiveRule(null)},Z={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},J=O=>{const y=l.getValidatorItem(O);if(!y)return;const W=y.operators,$=c.getRuleById(i,r,d),q=O===($==null?void 0:$.type)||O.includes("list")&&($!=null&&$.type.includes("list"))?{...$,type:O}:{...v,type:O,operator:W[0],formula1:void 0,formula2:void 0};f(q),m.executeCommand(R.UpdateSheetDataValidationSettingCommand.id,{unitId:i,subUnitId:r,ruleId:v.uid,setting:Q.getRuleSetting(q)})},ne=u.get(D.formulaInput),re=g.useMemo(()=>M.map(O=>Je.serializeRange(O.range)).join(","),[]),de=Q.getRuleOptions(v),ae=O=>{o.shallowEqual(O,Q.getRuleOptions(v))||(f({...v,...O}),b(R.UpdateSheetDataValidationOptionsCommand.id,{unitId:i,subUnitId:r,ruleId:d,options:O}))};return z.useSidebarClick(O=>{var W;const y=(W=A.current)==null?void 0:W.handleOutClick;y&&y(O,()=>F(!1))}),h.jsxs("div",{className:we.dataValidationDetail,children:[h.jsx(T.FormLayout,{label:S.t("dataValidation.panel.range"),error:!v.ranges.length||I?S.t("dataValidation.panel.rangeError"):"",children:h.jsx(Qe.RangeSelector,{unitId:i,subUnitId:r,initValue:re,onChange:K,onFocus:()=>F(!0),isFocus:Y,actions:A.current,onVerify:O=>V(!O)})}),h.jsx(T.FormLayout,{label:S.t("dataValidation.panel.type"),children:h.jsx(T.Select,{options:_==null?void 0:_.map(O=>({label:S.t(O.title),value:O.id})),value:v.type,onChange:J,className:we.dataValidationDetailFormItem})}),j!=null&&j.length?h.jsx(T.FormLayout,{label:S.t("dataValidation.panel.operator"),children:h.jsx(T.Select,{options:j.map((O,y)=>({value:`${O}`,label:x[y]})),value:`${v.operator}`,onChange:O=>{G({...Z,operator:O})},className:we.dataValidationDetailFormItem})}):null,ne?h.jsx(ne,{isTwoFormula:U,value:{formula1:v.formula1,formula2:v.formula2},onChange:O=>{G({...Z,...O})},showError:C,validResult:D.validatorFormula(v,i,r),unitId:i,subUnitId:r,ruleId:d},e+v.type):null,h.jsx(T.FormLayout,{children:h.jsx(T.Checkbox,{checked:(oe=v.allowBlank)!=null?oe:!0,onChange:()=>{var O;return G({...Z,allowBlank:!((O=v.allowBlank)==null||O)})},children:S.t("dataValidation.panel.allowBlank")})}),h.jsx(Ln,{value:de,onChange:ae,extraComponent:D.optionsInput}),h.jsxs("div",{className:we.dataValidationDetailButtons,children:[h.jsx(T.Button,{className:we.dataValidationDetailButton,onClick:te,children:S.t("dataValidation.panel.removeRule")}),h.jsx(T.Button,{className:we.dataValidationDetailButton,type:"primary",onClick:k,children:S.t("dataValidation.panel.done")})]})]})}const Fe={dataValidationItemContainer:"univer-data-validation-item-container",dataValidationItemTitle:"univer-data-validation-item-title",dataValidationItemContent:"univer-data-validation-item-content",dataValidationItemIcon:"univer-data-validation-item-icon"},Fn=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:i,disable:r}=e,s=o.useDependency(Q.DataValidatorRegistryService),d=o.useDependency(o.ICommandService),l=o.useDependency(N.IMarkSelectionService),p=s.getValidatorItem(t.type),u=g.useRef(),[m,c]=g.useState(!1),S=v=>{d.executeCommand(R.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:i}),v.stopPropagation()};return g.useEffect(()=>()=>{var v;u.current&&((v=u.current)==null||v.forEach(f=>{f&&l.removeShape(f)}))},[l]),h.jsxs("div",{className:Fe.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{r||(c(!0),u.current=t.ranges.map(v=>l.addShape({range:v,style:{fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:null})))},onMouseLeave:()=>{var v;c(!1),(v=u.current)==null||v.forEach(f=>{f&&l.removeShape(f)}),u.current=void 0},children:[h.jsx("div",{className:Fe.dataValidationItemTitle,children:p==null?void 0:p.generateRuleName(t)}),h.jsx("div",{className:Fe.dataValidationItemContent,children:t.ranges.map(v=>Je.serializeRange(v)).join(",")}),m?h.jsx("div",{className:Fe.dataValidationItemIcon,onClick:S,children:h.jsx(et,{})}):null]})},xe={dataValidationList:"univer-data-validation-list",dataValidationListButtons:"univer-data-validation-list-buttons",dataValidationListButton:"univer-data-validation-list-button"};function xn(){const e=o.useDependency(o.IUniverInstanceService),t=z.useObservable(()=>e.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return t?h.jsx(Nn,{workbook:t}):null}function Nn(e){const t=o.useDependency(R.SheetDataValidationModel),a=o.useDependency(o.IUniverInstanceService),n=o.useDependency(o.ICommandService),i=o.useDependency(o.Injector),r=o.useDependency(ue),s=o.useDependency(o.LocaleService),[d,l]=g.useState([]),{workbook:p}=e,u=z.useObservable(p.activeSheet$,void 0,!0),m=p.getUnitId(),c=u==null?void 0:u.getSheetId();g.useEffect(()=>{l(t.getRules(m,c));const w=t.ruleChange$.subscribe(_=>{_.unitId===m&&_.subUnitId===c&&l(t.getRules(m,c))});return()=>{w.unsubscribe()}},[m,c,t]);const S=async()=>{const w=R.createDefaultNewRule(i),_={unitId:m,subUnitId:c,rule:w};await n.executeCommand(R.AddSheetDataValidationCommand.id,_),r.setActiveRule({unitId:m,subUnitId:c,rule:w})},v=()=>{n.executeCommand(R.RemoveSheetAllDataValidationCommand.id,{unitId:m,subUnitId:c})},D=(w=>{const _=a.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),M=_.getActiveSheet(),E=_.getUnitId(),b=M.getSheetId();return w.map(V=>X.checkRangesEditablePermission(i,E,b,V.ranges)?{...V}:{...V,disable:!0})})(d),C=D==null?void 0:D.some(w=>w.disable);return h.jsxs("div",{className:xe.dataValidationList,children:[D==null?void 0:D.map(w=>{var _;return h.jsx(Fn,{unitId:m,subUnitId:c,onClick:()=>{w.disable||r.setActiveRule({unitId:m,subUnitId:c,rule:w})},rule:w,disable:(_=w.disable)!=null?_:!1},w.uid)}),h.jsxs("div",{className:xe.dataValidationListButtons,children:[d.length&&!C?h.jsx(T.Button,{className:xe.dataValidationListButton,onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,h.jsx(T.Button,{className:xe.dataValidationListButton,type:"primary",onClick:S,children:s.t("dataValidation.panel.add")})]})]})}const Un=()=>{const e=o.useDependency(ue),t=z.useObservable(e.activeRule$,e.activeRule);return t?h.jsx(An,{},t.rule.uid):h.jsx(xn,{})},Ne="data-validation.list.dropdown",ot="data-validation.date.dropdown",Ue={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),a=X.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:i}=a,r=R.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=i.getSheetId(),p={rule:r,unitId:d,subUnitId:l};return s.syncExecuteCommand(R.AddSheetDataValidationCommand.id,p)?(s.syncExecuteCommand(_e.id,{ruleId:r.uid,isAdd:!0}),!0):!1}};var Bn=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,Wn=(e,t,a,n)=>{for(var i=n>1?void 0:n?kn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Bn(t,a,i),i},Le=(e,t)=>(a,n)=>t(a,n,e);const Be="SHEET_DATA_VALIDATION_ALERT";let Pe=class extends o.Disposable{constructor(e,t,a,n,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(se.debounceTime(100)).subscribe(e=>{var t,a;if(e){const i=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!i)return;const r=i.getCell(e.location.row,e.location.col);if(((t=r==null?void 0:r.dataValidation)==null?void 0:t.validStatus)===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Be),d=(a=s==null?void 0:s.alert)==null?void 0:a.location;if(d&&d.row===e.location.row&&d.col===e.location.col&&d.subUnitId===e.location.subUnitId&&d.unitId===e.location.unitId)return;const l=r.dataValidation.validator,p=r.dataValidation.rule;if(!l)return;this._cellAlertManagerService.showAlert({type:N.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(p,e.location),location:e.location,width:200,height:74,key:Be});return}}this._cellAlertManagerService.removeAlert(Be)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(Be)}))}};Pe=Wn([Le(0,o.Inject(N.HoverManagerService)),Le(1,o.Inject(N.CellAlertManagerService)),Le(2,o.IUniverInstanceService),Le(3,o.Inject(o.LocaleService)),Le(4,z.IZenZoneService)],Pe);var $n=Object.defineProperty,Hn=Object.getOwnPropertyDescriptor,Yn=(e,t,a,n)=>{for(var i=n>1?void 0:n?Hn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&$n(t,a,i),i},rt=(e,t)=>(a,n)=>t(a,n,e);let ye=class extends o.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._dataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(i,r)=>{const{source:s,target:d,unitId:l,subUnitId:p}=i,u=this._dataValidationModel.getRuleObjectMatrix(l,p).clone(),m=N.virtualizeDiscreteRanges([s,d]),[c,S]=m.ranges,{mapFunc:v}=m,f={row:c.startRow,col:c.startColumn},D=N.getAutoFillRepeatRange(c,S),C=new o.ObjectMatrix,w=new Set;D.forEach(I=>{const V=I.repeatStartCell,A=I.relativeRange,Y={startRow:f.row,startColumn:f.col,endColumn:f.col,endRow:f.row},F={startRow:V.row,startColumn:V.col,endColumn:V.col,endRow:V.row};o.Range.foreach(A,(P,j)=>{const x=o.Rectangle.getPositionRange({startRow:P,startColumn:j,endColumn:j,endRow:P},Y),{row:U,col:k}=v(x.startRow,x.startColumn),K=this._dataValidationModel.getRuleIdByLocation(l,p,U,k);if(K){const G=o.Rectangle.getPositionRange({startRow:P,startColumn:j,endColumn:j,endRow:P},F),{row:te,col:Z}=v(G.startRow,G.startColumn);C.setValue(te,Z,K),w.add(K)}})});const _=Array.from(w).map(I=>({id:I,ranges:o.queryObjectMatrix(C,V=>V===I)}));u.addRangeRules(_);const M=u.diff(this._dataValidationModel.getRules(l,p)),{redoMutations:E,undoMutations:b}=R.getDataValidationDiffMutations(l,p,M,this._injector,"patched",r===N.APPLY_TYPE.ONLY_FORMAT);return{undos:b,redos:E}},a=[o.DataValidationType.CHECKBOX],n={id:R.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:i=>{const{source:r,unitId:s,subUnitId:d}=i;for(const l of r.rows)for(const p of r.cols){const u=this._dataValidationModel.getRuleByLocation(s,d,l,p);if(u&&a.indexOf(u.type)>-1){this._autoFillService.setDisableApplyType(N.APPLY_TYPE.SERIES,!0);return}}},onFillData:(i,r,s)=>s===N.APPLY_TYPE.COPY||s===N.APPLY_TYPE.ONLY_FORMAT||s===N.APPLY_TYPE.SERIES?t(i,s):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};ye=Yn([rt(0,N.IAutoFillService),rt(1,o.Inject(R.SheetDataValidationModel)),rt(2,o.Inject(o.Injector))],ye);var Xn=Object.defineProperty,zn=Object.getOwnPropertyDescriptor,Kn=(e,t,a,n)=>{for(var i=n>1?void 0:n?zn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Xn(t,a,i),i},st=(e,t)=>(a,n)=>t(a,n,e);let Ve=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:R.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,i)=>{const{copyType:r=N.COPY_TYPE.COPY,pasteType:s}=i,{range:d}=t||{},{range:l,unitId:p,subUnitId:u}=a;return this._generateMutations(l,{copyType:r,pasteType:s,copyRange:d,unitId:p,subUnitId:u})}})}_collect(t,a,n){const i=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:i};const r=this._injector.invoke(l=>N.rangeToDiscreteRange(n,l,t,a));if(!r)return;const{rows:s,cols:d}=r;s.forEach((l,p)=>{d.forEach((u,m)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(t,a,l,u);i.setValue(p,m,c!=null?c:"")})})}_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:n,subUnitId:i}=this._copyInfo;if(a.unitId!==n||i!==a.subUnitId){const r=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),s=new o.ObjectMatrix,d=new Set,{ranges:[l,p],mapFunc:u}=N.virtualizeDiscreteRanges([a.copyRange,t]),m=N.getRepeatRange(l,p,!0),c=new Map;m.forEach(({startRange:D})=>{var C;(C=this._copyInfo)==null||C.matrix.forValue((w,_,M)=>{const E=o.Rectangle.getPositionRange({startRow:w,endRow:w,startColumn:_,endColumn:_},D),b=`${i}-${M}`,I=this._sheetDataValidationModel.getRuleById(n,i,M);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,b)&&I&&c.set(b,{...I,uid:b});const{row:V,col:A}=u(E.startRow,E.startColumn);d.add(b),s.setValue(V,A,b)})});const S=Array.from(d).map(D=>({id:D,ranges:o.queryObjectMatrix(s,C=>C===D)}));r.addRangeRules(S);const{redoMutations:v,undoMutations:f}=R.getDataValidationDiffMutations(a.unitId,a.subUnitId,r.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),c.values()),this._injector,"patched",!1);return{redos:v,undos:f}}else{const r=this._sheetDataValidationModel.getRuleObjectMatrix(n,i).clone(),s=new o.ObjectMatrix,d=new Set,{ranges:[l,p],mapFunc:u}=N.virtualizeDiscreteRanges([a.copyRange,t]);N.getRepeatRange(l,p,!0).forEach(({startRange:f})=>{var D;(D=this._copyInfo)==null||D.matrix.forValue((C,w,_)=>{const M=o.Rectangle.getPositionRange({startRow:C,endRow:C,startColumn:w,endColumn:w},f),{row:E,col:b}=u(M.startRow,M.startColumn);s.setValue(E,b,_),d.add(_)})});const c=Array.from(d).map(f=>({id:f,ranges:o.queryObjectMatrix(s,D=>D===f)}));r.addRangeRules(c);const{redoMutations:S,undoMutations:v}=R.getDataValidationDiffMutations(n,i,r.diff(this._sheetDataValidationModel.getRules(n,i)),this._injector,"patched",!1);return{redos:S,undos:v}}}};Ve=Kn([st(0,N.ISheetClipboardService),st(1,o.Inject(R.SheetDataValidationModel)),st(2,o.Inject(o.Injector))],Ve);var Gn=Object.defineProperty,qn=Object.getOwnPropertyDescriptor,Zn=(e,t,a,n)=>{for(var i=n>1?void 0:n?qn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Gn(t,a,i),i},lt=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends o.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionInterceptorBaseController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===R.AddSheetDataValidationCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission,X.WorksheetSetCellStylePermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr"))),e.id===R.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission,X.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr")))}))}};Ee=Zn([lt(0,o.Inject(o.LocaleService)),lt(1,o.ICommandService),lt(2,o.Inject(N.SheetPermissionInterceptorBaseController))],Ee);const Ft="data-validation-single",xt="sheet.menu.data-validation";function Jn(e){return{id:xt,type:z.MenuItemType.SUBITEMS,icon:Ft,tooltip:"dataValidation.title",hidden$:z.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[X.WorkbookEditablePermission],worksheetTypes:[X.WorksheetSetCellStylePermission,X.WorksheetEditPermission],rangeTypes:[X.RangeProtectionPermissionEditPoint]})}}function Qn(e){return{id:_e.id,title:"dataValidation.panel.title",type:z.MenuItemType.BUTTON}}function ea(e){return{id:Ue.id,title:"dataValidation.panel.add",type:z.MenuItemType.BUTTON}}const ta={[z.RibbonStartGroup.FORMULAS_INSERT]:{[xt]:{order:9,menuItemFactory:Jn,[_e.id]:{order:0,menuItemFactory:Qn},[Ue.id]:{order:1,menuItemFactory:ea}}}};var na=Object.defineProperty,aa=Object.getOwnPropertyDescriptor,Nt=(e,t,a,n)=>{for(var i=n>1?void 0:n?aa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&na(t,a,i),i},ee=(e,t)=>(a,n)=>t(a,n,e);const Ut={tr:{size:6,color:"#fe4b4b"}};let Re=class extends o.RxDisposable{constructor(e,t,a,n,i,r,s,d,l,p,u){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=i,this._dropdownManagerService=r,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=p,this._editorBridgeService=u,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(ta)}_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:i,row:r,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,i,r,s);if(!l)return;const p=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(p!=null&&p.dropdown))return;const u=d.getActiveSheet();if(!u)return;const m=this._dropdownManagerService.activeDropdown,c=m==null?void 0:m.location;if(c&&c.unitId===n&&c.subUnitId===i&&c.row===r&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:i,row:r,col:s,workbook:d,worksheet:u},componentKey:p.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var C,w,_,M,E,b;const{row:n,col:i,unitId:r,subUnitId:s,workbook:d,worksheet:l}=t,p=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!p)return a(e);const u=this._sheetDataValidationModel.getRuleById(r,s,p);if(!u)return a(e);const m=(w=(C=this._dataValidationCacheService.getValue(r,s,n,i))==null?void 0:C.status)!=null?w:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(u.type),S=t.rawData;let v;const f={get value(){var I;return v!==void 0||(v=(I=R.getCellValueOrigin(S))!=null?I:null),v}},D={get value(){var I;return`${(I=f.value)!=null?I:""}`}};return a({...e,dataValidation:{ruleId:p,validStatus:m,rule:u,validator:c},markers:{...e==null?void 0:e.markers,...m===o.DataValidationStatus.INVALID?Ut:null},customRender:[...(_=e==null?void 0:e.customRender)!=null?_:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((M=e==null?void 0:e.fontRenderExtension)==null?void 0:M.isSkip)||((E=c==null?void 0:c.skipDefaultFontRender)==null?void 0:E.call(c,u,f.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(u,D.value,{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,i)},interceptorAutoHeight:()=>{var Y,F,P,j,x,U;const I=(F=(Y=this._renderManagerService.getRenderById(r))==null?void 0:Y.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:F.skeleton;if(!I)return;const V=I.worksheet.getMergedCell(n,i),A={data:{...e,dataValidation:{ruleId:p,validStatus:m,rule:u,validator:c}},style:I.getsStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((P=V==null?void 0:V.startRow)!=null?P:n,(j=V==null?void 0:V.startColumn)!=null?j:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(U=(x=c==null?void 0:c.canvasRender)==null?void 0:x.calcCellAutoHeight)==null?void 0:U.call(x,A)},interceptorAutoWidth:()=>{var Y,F,P,j,x,U;const I=(F=(Y=this._renderManagerService.getRenderById(r))==null?void 0:Y.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:F.skeleton;if(!I)return;const V=I.worksheet.getMergedCell(n,i),A={data:{...e,dataValidation:{ruleId:p,validStatus:m,rule:u,validator:c}},style:I.getsStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((P=V==null?void 0:V.startRow)!=null?P:n,(j=V==null?void 0:V.startColumn)!=null?j:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(U=(x=c==null?void 0:c.canvasRender)==null?void 0:x.calcCellAutoWidth)==null?void 0:U.call(x,A)},coverable:((b=e==null?void 0:e.coverable)!=null?b:!0)&&!(u.type===o.DataValidationType.LIST||u.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(se.filter(e=>e.source==="command"),se.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(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)}})}};Re=Nt([ee(0,o.ICommandService),ee(1,z.IMenuManagerService),ee(2,B.IRenderManagerService),ee(3,o.IUniverInstanceService),ee(4,o.Inject(N.AutoHeightController)),ee(5,o.Inject(fe)),ee(6,o.Inject(R.SheetDataValidationModel)),ee(7,o.Inject(Q.DataValidatorRegistryService)),ee(8,o.Inject(X.SheetInterceptorService)),ee(9,o.Inject(R.DataValidationCacheService)),ee(10,o.Optional(N.IEditorBridgeService))],Re);let Bt=class extends o.RxDisposable{constructor(e,t,a,n,i,r,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=i,this._sheetDataValidationModel=r,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var D,C,w,_,M,E;const{row:n,col:i,unitId:r,subUnitId:s,workbook:d,worksheet:l}=t,p=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!p)return a(e);const u=this._sheetDataValidationModel.getRuleById(r,s,p);if(!u)return a(e);const m=(C=(D=this._dataValidationCacheService.getValue(r,s,n,i))==null?void 0:D.status)!=null?C:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(u.type),S=l.getCellRaw(n,i),v=R.getCellValueOrigin(S),f=`${v!=null?v:""}`;return a({...e,dataValidation:{ruleId:p,validStatus:m,rule:u,validator:c},markers:{...e==null?void 0:e.markers,...m===o.DataValidationStatus.INVALID?Ut:null},customRender:[...(w=e==null?void 0:e.customRender)!=null?w:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((_=e==null?void 0:e.fontRenderExtension)==null?void 0:_.isSkip)||((M=c==null?void 0:c.skipDefaultFontRender)==null?void 0:M.call(c,u,v,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(u,f,{get style(){const b=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?b.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,i)},interceptorAutoHeight:()=>{var A,Y,F,P,j,x;const b=(Y=(A=this._renderManagerService.getRenderById(r))==null?void 0:A.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:Y.skeleton;if(!b)return;const I=b.worksheet.getMergedCell(n,i),V={data:{...e,dataValidation:{ruleId:p,validStatus:m,rule:u,validator:c}},style:b.getsStyles().getStyleByCell(e),primaryWithCoord:b.getCellWithCoordByIndex((F=I==null?void 0:I.startRow)!=null?F:n,(P=I==null?void 0:I.startColumn)!=null?P:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(x=(j=c==null?void 0:c.canvasRender)==null?void 0:j.calcCellAutoHeight)==null?void 0:x.call(j,V)},coverable:((E=e==null?void 0:e.coverable)!=null?E:!0)&&!(u.type===o.DataValidationType.LIST||u.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(se.filter(e=>e.source==="command"),se.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(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)}})}};Bt=Nt([ee(0,o.ICommandService),ee(1,B.IRenderManagerService),ee(2,o.Inject(N.AutoHeightController)),ee(3,o.Inject(Q.DataValidatorRegistryService)),ee(4,o.Inject(X.SheetInterceptorService)),ee(5,o.Inject(R.SheetDataValidationModel)),ee(6,o.Inject(R.DataValidationCacheService))],Bt);var ia=Object.defineProperty,oa=Object.getOwnPropertyDescriptor,ra=(e,t,a,n)=>{for(var i=n>1?void 0:n?oa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&ia(t,a,i),i},kt=(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(i=>{a.add(i.subUnitId)}),a.forEach(i=>{var r;(r=this._sheetSkeletonManagerService.getWorksheetSkeleton(i))==null||r.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};ke=ra([kt(1,o.Inject(R.SheetDataValidationModel)),kt(2,o.Inject(N.SheetSkeletonManagerService))],ke);const ie={dataValidationFormula:"univer-data-validation-formula",dataValidationFormulaAnd:"univer-data-validation-formula-and",dataValidationFormulaListItem:"univer-data-validation-formula-list-item",dataValidationFormulaListItemIcon:"univer-data-validation-formula-list-item-icon",dataValidationFormulaListItemDrag:"univer-data-validation-formula-list-item-drag",dataValidationFormulaListAdd:"univer-data-validation-formula-list-add",dataValidationFormulaColorSelect:"univer-data-validation-formula-color-select",dataValidationFormulaColorSelectPanel:"univer-data-validation-formula-color-select-panel",dataValidationFormulaColorItem:"univer-data-validation-formula-color-item"},sa=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:i,validResult:r}=e,s=o.useDependency(o.LocaleService),d=i?r==null?void 0:r.formula1:"",l=i?r==null?void 0:r.formula2:"";return t?h.jsxs(h.Fragment,{children:[h.jsx(T.FormLayout,{error:d,children:h.jsx(T.Input,{className:ie.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:p=>{n==null||n({...a,formula1:p})}})}),h.jsx("div",{className:ie.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),h.jsx(T.FormLayout,{error:l,children:h.jsx(T.Input,{className:ie.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:p=>{n==null||n({...a,formula2:p})}})})]}):h.jsx(T.FormLayout,{error:d,children:h.jsx(T.Input,{className:ie.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:p=>{n==null||n({formula1:p})}})})};function la(e){const{value:t,onChange:a,showError:n,validResult:i}=e,r=o.useDependency(o.LocaleService),s=n?i==null?void 0:i.formula1:"",d=n?i==null?void 0:i.formula2:"",[l,p]=g.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return h.jsxs(h.Fragment,{children:[h.jsx(T.FormLayout,{children:h.jsx(T.Checkbox,{checked:l,onChange:u=>{u?p(!0):(p(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:r.t("dataValidation.checkbox.tips")})}),l?h.jsx(T.FormLayout,{label:r.t("dataValidation.checkbox.checked"),error:s,children:h.jsx(T.Input,{className:ie.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:u=>{a==null||a({...t,formula1:u||void 0})}})}):null,l?h.jsx(T.FormLayout,{label:r.t("dataValidation.checkbox.unchecked"),error:d,children:h.jsx(T.Input,{className:ie.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:u=>{a==null||a({...t,formula2:u||void 0})}})}):null]})}function da(e){var m;const{unitId:t,subUnitId:a,value:n,onChange:i,showError:r,validResult:s}=e,d=r?s==null?void 0:s.formula1:void 0,l=g.useRef({}),[p,u]=g.useState(!1);return z.useSidebarClick(c=>{var v;const S=(v=l.current)==null?void 0:v.handleOutClick;S&&S(c,()=>u(!1))}),h.jsx(Qe.FormulaEditor,{initValue:(m=n==null?void 0:n.formula1)!=null?m:"",unitId:t,subUnitId:a,isFocus:p,onChange:c=>{const S=(c!=null?c:"").trim();S!==(n==null?void 0:n.formula1)&&(i==null||i({...n,formula1:S}))},errorText:d,onFocus:()=>u(!0),actions:l.current,isSupportAcrossSheet:!0})}function Wt(e){var t,a,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(a=Wt(e[t]))&&(n&&(n+=" "),n+=a)}else for(a in e)e[a]&&(n&&(n+=" "),n+=a);return n}function ca(){for(var e,t,a=0,n="",i=arguments.length;a<i;a++)(e=arguments[a])&&(t=Wt(e))&&(n&&(n+=" "),n+=t);return n}const ua=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],pa=e=>{const{value:t,onChange:a,disabled:n}=e,[i,r]=g.useState(!1);return h.jsx(T.Select,{disabled:n,open:i,onDropdownVisibleChange:r,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ie.dataValidationFormulaColorSelect,value:t,onChange:a,labelRender:s=>h.jsx("div",{className:ie.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>h.jsx("div",{className:ie.dataValidationFormulaColorSelectPanel,children:ua.map(s=>h.jsx("div",{onClick:()=>{a(s),r(!1)},className:ie.dataValidationFormulaColorItem,style:{background:s}},s))})})},$t=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:i,onItemDelete:r}=a;return h.jsxs("div",{className:ie.dataValidationFormulaListItem,style:n,children:[t.isRef?null:h.jsx("div",{className:ca(ie.dataValidationFormulaListItemDrag,"draggableHandle"),children:h.jsx(Ot,{})}),h.jsx(pa,{value:t.color,onChange:s=>{i(t.id,t.label,s)}}),h.jsx(T.Input,{disabled:t.isRef,value:t.label,onChange:s=>{i(t.id,s,t.color)}}),t.isRef?null:h.jsx("div",{className:ie.dataValidationFormulaListItemIcon,children:h.jsx(et,{onClick:()=>r(t.id)})})]})};function ha(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:i,validResult:r,showError:s,ruleId:d}=e,{formula1:l="",formula2:p=""}=t||{},u=g.useRef(null),[m,c]=g.useState(()=>o.isFormulaString(l)?"1":"0"),[S,v]=g.useState(m==="1"?l:"="),[f,D]=g.useState(m==="1"?l:"="),C=o.useDependency(o.LocaleService),w=o.useDependency(Q.DataValidatorRegistryService),_=o.useDependency(Q.DataValidationModel),M=o.useDependency(R.DataValidationFormulaController),[E,b]=g.useState(()=>p.split(",")),I=w.getValidatorItem(o.DataValidationType.LIST),[V,A]=g.useState([]),[Y,F]=g.useState(""),P=s?r==null?void 0:r.formula1:"",j=g.useMemo(()=>_.ruleChange$.pipe(se.debounceTime(16)),[]),x=z.useObservable(j),U=z.useEvent(a);g.useEffect(()=>{(async()=>{await new Promise($=>{setTimeout(()=>$(!0),100)});const y=_.getRuleById(n,i,d),W=y==null?void 0:y.formula1;if(o.isFormulaString(W)&&I&&y){const $=await I.getListAsync(y,n,i);A($)}})()},[_,x,I,d,i,n]),g.useEffect(()=>{o.isFormulaString(l)&&l!==f&&(v(l),D(f))},[f,l]);const[k,K]=g.useState(()=>{const y=m!=="1"?R.deserializeListOptions(l):[],W=p.split(",");return y.map(($,q)=>({label:$,color:W[q]||Ie,isRef:!1,id:o.Tools.generateRandomId(4)}))}),G=(y,W,$)=>{const q=k.find(ge=>ge.id===y);q&&(q.label=W,q.color=$,K([...k]))},te=y=>{const W=k.findIndex($=>$.id===y);W!==-1&&(k.splice(W,1),K([...k]))},Z=p.split(","),J=g.useMemo(()=>V.map((y,W)=>({label:y,color:Z[W]||Ie,id:`${W}`,isRef:!0})),[Z,V]),ne=(y,W,$)=>{const q=[...E];q[+y]=$,b(q),U({formula1:l,formula2:q.join(",")})},re=()=>{K([...k,{label:"",color:Ie,isRef:!1,id:o.Tools.generateRandomId(4)}])};g.useEffect(()=>{if(m==="1")return;const y=new Set,W=[];k.map($=>({labelList:$.label.split(","),item:$})).forEach(({item:$,labelList:q})=>{q.forEach(ge=>{y.has(ge)||(y.add(ge),W.push({label:ge,color:$.color}))})}),U({formula1:R.serializeListOptions(W.map($=>$.label)),formula2:W.map($=>$.color===Ie?"":$.color).join(",")})},[k,U,m,f,E]);const de=g.useMemo(()=>async y=>{if(!o.isFormulaString(y)){U==null||U({formula1:"",formula2:p});return}M.getFormulaRefCheck(y)?(U==null||U({formula1:o.isFormulaString(y)?y:"",formula2:p}),F("")):(U==null||U({formula1:"",formula2:p}),v("="),F(C.t("dataValidation.validFail.formulaError")))},[p,U]),ae=g.useRef({}),[oe,O]=g.useState(!1);return z.useSidebarClick(y=>{var $;const W=($=ae.current)==null?void 0:$.handleOutClick;W&&W(y,()=>O(!1))}),h.jsxs(h.Fragment,{children:[h.jsx(T.FormLayout,{label:C.t("dataValidation.list.options"),children:h.jsxs(T.RadioGroup,{value:m,onChange:y=>{c(y),v(f),y==="1"&&U({formula1:f==="="?"":f,formula2:E.join(",")})},children:[h.jsx(T.Radio,{value:"0",children:C.t("dataValidation.list.customOptions")}),h.jsx(T.Radio,{value:"1",children:C.t("dataValidation.list.refOptions")})]})}),m==="1"?h.jsxs(h.Fragment,{children:[h.jsx(Qe.FormulaEditor,{initValue:S,unitId:n,subUnitId:i,isFocus:oe,onChange:(y="")=>{const W=(y!=null?y:"").trim();D(W),de(W)},errorText:P||Y||void 0,onFocus:()=>O(!0),actions:ae.current,isSupportAcrossSheet:!0}),h.jsx("div",{ref:u,style:{marginTop:"12px"},children:J.map(y=>h.jsx($t,{item:y,commonProps:{onItemChange:ne},style:{marginBottom:12}},y.id))})]}):h.jsx(T.FormLayout,{error:P,children:h.jsxs("div",{ref:u,style:{marginTop:"-12px"},children:[h.jsx(T.DraggableList,{list:k,onListChange:K,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:y=>h.jsx($t,{item:y,commonProps:{onItemChange:G,onItemDelete:te}},y.id),idKey:"id"}),h.jsxs("a",{className:ie.dataValidationFormulaListAdd,onClick:re,children:[h.jsx(Rt,{}),C.t("dataValidation.list.add")]})]})})]})}const Ht="data-validation.custom-formula-input",We="data-validation.formula-input",dt="data-validation.list-formula-input",Yt="data-validation.checkbox-formula-input",ma=[[Ht,da],[We,sa],[dt,ha],[Yt,la]],va="LIST_RENDER_MODE_OPTION_INPUT";function $e(e){var i;const{value:t,onChange:a}=e,n=o.useDependency(o.LocaleService);return h.jsx(T.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:h.jsxs(T.RadioGroup,{value:`${(i=t.renderMode)!=null?i:o.DataValidationRenderMode.CUSTOM}`,onChange:r=>a({...t,renderMode:+r}),children:[h.jsx(T.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),h.jsx(T.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),h.jsx(T.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}$e.componentKey=va;const fa="DATE_SHOW_TIME_OPTION";function He(e){var i;const{value:t,onChange:a}=e,n=o.useDependency(o.LocaleService);return h.jsx(T.FormLayout,{children:h.jsx(T.Checkbox,{checked:(i=t.bizInfo)==null?void 0:i.showTime,onChange:r=>{a({...t,bizInfo:{...t.bizInfo,showTime:r}})},children:n.t("dataValidation.showTime.label")})})}He.componentKey=fa;var ga=Object.defineProperty,Sa=Object.getOwnPropertyDescriptor,_a=(e,t,a,n)=>{for(var i=n>1?void 0:n?Sa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&ga(t,a,i),i},Ye=(e,t)=>(a,n)=>t(a,n,e);const Xe=6;let ct=class{constructor(e,t,a,n){this._commandService=e,this._formulaService=t,this._themeService=a,this._renderManagerService=n}_calc(e,t){var p,u,m;const{vt:a,ht:n}=t||{},i=e.endX-e.startX-Xe*2,r=e.endY-e.startY,s=((p=t==null?void 0:t.fs)!=null?p:10)*1.6;let d=0,l=0;switch(a){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(r-s);break;default:l=0+(r-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:d=Xe;break;case o.HorizontalAlign.RIGHT:d=Xe+(i-s);break;default:d=Xe+(i-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((u=t==null?void 0:t.fs)!=null?u:10)*1.6,height:((m=t==null?void 0:t.fs)!=null?m: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 p,u,m,c,S,v,f,D,C;const{formula1:n=R.CHECKBOX_FORMULA_1,formula2:i=R.CHECKBOX_FORMULA_2}=e,r=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=R.getFormulaResult((m=(u=(p=r==null?void 0:r[0])==null?void 0:p.result)==null?void 0:u[0])==null?void 0:m[0]),d=R.getFormulaResult((v=(S=(c=r==null?void 0:r[1])==null?void 0:c.result)==null?void 0:S[0])==null?void 0:v[0]),l=R.isLegalFormulaResult(String(s))&&R.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(n)?R.getFormulaResult((C=(D=(f=r==null?void 0:r[0])==null?void 0:f.result)==null?void 0:D[0])==null?void 0:C[0]):n,formula2:o.isFormulaString(i)?d:i,isFormulaValid:l}}drawWith(e,t){var j,x,U,k,K,G;const{style:a,data:n,primaryWithCoord:i,unitId:r,subUnitId:s,worksheet:d,row:l,col:p}=t,u=i.isMergedMainCell?i.mergeInfo:i,m=R.getCellValueOrigin(d.getCellRaw(l,p)),c=(j=n.dataValidation)==null?void 0:j.rule,S=(x=n.dataValidation)==null?void 0:x.validator;if(!c||!S)return;const v=this._themeService.getCurrentTheme();if(!((U=S.skipDefaultFontRender)!=null&&U.call(S,c,m,{unitId:r,subUnitId:s,row:l,column:p})))return;const f=S.parseFormulaSync(c,r,s),{formula1:D}=f,C=this._calc(u,a),{a:w,d:_}=e.getTransform(),M=B.fixLineWidthByScale(C.left,w),E=B.fixLineWidthByScale(C.top,_),b=B.Transform.create().composeMatrix({left:M,top:E,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),I=u.endX-u.startX,V=u.endY-u.startY;e.save(),e.beginPath(),e.rect(u.startX,u.startY,I,V),e.clip();const A=b.getMatrix();e.transform(A[0],A[1],A[2],A[3],A[4],A[5]);const Y=((k=a==null?void 0:a.fs)!=null?k:10)*1.6,F=String(m)===String(D),P=v.hyacinth500;B.Checkbox.drawWith(e,{checked:F,width:Y,height:Y,fill:(G=(K=a==null?void 0:a.cl)==null?void 0:K.rgb)!=null?G:P}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),i=n.top,r=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:p}=e;return l<=d&&l>=s&&p<=r&&p>=i}async onPointerDown(e,t){var f,D,C;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:i,data:r,worksheet:s,row:d,col:l}=e,p=R.getCellValueOrigin(s.getCellRaw(d,l)),u=(f=r.dataValidation)==null?void 0:f.rule,m=(D=r.dataValidation)==null?void 0:D.validator;if(!u||!m||!((C=m.skipDefaultFontRender)!=null&&C.call(m,u,p,{unitId:n,subUnitId:i,row:d,column:l})))return;const{formula1:c,formula2:S}=await this._parseFormula(u,n,i),v={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(p)===R.transformCheckboxValue(String(c))?S:c,p:null}};this._commandService.executeCommand(X.SetRangeValuesCommand.id,v)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};ct=_a([Ye(0,o.ICommandService),Ye(1,o.Inject(R.DataValidationFormulaService)),Ye(2,o.Inject(o.ThemeService)),Ye(3,o.Inject(B.IRenderManagerService))],ct);var Ia=Object.defineProperty,Ca=Object.getOwnPropertyDescriptor,Da=(e,t,a,n)=>{for(var i=n>1?void 0:n?Ca(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Ia(t,a,i),i},wa=(e,t)=>(a,n)=>t(a,n,e);let pe=class{constructor(e){L(this,"canvasRender",null);L(this,"dropdown");L(this,"optionsInput");L(this,"formulaInput",dt);this.injector=e}};pe=Da([wa(0,o.Inject(o.Injector))],pe);class ya extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CHECKBOX);L(this,"canvasRender",this.injector.createInstance(ct));L(this,"formulaInput",Yt)}}class Va extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CUSTOM);L(this,"formulaInput",Ht)}}const Ea="data-validation.formula-input";class Ra extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DATE);L(this,"formulaInput",Ea);L(this,"optionsInput",He.componentKey);L(this,"dropdown",ot)}}class Ma extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DECIMAL);L(this,"formulaInput",We)}}const Xt=4,ba=0,ut=4,zt=4,pt=6,ze=6,Ce=14;function Oa(e,t){const a=B.FontCache.getTextSize(e,t),n=a.width+Xt*2,{ba:i,bd:r}=a,s=i+r;return{width:n,height:s+ba*2,ba:i}}function ht(e,t,a,n){const i=Ce+pt*2,r=a-i,s=n-ze*2,d=e.map(c=>({layout:Oa(c,t),text:c}));let l;const p=[];d.forEach(c=>{const{layout:S}=c,{width:v,height:f}=S;!l||l.width+v+ut>r?(l={width:v,height:f,items:[{...c,left:0}]},p.push(l)):(l.items.push({...c,left:l.width+ut}),l.width=l.width+v+ut)});let u=0,m=0;return p.forEach((c,S)=>{m=Math.max(m,c.width),S===p.length-1?u+=c.height:u+=c.height+zt}),{lines:p,totalHeight:u,contentWidth:r,contentHeight:s,cellAutoHeight:u+ze*2,calcAutoWidth:m+i}}const Ta=8;class La extends B.Shape{static drawWith(t,a){const{fontString:n,info:i,fill:r,color:s}=a,{layout:d,text:l}=i;t.save(),B.Rect.drawWith(t,{width:d.width,height:d.height,radius:Ta,fill:r||Ie}),t.translateWithPrecision(Xt,d.ba),t.font=n,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var Pa=Object.defineProperty,ja=Object.getOwnPropertyDescriptor,Aa=(e,t,a,n)=>{for(var i=n>1?void 0:n?ja(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Pa(t,a,i),i},Kt=(e,t)=>(a,n)=>t(a,n,e);const Fa=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 mt=class{constructor(e,t){L(this,"zIndex");L(this,"_dropdownInfoMap",new Map);this._commandService=e,this._renderManagerService=t}_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,i){const r=a-Ce+4;let s=4;switch(i){case o.VerticalAlign.MIDDLE:s=(n-Ce)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-Ce+4;break}e.save(),e.translateWithPrecision(t.startX+r,t.startY+s),e.fillStyle="#565656",e.fill(Fa),e.restore()}drawWith(e,t,a,n){var Z,J;const{primaryWithCoord:i,row:r,col:s,style:d,data:l,subUnitId:p}=t,u=i.isMergedMainCell?i.mergeInfo:i,m=l.fontRenderExtension,{leftOffset:c=0,rightOffset:S=0,topOffset:v=0,downOffset:f=0}=m||{},D=l.dataValidation,C=this._ensureMap(p),w=this._generateKey(r,s);if(!D)return;const _={startX:u.startX+c,endX:u.endX-S,startY:u.startY+v,endY:u.endY-f},M=_.endX-_.startX,E=_.endY-_.startY,{cl:b}=d||{},I=(Z=typeof b=="object"?b==null?void 0:b.rgb:b)!=null?Z:"#000",V=B.getFontStyleString(d!=null?d:void 0),{rule:A,validator:Y}=D,F=Y,{vt:P,ht:j}=d||{},x=P!=null?P:o.VerticalAlign.MIDDLE,U=(J=R.getCellValueOrigin(l))!=null?J:"",k=F.parseCellValue(U),K=F.getListWithColorMap(A),G=ht(k,V,M,E);this._drawDownIcon(e,_,M,E,x),e.save(),e.translateWithPrecision(_.startX,_.startY),e.beginPath(),e.rect(0,0,M-Ce,E),e.clip(),e.translateWithPrecision(pt,ze);let te=0;switch(x){case o.VerticalAlign.MIDDLE:te=(G.contentHeight-G.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:te=G.contentHeight-G.totalHeight;break}e.translateWithPrecision(0,te),G.lines.forEach((ne,re)=>{e.save();const{width:de,height:ae,items:oe}=ne;let O=0;switch(j){case o.HorizontalAlign.RIGHT:O=G.contentWidth-de;break;case o.HorizontalAlign.CENTER:O=(G.contentWidth-de)/2;break}e.translate(O,re*(ae+zt)),oe.forEach(y=>{e.save(),e.translateWithPrecision(y.left,0),La.drawWith(e,{...V,info:y,color:I,fill:K[y.text]}),e.restore()}),e.restore()}),e.restore(),C.set(w,{left:_.startX,top:_.startY,width:G.contentWidth+pt+Ce,height:G.contentHeight+ze*2})}calcCellAutoHeight(e){var M;const{primaryWithCoord:t,style:a,data:n}=e,i=n.fontRenderExtension,{leftOffset:r=0,rightOffset:s=0,topOffset:d=0,downOffset:l=0}=i||{},p=t.isMergedMainCell?t.mergeInfo:t,u={startX:p.startX+r,endX:p.endX-s,startY:p.startY+d,endY:p.endY-l},m=n.dataValidation;if(!m)return;const c=u.endX-u.startX,S=u.endY-u.startY,v=(M=R.getCellValueOrigin(n))!=null?M:"",{validator:f}=m,C=f.parseCellValue(v),w=B.getFontStyleString(a!=null?a:void 0);return ht(C,w,c,S).cellAutoHeight}calcCellAutoWidth(e){var M;const{primaryWithCoord:t,style:a,data:n}=e,i=n.fontRenderExtension,{leftOffset:r=0,rightOffset:s=0,topOffset:d=0,downOffset:l=0}=i||{},p=t.isMergedMainCell?t.mergeInfo:t,u={startX:p.startX+r,endX:p.endX-s,startY:p.startY+d,endY:p.endY-l},m=n.dataValidation;if(!m)return;const c=u.endX-u.startX,S=u.endY-u.startY,v=(M=R.getCellValueOrigin(n))!=null?M:"",{validator:f}=m,C=f.parseCellValue(v),w=B.getFontStyleString(a!=null?a:void 0);return ht(C,w,c,S).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:i}=n,{x:r}=e;return r>=i-Ce&&r<=i}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=e,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Ae.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};mt=Aa([Kt(0,o.ICommandService),Kt(1,o.Inject(B.IRenderManagerService))],mt);class xa extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST_MULTIPLE);L(this,"canvasRender",this.injector.createInstance(mt));L(this,"dropdown",Ne)}}var Na=Object.defineProperty,Ua=Object.getOwnPropertyDescriptor,Ba=(e,t,a,n)=>{for(var i=n>1?void 0:n?Ua(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Na(t,a,i),i},vt=(e,t)=>(a,n)=>t(a,n,e);const De=4,Ke=4,ce=14,he=6,Me=4,ft=8,ka="#565656",Gt=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 Wa(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:o.BooleanNumber.FALSE,bl:o.BooleanNumber.FALSE,ul:{s:o.BooleanNumber.FALSE},st:{s:o.BooleanNumber.FALSE},ol:{s:o.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function qt(e,t,a){const n=Wa(e,a),i=new o.DocumentDataModel(n),r=new B.DocumentViewModel(i);return{documentSkeleton:B.DocumentSkeleton.create(r,t),docModel:i,docViewModel:r}}function Ge(e,t,a){const{documentSkeleton:n,docModel:i,docViewModel:r}=qt(e,t,a);return{documents:new B.Documents(`DOCUMENTS_${o.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:i,docViewModel:r}}function Zt(e,t,a,n,i,r,s=!0){let d=0;const l=s?Me:0;switch(i){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(Me,d);let p=0;switch(r){case o.HorizontalAlign.CENTER:p=(e-a)/2;break;case o.HorizontalAlign.RIGHT:p=e-a;break}return p=Math.max(he,p),{paddingLeft:p,paddingTop:d}}let gt=class{constructor(e,t,a){L(this,"_dropdownInfoMap",new Map);L(this,"zIndex");this._localeService=e,this._commandService=t,this._renderManagerService=a}_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,i,r,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,p=a-ce;let u;switch(r){case o.VerticalAlign.MIDDLE:u=(n-Ke)/2;break;case o.VerticalAlign.BOTTOM:u=n-l-i-Me+(i/2-Ke/2);break;default:u=d+Me+(i/2-Ke/2);break}e.save(),e.translateWithPrecision(t.startX+p,t.startY+u),e.fillStyle="#565656",e.fill(Gt),e.restore()}drawWith(e,t,a){var x,U;const{primaryWithCoord:n,row:i,col:r,style:s,data:d,subUnitId:l}=t,p=n.isMergedMainCell?n.mergeInfo:n,u=(x=d.dataValidation)==null?void 0:x.rule,m=(U=d.dataValidation)==null?void 0:U.validator,c=d.fontRenderExtension,{leftOffset:S=0,rightOffset:v=0,topOffset:f=0,downOffset:D=0}=c||{};if(!u||!m||!m||m.id.indexOf(o.DataValidationType.LIST)!==0||!m.skipDefaultFontRender(u))return;const C={startX:p.startX+S,endX:p.endX-v,startY:p.startY+f,endY:p.endY-D},w=C.endX-C.startX,_=C.endY-C.startY,M=this._ensureMap(l),E=this._generateKey(i,r),b=m.getListWithColor(u),I=R.getCellValueOrigin(d),V=`${I!=null?I:""}`,A=b.find(k=>k.label===V);let{tb:Y,vt:F,ht:P,pd:j}=s||{};if(Y=Y!=null?Y:o.WrapStrategy.WRAP,F=F!=null?F:o.VerticalAlign.BOTTOM,P=P!=null?P:o.DEFAULT_STYLES.ht,j=j!=null?j:o.DEFAULT_STYLES.pd,u.renderMode===o.DataValidationRenderMode.ARROW){const{l:k=o.DEFAULT_STYLES.pd.l,t:K=o.DEFAULT_STYLES.pd.t,r:G=o.DEFAULT_STYLES.pd.r,b:te=o.DEFAULT_STYLES.pd.b}=j,Z=w-k-G-ce-4,{documentSkeleton:J,documents:ne,docModel:re}=Ge(V,this._localeService,s);Y===o.WrapStrategy.WRAP&&re.updateDocumentDataPageSize(Math.max(Z,1)),J.calculate(),J.getActualSize();const de=B.getDocsSkeletonPageSize(J),{height:ae,width:oe}=de,{paddingTop:O,paddingLeft:y}=Zt(Z,_-K-te,oe,ae,F,P,!0);this._drawDownIcon(e,C,w,_,ae,F,j),e.save(),e.translateWithPrecision(C.startX+k,C.startY+K),e.beginPath(),e.rect(0,0,w-k-G,_-K-te),e.clip(),e.translateWithPrecision(0,O),e.save(),e.translateWithPrecision(De,0),e.beginPath(),e.rect(0,0,Z,ae),e.clip(),ne.render(e),e.translateWithPrecision(y,0),e.restore(),e.restore(),M.set(E,{left:C.endX+k+a.rowHeaderWidth-ce,top:C.startY+K+a.columnHeaderHeight,width:ce,height:_-K-te})}else{e.save(),e.translateWithPrecision(C.startX,C.startY),e.beginPath(),e.rect(0,0,w,_),e.clip();const k=w-he*2-De-ce-4,{documentSkeleton:K,documents:G,docModel:te}=Ge(V,this._localeService,s);Y===o.WrapStrategy.WRAP&&te.updateDocumentDataPageSize(Math.max(k,1)),K.calculate();const Z=B.getDocsSkeletonPageSize(K),{height:J,width:ne}=Z,{paddingTop:re,paddingLeft:de}=Zt(k,_,ne,J,F,P);e.translateWithPrecision(he,re);const ae=Math.max(w-he*2,1),oe=J;B.Rect.drawWith(e,{width:ae,height:oe,fill:(A==null?void 0:A.color)||Ie,radius:ft}),e.save(),e.translateWithPrecision(De,0),e.beginPath(),e.rect(0,0,k,J),e.clip(),e.translateWithPrecision(de,0),G.render(e),e.restore(),e.translateWithPrecision(k+De+4,(J-Ke)/2),e.fillStyle=ka,e.fill(Gt),e.restore(),M.set(E,{left:C.startX+he+a.rowHeaderWidth,top:C.startY+re+a.columnHeaderHeight,width:ae,height:oe})}}calcCellAutoHeight(e){var _;const{primaryWithCoord:t,style:a,data:n}=e,i=t.isMergedMainCell?t.mergeInfo:t,r=n.fontRenderExtension,{leftOffset:s=0,rightOffset:d=0,topOffset:l=0,downOffset:p=0}=r||{},u=(_=n.dataValidation)==null?void 0:_.rule;if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const m={startX:i.startX+s,endX:i.endX-d,startY:i.startY+l,endY:i.endY-p},c=m.endX-m.startX,S=R.getCellValueOrigin(n),v=`${S!=null?S:""}`;let{tb:f,pd:D}=a||{};const{t:C=o.DEFAULT_STYLES.pd.t,b:w=o.DEFAULT_STYLES.pd.b}=D!=null?D:{};if(f=f!=null?f:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const M=c-ce,{documentSkeleton:E,docModel:b}=Ge(v,this._localeService,a);f===o.WrapStrategy.WRAP&&b.updateDocumentDataPageSize(Math.max(M,1)),E.calculate(),E.getActualSize();const I=B.getDocsSkeletonPageSize(E),{height:V}=I;return V+C+w+Me*2}else{const M=c-he*2-De-ce,{documentSkeleton:E,docModel:b}=qt(v,this._localeService,a);f===o.WrapStrategy.WRAP&&b.updateDocumentDataPageSize(Math.max(M,1)),E.calculate();const I=B.getDocsSkeletonPageSize(E),{height:V}=I;return V+Me*2}}calcCellAutoWidth(e){var V;const{primaryWithCoord:t,style:a,data:n}=e,i=t.isMergedMainCell?t.mergeInfo:t,r=n.fontRenderExtension,{leftOffset:s=0,rightOffset:d=0,topOffset:l=0,downOffset:p=0}=r||{},u=(V=n.dataValidation)==null?void 0:V.rule;if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const m={startX:i.startX+s,endX:i.endX-d,startY:i.startY+l,endY:i.endY-p},c=m.endX-m.startX,S=R.getCellValueOrigin(n),v=`${S!=null?S:""}`;let{tb:f,pd:D}=a||{};const{l:C=o.DEFAULT_STYLES.pd.l,r:w=o.DEFAULT_STYLES.pd.r}=D!=null?D:{};f=f!=null?f:o.WrapStrategy.WRAP;let _=he*2+ce;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:_=ce+he*2+w+C;break;case o.DataValidationRenderMode.CUSTOM:_=ce+he*2+De*2+w+C+ft/2+1;break;default:_=ce+he*2+De*2+w+C+ft/2+1}const M=c-_,{documentSkeleton:E,docModel:b}=Ge(v,this._localeService,a);return f===o.WrapStrategy.WRAP&&b.updateDocumentDataPageSize(Math.max(M,1)),E.calculate(),E.getActualSize(),B.getDocsSkeletonPageSize(E).width+_}isHit(e,t){const{data:a,subUnitId:n,row:i,col:r}=t,d=this._ensureMap(n).get(this._generateKey(i,r)),l=a.dataValidation;if(!l||!d||l.rule.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:p,left:u,width:m,height:c}=d,{x:S,y:v}=e;return S>=u&&S<=u+m&&v>=p&&v<=p+c}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=e,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Ae.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};gt=Ba([vt(0,o.Inject(o.LocaleService)),vt(1,o.ICommandService),vt(2,o.Inject(B.IRenderManagerService))],gt);class $a extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST);L(this,"canvasRender",this.injector.createInstance(gt));L(this,"dropdown",Ne);L(this,"optionsInput",$e.componentKey);L(this,"formulaInput",dt)}}class Ha extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.TEXT_LENGTH);L(this,"formulaInput",We)}}class Ya extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.WHOLE);L(this,"formulaInput",We)}}var Xa=Object.defineProperty,za=Object.getOwnPropertyDescriptor,Ka=(e,t,a,n)=>{for(var i=n>1?void 0:n?za(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Xa(t,a,i),i},St=(e,t)=>(a,n)=>t(a,n,e);let be=class extends o.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[Ft,Et],[tt,Un],[Lt,En],[Ne,Tn],[ot,un],[$e.componentKey,$e],[He.componentKey,He],...ma].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Ma,Ya,Ha,Ra,ya,$a,xa,Va].forEach(e=>{const t=this._injector.createInstance(e),a=this._dataValidatorRegistryService.getValidatorItem(t.id);a&&(a.formulaInput=t.formulaInput,a.canvasRender=t.canvasRender,a.dropdown=t.dropdown,a.optionsInput=t.optionsInput)})}};be=Ka([St(0,o.Inject(o.Injector)),St(1,o.Inject(z.ComponentManager)),St(2,o.Inject(Q.DataValidatorRegistryService))],be);var Ga=Object.defineProperty,qa=Object.getOwnPropertyDescriptor,Za=(e,t,a,n)=>{for(var i=n>1?void 0:n?qa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Ga(t,a,i),i},_t=(e,t)=>(a,n)=>t(a,n,e);const Ja="SHEET_DATA_VALIDATION_UI_PLUGIN";H.UniverSheetsDataValidationUIPlugin=(qe=class extends o.Plugin{constructor(t=At,a,n,i){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(at,s)}onStarting(){[[ue],[fe],[Pe],[ye],[Re],[Ee],[Ve],[Te],[be]].forEach(t=>{this._injector.add(t)}),[Ue,Ae,jt,nt,_e,Pt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ve),this._injector.get(Ee),this._injector.get(Te),this._injector.get(Pe),this._injector.get(B.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(be),this._injector.get(Re)}onSteady(){this._injector.get(ye)}},L(qe,"pluginName",Ja),L(qe,"type",o.UniverInstanceType.UNIVER_SHEET),qe),H.UniverSheetsDataValidationUIPlugin=Za([_t(1,o.Inject(o.Injector)),_t(2,o.ICommandService),_t(3,o.IConfigService)],H.UniverSheetsDataValidationUIPlugin);var Qa=Object.defineProperty,ei=Object.getOwnPropertyDescriptor,ti=(e,t,a,n)=>{for(var i=n>1?void 0:n?ei(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Qa(t,a,i),i},It=(e,t)=>(a,n)=>t(a,n,e);const ni="SHEET_DATA_VALIDATION_UI_PLUGIN";H.UniverSheetsDataValidationMobileUIPlugin=(Ze=class extends o.Plugin{constructor(t=At,a,n,i){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(at,s)}onStarting(){[[ue],[fe],[Pe],[ye],[Re],[Ee],[Ve],[be]].forEach(t=>{this._injector.add(t)}),[Ue,Ae,jt,nt,_e,Pt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ve),this._injector.get(Ee),this._injector.get(B.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(be),this._injector.get(Re)}onSteady(){this._injector.get(ye)}},L(Ze,"pluginName",ni),L(Ze,"type",o.UniverInstanceType.UNIVER_SHEET),Ze),H.UniverSheetsDataValidationMobileUIPlugin=ti([It(1,o.Inject(o.Injector)),It(2,o.ICommandService),It(3,o.IConfigService)],H.UniverSheetsDataValidationMobileUIPlugin),H.DATE_DROPDOWN_KEY=ot,H.LIST_DROPDOWN_KEY=Ne,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});
9
+ */var en=f,tn=Symbol.for("react.element"),nn=Symbol.for("react.fragment"),an=Object.prototype.hasOwnProperty,on=en.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,rn={key:!0,ref:!0,__self:!0,__source:!0};function yt(e,t,a){var n,i={},r=null,s=null;a!==void 0&&(r=""+a),t.key!==void 0&&(r=""+t.key),t.ref!==void 0&&(s=t.ref);for(n in t)an.call(t,n)&&!rn.hasOwnProperty(n)&&(i[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)i[n]===void 0&&(i[n]=t[n]);return{$$typeof:tn,type:e,key:r,ref:s,props:i,_owner:on.current}}Ae.Fragment=nn,Ae.jsx=yt,Ae.jsxs=yt,Dt.exports=Ae;var h=Dt.exports,sn=Object.defineProperty,ln=Object.getOwnPropertyDescriptor,dn=(e,t,a,n)=>{for(var i=n>1?void 0:n?ln(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&sn(t,a,i),i},Le=(e,t)=>(a,n)=>t(a,n,e);let Te=class extends o.Disposable{constructor(e,t,a,n,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(X.AFTER_CELL_EDIT_ASYNC,{handler:async(e,t,a)=>{var g;const n=await e,{worksheet:i,row:r,col:s,unitId:d,subUnitId:l,workbook:u}=t,p=this._dataValidationModel.getRuleIdByLocation(d,l,r,s),m=p?this._dataValidationModel.getRuleById(d,l,p):void 0;if(!m||m.errorStyle!==o.DataValidationErrorStyle.STOP)return a(Promise.resolve(n));const c=await this._dataValidatorRegistryService.getValidatorItem(m.type);if(!c||await c.validator({value:E.getCellValueOrigin(n),interceptValue:E.getCellValueOrigin((g=t==null?void 0:t.origin)!=null?g:n),row:r,column:s,unitId:d,subUnitId:l,worksheet:i,workbook:u,t:n==null?void 0:n.t},m))return a(Promise.resolve(n));const v=i.getCellRaw(r,s);return this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:c.getRuleFinalError(m,{row:r,col:s,unitId:d,subUnitId:l})},footer:{title:f.createElement(O.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(Promise.resolve(v))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:f.createElement(O.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Te=dn([Le(0,o.Inject(X.SheetInterceptorService)),Le(1,o.Inject(E.SheetDataValidationModel)),Le(2,o.Inject(Q.DataValidatorRegistryService)),Le(3,z.IDialogService),Le(4,o.Inject(o.LocaleService))],Te);const wt={dvDateDropdown:"univer-dv-date-dropdown",dvDateDropdownBtns:"univer-dv-date-dropdown-btns"},cn=e=>{if(e==null||typeof e=="boolean")return;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 un(e){var S;const{location:t,hideFn:a}=e,{worksheet:n,row:i,col:r,unitId:s,subUnitId:d,workbook:l}=t,u=o.useDependency(o.ICommandService),p=o.useDependency(Te),m=n.getCell(i,r),c=E.getCellValueOrigin(n.getCellRaw(i,r)),C=cn(c),[v,g]=f.useState(C),V=v&&v.isValid()?v:o.dayjs(),_=o.useDependency(o.LocaleService),w=o.useDependency(E.SheetDataValidationModel),y=w.getRuleByLocation(s,d,i,r);if(!y)return null;const b=w.getValidator(y.type);if(!m||!b)return;const I=!!((S=y.bizInfo)!=null&&S.showTime),D=async()=>{var x,U,$;if(!V)return;const A=V.format(I?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),W=(x=o.numfmt.parseDate(A))==null?void 0:x.v,F=l.getStyles().getStyleByCell(m),T=($=(U=F==null?void 0:F.n)==null?void 0:U.pattern)!=null?$:"",P=Jt.getPatternType(T);y.errorStyle!==o.DataValidationErrorStyle.STOP||await b.validator({value:W,unitId:s,subUnitId:d,row:i,column:r,worksheet:n,workbook:l,interceptValue:A.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},y)?(a(),await u.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:B.DeviceInputEventType.Keyboard,unitId:s,keycode:z.KeyCode.ESC}),await u.executeCommand(X.SetRangeValuesCommand.id,{unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:W,t:2,p:null,f:null,si:null,s:{n:{pattern:I?P==="datetime"?T:"yyyy-MM-dd hh:mm:ss":P==="date"?T:"yyyy-MM-dd"}}}})):p.showReject(b.getRuleFinalError(y,{row:i,col:r,unitId:s,subUnitId:d}))};return h.jsxs("div",{className:wt.dvDateDropdown,children:[h.jsx(O.DatePanel,{defaultValue:V,pickerValue:V,showTime:I||void 0,onSelect:async R=>{g(R)},onPanelChange:R=>{g(R)},disabledDate:R=>!o.numfmt.parseDate(R.format("YYYY-MM-DD"))}),h.jsx("div",{className:wt.dvDateDropdownBtns,children:h.jsx(O.Button,{size:"small",type:"primary",onClick:D,disabled:!V.isValid(),children:_.t("dataValidation.alert.ok")})})]})}var se=function(){return se=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},se.apply(this,arguments)},pn=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 i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(a[n[i]]=e[n[i]]);return a},ve=f.forwardRef(function(e,t){var a=e.icon,n=e.id,i=e.className,r=e.extend,s=pn(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),l=f.useRef("_".concat(vn()));return Vt(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},se({ref:t,className:d},s),r)});function Vt(e,t,a,n,i){return f.createElement(e.tag,se(se({key:t},hn(e,a,i)),n),(mn(e,a).children||[]).map(function(r,s){return Vt(r,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,i)}))}function hn(e,t,a){var n=se({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1);var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],d=r[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function mn(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)?se(se({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?se(se({},i),{attrs:se(se({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function vn(){return Math.random().toString(36).substring(2,8)}ve.displayName="UniverIcon";var fn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Et=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"check-mark-single",ref:t,icon:fn}))});Et.displayName="CheckMarkSingle";var gn={tag:"svg",attrs:{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.83062 8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767 13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279zM14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217 14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046 13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703 10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046 9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217 9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746 9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732 13.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"}}]},Mt=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"data-validation-single",ref:t,icon:gn}))});Mt.displayName="DataValidationSingle";var Sn={tag:"svg",attrs:{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.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.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.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.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"}}]},tt=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"delete-single",ref:t,icon:Sn}))});tt.displayName="DeleteSingle";var _n={tag:"svg",attrs:{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"}}]},Rt=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"increase-single",ref:t,icon:_n}))});Rt.displayName="IncreaseSingle";var In={tag:"svg",attrs:{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"}}]},bt=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"more-down-single",ref:t,icon:In}))});bt.displayName="MoreDownSingle";var Cn={tag:"svg",attrs:{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"}}]},Ot=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"more-up-single",ref:t,icon:Cn}))});Ot.displayName="MoreUpSingle";var Dn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},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 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},Lt=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"sequence-single",ref:t,icon:Dn}))});Lt.displayName="SequenceSingle";var yn=Object.defineProperty,wn=Object.getOwnPropertyDescriptor,Vn=(e,t,a,n)=>{for(var i=n>1?void 0:n?wn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&yn(t,a,i),i},Tt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends o.Disposable{constructor(t,a){super();L(this,"_open$",new re.BehaviorSubject(!1));L(this,"open$",this._open$.pipe(re.distinctUntilChanged()));L(this,"_activeRule");L(this,"_activeRule$",new re.BehaviorSubject(void 0));L(this,"activeRule$",this._activeRule$.asObservable());L(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(re.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===nt&&(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=Vn([Tt(0,o.IUniverInstanceService),Tt(1,z.ISidebarService)],ue);function En(){const e=o.useDependency(fe),t=z.useObservable(e.activeDropdown$,e.activeDropdown),a=o.useDependency(z.ComponentManager);if(!t)return null;const{location:n,componentKey:i}=t,r=a.get(i),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!r)return null;const d=()=>{e.hideDropdown()};return h.jsx(r,{location:n,hideFn:d},s)}const Pt="sheet.ui.dropdown";var Mn=Object.defineProperty,Rn=Object.getOwnPropertyDescriptor,bn=(e,t,a,n)=>{for(var i=n>1?void 0:n?Rn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Mn(t,a,i),i},Se=(e,t)=>(a,n)=>t(a,n,e);let fe=class extends o.Disposable{constructor(t,a,n,i,r,s,d){super();L(this,"_activeDropdown");L(this,"_activeDropdown$",new re.Subject);L(this,"_currentPopup",null);L(this,"activeDropdown$",this._activeDropdown$.asObservable());L(this,"_zenVisible",!1);this._canvasPopupManagerService=t,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=i,this._renderManagerService=r,this._dataValidationModel=s,this._sheetsSelectionsService=d,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,i){const r=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!r)return;const s=a?r.getSheetBySheetId(a):r.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(r.getUnitId(),s.getSheetId(),n,i);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdown}_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,a=!0){const{location:n}=t,{row:i,col:r,unitId:s,subUnitId:d}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const l=this._renderManagerService.getRenderById(o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),u=this._canvasPopupManagerService.attachPopupToCell(i,r,{componentKey:Pt,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[l==null?void 0:l.engine.getCanvasElement()].filter(Boolean)},s,d);if(!u)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const p=new o.DisposableCollection;p.add(u),p.add({dispose:()=>{var m,c;(c=(m=this._activeDropdown)==null?void 0:m.onHide)==null||c.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,i,r){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,i);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!u||!u.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:i,unitId:t,subUnitId:a},componentKey:u.dropdown,onHide:r})}};fe=bn([Se(0,o.Inject(N.SheetCanvasPopManagerService)),Se(1,o.IUniverInstanceService),Se(2,o.Inject(Q.DataValidatorRegistryService)),Se(3,z.IZenZoneService),Se(4,B.IRenderManagerService),Se(5,o.Inject(E.SheetDataValidationModel)),Se(6,o.Inject(X.SheetsSelectionsService))],fe);const nt="DataValidationPanel",_e={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,i=e.get(ue),r=e.get(Q.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(z.ISidebarService),l=X.getSheetCommandTarget(s);if(!l)return!1;const{unitId:u,subUnitId:p}=l,m=a?r.getRuleById(u,p,a):void 0;i.open(),i.setActiveRule(m&&{unitId:u,subUnitId:p,rule:m});const c=d.open({header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:nt},width:312,onClose:()=>i.close()});return i.setCloseDisposable(c),!0}},at={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},jt={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(at.id):t.executeCommand(_e.id),!0}},Fe={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:i,row:r,column:s}=t,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===i&&l.row===r&&l.col===s||a.showDataValidationDropdown(n,i,r,s),!0}},At={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},Ie="#ECECEC",it="sheets-data-validation-ui.config",Ft={},me={dvListDropdown:"univer-dv-list-dropdown",dvListDropdownTitle:"univer-dv-list-dropdown-title",dvListDropdownList:"univer-dv-list-dropdown-list",dvListDropdownListContainer:"univer-dv-list-dropdown-list-container",dvListDropdownSelectedIcon:"univer-dv-list-dropdown-selected-icon",dvListDropdownItemContainer:"univer-dv-list-dropdown-item-container",dvListDropdownItem:"univer-dv-list-dropdown-item",dvListDropdownSplit:"univer-dv-list-dropdown-split",dvListDropdownEdit:"univer-dv-list-dropdown-edit"},On=e=>{var I,D;const{value:t,onChange:a,multiple:n,options:i,title:r,onEdit:s,style:d,filter:l,location:u}=e,p=o.useDependency(o.LocaleService),m=o.useDependency(o.IConfigService),c=l==null?void 0:l.toLowerCase(),{row:C,col:v,unitId:g,subUnitId:V}=u,_=i.filter(S=>c?S.label.toLowerCase().includes(c):!0),w=(D=(I=m.getConfig(it))==null?void 0:I.showEditOnDropdown)!=null?D:!0,y=o.useDependency(N.SheetPermissionInterceptorBaseController),b=f.useMemo(()=>y.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission]},[{startColumn:v,startRow:C,endColumn:v,endRow:C}],g,V),[y,v,C,g,V]);return h.jsxs("div",{className:me.dvListDropdown,style:d,children:[h.jsx("div",{className:me.dvListDropdownTitle,children:r}),h.jsx("div",{className:me.dvListDropdownList,children:h.jsx(O.Scrollbar,{children:h.jsx("div",{className:me.dvListDropdownListContainer,children:_.map((S,R)=>{const A=t.indexOf(S.value)>-1,W=()=>{let T;A?T=new Set(t.filter(x=>x!==S.value)):T=new Set(n?[...t,S.value]:[S.value]);const P=[];i.forEach(x=>{T.has(x.value)&&P.push(x.value)}),a(P)},F=S.label.toLocaleLowerCase().indexOf(c);return h.jsxs("div",{className:me.dvListDropdownItemContainer,onClick:W,children:[h.jsx("div",{className:me.dvListDropdownItem,style:{background:S.color||Ie},children:c&&S.label.toLowerCase().includes(c)?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:S.label.substring(0,F)}),h.jsx("span",{style:{fontWeight:"bold"},children:S.label.substring(F,F+c.length)}),h.jsx("span",{children:S.label.substring(F+c.length)})]}):S.label}),h.jsx("div",{className:me.dvListDropdownSelectedIcon,children:A?h.jsx(Et,{}):null})]},R)})})},l)}),w&&b?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:me.dvListDropdownSplit}),h.jsx("div",{className:me.dvListDropdownEdit,children:h.jsx("a",{onClick:s,children:p.t("dataValidation.list.edit")})})]}):null]})};function Ln(e){var U,$,q,Z;const{location:t,hideFn:a}=e,{worksheet:n,row:i,col:r,unitId:s,subUnitId:d}=t,l=o.useDependency(Q.DataValidationModel),[u,p]=f.useState(""),m=o.useDependency(o.ICommandService),c=o.useDependency(o.LocaleService),[C,v]=f.useState(""),g=o.useDependency(N.IEditorBridgeService),V=o.useDependency(o.IUniverInstanceService),_=f.useMemo(()=>l.ruleChange$.pipe(re.debounceTime(16)),[]),w=o.useDependency(E.SheetDataValidationModel);z.useObservable(_);const y=z.RectPopup.useContext(),b=(($=(U=y.current)==null?void 0:U.right)!=null?$:0)-((Z=(q=y.current)==null?void 0:q.left)!=null?Z:0);if(f.useEffect(()=>{const G=m.onCommandExecuted(J=>{var te,ae;if(J.id===Qt.RichTextEditingMutation.id){const ie=J.params,{unitId:le}=ie,oe=V.getUnit(le,o.UniverInstanceType.UNIVER_DOC);if(!oe)return;const de=o.BuildTextUtils.transform.getPlainText((ae=(te=oe.getSnapshot().body)==null?void 0:te.dataStream)!=null?ae:"");p(de)}});return()=>{G.dispose()}},[m,V]),!n)return null;const I=w.getRuleByLocation(s,d,i,r);if(!I)return null;const D=w.getValidator(I.type);if(!D)return null;const S=n.getCell(i,r),R=(I==null?void 0:I.renderMode)===o.DataValidationRenderMode.CUSTOM||(I==null?void 0:I.renderMode)===void 0;if(!S||!I||!D||D.id.indexOf(o.DataValidationType.LIST)!==0)return;const A=I.type===o.DataValidationType.LIST_MULTIPLE,W=D.getListWithColor(I,s,d),F=C||E.getDataValidationCellValue(n.getCellRaw(i,r)),T=E.deserializeListOptions(F),P=()=>{m.executeCommand(_e.id,{ruleId:I.uid}),a()},x=W.map(G=>({label:G.label,value:G.label,color:R||G.color?G.color:"transparent"}));return h.jsx(On,{style:{minWidth:b,maxWidth:Math.max(b,200)},title:A?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:T,multiple:A,onChange:async G=>{const J=E.serializeListOptions(G),te={unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:J,p:null,f:null,si:null}};g.isVisible()&&g.changeVisible({visible:!1,keycode:z.KeyCode.ESC,eventType:B.DeviceInputEventType.Keyboard,unitId:s}),v(J),A||a(),g.isVisible().visible&&await m.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:B.DeviceInputEventType.Keyboard,unitId:s,keycode:z.KeyCode.ESC}),m.executeCommand(X.SetRangeValuesCommand.id,te)},options:x,onEdit:P,filter:u,location:t})}const ot={dataValidationOptionsButton:"univer-data-validation-options-button",dataValidationOptionsButtonIcon:"univer-data-validation-options-button-icon"};function Tn(e){var u;const t=o.useDependency(o.LocaleService),a=o.useDependency(z.ComponentManager),{value:n,onChange:i,extraComponent:r}=e,[s,d]=f.useState(!1),l=r?a.get(r):null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:ot.dataValidationOptionsButton,onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?h.jsx(Ot,{className:ot.dataValidationOptionsButtonIcon}):h.jsx(bt,{className:ot.dataValidationOptionsButtonIcon})]}),s&&h.jsxs(h.Fragment,{children:[l?h.jsx(l,{value:n,onChange:i}):null,h.jsx(O.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:h.jsxs(O.RadioGroup,{value:`${(u=n.errorStyle)!=null?u:o.DataValidationErrorStyle.WARNING}`,onChange:p=>i({...n,errorStyle:+p}),children:[h.jsx(O.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),h.jsx(O.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),h.jsx(O.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:h.jsx(O.Checkbox,{checked:n.showErrorMessage,onChange:()=>i({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?h.jsx(O.FormLayout,{children:h.jsx(O.Input,{value:n.error,onChange:p=>i({...n,error:p})})}):null]})]})}const ye={dataValidationDetail:"univer-data-validation-detail",dataValidationDetailFormItem:"univer-data-validation-detail-form-item",dataValidationDetailButtons:"univer-data-validation-detail-buttons",dataValidationDetailButton:"univer-data-validation-detail-button"},Pn=e=>o.debounce(async(t,a,n,i)=>{const r=await e.executeCommand(t,a,n);i==null||i(r)},1e3);function jn(e,t,a){var n,i,r,s;return t?((i=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:i.getSheetId())||"":((s=(r=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function An(){var de;const[e,t]=f.useState(0),a=o.useDependency(ue),n=z.useObservable(a.activeRule$,a.activeRule),{unitId:i,subUnitId:r,rule:s}=n||{},d=s.uid,l=o.useDependency(Q.DataValidatorRegistryService),u=o.useDependency(o.IUniverInstanceService),p=o.useDependency(z.ComponentManager),m=o.useDependency(o.ICommandService),c=o.useDependency(Q.DataValidationModel),C=o.useDependency(o.LocaleService),[v,g]=f.useState(s),V=l.getValidatorItem(v.type),[_,w]=f.useState(!1),y=l.getValidatorsByScope(Q.DataValidatorRegistryScope.SHEET),[b,I]=f.useState(()=>v.ranges.map(j=>({unitId:"",sheetId:"",range:j}))),D=f.useMemo(()=>Pn(m),[m]),[S,R]=f.useState(!1),A=f.useRef({}),[W,F]=f.useState(!1),T=o.useDependency(X.SheetsSelectionsService);if(f.useEffect(()=>()=>{const j=T.getCurrentLastSelection();j&&T.setSelections([j])},[T]),f.useEffect(()=>{m.onCommandExecuted(j=>{(j.id===o.UndoCommand.id||j.id===o.RedoCommand.id)&&setTimeout(()=>{const M=c.getRuleById(i,r,d);t(k=>k+1),M&&(g(M),I(M.ranges.map(k=>({unitId:"",sheetId:"",range:k}))))},20)})},[m,c,d,r,i]),!V)return null;const P=V.operators,x=V.operatorNames,U=v.operator?Q.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,$=()=>{!v.ranges.length||S||(V.validatorFormula(v,i,r).success?a.setActiveRule(null):w(!0))},q=z.useEvent(j=>{const M=j.split(",").map(Qe.deserializeRangeWithSheet).map(K=>{const ge=K.sheetName;if(ge){const ai=jn(u,K.unitId,ge);return{...K,sheetId:ai}}return{...K,sheetId:""}});if(o.isUnitRangesEqual(M,b))return;I(M);const k=M.filter(K=>(!K.unitId||K.unitId===i)&&(!K.sheetId||K.sheetId===r)).map(K=>K.range);if(g({...v,ranges:k}),k.length===0)return;const H={unitId:i,subUnitId:r,ruleId:d,ranges:k};D(E.UpdateSheetDataValidationRangeCommand.id,H)}),Z=j=>{if(o.shallowEqual(j,Q.getRuleSetting(v)))return;g({...v,...j});const M={unitId:i,subUnitId:r,ruleId:d,setting:j};D(E.UpdateSheetDataValidationSettingCommand.id,M,void 0)},G=async()=>{await m.executeCommand(E.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:i,subUnitId:r}),a.setActiveRule(null)},J={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},te=j=>{const M=l.getValidatorItem(j);if(!M)return;const k=M.operators,H=c.getRuleById(i,r,d),K=j===(H==null?void 0:H.type)||j.includes("list")&&(H!=null&&H.type.includes("list"))?{...H,type:j}:{...v,type:j,operator:k[0],formula1:void 0,formula2:void 0};g(K),m.executeCommand(E.UpdateSheetDataValidationSettingCommand.id,{unitId:i,subUnitId:r,ruleId:v.uid,setting:Q.getRuleSetting(K)})},ae=p.get(V.formulaInput),ie=f.useMemo(()=>b.map(j=>Qe.serializeRange(j.range)).join(","),[]),le=Q.getRuleOptions(v),oe=j=>{o.shallowEqual(j,Q.getRuleOptions(v))||(g({...v,...j}),D(E.UpdateSheetDataValidationOptionsCommand.id,{unitId:i,subUnitId:r,ruleId:d,options:j}))};return z.useSidebarClick(j=>{var k;const M=(k=A.current)==null?void 0:k.handleOutClick;M&&M(j,()=>F(!1))}),h.jsxs("div",{className:ye.dataValidationDetail,children:[h.jsx(O.FormLayout,{label:C.t("dataValidation.panel.range"),error:!v.ranges.length||S?C.t("dataValidation.panel.rangeError"):"",children:h.jsx(et.RangeSelector,{unitId:i,subUnitId:r,initValue:ie,onChange:q,onFocus:()=>F(!0),isFocus:W,actions:A.current,onVerify:j=>R(!j)})}),h.jsx(O.FormLayout,{label:C.t("dataValidation.panel.type"),children:h.jsx(O.Select,{options:y==null?void 0:y.map(j=>({label:C.t(j.title),value:j.id})),value:v.type,onChange:te,className:ye.dataValidationDetailFormItem})}),P!=null&&P.length?h.jsx(O.FormLayout,{label:C.t("dataValidation.panel.operator"),children:h.jsx(O.Select,{options:P.map((j,M)=>({value:`${j}`,label:x[M]})),value:`${v.operator}`,onChange:j=>{Z({...J,operator:j})},className:ye.dataValidationDetailFormItem})}):null,ae?h.jsx(ae,{isTwoFormula:U,value:{formula1:v.formula1,formula2:v.formula2},onChange:j=>{Z({...J,...j})},showError:_,validResult:V.validatorFormula(v,i,r),unitId:i,subUnitId:r,ruleId:d},e+v.type):null,h.jsx(O.FormLayout,{children:h.jsx(O.Checkbox,{checked:(de=v.allowBlank)!=null?de:!0,onChange:()=>{var j;return Z({...J,allowBlank:!((j=v.allowBlank)==null||j)})},children:C.t("dataValidation.panel.allowBlank")})}),h.jsx(Tn,{value:le,onChange:oe,extraComponent:V.optionsInput}),h.jsxs("div",{className:ye.dataValidationDetailButtons,children:[h.jsx(O.Button,{className:ye.dataValidationDetailButton,onClick:G,children:C.t("dataValidation.panel.removeRule")}),h.jsx(O.Button,{className:ye.dataValidationDetailButton,type:"primary",onClick:$,children:C.t("dataValidation.panel.done")})]})]})}const xe={dataValidationItemContainer:"univer-data-validation-item-container",dataValidationItemTitle:"univer-data-validation-item-title",dataValidationItemContent:"univer-data-validation-item-content",dataValidationItemIcon:"univer-data-validation-item-icon"},Fn=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:i,disable:r}=e,s=o.useDependency(Q.DataValidatorRegistryService),d=o.useDependency(o.ICommandService),l=o.useDependency(N.IMarkSelectionService),u=s.getValidatorItem(t.type),p=f.useRef(),[m,c]=f.useState(!1),C=v=>{d.executeCommand(E.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:i}),v.stopPropagation()};return f.useEffect(()=>()=>{var v;p.current&&((v=p.current)==null||v.forEach(g=>{g&&l.removeShape(g)}))},[l]),h.jsxs("div",{className:xe.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{r||(c(!0),p.current=t.ranges.map(v=>l.addShape({range:v,style:{fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:null})))},onMouseLeave:()=>{var v;c(!1),(v=p.current)==null||v.forEach(g=>{g&&l.removeShape(g)}),p.current=void 0},children:[h.jsx("div",{className:xe.dataValidationItemTitle,children:u==null?void 0:u.generateRuleName(t)}),h.jsx("div",{className:xe.dataValidationItemContent,children:t.ranges.map(v=>Qe.serializeRange(v)).join(",")}),m?h.jsx("div",{className:xe.dataValidationItemIcon,onClick:C,children:h.jsx(tt,{})}):null]})},Ne={dataValidationList:"univer-data-validation-list",dataValidationListButtons:"univer-data-validation-list-buttons",dataValidationListButton:"univer-data-validation-list-button"};function xn(){const e=o.useDependency(o.IUniverInstanceService),t=z.useObservable(()=>e.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return t?h.jsx(Nn,{workbook:t}):null}function Nn(e){const t=o.useDependency(E.SheetDataValidationModel),a=o.useDependency(o.IUniverInstanceService),n=o.useDependency(o.ICommandService),i=o.useDependency(o.Injector),r=o.useDependency(ue),s=o.useDependency(o.LocaleService),[d,l]=f.useState([]),{workbook:u}=e,p=z.useObservable(u.activeSheet$,void 0,!0),m=u.getUnitId(),c=p==null?void 0:p.getSheetId();f.useEffect(()=>{l(t.getRules(m,c));const w=t.ruleChange$.subscribe(y=>{y.unitId===m&&y.subUnitId===c&&l(t.getRules(m,c))});return()=>{w.unsubscribe()}},[m,c,t]);const C=async()=>{const w=E.createDefaultNewRule(i),y={unitId:m,subUnitId:c,rule:w};await n.executeCommand(E.AddSheetDataValidationCommand.id,y),r.setActiveRule({unitId:m,subUnitId:c,rule:w})},v=()=>{n.executeCommand(E.RemoveSheetAllDataValidationCommand.id,{unitId:m,subUnitId:c})},V=(w=>{const y=a.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),b=y.getActiveSheet(),I=y.getUnitId(),D=b.getSheetId();return w.map(R=>X.checkRangesEditablePermission(i,I,D,R.ranges)?{...R}:{...R,disable:!0})})(d),_=V==null?void 0:V.some(w=>w.disable);return h.jsxs("div",{className:Ne.dataValidationList,children:[V==null?void 0:V.map(w=>{var y;return h.jsx(Fn,{unitId:m,subUnitId:c,onClick:()=>{w.disable||r.setActiveRule({unitId:m,subUnitId:c,rule:w})},rule:w,disable:(y=w.disable)!=null?y:!1},w.uid)}),h.jsxs("div",{className:Ne.dataValidationListButtons,children:[d.length&&!_?h.jsx(O.Button,{className:Ne.dataValidationListButton,onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,h.jsx(O.Button,{className:Ne.dataValidationListButton,type:"primary",onClick:C,children:s.t("dataValidation.panel.add")})]})]})}const Un=()=>{const e=o.useDependency(ue),t=z.useObservable(e.activeRule$,e.activeRule);return t?h.jsx(An,{},t.rule.uid):h.jsx(xn,{})},Ue="data-validation.list.dropdown",rt="data-validation.date.dropdown",Be={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),a=X.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:i}=a,r=E.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=i.getSheetId(),u={rule:r,unitId:d,subUnitId:l};return s.syncExecuteCommand(E.AddSheetDataValidationCommand.id,u)?(s.syncExecuteCommand(_e.id,{ruleId:r.uid,isAdd:!0}),!0):!1}};var Bn=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,Wn=(e,t,a,n)=>{for(var i=n>1?void 0:n?kn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Bn(t,a,i),i},we=(e,t)=>(a,n)=>t(a,n,e);const ke="SHEET_DATA_VALIDATION_ALERT";let Pe=class extends o.Disposable{constructor(e,t,a,n,i,r){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=i,this._dataValidationModel=r,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(re.debounceTime(100)).subscribe(e=>{var t;if(e){if(!this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET).getActiveSheet())return;const i=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!i)return;if(this._dataValidationModel.validator(i,e.location)===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(ke),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)return;const l=this._dataValidationModel.getValidator(i.type);if(!l)return;this._cellAlertManagerService.showAlert({type:N.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(i,e.location),location:e.location,width:200,height:74,key:ke});return}}this._cellAlertManagerService.removeAlert(ke)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(ke)}))}};Pe=Wn([we(0,o.Inject(N.HoverManagerService)),we(1,o.Inject(N.CellAlertManagerService)),we(2,o.IUniverInstanceService),we(3,o.Inject(o.LocaleService)),we(4,z.IZenZoneService),we(5,o.Inject(E.SheetDataValidationModel))],Pe);var $n=Object.defineProperty,Hn=Object.getOwnPropertyDescriptor,Yn=(e,t,a,n)=>{for(var i=n>1?void 0:n?Hn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&$n(t,a,i),i},st=(e,t)=>(a,n)=>t(a,n,e);let Ve=class extends o.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._dataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(i,r)=>{const{source:s,target:d,unitId:l,subUnitId:u}=i,p=this._dataValidationModel.getRuleObjectMatrix(l,u).clone(),m=N.virtualizeDiscreteRanges([s,d]),[c,C]=m.ranges,{mapFunc:v}=m,g={row:c.startRow,col:c.startColumn},V=N.getAutoFillRepeatRange(c,C),_=new o.ObjectMatrix,w=new Set;V.forEach(S=>{const R=S.repeatStartCell,A=S.relativeRange,W={startRow:g.row,startColumn:g.col,endColumn:g.col,endRow:g.row},F={startRow:R.row,startColumn:R.col,endColumn:R.col,endRow:R.row};o.Range.foreach(A,(T,P)=>{const x=o.Rectangle.getPositionRange({startRow:T,startColumn:P,endColumn:P,endRow:T},W),{row:U,col:$}=v(x.startRow,x.startColumn),q=this._dataValidationModel.getRuleIdByLocation(l,u,U,$);if(q){const Z=o.Rectangle.getPositionRange({startRow:T,startColumn:P,endColumn:P,endRow:T},F),{row:G,col:J}=v(Z.startRow,Z.startColumn);_.setValue(G,J,q),w.add(q)}})});const y=Array.from(w).map(S=>({id:S,ranges:o.queryObjectMatrix(_,R=>R===S)}));p.addRangeRules(y);const b=p.diff(this._dataValidationModel.getRules(l,u)),{redoMutations:I,undoMutations:D}=E.getDataValidationDiffMutations(l,u,b,this._injector,"patched",r===N.APPLY_TYPE.ONLY_FORMAT);return{undos:D,redos:I}},a=[o.DataValidationType.CHECKBOX],n={id:E.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:i=>{const{source:r,unitId:s,subUnitId:d}=i;for(const l of r.rows)for(const u of r.cols){const p=this._dataValidationModel.getRuleByLocation(s,d,l,u);if(p&&a.indexOf(p.type)>-1){this._autoFillService.setDisableApplyType(N.APPLY_TYPE.SERIES,!0);return}}},onFillData:(i,r,s)=>s===N.APPLY_TYPE.COPY||s===N.APPLY_TYPE.ONLY_FORMAT||s===N.APPLY_TYPE.SERIES?t(i,s):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};Ve=Yn([st(0,N.IAutoFillService),st(1,o.Inject(E.SheetDataValidationModel)),st(2,o.Inject(o.Injector))],Ve);var Xn=Object.defineProperty,zn=Object.getOwnPropertyDescriptor,Kn=(e,t,a,n)=>{for(var i=n>1?void 0:n?zn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Xn(t,a,i),i},lt=(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:E.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,i)=>{const{copyType:r=N.COPY_TYPE.COPY,pasteType:s}=i,{range:d}=t||{},{range:l,unitId:u,subUnitId:p}=a;return this._generateMutations(l,{copyType:r,pasteType:s,copyRange:d,unitId:u,subUnitId:p})}})}_collect(t,a,n){const i=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:i};const r=this._injector.invoke(l=>N.rangeToDiscreteRange(n,l,t,a));if(!r)return;const{rows:s,cols:d}=r;s.forEach((l,u)=>{d.forEach((p,m)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(t,a,l,p);i.setValue(u,m,c!=null?c:"")})})}_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:n,subUnitId:i}=this._copyInfo;if(a.unitId!==n||i!==a.subUnitId){const r=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),s=new o.ObjectMatrix,d=new Set,{ranges:[l,u],mapFunc:p}=N.virtualizeDiscreteRanges([a.copyRange,t]),m=N.getRepeatRange(l,u,!0),c=new Map;m.forEach(({startRange:V})=>{var _;(_=this._copyInfo)==null||_.matrix.forValue((w,y,b)=>{const I=o.Rectangle.getPositionRange({startRow:w,endRow:w,startColumn:y,endColumn:y},V),D=`${i}-${b}`,S=this._sheetDataValidationModel.getRuleById(n,i,b);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,D)&&S&&c.set(D,{...S,uid:D});const{row:R,col:A}=p(I.startRow,I.startColumn);d.add(D),s.setValue(R,A,D)})});const C=Array.from(d).map(V=>({id:V,ranges:o.queryObjectMatrix(s,_=>_===V)}));r.addRangeRules(C);const{redoMutations:v,undoMutations:g}=E.getDataValidationDiffMutations(a.unitId,a.subUnitId,r.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),c.values()),this._injector,"patched",!1);return{redos:v,undos:g}}else{const r=this._sheetDataValidationModel.getRuleObjectMatrix(n,i).clone(),s=new o.ObjectMatrix,d=new Set,{ranges:[l,u],mapFunc:p}=N.virtualizeDiscreteRanges([a.copyRange,t]);N.getRepeatRange(l,u,!0).forEach(({startRange:g})=>{var V;(V=this._copyInfo)==null||V.matrix.forValue((_,w,y)=>{const b=o.Rectangle.getPositionRange({startRow:_,endRow:_,startColumn:w,endColumn:w},g),{row:I,col:D}=p(b.startRow,b.startColumn);s.setValue(I,D,y),d.add(y)})});const c=Array.from(d).map(g=>({id:g,ranges:o.queryObjectMatrix(s,V=>V===g)}));r.addRangeRules(c);const{redoMutations:C,undoMutations:v}=E.getDataValidationDiffMutations(n,i,r.diff(this._sheetDataValidationModel.getRules(n,i)),this._injector,"patched",!1);return{redos:C,undos:v}}}};Ee=Kn([lt(0,N.ISheetClipboardService),lt(1,o.Inject(E.SheetDataValidationModel)),lt(2,o.Inject(o.Injector))],Ee);var Gn=Object.defineProperty,qn=Object.getOwnPropertyDescriptor,Zn=(e,t,a,n)=>{for(var i=n>1?void 0:n?qn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Gn(t,a,i),i},dt=(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._sheetPermissionInterceptorBaseController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===E.AddSheetDataValidationCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission,X.WorksheetSetCellStylePermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr"))),e.id===E.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission,X.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr")))}))}};Me=Zn([dt(0,o.Inject(o.LocaleService)),dt(1,o.ICommandService),dt(2,o.Inject(N.SheetPermissionInterceptorBaseController))],Me);const xt="data-validation-single",Nt="sheet.menu.data-validation";function Jn(e){return{id:Nt,type:z.MenuItemType.SUBITEMS,icon:xt,tooltip:"dataValidation.title",hidden$:z.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[X.WorkbookEditablePermission],worksheetTypes:[X.WorksheetSetCellStylePermission,X.WorksheetEditPermission],rangeTypes:[X.RangeProtectionPermissionEditPoint]})}}function Qn(e){return{id:_e.id,title:"dataValidation.panel.title",type:z.MenuItemType.BUTTON}}function ea(e){return{id:Be.id,title:"dataValidation.panel.add",type:z.MenuItemType.BUTTON}}const ta={[z.RibbonStartGroup.FORMULAS_INSERT]:{[Nt]:{order:9,menuItemFactory:Jn,[_e.id]:{order:0,menuItemFactory:Qn},[Be.id]:{order:1,menuItemFactory:ea}}}};var na=Object.defineProperty,aa=Object.getOwnPropertyDescriptor,Ut=(e,t,a,n)=>{for(var i=n>1?void 0:n?aa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&na(t,a,i),i},ee=(e,t)=>(a,n)=>t(a,n,e);const Bt={tr:{size:6,color:"#fe4b4b"}};let Re=class extends o.RxDisposable{constructor(e,t,a,n,i,r,s,d,l,u,p){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=i,this._dropdownManagerService=r,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=u,this._editorBridgeService=p,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(ta)}_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:i,row:r,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,i,r,s);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(u!=null&&u.dropdown))return;const p=d.getActiveSheet();if(!p)return;const m=this._dropdownManagerService.activeDropdown,c=m==null?void 0:m.location;if(c&&c.unitId===n&&c.subUnitId===i&&c.row===r&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:i,row:r,col:s,workbook:d,worksheet:p},componentKey:u.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var _,w,y,b,I;const{row:n,col:i,unitId:r,subUnitId:s,workbook:d,worksheet:l}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!u)return a(e);const p=this._sheetDataValidationModel.getRuleById(r,s,u);if(!p)return a(e);const m=(_=this._dataValidationCacheService.getValue(r,s,n,i))!=null?_:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),C=t.rawData;let v;const g={get value(){var D;return v!==void 0||(v=(D=E.getCellValueOrigin(C))!=null?D:null),v}},V={get value(){var D;return`${(D=g.value)!=null?D:""}`}};return a({...e,markers:{...e==null?void 0:e.markers,...m===o.DataValidationStatus.INVALID?Bt:null},customRender:[...(w=e==null?void 0:e.customRender)!=null?w:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((b=c==null?void 0:c.skipDefaultFontRender)==null?void 0:b.call(c,p,g.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,V.value,{get style(){const D=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?D.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,i)},interceptorAutoHeight:()=>{var A,W,F,T,P,x;const D=(W=(A=this._renderManagerService.getRenderById(r))==null?void 0:A.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:W.skeleton;if(!D)return;const S=D.worksheet.getMergedCell(n,i),R={data:e,style:D.getsStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex((F=S==null?void 0:S.startRow)!=null?F:n,(T=S==null?void 0:S.startColumn)!=null?T:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(x=(P=c==null?void 0:c.canvasRender)==null?void 0:P.calcCellAutoHeight)==null?void 0:x.call(P,R)},interceptorAutoWidth:()=>{var A,W,F,T,P,x;const D=(W=(A=this._renderManagerService.getRenderById(r))==null?void 0:A.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:W.skeleton;if(!D)return;const S=D.worksheet.getMergedCell(n,i),R={data:e,style:D.getsStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex((F=S==null?void 0:S.startRow)!=null?F:n,(T=S==null?void 0:S.startColumn)!=null?T:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(x=(P=c==null?void 0:c.canvasRender)==null?void 0:P.calcCellAutoWidth)==null?void 0:x.call(P,R)},coverable:((I=e==null?void 0:e.coverable)!=null?I:!0)&&!(p.type===o.DataValidationType.LIST||p.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(re.filter(e=>e.source==="command"),re.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(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)}})}};Re=Ut([ee(0,o.ICommandService),ee(1,z.IMenuManagerService),ee(2,B.IRenderManagerService),ee(3,o.IUniverInstanceService),ee(4,o.Inject(N.AutoHeightController)),ee(5,o.Inject(fe)),ee(6,o.Inject(E.SheetDataValidationModel)),ee(7,o.Inject(Q.DataValidatorRegistryService)),ee(8,o.Inject(X.SheetInterceptorService)),ee(9,o.Inject(E.DataValidationCacheService)),ee(10,o.Optional(N.IEditorBridgeService))],Re);let kt=class extends o.RxDisposable{constructor(e,t,a,n,i,r,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=i,this._sheetDataValidationModel=r,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var V,_,w,y,b;const{row:n,col:i,unitId:r,subUnitId:s,workbook:d,worksheet:l}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!u)return a(e);const p=this._sheetDataValidationModel.getRuleById(r,s,u);if(!p)return a(e);const m=(V=this._dataValidationCacheService.getValue(r,s,n,i))!=null?V:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),C=l.getCellRaw(n,i),v=E.getCellValueOrigin(C),g=`${v!=null?v:""}`;return a({...e,markers:{...e==null?void 0:e.markers,...m===o.DataValidationStatus.INVALID?Bt:null},customRender:[...(_=e==null?void 0:e.customRender)!=null?_:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((w=e==null?void 0:e.fontRenderExtension)==null?void 0:w.isSkip)||((y=c==null?void 0:c.skipDefaultFontRender)==null?void 0:y.call(c,p,v,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,g,{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,i)},interceptorAutoHeight:()=>{var R,A,W,F,T,P;const I=(A=(R=this._renderManagerService.getRenderById(r))==null?void 0:R.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:A.skeleton;if(!I)return;const D=I.worksheet.getMergedCell(n,i),S={data:e,style:I.getsStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((W=D==null?void 0:D.startRow)!=null?W:n,(F=D==null?void 0:D.startColumn)!=null?F:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(P=(T=c==null?void 0:c.canvasRender)==null?void 0:T.calcCellAutoHeight)==null?void 0:P.call(T,S)},coverable:((b=e==null?void 0:e.coverable)!=null?b:!0)&&!(p.type===o.DataValidationType.LIST||p.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(re.filter(e=>e.source==="command"),re.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(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)}})}};kt=Ut([ee(0,o.ICommandService),ee(1,B.IRenderManagerService),ee(2,o.Inject(N.AutoHeightController)),ee(3,o.Inject(Q.DataValidatorRegistryService)),ee(4,o.Inject(X.SheetInterceptorService)),ee(5,o.Inject(E.SheetDataValidationModel)),ee(6,o.Inject(E.DataValidationCacheService))],kt);var ia=Object.defineProperty,oa=Object.getOwnPropertyDescriptor,ra=(e,t,a,n)=>{for(var i=n>1?void 0:n?oa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&ia(t,a,i),i},Wt=(e,t)=>(a,n)=>t(a,n,e);let We=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(i=>{a.add(i.subUnitId)}),a.forEach(i=>{var r;(r=this._sheetSkeletonManagerService.getWorksheetSkeleton(i))==null||r.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};We=ra([Wt(1,o.Inject(E.SheetDataValidationModel)),Wt(2,o.Inject(N.SheetSkeletonManagerService))],We);const ne={dataValidationFormula:"univer-data-validation-formula",dataValidationFormulaAnd:"univer-data-validation-formula-and",dataValidationFormulaListItem:"univer-data-validation-formula-list-item",dataValidationFormulaListItemIcon:"univer-data-validation-formula-list-item-icon",dataValidationFormulaListItemDrag:"univer-data-validation-formula-list-item-drag",dataValidationFormulaListAdd:"univer-data-validation-formula-list-add",dataValidationFormulaColorSelect:"univer-data-validation-formula-color-select",dataValidationFormulaColorSelectPanel:"univer-data-validation-formula-color-select-panel",dataValidationFormulaColorItem:"univer-data-validation-formula-color-item"},sa=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:i,validResult:r}=e,s=o.useDependency(o.LocaleService),d=i?r==null?void 0:r.formula1:"",l=i?r==null?void 0:r.formula2:"";return t?h.jsxs(h.Fragment,{children:[h.jsx(O.FormLayout,{error:d,children:h.jsx(O.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({...a,formula1:u})}})}),h.jsx("div",{className:ne.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),h.jsx(O.FormLayout,{error:l,children:h.jsx(O.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:u=>{n==null||n({...a,formula2:u})}})})]}):h.jsx(O.FormLayout,{error:d,children:h.jsx(O.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({formula1:u})}})})};function la(e){const{value:t,onChange:a,showError:n,validResult:i}=e,r=o.useDependency(o.LocaleService),s=n?i==null?void 0:i.formula1:"",d=n?i==null?void 0:i.formula2:"",[l,u]=f.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return h.jsxs(h.Fragment,{children:[h.jsx(O.FormLayout,{children:h.jsx(O.Checkbox,{checked:l,onChange:p=>{p?u(!0):(u(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:r.t("dataValidation.checkbox.tips")})}),l?h.jsx(O.FormLayout,{label:r.t("dataValidation.checkbox.checked"),error:s,children:h.jsx(O.Input,{className:ne.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:p=>{a==null||a({...t,formula1:p||void 0})}})}):null,l?h.jsx(O.FormLayout,{label:r.t("dataValidation.checkbox.unchecked"),error:d,children:h.jsx(O.Input,{className:ne.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:p=>{a==null||a({...t,formula2:p||void 0})}})}):null]})}function da(e){var m;const{unitId:t,subUnitId:a,value:n,onChange:i,showError:r,validResult:s}=e,d=r?s==null?void 0:s.formula1:void 0,l=f.useRef({}),[u,p]=f.useState(!1);return z.useSidebarClick(c=>{var v;const C=(v=l.current)==null?void 0:v.handleOutClick;C&&C(c,()=>p(!1))}),h.jsx(et.FormulaEditor,{initValue:(m=n==null?void 0:n.formula1)!=null?m:"",unitId:t,subUnitId:a,isFocus:u,onChange:c=>{const C=(c!=null?c:"").trim();C!==(n==null?void 0:n.formula1)&&(i==null||i({...n,formula1:C}))},errorText:d,onFocus:()=>p(!0),actions:l.current,isSupportAcrossSheet:!0})}function $t(e){var t,a,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(a=$t(e[t]))&&(n&&(n+=" "),n+=a)}else for(a in e)e[a]&&(n&&(n+=" "),n+=a);return n}function ca(){for(var e,t,a=0,n="",i=arguments.length;a<i;a++)(e=arguments[a])&&(t=$t(e))&&(n&&(n+=" "),n+=t);return n}const ua=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],pa=e=>{const{value:t,onChange:a,disabled:n}=e,[i,r]=f.useState(!1);return h.jsx(O.Select,{disabled:n,open:i,onDropdownVisibleChange:r,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ne.dataValidationFormulaColorSelect,value:t,onChange:a,labelRender:s=>h.jsx("div",{className:ne.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>h.jsx("div",{className:ne.dataValidationFormulaColorSelectPanel,children:ua.map(s=>h.jsx("div",{onClick:()=>{a(s),r(!1)},className:ne.dataValidationFormulaColorItem,style:{background:s}},s))})})},Ht=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:i,onItemDelete:r}=a;return h.jsxs("div",{className:ne.dataValidationFormulaListItem,style:n,children:[t.isRef?null:h.jsx("div",{className:ca(ne.dataValidationFormulaListItemDrag,"draggableHandle"),children:h.jsx(Lt,{})}),h.jsx(pa,{value:t.color,onChange:s=>{i(t.id,t.label,s)}}),h.jsx(O.Input,{disabled:t.isRef,value:t.label,onChange:s=>{i(t.id,s,t.color)}}),t.isRef?null:h.jsx("div",{className:ne.dataValidationFormulaListItemIcon,children:h.jsx(tt,{onClick:()=>r(t.id)})})]})};function ha(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:i,validResult:r,showError:s,ruleId:d}=e,{formula1:l="",formula2:u=""}=t||{},p=f.useRef(null),[m,c]=f.useState(()=>o.isFormulaString(l)?"1":"0"),[C,v]=f.useState(m==="1"?l:"="),[g,V]=f.useState(m==="1"?l:"="),_=o.useDependency(o.LocaleService),w=o.useDependency(Q.DataValidatorRegistryService),y=o.useDependency(Q.DataValidationModel),b=o.useDependency(E.DataValidationFormulaController),[I,D]=f.useState(()=>u.split(",")),S=w.getValidatorItem(o.DataValidationType.LIST),[R,A]=f.useState([]),[W,F]=f.useState(""),T=s?r==null?void 0:r.formula1:"",P=f.useMemo(()=>y.ruleChange$.pipe(re.debounceTime(16)),[]),x=z.useObservable(P),U=z.useEvent(a);f.useEffect(()=>{(async()=>{await new Promise(H=>{setTimeout(()=>H(!0),100)});const M=y.getRuleById(n,i,d),k=M==null?void 0:M.formula1;if(o.isFormulaString(k)&&S&&M){const H=await S.getListAsync(M,n,i);A(H)}})()},[y,x,S,d,i,n]),f.useEffect(()=>{o.isFormulaString(l)&&l!==g&&(v(l),V(g))},[g,l]);const[$,q]=f.useState(()=>{const M=m!=="1"?E.deserializeListOptions(l):[],k=u.split(",");return M.map((H,K)=>({label:H,color:k[K]||Ie,isRef:!1,id:o.Tools.generateRandomId(4)}))}),Z=(M,k,H)=>{const K=$.find(ge=>ge.id===M);K&&(K.label=k,K.color=H,q([...$]))},G=M=>{const k=$.findIndex(H=>H.id===M);k!==-1&&($.splice(k,1),q([...$]))},J=u.split(","),te=f.useMemo(()=>R.map((M,k)=>({label:M,color:J[k]||Ie,id:`${k}`,isRef:!0})),[J,R]),ae=(M,k,H)=>{const K=[...I];K[+M]=H,D(K),U({formula1:l,formula2:K.join(",")})},ie=()=>{q([...$,{label:"",color:Ie,isRef:!1,id:o.Tools.generateRandomId(4)}])};f.useEffect(()=>{if(m==="1")return;const M=new Set,k=[];$.map(H=>({labelList:H.label.split(","),item:H})).forEach(({item:H,labelList:K})=>{K.forEach(ge=>{M.has(ge)||(M.add(ge),k.push({label:ge,color:H.color}))})}),U({formula1:E.serializeListOptions(k.map(H=>H.label)),formula2:k.map(H=>H.color===Ie?"":H.color).join(",")})},[$,U,m,g,I]);const le=f.useMemo(()=>async M=>{if(!o.isFormulaString(M)){U==null||U({formula1:"",formula2:u});return}b.getFormulaRefCheck(M)?(U==null||U({formula1:o.isFormulaString(M)?M:"",formula2:u}),F("")):(U==null||U({formula1:"",formula2:u}),v("="),F(_.t("dataValidation.validFail.formulaError")))},[u,U]),oe=f.useRef({}),[de,j]=f.useState(!1);return z.useSidebarClick(M=>{var H;const k=(H=oe.current)==null?void 0:H.handleOutClick;k&&k(M,()=>j(!1))}),h.jsxs(h.Fragment,{children:[h.jsx(O.FormLayout,{label:_.t("dataValidation.list.options"),children:h.jsxs(O.RadioGroup,{value:m,onChange:M=>{c(M),v(g),M==="1"&&U({formula1:g==="="?"":g,formula2:I.join(",")})},children:[h.jsx(O.Radio,{value:"0",children:_.t("dataValidation.list.customOptions")}),h.jsx(O.Radio,{value:"1",children:_.t("dataValidation.list.refOptions")})]})}),m==="1"?h.jsxs(h.Fragment,{children:[h.jsx(et.FormulaEditor,{initValue:C,unitId:n,subUnitId:i,isFocus:de,onChange:(M="")=>{const k=(M!=null?M:"").trim();V(k),le(k)},errorText:T||W||void 0,onFocus:()=>j(!0),actions:oe.current,isSupportAcrossSheet:!0}),h.jsx("div",{ref:p,style:{marginTop:"12px"},children:te.map(M=>h.jsx(Ht,{item:M,commonProps:{onItemChange:ae},style:{marginBottom:12}},M.id))})]}):h.jsx(O.FormLayout,{error:T,children:h.jsxs("div",{ref:p,style:{marginTop:"-12px"},children:[h.jsx(O.DraggableList,{list:$,onListChange:q,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:M=>h.jsx(Ht,{item:M,commonProps:{onItemChange:Z,onItemDelete:G}},M.id),idKey:"id"}),h.jsxs("a",{className:ne.dataValidationFormulaListAdd,onClick:ie,children:[h.jsx(Rt,{}),_.t("dataValidation.list.add")]})]})})]})}const Yt="data-validation.custom-formula-input",$e="data-validation.formula-input",ct="data-validation.list-formula-input",Xt="data-validation.checkbox-formula-input",ma=[[Yt,da],[$e,sa],[ct,ha],[Xt,la]],va="LIST_RENDER_MODE_OPTION_INPUT";function He(e){var i;const{value:t,onChange:a}=e,n=o.useDependency(o.LocaleService);return h.jsx(O.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:h.jsxs(O.RadioGroup,{value:`${(i=t.renderMode)!=null?i:o.DataValidationRenderMode.CUSTOM}`,onChange:r=>a({...t,renderMode:+r}),children:[h.jsx(O.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),h.jsx(O.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),h.jsx(O.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}He.componentKey=va;const fa="DATE_SHOW_TIME_OPTION";function Ye(e){var i;const{value:t,onChange:a}=e,n=o.useDependency(o.LocaleService);return h.jsx(O.FormLayout,{children:h.jsx(O.Checkbox,{checked:(i=t.bizInfo)==null?void 0:i.showTime,onChange:r=>{a({...t,bizInfo:{...t.bizInfo,showTime:r}})},children:n.t("dataValidation.showTime.label")})})}Ye.componentKey=fa;var ga=Object.defineProperty,Sa=Object.getOwnPropertyDescriptor,_a=(e,t,a,n)=>{for(var i=n>1?void 0:n?Sa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&ga(t,a,i),i},je=(e,t)=>(a,n)=>t(a,n,e);const Xe=6;let ut=class{constructor(e,t,a,n,i){this._commandService=e,this._formulaService=t,this._themeService=a,this._renderManagerService=n,this._dataValidationModel=i}_calc(e,t){var u,p,m;const{vt:a,ht:n}=t||{},i=e.endX-e.startX-Xe*2,r=e.endY-e.startY,s=((u=t==null?void 0:t.fs)!=null?u:10)*1.6;let d=0,l=0;switch(a){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(r-s);break;default:l=0+(r-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:d=Xe;break;case o.HorizontalAlign.RIGHT:d=Xe+(i-s);break;default:d=Xe+(i-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((p=t==null?void 0:t.fs)!=null?p:10)*1.6,height:((m=t==null?void 0:t.fs)!=null?m: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 u,p,m,c,C,v,g,V,_;const{formula1:n=E.CHECKBOX_FORMULA_1,formula2:i=E.CHECKBOX_FORMULA_2}=e,r=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=E.getFormulaResult((m=(p=(u=r==null?void 0:r[0])==null?void 0:u.result)==null?void 0:p[0])==null?void 0:m[0]),d=E.getFormulaResult((v=(C=(c=r==null?void 0:r[1])==null?void 0:c.result)==null?void 0:C[0])==null?void 0:v[0]),l=E.isLegalFormulaResult(String(s))&&E.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(n)?E.getFormulaResult((_=(V=(g=r==null?void 0:r[0])==null?void 0:g.result)==null?void 0:V[0])==null?void 0:_[0]):n,formula2:o.isFormulaString(i)?d:i,isFormulaValid:l}}drawWith(e,t){var T,P,x,U;const{style:a,primaryWithCoord:n,unitId:i,subUnitId:r,worksheet:s,row:d,col:l}=t,u=n.isMergedMainCell?n.mergeInfo:n,p=E.getCellValueOrigin(s.getCellRaw(d,l)),m=this._dataValidationModel.getRuleByLocation(i,r,d,l);if(!m)return;const c=this._dataValidationModel.getValidator(m.type);if(!c)return;const C=this._themeService.getCurrentTheme();if(!((T=c.skipDefaultFontRender)!=null&&T.call(c,m,p,{unitId:i,subUnitId:r,row:d,column:l})))return;const v=c.parseFormulaSync(m,i,r),{formula1:g}=v,V=this._calc(u,a),{a:_,d:w}=e.getTransform(),y=B.fixLineWidthByScale(V.left,_),b=B.fixLineWidthByScale(V.top,w),I=B.Transform.create().composeMatrix({left:y,top:b,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),D=u.endX-u.startX,S=u.endY-u.startY;e.save(),e.beginPath(),e.rect(u.startX,u.startY,D,S),e.clip();const R=I.getMatrix();e.transform(R[0],R[1],R[2],R[3],R[4],R[5]);const A=((P=a==null?void 0:a.fs)!=null?P:10)*1.6,W=String(p)===String(g),F=C.hyacinth500;B.Checkbox.drawWith(e,{checked:W,width:A,height:A,fill:(U=(x=a==null?void 0:a.cl)==null?void 0:x.rgb)!=null?U:F}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),i=n.top,r=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:u}=e;return l<=d&&l>=s&&u<=r&&u>=i}async onPointerDown(e,t){var v;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:i,worksheet:r,row:s,col:d}=e,l=E.getCellValueOrigin(r.getCellRaw(s,d)),u=this._dataValidationModel.getRuleByLocation(n,i,s,d);if(!u)return;const p=this._dataValidationModel.getValidator(u.type);if(!p||!((v=p.skipDefaultFontRender)!=null&&v.call(p,u,l,{unitId:n,subUnitId:i,row:s,column:d})))return;const{formula1:m,formula2:c}=await this._parseFormula(u,n,i),C={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(l)===E.transformCheckboxValue(String(m))?c:m,p:null}};this._commandService.executeCommand(X.SetRangeValuesCommand.id,C)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};ut=_a([je(0,o.ICommandService),je(1,o.Inject(E.DataValidationFormulaService)),je(2,o.Inject(o.ThemeService)),je(3,o.Inject(B.IRenderManagerService)),je(4,o.Inject(E.SheetDataValidationModel))],ut);var Ia=Object.defineProperty,Ca=Object.getOwnPropertyDescriptor,Da=(e,t,a,n)=>{for(var i=n>1?void 0:n?Ca(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Ia(t,a,i),i},ya=(e,t)=>(a,n)=>t(a,n,e);let pe=class{constructor(e){L(this,"canvasRender",null);L(this,"dropdown");L(this,"optionsInput");L(this,"formulaInput",ct);this.injector=e}};pe=Da([ya(0,o.Inject(o.Injector))],pe);class wa extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CHECKBOX);L(this,"canvasRender",this.injector.createInstance(ut));L(this,"formulaInput",Xt)}}class Va extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CUSTOM);L(this,"formulaInput",Yt)}}const Ea="data-validation.formula-input";class Ma extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DATE);L(this,"formulaInput",Ea);L(this,"optionsInput",Ye.componentKey);L(this,"dropdown",rt)}}class Ra extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DECIMAL);L(this,"formulaInput",$e)}}const zt=4,ba=0,pt=4,Kt=4,ht=6,ze=6,Ce=14;function Oa(e,t){const a=B.FontCache.getTextSize(e,t),n=a.width+zt*2,{ba:i,bd:r}=a,s=i+r;return{width:n,height:s+ba*2,ba:i}}function mt(e,t,a,n){const i=Ce+ht*2,r=a-i,s=n-ze*2,d=e.map(c=>({layout:Oa(c,t),text:c}));let l;const u=[];d.forEach(c=>{const{layout:C}=c,{width:v,height:g}=C;!l||l.width+v+pt>r?(l={width:v,height:g,items:[{...c,left:0}]},u.push(l)):(l.items.push({...c,left:l.width+pt}),l.width=l.width+v+pt)});let p=0,m=0;return u.forEach((c,C)=>{m=Math.max(m,c.width),C===u.length-1?p+=c.height:p+=c.height+Kt}),{lines:u,totalHeight:p,contentWidth:r,contentHeight:s,cellAutoHeight:p+ze*2,calcAutoWidth:m+i}}const La=8;class Ta extends B.Shape{static drawWith(t,a){const{fontString:n,info:i,fill:r,color:s}=a,{layout:d,text:l}=i;t.save(),B.Rect.drawWith(t,{width:d.width,height:d.height,radius:La,fill:r||Ie}),t.translateWithPrecision(zt,d.ba),t.font=n,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var Pa=Object.defineProperty,ja=Object.getOwnPropertyDescriptor,Aa=(e,t,a,n)=>{for(var i=n>1?void 0:n?ja(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Pa(t,a,i),i},vt=(e,t)=>(a,n)=>t(a,n,e);const Fa=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 ft=class{constructor(e,t,a){L(this,"zIndex");L(this,"_dropdownInfoMap",new Map);this._commandService=e,this._renderManagerService=t,this._dataValidationModel=a}_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,i){const r=a-Ce+4;let s=4;switch(i){case o.VerticalAlign.MIDDLE:s=(n-Ce)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-Ce+4;break}e.save(),e.translateWithPrecision(t.startX+r,t.startY+s),e.fillStyle="#565656",e.fill(Fa),e.restore()}drawWith(e,t,a,n){var Z,G;const{primaryWithCoord:i,row:r,col:s,style:d,data:l,subUnitId:u}=t,p=i.isMergedMainCell?i.mergeInfo:i,m=l==null?void 0:l.fontRenderExtension,{leftOffset:c=0,rightOffset:C=0,topOffset:v=0,downOffset:g=0}=m||{},V=this._ensureMap(u),_=this._generateKey(r,s),w=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,r,s);if(!w)return;const y=this._dataValidationModel.getValidator(w.type);if(!y)return;const b={startX:p.startX+c,endX:p.endX-C,startY:p.startY+v,endY:p.endY-g},I=b.endX-b.startX,D=b.endY-b.startY,{cl:S}=d||{},R=(Z=typeof S=="object"?S==null?void 0:S.rgb:S)!=null?Z:"#000",A=B.getFontStyleString(d!=null?d:void 0),{vt:W,ht:F}=d||{},T=W!=null?W:o.VerticalAlign.MIDDLE,P=(G=E.getCellValueOrigin(l))!=null?G:"",x=y.parseCellValue(P),U=y.getListWithColorMap(w),$=mt(x,A,I,D);this._drawDownIcon(e,b,I,D,T),e.save(),e.translateWithPrecision(b.startX,b.startY),e.beginPath(),e.rect(0,0,I-Ce,D),e.clip(),e.translateWithPrecision(ht,ze);let q=0;switch(T){case o.VerticalAlign.MIDDLE:q=($.contentHeight-$.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:q=$.contentHeight-$.totalHeight;break}e.translateWithPrecision(0,q),$.lines.forEach((J,te)=>{e.save();const{width:ae,height:ie,items:le}=J;let oe=0;switch(F){case o.HorizontalAlign.RIGHT:oe=$.contentWidth-ae;break;case o.HorizontalAlign.CENTER:oe=($.contentWidth-ae)/2;break}e.translate(oe,te*(ie+Kt)),le.forEach(de=>{e.save(),e.translateWithPrecision(de.left,0),Ta.drawWith(e,{...A,info:de,color:R,fill:U[de.text]}),e.restore()}),e.restore()}),e.restore(),V.set(_,{left:b.startX,top:b.startY,width:$.contentWidth+ht+Ce,height:$.contentHeight+ze*2})}calcCellAutoHeight(e){var I;const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:u=0,downOffset:p=0}=s||{},m=t.isMergedMainCell?t.mergeInfo:t,c={startX:m.startX+d,endX:m.endX-l,startY:m.startY+u,endY:m.endY-p},C=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!C)return;const v=this._dataValidationModel.getValidator(C.type);if(!v)return;const g=c.endX-c.startX,V=c.endY-c.startY,_=(I=E.getCellValueOrigin(n))!=null?I:"",w=v.parseCellValue(_),y=B.getFontStyleString(a!=null?a:void 0);return mt(w,y,g,V).cellAutoHeight}calcCellAutoWidth(e){var I;const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:u=0,downOffset:p=0}=s||{},m=t.isMergedMainCell?t.mergeInfo:t,c={startX:m.startX+d,endX:m.endX-l,startY:m.startY+u,endY:m.endY-p},C=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!C)return;const v=this._dataValidationModel.getValidator(C.type);if(!v)return;const g=c.endX-c.startX,V=c.endY-c.startY,_=(I=E.getCellValueOrigin(n))!=null?I:"",w=v.parseCellValue(_),y=B.getFontStyleString(a!=null?a:void 0);return mt(w,y,g,V).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:i}=n,{x:r}=e;return r>=i-Ce&&r<=i}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=e,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Fe.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};ft=Aa([vt(0,o.ICommandService),vt(1,o.Inject(B.IRenderManagerService)),vt(2,o.Inject(E.SheetDataValidationModel))],ft);class xa extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST_MULTIPLE);L(this,"canvasRender",this.injector.createInstance(ft));L(this,"dropdown",Ue)}}var Na=Object.defineProperty,Ua=Object.getOwnPropertyDescriptor,Ba=(e,t,a,n)=>{for(var i=n>1?void 0:n?Ua(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Na(t,a,i),i},Ke=(e,t)=>(a,n)=>t(a,n,e);const De=4,Ge=4,ce=14,he=6,be=4,gt=8,ka="#565656",Gt=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 Wa(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:o.BooleanNumber.FALSE,bl:o.BooleanNumber.FALSE,ul:{s:o.BooleanNumber.FALSE},st:{s:o.BooleanNumber.FALSE},ol:{s:o.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function qt(e,t,a){const n=Wa(e,a),i=new o.DocumentDataModel(n),r=new B.DocumentViewModel(i);return{documentSkeleton:B.DocumentSkeleton.create(r,t),docModel:i,docViewModel:r}}function qe(e,t,a){const{documentSkeleton:n,docModel:i,docViewModel:r}=qt(e,t,a);return{documents:new B.Documents(`DOCUMENTS_${o.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:i,docViewModel:r}}function Zt(e,t,a,n,i,r,s=!0){let d=0;const l=s?be:0;switch(i){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(be,d);let u=0;switch(r){case o.HorizontalAlign.CENTER:u=(e-a)/2;break;case o.HorizontalAlign.RIGHT:u=e-a;break}return u=Math.max(he,u),{paddingLeft:u,paddingTop:d}}let St=class{constructor(e,t,a,n){L(this,"_dropdownInfoMap",new Map);L(this,"zIndex");this._localeService=e,this._commandService=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,i,r,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,u=a-ce;let p;switch(r){case o.VerticalAlign.MIDDLE:p=(n-Ge)/2;break;case o.VerticalAlign.BOTTOM:p=n-l-i-be+(i/2-Ge/2);break;default:p=d+be+(i/2-Ge/2);break}e.save(),e.translateWithPrecision(t.startX+u,t.startY+p),e.fillStyle="#565656",e.fill(Gt),e.restore()}drawWith(e,t,a){const{primaryWithCoord:n,row:i,col:r,style:s,data:d,subUnitId:l}=t,u=n.isMergedMainCell?n.mergeInfo:n,p=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,r);if(!p)return;const m=this._dataValidationModel.getValidator(p.type);if(!m)return;const c=d==null?void 0:d.fontRenderExtension,{leftOffset:C=0,rightOffset:v=0,topOffset:g=0,downOffset:V=0}=c||{};if(!p||!m||!m||m.id.indexOf(o.DataValidationType.LIST)!==0||!m.skipDefaultFontRender(p))return;const _={startX:u.startX+C,endX:u.endX-v,startY:u.startY+g,endY:u.endY-V},w=_.endX-_.startX,y=_.endY-_.startY,b=this._ensureMap(l),I=this._generateKey(i,r),D=m.getListWithColor(p),S=E.getCellValueOrigin(d),R=`${S!=null?S:""}`,A=D.find(x=>x.label===R);let{tb:W,vt:F,ht:T,pd:P}=s||{};if(W=W!=null?W:o.WrapStrategy.WRAP,F=F!=null?F:o.VerticalAlign.BOTTOM,T=T!=null?T:o.DEFAULT_STYLES.ht,P=P!=null?P:o.DEFAULT_STYLES.pd,p.renderMode===o.DataValidationRenderMode.ARROW){const{l:x=o.DEFAULT_STYLES.pd.l,t:U=o.DEFAULT_STYLES.pd.t,r:$=o.DEFAULT_STYLES.pd.r,b:q=o.DEFAULT_STYLES.pd.b}=P,Z=w-x-$-ce-4,{documentSkeleton:G,documents:J,docModel:te}=qe(R,this._localeService,s);W===o.WrapStrategy.WRAP&&te.updateDocumentDataPageSize(Math.max(Z,1)),G.calculate(),G.getActualSize();const ae=B.getDocsSkeletonPageSize(G),{height:ie,width:le}=ae,{paddingTop:oe,paddingLeft:de}=Zt(Z,y-U-q,le,ie,F,T,!0);this._drawDownIcon(e,_,w,y,ie,F,P),e.save(),e.translateWithPrecision(_.startX+x,_.startY+U),e.beginPath(),e.rect(0,0,w-x-$,y-U-q),e.clip(),e.translateWithPrecision(0,oe),e.save(),e.translateWithPrecision(De,0),e.beginPath(),e.rect(0,0,Z,ie),e.clip(),J.render(e),e.translateWithPrecision(de,0),e.restore(),e.restore(),b.set(I,{left:_.endX+x+a.rowHeaderWidth-ce,top:_.startY+U+a.columnHeaderHeight,width:ce,height:y-U-q})}else{e.save(),e.translateWithPrecision(_.startX,_.startY),e.beginPath(),e.rect(0,0,w,y),e.clip();const x=w-he*2-De-ce-4,{documentSkeleton:U,documents:$,docModel:q}=qe(R,this._localeService,s);W===o.WrapStrategy.WRAP&&q.updateDocumentDataPageSize(Math.max(x,1)),U.calculate();const Z=B.getDocsSkeletonPageSize(U),{height:G,width:J}=Z,{paddingTop:te,paddingLeft:ae}=Zt(x,y,J,G,F,T);e.translateWithPrecision(he,te);const ie=Math.max(w-he*2,1),le=G;B.Rect.drawWith(e,{width:ie,height:le,fill:(A==null?void 0:A.color)||Ie,radius:gt}),e.save(),e.translateWithPrecision(De,0),e.beginPath(),e.rect(0,0,x,G),e.clip(),e.translateWithPrecision(ae,0),$.render(e),e.restore(),e.translateWithPrecision(x+De+4,(G-Ge)/2),e.fillStyle=ka,e.fill(Gt),e.restore(),b.set(I,{left:_.startX+he+a.rowHeaderWidth,top:_.startY+te+a.columnHeaderHeight,width:ie,height:le})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:u=0,topOffset:p=0,downOffset:m=0}=d||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!c||c.renderMode===o.DataValidationRenderMode.TEXT)return;const C={startX:s.startX+l,endX:s.endX-u,startY:s.startY+p,endY:s.endY-m},v=C.endX-C.startX,g=E.getCellValueOrigin(n),V=`${g!=null?g:""}`;let{tb:_,pd:w}=a||{};const{t:y=o.DEFAULT_STYLES.pd.t,b=o.DEFAULT_STYLES.pd.b}=w!=null?w:{};if(_=_!=null?_:o.WrapStrategy.WRAP,c.renderMode===o.DataValidationRenderMode.ARROW){const I=v-ce,{documentSkeleton:D,docModel:S}=qe(V,this._localeService,a);_===o.WrapStrategy.WRAP&&S.updateDocumentDataPageSize(Math.max(I,1)),D.calculate(),D.getActualSize();const R=B.getDocsSkeletonPageSize(D),{height:A}=R;return A+y+b+be*2}else{const I=v-he*2-De-ce,{documentSkeleton:D,docModel:S}=qt(V,this._localeService,a);_===o.WrapStrategy.WRAP&&S.updateDocumentDataPageSize(Math.max(I,1)),D.calculate();const R=B.getDocsSkeletonPageSize(D),{height:A}=R;return A+be*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:u=0,topOffset:p=0,downOffset:m=0}=d||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!c||c.renderMode===o.DataValidationRenderMode.TEXT)return;const C={startX:s.startX+l,endX:s.endX-u,startY:s.startY+p,endY:s.endY-m},v=C.endX-C.startX,g=E.getCellValueOrigin(n),V=`${g!=null?g:""}`;let{tb:_,pd:w}=a||{};const{l:y=o.DEFAULT_STYLES.pd.l,r:b=o.DEFAULT_STYLES.pd.r}=w!=null?w:{};_=_!=null?_:o.WrapStrategy.WRAP;let I=he*2+ce;switch(c.renderMode){case o.DataValidationRenderMode.ARROW:I=ce+he*2+b+y;break;case o.DataValidationRenderMode.CUSTOM:I=ce+he*2+De*2+b+y+gt/2+1;break;default:I=ce+he*2+De*2+b+y+gt/2+1}const D=v-I,{documentSkeleton:S,docModel:R}=qe(V,this._localeService,a);return _===o.WrapStrategy.WRAP&&R.updateDocumentDataPageSize(Math.max(D,1)),S.calculate(),S.getActualSize(),B.getDocsSkeletonPageSize(S).width+I}isHit(e,t){const{subUnitId:a,row:n,col:i}=t,s=this._ensureMap(a).get(this._generateKey(n,i)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,i);if(!d||!s||d.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:u,width:p,height:m}=s,{x:c,y:C}=e;return c>=u&&c<=u+p&&C>=l&&C<=l+m}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=e,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Fe.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};St=Ba([Ke(0,o.Inject(o.LocaleService)),Ke(1,o.ICommandService),Ke(2,o.Inject(B.IRenderManagerService)),Ke(3,o.Inject(E.SheetDataValidationModel))],St);class $a extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST);L(this,"canvasRender",this.injector.createInstance(St));L(this,"dropdown",Ue);L(this,"optionsInput",He.componentKey);L(this,"formulaInput",ct)}}class Ha extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.TEXT_LENGTH);L(this,"formulaInput",$e)}}class Ya extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.WHOLE);L(this,"formulaInput",$e)}}var Xa=Object.defineProperty,za=Object.getOwnPropertyDescriptor,Ka=(e,t,a,n)=>{for(var i=n>1?void 0:n?za(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Xa(t,a,i),i},_t=(e,t)=>(a,n)=>t(a,n,e);let Oe=class extends o.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[xt,Mt],[nt,Un],[Pt,En],[Ue,Ln],[rt,un],[He.componentKey,He],[Ye.componentKey,Ye],...ma].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Ra,Ya,Ha,Ma,wa,$a,xa,Va].forEach(e=>{const t=this._injector.createInstance(e),a=this._dataValidatorRegistryService.getValidatorItem(t.id);a&&(a.formulaInput=t.formulaInput,a.canvasRender=t.canvasRender,a.dropdown=t.dropdown,a.optionsInput=t.optionsInput)})}};Oe=Ka([_t(0,o.Inject(o.Injector)),_t(1,o.Inject(z.ComponentManager)),_t(2,o.Inject(Q.DataValidatorRegistryService))],Oe);var Ga=Object.defineProperty,qa=Object.getOwnPropertyDescriptor,Za=(e,t,a,n)=>{for(var i=n>1?void 0:n?qa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Ga(t,a,i),i},It=(e,t)=>(a,n)=>t(a,n,e);const Ja="SHEET_DATA_VALIDATION_UI_PLUGIN";Y.UniverSheetsDataValidationUIPlugin=(Ze=class extends o.Plugin{constructor(t=Ft,a,n,i){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(it,s)}onStarting(){[[ue],[fe],[Pe],[Ve],[Re],[Me],[Ee],[Te],[Oe]].forEach(t=>{this._injector.add(t)}),[Be,Fe,At,at,_e,jt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(Te),this._injector.get(Pe),this._injector.get(B.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[We])}onRendered(){this._injector.get(Oe),this._injector.get(Re)}onSteady(){this._injector.get(Ve)}},L(Ze,"pluginName",Ja),L(Ze,"type",o.UniverInstanceType.UNIVER_SHEET),Ze),Y.UniverSheetsDataValidationUIPlugin=Za([It(1,o.Inject(o.Injector)),It(2,o.ICommandService),It(3,o.IConfigService)],Y.UniverSheetsDataValidationUIPlugin);var Qa=Object.defineProperty,ei=Object.getOwnPropertyDescriptor,ti=(e,t,a,n)=>{for(var i=n>1?void 0:n?ei(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Qa(t,a,i),i},Ct=(e,t)=>(a,n)=>t(a,n,e);const ni="SHEET_DATA_VALIDATION_UI_PLUGIN";Y.UniverSheetsDataValidationMobileUIPlugin=(Je=class extends o.Plugin{constructor(t=Ft,a,n,i){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(it,s)}onStarting(){[[ue],[fe],[Pe],[Ve],[Re],[Me],[Ee],[Oe]].forEach(t=>{this._injector.add(t)}),[Be,Fe,At,at,_e,jt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(B.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[We])}onRendered(){this._injector.get(Oe),this._injector.get(Re)}onSteady(){this._injector.get(Ve)}},L(Je,"pluginName",ni),L(Je,"type",o.UniverInstanceType.UNIVER_SHEET),Je),Y.UniverSheetsDataValidationMobileUIPlugin=ti([Ct(1,o.Inject(o.Injector)),Ct(2,o.ICommandService),Ct(3,o.IConfigService)],Y.UniverSheetsDataValidationMobileUIPlugin),Y.DATE_DROPDOWN_KEY=rt,Y.LIST_DROPDOWN_KEY=Ue,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-data-validation-ui",
3
- "version": "0.5.0-nightly.202411221606",
3
+ "version": "0.5.0-nightly.202411230627",
4
4
  "private": false,
5
5
  "description": "Data validation UI for Univer Sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -57,18 +57,18 @@
57
57
  "@flatten-js/interval-tree": "^1.1.3",
58
58
  "@univerjs/icons": "^0.2.7",
59
59
  "clsx": "^2.1.1",
60
- "@univerjs/core": "0.5.0-nightly.202411221606",
61
- "@univerjs/docs": "0.5.0-nightly.202411221606",
62
- "@univerjs/design": "0.5.0-nightly.202411221606",
63
- "@univerjs/engine-render": "0.5.0-nightly.202411221606",
64
- "@univerjs/engine-formula": "0.5.0-nightly.202411221606",
65
- "@univerjs/sheets": "0.5.0-nightly.202411221606",
66
- "@univerjs/data-validation": "0.5.0-nightly.202411221606",
67
- "@univerjs/sheets-numfmt": "0.5.0-nightly.202411221606",
68
- "@univerjs/sheets-formula-ui": "0.5.0-nightly.202411221606",
69
- "@univerjs/ui": "0.5.0-nightly.202411221606",
70
- "@univerjs/sheets-data-validation": "0.5.0-nightly.202411221606",
71
- "@univerjs/sheets-ui": "0.5.0-nightly.202411221606"
60
+ "@univerjs/data-validation": "0.5.0-nightly.202411230627",
61
+ "@univerjs/core": "0.5.0-nightly.202411230627",
62
+ "@univerjs/design": "0.5.0-nightly.202411230627",
63
+ "@univerjs/docs": "0.5.0-nightly.202411230627",
64
+ "@univerjs/engine-render": "0.5.0-nightly.202411230627",
65
+ "@univerjs/sheets": "0.5.0-nightly.202411230627",
66
+ "@univerjs/engine-formula": "0.5.0-nightly.202411230627",
67
+ "@univerjs/sheets-formula-ui": "0.5.0-nightly.202411230627",
68
+ "@univerjs/sheets-numfmt": "0.5.0-nightly.202411230627",
69
+ "@univerjs/sheets-ui": "0.5.0-nightly.202411230627",
70
+ "@univerjs/ui": "0.5.0-nightly.202411230627",
71
+ "@univerjs/sheets-data-validation": "0.5.0-nightly.202411230627"
72
72
  },
73
73
  "devDependencies": {
74
74
  "less": "^4.2.0",