@univerjs/sheets-data-validation-ui 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +807 -788
- package/lib/index.css +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +17 -17
package/lib/index.css
CHANGED
@@ -1 +1 @@
|
|
1
|
-
.univer-dv-date-dropdown{background:#fff;border-radius:var(--border-radius-base);box-shadow:var(--box-shadow-lg);padding:var(--padding-sm)}.univer-dv-date-dropdown-btns{display:flex;justify-content:flex-end;border-top:1px solid rgb(var(--border-color));padding-top:var(--padding-sm)}.univer-dv-list-dropdown{border-radius:var(--border-radius-lg);border:1px solid rgb(var(--border-color));background:rgba(var(--color-white));box-shadow:var(--box-shadow-base);box-sizing:border-box;padding-bottom:var(--padding-xs)}.univer-dv-list-dropdown-title{padding:var(--padding-sm) 14px;color:rgb(var(--text-color));font-size:12px;line-height:1.5;flex-shrink:0;flex-grow:0}.univer-dv-list-dropdown-list{max-height:200px}.univer-dv-list-dropdown-list-container{padding:0 var(--padding-sm)}.univer-dv-list-dropdown-selected-icon{width:16px;height:16px;font-size:16px;color:rgba(var(--blue-500));flex-shrink:0;flex-grow:0;margin-left:12px}.univer-dv-list-dropdown-item-container{display:flex;flex-direction:row;align-items:center;justify-content:space-between;padding:var(--padding-xs) 6px;border-radius:6px;margin-top:4px;cursor:pointer}.univer-dv-list-dropdown-item-container:hover{background-color:rgba(var(--grey-50))}.univer-dv-list-dropdown-item{padding:0 4px;font-size:12px;font-style:normal;font-weight:400;line-height:16px;border-radius:8px;height:16px;width:fit-content;flex:0 1 auto;text-overflow:ellipsis;overflow:hidden;color:rgba(var(--color-black));white-space:nowrap}.univer-dv-list-dropdown-split{height:1px;margin:4px 0;background:rgba(var(--grey-200));flex-shrink:0;flex-grow:0}.univer-dv-list-dropdown-edit{padding:0 var(--padding-xs);flex-shrink:0;flex-grow:0}.univer-dv-list-dropdown-edit a{padding:3px 6px;font-size:12px;line-height:1.5;cursor:pointer;border-radius:6px;display:block}.univer-dv-list-dropdown-edit a:hover{background:#f5f5f5}.univer-data-validation-options-button{cursor:pointer;margin-bottom:12px;font-size:var(--font-size-sm);color:rgba(var(--color-black));display:flex;align-items:center}.univer-data-validation-options-button-icon{font-size:8px;margin-left:4px}.univer-data-validation-detail{padding:var(--padding-base) 0}.univer-data-validation-detail-form-item{width:100%}.univer-data-validation-detail-buttons{margin-top:20px;display:flex;flex-direction:row;justify-content:flex-end}.univer-data-validation-detail-button{margin-left:12px}.univer-data-validation-item-container{border-radius:var(--border-radius-base);background-color:rgba(var(--bg-color-secondary));padding:var(--padding-sm);padding-right:36px;margin-left:-8px;margin-right:-8px;box-sizing:border-box;display:flex;flex-direction:column;justify-content:space-between;cursor:pointer;position:relative;border-radius:6px;width:287px;overflow:hidden}.univer-data-validation-item-container:hover{background-color:rgba(var(--grey-50))}.univer-data-validation-item-title{font-size:var(--font-size-sm);color:rgba(var(--color-black));line-height:22px;font-weight:500;overflow:hidden;text-overflow:ellipsis}.univer-data-validation-item-content{color:rgba(var(--text-color-secondary));font-size:var(--font-size-xs);line-height:18px;overflow:hidden;text-overflow:ellipsis}.univer-data-validation-item-icon{position:absolute;top:19px;right:8px;width:20px;height:20px;display:flex;justify-content:center;align-items:center;border-radius:4px}.univer-data-validation-item-icon:hover{background:rgba(var(--grey-200))}.univer-data-validation-list{padding:var(--padding-base) 0}.univer-data-validation-list-buttons{margin-top:20px;display:flex;flex-direction:row;justify-content:flex-end}.univer-data-validation-list-button{margin-left:12px}.univer-data-validation-formula{width:100%}.univer-data-validation-formula-and{margin-top:-4px;font-size:var(--font-size-sm);color:rgba(var(--grey-400))}.univer-data-validation-formula-list-item{display:flex;padding-bottom:2px;align-items:center}.univer-data-validation-formula-list-item-icon{font-size:16px;cursor:pointer;margin-left:4px;border-radius:4px}.univer-data-validation-formula-list-item-icon:hover{background:rgba(var(--grey-100))}.univer-data-validation-formula-list-item-drag{cursor:move}.univer-data-validation-formula-list-add{color:#274fee;font-size:13px;font-weight:400;cursor:pointer;display:flex;flex-direction:row;align-items:center;border-radius:4px;padding:4px 8px;width:fit-content}.univer-data-validation-formula-list-add svg{margin-right:4px}.univer-data-validation-formula-list-add:hover{background:#274fee0d}.univer-data-validation-formula-color-select{width:92px;margin-left:4px;margin-right:8px}.univer-data-validation-formula-color-select-panel{width:112px;display:flex;flex-direction:row;justify-content:space-between;padding:12px 4px 4px 12px;flex-wrap:wrap;box-sizing:border-box}.univer-data-validation-formula-color-select-panel .univer-data-validation-formula-color-item{margin-bottom:8px;margin-right:8px;box-sizing:border-box;cursor:pointer}.univer-data-validation-formula-color-item{border-radius:3px;border:1px solid rgba(var(--grey-400));width:16px;height:16px;box-sizing:border-box;font-size:16px}
|
1
|
+
*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(63 131 248 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(63 131 248 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*{scrollbar-color:initial;scrollbar-width:initial}@keyframes enter{0%{opacity:var(--tw-enter-opacity, 1);transform:translate3d(var(--tw-enter-translate-x, 0),var(--tw-enter-translate-y, 0),0) scale3d(var(--tw-enter-scale, 1),var(--tw-enter-scale, 1),var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity, 1);transform:translate3d(var(--tw-exit-translate-x, 0),var(--tw-exit-translate-y, 0),0) scale3d(var(--tw-exit-scale, 1),var(--tw-exit-scale, 1),var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0))}}.univer-dv-date-dropdown{background:#fff;border-radius:var(--border-radius-base);box-shadow:var(--box-shadow-lg);padding:var(--padding-sm)}.univer-dv-date-dropdown-btns{display:flex;justify-content:flex-end;border-top:1px solid rgb(var(--border-color));padding-top:var(--padding-sm)}.univer-dv-list-dropdown{border-radius:var(--border-radius-lg);border:1px solid rgb(var(--border-color));background:rgba(var(--color-white));box-shadow:var(--box-shadow-base);box-sizing:border-box;padding-bottom:var(--padding-xs)}.univer-dv-list-dropdown-title{padding:var(--padding-sm) 14px;color:rgb(var(--text-color));font-size:12px;line-height:1.5;flex-shrink:0;flex-grow:0}.univer-dv-list-dropdown-list{max-height:200px}.univer-dv-list-dropdown-list-container{padding:0 var(--padding-sm)}.univer-dv-list-dropdown-selected-icon{width:16px;height:16px;font-size:16px;color:rgba(var(--blue-500));flex-shrink:0;flex-grow:0;margin-left:12px}.univer-dv-list-dropdown-item-container{display:flex;flex-direction:row;align-items:center;justify-content:space-between;padding:var(--padding-xs) 6px;border-radius:6px;margin-top:4px;cursor:pointer}.univer-dv-list-dropdown-item-container:hover{background-color:rgba(var(--grey-50))}.univer-dv-list-dropdown-item{padding:0 4px;font-size:12px;font-style:normal;font-weight:400;line-height:16px;border-radius:8px;height:16px;width:-moz-fit-content;width:fit-content;flex:0 1 auto;text-overflow:ellipsis;overflow:hidden;color:rgba(var(--color-black));white-space:nowrap}.univer-dv-list-dropdown-split{height:1px;margin:4px 0;background:rgba(var(--grey-200));flex-shrink:0;flex-grow:0}.univer-dv-list-dropdown-edit{padding:0 var(--padding-xs);flex-shrink:0;flex-grow:0}.univer-dv-list-dropdown-edit a{padding:3px 6px;font-size:12px;line-height:1.5;cursor:pointer;border-radius:6px;display:block}.univer-dv-list-dropdown-edit a:hover{background:#f5f5f5}.univer-data-validation-options-button{cursor:pointer;margin-bottom:12px;font-size:var(--font-size-sm);color:rgba(var(--color-black));display:flex;align-items:center}.univer-data-validation-options-button-icon{font-size:8px;margin-left:4px}.univer-data-validation-detail{padding:var(--padding-base) 0}.univer-data-validation-detail-form-item{width:100%}.univer-data-validation-detail-buttons{margin-top:20px;display:flex;flex-direction:row;justify-content:flex-end}.univer-data-validation-detail-button{margin-left:12px}.univer-data-validation-item-container{border-radius:var(--border-radius-base);background-color:rgba(var(--bg-color-secondary));padding:var(--padding-sm);padding-right:36px;margin-left:-8px;margin-right:-8px;box-sizing:border-box;display:flex;flex-direction:column;justify-content:space-between;cursor:pointer;position:relative;border-radius:6px;width:287px;overflow:hidden}.univer-data-validation-item-container:hover{background-color:rgba(var(--grey-50))}.univer-data-validation-item-title{font-size:var(--font-size-sm);color:rgba(var(--color-black));line-height:22px;font-weight:500;overflow:hidden;text-overflow:ellipsis}.univer-data-validation-item-content{color:rgba(var(--text-color-secondary));font-size:var(--font-size-xs);line-height:18px;overflow:hidden;text-overflow:ellipsis}.univer-data-validation-item-icon{position:absolute;top:19px;right:8px;width:20px;height:20px;display:flex;justify-content:center;align-items:center;border-radius:4px}.univer-data-validation-item-icon:hover{background:rgba(var(--grey-200))}.univer-data-validation-list{padding:var(--padding-base) 0}.univer-data-validation-list-buttons{margin-top:20px;display:flex;flex-direction:row;justify-content:flex-end}.univer-data-validation-list-button{margin-left:12px}.univer-data-validation-formula{width:100%}.univer-data-validation-formula-and{margin-top:-4px;font-size:var(--font-size-sm);color:rgba(var(--grey-400))}.univer-data-validation-formula-list-item{display:flex;padding-bottom:2px;align-items:center}.univer-data-validation-formula-list-item-icon{font-size:16px;cursor:pointer;margin-left:4px;border-radius:4px}.univer-data-validation-formula-list-item-icon:hover{background:rgba(var(--grey-100))}.univer-data-validation-formula-list-item-drag{cursor:move}.univer-data-validation-formula-list-add{color:#274fee;font-size:13px;font-weight:400;cursor:pointer;display:flex;flex-direction:row;align-items:center;border-radius:4px;padding:4px 8px;width:-moz-fit-content;width:fit-content}.univer-data-validation-formula-list-add svg{margin-right:4px}.univer-data-validation-formula-list-add:hover{background:#274fee0d}.univer-data-validation-formula-color-select{width:92px;margin-left:4px;margin-right:8px}.univer-data-validation-formula-color-select-panel{width:112px;display:flex;flex-direction:row;justify-content:space-between;padding:12px 4px 4px 12px;flex-wrap:wrap;box-sizing:border-box}.univer-data-validation-formula-color-select-panel .univer-data-validation-formula-color-item{margin-bottom:8px;margin-right:8px;box-sizing:border-box;cursor:pointer}.univer-data-validation-formula-color-item{border-radius:3px;border:1px solid rgba(var(--grey-400));width:16px;height:16px;box-sizing:border-box;font-size:16px}
|
package/lib/umd/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
(function(Y,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("react"),require("@univerjs/core"),require("@univerjs/design"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("@univerjs/data-validation"),require("@univerjs/docs"),require("rxjs"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","react","@univerjs/core","@univerjs/design","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-data-validation","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/ui","@univerjs/data-validation","@univerjs/docs","rxjs","@univerjs/engine-formula","@univerjs/sheets-formula-ui"],f):(Y=typeof globalThis<"u"?globalThis:Y||self,f(Y.UniverSheetsDataValidationUi={},Y.React,Y.UniverCore,Y.UniverDesign,Y.UniverEngineRender,Y.UniverSheets,Y.UniverSheetsDataValidation,Y.UniverSheetsNumfmt,Y.UniverSheetsUi,Y.UniverUi,Y.UniverDataValidation,Y.UniverDocs,Y.rxjs,Y.UniverEngineFormula,Y.UniverSheetsFormulaUi))})(this,function(Y,f,o,b,B,X,E,Qt,x,z,J,en,re,
|
1
|
+
(function(Y,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("react"),require("@univerjs/core"),require("@univerjs/design"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("@univerjs/data-validation"),require("@univerjs/docs"),require("rxjs"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","react","@univerjs/core","@univerjs/design","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-data-validation","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/ui","@univerjs/data-validation","@univerjs/docs","rxjs","@univerjs/engine-formula","@univerjs/sheets-formula-ui"],f):(Y=typeof globalThis<"u"?globalThis:Y||self,f(Y.UniverSheetsDataValidationUi={},Y.React,Y.UniverCore,Y.UniverDesign,Y.UniverEngineRender,Y.UniverSheets,Y.UniverSheetsDataValidation,Y.UniverSheetsNumfmt,Y.UniverSheetsUi,Y.UniverUi,Y.UniverDataValidation,Y.UniverDocs,Y.rxjs,Y.UniverEngineFormula,Y.UniverSheetsFormulaUi))})(this,function(Y,f,o,b,B,X,E,Qt,x,z,J,en,re,tt,nt){"use strict";var ti=Object.defineProperty;var ni=(Y,f,o)=>f in Y?ti(Y,f,{enumerable:!0,configurable:!0,writable:!0,value:o}):Y[f]=o;var L=(Y,f,o)=>ni(Y,typeof f!="symbol"?f+"":f,o);var Qe,et;var at={exports:{}},Te={};/**
|
2
2
|
* @license React
|
3
3
|
* react-jsx-runtime.production.min.js
|
4
4
|
*
|
@@ -6,4 +6,4 @@
|
|
6
6
|
*
|
7
7
|
* This source code is licensed under the MIT license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
|
-
*/var yt;function tn(){if(yt)return Le;yt=1;var e=f,t=Symbol.for("react.element"),a=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function s(d,l,u){var p,m={},c=null,g=null;u!==void 0&&(c=""+u),l.key!==void 0&&(c=""+l.key),l.ref!==void 0&&(g=l.ref);for(p in l)n.call(l,p)&&!r.hasOwnProperty(p)&&(m[p]=l[p]);if(d&&d.defaultProps)for(p in l=d.defaultProps,l)m[p]===void 0&&(m[p]=l[p]);return{$$typeof:t,type:d,key:c,ref:g,props:m,_owner:i.current}}return Le.Fragment=a,Le.jsx=s,Le.jsxs=s,Le}var wt;function nn(){return wt||(wt=1,tt.exports=tn()),tt.exports}var h=nn(),an=Object.defineProperty,on=Object.getOwnPropertyDescriptor,rn=(e,t,a,n)=>{for(var i=n>1?void 0:n?on(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&an(t,a,i),i},Te=(e,t)=>(a,n)=>t(a,n,e);let Pe=class extends o.Disposable{constructor(e,t,a,n,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(X.AFTER_CELL_EDIT_ASYNC,{handler:async(e,t,a)=>{var I;const n=await e,{worksheet:i,row:r,col:s,unitId:d,subUnitId:l,workbook:u}=t,p=this._dataValidationModel.getRuleIdByLocation(d,l,r,s),m=p?this._dataValidationModel.getRuleById(d,l,p):void 0;if(!m||m.errorStyle!==o.DataValidationErrorStyle.STOP)return a(Promise.resolve(n));const c=await this._dataValidatorRegistryService.getValidatorItem(m.type);if(!c||await c.validator({value:E.getCellValueOrigin(n),interceptValue:E.getCellValueOrigin((I=t==null?void 0:t.origin)!=null?I:n),row:r,column:s,unitId:d,subUnitId:l,worksheet:i,workbook:u,t:n==null?void 0:n.t},m))return a(Promise.resolve(n));const v=i.getCellRaw(r,s);return this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:c.getRuleFinalError(m,{row:r,col:s,unitId:d,subUnitId:l})},footer:{title:f.createElement(b.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(Promise.resolve(v))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:f.createElement(b.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Pe=rn([Te(0,o.Inject(X.SheetInterceptorService)),Te(1,o.Inject(E.SheetDataValidationModel)),Te(2,o.Inject(J.DataValidatorRegistryService)),Te(3,z.IDialogService),Te(4,o.Inject(o.LocaleService))],Pe);const Vt={dvDateDropdown:"univer-dv-date-dropdown",dvDateDropdownBtns:"univer-dv-date-dropdown-btns"},sn=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function ln(e){var _;const{location:t,hideFn:a}=e,{worksheet:n,row:i,col:r,unitId:s,subUnitId:d,workbook:l}=t,u=o.useDependency(o.ICommandService),p=o.useDependency(Pe),m=n.getCell(i,r),c=E.getCellValueOrigin(n.getCellRaw(i,r)),g=sn(c),[v,I]=f.useState(g),w=v&&v.isValid()?v:o.dayjs(),C=o.useDependency(o.LocaleService),V=o.useDependency(E.SheetDataValidationModel),y=V.getRuleByLocation(s,d,i,r);if(!y)return null;const M=V.getValidator(y.type);if(!m||!M)return;const D=!!((_=y.bizInfo)!=null&&_.showTime),S=async()=>{var N,U,k;if(!w)return;const j=w.format(D?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),$=(N=o.numfmt.parseDate(j))==null?void 0:N.v,A=l.getStyles().getStyleByCell(m),T=(k=(U=A==null?void 0:A.n)==null?void 0:U.pattern)!=null?k:"",F=Qt.getPatternType(T);y.errorStyle!==o.DataValidationErrorStyle.STOP||await M.validator({value:$,unitId:s,subUnitId:d,row:i,column:r,worksheet:n,workbook:l,interceptValue:j.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},y)?(a(),await u.executeCommand(x.SetCellEditVisibleOperation.id,{visible:!1,eventType:B.DeviceInputEventType.Keyboard,unitId:s,keycode:z.KeyCode.ESC}),await u.executeCommand(X.SetRangeValuesCommand.id,{unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:$,t:2,p:null,f:null,si:null,s:{n:{pattern:D?F==="datetime"?T:"yyyy-MM-dd hh:mm:ss":F==="date"?T:"yyyy-MM-dd"}}}})):p.showReject(M.getRuleFinalError(y,{row:i,col:r,unitId:s,subUnitId:d}))};return h.jsxs("div",{className:Vt.dvDateDropdown,children:[h.jsx(b.DatePanel,{defaultValue:w,pickerValue:w,showTime:D||void 0,onSelect:async O=>{I(O)},onPanelChange:O=>{I(O)},disabledDate:O=>!o.numfmt.parseDate(O.format("YYYY-MM-DD"))}),h.jsx("div",{className:Vt.dvDateDropdownBtns,children:h.jsx(b.Button,{size:"small",type:"primary",onClick:S,disabled:!w.isValid(),children:C.t("dataValidation.alert.ok")})})]})}var se=function(){return se=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},se.apply(this,arguments)},dn=function(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(a[n[i]]=e[n[i]]);return a},ve=f.forwardRef(function(e,t){var a=e.icon,n=e.id,i=e.className,r=e.extend,s=dn(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),l=f.useRef("_".concat(pn()));return Et(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},se({ref:t,className:d},s),r)});function Et(e,t,a,n,i){return f.createElement(e.tag,se(se({key:t},cn(e,a,i)),n),(un(e,a).children||[]).map(function(r,s){return Et(r,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,i)}))}function cn(e,t,a){var n=se({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1);var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],d=r[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function un(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?se(se({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?se(se({},i),{attrs:se(se({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function pn(){return Math.random().toString(36).substring(2,8)}ve.displayName="UniverIcon";var hn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Rt=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"check-mark-single",ref:t,icon:hn}))});Rt.displayName="CheckMarkSingle";var mn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.4917 3.07803C1.4917 2.19437 2.20804 1.47803 3.0917 1.47803H5.6917C6.57536 1.47803 7.2917 2.19437 7.2917 3.07803V5.67803C7.2917 6.56168 6.57535 7.27803 5.6917 7.27803H3.0917C2.20804 7.27803 1.4917 6.56168 1.4917 5.67803V3.07803ZM3.0917 2.67803C2.87078 2.67803 2.6917 2.85711 2.6917 3.07803V5.67803C2.6917 5.89894 2.87079 6.07803 3.0917 6.07803H5.6917C5.91261 6.07803 6.0917 5.89894 6.0917 5.67803V3.07803C6.0917 2.85711 5.91261 2.67803 5.6917 2.67803H3.0917Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.6175 2.45279C14.8518 2.68711 14.8518 3.06701 14.6175 3.30132L11.6151 6.30365C11.3957 6.52307 11.0451 6.53897 10.8067 6.34031L8.80915 4.67566C8.55458 4.46352 8.52019 4.08518 8.73233 3.83062 8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767 13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279zM14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217 14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046 13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703 10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046 9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217 9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746 9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732 13.269 9.19746C13.5033 8.96315 13.8832 8.96315 14.1175 9.19746z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.0917 8.72168C2.20804 8.72168 1.4917 9.43802 1.4917 10.3217V12.9217C1.4917 13.8053 2.20804 14.5217 3.0917 14.5217H5.6917C6.57535 14.5217 7.2917 13.8053 7.2917 12.9217V10.3217C7.2917 9.43802 6.57536 8.72168 5.6917 8.72168H3.0917ZM2.6917 10.3217C2.6917 10.1008 2.87078 9.92168 3.0917 9.92168H5.6917C5.91261 9.92168 6.0917 10.1008 6.0917 10.3217V12.9217C6.0917 13.1426 5.91261 13.3217 5.6917 13.3217H3.0917C2.87079 13.3217 2.6917 13.1426 2.6917 12.9217V10.3217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Mt=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"data-validation-single",ref:t,icon:mn}))});Mt.displayName="DataValidationSingle";var vn={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=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"delete-single",ref:t,icon:vn}))});nt.displayName="DeleteSingle";var fn={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"}}]},bt=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"increase-single",ref:t,icon:fn}))});bt.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=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"more-down-single",ref:t,icon:gn}))});Ot.displayName="MoreDownSingle";var Sn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.64645 9.85355C4.45118 9.65829 4.45118 9.34171 4.64645 9.14645L7.64645 6.14645C7.84171 5.95118 8.15829 5.95118 8.35355 6.14645L11.3536 9.14645C11.5488 9.34171 11.5488 9.65829 11.3536 9.85355C11.1583 10.0488 10.8417 10.0488 10.6464 9.85355L8 7.20711L5.35355 9.85355C5.15829 10.0488 4.84171 10.0488 4.64645 9.85355Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Lt=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"more-up-single",ref:t,icon:Sn}))});Lt.displayName="MoreUpSingle";var _n={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},Tt=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"sequence-single",ref:t,icon:_n}))});Tt.displayName="SequenceSingle";var In=Object.defineProperty,Cn=Object.getOwnPropertyDescriptor,Dn=(e,t,a,n)=>{for(var i=n>1?void 0:n?Cn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&In(t,a,i),i},Pt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends o.Disposable{constructor(t,a){super();L(this,"_open$",new re.BehaviorSubject(!1));L(this,"open$",this._open$.pipe(re.distinctUntilChanged()));L(this,"_activeRule");L(this,"_activeRule$",new re.BehaviorSubject(void 0));L(this,"activeRule$",this._activeRule$.asObservable());L(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(re.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===at&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ue=Dn([Pt(0,o.IUniverInstanceService),Pt(1,z.ISidebarService)],ue);function yn(){const e=o.useDependency(fe),t=z.useObservable(e.activeDropdown$,e.activeDropdown),a=o.useDependency(z.ComponentManager);if(!t)return null;const{location:n,componentKey:i}=t,r=a.get(i),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!r)return null;const d=()=>{e.hideDropdown()};return h.jsx(r,{location:n,hideFn:d},s)}const jt="sheet.ui.dropdown";var wn=Object.defineProperty,Vn=Object.getOwnPropertyDescriptor,En=(e,t,a,n)=>{for(var i=n>1?void 0:n?Vn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&wn(t,a,i),i},Se=(e,t)=>(a,n)=>t(a,n,e);let fe=class extends o.Disposable{constructor(t,a,n,i,r,s,d){super();L(this,"_activeDropdown");L(this,"_activeDropdown$",new re.Subject);L(this,"_currentPopup",null);L(this,"activeDropdown$",this._activeDropdown$.asObservable());L(this,"_zenVisible",!1);this._canvasPopupManagerService=t,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=i,this._renderManagerService=r,this._dataValidationModel=s,this._sheetsSelectionsService=d,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,a,n,i){const r=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!r)return;const s=a?r.getSheetBySheetId(a):r.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(r.getUnitId(),s.getSheetId(),n,i);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdown}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t,a=!0){const{location:n}=t,{row:i,col:r,unitId:s,subUnitId:d}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const l=this._renderManagerService.getRenderById(o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),u=this._canvasPopupManagerService.attachPopupToCell(i,r,{componentKey:jt,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[l==null?void 0:l.engine.getCanvasElement()].filter(Boolean)},s,d);if(!u)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const p=new o.DisposableCollection;p.add(u),p.add({dispose:()=>{var m,c;(c=(m=this._activeDropdown)==null?void 0:m.onHide)==null||c.call(m)}}),this._currentPopup=p}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,a,n,i,r){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(a);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,i);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!u||!u.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:i,unitId:t,subUnitId:a},componentKey:u.dropdown,onHide:r})}};fe=En([Se(0,o.Inject(x.SheetCanvasPopManagerService)),Se(1,o.IUniverInstanceService),Se(2,o.Inject(J.DataValidatorRegistryService)),Se(3,z.IZenZoneService),Se(4,B.IRenderManagerService),Se(5,o.Inject(E.SheetDataValidationModel)),Se(6,o.Inject(X.SheetsSelectionsService))],fe);const at="DataValidationPanel",_e={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,i=e.get(ue),r=e.get(J.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(z.ISidebarService),l=X.getSheetCommandTarget(s);if(!l)return!1;const{unitId:u,subUnitId:p}=l,m=a?r.getRuleById(u,p,a):void 0;i.open(),i.setActiveRule(m&&{unitId:u,subUnitId:p,rule:m});const c=d.open({header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:at},width:312,onClose:()=>i.close()});return i.setCloseDisposable(c),!0}},it={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},At={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),a=e.get(ue);return a.open(),a.isOpen?t.executeCommand(it.id):t.executeCommand(_e.id),!0}},Fe={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(fe),{unitId:n,subUnitId:i,row:r,column:s}=t,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===i&&l.row===r&&l.col===s||a.showDataValidationDropdown(n,i,r,s),!0}},Ft={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},Ie="#ECECEC",ot="sheets-data-validation-ui.config",xt={},me={dvListDropdown:"univer-dv-list-dropdown",dvListDropdownTitle:"univer-dv-list-dropdown-title",dvListDropdownList:"univer-dv-list-dropdown-list",dvListDropdownListContainer:"univer-dv-list-dropdown-list-container",dvListDropdownSelectedIcon:"univer-dv-list-dropdown-selected-icon",dvListDropdownItemContainer:"univer-dv-list-dropdown-item-container",dvListDropdownItem:"univer-dv-list-dropdown-item",dvListDropdownSplit:"univer-dv-list-dropdown-split",dvListDropdownEdit:"univer-dv-list-dropdown-edit"},Rn=e=>{var D,S;const{value:t,onChange:a,multiple:n,options:i,title:r,onEdit:s,style:d,filter:l,location:u}=e,p=o.useDependency(o.LocaleService),m=o.useDependency(o.IConfigService),c=l==null?void 0:l.toLowerCase(),{row:g,col:v,unitId:I,subUnitId:w}=u,C=i.filter(_=>c?_.label.toLowerCase().includes(c):!0),V=(S=(D=m.getConfig(ot))==null?void 0:D.showEditOnDropdown)!=null?S:!0,y=o.useDependency(x.SheetPermissionInterceptorBaseController),M=f.useMemo(()=>y.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission]},[{startColumn:v,startRow:g,endColumn:v,endRow:g}],I,w),[y,v,g,I,w]);return h.jsxs("div",{className:me.dvListDropdown,style:d,children:[h.jsx("div",{className:me.dvListDropdownTitle,children:r}),h.jsx("div",{className:me.dvListDropdownList,children:h.jsx(b.Scrollbar,{children:h.jsx("div",{className:me.dvListDropdownListContainer,children:C.map((_,O)=>{const j=t.indexOf(_.value)>-1,$=()=>{let T;j?T=new Set(t.filter(N=>N!==_.value)):T=new Set(n?[...t,_.value]:[_.value]);const F=[];i.forEach(N=>{T.has(N.value)&&F.push(N.value)}),a(F)},A=_.label.toLocaleLowerCase().indexOf(c);return h.jsxs("div",{className:me.dvListDropdownItemContainer,onClick:$,children:[h.jsx("div",{className:me.dvListDropdownItem,style:{background:_.color||Ie},children:c&&_.label.toLowerCase().includes(c)?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:_.label.substring(0,A)}),h.jsx("span",{style:{fontWeight:"bold"},children:_.label.substring(A,A+c.length)}),h.jsx("span",{children:_.label.substring(A+c.length)})]}):_.label}),h.jsx("div",{className:me.dvListDropdownSelectedIcon,children:j?h.jsx(Rt,{}):null})]},O)})})},l)}),V&&M?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:me.dvListDropdownSplit}),h.jsx("div",{className:me.dvListDropdownEdit,children:h.jsx("a",{onClick:s,children:p.t("dataValidation.list.edit")})})]}):null]})};function Mn(e){var U,k,G,Z;const{location:t,hideFn:a}=e,{worksheet:n,row:i,col:r,unitId:s,subUnitId:d}=t,l=o.useDependency(J.DataValidationModel),[u,p]=f.useState(""),m=o.useDependency(o.ICommandService),c=o.useDependency(o.LocaleService),[g,v]=f.useState(""),I=o.useDependency(x.IEditorBridgeService),w=o.useDependency(o.IUniverInstanceService),C=f.useMemo(()=>l.ruleChange$.pipe(re.debounceTime(16)),[]),V=o.useDependency(E.SheetDataValidationModel);z.useObservable(C);const y=z.RectPopup.useContext(),M=((k=(U=y.current)==null?void 0:U.right)!=null?k:0)-((Z=(G=y.current)==null?void 0:G.left)!=null?Z:0);if(f.useEffect(()=>{const q=m.onCommandExecuted(ee=>{var te,ae;if(ee.id===en.RichTextEditingMutation.id){const ie=ee.params,{unitId:le}=ie,oe=w.getUnit(le,o.UniverInstanceType.UNIVER_DOC);if(!oe)return;const de=o.BuildTextUtils.transform.getPlainText((ae=(te=oe.getSnapshot().body)==null?void 0:te.dataStream)!=null?ae:"");p(de)}});return()=>{q.dispose()}},[m,w]),!n)return null;const D=V.getRuleByLocation(s,d,i,r);if(!D)return null;const S=V.getValidator(D.type);if(!S)return null;const _=n.getCell(i,r),O=(D==null?void 0:D.renderMode)===o.DataValidationRenderMode.CUSTOM||(D==null?void 0:D.renderMode)===void 0;if(!_||!D||!S||S.id.indexOf(o.DataValidationType.LIST)!==0)return;const j=D.type===o.DataValidationType.LIST_MULTIPLE,$=S.getListWithColor(D,s,d),A=g||E.getDataValidationCellValue(n.getCellRaw(i,r)),T=E.deserializeListOptions(A),F=()=>{m.executeCommand(_e.id,{ruleId:D.uid}),a()},N=$.map(q=>({label:q.label,value:q.label,color:O||q.color?q.color:"transparent"}));return h.jsx(Rn,{style:{minWidth:M,maxWidth:Math.max(M,200)},title:j?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:T,multiple:j,onChange:async q=>{const ee=E.serializeListOptions(q),te={unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:ee,p:null,f:null,si:null}};I.isVisible()&&I.changeVisible({visible:!1,keycode:z.KeyCode.ESC,eventType:B.DeviceInputEventType.Keyboard,unitId:s}),v(ee),j||a(),I.isVisible().visible&&await m.executeCommand(x.SetCellEditVisibleOperation.id,{visible:!1,eventType:B.DeviceInputEventType.Keyboard,unitId:s,keycode:z.KeyCode.ESC}),m.executeCommand(X.SetRangeValuesCommand.id,te)},options:N,onEdit:F,filter:u,location:t})}const rt={dataValidationOptionsButton:"univer-data-validation-options-button",dataValidationOptionsButtonIcon:"univer-data-validation-options-button-icon"};function bn(e){var u;const t=o.useDependency(o.LocaleService),a=o.useDependency(z.ComponentManager),{value:n,onChange:i,extraComponent:r}=e,[s,d]=f.useState(!1),l=r?a.get(r):null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:rt.dataValidationOptionsButton,onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?h.jsx(Lt,{className:rt.dataValidationOptionsButtonIcon}):h.jsx(Ot,{className:rt.dataValidationOptionsButtonIcon})]}),s&&h.jsxs(h.Fragment,{children:[l?h.jsx(l,{value:n,onChange:i}):null,h.jsx(b.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:h.jsxs(b.RadioGroup,{value:`${(u=n.errorStyle)!=null?u:o.DataValidationErrorStyle.WARNING}`,onChange:p=>i({...n,errorStyle:+p}),children:[h.jsx(b.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),h.jsx(b.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),h.jsx(b.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:h.jsx(b.Checkbox,{checked:n.showErrorMessage,onChange:()=>i({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?h.jsx(b.FormLayout,{children:h.jsx(b.Input,{value:n.error,onChange:p=>i({...n,error:p})})}):null]})]})}const ye={dataValidationDetail:"univer-data-validation-detail",dataValidationDetailFormItem:"univer-data-validation-detail-form-item",dataValidationDetailButtons:"univer-data-validation-detail-buttons",dataValidationDetailButton:"univer-data-validation-detail-button"},On=e=>o.debounce(async(t,a,n,i)=>{const r=await e.executeCommand(t,a,n);i==null||i(r)},1e3);function Ln(e,t,a){var n,i,r,s;return t?((i=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:i.getSheetId())||"":((s=(r=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Tn(){var de;const[e,t]=f.useState(0),a=o.useDependency(ue),n=z.useObservable(a.activeRule$,a.activeRule),{unitId:i,subUnitId:r,rule:s}=n||{},d=s.uid,l=o.useDependency(J.DataValidatorRegistryService),u=o.useDependency(o.IUniverInstanceService),p=o.useDependency(z.ComponentManager),m=o.useDependency(o.ICommandService),c=o.useDependency(J.DataValidationModel),g=o.useDependency(o.LocaleService),[v,I]=f.useState(s),w=l.getValidatorItem(v.type),[C,V]=f.useState(!1),y=l.getValidatorsByScope(J.DataValidatorRegistryScope.SHEET),[M,D]=f.useState(()=>v.ranges.map(P=>({unitId:"",sheetId:"",range:P}))),S=f.useMemo(()=>On(m),[m]),[_,O]=f.useState(!1),j=f.useRef({}),[$,A]=f.useState(!1),T=o.useDependency(X.SheetsSelectionsService);if(f.useEffect(()=>()=>{const P=T.getCurrentLastSelection();P&&T.setSelections([P])},[T]),f.useEffect(()=>{m.onCommandExecuted(P=>{(P.id===o.UndoCommand.id||P.id===o.RedoCommand.id)&&setTimeout(()=>{const R=c.getRuleById(i,r,d);t(W=>W+1),R&&(I(R),D(R.ranges.map(W=>({unitId:"",sheetId:"",range:W}))))},20)})},[m,c,d,r,i]),!w)return null;const F=w.operators,N=w.operatorNames,U=v.operator?J.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,k=()=>{!v.ranges.length||_||(w.validatorFormula(v,i,r).success?a.setActiveRule(null):V(!0))},G=z.useEvent(P=>{const R=P.split(",").map(Qe.deserializeRangeWithSheet).map(K=>{const ge=K.sheetName;if(ge){const ei=Ln(u,K.unitId,ge);return{...K,sheetId:ei}}return{...K,sheetId:""}});if(o.isUnitRangesEqual(R,M))return;D(R);const W=R.filter(K=>(!K.unitId||K.unitId===i)&&(!K.sheetId||K.sheetId===r)).map(K=>K.range);if(I({...v,ranges:W}),W.length===0)return;const H={unitId:i,subUnitId:r,ruleId:d,ranges:W};S(E.UpdateSheetDataValidationRangeCommand.id,H)}),Z=P=>{if(o.shallowEqual(P,J.getRuleSetting(v)))return;I({...v,...P});const R={unitId:i,subUnitId:r,ruleId:d,setting:P};S(E.UpdateSheetDataValidationSettingCommand.id,R,void 0)},q=async()=>{await m.executeCommand(E.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:i,subUnitId:r}),a.setActiveRule(null)},ee={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},te=P=>{const R=l.getValidatorItem(P);if(!R)return;const W=R.operators,H=c.getRuleById(i,r,d),K=P===(H==null?void 0:H.type)||P.includes("list")&&(H!=null&&H.type.includes("list"))?{...H,type:P}:{...v,type:P,operator:W[0],formula1:void 0,formula2:void 0};I(K),m.executeCommand(E.UpdateSheetDataValidationSettingCommand.id,{unitId:i,subUnitId:r,ruleId:v.uid,setting:J.getRuleSetting(K)})},ae=p.get(w.formulaInput),ie=f.useMemo(()=>M.map(P=>Qe.serializeRange(P.range)).join(","),[]),le=J.getRuleOptions(v),oe=P=>{o.shallowEqual(P,J.getRuleOptions(v))||(I({...v,...P}),S(E.UpdateSheetDataValidationOptionsCommand.id,{unitId:i,subUnitId:r,ruleId:d,options:P}))};return z.useSidebarClick(P=>{var W;const R=(W=j.current)==null?void 0:W.handleOutClick;R&&R(P,()=>A(!1))}),h.jsxs("div",{className:ye.dataValidationDetail,children:[h.jsx(b.FormLayout,{label:g.t("dataValidation.panel.range"),error:!v.ranges.length||_?g.t("dataValidation.panel.rangeError"):"",children:h.jsx(et.RangeSelector,{unitId:i,subUnitId:r,initValue:ie,onChange:G,onFocus:()=>A(!0),isFocus:$,actions:j.current,onVerify:P=>O(!P)})}),h.jsx(b.FormLayout,{label:g.t("dataValidation.panel.type"),children:h.jsx(b.Select,{options:y==null?void 0:y.map(P=>({label:g.t(P.title),value:P.id})),value:v.type,onChange:te,className:ye.dataValidationDetailFormItem})}),F!=null&&F.length?h.jsx(b.FormLayout,{label:g.t("dataValidation.panel.operator"),children:h.jsx(b.Select,{options:F.map((P,R)=>({value:`${P}`,label:N[R]})),value:`${v.operator}`,onChange:P=>{Z({...ee,operator:P})},className:ye.dataValidationDetailFormItem})}):null,ae?h.jsx(ae,{isTwoFormula:U,value:{formula1:v.formula1,formula2:v.formula2},onChange:P=>{Z({...ee,...P})},showError:C,validResult:w.validatorFormula(v,i,r),unitId:i,subUnitId:r,ruleId:d},e+v.type):null,h.jsx(b.FormLayout,{children:h.jsx(b.Checkbox,{checked:(de=v.allowBlank)!=null?de:!0,onChange:()=>{var P;return Z({...ee,allowBlank:!((P=v.allowBlank)==null||P)})},children:g.t("dataValidation.panel.allowBlank")})}),h.jsx(bn,{value:le,onChange:oe,extraComponent:w.optionsInput}),h.jsxs("div",{className:ye.dataValidationDetailButtons,children:[h.jsx(b.Button,{className:ye.dataValidationDetailButton,onClick:q,children:g.t("dataValidation.panel.removeRule")}),h.jsx(b.Button,{className:ye.dataValidationDetailButton,type:"primary",onClick:k,children:g.t("dataValidation.panel.done")})]})]})}const xe={dataValidationItemContainer:"univer-data-validation-item-container",dataValidationItemTitle:"univer-data-validation-item-title",dataValidationItemContent:"univer-data-validation-item-content",dataValidationItemIcon:"univer-data-validation-item-icon"},Pn=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:i,disable:r}=e,s=o.useDependency(J.DataValidatorRegistryService),d=o.useDependency(o.ICommandService),l=o.useDependency(x.IMarkSelectionService),u=s.getValidatorItem(t.type),p=f.useRef(),[m,c]=f.useState(!1),g=v=>{d.executeCommand(E.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:i}),v.stopPropagation()};return f.useEffect(()=>()=>{var v;p.current&&((v=p.current)==null||v.forEach(I=>{I&&l.removeShape(I)}))},[l]),h.jsxs("div",{className:xe.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{r||(c(!0),p.current=t.ranges.map(v=>l.addShape({range:v,style:{fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:null})))},onMouseLeave:()=>{var v;c(!1),(v=p.current)==null||v.forEach(I=>{I&&l.removeShape(I)}),p.current=void 0},children:[h.jsx("div",{className:xe.dataValidationItemTitle,children:u==null?void 0:u.generateRuleName(t)}),h.jsx("div",{className:xe.dataValidationItemContent,children:t.ranges.map(v=>Qe.serializeRange(v)).join(",")}),m?h.jsx("div",{className:xe.dataValidationItemIcon,onClick:g,children:h.jsx(nt,{})}):null]})},Ne={dataValidationList:"univer-data-validation-list",dataValidationListButtons:"univer-data-validation-list-buttons",dataValidationListButton:"univer-data-validation-list-button"};function jn(){const e=o.useDependency(o.IUniverInstanceService),t=z.useObservable(()=>e.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return t?h.jsx(An,{workbook:t}):null}function An(e){const t=o.useDependency(E.SheetDataValidationModel),a=o.useDependency(o.IUniverInstanceService),n=o.useDependency(o.ICommandService),i=o.useDependency(o.Injector),r=o.useDependency(ue),s=o.useDependency(o.LocaleService),[d,l]=f.useState([]),{workbook:u}=e,p=z.useObservable(u.activeSheet$,void 0,!0),m=u.getUnitId(),c=p==null?void 0:p.getSheetId();f.useEffect(()=>{l(t.getRules(m,c));const V=t.ruleChange$.subscribe(y=>{y.unitId===m&&y.subUnitId===c&&l(t.getRules(m,c))});return()=>{V.unsubscribe()}},[m,c,t]);const g=async()=>{const V=E.createDefaultNewRule(i),y={unitId:m,subUnitId:c,rule:V};await n.executeCommand(E.AddSheetDataValidationCommand.id,y),r.setActiveRule({unitId:m,subUnitId:c,rule:V})},v=()=>{n.executeCommand(E.RemoveSheetAllDataValidationCommand.id,{unitId:m,subUnitId:c})},w=(V=>{const y=a.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),M=y.getActiveSheet(),D=y.getUnitId(),S=M.getSheetId();return V.map(O=>X.checkRangesEditablePermission(i,D,S,O.ranges)?{...O}:{...O,disable:!0})})(d),C=w==null?void 0:w.some(V=>V.disable);return h.jsxs("div",{className:Ne.dataValidationList,children:[w==null?void 0:w.map(V=>{var y;return h.jsx(Pn,{unitId:m,subUnitId:c,onClick:()=>{V.disable||r.setActiveRule({unitId:m,subUnitId:c,rule:V})},rule:V,disable:(y=V.disable)!=null?y:!1},V.uid)}),h.jsxs("div",{className:Ne.dataValidationListButtons,children:[d.length&&!C?h.jsx(b.Button,{className:Ne.dataValidationListButton,onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,h.jsx(b.Button,{className:Ne.dataValidationListButton,type:"primary",onClick:g,children:s.t("dataValidation.panel.add")})]})]})}const Fn=()=>{const e=o.useDependency(ue),t=z.useObservable(e.activeRule$,e.activeRule);return t?h.jsx(Tn,{},t.rule.uid):h.jsx(jn,{})},Ue="data-validation.list.dropdown",st="data-validation.date.dropdown",Be={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),a=X.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:i}=a,r=E.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=i.getSheetId(),u={rule:r,unitId:d,subUnitId:l};return s.syncExecuteCommand(E.AddSheetDataValidationCommand.id,u)?(s.syncExecuteCommand(_e.id,{ruleId:r.uid,isAdd:!0}),!0):!1}};var xn=Object.defineProperty,Nn=Object.getOwnPropertyDescriptor,Un=(e,t,a,n)=>{for(var i=n>1?void 0:n?Nn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&xn(t,a,i),i},we=(e,t)=>(a,n)=>t(a,n,e);const ke="SHEET_DATA_VALIDATION_ALERT";let je=class extends o.Disposable{constructor(e,t,a,n,i,r){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=i,this._dataValidationModel=r,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(re.debounceTime(100)).subscribe(e=>{var t;if(e){if(!this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET).getActiveSheet())return;const i=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!i)return;if(this._dataValidationModel.validator(i,e.location)===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(ke),d=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(d&&d.row===e.location.row&&d.col===e.location.col&&d.subUnitId===e.location.subUnitId&&d.unitId===e.location.unitId)return;const l=this._dataValidationModel.getValidator(i.type);if(!l)return;this._cellAlertManagerService.showAlert({type:x.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(i,e.location),location:e.location,width:200,height:74,key:ke});return}}this._cellAlertManagerService.removeAlert(ke)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(ke)}))}};je=Un([we(0,o.Inject(x.HoverManagerService)),we(1,o.Inject(x.CellAlertManagerService)),we(2,o.IUniverInstanceService),we(3,o.Inject(o.LocaleService)),we(4,z.IZenZoneService),we(5,o.Inject(E.SheetDataValidationModel))],je);var Bn=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,Wn=(e,t,a,n)=>{for(var i=n>1?void 0:n?kn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Bn(t,a,i),i},lt=(e,t)=>(a,n)=>t(a,n,e);let Ve=class extends o.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,i)=>{const{source:r,target:s,unitId:d,subUnitId:l}=n,u=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),p=x.virtualizeDiscreteRanges([r,s]),[m,c]=p.ranges,{mapFunc:g}=p,v={row:m.startRow,col:m.startColumn},I=x.getAutoFillRepeatRange(m,c),w=new o.ObjectMatrix,C=new Set;I.forEach(S=>{const _=S.repeatStartCell,O=S.relativeRange,j={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},$={startRow:_.row,startColumn:_.col,endColumn:_.col,endRow:_.row};o.Range.foreach(O,(A,T)=>{const F=o.Rectangle.getPositionRange({startRow:A,startColumn:T,endColumn:T,endRow:A},j),{row:N,col:U}=g(F.startRow,F.startColumn),k=this._sheetDataValidationModel.getRuleIdByLocation(d,l,N,U)||"",G=o.Rectangle.getPositionRange({startRow:A,startColumn:T,endColumn:T,endRow:A},$),{row:Z,col:q}=g(G.startRow,G.startColumn);w.setValue(Z,q,k),C.add(k)})});const V=Array.from(C).map(S=>({id:S,ranges:o.queryObjectMatrix(w,_=>_===S)}));u.addRangeRules(V);const y=u.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:M,undoMutations:D}=E.getDataValidationDiffMutations(d,l,y,this._injector,"patched",i===x.APPLY_TYPE.ONLY_FORMAT);return{undos:D,redos:M}},a={id:E.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:i,unitId:r,subUnitId:s}=n;for(const d of i.rows)for(const l of i.cols){const u=this._sheetDataValidationModel.getRuleByLocation(r,s,d,l);if(u&&u.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(x.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,i,r)=>r===x.APPLY_TYPE.COPY||r===x.APPLY_TYPE.ONLY_FORMAT||r===x.APPLY_TYPE.SERIES?t(n,r):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};Ve=Wn([lt(0,x.IAutoFillService),lt(1,o.Inject(E.SheetDataValidationModel)),lt(2,o.Inject(o.Injector))],Ve);var $n=Object.defineProperty,Hn=Object.getOwnPropertyDescriptor,Yn=(e,t,a,n)=>{for(var i=n>1?void 0:n?Hn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&$n(t,a,i),i},dt=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends o.Disposable{constructor(t,a,n){super();L(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:E.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,i)=>{const{copyType:r=x.COPY_TYPE.COPY,pasteType:s}=i,{range:d}=t||{},{range:l,unitId:u,subUnitId:p}=a;return this._generateMutations(l,{copyType:r,pasteType:s,copyRange:d,unitId:u,subUnitId:p})}})}_collect(t,a,n){const i=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:i};const r=this._injector.invoke(l=>x.rangeToDiscreteRange(n,l,t,a));if(!r)return;const{rows:s,cols:d}=r;s.forEach((l,u)=>{d.forEach((p,m)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(t,a,l,p);i.setValue(u,m,c!=null?c:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===x.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([x.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,x.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,x.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,x.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:n,subUnitId:i}=this._copyInfo;if(a.unitId!==n||i!==a.subUnitId){const r=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),s=new o.ObjectMatrix,d=new Set,{ranges:[l,u],mapFunc:p}=x.virtualizeDiscreteRanges([a.copyRange,t]),m=x.getRepeatRange(l,u,!0),c=new Map;m.forEach(({startRange:w})=>{var C;(C=this._copyInfo)==null||C.matrix.forValue((V,y,M)=>{const D=o.Rectangle.getPositionRange({startRow:V,endRow:V,startColumn:y,endColumn:y},w),S=`${i}-${M}`,_=this._sheetDataValidationModel.getRuleById(n,i,M);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,S)&&_&&c.set(S,{..._,uid:S});const{row:O,col:j}=p(D.startRow,D.startColumn);d.add(S),s.setValue(O,j,S)})});const g=Array.from(d).map(w=>({id:w,ranges:o.queryObjectMatrix(s,C=>C===w)}));r.addRangeRules(g);const{redoMutations:v,undoMutations:I}=E.getDataValidationDiffMutations(a.unitId,a.subUnitId,r.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),c.values()),this._injector,"patched",!1);return{redos:v,undos:I}}else{const r=this._sheetDataValidationModel.getRuleObjectMatrix(n,i).clone(),s=new o.ObjectMatrix,d=new Set,{ranges:[l,u],mapFunc:p}=x.virtualizeDiscreteRanges([a.copyRange,t]);x.getRepeatRange(l,u,!0).forEach(({startRange:I})=>{var w;(w=this._copyInfo)==null||w.matrix.forValue((C,V,y)=>{const M=o.Rectangle.getPositionRange({startRow:C,endRow:C,startColumn:V,endColumn:V},I),{row:D,col:S}=p(M.startRow,M.startColumn);s.setValue(D,S,y),d.add(y)})});const c=Array.from(d).map(I=>({id:I,ranges:o.queryObjectMatrix(s,w=>w===I)}));r.addRangeRules(c);const{redoMutations:g,undoMutations:v}=E.getDataValidationDiffMutations(n,i,r.diff(this._sheetDataValidationModel.getRules(n,i)),this._injector,"patched",!1);return{redos:g,undos:v}}}};Ee=Yn([dt(0,x.ISheetClipboardService),dt(1,o.Inject(E.SheetDataValidationModel)),dt(2,o.Inject(o.Injector))],Ee);var Xn=Object.defineProperty,zn=Object.getOwnPropertyDescriptor,Kn=(e,t,a,n)=>{for(var i=n>1?void 0:n?zn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Xn(t,a,i),i},ct=(e,t)=>(a,n)=>t(a,n,e);let Re=class extends o.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionInterceptorBaseController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===E.AddSheetDataValidationCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission,X.WorksheetSetCellStylePermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr"))),e.id===E.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission,X.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr")))}))}};Re=Kn([ct(0,o.Inject(o.LocaleService)),ct(1,o.ICommandService),ct(2,o.Inject(x.SheetPermissionInterceptorBaseController))],Re);const Nt="data-validation-single",Ut="sheet.menu.data-validation";function qn(e){return{id:Ut,type:z.MenuItemType.SUBITEMS,icon:Nt,tooltip:"dataValidation.title",hidden$:z.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:x.getCurrentRangeDisable$(e,{workbookTypes:[X.WorkbookEditablePermission],worksheetTypes:[X.WorksheetSetCellStylePermission,X.WorksheetEditPermission],rangeTypes:[X.RangeProtectionPermissionEditPoint]})}}function Gn(e){return{id:_e.id,title:"dataValidation.panel.title",type:z.MenuItemType.BUTTON}}function Zn(e){return{id:Be.id,title:"dataValidation.panel.add",type:z.MenuItemType.BUTTON}}const Jn={[z.RibbonStartGroup.FORMULAS_INSERT]:{[Ut]:{order:9,menuItemFactory:qn,[_e.id]:{order:0,menuItemFactory:Gn},[Be.id]:{order:1,menuItemFactory:Zn}}}};var Qn=Object.defineProperty,ea=Object.getOwnPropertyDescriptor,Bt=(e,t,a,n)=>{for(var i=n>1?void 0:n?ea(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Qn(t,a,i),i},Q=(e,t)=>(a,n)=>t(a,n,e);const kt={tr:{size:6,color:"#fe4b4b"}};let Me=class extends o.RxDisposable{constructor(e,t,a,n,i,r,s,d,l,u,p){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=i,this._dropdownManagerService=r,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=u,this._editorBridgeService=p,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Jn)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var a;if(!e.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:i,row:r,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,i,r,s);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(u!=null&&u.dropdown))return;const p=d.getActiveSheet();if(!p)return;const m=this._dropdownManagerService.activeDropdown,c=m==null?void 0:m.location;if(c&&c.unitId===n&&c.subUnitId===i&&c.row===r&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:i,row:r,col:s,workbook:d,worksheet:p},componentKey:u.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var C,V,y,M,D;const{row:n,col:i,unitId:r,subUnitId:s,workbook:d,worksheet:l}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!u)return a(e);const p=this._sheetDataValidationModel.getRuleById(r,s,u);if(!p)return a(e);const m=(C=this._dataValidationCacheService.getValue(r,s,n,i))!=null?C:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),g=t.rawData;let v;const I={get value(){var S;return v!==void 0||(v=(S=E.getCellValueOrigin(g))!=null?S:null),v}},w={get value(){var S;return`${(S=I.value)!=null?S:""}`}};return a({...e,markers:{...e==null?void 0:e.markers,...m===o.DataValidationStatus.INVALID?kt:null},customRender:[...(V=e==null?void 0:e.customRender)!=null?V:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((M=c==null?void 0:c.skipDefaultFontRender)==null?void 0:M.call(c,p,I.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,w.value,{get style(){const S=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?S.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,i)},interceptorAutoHeight:()=>{var j,$,A,T,F,N;const S=($=(j=this._renderManagerService.getRenderById(r))==null?void 0:j.with(x.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:$.skeleton;if(!S)return;const _=S.worksheet.getMergedCell(n,i),O={data:e,style:S.getsStyles().getStyleByCell(e),primaryWithCoord:S.getCellWithCoordByIndex((A=_==null?void 0:_.startRow)!=null?A:n,(T=_==null?void 0:_.startColumn)!=null?T:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(N=(F=c==null?void 0:c.canvasRender)==null?void 0:F.calcCellAutoHeight)==null?void 0:N.call(F,O)},interceptorAutoWidth:()=>{var j,$,A,T,F,N;const S=($=(j=this._renderManagerService.getRenderById(r))==null?void 0:j.with(x.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:$.skeleton;if(!S)return;const _=S.worksheet.getMergedCell(n,i),O={data:e,style:S.getsStyles().getStyleByCell(e),primaryWithCoord:S.getCellWithCoordByIndex((A=_==null?void 0:_.startRow)!=null?A:n,(T=_==null?void 0:_.startColumn)!=null?T:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(N=(F=c==null?void 0:c.canvasRender)==null?void 0:F.calcCellAutoWidth)==null?void 0:N.call(F,O)},coverable:((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(p.type===o.DataValidationType.LIST||p.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(re.filter(e=>e.source==="command"),re.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};Me=Bt([Q(0,o.ICommandService),Q(1,z.IMenuManagerService),Q(2,B.IRenderManagerService),Q(3,o.IUniverInstanceService),Q(4,o.Inject(x.AutoHeightController)),Q(5,o.Inject(fe)),Q(6,o.Inject(E.SheetDataValidationModel)),Q(7,o.Inject(J.DataValidatorRegistryService)),Q(8,o.Inject(X.SheetInterceptorService)),Q(9,o.Inject(E.DataValidationCacheService)),Q(10,o.Optional(x.IEditorBridgeService))],Me);let Wt=class extends o.RxDisposable{constructor(e,t,a,n,i,r,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=i,this._sheetDataValidationModel=r,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var w,C,V,y,M;const{row:n,col:i,unitId:r,subUnitId:s,workbook:d,worksheet:l}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!u)return a(e);const p=this._sheetDataValidationModel.getRuleById(r,s,u);if(!p)return a(e);const m=(w=this._dataValidationCacheService.getValue(r,s,n,i))!=null?w:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),g=l.getCellRaw(n,i),v=E.getCellValueOrigin(g),I=`${v!=null?v:""}`;return a({...e,markers:{...e==null?void 0:e.markers,...m===o.DataValidationStatus.INVALID?kt:null},customRender:[...(C=e==null?void 0:e.customRender)!=null?C:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((V=e==null?void 0:e.fontRenderExtension)==null?void 0:V.isSkip)||((y=c==null?void 0:c.skipDefaultFontRender)==null?void 0:y.call(c,p,v,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,I,{get style(){const D=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?D.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,i)},interceptorAutoHeight:()=>{var O,j,$,A,T,F;const D=(j=(O=this._renderManagerService.getRenderById(r))==null?void 0:O.with(x.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:j.skeleton;if(!D)return;const S=D.worksheet.getMergedCell(n,i),_={data:e,style:D.getsStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex(($=S==null?void 0:S.startRow)!=null?$:n,(A=S==null?void 0:S.startColumn)!=null?A:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(F=(T=c==null?void 0:c.canvasRender)==null?void 0:T.calcCellAutoHeight)==null?void 0:F.call(T,_)},coverable:((M=e==null?void 0:e.coverable)!=null?M:!0)&&!(p.type===o.DataValidationType.LIST||p.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(re.filter(e=>e.source==="command"),re.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};Wt=Bt([Q(0,o.ICommandService),Q(1,B.IRenderManagerService),Q(2,o.Inject(x.AutoHeightController)),Q(3,o.Inject(J.DataValidatorRegistryService)),Q(4,o.Inject(X.SheetInterceptorService)),Q(5,o.Inject(E.SheetDataValidationModel)),Q(6,o.Inject(E.DataValidationCacheService))],Wt);var ta=Object.defineProperty,na=Object.getOwnPropertyDescriptor,aa=(e,t,a,n)=>{for(var i=n>1?void 0:n?na(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&ta(t,a,i),i},$t=(e,t)=>(a,n)=>t(a,n,e);let We=class extends o.Disposable{constructor(e,t,a){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const a=new Set;t.forEach(i=>{a.add(i.subUnitId)}),a.forEach(i=>{var r;(r=this._sheetSkeletonManagerService.getWorksheetSkeleton(i))==null||r.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};We=aa([$t(1,o.Inject(E.SheetDataValidationModel)),$t(2,o.Inject(x.SheetSkeletonManagerService))],We);const ne={dataValidationFormula:"univer-data-validation-formula",dataValidationFormulaAnd:"univer-data-validation-formula-and",dataValidationFormulaListItem:"univer-data-validation-formula-list-item",dataValidationFormulaListItemIcon:"univer-data-validation-formula-list-item-icon",dataValidationFormulaListItemDrag:"univer-data-validation-formula-list-item-drag",dataValidationFormulaListAdd:"univer-data-validation-formula-list-add",dataValidationFormulaColorSelect:"univer-data-validation-formula-color-select",dataValidationFormulaColorSelectPanel:"univer-data-validation-formula-color-select-panel",dataValidationFormulaColorItem:"univer-data-validation-formula-color-item"},ia=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:i,validResult:r}=e,s=o.useDependency(o.LocaleService),d=i?r==null?void 0:r.formula1:"",l=i?r==null?void 0:r.formula2:"";return t?h.jsxs(h.Fragment,{children:[h.jsx(b.FormLayout,{error:d,children:h.jsx(b.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({...a,formula1:u})}})}),h.jsx("div",{className:ne.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),h.jsx(b.FormLayout,{error:l,children:h.jsx(b.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:u=>{n==null||n({...a,formula2:u})}})})]}):h.jsx(b.FormLayout,{error:d,children:h.jsx(b.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({formula1:u})}})})};function oa(e){const{value:t,onChange:a,showError:n,validResult:i}=e,r=o.useDependency(o.LocaleService),s=n?i==null?void 0:i.formula1:"",d=n?i==null?void 0:i.formula2:"",[l,u]=f.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return h.jsxs(h.Fragment,{children:[h.jsx(b.FormLayout,{children:h.jsx(b.Checkbox,{checked:l,onChange:p=>{p?u(!0):(u(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:r.t("dataValidation.checkbox.tips")})}),l?h.jsx(b.FormLayout,{label:r.t("dataValidation.checkbox.checked"),error:s,children:h.jsx(b.Input,{className:ne.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:p=>{a==null||a({...t,formula1:p||void 0})}})}):null,l?h.jsx(b.FormLayout,{label:r.t("dataValidation.checkbox.unchecked"),error:d,children:h.jsx(b.Input,{className:ne.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:p=>{a==null||a({...t,formula2:p||void 0})}})}):null]})}function ra(e){var m;const{unitId:t,subUnitId:a,value:n,onChange:i,showError:r,validResult:s}=e,d=r?s==null?void 0:s.formula1:void 0,l=f.useRef({}),[u,p]=f.useState(!1);return z.useSidebarClick(c=>{var v;const g=(v=l.current)==null?void 0:v.handleOutClick;g&&g(c,()=>p(!1))}),h.jsx(et.FormulaEditor,{initValue:(m=n==null?void 0:n.formula1)!=null?m:"",unitId:t,subUnitId:a,isFocus:u,onChange:c=>{const g=(c!=null?c:"").trim();g!==(n==null?void 0:n.formula1)&&(i==null||i({...n,formula1:g}))},errorText:d,onFocus:()=>p(!0),actions:l.current,isSupportAcrossSheet:!0})}function Ht(e){var t,a,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(a=Ht(e[t]))&&(n&&(n+=" "),n+=a)}else for(a in e)e[a]&&(n&&(n+=" "),n+=a);return n}function sa(){for(var e,t,a=0,n="",i=arguments.length;a<i;a++)(e=arguments[a])&&(t=Ht(e))&&(n&&(n+=" "),n+=t);return n}const la=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],da=e=>{const{value:t,onChange:a,disabled:n}=e,[i,r]=f.useState(!1);return h.jsx(b.Select,{disabled:n,open:i,onDropdownVisibleChange:r,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ne.dataValidationFormulaColorSelect,value:t,onChange:a,labelRender:s=>h.jsx("div",{className:ne.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>h.jsx("div",{className:ne.dataValidationFormulaColorSelectPanel,children:la.map(s=>h.jsx("div",{onClick:()=>{a(s),r(!1)},className:ne.dataValidationFormulaColorItem,style:{background:s}},s))})})},Yt=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:i,onItemDelete:r}=a;return h.jsxs("div",{className:ne.dataValidationFormulaListItem,style:n,children:[t.isRef?null:h.jsx("div",{className:sa(ne.dataValidationFormulaListItemDrag,"draggableHandle"),children:h.jsx(Tt,{})}),h.jsx(da,{value:t.color,onChange:s=>{i(t.id,t.label,s)}}),h.jsx(b.Input,{disabled:t.isRef,value:t.label,onChange:s=>{i(t.id,s,t.color)}}),t.isRef?null:h.jsx("div",{className:ne.dataValidationFormulaListItemIcon,children:h.jsx(nt,{onClick:()=>r(t.id)})})]})};function ca(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:i,validResult:r,showError:s,ruleId:d}=e,{formula1:l="",formula2:u=""}=t||{},p=f.useRef(null),[m,c]=f.useState(()=>o.isFormulaString(l)?"1":"0"),[g,v]=f.useState(m==="1"?l:"="),[I,w]=f.useState(m==="1"?l:"="),C=o.useDependency(o.LocaleService),V=o.useDependency(J.DataValidatorRegistryService),y=o.useDependency(J.DataValidationModel),M=o.useDependency(E.DataValidationFormulaController),[D,S]=f.useState(()=>u.split(",")),_=V.getValidatorItem(o.DataValidationType.LIST),[O,j]=f.useState([]),[$,A]=f.useState(""),T=s?r==null?void 0:r.formula1:"",F=f.useMemo(()=>y.ruleChange$.pipe(re.debounceTime(16)),[]),N=z.useObservable(F),U=z.useEvent(a);f.useEffect(()=>{(async()=>{await new Promise(H=>{setTimeout(()=>H(!0),100)});const R=y.getRuleById(n,i,d),W=R==null?void 0:R.formula1;if(o.isFormulaString(W)&&_&&R){const H=await _.getListAsync(R,n,i);j(H)}})()},[y,N,_,d,i,n]),f.useEffect(()=>{o.isFormulaString(l)&&l!==I&&(v(l),w(I))},[I,l]);const[k,G]=f.useState(()=>{const R=m!=="1"?E.deserializeListOptions(l):[],W=u.split(",");return R.map((H,K)=>({label:H,color:W[K]||Ie,isRef:!1,id:o.Tools.generateRandomId(4)}))}),Z=(R,W,H)=>{const K=k.find(ge=>ge.id===R);K&&(K.label=W,K.color=H,G([...k]))},q=R=>{const W=k.findIndex(H=>H.id===R);W!==-1&&(k.splice(W,1),G([...k]))},ee=u.split(","),te=f.useMemo(()=>O.map((R,W)=>({label:R,color:ee[W]||Ie,id:`${W}`,isRef:!0})),[ee,O]),ae=(R,W,H)=>{const K=[...D];K[+R]=H,S(K),U({formula1:l,formula2:K.join(",")})},ie=()=>{G([...k,{label:"",color:Ie,isRef:!1,id:o.Tools.generateRandomId(4)}])};f.useEffect(()=>{if(m==="1")return;const R=new Set,W=[];k.map(H=>({labelList:H.label.split(","),item:H})).forEach(({item:H,labelList:K})=>{K.forEach(ge=>{R.has(ge)||(R.add(ge),W.push({label:ge,color:H.color}))})}),U({formula1:E.serializeListOptions(W.map(H=>H.label)),formula2:W.map(H=>H.color===Ie?"":H.color).join(",")})},[k,U,m,I,D]);const le=f.useMemo(()=>async R=>{if(!o.isFormulaString(R)){U==null||U({formula1:"",formula2:u});return}M.getFormulaRefCheck(R)?(U==null||U({formula1:o.isFormulaString(R)?R:"",formula2:u}),A("")):(U==null||U({formula1:"",formula2:u}),v("="),A(C.t("dataValidation.validFail.formulaError")))},[u,U]),oe=f.useRef({}),[de,P]=f.useState(!1);return z.useSidebarClick(R=>{var H;const W=(H=oe.current)==null?void 0:H.handleOutClick;W&&W(R,()=>P(!1))}),h.jsxs(h.Fragment,{children:[h.jsx(b.FormLayout,{label:C.t("dataValidation.list.options"),children:h.jsxs(b.RadioGroup,{value:m,onChange:R=>{c(R),v(I),R==="1"&&U({formula1:I==="="?"":I,formula2:D.join(",")})},children:[h.jsx(b.Radio,{value:"0",children:C.t("dataValidation.list.customOptions")}),h.jsx(b.Radio,{value:"1",children:C.t("dataValidation.list.refOptions")})]})}),m==="1"?h.jsxs(h.Fragment,{children:[h.jsx(et.FormulaEditor,{initValue:g,unitId:n,subUnitId:i,isFocus:de,onChange:(R="")=>{const W=(R!=null?R:"").trim();w(W),le(W)},errorText:T||$||void 0,onFocus:()=>P(!0),actions:oe.current,isSupportAcrossSheet:!0}),h.jsx("div",{ref:p,style:{marginTop:"12px"},children:te.map(R=>h.jsx(Yt,{item:R,commonProps:{onItemChange:ae},style:{marginBottom:12}},R.id))})]}):h.jsx(b.FormLayout,{error:T,children:h.jsxs("div",{ref:p,style:{marginTop:"-12px"},children:[h.jsx(b.DraggableList,{list:k,onListChange:G,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:R=>h.jsx(Yt,{item:R,commonProps:{onItemChange:Z,onItemDelete:q}},R.id),idKey:"id"}),h.jsxs("a",{className:ne.dataValidationFormulaListAdd,onClick:ie,children:[h.jsx(bt,{}),C.t("dataValidation.list.add")]})]})})]})}const Xt="data-validation.custom-formula-input",$e="data-validation.formula-input",ut="data-validation.list-formula-input",zt="data-validation.checkbox-formula-input",ua=[[Xt,ra],[$e,ia],[ut,ca],[zt,oa]],pa="LIST_RENDER_MODE_OPTION_INPUT";function He(e){var i;const{value:t,onChange:a}=e,n=o.useDependency(o.LocaleService);return h.jsx(b.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:h.jsxs(b.RadioGroup,{value:`${(i=t.renderMode)!=null?i:o.DataValidationRenderMode.CUSTOM}`,onChange:r=>a({...t,renderMode:+r}),children:[h.jsx(b.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),h.jsx(b.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),h.jsx(b.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}He.componentKey=pa;const ha="DATE_SHOW_TIME_OPTION";function Ye(e){var i;const{value:t,onChange:a}=e,n=o.useDependency(o.LocaleService);return h.jsx(b.FormLayout,{children:h.jsx(b.Checkbox,{checked:(i=t.bizInfo)==null?void 0:i.showTime,onChange:r=>{a({...t,bizInfo:{...t.bizInfo,showTime:r}})},children:n.t("dataValidation.showTime.label")})})}Ye.componentKey=ha;var ma=Object.defineProperty,va=Object.getOwnPropertyDescriptor,fa=(e,t,a,n)=>{for(var i=n>1?void 0:n?va(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&ma(t,a,i),i},Ae=(e,t)=>(a,n)=>t(a,n,e);const Xe=6;let pt=class{constructor(e,t,a,n,i){this._commandService=e,this._formulaService=t,this._themeService=a,this._renderManagerService=n,this._dataValidationModel=i}_calc(e,t){var u,p,m;const{vt:a,ht:n}=t||{},i=e.endX-e.startX-Xe*2,r=e.endY-e.startY,s=((u=t==null?void 0:t.fs)!=null?u:10)*1.6;let d=0,l=0;switch(a){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(r-s);break;default:l=0+(r-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:d=Xe;break;case o.HorizontalAlign.RIGHT:d=Xe+(i-s);break;default:d=Xe+(i-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((p=t==null?void 0:t.fs)!=null?p:10)*1.6,height:((m=t==null?void 0:t.fs)!=null?m:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var u,p,m,c,g,v,I,w,C;const{formula1:n=E.CHECKBOX_FORMULA_1,formula2:i=E.CHECKBOX_FORMULA_2}=e,r=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=E.getFormulaResult((m=(p=(u=r==null?void 0:r[0])==null?void 0:u.result)==null?void 0:p[0])==null?void 0:m[0]),d=E.getFormulaResult((v=(g=(c=r==null?void 0:r[1])==null?void 0:c.result)==null?void 0:g[0])==null?void 0:v[0]),l=E.isLegalFormulaResult(String(s))&&E.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(n)?E.getFormulaResult((C=(w=(I=r==null?void 0:r[0])==null?void 0:I.result)==null?void 0:w[0])==null?void 0:C[0]):n,formula2:o.isFormulaString(i)?d:i,isFormulaValid:l}}drawWith(e,t){var T,F,N,U;const{style:a,primaryWithCoord:n,unitId:i,subUnitId:r,worksheet:s,row:d,col:l}=t,u=n.isMergedMainCell?n.mergeInfo:n,p=E.getCellValueOrigin(s.getCellRaw(d,l)),m=this._dataValidationModel.getRuleByLocation(i,r,d,l);if(!m)return;const c=this._dataValidationModel.getValidator(m.type);if(!c)return;const g=this._themeService.getCurrentTheme();if(!((T=c.skipDefaultFontRender)!=null&&T.call(c,m,p,{unitId:i,subUnitId:r,row:d,column:l})))return;const v=c.parseFormulaSync(m,i,r),{formula1:I}=v,w=this._calc(u,a),{a:C,d:V}=e.getTransform(),y=B.fixLineWidthByScale(w.left,C),M=B.fixLineWidthByScale(w.top,V),D=B.Transform.create().composeMatrix({left:y,top:M,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),S=u.endX-u.startX,_=u.endY-u.startY;e.save(),e.beginPath(),e.rect(u.startX,u.startY,S,_),e.clip();const O=D.getMatrix();e.transform(O[0],O[1],O[2],O[3],O[4],O[5]);const j=((F=a==null?void 0:a.fs)!=null?F:10)*1.6,$=String(p)===String(I),A=g.hyacinth500;B.CheckboxShape.drawWith(e,{checked:$,width:j,height:j,fill:(U=(N=a==null?void 0:a.cl)==null?void 0:N.rgb)!=null?U:A}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),i=n.top,r=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:u}=e;return l<=d&&l>=s&&u<=r&&u>=i}async onPointerDown(e,t){var v;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:i,worksheet:r,row:s,col:d}=e,l=E.getCellValueOrigin(r.getCellRaw(s,d)),u=this._dataValidationModel.getRuleByLocation(n,i,s,d);if(!u)return;const p=this._dataValidationModel.getValidator(u.type);if(!p||!((v=p.skipDefaultFontRender)!=null&&v.call(p,u,l,{unitId:n,subUnitId:i,row:s,column:d})))return;const{formula1:m,formula2:c}=await this._parseFormula(u,n,i),g={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(l)===E.transformCheckboxValue(String(m))?c:m,p:null}};this._commandService.executeCommand(X.SetRangeValuesCommand.id,g)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};pt=fa([Ae(0,o.ICommandService),Ae(1,o.Inject(E.DataValidationFormulaService)),Ae(2,o.Inject(o.ThemeService)),Ae(3,o.Inject(B.IRenderManagerService)),Ae(4,o.Inject(E.SheetDataValidationModel))],pt);var ga=Object.defineProperty,Sa=Object.getOwnPropertyDescriptor,_a=(e,t,a,n)=>{for(var i=n>1?void 0:n?Sa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&ga(t,a,i),i},Ia=(e,t)=>(a,n)=>t(a,n,e);let pe=class{constructor(e){L(this,"canvasRender",null);L(this,"dropdown");L(this,"optionsInput");L(this,"formulaInput",ut);this.injector=e}};pe=_a([Ia(0,o.Inject(o.Injector))],pe);class Ca extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CHECKBOX);L(this,"canvasRender",this.injector.createInstance(pt));L(this,"formulaInput",zt)}}class Da extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CUSTOM);L(this,"formulaInput",Xt)}}const ya="data-validation.formula-input";class wa extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DATE);L(this,"formulaInput",ya);L(this,"optionsInput",Ye.componentKey);L(this,"dropdown",st)}}class Va extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DECIMAL);L(this,"formulaInput",$e)}}const Kt=4,Ea=0,ht=4,qt=4,mt=6,ze=6,Ce=14;function Ra(e,t){const a=B.FontCache.getTextSize(e,t),n=a.width+Kt*2,{ba:i,bd:r}=a,s=i+r;return{width:n,height:s+Ea*2,ba:i}}function vt(e,t,a,n){const i=Ce+mt*2,r=a-i,s=n-ze*2,d=e.map(c=>({layout:Ra(c,t),text:c}));let l;const u=[];d.forEach(c=>{const{layout:g}=c,{width:v,height:I}=g;!l||l.width+v+ht>r?(l={width:v,height:I,items:[{...c,left:0}]},u.push(l)):(l.items.push({...c,left:l.width+ht}),l.width=l.width+v+ht)});let p=0,m=0;return u.forEach((c,g)=>{m=Math.max(m,c.width),g===u.length-1?p+=c.height:p+=c.height+qt}),{lines:u,totalHeight:p,contentWidth:r,contentHeight:s,cellAutoHeight:p+ze*2,calcAutoWidth:m+i}}const Ma=8;class ba extends B.Shape{static drawWith(t,a){const{fontString:n,info:i,fill:r,color:s}=a,{layout:d,text:l}=i;t.save(),B.Rect.drawWith(t,{width:d.width,height:d.height,radius:Ma,fill:r||Ie}),t.translateWithPrecision(Kt,d.ba),t.font=n,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var Oa=Object.defineProperty,La=Object.getOwnPropertyDescriptor,Ta=(e,t,a,n)=>{for(var i=n>1?void 0:n?La(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Oa(t,a,i),i},ft=(e,t)=>(a,n)=>t(a,n,e);const Pa=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let gt=class{constructor(e,t,a){L(this,"zIndex");L(this,"_dropdownInfoMap",new Map);this._commandService=e,this._renderManagerService=t,this._dataValidationModel=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,i){const r=a-Ce+4;let s=4;switch(i){case o.VerticalAlign.MIDDLE:s=(n-Ce)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-Ce+4;break}e.save(),e.translateWithPrecision(t.startX+r,t.startY+s),e.fillStyle="#565656",e.fill(Pa),e.restore()}drawWith(e,t,a,n){var Z,q;const{primaryWithCoord:i,row:r,col:s,style:d,data:l,subUnitId:u}=t,p=i.isMergedMainCell?i.mergeInfo:i,m=l==null?void 0:l.fontRenderExtension,{leftOffset:c=0,rightOffset:g=0,topOffset:v=0,downOffset:I=0}=m||{},w=this._ensureMap(u),C=this._generateKey(r,s),V=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,r,s);if(!V)return;const y=this._dataValidationModel.getValidator(V.type);if(!y)return;const M={startX:p.startX+c,endX:p.endX-g,startY:p.startY+v,endY:p.endY-I},D=M.endX-M.startX,S=M.endY-M.startY,{cl:_}=d||{},O=(Z=typeof _=="object"?_==null?void 0:_.rgb:_)!=null?Z:"#000",j=B.getFontStyleString(d!=null?d:void 0),{vt:$,ht:A}=d||{},T=$!=null?$:o.VerticalAlign.MIDDLE,F=(q=E.getCellValueOrigin(l))!=null?q:"",N=y.parseCellValue(F),U=y.getListWithColorMap(V),k=vt(N,j,D,S);this._drawDownIcon(e,M,D,S,T),e.save(),e.translateWithPrecision(M.startX,M.startY),e.beginPath(),e.rect(0,0,D-Ce,S),e.clip(),e.translateWithPrecision(mt,ze);let G=0;switch(T){case o.VerticalAlign.MIDDLE:G=(k.contentHeight-k.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:G=k.contentHeight-k.totalHeight;break}e.translateWithPrecision(0,G),k.lines.forEach((ee,te)=>{e.save();const{width:ae,height:ie,items:le}=ee;let oe=0;switch(A){case o.HorizontalAlign.RIGHT:oe=k.contentWidth-ae;break;case o.HorizontalAlign.CENTER:oe=(k.contentWidth-ae)/2;break}e.translate(oe,te*(ie+qt)),le.forEach(de=>{e.save(),e.translateWithPrecision(de.left,0),ba.drawWith(e,{...j,info:de,color:O,fill:U[de.text]}),e.restore()}),e.restore()}),e.restore(),w.set(C,{left:M.startX,top:M.startY,width:k.contentWidth+mt+Ce,height:k.contentHeight+ze*2})}calcCellAutoHeight(e){var D;const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:u=0,downOffset:p=0}=s||{},m=t.isMergedMainCell?t.mergeInfo:t,c={startX:m.startX+d,endX:m.endX-l,startY:m.startY+u,endY:m.endY-p},g=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!g)return;const v=this._dataValidationModel.getValidator(g.type);if(!v)return;const I=c.endX-c.startX,w=c.endY-c.startY,C=(D=E.getCellValueOrigin(n))!=null?D:"",V=v.parseCellValue(C),y=B.getFontStyleString(a!=null?a:void 0);return vt(V,y,I,w).cellAutoHeight}calcCellAutoWidth(e){var D;const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:u=0,downOffset:p=0}=s||{},m=t.isMergedMainCell?t.mergeInfo:t,c={startX:m.startX+d,endX:m.endX-l,startY:m.startY+u,endY:m.endY-p},g=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!g)return;const v=this._dataValidationModel.getValidator(g.type);if(!v)return;const I=c.endX-c.startX,w=c.endY-c.startY,C=(D=E.getCellValueOrigin(n))!=null?D:"",V=v.parseCellValue(C),y=B.getFontStyleString(a!=null?a:void 0);return vt(V,y,I,w).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:i}=n,{x:r}=e;return r>=i-Ce&&r<=i}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=e,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Fe.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};gt=Ta([ft(0,o.ICommandService),ft(1,o.Inject(B.IRenderManagerService)),ft(2,o.Inject(E.SheetDataValidationModel))],gt);class ja extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST_MULTIPLE);L(this,"canvasRender",this.injector.createInstance(gt));L(this,"dropdown",Ue)}}var Aa=Object.defineProperty,Fa=Object.getOwnPropertyDescriptor,xa=(e,t,a,n)=>{for(var i=n>1?void 0:n?Fa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Aa(t,a,i),i},Ke=(e,t)=>(a,n)=>t(a,n,e);const De=4,qe=4,ce=14,he=6,be=4,St=8,Na="#565656",Gt=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function Ua(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:o.BooleanNumber.FALSE,bl:o.BooleanNumber.FALSE,ul:{s:o.BooleanNumber.FALSE},st:{s:o.BooleanNumber.FALSE},ol:{s:o.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function Zt(e,t,a){const n=Ua(e,a),i=new o.DocumentDataModel(n),r=new B.DocumentViewModel(i);return{documentSkeleton:B.DocumentSkeleton.create(r,t),docModel:i,docViewModel:r}}function Ge(e,t,a){const{documentSkeleton:n,docModel:i,docViewModel:r}=Zt(e,t,a);return{documents:new B.Documents(`DOCUMENTS_${o.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:i,docViewModel:r}}function Jt(e,t,a,n,i,r,s=!0){let d=0;const l=s?be:0;switch(i){case o.VerticalAlign.BOTTOM:d=t-n-l;break;case o.VerticalAlign.MIDDLE:d=(t-n)/2;break;default:d=l;break}d=Math.max(be,d);let u=0;switch(r){case o.HorizontalAlign.CENTER:u=(e-a)/2;break;case o.HorizontalAlign.RIGHT:u=e-a;break}return u=Math.max(he,u),{paddingLeft:u,paddingTop:d}}let _t=class{constructor(e,t,a,n){L(this,"_dropdownInfoMap",new Map);L(this,"zIndex");this._localeService=e,this._commandService=t,this._renderManagerService=a,this._dataValidationModel=n}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,i,r,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,u=a-ce;let p;switch(r){case o.VerticalAlign.MIDDLE:p=(n-qe)/2;break;case o.VerticalAlign.BOTTOM:p=n-l-i-be+(i/2-qe/2);break;default:p=d+be+(i/2-qe/2);break}e.save(),e.translateWithPrecision(t.startX+u,t.startY+p),e.fillStyle="#565656",e.fill(Gt),e.restore()}drawWith(e,t,a){const{primaryWithCoord:n,row:i,col:r,style:s,data:d,subUnitId:l}=t,u=n.isMergedMainCell?n.mergeInfo:n,p=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,r);if(!p)return;const m=this._dataValidationModel.getValidator(p.type);if(!m)return;const c=d==null?void 0:d.fontRenderExtension,{leftOffset:g=0,rightOffset:v=0,topOffset:I=0,downOffset:w=0}=c||{};if(!p||!m||!m||m.id.indexOf(o.DataValidationType.LIST)!==0||!m.skipDefaultFontRender(p))return;const C={startX:u.startX+g,endX:u.endX-v,startY:u.startY+I,endY:u.endY-w},V=C.endX-C.startX,y=C.endY-C.startY,M=this._ensureMap(l),D=this._generateKey(i,r),S=m.getListWithColor(p),_=E.getCellValueOrigin(d),O=`${_!=null?_:""}`,j=S.find(N=>N.label===O);let{tb:$,vt:A,ht:T,pd:F}=s||{};if($=$!=null?$:o.WrapStrategy.WRAP,A=A!=null?A:o.VerticalAlign.BOTTOM,T=T!=null?T:o.DEFAULT_STYLES.ht,F=F!=null?F:o.DEFAULT_STYLES.pd,p.renderMode===o.DataValidationRenderMode.ARROW){const{l:N=o.DEFAULT_STYLES.pd.l,t:U=o.DEFAULT_STYLES.pd.t,r:k=o.DEFAULT_STYLES.pd.r,b:G=o.DEFAULT_STYLES.pd.b}=F,Z=V-N-k-ce-4,{documentSkeleton:q,documents:ee,docModel:te}=Ge(O,this._localeService,s);$===o.WrapStrategy.WRAP&&te.updateDocumentDataPageSize(Math.max(Z,1)),q.calculate(),q.getActualSize();const ae=B.getDocsSkeletonPageSize(q),{height:ie,width:le}=ae,{paddingTop:oe,paddingLeft:de}=Jt(Z,y-U-G,le,ie,A,T,!0);this._drawDownIcon(e,C,V,y,ie,A,F),e.save(),e.translateWithPrecision(C.startX+N,C.startY+U),e.beginPath(),e.rect(0,0,V-N-k,y-U-G),e.clip(),e.translateWithPrecision(0,oe),e.save(),e.translateWithPrecision(De,0),e.beginPath(),e.rect(0,0,Z,ie),e.clip(),ee.render(e),e.translateWithPrecision(de,0),e.restore(),e.restore(),M.set(D,{left:C.endX+N+a.rowHeaderWidth-ce,top:C.startY+U+a.columnHeaderHeight,width:ce,height:y-U-G})}else{e.save(),e.translateWithPrecision(C.startX,C.startY),e.beginPath(),e.rect(0,0,V,y),e.clip();const N=V-he*2-De-ce-4,{documentSkeleton:U,documents:k,docModel:G}=Ge(O,this._localeService,s);$===o.WrapStrategy.WRAP&&G.updateDocumentDataPageSize(Math.max(N,1)),U.calculate();const Z=B.getDocsSkeletonPageSize(U),{height:q,width:ee}=Z,{paddingTop:te,paddingLeft:ae}=Jt(N,y,ee,q,A,T);e.translateWithPrecision(he,te);const ie=Math.max(V-he*2,1),le=q;B.Rect.drawWith(e,{width:ie,height:le,fill:(j==null?void 0:j.color)||Ie,radius:St}),e.save(),e.translateWithPrecision(De,0),e.beginPath(),e.rect(0,0,N,q),e.clip(),e.translateWithPrecision(ae,0),k.render(e),e.restore(),e.translateWithPrecision(N+De+4,(q-qe)/2),e.fillStyle=Na,e.fill(Gt),e.restore(),M.set(D,{left:C.startX+he+a.rowHeaderWidth,top:C.startY+te+a.columnHeaderHeight,width:ie,height:le})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:u=0,topOffset:p=0,downOffset:m=0}=d||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!c||c.renderMode===o.DataValidationRenderMode.TEXT)return;const g={startX:s.startX+l,endX:s.endX-u,startY:s.startY+p,endY:s.endY-m},v=g.endX-g.startX,I=E.getCellValueOrigin(n),w=`${I!=null?I:""}`;let{tb:C,pd:V}=a||{};const{t:y=o.DEFAULT_STYLES.pd.t,b:M=o.DEFAULT_STYLES.pd.b}=V!=null?V:{};if(C=C!=null?C:o.WrapStrategy.WRAP,c.renderMode===o.DataValidationRenderMode.ARROW){const D=v-ce,{documentSkeleton:S,docModel:_}=Ge(w,this._localeService,a);C===o.WrapStrategy.WRAP&&_.updateDocumentDataPageSize(Math.max(D,1)),S.calculate(),S.getActualSize();const O=B.getDocsSkeletonPageSize(S),{height:j}=O;return j+y+M+be*2}else{const D=v-he*2-De-ce,{documentSkeleton:S,docModel:_}=Zt(w,this._localeService,a);C===o.WrapStrategy.WRAP&&_.updateDocumentDataPageSize(Math.max(D,1)),S.calculate();const O=B.getDocsSkeletonPageSize(S),{height:j}=O;return j+be*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:u=0,topOffset:p=0,downOffset:m=0}=d||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!c||c.renderMode===o.DataValidationRenderMode.TEXT)return;const g={startX:s.startX+l,endX:s.endX-u,startY:s.startY+p,endY:s.endY-m},v=g.endX-g.startX,I=E.getCellValueOrigin(n),w=`${I!=null?I:""}`;let{tb:C,pd:V}=a||{};const{l:y=o.DEFAULT_STYLES.pd.l,r:M=o.DEFAULT_STYLES.pd.r}=V!=null?V:{};C=C!=null?C:o.WrapStrategy.WRAP;let D=he*2+ce;switch(c.renderMode){case o.DataValidationRenderMode.ARROW:D=ce+he*2+M+y;break;case o.DataValidationRenderMode.CUSTOM:D=ce+he*2+De*2+M+y+St/2+1;break;default:D=ce+he*2+De*2+M+y+St/2+1}const S=v-D,{documentSkeleton:_,docModel:O}=Ge(w,this._localeService,a);return C===o.WrapStrategy.WRAP&&O.updateDocumentDataPageSize(Math.max(S,1)),_.calculate(),_.getActualSize(),B.getDocsSkeletonPageSize(_).width+D}isHit(e,t){const{subUnitId:a,row:n,col:i}=t,s=this._ensureMap(a).get(this._generateKey(n,i)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,i);if(!d||!s||d.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:u,width:p,height:m}=s,{x:c,y:g}=e;return c>=u&&c<=u+p&&g>=l&&g<=l+m}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=e,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Fe.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};_t=xa([Ke(0,o.Inject(o.LocaleService)),Ke(1,o.ICommandService),Ke(2,o.Inject(B.IRenderManagerService)),Ke(3,o.Inject(E.SheetDataValidationModel))],_t);class Ba extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST);L(this,"canvasRender",this.injector.createInstance(_t));L(this,"dropdown",Ue);L(this,"optionsInput",He.componentKey);L(this,"formulaInput",ut)}}class ka extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.TEXT_LENGTH);L(this,"formulaInput",$e)}}class Wa extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.WHOLE);L(this,"formulaInput",$e)}}var $a=Object.defineProperty,Ha=Object.getOwnPropertyDescriptor,Ya=(e,t,a,n)=>{for(var i=n>1?void 0:n?Ha(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&$a(t,a,i),i},It=(e,t)=>(a,n)=>t(a,n,e);let Oe=class extends o.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[Nt,Mt],[at,Fn],[jt,yn],[Ue,Mn],[st,ln],[He.componentKey,He],[Ye.componentKey,Ye],...ua].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Va,Wa,ka,wa,Ca,Ba,ja,Da].forEach(e=>{const t=this._injector.createInstance(e),a=this._dataValidatorRegistryService.getValidatorItem(t.id);a&&(a.formulaInput=t.formulaInput,a.canvasRender=t.canvasRender,a.dropdown=t.dropdown,a.optionsInput=t.optionsInput)})}};Oe=Ya([It(0,o.Inject(o.Injector)),It(1,o.Inject(z.ComponentManager)),It(2,o.Inject(J.DataValidatorRegistryService))],Oe);var Xa=Object.defineProperty,za=Object.getOwnPropertyDescriptor,Ka=(e,t,a,n)=>{for(var i=n>1?void 0:n?za(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Xa(t,a,i),i},Ct=(e,t)=>(a,n)=>t(a,n,e);const qa="SHEET_DATA_VALIDATION_UI_PLUGIN";Y.UniverSheetsDataValidationUIPlugin=(Ze=class extends o.Plugin{constructor(t=xt,a,n,i){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(ot,s)}onStarting(){[[ue],[fe],[je],[Ve],[Me],[Re],[Ee],[Pe],[Oe]].forEach(t=>{this._injector.add(t)}),[Be,Fe,Ft,it,_e,At].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Re),this._injector.get(Pe),this._injector.get(je),this._injector.get(B.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[We])}onRendered(){this._injector.get(Oe),this._injector.get(Me)}onSteady(){this._injector.get(Ve)}},L(Ze,"pluginName",qa),L(Ze,"type",o.UniverInstanceType.UNIVER_SHEET),Ze),Y.UniverSheetsDataValidationUIPlugin=Ka([Ct(1,o.Inject(o.Injector)),Ct(2,o.ICommandService),Ct(3,o.IConfigService)],Y.UniverSheetsDataValidationUIPlugin);var Ga=Object.defineProperty,Za=Object.getOwnPropertyDescriptor,Ja=(e,t,a,n)=>{for(var i=n>1?void 0:n?Za(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Ga(t,a,i),i},Dt=(e,t)=>(a,n)=>t(a,n,e);const Qa="SHEET_DATA_VALIDATION_UI_PLUGIN";Y.UniverSheetsDataValidationMobileUIPlugin=(Je=class extends o.Plugin{constructor(t=xt,a,n,i){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(ot,s)}onStarting(){[[ue],[fe],[je],[Ve],[Me],[Re],[Ee],[Oe]].forEach(t=>{this._injector.add(t)}),[Be,Fe,Ft,it,_e,At].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Re),this._injector.get(B.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[We])}onRendered(){this._injector.get(Oe),this._injector.get(Me)}onSteady(){this._injector.get(Ve)}},L(Je,"pluginName",Qa),L(Je,"type",o.UniverInstanceType.UNIVER_SHEET),Je),Y.UniverSheetsDataValidationMobileUIPlugin=Ja([Dt(1,o.Inject(o.Injector)),Dt(2,o.ICommandService),Dt(3,o.IConfigService)],Y.UniverSheetsDataValidationMobileUIPlugin),Y.DATE_DROPDOWN_KEY=st,Y.LIST_DROPDOWN_KEY=Ue,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
|
9
|
+
*/var wt;function tn(){if(wt)return Te;wt=1;var e=f,t=Symbol.for("react.element"),a=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function s(d,l,u){var p,m={},c=null,g=null;u!==void 0&&(c=""+u),l.key!==void 0&&(c=""+l.key),l.ref!==void 0&&(g=l.ref);for(p in l)n.call(l,p)&&!r.hasOwnProperty(p)&&(m[p]=l[p]);if(d&&d.defaultProps)for(p in l=d.defaultProps,l)m[p]===void 0&&(m[p]=l[p]);return{$$typeof:t,type:d,key:c,ref:g,props:m,_owner:i.current}}return Te.Fragment=a,Te.jsx=s,Te.jsxs=s,Te}var Vt;function nn(){return Vt||(Vt=1,at.exports=tn()),at.exports}var h=nn(),an=Object.defineProperty,on=Object.getOwnPropertyDescriptor,rn=(e,t,a,n)=>{for(var i=n>1?void 0:n?on(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&an(t,a,i),i},Pe=(e,t)=>(a,n)=>t(a,n,e);let je=class extends o.Disposable{constructor(e,t,a,n,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(X.AFTER_CELL_EDIT_ASYNC,{handler:async(e,t,a)=>{var I;const n=await e,{worksheet:i,row:r,col:s,unitId:d,subUnitId:l,workbook:u}=t,p=this._dataValidationModel.getRuleIdByLocation(d,l,r,s),m=p?this._dataValidationModel.getRuleById(d,l,p):void 0;if(!m||m.errorStyle!==o.DataValidationErrorStyle.STOP)return a(Promise.resolve(n));const c=await this._dataValidatorRegistryService.getValidatorItem(m.type);if(!c||await c.validator({value:E.getCellValueOrigin(n),interceptValue:E.getCellValueOrigin((I=t==null?void 0:t.origin)!=null?I:n),row:r,column:s,unitId:d,subUnitId:l,worksheet:i,workbook:u,t:n==null?void 0:n.t},m))return a(Promise.resolve(n));const v=i.getCellRaw(r,s);return this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:c.getRuleFinalError(m,{row:r,col:s,unitId:d,subUnitId:l})},footer:{title:f.createElement(b.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(Promise.resolve(v))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:f.createElement(b.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};je=rn([Pe(0,o.Inject(X.SheetInterceptorService)),Pe(1,o.Inject(E.SheetDataValidationModel)),Pe(2,o.Inject(J.DataValidatorRegistryService)),Pe(3,z.IDialogService),Pe(4,o.Inject(o.LocaleService))],je);const Et={dvDateDropdown:"univer-dv-date-dropdown",dvDateDropdownBtns:"univer-dv-date-dropdown-btns"},sn=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function ln(e){var _;const{location:t,hideFn:a}=e,{worksheet:n,row:i,col:r,unitId:s,subUnitId:d,workbook:l}=t,u=o.useDependency(o.ICommandService),p=o.useDependency(je),m=n.getCell(i,r),c=E.getCellValueOrigin(n.getCellRaw(i,r)),g=sn(c),[v,I]=f.useState(g),w=v&&v.isValid()?v:o.dayjs(),C=o.useDependency(o.LocaleService),V=o.useDependency(E.SheetDataValidationModel),y=V.getRuleByLocation(s,d,i,r);if(!y)return null;const M=V.getValidator(y.type);if(!m||!M)return;const D=!!((_=y.bizInfo)!=null&&_.showTime),S=async()=>{var N,U,k;if(!w)return;const j=w.format(D?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),$=(N=o.numfmt.parseDate(j))==null?void 0:N.v,A=l.getStyles().getStyleByCell(m),T=(k=(U=A==null?void 0:A.n)==null?void 0:U.pattern)!=null?k:"",F=Qt.getPatternType(T);y.errorStyle!==o.DataValidationErrorStyle.STOP||await M.validator({value:$,unitId:s,subUnitId:d,row:i,column:r,worksheet:n,workbook:l,interceptValue:j.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},y)?(a(),await u.executeCommand(x.SetCellEditVisibleOperation.id,{visible:!1,eventType:B.DeviceInputEventType.Keyboard,unitId:s,keycode:z.KeyCode.ESC}),await u.executeCommand(X.SetRangeValuesCommand.id,{unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:$,t:2,p:null,f:null,si:null,s:{n:{pattern:D?F==="datetime"?T:"yyyy-MM-dd hh:mm:ss":F==="date"?T:"yyyy-MM-dd"}}}})):p.showReject(M.getRuleFinalError(y,{row:i,col:r,unitId:s,subUnitId:d}))};return h.jsxs("div",{className:Et.dvDateDropdown,children:[h.jsx(b.DatePanel,{defaultValue:w,pickerValue:w,showTime:D||void 0,onSelect:async O=>{I(O)},onPanelChange:O=>{I(O)},disabledDate:O=>!o.numfmt.parseDate(O.format("YYYY-MM-DD"))}),h.jsx("div",{className:Et.dvDateDropdownBtns,children:h.jsx(b.Button,{size:"small",type:"primary",onClick:S,disabled:!w.isValid(),children:C.t("dataValidation.alert.ok")})})]})}var se=function(){return se=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},se.apply(this,arguments)},dn=function(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(a[n[i]]=e[n[i]]);return a},ve=f.forwardRef(function(e,t){var a=e.icon,n=e.id,i=e.className,r=e.extend,s=dn(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),l=f.useRef("_".concat(pn()));return Rt(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},se({ref:t,className:d},s),r)});function Rt(e,t,a,n,i){return f.createElement(e.tag,se(se({key:t},cn(e,a,i)),n),(un(e,a).children||[]).map(function(r,s){return Rt(r,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,i)}))}function cn(e,t,a){var n=se({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1);var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],d=r[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function un(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?se(se({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?se(se({},i),{attrs:se(se({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function pn(){return Math.random().toString(36).substring(2,8)}ve.displayName="UniverIcon";var hn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Mt=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"check-mark-single",ref:t,icon:hn}))});Mt.displayName="CheckMarkSingle";var mn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.4917 3.07803C1.4917 2.19437 2.20804 1.47803 3.0917 1.47803H5.6917C6.57536 1.47803 7.2917 2.19437 7.2917 3.07803V5.67803C7.2917 6.56168 6.57535 7.27803 5.6917 7.27803H3.0917C2.20804 7.27803 1.4917 6.56168 1.4917 5.67803V3.07803ZM3.0917 2.67803C2.87078 2.67803 2.6917 2.85711 2.6917 3.07803V5.67803C2.6917 5.89894 2.87079 6.07803 3.0917 6.07803H5.6917C5.91261 6.07803 6.0917 5.89894 6.0917 5.67803V3.07803C6.0917 2.85711 5.91261 2.67803 5.6917 2.67803H3.0917Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.6175 2.45279C14.8518 2.68711 14.8518 3.06701 14.6175 3.30132L11.6151 6.30365C11.3957 6.52307 11.0451 6.53897 10.8067 6.34031L8.80915 4.67566C8.55458 4.46352 8.52019 4.08518 8.73233 3.83062 8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767 13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279zM14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217 14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046 13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703 10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046 9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217 9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746 9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732 13.269 9.19746C13.5033 8.96315 13.8832 8.96315 14.1175 9.19746z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.0917 8.72168C2.20804 8.72168 1.4917 9.43802 1.4917 10.3217V12.9217C1.4917 13.8053 2.20804 14.5217 3.0917 14.5217H5.6917C6.57535 14.5217 7.2917 13.8053 7.2917 12.9217V10.3217C7.2917 9.43802 6.57536 8.72168 5.6917 8.72168H3.0917ZM2.6917 10.3217C2.6917 10.1008 2.87078 9.92168 3.0917 9.92168H5.6917C5.91261 9.92168 6.0917 10.1008 6.0917 10.3217V12.9217C6.0917 13.1426 5.91261 13.3217 5.6917 13.3217H3.0917C2.87079 13.3217 2.6917 13.1426 2.6917 12.9217V10.3217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},bt=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"data-validation-single",ref:t,icon:mn}))});bt.displayName="DataValidationSingle";var vn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},it=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"delete-single",ref:t,icon:vn}))});it.displayName="DeleteSingle";var fn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},Ot=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"increase-single",ref:t,icon:fn}))});Ot.displayName="IncreaseSingle";var gn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Lt=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"more-down-single",ref:t,icon:gn}))});Lt.displayName="MoreDownSingle";var Sn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.64645 9.85355C4.45118 9.65829 4.45118 9.34171 4.64645 9.14645L7.64645 6.14645C7.84171 5.95118 8.15829 5.95118 8.35355 6.14645L11.3536 9.14645C11.5488 9.34171 11.5488 9.65829 11.3536 9.85355C11.1583 10.0488 10.8417 10.0488 10.6464 9.85355L8 7.20711L5.35355 9.85355C5.15829 10.0488 4.84171 10.0488 4.64645 9.85355Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Tt=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"more-up-single",ref:t,icon:Sn}))});Tt.displayName="MoreUpSingle";var _n={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},Pt=f.forwardRef(function(e,t){return f.createElement(ve,Object.assign({},e,{id:"sequence-single",ref:t,icon:_n}))});Pt.displayName="SequenceSingle";var In=Object.defineProperty,Cn=Object.getOwnPropertyDescriptor,Dn=(e,t,a,n)=>{for(var i=n>1?void 0:n?Cn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&In(t,a,i),i},jt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends o.Disposable{constructor(t,a){super();L(this,"_open$",new re.BehaviorSubject(!1));L(this,"open$",this._open$.pipe(re.distinctUntilChanged()));L(this,"_activeRule");L(this,"_activeRule$",new re.BehaviorSubject(void 0));L(this,"activeRule$",this._activeRule$.asObservable());L(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(re.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===xe&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ue=Dn([jt(0,o.IUniverInstanceService),jt(1,z.ISidebarService)],ue);function yn(){const e=o.useDependency(fe),t=z.useObservable(e.activeDropdown$,e.activeDropdown),a=o.useDependency(z.ComponentManager);if(!t)return null;const{location:n,componentKey:i}=t,r=a.get(i),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!r)return null;const d=()=>{e.hideDropdown()};return h.jsx(r,{location:n,hideFn:d},s)}const At="sheet.ui.dropdown";var wn=Object.defineProperty,Vn=Object.getOwnPropertyDescriptor,En=(e,t,a,n)=>{for(var i=n>1?void 0:n?Vn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&wn(t,a,i),i},Se=(e,t)=>(a,n)=>t(a,n,e);let fe=class extends o.Disposable{constructor(t,a,n,i,r,s,d){super();L(this,"_activeDropdown");L(this,"_activeDropdown$",new re.Subject);L(this,"_currentPopup",null);L(this,"activeDropdown$",this._activeDropdown$.asObservable());L(this,"_zenVisible",!1);this._canvasPopupManagerService=t,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=i,this._renderManagerService=r,this._dataValidationModel=s,this._sheetsSelectionsService=d,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,a,n,i){const r=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!r)return;const s=a?r.getSheetBySheetId(a):r.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(r.getUnitId(),s.getSheetId(),n,i);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdown}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t,a=!0){const{location:n}=t,{row:i,col:r,unitId:s,subUnitId:d}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const l=this._renderManagerService.getRenderById(o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),u=this._canvasPopupManagerService.attachPopupToCell(i,r,{componentKey:At,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[l==null?void 0:l.engine.getCanvasElement()].filter(Boolean)},s,d);if(!u)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const p=new o.DisposableCollection;p.add(u),p.add({dispose:()=>{var m,c;(c=(m=this._activeDropdown)==null?void 0:m.onHide)==null||c.call(m)}}),this._currentPopup=p}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,a,n,i,r){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(a);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,i);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!u||!u.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:i,unitId:t,subUnitId:a},componentKey:u.dropdown,onHide:r})}};fe=En([Se(0,o.Inject(x.SheetCanvasPopManagerService)),Se(1,o.IUniverInstanceService),Se(2,o.Inject(J.DataValidatorRegistryService)),Se(3,z.IZenZoneService),Se(4,B.IRenderManagerService),Se(5,o.Inject(E.SheetDataValidationModel)),Se(6,o.Inject(X.SheetsSelectionsService))],fe);const xe="DataValidationPanel",_e={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,i=e.get(ue),r=e.get(J.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(z.ISidebarService),l=X.getSheetCommandTarget(s);if(!l)return!1;const{unitId:u,subUnitId:p}=l,m=a?r.getRuleById(u,p,a):void 0;i.open(),i.setActiveRule(m&&{unitId:u,subUnitId:p,rule:m});const c=d.open({id:xe,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:xe},width:312,onClose:()=>i.close()});return i.setCloseDisposable(c),!0}},ot={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},Ft={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),a=e.get(ue);return a.open(),a.isOpen?t.executeCommand(ot.id):t.executeCommand(_e.id),!0}},Ne={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(fe),{unitId:n,subUnitId:i,row:r,column:s}=t,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===i&&l.row===r&&l.col===s||a.showDataValidationDropdown(n,i,r,s),!0}},xt={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},Ie="#ECECEC",rt="sheets-data-validation-ui.config",Ue={},me={dvListDropdown:"univer-dv-list-dropdown",dvListDropdownTitle:"univer-dv-list-dropdown-title",dvListDropdownList:"univer-dv-list-dropdown-list",dvListDropdownListContainer:"univer-dv-list-dropdown-list-container",dvListDropdownSelectedIcon:"univer-dv-list-dropdown-selected-icon",dvListDropdownItemContainer:"univer-dv-list-dropdown-item-container",dvListDropdownItem:"univer-dv-list-dropdown-item",dvListDropdownSplit:"univer-dv-list-dropdown-split",dvListDropdownEdit:"univer-dv-list-dropdown-edit"},Rn=e=>{var D,S;const{value:t,onChange:a,multiple:n,options:i,title:r,onEdit:s,style:d,filter:l,location:u}=e,p=o.useDependency(o.LocaleService),m=o.useDependency(o.IConfigService),c=l==null?void 0:l.toLowerCase(),{row:g,col:v,unitId:I,subUnitId:w}=u,C=i.filter(_=>c?_.label.toLowerCase().includes(c):!0),V=(S=(D=m.getConfig(rt))==null?void 0:D.showEditOnDropdown)!=null?S:!0,y=o.useDependency(x.SheetPermissionInterceptorBaseController),M=f.useMemo(()=>y.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission]},[{startColumn:v,startRow:g,endColumn:v,endRow:g}],I,w),[y,v,g,I,w]);return h.jsxs("div",{className:me.dvListDropdown,style:d,children:[h.jsx("div",{className:me.dvListDropdownTitle,children:r}),h.jsx("div",{className:me.dvListDropdownList,children:h.jsx(b.Scrollbar,{children:h.jsx("div",{className:me.dvListDropdownListContainer,children:C.map((_,O)=>{const j=t.indexOf(_.value)>-1,$=()=>{let T;j?T=new Set(t.filter(N=>N!==_.value)):T=new Set(n?[...t,_.value]:[_.value]);const F=[];i.forEach(N=>{T.has(N.value)&&F.push(N.value)}),a(F)},A=_.label.toLocaleLowerCase().indexOf(c);return h.jsxs("div",{className:me.dvListDropdownItemContainer,onClick:$,children:[h.jsx("div",{className:me.dvListDropdownItem,style:{background:_.color||Ie},children:c&&_.label.toLowerCase().includes(c)?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:_.label.substring(0,A)}),h.jsx("span",{style:{fontWeight:"bold"},children:_.label.substring(A,A+c.length)}),h.jsx("span",{children:_.label.substring(A+c.length)})]}):_.label}),h.jsx("div",{className:me.dvListDropdownSelectedIcon,children:j?h.jsx(Mt,{}):null})]},O)})})},l)}),V&&M?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:me.dvListDropdownSplit}),h.jsx("div",{className:me.dvListDropdownEdit,children:h.jsx("a",{onClick:s,children:p.t("dataValidation.list.edit")})})]}):null]})};function Mn(e){var U,k,G,Z;const{location:t,hideFn:a}=e,{worksheet:n,row:i,col:r,unitId:s,subUnitId:d}=t,l=o.useDependency(J.DataValidationModel),[u,p]=f.useState(""),m=o.useDependency(o.ICommandService),c=o.useDependency(o.LocaleService),[g,v]=f.useState(""),I=o.useDependency(x.IEditorBridgeService),w=o.useDependency(o.IUniverInstanceService),C=f.useMemo(()=>l.ruleChange$.pipe(re.debounceTime(16)),[]),V=o.useDependency(E.SheetDataValidationModel);z.useObservable(C);const y=z.RectPopup.useContext(),M=((k=(U=y.current)==null?void 0:U.right)!=null?k:0)-((Z=(G=y.current)==null?void 0:G.left)!=null?Z:0);if(f.useEffect(()=>{const q=m.onCommandExecuted(ee=>{var te,ae;if(ee.id===en.RichTextEditingMutation.id){const ie=ee.params,{unitId:le}=ie,oe=w.getUnit(le,o.UniverInstanceType.UNIVER_DOC);if(!oe)return;const de=o.BuildTextUtils.transform.getPlainText((ae=(te=oe.getSnapshot().body)==null?void 0:te.dataStream)!=null?ae:"");p(de)}});return()=>{q.dispose()}},[m,w]),!n)return null;const D=V.getRuleByLocation(s,d,i,r);if(!D)return null;const S=V.getValidator(D.type);if(!S)return null;const _=n.getCell(i,r),O=(D==null?void 0:D.renderMode)===o.DataValidationRenderMode.CUSTOM||(D==null?void 0:D.renderMode)===void 0;if(!_||!D||!S||S.id.indexOf(o.DataValidationType.LIST)!==0)return;const j=D.type===o.DataValidationType.LIST_MULTIPLE,$=S.getListWithColor(D,s,d),A=g||E.getDataValidationCellValue(n.getCellRaw(i,r)),T=E.deserializeListOptions(A),F=()=>{m.executeCommand(_e.id,{ruleId:D.uid}),a()},N=$.map(q=>({label:q.label,value:q.label,color:O||q.color?q.color:"transparent"}));return h.jsx(Rn,{style:{minWidth:M,maxWidth:Math.max(M,200)},title:j?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:T,multiple:j,onChange:async q=>{const ee=E.serializeListOptions(q),te={unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:ee,p:null,f:null,si:null}};I.isVisible()&&I.changeVisible({visible:!1,keycode:z.KeyCode.ESC,eventType:B.DeviceInputEventType.Keyboard,unitId:s}),v(ee),j||a(),I.isVisible().visible&&await m.executeCommand(x.SetCellEditVisibleOperation.id,{visible:!1,eventType:B.DeviceInputEventType.Keyboard,unitId:s,keycode:z.KeyCode.ESC}),m.executeCommand(X.SetRangeValuesCommand.id,te)},options:N,onEdit:F,filter:u,location:t})}const st={dataValidationOptionsButton:"univer-data-validation-options-button",dataValidationOptionsButtonIcon:"univer-data-validation-options-button-icon"};function bn(e){var u;const t=o.useDependency(o.LocaleService),a=o.useDependency(z.ComponentManager),{value:n,onChange:i,extraComponent:r}=e,[s,d]=f.useState(!1),l=r?a.get(r):null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:st.dataValidationOptionsButton,onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?h.jsx(Tt,{className:st.dataValidationOptionsButtonIcon}):h.jsx(Lt,{className:st.dataValidationOptionsButtonIcon})]}),s&&h.jsxs(h.Fragment,{children:[l?h.jsx(l,{value:n,onChange:i}):null,h.jsx(b.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:h.jsxs(b.RadioGroup,{value:`${(u=n.errorStyle)!=null?u:o.DataValidationErrorStyle.WARNING}`,onChange:p=>i({...n,errorStyle:+p}),children:[h.jsx(b.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),h.jsx(b.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),h.jsx(b.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:h.jsx(b.Checkbox,{checked:n.showErrorMessage,onChange:()=>i({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?h.jsx(b.FormLayout,{children:h.jsx(b.Input,{value:n.error,onChange:p=>i({...n,error:p})})}):null]})]})}const we={dataValidationDetail:"univer-data-validation-detail",dataValidationDetailFormItem:"univer-data-validation-detail-form-item",dataValidationDetailButtons:"univer-data-validation-detail-buttons",dataValidationDetailButton:"univer-data-validation-detail-button"},On=e=>o.debounce(async(t,a,n,i)=>{const r=await e.executeCommand(t,a,n);i==null||i(r)},1e3);function Ln(e,t,a){var n,i,r,s;return t?((i=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:i.getSheetId())||"":((s=(r=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Tn(){var de;const[e,t]=f.useState(0),a=o.useDependency(ue),n=z.useObservable(a.activeRule$,a.activeRule),{unitId:i,subUnitId:r,rule:s}=n||{},d=s.uid,l=o.useDependency(J.DataValidatorRegistryService),u=o.useDependency(o.IUniverInstanceService),p=o.useDependency(z.ComponentManager),m=o.useDependency(o.ICommandService),c=o.useDependency(J.DataValidationModel),g=o.useDependency(o.LocaleService),[v,I]=f.useState(s),w=l.getValidatorItem(v.type),[C,V]=f.useState(!1),y=l.getValidatorsByScope(J.DataValidatorRegistryScope.SHEET),[M,D]=f.useState(()=>v.ranges.map(P=>({unitId:"",sheetId:"",range:P}))),S=f.useMemo(()=>On(m),[m]),[_,O]=f.useState(!1),j=f.useRef({}),[$,A]=f.useState(!1),T=o.useDependency(X.SheetsSelectionsService);if(f.useEffect(()=>()=>{const P=T.getCurrentLastSelection();P&&T.setSelections([P])},[T]),f.useEffect(()=>{m.onCommandExecuted(P=>{(P.id===o.UndoCommand.id||P.id===o.RedoCommand.id)&&setTimeout(()=>{const R=c.getRuleById(i,r,d);t(W=>W+1),R&&(I(R),D(R.ranges.map(W=>({unitId:"",sheetId:"",range:W}))))},20)})},[m,c,d,r,i]),!w)return null;const F=w.operators,N=w.operatorNames,U=v.operator?J.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,k=()=>{!v.ranges.length||_||(w.validatorFormula(v,i,r).success?a.setActiveRule(null):V(!0))},G=z.useEvent(P=>{const R=P.split(",").filter(Boolean).map(tt.deserializeRangeWithSheet).map(K=>{const ge=K.sheetName;if(ge){const ei=Ln(u,K.unitId,ge);return{...K,sheetId:ei}}return{...K,sheetId:""}});if(o.isUnitRangesEqual(R,M))return;D(R);const W=R.filter(K=>(!K.unitId||K.unitId===i)&&(!K.sheetId||K.sheetId===r)).map(K=>K.range);if(I({...v,ranges:W}),W.length===0)return;const H={unitId:i,subUnitId:r,ruleId:d,ranges:W};S(E.UpdateSheetDataValidationRangeCommand.id,H)}),Z=P=>{if(o.shallowEqual(P,J.getRuleSetting(v)))return;I({...v,...P});const R={unitId:i,subUnitId:r,ruleId:d,setting:P};S(E.UpdateSheetDataValidationSettingCommand.id,R,void 0)},q=async()=>{await m.executeCommand(E.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:i,subUnitId:r}),a.setActiveRule(null)},ee={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},te=P=>{const R=l.getValidatorItem(P);if(!R)return;const W=R.operators,H=c.getRuleById(i,r,d),K=P===(H==null?void 0:H.type)||P.includes("list")&&(H!=null&&H.type.includes("list"))?{...H,type:P}:{...v,type:P,operator:W[0],formula1:void 0,formula2:void 0};I(K),m.executeCommand(E.UpdateSheetDataValidationSettingCommand.id,{unitId:i,subUnitId:r,ruleId:v.uid,setting:J.getRuleSetting(K)})},ae=p.get(w.formulaInput),ie=f.useMemo(()=>M.map(P=>tt.serializeRange(P.range)).join(","),[]),le=J.getRuleOptions(v),oe=P=>{o.shallowEqual(P,J.getRuleOptions(v))||(I({...v,...P}),S(E.UpdateSheetDataValidationOptionsCommand.id,{unitId:i,subUnitId:r,ruleId:d,options:P}))};return z.useSidebarClick(P=>{var W;const R=(W=j.current)==null?void 0:W.handleOutClick;R&&R(P,()=>A(!1))}),h.jsxs("div",{className:we.dataValidationDetail,children:[h.jsx(b.FormLayout,{label:g.t("dataValidation.panel.range"),error:!v.ranges.length||_?g.t("dataValidation.panel.rangeError"):"",children:h.jsx(nt.RangeSelector,{unitId:i,subUnitId:r,initValue:ie,onChange:G,onFocus:()=>A(!0),isFocus:$,actions:j.current,onVerify:P=>O(!P)})}),h.jsx(b.FormLayout,{label:g.t("dataValidation.panel.type"),children:h.jsx(b.Select,{options:y==null?void 0:y.map(P=>({label:g.t(P.title),value:P.id})),value:v.type,onChange:te,className:we.dataValidationDetailFormItem})}),F!=null&&F.length?h.jsx(b.FormLayout,{label:g.t("dataValidation.panel.operator"),children:h.jsx(b.Select,{options:F.map((P,R)=>({value:`${P}`,label:N[R]})),value:`${v.operator}`,onChange:P=>{Z({...ee,operator:P})},className:we.dataValidationDetailFormItem})}):null,ae?h.jsx(ae,{isTwoFormula:U,value:{formula1:v.formula1,formula2:v.formula2},onChange:P=>{Z({...ee,...P})},showError:C,validResult:w.validatorFormula(v,i,r),unitId:i,subUnitId:r,ruleId:d},e+v.type):null,h.jsx(b.FormLayout,{children:h.jsx(b.Checkbox,{checked:(de=v.allowBlank)!=null?de:!0,onChange:()=>{var P;return Z({...ee,allowBlank:!((P=v.allowBlank)==null||P)})},children:g.t("dataValidation.panel.allowBlank")})}),h.jsx(bn,{value:le,onChange:oe,extraComponent:w.optionsInput}),h.jsxs("div",{className:we.dataValidationDetailButtons,children:[h.jsx(b.Button,{className:we.dataValidationDetailButton,onClick:q,children:g.t("dataValidation.panel.removeRule")}),h.jsx(b.Button,{className:we.dataValidationDetailButton,type:"primary",onClick:k,children:g.t("dataValidation.panel.done")})]})]})}const Be={dataValidationItemContainer:"univer-data-validation-item-container",dataValidationItemTitle:"univer-data-validation-item-title",dataValidationItemContent:"univer-data-validation-item-content",dataValidationItemIcon:"univer-data-validation-item-icon"},Pn=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:i,disable:r}=e,s=o.useDependency(J.DataValidatorRegistryService),d=o.useDependency(o.ICommandService),l=o.useDependency(x.IMarkSelectionService),u=s.getValidatorItem(t.type),p=f.useRef(),[m,c]=f.useState(!1),g=v=>{d.executeCommand(E.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:i}),v.stopPropagation()};return f.useEffect(()=>()=>{var v;p.current&&((v=p.current)==null||v.forEach(I=>{I&&l.removeShape(I)}))},[l]),h.jsxs("div",{className:Be.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{r||(c(!0),p.current=t.ranges.map(v=>l.addShape({range:v,style:{fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:null})))},onMouseLeave:()=>{var v;c(!1),(v=p.current)==null||v.forEach(I=>{I&&l.removeShape(I)}),p.current=void 0},children:[h.jsx("div",{className:Be.dataValidationItemTitle,children:u==null?void 0:u.generateRuleName(t)}),h.jsx("div",{className:Be.dataValidationItemContent,children:t.ranges.map(v=>tt.serializeRange(v)).join(",")}),m?h.jsx("div",{className:Be.dataValidationItemIcon,onClick:g,children:h.jsx(it,{})}):null]})},ke={dataValidationList:"univer-data-validation-list",dataValidationListButtons:"univer-data-validation-list-buttons",dataValidationListButton:"univer-data-validation-list-button"};function jn(){const e=o.useDependency(o.IUniverInstanceService),t=z.useObservable(()=>e.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return t?h.jsx(An,{workbook:t}):null}function An(e){const t=o.useDependency(E.SheetDataValidationModel),a=o.useDependency(o.IUniverInstanceService),n=o.useDependency(o.ICommandService),i=o.useDependency(o.Injector),r=o.useDependency(ue),s=o.useDependency(o.LocaleService),[d,l]=f.useState([]),{workbook:u}=e,p=z.useObservable(u.activeSheet$,void 0,!0),m=u.getUnitId(),c=p==null?void 0:p.getSheetId();f.useEffect(()=>{l(t.getRules(m,c));const V=t.ruleChange$.subscribe(y=>{y.unitId===m&&y.subUnitId===c&&l(t.getRules(m,c))});return()=>{V.unsubscribe()}},[m,c,t]);const g=async()=>{const V=E.createDefaultNewRule(i),y={unitId:m,subUnitId:c,rule:V};await n.executeCommand(E.AddSheetDataValidationCommand.id,y),r.setActiveRule({unitId:m,subUnitId:c,rule:V})},v=()=>{n.executeCommand(E.RemoveSheetAllDataValidationCommand.id,{unitId:m,subUnitId:c})},w=(V=>{const y=a.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),M=y.getActiveSheet(),D=y.getUnitId(),S=M.getSheetId();return V.map(O=>X.checkRangesEditablePermission(i,D,S,O.ranges)?{...O}:{...O,disable:!0})})(d),C=w==null?void 0:w.some(V=>V.disable);return h.jsxs("div",{className:ke.dataValidationList,children:[w==null?void 0:w.map(V=>{var y;return h.jsx(Pn,{unitId:m,subUnitId:c,onClick:()=>{V.disable||r.setActiveRule({unitId:m,subUnitId:c,rule:V})},rule:V,disable:(y=V.disable)!=null?y:!1},V.uid)}),h.jsxs("div",{className:ke.dataValidationListButtons,children:[d.length&&!C?h.jsx(b.Button,{className:ke.dataValidationListButton,onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,h.jsx(b.Button,{className:ke.dataValidationListButton,type:"primary",onClick:g,children:s.t("dataValidation.panel.add")})]})]})}const Fn=()=>{const e=o.useDependency(ue),t=z.useObservable(e.activeRule$,e.activeRule);return t?h.jsx(Tn,{},t.rule.uid):h.jsx(jn,{})},We="data-validation.list.dropdown",lt="data-validation.date.dropdown",$e={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),a=X.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:i}=a,r=E.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=i.getSheetId(),u={rule:r,unitId:d,subUnitId:l};return s.syncExecuteCommand(E.AddSheetDataValidationCommand.id,u)?(s.syncExecuteCommand(_e.id,{ruleId:r.uid,isAdd:!0}),!0):!1}};var xn=Object.defineProperty,Nn=Object.getOwnPropertyDescriptor,Un=(e,t,a,n)=>{for(var i=n>1?void 0:n?Nn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&xn(t,a,i),i},Ve=(e,t)=>(a,n)=>t(a,n,e);const Ce="SHEET_DATA_VALIDATION_ALERT";let Ae=class extends o.Disposable{constructor(e,t,a,n,i,r){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=i,this._dataValidationModel=r,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(re.debounceTime(100)).subscribe(e=>{var t;if(e){const a=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),n=a.getSheetBySheetId(e.location.subUnitId);if(!n)return;const i=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!i){this._cellAlertManagerService.removeAlert(Ce);return}if(this._dataValidationModel.validator(i,{...e.location,workbook:a,worksheet:n})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Ce),d=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(d&&d.row===e.location.row&&d.col===e.location.col&&d.subUnitId===e.location.subUnitId&&d.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(Ce);return}const l=this._dataValidationModel.getValidator(i.type);if(!l){this._cellAlertManagerService.removeAlert(Ce);return}this._cellAlertManagerService.showAlert({type:x.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(i,e.location),location:e.location,width:200,height:74,key:Ce});return}}this._cellAlertManagerService.removeAlert(Ce)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(Ce)}))}};Ae=Un([Ve(0,o.Inject(x.HoverManagerService)),Ve(1,o.Inject(x.CellAlertManagerService)),Ve(2,o.IUniverInstanceService),Ve(3,o.Inject(o.LocaleService)),Ve(4,z.IZenZoneService),Ve(5,o.Inject(E.SheetDataValidationModel))],Ae);var Bn=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,Wn=(e,t,a,n)=>{for(var i=n>1?void 0:n?kn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Bn(t,a,i),i},dt=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends o.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,i)=>{const{source:r,target:s,unitId:d,subUnitId:l}=n,u=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),p=x.virtualizeDiscreteRanges([r,s]),[m,c]=p.ranges,{mapFunc:g}=p,v={row:m.startRow,col:m.startColumn},I=x.getAutoFillRepeatRange(m,c),w=new o.ObjectMatrix,C=new Set;I.forEach(S=>{const _=S.repeatStartCell,O=S.relativeRange,j={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},$={startRow:_.row,startColumn:_.col,endColumn:_.col,endRow:_.row};o.Range.foreach(O,(A,T)=>{const F=o.Rectangle.getPositionRange({startRow:A,startColumn:T,endColumn:T,endRow:A},j),{row:N,col:U}=g(F.startRow,F.startColumn),k=this._sheetDataValidationModel.getRuleIdByLocation(d,l,N,U)||"",G=o.Rectangle.getPositionRange({startRow:A,startColumn:T,endColumn:T,endRow:A},$),{row:Z,col:q}=g(G.startRow,G.startColumn);w.setValue(Z,q,k),C.add(k)})});const V=Array.from(C).map(S=>({id:S,ranges:o.queryObjectMatrix(w,_=>_===S)}));u.addRangeRules(V);const y=u.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:M,undoMutations:D}=E.getDataValidationDiffMutations(d,l,y,this._injector,"patched",i===x.APPLY_TYPE.ONLY_FORMAT);return{undos:D,redos:M}},a={id:E.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:i,unitId:r,subUnitId:s}=n;for(const d of i.rows)for(const l of i.cols){const u=this._sheetDataValidationModel.getRuleByLocation(r,s,d,l);if(u&&u.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(x.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,i,r)=>r===x.APPLY_TYPE.COPY||r===x.APPLY_TYPE.ONLY_FORMAT||r===x.APPLY_TYPE.SERIES?t(n,r):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};Ee=Wn([dt(0,x.IAutoFillService),dt(1,o.Inject(E.SheetDataValidationModel)),dt(2,o.Inject(o.Injector))],Ee);var $n=Object.defineProperty,Hn=Object.getOwnPropertyDescriptor,Yn=(e,t,a,n)=>{for(var i=n>1?void 0:n?Hn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&$n(t,a,i),i},ct=(e,t)=>(a,n)=>t(a,n,e);let Re=class extends o.Disposable{constructor(t,a,n){super();L(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:E.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,i)=>{const{copyType:r=x.COPY_TYPE.COPY,pasteType:s}=i,{range:d}=t||{},{range:l,unitId:u,subUnitId:p}=a;return this._generateMutations(l,{copyType:r,pasteType:s,copyRange:d,unitId:u,subUnitId:p})}})}_collect(t,a,n){const i=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:i};const r=this._injector.invoke(l=>x.rangeToDiscreteRange(n,l,t,a));if(!r)return;const{rows:s,cols:d}=r;s.forEach((l,u)=>{d.forEach((p,m)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(t,a,l,p);i.setValue(u,m,c!=null?c:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===x.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([x.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,x.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,x.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,x.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:n,subUnitId:i}=this._copyInfo;if(a.unitId!==n||i!==a.subUnitId){const r=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),s=new o.ObjectMatrix,d=new Set,{ranges:[l,u],mapFunc:p}=x.virtualizeDiscreteRanges([a.copyRange,t]),m=x.getRepeatRange(l,u,!0),c=new Map;m.forEach(({startRange:w})=>{var C;(C=this._copyInfo)==null||C.matrix.forValue((V,y,M)=>{const D=o.Rectangle.getPositionRange({startRow:V,endRow:V,startColumn:y,endColumn:y},w),S=`${i}-${M}`,_=this._sheetDataValidationModel.getRuleById(n,i,M);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,S)&&_&&c.set(S,{..._,uid:S});const{row:O,col:j}=p(D.startRow,D.startColumn);d.add(S),s.setValue(O,j,S)})});const g=Array.from(d).map(w=>({id:w,ranges:o.queryObjectMatrix(s,C=>C===w)}));r.addRangeRules(g);const{redoMutations:v,undoMutations:I}=E.getDataValidationDiffMutations(a.unitId,a.subUnitId,r.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),c.values()),this._injector,"patched",!1);return{redos:v,undos:I}}else{const r=this._sheetDataValidationModel.getRuleObjectMatrix(n,i).clone(),s=new o.ObjectMatrix,d=new Set,{ranges:[l,u],mapFunc:p}=x.virtualizeDiscreteRanges([a.copyRange,t]);x.getRepeatRange(l,u,!0).forEach(({startRange:I})=>{var w;(w=this._copyInfo)==null||w.matrix.forValue((C,V,y)=>{const M=o.Rectangle.getPositionRange({startRow:C,endRow:C,startColumn:V,endColumn:V},I),{row:D,col:S}=p(M.startRow,M.startColumn);s.setValue(D,S,y),d.add(y)})});const c=Array.from(d).map(I=>({id:I,ranges:o.queryObjectMatrix(s,w=>w===I)}));r.addRangeRules(c);const{redoMutations:g,undoMutations:v}=E.getDataValidationDiffMutations(n,i,r.diff(this._sheetDataValidationModel.getRules(n,i)),this._injector,"patched",!1);return{redos:g,undos:v}}}};Re=Yn([ct(0,x.ISheetClipboardService),ct(1,o.Inject(E.SheetDataValidationModel)),ct(2,o.Inject(o.Injector))],Re);var Xn=Object.defineProperty,zn=Object.getOwnPropertyDescriptor,Kn=(e,t,a,n)=>{for(var i=n>1?void 0:n?zn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Xn(t,a,i),i},ut=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends o.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionInterceptorBaseController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===E.AddSheetDataValidationCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission,X.WorksheetSetCellStylePermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr"))),e.id===E.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[X.WorkbookEditablePermission],rangeTypes:[X.RangeProtectionPermissionEditPoint],worksheetTypes:[X.WorksheetEditPermission,X.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr")))}))}};Me=Kn([ut(0,o.Inject(o.LocaleService)),ut(1,o.ICommandService),ut(2,o.Inject(x.SheetPermissionInterceptorBaseController))],Me);const Nt="data-validation-single",Ut="sheet.menu.data-validation";function qn(e){return{id:Ut,type:z.MenuItemType.SUBITEMS,icon:Nt,tooltip:"dataValidation.title",hidden$:z.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:x.getCurrentRangeDisable$(e,{workbookTypes:[X.WorkbookEditablePermission],worksheetTypes:[X.WorksheetSetCellStylePermission,X.WorksheetEditPermission],rangeTypes:[X.RangeProtectionPermissionEditPoint]})}}function Gn(e){return{id:_e.id,title:"dataValidation.panel.title",type:z.MenuItemType.BUTTON}}function Zn(e){return{id:$e.id,title:"dataValidation.panel.add",type:z.MenuItemType.BUTTON}}const Jn={[z.RibbonStartGroup.FORMULAS_INSERT]:{[Ut]:{order:9,menuItemFactory:qn,[_e.id]:{order:0,menuItemFactory:Gn},[$e.id]:{order:1,menuItemFactory:Zn}}}};var Qn=Object.defineProperty,ea=Object.getOwnPropertyDescriptor,Bt=(e,t,a,n)=>{for(var i=n>1?void 0:n?ea(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Qn(t,a,i),i},Q=(e,t)=>(a,n)=>t(a,n,e);const kt={tr:{size:6,color:"#fe4b4b"}};let be=class extends o.RxDisposable{constructor(e,t,a,n,i,r,s,d,l,u,p){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=i,this._dropdownManagerService=r,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=u,this._editorBridgeService=p,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Jn)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var a;if(!e.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:i,row:r,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,i,r,s);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(u!=null&&u.dropdown))return;const p=d.getActiveSheet();if(!p)return;const m=this._dropdownManagerService.activeDropdown,c=m==null?void 0:m.location;if(c&&c.unitId===n&&c.subUnitId===i&&c.row===r&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:i,row:r,col:s,workbook:d,worksheet:p},componentKey:u.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var C,V,y,M,D;const{row:n,col:i,unitId:r,subUnitId:s,workbook:d,worksheet:l}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!u)return a(e);const p=this._sheetDataValidationModel.getRuleById(r,s,u);if(!p)return a(e);const m=(C=this._dataValidationCacheService.getValue(r,s,n,i))!=null?C:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),g=t.rawData;let v;const I={get value(){var S;return v!==void 0||(v=(S=E.getCellValueOrigin(g))!=null?S:null),v}},w={get value(){var S;return`${(S=I.value)!=null?S:""}`}};return a({...e,markers:{...e==null?void 0:e.markers,...m===o.DataValidationStatus.INVALID?kt:null},customRender:[...(V=e==null?void 0:e.customRender)!=null?V:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((M=c==null?void 0:c.skipDefaultFontRender)==null?void 0:M.call(c,p,I.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,w.value,{get style(){const S=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?S.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,i)},interceptorAutoHeight:()=>{var j,$,A,T,F,N;const S=($=(j=this._renderManagerService.getRenderById(r))==null?void 0:j.with(x.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:$.skeleton;if(!S)return;const _=S.worksheet.getMergedCell(n,i),O={data:e,style:S.getsStyles().getStyleByCell(e),primaryWithCoord:S.getCellWithCoordByIndex((A=_==null?void 0:_.startRow)!=null?A:n,(T=_==null?void 0:_.startColumn)!=null?T:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(N=(F=c==null?void 0:c.canvasRender)==null?void 0:F.calcCellAutoHeight)==null?void 0:N.call(F,O)},interceptorAutoWidth:()=>{var j,$,A,T,F,N;const S=($=(j=this._renderManagerService.getRenderById(r))==null?void 0:j.with(x.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:$.skeleton;if(!S)return;const _=S.worksheet.getMergedCell(n,i),O={data:e,style:S.getsStyles().getStyleByCell(e),primaryWithCoord:S.getCellWithCoordByIndex((A=_==null?void 0:_.startRow)!=null?A:n,(T=_==null?void 0:_.startColumn)!=null?T:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(N=(F=c==null?void 0:c.canvasRender)==null?void 0:F.calcCellAutoWidth)==null?void 0:N.call(F,O)},coverable:((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(p.type===o.DataValidationType.LIST||p.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(re.filter(e=>e.source==="command"),re.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(a=>{var n;(a.rule.type===o.DataValidationType.LIST_MULTIPLE||a.rule.type===o.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};be=Bt([Q(0,o.ICommandService),Q(1,z.IMenuManagerService),Q(2,B.IRenderManagerService),Q(3,o.IUniverInstanceService),Q(4,o.Inject(x.AutoHeightController)),Q(5,o.Inject(fe)),Q(6,o.Inject(E.SheetDataValidationModel)),Q(7,o.Inject(J.DataValidatorRegistryService)),Q(8,o.Inject(X.SheetInterceptorService)),Q(9,o.Inject(E.DataValidationCacheService)),Q(10,o.Optional(x.IEditorBridgeService))],be);let Wt=class extends o.RxDisposable{constructor(e,t,a,n,i,r,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=i,this._sheetDataValidationModel=r,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(X.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:X.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var w,C,V,y,M;const{row:n,col:i,unitId:r,subUnitId:s,workbook:d,worksheet:l}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!u)return a(e);const p=this._sheetDataValidationModel.getRuleById(r,s,u);if(!p)return a(e);const m=(w=this._dataValidationCacheService.getValue(r,s,n,i))!=null?w:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(p.type),g=l.getCellRaw(n,i),v=E.getCellValueOrigin(g),I=`${v!=null?v:""}`;return a({...e,markers:{...e==null?void 0:e.markers,...m===o.DataValidationStatus.INVALID?kt:null},customRender:[...(C=e==null?void 0:e.customRender)!=null?C:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((V=e==null?void 0:e.fontRenderExtension)==null?void 0:V.isSkip)||((y=c==null?void 0:c.skipDefaultFontRender)==null?void 0:y.call(c,p,v,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(p,I,{get style(){const D=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?D.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,i)},interceptorAutoHeight:()=>{var O,j,$,A,T,F;const D=(j=(O=this._renderManagerService.getRenderById(r))==null?void 0:O.with(x.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:j.skeleton;if(!D)return;const S=D.worksheet.getMergedCell(n,i),_={data:e,style:D.getsStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex(($=S==null?void 0:S.startRow)!=null?$:n,(A=S==null?void 0:S.startColumn)!=null?A:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(F=(T=c==null?void 0:c.canvasRender)==null?void 0:T.calcCellAutoHeight)==null?void 0:F.call(T,_)},coverable:((M=e==null?void 0:e.coverable)!=null?M:!0)&&!(p.type===o.DataValidationType.LIST||p.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(re.filter(e=>e.source==="command"),re.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};Wt=Bt([Q(0,o.ICommandService),Q(1,B.IRenderManagerService),Q(2,o.Inject(x.AutoHeightController)),Q(3,o.Inject(J.DataValidatorRegistryService)),Q(4,o.Inject(X.SheetInterceptorService)),Q(5,o.Inject(E.SheetDataValidationModel)),Q(6,o.Inject(E.DataValidationCacheService))],Wt);var ta=Object.defineProperty,na=Object.getOwnPropertyDescriptor,aa=(e,t,a,n)=>{for(var i=n>1?void 0:n?na(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&ta(t,a,i),i},$t=(e,t)=>(a,n)=>t(a,n,e);let He=class extends o.Disposable{constructor(e,t,a){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const a=new Set;t.forEach(i=>{a.add(i.subUnitId)}),a.forEach(i=>{var r;(r=this._sheetSkeletonManagerService.getWorksheetSkeleton(i))==null||r.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};He=aa([$t(1,o.Inject(E.SheetDataValidationModel)),$t(2,o.Inject(x.SheetSkeletonManagerService))],He);const ne={dataValidationFormula:"univer-data-validation-formula",dataValidationFormulaAnd:"univer-data-validation-formula-and",dataValidationFormulaListItem:"univer-data-validation-formula-list-item",dataValidationFormulaListItemIcon:"univer-data-validation-formula-list-item-icon",dataValidationFormulaListItemDrag:"univer-data-validation-formula-list-item-drag",dataValidationFormulaListAdd:"univer-data-validation-formula-list-add",dataValidationFormulaColorSelect:"univer-data-validation-formula-color-select",dataValidationFormulaColorSelectPanel:"univer-data-validation-formula-color-select-panel",dataValidationFormulaColorItem:"univer-data-validation-formula-color-item"},ia=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:i,validResult:r}=e,s=o.useDependency(o.LocaleService),d=i?r==null?void 0:r.formula1:"",l=i?r==null?void 0:r.formula2:"";return t?h.jsxs(h.Fragment,{children:[h.jsx(b.FormLayout,{error:d,children:h.jsx(b.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({...a,formula1:u})}})}),h.jsx("div",{className:ne.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),h.jsx(b.FormLayout,{error:l,children:h.jsx(b.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:u=>{n==null||n({...a,formula2:u})}})})]}):h.jsx(b.FormLayout,{error:d,children:h.jsx(b.Input,{className:ne.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({formula1:u})}})})};function oa(e){const{value:t,onChange:a,showError:n,validResult:i}=e,r=o.useDependency(o.LocaleService),s=n?i==null?void 0:i.formula1:"",d=n?i==null?void 0:i.formula2:"",[l,u]=f.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return h.jsxs(h.Fragment,{children:[h.jsx(b.FormLayout,{children:h.jsx(b.Checkbox,{checked:l,onChange:p=>{p?u(!0):(u(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:r.t("dataValidation.checkbox.tips")})}),l?h.jsx(b.FormLayout,{label:r.t("dataValidation.checkbox.checked"),error:s,children:h.jsx(b.Input,{className:ne.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:p=>{a==null||a({...t,formula1:p||void 0})}})}):null,l?h.jsx(b.FormLayout,{label:r.t("dataValidation.checkbox.unchecked"),error:d,children:h.jsx(b.Input,{className:ne.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:p=>{a==null||a({...t,formula2:p||void 0})}})}):null]})}function ra(e){var m;const{unitId:t,subUnitId:a,value:n,onChange:i,showError:r,validResult:s}=e,d=r?s==null?void 0:s.formula1:void 0,l=f.useRef({}),[u,p]=f.useState(!1);return z.useSidebarClick(c=>{var v;const g=(v=l.current)==null?void 0:v.handleOutClick;g&&g(c,()=>p(!1))}),h.jsx(nt.FormulaEditor,{initValue:(m=n==null?void 0:n.formula1)!=null?m:"",unitId:t,subUnitId:a,isFocus:u,onChange:c=>{const g=(c!=null?c:"").trim();g!==(n==null?void 0:n.formula1)&&(i==null||i({...n,formula1:g}))},errorText:d,onFocus:()=>p(!0),actions:l.current,isSupportAcrossSheet:!0})}function Ht(e){var t,a,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(a=Ht(e[t]))&&(n&&(n+=" "),n+=a)}else for(a in e)e[a]&&(n&&(n+=" "),n+=a);return n}function sa(){for(var e,t,a=0,n="",i=arguments.length;a<i;a++)(e=arguments[a])&&(t=Ht(e))&&(n&&(n+=" "),n+=t);return n}const la=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],da=e=>{const{value:t,onChange:a,disabled:n}=e,[i,r]=f.useState(!1);return h.jsx(b.Select,{disabled:n,open:i,onDropdownVisibleChange:r,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ne.dataValidationFormulaColorSelect,value:t,onChange:a,labelRender:s=>h.jsx("div",{className:ne.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>h.jsx("div",{className:ne.dataValidationFormulaColorSelectPanel,children:la.map(s=>h.jsx("div",{onClick:()=>{a(s),r(!1)},className:ne.dataValidationFormulaColorItem,style:{background:s}},s))})})},Yt=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:i,onItemDelete:r}=a;return h.jsxs("div",{className:ne.dataValidationFormulaListItem,style:n,children:[t.isRef?null:h.jsx("div",{className:sa(ne.dataValidationFormulaListItemDrag,"draggableHandle"),children:h.jsx(Pt,{})}),h.jsx(da,{value:t.color,onChange:s=>{i(t.id,t.label,s)}}),h.jsx(b.Input,{disabled:t.isRef,value:t.label,onChange:s=>{i(t.id,s,t.color)}}),t.isRef?null:h.jsx("div",{className:ne.dataValidationFormulaListItemIcon,children:h.jsx(it,{onClick:()=>r(t.id)})})]})};function ca(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:i,validResult:r,showError:s,ruleId:d}=e,{formula1:l="",formula2:u=""}=t||{},p=f.useRef(null),[m,c]=f.useState(()=>o.isFormulaString(l)?"1":"0"),[g,v]=f.useState(m==="1"?l:"="),[I,w]=f.useState(m==="1"?l:"="),C=o.useDependency(o.LocaleService),V=o.useDependency(J.DataValidatorRegistryService),y=o.useDependency(J.DataValidationModel),M=o.useDependency(E.DataValidationFormulaController),[D,S]=f.useState(()=>u.split(",")),_=V.getValidatorItem(o.DataValidationType.LIST),[O,j]=f.useState([]),[$,A]=f.useState(""),T=s?r==null?void 0:r.formula1:"",F=f.useMemo(()=>y.ruleChange$.pipe(re.debounceTime(16)),[]),N=z.useObservable(F),U=z.useEvent(a);f.useEffect(()=>{(async()=>{await new Promise(H=>{setTimeout(()=>H(!0),100)});const R=y.getRuleById(n,i,d),W=R==null?void 0:R.formula1;if(o.isFormulaString(W)&&_&&R){const H=await _.getListAsync(R,n,i);j(H)}})()},[y,N,_,d,i,n]),f.useEffect(()=>{o.isFormulaString(l)&&l!==I&&(v(l),w(I))},[I,l]);const[k,G]=f.useState(()=>{const R=m!=="1"?E.deserializeListOptions(l):[],W=u.split(",");return R.map((H,K)=>({label:H,color:W[K]||Ie,isRef:!1,id:o.Tools.generateRandomId(4)}))}),Z=(R,W,H)=>{const K=k.find(ge=>ge.id===R);K&&(K.label=W,K.color=H,G([...k]))},q=R=>{const W=k.findIndex(H=>H.id===R);W!==-1&&(k.splice(W,1),G([...k]))},ee=u.split(","),te=f.useMemo(()=>O.map((R,W)=>({label:R,color:ee[W]||Ie,id:`${W}`,isRef:!0})),[ee,O]),ae=(R,W,H)=>{const K=[...D];K[+R]=H,S(K),U({formula1:l,formula2:K.join(",")})},ie=()=>{G([...k,{label:"",color:Ie,isRef:!1,id:o.Tools.generateRandomId(4)}])};f.useEffect(()=>{if(m==="1")return;const R=new Set,W=[];k.map(H=>({labelList:H.label.split(","),item:H})).forEach(({item:H,labelList:K})=>{K.forEach(ge=>{R.has(ge)||(R.add(ge),W.push({label:ge,color:H.color}))})}),U({formula1:E.serializeListOptions(W.map(H=>H.label)),formula2:W.map(H=>H.color===Ie?"":H.color).join(",")})},[k,U,m,I,D]);const le=f.useMemo(()=>async R=>{if(!o.isFormulaString(R)){U==null||U({formula1:"",formula2:u});return}M.getFormulaRefCheck(R)?(U==null||U({formula1:o.isFormulaString(R)?R:"",formula2:u}),A("")):(U==null||U({formula1:"",formula2:u}),v("="),A(C.t("dataValidation.validFail.formulaError")))},[u,U]),oe=f.useRef({}),[de,P]=f.useState(!1);return z.useSidebarClick(R=>{var H;const W=(H=oe.current)==null?void 0:H.handleOutClick;W&&W(R,()=>P(!1))}),h.jsxs(h.Fragment,{children:[h.jsx(b.FormLayout,{label:C.t("dataValidation.list.options"),children:h.jsxs(b.RadioGroup,{value:m,onChange:R=>{c(R),v(I),R==="1"&&U({formula1:I==="="?"":I,formula2:D.join(",")})},children:[h.jsx(b.Radio,{value:"0",children:C.t("dataValidation.list.customOptions")}),h.jsx(b.Radio,{value:"1",children:C.t("dataValidation.list.refOptions")})]})}),m==="1"?h.jsxs(h.Fragment,{children:[h.jsx(nt.FormulaEditor,{initValue:g,unitId:n,subUnitId:i,isFocus:de,onChange:(R="")=>{const W=(R!=null?R:"").trim();w(W),le(W)},errorText:T||$||void 0,onFocus:()=>P(!0),actions:oe.current,isSupportAcrossSheet:!0}),h.jsx("div",{ref:p,style:{marginTop:"12px"},children:te.map(R=>h.jsx(Yt,{item:R,commonProps:{onItemChange:ae},style:{marginBottom:12}},R.id))})]}):h.jsx(b.FormLayout,{error:T,children:h.jsxs("div",{ref:p,style:{marginTop:"-12px"},children:[h.jsx(b.DraggableList,{list:k,onListChange:G,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:R=>h.jsx(Yt,{item:R,commonProps:{onItemChange:Z,onItemDelete:q}},R.id),idKey:"id"}),h.jsxs("a",{className:ne.dataValidationFormulaListAdd,onClick:ie,children:[h.jsx(Ot,{}),C.t("dataValidation.list.add")]})]})})]})}const Xt="data-validation.custom-formula-input",Ye="data-validation.formula-input",pt="data-validation.list-formula-input",zt="data-validation.checkbox-formula-input",ua=[[Xt,ra],[Ye,ia],[pt,ca],[zt,oa]],pa="LIST_RENDER_MODE_OPTION_INPUT";function Xe(e){var i;const{value:t,onChange:a}=e,n=o.useDependency(o.LocaleService);return h.jsx(b.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:h.jsxs(b.RadioGroup,{value:`${(i=t.renderMode)!=null?i:o.DataValidationRenderMode.CUSTOM}`,onChange:r=>a({...t,renderMode:+r}),children:[h.jsx(b.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),h.jsx(b.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),h.jsx(b.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}Xe.componentKey=pa;const ha="DATE_SHOW_TIME_OPTION";function ze(e){var i;const{value:t,onChange:a}=e,n=o.useDependency(o.LocaleService);return h.jsx(b.FormLayout,{children:h.jsx(b.Checkbox,{checked:(i=t.bizInfo)==null?void 0:i.showTime,onChange:r=>{a({...t,bizInfo:{...t.bizInfo,showTime:r}})},children:n.t("dataValidation.showTime.label")})})}ze.componentKey=ha;var ma=Object.defineProperty,va=Object.getOwnPropertyDescriptor,fa=(e,t,a,n)=>{for(var i=n>1?void 0:n?va(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&ma(t,a,i),i},Fe=(e,t)=>(a,n)=>t(a,n,e);const Ke=6;let ht=class{constructor(e,t,a,n,i){this._commandService=e,this._formulaService=t,this._themeService=a,this._renderManagerService=n,this._dataValidationModel=i}_calc(e,t){var u,p,m;const{vt:a,ht:n}=t||{},i=e.endX-e.startX-Ke*2,r=e.endY-e.startY,s=((u=t==null?void 0:t.fs)!=null?u:10)*1.6;let d=0,l=0;switch(a){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(r-s);break;default:l=0+(r-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:d=Ke;break;case o.HorizontalAlign.RIGHT:d=Ke+(i-s);break;default:d=Ke+(i-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((p=t==null?void 0:t.fs)!=null?p:10)*1.6,height:((m=t==null?void 0:t.fs)!=null?m:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var u,p,m,c,g,v,I,w,C;const{formula1:n=E.CHECKBOX_FORMULA_1,formula2:i=E.CHECKBOX_FORMULA_2}=e,r=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=E.getFormulaResult((m=(p=(u=r==null?void 0:r[0])==null?void 0:u.result)==null?void 0:p[0])==null?void 0:m[0]),d=E.getFormulaResult((v=(g=(c=r==null?void 0:r[1])==null?void 0:c.result)==null?void 0:g[0])==null?void 0:v[0]),l=E.isLegalFormulaResult(String(s))&&E.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(n)?E.getFormulaResult((C=(w=(I=r==null?void 0:r[0])==null?void 0:I.result)==null?void 0:w[0])==null?void 0:C[0]):n,formula2:o.isFormulaString(i)?d:i,isFormulaValid:l}}drawWith(e,t){var T,F,N,U;const{style:a,primaryWithCoord:n,unitId:i,subUnitId:r,worksheet:s,row:d,col:l}=t,u=n.isMergedMainCell?n.mergeInfo:n,p=E.getCellValueOrigin(s.getCellRaw(d,l)),m=this._dataValidationModel.getRuleByLocation(i,r,d,l);if(!m)return;const c=this._dataValidationModel.getValidator(m.type);if(!c)return;const g=this._themeService.getCurrentTheme();if(!((T=c.skipDefaultFontRender)!=null&&T.call(c,m,p,{unitId:i,subUnitId:r,row:d,column:l})))return;const v=c.parseFormulaSync(m,i,r),{formula1:I}=v,w=this._calc(u,a),{a:C,d:V}=e.getTransform(),y=B.fixLineWidthByScale(w.left,C),M=B.fixLineWidthByScale(w.top,V),D=B.Transform.create().composeMatrix({left:y,top:M,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),S=u.endX-u.startX,_=u.endY-u.startY;e.save(),e.beginPath(),e.rect(u.startX,u.startY,S,_),e.clip();const O=D.getMatrix();e.transform(O[0],O[1],O[2],O[3],O[4],O[5]);const j=((F=a==null?void 0:a.fs)!=null?F:10)*1.6,$=String(p)===String(I),A=g.hyacinth500;B.CheckboxShape.drawWith(e,{checked:$,width:j,height:j,fill:(U=(N=a==null?void 0:a.cl)==null?void 0:N.rgb)!=null?U:A}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),i=n.top,r=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:u}=e;return l<=d&&l>=s&&u<=r&&u>=i}async onPointerDown(e,t){var v;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:i,worksheet:r,row:s,col:d}=e,l=E.getCellValueOrigin(r.getCellRaw(s,d)),u=this._dataValidationModel.getRuleByLocation(n,i,s,d);if(!u)return;const p=this._dataValidationModel.getValidator(u.type);if(!p||!((v=p.skipDefaultFontRender)!=null&&v.call(p,u,l,{unitId:n,subUnitId:i,row:s,column:d})))return;const{formula1:m,formula2:c}=await this._parseFormula(u,n,i),g={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(l)===E.transformCheckboxValue(String(m))?c:m,p:null}};this._commandService.executeCommand(X.SetRangeValuesCommand.id,g)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};ht=fa([Fe(0,o.ICommandService),Fe(1,o.Inject(E.DataValidationFormulaService)),Fe(2,o.Inject(o.ThemeService)),Fe(3,o.Inject(B.IRenderManagerService)),Fe(4,o.Inject(E.SheetDataValidationModel))],ht);var ga=Object.defineProperty,Sa=Object.getOwnPropertyDescriptor,_a=(e,t,a,n)=>{for(var i=n>1?void 0:n?Sa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&ga(t,a,i),i},Ia=(e,t)=>(a,n)=>t(a,n,e);let pe=class{constructor(e){L(this,"canvasRender",null);L(this,"dropdown");L(this,"optionsInput");L(this,"formulaInput",pt);this.injector=e}};pe=_a([Ia(0,o.Inject(o.Injector))],pe);class Ca extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CHECKBOX);L(this,"canvasRender",this.injector.createInstance(ht));L(this,"formulaInput",zt)}}class Da extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CUSTOM);L(this,"formulaInput",Xt)}}const ya="data-validation.formula-input";class wa extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DATE);L(this,"formulaInput",ya);L(this,"optionsInput",ze.componentKey);L(this,"dropdown",lt)}}class Va extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DECIMAL);L(this,"formulaInput",Ye)}}const Kt=4,Ea=0,mt=4,qt=4,vt=6,qe=6,De=14;function Ra(e,t){const a=B.FontCache.getTextSize(e,t),n=a.width+Kt*2,{ba:i,bd:r}=a,s=i+r;return{width:n,height:s+Ea*2,ba:i}}function ft(e,t,a,n){const i=De+vt*2,r=a-i,s=n-qe*2,d=e.map(c=>({layout:Ra(c,t),text:c}));let l;const u=[];d.forEach(c=>{const{layout:g}=c,{width:v,height:I}=g;!l||l.width+v+mt>r?(l={width:v,height:I,items:[{...c,left:0}]},u.push(l)):(l.items.push({...c,left:l.width+mt}),l.width=l.width+v+mt)});let p=0,m=0;return u.forEach((c,g)=>{m=Math.max(m,c.width),g===u.length-1?p+=c.height:p+=c.height+qt}),{lines:u,totalHeight:p,contentWidth:r,contentHeight:s,cellAutoHeight:p+qe*2,calcAutoWidth:m+i}}const Ma=8;class ba extends B.Shape{static drawWith(t,a){const{fontString:n,info:i,fill:r,color:s}=a,{layout:d,text:l}=i;t.save(),B.Rect.drawWith(t,{width:d.width,height:d.height,radius:Ma,fill:r||Ie}),t.translateWithPrecision(Kt,d.ba),t.font=n,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var Oa=Object.defineProperty,La=Object.getOwnPropertyDescriptor,Ta=(e,t,a,n)=>{for(var i=n>1?void 0:n?La(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Oa(t,a,i),i},gt=(e,t)=>(a,n)=>t(a,n,e);const Pa=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let St=class{constructor(e,t,a){L(this,"zIndex");L(this,"_dropdownInfoMap",new Map);this._commandService=e,this._renderManagerService=t,this._dataValidationModel=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,i){const r=a-De+4;let s=4;switch(i){case o.VerticalAlign.MIDDLE:s=(n-De)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-De+4;break}e.save(),e.translateWithPrecision(t.startX+r,t.startY+s),e.fillStyle="#565656",e.fill(Pa),e.restore()}drawWith(e,t,a,n){var Z,q;const{primaryWithCoord:i,row:r,col:s,style:d,data:l,subUnitId:u}=t,p=i.isMergedMainCell?i.mergeInfo:i,m=l==null?void 0:l.fontRenderExtension,{leftOffset:c=0,rightOffset:g=0,topOffset:v=0,downOffset:I=0}=m||{},w=this._ensureMap(u),C=this._generateKey(r,s),V=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,r,s);if(!V)return;const y=this._dataValidationModel.getValidator(V.type);if(!y)return;const M={startX:p.startX+c,endX:p.endX-g,startY:p.startY+v,endY:p.endY-I},D=M.endX-M.startX,S=M.endY-M.startY,{cl:_}=d||{},O=(Z=typeof _=="object"?_==null?void 0:_.rgb:_)!=null?Z:"#000",j=B.getFontStyleString(d!=null?d:void 0),{vt:$,ht:A}=d||{},T=$!=null?$:o.VerticalAlign.MIDDLE,F=(q=E.getCellValueOrigin(l))!=null?q:"",N=y.parseCellValue(F),U=y.getListWithColorMap(V),k=ft(N,j,D,S);this._drawDownIcon(e,M,D,S,T),e.save(),e.translateWithPrecision(M.startX,M.startY),e.beginPath(),e.rect(0,0,D-De,S),e.clip(),e.translateWithPrecision(vt,qe);let G=0;switch(T){case o.VerticalAlign.MIDDLE:G=(k.contentHeight-k.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:G=k.contentHeight-k.totalHeight;break}e.translateWithPrecision(0,G),k.lines.forEach((ee,te)=>{e.save();const{width:ae,height:ie,items:le}=ee;let oe=0;switch(A){case o.HorizontalAlign.RIGHT:oe=k.contentWidth-ae;break;case o.HorizontalAlign.CENTER:oe=(k.contentWidth-ae)/2;break}e.translate(oe,te*(ie+qt)),le.forEach(de=>{e.save(),e.translateWithPrecision(de.left,0),ba.drawWith(e,{...j,info:de,color:O,fill:U[de.text]}),e.restore()}),e.restore()}),e.restore(),w.set(C,{left:M.startX,top:M.startY,width:k.contentWidth+vt+De,height:k.contentHeight+qe*2})}calcCellAutoHeight(e){var D;const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:u=0,downOffset:p=0}=s||{},m=t.isMergedMainCell?t.mergeInfo:t,c={startX:m.startX+d,endX:m.endX-l,startY:m.startY+u,endY:m.endY-p},g=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!g)return;const v=this._dataValidationModel.getValidator(g.type);if(!v)return;const I=c.endX-c.startX,w=c.endY-c.startY,C=(D=E.getCellValueOrigin(n))!=null?D:"",V=v.parseCellValue(C),y=B.getFontStyleString(a!=null?a:void 0);return ft(V,y,I,w).cellAutoHeight}calcCellAutoWidth(e){var D;const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:u=0,downOffset:p=0}=s||{},m=t.isMergedMainCell?t.mergeInfo:t,c={startX:m.startX+d,endX:m.endX-l,startY:m.startY+u,endY:m.endY-p},g=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!g)return;const v=this._dataValidationModel.getValidator(g.type);if(!v)return;const I=c.endX-c.startX,w=c.endY-c.startY,C=(D=E.getCellValueOrigin(n))!=null?D:"",V=v.parseCellValue(C),y=B.getFontStyleString(a!=null?a:void 0);return ft(V,y,I,w).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:i}=n,{x:r}=e;return r>=i-De&&r<=i}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=e,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Ne.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};St=Ta([gt(0,o.ICommandService),gt(1,o.Inject(B.IRenderManagerService)),gt(2,o.Inject(E.SheetDataValidationModel))],St);class ja extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST_MULTIPLE);L(this,"canvasRender",this.injector.createInstance(St));L(this,"dropdown",We)}}var Aa=Object.defineProperty,Fa=Object.getOwnPropertyDescriptor,xa=(e,t,a,n)=>{for(var i=n>1?void 0:n?Fa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Aa(t,a,i),i},Ge=(e,t)=>(a,n)=>t(a,n,e);const ye=4,Ze=4,ce=14,he=6,Oe=4,_t=8,Na="#565656",Gt=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function Ua(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:o.BooleanNumber.FALSE,bl:o.BooleanNumber.FALSE,ul:{s:o.BooleanNumber.FALSE},st:{s:o.BooleanNumber.FALSE},ol:{s:o.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function Zt(e,t,a){const n=Ua(e,a),i=new o.DocumentDataModel(n),r=new B.DocumentViewModel(i);return{documentSkeleton:B.DocumentSkeleton.create(r,t),docModel:i,docViewModel:r}}function Je(e,t,a){const{documentSkeleton:n,docModel:i,docViewModel:r}=Zt(e,t,a);return{documents:new B.Documents(`DOCUMENTS_${o.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:i,docViewModel:r}}function Jt(e,t,a,n,i,r,s=!0){let d=0;const l=s?Oe:0;switch(i){case o.VerticalAlign.BOTTOM:d=t-n-l;break;case o.VerticalAlign.MIDDLE:d=(t-n)/2;break;default:d=l;break}d=Math.max(Oe,d);let u=0;switch(r){case o.HorizontalAlign.CENTER:u=(e-a)/2;break;case o.HorizontalAlign.RIGHT:u=e-a;break}return u=Math.max(he,u),{paddingLeft:u,paddingTop:d}}let It=class{constructor(e,t,a,n){L(this,"_dropdownInfoMap",new Map);L(this,"zIndex");this._localeService=e,this._commandService=t,this._renderManagerService=a,this._dataValidationModel=n}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,i,r,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,u=a-ce;let p;switch(r){case o.VerticalAlign.MIDDLE:p=(n-Ze)/2;break;case o.VerticalAlign.BOTTOM:p=n-l-i-Oe+(i/2-Ze/2);break;default:p=d+Oe+(i/2-Ze/2);break}e.save(),e.translateWithPrecision(t.startX+u,t.startY+p),e.fillStyle="#565656",e.fill(Gt),e.restore()}drawWith(e,t,a){const{primaryWithCoord:n,row:i,col:r,style:s,data:d,subUnitId:l}=t,u=n.isMergedMainCell?n.mergeInfo:n,p=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,r);if(!p)return;const m=this._dataValidationModel.getValidator(p.type);if(!m)return;const c=d==null?void 0:d.fontRenderExtension,{leftOffset:g=0,rightOffset:v=0,topOffset:I=0,downOffset:w=0}=c||{};if(!p||!m||!m||m.id.indexOf(o.DataValidationType.LIST)!==0||!m.skipDefaultFontRender(p))return;const C={startX:u.startX+g,endX:u.endX-v,startY:u.startY+I,endY:u.endY-w},V=C.endX-C.startX,y=C.endY-C.startY,M=this._ensureMap(l),D=this._generateKey(i,r),S=m.getListWithColor(p),_=E.getCellValueOrigin(d),O=`${_!=null?_:""}`,j=S.find(N=>N.label===O);let{tb:$,vt:A,ht:T,pd:F}=s||{};if($=$!=null?$:o.WrapStrategy.WRAP,A=A!=null?A:o.VerticalAlign.BOTTOM,T=T!=null?T:o.DEFAULT_STYLES.ht,F=F!=null?F:o.DEFAULT_STYLES.pd,p.renderMode===o.DataValidationRenderMode.ARROW){const{l:N=o.DEFAULT_STYLES.pd.l,t:U=o.DEFAULT_STYLES.pd.t,r:k=o.DEFAULT_STYLES.pd.r,b:G=o.DEFAULT_STYLES.pd.b}=F,Z=V-N-k-ce-4,{documentSkeleton:q,documents:ee,docModel:te}=Je(O,this._localeService,s);$===o.WrapStrategy.WRAP&&te.updateDocumentDataPageSize(Math.max(Z,1)),q.calculate(),q.getActualSize();const ae=B.getDocsSkeletonPageSize(q),{height:ie,width:le}=ae,{paddingTop:oe,paddingLeft:de}=Jt(Z,y-U-G,le,ie,A,T,!0);this._drawDownIcon(e,C,V,y,ie,A,F),e.save(),e.translateWithPrecision(C.startX+N,C.startY+U),e.beginPath(),e.rect(0,0,V-N-k,y-U-G),e.clip(),e.translateWithPrecision(0,oe),e.save(),e.translateWithPrecision(ye,0),e.beginPath(),e.rect(0,0,Z,ie),e.clip(),ee.render(e),e.translateWithPrecision(de,0),e.restore(),e.restore(),M.set(D,{left:C.endX+N+a.rowHeaderWidth-ce,top:C.startY+U+a.columnHeaderHeight,width:ce,height:y-U-G})}else{e.save(),e.translateWithPrecision(C.startX,C.startY),e.beginPath(),e.rect(0,0,V,y),e.clip();const N=V-he*2-ye-ce-4,{documentSkeleton:U,documents:k,docModel:G}=Je(O,this._localeService,s);$===o.WrapStrategy.WRAP&&G.updateDocumentDataPageSize(Math.max(N,1)),U.calculate();const Z=B.getDocsSkeletonPageSize(U),{height:q,width:ee}=Z,{paddingTop:te,paddingLeft:ae}=Jt(N,y,ee,q,A,T);e.translateWithPrecision(he,te);const ie=Math.max(V-he*2,1),le=q;B.Rect.drawWith(e,{width:ie,height:le,fill:(j==null?void 0:j.color)||Ie,radius:_t}),e.save(),e.translateWithPrecision(ye,0),e.beginPath(),e.rect(0,0,N,q),e.clip(),e.translateWithPrecision(ae,0),k.render(e),e.restore(),e.translateWithPrecision(N+ye+4,(q-Ze)/2),e.fillStyle=Na,e.fill(Gt),e.restore(),M.set(D,{left:C.startX+he+a.rowHeaderWidth,top:C.startY+te+a.columnHeaderHeight,width:ie,height:le})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:u=0,topOffset:p=0,downOffset:m=0}=d||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!c||c.renderMode===o.DataValidationRenderMode.TEXT)return;const g={startX:s.startX+l,endX:s.endX-u,startY:s.startY+p,endY:s.endY-m},v=g.endX-g.startX,I=E.getCellValueOrigin(n),w=`${I!=null?I:""}`;let{tb:C,pd:V}=a||{};const{t:y=o.DEFAULT_STYLES.pd.t,b:M=o.DEFAULT_STYLES.pd.b}=V!=null?V:{};if(C=C!=null?C:o.WrapStrategy.WRAP,c.renderMode===o.DataValidationRenderMode.ARROW){const D=v-ce,{documentSkeleton:S,docModel:_}=Je(w,this._localeService,a);C===o.WrapStrategy.WRAP&&_.updateDocumentDataPageSize(Math.max(D,1)),S.calculate(),S.getActualSize();const O=B.getDocsSkeletonPageSize(S),{height:j}=O;return j+y+M+Oe*2}else{const D=v-he*2-ye-ce,{documentSkeleton:S,docModel:_}=Zt(w,this._localeService,a);C===o.WrapStrategy.WRAP&&_.updateDocumentDataPageSize(Math.max(D,1)),S.calculate();const O=B.getDocsSkeletonPageSize(S),{height:j}=O;return j+Oe*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:i,col:r}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:u=0,topOffset:p=0,downOffset:m=0}=d||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,r);if(!c||c.renderMode===o.DataValidationRenderMode.TEXT)return;const g={startX:s.startX+l,endX:s.endX-u,startY:s.startY+p,endY:s.endY-m},v=g.endX-g.startX,I=E.getCellValueOrigin(n),w=`${I!=null?I:""}`;let{tb:C,pd:V}=a||{};const{l:y=o.DEFAULT_STYLES.pd.l,r:M=o.DEFAULT_STYLES.pd.r}=V!=null?V:{};C=C!=null?C:o.WrapStrategy.WRAP;let D=he*2+ce;switch(c.renderMode){case o.DataValidationRenderMode.ARROW:D=ce+he*2+M+y;break;case o.DataValidationRenderMode.CUSTOM:D=ce+he*2+ye*2+M+y+_t/2+1;break;default:D=ce+he*2+ye*2+M+y+_t/2+1}const S=v-D,{documentSkeleton:_,docModel:O}=Je(w,this._localeService,a);return C===o.WrapStrategy.WRAP&&O.updateDocumentDataPageSize(Math.max(S,1)),_.calculate(),_.getActualSize(),B.getDocsSkeletonPageSize(_).width+D}isHit(e,t){const{subUnitId:a,row:n,col:i}=t,s=this._ensureMap(a).get(this._generateKey(n,i)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,i);if(!d||!s||d.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:u,width:p,height:m}=s,{x:c,y:g}=e;return c>=u&&c<=u+p&&g>=l&&g<=l+m}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=e,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Ne.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};It=xa([Ge(0,o.Inject(o.LocaleService)),Ge(1,o.ICommandService),Ge(2,o.Inject(B.IRenderManagerService)),Ge(3,o.Inject(E.SheetDataValidationModel))],It);class Ba extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST);L(this,"canvasRender",this.injector.createInstance(It));L(this,"dropdown",We);L(this,"optionsInput",Xe.componentKey);L(this,"formulaInput",pt)}}class ka extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.TEXT_LENGTH);L(this,"formulaInput",Ye)}}class Wa extends pe{constructor(){super(...arguments);L(this,"id",o.DataValidationType.WHOLE);L(this,"formulaInput",Ye)}}var $a=Object.defineProperty,Ha=Object.getOwnPropertyDescriptor,Ya=(e,t,a,n)=>{for(var i=n>1?void 0:n?Ha(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&$a(t,a,i),i},Ct=(e,t)=>(a,n)=>t(a,n,e);let Le=class extends o.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[Nt,bt],[xe,Fn],[At,yn],[We,Mn],[lt,ln],[Xe.componentKey,Xe],[ze.componentKey,ze],...ua].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Va,Wa,ka,wa,Ca,Ba,ja,Da].forEach(e=>{const t=this._injector.createInstance(e),a=this._dataValidatorRegistryService.getValidatorItem(t.id);a&&(a.formulaInput=t.formulaInput,a.canvasRender=t.canvasRender,a.dropdown=t.dropdown,a.optionsInput=t.optionsInput)})}};Le=Ya([Ct(0,o.Inject(o.Injector)),Ct(1,o.Inject(z.ComponentManager)),Ct(2,o.Inject(J.DataValidatorRegistryService))],Le);var Xa=Object.defineProperty,za=Object.getOwnPropertyDescriptor,Ka=(e,t,a,n)=>{for(var i=n>1?void 0:n?za(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Xa(t,a,i),i},Dt=(e,t)=>(a,n)=>t(a,n,e);const qa="SHEET_DATA_VALIDATION_UI_PLUGIN";Y.UniverSheetsDataValidationUIPlugin=(Qe=class extends o.Plugin{constructor(t=Ue,a,n,i){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=o.merge({},Ue,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(rt,s)}onStarting(){[[ue],[fe],[Ae],[Ee],[be],[Me],[Re],[je],[Le]].forEach(t=>{this._injector.add(t)}),[$e,Ne,xt,ot,_e,Ft].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Re),this._injector.get(Me),this._injector.get(je),this._injector.get(Ae),this._injector.get(B.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[He])}onRendered(){this._injector.get(Le),this._injector.get(be)}onSteady(){this._injector.get(Ee)}},L(Qe,"pluginName",qa),L(Qe,"type",o.UniverInstanceType.UNIVER_SHEET),Qe),Y.UniverSheetsDataValidationUIPlugin=Ka([Dt(1,o.Inject(o.Injector)),Dt(2,o.ICommandService),Dt(3,o.IConfigService)],Y.UniverSheetsDataValidationUIPlugin);var Ga=Object.defineProperty,Za=Object.getOwnPropertyDescriptor,Ja=(e,t,a,n)=>{for(var i=n>1?void 0:n?Za(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(i=(n?s(t,a,i):s(i))||i);return n&&i&&Ga(t,a,i),i},yt=(e,t)=>(a,n)=>t(a,n,e);const Qa="SHEET_DATA_VALIDATION_UI_PLUGIN";Y.UniverSheetsDataValidationMobileUIPlugin=(et=class extends o.Plugin{constructor(t=Ue,a,n,i){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=o.merge({},Ue,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(rt,s)}onStarting(){[[ue],[fe],[Ae],[Ee],[be],[Me],[Re],[Le]].forEach(t=>{this._injector.add(t)}),[$e,Ne,xt,ot,_e,Ft].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Re),this._injector.get(Me),this._injector.get(B.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[He])}onRendered(){this._injector.get(Le),this._injector.get(be)}onSteady(){this._injector.get(Ee)}},L(et,"pluginName",Qa),L(et,"type",o.UniverInstanceType.UNIVER_SHEET),et),Y.UniverSheetsDataValidationMobileUIPlugin=Ja([yt(1,o.Inject(o.Injector)),yt(2,o.ICommandService),yt(3,o.IConfigService)],Y.UniverSheetsDataValidationMobileUIPlugin),Y.DATE_DROPDOWN_KEY=lt,Y.LIST_DROPDOWN_KEY=We,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@univerjs/sheets-data-validation-ui",
|
3
|
-
"version": "0.5.
|
3
|
+
"version": "0.5.2",
|
4
4
|
"private": false,
|
5
5
|
"description": "Data validation UI for Univer Sheets",
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
@@ -57,29 +57,29 @@
|
|
57
57
|
"@flatten-js/interval-tree": "^1.1.3",
|
58
58
|
"@univerjs/icons": "^0.2.8",
|
59
59
|
"clsx": "^2.1.1",
|
60
|
-
"@univerjs/core": "0.5.
|
61
|
-
"@univerjs/data-validation": "0.5.
|
62
|
-
"@univerjs/
|
63
|
-
"@univerjs/
|
64
|
-
"@univerjs/
|
65
|
-
"@univerjs/sheets-data-validation": "0.5.
|
66
|
-
"@univerjs/
|
67
|
-
"@univerjs/sheets
|
68
|
-
"@univerjs/
|
69
|
-
"@univerjs/sheets-
|
70
|
-
"@univerjs/ui": "0.5.
|
71
|
-
"@univerjs/sheets-ui": "0.5.
|
60
|
+
"@univerjs/core": "0.5.2",
|
61
|
+
"@univerjs/data-validation": "0.5.2",
|
62
|
+
"@univerjs/docs": "0.5.2",
|
63
|
+
"@univerjs/design": "0.5.2",
|
64
|
+
"@univerjs/engine-render": "0.5.2",
|
65
|
+
"@univerjs/sheets-data-validation": "0.5.2",
|
66
|
+
"@univerjs/engine-formula": "0.5.2",
|
67
|
+
"@univerjs/sheets": "0.5.2",
|
68
|
+
"@univerjs/sheets-numfmt": "0.5.2",
|
69
|
+
"@univerjs/sheets-ui": "0.5.2",
|
70
|
+
"@univerjs/ui": "0.5.2",
|
71
|
+
"@univerjs/sheets-formula-ui": "0.5.2"
|
72
72
|
},
|
73
73
|
"devDependencies": {
|
74
74
|
"less": "^4.2.1",
|
75
75
|
"postcss": "^8.4.49",
|
76
76
|
"react": "18.3.1",
|
77
77
|
"rxjs": "^7.8.1",
|
78
|
-
"tailwindcss": "^3.4.
|
78
|
+
"tailwindcss": "^3.4.16",
|
79
79
|
"typescript": "^5.7.2",
|
80
|
-
"vite": "^6.0.
|
81
|
-
"vitest": "^2.1.
|
82
|
-
"@univerjs-infra/shared": "0.5.
|
80
|
+
"vite": "^6.0.3",
|
81
|
+
"vitest": "^2.1.8",
|
82
|
+
"@univerjs-infra/shared": "0.5.2"
|
83
83
|
},
|
84
84
|
"space": {
|
85
85
|
".": {
|