@univerjs/sheets-data-validation-ui 0.5.0-nightly.202411131606 → 0.5.0-nightly.202411141606
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +4 -2
- package/lib/umd/index.js +1 -1
- package/package.json +14 -14
package/lib/cjs/index.js
CHANGED
@@ -6,4 +6,4 @@
|
|
6
6
|
*
|
7
7
|
* This source code is licensed under the MIT license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
|
-
*/var ln=j,dn=Symbol.for("react.element"),cn=Symbol.for("react.fragment"),un=Object.prototype.hasOwnProperty,hn=ln.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,pn={key:!0,ref:!0,__self:!0,__source:!0};function Lt(e,t,a){var n,o={},r=null,s=null;a!==void 0&&(r=""+a),t.key!==void 0&&(r=""+t.key),t.ref!==void 0&&(s=t.ref);for(n in t)un.call(t,n)&&!pn.hasOwnProperty(n)&&(o[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)o[n]===void 0&&(o[n]=t[n]);return{$$typeof:dn,type:e,key:r,ref:s,props:o,_owner:hn.current}}Ke.Fragment=cn;Ke.jsx=Lt;Ke.jsxs=Lt;Pt.exports=Ke;var m=Pt.exports,jt={exports:{}};(function(e,t){(function(a,n){e.exports=n()})(Ot,function(){var a=1e3,n=6e4,o=36e5,r="millisecond",s="second",d="minute",l="hour",u="day",h="week",p="month",c="quarter",C="year",g="date",f="Invalid Date",w=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,V=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(D){var S=["th","st","nd","rd"],v=D%100;return"["+D+(S[(v-20)%10]||S[v]||S[0])+"]"}},I=function(D,S,v){var y=String(D);return!y||y.length>=S?D:""+Array(S+1-y.length).join(v)+D},x={s:I,z:function(D){var S=-D.utcOffset(),v=Math.abs(S),y=Math.floor(v/60),_=v%60;return(S<=0?"+":"-")+I(y,2,"0")+":"+I(_,2,"0")},m:function D(S,v){if(S.date()<v.date())return-D(v,S);var y=12*(v.year()-S.year())+(v.month()-S.month()),_=S.clone().add(y,p),A=v-_<0,b=S.clone().add(y+(A?-1:1),p);return+(-(y+(v-_)/(A?_-b:b-_))||0)},a:function(D){return D<0?Math.ceil(D)||0:Math.floor(D)},p:function(D){return{M:p,y:C,w:h,d:u,D:g,h:l,m:d,s,ms:r,Q:c}[D]||String(D||"").toLowerCase().replace(/s$/,"")},u:function(D){return D===void 0}},T="en",P={};P[T]=M;var R="$isDayjsObject",L=function(D){return D instanceof W||!(!D||!D[R])},k=function D(S,v,y){var _;if(!S)return T;if(typeof S=="string"){var A=S.toLowerCase();P[A]&&(_=A),v&&(P[A]=v,_=A);var b=S.split("-");if(!_&&b.length>1)return D(b[0])}else{var H=S.name;P[H]=S,_=H}return!y&&_&&(T=_),_||!y&&T},U=function(D,S){if(L(D))return D.clone();var v=typeof S=="object"?S:{};return v.date=D,v.args=arguments,new W(v)},E=x;E.l=k,E.i=L,E.w=function(D,S){return U(D,{locale:S.$L,utc:S.$u,x:S.$x,$offset:S.$offset})};var W=function(){function D(v){this.$L=k(v.locale,null,!0),this.parse(v),this.$x=this.$x||v.x||{},this[R]=!0}var S=D.prototype;return S.parse=function(v){this.$d=function(y){var _=y.date,A=y.utc;if(_===null)return new Date(NaN);if(E.u(_))return new Date;if(_ instanceof Date)return new Date(_);if(typeof _=="string"&&!/Z$/i.test(_)){var b=_.match(w);if(b){var H=b[2]-1||0,G=(b[7]||"0").substring(0,3);return A?new Date(Date.UTC(b[1],H,b[3]||1,b[4]||0,b[5]||0,b[6]||0,G)):new Date(b[1],H,b[3]||1,b[4]||0,b[5]||0,b[6]||0,G)}}return new Date(_)}(v),this.init()},S.init=function(){var v=this.$d;this.$y=v.getFullYear(),this.$M=v.getMonth(),this.$D=v.getDate(),this.$W=v.getDay(),this.$H=v.getHours(),this.$m=v.getMinutes(),this.$s=v.getSeconds(),this.$ms=v.getMilliseconds()},S.$utils=function(){return E},S.isValid=function(){return this.$d.toString()!==f},S.isSame=function(v,y){var _=U(v);return this.startOf(y)<=_&&_<=this.endOf(y)},S.isAfter=function(v,y){return U(v)<this.startOf(y)},S.isBefore=function(v,y){return this.endOf(y)<U(v)},S.$g=function(v,y,_){return E.u(v)?this[y]:this.set(_,v)},S.unix=function(){return Math.floor(this.valueOf()/1e3)},S.valueOf=function(){return this.$d.getTime()},S.startOf=function(v,y){var _=this,A=!!E.u(y)||y,b=E.p(v),H=function(z,B){var Z=E.w(_.$u?Date.UTC(_.$y,B,z):new Date(_.$y,B,z),_);return A?Z:Z.endOf(u)},G=function(z,B){return E.w(_.toDate()[z].apply(_.toDate("s"),(A?[0,0,0,0]:[23,59,59,999]).slice(B)),_)},J=this.$W,te=this.$M,ne=this.$D,ae="set"+(this.$u?"UTC":"");switch(b){case C:return A?H(1,0):H(31,11);case p:return A?H(1,te):H(0,te+1);case h:var $=this.$locale().weekStart||0,O=(J<$?J+7:J)-$;return H(A?ne-O:ne+(6-O),te);case u:case g:return G(ae+"Hours",0);case l:return G(ae+"Minutes",1);case d:return G(ae+"Seconds",2);case s:return G(ae+"Milliseconds",3);default:return this.clone()}},S.endOf=function(v){return this.startOf(v,!1)},S.$set=function(v,y){var _,A=E.p(v),b="set"+(this.$u?"UTC":""),H=(_={},_[u]=b+"Date",_[g]=b+"Date",_[p]=b+"Month",_[C]=b+"FullYear",_[l]=b+"Hours",_[d]=b+"Minutes",_[s]=b+"Seconds",_[r]=b+"Milliseconds",_)[A],G=A===u?this.$D+(y-this.$W):y;if(A===p||A===C){var J=this.clone().set(g,1);J.$d[H](G),J.init(),this.$d=J.set(g,Math.min(this.$D,J.daysInMonth())).$d}else H&&this.$d[H](G);return this.init(),this},S.set=function(v,y){return this.clone().$set(v,y)},S.get=function(v){return this[E.p(v)]()},S.add=function(v,y){var _,A=this;v=Number(v);var b=E.p(y),H=function(te){var ne=U(A);return E.w(ne.date(ne.date()+Math.round(te*v)),A)};if(b===p)return this.set(p,this.$M+v);if(b===C)return this.set(C,this.$y+v);if(b===u)return H(1);if(b===h)return H(7);var G=(_={},_[d]=n,_[l]=o,_[s]=a,_)[b]||1,J=this.$d.getTime()+v*G;return E.w(J,this)},S.subtract=function(v,y){return this.add(-1*v,y)},S.format=function(v){var y=this,_=this.$locale();if(!this.isValid())return _.invalidDate||f;var A=v||"YYYY-MM-DDTHH:mm:ssZ",b=E.z(this),H=this.$H,G=this.$m,J=this.$M,te=_.weekdays,ne=_.months,ae=_.meridiem,$=function(B,Z,re,De){return B&&(B[Z]||B(y,A))||re[Z].slice(0,De)},O=function(B){return E.s(H%12||12,B,"0")},z=ae||function(B,Z,re){var De=B<12?"AM":"PM";return re?De.toLowerCase():De};return A.replace(V,function(B,Z){return Z||function(re){switch(re){case"YY":return String(y.$y).slice(-2);case"YYYY":return E.s(y.$y,4,"0");case"M":return J+1;case"MM":return E.s(J+1,2,"0");case"MMM":return $(_.monthsShort,J,ne,3);case"MMMM":return $(ne,J);case"D":return y.$D;case"DD":return E.s(y.$D,2,"0");case"d":return String(y.$W);case"dd":return $(_.weekdaysMin,y.$W,te,2);case"ddd":return $(_.weekdaysShort,y.$W,te,3);case"dddd":return te[y.$W];case"H":return String(H);case"HH":return E.s(H,2,"0");case"h":return O(1);case"hh":return O(2);case"a":return z(H,G,!0);case"A":return z(H,G,!1);case"m":return String(G);case"mm":return E.s(G,2,"0");case"s":return String(y.$s);case"ss":return E.s(y.$s,2,"0");case"SSS":return E.s(y.$ms,3,"0");case"Z":return b}return null}(B)||b.replace(":","")})},S.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},S.diff=function(v,y,_){var A,b=this,H=E.p(y),G=U(v),J=(G.utcOffset()-this.utcOffset())*n,te=this-G,ne=function(){return E.m(b,G)};switch(H){case C:A=ne()/12;break;case p:A=ne();break;case c:A=ne()/3;break;case h:A=(te-J)/6048e5;break;case u:A=(te-J)/864e5;break;case l:A=te/o;break;case d:A=te/n;break;case s:A=te/a;break;default:A=te}return _?A:E.a(A)},S.daysInMonth=function(){return this.endOf(p).$D},S.$locale=function(){return P[this.$L]},S.locale=function(v,y){if(!v)return this.$L;var _=this.clone(),A=k(v,y,!0);return A&&(_.$L=A),_},S.clone=function(){return E.w(this.$d,this)},S.toDate=function(){return new Date(this.valueOf())},S.toJSON=function(){return this.isValid()?this.toISOString():null},S.toISOString=function(){return this.$d.toISOString()},S.toString=function(){return this.$d.toUTCString()},D}(),X=W.prototype;return U.prototype=X,[["$ms",r],["$s",s],["$m",d],["$H",l],["$W",u],["$M",p],["$y",C],["$D",g]].forEach(function(D){X[D[1]]=function(S){return this.$g(S,D[0],D[1])}}),U.extend=function(D,S){return D.$i||(D(S,W,U),D.$i=!0),U},U.locale=k,U.isDayjs=L,U.unix=function(D){return U(1e3*D)},U.en=P[T],U.Ls=P,U.p={},U})})(jt);var fn=jt.exports;const We=Tt(fn);var At={exports:{}};(function(e,t){(function(a,n){e.exports=n()})(Ot,function(){var a="minute",n=/[+-]\d\d(?::?\d\d)?/g,o=/([+-]|\d\d)/g;return function(r,s,d){var l=s.prototype;d.utc=function(f){var w={date:f,utc:!0,args:arguments};return new s(w)},l.utc=function(f){var w=d(this.toDate(),{locale:this.$L,utc:!0});return f?w.add(this.utcOffset(),a):w},l.local=function(){return d(this.toDate(),{locale:this.$L,utc:!1})};var u=l.parse;l.parse=function(f){f.utc&&(this.$u=!0),this.$utils().u(f.$offset)||(this.$offset=f.$offset),u.call(this,f)};var h=l.init;l.init=function(){if(this.$u){var f=this.$d;this.$y=f.getUTCFullYear(),this.$M=f.getUTCMonth(),this.$D=f.getUTCDate(),this.$W=f.getUTCDay(),this.$H=f.getUTCHours(),this.$m=f.getUTCMinutes(),this.$s=f.getUTCSeconds(),this.$ms=f.getUTCMilliseconds()}else h.call(this)};var p=l.utcOffset;l.utcOffset=function(f,w){var V=this.$utils().u;if(V(f))return this.$u?0:V(this.$offset)?p.call(this):this.$offset;if(typeof f=="string"&&(f=function(T){T===void 0&&(T="");var P=T.match(n);if(!P)return null;var R=(""+P[0]).match(o)||["-",0,0],L=R[0],k=60*+R[1]+ +R[2];return k===0?0:L==="+"?k:-k}(f),f===null))return this;var M=Math.abs(f)<=16?60*f:f,I=this;if(w)return I.$offset=M,I.$u=f===0,I;if(f!==0){var x=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(I=this.local().add(M+x,a)).$offset=M,I.$x.$localOffset=x}else I=this.utc();return I};var c=l.format;l.format=function(f){var w=f||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return c.call(this,w)},l.valueOf=function(){var f=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*f},l.isUTC=function(){return!!this.$u},l.toISOString=function(){return this.toDate().toISOString()},l.toString=function(){return this.toDate().toUTCString()};var C=l.toDate;l.toDate=function(f){return f==="s"&&this.$offset?d(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():C.call(this)};var g=l.diff;l.diff=function(f,w,V){if(f&&this.$u===f.$u)return g.call(this,f,w,V);var M=this.local(),I=d(f).local();return g.call(M,I,w,V)}}})})(At);var mn=At.exports;const gn=Tt(mn);var vn=Object.defineProperty,Sn=Object.getOwnPropertyDescriptor,_n=(e,t,a,n)=>{for(var o=n>1?void 0:n?Sn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&vn(t,a,o),o},Oe=(e,t)=>(a,n)=>t(a,n,e);let Pe=class extends i.Disposable{constructor(e,t,a,n,o){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=o,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(Q.AFTER_CELL_EDIT_ASYNC,{handler:async(e,t,a)=>{var f;const n=await e,{worksheet:o,row:r,col:s,unitId:d,subUnitId:l,workbook:u}=t,h=this._dataValidationModel.getRuleIdByLocation(d,l,r,s),p=h?this._dataValidationModel.getRuleById(d,l,h):void 0;if(!p||p.errorStyle!==i.DataValidationErrorStyle.STOP)return a(Promise.resolve(n));const c=await this._dataValidatorRegistryService.getValidatorItem(p.type);if(!c||await c.validator({value:F.getCellValueOrigin(n),interceptValue:F.getCellValueOrigin((f=t==null?void 0:t.origin)!=null?f:n),row:r,column:s,unitId:d,subUnitId:l,worksheet:o,workbook:u,t:n==null?void 0:n.t},p))return a(Promise.resolve(n));const g=o.getCellRaw(r,s);return this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:c.getRuleFinalError(p,{row:r,col:s,unitId:d,subUnitId:l})},footer:{title:j.createElement(N.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(Promise.resolve(g))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:j.createElement(N.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Pe=_n([Oe(0,i.Inject(Q.SheetInterceptorService)),Oe(1,i.Inject(F.SheetDataValidationModel)),Oe(2,i.Inject(ie.DataValidatorRegistryService)),Oe(3,ee.IDialogService),Oe(4,i.Inject(i.LocaleService))],Pe);const In="univer-dv-date-dropdown",Cn="univer-dv-date-dropdown-btns",Dt={dvDateDropdown:In,dvDateDropdownBtns:Cn};We.extend(gn);const Dn=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return We(i.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=We(e);if(t.isValid())return t};function yn(e){var P,R,L;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:r,unitId:s,subUnitId:d,workbook:l}=t,u=i.useDependency(i.ICommandService),h=i.useDependency(Pe),p=n.getCell(o,r),c=(P=p==null?void 0:p.dataValidation)==null?void 0:P.rule,C=(R=p==null?void 0:p.dataValidation)==null?void 0:R.validator,g=F.getCellValueOrigin(n.getCellRaw(o,r)),f=Dn(g),[w,V]=j.useState(f),M=!!((L=c==null?void 0:c.bizInfo)!=null&&L.showTime),I=w&&w.isValid()?w:We(),x=i.useDependency(i.LocaleService);if(!p||!c||!C)return;const T=async()=>{var S,v,y;if(!I)return;const U=I.format(M?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),E=(S=i.numfmt.parseDate(U))==null?void 0:S.v,W=l.getStyles().getStyleByCell(p),X=(y=(v=W==null?void 0:W.n)==null?void 0:v.pattern)!=null?y:"",D=rn.getPatternType(X);c.errorStyle!==i.DataValidationErrorStyle.STOP||await C.validator({value:E,unitId:s,subUnitId:d,row:o,column:r,worksheet:n,workbook:l,interceptValue:U.replace("Z","").replace("T"," "),t:i.CellValueType.NUMBER},c)?(a(),await u.executeCommand(K.SetCellEditVisibleOperation.id,{visible:!1,eventType:q.DeviceInputEventType.Keyboard,unitId:s,keycode:ee.KeyCode.ESC}),await u.executeCommand(Q.SetRangeValuesCommand.id,{unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:o,endRow:o},value:{v:E,t:2,p:null,f:null,si:null,s:{n:{pattern:M?D==="datetime"?X:"yyyy-MM-dd hh:mm:ss":D==="date"?X:"yyyy-MM-dd"}}}})):h.showReject(C.getRuleFinalError(c,{row:o,col:r,unitId:s,subUnitId:d}))};return m.jsxs("div",{className:Dt.dvDateDropdown,children:[m.jsx(N.DatePanel,{defaultValue:I,pickerValue:I,showTime:M||void 0,onSelect:async k=>{V(k)},onPanelChange:k=>{V(k)},disabledDate:k=>!i.numfmt.parseDate(k.format("YYYY-MM-DD"))}),m.jsx("div",{className:Dt.dvDateDropdownBtns,children:m.jsx(N.Button,{size:"small",type:"primary",onClick:T,disabled:!I.isValid(),children:x.t("dataValidation.alert.ok")})})]})}var le=function(){return le=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},le.apply(this,arguments)},wn=function(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(a[n[o]]=e[n[o]]);return a},ge=j.forwardRef(function(e,t){var a=e.icon,n=e.id,o=e.className,r=e.extend,s=wn(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),l=j.useRef("_".concat(Mn()));return $t(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},le({ref:t,className:d},s),r)});function $t(e,t,a,n,o){return j.createElement(e.tag,le(le({key:t},Rn(e,a,o)),n),(Vn(e,a).children||[]).map(function(r,s){return $t(r,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,o)}))}function Rn(e,t,a){var n=le({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1);var o=t.defIds;return!o||o.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],d=r[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Vn(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?le(le({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?le(le({},o),{attrs:le(le({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):e}function Mn(){return Math.random().toString(36).substring(2,8)}ge.displayName="UniverIcon";var En={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},xt=j.forwardRef(function(e,t){return j.createElement(ge,Object.assign({},e,{id:"check-mark-single",ref:t,icon:En}))});xt.displayName="CheckMarkSingle";var bn={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"}}]},Ft=j.forwardRef(function(e,t){return j.createElement(ge,Object.assign({},e,{id:"data-validation-single",ref:t,icon:bn}))});Ft.displayName="DataValidationSingle";var On={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"}}]},gt=j.forwardRef(function(e,t){return j.createElement(ge,Object.assign({},e,{id:"delete-single",ref:t,icon:On}))});gt.displayName="DeleteSingle";var Tn={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"}}]},Ut=j.forwardRef(function(e,t){return j.createElement(ge,Object.assign({},e,{id:"increase-single",ref:t,icon:Tn}))});Ut.displayName="IncreaseSingle";var Pn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Nt=j.forwardRef(function(e,t){return j.createElement(ge,Object.assign({},e,{id:"more-down-single",ref:t,icon:Pn}))});Nt.displayName="MoreDownSingle";var Ln={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"}}]},kt=j.forwardRef(function(e,t){return j.createElement(ge,Object.assign({},e,{id:"more-up-single",ref:t,icon:Ln}))});kt.displayName="MoreUpSingle";var jn={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"}}]}]},Bt=j.forwardRef(function(e,t){return j.createElement(ge,Object.assign({},e,{id:"sequence-single",ref:t,icon:jn}))});Bt.displayName="SequenceSingle";var An=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,xn=(e,t,a,n)=>{for(var o=n>1?void 0:n?$n(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&An(t,a,o),o},yt=(e,t)=>(a,n)=>t(a,n,e);let he=class extends i.Disposable{constructor(t,a){super();Y(this,"_open$",new de.BehaviorSubject(!1));Y(this,"open$",this._open$.pipe(de.distinctUntilChanged()));Y(this,"_activeRule");Y(this,"_activeRule$",new de.BehaviorSubject(void 0));Y(this,"activeRule$",this._activeRule$.asObservable());Y(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).pipe(de.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===vt&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=i.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};he=xn([yt(0,i.IUniverInstanceService),yt(1,ee.ISidebarService)],he);function Fn(){const e=i.useDependency(me),t=ee.useObservable(e.activeDropdown$,e.activeDropdown),a=i.useDependency(ee.ComponentManager);if(!t)return null;const{location:n,componentKey:o}=t,r=a.get(o),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!r)return null;const d=()=>{e.hideDropdown()};return m.jsx(r,{location:n,hideFn:d},s)}const Wt="sheet.ui.dropdown";var Un=Object.defineProperty,Nn=Object.getOwnPropertyDescriptor,kn=(e,t,a,n)=>{for(var o=n>1?void 0:n?Nn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Un(t,a,o),o},ve=(e,t)=>(a,n)=>t(a,n,e);let me=class extends i.Disposable{constructor(t,a,n,o,r,s,d){super();Y(this,"_activeDropdown");Y(this,"_activeDropdown$",new de.Subject);Y(this,"_currentPopup",null);Y(this,"activeDropdown$",this._activeDropdown$.asObservable());Y(this,"_zenVisible",!1);this._canvasPopupManagerService=t,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=o,this._renderManagerService=r,this._dataValidationModel=s,this._sheetsSelectionsService=d,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,a,n,o){const r=t?this._univerInstanceService.getUnit(t,i.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!r)return;const s=a?r.getSheetBySheetId(a):r.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(r.getUnitId(),s.getSheetId(),n,o);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdown}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t,a=!0){const{location:n}=t,{row:o,col:r,unitId:s,subUnitId:d}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const l=this._renderManagerService.getRenderById(i.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),u=this._canvasPopupManagerService.attachPopupToCell(o,r,{componentKey:Wt,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[l==null?void 0:l.engine.getCanvasElement()].filter(Boolean)},s,d);if(!u)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const h=new i.DisposableCollection;h.add(u),h.add({dispose:()=>{var p,c;(c=(p=this._activeDropdown)==null?void 0:p.onHide)==null||c.call(p)}}),this._currentPopup=h}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,a,n,o,r){const s=this._univerInstanceService.getUnit(t,i.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(a);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,o);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!u||!u.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:o,unitId:t,subUnitId:a},componentKey:u.dropdown,onHide:r})}};me=kn([ve(0,i.Inject(K.SheetCanvasPopManagerService)),ve(1,i.IUniverInstanceService),ve(2,i.Inject(ie.DataValidatorRegistryService)),ve(3,ee.IZenZoneService),ve(4,q.IRenderManagerService),ve(5,i.Inject(F.SheetDataValidationModel)),ve(6,i.Inject(Q.SheetsSelectionsService))],me);const vt="DataValidationPanel",Ce={id:"data-validation.operation.open-validation-panel",type:i.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,o=e.get(he),r=e.get(ie.DataValidationModel),s=e.get(i.IUniverInstanceService),d=e.get(ee.ISidebarService),l=Q.getSheetCommandTarget(s);if(!l)return!1;const{unitId:u,subUnitId:h}=l,p=a?r.getRuleById(u,h,a):void 0;o.open(),o.setActiveRule(p&&{unitId:u,subUnitId:h,rule:p});const c=d.open({header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:vt},width:312,onClose:()=>o.close()});return o.setCloseDisposable(c),!0}},St={id:"data-validation.operation.close-validation-panel",type:i.CommandType.OPERATION,handler(e){return e.get(he).close(),!0}},Ht={id:"data-validation.operation.toggle-validation-panel",type:i.CommandType.OPERATION,handler(e){const t=e.get(i.ICommandService),a=e.get(he);return a.open(),a.isOpen?t.executeCommand(St.id):t.executeCommand(Ce.id),!0}},Ge={type:i.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(me),{unitId:n,subUnitId:o,row:r,column:s}=t,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===o&&l.row===r&&l.col===s||a.showDataValidationDropdown(n,o,r,s),!0}},Yt={type:i.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(me).hideDropdown(),!0):!1}},Ie="#ECECEC",_t="sheets-data-validation-ui.config",Xt={},Bn="univer-dv-list-dropdown",Wn="univer-dv-list-dropdown-title",Hn="univer-dv-list-dropdown-list",Yn="univer-dv-list-dropdown-list-container",Xn="univer-dv-list-dropdown-selected-icon",zn="univer-dv-list-dropdown-item-container",Kn="univer-dv-list-dropdown-item",Gn="univer-dv-list-dropdown-split",Zn="univer-dv-list-dropdown-edit",fe={dvListDropdown:Bn,dvListDropdownTitle:Wn,dvListDropdownList:Hn,dvListDropdownListContainer:Yn,dvListDropdownSelectedIcon:Xn,dvListDropdownItemContainer:zn,dvListDropdownItem:Kn,dvListDropdownSplit:Gn,dvListDropdownEdit:Zn},qn=e=>{var T,P;const{value:t,onChange:a,multiple:n,options:o,title:r,onEdit:s,style:d,filter:l,location:u}=e,h=i.useDependency(i.LocaleService),p=i.useDependency(i.IConfigService),c=l==null?void 0:l.toLowerCase(),{row:C,col:g,unitId:f,subUnitId:w}=u,V=o.filter(R=>c?R.label.toLowerCase().includes(c):!0),M=(P=(T=p.getConfig(_t))==null?void 0:T.showEditOnDropdown)!=null?P:!0,I=i.useDependency(K.SheetPermissionInterceptorBaseController),x=j.useMemo(()=>I.permissionCheckWithRanges({workbookTypes:[Q.WorkbookEditablePermission],rangeTypes:[Q.RangeProtectionPermissionEditPoint],worksheetTypes:[Q.WorksheetEditPermission]},[{startColumn:g,startRow:C,endColumn:g,endRow:C}],f,w),[I,g,C,f,w]);return m.jsxs("div",{className:fe.dvListDropdown,style:d,children:[m.jsx("div",{className:fe.dvListDropdownTitle,children:r}),m.jsx("div",{className:fe.dvListDropdownList,children:m.jsx(N.Scrollbar,{children:m.jsx("div",{className:fe.dvListDropdownListContainer,children:V.map((R,L)=>{const k=t.indexOf(R.value)>-1,U=()=>{let W;k?W=new Set(t.filter(D=>D!==R.value)):W=new Set(n?[...t,R.value]:[R.value]);const X=[];o.forEach(D=>{W.has(D.value)&&X.push(D.value)}),a(X)},E=R.label.toLocaleLowerCase().indexOf(c);return m.jsxs("div",{className:fe.dvListDropdownItemContainer,onClick:U,children:[m.jsx("div",{className:fe.dvListDropdownItem,style:{background:R.color||Ie},children:c&&R.label.toLowerCase().includes(c)?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:R.label.substring(0,E)}),m.jsx("span",{style:{fontWeight:"bold"},children:R.label.substring(E,E+c.length)}),m.jsx("span",{children:R.label.substring(E+c.length)})]}):R.label}),m.jsx("div",{className:fe.dvListDropdownSelectedIcon,children:k?m.jsx(xt,{}):null})]},L)})})},l)}),M&&x?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:fe.dvListDropdownSplit}),m.jsx("div",{className:fe.dvListDropdownEdit,children:m.jsx("a",{onClick:s,children:h.t("dataValidation.list.edit")})})]}):null]})};function Jn(e){var D,S,v,y,_,A;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:r,unitId:s,subUnitId:d}=t,l=i.useDependency(ie.DataValidationModel),[u,h]=j.useState(""),p=i.useDependency(i.ICommandService),c=i.useDependency(i.LocaleService),[C,g]=j.useState(""),f=i.useDependency(K.IEditorBridgeService),w=i.useDependency(i.IUniverInstanceService),V=j.useMemo(()=>l.ruleChange$.pipe(de.debounceTime(16)),[]);ee.useObservable(V);const M=ee.RectPopup.useContext(),I=((S=(D=M.current)==null?void 0:D.right)!=null?S:0)-((y=(v=M.current)==null?void 0:v.left)!=null?y:0);if(j.useEffect(()=>{const b=p.onCommandExecuted(H=>{var G,J;if(H.id===sn.RichTextEditingMutation.id){const te=H.params,{unitId:ne}=te,ae=w.getUnit(ne,i.UniverInstanceType.UNIVER_DOC);if(!ae)return;const $=i.BuildTextUtils.transform.getPlainText((J=(G=ae.getSnapshot().body)==null?void 0:G.dataStream)!=null?J:"");h($)}});return()=>{b.dispose()}},[p,w]),!n)return null;const x=n.getCell(o,r),T=(_=x==null?void 0:x.dataValidation)==null?void 0:_.rule,P=(A=x==null?void 0:x.dataValidation)==null?void 0:A.validator,R=(T==null?void 0:T.renderMode)===i.DataValidationRenderMode.CUSTOM||(T==null?void 0:T.renderMode)===void 0;if(!x||!T||!P||P.id.indexOf(i.DataValidationType.LIST)!==0)return;const L=T.type===i.DataValidationType.LIST_MULTIPLE,k=P.getListWithColor(T,s,d),U=C||F.getDataValidationCellValue(n.getCellRaw(o,r)),E=F.deserializeListOptions(U),W=()=>{p.executeCommand(Ce.id,{ruleId:T.uid}),a()},X=k.map(b=>({label:b.label,value:b.label,color:R||b.color?b.color:"transparent"}));return m.jsx(qn,{style:{minWidth:I,maxWidth:Math.max(I,200)},title:L?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:E,multiple:L,onChange:async b=>{const H=F.serializeListOptions(b),G={unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:o,endRow:o},value:{v:H,p:null,f:null,si:null}};f.isVisible()&&f.changeVisible({visible:!1,keycode:ee.KeyCode.ESC,eventType:q.DeviceInputEventType.Keyboard,unitId:s}),g(H),L||a(),f.isVisible().visible&&await p.executeCommand(K.SetCellEditVisibleOperation.id,{visible:!1,eventType:q.DeviceInputEventType.Keyboard,unitId:s,keycode:ee.KeyCode.ESC}),p.executeCommand(Q.SetRangeValuesCommand.id,G)},options:X,onEdit:W,filter:u,location:t})}const Qn="univer-data-validation-options-button",ea="univer-data-validation-options-button-icon",Qe={dataValidationOptionsButton:Qn,dataValidationOptionsButtonIcon:ea};function ta(e){var u;const t=i.useDependency(i.LocaleService),a=i.useDependency(ee.ComponentManager),{value:n,onChange:o,extraComponent:r}=e,[s,d]=j.useState(!1),l=r?a.get(r):null;return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:Qe.dataValidationOptionsButton,onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?m.jsx(kt,{className:Qe.dataValidationOptionsButtonIcon}):m.jsx(Nt,{className:Qe.dataValidationOptionsButtonIcon})]}),s&&m.jsxs(m.Fragment,{children:[l?m.jsx(l,{value:n,onChange:o}):null,m.jsx(N.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:m.jsxs(N.RadioGroup,{value:`${(u=n.errorStyle)!=null?u:i.DataValidationErrorStyle.WARNING}`,onChange:h=>o({...n,errorStyle:+h}),children:[m.jsx(N.Radio,{value:`${i.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),m.jsx(N.Radio,{value:`${i.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),m.jsx(N.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:m.jsx(N.Checkbox,{checked:n.showErrorMessage,onChange:()=>o({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?m.jsx(N.FormLayout,{children:m.jsx(N.Input,{value:n.error,onChange:h=>o({...n,error:h})})}):null]})]})}const na="univer-data-validation-detail",aa="univer-data-validation-detail-form-item",oa="univer-data-validation-detail-buttons",ia="univer-data-validation-detail-button",ye={dataValidationDetail:na,dataValidationDetailFormItem:aa,dataValidationDetailButtons:oa,dataValidationDetailButton:ia},ra=e=>i.debounce(async(t,a,n,o)=>{const r=await e.executeCommand(t,a,n);o==null||o(r)},1e3);function sa(e,t,a){var n,o,r,s;return t?((o=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:o.getSheetId())||"":((s=(r=e.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function la(){var ae;const[e,t]=j.useState(0),a=i.useDependency(he),n=ee.useObservable(a.activeRule$,a.activeRule),{unitId:o,subUnitId:r,rule:s}=n||{},d=s.uid,l=i.useDependency(ie.DataValidatorRegistryService),u=i.useDependency(i.IUniverInstanceService),h=i.useDependency(ee.ComponentManager),p=i.useDependency(i.ICommandService),c=i.useDependency(ie.DataValidationModel),C=i.useDependency(i.LocaleService),[g,f]=j.useState(s),w=l.getValidatorItem(g.type),[V,M]=j.useState(!1),I=l.getValidatorsByScope(ie.DataValidatorRegistryScope.SHEET),[x,T]=j.useState(()=>g.ranges.map($=>({unitId:"",sheetId:"",range:$}))),P=j.useMemo(()=>ra(p),[p]),[R,L]=j.useState(!1),k=j.useRef({}),[U,E]=j.useState(!1),W=i.useDependency(Q.SheetsSelectionsService);if(j.useEffect(()=>()=>{const $=W.getCurrentLastSelection();$&&W.setSelections([$])},[W]),j.useEffect(()=>{p.onCommandExecuted($=>{($.id===i.UndoCommand.id||$.id===i.RedoCommand.id)&&setTimeout(()=>{const O=c.getRuleById(o,r,d);t(z=>z+1),O&&(f(O),T(O.ranges.map(z=>({unitId:"",sheetId:"",range:z}))))},20)})},[p,c,d,r,o]),!w)return null;const X=w.operators,D=w.operatorNames,S=g.operator?ie.TWO_FORMULA_OPERATOR_COUNT.includes(g.operator):!1,v=()=>{!g.ranges.length||R||(w.validatorFormula(g,o,r).success?a.setActiveRule(null):M(!0))},y=ee.useEvent($=>{const O=$.split(",").map(ct.deserializeRangeWithSheet).map(Z=>{const re=Z.sheetName;if(re){const De=sa(u,Z.unitId,re);return{...Z,sheetId:De}}return{...Z,sheetId:""}});if(i.isUnitRangesEqual(O,x))return;T(O);const z=O.filter(Z=>(!Z.unitId||Z.unitId===o)&&(!Z.sheetId||Z.sheetId===r)).map(Z=>Z.range);if(f({...g,ranges:z}),z.length===0)return;const B={unitId:o,subUnitId:r,ruleId:d,ranges:z};P(F.UpdateSheetDataValidationRangeCommand.id,B)}),_=$=>{if(i.shallowEqual($,ie.getRuleSetting(g)))return;f({...g,...$});const O={unitId:o,subUnitId:r,ruleId:d,setting:$};P(F.UpdateSheetDataValidationSettingCommand.id,O,void 0)},A=async()=>{await p.executeCommand(F.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:o,subUnitId:r}),a.setActiveRule(null)},b={type:g.type,operator:g.operator,formula1:g.formula1,formula2:g.formula2,allowBlank:g.allowBlank},H=$=>{const O=l.getValidatorItem($);if(!O)return;const z=O.operators,B=c.getRuleById(o,r,d),Z=$===(B==null?void 0:B.type)||$.includes("list")&&(B!=null&&B.type.includes("list"))?{...B,type:$}:{...g,type:$,operator:z[0],formula1:void 0,formula2:void 0};f(Z),p.executeCommand(F.UpdateSheetDataValidationSettingCommand.id,{unitId:o,subUnitId:r,ruleId:g.uid,setting:ie.getRuleSetting(Z)})},G=h.get(w.formulaInput),J=j.useMemo(()=>x.map($=>ct.serializeRange($.range)).join(","),[]),te=ie.getRuleOptions(g),ne=$=>{i.shallowEqual($,ie.getRuleOptions(g))||(f({...g,...$}),P(F.UpdateSheetDataValidationOptionsCommand.id,{unitId:o,subUnitId:r,ruleId:d,options:$}))};return ee.useSidebarClick($=>{var z;const O=(z=k.current)==null?void 0:z.handleOutClick;O&&O($,()=>E(!1))}),m.jsxs("div",{className:ye.dataValidationDetail,children:[m.jsx(N.FormLayout,{label:C.t("dataValidation.panel.range"),error:!g.ranges.length||R?C.t("dataValidation.panel.rangeError"):"",children:m.jsx(mt.RangeSelector,{unitId:o,subUnitId:r,initValue:J,onChange:y,onFocus:()=>E(!0),isFocus:U,actions:k.current,onVerify:$=>L(!$)})}),m.jsx(N.FormLayout,{label:C.t("dataValidation.panel.type"),children:m.jsx(N.Select,{options:I==null?void 0:I.map($=>({label:C.t($.title),value:$.id})),value:g.type,onChange:H,className:ye.dataValidationDetailFormItem})}),X!=null&&X.length?m.jsx(N.FormLayout,{label:C.t("dataValidation.panel.operator"),children:m.jsx(N.Select,{options:X.map(($,O)=>({value:`${$}`,label:D[O]})),value:`${g.operator}`,onChange:$=>{_({...b,operator:$})},className:ye.dataValidationDetailFormItem})}):null,G?m.jsx(G,{isTwoFormula:S,value:{formula1:g.formula1,formula2:g.formula2},onChange:$=>{_({...b,...$})},showError:V,validResult:w.validatorFormula(g,o,r),unitId:o,subUnitId:r,ruleId:d},e+g.type):null,m.jsx(N.FormLayout,{children:m.jsx(N.Checkbox,{checked:(ae=g.allowBlank)!=null?ae:!0,onChange:()=>{var $;return _({...b,allowBlank:!(($=g.allowBlank)==null||$)})},children:C.t("dataValidation.panel.allowBlank")})}),m.jsx(ta,{value:te,onChange:ne,extraComponent:w.optionsInput}),m.jsxs("div",{className:ye.dataValidationDetailButtons,children:[m.jsx(N.Button,{className:ye.dataValidationDetailButton,onClick:A,children:C.t("dataValidation.panel.removeRule")}),m.jsx(N.Button,{className:ye.dataValidationDetailButton,type:"primary",onClick:v,children:C.t("dataValidation.panel.done")})]})]})}const da="univer-data-validation-item-container",ca="univer-data-validation-item-title",ua="univer-data-validation-item-content",ha="univer-data-validation-item-icon",je={dataValidationItemContainer:da,dataValidationItemTitle:ca,dataValidationItemContent:ua,dataValidationItemIcon:ha},pa=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:o,disable:r}=e,s=i.useDependency(ie.DataValidatorRegistryService),d=i.useDependency(i.ICommandService),l=i.useDependency(K.IMarkSelectionService),u=s.getValidatorItem(t.type),h=j.useRef(),[p,c]=j.useState(!1),C=g=>{d.executeCommand(F.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:o}),g.stopPropagation()};return j.useEffect(()=>()=>{var g;h.current&&((g=h.current)==null||g.forEach(f=>{f&&l.removeShape(f)}))},[l]),m.jsxs("div",{className:je.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{r||(c(!0),h.current=t.ranges.map(g=>l.addShape({range:g,style:{hasAutoFill:!1,fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:null})))},onMouseLeave:()=>{var g;c(!1),(g=h.current)==null||g.forEach(f=>{f&&l.removeShape(f)}),h.current=void 0},children:[m.jsx("div",{className:je.dataValidationItemTitle,children:u==null?void 0:u.generateRuleName(t)}),m.jsx("div",{className:je.dataValidationItemContent,children:t.ranges.map(g=>ct.serializeRange(g)).join(",")}),p?m.jsx("div",{className:je.dataValidationItemIcon,onClick:C,children:m.jsx(gt,{})}):null]})},fa="univer-data-validation-list",ma="univer-data-validation-list-buttons",ga="univer-data-validation-list-button",Ae={dataValidationList:fa,dataValidationListButtons:ma,dataValidationListButton:ga};function va(){const e=i.useDependency(i.IUniverInstanceService),t=ee.useObservable(()=>e.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return t?m.jsx(Sa,{workbook:t}):null}function Sa(e){const t=i.useDependency(F.SheetDataValidationModel),a=i.useDependency(i.IUniverInstanceService),n=i.useDependency(i.ICommandService),o=i.useDependency(i.Injector),r=i.useDependency(he),s=i.useDependency(i.LocaleService),[d,l]=j.useState([]),{workbook:u}=e,h=ee.useObservable(u.activeSheet$,void 0,!0),p=u.getUnitId(),c=h==null?void 0:h.getSheetId();j.useEffect(()=>{l(t.getRules(p,c));const M=t.ruleChange$.subscribe(I=>{I.unitId===p&&I.subUnitId===c&&l(t.getRules(p,c))});return()=>{M.unsubscribe()}},[p,c,t]);const C=async()=>{const M=F.createDefaultNewRule(o),I={unitId:p,subUnitId:c,rule:M};await n.executeCommand(F.AddSheetDataValidationCommand.id,I),r.setActiveRule({unitId:p,subUnitId:c,rule:M})},g=()=>{n.executeCommand(F.RemoveSheetAllDataValidationCommand.id,{unitId:p,subUnitId:c})},w=(M=>{const I=a.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),x=I.getActiveSheet(),T=I.getUnitId(),P=x.getSheetId();return M.map(L=>Q.checkRangesEditablePermission(o,T,P,L.ranges)?{...L}:{...L,disable:!0})})(d),V=w==null?void 0:w.some(M=>M.disable);return m.jsxs("div",{className:Ae.dataValidationList,children:[w==null?void 0:w.map(M=>{var I;return m.jsx(pa,{unitId:p,subUnitId:c,onClick:()=>{M.disable||r.setActiveRule({unitId:p,subUnitId:c,rule:M})},rule:M,disable:(I=M.disable)!=null?I:!1},M.uid)}),m.jsxs("div",{className:Ae.dataValidationListButtons,children:[d.length&&!V?m.jsx(N.Button,{className:Ae.dataValidationListButton,onClick:g,children:s.t("dataValidation.panel.removeAll")}):null,m.jsx(N.Button,{className:Ae.dataValidationListButton,type:"primary",onClick:C,children:s.t("dataValidation.panel.add")})]})]})}const _a=()=>{const e=i.useDependency(he),t=ee.useObservable(e.activeRule$,e.activeRule);return t?m.jsx(la,{},t.rule.uid):m.jsx(va,{})},Ze="data-validation.list.dropdown",It="data-validation.date.dropdown",qe={type:i.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(i.IUniverInstanceService),a=Q.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:o}=a,r=F.createDefaultNewRule(e),s=e.get(i.ICommandService),d=n.getUnitId(),l=o.getSheetId(),u={rule:r,unitId:d,subUnitId:l};return s.syncExecuteCommand(F.AddSheetDataValidationCommand.id,u)?(s.syncExecuteCommand(Ce.id,{ruleId:r.uid,isAdd:!0}),!0):!1}};var Ia=Object.defineProperty,Ca=Object.getOwnPropertyDescriptor,Da=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ca(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Ia(t,a,o),o},Te=(e,t)=>(a,n)=>t(a,n,e);const $e="SHEET_DATA_VALIDATION_ALERT";let Le=class extends i.Disposable{constructor(e,t,a,n,o){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=o,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(de.debounceTime(100)).subscribe(e=>{var t,a;if(e){const o=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!o)return;const r=o.getCell(e.location.row,e.location.col);if(((t=r==null?void 0:r.dataValidation)==null?void 0:t.validStatus)===i.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get($e),d=(a=s==null?void 0:s.alert)==null?void 0:a.location;if(d&&d.row===e.location.row&&d.col===e.location.col&&d.subUnitId===e.location.subUnitId&&d.unitId===e.location.unitId)return;const l=r.dataValidation.validator,u=r.dataValidation.rule;if(!l)return;this._cellAlertManagerService.showAlert({type:K.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(u,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)}))}};Le=Da([Te(0,i.Inject(K.HoverManagerService)),Te(1,i.Inject(K.CellAlertManagerService)),Te(2,i.IUniverInstanceService),Te(3,i.Inject(i.LocaleService)),Te(4,ee.IZenZoneService)],Le);var ya=Object.defineProperty,wa=Object.getOwnPropertyDescriptor,Ra=(e,t,a,n)=>{for(var o=n>1?void 0:n?wa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&ya(t,a,o),o},et=(e,t)=>(a,n)=>t(a,n,e);let Re=class extends i.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._dataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(o,r)=>{const{source:s,target:d,unitId:l,subUnitId:u}=o,h=this._dataValidationModel.getRuleObjectMatrix(l,u).clone(),p=K.virtualizeDiscreteRanges([s,d]),[c,C]=p.ranges,{mapFunc:g}=p,f={row:c.startRow,col:c.startColumn},w=K.getAutoFillRepeatRange(c,C),V=new i.ObjectMatrix,M=new Set;w.forEach(R=>{const L=R.repeatStartCell,k=R.relativeRange,U={startRow:f.row,startColumn:f.col,endColumn:f.col,endRow:f.row},E={startRow:L.row,startColumn:L.col,endColumn:L.col,endRow:L.row};i.Range.foreach(k,(W,X)=>{const D=i.Rectangle.getPositionRange({startRow:W,startColumn:X,endColumn:X,endRow:W},U),{row:S,col:v}=g(D.startRow,D.startColumn),y=this._dataValidationModel.getRuleIdByLocation(l,u,S,v);if(y){const _=i.Rectangle.getPositionRange({startRow:W,startColumn:X,endColumn:X,endRow:W},E),{row:A,col:b}=g(_.startRow,_.startColumn);V.setValue(A,b,y),M.add(y)}})});const I=Array.from(M).map(R=>({id:R,ranges:i.queryObjectMatrix(V,L=>L===R)}));h.addRangeRules(I);const x=h.diff(this._dataValidationModel.getRules(l,u)),{redoMutations:T,undoMutations:P}=F.getDataValidationDiffMutations(l,u,x,this._injector,"patched",r===K.APPLY_TYPE.ONLY_FORMAT);return{undos:P,redos:T}},a=[i.DataValidationType.CHECKBOX],n={id:F.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:o=>{const{source:r,unitId:s,subUnitId:d}=o;for(const l of r.rows)for(const u of r.cols){const h=this._dataValidationModel.getRuleByLocation(s,d,l,u);if(h&&a.indexOf(h.type)>-1){this._autoFillService.setDisableApplyType(K.APPLY_TYPE.SERIES,!0);return}}},onFillData:(o,r,s)=>s===K.APPLY_TYPE.COPY||s===K.APPLY_TYPE.ONLY_FORMAT||s===K.APPLY_TYPE.SERIES?t(o,s):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};Re=Ra([et(0,K.IAutoFillService),et(1,i.Inject(F.SheetDataValidationModel)),et(2,i.Inject(i.Injector))],Re);var Va=Object.defineProperty,Ma=Object.getOwnPropertyDescriptor,Ea=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ma(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Va(t,a,o),o},tt=(e,t)=>(a,n)=>t(a,n,e);let Ve=class extends i.Disposable{constructor(t,a,n){super();Y(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:F.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,o)=>{const{copyType:r=K.COPY_TYPE.COPY,pasteType:s}=o,{range:d}=t||{},{range:l,unitId:u,subUnitId:h}=a;return this._generateMutations(l,{copyType:r,pasteType:s,copyRange:d,unitId:u,subUnitId:h})}})}_collect(t,a,n){const o=new i.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:o};const r=this._injector.invoke(l=>K.rangeToDiscreteRange(n,l,t,a));if(!r)return;const{rows:s,cols:d}=r;s.forEach((l,u)=>{d.forEach((h,p)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(t,a,l,h);o.setValue(u,p,c!=null?c:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===K.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:n,subUnitId:o}=this._copyInfo;if(a.unitId!==n||o!==a.subUnitId){const r=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),s=new i.ObjectMatrix,d=new Set,{ranges:[l,u],mapFunc:h}=K.virtualizeDiscreteRanges([a.copyRange,t]),p=K.getRepeatRange(l,u,!0),c=new Map;p.forEach(({startRange:w})=>{var V;(V=this._copyInfo)==null||V.matrix.forValue((M,I,x)=>{const T=i.Rectangle.getPositionRange({startRow:M,endRow:M,startColumn:I,endColumn:I},w),P=`${o}-${x}`,R=this._sheetDataValidationModel.getRuleById(n,o,x);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,P)&&R&&c.set(P,{...R,uid:P});const{row:L,col:k}=h(T.startRow,T.startColumn);d.add(P),s.setValue(L,k,P)})});const C=Array.from(d).map(w=>({id:w,ranges:i.queryObjectMatrix(s,V=>V===w)}));r.addRangeRules(C);const{redoMutations:g,undoMutations:f}=F.getDataValidationDiffMutations(a.unitId,a.subUnitId,r.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),c.values()),this._injector,"patched",!1);return{redos:g,undos:f}}else{const r=this._sheetDataValidationModel.getRuleObjectMatrix(n,o).clone(),s=new i.ObjectMatrix,d=new Set,{ranges:[l,u],mapFunc:h}=K.virtualizeDiscreteRanges([a.copyRange,t]);K.getRepeatRange(l,u,!0).forEach(({startRange:f})=>{var w;(w=this._copyInfo)==null||w.matrix.forValue((V,M,I)=>{const x=i.Rectangle.getPositionRange({startRow:V,endRow:V,startColumn:M,endColumn:M},f),{row:T,col:P}=h(x.startRow,x.startColumn);s.setValue(T,P,I),d.add(I)})});const c=Array.from(d).map(f=>({id:f,ranges:i.queryObjectMatrix(s,w=>w===f)}));r.addRangeRules(c);const{redoMutations:C,undoMutations:g}=F.getDataValidationDiffMutations(n,o,r.diff(this._sheetDataValidationModel.getRules(n,o)),this._injector,"patched",!1);return{redos:C,undos:g}}}};Ve=Ea([tt(0,K.ISheetClipboardService),tt(1,i.Inject(F.SheetDataValidationModel)),tt(2,i.Inject(i.Injector))],Ve);var ba=Object.defineProperty,Oa=Object.getOwnPropertyDescriptor,Ta=(e,t,a,n)=>{for(var o=n>1?void 0:n?Oa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&ba(t,a,o),o},nt=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends i.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionInterceptorBaseController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===F.AddSheetDataValidationCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[Q.WorkbookEditablePermission],rangeTypes:[Q.RangeProtectionPermissionEditPoint],worksheetTypes:[Q.WorksheetEditPermission,Q.WorksheetSetCellStylePermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr"))),e.id===F.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[Q.WorkbookEditablePermission],rangeTypes:[Q.RangeProtectionPermissionEditPoint],worksheetTypes:[Q.WorksheetEditPermission,Q.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr")))}))}};Me=Ta([nt(0,i.Inject(i.LocaleService)),nt(1,i.ICommandService),nt(2,i.Inject(K.SheetPermissionInterceptorBaseController))],Me);const zt="data-validation-single",Kt="sheet.menu.data-validation";function Pa(e){return{id:Kt,type:ee.MenuItemType.SUBITEMS,icon:zt,tooltip:"dataValidation.title",hidden$:ee.getMenuHiddenObservable(e,i.UniverInstanceType.UNIVER_SHEET),disabled$:K.getCurrentRangeDisable$(e,{workbookTypes:[Q.WorkbookEditablePermission],worksheetTypes:[Q.WorksheetSetCellStylePermission,Q.WorksheetEditPermission],rangeTypes:[Q.RangeProtectionPermissionEditPoint]})}}function La(e){return{id:Ce.id,title:"dataValidation.panel.title",type:ee.MenuItemType.BUTTON}}function ja(e){return{id:qe.id,title:"dataValidation.panel.add",type:ee.MenuItemType.BUTTON}}const Aa={[ee.RibbonStartGroup.FORMULAS_INSERT]:{[Kt]:{order:9,menuItemFactory:Pa,[Ce.id]:{order:0,menuItemFactory:La},[qe.id]:{order:1,menuItemFactory:ja}}}};var $a=Object.defineProperty,xa=Object.getOwnPropertyDescriptor,Gt=(e,t,a,n)=>{for(var o=n>1?void 0:n?xa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&$a(t,a,o),o},oe=(e,t)=>(a,n)=>t(a,n,e);const Zt={tr:{size:6,color:"#fe4b4b"}};let Ee=class extends i.RxDisposable{constructor(e,t,a,n,o,r,s,d,l,u,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=o,this._dropdownManagerService=r,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=u,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Aa)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var a;if(!e.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:o,row:r,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,o,r,s);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(u!=null&&u.dropdown))return;const h=d.getActiveSheet();if(!h)return;const p=this._dropdownManagerService.activeDropdown,c=p==null?void 0:p.location;if(c&&c.unitId===n&&c.subUnitId===o&&c.row===r&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:o,row:r,col:s,workbook:d,worksheet:h},componentKey:u.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Q.INTERCEPTOR_POINT.CELL_CONTENT,{effect:i.InterceptorEffectEnum.Style,priority:Q.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var V,M,I,x,T,P;const{row:n,col:o,unitId:r,subUnitId:s,workbook:d,worksheet:l}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,o);if(!u)return a(e);const h=this._sheetDataValidationModel.getRuleById(r,s,u);if(!h)return a(e);const p=(M=(V=this._dataValidationCacheService.getValue(r,s,n,o))==null?void 0:V.status)!=null?M:i.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(h.type),C=t.rawData;let g;const f={get value(){var R;return g!==void 0||(g=(R=F.getCellValueOrigin(C))!=null?R:null),g}},w={get value(){var R;return`${(R=f.value)!=null?R:""}`}};return a({...e,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c},markers:{...e==null?void 0:e.markers,...p===i.DataValidationStatus.INVALID?Zt:null},customRender:[...(I=e==null?void 0:e.customRender)!=null?I:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((x=e==null?void 0:e.fontRenderExtension)==null?void 0:x.isSkip)||((T=c==null?void 0:c.skipDefaultFontRender)==null?void 0:T.call(c,h,f.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(h,w.value,{get style(){const R=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?R.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,o)},interceptorAutoHeight:()=>{var U,E,W,X,D,S;const R=(E=(U=this._renderManagerService.getRenderById(r))==null?void 0:U.with(K.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:E.skeleton;if(!R)return;const L=R.worksheet.getMergedCell(n,o),k={data:{...e,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c}},style:R.getsStyles().getStyleByCell(e),primaryWithCoord:R.getCellByIndex((W=L==null?void 0:L.startRow)!=null?W:n,(X=L==null?void 0:L.startColumn)!=null?X:o),unitId:r,subUnitId:s,row:n,col:o,workbook:d,worksheet:l};return(S=(D=c==null?void 0:c.canvasRender)==null?void 0:D.calcCellAutoHeight)==null?void 0:S.call(D,k)},interceptorAutoWidth:()=>{var U,E,W,X,D,S;const R=(E=(U=this._renderManagerService.getRenderById(r))==null?void 0:U.with(K.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:E.skeleton;if(!R)return;const L=R.worksheet.getMergedCell(n,o),k={data:{...e,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c}},style:R.getsStyles().getStyleByCell(e),primaryWithCoord:R.getCellByIndex((W=L==null?void 0:L.startRow)!=null?W:n,(X=L==null?void 0:L.startColumn)!=null?X:o),unitId:r,subUnitId:s,row:n,col:o,workbook:d,worksheet:l};return(S=(D=c==null?void 0:c.canvasRender)==null?void 0:D.calcCellAutoWidth)==null?void 0:S.call(D,k)},coverable:((P=e==null?void 0:e.coverable)!=null?P:!0)&&!(h.type===i.DataValidationType.LIST||h.type===i.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(de.filter(e=>e.source==="command"),de.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);i.sequenceExecute(a.redos,this._commandService)}})}};Ee=Gt([oe(0,i.ICommandService),oe(1,ee.IMenuManagerService),oe(2,q.IRenderManagerService),oe(3,i.IUniverInstanceService),oe(4,i.Inject(K.AutoHeightController)),oe(5,i.Inject(me)),oe(6,i.Inject(F.SheetDataValidationModel)),oe(7,i.Inject(ie.DataValidatorRegistryService)),oe(8,i.Inject(Q.SheetInterceptorService)),oe(9,i.Inject(F.DataValidationCacheService)),oe(10,i.Optional(K.IEditorBridgeService))],Ee);let wt=class extends i.RxDisposable{constructor(e,t,a,n,o,r,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=o,this._sheetDataValidationModel=r,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Q.INTERCEPTOR_POINT.CELL_CONTENT,{effect:i.InterceptorEffectEnum.Style,priority:Q.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var w,V,M,I,x,T;const{row:n,col:o,unitId:r,subUnitId:s,workbook:d,worksheet:l}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,o);if(!u)return a(e);const h=this._sheetDataValidationModel.getRuleById(r,s,u);if(!h)return a(e);const p=(V=(w=this._dataValidationCacheService.getValue(r,s,n,o))==null?void 0:w.status)!=null?V:i.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(h.type),C=l.getCellRaw(n,o),g=F.getCellValueOrigin(C),f=`${g!=null?g:""}`;return a({...e,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c},markers:{...e==null?void 0:e.markers,...p===i.DataValidationStatus.INVALID?Zt:null},customRender:[...(M=e==null?void 0:e.customRender)!=null?M:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((I=e==null?void 0:e.fontRenderExtension)==null?void 0:I.isSkip)||((x=c==null?void 0:c.skipDefaultFontRender)==null?void 0:x.call(c,h,g,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(h,f,{get style(){const P=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?P.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,o)},interceptorAutoHeight:()=>{var k,U,E,W,X,D;const P=(U=(k=this._renderManagerService.getRenderById(r))==null?void 0:k.with(K.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:U.skeleton;if(!P)return;const R=P.worksheet.getMergedCell(n,o),L={data:{...e,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c}},style:P.getsStyles().getStyleByCell(e),primaryWithCoord:P.getCellByIndex((E=R==null?void 0:R.startRow)!=null?E:n,(W=R==null?void 0:R.startColumn)!=null?W:o),unitId:r,subUnitId:s,row:n,col:o,workbook:d,worksheet:l};return(D=(X=c==null?void 0:c.canvasRender)==null?void 0:X.calcCellAutoHeight)==null?void 0:D.call(X,L)},coverable:((T=e==null?void 0:e.coverable)!=null?T:!0)&&!(h.type===i.DataValidationType.LIST||h.type===i.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(de.filter(e=>e.source==="command"),de.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);i.sequenceExecute(a.redos,this._commandService)}})}};wt=Gt([oe(0,i.ICommandService),oe(1,q.IRenderManagerService),oe(2,i.Inject(K.AutoHeightController)),oe(3,i.Inject(ie.DataValidatorRegistryService)),oe(4,i.Inject(Q.SheetInterceptorService)),oe(5,i.Inject(F.SheetDataValidationModel)),oe(6,i.Inject(F.DataValidationCacheService))],wt);var Fa=Object.defineProperty,Ua=Object.getOwnPropertyDescriptor,Na=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ua(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Fa(t,a,o),o},Rt=(e,t)=>(a,n)=>t(a,n,e);let He=class extends i.Disposable{constructor(e,t,a){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const a=new Set;t.forEach(o=>{a.add(o.subUnitId)}),a.forEach(o=>{var r;(r=this._sheetSkeletonManagerService.getWorksheetSkeleton(o))==null||r.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(i.bufferDebounceTime(16)).subscribe(e))}};He=Na([Rt(1,i.Inject(F.SheetDataValidationModel)),Rt(2,i.Inject(K.SheetSkeletonManagerService))],He);const ka="univer-data-validation-formula",Ba="univer-data-validation-formula-and",Wa="univer-data-validation-formula-list-item",Ha="univer-data-validation-formula-list-item-icon",Ya="univer-data-validation-formula-list-item-drag",Xa="univer-data-validation-formula-list-add",za="univer-data-validation-formula-color-select",Ka="univer-data-validation-formula-color-select-panel",Ga="univer-data-validation-formula-color-item",se={dataValidationFormula:ka,dataValidationFormulaAnd:Ba,dataValidationFormulaListItem:Wa,dataValidationFormulaListItemIcon:Ha,dataValidationFormulaListItemDrag:Ya,dataValidationFormulaListAdd:Xa,dataValidationFormulaColorSelect:za,dataValidationFormulaColorSelectPanel:Ka,dataValidationFormulaColorItem:Ga},Za=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:o,validResult:r}=e,s=i.useDependency(i.LocaleService),d=o?r==null?void 0:r.formula1:"",l=o?r==null?void 0:r.formula2:"";return t?m.jsxs(m.Fragment,{children:[m.jsx(N.FormLayout,{error:d,children:m.jsx(N.Input,{className:se.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({...a,formula1:u})}})}),m.jsx("div",{className:se.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),m.jsx(N.FormLayout,{error:l,children:m.jsx(N.Input,{className:se.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:u=>{n==null||n({...a,formula2:u})}})})]}):m.jsx(N.FormLayout,{error:d,children:m.jsx(N.Input,{className:se.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({formula1:u})}})})};function qa(e){const{value:t,onChange:a,showError:n,validResult:o}=e,r=i.useDependency(i.LocaleService),s=n?o==null?void 0:o.formula1:"",d=n?o==null?void 0:o.formula2:"",[l,u]=j.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return m.jsxs(m.Fragment,{children:[m.jsx(N.FormLayout,{children:m.jsx(N.Checkbox,{checked:l,onChange:h=>{h?u(!0):(u(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:r.t("dataValidation.checkbox.tips")})}),l?m.jsx(N.FormLayout,{label:r.t("dataValidation.checkbox.checked"),error:s,children:m.jsx(N.Input,{className:se.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{a==null||a({...t,formula1:h||void 0})}})}):null,l?m.jsx(N.FormLayout,{label:r.t("dataValidation.checkbox.unchecked"),error:d,children:m.jsx(N.Input,{className:se.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{a==null||a({...t,formula2:h||void 0})}})}):null]})}function Ja(e){var p;const{unitId:t,subUnitId:a,value:n,onChange:o,showError:r,validResult:s}=e,d=r?s==null?void 0:s.formula1:void 0,l=j.useRef({}),[u,h]=j.useState(!1);return ee.useSidebarClick(c=>{var g;const C=(g=l.current)==null?void 0:g.handleOutClick;C&&C(c,()=>h(!1))}),m.jsx(mt.FormulaEditor,{initValue:(p=n==null?void 0:n.formula1)!=null?p:"",unitId:t,subUnitId:a,isFocus:u,onChange:c=>{const C=(c!=null?c:"").trim();C!==(n==null?void 0:n.formula1)&&(o==null||o({...n,formula1:C}))},errorText:d,onFocus:()=>h(!0),actions:l.current})}function qt(e){var t,a,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(a=qt(e[t]))&&(n&&(n+=" "),n+=a)}else for(a in e)e[a]&&(n&&(n+=" "),n+=a);return n}function Qa(){for(var e,t,a=0,n="",o=arguments.length;a<o;a++)(e=arguments[a])&&(t=qt(e))&&(n&&(n+=" "),n+=t);return n}const eo=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],to=e=>{const{value:t,onChange:a,disabled:n}=e,[o,r]=j.useState(!1);return m.jsx(N.Select,{disabled:n,open:o,onDropdownVisibleChange:r,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:se.dataValidationFormulaColorSelect,value:t,onChange:a,labelRender:s=>m.jsx("div",{className:se.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>m.jsx("div",{className:se.dataValidationFormulaColorSelectPanel,children:eo.map(s=>m.jsx("div",{onClick:()=>{a(s),r(!1)},className:se.dataValidationFormulaColorItem,style:{background:s}},s))})})},Vt=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:o,onItemDelete:r}=a;return m.jsxs("div",{className:se.dataValidationFormulaListItem,style:n,children:[t.isRef?null:m.jsx("div",{className:Qa(se.dataValidationFormulaListItemDrag,"draggableHandle"),children:m.jsx(Bt,{})}),m.jsx(to,{value:t.color,onChange:s=>{o(t.id,t.label,s)}}),m.jsx(N.Input,{disabled:t.isRef,value:t.label,onChange:s=>{o(t.id,s,t.color)}}),t.isRef?null:m.jsx("div",{className:se.dataValidationFormulaListItemIcon,children:m.jsx(gt,{onClick:()=>r(t.id)})})]})};function no(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:o,validResult:r,showError:s,ruleId:d}=e,{formula1:l="",formula2:u=""}=t||{},h=j.useRef(null),[p,c]=j.useState(()=>i.isFormulaString(l)?"1":"0"),[C,g]=j.useState(p==="1"?l:"="),[f,w]=j.useState(p==="1"?l:"="),V=i.useDependency(i.LocaleService),M=i.useDependency(ie.DataValidatorRegistryService),I=i.useDependency(ie.DataValidationModel),x=i.useDependency(F.DataValidationFormulaController),[T,P]=j.useState(()=>u.split(",")),R=M.getValidatorItem(i.DataValidationType.LIST),[L,k]=j.useState([]),[U,E]=j.useState(""),W=s?r==null?void 0:r.formula1:"",X=j.useMemo(()=>I.ruleChange$.pipe(de.debounceTime(16)),[]),D=ee.useObservable(X),S=ee.useEvent(a);j.useEffect(()=>{(async()=>{await new Promise(B=>{setTimeout(()=>B(!0),100)});const O=I.getRuleById(n,o,d),z=O==null?void 0:O.formula1;if(i.isFormulaString(z)&&R&&O){const B=await R.getListAsync(O,n,o);k(B)}})()},[I,D,R,d,o,n]),j.useEffect(()=>{i.isFormulaString(l)&&l!==f&&(g(l),w(f))},[f,l]);const[v,y]=j.useState(()=>{const O=p!=="1"?F.deserializeListOptions(l):[],z=u.split(",");return O.map((B,Z)=>({label:B,color:z[Z]||Ie,isRef:!1,id:i.Tools.generateRandomId(4)}))}),_=(O,z,B)=>{const Z=v.find(re=>re.id===O);Z&&(Z.label=z,Z.color=B,y([...v]))},A=O=>{const z=v.findIndex(B=>B.id===O);z!==-1&&(v.splice(z,1),y([...v]))},b=u.split(","),H=j.useMemo(()=>L.map((O,z)=>({label:O,color:b[z]||Ie,id:`${z}`,isRef:!0})),[b,L]),G=(O,z,B)=>{const Z=[...T];Z[+O]=B,P(Z),S({formula1:l,formula2:Z.join(",")})},J=()=>{y([...v,{label:"",color:Ie,isRef:!1,id:i.Tools.generateRandomId(4)}])};j.useEffect(()=>{if(p==="1")return;const O=new Set,z=[];v.map(B=>({labelList:B.label.split(","),item:B})).forEach(({item:B,labelList:Z})=>{Z.forEach(re=>{O.has(re)||(O.add(re),z.push({label:re,color:B.color}))})}),S({formula1:F.serializeListOptions(z.map(B=>B.label)),formula2:z.map(B=>B.color===Ie?"":B.color).join(",")})},[v,S,p,f,T]);const te=j.useMemo(()=>async O=>{if(!i.isFormulaString(O)){S==null||S({formula1:"",formula2:u});return}x.getFormulaRefCheck(O)?(S==null||S({formula1:i.isFormulaString(O)?O:"",formula2:u}),E("")):(S==null||S({formula1:"",formula2:u}),g("="),E(V.t("dataValidation.validFail.formulaError")))},[u,S]),ne=j.useRef({}),[ae,$]=j.useState(!1);return ee.useSidebarClick(O=>{var B;const z=(B=ne.current)==null?void 0:B.handleOutClick;z&&z(O,()=>$(!1))}),m.jsxs(m.Fragment,{children:[m.jsx(N.FormLayout,{label:V.t("dataValidation.list.options"),children:m.jsxs(N.RadioGroup,{value:p,onChange:O=>{c(O),g(f),O==="1"&&S({formula1:f==="="?"":f,formula2:T.join(",")})},children:[m.jsx(N.Radio,{value:"0",children:V.t("dataValidation.list.customOptions")}),m.jsx(N.Radio,{value:"1",children:V.t("dataValidation.list.refOptions")})]})}),p==="1"?m.jsxs(m.Fragment,{children:[m.jsx(mt.FormulaEditor,{initValue:C,unitId:n,subUnitId:o,isFocus:ae,onChange:(O="")=>{const z=(O!=null?O:"").trim();w(z),te(z)},errorText:W||U||void 0,onFocus:()=>$(!0),actions:ne.current}),m.jsx("div",{ref:h,style:{marginTop:"12px"},children:H.map(O=>m.jsx(Vt,{item:O,commonProps:{onItemChange:G},style:{marginBottom:12}},O.id))})]}):m.jsx(N.FormLayout,{error:W,children:m.jsxs("div",{ref:h,style:{marginTop:"-12px"},children:[m.jsx(N.DraggableList,{list:v,onListChange:y,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:O=>m.jsx(Vt,{item:O,commonProps:{onItemChange:_,onItemDelete:A}},O.id),idKey:"id"}),m.jsxs("a",{className:se.dataValidationFormulaListAdd,onClick:J,children:[m.jsx(Ut,{}),V.t("dataValidation.list.add")]})]})})]})}const Jt="data-validation.custom-formula-input",Je="data-validation.formula-input",Ct="data-validation.list-formula-input",Qt="data-validation.checkbox-formula-input",ao=[[Jt,Ja],[Je,Za],[Ct,no],[Qt,qa]],oo="LIST_RENDER_MODE_OPTION_INPUT";function Ye(e){var o;const{value:t,onChange:a}=e,n=i.useDependency(i.LocaleService);return m.jsx(N.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:m.jsxs(N.RadioGroup,{value:`${(o=t.renderMode)!=null?o:i.DataValidationRenderMode.CUSTOM}`,onChange:r=>a({...t,renderMode:+r}),children:[m.jsx(N.Radio,{value:`${i.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),m.jsx(N.Radio,{value:`${i.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),m.jsx(N.Radio,{value:`${i.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}Ye.componentKey=oo;const io="DATE_SHOW_TIME_OPTION";function Xe(e){var o;const{value:t,onChange:a}=e,n=i.useDependency(i.LocaleService);return m.jsx(N.FormLayout,{children:m.jsx(N.Checkbox,{checked:(o=t.bizInfo)==null?void 0:o.showTime,onChange:r=>{a({...t,bizInfo:{...t.bizInfo,showTime:r}})},children:n.t("dataValidation.showTime.label")})})}Xe.componentKey=io;var ro=Object.defineProperty,so=Object.getOwnPropertyDescriptor,lo=(e,t,a,n)=>{for(var o=n>1?void 0:n?so(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&ro(t,a,o),o},xe=(e,t)=>(a,n)=>t(a,n,e);const Fe=6;let ut=class{constructor(e,t,a,n){this._commandService=e,this._formulaService=t,this._themeService=a,this._renderManagerService=n}_calc(e,t){var u,h,p;const{vt:a,ht:n}=t||{},o=e.endX-e.startX-Fe*2,r=e.endY-e.startY,s=((u=t==null?void 0:t.fs)!=null?u:10)*1.6;let d=0,l=0;switch(a){case i.VerticalAlign.TOP:l=0;break;case i.VerticalAlign.BOTTOM:l=0+(r-s);break;default:l=0+(r-s)/2;break}switch(n){case i.HorizontalAlign.LEFT:d=Fe;break;case i.HorizontalAlign.RIGHT:d=Fe+(o-s);break;default:d=Fe+(o-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 a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var u,h,p,c,C,g,f,w,V;const{formula1:n=F.CHECKBOX_FORMULA_1,formula2:o=F.CHECKBOX_FORMULA_2}=e,r=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=F.getFormulaResult((p=(h=(u=r==null?void 0:r[0])==null?void 0:u.result)==null?void 0:h[0])==null?void 0:p[0]),d=F.getFormulaResult((g=(C=(c=r==null?void 0:r[1])==null?void 0:c.result)==null?void 0:C[0])==null?void 0:g[0]),l=F.isLegalFormulaResult(String(s))&&F.isLegalFormulaResult(String(d));return{formula1:i.isFormulaString(n)?F.getFormulaResult((V=(w=(f=r==null?void 0:r[0])==null?void 0:f.result)==null?void 0:w[0])==null?void 0:V[0]):n,formula2:i.isFormulaString(o)?d:o,isFormulaValid:l}}drawWith(e,t){var X,D,S,v,y,_;const{style:a,data:n,primaryWithCoord:o,unitId:r,subUnitId:s,worksheet:d,row:l,col:u}=t,h=o.isMergedMainCell?o.mergeInfo:o,p=F.getCellValueOrigin(d.getCellRaw(l,u)),c=(X=n.dataValidation)==null?void 0:X.rule,C=(D=n.dataValidation)==null?void 0:D.validator;if(!c||!C)return;const g=this._themeService.getCurrentTheme();if(!((S=C.skipDefaultFontRender)!=null&&S.call(C,c,p,{unitId:r,subUnitId:s,row:l,column:u})))return;const f=C.parseFormulaSync(c,r,s),{formula1:w}=f,V=this._calc(h,a),{a:M,d:I}=e.getTransform(),x=q.fixLineWidthByScale(V.left,M),T=q.fixLineWidthByScale(V.top,I),P=q.Transform.create().composeMatrix({left:x,top:T,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),R=h.endX-h.startX,L=h.endY-h.startY;e.save(),e.beginPath(),e.rect(h.startX,h.startY,R,L),e.clip();const k=P.getMatrix();e.transform(k[0],k[1],k[2],k[3],k[4],k[5]);const U=((v=a==null?void 0:a.fs)!=null?v:10)*1.6,E=String(p)===String(w),W=g.hyacinth500;q.Checkbox.drawWith(e,{checked:E,width:U,height:U,fill:(_=(y=a==null?void 0:a.cl)==null?void 0:y.rgb)!=null?_:W}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),o=n.top,r=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:u}=e;return l<=d&&l>=s&&u<=r&&u>=o}async onPointerDown(e,t){var f,w,V;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:o,data:r,worksheet:s,row:d,col:l}=e,u=F.getCellValueOrigin(s.getCellRaw(d,l)),h=(f=r.dataValidation)==null?void 0:f.rule,p=(w=r.dataValidation)==null?void 0:w.validator;if(!h||!p||!((V=p.skipDefaultFontRender)!=null&&V.call(p,h,u,{unitId:n,subUnitId:o,row:d,column:l})))return;const{formula1:c,formula2:C}=await this._parseFormula(h,n,o),g={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(u)===F.transformCheckboxValue(String(c))?C:c,p:null}};this._commandService.executeCommand(Q.SetRangeValuesCommand.id,g)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(q.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(q.CURSOR_TYPE.DEFAULT)}};ut=lo([xe(0,i.ICommandService),xe(1,i.Inject(F.DataValidationFormulaService)),xe(2,i.Inject(i.ThemeService)),xe(3,i.Inject(q.IRenderManagerService))],ut);var co=Object.defineProperty,uo=Object.getOwnPropertyDescriptor,ho=(e,t,a,n)=>{for(var o=n>1?void 0:n?uo(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&co(t,a,o),o},po=(e,t)=>(a,n)=>t(a,n,e);let pe=class{constructor(e){Y(this,"canvasRender",null);Y(this,"dropdown");Y(this,"optionsInput");Y(this,"formulaInput",Ct);this.injector=e}};pe=ho([po(0,i.Inject(i.Injector))],pe);class fo extends pe{constructor(){super(...arguments);Y(this,"id",i.DataValidationType.CHECKBOX);Y(this,"canvasRender",this.injector.createInstance(ut));Y(this,"formulaInput",Qt)}}class mo extends pe{constructor(){super(...arguments);Y(this,"id",i.DataValidationType.CUSTOM);Y(this,"formulaInput",Jt)}}const go="data-validation.formula-input";class vo extends pe{constructor(){super(...arguments);Y(this,"id",i.DataValidationType.DATE);Y(this,"formulaInput",go);Y(this,"optionsInput",Xe.componentKey);Y(this,"dropdown",It)}}class So extends pe{constructor(){super(...arguments);Y(this,"id",i.DataValidationType.DECIMAL);Y(this,"formulaInput",Je)}}const en=4,_o=0,at=4,tn=4,ht=6,ze=6,_e=14;function Io(e,t){const a=q.FontCache.getTextSize(e,t),n=a.width+en*2,{ba:o,bd:r}=a,s=o+r;return{width:n,height:s+_o*2,ba:o}}function ot(e,t,a,n){const o=_e+ht*2,r=a-o,s=n-ze*2,d=e.map(c=>({layout:Io(c,t),text:c}));let l;const u=[];d.forEach(c=>{const{layout:C}=c,{width:g,height:f}=C;!l||l.width+g+at>r?(l={width:g,height:f,items:[{...c,left:0}]},u.push(l)):(l.items.push({...c,left:l.width+at}),l.width=l.width+g+at)});let h=0,p=0;return u.forEach((c,C)=>{p=Math.max(p,c.width),C===u.length-1?h+=c.height:h+=c.height+tn}),{lines:u,totalHeight:h,contentWidth:r,contentHeight:s,cellAutoHeight:h+ze*2,calcAutoWidth:p+o}}const Co=8;class Do extends q.Shape{static drawWith(t,a){const{fontString:n,info:o,fill:r,color:s}=a,{layout:d,text:l}=o;t.save(),q.Rect.drawWith(t,{width:d.width,height:d.height,radius:Co,fill:r||Ie}),t.translateWithPrecision(en,d.ba),t.font=n,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var yo=Object.defineProperty,wo=Object.getOwnPropertyDescriptor,Ro=(e,t,a,n)=>{for(var o=n>1?void 0:n?wo(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&yo(t,a,o),o},Mt=(e,t)=>(a,n)=>t(a,n,e);const Vo=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let pt=class{constructor(e,t){Y(this,"zIndex");Y(this,"_dropdownInfoMap",new Map);this._commandService=e,this._renderManagerService=t}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,o){const r=a-_e+4;let s=4;switch(o){case i.VerticalAlign.MIDDLE:s=(n-_e)/2+4;break;case i.VerticalAlign.BOTTOM:s=n-_e+4;break}e.save(),e.translateWithPrecision(t.startX+r,t.startY+s),e.fillStyle="#565656",e.fill(Vo),e.restore()}drawWith(e,t,a,n){var b,H;const{primaryWithCoord:o,row:r,col:s,style:d,data:l,subUnitId:u}=t,h=o.isMergedMainCell?o.mergeInfo:o,p=l.fontRenderExtension,{leftOffset:c=0,rightOffset:C=0,topOffset:g=0,downOffset:f=0}=p||{},w=l.dataValidation,V=this._ensureMap(u),M=this._generateKey(r,s);if(!w)return;const I={startX:h.startX+c,endX:h.endX-C,startY:h.startY+g,endY:h.endY-f},x=I.endX-I.startX,T=I.endY-I.startY,{cl:P}=d||{},R=(b=typeof P=="object"?P==null?void 0:P.rgb:P)!=null?b:"#000",L=q.getFontStyleString(d!=null?d:void 0),{rule:k,validator:U}=w,E=U,{vt:W,ht:X}=d||{},D=W!=null?W:i.VerticalAlign.MIDDLE,S=(H=F.getCellValueOrigin(l))!=null?H:"",v=E.parseCellValue(S),y=E.getListWithColorMap(k),_=ot(v,L,x,T);this._drawDownIcon(e,I,x,T,D),e.save(),e.translateWithPrecision(I.startX,I.startY),e.beginPath(),e.rect(0,0,x-_e,T),e.clip(),e.translateWithPrecision(ht,ze);let A=0;switch(D){case i.VerticalAlign.MIDDLE:A=(_.contentHeight-_.totalHeight)/2;break;case i.VerticalAlign.BOTTOM:A=_.contentHeight-_.totalHeight;break}e.translateWithPrecision(0,A),_.lines.forEach((G,J)=>{e.save();const{width:te,height:ne,items:ae}=G;let $=0;switch(X){case i.HorizontalAlign.RIGHT:$=_.contentWidth-te;break;case i.HorizontalAlign.CENTER:$=(_.contentWidth-te)/2;break}e.translate($,J*(ne+tn)),ae.forEach(O=>{e.save(),e.translateWithPrecision(O.left,0),Do.drawWith(e,{...L,info:O,color:R,fill:y[O.text]}),e.restore()}),e.restore()}),e.restore(),V.set(M,{left:I.startX,top:I.startY,width:_.contentWidth+ht+_e,height:_.contentHeight+ze*2})}calcCellAutoHeight(e){var x;const{primaryWithCoord:t,style:a,data:n}=e,o=n.fontRenderExtension,{leftOffset:r=0,rightOffset:s=0,topOffset:d=0,downOffset:l=0}=o||{},u=t.isMergedMainCell?t.mergeInfo:t,h={startX:u.startX+r,endX:u.endX-s,startY:u.startY+d,endY:u.endY-l},p=n.dataValidation;if(!p)return;const c=h.endX-h.startX,C=h.endY-h.startY,g=(x=F.getCellValueOrigin(n))!=null?x:"",{validator:f}=p,V=f.parseCellValue(g),M=q.getFontStyleString(a!=null?a:void 0);return ot(V,M,c,C).cellAutoHeight}calcCellAutoWidth(e){var x;const{primaryWithCoord:t,style:a,data:n}=e,o=n.fontRenderExtension,{leftOffset:r=0,rightOffset:s=0,topOffset:d=0,downOffset:l=0}=o||{},u=t.isMergedMainCell?t.mergeInfo:t,h={startX:u.startX+r,endX:u.endX-s,startY:u.startY+d,endY:u.endY-l},p=n.dataValidation;if(!p)return;const c=h.endX-h.startX,C=h.endY-h.startY,g=(x=F.getCellValueOrigin(n))!=null?x:"",{validator:f}=p,V=f.parseCellValue(g),M=q.getFontStyleString(a!=null?a:void 0);return ot(V,M,c,C).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:o}=n,{x:r}=e;return r>=o-_e&&r<=o}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:r}=e,s={unitId:a,subUnitId:n,row:o,column:r};this._commandService.executeCommand(Ge.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(q.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(q.CURSOR_TYPE.DEFAULT)}};pt=Ro([Mt(0,i.ICommandService),Mt(1,i.Inject(q.IRenderManagerService))],pt);class Mo extends pe{constructor(){super(...arguments);Y(this,"id",i.DataValidationType.LIST_MULTIPLE);Y(this,"canvasRender",this.injector.createInstance(pt));Y(this,"dropdown",Ze)}}var Eo=Object.defineProperty,bo=Object.getOwnPropertyDescriptor,Oo=(e,t,a,n)=>{for(var o=n>1?void 0:n?bo(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Eo(t,a,o),o},it=(e,t)=>(a,n)=>t(a,n,e);const Se=4,Ue=4,ce=14,ue=6,we=4,rt=8,To="#565656",Et=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 Po(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${i.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:i.BooleanNumber.FALSE,bl:i.BooleanNumber.FALSE,ul:{s:i.BooleanNumber.FALSE},st:{s:i.BooleanNumber.FALSE},ol:{s:i.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function nn(e,t,a){const n=Po(e,a),o=new i.DocumentDataModel(n),r=new q.DocumentViewModel(o);return{documentSkeleton:q.DocumentSkeleton.create(r,t),docModel:o,docViewModel:r}}function Ne(e,t,a){const{documentSkeleton:n,docModel:o,docViewModel:r}=nn(e,t,a);return{documents:new q.Documents(`DOCUMENTS_${i.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:o,docViewModel:r}}function bt(e,t,a,n,o,r,s=!0){let d=0;const l=s?we:0;switch(o){case i.VerticalAlign.BOTTOM:d=t-n-l;break;case i.VerticalAlign.MIDDLE:d=(t-n)/2;break;default:d=l;break}d=Math.max(we,d);let u=0;switch(r){case i.HorizontalAlign.CENTER:u=(e-a)/2;break;case i.HorizontalAlign.RIGHT:u=e-a;break}return u=Math.max(ue,u),{paddingLeft:u,paddingTop:d}}let ft=class{constructor(e,t,a){Y(this,"_dropdownInfoMap",new Map);Y(this,"zIndex");this._localeService=e,this._commandService=t,this._renderManagerService=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,o,r,s){const{t:d=i.DEFAULT_STYLES.pd.t,b:l=i.DEFAULT_STYLES.pd.b}=s,u=a-ce;let h;switch(r){case i.VerticalAlign.MIDDLE:h=(n-Ue)/2;break;case i.VerticalAlign.BOTTOM:h=n-l-o-we+(o/2-Ue/2);break;default:h=d+we+(o/2-Ue/2);break}e.save(),e.translateWithPrecision(t.startX+u,t.startY+h),e.fillStyle="#565656",e.fill(Et),e.restore()}drawWith(e,t,a){var D,S;const{primaryWithCoord:n,row:o,col:r,style:s,data:d,subUnitId:l}=t,u=n.isMergedMainCell?n.mergeInfo:n,h=(D=d.dataValidation)==null?void 0:D.rule,p=(S=d.dataValidation)==null?void 0:S.validator,c=d.fontRenderExtension,{leftOffset:C=0,rightOffset:g=0,topOffset:f=0,downOffset:w=0}=c||{};if(!h||!p||!p||p.id.indexOf(i.DataValidationType.LIST)!==0||!p.skipDefaultFontRender(h))return;const V={startX:u.startX+C,endX:u.endX-g,startY:u.startY+f,endY:u.endY-w},M=V.endX-V.startX,I=V.endY-V.startY,x=this._ensureMap(l),T=this._generateKey(o,r),P=p.getListWithColor(h),R=F.getCellValueOrigin(d),L=`${R!=null?R:""}`,k=P.find(v=>v.label===L);let{tb:U,vt:E,ht:W,pd:X}=s||{};if(U=U!=null?U:i.WrapStrategy.WRAP,E=E!=null?E:i.VerticalAlign.BOTTOM,W=W!=null?W:i.DEFAULT_STYLES.ht,X=X!=null?X:i.DEFAULT_STYLES.pd,h.renderMode===i.DataValidationRenderMode.ARROW){const{l:v=i.DEFAULT_STYLES.pd.l,t:y=i.DEFAULT_STYLES.pd.t,r:_=i.DEFAULT_STYLES.pd.r,b:A=i.DEFAULT_STYLES.pd.b}=X,b=M-v-_-ce-4,{documentSkeleton:H,documents:G,docModel:J}=Ne(L,this._localeService,s);U===i.WrapStrategy.WRAP&&J.updateDocumentDataPageSize(Math.max(b,1)),H.calculate(),H.getActualSize();const te=q.getDocsSkeletonPageSize(H),{height:ne,width:ae}=te,{paddingTop:$,paddingLeft:O}=bt(b,I-y-A,ae,ne,E,W,!0);this._drawDownIcon(e,V,M,I,ne,E,X),e.save(),e.translateWithPrecision(V.startX+v,V.startY+y),e.beginPath(),e.rect(0,0,M-v-_,I-y-A),e.clip(),e.translateWithPrecision(0,$),e.save(),e.translateWithPrecision(Se,0),e.beginPath(),e.rect(0,0,b,ne),e.clip(),G.render(e),e.translateWithPrecision(O,0),e.restore(),e.restore(),x.set(T,{left:V.endX+v+a.rowHeaderWidth-ce,top:V.startY+y+a.columnHeaderHeight,width:ce,height:I-y-A})}else{e.save(),e.translateWithPrecision(V.startX,V.startY),e.beginPath(),e.rect(0,0,M,I),e.clip();const v=M-ue*2-Se-ce-4,{documentSkeleton:y,documents:_,docModel:A}=Ne(L,this._localeService,s);U===i.WrapStrategy.WRAP&&A.updateDocumentDataPageSize(Math.max(v,1)),y.calculate();const b=q.getDocsSkeletonPageSize(y),{height:H,width:G}=b,{paddingTop:J,paddingLeft:te}=bt(v,I,G,H,E,W);e.translateWithPrecision(ue,J);const ne=Math.max(M-ue*2,1),ae=H;q.Rect.drawWith(e,{width:ne,height:ae,fill:(k==null?void 0:k.color)||Ie,radius:rt}),e.save(),e.translateWithPrecision(Se,0),e.beginPath(),e.rect(0,0,v,H),e.clip(),e.translateWithPrecision(te,0),_.render(e),e.restore(),e.translateWithPrecision(v+Se+4,(H-Ue)/2),e.fillStyle=To,e.fill(Et),e.restore(),x.set(T,{left:V.startX+ue+a.rowHeaderWidth,top:V.startY+J+a.columnHeaderHeight,width:ne,height:ae})}}calcCellAutoHeight(e){var I;const{primaryWithCoord:t,style:a,data:n}=e,o=t.isMergedMainCell?t.mergeInfo:t,r=n.fontRenderExtension,{leftOffset:s=0,rightOffset:d=0,topOffset:l=0,downOffset:u=0}=r||{},h=(I=n.dataValidation)==null?void 0:I.rule;if(!h||h.renderMode===i.DataValidationRenderMode.TEXT)return;const p={startX:o.startX+s,endX:o.endX-d,startY:o.startY+l,endY:o.endY-u},c=p.endX-p.startX,C=F.getCellValueOrigin(n),g=`${C!=null?C:""}`;let{tb:f,pd:w}=a||{};const{t:V=i.DEFAULT_STYLES.pd.t,b:M=i.DEFAULT_STYLES.pd.b}=w!=null?w:{};if(f=f!=null?f:i.WrapStrategy.WRAP,h.renderMode===i.DataValidationRenderMode.ARROW){const x=c-ce,{documentSkeleton:T,docModel:P}=Ne(g,this._localeService,a);f===i.WrapStrategy.WRAP&&P.updateDocumentDataPageSize(Math.max(x,1)),T.calculate(),T.getActualSize();const R=q.getDocsSkeletonPageSize(T),{height:L}=R;return L+V+M+we*2}else{const x=c-ue*2-Se-ce,{documentSkeleton:T,docModel:P}=nn(g,this._localeService,a);f===i.WrapStrategy.WRAP&&P.updateDocumentDataPageSize(Math.max(x,1)),T.calculate();const R=q.getDocsSkeletonPageSize(T),{height:L}=R;return L+we*2}}calcCellAutoWidth(e){var L;const{primaryWithCoord:t,style:a,data:n}=e,o=t.isMergedMainCell?t.mergeInfo:t,r=n.fontRenderExtension,{leftOffset:s=0,rightOffset:d=0,topOffset:l=0,downOffset:u=0}=r||{},h=(L=n.dataValidation)==null?void 0:L.rule;if(!h||h.renderMode===i.DataValidationRenderMode.TEXT)return;const p={startX:o.startX+s,endX:o.endX-d,startY:o.startY+l,endY:o.endY-u},c=p.endX-p.startX,C=F.getCellValueOrigin(n),g=`${C!=null?C:""}`;let{tb:f,pd:w}=a||{};const{l:V=i.DEFAULT_STYLES.pd.l,r:M=i.DEFAULT_STYLES.pd.r}=w!=null?w:{};f=f!=null?f:i.WrapStrategy.WRAP;let I=ue*2+ce;switch(h.renderMode){case i.DataValidationRenderMode.ARROW:I=ce+ue*2+M+V;break;case i.DataValidationRenderMode.CUSTOM:I=ce+ue*2+Se*2+M+V+rt/2+1;break;default:I=ce+ue*2+Se*2+M+V+rt/2+1}const x=c-I,{documentSkeleton:T,docModel:P}=Ne(g,this._localeService,a);return f===i.WrapStrategy.WRAP&&P.updateDocumentDataPageSize(Math.max(x,1)),T.calculate(),T.getActualSize(),q.getDocsSkeletonPageSize(T).width+I}isHit(e,t){const{data:a,subUnitId:n,row:o,col:r}=t,d=this._ensureMap(n).get(this._generateKey(o,r)),l=a.dataValidation;if(!l||!d||l.rule.renderMode===i.DataValidationRenderMode.TEXT)return!1;const{top:u,left:h,width:p,height:c}=d,{x:C,y:g}=e;return C>=h&&C<=h+p&&g>=u&&g<=u+c}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:r}=e,s={unitId:a,subUnitId:n,row:o,column:r};this._commandService.executeCommand(Ge.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(q.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(q.CURSOR_TYPE.DEFAULT)}};ft=Oo([it(0,i.Inject(i.LocaleService)),it(1,i.ICommandService),it(2,i.Inject(q.IRenderManagerService))],ft);class Lo extends pe{constructor(){super(...arguments);Y(this,"id",i.DataValidationType.LIST);Y(this,"canvasRender",this.injector.createInstance(ft));Y(this,"dropdown",Ze);Y(this,"optionsInput",Ye.componentKey);Y(this,"formulaInput",Ct)}}class jo extends pe{constructor(){super(...arguments);Y(this,"id",i.DataValidationType.TEXT_LENGTH);Y(this,"formulaInput",Je)}}class Ao extends pe{constructor(){super(...arguments);Y(this,"id",i.DataValidationType.WHOLE);Y(this,"formulaInput",Je)}}var $o=Object.defineProperty,xo=Object.getOwnPropertyDescriptor,Fo=(e,t,a,n)=>{for(var o=n>1?void 0:n?xo(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&$o(t,a,o),o},st=(e,t)=>(a,n)=>t(a,n,e);let be=class extends i.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[zt,Ft],[vt,_a],[Wt,Fn],[Ze,Jn],[It,yn],[Ye.componentKey,Ye],[Xe.componentKey,Xe],...ao].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[So,Ao,jo,vo,fo,Lo,Mo,mo].forEach(e=>{const t=this._injector.createInstance(e),a=this._dataValidatorRegistryService.getValidatorItem(t.id);a&&(a.formulaInput=t.formulaInput,a.canvasRender=t.canvasRender,a.dropdown=t.dropdown,a.optionsInput=t.optionsInput)})}};be=Fo([st(0,i.Inject(i.Injector)),st(1,i.Inject(ee.ComponentManager)),st(2,i.Inject(ie.DataValidatorRegistryService))],be);var Uo=Object.defineProperty,No=Object.getOwnPropertyDescriptor,ko=(e,t,a,n)=>{for(var o=n>1?void 0:n?No(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Uo(t,a,o),o},lt=(e,t)=>(a,n)=>t(a,n,e);const Bo="SHEET_DATA_VALIDATION_UI_PLUGIN";var ke;exports.UniverSheetsDataValidationUIPlugin=(ke=class extends i.Plugin{constructor(t=Xt,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(_t,s)}onStarting(){[[he],[me],[Le],[Re],[Ee],[Me],[Ve],[Pe],[be]].forEach(t=>{this._injector.add(t)}),[qe,Ge,Yt,St,Ce,Ht].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ve),this._injector.get(Me),this._injector.get(Pe),this._injector.get(Le),this._injector.get(q.IRenderManagerService).registerRenderModule(i.UniverInstanceType.UNIVER_SHEET,[He])}onRendered(){this._injector.get(be),this._injector.get(Ee)}onSteady(){this._injector.get(Re)}},Y(ke,"pluginName",Bo),Y(ke,"type",i.UniverInstanceType.UNIVER_SHEET),ke);exports.UniverSheetsDataValidationUIPlugin=ko([lt(1,i.Inject(i.Injector)),lt(2,i.ICommandService),lt(3,i.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);var Wo=Object.defineProperty,Ho=Object.getOwnPropertyDescriptor,Yo=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ho(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Wo(t,a,o),o},dt=(e,t)=>(a,n)=>t(a,n,e);const Xo="SHEET_DATA_VALIDATION_UI_PLUGIN";var Be;exports.UniverSheetsDataValidationMobileUIPlugin=(Be=class extends i.Plugin{constructor(t=Xt,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(_t,s)}onStarting(){[[he],[me],[Le],[Re],[Ee],[Me],[Ve],[be]].forEach(t=>{this._injector.add(t)}),[qe,Ge,Yt,St,Ce,Ht].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ve),this._injector.get(Me),this._injector.get(q.IRenderManagerService).registerRenderModule(i.UniverInstanceType.UNIVER_SHEET,[He])}onRendered(){this._injector.get(be),this._injector.get(Ee)}onSteady(){this._injector.get(Re)}},Y(Be,"pluginName",Xo),Y(Be,"type",i.UniverInstanceType.UNIVER_SHEET),Be);exports.UniverSheetsDataValidationMobileUIPlugin=Yo([dt(1,i.Inject(i.Injector)),dt(2,i.ICommandService),dt(3,i.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);exports.DATE_DROPDOWN_KEY=It;exports.LIST_DROPDOWN_KEY=Ze;
|
9
|
+
*/var ln=j,dn=Symbol.for("react.element"),cn=Symbol.for("react.fragment"),un=Object.prototype.hasOwnProperty,hn=ln.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,pn={key:!0,ref:!0,__self:!0,__source:!0};function Lt(e,t,a){var n,o={},r=null,s=null;a!==void 0&&(r=""+a),t.key!==void 0&&(r=""+t.key),t.ref!==void 0&&(s=t.ref);for(n in t)un.call(t,n)&&!pn.hasOwnProperty(n)&&(o[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)o[n]===void 0&&(o[n]=t[n]);return{$$typeof:dn,type:e,key:r,ref:s,props:o,_owner:hn.current}}Ke.Fragment=cn;Ke.jsx=Lt;Ke.jsxs=Lt;Pt.exports=Ke;var m=Pt.exports,jt={exports:{}};(function(e,t){(function(a,n){e.exports=n()})(Ot,function(){var a=1e3,n=6e4,o=36e5,r="millisecond",s="second",d="minute",l="hour",u="day",h="week",p="month",c="quarter",C="year",g="date",f="Invalid Date",w=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,V=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(D){var S=["th","st","nd","rd"],v=D%100;return"["+D+(S[(v-20)%10]||S[v]||S[0])+"]"}},I=function(D,S,v){var y=String(D);return!y||y.length>=S?D:""+Array(S+1-y.length).join(v)+D},x={s:I,z:function(D){var S=-D.utcOffset(),v=Math.abs(S),y=Math.floor(v/60),_=v%60;return(S<=0?"+":"-")+I(y,2,"0")+":"+I(_,2,"0")},m:function D(S,v){if(S.date()<v.date())return-D(v,S);var y=12*(v.year()-S.year())+(v.month()-S.month()),_=S.clone().add(y,p),A=v-_<0,b=S.clone().add(y+(A?-1:1),p);return+(-(y+(v-_)/(A?_-b:b-_))||0)},a:function(D){return D<0?Math.ceil(D)||0:Math.floor(D)},p:function(D){return{M:p,y:C,w:h,d:u,D:g,h:l,m:d,s,ms:r,Q:c}[D]||String(D||"").toLowerCase().replace(/s$/,"")},u:function(D){return D===void 0}},T="en",P={};P[T]=M;var R="$isDayjsObject",L=function(D){return D instanceof W||!(!D||!D[R])},k=function D(S,v,y){var _;if(!S)return T;if(typeof S=="string"){var A=S.toLowerCase();P[A]&&(_=A),v&&(P[A]=v,_=A);var b=S.split("-");if(!_&&b.length>1)return D(b[0])}else{var H=S.name;P[H]=S,_=H}return!y&&_&&(T=_),_||!y&&T},U=function(D,S){if(L(D))return D.clone();var v=typeof S=="object"?S:{};return v.date=D,v.args=arguments,new W(v)},E=x;E.l=k,E.i=L,E.w=function(D,S){return U(D,{locale:S.$L,utc:S.$u,x:S.$x,$offset:S.$offset})};var W=function(){function D(v){this.$L=k(v.locale,null,!0),this.parse(v),this.$x=this.$x||v.x||{},this[R]=!0}var S=D.prototype;return S.parse=function(v){this.$d=function(y){var _=y.date,A=y.utc;if(_===null)return new Date(NaN);if(E.u(_))return new Date;if(_ instanceof Date)return new Date(_);if(typeof _=="string"&&!/Z$/i.test(_)){var b=_.match(w);if(b){var H=b[2]-1||0,G=(b[7]||"0").substring(0,3);return A?new Date(Date.UTC(b[1],H,b[3]||1,b[4]||0,b[5]||0,b[6]||0,G)):new Date(b[1],H,b[3]||1,b[4]||0,b[5]||0,b[6]||0,G)}}return new Date(_)}(v),this.init()},S.init=function(){var v=this.$d;this.$y=v.getFullYear(),this.$M=v.getMonth(),this.$D=v.getDate(),this.$W=v.getDay(),this.$H=v.getHours(),this.$m=v.getMinutes(),this.$s=v.getSeconds(),this.$ms=v.getMilliseconds()},S.$utils=function(){return E},S.isValid=function(){return this.$d.toString()!==f},S.isSame=function(v,y){var _=U(v);return this.startOf(y)<=_&&_<=this.endOf(y)},S.isAfter=function(v,y){return U(v)<this.startOf(y)},S.isBefore=function(v,y){return this.endOf(y)<U(v)},S.$g=function(v,y,_){return E.u(v)?this[y]:this.set(_,v)},S.unix=function(){return Math.floor(this.valueOf()/1e3)},S.valueOf=function(){return this.$d.getTime()},S.startOf=function(v,y){var _=this,A=!!E.u(y)||y,b=E.p(v),H=function(z,B){var Z=E.w(_.$u?Date.UTC(_.$y,B,z):new Date(_.$y,B,z),_);return A?Z:Z.endOf(u)},G=function(z,B){return E.w(_.toDate()[z].apply(_.toDate("s"),(A?[0,0,0,0]:[23,59,59,999]).slice(B)),_)},J=this.$W,te=this.$M,ne=this.$D,ae="set"+(this.$u?"UTC":"");switch(b){case C:return A?H(1,0):H(31,11);case p:return A?H(1,te):H(0,te+1);case h:var $=this.$locale().weekStart||0,O=(J<$?J+7:J)-$;return H(A?ne-O:ne+(6-O),te);case u:case g:return G(ae+"Hours",0);case l:return G(ae+"Minutes",1);case d:return G(ae+"Seconds",2);case s:return G(ae+"Milliseconds",3);default:return this.clone()}},S.endOf=function(v){return this.startOf(v,!1)},S.$set=function(v,y){var _,A=E.p(v),b="set"+(this.$u?"UTC":""),H=(_={},_[u]=b+"Date",_[g]=b+"Date",_[p]=b+"Month",_[C]=b+"FullYear",_[l]=b+"Hours",_[d]=b+"Minutes",_[s]=b+"Seconds",_[r]=b+"Milliseconds",_)[A],G=A===u?this.$D+(y-this.$W):y;if(A===p||A===C){var J=this.clone().set(g,1);J.$d[H](G),J.init(),this.$d=J.set(g,Math.min(this.$D,J.daysInMonth())).$d}else H&&this.$d[H](G);return this.init(),this},S.set=function(v,y){return this.clone().$set(v,y)},S.get=function(v){return this[E.p(v)]()},S.add=function(v,y){var _,A=this;v=Number(v);var b=E.p(y),H=function(te){var ne=U(A);return E.w(ne.date(ne.date()+Math.round(te*v)),A)};if(b===p)return this.set(p,this.$M+v);if(b===C)return this.set(C,this.$y+v);if(b===u)return H(1);if(b===h)return H(7);var G=(_={},_[d]=n,_[l]=o,_[s]=a,_)[b]||1,J=this.$d.getTime()+v*G;return E.w(J,this)},S.subtract=function(v,y){return this.add(-1*v,y)},S.format=function(v){var y=this,_=this.$locale();if(!this.isValid())return _.invalidDate||f;var A=v||"YYYY-MM-DDTHH:mm:ssZ",b=E.z(this),H=this.$H,G=this.$m,J=this.$M,te=_.weekdays,ne=_.months,ae=_.meridiem,$=function(B,Z,re,De){return B&&(B[Z]||B(y,A))||re[Z].slice(0,De)},O=function(B){return E.s(H%12||12,B,"0")},z=ae||function(B,Z,re){var De=B<12?"AM":"PM";return re?De.toLowerCase():De};return A.replace(V,function(B,Z){return Z||function(re){switch(re){case"YY":return String(y.$y).slice(-2);case"YYYY":return E.s(y.$y,4,"0");case"M":return J+1;case"MM":return E.s(J+1,2,"0");case"MMM":return $(_.monthsShort,J,ne,3);case"MMMM":return $(ne,J);case"D":return y.$D;case"DD":return E.s(y.$D,2,"0");case"d":return String(y.$W);case"dd":return $(_.weekdaysMin,y.$W,te,2);case"ddd":return $(_.weekdaysShort,y.$W,te,3);case"dddd":return te[y.$W];case"H":return String(H);case"HH":return E.s(H,2,"0");case"h":return O(1);case"hh":return O(2);case"a":return z(H,G,!0);case"A":return z(H,G,!1);case"m":return String(G);case"mm":return E.s(G,2,"0");case"s":return String(y.$s);case"ss":return E.s(y.$s,2,"0");case"SSS":return E.s(y.$ms,3,"0");case"Z":return b}return null}(B)||b.replace(":","")})},S.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},S.diff=function(v,y,_){var A,b=this,H=E.p(y),G=U(v),J=(G.utcOffset()-this.utcOffset())*n,te=this-G,ne=function(){return E.m(b,G)};switch(H){case C:A=ne()/12;break;case p:A=ne();break;case c:A=ne()/3;break;case h:A=(te-J)/6048e5;break;case u:A=(te-J)/864e5;break;case l:A=te/o;break;case d:A=te/n;break;case s:A=te/a;break;default:A=te}return _?A:E.a(A)},S.daysInMonth=function(){return this.endOf(p).$D},S.$locale=function(){return P[this.$L]},S.locale=function(v,y){if(!v)return this.$L;var _=this.clone(),A=k(v,y,!0);return A&&(_.$L=A),_},S.clone=function(){return E.w(this.$d,this)},S.toDate=function(){return new Date(this.valueOf())},S.toJSON=function(){return this.isValid()?this.toISOString():null},S.toISOString=function(){return this.$d.toISOString()},S.toString=function(){return this.$d.toUTCString()},D}(),X=W.prototype;return U.prototype=X,[["$ms",r],["$s",s],["$m",d],["$H",l],["$W",u],["$M",p],["$y",C],["$D",g]].forEach(function(D){X[D[1]]=function(S){return this.$g(S,D[0],D[1])}}),U.extend=function(D,S){return D.$i||(D(S,W,U),D.$i=!0),U},U.locale=k,U.isDayjs=L,U.unix=function(D){return U(1e3*D)},U.en=P[T],U.Ls=P,U.p={},U})})(jt);var fn=jt.exports;const We=Tt(fn);var At={exports:{}};(function(e,t){(function(a,n){e.exports=n()})(Ot,function(){var a="minute",n=/[+-]\d\d(?::?\d\d)?/g,o=/([+-]|\d\d)/g;return function(r,s,d){var l=s.prototype;d.utc=function(f){var w={date:f,utc:!0,args:arguments};return new s(w)},l.utc=function(f){var w=d(this.toDate(),{locale:this.$L,utc:!0});return f?w.add(this.utcOffset(),a):w},l.local=function(){return d(this.toDate(),{locale:this.$L,utc:!1})};var u=l.parse;l.parse=function(f){f.utc&&(this.$u=!0),this.$utils().u(f.$offset)||(this.$offset=f.$offset),u.call(this,f)};var h=l.init;l.init=function(){if(this.$u){var f=this.$d;this.$y=f.getUTCFullYear(),this.$M=f.getUTCMonth(),this.$D=f.getUTCDate(),this.$W=f.getUTCDay(),this.$H=f.getUTCHours(),this.$m=f.getUTCMinutes(),this.$s=f.getUTCSeconds(),this.$ms=f.getUTCMilliseconds()}else h.call(this)};var p=l.utcOffset;l.utcOffset=function(f,w){var V=this.$utils().u;if(V(f))return this.$u?0:V(this.$offset)?p.call(this):this.$offset;if(typeof f=="string"&&(f=function(T){T===void 0&&(T="");var P=T.match(n);if(!P)return null;var R=(""+P[0]).match(o)||["-",0,0],L=R[0],k=60*+R[1]+ +R[2];return k===0?0:L==="+"?k:-k}(f),f===null))return this;var M=Math.abs(f)<=16?60*f:f,I=this;if(w)return I.$offset=M,I.$u=f===0,I;if(f!==0){var x=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(I=this.local().add(M+x,a)).$offset=M,I.$x.$localOffset=x}else I=this.utc();return I};var c=l.format;l.format=function(f){var w=f||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return c.call(this,w)},l.valueOf=function(){var f=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*f},l.isUTC=function(){return!!this.$u},l.toISOString=function(){return this.toDate().toISOString()},l.toString=function(){return this.toDate().toUTCString()};var C=l.toDate;l.toDate=function(f){return f==="s"&&this.$offset?d(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():C.call(this)};var g=l.diff;l.diff=function(f,w,V){if(f&&this.$u===f.$u)return g.call(this,f,w,V);var M=this.local(),I=d(f).local();return g.call(M,I,w,V)}}})})(At);var mn=At.exports;const gn=Tt(mn);var vn=Object.defineProperty,Sn=Object.getOwnPropertyDescriptor,_n=(e,t,a,n)=>{for(var o=n>1?void 0:n?Sn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&vn(t,a,o),o},Oe=(e,t)=>(a,n)=>t(a,n,e);let Pe=class extends i.Disposable{constructor(e,t,a,n,o){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=o,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(Q.AFTER_CELL_EDIT_ASYNC,{handler:async(e,t,a)=>{var f;const n=await e,{worksheet:o,row:r,col:s,unitId:d,subUnitId:l,workbook:u}=t,h=this._dataValidationModel.getRuleIdByLocation(d,l,r,s),p=h?this._dataValidationModel.getRuleById(d,l,h):void 0;if(!p||p.errorStyle!==i.DataValidationErrorStyle.STOP)return a(Promise.resolve(n));const c=await this._dataValidatorRegistryService.getValidatorItem(p.type);if(!c||await c.validator({value:F.getCellValueOrigin(n),interceptValue:F.getCellValueOrigin((f=t==null?void 0:t.origin)!=null?f:n),row:r,column:s,unitId:d,subUnitId:l,worksheet:o,workbook:u,t:n==null?void 0:n.t},p))return a(Promise.resolve(n));const g=o.getCellRaw(r,s);return this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:c.getRuleFinalError(p,{row:r,col:s,unitId:d,subUnitId:l})},footer:{title:j.createElement(N.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(Promise.resolve(g))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:j.createElement(N.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Pe=_n([Oe(0,i.Inject(Q.SheetInterceptorService)),Oe(1,i.Inject(F.SheetDataValidationModel)),Oe(2,i.Inject(ie.DataValidatorRegistryService)),Oe(3,ee.IDialogService),Oe(4,i.Inject(i.LocaleService))],Pe);const In="univer-dv-date-dropdown",Cn="univer-dv-date-dropdown-btns",Dt={dvDateDropdown:In,dvDateDropdownBtns:Cn};We.extend(gn);const Dn=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return We(i.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=We(e);if(t.isValid())return t};function yn(e){var P,R,L;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:r,unitId:s,subUnitId:d,workbook:l}=t,u=i.useDependency(i.ICommandService),h=i.useDependency(Pe),p=n.getCell(o,r),c=(P=p==null?void 0:p.dataValidation)==null?void 0:P.rule,C=(R=p==null?void 0:p.dataValidation)==null?void 0:R.validator,g=F.getCellValueOrigin(n.getCellRaw(o,r)),f=Dn(g),[w,V]=j.useState(f),M=!!((L=c==null?void 0:c.bizInfo)!=null&&L.showTime),I=w&&w.isValid()?w:We(),x=i.useDependency(i.LocaleService);if(!p||!c||!C)return;const T=async()=>{var S,v,y;if(!I)return;const U=I.format(M?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),E=(S=i.numfmt.parseDate(U))==null?void 0:S.v,W=l.getStyles().getStyleByCell(p),X=(y=(v=W==null?void 0:W.n)==null?void 0:v.pattern)!=null?y:"",D=rn.getPatternType(X);c.errorStyle!==i.DataValidationErrorStyle.STOP||await C.validator({value:E,unitId:s,subUnitId:d,row:o,column:r,worksheet:n,workbook:l,interceptValue:U.replace("Z","").replace("T"," "),t:i.CellValueType.NUMBER},c)?(a(),await u.executeCommand(K.SetCellEditVisibleOperation.id,{visible:!1,eventType:q.DeviceInputEventType.Keyboard,unitId:s,keycode:ee.KeyCode.ESC}),await u.executeCommand(Q.SetRangeValuesCommand.id,{unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:o,endRow:o},value:{v:E,t:2,p:null,f:null,si:null,s:{n:{pattern:M?D==="datetime"?X:"yyyy-MM-dd hh:mm:ss":D==="date"?X:"yyyy-MM-dd"}}}})):h.showReject(C.getRuleFinalError(c,{row:o,col:r,unitId:s,subUnitId:d}))};return m.jsxs("div",{className:Dt.dvDateDropdown,children:[m.jsx(N.DatePanel,{defaultValue:I,pickerValue:I,showTime:M||void 0,onSelect:async k=>{V(k)},onPanelChange:k=>{V(k)},disabledDate:k=>!i.numfmt.parseDate(k.format("YYYY-MM-DD"))}),m.jsx("div",{className:Dt.dvDateDropdownBtns,children:m.jsx(N.Button,{size:"small",type:"primary",onClick:T,disabled:!I.isValid(),children:x.t("dataValidation.alert.ok")})})]})}var le=function(){return le=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},le.apply(this,arguments)},wn=function(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(a[n[o]]=e[n[o]]);return a},ge=j.forwardRef(function(e,t){var a=e.icon,n=e.id,o=e.className,r=e.extend,s=wn(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),l=j.useRef("_".concat(Mn()));return $t(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},le({ref:t,className:d},s),r)});function $t(e,t,a,n,o){return j.createElement(e.tag,le(le({key:t},Rn(e,a,o)),n),(Vn(e,a).children||[]).map(function(r,s){return $t(r,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,o)}))}function Rn(e,t,a){var n=le({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1);var o=t.defIds;return!o||o.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],d=r[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Vn(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?le(le({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?le(le({},o),{attrs:le(le({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):e}function Mn(){return Math.random().toString(36).substring(2,8)}ge.displayName="UniverIcon";var En={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},xt=j.forwardRef(function(e,t){return j.createElement(ge,Object.assign({},e,{id:"check-mark-single",ref:t,icon:En}))});xt.displayName="CheckMarkSingle";var bn={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"}}]},Ft=j.forwardRef(function(e,t){return j.createElement(ge,Object.assign({},e,{id:"data-validation-single",ref:t,icon:bn}))});Ft.displayName="DataValidationSingle";var On={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"}}]},gt=j.forwardRef(function(e,t){return j.createElement(ge,Object.assign({},e,{id:"delete-single",ref:t,icon:On}))});gt.displayName="DeleteSingle";var Tn={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"}}]},Ut=j.forwardRef(function(e,t){return j.createElement(ge,Object.assign({},e,{id:"increase-single",ref:t,icon:Tn}))});Ut.displayName="IncreaseSingle";var Pn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Nt=j.forwardRef(function(e,t){return j.createElement(ge,Object.assign({},e,{id:"more-down-single",ref:t,icon:Pn}))});Nt.displayName="MoreDownSingle";var Ln={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"}}]},kt=j.forwardRef(function(e,t){return j.createElement(ge,Object.assign({},e,{id:"more-up-single",ref:t,icon:Ln}))});kt.displayName="MoreUpSingle";var jn={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"}}]}]},Bt=j.forwardRef(function(e,t){return j.createElement(ge,Object.assign({},e,{id:"sequence-single",ref:t,icon:jn}))});Bt.displayName="SequenceSingle";var An=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,xn=(e,t,a,n)=>{for(var o=n>1?void 0:n?$n(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&An(t,a,o),o},yt=(e,t)=>(a,n)=>t(a,n,e);let he=class extends i.Disposable{constructor(t,a){super();Y(this,"_open$",new de.BehaviorSubject(!1));Y(this,"open$",this._open$.pipe(de.distinctUntilChanged()));Y(this,"_activeRule");Y(this,"_activeRule$",new de.BehaviorSubject(void 0));Y(this,"activeRule$",this._activeRule$.asObservable());Y(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).pipe(de.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===vt&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=i.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};he=xn([yt(0,i.IUniverInstanceService),yt(1,ee.ISidebarService)],he);function Fn(){const e=i.useDependency(me),t=ee.useObservable(e.activeDropdown$,e.activeDropdown),a=i.useDependency(ee.ComponentManager);if(!t)return null;const{location:n,componentKey:o}=t,r=a.get(o),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!r)return null;const d=()=>{e.hideDropdown()};return m.jsx(r,{location:n,hideFn:d},s)}const Wt="sheet.ui.dropdown";var Un=Object.defineProperty,Nn=Object.getOwnPropertyDescriptor,kn=(e,t,a,n)=>{for(var o=n>1?void 0:n?Nn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Un(t,a,o),o},ve=(e,t)=>(a,n)=>t(a,n,e);let me=class extends i.Disposable{constructor(t,a,n,o,r,s,d){super();Y(this,"_activeDropdown");Y(this,"_activeDropdown$",new de.Subject);Y(this,"_currentPopup",null);Y(this,"activeDropdown$",this._activeDropdown$.asObservable());Y(this,"_zenVisible",!1);this._canvasPopupManagerService=t,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=o,this._renderManagerService=r,this._dataValidationModel=s,this._sheetsSelectionsService=d,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,a,n,o){const r=t?this._univerInstanceService.getUnit(t,i.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!r)return;const s=a?r.getSheetBySheetId(a):r.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(r.getUnitId(),s.getSheetId(),n,o);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdown}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t,a=!0){const{location:n}=t,{row:o,col:r,unitId:s,subUnitId:d}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const l=this._renderManagerService.getRenderById(i.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),u=this._canvasPopupManagerService.attachPopupToCell(o,r,{componentKey:Wt,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[l==null?void 0:l.engine.getCanvasElement()].filter(Boolean)},s,d);if(!u)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const h=new i.DisposableCollection;h.add(u),h.add({dispose:()=>{var p,c;(c=(p=this._activeDropdown)==null?void 0:p.onHide)==null||c.call(p)}}),this._currentPopup=h}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,a,n,o,r){const s=this._univerInstanceService.getUnit(t,i.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(a);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,o);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!u||!u.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:o,unitId:t,subUnitId:a},componentKey:u.dropdown,onHide:r})}};me=kn([ve(0,i.Inject(K.SheetCanvasPopManagerService)),ve(1,i.IUniverInstanceService),ve(2,i.Inject(ie.DataValidatorRegistryService)),ve(3,ee.IZenZoneService),ve(4,q.IRenderManagerService),ve(5,i.Inject(F.SheetDataValidationModel)),ve(6,i.Inject(Q.SheetsSelectionsService))],me);const vt="DataValidationPanel",Ce={id:"data-validation.operation.open-validation-panel",type:i.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,o=e.get(he),r=e.get(ie.DataValidationModel),s=e.get(i.IUniverInstanceService),d=e.get(ee.ISidebarService),l=Q.getSheetCommandTarget(s);if(!l)return!1;const{unitId:u,subUnitId:h}=l,p=a?r.getRuleById(u,h,a):void 0;o.open(),o.setActiveRule(p&&{unitId:u,subUnitId:h,rule:p});const c=d.open({header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:vt},width:312,onClose:()=>o.close()});return o.setCloseDisposable(c),!0}},St={id:"data-validation.operation.close-validation-panel",type:i.CommandType.OPERATION,handler(e){return e.get(he).close(),!0}},Ht={id:"data-validation.operation.toggle-validation-panel",type:i.CommandType.OPERATION,handler(e){const t=e.get(i.ICommandService),a=e.get(he);return a.open(),a.isOpen?t.executeCommand(St.id):t.executeCommand(Ce.id),!0}},Ge={type:i.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(me),{unitId:n,subUnitId:o,row:r,column:s}=t,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===o&&l.row===r&&l.col===s||a.showDataValidationDropdown(n,o,r,s),!0}},Yt={type:i.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(me).hideDropdown(),!0):!1}},Ie="#ECECEC",_t="sheets-data-validation-ui.config",Xt={},Bn="univer-dv-list-dropdown",Wn="univer-dv-list-dropdown-title",Hn="univer-dv-list-dropdown-list",Yn="univer-dv-list-dropdown-list-container",Xn="univer-dv-list-dropdown-selected-icon",zn="univer-dv-list-dropdown-item-container",Kn="univer-dv-list-dropdown-item",Gn="univer-dv-list-dropdown-split",Zn="univer-dv-list-dropdown-edit",fe={dvListDropdown:Bn,dvListDropdownTitle:Wn,dvListDropdownList:Hn,dvListDropdownListContainer:Yn,dvListDropdownSelectedIcon:Xn,dvListDropdownItemContainer:zn,dvListDropdownItem:Kn,dvListDropdownSplit:Gn,dvListDropdownEdit:Zn},qn=e=>{var T,P;const{value:t,onChange:a,multiple:n,options:o,title:r,onEdit:s,style:d,filter:l,location:u}=e,h=i.useDependency(i.LocaleService),p=i.useDependency(i.IConfigService),c=l==null?void 0:l.toLowerCase(),{row:C,col:g,unitId:f,subUnitId:w}=u,V=o.filter(R=>c?R.label.toLowerCase().includes(c):!0),M=(P=(T=p.getConfig(_t))==null?void 0:T.showEditOnDropdown)!=null?P:!0,I=i.useDependency(K.SheetPermissionInterceptorBaseController),x=j.useMemo(()=>I.permissionCheckWithRanges({workbookTypes:[Q.WorkbookEditablePermission],rangeTypes:[Q.RangeProtectionPermissionEditPoint],worksheetTypes:[Q.WorksheetEditPermission]},[{startColumn:g,startRow:C,endColumn:g,endRow:C}],f,w),[I,g,C,f,w]);return m.jsxs("div",{className:fe.dvListDropdown,style:d,children:[m.jsx("div",{className:fe.dvListDropdownTitle,children:r}),m.jsx("div",{className:fe.dvListDropdownList,children:m.jsx(N.Scrollbar,{children:m.jsx("div",{className:fe.dvListDropdownListContainer,children:V.map((R,L)=>{const k=t.indexOf(R.value)>-1,U=()=>{let W;k?W=new Set(t.filter(D=>D!==R.value)):W=new Set(n?[...t,R.value]:[R.value]);const X=[];o.forEach(D=>{W.has(D.value)&&X.push(D.value)}),a(X)},E=R.label.toLocaleLowerCase().indexOf(c);return m.jsxs("div",{className:fe.dvListDropdownItemContainer,onClick:U,children:[m.jsx("div",{className:fe.dvListDropdownItem,style:{background:R.color||Ie},children:c&&R.label.toLowerCase().includes(c)?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:R.label.substring(0,E)}),m.jsx("span",{style:{fontWeight:"bold"},children:R.label.substring(E,E+c.length)}),m.jsx("span",{children:R.label.substring(E+c.length)})]}):R.label}),m.jsx("div",{className:fe.dvListDropdownSelectedIcon,children:k?m.jsx(xt,{}):null})]},L)})})},l)}),M&&x?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:fe.dvListDropdownSplit}),m.jsx("div",{className:fe.dvListDropdownEdit,children:m.jsx("a",{onClick:s,children:h.t("dataValidation.list.edit")})})]}):null]})};function Jn(e){var D,S,v,y,_,A;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:r,unitId:s,subUnitId:d}=t,l=i.useDependency(ie.DataValidationModel),[u,h]=j.useState(""),p=i.useDependency(i.ICommandService),c=i.useDependency(i.LocaleService),[C,g]=j.useState(""),f=i.useDependency(K.IEditorBridgeService),w=i.useDependency(i.IUniverInstanceService),V=j.useMemo(()=>l.ruleChange$.pipe(de.debounceTime(16)),[]);ee.useObservable(V);const M=ee.RectPopup.useContext(),I=((S=(D=M.current)==null?void 0:D.right)!=null?S:0)-((y=(v=M.current)==null?void 0:v.left)!=null?y:0);if(j.useEffect(()=>{const b=p.onCommandExecuted(H=>{var G,J;if(H.id===sn.RichTextEditingMutation.id){const te=H.params,{unitId:ne}=te,ae=w.getUnit(ne,i.UniverInstanceType.UNIVER_DOC);if(!ae)return;const $=i.BuildTextUtils.transform.getPlainText((J=(G=ae.getSnapshot().body)==null?void 0:G.dataStream)!=null?J:"");h($)}});return()=>{b.dispose()}},[p,w]),!n)return null;const x=n.getCell(o,r),T=(_=x==null?void 0:x.dataValidation)==null?void 0:_.rule,P=(A=x==null?void 0:x.dataValidation)==null?void 0:A.validator,R=(T==null?void 0:T.renderMode)===i.DataValidationRenderMode.CUSTOM||(T==null?void 0:T.renderMode)===void 0;if(!x||!T||!P||P.id.indexOf(i.DataValidationType.LIST)!==0)return;const L=T.type===i.DataValidationType.LIST_MULTIPLE,k=P.getListWithColor(T,s,d),U=C||F.getDataValidationCellValue(n.getCellRaw(o,r)),E=F.deserializeListOptions(U),W=()=>{p.executeCommand(Ce.id,{ruleId:T.uid}),a()},X=k.map(b=>({label:b.label,value:b.label,color:R||b.color?b.color:"transparent"}));return m.jsx(qn,{style:{minWidth:I,maxWidth:Math.max(I,200)},title:L?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:E,multiple:L,onChange:async b=>{const H=F.serializeListOptions(b),G={unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:o,endRow:o},value:{v:H,p:null,f:null,si:null}};f.isVisible()&&f.changeVisible({visible:!1,keycode:ee.KeyCode.ESC,eventType:q.DeviceInputEventType.Keyboard,unitId:s}),g(H),L||a(),f.isVisible().visible&&await p.executeCommand(K.SetCellEditVisibleOperation.id,{visible:!1,eventType:q.DeviceInputEventType.Keyboard,unitId:s,keycode:ee.KeyCode.ESC}),p.executeCommand(Q.SetRangeValuesCommand.id,G)},options:X,onEdit:W,filter:u,location:t})}const Qn="univer-data-validation-options-button",ea="univer-data-validation-options-button-icon",Qe={dataValidationOptionsButton:Qn,dataValidationOptionsButtonIcon:ea};function ta(e){var u;const t=i.useDependency(i.LocaleService),a=i.useDependency(ee.ComponentManager),{value:n,onChange:o,extraComponent:r}=e,[s,d]=j.useState(!1),l=r?a.get(r):null;return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:Qe.dataValidationOptionsButton,onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?m.jsx(kt,{className:Qe.dataValidationOptionsButtonIcon}):m.jsx(Nt,{className:Qe.dataValidationOptionsButtonIcon})]}),s&&m.jsxs(m.Fragment,{children:[l?m.jsx(l,{value:n,onChange:o}):null,m.jsx(N.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:m.jsxs(N.RadioGroup,{value:`${(u=n.errorStyle)!=null?u:i.DataValidationErrorStyle.WARNING}`,onChange:h=>o({...n,errorStyle:+h}),children:[m.jsx(N.Radio,{value:`${i.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),m.jsx(N.Radio,{value:`${i.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),m.jsx(N.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:m.jsx(N.Checkbox,{checked:n.showErrorMessage,onChange:()=>o({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?m.jsx(N.FormLayout,{children:m.jsx(N.Input,{value:n.error,onChange:h=>o({...n,error:h})})}):null]})]})}const na="univer-data-validation-detail",aa="univer-data-validation-detail-form-item",oa="univer-data-validation-detail-buttons",ia="univer-data-validation-detail-button",ye={dataValidationDetail:na,dataValidationDetailFormItem:aa,dataValidationDetailButtons:oa,dataValidationDetailButton:ia},ra=e=>i.debounce(async(t,a,n,o)=>{const r=await e.executeCommand(t,a,n);o==null||o(r)},1e3);function sa(e,t,a){var n,o,r,s;return t?((o=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:o.getSheetId())||"":((s=(r=e.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function la(){var ae;const[e,t]=j.useState(0),a=i.useDependency(he),n=ee.useObservable(a.activeRule$,a.activeRule),{unitId:o,subUnitId:r,rule:s}=n||{},d=s.uid,l=i.useDependency(ie.DataValidatorRegistryService),u=i.useDependency(i.IUniverInstanceService),h=i.useDependency(ee.ComponentManager),p=i.useDependency(i.ICommandService),c=i.useDependency(ie.DataValidationModel),C=i.useDependency(i.LocaleService),[g,f]=j.useState(s),w=l.getValidatorItem(g.type),[V,M]=j.useState(!1),I=l.getValidatorsByScope(ie.DataValidatorRegistryScope.SHEET),[x,T]=j.useState(()=>g.ranges.map($=>({unitId:"",sheetId:"",range:$}))),P=j.useMemo(()=>ra(p),[p]),[R,L]=j.useState(!1),k=j.useRef({}),[U,E]=j.useState(!1),W=i.useDependency(Q.SheetsSelectionsService);if(j.useEffect(()=>()=>{const $=W.getCurrentLastSelection();$&&W.setSelections([$])},[W]),j.useEffect(()=>{p.onCommandExecuted($=>{($.id===i.UndoCommand.id||$.id===i.RedoCommand.id)&&setTimeout(()=>{const O=c.getRuleById(o,r,d);t(z=>z+1),O&&(f(O),T(O.ranges.map(z=>({unitId:"",sheetId:"",range:z}))))},20)})},[p,c,d,r,o]),!w)return null;const X=w.operators,D=w.operatorNames,S=g.operator?ie.TWO_FORMULA_OPERATOR_COUNT.includes(g.operator):!1,v=()=>{!g.ranges.length||R||(w.validatorFormula(g,o,r).success?a.setActiveRule(null):M(!0))},y=ee.useEvent($=>{const O=$.split(",").map(ct.deserializeRangeWithSheet).map(Z=>{const re=Z.sheetName;if(re){const De=sa(u,Z.unitId,re);return{...Z,sheetId:De}}return{...Z,sheetId:""}});if(i.isUnitRangesEqual(O,x))return;T(O);const z=O.filter(Z=>(!Z.unitId||Z.unitId===o)&&(!Z.sheetId||Z.sheetId===r)).map(Z=>Z.range);if(f({...g,ranges:z}),z.length===0)return;const B={unitId:o,subUnitId:r,ruleId:d,ranges:z};P(F.UpdateSheetDataValidationRangeCommand.id,B)}),_=$=>{if(i.shallowEqual($,ie.getRuleSetting(g)))return;f({...g,...$});const O={unitId:o,subUnitId:r,ruleId:d,setting:$};P(F.UpdateSheetDataValidationSettingCommand.id,O,void 0)},A=async()=>{await p.executeCommand(F.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:o,subUnitId:r}),a.setActiveRule(null)},b={type:g.type,operator:g.operator,formula1:g.formula1,formula2:g.formula2,allowBlank:g.allowBlank},H=$=>{const O=l.getValidatorItem($);if(!O)return;const z=O.operators,B=c.getRuleById(o,r,d),Z=$===(B==null?void 0:B.type)||$.includes("list")&&(B!=null&&B.type.includes("list"))?{...B,type:$}:{...g,type:$,operator:z[0],formula1:void 0,formula2:void 0};f(Z),p.executeCommand(F.UpdateSheetDataValidationSettingCommand.id,{unitId:o,subUnitId:r,ruleId:g.uid,setting:ie.getRuleSetting(Z)})},G=h.get(w.formulaInput),J=j.useMemo(()=>x.map($=>ct.serializeRange($.range)).join(","),[]),te=ie.getRuleOptions(g),ne=$=>{i.shallowEqual($,ie.getRuleOptions(g))||(f({...g,...$}),P(F.UpdateSheetDataValidationOptionsCommand.id,{unitId:o,subUnitId:r,ruleId:d,options:$}))};return ee.useSidebarClick($=>{var z;const O=(z=k.current)==null?void 0:z.handleOutClick;O&&O($,()=>E(!1))}),m.jsxs("div",{className:ye.dataValidationDetail,children:[m.jsx(N.FormLayout,{label:C.t("dataValidation.panel.range"),error:!g.ranges.length||R?C.t("dataValidation.panel.rangeError"):"",children:m.jsx(mt.RangeSelector,{unitId:o,subUnitId:r,initValue:J,onChange:y,onFocus:()=>E(!0),isFocus:U,actions:k.current,onVerify:$=>L(!$)})}),m.jsx(N.FormLayout,{label:C.t("dataValidation.panel.type"),children:m.jsx(N.Select,{options:I==null?void 0:I.map($=>({label:C.t($.title),value:$.id})),value:g.type,onChange:H,className:ye.dataValidationDetailFormItem})}),X!=null&&X.length?m.jsx(N.FormLayout,{label:C.t("dataValidation.panel.operator"),children:m.jsx(N.Select,{options:X.map(($,O)=>({value:`${$}`,label:D[O]})),value:`${g.operator}`,onChange:$=>{_({...b,operator:$})},className:ye.dataValidationDetailFormItem})}):null,G?m.jsx(G,{isTwoFormula:S,value:{formula1:g.formula1,formula2:g.formula2},onChange:$=>{_({...b,...$})},showError:V,validResult:w.validatorFormula(g,o,r),unitId:o,subUnitId:r,ruleId:d},e+g.type):null,m.jsx(N.FormLayout,{children:m.jsx(N.Checkbox,{checked:(ae=g.allowBlank)!=null?ae:!0,onChange:()=>{var $;return _({...b,allowBlank:!(($=g.allowBlank)==null||$)})},children:C.t("dataValidation.panel.allowBlank")})}),m.jsx(ta,{value:te,onChange:ne,extraComponent:w.optionsInput}),m.jsxs("div",{className:ye.dataValidationDetailButtons,children:[m.jsx(N.Button,{className:ye.dataValidationDetailButton,onClick:A,children:C.t("dataValidation.panel.removeRule")}),m.jsx(N.Button,{className:ye.dataValidationDetailButton,type:"primary",onClick:v,children:C.t("dataValidation.panel.done")})]})]})}const da="univer-data-validation-item-container",ca="univer-data-validation-item-title",ua="univer-data-validation-item-content",ha="univer-data-validation-item-icon",je={dataValidationItemContainer:da,dataValidationItemTitle:ca,dataValidationItemContent:ua,dataValidationItemIcon:ha},pa=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:o,disable:r}=e,s=i.useDependency(ie.DataValidatorRegistryService),d=i.useDependency(i.ICommandService),l=i.useDependency(K.IMarkSelectionService),u=s.getValidatorItem(t.type),h=j.useRef(),[p,c]=j.useState(!1),C=g=>{d.executeCommand(F.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:o}),g.stopPropagation()};return j.useEffect(()=>()=>{var g;h.current&&((g=h.current)==null||g.forEach(f=>{f&&l.removeShape(f)}))},[l]),m.jsxs("div",{className:je.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{r||(c(!0),h.current=t.ranges.map(g=>l.addShape({range:g,style:{hasAutoFill:!1,fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:null})))},onMouseLeave:()=>{var g;c(!1),(g=h.current)==null||g.forEach(f=>{f&&l.removeShape(f)}),h.current=void 0},children:[m.jsx("div",{className:je.dataValidationItemTitle,children:u==null?void 0:u.generateRuleName(t)}),m.jsx("div",{className:je.dataValidationItemContent,children:t.ranges.map(g=>ct.serializeRange(g)).join(",")}),p?m.jsx("div",{className:je.dataValidationItemIcon,onClick:C,children:m.jsx(gt,{})}):null]})},fa="univer-data-validation-list",ma="univer-data-validation-list-buttons",ga="univer-data-validation-list-button",Ae={dataValidationList:fa,dataValidationListButtons:ma,dataValidationListButton:ga};function va(){const e=i.useDependency(i.IUniverInstanceService),t=ee.useObservable(()=>e.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return t?m.jsx(Sa,{workbook:t}):null}function Sa(e){const t=i.useDependency(F.SheetDataValidationModel),a=i.useDependency(i.IUniverInstanceService),n=i.useDependency(i.ICommandService),o=i.useDependency(i.Injector),r=i.useDependency(he),s=i.useDependency(i.LocaleService),[d,l]=j.useState([]),{workbook:u}=e,h=ee.useObservable(u.activeSheet$,void 0,!0),p=u.getUnitId(),c=h==null?void 0:h.getSheetId();j.useEffect(()=>{l(t.getRules(p,c));const M=t.ruleChange$.subscribe(I=>{I.unitId===p&&I.subUnitId===c&&l(t.getRules(p,c))});return()=>{M.unsubscribe()}},[p,c,t]);const C=async()=>{const M=F.createDefaultNewRule(o),I={unitId:p,subUnitId:c,rule:M};await n.executeCommand(F.AddSheetDataValidationCommand.id,I),r.setActiveRule({unitId:p,subUnitId:c,rule:M})},g=()=>{n.executeCommand(F.RemoveSheetAllDataValidationCommand.id,{unitId:p,subUnitId:c})},w=(M=>{const I=a.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),x=I.getActiveSheet(),T=I.getUnitId(),P=x.getSheetId();return M.map(L=>Q.checkRangesEditablePermission(o,T,P,L.ranges)?{...L}:{...L,disable:!0})})(d),V=w==null?void 0:w.some(M=>M.disable);return m.jsxs("div",{className:Ae.dataValidationList,children:[w==null?void 0:w.map(M=>{var I;return m.jsx(pa,{unitId:p,subUnitId:c,onClick:()=>{M.disable||r.setActiveRule({unitId:p,subUnitId:c,rule:M})},rule:M,disable:(I=M.disable)!=null?I:!1},M.uid)}),m.jsxs("div",{className:Ae.dataValidationListButtons,children:[d.length&&!V?m.jsx(N.Button,{className:Ae.dataValidationListButton,onClick:g,children:s.t("dataValidation.panel.removeAll")}):null,m.jsx(N.Button,{className:Ae.dataValidationListButton,type:"primary",onClick:C,children:s.t("dataValidation.panel.add")})]})]})}const _a=()=>{const e=i.useDependency(he),t=ee.useObservable(e.activeRule$,e.activeRule);return t?m.jsx(la,{},t.rule.uid):m.jsx(va,{})},Ze="data-validation.list.dropdown",It="data-validation.date.dropdown",qe={type:i.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(i.IUniverInstanceService),a=Q.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:o}=a,r=F.createDefaultNewRule(e),s=e.get(i.ICommandService),d=n.getUnitId(),l=o.getSheetId(),u={rule:r,unitId:d,subUnitId:l};return s.syncExecuteCommand(F.AddSheetDataValidationCommand.id,u)?(s.syncExecuteCommand(Ce.id,{ruleId:r.uid,isAdd:!0}),!0):!1}};var Ia=Object.defineProperty,Ca=Object.getOwnPropertyDescriptor,Da=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ca(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Ia(t,a,o),o},Te=(e,t)=>(a,n)=>t(a,n,e);const $e="SHEET_DATA_VALIDATION_ALERT";let Le=class extends i.Disposable{constructor(e,t,a,n,o){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=o,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(de.debounceTime(100)).subscribe(e=>{var t,a;if(e){const o=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!o)return;const r=o.getCell(e.location.row,e.location.col);if(((t=r==null?void 0:r.dataValidation)==null?void 0:t.validStatus)===i.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get($e),d=(a=s==null?void 0:s.alert)==null?void 0:a.location;if(d&&d.row===e.location.row&&d.col===e.location.col&&d.subUnitId===e.location.subUnitId&&d.unitId===e.location.unitId)return;const l=r.dataValidation.validator,u=r.dataValidation.rule;if(!l)return;this._cellAlertManagerService.showAlert({type:K.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(u,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)}))}};Le=Da([Te(0,i.Inject(K.HoverManagerService)),Te(1,i.Inject(K.CellAlertManagerService)),Te(2,i.IUniverInstanceService),Te(3,i.Inject(i.LocaleService)),Te(4,ee.IZenZoneService)],Le);var ya=Object.defineProperty,wa=Object.getOwnPropertyDescriptor,Ra=(e,t,a,n)=>{for(var o=n>1?void 0:n?wa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&ya(t,a,o),o},et=(e,t)=>(a,n)=>t(a,n,e);let Re=class extends i.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._dataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(o,r)=>{const{source:s,target:d,unitId:l,subUnitId:u}=o,h=this._dataValidationModel.getRuleObjectMatrix(l,u).clone(),p=K.virtualizeDiscreteRanges([s,d]),[c,C]=p.ranges,{mapFunc:g}=p,f={row:c.startRow,col:c.startColumn},w=K.getAutoFillRepeatRange(c,C),V=new i.ObjectMatrix,M=new Set;w.forEach(R=>{const L=R.repeatStartCell,k=R.relativeRange,U={startRow:f.row,startColumn:f.col,endColumn:f.col,endRow:f.row},E={startRow:L.row,startColumn:L.col,endColumn:L.col,endRow:L.row};i.Range.foreach(k,(W,X)=>{const D=i.Rectangle.getPositionRange({startRow:W,startColumn:X,endColumn:X,endRow:W},U),{row:S,col:v}=g(D.startRow,D.startColumn),y=this._dataValidationModel.getRuleIdByLocation(l,u,S,v);if(y){const _=i.Rectangle.getPositionRange({startRow:W,startColumn:X,endColumn:X,endRow:W},E),{row:A,col:b}=g(_.startRow,_.startColumn);V.setValue(A,b,y),M.add(y)}})});const I=Array.from(M).map(R=>({id:R,ranges:i.queryObjectMatrix(V,L=>L===R)}));h.addRangeRules(I);const x=h.diff(this._dataValidationModel.getRules(l,u)),{redoMutations:T,undoMutations:P}=F.getDataValidationDiffMutations(l,u,x,this._injector,"patched",r===K.APPLY_TYPE.ONLY_FORMAT);return{undos:P,redos:T}},a=[i.DataValidationType.CHECKBOX],n={id:F.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:o=>{const{source:r,unitId:s,subUnitId:d}=o;for(const l of r.rows)for(const u of r.cols){const h=this._dataValidationModel.getRuleByLocation(s,d,l,u);if(h&&a.indexOf(h.type)>-1){this._autoFillService.setDisableApplyType(K.APPLY_TYPE.SERIES,!0);return}}},onFillData:(o,r,s)=>s===K.APPLY_TYPE.COPY||s===K.APPLY_TYPE.ONLY_FORMAT||s===K.APPLY_TYPE.SERIES?t(o,s):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};Re=Ra([et(0,K.IAutoFillService),et(1,i.Inject(F.SheetDataValidationModel)),et(2,i.Inject(i.Injector))],Re);var Va=Object.defineProperty,Ma=Object.getOwnPropertyDescriptor,Ea=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ma(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Va(t,a,o),o},tt=(e,t)=>(a,n)=>t(a,n,e);let Ve=class extends i.Disposable{constructor(t,a,n){super();Y(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:F.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,o)=>{const{copyType:r=K.COPY_TYPE.COPY,pasteType:s}=o,{range:d}=t||{},{range:l,unitId:u,subUnitId:h}=a;return this._generateMutations(l,{copyType:r,pasteType:s,copyRange:d,unitId:u,subUnitId:h})}})}_collect(t,a,n){const o=new i.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:o};const r=this._injector.invoke(l=>K.rangeToDiscreteRange(n,l,t,a));if(!r)return;const{rows:s,cols:d}=r;s.forEach((l,u)=>{d.forEach((h,p)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(t,a,l,h);o.setValue(u,p,c!=null?c:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===K.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:n,subUnitId:o}=this._copyInfo;if(a.unitId!==n||o!==a.subUnitId){const r=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),s=new i.ObjectMatrix,d=new Set,{ranges:[l,u],mapFunc:h}=K.virtualizeDiscreteRanges([a.copyRange,t]),p=K.getRepeatRange(l,u,!0),c=new Map;p.forEach(({startRange:w})=>{var V;(V=this._copyInfo)==null||V.matrix.forValue((M,I,x)=>{const T=i.Rectangle.getPositionRange({startRow:M,endRow:M,startColumn:I,endColumn:I},w),P=`${o}-${x}`,R=this._sheetDataValidationModel.getRuleById(n,o,x);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,P)&&R&&c.set(P,{...R,uid:P});const{row:L,col:k}=h(T.startRow,T.startColumn);d.add(P),s.setValue(L,k,P)})});const C=Array.from(d).map(w=>({id:w,ranges:i.queryObjectMatrix(s,V=>V===w)}));r.addRangeRules(C);const{redoMutations:g,undoMutations:f}=F.getDataValidationDiffMutations(a.unitId,a.subUnitId,r.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),c.values()),this._injector,"patched",!1);return{redos:g,undos:f}}else{const r=this._sheetDataValidationModel.getRuleObjectMatrix(n,o).clone(),s=new i.ObjectMatrix,d=new Set,{ranges:[l,u],mapFunc:h}=K.virtualizeDiscreteRanges([a.copyRange,t]);K.getRepeatRange(l,u,!0).forEach(({startRange:f})=>{var w;(w=this._copyInfo)==null||w.matrix.forValue((V,M,I)=>{const x=i.Rectangle.getPositionRange({startRow:V,endRow:V,startColumn:M,endColumn:M},f),{row:T,col:P}=h(x.startRow,x.startColumn);s.setValue(T,P,I),d.add(I)})});const c=Array.from(d).map(f=>({id:f,ranges:i.queryObjectMatrix(s,w=>w===f)}));r.addRangeRules(c);const{redoMutations:C,undoMutations:g}=F.getDataValidationDiffMutations(n,o,r.diff(this._sheetDataValidationModel.getRules(n,o)),this._injector,"patched",!1);return{redos:C,undos:g}}}};Ve=Ea([tt(0,K.ISheetClipboardService),tt(1,i.Inject(F.SheetDataValidationModel)),tt(2,i.Inject(i.Injector))],Ve);var ba=Object.defineProperty,Oa=Object.getOwnPropertyDescriptor,Ta=(e,t,a,n)=>{for(var o=n>1?void 0:n?Oa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&ba(t,a,o),o},nt=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends i.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionInterceptorBaseController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===F.AddSheetDataValidationCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[Q.WorkbookEditablePermission],rangeTypes:[Q.RangeProtectionPermissionEditPoint],worksheetTypes:[Q.WorksheetEditPermission,Q.WorksheetSetCellStylePermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr"))),e.id===F.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[Q.WorkbookEditablePermission],rangeTypes:[Q.RangeProtectionPermissionEditPoint],worksheetTypes:[Q.WorksheetEditPermission,Q.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr")))}))}};Me=Ta([nt(0,i.Inject(i.LocaleService)),nt(1,i.ICommandService),nt(2,i.Inject(K.SheetPermissionInterceptorBaseController))],Me);const zt="data-validation-single",Kt="sheet.menu.data-validation";function Pa(e){return{id:Kt,type:ee.MenuItemType.SUBITEMS,icon:zt,tooltip:"dataValidation.title",hidden$:ee.getMenuHiddenObservable(e,i.UniverInstanceType.UNIVER_SHEET),disabled$:K.getCurrentRangeDisable$(e,{workbookTypes:[Q.WorkbookEditablePermission],worksheetTypes:[Q.WorksheetSetCellStylePermission,Q.WorksheetEditPermission],rangeTypes:[Q.RangeProtectionPermissionEditPoint]})}}function La(e){return{id:Ce.id,title:"dataValidation.panel.title",type:ee.MenuItemType.BUTTON}}function ja(e){return{id:qe.id,title:"dataValidation.panel.add",type:ee.MenuItemType.BUTTON}}const Aa={[ee.RibbonStartGroup.FORMULAS_INSERT]:{[Kt]:{order:9,menuItemFactory:Pa,[Ce.id]:{order:0,menuItemFactory:La},[qe.id]:{order:1,menuItemFactory:ja}}}};var $a=Object.defineProperty,xa=Object.getOwnPropertyDescriptor,Gt=(e,t,a,n)=>{for(var o=n>1?void 0:n?xa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&$a(t,a,o),o},oe=(e,t)=>(a,n)=>t(a,n,e);const Zt={tr:{size:6,color:"#fe4b4b"}};let Ee=class extends i.RxDisposable{constructor(e,t,a,n,o,r,s,d,l,u,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=o,this._dropdownManagerService=r,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=u,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Aa)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var a;if(!e.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:o,row:r,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,o,r,s);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(u!=null&&u.dropdown))return;const h=d.getActiveSheet();if(!h)return;const p=this._dropdownManagerService.activeDropdown,c=p==null?void 0:p.location;if(c&&c.unitId===n&&c.subUnitId===o&&c.row===r&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:o,row:r,col:s,workbook:d,worksheet:h},componentKey:u.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Q.INTERCEPTOR_POINT.CELL_CONTENT,{effect:i.InterceptorEffectEnum.Style,priority:Q.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var V,M,I,x,T,P;const{row:n,col:o,unitId:r,subUnitId:s,workbook:d,worksheet:l}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,o);if(!u)return a(e);const h=this._sheetDataValidationModel.getRuleById(r,s,u);if(!h)return a(e);const p=(M=(V=this._dataValidationCacheService.getValue(r,s,n,o))==null?void 0:V.status)!=null?M:i.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(h.type),C=t.rawData;let g;const f={get value(){var R;return g!==void 0||(g=(R=F.getCellValueOrigin(C))!=null?R:null),g}},w={get value(){var R;return`${(R=f.value)!=null?R:""}`}};return a({...e,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c},markers:{...e==null?void 0:e.markers,...p===i.DataValidationStatus.INVALID?Zt:null},customRender:[...(I=e==null?void 0:e.customRender)!=null?I:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((x=e==null?void 0:e.fontRenderExtension)==null?void 0:x.isSkip)||((T=c==null?void 0:c.skipDefaultFontRender)==null?void 0:T.call(c,h,f.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(h,w.value,{get style(){const R=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?R.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,o)},interceptorAutoHeight:()=>{var U,E,W,X,D,S;const R=(E=(U=this._renderManagerService.getRenderById(r))==null?void 0:U.with(K.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:E.skeleton;if(!R)return;const L=R.worksheet.getMergedCell(n,o),k={data:{...e,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c}},style:R.getsStyles().getStyleByCell(e),primaryWithCoord:R.getCellByIndex((W=L==null?void 0:L.startRow)!=null?W:n,(X=L==null?void 0:L.startColumn)!=null?X:o),unitId:r,subUnitId:s,row:n,col:o,workbook:d,worksheet:l};return(S=(D=c==null?void 0:c.canvasRender)==null?void 0:D.calcCellAutoHeight)==null?void 0:S.call(D,k)},interceptorAutoWidth:()=>{var U,E,W,X,D,S;const R=(E=(U=this._renderManagerService.getRenderById(r))==null?void 0:U.with(K.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:E.skeleton;if(!R)return;const L=R.worksheet.getMergedCell(n,o),k={data:{...e,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c}},style:R.getsStyles().getStyleByCell(e),primaryWithCoord:R.getCellByIndex((W=L==null?void 0:L.startRow)!=null?W:n,(X=L==null?void 0:L.startColumn)!=null?X:o),unitId:r,subUnitId:s,row:n,col:o,workbook:d,worksheet:l};return(S=(D=c==null?void 0:c.canvasRender)==null?void 0:D.calcCellAutoWidth)==null?void 0:S.call(D,k)},coverable:((P=e==null?void 0:e.coverable)!=null?P:!0)&&!(h.type===i.DataValidationType.LIST||h.type===i.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(de.filter(e=>e.source==="command"),de.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);i.sequenceExecute(a.redos,this._commandService)}})}};Ee=Gt([oe(0,i.ICommandService),oe(1,ee.IMenuManagerService),oe(2,q.IRenderManagerService),oe(3,i.IUniverInstanceService),oe(4,i.Inject(K.AutoHeightController)),oe(5,i.Inject(me)),oe(6,i.Inject(F.SheetDataValidationModel)),oe(7,i.Inject(ie.DataValidatorRegistryService)),oe(8,i.Inject(Q.SheetInterceptorService)),oe(9,i.Inject(F.DataValidationCacheService)),oe(10,i.Optional(K.IEditorBridgeService))],Ee);let wt=class extends i.RxDisposable{constructor(e,t,a,n,o,r,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=o,this._sheetDataValidationModel=r,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Q.INTERCEPTOR_POINT.CELL_CONTENT,{effect:i.InterceptorEffectEnum.Style,priority:Q.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var w,V,M,I,x,T;const{row:n,col:o,unitId:r,subUnitId:s,workbook:d,worksheet:l}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,o);if(!u)return a(e);const h=this._sheetDataValidationModel.getRuleById(r,s,u);if(!h)return a(e);const p=(V=(w=this._dataValidationCacheService.getValue(r,s,n,o))==null?void 0:w.status)!=null?V:i.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(h.type),C=l.getCellRaw(n,o),g=F.getCellValueOrigin(C),f=`${g!=null?g:""}`;return a({...e,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c},markers:{...e==null?void 0:e.markers,...p===i.DataValidationStatus.INVALID?Zt:null},customRender:[...(M=e==null?void 0:e.customRender)!=null?M:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((I=e==null?void 0:e.fontRenderExtension)==null?void 0:I.isSkip)||((x=c==null?void 0:c.skipDefaultFontRender)==null?void 0:x.call(c,h,g,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(h,f,{get style(){const P=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?P.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,o)},interceptorAutoHeight:()=>{var k,U,E,W,X,D;const P=(U=(k=this._renderManagerService.getRenderById(r))==null?void 0:k.with(K.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:U.skeleton;if(!P)return;const R=P.worksheet.getMergedCell(n,o),L={data:{...e,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c}},style:P.getsStyles().getStyleByCell(e),primaryWithCoord:P.getCellByIndex((E=R==null?void 0:R.startRow)!=null?E:n,(W=R==null?void 0:R.startColumn)!=null?W:o),unitId:r,subUnitId:s,row:n,col:o,workbook:d,worksheet:l};return(D=(X=c==null?void 0:c.canvasRender)==null?void 0:X.calcCellAutoHeight)==null?void 0:D.call(X,L)},coverable:((T=e==null?void 0:e.coverable)!=null?T:!0)&&!(h.type===i.DataValidationType.LIST||h.type===i.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(de.filter(e=>e.source==="command"),de.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);i.sequenceExecute(a.redos,this._commandService)}})}};wt=Gt([oe(0,i.ICommandService),oe(1,q.IRenderManagerService),oe(2,i.Inject(K.AutoHeightController)),oe(3,i.Inject(ie.DataValidatorRegistryService)),oe(4,i.Inject(Q.SheetInterceptorService)),oe(5,i.Inject(F.SheetDataValidationModel)),oe(6,i.Inject(F.DataValidationCacheService))],wt);var Fa=Object.defineProperty,Ua=Object.getOwnPropertyDescriptor,Na=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ua(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Fa(t,a,o),o},Rt=(e,t)=>(a,n)=>t(a,n,e);let He=class extends i.Disposable{constructor(e,t,a){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const a=new Set;t.forEach(o=>{a.add(o.subUnitId)}),a.forEach(o=>{var r;(r=this._sheetSkeletonManagerService.getWorksheetSkeleton(o))==null||r.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(i.bufferDebounceTime(16)).subscribe(e))}};He=Na([Rt(1,i.Inject(F.SheetDataValidationModel)),Rt(2,i.Inject(K.SheetSkeletonManagerService))],He);const ka="univer-data-validation-formula",Ba="univer-data-validation-formula-and",Wa="univer-data-validation-formula-list-item",Ha="univer-data-validation-formula-list-item-icon",Ya="univer-data-validation-formula-list-item-drag",Xa="univer-data-validation-formula-list-add",za="univer-data-validation-formula-color-select",Ka="univer-data-validation-formula-color-select-panel",Ga="univer-data-validation-formula-color-item",se={dataValidationFormula:ka,dataValidationFormulaAnd:Ba,dataValidationFormulaListItem:Wa,dataValidationFormulaListItemIcon:Ha,dataValidationFormulaListItemDrag:Ya,dataValidationFormulaListAdd:Xa,dataValidationFormulaColorSelect:za,dataValidationFormulaColorSelectPanel:Ka,dataValidationFormulaColorItem:Ga},Za=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:o,validResult:r}=e,s=i.useDependency(i.LocaleService),d=o?r==null?void 0:r.formula1:"",l=o?r==null?void 0:r.formula2:"";return t?m.jsxs(m.Fragment,{children:[m.jsx(N.FormLayout,{error:d,children:m.jsx(N.Input,{className:se.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({...a,formula1:u})}})}),m.jsx("div",{className:se.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),m.jsx(N.FormLayout,{error:l,children:m.jsx(N.Input,{className:se.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:u=>{n==null||n({...a,formula2:u})}})})]}):m.jsx(N.FormLayout,{error:d,children:m.jsx(N.Input,{className:se.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({formula1:u})}})})};function qa(e){const{value:t,onChange:a,showError:n,validResult:o}=e,r=i.useDependency(i.LocaleService),s=n?o==null?void 0:o.formula1:"",d=n?o==null?void 0:o.formula2:"",[l,u]=j.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return m.jsxs(m.Fragment,{children:[m.jsx(N.FormLayout,{children:m.jsx(N.Checkbox,{checked:l,onChange:h=>{h?u(!0):(u(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:r.t("dataValidation.checkbox.tips")})}),l?m.jsx(N.FormLayout,{label:r.t("dataValidation.checkbox.checked"),error:s,children:m.jsx(N.Input,{className:se.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{a==null||a({...t,formula1:h||void 0})}})}):null,l?m.jsx(N.FormLayout,{label:r.t("dataValidation.checkbox.unchecked"),error:d,children:m.jsx(N.Input,{className:se.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{a==null||a({...t,formula2:h||void 0})}})}):null]})}function Ja(e){var p;const{unitId:t,subUnitId:a,value:n,onChange:o,showError:r,validResult:s}=e,d=r?s==null?void 0:s.formula1:void 0,l=j.useRef({}),[u,h]=j.useState(!1);return ee.useSidebarClick(c=>{var g;const C=(g=l.current)==null?void 0:g.handleOutClick;C&&C(c,()=>h(!1))}),m.jsx(mt.FormulaEditor,{initValue:(p=n==null?void 0:n.formula1)!=null?p:"",unitId:t,subUnitId:a,isFocus:u,onChange:c=>{const C=(c!=null?c:"").trim();C!==(n==null?void 0:n.formula1)&&(o==null||o({...n,formula1:C}))},errorText:d,onFocus:()=>h(!0),actions:l.current,isSupportAcrossSheet:!0})}function qt(e){var t,a,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(a=qt(e[t]))&&(n&&(n+=" "),n+=a)}else for(a in e)e[a]&&(n&&(n+=" "),n+=a);return n}function Qa(){for(var e,t,a=0,n="",o=arguments.length;a<o;a++)(e=arguments[a])&&(t=qt(e))&&(n&&(n+=" "),n+=t);return n}const eo=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],to=e=>{const{value:t,onChange:a,disabled:n}=e,[o,r]=j.useState(!1);return m.jsx(N.Select,{disabled:n,open:o,onDropdownVisibleChange:r,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:se.dataValidationFormulaColorSelect,value:t,onChange:a,labelRender:s=>m.jsx("div",{className:se.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>m.jsx("div",{className:se.dataValidationFormulaColorSelectPanel,children:eo.map(s=>m.jsx("div",{onClick:()=>{a(s),r(!1)},className:se.dataValidationFormulaColorItem,style:{background:s}},s))})})},Vt=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:o,onItemDelete:r}=a;return m.jsxs("div",{className:se.dataValidationFormulaListItem,style:n,children:[t.isRef?null:m.jsx("div",{className:Qa(se.dataValidationFormulaListItemDrag,"draggableHandle"),children:m.jsx(Bt,{})}),m.jsx(to,{value:t.color,onChange:s=>{o(t.id,t.label,s)}}),m.jsx(N.Input,{disabled:t.isRef,value:t.label,onChange:s=>{o(t.id,s,t.color)}}),t.isRef?null:m.jsx("div",{className:se.dataValidationFormulaListItemIcon,children:m.jsx(gt,{onClick:()=>r(t.id)})})]})};function no(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:o,validResult:r,showError:s,ruleId:d}=e,{formula1:l="",formula2:u=""}=t||{},h=j.useRef(null),[p,c]=j.useState(()=>i.isFormulaString(l)?"1":"0"),[C,g]=j.useState(p==="1"?l:"="),[f,w]=j.useState(p==="1"?l:"="),V=i.useDependency(i.LocaleService),M=i.useDependency(ie.DataValidatorRegistryService),I=i.useDependency(ie.DataValidationModel),x=i.useDependency(F.DataValidationFormulaController),[T,P]=j.useState(()=>u.split(",")),R=M.getValidatorItem(i.DataValidationType.LIST),[L,k]=j.useState([]),[U,E]=j.useState(""),W=s?r==null?void 0:r.formula1:"",X=j.useMemo(()=>I.ruleChange$.pipe(de.debounceTime(16)),[]),D=ee.useObservable(X),S=ee.useEvent(a);j.useEffect(()=>{(async()=>{await new Promise(B=>{setTimeout(()=>B(!0),100)});const O=I.getRuleById(n,o,d),z=O==null?void 0:O.formula1;if(i.isFormulaString(z)&&R&&O){const B=await R.getListAsync(O,n,o);k(B)}})()},[I,D,R,d,o,n]),j.useEffect(()=>{i.isFormulaString(l)&&l!==f&&(g(l),w(f))},[f,l]);const[v,y]=j.useState(()=>{const O=p!=="1"?F.deserializeListOptions(l):[],z=u.split(",");return O.map((B,Z)=>({label:B,color:z[Z]||Ie,isRef:!1,id:i.Tools.generateRandomId(4)}))}),_=(O,z,B)=>{const Z=v.find(re=>re.id===O);Z&&(Z.label=z,Z.color=B,y([...v]))},A=O=>{const z=v.findIndex(B=>B.id===O);z!==-1&&(v.splice(z,1),y([...v]))},b=u.split(","),H=j.useMemo(()=>L.map((O,z)=>({label:O,color:b[z]||Ie,id:`${z}`,isRef:!0})),[b,L]),G=(O,z,B)=>{const Z=[...T];Z[+O]=B,P(Z),S({formula1:l,formula2:Z.join(",")})},J=()=>{y([...v,{label:"",color:Ie,isRef:!1,id:i.Tools.generateRandomId(4)}])};j.useEffect(()=>{if(p==="1")return;const O=new Set,z=[];v.map(B=>({labelList:B.label.split(","),item:B})).forEach(({item:B,labelList:Z})=>{Z.forEach(re=>{O.has(re)||(O.add(re),z.push({label:re,color:B.color}))})}),S({formula1:F.serializeListOptions(z.map(B=>B.label)),formula2:z.map(B=>B.color===Ie?"":B.color).join(",")})},[v,S,p,f,T]);const te=j.useMemo(()=>async O=>{if(!i.isFormulaString(O)){S==null||S({formula1:"",formula2:u});return}x.getFormulaRefCheck(O)?(S==null||S({formula1:i.isFormulaString(O)?O:"",formula2:u}),E("")):(S==null||S({formula1:"",formula2:u}),g("="),E(V.t("dataValidation.validFail.formulaError")))},[u,S]),ne=j.useRef({}),[ae,$]=j.useState(!1);return ee.useSidebarClick(O=>{var B;const z=(B=ne.current)==null?void 0:B.handleOutClick;z&&z(O,()=>$(!1))}),m.jsxs(m.Fragment,{children:[m.jsx(N.FormLayout,{label:V.t("dataValidation.list.options"),children:m.jsxs(N.RadioGroup,{value:p,onChange:O=>{c(O),g(f),O==="1"&&S({formula1:f==="="?"":f,formula2:T.join(",")})},children:[m.jsx(N.Radio,{value:"0",children:V.t("dataValidation.list.customOptions")}),m.jsx(N.Radio,{value:"1",children:V.t("dataValidation.list.refOptions")})]})}),p==="1"?m.jsxs(m.Fragment,{children:[m.jsx(mt.FormulaEditor,{initValue:C,unitId:n,subUnitId:o,isFocus:ae,onChange:(O="")=>{const z=(O!=null?O:"").trim();w(z),te(z)},errorText:W||U||void 0,onFocus:()=>$(!0),actions:ne.current,isSupportAcrossSheet:!0}),m.jsx("div",{ref:h,style:{marginTop:"12px"},children:H.map(O=>m.jsx(Vt,{item:O,commonProps:{onItemChange:G},style:{marginBottom:12}},O.id))})]}):m.jsx(N.FormLayout,{error:W,children:m.jsxs("div",{ref:h,style:{marginTop:"-12px"},children:[m.jsx(N.DraggableList,{list:v,onListChange:y,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:O=>m.jsx(Vt,{item:O,commonProps:{onItemChange:_,onItemDelete:A}},O.id),idKey:"id"}),m.jsxs("a",{className:se.dataValidationFormulaListAdd,onClick:J,children:[m.jsx(Ut,{}),V.t("dataValidation.list.add")]})]})})]})}const Jt="data-validation.custom-formula-input",Je="data-validation.formula-input",Ct="data-validation.list-formula-input",Qt="data-validation.checkbox-formula-input",ao=[[Jt,Ja],[Je,Za],[Ct,no],[Qt,qa]],oo="LIST_RENDER_MODE_OPTION_INPUT";function Ye(e){var o;const{value:t,onChange:a}=e,n=i.useDependency(i.LocaleService);return m.jsx(N.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:m.jsxs(N.RadioGroup,{value:`${(o=t.renderMode)!=null?o:i.DataValidationRenderMode.CUSTOM}`,onChange:r=>a({...t,renderMode:+r}),children:[m.jsx(N.Radio,{value:`${i.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),m.jsx(N.Radio,{value:`${i.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),m.jsx(N.Radio,{value:`${i.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}Ye.componentKey=oo;const io="DATE_SHOW_TIME_OPTION";function Xe(e){var o;const{value:t,onChange:a}=e,n=i.useDependency(i.LocaleService);return m.jsx(N.FormLayout,{children:m.jsx(N.Checkbox,{checked:(o=t.bizInfo)==null?void 0:o.showTime,onChange:r=>{a({...t,bizInfo:{...t.bizInfo,showTime:r}})},children:n.t("dataValidation.showTime.label")})})}Xe.componentKey=io;var ro=Object.defineProperty,so=Object.getOwnPropertyDescriptor,lo=(e,t,a,n)=>{for(var o=n>1?void 0:n?so(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&ro(t,a,o),o},xe=(e,t)=>(a,n)=>t(a,n,e);const Fe=6;let ut=class{constructor(e,t,a,n){this._commandService=e,this._formulaService=t,this._themeService=a,this._renderManagerService=n}_calc(e,t){var u,h,p;const{vt:a,ht:n}=t||{},o=e.endX-e.startX-Fe*2,r=e.endY-e.startY,s=((u=t==null?void 0:t.fs)!=null?u:10)*1.6;let d=0,l=0;switch(a){case i.VerticalAlign.TOP:l=0;break;case i.VerticalAlign.BOTTOM:l=0+(r-s);break;default:l=0+(r-s)/2;break}switch(n){case i.HorizontalAlign.LEFT:d=Fe;break;case i.HorizontalAlign.RIGHT:d=Fe+(o-s);break;default:d=Fe+(o-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 a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var u,h,p,c,C,g,f,w,V;const{formula1:n=F.CHECKBOX_FORMULA_1,formula2:o=F.CHECKBOX_FORMULA_2}=e,r=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=F.getFormulaResult((p=(h=(u=r==null?void 0:r[0])==null?void 0:u.result)==null?void 0:h[0])==null?void 0:p[0]),d=F.getFormulaResult((g=(C=(c=r==null?void 0:r[1])==null?void 0:c.result)==null?void 0:C[0])==null?void 0:g[0]),l=F.isLegalFormulaResult(String(s))&&F.isLegalFormulaResult(String(d));return{formula1:i.isFormulaString(n)?F.getFormulaResult((V=(w=(f=r==null?void 0:r[0])==null?void 0:f.result)==null?void 0:w[0])==null?void 0:V[0]):n,formula2:i.isFormulaString(o)?d:o,isFormulaValid:l}}drawWith(e,t){var X,D,S,v,y,_;const{style:a,data:n,primaryWithCoord:o,unitId:r,subUnitId:s,worksheet:d,row:l,col:u}=t,h=o.isMergedMainCell?o.mergeInfo:o,p=F.getCellValueOrigin(d.getCellRaw(l,u)),c=(X=n.dataValidation)==null?void 0:X.rule,C=(D=n.dataValidation)==null?void 0:D.validator;if(!c||!C)return;const g=this._themeService.getCurrentTheme();if(!((S=C.skipDefaultFontRender)!=null&&S.call(C,c,p,{unitId:r,subUnitId:s,row:l,column:u})))return;const f=C.parseFormulaSync(c,r,s),{formula1:w}=f,V=this._calc(h,a),{a:M,d:I}=e.getTransform(),x=q.fixLineWidthByScale(V.left,M),T=q.fixLineWidthByScale(V.top,I),P=q.Transform.create().composeMatrix({left:x,top:T,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),R=h.endX-h.startX,L=h.endY-h.startY;e.save(),e.beginPath(),e.rect(h.startX,h.startY,R,L),e.clip();const k=P.getMatrix();e.transform(k[0],k[1],k[2],k[3],k[4],k[5]);const U=((v=a==null?void 0:a.fs)!=null?v:10)*1.6,E=String(p)===String(w),W=g.hyacinth500;q.Checkbox.drawWith(e,{checked:E,width:U,height:U,fill:(_=(y=a==null?void 0:a.cl)==null?void 0:y.rgb)!=null?_:W}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),o=n.top,r=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:u}=e;return l<=d&&l>=s&&u<=r&&u>=o}async onPointerDown(e,t){var f,w,V;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:o,data:r,worksheet:s,row:d,col:l}=e,u=F.getCellValueOrigin(s.getCellRaw(d,l)),h=(f=r.dataValidation)==null?void 0:f.rule,p=(w=r.dataValidation)==null?void 0:w.validator;if(!h||!p||!((V=p.skipDefaultFontRender)!=null&&V.call(p,h,u,{unitId:n,subUnitId:o,row:d,column:l})))return;const{formula1:c,formula2:C}=await this._parseFormula(h,n,o),g={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(u)===F.transformCheckboxValue(String(c))?C:c,p:null}};this._commandService.executeCommand(Q.SetRangeValuesCommand.id,g)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(q.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(q.CURSOR_TYPE.DEFAULT)}};ut=lo([xe(0,i.ICommandService),xe(1,i.Inject(F.DataValidationFormulaService)),xe(2,i.Inject(i.ThemeService)),xe(3,i.Inject(q.IRenderManagerService))],ut);var co=Object.defineProperty,uo=Object.getOwnPropertyDescriptor,ho=(e,t,a,n)=>{for(var o=n>1?void 0:n?uo(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&co(t,a,o),o},po=(e,t)=>(a,n)=>t(a,n,e);let pe=class{constructor(e){Y(this,"canvasRender",null);Y(this,"dropdown");Y(this,"optionsInput");Y(this,"formulaInput",Ct);this.injector=e}};pe=ho([po(0,i.Inject(i.Injector))],pe);class fo extends pe{constructor(){super(...arguments);Y(this,"id",i.DataValidationType.CHECKBOX);Y(this,"canvasRender",this.injector.createInstance(ut));Y(this,"formulaInput",Qt)}}class mo extends pe{constructor(){super(...arguments);Y(this,"id",i.DataValidationType.CUSTOM);Y(this,"formulaInput",Jt)}}const go="data-validation.formula-input";class vo extends pe{constructor(){super(...arguments);Y(this,"id",i.DataValidationType.DATE);Y(this,"formulaInput",go);Y(this,"optionsInput",Xe.componentKey);Y(this,"dropdown",It)}}class So extends pe{constructor(){super(...arguments);Y(this,"id",i.DataValidationType.DECIMAL);Y(this,"formulaInput",Je)}}const en=4,_o=0,at=4,tn=4,ht=6,ze=6,_e=14;function Io(e,t){const a=q.FontCache.getTextSize(e,t),n=a.width+en*2,{ba:o,bd:r}=a,s=o+r;return{width:n,height:s+_o*2,ba:o}}function ot(e,t,a,n){const o=_e+ht*2,r=a-o,s=n-ze*2,d=e.map(c=>({layout:Io(c,t),text:c}));let l;const u=[];d.forEach(c=>{const{layout:C}=c,{width:g,height:f}=C;!l||l.width+g+at>r?(l={width:g,height:f,items:[{...c,left:0}]},u.push(l)):(l.items.push({...c,left:l.width+at}),l.width=l.width+g+at)});let h=0,p=0;return u.forEach((c,C)=>{p=Math.max(p,c.width),C===u.length-1?h+=c.height:h+=c.height+tn}),{lines:u,totalHeight:h,contentWidth:r,contentHeight:s,cellAutoHeight:h+ze*2,calcAutoWidth:p+o}}const Co=8;class Do extends q.Shape{static drawWith(t,a){const{fontString:n,info:o,fill:r,color:s}=a,{layout:d,text:l}=o;t.save(),q.Rect.drawWith(t,{width:d.width,height:d.height,radius:Co,fill:r||Ie}),t.translateWithPrecision(en,d.ba),t.font=n,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var yo=Object.defineProperty,wo=Object.getOwnPropertyDescriptor,Ro=(e,t,a,n)=>{for(var o=n>1?void 0:n?wo(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&yo(t,a,o),o},Mt=(e,t)=>(a,n)=>t(a,n,e);const Vo=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let pt=class{constructor(e,t){Y(this,"zIndex");Y(this,"_dropdownInfoMap",new Map);this._commandService=e,this._renderManagerService=t}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,o){const r=a-_e+4;let s=4;switch(o){case i.VerticalAlign.MIDDLE:s=(n-_e)/2+4;break;case i.VerticalAlign.BOTTOM:s=n-_e+4;break}e.save(),e.translateWithPrecision(t.startX+r,t.startY+s),e.fillStyle="#565656",e.fill(Vo),e.restore()}drawWith(e,t,a,n){var b,H;const{primaryWithCoord:o,row:r,col:s,style:d,data:l,subUnitId:u}=t,h=o.isMergedMainCell?o.mergeInfo:o,p=l.fontRenderExtension,{leftOffset:c=0,rightOffset:C=0,topOffset:g=0,downOffset:f=0}=p||{},w=l.dataValidation,V=this._ensureMap(u),M=this._generateKey(r,s);if(!w)return;const I={startX:h.startX+c,endX:h.endX-C,startY:h.startY+g,endY:h.endY-f},x=I.endX-I.startX,T=I.endY-I.startY,{cl:P}=d||{},R=(b=typeof P=="object"?P==null?void 0:P.rgb:P)!=null?b:"#000",L=q.getFontStyleString(d!=null?d:void 0),{rule:k,validator:U}=w,E=U,{vt:W,ht:X}=d||{},D=W!=null?W:i.VerticalAlign.MIDDLE,S=(H=F.getCellValueOrigin(l))!=null?H:"",v=E.parseCellValue(S),y=E.getListWithColorMap(k),_=ot(v,L,x,T);this._drawDownIcon(e,I,x,T,D),e.save(),e.translateWithPrecision(I.startX,I.startY),e.beginPath(),e.rect(0,0,x-_e,T),e.clip(),e.translateWithPrecision(ht,ze);let A=0;switch(D){case i.VerticalAlign.MIDDLE:A=(_.contentHeight-_.totalHeight)/2;break;case i.VerticalAlign.BOTTOM:A=_.contentHeight-_.totalHeight;break}e.translateWithPrecision(0,A),_.lines.forEach((G,J)=>{e.save();const{width:te,height:ne,items:ae}=G;let $=0;switch(X){case i.HorizontalAlign.RIGHT:$=_.contentWidth-te;break;case i.HorizontalAlign.CENTER:$=(_.contentWidth-te)/2;break}e.translate($,J*(ne+tn)),ae.forEach(O=>{e.save(),e.translateWithPrecision(O.left,0),Do.drawWith(e,{...L,info:O,color:R,fill:y[O.text]}),e.restore()}),e.restore()}),e.restore(),V.set(M,{left:I.startX,top:I.startY,width:_.contentWidth+ht+_e,height:_.contentHeight+ze*2})}calcCellAutoHeight(e){var x;const{primaryWithCoord:t,style:a,data:n}=e,o=n.fontRenderExtension,{leftOffset:r=0,rightOffset:s=0,topOffset:d=0,downOffset:l=0}=o||{},u=t.isMergedMainCell?t.mergeInfo:t,h={startX:u.startX+r,endX:u.endX-s,startY:u.startY+d,endY:u.endY-l},p=n.dataValidation;if(!p)return;const c=h.endX-h.startX,C=h.endY-h.startY,g=(x=F.getCellValueOrigin(n))!=null?x:"",{validator:f}=p,V=f.parseCellValue(g),M=q.getFontStyleString(a!=null?a:void 0);return ot(V,M,c,C).cellAutoHeight}calcCellAutoWidth(e){var x;const{primaryWithCoord:t,style:a,data:n}=e,o=n.fontRenderExtension,{leftOffset:r=0,rightOffset:s=0,topOffset:d=0,downOffset:l=0}=o||{},u=t.isMergedMainCell?t.mergeInfo:t,h={startX:u.startX+r,endX:u.endX-s,startY:u.startY+d,endY:u.endY-l},p=n.dataValidation;if(!p)return;const c=h.endX-h.startX,C=h.endY-h.startY,g=(x=F.getCellValueOrigin(n))!=null?x:"",{validator:f}=p,V=f.parseCellValue(g),M=q.getFontStyleString(a!=null?a:void 0);return ot(V,M,c,C).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:o}=n,{x:r}=e;return r>=o-_e&&r<=o}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:r}=e,s={unitId:a,subUnitId:n,row:o,column:r};this._commandService.executeCommand(Ge.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(q.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(q.CURSOR_TYPE.DEFAULT)}};pt=Ro([Mt(0,i.ICommandService),Mt(1,i.Inject(q.IRenderManagerService))],pt);class Mo extends pe{constructor(){super(...arguments);Y(this,"id",i.DataValidationType.LIST_MULTIPLE);Y(this,"canvasRender",this.injector.createInstance(pt));Y(this,"dropdown",Ze)}}var Eo=Object.defineProperty,bo=Object.getOwnPropertyDescriptor,Oo=(e,t,a,n)=>{for(var o=n>1?void 0:n?bo(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Eo(t,a,o),o},it=(e,t)=>(a,n)=>t(a,n,e);const Se=4,Ue=4,ce=14,ue=6,we=4,rt=8,To="#565656",Et=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 Po(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${i.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:i.BooleanNumber.FALSE,bl:i.BooleanNumber.FALSE,ul:{s:i.BooleanNumber.FALSE},st:{s:i.BooleanNumber.FALSE},ol:{s:i.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function nn(e,t,a){const n=Po(e,a),o=new i.DocumentDataModel(n),r=new q.DocumentViewModel(o);return{documentSkeleton:q.DocumentSkeleton.create(r,t),docModel:o,docViewModel:r}}function Ne(e,t,a){const{documentSkeleton:n,docModel:o,docViewModel:r}=nn(e,t,a);return{documents:new q.Documents(`DOCUMENTS_${i.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:o,docViewModel:r}}function bt(e,t,a,n,o,r,s=!0){let d=0;const l=s?we:0;switch(o){case i.VerticalAlign.BOTTOM:d=t-n-l;break;case i.VerticalAlign.MIDDLE:d=(t-n)/2;break;default:d=l;break}d=Math.max(we,d);let u=0;switch(r){case i.HorizontalAlign.CENTER:u=(e-a)/2;break;case i.HorizontalAlign.RIGHT:u=e-a;break}return u=Math.max(ue,u),{paddingLeft:u,paddingTop:d}}let ft=class{constructor(e,t,a){Y(this,"_dropdownInfoMap",new Map);Y(this,"zIndex");this._localeService=e,this._commandService=t,this._renderManagerService=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,o,r,s){const{t:d=i.DEFAULT_STYLES.pd.t,b:l=i.DEFAULT_STYLES.pd.b}=s,u=a-ce;let h;switch(r){case i.VerticalAlign.MIDDLE:h=(n-Ue)/2;break;case i.VerticalAlign.BOTTOM:h=n-l-o-we+(o/2-Ue/2);break;default:h=d+we+(o/2-Ue/2);break}e.save(),e.translateWithPrecision(t.startX+u,t.startY+h),e.fillStyle="#565656",e.fill(Et),e.restore()}drawWith(e,t,a){var D,S;const{primaryWithCoord:n,row:o,col:r,style:s,data:d,subUnitId:l}=t,u=n.isMergedMainCell?n.mergeInfo:n,h=(D=d.dataValidation)==null?void 0:D.rule,p=(S=d.dataValidation)==null?void 0:S.validator,c=d.fontRenderExtension,{leftOffset:C=0,rightOffset:g=0,topOffset:f=0,downOffset:w=0}=c||{};if(!h||!p||!p||p.id.indexOf(i.DataValidationType.LIST)!==0||!p.skipDefaultFontRender(h))return;const V={startX:u.startX+C,endX:u.endX-g,startY:u.startY+f,endY:u.endY-w},M=V.endX-V.startX,I=V.endY-V.startY,x=this._ensureMap(l),T=this._generateKey(o,r),P=p.getListWithColor(h),R=F.getCellValueOrigin(d),L=`${R!=null?R:""}`,k=P.find(v=>v.label===L);let{tb:U,vt:E,ht:W,pd:X}=s||{};if(U=U!=null?U:i.WrapStrategy.WRAP,E=E!=null?E:i.VerticalAlign.BOTTOM,W=W!=null?W:i.DEFAULT_STYLES.ht,X=X!=null?X:i.DEFAULT_STYLES.pd,h.renderMode===i.DataValidationRenderMode.ARROW){const{l:v=i.DEFAULT_STYLES.pd.l,t:y=i.DEFAULT_STYLES.pd.t,r:_=i.DEFAULT_STYLES.pd.r,b:A=i.DEFAULT_STYLES.pd.b}=X,b=M-v-_-ce-4,{documentSkeleton:H,documents:G,docModel:J}=Ne(L,this._localeService,s);U===i.WrapStrategy.WRAP&&J.updateDocumentDataPageSize(Math.max(b,1)),H.calculate(),H.getActualSize();const te=q.getDocsSkeletonPageSize(H),{height:ne,width:ae}=te,{paddingTop:$,paddingLeft:O}=bt(b,I-y-A,ae,ne,E,W,!0);this._drawDownIcon(e,V,M,I,ne,E,X),e.save(),e.translateWithPrecision(V.startX+v,V.startY+y),e.beginPath(),e.rect(0,0,M-v-_,I-y-A),e.clip(),e.translateWithPrecision(0,$),e.save(),e.translateWithPrecision(Se,0),e.beginPath(),e.rect(0,0,b,ne),e.clip(),G.render(e),e.translateWithPrecision(O,0),e.restore(),e.restore(),x.set(T,{left:V.endX+v+a.rowHeaderWidth-ce,top:V.startY+y+a.columnHeaderHeight,width:ce,height:I-y-A})}else{e.save(),e.translateWithPrecision(V.startX,V.startY),e.beginPath(),e.rect(0,0,M,I),e.clip();const v=M-ue*2-Se-ce-4,{documentSkeleton:y,documents:_,docModel:A}=Ne(L,this._localeService,s);U===i.WrapStrategy.WRAP&&A.updateDocumentDataPageSize(Math.max(v,1)),y.calculate();const b=q.getDocsSkeletonPageSize(y),{height:H,width:G}=b,{paddingTop:J,paddingLeft:te}=bt(v,I,G,H,E,W);e.translateWithPrecision(ue,J);const ne=Math.max(M-ue*2,1),ae=H;q.Rect.drawWith(e,{width:ne,height:ae,fill:(k==null?void 0:k.color)||Ie,radius:rt}),e.save(),e.translateWithPrecision(Se,0),e.beginPath(),e.rect(0,0,v,H),e.clip(),e.translateWithPrecision(te,0),_.render(e),e.restore(),e.translateWithPrecision(v+Se+4,(H-Ue)/2),e.fillStyle=To,e.fill(Et),e.restore(),x.set(T,{left:V.startX+ue+a.rowHeaderWidth,top:V.startY+J+a.columnHeaderHeight,width:ne,height:ae})}}calcCellAutoHeight(e){var I;const{primaryWithCoord:t,style:a,data:n}=e,o=t.isMergedMainCell?t.mergeInfo:t,r=n.fontRenderExtension,{leftOffset:s=0,rightOffset:d=0,topOffset:l=0,downOffset:u=0}=r||{},h=(I=n.dataValidation)==null?void 0:I.rule;if(!h||h.renderMode===i.DataValidationRenderMode.TEXT)return;const p={startX:o.startX+s,endX:o.endX-d,startY:o.startY+l,endY:o.endY-u},c=p.endX-p.startX,C=F.getCellValueOrigin(n),g=`${C!=null?C:""}`;let{tb:f,pd:w}=a||{};const{t:V=i.DEFAULT_STYLES.pd.t,b:M=i.DEFAULT_STYLES.pd.b}=w!=null?w:{};if(f=f!=null?f:i.WrapStrategy.WRAP,h.renderMode===i.DataValidationRenderMode.ARROW){const x=c-ce,{documentSkeleton:T,docModel:P}=Ne(g,this._localeService,a);f===i.WrapStrategy.WRAP&&P.updateDocumentDataPageSize(Math.max(x,1)),T.calculate(),T.getActualSize();const R=q.getDocsSkeletonPageSize(T),{height:L}=R;return L+V+M+we*2}else{const x=c-ue*2-Se-ce,{documentSkeleton:T,docModel:P}=nn(g,this._localeService,a);f===i.WrapStrategy.WRAP&&P.updateDocumentDataPageSize(Math.max(x,1)),T.calculate();const R=q.getDocsSkeletonPageSize(T),{height:L}=R;return L+we*2}}calcCellAutoWidth(e){var L;const{primaryWithCoord:t,style:a,data:n}=e,o=t.isMergedMainCell?t.mergeInfo:t,r=n.fontRenderExtension,{leftOffset:s=0,rightOffset:d=0,topOffset:l=0,downOffset:u=0}=r||{},h=(L=n.dataValidation)==null?void 0:L.rule;if(!h||h.renderMode===i.DataValidationRenderMode.TEXT)return;const p={startX:o.startX+s,endX:o.endX-d,startY:o.startY+l,endY:o.endY-u},c=p.endX-p.startX,C=F.getCellValueOrigin(n),g=`${C!=null?C:""}`;let{tb:f,pd:w}=a||{};const{l:V=i.DEFAULT_STYLES.pd.l,r:M=i.DEFAULT_STYLES.pd.r}=w!=null?w:{};f=f!=null?f:i.WrapStrategy.WRAP;let I=ue*2+ce;switch(h.renderMode){case i.DataValidationRenderMode.ARROW:I=ce+ue*2+M+V;break;case i.DataValidationRenderMode.CUSTOM:I=ce+ue*2+Se*2+M+V+rt/2+1;break;default:I=ce+ue*2+Se*2+M+V+rt/2+1}const x=c-I,{documentSkeleton:T,docModel:P}=Ne(g,this._localeService,a);return f===i.WrapStrategy.WRAP&&P.updateDocumentDataPageSize(Math.max(x,1)),T.calculate(),T.getActualSize(),q.getDocsSkeletonPageSize(T).width+I}isHit(e,t){const{data:a,subUnitId:n,row:o,col:r}=t,d=this._ensureMap(n).get(this._generateKey(o,r)),l=a.dataValidation;if(!l||!d||l.rule.renderMode===i.DataValidationRenderMode.TEXT)return!1;const{top:u,left:h,width:p,height:c}=d,{x:C,y:g}=e;return C>=h&&C<=h+p&&g>=u&&g<=u+c}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:r}=e,s={unitId:a,subUnitId:n,row:o,column:r};this._commandService.executeCommand(Ge.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(q.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(q.CURSOR_TYPE.DEFAULT)}};ft=Oo([it(0,i.Inject(i.LocaleService)),it(1,i.ICommandService),it(2,i.Inject(q.IRenderManagerService))],ft);class Lo extends pe{constructor(){super(...arguments);Y(this,"id",i.DataValidationType.LIST);Y(this,"canvasRender",this.injector.createInstance(ft));Y(this,"dropdown",Ze);Y(this,"optionsInput",Ye.componentKey);Y(this,"formulaInput",Ct)}}class jo extends pe{constructor(){super(...arguments);Y(this,"id",i.DataValidationType.TEXT_LENGTH);Y(this,"formulaInput",Je)}}class Ao extends pe{constructor(){super(...arguments);Y(this,"id",i.DataValidationType.WHOLE);Y(this,"formulaInput",Je)}}var $o=Object.defineProperty,xo=Object.getOwnPropertyDescriptor,Fo=(e,t,a,n)=>{for(var o=n>1?void 0:n?xo(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&$o(t,a,o),o},st=(e,t)=>(a,n)=>t(a,n,e);let be=class extends i.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[zt,Ft],[vt,_a],[Wt,Fn],[Ze,Jn],[It,yn],[Ye.componentKey,Ye],[Xe.componentKey,Xe],...ao].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[So,Ao,jo,vo,fo,Lo,Mo,mo].forEach(e=>{const t=this._injector.createInstance(e),a=this._dataValidatorRegistryService.getValidatorItem(t.id);a&&(a.formulaInput=t.formulaInput,a.canvasRender=t.canvasRender,a.dropdown=t.dropdown,a.optionsInput=t.optionsInput)})}};be=Fo([st(0,i.Inject(i.Injector)),st(1,i.Inject(ee.ComponentManager)),st(2,i.Inject(ie.DataValidatorRegistryService))],be);var Uo=Object.defineProperty,No=Object.getOwnPropertyDescriptor,ko=(e,t,a,n)=>{for(var o=n>1?void 0:n?No(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Uo(t,a,o),o},lt=(e,t)=>(a,n)=>t(a,n,e);const Bo="SHEET_DATA_VALIDATION_UI_PLUGIN";var ke;exports.UniverSheetsDataValidationUIPlugin=(ke=class extends i.Plugin{constructor(t=Xt,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(_t,s)}onStarting(){[[he],[me],[Le],[Re],[Ee],[Me],[Ve],[Pe],[be]].forEach(t=>{this._injector.add(t)}),[qe,Ge,Yt,St,Ce,Ht].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ve),this._injector.get(Me),this._injector.get(Pe),this._injector.get(Le),this._injector.get(q.IRenderManagerService).registerRenderModule(i.UniverInstanceType.UNIVER_SHEET,[He])}onRendered(){this._injector.get(be),this._injector.get(Ee)}onSteady(){this._injector.get(Re)}},Y(ke,"pluginName",Bo),Y(ke,"type",i.UniverInstanceType.UNIVER_SHEET),ke);exports.UniverSheetsDataValidationUIPlugin=ko([lt(1,i.Inject(i.Injector)),lt(2,i.ICommandService),lt(3,i.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);var Wo=Object.defineProperty,Ho=Object.getOwnPropertyDescriptor,Yo=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ho(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Wo(t,a,o),o},dt=(e,t)=>(a,n)=>t(a,n,e);const Xo="SHEET_DATA_VALIDATION_UI_PLUGIN";var Be;exports.UniverSheetsDataValidationMobileUIPlugin=(Be=class extends i.Plugin{constructor(t=Xt,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(_t,s)}onStarting(){[[he],[me],[Le],[Re],[Ee],[Me],[Ve],[be]].forEach(t=>{this._injector.add(t)}),[qe,Ge,Yt,St,Ce,Ht].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ve),this._injector.get(Me),this._injector.get(q.IRenderManagerService).registerRenderModule(i.UniverInstanceType.UNIVER_SHEET,[He])}onRendered(){this._injector.get(be),this._injector.get(Ee)}onSteady(){this._injector.get(Re)}},Y(Be,"pluginName",Xo),Y(Be,"type",i.UniverInstanceType.UNIVER_SHEET),Be);exports.UniverSheetsDataValidationMobileUIPlugin=Yo([dt(1,i.Inject(i.Injector)),dt(2,i.ICommandService),dt(3,i.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);exports.DATE_DROPDOWN_KEY=It;exports.LIST_DROPDOWN_KEY=Ze;
|
package/lib/es/index.js
CHANGED
@@ -2266,7 +2266,8 @@ function Ur(t) {
|
|
2266
2266
|
},
|
2267
2267
|
errorText: l,
|
2268
2268
|
onFocus: () => u(!0),
|
2269
|
-
actions: s.current
|
2269
|
+
actions: s.current,
|
2270
|
+
isSupportAcrossSheet: !0
|
2270
2271
|
}
|
2271
2272
|
);
|
2272
2273
|
}
|
@@ -2495,7 +2496,8 @@ function Wr(t) {
|
|
2495
2496
|
},
|
2496
2497
|
errorText: N || A || void 0,
|
2497
2498
|
onFocus: () => L(!0),
|
2498
|
-
actions: Z.current
|
2499
|
+
actions: Z.current,
|
2500
|
+
isSupportAcrossSheet: !0
|
2499
2501
|
}
|
2500
2502
|
),
|
2501
2503
|
/* @__PURE__ */ p.jsx("div", { ref: u, style: { marginTop: "12px" }, children: U.map((E) => /* @__PURE__ */ p.jsx(Fn, { item: E, commonProps: { onItemChange: X }, style: { marginBottom: 12 } }, E.id)) })
|
package/lib/umd/index.js
CHANGED
@@ -6,4 +6,4 @@
|
|
6
6
|
*
|
7
7
|
* This source code is licensed under the MIT license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
|
-
*/var sn=E,ln=Symbol.for("react.element"),dn=Symbol.for("react.fragment"),cn=Object.prototype.hasOwnProperty,un=sn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,hn={key:!0,ref:!0,__self:!0,__source:!0};function Ve(t,e,a){var n,i={},r=null,s=null;a!==void 0&&(r=""+a),e.key!==void 0&&(r=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)cn.call(e,n)&&!hn.hasOwnProperty(n)&&(i[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps,e)i[n]===void 0&&(i[n]=e[n]);return{$$typeof:ln,type:t,key:r,ref:s,props:i,_owner:un.current}}At.Fragment=dn,At.jsx=Ve,At.jsxs=Ve,Me.exports=At;var m=Me.exports,Ee={exports:{}};(function(t,e){(function(a,n){t.exports=n()})(ye,function(){var a=1e3,n=6e4,i=36e5,r="millisecond",s="second",d="minute",l="hour",u="day",h="week",p="month",c="quarter",C="year",v="date",f="Invalid Date",w=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,V=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,b={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(D){var S=["th","st","nd","rd"],g=D%100;return"["+D+(S[(g-20)%10]||S[g]||S[0])+"]"}},I=function(D,S,g){var y=String(D);return!y||y.length>=S?D:""+Array(S+1-y.length).join(g)+D},F={s:I,z:function(D){var S=-D.utcOffset(),g=Math.abs(S),y=Math.floor(g/60),_=g%60;return(S<=0?"+":"-")+I(y,2,"0")+":"+I(_,2,"0")},m:function D(S,g){if(S.date()<g.date())return-D(g,S);var y=12*(g.year()-S.year())+(g.month()-S.month()),_=S.clone().add(y,p),A=g-_<0,O=S.clone().add(y+(A?-1:1),p);return+(-(y+(g-_)/(A?_-O:O-_))||0)},a:function(D){return D<0?Math.ceil(D)||0:Math.floor(D)},p:function(D){return{M:p,y:C,w:h,d:u,D:v,h:l,m:d,s,ms:r,Q:c}[D]||String(D||"").toLowerCase().replace(/s$/,"")},u:function(D){return D===void 0}},L="en",P={};P[L]=b;var M="$isDayjsObject",j=function(D){return D instanceof W||!(!D||!D[M])},k=function D(S,g,y){var _;if(!S)return L;if(typeof S=="string"){var A=S.toLowerCase();P[A]&&(_=A),g&&(P[A]=g,_=A);var O=S.split("-");if(!_&&O.length>1)return D(O[0])}else{var H=S.name;P[H]=S,_=H}return!y&&_&&(L=_),_||!y&&L},N=function(D,S){if(j(D))return D.clone();var g=typeof S=="object"?S:{};return g.date=D,g.args=arguments,new W(g)},R=F;R.l=k,R.i=j,R.w=function(D,S){return N(D,{locale:S.$L,utc:S.$u,x:S.$x,$offset:S.$offset})};var W=function(){function D(g){this.$L=k(g.locale,null,!0),this.parse(g),this.$x=this.$x||g.x||{},this[M]=!0}var S=D.prototype;return S.parse=function(g){this.$d=function(y){var _=y.date,A=y.utc;if(_===null)return new Date(NaN);if(R.u(_))return new Date;if(_ instanceof Date)return new Date(_);if(typeof _=="string"&&!/Z$/i.test(_)){var O=_.match(w);if(O){var H=O[2]-1||0,G=(O[7]||"0").substring(0,3);return A?new Date(Date.UTC(O[1],H,O[3]||1,O[4]||0,O[5]||0,O[6]||0,G)):new Date(O[1],H,O[3]||1,O[4]||0,O[5]||0,O[6]||0,G)}}return new Date(_)}(g),this.init()},S.init=function(){var g=this.$d;this.$y=g.getFullYear(),this.$M=g.getMonth(),this.$D=g.getDate(),this.$W=g.getDay(),this.$H=g.getHours(),this.$m=g.getMinutes(),this.$s=g.getSeconds(),this.$ms=g.getMilliseconds()},S.$utils=function(){return R},S.isValid=function(){return this.$d.toString()!==f},S.isSame=function(g,y){var _=N(g);return this.startOf(y)<=_&&_<=this.endOf(y)},S.isAfter=function(g,y){return N(g)<this.startOf(y)},S.isBefore=function(g,y){return this.endOf(y)<N(g)},S.$g=function(g,y,_){return R.u(g)?this[y]:this.set(_,g)},S.unix=function(){return Math.floor(this.valueOf()/1e3)},S.valueOf=function(){return this.$d.getTime()},S.startOf=function(g,y){var _=this,A=!!R.u(y)||y,O=R.p(g),H=function(z,B){var q=R.w(_.$u?Date.UTC(_.$y,B,z):new Date(_.$y,B,z),_);return A?q:q.endOf(u)},G=function(z,B){return R.w(_.toDate()[z].apply(_.toDate("s"),(A?[0,0,0,0]:[23,59,59,999]).slice(B)),_)},Q=this.$W,nt=this.$M,at=this.$D,it="set"+(this.$u?"UTC":"");switch(O){case C:return A?H(1,0):H(31,11);case p:return A?H(1,nt):H(0,nt+1);case h:var $=this.$locale().weekStart||0,T=(Q<$?Q+7:Q)-$;return H(A?at-T:at+(6-T),nt);case u:case v:return G(it+"Hours",0);case l:return G(it+"Minutes",1);case d:return G(it+"Seconds",2);case s:return G(it+"Milliseconds",3);default:return this.clone()}},S.endOf=function(g){return this.startOf(g,!1)},S.$set=function(g,y){var _,A=R.p(g),O="set"+(this.$u?"UTC":""),H=(_={},_[u]=O+"Date",_[v]=O+"Date",_[p]=O+"Month",_[C]=O+"FullYear",_[l]=O+"Hours",_[d]=O+"Minutes",_[s]=O+"Seconds",_[r]=O+"Milliseconds",_)[A],G=A===u?this.$D+(y-this.$W):y;if(A===p||A===C){var Q=this.clone().set(v,1);Q.$d[H](G),Q.init(),this.$d=Q.set(v,Math.min(this.$D,Q.daysInMonth())).$d}else H&&this.$d[H](G);return this.init(),this},S.set=function(g,y){return this.clone().$set(g,y)},S.get=function(g){return this[R.p(g)]()},S.add=function(g,y){var _,A=this;g=Number(g);var O=R.p(y),H=function(nt){var at=N(A);return R.w(at.date(at.date()+Math.round(nt*g)),A)};if(O===p)return this.set(p,this.$M+g);if(O===C)return this.set(C,this.$y+g);if(O===u)return H(1);if(O===h)return H(7);var G=(_={},_[d]=n,_[l]=i,_[s]=a,_)[O]||1,Q=this.$d.getTime()+g*G;return R.w(Q,this)},S.subtract=function(g,y){return this.add(-1*g,y)},S.format=function(g){var y=this,_=this.$locale();if(!this.isValid())return _.invalidDate||f;var A=g||"YYYY-MM-DDTHH:mm:ssZ",O=R.z(this),H=this.$H,G=this.$m,Q=this.$M,nt=_.weekdays,at=_.months,it=_.meridiem,$=function(B,q,lt,Ot){return B&&(B[q]||B(y,A))||lt[q].slice(0,Ot)},T=function(B){return R.s(H%12||12,B,"0")},z=it||function(B,q,lt){var Ot=B<12?"AM":"PM";return lt?Ot.toLowerCase():Ot};return A.replace(V,function(B,q){return q||function(lt){switch(lt){case"YY":return String(y.$y).slice(-2);case"YYYY":return R.s(y.$y,4,"0");case"M":return Q+1;case"MM":return R.s(Q+1,2,"0");case"MMM":return $(_.monthsShort,Q,at,3);case"MMMM":return $(at,Q);case"D":return y.$D;case"DD":return R.s(y.$D,2,"0");case"d":return String(y.$W);case"dd":return $(_.weekdaysMin,y.$W,nt,2);case"ddd":return $(_.weekdaysShort,y.$W,nt,3);case"dddd":return nt[y.$W];case"H":return String(H);case"HH":return R.s(H,2,"0");case"h":return T(1);case"hh":return T(2);case"a":return z(H,G,!0);case"A":return z(H,G,!1);case"m":return String(G);case"mm":return R.s(G,2,"0");case"s":return String(y.$s);case"ss":return R.s(y.$s,2,"0");case"SSS":return R.s(y.$ms,3,"0");case"Z":return O}return null}(B)||O.replace(":","")})},S.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},S.diff=function(g,y,_){var A,O=this,H=R.p(y),G=N(g),Q=(G.utcOffset()-this.utcOffset())*n,nt=this-G,at=function(){return R.m(O,G)};switch(H){case C:A=at()/12;break;case p:A=at();break;case c:A=at()/3;break;case h:A=(nt-Q)/6048e5;break;case u:A=(nt-Q)/864e5;break;case l:A=nt/i;break;case d:A=nt/n;break;case s:A=nt/a;break;default:A=nt}return _?A:R.a(A)},S.daysInMonth=function(){return this.endOf(p).$D},S.$locale=function(){return P[this.$L]},S.locale=function(g,y){if(!g)return this.$L;var _=this.clone(),A=k(g,y,!0);return A&&(_.$L=A),_},S.clone=function(){return R.w(this.$d,this)},S.toDate=function(){return new Date(this.valueOf())},S.toJSON=function(){return this.isValid()?this.toISOString():null},S.toISOString=function(){return this.$d.toISOString()},S.toString=function(){return this.$d.toUTCString()},D}(),X=W.prototype;return N.prototype=X,[["$ms",r],["$s",s],["$m",d],["$H",l],["$W",u],["$M",p],["$y",C],["$D",v]].forEach(function(D){X[D[1]]=function(S){return this.$g(S,D[0],D[1])}}),N.extend=function(D,S){return D.$i||(D(S,W,N),D.$i=!0),N},N.locale=k,N.isDayjs=j,N.unix=function(D){return N(1e3*D)},N.en=P[L],N.Ls=P,N.p={},N})})(Ee);var pn=Ee.exports;const $t=we(pn);var be={exports:{}};(function(t,e){(function(a,n){t.exports=n()})(ye,function(){var a="minute",n=/[+-]\d\d(?::?\d\d)?/g,i=/([+-]|\d\d)/g;return function(r,s,d){var l=s.prototype;d.utc=function(f){var w={date:f,utc:!0,args:arguments};return new s(w)},l.utc=function(f){var w=d(this.toDate(),{locale:this.$L,utc:!0});return f?w.add(this.utcOffset(),a):w},l.local=function(){return d(this.toDate(),{locale:this.$L,utc:!1})};var u=l.parse;l.parse=function(f){f.utc&&(this.$u=!0),this.$utils().u(f.$offset)||(this.$offset=f.$offset),u.call(this,f)};var h=l.init;l.init=function(){if(this.$u){var f=this.$d;this.$y=f.getUTCFullYear(),this.$M=f.getUTCMonth(),this.$D=f.getUTCDate(),this.$W=f.getUTCDay(),this.$H=f.getUTCHours(),this.$m=f.getUTCMinutes(),this.$s=f.getUTCSeconds(),this.$ms=f.getUTCMilliseconds()}else h.call(this)};var p=l.utcOffset;l.utcOffset=function(f,w){var V=this.$utils().u;if(V(f))return this.$u?0:V(this.$offset)?p.call(this):this.$offset;if(typeof f=="string"&&(f=function(L){L===void 0&&(L="");var P=L.match(n);if(!P)return null;var M=(""+P[0]).match(i)||["-",0,0],j=M[0],k=60*+M[1]+ +M[2];return k===0?0:j==="+"?k:-k}(f),f===null))return this;var b=Math.abs(f)<=16?60*f:f,I=this;if(w)return I.$offset=b,I.$u=f===0,I;if(f!==0){var F=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(I=this.local().add(b+F,a)).$offset=b,I.$x.$localOffset=F}else I=this.utc();return I};var c=l.format;l.format=function(f){var w=f||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return c.call(this,w)},l.valueOf=function(){var f=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*f},l.isUTC=function(){return!!this.$u},l.toISOString=function(){return this.toDate().toISOString()},l.toString=function(){return this.toDate().toUTCString()};var C=l.toDate;l.toDate=function(f){return f==="s"&&this.$offset?d(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():C.call(this)};var v=l.diff;l.diff=function(f,w,V){if(f&&this.$u===f.$u)return v.call(this,f,w,V);var b=this.local(),I=d(f).local();return v.call(b,I,w,V)}}})})(be);var fn=be.exports;const mn=we(fn);var vn=Object.defineProperty,gn=Object.getOwnPropertyDescriptor,Sn=(t,e,a,n)=>{for(var i=n>1?void 0:n?gn(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&vn(e,a,i),i},Tt=(t,e)=>(a,n)=>e(a,n,t);let Lt=class extends o.Disposable{constructor(t,e,a,n,i){super(),this._sheetInterceptorService=t,this._dataValidationModel=e,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(tt.AFTER_CELL_EDIT_ASYNC,{handler:async(t,e,a)=>{var f;const n=await t,{worksheet:i,row:r,col:s,unitId:d,subUnitId:l,workbook:u}=e,h=this._dataValidationModel.getRuleIdByLocation(d,l,r,s),p=h?this._dataValidationModel.getRuleById(d,l,h):void 0;if(!p||p.errorStyle!==o.DataValidationErrorStyle.STOP)return a(Promise.resolve(n));const c=await this._dataValidatorRegistryService.getValidatorItem(p.type);if(!c||await c.validator({value:x.getCellValueOrigin(n),interceptValue:x.getCellValueOrigin((f=e==null?void 0:e.origin)!=null?f:n),row:r,column:s,unitId:d,subUnitId:l,worksheet:i,workbook:u,t:n==null?void 0:n.t},p))return a(Promise.resolve(n));const v=i.getCellRaw(r,s);return this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:c.getRuleFinalError(p,{row:r,col:s,unitId:d,subUnitId:l})},footer:{title:E.createElement(U.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(Promise.resolve(v))}})}showReject(t){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:t},footer:{title:E.createElement(U.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Lt=Sn([Tt(0,o.Inject(tt.SheetInterceptorService)),Tt(1,o.Inject(x.SheetDataValidationModel)),Tt(2,o.Inject(ot.DataValidatorRegistryService)),Tt(3,et.IDialogService),Tt(4,o.Inject(o.LocaleService))],Lt);const Re={dvDateDropdown:"univer-dv-date-dropdown",dvDateDropdownBtns:"univer-dv-date-dropdown-btns"};$t.extend(mn);const _n=t=>{if(t==null||typeof t=="boolean")return;if(typeof t=="number"||!Number.isNaN(+t))return $t(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(t)));const e=$t(t);if(e.isValid())return e};function In(t){var P,M,j;const{location:e,hideFn:a}=t,{worksheet:n,row:i,col:r,unitId:s,subUnitId:d,workbook:l}=e,u=o.useDependency(o.ICommandService),h=o.useDependency(Lt),p=n.getCell(i,r),c=(P=p==null?void 0:p.dataValidation)==null?void 0:P.rule,C=(M=p==null?void 0:p.dataValidation)==null?void 0:M.validator,v=x.getCellValueOrigin(n.getCellRaw(i,r)),f=_n(v),[w,V]=E.useState(f),b=!!((j=c==null?void 0:c.bizInfo)!=null&&j.showTime),I=w&&w.isValid()?w:$t(),F=o.useDependency(o.LocaleService);if(!p||!c||!C)return;const L=async()=>{var S,g,y;if(!I)return;const N=I.format(b?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),R=(S=o.numfmt.parseDate(N))==null?void 0:S.v,W=l.getStyles().getStyleByCell(p),X=(y=(g=W==null?void 0:W.n)==null?void 0:g.pattern)!=null?y:"",D=on.getPatternType(X);c.errorStyle!==o.DataValidationErrorStyle.STOP||await C.validator({value:R,unitId:s,subUnitId:d,row:i,column:r,worksheet:n,workbook:l,interceptValue:N.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(a(),await u.executeCommand(K.SetCellEditVisibleOperation.id,{visible:!1,eventType:Z.DeviceInputEventType.Keyboard,unitId:s,keycode:et.KeyCode.ESC}),await u.executeCommand(tt.SetRangeValuesCommand.id,{unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:R,t:2,p:null,f:null,si:null,s:{n:{pattern:b?D==="datetime"?X:"yyyy-MM-dd hh:mm:ss":D==="date"?X:"yyyy-MM-dd"}}}})):h.showReject(C.getRuleFinalError(c,{row:i,col:r,unitId:s,subUnitId:d}))};return m.jsxs("div",{className:Re.dvDateDropdown,children:[m.jsx(U.DatePanel,{defaultValue:I,pickerValue:I,showTime:b||void 0,onSelect:async k=>{V(k)},onPanelChange:k=>{V(k)},disabledDate:k=>!o.numfmt.parseDate(k.format("YYYY-MM-DD"))}),m.jsx("div",{className:Re.dvDateDropdownBtns,children:m.jsx(U.Button,{size:"small",type:"primary",onClick:L,disabled:!I.isValid(),children:F.t("dataValidation.alert.ok")})})]})}var ct=function(){return ct=Object.assign||function(t){for(var e,a=1,n=arguments.length;a<n;a++){e=arguments[a];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},ct.apply(this,arguments)},Cn=function(t,e){var a={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(a[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(a[n[i]]=t[n[i]]);return a},vt=E.forwardRef(function(t,e){var a=t.icon,n=t.id,i=t.className,r=t.extend,s=Cn(t,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),l=E.useRef("_".concat(wn()));return Oe(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},ct({ref:e,className:d},s),r)});function Oe(t,e,a,n,i){return E.createElement(t.tag,ct(ct({key:e},Dn(t,a,i)),n),(yn(t,a).children||[]).map(function(r,s){return Oe(r,"".concat(e,"-").concat(t.tag,"-").concat(s),a,void 0,i)}))}function Dn(t,e,a){var n=ct({},t.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1);var i=e.defIds;return!i||i.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],d=r[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function yn(t,e){var a,n=e.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((a=t.children)===null||a===void 0)&&a.length)?ct(ct({},t),{children:t.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?ct(ct({},i),{attrs:ct(ct({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):t}function wn(){return Math.random().toString(36).substring(2,8)}vt.displayName="UniverIcon";var Mn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Te=E.forwardRef(function(t,e){return E.createElement(vt,Object.assign({},t,{id:"check-mark-single",ref:e,icon:Mn}))});Te.displayName="CheckMarkSingle";var Vn={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"}}]},Le=E.forwardRef(function(t,e){return E.createElement(vt,Object.assign({},t,{id:"data-validation-single",ref:e,icon:Vn}))});Le.displayName="DataValidationSingle";var En={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"}}]},ne=E.forwardRef(function(t,e){return E.createElement(vt,Object.assign({},t,{id:"delete-single",ref:e,icon:En}))});ne.displayName="DeleteSingle";var bn={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"}}]},Pe=E.forwardRef(function(t,e){return E.createElement(vt,Object.assign({},t,{id:"increase-single",ref:e,icon:bn}))});Pe.displayName="IncreaseSingle";var Rn={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"}}]},je=E.forwardRef(function(t,e){return E.createElement(vt,Object.assign({},t,{id:"more-down-single",ref:e,icon:Rn}))});je.displayName="MoreDownSingle";var On={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"}}]},Ae=E.forwardRef(function(t,e){return E.createElement(vt,Object.assign({},t,{id:"more-up-single",ref:e,icon:On}))});Ae.displayName="MoreUpSingle";var Tn={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"}}]}]},$e=E.forwardRef(function(t,e){return E.createElement(vt,Object.assign({},t,{id:"sequence-single",ref:e,icon:Tn}))});$e.displayName="SequenceSingle";var Ln=Object.defineProperty,Pn=Object.getOwnPropertyDescriptor,jn=(t,e,a,n)=>{for(var i=n>1?void 0:n?Pn(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&Ln(e,a,i),i},Fe=(t,e)=>(a,n)=>e(a,n,t);let ht=class extends o.Disposable{constructor(e,a){super();Y(this,"_open$",new dt.BehaviorSubject(!1));Y(this,"open$",this._open$.pipe(dt.distinctUntilChanged()));Y(this,"_activeRule");Y(this,"_activeRule$",new dt.BehaviorSubject(void 0));Y(this,"activeRule$",this._activeRule$.asObservable());Y(this,"_closeDisposable",null);this._univerInstanceService=e,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(dt.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===ae&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var e;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(e=this._closeDisposable)==null||e.dispose()}open(){this._open$.next(!0)}close(){var e;this._open$.next(!1),(e=this._closeDisposable)==null||e.dispose()}setCloseDisposable(e){this._closeDisposable=o.toDisposable(()=>{e.dispose(),this._closeDisposable=null})}setActiveRule(e){this._activeRule=e,this._activeRule$.next(e)}};ht=jn([Fe(0,o.IUniverInstanceService),Fe(1,et.ISidebarService)],ht);function An(){const t=o.useDependency(gt),e=et.useObservable(t.activeDropdown$,t.activeDropdown),a=o.useDependency(et.ComponentManager);if(!e)return null;const{location:n,componentKey:i}=e,r=a.get(i),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!r)return null;const d=()=>{t.hideDropdown()};return m.jsx(r,{location:n,hideFn:d},s)}const xe="sheet.ui.dropdown";var $n=Object.defineProperty,Fn=Object.getOwnPropertyDescriptor,xn=(t,e,a,n)=>{for(var i=n>1?void 0:n?Fn(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&$n(e,a,i),i},St=(t,e)=>(a,n)=>e(a,n,t);let gt=class extends o.Disposable{constructor(e,a,n,i,r,s,d){super();Y(this,"_activeDropdown");Y(this,"_activeDropdown$",new dt.Subject);Y(this,"_currentPopup",null);Y(this,"activeDropdown$",this._activeDropdown$.asObservable());Y(this,"_zenVisible",!1);this._canvasPopupManagerService=e,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=i,this._renderManagerService=r,this._dataValidationModel=s,this._sheetsSelectionsService=d,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{this._zenVisible=e,e&&this.hideDropdown()}))}_getDropdownByCell(e,a,n,i){const r=e?this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!r)return;const s=a?r.getSheetBySheetId(a):r.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(r.getUnitId(),s.getSheetId(),n,i);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdown}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(e=>{e&&e.every(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(e,a=!0){const{location:n}=e,{row:i,col:r,unitId:s,subUnitId:d}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=e,this._activeDropdown$.next(this._activeDropdown);const l=this._renderManagerService.getRenderById(o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),u=this._canvasPopupManagerService.attachPopupToCell(i,r,{componentKey:xe,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[l==null?void 0:l.engine.getCanvasElement()].filter(Boolean)},s,d);if(!u)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const h=new o.DisposableCollection;h.add(u),h.add({dispose:()=>{var p,c;(c=(p=this._activeDropdown)==null?void 0:p.onHide)==null||c.call(p)}}),this._currentPopup=h}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(e,a,n,i,r){const s=this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(a);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,i);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!u||!u.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:i,unitId:e,subUnitId:a},componentKey:u.dropdown,onHide:r})}};gt=xn([St(0,o.Inject(K.SheetCanvasPopManagerService)),St(1,o.IUniverInstanceService),St(2,o.Inject(ot.DataValidatorRegistryService)),St(3,et.IZenZoneService),St(4,Z.IRenderManagerService),St(5,o.Inject(x.SheetDataValidationModel)),St(6,o.Inject(tt.SheetsSelectionsService))],gt);const ae="DataValidationPanel",_t={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(t,e){if(!e)return!1;const{ruleId:a,isAdd:n}=e,i=t.get(ht),r=t.get(ot.DataValidationModel),s=t.get(o.IUniverInstanceService),d=t.get(et.ISidebarService),l=tt.getSheetCommandTarget(s);if(!l)return!1;const{unitId:u,subUnitId:h}=l,p=a?r.getRuleById(u,h,a):void 0;i.open(),i.setActiveRule(p&&{unitId:u,subUnitId:h,rule:p});const c=d.open({header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:ae},width:312,onClose:()=>i.close()});return i.setCloseDisposable(c),!0}},ie={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(t){return t.get(ht).close(),!0}},Ne={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(t){const e=t.get(o.ICommandService),a=t.get(ht);return a.open(),a.isOpen?e.executeCommand(ie.id):e.executeCommand(_t.id),!0}},Ft={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(t,e){if(!e)return!1;const a=t.get(gt),{unitId:n,subUnitId:i,row:r,column:s}=e,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===i&&l.row===r&&l.col===s||a.showDataValidationDropdown(n,i,r,s),!0}},Ue={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(t,e){return e?(t.get(gt).hideDropdown(),!0):!1}},It="#ECECEC",oe="sheets-data-validation-ui.config",ke={},mt={dvListDropdown:"univer-dv-list-dropdown",dvListDropdownTitle:"univer-dv-list-dropdown-title",dvListDropdownList:"univer-dv-list-dropdown-list",dvListDropdownListContainer:"univer-dv-list-dropdown-list-container",dvListDropdownSelectedIcon:"univer-dv-list-dropdown-selected-icon",dvListDropdownItemContainer:"univer-dv-list-dropdown-item-container",dvListDropdownItem:"univer-dv-list-dropdown-item",dvListDropdownSplit:"univer-dv-list-dropdown-split",dvListDropdownEdit:"univer-dv-list-dropdown-edit"},Nn=t=>{var L,P;const{value:e,onChange:a,multiple:n,options:i,title:r,onEdit:s,style:d,filter:l,location:u}=t,h=o.useDependency(o.LocaleService),p=o.useDependency(o.IConfigService),c=l==null?void 0:l.toLowerCase(),{row:C,col:v,unitId:f,subUnitId:w}=u,V=i.filter(M=>c?M.label.toLowerCase().includes(c):!0),b=(P=(L=p.getConfig(oe))==null?void 0:L.showEditOnDropdown)!=null?P:!0,I=o.useDependency(K.SheetPermissionInterceptorBaseController),F=E.useMemo(()=>I.permissionCheckWithRanges({workbookTypes:[tt.WorkbookEditablePermission],rangeTypes:[tt.RangeProtectionPermissionEditPoint],worksheetTypes:[tt.WorksheetEditPermission]},[{startColumn:v,startRow:C,endColumn:v,endRow:C}],f,w),[I,v,C,f,w]);return m.jsxs("div",{className:mt.dvListDropdown,style:d,children:[m.jsx("div",{className:mt.dvListDropdownTitle,children:r}),m.jsx("div",{className:mt.dvListDropdownList,children:m.jsx(U.Scrollbar,{children:m.jsx("div",{className:mt.dvListDropdownListContainer,children:V.map((M,j)=>{const k=e.indexOf(M.value)>-1,N=()=>{let W;k?W=new Set(e.filter(D=>D!==M.value)):W=new Set(n?[...e,M.value]:[M.value]);const X=[];i.forEach(D=>{W.has(D.value)&&X.push(D.value)}),a(X)},R=M.label.toLocaleLowerCase().indexOf(c);return m.jsxs("div",{className:mt.dvListDropdownItemContainer,onClick:N,children:[m.jsx("div",{className:mt.dvListDropdownItem,style:{background:M.color||It},children:c&&M.label.toLowerCase().includes(c)?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:M.label.substring(0,R)}),m.jsx("span",{style:{fontWeight:"bold"},children:M.label.substring(R,R+c.length)}),m.jsx("span",{children:M.label.substring(R+c.length)})]}):M.label}),m.jsx("div",{className:mt.dvListDropdownSelectedIcon,children:k?m.jsx(Te,{}):null})]},j)})})},l)}),b&&F?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:mt.dvListDropdownSplit}),m.jsx("div",{className:mt.dvListDropdownEdit,children:m.jsx("a",{onClick:s,children:h.t("dataValidation.list.edit")})})]}):null]})};function Un(t){var D,S,g,y,_,A;const{location:e,hideFn:a}=t,{worksheet:n,row:i,col:r,unitId:s,subUnitId:d}=e,l=o.useDependency(ot.DataValidationModel),[u,h]=E.useState(""),p=o.useDependency(o.ICommandService),c=o.useDependency(o.LocaleService),[C,v]=E.useState(""),f=o.useDependency(K.IEditorBridgeService),w=o.useDependency(o.IUniverInstanceService),V=E.useMemo(()=>l.ruleChange$.pipe(dt.debounceTime(16)),[]);et.useObservable(V);const b=et.RectPopup.useContext(),I=((S=(D=b.current)==null?void 0:D.right)!=null?S:0)-((y=(g=b.current)==null?void 0:g.left)!=null?y:0);if(E.useEffect(()=>{const O=p.onCommandExecuted(H=>{var G,Q;if(H.id===rn.RichTextEditingMutation.id){const nt=H.params,{unitId:at}=nt,it=w.getUnit(at,o.UniverInstanceType.UNIVER_DOC);if(!it)return;const $=o.BuildTextUtils.transform.getPlainText((Q=(G=it.getSnapshot().body)==null?void 0:G.dataStream)!=null?Q:"");h($)}});return()=>{O.dispose()}},[p,w]),!n)return null;const F=n.getCell(i,r),L=(_=F==null?void 0:F.dataValidation)==null?void 0:_.rule,P=(A=F==null?void 0:F.dataValidation)==null?void 0:A.validator,M=(L==null?void 0:L.renderMode)===o.DataValidationRenderMode.CUSTOM||(L==null?void 0:L.renderMode)===void 0;if(!F||!L||!P||P.id.indexOf(o.DataValidationType.LIST)!==0)return;const j=L.type===o.DataValidationType.LIST_MULTIPLE,k=P.getListWithColor(L,s,d),N=C||x.getDataValidationCellValue(n.getCellRaw(i,r)),R=x.deserializeListOptions(N),W=()=>{p.executeCommand(_t.id,{ruleId:L.uid}),a()},X=k.map(O=>({label:O.label,value:O.label,color:M||O.color?O.color:"transparent"}));return m.jsx(Nn,{style:{minWidth:I,maxWidth:Math.max(I,200)},title:j?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:R,multiple:j,onChange:async O=>{const H=x.serializeListOptions(O),G={unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:H,p:null,f:null,si:null}};f.isVisible()&&f.changeVisible({visible:!1,keycode:et.KeyCode.ESC,eventType:Z.DeviceInputEventType.Keyboard,unitId:s}),v(H),j||a(),f.isVisible().visible&&await p.executeCommand(K.SetCellEditVisibleOperation.id,{visible:!1,eventType:Z.DeviceInputEventType.Keyboard,unitId:s,keycode:et.KeyCode.ESC}),p.executeCommand(tt.SetRangeValuesCommand.id,G)},options:X,onEdit:W,filter:u,location:e})}const re={dataValidationOptionsButton:"univer-data-validation-options-button",dataValidationOptionsButtonIcon:"univer-data-validation-options-button-icon"};function kn(t){var u;const e=o.useDependency(o.LocaleService),a=o.useDependency(et.ComponentManager),{value:n,onChange:i,extraComponent:r}=t,[s,d]=E.useState(!1),l=r?a.get(r):null;return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:re.dataValidationOptionsButton,onClick:()=>d(!s),children:[e.t("dataValidation.panel.options"),s?m.jsx(Ae,{className:re.dataValidationOptionsButtonIcon}):m.jsx(je,{className:re.dataValidationOptionsButtonIcon})]}),s&&m.jsxs(m.Fragment,{children:[l?m.jsx(l,{value:n,onChange:i}):null,m.jsx(U.FormLayout,{label:e.t("dataValidation.panel.invalid"),children:m.jsxs(U.RadioGroup,{value:`${(u=n.errorStyle)!=null?u:o.DataValidationErrorStyle.WARNING}`,onChange:h=>i({...n,errorStyle:+h}),children:[m.jsx(U.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:e.t("dataValidation.panel.showWarning")}),m.jsx(U.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:e.t("dataValidation.panel.rejectInput")})]})}),m.jsx(U.FormLayout,{label:e.t("dataValidation.panel.messageInfo"),children:m.jsx(U.Checkbox,{checked:n.showErrorMessage,onChange:()=>i({...n,showErrorMessage:!n.showErrorMessage}),children:e.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?m.jsx(U.FormLayout,{children:m.jsx(U.Input,{value:n.error,onChange:h=>i({...n,error:h})})}):null]})]})}const yt={dataValidationDetail:"univer-data-validation-detail",dataValidationDetailFormItem:"univer-data-validation-detail-form-item",dataValidationDetailButtons:"univer-data-validation-detail-buttons",dataValidationDetailButton:"univer-data-validation-detail-button"},Bn=t=>o.debounce(async(e,a,n,i)=>{const r=await t.executeCommand(e,a,n);i==null||i(r)},1e3);function Wn(t,e,a){var n,i,r,s;return e?((i=(n=t.getUnit(e))==null?void 0:n.getSheetBySheetName(a))==null?void 0:i.getSheetId())||"":((s=(r=t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Hn(){var it;const[t,e]=E.useState(0),a=o.useDependency(ht),n=et.useObservable(a.activeRule$,a.activeRule),{unitId:i,subUnitId:r,rule:s}=n||{},d=s.uid,l=o.useDependency(ot.DataValidatorRegistryService),u=o.useDependency(o.IUniverInstanceService),h=o.useDependency(et.ComponentManager),p=o.useDependency(o.ICommandService),c=o.useDependency(ot.DataValidationModel),C=o.useDependency(o.LocaleService),[v,f]=E.useState(s),w=l.getValidatorItem(v.type),[V,b]=E.useState(!1),I=l.getValidatorsByScope(ot.DataValidatorRegistryScope.SHEET),[F,L]=E.useState(()=>v.ranges.map($=>({unitId:"",sheetId:"",range:$}))),P=E.useMemo(()=>Bn(p),[p]),[M,j]=E.useState(!1),k=E.useRef({}),[N,R]=E.useState(!1),W=o.useDependency(tt.SheetsSelectionsService);if(E.useEffect(()=>()=>{const $=W.getCurrentLastSelection();$&&W.setSelections([$])},[W]),E.useEffect(()=>{p.onCommandExecuted($=>{($.id===o.UndoCommand.id||$.id===o.RedoCommand.id)&&setTimeout(()=>{const T=c.getRuleById(i,r,d);e(z=>z+1),T&&(f(T),L(T.ranges.map(z=>({unitId:"",sheetId:"",range:z}))))},20)})},[p,c,d,r,i]),!w)return null;const X=w.operators,D=w.operatorNames,S=v.operator?ot.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,g=()=>{!v.ranges.length||M||(w.validatorFormula(v,i,r).success?a.setActiveRule(null):b(!0))},y=et.useEvent($=>{const T=$.split(",").map(te.deserializeRangeWithSheet).map(q=>{const lt=q.sheetName;if(lt){const Ot=Wn(u,q.unitId,lt);return{...q,sheetId:Ot}}return{...q,sheetId:""}});if(o.isUnitRangesEqual(T,F))return;L(T);const z=T.filter(q=>(!q.unitId||q.unitId===i)&&(!q.sheetId||q.sheetId===r)).map(q=>q.range);if(f({...v,ranges:z}),z.length===0)return;const B={unitId:i,subUnitId:r,ruleId:d,ranges:z};P(x.UpdateSheetDataValidationRangeCommand.id,B)}),_=$=>{if(o.shallowEqual($,ot.getRuleSetting(v)))return;f({...v,...$});const T={unitId:i,subUnitId:r,ruleId:d,setting:$};P(x.UpdateSheetDataValidationSettingCommand.id,T,void 0)},A=async()=>{await p.executeCommand(x.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:i,subUnitId:r}),a.setActiveRule(null)},O={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},H=$=>{const T=l.getValidatorItem($);if(!T)return;const z=T.operators,B=c.getRuleById(i,r,d),q=$===(B==null?void 0:B.type)||$.includes("list")&&(B!=null&&B.type.includes("list"))?{...B,type:$}:{...v,type:$,operator:z[0],formula1:void 0,formula2:void 0};f(q),p.executeCommand(x.UpdateSheetDataValidationSettingCommand.id,{unitId:i,subUnitId:r,ruleId:v.uid,setting:ot.getRuleSetting(q)})},G=h.get(w.formulaInput),Q=E.useMemo(()=>F.map($=>te.serializeRange($.range)).join(","),[]),nt=ot.getRuleOptions(v),at=$=>{o.shallowEqual($,ot.getRuleOptions(v))||(f({...v,...$}),P(x.UpdateSheetDataValidationOptionsCommand.id,{unitId:i,subUnitId:r,ruleId:d,options:$}))};return et.useSidebarClick($=>{var z;const T=(z=k.current)==null?void 0:z.handleOutClick;T&&T($,()=>R(!1))}),m.jsxs("div",{className:yt.dataValidationDetail,children:[m.jsx(U.FormLayout,{label:C.t("dataValidation.panel.range"),error:!v.ranges.length||M?C.t("dataValidation.panel.rangeError"):"",children:m.jsx(ee.RangeSelector,{unitId:i,subUnitId:r,initValue:Q,onChange:y,onFocus:()=>R(!0),isFocus:N,actions:k.current,onVerify:$=>j(!$)})}),m.jsx(U.FormLayout,{label:C.t("dataValidation.panel.type"),children:m.jsx(U.Select,{options:I==null?void 0:I.map($=>({label:C.t($.title),value:$.id})),value:v.type,onChange:H,className:yt.dataValidationDetailFormItem})}),X!=null&&X.length?m.jsx(U.FormLayout,{label:C.t("dataValidation.panel.operator"),children:m.jsx(U.Select,{options:X.map(($,T)=>({value:`${$}`,label:D[T]})),value:`${v.operator}`,onChange:$=>{_({...O,operator:$})},className:yt.dataValidationDetailFormItem})}):null,G?m.jsx(G,{isTwoFormula:S,value:{formula1:v.formula1,formula2:v.formula2},onChange:$=>{_({...O,...$})},showError:V,validResult:w.validatorFormula(v,i,r),unitId:i,subUnitId:r,ruleId:d},t+v.type):null,m.jsx(U.FormLayout,{children:m.jsx(U.Checkbox,{checked:(it=v.allowBlank)!=null?it:!0,onChange:()=>{var $;return _({...O,allowBlank:!(($=v.allowBlank)==null||$)})},children:C.t("dataValidation.panel.allowBlank")})}),m.jsx(kn,{value:nt,onChange:at,extraComponent:w.optionsInput}),m.jsxs("div",{className:yt.dataValidationDetailButtons,children:[m.jsx(U.Button,{className:yt.dataValidationDetailButton,onClick:A,children:C.t("dataValidation.panel.removeRule")}),m.jsx(U.Button,{className:yt.dataValidationDetailButton,type:"primary",onClick:g,children:C.t("dataValidation.panel.done")})]})]})}const xt={dataValidationItemContainer:"univer-data-validation-item-container",dataValidationItemTitle:"univer-data-validation-item-title",dataValidationItemContent:"univer-data-validation-item-content",dataValidationItemIcon:"univer-data-validation-item-icon"},Yn=t=>{const{rule:e,onClick:a,unitId:n,subUnitId:i,disable:r}=t,s=o.useDependency(ot.DataValidatorRegistryService),d=o.useDependency(o.ICommandService),l=o.useDependency(K.IMarkSelectionService),u=s.getValidatorItem(e.type),h=E.useRef(),[p,c]=E.useState(!1),C=v=>{d.executeCommand(x.RemoveSheetDataValidationCommand.id,{ruleId:e.uid,unitId:n,subUnitId:i}),v.stopPropagation()};return E.useEffect(()=>()=>{var v;h.current&&((v=h.current)==null||v.forEach(f=>{f&&l.removeShape(f)}))},[l]),m.jsxs("div",{className:xt.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{r||(c(!0),h.current=e.ranges.map(v=>l.addShape({range:v,style:{hasAutoFill:!1,fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:null})))},onMouseLeave:()=>{var v;c(!1),(v=h.current)==null||v.forEach(f=>{f&&l.removeShape(f)}),h.current=void 0},children:[m.jsx("div",{className:xt.dataValidationItemTitle,children:u==null?void 0:u.generateRuleName(e)}),m.jsx("div",{className:xt.dataValidationItemContent,children:e.ranges.map(v=>te.serializeRange(v)).join(",")}),p?m.jsx("div",{className:xt.dataValidationItemIcon,onClick:C,children:m.jsx(ne,{})}):null]})},Nt={dataValidationList:"univer-data-validation-list",dataValidationListButtons:"univer-data-validation-list-buttons",dataValidationListButton:"univer-data-validation-list-button"};function Xn(){const t=o.useDependency(o.IUniverInstanceService),e=et.useObservable(()=>t.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return e?m.jsx(zn,{workbook:e}):null}function zn(t){const e=o.useDependency(x.SheetDataValidationModel),a=o.useDependency(o.IUniverInstanceService),n=o.useDependency(o.ICommandService),i=o.useDependency(o.Injector),r=o.useDependency(ht),s=o.useDependency(o.LocaleService),[d,l]=E.useState([]),{workbook:u}=t,h=et.useObservable(u.activeSheet$,void 0,!0),p=u.getUnitId(),c=h==null?void 0:h.getSheetId();E.useEffect(()=>{l(e.getRules(p,c));const b=e.ruleChange$.subscribe(I=>{I.unitId===p&&I.subUnitId===c&&l(e.getRules(p,c))});return()=>{b.unsubscribe()}},[p,c,e]);const C=async()=>{const b=x.createDefaultNewRule(i),I={unitId:p,subUnitId:c,rule:b};await n.executeCommand(x.AddSheetDataValidationCommand.id,I),r.setActiveRule({unitId:p,subUnitId:c,rule:b})},v=()=>{n.executeCommand(x.RemoveSheetAllDataValidationCommand.id,{unitId:p,subUnitId:c})},w=(b=>{const I=a.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),F=I.getActiveSheet(),L=I.getUnitId(),P=F.getSheetId();return b.map(j=>tt.checkRangesEditablePermission(i,L,P,j.ranges)?{...j}:{...j,disable:!0})})(d),V=w==null?void 0:w.some(b=>b.disable);return m.jsxs("div",{className:Nt.dataValidationList,children:[w==null?void 0:w.map(b=>{var I;return m.jsx(Yn,{unitId:p,subUnitId:c,onClick:()=>{b.disable||r.setActiveRule({unitId:p,subUnitId:c,rule:b})},rule:b,disable:(I=b.disable)!=null?I:!1},b.uid)}),m.jsxs("div",{className:Nt.dataValidationListButtons,children:[d.length&&!V?m.jsx(U.Button,{className:Nt.dataValidationListButton,onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,m.jsx(U.Button,{className:Nt.dataValidationListButton,type:"primary",onClick:C,children:s.t("dataValidation.panel.add")})]})]})}const Kn=()=>{const t=o.useDependency(ht),e=et.useObservable(t.activeRule$,t.activeRule);return e?m.jsx(Hn,{},e.rule.uid):m.jsx(Xn,{})},Ut="data-validation.list.dropdown",se="data-validation.date.dropdown",kt={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(t){const e=t.get(o.IUniverInstanceService),a=tt.getSheetCommandTarget(e);if(!a)return!1;const{workbook:n,worksheet:i}=a,r=x.createDefaultNewRule(t),s=t.get(o.ICommandService),d=n.getUnitId(),l=i.getSheetId(),u={rule:r,unitId:d,subUnitId:l};return s.syncExecuteCommand(x.AddSheetDataValidationCommand.id,u)?(s.syncExecuteCommand(_t.id,{ruleId:r.uid,isAdd:!0}),!0):!1}};var Gn=Object.defineProperty,Zn=Object.getOwnPropertyDescriptor,qn=(t,e,a,n)=>{for(var i=n>1?void 0:n?Zn(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&Gn(e,a,i),i},Pt=(t,e)=>(a,n)=>e(a,n,t);const Bt="SHEET_DATA_VALIDATION_ALERT";let jt=class extends o.Disposable{constructor(t,e,a,n,i){super(),this._hoverManagerService=t,this._cellAlertManagerService=e,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(dt.debounceTime(100)).subscribe(t=>{var e,a;if(t){const i=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!i)return;const r=i.getCell(t.location.row,t.location.col);if(((e=r==null?void 0:r.dataValidation)==null?void 0:e.validStatus)===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Bt),d=(a=s==null?void 0:s.alert)==null?void 0:a.location;if(d&&d.row===t.location.row&&d.col===t.location.col&&d.subUnitId===t.location.subUnitId&&d.unitId===t.location.unitId)return;const l=r.dataValidation.validator,u=r.dataValidation.rule;if(!l)return;this._cellAlertManagerService.showAlert({type:K.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(u,t.location),location:t.location,width:200,height:74,key:Bt});return}}this._cellAlertManagerService.removeAlert(Bt)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t&&this._cellAlertManagerService.removeAlert(Bt)}))}};jt=qn([Pt(0,o.Inject(K.HoverManagerService)),Pt(1,o.Inject(K.CellAlertManagerService)),Pt(2,o.IUniverInstanceService),Pt(3,o.Inject(o.LocaleService)),Pt(4,et.IZenZoneService)],jt);var Jn=Object.defineProperty,Qn=Object.getOwnPropertyDescriptor,ta=(t,e,a,n)=>{for(var i=n>1?void 0:n?Qn(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&Jn(e,a,i),i},le=(t,e)=>(a,n)=>e(a,n,t);let wt=class extends o.Disposable{constructor(t,e,a){super(),this._autoFillService=t,this._dataValidationModel=e,this._injector=a,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),e=(i,r)=>{const{source:s,target:d,unitId:l,subUnitId:u}=i,h=this._dataValidationModel.getRuleObjectMatrix(l,u).clone(),p=K.virtualizeDiscreteRanges([s,d]),[c,C]=p.ranges,{mapFunc:v}=p,f={row:c.startRow,col:c.startColumn},w=K.getAutoFillRepeatRange(c,C),V=new o.ObjectMatrix,b=new Set;w.forEach(M=>{const j=M.repeatStartCell,k=M.relativeRange,N={startRow:f.row,startColumn:f.col,endColumn:f.col,endRow:f.row},R={startRow:j.row,startColumn:j.col,endColumn:j.col,endRow:j.row};o.Range.foreach(k,(W,X)=>{const D=o.Rectangle.getPositionRange({startRow:W,startColumn:X,endColumn:X,endRow:W},N),{row:S,col:g}=v(D.startRow,D.startColumn),y=this._dataValidationModel.getRuleIdByLocation(l,u,S,g);if(y){const _=o.Rectangle.getPositionRange({startRow:W,startColumn:X,endColumn:X,endRow:W},R),{row:A,col:O}=v(_.startRow,_.startColumn);V.setValue(A,O,y),b.add(y)}})});const I=Array.from(b).map(M=>({id:M,ranges:o.queryObjectMatrix(V,j=>j===M)}));h.addRangeRules(I);const F=h.diff(this._dataValidationModel.getRules(l,u)),{redoMutations:L,undoMutations:P}=x.getDataValidationDiffMutations(l,u,F,this._injector,"patched",r===K.APPLY_TYPE.ONLY_FORMAT);return{undos:P,redos:L}},a=[o.DataValidationType.CHECKBOX],n={id:x.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:i=>{const{source:r,unitId:s,subUnitId:d}=i;for(const l of r.rows)for(const u of r.cols){const h=this._dataValidationModel.getRuleByLocation(s,d,l,u);if(h&&a.indexOf(h.type)>-1){this._autoFillService.setDisableApplyType(K.APPLY_TYPE.SERIES,!0);return}}},onFillData:(i,r,s)=>s===K.APPLY_TYPE.COPY||s===K.APPLY_TYPE.ONLY_FORMAT||s===K.APPLY_TYPE.SERIES?e(i,s):t(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};wt=ta([le(0,K.IAutoFillService),le(1,o.Inject(x.SheetDataValidationModel)),le(2,o.Inject(o.Injector))],wt);var ea=Object.defineProperty,na=Object.getOwnPropertyDescriptor,aa=(t,e,a,n)=>{for(var i=n>1?void 0:n?na(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&ea(e,a,i),i},de=(t,e)=>(a,n)=>e(a,n,t);let Mt=class extends o.Disposable{constructor(e,a,n){super();Y(this,"_copyInfo");this._sheetClipboardService=e,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:x.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(e,a,n)=>this._collect(e,a,n),onPasteCells:(e,a,n,i)=>{const{copyType:r=K.COPY_TYPE.COPY,pasteType:s}=i,{range:d}=e||{},{range:l,unitId:u,subUnitId:h}=a;return this._generateMutations(l,{copyType:r,pasteType:s,copyRange:d,unitId:u,subUnitId:h})}})}_collect(e,a,n){const i=new o.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:a,matrix:i};const r=this._injector.invoke(l=>K.rangeToDiscreteRange(n,l,e,a));if(!r)return;const{rows:s,cols:d}=r;s.forEach((l,u)=>{d.forEach((h,p)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(e,a,l,h);i.setValue(u,p,c!=null?c:"")})})}_generateMutations(e,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===K.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:n,subUnitId:i}=this._copyInfo;if(a.unitId!==n||i!==a.subUnitId){const r=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),s=new o.ObjectMatrix,d=new Set,{ranges:[l,u],mapFunc:h}=K.virtualizeDiscreteRanges([a.copyRange,e]),p=K.getRepeatRange(l,u,!0),c=new Map;p.forEach(({startRange:w})=>{var V;(V=this._copyInfo)==null||V.matrix.forValue((b,I,F)=>{const L=o.Rectangle.getPositionRange({startRow:b,endRow:b,startColumn:I,endColumn:I},w),P=`${i}-${F}`,M=this._sheetDataValidationModel.getRuleById(n,i,F);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,P)&&M&&c.set(P,{...M,uid:P});const{row:j,col:k}=h(L.startRow,L.startColumn);d.add(P),s.setValue(j,k,P)})});const C=Array.from(d).map(w=>({id:w,ranges:o.queryObjectMatrix(s,V=>V===w)}));r.addRangeRules(C);const{redoMutations:v,undoMutations:f}=x.getDataValidationDiffMutations(a.unitId,a.subUnitId,r.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),c.values()),this._injector,"patched",!1);return{redos:v,undos:f}}else{const r=this._sheetDataValidationModel.getRuleObjectMatrix(n,i).clone(),s=new o.ObjectMatrix,d=new Set,{ranges:[l,u],mapFunc:h}=K.virtualizeDiscreteRanges([a.copyRange,e]);K.getRepeatRange(l,u,!0).forEach(({startRange:f})=>{var w;(w=this._copyInfo)==null||w.matrix.forValue((V,b,I)=>{const F=o.Rectangle.getPositionRange({startRow:V,endRow:V,startColumn:b,endColumn:b},f),{row:L,col:P}=h(F.startRow,F.startColumn);s.setValue(L,P,I),d.add(I)})});const c=Array.from(d).map(f=>({id:f,ranges:o.queryObjectMatrix(s,w=>w===f)}));r.addRangeRules(c);const{redoMutations:C,undoMutations:v}=x.getDataValidationDiffMutations(n,i,r.diff(this._sheetDataValidationModel.getRules(n,i)),this._injector,"patched",!1);return{redos:C,undos:v}}}};Mt=aa([de(0,K.ISheetClipboardService),de(1,o.Inject(x.SheetDataValidationModel)),de(2,o.Inject(o.Injector))],Mt);var ia=Object.defineProperty,oa=Object.getOwnPropertyDescriptor,ra=(t,e,a,n)=>{for(var i=n>1?void 0:n?oa(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&ia(e,a,i),i},ce=(t,e)=>(a,n)=>e(a,n,t);let Vt=class extends o.Disposable{constructor(t,e,a){super(),this._localeService=t,this._commandService=e,this._sheetPermissionInterceptorBaseController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===x.AddSheetDataValidationCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[tt.WorkbookEditablePermission],rangeTypes:[tt.RangeProtectionPermissionEditPoint],worksheetTypes:[tt.WorksheetEditPermission,tt.WorksheetSetCellStylePermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr"))),t.id===x.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[tt.WorkbookEditablePermission],rangeTypes:[tt.RangeProtectionPermissionEditPoint],worksheetTypes:[tt.WorksheetEditPermission,tt.WorksheetSetCellStylePermission]},t.params.ranges)||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr")))}))}};Vt=ra([ce(0,o.Inject(o.LocaleService)),ce(1,o.ICommandService),ce(2,o.Inject(K.SheetPermissionInterceptorBaseController))],Vt);const Be="data-validation-single",We="sheet.menu.data-validation";function sa(t){return{id:We,type:et.MenuItemType.SUBITEMS,icon:Be,tooltip:"dataValidation.title",hidden$:et.getMenuHiddenObservable(t,o.UniverInstanceType.UNIVER_SHEET),disabled$:K.getCurrentRangeDisable$(t,{workbookTypes:[tt.WorkbookEditablePermission],worksheetTypes:[tt.WorksheetSetCellStylePermission,tt.WorksheetEditPermission],rangeTypes:[tt.RangeProtectionPermissionEditPoint]})}}function la(t){return{id:_t.id,title:"dataValidation.panel.title",type:et.MenuItemType.BUTTON}}function da(t){return{id:kt.id,title:"dataValidation.panel.add",type:et.MenuItemType.BUTTON}}const ca={[et.RibbonStartGroup.FORMULAS_INSERT]:{[We]:{order:9,menuItemFactory:sa,[_t.id]:{order:0,menuItemFactory:la},[kt.id]:{order:1,menuItemFactory:da}}}};var ua=Object.defineProperty,ha=Object.getOwnPropertyDescriptor,He=(t,e,a,n)=>{for(var i=n>1?void 0:n?ha(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&ua(e,a,i),i},rt=(t,e)=>(a,n)=>e(a,n,t);const Ye={tr:{size:6,color:"#fe4b4b"}};let Et=class extends o.RxDisposable{constructor(t,e,a,n,i,r,s,d,l,u,h){super(),this._commandService=t,this._menuManagerService=e,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=i,this._dropdownManagerService=r,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=u,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(ca)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{var a;if(!t.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const e=this._editorBridgeService.getEditCellState();if(e){const{unitId:n,sheetId:i,row:r,column:s}=e,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,i,r,s);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(u!=null&&u.dropdown))return;const h=d.getActiveSheet();if(!h)return;const p=this._dropdownManagerService.activeDropdown,c=p==null?void 0:p.location;if(c&&c.unitId===n&&c.subUnitId===i&&c.row===r&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:i,row:r,col:s,workbook:d,worksheet:h},componentKey:u.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(tt.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:tt.InterceptCellContentPriority.DATA_VALIDATION,handler:(t,e,a)=>{var V,b,I,F,L,P;const{row:n,col:i,unitId:r,subUnitId:s,workbook:d,worksheet:l}=e,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!u)return a(t);const h=this._sheetDataValidationModel.getRuleById(r,s,u);if(!h)return a(t);const p=(b=(V=this._dataValidationCacheService.getValue(r,s,n,i))==null?void 0:V.status)!=null?b:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(h.type),C=e.rawData;let v;const f={get value(){var M;return v!==void 0||(v=(M=x.getCellValueOrigin(C))!=null?M:null),v}},w={get value(){var M;return`${(M=f.value)!=null?M:""}`}};return a({...t,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c},markers:{...t==null?void 0:t.markers,...p===o.DataValidationStatus.INVALID?Ye:null},customRender:[...(I=t==null?void 0:t.customRender)!=null?I:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...t==null?void 0:t.fontRenderExtension,isSkip:((F=t==null?void 0:t.fontRenderExtension)==null?void 0:F.isSkip)||((L=c==null?void 0:c.skipDefaultFontRender)==null?void 0:L.call(c,h,f.value,e))},interceptorStyle:{...t==null?void 0:t.interceptorStyle,...c==null?void 0:c.getExtraStyle(h,w.value,{get style(){const M=d.getStyles();return(typeof(t==null?void 0:t.s)=="string"?M.get(t==null?void 0:t.s):t==null?void 0:t.s)||{}}},n,i)},interceptorAutoHeight:()=>{var N,R,W,X,D,S;const M=(R=(N=this._renderManagerService.getRenderById(r))==null?void 0:N.with(K.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:R.skeleton;if(!M)return;const j=M.worksheet.getMergedCell(n,i),k={data:{...t,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c}},style:M.getsStyles().getStyleByCell(t),primaryWithCoord:M.getCellByIndex((W=j==null?void 0:j.startRow)!=null?W:n,(X=j==null?void 0:j.startColumn)!=null?X:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(S=(D=c==null?void 0:c.canvasRender)==null?void 0:D.calcCellAutoHeight)==null?void 0:S.call(D,k)},interceptorAutoWidth:()=>{var N,R,W,X,D,S;const M=(R=(N=this._renderManagerService.getRenderById(r))==null?void 0:N.with(K.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:R.skeleton;if(!M)return;const j=M.worksheet.getMergedCell(n,i),k={data:{...t,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c}},style:M.getsStyles().getStyleByCell(t),primaryWithCoord:M.getCellByIndex((W=j==null?void 0:j.startRow)!=null?W:n,(X=j==null?void 0:j.startColumn)!=null?X:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(S=(D=c==null?void 0:c.canvasRender)==null?void 0:D.calcCellAutoWidth)==null?void 0:S.call(D,k)},coverable:((P=t==null?void 0:t.coverable)!=null?P:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(dt.filter(t=>t.source==="command"),dt.bufferTime(16)).subscribe(t=>{const e=[];if(t.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&e.push(...a.rule.ranges)}),e.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(e);o.sequenceExecute(a.redos,this._commandService)}})}};Et=He([rt(0,o.ICommandService),rt(1,et.IMenuManagerService),rt(2,Z.IRenderManagerService),rt(3,o.IUniverInstanceService),rt(4,o.Inject(K.AutoHeightController)),rt(5,o.Inject(gt)),rt(6,o.Inject(x.SheetDataValidationModel)),rt(7,o.Inject(ot.DataValidatorRegistryService)),rt(8,o.Inject(tt.SheetInterceptorService)),rt(9,o.Inject(x.DataValidationCacheService)),rt(10,o.Optional(K.IEditorBridgeService))],Et);let Xe=class extends o.RxDisposable{constructor(t,e,a,n,i,r,s){super(),this._commandService=t,this._renderManagerService=e,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=i,this._sheetDataValidationModel=r,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(tt.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:tt.InterceptCellContentPriority.DATA_VALIDATION,handler:(t,e,a)=>{var w,V,b,I,F,L;const{row:n,col:i,unitId:r,subUnitId:s,workbook:d,worksheet:l}=e,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!u)return a(t);const h=this._sheetDataValidationModel.getRuleById(r,s,u);if(!h)return a(t);const p=(V=(w=this._dataValidationCacheService.getValue(r,s,n,i))==null?void 0:w.status)!=null?V:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(h.type),C=l.getCellRaw(n,i),v=x.getCellValueOrigin(C),f=`${v!=null?v:""}`;return a({...t,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c},markers:{...t==null?void 0:t.markers,...p===o.DataValidationStatus.INVALID?Ye:null},customRender:[...(b=t==null?void 0:t.customRender)!=null?b:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...t==null?void 0:t.fontRenderExtension,isSkip:((I=t==null?void 0:t.fontRenderExtension)==null?void 0:I.isSkip)||((F=c==null?void 0:c.skipDefaultFontRender)==null?void 0:F.call(c,h,v,e))},interceptorStyle:{...t==null?void 0:t.interceptorStyle,...c==null?void 0:c.getExtraStyle(h,f,{get style(){const P=d.getStyles();return(typeof(t==null?void 0:t.s)=="string"?P.get(t==null?void 0:t.s):t==null?void 0:t.s)||{}}},n,i)},interceptorAutoHeight:()=>{var k,N,R,W,X,D;const P=(N=(k=this._renderManagerService.getRenderById(r))==null?void 0:k.with(K.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:N.skeleton;if(!P)return;const M=P.worksheet.getMergedCell(n,i),j={data:{...t,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c}},style:P.getsStyles().getStyleByCell(t),primaryWithCoord:P.getCellByIndex((R=M==null?void 0:M.startRow)!=null?R:n,(W=M==null?void 0:M.startColumn)!=null?W:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(D=(X=c==null?void 0:c.canvasRender)==null?void 0:X.calcCellAutoHeight)==null?void 0:D.call(X,j)},coverable:((L=t==null?void 0:t.coverable)!=null?L:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(dt.filter(t=>t.source==="command"),dt.bufferTime(16)).subscribe(t=>{const e=[];if(t.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&e.push(...a.rule.ranges)}),e.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(e);o.sequenceExecute(a.redos,this._commandService)}})}};Xe=He([rt(0,o.ICommandService),rt(1,Z.IRenderManagerService),rt(2,o.Inject(K.AutoHeightController)),rt(3,o.Inject(ot.DataValidatorRegistryService)),rt(4,o.Inject(tt.SheetInterceptorService)),rt(5,o.Inject(x.SheetDataValidationModel)),rt(6,o.Inject(x.DataValidationCacheService))],Xe);var pa=Object.defineProperty,fa=Object.getOwnPropertyDescriptor,ma=(t,e,a,n)=>{for(var i=n>1?void 0:n?fa(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&pa(e,a,i),i},ze=(t,e)=>(a,n)=>e(a,n,t);let Wt=class extends o.Disposable{constructor(t,e,a){super(),this._context=t,this._sheetDataValidationModel=e,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const t=e=>{var n;if(!e.length)return;const a=new Set;e.forEach(i=>{a.add(i.subUnitId)}),a.forEach(i=>{var r;(r=this._sheetSkeletonManagerService.getWorksheetSkeleton(i))==null||r.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(t))}};Wt=ma([ze(1,o.Inject(x.SheetDataValidationModel)),ze(2,o.Inject(K.SheetSkeletonManagerService))],Wt);const st={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"},va=t=>{const{isTwoFormula:e=!1,value:a,onChange:n,showError:i,validResult:r}=t,s=o.useDependency(o.LocaleService),d=i?r==null?void 0:r.formula1:"",l=i?r==null?void 0:r.formula2:"";return e?m.jsxs(m.Fragment,{children:[m.jsx(U.FormLayout,{error:d,children:m.jsx(U.Input,{className:st.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({...a,formula1:u})}})}),m.jsx("div",{className:st.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),m.jsx(U.FormLayout,{error:l,children:m.jsx(U.Input,{className:st.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:u=>{n==null||n({...a,formula2:u})}})})]}):m.jsx(U.FormLayout,{error:d,children:m.jsx(U.Input,{className:st.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({formula1:u})}})})};function ga(t){const{value:e,onChange:a,showError:n,validResult:i}=t,r=o.useDependency(o.LocaleService),s=n?i==null?void 0:i.formula1:"",d=n?i==null?void 0:i.formula2:"",[l,u]=E.useState(!((e==null?void 0:e.formula1)===void 0&&(e==null?void 0:e.formula2)===void 0));return m.jsxs(m.Fragment,{children:[m.jsx(U.FormLayout,{children:m.jsx(U.Checkbox,{checked:l,onChange:h=>{h?u(!0):(u(!1),a==null||a({...e,formula1:void 0,formula2:void 0}))},children:r.t("dataValidation.checkbox.tips")})}),l?m.jsx(U.FormLayout,{label:r.t("dataValidation.checkbox.checked"),error:s,children:m.jsx(U.Input,{className:st.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:e==null?void 0:e.formula1,onChange:h=>{a==null||a({...e,formula1:h||void 0})}})}):null,l?m.jsx(U.FormLayout,{label:r.t("dataValidation.checkbox.unchecked"),error:d,children:m.jsx(U.Input,{className:st.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:e==null?void 0:e.formula2,onChange:h=>{a==null||a({...e,formula2:h||void 0})}})}):null]})}function Sa(t){var p;const{unitId:e,subUnitId:a,value:n,onChange:i,showError:r,validResult:s}=t,d=r?s==null?void 0:s.formula1:void 0,l=E.useRef({}),[u,h]=E.useState(!1);return et.useSidebarClick(c=>{var v;const C=(v=l.current)==null?void 0:v.handleOutClick;C&&C(c,()=>h(!1))}),m.jsx(ee.FormulaEditor,{initValue:(p=n==null?void 0:n.formula1)!=null?p:"",unitId:e,subUnitId:a,isFocus:u,onChange:c=>{const C=(c!=null?c:"").trim();C!==(n==null?void 0:n.formula1)&&(i==null||i({...n,formula1:C}))},errorText:d,onFocus:()=>h(!0),actions:l.current})}function Ke(t){var e,a,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(a=Ke(t[e]))&&(n&&(n+=" "),n+=a)}else for(a in t)t[a]&&(n&&(n+=" "),n+=a);return n}function _a(){for(var t,e,a=0,n="",i=arguments.length;a<i;a++)(t=arguments[a])&&(e=Ke(t))&&(n&&(n+=" "),n+=e);return n}const Ia=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Ca=t=>{const{value:e,onChange:a,disabled:n}=t,[i,r]=E.useState(!1);return m.jsx(U.Select,{disabled:n,open:i,onDropdownVisibleChange:r,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:st.dataValidationFormulaColorSelect,value:e,onChange:a,labelRender:s=>m.jsx("div",{className:st.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>m.jsx("div",{className:st.dataValidationFormulaColorSelectPanel,children:Ia.map(s=>m.jsx("div",{onClick:()=>{a(s),r(!1)},className:st.dataValidationFormulaColorItem,style:{background:s}},s))})})},Ge=t=>{const{item:e,commonProps:a,style:n}=t,{onItemChange:i,onItemDelete:r}=a;return m.jsxs("div",{className:st.dataValidationFormulaListItem,style:n,children:[e.isRef?null:m.jsx("div",{className:_a(st.dataValidationFormulaListItemDrag,"draggableHandle"),children:m.jsx($e,{})}),m.jsx(Ca,{value:e.color,onChange:s=>{i(e.id,e.label,s)}}),m.jsx(U.Input,{disabled:e.isRef,value:e.label,onChange:s=>{i(e.id,s,e.color)}}),e.isRef?null:m.jsx("div",{className:st.dataValidationFormulaListItemIcon,children:m.jsx(ne,{onClick:()=>r(e.id)})})]})};function Da(t){const{value:e,onChange:a=()=>{},unitId:n,subUnitId:i,validResult:r,showError:s,ruleId:d}=t,{formula1:l="",formula2:u=""}=e||{},h=E.useRef(null),[p,c]=E.useState(()=>o.isFormulaString(l)?"1":"0"),[C,v]=E.useState(p==="1"?l:"="),[f,w]=E.useState(p==="1"?l:"="),V=o.useDependency(o.LocaleService),b=o.useDependency(ot.DataValidatorRegistryService),I=o.useDependency(ot.DataValidationModel),F=o.useDependency(x.DataValidationFormulaController),[L,P]=E.useState(()=>u.split(",")),M=b.getValidatorItem(o.DataValidationType.LIST),[j,k]=E.useState([]),[N,R]=E.useState(""),W=s?r==null?void 0:r.formula1:"",X=E.useMemo(()=>I.ruleChange$.pipe(dt.debounceTime(16)),[]),D=et.useObservable(X),S=et.useEvent(a);E.useEffect(()=>{(async()=>{await new Promise(B=>{setTimeout(()=>B(!0),100)});const T=I.getRuleById(n,i,d),z=T==null?void 0:T.formula1;if(o.isFormulaString(z)&&M&&T){const B=await M.getListAsync(T,n,i);k(B)}})()},[I,D,M,d,i,n]),E.useEffect(()=>{o.isFormulaString(l)&&l!==f&&(v(l),w(f))},[f,l]);const[g,y]=E.useState(()=>{const T=p!=="1"?x.deserializeListOptions(l):[],z=u.split(",");return T.map((B,q)=>({label:B,color:z[q]||It,isRef:!1,id:o.Tools.generateRandomId(4)}))}),_=(T,z,B)=>{const q=g.find(lt=>lt.id===T);q&&(q.label=z,q.color=B,y([...g]))},A=T=>{const z=g.findIndex(B=>B.id===T);z!==-1&&(g.splice(z,1),y([...g]))},O=u.split(","),H=E.useMemo(()=>j.map((T,z)=>({label:T,color:O[z]||It,id:`${z}`,isRef:!0})),[O,j]),G=(T,z,B)=>{const q=[...L];q[+T]=B,P(q),S({formula1:l,formula2:q.join(",")})},Q=()=>{y([...g,{label:"",color:It,isRef:!1,id:o.Tools.generateRandomId(4)}])};E.useEffect(()=>{if(p==="1")return;const T=new Set,z=[];g.map(B=>({labelList:B.label.split(","),item:B})).forEach(({item:B,labelList:q})=>{q.forEach(lt=>{T.has(lt)||(T.add(lt),z.push({label:lt,color:B.color}))})}),S({formula1:x.serializeListOptions(z.map(B=>B.label)),formula2:z.map(B=>B.color===It?"":B.color).join(",")})},[g,S,p,f,L]);const nt=E.useMemo(()=>async T=>{if(!o.isFormulaString(T)){S==null||S({formula1:"",formula2:u});return}F.getFormulaRefCheck(T)?(S==null||S({formula1:o.isFormulaString(T)?T:"",formula2:u}),R("")):(S==null||S({formula1:"",formula2:u}),v("="),R(V.t("dataValidation.validFail.formulaError")))},[u,S]),at=E.useRef({}),[it,$]=E.useState(!1);return et.useSidebarClick(T=>{var B;const z=(B=at.current)==null?void 0:B.handleOutClick;z&&z(T,()=>$(!1))}),m.jsxs(m.Fragment,{children:[m.jsx(U.FormLayout,{label:V.t("dataValidation.list.options"),children:m.jsxs(U.RadioGroup,{value:p,onChange:T=>{c(T),v(f),T==="1"&&S({formula1:f==="="?"":f,formula2:L.join(",")})},children:[m.jsx(U.Radio,{value:"0",children:V.t("dataValidation.list.customOptions")}),m.jsx(U.Radio,{value:"1",children:V.t("dataValidation.list.refOptions")})]})}),p==="1"?m.jsxs(m.Fragment,{children:[m.jsx(ee.FormulaEditor,{initValue:C,unitId:n,subUnitId:i,isFocus:it,onChange:(T="")=>{const z=(T!=null?T:"").trim();w(z),nt(z)},errorText:W||N||void 0,onFocus:()=>$(!0),actions:at.current}),m.jsx("div",{ref:h,style:{marginTop:"12px"},children:H.map(T=>m.jsx(Ge,{item:T,commonProps:{onItemChange:G},style:{marginBottom:12}},T.id))})]}):m.jsx(U.FormLayout,{error:W,children:m.jsxs("div",{ref:h,style:{marginTop:"-12px"},children:[m.jsx(U.DraggableList,{list:g,onListChange:y,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:T=>m.jsx(Ge,{item:T,commonProps:{onItemChange:_,onItemDelete:A}},T.id),idKey:"id"}),m.jsxs("a",{className:st.dataValidationFormulaListAdd,onClick:Q,children:[m.jsx(Pe,{}),V.t("dataValidation.list.add")]})]})})]})}const Ze="data-validation.custom-formula-input",Ht="data-validation.formula-input",ue="data-validation.list-formula-input",qe="data-validation.checkbox-formula-input",ya=[[Ze,Sa],[Ht,va],[ue,Da],[qe,ga]],wa="LIST_RENDER_MODE_OPTION_INPUT";function Yt(t){var i;const{value:e,onChange:a}=t,n=o.useDependency(o.LocaleService);return m.jsx(U.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:m.jsxs(U.RadioGroup,{value:`${(i=e.renderMode)!=null?i:o.DataValidationRenderMode.CUSTOM}`,onChange:r=>a({...e,renderMode:+r}),children:[m.jsx(U.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),m.jsx(U.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),m.jsx(U.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}Yt.componentKey=wa;const Ma="DATE_SHOW_TIME_OPTION";function Xt(t){var i;const{value:e,onChange:a}=t,n=o.useDependency(o.LocaleService);return m.jsx(U.FormLayout,{children:m.jsx(U.Checkbox,{checked:(i=e.bizInfo)==null?void 0:i.showTime,onChange:r=>{a({...e,bizInfo:{...e.bizInfo,showTime:r}})},children:n.t("dataValidation.showTime.label")})})}Xt.componentKey=Ma;var Va=Object.defineProperty,Ea=Object.getOwnPropertyDescriptor,ba=(t,e,a,n)=>{for(var i=n>1?void 0:n?Ea(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&Va(e,a,i),i},zt=(t,e)=>(a,n)=>e(a,n,t);const Kt=6;let he=class{constructor(t,e,a,n){this._commandService=t,this._formulaService=e,this._themeService=a,this._renderManagerService=n}_calc(t,e){var u,h,p;const{vt:a,ht:n}=e||{},i=t.endX-t.startX-Kt*2,r=t.endY-t.startY,s=((u=e==null?void 0:e.fs)!=null?u:10)*1.6;let d=0,l=0;switch(a){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(r-s);break;default:l=0+(r-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:d=Kt;break;case o.HorizontalAlign.RIGHT:d=Kt+(i-s);break;default:d=Kt+(i-s)/2;break}return{left:t.startX+d,top:t.startY+l,width:((h=e==null?void 0:e.fs)!=null?h:10)*1.6,height:((p=e==null?void 0:e.fs)!=null?p:10)*1.6}}calcCellAutoHeight(t){var a;const{style:e}=t;return((a=e==null?void 0:e.fs)!=null?a:10)*1.6}calcCellAutoWidth(t){var a;const{style:e}=t;return((a=e==null?void 0:e.fs)!=null?a:10)*1.6}async _parseFormula(t,e,a){var u,h,p,c,C,v,f,w,V;const{formula1:n=x.CHECKBOX_FORMULA_1,formula2:i=x.CHECKBOX_FORMULA_2}=t,r=await this._formulaService.getRuleFormulaResult(e,a,t.uid),s=x.getFormulaResult((p=(h=(u=r==null?void 0:r[0])==null?void 0:u.result)==null?void 0:h[0])==null?void 0:p[0]),d=x.getFormulaResult((v=(C=(c=r==null?void 0:r[1])==null?void 0:c.result)==null?void 0:C[0])==null?void 0:v[0]),l=x.isLegalFormulaResult(String(s))&&x.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(n)?x.getFormulaResult((V=(w=(f=r==null?void 0:r[0])==null?void 0:f.result)==null?void 0:w[0])==null?void 0:V[0]):n,formula2:o.isFormulaString(i)?d:i,isFormulaValid:l}}drawWith(t,e){var X,D,S,g,y,_;const{style:a,data:n,primaryWithCoord:i,unitId:r,subUnitId:s,worksheet:d,row:l,col:u}=e,h=i.isMergedMainCell?i.mergeInfo:i,p=x.getCellValueOrigin(d.getCellRaw(l,u)),c=(X=n.dataValidation)==null?void 0:X.rule,C=(D=n.dataValidation)==null?void 0:D.validator;if(!c||!C)return;const v=this._themeService.getCurrentTheme();if(!((S=C.skipDefaultFontRender)!=null&&S.call(C,c,p,{unitId:r,subUnitId:s,row:l,column:u})))return;const f=C.parseFormulaSync(c,r,s),{formula1:w}=f,V=this._calc(h,a),{a:b,d:I}=t.getTransform(),F=Z.fixLineWidthByScale(V.left,b),L=Z.fixLineWidthByScale(V.top,I),P=Z.Transform.create().composeMatrix({left:F,top:L,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),M=h.endX-h.startX,j=h.endY-h.startY;t.save(),t.beginPath(),t.rect(h.startX,h.startY,M,j),t.clip();const k=P.getMatrix();t.transform(k[0],k[1],k[2],k[3],k[4],k[5]);const N=((g=a==null?void 0:a.fs)!=null?g:10)*1.6,R=String(p)===String(w),W=v.hyacinth500;Z.Checkbox.drawWith(t,{checked:R,width:N,height:N,fill:(_=(y=a==null?void 0:a.cl)==null?void 0:y.rgb)!=null?_:W}),t.restore()}isHit(t,e){const a=e.primaryWithCoord.isMergedMainCell?e.primaryWithCoord.mergeInfo:e.primaryWithCoord,n=this._calc(a,e.style),i=n.top,r=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:u}=t;return l<=d&&l>=s&&u<=r&&u>=i}async onPointerDown(t,e){var f,w,V;if(e.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:i,data:r,worksheet:s,row:d,col:l}=t,u=x.getCellValueOrigin(s.getCellRaw(d,l)),h=(f=r.dataValidation)==null?void 0:f.rule,p=(w=r.dataValidation)==null?void 0:w.validator;if(!h||!p||!((V=p.skipDefaultFontRender)!=null&&V.call(p,h,u,{unitId:n,subUnitId:i,row:d,column:l})))return;const{formula1:c,formula2:C}=await this._parseFormula(h,n,i),v={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(u)===x.transformCheckboxValue(String(c))?C:c,p:null}};this._commandService.executeCommand(tt.SetRangeValuesCommand.id,v)}onPointerEnter(t,e){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(Z.CURSOR_TYPE.POINTER)}onPointerLeave(t,e){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(Z.CURSOR_TYPE.DEFAULT)}};he=ba([zt(0,o.ICommandService),zt(1,o.Inject(x.DataValidationFormulaService)),zt(2,o.Inject(o.ThemeService)),zt(3,o.Inject(Z.IRenderManagerService))],he);var Ra=Object.defineProperty,Oa=Object.getOwnPropertyDescriptor,Ta=(t,e,a,n)=>{for(var i=n>1?void 0:n?Oa(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&Ra(e,a,i),i},La=(t,e)=>(a,n)=>e(a,n,t);let pt=class{constructor(t){Y(this,"canvasRender",null);Y(this,"dropdown");Y(this,"optionsInput");Y(this,"formulaInput",ue);this.injector=t}};pt=Ta([La(0,o.Inject(o.Injector))],pt);class Pa extends pt{constructor(){super(...arguments);Y(this,"id",o.DataValidationType.CHECKBOX);Y(this,"canvasRender",this.injector.createInstance(he));Y(this,"formulaInput",qe)}}class ja extends pt{constructor(){super(...arguments);Y(this,"id",o.DataValidationType.CUSTOM);Y(this,"formulaInput",Ze)}}const Aa="data-validation.formula-input";class $a extends pt{constructor(){super(...arguments);Y(this,"id",o.DataValidationType.DATE);Y(this,"formulaInput",Aa);Y(this,"optionsInput",Xt.componentKey);Y(this,"dropdown",se)}}class Fa extends pt{constructor(){super(...arguments);Y(this,"id",o.DataValidationType.DECIMAL);Y(this,"formulaInput",Ht)}}const Je=4,xa=0,pe=4,Qe=4,fe=6,Gt=6,Ct=14;function Na(t,e){const a=Z.FontCache.getTextSize(t,e),n=a.width+Je*2,{ba:i,bd:r}=a,s=i+r;return{width:n,height:s+xa*2,ba:i}}function me(t,e,a,n){const i=Ct+fe*2,r=a-i,s=n-Gt*2,d=t.map(c=>({layout:Na(c,e),text:c}));let l;const u=[];d.forEach(c=>{const{layout:C}=c,{width:v,height:f}=C;!l||l.width+v+pe>r?(l={width:v,height:f,items:[{...c,left:0}]},u.push(l)):(l.items.push({...c,left:l.width+pe}),l.width=l.width+v+pe)});let h=0,p=0;return u.forEach((c,C)=>{p=Math.max(p,c.width),C===u.length-1?h+=c.height:h+=c.height+Qe}),{lines:u,totalHeight:h,contentWidth:r,contentHeight:s,cellAutoHeight:h+Gt*2,calcAutoWidth:p+i}}const Ua=8;class ka extends Z.Shape{static drawWith(e,a){const{fontString:n,info:i,fill:r,color:s}=a,{layout:d,text:l}=i;e.save(),Z.Rect.drawWith(e,{width:d.width,height:d.height,radius:Ua,fill:r||It}),e.translateWithPrecision(Je,d.ba),e.font=n,e.fillStyle=s,e.fillText(l,0,0),e.restore()}}var Ba=Object.defineProperty,Wa=Object.getOwnPropertyDescriptor,Ha=(t,e,a,n)=>{for(var i=n>1?void 0:n?Wa(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&Ba(e,a,i),i},tn=(t,e)=>(a,n)=>e(a,n,t);const Ya=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 ve=class{constructor(t,e){Y(this,"zIndex");Y(this,"_dropdownInfoMap",new Map);this._commandService=t,this._renderManagerService=e}_ensureMap(t){let e=this._dropdownInfoMap.get(t);return e||(e=new Map,this._dropdownInfoMap.set(t,e)),e}_generateKey(t,e){return`${t}.${e}`}_drawDownIcon(t,e,a,n,i){const r=a-Ct+4;let s=4;switch(i){case o.VerticalAlign.MIDDLE:s=(n-Ct)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-Ct+4;break}t.save(),t.translateWithPrecision(e.startX+r,e.startY+s),t.fillStyle="#565656",t.fill(Ya),t.restore()}drawWith(t,e,a,n){var O,H;const{primaryWithCoord:i,row:r,col:s,style:d,data:l,subUnitId:u}=e,h=i.isMergedMainCell?i.mergeInfo:i,p=l.fontRenderExtension,{leftOffset:c=0,rightOffset:C=0,topOffset:v=0,downOffset:f=0}=p||{},w=l.dataValidation,V=this._ensureMap(u),b=this._generateKey(r,s);if(!w)return;const I={startX:h.startX+c,endX:h.endX-C,startY:h.startY+v,endY:h.endY-f},F=I.endX-I.startX,L=I.endY-I.startY,{cl:P}=d||{},M=(O=typeof P=="object"?P==null?void 0:P.rgb:P)!=null?O:"#000",j=Z.getFontStyleString(d!=null?d:void 0),{rule:k,validator:N}=w,R=N,{vt:W,ht:X}=d||{},D=W!=null?W:o.VerticalAlign.MIDDLE,S=(H=x.getCellValueOrigin(l))!=null?H:"",g=R.parseCellValue(S),y=R.getListWithColorMap(k),_=me(g,j,F,L);this._drawDownIcon(t,I,F,L,D),t.save(),t.translateWithPrecision(I.startX,I.startY),t.beginPath(),t.rect(0,0,F-Ct,L),t.clip(),t.translateWithPrecision(fe,Gt);let A=0;switch(D){case o.VerticalAlign.MIDDLE:A=(_.contentHeight-_.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:A=_.contentHeight-_.totalHeight;break}t.translateWithPrecision(0,A),_.lines.forEach((G,Q)=>{t.save();const{width:nt,height:at,items:it}=G;let $=0;switch(X){case o.HorizontalAlign.RIGHT:$=_.contentWidth-nt;break;case o.HorizontalAlign.CENTER:$=(_.contentWidth-nt)/2;break}t.translate($,Q*(at+Qe)),it.forEach(T=>{t.save(),t.translateWithPrecision(T.left,0),ka.drawWith(t,{...j,info:T,color:M,fill:y[T.text]}),t.restore()}),t.restore()}),t.restore(),V.set(b,{left:I.startX,top:I.startY,width:_.contentWidth+fe+Ct,height:_.contentHeight+Gt*2})}calcCellAutoHeight(t){var F;const{primaryWithCoord:e,style:a,data:n}=t,i=n.fontRenderExtension,{leftOffset:r=0,rightOffset:s=0,topOffset:d=0,downOffset:l=0}=i||{},u=e.isMergedMainCell?e.mergeInfo:e,h={startX:u.startX+r,endX:u.endX-s,startY:u.startY+d,endY:u.endY-l},p=n.dataValidation;if(!p)return;const c=h.endX-h.startX,C=h.endY-h.startY,v=(F=x.getCellValueOrigin(n))!=null?F:"",{validator:f}=p,V=f.parseCellValue(v),b=Z.getFontStyleString(a!=null?a:void 0);return me(V,b,c,C).cellAutoHeight}calcCellAutoWidth(t){var F;const{primaryWithCoord:e,style:a,data:n}=t,i=n.fontRenderExtension,{leftOffset:r=0,rightOffset:s=0,topOffset:d=0,downOffset:l=0}=i||{},u=e.isMergedMainCell?e.mergeInfo:e,h={startX:u.startX+r,endX:u.endX-s,startY:u.startY+d,endY:u.endY-l},p=n.dataValidation;if(!p)return;const c=h.endX-h.startX,C=h.endY-h.startY,v=(F=x.getCellValueOrigin(n))!=null?F:"",{validator:f}=p,V=f.parseCellValue(v),b=Z.getFontStyleString(a!=null?a:void 0);return me(V,b,c,C).calcAutoWidth}isHit(t,e){const{primaryWithCoord:a}=e,n=a.isMergedMainCell?a.mergeInfo:a,{endX:i}=n,{x:r}=t;return r>=i-Ct&&r<=i}onPointerDown(t,e){if(e.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=t,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Ft.id,s)}onPointerEnter(t,e){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(Z.CURSOR_TYPE.POINTER)}onPointerLeave(t,e){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(Z.CURSOR_TYPE.DEFAULT)}};ve=Ha([tn(0,o.ICommandService),tn(1,o.Inject(Z.IRenderManagerService))],ve);class Xa extends pt{constructor(){super(...arguments);Y(this,"id",o.DataValidationType.LIST_MULTIPLE);Y(this,"canvasRender",this.injector.createInstance(ve));Y(this,"dropdown",Ut)}}var za=Object.defineProperty,Ka=Object.getOwnPropertyDescriptor,Ga=(t,e,a,n)=>{for(var i=n>1?void 0:n?Ka(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&za(e,a,i),i},ge=(t,e)=>(a,n)=>e(a,n,t);const Dt=4,Zt=4,ut=14,ft=6,bt=4,Se=8,Za="#565656",en=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 qa(t,e){const a=t.length;return{id:"d",body:{dataStream:`${t}${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:o.BooleanNumber.FALSE,bl:o.BooleanNumber.FALSE,ul:{s:o.BooleanNumber.FALSE},st:{s:o.BooleanNumber.FALSE},ol:{s:o.BooleanNumber.FALSE},cl:void 0,...e,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function nn(t,e,a){const n=qa(t,a),i=new o.DocumentDataModel(n),r=new Z.DocumentViewModel(i);return{documentSkeleton:Z.DocumentSkeleton.create(r,e),docModel:i,docViewModel:r}}function qt(t,e,a){const{documentSkeleton:n,docModel:i,docViewModel:r}=nn(t,e,a);return{documents:new Z.Documents(`DOCUMENTS_${o.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:i,docViewModel:r}}function an(t,e,a,n,i,r,s=!0){let d=0;const l=s?bt:0;switch(i){case o.VerticalAlign.BOTTOM:d=e-n-l;break;case o.VerticalAlign.MIDDLE:d=(e-n)/2;break;default:d=l;break}d=Math.max(bt,d);let u=0;switch(r){case o.HorizontalAlign.CENTER:u=(t-a)/2;break;case o.HorizontalAlign.RIGHT:u=t-a;break}return u=Math.max(ft,u),{paddingLeft:u,paddingTop:d}}let _e=class{constructor(t,e,a){Y(this,"_dropdownInfoMap",new Map);Y(this,"zIndex");this._localeService=t,this._commandService=e,this._renderManagerService=a}_ensureMap(t){let e=this._dropdownInfoMap.get(t);return e||(e=new Map,this._dropdownInfoMap.set(t,e)),e}_generateKey(t,e){return`${t}.${e}`}_drawDownIcon(t,e,a,n,i,r,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,u=a-ut;let h;switch(r){case o.VerticalAlign.MIDDLE:h=(n-Zt)/2;break;case o.VerticalAlign.BOTTOM:h=n-l-i-bt+(i/2-Zt/2);break;default:h=d+bt+(i/2-Zt/2);break}t.save(),t.translateWithPrecision(e.startX+u,e.startY+h),t.fillStyle="#565656",t.fill(en),t.restore()}drawWith(t,e,a){var D,S;const{primaryWithCoord:n,row:i,col:r,style:s,data:d,subUnitId:l}=e,u=n.isMergedMainCell?n.mergeInfo:n,h=(D=d.dataValidation)==null?void 0:D.rule,p=(S=d.dataValidation)==null?void 0:S.validator,c=d.fontRenderExtension,{leftOffset:C=0,rightOffset:v=0,topOffset:f=0,downOffset:w=0}=c||{};if(!h||!p||!p||p.id.indexOf(o.DataValidationType.LIST)!==0||!p.skipDefaultFontRender(h))return;const V={startX:u.startX+C,endX:u.endX-v,startY:u.startY+f,endY:u.endY-w},b=V.endX-V.startX,I=V.endY-V.startY,F=this._ensureMap(l),L=this._generateKey(i,r),P=p.getListWithColor(h),M=x.getCellValueOrigin(d),j=`${M!=null?M:""}`,k=P.find(g=>g.label===j);let{tb:N,vt:R,ht:W,pd:X}=s||{};if(N=N!=null?N:o.WrapStrategy.WRAP,R=R!=null?R:o.VerticalAlign.BOTTOM,W=W!=null?W:o.DEFAULT_STYLES.ht,X=X!=null?X:o.DEFAULT_STYLES.pd,h.renderMode===o.DataValidationRenderMode.ARROW){const{l:g=o.DEFAULT_STYLES.pd.l,t:y=o.DEFAULT_STYLES.pd.t,r:_=o.DEFAULT_STYLES.pd.r,b:A=o.DEFAULT_STYLES.pd.b}=X,O=b-g-_-ut-4,{documentSkeleton:H,documents:G,docModel:Q}=qt(j,this._localeService,s);N===o.WrapStrategy.WRAP&&Q.updateDocumentDataPageSize(Math.max(O,1)),H.calculate(),H.getActualSize();const nt=Z.getDocsSkeletonPageSize(H),{height:at,width:it}=nt,{paddingTop:$,paddingLeft:T}=an(O,I-y-A,it,at,R,W,!0);this._drawDownIcon(t,V,b,I,at,R,X),t.save(),t.translateWithPrecision(V.startX+g,V.startY+y),t.beginPath(),t.rect(0,0,b-g-_,I-y-A),t.clip(),t.translateWithPrecision(0,$),t.save(),t.translateWithPrecision(Dt,0),t.beginPath(),t.rect(0,0,O,at),t.clip(),G.render(t),t.translateWithPrecision(T,0),t.restore(),t.restore(),F.set(L,{left:V.endX+g+a.rowHeaderWidth-ut,top:V.startY+y+a.columnHeaderHeight,width:ut,height:I-y-A})}else{t.save(),t.translateWithPrecision(V.startX,V.startY),t.beginPath(),t.rect(0,0,b,I),t.clip();const g=b-ft*2-Dt-ut-4,{documentSkeleton:y,documents:_,docModel:A}=qt(j,this._localeService,s);N===o.WrapStrategy.WRAP&&A.updateDocumentDataPageSize(Math.max(g,1)),y.calculate();const O=Z.getDocsSkeletonPageSize(y),{height:H,width:G}=O,{paddingTop:Q,paddingLeft:nt}=an(g,I,G,H,R,W);t.translateWithPrecision(ft,Q);const at=Math.max(b-ft*2,1),it=H;Z.Rect.drawWith(t,{width:at,height:it,fill:(k==null?void 0:k.color)||It,radius:Se}),t.save(),t.translateWithPrecision(Dt,0),t.beginPath(),t.rect(0,0,g,H),t.clip(),t.translateWithPrecision(nt,0),_.render(t),t.restore(),t.translateWithPrecision(g+Dt+4,(H-Zt)/2),t.fillStyle=Za,t.fill(en),t.restore(),F.set(L,{left:V.startX+ft+a.rowHeaderWidth,top:V.startY+Q+a.columnHeaderHeight,width:at,height:it})}}calcCellAutoHeight(t){var I;const{primaryWithCoord:e,style:a,data:n}=t,i=e.isMergedMainCell?e.mergeInfo:e,r=n.fontRenderExtension,{leftOffset:s=0,rightOffset:d=0,topOffset:l=0,downOffset:u=0}=r||{},h=(I=n.dataValidation)==null?void 0:I.rule;if(!h||h.renderMode===o.DataValidationRenderMode.TEXT)return;const p={startX:i.startX+s,endX:i.endX-d,startY:i.startY+l,endY:i.endY-u},c=p.endX-p.startX,C=x.getCellValueOrigin(n),v=`${C!=null?C:""}`;let{tb:f,pd:w}=a||{};const{t:V=o.DEFAULT_STYLES.pd.t,b=o.DEFAULT_STYLES.pd.b}=w!=null?w:{};if(f=f!=null?f:o.WrapStrategy.WRAP,h.renderMode===o.DataValidationRenderMode.ARROW){const F=c-ut,{documentSkeleton:L,docModel:P}=qt(v,this._localeService,a);f===o.WrapStrategy.WRAP&&P.updateDocumentDataPageSize(Math.max(F,1)),L.calculate(),L.getActualSize();const M=Z.getDocsSkeletonPageSize(L),{height:j}=M;return j+V+b+bt*2}else{const F=c-ft*2-Dt-ut,{documentSkeleton:L,docModel:P}=nn(v,this._localeService,a);f===o.WrapStrategy.WRAP&&P.updateDocumentDataPageSize(Math.max(F,1)),L.calculate();const M=Z.getDocsSkeletonPageSize(L),{height:j}=M;return j+bt*2}}calcCellAutoWidth(t){var j;const{primaryWithCoord:e,style:a,data:n}=t,i=e.isMergedMainCell?e.mergeInfo:e,r=n.fontRenderExtension,{leftOffset:s=0,rightOffset:d=0,topOffset:l=0,downOffset:u=0}=r||{},h=(j=n.dataValidation)==null?void 0:j.rule;if(!h||h.renderMode===o.DataValidationRenderMode.TEXT)return;const p={startX:i.startX+s,endX:i.endX-d,startY:i.startY+l,endY:i.endY-u},c=p.endX-p.startX,C=x.getCellValueOrigin(n),v=`${C!=null?C:""}`;let{tb:f,pd:w}=a||{};const{l:V=o.DEFAULT_STYLES.pd.l,r:b=o.DEFAULT_STYLES.pd.r}=w!=null?w:{};f=f!=null?f:o.WrapStrategy.WRAP;let I=ft*2+ut;switch(h.renderMode){case o.DataValidationRenderMode.ARROW:I=ut+ft*2+b+V;break;case o.DataValidationRenderMode.CUSTOM:I=ut+ft*2+Dt*2+b+V+Se/2+1;break;default:I=ut+ft*2+Dt*2+b+V+Se/2+1}const F=c-I,{documentSkeleton:L,docModel:P}=qt(v,this._localeService,a);return f===o.WrapStrategy.WRAP&&P.updateDocumentDataPageSize(Math.max(F,1)),L.calculate(),L.getActualSize(),Z.getDocsSkeletonPageSize(L).width+I}isHit(t,e){const{data:a,subUnitId:n,row:i,col:r}=e,d=this._ensureMap(n).get(this._generateKey(i,r)),l=a.dataValidation;if(!l||!d||l.rule.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:u,left:h,width:p,height:c}=d,{x:C,y:v}=t;return C>=h&&C<=h+p&&v>=u&&v<=u+c}onPointerDown(t,e){if(e.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=t,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Ft.id,s)}onPointerEnter(t,e){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(Z.CURSOR_TYPE.POINTER)}onPointerLeave(t,e){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(Z.CURSOR_TYPE.DEFAULT)}};_e=Ga([ge(0,o.Inject(o.LocaleService)),ge(1,o.ICommandService),ge(2,o.Inject(Z.IRenderManagerService))],_e);class Ja extends pt{constructor(){super(...arguments);Y(this,"id",o.DataValidationType.LIST);Y(this,"canvasRender",this.injector.createInstance(_e));Y(this,"dropdown",Ut);Y(this,"optionsInput",Yt.componentKey);Y(this,"formulaInput",ue)}}class Qa extends pt{constructor(){super(...arguments);Y(this,"id",o.DataValidationType.TEXT_LENGTH);Y(this,"formulaInput",Ht)}}class ti extends pt{constructor(){super(...arguments);Y(this,"id",o.DataValidationType.WHOLE);Y(this,"formulaInput",Ht)}}var ei=Object.defineProperty,ni=Object.getOwnPropertyDescriptor,ai=(t,e,a,n)=>{for(var i=n>1?void 0:n?ni(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&ei(e,a,i),i},Ie=(t,e)=>(a,n)=>e(a,n,t);let Rt=class extends o.RxDisposable{constructor(t,e,a){super(),this._injector=t,this._componentManger=e,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[Be,Le],[ae,Kn],[xe,An],[Ut,Un],[se,In],[Yt.componentKey,Yt],[Xt.componentKey,Xt],...ya].forEach(([t,e])=>{this.disposeWithMe(this._componentManger.register(t,e))})}_registerValidatorViews(){[Fa,ti,Qa,$a,Pa,Ja,Xa,ja].forEach(t=>{const e=this._injector.createInstance(t),a=this._dataValidatorRegistryService.getValidatorItem(e.id);a&&(a.formulaInput=e.formulaInput,a.canvasRender=e.canvasRender,a.dropdown=e.dropdown,a.optionsInput=e.optionsInput)})}};Rt=ai([Ie(0,o.Inject(o.Injector)),Ie(1,o.Inject(et.ComponentManager)),Ie(2,o.Inject(ot.DataValidatorRegistryService))],Rt);var ii=Object.defineProperty,oi=Object.getOwnPropertyDescriptor,ri=(t,e,a,n)=>{for(var i=n>1?void 0:n?oi(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&ii(e,a,i),i},Ce=(t,e)=>(a,n)=>e(a,n,t);const si="SHEET_DATA_VALIDATION_UI_PLUGIN";J.UniverSheetsDataValidationUIPlugin=(Jt=class extends o.Plugin{constructor(e=ke,a,n,i){super(),this._config=e,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(oe,s)}onStarting(){[[ht],[gt],[jt],[wt],[Et],[Vt],[Mt],[Lt],[Rt]].forEach(e=>{this._injector.add(e)}),[kt,Ft,Ue,ie,_t,Ne].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(Mt),this._injector.get(Vt),this._injector.get(Lt),this._injector.get(jt),this._injector.get(Z.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Wt])}onRendered(){this._injector.get(Rt),this._injector.get(Et)}onSteady(){this._injector.get(wt)}},Y(Jt,"pluginName",si),Y(Jt,"type",o.UniverInstanceType.UNIVER_SHEET),Jt),J.UniverSheetsDataValidationUIPlugin=ri([Ce(1,o.Inject(o.Injector)),Ce(2,o.ICommandService),Ce(3,o.IConfigService)],J.UniverSheetsDataValidationUIPlugin);var li=Object.defineProperty,di=Object.getOwnPropertyDescriptor,ci=(t,e,a,n)=>{for(var i=n>1?void 0:n?di(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&li(e,a,i),i},De=(t,e)=>(a,n)=>e(a,n,t);const ui="SHEET_DATA_VALIDATION_UI_PLUGIN";J.UniverSheetsDataValidationMobileUIPlugin=(Qt=class extends o.Plugin{constructor(e=ke,a,n,i){super(),this._config=e,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(oe,s)}onStarting(){[[ht],[gt],[jt],[wt],[Et],[Vt],[Mt],[Rt]].forEach(e=>{this._injector.add(e)}),[kt,Ft,Ue,ie,_t,Ne].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(Mt),this._injector.get(Vt),this._injector.get(Z.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Wt])}onRendered(){this._injector.get(Rt),this._injector.get(Et)}onSteady(){this._injector.get(wt)}},Y(Qt,"pluginName",ui),Y(Qt,"type",o.UniverInstanceType.UNIVER_SHEET),Qt),J.UniverSheetsDataValidationMobileUIPlugin=ci([De(1,o.Inject(o.Injector)),De(2,o.ICommandService),De(3,o.IConfigService)],J.UniverSheetsDataValidationMobileUIPlugin),J.DATE_DROPDOWN_KEY=se,J.LIST_DROPDOWN_KEY=Ut,Object.defineProperty(J,Symbol.toStringTag,{value:"Module"})});
|
9
|
+
*/var sn=E,ln=Symbol.for("react.element"),dn=Symbol.for("react.fragment"),cn=Object.prototype.hasOwnProperty,un=sn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,hn={key:!0,ref:!0,__self:!0,__source:!0};function Ve(t,e,a){var n,i={},r=null,s=null;a!==void 0&&(r=""+a),e.key!==void 0&&(r=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)cn.call(e,n)&&!hn.hasOwnProperty(n)&&(i[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps,e)i[n]===void 0&&(i[n]=e[n]);return{$$typeof:ln,type:t,key:r,ref:s,props:i,_owner:un.current}}At.Fragment=dn,At.jsx=Ve,At.jsxs=Ve,Me.exports=At;var m=Me.exports,Ee={exports:{}};(function(t,e){(function(a,n){t.exports=n()})(ye,function(){var a=1e3,n=6e4,i=36e5,r="millisecond",s="second",d="minute",l="hour",u="day",h="week",p="month",c="quarter",C="year",v="date",f="Invalid Date",w=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,V=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,b={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(D){var S=["th","st","nd","rd"],g=D%100;return"["+D+(S[(g-20)%10]||S[g]||S[0])+"]"}},I=function(D,S,g){var y=String(D);return!y||y.length>=S?D:""+Array(S+1-y.length).join(g)+D},F={s:I,z:function(D){var S=-D.utcOffset(),g=Math.abs(S),y=Math.floor(g/60),_=g%60;return(S<=0?"+":"-")+I(y,2,"0")+":"+I(_,2,"0")},m:function D(S,g){if(S.date()<g.date())return-D(g,S);var y=12*(g.year()-S.year())+(g.month()-S.month()),_=S.clone().add(y,p),A=g-_<0,O=S.clone().add(y+(A?-1:1),p);return+(-(y+(g-_)/(A?_-O:O-_))||0)},a:function(D){return D<0?Math.ceil(D)||0:Math.floor(D)},p:function(D){return{M:p,y:C,w:h,d:u,D:v,h:l,m:d,s,ms:r,Q:c}[D]||String(D||"").toLowerCase().replace(/s$/,"")},u:function(D){return D===void 0}},L="en",P={};P[L]=b;var M="$isDayjsObject",j=function(D){return D instanceof W||!(!D||!D[M])},k=function D(S,g,y){var _;if(!S)return L;if(typeof S=="string"){var A=S.toLowerCase();P[A]&&(_=A),g&&(P[A]=g,_=A);var O=S.split("-");if(!_&&O.length>1)return D(O[0])}else{var H=S.name;P[H]=S,_=H}return!y&&_&&(L=_),_||!y&&L},N=function(D,S){if(j(D))return D.clone();var g=typeof S=="object"?S:{};return g.date=D,g.args=arguments,new W(g)},R=F;R.l=k,R.i=j,R.w=function(D,S){return N(D,{locale:S.$L,utc:S.$u,x:S.$x,$offset:S.$offset})};var W=function(){function D(g){this.$L=k(g.locale,null,!0),this.parse(g),this.$x=this.$x||g.x||{},this[M]=!0}var S=D.prototype;return S.parse=function(g){this.$d=function(y){var _=y.date,A=y.utc;if(_===null)return new Date(NaN);if(R.u(_))return new Date;if(_ instanceof Date)return new Date(_);if(typeof _=="string"&&!/Z$/i.test(_)){var O=_.match(w);if(O){var H=O[2]-1||0,G=(O[7]||"0").substring(0,3);return A?new Date(Date.UTC(O[1],H,O[3]||1,O[4]||0,O[5]||0,O[6]||0,G)):new Date(O[1],H,O[3]||1,O[4]||0,O[5]||0,O[6]||0,G)}}return new Date(_)}(g),this.init()},S.init=function(){var g=this.$d;this.$y=g.getFullYear(),this.$M=g.getMonth(),this.$D=g.getDate(),this.$W=g.getDay(),this.$H=g.getHours(),this.$m=g.getMinutes(),this.$s=g.getSeconds(),this.$ms=g.getMilliseconds()},S.$utils=function(){return R},S.isValid=function(){return this.$d.toString()!==f},S.isSame=function(g,y){var _=N(g);return this.startOf(y)<=_&&_<=this.endOf(y)},S.isAfter=function(g,y){return N(g)<this.startOf(y)},S.isBefore=function(g,y){return this.endOf(y)<N(g)},S.$g=function(g,y,_){return R.u(g)?this[y]:this.set(_,g)},S.unix=function(){return Math.floor(this.valueOf()/1e3)},S.valueOf=function(){return this.$d.getTime()},S.startOf=function(g,y){var _=this,A=!!R.u(y)||y,O=R.p(g),H=function(z,B){var q=R.w(_.$u?Date.UTC(_.$y,B,z):new Date(_.$y,B,z),_);return A?q:q.endOf(u)},G=function(z,B){return R.w(_.toDate()[z].apply(_.toDate("s"),(A?[0,0,0,0]:[23,59,59,999]).slice(B)),_)},Q=this.$W,nt=this.$M,at=this.$D,it="set"+(this.$u?"UTC":"");switch(O){case C:return A?H(1,0):H(31,11);case p:return A?H(1,nt):H(0,nt+1);case h:var $=this.$locale().weekStart||0,T=(Q<$?Q+7:Q)-$;return H(A?at-T:at+(6-T),nt);case u:case v:return G(it+"Hours",0);case l:return G(it+"Minutes",1);case d:return G(it+"Seconds",2);case s:return G(it+"Milliseconds",3);default:return this.clone()}},S.endOf=function(g){return this.startOf(g,!1)},S.$set=function(g,y){var _,A=R.p(g),O="set"+(this.$u?"UTC":""),H=(_={},_[u]=O+"Date",_[v]=O+"Date",_[p]=O+"Month",_[C]=O+"FullYear",_[l]=O+"Hours",_[d]=O+"Minutes",_[s]=O+"Seconds",_[r]=O+"Milliseconds",_)[A],G=A===u?this.$D+(y-this.$W):y;if(A===p||A===C){var Q=this.clone().set(v,1);Q.$d[H](G),Q.init(),this.$d=Q.set(v,Math.min(this.$D,Q.daysInMonth())).$d}else H&&this.$d[H](G);return this.init(),this},S.set=function(g,y){return this.clone().$set(g,y)},S.get=function(g){return this[R.p(g)]()},S.add=function(g,y){var _,A=this;g=Number(g);var O=R.p(y),H=function(nt){var at=N(A);return R.w(at.date(at.date()+Math.round(nt*g)),A)};if(O===p)return this.set(p,this.$M+g);if(O===C)return this.set(C,this.$y+g);if(O===u)return H(1);if(O===h)return H(7);var G=(_={},_[d]=n,_[l]=i,_[s]=a,_)[O]||1,Q=this.$d.getTime()+g*G;return R.w(Q,this)},S.subtract=function(g,y){return this.add(-1*g,y)},S.format=function(g){var y=this,_=this.$locale();if(!this.isValid())return _.invalidDate||f;var A=g||"YYYY-MM-DDTHH:mm:ssZ",O=R.z(this),H=this.$H,G=this.$m,Q=this.$M,nt=_.weekdays,at=_.months,it=_.meridiem,$=function(B,q,lt,Ot){return B&&(B[q]||B(y,A))||lt[q].slice(0,Ot)},T=function(B){return R.s(H%12||12,B,"0")},z=it||function(B,q,lt){var Ot=B<12?"AM":"PM";return lt?Ot.toLowerCase():Ot};return A.replace(V,function(B,q){return q||function(lt){switch(lt){case"YY":return String(y.$y).slice(-2);case"YYYY":return R.s(y.$y,4,"0");case"M":return Q+1;case"MM":return R.s(Q+1,2,"0");case"MMM":return $(_.monthsShort,Q,at,3);case"MMMM":return $(at,Q);case"D":return y.$D;case"DD":return R.s(y.$D,2,"0");case"d":return String(y.$W);case"dd":return $(_.weekdaysMin,y.$W,nt,2);case"ddd":return $(_.weekdaysShort,y.$W,nt,3);case"dddd":return nt[y.$W];case"H":return String(H);case"HH":return R.s(H,2,"0");case"h":return T(1);case"hh":return T(2);case"a":return z(H,G,!0);case"A":return z(H,G,!1);case"m":return String(G);case"mm":return R.s(G,2,"0");case"s":return String(y.$s);case"ss":return R.s(y.$s,2,"0");case"SSS":return R.s(y.$ms,3,"0");case"Z":return O}return null}(B)||O.replace(":","")})},S.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},S.diff=function(g,y,_){var A,O=this,H=R.p(y),G=N(g),Q=(G.utcOffset()-this.utcOffset())*n,nt=this-G,at=function(){return R.m(O,G)};switch(H){case C:A=at()/12;break;case p:A=at();break;case c:A=at()/3;break;case h:A=(nt-Q)/6048e5;break;case u:A=(nt-Q)/864e5;break;case l:A=nt/i;break;case d:A=nt/n;break;case s:A=nt/a;break;default:A=nt}return _?A:R.a(A)},S.daysInMonth=function(){return this.endOf(p).$D},S.$locale=function(){return P[this.$L]},S.locale=function(g,y){if(!g)return this.$L;var _=this.clone(),A=k(g,y,!0);return A&&(_.$L=A),_},S.clone=function(){return R.w(this.$d,this)},S.toDate=function(){return new Date(this.valueOf())},S.toJSON=function(){return this.isValid()?this.toISOString():null},S.toISOString=function(){return this.$d.toISOString()},S.toString=function(){return this.$d.toUTCString()},D}(),X=W.prototype;return N.prototype=X,[["$ms",r],["$s",s],["$m",d],["$H",l],["$W",u],["$M",p],["$y",C],["$D",v]].forEach(function(D){X[D[1]]=function(S){return this.$g(S,D[0],D[1])}}),N.extend=function(D,S){return D.$i||(D(S,W,N),D.$i=!0),N},N.locale=k,N.isDayjs=j,N.unix=function(D){return N(1e3*D)},N.en=P[L],N.Ls=P,N.p={},N})})(Ee);var pn=Ee.exports;const $t=we(pn);var be={exports:{}};(function(t,e){(function(a,n){t.exports=n()})(ye,function(){var a="minute",n=/[+-]\d\d(?::?\d\d)?/g,i=/([+-]|\d\d)/g;return function(r,s,d){var l=s.prototype;d.utc=function(f){var w={date:f,utc:!0,args:arguments};return new s(w)},l.utc=function(f){var w=d(this.toDate(),{locale:this.$L,utc:!0});return f?w.add(this.utcOffset(),a):w},l.local=function(){return d(this.toDate(),{locale:this.$L,utc:!1})};var u=l.parse;l.parse=function(f){f.utc&&(this.$u=!0),this.$utils().u(f.$offset)||(this.$offset=f.$offset),u.call(this,f)};var h=l.init;l.init=function(){if(this.$u){var f=this.$d;this.$y=f.getUTCFullYear(),this.$M=f.getUTCMonth(),this.$D=f.getUTCDate(),this.$W=f.getUTCDay(),this.$H=f.getUTCHours(),this.$m=f.getUTCMinutes(),this.$s=f.getUTCSeconds(),this.$ms=f.getUTCMilliseconds()}else h.call(this)};var p=l.utcOffset;l.utcOffset=function(f,w){var V=this.$utils().u;if(V(f))return this.$u?0:V(this.$offset)?p.call(this):this.$offset;if(typeof f=="string"&&(f=function(L){L===void 0&&(L="");var P=L.match(n);if(!P)return null;var M=(""+P[0]).match(i)||["-",0,0],j=M[0],k=60*+M[1]+ +M[2];return k===0?0:j==="+"?k:-k}(f),f===null))return this;var b=Math.abs(f)<=16?60*f:f,I=this;if(w)return I.$offset=b,I.$u=f===0,I;if(f!==0){var F=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(I=this.local().add(b+F,a)).$offset=b,I.$x.$localOffset=F}else I=this.utc();return I};var c=l.format;l.format=function(f){var w=f||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return c.call(this,w)},l.valueOf=function(){var f=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*f},l.isUTC=function(){return!!this.$u},l.toISOString=function(){return this.toDate().toISOString()},l.toString=function(){return this.toDate().toUTCString()};var C=l.toDate;l.toDate=function(f){return f==="s"&&this.$offset?d(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():C.call(this)};var v=l.diff;l.diff=function(f,w,V){if(f&&this.$u===f.$u)return v.call(this,f,w,V);var b=this.local(),I=d(f).local();return v.call(b,I,w,V)}}})})(be);var fn=be.exports;const mn=we(fn);var vn=Object.defineProperty,gn=Object.getOwnPropertyDescriptor,Sn=(t,e,a,n)=>{for(var i=n>1?void 0:n?gn(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&vn(e,a,i),i},Tt=(t,e)=>(a,n)=>e(a,n,t);let Lt=class extends o.Disposable{constructor(t,e,a,n,i){super(),this._sheetInterceptorService=t,this._dataValidationModel=e,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(tt.AFTER_CELL_EDIT_ASYNC,{handler:async(t,e,a)=>{var f;const n=await t,{worksheet:i,row:r,col:s,unitId:d,subUnitId:l,workbook:u}=e,h=this._dataValidationModel.getRuleIdByLocation(d,l,r,s),p=h?this._dataValidationModel.getRuleById(d,l,h):void 0;if(!p||p.errorStyle!==o.DataValidationErrorStyle.STOP)return a(Promise.resolve(n));const c=await this._dataValidatorRegistryService.getValidatorItem(p.type);if(!c||await c.validator({value:x.getCellValueOrigin(n),interceptValue:x.getCellValueOrigin((f=e==null?void 0:e.origin)!=null?f:n),row:r,column:s,unitId:d,subUnitId:l,worksheet:i,workbook:u,t:n==null?void 0:n.t},p))return a(Promise.resolve(n));const v=i.getCellRaw(r,s);return this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:c.getRuleFinalError(p,{row:r,col:s,unitId:d,subUnitId:l})},footer:{title:E.createElement(U.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(Promise.resolve(v))}})}showReject(t){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:t},footer:{title:E.createElement(U.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Lt=Sn([Tt(0,o.Inject(tt.SheetInterceptorService)),Tt(1,o.Inject(x.SheetDataValidationModel)),Tt(2,o.Inject(ot.DataValidatorRegistryService)),Tt(3,et.IDialogService),Tt(4,o.Inject(o.LocaleService))],Lt);const Re={dvDateDropdown:"univer-dv-date-dropdown",dvDateDropdownBtns:"univer-dv-date-dropdown-btns"};$t.extend(mn);const _n=t=>{if(t==null||typeof t=="boolean")return;if(typeof t=="number"||!Number.isNaN(+t))return $t(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(t)));const e=$t(t);if(e.isValid())return e};function In(t){var P,M,j;const{location:e,hideFn:a}=t,{worksheet:n,row:i,col:r,unitId:s,subUnitId:d,workbook:l}=e,u=o.useDependency(o.ICommandService),h=o.useDependency(Lt),p=n.getCell(i,r),c=(P=p==null?void 0:p.dataValidation)==null?void 0:P.rule,C=(M=p==null?void 0:p.dataValidation)==null?void 0:M.validator,v=x.getCellValueOrigin(n.getCellRaw(i,r)),f=_n(v),[w,V]=E.useState(f),b=!!((j=c==null?void 0:c.bizInfo)!=null&&j.showTime),I=w&&w.isValid()?w:$t(),F=o.useDependency(o.LocaleService);if(!p||!c||!C)return;const L=async()=>{var S,g,y;if(!I)return;const N=I.format(b?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),R=(S=o.numfmt.parseDate(N))==null?void 0:S.v,W=l.getStyles().getStyleByCell(p),X=(y=(g=W==null?void 0:W.n)==null?void 0:g.pattern)!=null?y:"",D=on.getPatternType(X);c.errorStyle!==o.DataValidationErrorStyle.STOP||await C.validator({value:R,unitId:s,subUnitId:d,row:i,column:r,worksheet:n,workbook:l,interceptValue:N.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(a(),await u.executeCommand(K.SetCellEditVisibleOperation.id,{visible:!1,eventType:Z.DeviceInputEventType.Keyboard,unitId:s,keycode:et.KeyCode.ESC}),await u.executeCommand(tt.SetRangeValuesCommand.id,{unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:R,t:2,p:null,f:null,si:null,s:{n:{pattern:b?D==="datetime"?X:"yyyy-MM-dd hh:mm:ss":D==="date"?X:"yyyy-MM-dd"}}}})):h.showReject(C.getRuleFinalError(c,{row:i,col:r,unitId:s,subUnitId:d}))};return m.jsxs("div",{className:Re.dvDateDropdown,children:[m.jsx(U.DatePanel,{defaultValue:I,pickerValue:I,showTime:b||void 0,onSelect:async k=>{V(k)},onPanelChange:k=>{V(k)},disabledDate:k=>!o.numfmt.parseDate(k.format("YYYY-MM-DD"))}),m.jsx("div",{className:Re.dvDateDropdownBtns,children:m.jsx(U.Button,{size:"small",type:"primary",onClick:L,disabled:!I.isValid(),children:F.t("dataValidation.alert.ok")})})]})}var ct=function(){return ct=Object.assign||function(t){for(var e,a=1,n=arguments.length;a<n;a++){e=arguments[a];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},ct.apply(this,arguments)},Cn=function(t,e){var a={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(a[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(a[n[i]]=t[n[i]]);return a},vt=E.forwardRef(function(t,e){var a=t.icon,n=t.id,i=t.className,r=t.extend,s=Cn(t,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),l=E.useRef("_".concat(wn()));return Oe(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},ct({ref:e,className:d},s),r)});function Oe(t,e,a,n,i){return E.createElement(t.tag,ct(ct({key:e},Dn(t,a,i)),n),(yn(t,a).children||[]).map(function(r,s){return Oe(r,"".concat(e,"-").concat(t.tag,"-").concat(s),a,void 0,i)}))}function Dn(t,e,a){var n=ct({},t.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1);var i=e.defIds;return!i||i.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],d=r[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function yn(t,e){var a,n=e.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((a=t.children)===null||a===void 0)&&a.length)?ct(ct({},t),{children:t.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?ct(ct({},i),{attrs:ct(ct({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):t}function wn(){return Math.random().toString(36).substring(2,8)}vt.displayName="UniverIcon";var Mn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Te=E.forwardRef(function(t,e){return E.createElement(vt,Object.assign({},t,{id:"check-mark-single",ref:e,icon:Mn}))});Te.displayName="CheckMarkSingle";var Vn={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"}}]},Le=E.forwardRef(function(t,e){return E.createElement(vt,Object.assign({},t,{id:"data-validation-single",ref:e,icon:Vn}))});Le.displayName="DataValidationSingle";var En={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"}}]},ne=E.forwardRef(function(t,e){return E.createElement(vt,Object.assign({},t,{id:"delete-single",ref:e,icon:En}))});ne.displayName="DeleteSingle";var bn={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"}}]},Pe=E.forwardRef(function(t,e){return E.createElement(vt,Object.assign({},t,{id:"increase-single",ref:e,icon:bn}))});Pe.displayName="IncreaseSingle";var Rn={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"}}]},je=E.forwardRef(function(t,e){return E.createElement(vt,Object.assign({},t,{id:"more-down-single",ref:e,icon:Rn}))});je.displayName="MoreDownSingle";var On={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"}}]},Ae=E.forwardRef(function(t,e){return E.createElement(vt,Object.assign({},t,{id:"more-up-single",ref:e,icon:On}))});Ae.displayName="MoreUpSingle";var Tn={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"}}]}]},$e=E.forwardRef(function(t,e){return E.createElement(vt,Object.assign({},t,{id:"sequence-single",ref:e,icon:Tn}))});$e.displayName="SequenceSingle";var Ln=Object.defineProperty,Pn=Object.getOwnPropertyDescriptor,jn=(t,e,a,n)=>{for(var i=n>1?void 0:n?Pn(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&Ln(e,a,i),i},Fe=(t,e)=>(a,n)=>e(a,n,t);let ht=class extends o.Disposable{constructor(e,a){super();Y(this,"_open$",new dt.BehaviorSubject(!1));Y(this,"open$",this._open$.pipe(dt.distinctUntilChanged()));Y(this,"_activeRule");Y(this,"_activeRule$",new dt.BehaviorSubject(void 0));Y(this,"activeRule$",this._activeRule$.asObservable());Y(this,"_closeDisposable",null);this._univerInstanceService=e,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(dt.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===ae&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var e;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(e=this._closeDisposable)==null||e.dispose()}open(){this._open$.next(!0)}close(){var e;this._open$.next(!1),(e=this._closeDisposable)==null||e.dispose()}setCloseDisposable(e){this._closeDisposable=o.toDisposable(()=>{e.dispose(),this._closeDisposable=null})}setActiveRule(e){this._activeRule=e,this._activeRule$.next(e)}};ht=jn([Fe(0,o.IUniverInstanceService),Fe(1,et.ISidebarService)],ht);function An(){const t=o.useDependency(gt),e=et.useObservable(t.activeDropdown$,t.activeDropdown),a=o.useDependency(et.ComponentManager);if(!e)return null;const{location:n,componentKey:i}=e,r=a.get(i),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!r)return null;const d=()=>{t.hideDropdown()};return m.jsx(r,{location:n,hideFn:d},s)}const xe="sheet.ui.dropdown";var $n=Object.defineProperty,Fn=Object.getOwnPropertyDescriptor,xn=(t,e,a,n)=>{for(var i=n>1?void 0:n?Fn(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&$n(e,a,i),i},St=(t,e)=>(a,n)=>e(a,n,t);let gt=class extends o.Disposable{constructor(e,a,n,i,r,s,d){super();Y(this,"_activeDropdown");Y(this,"_activeDropdown$",new dt.Subject);Y(this,"_currentPopup",null);Y(this,"activeDropdown$",this._activeDropdown$.asObservable());Y(this,"_zenVisible",!1);this._canvasPopupManagerService=e,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=i,this._renderManagerService=r,this._dataValidationModel=s,this._sheetsSelectionsService=d,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{this._zenVisible=e,e&&this.hideDropdown()}))}_getDropdownByCell(e,a,n,i){const r=e?this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!r)return;const s=a?r.getSheetBySheetId(a):r.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(r.getUnitId(),s.getSheetId(),n,i);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdown}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(e=>{e&&e.every(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(e,a=!0){const{location:n}=e,{row:i,col:r,unitId:s,subUnitId:d}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=e,this._activeDropdown$.next(this._activeDropdown);const l=this._renderManagerService.getRenderById(o.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),u=this._canvasPopupManagerService.attachPopupToCell(i,r,{componentKey:xe,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[l==null?void 0:l.engine.getCanvasElement()].filter(Boolean)},s,d);if(!u)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const h=new o.DisposableCollection;h.add(u),h.add({dispose:()=>{var p,c;(c=(p=this._activeDropdown)==null?void 0:p.onHide)==null||c.call(p)}}),this._currentPopup=h}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(e,a,n,i,r){const s=this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(a);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,i);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!u||!u.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:i,unitId:e,subUnitId:a},componentKey:u.dropdown,onHide:r})}};gt=xn([St(0,o.Inject(K.SheetCanvasPopManagerService)),St(1,o.IUniverInstanceService),St(2,o.Inject(ot.DataValidatorRegistryService)),St(3,et.IZenZoneService),St(4,Z.IRenderManagerService),St(5,o.Inject(x.SheetDataValidationModel)),St(6,o.Inject(tt.SheetsSelectionsService))],gt);const ae="DataValidationPanel",_t={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(t,e){if(!e)return!1;const{ruleId:a,isAdd:n}=e,i=t.get(ht),r=t.get(ot.DataValidationModel),s=t.get(o.IUniverInstanceService),d=t.get(et.ISidebarService),l=tt.getSheetCommandTarget(s);if(!l)return!1;const{unitId:u,subUnitId:h}=l,p=a?r.getRuleById(u,h,a):void 0;i.open(),i.setActiveRule(p&&{unitId:u,subUnitId:h,rule:p});const c=d.open({header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:ae},width:312,onClose:()=>i.close()});return i.setCloseDisposable(c),!0}},ie={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(t){return t.get(ht).close(),!0}},Ne={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(t){const e=t.get(o.ICommandService),a=t.get(ht);return a.open(),a.isOpen?e.executeCommand(ie.id):e.executeCommand(_t.id),!0}},Ft={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(t,e){if(!e)return!1;const a=t.get(gt),{unitId:n,subUnitId:i,row:r,column:s}=e,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===i&&l.row===r&&l.col===s||a.showDataValidationDropdown(n,i,r,s),!0}},Ue={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(t,e){return e?(t.get(gt).hideDropdown(),!0):!1}},It="#ECECEC",oe="sheets-data-validation-ui.config",ke={},mt={dvListDropdown:"univer-dv-list-dropdown",dvListDropdownTitle:"univer-dv-list-dropdown-title",dvListDropdownList:"univer-dv-list-dropdown-list",dvListDropdownListContainer:"univer-dv-list-dropdown-list-container",dvListDropdownSelectedIcon:"univer-dv-list-dropdown-selected-icon",dvListDropdownItemContainer:"univer-dv-list-dropdown-item-container",dvListDropdownItem:"univer-dv-list-dropdown-item",dvListDropdownSplit:"univer-dv-list-dropdown-split",dvListDropdownEdit:"univer-dv-list-dropdown-edit"},Nn=t=>{var L,P;const{value:e,onChange:a,multiple:n,options:i,title:r,onEdit:s,style:d,filter:l,location:u}=t,h=o.useDependency(o.LocaleService),p=o.useDependency(o.IConfigService),c=l==null?void 0:l.toLowerCase(),{row:C,col:v,unitId:f,subUnitId:w}=u,V=i.filter(M=>c?M.label.toLowerCase().includes(c):!0),b=(P=(L=p.getConfig(oe))==null?void 0:L.showEditOnDropdown)!=null?P:!0,I=o.useDependency(K.SheetPermissionInterceptorBaseController),F=E.useMemo(()=>I.permissionCheckWithRanges({workbookTypes:[tt.WorkbookEditablePermission],rangeTypes:[tt.RangeProtectionPermissionEditPoint],worksheetTypes:[tt.WorksheetEditPermission]},[{startColumn:v,startRow:C,endColumn:v,endRow:C}],f,w),[I,v,C,f,w]);return m.jsxs("div",{className:mt.dvListDropdown,style:d,children:[m.jsx("div",{className:mt.dvListDropdownTitle,children:r}),m.jsx("div",{className:mt.dvListDropdownList,children:m.jsx(U.Scrollbar,{children:m.jsx("div",{className:mt.dvListDropdownListContainer,children:V.map((M,j)=>{const k=e.indexOf(M.value)>-1,N=()=>{let W;k?W=new Set(e.filter(D=>D!==M.value)):W=new Set(n?[...e,M.value]:[M.value]);const X=[];i.forEach(D=>{W.has(D.value)&&X.push(D.value)}),a(X)},R=M.label.toLocaleLowerCase().indexOf(c);return m.jsxs("div",{className:mt.dvListDropdownItemContainer,onClick:N,children:[m.jsx("div",{className:mt.dvListDropdownItem,style:{background:M.color||It},children:c&&M.label.toLowerCase().includes(c)?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:M.label.substring(0,R)}),m.jsx("span",{style:{fontWeight:"bold"},children:M.label.substring(R,R+c.length)}),m.jsx("span",{children:M.label.substring(R+c.length)})]}):M.label}),m.jsx("div",{className:mt.dvListDropdownSelectedIcon,children:k?m.jsx(Te,{}):null})]},j)})})},l)}),b&&F?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:mt.dvListDropdownSplit}),m.jsx("div",{className:mt.dvListDropdownEdit,children:m.jsx("a",{onClick:s,children:h.t("dataValidation.list.edit")})})]}):null]})};function Un(t){var D,S,g,y,_,A;const{location:e,hideFn:a}=t,{worksheet:n,row:i,col:r,unitId:s,subUnitId:d}=e,l=o.useDependency(ot.DataValidationModel),[u,h]=E.useState(""),p=o.useDependency(o.ICommandService),c=o.useDependency(o.LocaleService),[C,v]=E.useState(""),f=o.useDependency(K.IEditorBridgeService),w=o.useDependency(o.IUniverInstanceService),V=E.useMemo(()=>l.ruleChange$.pipe(dt.debounceTime(16)),[]);et.useObservable(V);const b=et.RectPopup.useContext(),I=((S=(D=b.current)==null?void 0:D.right)!=null?S:0)-((y=(g=b.current)==null?void 0:g.left)!=null?y:0);if(E.useEffect(()=>{const O=p.onCommandExecuted(H=>{var G,Q;if(H.id===rn.RichTextEditingMutation.id){const nt=H.params,{unitId:at}=nt,it=w.getUnit(at,o.UniverInstanceType.UNIVER_DOC);if(!it)return;const $=o.BuildTextUtils.transform.getPlainText((Q=(G=it.getSnapshot().body)==null?void 0:G.dataStream)!=null?Q:"");h($)}});return()=>{O.dispose()}},[p,w]),!n)return null;const F=n.getCell(i,r),L=(_=F==null?void 0:F.dataValidation)==null?void 0:_.rule,P=(A=F==null?void 0:F.dataValidation)==null?void 0:A.validator,M=(L==null?void 0:L.renderMode)===o.DataValidationRenderMode.CUSTOM||(L==null?void 0:L.renderMode)===void 0;if(!F||!L||!P||P.id.indexOf(o.DataValidationType.LIST)!==0)return;const j=L.type===o.DataValidationType.LIST_MULTIPLE,k=P.getListWithColor(L,s,d),N=C||x.getDataValidationCellValue(n.getCellRaw(i,r)),R=x.deserializeListOptions(N),W=()=>{p.executeCommand(_t.id,{ruleId:L.uid}),a()},X=k.map(O=>({label:O.label,value:O.label,color:M||O.color?O.color:"transparent"}));return m.jsx(Nn,{style:{minWidth:I,maxWidth:Math.max(I,200)},title:j?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:R,multiple:j,onChange:async O=>{const H=x.serializeListOptions(O),G={unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:i,endRow:i},value:{v:H,p:null,f:null,si:null}};f.isVisible()&&f.changeVisible({visible:!1,keycode:et.KeyCode.ESC,eventType:Z.DeviceInputEventType.Keyboard,unitId:s}),v(H),j||a(),f.isVisible().visible&&await p.executeCommand(K.SetCellEditVisibleOperation.id,{visible:!1,eventType:Z.DeviceInputEventType.Keyboard,unitId:s,keycode:et.KeyCode.ESC}),p.executeCommand(tt.SetRangeValuesCommand.id,G)},options:X,onEdit:W,filter:u,location:e})}const re={dataValidationOptionsButton:"univer-data-validation-options-button",dataValidationOptionsButtonIcon:"univer-data-validation-options-button-icon"};function kn(t){var u;const e=o.useDependency(o.LocaleService),a=o.useDependency(et.ComponentManager),{value:n,onChange:i,extraComponent:r}=t,[s,d]=E.useState(!1),l=r?a.get(r):null;return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:re.dataValidationOptionsButton,onClick:()=>d(!s),children:[e.t("dataValidation.panel.options"),s?m.jsx(Ae,{className:re.dataValidationOptionsButtonIcon}):m.jsx(je,{className:re.dataValidationOptionsButtonIcon})]}),s&&m.jsxs(m.Fragment,{children:[l?m.jsx(l,{value:n,onChange:i}):null,m.jsx(U.FormLayout,{label:e.t("dataValidation.panel.invalid"),children:m.jsxs(U.RadioGroup,{value:`${(u=n.errorStyle)!=null?u:o.DataValidationErrorStyle.WARNING}`,onChange:h=>i({...n,errorStyle:+h}),children:[m.jsx(U.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:e.t("dataValidation.panel.showWarning")}),m.jsx(U.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:e.t("dataValidation.panel.rejectInput")})]})}),m.jsx(U.FormLayout,{label:e.t("dataValidation.panel.messageInfo"),children:m.jsx(U.Checkbox,{checked:n.showErrorMessage,onChange:()=>i({...n,showErrorMessage:!n.showErrorMessage}),children:e.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?m.jsx(U.FormLayout,{children:m.jsx(U.Input,{value:n.error,onChange:h=>i({...n,error:h})})}):null]})]})}const yt={dataValidationDetail:"univer-data-validation-detail",dataValidationDetailFormItem:"univer-data-validation-detail-form-item",dataValidationDetailButtons:"univer-data-validation-detail-buttons",dataValidationDetailButton:"univer-data-validation-detail-button"},Bn=t=>o.debounce(async(e,a,n,i)=>{const r=await t.executeCommand(e,a,n);i==null||i(r)},1e3);function Wn(t,e,a){var n,i,r,s;return e?((i=(n=t.getUnit(e))==null?void 0:n.getSheetBySheetName(a))==null?void 0:i.getSheetId())||"":((s=(r=t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Hn(){var it;const[t,e]=E.useState(0),a=o.useDependency(ht),n=et.useObservable(a.activeRule$,a.activeRule),{unitId:i,subUnitId:r,rule:s}=n||{},d=s.uid,l=o.useDependency(ot.DataValidatorRegistryService),u=o.useDependency(o.IUniverInstanceService),h=o.useDependency(et.ComponentManager),p=o.useDependency(o.ICommandService),c=o.useDependency(ot.DataValidationModel),C=o.useDependency(o.LocaleService),[v,f]=E.useState(s),w=l.getValidatorItem(v.type),[V,b]=E.useState(!1),I=l.getValidatorsByScope(ot.DataValidatorRegistryScope.SHEET),[F,L]=E.useState(()=>v.ranges.map($=>({unitId:"",sheetId:"",range:$}))),P=E.useMemo(()=>Bn(p),[p]),[M,j]=E.useState(!1),k=E.useRef({}),[N,R]=E.useState(!1),W=o.useDependency(tt.SheetsSelectionsService);if(E.useEffect(()=>()=>{const $=W.getCurrentLastSelection();$&&W.setSelections([$])},[W]),E.useEffect(()=>{p.onCommandExecuted($=>{($.id===o.UndoCommand.id||$.id===o.RedoCommand.id)&&setTimeout(()=>{const T=c.getRuleById(i,r,d);e(z=>z+1),T&&(f(T),L(T.ranges.map(z=>({unitId:"",sheetId:"",range:z}))))},20)})},[p,c,d,r,i]),!w)return null;const X=w.operators,D=w.operatorNames,S=v.operator?ot.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,g=()=>{!v.ranges.length||M||(w.validatorFormula(v,i,r).success?a.setActiveRule(null):b(!0))},y=et.useEvent($=>{const T=$.split(",").map(te.deserializeRangeWithSheet).map(q=>{const lt=q.sheetName;if(lt){const Ot=Wn(u,q.unitId,lt);return{...q,sheetId:Ot}}return{...q,sheetId:""}});if(o.isUnitRangesEqual(T,F))return;L(T);const z=T.filter(q=>(!q.unitId||q.unitId===i)&&(!q.sheetId||q.sheetId===r)).map(q=>q.range);if(f({...v,ranges:z}),z.length===0)return;const B={unitId:i,subUnitId:r,ruleId:d,ranges:z};P(x.UpdateSheetDataValidationRangeCommand.id,B)}),_=$=>{if(o.shallowEqual($,ot.getRuleSetting(v)))return;f({...v,...$});const T={unitId:i,subUnitId:r,ruleId:d,setting:$};P(x.UpdateSheetDataValidationSettingCommand.id,T,void 0)},A=async()=>{await p.executeCommand(x.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:i,subUnitId:r}),a.setActiveRule(null)},O={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},H=$=>{const T=l.getValidatorItem($);if(!T)return;const z=T.operators,B=c.getRuleById(i,r,d),q=$===(B==null?void 0:B.type)||$.includes("list")&&(B!=null&&B.type.includes("list"))?{...B,type:$}:{...v,type:$,operator:z[0],formula1:void 0,formula2:void 0};f(q),p.executeCommand(x.UpdateSheetDataValidationSettingCommand.id,{unitId:i,subUnitId:r,ruleId:v.uid,setting:ot.getRuleSetting(q)})},G=h.get(w.formulaInput),Q=E.useMemo(()=>F.map($=>te.serializeRange($.range)).join(","),[]),nt=ot.getRuleOptions(v),at=$=>{o.shallowEqual($,ot.getRuleOptions(v))||(f({...v,...$}),P(x.UpdateSheetDataValidationOptionsCommand.id,{unitId:i,subUnitId:r,ruleId:d,options:$}))};return et.useSidebarClick($=>{var z;const T=(z=k.current)==null?void 0:z.handleOutClick;T&&T($,()=>R(!1))}),m.jsxs("div",{className:yt.dataValidationDetail,children:[m.jsx(U.FormLayout,{label:C.t("dataValidation.panel.range"),error:!v.ranges.length||M?C.t("dataValidation.panel.rangeError"):"",children:m.jsx(ee.RangeSelector,{unitId:i,subUnitId:r,initValue:Q,onChange:y,onFocus:()=>R(!0),isFocus:N,actions:k.current,onVerify:$=>j(!$)})}),m.jsx(U.FormLayout,{label:C.t("dataValidation.panel.type"),children:m.jsx(U.Select,{options:I==null?void 0:I.map($=>({label:C.t($.title),value:$.id})),value:v.type,onChange:H,className:yt.dataValidationDetailFormItem})}),X!=null&&X.length?m.jsx(U.FormLayout,{label:C.t("dataValidation.panel.operator"),children:m.jsx(U.Select,{options:X.map(($,T)=>({value:`${$}`,label:D[T]})),value:`${v.operator}`,onChange:$=>{_({...O,operator:$})},className:yt.dataValidationDetailFormItem})}):null,G?m.jsx(G,{isTwoFormula:S,value:{formula1:v.formula1,formula2:v.formula2},onChange:$=>{_({...O,...$})},showError:V,validResult:w.validatorFormula(v,i,r),unitId:i,subUnitId:r,ruleId:d},t+v.type):null,m.jsx(U.FormLayout,{children:m.jsx(U.Checkbox,{checked:(it=v.allowBlank)!=null?it:!0,onChange:()=>{var $;return _({...O,allowBlank:!(($=v.allowBlank)==null||$)})},children:C.t("dataValidation.panel.allowBlank")})}),m.jsx(kn,{value:nt,onChange:at,extraComponent:w.optionsInput}),m.jsxs("div",{className:yt.dataValidationDetailButtons,children:[m.jsx(U.Button,{className:yt.dataValidationDetailButton,onClick:A,children:C.t("dataValidation.panel.removeRule")}),m.jsx(U.Button,{className:yt.dataValidationDetailButton,type:"primary",onClick:g,children:C.t("dataValidation.panel.done")})]})]})}const xt={dataValidationItemContainer:"univer-data-validation-item-container",dataValidationItemTitle:"univer-data-validation-item-title",dataValidationItemContent:"univer-data-validation-item-content",dataValidationItemIcon:"univer-data-validation-item-icon"},Yn=t=>{const{rule:e,onClick:a,unitId:n,subUnitId:i,disable:r}=t,s=o.useDependency(ot.DataValidatorRegistryService),d=o.useDependency(o.ICommandService),l=o.useDependency(K.IMarkSelectionService),u=s.getValidatorItem(e.type),h=E.useRef(),[p,c]=E.useState(!1),C=v=>{d.executeCommand(x.RemoveSheetDataValidationCommand.id,{ruleId:e.uid,unitId:n,subUnitId:i}),v.stopPropagation()};return E.useEffect(()=>()=>{var v;h.current&&((v=h.current)==null||v.forEach(f=>{f&&l.removeShape(f)}))},[l]),m.jsxs("div",{className:xt.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{r||(c(!0),h.current=e.ranges.map(v=>l.addShape({range:v,style:{hasAutoFill:!1,fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:null})))},onMouseLeave:()=>{var v;c(!1),(v=h.current)==null||v.forEach(f=>{f&&l.removeShape(f)}),h.current=void 0},children:[m.jsx("div",{className:xt.dataValidationItemTitle,children:u==null?void 0:u.generateRuleName(e)}),m.jsx("div",{className:xt.dataValidationItemContent,children:e.ranges.map(v=>te.serializeRange(v)).join(",")}),p?m.jsx("div",{className:xt.dataValidationItemIcon,onClick:C,children:m.jsx(ne,{})}):null]})},Nt={dataValidationList:"univer-data-validation-list",dataValidationListButtons:"univer-data-validation-list-buttons",dataValidationListButton:"univer-data-validation-list-button"};function Xn(){const t=o.useDependency(o.IUniverInstanceService),e=et.useObservable(()=>t.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return e?m.jsx(zn,{workbook:e}):null}function zn(t){const e=o.useDependency(x.SheetDataValidationModel),a=o.useDependency(o.IUniverInstanceService),n=o.useDependency(o.ICommandService),i=o.useDependency(o.Injector),r=o.useDependency(ht),s=o.useDependency(o.LocaleService),[d,l]=E.useState([]),{workbook:u}=t,h=et.useObservable(u.activeSheet$,void 0,!0),p=u.getUnitId(),c=h==null?void 0:h.getSheetId();E.useEffect(()=>{l(e.getRules(p,c));const b=e.ruleChange$.subscribe(I=>{I.unitId===p&&I.subUnitId===c&&l(e.getRules(p,c))});return()=>{b.unsubscribe()}},[p,c,e]);const C=async()=>{const b=x.createDefaultNewRule(i),I={unitId:p,subUnitId:c,rule:b};await n.executeCommand(x.AddSheetDataValidationCommand.id,I),r.setActiveRule({unitId:p,subUnitId:c,rule:b})},v=()=>{n.executeCommand(x.RemoveSheetAllDataValidationCommand.id,{unitId:p,subUnitId:c})},w=(b=>{const I=a.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),F=I.getActiveSheet(),L=I.getUnitId(),P=F.getSheetId();return b.map(j=>tt.checkRangesEditablePermission(i,L,P,j.ranges)?{...j}:{...j,disable:!0})})(d),V=w==null?void 0:w.some(b=>b.disable);return m.jsxs("div",{className:Nt.dataValidationList,children:[w==null?void 0:w.map(b=>{var I;return m.jsx(Yn,{unitId:p,subUnitId:c,onClick:()=>{b.disable||r.setActiveRule({unitId:p,subUnitId:c,rule:b})},rule:b,disable:(I=b.disable)!=null?I:!1},b.uid)}),m.jsxs("div",{className:Nt.dataValidationListButtons,children:[d.length&&!V?m.jsx(U.Button,{className:Nt.dataValidationListButton,onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,m.jsx(U.Button,{className:Nt.dataValidationListButton,type:"primary",onClick:C,children:s.t("dataValidation.panel.add")})]})]})}const Kn=()=>{const t=o.useDependency(ht),e=et.useObservable(t.activeRule$,t.activeRule);return e?m.jsx(Hn,{},e.rule.uid):m.jsx(Xn,{})},Ut="data-validation.list.dropdown",se="data-validation.date.dropdown",kt={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(t){const e=t.get(o.IUniverInstanceService),a=tt.getSheetCommandTarget(e);if(!a)return!1;const{workbook:n,worksheet:i}=a,r=x.createDefaultNewRule(t),s=t.get(o.ICommandService),d=n.getUnitId(),l=i.getSheetId(),u={rule:r,unitId:d,subUnitId:l};return s.syncExecuteCommand(x.AddSheetDataValidationCommand.id,u)?(s.syncExecuteCommand(_t.id,{ruleId:r.uid,isAdd:!0}),!0):!1}};var Gn=Object.defineProperty,Zn=Object.getOwnPropertyDescriptor,qn=(t,e,a,n)=>{for(var i=n>1?void 0:n?Zn(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&Gn(e,a,i),i},Pt=(t,e)=>(a,n)=>e(a,n,t);const Bt="SHEET_DATA_VALIDATION_ALERT";let jt=class extends o.Disposable{constructor(t,e,a,n,i){super(),this._hoverManagerService=t,this._cellAlertManagerService=e,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(dt.debounceTime(100)).subscribe(t=>{var e,a;if(t){const i=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!i)return;const r=i.getCell(t.location.row,t.location.col);if(((e=r==null?void 0:r.dataValidation)==null?void 0:e.validStatus)===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Bt),d=(a=s==null?void 0:s.alert)==null?void 0:a.location;if(d&&d.row===t.location.row&&d.col===t.location.col&&d.subUnitId===t.location.subUnitId&&d.unitId===t.location.unitId)return;const l=r.dataValidation.validator,u=r.dataValidation.rule;if(!l)return;this._cellAlertManagerService.showAlert({type:K.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(u,t.location),location:t.location,width:200,height:74,key:Bt});return}}this._cellAlertManagerService.removeAlert(Bt)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t&&this._cellAlertManagerService.removeAlert(Bt)}))}};jt=qn([Pt(0,o.Inject(K.HoverManagerService)),Pt(1,o.Inject(K.CellAlertManagerService)),Pt(2,o.IUniverInstanceService),Pt(3,o.Inject(o.LocaleService)),Pt(4,et.IZenZoneService)],jt);var Jn=Object.defineProperty,Qn=Object.getOwnPropertyDescriptor,ta=(t,e,a,n)=>{for(var i=n>1?void 0:n?Qn(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&Jn(e,a,i),i},le=(t,e)=>(a,n)=>e(a,n,t);let wt=class extends o.Disposable{constructor(t,e,a){super(),this._autoFillService=t,this._dataValidationModel=e,this._injector=a,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),e=(i,r)=>{const{source:s,target:d,unitId:l,subUnitId:u}=i,h=this._dataValidationModel.getRuleObjectMatrix(l,u).clone(),p=K.virtualizeDiscreteRanges([s,d]),[c,C]=p.ranges,{mapFunc:v}=p,f={row:c.startRow,col:c.startColumn},w=K.getAutoFillRepeatRange(c,C),V=new o.ObjectMatrix,b=new Set;w.forEach(M=>{const j=M.repeatStartCell,k=M.relativeRange,N={startRow:f.row,startColumn:f.col,endColumn:f.col,endRow:f.row},R={startRow:j.row,startColumn:j.col,endColumn:j.col,endRow:j.row};o.Range.foreach(k,(W,X)=>{const D=o.Rectangle.getPositionRange({startRow:W,startColumn:X,endColumn:X,endRow:W},N),{row:S,col:g}=v(D.startRow,D.startColumn),y=this._dataValidationModel.getRuleIdByLocation(l,u,S,g);if(y){const _=o.Rectangle.getPositionRange({startRow:W,startColumn:X,endColumn:X,endRow:W},R),{row:A,col:O}=v(_.startRow,_.startColumn);V.setValue(A,O,y),b.add(y)}})});const I=Array.from(b).map(M=>({id:M,ranges:o.queryObjectMatrix(V,j=>j===M)}));h.addRangeRules(I);const F=h.diff(this._dataValidationModel.getRules(l,u)),{redoMutations:L,undoMutations:P}=x.getDataValidationDiffMutations(l,u,F,this._injector,"patched",r===K.APPLY_TYPE.ONLY_FORMAT);return{undos:P,redos:L}},a=[o.DataValidationType.CHECKBOX],n={id:x.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:i=>{const{source:r,unitId:s,subUnitId:d}=i;for(const l of r.rows)for(const u of r.cols){const h=this._dataValidationModel.getRuleByLocation(s,d,l,u);if(h&&a.indexOf(h.type)>-1){this._autoFillService.setDisableApplyType(K.APPLY_TYPE.SERIES,!0);return}}},onFillData:(i,r,s)=>s===K.APPLY_TYPE.COPY||s===K.APPLY_TYPE.ONLY_FORMAT||s===K.APPLY_TYPE.SERIES?e(i,s):t(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};wt=ta([le(0,K.IAutoFillService),le(1,o.Inject(x.SheetDataValidationModel)),le(2,o.Inject(o.Injector))],wt);var ea=Object.defineProperty,na=Object.getOwnPropertyDescriptor,aa=(t,e,a,n)=>{for(var i=n>1?void 0:n?na(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&ea(e,a,i),i},de=(t,e)=>(a,n)=>e(a,n,t);let Mt=class extends o.Disposable{constructor(e,a,n){super();Y(this,"_copyInfo");this._sheetClipboardService=e,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:x.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(e,a,n)=>this._collect(e,a,n),onPasteCells:(e,a,n,i)=>{const{copyType:r=K.COPY_TYPE.COPY,pasteType:s}=i,{range:d}=e||{},{range:l,unitId:u,subUnitId:h}=a;return this._generateMutations(l,{copyType:r,pasteType:s,copyRange:d,unitId:u,subUnitId:h})}})}_collect(e,a,n){const i=new o.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:a,matrix:i};const r=this._injector.invoke(l=>K.rangeToDiscreteRange(n,l,e,a));if(!r)return;const{rows:s,cols:d}=r;s.forEach((l,u)=>{d.forEach((h,p)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(e,a,l,h);i.setValue(u,p,c!=null?c:"")})})}_generateMutations(e,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===K.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,K.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:n,subUnitId:i}=this._copyInfo;if(a.unitId!==n||i!==a.subUnitId){const r=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),s=new o.ObjectMatrix,d=new Set,{ranges:[l,u],mapFunc:h}=K.virtualizeDiscreteRanges([a.copyRange,e]),p=K.getRepeatRange(l,u,!0),c=new Map;p.forEach(({startRange:w})=>{var V;(V=this._copyInfo)==null||V.matrix.forValue((b,I,F)=>{const L=o.Rectangle.getPositionRange({startRow:b,endRow:b,startColumn:I,endColumn:I},w),P=`${i}-${F}`,M=this._sheetDataValidationModel.getRuleById(n,i,F);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,P)&&M&&c.set(P,{...M,uid:P});const{row:j,col:k}=h(L.startRow,L.startColumn);d.add(P),s.setValue(j,k,P)})});const C=Array.from(d).map(w=>({id:w,ranges:o.queryObjectMatrix(s,V=>V===w)}));r.addRangeRules(C);const{redoMutations:v,undoMutations:f}=x.getDataValidationDiffMutations(a.unitId,a.subUnitId,r.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),c.values()),this._injector,"patched",!1);return{redos:v,undos:f}}else{const r=this._sheetDataValidationModel.getRuleObjectMatrix(n,i).clone(),s=new o.ObjectMatrix,d=new Set,{ranges:[l,u],mapFunc:h}=K.virtualizeDiscreteRanges([a.copyRange,e]);K.getRepeatRange(l,u,!0).forEach(({startRange:f})=>{var w;(w=this._copyInfo)==null||w.matrix.forValue((V,b,I)=>{const F=o.Rectangle.getPositionRange({startRow:V,endRow:V,startColumn:b,endColumn:b},f),{row:L,col:P}=h(F.startRow,F.startColumn);s.setValue(L,P,I),d.add(I)})});const c=Array.from(d).map(f=>({id:f,ranges:o.queryObjectMatrix(s,w=>w===f)}));r.addRangeRules(c);const{redoMutations:C,undoMutations:v}=x.getDataValidationDiffMutations(n,i,r.diff(this._sheetDataValidationModel.getRules(n,i)),this._injector,"patched",!1);return{redos:C,undos:v}}}};Mt=aa([de(0,K.ISheetClipboardService),de(1,o.Inject(x.SheetDataValidationModel)),de(2,o.Inject(o.Injector))],Mt);var ia=Object.defineProperty,oa=Object.getOwnPropertyDescriptor,ra=(t,e,a,n)=>{for(var i=n>1?void 0:n?oa(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&ia(e,a,i),i},ce=(t,e)=>(a,n)=>e(a,n,t);let Vt=class extends o.Disposable{constructor(t,e,a){super(),this._localeService=t,this._commandService=e,this._sheetPermissionInterceptorBaseController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===x.AddSheetDataValidationCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[tt.WorkbookEditablePermission],rangeTypes:[tt.RangeProtectionPermissionEditPoint],worksheetTypes:[tt.WorksheetEditPermission,tt.WorksheetSetCellStylePermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr"))),t.id===x.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[tt.WorkbookEditablePermission],rangeTypes:[tt.RangeProtectionPermissionEditPoint],worksheetTypes:[tt.WorksheetEditPermission,tt.WorksheetSetCellStylePermission]},t.params.ranges)||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr")))}))}};Vt=ra([ce(0,o.Inject(o.LocaleService)),ce(1,o.ICommandService),ce(2,o.Inject(K.SheetPermissionInterceptorBaseController))],Vt);const Be="data-validation-single",We="sheet.menu.data-validation";function sa(t){return{id:We,type:et.MenuItemType.SUBITEMS,icon:Be,tooltip:"dataValidation.title",hidden$:et.getMenuHiddenObservable(t,o.UniverInstanceType.UNIVER_SHEET),disabled$:K.getCurrentRangeDisable$(t,{workbookTypes:[tt.WorkbookEditablePermission],worksheetTypes:[tt.WorksheetSetCellStylePermission,tt.WorksheetEditPermission],rangeTypes:[tt.RangeProtectionPermissionEditPoint]})}}function la(t){return{id:_t.id,title:"dataValidation.panel.title",type:et.MenuItemType.BUTTON}}function da(t){return{id:kt.id,title:"dataValidation.panel.add",type:et.MenuItemType.BUTTON}}const ca={[et.RibbonStartGroup.FORMULAS_INSERT]:{[We]:{order:9,menuItemFactory:sa,[_t.id]:{order:0,menuItemFactory:la},[kt.id]:{order:1,menuItemFactory:da}}}};var ua=Object.defineProperty,ha=Object.getOwnPropertyDescriptor,He=(t,e,a,n)=>{for(var i=n>1?void 0:n?ha(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&ua(e,a,i),i},rt=(t,e)=>(a,n)=>e(a,n,t);const Ye={tr:{size:6,color:"#fe4b4b"}};let Et=class extends o.RxDisposable{constructor(t,e,a,n,i,r,s,d,l,u,h){super(),this._commandService=t,this._menuManagerService=e,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=i,this._dropdownManagerService=r,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=u,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(ca)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{var a;if(!t.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const e=this._editorBridgeService.getEditCellState();if(e){const{unitId:n,sheetId:i,row:r,column:s}=e,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,i,r,s);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(u!=null&&u.dropdown))return;const h=d.getActiveSheet();if(!h)return;const p=this._dropdownManagerService.activeDropdown,c=p==null?void 0:p.location;if(c&&c.unitId===n&&c.subUnitId===i&&c.row===r&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:i,row:r,col:s,workbook:d,worksheet:h},componentKey:u.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(tt.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:tt.InterceptCellContentPriority.DATA_VALIDATION,handler:(t,e,a)=>{var V,b,I,F,L,P;const{row:n,col:i,unitId:r,subUnitId:s,workbook:d,worksheet:l}=e,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!u)return a(t);const h=this._sheetDataValidationModel.getRuleById(r,s,u);if(!h)return a(t);const p=(b=(V=this._dataValidationCacheService.getValue(r,s,n,i))==null?void 0:V.status)!=null?b:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(h.type),C=e.rawData;let v;const f={get value(){var M;return v!==void 0||(v=(M=x.getCellValueOrigin(C))!=null?M:null),v}},w={get value(){var M;return`${(M=f.value)!=null?M:""}`}};return a({...t,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c},markers:{...t==null?void 0:t.markers,...p===o.DataValidationStatus.INVALID?Ye:null},customRender:[...(I=t==null?void 0:t.customRender)!=null?I:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...t==null?void 0:t.fontRenderExtension,isSkip:((F=t==null?void 0:t.fontRenderExtension)==null?void 0:F.isSkip)||((L=c==null?void 0:c.skipDefaultFontRender)==null?void 0:L.call(c,h,f.value,e))},interceptorStyle:{...t==null?void 0:t.interceptorStyle,...c==null?void 0:c.getExtraStyle(h,w.value,{get style(){const M=d.getStyles();return(typeof(t==null?void 0:t.s)=="string"?M.get(t==null?void 0:t.s):t==null?void 0:t.s)||{}}},n,i)},interceptorAutoHeight:()=>{var N,R,W,X,D,S;const M=(R=(N=this._renderManagerService.getRenderById(r))==null?void 0:N.with(K.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:R.skeleton;if(!M)return;const j=M.worksheet.getMergedCell(n,i),k={data:{...t,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c}},style:M.getsStyles().getStyleByCell(t),primaryWithCoord:M.getCellByIndex((W=j==null?void 0:j.startRow)!=null?W:n,(X=j==null?void 0:j.startColumn)!=null?X:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(S=(D=c==null?void 0:c.canvasRender)==null?void 0:D.calcCellAutoHeight)==null?void 0:S.call(D,k)},interceptorAutoWidth:()=>{var N,R,W,X,D,S;const M=(R=(N=this._renderManagerService.getRenderById(r))==null?void 0:N.with(K.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:R.skeleton;if(!M)return;const j=M.worksheet.getMergedCell(n,i),k={data:{...t,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c}},style:M.getsStyles().getStyleByCell(t),primaryWithCoord:M.getCellByIndex((W=j==null?void 0:j.startRow)!=null?W:n,(X=j==null?void 0:j.startColumn)!=null?X:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(S=(D=c==null?void 0:c.canvasRender)==null?void 0:D.calcCellAutoWidth)==null?void 0:S.call(D,k)},coverable:((P=t==null?void 0:t.coverable)!=null?P:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(dt.filter(t=>t.source==="command"),dt.bufferTime(16)).subscribe(t=>{const e=[];if(t.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&e.push(...a.rule.ranges)}),e.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(e);o.sequenceExecute(a.redos,this._commandService)}})}};Et=He([rt(0,o.ICommandService),rt(1,et.IMenuManagerService),rt(2,Z.IRenderManagerService),rt(3,o.IUniverInstanceService),rt(4,o.Inject(K.AutoHeightController)),rt(5,o.Inject(gt)),rt(6,o.Inject(x.SheetDataValidationModel)),rt(7,o.Inject(ot.DataValidatorRegistryService)),rt(8,o.Inject(tt.SheetInterceptorService)),rt(9,o.Inject(x.DataValidationCacheService)),rt(10,o.Optional(K.IEditorBridgeService))],Et);let Xe=class extends o.RxDisposable{constructor(t,e,a,n,i,r,s){super(),this._commandService=t,this._renderManagerService=e,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=i,this._sheetDataValidationModel=r,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(tt.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:tt.InterceptCellContentPriority.DATA_VALIDATION,handler:(t,e,a)=>{var w,V,b,I,F,L;const{row:n,col:i,unitId:r,subUnitId:s,workbook:d,worksheet:l}=e,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,i);if(!u)return a(t);const h=this._sheetDataValidationModel.getRuleById(r,s,u);if(!h)return a(t);const p=(V=(w=this._dataValidationCacheService.getValue(r,s,n,i))==null?void 0:w.status)!=null?V:o.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(h.type),C=l.getCellRaw(n,i),v=x.getCellValueOrigin(C),f=`${v!=null?v:""}`;return a({...t,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c},markers:{...t==null?void 0:t.markers,...p===o.DataValidationStatus.INVALID?Ye:null},customRender:[...(b=t==null?void 0:t.customRender)!=null?b:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...t==null?void 0:t.fontRenderExtension,isSkip:((I=t==null?void 0:t.fontRenderExtension)==null?void 0:I.isSkip)||((F=c==null?void 0:c.skipDefaultFontRender)==null?void 0:F.call(c,h,v,e))},interceptorStyle:{...t==null?void 0:t.interceptorStyle,...c==null?void 0:c.getExtraStyle(h,f,{get style(){const P=d.getStyles();return(typeof(t==null?void 0:t.s)=="string"?P.get(t==null?void 0:t.s):t==null?void 0:t.s)||{}}},n,i)},interceptorAutoHeight:()=>{var k,N,R,W,X,D;const P=(N=(k=this._renderManagerService.getRenderById(r))==null?void 0:k.with(K.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:N.skeleton;if(!P)return;const M=P.worksheet.getMergedCell(n,i),j={data:{...t,dataValidation:{ruleId:u,validStatus:p,rule:h,validator:c}},style:P.getsStyles().getStyleByCell(t),primaryWithCoord:P.getCellByIndex((R=M==null?void 0:M.startRow)!=null?R:n,(W=M==null?void 0:M.startColumn)!=null?W:i),unitId:r,subUnitId:s,row:n,col:i,workbook:d,worksheet:l};return(D=(X=c==null?void 0:c.canvasRender)==null?void 0:X.calcCellAutoHeight)==null?void 0:D.call(X,j)},coverable:((L=t==null?void 0:t.coverable)!=null?L:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(dt.filter(t=>t.source==="command"),dt.bufferTime(16)).subscribe(t=>{const e=[];if(t.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&e.push(...a.rule.ranges)}),e.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(e);o.sequenceExecute(a.redos,this._commandService)}})}};Xe=He([rt(0,o.ICommandService),rt(1,Z.IRenderManagerService),rt(2,o.Inject(K.AutoHeightController)),rt(3,o.Inject(ot.DataValidatorRegistryService)),rt(4,o.Inject(tt.SheetInterceptorService)),rt(5,o.Inject(x.SheetDataValidationModel)),rt(6,o.Inject(x.DataValidationCacheService))],Xe);var pa=Object.defineProperty,fa=Object.getOwnPropertyDescriptor,ma=(t,e,a,n)=>{for(var i=n>1?void 0:n?fa(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&pa(e,a,i),i},ze=(t,e)=>(a,n)=>e(a,n,t);let Wt=class extends o.Disposable{constructor(t,e,a){super(),this._context=t,this._sheetDataValidationModel=e,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const t=e=>{var n;if(!e.length)return;const a=new Set;e.forEach(i=>{a.add(i.subUnitId)}),a.forEach(i=>{var r;(r=this._sheetSkeletonManagerService.getWorksheetSkeleton(i))==null||r.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(t))}};Wt=ma([ze(1,o.Inject(x.SheetDataValidationModel)),ze(2,o.Inject(K.SheetSkeletonManagerService))],Wt);const st={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"},va=t=>{const{isTwoFormula:e=!1,value:a,onChange:n,showError:i,validResult:r}=t,s=o.useDependency(o.LocaleService),d=i?r==null?void 0:r.formula1:"",l=i?r==null?void 0:r.formula2:"";return e?m.jsxs(m.Fragment,{children:[m.jsx(U.FormLayout,{error:d,children:m.jsx(U.Input,{className:st.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({...a,formula1:u})}})}),m.jsx("div",{className:st.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),m.jsx(U.FormLayout,{error:l,children:m.jsx(U.Input,{className:st.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:u=>{n==null||n({...a,formula2:u})}})})]}):m.jsx(U.FormLayout,{error:d,children:m.jsx(U.Input,{className:st.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({formula1:u})}})})};function ga(t){const{value:e,onChange:a,showError:n,validResult:i}=t,r=o.useDependency(o.LocaleService),s=n?i==null?void 0:i.formula1:"",d=n?i==null?void 0:i.formula2:"",[l,u]=E.useState(!((e==null?void 0:e.formula1)===void 0&&(e==null?void 0:e.formula2)===void 0));return m.jsxs(m.Fragment,{children:[m.jsx(U.FormLayout,{children:m.jsx(U.Checkbox,{checked:l,onChange:h=>{h?u(!0):(u(!1),a==null||a({...e,formula1:void 0,formula2:void 0}))},children:r.t("dataValidation.checkbox.tips")})}),l?m.jsx(U.FormLayout,{label:r.t("dataValidation.checkbox.checked"),error:s,children:m.jsx(U.Input,{className:st.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:e==null?void 0:e.formula1,onChange:h=>{a==null||a({...e,formula1:h||void 0})}})}):null,l?m.jsx(U.FormLayout,{label:r.t("dataValidation.checkbox.unchecked"),error:d,children:m.jsx(U.Input,{className:st.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:e==null?void 0:e.formula2,onChange:h=>{a==null||a({...e,formula2:h||void 0})}})}):null]})}function Sa(t){var p;const{unitId:e,subUnitId:a,value:n,onChange:i,showError:r,validResult:s}=t,d=r?s==null?void 0:s.formula1:void 0,l=E.useRef({}),[u,h]=E.useState(!1);return et.useSidebarClick(c=>{var v;const C=(v=l.current)==null?void 0:v.handleOutClick;C&&C(c,()=>h(!1))}),m.jsx(ee.FormulaEditor,{initValue:(p=n==null?void 0:n.formula1)!=null?p:"",unitId:e,subUnitId:a,isFocus:u,onChange:c=>{const C=(c!=null?c:"").trim();C!==(n==null?void 0:n.formula1)&&(i==null||i({...n,formula1:C}))},errorText:d,onFocus:()=>h(!0),actions:l.current,isSupportAcrossSheet:!0})}function Ke(t){var e,a,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(a=Ke(t[e]))&&(n&&(n+=" "),n+=a)}else for(a in t)t[a]&&(n&&(n+=" "),n+=a);return n}function _a(){for(var t,e,a=0,n="",i=arguments.length;a<i;a++)(t=arguments[a])&&(e=Ke(t))&&(n&&(n+=" "),n+=e);return n}const Ia=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Ca=t=>{const{value:e,onChange:a,disabled:n}=t,[i,r]=E.useState(!1);return m.jsx(U.Select,{disabled:n,open:i,onDropdownVisibleChange:r,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:st.dataValidationFormulaColorSelect,value:e,onChange:a,labelRender:s=>m.jsx("div",{className:st.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>m.jsx("div",{className:st.dataValidationFormulaColorSelectPanel,children:Ia.map(s=>m.jsx("div",{onClick:()=>{a(s),r(!1)},className:st.dataValidationFormulaColorItem,style:{background:s}},s))})})},Ge=t=>{const{item:e,commonProps:a,style:n}=t,{onItemChange:i,onItemDelete:r}=a;return m.jsxs("div",{className:st.dataValidationFormulaListItem,style:n,children:[e.isRef?null:m.jsx("div",{className:_a(st.dataValidationFormulaListItemDrag,"draggableHandle"),children:m.jsx($e,{})}),m.jsx(Ca,{value:e.color,onChange:s=>{i(e.id,e.label,s)}}),m.jsx(U.Input,{disabled:e.isRef,value:e.label,onChange:s=>{i(e.id,s,e.color)}}),e.isRef?null:m.jsx("div",{className:st.dataValidationFormulaListItemIcon,children:m.jsx(ne,{onClick:()=>r(e.id)})})]})};function Da(t){const{value:e,onChange:a=()=>{},unitId:n,subUnitId:i,validResult:r,showError:s,ruleId:d}=t,{formula1:l="",formula2:u=""}=e||{},h=E.useRef(null),[p,c]=E.useState(()=>o.isFormulaString(l)?"1":"0"),[C,v]=E.useState(p==="1"?l:"="),[f,w]=E.useState(p==="1"?l:"="),V=o.useDependency(o.LocaleService),b=o.useDependency(ot.DataValidatorRegistryService),I=o.useDependency(ot.DataValidationModel),F=o.useDependency(x.DataValidationFormulaController),[L,P]=E.useState(()=>u.split(",")),M=b.getValidatorItem(o.DataValidationType.LIST),[j,k]=E.useState([]),[N,R]=E.useState(""),W=s?r==null?void 0:r.formula1:"",X=E.useMemo(()=>I.ruleChange$.pipe(dt.debounceTime(16)),[]),D=et.useObservable(X),S=et.useEvent(a);E.useEffect(()=>{(async()=>{await new Promise(B=>{setTimeout(()=>B(!0),100)});const T=I.getRuleById(n,i,d),z=T==null?void 0:T.formula1;if(o.isFormulaString(z)&&M&&T){const B=await M.getListAsync(T,n,i);k(B)}})()},[I,D,M,d,i,n]),E.useEffect(()=>{o.isFormulaString(l)&&l!==f&&(v(l),w(f))},[f,l]);const[g,y]=E.useState(()=>{const T=p!=="1"?x.deserializeListOptions(l):[],z=u.split(",");return T.map((B,q)=>({label:B,color:z[q]||It,isRef:!1,id:o.Tools.generateRandomId(4)}))}),_=(T,z,B)=>{const q=g.find(lt=>lt.id===T);q&&(q.label=z,q.color=B,y([...g]))},A=T=>{const z=g.findIndex(B=>B.id===T);z!==-1&&(g.splice(z,1),y([...g]))},O=u.split(","),H=E.useMemo(()=>j.map((T,z)=>({label:T,color:O[z]||It,id:`${z}`,isRef:!0})),[O,j]),G=(T,z,B)=>{const q=[...L];q[+T]=B,P(q),S({formula1:l,formula2:q.join(",")})},Q=()=>{y([...g,{label:"",color:It,isRef:!1,id:o.Tools.generateRandomId(4)}])};E.useEffect(()=>{if(p==="1")return;const T=new Set,z=[];g.map(B=>({labelList:B.label.split(","),item:B})).forEach(({item:B,labelList:q})=>{q.forEach(lt=>{T.has(lt)||(T.add(lt),z.push({label:lt,color:B.color}))})}),S({formula1:x.serializeListOptions(z.map(B=>B.label)),formula2:z.map(B=>B.color===It?"":B.color).join(",")})},[g,S,p,f,L]);const nt=E.useMemo(()=>async T=>{if(!o.isFormulaString(T)){S==null||S({formula1:"",formula2:u});return}F.getFormulaRefCheck(T)?(S==null||S({formula1:o.isFormulaString(T)?T:"",formula2:u}),R("")):(S==null||S({formula1:"",formula2:u}),v("="),R(V.t("dataValidation.validFail.formulaError")))},[u,S]),at=E.useRef({}),[it,$]=E.useState(!1);return et.useSidebarClick(T=>{var B;const z=(B=at.current)==null?void 0:B.handleOutClick;z&&z(T,()=>$(!1))}),m.jsxs(m.Fragment,{children:[m.jsx(U.FormLayout,{label:V.t("dataValidation.list.options"),children:m.jsxs(U.RadioGroup,{value:p,onChange:T=>{c(T),v(f),T==="1"&&S({formula1:f==="="?"":f,formula2:L.join(",")})},children:[m.jsx(U.Radio,{value:"0",children:V.t("dataValidation.list.customOptions")}),m.jsx(U.Radio,{value:"1",children:V.t("dataValidation.list.refOptions")})]})}),p==="1"?m.jsxs(m.Fragment,{children:[m.jsx(ee.FormulaEditor,{initValue:C,unitId:n,subUnitId:i,isFocus:it,onChange:(T="")=>{const z=(T!=null?T:"").trim();w(z),nt(z)},errorText:W||N||void 0,onFocus:()=>$(!0),actions:at.current,isSupportAcrossSheet:!0}),m.jsx("div",{ref:h,style:{marginTop:"12px"},children:H.map(T=>m.jsx(Ge,{item:T,commonProps:{onItemChange:G},style:{marginBottom:12}},T.id))})]}):m.jsx(U.FormLayout,{error:W,children:m.jsxs("div",{ref:h,style:{marginTop:"-12px"},children:[m.jsx(U.DraggableList,{list:g,onListChange:y,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:T=>m.jsx(Ge,{item:T,commonProps:{onItemChange:_,onItemDelete:A}},T.id),idKey:"id"}),m.jsxs("a",{className:st.dataValidationFormulaListAdd,onClick:Q,children:[m.jsx(Pe,{}),V.t("dataValidation.list.add")]})]})})]})}const Ze="data-validation.custom-formula-input",Ht="data-validation.formula-input",ue="data-validation.list-formula-input",qe="data-validation.checkbox-formula-input",ya=[[Ze,Sa],[Ht,va],[ue,Da],[qe,ga]],wa="LIST_RENDER_MODE_OPTION_INPUT";function Yt(t){var i;const{value:e,onChange:a}=t,n=o.useDependency(o.LocaleService);return m.jsx(U.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:m.jsxs(U.RadioGroup,{value:`${(i=e.renderMode)!=null?i:o.DataValidationRenderMode.CUSTOM}`,onChange:r=>a({...e,renderMode:+r}),children:[m.jsx(U.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),m.jsx(U.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),m.jsx(U.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}Yt.componentKey=wa;const Ma="DATE_SHOW_TIME_OPTION";function Xt(t){var i;const{value:e,onChange:a}=t,n=o.useDependency(o.LocaleService);return m.jsx(U.FormLayout,{children:m.jsx(U.Checkbox,{checked:(i=e.bizInfo)==null?void 0:i.showTime,onChange:r=>{a({...e,bizInfo:{...e.bizInfo,showTime:r}})},children:n.t("dataValidation.showTime.label")})})}Xt.componentKey=Ma;var Va=Object.defineProperty,Ea=Object.getOwnPropertyDescriptor,ba=(t,e,a,n)=>{for(var i=n>1?void 0:n?Ea(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&Va(e,a,i),i},zt=(t,e)=>(a,n)=>e(a,n,t);const Kt=6;let he=class{constructor(t,e,a,n){this._commandService=t,this._formulaService=e,this._themeService=a,this._renderManagerService=n}_calc(t,e){var u,h,p;const{vt:a,ht:n}=e||{},i=t.endX-t.startX-Kt*2,r=t.endY-t.startY,s=((u=e==null?void 0:e.fs)!=null?u:10)*1.6;let d=0,l=0;switch(a){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(r-s);break;default:l=0+(r-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:d=Kt;break;case o.HorizontalAlign.RIGHT:d=Kt+(i-s);break;default:d=Kt+(i-s)/2;break}return{left:t.startX+d,top:t.startY+l,width:((h=e==null?void 0:e.fs)!=null?h:10)*1.6,height:((p=e==null?void 0:e.fs)!=null?p:10)*1.6}}calcCellAutoHeight(t){var a;const{style:e}=t;return((a=e==null?void 0:e.fs)!=null?a:10)*1.6}calcCellAutoWidth(t){var a;const{style:e}=t;return((a=e==null?void 0:e.fs)!=null?a:10)*1.6}async _parseFormula(t,e,a){var u,h,p,c,C,v,f,w,V;const{formula1:n=x.CHECKBOX_FORMULA_1,formula2:i=x.CHECKBOX_FORMULA_2}=t,r=await this._formulaService.getRuleFormulaResult(e,a,t.uid),s=x.getFormulaResult((p=(h=(u=r==null?void 0:r[0])==null?void 0:u.result)==null?void 0:h[0])==null?void 0:p[0]),d=x.getFormulaResult((v=(C=(c=r==null?void 0:r[1])==null?void 0:c.result)==null?void 0:C[0])==null?void 0:v[0]),l=x.isLegalFormulaResult(String(s))&&x.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(n)?x.getFormulaResult((V=(w=(f=r==null?void 0:r[0])==null?void 0:f.result)==null?void 0:w[0])==null?void 0:V[0]):n,formula2:o.isFormulaString(i)?d:i,isFormulaValid:l}}drawWith(t,e){var X,D,S,g,y,_;const{style:a,data:n,primaryWithCoord:i,unitId:r,subUnitId:s,worksheet:d,row:l,col:u}=e,h=i.isMergedMainCell?i.mergeInfo:i,p=x.getCellValueOrigin(d.getCellRaw(l,u)),c=(X=n.dataValidation)==null?void 0:X.rule,C=(D=n.dataValidation)==null?void 0:D.validator;if(!c||!C)return;const v=this._themeService.getCurrentTheme();if(!((S=C.skipDefaultFontRender)!=null&&S.call(C,c,p,{unitId:r,subUnitId:s,row:l,column:u})))return;const f=C.parseFormulaSync(c,r,s),{formula1:w}=f,V=this._calc(h,a),{a:b,d:I}=t.getTransform(),F=Z.fixLineWidthByScale(V.left,b),L=Z.fixLineWidthByScale(V.top,I),P=Z.Transform.create().composeMatrix({left:F,top:L,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),M=h.endX-h.startX,j=h.endY-h.startY;t.save(),t.beginPath(),t.rect(h.startX,h.startY,M,j),t.clip();const k=P.getMatrix();t.transform(k[0],k[1],k[2],k[3],k[4],k[5]);const N=((g=a==null?void 0:a.fs)!=null?g:10)*1.6,R=String(p)===String(w),W=v.hyacinth500;Z.Checkbox.drawWith(t,{checked:R,width:N,height:N,fill:(_=(y=a==null?void 0:a.cl)==null?void 0:y.rgb)!=null?_:W}),t.restore()}isHit(t,e){const a=e.primaryWithCoord.isMergedMainCell?e.primaryWithCoord.mergeInfo:e.primaryWithCoord,n=this._calc(a,e.style),i=n.top,r=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:u}=t;return l<=d&&l>=s&&u<=r&&u>=i}async onPointerDown(t,e){var f,w,V;if(e.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:i,data:r,worksheet:s,row:d,col:l}=t,u=x.getCellValueOrigin(s.getCellRaw(d,l)),h=(f=r.dataValidation)==null?void 0:f.rule,p=(w=r.dataValidation)==null?void 0:w.validator;if(!h||!p||!((V=p.skipDefaultFontRender)!=null&&V.call(p,h,u,{unitId:n,subUnitId:i,row:d,column:l})))return;const{formula1:c,formula2:C}=await this._parseFormula(h,n,i),v={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(u)===x.transformCheckboxValue(String(c))?C:c,p:null}};this._commandService.executeCommand(tt.SetRangeValuesCommand.id,v)}onPointerEnter(t,e){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(Z.CURSOR_TYPE.POINTER)}onPointerLeave(t,e){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(Z.CURSOR_TYPE.DEFAULT)}};he=ba([zt(0,o.ICommandService),zt(1,o.Inject(x.DataValidationFormulaService)),zt(2,o.Inject(o.ThemeService)),zt(3,o.Inject(Z.IRenderManagerService))],he);var Ra=Object.defineProperty,Oa=Object.getOwnPropertyDescriptor,Ta=(t,e,a,n)=>{for(var i=n>1?void 0:n?Oa(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&Ra(e,a,i),i},La=(t,e)=>(a,n)=>e(a,n,t);let pt=class{constructor(t){Y(this,"canvasRender",null);Y(this,"dropdown");Y(this,"optionsInput");Y(this,"formulaInput",ue);this.injector=t}};pt=Ta([La(0,o.Inject(o.Injector))],pt);class Pa extends pt{constructor(){super(...arguments);Y(this,"id",o.DataValidationType.CHECKBOX);Y(this,"canvasRender",this.injector.createInstance(he));Y(this,"formulaInput",qe)}}class ja extends pt{constructor(){super(...arguments);Y(this,"id",o.DataValidationType.CUSTOM);Y(this,"formulaInput",Ze)}}const Aa="data-validation.formula-input";class $a extends pt{constructor(){super(...arguments);Y(this,"id",o.DataValidationType.DATE);Y(this,"formulaInput",Aa);Y(this,"optionsInput",Xt.componentKey);Y(this,"dropdown",se)}}class Fa extends pt{constructor(){super(...arguments);Y(this,"id",o.DataValidationType.DECIMAL);Y(this,"formulaInput",Ht)}}const Je=4,xa=0,pe=4,Qe=4,fe=6,Gt=6,Ct=14;function Na(t,e){const a=Z.FontCache.getTextSize(t,e),n=a.width+Je*2,{ba:i,bd:r}=a,s=i+r;return{width:n,height:s+xa*2,ba:i}}function me(t,e,a,n){const i=Ct+fe*2,r=a-i,s=n-Gt*2,d=t.map(c=>({layout:Na(c,e),text:c}));let l;const u=[];d.forEach(c=>{const{layout:C}=c,{width:v,height:f}=C;!l||l.width+v+pe>r?(l={width:v,height:f,items:[{...c,left:0}]},u.push(l)):(l.items.push({...c,left:l.width+pe}),l.width=l.width+v+pe)});let h=0,p=0;return u.forEach((c,C)=>{p=Math.max(p,c.width),C===u.length-1?h+=c.height:h+=c.height+Qe}),{lines:u,totalHeight:h,contentWidth:r,contentHeight:s,cellAutoHeight:h+Gt*2,calcAutoWidth:p+i}}const Ua=8;class ka extends Z.Shape{static drawWith(e,a){const{fontString:n,info:i,fill:r,color:s}=a,{layout:d,text:l}=i;e.save(),Z.Rect.drawWith(e,{width:d.width,height:d.height,radius:Ua,fill:r||It}),e.translateWithPrecision(Je,d.ba),e.font=n,e.fillStyle=s,e.fillText(l,0,0),e.restore()}}var Ba=Object.defineProperty,Wa=Object.getOwnPropertyDescriptor,Ha=(t,e,a,n)=>{for(var i=n>1?void 0:n?Wa(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&Ba(e,a,i),i},tn=(t,e)=>(a,n)=>e(a,n,t);const Ya=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 ve=class{constructor(t,e){Y(this,"zIndex");Y(this,"_dropdownInfoMap",new Map);this._commandService=t,this._renderManagerService=e}_ensureMap(t){let e=this._dropdownInfoMap.get(t);return e||(e=new Map,this._dropdownInfoMap.set(t,e)),e}_generateKey(t,e){return`${t}.${e}`}_drawDownIcon(t,e,a,n,i){const r=a-Ct+4;let s=4;switch(i){case o.VerticalAlign.MIDDLE:s=(n-Ct)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-Ct+4;break}t.save(),t.translateWithPrecision(e.startX+r,e.startY+s),t.fillStyle="#565656",t.fill(Ya),t.restore()}drawWith(t,e,a,n){var O,H;const{primaryWithCoord:i,row:r,col:s,style:d,data:l,subUnitId:u}=e,h=i.isMergedMainCell?i.mergeInfo:i,p=l.fontRenderExtension,{leftOffset:c=0,rightOffset:C=0,topOffset:v=0,downOffset:f=0}=p||{},w=l.dataValidation,V=this._ensureMap(u),b=this._generateKey(r,s);if(!w)return;const I={startX:h.startX+c,endX:h.endX-C,startY:h.startY+v,endY:h.endY-f},F=I.endX-I.startX,L=I.endY-I.startY,{cl:P}=d||{},M=(O=typeof P=="object"?P==null?void 0:P.rgb:P)!=null?O:"#000",j=Z.getFontStyleString(d!=null?d:void 0),{rule:k,validator:N}=w,R=N,{vt:W,ht:X}=d||{},D=W!=null?W:o.VerticalAlign.MIDDLE,S=(H=x.getCellValueOrigin(l))!=null?H:"",g=R.parseCellValue(S),y=R.getListWithColorMap(k),_=me(g,j,F,L);this._drawDownIcon(t,I,F,L,D),t.save(),t.translateWithPrecision(I.startX,I.startY),t.beginPath(),t.rect(0,0,F-Ct,L),t.clip(),t.translateWithPrecision(fe,Gt);let A=0;switch(D){case o.VerticalAlign.MIDDLE:A=(_.contentHeight-_.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:A=_.contentHeight-_.totalHeight;break}t.translateWithPrecision(0,A),_.lines.forEach((G,Q)=>{t.save();const{width:nt,height:at,items:it}=G;let $=0;switch(X){case o.HorizontalAlign.RIGHT:$=_.contentWidth-nt;break;case o.HorizontalAlign.CENTER:$=(_.contentWidth-nt)/2;break}t.translate($,Q*(at+Qe)),it.forEach(T=>{t.save(),t.translateWithPrecision(T.left,0),ka.drawWith(t,{...j,info:T,color:M,fill:y[T.text]}),t.restore()}),t.restore()}),t.restore(),V.set(b,{left:I.startX,top:I.startY,width:_.contentWidth+fe+Ct,height:_.contentHeight+Gt*2})}calcCellAutoHeight(t){var F;const{primaryWithCoord:e,style:a,data:n}=t,i=n.fontRenderExtension,{leftOffset:r=0,rightOffset:s=0,topOffset:d=0,downOffset:l=0}=i||{},u=e.isMergedMainCell?e.mergeInfo:e,h={startX:u.startX+r,endX:u.endX-s,startY:u.startY+d,endY:u.endY-l},p=n.dataValidation;if(!p)return;const c=h.endX-h.startX,C=h.endY-h.startY,v=(F=x.getCellValueOrigin(n))!=null?F:"",{validator:f}=p,V=f.parseCellValue(v),b=Z.getFontStyleString(a!=null?a:void 0);return me(V,b,c,C).cellAutoHeight}calcCellAutoWidth(t){var F;const{primaryWithCoord:e,style:a,data:n}=t,i=n.fontRenderExtension,{leftOffset:r=0,rightOffset:s=0,topOffset:d=0,downOffset:l=0}=i||{},u=e.isMergedMainCell?e.mergeInfo:e,h={startX:u.startX+r,endX:u.endX-s,startY:u.startY+d,endY:u.endY-l},p=n.dataValidation;if(!p)return;const c=h.endX-h.startX,C=h.endY-h.startY,v=(F=x.getCellValueOrigin(n))!=null?F:"",{validator:f}=p,V=f.parseCellValue(v),b=Z.getFontStyleString(a!=null?a:void 0);return me(V,b,c,C).calcAutoWidth}isHit(t,e){const{primaryWithCoord:a}=e,n=a.isMergedMainCell?a.mergeInfo:a,{endX:i}=n,{x:r}=t;return r>=i-Ct&&r<=i}onPointerDown(t,e){if(e.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=t,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Ft.id,s)}onPointerEnter(t,e){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(Z.CURSOR_TYPE.POINTER)}onPointerLeave(t,e){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(Z.CURSOR_TYPE.DEFAULT)}};ve=Ha([tn(0,o.ICommandService),tn(1,o.Inject(Z.IRenderManagerService))],ve);class Xa extends pt{constructor(){super(...arguments);Y(this,"id",o.DataValidationType.LIST_MULTIPLE);Y(this,"canvasRender",this.injector.createInstance(ve));Y(this,"dropdown",Ut)}}var za=Object.defineProperty,Ka=Object.getOwnPropertyDescriptor,Ga=(t,e,a,n)=>{for(var i=n>1?void 0:n?Ka(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&za(e,a,i),i},ge=(t,e)=>(a,n)=>e(a,n,t);const Dt=4,Zt=4,ut=14,ft=6,bt=4,Se=8,Za="#565656",en=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 qa(t,e){const a=t.length;return{id:"d",body:{dataStream:`${t}${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:o.BooleanNumber.FALSE,bl:o.BooleanNumber.FALSE,ul:{s:o.BooleanNumber.FALSE},st:{s:o.BooleanNumber.FALSE},ol:{s:o.BooleanNumber.FALSE},cl:void 0,...e,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function nn(t,e,a){const n=qa(t,a),i=new o.DocumentDataModel(n),r=new Z.DocumentViewModel(i);return{documentSkeleton:Z.DocumentSkeleton.create(r,e),docModel:i,docViewModel:r}}function qt(t,e,a){const{documentSkeleton:n,docModel:i,docViewModel:r}=nn(t,e,a);return{documents:new Z.Documents(`DOCUMENTS_${o.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:i,docViewModel:r}}function an(t,e,a,n,i,r,s=!0){let d=0;const l=s?bt:0;switch(i){case o.VerticalAlign.BOTTOM:d=e-n-l;break;case o.VerticalAlign.MIDDLE:d=(e-n)/2;break;default:d=l;break}d=Math.max(bt,d);let u=0;switch(r){case o.HorizontalAlign.CENTER:u=(t-a)/2;break;case o.HorizontalAlign.RIGHT:u=t-a;break}return u=Math.max(ft,u),{paddingLeft:u,paddingTop:d}}let _e=class{constructor(t,e,a){Y(this,"_dropdownInfoMap",new Map);Y(this,"zIndex");this._localeService=t,this._commandService=e,this._renderManagerService=a}_ensureMap(t){let e=this._dropdownInfoMap.get(t);return e||(e=new Map,this._dropdownInfoMap.set(t,e)),e}_generateKey(t,e){return`${t}.${e}`}_drawDownIcon(t,e,a,n,i,r,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,u=a-ut;let h;switch(r){case o.VerticalAlign.MIDDLE:h=(n-Zt)/2;break;case o.VerticalAlign.BOTTOM:h=n-l-i-bt+(i/2-Zt/2);break;default:h=d+bt+(i/2-Zt/2);break}t.save(),t.translateWithPrecision(e.startX+u,e.startY+h),t.fillStyle="#565656",t.fill(en),t.restore()}drawWith(t,e,a){var D,S;const{primaryWithCoord:n,row:i,col:r,style:s,data:d,subUnitId:l}=e,u=n.isMergedMainCell?n.mergeInfo:n,h=(D=d.dataValidation)==null?void 0:D.rule,p=(S=d.dataValidation)==null?void 0:S.validator,c=d.fontRenderExtension,{leftOffset:C=0,rightOffset:v=0,topOffset:f=0,downOffset:w=0}=c||{};if(!h||!p||!p||p.id.indexOf(o.DataValidationType.LIST)!==0||!p.skipDefaultFontRender(h))return;const V={startX:u.startX+C,endX:u.endX-v,startY:u.startY+f,endY:u.endY-w},b=V.endX-V.startX,I=V.endY-V.startY,F=this._ensureMap(l),L=this._generateKey(i,r),P=p.getListWithColor(h),M=x.getCellValueOrigin(d),j=`${M!=null?M:""}`,k=P.find(g=>g.label===j);let{tb:N,vt:R,ht:W,pd:X}=s||{};if(N=N!=null?N:o.WrapStrategy.WRAP,R=R!=null?R:o.VerticalAlign.BOTTOM,W=W!=null?W:o.DEFAULT_STYLES.ht,X=X!=null?X:o.DEFAULT_STYLES.pd,h.renderMode===o.DataValidationRenderMode.ARROW){const{l:g=o.DEFAULT_STYLES.pd.l,t:y=o.DEFAULT_STYLES.pd.t,r:_=o.DEFAULT_STYLES.pd.r,b:A=o.DEFAULT_STYLES.pd.b}=X,O=b-g-_-ut-4,{documentSkeleton:H,documents:G,docModel:Q}=qt(j,this._localeService,s);N===o.WrapStrategy.WRAP&&Q.updateDocumentDataPageSize(Math.max(O,1)),H.calculate(),H.getActualSize();const nt=Z.getDocsSkeletonPageSize(H),{height:at,width:it}=nt,{paddingTop:$,paddingLeft:T}=an(O,I-y-A,it,at,R,W,!0);this._drawDownIcon(t,V,b,I,at,R,X),t.save(),t.translateWithPrecision(V.startX+g,V.startY+y),t.beginPath(),t.rect(0,0,b-g-_,I-y-A),t.clip(),t.translateWithPrecision(0,$),t.save(),t.translateWithPrecision(Dt,0),t.beginPath(),t.rect(0,0,O,at),t.clip(),G.render(t),t.translateWithPrecision(T,0),t.restore(),t.restore(),F.set(L,{left:V.endX+g+a.rowHeaderWidth-ut,top:V.startY+y+a.columnHeaderHeight,width:ut,height:I-y-A})}else{t.save(),t.translateWithPrecision(V.startX,V.startY),t.beginPath(),t.rect(0,0,b,I),t.clip();const g=b-ft*2-Dt-ut-4,{documentSkeleton:y,documents:_,docModel:A}=qt(j,this._localeService,s);N===o.WrapStrategy.WRAP&&A.updateDocumentDataPageSize(Math.max(g,1)),y.calculate();const O=Z.getDocsSkeletonPageSize(y),{height:H,width:G}=O,{paddingTop:Q,paddingLeft:nt}=an(g,I,G,H,R,W);t.translateWithPrecision(ft,Q);const at=Math.max(b-ft*2,1),it=H;Z.Rect.drawWith(t,{width:at,height:it,fill:(k==null?void 0:k.color)||It,radius:Se}),t.save(),t.translateWithPrecision(Dt,0),t.beginPath(),t.rect(0,0,g,H),t.clip(),t.translateWithPrecision(nt,0),_.render(t),t.restore(),t.translateWithPrecision(g+Dt+4,(H-Zt)/2),t.fillStyle=Za,t.fill(en),t.restore(),F.set(L,{left:V.startX+ft+a.rowHeaderWidth,top:V.startY+Q+a.columnHeaderHeight,width:at,height:it})}}calcCellAutoHeight(t){var I;const{primaryWithCoord:e,style:a,data:n}=t,i=e.isMergedMainCell?e.mergeInfo:e,r=n.fontRenderExtension,{leftOffset:s=0,rightOffset:d=0,topOffset:l=0,downOffset:u=0}=r||{},h=(I=n.dataValidation)==null?void 0:I.rule;if(!h||h.renderMode===o.DataValidationRenderMode.TEXT)return;const p={startX:i.startX+s,endX:i.endX-d,startY:i.startY+l,endY:i.endY-u},c=p.endX-p.startX,C=x.getCellValueOrigin(n),v=`${C!=null?C:""}`;let{tb:f,pd:w}=a||{};const{t:V=o.DEFAULT_STYLES.pd.t,b=o.DEFAULT_STYLES.pd.b}=w!=null?w:{};if(f=f!=null?f:o.WrapStrategy.WRAP,h.renderMode===o.DataValidationRenderMode.ARROW){const F=c-ut,{documentSkeleton:L,docModel:P}=qt(v,this._localeService,a);f===o.WrapStrategy.WRAP&&P.updateDocumentDataPageSize(Math.max(F,1)),L.calculate(),L.getActualSize();const M=Z.getDocsSkeletonPageSize(L),{height:j}=M;return j+V+b+bt*2}else{const F=c-ft*2-Dt-ut,{documentSkeleton:L,docModel:P}=nn(v,this._localeService,a);f===o.WrapStrategy.WRAP&&P.updateDocumentDataPageSize(Math.max(F,1)),L.calculate();const M=Z.getDocsSkeletonPageSize(L),{height:j}=M;return j+bt*2}}calcCellAutoWidth(t){var j;const{primaryWithCoord:e,style:a,data:n}=t,i=e.isMergedMainCell?e.mergeInfo:e,r=n.fontRenderExtension,{leftOffset:s=0,rightOffset:d=0,topOffset:l=0,downOffset:u=0}=r||{},h=(j=n.dataValidation)==null?void 0:j.rule;if(!h||h.renderMode===o.DataValidationRenderMode.TEXT)return;const p={startX:i.startX+s,endX:i.endX-d,startY:i.startY+l,endY:i.endY-u},c=p.endX-p.startX,C=x.getCellValueOrigin(n),v=`${C!=null?C:""}`;let{tb:f,pd:w}=a||{};const{l:V=o.DEFAULT_STYLES.pd.l,r:b=o.DEFAULT_STYLES.pd.r}=w!=null?w:{};f=f!=null?f:o.WrapStrategy.WRAP;let I=ft*2+ut;switch(h.renderMode){case o.DataValidationRenderMode.ARROW:I=ut+ft*2+b+V;break;case o.DataValidationRenderMode.CUSTOM:I=ut+ft*2+Dt*2+b+V+Se/2+1;break;default:I=ut+ft*2+Dt*2+b+V+Se/2+1}const F=c-I,{documentSkeleton:L,docModel:P}=qt(v,this._localeService,a);return f===o.WrapStrategy.WRAP&&P.updateDocumentDataPageSize(Math.max(F,1)),L.calculate(),L.getActualSize(),Z.getDocsSkeletonPageSize(L).width+I}isHit(t,e){const{data:a,subUnitId:n,row:i,col:r}=e,d=this._ensureMap(n).get(this._generateKey(i,r)),l=a.dataValidation;if(!l||!d||l.rule.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:u,left:h,width:p,height:c}=d,{x:C,y:v}=t;return C>=h&&C<=h+p&&v>=u&&v<=u+c}onPointerDown(t,e){if(e.button===2)return;const{unitId:a,subUnitId:n,row:i,col:r}=t,s={unitId:a,subUnitId:n,row:i,column:r};this._commandService.executeCommand(Ft.id,s)}onPointerEnter(t,e){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(Z.CURSOR_TYPE.POINTER)}onPointerLeave(t,e){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(Z.CURSOR_TYPE.DEFAULT)}};_e=Ga([ge(0,o.Inject(o.LocaleService)),ge(1,o.ICommandService),ge(2,o.Inject(Z.IRenderManagerService))],_e);class Ja extends pt{constructor(){super(...arguments);Y(this,"id",o.DataValidationType.LIST);Y(this,"canvasRender",this.injector.createInstance(_e));Y(this,"dropdown",Ut);Y(this,"optionsInput",Yt.componentKey);Y(this,"formulaInput",ue)}}class Qa extends pt{constructor(){super(...arguments);Y(this,"id",o.DataValidationType.TEXT_LENGTH);Y(this,"formulaInput",Ht)}}class ti extends pt{constructor(){super(...arguments);Y(this,"id",o.DataValidationType.WHOLE);Y(this,"formulaInput",Ht)}}var ei=Object.defineProperty,ni=Object.getOwnPropertyDescriptor,ai=(t,e,a,n)=>{for(var i=n>1?void 0:n?ni(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&ei(e,a,i),i},Ie=(t,e)=>(a,n)=>e(a,n,t);let Rt=class extends o.RxDisposable{constructor(t,e,a){super(),this._injector=t,this._componentManger=e,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[Be,Le],[ae,Kn],[xe,An],[Ut,Un],[se,In],[Yt.componentKey,Yt],[Xt.componentKey,Xt],...ya].forEach(([t,e])=>{this.disposeWithMe(this._componentManger.register(t,e))})}_registerValidatorViews(){[Fa,ti,Qa,$a,Pa,Ja,Xa,ja].forEach(t=>{const e=this._injector.createInstance(t),a=this._dataValidatorRegistryService.getValidatorItem(e.id);a&&(a.formulaInput=e.formulaInput,a.canvasRender=e.canvasRender,a.dropdown=e.dropdown,a.optionsInput=e.optionsInput)})}};Rt=ai([Ie(0,o.Inject(o.Injector)),Ie(1,o.Inject(et.ComponentManager)),Ie(2,o.Inject(ot.DataValidatorRegistryService))],Rt);var ii=Object.defineProperty,oi=Object.getOwnPropertyDescriptor,ri=(t,e,a,n)=>{for(var i=n>1?void 0:n?oi(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&ii(e,a,i),i},Ce=(t,e)=>(a,n)=>e(a,n,t);const si="SHEET_DATA_VALIDATION_UI_PLUGIN";J.UniverSheetsDataValidationUIPlugin=(Jt=class extends o.Plugin{constructor(e=ke,a,n,i){super(),this._config=e,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(oe,s)}onStarting(){[[ht],[gt],[jt],[wt],[Et],[Vt],[Mt],[Lt],[Rt]].forEach(e=>{this._injector.add(e)}),[kt,Ft,Ue,ie,_t,Ne].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(Mt),this._injector.get(Vt),this._injector.get(Lt),this._injector.get(jt),this._injector.get(Z.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Wt])}onRendered(){this._injector.get(Rt),this._injector.get(Et)}onSteady(){this._injector.get(wt)}},Y(Jt,"pluginName",si),Y(Jt,"type",o.UniverInstanceType.UNIVER_SHEET),Jt),J.UniverSheetsDataValidationUIPlugin=ri([Ce(1,o.Inject(o.Injector)),Ce(2,o.ICommandService),Ce(3,o.IConfigService)],J.UniverSheetsDataValidationUIPlugin);var li=Object.defineProperty,di=Object.getOwnPropertyDescriptor,ci=(t,e,a,n)=>{for(var i=n>1?void 0:n?di(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(i=(n?s(e,a,i):s(i))||i);return n&&i&&li(e,a,i),i},De=(t,e)=>(a,n)=>e(a,n,t);const ui="SHEET_DATA_VALIDATION_UI_PLUGIN";J.UniverSheetsDataValidationMobileUIPlugin=(Qt=class extends o.Plugin{constructor(e=ke,a,n,i){super(),this._config=e,this._injector=a,this._commandService=n,this._configService=i;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(oe,s)}onStarting(){[[ht],[gt],[jt],[wt],[Et],[Vt],[Mt],[Rt]].forEach(e=>{this._injector.add(e)}),[kt,Ft,Ue,ie,_t,Ne].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(Mt),this._injector.get(Vt),this._injector.get(Z.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Wt])}onRendered(){this._injector.get(Rt),this._injector.get(Et)}onSteady(){this._injector.get(wt)}},Y(Qt,"pluginName",ui),Y(Qt,"type",o.UniverInstanceType.UNIVER_SHEET),Qt),J.UniverSheetsDataValidationMobileUIPlugin=ci([De(1,o.Inject(o.Injector)),De(2,o.ICommandService),De(3,o.IConfigService)],J.UniverSheetsDataValidationMobileUIPlugin),J.DATE_DROPDOWN_KEY=se,J.LIST_DROPDOWN_KEY=Ut,Object.defineProperty(J,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@univerjs/sheets-data-validation-ui",
|
3
|
-
"version": "0.5.0-nightly.
|
3
|
+
"version": "0.5.0-nightly.202411141606",
|
4
4
|
"private": false,
|
5
5
|
"description": "Data validation UI for Univer Sheets",
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
@@ -59,19 +59,19 @@
|
|
59
59
|
"@univerjs/protocol": "0.1.39-alpha.38",
|
60
60
|
"clsx": "^2.1.1",
|
61
61
|
"dayjs": "^1.11.13",
|
62
|
-
"@univerjs/
|
63
|
-
"@univerjs/
|
64
|
-
"@univerjs/
|
65
|
-
"@univerjs/
|
66
|
-
"@univerjs/docs": "0.5.0-nightly.
|
67
|
-
"@univerjs/engine-
|
68
|
-
"@univerjs/
|
69
|
-
"@univerjs/sheets": "0.5.0-nightly.
|
70
|
-
"@univerjs/sheets
|
71
|
-
"@univerjs/sheets-numfmt": "0.5.0-nightly.
|
72
|
-
"@univerjs/sheets-
|
73
|
-
"@univerjs/ui": "0.5.0-nightly.
|
74
|
-
"@univerjs/sheets-ui": "0.5.0-nightly.
|
62
|
+
"@univerjs/core": "0.5.0-nightly.202411141606",
|
63
|
+
"@univerjs/data-validation": "0.5.0-nightly.202411141606",
|
64
|
+
"@univerjs/design": "0.5.0-nightly.202411141606",
|
65
|
+
"@univerjs/docs-ui": "0.5.0-nightly.202411141606",
|
66
|
+
"@univerjs/docs": "0.5.0-nightly.202411141606",
|
67
|
+
"@univerjs/engine-render": "0.5.0-nightly.202411141606",
|
68
|
+
"@univerjs/engine-formula": "0.5.0-nightly.202411141606",
|
69
|
+
"@univerjs/sheets-data-validation": "0.5.0-nightly.202411141606",
|
70
|
+
"@univerjs/sheets": "0.5.0-nightly.202411141606",
|
71
|
+
"@univerjs/sheets-numfmt": "0.5.0-nightly.202411141606",
|
72
|
+
"@univerjs/sheets-ui": "0.5.0-nightly.202411141606",
|
73
|
+
"@univerjs/ui": "0.5.0-nightly.202411141606",
|
74
|
+
"@univerjs/sheets-formula-ui": "0.5.0-nightly.202411141606"
|
75
75
|
},
|
76
76
|
"devDependencies": {
|
77
77
|
"less": "^4.2.0",
|