@univerjs/sheets-data-validation-ui 0.6.10-nightly.202504171607 → 0.6.10-nightly.202504191606

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { Nullable, Disposable, ICommandService, Injector, IUniverInstanceService } from '@univerjs/core';
1
+ import { Nullable, Disposable, ICommandService, IConfigService, Injector, IUniverInstanceService } from '@univerjs/core';
2
2
  import { ISheetLocation, SheetsSelectionsService } from '@univerjs/sheets';
3
3
  import { DataValidatorRegistryService } from '@univerjs/data-validation';
4
4
  import { SheetDataValidationModel } from '@univerjs/sheets-data-validation';
@@ -26,13 +26,14 @@ export declare class DataValidationDropdownManagerService extends Disposable {
26
26
  private readonly _commandService;
27
27
  private readonly _editorBridgeService;
28
28
  private readonly _injector;
29
+ private readonly _configService;
29
30
  private _activeDropdown;
30
31
  private _activeDropdown$;
31
32
  private _currentPopup;
32
33
  activeDropdown$: import('rxjs').Observable<Nullable<IDataValidationDropdownParam>>;
33
34
  private _zenVisible;
34
35
  get activeDropdown(): Nullable<IDataValidationDropdownParam>;
35
- constructor(_univerInstanceService: IUniverInstanceService, _dataValidatorRegistryService: DataValidatorRegistryService, _zenZoneService: IZenZoneService, _dataValidationModel: SheetDataValidationModel, _sheetsSelectionsService: SheetsSelectionsService, _cellDropdownManagerService: ISheetCellDropdownManagerService, _sheetDataValidationModel: SheetDataValidationModel, _commandService: ICommandService, _editorBridgeService: IEditorBridgeService, _injector: Injector);
36
+ constructor(_univerInstanceService: IUniverInstanceService, _dataValidatorRegistryService: DataValidatorRegistryService, _zenZoneService: IZenZoneService, _dataValidationModel: SheetDataValidationModel, _sheetsSelectionsService: SheetsSelectionsService, _cellDropdownManagerService: ISheetCellDropdownManagerService, _sheetDataValidationModel: SheetDataValidationModel, _commandService: ICommandService, _editorBridgeService: IEditorBridgeService, _injector: Injector, _configService: IConfigService);
36
37
  private _init;
37
38
  private _getDropdownByCell;
38
39
  private _initSelectionChange;
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(P,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@univerjs/sheets-data-validation"),require("react/jsx-runtime"),require("@univerjs/design"),require("@univerjs/ui"),require("react"),require("@univerjs/sheets-formula-ui"),require("@univerjs/data-validation"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/engine-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-data-validation","react/jsx-runtime","@univerjs/design","@univerjs/ui","react","@univerjs/sheets-formula-ui","@univerjs/data-validation","rxjs","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/engine-formula"],r):(P=typeof globalThis<"u"?globalThis:P||self,r(P.UniverSheetsDataValidationUi={},P.UniverCore,P.UniverSheetsDataValidation,P.React,P.UniverDesign,P.UniverUi,P.React,P.UniverSheetsFormulaUi,P.UniverDataValidation,P.rxjs,P.UniverEngineRender,P.UniverSheets,P.UniverSheetsNumfmt,P.UniverSheetsUi,P.UniverEngineFormula))})(this,function(P,r,S,g,O,D,M,Je,z,ae,F,$,jt,k,Qe){"use strict";var vn=Object.defineProperty;var fn=(P,r,S)=>r in P?vn(P,r,{enumerable:!0,configurable:!0,writable:!0,value:S}):P[r]=S;var A=(P,r,S)=>fn(P,typeof r!="symbol"?r+"":r,S);var qe,Ze;const ee={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"},Ht=e=>{const{isTwoFormula:t=!1,value:n,onChange:a,showError:i,validResult:o}=e,s=D.useDependency(r.LocaleService),d=i?o==null?void 0:o.formula1:"",l=i?o==null?void 0:o.formula2:"";return t?g.jsxs(g.Fragment,{children:[g.jsx(O.FormLayout,{error:d,children:g.jsx(O.Input,{className:ee.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:c=>{a==null||a({...n,formula1:c})}})}),g.jsx("div",{className:ee.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),g.jsx(O.FormLayout,{error:l,children:g.jsx(O.Input,{className:ee.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula2,onChange:c=>{a==null||a({...n,formula2:c})}})})]}):g.jsx(O.FormLayout,{error:d,children:g.jsx(O.Input,{className:ee.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:c=>{a==null||a({formula1:c})}})})};function Wt(e){const{value:t,onChange:n,showError:a,validResult:i}=e,o=D.useDependency(r.LocaleService),s=a?i==null?void 0:i.formula1:"",d=a?i==null?void 0:i.formula2:"",[l,c]=M.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return g.jsxs(g.Fragment,{children:[g.jsx(O.FormLayout,{children:g.jsx(O.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),n==null||n({...t,formula1:void 0,formula2:void 0}))},children:o.t("dataValidation.checkbox.tips")})}),l?g.jsx(O.FormLayout,{label:o.t("dataValidation.checkbox.checked"),error:s,children:g.jsx(O.Input,{className:ee.dataValidationFormula,placeholder:o.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{n==null||n({...t,formula1:h||void 0})}})}):null,l?g.jsx(O.FormLayout,{label:o.t("dataValidation.checkbox.unchecked"),error:d,children:g.jsx(O.Input,{className:ee.dataValidationFormula,placeholder:o.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{n==null||n({...t,formula2:h||void 0})}})}):null]})}function $t(e){var p;const{unitId:t,subUnitId:n,value:a,onChange:i,showError:o,validResult:s}=e,d=o?s==null?void 0:s.formula1:void 0,l=M.useRef(null),[c,h]=M.useState(!1);return D.useSidebarClick(u=>{var v;((v=l.current)==null?void 0:v.isClickOutSide(u))&&h(!1)}),g.jsx(Je.FormulaEditor,{initValue:(p=a==null?void 0:a.formula1)!=null?p:"=",unitId:t,subUnitId:n,isFocus:c,onChange:u=>{const I=(u!=null?u:"").trim();I!==(a==null?void 0:a.formula1)&&(i==null||i({...a,formula1:I}))},errorText:d,onFocus:()=>h(!0),isSupportAcrossSheet:!0,ref:l})}var ne=function(){return ne=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},ne.apply(this,arguments)},Yt=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,a=Object.getOwnPropertySymbols(e);i<a.length;i++)t.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(n[a[i]]=e[a[i]]);return n},ge=M.forwardRef(function(e,t){var n=e.icon,a=e.id,i=e.className,o=e.extend,s=Yt(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(a," ").concat(i||"").trim(),l=M.useRef("_".concat(zt()));return ft(n,"".concat(a),{defIds:n.defIds,idSuffix:l.current},ne({ref:t,className:d},s),o)});function ft(e,t,n,a,i){return M.createElement(e.tag,ne(ne({key:t},xt(e,n,i)),a),(Xt(e,n).children||[]).map(function(o,s){return ft(o,"".concat(t,"-").concat(e.tag,"-").concat(s),n,void 0,i)}))}function xt(e,t,n){var a=ne({},e.attrs);n!=null&&n.colorChannel1&&a.fill==="colorChannel1"&&(a.fill=n.colorChannel1),e.tag==="mask"&&a.id&&(a.id=a.id+t.idSuffix),Object.entries(a).forEach(function(o){var s=o[0],d=o[1];s==="mask"&&typeof d=="string"&&(a[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&a["xlink:href"]&&(a["xlink:href"]=a["xlink:href"]+t.idSuffix),Object.entries(a).forEach(function(o){var s=o[0],d=o[1];typeof d=="string"&&(a[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),a}function Xt(e,t){var n,a=t.defIds;return!a||a.length===0?e:e.tag==="defs"&&(!((n=e.children)===null||n===void 0)&&n.length)?ne(ne({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&a&&a.indexOf(i.attrs.id)>-1?ne(ne({},i),{attrs:ne(ne({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function zt(){return Math.random().toString(36).substring(2,8)}ge.displayName="UniverIcon";var Kt={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"}}]},St=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"data-validation-single",ref:t,icon:Kt}))});St.displayName="DataValidationSingle";var Gt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},et=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"delete-single",ref:t,icon:Gt}))});et.displayName="DeleteSingle";var qt={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"}}]},_t=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"increase-single",ref:t,icon:qt}))});_t.displayName="IncreaseSingle";var Zt={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"}}]},It=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"more-down-single",ref:t,icon:Zt}))});It.displayName="MoreDownSingle";var Jt={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"}}]},Ct=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"more-up-single",ref:t,icon:Jt}))});Ct.displayName="MoreUpSingle";var Qt={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"}}]}]},yt=M.forwardRef(function(e,t){return M.createElement(ge,Object.assign({},e,{id:"sequence-single",ref:t,icon:Qt}))});yt.displayName="SequenceSingle";const Ce="#ECECEC",ea=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],ta=e=>{const{value:t,onChange:n,disabled:a}=e,[i,o]=M.useState(!1);return g.jsx(O.Select,{disabled:a,open:i,onDropdownVisibleChange:o,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ee.dataValidationFormulaColorSelect,value:t,onChange:n,labelRender:s=>g.jsx("div",{className:ee.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>g.jsx("div",{className:ee.dataValidationFormulaColorSelectPanel,children:ea.map(s=>g.jsx("div",{onClick:()=>{n(s),o(!1)},className:ee.dataValidationFormulaColorItem,style:{background:s}},s))})})},Vt=e=>{const{item:t,commonProps:n,style:a}=e,{onItemChange:i,onItemDelete:o}=n;return g.jsxs("div",{className:ee.dataValidationFormulaListItem,style:a,children:[t.isRef?null:g.jsx("div",{className:O.clsx(ee.dataValidationFormulaListItemDrag,"draggableHandle"),children:g.jsx(yt,{})}),g.jsx(ta,{value:t.color,onChange:s=>{i(t.id,t.label,s)}}),g.jsx(O.Input,{disabled:t.isRef,value:t.label,onChange:s=>{i(t.id,s,t.color)}}),t.isRef?null:g.jsx("div",{className:ee.dataValidationFormulaListItemIcon,children:g.jsx(et,{onClick:()=>o(t.id)})})]})};function aa(e){const{value:t,onChange:n=()=>{},unitId:a,subUnitId:i,validResult:o,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},h=M.useRef(null),[p,u]=M.useState(()=>r.isFormulaString(l)?"1":"0"),[I,v]=M.useState(p==="1"?l:"="),[T,w]=M.useState(p==="1"?l:"="),m=D.useDependency(r.LocaleService),f=D.useDependency(z.DataValidatorRegistryService),_=D.useDependency(z.DataValidationModel),R=D.useDependency(S.DataValidationFormulaController),[E,y]=M.useState(()=>c.split(",")),V=f.getValidatorItem(r.DataValidationType.LIST),[b,j]=M.useState([]),[W,B]=M.useState(""),N=s?o==null?void 0:o.formula1:"",H=M.useMemo(()=>_.ruleChange$.pipe(ae.debounceTime(16)),[]),K=D.useObservable(H),Y=D.useEvent(n);M.useEffect(()=>{(async()=>{await new Promise(L=>{setTimeout(()=>L(!0),100)});const U=_.getRuleById(a,i,d),C=U==null?void 0:U.formula1;if(r.isFormulaString(C)&&V&&U){const L=await V.getListAsync(U,a,i);j(L)}})()},[_,K,V,d,i,a]),M.useEffect(()=>{r.isFormulaString(l)&&l!==T&&(v(l),w(T))},[T,l]);const[X,G]=M.useState(()=>{const U=p!=="1"?S.deserializeListOptions(l):[],C=c.split(",");return U.map((L,x)=>({label:L,color:C[x]||Ce,isRef:!1,id:r.Tools.generateRandomId(4)}))}),J=(U,C,L)=>{const x=X.find(Q=>Q.id===U);x&&(x.label=C,x.color=L,G([...X]))},Z=U=>{const C=X.findIndex(L=>L.id===U);C!==-1&&(X.splice(C,1),G([...X]))},ie=c.split(","),ue=M.useMemo(()=>b.map((U,C)=>({label:U,color:ie[C]||Ce,id:`${C}`,isRef:!0})),[ie,b]),se=(U,C,L)=>{const x=[...E];x[+U]=L,y(x),Y({formula1:l,formula2:x.join(",")})},oe=()=>{G([...X,{label:"",color:Ce,isRef:!1,id:r.Tools.generateRandomId(4)}])};M.useEffect(()=>{if(p==="1")return;const U=new Set,C=[];X.map(L=>({labelList:L.label.split(","),item:L})).forEach(({item:L,labelList:x})=>{x.forEach(Q=>{U.has(Q)||(U.add(Q),C.push({label:Q,color:L.color}))})}),Y({formula1:S.serializeListOptions(C.map(L=>L.label)),formula2:C.map(L=>L.color===Ce?"":L.color).join(",")})},[X,Y,p,T,E]);const he=D.useEvent(async U=>{if(!r.isFormulaString(U)){Y==null||Y({formula1:"",formula2:c});return}R.getFormulaRefCheck(U)?(Y==null||Y({formula1:r.isFormulaString(U)?U:"",formula2:c}),B("")):(Y==null||Y({formula1:"",formula2:c}),v("="),B(m.t("dataValidation.validFail.formulaError")))}),pe=M.useRef(null),[me,Fe]=M.useState(!1);return D.useSidebarClick(U=>{var L;((L=pe.current)==null?void 0:L.isClickOutSide(U))&&Fe(!1)}),g.jsxs(g.Fragment,{children:[g.jsx(O.FormLayout,{label:m.t("dataValidation.list.options"),children:g.jsxs(O.RadioGroup,{value:p,onChange:U=>{u(U),v(T),U==="1"&&Y({formula1:T==="="?"":T,formula2:E.join(",")})},children:[g.jsx(O.Radio,{value:"0",children:m.t("dataValidation.list.customOptions")}),g.jsx(O.Radio,{value:"1",children:m.t("dataValidation.list.refOptions")})]})}),p==="1"?g.jsxs(g.Fragment,{children:[g.jsx(Je.FormulaEditor,{initValue:I,unitId:a,subUnitId:i,isFocus:me,onChange:(U="")=>{const C=(U!=null?U:"").trim();w(C),he(C)},errorText:N||W||void 0,onFocus:()=>Fe(!0),isSupportAcrossSheet:!0,ref:pe}),g.jsx("div",{ref:h,style:{marginTop:"12px"},children:ue.map(U=>g.jsx(Vt,{item:U,commonProps:{onItemChange:se},style:{marginBottom:12}},U.id))})]}):g.jsx(O.FormLayout,{error:N,children:g.jsxs("div",{ref:h,style:{marginTop:"-12px"},children:[g.jsx(O.DraggableList,{list:X,onListChange:G,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:U=>g.jsx(Vt,{item:U,commonProps:{onItemChange:J,onItemDelete:Z}},U.id),idKey:"id"}),g.jsxs("a",{className:ee.dataValidationFormulaListAdd,onClick:oe,children:[g.jsx(_t,{}),m.t("dataValidation.list.add")]})]})})]})}const na=[[S.CUSTOM_FORMULA_INPUT_NAME,$t],[S.BASE_FORMULA_INPUT_NAME,Ht],[S.LIST_FORMULA_INPUT_NAME,aa],[S.CHECKBOX_FORMULA_INPUT_NAME,Wt]];var ia=Object.getOwnPropertyDescriptor,oa=(e,t,n,a)=>{for(var i=a>1?void 0:a?ia(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},ra=(e,t)=>(n,a)=>t(n,a,e);P.BaseSheetDataValidatorView=class{constructor(t){A(this,"canvasRender",null);A(this,"dropdownType");A(this,"optionsInput");A(this,"formulaInput",S.LIST_FORMULA_INPUT_NAME);this.injector=t}},P.BaseSheetDataValidatorView=oa([ra(0,r.Inject(r.Injector))],P.BaseSheetDataValidatorView);var sa=Object.getOwnPropertyDescriptor,la=(e,t,n,a)=>{for(var i=a>1?void 0:a?sa(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Dt=(e,t)=>(n,a)=>t(n,a,e);let le=class extends r.Disposable{constructor(t,n){super();A(this,"_open$",new ae.BehaviorSubject(!1));A(this,"open$",this._open$.pipe(ae.distinctUntilChanged()));A(this,"_activeRule");A(this,"_activeRule$",new ae.BehaviorSubject(void 0));A(this,"activeRule$",this._activeRule$.asObservable());A(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=n,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).pipe(ae.filter(a=>!a)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(a=>{a.id===Ue&&(a.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=r.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};le=la([Dt(0,r.IUniverInstanceService),Dt(1,D.ISidebarService)],le);var da=Object.getOwnPropertyDescriptor,ca=(e,t,n,a)=>{for(var i=a>1?void 0:a?da(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},ye=(e,t)=>(n,a)=>t(n,a,e);let Ve=class extends r.Disposable{constructor(e,t,n,a,i,o){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=a,this._localeService=i,this._sheetsDataValidationValidatorService=o,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept($.VALIDATE_CELL,{handler:async(e,t,n)=>{const a=await e,{row:i,col:o,unitId:s,subUnitId:d}=t,l=this._dataValidationModel.getRuleIdByLocation(s,d,i,o),c=l?this._dataValidationModel.getRuleById(s,d,l):void 0;if(a===!1)return n(Promise.resolve(!1));if(!c||c.errorStyle!==r.DataValidationErrorStyle.STOP)return n(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,i,o)===r.DataValidationStatus.VALID?n(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:h.getRuleFinalError(c,{row:i,col:o,unitId:s,subUnitId:d})},footer:{title:M.createElement(O.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),n(Promise.resolve(!1)))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:M.createElement(O.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Ve=ca([ye(0,r.Inject($.SheetInterceptorService)),ye(1,r.Inject(S.SheetDataValidationModel)),ye(2,r.Inject(z.DataValidatorRegistryService)),ye(3,D.IDialogService),ye(4,r.Inject(r.LocaleService)),ye(5,r.Inject(S.SheetsDataValidationValidatorService))],Ve);var ua=Object.getOwnPropertyDescriptor,ha=(e,t,n,a)=>{for(var i=a>1?void 0:a?ua(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},de=(e,t)=>(n,a)=>t(n,a,e);const tt=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return r.dayjs(r.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=r.dayjs(e);if(t.isValid())return t};function pa(e,t){const n=jt.getPatternType(t);if(e===n)return t;switch(e){case"datetime":return"yyyy-MM-dd hh:mm:ss";case"date":return"yyyy-MM-dd";case"time":return"HH:mm:ss"}}let ve=class extends r.Disposable{constructor(t,n,a,i,o,s,d,l,c,h){super();A(this,"_activeDropdown");A(this,"_activeDropdown$",new ae.Subject);A(this,"_currentPopup",null);A(this,"activeDropdown$",this._activeDropdown$.asObservable());A(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=n,this._zenZoneService=a,this._dataValidationModel=i,this._sheetsSelectionsService=o,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,this._injector=h,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,n,a,i){const o=t?this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET);if(!o)return;const s=n?o.getSheetBySheetId(n):o.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(o.getUnitId(),s.getSheetId(),a,i);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(n=>!(n.primary&&this._getDropdownByCell(n.primary.unitId,n.primary.sheetId,n.primary.actualRow,n.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var T,w;const{location:n}=t,{row:a,col:i,unitId:o,subUnitId:s,workbook:d,worksheet:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(o,s,a,i);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let p;const u=async(m,f)=>{var W,B,N;if(!m)return!0;const _=m,R=l.getCell(a,i),E=_.format(f==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),y=(W=r.numfmt.parseDate(E))==null?void 0:W.v,V=f==="time"?y%1:y,b=d.getStyles().getStyleByCell(R),j=(N=(B=b==null?void 0:b.n)==null?void 0:B.pattern)!=null?N:"";return c.errorStyle!==r.DataValidationErrorStyle.STOP||await h.validator({value:V,unitId:o,subUnitId:s,row:a,column:i,worksheet:l,workbook:d,interceptValue:E.replace("Z","").replace("T"," "),t:r.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(k.SetCellEditVisibleOperation.id,{visible:!1,eventType:F.DeviceInputEventType.Keyboard,unitId:o,keycode:D.KeyCode.ESC}),await this._commandService.executeCommand($.SetRangeValuesCommand.id,{unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:V,t:2,p:null,f:null,si:null,s:{n:{pattern:pa(f,j)}}}}),!0):(this._injector.has(Ve)&&this._injector.get(Ve).showReject(h.getRuleFinalError(c,{row:a,col:i,unitId:o,subUnitId:s})),!1)};let I;switch(h.dropdownType){case z.DataValidatorDropdownType.DATE:{const m=S.getCellValueOrigin(l.getCellRaw(a,i)),f=tt(m),_=!!((T=c.bizInfo)!=null&&T.showTime);I={location:n,type:"datepicker",props:{showTime:_,onChange:R=>u(R,_?"datetime":"date"),defaultValue:f,patternType:"date"}};break}case z.DataValidatorDropdownType.TIME:{const m=S.getCellValueOrigin(l.getCellRaw(a,i)),f=tt(m);I={location:n,type:"datepicker",props:{onChange:_=>u(_,"time"),defaultValue:f,patternType:"time"}};break}case z.DataValidatorDropdownType.DATETIME:{const m=S.getCellValueOrigin(l.getCellRaw(a,i)),f=tt(m);I={location:n,type:"datepicker",props:{onChange:_=>u(_,"datetime"),defaultValue:f,patternType:"datetime"}};break}case z.DataValidatorDropdownType.LIST:case z.DataValidatorDropdownType.MULTIPLE_LIST:{const m=h.dropdownType===z.DataValidatorDropdownType.MULTIPLE_LIST,f=async b=>{const j=S.serializeListOptions(b),W={unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:j,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(k.SetCellEditVisibleOperation.id,{visible:!1,eventType:F.DeviceInputEventType.Keyboard,unitId:o,keycode:D.KeyCode.ESC}),this._commandService.executeCommand($.SetRangeValuesCommand.id,W),!m},_=(c==null?void 0:c.renderMode)===r.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,R=h.getListWithColor(c,o,s),E=S.getDataValidationCellValue(l.getCellRaw(a,i)),y=()=>{this._commandService.executeCommand(fe.id,{ruleId:c.uid}),p==null||p.dispose()},V=R.map(b=>({label:b.label,value:b.label,color:_||b.color?b.color:"transparent"}));I={location:n,type:"list",props:{onChange:b=>f(b),options:V,onEdit:y,defaultValue:E,multiple:m}};break}case z.DataValidatorDropdownType.CASCADE:{I={type:"cascader",props:{onChange:f=>{const _={unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:f.join("/"),p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(k.SetCellEditVisibleOperation.id,{visible:!1,eventType:F.DeviceInputEventType.Keyboard,unitId:o,keycode:D.KeyCode.ESC}),this._commandService.syncExecuteCommand($.SetRangeValuesCommand.id,_),!0},defaultValue:S.getDataValidationCellValue(l.getCellRaw(a,i)).split("/"),options:JSON.parse((w=c.formula1)!=null?w:"[]")},location:n};break}case z.DataValidatorDropdownType.COLOR:{I={type:"color",props:{onChange:f=>{const _={unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:f,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(k.SetCellEditVisibleOperation.id,{visible:!1,eventType:F.DeviceInputEventType.Keyboard,unitId:o,keycode:D.KeyCode.ESC}),this._commandService.syncExecuteCommand($.SetRangeValuesCommand.id,_),!0},defaultValue:S.getDataValidationCellValue(l.getCellRaw(a,i))},location:n};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(p=this._cellDropdownManagerService.showDropdown(I),!p)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const v=new r.DisposableCollection;v.add(p),v.add({dispose:()=>{var m,f;(f=(m=this._activeDropdown)==null?void 0:m.onHide)==null||f.call(m)}}),this._currentPopup=v}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,n,a,i,o){const s=this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(n);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),a,i);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!c||!c.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:a,col:i,unitId:t,subUnitId:n},onHide:o})}};ve=ha([de(0,r.IUniverInstanceService),de(1,r.Inject(z.DataValidatorRegistryService)),de(2,D.IZenZoneService),de(3,r.Inject(S.SheetDataValidationModel)),de(4,r.Inject($.SheetsSelectionsService)),de(5,r.Inject(k.ISheetCellDropdownManagerService)),de(6,r.Inject(S.SheetDataValidationModel)),de(7,r.ICommandService),de(8,k.IEditorBridgeService),de(9,r.Inject(r.Injector))],ve);const Ue="DataValidationPanel",fe={id:"data-validation.operation.open-validation-panel",type:r.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:n,isAdd:a}=t,i=e.get(le),o=e.get(z.DataValidationModel),s=e.get(r.IUniverInstanceService),d=e.get(D.ISidebarService),l=$.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,p=n?o.getRuleById(c,h,n):void 0;i.open(),i.setActiveRule(p&&{unitId:c,subUnitId:h,rule:p});const u=d.open({id:Ue,header:{title:a?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Ue},width:312,onClose:()=>i.close()});return i.setCloseDisposable(u),!0}},at={id:"data-validation.operation.close-validation-panel",type:r.CommandType.OPERATION,handler(e){return e.get(le).close(),!0}},wt={id:"data-validation.operation.toggle-validation-panel",type:r.CommandType.OPERATION,handler(e){const t=e.get(r.ICommandService),n=e.get(le);return n.open(),n.isOpen?t.executeCommand(at.id):t.executeCommand(fe.id),!0}},Ne={type:r.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const n=e.get(ve),{unitId:a,subUnitId:i,row:o,column:s}=t,d=n.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===a&&l.subUnitId===i&&l.row===o&&l.col===s||n.showDataValidationDropdown(a,i,o,s),!0}},Et={type:r.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(ve).hideDropdown(),!0):!1}},ke={type:r.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(r.IUniverInstanceService),n=$.getSheetCommandTarget(t);if(!n)return!1;const{workbook:a,worksheet:i}=n,o=S.createDefaultNewRule(e),s=e.get(r.ICommandService),d=a.getUnitId(),l=i.getSheetId(),c={rule:o,unitId:d,subUnitId:l};return s.syncExecuteCommand(S.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(fe.id,{ruleId:o.uid,isAdd:!0}),!0):!1}},Mt="sheets-data-validation-ui.config",Be={};var ma=Object.getOwnPropertyDescriptor,ga=(e,t,n,a)=>{for(var i=a>1?void 0:a?ma(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},De=(e,t)=>(n,a)=>t(n,a,e);const Se="SHEET_DATA_VALIDATION_ALERT";let Ae=class extends r.Disposable{constructor(e,t,n,a,i,o){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=a,this._zenZoneService=i,this._dataValidationModel=o,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ae.debounceTime(100)).subscribe(e=>{var t;if(e){const n=this._univerInstanceService.getUnit(e.location.unitId,r.UniverInstanceType.UNIVER_SHEET),a=n.getSheetBySheetId(e.location.subUnitId);if(!a)return;const i=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!i){this._cellAlertManagerService.removeAlert(Se);return}if(this._dataValidationModel.validator(i,{...e.location,workbook:n,worksheet:a})===r.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Se),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(Se);return}const l=this._dataValidationModel.getValidator(i.type);if(!l){this._cellAlertManagerService.removeAlert(Se);return}this._cellAlertManagerService.showAlert({type:k.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:Se});return}}this._cellAlertManagerService.removeAlert(Se)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(Se)}))}};Ae=ga([De(0,r.Inject(k.HoverManagerService)),De(1,r.Inject(k.CellAlertManagerService)),De(2,r.IUniverInstanceService),De(3,r.Inject(r.LocaleService)),De(4,D.IZenZoneService),De(5,r.Inject(S.SheetDataValidationModel))],Ae);var va=Object.getOwnPropertyDescriptor,fa=(e,t,n,a)=>{for(var i=a>1?void 0:a?va(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},nt=(e,t)=>(n,a)=>t(n,a,e);let we=class extends r.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(a,i)=>{const{source:o,target:s,unitId:d,subUnitId:l}=a,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=k.virtualizeDiscreteRanges([o,s]),[p,u]=h.ranges,{mapFunc:I}=h,v={row:p.startRow,col:p.startColumn},T=k.getAutoFillRepeatRange(p,u),w=new r.ObjectMatrix,m=new Set;T.forEach(y=>{const V=y.repeatStartCell,b=y.relativeRange,j={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},W={startRow:V.row,startColumn:V.col,endColumn:V.col,endRow:V.row};r.Range.foreach(b,(B,N)=>{const H=r.Rectangle.getPositionRange({startRow:B,startColumn:N,endColumn:N,endRow:B},j),{row:K,col:Y}=I(H.startRow,H.startColumn),X=this._sheetDataValidationModel.getRuleIdByLocation(d,l,K,Y)||"",G=r.Rectangle.getPositionRange({startRow:B,startColumn:N,endColumn:N,endRow:B},W),{row:J,col:Z}=I(G.startRow,G.startColumn);w.setValue(J,Z,X),m.add(X)})});const f=Array.from(m).map(y=>({id:y,ranges:r.queryObjectMatrix(w,V=>V===y)}));c.addRangeRules(f);const _=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:R,undoMutations:E}=S.getDataValidationDiffMutations(d,l,_,this._injector,"patched",i===k.APPLY_TYPE.ONLY_FORMAT);return{undos:E,redos:R}},n={id:S.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:a=>{const{source:i,unitId:o,subUnitId:s}=a;for(const d of i.rows)for(const l of i.cols){const c=this._sheetDataValidationModel.getRuleByLocation(o,s,d,l);if(c&&c.type===r.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(k.APPLY_TYPE.SERIES,!0);return}}},onFillData:(a,i,o)=>o===k.APPLY_TYPE.COPY||o===k.APPLY_TYPE.ONLY_FORMAT||o===k.APPLY_TYPE.SERIES?t(a,o):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};we=fa([nt(0,k.IAutoFillService),nt(1,r.Inject(S.SheetDataValidationModel)),nt(2,r.Inject(r.Injector))],we);var Sa=Object.getOwnPropertyDescriptor,_a=(e,t,n,a)=>{for(var i=a>1?void 0:a?Sa(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},it=(e,t)=>(n,a)=>t(n,a,e);let Ee=class extends r.Disposable{constructor(t,n,a){super();A(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=n,this._injector=a,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:S.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,n,a)=>this._collect(t,n,a),onPasteCells:(t,n,a,i)=>{const{copyType:o=k.COPY_TYPE.COPY,pasteType:s}=i,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=n;return this._generateMutations(l,{copyType:o,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,n,a){const i=new r.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:i};const o=this._injector.invoke(l=>$.rangeToDiscreteRange(a,l,t,n));if(!o)return;const{rows:s,cols:d}=o;s.forEach((l,c)=>{d.forEach((h,p)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,n,l,h);i.setValue(c,p,u!=null?u:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(n.copyType===k.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([k.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,k.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,k.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,k.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:i,subUnitId:o}=this._copyInfo;if(n.unitId!==i||o!==n.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(n.unitId,n.subUnitId).clone(),d=new r.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:p}=k.virtualizeDiscreteRanges([n.copyRange,t]),u=k.getRepeatRange(c,h,!0),I=new Map;u.forEach(({startRange:m})=>{var f;(f=this._copyInfo)==null||f.matrix.forValue((_,R,E)=>{const y=r.Rectangle.getPositionRange({startRow:_,endRow:_,startColumn:R,endColumn:R},m),V=`${o}-${E}`,b=this._sheetDataValidationModel.getRuleById(i,o,E);!this._sheetDataValidationModel.getRuleById(n.unitId,n.subUnitId,V)&&b&&I.set(V,{...b,uid:V});const{row:j,col:W}=p(y.startRow,y.startColumn);l.add(V),d.setValue(j,W,V)})});const v=Array.from(l).map(m=>({id:m,ranges:r.queryObjectMatrix(d,f=>f===m)}));s.addRangeRules(v);const{redoMutations:T,undoMutations:w}=S.getDataValidationDiffMutations(n.unitId,n.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(n.unitId,n.subUnitId),I.values()),this._injector,"patched",!1);return{redos:T,undos:w}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(i,o).clone(),d=new r.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:p}=k.virtualizeDiscreteRanges([n.copyRange,t]);k.getRepeatRange(c,h,!0).forEach(({startRange:w})=>{var m;(m=this._copyInfo)==null||m.matrix.forValue((f,_,R)=>{const E=r.Rectangle.getPositionRange({startRow:f,endRow:f,startColumn:_,endColumn:_},w),{row:y,col:V}=p(E.startRow,E.startColumn);d.setValue(y,V,R),l.add(R)})});const I=Array.from(l).map(w=>({id:w,ranges:r.queryObjectMatrix(d,m=>m===w)}));s.addRangeRules(I);const{redoMutations:v,undoMutations:T}=S.getDataValidationDiffMutations(i,o,s.diff(this._sheetDataValidationModel.getRules(i,o)),this._injector,"patched",!1);return{redos:v,undos:T}}}};Ee=_a([it(0,k.ISheetClipboardService),it(1,r.Inject(S.SheetDataValidationModel)),it(2,r.Inject(r.Injector))],Ee);var Ia=Object.getOwnPropertyDescriptor,Ca=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ia(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},ot=(e,t)=>(n,a)=>t(n,a,e);let Me=class extends r.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===S.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[$.WorkbookEditablePermission],rangeTypes:[$.RangeProtectionPermissionEditPoint],worksheetTypes:[$.WorksheetEditPermission,$.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===S.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[$.WorkbookEditablePermission],rangeTypes:[$.RangeProtectionPermissionEditPoint],worksheetTypes:[$.WorksheetEditPermission,$.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Me=Ca([ot(0,r.Inject(r.LocaleService)),ot(1,r.ICommandService),ot(2,r.Inject($.SheetPermissionCheckController))],Me);const Tt="data-validation-single",bt="sheet.menu.data-validation";function ya(e){return{id:bt,type:D.MenuItemType.SUBITEMS,icon:Tt,tooltip:"dataValidation.title",hidden$:D.getMenuHiddenObservable(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:k.getCurrentRangeDisable$(e,{workbookTypes:[$.WorkbookEditablePermission],worksheetTypes:[$.WorksheetSetCellStylePermission,$.WorksheetEditPermission],rangeTypes:[$.RangeProtectionPermissionEditPoint]})}}function Va(e){return{id:fe.id,title:"dataValidation.panel.title",type:D.MenuItemType.BUTTON}}function Da(e){return{id:ke.id,title:"dataValidation.panel.add",type:D.MenuItemType.BUTTON}}const wa={[D.RibbonStartGroup.FORMULAS_INSERT]:{[bt]:{order:9,menuItemFactory:ya,[fe.id]:{order:0,menuItemFactory:Va},[ke.id]:{order:1,menuItemFactory:Da}}}};var Ea=Object.getOwnPropertyDescriptor,Ot=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ea(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},q=(e,t)=>(n,a)=>t(n,a,e);const Rt={tr:{size:6,color:"#fe4b4b"}};let Te=class extends r.RxDisposable{constructor(e,t,n,a,i,o,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=a,this._autoHeightController=i,this._dropdownManagerService=o,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=c,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(wa)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var n;if(!e.visible){((n=this._dropdownManagerService.activeDropdown)==null?void 0:n.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:a,sheetId:i,row:o,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(a);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(a,i,o,s);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(c!=null&&c.dropdownType))return;const h=d.getActiveSheet();if(!h)return;const p=this._dropdownManagerService.activeDropdown,u=p==null?void 0:p.location;if(u&&u.unitId===a&&u.subUnitId===i&&u.row===o&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:a,subUnitId:i,row:o,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept($.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:$.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var m,f,_,R,E;const{row:a,col:i,unitId:o,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(o,s,a,i);if(!c)return n(e);const h=this._sheetDataValidationModel.getRuleById(o,s,c);if(!h)return n(e);const p=(m=this._dataValidationCacheService.getValue(o,s,a,i))!=null?m:r.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=t.rawData;let v;const T={get value(){var y;return v!==void 0||(v=(y=S.getCellValueOrigin(I))!=null?y:null),v}},w={get value(){var y;return`${(y=T.value)!=null?y:""}`}};return n({...e,markers:{...e==null?void 0:e.markers,...p===r.DataValidationStatus.INVALID?Rt:null},customRender:[...(f=e==null?void 0:e.customRender)!=null?f:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((_=e==null?void 0:e.fontRenderExtension)==null?void 0:_.isSkip)||((R=u==null?void 0:u.skipDefaultFontRender)==null?void 0:R.call(u,h,T.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,w.value,{get style(){const y=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?y.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,i)},interceptorAutoHeight:()=>{var j,W,B,N,H,K;const y=(W=(j=this._renderManagerService.getRenderById(o))==null?void 0:j.with(k.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!y)return;const V=y.worksheet.getMergedCell(a,i),b={data:e,style:y.getStyles().getStyleByCell(e),primaryWithCoord:y.getCellWithCoordByIndex((B=V==null?void 0:V.startRow)!=null?B:a,(N=V==null?void 0:V.startColumn)!=null?N:i),unitId:o,subUnitId:s,row:a,col:i,workbook:d,worksheet:l};return(K=(H=u==null?void 0:u.canvasRender)==null?void 0:H.calcCellAutoHeight)==null?void 0:K.call(H,b)},interceptorAutoWidth:()=>{var j,W,B,N,H,K;const y=(W=(j=this._renderManagerService.getRenderById(o))==null?void 0:j.with(k.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!y)return;const V=y.worksheet.getMergedCell(a,i),b={data:e,style:y.getStyles().getStyleByCell(e),primaryWithCoord:y.getCellWithCoordByIndex((B=V==null?void 0:V.startRow)!=null?B:a,(N=V==null?void 0:V.startColumn)!=null?N:i),unitId:o,subUnitId:s,row:a,col:i,workbook:d,worksheet:l};return(K=(H=u==null?void 0:u.canvasRender)==null?void 0:H.calcCellAutoWidth)==null?void 0:K.call(H,b)},coverable:((E=e==null?void 0:e.coverable)!=null?E:!0)&&!(h.type===r.DataValidationType.LIST||h.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ae.filter(e=>e.source==="command"),ae.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(n=>{var a;(n.rule.type===r.DataValidationType.LIST_MULTIPLE||n.rule.type===r.DataValidationType.LIST)&&(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(n.redos,this._commandService)}})}};Te=Ot([q(0,r.ICommandService),q(1,D.IMenuManagerService),q(2,F.IRenderManagerService),q(3,r.IUniverInstanceService),q(4,r.Inject(k.AutoHeightController)),q(5,r.Inject(ve)),q(6,r.Inject(S.SheetDataValidationModel)),q(7,r.Inject(z.DataValidatorRegistryService)),q(8,r.Inject($.SheetInterceptorService)),q(9,r.Inject(S.DataValidationCacheService)),q(10,r.Optional(k.IEditorBridgeService))],Te);let Lt=class extends r.RxDisposable{constructor(e,t,n,a,i,o,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=a,this._sheetInterceptorService=i,this._sheetDataValidationModel=o,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept($.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:$.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var w,m,f,_,R;const{row:a,col:i,unitId:o,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(o,s,a,i);if(!c)return n(e);const h=this._sheetDataValidationModel.getRuleById(o,s,c);if(!h)return n(e);const p=(w=this._dataValidationCacheService.getValue(o,s,a,i))!=null?w:r.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=l.getCellRaw(a,i),v=S.getCellValueOrigin(I),T=`${v!=null?v:""}`;return n({...e,markers:{...e==null?void 0:e.markers,...p===r.DataValidationStatus.INVALID?Rt:null},customRender:[...(m=e==null?void 0:e.customRender)!=null?m:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((f=e==null?void 0:e.fontRenderExtension)==null?void 0:f.isSkip)||((_=u==null?void 0:u.skipDefaultFontRender)==null?void 0:_.call(u,h,v,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,T,{get style(){const E=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?E.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,i)},interceptorAutoHeight:()=>{var b,j,W,B,N,H;const E=(j=(b=this._renderManagerService.getRenderById(o))==null?void 0:b.with(k.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:j.skeleton;if(!E)return;const y=E.worksheet.getMergedCell(a,i),V={data:e,style:E.getStyles().getStyleByCell(e),primaryWithCoord:E.getCellWithCoordByIndex((W=y==null?void 0:y.startRow)!=null?W:a,(B=y==null?void 0:y.startColumn)!=null?B:i),unitId:o,subUnitId:s,row:a,col:i,workbook:d,worksheet:l};return(H=(N=u==null?void 0:u.canvasRender)==null?void 0:N.calcCellAutoHeight)==null?void 0:H.call(N,V)},coverable:((R=e==null?void 0:e.coverable)!=null?R:!0)&&!(h.type===r.DataValidationType.LIST||h.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ae.filter(e=>e.source==="command"),ae.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(n=>{var a;(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(n.redos,this._commandService)}})}};Lt=Ot([q(0,r.ICommandService),q(1,F.IRenderManagerService),q(2,r.Inject(k.AutoHeightController)),q(3,r.Inject(z.DataValidatorRegistryService)),q(4,r.Inject($.SheetInterceptorService)),q(5,r.Inject(S.SheetDataValidationModel)),q(6,r.Inject(S.DataValidationCacheService))],Lt);var Ma=Object.getOwnPropertyDescriptor,Ta=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ma(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},At=(e,t)=>(n,a)=>t(n,a,e);let je=class extends r.Disposable{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var a;if(!t.length)return;const n=new Set;t.forEach(i=>{n.add(i.subUnitId)}),n.forEach(i=>{var o;(o=this._sheetSkeletonManagerService.getSkeletonParam(i))==null||o.skeleton.makeDirty(!0)}),(a=this._context.mainComponent)==null||a.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(r.bufferDebounceTime(16)).subscribe(e))}};je=Ta([At(1,r.Inject(S.SheetDataValidationModel)),At(2,r.Inject(k.SheetSkeletonManagerService))],je);const rt={dataValidationOptionsButton:"univer-data-validation-options-button",dataValidationOptionsButtonIcon:"univer-data-validation-options-button-icon"};function ba(e){var c;const t=D.useDependency(r.LocaleService),n=D.useDependency(D.ComponentManager),{value:a,onChange:i,extraComponent:o}=e,[s,d]=M.useState(!1),l=o?n.get(o):null;return g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:rt.dataValidationOptionsButton,onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?g.jsx(Ct,{className:rt.dataValidationOptionsButtonIcon}):g.jsx(It,{className:rt.dataValidationOptionsButtonIcon})]}),s&&g.jsxs(g.Fragment,{children:[l?g.jsx(l,{value:a,onChange:i}):null,g.jsx(O.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:g.jsxs(O.RadioGroup,{value:`${(c=a.errorStyle)!=null?c:r.DataValidationErrorStyle.WARNING}`,onChange:h=>i({...a,errorStyle:+h}),children:[g.jsx(O.Radio,{value:`${r.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),g.jsx(O.Radio,{value:`${r.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),g.jsx(O.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:g.jsx(O.Checkbox,{checked:a.showErrorMessage,onChange:()=>i({...a,showErrorMessage:!a.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),a.showErrorMessage?g.jsx(O.FormLayout,{children:g.jsx(O.Input,{value:a.error,onChange:h=>i({...a,error:h})})}):null]})]})}const be={dataValidationDetail:"univer-data-validation-detail",dataValidationDetailFormItem:"univer-data-validation-detail-form-item",dataValidationDetailButtons:"univer-data-validation-detail-buttons",dataValidationDetailButton:"univer-data-validation-detail-button"},Oa=e=>r.debounce(async(t,n,a,i)=>{const o=await e.executeCommand(t,n,a);i==null||i(o)},1e3);function Ra(e,t,n){var a,i,o,s;return t?((i=(a=e.getUnit(t))==null?void 0:a.getSheetBySheetName(n))==null?void 0:i.getSheetId())||"":((s=(o=e.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:o.getSheetBySheetName(n))==null?void 0:s.getSheetId())||""}function La(){var Fe,U;const[e,t]=M.useState(0),n=D.useDependency(le),a=D.useObservable(n.activeRule$,n.activeRule),{unitId:i,subUnitId:o,rule:s}=a||{},d=s.uid,l=D.useDependency(z.DataValidatorRegistryService),c=D.useDependency(r.IUniverInstanceService),h=D.useDependency(D.ComponentManager),p=D.useDependency(r.ICommandService),u=D.useDependency(z.DataValidationModel),I=D.useDependency(r.LocaleService),[v,T]=M.useState(s),w=l.getValidatorItem(v.type),[m,f]=M.useState(!1),_=l.getValidatorsByScope(z.DataValidatorRegistryScope.SHEET),[R,E]=M.useState(()=>v.ranges.map(C=>({unitId:"",sheetId:"",range:C}))),y=M.useMemo(()=>Oa(p),[p]),[V,b]=M.useState(!1),[j,W]=M.useState(!1),B=M.useRef(null),N=D.useDependency($.SheetsSelectionsService);if(M.useEffect(()=>()=>{const C=N.getCurrentLastSelection();C&&N.setSelections([C])},[N]),M.useEffect(()=>{p.onCommandExecuted(C=>{(C.id===r.UndoCommand.id||C.id===r.RedoCommand.id)&&setTimeout(()=>{const L=u.getRuleById(i,o,d);t(x=>x+1),L&&(T(L),E(L.ranges.map(x=>({unitId:"",sheetId:"",range:x}))))},20)})},[p,u,d,o,i]),!w)return null;const H=w.operators,K=w.operatorNames,Y=v.operator?z.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,X=()=>{var C,L,x;(L=(C=B.current)==null?void 0:C.editor)!=null&&L.isFocus()&&G((x=B.current)==null?void 0:x.getValue()),!(!v.ranges.length||V)&&(w.validatorFormula(v,i,o).success?n.setActiveRule(null):f(!0))},G=D.useEvent(C=>{const L=C.split(",").filter(Boolean).map(Qe.deserializeRangeWithSheet).map(te=>{const Bt=te.sheetName;if(Bt){const gn=Ra(c,te.unitId,Bt);return{...te,sheetId:gn}}return{...te,sheetId:""}});if(r.isUnitRangesEqual(L,R))return;E(L);const x=L.filter(te=>(!te.unitId||te.unitId===i)&&(!te.sheetId||te.sheetId===o)).map(te=>te.range);if(T({...v,ranges:x}),x.length===0)return;const Q={unitId:i,subUnitId:o,ruleId:d,ranges:x};y(S.UpdateSheetDataValidationRangeCommand.id,Q)}),J=C=>{if(r.shallowEqual(C,z.getRuleSetting(v)))return;T({...v,...C});const L={unitId:i,subUnitId:o,ruleId:d,setting:C};y(S.UpdateSheetDataValidationSettingCommand.id,L,void 0)},Z=async()=>{await p.executeCommand(S.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:i,subUnitId:o}),n.setActiveRule(null)},ie={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},ue=C=>{const L=l.getValidatorItem(C);if(!L)return;const x=L.operators,Q=u.getRuleById(i,o,d),te=C===(Q==null?void 0:Q.type)||C.includes("list")&&(Q!=null&&Q.type.includes("list"))?{...Q,type:C}:{...v,type:C,operator:x[0],formula1:void 0,formula2:void 0};T(te),p.executeCommand(S.UpdateSheetDataValidationSettingCommand.id,{unitId:i,subUnitId:o,ruleId:v.uid,setting:z.getRuleSetting(te)})},se=h.get(w.formulaInput),oe=M.useMemo(()=>R.map(C=>Qe.serializeRange(C.range)).join(","),[]),he=z.getRuleOptions(v),pe=C=>{r.shallowEqual(C,z.getRuleOptions(v))||(T({...v,...C}),y(S.UpdateSheetDataValidationOptionsCommand.id,{unitId:i,subUnitId:o,ruleId:d,options:C}))},me=!v.operator;return g.jsxs("div",{className:be.dataValidationDetail,children:[g.jsx(O.FormLayout,{label:I.t("dataValidation.panel.range"),error:!v.ranges.length||V?I.t("dataValidation.panel.rangeError"):"",children:g.jsx(Je.RangeSelector,{selectorRef:B,unitId:i,subUnitId:o,initialValue:oe,onChange:(C,L)=>{var x;!j&&((x=B.current)!=null&&x.verify())&&G(L)},onFocusChange:(C,L)=>{var x;W(C),!C&&L&&((x=B.current)!=null&&x.verify())&&G(L)},onVerify:C=>b(!C)})}),g.jsx(O.FormLayout,{label:I.t("dataValidation.panel.type"),children:g.jsx(O.Select,{options:(Fe=_==null?void 0:_.sort((C,L)=>C.order-L.order))==null?void 0:Fe.map(C=>({label:I.t(C.title),value:C.id})),value:v.type,onChange:ue,className:be.dataValidationDetailFormItem})}),H!=null&&H.length?g.jsx(O.FormLayout,{label:I.t("dataValidation.panel.operator"),children:g.jsx(O.Select,{options:[{value:"",label:I.t("dataValidation.operators.legal")},...H.map((C,L)=>({value:`${C}`,label:K[L]}))],value:`${v.operator}`,onChange:C=>{J({...ie,operator:C})},className:be.dataValidationDetailFormItem})}):null,se&&!me?g.jsx(O.FormLayout,{children:g.jsx(se,{isTwoFormula:Y,value:{formula1:v.formula1,formula2:v.formula2},onChange:C=>{J({...ie,...C})},showError:m,validResult:w.validatorFormula(v,i,o),unitId:i,subUnitId:o,ruleId:d},e+v.type)}):null,g.jsx(O.FormLayout,{children:g.jsx(O.Checkbox,{checked:(U=v.allowBlank)!=null?U:!0,onChange:()=>{var C;return J({...ie,allowBlank:!((C=v.allowBlank)==null||C)})},children:I.t("dataValidation.panel.allowBlank")})}),g.jsx(ba,{value:he,onChange:pe,extraComponent:w.optionsInput}),g.jsxs("div",{className:be.dataValidationDetailButtons,children:[g.jsx(O.Button,{className:be.dataValidationDetailButton,onClick:Z,children:I.t("dataValidation.panel.removeRule")}),g.jsx(O.Button,{className:be.dataValidationDetailButton,variant:"primary",onClick:X,children:I.t("dataValidation.panel.done")})]})]})}const He={dataValidationItemContainer:"univer-data-validation-item-container",dataValidationItemTitle:"univer-data-validation-item-title",dataValidationItemContent:"univer-data-validation-item-content",dataValidationItemIcon:"univer-data-validation-item-icon"},Aa=e=>{const{rule:t,onClick:n,unitId:a,subUnitId:i,disable:o}=e,s=D.useDependency(z.DataValidatorRegistryService),d=D.useDependency(r.ICommandService),l=D.useDependency(k.IMarkSelectionService),c=s.getValidatorItem(t.type),h=M.useRef(void 0),[p,u]=M.useState(!1),I=D.useDependency(r.ThemeService),v=D.useObservable(I.currentTheme$),T=M.useMemo(()=>{var _;const m=(_=v==null?void 0:v.loopColor2)!=null?_:"#49B811",f=new r.ColorKit(m).toRgb();return{fill:`rgba(${f.r}, ${f.g}, ${f.b}, 0.1)`,stroke:m}},[v]),w=m=>{d.executeCommand(S.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:a,subUnitId:i}),m.stopPropagation()};return M.useEffect(()=>()=>{var m;h.current&&((m=h.current)==null||m.forEach(f=>{f&&l.removeShape(f)}))},[l]),g.jsxs("div",{className:He.dataValidationItemContainer,onClick:n,onMouseEnter:()=>{o||(u(!0),h.current=t.ranges.map(m=>l.addShape({range:m,style:T,primary:null})))},onMouseLeave:()=>{var m;u(!1),(m=h.current)==null||m.forEach(f=>{f&&l.removeShape(f)}),h.current=void 0},children:[g.jsx("div",{className:He.dataValidationItemTitle,children:c==null?void 0:c.generateRuleName(t)}),g.jsx("div",{className:He.dataValidationItemContent,children:t.ranges.map(m=>Qe.serializeRange(m)).join(",")}),p?g.jsx("div",{className:He.dataValidationItemIcon,onClick:w,children:g.jsx(et,{})}):null]})},We={dataValidationList:"univer-data-validation-list",dataValidationListButtons:"univer-data-validation-list-buttons",dataValidationListButton:"univer-data-validation-list-button"};function Pa(e){const t=D.useDependency(S.SheetDataValidationModel),n=D.useDependency(r.IUniverInstanceService),a=D.useDependency(r.ICommandService),i=D.useDependency(r.Injector),o=D.useDependency(le),s=D.useDependency(r.LocaleService),[d,l]=M.useState([]),{workbook:c}=e,h=D.useObservable(c.activeSheet$,void 0,!0),p=c.getUnitId(),u=h==null?void 0:h.getSheetId();M.useEffect(()=>{l(t.getRules(p,u));const f=t.ruleChange$.subscribe(_=>{_.unitId===p&&_.subUnitId===u&&l(t.getRules(p,u))});return()=>{f.unsubscribe()}},[p,u,t]);const I=async()=>{const f=S.createDefaultNewRule(i),_={unitId:p,subUnitId:u,rule:f};await a.executeCommand(S.AddSheetDataValidationCommand.id,_),o.setActiveRule({unitId:p,subUnitId:u,rule:f})},v=()=>{a.executeCommand(S.RemoveSheetAllDataValidationCommand.id,{unitId:p,subUnitId:u})},w=(f=>{const _=n.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET),R=_.getActiveSheet(),E=_.getUnitId(),y=R.getSheetId();return f.map(b=>$.checkRangesEditablePermission(i,E,y,b.ranges)?{...b}:{...b,disable:!0})})(d),m=w==null?void 0:w.some(f=>f.disable);return g.jsxs("div",{className:We.dataValidationList,children:[w==null?void 0:w.map(f=>{var _;return g.jsx(Aa,{unitId:p,subUnitId:u,onClick:()=>{f.disable||o.setActiveRule({unitId:p,subUnitId:u,rule:f})},rule:f,disable:(_=f.disable)!=null?_:!1},f.uid)}),g.jsxs("div",{className:We.dataValidationListButtons,children:[d.length&&!m?g.jsx(O.Button,{className:We.dataValidationListButton,onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,g.jsx(O.Button,{className:We.dataValidationListButton,variant:"primary",onClick:I,children:s.t("dataValidation.panel.add")})]})]})}const Fa=()=>{const e=D.useDependency(le),t=D.useObservable(e.activeRule$,e.activeRule),n=D.useDependency(r.IUniverInstanceService),a=D.useObservable(()=>n.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),i=D.useObservable(()=>{var o;return(o=a==null?void 0:a.activeSheet$)!=null?o:ae.of(null)},void 0,void 0,[]);return!a||!i?null:t&&t.subUnitId===i.getSheetId()?g.jsx(La,{},t.rule.uid):g.jsx(Pa,{workbook:a})},Ua="LIST_RENDER_MODE_OPTION_INPUT";function $e(e){var i;const{value:t,onChange:n}=e,a=D.useDependency(r.LocaleService);return g.jsx(O.FormLayout,{label:a.t("dataValidation.renderMode.label"),children:g.jsxs(O.RadioGroup,{value:`${(i=t.renderMode)!=null?i:r.DataValidationRenderMode.CUSTOM}`,onChange:o=>n({...t,renderMode:+o}),children:[g.jsx(O.Radio,{value:`${r.DataValidationRenderMode.CUSTOM}`,children:a.t("dataValidation.renderMode.chip")}),g.jsx(O.Radio,{value:`${r.DataValidationRenderMode.ARROW}`,children:a.t("dataValidation.renderMode.arrow")}),g.jsx(O.Radio,{value:`${r.DataValidationRenderMode.TEXT}`,children:a.t("dataValidation.renderMode.text")})]})})}$e.componentKey=Ua;const Na="DATE_SHOW_TIME_OPTION";function Ye(e){var i;const{value:t,onChange:n}=e,a=D.useDependency(r.LocaleService);return g.jsx(O.FormLayout,{children:g.jsx(O.Checkbox,{checked:(i=t.bizInfo)==null?void 0:i.showTime,onChange:o=>{n({...t,bizInfo:{...t.bizInfo,showTime:o}})},children:a.t("dataValidation.showTime.label")})})}Ye.componentKey=Na;var ka=Object.getOwnPropertyDescriptor,Ba=(e,t,n,a)=>{for(var i=a>1?void 0:a?ka(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Oe=(e,t)=>(n,a)=>t(n,a,e);const xe=6;let st=class{constructor(e,t,n,a,i,o){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=a,this._renderManagerService=i,this._dataValidationModel=o}_calc(e,t){var c,h,p;const{vt:n,ht:a}=t||{},i=e.endX-e.startX-xe*2,o=e.endY-e.startY,s=((c=t==null?void 0:t.fs)!=null?c:10)*1.6;let d=0,l=0;switch(n){case r.VerticalAlign.TOP:l=0;break;case r.VerticalAlign.BOTTOM:l=0+(o-s);break;default:l=0+(o-s)/2;break}switch(a){case r.HorizontalAlign.LEFT:d=xe;break;case r.HorizontalAlign.RIGHT:d=xe+(i-s);break;default:d=xe+(i-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((p=t==null?void 0:t.fs)!=null?p:10)*1.6}}calcCellAutoHeight(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}calcCellAutoWidth(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}async _parseFormula(e,t,n){var c,h,p,u,I,v,T,w,m;const{formula1:a=S.CHECKBOX_FORMULA_1,formula2:i=S.CHECKBOX_FORMULA_2}=e,o=await this._formulaService.getRuleFormulaResult(t,n,e.uid),s=S.getFormulaResult((p=(h=(c=o==null?void 0:o[0])==null?void 0:c.result)==null?void 0:h[0])==null?void 0:p[0]),d=S.getFormulaResult((v=(I=(u=o==null?void 0:o[1])==null?void 0:u.result)==null?void 0:I[0])==null?void 0:v[0]),l=S.isLegalFormulaResult(String(s))&&S.isLegalFormulaResult(String(d));return{formula1:r.isFormulaString(a)?S.getFormulaResult((m=(w=(T=o==null?void 0:o[0])==null?void 0:T.result)==null?void 0:w[0])==null?void 0:m[0]):a,formula2:r.isFormulaString(i)?d:i,isFormulaValid:l}}drawWith(e,t){var N,H,K,Y;const{style:n,primaryWithCoord:a,unitId:i,subUnitId:o,worksheet:s,row:d,col:l}=t,c=a.isMergedMainCell?a.mergeInfo:a,h=S.getCellValueOrigin(s.getCellRaw(d,l)),p=this._dataValidationModel.getRuleByLocation(i,o,d,l);if(!p)return;const u=this._dataValidationModel.getValidator(p.type);if(!u)return;const I=this._themeService.getCurrentTheme();if(!((N=u.skipDefaultFontRender)!=null&&N.call(u,p,h,{unitId:i,subUnitId:o,row:d,column:l})))return;const v=u.parseFormulaSync(p,i,o),{formula1:T}=v,w=this._calc(c,n),{a:m,d:f}=e.getTransform(),_=F.fixLineWidthByScale(w.left,m),R=F.fixLineWidthByScale(w.top,f),E=F.Transform.create().composeMatrix({left:_,top:R,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),y=c.endX-c.startX,V=c.endY-c.startY;e.save(),e.beginPath(),e.rect(c.startX,c.startY,y,V),e.clip();const b=E.getMatrix();e.transform(b[0],b[1],b[2],b[3],b[4],b[5]);const j=((H=n==null?void 0:n.fs)!=null?H:10)*1.6,W=String(h)===String(T),B=I.hyacinth500;F.CheckboxShape.drawWith(e,{checked:W,width:j,height:j,fill:(Y=(K=n==null?void 0:n.cl)==null?void 0:K.rgb)!=null?Y:B}),e.restore()}isHit(e,t){const n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,a=this._calc(n,t.style),i=a.top,o=a.top+a.height,s=a.left,d=a.left+a.width,{x:l,y:c}=e;return l<=d&&l>=s&&c<=o&&c>=i}async onPointerDown(e,t){var v;if(t.button===2)return;const{primaryWithCoord:n,unitId:a,subUnitId:i,worksheet:o,row:s,col:d}=e,l=S.getCellValueOrigin(o.getCellRaw(s,d)),c=this._dataValidationModel.getRuleByLocation(a,i,s,d);if(!c)return;const h=this._dataValidationModel.getValidator(c.type);if(!h||!((v=h.skipDefaultFontRender)!=null&&v.call(h,c,l,{unitId:a,subUnitId:i,row:s,column:d})))return;const{formula1:p,formula2:u}=await this._parseFormula(c,a,i),I={range:{startColumn:n.actualColumn,endColumn:n.actualColumn,startRow:n.actualRow,endRow:n.actualRow},value:{v:String(l)===S.transformCheckboxValue(String(p))?u:p,p:null}};this._commandService.executeCommand($.SetRangeValuesCommand.id,I)}onPointerEnter(e,t){var n,a;(a=(n=F.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(F.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=F.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(F.CURSOR_TYPE.DEFAULT)}};st=Ba([Oe(0,r.ICommandService),Oe(1,r.IUniverInstanceService),Oe(2,r.Inject(S.DataValidationFormulaService)),Oe(3,r.Inject(r.ThemeService)),Oe(4,r.Inject(F.IRenderManagerService)),Oe(5,r.Inject(S.SheetDataValidationModel))],st);class ja extends P.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",r.DataValidationType.CHECKBOX);A(this,"canvasRender",this.injector.createInstance(st));A(this,"formulaInput",S.CHECKBOX_FORMULA_INPUT_NAME)}}class Ha extends P.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",r.DataValidationType.CUSTOM);A(this,"formulaInput",S.CUSTOM_FORMULA_INPUT_NAME)}}const Wa="data-validation.formula-input";class $a extends P.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",r.DataValidationType.DATE);A(this,"formulaInput",Wa);A(this,"optionsInput",Ye.componentKey);A(this,"dropdownType",z.DataValidatorDropdownType.DATE)}}class Ya extends P.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",r.DataValidationType.DECIMAL);A(this,"formulaInput",S.BASE_FORMULA_INPUT_NAME)}}const Pt=4,xa=0,lt=4,Ft=4,dt=6,Xe=6,_e=14;function Xa(e,t){const n=F.FontCache.getTextSize(e,t),a=n.width+Pt*2,{ba:i,bd:o}=n,s=i+o;return{width:a,height:s+xa*2,ba:i}}function ct(e,t,n,a){const i=_e+dt*2,o=n-i,s=a-Xe*2,d=e.map(u=>({layout:Xa(u,t),text:u}));let l;const c=[];d.forEach(u=>{const{layout:I}=u,{width:v,height:T}=I;!l||l.width+v+lt>o?(l={width:v,height:T,items:[{...u,left:0}]},c.push(l)):(l.items.push({...u,left:l.width+lt}),l.width=l.width+v+lt)});let h=0,p=0;return c.forEach((u,I)=>{p=Math.max(p,u.width),I===c.length-1?h+=u.height:h+=u.height+Ft}),{lines:c,totalHeight:h,contentWidth:o,contentHeight:s,cellAutoHeight:h+Xe*2,calcAutoWidth:p+i}}const za=8;class Ka extends F.Shape{static drawWith(t,n){const{fontString:a,info:i,fill:o,color:s}=n,{layout:d,text:l}=i;t.save(),F.Rect.drawWith(t,{width:d.width,height:d.height,radius:za,fill:o||Ce}),t.translateWithPrecision(Pt,d.ba),t.font=a,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var Ga=Object.getOwnPropertyDescriptor,qa=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ga(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},ze=(e,t)=>(n,a)=>t(n,a,e);const Za=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let ut=class{constructor(e,t,n,a){A(this,"zIndex");A(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,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,n,a,i){const o=n-_e+4;let s=4;switch(i){case r.VerticalAlign.MIDDLE:s=(a-_e)/2+4;break;case r.VerticalAlign.BOTTOM:s=a-_e+4;break}e.save(),e.translateWithPrecision(t.startX+o,t.startY+s),e.fillStyle="#565656",e.fill(Za),e.restore()}drawWith(e,t,n,a){var J,Z;const{primaryWithCoord:i,row:o,col:s,style:d,data:l,subUnitId:c}=t,h=i.isMergedMainCell?i.mergeInfo:i,p=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:I=0,topOffset:v=0,downOffset:T=0}=p||{},w=this._ensureMap(c),m=this._generateKey(o,s),f=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,o,s);if(!f)return;const _=this._dataValidationModel.getValidator(f.type);if(!_)return;const R={startX:h.startX+u,endX:h.endX-I,startY:h.startY+v,endY:h.endY-T},E=R.endX-R.startX,y=R.endY-R.startY,{cl:V}=d||{},b=(J=typeof V=="object"?V==null?void 0:V.rgb:V)!=null?J:"#000",j=F.getFontStyleString(d!=null?d:void 0),{vt:W,ht:B}=d||{},N=W!=null?W:r.VerticalAlign.MIDDLE,H=(Z=S.getCellValueOrigin(l))!=null?Z:"",K=_.parseCellValue(H),Y=_.getListWithColorMap(f),X=ct(K,j,E,y);this._drawDownIcon(e,R,E,y,N),e.save(),e.translateWithPrecision(R.startX,R.startY),e.beginPath(),e.rect(0,0,E-_e,y),e.clip(),e.translateWithPrecision(dt,Xe);let G=0;switch(N){case r.VerticalAlign.MIDDLE:G=(X.contentHeight-X.totalHeight)/2;break;case r.VerticalAlign.BOTTOM:G=X.contentHeight-X.totalHeight;break}e.translateWithPrecision(0,G),X.lines.forEach((ie,ue)=>{e.save();const{width:se,height:oe,items:he}=ie;let pe=0;switch(B){case r.HorizontalAlign.RIGHT:pe=X.contentWidth-se;break;case r.HorizontalAlign.CENTER:pe=(X.contentWidth-se)/2;break}e.translate(pe,ue*(oe+Ft)),he.forEach(me=>{e.save(),e.translateWithPrecision(me.left,0),Ka.drawWith(e,{...j,info:me,color:b,fill:Y[me.text]}),e.restore()}),e.restore()}),e.restore(),w.set(m,{left:R.startX,top:R.startY,width:X.contentWidth+dt+_e,height:X.contentHeight+Xe*2})}calcCellAutoHeight(e){var E;const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},p=t.isMergedMainCell?t.mergeInfo:t,u={startX:p.startX+d,endX:p.endX-l,startY:p.startY+c,endY:p.endY-h},I=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!I)return;const v=this._dataValidationModel.getValidator(I.type);if(!v)return;const T=u.endX-u.startX,w=u.endY-u.startY,m=(E=S.getCellValueOrigin(a))!=null?E:"",f=v.parseCellValue(m),_=F.getFontStyleString(n!=null?n:void 0);return ct(f,_,T,w).cellAutoHeight}calcCellAutoWidth(e){var E;const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},p=t.isMergedMainCell?t.mergeInfo:t,u={startX:p.startX+d,endX:p.endX-l,startY:p.startY+c,endY:p.endY-h},I=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!I)return;const v=this._dataValidationModel.getValidator(I.type);if(!v)return;const T=u.endX-u.startX,w=u.endY-u.startY,m=(E=S.getCellValueOrigin(a))!=null?E:"",f=v.parseCellValue(m),_=F.getFontStyleString(n!=null?n:void 0);return ct(f,_,T,w).calcAutoWidth}isHit(e,t){const{primaryWithCoord:n}=t,a=n.isMergedMainCell?n.mergeInfo:n,{endX:i}=a,{x:o}=e;return o>=i-_e&&o<=i}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:i,col:o}=e,s={unitId:n,subUnitId:a,row:i,column:o};this._commandService.executeCommand(Ne.id,s)}onPointerEnter(e,t){var n,a;return(a=(n=F.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(F.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;return(a=(n=F.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(F.CURSOR_TYPE.DEFAULT)}};ut=qa([ze(0,r.ICommandService),ze(1,r.IUniverInstanceService),ze(2,r.Inject(F.IRenderManagerService)),ze(3,r.Inject(S.SheetDataValidationModel))],ut);class Ja extends P.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",r.DataValidationType.LIST_MULTIPLE);A(this,"canvasRender",this.injector.createInstance(ut));A(this,"dropdownType",z.DataValidatorDropdownType.MULTIPLE_LIST)}}var Qa=Object.getOwnPropertyDescriptor,en=(e,t,n,a)=>{for(var i=a>1?void 0:a?Qa(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Pe=(e,t)=>(n,a)=>t(n,a,e);const Ie=4,Ke=4,re=14,ce=6,Re=4,ht=8,tn="#565656",Ut=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 an(e,t){const n=e.length;return{id:"d",body:{dataStream:`${e}${r.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:r.BooleanNumber.FALSE,bl:r.BooleanNumber.FALSE,ul:{s:r.BooleanNumber.FALSE},st:{s:r.BooleanNumber.FALSE},ol:{s:r.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:n}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function Nt(e,t,n){const a=an(e,n),i=new r.DocumentDataModel(a),o=new F.DocumentViewModel(i);return{documentSkeleton:F.DocumentSkeleton.create(o,t),docModel:i,docViewModel:o}}function Ge(e,t,n){const{documentSkeleton:a,docModel:i,docViewModel:o}=Nt(e,t,n);return{documents:new F.Documents(`DOCUMENTS_${r.Tools.generateRandomId()}`,a,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:a,docModel:i,docViewModel:o}}function kt(e,t,n,a,i,o,s=!0){let d=0;const l=s?Re:0;switch(i){case r.VerticalAlign.BOTTOM:d=t-a-l;break;case r.VerticalAlign.MIDDLE:d=(t-a)/2;break;default:d=l;break}d=Math.max(Re,d);let c=0;switch(o){case r.HorizontalAlign.CENTER:c=(e-n)/2;break;case r.HorizontalAlign.RIGHT:c=e-n;break}return c=Math.max(ce,c),{paddingLeft:c,paddingTop:d}}let pt=class{constructor(e,t,n,a,i){A(this,"_dropdownInfoMap",new Map);A(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=a,this._dataValidationModel=i}_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,n,a,i,o,s){const{t:d=r.DEFAULT_STYLES.pd.t,b:l=r.DEFAULT_STYLES.pd.b}=s,c=n-re;let h;switch(o){case r.VerticalAlign.MIDDLE:h=(a-Ke)/2;break;case r.VerticalAlign.BOTTOM:h=a-l-i-Re+(i/2-Ke/2);break;default:h=d+Re+(i/2-Ke/2);break}e.save(),e.translateWithPrecision(t.startX+c,t.startY+h),e.fillStyle="#565656",e.fill(Ut),e.restore()}drawWith(e,t,n){const{primaryWithCoord:a,row:i,col:o,style:s,data:d,subUnitId:l}=t,c=a.isMergedMainCell?a.mergeInfo:a,h=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,o);if(!h)return;const p=this._dataValidationModel.getValidator(h.type);if(!p)return;const u=d==null?void 0:d.fontRenderExtension,{leftOffset:I=0,rightOffset:v=0,topOffset:T=0,downOffset:w=0}=u||{};if(!h||!p||!p||p.id.indexOf(r.DataValidationType.LIST)!==0||!p.skipDefaultFontRender(h))return;const m={startX:c.startX+I,endX:c.endX-v,startY:c.startY+T,endY:c.endY-w},f=m.endX-m.startX,_=m.endY-m.startY,R=this._ensureMap(l),E=this._generateKey(i,o),y=p.getListWithColor(h),V=S.getCellValueOrigin(d),b=`${V!=null?V:""}`,j=y.find(K=>K.label===b);let{tb:W,vt:B,ht:N,pd:H}=s||{};if(W=W!=null?W:r.WrapStrategy.WRAP,B=B!=null?B:r.VerticalAlign.BOTTOM,N=N!=null?N:r.DEFAULT_STYLES.ht,H=H!=null?H:r.DEFAULT_STYLES.pd,h.renderMode===r.DataValidationRenderMode.ARROW){const{l:K=r.DEFAULT_STYLES.pd.l,t:Y=r.DEFAULT_STYLES.pd.t,r:X=r.DEFAULT_STYLES.pd.r,b:G=r.DEFAULT_STYLES.pd.b}=H,J=f-K-X-re-4,{documentSkeleton:Z,documents:ie,docModel:ue}=Ge(b,this._localeService,s);W===r.WrapStrategy.WRAP&&ue.updateDocumentDataPageSize(Math.max(J,1)),Z.calculate(),Z.getActualSize();const se=F.getDocsSkeletonPageSize(Z),{height:oe,width:he}=se,{paddingTop:pe,paddingLeft:me}=kt(J,_-Y-G,he,oe,B,N,!0);this._drawDownIcon(e,m,f,_,oe,B,H),e.save(),e.translateWithPrecision(m.startX+K,m.startY+Y),e.beginPath(),e.rect(0,0,f-K-X,_-Y-G),e.clip(),e.translateWithPrecision(0,pe),e.save(),e.translateWithPrecision(Ie,0),e.beginPath(),e.rect(0,0,J,oe),e.clip(),ie.render(e),e.translateWithPrecision(me,0),e.restore(),e.restore(),R.set(E,{left:m.endX+K+n.rowHeaderWidth-re,top:m.startY+Y+n.columnHeaderHeight,width:re,height:_-Y-G})}else{e.save(),e.translateWithPrecision(m.startX,m.startY),e.beginPath(),e.rect(0,0,f,_),e.clip();const K=f-ce*2-Ie-re-4,{documentSkeleton:Y,documents:X,docModel:G}=Ge(b,this._localeService,s);W===r.WrapStrategy.WRAP&&G.updateDocumentDataPageSize(Math.max(K,1)),Y.calculate();const J=F.getDocsSkeletonPageSize(Y),{height:Z,width:ie}=J,{paddingTop:ue,paddingLeft:se}=kt(K,_,ie,Z,B,N);e.translateWithPrecision(ce,ue);const oe=Math.max(f-ce*2,1),he=Z;F.Rect.drawWith(e,{width:oe,height:he,fill:(j==null?void 0:j.color)||Ce,radius:ht}),e.save(),e.translateWithPrecision(Ie,0),e.beginPath(),e.rect(0,0,K,Z),e.clip(),e.translateWithPrecision(se,0),X.render(e),e.restore(),e.translateWithPrecision(K+Ie+4,(Z-Ke)/2),e.fillStyle=tn,e.fill(Ut),e.restore(),R.set(E,{left:m.startX+ce+n.rowHeaderWidth,top:m.startY+ue+n.columnHeaderHeight,width:oe,height:he})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:p=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!u||u.renderMode===r.DataValidationRenderMode.TEXT)return;const I={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-p},v=I.endX-I.startX,T=S.getCellValueOrigin(a),w=`${T!=null?T:""}`;let{tb:m,pd:f}=n||{};const{t:_=r.DEFAULT_STYLES.pd.t,b:R=r.DEFAULT_STYLES.pd.b}=f!=null?f:{};if(m=m!=null?m:r.WrapStrategy.WRAP,u.renderMode===r.DataValidationRenderMode.ARROW){const E=v-re,{documentSkeleton:y,docModel:V}=Ge(w,this._localeService,n);m===r.WrapStrategy.WRAP&&V.updateDocumentDataPageSize(Math.max(E,1)),y.calculate(),y.getActualSize();const b=F.getDocsSkeletonPageSize(y),{height:j}=b;return j+_+R+Re*2}else{const E=v-ce*2-Ie-re,{documentSkeleton:y,docModel:V}=Nt(w,this._localeService,n);m===r.WrapStrategy.WRAP&&V.updateDocumentDataPageSize(Math.max(E,1)),y.calculate();const b=F.getDocsSkeletonPageSize(y),{height:j}=b;return j+Re*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:p=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!u||u.renderMode===r.DataValidationRenderMode.TEXT)return;const I={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-p},v=I.endX-I.startX,T=S.getCellValueOrigin(a),w=`${T!=null?T:""}`;let{tb:m,pd:f}=n||{};const{l:_=r.DEFAULT_STYLES.pd.l,r:R=r.DEFAULT_STYLES.pd.r}=f!=null?f:{};m=m!=null?m:r.WrapStrategy.WRAP;let E=ce*2+re;switch(u.renderMode){case r.DataValidationRenderMode.ARROW:E=re+ce*2+R+_;break;case r.DataValidationRenderMode.CUSTOM:E=re+ce*2+Ie*2+R+_+ht/2+1;break;default:E=re+ce*2+Ie*2+R+_+ht/2+1}const y=v-E,{documentSkeleton:V,docModel:b}=Ge(w,this._localeService,n);return m===r.WrapStrategy.WRAP&&b.updateDocumentDataPageSize(Math.max(y,1)),V.calculate(),V.getActualSize(),F.getDocsSkeletonPageSize(V).width+E}isHit(e,t){const{subUnitId:n,row:a,col:i}=t,s=this._ensureMap(n).get(this._generateKey(a,i)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,a,i);if(!d||!s||d.renderMode===r.DataValidationRenderMode.TEXT)return!1;const{top:l,left:c,width:h,height:p}=s,{x:u,y:I}=e;return u>=c&&u<=c+h&&I>=l&&I<=l+p}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:i,col:o}=e,s={unitId:n,subUnitId:a,row:i,column:o};this._commandService.executeCommand(Ne.id,s)}onPointerEnter(e,t){var n,a;(a=(n=F.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(F.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=F.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(F.CURSOR_TYPE.DEFAULT)}};pt=en([Pe(0,r.IUniverInstanceService),Pe(1,r.Inject(r.LocaleService)),Pe(2,r.ICommandService),Pe(3,r.Inject(F.IRenderManagerService)),Pe(4,r.Inject(S.SheetDataValidationModel))],pt);class nn extends P.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",r.DataValidationType.LIST);A(this,"canvasRender",this.injector.createInstance(pt));A(this,"dropdownType",z.DataValidatorDropdownType.LIST);A(this,"optionsInput",$e.componentKey);A(this,"formulaInput",S.LIST_FORMULA_INPUT_NAME)}}class on extends P.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",r.DataValidationType.TEXT_LENGTH);A(this,"formulaInput",S.BASE_FORMULA_INPUT_NAME)}}class rn extends P.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",r.DataValidationType.WHOLE);A(this,"formulaInput",S.BASE_FORMULA_INPUT_NAME)}}var sn=Object.getOwnPropertyDescriptor,ln=(e,t,n,a)=>{for(var i=a>1?void 0:a?sn(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},mt=(e,t)=>(n,a)=>t(n,a,e);let Le=class extends r.RxDisposable{constructor(e,t,n){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=n,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[Tt,St],[Ue,Fa],[$e.componentKey,$e],[Ye.componentKey,Ye],...na].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Ya,rn,on,$a,ja,nn,Ja,Ha].forEach(e=>{const t=this._injector.createInstance(e),n=this._dataValidatorRegistryService.getValidatorItem(t.id);n&&(n.formulaInput=t.formulaInput,n.canvasRender=t.canvasRender,n.dropdownType=t.dropdownType,n.optionsInput=t.optionsInput)})}};Le=ln([mt(0,r.Inject(r.Injector)),mt(1,r.Inject(D.ComponentManager)),mt(2,r.Inject(z.DataValidatorRegistryService))],Le);var dn=Object.getOwnPropertyDescriptor,cn=(e,t,n,a)=>{for(var i=a>1?void 0:a?dn(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},gt=(e,t)=>(n,a)=>t(n,a,e);const un="SHEET_DATA_VALIDATION_UI_PLUGIN";P.UniverSheetsDataValidationUIPlugin=(qe=class extends r.Plugin{constructor(t=Be,n,a,i){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=i;const{menu:o,...s}=r.merge({},Be,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Mt,s)}onStarting(){[[le],[ve],[Ae],[we],[Te],[Me],[Ee],[Ve],[Le]].forEach(t=>{this._injector.add(t)}),[ke,Ne,Et,at,fe,wt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(Ve),this._injector.get(Ae),this._injector.get(F.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[je])}onRendered(){this._injector.get(Le),this._injector.get(Te)}onSteady(){this._injector.get(we)}},A(qe,"pluginName",un),A(qe,"type",r.UniverInstanceType.UNIVER_SHEET),qe),P.UniverSheetsDataValidationUIPlugin=cn([gt(1,r.Inject(r.Injector)),gt(2,r.ICommandService),gt(3,r.IConfigService)],P.UniverSheetsDataValidationUIPlugin);var hn=Object.getOwnPropertyDescriptor,pn=(e,t,n,a)=>{for(var i=a>1?void 0:a?hn(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},vt=(e,t)=>(n,a)=>t(n,a,e);const mn="SHEET_DATA_VALIDATION_UI_PLUGIN";P.UniverSheetsDataValidationMobileUIPlugin=(Ze=class extends r.Plugin{constructor(t=Be,n,a,i){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=i;const{menu:o,...s}=r.merge({},Be,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Mt,s)}onStarting(){[[le],[ve],[Ae],[we],[Te],[Me],[Ee],[Le]].forEach(t=>{this._injector.add(t)}),[ke,Ne,Et,at,fe,wt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(F.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[je])}onRendered(){this._injector.get(Le),this._injector.get(Te)}onSteady(){this._injector.get(we)}},A(Ze,"pluginName",mn),A(Ze,"type",r.UniverInstanceType.UNIVER_SHEET),Ze),P.UniverSheetsDataValidationMobileUIPlugin=pn([vt(1,r.Inject(r.Injector)),vt(2,r.ICommandService),vt(3,r.IConfigService)],P.UniverSheetsDataValidationMobileUIPlugin),Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
1
+ (function(F,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@univerjs/sheets-data-validation"),require("react/jsx-runtime"),require("@univerjs/design"),require("@univerjs/ui"),require("react"),require("@univerjs/sheets-formula-ui"),require("@univerjs/data-validation"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/engine-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-data-validation","react/jsx-runtime","@univerjs/design","@univerjs/ui","react","@univerjs/sheets-formula-ui","@univerjs/data-validation","rxjs","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/engine-formula"],r):(F=typeof globalThis<"u"?globalThis:F||self,r(F.UniverSheetsDataValidationUi={},F.UniverCore,F.UniverSheetsDataValidation,F.React,F.UniverDesign,F.UniverUi,F.React,F.UniverSheetsFormulaUi,F.UniverDataValidation,F.rxjs,F.UniverEngineRender,F.UniverSheets,F.UniverSheetsNumfmt,F.UniverSheetsUi,F.UniverEngineFormula))})(this,function(F,r,f,g,b,E,T,Je,x,ae,U,Y,jt,H,Qe){"use strict";var vn=Object.defineProperty;var fn=(F,r,f)=>r in F?vn(F,r,{enumerable:!0,configurable:!0,writable:!0,value:f}):F[r]=f;var R=(F,r,f)=>fn(F,typeof r!="symbol"?r+"":r,f);var qe,Ze;const ee={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"},Ht=e=>{const{isTwoFormula:t=!1,value:n,onChange:a,showError:i,validResult:o}=e,s=E.useDependency(r.LocaleService),d=i?o==null?void 0:o.formula1:"",l=i?o==null?void 0:o.formula2:"";return t?g.jsxs(g.Fragment,{children:[g.jsx(b.FormLayout,{error:d,children:g.jsx(b.Input,{className:ee.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:c=>{a==null||a({...n,formula1:c})}})}),g.jsx("div",{className:ee.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),g.jsx(b.FormLayout,{error:l,children:g.jsx(b.Input,{className:ee.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula2,onChange:c=>{a==null||a({...n,formula2:c})}})})]}):g.jsx(b.FormLayout,{error:d,children:g.jsx(b.Input,{className:ee.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:c=>{a==null||a({formula1:c})}})})};function Wt(e){const{value:t,onChange:n,showError:a,validResult:i}=e,o=E.useDependency(r.LocaleService),s=a?i==null?void 0:i.formula1:"",d=a?i==null?void 0:i.formula2:"",[l,c]=T.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return g.jsxs(g.Fragment,{children:[g.jsx(b.FormLayout,{children:g.jsx(b.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),n==null||n({...t,formula1:void 0,formula2:void 0}))},children:o.t("dataValidation.checkbox.tips")})}),l?g.jsx(b.FormLayout,{label:o.t("dataValidation.checkbox.checked"),error:s,children:g.jsx(b.Input,{className:ee.dataValidationFormula,placeholder:o.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{n==null||n({...t,formula1:h||void 0})}})}):null,l?g.jsx(b.FormLayout,{label:o.t("dataValidation.checkbox.unchecked"),error:d,children:g.jsx(b.Input,{className:ee.dataValidationFormula,placeholder:o.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{n==null||n({...t,formula2:h||void 0})}})}):null]})}function $t(e){var p;const{unitId:t,subUnitId:n,value:a,onChange:i,showError:o,validResult:s}=e,d=o?s==null?void 0:s.formula1:void 0,l=T.useRef(null),[c,h]=T.useState(!1);return E.useSidebarClick(u=>{var m;((m=l.current)==null?void 0:m.isClickOutSide(u))&&h(!1)}),g.jsx(Je.FormulaEditor,{initValue:(p=a==null?void 0:a.formula1)!=null?p:"=",unitId:t,subUnitId:n,isFocus:c,onChange:u=>{const C=(u!=null?u:"").trim();C!==(a==null?void 0:a.formula1)&&(i==null||i({...a,formula1:C}))},errorText:d,onFocus:()=>h(!0),isSupportAcrossSheet:!0,ref:l})}var ne=function(){return ne=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},ne.apply(this,arguments)},Yt=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,a=Object.getOwnPropertySymbols(e);i<a.length;i++)t.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(n[a[i]]=e[a[i]]);return n},ve=T.forwardRef(function(e,t){var n=e.icon,a=e.id,i=e.className,o=e.extend,s=Yt(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(a," ").concat(i||"").trim(),l=T.useRef("_".concat(zt()));return St(n,"".concat(a),{defIds:n.defIds,idSuffix:l.current},ne({ref:t,className:d},s),o)});function St(e,t,n,a,i){return T.createElement(e.tag,ne(ne({key:t},xt(e,n,i)),a),(Xt(e,n).children||[]).map(function(o,s){return St(o,"".concat(t,"-").concat(e.tag,"-").concat(s),n,void 0,i)}))}function xt(e,t,n){var a=ne({},e.attrs);n!=null&&n.colorChannel1&&a.fill==="colorChannel1"&&(a.fill=n.colorChannel1),e.tag==="mask"&&a.id&&(a.id=a.id+t.idSuffix),Object.entries(a).forEach(function(o){var s=o[0],d=o[1];s==="mask"&&typeof d=="string"&&(a[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&a["xlink:href"]&&(a["xlink:href"]=a["xlink:href"]+t.idSuffix),Object.entries(a).forEach(function(o){var s=o[0],d=o[1];typeof d=="string"&&(a[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),a}function Xt(e,t){var n,a=t.defIds;return!a||a.length===0?e:e.tag==="defs"&&(!((n=e.children)===null||n===void 0)&&n.length)?ne(ne({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&a&&a.indexOf(i.attrs.id)>-1?ne(ne({},i),{attrs:ne(ne({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function zt(){return Math.random().toString(36).substring(2,8)}ve.displayName="UniverIcon";var Kt={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"}}]},_t=T.forwardRef(function(e,t){return T.createElement(ve,Object.assign({},e,{id:"data-validation-single",ref:t,icon:Kt}))});_t.displayName="DataValidationSingle";var Gt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},et=T.forwardRef(function(e,t){return T.createElement(ve,Object.assign({},e,{id:"delete-single",ref:t,icon:Gt}))});et.displayName="DeleteSingle";var qt={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"}}]},It=T.forwardRef(function(e,t){return T.createElement(ve,Object.assign({},e,{id:"increase-single",ref:t,icon:qt}))});It.displayName="IncreaseSingle";var Zt={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"}}]},Ct=T.forwardRef(function(e,t){return T.createElement(ve,Object.assign({},e,{id:"more-down-single",ref:t,icon:Zt}))});Ct.displayName="MoreDownSingle";var Jt={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"}}]},yt=T.forwardRef(function(e,t){return T.createElement(ve,Object.assign({},e,{id:"more-up-single",ref:t,icon:Jt}))});yt.displayName="MoreUpSingle";var Qt={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"}}]}]},Vt=T.forwardRef(function(e,t){return T.createElement(ve,Object.assign({},e,{id:"sequence-single",ref:t,icon:Qt}))});Vt.displayName="SequenceSingle";const ye="#ECECEC",ea=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],ta=e=>{const{value:t,onChange:n,disabled:a}=e,[i,o]=T.useState(!1);return g.jsx(b.Select,{disabled:a,open:i,onDropdownVisibleChange:o,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ee.dataValidationFormulaColorSelect,value:t,onChange:n,labelRender:s=>g.jsx("div",{className:ee.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>g.jsx("div",{className:ee.dataValidationFormulaColorSelectPanel,children:ea.map(s=>g.jsx("div",{onClick:()=>{n(s),o(!1)},className:ee.dataValidationFormulaColorItem,style:{background:s}},s))})})},Dt=e=>{const{item:t,commonProps:n,style:a}=e,{onItemChange:i,onItemDelete:o}=n;return g.jsxs("div",{className:ee.dataValidationFormulaListItem,style:a,children:[t.isRef?null:g.jsx("div",{className:b.clsx(ee.dataValidationFormulaListItemDrag,"draggableHandle"),children:g.jsx(Vt,{})}),g.jsx(ta,{value:t.color,onChange:s=>{i(t.id,t.label,s)}}),g.jsx(b.Input,{disabled:t.isRef,value:t.label,onChange:s=>{i(t.id,s,t.color)},inputStyle:{height:28}}),t.isRef?null:g.jsx("div",{className:ee.dataValidationFormulaListItemIcon,children:g.jsx(et,{onClick:()=>o(t.id)})})]})};function aa(e){const{value:t,onChange:n=()=>{},unitId:a,subUnitId:i,validResult:o,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},[h,p]=T.useState(()=>r.isFormulaString(l)?"1":"0"),[u,C]=T.useState(h==="1"?l:"="),[m,O]=T.useState(h==="1"?l:"="),M=E.useDependency(r.LocaleService),v=E.useDependency(x.DataValidatorRegistryService),_=E.useDependency(x.DataValidationModel),S=E.useDependency(f.DataValidationFormulaController),[V,D]=T.useState(()=>c.split(",")),y=v.getValidatorItem(r.DataValidationType.LIST),[w,L]=T.useState([]),[W,A]=T.useState(""),B=s?o==null?void 0:o.formula1:"",k=T.useMemo(()=>_.ruleChange$.pipe(ae.debounceTime(16)),[]),j=E.useObservable(k),P=E.useEvent(n);T.useEffect(()=>{(async()=>{await new Promise(I=>{setTimeout(()=>I(!0),100)});const N=_.getRuleById(a,i,d),G=N==null?void 0:N.formula1;if(r.isFormulaString(G)&&y&&N){const I=await y.getListAsync(N,a,i);L(I)}})()},[_,j,y,d,i,a]),T.useEffect(()=>{r.isFormulaString(l)&&l!==m&&(C(l),O(m))},[m,l]);const[X,z]=T.useState(()=>{const N=h!=="1"?f.deserializeListOptions(l):[],G=c.split(",");return N.map((I,$)=>({label:I,color:G[$]||ye,isRef:!1,id:r.Tools.generateRandomId(4)}))}),Z=(N,G,I)=>{const $=X.find(K=>K.id===N);$&&($.label=G,$.color=I,z([...X]))},Q=N=>{const G=X.findIndex(I=>I.id===N);G!==-1&&(X.splice(G,1),z([...X]))},J=c.split(","),ie=T.useMemo(()=>w.map((N,G)=>({label:N,color:J[G]||ye,id:`${G}`,isRef:!0})),[J,w]),he=(N,G,I)=>{const $=[...V];$[+N]=I,D($),P({formula1:l,formula2:$.join(",")})},le=()=>{z([...X,{label:"",color:ye,isRef:!1,id:r.Tools.generateRandomId(4)}])};T.useEffect(()=>{if(h==="1")return;const N=new Set,G=[];X.map(I=>({labelList:I.label.split(","),item:I})).forEach(({item:I,labelList:$})=>{$.forEach(K=>{N.has(K)||(N.add(K),G.push({label:K,color:I.color}))})}),P({formula1:f.serializeListOptions(G.map(I=>I.label)),formula2:G.map(I=>I.color===ye?"":I.color).join(",")})},[X,P,h,m,V]);const oe=E.useEvent(async N=>{if(!r.isFormulaString(N)){P==null||P({formula1:"",formula2:c});return}S.getFormulaRefCheck(N)?(P==null||P({formula1:r.isFormulaString(N)?N:"",formula2:c}),A("")):(P==null||P({formula1:"",formula2:c}),C("="),A(M.t("dataValidation.validFail.formulaError")))}),de=T.useRef(null),[me,pe]=T.useState(!1);return E.useSidebarClick(N=>{var I;((I=de.current)==null?void 0:I.isClickOutSide(N))&&pe(!1)}),g.jsxs(g.Fragment,{children:[g.jsx(b.FormLayout,{label:M.t("dataValidation.list.options"),children:g.jsxs(b.RadioGroup,{value:h,onChange:N=>{p(N),C(m),N==="1"&&P({formula1:m==="="?"":m,formula2:V.join(",")})},children:[g.jsx(b.Radio,{value:"0",children:M.t("dataValidation.list.customOptions")}),g.jsx(b.Radio,{value:"1",children:M.t("dataValidation.list.refOptions")})]})}),h==="1"?g.jsxs(g.Fragment,{children:[g.jsx(Je.FormulaEditor,{initValue:u,unitId:a,subUnitId:i,isFocus:me,onChange:(N="")=>{const G=(N!=null?N:"").trim();O(G),oe(G)},errorText:B||W||void 0,onFocus:()=>pe(!0),isSupportAcrossSheet:!0,ref:de}),ie.length>0&&g.jsx("div",{style:{marginTop:"12px"},children:ie.map(N=>g.jsx(Dt,{item:N,commonProps:{onItemChange:he},style:{marginBottom:12}},N.id))})]}):g.jsx(b.FormLayout,{error:B,children:g.jsxs("div",{style:{marginTop:"-12px"},children:[g.jsx(b.DraggableList,{list:X,onListChange:z,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:N=>g.jsx(Dt,{item:N,commonProps:{onItemChange:Z,onItemDelete:Q}},N.id),idKey:"id"}),g.jsxs("a",{className:ee.dataValidationFormulaListAdd,onClick:le,children:[g.jsx(It,{}),M.t("dataValidation.list.add")]})]})})]})}const na=[[f.CUSTOM_FORMULA_INPUT_NAME,$t],[f.BASE_FORMULA_INPUT_NAME,Ht],[f.LIST_FORMULA_INPUT_NAME,aa],[f.CHECKBOX_FORMULA_INPUT_NAME,Wt]];var ia=Object.getOwnPropertyDescriptor,oa=(e,t,n,a)=>{for(var i=a>1?void 0:a?ia(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},ra=(e,t)=>(n,a)=>t(n,a,e);F.BaseSheetDataValidatorView=class{constructor(t){R(this,"canvasRender",null);R(this,"dropdownType");R(this,"optionsInput");R(this,"formulaInput",f.LIST_FORMULA_INPUT_NAME);this.injector=t}},F.BaseSheetDataValidatorView=oa([ra(0,r.Inject(r.Injector))],F.BaseSheetDataValidatorView);var sa=Object.getOwnPropertyDescriptor,la=(e,t,n,a)=>{for(var i=a>1?void 0:a?sa(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},wt=(e,t)=>(n,a)=>t(n,a,e);let ce=class extends r.Disposable{constructor(t,n){super();R(this,"_open$",new ae.BehaviorSubject(!1));R(this,"open$",this._open$.pipe(ae.distinctUntilChanged()));R(this,"_activeRule");R(this,"_activeRule$",new ae.BehaviorSubject(void 0));R(this,"activeRule$",this._activeRule$.asObservable());R(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=n,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).pipe(ae.filter(a=>!a)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(a=>{a.id===Ne&&(a.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=r.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ce=la([wt(0,r.IUniverInstanceService),wt(1,E.ISidebarService)],ce);const tt="sheets-data-validation-ui.config",Ue={};var da=Object.getOwnPropertyDescriptor,ca=(e,t,n,a)=>{for(var i=a>1?void 0:a?da(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Ve=(e,t)=>(n,a)=>t(n,a,e);let De=class extends r.Disposable{constructor(e,t,n,a,i,o){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=a,this._localeService=i,this._sheetsDataValidationValidatorService=o,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(Y.VALIDATE_CELL,{handler:async(e,t,n)=>{const a=await e,{row:i,col:o,unitId:s,subUnitId:d}=t,l=this._dataValidationModel.getRuleIdByLocation(s,d,i,o),c=l?this._dataValidationModel.getRuleById(s,d,l):void 0;if(a===!1)return n(Promise.resolve(!1));if(!c||c.errorStyle!==r.DataValidationErrorStyle.STOP)return n(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,i,o)===r.DataValidationStatus.VALID?n(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:h.getRuleFinalError(c,{row:i,col:o,unitId:s,subUnitId:d})},footer:{title:T.createElement(b.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),n(Promise.resolve(!1)))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:T.createElement(b.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};De=ca([Ve(0,r.Inject(Y.SheetInterceptorService)),Ve(1,r.Inject(f.SheetDataValidationModel)),Ve(2,r.Inject(x.DataValidatorRegistryService)),Ve(3,E.IDialogService),Ve(4,r.Inject(r.LocaleService)),Ve(5,r.Inject(f.SheetsDataValidationValidatorService))],De);var ua=Object.getOwnPropertyDescriptor,ha=(e,t,n,a)=>{for(var i=a>1?void 0:a?ua(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},re=(e,t)=>(n,a)=>t(n,a,e);const at=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return r.dayjs(r.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=r.dayjs(e);if(t.isValid())return t};function pa(e,t){const n=jt.getPatternType(t);if(e===n)return t;switch(e){case"datetime":return"yyyy-MM-dd hh:mm:ss";case"date":return"yyyy-MM-dd";case"time":return"HH:mm:ss"}}let fe=class extends r.Disposable{constructor(t,n,a,i,o,s,d,l,c,h,p){super();R(this,"_activeDropdown");R(this,"_activeDropdown$",new ae.Subject);R(this,"_currentPopup",null);R(this,"activeDropdown$",this._activeDropdown$.asObservable());R(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=n,this._zenZoneService=a,this._dataValidationModel=i,this._sheetsSelectionsService=o,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,this._injector=h,this._configService=p,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,n,a,i){const o=t?this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET);if(!o)return;const s=n?o.getSheetBySheetId(n):o.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(o.getUnitId(),s.getSheetId(),a,i);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(n=>!(n.primary&&this._getDropdownByCell(n.primary.unitId,n.primary.sheetId,n.primary.actualRow,n.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var O,M,v,_;const{location:n}=t,{row:a,col:i,unitId:o,subUnitId:s,workbook:d,worksheet:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(o,s,a,i);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let p;const u=async(S,V)=>{var k,j,P;if(!S)return!0;const D=S,y=l.getCell(a,i),w=D.format(V==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),L=(k=r.numfmt.parseDate(w))==null?void 0:k.v,W=V==="time"?L%1:L,A=d.getStyles().getStyleByCell(y),B=(P=(j=A==null?void 0:A.n)==null?void 0:j.pattern)!=null?P:"";return c.errorStyle!==r.DataValidationErrorStyle.STOP||await h.validator({value:W,unitId:o,subUnitId:s,row:a,column:i,worksheet:l,workbook:d,interceptValue:w.replace("Z","").replace("T"," "),t:r.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(H.SetCellEditVisibleOperation.id,{visible:!1,eventType:U.DeviceInputEventType.Keyboard,unitId:o,keycode:E.KeyCode.ESC}),await this._commandService.executeCommand(Y.SetRangeValuesCommand.id,{unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:W,t:2,p:null,f:null,si:null,s:{n:{pattern:pa(V,B)}}}}),!0):(this._injector.has(De)&&this._injector.get(De).showReject(h.getRuleFinalError(c,{row:a,col:i,unitId:o,subUnitId:s})),!1)};let C;switch(h.dropdownType){case x.DataValidatorDropdownType.DATE:{const S=f.getCellValueOrigin(l.getCellRaw(a,i)),V=at(S),D=!!((O=c.bizInfo)!=null&&O.showTime);C={location:n,type:"datepicker",props:{showTime:D,onChange:y=>u(y,D?"datetime":"date"),defaultValue:V,patternType:"date"}};break}case x.DataValidatorDropdownType.TIME:{const S=f.getCellValueOrigin(l.getCellRaw(a,i)),V=at(S);C={location:n,type:"datepicker",props:{onChange:D=>u(D,"time"),defaultValue:V,patternType:"time"}};break}case x.DataValidatorDropdownType.DATETIME:{const S=f.getCellValueOrigin(l.getCellRaw(a,i)),V=at(S);C={location:n,type:"datepicker",props:{onChange:D=>u(D,"datetime"),defaultValue:V,patternType:"datetime"}};break}case x.DataValidatorDropdownType.LIST:case x.DataValidatorDropdownType.MULTIPLE_LIST:{const S=h.dropdownType===x.DataValidatorDropdownType.MULTIPLE_LIST,V=async A=>{const B=f.serializeListOptions(A),k={unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:B,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(H.SetCellEditVisibleOperation.id,{visible:!1,eventType:U.DeviceInputEventType.Keyboard,unitId:o,keycode:E.KeyCode.ESC}),this._commandService.executeCommand(Y.SetRangeValuesCommand.id,k),!S},D=(c==null?void 0:c.renderMode)===r.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,y=h.getListWithColor(c,o,s),w=f.getDataValidationCellValue(l.getCellRaw(a,i)),L=()=>{this._commandService.executeCommand(Se.id,{ruleId:c.uid}),p==null||p.dispose()},W=y.map(A=>({label:A.label,value:A.label,color:D||A.color?A.color:"transparent"}));C={location:n,type:"list",props:{onChange:A=>V(A),options:W,onEdit:L,defaultValue:w,multiple:S,showEdit:(v=(M=this._configService.getConfig(tt))==null?void 0:M.showEditOnDropdown)!=null?v:!0}};break}case x.DataValidatorDropdownType.CASCADE:{C={type:"cascader",props:{onChange:V=>{const D={unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:V.join("/"),p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(H.SetCellEditVisibleOperation.id,{visible:!1,eventType:U.DeviceInputEventType.Keyboard,unitId:o,keycode:E.KeyCode.ESC}),this._commandService.syncExecuteCommand(Y.SetRangeValuesCommand.id,D),!0},defaultValue:f.getDataValidationCellValue(l.getCellRaw(a,i)).split("/"),options:JSON.parse((_=c.formula1)!=null?_:"[]")},location:n};break}case x.DataValidatorDropdownType.COLOR:{C={type:"color",props:{onChange:V=>{const D={unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:V,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(H.SetCellEditVisibleOperation.id,{visible:!1,eventType:U.DeviceInputEventType.Keyboard,unitId:o,keycode:E.KeyCode.ESC}),this._commandService.syncExecuteCommand(Y.SetRangeValuesCommand.id,D),!0},defaultValue:f.getDataValidationCellValue(l.getCellRaw(a,i))},location:n};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(p=this._cellDropdownManagerService.showDropdown(C),!p)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const m=new r.DisposableCollection;m.add(p),m.add({dispose:()=>{var S,V;(V=(S=this._activeDropdown)==null?void 0:S.onHide)==null||V.call(S)}}),this._currentPopup=m}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,n,a,i,o){const s=this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(n);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),a,i);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!c||!c.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:a,col:i,unitId:t,subUnitId:n},onHide:o})}};fe=ha([re(0,r.IUniverInstanceService),re(1,r.Inject(x.DataValidatorRegistryService)),re(2,E.IZenZoneService),re(3,r.Inject(f.SheetDataValidationModel)),re(4,r.Inject(Y.SheetsSelectionsService)),re(5,r.Inject(H.ISheetCellDropdownManagerService)),re(6,r.Inject(f.SheetDataValidationModel)),re(7,r.ICommandService),re(8,H.IEditorBridgeService),re(9,r.Inject(r.Injector)),re(10,r.IConfigService)],fe);const Ne="DataValidationPanel",Se={id:"data-validation.operation.open-validation-panel",type:r.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:n,isAdd:a}=t,i=e.get(ce),o=e.get(x.DataValidationModel),s=e.get(r.IUniverInstanceService),d=e.get(E.ISidebarService),l=Y.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,p=n?o.getRuleById(c,h,n):void 0;i.open(),i.setActiveRule(p&&{unitId:c,subUnitId:h,rule:p});const u=d.open({id:Ne,header:{title:a?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Ne},width:312,onClose:()=>i.close()});return i.setCloseDisposable(u),!0}},nt={id:"data-validation.operation.close-validation-panel",type:r.CommandType.OPERATION,handler(e){return e.get(ce).close(),!0}},Et={id:"data-validation.operation.toggle-validation-panel",type:r.CommandType.OPERATION,handler(e){const t=e.get(r.ICommandService),n=e.get(ce);return n.open(),n.isOpen?t.executeCommand(nt.id):t.executeCommand(Se.id),!0}},ke={type:r.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const n=e.get(fe),{unitId:a,subUnitId:i,row:o,column:s}=t,d=n.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===a&&l.subUnitId===i&&l.row===o&&l.col===s||n.showDataValidationDropdown(a,i,o,s),!0}},Mt={type:r.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},Be={type:r.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(r.IUniverInstanceService),n=Y.getSheetCommandTarget(t);if(!n)return!1;const{workbook:a,worksheet:i}=n,o=f.createDefaultNewRule(e),s=e.get(r.ICommandService),d=a.getUnitId(),l=i.getSheetId(),c={rule:o,unitId:d,subUnitId:l};return s.syncExecuteCommand(f.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(Se.id,{ruleId:o.uid,isAdd:!0}),!0):!1}};var ma=Object.getOwnPropertyDescriptor,ga=(e,t,n,a)=>{for(var i=a>1?void 0:a?ma(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},we=(e,t)=>(n,a)=>t(n,a,e);const _e="SHEET_DATA_VALIDATION_ALERT";let Pe=class extends r.Disposable{constructor(e,t,n,a,i,o){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=a,this._zenZoneService=i,this._dataValidationModel=o,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ae.debounceTime(100)).subscribe(e=>{var t;if(e){const n=this._univerInstanceService.getUnit(e.location.unitId,r.UniverInstanceType.UNIVER_SHEET),a=n.getSheetBySheetId(e.location.subUnitId);if(!a)return;const i=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!i){this._cellAlertManagerService.removeAlert(_e);return}if(this._dataValidationModel.validator(i,{...e.location,workbook:n,worksheet:a})===r.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(_e),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(_e);return}const l=this._dataValidationModel.getValidator(i.type);if(!l){this._cellAlertManagerService.removeAlert(_e);return}this._cellAlertManagerService.showAlert({type:H.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:_e});return}}this._cellAlertManagerService.removeAlert(_e)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(_e)}))}};Pe=ga([we(0,r.Inject(H.HoverManagerService)),we(1,r.Inject(H.CellAlertManagerService)),we(2,r.IUniverInstanceService),we(3,r.Inject(r.LocaleService)),we(4,E.IZenZoneService),we(5,r.Inject(f.SheetDataValidationModel))],Pe);var va=Object.getOwnPropertyDescriptor,fa=(e,t,n,a)=>{for(var i=a>1?void 0:a?va(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},it=(e,t)=>(n,a)=>t(n,a,e);let Ee=class extends r.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(a,i)=>{const{source:o,target:s,unitId:d,subUnitId:l}=a,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=H.virtualizeDiscreteRanges([o,s]),[p,u]=h.ranges,{mapFunc:C}=h,m={row:p.startRow,col:p.startColumn},O=H.getAutoFillRepeatRange(p,u),M=new r.ObjectMatrix,v=new Set;O.forEach(y=>{const w=y.repeatStartCell,L=y.relativeRange,W={startRow:m.row,startColumn:m.col,endColumn:m.col,endRow:m.row},A={startRow:w.row,startColumn:w.col,endColumn:w.col,endRow:w.row};r.Range.foreach(L,(B,k)=>{const j=r.Rectangle.getPositionRange({startRow:B,startColumn:k,endColumn:k,endRow:B},W),{row:P,col:X}=C(j.startRow,j.startColumn),z=this._sheetDataValidationModel.getRuleIdByLocation(d,l,P,X)||"",Z=r.Rectangle.getPositionRange({startRow:B,startColumn:k,endColumn:k,endRow:B},A),{row:Q,col:J}=C(Z.startRow,Z.startColumn);M.setValue(Q,J,z),v.add(z)})});const _=Array.from(v).map(y=>({id:y,ranges:r.queryObjectMatrix(M,w=>w===y)}));c.addRangeRules(_);const S=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:V,undoMutations:D}=f.getDataValidationDiffMutations(d,l,S,this._injector,"patched",i===H.APPLY_TYPE.ONLY_FORMAT);return{undos:D,redos:V}},n={id:f.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:a=>{const{source:i,unitId:o,subUnitId:s}=a;for(const d of i.rows)for(const l of i.cols){const c=this._sheetDataValidationModel.getRuleByLocation(o,s,d,l);if(c&&c.type===r.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(H.APPLY_TYPE.SERIES,!0);return}}},onFillData:(a,i,o)=>o===H.APPLY_TYPE.COPY||o===H.APPLY_TYPE.ONLY_FORMAT||o===H.APPLY_TYPE.SERIES?t(a,o):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};Ee=fa([it(0,H.IAutoFillService),it(1,r.Inject(f.SheetDataValidationModel)),it(2,r.Inject(r.Injector))],Ee);var Sa=Object.getOwnPropertyDescriptor,_a=(e,t,n,a)=>{for(var i=a>1?void 0:a?Sa(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},ot=(e,t)=>(n,a)=>t(n,a,e);let Me=class extends r.Disposable{constructor(t,n,a){super();R(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=n,this._injector=a,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:f.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,n,a)=>this._collect(t,n,a),onPasteCells:(t,n,a,i)=>{const{copyType:o=H.COPY_TYPE.COPY,pasteType:s}=i,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=n;return this._generateMutations(l,{copyType:o,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,n,a){const i=new r.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:i};const o=this._injector.invoke(l=>Y.rangeToDiscreteRange(a,l,t,n));if(!o)return;const{rows:s,cols:d}=o;s.forEach((l,c)=>{d.forEach((h,p)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,n,l,h);i.setValue(c,p,u!=null?u:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(n.copyType===H.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([H.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,H.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,H.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,H.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:i,subUnitId:o}=this._copyInfo;if(n.unitId!==i||o!==n.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(n.unitId,n.subUnitId).clone(),d=new r.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:p}=H.virtualizeDiscreteRanges([n.copyRange,t]),u=H.getRepeatRange(c,h,!0),C=new Map;u.forEach(({startRange:v})=>{var _;(_=this._copyInfo)==null||_.matrix.forValue((S,V,D)=>{const y=r.Rectangle.getPositionRange({startRow:S,endRow:S,startColumn:V,endColumn:V},v),w=`${o}-${D}`,L=this._sheetDataValidationModel.getRuleById(i,o,D);!this._sheetDataValidationModel.getRuleById(n.unitId,n.subUnitId,w)&&L&&C.set(w,{...L,uid:w});const{row:W,col:A}=p(y.startRow,y.startColumn);l.add(w),d.setValue(W,A,w)})});const m=Array.from(l).map(v=>({id:v,ranges:r.queryObjectMatrix(d,_=>_===v)}));s.addRangeRules(m);const{redoMutations:O,undoMutations:M}=f.getDataValidationDiffMutations(n.unitId,n.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(n.unitId,n.subUnitId),C.values()),this._injector,"patched",!1);return{redos:O,undos:M}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(i,o).clone(),d=new r.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:p}=H.virtualizeDiscreteRanges([n.copyRange,t]);H.getRepeatRange(c,h,!0).forEach(({startRange:M})=>{var v;(v=this._copyInfo)==null||v.matrix.forValue((_,S,V)=>{const D=r.Rectangle.getPositionRange({startRow:_,endRow:_,startColumn:S,endColumn:S},M),{row:y,col:w}=p(D.startRow,D.startColumn);d.setValue(y,w,V),l.add(V)})});const C=Array.from(l).map(M=>({id:M,ranges:r.queryObjectMatrix(d,v=>v===M)}));s.addRangeRules(C);const{redoMutations:m,undoMutations:O}=f.getDataValidationDiffMutations(i,o,s.diff(this._sheetDataValidationModel.getRules(i,o)),this._injector,"patched",!1);return{redos:m,undos:O}}}};Me=_a([ot(0,H.ISheetClipboardService),ot(1,r.Inject(f.SheetDataValidationModel)),ot(2,r.Inject(r.Injector))],Me);var Ia=Object.getOwnPropertyDescriptor,Ca=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ia(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},rt=(e,t)=>(n,a)=>t(n,a,e);let Te=class extends r.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===f.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[Y.WorkbookEditablePermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint],worksheetTypes:[Y.WorksheetEditPermission,Y.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===f.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[Y.WorkbookEditablePermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint],worksheetTypes:[Y.WorksheetEditPermission,Y.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Te=Ca([rt(0,r.Inject(r.LocaleService)),rt(1,r.ICommandService),rt(2,r.Inject(Y.SheetPermissionCheckController))],Te);const Tt="data-validation-single",bt="sheet.menu.data-validation";function ya(e){return{id:bt,type:E.MenuItemType.SUBITEMS,icon:Tt,tooltip:"dataValidation.title",hidden$:E.getMenuHiddenObservable(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:H.getCurrentRangeDisable$(e,{workbookTypes:[Y.WorkbookEditablePermission],worksheetTypes:[Y.WorksheetSetCellStylePermission,Y.WorksheetEditPermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint]})}}function Va(e){return{id:Se.id,title:"dataValidation.panel.title",type:E.MenuItemType.BUTTON}}function Da(e){return{id:Be.id,title:"dataValidation.panel.add",type:E.MenuItemType.BUTTON}}const wa={[E.RibbonStartGroup.FORMULAS_INSERT]:{[bt]:{order:9,menuItemFactory:ya,[Se.id]:{order:0,menuItemFactory:Va},[Be.id]:{order:1,menuItemFactory:Da}}}};var Ea=Object.getOwnPropertyDescriptor,Ot=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ea(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},q=(e,t)=>(n,a)=>t(n,a,e);const Rt={tr:{size:6,color:"#fe4b4b"}};let be=class extends r.RxDisposable{constructor(e,t,n,a,i,o,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=a,this._autoHeightController=i,this._dropdownManagerService=o,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=c,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(wa)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var n;if(!e.visible){((n=this._dropdownManagerService.activeDropdown)==null?void 0:n.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:a,sheetId:i,row:o,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(a);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(a,i,o,s);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(c!=null&&c.dropdownType))return;const h=d.getActiveSheet();if(!h)return;const p=this._dropdownManagerService.activeDropdown,u=p==null?void 0:p.location;if(u&&u.unitId===a&&u.subUnitId===i&&u.row===o&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:a,subUnitId:i,row:o,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:Y.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var v,_,S,V,D;const{row:a,col:i,unitId:o,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(o,s,a,i);if(!c)return n(e);const h=this._sheetDataValidationModel.getRuleById(o,s,c);if(!h)return n(e);const p=(v=this._dataValidationCacheService.getValue(o,s,a,i))!=null?v:r.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),C=t.rawData;let m;const O={get value(){var y;return m!==void 0||(m=(y=f.getCellValueOrigin(C))!=null?y:null),m}},M={get value(){var y;return`${(y=O.value)!=null?y:""}`}};return n({...e,markers:{...e==null?void 0:e.markers,...p===r.DataValidationStatus.INVALID?Rt:null},customRender:[...(_=e==null?void 0:e.customRender)!=null?_:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((S=e==null?void 0:e.fontRenderExtension)==null?void 0:S.isSkip)||((V=u==null?void 0:u.skipDefaultFontRender)==null?void 0:V.call(u,h,O.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,M.value,{get style(){const y=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?y.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,i)},interceptorAutoHeight:()=>{var W,A,B,k,j,P;const y=(A=(W=this._renderManagerService.getRenderById(o))==null?void 0:W.with(H.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:A.skeleton;if(!y)return;const w=y.worksheet.getMergedCell(a,i),L={data:e,style:y.getStyles().getStyleByCell(e),primaryWithCoord:y.getCellWithCoordByIndex((B=w==null?void 0:w.startRow)!=null?B:a,(k=w==null?void 0:w.startColumn)!=null?k:i),unitId:o,subUnitId:s,row:a,col:i,workbook:d,worksheet:l};return(P=(j=u==null?void 0:u.canvasRender)==null?void 0:j.calcCellAutoHeight)==null?void 0:P.call(j,L)},interceptorAutoWidth:()=>{var W,A,B,k,j,P;const y=(A=(W=this._renderManagerService.getRenderById(o))==null?void 0:W.with(H.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:A.skeleton;if(!y)return;const w=y.worksheet.getMergedCell(a,i),L={data:e,style:y.getStyles().getStyleByCell(e),primaryWithCoord:y.getCellWithCoordByIndex((B=w==null?void 0:w.startRow)!=null?B:a,(k=w==null?void 0:w.startColumn)!=null?k:i),unitId:o,subUnitId:s,row:a,col:i,workbook:d,worksheet:l};return(P=(j=u==null?void 0:u.canvasRender)==null?void 0:j.calcCellAutoWidth)==null?void 0:P.call(j,L)},coverable:((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(h.type===r.DataValidationType.LIST||h.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ae.filter(e=>e.source==="command"),ae.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(n=>{var a;(n.rule.type===r.DataValidationType.LIST_MULTIPLE||n.rule.type===r.DataValidationType.LIST)&&(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(n.redos,this._commandService)}})}};be=Ot([q(0,r.ICommandService),q(1,E.IMenuManagerService),q(2,U.IRenderManagerService),q(3,r.IUniverInstanceService),q(4,r.Inject(H.AutoHeightController)),q(5,r.Inject(fe)),q(6,r.Inject(f.SheetDataValidationModel)),q(7,r.Inject(x.DataValidatorRegistryService)),q(8,r.Inject(Y.SheetInterceptorService)),q(9,r.Inject(f.DataValidationCacheService)),q(10,r.Optional(H.IEditorBridgeService))],be);let Lt=class extends r.RxDisposable{constructor(e,t,n,a,i,o,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=a,this._sheetInterceptorService=i,this._sheetDataValidationModel=o,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:Y.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var M,v,_,S,V;const{row:a,col:i,unitId:o,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(o,s,a,i);if(!c)return n(e);const h=this._sheetDataValidationModel.getRuleById(o,s,c);if(!h)return n(e);const p=(M=this._dataValidationCacheService.getValue(o,s,a,i))!=null?M:r.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),C=l.getCellRaw(a,i),m=f.getCellValueOrigin(C),O=`${m!=null?m:""}`;return n({...e,markers:{...e==null?void 0:e.markers,...p===r.DataValidationStatus.INVALID?Rt:null},customRender:[...(v=e==null?void 0:e.customRender)!=null?v:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((_=e==null?void 0:e.fontRenderExtension)==null?void 0:_.isSkip)||((S=u==null?void 0:u.skipDefaultFontRender)==null?void 0:S.call(u,h,m,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,O,{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)||{}}},a,i)},interceptorAutoHeight:()=>{var L,W,A,B,k,j;const D=(W=(L=this._renderManagerService.getRenderById(o))==null?void 0:L.with(H.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!D)return;const y=D.worksheet.getMergedCell(a,i),w={data:e,style:D.getStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex((A=y==null?void 0:y.startRow)!=null?A:a,(B=y==null?void 0:y.startColumn)!=null?B:i),unitId:o,subUnitId:s,row:a,col:i,workbook:d,worksheet:l};return(j=(k=u==null?void 0:u.canvasRender)==null?void 0:k.calcCellAutoHeight)==null?void 0:j.call(k,w)},coverable:((V=e==null?void 0:e.coverable)!=null?V:!0)&&!(h.type===r.DataValidationType.LIST||h.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ae.filter(e=>e.source==="command"),ae.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(n=>{var a;(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(n.redos,this._commandService)}})}};Lt=Ot([q(0,r.ICommandService),q(1,U.IRenderManagerService),q(2,r.Inject(H.AutoHeightController)),q(3,r.Inject(x.DataValidatorRegistryService)),q(4,r.Inject(Y.SheetInterceptorService)),q(5,r.Inject(f.SheetDataValidationModel)),q(6,r.Inject(f.DataValidationCacheService))],Lt);var Ma=Object.getOwnPropertyDescriptor,Ta=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ma(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},At=(e,t)=>(n,a)=>t(n,a,e);let je=class extends r.Disposable{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var a;if(!t.length)return;const n=new Set;t.forEach(i=>{n.add(i.subUnitId)}),n.forEach(i=>{var o;(o=this._sheetSkeletonManagerService.getSkeletonParam(i))==null||o.skeleton.makeDirty(!0)}),(a=this._context.mainComponent)==null||a.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(r.bufferDebounceTime(16)).subscribe(e))}};je=Ta([At(1,r.Inject(f.SheetDataValidationModel)),At(2,r.Inject(H.SheetSkeletonManagerService))],je);const st={dataValidationOptionsButton:"univer-data-validation-options-button",dataValidationOptionsButtonIcon:"univer-data-validation-options-button-icon"};function ba(e){var c;const t=E.useDependency(r.LocaleService),n=E.useDependency(E.ComponentManager),{value:a,onChange:i,extraComponent:o}=e,[s,d]=T.useState(!1),l=o?n.get(o):null;return g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:st.dataValidationOptionsButton,onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?g.jsx(yt,{className:st.dataValidationOptionsButtonIcon}):g.jsx(Ct,{className:st.dataValidationOptionsButtonIcon})]}),s&&g.jsxs(g.Fragment,{children:[l?g.jsx(l,{value:a,onChange:i}):null,g.jsx(b.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:g.jsxs(b.RadioGroup,{value:`${(c=a.errorStyle)!=null?c:r.DataValidationErrorStyle.WARNING}`,onChange:h=>i({...a,errorStyle:+h}),children:[g.jsx(b.Radio,{value:`${r.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),g.jsx(b.Radio,{value:`${r.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),g.jsx(b.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:g.jsx(b.Checkbox,{checked:a.showErrorMessage,onChange:()=>i({...a,showErrorMessage:!a.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),a.showErrorMessage?g.jsx(b.FormLayout,{children:g.jsx(b.Input,{value:a.error,onChange:h=>i({...a,error:h})})}):null]})]})}const Oe={dataValidationDetail:"univer-data-validation-detail",dataValidationDetailFormItem:"univer-data-validation-detail-form-item",dataValidationDetailButtons:"univer-data-validation-detail-buttons",dataValidationDetailButton:"univer-data-validation-detail-button"},Oa=e=>r.debounce(async(t,n,a,i)=>{const o=await e.executeCommand(t,n,a);i==null||i(o)},1e3);function Ra(e,t,n){var a,i,o,s;return t?((i=(a=e.getUnit(t))==null?void 0:a.getSheetBySheetName(n))==null?void 0:i.getSheetId())||"":((s=(o=e.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:o.getSheetBySheetName(n))==null?void 0:s.getSheetId())||""}function La(){var N,G;const[e,t]=T.useState(0),n=E.useDependency(ce),a=E.useObservable(n.activeRule$,n.activeRule),{unitId:i,subUnitId:o,rule:s}=a||{},d=s.uid,l=E.useDependency(x.DataValidatorRegistryService),c=E.useDependency(r.IUniverInstanceService),h=E.useDependency(E.ComponentManager),p=E.useDependency(r.ICommandService),u=E.useDependency(x.DataValidationModel),C=E.useDependency(r.LocaleService),[m,O]=T.useState(s),M=l.getValidatorItem(m.type),[v,_]=T.useState(!1),S=l.getValidatorsByScope(x.DataValidatorRegistryScope.SHEET),[V,D]=T.useState(()=>m.ranges.map(I=>({unitId:"",sheetId:"",range:I}))),y=T.useMemo(()=>Oa(p),[p]),[w,L]=T.useState(!1),[W,A]=T.useState(!1),B=T.useRef(null),k=E.useDependency(Y.SheetsSelectionsService);if(T.useEffect(()=>()=>{const I=k.getCurrentLastSelection();I&&k.setSelections([I])},[k]),T.useEffect(()=>{p.onCommandExecuted(I=>{(I.id===r.UndoCommand.id||I.id===r.RedoCommand.id)&&setTimeout(()=>{const $=u.getRuleById(i,o,d);t(K=>K+1),$&&(O($),D($.ranges.map(K=>({unitId:"",sheetId:"",range:K}))))},20)})},[p,u,d,o,i]),!M)return null;const j=M.operators,P=M.operatorNames,X=m.operator?x.TWO_FORMULA_OPERATOR_COUNT.includes(m.operator):!1,z=()=>{var I,$,K;($=(I=B.current)==null?void 0:I.editor)!=null&&$.isFocus()&&Z((K=B.current)==null?void 0:K.getValue()),!(!m.ranges.length||w)&&(M.validatorFormula(m,i,o).success?n.setActiveRule(null):_(!0))},Z=E.useEvent(I=>{const $=I.split(",").filter(Boolean).map(Qe.deserializeRangeWithSheet).map(te=>{const Bt=te.sheetName;if(Bt){const gn=Ra(c,te.unitId,Bt);return{...te,sheetId:gn}}return{...te,sheetId:""}});if(r.isUnitRangesEqual($,V))return;D($);const K=$.filter(te=>(!te.unitId||te.unitId===i)&&(!te.sheetId||te.sheetId===o)).map(te=>te.range);if(O({...m,ranges:K}),K.length===0)return;const ge={unitId:i,subUnitId:o,ruleId:d,ranges:K};y(f.UpdateSheetDataValidationRangeCommand.id,ge)}),Q=I=>{if(r.shallowEqual(I,x.getRuleSetting(m)))return;O({...m,...I});const $={unitId:i,subUnitId:o,ruleId:d,setting:I};y(f.UpdateSheetDataValidationSettingCommand.id,$,void 0)},J=async()=>{await p.executeCommand(f.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:i,subUnitId:o}),n.setActiveRule(null)},ie={type:m.type,operator:m.operator,formula1:m.formula1,formula2:m.formula2,allowBlank:m.allowBlank},he=I=>{const $=l.getValidatorItem(I);if(!$)return;const K=$.operators,ge=u.getRuleById(i,o,d),te=I===(ge==null?void 0:ge.type)||I.includes("list")&&(ge!=null&&ge.type.includes("list"))?{...ge,type:I}:{...m,type:I,operator:K[0],formula1:void 0,formula2:void 0};O(te),p.executeCommand(f.UpdateSheetDataValidationSettingCommand.id,{unitId:i,subUnitId:o,ruleId:m.uid,setting:x.getRuleSetting(te)})},le=h.get(M.formulaInput),oe=T.useMemo(()=>V.map(I=>Qe.serializeRange(I.range)).join(","),[]),de=x.getRuleOptions(m),me=I=>{r.shallowEqual(I,x.getRuleOptions(m))||(O({...m,...I}),y(f.UpdateSheetDataValidationOptionsCommand.id,{unitId:i,subUnitId:o,ruleId:d,options:I}))},pe=j.length&&!m.operator;return g.jsxs("div",{className:Oe.dataValidationDetail,children:[g.jsx(b.FormLayout,{label:C.t("dataValidation.panel.range"),error:!m.ranges.length||w?C.t("dataValidation.panel.rangeError"):"",children:g.jsx(Je.RangeSelector,{selectorRef:B,unitId:i,subUnitId:o,initialValue:oe,onChange:(I,$)=>{var K;!W&&((K=B.current)!=null&&K.verify())&&Z($)},onFocusChange:(I,$)=>{var K;A(I),!I&&$&&((K=B.current)!=null&&K.verify())&&Z($)},onVerify:I=>L(!I)})}),g.jsx(b.FormLayout,{label:C.t("dataValidation.panel.type"),children:g.jsx(b.Select,{options:(N=S==null?void 0:S.sort((I,$)=>I.order-$.order))==null?void 0:N.map(I=>({label:C.t(I.title),value:I.id})),value:m.type,onChange:he,className:Oe.dataValidationDetailFormItem})}),j!=null&&j.length?g.jsx(b.FormLayout,{label:C.t("dataValidation.panel.operator"),children:g.jsx(b.Select,{options:[{value:"",label:C.t("dataValidation.operators.legal")},...j.map((I,$)=>({value:`${I}`,label:P[$]}))],value:`${m.operator}`,onChange:I=>{Q({...ie,operator:I})},className:Oe.dataValidationDetailFormItem})}):null,le&&!pe?g.jsx(b.FormLayout,{children:g.jsx(le,{isTwoFormula:X,value:{formula1:m.formula1,formula2:m.formula2},onChange:I=>{Q({...ie,...I})},showError:v,validResult:M.validatorFormula(m,i,o),unitId:i,subUnitId:o,ruleId:d},e+m.type)}):null,g.jsx(b.FormLayout,{children:g.jsx(b.Checkbox,{checked:(G=m.allowBlank)!=null?G:!0,onChange:()=>{var I;return Q({...ie,allowBlank:!((I=m.allowBlank)==null||I)})},children:C.t("dataValidation.panel.allowBlank")})}),g.jsx(ba,{value:de,onChange:me,extraComponent:M.optionsInput}),g.jsxs("div",{className:Oe.dataValidationDetailButtons,children:[g.jsx(b.Button,{className:Oe.dataValidationDetailButton,onClick:J,children:C.t("dataValidation.panel.removeRule")}),g.jsx(b.Button,{className:Oe.dataValidationDetailButton,variant:"primary",onClick:z,children:C.t("dataValidation.panel.done")})]})]})}const He={dataValidationItemContainer:"univer-data-validation-item-container",dataValidationItemTitle:"univer-data-validation-item-title",dataValidationItemContent:"univer-data-validation-item-content",dataValidationItemIcon:"univer-data-validation-item-icon"},Aa=e=>{const{rule:t,onClick:n,unitId:a,subUnitId:i,disable:o}=e,s=E.useDependency(x.DataValidatorRegistryService),d=E.useDependency(r.ICommandService),l=E.useDependency(H.IMarkSelectionService),c=s.getValidatorItem(t.type),h=T.useRef(void 0),[p,u]=T.useState(!1),C=E.useDependency(r.ThemeService),m=E.useObservable(C.currentTheme$),O=T.useMemo(()=>{var S;const v=(S=m==null?void 0:m.loopColor2)!=null?S:"#49B811",_=new r.ColorKit(v).toRgb();return{fill:`rgba(${_.r}, ${_.g}, ${_.b}, 0.1)`,stroke:v}},[m]),M=v=>{d.executeCommand(f.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:a,subUnitId:i}),v.stopPropagation()};return T.useEffect(()=>()=>{var v;h.current&&((v=h.current)==null||v.forEach(_=>{_&&l.removeShape(_)}))},[l]),g.jsxs("div",{className:He.dataValidationItemContainer,onClick:n,onMouseEnter:()=>{o||(u(!0),h.current=t.ranges.map(v=>l.addShape({range:v,style:O,primary:null})))},onMouseLeave:()=>{var v;u(!1),(v=h.current)==null||v.forEach(_=>{_&&l.removeShape(_)}),h.current=void 0},children:[g.jsx("div",{className:He.dataValidationItemTitle,children:c==null?void 0:c.generateRuleName(t)}),g.jsx("div",{className:He.dataValidationItemContent,children:t.ranges.map(v=>Qe.serializeRange(v)).join(",")}),p?g.jsx("div",{className:He.dataValidationItemIcon,onClick:M,children:g.jsx(et,{})}):null]})},We={dataValidationList:"univer-data-validation-list",dataValidationListButtons:"univer-data-validation-list-buttons",dataValidationListButton:"univer-data-validation-list-button"};function Pa(e){const t=E.useDependency(f.SheetDataValidationModel),n=E.useDependency(r.IUniverInstanceService),a=E.useDependency(r.ICommandService),i=E.useDependency(r.Injector),o=E.useDependency(ce),s=E.useDependency(r.LocaleService),[d,l]=T.useState([]),{workbook:c}=e,h=E.useObservable(c.activeSheet$,void 0,!0),p=c.getUnitId(),u=h==null?void 0:h.getSheetId();T.useEffect(()=>{l(t.getRules(p,u));const _=t.ruleChange$.subscribe(S=>{S.unitId===p&&S.subUnitId===u&&l(t.getRules(p,u))});return()=>{_.unsubscribe()}},[p,u,t]);const C=async()=>{const _=f.createDefaultNewRule(i),S={unitId:p,subUnitId:u,rule:_};await a.executeCommand(f.AddSheetDataValidationCommand.id,S),o.setActiveRule({unitId:p,subUnitId:u,rule:_})},m=()=>{a.executeCommand(f.RemoveSheetAllDataValidationCommand.id,{unitId:p,subUnitId:u})},M=(_=>{const S=n.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET),V=S.getActiveSheet(),D=S.getUnitId(),y=V.getSheetId();return _.map(L=>Y.checkRangesEditablePermission(i,D,y,L.ranges)?{...L}:{...L,disable:!0})})(d),v=M==null?void 0:M.some(_=>_.disable);return g.jsxs("div",{className:We.dataValidationList,children:[M==null?void 0:M.map(_=>{var S;return g.jsx(Aa,{unitId:p,subUnitId:u,onClick:()=>{_.disable||o.setActiveRule({unitId:p,subUnitId:u,rule:_})},rule:_,disable:(S=_.disable)!=null?S:!1},_.uid)}),g.jsxs("div",{className:We.dataValidationListButtons,children:[d.length&&!v?g.jsx(b.Button,{className:We.dataValidationListButton,onClick:m,children:s.t("dataValidation.panel.removeAll")}):null,g.jsx(b.Button,{className:We.dataValidationListButton,variant:"primary",onClick:C,children:s.t("dataValidation.panel.add")})]})]})}const Fa=()=>{const e=E.useDependency(ce),t=E.useObservable(e.activeRule$,e.activeRule),n=E.useDependency(r.IUniverInstanceService),a=E.useObservable(()=>n.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),i=E.useObservable(()=>{var o;return(o=a==null?void 0:a.activeSheet$)!=null?o:ae.of(null)},void 0,void 0,[]);return!a||!i?null:t&&t.subUnitId===i.getSheetId()?g.jsx(La,{},t.rule.uid):g.jsx(Pa,{workbook:a})},Ua="LIST_RENDER_MODE_OPTION_INPUT";function $e(e){var i;const{value:t,onChange:n}=e,a=E.useDependency(r.LocaleService);return g.jsx(b.FormLayout,{label:a.t("dataValidation.renderMode.label"),children:g.jsxs(b.RadioGroup,{value:`${(i=t.renderMode)!=null?i:r.DataValidationRenderMode.CUSTOM}`,onChange:o=>n({...t,renderMode:+o}),children:[g.jsx(b.Radio,{value:`${r.DataValidationRenderMode.CUSTOM}`,children:a.t("dataValidation.renderMode.chip")}),g.jsx(b.Radio,{value:`${r.DataValidationRenderMode.ARROW}`,children:a.t("dataValidation.renderMode.arrow")}),g.jsx(b.Radio,{value:`${r.DataValidationRenderMode.TEXT}`,children:a.t("dataValidation.renderMode.text")})]})})}$e.componentKey=Ua;const Na="DATE_SHOW_TIME_OPTION";function Ye(e){var i;const{value:t,onChange:n}=e,a=E.useDependency(r.LocaleService);return g.jsx(b.FormLayout,{children:g.jsx(b.Checkbox,{checked:(i=t.bizInfo)==null?void 0:i.showTime,onChange:o=>{n({...t,bizInfo:{...t.bizInfo,showTime:o}})},children:a.t("dataValidation.showTime.label")})})}Ye.componentKey=Na;var ka=Object.getOwnPropertyDescriptor,Ba=(e,t,n,a)=>{for(var i=a>1?void 0:a?ka(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Re=(e,t)=>(n,a)=>t(n,a,e);const xe=6;let lt=class{constructor(e,t,n,a,i,o){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=a,this._renderManagerService=i,this._dataValidationModel=o}_calc(e,t){var c,h,p;const{vt:n,ht:a}=t||{},i=e.endX-e.startX-xe*2,o=e.endY-e.startY,s=((c=t==null?void 0:t.fs)!=null?c:10)*1.6;let d=0,l=0;switch(n){case r.VerticalAlign.TOP:l=0;break;case r.VerticalAlign.BOTTOM:l=0+(o-s);break;default:l=0+(o-s)/2;break}switch(a){case r.HorizontalAlign.LEFT:d=xe;break;case r.HorizontalAlign.RIGHT:d=xe+(i-s);break;default:d=xe+(i-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((p=t==null?void 0:t.fs)!=null?p:10)*1.6}}calcCellAutoHeight(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}calcCellAutoWidth(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}async _parseFormula(e,t,n){var c,h,p,u,C,m,O,M,v;const{formula1:a=f.CHECKBOX_FORMULA_1,formula2:i=f.CHECKBOX_FORMULA_2}=e,o=await this._formulaService.getRuleFormulaResult(t,n,e.uid),s=f.getFormulaResult((p=(h=(c=o==null?void 0:o[0])==null?void 0:c.result)==null?void 0:h[0])==null?void 0:p[0]),d=f.getFormulaResult((m=(C=(u=o==null?void 0:o[1])==null?void 0:u.result)==null?void 0:C[0])==null?void 0:m[0]),l=f.isLegalFormulaResult(String(s))&&f.isLegalFormulaResult(String(d));return{formula1:r.isFormulaString(a)?f.getFormulaResult((v=(M=(O=o==null?void 0:o[0])==null?void 0:O.result)==null?void 0:M[0])==null?void 0:v[0]):a,formula2:r.isFormulaString(i)?d:i,isFormulaValid:l}}drawWith(e,t){var k,j,P,X;const{style:n,primaryWithCoord:a,unitId:i,subUnitId:o,worksheet:s,row:d,col:l}=t,c=a.isMergedMainCell?a.mergeInfo:a,h=f.getCellValueOrigin(s.getCellRaw(d,l)),p=this._dataValidationModel.getRuleByLocation(i,o,d,l);if(!p)return;const u=this._dataValidationModel.getValidator(p.type);if(!u)return;const C=this._themeService.getCurrentTheme();if(!((k=u.skipDefaultFontRender)!=null&&k.call(u,p,h,{unitId:i,subUnitId:o,row:d,column:l})))return;const m=u.parseFormulaSync(p,i,o),{formula1:O}=m,M=this._calc(c,n),{a:v,d:_}=e.getTransform(),S=U.fixLineWidthByScale(M.left,v),V=U.fixLineWidthByScale(M.top,_),D=U.Transform.create().composeMatrix({left:S,top:V,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),y=c.endX-c.startX,w=c.endY-c.startY;e.save(),e.beginPath(),e.rect(c.startX,c.startY,y,w),e.clip();const L=D.getMatrix();e.transform(L[0],L[1],L[2],L[3],L[4],L[5]);const W=((j=n==null?void 0:n.fs)!=null?j:10)*1.6,A=String(h)===String(O),B=C.hyacinth500;U.CheckboxShape.drawWith(e,{checked:A,width:W,height:W,fill:(X=(P=n==null?void 0:n.cl)==null?void 0:P.rgb)!=null?X:B}),e.restore()}isHit(e,t){const n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,a=this._calc(n,t.style),i=a.top,o=a.top+a.height,s=a.left,d=a.left+a.width,{x:l,y:c}=e;return l<=d&&l>=s&&c<=o&&c>=i}async onPointerDown(e,t){var m;if(t.button===2)return;const{primaryWithCoord:n,unitId:a,subUnitId:i,worksheet:o,row:s,col:d}=e,l=f.getCellValueOrigin(o.getCellRaw(s,d)),c=this._dataValidationModel.getRuleByLocation(a,i,s,d);if(!c)return;const h=this._dataValidationModel.getValidator(c.type);if(!h||!((m=h.skipDefaultFontRender)!=null&&m.call(h,c,l,{unitId:a,subUnitId:i,row:s,column:d})))return;const{formula1:p,formula2:u}=await this._parseFormula(c,a,i),C={range:{startColumn:n.actualColumn,endColumn:n.actualColumn,startRow:n.actualRow,endRow:n.actualRow},value:{v:String(l)===f.transformCheckboxValue(String(p))?u:p,p:null}};this._commandService.executeCommand(Y.SetRangeValuesCommand.id,C)}onPointerEnter(e,t){var n,a;(a=(n=U.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(U.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=U.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(U.CURSOR_TYPE.DEFAULT)}};lt=Ba([Re(0,r.ICommandService),Re(1,r.IUniverInstanceService),Re(2,r.Inject(f.DataValidationFormulaService)),Re(3,r.Inject(r.ThemeService)),Re(4,r.Inject(U.IRenderManagerService)),Re(5,r.Inject(f.SheetDataValidationModel))],lt);class ja extends F.BaseSheetDataValidatorView{constructor(){super(...arguments);R(this,"id",r.DataValidationType.CHECKBOX);R(this,"canvasRender",this.injector.createInstance(lt));R(this,"formulaInput",f.CHECKBOX_FORMULA_INPUT_NAME)}}class Ha extends F.BaseSheetDataValidatorView{constructor(){super(...arguments);R(this,"id",r.DataValidationType.CUSTOM);R(this,"formulaInput",f.CUSTOM_FORMULA_INPUT_NAME)}}const Wa="data-validation.formula-input";class $a extends F.BaseSheetDataValidatorView{constructor(){super(...arguments);R(this,"id",r.DataValidationType.DATE);R(this,"formulaInput",Wa);R(this,"optionsInput",Ye.componentKey);R(this,"dropdownType",x.DataValidatorDropdownType.DATE)}}class Ya extends F.BaseSheetDataValidatorView{constructor(){super(...arguments);R(this,"id",r.DataValidationType.DECIMAL);R(this,"formulaInput",f.BASE_FORMULA_INPUT_NAME)}}const Pt=4,xa=0,dt=4,Ft=4,ct=6,Xe=6,Ie=14;function Xa(e,t){const n=U.FontCache.getTextSize(e,t),a=n.width+Pt*2,{ba:i,bd:o}=n,s=i+o;return{width:a,height:s+xa*2,ba:i}}function ut(e,t,n,a){const i=Ie+ct*2,o=n-i,s=a-Xe*2,d=e.map(u=>({layout:Xa(u,t),text:u}));let l;const c=[];d.forEach(u=>{const{layout:C}=u,{width:m,height:O}=C;!l||l.width+m+dt>o?(l={width:m,height:O,items:[{...u,left:0}]},c.push(l)):(l.items.push({...u,left:l.width+dt}),l.width=l.width+m+dt)});let h=0,p=0;return c.forEach((u,C)=>{p=Math.max(p,u.width),C===c.length-1?h+=u.height:h+=u.height+Ft}),{lines:c,totalHeight:h,contentWidth:o,contentHeight:s,cellAutoHeight:h+Xe*2,calcAutoWidth:p+i}}const za=8;class Ka extends U.Shape{static drawWith(t,n){const{fontString:a,info:i,fill:o,color:s}=n,{layout:d,text:l}=i;t.save(),U.Rect.drawWith(t,{width:d.width,height:d.height,radius:za,fill:o||ye}),t.translateWithPrecision(Pt,d.ba),t.font=a,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var Ga=Object.getOwnPropertyDescriptor,qa=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ga(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},ze=(e,t)=>(n,a)=>t(n,a,e);const Za=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let ht=class{constructor(e,t,n,a){R(this,"zIndex");R(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,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,n,a,i){const o=n-Ie+4;let s=4;switch(i){case r.VerticalAlign.MIDDLE:s=(a-Ie)/2+4;break;case r.VerticalAlign.BOTTOM:s=a-Ie+4;break}e.save(),e.translateWithPrecision(t.startX+o,t.startY+s),e.fillStyle="#565656",e.fill(Za),e.restore()}drawWith(e,t,n,a){var Q,J;const{primaryWithCoord:i,row:o,col:s,style:d,data:l,subUnitId:c}=t,h=i.isMergedMainCell?i.mergeInfo:i,p=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:C=0,topOffset:m=0,downOffset:O=0}=p||{},M=this._ensureMap(c),v=this._generateKey(o,s),_=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,o,s);if(!_)return;const S=this._dataValidationModel.getValidator(_.type);if(!S)return;const V={startX:h.startX+u,endX:h.endX-C,startY:h.startY+m,endY:h.endY-O},D=V.endX-V.startX,y=V.endY-V.startY,{cl:w}=d||{},L=(Q=typeof w=="object"?w==null?void 0:w.rgb:w)!=null?Q:"#000",W=U.getFontStyleString(d!=null?d:void 0),{vt:A,ht:B}=d||{},k=A!=null?A:r.VerticalAlign.MIDDLE,j=(J=f.getCellValueOrigin(l))!=null?J:"",P=S.parseCellValue(j),X=S.getListWithColorMap(_),z=ut(P,W,D,y);this._drawDownIcon(e,V,D,y,k),e.save(),e.translateWithPrecision(V.startX,V.startY),e.beginPath(),e.rect(0,0,D-Ie,y),e.clip(),e.translateWithPrecision(ct,Xe);let Z=0;switch(k){case r.VerticalAlign.MIDDLE:Z=(z.contentHeight-z.totalHeight)/2;break;case r.VerticalAlign.BOTTOM:Z=z.contentHeight-z.totalHeight;break}e.translateWithPrecision(0,Z),z.lines.forEach((ie,he)=>{e.save();const{width:le,height:oe,items:de}=ie;let me=0;switch(B){case r.HorizontalAlign.RIGHT:me=z.contentWidth-le;break;case r.HorizontalAlign.CENTER:me=(z.contentWidth-le)/2;break}e.translate(me,he*(oe+Ft)),de.forEach(pe=>{e.save(),e.translateWithPrecision(pe.left,0),Ka.drawWith(e,{...W,info:pe,color:L,fill:X[pe.text]}),e.restore()}),e.restore()}),e.restore(),M.set(v,{left:V.startX,top:V.startY,width:z.contentWidth+ct+Ie,height:z.contentHeight+Xe*2})}calcCellAutoHeight(e){var D;const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},p=t.isMergedMainCell?t.mergeInfo:t,u={startX:p.startX+d,endX:p.endX-l,startY:p.startY+c,endY:p.endY-h},C=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!C)return;const m=this._dataValidationModel.getValidator(C.type);if(!m)return;const O=u.endX-u.startX,M=u.endY-u.startY,v=(D=f.getCellValueOrigin(a))!=null?D:"",_=m.parseCellValue(v),S=U.getFontStyleString(n!=null?n:void 0);return ut(_,S,O,M).cellAutoHeight}calcCellAutoWidth(e){var D;const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},p=t.isMergedMainCell?t.mergeInfo:t,u={startX:p.startX+d,endX:p.endX-l,startY:p.startY+c,endY:p.endY-h},C=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!C)return;const m=this._dataValidationModel.getValidator(C.type);if(!m)return;const O=u.endX-u.startX,M=u.endY-u.startY,v=(D=f.getCellValueOrigin(a))!=null?D:"",_=m.parseCellValue(v),S=U.getFontStyleString(n!=null?n:void 0);return ut(_,S,O,M).calcAutoWidth}isHit(e,t){const{primaryWithCoord:n}=t,a=n.isMergedMainCell?n.mergeInfo:n,{endX:i}=a,{x:o}=e;return o>=i-Ie&&o<=i}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:i,col:o}=e,s={unitId:n,subUnitId:a,row:i,column:o};this._commandService.executeCommand(ke.id,s)}onPointerEnter(e,t){var n,a;return(a=(n=U.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(U.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;return(a=(n=U.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(U.CURSOR_TYPE.DEFAULT)}};ht=qa([ze(0,r.ICommandService),ze(1,r.IUniverInstanceService),ze(2,r.Inject(U.IRenderManagerService)),ze(3,r.Inject(f.SheetDataValidationModel))],ht);class Ja extends F.BaseSheetDataValidatorView{constructor(){super(...arguments);R(this,"id",r.DataValidationType.LIST_MULTIPLE);R(this,"canvasRender",this.injector.createInstance(ht));R(this,"dropdownType",x.DataValidatorDropdownType.MULTIPLE_LIST)}}var Qa=Object.getOwnPropertyDescriptor,en=(e,t,n,a)=>{for(var i=a>1?void 0:a?Qa(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Fe=(e,t)=>(n,a)=>t(n,a,e);const Ce=4,Ke=4,se=14,ue=6,Le=4,pt=8,tn="#565656",Ut=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 an(e,t){const n=e.length;return{id:"d",body:{dataStream:`${e}${r.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:r.BooleanNumber.FALSE,bl:r.BooleanNumber.FALSE,ul:{s:r.BooleanNumber.FALSE},st:{s:r.BooleanNumber.FALSE},ol:{s:r.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:n}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function Nt(e,t,n){const a=an(e,n),i=new r.DocumentDataModel(a),o=new U.DocumentViewModel(i);return{documentSkeleton:U.DocumentSkeleton.create(o,t),docModel:i,docViewModel:o}}function Ge(e,t,n){const{documentSkeleton:a,docModel:i,docViewModel:o}=Nt(e,t,n);return{documents:new U.Documents(`DOCUMENTS_${r.Tools.generateRandomId()}`,a,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:a,docModel:i,docViewModel:o}}function kt(e,t,n,a,i,o,s=!0){let d=0;const l=s?Le:0;switch(i){case r.VerticalAlign.BOTTOM:d=t-a-l;break;case r.VerticalAlign.MIDDLE:d=(t-a)/2;break;default:d=l;break}d=Math.max(Le,d);let c=0;switch(o){case r.HorizontalAlign.CENTER:c=(e-n)/2;break;case r.HorizontalAlign.RIGHT:c=e-n;break}return c=Math.max(ue,c),{paddingLeft:c,paddingTop:d}}let mt=class{constructor(e,t,n,a,i){R(this,"_dropdownInfoMap",new Map);R(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=a,this._dataValidationModel=i}_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,n,a,i,o,s){const{t:d=r.DEFAULT_STYLES.pd.t,b:l=r.DEFAULT_STYLES.pd.b}=s,c=n-se;let h;switch(o){case r.VerticalAlign.MIDDLE:h=(a-Ke)/2;break;case r.VerticalAlign.BOTTOM:h=a-l-i-Le+(i/2-Ke/2);break;default:h=d+Le+(i/2-Ke/2);break}e.save(),e.translateWithPrecision(t.startX+c,t.startY+h),e.fillStyle="#565656",e.fill(Ut),e.restore()}drawWith(e,t,n){const{primaryWithCoord:a,row:i,col:o,style:s,data:d,subUnitId:l}=t,c=a.isMergedMainCell?a.mergeInfo:a,h=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,o);if(!h)return;const p=this._dataValidationModel.getValidator(h.type);if(!p)return;const u=d==null?void 0:d.fontRenderExtension,{leftOffset:C=0,rightOffset:m=0,topOffset:O=0,downOffset:M=0}=u||{};if(!h||!p||!p||p.id.indexOf(r.DataValidationType.LIST)!==0||!p.skipDefaultFontRender(h))return;const v={startX:c.startX+C,endX:c.endX-m,startY:c.startY+O,endY:c.endY-M},_=v.endX-v.startX,S=v.endY-v.startY,V=this._ensureMap(l),D=this._generateKey(i,o),y=p.getListWithColor(h),w=f.getCellValueOrigin(d),L=`${w!=null?w:""}`,W=y.find(P=>P.label===L);let{tb:A,vt:B,ht:k,pd:j}=s||{};if(A=A!=null?A:r.WrapStrategy.WRAP,B=B!=null?B:r.VerticalAlign.BOTTOM,k=k!=null?k:r.DEFAULT_STYLES.ht,j=j!=null?j:r.DEFAULT_STYLES.pd,h.renderMode===r.DataValidationRenderMode.ARROW){const{l:P=r.DEFAULT_STYLES.pd.l,t:X=r.DEFAULT_STYLES.pd.t,r:z=r.DEFAULT_STYLES.pd.r,b:Z=r.DEFAULT_STYLES.pd.b}=j,Q=_-P-z-se-4,{documentSkeleton:J,documents:ie,docModel:he}=Ge(L,this._localeService,s);A===r.WrapStrategy.WRAP&&he.updateDocumentDataPageSize(Math.max(Q,1)),J.calculate(),J.getActualSize();const le=U.getDocsSkeletonPageSize(J),{height:oe,width:de}=le,{paddingTop:me,paddingLeft:pe}=kt(Q,S-X-Z,de,oe,B,k,!0);this._drawDownIcon(e,v,_,S,oe,B,j),e.save(),e.translateWithPrecision(v.startX+P,v.startY+X),e.beginPath(),e.rect(0,0,_-P-z,S-X-Z),e.clip(),e.translateWithPrecision(0,me),e.save(),e.translateWithPrecision(Ce,0),e.beginPath(),e.rect(0,0,Q,oe),e.clip(),ie.render(e),e.translateWithPrecision(pe,0),e.restore(),e.restore(),V.set(D,{left:v.endX+P+n.rowHeaderWidth-se,top:v.startY+X+n.columnHeaderHeight,width:se,height:S-X-Z})}else{e.save(),e.translateWithPrecision(v.startX,v.startY),e.beginPath(),e.rect(0,0,_,S),e.clip();const P=_-ue*2-Ce-se-4,{documentSkeleton:X,documents:z,docModel:Z}=Ge(L,this._localeService,s);A===r.WrapStrategy.WRAP&&Z.updateDocumentDataPageSize(Math.max(P,1)),X.calculate();const Q=U.getDocsSkeletonPageSize(X),{height:J,width:ie}=Q,{paddingTop:he,paddingLeft:le}=kt(P,S,ie,J,B,k);e.translateWithPrecision(ue,he);const oe=Math.max(_-ue*2,1),de=J;U.Rect.drawWith(e,{width:oe,height:de,fill:(W==null?void 0:W.color)||ye,radius:pt}),e.save(),e.translateWithPrecision(Ce,0),e.beginPath(),e.rect(0,0,P,J),e.clip(),e.translateWithPrecision(le,0),z.render(e),e.restore(),e.translateWithPrecision(P+Ce+4,(J-Ke)/2),e.fillStyle=tn,e.fill(Ut),e.restore(),V.set(D,{left:v.startX+ue+n.rowHeaderWidth,top:v.startY+he+n.columnHeaderHeight,width:oe,height:de})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:p=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!u||u.renderMode===r.DataValidationRenderMode.TEXT)return;const C={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-p},m=C.endX-C.startX,O=f.getCellValueOrigin(a),M=`${O!=null?O:""}`;let{tb:v,pd:_}=n||{};const{t:S=r.DEFAULT_STYLES.pd.t,b:V=r.DEFAULT_STYLES.pd.b}=_!=null?_:{};if(v=v!=null?v:r.WrapStrategy.WRAP,u.renderMode===r.DataValidationRenderMode.ARROW){const D=m-se,{documentSkeleton:y,docModel:w}=Ge(M,this._localeService,n);v===r.WrapStrategy.WRAP&&w.updateDocumentDataPageSize(Math.max(D,1)),y.calculate(),y.getActualSize();const L=U.getDocsSkeletonPageSize(y),{height:W}=L;return W+S+V+Le*2}else{const D=m-ue*2-Ce-se,{documentSkeleton:y,docModel:w}=Nt(M,this._localeService,n);v===r.WrapStrategy.WRAP&&w.updateDocumentDataPageSize(Math.max(D,1)),y.calculate();const L=U.getDocsSkeletonPageSize(y),{height:W}=L;return W+Le*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:p=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!u||u.renderMode===r.DataValidationRenderMode.TEXT)return;const C={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-p},m=C.endX-C.startX,O=f.getCellValueOrigin(a),M=`${O!=null?O:""}`;let{tb:v,pd:_}=n||{};const{l:S=r.DEFAULT_STYLES.pd.l,r:V=r.DEFAULT_STYLES.pd.r}=_!=null?_:{};v=v!=null?v:r.WrapStrategy.WRAP;let D=ue*2+se;switch(u.renderMode){case r.DataValidationRenderMode.ARROW:D=se+ue*2+V+S;break;case r.DataValidationRenderMode.CUSTOM:D=se+ue*2+Ce*2+V+S+pt/2+1;break;default:D=se+ue*2+Ce*2+V+S+pt/2+1}const y=m-D,{documentSkeleton:w,docModel:L}=Ge(M,this._localeService,n);return v===r.WrapStrategy.WRAP&&L.updateDocumentDataPageSize(Math.max(y,1)),w.calculate(),w.getActualSize(),U.getDocsSkeletonPageSize(w).width+D}isHit(e,t){const{subUnitId:n,row:a,col:i}=t,s=this._ensureMap(n).get(this._generateKey(a,i)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,a,i);if(!d||!s||d.renderMode===r.DataValidationRenderMode.TEXT)return!1;const{top:l,left:c,width:h,height:p}=s,{x:u,y:C}=e;return u>=c&&u<=c+h&&C>=l&&C<=l+p}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:i,col:o}=e,s={unitId:n,subUnitId:a,row:i,column:o};this._commandService.executeCommand(ke.id,s)}onPointerEnter(e,t){var n,a;(a=(n=U.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(U.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=U.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(U.CURSOR_TYPE.DEFAULT)}};mt=en([Fe(0,r.IUniverInstanceService),Fe(1,r.Inject(r.LocaleService)),Fe(2,r.ICommandService),Fe(3,r.Inject(U.IRenderManagerService)),Fe(4,r.Inject(f.SheetDataValidationModel))],mt);class nn extends F.BaseSheetDataValidatorView{constructor(){super(...arguments);R(this,"id",r.DataValidationType.LIST);R(this,"canvasRender",this.injector.createInstance(mt));R(this,"dropdownType",x.DataValidatorDropdownType.LIST);R(this,"optionsInput",$e.componentKey);R(this,"formulaInput",f.LIST_FORMULA_INPUT_NAME)}}class on extends F.BaseSheetDataValidatorView{constructor(){super(...arguments);R(this,"id",r.DataValidationType.TEXT_LENGTH);R(this,"formulaInput",f.BASE_FORMULA_INPUT_NAME)}}class rn extends F.BaseSheetDataValidatorView{constructor(){super(...arguments);R(this,"id",r.DataValidationType.WHOLE);R(this,"formulaInput",f.BASE_FORMULA_INPUT_NAME)}}var sn=Object.getOwnPropertyDescriptor,ln=(e,t,n,a)=>{for(var i=a>1?void 0:a?sn(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},gt=(e,t)=>(n,a)=>t(n,a,e);let Ae=class extends r.RxDisposable{constructor(e,t,n){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=n,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[Tt,_t],[Ne,Fa],[$e.componentKey,$e],[Ye.componentKey,Ye],...na].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Ya,rn,on,$a,ja,nn,Ja,Ha].forEach(e=>{const t=this._injector.createInstance(e),n=this._dataValidatorRegistryService.getValidatorItem(t.id);n&&(n.formulaInput=t.formulaInput,n.canvasRender=t.canvasRender,n.dropdownType=t.dropdownType,n.optionsInput=t.optionsInput)})}};Ae=ln([gt(0,r.Inject(r.Injector)),gt(1,r.Inject(E.ComponentManager)),gt(2,r.Inject(x.DataValidatorRegistryService))],Ae);var dn=Object.getOwnPropertyDescriptor,cn=(e,t,n,a)=>{for(var i=a>1?void 0:a?dn(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},vt=(e,t)=>(n,a)=>t(n,a,e);const un="SHEET_DATA_VALIDATION_UI_PLUGIN";F.UniverSheetsDataValidationUIPlugin=(qe=class extends r.Plugin{constructor(t=Ue,n,a,i){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=i;const{menu:o,...s}=r.merge({},Ue,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(tt,s)}onStarting(){[[ce],[fe],[Pe],[Ee],[be],[Te],[Me],[De],[Ae]].forEach(t=>{this._injector.add(t)}),[Be,ke,Mt,nt,Se,Et].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Me),this._injector.get(Te),this._injector.get(De),this._injector.get(Pe),this._injector.get(U.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[je])}onRendered(){this._injector.get(Ae),this._injector.get(be)}onSteady(){this._injector.get(Ee)}},R(qe,"pluginName",un),R(qe,"type",r.UniverInstanceType.UNIVER_SHEET),qe),F.UniverSheetsDataValidationUIPlugin=cn([vt(1,r.Inject(r.Injector)),vt(2,r.ICommandService),vt(3,r.IConfigService)],F.UniverSheetsDataValidationUIPlugin);var hn=Object.getOwnPropertyDescriptor,pn=(e,t,n,a)=>{for(var i=a>1?void 0:a?hn(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},ft=(e,t)=>(n,a)=>t(n,a,e);const mn="SHEET_DATA_VALIDATION_UI_PLUGIN";F.UniverSheetsDataValidationMobileUIPlugin=(Ze=class extends r.Plugin{constructor(t=Ue,n,a,i){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=i;const{menu:o,...s}=r.merge({},Ue,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(tt,s)}onStarting(){[[ce],[fe],[Pe],[Ee],[be],[Te],[Me],[Ae]].forEach(t=>{this._injector.add(t)}),[Be,ke,Mt,nt,Se,Et].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Me),this._injector.get(Te),this._injector.get(U.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[je])}onRendered(){this._injector.get(Ae),this._injector.get(be)}onSteady(){this._injector.get(Ee)}},R(Ze,"pluginName",mn),R(Ze,"type",r.UniverInstanceType.UNIVER_SHEET),Ze),F.UniverSheetsDataValidationMobileUIPlugin=pn([ft(1,r.Inject(r.Injector)),ft(2,r.ICommandService),ft(3,r.IConfigService)],F.UniverSheetsDataValidationMobileUIPlugin),Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-data-validation-ui",
3
- "version": "0.6.10-nightly.202504171607",
3
+ "version": "0.6.10-nightly.202504191606",
4
4
  "private": false,
5
5
  "description": "Data validation UI for Univer Sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -56,17 +56,17 @@
56
56
  "dependencies": {
57
57
  "@flatten-js/interval-tree": "^1.1.3",
58
58
  "@univerjs/icons": "^0.3.2",
59
- "@univerjs/core": "0.6.10-nightly.202504171607",
60
- "@univerjs/data-validation": "0.6.10-nightly.202504171607",
61
- "@univerjs/engine-formula": "0.6.10-nightly.202504171607",
62
- "@univerjs/engine-render": "0.6.10-nightly.202504171607",
63
- "@univerjs/sheets": "0.6.10-nightly.202504171607",
64
- "@univerjs/design": "0.6.10-nightly.202504171607",
65
- "@univerjs/sheets-formula-ui": "0.6.10-nightly.202504171607",
66
- "@univerjs/sheets-data-validation": "0.6.10-nightly.202504171607",
67
- "@univerjs/sheets-numfmt": "0.6.10-nightly.202504171607",
68
- "@univerjs/sheets-ui": "0.6.10-nightly.202504171607",
69
- "@univerjs/ui": "0.6.10-nightly.202504171607"
59
+ "@univerjs/data-validation": "0.6.10-nightly.202504191606",
60
+ "@univerjs/core": "0.6.10-nightly.202504191606",
61
+ "@univerjs/engine-formula": "0.6.10-nightly.202504191606",
62
+ "@univerjs/design": "0.6.10-nightly.202504191606",
63
+ "@univerjs/engine-render": "0.6.10-nightly.202504191606",
64
+ "@univerjs/sheets": "0.6.10-nightly.202504191606",
65
+ "@univerjs/sheets-formula-ui": "0.6.10-nightly.202504191606",
66
+ "@univerjs/sheets-numfmt": "0.6.10-nightly.202504191606",
67
+ "@univerjs/sheets-ui": "0.6.10-nightly.202504191606",
68
+ "@univerjs/sheets-data-validation": "0.6.10-nightly.202504191606",
69
+ "@univerjs/ui": "0.6.10-nightly.202504191606"
70
70
  },
71
71
  "devDependencies": {
72
72
  "less": "^4.3.0",
@@ -77,7 +77,7 @@
77
77
  "typescript": "^5.8.3",
78
78
  "vite": "^6.3.0",
79
79
  "vitest": "^3.1.1",
80
- "@univerjs-infra/shared": "0.6.10-alpha.0"
80
+ "@univerjs-infra/shared": "0.6.10"
81
81
  },
82
82
  "scripts": {
83
83
  "dev": "vite",