@univerjs/sheets-data-validation-ui 0.6.1-nightly.202502221605 → 0.6.1-nightly.202502241606

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var Gt=Object.defineProperty;var qt=(e,t,a)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var O=(e,t,a)=>qt(e,typeof t!="symbol"?t+"":t,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),r=require("@univerjs/core"),T=require("@univerjs/design"),W=require("@univerjs/engine-render"),X=require("@univerjs/sheets"),w=require("@univerjs/sheets-data-validation"),Zt=require("@univerjs/sheets-numfmt"),N=require("@univerjs/sheets-ui"),f=require("@univerjs/ui"),E=require("react"),Q=require("@univerjs/data-validation"),Jt=require("@univerjs/docs"),le=require("rxjs"),ct=require("@univerjs/engine-formula"),mt=require("@univerjs/sheets-formula-ui");var Qt=Object.getOwnPropertyDescriptor,en=(e,t,a,n)=>{for(var o=n>1?void 0:n?Qt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Le=(e,t)=>(a,n)=>t(a,n,e);let Pe=class extends r.Disposable{constructor(e,t,a,n,o){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=o,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(X.AFTER_CELL_EDIT_ASYNC,{handler:async(e,t,a)=>{var D;const n=await e,{worksheet:o,row:i,col:s,unitId:l,subUnitId:d,workbook:u}=t,p=this._dataValidationModel.getRuleIdByLocation(l,d,i,s),g=p?this._dataValidationModel.getRuleById(l,d,p):void 0;if(!g||g.errorStyle!==r.DataValidationErrorStyle.STOP)return a(Promise.resolve(n));const c=await this._dataValidatorRegistryService.getValidatorItem(g.type);if(!c||await c.validator({value:w.getCellValueOrigin(n),interceptValue:w.getCellValueOrigin((D=t==null?void 0:t.origin)!=null?D:n),row:i,column:s,unitId:l,subUnitId:d,worksheet:o,workbook:u,t:n==null?void 0:n.t},g))return a(Promise.resolve(n));const m=o.getCellRaw(i,s);return this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:c.getRuleFinalError(g,{row:i,col:s,unitId:l,subUnitId:d})},footer:{title:E.createElement(T.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(Promise.resolve(m))}})}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(T.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Pe=en([Le(0,r.Inject(X.SheetInterceptorService)),Le(1,r.Inject(w.SheetDataValidationModel)),Le(2,r.Inject(Q.DataValidatorRegistryService)),Le(3,f.IDialogService),Le(4,r.Inject(r.LocaleService))],Pe);const tn="univer-dv-date-dropdown",nn="univer-dv-date-dropdown-btns",Ct={dvDateDropdown:tn,dvDateDropdownBtns:nn},an=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return r.dayjs(r.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=r.dayjs(e);if(t.isValid())return t};function on(e){var v;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:i,unitId:s,subUnitId:l,workbook:d}=t,u=f.useDependency(r.ICommandService),p=f.useDependency(Pe),g=n.getCell(o,i),c=w.getCellValueOrigin(n.getCellRaw(o,i)),_=an(c),[m,D]=E.useState(_),V=m&&m.isValid()?m:r.dayjs(),S=f.useDependency(r.LocaleService),R=f.useDependency(w.SheetDataValidationModel),y=R.getRuleByLocation(s,l,o,i);if(!y)return null;const b=R.getValidator(y.type);if(!g||!b)return;const I=!!((v=y.bizInfo)!=null&&v.showTime),C=async()=>{var k,U,$;if(!V)return;const j=V.format(I?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),B=(k=r.numfmt.parseDate(j))==null?void 0:k.v,F=d.getStyles().getStyleByCell(g),P=($=(U=F==null?void 0:F.n)==null?void 0:U.pattern)!=null?$:"",x=Zt.getPatternType(P);y.errorStyle!==r.DataValidationErrorStyle.STOP||await b.validator({value:B,unitId:s,subUnitId:l,row:o,column:i,worksheet:n,workbook:d,interceptValue:j.replace("Z","").replace("T"," "),t:r.CellValueType.NUMBER},y)?(a(),await u.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:W.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),await u.executeCommand(X.SetRangeValuesCommand.id,{unitId:s,subUnitId:l,range:{startColumn:i,endColumn:i,startRow:o,endRow:o},value:{v:B,t:2,p:null,f:null,si:null,s:{n:{pattern:I?x==="datetime"?P:"yyyy-MM-dd hh:mm:ss":x==="date"?P:"yyyy-MM-dd"}}}})):p.showReject(b.getRuleFinalError(y,{row:o,col:i,unitId:s,subUnitId:l}))};return h.jsxs("div",{className:Ct.dvDateDropdown,children:[h.jsx(T.DatePanel,{defaultValue:V,pickerValue:V,showTime:I||void 0,onSelect:async L=>{D(L)},onPanelChange:L=>{D(L)},disabledDate:L=>!r.numfmt.parseDate(L.format("YYYY-MM-DD"))}),h.jsx("div",{className:Ct.dvDateDropdownBtns,children:h.jsx(T.Button,{size:"small",type:"primary",onClick:C,disabled:!V.isValid(),children:S.t("dataValidation.alert.ok")})})]})}var se=function(){return se=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},se.apply(this,arguments)},rn=function(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(a[n[o]]=e[n[o]]);return a},ve=E.forwardRef(function(e,t){var a=e.icon,n=e.id,o=e.className,i=e.extend,s=rn(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),d=E.useRef("_".concat(dn()));return Mt(a,"".concat(n),{defIds:a.defIds,idSuffix:d.current},se({ref:t,className:l},s),i)});function Mt(e,t,a,n,o){return E.createElement(e.tag,se(se({key:t},sn(e,a,o)),n),(ln(e,a).children||[]).map(function(i,s){return Mt(i,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,o)}))}function sn(e,t,a){var n=se({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],l=i[1];s==="mask"&&typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var o=t.defIds;return!o||o.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],l=i[1];typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function ln(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?se(se({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?se(se({},o),{attrs:se(se({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):e}function dn(){return Math.random().toString(36).substring(2,8)}ve.displayName="UniverIcon";var cn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},bt=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"check-mark-single",ref:t,icon:cn}))});bt.displayName="CheckMarkSingle";var un={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.4917 3.07803C1.4917 2.19437 2.20804 1.47803 3.0917 1.47803H5.6917C6.57536 1.47803 7.2917 2.19437 7.2917 3.07803V5.67803C7.2917 6.56168 6.57535 7.27803 5.6917 7.27803H3.0917C2.20804 7.27803 1.4917 6.56168 1.4917 5.67803V3.07803ZM3.0917 2.67803C2.87078 2.67803 2.6917 2.85711 2.6917 3.07803V5.67803C2.6917 5.89894 2.87079 6.07803 3.0917 6.07803H5.6917C5.91261 6.07803 6.0917 5.89894 6.0917 5.67803V3.07803C6.0917 2.85711 5.91261 2.67803 5.6917 2.67803H3.0917Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.6175 2.45279C14.8518 2.68711 14.8518 3.06701 14.6175 3.30132L11.6151 6.30365C11.3957 6.52307 11.0451 6.53897 10.8067 6.34031L8.80915 4.67566C8.55458 4.46352 8.52019 4.08518 8.73233 3.83062 8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767 13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279zM14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217 14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046 13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703 10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046 9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217 9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746 9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732 13.269 9.19746C13.5033 8.96315 13.8832 8.96315 14.1175 9.19746z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.0917 8.72168C2.20804 8.72168 1.4917 9.43802 1.4917 10.3217V12.9217C1.4917 13.8053 2.20804 14.5217 3.0917 14.5217H5.6917C6.57535 14.5217 7.2917 13.8053 7.2917 12.9217V10.3217C7.2917 9.43802 6.57536 8.72168 5.6917 8.72168H3.0917ZM2.6917 10.3217C2.6917 10.1008 2.87078 9.92168 3.0917 9.92168H5.6917C5.91261 9.92168 6.0917 10.1008 6.0917 10.3217V12.9217C6.0917 13.1426 5.91261 13.3217 5.6917 13.3217H3.0917C2.87079 13.3217 2.6917 13.1426 2.6917 12.9217V10.3217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Tt=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"data-validation-single",ref:t,icon:un}))});Tt.displayName="DataValidationSingle";var hn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},vt=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"delete-single",ref:t,icon:hn}))});vt.displayName="DeleteSingle";var pn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},Lt=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"increase-single",ref:t,icon:pn}))});Lt.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"}}]},Ot=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"more-down-single",ref:t,icon:gn}))});Ot.displayName="MoreDownSingle";var mn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.64645 9.85355C4.45118 9.65829 4.45118 9.34171 4.64645 9.14645L7.64645 6.14645C7.84171 5.95118 8.15829 5.95118 8.35355 6.14645L11.3536 9.14645C11.5488 9.34171 11.5488 9.65829 11.3536 9.85355C11.1583 10.0488 10.8417 10.0488 10.6464 9.85355L8 7.20711L5.35355 9.85355C5.15829 10.0488 4.84171 10.0488 4.64645 9.85355Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Pt=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"more-up-single",ref:t,icon:mn}))});Pt.displayName="MoreUpSingle";var vn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},At=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"sequence-single",ref:t,icon:vn}))});At.displayName="SequenceSingle";var fn=Object.getOwnPropertyDescriptor,Sn=(e,t,a,n)=>{for(var o=n>1?void 0:n?fn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Dt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends r.Disposable{constructor(t,a){super();O(this,"_open$",new le.BehaviorSubject(!1));O(this,"open$",this._open$.pipe(le.distinctUntilChanged()));O(this,"_activeRule");O(this,"_activeRule$",new le.BehaviorSubject(void 0));O(this,"activeRule$",this._activeRule$.asObservable());O(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).pipe(le.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===$e&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=r.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ue=Sn([Dt(0,r.IUniverInstanceService),Dt(1,f.ISidebarService)],ue);function _n(){const e=f.useDependency(me),t=f.useObservable(e.activeDropdown$,e.activeDropdown),a=f.useDependency(f.ComponentManager);if(!t)return null;const{location:n,componentKey:o}=t,i=a.get(o),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!i)return null;const l=()=>{e.hideDropdown()};return h.jsx(i,{location:n,hideFn:l},s)}const jt="sheet.ui.dropdown";var In=Object.getOwnPropertyDescriptor,Cn=(e,t,a,n)=>{for(var o=n>1?void 0:n?In(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},fe=(e,t)=>(a,n)=>t(a,n,e);let me=class extends r.Disposable{constructor(t,a,n,o,i,s,l){super();O(this,"_activeDropdown");O(this,"_activeDropdown$",new le.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=o,this._renderManagerService=i,this._dataValidationModel=s,this._sheetsSelectionsService=l,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,a,n,o){const i=t?this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=a?i.getSheetBySheetId(a):i.getActiveSheet();if(!s)return;const l=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,o);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);return d==null?void 0:d.dropdown}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t,a=!0){const{location:n}=t,{row:o,col:i,unitId:s,subUnitId:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const d=this._renderManagerService.getRenderById(r.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),u=this._canvasPopupManagerService.attachPopupToCell(o,i,{componentKey:jt,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[d==null?void 0:d.engine.getCanvasElement()].filter(Boolean)},s,l);if(!u)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const p=new r.DisposableCollection;p.add(u),p.add({dispose:()=>{var g,c;(c=(g=this._activeDropdown)==null?void 0:g.onHide)==null||c.call(g)}}),this._currentPopup=p}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,a,n,o,i){const s=this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET);if(!s)return;const l=s.getSheetBySheetId(a);if(!l)return;const d=this._dataValidationModel.getRuleByLocation(s.getUnitId(),l.getSheetId(),n,o);if(!d)return;const u=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!u||!u.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:l,row:n,col:o,unitId:t,subUnitId:a},componentKey:u.dropdown,onHide:i})}};me=Cn([fe(0,r.Inject(N.SheetCanvasPopManagerService)),fe(1,r.IUniverInstanceService),fe(2,r.Inject(Q.DataValidatorRegistryService)),fe(3,f.IZenZoneService),fe(4,W.IRenderManagerService),fe(5,r.Inject(w.SheetDataValidationModel)),fe(6,r.Inject(X.SheetsSelectionsService))],me);const $e="DataValidationPanel",De={id:"data-validation.operation.open-validation-panel",type:r.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,o=e.get(ue),i=e.get(Q.DataValidationModel),s=e.get(r.IUniverInstanceService),l=e.get(f.ISidebarService),d=X.getSheetCommandTarget(s);if(!d)return!1;const{unitId:u,subUnitId:p}=d,g=a?i.getRuleById(u,p,a):void 0;o.open(),o.setActiveRule(g&&{unitId:u,subUnitId:p,rule:g});const c=l.open({id:$e,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:$e},width:312,onClose:()=>o.close()});return o.setCloseDisposable(c),!0}},ft={id:"data-validation.operation.close-validation-panel",type:r.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},Ft={id:"data-validation.operation.toggle-validation-panel",type:r.CommandType.OPERATION,handler(e){const t=e.get(r.ICommandService),a=e.get(ue);return a.open(),a.isOpen?t.executeCommand(ft.id):t.executeCommand(De.id),!0}},Ge={type:r.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(me),{unitId:n,subUnitId:o,row:i,column:s}=t,l=a.activeDropdown,d=l==null?void 0:l.location;return d&&d.unitId===n&&d.subUnitId===o&&d.row===i&&d.col===s||a.showDataValidationDropdown(n,o,i,s),!0}},xt={type:r.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(me).hideDropdown(),!0):!1}},Ce="#ECECEC",St="sheets-data-validation-ui.config",He={},Dn="univer-dv-list-dropdown",yn="univer-dv-list-dropdown-title",Rn="univer-dv-list-dropdown-list",Vn="univer-dv-list-dropdown-list-container",wn="univer-dv-list-dropdown-selected-icon",En="univer-dv-list-dropdown-item-container",Mn="univer-dv-list-dropdown-item",bn="univer-dv-list-dropdown-split",Tn="univer-dv-list-dropdown-edit",pe={dvListDropdown:Dn,dvListDropdownTitle:yn,dvListDropdownList:Rn,dvListDropdownListContainer:Vn,dvListDropdownSelectedIcon:wn,dvListDropdownItemContainer:En,dvListDropdownItem:Mn,dvListDropdownSplit:bn,dvListDropdownEdit:Tn},Ln=e=>{var I,C;const{value:t,onChange:a,multiple:n,options:o,title:i,onEdit:s,style:l,filter:d,location:u}=e,p=f.useDependency(r.LocaleService),g=f.useDependency(r.IConfigService),c=d==null?void 0:d.toLowerCase(),{row:_,col:m,unitId:D,subUnitId:V}=u,S=o.filter(v=>c?v.label.toLowerCase().includes(c):!0),R=(C=(I=g.getConfig(St))==null?void 0:I.showEditOnDropdown)!=null?C:!0,y=f.useDependency(X.SheetPermissionCheckController),b=E.useMemo(()=>y.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission]},[{startColumn:m,startRow:_,endColumn:m,endRow:_}],D,V),[y,m,_,D,V]);return h.jsxs("div",{className:pe.dvListDropdown,style:l,children:[h.jsx("div",{className:pe.dvListDropdownTitle,children:i}),h.jsx("div",{className:pe.dvListDropdownList,children:h.jsx(T.Scrollbar,{children:h.jsx("div",{className:pe.dvListDropdownListContainer,children:S.map((v,L)=>{const j=t.indexOf(v.value)>-1,B=()=>{let P;j?P=new Set(t.filter(k=>k!==v.value)):P=new Set(n?[...t,v.value]:[v.value]);const x=[];o.forEach(k=>{P.has(k.value)&&x.push(k.value)}),a(x)},F=v.label.toLocaleLowerCase().indexOf(c);return h.jsxs("div",{className:pe.dvListDropdownItemContainer,onClick:B,children:[h.jsx("div",{className:pe.dvListDropdownItem,style:{background:v.color||Ce},children:c&&v.label.toLowerCase().includes(c)?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:v.label.substring(0,F)}),h.jsx("span",{style:{fontWeight:"bold"},children:v.label.substring(F,F+c.length)}),h.jsx("span",{children:v.label.substring(F+c.length)})]}):v.label}),h.jsx("div",{className:pe.dvListDropdownSelectedIcon,children:j?h.jsx(bt,{}):null})]},L)})})},d)}),R&&b?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:pe.dvListDropdownSplit}),h.jsx("div",{className:pe.dvListDropdownEdit,children:h.jsx("a",{onClick:s,children:p.t("dataValidation.list.edit")})})]}):null]})};function On(e){var U,$,G,q;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:i,unitId:s,subUnitId:l}=t,d=f.useDependency(Q.DataValidationModel),[u,p]=E.useState(""),g=f.useDependency(r.ICommandService),c=f.useDependency(r.LocaleService),[_,m]=E.useState(""),D=f.useDependency(N.IEditorBridgeService),V=f.useDependency(r.IUniverInstanceService),S=E.useMemo(()=>d.ruleChange$.pipe(le.debounceTime(16)),[]),R=f.useDependency(w.SheetDataValidationModel);f.useObservable(S);const y=f.RectPopup.useContext(),b=(($=(U=y.current)==null?void 0:U.right)!=null?$:0)-((q=(G=y.current)==null?void 0:G.left)!=null?q:0);if(E.useEffect(()=>{const K=g.onCommandExecuted(Z=>{var ee,te;if(Z.id===Jt.RichTextEditingMutation.id){const ne=Z.params,{unitId:ie}=ne,oe=V.getUnit(ie,r.UniverInstanceType.UNIVER_DOC);if(!oe||!D.isVisible().visible)return;const re=r.BuildTextUtils.transform.getPlainText((te=(ee=oe.getSnapshot().body)==null?void 0:ee.dataStream)!=null?te:"");p(re)}});return()=>{K.dispose()}},[g,D,V]),!n)return null;const I=R.getRuleByLocation(s,l,o,i);if(!I)return null;const C=R.getValidator(I.type);if(!C)return null;const v=n.getCell(o,i),L=(I==null?void 0:I.renderMode)===r.DataValidationRenderMode.CUSTOM||(I==null?void 0:I.renderMode)===void 0;if(!v||!I||!C||C.id.indexOf(r.DataValidationType.LIST)!==0)return;const j=I.type===r.DataValidationType.LIST_MULTIPLE,B=C.getListWithColor(I,s,l),F=_||w.getDataValidationCellValue(n.getCellRaw(o,i)),P=w.deserializeListOptions(F),x=()=>{g.executeCommand(De.id,{ruleId:I.uid}),a()},k=B.map(K=>({label:K.label,value:K.label,color:L||K.color?K.color:"transparent"}));return h.jsx(Ln,{style:{minWidth:b,maxWidth:Math.max(b,200)},title:j?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:P,multiple:j,onChange:async K=>{const Z=w.serializeListOptions(K),ee={unitId:s,subUnitId:l,range:{startColumn:i,endColumn:i,startRow:o,endRow:o},value:{v:Z,p:null,f:null,si:null}};D.isVisible()&&g.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:W.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),m(Z),j||a(),D.isVisible().visible&&await g.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:W.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),g.executeCommand(X.SetRangeValuesCommand.id,ee)},options:k,onEdit:x,filter:u,location:t})}const Pn="univer-data-validation-options-button",An="univer-data-validation-options-button-icon",Qe={dataValidationOptionsButton:Pn,dataValidationOptionsButtonIcon:An};function jn(e){var u;const t=f.useDependency(r.LocaleService),a=f.useDependency(f.ComponentManager),{value:n,onChange:o,extraComponent:i}=e,[s,l]=E.useState(!1),d=i?a.get(i):null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:Qe.dataValidationOptionsButton,onClick:()=>l(!s),children:[t.t("dataValidation.panel.options"),s?h.jsx(Pt,{className:Qe.dataValidationOptionsButtonIcon}):h.jsx(Ot,{className:Qe.dataValidationOptionsButtonIcon})]}),s&&h.jsxs(h.Fragment,{children:[d?h.jsx(d,{value:n,onChange:o}):null,h.jsx(T.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:h.jsxs(T.RadioGroup,{value:`${(u=n.errorStyle)!=null?u:r.DataValidationErrorStyle.WARNING}`,onChange:p=>o({...n,errorStyle:+p}),children:[h.jsx(T.Radio,{value:`${r.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),h.jsx(T.Radio,{value:`${r.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),h.jsx(T.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:h.jsx(T.Checkbox,{checked:n.showErrorMessage,onChange:()=>o({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?h.jsx(T.FormLayout,{children:h.jsx(T.Input,{value:n.error,onChange:p=>o({...n,error:p})})}):null]})]})}const Fn="univer-data-validation-detail",xn="univer-data-validation-detail-form-item",kn="univer-data-validation-detail-buttons",Un="univer-data-validation-detail-button",ye={dataValidationDetail:Fn,dataValidationDetailFormItem:xn,dataValidationDetailButtons:kn,dataValidationDetailButton:Un},Nn=e=>r.debounce(async(t,a,n,o)=>{const i=await e.executeCommand(t,a,n);o==null||o(i)},1e3);function Bn(e,t,a){var n,o,i,s;return t?((o=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:o.getSheetId())||"":((s=(i=e.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Wn(){var re;const[e,t]=E.useState(0),a=f.useDependency(ue),n=f.useObservable(a.activeRule$,a.activeRule),{unitId:o,subUnitId:i,rule:s}=n||{},l=s.uid,d=f.useDependency(Q.DataValidatorRegistryService),u=f.useDependency(r.IUniverInstanceService),p=f.useDependency(f.ComponentManager),g=f.useDependency(r.ICommandService),c=f.useDependency(Q.DataValidationModel),_=f.useDependency(r.LocaleService),[m,D]=E.useState(s),V=d.getValidatorItem(m.type),[S,R]=E.useState(!1),y=d.getValidatorsByScope(Q.DataValidatorRegistryScope.SHEET),[b,I]=E.useState(()=>m.ranges.map(A=>({unitId:"",sheetId:"",range:A}))),C=E.useMemo(()=>Nn(g),[g]),[v,L]=E.useState(!1),j=E.useRef({}),[B,F]=E.useState(!1),P=f.useDependency(X.SheetsSelectionsService);if(E.useEffect(()=>()=>{const A=P.getCurrentLastSelection();A&&P.setSelections([A])},[P]),E.useEffect(()=>{g.onCommandExecuted(A=>{(A.id===r.UndoCommand.id||A.id===r.RedoCommand.id)&&setTimeout(()=>{const M=c.getRuleById(o,i,l);t(H=>H+1),M&&(D(M),I(M.ranges.map(H=>({unitId:"",sheetId:"",range:H}))))},20)})},[g,c,l,i,o]),!V)return null;const x=V.operators,k=V.operatorNames,U=m.operator?Q.TWO_FORMULA_OPERATOR_COUNT.includes(m.operator):!1,$=()=>{!m.ranges.length||v||(V.validatorFormula(m,o,i).success?a.setActiveRule(null):R(!0))},G=f.useEvent(A=>{const M=A.split(",").filter(Boolean).map(ct.deserializeRangeWithSheet).map(z=>{const ge=z.sheetName;if(ge){const Kt=Bn(u,z.unitId,ge);return{...z,sheetId:Kt}}return{...z,sheetId:""}});if(r.isUnitRangesEqual(M,b))return;I(M);const H=M.filter(z=>(!z.unitId||z.unitId===o)&&(!z.sheetId||z.sheetId===i)).map(z=>z.range);if(D({...m,ranges:H}),H.length===0)return;const Y={unitId:o,subUnitId:i,ruleId:l,ranges:H};C(w.UpdateSheetDataValidationRangeCommand.id,Y)}),q=A=>{if(r.shallowEqual(A,Q.getRuleSetting(m)))return;D({...m,...A});const M={unitId:o,subUnitId:i,ruleId:l,setting:A};C(w.UpdateSheetDataValidationSettingCommand.id,M,void 0)},K=async()=>{await g.executeCommand(w.RemoveSheetDataValidationCommand.id,{ruleId:l,unitId:o,subUnitId:i}),a.setActiveRule(null)},Z={type:m.type,operator:m.operator,formula1:m.formula1,formula2:m.formula2,allowBlank:m.allowBlank},ee=A=>{const M=d.getValidatorItem(A);if(!M)return;const H=M.operators,Y=c.getRuleById(o,i,l),z=A===(Y==null?void 0:Y.type)||A.includes("list")&&(Y!=null&&Y.type.includes("list"))?{...Y,type:A}:{...m,type:A,operator:H[0],formula1:void 0,formula2:void 0};D(z),g.executeCommand(w.UpdateSheetDataValidationSettingCommand.id,{unitId:o,subUnitId:i,ruleId:m.uid,setting:Q.getRuleSetting(z)})},te=p.get(V.formulaInput),ne=E.useMemo(()=>b.map(A=>ct.serializeRange(A.range)).join(","),[]),ie=Q.getRuleOptions(m),oe=A=>{r.shallowEqual(A,Q.getRuleOptions(m))||(D({...m,...A}),C(w.UpdateSheetDataValidationOptionsCommand.id,{unitId:o,subUnitId:i,ruleId:l,options:A}))};return f.useSidebarClick(A=>{var H;const M=(H=j.current)==null?void 0:H.handleOutClick;M&&M(A,()=>F(!1))}),h.jsxs("div",{className:ye.dataValidationDetail,children:[h.jsx(T.FormLayout,{label:_.t("dataValidation.panel.range"),error:!m.ranges.length||v?_.t("dataValidation.panel.rangeError"):"",children:h.jsx(mt.RangeSelector,{unitId:o,subUnitId:i,initValue:ne,onChange:G,onFocus:()=>F(!0),isFocus:B,actions:j.current,onVerify:A=>L(!A)})}),h.jsx(T.FormLayout,{label:_.t("dataValidation.panel.type"),children:h.jsx(T.Select,{options:y==null?void 0:y.map(A=>({label:_.t(A.title),value:A.id})),value:m.type,onChange:ee,className:ye.dataValidationDetailFormItem})}),x!=null&&x.length?h.jsx(T.FormLayout,{label:_.t("dataValidation.panel.operator"),children:h.jsx(T.Select,{options:x.map((A,M)=>({value:`${A}`,label:k[M]})),value:`${m.operator}`,onChange:A=>{q({...Z,operator:A})},className:ye.dataValidationDetailFormItem})}):null,te?h.jsx(te,{isTwoFormula:U,value:{formula1:m.formula1,formula2:m.formula2},onChange:A=>{q({...Z,...A})},showError:S,validResult:V.validatorFormula(m,o,i),unitId:o,subUnitId:i,ruleId:l},e+m.type):null,h.jsx(T.FormLayout,{children:h.jsx(T.Checkbox,{checked:(re=m.allowBlank)!=null?re:!0,onChange:()=>{var A;return q({...Z,allowBlank:!((A=m.allowBlank)==null||A)})},children:_.t("dataValidation.panel.allowBlank")})}),h.jsx(jn,{value:ie,onChange:oe,extraComponent:V.optionsInput}),h.jsxs("div",{className:ye.dataValidationDetailButtons,children:[h.jsx(T.Button,{className:ye.dataValidationDetailButton,onClick:K,children:_.t("dataValidation.panel.removeRule")}),h.jsx(T.Button,{className:ye.dataValidationDetailButton,type:"primary",onClick:$,children:_.t("dataValidation.panel.done")})]})]})}const $n="univer-data-validation-item-container",Hn="univer-data-validation-item-title",Yn="univer-data-validation-item-content",Xn="univer-data-validation-item-icon",je={dataValidationItemContainer:$n,dataValidationItemTitle:Hn,dataValidationItemContent:Yn,dataValidationItemIcon:Xn},zn=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:o,disable:i}=e,s=f.useDependency(Q.DataValidatorRegistryService),l=f.useDependency(r.ICommandService),d=f.useDependency(N.IMarkSelectionService),u=s.getValidatorItem(t.type),p=E.useRef(void 0),[g,c]=E.useState(!1),_=m=>{l.executeCommand(w.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:o}),m.stopPropagation()};return E.useEffect(()=>()=>{var m;p.current&&((m=p.current)==null||m.forEach(D=>{D&&d.removeShape(D)}))},[d]),h.jsxs("div",{className:je.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{i||(c(!0),p.current=t.ranges.map(m=>d.addShape({range:m,style:{fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:null})))},onMouseLeave:()=>{var m;c(!1),(m=p.current)==null||m.forEach(D=>{D&&d.removeShape(D)}),p.current=void 0},children:[h.jsx("div",{className:je.dataValidationItemTitle,children:u==null?void 0:u.generateRuleName(t)}),h.jsx("div",{className:je.dataValidationItemContent,children:t.ranges.map(m=>ct.serializeRange(m)).join(",")}),g?h.jsx("div",{className:je.dataValidationItemIcon,onClick:_,children:h.jsx(vt,{})}):null]})},Kn="univer-data-validation-list",Gn="univer-data-validation-list-buttons",qn="univer-data-validation-list-button",Fe={dataValidationList:Kn,dataValidationListButtons:Gn,dataValidationListButton:qn};function Zn(){const e=f.useDependency(r.IUniverInstanceService),t=f.useObservable(()=>e.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return t?h.jsx(Jn,{workbook:t}):null}function Jn(e){const t=f.useDependency(w.SheetDataValidationModel),a=f.useDependency(r.IUniverInstanceService),n=f.useDependency(r.ICommandService),o=f.useDependency(r.Injector),i=f.useDependency(ue),s=f.useDependency(r.LocaleService),[l,d]=E.useState([]),{workbook:u}=e,p=f.useObservable(u.activeSheet$,void 0,!0),g=u.getUnitId(),c=p==null?void 0:p.getSheetId();E.useEffect(()=>{d(t.getRules(g,c));const R=t.ruleChange$.subscribe(y=>{y.unitId===g&&y.subUnitId===c&&d(t.getRules(g,c))});return()=>{R.unsubscribe()}},[g,c,t]);const _=async()=>{const R=w.createDefaultNewRule(o),y={unitId:g,subUnitId:c,rule:R};await n.executeCommand(w.AddSheetDataValidationCommand.id,y),i.setActiveRule({unitId:g,subUnitId:c,rule:R})},m=()=>{n.executeCommand(w.RemoveSheetAllDataValidationCommand.id,{unitId:g,subUnitId:c})},V=(R=>{const y=a.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET),b=y.getActiveSheet(),I=y.getUnitId(),C=b.getSheetId();return R.map(L=>X.checkRangesEditablePermission(o,I,C,L.ranges)?{...L}:{...L,disable:!0})})(l),S=V==null?void 0:V.some(R=>R.disable);return h.jsxs("div",{className:Fe.dataValidationList,children:[V==null?void 0:V.map(R=>{var y;return h.jsx(zn,{unitId:g,subUnitId:c,onClick:()=>{R.disable||i.setActiveRule({unitId:g,subUnitId:c,rule:R})},rule:R,disable:(y=R.disable)!=null?y:!1},R.uid)}),h.jsxs("div",{className:Fe.dataValidationListButtons,children:[l.length&&!S?h.jsx(T.Button,{className:Fe.dataValidationListButton,onClick:m,children:s.t("dataValidation.panel.removeAll")}):null,h.jsx(T.Button,{className:Fe.dataValidationListButton,type:"primary",onClick:_,children:s.t("dataValidation.panel.add")})]})]})}const Qn=()=>{const e=f.useDependency(ue),t=f.useObservable(e.activeRule$,e.activeRule);return t?h.jsx(Wn,{},t.rule.uid):h.jsx(Zn,{})},qe="data-validation.list.dropdown",_t="data-validation.date.dropdown",Ze={type:r.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(r.IUniverInstanceService),a=X.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:o}=a,i=w.createDefaultNewRule(e),s=e.get(r.ICommandService),l=n.getUnitId(),d=o.getSheetId(),u={rule:i,unitId:l,subUnitId:d};return s.syncExecuteCommand(w.AddSheetDataValidationCommand.id,u)?(s.syncExecuteCommand(De.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var ea=Object.getOwnPropertyDescriptor,ta=(e,t,a,n)=>{for(var o=n>1?void 0:n?ea(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Re=(e,t)=>(a,n)=>t(a,n,e);const Se="SHEET_DATA_VALIDATION_ALERT";let Ae=class extends r.Disposable{constructor(e,t,a,n,o,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=o,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(le.debounceTime(100)).subscribe(e=>{var t;if(e){const a=this._univerInstanceService.getUnit(e.location.unitId,r.UniverInstanceType.UNIVER_SHEET),n=a.getSheetBySheetId(e.location.subUnitId);if(!n)return;const o=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!o){this._cellAlertManagerService.removeAlert(Se);return}if(this._dataValidationModel.validator(o,{...e.location,workbook:a,worksheet:n})===r.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Se),l=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(l&&l.row===e.location.row&&l.col===e.location.col&&l.subUnitId===e.location.subUnitId&&l.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(Se);return}const d=this._dataValidationModel.getValidator(o.type);if(!d){this._cellAlertManagerService.removeAlert(Se);return}this._cellAlertManagerService.showAlert({type:N.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:d==null?void 0:d.getRuleFinalError(o,e.location),location:e.location,width:200,height:74,key:Se});return}}this._cellAlertManagerService.removeAlert(Se)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(Se)}))}};Ae=ta([Re(0,r.Inject(N.HoverManagerService)),Re(1,r.Inject(N.CellAlertManagerService)),Re(2,r.IUniverInstanceService),Re(3,r.Inject(r.LocaleService)),Re(4,f.IZenZoneService),Re(5,r.Inject(w.SheetDataValidationModel))],Ae);var na=Object.getOwnPropertyDescriptor,aa=(e,t,a,n)=>{for(var o=n>1?void 0:n?na(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},et=(e,t)=>(a,n)=>t(a,n,e);let we=class extends r.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,o)=>{const{source:i,target:s,unitId:l,subUnitId:d}=n,u=this._sheetDataValidationModel.getRuleObjectMatrix(l,d).clone(),p=N.virtualizeDiscreteRanges([i,s]),[g,c]=p.ranges,{mapFunc:_}=p,m={row:g.startRow,col:g.startColumn},D=N.getAutoFillRepeatRange(g,c),V=new r.ObjectMatrix,S=new Set;D.forEach(C=>{const v=C.repeatStartCell,L=C.relativeRange,j={startRow:m.row,startColumn:m.col,endColumn:m.col,endRow:m.row},B={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row};r.Range.foreach(L,(F,P)=>{const x=r.Rectangle.getPositionRange({startRow:F,startColumn:P,endColumn:P,endRow:F},j),{row:k,col:U}=_(x.startRow,x.startColumn),$=this._sheetDataValidationModel.getRuleIdByLocation(l,d,k,U)||"",G=r.Rectangle.getPositionRange({startRow:F,startColumn:P,endColumn:P,endRow:F},B),{row:q,col:K}=_(G.startRow,G.startColumn);V.setValue(q,K,$),S.add($)})});const R=Array.from(S).map(C=>({id:C,ranges:r.queryObjectMatrix(V,v=>v===C)}));u.addRangeRules(R);const y=u.diff(this._sheetDataValidationModel.getRules(l,d)),{redoMutations:b,undoMutations:I}=w.getDataValidationDiffMutations(l,d,y,this._injector,"patched",o===N.APPLY_TYPE.ONLY_FORMAT);return{undos:I,redos:b}},a={id:w.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:o,unitId:i,subUnitId:s}=n;for(const l of o.rows)for(const d of o.cols){const u=this._sheetDataValidationModel.getRuleByLocation(i,s,l,d);if(u&&u.type===r.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(N.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,o,i)=>i===N.APPLY_TYPE.COPY||i===N.APPLY_TYPE.ONLY_FORMAT||i===N.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};we=aa([et(0,N.IAutoFillService),et(1,r.Inject(w.SheetDataValidationModel)),et(2,r.Inject(r.Injector))],we);var oa=Object.getOwnPropertyDescriptor,ia=(e,t,a,n)=>{for(var o=n>1?void 0:n?oa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},tt=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends r.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:w.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,o)=>{const{copyType:i=N.COPY_TYPE.COPY,pasteType:s}=o,{range:l}=t||{},{range:d,unitId:u,subUnitId:p}=a;return this._generateMutations(d,{copyType:i,pasteType:s,copyRange:l,unitId:u,subUnitId:p})}})}_collect(t,a,n){const o=new r.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:o};const i=this._injector.invoke(d=>N.rangeToDiscreteRange(n,d,t,a));if(!i)return;const{rows:s,cols:l}=i;s.forEach((d,u)=>{l.forEach((p,g)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(t,a,d,p);o.setValue(u,g,c!=null?c:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===N.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:o,subUnitId:i}=this._copyInfo;if(a.unitId!==o||i!==a.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),l=new r.ObjectMatrix,d=new Set,{ranges:[u,p],mapFunc:g}=N.virtualizeDiscreteRanges([a.copyRange,t]),c=N.getRepeatRange(u,p,!0),_=new Map;c.forEach(({startRange:S})=>{var R;(R=this._copyInfo)==null||R.matrix.forValue((y,b,I)=>{const C=r.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:b,endColumn:b},S),v=`${i}-${I}`,L=this._sheetDataValidationModel.getRuleById(o,i,I);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,v)&&L&&_.set(v,{...L,uid:v});const{row:j,col:B}=g(C.startRow,C.startColumn);d.add(v),l.setValue(j,B,v)})});const m=Array.from(d).map(S=>({id:S,ranges:r.queryObjectMatrix(l,R=>R===S)}));s.addRangeRules(m);const{redoMutations:D,undoMutations:V}=w.getDataValidationDiffMutations(a.unitId,a.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),_.values()),this._injector,"patched",!1);return{redos:D,undos:V}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(o,i).clone(),l=new r.ObjectMatrix,d=new Set,{ranges:[u,p],mapFunc:g}=N.virtualizeDiscreteRanges([a.copyRange,t]);N.getRepeatRange(u,p,!0).forEach(({startRange:V})=>{var S;(S=this._copyInfo)==null||S.matrix.forValue((R,y,b)=>{const I=r.Rectangle.getPositionRange({startRow:R,endRow:R,startColumn:y,endColumn:y},V),{row:C,col:v}=g(I.startRow,I.startColumn);l.setValue(C,v,b),d.add(b)})});const _=Array.from(d).map(V=>({id:V,ranges:r.queryObjectMatrix(l,S=>S===V)}));s.addRangeRules(_);const{redoMutations:m,undoMutations:D}=w.getDataValidationDiffMutations(o,i,s.diff(this._sheetDataValidationModel.getRules(o,i)),this._injector,"patched",!1);return{redos:m,undos:D}}}};Ee=ia([tt(0,N.ISheetClipboardService),tt(1,r.Inject(w.SheetDataValidationModel)),tt(2,r.Inject(r.Injector))],Ee);var ra=Object.getOwnPropertyDescriptor,sa=(e,t,a,n)=>{for(var o=n>1?void 0:n?ra(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},nt=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends r.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===w.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===w.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=sa([nt(0,r.Inject(r.LocaleService)),nt(1,r.ICommandService),nt(2,r.Inject(X.SheetPermissionCheckController))],Me);const kt="data-validation-single",Ut="sheet.menu.data-validation";function la(e){return{id:Ut,type:f.MenuItemType.SUBITEMS,icon:kt,tooltip:"dataValidation.title",hidden$:f.getMenuHiddenObservable(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[X.WorkbookEditablePermission],worksheetTypes:[X.WorksheetSetCellStylePermission,X.WorksheetEditPermission],rangeTypes:[X.RangeProtectionPermissionEditPoint]})}}function da(e){return{id:De.id,title:"dataValidation.panel.title",type:f.MenuItemType.BUTTON}}function ca(e){return{id:Ze.id,title:"dataValidation.panel.add",type:f.MenuItemType.BUTTON}}const ua={[f.RibbonStartGroup.FORMULAS_INSERT]:{[Ut]:{order:9,menuItemFactory:la,[De.id]:{order:0,menuItemFactory:da},[Ze.id]:{order:1,menuItemFactory:ca}}}};var ha=Object.getOwnPropertyDescriptor,Nt=(e,t,a,n)=>{for(var o=n>1?void 0:n?ha(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},J=(e,t)=>(a,n)=>t(a,n,e);const Bt={tr:{size:6,color:"#fe4b4b"}};let be=class extends r.RxDisposable{constructor(e,t,a,n,o,i,s,l,d,u,p){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=o,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=l,this._sheetInterceptorService=d,this._dataValidationCacheService=u,this._editorBridgeService=p,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(ua)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var a;if(!e.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:o,row:i,column:s}=t,l=this._univerInstanceService.getUniverSheetInstance(n);if(!l)return;const d=this._sheetDataValidationModel.getRuleByLocation(n,o,i,s);if(!d)return;const u=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!(u!=null&&u.dropdown))return;const p=l.getActiveSheet();if(!p)return;const g=this._dropdownManagerService.activeDropdown,c=g==null?void 0:g.location;if(c&&c.unitId===n&&c.subUnitId===o&&c.row===i&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:o,row:i,col:s,workbook:l,worksheet:p},componentKey:u.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var S,R,y,b,I;const{row:n,col:o,unitId:i,subUnitId:s,workbook:l,worksheet:d}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,o);if(!u)return a(e);const p=this._sheetDataValidationModel.getRuleById(i,s,u);if(!p)return a(e);const g=(S=this._dataValidationCacheService.getValue(i,s,n,o))!=null?S:r.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),_=t.rawData;let m;const D={get value(){var C;return m!==void 0||(m=(C=w.getCellValueOrigin(_))!=null?C:null),m}},V={get value(){var C;return`${(C=D.value)!=null?C:""}`}};return a({...e,markers:{...e==null?void 0:e.markers,...g===r.DataValidationStatus.INVALID?Bt:null},customRender:[...(R=e==null?void 0:e.customRender)!=null?R:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((b=c==null?void 0:c.skipDefaultFontRender)==null?void 0:b.call(c,p,D.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,V.value,{get style(){const C=l.getStyles();return(typeof(e==null?void 0:e.s)=="string"?C.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,o)},interceptorAutoHeight:()=>{var j,B,F,P,x,k;const C=(B=(j=this._renderManagerService.getRenderById(i))==null?void 0:j.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:B.skeleton;if(!C)return;const v=C.worksheet.getMergedCell(n,o),L={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((F=v==null?void 0:v.startRow)!=null?F:n,(P=v==null?void 0:v.startColumn)!=null?P:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(k=(x=c==null?void 0:c.canvasRender)==null?void 0:x.calcCellAutoHeight)==null?void 0:k.call(x,L)},interceptorAutoWidth:()=>{var j,B,F,P,x,k;const C=(B=(j=this._renderManagerService.getRenderById(i))==null?void 0:j.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:B.skeleton;if(!C)return;const v=C.worksheet.getMergedCell(n,o),L={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((F=v==null?void 0:v.startRow)!=null?F:n,(P=v==null?void 0:v.startColumn)!=null?P:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(k=(x=c==null?void 0:c.canvasRender)==null?void 0:x.calcCellAutoWidth)==null?void 0:k.call(x,L)},coverable:((I=e==null?void 0:e.coverable)!=null?I:!0)&&!(p.type===r.DataValidationType.LIST||p.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(le.filter(e=>e.source==="command"),le.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(a=>{var n;(a.rule.type===r.DataValidationType.LIST_MULTIPLE||a.rule.type===r.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(a.redos,this._commandService)}})}};be=Nt([J(0,r.ICommandService),J(1,f.IMenuManagerService),J(2,W.IRenderManagerService),J(3,r.IUniverInstanceService),J(4,r.Inject(N.AutoHeightController)),J(5,r.Inject(me)),J(6,r.Inject(w.SheetDataValidationModel)),J(7,r.Inject(Q.DataValidatorRegistryService)),J(8,r.Inject(X.SheetInterceptorService)),J(9,r.Inject(w.DataValidationCacheService)),J(10,r.Optional(N.IEditorBridgeService))],be);let yt=class extends r.RxDisposable{constructor(e,t,a,n,o,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=o,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var V,S,R,y,b;const{row:n,col:o,unitId:i,subUnitId:s,workbook:l,worksheet:d}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,o);if(!u)return a(e);const p=this._sheetDataValidationModel.getRuleById(i,s,u);if(!p)return a(e);const g=(V=this._dataValidationCacheService.getValue(i,s,n,o))!=null?V:r.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),_=d.getCellRaw(n,o),m=w.getCellValueOrigin(_),D=`${m!=null?m:""}`;return a({...e,markers:{...e==null?void 0:e.markers,...g===r.DataValidationStatus.INVALID?Bt:null},customRender:[...(S=e==null?void 0:e.customRender)!=null?S:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((R=e==null?void 0:e.fontRenderExtension)==null?void 0:R.isSkip)||((y=c==null?void 0:c.skipDefaultFontRender)==null?void 0:y.call(c,p,m,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,D,{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,o)},interceptorAutoHeight:()=>{var L,j,B,F,P,x;const I=(j=(L=this._renderManagerService.getRenderById(i))==null?void 0:L.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:j.skeleton;if(!I)return;const C=I.worksheet.getMergedCell(n,o),v={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((B=C==null?void 0:C.startRow)!=null?B:n,(F=C==null?void 0:C.startColumn)!=null?F:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(x=(P=c==null?void 0:c.canvasRender)==null?void 0:P.calcCellAutoHeight)==null?void 0:x.call(P,v)},coverable:((b=e==null?void 0:e.coverable)!=null?b:!0)&&!(p.type===r.DataValidationType.LIST||p.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(le.filter(e=>e.source==="command"),le.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(a.redos,this._commandService)}})}};yt=Nt([J(0,r.ICommandService),J(1,W.IRenderManagerService),J(2,r.Inject(N.AutoHeightController)),J(3,r.Inject(Q.DataValidatorRegistryService)),J(4,r.Inject(X.SheetInterceptorService)),J(5,r.Inject(w.SheetDataValidationModel)),J(6,r.Inject(w.DataValidationCacheService))],yt);var pa=Object.getOwnPropertyDescriptor,ga=(e,t,a,n)=>{for(var o=n>1?void 0:n?pa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Rt=(e,t)=>(a,n)=>t(a,n,e);let Ye=class extends r.Disposable{constructor(e,t,a){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const a=new Set;t.forEach(o=>{a.add(o.subUnitId)}),a.forEach(o=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(o))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(r.bufferDebounceTime(16)).subscribe(e))}};Ye=ga([Rt(1,r.Inject(w.SheetDataValidationModel)),Rt(2,r.Inject(N.SheetSkeletonManagerService))],Ye);const ma="univer-data-validation-formula",va="univer-data-validation-formula-and",fa="univer-data-validation-formula-list-item",Sa="univer-data-validation-formula-list-item-icon",_a="univer-data-validation-formula-list-item-drag",Ia="univer-data-validation-formula-list-add",Ca="univer-data-validation-formula-color-select",Da="univer-data-validation-formula-color-select-panel",ya="univer-data-validation-formula-color-item",ae={dataValidationFormula:ma,dataValidationFormulaAnd:va,dataValidationFormulaListItem:fa,dataValidationFormulaListItemIcon:Sa,dataValidationFormulaListItemDrag:_a,dataValidationFormulaListAdd:Ia,dataValidationFormulaColorSelect:Ca,dataValidationFormulaColorSelectPanel:Da,dataValidationFormulaColorItem:ya},Ra=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:o,validResult:i}=e,s=f.useDependency(r.LocaleService),l=o?i==null?void 0:i.formula1:"",d=o?i==null?void 0:i.formula2:"";return t?h.jsxs(h.Fragment,{children:[h.jsx(T.FormLayout,{error:l,children:h.jsx(T.Input,{className:ae.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({...a,formula1:u})}})}),h.jsx("div",{className:ae.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),h.jsx(T.FormLayout,{error:d,children:h.jsx(T.Input,{className:ae.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:u=>{n==null||n({...a,formula2:u})}})})]}):h.jsx(T.FormLayout,{error:l,children:h.jsx(T.Input,{className:ae.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({formula1:u})}})})};function Va(e){const{value:t,onChange:a,showError:n,validResult:o}=e,i=f.useDependency(r.LocaleService),s=n?o==null?void 0:o.formula1:"",l=n?o==null?void 0:o.formula2:"",[d,u]=E.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return h.jsxs(h.Fragment,{children:[h.jsx(T.FormLayout,{children:h.jsx(T.Checkbox,{checked:d,onChange:p=>{p?u(!0):(u(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),d?h.jsx(T.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:h.jsx(T.Input,{className:ae.dataValidationFormula,placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:p=>{a==null||a({...t,formula1:p||void 0})}})}):null,d?h.jsx(T.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:l,children:h.jsx(T.Input,{className:ae.dataValidationFormula,placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:p=>{a==null||a({...t,formula2:p||void 0})}})}):null]})}function wa(e){var g;const{unitId:t,subUnitId:a,value:n,onChange:o,showError:i,validResult:s}=e,l=i?s==null?void 0:s.formula1:void 0,d=E.useRef({}),[u,p]=E.useState(!1);return f.useSidebarClick(c=>{var m;const _=(m=d.current)==null?void 0:m.handleOutClick;_&&_(c,()=>p(!1))}),h.jsx(mt.FormulaEditor,{initValue:(g=n==null?void 0:n.formula1)!=null?g:"=",unitId:t,subUnitId:a,isFocus:u,onChange:c=>{const _=(c!=null?c:"").trim();_!==(n==null?void 0:n.formula1)&&(o==null||o({...n,formula1:_}))},errorText:l,onFocus:()=>p(!0),actions:d.current,isSupportAcrossSheet:!0})}function Wt(e){var t,a,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(a=Wt(e[t]))&&(n&&(n+=" "),n+=a)}else for(a in e)e[a]&&(n&&(n+=" "),n+=a);return n}function Ea(){for(var e,t,a=0,n="",o=arguments.length;a<o;a++)(e=arguments[a])&&(t=Wt(e))&&(n&&(n+=" "),n+=t);return n}const Ma=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],ba=e=>{const{value:t,onChange:a,disabled:n}=e,[o,i]=E.useState(!1);return h.jsx(T.Select,{disabled:n,open:o,onDropdownVisibleChange:i,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ae.dataValidationFormulaColorSelect,value:t,onChange:a,labelRender:s=>h.jsx("div",{className:ae.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>h.jsx("div",{className:ae.dataValidationFormulaColorSelectPanel,children:Ma.map(s=>h.jsx("div",{onClick:()=>{a(s),i(!1)},className:ae.dataValidationFormulaColorItem,style:{background:s}},s))})})},Vt=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:o,onItemDelete:i}=a;return h.jsxs("div",{className:ae.dataValidationFormulaListItem,style:n,children:[t.isRef?null:h.jsx("div",{className:Ea(ae.dataValidationFormulaListItemDrag,"draggableHandle"),children:h.jsx(At,{})}),h.jsx(ba,{value:t.color,onChange:s=>{o(t.id,t.label,s)}}),h.jsx(T.Input,{disabled:t.isRef,value:t.label,onChange:s=>{o(t.id,s,t.color)}}),t.isRef?null:h.jsx("div",{className:ae.dataValidationFormulaListItemIcon,children:h.jsx(vt,{onClick:()=>i(t.id)})})]})};function Ta(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:o,validResult:i,showError:s,ruleId:l}=e,{formula1:d="",formula2:u=""}=t||{},p=E.useRef(null),[g,c]=E.useState(()=>r.isFormulaString(d)?"1":"0"),[_,m]=E.useState(g==="1"?d:"="),[D,V]=E.useState(g==="1"?d:"="),S=f.useDependency(r.LocaleService),R=f.useDependency(Q.DataValidatorRegistryService),y=f.useDependency(Q.DataValidationModel),b=f.useDependency(w.DataValidationFormulaController),[I,C]=E.useState(()=>u.split(",")),v=R.getValidatorItem(r.DataValidationType.LIST),[L,j]=E.useState([]),[B,F]=E.useState(""),P=s?i==null?void 0:i.formula1:"",x=E.useMemo(()=>y.ruleChange$.pipe(le.debounceTime(16)),[]),k=f.useObservable(x),U=f.useEvent(a);E.useEffect(()=>{(async()=>{await new Promise(Y=>{setTimeout(()=>Y(!0),100)});const M=y.getRuleById(n,o,l),H=M==null?void 0:M.formula1;if(r.isFormulaString(H)&&v&&M){const Y=await v.getListAsync(M,n,o);j(Y)}})()},[y,k,v,l,o,n]),E.useEffect(()=>{r.isFormulaString(d)&&d!==D&&(m(d),V(D))},[D,d]);const[$,G]=E.useState(()=>{const M=g!=="1"?w.deserializeListOptions(d):[],H=u.split(",");return M.map((Y,z)=>({label:Y,color:H[z]||Ce,isRef:!1,id:r.Tools.generateRandomId(4)}))}),q=(M,H,Y)=>{const z=$.find(ge=>ge.id===M);z&&(z.label=H,z.color=Y,G([...$]))},K=M=>{const H=$.findIndex(Y=>Y.id===M);H!==-1&&($.splice(H,1),G([...$]))},Z=u.split(","),ee=E.useMemo(()=>L.map((M,H)=>({label:M,color:Z[H]||Ce,id:`${H}`,isRef:!0})),[Z,L]),te=(M,H,Y)=>{const z=[...I];z[+M]=Y,C(z),U({formula1:d,formula2:z.join(",")})},ne=()=>{G([...$,{label:"",color:Ce,isRef:!1,id:r.Tools.generateRandomId(4)}])};E.useEffect(()=>{if(g==="1")return;const M=new Set,H=[];$.map(Y=>({labelList:Y.label.split(","),item:Y})).forEach(({item:Y,labelList:z})=>{z.forEach(ge=>{M.has(ge)||(M.add(ge),H.push({label:ge,color:Y.color}))})}),U({formula1:w.serializeListOptions(H.map(Y=>Y.label)),formula2:H.map(Y=>Y.color===Ce?"":Y.color).join(",")})},[$,U,g,D,I]);const ie=f.useEvent(async M=>{if(!r.isFormulaString(M)){U==null||U({formula1:"",formula2:u});return}b.getFormulaRefCheck(M)?(U==null||U({formula1:r.isFormulaString(M)?M:"",formula2:u}),F("")):(U==null||U({formula1:"",formula2:u}),m("="),F(S.t("dataValidation.validFail.formulaError")))}),oe=E.useRef({}),[re,A]=E.useState(!1);return f.useSidebarClick(M=>{var Y;const H=(Y=oe.current)==null?void 0:Y.handleOutClick;H&&H(M,()=>A(!1))}),h.jsxs(h.Fragment,{children:[h.jsx(T.FormLayout,{label:S.t("dataValidation.list.options"),children:h.jsxs(T.RadioGroup,{value:g,onChange:M=>{c(M),m(D),M==="1"&&U({formula1:D==="="?"":D,formula2:I.join(",")})},children:[h.jsx(T.Radio,{value:"0",children:S.t("dataValidation.list.customOptions")}),h.jsx(T.Radio,{value:"1",children:S.t("dataValidation.list.refOptions")})]})}),g==="1"?h.jsxs(h.Fragment,{children:[h.jsx(mt.FormulaEditor,{initValue:_,unitId:n,subUnitId:o,isFocus:re,onChange:(M="")=>{const H=(M!=null?M:"").trim();V(H),ie(H)},errorText:P||B||void 0,onFocus:()=>A(!0),actions:oe.current,isSupportAcrossSheet:!0}),h.jsx("div",{ref:p,style:{marginTop:"12px"},children:ee.map(M=>h.jsx(Vt,{item:M,commonProps:{onItemChange:te},style:{marginBottom:12}},M.id))})]}):h.jsx(T.FormLayout,{error:P,children:h.jsxs("div",{ref:p,style:{marginTop:"-12px"},children:[h.jsx(T.DraggableList,{list:$,onListChange:G,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:M=>h.jsx(Vt,{item:M,commonProps:{onItemChange:q,onItemDelete:K}},M.id),idKey:"id"}),h.jsxs("a",{className:ae.dataValidationFormulaListAdd,onClick:ne,children:[h.jsx(Lt,{}),S.t("dataValidation.list.add")]})]})})]})}const $t="data-validation.custom-formula-input",Je="data-validation.formula-input",It="data-validation.list-formula-input",Ht="data-validation.checkbox-formula-input",La=[[$t,wa],[Je,Ra],[It,Ta],[Ht,Va]],Oa="LIST_RENDER_MODE_OPTION_INPUT";function Xe(e){var o;const{value:t,onChange:a}=e,n=f.useDependency(r.LocaleService);return h.jsx(T.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:h.jsxs(T.RadioGroup,{value:`${(o=t.renderMode)!=null?o:r.DataValidationRenderMode.CUSTOM}`,onChange:i=>a({...t,renderMode:+i}),children:[h.jsx(T.Radio,{value:`${r.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),h.jsx(T.Radio,{value:`${r.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),h.jsx(T.Radio,{value:`${r.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}Xe.componentKey=Oa;const Pa="DATE_SHOW_TIME_OPTION";function ze(e){var o;const{value:t,onChange:a}=e,n=f.useDependency(r.LocaleService);return h.jsx(T.FormLayout,{children:h.jsx(T.Checkbox,{checked:(o=t.bizInfo)==null?void 0:o.showTime,onChange:i=>{a({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:n.t("dataValidation.showTime.label")})})}ze.componentKey=Pa;var Aa=Object.getOwnPropertyDescriptor,ja=(e,t,a,n)=>{for(var o=n>1?void 0:n?Aa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Oe=(e,t)=>(a,n)=>t(a,n,e);const xe=6;let ut=class{constructor(e,t,a,n,o){this._commandService=e,this._formulaService=t,this._themeService=a,this._renderManagerService=n,this._dataValidationModel=o}_calc(e,t){var u,p,g;const{vt:a,ht:n}=t||{},o=e.endX-e.startX-xe*2,i=e.endY-e.startY,s=((u=t==null?void 0:t.fs)!=null?u:10)*1.6;let l=0,d=0;switch(a){case r.VerticalAlign.TOP:d=0;break;case r.VerticalAlign.BOTTOM:d=0+(i-s);break;default:d=0+(i-s)/2;break}switch(n){case r.HorizontalAlign.LEFT:l=xe;break;case r.HorizontalAlign.RIGHT:l=xe+(o-s);break;default:l=xe+(o-s)/2;break}return{left:e.startX+l,top:e.startY+d,width:((p=t==null?void 0:t.fs)!=null?p:10)*1.6,height:((g=t==null?void 0:t.fs)!=null?g:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var u,p,g,c,_,m,D,V,S;const{formula1:n=w.CHECKBOX_FORMULA_1,formula2:o=w.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=w.getFormulaResult((g=(p=(u=i==null?void 0:i[0])==null?void 0:u.result)==null?void 0:p[0])==null?void 0:g[0]),l=w.getFormulaResult((m=(_=(c=i==null?void 0:i[1])==null?void 0:c.result)==null?void 0:_[0])==null?void 0:m[0]),d=w.isLegalFormulaResult(String(s))&&w.isLegalFormulaResult(String(l));return{formula1:r.isFormulaString(n)?w.getFormulaResult((S=(V=(D=i==null?void 0:i[0])==null?void 0:D.result)==null?void 0:V[0])==null?void 0:S[0]):n,formula2:r.isFormulaString(o)?l:o,isFormulaValid:d}}drawWith(e,t){var P,x,k,U;const{style:a,primaryWithCoord:n,unitId:o,subUnitId:i,worksheet:s,row:l,col:d}=t,u=n.isMergedMainCell?n.mergeInfo:n,p=w.getCellValueOrigin(s.getCellRaw(l,d)),g=this._dataValidationModel.getRuleByLocation(o,i,l,d);if(!g)return;const c=this._dataValidationModel.getValidator(g.type);if(!c)return;const _=this._themeService.getCurrentTheme();if(!((P=c.skipDefaultFontRender)!=null&&P.call(c,g,p,{unitId:o,subUnitId:i,row:l,column:d})))return;const m=c.parseFormulaSync(g,o,i),{formula1:D}=m,V=this._calc(u,a),{a:S,d:R}=e.getTransform(),y=W.fixLineWidthByScale(V.left,S),b=W.fixLineWidthByScale(V.top,R),I=W.Transform.create().composeMatrix({left:y,top:b,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 L=I.getMatrix();e.transform(L[0],L[1],L[2],L[3],L[4],L[5]);const j=((x=a==null?void 0:a.fs)!=null?x:10)*1.6,B=String(p)===String(D),F=_.hyacinth500;W.CheckboxShape.drawWith(e,{checked:B,width:j,height:j,fill:(U=(k=a==null?void 0:a.cl)==null?void 0:k.rgb)!=null?U:F}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),o=n.top,i=n.top+n.height,s=n.left,l=n.left+n.width,{x:d,y:u}=e;return d<=l&&d>=s&&u<=i&&u>=o}async onPointerDown(e,t){var m;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:o,worksheet:i,row:s,col:l}=e,d=w.getCellValueOrigin(i.getCellRaw(s,l)),u=this._dataValidationModel.getRuleByLocation(n,o,s,l);if(!u)return;const p=this._dataValidationModel.getValidator(u.type);if(!p||!((m=p.skipDefaultFontRender)!=null&&m.call(p,u,d,{unitId:n,subUnitId:o,row:s,column:l})))return;const{formula1:g,formula2:c}=await this._parseFormula(u,n,o),_={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(d)===w.transformCheckboxValue(String(g))?c:g,p:null}};this._commandService.executeCommand(X.SetRangeValuesCommand.id,_)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(W.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(W.CURSOR_TYPE.DEFAULT)}};ut=ja([Oe(0,r.ICommandService),Oe(1,r.Inject(w.DataValidationFormulaService)),Oe(2,r.Inject(r.ThemeService)),Oe(3,r.Inject(W.IRenderManagerService)),Oe(4,r.Inject(w.SheetDataValidationModel))],ut);var Fa=Object.getOwnPropertyDescriptor,xa=(e,t,a,n)=>{for(var o=n>1?void 0:n?Fa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},ka=(e,t)=>(a,n)=>t(a,n,e);let he=class{constructor(e){O(this,"canvasRender",null);O(this,"dropdown");O(this,"optionsInput");O(this,"formulaInput",It);this.injector=e}};he=xa([ka(0,r.Inject(r.Injector))],he);class Ua extends he{constructor(){super(...arguments);O(this,"id",r.DataValidationType.CHECKBOX);O(this,"canvasRender",this.injector.createInstance(ut));O(this,"formulaInput",Ht)}}class Na extends he{constructor(){super(...arguments);O(this,"id",r.DataValidationType.CUSTOM);O(this,"formulaInput",$t)}}const Ba="data-validation.formula-input";class Wa extends he{constructor(){super(...arguments);O(this,"id",r.DataValidationType.DATE);O(this,"formulaInput",Ba);O(this,"optionsInput",ze.componentKey);O(this,"dropdown",_t)}}class $a extends he{constructor(){super(...arguments);O(this,"id",r.DataValidationType.DECIMAL);O(this,"formulaInput",Je)}}const Yt=4,Ha=0,at=4,Xt=4,ht=6,Ke=6,Ie=14;function Ya(e,t){const a=W.FontCache.getTextSize(e,t),n=a.width+Yt*2,{ba:o,bd:i}=a,s=o+i;return{width:n,height:s+Ha*2,ba:o}}function ot(e,t,a,n){const o=Ie+ht*2,i=a-o,s=n-Ke*2,l=e.map(c=>({layout:Ya(c,t),text:c}));let d;const u=[];l.forEach(c=>{const{layout:_}=c,{width:m,height:D}=_;!d||d.width+m+at>i?(d={width:m,height:D,items:[{...c,left:0}]},u.push(d)):(d.items.push({...c,left:d.width+at}),d.width=d.width+m+at)});let p=0,g=0;return u.forEach((c,_)=>{g=Math.max(g,c.width),_===u.length-1?p+=c.height:p+=c.height+Xt}),{lines:u,totalHeight:p,contentWidth:i,contentHeight:s,cellAutoHeight:p+Ke*2,calcAutoWidth:g+o}}const Xa=8;class za extends W.Shape{static drawWith(t,a){const{fontString:n,info:o,fill:i,color:s}=a,{layout:l,text:d}=o;t.save(),W.Rect.drawWith(t,{width:l.width,height:l.height,radius:Xa,fill:i||Ce}),t.translateWithPrecision(Yt,l.ba),t.font=n,t.fillStyle=s,t.fillText(d,0,0),t.restore()}}var Ka=Object.getOwnPropertyDescriptor,Ga=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ka(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},it=(e,t)=>(a,n)=>t(a,n,e);const qa=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let pt=class{constructor(e,t,a){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,o){const i=a-Ie+4;let s=4;switch(o){case r.VerticalAlign.MIDDLE:s=(n-Ie)/2+4;break;case r.VerticalAlign.BOTTOM:s=n-Ie+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(qa),e.restore()}drawWith(e,t,a,n){var q,K;const{primaryWithCoord:o,row:i,col:s,style:l,data:d,subUnitId:u}=t,p=o.isMergedMainCell?o.mergeInfo:o,g=d==null?void 0:d.fontRenderExtension,{leftOffset:c=0,rightOffset:_=0,topOffset:m=0,downOffset:D=0}=g||{},V=this._ensureMap(u),S=this._generateKey(i,s),R=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,s);if(!R)return;const y=this._dataValidationModel.getValidator(R.type);if(!y)return;const b={startX:p.startX+c,endX:p.endX-_,startY:p.startY+m,endY:p.endY-D},I=b.endX-b.startX,C=b.endY-b.startY,{cl:v}=l||{},L=(q=typeof v=="object"?v==null?void 0:v.rgb:v)!=null?q:"#000",j=W.getFontStyleString(l!=null?l:void 0),{vt:B,ht:F}=l||{},P=B!=null?B:r.VerticalAlign.MIDDLE,x=(K=w.getCellValueOrigin(d))!=null?K:"",k=y.parseCellValue(x),U=y.getListWithColorMap(R),$=ot(k,j,I,C);this._drawDownIcon(e,b,I,C,P),e.save(),e.translateWithPrecision(b.startX,b.startY),e.beginPath(),e.rect(0,0,I-Ie,C),e.clip(),e.translateWithPrecision(ht,Ke);let G=0;switch(P){case r.VerticalAlign.MIDDLE:G=($.contentHeight-$.totalHeight)/2;break;case r.VerticalAlign.BOTTOM:G=$.contentHeight-$.totalHeight;break}e.translateWithPrecision(0,G),$.lines.forEach((Z,ee)=>{e.save();const{width:te,height:ne,items:ie}=Z;let oe=0;switch(F){case r.HorizontalAlign.RIGHT:oe=$.contentWidth-te;break;case r.HorizontalAlign.CENTER:oe=($.contentWidth-te)/2;break}e.translate(oe,ee*(ne+Xt)),ie.forEach(re=>{e.save(),e.translateWithPrecision(re.left,0),za.drawWith(e,{...j,info:re,color:L,fill:U[re.text]}),e.restore()}),e.restore()}),e.restore(),V.set(S,{left:b.startX,top:b.startY,width:$.contentWidth+ht+Ie,height:$.contentHeight+Ke*2})}calcCellAutoHeight(e){var I;const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:u=0,downOffset:p=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,c={startX:g.startX+l,endX:g.endX-d,startY:g.startY+u,endY:g.endY-p},_=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!_)return;const m=this._dataValidationModel.getValidator(_.type);if(!m)return;const D=c.endX-c.startX,V=c.endY-c.startY,S=(I=w.getCellValueOrigin(n))!=null?I:"",R=m.parseCellValue(S),y=W.getFontStyleString(a!=null?a:void 0);return ot(R,y,D,V).cellAutoHeight}calcCellAutoWidth(e){var I;const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:u=0,downOffset:p=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,c={startX:g.startX+l,endX:g.endX-d,startY:g.startY+u,endY:g.endY-p},_=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!_)return;const m=this._dataValidationModel.getValidator(_.type);if(!m)return;const D=c.endX-c.startX,V=c.endY-c.startY,S=(I=w.getCellValueOrigin(n))!=null?I:"",R=m.parseCellValue(S),y=W.getFontStyleString(a!=null?a:void 0);return ot(R,y,D,V).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:o}=n,{x:i}=e;return i>=o-Ie&&i<=o}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:i}=e,s={unitId:a,subUnitId:n,row:o,column:i};this._commandService.executeCommand(Ge.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(W.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(W.CURSOR_TYPE.DEFAULT)}};pt=Ga([it(0,r.ICommandService),it(1,r.Inject(W.IRenderManagerService)),it(2,r.Inject(w.SheetDataValidationModel))],pt);class Za extends he{constructor(){super(...arguments);O(this,"id",r.DataValidationType.LIST_MULTIPLE);O(this,"canvasRender",this.injector.createInstance(pt));O(this,"dropdown",qe)}}var Ja=Object.getOwnPropertyDescriptor,Qa=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ja(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},ke=(e,t)=>(a,n)=>t(a,n,e);const _e=4,Ue=4,de=14,ce=6,Ve=4,rt=8,eo="#565656",wt=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function to(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${r.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:r.BooleanNumber.FALSE,bl:r.BooleanNumber.FALSE,ul:{s:r.BooleanNumber.FALSE},st:{s:r.BooleanNumber.FALSE},ol:{s:r.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function zt(e,t,a){const n=to(e,a),o=new r.DocumentDataModel(n),i=new W.DocumentViewModel(o);return{documentSkeleton:W.DocumentSkeleton.create(i,t),docModel:o,docViewModel:i}}function Ne(e,t,a){const{documentSkeleton:n,docModel:o,docViewModel:i}=zt(e,t,a);return{documents:new W.Documents(`DOCUMENTS_${r.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:o,docViewModel:i}}function Et(e,t,a,n,o,i,s=!0){let l=0;const d=s?Ve:0;switch(o){case r.VerticalAlign.BOTTOM:l=t-n-d;break;case r.VerticalAlign.MIDDLE:l=(t-n)/2;break;default:l=d;break}l=Math.max(Ve,l);let u=0;switch(i){case r.HorizontalAlign.CENTER:u=(e-a)/2;break;case r.HorizontalAlign.RIGHT:u=e-a;break}return u=Math.max(ce,u),{paddingLeft:u,paddingTop:l}}let gt=class{constructor(e,t,a,n){O(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,o,i,s){const{t:l=r.DEFAULT_STYLES.pd.t,b:d=r.DEFAULT_STYLES.pd.b}=s,u=a-de;let p;switch(i){case r.VerticalAlign.MIDDLE:p=(n-Ue)/2;break;case r.VerticalAlign.BOTTOM:p=n-d-o-Ve+(o/2-Ue/2);break;default:p=l+Ve+(o/2-Ue/2);break}e.save(),e.translateWithPrecision(t.startX+u,t.startY+p),e.fillStyle="#565656",e.fill(wt),e.restore()}drawWith(e,t,a){const{primaryWithCoord:n,row:o,col:i,style:s,data:l,subUnitId:d}=t,u=n.isMergedMainCell?n.mergeInfo:n,p=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,o,i);if(!p)return;const g=this._dataValidationModel.getValidator(p.type);if(!g)return;const c=l==null?void 0:l.fontRenderExtension,{leftOffset:_=0,rightOffset:m=0,topOffset:D=0,downOffset:V=0}=c||{};if(!p||!g||!g||g.id.indexOf(r.DataValidationType.LIST)!==0||!g.skipDefaultFontRender(p))return;const S={startX:u.startX+_,endX:u.endX-m,startY:u.startY+D,endY:u.endY-V},R=S.endX-S.startX,y=S.endY-S.startY,b=this._ensureMap(d),I=this._generateKey(o,i),C=g.getListWithColor(p),v=w.getCellValueOrigin(l),L=`${v!=null?v:""}`,j=C.find(k=>k.label===L);let{tb:B,vt:F,ht:P,pd:x}=s||{};if(B=B!=null?B:r.WrapStrategy.WRAP,F=F!=null?F:r.VerticalAlign.BOTTOM,P=P!=null?P:r.DEFAULT_STYLES.ht,x=x!=null?x:r.DEFAULT_STYLES.pd,p.renderMode===r.DataValidationRenderMode.ARROW){const{l:k=r.DEFAULT_STYLES.pd.l,t:U=r.DEFAULT_STYLES.pd.t,r:$=r.DEFAULT_STYLES.pd.r,b:G=r.DEFAULT_STYLES.pd.b}=x,q=R-k-$-de-4,{documentSkeleton:K,documents:Z,docModel:ee}=Ne(L,this._localeService,s);B===r.WrapStrategy.WRAP&&ee.updateDocumentDataPageSize(Math.max(q,1)),K.calculate(),K.getActualSize();const te=W.getDocsSkeletonPageSize(K),{height:ne,width:ie}=te,{paddingTop:oe,paddingLeft:re}=Et(q,y-U-G,ie,ne,F,P,!0);this._drawDownIcon(e,S,R,y,ne,F,x),e.save(),e.translateWithPrecision(S.startX+k,S.startY+U),e.beginPath(),e.rect(0,0,R-k-$,y-U-G),e.clip(),e.translateWithPrecision(0,oe),e.save(),e.translateWithPrecision(_e,0),e.beginPath(),e.rect(0,0,q,ne),e.clip(),Z.render(e),e.translateWithPrecision(re,0),e.restore(),e.restore(),b.set(I,{left:S.endX+k+a.rowHeaderWidth-de,top:S.startY+U+a.columnHeaderHeight,width:de,height:y-U-G})}else{e.save(),e.translateWithPrecision(S.startX,S.startY),e.beginPath(),e.rect(0,0,R,y),e.clip();const k=R-ce*2-_e-de-4,{documentSkeleton:U,documents:$,docModel:G}=Ne(L,this._localeService,s);B===r.WrapStrategy.WRAP&&G.updateDocumentDataPageSize(Math.max(k,1)),U.calculate();const q=W.getDocsSkeletonPageSize(U),{height:K,width:Z}=q,{paddingTop:ee,paddingLeft:te}=Et(k,y,Z,K,F,P);e.translateWithPrecision(ce,ee);const ne=Math.max(R-ce*2,1),ie=K;W.Rect.drawWith(e,{width:ne,height:ie,fill:(j==null?void 0:j.color)||Ce,radius:rt}),e.save(),e.translateWithPrecision(_e,0),e.beginPath(),e.rect(0,0,k,K),e.clip(),e.translateWithPrecision(te,0),$.render(e),e.restore(),e.translateWithPrecision(k+_e+4,(K-Ue)/2),e.fillStyle=eo,e.fill(wt),e.restore(),b.set(I,{left:S.startX+ce+a.rowHeaderWidth,top:S.startY+ee+a.columnHeaderHeight,width:ne,height:ie})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,l=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:u=0,topOffset:p=0,downOffset:g=0}=l||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!c||c.renderMode===r.DataValidationRenderMode.TEXT)return;const _={startX:s.startX+d,endX:s.endX-u,startY:s.startY+p,endY:s.endY-g},m=_.endX-_.startX,D=w.getCellValueOrigin(n),V=`${D!=null?D:""}`;let{tb:S,pd:R}=a||{};const{t:y=r.DEFAULT_STYLES.pd.t,b=r.DEFAULT_STYLES.pd.b}=R!=null?R:{};if(S=S!=null?S:r.WrapStrategy.WRAP,c.renderMode===r.DataValidationRenderMode.ARROW){const I=m-de,{documentSkeleton:C,docModel:v}=Ne(V,this._localeService,a);S===r.WrapStrategy.WRAP&&v.updateDocumentDataPageSize(Math.max(I,1)),C.calculate(),C.getActualSize();const L=W.getDocsSkeletonPageSize(C),{height:j}=L;return j+y+b+Ve*2}else{const I=m-ce*2-_e-de,{documentSkeleton:C,docModel:v}=zt(V,this._localeService,a);S===r.WrapStrategy.WRAP&&v.updateDocumentDataPageSize(Math.max(I,1)),C.calculate();const L=W.getDocsSkeletonPageSize(C),{height:j}=L;return j+Ve*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,l=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:u=0,topOffset:p=0,downOffset:g=0}=l||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!c||c.renderMode===r.DataValidationRenderMode.TEXT)return;const _={startX:s.startX+d,endX:s.endX-u,startY:s.startY+p,endY:s.endY-g},m=_.endX-_.startX,D=w.getCellValueOrigin(n),V=`${D!=null?D:""}`;let{tb:S,pd:R}=a||{};const{l:y=r.DEFAULT_STYLES.pd.l,r:b=r.DEFAULT_STYLES.pd.r}=R!=null?R:{};S=S!=null?S:r.WrapStrategy.WRAP;let I=ce*2+de;switch(c.renderMode){case r.DataValidationRenderMode.ARROW:I=de+ce*2+b+y;break;case r.DataValidationRenderMode.CUSTOM:I=de+ce*2+_e*2+b+y+rt/2+1;break;default:I=de+ce*2+_e*2+b+y+rt/2+1}const C=m-I,{documentSkeleton:v,docModel:L}=Ne(V,this._localeService,a);return S===r.WrapStrategy.WRAP&&L.updateDocumentDataPageSize(Math.max(C,1)),v.calculate(),v.getActualSize(),W.getDocsSkeletonPageSize(v).width+I}isHit(e,t){const{subUnitId:a,row:n,col:o}=t,s=this._ensureMap(a).get(this._generateKey(n,o)),l=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,o);if(!l||!s||l.renderMode===r.DataValidationRenderMode.TEXT)return!1;const{top:d,left:u,width:p,height:g}=s,{x:c,y:_}=e;return c>=u&&c<=u+p&&_>=d&&_<=d+g}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:i}=e,s={unitId:a,subUnitId:n,row:o,column:i};this._commandService.executeCommand(Ge.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(W.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(W.CURSOR_TYPE.DEFAULT)}};gt=Qa([ke(0,r.Inject(r.LocaleService)),ke(1,r.ICommandService),ke(2,r.Inject(W.IRenderManagerService)),ke(3,r.Inject(w.SheetDataValidationModel))],gt);class no extends he{constructor(){super(...arguments);O(this,"id",r.DataValidationType.LIST);O(this,"canvasRender",this.injector.createInstance(gt));O(this,"dropdown",qe);O(this,"optionsInput",Xe.componentKey);O(this,"formulaInput",It)}}class ao extends he{constructor(){super(...arguments);O(this,"id",r.DataValidationType.TEXT_LENGTH);O(this,"formulaInput",Je)}}class oo extends he{constructor(){super(...arguments);O(this,"id",r.DataValidationType.WHOLE);O(this,"formulaInput",Je)}}var io=Object.getOwnPropertyDescriptor,ro=(e,t,a,n)=>{for(var o=n>1?void 0:n?io(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},st=(e,t)=>(a,n)=>t(a,n,e);let Te=class extends r.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[kt,Tt],[$e,Qn],[jt,_n],[qe,On],[_t,on],[Xe.componentKey,Xe],[ze.componentKey,ze],...La].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[$a,oo,ao,Wa,Ua,no,Za,Na].forEach(e=>{const t=this._injector.createInstance(e),a=this._dataValidatorRegistryService.getValidatorItem(t.id);a&&(a.formulaInput=t.formulaInput,a.canvasRender=t.canvasRender,a.dropdown=t.dropdown,a.optionsInput=t.optionsInput)})}};Te=ro([st(0,r.Inject(r.Injector)),st(1,r.Inject(f.ComponentManager)),st(2,r.Inject(Q.DataValidatorRegistryService))],Te);var so=Object.getOwnPropertyDescriptor,lo=(e,t,a,n)=>{for(var o=n>1?void 0:n?so(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},lt=(e,t)=>(a,n)=>t(a,n,e);const co="SHEET_DATA_VALIDATION_UI_PLUGIN";var Be;exports.UniverSheetsDataValidationUIPlugin=(Be=class extends r.Plugin{constructor(t=He,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:i,...s}=r.merge({},He,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(St,s)}onStarting(){[[ue],[me],[Ae],[we],[be],[Me],[Ee],[Pe],[Te]].forEach(t=>{this._injector.add(t)}),[Ze,Ge,xt,ft,De,Ft].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(Pe),this._injector.get(Ae),this._injector.get(W.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[Ye])}onRendered(){this._injector.get(Te),this._injector.get(be)}onSteady(){this._injector.get(we)}},O(Be,"pluginName",co),O(Be,"type",r.UniverInstanceType.UNIVER_SHEET),Be);exports.UniverSheetsDataValidationUIPlugin=lo([lt(1,r.Inject(r.Injector)),lt(2,r.ICommandService),lt(3,r.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);var uo=Object.getOwnPropertyDescriptor,ho=(e,t,a,n)=>{for(var o=n>1?void 0:n?uo(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},dt=(e,t)=>(a,n)=>t(a,n,e);const po="SHEET_DATA_VALIDATION_UI_PLUGIN";var We;exports.UniverSheetsDataValidationMobileUIPlugin=(We=class extends r.Plugin{constructor(t=He,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:i,...s}=r.merge({},He,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(St,s)}onStarting(){[[ue],[me],[Ae],[we],[be],[Me],[Ee],[Te]].forEach(t=>{this._injector.add(t)}),[Ze,Ge,xt,ft,De,Ft].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(W.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[Ye])}onRendered(){this._injector.get(Te),this._injector.get(be)}onSteady(){this._injector.get(we)}},O(We,"pluginName",po),O(We,"type",r.UniverInstanceType.UNIVER_SHEET),We);exports.UniverSheetsDataValidationMobileUIPlugin=ho([dt(1,r.Inject(r.Injector)),dt(2,r.ICommandService),dt(3,r.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);exports.DATE_DROPDOWN_KEY=_t;exports.LIST_DROPDOWN_KEY=qe;
1
+ "use strict";var Gt=Object.defineProperty;var qt=(e,t,a)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var O=(e,t,a)=>qt(e,typeof t!="symbol"?t+"":t,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),r=require("@univerjs/core"),T=require("@univerjs/design"),W=require("@univerjs/engine-render"),X=require("@univerjs/sheets"),w=require("@univerjs/sheets-data-validation"),Zt=require("@univerjs/sheets-numfmt"),B=require("@univerjs/sheets-ui"),f=require("@univerjs/ui"),E=require("react"),Q=require("@univerjs/data-validation"),Jt=require("@univerjs/docs"),le=require("rxjs"),ct=require("@univerjs/engine-formula"),mt=require("@univerjs/sheets-formula-ui");var Qt=Object.getOwnPropertyDescriptor,en=(e,t,a,n)=>{for(var o=n>1?void 0:n?Qt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Le=(e,t)=>(a,n)=>t(a,n,e);let Pe=class extends r.Disposable{constructor(e,t,a,n,o){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=o,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(X.AFTER_CELL_EDIT_ASYNC,{handler:async(e,t,a)=>{var D;const n=await e,{worksheet:o,row:i,col:s,unitId:l,subUnitId:d,workbook:u}=t,p=this._dataValidationModel.getRuleIdByLocation(l,d,i,s),g=p?this._dataValidationModel.getRuleById(l,d,p):void 0;if(!g||g.errorStyle!==r.DataValidationErrorStyle.STOP)return a(Promise.resolve(n));const c=await this._dataValidatorRegistryService.getValidatorItem(g.type);if(!c||await c.validator({value:w.getCellValueOrigin(n),interceptValue:w.getCellValueOrigin((D=t==null?void 0:t.origin)!=null?D:n),row:i,column:s,unitId:l,subUnitId:d,worksheet:o,workbook:u,t:n==null?void 0:n.t},g))return a(Promise.resolve(n));const m=o.getCellRaw(i,s);return this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:c.getRuleFinalError(g,{row:i,col:s,unitId:l,subUnitId:d})},footer:{title:E.createElement(T.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(Promise.resolve(m))}})}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(T.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Pe=en([Le(0,r.Inject(X.SheetInterceptorService)),Le(1,r.Inject(w.SheetDataValidationModel)),Le(2,r.Inject(Q.DataValidatorRegistryService)),Le(3,f.IDialogService),Le(4,r.Inject(r.LocaleService))],Pe);const tn="univer-dv-date-dropdown",nn="univer-dv-date-dropdown-btns",Ct={dvDateDropdown:tn,dvDateDropdownBtns:nn},an=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return r.dayjs(r.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=r.dayjs(e);if(t.isValid())return t};function on(e){var v;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:i,unitId:s,subUnitId:l,workbook:d}=t,u=f.useDependency(r.ICommandService),p=f.useDependency(Pe),g=n.getCell(o,i),c=w.getCellValueOrigin(n.getCellRaw(o,i)),_=an(c),[m,D]=E.useState(_),V=m&&m.isValid()?m:r.dayjs(),S=f.useDependency(r.LocaleService),R=f.useDependency(w.SheetDataValidationModel),y=R.getRuleByLocation(s,l,o,i);if(!y)return null;const b=R.getValidator(y.type);if(!g||!b)return;const I=!!((v=y.bizInfo)!=null&&v.showTime),C=async()=>{var k,U,$;if(!V)return;const j=V.format(I?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),N=(k=r.numfmt.parseDate(j))==null?void 0:k.v,F=d.getStyles().getStyleByCell(g),P=($=(U=F==null?void 0:F.n)==null?void 0:U.pattern)!=null?$:"",x=Zt.getPatternType(P);y.errorStyle!==r.DataValidationErrorStyle.STOP||await b.validator({value:N,unitId:s,subUnitId:l,row:o,column:i,worksheet:n,workbook:d,interceptValue:j.replace("Z","").replace("T"," "),t:r.CellValueType.NUMBER},y)?(a(),await u.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:W.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),await u.executeCommand(X.SetRangeValuesCommand.id,{unitId:s,subUnitId:l,range:{startColumn:i,endColumn:i,startRow:o,endRow:o},value:{v:N,t:2,p:null,f:null,si:null,s:{n:{pattern:I?x==="datetime"?P:"yyyy-MM-dd hh:mm:ss":x==="date"?P:"yyyy-MM-dd"}}}})):p.showReject(b.getRuleFinalError(y,{row:o,col:i,unitId:s,subUnitId:l}))};return h.jsxs("div",{className:Ct.dvDateDropdown,children:[h.jsx(T.DatePanel,{defaultValue:V,pickerValue:V,showTime:I||void 0,onSelect:async L=>{D(L)},onPanelChange:L=>{D(L)},disabledDate:L=>!r.numfmt.parseDate(L.format("YYYY-MM-DD"))}),h.jsx("div",{className:Ct.dvDateDropdownBtns,children:h.jsx(T.Button,{size:"small",type:"primary",onClick:C,disabled:!V.isValid(),children:S.t("dataValidation.alert.ok")})})]})}var se=function(){return se=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},se.apply(this,arguments)},rn=function(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(a[n[o]]=e[n[o]]);return a},ve=E.forwardRef(function(e,t){var a=e.icon,n=e.id,o=e.className,i=e.extend,s=rn(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),d=E.useRef("_".concat(dn()));return Mt(a,"".concat(n),{defIds:a.defIds,idSuffix:d.current},se({ref:t,className:l},s),i)});function Mt(e,t,a,n,o){return E.createElement(e.tag,se(se({key:t},sn(e,a,o)),n),(ln(e,a).children||[]).map(function(i,s){return Mt(i,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,o)}))}function sn(e,t,a){var n=se({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],l=i[1];s==="mask"&&typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var o=t.defIds;return!o||o.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],l=i[1];typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function ln(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?se(se({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?se(se({},o),{attrs:se(se({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):e}function dn(){return Math.random().toString(36).substring(2,8)}ve.displayName="UniverIcon";var cn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},bt=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"check-mark-single",ref:t,icon:cn}))});bt.displayName="CheckMarkSingle";var un={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.4917 3.07803C1.4917 2.19437 2.20804 1.47803 3.0917 1.47803H5.6917C6.57536 1.47803 7.2917 2.19437 7.2917 3.07803V5.67803C7.2917 6.56168 6.57535 7.27803 5.6917 7.27803H3.0917C2.20804 7.27803 1.4917 6.56168 1.4917 5.67803V3.07803ZM3.0917 2.67803C2.87078 2.67803 2.6917 2.85711 2.6917 3.07803V5.67803C2.6917 5.89894 2.87079 6.07803 3.0917 6.07803H5.6917C5.91261 6.07803 6.0917 5.89894 6.0917 5.67803V3.07803C6.0917 2.85711 5.91261 2.67803 5.6917 2.67803H3.0917Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.6175 2.45279C14.8518 2.68711 14.8518 3.06701 14.6175 3.30132L11.6151 6.30365C11.3957 6.52307 11.0451 6.53897 10.8067 6.34031L8.80915 4.67566C8.55458 4.46352 8.52019 4.08518 8.73233 3.83062 8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767 13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279zM14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217 14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046 13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703 10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046 9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217 9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746 9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732 13.269 9.19746C13.5033 8.96315 13.8832 8.96315 14.1175 9.19746z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.0917 8.72168C2.20804 8.72168 1.4917 9.43802 1.4917 10.3217V12.9217C1.4917 13.8053 2.20804 14.5217 3.0917 14.5217H5.6917C6.57535 14.5217 7.2917 13.8053 7.2917 12.9217V10.3217C7.2917 9.43802 6.57536 8.72168 5.6917 8.72168H3.0917ZM2.6917 10.3217C2.6917 10.1008 2.87078 9.92168 3.0917 9.92168H5.6917C5.91261 9.92168 6.0917 10.1008 6.0917 10.3217V12.9217C6.0917 13.1426 5.91261 13.3217 5.6917 13.3217H3.0917C2.87079 13.3217 2.6917 13.1426 2.6917 12.9217V10.3217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Tt=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"data-validation-single",ref:t,icon:un}))});Tt.displayName="DataValidationSingle";var hn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},vt=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"delete-single",ref:t,icon:hn}))});vt.displayName="DeleteSingle";var pn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},Lt=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"increase-single",ref:t,icon:pn}))});Lt.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"}}]},Ot=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"more-down-single",ref:t,icon:gn}))});Ot.displayName="MoreDownSingle";var mn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.64645 9.85355C4.45118 9.65829 4.45118 9.34171 4.64645 9.14645L7.64645 6.14645C7.84171 5.95118 8.15829 5.95118 8.35355 6.14645L11.3536 9.14645C11.5488 9.34171 11.5488 9.65829 11.3536 9.85355C11.1583 10.0488 10.8417 10.0488 10.6464 9.85355L8 7.20711L5.35355 9.85355C5.15829 10.0488 4.84171 10.0488 4.64645 9.85355Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Pt=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"more-up-single",ref:t,icon:mn}))});Pt.displayName="MoreUpSingle";var vn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},At=E.forwardRef(function(e,t){return E.createElement(ve,Object.assign({},e,{id:"sequence-single",ref:t,icon:vn}))});At.displayName="SequenceSingle";var fn=Object.getOwnPropertyDescriptor,Sn=(e,t,a,n)=>{for(var o=n>1?void 0:n?fn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Dt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends r.Disposable{constructor(t,a){super();O(this,"_open$",new le.BehaviorSubject(!1));O(this,"open$",this._open$.pipe(le.distinctUntilChanged()));O(this,"_activeRule");O(this,"_activeRule$",new le.BehaviorSubject(void 0));O(this,"activeRule$",this._activeRule$.asObservable());O(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).pipe(le.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===$e&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=r.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ue=Sn([Dt(0,r.IUniverInstanceService),Dt(1,f.ISidebarService)],ue);function _n(){const e=f.useDependency(me),t=f.useObservable(e.activeDropdown$,e.activeDropdown),a=f.useDependency(f.ComponentManager);if(!t)return null;const{location:n,componentKey:o}=t,i=a.get(o),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!i)return null;const l=()=>{e.hideDropdown()};return h.jsx(i,{location:n,hideFn:l},s)}const jt="sheet.ui.dropdown";var In=Object.getOwnPropertyDescriptor,Cn=(e,t,a,n)=>{for(var o=n>1?void 0:n?In(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},fe=(e,t)=>(a,n)=>t(a,n,e);let me=class extends r.Disposable{constructor(t,a,n,o,i,s,l){super();O(this,"_activeDropdown");O(this,"_activeDropdown$",new le.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=o,this._renderManagerService=i,this._dataValidationModel=s,this._sheetsSelectionsService=l,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,a,n,o){const i=t?this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=a?i.getSheetBySheetId(a):i.getActiveSheet();if(!s)return;const l=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,o);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);return d==null?void 0:d.dropdown}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t,a=!0){const{location:n}=t,{row:o,col:i,unitId:s,subUnitId:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const d=this._renderManagerService.getRenderById(r.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),u=this._canvasPopupManagerService.attachPopupToCell(o,i,{componentKey:jt,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[d==null?void 0:d.engine.getCanvasElement()].filter(Boolean)},s,l);if(!u)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const p=new r.DisposableCollection;p.add(u),p.add({dispose:()=>{var g,c;(c=(g=this._activeDropdown)==null?void 0:g.onHide)==null||c.call(g)}}),this._currentPopup=p}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,a,n,o,i){const s=this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET);if(!s)return;const l=s.getSheetBySheetId(a);if(!l)return;const d=this._dataValidationModel.getRuleByLocation(s.getUnitId(),l.getSheetId(),n,o);if(!d)return;const u=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!u||!u.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:l,row:n,col:o,unitId:t,subUnitId:a},componentKey:u.dropdown,onHide:i})}};me=Cn([fe(0,r.Inject(B.SheetCanvasPopManagerService)),fe(1,r.IUniverInstanceService),fe(2,r.Inject(Q.DataValidatorRegistryService)),fe(3,f.IZenZoneService),fe(4,W.IRenderManagerService),fe(5,r.Inject(w.SheetDataValidationModel)),fe(6,r.Inject(X.SheetsSelectionsService))],me);const $e="DataValidationPanel",De={id:"data-validation.operation.open-validation-panel",type:r.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,o=e.get(ue),i=e.get(Q.DataValidationModel),s=e.get(r.IUniverInstanceService),l=e.get(f.ISidebarService),d=X.getSheetCommandTarget(s);if(!d)return!1;const{unitId:u,subUnitId:p}=d,g=a?i.getRuleById(u,p,a):void 0;o.open(),o.setActiveRule(g&&{unitId:u,subUnitId:p,rule:g});const c=l.open({id:$e,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:$e},width:312,onClose:()=>o.close()});return o.setCloseDisposable(c),!0}},ft={id:"data-validation.operation.close-validation-panel",type:r.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},Ft={id:"data-validation.operation.toggle-validation-panel",type:r.CommandType.OPERATION,handler(e){const t=e.get(r.ICommandService),a=e.get(ue);return a.open(),a.isOpen?t.executeCommand(ft.id):t.executeCommand(De.id),!0}},Ge={type:r.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(me),{unitId:n,subUnitId:o,row:i,column:s}=t,l=a.activeDropdown,d=l==null?void 0:l.location;return d&&d.unitId===n&&d.subUnitId===o&&d.row===i&&d.col===s||a.showDataValidationDropdown(n,o,i,s),!0}},xt={type:r.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(me).hideDropdown(),!0):!1}},Ce="#ECECEC",St="sheets-data-validation-ui.config",He={},Dn="univer-dv-list-dropdown",yn="univer-dv-list-dropdown-title",Rn="univer-dv-list-dropdown-list",Vn="univer-dv-list-dropdown-list-container",wn="univer-dv-list-dropdown-selected-icon",En="univer-dv-list-dropdown-item-container",Mn="univer-dv-list-dropdown-item",bn="univer-dv-list-dropdown-split",Tn="univer-dv-list-dropdown-edit",pe={dvListDropdown:Dn,dvListDropdownTitle:yn,dvListDropdownList:Rn,dvListDropdownListContainer:Vn,dvListDropdownSelectedIcon:wn,dvListDropdownItemContainer:En,dvListDropdownItem:Mn,dvListDropdownSplit:bn,dvListDropdownEdit:Tn},Ln=e=>{var I,C;const{value:t,onChange:a,multiple:n,options:o,title:i,onEdit:s,style:l,filter:d,location:u}=e,p=f.useDependency(r.LocaleService),g=f.useDependency(r.IConfigService),c=d==null?void 0:d.toLowerCase(),{row:_,col:m,unitId:D,subUnitId:V}=u,S=o.filter(v=>c?v.label.toLowerCase().includes(c):!0),R=(C=(I=g.getConfig(St))==null?void 0:I.showEditOnDropdown)!=null?C:!0,y=f.useDependency(X.SheetPermissionCheckController),b=E.useMemo(()=>y.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission]},[{startColumn:m,startRow:_,endColumn:m,endRow:_}],D,V),[y,m,_,D,V]);return h.jsxs("div",{className:pe.dvListDropdown,style:l,children:[h.jsx("div",{className:pe.dvListDropdownTitle,children:i}),h.jsx("div",{className:pe.dvListDropdownList,children:h.jsx(T.Scrollbar,{children:h.jsx("div",{className:pe.dvListDropdownListContainer,children:S.map((v,L)=>{const j=t.indexOf(v.value)>-1,N=()=>{let P;j?P=new Set(t.filter(k=>k!==v.value)):P=new Set(n?[...t,v.value]:[v.value]);const x=[];o.forEach(k=>{P.has(k.value)&&x.push(k.value)}),a(x)},F=v.label.toLocaleLowerCase().indexOf(c);return h.jsxs("div",{className:pe.dvListDropdownItemContainer,onClick:N,children:[h.jsx("div",{className:pe.dvListDropdownItem,style:{background:v.color||Ce},children:c&&v.label.toLowerCase().includes(c)?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:v.label.substring(0,F)}),h.jsx("span",{style:{fontWeight:"bold"},children:v.label.substring(F,F+c.length)}),h.jsx("span",{children:v.label.substring(F+c.length)})]}):v.label}),h.jsx("div",{className:pe.dvListDropdownSelectedIcon,children:j?h.jsx(bt,{}):null})]},L)})})},d)}),R&&b?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:pe.dvListDropdownSplit}),h.jsx("div",{className:pe.dvListDropdownEdit,children:h.jsx("a",{onClick:s,children:p.t("dataValidation.list.edit")})})]}):null]})};function On(e){var U,$,G,q;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:i,unitId:s,subUnitId:l}=t,d=f.useDependency(Q.DataValidationModel),[u,p]=E.useState(""),g=f.useDependency(r.ICommandService),c=f.useDependency(r.LocaleService),[_,m]=E.useState(""),D=f.useDependency(B.IEditorBridgeService),V=f.useDependency(r.IUniverInstanceService),S=E.useMemo(()=>d.ruleChange$.pipe(le.debounceTime(16)),[]),R=f.useDependency(w.SheetDataValidationModel);f.useObservable(S);const y=f.RectPopup.useContext(),b=(($=(U=y.current)==null?void 0:U.right)!=null?$:0)-((q=(G=y.current)==null?void 0:G.left)!=null?q:0);if(E.useEffect(()=>{const K=g.onCommandExecuted(Z=>{var ee,te;if(Z.id===Jt.RichTextEditingMutation.id){const ne=Z.params,{unitId:ie}=ne,oe=V.getUnit(ie,r.UniverInstanceType.UNIVER_DOC);if(!oe||!D.isVisible().visible)return;const re=r.BuildTextUtils.transform.getPlainText((te=(ee=oe.getSnapshot().body)==null?void 0:ee.dataStream)!=null?te:"");p(re)}});return()=>{K.dispose()}},[g,D,V]),!n)return null;const I=R.getRuleByLocation(s,l,o,i);if(!I)return null;const C=R.getValidator(I.type);if(!C)return null;const v=n.getCell(o,i),L=(I==null?void 0:I.renderMode)===r.DataValidationRenderMode.CUSTOM||(I==null?void 0:I.renderMode)===void 0;if(!v||!I||!C||C.id.indexOf(r.DataValidationType.LIST)!==0)return;const j=I.type===r.DataValidationType.LIST_MULTIPLE,N=C.getListWithColor(I,s,l),F=_||w.getDataValidationCellValue(n.getCellRaw(o,i)),P=w.deserializeListOptions(F),x=()=>{g.executeCommand(De.id,{ruleId:I.uid}),a()},k=N.map(K=>({label:K.label,value:K.label,color:L||K.color?K.color:"transparent"}));return h.jsx(Ln,{style:{minWidth:b,maxWidth:Math.max(b,200)},title:j?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:P,multiple:j,onChange:async K=>{const Z=w.serializeListOptions(K),ee={unitId:s,subUnitId:l,range:{startColumn:i,endColumn:i,startRow:o,endRow:o},value:{v:Z,p:null,f:null,si:null}};D.isVisible()&&g.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:W.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),m(Z),j||a(),D.isVisible().visible&&await g.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:W.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),g.executeCommand(X.SetRangeValuesCommand.id,ee)},options:k,onEdit:x,filter:u,location:t})}const Pn="univer-data-validation-options-button",An="univer-data-validation-options-button-icon",Qe={dataValidationOptionsButton:Pn,dataValidationOptionsButtonIcon:An};function jn(e){var u;const t=f.useDependency(r.LocaleService),a=f.useDependency(f.ComponentManager),{value:n,onChange:o,extraComponent:i}=e,[s,l]=E.useState(!1),d=i?a.get(i):null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:Qe.dataValidationOptionsButton,onClick:()=>l(!s),children:[t.t("dataValidation.panel.options"),s?h.jsx(Pt,{className:Qe.dataValidationOptionsButtonIcon}):h.jsx(Ot,{className:Qe.dataValidationOptionsButtonIcon})]}),s&&h.jsxs(h.Fragment,{children:[d?h.jsx(d,{value:n,onChange:o}):null,h.jsx(T.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:h.jsxs(T.RadioGroup,{value:`${(u=n.errorStyle)!=null?u:r.DataValidationErrorStyle.WARNING}`,onChange:p=>o({...n,errorStyle:+p}),children:[h.jsx(T.Radio,{value:`${r.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),h.jsx(T.Radio,{value:`${r.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),h.jsx(T.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:h.jsx(T.Checkbox,{checked:n.showErrorMessage,onChange:()=>o({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?h.jsx(T.FormLayout,{children:h.jsx(T.Input,{value:n.error,onChange:p=>o({...n,error:p})})}):null]})]})}const Fn="univer-data-validation-detail",xn="univer-data-validation-detail-form-item",kn="univer-data-validation-detail-buttons",Un="univer-data-validation-detail-button",ye={dataValidationDetail:Fn,dataValidationDetailFormItem:xn,dataValidationDetailButtons:kn,dataValidationDetailButton:Un},Nn=e=>r.debounce(async(t,a,n,o)=>{const i=await e.executeCommand(t,a,n);o==null||o(i)},1e3);function Bn(e,t,a){var n,o,i,s;return t?((o=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:o.getSheetId())||"":((s=(i=e.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Wn(){var re;const[e,t]=E.useState(0),a=f.useDependency(ue),n=f.useObservable(a.activeRule$,a.activeRule),{unitId:o,subUnitId:i,rule:s}=n||{},l=s.uid,d=f.useDependency(Q.DataValidatorRegistryService),u=f.useDependency(r.IUniverInstanceService),p=f.useDependency(f.ComponentManager),g=f.useDependency(r.ICommandService),c=f.useDependency(Q.DataValidationModel),_=f.useDependency(r.LocaleService),[m,D]=E.useState(s),V=d.getValidatorItem(m.type),[S,R]=E.useState(!1),y=d.getValidatorsByScope(Q.DataValidatorRegistryScope.SHEET),[b,I]=E.useState(()=>m.ranges.map(A=>({unitId:"",sheetId:"",range:A}))),C=E.useMemo(()=>Nn(g),[g]),[v,L]=E.useState(!1),j=E.useRef({}),[N,F]=E.useState(!1),P=f.useDependency(X.SheetsSelectionsService);if(E.useEffect(()=>()=>{const A=P.getCurrentLastSelection();A&&P.setSelections([A])},[P]),E.useEffect(()=>{g.onCommandExecuted(A=>{(A.id===r.UndoCommand.id||A.id===r.RedoCommand.id)&&setTimeout(()=>{const M=c.getRuleById(o,i,l);t(H=>H+1),M&&(D(M),I(M.ranges.map(H=>({unitId:"",sheetId:"",range:H}))))},20)})},[g,c,l,i,o]),!V)return null;const x=V.operators,k=V.operatorNames,U=m.operator?Q.TWO_FORMULA_OPERATOR_COUNT.includes(m.operator):!1,$=()=>{!m.ranges.length||v||(V.validatorFormula(m,o,i).success?a.setActiveRule(null):R(!0))},G=f.useEvent(A=>{const M=A.split(",").filter(Boolean).map(ct.deserializeRangeWithSheet).map(z=>{const ge=z.sheetName;if(ge){const Kt=Bn(u,z.unitId,ge);return{...z,sheetId:Kt}}return{...z,sheetId:""}});if(r.isUnitRangesEqual(M,b))return;I(M);const H=M.filter(z=>(!z.unitId||z.unitId===o)&&(!z.sheetId||z.sheetId===i)).map(z=>z.range);if(D({...m,ranges:H}),H.length===0)return;const Y={unitId:o,subUnitId:i,ruleId:l,ranges:H};C(w.UpdateSheetDataValidationRangeCommand.id,Y)}),q=A=>{if(r.shallowEqual(A,Q.getRuleSetting(m)))return;D({...m,...A});const M={unitId:o,subUnitId:i,ruleId:l,setting:A};C(w.UpdateSheetDataValidationSettingCommand.id,M,void 0)},K=async()=>{await g.executeCommand(w.RemoveSheetDataValidationCommand.id,{ruleId:l,unitId:o,subUnitId:i}),a.setActiveRule(null)},Z={type:m.type,operator:m.operator,formula1:m.formula1,formula2:m.formula2,allowBlank:m.allowBlank},ee=A=>{const M=d.getValidatorItem(A);if(!M)return;const H=M.operators,Y=c.getRuleById(o,i,l),z=A===(Y==null?void 0:Y.type)||A.includes("list")&&(Y!=null&&Y.type.includes("list"))?{...Y,type:A}:{...m,type:A,operator:H[0],formula1:void 0,formula2:void 0};D(z),g.executeCommand(w.UpdateSheetDataValidationSettingCommand.id,{unitId:o,subUnitId:i,ruleId:m.uid,setting:Q.getRuleSetting(z)})},te=p.get(V.formulaInput),ne=E.useMemo(()=>b.map(A=>ct.serializeRange(A.range)).join(","),[]),ie=Q.getRuleOptions(m),oe=A=>{r.shallowEqual(A,Q.getRuleOptions(m))||(D({...m,...A}),C(w.UpdateSheetDataValidationOptionsCommand.id,{unitId:o,subUnitId:i,ruleId:l,options:A}))};return f.useSidebarClick(A=>{var H;const M=(H=j.current)==null?void 0:H.handleOutClick;M&&M(A,()=>F(!1))}),h.jsxs("div",{className:ye.dataValidationDetail,children:[h.jsx(T.FormLayout,{label:_.t("dataValidation.panel.range"),error:!m.ranges.length||v?_.t("dataValidation.panel.rangeError"):"",children:h.jsx(mt.RangeSelector,{unitId:o,subUnitId:i,initValue:ne,onChange:G,onFocus:()=>F(!0),isFocus:N,actions:j.current,onVerify:A=>L(!A)})}),h.jsx(T.FormLayout,{label:_.t("dataValidation.panel.type"),children:h.jsx(T.Select,{options:y==null?void 0:y.map(A=>({label:_.t(A.title),value:A.id})),value:m.type,onChange:ee,className:ye.dataValidationDetailFormItem})}),x!=null&&x.length?h.jsx(T.FormLayout,{label:_.t("dataValidation.panel.operator"),children:h.jsx(T.Select,{options:x.map((A,M)=>({value:`${A}`,label:k[M]})),value:`${m.operator}`,onChange:A=>{q({...Z,operator:A})},className:ye.dataValidationDetailFormItem})}):null,te?h.jsx(te,{isTwoFormula:U,value:{formula1:m.formula1,formula2:m.formula2},onChange:A=>{q({...Z,...A})},showError:S,validResult:V.validatorFormula(m,o,i),unitId:o,subUnitId:i,ruleId:l},e+m.type):null,h.jsx(T.FormLayout,{children:h.jsx(T.Checkbox,{checked:(re=m.allowBlank)!=null?re:!0,onChange:()=>{var A;return q({...Z,allowBlank:!((A=m.allowBlank)==null||A)})},children:_.t("dataValidation.panel.allowBlank")})}),h.jsx(jn,{value:ie,onChange:oe,extraComponent:V.optionsInput}),h.jsxs("div",{className:ye.dataValidationDetailButtons,children:[h.jsx(T.Button,{className:ye.dataValidationDetailButton,onClick:K,children:_.t("dataValidation.panel.removeRule")}),h.jsx(T.Button,{className:ye.dataValidationDetailButton,type:"primary",onClick:$,children:_.t("dataValidation.panel.done")})]})]})}const $n="univer-data-validation-item-container",Hn="univer-data-validation-item-title",Yn="univer-data-validation-item-content",Xn="univer-data-validation-item-icon",je={dataValidationItemContainer:$n,dataValidationItemTitle:Hn,dataValidationItemContent:Yn,dataValidationItemIcon:Xn},zn=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:o,disable:i}=e,s=f.useDependency(Q.DataValidatorRegistryService),l=f.useDependency(r.ICommandService),d=f.useDependency(B.IMarkSelectionService),u=s.getValidatorItem(t.type),p=E.useRef(void 0),[g,c]=E.useState(!1),_=m=>{l.executeCommand(w.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:o}),m.stopPropagation()};return E.useEffect(()=>()=>{var m;p.current&&((m=p.current)==null||m.forEach(D=>{D&&d.removeShape(D)}))},[d]),h.jsxs("div",{className:je.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{i||(c(!0),p.current=t.ranges.map(m=>d.addShape({range:m,style:{fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:null})))},onMouseLeave:()=>{var m;c(!1),(m=p.current)==null||m.forEach(D=>{D&&d.removeShape(D)}),p.current=void 0},children:[h.jsx("div",{className:je.dataValidationItemTitle,children:u==null?void 0:u.generateRuleName(t)}),h.jsx("div",{className:je.dataValidationItemContent,children:t.ranges.map(m=>ct.serializeRange(m)).join(",")}),g?h.jsx("div",{className:je.dataValidationItemIcon,onClick:_,children:h.jsx(vt,{})}):null]})},Kn="univer-data-validation-list",Gn="univer-data-validation-list-buttons",qn="univer-data-validation-list-button",Fe={dataValidationList:Kn,dataValidationListButtons:Gn,dataValidationListButton:qn};function Zn(){const e=f.useDependency(r.IUniverInstanceService),t=f.useObservable(()=>e.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return t?h.jsx(Jn,{workbook:t}):null}function Jn(e){const t=f.useDependency(w.SheetDataValidationModel),a=f.useDependency(r.IUniverInstanceService),n=f.useDependency(r.ICommandService),o=f.useDependency(r.Injector),i=f.useDependency(ue),s=f.useDependency(r.LocaleService),[l,d]=E.useState([]),{workbook:u}=e,p=f.useObservable(u.activeSheet$,void 0,!0),g=u.getUnitId(),c=p==null?void 0:p.getSheetId();E.useEffect(()=>{d(t.getRules(g,c));const R=t.ruleChange$.subscribe(y=>{y.unitId===g&&y.subUnitId===c&&d(t.getRules(g,c))});return()=>{R.unsubscribe()}},[g,c,t]);const _=async()=>{const R=w.createDefaultNewRule(o),y={unitId:g,subUnitId:c,rule:R};await n.executeCommand(w.AddSheetDataValidationCommand.id,y),i.setActiveRule({unitId:g,subUnitId:c,rule:R})},m=()=>{n.executeCommand(w.RemoveSheetAllDataValidationCommand.id,{unitId:g,subUnitId:c})},V=(R=>{const y=a.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET),b=y.getActiveSheet(),I=y.getUnitId(),C=b.getSheetId();return R.map(L=>X.checkRangesEditablePermission(o,I,C,L.ranges)?{...L}:{...L,disable:!0})})(l),S=V==null?void 0:V.some(R=>R.disable);return h.jsxs("div",{className:Fe.dataValidationList,children:[V==null?void 0:V.map(R=>{var y;return h.jsx(zn,{unitId:g,subUnitId:c,onClick:()=>{R.disable||i.setActiveRule({unitId:g,subUnitId:c,rule:R})},rule:R,disable:(y=R.disable)!=null?y:!1},R.uid)}),h.jsxs("div",{className:Fe.dataValidationListButtons,children:[l.length&&!S?h.jsx(T.Button,{className:Fe.dataValidationListButton,onClick:m,children:s.t("dataValidation.panel.removeAll")}):null,h.jsx(T.Button,{className:Fe.dataValidationListButton,type:"primary",onClick:_,children:s.t("dataValidation.panel.add")})]})]})}const Qn=()=>{const e=f.useDependency(ue),t=f.useObservable(e.activeRule$,e.activeRule);return t?h.jsx(Wn,{},t.rule.uid):h.jsx(Zn,{})},qe="data-validation.list.dropdown",_t="data-validation.date.dropdown",Ze={type:r.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(r.IUniverInstanceService),a=X.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:o}=a,i=w.createDefaultNewRule(e),s=e.get(r.ICommandService),l=n.getUnitId(),d=o.getSheetId(),u={rule:i,unitId:l,subUnitId:d};return s.syncExecuteCommand(w.AddSheetDataValidationCommand.id,u)?(s.syncExecuteCommand(De.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var ea=Object.getOwnPropertyDescriptor,ta=(e,t,a,n)=>{for(var o=n>1?void 0:n?ea(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Re=(e,t)=>(a,n)=>t(a,n,e);const Se="SHEET_DATA_VALIDATION_ALERT";let Ae=class extends r.Disposable{constructor(e,t,a,n,o,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=o,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(le.debounceTime(100)).subscribe(e=>{var t;if(e){const a=this._univerInstanceService.getUnit(e.location.unitId,r.UniverInstanceType.UNIVER_SHEET),n=a.getSheetBySheetId(e.location.subUnitId);if(!n)return;const o=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!o){this._cellAlertManagerService.removeAlert(Se);return}if(this._dataValidationModel.validator(o,{...e.location,workbook:a,worksheet:n})===r.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Se),l=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(l&&l.row===e.location.row&&l.col===e.location.col&&l.subUnitId===e.location.subUnitId&&l.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(Se);return}const d=this._dataValidationModel.getValidator(o.type);if(!d){this._cellAlertManagerService.removeAlert(Se);return}this._cellAlertManagerService.showAlert({type:B.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:d==null?void 0:d.getRuleFinalError(o,e.location),location:e.location,width:200,height:74,key:Se});return}}this._cellAlertManagerService.removeAlert(Se)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(Se)}))}};Ae=ta([Re(0,r.Inject(B.HoverManagerService)),Re(1,r.Inject(B.CellAlertManagerService)),Re(2,r.IUniverInstanceService),Re(3,r.Inject(r.LocaleService)),Re(4,f.IZenZoneService),Re(5,r.Inject(w.SheetDataValidationModel))],Ae);var na=Object.getOwnPropertyDescriptor,aa=(e,t,a,n)=>{for(var o=n>1?void 0:n?na(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},et=(e,t)=>(a,n)=>t(a,n,e);let we=class extends r.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,o)=>{const{source:i,target:s,unitId:l,subUnitId:d}=n,u=this._sheetDataValidationModel.getRuleObjectMatrix(l,d).clone(),p=B.virtualizeDiscreteRanges([i,s]),[g,c]=p.ranges,{mapFunc:_}=p,m={row:g.startRow,col:g.startColumn},D=B.getAutoFillRepeatRange(g,c),V=new r.ObjectMatrix,S=new Set;D.forEach(C=>{const v=C.repeatStartCell,L=C.relativeRange,j={startRow:m.row,startColumn:m.col,endColumn:m.col,endRow:m.row},N={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row};r.Range.foreach(L,(F,P)=>{const x=r.Rectangle.getPositionRange({startRow:F,startColumn:P,endColumn:P,endRow:F},j),{row:k,col:U}=_(x.startRow,x.startColumn),$=this._sheetDataValidationModel.getRuleIdByLocation(l,d,k,U)||"",G=r.Rectangle.getPositionRange({startRow:F,startColumn:P,endColumn:P,endRow:F},N),{row:q,col:K}=_(G.startRow,G.startColumn);V.setValue(q,K,$),S.add($)})});const R=Array.from(S).map(C=>({id:C,ranges:r.queryObjectMatrix(V,v=>v===C)}));u.addRangeRules(R);const y=u.diff(this._sheetDataValidationModel.getRules(l,d)),{redoMutations:b,undoMutations:I}=w.getDataValidationDiffMutations(l,d,y,this._injector,"patched",o===B.APPLY_TYPE.ONLY_FORMAT);return{undos:I,redos:b}},a={id:w.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:o,unitId:i,subUnitId:s}=n;for(const l of o.rows)for(const d of o.cols){const u=this._sheetDataValidationModel.getRuleByLocation(i,s,l,d);if(u&&u.type===r.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(B.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,o,i)=>i===B.APPLY_TYPE.COPY||i===B.APPLY_TYPE.ONLY_FORMAT||i===B.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};we=aa([et(0,B.IAutoFillService),et(1,r.Inject(w.SheetDataValidationModel)),et(2,r.Inject(r.Injector))],we);var oa=Object.getOwnPropertyDescriptor,ia=(e,t,a,n)=>{for(var o=n>1?void 0:n?oa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},tt=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends r.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:w.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,o)=>{const{copyType:i=B.COPY_TYPE.COPY,pasteType:s}=o,{range:l}=t||{},{range:d,unitId:u,subUnitId:p}=a;return this._generateMutations(d,{copyType:i,pasteType:s,copyRange:l,unitId:u,subUnitId:p})}})}_collect(t,a,n){const o=new r.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:o};const i=this._injector.invoke(d=>X.rangeToDiscreteRange(n,d,t,a));if(!i)return;const{rows:s,cols:l}=i;s.forEach((d,u)=>{l.forEach((p,g)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(t,a,d,p);o.setValue(u,g,c!=null?c:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===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:o,subUnitId:i}=this._copyInfo;if(a.unitId!==o||i!==a.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),l=new r.ObjectMatrix,d=new Set,{ranges:[u,p],mapFunc:g}=B.virtualizeDiscreteRanges([a.copyRange,t]),c=B.getRepeatRange(u,p,!0),_=new Map;c.forEach(({startRange:S})=>{var R;(R=this._copyInfo)==null||R.matrix.forValue((y,b,I)=>{const C=r.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:b,endColumn:b},S),v=`${i}-${I}`,L=this._sheetDataValidationModel.getRuleById(o,i,I);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,v)&&L&&_.set(v,{...L,uid:v});const{row:j,col:N}=g(C.startRow,C.startColumn);d.add(v),l.setValue(j,N,v)})});const m=Array.from(d).map(S=>({id:S,ranges:r.queryObjectMatrix(l,R=>R===S)}));s.addRangeRules(m);const{redoMutations:D,undoMutations:V}=w.getDataValidationDiffMutations(a.unitId,a.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),_.values()),this._injector,"patched",!1);return{redos:D,undos:V}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(o,i).clone(),l=new r.ObjectMatrix,d=new Set,{ranges:[u,p],mapFunc:g}=B.virtualizeDiscreteRanges([a.copyRange,t]);B.getRepeatRange(u,p,!0).forEach(({startRange:V})=>{var S;(S=this._copyInfo)==null||S.matrix.forValue((R,y,b)=>{const I=r.Rectangle.getPositionRange({startRow:R,endRow:R,startColumn:y,endColumn:y},V),{row:C,col:v}=g(I.startRow,I.startColumn);l.setValue(C,v,b),d.add(b)})});const _=Array.from(d).map(V=>({id:V,ranges:r.queryObjectMatrix(l,S=>S===V)}));s.addRangeRules(_);const{redoMutations:m,undoMutations:D}=w.getDataValidationDiffMutations(o,i,s.diff(this._sheetDataValidationModel.getRules(o,i)),this._injector,"patched",!1);return{redos:m,undos:D}}}};Ee=ia([tt(0,B.ISheetClipboardService),tt(1,r.Inject(w.SheetDataValidationModel)),tt(2,r.Inject(r.Injector))],Ee);var ra=Object.getOwnPropertyDescriptor,sa=(e,t,a,n)=>{for(var o=n>1?void 0:n?ra(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},nt=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends r.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===w.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===w.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=sa([nt(0,r.Inject(r.LocaleService)),nt(1,r.ICommandService),nt(2,r.Inject(X.SheetPermissionCheckController))],Me);const kt="data-validation-single",Ut="sheet.menu.data-validation";function la(e){return{id:Ut,type:f.MenuItemType.SUBITEMS,icon:kt,tooltip:"dataValidation.title",hidden$:f.getMenuHiddenObservable(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:B.getCurrentRangeDisable$(e,{workbookTypes:[X.WorkbookEditablePermission],worksheetTypes:[X.WorksheetSetCellStylePermission,X.WorksheetEditPermission],rangeTypes:[X.RangeProtectionPermissionEditPoint]})}}function da(e){return{id:De.id,title:"dataValidation.panel.title",type:f.MenuItemType.BUTTON}}function ca(e){return{id:Ze.id,title:"dataValidation.panel.add",type:f.MenuItemType.BUTTON}}const ua={[f.RibbonStartGroup.FORMULAS_INSERT]:{[Ut]:{order:9,menuItemFactory:la,[De.id]:{order:0,menuItemFactory:da},[Ze.id]:{order:1,menuItemFactory:ca}}}};var ha=Object.getOwnPropertyDescriptor,Nt=(e,t,a,n)=>{for(var o=n>1?void 0:n?ha(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},J=(e,t)=>(a,n)=>t(a,n,e);const Bt={tr:{size:6,color:"#fe4b4b"}};let be=class extends r.RxDisposable{constructor(e,t,a,n,o,i,s,l,d,u,p){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=o,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=l,this._sheetInterceptorService=d,this._dataValidationCacheService=u,this._editorBridgeService=p,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(ua)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var a;if(!e.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:o,row:i,column:s}=t,l=this._univerInstanceService.getUniverSheetInstance(n);if(!l)return;const d=this._sheetDataValidationModel.getRuleByLocation(n,o,i,s);if(!d)return;const u=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!(u!=null&&u.dropdown))return;const p=l.getActiveSheet();if(!p)return;const g=this._dropdownManagerService.activeDropdown,c=g==null?void 0:g.location;if(c&&c.unitId===n&&c.subUnitId===o&&c.row===i&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:o,row:i,col:s,workbook:l,worksheet:p},componentKey:u.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var S,R,y,b,I;const{row:n,col:o,unitId:i,subUnitId:s,workbook:l,worksheet:d}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,o);if(!u)return a(e);const p=this._sheetDataValidationModel.getRuleById(i,s,u);if(!p)return a(e);const g=(S=this._dataValidationCacheService.getValue(i,s,n,o))!=null?S:r.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),_=t.rawData;let m;const D={get value(){var C;return m!==void 0||(m=(C=w.getCellValueOrigin(_))!=null?C:null),m}},V={get value(){var C;return`${(C=D.value)!=null?C:""}`}};return a({...e,markers:{...e==null?void 0:e.markers,...g===r.DataValidationStatus.INVALID?Bt:null},customRender:[...(R=e==null?void 0:e.customRender)!=null?R:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((b=c==null?void 0:c.skipDefaultFontRender)==null?void 0:b.call(c,p,D.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,V.value,{get style(){const C=l.getStyles();return(typeof(e==null?void 0:e.s)=="string"?C.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,o)},interceptorAutoHeight:()=>{var j,N,F,P,x,k;const C=(N=(j=this._renderManagerService.getRenderById(i))==null?void 0:j.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:N.skeleton;if(!C)return;const v=C.worksheet.getMergedCell(n,o),L={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((F=v==null?void 0:v.startRow)!=null?F:n,(P=v==null?void 0:v.startColumn)!=null?P:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(k=(x=c==null?void 0:c.canvasRender)==null?void 0:x.calcCellAutoHeight)==null?void 0:k.call(x,L)},interceptorAutoWidth:()=>{var j,N,F,P,x,k;const C=(N=(j=this._renderManagerService.getRenderById(i))==null?void 0:j.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:N.skeleton;if(!C)return;const v=C.worksheet.getMergedCell(n,o),L={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((F=v==null?void 0:v.startRow)!=null?F:n,(P=v==null?void 0:v.startColumn)!=null?P:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(k=(x=c==null?void 0:c.canvasRender)==null?void 0:x.calcCellAutoWidth)==null?void 0:k.call(x,L)},coverable:((I=e==null?void 0:e.coverable)!=null?I:!0)&&!(p.type===r.DataValidationType.LIST||p.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(le.filter(e=>e.source==="command"),le.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(a=>{var n;(a.rule.type===r.DataValidationType.LIST_MULTIPLE||a.rule.type===r.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(a.redos,this._commandService)}})}};be=Nt([J(0,r.ICommandService),J(1,f.IMenuManagerService),J(2,W.IRenderManagerService),J(3,r.IUniverInstanceService),J(4,r.Inject(B.AutoHeightController)),J(5,r.Inject(me)),J(6,r.Inject(w.SheetDataValidationModel)),J(7,r.Inject(Q.DataValidatorRegistryService)),J(8,r.Inject(X.SheetInterceptorService)),J(9,r.Inject(w.DataValidationCacheService)),J(10,r.Optional(B.IEditorBridgeService))],be);let yt=class extends r.RxDisposable{constructor(e,t,a,n,o,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=o,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var V,S,R,y,b;const{row:n,col:o,unitId:i,subUnitId:s,workbook:l,worksheet:d}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,o);if(!u)return a(e);const p=this._sheetDataValidationModel.getRuleById(i,s,u);if(!p)return a(e);const g=(V=this._dataValidationCacheService.getValue(i,s,n,o))!=null?V:r.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),_=d.getCellRaw(n,o),m=w.getCellValueOrigin(_),D=`${m!=null?m:""}`;return a({...e,markers:{...e==null?void 0:e.markers,...g===r.DataValidationStatus.INVALID?Bt:null},customRender:[...(S=e==null?void 0:e.customRender)!=null?S:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((R=e==null?void 0:e.fontRenderExtension)==null?void 0:R.isSkip)||((y=c==null?void 0:c.skipDefaultFontRender)==null?void 0:y.call(c,p,m,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,D,{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,o)},interceptorAutoHeight:()=>{var L,j,N,F,P,x;const I=(j=(L=this._renderManagerService.getRenderById(i))==null?void 0:L.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:j.skeleton;if(!I)return;const C=I.worksheet.getMergedCell(n,o),v={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((N=C==null?void 0:C.startRow)!=null?N:n,(F=C==null?void 0:C.startColumn)!=null?F:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(x=(P=c==null?void 0:c.canvasRender)==null?void 0:P.calcCellAutoHeight)==null?void 0:x.call(P,v)},coverable:((b=e==null?void 0:e.coverable)!=null?b:!0)&&!(p.type===r.DataValidationType.LIST||p.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(le.filter(e=>e.source==="command"),le.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(a.redos,this._commandService)}})}};yt=Nt([J(0,r.ICommandService),J(1,W.IRenderManagerService),J(2,r.Inject(B.AutoHeightController)),J(3,r.Inject(Q.DataValidatorRegistryService)),J(4,r.Inject(X.SheetInterceptorService)),J(5,r.Inject(w.SheetDataValidationModel)),J(6,r.Inject(w.DataValidationCacheService))],yt);var pa=Object.getOwnPropertyDescriptor,ga=(e,t,a,n)=>{for(var o=n>1?void 0:n?pa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Rt=(e,t)=>(a,n)=>t(a,n,e);let Ye=class extends r.Disposable{constructor(e,t,a){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const a=new Set;t.forEach(o=>{a.add(o.subUnitId)}),a.forEach(o=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(o))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(r.bufferDebounceTime(16)).subscribe(e))}};Ye=ga([Rt(1,r.Inject(w.SheetDataValidationModel)),Rt(2,r.Inject(B.SheetSkeletonManagerService))],Ye);const ma="univer-data-validation-formula",va="univer-data-validation-formula-and",fa="univer-data-validation-formula-list-item",Sa="univer-data-validation-formula-list-item-icon",_a="univer-data-validation-formula-list-item-drag",Ia="univer-data-validation-formula-list-add",Ca="univer-data-validation-formula-color-select",Da="univer-data-validation-formula-color-select-panel",ya="univer-data-validation-formula-color-item",ae={dataValidationFormula:ma,dataValidationFormulaAnd:va,dataValidationFormulaListItem:fa,dataValidationFormulaListItemIcon:Sa,dataValidationFormulaListItemDrag:_a,dataValidationFormulaListAdd:Ia,dataValidationFormulaColorSelect:Ca,dataValidationFormulaColorSelectPanel:Da,dataValidationFormulaColorItem:ya},Ra=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:o,validResult:i}=e,s=f.useDependency(r.LocaleService),l=o?i==null?void 0:i.formula1:"",d=o?i==null?void 0:i.formula2:"";return t?h.jsxs(h.Fragment,{children:[h.jsx(T.FormLayout,{error:l,children:h.jsx(T.Input,{className:ae.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({...a,formula1:u})}})}),h.jsx("div",{className:ae.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),h.jsx(T.FormLayout,{error:d,children:h.jsx(T.Input,{className:ae.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:u=>{n==null||n({...a,formula2:u})}})})]}):h.jsx(T.FormLayout,{error:l,children:h.jsx(T.Input,{className:ae.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({formula1:u})}})})};function Va(e){const{value:t,onChange:a,showError:n,validResult:o}=e,i=f.useDependency(r.LocaleService),s=n?o==null?void 0:o.formula1:"",l=n?o==null?void 0:o.formula2:"",[d,u]=E.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return h.jsxs(h.Fragment,{children:[h.jsx(T.FormLayout,{children:h.jsx(T.Checkbox,{checked:d,onChange:p=>{p?u(!0):(u(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),d?h.jsx(T.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:h.jsx(T.Input,{className:ae.dataValidationFormula,placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:p=>{a==null||a({...t,formula1:p||void 0})}})}):null,d?h.jsx(T.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:l,children:h.jsx(T.Input,{className:ae.dataValidationFormula,placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:p=>{a==null||a({...t,formula2:p||void 0})}})}):null]})}function wa(e){var g;const{unitId:t,subUnitId:a,value:n,onChange:o,showError:i,validResult:s}=e,l=i?s==null?void 0:s.formula1:void 0,d=E.useRef({}),[u,p]=E.useState(!1);return f.useSidebarClick(c=>{var m;const _=(m=d.current)==null?void 0:m.handleOutClick;_&&_(c,()=>p(!1))}),h.jsx(mt.FormulaEditor,{initValue:(g=n==null?void 0:n.formula1)!=null?g:"=",unitId:t,subUnitId:a,isFocus:u,onChange:c=>{const _=(c!=null?c:"").trim();_!==(n==null?void 0:n.formula1)&&(o==null||o({...n,formula1:_}))},errorText:l,onFocus:()=>p(!0),actions:d.current,isSupportAcrossSheet:!0})}function Wt(e){var t,a,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(a=Wt(e[t]))&&(n&&(n+=" "),n+=a)}else for(a in e)e[a]&&(n&&(n+=" "),n+=a);return n}function Ea(){for(var e,t,a=0,n="",o=arguments.length;a<o;a++)(e=arguments[a])&&(t=Wt(e))&&(n&&(n+=" "),n+=t);return n}const Ma=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],ba=e=>{const{value:t,onChange:a,disabled:n}=e,[o,i]=E.useState(!1);return h.jsx(T.Select,{disabled:n,open:o,onDropdownVisibleChange:i,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ae.dataValidationFormulaColorSelect,value:t,onChange:a,labelRender:s=>h.jsx("div",{className:ae.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>h.jsx("div",{className:ae.dataValidationFormulaColorSelectPanel,children:Ma.map(s=>h.jsx("div",{onClick:()=>{a(s),i(!1)},className:ae.dataValidationFormulaColorItem,style:{background:s}},s))})})},Vt=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:o,onItemDelete:i}=a;return h.jsxs("div",{className:ae.dataValidationFormulaListItem,style:n,children:[t.isRef?null:h.jsx("div",{className:Ea(ae.dataValidationFormulaListItemDrag,"draggableHandle"),children:h.jsx(At,{})}),h.jsx(ba,{value:t.color,onChange:s=>{o(t.id,t.label,s)}}),h.jsx(T.Input,{disabled:t.isRef,value:t.label,onChange:s=>{o(t.id,s,t.color)}}),t.isRef?null:h.jsx("div",{className:ae.dataValidationFormulaListItemIcon,children:h.jsx(vt,{onClick:()=>i(t.id)})})]})};function Ta(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:o,validResult:i,showError:s,ruleId:l}=e,{formula1:d="",formula2:u=""}=t||{},p=E.useRef(null),[g,c]=E.useState(()=>r.isFormulaString(d)?"1":"0"),[_,m]=E.useState(g==="1"?d:"="),[D,V]=E.useState(g==="1"?d:"="),S=f.useDependency(r.LocaleService),R=f.useDependency(Q.DataValidatorRegistryService),y=f.useDependency(Q.DataValidationModel),b=f.useDependency(w.DataValidationFormulaController),[I,C]=E.useState(()=>u.split(",")),v=R.getValidatorItem(r.DataValidationType.LIST),[L,j]=E.useState([]),[N,F]=E.useState(""),P=s?i==null?void 0:i.formula1:"",x=E.useMemo(()=>y.ruleChange$.pipe(le.debounceTime(16)),[]),k=f.useObservable(x),U=f.useEvent(a);E.useEffect(()=>{(async()=>{await new Promise(Y=>{setTimeout(()=>Y(!0),100)});const M=y.getRuleById(n,o,l),H=M==null?void 0:M.formula1;if(r.isFormulaString(H)&&v&&M){const Y=await v.getListAsync(M,n,o);j(Y)}})()},[y,k,v,l,o,n]),E.useEffect(()=>{r.isFormulaString(d)&&d!==D&&(m(d),V(D))},[D,d]);const[$,G]=E.useState(()=>{const M=g!=="1"?w.deserializeListOptions(d):[],H=u.split(",");return M.map((Y,z)=>({label:Y,color:H[z]||Ce,isRef:!1,id:r.Tools.generateRandomId(4)}))}),q=(M,H,Y)=>{const z=$.find(ge=>ge.id===M);z&&(z.label=H,z.color=Y,G([...$]))},K=M=>{const H=$.findIndex(Y=>Y.id===M);H!==-1&&($.splice(H,1),G([...$]))},Z=u.split(","),ee=E.useMemo(()=>L.map((M,H)=>({label:M,color:Z[H]||Ce,id:`${H}`,isRef:!0})),[Z,L]),te=(M,H,Y)=>{const z=[...I];z[+M]=Y,C(z),U({formula1:d,formula2:z.join(",")})},ne=()=>{G([...$,{label:"",color:Ce,isRef:!1,id:r.Tools.generateRandomId(4)}])};E.useEffect(()=>{if(g==="1")return;const M=new Set,H=[];$.map(Y=>({labelList:Y.label.split(","),item:Y})).forEach(({item:Y,labelList:z})=>{z.forEach(ge=>{M.has(ge)||(M.add(ge),H.push({label:ge,color:Y.color}))})}),U({formula1:w.serializeListOptions(H.map(Y=>Y.label)),formula2:H.map(Y=>Y.color===Ce?"":Y.color).join(",")})},[$,U,g,D,I]);const ie=f.useEvent(async M=>{if(!r.isFormulaString(M)){U==null||U({formula1:"",formula2:u});return}b.getFormulaRefCheck(M)?(U==null||U({formula1:r.isFormulaString(M)?M:"",formula2:u}),F("")):(U==null||U({formula1:"",formula2:u}),m("="),F(S.t("dataValidation.validFail.formulaError")))}),oe=E.useRef({}),[re,A]=E.useState(!1);return f.useSidebarClick(M=>{var Y;const H=(Y=oe.current)==null?void 0:Y.handleOutClick;H&&H(M,()=>A(!1))}),h.jsxs(h.Fragment,{children:[h.jsx(T.FormLayout,{label:S.t("dataValidation.list.options"),children:h.jsxs(T.RadioGroup,{value:g,onChange:M=>{c(M),m(D),M==="1"&&U({formula1:D==="="?"":D,formula2:I.join(",")})},children:[h.jsx(T.Radio,{value:"0",children:S.t("dataValidation.list.customOptions")}),h.jsx(T.Radio,{value:"1",children:S.t("dataValidation.list.refOptions")})]})}),g==="1"?h.jsxs(h.Fragment,{children:[h.jsx(mt.FormulaEditor,{initValue:_,unitId:n,subUnitId:o,isFocus:re,onChange:(M="")=>{const H=(M!=null?M:"").trim();V(H),ie(H)},errorText:P||N||void 0,onFocus:()=>A(!0),actions:oe.current,isSupportAcrossSheet:!0}),h.jsx("div",{ref:p,style:{marginTop:"12px"},children:ee.map(M=>h.jsx(Vt,{item:M,commonProps:{onItemChange:te},style:{marginBottom:12}},M.id))})]}):h.jsx(T.FormLayout,{error:P,children:h.jsxs("div",{ref:p,style:{marginTop:"-12px"},children:[h.jsx(T.DraggableList,{list:$,onListChange:G,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:M=>h.jsx(Vt,{item:M,commonProps:{onItemChange:q,onItemDelete:K}},M.id),idKey:"id"}),h.jsxs("a",{className:ae.dataValidationFormulaListAdd,onClick:ne,children:[h.jsx(Lt,{}),S.t("dataValidation.list.add")]})]})})]})}const $t="data-validation.custom-formula-input",Je="data-validation.formula-input",It="data-validation.list-formula-input",Ht="data-validation.checkbox-formula-input",La=[[$t,wa],[Je,Ra],[It,Ta],[Ht,Va]],Oa="LIST_RENDER_MODE_OPTION_INPUT";function Xe(e){var o;const{value:t,onChange:a}=e,n=f.useDependency(r.LocaleService);return h.jsx(T.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:h.jsxs(T.RadioGroup,{value:`${(o=t.renderMode)!=null?o:r.DataValidationRenderMode.CUSTOM}`,onChange:i=>a({...t,renderMode:+i}),children:[h.jsx(T.Radio,{value:`${r.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),h.jsx(T.Radio,{value:`${r.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),h.jsx(T.Radio,{value:`${r.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}Xe.componentKey=Oa;const Pa="DATE_SHOW_TIME_OPTION";function ze(e){var o;const{value:t,onChange:a}=e,n=f.useDependency(r.LocaleService);return h.jsx(T.FormLayout,{children:h.jsx(T.Checkbox,{checked:(o=t.bizInfo)==null?void 0:o.showTime,onChange:i=>{a({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:n.t("dataValidation.showTime.label")})})}ze.componentKey=Pa;var Aa=Object.getOwnPropertyDescriptor,ja=(e,t,a,n)=>{for(var o=n>1?void 0:n?Aa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Oe=(e,t)=>(a,n)=>t(a,n,e);const xe=6;let ut=class{constructor(e,t,a,n,o){this._commandService=e,this._formulaService=t,this._themeService=a,this._renderManagerService=n,this._dataValidationModel=o}_calc(e,t){var u,p,g;const{vt:a,ht:n}=t||{},o=e.endX-e.startX-xe*2,i=e.endY-e.startY,s=((u=t==null?void 0:t.fs)!=null?u:10)*1.6;let l=0,d=0;switch(a){case r.VerticalAlign.TOP:d=0;break;case r.VerticalAlign.BOTTOM:d=0+(i-s);break;default:d=0+(i-s)/2;break}switch(n){case r.HorizontalAlign.LEFT:l=xe;break;case r.HorizontalAlign.RIGHT:l=xe+(o-s);break;default:l=xe+(o-s)/2;break}return{left:e.startX+l,top:e.startY+d,width:((p=t==null?void 0:t.fs)!=null?p:10)*1.6,height:((g=t==null?void 0:t.fs)!=null?g:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var u,p,g,c,_,m,D,V,S;const{formula1:n=w.CHECKBOX_FORMULA_1,formula2:o=w.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=w.getFormulaResult((g=(p=(u=i==null?void 0:i[0])==null?void 0:u.result)==null?void 0:p[0])==null?void 0:g[0]),l=w.getFormulaResult((m=(_=(c=i==null?void 0:i[1])==null?void 0:c.result)==null?void 0:_[0])==null?void 0:m[0]),d=w.isLegalFormulaResult(String(s))&&w.isLegalFormulaResult(String(l));return{formula1:r.isFormulaString(n)?w.getFormulaResult((S=(V=(D=i==null?void 0:i[0])==null?void 0:D.result)==null?void 0:V[0])==null?void 0:S[0]):n,formula2:r.isFormulaString(o)?l:o,isFormulaValid:d}}drawWith(e,t){var P,x,k,U;const{style:a,primaryWithCoord:n,unitId:o,subUnitId:i,worksheet:s,row:l,col:d}=t,u=n.isMergedMainCell?n.mergeInfo:n,p=w.getCellValueOrigin(s.getCellRaw(l,d)),g=this._dataValidationModel.getRuleByLocation(o,i,l,d);if(!g)return;const c=this._dataValidationModel.getValidator(g.type);if(!c)return;const _=this._themeService.getCurrentTheme();if(!((P=c.skipDefaultFontRender)!=null&&P.call(c,g,p,{unitId:o,subUnitId:i,row:l,column:d})))return;const m=c.parseFormulaSync(g,o,i),{formula1:D}=m,V=this._calc(u,a),{a:S,d:R}=e.getTransform(),y=W.fixLineWidthByScale(V.left,S),b=W.fixLineWidthByScale(V.top,R),I=W.Transform.create().composeMatrix({left:y,top:b,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 L=I.getMatrix();e.transform(L[0],L[1],L[2],L[3],L[4],L[5]);const j=((x=a==null?void 0:a.fs)!=null?x:10)*1.6,N=String(p)===String(D),F=_.hyacinth500;W.CheckboxShape.drawWith(e,{checked:N,width:j,height:j,fill:(U=(k=a==null?void 0:a.cl)==null?void 0:k.rgb)!=null?U:F}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),o=n.top,i=n.top+n.height,s=n.left,l=n.left+n.width,{x:d,y:u}=e;return d<=l&&d>=s&&u<=i&&u>=o}async onPointerDown(e,t){var m;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:o,worksheet:i,row:s,col:l}=e,d=w.getCellValueOrigin(i.getCellRaw(s,l)),u=this._dataValidationModel.getRuleByLocation(n,o,s,l);if(!u)return;const p=this._dataValidationModel.getValidator(u.type);if(!p||!((m=p.skipDefaultFontRender)!=null&&m.call(p,u,d,{unitId:n,subUnitId:o,row:s,column:l})))return;const{formula1:g,formula2:c}=await this._parseFormula(u,n,o),_={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(d)===w.transformCheckboxValue(String(g))?c:g,p:null}};this._commandService.executeCommand(X.SetRangeValuesCommand.id,_)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(W.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(W.CURSOR_TYPE.DEFAULT)}};ut=ja([Oe(0,r.ICommandService),Oe(1,r.Inject(w.DataValidationFormulaService)),Oe(2,r.Inject(r.ThemeService)),Oe(3,r.Inject(W.IRenderManagerService)),Oe(4,r.Inject(w.SheetDataValidationModel))],ut);var Fa=Object.getOwnPropertyDescriptor,xa=(e,t,a,n)=>{for(var o=n>1?void 0:n?Fa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},ka=(e,t)=>(a,n)=>t(a,n,e);let he=class{constructor(e){O(this,"canvasRender",null);O(this,"dropdown");O(this,"optionsInput");O(this,"formulaInput",It);this.injector=e}};he=xa([ka(0,r.Inject(r.Injector))],he);class Ua extends he{constructor(){super(...arguments);O(this,"id",r.DataValidationType.CHECKBOX);O(this,"canvasRender",this.injector.createInstance(ut));O(this,"formulaInput",Ht)}}class Na extends he{constructor(){super(...arguments);O(this,"id",r.DataValidationType.CUSTOM);O(this,"formulaInput",$t)}}const Ba="data-validation.formula-input";class Wa extends he{constructor(){super(...arguments);O(this,"id",r.DataValidationType.DATE);O(this,"formulaInput",Ba);O(this,"optionsInput",ze.componentKey);O(this,"dropdown",_t)}}class $a extends he{constructor(){super(...arguments);O(this,"id",r.DataValidationType.DECIMAL);O(this,"formulaInput",Je)}}const Yt=4,Ha=0,at=4,Xt=4,ht=6,Ke=6,Ie=14;function Ya(e,t){const a=W.FontCache.getTextSize(e,t),n=a.width+Yt*2,{ba:o,bd:i}=a,s=o+i;return{width:n,height:s+Ha*2,ba:o}}function ot(e,t,a,n){const o=Ie+ht*2,i=a-o,s=n-Ke*2,l=e.map(c=>({layout:Ya(c,t),text:c}));let d;const u=[];l.forEach(c=>{const{layout:_}=c,{width:m,height:D}=_;!d||d.width+m+at>i?(d={width:m,height:D,items:[{...c,left:0}]},u.push(d)):(d.items.push({...c,left:d.width+at}),d.width=d.width+m+at)});let p=0,g=0;return u.forEach((c,_)=>{g=Math.max(g,c.width),_===u.length-1?p+=c.height:p+=c.height+Xt}),{lines:u,totalHeight:p,contentWidth:i,contentHeight:s,cellAutoHeight:p+Ke*2,calcAutoWidth:g+o}}const Xa=8;class za extends W.Shape{static drawWith(t,a){const{fontString:n,info:o,fill:i,color:s}=a,{layout:l,text:d}=o;t.save(),W.Rect.drawWith(t,{width:l.width,height:l.height,radius:Xa,fill:i||Ce}),t.translateWithPrecision(Yt,l.ba),t.font=n,t.fillStyle=s,t.fillText(d,0,0),t.restore()}}var Ka=Object.getOwnPropertyDescriptor,Ga=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ka(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},it=(e,t)=>(a,n)=>t(a,n,e);const qa=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let pt=class{constructor(e,t,a){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,o){const i=a-Ie+4;let s=4;switch(o){case r.VerticalAlign.MIDDLE:s=(n-Ie)/2+4;break;case r.VerticalAlign.BOTTOM:s=n-Ie+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(qa),e.restore()}drawWith(e,t,a,n){var q,K;const{primaryWithCoord:o,row:i,col:s,style:l,data:d,subUnitId:u}=t,p=o.isMergedMainCell?o.mergeInfo:o,g=d==null?void 0:d.fontRenderExtension,{leftOffset:c=0,rightOffset:_=0,topOffset:m=0,downOffset:D=0}=g||{},V=this._ensureMap(u),S=this._generateKey(i,s),R=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,s);if(!R)return;const y=this._dataValidationModel.getValidator(R.type);if(!y)return;const b={startX:p.startX+c,endX:p.endX-_,startY:p.startY+m,endY:p.endY-D},I=b.endX-b.startX,C=b.endY-b.startY,{cl:v}=l||{},L=(q=typeof v=="object"?v==null?void 0:v.rgb:v)!=null?q:"#000",j=W.getFontStyleString(l!=null?l:void 0),{vt:N,ht:F}=l||{},P=N!=null?N:r.VerticalAlign.MIDDLE,x=(K=w.getCellValueOrigin(d))!=null?K:"",k=y.parseCellValue(x),U=y.getListWithColorMap(R),$=ot(k,j,I,C);this._drawDownIcon(e,b,I,C,P),e.save(),e.translateWithPrecision(b.startX,b.startY),e.beginPath(),e.rect(0,0,I-Ie,C),e.clip(),e.translateWithPrecision(ht,Ke);let G=0;switch(P){case r.VerticalAlign.MIDDLE:G=($.contentHeight-$.totalHeight)/2;break;case r.VerticalAlign.BOTTOM:G=$.contentHeight-$.totalHeight;break}e.translateWithPrecision(0,G),$.lines.forEach((Z,ee)=>{e.save();const{width:te,height:ne,items:ie}=Z;let oe=0;switch(F){case r.HorizontalAlign.RIGHT:oe=$.contentWidth-te;break;case r.HorizontalAlign.CENTER:oe=($.contentWidth-te)/2;break}e.translate(oe,ee*(ne+Xt)),ie.forEach(re=>{e.save(),e.translateWithPrecision(re.left,0),za.drawWith(e,{...j,info:re,color:L,fill:U[re.text]}),e.restore()}),e.restore()}),e.restore(),V.set(S,{left:b.startX,top:b.startY,width:$.contentWidth+ht+Ie,height:$.contentHeight+Ke*2})}calcCellAutoHeight(e){var I;const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:u=0,downOffset:p=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,c={startX:g.startX+l,endX:g.endX-d,startY:g.startY+u,endY:g.endY-p},_=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!_)return;const m=this._dataValidationModel.getValidator(_.type);if(!m)return;const D=c.endX-c.startX,V=c.endY-c.startY,S=(I=w.getCellValueOrigin(n))!=null?I:"",R=m.parseCellValue(S),y=W.getFontStyleString(a!=null?a:void 0);return ot(R,y,D,V).cellAutoHeight}calcCellAutoWidth(e){var I;const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:u=0,downOffset:p=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,c={startX:g.startX+l,endX:g.endX-d,startY:g.startY+u,endY:g.endY-p},_=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!_)return;const m=this._dataValidationModel.getValidator(_.type);if(!m)return;const D=c.endX-c.startX,V=c.endY-c.startY,S=(I=w.getCellValueOrigin(n))!=null?I:"",R=m.parseCellValue(S),y=W.getFontStyleString(a!=null?a:void 0);return ot(R,y,D,V).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:o}=n,{x:i}=e;return i>=o-Ie&&i<=o}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:i}=e,s={unitId:a,subUnitId:n,row:o,column:i};this._commandService.executeCommand(Ge.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(W.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(W.CURSOR_TYPE.DEFAULT)}};pt=Ga([it(0,r.ICommandService),it(1,r.Inject(W.IRenderManagerService)),it(2,r.Inject(w.SheetDataValidationModel))],pt);class Za extends he{constructor(){super(...arguments);O(this,"id",r.DataValidationType.LIST_MULTIPLE);O(this,"canvasRender",this.injector.createInstance(pt));O(this,"dropdown",qe)}}var Ja=Object.getOwnPropertyDescriptor,Qa=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ja(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},ke=(e,t)=>(a,n)=>t(a,n,e);const _e=4,Ue=4,de=14,ce=6,Ve=4,rt=8,eo="#565656",wt=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function to(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${r.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:r.BooleanNumber.FALSE,bl:r.BooleanNumber.FALSE,ul:{s:r.BooleanNumber.FALSE},st:{s:r.BooleanNumber.FALSE},ol:{s:r.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function zt(e,t,a){const n=to(e,a),o=new r.DocumentDataModel(n),i=new W.DocumentViewModel(o);return{documentSkeleton:W.DocumentSkeleton.create(i,t),docModel:o,docViewModel:i}}function Ne(e,t,a){const{documentSkeleton:n,docModel:o,docViewModel:i}=zt(e,t,a);return{documents:new W.Documents(`DOCUMENTS_${r.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:o,docViewModel:i}}function Et(e,t,a,n,o,i,s=!0){let l=0;const d=s?Ve:0;switch(o){case r.VerticalAlign.BOTTOM:l=t-n-d;break;case r.VerticalAlign.MIDDLE:l=(t-n)/2;break;default:l=d;break}l=Math.max(Ve,l);let u=0;switch(i){case r.HorizontalAlign.CENTER:u=(e-a)/2;break;case r.HorizontalAlign.RIGHT:u=e-a;break}return u=Math.max(ce,u),{paddingLeft:u,paddingTop:l}}let gt=class{constructor(e,t,a,n){O(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,o,i,s){const{t:l=r.DEFAULT_STYLES.pd.t,b:d=r.DEFAULT_STYLES.pd.b}=s,u=a-de;let p;switch(i){case r.VerticalAlign.MIDDLE:p=(n-Ue)/2;break;case r.VerticalAlign.BOTTOM:p=n-d-o-Ve+(o/2-Ue/2);break;default:p=l+Ve+(o/2-Ue/2);break}e.save(),e.translateWithPrecision(t.startX+u,t.startY+p),e.fillStyle="#565656",e.fill(wt),e.restore()}drawWith(e,t,a){const{primaryWithCoord:n,row:o,col:i,style:s,data:l,subUnitId:d}=t,u=n.isMergedMainCell?n.mergeInfo:n,p=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,o,i);if(!p)return;const g=this._dataValidationModel.getValidator(p.type);if(!g)return;const c=l==null?void 0:l.fontRenderExtension,{leftOffset:_=0,rightOffset:m=0,topOffset:D=0,downOffset:V=0}=c||{};if(!p||!g||!g||g.id.indexOf(r.DataValidationType.LIST)!==0||!g.skipDefaultFontRender(p))return;const S={startX:u.startX+_,endX:u.endX-m,startY:u.startY+D,endY:u.endY-V},R=S.endX-S.startX,y=S.endY-S.startY,b=this._ensureMap(d),I=this._generateKey(o,i),C=g.getListWithColor(p),v=w.getCellValueOrigin(l),L=`${v!=null?v:""}`,j=C.find(k=>k.label===L);let{tb:N,vt:F,ht:P,pd:x}=s||{};if(N=N!=null?N:r.WrapStrategy.WRAP,F=F!=null?F:r.VerticalAlign.BOTTOM,P=P!=null?P:r.DEFAULT_STYLES.ht,x=x!=null?x:r.DEFAULT_STYLES.pd,p.renderMode===r.DataValidationRenderMode.ARROW){const{l:k=r.DEFAULT_STYLES.pd.l,t:U=r.DEFAULT_STYLES.pd.t,r:$=r.DEFAULT_STYLES.pd.r,b:G=r.DEFAULT_STYLES.pd.b}=x,q=R-k-$-de-4,{documentSkeleton:K,documents:Z,docModel:ee}=Ne(L,this._localeService,s);N===r.WrapStrategy.WRAP&&ee.updateDocumentDataPageSize(Math.max(q,1)),K.calculate(),K.getActualSize();const te=W.getDocsSkeletonPageSize(K),{height:ne,width:ie}=te,{paddingTop:oe,paddingLeft:re}=Et(q,y-U-G,ie,ne,F,P,!0);this._drawDownIcon(e,S,R,y,ne,F,x),e.save(),e.translateWithPrecision(S.startX+k,S.startY+U),e.beginPath(),e.rect(0,0,R-k-$,y-U-G),e.clip(),e.translateWithPrecision(0,oe),e.save(),e.translateWithPrecision(_e,0),e.beginPath(),e.rect(0,0,q,ne),e.clip(),Z.render(e),e.translateWithPrecision(re,0),e.restore(),e.restore(),b.set(I,{left:S.endX+k+a.rowHeaderWidth-de,top:S.startY+U+a.columnHeaderHeight,width:de,height:y-U-G})}else{e.save(),e.translateWithPrecision(S.startX,S.startY),e.beginPath(),e.rect(0,0,R,y),e.clip();const k=R-ce*2-_e-de-4,{documentSkeleton:U,documents:$,docModel:G}=Ne(L,this._localeService,s);N===r.WrapStrategy.WRAP&&G.updateDocumentDataPageSize(Math.max(k,1)),U.calculate();const q=W.getDocsSkeletonPageSize(U),{height:K,width:Z}=q,{paddingTop:ee,paddingLeft:te}=Et(k,y,Z,K,F,P);e.translateWithPrecision(ce,ee);const ne=Math.max(R-ce*2,1),ie=K;W.Rect.drawWith(e,{width:ne,height:ie,fill:(j==null?void 0:j.color)||Ce,radius:rt}),e.save(),e.translateWithPrecision(_e,0),e.beginPath(),e.rect(0,0,k,K),e.clip(),e.translateWithPrecision(te,0),$.render(e),e.restore(),e.translateWithPrecision(k+_e+4,(K-Ue)/2),e.fillStyle=eo,e.fill(wt),e.restore(),b.set(I,{left:S.startX+ce+a.rowHeaderWidth,top:S.startY+ee+a.columnHeaderHeight,width:ne,height:ie})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,l=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:u=0,topOffset:p=0,downOffset:g=0}=l||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!c||c.renderMode===r.DataValidationRenderMode.TEXT)return;const _={startX:s.startX+d,endX:s.endX-u,startY:s.startY+p,endY:s.endY-g},m=_.endX-_.startX,D=w.getCellValueOrigin(n),V=`${D!=null?D:""}`;let{tb:S,pd:R}=a||{};const{t:y=r.DEFAULT_STYLES.pd.t,b=r.DEFAULT_STYLES.pd.b}=R!=null?R:{};if(S=S!=null?S:r.WrapStrategy.WRAP,c.renderMode===r.DataValidationRenderMode.ARROW){const I=m-de,{documentSkeleton:C,docModel:v}=Ne(V,this._localeService,a);S===r.WrapStrategy.WRAP&&v.updateDocumentDataPageSize(Math.max(I,1)),C.calculate(),C.getActualSize();const L=W.getDocsSkeletonPageSize(C),{height:j}=L;return j+y+b+Ve*2}else{const I=m-ce*2-_e-de,{documentSkeleton:C,docModel:v}=zt(V,this._localeService,a);S===r.WrapStrategy.WRAP&&v.updateDocumentDataPageSize(Math.max(I,1)),C.calculate();const L=W.getDocsSkeletonPageSize(C),{height:j}=L;return j+Ve*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,l=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:u=0,topOffset:p=0,downOffset:g=0}=l||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!c||c.renderMode===r.DataValidationRenderMode.TEXT)return;const _={startX:s.startX+d,endX:s.endX-u,startY:s.startY+p,endY:s.endY-g},m=_.endX-_.startX,D=w.getCellValueOrigin(n),V=`${D!=null?D:""}`;let{tb:S,pd:R}=a||{};const{l:y=r.DEFAULT_STYLES.pd.l,r:b=r.DEFAULT_STYLES.pd.r}=R!=null?R:{};S=S!=null?S:r.WrapStrategy.WRAP;let I=ce*2+de;switch(c.renderMode){case r.DataValidationRenderMode.ARROW:I=de+ce*2+b+y;break;case r.DataValidationRenderMode.CUSTOM:I=de+ce*2+_e*2+b+y+rt/2+1;break;default:I=de+ce*2+_e*2+b+y+rt/2+1}const C=m-I,{documentSkeleton:v,docModel:L}=Ne(V,this._localeService,a);return S===r.WrapStrategy.WRAP&&L.updateDocumentDataPageSize(Math.max(C,1)),v.calculate(),v.getActualSize(),W.getDocsSkeletonPageSize(v).width+I}isHit(e,t){const{subUnitId:a,row:n,col:o}=t,s=this._ensureMap(a).get(this._generateKey(n,o)),l=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,o);if(!l||!s||l.renderMode===r.DataValidationRenderMode.TEXT)return!1;const{top:d,left:u,width:p,height:g}=s,{x:c,y:_}=e;return c>=u&&c<=u+p&&_>=d&&_<=d+g}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:i}=e,s={unitId:a,subUnitId:n,row:o,column:i};this._commandService.executeCommand(Ge.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(W.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(W.CURSOR_TYPE.DEFAULT)}};gt=Qa([ke(0,r.Inject(r.LocaleService)),ke(1,r.ICommandService),ke(2,r.Inject(W.IRenderManagerService)),ke(3,r.Inject(w.SheetDataValidationModel))],gt);class no extends he{constructor(){super(...arguments);O(this,"id",r.DataValidationType.LIST);O(this,"canvasRender",this.injector.createInstance(gt));O(this,"dropdown",qe);O(this,"optionsInput",Xe.componentKey);O(this,"formulaInput",It)}}class ao extends he{constructor(){super(...arguments);O(this,"id",r.DataValidationType.TEXT_LENGTH);O(this,"formulaInput",Je)}}class oo extends he{constructor(){super(...arguments);O(this,"id",r.DataValidationType.WHOLE);O(this,"formulaInput",Je)}}var io=Object.getOwnPropertyDescriptor,ro=(e,t,a,n)=>{for(var o=n>1?void 0:n?io(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},st=(e,t)=>(a,n)=>t(a,n,e);let Te=class extends r.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[kt,Tt],[$e,Qn],[jt,_n],[qe,On],[_t,on],[Xe.componentKey,Xe],[ze.componentKey,ze],...La].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[$a,oo,ao,Wa,Ua,no,Za,Na].forEach(e=>{const t=this._injector.createInstance(e),a=this._dataValidatorRegistryService.getValidatorItem(t.id);a&&(a.formulaInput=t.formulaInput,a.canvasRender=t.canvasRender,a.dropdown=t.dropdown,a.optionsInput=t.optionsInput)})}};Te=ro([st(0,r.Inject(r.Injector)),st(1,r.Inject(f.ComponentManager)),st(2,r.Inject(Q.DataValidatorRegistryService))],Te);var so=Object.getOwnPropertyDescriptor,lo=(e,t,a,n)=>{for(var o=n>1?void 0:n?so(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},lt=(e,t)=>(a,n)=>t(a,n,e);const co="SHEET_DATA_VALIDATION_UI_PLUGIN";var Be;exports.UniverSheetsDataValidationUIPlugin=(Be=class extends r.Plugin{constructor(t=He,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:i,...s}=r.merge({},He,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(St,s)}onStarting(){[[ue],[me],[Ae],[we],[be],[Me],[Ee],[Pe],[Te]].forEach(t=>{this._injector.add(t)}),[Ze,Ge,xt,ft,De,Ft].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(Pe),this._injector.get(Ae),this._injector.get(W.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[Ye])}onRendered(){this._injector.get(Te),this._injector.get(be)}onSteady(){this._injector.get(we)}},O(Be,"pluginName",co),O(Be,"type",r.UniverInstanceType.UNIVER_SHEET),Be);exports.UniverSheetsDataValidationUIPlugin=lo([lt(1,r.Inject(r.Injector)),lt(2,r.ICommandService),lt(3,r.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);var uo=Object.getOwnPropertyDescriptor,ho=(e,t,a,n)=>{for(var o=n>1?void 0:n?uo(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},dt=(e,t)=>(a,n)=>t(a,n,e);const po="SHEET_DATA_VALIDATION_UI_PLUGIN";var We;exports.UniverSheetsDataValidationMobileUIPlugin=(We=class extends r.Plugin{constructor(t=He,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:i,...s}=r.merge({},He,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(St,s)}onStarting(){[[ue],[me],[Ae],[we],[be],[Me],[Ee],[Te]].forEach(t=>{this._injector.add(t)}),[Ze,Ge,xt,ft,De,Ft].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(W.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[Ye])}onRendered(){this._injector.get(Te),this._injector.get(be)}onSteady(){this._injector.get(we)}},O(We,"pluginName",po),O(We,"type",r.UniverInstanceType.UNIVER_SHEET),We);exports.UniverSheetsDataValidationMobileUIPlugin=ho([dt(1,r.Inject(r.Injector)),dt(2,r.ICommandService),dt(3,r.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);exports.DATE_DROPDOWN_KEY=_t;exports.LIST_DROPDOWN_KEY=qe;
package/lib/es/index.js CHANGED
@@ -5,10 +5,10 @@ import { jsxs as j, jsx as m, Fragment as wt } from "react/jsx-runtime";
5
5
  import { Inject as E, LocaleService as Q, Disposable as Dt, DataValidationErrorStyle as re, ICommandService as tt, dayjs as Ze, numfmt as qe, CellValueType as Ho, UniverInstanceType as X, toDisposable as xo, IUniverInstanceService as vt, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as jo, DisposableCollection as Yo, CommandType as te, BuildTextUtils as Xo, DataValidationRenderMode as ct, DataValidationType as K, IConfigService as pn, debounce as zo, UndoCommand as Ko, RedoCommand as Go, isUnitRangesEqual as Zo, shallowEqual as En, Injector as Bt, DataValidationStatus as se, ObjectMatrix as Se, Range as qo, Rectangle as Ce, queryObjectMatrix as Je, Optional as Jo, RxDisposable as mn, InterceptorEffectEnum as zn, sequenceExecute as Kn, bufferDebounceTime as Qo, isFormulaString as At, Tools as Qe, ThemeService as ta, VerticalAlign as ht, HorizontalAlign as Yt, DEFAULT_STYLES as dt, WrapStrategy as Ct, DocumentDataModel as ea, BooleanNumber as ee, DEFAULT_EMPTY_DOCUMENT_VALUE as na, Plugin as Gn, merge as Zn } from "@univerjs/core";
6
6
  import { Button as Ut, DatePanel as oa, Scrollbar as aa, FormLayout as q, RadioGroup as gn, Radio as Ft, Checkbox as Le, Input as Nt, Select as tn, DraggableList as ia } from "@univerjs/design";
7
7
  import { DeviceInputEventType as en, IRenderManagerService as Vt, fixLineWidthByScale as bn, Transform as ra, CheckboxShape as sa, CURSOR_TYPE as Xt, FontCache as la, Shape as da, Rect as qn, getFontStyleString as Ne, getDocsSkeletonPageSize as ne, Documents as ca, DocumentViewModel as ua, DocumentSkeleton as ha } from "@univerjs/engine-render";
8
- import { SheetInterceptorService as fn, AFTER_CELL_EDIT_ASYNC as pa, SetRangeValuesCommand as vn, SheetsSelectionsService as Jn, getSheetCommandTarget as Qn, SheetPermissionCheckController as to, WorksheetEditPermission as Ie, RangeProtectionPermissionEditPoint as we, WorkbookEditablePermission as Re, checkRangesEditablePermission as ma, WorksheetSetCellStylePermission as nn, INTERCEPTOR_POINT as eo, InterceptCellContentPriority as no } from "@univerjs/sheets";
9
- import { SheetDataValidationModel as at, getCellValueOrigin as rt, getDataValidationCellValue as ga, deserializeListOptions as oo, serializeListOptions as ao, UpdateSheetDataValidationRangeCommand as io, UpdateSheetDataValidationSettingCommand as On, UpdateSheetDataValidationOptionsCommand as fa, RemoveSheetDataValidationCommand as ro, RemoveSheetAllDataValidationCommand as va, createDefaultNewRule as so, AddSheetDataValidationCommand as _n, DATA_VALIDATION_PLUGIN_NAME as lo, getDataValidationDiffMutations as on, DataValidationCacheService as co, DataValidationFormulaController as _a, DataValidationFormulaService as Sa, CHECKBOX_FORMULA_2 as Ca, CHECKBOX_FORMULA_1 as Ia, getFormulaResult as Ue, isLegalFormulaResult as Ln, transformCheckboxValue as wa } from "@univerjs/sheets-data-validation";
10
- import { getPatternType as Ra } from "@univerjs/sheets-numfmt";
11
- import { SetCellEditVisibleOperation as an, SheetCanvasPopManagerService as Da, IEditorBridgeService as uo, IMarkSelectionService as Va, HoverManagerService as ya, CellAlertManagerService as Ma, CellAlertType as Ea, IAutoFillService as ba, APPLY_TYPE as oe, virtualizeDiscreteRanges as rn, getAutoFillRepeatRange as Oa, ISheetClipboardService as La, COPY_TYPE as Tn, rangeToDiscreteRange as Ta, PREDEFINED_HOOK_NAME as ce, getRepeatRange as Pn, getCurrentRangeDisable$ as Pa, AutoHeightController as ho, SheetSkeletonManagerService as De } from "@univerjs/sheets-ui";
8
+ import { SheetInterceptorService as fn, AFTER_CELL_EDIT_ASYNC as pa, SetRangeValuesCommand as vn, SheetsSelectionsService as Jn, getSheetCommandTarget as Qn, SheetPermissionCheckController as to, WorksheetEditPermission as Ie, RangeProtectionPermissionEditPoint as we, WorkbookEditablePermission as Re, checkRangesEditablePermission as ma, rangeToDiscreteRange as ga, WorksheetSetCellStylePermission as nn, INTERCEPTOR_POINT as eo, InterceptCellContentPriority as no } from "@univerjs/sheets";
9
+ import { SheetDataValidationModel as at, getCellValueOrigin as rt, getDataValidationCellValue as fa, deserializeListOptions as oo, serializeListOptions as ao, UpdateSheetDataValidationRangeCommand as io, UpdateSheetDataValidationSettingCommand as On, UpdateSheetDataValidationOptionsCommand as va, RemoveSheetDataValidationCommand as ro, RemoveSheetAllDataValidationCommand as _a, createDefaultNewRule as so, AddSheetDataValidationCommand as _n, DATA_VALIDATION_PLUGIN_NAME as lo, getDataValidationDiffMutations as on, DataValidationCacheService as co, DataValidationFormulaController as Sa, DataValidationFormulaService as Ca, CHECKBOX_FORMULA_2 as Ia, CHECKBOX_FORMULA_1 as wa, getFormulaResult as Ue, isLegalFormulaResult as Ln, transformCheckboxValue as Ra } from "@univerjs/sheets-data-validation";
10
+ import { getPatternType as Da } from "@univerjs/sheets-numfmt";
11
+ import { SetCellEditVisibleOperation as an, SheetCanvasPopManagerService as Va, IEditorBridgeService as uo, IMarkSelectionService as ya, HoverManagerService as Ma, CellAlertManagerService as Ea, CellAlertType as ba, IAutoFillService as Oa, APPLY_TYPE as oe, virtualizeDiscreteRanges as rn, getAutoFillRepeatRange as La, ISheetClipboardService as Ta, COPY_TYPE as Tn, PREDEFINED_HOOK_NAME as ce, getRepeatRange as Pn, getCurrentRangeDisable$ as Pa, AutoHeightController as ho, SheetSkeletonManagerService as De } from "@univerjs/sheets-ui";
12
12
  import { IDialogService as Aa, useDependency as L, KeyCode as sn, ISidebarService as po, useObservable as $t, ComponentManager as Te, IZenZoneService as mo, RectPopup as ka, useEvent as ln, useSidebarClick as Sn, MenuItemType as Cn, getMenuHiddenObservable as Fa, RibbonStartGroup as Na, IMenuManagerService as Ua } from "@univerjs/ui";
13
13
  import An, { useState as x, forwardRef as yt, useRef as zt, createElement as Mt, useMemo as Kt, useEffect as It } from "react";
14
14
  import { DataValidatorRegistryService as Et, DataValidationModel as Pe, DataValidatorRegistryScope as Ba, TWO_FORMULA_OPERATOR_COUNT as $a, getRuleOptions as kn, getRuleSetting as Fn } from "@univerjs/data-validation";
@@ -135,7 +135,7 @@ function qa(t) {
135
135
  var k, F, U;
136
136
  if (!R)
137
137
  return;
138
- const T = R.format(_ ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD 00:00:00"), N = (k = qe.parseDate(T)) == null ? void 0 : k.v, P = l.getStyles().getStyleByCell(h), b = (U = (F = P == null ? void 0 : P.n) == null ? void 0 : F.pattern) != null ? U : "", A = Ra(b);
138
+ const T = R.format(_ ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD 00:00:00"), N = (k = qe.parseDate(T)) == null ? void 0 : k.v, P = l.getStyles().getStyleByCell(h), b = (U = (F = P == null ? void 0 : P.n) == null ? void 0 : F.pattern) != null ? U : "", A = Da(b);
139
139
  I.errorStyle !== re.STOP || await V.validator({
140
140
  value: N,
141
141
  unitId: r,
@@ -471,7 +471,7 @@ let Rt = class extends Dt {
471
471
  }
472
472
  };
473
473
  Rt = pi([
474
- Ot(0, E(Da)),
474
+ Ot(0, E(Va)),
475
475
  Ot(1, vt),
476
476
  Ot(2, E(Et)),
477
477
  Ot(3, mo),
@@ -612,7 +612,7 @@ function Di(t) {
612
612
  const g = n.getCell(a, i), y = (_ == null ? void 0 : _.renderMode) === ct.CUSTOM || (_ == null ? void 0 : _.renderMode) === void 0;
613
613
  if (!g || !_ || !S || S.id.indexOf(K.LIST) !== 0)
614
614
  return;
615
- const T = _.type === K.LIST_MULTIPLE, N = S.getListWithColor(_, r, s), P = v || ga(n.getCellRaw(a, i)), b = oo(P), A = () => {
615
+ const T = _.type === K.LIST_MULTIPLE, N = S.getListWithColor(_, r, s), P = v || fa(n.getCellRaw(a, i)), b = oo(P), A = () => {
616
616
  h.executeCommand(Wt.id, {
617
617
  ruleId: _.uid
618
618
  }), o();
@@ -832,7 +832,7 @@ function Ai() {
832
832
  ...p,
833
833
  ...O
834
834
  }), S(
835
- fa.id,
835
+ va.id,
836
836
  {
837
837
  unitId: a,
838
838
  subUnitId: i,
@@ -944,7 +944,7 @@ const ki = "univer-data-validation-item-container", Fi = "univer-data-validation
944
944
  dataValidationItemContent: Ni,
945
945
  dataValidationItemIcon: Ui
946
946
  }, Bi = (t) => {
947
- const { rule: e, onClick: o, unitId: n, subUnitId: a, disable: i } = t, r = L(Et), s = L(tt), l = L(Va), c = r.getValidatorItem(e.type), u = zt(void 0), [h, d] = x(!1), v = (p) => {
947
+ const { rule: e, onClick: o, unitId: n, subUnitId: a, disable: i } = t, r = L(Et), s = L(tt), l = L(ya), c = r.getValidatorItem(e.type), u = zt(void 0), [h, d] = x(!1), v = (p) => {
948
948
  s.executeCommand(ro.id, {
949
949
  ruleId: e.uid,
950
950
  unitId: n,
@@ -1024,7 +1024,7 @@ function ji(t) {
1024
1024
  rule: w
1025
1025
  });
1026
1026
  }, p = () => {
1027
- n.executeCommand(va.id, {
1027
+ n.executeCommand(_a.id, {
1028
1028
  unitId: h,
1029
1029
  subUnitId: d
1030
1030
  });
@@ -1115,7 +1115,7 @@ let de = class extends Dt {
1115
1115
  return;
1116
1116
  }
1117
1117
  this._cellAlertManagerService.showAlert({
1118
- type: Ea.ERROR,
1118
+ type: ba.ERROR,
1119
1119
  title: this._localeService.t("dataValidation.error.title"),
1120
1120
  message: l == null ? void 0 : l.getRuleFinalError(a, t.location),
1121
1121
  location: t.location,
@@ -1136,8 +1136,8 @@ let de = class extends Dt {
1136
1136
  }
1137
1137
  };
1138
1138
  de = zi([
1139
- xt(0, E(ya)),
1140
- xt(1, E(Ma)),
1139
+ xt(0, E(Ma)),
1140
+ xt(1, E(Ea)),
1141
1141
  xt(2, vt),
1142
1142
  xt(3, E(Q)),
1143
1143
  xt(4, mo),
@@ -1158,7 +1158,7 @@ let Gt = class extends Dt {
1158
1158
  const { source: i, target: r, unitId: s, subUnitId: l } = n, c = this._sheetDataValidationModel.getRuleObjectMatrix(s, l).clone(), u = rn([i, r]), [h, d] = u.ranges, { mapFunc: v } = u, p = {
1159
1159
  row: h.startRow,
1160
1160
  col: h.startColumn
1161
- }, C = Oa(h, d), R = new Se(), f = /* @__PURE__ */ new Set();
1161
+ }, C = La(h, d), R = new Se(), f = /* @__PURE__ */ new Set();
1162
1162
  C.forEach((S) => {
1163
1163
  const g = S.repeatStartCell, y = S.relativeRange, T = {
1164
1164
  startRow: p.row,
@@ -1220,7 +1220,7 @@ let Gt = class extends Dt {
1220
1220
  }
1221
1221
  };
1222
1222
  Gt = Gi([
1223
- $e(0, ba),
1223
+ $e(0, Oa),
1224
1224
  $e(1, E(at)),
1225
1225
  $e(2, E(Bt))
1226
1226
  ], Gt);
@@ -1252,7 +1252,7 @@ let Zt = class extends Dt {
1252
1252
  subUnitId: o,
1253
1253
  matrix: a
1254
1254
  };
1255
- const i = this._injector.invoke((l) => Ta(n, l, e, o));
1255
+ const i = this._injector.invoke((l) => ga(n, l, e, o));
1256
1256
  if (!i)
1257
1257
  return;
1258
1258
  const { rows: r, cols: s } = i;
@@ -1347,7 +1347,7 @@ let Zt = class extends Dt {
1347
1347
  }
1348
1348
  };
1349
1349
  Zt = qi([
1350
- We(0, La),
1350
+ We(0, Ta),
1351
1351
  We(1, E(at)),
1352
1352
  We(2, E(Bt))
1353
1353
  ], Zt);
@@ -1967,7 +1967,7 @@ const Cr = [
1967
1967
  };
1968
1968
  function wr(t) {
1969
1969
  const { value: e, onChange: o = () => {
1970
- }, unitId: n, subUnitId: a, validResult: i, showError: r, ruleId: s } = t, { formula1: l = "", formula2: c = "" } = e || {}, u = zt(null), [h, d] = x(() => At(l) ? "1" : "0"), [v, p] = x(h === "1" ? l : "="), [C, R] = x(h === "1" ? l : "="), f = L(Q), w = L(Et), I = L(Pe), V = L(_a), [_, S] = x(() => c.split(",")), g = w.getValidatorItem(K.LIST), [y, T] = x([]), [N, P] = x(""), b = r ? i == null ? void 0 : i.formula1 : "", A = Kt(() => I.ruleChange$.pipe(wn(16)), []), k = $t(A), F = ln(o);
1970
+ }, unitId: n, subUnitId: a, validResult: i, showError: r, ruleId: s } = t, { formula1: l = "", formula2: c = "" } = e || {}, u = zt(null), [h, d] = x(() => At(l) ? "1" : "0"), [v, p] = x(h === "1" ? l : "="), [C, R] = x(h === "1" ? l : "="), f = L(Q), w = L(Et), I = L(Pe), V = L(Sa), [_, S] = x(() => c.split(",")), g = w.getValidatorItem(K.LIST), [y, T] = x([]), [N, P] = x(""), b = r ? i == null ? void 0 : i.formula1 : "", A = Kt(() => I.ruleChange$.pipe(wn(16)), []), k = $t(A), F = ln(o);
1971
1971
  It(() => {
1972
1972
  (async () => {
1973
1973
  await new Promise(($) => {
@@ -2228,7 +2228,7 @@ let dn = class {
2228
2228
  }
2229
2229
  async _parseFormula(t, e, o) {
2230
2230
  var c, u, h, d, v, p, C, R, f;
2231
- const { formula1: n = Ia, formula2: a = Ca } = t, i = await this._formulaService.getRuleFormulaResult(e, o, t.uid), r = Ue((h = (u = (c = i == null ? void 0 : i[0]) == null ? void 0 : c.result) == null ? void 0 : u[0]) == null ? void 0 : h[0]), s = Ue((p = (v = (d = i == null ? void 0 : i[1]) == null ? void 0 : d.result) == null ? void 0 : v[0]) == null ? void 0 : p[0]), l = Ln(String(r)) && Ln(String(s));
2231
+ const { formula1: n = wa, formula2: a = Ia } = t, i = await this._formulaService.getRuleFormulaResult(e, o, t.uid), r = Ue((h = (u = (c = i == null ? void 0 : i[0]) == null ? void 0 : c.result) == null ? void 0 : u[0]) == null ? void 0 : h[0]), s = Ue((p = (v = (d = i == null ? void 0 : i[1]) == null ? void 0 : d.result) == null ? void 0 : v[0]) == null ? void 0 : p[0]), l = Ln(String(r)) && Ln(String(s));
2232
2232
  return {
2233
2233
  formula1: At(n) ? Ue((f = (R = (C = i == null ? void 0 : i[0]) == null ? void 0 : C.result) == null ? void 0 : R[0]) == null ? void 0 : f[0]) : n,
2234
2234
  formula2: At(a) ? s : a,
@@ -2290,7 +2290,7 @@ let dn = class {
2290
2290
  endRow: o.actualRow
2291
2291
  },
2292
2292
  value: {
2293
- v: String(l) === wa(String(h)) ? d : h,
2293
+ v: String(l) === Ra(String(h)) ? d : h,
2294
2294
  p: null
2295
2295
  }
2296
2296
  };
@@ -2310,7 +2310,7 @@ let dn = class {
2310
2310
  };
2311
2311
  dn = Mr([
2312
2312
  ie(0, tt),
2313
- ie(1, E(Sa)),
2313
+ ie(1, E(Ca)),
2314
2314
  ie(2, E(ta)),
2315
2315
  ie(3, E(Vt)),
2316
2316
  ie(4, E(at))
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(x,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react/jsx-runtime"),require("@univerjs/core"),require("@univerjs/design"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("react"),require("@univerjs/data-validation"),require("@univerjs/docs"),require("rxjs"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@univerjs/core","@univerjs/design","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-data-validation","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/ui","react","@univerjs/data-validation","@univerjs/docs","rxjs","@univerjs/engine-formula","@univerjs/sheets-formula-ui"],u):(x=typeof globalThis<"u"?globalThis:x||self,u(x.UniverSheetsDataValidationUi={},x.React,x.UniverCore,x.UniverDesign,x.UniverEngineRender,x.UniverSheets,x.UniverSheetsDataValidation,x.UniverSheetsNumfmt,x.UniverSheetsUi,x.UniverUi,x.React,x.UniverDataValidation,x.UniverDocs,x.rxjs,x.UniverEngineFormula,x.UniverSheetsFormulaUi))})(this,function(x,u,r,T,W,z,E,Gt,B,f,M,J,qt,re,et,tt){"use strict";var Ra=Object.defineProperty;var Aa=(x,u,r)=>u in x?Ra(x,u,{enumerable:!0,configurable:!0,writable:!0,value:r}):x[u]=r;var P=(x,u,r)=>Aa(x,typeof u!="symbol"?u+"":u,r);var Je,Qe;var Zt=Object.getOwnPropertyDescriptor,Jt=(e,t,a,n)=>{for(var o=n>1?void 0:n?Zt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Pe=(e,t)=>(a,n)=>t(a,n,e);let Re=class extends r.Disposable{constructor(e,t,a,n,o){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=o,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(z.AFTER_CELL_EDIT_ASYNC,{handler:async(e,t,a)=>{var D;const n=await e,{worksheet:o,row:i,col:s,unitId:l,subUnitId:d,workbook:h}=t,p=this._dataValidationModel.getRuleIdByLocation(l,d,i,s),v=p?this._dataValidationModel.getRuleById(l,d,p):void 0;if(!v||v.errorStyle!==r.DataValidationErrorStyle.STOP)return a(Promise.resolve(n));const c=await this._dataValidatorRegistryService.getValidatorItem(v.type);if(!c||await c.validator({value:E.getCellValueOrigin(n),interceptValue:E.getCellValueOrigin((D=t==null?void 0:t.origin)!=null?D:n),row:i,column:s,unitId:l,subUnitId:d,worksheet:o,workbook:h,t:n==null?void 0:n.t},v))return a(Promise.resolve(n));const g=o.getCellRaw(i,s);return this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:c.getRuleFinalError(v,{row:i,col:s,unitId:l,subUnitId:d})},footer:{title:M.createElement(T.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(Promise.resolve(g))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:M.createElement(T.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Re=Jt([Pe(0,r.Inject(z.SheetInterceptorService)),Pe(1,r.Inject(E.SheetDataValidationModel)),Pe(2,r.Inject(J.DataValidatorRegistryService)),Pe(3,f.IDialogService),Pe(4,r.Inject(r.LocaleService))],Re);const Dt={dvDateDropdown:"univer-dv-date-dropdown",dvDateDropdownBtns:"univer-dv-date-dropdown-btns"},Qt=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return r.dayjs(r.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=r.dayjs(e);if(t.isValid())return t};function en(e){var m;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:i,unitId:s,subUnitId:l,workbook:d}=t,h=f.useDependency(r.ICommandService),p=f.useDependency(Re),v=n.getCell(o,i),c=E.getCellValueOrigin(n.getCellRaw(o,i)),_=Qt(c),[g,D]=M.useState(_),V=g&&g.isValid()?g:r.dayjs(),S=f.useDependency(r.LocaleService),w=f.useDependency(E.SheetDataValidationModel),y=w.getRuleByLocation(s,l,o,i);if(!y)return null;const L=w.getValidator(y.type);if(!v||!L)return;const I=!!((m=y.bizInfo)!=null&&m.showTime),C=async()=>{var U,j,H;if(!V)return;const F=V.format(I?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),$=(U=r.numfmt.parseDate(F))==null?void 0:U.v,k=d.getStyles().getStyleByCell(v),R=(H=(j=k==null?void 0:k.n)==null?void 0:j.pattern)!=null?H:"",N=Gt.getPatternType(R);y.errorStyle!==r.DataValidationErrorStyle.STOP||await L.validator({value:$,unitId:s,subUnitId:l,row:o,column:i,worksheet:n,workbook:d,interceptValue:F.replace("Z","").replace("T"," "),t:r.CellValueType.NUMBER},y)?(a(),await h.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:W.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),await h.executeCommand(z.SetRangeValuesCommand.id,{unitId:s,subUnitId:l,range:{startColumn:i,endColumn:i,startRow:o,endRow:o},value:{v:$,t:2,p:null,f:null,si:null,s:{n:{pattern:I?N==="datetime"?R:"yyyy-MM-dd hh:mm:ss":N==="date"?R:"yyyy-MM-dd"}}}})):p.showReject(L.getRuleFinalError(y,{row:o,col:i,unitId:s,subUnitId:l}))};return u.jsxs("div",{className:Dt.dvDateDropdown,children:[u.jsx(T.DatePanel,{defaultValue:V,pickerValue:V,showTime:I||void 0,onSelect:async O=>{D(O)},onPanelChange:O=>{D(O)},disabledDate:O=>!r.numfmt.parseDate(O.format("YYYY-MM-DD"))}),u.jsx("div",{className:Dt.dvDateDropdownBtns,children:u.jsx(T.Button,{size:"small",type:"primary",onClick:C,disabled:!V.isValid(),children:S.t("dataValidation.alert.ok")})})]})}var se=function(){return se=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},se.apply(this,arguments)},tn=function(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(a[n[o]]=e[n[o]]);return a},ge=M.forwardRef(function(e,t){var a=e.icon,n=e.id,o=e.className,i=e.extend,s=tn(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),d=M.useRef("_".concat(on()));return yt(a,"".concat(n),{defIds:a.defIds,idSuffix:d.current},se({ref:t,className:l},s),i)});function yt(e,t,a,n,o){return M.createElement(e.tag,se(se({key:t},nn(e,a,o)),n),(an(e,a).children||[]).map(function(i,s){return yt(i,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,o)}))}function nn(e,t,a){var n=se({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],l=i[1];s==="mask"&&typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var o=t.defIds;return!o||o.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],l=i[1];typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function an(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?se(se({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?se(se({},o),{attrs:se(se({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):e}function on(){return Math.random().toString(36).substring(2,8)}ge.displayName="UniverIcon";var rn={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=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"check-mark-single",ref:t,icon:rn}))});wt.displayName="CheckMarkSingle";var sn={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=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"data-validation-single",ref:t,icon:sn}))});Vt.displayName="DataValidationSingle";var ln={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=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"delete-single",ref:t,icon:ln}))});nt.displayName="DeleteSingle";var dn={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=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"increase-single",ref:t,icon:dn}))});Et.displayName="IncreaseSingle";var cn={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=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"more-down-single",ref:t,icon:cn}))});Mt.displayName="MoreDownSingle";var un={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=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"more-up-single",ref:t,icon:un}))});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=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"sequence-single",ref:t,icon:hn}))});Lt.displayName="SequenceSingle";var pn=Object.getOwnPropertyDescriptor,vn=(e,t,a,n)=>{for(var o=n>1?void 0:n?pn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Tt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends r.Disposable{constructor(t,a){super();P(this,"_open$",new re.BehaviorSubject(!1));P(this,"open$",this._open$.pipe(re.distinctUntilChanged()));P(this,"_activeRule");P(this,"_activeRule$",new re.BehaviorSubject(void 0));P(this,"activeRule$",this._activeRule$.asObservable());P(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).pipe(re.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===ke&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=r.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ue=vn([Tt(0,r.IUniverInstanceService),Tt(1,f.ISidebarService)],ue);function gn(){const e=f.useDependency(me),t=f.useObservable(e.activeDropdown$,e.activeDropdown),a=f.useDependency(f.ComponentManager);if(!t)return null;const{location:n,componentKey:o}=t,i=a.get(o),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!i)return null;const l=()=>{e.hideDropdown()};return u.jsx(i,{location:n,hideFn:l},s)}const Ot="sheet.ui.dropdown";var mn=Object.getOwnPropertyDescriptor,fn=(e,t,a,n)=>{for(var o=n>1?void 0:n?mn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Se=(e,t)=>(a,n)=>t(a,n,e);let me=class extends r.Disposable{constructor(t,a,n,o,i,s,l){super();P(this,"_activeDropdown");P(this,"_activeDropdown$",new re.Subject);P(this,"_currentPopup",null);P(this,"activeDropdown$",this._activeDropdown$.asObservable());P(this,"_zenVisible",!1);this._canvasPopupManagerService=t,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=o,this._renderManagerService=i,this._dataValidationModel=s,this._sheetsSelectionsService=l,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,a,n,o){const i=t?this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=a?i.getSheetBySheetId(a):i.getActiveSheet();if(!s)return;const l=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,o);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);return d==null?void 0:d.dropdown}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t,a=!0){const{location:n}=t,{row:o,col:i,unitId:s,subUnitId:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const d=this._renderManagerService.getRenderById(r.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),h=this._canvasPopupManagerService.attachPopupToCell(o,i,{componentKey:Ot,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[d==null?void 0:d.engine.getCanvasElement()].filter(Boolean)},s,l);if(!h)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const p=new r.DisposableCollection;p.add(h),p.add({dispose:()=>{var v,c;(c=(v=this._activeDropdown)==null?void 0:v.onHide)==null||c.call(v)}}),this._currentPopup=p}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,a,n,o,i){const s=this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET);if(!s)return;const l=s.getSheetBySheetId(a);if(!l)return;const d=this._dataValidationModel.getRuleByLocation(s.getUnitId(),l.getSheetId(),n,o);if(!d)return;const h=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!h||!h.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:l,row:n,col:o,unitId:t,subUnitId:a},componentKey:h.dropdown,onHide:i})}};me=fn([Se(0,r.Inject(B.SheetCanvasPopManagerService)),Se(1,r.IUniverInstanceService),Se(2,r.Inject(J.DataValidatorRegistryService)),Se(3,f.IZenZoneService),Se(4,W.IRenderManagerService),Se(5,r.Inject(E.SheetDataValidationModel)),Se(6,r.Inject(z.SheetsSelectionsService))],me);const ke="DataValidationPanel",_e={id:"data-validation.operation.open-validation-panel",type:r.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,o=e.get(ue),i=e.get(J.DataValidationModel),s=e.get(r.IUniverInstanceService),l=e.get(f.ISidebarService),d=z.getSheetCommandTarget(s);if(!d)return!1;const{unitId:h,subUnitId:p}=d,v=a?i.getRuleById(h,p,a):void 0;o.open(),o.setActiveRule(v&&{unitId:h,subUnitId:p,rule:v});const c=l.open({id:ke,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:ke},width:312,onClose:()=>o.close()});return o.setCloseDisposable(c),!0}},at={id:"data-validation.operation.close-validation-panel",type:r.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},Pt={id:"data-validation.operation.toggle-validation-panel",type:r.CommandType.OPERATION,handler(e){const t=e.get(r.ICommandService),a=e.get(ue);return a.open(),a.isOpen?t.executeCommand(at.id):t.executeCommand(_e.id),!0}},Ne={type:r.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(me),{unitId:n,subUnitId:o,row:i,column:s}=t,l=a.activeDropdown,d=l==null?void 0:l.location;return d&&d.unitId===n&&d.subUnitId===o&&d.row===i&&d.col===s||a.showDataValidationDropdown(n,o,i,s),!0}},Rt={type:r.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(me).hideDropdown(),!0):!1}},Ie="#ECECEC",ot="sheets-data-validation-ui.config",Ue={},ve={dvListDropdown:"univer-dv-list-dropdown",dvListDropdownTitle:"univer-dv-list-dropdown-title",dvListDropdownList:"univer-dv-list-dropdown-list",dvListDropdownListContainer:"univer-dv-list-dropdown-list-container",dvListDropdownSelectedIcon:"univer-dv-list-dropdown-selected-icon",dvListDropdownItemContainer:"univer-dv-list-dropdown-item-container",dvListDropdownItem:"univer-dv-list-dropdown-item",dvListDropdownSplit:"univer-dv-list-dropdown-split",dvListDropdownEdit:"univer-dv-list-dropdown-edit"},Sn=e=>{var I,C;const{value:t,onChange:a,multiple:n,options:o,title:i,onEdit:s,style:l,filter:d,location:h}=e,p=f.useDependency(r.LocaleService),v=f.useDependency(r.IConfigService),c=d==null?void 0:d.toLowerCase(),{row:_,col:g,unitId:D,subUnitId:V}=h,S=o.filter(m=>c?m.label.toLowerCase().includes(c):!0),w=(C=(I=v.getConfig(ot))==null?void 0:I.showEditOnDropdown)!=null?C:!0,y=f.useDependency(z.SheetPermissionCheckController),L=M.useMemo(()=>y.permissionCheckWithRanges({workbookTypes:[z.WorkbookEditablePermission],rangeTypes:[z.RangeProtectionPermissionEditPoint],worksheetTypes:[z.WorksheetEditPermission]},[{startColumn:g,startRow:_,endColumn:g,endRow:_}],D,V),[y,g,_,D,V]);return u.jsxs("div",{className:ve.dvListDropdown,style:l,children:[u.jsx("div",{className:ve.dvListDropdownTitle,children:i}),u.jsx("div",{className:ve.dvListDropdownList,children:u.jsx(T.Scrollbar,{children:u.jsx("div",{className:ve.dvListDropdownListContainer,children:S.map((m,O)=>{const F=t.indexOf(m.value)>-1,$=()=>{let R;F?R=new Set(t.filter(U=>U!==m.value)):R=new Set(n?[...t,m.value]:[m.value]);const N=[];o.forEach(U=>{R.has(U.value)&&N.push(U.value)}),a(N)},k=m.label.toLocaleLowerCase().indexOf(c);return u.jsxs("div",{className:ve.dvListDropdownItemContainer,onClick:$,children:[u.jsx("div",{className:ve.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,k)}),u.jsx("span",{style:{fontWeight:"bold"},children:m.label.substring(k,k+c.length)}),u.jsx("span",{children:m.label.substring(k+c.length)})]}):m.label}),u.jsx("div",{className:ve.dvListDropdownSelectedIcon,children:F?u.jsx(wt,{}):null})]},O)})})},d)}),w&&L?u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ve.dvListDropdownSplit}),u.jsx("div",{className:ve.dvListDropdownEdit,children:u.jsx("a",{onClick:s,children:p.t("dataValidation.list.edit")})})]}):null]})};function _n(e){var j,H,q,Z;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:i,unitId:s,subUnitId:l}=t,d=f.useDependency(J.DataValidationModel),[h,p]=M.useState(""),v=f.useDependency(r.ICommandService),c=f.useDependency(r.LocaleService),[_,g]=M.useState(""),D=f.useDependency(B.IEditorBridgeService),V=f.useDependency(r.IUniverInstanceService),S=M.useMemo(()=>d.ruleChange$.pipe(re.debounceTime(16)),[]),w=f.useDependency(E.SheetDataValidationModel);f.useObservable(S);const y=f.RectPopup.useContext(),L=((H=(j=y.current)==null?void 0:j.right)!=null?H:0)-((Z=(q=y.current)==null?void 0:q.left)!=null?Z:0);if(M.useEffect(()=>{const G=v.onCommandExecuted(ee=>{var te,ae;if(ee.id===qt.RichTextEditingMutation.id){const oe=ee.params,{unitId:le}=oe,ie=V.getUnit(le,r.UniverInstanceType.UNIVER_DOC);if(!ie||!D.isVisible().visible)return;const de=r.BuildTextUtils.transform.getPlainText((ae=(te=ie.getSnapshot().body)==null?void 0:te.dataStream)!=null?ae:"");p(de)}});return()=>{G.dispose()}},[v,D,V]),!n)return null;const I=w.getRuleByLocation(s,l,o,i);if(!I)return null;const C=w.getValidator(I.type);if(!C)return null;const m=n.getCell(o,i),O=(I==null?void 0:I.renderMode)===r.DataValidationRenderMode.CUSTOM||(I==null?void 0:I.renderMode)===void 0;if(!m||!I||!C||C.id.indexOf(r.DataValidationType.LIST)!==0)return;const F=I.type===r.DataValidationType.LIST_MULTIPLE,$=C.getListWithColor(I,s,l),k=_||E.getDataValidationCellValue(n.getCellRaw(o,i)),R=E.deserializeListOptions(k),N=()=>{v.executeCommand(_e.id,{ruleId:I.uid}),a()},U=$.map(G=>({label:G.label,value:G.label,color:O||G.color?G.color:"transparent"}));return u.jsx(Sn,{style:{minWidth:L,maxWidth:Math.max(L,200)},title:F?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:R,multiple:F,onChange:async G=>{const ee=E.serializeListOptions(G),te={unitId:s,subUnitId:l,range:{startColumn:i,endColumn:i,startRow:o,endRow:o},value:{v:ee,p:null,f:null,si:null}};D.isVisible()&&v.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:W.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),g(ee),F||a(),D.isVisible().visible&&await v.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:W.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),v.executeCommand(z.SetRangeValuesCommand.id,te)},options:U,onEdit:N,filter:h,location:t})}const it={dataValidationOptionsButton:"univer-data-validation-options-button",dataValidationOptionsButtonIcon:"univer-data-validation-options-button-icon"};function In(e){var h;const t=f.useDependency(r.LocaleService),a=f.useDependency(f.ComponentManager),{value:n,onChange:o,extraComponent:i}=e,[s,l]=M.useState(!1),d=i?a.get(i):null;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:it.dataValidationOptionsButton,onClick:()=>l(!s),children:[t.t("dataValidation.panel.options"),s?u.jsx(bt,{className:it.dataValidationOptionsButtonIcon}):u.jsx(Mt,{className:it.dataValidationOptionsButtonIcon})]}),s&&u.jsxs(u.Fragment,{children:[d?u.jsx(d,{value:n,onChange:o}):null,u.jsx(T.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:u.jsxs(T.RadioGroup,{value:`${(h=n.errorStyle)!=null?h:r.DataValidationErrorStyle.WARNING}`,onChange:p=>o({...n,errorStyle:+p}),children:[u.jsx(T.Radio,{value:`${r.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),u.jsx(T.Radio,{value:`${r.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),u.jsx(T.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:u.jsx(T.Checkbox,{checked:n.showErrorMessage,onChange:()=>o({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?u.jsx(T.FormLayout,{children:u.jsx(T.Input,{value:n.error,onChange:p=>o({...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"},Cn=e=>r.debounce(async(t,a,n,o)=>{const i=await e.executeCommand(t,a,n);o==null||o(i)},1e3);function Dn(e,t,a){var n,o,i,s;return t?((o=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:o.getSheetId())||"":((s=(i=e.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function yn(){var de;const[e,t]=M.useState(0),a=f.useDependency(ue),n=f.useObservable(a.activeRule$,a.activeRule),{unitId:o,subUnitId:i,rule:s}=n||{},l=s.uid,d=f.useDependency(J.DataValidatorRegistryService),h=f.useDependency(r.IUniverInstanceService),p=f.useDependency(f.ComponentManager),v=f.useDependency(r.ICommandService),c=f.useDependency(J.DataValidationModel),_=f.useDependency(r.LocaleService),[g,D]=M.useState(s),V=d.getValidatorItem(g.type),[S,w]=M.useState(!1),y=d.getValidatorsByScope(J.DataValidatorRegistryScope.SHEET),[L,I]=M.useState(()=>g.ranges.map(A=>({unitId:"",sheetId:"",range:A}))),C=M.useMemo(()=>Cn(v),[v]),[m,O]=M.useState(!1),F=M.useRef({}),[$,k]=M.useState(!1),R=f.useDependency(z.SheetsSelectionsService);if(M.useEffect(()=>()=>{const A=R.getCurrentLastSelection();A&&R.setSelections([A])},[R]),M.useEffect(()=>{v.onCommandExecuted(A=>{(A.id===r.UndoCommand.id||A.id===r.RedoCommand.id)&&setTimeout(()=>{const b=c.getRuleById(o,i,l);t(Y=>Y+1),b&&(D(b),I(b.ranges.map(Y=>({unitId:"",sheetId:"",range:Y}))))},20)})},[v,c,l,i,o]),!V)return null;const N=V.operators,U=V.operatorNames,j=g.operator?J.TWO_FORMULA_OPERATOR_COUNT.includes(g.operator):!1,H=()=>{!g.ranges.length||m||(V.validatorFormula(g,o,i).success?a.setActiveRule(null):w(!0))},q=f.useEvent(A=>{const b=A.split(",").filter(Boolean).map(et.deserializeRangeWithSheet).map(K=>{const fe=K.sheetName;if(fe){const Pa=Dn(h,K.unitId,fe);return{...K,sheetId:Pa}}return{...K,sheetId:""}});if(r.isUnitRangesEqual(b,L))return;I(b);const Y=b.filter(K=>(!K.unitId||K.unitId===o)&&(!K.sheetId||K.sheetId===i)).map(K=>K.range);if(D({...g,ranges:Y}),Y.length===0)return;const X={unitId:o,subUnitId:i,ruleId:l,ranges:Y};C(E.UpdateSheetDataValidationRangeCommand.id,X)}),Z=A=>{if(r.shallowEqual(A,J.getRuleSetting(g)))return;D({...g,...A});const b={unitId:o,subUnitId:i,ruleId:l,setting:A};C(E.UpdateSheetDataValidationSettingCommand.id,b,void 0)},G=async()=>{await v.executeCommand(E.RemoveSheetDataValidationCommand.id,{ruleId:l,unitId:o,subUnitId:i}),a.setActiveRule(null)},ee={type:g.type,operator:g.operator,formula1:g.formula1,formula2:g.formula2,allowBlank:g.allowBlank},te=A=>{const b=d.getValidatorItem(A);if(!b)return;const Y=b.operators,X=c.getRuleById(o,i,l),K=A===(X==null?void 0:X.type)||A.includes("list")&&(X!=null&&X.type.includes("list"))?{...X,type:A}:{...g,type:A,operator:Y[0],formula1:void 0,formula2:void 0};D(K),v.executeCommand(E.UpdateSheetDataValidationSettingCommand.id,{unitId:o,subUnitId:i,ruleId:g.uid,setting:J.getRuleSetting(K)})},ae=p.get(V.formulaInput),oe=M.useMemo(()=>L.map(A=>et.serializeRange(A.range)).join(","),[]),le=J.getRuleOptions(g),ie=A=>{r.shallowEqual(A,J.getRuleOptions(g))||(D({...g,...A}),C(E.UpdateSheetDataValidationOptionsCommand.id,{unitId:o,subUnitId:i,ruleId:l,options:A}))};return f.useSidebarClick(A=>{var Y;const b=(Y=F.current)==null?void 0:Y.handleOutClick;b&&b(A,()=>k(!1))}),u.jsxs("div",{className:we.dataValidationDetail,children:[u.jsx(T.FormLayout,{label:_.t("dataValidation.panel.range"),error:!g.ranges.length||m?_.t("dataValidation.panel.rangeError"):"",children:u.jsx(tt.RangeSelector,{unitId:o,subUnitId:i,initValue:oe,onChange:q,onFocus:()=>k(!0),isFocus:$,actions:F.current,onVerify:A=>O(!A)})}),u.jsx(T.FormLayout,{label:_.t("dataValidation.panel.type"),children:u.jsx(T.Select,{options:y==null?void 0:y.map(A=>({label:_.t(A.title),value:A.id})),value:g.type,onChange:te,className:we.dataValidationDetailFormItem})}),N!=null&&N.length?u.jsx(T.FormLayout,{label:_.t("dataValidation.panel.operator"),children:u.jsx(T.Select,{options:N.map((A,b)=>({value:`${A}`,label:U[b]})),value:`${g.operator}`,onChange:A=>{Z({...ee,operator:A})},className:we.dataValidationDetailFormItem})}):null,ae?u.jsx(ae,{isTwoFormula:j,value:{formula1:g.formula1,formula2:g.formula2},onChange:A=>{Z({...ee,...A})},showError:S,validResult:V.validatorFormula(g,o,i),unitId:o,subUnitId:i,ruleId:l},e+g.type):null,u.jsx(T.FormLayout,{children:u.jsx(T.Checkbox,{checked:(de=g.allowBlank)!=null?de:!0,onChange:()=>{var A;return Z({...ee,allowBlank:!((A=g.allowBlank)==null||A)})},children:_.t("dataValidation.panel.allowBlank")})}),u.jsx(In,{value:le,onChange:ie,extraComponent:V.optionsInput}),u.jsxs("div",{className:we.dataValidationDetailButtons,children:[u.jsx(T.Button,{className:we.dataValidationDetailButton,onClick:G,children:_.t("dataValidation.panel.removeRule")}),u.jsx(T.Button,{className:we.dataValidationDetailButton,type:"primary",onClick:H,children:_.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"},wn=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:o,disable:i}=e,s=f.useDependency(J.DataValidatorRegistryService),l=f.useDependency(r.ICommandService),d=f.useDependency(B.IMarkSelectionService),h=s.getValidatorItem(t.type),p=M.useRef(void 0),[v,c]=M.useState(!1),_=g=>{l.executeCommand(E.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:o}),g.stopPropagation()};return M.useEffect(()=>()=>{var g;p.current&&((g=p.current)==null||g.forEach(D=>{D&&d.removeShape(D)}))},[d]),u.jsxs("div",{className:Be.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{i||(c(!0),p.current=t.ranges.map(g=>d.addShape({range:g,style:{fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:null})))},onMouseLeave:()=>{var g;c(!1),(g=p.current)==null||g.forEach(D=>{D&&d.removeShape(D)}),p.current=void 0},children:[u.jsx("div",{className:Be.dataValidationItemTitle,children:h==null?void 0:h.generateRuleName(t)}),u.jsx("div",{className:Be.dataValidationItemContent,children:t.ranges.map(g=>et.serializeRange(g)).join(",")}),v?u.jsx("div",{className:Be.dataValidationItemIcon,onClick:_,children:u.jsx(nt,{})}):null]})},je={dataValidationList:"univer-data-validation-list",dataValidationListButtons:"univer-data-validation-list-buttons",dataValidationListButton:"univer-data-validation-list-button"};function Vn(){const e=f.useDependency(r.IUniverInstanceService),t=f.useObservable(()=>e.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return t?u.jsx(En,{workbook:t}):null}function En(e){const t=f.useDependency(E.SheetDataValidationModel),a=f.useDependency(r.IUniverInstanceService),n=f.useDependency(r.ICommandService),o=f.useDependency(r.Injector),i=f.useDependency(ue),s=f.useDependency(r.LocaleService),[l,d]=M.useState([]),{workbook:h}=e,p=f.useObservable(h.activeSheet$,void 0,!0),v=h.getUnitId(),c=p==null?void 0:p.getSheetId();M.useEffect(()=>{d(t.getRules(v,c));const w=t.ruleChange$.subscribe(y=>{y.unitId===v&&y.subUnitId===c&&d(t.getRules(v,c))});return()=>{w.unsubscribe()}},[v,c,t]);const _=async()=>{const w=E.createDefaultNewRule(o),y={unitId:v,subUnitId:c,rule:w};await n.executeCommand(E.AddSheetDataValidationCommand.id,y),i.setActiveRule({unitId:v,subUnitId:c,rule:w})},g=()=>{n.executeCommand(E.RemoveSheetAllDataValidationCommand.id,{unitId:v,subUnitId:c})},V=(w=>{const y=a.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET),L=y.getActiveSheet(),I=y.getUnitId(),C=L.getSheetId();return w.map(O=>z.checkRangesEditablePermission(o,I,C,O.ranges)?{...O}:{...O,disable:!0})})(l),S=V==null?void 0:V.some(w=>w.disable);return u.jsxs("div",{className:je.dataValidationList,children:[V==null?void 0:V.map(w=>{var y;return u.jsx(wn,{unitId:v,subUnitId:c,onClick:()=>{w.disable||i.setActiveRule({unitId:v,subUnitId:c,rule:w})},rule:w,disable:(y=w.disable)!=null?y:!1},w.uid)}),u.jsxs("div",{className:je.dataValidationListButtons,children:[l.length&&!S?u.jsx(T.Button,{className:je.dataValidationListButton,onClick:g,children:s.t("dataValidation.panel.removeAll")}):null,u.jsx(T.Button,{className:je.dataValidationListButton,type:"primary",onClick:_,children:s.t("dataValidation.panel.add")})]})]})}const Mn=()=>{const e=f.useDependency(ue),t=f.useObservable(e.activeRule$,e.activeRule);return t?u.jsx(yn,{},t.rule.uid):u.jsx(Vn,{})},We="data-validation.list.dropdown",rt="data-validation.date.dropdown",$e={type:r.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(r.IUniverInstanceService),a=z.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:o}=a,i=E.createDefaultNewRule(e),s=e.get(r.ICommandService),l=n.getUnitId(),d=o.getSheetId(),h={rule:i,unitId:l,subUnitId:d};return s.syncExecuteCommand(E.AddSheetDataValidationCommand.id,h)?(s.syncExecuteCommand(_e.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var bn=Object.getOwnPropertyDescriptor,Ln=(e,t,a,n)=>{for(var o=n>1?void 0:n?bn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Ve=(e,t)=>(a,n)=>t(a,n,e);const Ce="SHEET_DATA_VALIDATION_ALERT";let Ae=class extends r.Disposable{constructor(e,t,a,n,o,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=o,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(re.debounceTime(100)).subscribe(e=>{var t;if(e){const a=this._univerInstanceService.getUnit(e.location.unitId,r.UniverInstanceType.UNIVER_SHEET),n=a.getSheetBySheetId(e.location.subUnitId);if(!n)return;const o=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!o){this._cellAlertManagerService.removeAlert(Ce);return}if(this._dataValidationModel.validator(o,{...e.location,workbook:a,worksheet:n})===r.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Ce),l=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(l&&l.row===e.location.row&&l.col===e.location.col&&l.subUnitId===e.location.subUnitId&&l.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(Ce);return}const d=this._dataValidationModel.getValidator(o.type);if(!d){this._cellAlertManagerService.removeAlert(Ce);return}this._cellAlertManagerService.showAlert({type:B.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:d==null?void 0:d.getRuleFinalError(o,e.location),location:e.location,width:200,height:74,key:Ce});return}}this._cellAlertManagerService.removeAlert(Ce)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(Ce)}))}};Ae=Ln([Ve(0,r.Inject(B.HoverManagerService)),Ve(1,r.Inject(B.CellAlertManagerService)),Ve(2,r.IUniverInstanceService),Ve(3,r.Inject(r.LocaleService)),Ve(4,f.IZenZoneService),Ve(5,r.Inject(E.SheetDataValidationModel))],Ae);var Tn=Object.getOwnPropertyDescriptor,On=(e,t,a,n)=>{for(var o=n>1?void 0:n?Tn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},st=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends r.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,o)=>{const{source:i,target:s,unitId:l,subUnitId:d}=n,h=this._sheetDataValidationModel.getRuleObjectMatrix(l,d).clone(),p=B.virtualizeDiscreteRanges([i,s]),[v,c]=p.ranges,{mapFunc:_}=p,g={row:v.startRow,col:v.startColumn},D=B.getAutoFillRepeatRange(v,c),V=new r.ObjectMatrix,S=new Set;D.forEach(C=>{const m=C.repeatStartCell,O=C.relativeRange,F={startRow:g.row,startColumn:g.col,endColumn:g.col,endRow:g.row},$={startRow:m.row,startColumn:m.col,endColumn:m.col,endRow:m.row};r.Range.foreach(O,(k,R)=>{const N=r.Rectangle.getPositionRange({startRow:k,startColumn:R,endColumn:R,endRow:k},F),{row:U,col:j}=_(N.startRow,N.startColumn),H=this._sheetDataValidationModel.getRuleIdByLocation(l,d,U,j)||"",q=r.Rectangle.getPositionRange({startRow:k,startColumn:R,endColumn:R,endRow:k},$),{row:Z,col:G}=_(q.startRow,q.startColumn);V.setValue(Z,G,H),S.add(H)})});const w=Array.from(S).map(C=>({id:C,ranges:r.queryObjectMatrix(V,m=>m===C)}));h.addRangeRules(w);const y=h.diff(this._sheetDataValidationModel.getRules(l,d)),{redoMutations:L,undoMutations:I}=E.getDataValidationDiffMutations(l,d,y,this._injector,"patched",o===B.APPLY_TYPE.ONLY_FORMAT);return{undos:I,redos:L}},a={id:E.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:o,unitId:i,subUnitId:s}=n;for(const l of o.rows)for(const d of o.cols){const h=this._sheetDataValidationModel.getRuleByLocation(i,s,l,d);if(h&&h.type===r.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(B.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,o,i)=>i===B.APPLY_TYPE.COPY||i===B.APPLY_TYPE.ONLY_FORMAT||i===B.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};Ee=On([st(0,B.IAutoFillService),st(1,r.Inject(E.SheetDataValidationModel)),st(2,r.Inject(r.Injector))],Ee);var Pn=Object.getOwnPropertyDescriptor,Rn=(e,t,a,n)=>{for(var o=n>1?void 0:n?Pn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},lt=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends r.Disposable{constructor(t,a,n){super();P(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:E.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,o)=>{const{copyType:i=B.COPY_TYPE.COPY,pasteType:s}=o,{range:l}=t||{},{range:d,unitId:h,subUnitId:p}=a;return this._generateMutations(d,{copyType:i,pasteType:s,copyRange:l,unitId:h,subUnitId:p})}})}_collect(t,a,n){const o=new r.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:o};const i=this._injector.invoke(d=>B.rangeToDiscreteRange(n,d,t,a));if(!i)return;const{rows:s,cols:l}=i;s.forEach((d,h)=>{l.forEach((p,v)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(t,a,d,p);o.setValue(h,v,c!=null?c:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===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:o,subUnitId:i}=this._copyInfo;if(a.unitId!==o||i!==a.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),l=new r.ObjectMatrix,d=new Set,{ranges:[h,p],mapFunc:v}=B.virtualizeDiscreteRanges([a.copyRange,t]),c=B.getRepeatRange(h,p,!0),_=new Map;c.forEach(({startRange:S})=>{var w;(w=this._copyInfo)==null||w.matrix.forValue((y,L,I)=>{const C=r.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:L,endColumn:L},S),m=`${i}-${I}`,O=this._sheetDataValidationModel.getRuleById(o,i,I);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,m)&&O&&_.set(m,{...O,uid:m});const{row:F,col:$}=v(C.startRow,C.startColumn);d.add(m),l.setValue(F,$,m)})});const g=Array.from(d).map(S=>({id:S,ranges:r.queryObjectMatrix(l,w=>w===S)}));s.addRangeRules(g);const{redoMutations:D,undoMutations:V}=E.getDataValidationDiffMutations(a.unitId,a.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),_.values()),this._injector,"patched",!1);return{redos:D,undos:V}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(o,i).clone(),l=new r.ObjectMatrix,d=new Set,{ranges:[h,p],mapFunc:v}=B.virtualizeDiscreteRanges([a.copyRange,t]);B.getRepeatRange(h,p,!0).forEach(({startRange:V})=>{var S;(S=this._copyInfo)==null||S.matrix.forValue((w,y,L)=>{const I=r.Rectangle.getPositionRange({startRow:w,endRow:w,startColumn:y,endColumn:y},V),{row:C,col:m}=v(I.startRow,I.startColumn);l.setValue(C,m,L),d.add(L)})});const _=Array.from(d).map(V=>({id:V,ranges:r.queryObjectMatrix(l,S=>S===V)}));s.addRangeRules(_);const{redoMutations:g,undoMutations:D}=E.getDataValidationDiffMutations(o,i,s.diff(this._sheetDataValidationModel.getRules(o,i)),this._injector,"patched",!1);return{redos:g,undos:D}}}};Me=Rn([lt(0,B.ISheetClipboardService),lt(1,r.Inject(E.SheetDataValidationModel)),lt(2,r.Inject(r.Injector))],Me);var An=Object.getOwnPropertyDescriptor,Fn=(e,t,a,n)=>{for(var o=n>1?void 0:n?An(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},dt=(e,t)=>(a,n)=>t(a,n,e);let be=class extends r.Disposable{constructor(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:[z.WorkbookEditablePermission],rangeTypes:[z.RangeProtectionPermissionEditPoint],worksheetTypes:[z.WorksheetEditPermission,z.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===E.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[z.WorkbookEditablePermission],rangeTypes:[z.RangeProtectionPermissionEditPoint],worksheetTypes:[z.WorksheetEditPermission,z.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};be=Fn([dt(0,r.Inject(r.LocaleService)),dt(1,r.ICommandService),dt(2,r.Inject(z.SheetPermissionCheckController))],be);const At="data-validation-single",Ft="sheet.menu.data-validation";function kn(e){return{id:Ft,type:f.MenuItemType.SUBITEMS,icon:At,tooltip:"dataValidation.title",hidden$:f.getMenuHiddenObservable(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:B.getCurrentRangeDisable$(e,{workbookTypes:[z.WorkbookEditablePermission],worksheetTypes:[z.WorksheetSetCellStylePermission,z.WorksheetEditPermission],rangeTypes:[z.RangeProtectionPermissionEditPoint]})}}function Nn(e){return{id:_e.id,title:"dataValidation.panel.title",type:f.MenuItemType.BUTTON}}function Un(e){return{id:$e.id,title:"dataValidation.panel.add",type:f.MenuItemType.BUTTON}}const Bn={[f.RibbonStartGroup.FORMULAS_INSERT]:{[Ft]:{order:9,menuItemFactory:kn,[_e.id]:{order:0,menuItemFactory:Nn},[$e.id]:{order:1,menuItemFactory:Un}}}};var jn=Object.getOwnPropertyDescriptor,kt=(e,t,a,n)=>{for(var o=n>1?void 0:n?jn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Q=(e,t)=>(a,n)=>t(a,n,e);const Nt={tr:{size:6,color:"#fe4b4b"}};let Le=class extends r.RxDisposable{constructor(e,t,a,n,o,i,s,l,d,h,p){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=o,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=l,this._sheetInterceptorService=d,this._dataValidationCacheService=h,this._editorBridgeService=p,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Bn)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var a;if(!e.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:o,row:i,column:s}=t,l=this._univerInstanceService.getUniverSheetInstance(n);if(!l)return;const d=this._sheetDataValidationModel.getRuleByLocation(n,o,i,s);if(!d)return;const h=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!(h!=null&&h.dropdown))return;const p=l.getActiveSheet();if(!p)return;const v=this._dropdownManagerService.activeDropdown,c=v==null?void 0:v.location;if(c&&c.unitId===n&&c.subUnitId===o&&c.row===i&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:o,row:i,col:s,workbook:l,worksheet:p},componentKey:h.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(z.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:z.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var S,w,y,L,I;const{row:n,col:o,unitId:i,subUnitId:s,workbook:l,worksheet:d}=t,h=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,o);if(!h)return a(e);const p=this._sheetDataValidationModel.getRuleById(i,s,h);if(!p)return a(e);const v=(S=this._dataValidationCacheService.getValue(i,s,n,o))!=null?S:r.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),_=t.rawData;let g;const D={get value(){var C;return g!==void 0||(g=(C=E.getCellValueOrigin(_))!=null?C:null),g}},V={get value(){var C;return`${(C=D.value)!=null?C:""}`}};return a({...e,markers:{...e==null?void 0:e.markers,...v===r.DataValidationStatus.INVALID?Nt: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)||((L=c==null?void 0:c.skipDefaultFontRender)==null?void 0:L.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=l.getStyles();return(typeof(e==null?void 0:e.s)=="string"?C.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,o)},interceptorAutoHeight:()=>{var F,$,k,R,N,U;const C=($=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:$.skeleton;if(!C)return;const m=C.worksheet.getMergedCell(n,o),O={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((k=m==null?void 0:m.startRow)!=null?k:n,(R=m==null?void 0:m.startColumn)!=null?R:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(U=(N=c==null?void 0:c.canvasRender)==null?void 0:N.calcCellAutoHeight)==null?void 0:U.call(N,O)},interceptorAutoWidth:()=>{var F,$,k,R,N,U;const C=($=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:$.skeleton;if(!C)return;const m=C.worksheet.getMergedCell(n,o),O={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((k=m==null?void 0:m.startRow)!=null?k:n,(R=m==null?void 0:m.startColumn)!=null?R:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(U=(N=c==null?void 0:c.canvasRender)==null?void 0:N.calcCellAutoWidth)==null?void 0:U.call(N,O)},coverable:((I=e==null?void 0:e.coverable)!=null?I:!0)&&!(p.type===r.DataValidationType.LIST||p.type===r.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===r.DataValidationType.LIST_MULTIPLE||a.rule.type===r.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(a.redos,this._commandService)}})}};Le=kt([Q(0,r.ICommandService),Q(1,f.IMenuManagerService),Q(2,W.IRenderManagerService),Q(3,r.IUniverInstanceService),Q(4,r.Inject(B.AutoHeightController)),Q(5,r.Inject(me)),Q(6,r.Inject(E.SheetDataValidationModel)),Q(7,r.Inject(J.DataValidatorRegistryService)),Q(8,r.Inject(z.SheetInterceptorService)),Q(9,r.Inject(E.DataValidationCacheService)),Q(10,r.Optional(B.IEditorBridgeService))],Le);let Ut=class extends r.RxDisposable{constructor(e,t,a,n,o,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=o,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(z.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:z.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var V,S,w,y,L;const{row:n,col:o,unitId:i,subUnitId:s,workbook:l,worksheet:d}=t,h=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,o);if(!h)return a(e);const p=this._sheetDataValidationModel.getRuleById(i,s,h);if(!p)return a(e);const v=(V=this._dataValidationCacheService.getValue(i,s,n,o))!=null?V:r.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),_=d.getCellRaw(n,o),g=E.getCellValueOrigin(_),D=`${g!=null?g:""}`;return a({...e,markers:{...e==null?void 0:e.markers,...v===r.DataValidationStatus.INVALID?Nt:null},customRender:[...(S=e==null?void 0:e.customRender)!=null?S:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((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,g,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,D,{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,o)},interceptorAutoHeight:()=>{var O,F,$,k,R,N;const I=(F=(O=this._renderManagerService.getRenderById(i))==null?void 0:O.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:F.skeleton;if(!I)return;const C=I.worksheet.getMergedCell(n,o),m={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex(($=C==null?void 0:C.startRow)!=null?$:n,(k=C==null?void 0:C.startColumn)!=null?k:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(N=(R=c==null?void 0:c.canvasRender)==null?void 0:R.calcCellAutoHeight)==null?void 0:N.call(R,m)},coverable:((L=e==null?void 0:e.coverable)!=null?L:!0)&&!(p.type===r.DataValidationType.LIST||p.type===r.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);r.sequenceExecute(a.redos,this._commandService)}})}};Ut=kt([Q(0,r.ICommandService),Q(1,W.IRenderManagerService),Q(2,r.Inject(B.AutoHeightController)),Q(3,r.Inject(J.DataValidatorRegistryService)),Q(4,r.Inject(z.SheetInterceptorService)),Q(5,r.Inject(E.SheetDataValidationModel)),Q(6,r.Inject(E.DataValidationCacheService))],Ut);var Wn=Object.getOwnPropertyDescriptor,$n=(e,t,a,n)=>{for(var o=n>1?void 0:n?Wn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Bt=(e,t)=>(a,n)=>t(a,n,e);let He=class extends r.Disposable{constructor(e,t,a){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const a=new Set;t.forEach(o=>{a.add(o.subUnitId)}),a.forEach(o=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(o))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(r.bufferDebounceTime(16)).subscribe(e))}};He=$n([Bt(1,r.Inject(E.SheetDataValidationModel)),Bt(2,r.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"},Hn=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:o,validResult:i}=e,s=f.useDependency(r.LocaleService),l=o?i==null?void 0:i.formula1:"",d=o?i==null?void 0:i.formula2:"";return t?u.jsxs(u.Fragment,{children:[u.jsx(T.FormLayout,{error:l,children:u.jsx(T.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:h=>{n==null||n({...a,formula1:h})}})}),u.jsx("div",{className:ne.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),u.jsx(T.FormLayout,{error:d,children:u.jsx(T.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:h=>{n==null||n({...a,formula2:h})}})})]}):u.jsx(T.FormLayout,{error:l,children:u.jsx(T.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:h=>{n==null||n({formula1:h})}})})};function Yn(e){const{value:t,onChange:a,showError:n,validResult:o}=e,i=f.useDependency(r.LocaleService),s=n?o==null?void 0:o.formula1:"",l=n?o==null?void 0:o.formula2:"",[d,h]=M.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(T.FormLayout,{children:u.jsx(T.Checkbox,{checked:d,onChange:p=>{p?h(!0):(h(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),d?u.jsx(T.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:u.jsx(T.Input,{className:ne.dataValidationFormula,placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:p=>{a==null||a({...t,formula1:p||void 0})}})}):null,d?u.jsx(T.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:l,children:u.jsx(T.Input,{className:ne.dataValidationFormula,placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:p=>{a==null||a({...t,formula2:p||void 0})}})}):null]})}function xn(e){var v;const{unitId:t,subUnitId:a,value:n,onChange:o,showError:i,validResult:s}=e,l=i?s==null?void 0:s.formula1:void 0,d=M.useRef({}),[h,p]=M.useState(!1);return f.useSidebarClick(c=>{var g;const _=(g=d.current)==null?void 0:g.handleOutClick;_&&_(c,()=>p(!1))}),u.jsx(tt.FormulaEditor,{initValue:(v=n==null?void 0:n.formula1)!=null?v:"=",unitId:t,subUnitId:a,isFocus:h,onChange:c=>{const _=(c!=null?c:"").trim();_!==(n==null?void 0:n.formula1)&&(o==null||o({...n,formula1:_}))},errorText:l,onFocus:()=>p(!0),actions:d.current,isSupportAcrossSheet:!0})}function jt(e){var t,a,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(a=jt(e[t]))&&(n&&(n+=" "),n+=a)}else for(a in e)e[a]&&(n&&(n+=" "),n+=a);return n}function Xn(){for(var e,t,a=0,n="",o=arguments.length;a<o;a++)(e=arguments[a])&&(t=jt(e))&&(n&&(n+=" "),n+=t);return n}const zn=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Kn=e=>{const{value:t,onChange:a,disabled:n}=e,[o,i]=M.useState(!1);return u.jsx(T.Select,{disabled:n,open:o,onDropdownVisibleChange:i,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ne.dataValidationFormulaColorSelect,value:t,onChange:a,labelRender:s=>u.jsx("div",{className:ne.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>u.jsx("div",{className:ne.dataValidationFormulaColorSelectPanel,children:zn.map(s=>u.jsx("div",{onClick:()=>{a(s),i(!1)},className:ne.dataValidationFormulaColorItem,style:{background:s}},s))})})},Wt=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:o,onItemDelete:i}=a;return u.jsxs("div",{className:ne.dataValidationFormulaListItem,style:n,children:[t.isRef?null:u.jsx("div",{className:Xn(ne.dataValidationFormulaListItemDrag,"draggableHandle"),children:u.jsx(Lt,{})}),u.jsx(Kn,{value:t.color,onChange:s=>{o(t.id,t.label,s)}}),u.jsx(T.Input,{disabled:t.isRef,value:t.label,onChange:s=>{o(t.id,s,t.color)}}),t.isRef?null:u.jsx("div",{className:ne.dataValidationFormulaListItemIcon,children:u.jsx(nt,{onClick:()=>i(t.id)})})]})};function Gn(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:o,validResult:i,showError:s,ruleId:l}=e,{formula1:d="",formula2:h=""}=t||{},p=M.useRef(null),[v,c]=M.useState(()=>r.isFormulaString(d)?"1":"0"),[_,g]=M.useState(v==="1"?d:"="),[D,V]=M.useState(v==="1"?d:"="),S=f.useDependency(r.LocaleService),w=f.useDependency(J.DataValidatorRegistryService),y=f.useDependency(J.DataValidationModel),L=f.useDependency(E.DataValidationFormulaController),[I,C]=M.useState(()=>h.split(",")),m=w.getValidatorItem(r.DataValidationType.LIST),[O,F]=M.useState([]),[$,k]=M.useState(""),R=s?i==null?void 0:i.formula1:"",N=M.useMemo(()=>y.ruleChange$.pipe(re.debounceTime(16)),[]),U=f.useObservable(N),j=f.useEvent(a);M.useEffect(()=>{(async()=>{await new Promise(X=>{setTimeout(()=>X(!0),100)});const b=y.getRuleById(n,o,l),Y=b==null?void 0:b.formula1;if(r.isFormulaString(Y)&&m&&b){const X=await m.getListAsync(b,n,o);F(X)}})()},[y,U,m,l,o,n]),M.useEffect(()=>{r.isFormulaString(d)&&d!==D&&(g(d),V(D))},[D,d]);const[H,q]=M.useState(()=>{const b=v!=="1"?E.deserializeListOptions(d):[],Y=h.split(",");return b.map((X,K)=>({label:X,color:Y[K]||Ie,isRef:!1,id:r.Tools.generateRandomId(4)}))}),Z=(b,Y,X)=>{const K=H.find(fe=>fe.id===b);K&&(K.label=Y,K.color=X,q([...H]))},G=b=>{const Y=H.findIndex(X=>X.id===b);Y!==-1&&(H.splice(Y,1),q([...H]))},ee=h.split(","),te=M.useMemo(()=>O.map((b,Y)=>({label:b,color:ee[Y]||Ie,id:`${Y}`,isRef:!0})),[ee,O]),ae=(b,Y,X)=>{const K=[...I];K[+b]=X,C(K),j({formula1:d,formula2:K.join(",")})},oe=()=>{q([...H,{label:"",color:Ie,isRef:!1,id:r.Tools.generateRandomId(4)}])};M.useEffect(()=>{if(v==="1")return;const b=new Set,Y=[];H.map(X=>({labelList:X.label.split(","),item:X})).forEach(({item:X,labelList:K})=>{K.forEach(fe=>{b.has(fe)||(b.add(fe),Y.push({label:fe,color:X.color}))})}),j({formula1:E.serializeListOptions(Y.map(X=>X.label)),formula2:Y.map(X=>X.color===Ie?"":X.color).join(",")})},[H,j,v,D,I]);const le=f.useEvent(async b=>{if(!r.isFormulaString(b)){j==null||j({formula1:"",formula2:h});return}L.getFormulaRefCheck(b)?(j==null||j({formula1:r.isFormulaString(b)?b:"",formula2:h}),k("")):(j==null||j({formula1:"",formula2:h}),g("="),k(S.t("dataValidation.validFail.formulaError")))}),ie=M.useRef({}),[de,A]=M.useState(!1);return f.useSidebarClick(b=>{var X;const Y=(X=ie.current)==null?void 0:X.handleOutClick;Y&&Y(b,()=>A(!1))}),u.jsxs(u.Fragment,{children:[u.jsx(T.FormLayout,{label:S.t("dataValidation.list.options"),children:u.jsxs(T.RadioGroup,{value:v,onChange:b=>{c(b),g(D),b==="1"&&j({formula1:D==="="?"":D,formula2:I.join(",")})},children:[u.jsx(T.Radio,{value:"0",children:S.t("dataValidation.list.customOptions")}),u.jsx(T.Radio,{value:"1",children:S.t("dataValidation.list.refOptions")})]})}),v==="1"?u.jsxs(u.Fragment,{children:[u.jsx(tt.FormulaEditor,{initValue:_,unitId:n,subUnitId:o,isFocus:de,onChange:(b="")=>{const Y=(b!=null?b:"").trim();V(Y),le(Y)},errorText:R||$||void 0,onFocus:()=>A(!0),actions:ie.current,isSupportAcrossSheet:!0}),u.jsx("div",{ref:p,style:{marginTop:"12px"},children:te.map(b=>u.jsx(Wt,{item:b,commonProps:{onItemChange:ae},style:{marginBottom:12}},b.id))})]}):u.jsx(T.FormLayout,{error:R,children:u.jsxs("div",{ref:p,style:{marginTop:"-12px"},children:[u.jsx(T.DraggableList,{list:H,onListChange:q,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:b=>u.jsx(Wt,{item:b,commonProps:{onItemChange:Z,onItemDelete:G}},b.id),idKey:"id"}),u.jsxs("a",{className:ne.dataValidationFormulaListAdd,onClick:oe,children:[u.jsx(Et,{}),S.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",qn=[[$t,xn],[Ye,Hn],[ct,Gn],[Ht,Yn]],Zn="LIST_RENDER_MODE_OPTION_INPUT";function xe(e){var o;const{value:t,onChange:a}=e,n=f.useDependency(r.LocaleService);return u.jsx(T.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:u.jsxs(T.RadioGroup,{value:`${(o=t.renderMode)!=null?o:r.DataValidationRenderMode.CUSTOM}`,onChange:i=>a({...t,renderMode:+i}),children:[u.jsx(T.Radio,{value:`${r.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),u.jsx(T.Radio,{value:`${r.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),u.jsx(T.Radio,{value:`${r.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}xe.componentKey=Zn;const Jn="DATE_SHOW_TIME_OPTION";function Xe(e){var o;const{value:t,onChange:a}=e,n=f.useDependency(r.LocaleService);return u.jsx(T.FormLayout,{children:u.jsx(T.Checkbox,{checked:(o=t.bizInfo)==null?void 0:o.showTime,onChange:i=>{a({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:n.t("dataValidation.showTime.label")})})}Xe.componentKey=Jn;var Qn=Object.getOwnPropertyDescriptor,ea=(e,t,a,n)=>{for(var o=n>1?void 0:n?Qn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Fe=(e,t)=>(a,n)=>t(a,n,e);const ze=6;let ut=class{constructor(e,t,a,n,o){this._commandService=e,this._formulaService=t,this._themeService=a,this._renderManagerService=n,this._dataValidationModel=o}_calc(e,t){var h,p,v;const{vt:a,ht:n}=t||{},o=e.endX-e.startX-ze*2,i=e.endY-e.startY,s=((h=t==null?void 0:t.fs)!=null?h:10)*1.6;let l=0,d=0;switch(a){case r.VerticalAlign.TOP:d=0;break;case r.VerticalAlign.BOTTOM:d=0+(i-s);break;default:d=0+(i-s)/2;break}switch(n){case r.HorizontalAlign.LEFT:l=ze;break;case r.HorizontalAlign.RIGHT:l=ze+(o-s);break;default:l=ze+(o-s)/2;break}return{left:e.startX+l,top:e.startY+d,width:((p=t==null?void 0:t.fs)!=null?p:10)*1.6,height:((v=t==null?void 0:t.fs)!=null?v:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var h,p,v,c,_,g,D,V,S;const{formula1:n=E.CHECKBOX_FORMULA_1,formula2:o=E.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=E.getFormulaResult((v=(p=(h=i==null?void 0:i[0])==null?void 0:h.result)==null?void 0:p[0])==null?void 0:v[0]),l=E.getFormulaResult((g=(_=(c=i==null?void 0:i[1])==null?void 0:c.result)==null?void 0:_[0])==null?void 0:g[0]),d=E.isLegalFormulaResult(String(s))&&E.isLegalFormulaResult(String(l));return{formula1:r.isFormulaString(n)?E.getFormulaResult((S=(V=(D=i==null?void 0:i[0])==null?void 0:D.result)==null?void 0:V[0])==null?void 0:S[0]):n,formula2:r.isFormulaString(o)?l:o,isFormulaValid:d}}drawWith(e,t){var R,N,U,j;const{style:a,primaryWithCoord:n,unitId:o,subUnitId:i,worksheet:s,row:l,col:d}=t,h=n.isMergedMainCell?n.mergeInfo:n,p=E.getCellValueOrigin(s.getCellRaw(l,d)),v=this._dataValidationModel.getRuleByLocation(o,i,l,d);if(!v)return;const c=this._dataValidationModel.getValidator(v.type);if(!c)return;const _=this._themeService.getCurrentTheme();if(!((R=c.skipDefaultFontRender)!=null&&R.call(c,v,p,{unitId:o,subUnitId:i,row:l,column:d})))return;const g=c.parseFormulaSync(v,o,i),{formula1:D}=g,V=this._calc(h,a),{a:S,d:w}=e.getTransform(),y=W.fixLineWidthByScale(V.left,S),L=W.fixLineWidthByScale(V.top,w),I=W.Transform.create().composeMatrix({left:y,top:L,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),C=h.endX-h.startX,m=h.endY-h.startY;e.save(),e.beginPath(),e.rect(h.startX,h.startY,C,m),e.clip();const O=I.getMatrix();e.transform(O[0],O[1],O[2],O[3],O[4],O[5]);const F=((N=a==null?void 0:a.fs)!=null?N:10)*1.6,$=String(p)===String(D),k=_.hyacinth500;W.CheckboxShape.drawWith(e,{checked:$,width:F,height:F,fill:(j=(U=a==null?void 0:a.cl)==null?void 0:U.rgb)!=null?j:k}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),o=n.top,i=n.top+n.height,s=n.left,l=n.left+n.width,{x:d,y:h}=e;return d<=l&&d>=s&&h<=i&&h>=o}async onPointerDown(e,t){var g;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:o,worksheet:i,row:s,col:l}=e,d=E.getCellValueOrigin(i.getCellRaw(s,l)),h=this._dataValidationModel.getRuleByLocation(n,o,s,l);if(!h)return;const p=this._dataValidationModel.getValidator(h.type);if(!p||!((g=p.skipDefaultFontRender)!=null&&g.call(p,h,d,{unitId:n,subUnitId:o,row:s,column:l})))return;const{formula1:v,formula2:c}=await this._parseFormula(h,n,o),_={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(d)===E.transformCheckboxValue(String(v))?c:v,p:null}};this._commandService.executeCommand(z.SetRangeValuesCommand.id,_)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(W.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(W.CURSOR_TYPE.DEFAULT)}};ut=ea([Fe(0,r.ICommandService),Fe(1,r.Inject(E.DataValidationFormulaService)),Fe(2,r.Inject(r.ThemeService)),Fe(3,r.Inject(W.IRenderManagerService)),Fe(4,r.Inject(E.SheetDataValidationModel))],ut);var ta=Object.getOwnPropertyDescriptor,na=(e,t,a,n)=>{for(var o=n>1?void 0:n?ta(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},aa=(e,t)=>(a,n)=>t(a,n,e);let he=class{constructor(e){P(this,"canvasRender",null);P(this,"dropdown");P(this,"optionsInput");P(this,"formulaInput",ct);this.injector=e}};he=na([aa(0,r.Inject(r.Injector))],he);class oa extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.CHECKBOX);P(this,"canvasRender",this.injector.createInstance(ut));P(this,"formulaInput",Ht)}}class ia extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.CUSTOM);P(this,"formulaInput",$t)}}const ra="data-validation.formula-input";class sa extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.DATE);P(this,"formulaInput",ra);P(this,"optionsInput",Xe.componentKey);P(this,"dropdown",rt)}}class la extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.DECIMAL);P(this,"formulaInput",Ye)}}const Yt=4,da=0,ht=4,xt=4,pt=6,Ke=6,De=14;function ca(e,t){const a=W.FontCache.getTextSize(e,t),n=a.width+Yt*2,{ba:o,bd:i}=a,s=o+i;return{width:n,height:s+da*2,ba:o}}function vt(e,t,a,n){const o=De+pt*2,i=a-o,s=n-Ke*2,l=e.map(c=>({layout:ca(c,t),text:c}));let d;const h=[];l.forEach(c=>{const{layout:_}=c,{width:g,height:D}=_;!d||d.width+g+ht>i?(d={width:g,height:D,items:[{...c,left:0}]},h.push(d)):(d.items.push({...c,left:d.width+ht}),d.width=d.width+g+ht)});let p=0,v=0;return h.forEach((c,_)=>{v=Math.max(v,c.width),_===h.length-1?p+=c.height:p+=c.height+xt}),{lines:h,totalHeight:p,contentWidth:i,contentHeight:s,cellAutoHeight:p+Ke*2,calcAutoWidth:v+o}}const ua=8;class ha extends W.Shape{static drawWith(t,a){const{fontString:n,info:o,fill:i,color:s}=a,{layout:l,text:d}=o;t.save(),W.Rect.drawWith(t,{width:l.width,height:l.height,radius:ua,fill:i||Ie}),t.translateWithPrecision(Yt,l.ba),t.font=n,t.fillStyle=s,t.fillText(d,0,0),t.restore()}}var pa=Object.getOwnPropertyDescriptor,va=(e,t,a,n)=>{for(var o=n>1?void 0:n?pa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},gt=(e,t)=>(a,n)=>t(a,n,e);const ga=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){P(this,"zIndex");P(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,o){const i=a-De+4;let s=4;switch(o){case r.VerticalAlign.MIDDLE:s=(n-De)/2+4;break;case r.VerticalAlign.BOTTOM:s=n-De+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(ga),e.restore()}drawWith(e,t,a,n){var Z,G;const{primaryWithCoord:o,row:i,col:s,style:l,data:d,subUnitId:h}=t,p=o.isMergedMainCell?o.mergeInfo:o,v=d==null?void 0:d.fontRenderExtension,{leftOffset:c=0,rightOffset:_=0,topOffset:g=0,downOffset:D=0}=v||{},V=this._ensureMap(h),S=this._generateKey(i,s),w=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,s);if(!w)return;const y=this._dataValidationModel.getValidator(w.type);if(!y)return;const L={startX:p.startX+c,endX:p.endX-_,startY:p.startY+g,endY:p.endY-D},I=L.endX-L.startX,C=L.endY-L.startY,{cl:m}=l||{},O=(Z=typeof m=="object"?m==null?void 0:m.rgb:m)!=null?Z:"#000",F=W.getFontStyleString(l!=null?l:void 0),{vt:$,ht:k}=l||{},R=$!=null?$:r.VerticalAlign.MIDDLE,N=(G=E.getCellValueOrigin(d))!=null?G:"",U=y.parseCellValue(N),j=y.getListWithColorMap(w),H=vt(U,F,I,C);this._drawDownIcon(e,L,I,C,R),e.save(),e.translateWithPrecision(L.startX,L.startY),e.beginPath(),e.rect(0,0,I-De,C),e.clip(),e.translateWithPrecision(pt,Ke);let q=0;switch(R){case r.VerticalAlign.MIDDLE:q=(H.contentHeight-H.totalHeight)/2;break;case r.VerticalAlign.BOTTOM:q=H.contentHeight-H.totalHeight;break}e.translateWithPrecision(0,q),H.lines.forEach((ee,te)=>{e.save();const{width:ae,height:oe,items:le}=ee;let ie=0;switch(k){case r.HorizontalAlign.RIGHT:ie=H.contentWidth-ae;break;case r.HorizontalAlign.CENTER:ie=(H.contentWidth-ae)/2;break}e.translate(ie,te*(oe+xt)),le.forEach(de=>{e.save(),e.translateWithPrecision(de.left,0),ha.drawWith(e,{...F,info:de,color:O,fill:j[de.text]}),e.restore()}),e.restore()}),e.restore(),V.set(S,{left:L.startX,top:L.startY,width:H.contentWidth+pt+De,height:H.contentHeight+Ke*2})}calcCellAutoHeight(e){var I;const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:p=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,c={startX:v.startX+l,endX:v.endX-d,startY:v.startY+h,endY:v.endY-p},_=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!_)return;const g=this._dataValidationModel.getValidator(_.type);if(!g)return;const D=c.endX-c.startX,V=c.endY-c.startY,S=(I=E.getCellValueOrigin(n))!=null?I:"",w=g.parseCellValue(S),y=W.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:o,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:p=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,c={startX:v.startX+l,endX:v.endX-d,startY:v.startY+h,endY:v.endY-p},_=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!_)return;const g=this._dataValidationModel.getValidator(_.type);if(!g)return;const D=c.endX-c.startX,V=c.endY-c.startY,S=(I=E.getCellValueOrigin(n))!=null?I:"",w=g.parseCellValue(S),y=W.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:o}=n,{x:i}=e;return i>=o-De&&i<=o}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:i}=e,s={unitId:a,subUnitId:n,row:o,column:i};this._commandService.executeCommand(Ne.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(W.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(W.CURSOR_TYPE.DEFAULT)}};mt=va([gt(0,r.ICommandService),gt(1,r.Inject(W.IRenderManagerService)),gt(2,r.Inject(E.SheetDataValidationModel))],mt);class ma extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.LIST_MULTIPLE);P(this,"canvasRender",this.injector.createInstance(mt));P(this,"dropdown",We)}}var fa=Object.getOwnPropertyDescriptor,Sa=(e,t,a,n)=>{for(var o=n>1?void 0:n?fa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Ge=(e,t)=>(a,n)=>t(a,n,e);const ye=4,qe=4,ce=14,pe=6,Te=4,ft=8,_a="#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 Ia(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${r.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:r.BooleanNumber.FALSE,bl:r.BooleanNumber.FALSE,ul:{s:r.BooleanNumber.FALSE},st:{s:r.BooleanNumber.FALSE},ol:{s:r.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function zt(e,t,a){const n=Ia(e,a),o=new r.DocumentDataModel(n),i=new W.DocumentViewModel(o);return{documentSkeleton:W.DocumentSkeleton.create(i,t),docModel:o,docViewModel:i}}function Ze(e,t,a){const{documentSkeleton:n,docModel:o,docViewModel:i}=zt(e,t,a);return{documents:new W.Documents(`DOCUMENTS_${r.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:o,docViewModel:i}}function Kt(e,t,a,n,o,i,s=!0){let l=0;const d=s?Te:0;switch(o){case r.VerticalAlign.BOTTOM:l=t-n-d;break;case r.VerticalAlign.MIDDLE:l=(t-n)/2;break;default:l=d;break}l=Math.max(Te,l);let h=0;switch(i){case r.HorizontalAlign.CENTER:h=(e-a)/2;break;case r.HorizontalAlign.RIGHT:h=e-a;break}return h=Math.max(pe,h),{paddingLeft:h,paddingTop:l}}let St=class{constructor(e,t,a,n){P(this,"_dropdownInfoMap",new Map);P(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,o,i,s){const{t:l=r.DEFAULT_STYLES.pd.t,b:d=r.DEFAULT_STYLES.pd.b}=s,h=a-ce;let p;switch(i){case r.VerticalAlign.MIDDLE:p=(n-qe)/2;break;case r.VerticalAlign.BOTTOM:p=n-d-o-Te+(o/2-qe/2);break;default:p=l+Te+(o/2-qe/2);break}e.save(),e.translateWithPrecision(t.startX+h,t.startY+p),e.fillStyle="#565656",e.fill(Xt),e.restore()}drawWith(e,t,a){const{primaryWithCoord:n,row:o,col:i,style:s,data:l,subUnitId:d}=t,h=n.isMergedMainCell?n.mergeInfo:n,p=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,o,i);if(!p)return;const v=this._dataValidationModel.getValidator(p.type);if(!v)return;const c=l==null?void 0:l.fontRenderExtension,{leftOffset:_=0,rightOffset:g=0,topOffset:D=0,downOffset:V=0}=c||{};if(!p||!v||!v||v.id.indexOf(r.DataValidationType.LIST)!==0||!v.skipDefaultFontRender(p))return;const S={startX:h.startX+_,endX:h.endX-g,startY:h.startY+D,endY:h.endY-V},w=S.endX-S.startX,y=S.endY-S.startY,L=this._ensureMap(d),I=this._generateKey(o,i),C=v.getListWithColor(p),m=E.getCellValueOrigin(l),O=`${m!=null?m:""}`,F=C.find(U=>U.label===O);let{tb:$,vt:k,ht:R,pd:N}=s||{};if($=$!=null?$:r.WrapStrategy.WRAP,k=k!=null?k:r.VerticalAlign.BOTTOM,R=R!=null?R:r.DEFAULT_STYLES.ht,N=N!=null?N:r.DEFAULT_STYLES.pd,p.renderMode===r.DataValidationRenderMode.ARROW){const{l:U=r.DEFAULT_STYLES.pd.l,t:j=r.DEFAULT_STYLES.pd.t,r:H=r.DEFAULT_STYLES.pd.r,b:q=r.DEFAULT_STYLES.pd.b}=N,Z=w-U-H-ce-4,{documentSkeleton:G,documents:ee,docModel:te}=Ze(O,this._localeService,s);$===r.WrapStrategy.WRAP&&te.updateDocumentDataPageSize(Math.max(Z,1)),G.calculate(),G.getActualSize();const ae=W.getDocsSkeletonPageSize(G),{height:oe,width:le}=ae,{paddingTop:ie,paddingLeft:de}=Kt(Z,y-j-q,le,oe,k,R,!0);this._drawDownIcon(e,S,w,y,oe,k,N),e.save(),e.translateWithPrecision(S.startX+U,S.startY+j),e.beginPath(),e.rect(0,0,w-U-H,y-j-q),e.clip(),e.translateWithPrecision(0,ie),e.save(),e.translateWithPrecision(ye,0),e.beginPath(),e.rect(0,0,Z,oe),e.clip(),ee.render(e),e.translateWithPrecision(de,0),e.restore(),e.restore(),L.set(I,{left:S.endX+U+a.rowHeaderWidth-ce,top:S.startY+j+a.columnHeaderHeight,width:ce,height:y-j-q})}else{e.save(),e.translateWithPrecision(S.startX,S.startY),e.beginPath(),e.rect(0,0,w,y),e.clip();const U=w-pe*2-ye-ce-4,{documentSkeleton:j,documents:H,docModel:q}=Ze(O,this._localeService,s);$===r.WrapStrategy.WRAP&&q.updateDocumentDataPageSize(Math.max(U,1)),j.calculate();const Z=W.getDocsSkeletonPageSize(j),{height:G,width:ee}=Z,{paddingTop:te,paddingLeft:ae}=Kt(U,y,ee,G,k,R);e.translateWithPrecision(pe,te);const oe=Math.max(w-pe*2,1),le=G;W.Rect.drawWith(e,{width:oe,height:le,fill:(F==null?void 0:F.color)||Ie,radius:ft}),e.save(),e.translateWithPrecision(ye,0),e.beginPath(),e.rect(0,0,U,G),e.clip(),e.translateWithPrecision(ae,0),H.render(e),e.restore(),e.translateWithPrecision(U+ye+4,(G-qe)/2),e.fillStyle=_a,e.fill(Xt),e.restore(),L.set(I,{left:S.startX+pe+a.rowHeaderWidth,top:S.startY+te+a.columnHeaderHeight,width:oe,height:le})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,l=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:h=0,topOffset:p=0,downOffset:v=0}=l||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!c||c.renderMode===r.DataValidationRenderMode.TEXT)return;const _={startX:s.startX+d,endX:s.endX-h,startY:s.startY+p,endY:s.endY-v},g=_.endX-_.startX,D=E.getCellValueOrigin(n),V=`${D!=null?D:""}`;let{tb:S,pd:w}=a||{};const{t:y=r.DEFAULT_STYLES.pd.t,b:L=r.DEFAULT_STYLES.pd.b}=w!=null?w:{};if(S=S!=null?S:r.WrapStrategy.WRAP,c.renderMode===r.DataValidationRenderMode.ARROW){const I=g-ce,{documentSkeleton:C,docModel:m}=Ze(V,this._localeService,a);S===r.WrapStrategy.WRAP&&m.updateDocumentDataPageSize(Math.max(I,1)),C.calculate(),C.getActualSize();const O=W.getDocsSkeletonPageSize(C),{height:F}=O;return F+y+L+Te*2}else{const I=g-pe*2-ye-ce,{documentSkeleton:C,docModel:m}=zt(V,this._localeService,a);S===r.WrapStrategy.WRAP&&m.updateDocumentDataPageSize(Math.max(I,1)),C.calculate();const O=W.getDocsSkeletonPageSize(C),{height:F}=O;return F+Te*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,l=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:h=0,topOffset:p=0,downOffset:v=0}=l||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!c||c.renderMode===r.DataValidationRenderMode.TEXT)return;const _={startX:s.startX+d,endX:s.endX-h,startY:s.startY+p,endY:s.endY-v},g=_.endX-_.startX,D=E.getCellValueOrigin(n),V=`${D!=null?D:""}`;let{tb:S,pd:w}=a||{};const{l:y=r.DEFAULT_STYLES.pd.l,r:L=r.DEFAULT_STYLES.pd.r}=w!=null?w:{};S=S!=null?S:r.WrapStrategy.WRAP;let I=pe*2+ce;switch(c.renderMode){case r.DataValidationRenderMode.ARROW:I=ce+pe*2+L+y;break;case r.DataValidationRenderMode.CUSTOM:I=ce+pe*2+ye*2+L+y+ft/2+1;break;default:I=ce+pe*2+ye*2+L+y+ft/2+1}const C=g-I,{documentSkeleton:m,docModel:O}=Ze(V,this._localeService,a);return S===r.WrapStrategy.WRAP&&O.updateDocumentDataPageSize(Math.max(C,1)),m.calculate(),m.getActualSize(),W.getDocsSkeletonPageSize(m).width+I}isHit(e,t){const{subUnitId:a,row:n,col:o}=t,s=this._ensureMap(a).get(this._generateKey(n,o)),l=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,o);if(!l||!s||l.renderMode===r.DataValidationRenderMode.TEXT)return!1;const{top:d,left:h,width:p,height:v}=s,{x:c,y:_}=e;return c>=h&&c<=h+p&&_>=d&&_<=d+v}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:i}=e,s={unitId:a,subUnitId:n,row:o,column:i};this._commandService.executeCommand(Ne.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(W.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(W.CURSOR_TYPE.DEFAULT)}};St=Sa([Ge(0,r.Inject(r.LocaleService)),Ge(1,r.ICommandService),Ge(2,r.Inject(W.IRenderManagerService)),Ge(3,r.Inject(E.SheetDataValidationModel))],St);class Ca extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.LIST);P(this,"canvasRender",this.injector.createInstance(St));P(this,"dropdown",We);P(this,"optionsInput",xe.componentKey);P(this,"formulaInput",ct)}}class Da extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.TEXT_LENGTH);P(this,"formulaInput",Ye)}}class ya extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.WHOLE);P(this,"formulaInput",Ye)}}var wa=Object.getOwnPropertyDescriptor,Va=(e,t,a,n)=>{for(var o=n>1?void 0:n?wa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},_t=(e,t)=>(a,n)=>t(a,n,e);let Oe=class extends r.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[At,Vt],[ke,Mn],[Ot,gn],[We,_n],[rt,en],[xe.componentKey,xe],[Xe.componentKey,Xe],...qn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[la,ya,Da,sa,oa,Ca,ma,ia].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=Va([_t(0,r.Inject(r.Injector)),_t(1,r.Inject(f.ComponentManager)),_t(2,r.Inject(J.DataValidatorRegistryService))],Oe);var Ea=Object.getOwnPropertyDescriptor,Ma=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ea(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},It=(e,t)=>(a,n)=>t(a,n,e);const ba="SHEET_DATA_VALIDATION_UI_PLUGIN";x.UniverSheetsDataValidationUIPlugin=(Je=class extends r.Plugin{constructor(t=Ue,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:i,...s}=r.merge({},Ue,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ot,s)}onStarting(){[[ue],[me],[Ae],[Ee],[Le],[be],[Me],[Re],[Oe]].forEach(t=>{this._injector.add(t)}),[$e,Ne,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(W.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[He])}onRendered(){this._injector.get(Oe),this._injector.get(Le)}onSteady(){this._injector.get(Ee)}},P(Je,"pluginName",ba),P(Je,"type",r.UniverInstanceType.UNIVER_SHEET),Je),x.UniverSheetsDataValidationUIPlugin=Ma([It(1,r.Inject(r.Injector)),It(2,r.ICommandService),It(3,r.IConfigService)],x.UniverSheetsDataValidationUIPlugin);var La=Object.getOwnPropertyDescriptor,Ta=(e,t,a,n)=>{for(var o=n>1?void 0:n?La(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Ct=(e,t)=>(a,n)=>t(a,n,e);const Oa="SHEET_DATA_VALIDATION_UI_PLUGIN";x.UniverSheetsDataValidationMobileUIPlugin=(Qe=class extends r.Plugin{constructor(t=Ue,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:i,...s}=r.merge({},Ue,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ot,s)}onStarting(){[[ue],[me],[Ae],[Ee],[Le],[be],[Me],[Oe]].forEach(t=>{this._injector.add(t)}),[$e,Ne,Rt,at,_e,Pt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Me),this._injector.get(be),this._injector.get(W.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[He])}onRendered(){this._injector.get(Oe),this._injector.get(Le)}onSteady(){this._injector.get(Ee)}},P(Qe,"pluginName",Oa),P(Qe,"type",r.UniverInstanceType.UNIVER_SHEET),Qe),x.UniverSheetsDataValidationMobileUIPlugin=Ta([Ct(1,r.Inject(r.Injector)),Ct(2,r.ICommandService),Ct(3,r.IConfigService)],x.UniverSheetsDataValidationMobileUIPlugin),x.DATE_DROPDOWN_KEY=rt,x.LIST_DROPDOWN_KEY=We,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
1
+ (function(x,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react/jsx-runtime"),require("@univerjs/core"),require("@univerjs/design"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("react"),require("@univerjs/data-validation"),require("@univerjs/docs"),require("rxjs"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@univerjs/core","@univerjs/design","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-data-validation","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/ui","react","@univerjs/data-validation","@univerjs/docs","rxjs","@univerjs/engine-formula","@univerjs/sheets-formula-ui"],u):(x=typeof globalThis<"u"?globalThis:x||self,u(x.UniverSheetsDataValidationUi={},x.React,x.UniverCore,x.UniverDesign,x.UniverEngineRender,x.UniverSheets,x.UniverSheetsDataValidation,x.UniverSheetsNumfmt,x.UniverSheetsUi,x.UniverUi,x.React,x.UniverDataValidation,x.UniverDocs,x.rxjs,x.UniverEngineFormula,x.UniverSheetsFormulaUi))})(this,function(x,u,r,T,j,X,E,Gt,W,f,M,J,qt,re,et,tt){"use strict";var Ra=Object.defineProperty;var Aa=(x,u,r)=>u in x?Ra(x,u,{enumerable:!0,configurable:!0,writable:!0,value:r}):x[u]=r;var P=(x,u,r)=>Aa(x,typeof u!="symbol"?u+"":u,r);var Je,Qe;var Zt=Object.getOwnPropertyDescriptor,Jt=(e,t,a,n)=>{for(var o=n>1?void 0:n?Zt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Pe=(e,t)=>(a,n)=>t(a,n,e);let Re=class extends r.Disposable{constructor(e,t,a,n,o){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=o,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(X.AFTER_CELL_EDIT_ASYNC,{handler:async(e,t,a)=>{var D;const n=await e,{worksheet:o,row:i,col:s,unitId:l,subUnitId:d,workbook:h}=t,p=this._dataValidationModel.getRuleIdByLocation(l,d,i,s),v=p?this._dataValidationModel.getRuleById(l,d,p):void 0;if(!v||v.errorStyle!==r.DataValidationErrorStyle.STOP)return a(Promise.resolve(n));const c=await this._dataValidatorRegistryService.getValidatorItem(v.type);if(!c||await c.validator({value:E.getCellValueOrigin(n),interceptValue:E.getCellValueOrigin((D=t==null?void 0:t.origin)!=null?D:n),row:i,column:s,unitId:l,subUnitId:d,worksheet:o,workbook:h,t:n==null?void 0:n.t},v))return a(Promise.resolve(n));const g=o.getCellRaw(i,s);return this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:c.getRuleFinalError(v,{row:i,col:s,unitId:l,subUnitId:d})},footer:{title:M.createElement(T.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(Promise.resolve(g))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:M.createElement(T.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Re=Jt([Pe(0,r.Inject(X.SheetInterceptorService)),Pe(1,r.Inject(E.SheetDataValidationModel)),Pe(2,r.Inject(J.DataValidatorRegistryService)),Pe(3,f.IDialogService),Pe(4,r.Inject(r.LocaleService))],Re);const Dt={dvDateDropdown:"univer-dv-date-dropdown",dvDateDropdownBtns:"univer-dv-date-dropdown-btns"},Qt=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return r.dayjs(r.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=r.dayjs(e);if(t.isValid())return t};function en(e){var m;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:i,unitId:s,subUnitId:l,workbook:d}=t,h=f.useDependency(r.ICommandService),p=f.useDependency(Re),v=n.getCell(o,i),c=E.getCellValueOrigin(n.getCellRaw(o,i)),_=Qt(c),[g,D]=M.useState(_),V=g&&g.isValid()?g:r.dayjs(),S=f.useDependency(r.LocaleService),w=f.useDependency(E.SheetDataValidationModel),y=w.getRuleByLocation(s,l,o,i);if(!y)return null;const L=w.getValidator(y.type);if(!v||!L)return;const I=!!((m=y.bizInfo)!=null&&m.showTime),C=async()=>{var U,B,H;if(!V)return;const F=V.format(I?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),$=(U=r.numfmt.parseDate(F))==null?void 0:U.v,k=d.getStyles().getStyleByCell(v),R=(H=(B=k==null?void 0:k.n)==null?void 0:B.pattern)!=null?H:"",N=Gt.getPatternType(R);y.errorStyle!==r.DataValidationErrorStyle.STOP||await L.validator({value:$,unitId:s,subUnitId:l,row:o,column:i,worksheet:n,workbook:d,interceptValue:F.replace("Z","").replace("T"," "),t:r.CellValueType.NUMBER},y)?(a(),await h.executeCommand(W.SetCellEditVisibleOperation.id,{visible:!1,eventType:j.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),await h.executeCommand(X.SetRangeValuesCommand.id,{unitId:s,subUnitId:l,range:{startColumn:i,endColumn:i,startRow:o,endRow:o},value:{v:$,t:2,p:null,f:null,si:null,s:{n:{pattern:I?N==="datetime"?R:"yyyy-MM-dd hh:mm:ss":N==="date"?R:"yyyy-MM-dd"}}}})):p.showReject(L.getRuleFinalError(y,{row:o,col:i,unitId:s,subUnitId:l}))};return u.jsxs("div",{className:Dt.dvDateDropdown,children:[u.jsx(T.DatePanel,{defaultValue:V,pickerValue:V,showTime:I||void 0,onSelect:async O=>{D(O)},onPanelChange:O=>{D(O)},disabledDate:O=>!r.numfmt.parseDate(O.format("YYYY-MM-DD"))}),u.jsx("div",{className:Dt.dvDateDropdownBtns,children:u.jsx(T.Button,{size:"small",type:"primary",onClick:C,disabled:!V.isValid(),children:S.t("dataValidation.alert.ok")})})]})}var se=function(){return se=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},se.apply(this,arguments)},tn=function(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(a[n[o]]=e[n[o]]);return a},ge=M.forwardRef(function(e,t){var a=e.icon,n=e.id,o=e.className,i=e.extend,s=tn(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),d=M.useRef("_".concat(on()));return yt(a,"".concat(n),{defIds:a.defIds,idSuffix:d.current},se({ref:t,className:l},s),i)});function yt(e,t,a,n,o){return M.createElement(e.tag,se(se({key:t},nn(e,a,o)),n),(an(e,a).children||[]).map(function(i,s){return yt(i,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,o)}))}function nn(e,t,a){var n=se({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],l=i[1];s==="mask"&&typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var o=t.defIds;return!o||o.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],l=i[1];typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function an(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?se(se({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?se(se({},o),{attrs:se(se({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):e}function on(){return Math.random().toString(36).substring(2,8)}ge.displayName="UniverIcon";var rn={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=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"check-mark-single",ref:t,icon:rn}))});wt.displayName="CheckMarkSingle";var sn={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=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"data-validation-single",ref:t,icon:sn}))});Vt.displayName="DataValidationSingle";var ln={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=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"delete-single",ref:t,icon:ln}))});nt.displayName="DeleteSingle";var dn={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=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"increase-single",ref:t,icon:dn}))});Et.displayName="IncreaseSingle";var cn={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=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"more-down-single",ref:t,icon:cn}))});Mt.displayName="MoreDownSingle";var un={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=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"more-up-single",ref:t,icon:un}))});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=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"sequence-single",ref:t,icon:hn}))});Lt.displayName="SequenceSingle";var pn=Object.getOwnPropertyDescriptor,vn=(e,t,a,n)=>{for(var o=n>1?void 0:n?pn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Tt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends r.Disposable{constructor(t,a){super();P(this,"_open$",new re.BehaviorSubject(!1));P(this,"open$",this._open$.pipe(re.distinctUntilChanged()));P(this,"_activeRule");P(this,"_activeRule$",new re.BehaviorSubject(void 0));P(this,"activeRule$",this._activeRule$.asObservable());P(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).pipe(re.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===ke&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=r.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ue=vn([Tt(0,r.IUniverInstanceService),Tt(1,f.ISidebarService)],ue);function gn(){const e=f.useDependency(me),t=f.useObservable(e.activeDropdown$,e.activeDropdown),a=f.useDependency(f.ComponentManager);if(!t)return null;const{location:n,componentKey:o}=t,i=a.get(o),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!i)return null;const l=()=>{e.hideDropdown()};return u.jsx(i,{location:n,hideFn:l},s)}const Ot="sheet.ui.dropdown";var mn=Object.getOwnPropertyDescriptor,fn=(e,t,a,n)=>{for(var o=n>1?void 0:n?mn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Se=(e,t)=>(a,n)=>t(a,n,e);let me=class extends r.Disposable{constructor(t,a,n,o,i,s,l){super();P(this,"_activeDropdown");P(this,"_activeDropdown$",new re.Subject);P(this,"_currentPopup",null);P(this,"activeDropdown$",this._activeDropdown$.asObservable());P(this,"_zenVisible",!1);this._canvasPopupManagerService=t,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=o,this._renderManagerService=i,this._dataValidationModel=s,this._sheetsSelectionsService=l,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,a,n,o){const i=t?this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=a?i.getSheetBySheetId(a):i.getActiveSheet();if(!s)return;const l=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,o);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);return d==null?void 0:d.dropdown}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t,a=!0){const{location:n}=t,{row:o,col:i,unitId:s,subUnitId:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const d=this._renderManagerService.getRenderById(r.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),h=this._canvasPopupManagerService.attachPopupToCell(o,i,{componentKey:Ot,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[d==null?void 0:d.engine.getCanvasElement()].filter(Boolean)},s,l);if(!h)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const p=new r.DisposableCollection;p.add(h),p.add({dispose:()=>{var v,c;(c=(v=this._activeDropdown)==null?void 0:v.onHide)==null||c.call(v)}}),this._currentPopup=p}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,a,n,o,i){const s=this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET);if(!s)return;const l=s.getSheetBySheetId(a);if(!l)return;const d=this._dataValidationModel.getRuleByLocation(s.getUnitId(),l.getSheetId(),n,o);if(!d)return;const h=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!h||!h.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:l,row:n,col:o,unitId:t,subUnitId:a},componentKey:h.dropdown,onHide:i})}};me=fn([Se(0,r.Inject(W.SheetCanvasPopManagerService)),Se(1,r.IUniverInstanceService),Se(2,r.Inject(J.DataValidatorRegistryService)),Se(3,f.IZenZoneService),Se(4,j.IRenderManagerService),Se(5,r.Inject(E.SheetDataValidationModel)),Se(6,r.Inject(X.SheetsSelectionsService))],me);const ke="DataValidationPanel",_e={id:"data-validation.operation.open-validation-panel",type:r.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,o=e.get(ue),i=e.get(J.DataValidationModel),s=e.get(r.IUniverInstanceService),l=e.get(f.ISidebarService),d=X.getSheetCommandTarget(s);if(!d)return!1;const{unitId:h,subUnitId:p}=d,v=a?i.getRuleById(h,p,a):void 0;o.open(),o.setActiveRule(v&&{unitId:h,subUnitId:p,rule:v});const c=l.open({id:ke,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:ke},width:312,onClose:()=>o.close()});return o.setCloseDisposable(c),!0}},at={id:"data-validation.operation.close-validation-panel",type:r.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},Pt={id:"data-validation.operation.toggle-validation-panel",type:r.CommandType.OPERATION,handler(e){const t=e.get(r.ICommandService),a=e.get(ue);return a.open(),a.isOpen?t.executeCommand(at.id):t.executeCommand(_e.id),!0}},Ne={type:r.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(me),{unitId:n,subUnitId:o,row:i,column:s}=t,l=a.activeDropdown,d=l==null?void 0:l.location;return d&&d.unitId===n&&d.subUnitId===o&&d.row===i&&d.col===s||a.showDataValidationDropdown(n,o,i,s),!0}},Rt={type:r.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(me).hideDropdown(),!0):!1}},Ie="#ECECEC",ot="sheets-data-validation-ui.config",Ue={},ve={dvListDropdown:"univer-dv-list-dropdown",dvListDropdownTitle:"univer-dv-list-dropdown-title",dvListDropdownList:"univer-dv-list-dropdown-list",dvListDropdownListContainer:"univer-dv-list-dropdown-list-container",dvListDropdownSelectedIcon:"univer-dv-list-dropdown-selected-icon",dvListDropdownItemContainer:"univer-dv-list-dropdown-item-container",dvListDropdownItem:"univer-dv-list-dropdown-item",dvListDropdownSplit:"univer-dv-list-dropdown-split",dvListDropdownEdit:"univer-dv-list-dropdown-edit"},Sn=e=>{var I,C;const{value:t,onChange:a,multiple:n,options:o,title:i,onEdit:s,style:l,filter:d,location:h}=e,p=f.useDependency(r.LocaleService),v=f.useDependency(r.IConfigService),c=d==null?void 0:d.toLowerCase(),{row:_,col:g,unitId:D,subUnitId:V}=h,S=o.filter(m=>c?m.label.toLowerCase().includes(c):!0),w=(C=(I=v.getConfig(ot))==null?void 0:I.showEditOnDropdown)!=null?C:!0,y=f.useDependency(X.SheetPermissionCheckController),L=M.useMemo(()=>y.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission]},[{startColumn:g,startRow:_,endColumn:g,endRow:_}],D,V),[y,g,_,D,V]);return u.jsxs("div",{className:ve.dvListDropdown,style:l,children:[u.jsx("div",{className:ve.dvListDropdownTitle,children:i}),u.jsx("div",{className:ve.dvListDropdownList,children:u.jsx(T.Scrollbar,{children:u.jsx("div",{className:ve.dvListDropdownListContainer,children:S.map((m,O)=>{const F=t.indexOf(m.value)>-1,$=()=>{let R;F?R=new Set(t.filter(U=>U!==m.value)):R=new Set(n?[...t,m.value]:[m.value]);const N=[];o.forEach(U=>{R.has(U.value)&&N.push(U.value)}),a(N)},k=m.label.toLocaleLowerCase().indexOf(c);return u.jsxs("div",{className:ve.dvListDropdownItemContainer,onClick:$,children:[u.jsx("div",{className:ve.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,k)}),u.jsx("span",{style:{fontWeight:"bold"},children:m.label.substring(k,k+c.length)}),u.jsx("span",{children:m.label.substring(k+c.length)})]}):m.label}),u.jsx("div",{className:ve.dvListDropdownSelectedIcon,children:F?u.jsx(wt,{}):null})]},O)})})},d)}),w&&L?u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ve.dvListDropdownSplit}),u.jsx("div",{className:ve.dvListDropdownEdit,children:u.jsx("a",{onClick:s,children:p.t("dataValidation.list.edit")})})]}):null]})};function _n(e){var B,H,q,Z;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:i,unitId:s,subUnitId:l}=t,d=f.useDependency(J.DataValidationModel),[h,p]=M.useState(""),v=f.useDependency(r.ICommandService),c=f.useDependency(r.LocaleService),[_,g]=M.useState(""),D=f.useDependency(W.IEditorBridgeService),V=f.useDependency(r.IUniverInstanceService),S=M.useMemo(()=>d.ruleChange$.pipe(re.debounceTime(16)),[]),w=f.useDependency(E.SheetDataValidationModel);f.useObservable(S);const y=f.RectPopup.useContext(),L=((H=(B=y.current)==null?void 0:B.right)!=null?H:0)-((Z=(q=y.current)==null?void 0:q.left)!=null?Z:0);if(M.useEffect(()=>{const G=v.onCommandExecuted(ee=>{var te,ae;if(ee.id===qt.RichTextEditingMutation.id){const oe=ee.params,{unitId:le}=oe,ie=V.getUnit(le,r.UniverInstanceType.UNIVER_DOC);if(!ie||!D.isVisible().visible)return;const de=r.BuildTextUtils.transform.getPlainText((ae=(te=ie.getSnapshot().body)==null?void 0:te.dataStream)!=null?ae:"");p(de)}});return()=>{G.dispose()}},[v,D,V]),!n)return null;const I=w.getRuleByLocation(s,l,o,i);if(!I)return null;const C=w.getValidator(I.type);if(!C)return null;const m=n.getCell(o,i),O=(I==null?void 0:I.renderMode)===r.DataValidationRenderMode.CUSTOM||(I==null?void 0:I.renderMode)===void 0;if(!m||!I||!C||C.id.indexOf(r.DataValidationType.LIST)!==0)return;const F=I.type===r.DataValidationType.LIST_MULTIPLE,$=C.getListWithColor(I,s,l),k=_||E.getDataValidationCellValue(n.getCellRaw(o,i)),R=E.deserializeListOptions(k),N=()=>{v.executeCommand(_e.id,{ruleId:I.uid}),a()},U=$.map(G=>({label:G.label,value:G.label,color:O||G.color?G.color:"transparent"}));return u.jsx(Sn,{style:{minWidth:L,maxWidth:Math.max(L,200)},title:F?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:R,multiple:F,onChange:async G=>{const ee=E.serializeListOptions(G),te={unitId:s,subUnitId:l,range:{startColumn:i,endColumn:i,startRow:o,endRow:o},value:{v:ee,p:null,f:null,si:null}};D.isVisible()&&v.executeCommand(W.SetCellEditVisibleOperation.id,{visible:!1,eventType:j.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),g(ee),F||a(),D.isVisible().visible&&await v.executeCommand(W.SetCellEditVisibleOperation.id,{visible:!1,eventType:j.DeviceInputEventType.Keyboard,unitId:s,keycode:f.KeyCode.ESC}),v.executeCommand(X.SetRangeValuesCommand.id,te)},options:U,onEdit:N,filter:h,location:t})}const it={dataValidationOptionsButton:"univer-data-validation-options-button",dataValidationOptionsButtonIcon:"univer-data-validation-options-button-icon"};function In(e){var h;const t=f.useDependency(r.LocaleService),a=f.useDependency(f.ComponentManager),{value:n,onChange:o,extraComponent:i}=e,[s,l]=M.useState(!1),d=i?a.get(i):null;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:it.dataValidationOptionsButton,onClick:()=>l(!s),children:[t.t("dataValidation.panel.options"),s?u.jsx(bt,{className:it.dataValidationOptionsButtonIcon}):u.jsx(Mt,{className:it.dataValidationOptionsButtonIcon})]}),s&&u.jsxs(u.Fragment,{children:[d?u.jsx(d,{value:n,onChange:o}):null,u.jsx(T.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:u.jsxs(T.RadioGroup,{value:`${(h=n.errorStyle)!=null?h:r.DataValidationErrorStyle.WARNING}`,onChange:p=>o({...n,errorStyle:+p}),children:[u.jsx(T.Radio,{value:`${r.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),u.jsx(T.Radio,{value:`${r.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),u.jsx(T.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:u.jsx(T.Checkbox,{checked:n.showErrorMessage,onChange:()=>o({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?u.jsx(T.FormLayout,{children:u.jsx(T.Input,{value:n.error,onChange:p=>o({...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"},Cn=e=>r.debounce(async(t,a,n,o)=>{const i=await e.executeCommand(t,a,n);o==null||o(i)},1e3);function Dn(e,t,a){var n,o,i,s;return t?((o=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:o.getSheetId())||"":((s=(i=e.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function yn(){var de;const[e,t]=M.useState(0),a=f.useDependency(ue),n=f.useObservable(a.activeRule$,a.activeRule),{unitId:o,subUnitId:i,rule:s}=n||{},l=s.uid,d=f.useDependency(J.DataValidatorRegistryService),h=f.useDependency(r.IUniverInstanceService),p=f.useDependency(f.ComponentManager),v=f.useDependency(r.ICommandService),c=f.useDependency(J.DataValidationModel),_=f.useDependency(r.LocaleService),[g,D]=M.useState(s),V=d.getValidatorItem(g.type),[S,w]=M.useState(!1),y=d.getValidatorsByScope(J.DataValidatorRegistryScope.SHEET),[L,I]=M.useState(()=>g.ranges.map(A=>({unitId:"",sheetId:"",range:A}))),C=M.useMemo(()=>Cn(v),[v]),[m,O]=M.useState(!1),F=M.useRef({}),[$,k]=M.useState(!1),R=f.useDependency(X.SheetsSelectionsService);if(M.useEffect(()=>()=>{const A=R.getCurrentLastSelection();A&&R.setSelections([A])},[R]),M.useEffect(()=>{v.onCommandExecuted(A=>{(A.id===r.UndoCommand.id||A.id===r.RedoCommand.id)&&setTimeout(()=>{const b=c.getRuleById(o,i,l);t(Y=>Y+1),b&&(D(b),I(b.ranges.map(Y=>({unitId:"",sheetId:"",range:Y}))))},20)})},[v,c,l,i,o]),!V)return null;const N=V.operators,U=V.operatorNames,B=g.operator?J.TWO_FORMULA_OPERATOR_COUNT.includes(g.operator):!1,H=()=>{!g.ranges.length||m||(V.validatorFormula(g,o,i).success?a.setActiveRule(null):w(!0))},q=f.useEvent(A=>{const b=A.split(",").filter(Boolean).map(et.deserializeRangeWithSheet).map(K=>{const fe=K.sheetName;if(fe){const Pa=Dn(h,K.unitId,fe);return{...K,sheetId:Pa}}return{...K,sheetId:""}});if(r.isUnitRangesEqual(b,L))return;I(b);const Y=b.filter(K=>(!K.unitId||K.unitId===o)&&(!K.sheetId||K.sheetId===i)).map(K=>K.range);if(D({...g,ranges:Y}),Y.length===0)return;const z={unitId:o,subUnitId:i,ruleId:l,ranges:Y};C(E.UpdateSheetDataValidationRangeCommand.id,z)}),Z=A=>{if(r.shallowEqual(A,J.getRuleSetting(g)))return;D({...g,...A});const b={unitId:o,subUnitId:i,ruleId:l,setting:A};C(E.UpdateSheetDataValidationSettingCommand.id,b,void 0)},G=async()=>{await v.executeCommand(E.RemoveSheetDataValidationCommand.id,{ruleId:l,unitId:o,subUnitId:i}),a.setActiveRule(null)},ee={type:g.type,operator:g.operator,formula1:g.formula1,formula2:g.formula2,allowBlank:g.allowBlank},te=A=>{const b=d.getValidatorItem(A);if(!b)return;const Y=b.operators,z=c.getRuleById(o,i,l),K=A===(z==null?void 0:z.type)||A.includes("list")&&(z!=null&&z.type.includes("list"))?{...z,type:A}:{...g,type:A,operator:Y[0],formula1:void 0,formula2:void 0};D(K),v.executeCommand(E.UpdateSheetDataValidationSettingCommand.id,{unitId:o,subUnitId:i,ruleId:g.uid,setting:J.getRuleSetting(K)})},ae=p.get(V.formulaInput),oe=M.useMemo(()=>L.map(A=>et.serializeRange(A.range)).join(","),[]),le=J.getRuleOptions(g),ie=A=>{r.shallowEqual(A,J.getRuleOptions(g))||(D({...g,...A}),C(E.UpdateSheetDataValidationOptionsCommand.id,{unitId:o,subUnitId:i,ruleId:l,options:A}))};return f.useSidebarClick(A=>{var Y;const b=(Y=F.current)==null?void 0:Y.handleOutClick;b&&b(A,()=>k(!1))}),u.jsxs("div",{className:we.dataValidationDetail,children:[u.jsx(T.FormLayout,{label:_.t("dataValidation.panel.range"),error:!g.ranges.length||m?_.t("dataValidation.panel.rangeError"):"",children:u.jsx(tt.RangeSelector,{unitId:o,subUnitId:i,initValue:oe,onChange:q,onFocus:()=>k(!0),isFocus:$,actions:F.current,onVerify:A=>O(!A)})}),u.jsx(T.FormLayout,{label:_.t("dataValidation.panel.type"),children:u.jsx(T.Select,{options:y==null?void 0:y.map(A=>({label:_.t(A.title),value:A.id})),value:g.type,onChange:te,className:we.dataValidationDetailFormItem})}),N!=null&&N.length?u.jsx(T.FormLayout,{label:_.t("dataValidation.panel.operator"),children:u.jsx(T.Select,{options:N.map((A,b)=>({value:`${A}`,label:U[b]})),value:`${g.operator}`,onChange:A=>{Z({...ee,operator:A})},className:we.dataValidationDetailFormItem})}):null,ae?u.jsx(ae,{isTwoFormula:B,value:{formula1:g.formula1,formula2:g.formula2},onChange:A=>{Z({...ee,...A})},showError:S,validResult:V.validatorFormula(g,o,i),unitId:o,subUnitId:i,ruleId:l},e+g.type):null,u.jsx(T.FormLayout,{children:u.jsx(T.Checkbox,{checked:(de=g.allowBlank)!=null?de:!0,onChange:()=>{var A;return Z({...ee,allowBlank:!((A=g.allowBlank)==null||A)})},children:_.t("dataValidation.panel.allowBlank")})}),u.jsx(In,{value:le,onChange:ie,extraComponent:V.optionsInput}),u.jsxs("div",{className:we.dataValidationDetailButtons,children:[u.jsx(T.Button,{className:we.dataValidationDetailButton,onClick:G,children:_.t("dataValidation.panel.removeRule")}),u.jsx(T.Button,{className:we.dataValidationDetailButton,type:"primary",onClick:H,children:_.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"},wn=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:o,disable:i}=e,s=f.useDependency(J.DataValidatorRegistryService),l=f.useDependency(r.ICommandService),d=f.useDependency(W.IMarkSelectionService),h=s.getValidatorItem(t.type),p=M.useRef(void 0),[v,c]=M.useState(!1),_=g=>{l.executeCommand(E.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:o}),g.stopPropagation()};return M.useEffect(()=>()=>{var g;p.current&&((g=p.current)==null||g.forEach(D=>{D&&d.removeShape(D)}))},[d]),u.jsxs("div",{className:Be.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{i||(c(!0),p.current=t.ranges.map(g=>d.addShape({range:g,style:{fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:null})))},onMouseLeave:()=>{var g;c(!1),(g=p.current)==null||g.forEach(D=>{D&&d.removeShape(D)}),p.current=void 0},children:[u.jsx("div",{className:Be.dataValidationItemTitle,children:h==null?void 0:h.generateRuleName(t)}),u.jsx("div",{className:Be.dataValidationItemContent,children:t.ranges.map(g=>et.serializeRange(g)).join(",")}),v?u.jsx("div",{className:Be.dataValidationItemIcon,onClick:_,children:u.jsx(nt,{})}):null]})},je={dataValidationList:"univer-data-validation-list",dataValidationListButtons:"univer-data-validation-list-buttons",dataValidationListButton:"univer-data-validation-list-button"};function Vn(){const e=f.useDependency(r.IUniverInstanceService),t=f.useObservable(()=>e.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return t?u.jsx(En,{workbook:t}):null}function En(e){const t=f.useDependency(E.SheetDataValidationModel),a=f.useDependency(r.IUniverInstanceService),n=f.useDependency(r.ICommandService),o=f.useDependency(r.Injector),i=f.useDependency(ue),s=f.useDependency(r.LocaleService),[l,d]=M.useState([]),{workbook:h}=e,p=f.useObservable(h.activeSheet$,void 0,!0),v=h.getUnitId(),c=p==null?void 0:p.getSheetId();M.useEffect(()=>{d(t.getRules(v,c));const w=t.ruleChange$.subscribe(y=>{y.unitId===v&&y.subUnitId===c&&d(t.getRules(v,c))});return()=>{w.unsubscribe()}},[v,c,t]);const _=async()=>{const w=E.createDefaultNewRule(o),y={unitId:v,subUnitId:c,rule:w};await n.executeCommand(E.AddSheetDataValidationCommand.id,y),i.setActiveRule({unitId:v,subUnitId:c,rule:w})},g=()=>{n.executeCommand(E.RemoveSheetAllDataValidationCommand.id,{unitId:v,subUnitId:c})},V=(w=>{const y=a.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET),L=y.getActiveSheet(),I=y.getUnitId(),C=L.getSheetId();return w.map(O=>X.checkRangesEditablePermission(o,I,C,O.ranges)?{...O}:{...O,disable:!0})})(l),S=V==null?void 0:V.some(w=>w.disable);return u.jsxs("div",{className:je.dataValidationList,children:[V==null?void 0:V.map(w=>{var y;return u.jsx(wn,{unitId:v,subUnitId:c,onClick:()=>{w.disable||i.setActiveRule({unitId:v,subUnitId:c,rule:w})},rule:w,disable:(y=w.disable)!=null?y:!1},w.uid)}),u.jsxs("div",{className:je.dataValidationListButtons,children:[l.length&&!S?u.jsx(T.Button,{className:je.dataValidationListButton,onClick:g,children:s.t("dataValidation.panel.removeAll")}):null,u.jsx(T.Button,{className:je.dataValidationListButton,type:"primary",onClick:_,children:s.t("dataValidation.panel.add")})]})]})}const Mn=()=>{const e=f.useDependency(ue),t=f.useObservable(e.activeRule$,e.activeRule);return t?u.jsx(yn,{},t.rule.uid):u.jsx(Vn,{})},We="data-validation.list.dropdown",rt="data-validation.date.dropdown",$e={type:r.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(r.IUniverInstanceService),a=X.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:o}=a,i=E.createDefaultNewRule(e),s=e.get(r.ICommandService),l=n.getUnitId(),d=o.getSheetId(),h={rule:i,unitId:l,subUnitId:d};return s.syncExecuteCommand(E.AddSheetDataValidationCommand.id,h)?(s.syncExecuteCommand(_e.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var bn=Object.getOwnPropertyDescriptor,Ln=(e,t,a,n)=>{for(var o=n>1?void 0:n?bn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Ve=(e,t)=>(a,n)=>t(a,n,e);const Ce="SHEET_DATA_VALIDATION_ALERT";let Ae=class extends r.Disposable{constructor(e,t,a,n,o,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=o,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(re.debounceTime(100)).subscribe(e=>{var t;if(e){const a=this._univerInstanceService.getUnit(e.location.unitId,r.UniverInstanceType.UNIVER_SHEET),n=a.getSheetBySheetId(e.location.subUnitId);if(!n)return;const o=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!o){this._cellAlertManagerService.removeAlert(Ce);return}if(this._dataValidationModel.validator(o,{...e.location,workbook:a,worksheet:n})===r.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Ce),l=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(l&&l.row===e.location.row&&l.col===e.location.col&&l.subUnitId===e.location.subUnitId&&l.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(Ce);return}const d=this._dataValidationModel.getValidator(o.type);if(!d){this._cellAlertManagerService.removeAlert(Ce);return}this._cellAlertManagerService.showAlert({type:W.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:d==null?void 0:d.getRuleFinalError(o,e.location),location:e.location,width:200,height:74,key:Ce});return}}this._cellAlertManagerService.removeAlert(Ce)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(Ce)}))}};Ae=Ln([Ve(0,r.Inject(W.HoverManagerService)),Ve(1,r.Inject(W.CellAlertManagerService)),Ve(2,r.IUniverInstanceService),Ve(3,r.Inject(r.LocaleService)),Ve(4,f.IZenZoneService),Ve(5,r.Inject(E.SheetDataValidationModel))],Ae);var Tn=Object.getOwnPropertyDescriptor,On=(e,t,a,n)=>{for(var o=n>1?void 0:n?Tn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},st=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends r.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,o)=>{const{source:i,target:s,unitId:l,subUnitId:d}=n,h=this._sheetDataValidationModel.getRuleObjectMatrix(l,d).clone(),p=W.virtualizeDiscreteRanges([i,s]),[v,c]=p.ranges,{mapFunc:_}=p,g={row:v.startRow,col:v.startColumn},D=W.getAutoFillRepeatRange(v,c),V=new r.ObjectMatrix,S=new Set;D.forEach(C=>{const m=C.repeatStartCell,O=C.relativeRange,F={startRow:g.row,startColumn:g.col,endColumn:g.col,endRow:g.row},$={startRow:m.row,startColumn:m.col,endColumn:m.col,endRow:m.row};r.Range.foreach(O,(k,R)=>{const N=r.Rectangle.getPositionRange({startRow:k,startColumn:R,endColumn:R,endRow:k},F),{row:U,col:B}=_(N.startRow,N.startColumn),H=this._sheetDataValidationModel.getRuleIdByLocation(l,d,U,B)||"",q=r.Rectangle.getPositionRange({startRow:k,startColumn:R,endColumn:R,endRow:k},$),{row:Z,col:G}=_(q.startRow,q.startColumn);V.setValue(Z,G,H),S.add(H)})});const w=Array.from(S).map(C=>({id:C,ranges:r.queryObjectMatrix(V,m=>m===C)}));h.addRangeRules(w);const y=h.diff(this._sheetDataValidationModel.getRules(l,d)),{redoMutations:L,undoMutations:I}=E.getDataValidationDiffMutations(l,d,y,this._injector,"patched",o===W.APPLY_TYPE.ONLY_FORMAT);return{undos:I,redos:L}},a={id:E.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:o,unitId:i,subUnitId:s}=n;for(const l of o.rows)for(const d of o.cols){const h=this._sheetDataValidationModel.getRuleByLocation(i,s,l,d);if(h&&h.type===r.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(W.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,o,i)=>i===W.APPLY_TYPE.COPY||i===W.APPLY_TYPE.ONLY_FORMAT||i===W.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};Ee=On([st(0,W.IAutoFillService),st(1,r.Inject(E.SheetDataValidationModel)),st(2,r.Inject(r.Injector))],Ee);var Pn=Object.getOwnPropertyDescriptor,Rn=(e,t,a,n)=>{for(var o=n>1?void 0:n?Pn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},lt=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends r.Disposable{constructor(t,a,n){super();P(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:E.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,o)=>{const{copyType:i=W.COPY_TYPE.COPY,pasteType:s}=o,{range:l}=t||{},{range:d,unitId:h,subUnitId:p}=a;return this._generateMutations(d,{copyType:i,pasteType:s,copyRange:l,unitId:h,subUnitId:p})}})}_collect(t,a,n){const o=new r.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:o};const i=this._injector.invoke(d=>X.rangeToDiscreteRange(n,d,t,a));if(!i)return;const{rows:s,cols:l}=i;s.forEach((d,h)=>{l.forEach((p,v)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(t,a,d,p);o.setValue(h,v,c!=null?c:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===W.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:o,subUnitId:i}=this._copyInfo;if(a.unitId!==o||i!==a.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),l=new r.ObjectMatrix,d=new Set,{ranges:[h,p],mapFunc:v}=W.virtualizeDiscreteRanges([a.copyRange,t]),c=W.getRepeatRange(h,p,!0),_=new Map;c.forEach(({startRange:S})=>{var w;(w=this._copyInfo)==null||w.matrix.forValue((y,L,I)=>{const C=r.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:L,endColumn:L},S),m=`${i}-${I}`,O=this._sheetDataValidationModel.getRuleById(o,i,I);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,m)&&O&&_.set(m,{...O,uid:m});const{row:F,col:$}=v(C.startRow,C.startColumn);d.add(m),l.setValue(F,$,m)})});const g=Array.from(d).map(S=>({id:S,ranges:r.queryObjectMatrix(l,w=>w===S)}));s.addRangeRules(g);const{redoMutations:D,undoMutations:V}=E.getDataValidationDiffMutations(a.unitId,a.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),_.values()),this._injector,"patched",!1);return{redos:D,undos:V}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(o,i).clone(),l=new r.ObjectMatrix,d=new Set,{ranges:[h,p],mapFunc:v}=W.virtualizeDiscreteRanges([a.copyRange,t]);W.getRepeatRange(h,p,!0).forEach(({startRange:V})=>{var S;(S=this._copyInfo)==null||S.matrix.forValue((w,y,L)=>{const I=r.Rectangle.getPositionRange({startRow:w,endRow:w,startColumn:y,endColumn:y},V),{row:C,col:m}=v(I.startRow,I.startColumn);l.setValue(C,m,L),d.add(L)})});const _=Array.from(d).map(V=>({id:V,ranges:r.queryObjectMatrix(l,S=>S===V)}));s.addRangeRules(_);const{redoMutations:g,undoMutations:D}=E.getDataValidationDiffMutations(o,i,s.diff(this._sheetDataValidationModel.getRules(o,i)),this._injector,"patched",!1);return{redos:g,undos:D}}}};Me=Rn([lt(0,W.ISheetClipboardService),lt(1,r.Inject(E.SheetDataValidationModel)),lt(2,r.Inject(r.Injector))],Me);var An=Object.getOwnPropertyDescriptor,Fn=(e,t,a,n)=>{for(var o=n>1?void 0:n?An(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},dt=(e,t)=>(a,n)=>t(a,n,e);let be=class extends r.Disposable{constructor(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")))}))}};be=Fn([dt(0,r.Inject(r.LocaleService)),dt(1,r.ICommandService),dt(2,r.Inject(X.SheetPermissionCheckController))],be);const At="data-validation-single",Ft="sheet.menu.data-validation";function kn(e){return{id:Ft,type:f.MenuItemType.SUBITEMS,icon:At,tooltip:"dataValidation.title",hidden$:f.getMenuHiddenObservable(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:W.getCurrentRangeDisable$(e,{workbookTypes:[X.WorkbookEditablePermission],worksheetTypes:[X.WorksheetSetCellStylePermission,X.WorksheetEditPermission],rangeTypes:[X.RangeProtectionPermissionEditPoint]})}}function Nn(e){return{id:_e.id,title:"dataValidation.panel.title",type:f.MenuItemType.BUTTON}}function Un(e){return{id:$e.id,title:"dataValidation.panel.add",type:f.MenuItemType.BUTTON}}const Bn={[f.RibbonStartGroup.FORMULAS_INSERT]:{[Ft]:{order:9,menuItemFactory:kn,[_e.id]:{order:0,menuItemFactory:Nn},[$e.id]:{order:1,menuItemFactory:Un}}}};var jn=Object.getOwnPropertyDescriptor,kt=(e,t,a,n)=>{for(var o=n>1?void 0:n?jn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Q=(e,t)=>(a,n)=>t(a,n,e);const Nt={tr:{size:6,color:"#fe4b4b"}};let Le=class extends r.RxDisposable{constructor(e,t,a,n,o,i,s,l,d,h,p){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=o,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=l,this._sheetInterceptorService=d,this._dataValidationCacheService=h,this._editorBridgeService=p,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Bn)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var a;if(!e.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:o,row:i,column:s}=t,l=this._univerInstanceService.getUniverSheetInstance(n);if(!l)return;const d=this._sheetDataValidationModel.getRuleByLocation(n,o,i,s);if(!d)return;const h=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!(h!=null&&h.dropdown))return;const p=l.getActiveSheet();if(!p)return;const v=this._dropdownManagerService.activeDropdown,c=v==null?void 0:v.location;if(c&&c.unitId===n&&c.subUnitId===o&&c.row===i&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:o,row:i,col:s,workbook:l,worksheet:p},componentKey:h.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var S,w,y,L,I;const{row:n,col:o,unitId:i,subUnitId:s,workbook:l,worksheet:d}=t,h=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,o);if(!h)return a(e);const p=this._sheetDataValidationModel.getRuleById(i,s,h);if(!p)return a(e);const v=(S=this._dataValidationCacheService.getValue(i,s,n,o))!=null?S:r.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),_=t.rawData;let g;const D={get value(){var C;return g!==void 0||(g=(C=E.getCellValueOrigin(_))!=null?C:null),g}},V={get value(){var C;return`${(C=D.value)!=null?C:""}`}};return a({...e,markers:{...e==null?void 0:e.markers,...v===r.DataValidationStatus.INVALID?Nt: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)||((L=c==null?void 0:c.skipDefaultFontRender)==null?void 0:L.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=l.getStyles();return(typeof(e==null?void 0:e.s)=="string"?C.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,o)},interceptorAutoHeight:()=>{var F,$,k,R,N,U;const C=($=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(W.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:$.skeleton;if(!C)return;const m=C.worksheet.getMergedCell(n,o),O={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((k=m==null?void 0:m.startRow)!=null?k:n,(R=m==null?void 0:m.startColumn)!=null?R:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(U=(N=c==null?void 0:c.canvasRender)==null?void 0:N.calcCellAutoHeight)==null?void 0:U.call(N,O)},interceptorAutoWidth:()=>{var F,$,k,R,N,U;const C=($=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(W.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:$.skeleton;if(!C)return;const m=C.worksheet.getMergedCell(n,o),O={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((k=m==null?void 0:m.startRow)!=null?k:n,(R=m==null?void 0:m.startColumn)!=null?R:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(U=(N=c==null?void 0:c.canvasRender)==null?void 0:N.calcCellAutoWidth)==null?void 0:U.call(N,O)},coverable:((I=e==null?void 0:e.coverable)!=null?I:!0)&&!(p.type===r.DataValidationType.LIST||p.type===r.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===r.DataValidationType.LIST_MULTIPLE||a.rule.type===r.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(a.redos,this._commandService)}})}};Le=kt([Q(0,r.ICommandService),Q(1,f.IMenuManagerService),Q(2,j.IRenderManagerService),Q(3,r.IUniverInstanceService),Q(4,r.Inject(W.AutoHeightController)),Q(5,r.Inject(me)),Q(6,r.Inject(E.SheetDataValidationModel)),Q(7,r.Inject(J.DataValidatorRegistryService)),Q(8,r.Inject(X.SheetInterceptorService)),Q(9,r.Inject(E.DataValidationCacheService)),Q(10,r.Optional(W.IEditorBridgeService))],Le);let Ut=class extends r.RxDisposable{constructor(e,t,a,n,o,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=o,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var V,S,w,y,L;const{row:n,col:o,unitId:i,subUnitId:s,workbook:l,worksheet:d}=t,h=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,o);if(!h)return a(e);const p=this._sheetDataValidationModel.getRuleById(i,s,h);if(!p)return a(e);const v=(V=this._dataValidationCacheService.getValue(i,s,n,o))!=null?V:r.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),_=d.getCellRaw(n,o),g=E.getCellValueOrigin(_),D=`${g!=null?g:""}`;return a({...e,markers:{...e==null?void 0:e.markers,...v===r.DataValidationStatus.INVALID?Nt:null},customRender:[...(S=e==null?void 0:e.customRender)!=null?S:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((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,g,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,D,{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,o)},interceptorAutoHeight:()=>{var O,F,$,k,R,N;const I=(F=(O=this._renderManagerService.getRenderById(i))==null?void 0:O.with(W.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:F.skeleton;if(!I)return;const C=I.worksheet.getMergedCell(n,o),m={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex(($=C==null?void 0:C.startRow)!=null?$:n,(k=C==null?void 0:C.startColumn)!=null?k:o),unitId:i,subUnitId:s,row:n,col:o,workbook:l,worksheet:d};return(N=(R=c==null?void 0:c.canvasRender)==null?void 0:R.calcCellAutoHeight)==null?void 0:N.call(R,m)},coverable:((L=e==null?void 0:e.coverable)!=null?L:!0)&&!(p.type===r.DataValidationType.LIST||p.type===r.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);r.sequenceExecute(a.redos,this._commandService)}})}};Ut=kt([Q(0,r.ICommandService),Q(1,j.IRenderManagerService),Q(2,r.Inject(W.AutoHeightController)),Q(3,r.Inject(J.DataValidatorRegistryService)),Q(4,r.Inject(X.SheetInterceptorService)),Q(5,r.Inject(E.SheetDataValidationModel)),Q(6,r.Inject(E.DataValidationCacheService))],Ut);var Wn=Object.getOwnPropertyDescriptor,$n=(e,t,a,n)=>{for(var o=n>1?void 0:n?Wn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Bt=(e,t)=>(a,n)=>t(a,n,e);let He=class extends r.Disposable{constructor(e,t,a){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const a=new Set;t.forEach(o=>{a.add(o.subUnitId)}),a.forEach(o=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(o))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(r.bufferDebounceTime(16)).subscribe(e))}};He=$n([Bt(1,r.Inject(E.SheetDataValidationModel)),Bt(2,r.Inject(W.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"},Hn=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:o,validResult:i}=e,s=f.useDependency(r.LocaleService),l=o?i==null?void 0:i.formula1:"",d=o?i==null?void 0:i.formula2:"";return t?u.jsxs(u.Fragment,{children:[u.jsx(T.FormLayout,{error:l,children:u.jsx(T.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:h=>{n==null||n({...a,formula1:h})}})}),u.jsx("div",{className:ne.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),u.jsx(T.FormLayout,{error:d,children:u.jsx(T.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:h=>{n==null||n({...a,formula2:h})}})})]}):u.jsx(T.FormLayout,{error:l,children:u.jsx(T.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:h=>{n==null||n({formula1:h})}})})};function Yn(e){const{value:t,onChange:a,showError:n,validResult:o}=e,i=f.useDependency(r.LocaleService),s=n?o==null?void 0:o.formula1:"",l=n?o==null?void 0:o.formula2:"",[d,h]=M.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(T.FormLayout,{children:u.jsx(T.Checkbox,{checked:d,onChange:p=>{p?h(!0):(h(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),d?u.jsx(T.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:u.jsx(T.Input,{className:ne.dataValidationFormula,placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:p=>{a==null||a({...t,formula1:p||void 0})}})}):null,d?u.jsx(T.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:l,children:u.jsx(T.Input,{className:ne.dataValidationFormula,placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:p=>{a==null||a({...t,formula2:p||void 0})}})}):null]})}function xn(e){var v;const{unitId:t,subUnitId:a,value:n,onChange:o,showError:i,validResult:s}=e,l=i?s==null?void 0:s.formula1:void 0,d=M.useRef({}),[h,p]=M.useState(!1);return f.useSidebarClick(c=>{var g;const _=(g=d.current)==null?void 0:g.handleOutClick;_&&_(c,()=>p(!1))}),u.jsx(tt.FormulaEditor,{initValue:(v=n==null?void 0:n.formula1)!=null?v:"=",unitId:t,subUnitId:a,isFocus:h,onChange:c=>{const _=(c!=null?c:"").trim();_!==(n==null?void 0:n.formula1)&&(o==null||o({...n,formula1:_}))},errorText:l,onFocus:()=>p(!0),actions:d.current,isSupportAcrossSheet:!0})}function jt(e){var t,a,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(a=jt(e[t]))&&(n&&(n+=" "),n+=a)}else for(a in e)e[a]&&(n&&(n+=" "),n+=a);return n}function Xn(){for(var e,t,a=0,n="",o=arguments.length;a<o;a++)(e=arguments[a])&&(t=jt(e))&&(n&&(n+=" "),n+=t);return n}const zn=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Kn=e=>{const{value:t,onChange:a,disabled:n}=e,[o,i]=M.useState(!1);return u.jsx(T.Select,{disabled:n,open:o,onDropdownVisibleChange:i,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ne.dataValidationFormulaColorSelect,value:t,onChange:a,labelRender:s=>u.jsx("div",{className:ne.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>u.jsx("div",{className:ne.dataValidationFormulaColorSelectPanel,children:zn.map(s=>u.jsx("div",{onClick:()=>{a(s),i(!1)},className:ne.dataValidationFormulaColorItem,style:{background:s}},s))})})},Wt=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:o,onItemDelete:i}=a;return u.jsxs("div",{className:ne.dataValidationFormulaListItem,style:n,children:[t.isRef?null:u.jsx("div",{className:Xn(ne.dataValidationFormulaListItemDrag,"draggableHandle"),children:u.jsx(Lt,{})}),u.jsx(Kn,{value:t.color,onChange:s=>{o(t.id,t.label,s)}}),u.jsx(T.Input,{disabled:t.isRef,value:t.label,onChange:s=>{o(t.id,s,t.color)}}),t.isRef?null:u.jsx("div",{className:ne.dataValidationFormulaListItemIcon,children:u.jsx(nt,{onClick:()=>i(t.id)})})]})};function Gn(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:o,validResult:i,showError:s,ruleId:l}=e,{formula1:d="",formula2:h=""}=t||{},p=M.useRef(null),[v,c]=M.useState(()=>r.isFormulaString(d)?"1":"0"),[_,g]=M.useState(v==="1"?d:"="),[D,V]=M.useState(v==="1"?d:"="),S=f.useDependency(r.LocaleService),w=f.useDependency(J.DataValidatorRegistryService),y=f.useDependency(J.DataValidationModel),L=f.useDependency(E.DataValidationFormulaController),[I,C]=M.useState(()=>h.split(",")),m=w.getValidatorItem(r.DataValidationType.LIST),[O,F]=M.useState([]),[$,k]=M.useState(""),R=s?i==null?void 0:i.formula1:"",N=M.useMemo(()=>y.ruleChange$.pipe(re.debounceTime(16)),[]),U=f.useObservable(N),B=f.useEvent(a);M.useEffect(()=>{(async()=>{await new Promise(z=>{setTimeout(()=>z(!0),100)});const b=y.getRuleById(n,o,l),Y=b==null?void 0:b.formula1;if(r.isFormulaString(Y)&&m&&b){const z=await m.getListAsync(b,n,o);F(z)}})()},[y,U,m,l,o,n]),M.useEffect(()=>{r.isFormulaString(d)&&d!==D&&(g(d),V(D))},[D,d]);const[H,q]=M.useState(()=>{const b=v!=="1"?E.deserializeListOptions(d):[],Y=h.split(",");return b.map((z,K)=>({label:z,color:Y[K]||Ie,isRef:!1,id:r.Tools.generateRandomId(4)}))}),Z=(b,Y,z)=>{const K=H.find(fe=>fe.id===b);K&&(K.label=Y,K.color=z,q([...H]))},G=b=>{const Y=H.findIndex(z=>z.id===b);Y!==-1&&(H.splice(Y,1),q([...H]))},ee=h.split(","),te=M.useMemo(()=>O.map((b,Y)=>({label:b,color:ee[Y]||Ie,id:`${Y}`,isRef:!0})),[ee,O]),ae=(b,Y,z)=>{const K=[...I];K[+b]=z,C(K),B({formula1:d,formula2:K.join(",")})},oe=()=>{q([...H,{label:"",color:Ie,isRef:!1,id:r.Tools.generateRandomId(4)}])};M.useEffect(()=>{if(v==="1")return;const b=new Set,Y=[];H.map(z=>({labelList:z.label.split(","),item:z})).forEach(({item:z,labelList:K})=>{K.forEach(fe=>{b.has(fe)||(b.add(fe),Y.push({label:fe,color:z.color}))})}),B({formula1:E.serializeListOptions(Y.map(z=>z.label)),formula2:Y.map(z=>z.color===Ie?"":z.color).join(",")})},[H,B,v,D,I]);const le=f.useEvent(async b=>{if(!r.isFormulaString(b)){B==null||B({formula1:"",formula2:h});return}L.getFormulaRefCheck(b)?(B==null||B({formula1:r.isFormulaString(b)?b:"",formula2:h}),k("")):(B==null||B({formula1:"",formula2:h}),g("="),k(S.t("dataValidation.validFail.formulaError")))}),ie=M.useRef({}),[de,A]=M.useState(!1);return f.useSidebarClick(b=>{var z;const Y=(z=ie.current)==null?void 0:z.handleOutClick;Y&&Y(b,()=>A(!1))}),u.jsxs(u.Fragment,{children:[u.jsx(T.FormLayout,{label:S.t("dataValidation.list.options"),children:u.jsxs(T.RadioGroup,{value:v,onChange:b=>{c(b),g(D),b==="1"&&B({formula1:D==="="?"":D,formula2:I.join(",")})},children:[u.jsx(T.Radio,{value:"0",children:S.t("dataValidation.list.customOptions")}),u.jsx(T.Radio,{value:"1",children:S.t("dataValidation.list.refOptions")})]})}),v==="1"?u.jsxs(u.Fragment,{children:[u.jsx(tt.FormulaEditor,{initValue:_,unitId:n,subUnitId:o,isFocus:de,onChange:(b="")=>{const Y=(b!=null?b:"").trim();V(Y),le(Y)},errorText:R||$||void 0,onFocus:()=>A(!0),actions:ie.current,isSupportAcrossSheet:!0}),u.jsx("div",{ref:p,style:{marginTop:"12px"},children:te.map(b=>u.jsx(Wt,{item:b,commonProps:{onItemChange:ae},style:{marginBottom:12}},b.id))})]}):u.jsx(T.FormLayout,{error:R,children:u.jsxs("div",{ref:p,style:{marginTop:"-12px"},children:[u.jsx(T.DraggableList,{list:H,onListChange:q,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:b=>u.jsx(Wt,{item:b,commonProps:{onItemChange:Z,onItemDelete:G}},b.id),idKey:"id"}),u.jsxs("a",{className:ne.dataValidationFormulaListAdd,onClick:oe,children:[u.jsx(Et,{}),S.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",qn=[[$t,xn],[Ye,Hn],[ct,Gn],[Ht,Yn]],Zn="LIST_RENDER_MODE_OPTION_INPUT";function xe(e){var o;const{value:t,onChange:a}=e,n=f.useDependency(r.LocaleService);return u.jsx(T.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:u.jsxs(T.RadioGroup,{value:`${(o=t.renderMode)!=null?o:r.DataValidationRenderMode.CUSTOM}`,onChange:i=>a({...t,renderMode:+i}),children:[u.jsx(T.Radio,{value:`${r.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),u.jsx(T.Radio,{value:`${r.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),u.jsx(T.Radio,{value:`${r.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}xe.componentKey=Zn;const Jn="DATE_SHOW_TIME_OPTION";function Xe(e){var o;const{value:t,onChange:a}=e,n=f.useDependency(r.LocaleService);return u.jsx(T.FormLayout,{children:u.jsx(T.Checkbox,{checked:(o=t.bizInfo)==null?void 0:o.showTime,onChange:i=>{a({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:n.t("dataValidation.showTime.label")})})}Xe.componentKey=Jn;var Qn=Object.getOwnPropertyDescriptor,ea=(e,t,a,n)=>{for(var o=n>1?void 0:n?Qn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Fe=(e,t)=>(a,n)=>t(a,n,e);const ze=6;let ut=class{constructor(e,t,a,n,o){this._commandService=e,this._formulaService=t,this._themeService=a,this._renderManagerService=n,this._dataValidationModel=o}_calc(e,t){var h,p,v;const{vt:a,ht:n}=t||{},o=e.endX-e.startX-ze*2,i=e.endY-e.startY,s=((h=t==null?void 0:t.fs)!=null?h:10)*1.6;let l=0,d=0;switch(a){case r.VerticalAlign.TOP:d=0;break;case r.VerticalAlign.BOTTOM:d=0+(i-s);break;default:d=0+(i-s)/2;break}switch(n){case r.HorizontalAlign.LEFT:l=ze;break;case r.HorizontalAlign.RIGHT:l=ze+(o-s);break;default:l=ze+(o-s)/2;break}return{left:e.startX+l,top:e.startY+d,width:((p=t==null?void 0:t.fs)!=null?p:10)*1.6,height:((v=t==null?void 0:t.fs)!=null?v:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var h,p,v,c,_,g,D,V,S;const{formula1:n=E.CHECKBOX_FORMULA_1,formula2:o=E.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=E.getFormulaResult((v=(p=(h=i==null?void 0:i[0])==null?void 0:h.result)==null?void 0:p[0])==null?void 0:v[0]),l=E.getFormulaResult((g=(_=(c=i==null?void 0:i[1])==null?void 0:c.result)==null?void 0:_[0])==null?void 0:g[0]),d=E.isLegalFormulaResult(String(s))&&E.isLegalFormulaResult(String(l));return{formula1:r.isFormulaString(n)?E.getFormulaResult((S=(V=(D=i==null?void 0:i[0])==null?void 0:D.result)==null?void 0:V[0])==null?void 0:S[0]):n,formula2:r.isFormulaString(o)?l:o,isFormulaValid:d}}drawWith(e,t){var R,N,U,B;const{style:a,primaryWithCoord:n,unitId:o,subUnitId:i,worksheet:s,row:l,col:d}=t,h=n.isMergedMainCell?n.mergeInfo:n,p=E.getCellValueOrigin(s.getCellRaw(l,d)),v=this._dataValidationModel.getRuleByLocation(o,i,l,d);if(!v)return;const c=this._dataValidationModel.getValidator(v.type);if(!c)return;const _=this._themeService.getCurrentTheme();if(!((R=c.skipDefaultFontRender)!=null&&R.call(c,v,p,{unitId:o,subUnitId:i,row:l,column:d})))return;const g=c.parseFormulaSync(v,o,i),{formula1:D}=g,V=this._calc(h,a),{a:S,d:w}=e.getTransform(),y=j.fixLineWidthByScale(V.left,S),L=j.fixLineWidthByScale(V.top,w),I=j.Transform.create().composeMatrix({left:y,top:L,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),C=h.endX-h.startX,m=h.endY-h.startY;e.save(),e.beginPath(),e.rect(h.startX,h.startY,C,m),e.clip();const O=I.getMatrix();e.transform(O[0],O[1],O[2],O[3],O[4],O[5]);const F=((N=a==null?void 0:a.fs)!=null?N:10)*1.6,$=String(p)===String(D),k=_.hyacinth500;j.CheckboxShape.drawWith(e,{checked:$,width:F,height:F,fill:(B=(U=a==null?void 0:a.cl)==null?void 0:U.rgb)!=null?B:k}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),o=n.top,i=n.top+n.height,s=n.left,l=n.left+n.width,{x:d,y:h}=e;return d<=l&&d>=s&&h<=i&&h>=o}async onPointerDown(e,t){var g;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:o,worksheet:i,row:s,col:l}=e,d=E.getCellValueOrigin(i.getCellRaw(s,l)),h=this._dataValidationModel.getRuleByLocation(n,o,s,l);if(!h)return;const p=this._dataValidationModel.getValidator(h.type);if(!p||!((g=p.skipDefaultFontRender)!=null&&g.call(p,h,d,{unitId:n,subUnitId:o,row:s,column:l})))return;const{formula1:v,formula2:c}=await this._parseFormula(h,n,o),_={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(d)===E.transformCheckboxValue(String(v))?c:v,p:null}};this._commandService.executeCommand(X.SetRangeValuesCommand.id,_)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(j.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(j.CURSOR_TYPE.DEFAULT)}};ut=ea([Fe(0,r.ICommandService),Fe(1,r.Inject(E.DataValidationFormulaService)),Fe(2,r.Inject(r.ThemeService)),Fe(3,r.Inject(j.IRenderManagerService)),Fe(4,r.Inject(E.SheetDataValidationModel))],ut);var ta=Object.getOwnPropertyDescriptor,na=(e,t,a,n)=>{for(var o=n>1?void 0:n?ta(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},aa=(e,t)=>(a,n)=>t(a,n,e);let he=class{constructor(e){P(this,"canvasRender",null);P(this,"dropdown");P(this,"optionsInput");P(this,"formulaInput",ct);this.injector=e}};he=na([aa(0,r.Inject(r.Injector))],he);class oa extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.CHECKBOX);P(this,"canvasRender",this.injector.createInstance(ut));P(this,"formulaInput",Ht)}}class ia extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.CUSTOM);P(this,"formulaInput",$t)}}const ra="data-validation.formula-input";class sa extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.DATE);P(this,"formulaInput",ra);P(this,"optionsInput",Xe.componentKey);P(this,"dropdown",rt)}}class la extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.DECIMAL);P(this,"formulaInput",Ye)}}const Yt=4,da=0,ht=4,xt=4,pt=6,Ke=6,De=14;function ca(e,t){const a=j.FontCache.getTextSize(e,t),n=a.width+Yt*2,{ba:o,bd:i}=a,s=o+i;return{width:n,height:s+da*2,ba:o}}function vt(e,t,a,n){const o=De+pt*2,i=a-o,s=n-Ke*2,l=e.map(c=>({layout:ca(c,t),text:c}));let d;const h=[];l.forEach(c=>{const{layout:_}=c,{width:g,height:D}=_;!d||d.width+g+ht>i?(d={width:g,height:D,items:[{...c,left:0}]},h.push(d)):(d.items.push({...c,left:d.width+ht}),d.width=d.width+g+ht)});let p=0,v=0;return h.forEach((c,_)=>{v=Math.max(v,c.width),_===h.length-1?p+=c.height:p+=c.height+xt}),{lines:h,totalHeight:p,contentWidth:i,contentHeight:s,cellAutoHeight:p+Ke*2,calcAutoWidth:v+o}}const ua=8;class ha extends j.Shape{static drawWith(t,a){const{fontString:n,info:o,fill:i,color:s}=a,{layout:l,text:d}=o;t.save(),j.Rect.drawWith(t,{width:l.width,height:l.height,radius:ua,fill:i||Ie}),t.translateWithPrecision(Yt,l.ba),t.font=n,t.fillStyle=s,t.fillText(d,0,0),t.restore()}}var pa=Object.getOwnPropertyDescriptor,va=(e,t,a,n)=>{for(var o=n>1?void 0:n?pa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},gt=(e,t)=>(a,n)=>t(a,n,e);const ga=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){P(this,"zIndex");P(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,o){const i=a-De+4;let s=4;switch(o){case r.VerticalAlign.MIDDLE:s=(n-De)/2+4;break;case r.VerticalAlign.BOTTOM:s=n-De+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(ga),e.restore()}drawWith(e,t,a,n){var Z,G;const{primaryWithCoord:o,row:i,col:s,style:l,data:d,subUnitId:h}=t,p=o.isMergedMainCell?o.mergeInfo:o,v=d==null?void 0:d.fontRenderExtension,{leftOffset:c=0,rightOffset:_=0,topOffset:g=0,downOffset:D=0}=v||{},V=this._ensureMap(h),S=this._generateKey(i,s),w=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,s);if(!w)return;const y=this._dataValidationModel.getValidator(w.type);if(!y)return;const L={startX:p.startX+c,endX:p.endX-_,startY:p.startY+g,endY:p.endY-D},I=L.endX-L.startX,C=L.endY-L.startY,{cl:m}=l||{},O=(Z=typeof m=="object"?m==null?void 0:m.rgb:m)!=null?Z:"#000",F=j.getFontStyleString(l!=null?l:void 0),{vt:$,ht:k}=l||{},R=$!=null?$:r.VerticalAlign.MIDDLE,N=(G=E.getCellValueOrigin(d))!=null?G:"",U=y.parseCellValue(N),B=y.getListWithColorMap(w),H=vt(U,F,I,C);this._drawDownIcon(e,L,I,C,R),e.save(),e.translateWithPrecision(L.startX,L.startY),e.beginPath(),e.rect(0,0,I-De,C),e.clip(),e.translateWithPrecision(pt,Ke);let q=0;switch(R){case r.VerticalAlign.MIDDLE:q=(H.contentHeight-H.totalHeight)/2;break;case r.VerticalAlign.BOTTOM:q=H.contentHeight-H.totalHeight;break}e.translateWithPrecision(0,q),H.lines.forEach((ee,te)=>{e.save();const{width:ae,height:oe,items:le}=ee;let ie=0;switch(k){case r.HorizontalAlign.RIGHT:ie=H.contentWidth-ae;break;case r.HorizontalAlign.CENTER:ie=(H.contentWidth-ae)/2;break}e.translate(ie,te*(oe+xt)),le.forEach(de=>{e.save(),e.translateWithPrecision(de.left,0),ha.drawWith(e,{...F,info:de,color:O,fill:B[de.text]}),e.restore()}),e.restore()}),e.restore(),V.set(S,{left:L.startX,top:L.startY,width:H.contentWidth+pt+De,height:H.contentHeight+Ke*2})}calcCellAutoHeight(e){var I;const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:p=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,c={startX:v.startX+l,endX:v.endX-d,startY:v.startY+h,endY:v.endY-p},_=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!_)return;const g=this._dataValidationModel.getValidator(_.type);if(!g)return;const D=c.endX-c.startX,V=c.endY-c.startY,S=(I=E.getCellValueOrigin(n))!=null?I:"",w=g.parseCellValue(S),y=j.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:o,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:p=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,c={startX:v.startX+l,endX:v.endX-d,startY:v.startY+h,endY:v.endY-p},_=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!_)return;const g=this._dataValidationModel.getValidator(_.type);if(!g)return;const D=c.endX-c.startX,V=c.endY-c.startY,S=(I=E.getCellValueOrigin(n))!=null?I:"",w=g.parseCellValue(S),y=j.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:o}=n,{x:i}=e;return i>=o-De&&i<=o}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:i}=e,s={unitId:a,subUnitId:n,row:o,column:i};this._commandService.executeCommand(Ne.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(j.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(j.CURSOR_TYPE.DEFAULT)}};mt=va([gt(0,r.ICommandService),gt(1,r.Inject(j.IRenderManagerService)),gt(2,r.Inject(E.SheetDataValidationModel))],mt);class ma extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.LIST_MULTIPLE);P(this,"canvasRender",this.injector.createInstance(mt));P(this,"dropdown",We)}}var fa=Object.getOwnPropertyDescriptor,Sa=(e,t,a,n)=>{for(var o=n>1?void 0:n?fa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Ge=(e,t)=>(a,n)=>t(a,n,e);const ye=4,qe=4,ce=14,pe=6,Te=4,ft=8,_a="#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 Ia(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${r.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:r.BooleanNumber.FALSE,bl:r.BooleanNumber.FALSE,ul:{s:r.BooleanNumber.FALSE},st:{s:r.BooleanNumber.FALSE},ol:{s:r.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function zt(e,t,a){const n=Ia(e,a),o=new r.DocumentDataModel(n),i=new j.DocumentViewModel(o);return{documentSkeleton:j.DocumentSkeleton.create(i,t),docModel:o,docViewModel:i}}function Ze(e,t,a){const{documentSkeleton:n,docModel:o,docViewModel:i}=zt(e,t,a);return{documents:new j.Documents(`DOCUMENTS_${r.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:o,docViewModel:i}}function Kt(e,t,a,n,o,i,s=!0){let l=0;const d=s?Te:0;switch(o){case r.VerticalAlign.BOTTOM:l=t-n-d;break;case r.VerticalAlign.MIDDLE:l=(t-n)/2;break;default:l=d;break}l=Math.max(Te,l);let h=0;switch(i){case r.HorizontalAlign.CENTER:h=(e-a)/2;break;case r.HorizontalAlign.RIGHT:h=e-a;break}return h=Math.max(pe,h),{paddingLeft:h,paddingTop:l}}let St=class{constructor(e,t,a,n){P(this,"_dropdownInfoMap",new Map);P(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,o,i,s){const{t:l=r.DEFAULT_STYLES.pd.t,b:d=r.DEFAULT_STYLES.pd.b}=s,h=a-ce;let p;switch(i){case r.VerticalAlign.MIDDLE:p=(n-qe)/2;break;case r.VerticalAlign.BOTTOM:p=n-d-o-Te+(o/2-qe/2);break;default:p=l+Te+(o/2-qe/2);break}e.save(),e.translateWithPrecision(t.startX+h,t.startY+p),e.fillStyle="#565656",e.fill(Xt),e.restore()}drawWith(e,t,a){const{primaryWithCoord:n,row:o,col:i,style:s,data:l,subUnitId:d}=t,h=n.isMergedMainCell?n.mergeInfo:n,p=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,o,i);if(!p)return;const v=this._dataValidationModel.getValidator(p.type);if(!v)return;const c=l==null?void 0:l.fontRenderExtension,{leftOffset:_=0,rightOffset:g=0,topOffset:D=0,downOffset:V=0}=c||{};if(!p||!v||!v||v.id.indexOf(r.DataValidationType.LIST)!==0||!v.skipDefaultFontRender(p))return;const S={startX:h.startX+_,endX:h.endX-g,startY:h.startY+D,endY:h.endY-V},w=S.endX-S.startX,y=S.endY-S.startY,L=this._ensureMap(d),I=this._generateKey(o,i),C=v.getListWithColor(p),m=E.getCellValueOrigin(l),O=`${m!=null?m:""}`,F=C.find(U=>U.label===O);let{tb:$,vt:k,ht:R,pd:N}=s||{};if($=$!=null?$:r.WrapStrategy.WRAP,k=k!=null?k:r.VerticalAlign.BOTTOM,R=R!=null?R:r.DEFAULT_STYLES.ht,N=N!=null?N:r.DEFAULT_STYLES.pd,p.renderMode===r.DataValidationRenderMode.ARROW){const{l:U=r.DEFAULT_STYLES.pd.l,t:B=r.DEFAULT_STYLES.pd.t,r:H=r.DEFAULT_STYLES.pd.r,b:q=r.DEFAULT_STYLES.pd.b}=N,Z=w-U-H-ce-4,{documentSkeleton:G,documents:ee,docModel:te}=Ze(O,this._localeService,s);$===r.WrapStrategy.WRAP&&te.updateDocumentDataPageSize(Math.max(Z,1)),G.calculate(),G.getActualSize();const ae=j.getDocsSkeletonPageSize(G),{height:oe,width:le}=ae,{paddingTop:ie,paddingLeft:de}=Kt(Z,y-B-q,le,oe,k,R,!0);this._drawDownIcon(e,S,w,y,oe,k,N),e.save(),e.translateWithPrecision(S.startX+U,S.startY+B),e.beginPath(),e.rect(0,0,w-U-H,y-B-q),e.clip(),e.translateWithPrecision(0,ie),e.save(),e.translateWithPrecision(ye,0),e.beginPath(),e.rect(0,0,Z,oe),e.clip(),ee.render(e),e.translateWithPrecision(de,0),e.restore(),e.restore(),L.set(I,{left:S.endX+U+a.rowHeaderWidth-ce,top:S.startY+B+a.columnHeaderHeight,width:ce,height:y-B-q})}else{e.save(),e.translateWithPrecision(S.startX,S.startY),e.beginPath(),e.rect(0,0,w,y),e.clip();const U=w-pe*2-ye-ce-4,{documentSkeleton:B,documents:H,docModel:q}=Ze(O,this._localeService,s);$===r.WrapStrategy.WRAP&&q.updateDocumentDataPageSize(Math.max(U,1)),B.calculate();const Z=j.getDocsSkeletonPageSize(B),{height:G,width:ee}=Z,{paddingTop:te,paddingLeft:ae}=Kt(U,y,ee,G,k,R);e.translateWithPrecision(pe,te);const oe=Math.max(w-pe*2,1),le=G;j.Rect.drawWith(e,{width:oe,height:le,fill:(F==null?void 0:F.color)||Ie,radius:ft}),e.save(),e.translateWithPrecision(ye,0),e.beginPath(),e.rect(0,0,U,G),e.clip(),e.translateWithPrecision(ae,0),H.render(e),e.restore(),e.translateWithPrecision(U+ye+4,(G-qe)/2),e.fillStyle=_a,e.fill(Xt),e.restore(),L.set(I,{left:S.startX+pe+a.rowHeaderWidth,top:S.startY+te+a.columnHeaderHeight,width:oe,height:le})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,l=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:h=0,topOffset:p=0,downOffset:v=0}=l||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!c||c.renderMode===r.DataValidationRenderMode.TEXT)return;const _={startX:s.startX+d,endX:s.endX-h,startY:s.startY+p,endY:s.endY-v},g=_.endX-_.startX,D=E.getCellValueOrigin(n),V=`${D!=null?D:""}`;let{tb:S,pd:w}=a||{};const{t:y=r.DEFAULT_STYLES.pd.t,b:L=r.DEFAULT_STYLES.pd.b}=w!=null?w:{};if(S=S!=null?S:r.WrapStrategy.WRAP,c.renderMode===r.DataValidationRenderMode.ARROW){const I=g-ce,{documentSkeleton:C,docModel:m}=Ze(V,this._localeService,a);S===r.WrapStrategy.WRAP&&m.updateDocumentDataPageSize(Math.max(I,1)),C.calculate(),C.getActualSize();const O=j.getDocsSkeletonPageSize(C),{height:F}=O;return F+y+L+Te*2}else{const I=g-pe*2-ye-ce,{documentSkeleton:C,docModel:m}=zt(V,this._localeService,a);S===r.WrapStrategy.WRAP&&m.updateDocumentDataPageSize(Math.max(I,1)),C.calculate();const O=j.getDocsSkeletonPageSize(C),{height:F}=O;return F+Te*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:o,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,l=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:h=0,topOffset:p=0,downOffset:v=0}=l||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,i);if(!c||c.renderMode===r.DataValidationRenderMode.TEXT)return;const _={startX:s.startX+d,endX:s.endX-h,startY:s.startY+p,endY:s.endY-v},g=_.endX-_.startX,D=E.getCellValueOrigin(n),V=`${D!=null?D:""}`;let{tb:S,pd:w}=a||{};const{l:y=r.DEFAULT_STYLES.pd.l,r:L=r.DEFAULT_STYLES.pd.r}=w!=null?w:{};S=S!=null?S:r.WrapStrategy.WRAP;let I=pe*2+ce;switch(c.renderMode){case r.DataValidationRenderMode.ARROW:I=ce+pe*2+L+y;break;case r.DataValidationRenderMode.CUSTOM:I=ce+pe*2+ye*2+L+y+ft/2+1;break;default:I=ce+pe*2+ye*2+L+y+ft/2+1}const C=g-I,{documentSkeleton:m,docModel:O}=Ze(V,this._localeService,a);return S===r.WrapStrategy.WRAP&&O.updateDocumentDataPageSize(Math.max(C,1)),m.calculate(),m.getActualSize(),j.getDocsSkeletonPageSize(m).width+I}isHit(e,t){const{subUnitId:a,row:n,col:o}=t,s=this._ensureMap(a).get(this._generateKey(n,o)),l=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,o);if(!l||!s||l.renderMode===r.DataValidationRenderMode.TEXT)return!1;const{top:d,left:h,width:p,height:v}=s,{x:c,y:_}=e;return c>=h&&c<=h+p&&_>=d&&_<=d+v}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:i}=e,s={unitId:a,subUnitId:n,row:o,column:i};this._commandService.executeCommand(Ne.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(j.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(j.CURSOR_TYPE.DEFAULT)}};St=Sa([Ge(0,r.Inject(r.LocaleService)),Ge(1,r.ICommandService),Ge(2,r.Inject(j.IRenderManagerService)),Ge(3,r.Inject(E.SheetDataValidationModel))],St);class Ca extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.LIST);P(this,"canvasRender",this.injector.createInstance(St));P(this,"dropdown",We);P(this,"optionsInput",xe.componentKey);P(this,"formulaInput",ct)}}class Da extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.TEXT_LENGTH);P(this,"formulaInput",Ye)}}class ya extends he{constructor(){super(...arguments);P(this,"id",r.DataValidationType.WHOLE);P(this,"formulaInput",Ye)}}var wa=Object.getOwnPropertyDescriptor,Va=(e,t,a,n)=>{for(var o=n>1?void 0:n?wa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},_t=(e,t)=>(a,n)=>t(a,n,e);let Oe=class extends r.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[At,Vt],[ke,Mn],[Ot,gn],[We,_n],[rt,en],[xe.componentKey,xe],[Xe.componentKey,Xe],...qn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[la,ya,Da,sa,oa,Ca,ma,ia].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=Va([_t(0,r.Inject(r.Injector)),_t(1,r.Inject(f.ComponentManager)),_t(2,r.Inject(J.DataValidatorRegistryService))],Oe);var Ea=Object.getOwnPropertyDescriptor,Ma=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ea(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},It=(e,t)=>(a,n)=>t(a,n,e);const ba="SHEET_DATA_VALIDATION_UI_PLUGIN";x.UniverSheetsDataValidationUIPlugin=(Je=class extends r.Plugin{constructor(t=Ue,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:i,...s}=r.merge({},Ue,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ot,s)}onStarting(){[[ue],[me],[Ae],[Ee],[Le],[be],[Me],[Re],[Oe]].forEach(t=>{this._injector.add(t)}),[$e,Ne,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(j.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[He])}onRendered(){this._injector.get(Oe),this._injector.get(Le)}onSteady(){this._injector.get(Ee)}},P(Je,"pluginName",ba),P(Je,"type",r.UniverInstanceType.UNIVER_SHEET),Je),x.UniverSheetsDataValidationUIPlugin=Ma([It(1,r.Inject(r.Injector)),It(2,r.ICommandService),It(3,r.IConfigService)],x.UniverSheetsDataValidationUIPlugin);var La=Object.getOwnPropertyDescriptor,Ta=(e,t,a,n)=>{for(var o=n>1?void 0:n?La(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=s(o)||o);return o},Ct=(e,t)=>(a,n)=>t(a,n,e);const Oa="SHEET_DATA_VALIDATION_UI_PLUGIN";x.UniverSheetsDataValidationMobileUIPlugin=(Qe=class extends r.Plugin{constructor(t=Ue,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:i,...s}=r.merge({},Ue,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ot,s)}onStarting(){[[ue],[me],[Ae],[Ee],[Le],[be],[Me],[Oe]].forEach(t=>{this._injector.add(t)}),[$e,Ne,Rt,at,_e,Pt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Me),this._injector.get(be),this._injector.get(j.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[He])}onRendered(){this._injector.get(Oe),this._injector.get(Le)}onSteady(){this._injector.get(Ee)}},P(Qe,"pluginName",Oa),P(Qe,"type",r.UniverInstanceType.UNIVER_SHEET),Qe),x.UniverSheetsDataValidationMobileUIPlugin=Ta([Ct(1,r.Inject(r.Injector)),Ct(2,r.ICommandService),Ct(3,r.IConfigService)],x.UniverSheetsDataValidationMobileUIPlugin),x.DATE_DROPDOWN_KEY=rt,x.LIST_DROPDOWN_KEY=We,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-data-validation-ui",
3
- "version": "0.6.1-nightly.202502221605",
3
+ "version": "0.6.1-nightly.202502241606",
4
4
  "private": false,
5
5
  "description": "Data validation UI for Univer Sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -57,18 +57,18 @@
57
57
  "@flatten-js/interval-tree": "^1.1.3",
58
58
  "@univerjs/icons": "^0.2.20",
59
59
  "clsx": "^2.1.1",
60
- "@univerjs/core": "0.6.1-nightly.202502221605",
61
- "@univerjs/engine-formula": "0.6.1-nightly.202502221605",
62
- "@univerjs/data-validation": "0.6.1-nightly.202502221605",
63
- "@univerjs/design": "0.6.1-nightly.202502221605",
64
- "@univerjs/docs": "0.6.1-nightly.202502221605",
65
- "@univerjs/engine-render": "0.6.1-nightly.202502221605",
66
- "@univerjs/sheets": "0.6.1-nightly.202502221605",
67
- "@univerjs/sheets-formula-ui": "0.6.1-nightly.202502221605",
68
- "@univerjs/sheets-data-validation": "0.6.1-nightly.202502221605",
69
- "@univerjs/sheets-numfmt": "0.6.1-nightly.202502221605",
70
- "@univerjs/sheets-ui": "0.6.1-nightly.202502221605",
71
- "@univerjs/ui": "0.6.1-nightly.202502221605"
60
+ "@univerjs/core": "0.6.1-nightly.202502241606",
61
+ "@univerjs/docs": "0.6.1-nightly.202502241606",
62
+ "@univerjs/engine-formula": "0.6.1-nightly.202502241606",
63
+ "@univerjs/data-validation": "0.6.1-nightly.202502241606",
64
+ "@univerjs/engine-render": "0.6.1-nightly.202502241606",
65
+ "@univerjs/design": "0.6.1-nightly.202502241606",
66
+ "@univerjs/sheets-data-validation": "0.6.1-nightly.202502241606",
67
+ "@univerjs/sheets-formula-ui": "0.6.1-nightly.202502241606",
68
+ "@univerjs/sheets-numfmt": "0.6.1-nightly.202502241606",
69
+ "@univerjs/ui": "0.6.1-nightly.202502241606",
70
+ "@univerjs/sheets": "0.6.1-nightly.202502241606",
71
+ "@univerjs/sheets-ui": "0.6.1-nightly.202502241606"
72
72
  },
73
73
  "devDependencies": {
74
74
  "less": "^4.2.2",