@univerjs/sheets-data-validation-ui 0.5.5 → 0.6.0-alpha.0

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/umd/index.js CHANGED
@@ -1,9 +1 @@
1
- (function(Y,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("react"),require("@univerjs/core"),require("@univerjs/design"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("@univerjs/data-validation"),require("@univerjs/docs"),require("rxjs"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","react","@univerjs/core","@univerjs/design","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-data-validation","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/ui","@univerjs/data-validation","@univerjs/docs","rxjs","@univerjs/engine-formula","@univerjs/sheets-formula-ui"],g):(Y=typeof globalThis<"u"?globalThis:Y||self,g(Y.UniverSheetsDataValidationUi={},Y.React,Y.UniverCore,Y.UniverDesign,Y.UniverEngineRender,Y.UniverSheets,Y.UniverSheetsDataValidation,Y.UniverSheetsNumfmt,Y.UniverSheetsUi,Y.UniverUi,Y.UniverDataValidation,Y.UniverDocs,Y.rxjs,Y.UniverEngineFormula,Y.UniverSheetsFormulaUi))})(this,function(Y,g,o,b,U,X,E,Qt,B,z,J,en,re,tt,nt){"use strict";var ti=Object.defineProperty;var ni=(Y,g,o)=>g in Y?ti(Y,g,{enumerable:!0,configurable:!0,writable:!0,value:o}):Y[g]=o;var L=(Y,g,o)=>ni(Y,typeof g!="symbol"?g+"":g,o);var Qe,et;var at={exports:{}},Te={};/**
2
- * @license React
3
- * react-jsx-runtime.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var wt;function tn(){if(wt)return Te;wt=1;var e=g,t=Symbol.for("react.element"),a=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function s(d,l,u){var p,m={},c=null,S=null;u!==void 0&&(c=""+u),l.key!==void 0&&(c=""+l.key),l.ref!==void 0&&(S=l.ref);for(p in l)n.call(l,p)&&!r.hasOwnProperty(p)&&(m[p]=l[p]);if(d&&d.defaultProps)for(p in l=d.defaultProps,l)m[p]===void 0&&(m[p]=l[p]);return{$$typeof:t,type:d,key:c,ref:S,props:m,_owner:i.current}}return Te.Fragment=a,Te.jsx=s,Te.jsxs=s,Te}var Vt;function nn(){return Vt||(Vt=1,at.exports=tn()),at.exports}var h=nn(),an=Object.defineProperty,on=Object.getOwnPropertyDescriptor,rn=(e,t,a,n)=>{for(var i=n>1?void 0:n?on(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&an(t,a,i),i},Pe=(e,t)=>(a,n)=>t(a,n,e);let je=class extends o.Disposable{constructor(e,t,a,n,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(X.AFTER_CELL_EDIT_ASYNC,{handler:async(e,t,a)=>{var D;const n=await e,{worksheet:i,row:r,col:s,unitId:d,subUnitId:l,workbook:u}=t,p=this._dataValidationModel.getRuleIdByLocation(d,l,r,s),m=p?this._dataValidationModel.getRuleById(d,l,p):void 0;if(!m||m.errorStyle!==o.DataValidationErrorStyle.STOP)return a(Promise.resolve(n));const c=await this._dataValidatorRegistryService.getValidatorItem(m.type);if(!c||await c.validator({value:E.getCellValueOrigin(n),interceptValue:E.getCellValueOrigin((D=t==null?void 0:t.origin)!=null?D:n),row:r,column:s,unitId:d,subUnitId:l,worksheet:i,workbook:u,t:n==null?void 0:n.t},m))return a(Promise.resolve(n));const f=i.getCellRaw(r,s);return this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:c.getRuleFinalError(m,{row:r,col:s,unitId:d,subUnitId:l})},footer:{title:g.createElement(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(f))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:g.createElement(b.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};je=rn([Pe(0,o.Inject(X.SheetInterceptorService)),Pe(1,o.Inject(E.SheetDataValidationModel)),Pe(2,o.Inject(J.DataValidatorRegistryService)),Pe(3,z.IDialogService),Pe(4,o.Inject(o.LocaleService))],je);const Et={dvDateDropdown:"univer-dv-date-dropdown",dvDateDropdownBtns:"univer-dv-date-dropdown-btns"},sn=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function ln(e){var v;const{location:t,hideFn:a}=e,{worksheet:n,row:i,col:r,unitId:s,subUnitId:d,workbook:l}=t,u=o.useDependency(o.ICommandService),p=o.useDependency(je),m=n.getCell(i,r),c=E.getCellValueOrigin(n.getCellRaw(i,r)),S=sn(c),[f,D]=g.useState(S),V=f&&f.isValid()?f:o.dayjs(),_=o.useDependency(o.LocaleService),w=o.useDependency(E.SheetDataValidationModel),y=w.getRuleByLocation(s,d,i,r);if(!y)return null;const M=w.getValidator(y.type);if(!m||!M)return;const I=!!((v=y.bizInfo)!=null&&v.showTime),C=async()=>{var x,N,W;if(!V)return;const j=V.format(I?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),k=(x=o.numfmt.parseDate(j))==null?void 0:x.v,A=l.getStyles().getStyleByCell(m),T=(W=(N=A==null?void 0:A.n)==null?void 0:N.pattern)!=null?W:"",F=Qt.getPatternType(T);y.errorStyle!==o.DataValidationErrorStyle.STOP||await M.validator({value:k,unitId:s,subUnitId:d,row:i,column:r,worksheet:n,workbook:l,interceptValue:j.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},y)?(a(),await u.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:U.DeviceInputEventType.Keyboard,unitId:s,keycode:z.KeyCode.ESC}),await u.executeCommand(X.SetRangeValuesCommand.id,{unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:k,t:2,p:null,f:null,si:null,s:{n:{pattern:I?F==="datetime"?T:"yyyy-MM-dd hh:mm:ss":F==="date"?T:"yyyy-MM-dd"}}}})):p.showReject(M.getRuleFinalError(y,{row:i,col:r,unitId:s,subUnitId:d}))};return h.jsxs("div",{className:Et.dvDateDropdown,children:[h.jsx(b.DatePanel,{defaultValue:V,pickerValue:V,showTime:I||void 0,onSelect:async O=>{D(O)},onPanelChange:O=>{D(O)},disabledDate:O=>!o.numfmt.parseDate(O.format("YYYY-MM-DD"))}),h.jsx("div",{className:Et.dvDateDropdownBtns,children:h.jsx(b.Button,{size:"small",type:"primary",onClick:C,disabled:!V.isValid(),children:_.t("dataValidation.alert.ok")})})]})}var se=function(){return se=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},se.apply(this,arguments)},dn=function(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(a[n[i]]=e[n[i]]);return a},fe=g.forwardRef(function(e,t){var a=e.icon,n=e.id,i=e.className,r=e.extend,s=dn(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),l=g.useRef("_".concat(pn()));return Rt(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},se({ref:t,className:d},s),r)});function Rt(e,t,a,n,i){return g.createElement(e.tag,se(se({key:t},cn(e,a,i)),n),(un(e,a).children||[]).map(function(r,s){return Rt(r,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,i)}))}function cn(e,t,a){var n=se({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1);var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],d=r[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function un(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?se(se({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?se(se({},i),{attrs:se(se({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function pn(){return Math.random().toString(36).substring(2,8)}fe.displayName="UniverIcon";var hn={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"}}]},Mt=g.forwardRef(function(e,t){return g.createElement(fe,Object.assign({},e,{id:"check-mark-single",ref:t,icon:hn}))});Mt.displayName="CheckMarkSingle";var mn={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"}}]},bt=g.forwardRef(function(e,t){return g.createElement(fe,Object.assign({},e,{id:"data-validation-single",ref:t,icon:mn}))});bt.displayName="DataValidationSingle";var fn={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"}}]},it=g.forwardRef(function(e,t){return g.createElement(fe,Object.assign({},e,{id:"delete-single",ref:t,icon:fn}))});it.displayName="DeleteSingle";var vn={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"}}]},Ot=g.forwardRef(function(e,t){return g.createElement(fe,Object.assign({},e,{id:"increase-single",ref:t,icon:vn}))});Ot.displayName="IncreaseSingle";var gn={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"}}]},Lt=g.forwardRef(function(e,t){return g.createElement(fe,Object.assign({},e,{id:"more-down-single",ref:t,icon:gn}))});Lt.displayName="MoreDownSingle";var Sn={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"}}]},Tt=g.forwardRef(function(e,t){return g.createElement(fe,Object.assign({},e,{id:"more-up-single",ref:t,icon:Sn}))});Tt.displayName="MoreUpSingle";var _n={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"}}]}]},Pt=g.forwardRef(function(e,t){return g.createElement(fe,Object.assign({},e,{id:"sequence-single",ref:t,icon:_n}))});Pt.displayName="SequenceSingle";var In=Object.defineProperty,Cn=Object.getOwnPropertyDescriptor,Dn=(e,t,a,n)=>{for(var i=n>1?void 0:n?Cn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&In(t,a,i),i},jt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends o.Disposable{constructor(t,a){super();L(this,"_open$",new re.BehaviorSubject(!1));L(this,"open$",this._open$.pipe(re.distinctUntilChanged()));L(this,"_activeRule");L(this,"_activeRule$",new re.BehaviorSubject(void 0));L(this,"activeRule$",this._activeRule$.asObservable());L(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(re.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===xe&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ue=Dn([jt(0,o.IUniverInstanceService),jt(1,z.ISidebarService)],ue);function yn(){const e=o.useDependency(ve),t=z.useObservable(e.activeDropdown$,e.activeDropdown),a=o.useDependency(z.ComponentManager);if(!t)return null;const{location:n,componentKey:i}=t,r=a.get(i),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!r)return null;const d=()=>{e.hideDropdown()};return h.jsx(r,{location:n,hideFn:d},s)}const At="sheet.ui.dropdown";var wn=Object.defineProperty,Vn=Object.getOwnPropertyDescriptor,En=(e,t,a,n)=>{for(var i=n>1?void 0:n?Vn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&wn(t,a,i),i},Se=(e,t)=>(a,n)=>t(a,n,e);let ve=class extends o.Disposable{constructor(t,a,n,i,r,s,d){super();L(this,"_activeDropdown");L(this,"_activeDropdown$",new re.Subject);L(this,"_currentPopup",null);L(this,"activeDropdown$",this._activeDropdown$.asObservable());L(this,"_zenVisible",!1);this._canvasPopupManagerService=t,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=i,this._renderManagerService=r,this._dataValidationModel=s,this._sheetsSelectionsService=d,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,a,n,i){const r=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!r)return;const s=a?r.getSheetBySheetId(a):r.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(r.getUnitId(),s.getSheetId(),n,i);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdown}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t,a=!0){const{location:n}=t,{row:i,col:r,unitId:s,subUnitId:d}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const l=this._renderManagerService.getRenderById(o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),u=this._canvasPopupManagerService.attachPopupToCell(i,r,{componentKey:At,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[l==null?void 0:l.engine.getCanvasElement()].filter(Boolean)},s,d);if(!u)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const p=new o.DisposableCollection;p.add(u),p.add({dispose:()=>{var m,c;(c=(m=this._activeDropdown)==null?void 0:m.onHide)==null||c.call(m)}}),this._currentPopup=p}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,a,n,i,r){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(a);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,i);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!u||!u.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:i,unitId:t,subUnitId:a},componentKey:u.dropdown,onHide:r})}};ve=En([Se(0,o.Inject(B.SheetCanvasPopManagerService)),Se(1,o.IUniverInstanceService),Se(2,o.Inject(J.DataValidatorRegistryService)),Se(3,z.IZenZoneService),Se(4,U.IRenderManagerService),Se(5,o.Inject(E.SheetDataValidationModel)),Se(6,o.Inject(X.SheetsSelectionsService))],ve);const xe="DataValidationPanel",_e={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,i=e.get(ue),r=e.get(J.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(z.ISidebarService),l=X.getSheetCommandTarget(s);if(!l)return!1;const{unitId:u,subUnitId:p}=l,m=a?r.getRuleById(u,p,a):void 0;i.open(),i.setActiveRule(m&&{unitId:u,subUnitId:p,rule:m});const c=d.open({id:xe,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:xe},width:312,onClose:()=>i.close()});return i.setCloseDisposable(c),!0}},ot={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},Ft={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),a=e.get(ue);return a.open(),a.isOpen?t.executeCommand(ot.id):t.executeCommand(_e.id),!0}},Ne={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(ve),{unitId:n,subUnitId:i,row:r,column:s}=t,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===i&&l.row===r&&l.col===s||a.showDataValidationDropdown(n,i,r,s),!0}},xt={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(ve).hideDropdown(),!0):!1}},Ie="#ECECEC",rt="sheets-data-validation-ui.config",Ue={},me={dvListDropdown:"univer-dv-list-dropdown",dvListDropdownTitle:"univer-dv-list-dropdown-title",dvListDropdownList:"univer-dv-list-dropdown-list",dvListDropdownListContainer:"univer-dv-list-dropdown-list-container",dvListDropdownSelectedIcon:"univer-dv-list-dropdown-selected-icon",dvListDropdownItemContainer:"univer-dv-list-dropdown-item-container",dvListDropdownItem:"univer-dv-list-dropdown-item",dvListDropdownSplit:"univer-dv-list-dropdown-split",dvListDropdownEdit:"univer-dv-list-dropdown-edit"},Rn=e=>{var I,C;const{value:t,onChange:a,multiple:n,options:i,title:r,onEdit:s,style:d,filter:l,location:u}=e,p=o.useDependency(o.LocaleService),m=o.useDependency(o.IConfigService),c=l==null?void 0:l.toLowerCase(),{row:S,col:f,unitId:D,subUnitId:V}=u,_=i.filter(v=>c?v.label.toLowerCase().includes(c):!0),w=(C=(I=m.getConfig(rt))==null?void 0:I.showEditOnDropdown)!=null?C:!0,y=o.useDependency(X.SheetPermissionCheckController),M=g.useMemo(()=>y.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission]},[{startColumn:f,startRow:S,endColumn:f,endRow:S}],D,V),[y,f,S,D,V]);return h.jsxs("div",{className:me.dvListDropdown,style:d,children:[h.jsx("div",{className:me.dvListDropdownTitle,children:r}),h.jsx("div",{className:me.dvListDropdownList,children:h.jsx(b.Scrollbar,{children:h.jsx("div",{className:me.dvListDropdownListContainer,children:_.map((v,O)=>{const j=t.indexOf(v.value)>-1,k=()=>{let T;j?T=new Set(t.filter(x=>x!==v.value)):T=new Set(n?[...t,v.value]:[v.value]);const F=[];i.forEach(x=>{T.has(x.value)&&F.push(x.value)}),a(F)},A=v.label.toLocaleLowerCase().indexOf(c);return h.jsxs("div",{className:me.dvListDropdownItemContainer,onClick:k,children:[h.jsx("div",{className:me.dvListDropdownItem,style:{background:v.color||Ie},children:c&&v.label.toLowerCase().includes(c)?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:v.label.substring(0,A)}),h.jsx("span",{style:{fontWeight:"bold"},children:v.label.substring(A,A+c.length)}),h.jsx("span",{children:v.label.substring(A+c.length)})]}):v.label}),h.jsx("div",{className:me.dvListDropdownSelectedIcon,children:j?h.jsx(Mt,{}):null})]},O)})})},l)}),w&&M?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:me.dvListDropdownSplit}),h.jsx("div",{className:me.dvListDropdownEdit,children:h.jsx("a",{onClick:s,children:p.t("dataValidation.list.edit")})})]}):null]})};function Mn(e){var N,W,G,Z;const{location:t,hideFn:a}=e,{worksheet:n,row:i,col:r,unitId:s,subUnitId:d}=t,l=o.useDependency(J.DataValidationModel),[u,p]=g.useState(""),m=o.useDependency(o.ICommandService),c=o.useDependency(o.LocaleService),[S,f]=g.useState(""),D=o.useDependency(B.IEditorBridgeService),V=o.useDependency(o.IUniverInstanceService),_=g.useMemo(()=>l.ruleChange$.pipe(re.debounceTime(16)),[]),w=o.useDependency(E.SheetDataValidationModel);z.useObservable(_);const y=z.RectPopup.useContext(),M=((W=(N=y.current)==null?void 0:N.right)!=null?W:0)-((Z=(G=y.current)==null?void 0:G.left)!=null?Z:0);if(g.useEffect(()=>{const q=m.onCommandExecuted(ee=>{var te,ae;if(ee.id===en.RichTextEditingMutation.id){const ie=ee.params,{unitId:le}=ie,oe=V.getUnit(le,o.UniverInstanceType.UNIVER_DOC);if(!oe||!D.isVisible().visible)return;const de=o.BuildTextUtils.transform.getPlainText((ae=(te=oe.getSnapshot().body)==null?void 0:te.dataStream)!=null?ae:"");p(de)}});return()=>{q.dispose()}},[m,D,V]),!n)return null;const I=w.getRuleByLocation(s,d,i,r);if(!I)return null;const C=w.getValidator(I.type);if(!C)return null;const v=n.getCell(i,r),O=(I==null?void 0:I.renderMode)===o.DataValidationRenderMode.CUSTOM||(I==null?void 0:I.renderMode)===void 0;if(!v||!I||!C||C.id.indexOf(o.DataValidationType.LIST)!==0)return;const j=I.type===o.DataValidationType.LIST_MULTIPLE,k=C.getListWithColor(I,s,d),A=S||E.getDataValidationCellValue(n.getCellRaw(i,r)),T=E.deserializeListOptions(A),F=()=>{m.executeCommand(_e.id,{ruleId:I.uid}),a()},x=k.map(q=>({label:q.label,value:q.label,color:O||q.color?q.color:"transparent"}));return h.jsx(Rn,{style:{minWidth:M,maxWidth:Math.max(M,200)},title:j?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:T,multiple:j,onChange:async q=>{const ee=E.serializeListOptions(q),te={unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:ee,p:null,f:null,si:null}};D.isVisible()&&D.changeVisible({visible:!1,keycode:z.KeyCode.ESC,eventType:U.DeviceInputEventType.Keyboard,unitId:s}),f(ee),j||a(),D.isVisible().visible&&await m.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:U.DeviceInputEventType.Keyboard,unitId:s,keycode:z.KeyCode.ESC}),m.executeCommand(X.SetRangeValuesCommand.id,te)},options:x,onEdit:F,filter:u,location:t})}const st={dataValidationOptionsButton:"univer-data-validation-options-button",dataValidationOptionsButtonIcon:"univer-data-validation-options-button-icon"};function bn(e){var u;const t=o.useDependency(o.LocaleService),a=o.useDependency(z.ComponentManager),{value:n,onChange:i,extraComponent:r}=e,[s,d]=g.useState(!1),l=r?a.get(r):null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:st.dataValidationOptionsButton,onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?h.jsx(Tt,{className:st.dataValidationOptionsButtonIcon}):h.jsx(Lt,{className:st.dataValidationOptionsButtonIcon})]}),s&&h.jsxs(h.Fragment,{children:[l?h.jsx(l,{value:n,onChange:i}):null,h.jsx(b.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:h.jsxs(b.RadioGroup,{value:`${(u=n.errorStyle)!=null?u:o.DataValidationErrorStyle.WARNING}`,onChange:p=>i({...n,errorStyle:+p}),children:[h.jsx(b.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),h.jsx(b.Radio,{value:`${o.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:()=>i({...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=>i({...n,error:p})})}):null]})]})}const we={dataValidationDetail:"univer-data-validation-detail",dataValidationDetailFormItem:"univer-data-validation-detail-form-item",dataValidationDetailButtons:"univer-data-validation-detail-buttons",dataValidationDetailButton:"univer-data-validation-detail-button"},On=e=>o.debounce(async(t,a,n,i)=>{const r=await e.executeCommand(t,a,n);i==null||i(r)},1e3);function Ln(e,t,a){var n,i,r,s;return t?((i=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:i.getSheetId())||"":((s=(r=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Tn(){var de;const[e,t]=g.useState(0),a=o.useDependency(ue),n=z.useObservable(a.activeRule$,a.activeRule),{unitId:i,subUnitId:r,rule:s}=n||{},d=s.uid,l=o.useDependency(J.DataValidatorRegistryService),u=o.useDependency(o.IUniverInstanceService),p=o.useDependency(z.ComponentManager),m=o.useDependency(o.ICommandService),c=o.useDependency(J.DataValidationModel),S=o.useDependency(o.LocaleService),[f,D]=g.useState(s),V=l.getValidatorItem(f.type),[_,w]=g.useState(!1),y=l.getValidatorsByScope(J.DataValidatorRegistryScope.SHEET),[M,I]=g.useState(()=>f.ranges.map(P=>({unitId:"",sheetId:"",range:P}))),C=g.useMemo(()=>On(m),[m]),[v,O]=g.useState(!1),j=g.useRef({}),[k,A]=g.useState(!1),T=o.useDependency(X.SheetsSelectionsService);if(g.useEffect(()=>()=>{const P=T.getCurrentLastSelection();P&&T.setSelections([P])},[T]),g.useEffect(()=>{m.onCommandExecuted(P=>{(P.id===o.UndoCommand.id||P.id===o.RedoCommand.id)&&setTimeout(()=>{const R=c.getRuleById(i,r,d);t($=>$+1),R&&(D(R),I(R.ranges.map($=>({unitId:"",sheetId:"",range:$}))))},20)})},[m,c,d,r,i]),!V)return null;const F=V.operators,x=V.operatorNames,N=f.operator?J.TWO_FORMULA_OPERATOR_COUNT.includes(f.operator):!1,W=()=>{!f.ranges.length||v||(V.validatorFormula(f,i,r).success?a.setActiveRule(null):w(!0))},G=z.useEvent(P=>{const R=P.split(",").filter(Boolean).map(tt.deserializeRangeWithSheet).map(K=>{const ge=K.sheetName;if(ge){const ei=Ln(u,K.unitId,ge);return{...K,sheetId:ei}}return{...K,sheetId:""}});if(o.isUnitRangesEqual(R,M))return;I(R);const $=R.filter(K=>(!K.unitId||K.unitId===i)&&(!K.sheetId||K.sheetId===r)).map(K=>K.range);if(D({...f,ranges:$}),$.length===0)return;const H={unitId:i,subUnitId:r,ruleId:d,ranges:$};C(E.UpdateSheetDataValidationRangeCommand.id,H)}),Z=P=>{if(o.shallowEqual(P,J.getRuleSetting(f)))return;D({...f,...P});const R={unitId:i,subUnitId:r,ruleId:d,setting:P};C(E.UpdateSheetDataValidationSettingCommand.id,R,void 0)},q=async()=>{await m.executeCommand(E.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:i,subUnitId:r}),a.setActiveRule(null)},ee={type:f.type,operator:f.operator,formula1:f.formula1,formula2:f.formula2,allowBlank:f.allowBlank},te=P=>{const R=l.getValidatorItem(P);if(!R)return;const $=R.operators,H=c.getRuleById(i,r,d),K=P===(H==null?void 0:H.type)||P.includes("list")&&(H!=null&&H.type.includes("list"))?{...H,type:P}:{...f,type:P,operator:$[0],formula1:void 0,formula2:void 0};D(K),m.executeCommand(E.UpdateSheetDataValidationSettingCommand.id,{unitId:i,subUnitId:r,ruleId:f.uid,setting:J.getRuleSetting(K)})},ae=p.get(V.formulaInput),ie=g.useMemo(()=>M.map(P=>tt.serializeRange(P.range)).join(","),[]),le=J.getRuleOptions(f),oe=P=>{o.shallowEqual(P,J.getRuleOptions(f))||(D({...f,...P}),C(E.UpdateSheetDataValidationOptionsCommand.id,{unitId:i,subUnitId:r,ruleId:d,options:P}))};return z.useSidebarClick(P=>{var $;const R=($=j.current)==null?void 0:$.handleOutClick;R&&R(P,()=>A(!1))}),h.jsxs("div",{className:we.dataValidationDetail,children:[h.jsx(b.FormLayout,{label:S.t("dataValidation.panel.range"),error:!f.ranges.length||v?S.t("dataValidation.panel.rangeError"):"",children:h.jsx(nt.RangeSelector,{unitId:i,subUnitId:r,initValue:ie,onChange:G,onFocus:()=>A(!0),isFocus:k,actions:j.current,onVerify:P=>O(!P)})}),h.jsx(b.FormLayout,{label:S.t("dataValidation.panel.type"),children:h.jsx(b.Select,{options:y==null?void 0:y.map(P=>({label:S.t(P.title),value:P.id})),value:f.type,onChange:te,className:we.dataValidationDetailFormItem})}),F!=null&&F.length?h.jsx(b.FormLayout,{label:S.t("dataValidation.panel.operator"),children:h.jsx(b.Select,{options:F.map((P,R)=>({value:`${P}`,label:x[R]})),value:`${f.operator}`,onChange:P=>{Z({...ee,operator:P})},className:we.dataValidationDetailFormItem})}):null,ae?h.jsx(ae,{isTwoFormula:N,value:{formula1:f.formula1,formula2:f.formula2},onChange:P=>{Z({...ee,...P})},showError:_,validResult:V.validatorFormula(f,i,r),unitId:i,subUnitId:r,ruleId:d},e+f.type):null,h.jsx(b.FormLayout,{children:h.jsx(b.Checkbox,{checked:(de=f.allowBlank)!=null?de:!0,onChange:()=>{var P;return Z({...ee,allowBlank:!((P=f.allowBlank)==null||P)})},children:S.t("dataValidation.panel.allowBlank")})}),h.jsx(bn,{value:le,onChange:oe,extraComponent:V.optionsInput}),h.jsxs("div",{className:we.dataValidationDetailButtons,children:[h.jsx(b.Button,{className:we.dataValidationDetailButton,onClick:q,children:S.t("dataValidation.panel.removeRule")}),h.jsx(b.Button,{className:we.dataValidationDetailButton,type:"primary",onClick:W,children:S.t("dataValidation.panel.done")})]})]})}const Be={dataValidationItemContainer:"univer-data-validation-item-container",dataValidationItemTitle:"univer-data-validation-item-title",dataValidationItemContent:"univer-data-validation-item-content",dataValidationItemIcon:"univer-data-validation-item-icon"},Pn=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:i,disable:r}=e,s=o.useDependency(J.DataValidatorRegistryService),d=o.useDependency(o.ICommandService),l=o.useDependency(B.IMarkSelectionService),u=s.getValidatorItem(t.type),p=g.useRef(),[m,c]=g.useState(!1),S=f=>{d.executeCommand(E.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:i}),f.stopPropagation()};return g.useEffect(()=>()=>{var f;p.current&&((f=p.current)==null||f.forEach(D=>{D&&l.removeShape(D)}))},[l]),h.jsxs("div",{className:Be.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{r||(c(!0),p.current=t.ranges.map(f=>l.addShape({range:f,style:{fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:null})))},onMouseLeave:()=>{var f;c(!1),(f=p.current)==null||f.forEach(D=>{D&&l.removeShape(D)}),p.current=void 0},children:[h.jsx("div",{className:Be.dataValidationItemTitle,children:u==null?void 0:u.generateRuleName(t)}),h.jsx("div",{className:Be.dataValidationItemContent,children:t.ranges.map(f=>tt.serializeRange(f)).join(",")}),m?h.jsx("div",{className:Be.dataValidationItemIcon,onClick:S,children:h.jsx(it,{})}):null]})},ke={dataValidationList:"univer-data-validation-list",dataValidationListButtons:"univer-data-validation-list-buttons",dataValidationListButton:"univer-data-validation-list-button"};function jn(){const e=o.useDependency(o.IUniverInstanceService),t=z.useObservable(()=>e.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return t?h.jsx(An,{workbook:t}):null}function An(e){const t=o.useDependency(E.SheetDataValidationModel),a=o.useDependency(o.IUniverInstanceService),n=o.useDependency(o.ICommandService),i=o.useDependency(o.Injector),r=o.useDependency(ue),s=o.useDependency(o.LocaleService),[d,l]=g.useState([]),{workbook:u}=e,p=z.useObservable(u.activeSheet$,void 0,!0),m=u.getUnitId(),c=p==null?void 0:p.getSheetId();g.useEffect(()=>{l(t.getRules(m,c));const w=t.ruleChange$.subscribe(y=>{y.unitId===m&&y.subUnitId===c&&l(t.getRules(m,c))});return()=>{w.unsubscribe()}},[m,c,t]);const S=async()=>{const w=E.createDefaultNewRule(i),y={unitId:m,subUnitId:c,rule:w};await n.executeCommand(E.AddSheetDataValidationCommand.id,y),r.setActiveRule({unitId:m,subUnitId:c,rule:w})},f=()=>{n.executeCommand(E.RemoveSheetAllDataValidationCommand.id,{unitId:m,subUnitId:c})},V=(w=>{const y=a.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),M=y.getActiveSheet(),I=y.getUnitId(),C=M.getSheetId();return w.map(O=>X.checkRangesEditablePermission(i,I,C,O.ranges)?{...O}:{...O,disable:!0})})(d),_=V==null?void 0:V.some(w=>w.disable);return h.jsxs("div",{className:ke.dataValidationList,children:[V==null?void 0:V.map(w=>{var y;return h.jsx(Pn,{unitId:m,subUnitId:c,onClick:()=>{w.disable||r.setActiveRule({unitId:m,subUnitId:c,rule:w})},rule:w,disable:(y=w.disable)!=null?y:!1},w.uid)}),h.jsxs("div",{className:ke.dataValidationListButtons,children:[d.length&&!_?h.jsx(b.Button,{className:ke.dataValidationListButton,onClick:f,children:s.t("dataValidation.panel.removeAll")}):null,h.jsx(b.Button,{className:ke.dataValidationListButton,type:"primary",onClick:S,children:s.t("dataValidation.panel.add")})]})]})}const Fn=()=>{const e=o.useDependency(ue),t=z.useObservable(e.activeRule$,e.activeRule);return t?h.jsx(Tn,{},t.rule.uid):h.jsx(jn,{})},We="data-validation.list.dropdown",lt="data-validation.date.dropdown",$e={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),a=X.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:i}=a,r=E.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=i.getSheetId(),u={rule:r,unitId:d,subUnitId:l};return s.syncExecuteCommand(E.AddSheetDataValidationCommand.id,u)?(s.syncExecuteCommand(_e.id,{ruleId:r.uid,isAdd:!0}),!0):!1}};var xn=Object.defineProperty,Nn=Object.getOwnPropertyDescriptor,Un=(e,t,a,n)=>{for(var i=n>1?void 0:n?Nn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&xn(t,a,i),i},Ve=(e,t)=>(a,n)=>t(a,n,e);const Ce="SHEET_DATA_VALIDATION_ALERT";let Ae=class extends o.Disposable{constructor(e,t,a,n,i,r){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=i,this._dataValidationModel=r,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(re.debounceTime(100)).subscribe(e=>{var t;if(e){const a=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),n=a.getSheetBySheetId(e.location.subUnitId);if(!n)return;const i=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!i){this._cellAlertManagerService.removeAlert(Ce);return}if(this._dataValidationModel.validator(i,{...e.location,workbook:a,worksheet:n})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Ce),d=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(d&&d.row===e.location.row&&d.col===e.location.col&&d.subUnitId===e.location.subUnitId&&d.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(Ce);return}const l=this._dataValidationModel.getValidator(i.type);if(!l){this._cellAlertManagerService.removeAlert(Ce);return}this._cellAlertManagerService.showAlert({type:B.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(i,e.location),location:e.location,width:200,height:74,key:Ce});return}}this._cellAlertManagerService.removeAlert(Ce)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(Ce)}))}};Ae=Un([Ve(0,o.Inject(B.HoverManagerService)),Ve(1,o.Inject(B.CellAlertManagerService)),Ve(2,o.IUniverInstanceService),Ve(3,o.Inject(o.LocaleService)),Ve(4,z.IZenZoneService),Ve(5,o.Inject(E.SheetDataValidationModel))],Ae);var Bn=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,Wn=(e,t,a,n)=>{for(var i=n>1?void 0:n?kn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Bn(t,a,i),i},dt=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends o.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,i)=>{const{source:r,target:s,unitId:d,subUnitId:l}=n,u=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),p=B.virtualizeDiscreteRanges([r,s]),[m,c]=p.ranges,{mapFunc:S}=p,f={row:m.startRow,col:m.startColumn},D=B.getAutoFillRepeatRange(m,c),V=new o.ObjectMatrix,_=new Set;D.forEach(C=>{const v=C.repeatStartCell,O=C.relativeRange,j={startRow:f.row,startColumn:f.col,endColumn:f.col,endRow:f.row},k={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row};o.Range.foreach(O,(A,T)=>{const F=o.Rectangle.getPositionRange({startRow:A,startColumn:T,endColumn:T,endRow:A},j),{row:x,col:N}=S(F.startRow,F.startColumn),W=this._sheetDataValidationModel.getRuleIdByLocation(d,l,x,N)||"",G=o.Rectangle.getPositionRange({startRow:A,startColumn:T,endColumn:T,endRow:A},k),{row:Z,col:q}=S(G.startRow,G.startColumn);V.setValue(Z,q,W),_.add(W)})});const w=Array.from(_).map(C=>({id:C,ranges:o.queryObjectMatrix(V,v=>v===C)}));u.addRangeRules(w);const y=u.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:M,undoMutations:I}=E.getDataValidationDiffMutations(d,l,y,this._injector,"patched",i===B.APPLY_TYPE.ONLY_FORMAT);return{undos:I,redos:M}},a={id:E.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:i,unitId:r,subUnitId:s}=n;for(const d of i.rows)for(const l of i.cols){const u=this._sheetDataValidationModel.getRuleByLocation(r,s,d,l);if(u&&u.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(B.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,i,r)=>r===B.APPLY_TYPE.COPY||r===B.APPLY_TYPE.ONLY_FORMAT||r===B.APPLY_TYPE.SERIES?t(n,r):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};Ee=Wn([dt(0,B.IAutoFillService),dt(1,o.Inject(E.SheetDataValidationModel)),dt(2,o.Inject(o.Injector))],Ee);var $n=Object.defineProperty,Hn=Object.getOwnPropertyDescriptor,Yn=(e,t,a,n)=>{for(var i=n>1?void 0:n?Hn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&$n(t,a,i),i},ct=(e,t)=>(a,n)=>t(a,n,e);let Re=class extends o.Disposable{constructor(t,a,n){super();L(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:E.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,i)=>{const{copyType:r=B.COPY_TYPE.COPY,pasteType:s}=i,{range:d}=t||{},{range:l,unitId:u,subUnitId:p}=a;return this._generateMutations(l,{copyType:r,pasteType:s,copyRange:d,unitId:u,subUnitId:p})}})}_collect(t,a,n){const i=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:i};const r=this._injector.invoke(l=>B.rangeToDiscreteRange(n,l,t,a));if(!r)return;const{rows:s,cols:d}=r;s.forEach((l,u)=>{d.forEach((p,m)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(t,a,l,p);i.setValue(u,m,c!=null?c:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===B.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:i,subUnitId:r}=this._copyInfo;if(a.unitId!==i||r!==a.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[u,p],mapFunc:m}=B.virtualizeDiscreteRanges([a.copyRange,t]),c=B.getRepeatRange(u,p,!0),S=new Map;c.forEach(({startRange:_})=>{var w;(w=this._copyInfo)==null||w.matrix.forValue((y,M,I)=>{const C=o.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:M,endColumn:M},_),v=`${r}-${I}`,O=this._sheetDataValidationModel.getRuleById(i,r,I);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,v)&&O&&S.set(v,{...O,uid:v});const{row:j,col:k}=m(C.startRow,C.startColumn);l.add(v),d.setValue(j,k,v)})});const f=Array.from(l).map(_=>({id:_,ranges:o.queryObjectMatrix(d,w=>w===_)}));s.addRangeRules(f);const{redoMutations:D,undoMutations:V}=E.getDataValidationDiffMutations(a.unitId,a.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),S.values()),this._injector,"patched",!1);return{redos:D,undos:V}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(i,r).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[u,p],mapFunc:m}=B.virtualizeDiscreteRanges([a.copyRange,t]);B.getRepeatRange(u,p,!0).forEach(({startRange:V})=>{var _;(_=this._copyInfo)==null||_.matrix.forValue((w,y,M)=>{const I=o.Rectangle.getPositionRange({startRow:w,endRow:w,startColumn:y,endColumn:y},V),{row:C,col:v}=m(I.startRow,I.startColumn);d.setValue(C,v,M),l.add(M)})});const S=Array.from(l).map(V=>({id:V,ranges:o.queryObjectMatrix(d,_=>_===V)}));s.addRangeRules(S);const{redoMutations:f,undoMutations:D}=E.getDataValidationDiffMutations(i,r,s.diff(this._sheetDataValidationModel.getRules(i,r)),this._injector,"patched",!1);return{redos:f,undos:D}}}};Re=Yn([ct(0,B.ISheetClipboardService),ct(1,o.Inject(E.SheetDataValidationModel)),ct(2,o.Inject(o.Injector))],Re);var Xn=Object.defineProperty,zn=Object.getOwnPropertyDescriptor,Kn=(e,t,a,n)=>{for(var i=n>1?void 0:n?zn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Xn(t,a,i),i},ut=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends o.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===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")))}))}};Me=Kn([ut(0,o.Inject(o.LocaleService)),ut(1,o.ICommandService),ut(2,o.Inject(X.SheetPermissionCheckController))],Me);const Nt="data-validation-single",Ut="sheet.menu.data-validation";function qn(e){return{id:Ut,type:z.MenuItemType.SUBITEMS,icon:Nt,tooltip:"dataValidation.title",hidden$:z.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:B.getCurrentRangeDisable$(e,{workbookTypes:[X.WorkbookEditablePermission],worksheetTypes:[X.WorksheetSetCellStylePermission,X.WorksheetEditPermission],rangeTypes:[X.RangeProtectionPermissionEditPoint]})}}function Gn(e){return{id:_e.id,title:"dataValidation.panel.title",type:z.MenuItemType.BUTTON}}function Zn(e){return{id:$e.id,title:"dataValidation.panel.add",type:z.MenuItemType.BUTTON}}const Jn={[z.RibbonStartGroup.FORMULAS_INSERT]:{[Ut]:{order:9,menuItemFactory:qn,[_e.id]:{order:0,menuItemFactory:Gn},[$e.id]:{order:1,menuItemFactory:Zn}}}};var Qn=Object.defineProperty,ea=Object.getOwnPropertyDescriptor,Bt=(e,t,a,n)=>{for(var i=n>1?void 0:n?ea(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Qn(t,a,i),i},Q=(e,t)=>(a,n)=>t(a,n,e);const kt={tr:{size:6,color:"#fe4b4b"}};let be=class extends o.RxDisposable{constructor(e,t,a,n,i,r,s,d,l,u,p){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=i,this._dropdownManagerService=r,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=u,this._editorBridgeService=p,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Jn)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var a;if(!e.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:i,row:r,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,i,r,s);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(u!=null&&u.dropdown))return;const p=d.getActiveSheet();if(!p)return;const m=this._dropdownManagerService.activeDropdown,c=m==null?void 0:m.location;if(c&&c.unitId===n&&c.subUnitId===i&&c.row===r&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:i,row:r,col:s,workbook:d,worksheet:p},componentKey:u.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var _,w,y,M,I;const{row:n,col:i,unitId:r,subUnitId:s,workbook:d,worksheet:l}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!u)return a(e);const p=this._sheetDataValidationModel.getRuleById(r,s,u);if(!p)return a(e);const m=(_=this._dataValidationCacheService.getValue(r,s,n,i))!=null?_:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),S=t.rawData;let f;const D={get value(){var C;return f!==void 0||(f=(C=E.getCellValueOrigin(S))!=null?C:null),f}},V={get value(){var C;return`${(C=D.value)!=null?C:""}`}};return a({...e,markers:{...e==null?void 0:e.markers,...m===o.DataValidationStatus.INVALID?kt:null},customRender:[...(w=e==null?void 0:e.customRender)!=null?w:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((M=c==null?void 0:c.skipDefaultFontRender)==null?void 0:M.call(c,p,D.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,V.value,{get style(){const C=d.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,i)},interceptorAutoHeight:()=>{var j,k,A,T,F,x;const C=(k=(j=this._renderManagerService.getRenderById(r))==null?void 0:j.with(B.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:k.skeleton;if(!C)return;const v=C.worksheet.getMergedCell(n,i),O={data:e,style:C.getsStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((A=v==null?void 0:v.startRow)!=null?A:n,(T=v==null?void 0:v.startColumn)!=null?T:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(x=(F=c==null?void 0:c.canvasRender)==null?void 0:F.calcCellAutoHeight)==null?void 0:x.call(F,O)},interceptorAutoWidth:()=>{var j,k,A,T,F,x;const C=(k=(j=this._renderManagerService.getRenderById(r))==null?void 0:j.with(B.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:k.skeleton;if(!C)return;const v=C.worksheet.getMergedCell(n,i),O={data:e,style:C.getsStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((A=v==null?void 0:v.startRow)!=null?A:n,(T=v==null?void 0:v.startColumn)!=null?T:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(x=(F=c==null?void 0:c.canvasRender)==null?void 0:F.calcCellAutoWidth)==null?void 0:x.call(F,O)},coverable:((I=e==null?void 0:e.coverable)!=null?I:!0)&&!(p.type===o.DataValidationType.LIST||p.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(re.filter(e=>e.source==="command"),re.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(a=>{var n;(a.rule.type===o.DataValidationType.LIST_MULTIPLE||a.rule.type===o.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};be=Bt([Q(0,o.ICommandService),Q(1,z.IMenuManagerService),Q(2,U.IRenderManagerService),Q(3,o.IUniverInstanceService),Q(4,o.Inject(B.AutoHeightController)),Q(5,o.Inject(ve)),Q(6,o.Inject(E.SheetDataValidationModel)),Q(7,o.Inject(J.DataValidatorRegistryService)),Q(8,o.Inject(X.SheetInterceptorService)),Q(9,o.Inject(E.DataValidationCacheService)),Q(10,o.Optional(B.IEditorBridgeService))],be);let Wt=class extends o.RxDisposable{constructor(e,t,a,n,i,r,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=i,this._sheetDataValidationModel=r,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var V,_,w,y,M;const{row:n,col:i,unitId:r,subUnitId:s,workbook:d,worksheet:l}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!u)return a(e);const p=this._sheetDataValidationModel.getRuleById(r,s,u);if(!p)return a(e);const m=(V=this._dataValidationCacheService.getValue(r,s,n,i))!=null?V:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),S=l.getCellRaw(n,i),f=E.getCellValueOrigin(S),D=`${f!=null?f:""}`;return a({...e,markers:{...e==null?void 0:e.markers,...m===o.DataValidationStatus.INVALID?kt:null},customRender:[...(_=e==null?void 0:e.customRender)!=null?_:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((w=e==null?void 0:e.fontRenderExtension)==null?void 0:w.isSkip)||((y=c==null?void 0:c.skipDefaultFontRender)==null?void 0:y.call(c,p,f,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,D,{get style(){const I=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?I.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,i)},interceptorAutoHeight:()=>{var O,j,k,A,T,F;const I=(j=(O=this._renderManagerService.getRenderById(r))==null?void 0:O.with(B.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:j.skeleton;if(!I)return;const C=I.worksheet.getMergedCell(n,i),v={data:e,style:I.getsStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((k=C==null?void 0:C.startRow)!=null?k:n,(A=C==null?void 0:C.startColumn)!=null?A:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(F=(T=c==null?void 0:c.canvasRender)==null?void 0:T.calcCellAutoHeight)==null?void 0:F.call(T,v)},coverable:((M=e==null?void 0:e.coverable)!=null?M:!0)&&!(p.type===o.DataValidationType.LIST||p.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(re.filter(e=>e.source==="command"),re.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};Wt=Bt([Q(0,o.ICommandService),Q(1,U.IRenderManagerService),Q(2,o.Inject(B.AutoHeightController)),Q(3,o.Inject(J.DataValidatorRegistryService)),Q(4,o.Inject(X.SheetInterceptorService)),Q(5,o.Inject(E.SheetDataValidationModel)),Q(6,o.Inject(E.DataValidationCacheService))],Wt);var ta=Object.defineProperty,na=Object.getOwnPropertyDescriptor,aa=(e,t,a,n)=>{for(var i=n>1?void 0:n?na(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&ta(t,a,i),i},$t=(e,t)=>(a,n)=>t(a,n,e);let He=class extends o.Disposable{constructor(e,t,a){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const a=new Set;t.forEach(i=>{a.add(i.subUnitId)}),a.forEach(i=>{var r;(r=this._sheetSkeletonManagerService.getWorksheetSkeleton(i))==null||r.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};He=aa([$t(1,o.Inject(E.SheetDataValidationModel)),$t(2,o.Inject(B.SheetSkeletonManagerService))],He);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"},ia=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:i,validResult:r}=e,s=o.useDependency(o.LocaleService),d=i?r==null?void 0:r.formula1:"",l=i?r==null?void 0:r.formula2:"";return t?h.jsxs(h.Fragment,{children:[h.jsx(b.FormLayout,{error:d,children:h.jsx(b.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({...a,formula1:u})}})}),h.jsx("div",{className:ne.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),h.jsx(b.FormLayout,{error:l,children:h.jsx(b.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:u=>{n==null||n({...a,formula2:u})}})})]}):h.jsx(b.FormLayout,{error:d,children:h.jsx(b.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({formula1:u})}})})};function oa(e){const{value:t,onChange:a,showError:n,validResult:i}=e,r=o.useDependency(o.LocaleService),s=n?i==null?void 0:i.formula1:"",d=n?i==null?void 0:i.formula2:"",[l,u]=g.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return h.jsxs(h.Fragment,{children:[h.jsx(b.FormLayout,{children:h.jsx(b.Checkbox,{checked:l,onChange:p=>{p?u(!0):(u(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:r.t("dataValidation.checkbox.tips")})}),l?h.jsx(b.FormLayout,{label:r.t("dataValidation.checkbox.checked"),error:s,children:h.jsx(b.Input,{className:ne.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:p=>{a==null||a({...t,formula1:p||void 0})}})}):null,l?h.jsx(b.FormLayout,{label:r.t("dataValidation.checkbox.unchecked"),error:d,children:h.jsx(b.Input,{className:ne.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:p=>{a==null||a({...t,formula2:p||void 0})}})}):null]})}function ra(e){var m;const{unitId:t,subUnitId:a,value:n,onChange:i,showError:r,validResult:s}=e,d=r?s==null?void 0:s.formula1:void 0,l=g.useRef({}),[u,p]=g.useState(!1);return z.useSidebarClick(c=>{var f;const S=(f=l.current)==null?void 0:f.handleOutClick;S&&S(c,()=>p(!1))}),h.jsx(nt.FormulaEditor,{initValue:(m=n==null?void 0:n.formula1)!=null?m:"=",unitId:t,subUnitId:a,isFocus:u,onChange:c=>{const S=(c!=null?c:"").trim();S!==(n==null?void 0:n.formula1)&&(i==null||i({...n,formula1:S}))},errorText:d,onFocus:()=>p(!0),actions:l.current,isSupportAcrossSheet:!0})}function Ht(e){var t,a,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(a=Ht(e[t]))&&(n&&(n+=" "),n+=a)}else for(a in e)e[a]&&(n&&(n+=" "),n+=a);return n}function sa(){for(var e,t,a=0,n="",i=arguments.length;a<i;a++)(e=arguments[a])&&(t=Ht(e))&&(n&&(n+=" "),n+=t);return n}const la=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],da=e=>{const{value:t,onChange:a,disabled:n}=e,[i,r]=g.useState(!1);return h.jsx(b.Select,{disabled:n,open:i,onDropdownVisibleChange:r,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ne.dataValidationFormulaColorSelect,value:t,onChange:a,labelRender:s=>h.jsx("div",{className:ne.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>h.jsx("div",{className:ne.dataValidationFormulaColorSelectPanel,children:la.map(s=>h.jsx("div",{onClick:()=>{a(s),r(!1)},className:ne.dataValidationFormulaColorItem,style:{background:s}},s))})})},Yt=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:i,onItemDelete:r}=a;return h.jsxs("div",{className:ne.dataValidationFormulaListItem,style:n,children:[t.isRef?null:h.jsx("div",{className:sa(ne.dataValidationFormulaListItemDrag,"draggableHandle"),children:h.jsx(Pt,{})}),h.jsx(da,{value:t.color,onChange:s=>{i(t.id,t.label,s)}}),h.jsx(b.Input,{disabled:t.isRef,value:t.label,onChange:s=>{i(t.id,s,t.color)}}),t.isRef?null:h.jsx("div",{className:ne.dataValidationFormulaListItemIcon,children:h.jsx(it,{onClick:()=>r(t.id)})})]})};function ca(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:i,validResult:r,showError:s,ruleId:d}=e,{formula1:l="",formula2:u=""}=t||{},p=g.useRef(null),[m,c]=g.useState(()=>o.isFormulaString(l)?"1":"0"),[S,f]=g.useState(m==="1"?l:"="),[D,V]=g.useState(m==="1"?l:"="),_=o.useDependency(o.LocaleService),w=o.useDependency(J.DataValidatorRegistryService),y=o.useDependency(J.DataValidationModel),M=o.useDependency(E.DataValidationFormulaController),[I,C]=g.useState(()=>u.split(",")),v=w.getValidatorItem(o.DataValidationType.LIST),[O,j]=g.useState([]),[k,A]=g.useState(""),T=s?r==null?void 0:r.formula1:"",F=g.useMemo(()=>y.ruleChange$.pipe(re.debounceTime(16)),[]),x=z.useObservable(F),N=z.useEvent(a);g.useEffect(()=>{(async()=>{await new Promise(H=>{setTimeout(()=>H(!0),100)});const R=y.getRuleById(n,i,d),$=R==null?void 0:R.formula1;if(o.isFormulaString($)&&v&&R){const H=await v.getListAsync(R,n,i);j(H)}})()},[y,x,v,d,i,n]),g.useEffect(()=>{o.isFormulaString(l)&&l!==D&&(f(l),V(D))},[D,l]);const[W,G]=g.useState(()=>{const R=m!=="1"?E.deserializeListOptions(l):[],$=u.split(",");return R.map((H,K)=>({label:H,color:$[K]||Ie,isRef:!1,id:o.Tools.generateRandomId(4)}))}),Z=(R,$,H)=>{const K=W.find(ge=>ge.id===R);K&&(K.label=$,K.color=H,G([...W]))},q=R=>{const $=W.findIndex(H=>H.id===R);$!==-1&&(W.splice($,1),G([...W]))},ee=u.split(","),te=g.useMemo(()=>O.map((R,$)=>({label:R,color:ee[$]||Ie,id:`${$}`,isRef:!0})),[ee,O]),ae=(R,$,H)=>{const K=[...I];K[+R]=H,C(K),N({formula1:l,formula2:K.join(",")})},ie=()=>{G([...W,{label:"",color:Ie,isRef:!1,id:o.Tools.generateRandomId(4)}])};g.useEffect(()=>{if(m==="1")return;const R=new Set,$=[];W.map(H=>({labelList:H.label.split(","),item:H})).forEach(({item:H,labelList:K})=>{K.forEach(ge=>{R.has(ge)||(R.add(ge),$.push({label:ge,color:H.color}))})}),N({formula1:E.serializeListOptions($.map(H=>H.label)),formula2:$.map(H=>H.color===Ie?"":H.color).join(",")})},[W,N,m,D,I]);const le=z.useEvent(async R=>{if(!o.isFormulaString(R)){N==null||N({formula1:"",formula2:u});return}M.getFormulaRefCheck(R)?(N==null||N({formula1:o.isFormulaString(R)?R:"",formula2:u}),A("")):(N==null||N({formula1:"",formula2:u}),f("="),A(_.t("dataValidation.validFail.formulaError")))}),oe=g.useRef({}),[de,P]=g.useState(!1);return z.useSidebarClick(R=>{var H;const $=(H=oe.current)==null?void 0:H.handleOutClick;$&&$(R,()=>P(!1))}),h.jsxs(h.Fragment,{children:[h.jsx(b.FormLayout,{label:_.t("dataValidation.list.options"),children:h.jsxs(b.RadioGroup,{value:m,onChange:R=>{c(R),f(D),R==="1"&&N({formula1:D==="="?"":D,formula2:I.join(",")})},children:[h.jsx(b.Radio,{value:"0",children:_.t("dataValidation.list.customOptions")}),h.jsx(b.Radio,{value:"1",children:_.t("dataValidation.list.refOptions")})]})}),m==="1"?h.jsxs(h.Fragment,{children:[h.jsx(nt.FormulaEditor,{initValue:S,unitId:n,subUnitId:i,isFocus:de,onChange:(R="")=>{const $=(R!=null?R:"").trim();V($),le($)},errorText:T||k||void 0,onFocus:()=>P(!0),actions:oe.current,isSupportAcrossSheet:!0}),h.jsx("div",{ref:p,style:{marginTop:"12px"},children:te.map(R=>h.jsx(Yt,{item:R,commonProps:{onItemChange:ae},style:{marginBottom:12}},R.id))})]}):h.jsx(b.FormLayout,{error:T,children:h.jsxs("div",{ref:p,style:{marginTop:"-12px"},children:[h.jsx(b.DraggableList,{list:W,onListChange:G,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:R=>h.jsx(Yt,{item:R,commonProps:{onItemChange:Z,onItemDelete:q}},R.id),idKey:"id"}),h.jsxs("a",{className:ne.dataValidationFormulaListAdd,onClick:ie,children:[h.jsx(Ot,{}),_.t("dataValidation.list.add")]})]})})]})}const Xt="data-validation.custom-formula-input",Ye="data-validation.formula-input",pt="data-validation.list-formula-input",zt="data-validation.checkbox-formula-input",ua=[[Xt,ra],[Ye,ia],[pt,ca],[zt,oa]],pa="LIST_RENDER_MODE_OPTION_INPUT";function Xe(e){var i;const{value:t,onChange:a}=e,n=o.useDependency(o.LocaleService);return h.jsx(b.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:h.jsxs(b.RadioGroup,{value:`${(i=t.renderMode)!=null?i:o.DataValidationRenderMode.CUSTOM}`,onChange:r=>a({...t,renderMode:+r}),children:[h.jsx(b.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),h.jsx(b.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),h.jsx(b.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}Xe.componentKey=pa;const ha="DATE_SHOW_TIME_OPTION";function ze(e){var i;const{value:t,onChange:a}=e,n=o.useDependency(o.LocaleService);return h.jsx(b.FormLayout,{children:h.jsx(b.Checkbox,{checked:(i=t.bizInfo)==null?void 0:i.showTime,onChange:r=>{a({...t,bizInfo:{...t.bizInfo,showTime:r}})},children:n.t("dataValidation.showTime.label")})})}ze.componentKey=ha;var ma=Object.defineProperty,fa=Object.getOwnPropertyDescriptor,va=(e,t,a,n)=>{for(var i=n>1?void 0:n?fa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&ma(t,a,i),i},Fe=(e,t)=>(a,n)=>t(a,n,e);const Ke=6;let ht=class{constructor(e,t,a,n,i){this._commandService=e,this._formulaService=t,this._themeService=a,this._renderManagerService=n,this._dataValidationModel=i}_calc(e,t){var u,p,m;const{vt:a,ht:n}=t||{},i=e.endX-e.startX-Ke*2,r=e.endY-e.startY,s=((u=t==null?void 0:t.fs)!=null?u:10)*1.6;let d=0,l=0;switch(a){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(r-s);break;default:l=0+(r-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:d=Ke;break;case o.HorizontalAlign.RIGHT:d=Ke+(i-s);break;default:d=Ke+(i-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((p=t==null?void 0:t.fs)!=null?p:10)*1.6,height:((m=t==null?void 0:t.fs)!=null?m:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var u,p,m,c,S,f,D,V,_;const{formula1:n=E.CHECKBOX_FORMULA_1,formula2:i=E.CHECKBOX_FORMULA_2}=e,r=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=E.getFormulaResult((m=(p=(u=r==null?void 0:r[0])==null?void 0:u.result)==null?void 0:p[0])==null?void 0:m[0]),d=E.getFormulaResult((f=(S=(c=r==null?void 0:r[1])==null?void 0:c.result)==null?void 0:S[0])==null?void 0:f[0]),l=E.isLegalFormulaResult(String(s))&&E.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(n)?E.getFormulaResult((_=(V=(D=r==null?void 0:r[0])==null?void 0:D.result)==null?void 0:V[0])==null?void 0:_[0]):n,formula2:o.isFormulaString(i)?d:i,isFormulaValid:l}}drawWith(e,t){var T,F,x,N;const{style:a,primaryWithCoord:n,unitId:i,subUnitId:r,worksheet:s,row:d,col:l}=t,u=n.isMergedMainCell?n.mergeInfo:n,p=E.getCellValueOrigin(s.getCellRaw(d,l)),m=this._dataValidationModel.getRuleByLocation(i,r,d,l);if(!m)return;const c=this._dataValidationModel.getValidator(m.type);if(!c)return;const S=this._themeService.getCurrentTheme();if(!((T=c.skipDefaultFontRender)!=null&&T.call(c,m,p,{unitId:i,subUnitId:r,row:d,column:l})))return;const f=c.parseFormulaSync(m,i,r),{formula1:D}=f,V=this._calc(u,a),{a:_,d:w}=e.getTransform(),y=U.fixLineWidthByScale(V.left,_),M=U.fixLineWidthByScale(V.top,w),I=U.Transform.create().composeMatrix({left:y,top:M,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),C=u.endX-u.startX,v=u.endY-u.startY;e.save(),e.beginPath(),e.rect(u.startX,u.startY,C,v),e.clip();const O=I.getMatrix();e.transform(O[0],O[1],O[2],O[3],O[4],O[5]);const j=((F=a==null?void 0:a.fs)!=null?F:10)*1.6,k=String(p)===String(D),A=S.hyacinth500;U.CheckboxShape.drawWith(e,{checked:k,width:j,height:j,fill:(N=(x=a==null?void 0:a.cl)==null?void 0:x.rgb)!=null?N:A}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),i=n.top,r=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:u}=e;return l<=d&&l>=s&&u<=r&&u>=i}async onPointerDown(e,t){var f;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:i,worksheet:r,row:s,col:d}=e,l=E.getCellValueOrigin(r.getCellRaw(s,d)),u=this._dataValidationModel.getRuleByLocation(n,i,s,d);if(!u)return;const p=this._dataValidationModel.getValidator(u.type);if(!p||!((f=p.skipDefaultFontRender)!=null&&f.call(p,u,l,{unitId:n,subUnitId:i,row:s,column:d})))return;const{formula1:m,formula2:c}=await this._parseFormula(u,n,i),S={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(l)===E.transformCheckboxValue(String(m))?c:m,p:null}};this._commandService.executeCommand(X.SetRangeValuesCommand.id,S)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(U.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(U.CURSOR_TYPE.DEFAULT)}};ht=va([Fe(0,o.ICommandService),Fe(1,o.Inject(E.DataValidationFormulaService)),Fe(2,o.Inject(o.ThemeService)),Fe(3,o.Inject(U.IRenderManagerService)),Fe(4,o.Inject(E.SheetDataValidationModel))],ht);var ga=Object.defineProperty,Sa=Object.getOwnPropertyDescriptor,_a=(e,t,a,n)=>{for(var i=n>1?void 0:n?Sa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&ga(t,a,i),i},Ia=(e,t)=>(a,n)=>t(a,n,e);let pe=class{constructor(e){L(this,"canvasRender",null);L(this,"dropdown");L(this,"optionsInput");L(this,"formulaInput",pt);this.injector=e}};pe=_a([Ia(0,o.Inject(o.Injector))],pe);class Ca extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CHECKBOX);L(this,"canvasRender",this.injector.createInstance(ht));L(this,"formulaInput",zt)}}class Da extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CUSTOM);L(this,"formulaInput",Xt)}}const ya="data-validation.formula-input";class wa extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DATE);L(this,"formulaInput",ya);L(this,"optionsInput",ze.componentKey);L(this,"dropdown",lt)}}class Va extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DECIMAL);L(this,"formulaInput",Ye)}}const Kt=4,Ea=0,mt=4,qt=4,ft=6,qe=6,De=14;function Ra(e,t){const a=U.FontCache.getTextSize(e,t),n=a.width+Kt*2,{ba:i,bd:r}=a,s=i+r;return{width:n,height:s+Ea*2,ba:i}}function vt(e,t,a,n){const i=De+ft*2,r=a-i,s=n-qe*2,d=e.map(c=>({layout:Ra(c,t),text:c}));let l;const u=[];d.forEach(c=>{const{layout:S}=c,{width:f,height:D}=S;!l||l.width+f+mt>r?(l={width:f,height:D,items:[{...c,left:0}]},u.push(l)):(l.items.push({...c,left:l.width+mt}),l.width=l.width+f+mt)});let p=0,m=0;return u.forEach((c,S)=>{m=Math.max(m,c.width),S===u.length-1?p+=c.height:p+=c.height+qt}),{lines:u,totalHeight:p,contentWidth:r,contentHeight:s,cellAutoHeight:p+qe*2,calcAutoWidth:m+i}}const Ma=8;class ba extends U.Shape{static drawWith(t,a){const{fontString:n,info:i,fill:r,color:s}=a,{layout:d,text:l}=i;t.save(),U.Rect.drawWith(t,{width:d.width,height:d.height,radius:Ma,fill:r||Ie}),t.translateWithPrecision(Kt,d.ba),t.font=n,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var Oa=Object.defineProperty,La=Object.getOwnPropertyDescriptor,Ta=(e,t,a,n)=>{for(var i=n>1?void 0:n?La(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Oa(t,a,i),i},gt=(e,t)=>(a,n)=>t(a,n,e);const Pa=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 St=class{constructor(e,t,a){L(this,"zIndex");L(this,"_dropdownInfoMap",new Map);this._commandService=e,this._renderManagerService=t,this._dataValidationModel=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,i){const r=a-De+4;let s=4;switch(i){case o.VerticalAlign.MIDDLE:s=(n-De)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-De+4;break}e.save(),e.translateWithPrecision(t.startX+r,t.startY+s),e.fillStyle="#565656",e.fill(Pa),e.restore()}drawWith(e,t,a,n){var Z,q;const{primaryWithCoord:i,row:r,col:s,style:d,data:l,subUnitId:u}=t,p=i.isMergedMainCell?i.mergeInfo:i,m=l==null?void 0:l.fontRenderExtension,{leftOffset:c=0,rightOffset:S=0,topOffset:f=0,downOffset:D=0}=m||{},V=this._ensureMap(u),_=this._generateKey(r,s),w=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,r,s);if(!w)return;const y=this._dataValidationModel.getValidator(w.type);if(!y)return;const M={startX:p.startX+c,endX:p.endX-S,startY:p.startY+f,endY:p.endY-D},I=M.endX-M.startX,C=M.endY-M.startY,{cl:v}=d||{},O=(Z=typeof v=="object"?v==null?void 0:v.rgb:v)!=null?Z:"#000",j=U.getFontStyleString(d!=null?d:void 0),{vt:k,ht:A}=d||{},T=k!=null?k:o.VerticalAlign.MIDDLE,F=(q=E.getCellValueOrigin(l))!=null?q:"",x=y.parseCellValue(F),N=y.getListWithColorMap(w),W=vt(x,j,I,C);this._drawDownIcon(e,M,I,C,T),e.save(),e.translateWithPrecision(M.startX,M.startY),e.beginPath(),e.rect(0,0,I-De,C),e.clip(),e.translateWithPrecision(ft,qe);let G=0;switch(T){case o.VerticalAlign.MIDDLE:G=(W.contentHeight-W.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:G=W.contentHeight-W.totalHeight;break}e.translateWithPrecision(0,G),W.lines.forEach((ee,te)=>{e.save();const{width:ae,height:ie,items:le}=ee;let oe=0;switch(A){case o.HorizontalAlign.RIGHT:oe=W.contentWidth-ae;break;case o.HorizontalAlign.CENTER:oe=(W.contentWidth-ae)/2;break}e.translate(oe,te*(ie+qt)),le.forEach(de=>{e.save(),e.translateWithPrecision(de.left,0),ba.drawWith(e,{...j,info:de,color:O,fill:N[de.text]}),e.restore()}),e.restore()}),e.restore(),V.set(_,{left:M.startX,top:M.startY,width:W.contentWidth+ft+De,height:W.contentHeight+qe*2})}calcCellAutoHeight(e){var I;const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:u=0,downOffset:p=0}=s||{},m=t.isMergedMainCell?t.mergeInfo:t,c={startX:m.startX+d,endX:m.endX-l,startY:m.startY+u,endY:m.endY-p},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!S)return;const f=this._dataValidationModel.getValidator(S.type);if(!f)return;const D=c.endX-c.startX,V=c.endY-c.startY,_=(I=E.getCellValueOrigin(n))!=null?I:"",w=f.parseCellValue(_),y=U.getFontStyleString(a!=null?a:void 0);return vt(w,y,D,V).cellAutoHeight}calcCellAutoWidth(e){var I;const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:u=0,downOffset:p=0}=s||{},m=t.isMergedMainCell?t.mergeInfo:t,c={startX:m.startX+d,endX:m.endX-l,startY:m.startY+u,endY:m.endY-p},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!S)return;const f=this._dataValidationModel.getValidator(S.type);if(!f)return;const D=c.endX-c.startX,V=c.endY-c.startY,_=(I=E.getCellValueOrigin(n))!=null?I:"",w=f.parseCellValue(_),y=U.getFontStyleString(a!=null?a:void 0);return vt(w,y,D,V).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:i}=n,{x:r}=e;return r>=i-De&&r<=i}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=e,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Ne.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(U.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(U.CURSOR_TYPE.DEFAULT)}};St=Ta([gt(0,o.ICommandService),gt(1,o.Inject(U.IRenderManagerService)),gt(2,o.Inject(E.SheetDataValidationModel))],St);class ja extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST_MULTIPLE);L(this,"canvasRender",this.injector.createInstance(St));L(this,"dropdown",We)}}var Aa=Object.defineProperty,Fa=Object.getOwnPropertyDescriptor,xa=(e,t,a,n)=>{for(var i=n>1?void 0:n?Fa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Aa(t,a,i),i},Ge=(e,t)=>(a,n)=>t(a,n,e);const ye=4,Ze=4,ce=14,he=6,Oe=4,_t=8,Na="#565656",Gt=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function Ua(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:o.BooleanNumber.FALSE,bl:o.BooleanNumber.FALSE,ul:{s:o.BooleanNumber.FALSE},st:{s:o.BooleanNumber.FALSE},ol:{s:o.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function Zt(e,t,a){const n=Ua(e,a),i=new o.DocumentDataModel(n),r=new U.DocumentViewModel(i);return{documentSkeleton:U.DocumentSkeleton.create(r,t),docModel:i,docViewModel:r}}function Je(e,t,a){const{documentSkeleton:n,docModel:i,docViewModel:r}=Zt(e,t,a);return{documents:new U.Documents(`DOCUMENTS_${o.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:i,docViewModel:r}}function Jt(e,t,a,n,i,r,s=!0){let d=0;const l=s?Oe:0;switch(i){case o.VerticalAlign.BOTTOM:d=t-n-l;break;case o.VerticalAlign.MIDDLE:d=(t-n)/2;break;default:d=l;break}d=Math.max(Oe,d);let u=0;switch(r){case o.HorizontalAlign.CENTER:u=(e-a)/2;break;case o.HorizontalAlign.RIGHT:u=e-a;break}return u=Math.max(he,u),{paddingLeft:u,paddingTop:d}}let It=class{constructor(e,t,a,n){L(this,"_dropdownInfoMap",new Map);L(this,"zIndex");this._localeService=e,this._commandService=t,this._renderManagerService=a,this._dataValidationModel=n}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,i,r,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,u=a-ce;let p;switch(r){case o.VerticalAlign.MIDDLE:p=(n-Ze)/2;break;case o.VerticalAlign.BOTTOM:p=n-l-i-Oe+(i/2-Ze/2);break;default:p=d+Oe+(i/2-Ze/2);break}e.save(),e.translateWithPrecision(t.startX+u,t.startY+p),e.fillStyle="#565656",e.fill(Gt),e.restore()}drawWith(e,t,a){const{primaryWithCoord:n,row:i,col:r,style:s,data:d,subUnitId:l}=t,u=n.isMergedMainCell?n.mergeInfo:n,p=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,r);if(!p)return;const m=this._dataValidationModel.getValidator(p.type);if(!m)return;const c=d==null?void 0:d.fontRenderExtension,{leftOffset:S=0,rightOffset:f=0,topOffset:D=0,downOffset:V=0}=c||{};if(!p||!m||!m||m.id.indexOf(o.DataValidationType.LIST)!==0||!m.skipDefaultFontRender(p))return;const _={startX:u.startX+S,endX:u.endX-f,startY:u.startY+D,endY:u.endY-V},w=_.endX-_.startX,y=_.endY-_.startY,M=this._ensureMap(l),I=this._generateKey(i,r),C=m.getListWithColor(p),v=E.getCellValueOrigin(d),O=`${v!=null?v:""}`,j=C.find(x=>x.label===O);let{tb:k,vt:A,ht:T,pd:F}=s||{};if(k=k!=null?k:o.WrapStrategy.WRAP,A=A!=null?A:o.VerticalAlign.BOTTOM,T=T!=null?T:o.DEFAULT_STYLES.ht,F=F!=null?F:o.DEFAULT_STYLES.pd,p.renderMode===o.DataValidationRenderMode.ARROW){const{l:x=o.DEFAULT_STYLES.pd.l,t:N=o.DEFAULT_STYLES.pd.t,r:W=o.DEFAULT_STYLES.pd.r,b:G=o.DEFAULT_STYLES.pd.b}=F,Z=w-x-W-ce-4,{documentSkeleton:q,documents:ee,docModel:te}=Je(O,this._localeService,s);k===o.WrapStrategy.WRAP&&te.updateDocumentDataPageSize(Math.max(Z,1)),q.calculate(),q.getActualSize();const ae=U.getDocsSkeletonPageSize(q),{height:ie,width:le}=ae,{paddingTop:oe,paddingLeft:de}=Jt(Z,y-N-G,le,ie,A,T,!0);this._drawDownIcon(e,_,w,y,ie,A,F),e.save(),e.translateWithPrecision(_.startX+x,_.startY+N),e.beginPath(),e.rect(0,0,w-x-W,y-N-G),e.clip(),e.translateWithPrecision(0,oe),e.save(),e.translateWithPrecision(ye,0),e.beginPath(),e.rect(0,0,Z,ie),e.clip(),ee.render(e),e.translateWithPrecision(de,0),e.restore(),e.restore(),M.set(I,{left:_.endX+x+a.rowHeaderWidth-ce,top:_.startY+N+a.columnHeaderHeight,width:ce,height:y-N-G})}else{e.save(),e.translateWithPrecision(_.startX,_.startY),e.beginPath(),e.rect(0,0,w,y),e.clip();const x=w-he*2-ye-ce-4,{documentSkeleton:N,documents:W,docModel:G}=Je(O,this._localeService,s);k===o.WrapStrategy.WRAP&&G.updateDocumentDataPageSize(Math.max(x,1)),N.calculate();const Z=U.getDocsSkeletonPageSize(N),{height:q,width:ee}=Z,{paddingTop:te,paddingLeft:ae}=Jt(x,y,ee,q,A,T);e.translateWithPrecision(he,te);const ie=Math.max(w-he*2,1),le=q;U.Rect.drawWith(e,{width:ie,height:le,fill:(j==null?void 0:j.color)||Ie,radius:_t}),e.save(),e.translateWithPrecision(ye,0),e.beginPath(),e.rect(0,0,x,q),e.clip(),e.translateWithPrecision(ae,0),W.render(e),e.restore(),e.translateWithPrecision(x+ye+4,(q-Ze)/2),e.fillStyle=Na,e.fill(Gt),e.restore(),M.set(I,{left:_.startX+he+a.rowHeaderWidth,top:_.startY+te+a.columnHeaderHeight,width:ie,height:le})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:u=0,topOffset:p=0,downOffset:m=0}=d||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!c||c.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-u,startY:s.startY+p,endY:s.endY-m},f=S.endX-S.startX,D=E.getCellValueOrigin(n),V=`${D!=null?D:""}`;let{tb:_,pd:w}=a||{};const{t:y=o.DEFAULT_STYLES.pd.t,b:M=o.DEFAULT_STYLES.pd.b}=w!=null?w:{};if(_=_!=null?_:o.WrapStrategy.WRAP,c.renderMode===o.DataValidationRenderMode.ARROW){const I=f-ce,{documentSkeleton:C,docModel:v}=Je(V,this._localeService,a);_===o.WrapStrategy.WRAP&&v.updateDocumentDataPageSize(Math.max(I,1)),C.calculate(),C.getActualSize();const O=U.getDocsSkeletonPageSize(C),{height:j}=O;return j+y+M+Oe*2}else{const I=f-he*2-ye-ce,{documentSkeleton:C,docModel:v}=Zt(V,this._localeService,a);_===o.WrapStrategy.WRAP&&v.updateDocumentDataPageSize(Math.max(I,1)),C.calculate();const O=U.getDocsSkeletonPageSize(C),{height:j}=O;return j+Oe*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:u=0,topOffset:p=0,downOffset:m=0}=d||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!c||c.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-u,startY:s.startY+p,endY:s.endY-m},f=S.endX-S.startX,D=E.getCellValueOrigin(n),V=`${D!=null?D:""}`;let{tb:_,pd:w}=a||{};const{l:y=o.DEFAULT_STYLES.pd.l,r:M=o.DEFAULT_STYLES.pd.r}=w!=null?w:{};_=_!=null?_:o.WrapStrategy.WRAP;let I=he*2+ce;switch(c.renderMode){case o.DataValidationRenderMode.ARROW:I=ce+he*2+M+y;break;case o.DataValidationRenderMode.CUSTOM:I=ce+he*2+ye*2+M+y+_t/2+1;break;default:I=ce+he*2+ye*2+M+y+_t/2+1}const C=f-I,{documentSkeleton:v,docModel:O}=Je(V,this._localeService,a);return _===o.WrapStrategy.WRAP&&O.updateDocumentDataPageSize(Math.max(C,1)),v.calculate(),v.getActualSize(),U.getDocsSkeletonPageSize(v).width+I}isHit(e,t){const{subUnitId:a,row:n,col:i}=t,s=this._ensureMap(a).get(this._generateKey(n,i)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,i);if(!d||!s||d.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:u,width:p,height:m}=s,{x:c,y:S}=e;return c>=u&&c<=u+p&&S>=l&&S<=l+m}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=e,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Ne.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(U.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(U.CURSOR_TYPE.DEFAULT)}};It=xa([Ge(0,o.Inject(o.LocaleService)),Ge(1,o.ICommandService),Ge(2,o.Inject(U.IRenderManagerService)),Ge(3,o.Inject(E.SheetDataValidationModel))],It);class Ba extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST);L(this,"canvasRender",this.injector.createInstance(It));L(this,"dropdown",We);L(this,"optionsInput",Xe.componentKey);L(this,"formulaInput",pt)}}class ka extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.TEXT_LENGTH);L(this,"formulaInput",Ye)}}class Wa extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.WHOLE);L(this,"formulaInput",Ye)}}var $a=Object.defineProperty,Ha=Object.getOwnPropertyDescriptor,Ya=(e,t,a,n)=>{for(var i=n>1?void 0:n?Ha(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&$a(t,a,i),i},Ct=(e,t)=>(a,n)=>t(a,n,e);let Le=class extends o.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[Nt,bt],[xe,Fn],[At,yn],[We,Mn],[lt,ln],[Xe.componentKey,Xe],[ze.componentKey,ze],...ua].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Va,Wa,ka,wa,Ca,Ba,ja,Da].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)})}};Le=Ya([Ct(0,o.Inject(o.Injector)),Ct(1,o.Inject(z.ComponentManager)),Ct(2,o.Inject(J.DataValidatorRegistryService))],Le);var Xa=Object.defineProperty,za=Object.getOwnPropertyDescriptor,Ka=(e,t,a,n)=>{for(var i=n>1?void 0:n?za(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Xa(t,a,i),i},Dt=(e,t)=>(a,n)=>t(a,n,e);const qa="SHEET_DATA_VALIDATION_UI_PLUGIN";Y.UniverSheetsDataValidationUIPlugin=(Qe=class extends o.Plugin{constructor(t=Ue,a,n,i){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=o.merge({},Ue,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(rt,s)}onStarting(){[[ue],[ve],[Ae],[Ee],[be],[Me],[Re],[je],[Le]].forEach(t=>{this._injector.add(t)}),[$e,Ne,xt,ot,_e,Ft].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Re),this._injector.get(Me),this._injector.get(je),this._injector.get(Ae),this._injector.get(U.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[He])}onRendered(){this._injector.get(Le),this._injector.get(be)}onSteady(){this._injector.get(Ee)}},L(Qe,"pluginName",qa),L(Qe,"type",o.UniverInstanceType.UNIVER_SHEET),Qe),Y.UniverSheetsDataValidationUIPlugin=Ka([Dt(1,o.Inject(o.Injector)),Dt(2,o.ICommandService),Dt(3,o.IConfigService)],Y.UniverSheetsDataValidationUIPlugin);var Ga=Object.defineProperty,Za=Object.getOwnPropertyDescriptor,Ja=(e,t,a,n)=>{for(var i=n>1?void 0:n?Za(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Ga(t,a,i),i},yt=(e,t)=>(a,n)=>t(a,n,e);const Qa="SHEET_DATA_VALIDATION_UI_PLUGIN";Y.UniverSheetsDataValidationMobileUIPlugin=(et=class extends o.Plugin{constructor(t=Ue,a,n,i){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=o.merge({},Ue,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(rt,s)}onStarting(){[[ue],[ve],[Ae],[Ee],[be],[Me],[Re],[Le]].forEach(t=>{this._injector.add(t)}),[$e,Ne,xt,ot,_e,Ft].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Re),this._injector.get(Me),this._injector.get(U.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[He])}onRendered(){this._injector.get(Le),this._injector.get(be)}onSteady(){this._injector.get(Ee)}},L(et,"pluginName",Qa),L(et,"type",o.UniverInstanceType.UNIVER_SHEET),et),Y.UniverSheetsDataValidationMobileUIPlugin=Ja([yt(1,o.Inject(o.Injector)),yt(2,o.ICommandService),yt(3,o.IConfigService)],Y.UniverSheetsDataValidationMobileUIPlugin),Y.DATE_DROPDOWN_KEY=lt,Y.LIST_DROPDOWN_KEY=We,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
1
+ (function(Y,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):(Y=typeof globalThis<"u"?globalThis:Y||self,u(Y.UniverSheetsDataValidationUi={},Y.React,Y.UniverCore,Y.UniverDesign,Y.UniverEngineRender,Y.UniverSheets,Y.UniverSheetsDataValidation,Y.UniverSheetsNumfmt,Y.UniverSheetsUi,Y.UniverUi,Y.React,Y.UniverDataValidation,Y.UniverDocs,Y.rxjs,Y.UniverEngineFormula,Y.UniverSheetsFormulaUi))})(this,function(Y,u,o,L,B,X,V,Gt,k,z,E,J,qt,re,et,tt){"use strict";var Ga=Object.defineProperty;var qa=(Y,u,o)=>u in Y?Ga(Y,u,{enumerable:!0,configurable:!0,writable:!0,value:o}):Y[u]=o;var O=(Y,u,o)=>qa(Y,typeof u!="symbol"?u+"":u,o);var Je,Qe;var Zt=Object.defineProperty,Jt=Object.getOwnPropertyDescriptor,Qt=(e,t,a,n)=>{for(var i=n>1?void 0:n?Jt(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Zt(t,a,i),i},Pe=(e,t)=>(a,n)=>t(a,n,e);let Re=class extends o.Disposable{constructor(e,t,a,n,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(X.AFTER_CELL_EDIT_ASYNC,{handler:async(e,t,a)=>{var C;const n=await e,{worksheet:i,row:r,col:s,unitId:l,subUnitId:d,workbook:p}=t,h=this._dataValidationModel.getRuleIdByLocation(l,d,r,s),f=h?this._dataValidationModel.getRuleById(l,d,h):void 0;if(!f||f.errorStyle!==o.DataValidationErrorStyle.STOP)return a(Promise.resolve(n));const c=await this._dataValidatorRegistryService.getValidatorItem(f.type);if(!c||await c.validator({value:V.getCellValueOrigin(n),interceptValue:V.getCellValueOrigin((C=t==null?void 0:t.origin)!=null?C:n),row:r,column:s,unitId:l,subUnitId:d,worksheet:i,workbook:p,t:n==null?void 0:n.t},f))return a(Promise.resolve(n));const v=i.getCellRaw(r,s);return this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:c.getRuleFinalError(f,{row:r,col:s,unitId:l,subUnitId:d})},footer:{title:E.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(v))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:E.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")}})}};Re=Qt([Pe(0,o.Inject(X.SheetInterceptorService)),Pe(1,o.Inject(V.SheetDataValidationModel)),Pe(2,o.Inject(J.DataValidatorRegistryService)),Pe(3,z.IDialogService),Pe(4,o.Inject(o.LocaleService))],Re);const Dt={dvDateDropdown:"univer-dv-date-dropdown",dvDateDropdownBtns:"univer-dv-date-dropdown-btns"},en=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function tn(e){var m;const{location:t,hideFn:a}=e,{worksheet:n,row:i,col:r,unitId:s,subUnitId:l,workbook:d}=t,p=o.useDependency(o.ICommandService),h=o.useDependency(Re),f=n.getCell(i,r),c=V.getCellValueOrigin(n.getCellRaw(i,r)),S=en(c),[v,C]=E.useState(S),w=v&&v.isValid()?v:o.dayjs(),g=o.useDependency(o.LocaleService),y=o.useDependency(V.SheetDataValidationModel),D=y.getRuleByLocation(s,l,i,r);if(!D)return null;const b=y.getValidator(D.type);if(!f||!b)return;const _=!!((m=D.bizInfo)!=null&&m.showTime),I=async()=>{var U,j,$;if(!w)return;const A=w.format(_?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),W=(U=o.numfmt.parseDate(A))==null?void 0:U.v,F=d.getStyles().getStyleByCell(f),P=($=(j=F==null?void 0:F.n)==null?void 0:j.pattern)!=null?$:"",N=Gt.getPatternType(P);D.errorStyle!==o.DataValidationErrorStyle.STOP||await b.validator({value:W,unitId:s,subUnitId:l,row:i,column:r,worksheet:n,workbook:d,interceptValue:A.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},D)?(a(),await p.executeCommand(k.SetCellEditVisibleOperation.id,{visible:!1,eventType:B.DeviceInputEventType.Keyboard,unitId:s,keycode:z.KeyCode.ESC}),await p.executeCommand(X.SetRangeValuesCommand.id,{unitId:s,subUnitId:l,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:W,t:2,p:null,f:null,si:null,s:{n:{pattern:_?N==="datetime"?P:"yyyy-MM-dd hh:mm:ss":N==="date"?P:"yyyy-MM-dd"}}}})):h.showReject(b.getRuleFinalError(D,{row:i,col:r,unitId:s,subUnitId:l}))};return u.jsxs("div",{className:Dt.dvDateDropdown,children:[u.jsx(L.DatePanel,{defaultValue:w,pickerValue:w,showTime:_||void 0,onSelect:async T=>{C(T)},onPanelChange:T=>{C(T)},disabledDate:T=>!o.numfmt.parseDate(T.format("YYYY-MM-DD"))}),u.jsx("div",{className:Dt.dvDateDropdownBtns,children:u.jsx(L.Button,{size:"small",type:"primary",onClick:I,disabled:!w.isValid(),children:g.t("dataValidation.alert.ok")})})]})}var se=function(){return se=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},se.apply(this,arguments)},nn=function(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(a[n[i]]=e[n[i]]);return a},ve=E.forwardRef(function(e,t){var a=e.icon,n=e.id,i=e.className,r=e.extend,s=nn(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),d=E.useRef("_".concat(rn()));return yt(a,"".concat(n),{defIds:a.defIds,idSuffix:d.current},se({ref:t,className:l},s),r)});function yt(e,t,a,n,i){return E.createElement(e.tag,se(se({key:t},an(e,a,i)),n),(on(e,a).children||[]).map(function(r,s){return yt(r,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,i)}))}function an(e,t,a){var n=se({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1);var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],l=r[1];typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function on(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?se(se({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?se(se({},i),{attrs:se(se({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function rn(){return Math.random().toString(36).substring(2,8)}ve.displayName="UniverIcon";var sn={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=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"check-mark-single",ref:t,icon:sn}))});wt.displayName="CheckMarkSingle";var ln={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=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"data-validation-single",ref:t,icon:ln}))});Vt.displayName="DataValidationSingle";var dn={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"}}]},nt=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"delete-single",ref:t,icon:dn}))});nt.displayName="DeleteSingle";var cn={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=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"increase-single",ref:t,icon:cn}))});Et.displayName="IncreaseSingle";var un={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=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"more-down-single",ref:t,icon:un}))});Mt.displayName="MoreDownSingle";var pn={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=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"more-up-single",ref:t,icon:pn}))});bt.displayName="MoreUpSingle";var hn={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=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"sequence-single",ref:t,icon:hn}))});Lt.displayName="SequenceSingle";var fn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,mn=(e,t,a,n)=>{for(var i=n>1?void 0:n?vn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&fn(t,a,i),i},Tt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends o.Disposable{constructor(t,a){super();O(this,"_open$",new re.BehaviorSubject(!1));O(this,"open$",this._open$.pipe(re.distinctUntilChanged()));O(this,"_activeRule");O(this,"_activeRule$",new re.BehaviorSubject(void 0));O(this,"activeRule$",this._activeRule$.asObservable());O(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(re.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===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=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ue=mn([Tt(0,o.IUniverInstanceService),Tt(1,z.ISidebarService)],ue);function gn(){const e=o.useDependency(me),t=z.useObservable(e.activeDropdown$,e.activeDropdown),a=o.useDependency(z.ComponentManager);if(!t)return null;const{location:n,componentKey:i}=t,r=a.get(i),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!r)return null;const l=()=>{e.hideDropdown()};return u.jsx(r,{location:n,hideFn:l},s)}const Ot="sheet.ui.dropdown";var Sn=Object.defineProperty,_n=Object.getOwnPropertyDescriptor,In=(e,t,a,n)=>{for(var i=n>1?void 0:n?_n(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Sn(t,a,i),i},Se=(e,t)=>(a,n)=>t(a,n,e);let me=class extends o.Disposable{constructor(t,a,n,i,r,s,l){super();O(this,"_activeDropdown");O(this,"_activeDropdown$",new re.Subject);O(this,"_currentPopup",null);O(this,"activeDropdown$",this._activeDropdown$.asObservable());O(this,"_zenVisible",!1);this._canvasPopupManagerService=t,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=i,this._renderManagerService=r,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,i){const r=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!r)return;const s=a?r.getSheetBySheetId(a):r.getActiveSheet();if(!s)return;const l=this._dataValidationModel.getRuleByLocation(r.getUnitId(),s.getSheetId(),n,i);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:i,col:r,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(o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),p=this._canvasPopupManagerService.attachPopupToCell(i,r,{componentKey:Ot,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[d==null?void 0:d.engine.getCanvasElement()].filter(Boolean)},s,l);if(!p)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const h=new o.DisposableCollection;h.add(p),h.add({dispose:()=>{var f,c;(c=(f=this._activeDropdown)==null?void 0:f.onHide)==null||c.call(f)}}),this._currentPopup=h}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,a,n,i,r){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const l=s.getSheetBySheetId(a);if(!l)return;const d=this._dataValidationModel.getRuleByLocation(s.getUnitId(),l.getSheetId(),n,i);if(!d)return;const p=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!p||!p.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:l,row:n,col:i,unitId:t,subUnitId:a},componentKey:p.dropdown,onHide:r})}};me=In([Se(0,o.Inject(k.SheetCanvasPopManagerService)),Se(1,o.IUniverInstanceService),Se(2,o.Inject(J.DataValidatorRegistryService)),Se(3,z.IZenZoneService),Se(4,B.IRenderManagerService),Se(5,o.Inject(V.SheetDataValidationModel)),Se(6,o.Inject(X.SheetsSelectionsService))],me);const Ne="DataValidationPanel",_e={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,i=e.get(ue),r=e.get(J.DataValidationModel),s=e.get(o.IUniverInstanceService),l=e.get(z.ISidebarService),d=X.getSheetCommandTarget(s);if(!d)return!1;const{unitId:p,subUnitId:h}=d,f=a?r.getRuleById(p,h,a):void 0;i.open(),i.setActiveRule(f&&{unitId:p,subUnitId:h,rule:f});const c=l.open({id:Ne,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Ne},width:312,onClose:()=>i.close()});return i.setCloseDisposable(c),!0}},at={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},Pt={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),a=e.get(ue);return a.open(),a.isOpen?t.executeCommand(at.id):t.executeCommand(_e.id),!0}},Ue={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(me),{unitId:n,subUnitId:i,row:r,column:s}=t,l=a.activeDropdown,d=l==null?void 0:l.location;return d&&d.unitId===n&&d.subUnitId===i&&d.row===r&&d.col===s||a.showDataValidationDropdown(n,i,r,s),!0}},Rt={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(me).hideDropdown(),!0):!1}},Ie="#ECECEC",it="sheets-data-validation-ui.config",je={},fe={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"},Cn=e=>{var _,I;const{value:t,onChange:a,multiple:n,options:i,title:r,onEdit:s,style:l,filter:d,location:p}=e,h=o.useDependency(o.LocaleService),f=o.useDependency(o.IConfigService),c=d==null?void 0:d.toLowerCase(),{row:S,col:v,unitId:C,subUnitId:w}=p,g=i.filter(m=>c?m.label.toLowerCase().includes(c):!0),y=(I=(_=f.getConfig(it))==null?void 0:_.showEditOnDropdown)!=null?I:!0,D=o.useDependency(X.SheetPermissionCheckController),b=E.useMemo(()=>D.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission]},[{startColumn:v,startRow:S,endColumn:v,endRow:S}],C,w),[D,v,S,C,w]);return u.jsxs("div",{className:fe.dvListDropdown,style:l,children:[u.jsx("div",{className:fe.dvListDropdownTitle,children:r}),u.jsx("div",{className:fe.dvListDropdownList,children:u.jsx(L.Scrollbar,{children:u.jsx("div",{className:fe.dvListDropdownListContainer,children:g.map((m,T)=>{const A=t.indexOf(m.value)>-1,W=()=>{let P;A?P=new Set(t.filter(U=>U!==m.value)):P=new Set(n?[...t,m.value]:[m.value]);const N=[];i.forEach(U=>{P.has(U.value)&&N.push(U.value)}),a(N)},F=m.label.toLocaleLowerCase().indexOf(c);return u.jsxs("div",{className:fe.dvListDropdownItemContainer,onClick:W,children:[u.jsx("div",{className:fe.dvListDropdownItem,style:{background:m.color||Ie},children:c&&m.label.toLowerCase().includes(c)?u.jsxs(u.Fragment,{children:[u.jsx("span",{children:m.label.substring(0,F)}),u.jsx("span",{style:{fontWeight:"bold"},children:m.label.substring(F,F+c.length)}),u.jsx("span",{children:m.label.substring(F+c.length)})]}):m.label}),u.jsx("div",{className:fe.dvListDropdownSelectedIcon,children:A?u.jsx(wt,{}):null})]},T)})})},d)}),y&&b?u.jsxs(u.Fragment,{children:[u.jsx("div",{className:fe.dvListDropdownSplit}),u.jsx("div",{className:fe.dvListDropdownEdit,children:u.jsx("a",{onClick:s,children:h.t("dataValidation.list.edit")})})]}):null]})};function Dn(e){var j,$,q,Z;const{location:t,hideFn:a}=e,{worksheet:n,row:i,col:r,unitId:s,subUnitId:l}=t,d=o.useDependency(J.DataValidationModel),[p,h]=E.useState(""),f=o.useDependency(o.ICommandService),c=o.useDependency(o.LocaleService),[S,v]=E.useState(""),C=o.useDependency(k.IEditorBridgeService),w=o.useDependency(o.IUniverInstanceService),g=E.useMemo(()=>d.ruleChange$.pipe(re.debounceTime(16)),[]),y=o.useDependency(V.SheetDataValidationModel);z.useObservable(g);const D=z.RectPopup.useContext(),b=(($=(j=D.current)==null?void 0:j.right)!=null?$:0)-((Z=(q=D.current)==null?void 0:q.left)!=null?Z:0);if(E.useEffect(()=>{const G=f.onCommandExecuted(ee=>{var te,ae;if(ee.id===qt.RichTextEditingMutation.id){const ie=ee.params,{unitId:le}=ie,oe=w.getUnit(le,o.UniverInstanceType.UNIVER_DOC);if(!oe||!C.isVisible().visible)return;const de=o.BuildTextUtils.transform.getPlainText((ae=(te=oe.getSnapshot().body)==null?void 0:te.dataStream)!=null?ae:"");h(de)}});return()=>{G.dispose()}},[f,C,w]),!n)return null;const _=y.getRuleByLocation(s,l,i,r);if(!_)return null;const I=y.getValidator(_.type);if(!I)return null;const m=n.getCell(i,r),T=(_==null?void 0:_.renderMode)===o.DataValidationRenderMode.CUSTOM||(_==null?void 0:_.renderMode)===void 0;if(!m||!_||!I||I.id.indexOf(o.DataValidationType.LIST)!==0)return;const A=_.type===o.DataValidationType.LIST_MULTIPLE,W=I.getListWithColor(_,s,l),F=S||V.getDataValidationCellValue(n.getCellRaw(i,r)),P=V.deserializeListOptions(F),N=()=>{f.executeCommand(_e.id,{ruleId:_.uid}),a()},U=W.map(G=>({label:G.label,value:G.label,color:T||G.color?G.color:"transparent"}));return u.jsx(Cn,{style:{minWidth:b,maxWidth:Math.max(b,200)},title:A?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:P,multiple:A,onChange:async G=>{const ee=V.serializeListOptions(G),te={unitId:s,subUnitId:l,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:ee,p:null,f:null,si:null}};C.isVisible()&&C.changeVisible({visible:!1,keycode:z.KeyCode.ESC,eventType:B.DeviceInputEventType.Keyboard,unitId:s}),v(ee),A||a(),C.isVisible().visible&&await f.executeCommand(k.SetCellEditVisibleOperation.id,{visible:!1,eventType:B.DeviceInputEventType.Keyboard,unitId:s,keycode:z.KeyCode.ESC}),f.executeCommand(X.SetRangeValuesCommand.id,te)},options:U,onEdit:N,filter:p,location:t})}const ot={dataValidationOptionsButton:"univer-data-validation-options-button",dataValidationOptionsButtonIcon:"univer-data-validation-options-button-icon"};function yn(e){var p;const t=o.useDependency(o.LocaleService),a=o.useDependency(z.ComponentManager),{value:n,onChange:i,extraComponent:r}=e,[s,l]=E.useState(!1),d=r?a.get(r):null;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:ot.dataValidationOptionsButton,onClick:()=>l(!s),children:[t.t("dataValidation.panel.options"),s?u.jsx(bt,{className:ot.dataValidationOptionsButtonIcon}):u.jsx(Mt,{className:ot.dataValidationOptionsButtonIcon})]}),s&&u.jsxs(u.Fragment,{children:[d?u.jsx(d,{value:n,onChange:i}):null,u.jsx(L.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:u.jsxs(L.RadioGroup,{value:`${(p=n.errorStyle)!=null?p:o.DataValidationErrorStyle.WARNING}`,onChange:h=>i({...n,errorStyle:+h}),children:[u.jsx(L.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),u.jsx(L.Radio,{value:`${o.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:()=>i({...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:h=>i({...n,error:h})})}):null]})]})}const we={dataValidationDetail:"univer-data-validation-detail",dataValidationDetailFormItem:"univer-data-validation-detail-form-item",dataValidationDetailButtons:"univer-data-validation-detail-buttons",dataValidationDetailButton:"univer-data-validation-detail-button"},wn=e=>o.debounce(async(t,a,n,i)=>{const r=await e.executeCommand(t,a,n);i==null||i(r)},1e3);function Vn(e,t,a){var n,i,r,s;return t?((i=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:i.getSheetId())||"":((s=(r=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function En(){var de;const[e,t]=E.useState(0),a=o.useDependency(ue),n=z.useObservable(a.activeRule$,a.activeRule),{unitId:i,subUnitId:r,rule:s}=n||{},l=s.uid,d=o.useDependency(J.DataValidatorRegistryService),p=o.useDependency(o.IUniverInstanceService),h=o.useDependency(z.ComponentManager),f=o.useDependency(o.ICommandService),c=o.useDependency(J.DataValidationModel),S=o.useDependency(o.LocaleService),[v,C]=E.useState(s),w=d.getValidatorItem(v.type),[g,y]=E.useState(!1),D=d.getValidatorsByScope(J.DataValidatorRegistryScope.SHEET),[b,_]=E.useState(()=>v.ranges.map(R=>({unitId:"",sheetId:"",range:R}))),I=E.useMemo(()=>wn(f),[f]),[m,T]=E.useState(!1),A=E.useRef({}),[W,F]=E.useState(!1),P=o.useDependency(X.SheetsSelectionsService);if(E.useEffect(()=>()=>{const R=P.getCurrentLastSelection();R&&P.setSelections([R])},[P]),E.useEffect(()=>{f.onCommandExecuted(R=>{(R.id===o.UndoCommand.id||R.id===o.RedoCommand.id)&&setTimeout(()=>{const M=c.getRuleById(i,r,l);t(H=>H+1),M&&(C(M),_(M.ranges.map(H=>({unitId:"",sheetId:"",range:H}))))},20)})},[f,c,l,r,i]),!w)return null;const N=w.operators,U=w.operatorNames,j=v.operator?J.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,$=()=>{!v.ranges.length||m||(w.validatorFormula(v,i,r).success?a.setActiveRule(null):y(!0))},q=z.useEvent(R=>{const M=R.split(",").filter(Boolean).map(et.deserializeRangeWithSheet).map(K=>{const ge=K.sheetName;if(ge){const Ka=Vn(p,K.unitId,ge);return{...K,sheetId:Ka}}return{...K,sheetId:""}});if(o.isUnitRangesEqual(M,b))return;_(M);const H=M.filter(K=>(!K.unitId||K.unitId===i)&&(!K.sheetId||K.sheetId===r)).map(K=>K.range);if(C({...v,ranges:H}),H.length===0)return;const x={unitId:i,subUnitId:r,ruleId:l,ranges:H};I(V.UpdateSheetDataValidationRangeCommand.id,x)}),Z=R=>{if(o.shallowEqual(R,J.getRuleSetting(v)))return;C({...v,...R});const M={unitId:i,subUnitId:r,ruleId:l,setting:R};I(V.UpdateSheetDataValidationSettingCommand.id,M,void 0)},G=async()=>{await f.executeCommand(V.RemoveSheetDataValidationCommand.id,{ruleId:l,unitId:i,subUnitId:r}),a.setActiveRule(null)},ee={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},te=R=>{const M=d.getValidatorItem(R);if(!M)return;const H=M.operators,x=c.getRuleById(i,r,l),K=R===(x==null?void 0:x.type)||R.includes("list")&&(x!=null&&x.type.includes("list"))?{...x,type:R}:{...v,type:R,operator:H[0],formula1:void 0,formula2:void 0};C(K),f.executeCommand(V.UpdateSheetDataValidationSettingCommand.id,{unitId:i,subUnitId:r,ruleId:v.uid,setting:J.getRuleSetting(K)})},ae=h.get(w.formulaInput),ie=E.useMemo(()=>b.map(R=>et.serializeRange(R.range)).join(","),[]),le=J.getRuleOptions(v),oe=R=>{o.shallowEqual(R,J.getRuleOptions(v))||(C({...v,...R}),I(V.UpdateSheetDataValidationOptionsCommand.id,{unitId:i,subUnitId:r,ruleId:l,options:R}))};return z.useSidebarClick(R=>{var H;const M=(H=A.current)==null?void 0:H.handleOutClick;M&&M(R,()=>F(!1))}),u.jsxs("div",{className:we.dataValidationDetail,children:[u.jsx(L.FormLayout,{label:S.t("dataValidation.panel.range"),error:!v.ranges.length||m?S.t("dataValidation.panel.rangeError"):"",children:u.jsx(tt.RangeSelector,{unitId:i,subUnitId:r,initValue:ie,onChange:q,onFocus:()=>F(!0),isFocus:W,actions:A.current,onVerify:R=>T(!R)})}),u.jsx(L.FormLayout,{label:S.t("dataValidation.panel.type"),children:u.jsx(L.Select,{options:D==null?void 0:D.map(R=>({label:S.t(R.title),value:R.id})),value:v.type,onChange:te,className:we.dataValidationDetailFormItem})}),N!=null&&N.length?u.jsx(L.FormLayout,{label:S.t("dataValidation.panel.operator"),children:u.jsx(L.Select,{options:N.map((R,M)=>({value:`${R}`,label:U[M]})),value:`${v.operator}`,onChange:R=>{Z({...ee,operator:R})},className:we.dataValidationDetailFormItem})}):null,ae?u.jsx(ae,{isTwoFormula:j,value:{formula1:v.formula1,formula2:v.formula2},onChange:R=>{Z({...ee,...R})},showError:g,validResult:w.validatorFormula(v,i,r),unitId:i,subUnitId:r,ruleId:l},e+v.type):null,u.jsx(L.FormLayout,{children:u.jsx(L.Checkbox,{checked:(de=v.allowBlank)!=null?de:!0,onChange:()=>{var R;return Z({...ee,allowBlank:!((R=v.allowBlank)==null||R)})},children:S.t("dataValidation.panel.allowBlank")})}),u.jsx(yn,{value:le,onChange:oe,extraComponent:w.optionsInput}),u.jsxs("div",{className:we.dataValidationDetailButtons,children:[u.jsx(L.Button,{className:we.dataValidationDetailButton,onClick:G,children:S.t("dataValidation.panel.removeRule")}),u.jsx(L.Button,{className:we.dataValidationDetailButton,type:"primary",onClick:$,children:S.t("dataValidation.panel.done")})]})]})}const Be={dataValidationItemContainer:"univer-data-validation-item-container",dataValidationItemTitle:"univer-data-validation-item-title",dataValidationItemContent:"univer-data-validation-item-content",dataValidationItemIcon:"univer-data-validation-item-icon"},Mn=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:i,disable:r}=e,s=o.useDependency(J.DataValidatorRegistryService),l=o.useDependency(o.ICommandService),d=o.useDependency(k.IMarkSelectionService),p=s.getValidatorItem(t.type),h=E.useRef(void 0),[f,c]=E.useState(!1),S=v=>{l.executeCommand(V.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:i}),v.stopPropagation()};return E.useEffect(()=>()=>{var v;h.current&&((v=h.current)==null||v.forEach(C=>{C&&d.removeShape(C)}))},[d]),u.jsxs("div",{className:Be.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{r||(c(!0),h.current=t.ranges.map(v=>d.addShape({range:v,style:{fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:null})))},onMouseLeave:()=>{var v;c(!1),(v=h.current)==null||v.forEach(C=>{C&&d.removeShape(C)}),h.current=void 0},children:[u.jsx("div",{className:Be.dataValidationItemTitle,children:p==null?void 0:p.generateRuleName(t)}),u.jsx("div",{className:Be.dataValidationItemContent,children:t.ranges.map(v=>et.serializeRange(v)).join(",")}),f?u.jsx("div",{className:Be.dataValidationItemIcon,onClick:S,children:u.jsx(nt,{})}):null]})},ke={dataValidationList:"univer-data-validation-list",dataValidationListButtons:"univer-data-validation-list-buttons",dataValidationListButton:"univer-data-validation-list-button"};function bn(){const e=o.useDependency(o.IUniverInstanceService),t=z.useObservable(()=>e.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return t?u.jsx(Ln,{workbook:t}):null}function Ln(e){const t=o.useDependency(V.SheetDataValidationModel),a=o.useDependency(o.IUniverInstanceService),n=o.useDependency(o.ICommandService),i=o.useDependency(o.Injector),r=o.useDependency(ue),s=o.useDependency(o.LocaleService),[l,d]=E.useState([]),{workbook:p}=e,h=z.useObservable(p.activeSheet$,void 0,!0),f=p.getUnitId(),c=h==null?void 0:h.getSheetId();E.useEffect(()=>{d(t.getRules(f,c));const y=t.ruleChange$.subscribe(D=>{D.unitId===f&&D.subUnitId===c&&d(t.getRules(f,c))});return()=>{y.unsubscribe()}},[f,c,t]);const S=async()=>{const y=V.createDefaultNewRule(i),D={unitId:f,subUnitId:c,rule:y};await n.executeCommand(V.AddSheetDataValidationCommand.id,D),r.setActiveRule({unitId:f,subUnitId:c,rule:y})},v=()=>{n.executeCommand(V.RemoveSheetAllDataValidationCommand.id,{unitId:f,subUnitId:c})},w=(y=>{const D=a.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),b=D.getActiveSheet(),_=D.getUnitId(),I=b.getSheetId();return y.map(T=>X.checkRangesEditablePermission(i,_,I,T.ranges)?{...T}:{...T,disable:!0})})(l),g=w==null?void 0:w.some(y=>y.disable);return u.jsxs("div",{className:ke.dataValidationList,children:[w==null?void 0:w.map(y=>{var D;return u.jsx(Mn,{unitId:f,subUnitId:c,onClick:()=>{y.disable||r.setActiveRule({unitId:f,subUnitId:c,rule:y})},rule:y,disable:(D=y.disable)!=null?D:!1},y.uid)}),u.jsxs("div",{className:ke.dataValidationListButtons,children:[l.length&&!g?u.jsx(L.Button,{className:ke.dataValidationListButton,onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,u.jsx(L.Button,{className:ke.dataValidationListButton,type:"primary",onClick:S,children:s.t("dataValidation.panel.add")})]})]})}const Tn=()=>{const e=o.useDependency(ue),t=z.useObservable(e.activeRule$,e.activeRule);return t?u.jsx(En,{},t.rule.uid):u.jsx(bn,{})},We="data-validation.list.dropdown",rt="data-validation.date.dropdown",$e={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),a=X.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:i}=a,r=V.createDefaultNewRule(e),s=e.get(o.ICommandService),l=n.getUnitId(),d=i.getSheetId(),p={rule:r,unitId:l,subUnitId:d};return s.syncExecuteCommand(V.AddSheetDataValidationCommand.id,p)?(s.syncExecuteCommand(_e.id,{ruleId:r.uid,isAdd:!0}),!0):!1}};var On=Object.defineProperty,Pn=Object.getOwnPropertyDescriptor,Rn=(e,t,a,n)=>{for(var i=n>1?void 0:n?Pn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&On(t,a,i),i},Ve=(e,t)=>(a,n)=>t(a,n,e);const Ce="SHEET_DATA_VALIDATION_ALERT";let Ae=class extends o.Disposable{constructor(e,t,a,n,i,r){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=i,this._dataValidationModel=r,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(re.debounceTime(100)).subscribe(e=>{var t;if(e){const a=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),n=a.getSheetBySheetId(e.location.subUnitId);if(!n)return;const i=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!i){this._cellAlertManagerService.removeAlert(Ce);return}if(this._dataValidationModel.validator(i,{...e.location,workbook:a,worksheet:n})===o.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(i.type);if(!d){this._cellAlertManagerService.removeAlert(Ce);return}this._cellAlertManagerService.showAlert({type:k.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:d==null?void 0:d.getRuleFinalError(i,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)}))}};Ae=Rn([Ve(0,o.Inject(k.HoverManagerService)),Ve(1,o.Inject(k.CellAlertManagerService)),Ve(2,o.IUniverInstanceService),Ve(3,o.Inject(o.LocaleService)),Ve(4,z.IZenZoneService),Ve(5,o.Inject(V.SheetDataValidationModel))],Ae);var An=Object.defineProperty,Fn=Object.getOwnPropertyDescriptor,Nn=(e,t,a,n)=>{for(var i=n>1?void 0:n?Fn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&An(t,a,i),i},st=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends o.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,i)=>{const{source:r,target:s,unitId:l,subUnitId:d}=n,p=this._sheetDataValidationModel.getRuleObjectMatrix(l,d).clone(),h=k.virtualizeDiscreteRanges([r,s]),[f,c]=h.ranges,{mapFunc:S}=h,v={row:f.startRow,col:f.startColumn},C=k.getAutoFillRepeatRange(f,c),w=new o.ObjectMatrix,g=new Set;C.forEach(I=>{const m=I.repeatStartCell,T=I.relativeRange,A={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},W={startRow:m.row,startColumn:m.col,endColumn:m.col,endRow:m.row};o.Range.foreach(T,(F,P)=>{const N=o.Rectangle.getPositionRange({startRow:F,startColumn:P,endColumn:P,endRow:F},A),{row:U,col:j}=S(N.startRow,N.startColumn),$=this._sheetDataValidationModel.getRuleIdByLocation(l,d,U,j)||"",q=o.Rectangle.getPositionRange({startRow:F,startColumn:P,endColumn:P,endRow:F},W),{row:Z,col:G}=S(q.startRow,q.startColumn);w.setValue(Z,G,$),g.add($)})});const y=Array.from(g).map(I=>({id:I,ranges:o.queryObjectMatrix(w,m=>m===I)}));p.addRangeRules(y);const D=p.diff(this._sheetDataValidationModel.getRules(l,d)),{redoMutations:b,undoMutations:_}=V.getDataValidationDiffMutations(l,d,D,this._injector,"patched",i===k.APPLY_TYPE.ONLY_FORMAT);return{undos:_,redos:b}},a={id:V.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:i,unitId:r,subUnitId:s}=n;for(const l of i.rows)for(const d of i.cols){const p=this._sheetDataValidationModel.getRuleByLocation(r,s,l,d);if(p&&p.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(k.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,i,r)=>r===k.APPLY_TYPE.COPY||r===k.APPLY_TYPE.ONLY_FORMAT||r===k.APPLY_TYPE.SERIES?t(n,r):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};Ee=Nn([st(0,k.IAutoFillService),st(1,o.Inject(V.SheetDataValidationModel)),st(2,o.Inject(o.Injector))],Ee);var Un=Object.defineProperty,jn=Object.getOwnPropertyDescriptor,Bn=(e,t,a,n)=>{for(var i=n>1?void 0:n?jn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Un(t,a,i),i},lt=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends o.Disposable{constructor(t,a,n){super();O(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:V.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,i)=>{const{copyType:r=k.COPY_TYPE.COPY,pasteType:s}=i,{range:l}=t||{},{range:d,unitId:p,subUnitId:h}=a;return this._generateMutations(d,{copyType:r,pasteType:s,copyRange:l,unitId:p,subUnitId:h})}})}_collect(t,a,n){const i=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:i};const r=this._injector.invoke(d=>k.rangeToDiscreteRange(n,d,t,a));if(!r)return;const{rows:s,cols:l}=r;s.forEach((d,p)=>{l.forEach((h,f)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(t,a,d,h);i.setValue(p,f,c!=null?c:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===k.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([k.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,k.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,k.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,k.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:i,subUnitId:r}=this._copyInfo;if(a.unitId!==i||r!==a.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),l=new o.ObjectMatrix,d=new Set,{ranges:[p,h],mapFunc:f}=k.virtualizeDiscreteRanges([a.copyRange,t]),c=k.getRepeatRange(p,h,!0),S=new Map;c.forEach(({startRange:g})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((D,b,_)=>{const I=o.Rectangle.getPositionRange({startRow:D,endRow:D,startColumn:b,endColumn:b},g),m=`${r}-${_}`,T=this._sheetDataValidationModel.getRuleById(i,r,_);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,m)&&T&&S.set(m,{...T,uid:m});const{row:A,col:W}=f(I.startRow,I.startColumn);d.add(m),l.setValue(A,W,m)})});const v=Array.from(d).map(g=>({id:g,ranges:o.queryObjectMatrix(l,y=>y===g)}));s.addRangeRules(v);const{redoMutations:C,undoMutations:w}=V.getDataValidationDiffMutations(a.unitId,a.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),S.values()),this._injector,"patched",!1);return{redos:C,undos:w}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(i,r).clone(),l=new o.ObjectMatrix,d=new Set,{ranges:[p,h],mapFunc:f}=k.virtualizeDiscreteRanges([a.copyRange,t]);k.getRepeatRange(p,h,!0).forEach(({startRange:w})=>{var g;(g=this._copyInfo)==null||g.matrix.forValue((y,D,b)=>{const _=o.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:D,endColumn:D},w),{row:I,col:m}=f(_.startRow,_.startColumn);l.setValue(I,m,b),d.add(b)})});const S=Array.from(d).map(w=>({id:w,ranges:o.queryObjectMatrix(l,g=>g===w)}));s.addRangeRules(S);const{redoMutations:v,undoMutations:C}=V.getDataValidationDiffMutations(i,r,s.diff(this._sheetDataValidationModel.getRules(i,r)),this._injector,"patched",!1);return{redos:v,undos:C}}}};Me=Bn([lt(0,k.ISheetClipboardService),lt(1,o.Inject(V.SheetDataValidationModel)),lt(2,o.Inject(o.Injector))],Me);var kn=Object.defineProperty,Wn=Object.getOwnPropertyDescriptor,$n=(e,t,a,n)=>{for(var i=n>1?void 0:n?Wn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&kn(t,a,i),i},dt=(e,t)=>(a,n)=>t(a,n,e);let be=class extends o.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===V.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===V.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")))}))}};be=$n([dt(0,o.Inject(o.LocaleService)),dt(1,o.ICommandService),dt(2,o.Inject(X.SheetPermissionCheckController))],be);const At="data-validation-single",Ft="sheet.menu.data-validation";function Hn(e){return{id:Ft,type:z.MenuItemType.SUBITEMS,icon:At,tooltip:"dataValidation.title",hidden$:z.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:k.getCurrentRangeDisable$(e,{workbookTypes:[X.WorkbookEditablePermission],worksheetTypes:[X.WorksheetSetCellStylePermission,X.WorksheetEditPermission],rangeTypes:[X.RangeProtectionPermissionEditPoint]})}}function Yn(e){return{id:_e.id,title:"dataValidation.panel.title",type:z.MenuItemType.BUTTON}}function xn(e){return{id:$e.id,title:"dataValidation.panel.add",type:z.MenuItemType.BUTTON}}const Xn={[z.RibbonStartGroup.FORMULAS_INSERT]:{[Ft]:{order:9,menuItemFactory:Hn,[_e.id]:{order:0,menuItemFactory:Yn},[$e.id]:{order:1,menuItemFactory:xn}}}};var zn=Object.defineProperty,Kn=Object.getOwnPropertyDescriptor,Nt=(e,t,a,n)=>{for(var i=n>1?void 0:n?Kn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&zn(t,a,i),i},Q=(e,t)=>(a,n)=>t(a,n,e);const Ut={tr:{size:6,color:"#fe4b4b"}};let Le=class extends o.RxDisposable{constructor(e,t,a,n,i,r,s,l,d,p,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=i,this._dropdownManagerService=r,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=l,this._sheetInterceptorService=d,this._dataValidationCacheService=p,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Xn)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var a;if(!e.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:i,row:r,column:s}=t,l=this._univerInstanceService.getUniverSheetInstance(n);if(!l)return;const d=this._sheetDataValidationModel.getRuleByLocation(n,i,r,s);if(!d)return;const p=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!(p!=null&&p.dropdown))return;const h=l.getActiveSheet();if(!h)return;const f=this._dropdownManagerService.activeDropdown,c=f==null?void 0:f.location;if(c&&c.unitId===n&&c.subUnitId===i&&c.row===r&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:i,row:r,col:s,workbook:l,worksheet:h},componentKey:p.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var g,y,D,b,_;const{row:n,col:i,unitId:r,subUnitId:s,workbook:l,worksheet:d}=t,p=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!p)return a(e);const h=this._sheetDataValidationModel.getRuleById(r,s,p);if(!h)return a(e);const f=(g=this._dataValidationCacheService.getValue(r,s,n,i))!=null?g:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(h.type),S=t.rawData;let v;const C={get value(){var I;return v!==void 0||(v=(I=V.getCellValueOrigin(S))!=null?I:null),v}},w={get value(){var I;return`${(I=C.value)!=null?I:""}`}};return a({...e,markers:{...e==null?void 0:e.markers,...f===o.DataValidationStatus.INVALID?Ut:null},customRender:[...(y=e==null?void 0:e.customRender)!=null?y:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((D=e==null?void 0:e.fontRenderExtension)==null?void 0:D.isSkip)||((b=c==null?void 0:c.skipDefaultFontRender)==null?void 0:b.call(c,h,C.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(h,w.value,{get style(){const I=l.getStyles();return(typeof(e==null?void 0:e.s)=="string"?I.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,i)},interceptorAutoHeight:()=>{var A,W,F,P,N,U;const I=(W=(A=this._renderManagerService.getRenderById(r))==null?void 0:A.with(k.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:W.skeleton;if(!I)return;const m=I.worksheet.getMergedCell(n,i),T={data:e,style:I.getsStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((F=m==null?void 0:m.startRow)!=null?F:n,(P=m==null?void 0:m.startColumn)!=null?P:i),unitId:r,subUnitId:s,row:n,col:i,workbook:l,worksheet:d};return(U=(N=c==null?void 0:c.canvasRender)==null?void 0:N.calcCellAutoHeight)==null?void 0:U.call(N,T)},interceptorAutoWidth:()=>{var A,W,F,P,N,U;const I=(W=(A=this._renderManagerService.getRenderById(r))==null?void 0:A.with(k.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:W.skeleton;if(!I)return;const m=I.worksheet.getMergedCell(n,i),T={data:e,style:I.getsStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((F=m==null?void 0:m.startRow)!=null?F:n,(P=m==null?void 0:m.startColumn)!=null?P:i),unitId:r,subUnitId:s,row:n,col:i,workbook:l,worksheet:d};return(U=(N=c==null?void 0:c.canvasRender)==null?void 0:N.calcCellAutoWidth)==null?void 0:U.call(N,T)},coverable:((_=e==null?void 0:e.coverable)!=null?_:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(re.filter(e=>e.source==="command"),re.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(a=>{var n;(a.rule.type===o.DataValidationType.LIST_MULTIPLE||a.rule.type===o.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};Le=Nt([Q(0,o.ICommandService),Q(1,z.IMenuManagerService),Q(2,B.IRenderManagerService),Q(3,o.IUniverInstanceService),Q(4,o.Inject(k.AutoHeightController)),Q(5,o.Inject(me)),Q(6,o.Inject(V.SheetDataValidationModel)),Q(7,o.Inject(J.DataValidatorRegistryService)),Q(8,o.Inject(X.SheetInterceptorService)),Q(9,o.Inject(V.DataValidationCacheService)),Q(10,o.Optional(k.IEditorBridgeService))],Le);let jt=class extends o.RxDisposable{constructor(e,t,a,n,i,r,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=i,this._sheetDataValidationModel=r,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var w,g,y,D,b;const{row:n,col:i,unitId:r,subUnitId:s,workbook:l,worksheet:d}=t,p=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!p)return a(e);const h=this._sheetDataValidationModel.getRuleById(r,s,p);if(!h)return a(e);const f=(w=this._dataValidationCacheService.getValue(r,s,n,i))!=null?w:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(h.type),S=d.getCellRaw(n,i),v=V.getCellValueOrigin(S),C=`${v!=null?v:""}`;return a({...e,markers:{...e==null?void 0:e.markers,...f===o.DataValidationStatus.INVALID?Ut:null},customRender:[...(g=e==null?void 0:e.customRender)!=null?g:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((D=c==null?void 0:c.skipDefaultFontRender)==null?void 0:D.call(c,h,v,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(h,C,{get style(){const _=l.getStyles();return(typeof(e==null?void 0:e.s)=="string"?_.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,i)},interceptorAutoHeight:()=>{var T,A,W,F,P,N;const _=(A=(T=this._renderManagerService.getRenderById(r))==null?void 0:T.with(k.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:A.skeleton;if(!_)return;const I=_.worksheet.getMergedCell(n,i),m={data:e,style:_.getsStyles().getStyleByCell(e),primaryWithCoord:_.getCellWithCoordByIndex((W=I==null?void 0:I.startRow)!=null?W:n,(F=I==null?void 0:I.startColumn)!=null?F:i),unitId:r,subUnitId:s,row:n,col:i,workbook:l,worksheet:d};return(N=(P=c==null?void 0:c.canvasRender)==null?void 0:P.calcCellAutoHeight)==null?void 0:N.call(P,m)},coverable:((b=e==null?void 0:e.coverable)!=null?b:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(re.filter(e=>e.source==="command"),re.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};jt=Nt([Q(0,o.ICommandService),Q(1,B.IRenderManagerService),Q(2,o.Inject(k.AutoHeightController)),Q(3,o.Inject(J.DataValidatorRegistryService)),Q(4,o.Inject(X.SheetInterceptorService)),Q(5,o.Inject(V.SheetDataValidationModel)),Q(6,o.Inject(V.DataValidationCacheService))],jt);var Gn=Object.defineProperty,qn=Object.getOwnPropertyDescriptor,Zn=(e,t,a,n)=>{for(var i=n>1?void 0:n?qn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Gn(t,a,i),i},Bt=(e,t)=>(a,n)=>t(a,n,e);let He=class extends o.Disposable{constructor(e,t,a){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const a=new Set;t.forEach(i=>{a.add(i.subUnitId)}),a.forEach(i=>{var r;(r=this._sheetSkeletonManagerService.getWorksheetSkeleton(i))==null||r.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};He=Zn([Bt(1,o.Inject(V.SheetDataValidationModel)),Bt(2,o.Inject(k.SheetSkeletonManagerService))],He);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"},Jn=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:i,validResult:r}=e,s=o.useDependency(o.LocaleService),l=i?r==null?void 0:r.formula1:"",d=i?r==null?void 0:r.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:p=>{n==null||n({...a,formula1:p})}})}),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:p=>{n==null||n({...a,formula2:p})}})})]}):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:p=>{n==null||n({formula1:p})}})})};function Qn(e){const{value:t,onChange:a,showError:n,validResult:i}=e,r=o.useDependency(o.LocaleService),s=n?i==null?void 0:i.formula1:"",l=n?i==null?void 0:i.formula2:"",[d,p]=E.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:h=>{h?p(!0):(p(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:r.t("dataValidation.checkbox.tips")})}),d?u.jsx(L.FormLayout,{label:r.t("dataValidation.checkbox.checked"),error:s,children:u.jsx(L.Input,{className:ne.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{a==null||a({...t,formula1:h||void 0})}})}):null,d?u.jsx(L.FormLayout,{label:r.t("dataValidation.checkbox.unchecked"),error:l,children:u.jsx(L.Input,{className:ne.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{a==null||a({...t,formula2:h||void 0})}})}):null]})}function ea(e){var f;const{unitId:t,subUnitId:a,value:n,onChange:i,showError:r,validResult:s}=e,l=r?s==null?void 0:s.formula1:void 0,d=E.useRef({}),[p,h]=E.useState(!1);return z.useSidebarClick(c=>{var v;const S=(v=d.current)==null?void 0:v.handleOutClick;S&&S(c,()=>h(!1))}),u.jsx(tt.FormulaEditor,{initValue:(f=n==null?void 0:n.formula1)!=null?f:"=",unitId:t,subUnitId:a,isFocus:p,onChange:c=>{const S=(c!=null?c:"").trim();S!==(n==null?void 0:n.formula1)&&(i==null||i({...n,formula1:S}))},errorText:l,onFocus:()=>h(!0),actions:d.current,isSupportAcrossSheet:!0})}function kt(e){var t,a,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(a=kt(e[t]))&&(n&&(n+=" "),n+=a)}else for(a in e)e[a]&&(n&&(n+=" "),n+=a);return n}function ta(){for(var e,t,a=0,n="",i=arguments.length;a<i;a++)(e=arguments[a])&&(t=kt(e))&&(n&&(n+=" "),n+=t);return n}const na=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],aa=e=>{const{value:t,onChange:a,disabled:n}=e,[i,r]=E.useState(!1);return u.jsx(L.Select,{disabled:n,open:i,onDropdownVisibleChange:r,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:na.map(s=>u.jsx("div",{onClick:()=>{a(s),r(!1)},className:ne.dataValidationFormulaColorItem,style:{background:s}},s))})})},Wt=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:i,onItemDelete:r}=a;return u.jsxs("div",{className:ne.dataValidationFormulaListItem,style:n,children:[t.isRef?null:u.jsx("div",{className:ta(ne.dataValidationFormulaListItemDrag,"draggableHandle"),children:u.jsx(Lt,{})}),u.jsx(aa,{value:t.color,onChange:s=>{i(t.id,t.label,s)}}),u.jsx(L.Input,{disabled:t.isRef,value:t.label,onChange:s=>{i(t.id,s,t.color)}}),t.isRef?null:u.jsx("div",{className:ne.dataValidationFormulaListItemIcon,children:u.jsx(nt,{onClick:()=>r(t.id)})})]})};function ia(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:i,validResult:r,showError:s,ruleId:l}=e,{formula1:d="",formula2:p=""}=t||{},h=E.useRef(null),[f,c]=E.useState(()=>o.isFormulaString(d)?"1":"0"),[S,v]=E.useState(f==="1"?d:"="),[C,w]=E.useState(f==="1"?d:"="),g=o.useDependency(o.LocaleService),y=o.useDependency(J.DataValidatorRegistryService),D=o.useDependency(J.DataValidationModel),b=o.useDependency(V.DataValidationFormulaController),[_,I]=E.useState(()=>p.split(",")),m=y.getValidatorItem(o.DataValidationType.LIST),[T,A]=E.useState([]),[W,F]=E.useState(""),P=s?r==null?void 0:r.formula1:"",N=E.useMemo(()=>D.ruleChange$.pipe(re.debounceTime(16)),[]),U=z.useObservable(N),j=z.useEvent(a);E.useEffect(()=>{(async()=>{await new Promise(x=>{setTimeout(()=>x(!0),100)});const M=D.getRuleById(n,i,l),H=M==null?void 0:M.formula1;if(o.isFormulaString(H)&&m&&M){const x=await m.getListAsync(M,n,i);A(x)}})()},[D,U,m,l,i,n]),E.useEffect(()=>{o.isFormulaString(d)&&d!==C&&(v(d),w(C))},[C,d]);const[$,q]=E.useState(()=>{const M=f!=="1"?V.deserializeListOptions(d):[],H=p.split(",");return M.map((x,K)=>({label:x,color:H[K]||Ie,isRef:!1,id:o.Tools.generateRandomId(4)}))}),Z=(M,H,x)=>{const K=$.find(ge=>ge.id===M);K&&(K.label=H,K.color=x,q([...$]))},G=M=>{const H=$.findIndex(x=>x.id===M);H!==-1&&($.splice(H,1),q([...$]))},ee=p.split(","),te=E.useMemo(()=>T.map((M,H)=>({label:M,color:ee[H]||Ie,id:`${H}`,isRef:!0})),[ee,T]),ae=(M,H,x)=>{const K=[..._];K[+M]=x,I(K),j({formula1:d,formula2:K.join(",")})},ie=()=>{q([...$,{label:"",color:Ie,isRef:!1,id:o.Tools.generateRandomId(4)}])};E.useEffect(()=>{if(f==="1")return;const M=new Set,H=[];$.map(x=>({labelList:x.label.split(","),item:x})).forEach(({item:x,labelList:K})=>{K.forEach(ge=>{M.has(ge)||(M.add(ge),H.push({label:ge,color:x.color}))})}),j({formula1:V.serializeListOptions(H.map(x=>x.label)),formula2:H.map(x=>x.color===Ie?"":x.color).join(",")})},[$,j,f,C,_]);const le=z.useEvent(async M=>{if(!o.isFormulaString(M)){j==null||j({formula1:"",formula2:p});return}b.getFormulaRefCheck(M)?(j==null||j({formula1:o.isFormulaString(M)?M:"",formula2:p}),F("")):(j==null||j({formula1:"",formula2:p}),v("="),F(g.t("dataValidation.validFail.formulaError")))}),oe=E.useRef({}),[de,R]=E.useState(!1);return z.useSidebarClick(M=>{var x;const H=(x=oe.current)==null?void 0:x.handleOutClick;H&&H(M,()=>R(!1))}),u.jsxs(u.Fragment,{children:[u.jsx(L.FormLayout,{label:g.t("dataValidation.list.options"),children:u.jsxs(L.RadioGroup,{value:f,onChange:M=>{c(M),v(C),M==="1"&&j({formula1:C==="="?"":C,formula2:_.join(",")})},children:[u.jsx(L.Radio,{value:"0",children:g.t("dataValidation.list.customOptions")}),u.jsx(L.Radio,{value:"1",children:g.t("dataValidation.list.refOptions")})]})}),f==="1"?u.jsxs(u.Fragment,{children:[u.jsx(tt.FormulaEditor,{initValue:S,unitId:n,subUnitId:i,isFocus:de,onChange:(M="")=>{const H=(M!=null?M:"").trim();w(H),le(H)},errorText:P||W||void 0,onFocus:()=>R(!0),actions:oe.current,isSupportAcrossSheet:!0}),u.jsx("div",{ref:h,style:{marginTop:"12px"},children:te.map(M=>u.jsx(Wt,{item:M,commonProps:{onItemChange:ae},style:{marginBottom:12}},M.id))})]}):u.jsx(L.FormLayout,{error:P,children:u.jsxs("div",{ref:h,style:{marginTop:"-12px"},children:[u.jsx(L.DraggableList,{list:$,onListChange:q,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:M=>u.jsx(Wt,{item:M,commonProps:{onItemChange:Z,onItemDelete:G}},M.id),idKey:"id"}),u.jsxs("a",{className:ne.dataValidationFormulaListAdd,onClick:ie,children:[u.jsx(Et,{}),g.t("dataValidation.list.add")]})]})})]})}const $t="data-validation.custom-formula-input",Ye="data-validation.formula-input",ct="data-validation.list-formula-input",Ht="data-validation.checkbox-formula-input",oa=[[$t,ea],[Ye,Jn],[ct,ia],[Ht,Qn]],ra="LIST_RENDER_MODE_OPTION_INPUT";function xe(e){var i;const{value:t,onChange:a}=e,n=o.useDependency(o.LocaleService);return u.jsx(L.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:u.jsxs(L.RadioGroup,{value:`${(i=t.renderMode)!=null?i:o.DataValidationRenderMode.CUSTOM}`,onChange:r=>a({...t,renderMode:+r}),children:[u.jsx(L.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),u.jsx(L.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),u.jsx(L.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}xe.componentKey=ra;const sa="DATE_SHOW_TIME_OPTION";function Xe(e){var i;const{value:t,onChange:a}=e,n=o.useDependency(o.LocaleService);return u.jsx(L.FormLayout,{children:u.jsx(L.Checkbox,{checked:(i=t.bizInfo)==null?void 0:i.showTime,onChange:r=>{a({...t,bizInfo:{...t.bizInfo,showTime:r}})},children:n.t("dataValidation.showTime.label")})})}Xe.componentKey=sa;var la=Object.defineProperty,da=Object.getOwnPropertyDescriptor,ca=(e,t,a,n)=>{for(var i=n>1?void 0:n?da(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&la(t,a,i),i},Fe=(e,t)=>(a,n)=>t(a,n,e);const ze=6;let ut=class{constructor(e,t,a,n,i){this._commandService=e,this._formulaService=t,this._themeService=a,this._renderManagerService=n,this._dataValidationModel=i}_calc(e,t){var p,h,f;const{vt:a,ht:n}=t||{},i=e.endX-e.startX-ze*2,r=e.endY-e.startY,s=((p=t==null?void 0:t.fs)!=null?p:10)*1.6;let l=0,d=0;switch(a){case o.VerticalAlign.TOP:d=0;break;case o.VerticalAlign.BOTTOM:d=0+(r-s);break;default:d=0+(r-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:l=ze;break;case o.HorizontalAlign.RIGHT:l=ze+(i-s);break;default:l=ze+(i-s)/2;break}return{left:e.startX+l,top:e.startY+d,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((f=t==null?void 0:t.fs)!=null?f:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var p,h,f,c,S,v,C,w,g;const{formula1:n=V.CHECKBOX_FORMULA_1,formula2:i=V.CHECKBOX_FORMULA_2}=e,r=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=V.getFormulaResult((f=(h=(p=r==null?void 0:r[0])==null?void 0:p.result)==null?void 0:h[0])==null?void 0:f[0]),l=V.getFormulaResult((v=(S=(c=r==null?void 0:r[1])==null?void 0:c.result)==null?void 0:S[0])==null?void 0:v[0]),d=V.isLegalFormulaResult(String(s))&&V.isLegalFormulaResult(String(l));return{formula1:o.isFormulaString(n)?V.getFormulaResult((g=(w=(C=r==null?void 0:r[0])==null?void 0:C.result)==null?void 0:w[0])==null?void 0:g[0]):n,formula2:o.isFormulaString(i)?l:i,isFormulaValid:d}}drawWith(e,t){var P,N,U,j;const{style:a,primaryWithCoord:n,unitId:i,subUnitId:r,worksheet:s,row:l,col:d}=t,p=n.isMergedMainCell?n.mergeInfo:n,h=V.getCellValueOrigin(s.getCellRaw(l,d)),f=this._dataValidationModel.getRuleByLocation(i,r,l,d);if(!f)return;const c=this._dataValidationModel.getValidator(f.type);if(!c)return;const S=this._themeService.getCurrentTheme();if(!((P=c.skipDefaultFontRender)!=null&&P.call(c,f,h,{unitId:i,subUnitId:r,row:l,column:d})))return;const v=c.parseFormulaSync(f,i,r),{formula1:C}=v,w=this._calc(p,a),{a:g,d:y}=e.getTransform(),D=B.fixLineWidthByScale(w.left,g),b=B.fixLineWidthByScale(w.top,y),_=B.Transform.create().composeMatrix({left:D,top:b,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),I=p.endX-p.startX,m=p.endY-p.startY;e.save(),e.beginPath(),e.rect(p.startX,p.startY,I,m),e.clip();const T=_.getMatrix();e.transform(T[0],T[1],T[2],T[3],T[4],T[5]);const A=((N=a==null?void 0:a.fs)!=null?N:10)*1.6,W=String(h)===String(C),F=S.hyacinth500;B.CheckboxShape.drawWith(e,{checked:W,width:A,height:A,fill:(j=(U=a==null?void 0:a.cl)==null?void 0:U.rgb)!=null?j:F}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),i=n.top,r=n.top+n.height,s=n.left,l=n.left+n.width,{x:d,y:p}=e;return d<=l&&d>=s&&p<=r&&p>=i}async onPointerDown(e,t){var v;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:i,worksheet:r,row:s,col:l}=e,d=V.getCellValueOrigin(r.getCellRaw(s,l)),p=this._dataValidationModel.getRuleByLocation(n,i,s,l);if(!p)return;const h=this._dataValidationModel.getValidator(p.type);if(!h||!((v=h.skipDefaultFontRender)!=null&&v.call(h,p,d,{unitId:n,subUnitId:i,row:s,column:l})))return;const{formula1:f,formula2:c}=await this._parseFormula(p,n,i),S={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(d)===V.transformCheckboxValue(String(f))?c:f,p:null}};this._commandService.executeCommand(X.SetRangeValuesCommand.id,S)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};ut=ca([Fe(0,o.ICommandService),Fe(1,o.Inject(V.DataValidationFormulaService)),Fe(2,o.Inject(o.ThemeService)),Fe(3,o.Inject(B.IRenderManagerService)),Fe(4,o.Inject(V.SheetDataValidationModel))],ut);var ua=Object.defineProperty,pa=Object.getOwnPropertyDescriptor,ha=(e,t,a,n)=>{for(var i=n>1?void 0:n?pa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&ua(t,a,i),i},fa=(e,t)=>(a,n)=>t(a,n,e);let pe=class{constructor(e){O(this,"canvasRender",null);O(this,"dropdown");O(this,"optionsInput");O(this,"formulaInput",ct);this.injector=e}};pe=ha([fa(0,o.Inject(o.Injector))],pe);class va extends pe{constructor(){super(...arguments);O(this,"id",o.DataValidationType.CHECKBOX);O(this,"canvasRender",this.injector.createInstance(ut));O(this,"formulaInput",Ht)}}class ma extends pe{constructor(){super(...arguments);O(this,"id",o.DataValidationType.CUSTOM);O(this,"formulaInput",$t)}}const ga="data-validation.formula-input";class Sa extends pe{constructor(){super(...arguments);O(this,"id",o.DataValidationType.DATE);O(this,"formulaInput",ga);O(this,"optionsInput",Xe.componentKey);O(this,"dropdown",rt)}}class _a extends pe{constructor(){super(...arguments);O(this,"id",o.DataValidationType.DECIMAL);O(this,"formulaInput",Ye)}}const Yt=4,Ia=0,pt=4,xt=4,ht=6,Ke=6,De=14;function Ca(e,t){const a=B.FontCache.getTextSize(e,t),n=a.width+Yt*2,{ba:i,bd:r}=a,s=i+r;return{width:n,height:s+Ia*2,ba:i}}function ft(e,t,a,n){const i=De+ht*2,r=a-i,s=n-Ke*2,l=e.map(c=>({layout:Ca(c,t),text:c}));let d;const p=[];l.forEach(c=>{const{layout:S}=c,{width:v,height:C}=S;!d||d.width+v+pt>r?(d={width:v,height:C,items:[{...c,left:0}]},p.push(d)):(d.items.push({...c,left:d.width+pt}),d.width=d.width+v+pt)});let h=0,f=0;return p.forEach((c,S)=>{f=Math.max(f,c.width),S===p.length-1?h+=c.height:h+=c.height+xt}),{lines:p,totalHeight:h,contentWidth:r,contentHeight:s,cellAutoHeight:h+Ke*2,calcAutoWidth:f+i}}const Da=8;class ya extends B.Shape{static drawWith(t,a){const{fontString:n,info:i,fill:r,color:s}=a,{layout:l,text:d}=i;t.save(),B.Rect.drawWith(t,{width:l.width,height:l.height,radius:Da,fill:r||Ie}),t.translateWithPrecision(Yt,l.ba),t.font=n,t.fillStyle=s,t.fillText(d,0,0),t.restore()}}var wa=Object.defineProperty,Va=Object.getOwnPropertyDescriptor,Ea=(e,t,a,n)=>{for(var i=n>1?void 0:n?Va(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&wa(t,a,i),i},vt=(e,t)=>(a,n)=>t(a,n,e);const Ma=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){O(this,"zIndex");O(this,"_dropdownInfoMap",new Map);this._commandService=e,this._renderManagerService=t,this._dataValidationModel=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,i){const r=a-De+4;let s=4;switch(i){case o.VerticalAlign.MIDDLE:s=(n-De)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-De+4;break}e.save(),e.translateWithPrecision(t.startX+r,t.startY+s),e.fillStyle="#565656",e.fill(Ma),e.restore()}drawWith(e,t,a,n){var Z,G;const{primaryWithCoord:i,row:r,col:s,style:l,data:d,subUnitId:p}=t,h=i.isMergedMainCell?i.mergeInfo:i,f=d==null?void 0:d.fontRenderExtension,{leftOffset:c=0,rightOffset:S=0,topOffset:v=0,downOffset:C=0}=f||{},w=this._ensureMap(p),g=this._generateKey(r,s),y=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,r,s);if(!y)return;const D=this._dataValidationModel.getValidator(y.type);if(!D)return;const b={startX:h.startX+c,endX:h.endX-S,startY:h.startY+v,endY:h.endY-C},_=b.endX-b.startX,I=b.endY-b.startY,{cl:m}=l||{},T=(Z=typeof m=="object"?m==null?void 0:m.rgb:m)!=null?Z:"#000",A=B.getFontStyleString(l!=null?l:void 0),{vt:W,ht:F}=l||{},P=W!=null?W:o.VerticalAlign.MIDDLE,N=(G=V.getCellValueOrigin(d))!=null?G:"",U=D.parseCellValue(N),j=D.getListWithColorMap(y),$=ft(U,A,_,I);this._drawDownIcon(e,b,_,I,P),e.save(),e.translateWithPrecision(b.startX,b.startY),e.beginPath(),e.rect(0,0,_-De,I),e.clip(),e.translateWithPrecision(ht,Ke);let q=0;switch(P){case o.VerticalAlign.MIDDLE:q=($.contentHeight-$.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:q=$.contentHeight-$.totalHeight;break}e.translateWithPrecision(0,q),$.lines.forEach((ee,te)=>{e.save();const{width:ae,height:ie,items:le}=ee;let oe=0;switch(F){case o.HorizontalAlign.RIGHT:oe=$.contentWidth-ae;break;case o.HorizontalAlign.CENTER:oe=($.contentWidth-ae)/2;break}e.translate(oe,te*(ie+xt)),le.forEach(de=>{e.save(),e.translateWithPrecision(de.left,0),ya.drawWith(e,{...A,info:de,color:T,fill:j[de.text]}),e.restore()}),e.restore()}),e.restore(),w.set(g,{left:b.startX,top:b.startY,width:$.contentWidth+ht+De,height:$.contentHeight+Ke*2})}calcCellAutoHeight(e){var _;const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:p=0,downOffset:h=0}=s||{},f=t.isMergedMainCell?t.mergeInfo:t,c={startX:f.startX+l,endX:f.endX-d,startY:f.startY+p,endY:f.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!S)return;const v=this._dataValidationModel.getValidator(S.type);if(!v)return;const C=c.endX-c.startX,w=c.endY-c.startY,g=(_=V.getCellValueOrigin(n))!=null?_:"",y=v.parseCellValue(g),D=B.getFontStyleString(a!=null?a:void 0);return ft(y,D,C,w).cellAutoHeight}calcCellAutoWidth(e){var _;const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:p=0,downOffset:h=0}=s||{},f=t.isMergedMainCell?t.mergeInfo:t,c={startX:f.startX+l,endX:f.endX-d,startY:f.startY+p,endY:f.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!S)return;const v=this._dataValidationModel.getValidator(S.type);if(!v)return;const C=c.endX-c.startX,w=c.endY-c.startY,g=(_=V.getCellValueOrigin(n))!=null?_:"",y=v.parseCellValue(g),D=B.getFontStyleString(a!=null?a:void 0);return ft(y,D,C,w).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:i}=n,{x:r}=e;return r>=i-De&&r<=i}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=e,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Ue.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};mt=Ea([vt(0,o.ICommandService),vt(1,o.Inject(B.IRenderManagerService)),vt(2,o.Inject(V.SheetDataValidationModel))],mt);class ba extends pe{constructor(){super(...arguments);O(this,"id",o.DataValidationType.LIST_MULTIPLE);O(this,"canvasRender",this.injector.createInstance(mt));O(this,"dropdown",We)}}var La=Object.defineProperty,Ta=Object.getOwnPropertyDescriptor,Oa=(e,t,a,n)=>{for(var i=n>1?void 0:n?Ta(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&La(t,a,i),i},Ge=(e,t)=>(a,n)=>t(a,n,e);const ye=4,qe=4,ce=14,he=6,Te=4,gt=8,Pa="#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 Ra(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:o.BooleanNumber.FALSE,bl:o.BooleanNumber.FALSE,ul:{s:o.BooleanNumber.FALSE},st:{s:o.BooleanNumber.FALSE},ol:{s:o.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function zt(e,t,a){const n=Ra(e,a),i=new o.DocumentDataModel(n),r=new B.DocumentViewModel(i);return{documentSkeleton:B.DocumentSkeleton.create(r,t),docModel:i,docViewModel:r}}function Ze(e,t,a){const{documentSkeleton:n,docModel:i,docViewModel:r}=zt(e,t,a);return{documents:new B.Documents(`DOCUMENTS_${o.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:i,docViewModel:r}}function Kt(e,t,a,n,i,r,s=!0){let l=0;const d=s?Te:0;switch(i){case o.VerticalAlign.BOTTOM:l=t-n-d;break;case o.VerticalAlign.MIDDLE:l=(t-n)/2;break;default:l=d;break}l=Math.max(Te,l);let p=0;switch(r){case o.HorizontalAlign.CENTER:p=(e-a)/2;break;case o.HorizontalAlign.RIGHT:p=e-a;break}return p=Math.max(he,p),{paddingLeft:p,paddingTop:l}}let St=class{constructor(e,t,a,n){O(this,"_dropdownInfoMap",new Map);O(this,"zIndex");this._localeService=e,this._commandService=t,this._renderManagerService=a,this._dataValidationModel=n}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,i,r,s){const{t:l=o.DEFAULT_STYLES.pd.t,b:d=o.DEFAULT_STYLES.pd.b}=s,p=a-ce;let h;switch(r){case o.VerticalAlign.MIDDLE:h=(n-qe)/2;break;case o.VerticalAlign.BOTTOM:h=n-d-i-Te+(i/2-qe/2);break;default:h=l+Te+(i/2-qe/2);break}e.save(),e.translateWithPrecision(t.startX+p,t.startY+h),e.fillStyle="#565656",e.fill(Xt),e.restore()}drawWith(e,t,a){const{primaryWithCoord:n,row:i,col:r,style:s,data:l,subUnitId:d}=t,p=n.isMergedMainCell?n.mergeInfo:n,h=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,r);if(!h)return;const f=this._dataValidationModel.getValidator(h.type);if(!f)return;const c=l==null?void 0:l.fontRenderExtension,{leftOffset:S=0,rightOffset:v=0,topOffset:C=0,downOffset:w=0}=c||{};if(!h||!f||!f||f.id.indexOf(o.DataValidationType.LIST)!==0||!f.skipDefaultFontRender(h))return;const g={startX:p.startX+S,endX:p.endX-v,startY:p.startY+C,endY:p.endY-w},y=g.endX-g.startX,D=g.endY-g.startY,b=this._ensureMap(d),_=this._generateKey(i,r),I=f.getListWithColor(h),m=V.getCellValueOrigin(l),T=`${m!=null?m:""}`,A=I.find(U=>U.label===T);let{tb:W,vt:F,ht:P,pd:N}=s||{};if(W=W!=null?W:o.WrapStrategy.WRAP,F=F!=null?F:o.VerticalAlign.BOTTOM,P=P!=null?P:o.DEFAULT_STYLES.ht,N=N!=null?N:o.DEFAULT_STYLES.pd,h.renderMode===o.DataValidationRenderMode.ARROW){const{l:U=o.DEFAULT_STYLES.pd.l,t:j=o.DEFAULT_STYLES.pd.t,r:$=o.DEFAULT_STYLES.pd.r,b:q=o.DEFAULT_STYLES.pd.b}=N,Z=y-U-$-ce-4,{documentSkeleton:G,documents:ee,docModel:te}=Ze(T,this._localeService,s);W===o.WrapStrategy.WRAP&&te.updateDocumentDataPageSize(Math.max(Z,1)),G.calculate(),G.getActualSize();const ae=B.getDocsSkeletonPageSize(G),{height:ie,width:le}=ae,{paddingTop:oe,paddingLeft:de}=Kt(Z,D-j-q,le,ie,F,P,!0);this._drawDownIcon(e,g,y,D,ie,F,N),e.save(),e.translateWithPrecision(g.startX+U,g.startY+j),e.beginPath(),e.rect(0,0,y-U-$,D-j-q),e.clip(),e.translateWithPrecision(0,oe),e.save(),e.translateWithPrecision(ye,0),e.beginPath(),e.rect(0,0,Z,ie),e.clip(),ee.render(e),e.translateWithPrecision(de,0),e.restore(),e.restore(),b.set(_,{left:g.endX+U+a.rowHeaderWidth-ce,top:g.startY+j+a.columnHeaderHeight,width:ce,height:D-j-q})}else{e.save(),e.translateWithPrecision(g.startX,g.startY),e.beginPath(),e.rect(0,0,y,D),e.clip();const U=y-he*2-ye-ce-4,{documentSkeleton:j,documents:$,docModel:q}=Ze(T,this._localeService,s);W===o.WrapStrategy.WRAP&&q.updateDocumentDataPageSize(Math.max(U,1)),j.calculate();const Z=B.getDocsSkeletonPageSize(j),{height:G,width:ee}=Z,{paddingTop:te,paddingLeft:ae}=Kt(U,D,ee,G,F,P);e.translateWithPrecision(he,te);const ie=Math.max(y-he*2,1),le=G;B.Rect.drawWith(e,{width:ie,height:le,fill:(A==null?void 0:A.color)||Ie,radius:gt}),e.save(),e.translateWithPrecision(ye,0),e.beginPath(),e.rect(0,0,U,G),e.clip(),e.translateWithPrecision(ae,0),$.render(e),e.restore(),e.translateWithPrecision(U+ye+4,(G-qe)/2),e.fillStyle=Pa,e.fill(Xt),e.restore(),b.set(_,{left:g.startX+he+a.rowHeaderWidth,top:g.startY+te+a.columnHeaderHeight,width:ie,height:le})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=t.isMergedMainCell?t.mergeInfo:t,l=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:p=0,topOffset:h=0,downOffset:f=0}=l||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!c||c.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+d,endX:s.endX-p,startY:s.startY+h,endY:s.endY-f},v=S.endX-S.startX,C=V.getCellValueOrigin(n),w=`${C!=null?C:""}`;let{tb:g,pd:y}=a||{};const{t:D=o.DEFAULT_STYLES.pd.t,b=o.DEFAULT_STYLES.pd.b}=y!=null?y:{};if(g=g!=null?g:o.WrapStrategy.WRAP,c.renderMode===o.DataValidationRenderMode.ARROW){const _=v-ce,{documentSkeleton:I,docModel:m}=Ze(w,this._localeService,a);g===o.WrapStrategy.WRAP&&m.updateDocumentDataPageSize(Math.max(_,1)),I.calculate(),I.getActualSize();const T=B.getDocsSkeletonPageSize(I),{height:A}=T;return A+D+b+Te*2}else{const _=v-he*2-ye-ce,{documentSkeleton:I,docModel:m}=zt(w,this._localeService,a);g===o.WrapStrategy.WRAP&&m.updateDocumentDataPageSize(Math.max(_,1)),I.calculate();const T=B.getDocsSkeletonPageSize(I),{height:A}=T;return A+Te*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=t.isMergedMainCell?t.mergeInfo:t,l=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:p=0,topOffset:h=0,downOffset:f=0}=l||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!c||c.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+d,endX:s.endX-p,startY:s.startY+h,endY:s.endY-f},v=S.endX-S.startX,C=V.getCellValueOrigin(n),w=`${C!=null?C:""}`;let{tb:g,pd:y}=a||{};const{l:D=o.DEFAULT_STYLES.pd.l,r:b=o.DEFAULT_STYLES.pd.r}=y!=null?y:{};g=g!=null?g:o.WrapStrategy.WRAP;let _=he*2+ce;switch(c.renderMode){case o.DataValidationRenderMode.ARROW:_=ce+he*2+b+D;break;case o.DataValidationRenderMode.CUSTOM:_=ce+he*2+ye*2+b+D+gt/2+1;break;default:_=ce+he*2+ye*2+b+D+gt/2+1}const I=v-_,{documentSkeleton:m,docModel:T}=Ze(w,this._localeService,a);return g===o.WrapStrategy.WRAP&&T.updateDocumentDataPageSize(Math.max(I,1)),m.calculate(),m.getActualSize(),B.getDocsSkeletonPageSize(m).width+_}isHit(e,t){const{subUnitId:a,row:n,col:i}=t,s=this._ensureMap(a).get(this._generateKey(n,i)),l=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,i);if(!l||!s||l.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:d,left:p,width:h,height:f}=s,{x:c,y:S}=e;return c>=p&&c<=p+h&&S>=d&&S<=d+f}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=e,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Ue.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};St=Oa([Ge(0,o.Inject(o.LocaleService)),Ge(1,o.ICommandService),Ge(2,o.Inject(B.IRenderManagerService)),Ge(3,o.Inject(V.SheetDataValidationModel))],St);class Aa extends pe{constructor(){super(...arguments);O(this,"id",o.DataValidationType.LIST);O(this,"canvasRender",this.injector.createInstance(St));O(this,"dropdown",We);O(this,"optionsInput",xe.componentKey);O(this,"formulaInput",ct)}}class Fa extends pe{constructor(){super(...arguments);O(this,"id",o.DataValidationType.TEXT_LENGTH);O(this,"formulaInput",Ye)}}class Na extends pe{constructor(){super(...arguments);O(this,"id",o.DataValidationType.WHOLE);O(this,"formulaInput",Ye)}}var Ua=Object.defineProperty,ja=Object.getOwnPropertyDescriptor,Ba=(e,t,a,n)=>{for(var i=n>1?void 0:n?ja(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Ua(t,a,i),i},_t=(e,t)=>(a,n)=>t(a,n,e);let Oe=class extends o.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[At,Vt],[Ne,Tn],[Ot,gn],[We,Dn],[rt,tn],[xe.componentKey,xe],[Xe.componentKey,Xe],...oa].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[_a,Na,Fa,Sa,va,Aa,ba,ma].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=Ba([_t(0,o.Inject(o.Injector)),_t(1,o.Inject(z.ComponentManager)),_t(2,o.Inject(J.DataValidatorRegistryService))],Oe);var ka=Object.defineProperty,Wa=Object.getOwnPropertyDescriptor,$a=(e,t,a,n)=>{for(var i=n>1?void 0:n?Wa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&ka(t,a,i),i},It=(e,t)=>(a,n)=>t(a,n,e);const Ha="SHEET_DATA_VALIDATION_UI_PLUGIN";Y.UniverSheetsDataValidationUIPlugin=(Je=class extends o.Plugin{constructor(t=je,a,n,i){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=o.merge({},je,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(it,s)}onStarting(){[[ue],[me],[Ae],[Ee],[Le],[be],[Me],[Re],[Oe]].forEach(t=>{this._injector.add(t)}),[$e,Ue,Rt,at,_e,Pt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Me),this._injector.get(be),this._injector.get(Re),this._injector.get(Ae),this._injector.get(B.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[He])}onRendered(){this._injector.get(Oe),this._injector.get(Le)}onSteady(){this._injector.get(Ee)}},O(Je,"pluginName",Ha),O(Je,"type",o.UniverInstanceType.UNIVER_SHEET),Je),Y.UniverSheetsDataValidationUIPlugin=$a([It(1,o.Inject(o.Injector)),It(2,o.ICommandService),It(3,o.IConfigService)],Y.UniverSheetsDataValidationUIPlugin);var Ya=Object.defineProperty,xa=Object.getOwnPropertyDescriptor,Xa=(e,t,a,n)=>{for(var i=n>1?void 0:n?xa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Ya(t,a,i),i},Ct=(e,t)=>(a,n)=>t(a,n,e);const za="SHEET_DATA_VALIDATION_UI_PLUGIN";Y.UniverSheetsDataValidationMobileUIPlugin=(Qe=class extends o.Plugin{constructor(t=je,a,n,i){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=o.merge({},je,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(it,s)}onStarting(){[[ue],[me],[Ae],[Ee],[Le],[be],[Me],[Oe]].forEach(t=>{this._injector.add(t)}),[$e,Ue,Rt,at,_e,Pt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Me),this._injector.get(be),this._injector.get(B.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[He])}onRendered(){this._injector.get(Oe),this._injector.get(Le)}onSteady(){this._injector.get(Ee)}},O(Qe,"pluginName",za),O(Qe,"type",o.UniverInstanceType.UNIVER_SHEET),Qe),Y.UniverSheetsDataValidationMobileUIPlugin=Xa([Ct(1,o.Inject(o.Injector)),Ct(2,o.ICommandService),Ct(3,o.IConfigService)],Y.UniverSheetsDataValidationMobileUIPlugin),Y.DATE_DROPDOWN_KEY=rt,Y.LIST_DROPDOWN_KEY=We,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-data-validation-ui",
3
- "version": "0.5.5",
3
+ "version": "0.6.0-alpha.0",
4
4
  "private": false,
5
5
  "description": "Data validation UI for Univer Sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -50,25 +50,25 @@
50
50
  "lib"
51
51
  ],
52
52
  "peerDependencies": {
53
- "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
53
+ "react": ">=16.9.0 || >=17 || >=18 || >=19",
54
54
  "rxjs": ">=7.0.0"
55
55
  },
56
56
  "dependencies": {
57
57
  "@flatten-js/interval-tree": "^1.1.3",
58
- "@univerjs/icons": "^0.2.12",
58
+ "@univerjs/icons": "^0.2.14",
59
59
  "clsx": "^2.1.1",
60
- "@univerjs/core": "0.5.5",
61
- "@univerjs/design": "0.5.5",
62
- "@univerjs/docs": "0.5.5",
63
- "@univerjs/engine-render": "0.5.5",
64
- "@univerjs/data-validation": "0.5.5",
65
- "@univerjs/engine-formula": "0.5.5",
66
- "@univerjs/sheets-data-validation": "0.5.5",
67
- "@univerjs/sheets": "0.5.5",
68
- "@univerjs/sheets-formula-ui": "0.5.5",
69
- "@univerjs/sheets-ui": "0.5.5",
70
- "@univerjs/ui": "0.5.5",
71
- "@univerjs/sheets-numfmt": "0.5.5"
60
+ "@univerjs/core": "0.6.0-alpha.0",
61
+ "@univerjs/data-validation": "0.6.0-alpha.0",
62
+ "@univerjs/design": "0.6.0-alpha.0",
63
+ "@univerjs/engine-formula": "0.6.0-alpha.0",
64
+ "@univerjs/docs": "0.6.0-alpha.0",
65
+ "@univerjs/engine-render": "0.6.0-alpha.0",
66
+ "@univerjs/sheets": "0.6.0-alpha.0",
67
+ "@univerjs/sheets-numfmt": "0.6.0-alpha.0",
68
+ "@univerjs/sheets-ui": "0.6.0-alpha.0",
69
+ "@univerjs/sheets-formula-ui": "0.6.0-alpha.0",
70
+ "@univerjs/ui": "0.6.0-alpha.0",
71
+ "@univerjs/sheets-data-validation": "0.6.0-alpha.0"
72
72
  },
73
73
  "devDependencies": {
74
74
  "less": "^4.2.1",
@@ -76,10 +76,10 @@
76
76
  "react": "18.3.1",
77
77
  "rxjs": "^7.8.1",
78
78
  "tailwindcss": "^3.4.17",
79
- "typescript": "^5.7.2",
79
+ "typescript": "^5.7.3",
80
80
  "vite": "^6.0.7",
81
81
  "vitest": "^2.1.8",
82
- "@univerjs-infra/shared": "0.5.5"
82
+ "@univerjs-infra/shared": "0.6.0-alpha.0"
83
83
  },
84
84
  "scripts": {
85
85
  "dev": "vite",