@univerjs/sheets-data-validation-ui 0.6.10-nightly.202504141607 → 0.6.10-nightly.202504161609

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var Kt=Object.defineProperty;var Gt=(e,t,a)=>t in e?Kt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var P=(e,t,a)=>Gt(e,typeof t!="symbol"?t+"":t,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),r=require("@univerjs/core"),b=require("@univerjs/design"),U=require("@univerjs/engine-render"),X=require("@univerjs/sheets"),M=require("@univerjs/sheets-data-validation"),qt=require("@univerjs/sheets-numfmt"),$=require("@univerjs/sheets-ui"),f=require("@univerjs/ui"),R=require("react"),Q=require("@univerjs/data-validation"),Zt=require("@univerjs/docs"),ie=require("rxjs"),ct=require("@univerjs/engine-formula"),mt=require("@univerjs/sheets-formula-ui");var Jt=Object.getOwnPropertyDescriptor,Qt=(e,t,a,n)=>{for(var o=n>1?void 0:n?Jt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},ye=(e,t)=>(a,n)=>t(a,n,e);let Ae=class extends r.Disposable{constructor(e,t,a,n,o,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=o,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(X.VALIDATE_CELL,{handler:async(e,t,a)=>{const n=await e,{row:o,col:i,unitId:s,subUnitId:l}=t,d=this._dataValidationModel.getRuleIdByLocation(s,l,o,i),u=d?this._dataValidationModel.getRuleById(s,l,d):void 0;if(n===!1)return a(Promise.resolve(!1));if(!u||u.errorStyle!==r.DataValidationErrorStyle.STOP)return a(Promise.resolve(!0));const p=this._dataValidatorRegistryService.getValidatorItem(u.type);return!p||await this._sheetsDataValidationValidatorService.validatorCell(s,l,o,i)===r.DataValidationStatus.VALID?a(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:p.getRuleFinalError(u,{row:o,col:i,unitId:s,subUnitId:l})},footer:{title:R.createElement(b.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(!1)))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:R.createElement(b.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Ae=Qt([ye(0,r.Inject(X.SheetInterceptorService)),ye(1,r.Inject(M.SheetDataValidationModel)),ye(2,r.Inject(Q.DataValidatorRegistryService)),ye(3,f.IDialogService),ye(4,r.Inject(r.LocaleService)),ye(5,r.Inject(M.SheetsDataValidationValidatorService))],Ae);const en="univer-dv-date-dropdown",tn="univer-dv-date-dropdown-btns",Ct={dvDateDropdown:en,dvDateDropdownBtns:tn},nn=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return r.dayjs(r.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=r.dayjs(e);if(t.isValid())return t};function an(e){var _;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:i,unitId:s,subUnitId:l,workbook:d}=t,u=f.useDependency(r.ICommandService),p=f.useDependency(Ae),g=n.getCell(o,i),c=M.getCellValueOrigin(n.getCellRaw(o,i)),y=nn(c),[m,w]=R.useState(y),V=m&&m.isValid()?m:r.dayjs(),v=f.useDependency(r.LocaleService),S=f.useDependency(M.SheetDataValidationModel),I=S.getRuleByLocation(s,l,o,i);if(!I)return null;const T=S.getValidator(I.type);if(!g||!T)return;const C=!!((_=I.bizInfo)!=null&&_.showTime),D=async()=>{var N,B,H;if(!V)return;const F=V.format(C?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),W=(N=r.numfmt.parseDate(F))==null?void 0:N.v,A=d.getStyles().getStyleByCell(g),j=(H=(B=A==null?void 0:A.n)==null?void 0:B.pattern)!=null?H:"",x=qt.getPatternType(j);I.errorStyle!==r.DataValidationErrorStyle.STOP||await T.validator({value:W,unitId:s,subUnitId:l,row:o,column:i,worksheet:n,workbook:d,interceptValue:F.replace("Z","").replace("T"," "),t:r.CellValueType.NUMBER},I)?(a(),await u.executeCommand($.SetCellEditVisibleOperation.id,{visible:!1,eventType:U.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),await u.executeCommand(X.SetRangeValuesCommand.id,{unitId:s,subUnitId:l,range:{startColumn:i,endColumn:i,startRow:o,endRow:o},value:{v:W,t:2,p:null,f:null,si:null,s:{n:{pattern:C?x==="datetime"?j:"yyyy-MM-dd hh:mm:ss":x==="date"?j:"yyyy-MM-dd"}}}})):p.showReject(T.getRuleFinalError(I,{row:o,col:i,unitId:s,subUnitId:l}))};return h.jsxs("div",{className:Ct.dvDateDropdown,children:[h.jsx(b.DatePanel,{defaultValue:V,pickerValue:V,showTime:C||void 0,onSelect:async L=>{w(L)},onPanelChange:L=>{w(L)},disabledDate:L=>!r.numfmt.parseDate(L.format("YYYY-MM-DD"))}),h.jsx("div",{className:Ct.dvDateDropdownBtns,children:h.jsx(b.Button,{size:"small",type:"primary",onClick:D,disabled:!V.isValid(),children:v.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 o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},le.apply(this,arguments)},on=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 o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(a[n[o]]=e[n[o]]);return a},ve=R.forwardRef(function(e,t){var a=e.icon,n=e.id,o=e.className,i=e.extend,s=on(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),d=R.useRef("_".concat(ln()));return Mt(a,"".concat(n),{defIds:a.defIds,idSuffix:d.current},le({ref:t,className:l},s),i)});function Mt(e,t,a,n,o){return R.createElement(e.tag,le(le({key:t},rn(e,a,o)),n),(sn(e,a).children||[]).map(function(i,s){return Mt(i,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,o)}))}function rn(e,t,a){var n=le({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],l=i[1];s==="mask"&&typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var o=t.defIds;return!o||o.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],l=i[1];typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function sn(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?le(le({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?le(le({},o),{attrs:le(le({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):e}function ln(){return Math.random().toString(36).substring(2,8)}ve.displayName="UniverIcon";var dn={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"}}]},bt=R.forwardRef(function(e,t){return R.createElement(ve,Object.assign({},e,{id:"check-mark-single",ref:t,icon:dn}))});bt.displayName="CheckMarkSingle";var cn={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"}}]},Tt=R.forwardRef(function(e,t){return R.createElement(ve,Object.assign({},e,{id:"data-validation-single",ref:t,icon:cn}))});Tt.displayName="DataValidationSingle";var un={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"}}]},vt=R.forwardRef(function(e,t){return R.createElement(ve,Object.assign({},e,{id:"delete-single",ref:t,icon:un}))});vt.displayName="DeleteSingle";var hn={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"}}]},Lt=R.forwardRef(function(e,t){return R.createElement(ve,Object.assign({},e,{id:"increase-single",ref:t,icon:hn}))});Lt.displayName="IncreaseSingle";var pn={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"}}]},Ot=R.forwardRef(function(e,t){return R.createElement(ve,Object.assign({},e,{id:"more-down-single",ref:t,icon:pn}))});Ot.displayName="MoreDownSingle";var gn={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"}}]},Pt=R.forwardRef(function(e,t){return R.createElement(ve,Object.assign({},e,{id:"more-up-single",ref:t,icon:gn}))});Pt.displayName="MoreUpSingle";var mn={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"}}]}]},At=R.forwardRef(function(e,t){return R.createElement(ve,Object.assign({},e,{id:"sequence-single",ref:t,icon:mn}))});At.displayName="SequenceSingle";var vn=Object.getOwnPropertyDescriptor,fn=(e,t,a,n)=>{for(var o=n>1?void 0:n?vn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Dt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends r.Disposable{constructor(t,a){super();P(this,"_open$",new ie.BehaviorSubject(!1));P(this,"open$",this._open$.pipe(ie.distinctUntilChanged()));P(this,"_activeRule");P(this,"_activeRule$",new ie.BehaviorSubject(void 0));P(this,"activeRule$",this._activeRule$.asObservable());P(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).pipe(ie.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===He&&(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=r.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ue=fn([Dt(0,r.IUniverInstanceService),Dt(1,f.ISidebarService)],ue);function Sn(){const e=f.useDependency(me),t=f.useObservable(e.activeDropdown$,e.activeDropdown),a=f.useDependency(f.ComponentManager);if(!t)return null;const{location:n,componentKey:o}=t,i=a.get(o),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!i)return null;const l=()=>{e.hideDropdown()};return h.jsx(i,{location:n,hideFn:l},s)}const jt="sheet.ui.dropdown";var _n=Object.getOwnPropertyDescriptor,In=(e,t,a,n)=>{for(var o=n>1?void 0:n?_n(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},fe=(e,t)=>(a,n)=>t(a,n,e);let me=class extends r.Disposable{constructor(t,a,n,o,i,s,l){super();P(this,"_activeDropdown");P(this,"_activeDropdown$",new ie.Subject);P(this,"_currentPopup",null);P(this,"activeDropdown$",this._activeDropdown$.asObservable());P(this,"_zenVisible",!1);this._canvasPopupManagerService=t,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=o,this._renderManagerService=i,this._dataValidationModel=s,this._sheetsSelectionsService=l,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,o){const i=t?this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=a?i.getSheetBySheetId(a):i.getActiveSheet();if(!s)return;const l=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,o);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);return d==null?void 0:d.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:o,col:i,unitId:s,subUnitId:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const d=this._renderManagerService.getRenderById(r.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),u=this._canvasPopupManagerService.attachPopupToCell(o,i,{componentKey:jt,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[d==null?void 0:d.engine.getCanvasElement()].filter(Boolean)},s,l);if(!u)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const p=new r.DisposableCollection;p.add(u),p.add({dispose:()=>{var g,c;(c=(g=this._activeDropdown)==null?void 0:g.onHide)==null||c.call(g)}}),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,o,i){const s=this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET);if(!s)return;const l=s.getSheetBySheetId(a);if(!l)return;const d=this._dataValidationModel.getRuleByLocation(s.getUnitId(),l.getSheetId(),n,o);if(!d)return;const u=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!u||!u.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:l,row:n,col:o,unitId:t,subUnitId:a},componentKey:u.dropdown,onHide:i})}};me=In([fe(0,r.Inject($.SheetCanvasPopManagerService)),fe(1,r.IUniverInstanceService),fe(2,r.Inject(Q.DataValidatorRegistryService)),fe(3,f.IZenZoneService),fe(4,U.IRenderManagerService),fe(5,r.Inject(M.SheetDataValidationModel)),fe(6,r.Inject(X.SheetsSelectionsService))],me);const He="DataValidationPanel",De={id:"data-validation.operation.open-validation-panel",type:r.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,o=e.get(ue),i=e.get(Q.DataValidationModel),s=e.get(r.IUniverInstanceService),l=e.get(f.ISidebarService),d=X.getSheetCommandTarget(s);if(!d)return!1;const{unitId:u,subUnitId:p}=d,g=a?i.getRuleById(u,p,a):void 0;o.open(),o.setActiveRule(g&&{unitId:u,subUnitId:p,rule:g});const c=l.open({id:He,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:He},width:312,onClose:()=>o.close()});return o.setCloseDisposable(c),!0}},ft={id:"data-validation.operation.close-validation-panel",type:r.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},Ft={id:"data-validation.operation.toggle-validation-panel",type:r.CommandType.OPERATION,handler(e){const t=e.get(r.ICommandService),a=e.get(ue);return a.open(),a.isOpen?t.executeCommand(ft.id):t.executeCommand(De.id),!0}},qe={type:r.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(me),{unitId:n,subUnitId:o,row:i,column:s}=t,l=a.activeDropdown,d=l==null?void 0:l.location;return d&&d.unitId===n&&d.subUnitId===o&&d.row===i&&d.col===s||a.showDataValidationDropdown(n,o,i,s),!0}},xt={type:r.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(me).hideDropdown(),!0):!1}},Ce="#ECECEC",St="sheets-data-validation-ui.config",Ye={},Cn="univer-dv-list-dropdown",Dn="univer-dv-list-dropdown-title",yn="univer-dv-list-dropdown-list",Vn="univer-dv-list-dropdown-list-container",Rn="univer-dv-list-dropdown-selected-icon",wn="univer-dv-list-dropdown-item-container",En="univer-dv-list-dropdown-item",Mn="univer-dv-list-dropdown-split",bn="univer-dv-list-dropdown-edit",pe={dvListDropdown:Cn,dvListDropdownTitle:Dn,dvListDropdownList:yn,dvListDropdownListContainer:Vn,dvListDropdownSelectedIcon:Rn,dvListDropdownItemContainer:wn,dvListDropdownItem:En,dvListDropdownSplit:Mn,dvListDropdownEdit:bn},Tn=e=>{var C,D;const{value:t,onChange:a,multiple:n,options:o,title:i,onEdit:s,style:l,filter:d,location:u}=e,p=f.useDependency(r.LocaleService),g=f.useDependency(r.IConfigService),c=d==null?void 0:d.toLowerCase(),{row:y,col:m,unitId:w,subUnitId:V}=u,v=o.filter(_=>c?_.label.toLowerCase().includes(c):!0),S=(D=(C=g.getConfig(St))==null?void 0:C.showEditOnDropdown)!=null?D:!0,I=f.useDependency(X.SheetPermissionCheckController),T=R.useMemo(()=>I.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission]},[{startColumn:m,startRow:y,endColumn:m,endRow:y}],w,V),[I,m,y,w,V]);return h.jsxs("div",{className:pe.dvListDropdown,style:l,children:[h.jsx("div",{className:pe.dvListDropdownTitle,children:i}),h.jsx("div",{className:pe.dvListDropdownList,children:h.jsx(b.Scrollbar,{children:h.jsx("div",{className:pe.dvListDropdownListContainer,children:v.map((_,L)=>{const F=t.indexOf(_.value)>-1,W=()=>{let j;F?j=new Set(t.filter(N=>N!==_.value)):j=new Set(n?[...t,_.value]:[_.value]);const x=[];o.forEach(N=>{j.has(N.value)&&x.push(N.value)}),a(x)},A=_.label.toLocaleLowerCase().indexOf(c);return h.jsxs("div",{className:pe.dvListDropdownItemContainer,onClick:W,children:[h.jsx("div",{className:pe.dvListDropdownItem,style:{background:_.color||Ce},children:c&&_.label.toLowerCase().includes(c)?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:_.label.substring(0,A)}),h.jsx("span",{style:{fontWeight:"bold"},children:_.label.substring(A,A+c.length)}),h.jsx("span",{children:_.label.substring(A+c.length)})]}):_.label}),h.jsx("div",{className:pe.dvListDropdownSelectedIcon,children:F?h.jsx(bt,{}):null})]},L)})})},d)}),S&&T?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:pe.dvListDropdownSplit}),h.jsx("div",{className:pe.dvListDropdownEdit,children:h.jsx("a",{onClick:s,children:p.t("dataValidation.list.edit")})})]}):null]})};function Ln(e){var B,H,G,q;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:i,unitId:s,subUnitId:l}=t,d=f.useDependency(Q.DataValidationModel),[u,p]=R.useState(""),g=f.useDependency(r.ICommandService),c=f.useDependency(r.LocaleService),[y,m]=R.useState(""),w=f.useDependency($.IEditorBridgeService),V=f.useDependency(r.IUniverInstanceService),v=R.useMemo(()=>d.ruleChange$.pipe(ie.debounceTime(16)),[]),S=f.useDependency(M.SheetDataValidationModel);f.useObservable(v);const I=f.RectPopup.useContext(),T=((H=(B=I.current)==null?void 0:B.right)!=null?H:0)-((q=(G=I.current)==null?void 0:G.left)!=null?q:0);if(R.useEffect(()=>{const K=g.onCommandExecuted(Z=>{var ee,te;if(Z.id===Zt.RichTextEditingMutation.id){const ne=Z.params,{unitId:re}=ne,oe=V.getUnit(re,r.UniverInstanceType.UNIVER_DOC);if(!oe||!w.isVisible().visible)return;const se=r.BuildTextUtils.transform.getPlainText((te=(ee=oe.getSnapshot().body)==null?void 0:ee.dataStream)!=null?te:"");p(se)}});return()=>{K.dispose()}},[g,w,V]),!n)return null;const C=S.getRuleByLocation(s,l,o,i);if(!C)return null;const D=S.getValidator(C.type);if(!D)return null;const _=n.getCell(o,i),L=(C==null?void 0:C.renderMode)===r.DataValidationRenderMode.CUSTOM||(C==null?void 0:C.renderMode)===void 0;if(!_||!C||!D||D.id.indexOf(r.DataValidationType.LIST)!==0)return;const F=C.type===r.DataValidationType.LIST_MULTIPLE,W=D.getListWithColor(C,s,l),A=y||M.getDataValidationCellValue(n.getCellRaw(o,i)),j=M.deserializeListOptions(A),x=()=>{g.executeCommand(De.id,{ruleId:C.uid}),a()},N=W.map(K=>({label:K.label,value:K.label,color:L||K.color?K.color:"transparent"}));return h.jsx(Tn,{style:{minWidth:T,maxWidth:Math.max(T,200)},title:F?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:j,multiple:F,onChange:async K=>{const Z=M.serializeListOptions(K),ee={unitId:s,subUnitId:l,range:{startColumn:i,endColumn:i,startRow:o,endRow:o},value:{v:Z,p:null,f:null,si:null}};w.isVisible()&&g.executeCommand($.SetCellEditVisibleOperation.id,{visible:!1,eventType:U.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),m(Z),F||a(),w.isVisible().visible&&await g.executeCommand($.SetCellEditVisibleOperation.id,{visible:!1,eventType:U.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),g.executeCommand(X.SetRangeValuesCommand.id,ee)},options:N,onEdit:x,filter:u,location:t})}const On="univer-data-validation-options-button",Pn="univer-data-validation-options-button-icon",et={dataValidationOptionsButton:On,dataValidationOptionsButtonIcon:Pn};function An(e){var u;const t=f.useDependency(r.LocaleService),a=f.useDependency(f.ComponentManager),{value:n,onChange:o,extraComponent:i}=e,[s,l]=R.useState(!1),d=i?a.get(i):null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:et.dataValidationOptionsButton,onClick:()=>l(!s),children:[t.t("dataValidation.panel.options"),s?h.jsx(Pt,{className:et.dataValidationOptionsButtonIcon}):h.jsx(Ot,{className:et.dataValidationOptionsButtonIcon})]}),s&&h.jsxs(h.Fragment,{children:[d?h.jsx(d,{value:n,onChange:o}):null,h.jsx(b.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:h.jsxs(b.RadioGroup,{value:`${(u=n.errorStyle)!=null?u:r.DataValidationErrorStyle.WARNING}`,onChange:p=>o({...n,errorStyle:+p}),children:[h.jsx(b.Radio,{value:`${r.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),h.jsx(b.Radio,{value:`${r.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),h.jsx(b.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:h.jsx(b.Checkbox,{checked:n.showErrorMessage,onChange:()=>o({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?h.jsx(b.FormLayout,{children:h.jsx(b.Input,{value:n.error,onChange:p=>o({...n,error:p})})}):null]})]})}const jn="univer-data-validation-detail",Fn="univer-data-validation-detail-form-item",xn="univer-data-validation-detail-buttons",Un="univer-data-validation-detail-button",Ve={dataValidationDetail:jn,dataValidationDetailFormItem:Fn,dataValidationDetailButtons:xn,dataValidationDetailButton:Un},kn=e=>r.debounce(async(t,a,n,o)=>{const i=await e.executeCommand(t,a,n);o==null||o(i)},1e3);function Nn(e,t,a){var n,o,i,s;return t?((o=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:o.getSheetId())||"":((s=(i=e.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Bn(){var se;const[e,t]=R.useState(0),a=f.useDependency(ue),n=f.useObservable(a.activeRule$,a.activeRule),{unitId:o,subUnitId:i,rule:s}=n||{},l=s.uid,d=f.useDependency(Q.DataValidatorRegistryService),u=f.useDependency(r.IUniverInstanceService),p=f.useDependency(f.ComponentManager),g=f.useDependency(r.ICommandService),c=f.useDependency(Q.DataValidationModel),y=f.useDependency(r.LocaleService),[m,w]=R.useState(s),V=d.getValidatorItem(m.type),[v,S]=R.useState(!1),I=d.getValidatorsByScope(Q.DataValidatorRegistryScope.SHEET),[T,C]=R.useState(()=>m.ranges.map(O=>({unitId:"",sheetId:"",range:O}))),D=R.useMemo(()=>kn(g),[g]),[_,L]=R.useState(!1),[F,W]=R.useState(!1),A=R.useRef(null),j=f.useDependency(X.SheetsSelectionsService);if(R.useEffect(()=>()=>{const O=j.getCurrentLastSelection();O&&j.setSelections([O])},[j]),R.useEffect(()=>{g.onCommandExecuted(O=>{(O.id===r.UndoCommand.id||O.id===r.RedoCommand.id)&&setTimeout(()=>{const E=c.getRuleById(o,i,l);t(k=>k+1),E&&(w(E),C(E.ranges.map(k=>({unitId:"",sheetId:"",range:k}))))},20)})},[g,c,l,i,o]),!V)return null;const x=V.operators,N=V.operatorNames,B=m.operator?Q.TWO_FORMULA_OPERATOR_COUNT.includes(m.operator):!1,H=()=>{var O,E,k;(E=(O=A.current)==null?void 0:O.editor)!=null&&E.isFocus()&&G((k=A.current)==null?void 0:k.getValue()),!(!m.ranges.length||_)&&(V.validatorFormula(m,o,i).success?a.setActiveRule(null):S(!0))},G=f.useEvent(O=>{const E=O.split(",").filter(Boolean).map(ct.deserializeRangeWithSheet).map(z=>{const ge=z.sheetName;if(ge){const zt=Nn(u,z.unitId,ge);return{...z,sheetId:zt}}return{...z,sheetId:""}});if(r.isUnitRangesEqual(E,T))return;C(E);const k=E.filter(z=>(!z.unitId||z.unitId===o)&&(!z.sheetId||z.sheetId===i)).map(z=>z.range);if(w({...m,ranges:k}),k.length===0)return;const Y={unitId:o,subUnitId:i,ruleId:l,ranges:k};D(M.UpdateSheetDataValidationRangeCommand.id,Y)}),q=O=>{if(r.shallowEqual(O,Q.getRuleSetting(m)))return;w({...m,...O});const E={unitId:o,subUnitId:i,ruleId:l,setting:O};D(M.UpdateSheetDataValidationSettingCommand.id,E,void 0)},K=async()=>{await g.executeCommand(M.RemoveSheetDataValidationCommand.id,{ruleId:l,unitId:o,subUnitId:i}),a.setActiveRule(null)},Z={type:m.type,operator:m.operator,formula1:m.formula1,formula2:m.formula2,allowBlank:m.allowBlank},ee=O=>{const E=d.getValidatorItem(O);if(!E)return;const k=E.operators,Y=c.getRuleById(o,i,l),z=O===(Y==null?void 0:Y.type)||O.includes("list")&&(Y!=null&&Y.type.includes("list"))?{...Y,type:O}:{...m,type:O,operator:k[0],formula1:void 0,formula2:void 0};w(z),g.executeCommand(M.UpdateSheetDataValidationSettingCommand.id,{unitId:o,subUnitId:i,ruleId:m.uid,setting:Q.getRuleSetting(z)})},te=p.get(V.formulaInput),ne=R.useMemo(()=>T.map(O=>ct.serializeRange(O.range)).join(","),[]),re=Q.getRuleOptions(m),oe=O=>{r.shallowEqual(O,Q.getRuleOptions(m))||(w({...m,...O}),D(M.UpdateSheetDataValidationOptionsCommand.id,{unitId:o,subUnitId:i,ruleId:l,options:O}))};return h.jsxs("div",{className:Ve.dataValidationDetail,children:[h.jsx(b.FormLayout,{label:y.t("dataValidation.panel.range"),error:!m.ranges.length||_?y.t("dataValidation.panel.rangeError"):"",children:h.jsx(mt.RangeSelector,{selectorRef:A,unitId:o,subUnitId:i,initialValue:ne,onChange:(O,E)=>{var k;!F&&((k=A.current)!=null&&k.verify())&&G(E)},onFocusChange:(O,E)=>{var k;W(O),!O&&E&&((k=A.current)!=null&&k.verify())&&G(E)},onVerify:O=>L(!O)})}),h.jsx(b.FormLayout,{label:y.t("dataValidation.panel.type"),children:h.jsx(b.Select,{options:I==null?void 0:I.map(O=>({label:y.t(O.title),value:O.id})),value:m.type,onChange:ee,className:Ve.dataValidationDetailFormItem})}),x!=null&&x.length?h.jsx(b.FormLayout,{label:y.t("dataValidation.panel.operator"),children:h.jsx(b.Select,{options:x.map((O,E)=>({value:`${O}`,label:N[E]})),value:`${m.operator}`,onChange:O=>{q({...Z,operator:O})},className:Ve.dataValidationDetailFormItem})}):null,te?h.jsx(b.FormLayout,{children:h.jsx(te,{isTwoFormula:B,value:{formula1:m.formula1,formula2:m.formula2},onChange:O=>{q({...Z,...O})},showError:v,validResult:V.validatorFormula(m,o,i),unitId:o,subUnitId:i,ruleId:l},e+m.type)}):null,h.jsx(b.FormLayout,{children:h.jsx(b.Checkbox,{checked:(se=m.allowBlank)!=null?se:!0,onChange:()=>{var O;return q({...Z,allowBlank:!((O=m.allowBlank)==null||O)})},children:y.t("dataValidation.panel.allowBlank")})}),h.jsx(An,{value:re,onChange:oe,extraComponent:V.optionsInput}),h.jsxs("div",{className:Ve.dataValidationDetailButtons,children:[h.jsx(b.Button,{className:Ve.dataValidationDetailButton,onClick:K,children:y.t("dataValidation.panel.removeRule")}),h.jsx(b.Button,{className:Ve.dataValidationDetailButton,type:"primary",onClick:H,children:y.t("dataValidation.panel.done")})]})]})}const Wn="univer-data-validation-item-container",$n="univer-data-validation-item-title",Hn="univer-data-validation-item-content",Yn="univer-data-validation-item-icon",Fe={dataValidationItemContainer:Wn,dataValidationItemTitle:$n,dataValidationItemContent:Hn,dataValidationItemIcon:Yn},Xn=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:o,disable:i}=e,s=f.useDependency(Q.DataValidatorRegistryService),l=f.useDependency(r.ICommandService),d=f.useDependency($.IMarkSelectionService),u=s.getValidatorItem(t.type),p=R.useRef(void 0),[g,c]=R.useState(!1),y=f.useDependency(r.ThemeService),m=f.useObservable(y.currentTheme$),w=R.useMemo(()=>{var I;const v=(I=m==null?void 0:m.loopColor2)!=null?I:"#49B811",S=new r.ColorKit(v).toRgb();return{fill:`rgba(${S.r}, ${S.g}, ${S.b}, 0.1)`,stroke:v}},[m]),V=v=>{l.executeCommand(M.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:o}),v.stopPropagation()};return R.useEffect(()=>()=>{var v;p.current&&((v=p.current)==null||v.forEach(S=>{S&&d.removeShape(S)}))},[d]),h.jsxs("div",{className:Fe.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{i||(c(!0),p.current=t.ranges.map(v=>d.addShape({range:v,style:w,primary:null})))},onMouseLeave:()=>{var v;c(!1),(v=p.current)==null||v.forEach(S=>{S&&d.removeShape(S)}),p.current=void 0},children:[h.jsx("div",{className:Fe.dataValidationItemTitle,children:u==null?void 0:u.generateRuleName(t)}),h.jsx("div",{className:Fe.dataValidationItemContent,children:t.ranges.map(v=>ct.serializeRange(v)).join(",")}),g?h.jsx("div",{className:Fe.dataValidationItemIcon,onClick:V,children:h.jsx(vt,{})}):null]})},zn="univer-data-validation-list",Kn="univer-data-validation-list-buttons",Gn="univer-data-validation-list-button",xe={dataValidationList:zn,dataValidationListButtons:Kn,dataValidationListButton:Gn};function qn(e){const t=f.useDependency(M.SheetDataValidationModel),a=f.useDependency(r.IUniverInstanceService),n=f.useDependency(r.ICommandService),o=f.useDependency(r.Injector),i=f.useDependency(ue),s=f.useDependency(r.LocaleService),[l,d]=R.useState([]),{workbook:u}=e,p=f.useObservable(u.activeSheet$,void 0,!0),g=u.getUnitId(),c=p==null?void 0:p.getSheetId();R.useEffect(()=>{d(t.getRules(g,c));const S=t.ruleChange$.subscribe(I=>{I.unitId===g&&I.subUnitId===c&&d(t.getRules(g,c))});return()=>{S.unsubscribe()}},[g,c,t]);const y=async()=>{const S=M.createDefaultNewRule(o),I={unitId:g,subUnitId:c,rule:S};await n.executeCommand(M.AddSheetDataValidationCommand.id,I),i.setActiveRule({unitId:g,subUnitId:c,rule:S})},m=()=>{n.executeCommand(M.RemoveSheetAllDataValidationCommand.id,{unitId:g,subUnitId:c})},V=(S=>{const I=a.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET),T=I.getActiveSheet(),C=I.getUnitId(),D=T.getSheetId();return S.map(L=>X.checkRangesEditablePermission(o,C,D,L.ranges)?{...L}:{...L,disable:!0})})(l),v=V==null?void 0:V.some(S=>S.disable);return h.jsxs("div",{className:xe.dataValidationList,children:[V==null?void 0:V.map(S=>{var I;return h.jsx(Xn,{unitId:g,subUnitId:c,onClick:()=>{S.disable||i.setActiveRule({unitId:g,subUnitId:c,rule:S})},rule:S,disable:(I=S.disable)!=null?I:!1},S.uid)}),h.jsxs("div",{className:xe.dataValidationListButtons,children:[l.length&&!v?h.jsx(b.Button,{className:xe.dataValidationListButton,onClick:m,children:s.t("dataValidation.panel.removeAll")}):null,h.jsx(b.Button,{className:xe.dataValidationListButton,type:"primary",onClick:y,children:s.t("dataValidation.panel.add")})]})]})}const Zn=()=>{const e=f.useDependency(ue),t=f.useObservable(e.activeRule$,e.activeRule),a=f.useDependency(r.IUniverInstanceService),n=f.useObservable(()=>a.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),o=f.useObservable(()=>{var i;return(i=n==null?void 0:n.activeSheet$)!=null?i:ie.of(null)},void 0,void 0,[]);return!n||!o?null:t&&t.subUnitId===o.getSheetId()?h.jsx(Bn,{},t.rule.uid):h.jsx(qn,{workbook:n})},Ze="data-validation.list.dropdown",_t="data-validation.date.dropdown",Je={type:r.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(r.IUniverInstanceService),a=X.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:o}=a,i=M.createDefaultNewRule(e),s=e.get(r.ICommandService),l=n.getUnitId(),d=o.getSheetId(),u={rule:i,unitId:l,subUnitId:d};return s.syncExecuteCommand(M.AddSheetDataValidationCommand.id,u)?(s.syncExecuteCommand(De.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var Jn=Object.getOwnPropertyDescriptor,Qn=(e,t,a,n)=>{for(var o=n>1?void 0:n?Jn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Re=(e,t)=>(a,n)=>t(a,n,e);const Se="SHEET_DATA_VALIDATION_ALERT";let je=class extends r.Disposable{constructor(e,t,a,n,o,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=o,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ie.debounceTime(100)).subscribe(e=>{var t;if(e){const a=this._univerInstanceService.getUnit(e.location.unitId,r.UniverInstanceType.UNIVER_SHEET),n=a.getSheetBySheetId(e.location.subUnitId);if(!n)return;const o=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!o){this._cellAlertManagerService.removeAlert(Se);return}if(this._dataValidationModel.validator(o,{...e.location,workbook:a,worksheet:n})===r.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Se),l=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(l&&l.row===e.location.row&&l.col===e.location.col&&l.subUnitId===e.location.subUnitId&&l.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(Se);return}const d=this._dataValidationModel.getValidator(o.type);if(!d){this._cellAlertManagerService.removeAlert(Se);return}this._cellAlertManagerService.showAlert({type:$.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:d==null?void 0:d.getRuleFinalError(o,e.location),location:e.location,width:200,height:74,key:Se});return}}this._cellAlertManagerService.removeAlert(Se)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(Se)}))}};je=Qn([Re(0,r.Inject($.HoverManagerService)),Re(1,r.Inject($.CellAlertManagerService)),Re(2,r.IUniverInstanceService),Re(3,r.Inject(r.LocaleService)),Re(4,f.IZenZoneService),Re(5,r.Inject(M.SheetDataValidationModel))],je);var ea=Object.getOwnPropertyDescriptor,ta=(e,t,a,n)=>{for(var o=n>1?void 0:n?ea(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},tt=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends r.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,o)=>{const{source:i,target:s,unitId:l,subUnitId:d}=n,u=this._sheetDataValidationModel.getRuleObjectMatrix(l,d).clone(),p=$.virtualizeDiscreteRanges([i,s]),[g,c]=p.ranges,{mapFunc:y}=p,m={row:g.startRow,col:g.startColumn},w=$.getAutoFillRepeatRange(g,c),V=new r.ObjectMatrix,v=new Set;w.forEach(D=>{const _=D.repeatStartCell,L=D.relativeRange,F={startRow:m.row,startColumn:m.col,endColumn:m.col,endRow:m.row},W={startRow:_.row,startColumn:_.col,endColumn:_.col,endRow:_.row};r.Range.foreach(L,(A,j)=>{const x=r.Rectangle.getPositionRange({startRow:A,startColumn:j,endColumn:j,endRow:A},F),{row:N,col:B}=y(x.startRow,x.startColumn),H=this._sheetDataValidationModel.getRuleIdByLocation(l,d,N,B)||"",G=r.Rectangle.getPositionRange({startRow:A,startColumn:j,endColumn:j,endRow:A},W),{row:q,col:K}=y(G.startRow,G.startColumn);V.setValue(q,K,H),v.add(H)})});const S=Array.from(v).map(D=>({id:D,ranges:r.queryObjectMatrix(V,_=>_===D)}));u.addRangeRules(S);const I=u.diff(this._sheetDataValidationModel.getRules(l,d)),{redoMutations:T,undoMutations:C}=M.getDataValidationDiffMutations(l,d,I,this._injector,"patched",o===$.APPLY_TYPE.ONLY_FORMAT);return{undos:C,redos:T}},a={id:M.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:o,unitId:i,subUnitId:s}=n;for(const l of o.rows)for(const d of o.cols){const u=this._sheetDataValidationModel.getRuleByLocation(i,s,l,d);if(u&&u.type===r.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType($.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,o,i)=>i===$.APPLY_TYPE.COPY||i===$.APPLY_TYPE.ONLY_FORMAT||i===$.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};Me=ta([tt(0,$.IAutoFillService),tt(1,r.Inject(M.SheetDataValidationModel)),tt(2,r.Inject(r.Injector))],Me);var na=Object.getOwnPropertyDescriptor,aa=(e,t,a,n)=>{for(var o=n>1?void 0:n?na(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},nt=(e,t)=>(a,n)=>t(a,n,e);let be=class extends r.Disposable{constructor(t,a,n){super();P(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:M.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,o)=>{const{copyType:i=$.COPY_TYPE.COPY,pasteType:s}=o,{range:l}=t||{},{range:d,unitId:u,subUnitId:p}=a;return this._generateMutations(d,{copyType:i,pasteType:s,copyRange:l,unitId:u,subUnitId:p})}})}_collect(t,a,n){const o=new r.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:o};const i=this._injector.invoke(d=>X.rangeToDiscreteRange(n,d,t,a));if(!i)return;const{rows:s,cols:l}=i;s.forEach((d,u)=>{l.forEach((p,g)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(t,a,d,p);o.setValue(u,g,c!=null?c:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===$.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:o,subUnitId:i}=this._copyInfo;if(a.unitId!==o||i!==a.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),l=new r.ObjectMatrix,d=new Set,{ranges:[u,p],mapFunc:g}=$.virtualizeDiscreteRanges([a.copyRange,t]),c=$.getRepeatRange(u,p,!0),y=new Map;c.forEach(({startRange:v})=>{var S;(S=this._copyInfo)==null||S.matrix.forValue((I,T,C)=>{const D=r.Rectangle.getPositionRange({startRow:I,endRow:I,startColumn:T,endColumn:T},v),_=`${i}-${C}`,L=this._sheetDataValidationModel.getRuleById(o,i,C);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,_)&&L&&y.set(_,{...L,uid:_});const{row:F,col:W}=g(D.startRow,D.startColumn);d.add(_),l.setValue(F,W,_)})});const m=Array.from(d).map(v=>({id:v,ranges:r.queryObjectMatrix(l,S=>S===v)}));s.addRangeRules(m);const{redoMutations:w,undoMutations:V}=M.getDataValidationDiffMutations(a.unitId,a.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),y.values()),this._injector,"patched",!1);return{redos:w,undos:V}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(o,i).clone(),l=new r.ObjectMatrix,d=new Set,{ranges:[u,p],mapFunc:g}=$.virtualizeDiscreteRanges([a.copyRange,t]);$.getRepeatRange(u,p,!0).forEach(({startRange:V})=>{var v;(v=this._copyInfo)==null||v.matrix.forValue((S,I,T)=>{const C=r.Rectangle.getPositionRange({startRow:S,endRow:S,startColumn:I,endColumn:I},V),{row:D,col:_}=g(C.startRow,C.startColumn);l.setValue(D,_,T),d.add(T)})});const y=Array.from(d).map(V=>({id:V,ranges:r.queryObjectMatrix(l,v=>v===V)}));s.addRangeRules(y);const{redoMutations:m,undoMutations:w}=M.getDataValidationDiffMutations(o,i,s.diff(this._sheetDataValidationModel.getRules(o,i)),this._injector,"patched",!1);return{redos:m,undos:w}}}};be=aa([nt(0,$.ISheetClipboardService),nt(1,r.Inject(M.SheetDataValidationModel)),nt(2,r.Inject(r.Injector))],be);var oa=Object.getOwnPropertyDescriptor,ia=(e,t,a,n)=>{for(var o=n>1?void 0:n?oa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},at=(e,t)=>(a,n)=>t(a,n,e);let Te=class extends r.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===M.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission,X.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===M.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission,X.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Te=ia([at(0,r.Inject(r.LocaleService)),at(1,r.ICommandService),at(2,r.Inject(X.SheetPermissionCheckController))],Te);const Ut="data-validation-single",kt="sheet.menu.data-validation";function ra(e){return{id:kt,type:f.MenuItemType.SUBITEMS,icon:Ut,tooltip:"dataValidation.title",hidden$:f.getMenuHiddenObservable(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:$.getCurrentRangeDisable$(e,{workbookTypes:[X.WorkbookEditablePermission],worksheetTypes:[X.WorksheetSetCellStylePermission,X.WorksheetEditPermission],rangeTypes:[X.RangeProtectionPermissionEditPoint]})}}function sa(e){return{id:De.id,title:"dataValidation.panel.title",type:f.MenuItemType.BUTTON}}function la(e){return{id:Je.id,title:"dataValidation.panel.add",type:f.MenuItemType.BUTTON}}const da={[f.RibbonStartGroup.FORMULAS_INSERT]:{[kt]:{order:9,menuItemFactory:ra,[De.id]:{order:0,menuItemFactory:sa},[Je.id]:{order:1,menuItemFactory:la}}}};var ca=Object.getOwnPropertyDescriptor,Nt=(e,t,a,n)=>{for(var o=n>1?void 0:n?ca(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},J=(e,t)=>(a,n)=>t(a,n,e);const Bt={tr:{size:6,color:"#fe4b4b"}};let Le=class extends r.RxDisposable{constructor(e,t,a,n,o,i,s,l,d,u,p){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=o,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=l,this._sheetInterceptorService=d,this._dataValidationCacheService=u,this._editorBridgeService=p,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(da)}_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:o,row:i,column:s}=t,l=this._univerInstanceService.getUniverSheetInstance(n);if(!l)return;const d=this._sheetDataValidationModel.getRuleByLocation(n,o,i,s);if(!d)return;const u=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!(u!=null&&u.dropdown))return;const p=l.getActiveSheet();if(!p)return;const g=this._dropdownManagerService.activeDropdown,c=g==null?void 0:g.location;if(c&&c.unitId===n&&c.subUnitId===o&&c.row===i&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:o,row:i,col:s,workbook:l,worksheet:p},componentKey:u.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var v,S,I,T,C;const{row:n,col:o,unitId:i,subUnitId:s,workbook:l,worksheet:d}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,o);if(!u)return a(e);const p=this._sheetDataValidationModel.getRuleById(i,s,u);if(!p)return a(e);const g=(v=this._dataValidationCacheService.getValue(i,s,n,o))!=null?v:r.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),y=t.rawData;let m;const w={get value(){var D;return m!==void 0||(m=(D=M.getCellValueOrigin(y))!=null?D:null),m}},V={get value(){var D;return`${(D=w.value)!=null?D:""}`}};return a({...e,markers:{...e==null?void 0:e.markers,...g===r.DataValidationStatus.INVALID?Bt:null},customRender:[...(S=e==null?void 0:e.customRender)!=null?S:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((I=e==null?void 0:e.fontRenderExtension)==null?void 0:I.isSkip)||((T=c==null?void 0:c.skipDefaultFontRender)==null?void 0:T.call(c,p,w.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,V.value,{get style(){const D=l.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,o)},interceptorAutoHeight:()=>{var F,W,A,j,x,N;const D=(W=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with($.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!D)return;const _=D.worksheet.getMergedCell(n,o),L={data:e,style:D.getStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex((A=_==null?void 0:_.startRow)!=null?A:n,(j=_==null?void 0:_.startColumn)!=null?j:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(N=(x=c==null?void 0:c.canvasRender)==null?void 0:x.calcCellAutoHeight)==null?void 0:N.call(x,L)},interceptorAutoWidth:()=>{var F,W,A,j,x,N;const D=(W=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with($.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!D)return;const _=D.worksheet.getMergedCell(n,o),L={data:e,style:D.getStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex((A=_==null?void 0:_.startRow)!=null?A:n,(j=_==null?void 0:_.startColumn)!=null?j:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(N=(x=c==null?void 0:c.canvasRender)==null?void 0:x.calcCellAutoWidth)==null?void 0:N.call(x,L)},coverable:((C=e==null?void 0:e.coverable)!=null?C:!0)&&!(p.type===r.DataValidationType.LIST||p.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(a=>{var n;(a.rule.type===r.DataValidationType.LIST_MULTIPLE||a.rule.type===r.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(a.redos,this._commandService)}})}};Le=Nt([J(0,r.ICommandService),J(1,f.IMenuManagerService),J(2,U.IRenderManagerService),J(3,r.IUniverInstanceService),J(4,r.Inject($.AutoHeightController)),J(5,r.Inject(me)),J(6,r.Inject(M.SheetDataValidationModel)),J(7,r.Inject(Q.DataValidatorRegistryService)),J(8,r.Inject(X.SheetInterceptorService)),J(9,r.Inject(M.DataValidationCacheService)),J(10,r.Optional($.IEditorBridgeService))],Le);let yt=class extends r.RxDisposable{constructor(e,t,a,n,o,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=o,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var V,v,S,I,T;const{row:n,col:o,unitId:i,subUnitId:s,workbook:l,worksheet:d}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,o);if(!u)return a(e);const p=this._sheetDataValidationModel.getRuleById(i,s,u);if(!p)return a(e);const g=(V=this._dataValidationCacheService.getValue(i,s,n,o))!=null?V:r.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),y=d.getCellRaw(n,o),m=M.getCellValueOrigin(y),w=`${m!=null?m:""}`;return a({...e,markers:{...e==null?void 0:e.markers,...g===r.DataValidationStatus.INVALID?Bt:null},customRender:[...(v=e==null?void 0:e.customRender)!=null?v:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((S=e==null?void 0:e.fontRenderExtension)==null?void 0:S.isSkip)||((I=c==null?void 0:c.skipDefaultFontRender)==null?void 0:I.call(c,p,m,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,w,{get style(){const C=l.getStyles();return(typeof(e==null?void 0:e.s)=="string"?C.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,o)},interceptorAutoHeight:()=>{var L,F,W,A,j,x;const C=(F=(L=this._renderManagerService.getRenderById(i))==null?void 0:L.with($.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:F.skeleton;if(!C)return;const D=C.worksheet.getMergedCell(n,o),_={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((W=D==null?void 0:D.startRow)!=null?W:n,(A=D==null?void 0:D.startColumn)!=null?A:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(x=(j=c==null?void 0:c.canvasRender)==null?void 0:j.calcCellAutoHeight)==null?void 0:x.call(j,_)},coverable:((T=e==null?void 0:e.coverable)!=null?T:!0)&&!(p.type===r.DataValidationType.LIST||p.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.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);r.sequenceExecute(a.redos,this._commandService)}})}};yt=Nt([J(0,r.ICommandService),J(1,U.IRenderManagerService),J(2,r.Inject($.AutoHeightController)),J(3,r.Inject(Q.DataValidatorRegistryService)),J(4,r.Inject(X.SheetInterceptorService)),J(5,r.Inject(M.SheetDataValidationModel)),J(6,r.Inject(M.DataValidationCacheService))],yt);var ua=Object.getOwnPropertyDescriptor,ha=(e,t,a,n)=>{for(var o=n>1?void 0:n?ua(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Vt=(e,t)=>(a,n)=>t(a,n,e);let Xe=class extends r.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(o=>{a.add(o.subUnitId)}),a.forEach(o=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(o))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(r.bufferDebounceTime(16)).subscribe(e))}};Xe=ha([Vt(1,r.Inject(M.SheetDataValidationModel)),Vt(2,r.Inject($.SheetSkeletonManagerService))],Xe);const pa="univer-data-validation-formula",ga="univer-data-validation-formula-and",ma="univer-data-validation-formula-list-item",va="univer-data-validation-formula-list-item-icon",fa="univer-data-validation-formula-list-item-drag",Sa="univer-data-validation-formula-list-add",_a="univer-data-validation-formula-color-select",Ia="univer-data-validation-formula-color-select-panel",Ca="univer-data-validation-formula-color-item",ae={dataValidationFormula:pa,dataValidationFormulaAnd:ga,dataValidationFormulaListItem:ma,dataValidationFormulaListItemIcon:va,dataValidationFormulaListItemDrag:fa,dataValidationFormulaListAdd:Sa,dataValidationFormulaColorSelect:_a,dataValidationFormulaColorSelectPanel:Ia,dataValidationFormulaColorItem:Ca},Da=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:o,validResult:i}=e,s=f.useDependency(r.LocaleService),l=o?i==null?void 0:i.formula1:"",d=o?i==null?void 0:i.formula2:"";return t?h.jsxs(h.Fragment,{children:[h.jsx(b.FormLayout,{error:l,children:h.jsx(b.Input,{className:ae.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:ae.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),h.jsx(b.FormLayout,{error:d,children:h.jsx(b.Input,{className:ae.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:u=>{n==null||n({...a,formula2:u})}})})]}):h.jsx(b.FormLayout,{error:l,children:h.jsx(b.Input,{className:ae.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({formula1:u})}})})};function ya(e){const{value:t,onChange:a,showError:n,validResult:o}=e,i=f.useDependency(r.LocaleService),s=n?o==null?void 0:o.formula1:"",l=n?o==null?void 0:o.formula2:"",[d,u]=R.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(b.FormLayout,{children:h.jsx(b.Checkbox,{checked:d,onChange:p=>{p?u(!0):(u(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),d?h.jsx(b.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:h.jsx(b.Input,{className:ae.dataValidationFormula,placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:p=>{a==null||a({...t,formula1:p||void 0})}})}):null,d?h.jsx(b.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:l,children:h.jsx(b.Input,{className:ae.dataValidationFormula,placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:p=>{a==null||a({...t,formula2:p||void 0})}})}):null]})}function Va(e){var g;const{unitId:t,subUnitId:a,value:n,onChange:o,showError:i,validResult:s}=e,l=i?s==null?void 0:s.formula1:void 0,d=R.useRef(null),[u,p]=R.useState(!1);return f.useSidebarClick(c=>{var m;((m=d.current)==null?void 0:m.isClickOutSide(c))&&p(!1)}),h.jsx(mt.FormulaEditor,{initValue:(g=n==null?void 0:n.formula1)!=null?g:"=",unitId:t,subUnitId:a,isFocus:u,onChange:c=>{const y=(c!=null?c:"").trim();y!==(n==null?void 0:n.formula1)&&(o==null||o({...n,formula1:y}))},errorText:l,onFocus:()=>p(!0),isSupportAcrossSheet:!0,ref:d})}const Ra=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],wa=e=>{const{value:t,onChange:a,disabled:n}=e,[o,i]=R.useState(!1);return h.jsx(b.Select,{disabled:n,open:o,onDropdownVisibleChange:i,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ae.dataValidationFormulaColorSelect,value:t,onChange:a,labelRender:s=>h.jsx("div",{className:ae.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>h.jsx("div",{className:ae.dataValidationFormulaColorSelectPanel,children:Ra.map(s=>h.jsx("div",{onClick:()=>{a(s),i(!1)},className:ae.dataValidationFormulaColorItem,style:{background:s}},s))})})},Rt=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:o,onItemDelete:i}=a;return h.jsxs("div",{className:ae.dataValidationFormulaListItem,style:n,children:[t.isRef?null:h.jsx("div",{className:b.clsx(ae.dataValidationFormulaListItemDrag,"draggableHandle"),children:h.jsx(At,{})}),h.jsx(wa,{value:t.color,onChange:s=>{o(t.id,t.label,s)}}),h.jsx(b.Input,{disabled:t.isRef,value:t.label,onChange:s=>{o(t.id,s,t.color)}}),t.isRef?null:h.jsx("div",{className:ae.dataValidationFormulaListItemIcon,children:h.jsx(vt,{onClick:()=>i(t.id)})})]})};function Ea(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:o,validResult:i,showError:s,ruleId:l}=e,{formula1:d="",formula2:u=""}=t||{},p=R.useRef(null),[g,c]=R.useState(()=>r.isFormulaString(d)?"1":"0"),[y,m]=R.useState(g==="1"?d:"="),[w,V]=R.useState(g==="1"?d:"="),v=f.useDependency(r.LocaleService),S=f.useDependency(Q.DataValidatorRegistryService),I=f.useDependency(Q.DataValidationModel),T=f.useDependency(M.DataValidationFormulaController),[C,D]=R.useState(()=>u.split(",")),_=S.getValidatorItem(r.DataValidationType.LIST),[L,F]=R.useState([]),[W,A]=R.useState(""),j=s?i==null?void 0:i.formula1:"",x=R.useMemo(()=>I.ruleChange$.pipe(ie.debounceTime(16)),[]),N=f.useObservable(x),B=f.useEvent(a);R.useEffect(()=>{(async()=>{await new Promise(Y=>{setTimeout(()=>Y(!0),100)});const E=I.getRuleById(n,o,l),k=E==null?void 0:E.formula1;if(r.isFormulaString(k)&&_&&E){const Y=await _.getListAsync(E,n,o);F(Y)}})()},[I,N,_,l,o,n]),R.useEffect(()=>{r.isFormulaString(d)&&d!==w&&(m(d),V(w))},[w,d]);const[H,G]=R.useState(()=>{const E=g!=="1"?M.deserializeListOptions(d):[],k=u.split(",");return E.map((Y,z)=>({label:Y,color:k[z]||Ce,isRef:!1,id:r.Tools.generateRandomId(4)}))}),q=(E,k,Y)=>{const z=H.find(ge=>ge.id===E);z&&(z.label=k,z.color=Y,G([...H]))},K=E=>{const k=H.findIndex(Y=>Y.id===E);k!==-1&&(H.splice(k,1),G([...H]))},Z=u.split(","),ee=R.useMemo(()=>L.map((E,k)=>({label:E,color:Z[k]||Ce,id:`${k}`,isRef:!0})),[Z,L]),te=(E,k,Y)=>{const z=[...C];z[+E]=Y,D(z),B({formula1:d,formula2:z.join(",")})},ne=()=>{G([...H,{label:"",color:Ce,isRef:!1,id:r.Tools.generateRandomId(4)}])};R.useEffect(()=>{if(g==="1")return;const E=new Set,k=[];H.map(Y=>({labelList:Y.label.split(","),item:Y})).forEach(({item:Y,labelList:z})=>{z.forEach(ge=>{E.has(ge)||(E.add(ge),k.push({label:ge,color:Y.color}))})}),B({formula1:M.serializeListOptions(k.map(Y=>Y.label)),formula2:k.map(Y=>Y.color===Ce?"":Y.color).join(",")})},[H,B,g,w,C]);const re=f.useEvent(async E=>{if(!r.isFormulaString(E)){B==null||B({formula1:"",formula2:u});return}T.getFormulaRefCheck(E)?(B==null||B({formula1:r.isFormulaString(E)?E:"",formula2:u}),A("")):(B==null||B({formula1:"",formula2:u}),m("="),A(v.t("dataValidation.validFail.formulaError")))}),oe=R.useRef(null),[se,O]=R.useState(!1);return f.useSidebarClick(E=>{var Y;((Y=oe.current)==null?void 0:Y.isClickOutSide(E))&&O(!1)}),h.jsxs(h.Fragment,{children:[h.jsx(b.FormLayout,{label:v.t("dataValidation.list.options"),children:h.jsxs(b.RadioGroup,{value:g,onChange:E=>{c(E),m(w),E==="1"&&B({formula1:w==="="?"":w,formula2:C.join(",")})},children:[h.jsx(b.Radio,{value:"0",children:v.t("dataValidation.list.customOptions")}),h.jsx(b.Radio,{value:"1",children:v.t("dataValidation.list.refOptions")})]})}),g==="1"?h.jsxs(h.Fragment,{children:[h.jsx(mt.FormulaEditor,{initValue:y,unitId:n,subUnitId:o,isFocus:se,onChange:(E="")=>{const k=(E!=null?E:"").trim();V(k),re(k)},errorText:j||W||void 0,onFocus:()=>O(!0),isSupportAcrossSheet:!0,ref:oe}),h.jsx("div",{ref:p,style:{marginTop:"12px"},children:ee.map(E=>h.jsx(Rt,{item:E,commonProps:{onItemChange:te},style:{marginBottom:12}},E.id))})]}):h.jsx(b.FormLayout,{error:j,children:h.jsxs("div",{ref:p,style:{marginTop:"-12px"},children:[h.jsx(b.DraggableList,{list:H,onListChange:G,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:E=>h.jsx(Rt,{item:E,commonProps:{onItemChange:q,onItemDelete:K}},E.id),idKey:"id"}),h.jsxs("a",{className:ae.dataValidationFormulaListAdd,onClick:ne,children:[h.jsx(Lt,{}),v.t("dataValidation.list.add")]})]})})]})}const Wt="data-validation.custom-formula-input",Qe="data-validation.formula-input",It="data-validation.list-formula-input",$t="data-validation.checkbox-formula-input",Ma=[[Wt,Va],[Qe,Da],[It,Ea],[$t,ya]],ba="LIST_RENDER_MODE_OPTION_INPUT";function ze(e){var o;const{value:t,onChange:a}=e,n=f.useDependency(r.LocaleService);return h.jsx(b.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:h.jsxs(b.RadioGroup,{value:`${(o=t.renderMode)!=null?o:r.DataValidationRenderMode.CUSTOM}`,onChange:i=>a({...t,renderMode:+i}),children:[h.jsx(b.Radio,{value:`${r.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),h.jsx(b.Radio,{value:`${r.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),h.jsx(b.Radio,{value:`${r.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}ze.componentKey=ba;const Ta="DATE_SHOW_TIME_OPTION";function Ke(e){var o;const{value:t,onChange:a}=e,n=f.useDependency(r.LocaleService);return h.jsx(b.FormLayout,{children:h.jsx(b.Checkbox,{checked:(o=t.bizInfo)==null?void 0:o.showTime,onChange:i=>{a({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:n.t("dataValidation.showTime.label")})})}Ke.componentKey=Ta;var La=Object.getOwnPropertyDescriptor,Oa=(e,t,a,n)=>{for(var o=n>1?void 0:n?La(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},we=(e,t)=>(a,n)=>t(a,n,e);const Ue=6;let ut=class{constructor(e,t,a,n,o,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=a,this._themeService=n,this._renderManagerService=o,this._dataValidationModel=i}_calc(e,t){var u,p,g;const{vt:a,ht:n}=t||{},o=e.endX-e.startX-Ue*2,i=e.endY-e.startY,s=((u=t==null?void 0:t.fs)!=null?u:10)*1.6;let l=0,d=0;switch(a){case r.VerticalAlign.TOP:d=0;break;case r.VerticalAlign.BOTTOM:d=0+(i-s);break;default:d=0+(i-s)/2;break}switch(n){case r.HorizontalAlign.LEFT:l=Ue;break;case r.HorizontalAlign.RIGHT:l=Ue+(o-s);break;default:l=Ue+(o-s)/2;break}return{left:e.startX+l,top:e.startY+d,width:((p=t==null?void 0:t.fs)!=null?p:10)*1.6,height:((g=t==null?void 0:t.fs)!=null?g:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var u,p,g,c,y,m,w,V,v;const{formula1:n=M.CHECKBOX_FORMULA_1,formula2:o=M.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=M.getFormulaResult((g=(p=(u=i==null?void 0:i[0])==null?void 0:u.result)==null?void 0:p[0])==null?void 0:g[0]),l=M.getFormulaResult((m=(y=(c=i==null?void 0:i[1])==null?void 0:c.result)==null?void 0:y[0])==null?void 0:m[0]),d=M.isLegalFormulaResult(String(s))&&M.isLegalFormulaResult(String(l));return{formula1:r.isFormulaString(n)?M.getFormulaResult((v=(V=(w=i==null?void 0:i[0])==null?void 0:w.result)==null?void 0:V[0])==null?void 0:v[0]):n,formula2:r.isFormulaString(o)?l:o,isFormulaValid:d}}drawWith(e,t){var j,x,N,B;const{style:a,primaryWithCoord:n,unitId:o,subUnitId:i,worksheet:s,row:l,col:d}=t,u=n.isMergedMainCell?n.mergeInfo:n,p=M.getCellValueOrigin(s.getCellRaw(l,d)),g=this._dataValidationModel.getRuleByLocation(o,i,l,d);if(!g)return;const c=this._dataValidationModel.getValidator(g.type);if(!c)return;const y=this._themeService.getCurrentTheme();if(!((j=c.skipDefaultFontRender)!=null&&j.call(c,g,p,{unitId:o,subUnitId:i,row:l,column:d})))return;const m=c.parseFormulaSync(g,o,i),{formula1:w}=m,V=this._calc(u,a),{a:v,d:S}=e.getTransform(),I=U.fixLineWidthByScale(V.left,v),T=U.fixLineWidthByScale(V.top,S),C=U.Transform.create().composeMatrix({left:I,top:T,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),D=u.endX-u.startX,_=u.endY-u.startY;e.save(),e.beginPath(),e.rect(u.startX,u.startY,D,_),e.clip();const L=C.getMatrix();e.transform(L[0],L[1],L[2],L[3],L[4],L[5]);const F=((x=a==null?void 0:a.fs)!=null?x:10)*1.6,W=String(p)===String(w),A=y.hyacinth500;U.CheckboxShape.drawWith(e,{checked:W,width:F,height:F,fill:(B=(N=a==null?void 0:a.cl)==null?void 0:N.rgb)!=null?B:A}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),o=n.top,i=n.top+n.height,s=n.left,l=n.left+n.width,{x:d,y:u}=e;return d<=l&&d>=s&&u<=i&&u>=o}async onPointerDown(e,t){var m;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:o,worksheet:i,row:s,col:l}=e,d=M.getCellValueOrigin(i.getCellRaw(s,l)),u=this._dataValidationModel.getRuleByLocation(n,o,s,l);if(!u)return;const p=this._dataValidationModel.getValidator(u.type);if(!p||!((m=p.skipDefaultFontRender)!=null&&m.call(p,u,d,{unitId:n,subUnitId:o,row:s,column:l})))return;const{formula1:g,formula2:c}=await this._parseFormula(u,n,o),y={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(d)===M.transformCheckboxValue(String(g))?c:g,p:null}};this._commandService.executeCommand(X.SetRangeValuesCommand.id,y)}onPointerEnter(e,t){var a,n;(n=(a=U.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(U.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=U.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(U.CURSOR_TYPE.DEFAULT)}};ut=Oa([we(0,r.ICommandService),we(1,r.IUniverInstanceService),we(2,r.Inject(M.DataValidationFormulaService)),we(3,r.Inject(r.ThemeService)),we(4,r.Inject(U.IRenderManagerService)),we(5,r.Inject(M.SheetDataValidationModel))],ut);var Pa=Object.getOwnPropertyDescriptor,Aa=(e,t,a,n)=>{for(var o=n>1?void 0:n?Pa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},ja=(e,t)=>(a,n)=>t(a,n,e);let he=class{constructor(e){P(this,"canvasRender",null);P(this,"dropdown");P(this,"optionsInput");P(this,"formulaInput",It);this.injector=e}};he=Aa([ja(0,r.Inject(r.Injector))],he);class Fa extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.CHECKBOX);P(this,"canvasRender",this.injector.createInstance(ut));P(this,"formulaInput",$t)}}class xa extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.CUSTOM);P(this,"formulaInput",Wt)}}const Ua="data-validation.formula-input";class ka extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.DATE);P(this,"formulaInput",Ua);P(this,"optionsInput",Ke.componentKey);P(this,"dropdown",_t)}}class Na extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.DECIMAL);P(this,"formulaInput",Qe)}}const Ht=4,Ba=0,ot=4,Yt=4,ht=6,Ge=6,Ie=14;function Wa(e,t){const a=U.FontCache.getTextSize(e,t),n=a.width+Ht*2,{ba:o,bd:i}=a,s=o+i;return{width:n,height:s+Ba*2,ba:o}}function it(e,t,a,n){const o=Ie+ht*2,i=a-o,s=n-Ge*2,l=e.map(c=>({layout:Wa(c,t),text:c}));let d;const u=[];l.forEach(c=>{const{layout:y}=c,{width:m,height:w}=y;!d||d.width+m+ot>i?(d={width:m,height:w,items:[{...c,left:0}]},u.push(d)):(d.items.push({...c,left:d.width+ot}),d.width=d.width+m+ot)});let p=0,g=0;return u.forEach((c,y)=>{g=Math.max(g,c.width),y===u.length-1?p+=c.height:p+=c.height+Yt}),{lines:u,totalHeight:p,contentWidth:i,contentHeight:s,cellAutoHeight:p+Ge*2,calcAutoWidth:g+o}}const $a=8;class Ha extends U.Shape{static drawWith(t,a){const{fontString:n,info:o,fill:i,color:s}=a,{layout:l,text:d}=o;t.save(),U.Rect.drawWith(t,{width:l.width,height:l.height,radius:$a,fill:i||Ce}),t.translateWithPrecision(Ht,l.ba),t.font=n,t.fillStyle=s,t.fillText(d,0,0),t.restore()}}var Ya=Object.getOwnPropertyDescriptor,Xa=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ya(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},ke=(e,t)=>(a,n)=>t(a,n,e);const za=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 pt=class{constructor(e,t,a,n){P(this,"zIndex");P(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=a,this._dataValidationModel=n}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,o){const i=a-Ie+4;let s=4;switch(o){case r.VerticalAlign.MIDDLE:s=(n-Ie)/2+4;break;case r.VerticalAlign.BOTTOM:s=n-Ie+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(za),e.restore()}drawWith(e,t,a,n){var q,K;const{primaryWithCoord:o,row:i,col:s,style:l,data:d,subUnitId:u}=t,p=o.isMergedMainCell?o.mergeInfo:o,g=d==null?void 0:d.fontRenderExtension,{leftOffset:c=0,rightOffset:y=0,topOffset:m=0,downOffset:w=0}=g||{},V=this._ensureMap(u),v=this._generateKey(i,s),S=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,s);if(!S)return;const I=this._dataValidationModel.getValidator(S.type);if(!I)return;const T={startX:p.startX+c,endX:p.endX-y,startY:p.startY+m,endY:p.endY-w},C=T.endX-T.startX,D=T.endY-T.startY,{cl:_}=l||{},L=(q=typeof _=="object"?_==null?void 0:_.rgb:_)!=null?q:"#000",F=U.getFontStyleString(l!=null?l:void 0),{vt:W,ht:A}=l||{},j=W!=null?W:r.VerticalAlign.MIDDLE,x=(K=M.getCellValueOrigin(d))!=null?K:"",N=I.parseCellValue(x),B=I.getListWithColorMap(S),H=it(N,F,C,D);this._drawDownIcon(e,T,C,D,j),e.save(),e.translateWithPrecision(T.startX,T.startY),e.beginPath(),e.rect(0,0,C-Ie,D),e.clip(),e.translateWithPrecision(ht,Ge);let G=0;switch(j){case r.VerticalAlign.MIDDLE:G=(H.contentHeight-H.totalHeight)/2;break;case r.VerticalAlign.BOTTOM:G=H.contentHeight-H.totalHeight;break}e.translateWithPrecision(0,G),H.lines.forEach((Z,ee)=>{e.save();const{width:te,height:ne,items:re}=Z;let oe=0;switch(A){case r.HorizontalAlign.RIGHT:oe=H.contentWidth-te;break;case r.HorizontalAlign.CENTER:oe=(H.contentWidth-te)/2;break}e.translate(oe,ee*(ne+Yt)),re.forEach(se=>{e.save(),e.translateWithPrecision(se.left,0),Ha.drawWith(e,{...F,info:se,color:L,fill:B[se.text]}),e.restore()}),e.restore()}),e.restore(),V.set(v,{left:T.startX,top:T.startY,width:H.contentWidth+ht+Ie,height:H.contentHeight+Ge*2})}calcCellAutoHeight(e){var C;const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:u=0,downOffset:p=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,c={startX:g.startX+l,endX:g.endX-d,startY:g.startY+u,endY:g.endY-p},y=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!y)return;const m=this._dataValidationModel.getValidator(y.type);if(!m)return;const w=c.endX-c.startX,V=c.endY-c.startY,v=(C=M.getCellValueOrigin(n))!=null?C:"",S=m.parseCellValue(v),I=U.getFontStyleString(a!=null?a:void 0);return it(S,I,w,V).cellAutoHeight}calcCellAutoWidth(e){var C;const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:u=0,downOffset:p=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,c={startX:g.startX+l,endX:g.endX-d,startY:g.startY+u,endY:g.endY-p},y=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!y)return;const m=this._dataValidationModel.getValidator(y.type);if(!m)return;const w=c.endX-c.startX,V=c.endY-c.startY,v=(C=M.getCellValueOrigin(n))!=null?C:"",S=m.parseCellValue(v),I=U.getFontStyleString(a!=null?a:void 0);return it(S,I,w,V).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:o}=n,{x:i}=e;return i>=o-Ie&&i<=o}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:i}=e,s={unitId:a,subUnitId:n,row:o,column:i};this._commandService.executeCommand(qe.id,s)}onPointerEnter(e,t){var a,n;return(n=(a=U.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(U.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;return(n=(a=U.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(U.CURSOR_TYPE.DEFAULT)}};pt=Xa([ke(0,r.ICommandService),ke(1,r.IUniverInstanceService),ke(2,r.Inject(U.IRenderManagerService)),ke(3,r.Inject(M.SheetDataValidationModel))],pt);class Ka extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.LIST_MULTIPLE);P(this,"canvasRender",this.injector.createInstance(pt));P(this,"dropdown",Ze)}}var Ga=Object.getOwnPropertyDescriptor,qa=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ga(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Pe=(e,t)=>(a,n)=>t(a,n,e);const _e=4,Ne=4,de=14,ce=6,Ee=4,rt=8,Za="#565656",wt=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 Ja(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${r.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:r.BooleanNumber.FALSE,bl:r.BooleanNumber.FALSE,ul:{s:r.BooleanNumber.FALSE},st:{s:r.BooleanNumber.FALSE},ol:{s:r.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 Xt(e,t,a){const n=Ja(e,a),o=new r.DocumentDataModel(n),i=new U.DocumentViewModel(o);return{documentSkeleton:U.DocumentSkeleton.create(i,t),docModel:o,docViewModel:i}}function Be(e,t,a){const{documentSkeleton:n,docModel:o,docViewModel:i}=Xt(e,t,a);return{documents:new U.Documents(`DOCUMENTS_${r.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:o,docViewModel:i}}function Et(e,t,a,n,o,i,s=!0){let l=0;const d=s?Ee:0;switch(o){case r.VerticalAlign.BOTTOM:l=t-n-d;break;case r.VerticalAlign.MIDDLE:l=(t-n)/2;break;default:l=d;break}l=Math.max(Ee,l);let u=0;switch(i){case r.HorizontalAlign.CENTER:u=(e-a)/2;break;case r.HorizontalAlign.RIGHT:u=e-a;break}return u=Math.max(ce,u),{paddingLeft:u,paddingTop:l}}let gt=class{constructor(e,t,a,n,o){P(this,"_dropdownInfoMap",new Map);P(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=a,this._renderManagerService=n,this._dataValidationModel=o}_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,o,i,s){const{t:l=r.DEFAULT_STYLES.pd.t,b:d=r.DEFAULT_STYLES.pd.b}=s,u=a-de;let p;switch(i){case r.VerticalAlign.MIDDLE:p=(n-Ne)/2;break;case r.VerticalAlign.BOTTOM:p=n-d-o-Ee+(o/2-Ne/2);break;default:p=l+Ee+(o/2-Ne/2);break}e.save(),e.translateWithPrecision(t.startX+u,t.startY+p),e.fillStyle="#565656",e.fill(wt),e.restore()}drawWith(e,t,a){const{primaryWithCoord:n,row:o,col:i,style:s,data:l,subUnitId:d}=t,u=n.isMergedMainCell?n.mergeInfo:n,p=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,o,i);if(!p)return;const g=this._dataValidationModel.getValidator(p.type);if(!g)return;const c=l==null?void 0:l.fontRenderExtension,{leftOffset:y=0,rightOffset:m=0,topOffset:w=0,downOffset:V=0}=c||{};if(!p||!g||!g||g.id.indexOf(r.DataValidationType.LIST)!==0||!g.skipDefaultFontRender(p))return;const v={startX:u.startX+y,endX:u.endX-m,startY:u.startY+w,endY:u.endY-V},S=v.endX-v.startX,I=v.endY-v.startY,T=this._ensureMap(d),C=this._generateKey(o,i),D=g.getListWithColor(p),_=M.getCellValueOrigin(l),L=`${_!=null?_:""}`,F=D.find(N=>N.label===L);let{tb:W,vt:A,ht:j,pd:x}=s||{};if(W=W!=null?W:r.WrapStrategy.WRAP,A=A!=null?A:r.VerticalAlign.BOTTOM,j=j!=null?j:r.DEFAULT_STYLES.ht,x=x!=null?x:r.DEFAULT_STYLES.pd,p.renderMode===r.DataValidationRenderMode.ARROW){const{l:N=r.DEFAULT_STYLES.pd.l,t:B=r.DEFAULT_STYLES.pd.t,r:H=r.DEFAULT_STYLES.pd.r,b:G=r.DEFAULT_STYLES.pd.b}=x,q=S-N-H-de-4,{documentSkeleton:K,documents:Z,docModel:ee}=Be(L,this._localeService,s);W===r.WrapStrategy.WRAP&&ee.updateDocumentDataPageSize(Math.max(q,1)),K.calculate(),K.getActualSize();const te=U.getDocsSkeletonPageSize(K),{height:ne,width:re}=te,{paddingTop:oe,paddingLeft:se}=Et(q,I-B-G,re,ne,A,j,!0);this._drawDownIcon(e,v,S,I,ne,A,x),e.save(),e.translateWithPrecision(v.startX+N,v.startY+B),e.beginPath(),e.rect(0,0,S-N-H,I-B-G),e.clip(),e.translateWithPrecision(0,oe),e.save(),e.translateWithPrecision(_e,0),e.beginPath(),e.rect(0,0,q,ne),e.clip(),Z.render(e),e.translateWithPrecision(se,0),e.restore(),e.restore(),T.set(C,{left:v.endX+N+a.rowHeaderWidth-de,top:v.startY+B+a.columnHeaderHeight,width:de,height:I-B-G})}else{e.save(),e.translateWithPrecision(v.startX,v.startY),e.beginPath(),e.rect(0,0,S,I),e.clip();const N=S-ce*2-_e-de-4,{documentSkeleton:B,documents:H,docModel:G}=Be(L,this._localeService,s);W===r.WrapStrategy.WRAP&&G.updateDocumentDataPageSize(Math.max(N,1)),B.calculate();const q=U.getDocsSkeletonPageSize(B),{height:K,width:Z}=q,{paddingTop:ee,paddingLeft:te}=Et(N,I,Z,K,A,j);e.translateWithPrecision(ce,ee);const ne=Math.max(S-ce*2,1),re=K;U.Rect.drawWith(e,{width:ne,height:re,fill:(F==null?void 0:F.color)||Ce,radius:rt}),e.save(),e.translateWithPrecision(_e,0),e.beginPath(),e.rect(0,0,N,K),e.clip(),e.translateWithPrecision(te,0),H.render(e),e.restore(),e.translateWithPrecision(N+_e+4,(K-Ne)/2),e.fillStyle=Za,e.fill(wt),e.restore(),T.set(C,{left:v.startX+ce+a.rowHeaderWidth,top:v.startY+ee+a.columnHeaderHeight,width:ne,height:re})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,l=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:u=0,topOffset:p=0,downOffset:g=0}=l||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!c||c.renderMode===r.DataValidationRenderMode.TEXT)return;const y={startX:s.startX+d,endX:s.endX-u,startY:s.startY+p,endY:s.endY-g},m=y.endX-y.startX,w=M.getCellValueOrigin(n),V=`${w!=null?w:""}`;let{tb:v,pd:S}=a||{};const{t:I=r.DEFAULT_STYLES.pd.t,b:T=r.DEFAULT_STYLES.pd.b}=S!=null?S:{};if(v=v!=null?v:r.WrapStrategy.WRAP,c.renderMode===r.DataValidationRenderMode.ARROW){const C=m-de,{documentSkeleton:D,docModel:_}=Be(V,this._localeService,a);v===r.WrapStrategy.WRAP&&_.updateDocumentDataPageSize(Math.max(C,1)),D.calculate(),D.getActualSize();const L=U.getDocsSkeletonPageSize(D),{height:F}=L;return F+I+T+Ee*2}else{const C=m-ce*2-_e-de,{documentSkeleton:D,docModel:_}=Xt(V,this._localeService,a);v===r.WrapStrategy.WRAP&&_.updateDocumentDataPageSize(Math.max(C,1)),D.calculate();const L=U.getDocsSkeletonPageSize(D),{height:F}=L;return F+Ee*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,l=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:u=0,topOffset:p=0,downOffset:g=0}=l||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!c||c.renderMode===r.DataValidationRenderMode.TEXT)return;const y={startX:s.startX+d,endX:s.endX-u,startY:s.startY+p,endY:s.endY-g},m=y.endX-y.startX,w=M.getCellValueOrigin(n),V=`${w!=null?w:""}`;let{tb:v,pd:S}=a||{};const{l:I=r.DEFAULT_STYLES.pd.l,r:T=r.DEFAULT_STYLES.pd.r}=S!=null?S:{};v=v!=null?v:r.WrapStrategy.WRAP;let C=ce*2+de;switch(c.renderMode){case r.DataValidationRenderMode.ARROW:C=de+ce*2+T+I;break;case r.DataValidationRenderMode.CUSTOM:C=de+ce*2+_e*2+T+I+rt/2+1;break;default:C=de+ce*2+_e*2+T+I+rt/2+1}const D=m-C,{documentSkeleton:_,docModel:L}=Be(V,this._localeService,a);return v===r.WrapStrategy.WRAP&&L.updateDocumentDataPageSize(Math.max(D,1)),_.calculate(),_.getActualSize(),U.getDocsSkeletonPageSize(_).width+C}isHit(e,t){const{subUnitId:a,row:n,col:o}=t,s=this._ensureMap(a).get(this._generateKey(n,o)),l=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,o);if(!l||!s||l.renderMode===r.DataValidationRenderMode.TEXT)return!1;const{top:d,left:u,width:p,height:g}=s,{x:c,y}=e;return c>=u&&c<=u+p&&y>=d&&y<=d+g}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:i}=e,s={unitId:a,subUnitId:n,row:o,column:i};this._commandService.executeCommand(qe.id,s)}onPointerEnter(e,t){var a,n;(n=(a=U.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(U.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=U.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(U.CURSOR_TYPE.DEFAULT)}};gt=qa([Pe(0,r.IUniverInstanceService),Pe(1,r.Inject(r.LocaleService)),Pe(2,r.ICommandService),Pe(3,r.Inject(U.IRenderManagerService)),Pe(4,r.Inject(M.SheetDataValidationModel))],gt);class Qa extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.LIST);P(this,"canvasRender",this.injector.createInstance(gt));P(this,"dropdown",Ze);P(this,"optionsInput",ze.componentKey);P(this,"formulaInput",It)}}class eo extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.TEXT_LENGTH);P(this,"formulaInput",Qe)}}class to extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.WHOLE);P(this,"formulaInput",Qe)}}var no=Object.getOwnPropertyDescriptor,ao=(e,t,a,n)=>{for(var o=n>1?void 0:n?no(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},st=(e,t)=>(a,n)=>t(a,n,e);let Oe=class extends r.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[Ut,Tt],[He,Zn],[jt,Sn],[Ze,Ln],[_t,an],[ze.componentKey,ze],[Ke.componentKey,Ke],...Ma].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Na,to,eo,ka,Fa,Qa,Ka,xa].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=ao([st(0,r.Inject(r.Injector)),st(1,r.Inject(f.ComponentManager)),st(2,r.Inject(Q.DataValidatorRegistryService))],Oe);var oo=Object.getOwnPropertyDescriptor,io=(e,t,a,n)=>{for(var o=n>1?void 0:n?oo(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},lt=(e,t)=>(a,n)=>t(a,n,e);const ro="SHEET_DATA_VALIDATION_UI_PLUGIN";var We;exports.UniverSheetsDataValidationUIPlugin=(We=class extends r.Plugin{constructor(t=Ye,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:i,...s}=r.merge({},Ye,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(St,s)}onStarting(){[[ue],[me],[je],[Me],[Le],[Te],[be],[Ae],[Oe]].forEach(t=>{this._injector.add(t)}),[Je,qe,xt,ft,De,Ft].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(be),this._injector.get(Te),this._injector.get(Ae),this._injector.get(je),this._injector.get(U.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[Xe])}onRendered(){this._injector.get(Oe),this._injector.get(Le)}onSteady(){this._injector.get(Me)}},P(We,"pluginName",ro),P(We,"type",r.UniverInstanceType.UNIVER_SHEET),We);exports.UniverSheetsDataValidationUIPlugin=io([lt(1,r.Inject(r.Injector)),lt(2,r.ICommandService),lt(3,r.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);var so=Object.getOwnPropertyDescriptor,lo=(e,t,a,n)=>{for(var o=n>1?void 0:n?so(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},dt=(e,t)=>(a,n)=>t(a,n,e);const co="SHEET_DATA_VALIDATION_UI_PLUGIN";var $e;exports.UniverSheetsDataValidationMobileUIPlugin=($e=class extends r.Plugin{constructor(t=Ye,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:i,...s}=r.merge({},Ye,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(St,s)}onStarting(){[[ue],[me],[je],[Me],[Le],[Te],[be],[Oe]].forEach(t=>{this._injector.add(t)}),[Je,qe,xt,ft,De,Ft].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(be),this._injector.get(Te),this._injector.get(U.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[Xe])}onRendered(){this._injector.get(Oe),this._injector.get(Le)}onSteady(){this._injector.get(Me)}},P($e,"pluginName",co),P($e,"type",r.UniverInstanceType.UNIVER_SHEET),$e);exports.UniverSheetsDataValidationMobileUIPlugin=lo([dt(1,r.Inject(r.Injector)),dt(2,r.ICommandService),dt(3,r.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);exports.DATE_DROPDOWN_KEY=_t;exports.LIST_DROPDOWN_KEY=Ze;
1
+ "use strict";var Kt=Object.defineProperty;var Gt=(e,t,a)=>t in e?Kt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var P=(e,t,a)=>Gt(e,typeof t!="symbol"?t+"":t,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),r=require("@univerjs/core"),b=require("@univerjs/design"),U=require("@univerjs/engine-render"),X=require("@univerjs/sheets"),M=require("@univerjs/sheets-data-validation"),qt=require("@univerjs/sheets-numfmt"),$=require("@univerjs/sheets-ui"),f=require("@univerjs/ui"),R=require("react"),Q=require("@univerjs/data-validation"),Zt=require("@univerjs/docs"),ie=require("rxjs"),ct=require("@univerjs/engine-formula"),mt=require("@univerjs/sheets-formula-ui");var Jt=Object.getOwnPropertyDescriptor,Qt=(e,t,a,n)=>{for(var o=n>1?void 0:n?Jt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Ve=(e,t)=>(a,n)=>t(a,n,e);let Ae=class extends r.Disposable{constructor(e,t,a,n,o,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=o,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(X.VALIDATE_CELL,{handler:async(e,t,a)=>{const n=await e,{row:o,col:i,unitId:s,subUnitId:l}=t,d=this._dataValidationModel.getRuleIdByLocation(s,l,o,i),u=d?this._dataValidationModel.getRuleById(s,l,d):void 0;if(n===!1)return a(Promise.resolve(!1));if(!u||u.errorStyle!==r.DataValidationErrorStyle.STOP)return a(Promise.resolve(!0));const p=this._dataValidatorRegistryService.getValidatorItem(u.type);return!p||await this._sheetsDataValidationValidatorService.validatorCell(s,l,o,i)===r.DataValidationStatus.VALID?a(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:p.getRuleFinalError(u,{row:o,col:i,unitId:s,subUnitId:l})},footer:{title:R.createElement(b.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(Promise.resolve(!1)))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:R.createElement(b.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Ae=Qt([Ve(0,r.Inject(X.SheetInterceptorService)),Ve(1,r.Inject(M.SheetDataValidationModel)),Ve(2,r.Inject(Q.DataValidatorRegistryService)),Ve(3,f.IDialogService),Ve(4,r.Inject(r.LocaleService)),Ve(5,r.Inject(M.SheetsDataValidationValidatorService))],Ae);const en="univer-dv-date-dropdown",tn="univer-dv-date-dropdown-btns",Ct={dvDateDropdown:en,dvDateDropdownBtns:tn},nn=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return r.dayjs(r.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=r.dayjs(e);if(t.isValid())return t};function an(e){var _;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:i,unitId:s,subUnitId:l,workbook:d}=t,u=f.useDependency(r.ICommandService),p=f.useDependency(Ae),g=n.getCell(o,i),c=M.getCellValueOrigin(n.getCellRaw(o,i)),V=nn(c),[m,w]=R.useState(V),y=m&&m.isValid()?m:r.dayjs(),v=f.useDependency(r.LocaleService),S=f.useDependency(M.SheetDataValidationModel),I=S.getRuleByLocation(s,l,o,i);if(!I)return null;const T=S.getValidator(I.type);if(!g||!T)return;const C=!!((_=I.bizInfo)!=null&&_.showTime),D=async()=>{var N,B,H;if(!y)return;const F=y.format(C?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),W=(N=r.numfmt.parseDate(F))==null?void 0:N.v,A=d.getStyles().getStyleByCell(g),j=(H=(B=A==null?void 0:A.n)==null?void 0:B.pattern)!=null?H:"",x=qt.getPatternType(j);I.errorStyle!==r.DataValidationErrorStyle.STOP||await T.validator({value:W,unitId:s,subUnitId:l,row:o,column:i,worksheet:n,workbook:d,interceptValue:F.replace("Z","").replace("T"," "),t:r.CellValueType.NUMBER},I)?(a(),await u.executeCommand($.SetCellEditVisibleOperation.id,{visible:!1,eventType:U.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),await u.executeCommand(X.SetRangeValuesCommand.id,{unitId:s,subUnitId:l,range:{startColumn:i,endColumn:i,startRow:o,endRow:o},value:{v:W,t:2,p:null,f:null,si:null,s:{n:{pattern:C?x==="datetime"?j:"yyyy-MM-dd hh:mm:ss":x==="date"?j:"yyyy-MM-dd"}}}})):p.showReject(T.getRuleFinalError(I,{row:o,col:i,unitId:s,subUnitId:l}))};return h.jsxs("div",{className:Ct.dvDateDropdown,children:[h.jsx(b.DatePanel,{defaultValue:y,pickerValue:y,showTime:C||void 0,onSelect:async L=>{w(L)},onPanelChange:L=>{w(L)},disabledDate:L=>!r.numfmt.parseDate(L.format("YYYY-MM-DD"))}),h.jsx("div",{className:Ct.dvDateDropdownBtns,children:h.jsx(b.Button,{size:"small",variant:"primary",onClick:D,disabled:!y.isValid(),children:v.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 o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},le.apply(this,arguments)},on=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 o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(a[n[o]]=e[n[o]]);return a},ve=R.forwardRef(function(e,t){var a=e.icon,n=e.id,o=e.className,i=e.extend,s=on(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),d=R.useRef("_".concat(ln()));return Mt(a,"".concat(n),{defIds:a.defIds,idSuffix:d.current},le({ref:t,className:l},s),i)});function Mt(e,t,a,n,o){return R.createElement(e.tag,le(le({key:t},rn(e,a,o)),n),(sn(e,a).children||[]).map(function(i,s){return Mt(i,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,o)}))}function rn(e,t,a){var n=le({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],l=i[1];s==="mask"&&typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var o=t.defIds;return!o||o.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],l=i[1];typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function sn(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?le(le({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?le(le({},o),{attrs:le(le({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):e}function ln(){return Math.random().toString(36).substring(2,8)}ve.displayName="UniverIcon";var dn={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"}}]},bt=R.forwardRef(function(e,t){return R.createElement(ve,Object.assign({},e,{id:"check-mark-single",ref:t,icon:dn}))});bt.displayName="CheckMarkSingle";var cn={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"}}]},Tt=R.forwardRef(function(e,t){return R.createElement(ve,Object.assign({},e,{id:"data-validation-single",ref:t,icon:cn}))});Tt.displayName="DataValidationSingle";var un={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"}}]},vt=R.forwardRef(function(e,t){return R.createElement(ve,Object.assign({},e,{id:"delete-single",ref:t,icon:un}))});vt.displayName="DeleteSingle";var hn={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"}}]},Lt=R.forwardRef(function(e,t){return R.createElement(ve,Object.assign({},e,{id:"increase-single",ref:t,icon:hn}))});Lt.displayName="IncreaseSingle";var pn={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"}}]},Ot=R.forwardRef(function(e,t){return R.createElement(ve,Object.assign({},e,{id:"more-down-single",ref:t,icon:pn}))});Ot.displayName="MoreDownSingle";var gn={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"}}]},Pt=R.forwardRef(function(e,t){return R.createElement(ve,Object.assign({},e,{id:"more-up-single",ref:t,icon:gn}))});Pt.displayName="MoreUpSingle";var mn={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"}}]}]},At=R.forwardRef(function(e,t){return R.createElement(ve,Object.assign({},e,{id:"sequence-single",ref:t,icon:mn}))});At.displayName="SequenceSingle";var vn=Object.getOwnPropertyDescriptor,fn=(e,t,a,n)=>{for(var o=n>1?void 0:n?vn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Dt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends r.Disposable{constructor(t,a){super();P(this,"_open$",new ie.BehaviorSubject(!1));P(this,"open$",this._open$.pipe(ie.distinctUntilChanged()));P(this,"_activeRule");P(this,"_activeRule$",new ie.BehaviorSubject(void 0));P(this,"activeRule$",this._activeRule$.asObservable());P(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).pipe(ie.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===He&&(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=r.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ue=fn([Dt(0,r.IUniverInstanceService),Dt(1,f.ISidebarService)],ue);function Sn(){const e=f.useDependency(me),t=f.useObservable(e.activeDropdown$,e.activeDropdown),a=f.useDependency(f.ComponentManager);if(!t)return null;const{location:n,componentKey:o}=t,i=a.get(o),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!i)return null;const l=()=>{e.hideDropdown()};return h.jsx(i,{location:n,hideFn:l},s)}const jt="sheet.ui.dropdown";var _n=Object.getOwnPropertyDescriptor,In=(e,t,a,n)=>{for(var o=n>1?void 0:n?_n(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},fe=(e,t)=>(a,n)=>t(a,n,e);let me=class extends r.Disposable{constructor(t,a,n,o,i,s,l){super();P(this,"_activeDropdown");P(this,"_activeDropdown$",new ie.Subject);P(this,"_currentPopup",null);P(this,"activeDropdown$",this._activeDropdown$.asObservable());P(this,"_zenVisible",!1);this._canvasPopupManagerService=t,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=o,this._renderManagerService=i,this._dataValidationModel=s,this._sheetsSelectionsService=l,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,o){const i=t?this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=a?i.getSheetBySheetId(a):i.getActiveSheet();if(!s)return;const l=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,o);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);return d==null?void 0:d.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:o,col:i,unitId:s,subUnitId:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const d=this._renderManagerService.getRenderById(r.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),u=this._canvasPopupManagerService.attachPopupToCell(o,i,{componentKey:jt,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[d==null?void 0:d.engine.getCanvasElement()].filter(Boolean)},s,l);if(!u)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const p=new r.DisposableCollection;p.add(u),p.add({dispose:()=>{var g,c;(c=(g=this._activeDropdown)==null?void 0:g.onHide)==null||c.call(g)}}),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,o,i){const s=this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET);if(!s)return;const l=s.getSheetBySheetId(a);if(!l)return;const d=this._dataValidationModel.getRuleByLocation(s.getUnitId(),l.getSheetId(),n,o);if(!d)return;const u=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!u||!u.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:l,row:n,col:o,unitId:t,subUnitId:a},componentKey:u.dropdown,onHide:i})}};me=In([fe(0,r.Inject($.SheetCanvasPopManagerService)),fe(1,r.IUniverInstanceService),fe(2,r.Inject(Q.DataValidatorRegistryService)),fe(3,f.IZenZoneService),fe(4,U.IRenderManagerService),fe(5,r.Inject(M.SheetDataValidationModel)),fe(6,r.Inject(X.SheetsSelectionsService))],me);const He="DataValidationPanel",De={id:"data-validation.operation.open-validation-panel",type:r.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,o=e.get(ue),i=e.get(Q.DataValidationModel),s=e.get(r.IUniverInstanceService),l=e.get(f.ISidebarService),d=X.getSheetCommandTarget(s);if(!d)return!1;const{unitId:u,subUnitId:p}=d,g=a?i.getRuleById(u,p,a):void 0;o.open(),o.setActiveRule(g&&{unitId:u,subUnitId:p,rule:g});const c=l.open({id:He,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:He},width:312,onClose:()=>o.close()});return o.setCloseDisposable(c),!0}},ft={id:"data-validation.operation.close-validation-panel",type:r.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},Ft={id:"data-validation.operation.toggle-validation-panel",type:r.CommandType.OPERATION,handler(e){const t=e.get(r.ICommandService),a=e.get(ue);return a.open(),a.isOpen?t.executeCommand(ft.id):t.executeCommand(De.id),!0}},qe={type:r.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(me),{unitId:n,subUnitId:o,row:i,column:s}=t,l=a.activeDropdown,d=l==null?void 0:l.location;return d&&d.unitId===n&&d.subUnitId===o&&d.row===i&&d.col===s||a.showDataValidationDropdown(n,o,i,s),!0}},xt={type:r.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(me).hideDropdown(),!0):!1}},Ce="#ECECEC",St="sheets-data-validation-ui.config",Ye={},Cn="univer-dv-list-dropdown",Dn="univer-dv-list-dropdown-title",Vn="univer-dv-list-dropdown-list",yn="univer-dv-list-dropdown-list-container",Rn="univer-dv-list-dropdown-selected-icon",wn="univer-dv-list-dropdown-item-container",En="univer-dv-list-dropdown-item",Mn="univer-dv-list-dropdown-split",bn="univer-dv-list-dropdown-edit",pe={dvListDropdown:Cn,dvListDropdownTitle:Dn,dvListDropdownList:Vn,dvListDropdownListContainer:yn,dvListDropdownSelectedIcon:Rn,dvListDropdownItemContainer:wn,dvListDropdownItem:En,dvListDropdownSplit:Mn,dvListDropdownEdit:bn},Tn=e=>{var C,D;const{value:t,onChange:a,multiple:n,options:o,title:i,onEdit:s,style:l,filter:d,location:u}=e,p=f.useDependency(r.LocaleService),g=f.useDependency(r.IConfigService),c=d==null?void 0:d.toLowerCase(),{row:V,col:m,unitId:w,subUnitId:y}=u,v=o.filter(_=>c?_.label.toLowerCase().includes(c):!0),S=(D=(C=g.getConfig(St))==null?void 0:C.showEditOnDropdown)!=null?D:!0,I=f.useDependency(X.SheetPermissionCheckController),T=R.useMemo(()=>I.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission]},[{startColumn:m,startRow:V,endColumn:m,endRow:V}],w,y),[I,m,V,w,y]);return h.jsxs("div",{className:pe.dvListDropdown,style:l,children:[h.jsx("div",{className:pe.dvListDropdownTitle,children:i}),h.jsx("div",{className:pe.dvListDropdownList,children:h.jsx(b.Scrollbar,{children:h.jsx("div",{className:pe.dvListDropdownListContainer,children:v.map((_,L)=>{const F=t.indexOf(_.value)>-1,W=()=>{let j;F?j=new Set(t.filter(N=>N!==_.value)):j=new Set(n?[...t,_.value]:[_.value]);const x=[];o.forEach(N=>{j.has(N.value)&&x.push(N.value)}),a(x)},A=_.label.toLocaleLowerCase().indexOf(c);return h.jsxs("div",{className:pe.dvListDropdownItemContainer,onClick:W,children:[h.jsx("div",{className:pe.dvListDropdownItem,style:{background:_.color||Ce},children:c&&_.label.toLowerCase().includes(c)?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:_.label.substring(0,A)}),h.jsx("span",{style:{fontWeight:"bold"},children:_.label.substring(A,A+c.length)}),h.jsx("span",{children:_.label.substring(A+c.length)})]}):_.label}),h.jsx("div",{className:pe.dvListDropdownSelectedIcon,children:F?h.jsx(bt,{}):null})]},L)})})},d)}),S&&T?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:pe.dvListDropdownSplit}),h.jsx("div",{className:pe.dvListDropdownEdit,children:h.jsx("a",{onClick:s,children:p.t("dataValidation.list.edit")})})]}):null]})};function Ln(e){var B,H,G,q;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:i,unitId:s,subUnitId:l}=t,d=f.useDependency(Q.DataValidationModel),[u,p]=R.useState(""),g=f.useDependency(r.ICommandService),c=f.useDependency(r.LocaleService),[V,m]=R.useState(""),w=f.useDependency($.IEditorBridgeService),y=f.useDependency(r.IUniverInstanceService),v=R.useMemo(()=>d.ruleChange$.pipe(ie.debounceTime(16)),[]),S=f.useDependency(M.SheetDataValidationModel);f.useObservable(v);const I=f.RectPopup.useContext(),T=((H=(B=I.current)==null?void 0:B.right)!=null?H:0)-((q=(G=I.current)==null?void 0:G.left)!=null?q:0);if(R.useEffect(()=>{const K=g.onCommandExecuted(Z=>{var ee,te;if(Z.id===Zt.RichTextEditingMutation.id){const ne=Z.params,{unitId:re}=ne,oe=y.getUnit(re,r.UniverInstanceType.UNIVER_DOC);if(!oe||!w.isVisible().visible)return;const se=r.BuildTextUtils.transform.getPlainText((te=(ee=oe.getSnapshot().body)==null?void 0:ee.dataStream)!=null?te:"");p(se)}});return()=>{K.dispose()}},[g,w,y]),!n)return null;const C=S.getRuleByLocation(s,l,o,i);if(!C)return null;const D=S.getValidator(C.type);if(!D)return null;const _=n.getCell(o,i),L=(C==null?void 0:C.renderMode)===r.DataValidationRenderMode.CUSTOM||(C==null?void 0:C.renderMode)===void 0;if(!_||!C||!D||D.id.indexOf(r.DataValidationType.LIST)!==0)return;const F=C.type===r.DataValidationType.LIST_MULTIPLE,W=D.getListWithColor(C,s,l),A=V||M.getDataValidationCellValue(n.getCellRaw(o,i)),j=M.deserializeListOptions(A),x=()=>{g.executeCommand(De.id,{ruleId:C.uid}),a()},N=W.map(K=>({label:K.label,value:K.label,color:L||K.color?K.color:"transparent"}));return h.jsx(Tn,{style:{minWidth:T,maxWidth:Math.max(T,200)},title:F?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:j,multiple:F,onChange:async K=>{const Z=M.serializeListOptions(K),ee={unitId:s,subUnitId:l,range:{startColumn:i,endColumn:i,startRow:o,endRow:o},value:{v:Z,p:null,f:null,si:null}};w.isVisible()&&g.executeCommand($.SetCellEditVisibleOperation.id,{visible:!1,eventType:U.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),m(Z),F||a(),w.isVisible().visible&&await g.executeCommand($.SetCellEditVisibleOperation.id,{visible:!1,eventType:U.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),g.executeCommand(X.SetRangeValuesCommand.id,ee)},options:N,onEdit:x,filter:u,location:t})}const On="univer-data-validation-options-button",Pn="univer-data-validation-options-button-icon",et={dataValidationOptionsButton:On,dataValidationOptionsButtonIcon:Pn};function An(e){var u;const t=f.useDependency(r.LocaleService),a=f.useDependency(f.ComponentManager),{value:n,onChange:o,extraComponent:i}=e,[s,l]=R.useState(!1),d=i?a.get(i):null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:et.dataValidationOptionsButton,onClick:()=>l(!s),children:[t.t("dataValidation.panel.options"),s?h.jsx(Pt,{className:et.dataValidationOptionsButtonIcon}):h.jsx(Ot,{className:et.dataValidationOptionsButtonIcon})]}),s&&h.jsxs(h.Fragment,{children:[d?h.jsx(d,{value:n,onChange:o}):null,h.jsx(b.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:h.jsxs(b.RadioGroup,{value:`${(u=n.errorStyle)!=null?u:r.DataValidationErrorStyle.WARNING}`,onChange:p=>o({...n,errorStyle:+p}),children:[h.jsx(b.Radio,{value:`${r.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),h.jsx(b.Radio,{value:`${r.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),h.jsx(b.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:h.jsx(b.Checkbox,{checked:n.showErrorMessage,onChange:()=>o({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?h.jsx(b.FormLayout,{children:h.jsx(b.Input,{value:n.error,onChange:p=>o({...n,error:p})})}):null]})]})}const jn="univer-data-validation-detail",Fn="univer-data-validation-detail-form-item",xn="univer-data-validation-detail-buttons",Un="univer-data-validation-detail-button",ye={dataValidationDetail:jn,dataValidationDetailFormItem:Fn,dataValidationDetailButtons:xn,dataValidationDetailButton:Un},kn=e=>r.debounce(async(t,a,n,o)=>{const i=await e.executeCommand(t,a,n);o==null||o(i)},1e3);function Nn(e,t,a){var n,o,i,s;return t?((o=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:o.getSheetId())||"":((s=(i=e.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Bn(){var se;const[e,t]=R.useState(0),a=f.useDependency(ue),n=f.useObservable(a.activeRule$,a.activeRule),{unitId:o,subUnitId:i,rule:s}=n||{},l=s.uid,d=f.useDependency(Q.DataValidatorRegistryService),u=f.useDependency(r.IUniverInstanceService),p=f.useDependency(f.ComponentManager),g=f.useDependency(r.ICommandService),c=f.useDependency(Q.DataValidationModel),V=f.useDependency(r.LocaleService),[m,w]=R.useState(s),y=d.getValidatorItem(m.type),[v,S]=R.useState(!1),I=d.getValidatorsByScope(Q.DataValidatorRegistryScope.SHEET),[T,C]=R.useState(()=>m.ranges.map(O=>({unitId:"",sheetId:"",range:O}))),D=R.useMemo(()=>kn(g),[g]),[_,L]=R.useState(!1),[F,W]=R.useState(!1),A=R.useRef(null),j=f.useDependency(X.SheetsSelectionsService);if(R.useEffect(()=>()=>{const O=j.getCurrentLastSelection();O&&j.setSelections([O])},[j]),R.useEffect(()=>{g.onCommandExecuted(O=>{(O.id===r.UndoCommand.id||O.id===r.RedoCommand.id)&&setTimeout(()=>{const E=c.getRuleById(o,i,l);t(k=>k+1),E&&(w(E),C(E.ranges.map(k=>({unitId:"",sheetId:"",range:k}))))},20)})},[g,c,l,i,o]),!y)return null;const x=y.operators,N=y.operatorNames,B=m.operator?Q.TWO_FORMULA_OPERATOR_COUNT.includes(m.operator):!1,H=()=>{var O,E,k;(E=(O=A.current)==null?void 0:O.editor)!=null&&E.isFocus()&&G((k=A.current)==null?void 0:k.getValue()),!(!m.ranges.length||_)&&(y.validatorFormula(m,o,i).success?a.setActiveRule(null):S(!0))},G=f.useEvent(O=>{const E=O.split(",").filter(Boolean).map(ct.deserializeRangeWithSheet).map(z=>{const ge=z.sheetName;if(ge){const zt=Nn(u,z.unitId,ge);return{...z,sheetId:zt}}return{...z,sheetId:""}});if(r.isUnitRangesEqual(E,T))return;C(E);const k=E.filter(z=>(!z.unitId||z.unitId===o)&&(!z.sheetId||z.sheetId===i)).map(z=>z.range);if(w({...m,ranges:k}),k.length===0)return;const Y={unitId:o,subUnitId:i,ruleId:l,ranges:k};D(M.UpdateSheetDataValidationRangeCommand.id,Y)}),q=O=>{if(r.shallowEqual(O,Q.getRuleSetting(m)))return;w({...m,...O});const E={unitId:o,subUnitId:i,ruleId:l,setting:O};D(M.UpdateSheetDataValidationSettingCommand.id,E,void 0)},K=async()=>{await g.executeCommand(M.RemoveSheetDataValidationCommand.id,{ruleId:l,unitId:o,subUnitId:i}),a.setActiveRule(null)},Z={type:m.type,operator:m.operator,formula1:m.formula1,formula2:m.formula2,allowBlank:m.allowBlank},ee=O=>{const E=d.getValidatorItem(O);if(!E)return;const k=E.operators,Y=c.getRuleById(o,i,l),z=O===(Y==null?void 0:Y.type)||O.includes("list")&&(Y!=null&&Y.type.includes("list"))?{...Y,type:O}:{...m,type:O,operator:k[0],formula1:void 0,formula2:void 0};w(z),g.executeCommand(M.UpdateSheetDataValidationSettingCommand.id,{unitId:o,subUnitId:i,ruleId:m.uid,setting:Q.getRuleSetting(z)})},te=p.get(y.formulaInput),ne=R.useMemo(()=>T.map(O=>ct.serializeRange(O.range)).join(","),[]),re=Q.getRuleOptions(m),oe=O=>{r.shallowEqual(O,Q.getRuleOptions(m))||(w({...m,...O}),D(M.UpdateSheetDataValidationOptionsCommand.id,{unitId:o,subUnitId:i,ruleId:l,options:O}))};return h.jsxs("div",{className:ye.dataValidationDetail,children:[h.jsx(b.FormLayout,{label:V.t("dataValidation.panel.range"),error:!m.ranges.length||_?V.t("dataValidation.panel.rangeError"):"",children:h.jsx(mt.RangeSelector,{selectorRef:A,unitId:o,subUnitId:i,initialValue:ne,onChange:(O,E)=>{var k;!F&&((k=A.current)!=null&&k.verify())&&G(E)},onFocusChange:(O,E)=>{var k;W(O),!O&&E&&((k=A.current)!=null&&k.verify())&&G(E)},onVerify:O=>L(!O)})}),h.jsx(b.FormLayout,{label:V.t("dataValidation.panel.type"),children:h.jsx(b.Select,{options:I==null?void 0:I.map(O=>({label:V.t(O.title),value:O.id})),value:m.type,onChange:ee,className:ye.dataValidationDetailFormItem})}),x!=null&&x.length?h.jsx(b.FormLayout,{label:V.t("dataValidation.panel.operator"),children:h.jsx(b.Select,{options:x.map((O,E)=>({value:`${O}`,label:N[E]})),value:`${m.operator}`,onChange:O=>{q({...Z,operator:O})},className:ye.dataValidationDetailFormItem})}):null,te?h.jsx(b.FormLayout,{children:h.jsx(te,{isTwoFormula:B,value:{formula1:m.formula1,formula2:m.formula2},onChange:O=>{q({...Z,...O})},showError:v,validResult:y.validatorFormula(m,o,i),unitId:o,subUnitId:i,ruleId:l},e+m.type)}):null,h.jsx(b.FormLayout,{children:h.jsx(b.Checkbox,{checked:(se=m.allowBlank)!=null?se:!0,onChange:()=>{var O;return q({...Z,allowBlank:!((O=m.allowBlank)==null||O)})},children:V.t("dataValidation.panel.allowBlank")})}),h.jsx(An,{value:re,onChange:oe,extraComponent:y.optionsInput}),h.jsxs("div",{className:ye.dataValidationDetailButtons,children:[h.jsx(b.Button,{className:ye.dataValidationDetailButton,onClick:K,children:V.t("dataValidation.panel.removeRule")}),h.jsx(b.Button,{className:ye.dataValidationDetailButton,variant:"primary",onClick:H,children:V.t("dataValidation.panel.done")})]})]})}const Wn="univer-data-validation-item-container",$n="univer-data-validation-item-title",Hn="univer-data-validation-item-content",Yn="univer-data-validation-item-icon",Fe={dataValidationItemContainer:Wn,dataValidationItemTitle:$n,dataValidationItemContent:Hn,dataValidationItemIcon:Yn},Xn=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:o,disable:i}=e,s=f.useDependency(Q.DataValidatorRegistryService),l=f.useDependency(r.ICommandService),d=f.useDependency($.IMarkSelectionService),u=s.getValidatorItem(t.type),p=R.useRef(void 0),[g,c]=R.useState(!1),V=f.useDependency(r.ThemeService),m=f.useObservable(V.currentTheme$),w=R.useMemo(()=>{var I;const v=(I=m==null?void 0:m.loopColor2)!=null?I:"#49B811",S=new r.ColorKit(v).toRgb();return{fill:`rgba(${S.r}, ${S.g}, ${S.b}, 0.1)`,stroke:v}},[m]),y=v=>{l.executeCommand(M.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:o}),v.stopPropagation()};return R.useEffect(()=>()=>{var v;p.current&&((v=p.current)==null||v.forEach(S=>{S&&d.removeShape(S)}))},[d]),h.jsxs("div",{className:Fe.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{i||(c(!0),p.current=t.ranges.map(v=>d.addShape({range:v,style:w,primary:null})))},onMouseLeave:()=>{var v;c(!1),(v=p.current)==null||v.forEach(S=>{S&&d.removeShape(S)}),p.current=void 0},children:[h.jsx("div",{className:Fe.dataValidationItemTitle,children:u==null?void 0:u.generateRuleName(t)}),h.jsx("div",{className:Fe.dataValidationItemContent,children:t.ranges.map(v=>ct.serializeRange(v)).join(",")}),g?h.jsx("div",{className:Fe.dataValidationItemIcon,onClick:y,children:h.jsx(vt,{})}):null]})},zn="univer-data-validation-list",Kn="univer-data-validation-list-buttons",Gn="univer-data-validation-list-button",xe={dataValidationList:zn,dataValidationListButtons:Kn,dataValidationListButton:Gn};function qn(e){const t=f.useDependency(M.SheetDataValidationModel),a=f.useDependency(r.IUniverInstanceService),n=f.useDependency(r.ICommandService),o=f.useDependency(r.Injector),i=f.useDependency(ue),s=f.useDependency(r.LocaleService),[l,d]=R.useState([]),{workbook:u}=e,p=f.useObservable(u.activeSheet$,void 0,!0),g=u.getUnitId(),c=p==null?void 0:p.getSheetId();R.useEffect(()=>{d(t.getRules(g,c));const S=t.ruleChange$.subscribe(I=>{I.unitId===g&&I.subUnitId===c&&d(t.getRules(g,c))});return()=>{S.unsubscribe()}},[g,c,t]);const V=async()=>{const S=M.createDefaultNewRule(o),I={unitId:g,subUnitId:c,rule:S};await n.executeCommand(M.AddSheetDataValidationCommand.id,I),i.setActiveRule({unitId:g,subUnitId:c,rule:S})},m=()=>{n.executeCommand(M.RemoveSheetAllDataValidationCommand.id,{unitId:g,subUnitId:c})},y=(S=>{const I=a.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET),T=I.getActiveSheet(),C=I.getUnitId(),D=T.getSheetId();return S.map(L=>X.checkRangesEditablePermission(o,C,D,L.ranges)?{...L}:{...L,disable:!0})})(l),v=y==null?void 0:y.some(S=>S.disable);return h.jsxs("div",{className:xe.dataValidationList,children:[y==null?void 0:y.map(S=>{var I;return h.jsx(Xn,{unitId:g,subUnitId:c,onClick:()=>{S.disable||i.setActiveRule({unitId:g,subUnitId:c,rule:S})},rule:S,disable:(I=S.disable)!=null?I:!1},S.uid)}),h.jsxs("div",{className:xe.dataValidationListButtons,children:[l.length&&!v?h.jsx(b.Button,{className:xe.dataValidationListButton,onClick:m,children:s.t("dataValidation.panel.removeAll")}):null,h.jsx(b.Button,{className:xe.dataValidationListButton,variant:"primary",onClick:V,children:s.t("dataValidation.panel.add")})]})]})}const Zn=()=>{const e=f.useDependency(ue),t=f.useObservable(e.activeRule$,e.activeRule),a=f.useDependency(r.IUniverInstanceService),n=f.useObservable(()=>a.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),o=f.useObservable(()=>{var i;return(i=n==null?void 0:n.activeSheet$)!=null?i:ie.of(null)},void 0,void 0,[]);return!n||!o?null:t&&t.subUnitId===o.getSheetId()?h.jsx(Bn,{},t.rule.uid):h.jsx(qn,{workbook:n})},Ze="data-validation.list.dropdown",_t="data-validation.date.dropdown",Je={type:r.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(r.IUniverInstanceService),a=X.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:o}=a,i=M.createDefaultNewRule(e),s=e.get(r.ICommandService),l=n.getUnitId(),d=o.getSheetId(),u={rule:i,unitId:l,subUnitId:d};return s.syncExecuteCommand(M.AddSheetDataValidationCommand.id,u)?(s.syncExecuteCommand(De.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var Jn=Object.getOwnPropertyDescriptor,Qn=(e,t,a,n)=>{for(var o=n>1?void 0:n?Jn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Re=(e,t)=>(a,n)=>t(a,n,e);const Se="SHEET_DATA_VALIDATION_ALERT";let je=class extends r.Disposable{constructor(e,t,a,n,o,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=o,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ie.debounceTime(100)).subscribe(e=>{var t;if(e){const a=this._univerInstanceService.getUnit(e.location.unitId,r.UniverInstanceType.UNIVER_SHEET),n=a.getSheetBySheetId(e.location.subUnitId);if(!n)return;const o=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!o){this._cellAlertManagerService.removeAlert(Se);return}if(this._dataValidationModel.validator(o,{...e.location,workbook:a,worksheet:n})===r.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Se),l=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(l&&l.row===e.location.row&&l.col===e.location.col&&l.subUnitId===e.location.subUnitId&&l.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(Se);return}const d=this._dataValidationModel.getValidator(o.type);if(!d){this._cellAlertManagerService.removeAlert(Se);return}this._cellAlertManagerService.showAlert({type:$.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:d==null?void 0:d.getRuleFinalError(o,e.location),location:e.location,width:200,height:74,key:Se});return}}this._cellAlertManagerService.removeAlert(Se)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(Se)}))}};je=Qn([Re(0,r.Inject($.HoverManagerService)),Re(1,r.Inject($.CellAlertManagerService)),Re(2,r.IUniverInstanceService),Re(3,r.Inject(r.LocaleService)),Re(4,f.IZenZoneService),Re(5,r.Inject(M.SheetDataValidationModel))],je);var ea=Object.getOwnPropertyDescriptor,ta=(e,t,a,n)=>{for(var o=n>1?void 0:n?ea(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},tt=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends r.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,o)=>{const{source:i,target:s,unitId:l,subUnitId:d}=n,u=this._sheetDataValidationModel.getRuleObjectMatrix(l,d).clone(),p=$.virtualizeDiscreteRanges([i,s]),[g,c]=p.ranges,{mapFunc:V}=p,m={row:g.startRow,col:g.startColumn},w=$.getAutoFillRepeatRange(g,c),y=new r.ObjectMatrix,v=new Set;w.forEach(D=>{const _=D.repeatStartCell,L=D.relativeRange,F={startRow:m.row,startColumn:m.col,endColumn:m.col,endRow:m.row},W={startRow:_.row,startColumn:_.col,endColumn:_.col,endRow:_.row};r.Range.foreach(L,(A,j)=>{const x=r.Rectangle.getPositionRange({startRow:A,startColumn:j,endColumn:j,endRow:A},F),{row:N,col:B}=V(x.startRow,x.startColumn),H=this._sheetDataValidationModel.getRuleIdByLocation(l,d,N,B)||"",G=r.Rectangle.getPositionRange({startRow:A,startColumn:j,endColumn:j,endRow:A},W),{row:q,col:K}=V(G.startRow,G.startColumn);y.setValue(q,K,H),v.add(H)})});const S=Array.from(v).map(D=>({id:D,ranges:r.queryObjectMatrix(y,_=>_===D)}));u.addRangeRules(S);const I=u.diff(this._sheetDataValidationModel.getRules(l,d)),{redoMutations:T,undoMutations:C}=M.getDataValidationDiffMutations(l,d,I,this._injector,"patched",o===$.APPLY_TYPE.ONLY_FORMAT);return{undos:C,redos:T}},a={id:M.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:o,unitId:i,subUnitId:s}=n;for(const l of o.rows)for(const d of o.cols){const u=this._sheetDataValidationModel.getRuleByLocation(i,s,l,d);if(u&&u.type===r.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType($.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,o,i)=>i===$.APPLY_TYPE.COPY||i===$.APPLY_TYPE.ONLY_FORMAT||i===$.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};Me=ta([tt(0,$.IAutoFillService),tt(1,r.Inject(M.SheetDataValidationModel)),tt(2,r.Inject(r.Injector))],Me);var na=Object.getOwnPropertyDescriptor,aa=(e,t,a,n)=>{for(var o=n>1?void 0:n?na(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},nt=(e,t)=>(a,n)=>t(a,n,e);let be=class extends r.Disposable{constructor(t,a,n){super();P(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:M.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,o)=>{const{copyType:i=$.COPY_TYPE.COPY,pasteType:s}=o,{range:l}=t||{},{range:d,unitId:u,subUnitId:p}=a;return this._generateMutations(d,{copyType:i,pasteType:s,copyRange:l,unitId:u,subUnitId:p})}})}_collect(t,a,n){const o=new r.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:o};const i=this._injector.invoke(d=>X.rangeToDiscreteRange(n,d,t,a));if(!i)return;const{rows:s,cols:l}=i;s.forEach((d,u)=>{l.forEach((p,g)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(t,a,d,p);o.setValue(u,g,c!=null?c:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===$.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:o,subUnitId:i}=this._copyInfo;if(a.unitId!==o||i!==a.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),l=new r.ObjectMatrix,d=new Set,{ranges:[u,p],mapFunc:g}=$.virtualizeDiscreteRanges([a.copyRange,t]),c=$.getRepeatRange(u,p,!0),V=new Map;c.forEach(({startRange:v})=>{var S;(S=this._copyInfo)==null||S.matrix.forValue((I,T,C)=>{const D=r.Rectangle.getPositionRange({startRow:I,endRow:I,startColumn:T,endColumn:T},v),_=`${i}-${C}`,L=this._sheetDataValidationModel.getRuleById(o,i,C);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,_)&&L&&V.set(_,{...L,uid:_});const{row:F,col:W}=g(D.startRow,D.startColumn);d.add(_),l.setValue(F,W,_)})});const m=Array.from(d).map(v=>({id:v,ranges:r.queryObjectMatrix(l,S=>S===v)}));s.addRangeRules(m);const{redoMutations:w,undoMutations:y}=M.getDataValidationDiffMutations(a.unitId,a.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),V.values()),this._injector,"patched",!1);return{redos:w,undos:y}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(o,i).clone(),l=new r.ObjectMatrix,d=new Set,{ranges:[u,p],mapFunc:g}=$.virtualizeDiscreteRanges([a.copyRange,t]);$.getRepeatRange(u,p,!0).forEach(({startRange:y})=>{var v;(v=this._copyInfo)==null||v.matrix.forValue((S,I,T)=>{const C=r.Rectangle.getPositionRange({startRow:S,endRow:S,startColumn:I,endColumn:I},y),{row:D,col:_}=g(C.startRow,C.startColumn);l.setValue(D,_,T),d.add(T)})});const V=Array.from(d).map(y=>({id:y,ranges:r.queryObjectMatrix(l,v=>v===y)}));s.addRangeRules(V);const{redoMutations:m,undoMutations:w}=M.getDataValidationDiffMutations(o,i,s.diff(this._sheetDataValidationModel.getRules(o,i)),this._injector,"patched",!1);return{redos:m,undos:w}}}};be=aa([nt(0,$.ISheetClipboardService),nt(1,r.Inject(M.SheetDataValidationModel)),nt(2,r.Inject(r.Injector))],be);var oa=Object.getOwnPropertyDescriptor,ia=(e,t,a,n)=>{for(var o=n>1?void 0:n?oa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},at=(e,t)=>(a,n)=>t(a,n,e);let Te=class extends r.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===M.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission,X.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===M.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission,X.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Te=ia([at(0,r.Inject(r.LocaleService)),at(1,r.ICommandService),at(2,r.Inject(X.SheetPermissionCheckController))],Te);const Ut="data-validation-single",kt="sheet.menu.data-validation";function ra(e){return{id:kt,type:f.MenuItemType.SUBITEMS,icon:Ut,tooltip:"dataValidation.title",hidden$:f.getMenuHiddenObservable(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:$.getCurrentRangeDisable$(e,{workbookTypes:[X.WorkbookEditablePermission],worksheetTypes:[X.WorksheetSetCellStylePermission,X.WorksheetEditPermission],rangeTypes:[X.RangeProtectionPermissionEditPoint]})}}function sa(e){return{id:De.id,title:"dataValidation.panel.title",type:f.MenuItemType.BUTTON}}function la(e){return{id:Je.id,title:"dataValidation.panel.add",type:f.MenuItemType.BUTTON}}const da={[f.RibbonStartGroup.FORMULAS_INSERT]:{[kt]:{order:9,menuItemFactory:ra,[De.id]:{order:0,menuItemFactory:sa},[Je.id]:{order:1,menuItemFactory:la}}}};var ca=Object.getOwnPropertyDescriptor,Nt=(e,t,a,n)=>{for(var o=n>1?void 0:n?ca(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},J=(e,t)=>(a,n)=>t(a,n,e);const Bt={tr:{size:6,color:"#fe4b4b"}};let Le=class extends r.RxDisposable{constructor(e,t,a,n,o,i,s,l,d,u,p){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=o,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=l,this._sheetInterceptorService=d,this._dataValidationCacheService=u,this._editorBridgeService=p,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(da)}_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:o,row:i,column:s}=t,l=this._univerInstanceService.getUniverSheetInstance(n);if(!l)return;const d=this._sheetDataValidationModel.getRuleByLocation(n,o,i,s);if(!d)return;const u=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!(u!=null&&u.dropdown))return;const p=l.getActiveSheet();if(!p)return;const g=this._dropdownManagerService.activeDropdown,c=g==null?void 0:g.location;if(c&&c.unitId===n&&c.subUnitId===o&&c.row===i&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:o,row:i,col:s,workbook:l,worksheet:p},componentKey:u.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var v,S,I,T,C;const{row:n,col:o,unitId:i,subUnitId:s,workbook:l,worksheet:d}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,o);if(!u)return a(e);const p=this._sheetDataValidationModel.getRuleById(i,s,u);if(!p)return a(e);const g=(v=this._dataValidationCacheService.getValue(i,s,n,o))!=null?v:r.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),V=t.rawData;let m;const w={get value(){var D;return m!==void 0||(m=(D=M.getCellValueOrigin(V))!=null?D:null),m}},y={get value(){var D;return`${(D=w.value)!=null?D:""}`}};return a({...e,markers:{...e==null?void 0:e.markers,...g===r.DataValidationStatus.INVALID?Bt:null},customRender:[...(S=e==null?void 0:e.customRender)!=null?S:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((I=e==null?void 0:e.fontRenderExtension)==null?void 0:I.isSkip)||((T=c==null?void 0:c.skipDefaultFontRender)==null?void 0:T.call(c,p,w.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,y.value,{get style(){const D=l.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,o)},interceptorAutoHeight:()=>{var F,W,A,j,x,N;const D=(W=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with($.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!D)return;const _=D.worksheet.getMergedCell(n,o),L={data:e,style:D.getStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex((A=_==null?void 0:_.startRow)!=null?A:n,(j=_==null?void 0:_.startColumn)!=null?j:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(N=(x=c==null?void 0:c.canvasRender)==null?void 0:x.calcCellAutoHeight)==null?void 0:N.call(x,L)},interceptorAutoWidth:()=>{var F,W,A,j,x,N;const D=(W=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with($.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!D)return;const _=D.worksheet.getMergedCell(n,o),L={data:e,style:D.getStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex((A=_==null?void 0:_.startRow)!=null?A:n,(j=_==null?void 0:_.startColumn)!=null?j:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(N=(x=c==null?void 0:c.canvasRender)==null?void 0:x.calcCellAutoWidth)==null?void 0:N.call(x,L)},coverable:((C=e==null?void 0:e.coverable)!=null?C:!0)&&!(p.type===r.DataValidationType.LIST||p.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(a=>{var n;(a.rule.type===r.DataValidationType.LIST_MULTIPLE||a.rule.type===r.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(a.redos,this._commandService)}})}};Le=Nt([J(0,r.ICommandService),J(1,f.IMenuManagerService),J(2,U.IRenderManagerService),J(3,r.IUniverInstanceService),J(4,r.Inject($.AutoHeightController)),J(5,r.Inject(me)),J(6,r.Inject(M.SheetDataValidationModel)),J(7,r.Inject(Q.DataValidatorRegistryService)),J(8,r.Inject(X.SheetInterceptorService)),J(9,r.Inject(M.DataValidationCacheService)),J(10,r.Optional($.IEditorBridgeService))],Le);let Vt=class extends r.RxDisposable{constructor(e,t,a,n,o,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=o,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var y,v,S,I,T;const{row:n,col:o,unitId:i,subUnitId:s,workbook:l,worksheet:d}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,o);if(!u)return a(e);const p=this._sheetDataValidationModel.getRuleById(i,s,u);if(!p)return a(e);const g=(y=this._dataValidationCacheService.getValue(i,s,n,o))!=null?y:r.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),V=d.getCellRaw(n,o),m=M.getCellValueOrigin(V),w=`${m!=null?m:""}`;return a({...e,markers:{...e==null?void 0:e.markers,...g===r.DataValidationStatus.INVALID?Bt:null},customRender:[...(v=e==null?void 0:e.customRender)!=null?v:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((S=e==null?void 0:e.fontRenderExtension)==null?void 0:S.isSkip)||((I=c==null?void 0:c.skipDefaultFontRender)==null?void 0:I.call(c,p,m,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,w,{get style(){const C=l.getStyles();return(typeof(e==null?void 0:e.s)=="string"?C.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,o)},interceptorAutoHeight:()=>{var L,F,W,A,j,x;const C=(F=(L=this._renderManagerService.getRenderById(i))==null?void 0:L.with($.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:F.skeleton;if(!C)return;const D=C.worksheet.getMergedCell(n,o),_={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((W=D==null?void 0:D.startRow)!=null?W:n,(A=D==null?void 0:D.startColumn)!=null?A:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(x=(j=c==null?void 0:c.canvasRender)==null?void 0:j.calcCellAutoHeight)==null?void 0:x.call(j,_)},coverable:((T=e==null?void 0:e.coverable)!=null?T:!0)&&!(p.type===r.DataValidationType.LIST||p.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.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);r.sequenceExecute(a.redos,this._commandService)}})}};Vt=Nt([J(0,r.ICommandService),J(1,U.IRenderManagerService),J(2,r.Inject($.AutoHeightController)),J(3,r.Inject(Q.DataValidatorRegistryService)),J(4,r.Inject(X.SheetInterceptorService)),J(5,r.Inject(M.SheetDataValidationModel)),J(6,r.Inject(M.DataValidationCacheService))],Vt);var ua=Object.getOwnPropertyDescriptor,ha=(e,t,a,n)=>{for(var o=n>1?void 0:n?ua(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},yt=(e,t)=>(a,n)=>t(a,n,e);let Xe=class extends r.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(o=>{a.add(o.subUnitId)}),a.forEach(o=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(o))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(r.bufferDebounceTime(16)).subscribe(e))}};Xe=ha([yt(1,r.Inject(M.SheetDataValidationModel)),yt(2,r.Inject($.SheetSkeletonManagerService))],Xe);const pa="univer-data-validation-formula",ga="univer-data-validation-formula-and",ma="univer-data-validation-formula-list-item",va="univer-data-validation-formula-list-item-icon",fa="univer-data-validation-formula-list-item-drag",Sa="univer-data-validation-formula-list-add",_a="univer-data-validation-formula-color-select",Ia="univer-data-validation-formula-color-select-panel",Ca="univer-data-validation-formula-color-item",ae={dataValidationFormula:pa,dataValidationFormulaAnd:ga,dataValidationFormulaListItem:ma,dataValidationFormulaListItemIcon:va,dataValidationFormulaListItemDrag:fa,dataValidationFormulaListAdd:Sa,dataValidationFormulaColorSelect:_a,dataValidationFormulaColorSelectPanel:Ia,dataValidationFormulaColorItem:Ca},Da=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:o,validResult:i}=e,s=f.useDependency(r.LocaleService),l=o?i==null?void 0:i.formula1:"",d=o?i==null?void 0:i.formula2:"";return t?h.jsxs(h.Fragment,{children:[h.jsx(b.FormLayout,{error:l,children:h.jsx(b.Input,{className:ae.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:ae.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),h.jsx(b.FormLayout,{error:d,children:h.jsx(b.Input,{className:ae.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:u=>{n==null||n({...a,formula2:u})}})})]}):h.jsx(b.FormLayout,{error:l,children:h.jsx(b.Input,{className:ae.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({formula1:u})}})})};function Va(e){const{value:t,onChange:a,showError:n,validResult:o}=e,i=f.useDependency(r.LocaleService),s=n?o==null?void 0:o.formula1:"",l=n?o==null?void 0:o.formula2:"",[d,u]=R.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(b.FormLayout,{children:h.jsx(b.Checkbox,{checked:d,onChange:p=>{p?u(!0):(u(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),d?h.jsx(b.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:h.jsx(b.Input,{className:ae.dataValidationFormula,placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:p=>{a==null||a({...t,formula1:p||void 0})}})}):null,d?h.jsx(b.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:l,children:h.jsx(b.Input,{className:ae.dataValidationFormula,placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:p=>{a==null||a({...t,formula2:p||void 0})}})}):null]})}function ya(e){var g;const{unitId:t,subUnitId:a,value:n,onChange:o,showError:i,validResult:s}=e,l=i?s==null?void 0:s.formula1:void 0,d=R.useRef(null),[u,p]=R.useState(!1);return f.useSidebarClick(c=>{var m;((m=d.current)==null?void 0:m.isClickOutSide(c))&&p(!1)}),h.jsx(mt.FormulaEditor,{initValue:(g=n==null?void 0:n.formula1)!=null?g:"=",unitId:t,subUnitId:a,isFocus:u,onChange:c=>{const V=(c!=null?c:"").trim();V!==(n==null?void 0:n.formula1)&&(o==null||o({...n,formula1:V}))},errorText:l,onFocus:()=>p(!0),isSupportAcrossSheet:!0,ref:d})}const Ra=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],wa=e=>{const{value:t,onChange:a,disabled:n}=e,[o,i]=R.useState(!1);return h.jsx(b.Select,{disabled:n,open:o,onDropdownVisibleChange:i,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ae.dataValidationFormulaColorSelect,value:t,onChange:a,labelRender:s=>h.jsx("div",{className:ae.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>h.jsx("div",{className:ae.dataValidationFormulaColorSelectPanel,children:Ra.map(s=>h.jsx("div",{onClick:()=>{a(s),i(!1)},className:ae.dataValidationFormulaColorItem,style:{background:s}},s))})})},Rt=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:o,onItemDelete:i}=a;return h.jsxs("div",{className:ae.dataValidationFormulaListItem,style:n,children:[t.isRef?null:h.jsx("div",{className:b.clsx(ae.dataValidationFormulaListItemDrag,"draggableHandle"),children:h.jsx(At,{})}),h.jsx(wa,{value:t.color,onChange:s=>{o(t.id,t.label,s)}}),h.jsx(b.Input,{disabled:t.isRef,value:t.label,onChange:s=>{o(t.id,s,t.color)}}),t.isRef?null:h.jsx("div",{className:ae.dataValidationFormulaListItemIcon,children:h.jsx(vt,{onClick:()=>i(t.id)})})]})};function Ea(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:o,validResult:i,showError:s,ruleId:l}=e,{formula1:d="",formula2:u=""}=t||{},p=R.useRef(null),[g,c]=R.useState(()=>r.isFormulaString(d)?"1":"0"),[V,m]=R.useState(g==="1"?d:"="),[w,y]=R.useState(g==="1"?d:"="),v=f.useDependency(r.LocaleService),S=f.useDependency(Q.DataValidatorRegistryService),I=f.useDependency(Q.DataValidationModel),T=f.useDependency(M.DataValidationFormulaController),[C,D]=R.useState(()=>u.split(",")),_=S.getValidatorItem(r.DataValidationType.LIST),[L,F]=R.useState([]),[W,A]=R.useState(""),j=s?i==null?void 0:i.formula1:"",x=R.useMemo(()=>I.ruleChange$.pipe(ie.debounceTime(16)),[]),N=f.useObservable(x),B=f.useEvent(a);R.useEffect(()=>{(async()=>{await new Promise(Y=>{setTimeout(()=>Y(!0),100)});const E=I.getRuleById(n,o,l),k=E==null?void 0:E.formula1;if(r.isFormulaString(k)&&_&&E){const Y=await _.getListAsync(E,n,o);F(Y)}})()},[I,N,_,l,o,n]),R.useEffect(()=>{r.isFormulaString(d)&&d!==w&&(m(d),y(w))},[w,d]);const[H,G]=R.useState(()=>{const E=g!=="1"?M.deserializeListOptions(d):[],k=u.split(",");return E.map((Y,z)=>({label:Y,color:k[z]||Ce,isRef:!1,id:r.Tools.generateRandomId(4)}))}),q=(E,k,Y)=>{const z=H.find(ge=>ge.id===E);z&&(z.label=k,z.color=Y,G([...H]))},K=E=>{const k=H.findIndex(Y=>Y.id===E);k!==-1&&(H.splice(k,1),G([...H]))},Z=u.split(","),ee=R.useMemo(()=>L.map((E,k)=>({label:E,color:Z[k]||Ce,id:`${k}`,isRef:!0})),[Z,L]),te=(E,k,Y)=>{const z=[...C];z[+E]=Y,D(z),B({formula1:d,formula2:z.join(",")})},ne=()=>{G([...H,{label:"",color:Ce,isRef:!1,id:r.Tools.generateRandomId(4)}])};R.useEffect(()=>{if(g==="1")return;const E=new Set,k=[];H.map(Y=>({labelList:Y.label.split(","),item:Y})).forEach(({item:Y,labelList:z})=>{z.forEach(ge=>{E.has(ge)||(E.add(ge),k.push({label:ge,color:Y.color}))})}),B({formula1:M.serializeListOptions(k.map(Y=>Y.label)),formula2:k.map(Y=>Y.color===Ce?"":Y.color).join(",")})},[H,B,g,w,C]);const re=f.useEvent(async E=>{if(!r.isFormulaString(E)){B==null||B({formula1:"",formula2:u});return}T.getFormulaRefCheck(E)?(B==null||B({formula1:r.isFormulaString(E)?E:"",formula2:u}),A("")):(B==null||B({formula1:"",formula2:u}),m("="),A(v.t("dataValidation.validFail.formulaError")))}),oe=R.useRef(null),[se,O]=R.useState(!1);return f.useSidebarClick(E=>{var Y;((Y=oe.current)==null?void 0:Y.isClickOutSide(E))&&O(!1)}),h.jsxs(h.Fragment,{children:[h.jsx(b.FormLayout,{label:v.t("dataValidation.list.options"),children:h.jsxs(b.RadioGroup,{value:g,onChange:E=>{c(E),m(w),E==="1"&&B({formula1:w==="="?"":w,formula2:C.join(",")})},children:[h.jsx(b.Radio,{value:"0",children:v.t("dataValidation.list.customOptions")}),h.jsx(b.Radio,{value:"1",children:v.t("dataValidation.list.refOptions")})]})}),g==="1"?h.jsxs(h.Fragment,{children:[h.jsx(mt.FormulaEditor,{initValue:V,unitId:n,subUnitId:o,isFocus:se,onChange:(E="")=>{const k=(E!=null?E:"").trim();y(k),re(k)},errorText:j||W||void 0,onFocus:()=>O(!0),isSupportAcrossSheet:!0,ref:oe}),h.jsx("div",{ref:p,style:{marginTop:"12px"},children:ee.map(E=>h.jsx(Rt,{item:E,commonProps:{onItemChange:te},style:{marginBottom:12}},E.id))})]}):h.jsx(b.FormLayout,{error:j,children:h.jsxs("div",{ref:p,style:{marginTop:"-12px"},children:[h.jsx(b.DraggableList,{list:H,onListChange:G,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:E=>h.jsx(Rt,{item:E,commonProps:{onItemChange:q,onItemDelete:K}},E.id),idKey:"id"}),h.jsxs("a",{className:ae.dataValidationFormulaListAdd,onClick:ne,children:[h.jsx(Lt,{}),v.t("dataValidation.list.add")]})]})})]})}const Wt="data-validation.custom-formula-input",Qe="data-validation.formula-input",It="data-validation.list-formula-input",$t="data-validation.checkbox-formula-input",Ma=[[Wt,ya],[Qe,Da],[It,Ea],[$t,Va]],ba="LIST_RENDER_MODE_OPTION_INPUT";function ze(e){var o;const{value:t,onChange:a}=e,n=f.useDependency(r.LocaleService);return h.jsx(b.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:h.jsxs(b.RadioGroup,{value:`${(o=t.renderMode)!=null?o:r.DataValidationRenderMode.CUSTOM}`,onChange:i=>a({...t,renderMode:+i}),children:[h.jsx(b.Radio,{value:`${r.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),h.jsx(b.Radio,{value:`${r.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),h.jsx(b.Radio,{value:`${r.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}ze.componentKey=ba;const Ta="DATE_SHOW_TIME_OPTION";function Ke(e){var o;const{value:t,onChange:a}=e,n=f.useDependency(r.LocaleService);return h.jsx(b.FormLayout,{children:h.jsx(b.Checkbox,{checked:(o=t.bizInfo)==null?void 0:o.showTime,onChange:i=>{a({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:n.t("dataValidation.showTime.label")})})}Ke.componentKey=Ta;var La=Object.getOwnPropertyDescriptor,Oa=(e,t,a,n)=>{for(var o=n>1?void 0:n?La(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},we=(e,t)=>(a,n)=>t(a,n,e);const Ue=6;let ut=class{constructor(e,t,a,n,o,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=a,this._themeService=n,this._renderManagerService=o,this._dataValidationModel=i}_calc(e,t){var u,p,g;const{vt:a,ht:n}=t||{},o=e.endX-e.startX-Ue*2,i=e.endY-e.startY,s=((u=t==null?void 0:t.fs)!=null?u:10)*1.6;let l=0,d=0;switch(a){case r.VerticalAlign.TOP:d=0;break;case r.VerticalAlign.BOTTOM:d=0+(i-s);break;default:d=0+(i-s)/2;break}switch(n){case r.HorizontalAlign.LEFT:l=Ue;break;case r.HorizontalAlign.RIGHT:l=Ue+(o-s);break;default:l=Ue+(o-s)/2;break}return{left:e.startX+l,top:e.startY+d,width:((p=t==null?void 0:t.fs)!=null?p:10)*1.6,height:((g=t==null?void 0:t.fs)!=null?g:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var u,p,g,c,V,m,w,y,v;const{formula1:n=M.CHECKBOX_FORMULA_1,formula2:o=M.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=M.getFormulaResult((g=(p=(u=i==null?void 0:i[0])==null?void 0:u.result)==null?void 0:p[0])==null?void 0:g[0]),l=M.getFormulaResult((m=(V=(c=i==null?void 0:i[1])==null?void 0:c.result)==null?void 0:V[0])==null?void 0:m[0]),d=M.isLegalFormulaResult(String(s))&&M.isLegalFormulaResult(String(l));return{formula1:r.isFormulaString(n)?M.getFormulaResult((v=(y=(w=i==null?void 0:i[0])==null?void 0:w.result)==null?void 0:y[0])==null?void 0:v[0]):n,formula2:r.isFormulaString(o)?l:o,isFormulaValid:d}}drawWith(e,t){var j,x,N,B;const{style:a,primaryWithCoord:n,unitId:o,subUnitId:i,worksheet:s,row:l,col:d}=t,u=n.isMergedMainCell?n.mergeInfo:n,p=M.getCellValueOrigin(s.getCellRaw(l,d)),g=this._dataValidationModel.getRuleByLocation(o,i,l,d);if(!g)return;const c=this._dataValidationModel.getValidator(g.type);if(!c)return;const V=this._themeService.getCurrentTheme();if(!((j=c.skipDefaultFontRender)!=null&&j.call(c,g,p,{unitId:o,subUnitId:i,row:l,column:d})))return;const m=c.parseFormulaSync(g,o,i),{formula1:w}=m,y=this._calc(u,a),{a:v,d:S}=e.getTransform(),I=U.fixLineWidthByScale(y.left,v),T=U.fixLineWidthByScale(y.top,S),C=U.Transform.create().composeMatrix({left:I,top:T,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),D=u.endX-u.startX,_=u.endY-u.startY;e.save(),e.beginPath(),e.rect(u.startX,u.startY,D,_),e.clip();const L=C.getMatrix();e.transform(L[0],L[1],L[2],L[3],L[4],L[5]);const F=((x=a==null?void 0:a.fs)!=null?x:10)*1.6,W=String(p)===String(w),A=V.hyacinth500;U.CheckboxShape.drawWith(e,{checked:W,width:F,height:F,fill:(B=(N=a==null?void 0:a.cl)==null?void 0:N.rgb)!=null?B:A}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),o=n.top,i=n.top+n.height,s=n.left,l=n.left+n.width,{x:d,y:u}=e;return d<=l&&d>=s&&u<=i&&u>=o}async onPointerDown(e,t){var m;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:o,worksheet:i,row:s,col:l}=e,d=M.getCellValueOrigin(i.getCellRaw(s,l)),u=this._dataValidationModel.getRuleByLocation(n,o,s,l);if(!u)return;const p=this._dataValidationModel.getValidator(u.type);if(!p||!((m=p.skipDefaultFontRender)!=null&&m.call(p,u,d,{unitId:n,subUnitId:o,row:s,column:l})))return;const{formula1:g,formula2:c}=await this._parseFormula(u,n,o),V={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(d)===M.transformCheckboxValue(String(g))?c:g,p:null}};this._commandService.executeCommand(X.SetRangeValuesCommand.id,V)}onPointerEnter(e,t){var a,n;(n=(a=U.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(U.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=U.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(U.CURSOR_TYPE.DEFAULT)}};ut=Oa([we(0,r.ICommandService),we(1,r.IUniverInstanceService),we(2,r.Inject(M.DataValidationFormulaService)),we(3,r.Inject(r.ThemeService)),we(4,r.Inject(U.IRenderManagerService)),we(5,r.Inject(M.SheetDataValidationModel))],ut);var Pa=Object.getOwnPropertyDescriptor,Aa=(e,t,a,n)=>{for(var o=n>1?void 0:n?Pa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},ja=(e,t)=>(a,n)=>t(a,n,e);let he=class{constructor(e){P(this,"canvasRender",null);P(this,"dropdown");P(this,"optionsInput");P(this,"formulaInput",It);this.injector=e}};he=Aa([ja(0,r.Inject(r.Injector))],he);class Fa extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.CHECKBOX);P(this,"canvasRender",this.injector.createInstance(ut));P(this,"formulaInput",$t)}}class xa extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.CUSTOM);P(this,"formulaInput",Wt)}}const Ua="data-validation.formula-input";class ka extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.DATE);P(this,"formulaInput",Ua);P(this,"optionsInput",Ke.componentKey);P(this,"dropdown",_t)}}class Na extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.DECIMAL);P(this,"formulaInput",Qe)}}const Ht=4,Ba=0,ot=4,Yt=4,ht=6,Ge=6,Ie=14;function Wa(e,t){const a=U.FontCache.getTextSize(e,t),n=a.width+Ht*2,{ba:o,bd:i}=a,s=o+i;return{width:n,height:s+Ba*2,ba:o}}function it(e,t,a,n){const o=Ie+ht*2,i=a-o,s=n-Ge*2,l=e.map(c=>({layout:Wa(c,t),text:c}));let d;const u=[];l.forEach(c=>{const{layout:V}=c,{width:m,height:w}=V;!d||d.width+m+ot>i?(d={width:m,height:w,items:[{...c,left:0}]},u.push(d)):(d.items.push({...c,left:d.width+ot}),d.width=d.width+m+ot)});let p=0,g=0;return u.forEach((c,V)=>{g=Math.max(g,c.width),V===u.length-1?p+=c.height:p+=c.height+Yt}),{lines:u,totalHeight:p,contentWidth:i,contentHeight:s,cellAutoHeight:p+Ge*2,calcAutoWidth:g+o}}const $a=8;class Ha extends U.Shape{static drawWith(t,a){const{fontString:n,info:o,fill:i,color:s}=a,{layout:l,text:d}=o;t.save(),U.Rect.drawWith(t,{width:l.width,height:l.height,radius:$a,fill:i||Ce}),t.translateWithPrecision(Ht,l.ba),t.font=n,t.fillStyle=s,t.fillText(d,0,0),t.restore()}}var Ya=Object.getOwnPropertyDescriptor,Xa=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ya(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},ke=(e,t)=>(a,n)=>t(a,n,e);const za=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 pt=class{constructor(e,t,a,n){P(this,"zIndex");P(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=a,this._dataValidationModel=n}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,o){const i=a-Ie+4;let s=4;switch(o){case r.VerticalAlign.MIDDLE:s=(n-Ie)/2+4;break;case r.VerticalAlign.BOTTOM:s=n-Ie+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(za),e.restore()}drawWith(e,t,a,n){var q,K;const{primaryWithCoord:o,row:i,col:s,style:l,data:d,subUnitId:u}=t,p=o.isMergedMainCell?o.mergeInfo:o,g=d==null?void 0:d.fontRenderExtension,{leftOffset:c=0,rightOffset:V=0,topOffset:m=0,downOffset:w=0}=g||{},y=this._ensureMap(u),v=this._generateKey(i,s),S=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,s);if(!S)return;const I=this._dataValidationModel.getValidator(S.type);if(!I)return;const T={startX:p.startX+c,endX:p.endX-V,startY:p.startY+m,endY:p.endY-w},C=T.endX-T.startX,D=T.endY-T.startY,{cl:_}=l||{},L=(q=typeof _=="object"?_==null?void 0:_.rgb:_)!=null?q:"#000",F=U.getFontStyleString(l!=null?l:void 0),{vt:W,ht:A}=l||{},j=W!=null?W:r.VerticalAlign.MIDDLE,x=(K=M.getCellValueOrigin(d))!=null?K:"",N=I.parseCellValue(x),B=I.getListWithColorMap(S),H=it(N,F,C,D);this._drawDownIcon(e,T,C,D,j),e.save(),e.translateWithPrecision(T.startX,T.startY),e.beginPath(),e.rect(0,0,C-Ie,D),e.clip(),e.translateWithPrecision(ht,Ge);let G=0;switch(j){case r.VerticalAlign.MIDDLE:G=(H.contentHeight-H.totalHeight)/2;break;case r.VerticalAlign.BOTTOM:G=H.contentHeight-H.totalHeight;break}e.translateWithPrecision(0,G),H.lines.forEach((Z,ee)=>{e.save();const{width:te,height:ne,items:re}=Z;let oe=0;switch(A){case r.HorizontalAlign.RIGHT:oe=H.contentWidth-te;break;case r.HorizontalAlign.CENTER:oe=(H.contentWidth-te)/2;break}e.translate(oe,ee*(ne+Yt)),re.forEach(se=>{e.save(),e.translateWithPrecision(se.left,0),Ha.drawWith(e,{...F,info:se,color:L,fill:B[se.text]}),e.restore()}),e.restore()}),e.restore(),y.set(v,{left:T.startX,top:T.startY,width:H.contentWidth+ht+Ie,height:H.contentHeight+Ge*2})}calcCellAutoHeight(e){var C;const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:u=0,downOffset:p=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,c={startX:g.startX+l,endX:g.endX-d,startY:g.startY+u,endY:g.endY-p},V=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!V)return;const m=this._dataValidationModel.getValidator(V.type);if(!m)return;const w=c.endX-c.startX,y=c.endY-c.startY,v=(C=M.getCellValueOrigin(n))!=null?C:"",S=m.parseCellValue(v),I=U.getFontStyleString(a!=null?a:void 0);return it(S,I,w,y).cellAutoHeight}calcCellAutoWidth(e){var C;const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:u=0,downOffset:p=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,c={startX:g.startX+l,endX:g.endX-d,startY:g.startY+u,endY:g.endY-p},V=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!V)return;const m=this._dataValidationModel.getValidator(V.type);if(!m)return;const w=c.endX-c.startX,y=c.endY-c.startY,v=(C=M.getCellValueOrigin(n))!=null?C:"",S=m.parseCellValue(v),I=U.getFontStyleString(a!=null?a:void 0);return it(S,I,w,y).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:o}=n,{x:i}=e;return i>=o-Ie&&i<=o}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:i}=e,s={unitId:a,subUnitId:n,row:o,column:i};this._commandService.executeCommand(qe.id,s)}onPointerEnter(e,t){var a,n;return(n=(a=U.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(U.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;return(n=(a=U.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(U.CURSOR_TYPE.DEFAULT)}};pt=Xa([ke(0,r.ICommandService),ke(1,r.IUniverInstanceService),ke(2,r.Inject(U.IRenderManagerService)),ke(3,r.Inject(M.SheetDataValidationModel))],pt);class Ka extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.LIST_MULTIPLE);P(this,"canvasRender",this.injector.createInstance(pt));P(this,"dropdown",Ze)}}var Ga=Object.getOwnPropertyDescriptor,qa=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ga(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Pe=(e,t)=>(a,n)=>t(a,n,e);const _e=4,Ne=4,de=14,ce=6,Ee=4,rt=8,Za="#565656",wt=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 Ja(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${r.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:r.BooleanNumber.FALSE,bl:r.BooleanNumber.FALSE,ul:{s:r.BooleanNumber.FALSE},st:{s:r.BooleanNumber.FALSE},ol:{s:r.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 Xt(e,t,a){const n=Ja(e,a),o=new r.DocumentDataModel(n),i=new U.DocumentViewModel(o);return{documentSkeleton:U.DocumentSkeleton.create(i,t),docModel:o,docViewModel:i}}function Be(e,t,a){const{documentSkeleton:n,docModel:o,docViewModel:i}=Xt(e,t,a);return{documents:new U.Documents(`DOCUMENTS_${r.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:o,docViewModel:i}}function Et(e,t,a,n,o,i,s=!0){let l=0;const d=s?Ee:0;switch(o){case r.VerticalAlign.BOTTOM:l=t-n-d;break;case r.VerticalAlign.MIDDLE:l=(t-n)/2;break;default:l=d;break}l=Math.max(Ee,l);let u=0;switch(i){case r.HorizontalAlign.CENTER:u=(e-a)/2;break;case r.HorizontalAlign.RIGHT:u=e-a;break}return u=Math.max(ce,u),{paddingLeft:u,paddingTop:l}}let gt=class{constructor(e,t,a,n,o){P(this,"_dropdownInfoMap",new Map);P(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=a,this._renderManagerService=n,this._dataValidationModel=o}_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,o,i,s){const{t:l=r.DEFAULT_STYLES.pd.t,b:d=r.DEFAULT_STYLES.pd.b}=s,u=a-de;let p;switch(i){case r.VerticalAlign.MIDDLE:p=(n-Ne)/2;break;case r.VerticalAlign.BOTTOM:p=n-d-o-Ee+(o/2-Ne/2);break;default:p=l+Ee+(o/2-Ne/2);break}e.save(),e.translateWithPrecision(t.startX+u,t.startY+p),e.fillStyle="#565656",e.fill(wt),e.restore()}drawWith(e,t,a){const{primaryWithCoord:n,row:o,col:i,style:s,data:l,subUnitId:d}=t,u=n.isMergedMainCell?n.mergeInfo:n,p=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,o,i);if(!p)return;const g=this._dataValidationModel.getValidator(p.type);if(!g)return;const c=l==null?void 0:l.fontRenderExtension,{leftOffset:V=0,rightOffset:m=0,topOffset:w=0,downOffset:y=0}=c||{};if(!p||!g||!g||g.id.indexOf(r.DataValidationType.LIST)!==0||!g.skipDefaultFontRender(p))return;const v={startX:u.startX+V,endX:u.endX-m,startY:u.startY+w,endY:u.endY-y},S=v.endX-v.startX,I=v.endY-v.startY,T=this._ensureMap(d),C=this._generateKey(o,i),D=g.getListWithColor(p),_=M.getCellValueOrigin(l),L=`${_!=null?_:""}`,F=D.find(N=>N.label===L);let{tb:W,vt:A,ht:j,pd:x}=s||{};if(W=W!=null?W:r.WrapStrategy.WRAP,A=A!=null?A:r.VerticalAlign.BOTTOM,j=j!=null?j:r.DEFAULT_STYLES.ht,x=x!=null?x:r.DEFAULT_STYLES.pd,p.renderMode===r.DataValidationRenderMode.ARROW){const{l:N=r.DEFAULT_STYLES.pd.l,t:B=r.DEFAULT_STYLES.pd.t,r:H=r.DEFAULT_STYLES.pd.r,b:G=r.DEFAULT_STYLES.pd.b}=x,q=S-N-H-de-4,{documentSkeleton:K,documents:Z,docModel:ee}=Be(L,this._localeService,s);W===r.WrapStrategy.WRAP&&ee.updateDocumentDataPageSize(Math.max(q,1)),K.calculate(),K.getActualSize();const te=U.getDocsSkeletonPageSize(K),{height:ne,width:re}=te,{paddingTop:oe,paddingLeft:se}=Et(q,I-B-G,re,ne,A,j,!0);this._drawDownIcon(e,v,S,I,ne,A,x),e.save(),e.translateWithPrecision(v.startX+N,v.startY+B),e.beginPath(),e.rect(0,0,S-N-H,I-B-G),e.clip(),e.translateWithPrecision(0,oe),e.save(),e.translateWithPrecision(_e,0),e.beginPath(),e.rect(0,0,q,ne),e.clip(),Z.render(e),e.translateWithPrecision(se,0),e.restore(),e.restore(),T.set(C,{left:v.endX+N+a.rowHeaderWidth-de,top:v.startY+B+a.columnHeaderHeight,width:de,height:I-B-G})}else{e.save(),e.translateWithPrecision(v.startX,v.startY),e.beginPath(),e.rect(0,0,S,I),e.clip();const N=S-ce*2-_e-de-4,{documentSkeleton:B,documents:H,docModel:G}=Be(L,this._localeService,s);W===r.WrapStrategy.WRAP&&G.updateDocumentDataPageSize(Math.max(N,1)),B.calculate();const q=U.getDocsSkeletonPageSize(B),{height:K,width:Z}=q,{paddingTop:ee,paddingLeft:te}=Et(N,I,Z,K,A,j);e.translateWithPrecision(ce,ee);const ne=Math.max(S-ce*2,1),re=K;U.Rect.drawWith(e,{width:ne,height:re,fill:(F==null?void 0:F.color)||Ce,radius:rt}),e.save(),e.translateWithPrecision(_e,0),e.beginPath(),e.rect(0,0,N,K),e.clip(),e.translateWithPrecision(te,0),H.render(e),e.restore(),e.translateWithPrecision(N+_e+4,(K-Ne)/2),e.fillStyle=Za,e.fill(wt),e.restore(),T.set(C,{left:v.startX+ce+a.rowHeaderWidth,top:v.startY+ee+a.columnHeaderHeight,width:ne,height:re})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,l=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:u=0,topOffset:p=0,downOffset:g=0}=l||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!c||c.renderMode===r.DataValidationRenderMode.TEXT)return;const V={startX:s.startX+d,endX:s.endX-u,startY:s.startY+p,endY:s.endY-g},m=V.endX-V.startX,w=M.getCellValueOrigin(n),y=`${w!=null?w:""}`;let{tb:v,pd:S}=a||{};const{t:I=r.DEFAULT_STYLES.pd.t,b:T=r.DEFAULT_STYLES.pd.b}=S!=null?S:{};if(v=v!=null?v:r.WrapStrategy.WRAP,c.renderMode===r.DataValidationRenderMode.ARROW){const C=m-de,{documentSkeleton:D,docModel:_}=Be(y,this._localeService,a);v===r.WrapStrategy.WRAP&&_.updateDocumentDataPageSize(Math.max(C,1)),D.calculate(),D.getActualSize();const L=U.getDocsSkeletonPageSize(D),{height:F}=L;return F+I+T+Ee*2}else{const C=m-ce*2-_e-de,{documentSkeleton:D,docModel:_}=Xt(y,this._localeService,a);v===r.WrapStrategy.WRAP&&_.updateDocumentDataPageSize(Math.max(C,1)),D.calculate();const L=U.getDocsSkeletonPageSize(D),{height:F}=L;return F+Ee*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,l=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:u=0,topOffset:p=0,downOffset:g=0}=l||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!c||c.renderMode===r.DataValidationRenderMode.TEXT)return;const V={startX:s.startX+d,endX:s.endX-u,startY:s.startY+p,endY:s.endY-g},m=V.endX-V.startX,w=M.getCellValueOrigin(n),y=`${w!=null?w:""}`;let{tb:v,pd:S}=a||{};const{l:I=r.DEFAULT_STYLES.pd.l,r:T=r.DEFAULT_STYLES.pd.r}=S!=null?S:{};v=v!=null?v:r.WrapStrategy.WRAP;let C=ce*2+de;switch(c.renderMode){case r.DataValidationRenderMode.ARROW:C=de+ce*2+T+I;break;case r.DataValidationRenderMode.CUSTOM:C=de+ce*2+_e*2+T+I+rt/2+1;break;default:C=de+ce*2+_e*2+T+I+rt/2+1}const D=m-C,{documentSkeleton:_,docModel:L}=Be(y,this._localeService,a);return v===r.WrapStrategy.WRAP&&L.updateDocumentDataPageSize(Math.max(D,1)),_.calculate(),_.getActualSize(),U.getDocsSkeletonPageSize(_).width+C}isHit(e,t){const{subUnitId:a,row:n,col:o}=t,s=this._ensureMap(a).get(this._generateKey(n,o)),l=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,o);if(!l||!s||l.renderMode===r.DataValidationRenderMode.TEXT)return!1;const{top:d,left:u,width:p,height:g}=s,{x:c,y:V}=e;return c>=u&&c<=u+p&&V>=d&&V<=d+g}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:i}=e,s={unitId:a,subUnitId:n,row:o,column:i};this._commandService.executeCommand(qe.id,s)}onPointerEnter(e,t){var a,n;(n=(a=U.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(U.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=U.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(U.CURSOR_TYPE.DEFAULT)}};gt=qa([Pe(0,r.IUniverInstanceService),Pe(1,r.Inject(r.LocaleService)),Pe(2,r.ICommandService),Pe(3,r.Inject(U.IRenderManagerService)),Pe(4,r.Inject(M.SheetDataValidationModel))],gt);class Qa extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.LIST);P(this,"canvasRender",this.injector.createInstance(gt));P(this,"dropdown",Ze);P(this,"optionsInput",ze.componentKey);P(this,"formulaInput",It)}}class eo extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.TEXT_LENGTH);P(this,"formulaInput",Qe)}}class to extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.WHOLE);P(this,"formulaInput",Qe)}}var no=Object.getOwnPropertyDescriptor,ao=(e,t,a,n)=>{for(var o=n>1?void 0:n?no(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},st=(e,t)=>(a,n)=>t(a,n,e);let Oe=class extends r.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[Ut,Tt],[He,Zn],[jt,Sn],[Ze,Ln],[_t,an],[ze.componentKey,ze],[Ke.componentKey,Ke],...Ma].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Na,to,eo,ka,Fa,Qa,Ka,xa].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=ao([st(0,r.Inject(r.Injector)),st(1,r.Inject(f.ComponentManager)),st(2,r.Inject(Q.DataValidatorRegistryService))],Oe);var oo=Object.getOwnPropertyDescriptor,io=(e,t,a,n)=>{for(var o=n>1?void 0:n?oo(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},lt=(e,t)=>(a,n)=>t(a,n,e);const ro="SHEET_DATA_VALIDATION_UI_PLUGIN";var We;exports.UniverSheetsDataValidationUIPlugin=(We=class extends r.Plugin{constructor(t=Ye,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:i,...s}=r.merge({},Ye,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(St,s)}onStarting(){[[ue],[me],[je],[Me],[Le],[Te],[be],[Ae],[Oe]].forEach(t=>{this._injector.add(t)}),[Je,qe,xt,ft,De,Ft].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(be),this._injector.get(Te),this._injector.get(Ae),this._injector.get(je),this._injector.get(U.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[Xe])}onRendered(){this._injector.get(Oe),this._injector.get(Le)}onSteady(){this._injector.get(Me)}},P(We,"pluginName",ro),P(We,"type",r.UniverInstanceType.UNIVER_SHEET),We);exports.UniverSheetsDataValidationUIPlugin=io([lt(1,r.Inject(r.Injector)),lt(2,r.ICommandService),lt(3,r.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);var so=Object.getOwnPropertyDescriptor,lo=(e,t,a,n)=>{for(var o=n>1?void 0:n?so(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},dt=(e,t)=>(a,n)=>t(a,n,e);const co="SHEET_DATA_VALIDATION_UI_PLUGIN";var $e;exports.UniverSheetsDataValidationMobileUIPlugin=($e=class extends r.Plugin{constructor(t=Ye,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:i,...s}=r.merge({},Ye,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(St,s)}onStarting(){[[ue],[me],[je],[Me],[Le],[Te],[be],[Oe]].forEach(t=>{this._injector.add(t)}),[Je,qe,xt,ft,De,Ft].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(be),this._injector.get(Te),this._injector.get(U.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[Xe])}onRendered(){this._injector.get(Oe),this._injector.get(Le)}onSteady(){this._injector.get(Me)}},P($e,"pluginName",co),P($e,"type",r.UniverInstanceType.UNIVER_SHEET),$e);exports.UniverSheetsDataValidationMobileUIPlugin=lo([dt(1,r.Inject(r.Injector)),dt(2,r.ICommandService),dt(3,r.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);exports.DATE_DROPDOWN_KEY=_t;exports.LIST_DROPDOWN_KEY=Ze;
package/lib/es/index.js CHANGED
@@ -49,7 +49,7 @@ let ce = class extends Vt {
49
49
  title: An.createElement(
50
50
  Bt,
51
51
  {
52
- type: "primary",
52
+ variant: "primary",
53
53
  onClick: () => this._dialogService.close("reject-input-dialog")
54
54
  },
55
55
  this._localeService.t("dataValidation.alert.ok")
@@ -77,7 +77,7 @@ let ce = class extends Vt {
77
77
  title: An.createElement(
78
78
  Bt,
79
79
  {
80
- type: "primary",
80
+ variant: "primary",
81
81
  onClick: () => this._dialogService.close("reject-input-dialog")
82
82
  },
83
83
  this._localeService.t("dataValidation.alert.ok")
@@ -176,7 +176,7 @@ function ei(t) {
176
176
  disabledDate: (y) => !Je.parseDate(y.format("YYYY-MM-DD"))
177
177
  }
178
178
  ),
179
- /* @__PURE__ */ m("div", { className: Un.dvDateDropdownBtns, children: /* @__PURE__ */ m(Bt, { size: "small", type: "primary", onClick: C, disabled: !w.isValid(), children: g.t("dataValidation.alert.ok") }) })
179
+ /* @__PURE__ */ m("div", { className: Un.dvDateDropdownBtns, children: /* @__PURE__ */ m(Bt, { size: "small", variant: "primary", onClick: C, disabled: !w.isValid(), children: g.t("dataValidation.alert.ok") }) })
180
180
  ] });
181
181
  }
182
182
  var ut = function() {
@@ -922,7 +922,7 @@ function Ui() {
922
922
  /* @__PURE__ */ m(Li, { value: st, onChange: it, extraComponent: w.optionsInput }),
923
923
  /* @__PURE__ */ Y("div", { className: jt.dataValidationDetailButtons, children: [
924
924
  /* @__PURE__ */ m(Bt, { className: jt.dataValidationDetailButton, onClick: H, children: I.t("dataValidation.panel.removeRule") }),
925
- /* @__PURE__ */ m(Bt, { className: jt.dataValidationDetailButton, type: "primary", onClick: B, children: I.t("dataValidation.panel.done") })
925
+ /* @__PURE__ */ m(Bt, { className: jt.dataValidationDetailButton, variant: "primary", onClick: B, children: I.t("dataValidation.panel.done") })
926
926
  ] })
927
927
  ] });
928
928
  }
@@ -1035,7 +1035,7 @@ function zi(t) {
1035
1035
  }),
1036
1036
  /* @__PURE__ */ Y("div", { className: me.dataValidationListButtons, children: [
1037
1037
  s.length && !g ? /* @__PURE__ */ m(Bt, { className: me.dataValidationListButton, onClick: p, children: r.t("dataValidation.panel.removeAll") }) : null,
1038
- /* @__PURE__ */ m(Bt, { className: me.dataValidationListButton, type: "primary", onClick: I, children: r.t("dataValidation.panel.add") })
1038
+ /* @__PURE__ */ m(Bt, { className: me.dataValidationListButton, variant: "primary", onClick: I, children: r.t("dataValidation.panel.add") })
1039
1039
  ] })
1040
1040
  ] });
1041
1041
  }
package/lib/index.js CHANGED
@@ -49,7 +49,7 @@ let ce = class extends Vt {
49
49
  title: An.createElement(
50
50
  Bt,
51
51
  {
52
- type: "primary",
52
+ variant: "primary",
53
53
  onClick: () => this._dialogService.close("reject-input-dialog")
54
54
  },
55
55
  this._localeService.t("dataValidation.alert.ok")
@@ -77,7 +77,7 @@ let ce = class extends Vt {
77
77
  title: An.createElement(
78
78
  Bt,
79
79
  {
80
- type: "primary",
80
+ variant: "primary",
81
81
  onClick: () => this._dialogService.close("reject-input-dialog")
82
82
  },
83
83
  this._localeService.t("dataValidation.alert.ok")
@@ -176,7 +176,7 @@ function ei(t) {
176
176
  disabledDate: (y) => !Je.parseDate(y.format("YYYY-MM-DD"))
177
177
  }
178
178
  ),
179
- /* @__PURE__ */ m("div", { className: Un.dvDateDropdownBtns, children: /* @__PURE__ */ m(Bt, { size: "small", type: "primary", onClick: C, disabled: !w.isValid(), children: g.t("dataValidation.alert.ok") }) })
179
+ /* @__PURE__ */ m("div", { className: Un.dvDateDropdownBtns, children: /* @__PURE__ */ m(Bt, { size: "small", variant: "primary", onClick: C, disabled: !w.isValid(), children: g.t("dataValidation.alert.ok") }) })
180
180
  ] });
181
181
  }
182
182
  var ut = function() {
@@ -922,7 +922,7 @@ function Ui() {
922
922
  /* @__PURE__ */ m(Li, { value: st, onChange: it, extraComponent: w.optionsInput }),
923
923
  /* @__PURE__ */ Y("div", { className: jt.dataValidationDetailButtons, children: [
924
924
  /* @__PURE__ */ m(Bt, { className: jt.dataValidationDetailButton, onClick: H, children: I.t("dataValidation.panel.removeRule") }),
925
- /* @__PURE__ */ m(Bt, { className: jt.dataValidationDetailButton, type: "primary", onClick: B, children: I.t("dataValidation.panel.done") })
925
+ /* @__PURE__ */ m(Bt, { className: jt.dataValidationDetailButton, variant: "primary", onClick: B, children: I.t("dataValidation.panel.done") })
926
926
  ] })
927
927
  ] });
928
928
  }
@@ -1035,7 +1035,7 @@ function zi(t) {
1035
1035
  }),
1036
1036
  /* @__PURE__ */ Y("div", { className: me.dataValidationListButtons, children: [
1037
1037
  s.length && !g ? /* @__PURE__ */ m(Bt, { className: me.dataValidationListButton, onClick: p, children: r.t("dataValidation.panel.removeAll") }) : null,
1038
- /* @__PURE__ */ m(Bt, { className: me.dataValidationListButton, type: "primary", onClick: I, children: r.t("dataValidation.panel.add") })
1038
+ /* @__PURE__ */ m(Bt, { className: me.dataValidationListButton, variant: "primary", onClick: I, children: r.t("dataValidation.panel.add") })
1039
1039
  ] })
1040
1040
  ] });
1041
1041
  }
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(x,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react/jsx-runtime"),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("react"),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/jsx-runtime","@univerjs/core","@univerjs/design","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-data-validation","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/ui","react","@univerjs/data-validation","@univerjs/docs","rxjs","@univerjs/engine-formula","@univerjs/sheets-formula-ui"],u):(x=typeof globalThis<"u"?globalThis:x||self,u(x.UniverSheetsDataValidationUi={},x.React,x.UniverCore,x.UniverDesign,x.UniverEngineRender,x.UniverSheets,x.UniverSheetsDataValidation,x.UniverSheetsNumfmt,x.UniverSheetsUi,x.UniverUi,x.React,x.UniverDataValidation,x.UniverDocs,x.rxjs,x.UniverEngineFormula,x.UniverSheetsFormulaUi))})(this,function(x,u,r,L,k,X,E,Kt,$,f,V,J,Gt,ie,tt,nt){"use strict";var Ta=Object.defineProperty;var Oa=(x,u,r)=>u in x?Ta(x,u,{enumerable:!0,configurable:!0,writable:!0,value:r}):x[u]=r;var R=(x,u,r)=>Oa(x,typeof u!="symbol"?u+"":u,r);var Qe,et;var qt=Object.getOwnPropertyDescriptor,Zt=(e,t,a,n)=>{for(var o=n>1?void 0:n?qt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},we=(e,t)=>(a,n)=>t(a,n,e);let Ae=class extends r.Disposable{constructor(e,t,a,n,o,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=o,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(X.VALIDATE_CELL,{handler:async(e,t,a)=>{const n=await e,{row:o,col:i,unitId:s,subUnitId:l}=t,d=this._dataValidationModel.getRuleIdByLocation(s,l,o,i),h=d?this._dataValidationModel.getRuleById(s,l,d):void 0;if(n===!1)return a(Promise.resolve(!1));if(!h||h.errorStyle!==r.DataValidationErrorStyle.STOP)return a(Promise.resolve(!0));const p=this._dataValidatorRegistryService.getValidatorItem(h.type);return!p||await this._sheetsDataValidationValidatorService.validatorCell(s,l,o,i)===r.DataValidationStatus.VALID?a(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:p.getRuleFinalError(h,{row:o,col:i,unitId:s,subUnitId:l})},footer:{title:V.createElement(L.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(!1)))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:V.createElement(L.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Ae=Zt([we(0,r.Inject(X.SheetInterceptorService)),we(1,r.Inject(E.SheetDataValidationModel)),we(2,r.Inject(J.DataValidatorRegistryService)),we(3,f.IDialogService),we(4,r.Inject(r.LocaleService)),we(5,r.Inject(E.SheetsDataValidationValidatorService))],Ae);const Dt={dvDateDropdown:"univer-dv-date-dropdown",dvDateDropdownBtns:"univer-dv-date-dropdown-btns"},Jt=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return r.dayjs(r.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=r.dayjs(e);if(t.isValid())return t};function Qt(e){var I;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:i,unitId:s,subUnitId:l,workbook:d}=t,h=f.useDependency(r.ICommandService),p=f.useDependency(Ae),v=n.getCell(o,i),c=E.getCellValueOrigin(n.getCellRaw(o,i)),y=Jt(c),[g,M]=V.useState(y),w=g&&g.isValid()?g:r.dayjs(),m=f.useDependency(r.LocaleService),S=f.useDependency(E.SheetDataValidationModel),_=S.getRuleByLocation(s,l,o,i);if(!_)return null;const T=S.getValidator(_.type);if(!v||!T)return;const C=!!((I=_.bizInfo)!=null&&I.showTime),D=async()=>{var j,W,Y;if(!w)return;const N=w.format(C?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),H=(j=r.numfmt.parseDate(N))==null?void 0:j.v,A=d.getStyles().getStyleByCell(v),F=(Y=(W=A==null?void 0:A.n)==null?void 0:W.pattern)!=null?Y:"",U=Kt.getPatternType(F);_.errorStyle!==r.DataValidationErrorStyle.STOP||await T.validator({value:H,unitId:s,subUnitId:l,row:o,column:i,worksheet:n,workbook:d,interceptValue:N.replace("Z","").replace("T"," "),t:r.CellValueType.NUMBER},_)?(a(),await h.executeCommand($.SetCellEditVisibleOperation.id,{visible:!1,eventType:k.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),await h.executeCommand(X.SetRangeValuesCommand.id,{unitId:s,subUnitId:l,range:{startColumn:i,endColumn:i,startRow:o,endRow:o},value:{v:H,t:2,p:null,f:null,si:null,s:{n:{pattern:C?U==="datetime"?F:"yyyy-MM-dd hh:mm:ss":U==="date"?F:"yyyy-MM-dd"}}}})):p.showReject(T.getRuleFinalError(_,{row:o,col:i,unitId:s,subUnitId:l}))};return u.jsxs("div",{className:Dt.dvDateDropdown,children:[u.jsx(L.DatePanel,{defaultValue:w,pickerValue:w,showTime:C||void 0,onSelect:async O=>{M(O)},onPanelChange:O=>{M(O)},disabledDate:O=>!r.numfmt.parseDate(O.format("YYYY-MM-DD"))}),u.jsx("div",{className:Dt.dvDateDropdownBtns,children:u.jsx(L.Button,{size:"small",type:"primary",onClick:D,disabled:!w.isValid(),children:m.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 o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},se.apply(this,arguments)},en=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 o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(a[n[o]]=e[n[o]]);return a},ge=V.forwardRef(function(e,t){var a=e.icon,n=e.id,o=e.className,i=e.extend,s=en(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),d=V.useRef("_".concat(an()));return yt(a,"".concat(n),{defIds:a.defIds,idSuffix:d.current},se({ref:t,className:l},s),i)});function yt(e,t,a,n,o){return V.createElement(e.tag,se(se({key:t},tn(e,a,o)),n),(nn(e,a).children||[]).map(function(i,s){return yt(i,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,o)}))}function tn(e,t,a){var n=se({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],l=i[1];s==="mask"&&typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var o=t.defIds;return!o||o.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],l=i[1];typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function nn(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(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?se(se({},o),{attrs:se(se({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):e}function an(){return Math.random().toString(36).substring(2,8)}ge.displayName="UniverIcon";var on={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"}}]},wt=V.forwardRef(function(e,t){return V.createElement(ge,Object.assign({},e,{id:"check-mark-single",ref:t,icon:on}))});wt.displayName="CheckMarkSingle";var rn={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"}}]},Vt=V.forwardRef(function(e,t){return V.createElement(ge,Object.assign({},e,{id:"data-validation-single",ref:t,icon:rn}))});Vt.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"}}]},at=V.forwardRef(function(e,t){return V.createElement(ge,Object.assign({},e,{id:"delete-single",ref:t,icon:sn}))});at.displayName="DeleteSingle";var ln={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"}}]},Et=V.forwardRef(function(e,t){return V.createElement(ge,Object.assign({},e,{id:"increase-single",ref:t,icon:ln}))});Et.displayName="IncreaseSingle";var dn={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=V.forwardRef(function(e,t){return V.createElement(ge,Object.assign({},e,{id:"more-down-single",ref:t,icon:dn}))});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=V.forwardRef(function(e,t){return V.createElement(ge,Object.assign({},e,{id:"more-up-single",ref:t,icon:cn}))});bt.displayName="MoreUpSingle";var un={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=V.forwardRef(function(e,t){return V.createElement(ge,Object.assign({},e,{id:"sequence-single",ref:t,icon:un}))});Lt.displayName="SequenceSingle";var hn=Object.getOwnPropertyDescriptor,pn=(e,t,a,n)=>{for(var o=n>1?void 0:n?hn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Tt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends r.Disposable{constructor(t,a){super();R(this,"_open$",new ie.BehaviorSubject(!1));R(this,"open$",this._open$.pipe(ie.distinctUntilChanged()));R(this,"_activeRule");R(this,"_activeRule$",new ie.BehaviorSubject(void 0));R(this,"activeRule$",this._activeRule$.asObservable());R(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).pipe(ie.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===Ne&&(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=r.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ue=pn([Tt(0,r.IUniverInstanceService),Tt(1,f.ISidebarService)],ue);function vn(){const e=f.useDependency(me),t=f.useObservable(e.activeDropdown$,e.activeDropdown),a=f.useDependency(f.ComponentManager);if(!t)return null;const{location:n,componentKey:o}=t,i=a.get(o),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!i)return null;const l=()=>{e.hideDropdown()};return u.jsx(i,{location:n,hideFn:l},s)}const Ot="sheet.ui.dropdown";var gn=Object.getOwnPropertyDescriptor,mn=(e,t,a,n)=>{for(var o=n>1?void 0:n?gn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Se=(e,t)=>(a,n)=>t(a,n,e);let me=class extends r.Disposable{constructor(t,a,n,o,i,s,l){super();R(this,"_activeDropdown");R(this,"_activeDropdown$",new ie.Subject);R(this,"_currentPopup",null);R(this,"activeDropdown$",this._activeDropdown$.asObservable());R(this,"_zenVisible",!1);this._canvasPopupManagerService=t,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=o,this._renderManagerService=i,this._dataValidationModel=s,this._sheetsSelectionsService=l,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,o){const i=t?this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=a?i.getSheetBySheetId(a):i.getActiveSheet();if(!s)return;const l=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,o);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);return d==null?void 0:d.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:o,col:i,unitId:s,subUnitId:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const d=this._renderManagerService.getRenderById(r.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),h=this._canvasPopupManagerService.attachPopupToCell(o,i,{componentKey:Ot,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[d==null?void 0:d.engine.getCanvasElement()].filter(Boolean)},s,l);if(!h)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const p=new r.DisposableCollection;p.add(h),p.add({dispose:()=>{var v,c;(c=(v=this._activeDropdown)==null?void 0:v.onHide)==null||c.call(v)}}),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,o,i){const s=this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET);if(!s)return;const l=s.getSheetBySheetId(a);if(!l)return;const d=this._dataValidationModel.getRuleByLocation(s.getUnitId(),l.getSheetId(),n,o);if(!d)return;const h=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!h||!h.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:l,row:n,col:o,unitId:t,subUnitId:a},componentKey:h.dropdown,onHide:i})}};me=mn([Se(0,r.Inject($.SheetCanvasPopManagerService)),Se(1,r.IUniverInstanceService),Se(2,r.Inject(J.DataValidatorRegistryService)),Se(3,f.IZenZoneService),Se(4,k.IRenderManagerService),Se(5,r.Inject(E.SheetDataValidationModel)),Se(6,r.Inject(X.SheetsSelectionsService))],me);const Ne="DataValidationPanel",Ie={id:"data-validation.operation.open-validation-panel",type:r.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,o=e.get(ue),i=e.get(J.DataValidationModel),s=e.get(r.IUniverInstanceService),l=e.get(f.ISidebarService),d=X.getSheetCommandTarget(s);if(!d)return!1;const{unitId:h,subUnitId:p}=d,v=a?i.getRuleById(h,p,a):void 0;o.open(),o.setActiveRule(v&&{unitId:h,subUnitId:p,rule:v});const c=l.open({id:Ne,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Ne},width:312,onClose:()=>o.close()});return o.setCloseDisposable(c),!0}},ot={id:"data-validation.operation.close-validation-panel",type:r.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},Pt={id:"data-validation.operation.toggle-validation-panel",type:r.CommandType.OPERATION,handler(e){const t=e.get(r.ICommandService),a=e.get(ue);return a.open(),a.isOpen?t.executeCommand(ot.id):t.executeCommand(Ie.id),!0}},Ue={type:r.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(me),{unitId:n,subUnitId:o,row:i,column:s}=t,l=a.activeDropdown,d=l==null?void 0:l.location;return d&&d.unitId===n&&d.subUnitId===o&&d.row===i&&d.col===s||a.showDataValidationDropdown(n,o,i,s),!0}},Rt={type:r.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(me).hideDropdown(),!0):!1}},_e="#ECECEC",it="sheets-data-validation-ui.config",Be={},ve={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"},fn=e=>{var C,D;const{value:t,onChange:a,multiple:n,options:o,title:i,onEdit:s,style:l,filter:d,location:h}=e,p=f.useDependency(r.LocaleService),v=f.useDependency(r.IConfigService),c=d==null?void 0:d.toLowerCase(),{row:y,col:g,unitId:M,subUnitId:w}=h,m=o.filter(I=>c?I.label.toLowerCase().includes(c):!0),S=(D=(C=v.getConfig(it))==null?void 0:C.showEditOnDropdown)!=null?D:!0,_=f.useDependency(X.SheetPermissionCheckController),T=V.useMemo(()=>_.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission]},[{startColumn:g,startRow:y,endColumn:g,endRow:y}],M,w),[_,g,y,M,w]);return u.jsxs("div",{className:ve.dvListDropdown,style:l,children:[u.jsx("div",{className:ve.dvListDropdownTitle,children:i}),u.jsx("div",{className:ve.dvListDropdownList,children:u.jsx(L.Scrollbar,{children:u.jsx("div",{className:ve.dvListDropdownListContainer,children:m.map((I,O)=>{const N=t.indexOf(I.value)>-1,H=()=>{let F;N?F=new Set(t.filter(j=>j!==I.value)):F=new Set(n?[...t,I.value]:[I.value]);const U=[];o.forEach(j=>{F.has(j.value)&&U.push(j.value)}),a(U)},A=I.label.toLocaleLowerCase().indexOf(c);return u.jsxs("div",{className:ve.dvListDropdownItemContainer,onClick:H,children:[u.jsx("div",{className:ve.dvListDropdownItem,style:{background:I.color||_e},children:c&&I.label.toLowerCase().includes(c)?u.jsxs(u.Fragment,{children:[u.jsx("span",{children:I.label.substring(0,A)}),u.jsx("span",{style:{fontWeight:"bold"},children:I.label.substring(A,A+c.length)}),u.jsx("span",{children:I.label.substring(A+c.length)})]}):I.label}),u.jsx("div",{className:ve.dvListDropdownSelectedIcon,children:N?u.jsx(wt,{}):null})]},O)})})},d)}),S&&T?u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ve.dvListDropdownSplit}),u.jsx("div",{className:ve.dvListDropdownEdit,children:u.jsx("a",{onClick:s,children:p.t("dataValidation.list.edit")})})]}):null]})};function Sn(e){var W,Y,q,Z;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:i,unitId:s,subUnitId:l}=t,d=f.useDependency(J.DataValidationModel),[h,p]=V.useState(""),v=f.useDependency(r.ICommandService),c=f.useDependency(r.LocaleService),[y,g]=V.useState(""),M=f.useDependency($.IEditorBridgeService),w=f.useDependency(r.IUniverInstanceService),m=V.useMemo(()=>d.ruleChange$.pipe(ie.debounceTime(16)),[]),S=f.useDependency(E.SheetDataValidationModel);f.useObservable(m);const _=f.RectPopup.useContext(),T=((Y=(W=_.current)==null?void 0:W.right)!=null?Y:0)-((Z=(q=_.current)==null?void 0:q.left)!=null?Z:0);if(V.useEffect(()=>{const G=v.onCommandExecuted(ee=>{var te,ae;if(ee.id===Gt.RichTextEditingMutation.id){const oe=ee.params,{unitId:le}=oe,re=w.getUnit(le,r.UniverInstanceType.UNIVER_DOC);if(!re||!M.isVisible().visible)return;const de=r.BuildTextUtils.transform.getPlainText((ae=(te=re.getSnapshot().body)==null?void 0:te.dataStream)!=null?ae:"");p(de)}});return()=>{G.dispose()}},[v,M,w]),!n)return null;const C=S.getRuleByLocation(s,l,o,i);if(!C)return null;const D=S.getValidator(C.type);if(!D)return null;const I=n.getCell(o,i),O=(C==null?void 0:C.renderMode)===r.DataValidationRenderMode.CUSTOM||(C==null?void 0:C.renderMode)===void 0;if(!I||!C||!D||D.id.indexOf(r.DataValidationType.LIST)!==0)return;const N=C.type===r.DataValidationType.LIST_MULTIPLE,H=D.getListWithColor(C,s,l),A=y||E.getDataValidationCellValue(n.getCellRaw(o,i)),F=E.deserializeListOptions(A),U=()=>{v.executeCommand(Ie.id,{ruleId:C.uid}),a()},j=H.map(G=>({label:G.label,value:G.label,color:O||G.color?G.color:"transparent"}));return u.jsx(fn,{style:{minWidth:T,maxWidth:Math.max(T,200)},title:N?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:F,multiple:N,onChange:async G=>{const ee=E.serializeListOptions(G),te={unitId:s,subUnitId:l,range:{startColumn:i,endColumn:i,startRow:o,endRow:o},value:{v:ee,p:null,f:null,si:null}};M.isVisible()&&v.executeCommand($.SetCellEditVisibleOperation.id,{visible:!1,eventType:k.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),g(ee),N||a(),M.isVisible().visible&&await v.executeCommand($.SetCellEditVisibleOperation.id,{visible:!1,eventType:k.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),v.executeCommand(X.SetRangeValuesCommand.id,te)},options:j,onEdit:U,filter:h,location:t})}const rt={dataValidationOptionsButton:"univer-data-validation-options-button",dataValidationOptionsButtonIcon:"univer-data-validation-options-button-icon"};function In(e){var h;const t=f.useDependency(r.LocaleService),a=f.useDependency(f.ComponentManager),{value:n,onChange:o,extraComponent:i}=e,[s,l]=V.useState(!1),d=i?a.get(i):null;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:rt.dataValidationOptionsButton,onClick:()=>l(!s),children:[t.t("dataValidation.panel.options"),s?u.jsx(bt,{className:rt.dataValidationOptionsButtonIcon}):u.jsx(Mt,{className:rt.dataValidationOptionsButtonIcon})]}),s&&u.jsxs(u.Fragment,{children:[d?u.jsx(d,{value:n,onChange:o}):null,u.jsx(L.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:u.jsxs(L.RadioGroup,{value:`${(h=n.errorStyle)!=null?h:r.DataValidationErrorStyle.WARNING}`,onChange:p=>o({...n,errorStyle:+p}),children:[u.jsx(L.Radio,{value:`${r.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),u.jsx(L.Radio,{value:`${r.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),u.jsx(L.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:u.jsx(L.Checkbox,{checked:n.showErrorMessage,onChange:()=>o({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?u.jsx(L.FormLayout,{children:u.jsx(L.Input,{value:n.error,onChange:p=>o({...n,error:p})})}):null]})]})}const Ve={dataValidationDetail:"univer-data-validation-detail",dataValidationDetailFormItem:"univer-data-validation-detail-form-item",dataValidationDetailButtons:"univer-data-validation-detail-buttons",dataValidationDetailButton:"univer-data-validation-detail-button"},_n=e=>r.debounce(async(t,a,n,o)=>{const i=await e.executeCommand(t,a,n);o==null||o(i)},1e3);function Cn(e,t,a){var n,o,i,s;return t?((o=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:o.getSheetId())||"":((s=(i=e.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Dn(){var de;const[e,t]=V.useState(0),a=f.useDependency(ue),n=f.useObservable(a.activeRule$,a.activeRule),{unitId:o,subUnitId:i,rule:s}=n||{},l=s.uid,d=f.useDependency(J.DataValidatorRegistryService),h=f.useDependency(r.IUniverInstanceService),p=f.useDependency(f.ComponentManager),v=f.useDependency(r.ICommandService),c=f.useDependency(J.DataValidationModel),y=f.useDependency(r.LocaleService),[g,M]=V.useState(s),w=d.getValidatorItem(g.type),[m,S]=V.useState(!1),_=d.getValidatorsByScope(J.DataValidatorRegistryScope.SHEET),[T,C]=V.useState(()=>g.ranges.map(P=>({unitId:"",sheetId:"",range:P}))),D=V.useMemo(()=>_n(v),[v]),[I,O]=V.useState(!1),[N,H]=V.useState(!1),A=V.useRef(null),F=f.useDependency(X.SheetsSelectionsService);if(V.useEffect(()=>()=>{const P=F.getCurrentLastSelection();P&&F.setSelections([P])},[F]),V.useEffect(()=>{v.onCommandExecuted(P=>{(P.id===r.UndoCommand.id||P.id===r.RedoCommand.id)&&setTimeout(()=>{const b=c.getRuleById(o,i,l);t(B=>B+1),b&&(M(b),C(b.ranges.map(B=>({unitId:"",sheetId:"",range:B}))))},20)})},[v,c,l,i,o]),!w)return null;const U=w.operators,j=w.operatorNames,W=g.operator?J.TWO_FORMULA_OPERATOR_COUNT.includes(g.operator):!1,Y=()=>{var P,b,B;(b=(P=A.current)==null?void 0:P.editor)!=null&&b.isFocus()&&q((B=A.current)==null?void 0:B.getValue()),!(!g.ranges.length||I)&&(w.validatorFormula(g,o,i).success?a.setActiveRule(null):S(!0))},q=f.useEvent(P=>{const b=P.split(",").filter(Boolean).map(tt.deserializeRangeWithSheet).map(K=>{const fe=K.sheetName;if(fe){const La=Cn(h,K.unitId,fe);return{...K,sheetId:La}}return{...K,sheetId:""}});if(r.isUnitRangesEqual(b,T))return;C(b);const B=b.filter(K=>(!K.unitId||K.unitId===o)&&(!K.sheetId||K.sheetId===i)).map(K=>K.range);if(M({...g,ranges:B}),B.length===0)return;const z={unitId:o,subUnitId:i,ruleId:l,ranges:B};D(E.UpdateSheetDataValidationRangeCommand.id,z)}),Z=P=>{if(r.shallowEqual(P,J.getRuleSetting(g)))return;M({...g,...P});const b={unitId:o,subUnitId:i,ruleId:l,setting:P};D(E.UpdateSheetDataValidationSettingCommand.id,b,void 0)},G=async()=>{await v.executeCommand(E.RemoveSheetDataValidationCommand.id,{ruleId:l,unitId:o,subUnitId:i}),a.setActiveRule(null)},ee={type:g.type,operator:g.operator,formula1:g.formula1,formula2:g.formula2,allowBlank:g.allowBlank},te=P=>{const b=d.getValidatorItem(P);if(!b)return;const B=b.operators,z=c.getRuleById(o,i,l),K=P===(z==null?void 0:z.type)||P.includes("list")&&(z!=null&&z.type.includes("list"))?{...z,type:P}:{...g,type:P,operator:B[0],formula1:void 0,formula2:void 0};M(K),v.executeCommand(E.UpdateSheetDataValidationSettingCommand.id,{unitId:o,subUnitId:i,ruleId:g.uid,setting:J.getRuleSetting(K)})},ae=p.get(w.formulaInput),oe=V.useMemo(()=>T.map(P=>tt.serializeRange(P.range)).join(","),[]),le=J.getRuleOptions(g),re=P=>{r.shallowEqual(P,J.getRuleOptions(g))||(M({...g,...P}),D(E.UpdateSheetDataValidationOptionsCommand.id,{unitId:o,subUnitId:i,ruleId:l,options:P}))};return u.jsxs("div",{className:Ve.dataValidationDetail,children:[u.jsx(L.FormLayout,{label:y.t("dataValidation.panel.range"),error:!g.ranges.length||I?y.t("dataValidation.panel.rangeError"):"",children:u.jsx(nt.RangeSelector,{selectorRef:A,unitId:o,subUnitId:i,initialValue:oe,onChange:(P,b)=>{var B;!N&&((B=A.current)!=null&&B.verify())&&q(b)},onFocusChange:(P,b)=>{var B;H(P),!P&&b&&((B=A.current)!=null&&B.verify())&&q(b)},onVerify:P=>O(!P)})}),u.jsx(L.FormLayout,{label:y.t("dataValidation.panel.type"),children:u.jsx(L.Select,{options:_==null?void 0:_.map(P=>({label:y.t(P.title),value:P.id})),value:g.type,onChange:te,className:Ve.dataValidationDetailFormItem})}),U!=null&&U.length?u.jsx(L.FormLayout,{label:y.t("dataValidation.panel.operator"),children:u.jsx(L.Select,{options:U.map((P,b)=>({value:`${P}`,label:j[b]})),value:`${g.operator}`,onChange:P=>{Z({...ee,operator:P})},className:Ve.dataValidationDetailFormItem})}):null,ae?u.jsx(L.FormLayout,{children:u.jsx(ae,{isTwoFormula:W,value:{formula1:g.formula1,formula2:g.formula2},onChange:P=>{Z({...ee,...P})},showError:m,validResult:w.validatorFormula(g,o,i),unitId:o,subUnitId:i,ruleId:l},e+g.type)}):null,u.jsx(L.FormLayout,{children:u.jsx(L.Checkbox,{checked:(de=g.allowBlank)!=null?de:!0,onChange:()=>{var P;return Z({...ee,allowBlank:!((P=g.allowBlank)==null||P)})},children:y.t("dataValidation.panel.allowBlank")})}),u.jsx(In,{value:le,onChange:re,extraComponent:w.optionsInput}),u.jsxs("div",{className:Ve.dataValidationDetailButtons,children:[u.jsx(L.Button,{className:Ve.dataValidationDetailButton,onClick:G,children:y.t("dataValidation.panel.removeRule")}),u.jsx(L.Button,{className:Ve.dataValidationDetailButton,type:"primary",onClick:Y,children:y.t("dataValidation.panel.done")})]})]})}const je={dataValidationItemContainer:"univer-data-validation-item-container",dataValidationItemTitle:"univer-data-validation-item-title",dataValidationItemContent:"univer-data-validation-item-content",dataValidationItemIcon:"univer-data-validation-item-icon"},yn=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:o,disable:i}=e,s=f.useDependency(J.DataValidatorRegistryService),l=f.useDependency(r.ICommandService),d=f.useDependency($.IMarkSelectionService),h=s.getValidatorItem(t.type),p=V.useRef(void 0),[v,c]=V.useState(!1),y=f.useDependency(r.ThemeService),g=f.useObservable(y.currentTheme$),M=V.useMemo(()=>{var _;const m=(_=g==null?void 0:g.loopColor2)!=null?_:"#49B811",S=new r.ColorKit(m).toRgb();return{fill:`rgba(${S.r}, ${S.g}, ${S.b}, 0.1)`,stroke:m}},[g]),w=m=>{l.executeCommand(E.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:o}),m.stopPropagation()};return V.useEffect(()=>()=>{var m;p.current&&((m=p.current)==null||m.forEach(S=>{S&&d.removeShape(S)}))},[d]),u.jsxs("div",{className:je.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{i||(c(!0),p.current=t.ranges.map(m=>d.addShape({range:m,style:M,primary:null})))},onMouseLeave:()=>{var m;c(!1),(m=p.current)==null||m.forEach(S=>{S&&d.removeShape(S)}),p.current=void 0},children:[u.jsx("div",{className:je.dataValidationItemTitle,children:h==null?void 0:h.generateRuleName(t)}),u.jsx("div",{className:je.dataValidationItemContent,children:t.ranges.map(m=>tt.serializeRange(m)).join(",")}),v?u.jsx("div",{className:je.dataValidationItemIcon,onClick:w,children:u.jsx(at,{})}):null]})},We={dataValidationList:"univer-data-validation-list",dataValidationListButtons:"univer-data-validation-list-buttons",dataValidationListButton:"univer-data-validation-list-button"};function wn(e){const t=f.useDependency(E.SheetDataValidationModel),a=f.useDependency(r.IUniverInstanceService),n=f.useDependency(r.ICommandService),o=f.useDependency(r.Injector),i=f.useDependency(ue),s=f.useDependency(r.LocaleService),[l,d]=V.useState([]),{workbook:h}=e,p=f.useObservable(h.activeSheet$,void 0,!0),v=h.getUnitId(),c=p==null?void 0:p.getSheetId();V.useEffect(()=>{d(t.getRules(v,c));const S=t.ruleChange$.subscribe(_=>{_.unitId===v&&_.subUnitId===c&&d(t.getRules(v,c))});return()=>{S.unsubscribe()}},[v,c,t]);const y=async()=>{const S=E.createDefaultNewRule(o),_={unitId:v,subUnitId:c,rule:S};await n.executeCommand(E.AddSheetDataValidationCommand.id,_),i.setActiveRule({unitId:v,subUnitId:c,rule:S})},g=()=>{n.executeCommand(E.RemoveSheetAllDataValidationCommand.id,{unitId:v,subUnitId:c})},w=(S=>{const _=a.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET),T=_.getActiveSheet(),C=_.getUnitId(),D=T.getSheetId();return S.map(O=>X.checkRangesEditablePermission(o,C,D,O.ranges)?{...O}:{...O,disable:!0})})(l),m=w==null?void 0:w.some(S=>S.disable);return u.jsxs("div",{className:We.dataValidationList,children:[w==null?void 0:w.map(S=>{var _;return u.jsx(yn,{unitId:v,subUnitId:c,onClick:()=>{S.disable||i.setActiveRule({unitId:v,subUnitId:c,rule:S})},rule:S,disable:(_=S.disable)!=null?_:!1},S.uid)}),u.jsxs("div",{className:We.dataValidationListButtons,children:[l.length&&!m?u.jsx(L.Button,{className:We.dataValidationListButton,onClick:g,children:s.t("dataValidation.panel.removeAll")}):null,u.jsx(L.Button,{className:We.dataValidationListButton,type:"primary",onClick:y,children:s.t("dataValidation.panel.add")})]})]})}const Vn=()=>{const e=f.useDependency(ue),t=f.useObservable(e.activeRule$,e.activeRule),a=f.useDependency(r.IUniverInstanceService),n=f.useObservable(()=>a.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),o=f.useObservable(()=>{var i;return(i=n==null?void 0:n.activeSheet$)!=null?i:ie.of(null)},void 0,void 0,[]);return!n||!o?null:t&&t.subUnitId===o.getSheetId()?u.jsx(Dn,{},t.rule.uid):u.jsx(wn,{workbook:n})},$e="data-validation.list.dropdown",st="data-validation.date.dropdown",He={type:r.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(r.IUniverInstanceService),a=X.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:o}=a,i=E.createDefaultNewRule(e),s=e.get(r.ICommandService),l=n.getUnitId(),d=o.getSheetId(),h={rule:i,unitId:l,subUnitId:d};return s.syncExecuteCommand(E.AddSheetDataValidationCommand.id,h)?(s.syncExecuteCommand(Ie.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var En=Object.getOwnPropertyDescriptor,Mn=(e,t,a,n)=>{for(var o=n>1?void 0:n?En(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Ee=(e,t)=>(a,n)=>t(a,n,e);const Ce="SHEET_DATA_VALIDATION_ALERT";let Fe=class extends r.Disposable{constructor(e,t,a,n,o,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=o,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ie.debounceTime(100)).subscribe(e=>{var t;if(e){const a=this._univerInstanceService.getUnit(e.location.unitId,r.UniverInstanceType.UNIVER_SHEET),n=a.getSheetBySheetId(e.location.subUnitId);if(!n)return;const o=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!o){this._cellAlertManagerService.removeAlert(Ce);return}if(this._dataValidationModel.validator(o,{...e.location,workbook:a,worksheet:n})===r.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Ce),l=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(l&&l.row===e.location.row&&l.col===e.location.col&&l.subUnitId===e.location.subUnitId&&l.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(Ce);return}const d=this._dataValidationModel.getValidator(o.type);if(!d){this._cellAlertManagerService.removeAlert(Ce);return}this._cellAlertManagerService.showAlert({type:$.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:d==null?void 0:d.getRuleFinalError(o,e.location),location:e.location,width:200,height:74,key:Ce});return}}this._cellAlertManagerService.removeAlert(Ce)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(Ce)}))}};Fe=Mn([Ee(0,r.Inject($.HoverManagerService)),Ee(1,r.Inject($.CellAlertManagerService)),Ee(2,r.IUniverInstanceService),Ee(3,r.Inject(r.LocaleService)),Ee(4,f.IZenZoneService),Ee(5,r.Inject(E.SheetDataValidationModel))],Fe);var bn=Object.getOwnPropertyDescriptor,Ln=(e,t,a,n)=>{for(var o=n>1?void 0:n?bn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},lt=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends r.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,o)=>{const{source:i,target:s,unitId:l,subUnitId:d}=n,h=this._sheetDataValidationModel.getRuleObjectMatrix(l,d).clone(),p=$.virtualizeDiscreteRanges([i,s]),[v,c]=p.ranges,{mapFunc:y}=p,g={row:v.startRow,col:v.startColumn},M=$.getAutoFillRepeatRange(v,c),w=new r.ObjectMatrix,m=new Set;M.forEach(D=>{const I=D.repeatStartCell,O=D.relativeRange,N={startRow:g.row,startColumn:g.col,endColumn:g.col,endRow:g.row},H={startRow:I.row,startColumn:I.col,endColumn:I.col,endRow:I.row};r.Range.foreach(O,(A,F)=>{const U=r.Rectangle.getPositionRange({startRow:A,startColumn:F,endColumn:F,endRow:A},N),{row:j,col:W}=y(U.startRow,U.startColumn),Y=this._sheetDataValidationModel.getRuleIdByLocation(l,d,j,W)||"",q=r.Rectangle.getPositionRange({startRow:A,startColumn:F,endColumn:F,endRow:A},H),{row:Z,col:G}=y(q.startRow,q.startColumn);w.setValue(Z,G,Y),m.add(Y)})});const S=Array.from(m).map(D=>({id:D,ranges:r.queryObjectMatrix(w,I=>I===D)}));h.addRangeRules(S);const _=h.diff(this._sheetDataValidationModel.getRules(l,d)),{redoMutations:T,undoMutations:C}=E.getDataValidationDiffMutations(l,d,_,this._injector,"patched",o===$.APPLY_TYPE.ONLY_FORMAT);return{undos:C,redos:T}},a={id:E.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:o,unitId:i,subUnitId:s}=n;for(const l of o.rows)for(const d of o.cols){const h=this._sheetDataValidationModel.getRuleByLocation(i,s,l,d);if(h&&h.type===r.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType($.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,o,i)=>i===$.APPLY_TYPE.COPY||i===$.APPLY_TYPE.ONLY_FORMAT||i===$.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};Me=Ln([lt(0,$.IAutoFillService),lt(1,r.Inject(E.SheetDataValidationModel)),lt(2,r.Inject(r.Injector))],Me);var Tn=Object.getOwnPropertyDescriptor,On=(e,t,a,n)=>{for(var o=n>1?void 0:n?Tn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},dt=(e,t)=>(a,n)=>t(a,n,e);let be=class extends r.Disposable{constructor(t,a,n){super();R(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,o)=>{const{copyType:i=$.COPY_TYPE.COPY,pasteType:s}=o,{range:l}=t||{},{range:d,unitId:h,subUnitId:p}=a;return this._generateMutations(d,{copyType:i,pasteType:s,copyRange:l,unitId:h,subUnitId:p})}})}_collect(t,a,n){const o=new r.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:o};const i=this._injector.invoke(d=>X.rangeToDiscreteRange(n,d,t,a));if(!i)return;const{rows:s,cols:l}=i;s.forEach((d,h)=>{l.forEach((p,v)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(t,a,d,p);o.setValue(h,v,c!=null?c:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===$.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:o,subUnitId:i}=this._copyInfo;if(a.unitId!==o||i!==a.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),l=new r.ObjectMatrix,d=new Set,{ranges:[h,p],mapFunc:v}=$.virtualizeDiscreteRanges([a.copyRange,t]),c=$.getRepeatRange(h,p,!0),y=new Map;c.forEach(({startRange:m})=>{var S;(S=this._copyInfo)==null||S.matrix.forValue((_,T,C)=>{const D=r.Rectangle.getPositionRange({startRow:_,endRow:_,startColumn:T,endColumn:T},m),I=`${i}-${C}`,O=this._sheetDataValidationModel.getRuleById(o,i,C);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,I)&&O&&y.set(I,{...O,uid:I});const{row:N,col:H}=v(D.startRow,D.startColumn);d.add(I),l.setValue(N,H,I)})});const g=Array.from(d).map(m=>({id:m,ranges:r.queryObjectMatrix(l,S=>S===m)}));s.addRangeRules(g);const{redoMutations:M,undoMutations:w}=E.getDataValidationDiffMutations(a.unitId,a.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),y.values()),this._injector,"patched",!1);return{redos:M,undos:w}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(o,i).clone(),l=new r.ObjectMatrix,d=new Set,{ranges:[h,p],mapFunc:v}=$.virtualizeDiscreteRanges([a.copyRange,t]);$.getRepeatRange(h,p,!0).forEach(({startRange:w})=>{var m;(m=this._copyInfo)==null||m.matrix.forValue((S,_,T)=>{const C=r.Rectangle.getPositionRange({startRow:S,endRow:S,startColumn:_,endColumn:_},w),{row:D,col:I}=v(C.startRow,C.startColumn);l.setValue(D,I,T),d.add(T)})});const y=Array.from(d).map(w=>({id:w,ranges:r.queryObjectMatrix(l,m=>m===w)}));s.addRangeRules(y);const{redoMutations:g,undoMutations:M}=E.getDataValidationDiffMutations(o,i,s.diff(this._sheetDataValidationModel.getRules(o,i)),this._injector,"patched",!1);return{redos:g,undos:M}}}};be=On([dt(0,$.ISheetClipboardService),dt(1,r.Inject(E.SheetDataValidationModel)),dt(2,r.Inject(r.Injector))],be);var Pn=Object.getOwnPropertyDescriptor,Rn=(e,t,a,n)=>{for(var o=n>1?void 0:n?Pn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},ct=(e,t)=>(a,n)=>t(a,n,e);let Le=class extends r.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===E.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission,X.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===E.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission,X.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Le=Rn([ct(0,r.Inject(r.LocaleService)),ct(1,r.ICommandService),ct(2,r.Inject(X.SheetPermissionCheckController))],Le);const At="data-validation-single",Ft="sheet.menu.data-validation";function An(e){return{id:Ft,type:f.MenuItemType.SUBITEMS,icon:At,tooltip:"dataValidation.title",hidden$:f.getMenuHiddenObservable(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:$.getCurrentRangeDisable$(e,{workbookTypes:[X.WorkbookEditablePermission],worksheetTypes:[X.WorksheetSetCellStylePermission,X.WorksheetEditPermission],rangeTypes:[X.RangeProtectionPermissionEditPoint]})}}function Fn(e){return{id:Ie.id,title:"dataValidation.panel.title",type:f.MenuItemType.BUTTON}}function kn(e){return{id:He.id,title:"dataValidation.panel.add",type:f.MenuItemType.BUTTON}}const Nn={[f.RibbonStartGroup.FORMULAS_INSERT]:{[Ft]:{order:9,menuItemFactory:An,[Ie.id]:{order:0,menuItemFactory:Fn},[He.id]:{order:1,menuItemFactory:kn}}}};var Un=Object.getOwnPropertyDescriptor,kt=(e,t,a,n)=>{for(var o=n>1?void 0:n?Un(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Q=(e,t)=>(a,n)=>t(a,n,e);const Nt={tr:{size:6,color:"#fe4b4b"}};let Te=class extends r.RxDisposable{constructor(e,t,a,n,o,i,s,l,d,h,p){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=o,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=l,this._sheetInterceptorService=d,this._dataValidationCacheService=h,this._editorBridgeService=p,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Nn)}_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:o,row:i,column:s}=t,l=this._univerInstanceService.getUniverSheetInstance(n);if(!l)return;const d=this._sheetDataValidationModel.getRuleByLocation(n,o,i,s);if(!d)return;const h=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!(h!=null&&h.dropdown))return;const p=l.getActiveSheet();if(!p)return;const v=this._dropdownManagerService.activeDropdown,c=v==null?void 0:v.location;if(c&&c.unitId===n&&c.subUnitId===o&&c.row===i&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:o,row:i,col:s,workbook:l,worksheet:p},componentKey:h.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var m,S,_,T,C;const{row:n,col:o,unitId:i,subUnitId:s,workbook:l,worksheet:d}=t,h=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,o);if(!h)return a(e);const p=this._sheetDataValidationModel.getRuleById(i,s,h);if(!p)return a(e);const v=(m=this._dataValidationCacheService.getValue(i,s,n,o))!=null?m:r.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),y=t.rawData;let g;const M={get value(){var D;return g!==void 0||(g=(D=E.getCellValueOrigin(y))!=null?D:null),g}},w={get value(){var D;return`${(D=M.value)!=null?D:""}`}};return a({...e,markers:{...e==null?void 0:e.markers,...v===r.DataValidationStatus.INVALID?Nt:null},customRender:[...(S=e==null?void 0:e.customRender)!=null?S:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((_=e==null?void 0:e.fontRenderExtension)==null?void 0:_.isSkip)||((T=c==null?void 0:c.skipDefaultFontRender)==null?void 0:T.call(c,p,M.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,w.value,{get style(){const D=l.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,o)},interceptorAutoHeight:()=>{var N,H,A,F,U,j;const D=(H=(N=this._renderManagerService.getRenderById(i))==null?void 0:N.with($.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:H.skeleton;if(!D)return;const I=D.worksheet.getMergedCell(n,o),O={data:e,style:D.getStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex((A=I==null?void 0:I.startRow)!=null?A:n,(F=I==null?void 0:I.startColumn)!=null?F:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(j=(U=c==null?void 0:c.canvasRender)==null?void 0:U.calcCellAutoHeight)==null?void 0:j.call(U,O)},interceptorAutoWidth:()=>{var N,H,A,F,U,j;const D=(H=(N=this._renderManagerService.getRenderById(i))==null?void 0:N.with($.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:H.skeleton;if(!D)return;const I=D.worksheet.getMergedCell(n,o),O={data:e,style:D.getStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex((A=I==null?void 0:I.startRow)!=null?A:n,(F=I==null?void 0:I.startColumn)!=null?F:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(j=(U=c==null?void 0:c.canvasRender)==null?void 0:U.calcCellAutoWidth)==null?void 0:j.call(U,O)},coverable:((C=e==null?void 0:e.coverable)!=null?C:!0)&&!(p.type===r.DataValidationType.LIST||p.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(a=>{var n;(a.rule.type===r.DataValidationType.LIST_MULTIPLE||a.rule.type===r.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(a.redos,this._commandService)}})}};Te=kt([Q(0,r.ICommandService),Q(1,f.IMenuManagerService),Q(2,k.IRenderManagerService),Q(3,r.IUniverInstanceService),Q(4,r.Inject($.AutoHeightController)),Q(5,r.Inject(me)),Q(6,r.Inject(E.SheetDataValidationModel)),Q(7,r.Inject(J.DataValidatorRegistryService)),Q(8,r.Inject(X.SheetInterceptorService)),Q(9,r.Inject(E.DataValidationCacheService)),Q(10,r.Optional($.IEditorBridgeService))],Te);let Ut=class extends r.RxDisposable{constructor(e,t,a,n,o,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=o,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var w,m,S,_,T;const{row:n,col:o,unitId:i,subUnitId:s,workbook:l,worksheet:d}=t,h=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,o);if(!h)return a(e);const p=this._sheetDataValidationModel.getRuleById(i,s,h);if(!p)return a(e);const v=(w=this._dataValidationCacheService.getValue(i,s,n,o))!=null?w:r.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),y=d.getCellRaw(n,o),g=E.getCellValueOrigin(y),M=`${g!=null?g:""}`;return a({...e,markers:{...e==null?void 0:e.markers,...v===r.DataValidationStatus.INVALID?Nt:null},customRender:[...(m=e==null?void 0:e.customRender)!=null?m:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((S=e==null?void 0:e.fontRenderExtension)==null?void 0:S.isSkip)||((_=c==null?void 0:c.skipDefaultFontRender)==null?void 0:_.call(c,p,g,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,M,{get style(){const C=l.getStyles();return(typeof(e==null?void 0:e.s)=="string"?C.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,o)},interceptorAutoHeight:()=>{var O,N,H,A,F,U;const C=(N=(O=this._renderManagerService.getRenderById(i))==null?void 0:O.with($.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:N.skeleton;if(!C)return;const D=C.worksheet.getMergedCell(n,o),I={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((H=D==null?void 0:D.startRow)!=null?H:n,(A=D==null?void 0:D.startColumn)!=null?A:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(U=(F=c==null?void 0:c.canvasRender)==null?void 0:F.calcCellAutoHeight)==null?void 0:U.call(F,I)},coverable:((T=e==null?void 0:e.coverable)!=null?T:!0)&&!(p.type===r.DataValidationType.LIST||p.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.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);r.sequenceExecute(a.redos,this._commandService)}})}};Ut=kt([Q(0,r.ICommandService),Q(1,k.IRenderManagerService),Q(2,r.Inject($.AutoHeightController)),Q(3,r.Inject(J.DataValidatorRegistryService)),Q(4,r.Inject(X.SheetInterceptorService)),Q(5,r.Inject(E.SheetDataValidationModel)),Q(6,r.Inject(E.DataValidationCacheService))],Ut);var Bn=Object.getOwnPropertyDescriptor,jn=(e,t,a,n)=>{for(var o=n>1?void 0:n?Bn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Bt=(e,t)=>(a,n)=>t(a,n,e);let Ye=class extends r.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(o=>{a.add(o.subUnitId)}),a.forEach(o=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(o))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(r.bufferDebounceTime(16)).subscribe(e))}};Ye=jn([Bt(1,r.Inject(E.SheetDataValidationModel)),Bt(2,r.Inject($.SheetSkeletonManagerService))],Ye);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"},Wn=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:o,validResult:i}=e,s=f.useDependency(r.LocaleService),l=o?i==null?void 0:i.formula1:"",d=o?i==null?void 0:i.formula2:"";return t?u.jsxs(u.Fragment,{children:[u.jsx(L.FormLayout,{error:l,children:u.jsx(L.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:h=>{n==null||n({...a,formula1:h})}})}),u.jsx("div",{className:ne.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),u.jsx(L.FormLayout,{error:d,children:u.jsx(L.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:h=>{n==null||n({...a,formula2:h})}})})]}):u.jsx(L.FormLayout,{error:l,children:u.jsx(L.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:h=>{n==null||n({formula1:h})}})})};function $n(e){const{value:t,onChange:a,showError:n,validResult:o}=e,i=f.useDependency(r.LocaleService),s=n?o==null?void 0:o.formula1:"",l=n?o==null?void 0:o.formula2:"",[d,h]=V.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return u.jsxs(u.Fragment,{children:[u.jsx(L.FormLayout,{children:u.jsx(L.Checkbox,{checked:d,onChange:p=>{p?h(!0):(h(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),d?u.jsx(L.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:u.jsx(L.Input,{className:ne.dataValidationFormula,placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:p=>{a==null||a({...t,formula1:p||void 0})}})}):null,d?u.jsx(L.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:l,children:u.jsx(L.Input,{className:ne.dataValidationFormula,placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:p=>{a==null||a({...t,formula2:p||void 0})}})}):null]})}function Hn(e){var v;const{unitId:t,subUnitId:a,value:n,onChange:o,showError:i,validResult:s}=e,l=i?s==null?void 0:s.formula1:void 0,d=V.useRef(null),[h,p]=V.useState(!1);return f.useSidebarClick(c=>{var g;((g=d.current)==null?void 0:g.isClickOutSide(c))&&p(!1)}),u.jsx(nt.FormulaEditor,{initValue:(v=n==null?void 0:n.formula1)!=null?v:"=",unitId:t,subUnitId:a,isFocus:h,onChange:c=>{const y=(c!=null?c:"").trim();y!==(n==null?void 0:n.formula1)&&(o==null||o({...n,formula1:y}))},errorText:l,onFocus:()=>p(!0),isSupportAcrossSheet:!0,ref:d})}const Yn=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],xn=e=>{const{value:t,onChange:a,disabled:n}=e,[o,i]=V.useState(!1);return u.jsx(L.Select,{disabled:n,open:o,onDropdownVisibleChange:i,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ne.dataValidationFormulaColorSelect,value:t,onChange:a,labelRender:s=>u.jsx("div",{className:ne.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>u.jsx("div",{className:ne.dataValidationFormulaColorSelectPanel,children:Yn.map(s=>u.jsx("div",{onClick:()=>{a(s),i(!1)},className:ne.dataValidationFormulaColorItem,style:{background:s}},s))})})},jt=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:o,onItemDelete:i}=a;return u.jsxs("div",{className:ne.dataValidationFormulaListItem,style:n,children:[t.isRef?null:u.jsx("div",{className:L.clsx(ne.dataValidationFormulaListItemDrag,"draggableHandle"),children:u.jsx(Lt,{})}),u.jsx(xn,{value:t.color,onChange:s=>{o(t.id,t.label,s)}}),u.jsx(L.Input,{disabled:t.isRef,value:t.label,onChange:s=>{o(t.id,s,t.color)}}),t.isRef?null:u.jsx("div",{className:ne.dataValidationFormulaListItemIcon,children:u.jsx(at,{onClick:()=>i(t.id)})})]})};function Xn(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:o,validResult:i,showError:s,ruleId:l}=e,{formula1:d="",formula2:h=""}=t||{},p=V.useRef(null),[v,c]=V.useState(()=>r.isFormulaString(d)?"1":"0"),[y,g]=V.useState(v==="1"?d:"="),[M,w]=V.useState(v==="1"?d:"="),m=f.useDependency(r.LocaleService),S=f.useDependency(J.DataValidatorRegistryService),_=f.useDependency(J.DataValidationModel),T=f.useDependency(E.DataValidationFormulaController),[C,D]=V.useState(()=>h.split(",")),I=S.getValidatorItem(r.DataValidationType.LIST),[O,N]=V.useState([]),[H,A]=V.useState(""),F=s?i==null?void 0:i.formula1:"",U=V.useMemo(()=>_.ruleChange$.pipe(ie.debounceTime(16)),[]),j=f.useObservable(U),W=f.useEvent(a);V.useEffect(()=>{(async()=>{await new Promise(z=>{setTimeout(()=>z(!0),100)});const b=_.getRuleById(n,o,l),B=b==null?void 0:b.formula1;if(r.isFormulaString(B)&&I&&b){const z=await I.getListAsync(b,n,o);N(z)}})()},[_,j,I,l,o,n]),V.useEffect(()=>{r.isFormulaString(d)&&d!==M&&(g(d),w(M))},[M,d]);const[Y,q]=V.useState(()=>{const b=v!=="1"?E.deserializeListOptions(d):[],B=h.split(",");return b.map((z,K)=>({label:z,color:B[K]||_e,isRef:!1,id:r.Tools.generateRandomId(4)}))}),Z=(b,B,z)=>{const K=Y.find(fe=>fe.id===b);K&&(K.label=B,K.color=z,q([...Y]))},G=b=>{const B=Y.findIndex(z=>z.id===b);B!==-1&&(Y.splice(B,1),q([...Y]))},ee=h.split(","),te=V.useMemo(()=>O.map((b,B)=>({label:b,color:ee[B]||_e,id:`${B}`,isRef:!0})),[ee,O]),ae=(b,B,z)=>{const K=[...C];K[+b]=z,D(K),W({formula1:d,formula2:K.join(",")})},oe=()=>{q([...Y,{label:"",color:_e,isRef:!1,id:r.Tools.generateRandomId(4)}])};V.useEffect(()=>{if(v==="1")return;const b=new Set,B=[];Y.map(z=>({labelList:z.label.split(","),item:z})).forEach(({item:z,labelList:K})=>{K.forEach(fe=>{b.has(fe)||(b.add(fe),B.push({label:fe,color:z.color}))})}),W({formula1:E.serializeListOptions(B.map(z=>z.label)),formula2:B.map(z=>z.color===_e?"":z.color).join(",")})},[Y,W,v,M,C]);const le=f.useEvent(async b=>{if(!r.isFormulaString(b)){W==null||W({formula1:"",formula2:h});return}T.getFormulaRefCheck(b)?(W==null||W({formula1:r.isFormulaString(b)?b:"",formula2:h}),A("")):(W==null||W({formula1:"",formula2:h}),g("="),A(m.t("dataValidation.validFail.formulaError")))}),re=V.useRef(null),[de,P]=V.useState(!1);return f.useSidebarClick(b=>{var z;((z=re.current)==null?void 0:z.isClickOutSide(b))&&P(!1)}),u.jsxs(u.Fragment,{children:[u.jsx(L.FormLayout,{label:m.t("dataValidation.list.options"),children:u.jsxs(L.RadioGroup,{value:v,onChange:b=>{c(b),g(M),b==="1"&&W({formula1:M==="="?"":M,formula2:C.join(",")})},children:[u.jsx(L.Radio,{value:"0",children:m.t("dataValidation.list.customOptions")}),u.jsx(L.Radio,{value:"1",children:m.t("dataValidation.list.refOptions")})]})}),v==="1"?u.jsxs(u.Fragment,{children:[u.jsx(nt.FormulaEditor,{initValue:y,unitId:n,subUnitId:o,isFocus:de,onChange:(b="")=>{const B=(b!=null?b:"").trim();w(B),le(B)},errorText:F||H||void 0,onFocus:()=>P(!0),isSupportAcrossSheet:!0,ref:re}),u.jsx("div",{ref:p,style:{marginTop:"12px"},children:te.map(b=>u.jsx(jt,{item:b,commonProps:{onItemChange:ae},style:{marginBottom:12}},b.id))})]}):u.jsx(L.FormLayout,{error:F,children:u.jsxs("div",{ref:p,style:{marginTop:"-12px"},children:[u.jsx(L.DraggableList,{list:Y,onListChange:q,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:b=>u.jsx(jt,{item:b,commonProps:{onItemChange:Z,onItemDelete:G}},b.id),idKey:"id"}),u.jsxs("a",{className:ne.dataValidationFormulaListAdd,onClick:oe,children:[u.jsx(Et,{}),m.t("dataValidation.list.add")]})]})})]})}const Wt="data-validation.custom-formula-input",xe="data-validation.formula-input",ut="data-validation.list-formula-input",$t="data-validation.checkbox-formula-input",zn=[[Wt,Hn],[xe,Wn],[ut,Xn],[$t,$n]],Kn="LIST_RENDER_MODE_OPTION_INPUT";function Xe(e){var o;const{value:t,onChange:a}=e,n=f.useDependency(r.LocaleService);return u.jsx(L.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:u.jsxs(L.RadioGroup,{value:`${(o=t.renderMode)!=null?o:r.DataValidationRenderMode.CUSTOM}`,onChange:i=>a({...t,renderMode:+i}),children:[u.jsx(L.Radio,{value:`${r.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),u.jsx(L.Radio,{value:`${r.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),u.jsx(L.Radio,{value:`${r.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}Xe.componentKey=Kn;const Gn="DATE_SHOW_TIME_OPTION";function ze(e){var o;const{value:t,onChange:a}=e,n=f.useDependency(r.LocaleService);return u.jsx(L.FormLayout,{children:u.jsx(L.Checkbox,{checked:(o=t.bizInfo)==null?void 0:o.showTime,onChange:i=>{a({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:n.t("dataValidation.showTime.label")})})}ze.componentKey=Gn;var qn=Object.getOwnPropertyDescriptor,Zn=(e,t,a,n)=>{for(var o=n>1?void 0:n?qn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Oe=(e,t)=>(a,n)=>t(a,n,e);const Ke=6;let ht=class{constructor(e,t,a,n,o,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=a,this._themeService=n,this._renderManagerService=o,this._dataValidationModel=i}_calc(e,t){var h,p,v;const{vt:a,ht:n}=t||{},o=e.endX-e.startX-Ke*2,i=e.endY-e.startY,s=((h=t==null?void 0:t.fs)!=null?h:10)*1.6;let l=0,d=0;switch(a){case r.VerticalAlign.TOP:d=0;break;case r.VerticalAlign.BOTTOM:d=0+(i-s);break;default:d=0+(i-s)/2;break}switch(n){case r.HorizontalAlign.LEFT:l=Ke;break;case r.HorizontalAlign.RIGHT:l=Ke+(o-s);break;default:l=Ke+(o-s)/2;break}return{left:e.startX+l,top:e.startY+d,width:((p=t==null?void 0:t.fs)!=null?p:10)*1.6,height:((v=t==null?void 0:t.fs)!=null?v:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var h,p,v,c,y,g,M,w,m;const{formula1:n=E.CHECKBOX_FORMULA_1,formula2:o=E.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=E.getFormulaResult((v=(p=(h=i==null?void 0:i[0])==null?void 0:h.result)==null?void 0:p[0])==null?void 0:v[0]),l=E.getFormulaResult((g=(y=(c=i==null?void 0:i[1])==null?void 0:c.result)==null?void 0:y[0])==null?void 0:g[0]),d=E.isLegalFormulaResult(String(s))&&E.isLegalFormulaResult(String(l));return{formula1:r.isFormulaString(n)?E.getFormulaResult((m=(w=(M=i==null?void 0:i[0])==null?void 0:M.result)==null?void 0:w[0])==null?void 0:m[0]):n,formula2:r.isFormulaString(o)?l:o,isFormulaValid:d}}drawWith(e,t){var F,U,j,W;const{style:a,primaryWithCoord:n,unitId:o,subUnitId:i,worksheet:s,row:l,col:d}=t,h=n.isMergedMainCell?n.mergeInfo:n,p=E.getCellValueOrigin(s.getCellRaw(l,d)),v=this._dataValidationModel.getRuleByLocation(o,i,l,d);if(!v)return;const c=this._dataValidationModel.getValidator(v.type);if(!c)return;const y=this._themeService.getCurrentTheme();if(!((F=c.skipDefaultFontRender)!=null&&F.call(c,v,p,{unitId:o,subUnitId:i,row:l,column:d})))return;const g=c.parseFormulaSync(v,o,i),{formula1:M}=g,w=this._calc(h,a),{a:m,d:S}=e.getTransform(),_=k.fixLineWidthByScale(w.left,m),T=k.fixLineWidthByScale(w.top,S),C=k.Transform.create().composeMatrix({left:_,top:T,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),D=h.endX-h.startX,I=h.endY-h.startY;e.save(),e.beginPath(),e.rect(h.startX,h.startY,D,I),e.clip();const O=C.getMatrix();e.transform(O[0],O[1],O[2],O[3],O[4],O[5]);const N=((U=a==null?void 0:a.fs)!=null?U:10)*1.6,H=String(p)===String(M),A=y.hyacinth500;k.CheckboxShape.drawWith(e,{checked:H,width:N,height:N,fill:(W=(j=a==null?void 0:a.cl)==null?void 0:j.rgb)!=null?W:A}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),o=n.top,i=n.top+n.height,s=n.left,l=n.left+n.width,{x:d,y:h}=e;return d<=l&&d>=s&&h<=i&&h>=o}async onPointerDown(e,t){var g;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:o,worksheet:i,row:s,col:l}=e,d=E.getCellValueOrigin(i.getCellRaw(s,l)),h=this._dataValidationModel.getRuleByLocation(n,o,s,l);if(!h)return;const p=this._dataValidationModel.getValidator(h.type);if(!p||!((g=p.skipDefaultFontRender)!=null&&g.call(p,h,d,{unitId:n,subUnitId:o,row:s,column:l})))return;const{formula1:v,formula2:c}=await this._parseFormula(h,n,o),y={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(d)===E.transformCheckboxValue(String(v))?c:v,p:null}};this._commandService.executeCommand(X.SetRangeValuesCommand.id,y)}onPointerEnter(e,t){var a,n;(n=(a=k.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(k.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=k.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(k.CURSOR_TYPE.DEFAULT)}};ht=Zn([Oe(0,r.ICommandService),Oe(1,r.IUniverInstanceService),Oe(2,r.Inject(E.DataValidationFormulaService)),Oe(3,r.Inject(r.ThemeService)),Oe(4,r.Inject(k.IRenderManagerService)),Oe(5,r.Inject(E.SheetDataValidationModel))],ht);var Jn=Object.getOwnPropertyDescriptor,Qn=(e,t,a,n)=>{for(var o=n>1?void 0:n?Jn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},ea=(e,t)=>(a,n)=>t(a,n,e);let he=class{constructor(e){R(this,"canvasRender",null);R(this,"dropdown");R(this,"optionsInput");R(this,"formulaInput",ut);this.injector=e}};he=Qn([ea(0,r.Inject(r.Injector))],he);class ta extends he{constructor(){super(...arguments);R(this,"id",r.DataValidationType.CHECKBOX);R(this,"canvasRender",this.injector.createInstance(ht));R(this,"formulaInput",$t)}}class na extends he{constructor(){super(...arguments);R(this,"id",r.DataValidationType.CUSTOM);R(this,"formulaInput",Wt)}}const aa="data-validation.formula-input";class oa extends he{constructor(){super(...arguments);R(this,"id",r.DataValidationType.DATE);R(this,"formulaInput",aa);R(this,"optionsInput",ze.componentKey);R(this,"dropdown",st)}}class ia extends he{constructor(){super(...arguments);R(this,"id",r.DataValidationType.DECIMAL);R(this,"formulaInput",xe)}}const Ht=4,ra=0,pt=4,Yt=4,vt=6,Ge=6,De=14;function sa(e,t){const a=k.FontCache.getTextSize(e,t),n=a.width+Ht*2,{ba:o,bd:i}=a,s=o+i;return{width:n,height:s+ra*2,ba:o}}function gt(e,t,a,n){const o=De+vt*2,i=a-o,s=n-Ge*2,l=e.map(c=>({layout:sa(c,t),text:c}));let d;const h=[];l.forEach(c=>{const{layout:y}=c,{width:g,height:M}=y;!d||d.width+g+pt>i?(d={width:g,height:M,items:[{...c,left:0}]},h.push(d)):(d.items.push({...c,left:d.width+pt}),d.width=d.width+g+pt)});let p=0,v=0;return h.forEach((c,y)=>{v=Math.max(v,c.width),y===h.length-1?p+=c.height:p+=c.height+Yt}),{lines:h,totalHeight:p,contentWidth:i,contentHeight:s,cellAutoHeight:p+Ge*2,calcAutoWidth:v+o}}const la=8;class da extends k.Shape{static drawWith(t,a){const{fontString:n,info:o,fill:i,color:s}=a,{layout:l,text:d}=o;t.save(),k.Rect.drawWith(t,{width:l.width,height:l.height,radius:la,fill:i||_e}),t.translateWithPrecision(Ht,l.ba),t.font=n,t.fillStyle=s,t.fillText(d,0,0),t.restore()}}var ca=Object.getOwnPropertyDescriptor,ua=(e,t,a,n)=>{for(var o=n>1?void 0:n?ca(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},qe=(e,t)=>(a,n)=>t(a,n,e);const ha=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,a,n){R(this,"zIndex");R(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=a,this._dataValidationModel=n}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,o){const i=a-De+4;let s=4;switch(o){case r.VerticalAlign.MIDDLE:s=(n-De)/2+4;break;case r.VerticalAlign.BOTTOM:s=n-De+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(ha),e.restore()}drawWith(e,t,a,n){var Z,G;const{primaryWithCoord:o,row:i,col:s,style:l,data:d,subUnitId:h}=t,p=o.isMergedMainCell?o.mergeInfo:o,v=d==null?void 0:d.fontRenderExtension,{leftOffset:c=0,rightOffset:y=0,topOffset:g=0,downOffset:M=0}=v||{},w=this._ensureMap(h),m=this._generateKey(i,s),S=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,s);if(!S)return;const _=this._dataValidationModel.getValidator(S.type);if(!_)return;const T={startX:p.startX+c,endX:p.endX-y,startY:p.startY+g,endY:p.endY-M},C=T.endX-T.startX,D=T.endY-T.startY,{cl:I}=l||{},O=(Z=typeof I=="object"?I==null?void 0:I.rgb:I)!=null?Z:"#000",N=k.getFontStyleString(l!=null?l:void 0),{vt:H,ht:A}=l||{},F=H!=null?H:r.VerticalAlign.MIDDLE,U=(G=E.getCellValueOrigin(d))!=null?G:"",j=_.parseCellValue(U),W=_.getListWithColorMap(S),Y=gt(j,N,C,D);this._drawDownIcon(e,T,C,D,F),e.save(),e.translateWithPrecision(T.startX,T.startY),e.beginPath(),e.rect(0,0,C-De,D),e.clip(),e.translateWithPrecision(vt,Ge);let q=0;switch(F){case r.VerticalAlign.MIDDLE:q=(Y.contentHeight-Y.totalHeight)/2;break;case r.VerticalAlign.BOTTOM:q=Y.contentHeight-Y.totalHeight;break}e.translateWithPrecision(0,q),Y.lines.forEach((ee,te)=>{e.save();const{width:ae,height:oe,items:le}=ee;let re=0;switch(A){case r.HorizontalAlign.RIGHT:re=Y.contentWidth-ae;break;case r.HorizontalAlign.CENTER:re=(Y.contentWidth-ae)/2;break}e.translate(re,te*(oe+Yt)),le.forEach(de=>{e.save(),e.translateWithPrecision(de.left,0),da.drawWith(e,{...N,info:de,color:O,fill:W[de.text]}),e.restore()}),e.restore()}),e.restore(),w.set(m,{left:T.startX,top:T.startY,width:Y.contentWidth+vt+De,height:Y.contentHeight+Ge*2})}calcCellAutoHeight(e){var C;const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:p=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,c={startX:v.startX+l,endX:v.endX-d,startY:v.startY+h,endY:v.endY-p},y=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!y)return;const g=this._dataValidationModel.getValidator(y.type);if(!g)return;const M=c.endX-c.startX,w=c.endY-c.startY,m=(C=E.getCellValueOrigin(n))!=null?C:"",S=g.parseCellValue(m),_=k.getFontStyleString(a!=null?a:void 0);return gt(S,_,M,w).cellAutoHeight}calcCellAutoWidth(e){var C;const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:p=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,c={startX:v.startX+l,endX:v.endX-d,startY:v.startY+h,endY:v.endY-p},y=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!y)return;const g=this._dataValidationModel.getValidator(y.type);if(!g)return;const M=c.endX-c.startX,w=c.endY-c.startY,m=(C=E.getCellValueOrigin(n))!=null?C:"",S=g.parseCellValue(m),_=k.getFontStyleString(a!=null?a:void 0);return gt(S,_,M,w).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:o}=n,{x:i}=e;return i>=o-De&&i<=o}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:i}=e,s={unitId:a,subUnitId:n,row:o,column:i};this._commandService.executeCommand(Ue.id,s)}onPointerEnter(e,t){var a,n;return(n=(a=k.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(k.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;return(n=(a=k.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(k.CURSOR_TYPE.DEFAULT)}};mt=ua([qe(0,r.ICommandService),qe(1,r.IUniverInstanceService),qe(2,r.Inject(k.IRenderManagerService)),qe(3,r.Inject(E.SheetDataValidationModel))],mt);class pa extends he{constructor(){super(...arguments);R(this,"id",r.DataValidationType.LIST_MULTIPLE);R(this,"canvasRender",this.injector.createInstance(mt));R(this,"dropdown",$e)}}var va=Object.getOwnPropertyDescriptor,ga=(e,t,a,n)=>{for(var o=n>1?void 0:n?va(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},ke=(e,t)=>(a,n)=>t(a,n,e);const ye=4,Ze=4,ce=14,pe=6,Pe=4,ft=8,ma="#565656",xt=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 fa(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${r.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:r.BooleanNumber.FALSE,bl:r.BooleanNumber.FALSE,ul:{s:r.BooleanNumber.FALSE},st:{s:r.BooleanNumber.FALSE},ol:{s:r.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 Xt(e,t,a){const n=fa(e,a),o=new r.DocumentDataModel(n),i=new k.DocumentViewModel(o);return{documentSkeleton:k.DocumentSkeleton.create(i,t),docModel:o,docViewModel:i}}function Je(e,t,a){const{documentSkeleton:n,docModel:o,docViewModel:i}=Xt(e,t,a);return{documents:new k.Documents(`DOCUMENTS_${r.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:o,docViewModel:i}}function zt(e,t,a,n,o,i,s=!0){let l=0;const d=s?Pe:0;switch(o){case r.VerticalAlign.BOTTOM:l=t-n-d;break;case r.VerticalAlign.MIDDLE:l=(t-n)/2;break;default:l=d;break}l=Math.max(Pe,l);let h=0;switch(i){case r.HorizontalAlign.CENTER:h=(e-a)/2;break;case r.HorizontalAlign.RIGHT:h=e-a;break}return h=Math.max(pe,h),{paddingLeft:h,paddingTop:l}}let St=class{constructor(e,t,a,n,o){R(this,"_dropdownInfoMap",new Map);R(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=a,this._renderManagerService=n,this._dataValidationModel=o}_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,o,i,s){const{t:l=r.DEFAULT_STYLES.pd.t,b:d=r.DEFAULT_STYLES.pd.b}=s,h=a-ce;let p;switch(i){case r.VerticalAlign.MIDDLE:p=(n-Ze)/2;break;case r.VerticalAlign.BOTTOM:p=n-d-o-Pe+(o/2-Ze/2);break;default:p=l+Pe+(o/2-Ze/2);break}e.save(),e.translateWithPrecision(t.startX+h,t.startY+p),e.fillStyle="#565656",e.fill(xt),e.restore()}drawWith(e,t,a){const{primaryWithCoord:n,row:o,col:i,style:s,data:l,subUnitId:d}=t,h=n.isMergedMainCell?n.mergeInfo:n,p=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,o,i);if(!p)return;const v=this._dataValidationModel.getValidator(p.type);if(!v)return;const c=l==null?void 0:l.fontRenderExtension,{leftOffset:y=0,rightOffset:g=0,topOffset:M=0,downOffset:w=0}=c||{};if(!p||!v||!v||v.id.indexOf(r.DataValidationType.LIST)!==0||!v.skipDefaultFontRender(p))return;const m={startX:h.startX+y,endX:h.endX-g,startY:h.startY+M,endY:h.endY-w},S=m.endX-m.startX,_=m.endY-m.startY,T=this._ensureMap(d),C=this._generateKey(o,i),D=v.getListWithColor(p),I=E.getCellValueOrigin(l),O=`${I!=null?I:""}`,N=D.find(j=>j.label===O);let{tb:H,vt:A,ht:F,pd:U}=s||{};if(H=H!=null?H:r.WrapStrategy.WRAP,A=A!=null?A:r.VerticalAlign.BOTTOM,F=F!=null?F:r.DEFAULT_STYLES.ht,U=U!=null?U:r.DEFAULT_STYLES.pd,p.renderMode===r.DataValidationRenderMode.ARROW){const{l:j=r.DEFAULT_STYLES.pd.l,t:W=r.DEFAULT_STYLES.pd.t,r:Y=r.DEFAULT_STYLES.pd.r,b:q=r.DEFAULT_STYLES.pd.b}=U,Z=S-j-Y-ce-4,{documentSkeleton:G,documents:ee,docModel:te}=Je(O,this._localeService,s);H===r.WrapStrategy.WRAP&&te.updateDocumentDataPageSize(Math.max(Z,1)),G.calculate(),G.getActualSize();const ae=k.getDocsSkeletonPageSize(G),{height:oe,width:le}=ae,{paddingTop:re,paddingLeft:de}=zt(Z,_-W-q,le,oe,A,F,!0);this._drawDownIcon(e,m,S,_,oe,A,U),e.save(),e.translateWithPrecision(m.startX+j,m.startY+W),e.beginPath(),e.rect(0,0,S-j-Y,_-W-q),e.clip(),e.translateWithPrecision(0,re),e.save(),e.translateWithPrecision(ye,0),e.beginPath(),e.rect(0,0,Z,oe),e.clip(),ee.render(e),e.translateWithPrecision(de,0),e.restore(),e.restore(),T.set(C,{left:m.endX+j+a.rowHeaderWidth-ce,top:m.startY+W+a.columnHeaderHeight,width:ce,height:_-W-q})}else{e.save(),e.translateWithPrecision(m.startX,m.startY),e.beginPath(),e.rect(0,0,S,_),e.clip();const j=S-pe*2-ye-ce-4,{documentSkeleton:W,documents:Y,docModel:q}=Je(O,this._localeService,s);H===r.WrapStrategy.WRAP&&q.updateDocumentDataPageSize(Math.max(j,1)),W.calculate();const Z=k.getDocsSkeletonPageSize(W),{height:G,width:ee}=Z,{paddingTop:te,paddingLeft:ae}=zt(j,_,ee,G,A,F);e.translateWithPrecision(pe,te);const oe=Math.max(S-pe*2,1),le=G;k.Rect.drawWith(e,{width:oe,height:le,fill:(N==null?void 0:N.color)||_e,radius:ft}),e.save(),e.translateWithPrecision(ye,0),e.beginPath(),e.rect(0,0,j,G),e.clip(),e.translateWithPrecision(ae,0),Y.render(e),e.restore(),e.translateWithPrecision(j+ye+4,(G-Ze)/2),e.fillStyle=ma,e.fill(xt),e.restore(),T.set(C,{left:m.startX+pe+a.rowHeaderWidth,top:m.startY+te+a.columnHeaderHeight,width:oe,height:le})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,l=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:h=0,topOffset:p=0,downOffset:v=0}=l||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!c||c.renderMode===r.DataValidationRenderMode.TEXT)return;const y={startX:s.startX+d,endX:s.endX-h,startY:s.startY+p,endY:s.endY-v},g=y.endX-y.startX,M=E.getCellValueOrigin(n),w=`${M!=null?M:""}`;let{tb:m,pd:S}=a||{};const{t:_=r.DEFAULT_STYLES.pd.t,b:T=r.DEFAULT_STYLES.pd.b}=S!=null?S:{};if(m=m!=null?m:r.WrapStrategy.WRAP,c.renderMode===r.DataValidationRenderMode.ARROW){const C=g-ce,{documentSkeleton:D,docModel:I}=Je(w,this._localeService,a);m===r.WrapStrategy.WRAP&&I.updateDocumentDataPageSize(Math.max(C,1)),D.calculate(),D.getActualSize();const O=k.getDocsSkeletonPageSize(D),{height:N}=O;return N+_+T+Pe*2}else{const C=g-pe*2-ye-ce,{documentSkeleton:D,docModel:I}=Xt(w,this._localeService,a);m===r.WrapStrategy.WRAP&&I.updateDocumentDataPageSize(Math.max(C,1)),D.calculate();const O=k.getDocsSkeletonPageSize(D),{height:N}=O;return N+Pe*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,l=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:h=0,topOffset:p=0,downOffset:v=0}=l||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!c||c.renderMode===r.DataValidationRenderMode.TEXT)return;const y={startX:s.startX+d,endX:s.endX-h,startY:s.startY+p,endY:s.endY-v},g=y.endX-y.startX,M=E.getCellValueOrigin(n),w=`${M!=null?M:""}`;let{tb:m,pd:S}=a||{};const{l:_=r.DEFAULT_STYLES.pd.l,r:T=r.DEFAULT_STYLES.pd.r}=S!=null?S:{};m=m!=null?m:r.WrapStrategy.WRAP;let C=pe*2+ce;switch(c.renderMode){case r.DataValidationRenderMode.ARROW:C=ce+pe*2+T+_;break;case r.DataValidationRenderMode.CUSTOM:C=ce+pe*2+ye*2+T+_+ft/2+1;break;default:C=ce+pe*2+ye*2+T+_+ft/2+1}const D=g-C,{documentSkeleton:I,docModel:O}=Je(w,this._localeService,a);return m===r.WrapStrategy.WRAP&&O.updateDocumentDataPageSize(Math.max(D,1)),I.calculate(),I.getActualSize(),k.getDocsSkeletonPageSize(I).width+C}isHit(e,t){const{subUnitId:a,row:n,col:o}=t,s=this._ensureMap(a).get(this._generateKey(n,o)),l=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,o);if(!l||!s||l.renderMode===r.DataValidationRenderMode.TEXT)return!1;const{top:d,left:h,width:p,height:v}=s,{x:c,y}=e;return c>=h&&c<=h+p&&y>=d&&y<=d+v}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:i}=e,s={unitId:a,subUnitId:n,row:o,column:i};this._commandService.executeCommand(Ue.id,s)}onPointerEnter(e,t){var a,n;(n=(a=k.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(k.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=k.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(k.CURSOR_TYPE.DEFAULT)}};St=ga([ke(0,r.IUniverInstanceService),ke(1,r.Inject(r.LocaleService)),ke(2,r.ICommandService),ke(3,r.Inject(k.IRenderManagerService)),ke(4,r.Inject(E.SheetDataValidationModel))],St);class Sa extends he{constructor(){super(...arguments);R(this,"id",r.DataValidationType.LIST);R(this,"canvasRender",this.injector.createInstance(St));R(this,"dropdown",$e);R(this,"optionsInput",Xe.componentKey);R(this,"formulaInput",ut)}}class Ia extends he{constructor(){super(...arguments);R(this,"id",r.DataValidationType.TEXT_LENGTH);R(this,"formulaInput",xe)}}class _a extends he{constructor(){super(...arguments);R(this,"id",r.DataValidationType.WHOLE);R(this,"formulaInput",xe)}}var Ca=Object.getOwnPropertyDescriptor,Da=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ca(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},It=(e,t)=>(a,n)=>t(a,n,e);let Re=class extends r.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[At,Vt],[Ne,Vn],[Ot,vn],[$e,Sn],[st,Qt],[Xe.componentKey,Xe],[ze.componentKey,ze],...zn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[ia,_a,Ia,oa,ta,Sa,pa,na].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)})}};Re=Da([It(0,r.Inject(r.Injector)),It(1,r.Inject(f.ComponentManager)),It(2,r.Inject(J.DataValidatorRegistryService))],Re);var ya=Object.getOwnPropertyDescriptor,wa=(e,t,a,n)=>{for(var o=n>1?void 0:n?ya(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},_t=(e,t)=>(a,n)=>t(a,n,e);const Va="SHEET_DATA_VALIDATION_UI_PLUGIN";x.UniverSheetsDataValidationUIPlugin=(Qe=class extends r.Plugin{constructor(t=Be,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:i,...s}=r.merge({},Be,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(it,s)}onStarting(){[[ue],[me],[Fe],[Me],[Te],[Le],[be],[Ae],[Re]].forEach(t=>{this._injector.add(t)}),[He,Ue,Rt,ot,Ie,Pt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(be),this._injector.get(Le),this._injector.get(Ae),this._injector.get(Fe),this._injector.get(k.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[Ye])}onRendered(){this._injector.get(Re),this._injector.get(Te)}onSteady(){this._injector.get(Me)}},R(Qe,"pluginName",Va),R(Qe,"type",r.UniverInstanceType.UNIVER_SHEET),Qe),x.UniverSheetsDataValidationUIPlugin=wa([_t(1,r.Inject(r.Injector)),_t(2,r.ICommandService),_t(3,r.IConfigService)],x.UniverSheetsDataValidationUIPlugin);var Ea=Object.getOwnPropertyDescriptor,Ma=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ea(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Ct=(e,t)=>(a,n)=>t(a,n,e);const ba="SHEET_DATA_VALIDATION_UI_PLUGIN";x.UniverSheetsDataValidationMobileUIPlugin=(et=class extends r.Plugin{constructor(t=Be,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:i,...s}=r.merge({},Be,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(it,s)}onStarting(){[[ue],[me],[Fe],[Me],[Te],[Le],[be],[Re]].forEach(t=>{this._injector.add(t)}),[He,Ue,Rt,ot,Ie,Pt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(be),this._injector.get(Le),this._injector.get(k.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[Ye])}onRendered(){this._injector.get(Re),this._injector.get(Te)}onSteady(){this._injector.get(Me)}},R(et,"pluginName",ba),R(et,"type",r.UniverInstanceType.UNIVER_SHEET),et),x.UniverSheetsDataValidationMobileUIPlugin=Ma([Ct(1,r.Inject(r.Injector)),Ct(2,r.ICommandService),Ct(3,r.IConfigService)],x.UniverSheetsDataValidationMobileUIPlugin),x.DATE_DROPDOWN_KEY=st,x.LIST_DROPDOWN_KEY=$e,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
1
+ (function(x,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react/jsx-runtime"),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("react"),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/jsx-runtime","@univerjs/core","@univerjs/design","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-data-validation","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/ui","react","@univerjs/data-validation","@univerjs/docs","rxjs","@univerjs/engine-formula","@univerjs/sheets-formula-ui"],u):(x=typeof globalThis<"u"?globalThis:x||self,u(x.UniverSheetsDataValidationUi={},x.React,x.UniverCore,x.UniverDesign,x.UniverEngineRender,x.UniverSheets,x.UniverSheetsDataValidation,x.UniverSheetsNumfmt,x.UniverSheetsUi,x.UniverUi,x.React,x.UniverDataValidation,x.UniverDocs,x.rxjs,x.UniverEngineFormula,x.UniverSheetsFormulaUi))})(this,function(x,u,r,L,k,X,E,Kt,$,f,V,J,Gt,ie,tt,nt){"use strict";var Ta=Object.defineProperty;var Oa=(x,u,r)=>u in x?Ta(x,u,{enumerable:!0,configurable:!0,writable:!0,value:r}):x[u]=r;var R=(x,u,r)=>Oa(x,typeof u!="symbol"?u+"":u,r);var Qe,et;var qt=Object.getOwnPropertyDescriptor,Zt=(e,t,a,n)=>{for(var o=n>1?void 0:n?qt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},we=(e,t)=>(a,n)=>t(a,n,e);let Ae=class extends r.Disposable{constructor(e,t,a,n,o,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=o,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(X.VALIDATE_CELL,{handler:async(e,t,a)=>{const n=await e,{row:o,col:i,unitId:s,subUnitId:l}=t,d=this._dataValidationModel.getRuleIdByLocation(s,l,o,i),h=d?this._dataValidationModel.getRuleById(s,l,d):void 0;if(n===!1)return a(Promise.resolve(!1));if(!h||h.errorStyle!==r.DataValidationErrorStyle.STOP)return a(Promise.resolve(!0));const p=this._dataValidatorRegistryService.getValidatorItem(h.type);return!p||await this._sheetsDataValidationValidatorService.validatorCell(s,l,o,i)===r.DataValidationStatus.VALID?a(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:p.getRuleFinalError(h,{row:o,col:i,unitId:s,subUnitId:l})},footer:{title:V.createElement(L.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(Promise.resolve(!1)))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:V.createElement(L.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Ae=Zt([we(0,r.Inject(X.SheetInterceptorService)),we(1,r.Inject(E.SheetDataValidationModel)),we(2,r.Inject(J.DataValidatorRegistryService)),we(3,f.IDialogService),we(4,r.Inject(r.LocaleService)),we(5,r.Inject(E.SheetsDataValidationValidatorService))],Ae);const Dt={dvDateDropdown:"univer-dv-date-dropdown",dvDateDropdownBtns:"univer-dv-date-dropdown-btns"},Jt=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return r.dayjs(r.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=r.dayjs(e);if(t.isValid())return t};function Qt(e){var I;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:i,unitId:s,subUnitId:l,workbook:d}=t,h=f.useDependency(r.ICommandService),p=f.useDependency(Ae),v=n.getCell(o,i),c=E.getCellValueOrigin(n.getCellRaw(o,i)),y=Jt(c),[g,M]=V.useState(y),w=g&&g.isValid()?g:r.dayjs(),m=f.useDependency(r.LocaleService),S=f.useDependency(E.SheetDataValidationModel),_=S.getRuleByLocation(s,l,o,i);if(!_)return null;const T=S.getValidator(_.type);if(!v||!T)return;const C=!!((I=_.bizInfo)!=null&&I.showTime),D=async()=>{var j,W,Y;if(!w)return;const N=w.format(C?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),H=(j=r.numfmt.parseDate(N))==null?void 0:j.v,A=d.getStyles().getStyleByCell(v),F=(Y=(W=A==null?void 0:A.n)==null?void 0:W.pattern)!=null?Y:"",U=Kt.getPatternType(F);_.errorStyle!==r.DataValidationErrorStyle.STOP||await T.validator({value:H,unitId:s,subUnitId:l,row:o,column:i,worksheet:n,workbook:d,interceptValue:N.replace("Z","").replace("T"," "),t:r.CellValueType.NUMBER},_)?(a(),await h.executeCommand($.SetCellEditVisibleOperation.id,{visible:!1,eventType:k.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),await h.executeCommand(X.SetRangeValuesCommand.id,{unitId:s,subUnitId:l,range:{startColumn:i,endColumn:i,startRow:o,endRow:o},value:{v:H,t:2,p:null,f:null,si:null,s:{n:{pattern:C?U==="datetime"?F:"yyyy-MM-dd hh:mm:ss":U==="date"?F:"yyyy-MM-dd"}}}})):p.showReject(T.getRuleFinalError(_,{row:o,col:i,unitId:s,subUnitId:l}))};return u.jsxs("div",{className:Dt.dvDateDropdown,children:[u.jsx(L.DatePanel,{defaultValue:w,pickerValue:w,showTime:C||void 0,onSelect:async O=>{M(O)},onPanelChange:O=>{M(O)},disabledDate:O=>!r.numfmt.parseDate(O.format("YYYY-MM-DD"))}),u.jsx("div",{className:Dt.dvDateDropdownBtns,children:u.jsx(L.Button,{size:"small",variant:"primary",onClick:D,disabled:!w.isValid(),children:m.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 o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},se.apply(this,arguments)},en=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 o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(a[n[o]]=e[n[o]]);return a},ge=V.forwardRef(function(e,t){var a=e.icon,n=e.id,o=e.className,i=e.extend,s=en(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),d=V.useRef("_".concat(an()));return yt(a,"".concat(n),{defIds:a.defIds,idSuffix:d.current},se({ref:t,className:l},s),i)});function yt(e,t,a,n,o){return V.createElement(e.tag,se(se({key:t},tn(e,a,o)),n),(nn(e,a).children||[]).map(function(i,s){return yt(i,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,o)}))}function tn(e,t,a){var n=se({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],l=i[1];s==="mask"&&typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var o=t.defIds;return!o||o.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],l=i[1];typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function nn(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(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?se(se({},o),{attrs:se(se({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):e}function an(){return Math.random().toString(36).substring(2,8)}ge.displayName="UniverIcon";var on={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"}}]},wt=V.forwardRef(function(e,t){return V.createElement(ge,Object.assign({},e,{id:"check-mark-single",ref:t,icon:on}))});wt.displayName="CheckMarkSingle";var rn={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"}}]},Vt=V.forwardRef(function(e,t){return V.createElement(ge,Object.assign({},e,{id:"data-validation-single",ref:t,icon:rn}))});Vt.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"}}]},at=V.forwardRef(function(e,t){return V.createElement(ge,Object.assign({},e,{id:"delete-single",ref:t,icon:sn}))});at.displayName="DeleteSingle";var ln={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"}}]},Et=V.forwardRef(function(e,t){return V.createElement(ge,Object.assign({},e,{id:"increase-single",ref:t,icon:ln}))});Et.displayName="IncreaseSingle";var dn={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=V.forwardRef(function(e,t){return V.createElement(ge,Object.assign({},e,{id:"more-down-single",ref:t,icon:dn}))});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=V.forwardRef(function(e,t){return V.createElement(ge,Object.assign({},e,{id:"more-up-single",ref:t,icon:cn}))});bt.displayName="MoreUpSingle";var un={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=V.forwardRef(function(e,t){return V.createElement(ge,Object.assign({},e,{id:"sequence-single",ref:t,icon:un}))});Lt.displayName="SequenceSingle";var hn=Object.getOwnPropertyDescriptor,pn=(e,t,a,n)=>{for(var o=n>1?void 0:n?hn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Tt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends r.Disposable{constructor(t,a){super();R(this,"_open$",new ie.BehaviorSubject(!1));R(this,"open$",this._open$.pipe(ie.distinctUntilChanged()));R(this,"_activeRule");R(this,"_activeRule$",new ie.BehaviorSubject(void 0));R(this,"activeRule$",this._activeRule$.asObservable());R(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).pipe(ie.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===Ne&&(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=r.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ue=pn([Tt(0,r.IUniverInstanceService),Tt(1,f.ISidebarService)],ue);function vn(){const e=f.useDependency(me),t=f.useObservable(e.activeDropdown$,e.activeDropdown),a=f.useDependency(f.ComponentManager);if(!t)return null;const{location:n,componentKey:o}=t,i=a.get(o),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!i)return null;const l=()=>{e.hideDropdown()};return u.jsx(i,{location:n,hideFn:l},s)}const Ot="sheet.ui.dropdown";var gn=Object.getOwnPropertyDescriptor,mn=(e,t,a,n)=>{for(var o=n>1?void 0:n?gn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Se=(e,t)=>(a,n)=>t(a,n,e);let me=class extends r.Disposable{constructor(t,a,n,o,i,s,l){super();R(this,"_activeDropdown");R(this,"_activeDropdown$",new ie.Subject);R(this,"_currentPopup",null);R(this,"activeDropdown$",this._activeDropdown$.asObservable());R(this,"_zenVisible",!1);this._canvasPopupManagerService=t,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=o,this._renderManagerService=i,this._dataValidationModel=s,this._sheetsSelectionsService=l,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,o){const i=t?this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=a?i.getSheetBySheetId(a):i.getActiveSheet();if(!s)return;const l=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,o);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);return d==null?void 0:d.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:o,col:i,unitId:s,subUnitId:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const d=this._renderManagerService.getRenderById(r.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),h=this._canvasPopupManagerService.attachPopupToCell(o,i,{componentKey:Ot,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[d==null?void 0:d.engine.getCanvasElement()].filter(Boolean)},s,l);if(!h)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const p=new r.DisposableCollection;p.add(h),p.add({dispose:()=>{var v,c;(c=(v=this._activeDropdown)==null?void 0:v.onHide)==null||c.call(v)}}),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,o,i){const s=this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET);if(!s)return;const l=s.getSheetBySheetId(a);if(!l)return;const d=this._dataValidationModel.getRuleByLocation(s.getUnitId(),l.getSheetId(),n,o);if(!d)return;const h=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!h||!h.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:l,row:n,col:o,unitId:t,subUnitId:a},componentKey:h.dropdown,onHide:i})}};me=mn([Se(0,r.Inject($.SheetCanvasPopManagerService)),Se(1,r.IUniverInstanceService),Se(2,r.Inject(J.DataValidatorRegistryService)),Se(3,f.IZenZoneService),Se(4,k.IRenderManagerService),Se(5,r.Inject(E.SheetDataValidationModel)),Se(6,r.Inject(X.SheetsSelectionsService))],me);const Ne="DataValidationPanel",Ie={id:"data-validation.operation.open-validation-panel",type:r.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,o=e.get(ue),i=e.get(J.DataValidationModel),s=e.get(r.IUniverInstanceService),l=e.get(f.ISidebarService),d=X.getSheetCommandTarget(s);if(!d)return!1;const{unitId:h,subUnitId:p}=d,v=a?i.getRuleById(h,p,a):void 0;o.open(),o.setActiveRule(v&&{unitId:h,subUnitId:p,rule:v});const c=l.open({id:Ne,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Ne},width:312,onClose:()=>o.close()});return o.setCloseDisposable(c),!0}},ot={id:"data-validation.operation.close-validation-panel",type:r.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},Pt={id:"data-validation.operation.toggle-validation-panel",type:r.CommandType.OPERATION,handler(e){const t=e.get(r.ICommandService),a=e.get(ue);return a.open(),a.isOpen?t.executeCommand(ot.id):t.executeCommand(Ie.id),!0}},Ue={type:r.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(me),{unitId:n,subUnitId:o,row:i,column:s}=t,l=a.activeDropdown,d=l==null?void 0:l.location;return d&&d.unitId===n&&d.subUnitId===o&&d.row===i&&d.col===s||a.showDataValidationDropdown(n,o,i,s),!0}},Rt={type:r.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(me).hideDropdown(),!0):!1}},_e="#ECECEC",it="sheets-data-validation-ui.config",Be={},ve={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"},fn=e=>{var C,D;const{value:t,onChange:a,multiple:n,options:o,title:i,onEdit:s,style:l,filter:d,location:h}=e,p=f.useDependency(r.LocaleService),v=f.useDependency(r.IConfigService),c=d==null?void 0:d.toLowerCase(),{row:y,col:g,unitId:M,subUnitId:w}=h,m=o.filter(I=>c?I.label.toLowerCase().includes(c):!0),S=(D=(C=v.getConfig(it))==null?void 0:C.showEditOnDropdown)!=null?D:!0,_=f.useDependency(X.SheetPermissionCheckController),T=V.useMemo(()=>_.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission]},[{startColumn:g,startRow:y,endColumn:g,endRow:y}],M,w),[_,g,y,M,w]);return u.jsxs("div",{className:ve.dvListDropdown,style:l,children:[u.jsx("div",{className:ve.dvListDropdownTitle,children:i}),u.jsx("div",{className:ve.dvListDropdownList,children:u.jsx(L.Scrollbar,{children:u.jsx("div",{className:ve.dvListDropdownListContainer,children:m.map((I,O)=>{const N=t.indexOf(I.value)>-1,H=()=>{let F;N?F=new Set(t.filter(j=>j!==I.value)):F=new Set(n?[...t,I.value]:[I.value]);const U=[];o.forEach(j=>{F.has(j.value)&&U.push(j.value)}),a(U)},A=I.label.toLocaleLowerCase().indexOf(c);return u.jsxs("div",{className:ve.dvListDropdownItemContainer,onClick:H,children:[u.jsx("div",{className:ve.dvListDropdownItem,style:{background:I.color||_e},children:c&&I.label.toLowerCase().includes(c)?u.jsxs(u.Fragment,{children:[u.jsx("span",{children:I.label.substring(0,A)}),u.jsx("span",{style:{fontWeight:"bold"},children:I.label.substring(A,A+c.length)}),u.jsx("span",{children:I.label.substring(A+c.length)})]}):I.label}),u.jsx("div",{className:ve.dvListDropdownSelectedIcon,children:N?u.jsx(wt,{}):null})]},O)})})},d)}),S&&T?u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ve.dvListDropdownSplit}),u.jsx("div",{className:ve.dvListDropdownEdit,children:u.jsx("a",{onClick:s,children:p.t("dataValidation.list.edit")})})]}):null]})};function Sn(e){var W,Y,q,Z;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:i,unitId:s,subUnitId:l}=t,d=f.useDependency(J.DataValidationModel),[h,p]=V.useState(""),v=f.useDependency(r.ICommandService),c=f.useDependency(r.LocaleService),[y,g]=V.useState(""),M=f.useDependency($.IEditorBridgeService),w=f.useDependency(r.IUniverInstanceService),m=V.useMemo(()=>d.ruleChange$.pipe(ie.debounceTime(16)),[]),S=f.useDependency(E.SheetDataValidationModel);f.useObservable(m);const _=f.RectPopup.useContext(),T=((Y=(W=_.current)==null?void 0:W.right)!=null?Y:0)-((Z=(q=_.current)==null?void 0:q.left)!=null?Z:0);if(V.useEffect(()=>{const G=v.onCommandExecuted(ee=>{var te,ae;if(ee.id===Gt.RichTextEditingMutation.id){const oe=ee.params,{unitId:le}=oe,re=w.getUnit(le,r.UniverInstanceType.UNIVER_DOC);if(!re||!M.isVisible().visible)return;const de=r.BuildTextUtils.transform.getPlainText((ae=(te=re.getSnapshot().body)==null?void 0:te.dataStream)!=null?ae:"");p(de)}});return()=>{G.dispose()}},[v,M,w]),!n)return null;const C=S.getRuleByLocation(s,l,o,i);if(!C)return null;const D=S.getValidator(C.type);if(!D)return null;const I=n.getCell(o,i),O=(C==null?void 0:C.renderMode)===r.DataValidationRenderMode.CUSTOM||(C==null?void 0:C.renderMode)===void 0;if(!I||!C||!D||D.id.indexOf(r.DataValidationType.LIST)!==0)return;const N=C.type===r.DataValidationType.LIST_MULTIPLE,H=D.getListWithColor(C,s,l),A=y||E.getDataValidationCellValue(n.getCellRaw(o,i)),F=E.deserializeListOptions(A),U=()=>{v.executeCommand(Ie.id,{ruleId:C.uid}),a()},j=H.map(G=>({label:G.label,value:G.label,color:O||G.color?G.color:"transparent"}));return u.jsx(fn,{style:{minWidth:T,maxWidth:Math.max(T,200)},title:N?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:F,multiple:N,onChange:async G=>{const ee=E.serializeListOptions(G),te={unitId:s,subUnitId:l,range:{startColumn:i,endColumn:i,startRow:o,endRow:o},value:{v:ee,p:null,f:null,si:null}};M.isVisible()&&v.executeCommand($.SetCellEditVisibleOperation.id,{visible:!1,eventType:k.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),g(ee),N||a(),M.isVisible().visible&&await v.executeCommand($.SetCellEditVisibleOperation.id,{visible:!1,eventType:k.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),v.executeCommand(X.SetRangeValuesCommand.id,te)},options:j,onEdit:U,filter:h,location:t})}const rt={dataValidationOptionsButton:"univer-data-validation-options-button",dataValidationOptionsButtonIcon:"univer-data-validation-options-button-icon"};function In(e){var h;const t=f.useDependency(r.LocaleService),a=f.useDependency(f.ComponentManager),{value:n,onChange:o,extraComponent:i}=e,[s,l]=V.useState(!1),d=i?a.get(i):null;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:rt.dataValidationOptionsButton,onClick:()=>l(!s),children:[t.t("dataValidation.panel.options"),s?u.jsx(bt,{className:rt.dataValidationOptionsButtonIcon}):u.jsx(Mt,{className:rt.dataValidationOptionsButtonIcon})]}),s&&u.jsxs(u.Fragment,{children:[d?u.jsx(d,{value:n,onChange:o}):null,u.jsx(L.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:u.jsxs(L.RadioGroup,{value:`${(h=n.errorStyle)!=null?h:r.DataValidationErrorStyle.WARNING}`,onChange:p=>o({...n,errorStyle:+p}),children:[u.jsx(L.Radio,{value:`${r.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),u.jsx(L.Radio,{value:`${r.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),u.jsx(L.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:u.jsx(L.Checkbox,{checked:n.showErrorMessage,onChange:()=>o({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?u.jsx(L.FormLayout,{children:u.jsx(L.Input,{value:n.error,onChange:p=>o({...n,error:p})})}):null]})]})}const Ve={dataValidationDetail:"univer-data-validation-detail",dataValidationDetailFormItem:"univer-data-validation-detail-form-item",dataValidationDetailButtons:"univer-data-validation-detail-buttons",dataValidationDetailButton:"univer-data-validation-detail-button"},_n=e=>r.debounce(async(t,a,n,o)=>{const i=await e.executeCommand(t,a,n);o==null||o(i)},1e3);function Cn(e,t,a){var n,o,i,s;return t?((o=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:o.getSheetId())||"":((s=(i=e.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Dn(){var de;const[e,t]=V.useState(0),a=f.useDependency(ue),n=f.useObservable(a.activeRule$,a.activeRule),{unitId:o,subUnitId:i,rule:s}=n||{},l=s.uid,d=f.useDependency(J.DataValidatorRegistryService),h=f.useDependency(r.IUniverInstanceService),p=f.useDependency(f.ComponentManager),v=f.useDependency(r.ICommandService),c=f.useDependency(J.DataValidationModel),y=f.useDependency(r.LocaleService),[g,M]=V.useState(s),w=d.getValidatorItem(g.type),[m,S]=V.useState(!1),_=d.getValidatorsByScope(J.DataValidatorRegistryScope.SHEET),[T,C]=V.useState(()=>g.ranges.map(P=>({unitId:"",sheetId:"",range:P}))),D=V.useMemo(()=>_n(v),[v]),[I,O]=V.useState(!1),[N,H]=V.useState(!1),A=V.useRef(null),F=f.useDependency(X.SheetsSelectionsService);if(V.useEffect(()=>()=>{const P=F.getCurrentLastSelection();P&&F.setSelections([P])},[F]),V.useEffect(()=>{v.onCommandExecuted(P=>{(P.id===r.UndoCommand.id||P.id===r.RedoCommand.id)&&setTimeout(()=>{const b=c.getRuleById(o,i,l);t(B=>B+1),b&&(M(b),C(b.ranges.map(B=>({unitId:"",sheetId:"",range:B}))))},20)})},[v,c,l,i,o]),!w)return null;const U=w.operators,j=w.operatorNames,W=g.operator?J.TWO_FORMULA_OPERATOR_COUNT.includes(g.operator):!1,Y=()=>{var P,b,B;(b=(P=A.current)==null?void 0:P.editor)!=null&&b.isFocus()&&q((B=A.current)==null?void 0:B.getValue()),!(!g.ranges.length||I)&&(w.validatorFormula(g,o,i).success?a.setActiveRule(null):S(!0))},q=f.useEvent(P=>{const b=P.split(",").filter(Boolean).map(tt.deserializeRangeWithSheet).map(K=>{const fe=K.sheetName;if(fe){const La=Cn(h,K.unitId,fe);return{...K,sheetId:La}}return{...K,sheetId:""}});if(r.isUnitRangesEqual(b,T))return;C(b);const B=b.filter(K=>(!K.unitId||K.unitId===o)&&(!K.sheetId||K.sheetId===i)).map(K=>K.range);if(M({...g,ranges:B}),B.length===0)return;const z={unitId:o,subUnitId:i,ruleId:l,ranges:B};D(E.UpdateSheetDataValidationRangeCommand.id,z)}),Z=P=>{if(r.shallowEqual(P,J.getRuleSetting(g)))return;M({...g,...P});const b={unitId:o,subUnitId:i,ruleId:l,setting:P};D(E.UpdateSheetDataValidationSettingCommand.id,b,void 0)},G=async()=>{await v.executeCommand(E.RemoveSheetDataValidationCommand.id,{ruleId:l,unitId:o,subUnitId:i}),a.setActiveRule(null)},ee={type:g.type,operator:g.operator,formula1:g.formula1,formula2:g.formula2,allowBlank:g.allowBlank},te=P=>{const b=d.getValidatorItem(P);if(!b)return;const B=b.operators,z=c.getRuleById(o,i,l),K=P===(z==null?void 0:z.type)||P.includes("list")&&(z!=null&&z.type.includes("list"))?{...z,type:P}:{...g,type:P,operator:B[0],formula1:void 0,formula2:void 0};M(K),v.executeCommand(E.UpdateSheetDataValidationSettingCommand.id,{unitId:o,subUnitId:i,ruleId:g.uid,setting:J.getRuleSetting(K)})},ae=p.get(w.formulaInput),oe=V.useMemo(()=>T.map(P=>tt.serializeRange(P.range)).join(","),[]),le=J.getRuleOptions(g),re=P=>{r.shallowEqual(P,J.getRuleOptions(g))||(M({...g,...P}),D(E.UpdateSheetDataValidationOptionsCommand.id,{unitId:o,subUnitId:i,ruleId:l,options:P}))};return u.jsxs("div",{className:Ve.dataValidationDetail,children:[u.jsx(L.FormLayout,{label:y.t("dataValidation.panel.range"),error:!g.ranges.length||I?y.t("dataValidation.panel.rangeError"):"",children:u.jsx(nt.RangeSelector,{selectorRef:A,unitId:o,subUnitId:i,initialValue:oe,onChange:(P,b)=>{var B;!N&&((B=A.current)!=null&&B.verify())&&q(b)},onFocusChange:(P,b)=>{var B;H(P),!P&&b&&((B=A.current)!=null&&B.verify())&&q(b)},onVerify:P=>O(!P)})}),u.jsx(L.FormLayout,{label:y.t("dataValidation.panel.type"),children:u.jsx(L.Select,{options:_==null?void 0:_.map(P=>({label:y.t(P.title),value:P.id})),value:g.type,onChange:te,className:Ve.dataValidationDetailFormItem})}),U!=null&&U.length?u.jsx(L.FormLayout,{label:y.t("dataValidation.panel.operator"),children:u.jsx(L.Select,{options:U.map((P,b)=>({value:`${P}`,label:j[b]})),value:`${g.operator}`,onChange:P=>{Z({...ee,operator:P})},className:Ve.dataValidationDetailFormItem})}):null,ae?u.jsx(L.FormLayout,{children:u.jsx(ae,{isTwoFormula:W,value:{formula1:g.formula1,formula2:g.formula2},onChange:P=>{Z({...ee,...P})},showError:m,validResult:w.validatorFormula(g,o,i),unitId:o,subUnitId:i,ruleId:l},e+g.type)}):null,u.jsx(L.FormLayout,{children:u.jsx(L.Checkbox,{checked:(de=g.allowBlank)!=null?de:!0,onChange:()=>{var P;return Z({...ee,allowBlank:!((P=g.allowBlank)==null||P)})},children:y.t("dataValidation.panel.allowBlank")})}),u.jsx(In,{value:le,onChange:re,extraComponent:w.optionsInput}),u.jsxs("div",{className:Ve.dataValidationDetailButtons,children:[u.jsx(L.Button,{className:Ve.dataValidationDetailButton,onClick:G,children:y.t("dataValidation.panel.removeRule")}),u.jsx(L.Button,{className:Ve.dataValidationDetailButton,variant:"primary",onClick:Y,children:y.t("dataValidation.panel.done")})]})]})}const je={dataValidationItemContainer:"univer-data-validation-item-container",dataValidationItemTitle:"univer-data-validation-item-title",dataValidationItemContent:"univer-data-validation-item-content",dataValidationItemIcon:"univer-data-validation-item-icon"},yn=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:o,disable:i}=e,s=f.useDependency(J.DataValidatorRegistryService),l=f.useDependency(r.ICommandService),d=f.useDependency($.IMarkSelectionService),h=s.getValidatorItem(t.type),p=V.useRef(void 0),[v,c]=V.useState(!1),y=f.useDependency(r.ThemeService),g=f.useObservable(y.currentTheme$),M=V.useMemo(()=>{var _;const m=(_=g==null?void 0:g.loopColor2)!=null?_:"#49B811",S=new r.ColorKit(m).toRgb();return{fill:`rgba(${S.r}, ${S.g}, ${S.b}, 0.1)`,stroke:m}},[g]),w=m=>{l.executeCommand(E.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:o}),m.stopPropagation()};return V.useEffect(()=>()=>{var m;p.current&&((m=p.current)==null||m.forEach(S=>{S&&d.removeShape(S)}))},[d]),u.jsxs("div",{className:je.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{i||(c(!0),p.current=t.ranges.map(m=>d.addShape({range:m,style:M,primary:null})))},onMouseLeave:()=>{var m;c(!1),(m=p.current)==null||m.forEach(S=>{S&&d.removeShape(S)}),p.current=void 0},children:[u.jsx("div",{className:je.dataValidationItemTitle,children:h==null?void 0:h.generateRuleName(t)}),u.jsx("div",{className:je.dataValidationItemContent,children:t.ranges.map(m=>tt.serializeRange(m)).join(",")}),v?u.jsx("div",{className:je.dataValidationItemIcon,onClick:w,children:u.jsx(at,{})}):null]})},We={dataValidationList:"univer-data-validation-list",dataValidationListButtons:"univer-data-validation-list-buttons",dataValidationListButton:"univer-data-validation-list-button"};function wn(e){const t=f.useDependency(E.SheetDataValidationModel),a=f.useDependency(r.IUniverInstanceService),n=f.useDependency(r.ICommandService),o=f.useDependency(r.Injector),i=f.useDependency(ue),s=f.useDependency(r.LocaleService),[l,d]=V.useState([]),{workbook:h}=e,p=f.useObservable(h.activeSheet$,void 0,!0),v=h.getUnitId(),c=p==null?void 0:p.getSheetId();V.useEffect(()=>{d(t.getRules(v,c));const S=t.ruleChange$.subscribe(_=>{_.unitId===v&&_.subUnitId===c&&d(t.getRules(v,c))});return()=>{S.unsubscribe()}},[v,c,t]);const y=async()=>{const S=E.createDefaultNewRule(o),_={unitId:v,subUnitId:c,rule:S};await n.executeCommand(E.AddSheetDataValidationCommand.id,_),i.setActiveRule({unitId:v,subUnitId:c,rule:S})},g=()=>{n.executeCommand(E.RemoveSheetAllDataValidationCommand.id,{unitId:v,subUnitId:c})},w=(S=>{const _=a.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET),T=_.getActiveSheet(),C=_.getUnitId(),D=T.getSheetId();return S.map(O=>X.checkRangesEditablePermission(o,C,D,O.ranges)?{...O}:{...O,disable:!0})})(l),m=w==null?void 0:w.some(S=>S.disable);return u.jsxs("div",{className:We.dataValidationList,children:[w==null?void 0:w.map(S=>{var _;return u.jsx(yn,{unitId:v,subUnitId:c,onClick:()=>{S.disable||i.setActiveRule({unitId:v,subUnitId:c,rule:S})},rule:S,disable:(_=S.disable)!=null?_:!1},S.uid)}),u.jsxs("div",{className:We.dataValidationListButtons,children:[l.length&&!m?u.jsx(L.Button,{className:We.dataValidationListButton,onClick:g,children:s.t("dataValidation.panel.removeAll")}):null,u.jsx(L.Button,{className:We.dataValidationListButton,variant:"primary",onClick:y,children:s.t("dataValidation.panel.add")})]})]})}const Vn=()=>{const e=f.useDependency(ue),t=f.useObservable(e.activeRule$,e.activeRule),a=f.useDependency(r.IUniverInstanceService),n=f.useObservable(()=>a.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),o=f.useObservable(()=>{var i;return(i=n==null?void 0:n.activeSheet$)!=null?i:ie.of(null)},void 0,void 0,[]);return!n||!o?null:t&&t.subUnitId===o.getSheetId()?u.jsx(Dn,{},t.rule.uid):u.jsx(wn,{workbook:n})},$e="data-validation.list.dropdown",st="data-validation.date.dropdown",He={type:r.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(r.IUniverInstanceService),a=X.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:o}=a,i=E.createDefaultNewRule(e),s=e.get(r.ICommandService),l=n.getUnitId(),d=o.getSheetId(),h={rule:i,unitId:l,subUnitId:d};return s.syncExecuteCommand(E.AddSheetDataValidationCommand.id,h)?(s.syncExecuteCommand(Ie.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var En=Object.getOwnPropertyDescriptor,Mn=(e,t,a,n)=>{for(var o=n>1?void 0:n?En(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Ee=(e,t)=>(a,n)=>t(a,n,e);const Ce="SHEET_DATA_VALIDATION_ALERT";let Fe=class extends r.Disposable{constructor(e,t,a,n,o,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=o,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ie.debounceTime(100)).subscribe(e=>{var t;if(e){const a=this._univerInstanceService.getUnit(e.location.unitId,r.UniverInstanceType.UNIVER_SHEET),n=a.getSheetBySheetId(e.location.subUnitId);if(!n)return;const o=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!o){this._cellAlertManagerService.removeAlert(Ce);return}if(this._dataValidationModel.validator(o,{...e.location,workbook:a,worksheet:n})===r.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Ce),l=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(l&&l.row===e.location.row&&l.col===e.location.col&&l.subUnitId===e.location.subUnitId&&l.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(Ce);return}const d=this._dataValidationModel.getValidator(o.type);if(!d){this._cellAlertManagerService.removeAlert(Ce);return}this._cellAlertManagerService.showAlert({type:$.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:d==null?void 0:d.getRuleFinalError(o,e.location),location:e.location,width:200,height:74,key:Ce});return}}this._cellAlertManagerService.removeAlert(Ce)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(Ce)}))}};Fe=Mn([Ee(0,r.Inject($.HoverManagerService)),Ee(1,r.Inject($.CellAlertManagerService)),Ee(2,r.IUniverInstanceService),Ee(3,r.Inject(r.LocaleService)),Ee(4,f.IZenZoneService),Ee(5,r.Inject(E.SheetDataValidationModel))],Fe);var bn=Object.getOwnPropertyDescriptor,Ln=(e,t,a,n)=>{for(var o=n>1?void 0:n?bn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},lt=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends r.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,o)=>{const{source:i,target:s,unitId:l,subUnitId:d}=n,h=this._sheetDataValidationModel.getRuleObjectMatrix(l,d).clone(),p=$.virtualizeDiscreteRanges([i,s]),[v,c]=p.ranges,{mapFunc:y}=p,g={row:v.startRow,col:v.startColumn},M=$.getAutoFillRepeatRange(v,c),w=new r.ObjectMatrix,m=new Set;M.forEach(D=>{const I=D.repeatStartCell,O=D.relativeRange,N={startRow:g.row,startColumn:g.col,endColumn:g.col,endRow:g.row},H={startRow:I.row,startColumn:I.col,endColumn:I.col,endRow:I.row};r.Range.foreach(O,(A,F)=>{const U=r.Rectangle.getPositionRange({startRow:A,startColumn:F,endColumn:F,endRow:A},N),{row:j,col:W}=y(U.startRow,U.startColumn),Y=this._sheetDataValidationModel.getRuleIdByLocation(l,d,j,W)||"",q=r.Rectangle.getPositionRange({startRow:A,startColumn:F,endColumn:F,endRow:A},H),{row:Z,col:G}=y(q.startRow,q.startColumn);w.setValue(Z,G,Y),m.add(Y)})});const S=Array.from(m).map(D=>({id:D,ranges:r.queryObjectMatrix(w,I=>I===D)}));h.addRangeRules(S);const _=h.diff(this._sheetDataValidationModel.getRules(l,d)),{redoMutations:T,undoMutations:C}=E.getDataValidationDiffMutations(l,d,_,this._injector,"patched",o===$.APPLY_TYPE.ONLY_FORMAT);return{undos:C,redos:T}},a={id:E.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:o,unitId:i,subUnitId:s}=n;for(const l of o.rows)for(const d of o.cols){const h=this._sheetDataValidationModel.getRuleByLocation(i,s,l,d);if(h&&h.type===r.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType($.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,o,i)=>i===$.APPLY_TYPE.COPY||i===$.APPLY_TYPE.ONLY_FORMAT||i===$.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};Me=Ln([lt(0,$.IAutoFillService),lt(1,r.Inject(E.SheetDataValidationModel)),lt(2,r.Inject(r.Injector))],Me);var Tn=Object.getOwnPropertyDescriptor,On=(e,t,a,n)=>{for(var o=n>1?void 0:n?Tn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},dt=(e,t)=>(a,n)=>t(a,n,e);let be=class extends r.Disposable{constructor(t,a,n){super();R(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,o)=>{const{copyType:i=$.COPY_TYPE.COPY,pasteType:s}=o,{range:l}=t||{},{range:d,unitId:h,subUnitId:p}=a;return this._generateMutations(d,{copyType:i,pasteType:s,copyRange:l,unitId:h,subUnitId:p})}})}_collect(t,a,n){const o=new r.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:o};const i=this._injector.invoke(d=>X.rangeToDiscreteRange(n,d,t,a));if(!i)return;const{rows:s,cols:l}=i;s.forEach((d,h)=>{l.forEach((p,v)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(t,a,d,p);o.setValue(h,v,c!=null?c:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===$.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:o,subUnitId:i}=this._copyInfo;if(a.unitId!==o||i!==a.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),l=new r.ObjectMatrix,d=new Set,{ranges:[h,p],mapFunc:v}=$.virtualizeDiscreteRanges([a.copyRange,t]),c=$.getRepeatRange(h,p,!0),y=new Map;c.forEach(({startRange:m})=>{var S;(S=this._copyInfo)==null||S.matrix.forValue((_,T,C)=>{const D=r.Rectangle.getPositionRange({startRow:_,endRow:_,startColumn:T,endColumn:T},m),I=`${i}-${C}`,O=this._sheetDataValidationModel.getRuleById(o,i,C);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,I)&&O&&y.set(I,{...O,uid:I});const{row:N,col:H}=v(D.startRow,D.startColumn);d.add(I),l.setValue(N,H,I)})});const g=Array.from(d).map(m=>({id:m,ranges:r.queryObjectMatrix(l,S=>S===m)}));s.addRangeRules(g);const{redoMutations:M,undoMutations:w}=E.getDataValidationDiffMutations(a.unitId,a.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),y.values()),this._injector,"patched",!1);return{redos:M,undos:w}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(o,i).clone(),l=new r.ObjectMatrix,d=new Set,{ranges:[h,p],mapFunc:v}=$.virtualizeDiscreteRanges([a.copyRange,t]);$.getRepeatRange(h,p,!0).forEach(({startRange:w})=>{var m;(m=this._copyInfo)==null||m.matrix.forValue((S,_,T)=>{const C=r.Rectangle.getPositionRange({startRow:S,endRow:S,startColumn:_,endColumn:_},w),{row:D,col:I}=v(C.startRow,C.startColumn);l.setValue(D,I,T),d.add(T)})});const y=Array.from(d).map(w=>({id:w,ranges:r.queryObjectMatrix(l,m=>m===w)}));s.addRangeRules(y);const{redoMutations:g,undoMutations:M}=E.getDataValidationDiffMutations(o,i,s.diff(this._sheetDataValidationModel.getRules(o,i)),this._injector,"patched",!1);return{redos:g,undos:M}}}};be=On([dt(0,$.ISheetClipboardService),dt(1,r.Inject(E.SheetDataValidationModel)),dt(2,r.Inject(r.Injector))],be);var Pn=Object.getOwnPropertyDescriptor,Rn=(e,t,a,n)=>{for(var o=n>1?void 0:n?Pn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},ct=(e,t)=>(a,n)=>t(a,n,e);let Le=class extends r.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===E.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission,X.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===E.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission,X.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Le=Rn([ct(0,r.Inject(r.LocaleService)),ct(1,r.ICommandService),ct(2,r.Inject(X.SheetPermissionCheckController))],Le);const At="data-validation-single",Ft="sheet.menu.data-validation";function An(e){return{id:Ft,type:f.MenuItemType.SUBITEMS,icon:At,tooltip:"dataValidation.title",hidden$:f.getMenuHiddenObservable(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:$.getCurrentRangeDisable$(e,{workbookTypes:[X.WorkbookEditablePermission],worksheetTypes:[X.WorksheetSetCellStylePermission,X.WorksheetEditPermission],rangeTypes:[X.RangeProtectionPermissionEditPoint]})}}function Fn(e){return{id:Ie.id,title:"dataValidation.panel.title",type:f.MenuItemType.BUTTON}}function kn(e){return{id:He.id,title:"dataValidation.panel.add",type:f.MenuItemType.BUTTON}}const Nn={[f.RibbonStartGroup.FORMULAS_INSERT]:{[Ft]:{order:9,menuItemFactory:An,[Ie.id]:{order:0,menuItemFactory:Fn},[He.id]:{order:1,menuItemFactory:kn}}}};var Un=Object.getOwnPropertyDescriptor,kt=(e,t,a,n)=>{for(var o=n>1?void 0:n?Un(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Q=(e,t)=>(a,n)=>t(a,n,e);const Nt={tr:{size:6,color:"#fe4b4b"}};let Te=class extends r.RxDisposable{constructor(e,t,a,n,o,i,s,l,d,h,p){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=o,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=l,this._sheetInterceptorService=d,this._dataValidationCacheService=h,this._editorBridgeService=p,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Nn)}_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:o,row:i,column:s}=t,l=this._univerInstanceService.getUniverSheetInstance(n);if(!l)return;const d=this._sheetDataValidationModel.getRuleByLocation(n,o,i,s);if(!d)return;const h=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!(h!=null&&h.dropdown))return;const p=l.getActiveSheet();if(!p)return;const v=this._dropdownManagerService.activeDropdown,c=v==null?void 0:v.location;if(c&&c.unitId===n&&c.subUnitId===o&&c.row===i&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:o,row:i,col:s,workbook:l,worksheet:p},componentKey:h.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var m,S,_,T,C;const{row:n,col:o,unitId:i,subUnitId:s,workbook:l,worksheet:d}=t,h=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,o);if(!h)return a(e);const p=this._sheetDataValidationModel.getRuleById(i,s,h);if(!p)return a(e);const v=(m=this._dataValidationCacheService.getValue(i,s,n,o))!=null?m:r.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),y=t.rawData;let g;const M={get value(){var D;return g!==void 0||(g=(D=E.getCellValueOrigin(y))!=null?D:null),g}},w={get value(){var D;return`${(D=M.value)!=null?D:""}`}};return a({...e,markers:{...e==null?void 0:e.markers,...v===r.DataValidationStatus.INVALID?Nt:null},customRender:[...(S=e==null?void 0:e.customRender)!=null?S:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((_=e==null?void 0:e.fontRenderExtension)==null?void 0:_.isSkip)||((T=c==null?void 0:c.skipDefaultFontRender)==null?void 0:T.call(c,p,M.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,w.value,{get style(){const D=l.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,o)},interceptorAutoHeight:()=>{var N,H,A,F,U,j;const D=(H=(N=this._renderManagerService.getRenderById(i))==null?void 0:N.with($.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:H.skeleton;if(!D)return;const I=D.worksheet.getMergedCell(n,o),O={data:e,style:D.getStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex((A=I==null?void 0:I.startRow)!=null?A:n,(F=I==null?void 0:I.startColumn)!=null?F:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(j=(U=c==null?void 0:c.canvasRender)==null?void 0:U.calcCellAutoHeight)==null?void 0:j.call(U,O)},interceptorAutoWidth:()=>{var N,H,A,F,U,j;const D=(H=(N=this._renderManagerService.getRenderById(i))==null?void 0:N.with($.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:H.skeleton;if(!D)return;const I=D.worksheet.getMergedCell(n,o),O={data:e,style:D.getStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex((A=I==null?void 0:I.startRow)!=null?A:n,(F=I==null?void 0:I.startColumn)!=null?F:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(j=(U=c==null?void 0:c.canvasRender)==null?void 0:U.calcCellAutoWidth)==null?void 0:j.call(U,O)},coverable:((C=e==null?void 0:e.coverable)!=null?C:!0)&&!(p.type===r.DataValidationType.LIST||p.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(a=>{var n;(a.rule.type===r.DataValidationType.LIST_MULTIPLE||a.rule.type===r.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(a.redos,this._commandService)}})}};Te=kt([Q(0,r.ICommandService),Q(1,f.IMenuManagerService),Q(2,k.IRenderManagerService),Q(3,r.IUniverInstanceService),Q(4,r.Inject($.AutoHeightController)),Q(5,r.Inject(me)),Q(6,r.Inject(E.SheetDataValidationModel)),Q(7,r.Inject(J.DataValidatorRegistryService)),Q(8,r.Inject(X.SheetInterceptorService)),Q(9,r.Inject(E.DataValidationCacheService)),Q(10,r.Optional($.IEditorBridgeService))],Te);let Ut=class extends r.RxDisposable{constructor(e,t,a,n,o,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=o,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var w,m,S,_,T;const{row:n,col:o,unitId:i,subUnitId:s,workbook:l,worksheet:d}=t,h=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,o);if(!h)return a(e);const p=this._sheetDataValidationModel.getRuleById(i,s,h);if(!p)return a(e);const v=(w=this._dataValidationCacheService.getValue(i,s,n,o))!=null?w:r.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),y=d.getCellRaw(n,o),g=E.getCellValueOrigin(y),M=`${g!=null?g:""}`;return a({...e,markers:{...e==null?void 0:e.markers,...v===r.DataValidationStatus.INVALID?Nt:null},customRender:[...(m=e==null?void 0:e.customRender)!=null?m:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((S=e==null?void 0:e.fontRenderExtension)==null?void 0:S.isSkip)||((_=c==null?void 0:c.skipDefaultFontRender)==null?void 0:_.call(c,p,g,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,M,{get style(){const C=l.getStyles();return(typeof(e==null?void 0:e.s)=="string"?C.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,o)},interceptorAutoHeight:()=>{var O,N,H,A,F,U;const C=(N=(O=this._renderManagerService.getRenderById(i))==null?void 0:O.with($.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:N.skeleton;if(!C)return;const D=C.worksheet.getMergedCell(n,o),I={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((H=D==null?void 0:D.startRow)!=null?H:n,(A=D==null?void 0:D.startColumn)!=null?A:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(U=(F=c==null?void 0:c.canvasRender)==null?void 0:F.calcCellAutoHeight)==null?void 0:U.call(F,I)},coverable:((T=e==null?void 0:e.coverable)!=null?T:!0)&&!(p.type===r.DataValidationType.LIST||p.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.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);r.sequenceExecute(a.redos,this._commandService)}})}};Ut=kt([Q(0,r.ICommandService),Q(1,k.IRenderManagerService),Q(2,r.Inject($.AutoHeightController)),Q(3,r.Inject(J.DataValidatorRegistryService)),Q(4,r.Inject(X.SheetInterceptorService)),Q(5,r.Inject(E.SheetDataValidationModel)),Q(6,r.Inject(E.DataValidationCacheService))],Ut);var Bn=Object.getOwnPropertyDescriptor,jn=(e,t,a,n)=>{for(var o=n>1?void 0:n?Bn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Bt=(e,t)=>(a,n)=>t(a,n,e);let Ye=class extends r.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(o=>{a.add(o.subUnitId)}),a.forEach(o=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(o))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(r.bufferDebounceTime(16)).subscribe(e))}};Ye=jn([Bt(1,r.Inject(E.SheetDataValidationModel)),Bt(2,r.Inject($.SheetSkeletonManagerService))],Ye);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"},Wn=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:o,validResult:i}=e,s=f.useDependency(r.LocaleService),l=o?i==null?void 0:i.formula1:"",d=o?i==null?void 0:i.formula2:"";return t?u.jsxs(u.Fragment,{children:[u.jsx(L.FormLayout,{error:l,children:u.jsx(L.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:h=>{n==null||n({...a,formula1:h})}})}),u.jsx("div",{className:ne.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),u.jsx(L.FormLayout,{error:d,children:u.jsx(L.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:h=>{n==null||n({...a,formula2:h})}})})]}):u.jsx(L.FormLayout,{error:l,children:u.jsx(L.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:h=>{n==null||n({formula1:h})}})})};function $n(e){const{value:t,onChange:a,showError:n,validResult:o}=e,i=f.useDependency(r.LocaleService),s=n?o==null?void 0:o.formula1:"",l=n?o==null?void 0:o.formula2:"",[d,h]=V.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return u.jsxs(u.Fragment,{children:[u.jsx(L.FormLayout,{children:u.jsx(L.Checkbox,{checked:d,onChange:p=>{p?h(!0):(h(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),d?u.jsx(L.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:u.jsx(L.Input,{className:ne.dataValidationFormula,placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:p=>{a==null||a({...t,formula1:p||void 0})}})}):null,d?u.jsx(L.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:l,children:u.jsx(L.Input,{className:ne.dataValidationFormula,placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:p=>{a==null||a({...t,formula2:p||void 0})}})}):null]})}function Hn(e){var v;const{unitId:t,subUnitId:a,value:n,onChange:o,showError:i,validResult:s}=e,l=i?s==null?void 0:s.formula1:void 0,d=V.useRef(null),[h,p]=V.useState(!1);return f.useSidebarClick(c=>{var g;((g=d.current)==null?void 0:g.isClickOutSide(c))&&p(!1)}),u.jsx(nt.FormulaEditor,{initValue:(v=n==null?void 0:n.formula1)!=null?v:"=",unitId:t,subUnitId:a,isFocus:h,onChange:c=>{const y=(c!=null?c:"").trim();y!==(n==null?void 0:n.formula1)&&(o==null||o({...n,formula1:y}))},errorText:l,onFocus:()=>p(!0),isSupportAcrossSheet:!0,ref:d})}const Yn=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],xn=e=>{const{value:t,onChange:a,disabled:n}=e,[o,i]=V.useState(!1);return u.jsx(L.Select,{disabled:n,open:o,onDropdownVisibleChange:i,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ne.dataValidationFormulaColorSelect,value:t,onChange:a,labelRender:s=>u.jsx("div",{className:ne.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>u.jsx("div",{className:ne.dataValidationFormulaColorSelectPanel,children:Yn.map(s=>u.jsx("div",{onClick:()=>{a(s),i(!1)},className:ne.dataValidationFormulaColorItem,style:{background:s}},s))})})},jt=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:o,onItemDelete:i}=a;return u.jsxs("div",{className:ne.dataValidationFormulaListItem,style:n,children:[t.isRef?null:u.jsx("div",{className:L.clsx(ne.dataValidationFormulaListItemDrag,"draggableHandle"),children:u.jsx(Lt,{})}),u.jsx(xn,{value:t.color,onChange:s=>{o(t.id,t.label,s)}}),u.jsx(L.Input,{disabled:t.isRef,value:t.label,onChange:s=>{o(t.id,s,t.color)}}),t.isRef?null:u.jsx("div",{className:ne.dataValidationFormulaListItemIcon,children:u.jsx(at,{onClick:()=>i(t.id)})})]})};function Xn(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:o,validResult:i,showError:s,ruleId:l}=e,{formula1:d="",formula2:h=""}=t||{},p=V.useRef(null),[v,c]=V.useState(()=>r.isFormulaString(d)?"1":"0"),[y,g]=V.useState(v==="1"?d:"="),[M,w]=V.useState(v==="1"?d:"="),m=f.useDependency(r.LocaleService),S=f.useDependency(J.DataValidatorRegistryService),_=f.useDependency(J.DataValidationModel),T=f.useDependency(E.DataValidationFormulaController),[C,D]=V.useState(()=>h.split(",")),I=S.getValidatorItem(r.DataValidationType.LIST),[O,N]=V.useState([]),[H,A]=V.useState(""),F=s?i==null?void 0:i.formula1:"",U=V.useMemo(()=>_.ruleChange$.pipe(ie.debounceTime(16)),[]),j=f.useObservable(U),W=f.useEvent(a);V.useEffect(()=>{(async()=>{await new Promise(z=>{setTimeout(()=>z(!0),100)});const b=_.getRuleById(n,o,l),B=b==null?void 0:b.formula1;if(r.isFormulaString(B)&&I&&b){const z=await I.getListAsync(b,n,o);N(z)}})()},[_,j,I,l,o,n]),V.useEffect(()=>{r.isFormulaString(d)&&d!==M&&(g(d),w(M))},[M,d]);const[Y,q]=V.useState(()=>{const b=v!=="1"?E.deserializeListOptions(d):[],B=h.split(",");return b.map((z,K)=>({label:z,color:B[K]||_e,isRef:!1,id:r.Tools.generateRandomId(4)}))}),Z=(b,B,z)=>{const K=Y.find(fe=>fe.id===b);K&&(K.label=B,K.color=z,q([...Y]))},G=b=>{const B=Y.findIndex(z=>z.id===b);B!==-1&&(Y.splice(B,1),q([...Y]))},ee=h.split(","),te=V.useMemo(()=>O.map((b,B)=>({label:b,color:ee[B]||_e,id:`${B}`,isRef:!0})),[ee,O]),ae=(b,B,z)=>{const K=[...C];K[+b]=z,D(K),W({formula1:d,formula2:K.join(",")})},oe=()=>{q([...Y,{label:"",color:_e,isRef:!1,id:r.Tools.generateRandomId(4)}])};V.useEffect(()=>{if(v==="1")return;const b=new Set,B=[];Y.map(z=>({labelList:z.label.split(","),item:z})).forEach(({item:z,labelList:K})=>{K.forEach(fe=>{b.has(fe)||(b.add(fe),B.push({label:fe,color:z.color}))})}),W({formula1:E.serializeListOptions(B.map(z=>z.label)),formula2:B.map(z=>z.color===_e?"":z.color).join(",")})},[Y,W,v,M,C]);const le=f.useEvent(async b=>{if(!r.isFormulaString(b)){W==null||W({formula1:"",formula2:h});return}T.getFormulaRefCheck(b)?(W==null||W({formula1:r.isFormulaString(b)?b:"",formula2:h}),A("")):(W==null||W({formula1:"",formula2:h}),g("="),A(m.t("dataValidation.validFail.formulaError")))}),re=V.useRef(null),[de,P]=V.useState(!1);return f.useSidebarClick(b=>{var z;((z=re.current)==null?void 0:z.isClickOutSide(b))&&P(!1)}),u.jsxs(u.Fragment,{children:[u.jsx(L.FormLayout,{label:m.t("dataValidation.list.options"),children:u.jsxs(L.RadioGroup,{value:v,onChange:b=>{c(b),g(M),b==="1"&&W({formula1:M==="="?"":M,formula2:C.join(",")})},children:[u.jsx(L.Radio,{value:"0",children:m.t("dataValidation.list.customOptions")}),u.jsx(L.Radio,{value:"1",children:m.t("dataValidation.list.refOptions")})]})}),v==="1"?u.jsxs(u.Fragment,{children:[u.jsx(nt.FormulaEditor,{initValue:y,unitId:n,subUnitId:o,isFocus:de,onChange:(b="")=>{const B=(b!=null?b:"").trim();w(B),le(B)},errorText:F||H||void 0,onFocus:()=>P(!0),isSupportAcrossSheet:!0,ref:re}),u.jsx("div",{ref:p,style:{marginTop:"12px"},children:te.map(b=>u.jsx(jt,{item:b,commonProps:{onItemChange:ae},style:{marginBottom:12}},b.id))})]}):u.jsx(L.FormLayout,{error:F,children:u.jsxs("div",{ref:p,style:{marginTop:"-12px"},children:[u.jsx(L.DraggableList,{list:Y,onListChange:q,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:b=>u.jsx(jt,{item:b,commonProps:{onItemChange:Z,onItemDelete:G}},b.id),idKey:"id"}),u.jsxs("a",{className:ne.dataValidationFormulaListAdd,onClick:oe,children:[u.jsx(Et,{}),m.t("dataValidation.list.add")]})]})})]})}const Wt="data-validation.custom-formula-input",xe="data-validation.formula-input",ut="data-validation.list-formula-input",$t="data-validation.checkbox-formula-input",zn=[[Wt,Hn],[xe,Wn],[ut,Xn],[$t,$n]],Kn="LIST_RENDER_MODE_OPTION_INPUT";function Xe(e){var o;const{value:t,onChange:a}=e,n=f.useDependency(r.LocaleService);return u.jsx(L.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:u.jsxs(L.RadioGroup,{value:`${(o=t.renderMode)!=null?o:r.DataValidationRenderMode.CUSTOM}`,onChange:i=>a({...t,renderMode:+i}),children:[u.jsx(L.Radio,{value:`${r.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),u.jsx(L.Radio,{value:`${r.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),u.jsx(L.Radio,{value:`${r.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}Xe.componentKey=Kn;const Gn="DATE_SHOW_TIME_OPTION";function ze(e){var o;const{value:t,onChange:a}=e,n=f.useDependency(r.LocaleService);return u.jsx(L.FormLayout,{children:u.jsx(L.Checkbox,{checked:(o=t.bizInfo)==null?void 0:o.showTime,onChange:i=>{a({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:n.t("dataValidation.showTime.label")})})}ze.componentKey=Gn;var qn=Object.getOwnPropertyDescriptor,Zn=(e,t,a,n)=>{for(var o=n>1?void 0:n?qn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Oe=(e,t)=>(a,n)=>t(a,n,e);const Ke=6;let ht=class{constructor(e,t,a,n,o,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=a,this._themeService=n,this._renderManagerService=o,this._dataValidationModel=i}_calc(e,t){var h,p,v;const{vt:a,ht:n}=t||{},o=e.endX-e.startX-Ke*2,i=e.endY-e.startY,s=((h=t==null?void 0:t.fs)!=null?h:10)*1.6;let l=0,d=0;switch(a){case r.VerticalAlign.TOP:d=0;break;case r.VerticalAlign.BOTTOM:d=0+(i-s);break;default:d=0+(i-s)/2;break}switch(n){case r.HorizontalAlign.LEFT:l=Ke;break;case r.HorizontalAlign.RIGHT:l=Ke+(o-s);break;default:l=Ke+(o-s)/2;break}return{left:e.startX+l,top:e.startY+d,width:((p=t==null?void 0:t.fs)!=null?p:10)*1.6,height:((v=t==null?void 0:t.fs)!=null?v:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var h,p,v,c,y,g,M,w,m;const{formula1:n=E.CHECKBOX_FORMULA_1,formula2:o=E.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=E.getFormulaResult((v=(p=(h=i==null?void 0:i[0])==null?void 0:h.result)==null?void 0:p[0])==null?void 0:v[0]),l=E.getFormulaResult((g=(y=(c=i==null?void 0:i[1])==null?void 0:c.result)==null?void 0:y[0])==null?void 0:g[0]),d=E.isLegalFormulaResult(String(s))&&E.isLegalFormulaResult(String(l));return{formula1:r.isFormulaString(n)?E.getFormulaResult((m=(w=(M=i==null?void 0:i[0])==null?void 0:M.result)==null?void 0:w[0])==null?void 0:m[0]):n,formula2:r.isFormulaString(o)?l:o,isFormulaValid:d}}drawWith(e,t){var F,U,j,W;const{style:a,primaryWithCoord:n,unitId:o,subUnitId:i,worksheet:s,row:l,col:d}=t,h=n.isMergedMainCell?n.mergeInfo:n,p=E.getCellValueOrigin(s.getCellRaw(l,d)),v=this._dataValidationModel.getRuleByLocation(o,i,l,d);if(!v)return;const c=this._dataValidationModel.getValidator(v.type);if(!c)return;const y=this._themeService.getCurrentTheme();if(!((F=c.skipDefaultFontRender)!=null&&F.call(c,v,p,{unitId:o,subUnitId:i,row:l,column:d})))return;const g=c.parseFormulaSync(v,o,i),{formula1:M}=g,w=this._calc(h,a),{a:m,d:S}=e.getTransform(),_=k.fixLineWidthByScale(w.left,m),T=k.fixLineWidthByScale(w.top,S),C=k.Transform.create().composeMatrix({left:_,top:T,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),D=h.endX-h.startX,I=h.endY-h.startY;e.save(),e.beginPath(),e.rect(h.startX,h.startY,D,I),e.clip();const O=C.getMatrix();e.transform(O[0],O[1],O[2],O[3],O[4],O[5]);const N=((U=a==null?void 0:a.fs)!=null?U:10)*1.6,H=String(p)===String(M),A=y.hyacinth500;k.CheckboxShape.drawWith(e,{checked:H,width:N,height:N,fill:(W=(j=a==null?void 0:a.cl)==null?void 0:j.rgb)!=null?W:A}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),o=n.top,i=n.top+n.height,s=n.left,l=n.left+n.width,{x:d,y:h}=e;return d<=l&&d>=s&&h<=i&&h>=o}async onPointerDown(e,t){var g;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:o,worksheet:i,row:s,col:l}=e,d=E.getCellValueOrigin(i.getCellRaw(s,l)),h=this._dataValidationModel.getRuleByLocation(n,o,s,l);if(!h)return;const p=this._dataValidationModel.getValidator(h.type);if(!p||!((g=p.skipDefaultFontRender)!=null&&g.call(p,h,d,{unitId:n,subUnitId:o,row:s,column:l})))return;const{formula1:v,formula2:c}=await this._parseFormula(h,n,o),y={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(d)===E.transformCheckboxValue(String(v))?c:v,p:null}};this._commandService.executeCommand(X.SetRangeValuesCommand.id,y)}onPointerEnter(e,t){var a,n;(n=(a=k.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(k.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=k.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(k.CURSOR_TYPE.DEFAULT)}};ht=Zn([Oe(0,r.ICommandService),Oe(1,r.IUniverInstanceService),Oe(2,r.Inject(E.DataValidationFormulaService)),Oe(3,r.Inject(r.ThemeService)),Oe(4,r.Inject(k.IRenderManagerService)),Oe(5,r.Inject(E.SheetDataValidationModel))],ht);var Jn=Object.getOwnPropertyDescriptor,Qn=(e,t,a,n)=>{for(var o=n>1?void 0:n?Jn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},ea=(e,t)=>(a,n)=>t(a,n,e);let he=class{constructor(e){R(this,"canvasRender",null);R(this,"dropdown");R(this,"optionsInput");R(this,"formulaInput",ut);this.injector=e}};he=Qn([ea(0,r.Inject(r.Injector))],he);class ta extends he{constructor(){super(...arguments);R(this,"id",r.DataValidationType.CHECKBOX);R(this,"canvasRender",this.injector.createInstance(ht));R(this,"formulaInput",$t)}}class na extends he{constructor(){super(...arguments);R(this,"id",r.DataValidationType.CUSTOM);R(this,"formulaInput",Wt)}}const aa="data-validation.formula-input";class oa extends he{constructor(){super(...arguments);R(this,"id",r.DataValidationType.DATE);R(this,"formulaInput",aa);R(this,"optionsInput",ze.componentKey);R(this,"dropdown",st)}}class ia extends he{constructor(){super(...arguments);R(this,"id",r.DataValidationType.DECIMAL);R(this,"formulaInput",xe)}}const Ht=4,ra=0,pt=4,Yt=4,vt=6,Ge=6,De=14;function sa(e,t){const a=k.FontCache.getTextSize(e,t),n=a.width+Ht*2,{ba:o,bd:i}=a,s=o+i;return{width:n,height:s+ra*2,ba:o}}function gt(e,t,a,n){const o=De+vt*2,i=a-o,s=n-Ge*2,l=e.map(c=>({layout:sa(c,t),text:c}));let d;const h=[];l.forEach(c=>{const{layout:y}=c,{width:g,height:M}=y;!d||d.width+g+pt>i?(d={width:g,height:M,items:[{...c,left:0}]},h.push(d)):(d.items.push({...c,left:d.width+pt}),d.width=d.width+g+pt)});let p=0,v=0;return h.forEach((c,y)=>{v=Math.max(v,c.width),y===h.length-1?p+=c.height:p+=c.height+Yt}),{lines:h,totalHeight:p,contentWidth:i,contentHeight:s,cellAutoHeight:p+Ge*2,calcAutoWidth:v+o}}const la=8;class da extends k.Shape{static drawWith(t,a){const{fontString:n,info:o,fill:i,color:s}=a,{layout:l,text:d}=o;t.save(),k.Rect.drawWith(t,{width:l.width,height:l.height,radius:la,fill:i||_e}),t.translateWithPrecision(Ht,l.ba),t.font=n,t.fillStyle=s,t.fillText(d,0,0),t.restore()}}var ca=Object.getOwnPropertyDescriptor,ua=(e,t,a,n)=>{for(var o=n>1?void 0:n?ca(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},qe=(e,t)=>(a,n)=>t(a,n,e);const ha=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,a,n){R(this,"zIndex");R(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=a,this._dataValidationModel=n}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,o){const i=a-De+4;let s=4;switch(o){case r.VerticalAlign.MIDDLE:s=(n-De)/2+4;break;case r.VerticalAlign.BOTTOM:s=n-De+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(ha),e.restore()}drawWith(e,t,a,n){var Z,G;const{primaryWithCoord:o,row:i,col:s,style:l,data:d,subUnitId:h}=t,p=o.isMergedMainCell?o.mergeInfo:o,v=d==null?void 0:d.fontRenderExtension,{leftOffset:c=0,rightOffset:y=0,topOffset:g=0,downOffset:M=0}=v||{},w=this._ensureMap(h),m=this._generateKey(i,s),S=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,s);if(!S)return;const _=this._dataValidationModel.getValidator(S.type);if(!_)return;const T={startX:p.startX+c,endX:p.endX-y,startY:p.startY+g,endY:p.endY-M},C=T.endX-T.startX,D=T.endY-T.startY,{cl:I}=l||{},O=(Z=typeof I=="object"?I==null?void 0:I.rgb:I)!=null?Z:"#000",N=k.getFontStyleString(l!=null?l:void 0),{vt:H,ht:A}=l||{},F=H!=null?H:r.VerticalAlign.MIDDLE,U=(G=E.getCellValueOrigin(d))!=null?G:"",j=_.parseCellValue(U),W=_.getListWithColorMap(S),Y=gt(j,N,C,D);this._drawDownIcon(e,T,C,D,F),e.save(),e.translateWithPrecision(T.startX,T.startY),e.beginPath(),e.rect(0,0,C-De,D),e.clip(),e.translateWithPrecision(vt,Ge);let q=0;switch(F){case r.VerticalAlign.MIDDLE:q=(Y.contentHeight-Y.totalHeight)/2;break;case r.VerticalAlign.BOTTOM:q=Y.contentHeight-Y.totalHeight;break}e.translateWithPrecision(0,q),Y.lines.forEach((ee,te)=>{e.save();const{width:ae,height:oe,items:le}=ee;let re=0;switch(A){case r.HorizontalAlign.RIGHT:re=Y.contentWidth-ae;break;case r.HorizontalAlign.CENTER:re=(Y.contentWidth-ae)/2;break}e.translate(re,te*(oe+Yt)),le.forEach(de=>{e.save(),e.translateWithPrecision(de.left,0),da.drawWith(e,{...N,info:de,color:O,fill:W[de.text]}),e.restore()}),e.restore()}),e.restore(),w.set(m,{left:T.startX,top:T.startY,width:Y.contentWidth+vt+De,height:Y.contentHeight+Ge*2})}calcCellAutoHeight(e){var C;const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:p=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,c={startX:v.startX+l,endX:v.endX-d,startY:v.startY+h,endY:v.endY-p},y=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!y)return;const g=this._dataValidationModel.getValidator(y.type);if(!g)return;const M=c.endX-c.startX,w=c.endY-c.startY,m=(C=E.getCellValueOrigin(n))!=null?C:"",S=g.parseCellValue(m),_=k.getFontStyleString(a!=null?a:void 0);return gt(S,_,M,w).cellAutoHeight}calcCellAutoWidth(e){var C;const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:p=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,c={startX:v.startX+l,endX:v.endX-d,startY:v.startY+h,endY:v.endY-p},y=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!y)return;const g=this._dataValidationModel.getValidator(y.type);if(!g)return;const M=c.endX-c.startX,w=c.endY-c.startY,m=(C=E.getCellValueOrigin(n))!=null?C:"",S=g.parseCellValue(m),_=k.getFontStyleString(a!=null?a:void 0);return gt(S,_,M,w).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:o}=n,{x:i}=e;return i>=o-De&&i<=o}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:i}=e,s={unitId:a,subUnitId:n,row:o,column:i};this._commandService.executeCommand(Ue.id,s)}onPointerEnter(e,t){var a,n;return(n=(a=k.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(k.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;return(n=(a=k.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(k.CURSOR_TYPE.DEFAULT)}};mt=ua([qe(0,r.ICommandService),qe(1,r.IUniverInstanceService),qe(2,r.Inject(k.IRenderManagerService)),qe(3,r.Inject(E.SheetDataValidationModel))],mt);class pa extends he{constructor(){super(...arguments);R(this,"id",r.DataValidationType.LIST_MULTIPLE);R(this,"canvasRender",this.injector.createInstance(mt));R(this,"dropdown",$e)}}var va=Object.getOwnPropertyDescriptor,ga=(e,t,a,n)=>{for(var o=n>1?void 0:n?va(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},ke=(e,t)=>(a,n)=>t(a,n,e);const ye=4,Ze=4,ce=14,pe=6,Pe=4,ft=8,ma="#565656",xt=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 fa(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${r.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:r.BooleanNumber.FALSE,bl:r.BooleanNumber.FALSE,ul:{s:r.BooleanNumber.FALSE},st:{s:r.BooleanNumber.FALSE},ol:{s:r.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 Xt(e,t,a){const n=fa(e,a),o=new r.DocumentDataModel(n),i=new k.DocumentViewModel(o);return{documentSkeleton:k.DocumentSkeleton.create(i,t),docModel:o,docViewModel:i}}function Je(e,t,a){const{documentSkeleton:n,docModel:o,docViewModel:i}=Xt(e,t,a);return{documents:new k.Documents(`DOCUMENTS_${r.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:o,docViewModel:i}}function zt(e,t,a,n,o,i,s=!0){let l=0;const d=s?Pe:0;switch(o){case r.VerticalAlign.BOTTOM:l=t-n-d;break;case r.VerticalAlign.MIDDLE:l=(t-n)/2;break;default:l=d;break}l=Math.max(Pe,l);let h=0;switch(i){case r.HorizontalAlign.CENTER:h=(e-a)/2;break;case r.HorizontalAlign.RIGHT:h=e-a;break}return h=Math.max(pe,h),{paddingLeft:h,paddingTop:l}}let St=class{constructor(e,t,a,n,o){R(this,"_dropdownInfoMap",new Map);R(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=a,this._renderManagerService=n,this._dataValidationModel=o}_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,o,i,s){const{t:l=r.DEFAULT_STYLES.pd.t,b:d=r.DEFAULT_STYLES.pd.b}=s,h=a-ce;let p;switch(i){case r.VerticalAlign.MIDDLE:p=(n-Ze)/2;break;case r.VerticalAlign.BOTTOM:p=n-d-o-Pe+(o/2-Ze/2);break;default:p=l+Pe+(o/2-Ze/2);break}e.save(),e.translateWithPrecision(t.startX+h,t.startY+p),e.fillStyle="#565656",e.fill(xt),e.restore()}drawWith(e,t,a){const{primaryWithCoord:n,row:o,col:i,style:s,data:l,subUnitId:d}=t,h=n.isMergedMainCell?n.mergeInfo:n,p=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,o,i);if(!p)return;const v=this._dataValidationModel.getValidator(p.type);if(!v)return;const c=l==null?void 0:l.fontRenderExtension,{leftOffset:y=0,rightOffset:g=0,topOffset:M=0,downOffset:w=0}=c||{};if(!p||!v||!v||v.id.indexOf(r.DataValidationType.LIST)!==0||!v.skipDefaultFontRender(p))return;const m={startX:h.startX+y,endX:h.endX-g,startY:h.startY+M,endY:h.endY-w},S=m.endX-m.startX,_=m.endY-m.startY,T=this._ensureMap(d),C=this._generateKey(o,i),D=v.getListWithColor(p),I=E.getCellValueOrigin(l),O=`${I!=null?I:""}`,N=D.find(j=>j.label===O);let{tb:H,vt:A,ht:F,pd:U}=s||{};if(H=H!=null?H:r.WrapStrategy.WRAP,A=A!=null?A:r.VerticalAlign.BOTTOM,F=F!=null?F:r.DEFAULT_STYLES.ht,U=U!=null?U:r.DEFAULT_STYLES.pd,p.renderMode===r.DataValidationRenderMode.ARROW){const{l:j=r.DEFAULT_STYLES.pd.l,t:W=r.DEFAULT_STYLES.pd.t,r:Y=r.DEFAULT_STYLES.pd.r,b:q=r.DEFAULT_STYLES.pd.b}=U,Z=S-j-Y-ce-4,{documentSkeleton:G,documents:ee,docModel:te}=Je(O,this._localeService,s);H===r.WrapStrategy.WRAP&&te.updateDocumentDataPageSize(Math.max(Z,1)),G.calculate(),G.getActualSize();const ae=k.getDocsSkeletonPageSize(G),{height:oe,width:le}=ae,{paddingTop:re,paddingLeft:de}=zt(Z,_-W-q,le,oe,A,F,!0);this._drawDownIcon(e,m,S,_,oe,A,U),e.save(),e.translateWithPrecision(m.startX+j,m.startY+W),e.beginPath(),e.rect(0,0,S-j-Y,_-W-q),e.clip(),e.translateWithPrecision(0,re),e.save(),e.translateWithPrecision(ye,0),e.beginPath(),e.rect(0,0,Z,oe),e.clip(),ee.render(e),e.translateWithPrecision(de,0),e.restore(),e.restore(),T.set(C,{left:m.endX+j+a.rowHeaderWidth-ce,top:m.startY+W+a.columnHeaderHeight,width:ce,height:_-W-q})}else{e.save(),e.translateWithPrecision(m.startX,m.startY),e.beginPath(),e.rect(0,0,S,_),e.clip();const j=S-pe*2-ye-ce-4,{documentSkeleton:W,documents:Y,docModel:q}=Je(O,this._localeService,s);H===r.WrapStrategy.WRAP&&q.updateDocumentDataPageSize(Math.max(j,1)),W.calculate();const Z=k.getDocsSkeletonPageSize(W),{height:G,width:ee}=Z,{paddingTop:te,paddingLeft:ae}=zt(j,_,ee,G,A,F);e.translateWithPrecision(pe,te);const oe=Math.max(S-pe*2,1),le=G;k.Rect.drawWith(e,{width:oe,height:le,fill:(N==null?void 0:N.color)||_e,radius:ft}),e.save(),e.translateWithPrecision(ye,0),e.beginPath(),e.rect(0,0,j,G),e.clip(),e.translateWithPrecision(ae,0),Y.render(e),e.restore(),e.translateWithPrecision(j+ye+4,(G-Ze)/2),e.fillStyle=ma,e.fill(xt),e.restore(),T.set(C,{left:m.startX+pe+a.rowHeaderWidth,top:m.startY+te+a.columnHeaderHeight,width:oe,height:le})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,l=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:h=0,topOffset:p=0,downOffset:v=0}=l||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!c||c.renderMode===r.DataValidationRenderMode.TEXT)return;const y={startX:s.startX+d,endX:s.endX-h,startY:s.startY+p,endY:s.endY-v},g=y.endX-y.startX,M=E.getCellValueOrigin(n),w=`${M!=null?M:""}`;let{tb:m,pd:S}=a||{};const{t:_=r.DEFAULT_STYLES.pd.t,b:T=r.DEFAULT_STYLES.pd.b}=S!=null?S:{};if(m=m!=null?m:r.WrapStrategy.WRAP,c.renderMode===r.DataValidationRenderMode.ARROW){const C=g-ce,{documentSkeleton:D,docModel:I}=Je(w,this._localeService,a);m===r.WrapStrategy.WRAP&&I.updateDocumentDataPageSize(Math.max(C,1)),D.calculate(),D.getActualSize();const O=k.getDocsSkeletonPageSize(D),{height:N}=O;return N+_+T+Pe*2}else{const C=g-pe*2-ye-ce,{documentSkeleton:D,docModel:I}=Xt(w,this._localeService,a);m===r.WrapStrategy.WRAP&&I.updateDocumentDataPageSize(Math.max(C,1)),D.calculate();const O=k.getDocsSkeletonPageSize(D),{height:N}=O;return N+Pe*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,l=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:h=0,topOffset:p=0,downOffset:v=0}=l||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!c||c.renderMode===r.DataValidationRenderMode.TEXT)return;const y={startX:s.startX+d,endX:s.endX-h,startY:s.startY+p,endY:s.endY-v},g=y.endX-y.startX,M=E.getCellValueOrigin(n),w=`${M!=null?M:""}`;let{tb:m,pd:S}=a||{};const{l:_=r.DEFAULT_STYLES.pd.l,r:T=r.DEFAULT_STYLES.pd.r}=S!=null?S:{};m=m!=null?m:r.WrapStrategy.WRAP;let C=pe*2+ce;switch(c.renderMode){case r.DataValidationRenderMode.ARROW:C=ce+pe*2+T+_;break;case r.DataValidationRenderMode.CUSTOM:C=ce+pe*2+ye*2+T+_+ft/2+1;break;default:C=ce+pe*2+ye*2+T+_+ft/2+1}const D=g-C,{documentSkeleton:I,docModel:O}=Je(w,this._localeService,a);return m===r.WrapStrategy.WRAP&&O.updateDocumentDataPageSize(Math.max(D,1)),I.calculate(),I.getActualSize(),k.getDocsSkeletonPageSize(I).width+C}isHit(e,t){const{subUnitId:a,row:n,col:o}=t,s=this._ensureMap(a).get(this._generateKey(n,o)),l=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,o);if(!l||!s||l.renderMode===r.DataValidationRenderMode.TEXT)return!1;const{top:d,left:h,width:p,height:v}=s,{x:c,y}=e;return c>=h&&c<=h+p&&y>=d&&y<=d+v}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:i}=e,s={unitId:a,subUnitId:n,row:o,column:i};this._commandService.executeCommand(Ue.id,s)}onPointerEnter(e,t){var a,n;(n=(a=k.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(k.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=k.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(k.CURSOR_TYPE.DEFAULT)}};St=ga([ke(0,r.IUniverInstanceService),ke(1,r.Inject(r.LocaleService)),ke(2,r.ICommandService),ke(3,r.Inject(k.IRenderManagerService)),ke(4,r.Inject(E.SheetDataValidationModel))],St);class Sa extends he{constructor(){super(...arguments);R(this,"id",r.DataValidationType.LIST);R(this,"canvasRender",this.injector.createInstance(St));R(this,"dropdown",$e);R(this,"optionsInput",Xe.componentKey);R(this,"formulaInput",ut)}}class Ia extends he{constructor(){super(...arguments);R(this,"id",r.DataValidationType.TEXT_LENGTH);R(this,"formulaInput",xe)}}class _a extends he{constructor(){super(...arguments);R(this,"id",r.DataValidationType.WHOLE);R(this,"formulaInput",xe)}}var Ca=Object.getOwnPropertyDescriptor,Da=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ca(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},It=(e,t)=>(a,n)=>t(a,n,e);let Re=class extends r.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[At,Vt],[Ne,Vn],[Ot,vn],[$e,Sn],[st,Qt],[Xe.componentKey,Xe],[ze.componentKey,ze],...zn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[ia,_a,Ia,oa,ta,Sa,pa,na].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)})}};Re=Da([It(0,r.Inject(r.Injector)),It(1,r.Inject(f.ComponentManager)),It(2,r.Inject(J.DataValidatorRegistryService))],Re);var ya=Object.getOwnPropertyDescriptor,wa=(e,t,a,n)=>{for(var o=n>1?void 0:n?ya(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},_t=(e,t)=>(a,n)=>t(a,n,e);const Va="SHEET_DATA_VALIDATION_UI_PLUGIN";x.UniverSheetsDataValidationUIPlugin=(Qe=class extends r.Plugin{constructor(t=Be,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:i,...s}=r.merge({},Be,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(it,s)}onStarting(){[[ue],[me],[Fe],[Me],[Te],[Le],[be],[Ae],[Re]].forEach(t=>{this._injector.add(t)}),[He,Ue,Rt,ot,Ie,Pt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(be),this._injector.get(Le),this._injector.get(Ae),this._injector.get(Fe),this._injector.get(k.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[Ye])}onRendered(){this._injector.get(Re),this._injector.get(Te)}onSteady(){this._injector.get(Me)}},R(Qe,"pluginName",Va),R(Qe,"type",r.UniverInstanceType.UNIVER_SHEET),Qe),x.UniverSheetsDataValidationUIPlugin=wa([_t(1,r.Inject(r.Injector)),_t(2,r.ICommandService),_t(3,r.IConfigService)],x.UniverSheetsDataValidationUIPlugin);var Ea=Object.getOwnPropertyDescriptor,Ma=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ea(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Ct=(e,t)=>(a,n)=>t(a,n,e);const ba="SHEET_DATA_VALIDATION_UI_PLUGIN";x.UniverSheetsDataValidationMobileUIPlugin=(et=class extends r.Plugin{constructor(t=Be,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:i,...s}=r.merge({},Be,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(it,s)}onStarting(){[[ue],[me],[Fe],[Me],[Te],[Le],[be],[Re]].forEach(t=>{this._injector.add(t)}),[He,Ue,Rt,ot,Ie,Pt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(be),this._injector.get(Le),this._injector.get(k.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[Ye])}onRendered(){this._injector.get(Re),this._injector.get(Te)}onSteady(){this._injector.get(Me)}},R(et,"pluginName",ba),R(et,"type",r.UniverInstanceType.UNIVER_SHEET),et),x.UniverSheetsDataValidationMobileUIPlugin=Ma([Ct(1,r.Inject(r.Injector)),Ct(2,r.ICommandService),Ct(3,r.IConfigService)],x.UniverSheetsDataValidationMobileUIPlugin),x.DATE_DROPDOWN_KEY=st,x.LIST_DROPDOWN_KEY=$e,Object.defineProperty(x,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.6.10-nightly.202504141607",
3
+ "version": "0.6.10-nightly.202504161609",
4
4
  "private": false,
5
5
  "description": "Data validation UI for Univer Sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -56,18 +56,18 @@
56
56
  "dependencies": {
57
57
  "@flatten-js/interval-tree": "^1.1.3",
58
58
  "@univerjs/icons": "^0.2.35",
59
- "@univerjs/design": "0.6.10-nightly.202504141607",
60
- "@univerjs/docs": "0.6.10-nightly.202504141607",
61
- "@univerjs/data-validation": "0.6.10-nightly.202504141607",
62
- "@univerjs/core": "0.6.10-nightly.202504141607",
63
- "@univerjs/engine-formula": "0.6.10-nightly.202504141607",
64
- "@univerjs/engine-render": "0.6.10-nightly.202504141607",
65
- "@univerjs/sheets": "0.6.10-nightly.202504141607",
66
- "@univerjs/sheets-formula-ui": "0.6.10-nightly.202504141607",
67
- "@univerjs/ui": "0.6.10-nightly.202504141607",
68
- "@univerjs/sheets-numfmt": "0.6.10-nightly.202504141607",
69
- "@univerjs/sheets-data-validation": "0.6.10-nightly.202504141607",
70
- "@univerjs/sheets-ui": "0.6.10-nightly.202504141607"
59
+ "@univerjs/core": "0.6.10-nightly.202504161609",
60
+ "@univerjs/data-validation": "0.6.10-nightly.202504161609",
61
+ "@univerjs/design": "0.6.10-nightly.202504161609",
62
+ "@univerjs/engine-formula": "0.6.10-nightly.202504161609",
63
+ "@univerjs/docs": "0.6.10-nightly.202504161609",
64
+ "@univerjs/engine-render": "0.6.10-nightly.202504161609",
65
+ "@univerjs/sheets-data-validation": "0.6.10-nightly.202504161609",
66
+ "@univerjs/sheets": "0.6.10-nightly.202504161609",
67
+ "@univerjs/sheets-formula-ui": "0.6.10-nightly.202504161609",
68
+ "@univerjs/sheets-numfmt": "0.6.10-nightly.202504161609",
69
+ "@univerjs/sheets-ui": "0.6.10-nightly.202504161609",
70
+ "@univerjs/ui": "0.6.10-nightly.202504161609"
71
71
  },
72
72
  "devDependencies": {
73
73
  "less": "^4.3.0",
@@ -76,7 +76,7 @@
76
76
  "rxjs": "^7.8.1",
77
77
  "tailwindcss": "^3.4.17",
78
78
  "typescript": "^5.8.3",
79
- "vite": "^6.2.6",
79
+ "vite": "^6.3.0",
80
80
  "vitest": "^3.1.1",
81
81
  "@univerjs-infra/shared": "0.6.10-alpha.0"
82
82
  },