index.js 116 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057
  1. var ko = Object.defineProperty;
  2. var Wo = (e, t, o) => t in e ? ko(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
  3. var M = (e, t, o) => Wo(e, typeof t != "symbol" ? t + "" : t, o);
  4. import Zt, { useState as W, forwardRef as we, useRef as We, createElement as Re, useMemo as He, useEffect as Ce } from "react";
  5. import { Inject as b, LocaleService as J, Disposable as De, DataValidationErrorStyle as it, useDependency as L, ICommandService as Q, dayjs as qt, numfmt as Jt, CellValueType as Ho, UniverInstanceType as Y, toDisposable as Yo, IUniverInstanceService as ge, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as Xo, DisposableCollection as zo, CommandType as Je, BuildTextUtils as Ko, DataValidationRenderMode as de, DataValidationType as z, IConfigService as pn, UndoCommand as Go, RedoCommand as Zo, isUnitRangesEqual as qo, debounce as Jo, shallowEqual as bn, Injector as Fe, DataValidationStatus as rt, ObjectMatrix as _t, Range as Qo, Rectangle as St, queryObjectMatrix as Qt, Optional as ea, RxDisposable as fn, InterceptorEffectEnum as Kn, sequenceExecute as Gn, bufferDebounceTime as ta, isFormulaString as Pe, Tools as en, ThemeService as na, VerticalAlign as ue, HorizontalAlign as Ye, DEFAULT_STYLES as le, WrapStrategy as Se, DocumentDataModel as oa, DEFAULT_EMPTY_DOCUMENT_VALUE as aa, BooleanNumber as Qe, Plugin as Zn, merge as qn } from "@univerjs/core";
  6. import { Button as je, DatePanel as ia, Scrollbar as ra, FormLayout as Z, RadioGroup as mn, Radio as Ae, Checkbox as Ot, Input as xe, Select as tn, DraggableList as sa } from "@univerjs/design";
  7. import { DeviceInputEventType as nn, IRenderManagerService as Ve, fixLineWidthByScale as En, Transform as la, CheckboxShape as da, CURSOR_TYPE as Xe, FontCache as ca, Shape as ua, Rect as Jn, getFontStyleString as jt, getDocsSkeletonPageSize as et, DocumentViewModel as ha, DocumentSkeleton as pa, Documents as fa } from "@univerjs/engine-render";
  8. import { SheetInterceptorService as gn, AFTER_CELL_EDIT_ASYNC as ma, SetRangeValuesCommand as vn, SheetsSelectionsService as Qn, getSheetCommandTarget as eo, SheetPermissionCheckController as to, WorkbookEditablePermission as Ct, RangeProtectionPermissionEditPoint as It, WorksheetEditPermission as wt, checkRangesEditablePermission as ga, WorksheetSetCellStylePermission as on, INTERCEPTOR_POINT as no, InterceptCellContentPriority as oo } from "@univerjs/sheets";
  9. import { SheetDataValidationModel as oe, getCellValueOrigin as ie, getDataValidationCellValue as va, deserializeListOptions as ao, serializeListOptions as io, UpdateSheetDataValidationRangeCommand as ro, UpdateSheetDataValidationSettingCommand as On, RemoveSheetDataValidationCommand as so, UpdateSheetDataValidationOptionsCommand as _a, createDefaultNewRule as lo, AddSheetDataValidationCommand as _n, RemoveSheetAllDataValidationCommand as Sa, DATA_VALIDATION_PLUGIN_NAME as co, getDataValidationDiffMutations as an, DataValidationCacheService as uo, DataValidationFormulaController as Ca, DataValidationFormulaService as Ia, getFormulaResult as Ft, isLegalFormulaResult as Ln, transformCheckboxValue as wa, CHECKBOX_FORMULA_1 as Ra, CHECKBOX_FORMULA_2 as Da } from "@univerjs/sheets-data-validation";
  10. import { getPatternType as Va } from "@univerjs/sheets-numfmt";
  11. import { SetCellEditVisibleOperation as ho, SheetCanvasPopManagerService as ya, IEditorBridgeService as po, IMarkSelectionService as Ma, HoverManagerService as ba, CellAlertManagerService as Ea, CellAlertType as Oa, IAutoFillService as La, APPLY_TYPE as tt, virtualizeDiscreteRanges as rn, getAutoFillRepeatRange as Pa, COPY_TYPE as Pn, rangeToDiscreteRange as Ta, PREDEFINED_HOOK_NAME as dt, getRepeatRange as Tn, ISheetClipboardService as Aa, getCurrentRangeDisable$ as xa, AutoHeightController as fo, SheetSkeletonManagerService as Rt } from "@univerjs/sheets-ui";
  12. import { IDialogService as ja, KeyCode as sn, ISidebarService as mo, useObservable as Ne, ComponentManager as Lt, IZenZoneService as go, RectPopup as Fa, useEvent as ln, useSidebarClick as Sn, MenuItemType as Cn, getMenuHiddenObservable as Na, RibbonStartGroup as Ua, IMenuManagerService as Ba } from "@univerjs/ui";
  13. import { DataValidatorRegistryService as ye, DataValidationModel as Pt, DataValidatorRegistryScope as $a, TWO_FORMULA_OPERATOR_COUNT as ka, getRuleOptions as An, getRuleSetting as xn } from "@univerjs/data-validation";
  14. import { RichTextEditingMutation as Wa } from "@univerjs/docs";
  15. import { filter as In, BehaviorSubject as jn, distinctUntilChanged as Ha, Subject as Ya, debounceTime as wn, bufferTime as vo } from "rxjs";
  16. import { deserializeRangeWithSheet as Xa, serializeRange as _o } from "@univerjs/engine-formula";
  17. import { RangeSelector as za, FormulaEditor as So } from "@univerjs/sheets-formula-ui";
  18. var Nt = { exports: {} }, nt = {};
  19. /**
  20. * @license React
  21. * react-jsx-runtime.production.min.js
  22. *
  23. * Copyright (c) Facebook, Inc. and its affiliates.
  24. *
  25. * This source code is licensed under the MIT license found in the
  26. * LICENSE file in the root directory of this source tree.
  27. */
  28. var Fn;
  29. function Ka() {
  30. if (Fn) return nt;
  31. Fn = 1;
  32. var e = Zt, t = Symbol.for("react.element"), o = Symbol.for("react.fragment"), n = Object.prototype.hasOwnProperty, a = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
  33. function r(l, s, c) {
  34. var u, p = {}, d = null, g = null;
  35. c !== void 0 && (d = "" + c), s.key !== void 0 && (d = "" + s.key), s.ref !== void 0 && (g = s.ref);
  36. for (u in s) n.call(s, u) && !i.hasOwnProperty(u) && (p[u] = s[u]);
  37. if (l && l.defaultProps) for (u in s = l.defaultProps, s) p[u] === void 0 && (p[u] = s[u]);
  38. return { $$typeof: t, type: l, key: d, ref: g, props: p, _owner: a.current };
  39. }
  40. return nt.Fragment = o, nt.jsx = r, nt.jsxs = r, nt;
  41. }
  42. var Nn;
  43. function Ga() {
  44. return Nn || (Nn = 1, Nt.exports = Ka()), Nt.exports;
  45. }
  46. var h = Ga(), Za = Object.defineProperty, qa = Object.getOwnPropertyDescriptor, Ja = (e, t, o, n) => {
  47. for (var a = n > 1 ? void 0 : n ? qa(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  48. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  49. return n && a && Za(t, o, a), a;
  50. }, ot = (e, t) => (o, n) => t(o, n, e);
  51. let st = class extends De {
  52. constructor(e, t, o, n, a) {
  53. super(), this._sheetInterceptorService = e, this._dataValidationModel = t, this._dataValidatorRegistryService = o, this._dialogService = n, this._localeService = a, this._initEditorBridgeInterceptor();
  54. }
  55. _initEditorBridgeInterceptor() {
  56. this._sheetInterceptorService.writeCellInterceptor.intercept(
  57. ma,
  58. {
  59. handler: async (e, t, o) => {
  60. var C;
  61. const n = await e, { worksheet: a, row: i, col: r, unitId: l, subUnitId: s, workbook: c } = t, u = this._dataValidationModel.getRuleIdByLocation(l, s, i, r), p = u ? this._dataValidationModel.getRuleById(l, s, u) : void 0;
  62. if (!p || p.errorStyle !== it.STOP)
  63. return o(Promise.resolve(n));
  64. const d = await this._dataValidatorRegistryService.getValidatorItem(p.type);
  65. if (!d || await d.validator(
  66. {
  67. value: ie(n),
  68. interceptValue: ie((C = t == null ? void 0 : t.origin) != null ? C : n),
  69. row: i,
  70. column: r,
  71. unitId: l,
  72. subUnitId: s,
  73. worksheet: a,
  74. workbook: c,
  75. t: n == null ? void 0 : n.t
  76. },
  77. p
  78. ))
  79. return o(Promise.resolve(n));
  80. const f = a.getCellRaw(i, r);
  81. return this._dialogService.open({
  82. width: 368,
  83. title: {
  84. title: this._localeService.t("dataValidation.alert.title")
  85. },
  86. id: "reject-input-dialog",
  87. children: {
  88. title: d.getRuleFinalError(p, { row: i, col: r, unitId: l, subUnitId: s })
  89. },
  90. footer: {
  91. title: Zt.createElement(
  92. je,
  93. {
  94. type: "primary",
  95. onClick: () => this._dialogService.close("reject-input-dialog")
  96. },
  97. this._localeService.t("dataValidation.alert.ok")
  98. )
  99. },
  100. onClose: () => {
  101. this._dialogService.close("reject-input-dialog");
  102. }
  103. }), o(Promise.resolve(f));
  104. }
  105. }
  106. );
  107. }
  108. showReject(e) {
  109. this._dialogService.open({
  110. width: 368,
  111. title: {
  112. title: this._localeService.t("dataValidation.alert.title")
  113. },
  114. id: "reject-input-dialog",
  115. children: {
  116. title: e
  117. },
  118. footer: {
  119. title: Zt.createElement(
  120. je,
  121. {
  122. type: "primary",
  123. onClick: () => this._dialogService.close("reject-input-dialog")
  124. },
  125. this._localeService.t("dataValidation.alert.ok")
  126. )
  127. },
  128. onClose: () => {
  129. this._dialogService.close("reject-input-dialog");
  130. }
  131. });
  132. }
  133. };
  134. st = Ja([
  135. ot(0, b(gn)),
  136. ot(1, b(oe)),
  137. ot(2, b(ye)),
  138. ot(3, ja),
  139. ot(4, b(J))
  140. ], st);
  141. const Qa = "univer-dv-date-dropdown", ei = "univer-dv-date-dropdown-btns", Un = {
  142. dvDateDropdown: Qa,
  143. dvDateDropdownBtns: ei
  144. }, ti = (e) => {
  145. if (e == null || typeof e == "boolean")
  146. return;
  147. if (typeof e == "number" || !Number.isNaN(+e))
  148. return qt(Jt.format("yyyy-MM-dd HH:mm:ss", Number(e)));
  149. const t = qt(e);
  150. if (t.isValid())
  151. return t;
  152. };
  153. function ni(e) {
  154. var m;
  155. const { location: t, hideFn: o } = e, { worksheet: n, row: a, col: i, unitId: r, subUnitId: l, workbook: s } = t, c = L(Q), u = L(st), p = n.getCell(a, i), d = ie(n.getCellRaw(a, i)), g = ti(d), [f, C] = W(g), R = f && f.isValid() ? f : qt(), v = L(J), w = L(oe), I = w.getRuleByLocation(r, l, a, i);
  156. if (!I)
  157. return null;
  158. const V = w.getValidator(I.type);
  159. if (!p || !V)
  160. return;
  161. const _ = !!((m = I.bizInfo) != null && m.showTime), S = async () => {
  162. var x, j, N;
  163. if (!R)
  164. return;
  165. const P = R.format(_ ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD 00:00:00"), F = (x = Jt.parseDate(P)) == null ? void 0 : x.v, T = s.getStyles().getStyleByCell(p), E = (N = (j = T == null ? void 0 : T.n) == null ? void 0 : j.pattern) != null ? N : "", A = Va(E);
  166. I.errorStyle !== it.STOP || await V.validator({
  167. value: F,
  168. unitId: r,
  169. subUnitId: l,
  170. row: a,
  171. column: i,
  172. worksheet: n,
  173. workbook: s,
  174. interceptValue: P.replace("Z", "").replace("T", " "),
  175. t: Ho.NUMBER
  176. }, I) ? (o(), await c.executeCommand(ho.id, {
  177. visible: !1,
  178. eventType: nn.Keyboard,
  179. unitId: r,
  180. keycode: sn.ESC
  181. }), await c.executeCommand(vn.id, {
  182. unitId: r,
  183. subUnitId: l,
  184. range: {
  185. startColumn: i,
  186. endColumn: i,
  187. startRow: a,
  188. endRow: a
  189. },
  190. value: {
  191. v: F,
  192. t: 2,
  193. p: null,
  194. f: null,
  195. si: null,
  196. s: {
  197. n: {
  198. pattern: _ ? A === "datetime" ? E : "yyyy-MM-dd hh:mm:ss" : A === "date" ? E : "yyyy-MM-dd"
  199. }
  200. }
  201. }
  202. })) : u.showReject(V.getRuleFinalError(I, { row: a, col: i, unitId: r, subUnitId: l }));
  203. };
  204. return /* @__PURE__ */ h.jsxs("div", { className: Un.dvDateDropdown, children: [
  205. /* @__PURE__ */ h.jsx(
  206. ia,
  207. {
  208. defaultValue: R,
  209. pickerValue: R,
  210. showTime: _ || void 0,
  211. onSelect: async (y) => {
  212. C(y);
  213. },
  214. onPanelChange: (y) => {
  215. C(y);
  216. },
  217. disabledDate: (y) => !Jt.parseDate(y.format("YYYY-MM-DD"))
  218. }
  219. ),
  220. /* @__PURE__ */ h.jsx("div", { className: Un.dvDateDropdownBtns, children: /* @__PURE__ */ h.jsx(je, { size: "small", type: "primary", onClick: S, disabled: !R.isValid(), children: v.t("dataValidation.alert.ok") }) })
  221. ] });
  222. }
  223. var ce = function() {
  224. return ce = Object.assign || function(e) {
  225. for (var t, o = 1, n = arguments.length; o < n; o++) {
  226. t = arguments[o];
  227. for (var a in t) Object.prototype.hasOwnProperty.call(t, a) && (e[a] = t[a]);
  228. }
  229. return e;
  230. }, ce.apply(this, arguments);
  231. }, oi = function(e, t) {
  232. var o = {};
  233. for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (o[n] = e[n]);
  234. if (e != null && typeof Object.getOwnPropertySymbols == "function")
  235. for (var a = 0, n = Object.getOwnPropertySymbols(e); a < n.length; a++)
  236. t.indexOf(n[a]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[a]) && (o[n[a]] = e[n[a]]);
  237. return o;
  238. }, Me = we(function(e, t) {
  239. var o = e.icon, n = e.id, a = e.className, i = e.extend, r = oi(e, ["icon", "id", "className", "extend"]), l = "univerjs-icon univerjs-icon-".concat(n, " ").concat(a || "").trim(), s = We("_".concat(ri()));
  240. return Co(o, "".concat(n), { defIds: o.defIds, idSuffix: s.current }, ce({ ref: t, className: l }, r), i);
  241. });
  242. function Co(e, t, o, n, a) {
  243. return Re(e.tag, ce(ce({ key: t }, ai(e, o, a)), n), (ii(e, o).children || []).map(function(i, r) {
  244. return Co(i, "".concat(t, "-").concat(e.tag, "-").concat(r), o, void 0, a);
  245. }));
  246. }
  247. function ai(e, t, o) {
  248. var n = ce({}, e.attrs);
  249. o != null && o.colorChannel1 && n.fill === "colorChannel1" && (n.fill = o.colorChannel1);
  250. var a = t.defIds;
  251. return !a || a.length === 0 || (e.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + t.idSuffix), Object.entries(n).forEach(function(i) {
  252. var r = i[0], l = i[1];
  253. typeof l == "string" && (n[r] = l.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
  254. })), n;
  255. }
  256. function ii(e, t) {
  257. var o, n = t.defIds;
  258. return !n || n.length === 0 ? e : e.tag === "defs" && (!((o = e.children) === null || o === void 0) && o.length) ? ce(ce({}, e), { children: e.children.map(function(a) {
  259. return typeof a.attrs.id == "string" && n && n.indexOf(a.attrs.id) > -1 ? ce(ce({}, a), { attrs: ce(ce({}, a.attrs), { id: a.attrs.id + t.idSuffix }) }) : a;
  260. }) }) : e;
  261. }
  262. function ri() {
  263. return Math.random().toString(36).substring(2, 8);
  264. }
  265. Me.displayName = "UniverIcon";
  266. var si = { 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" } }] }, Io = we(function(e, t) {
  267. return Re(Me, Object.assign({}, e, {
  268. id: "check-mark-single",
  269. ref: t,
  270. icon: si
  271. }));
  272. });
  273. Io.displayName = "CheckMarkSingle";
  274. var li = { 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" } }] }, wo = we(function(e, t) {
  275. return Re(Me, Object.assign({}, e, {
  276. id: "data-validation-single",
  277. ref: t,
  278. icon: li
  279. }));
  280. });
  281. wo.displayName = "DataValidationSingle";
  282. var di = { 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" } }] }, Rn = we(function(e, t) {
  283. return Re(Me, Object.assign({}, e, {
  284. id: "delete-single",
  285. ref: t,
  286. icon: di
  287. }));
  288. });
  289. Rn.displayName = "DeleteSingle";
  290. var ci = { 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" } }] }, Ro = we(function(e, t) {
  291. return Re(Me, Object.assign({}, e, {
  292. id: "increase-single",
  293. ref: t,
  294. icon: ci
  295. }));
  296. });
  297. Ro.displayName = "IncreaseSingle";
  298. var ui = { 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" } }] }, Do = we(function(e, t) {
  299. return Re(Me, Object.assign({}, e, {
  300. id: "more-down-single",
  301. ref: t,
  302. icon: ui
  303. }));
  304. });
  305. Do.displayName = "MoreDownSingle";
  306. var hi = { 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" } }] }, Vo = we(function(e, t) {
  307. return Re(Me, Object.assign({}, e, {
  308. id: "more-up-single",
  309. ref: t,
  310. icon: hi
  311. }));
  312. });
  313. Vo.displayName = "MoreUpSingle";
  314. var pi = { 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" } }] }] }, yo = we(function(e, t) {
  315. return Re(Me, Object.assign({}, e, {
  316. id: "sequence-single",
  317. ref: t,
  318. icon: pi
  319. }));
  320. });
  321. yo.displayName = "SequenceSingle";
  322. var fi = Object.defineProperty, mi = Object.getOwnPropertyDescriptor, gi = (e, t, o, n) => {
  323. for (var a = n > 1 ? void 0 : n ? mi(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  324. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  325. return n && a && fi(t, o, a), a;
  326. }, Bn = (e, t) => (o, n) => t(o, n, e);
  327. let fe = class extends De {
  328. constructor(t, o) {
  329. super();
  330. M(this, "_open$", new jn(!1));
  331. M(this, "open$", this._open$.pipe(Ha()));
  332. M(this, "_activeRule");
  333. M(this, "_activeRule$", new jn(void 0));
  334. M(this, "activeRule$", this._activeRule$.asObservable());
  335. M(this, "_closeDisposable", null);
  336. this._univerInstanceService = t, this._sidebarService = o, this.disposeWithMe(
  337. this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET).pipe(In((n) => !n)).subscribe(() => {
  338. this.close();
  339. })
  340. ), this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe((n) => {
  341. n.id === Dt && (n.visible || setTimeout(() => {
  342. this._sidebarService.sidebarOptions$.next({ visible: !1 });
  343. }));
  344. }));
  345. }
  346. get activeRule() {
  347. return this._activeRule;
  348. }
  349. get isOpen() {
  350. return this._open$.getValue();
  351. }
  352. dispose() {
  353. var t;
  354. super.dispose(), this._open$.next(!1), this._open$.complete(), this._activeRule$.complete(), (t = this._closeDisposable) == null || t.dispose();
  355. }
  356. open() {
  357. this._open$.next(!0);
  358. }
  359. close() {
  360. var t;
  361. this._open$.next(!1), (t = this._closeDisposable) == null || t.dispose();
  362. }
  363. setCloseDisposable(t) {
  364. this._closeDisposable = Yo(() => {
  365. t.dispose(), this._closeDisposable = null;
  366. });
  367. }
  368. setActiveRule(t) {
  369. this._activeRule = t, this._activeRule$.next(t);
  370. }
  371. };
  372. fe = gi([
  373. Bn(0, ge),
  374. Bn(1, mo)
  375. ], fe);
  376. function vi() {
  377. const e = L(Ie), t = Ne(e.activeDropdown$, e.activeDropdown), o = L(Lt);
  378. if (!t)
  379. return null;
  380. const { location: n, componentKey: a } = t, i = o.get(a), r = `${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;
  381. if (!i)
  382. return null;
  383. const l = () => {
  384. e.hideDropdown();
  385. };
  386. return /* @__PURE__ */ h.jsx(
  387. i,
  388. {
  389. location: n,
  390. hideFn: l
  391. },
  392. r
  393. );
  394. }
  395. const Mo = "sheet.ui.dropdown";
  396. var _i = Object.defineProperty, Si = Object.getOwnPropertyDescriptor, Ci = (e, t, o, n) => {
  397. for (var a = n > 1 ? void 0 : n ? Si(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  398. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  399. return n && a && _i(t, o, a), a;
  400. }, be = (e, t) => (o, n) => t(o, n, e);
  401. let Ie = class extends De {
  402. constructor(t, o, n, a, i, r, l) {
  403. super();
  404. M(this, "_activeDropdown");
  405. M(this, "_activeDropdown$", new Ya());
  406. M(this, "_currentPopup", null);
  407. M(this, "activeDropdown$", this._activeDropdown$.asObservable());
  408. M(this, "_zenVisible", !1);
  409. this._canvasPopupManagerService = t, this._univerInstanceService = o, this._dataValidatorRegistryService = n, this._zenZoneService = a, this._renderManagerService = i, this._dataValidationModel = r, this._sheetsSelectionsService = l, this._init(), this._initSelectionChange(), this.disposeWithMe(() => {
  410. this._activeDropdown$.complete();
  411. });
  412. }
  413. get activeDropdown() {
  414. return this._activeDropdown;
  415. }
  416. _init() {
  417. this.disposeWithMe(this._zenZoneService.visible$.subscribe((t) => {
  418. this._zenVisible = t, t && this.hideDropdown();
  419. }));
  420. }
  421. _getDropdownByCell(t, o, n, a) {
  422. const i = t ? this._univerInstanceService.getUnit(t, Y.UNIVER_SHEET) : this._univerInstanceService.getCurrentUnitForType(Y.UNIVER_SHEET);
  423. if (!i)
  424. return;
  425. const r = o ? i.getSheetBySheetId(o) : i.getActiveSheet();
  426. if (!r)
  427. return;
  428. const l = this._dataValidationModel.getRuleByLocation(i.getUnitId(), r.getSheetId(), n, a);
  429. if (!l)
  430. return;
  431. const s = this._dataValidatorRegistryService.getValidatorItem(l.type);
  432. return s == null ? void 0 : s.dropdown;
  433. }
  434. _initSelectionChange() {
  435. this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe((t) => {
  436. t && t.every((o) => !(o.primary && this._getDropdownByCell(o.primary.unitId, o.primary.sheetId, o.primary.actualRow, o.primary.actualColumn))) && this.hideDropdown();
  437. }));
  438. }
  439. showDropdown(t, o = !0) {
  440. const { location: n } = t, { row: a, col: i, unitId: r, subUnitId: l } = n;
  441. if (this._currentPopup && this._currentPopup.dispose(), this._zenVisible)
  442. return;
  443. this._activeDropdown = t, this._activeDropdown$.next(this._activeDropdown);
  444. const s = this._renderManagerService.getRenderById(Xo), c = this._canvasPopupManagerService.attachPopupToCell(
  445. a,
  446. i,
  447. {
  448. componentKey: Mo,
  449. onClickOutside: () => {
  450. o && this.hideDropdown();
  451. },
  452. offset: [0, 3],
  453. excludeOutside: [s == null ? void 0 : s.engine.getCanvasElement()].filter(Boolean)
  454. },
  455. r,
  456. l
  457. );
  458. if (!c)
  459. throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");
  460. const u = new zo();
  461. u.add(c), u.add({
  462. dispose: () => {
  463. var p, d;
  464. (d = (p = this._activeDropdown) == null ? void 0 : p.onHide) == null || d.call(p);
  465. }
  466. }), this._currentPopup = u;
  467. }
  468. hideDropdown() {
  469. this._activeDropdown && (this._currentPopup && this._currentPopup.dispose(), this._currentPopup = null, this._activeDropdown = null, this._activeDropdown$.next(null));
  470. }
  471. showDataValidationDropdown(t, o, n, a, i) {
  472. const r = this._univerInstanceService.getUnit(t, Y.UNIVER_SHEET);
  473. if (!r)
  474. return;
  475. const l = r.getSheetBySheetId(o);
  476. if (!l)
  477. return;
  478. const s = this._dataValidationModel.getRuleByLocation(r.getUnitId(), l.getSheetId(), n, a);
  479. if (!s)
  480. return;
  481. const c = this._dataValidatorRegistryService.getValidatorItem(s.type);
  482. if (!c || !c.dropdown) {
  483. this.hideDropdown();
  484. return;
  485. }
  486. this.showDropdown({
  487. location: {
  488. workbook: r,
  489. worksheet: l,
  490. row: n,
  491. col: a,
  492. unitId: t,
  493. subUnitId: o
  494. },
  495. componentKey: c.dropdown,
  496. onHide: i
  497. });
  498. }
  499. };
  500. Ie = Ci([
  501. be(0, b(ya)),
  502. be(1, ge),
  503. be(2, b(ye)),
  504. be(3, go),
  505. be(4, Ve),
  506. be(5, b(oe)),
  507. be(6, b(Qn))
  508. ], Ie);
  509. const Dt = "DataValidationPanel", Ue = {
  510. id: "data-validation.operation.open-validation-panel",
  511. type: Je.OPERATION,
  512. handler(e, t) {
  513. if (!t)
  514. return !1;
  515. const { ruleId: o, isAdd: n } = t, a = e.get(fe), i = e.get(Pt), r = e.get(ge), l = e.get(mo), s = eo(r);
  516. if (!s) return !1;
  517. const { unitId: c, subUnitId: u } = s, p = o ? i.getRuleById(c, u, o) : void 0;
  518. a.open(), a.setActiveRule(p && {
  519. unitId: c,
  520. subUnitId: u,
  521. rule: p
  522. });
  523. const d = l.open({
  524. id: Dt,
  525. header: { title: n ? "dataValidation.panel.addTitle" : "dataValidation.panel.title" },
  526. children: { label: Dt },
  527. width: 312,
  528. onClose: () => a.close()
  529. });
  530. return a.setCloseDisposable(d), !0;
  531. }
  532. }, Dn = {
  533. id: "data-validation.operation.close-validation-panel",
  534. type: Je.OPERATION,
  535. handler(e) {
  536. return e.get(fe).close(), !0;
  537. }
  538. }, bo = {
  539. id: "data-validation.operation.toggle-validation-panel",
  540. type: Je.OPERATION,
  541. handler(e) {
  542. const t = e.get(Q), o = e.get(fe);
  543. return o.open(), o.isOpen ? t.executeCommand(Dn.id) : t.executeCommand(Ue.id), !0;
  544. }
  545. }, Tt = {
  546. type: Je.OPERATION,
  547. id: "sheet.operation.show-data-validation-dropdown",
  548. handler(e, t) {
  549. if (!t)
  550. return !1;
  551. const o = e.get(Ie), { unitId: n, subUnitId: a, row: i, column: r } = t, l = o.activeDropdown, s = l == null ? void 0 : l.location;
  552. return s && s.unitId === n && s.subUnitId === a && s.row === i && s.col === r || o.showDataValidationDropdown(
  553. n,
  554. a,
  555. i,
  556. r
  557. ), !0;
  558. }
  559. }, Eo = {
  560. type: Je.OPERATION,
  561. id: "sheet.operation.hide-data-validation-dropdown",
  562. handler(e, t) {
  563. return t ? (e.get(Ie).hideDropdown(), !0) : !1;
  564. }
  565. }, Te = "#ECECEC", Vn = "sheets-data-validation-ui.config", Vt = {}, Ii = "univer-dv-list-dropdown", wi = "univer-dv-list-dropdown-title", Ri = "univer-dv-list-dropdown-list", Di = "univer-dv-list-dropdown-list-container", Vi = "univer-dv-list-dropdown-selected-icon", yi = "univer-dv-list-dropdown-item-container", Mi = "univer-dv-list-dropdown-item", bi = "univer-dv-list-dropdown-split", Ei = "univer-dv-list-dropdown-edit", ve = {
  566. dvListDropdown: Ii,
  567. dvListDropdownTitle: wi,
  568. dvListDropdownList: Ri,
  569. dvListDropdownListContainer: Di,
  570. dvListDropdownSelectedIcon: Vi,
  571. dvListDropdownItemContainer: yi,
  572. dvListDropdownItem: Mi,
  573. dvListDropdownSplit: bi,
  574. dvListDropdownEdit: Ei
  575. }, Oi = (e) => {
  576. var _, S;
  577. const { value: t, onChange: o, multiple: n, options: a, title: i, onEdit: r, style: l, filter: s, location: c } = e, u = L(J), p = L(pn), d = s == null ? void 0 : s.toLowerCase(), { row: g, col: f, unitId: C, subUnitId: R } = c, v = a.filter((m) => d ? m.label.toLowerCase().includes(d) : !0), w = (S = (_ = p.getConfig(Vn)) == null ? void 0 : _.showEditOnDropdown) != null ? S : !0, I = L(to), V = He(() => I.permissionCheckWithRanges(
  578. {
  579. workbookTypes: [Ct],
  580. rangeTypes: [It],
  581. worksheetTypes: [wt]
  582. },
  583. [{ startColumn: f, startRow: g, endColumn: f, endRow: g }],
  584. C,
  585. R
  586. ), [I, f, g, C, R]);
  587. return /* @__PURE__ */ h.jsxs("div", { className: ve.dvListDropdown, style: l, children: [
  588. /* @__PURE__ */ h.jsx("div", { className: ve.dvListDropdownTitle, children: i }),
  589. /* @__PURE__ */ h.jsx("div", { className: ve.dvListDropdownList, children: /* @__PURE__ */ h.jsx(ra, { children: /* @__PURE__ */ h.jsx("div", { className: ve.dvListDropdownListContainer, children: v.map((m, y) => {
  590. const P = t.indexOf(m.value) > -1, F = () => {
  591. let E;
  592. P ? E = new Set(t.filter((x) => x !== m.value)) : E = new Set(n ? [...t, m.value] : [m.value]);
  593. const A = [];
  594. a.forEach((x) => {
  595. E.has(x.value) && A.push(x.value);
  596. }), o(A);
  597. }, T = m.label.toLocaleLowerCase().indexOf(d);
  598. return /* @__PURE__ */ h.jsxs("div", { className: ve.dvListDropdownItemContainer, onClick: F, children: [
  599. /* @__PURE__ */ h.jsx("div", { className: ve.dvListDropdownItem, style: { background: m.color || Te }, children: d && m.label.toLowerCase().includes(d) ? /* @__PURE__ */ h.jsxs(h.Fragment, { children: [
  600. /* @__PURE__ */ h.jsx("span", { children: m.label.substring(0, T) }),
  601. /* @__PURE__ */ h.jsx("span", { style: { fontWeight: "bold" }, children: m.label.substring(T, T + d.length) }),
  602. /* @__PURE__ */ h.jsx("span", { children: m.label.substring(T + d.length) })
  603. ] }) : m.label }),
  604. /* @__PURE__ */ h.jsx("div", { className: ve.dvListDropdownSelectedIcon, children: P ? /* @__PURE__ */ h.jsx(Io, {}) : null })
  605. ] }, y);
  606. }) }) }, s) }),
  607. w && V ? /* @__PURE__ */ h.jsxs(h.Fragment, { children: [
  608. /* @__PURE__ */ h.jsx("div", { className: ve.dvListDropdownSplit }),
  609. /* @__PURE__ */ h.jsx("div", { className: ve.dvListDropdownEdit, children: /* @__PURE__ */ h.jsx("a", { onClick: r, children: u.t("dataValidation.list.edit") }) })
  610. ] }) : null
  611. ] });
  612. };
  613. function Li(e) {
  614. var j, N, H, X;
  615. const { location: t, hideFn: o } = e, { worksheet: n, row: a, col: i, unitId: r, subUnitId: l } = t, s = L(Pt), [c, u] = W(""), p = L(Q), d = L(J), [g, f] = W(""), C = L(po), R = L(ge), v = He(() => s.ruleChange$.pipe(wn(16)), []), w = L(oe);
  616. Ne(v);
  617. const I = Fa.useContext(), V = ((N = (j = I.current) == null ? void 0 : j.right) != null ? N : 0) - ((X = (H = I.current) == null ? void 0 : H.left) != null ? X : 0);
  618. if (Ce(() => {
  619. const k = p.onCommandExecuted((K) => {
  620. var q, ee;
  621. if (K.id === Wa.id) {
  622. const te = K.params, { unitId: re } = te, ae = R.getUnit(re, Y.UNIVER_DOC);
  623. if (!ae || !C.isVisible().visible) return;
  624. const se = Ko.transform.getPlainText((ee = (q = ae.getSnapshot().body) == null ? void 0 : q.dataStream) != null ? ee : "");
  625. u(se);
  626. }
  627. });
  628. return () => {
  629. k.dispose();
  630. };
  631. }, [p, C, R]), !n)
  632. return null;
  633. const _ = w.getRuleByLocation(r, l, a, i);
  634. if (!_)
  635. return null;
  636. const S = w.getValidator(_.type);
  637. if (!S)
  638. return null;
  639. const m = n.getCell(a, i), y = (_ == null ? void 0 : _.renderMode) === de.CUSTOM || (_ == null ? void 0 : _.renderMode) === void 0;
  640. if (!m || !_ || !S || S.id.indexOf(z.LIST) !== 0)
  641. return;
  642. const P = _.type === z.LIST_MULTIPLE, F = S.getListWithColor(_, r, l), T = g || va(n.getCellRaw(a, i)), E = ao(T), A = () => {
  643. p.executeCommand(Ue.id, {
  644. ruleId: _.uid
  645. }), o();
  646. }, x = F.map((k) => ({
  647. label: k.label,
  648. value: k.label,
  649. color: y || k.color ? k.color : "transparent"
  650. }));
  651. return /* @__PURE__ */ h.jsx(
  652. Oi,
  653. {
  654. style: { minWidth: V, maxWidth: Math.max(V, 200) },
  655. title: P ? d.t("dataValidation.listMultiple.dropdown") : d.t("dataValidation.list.dropdown"),
  656. value: E,
  657. multiple: P,
  658. onChange: async (k) => {
  659. const K = io(k), q = {
  660. unitId: r,
  661. subUnitId: l,
  662. range: {
  663. startColumn: i,
  664. endColumn: i,
  665. startRow: a,
  666. endRow: a
  667. },
  668. value: {
  669. v: K,
  670. p: null,
  671. f: null,
  672. si: null
  673. }
  674. };
  675. C.isVisible() && C.changeVisible({
  676. visible: !1,
  677. keycode: sn.ESC,
  678. eventType: nn.Keyboard,
  679. unitId: r
  680. }), f(K), P || o(), C.isVisible().visible && await p.executeCommand(ho.id, {
  681. visible: !1,
  682. eventType: nn.Keyboard,
  683. unitId: r,
  684. keycode: sn.ESC
  685. }), p.executeCommand(vn.id, q);
  686. },
  687. options: x,
  688. onEdit: A,
  689. filter: c,
  690. location: t
  691. }
  692. );
  693. }
  694. const Pi = "univer-data-validation-options-button", Ti = "univer-data-validation-options-button-icon", Ut = {
  695. dataValidationOptionsButton: Pi,
  696. dataValidationOptionsButtonIcon: Ti
  697. };
  698. function Ai(e) {
  699. var c;
  700. const t = L(J), o = L(Lt), { value: n, onChange: a, extraComponent: i } = e, [r, l] = W(!1), s = i ? o.get(i) : null;
  701. return /* @__PURE__ */ h.jsxs(h.Fragment, { children: [
  702. /* @__PURE__ */ h.jsxs("div", { className: Ut.dataValidationOptionsButton, onClick: () => l(!r), children: [
  703. t.t("dataValidation.panel.options"),
  704. r ? /* @__PURE__ */ h.jsx(Vo, { className: Ut.dataValidationOptionsButtonIcon }) : /* @__PURE__ */ h.jsx(Do, { className: Ut.dataValidationOptionsButtonIcon })
  705. ] }),
  706. r && /* @__PURE__ */ h.jsxs(h.Fragment, { children: [
  707. s ? /* @__PURE__ */ h.jsx(s, { value: n, onChange: a }) : null,
  708. /* @__PURE__ */ h.jsx(
  709. Z,
  710. {
  711. label: t.t("dataValidation.panel.invalid"),
  712. children: /* @__PURE__ */ h.jsxs(
  713. mn,
  714. {
  715. value: `${(c = n.errorStyle) != null ? c : it.WARNING}`,
  716. onChange: (u) => a({ ...n, errorStyle: +u }),
  717. children: [
  718. /* @__PURE__ */ h.jsx(Ae, { value: `${it.WARNING}`, children: t.t("dataValidation.panel.showWarning") }),
  719. /* @__PURE__ */ h.jsx(Ae, { value: `${it.STOP}`, children: t.t("dataValidation.panel.rejectInput") })
  720. ]
  721. }
  722. )
  723. }
  724. ),
  725. /* @__PURE__ */ h.jsx(
  726. Z,
  727. {
  728. label: t.t("dataValidation.panel.messageInfo"),
  729. children: /* @__PURE__ */ h.jsx(
  730. Ot,
  731. {
  732. checked: n.showErrorMessage,
  733. onChange: () => a({
  734. ...n,
  735. showErrorMessage: !n.showErrorMessage
  736. }),
  737. children: t.t("dataValidation.panel.showInfo")
  738. }
  739. )
  740. }
  741. ),
  742. n.showErrorMessage ? /* @__PURE__ */ h.jsx(Z, { children: /* @__PURE__ */ h.jsx(xe, { value: n.error, onChange: (u) => a({ ...n, error: u }) }) }) : null
  743. ] })
  744. ] });
  745. }
  746. const xi = "univer-data-validation-detail", ji = "univer-data-validation-detail-form-item", Fi = "univer-data-validation-detail-buttons", Ni = "univer-data-validation-detail-button", Be = {
  747. dataValidationDetail: xi,
  748. dataValidationDetailFormItem: ji,
  749. dataValidationDetailButtons: Fi,
  750. dataValidationDetailButton: Ni
  751. }, Ui = (e) => Jo(
  752. async (t, o, n, a) => {
  753. const i = await e.executeCommand(t, o, n);
  754. a == null || a(i);
  755. },
  756. 1e3
  757. );
  758. function Bi(e, t, o) {
  759. var n, a, i, r;
  760. return t ? ((a = (n = e.getUnit(t)) == null ? void 0 : n.getSheetBySheetName(o)) == null ? void 0 : a.getSheetId()) || "" : ((r = (i = e.getCurrentUnitForType(Y.UNIVER_SHEET)) == null ? void 0 : i.getSheetBySheetName(o)) == null ? void 0 : r.getSheetId()) || "";
  761. }
  762. function $i() {
  763. var se;
  764. const [e, t] = W(0), o = L(fe), n = Ne(o.activeRule$, o.activeRule), { unitId: a, subUnitId: i, rule: r } = n || {}, l = r.uid, s = L(ye), c = L(ge), u = L(Lt), p = L(Q), d = L(Pt), g = L(J), [f, C] = W(r), R = s.getValidatorItem(f.type), [v, w] = W(!1), I = s.getValidatorsByScope($a.SHEET), [V, _] = W(() => f.ranges.map((O) => ({ unitId: "", sheetId: "", range: O }))), S = He(() => Ui(p), [p]), [m, y] = W(!1), P = We({}), [F, T] = W(!1), E = L(Qn);
  765. if (Ce(() => () => {
  766. const O = E.getCurrentLastSelection();
  767. O && E.setSelections([O]);
  768. }, [E]), Ce(() => {
  769. p.onCommandExecuted((O) => {
  770. (O.id === Go.id || O.id === Zo.id) && setTimeout(() => {
  771. const D = d.getRuleById(a, i, l);
  772. t((U) => U + 1), D && (C(D), _(D.ranges.map((U) => ({ unitId: "", sheetId: "", range: U }))));
  773. }, 20);
  774. });
  775. }, [p, d, l, i, a]), !R)
  776. return null;
  777. const A = R.operators, x = R.operatorNames, j = f.operator ? ka.includes(f.operator) : !1, N = () => {
  778. !f.ranges.length || m || (R.validatorFormula(f, a, i).success ? o.setActiveRule(null) : w(!0));
  779. }, H = ln((O) => {
  780. const D = O.split(",").filter(Boolean).map(Xa).map(($) => {
  781. const _e = $.sheetName;
  782. if (_e) {
  783. const $o = Bi(c, $.unitId, _e);
  784. return { ...$, sheetId: $o };
  785. }
  786. return {
  787. ...$,
  788. sheetId: ""
  789. };
  790. });
  791. if (qo(D, V))
  792. return;
  793. _(D);
  794. const U = D.filter(($) => (!$.unitId || $.unitId === a) && (!$.sheetId || $.sheetId === i)).map(($) => $.range);
  795. if (C({
  796. ...f,
  797. ranges: U
  798. }), U.length === 0)
  799. return;
  800. const B = {
  801. unitId: a,
  802. subUnitId: i,
  803. ruleId: l,
  804. ranges: U
  805. };
  806. S(ro.id, B);
  807. }), X = (O) => {
  808. if (bn(O, xn(f)))
  809. return;
  810. C({
  811. ...f,
  812. ...O
  813. });
  814. const D = {
  815. unitId: a,
  816. subUnitId: i,
  817. ruleId: l,
  818. setting: O
  819. };
  820. S(
  821. On.id,
  822. D,
  823. void 0
  824. );
  825. }, k = async () => {
  826. await p.executeCommand(so.id, {
  827. ruleId: l,
  828. unitId: a,
  829. subUnitId: i
  830. }), o.setActiveRule(null);
  831. }, K = {
  832. type: f.type,
  833. operator: f.operator,
  834. formula1: f.formula1,
  835. formula2: f.formula2,
  836. allowBlank: f.allowBlank
  837. }, q = (O) => {
  838. const D = s.getValidatorItem(O);
  839. if (!D)
  840. return;
  841. const U = D.operators, B = d.getRuleById(a, i, l), $ = O === (B == null ? void 0 : B.type) || O.includes("list") && (B != null && B.type.includes("list")) ? {
  842. ...B,
  843. type: O
  844. } : {
  845. ...f,
  846. type: O,
  847. operator: U[0],
  848. formula1: void 0,
  849. formula2: void 0
  850. };
  851. C($), p.executeCommand(On.id, {
  852. unitId: a,
  853. subUnitId: i,
  854. ruleId: f.uid,
  855. setting: xn($)
  856. });
  857. }, ee = u.get(R.formulaInput), te = He(() => V.map((O) => _o(O.range)).join(","), []), re = An(f), ae = (O) => {
  858. bn(O, An(f)) || (C({
  859. ...f,
  860. ...O
  861. }), S(
  862. _a.id,
  863. {
  864. unitId: a,
  865. subUnitId: i,
  866. ruleId: l,
  867. options: O
  868. }
  869. ));
  870. };
  871. return Sn((O) => {
  872. var U;
  873. const D = (U = P.current) == null ? void 0 : U.handleOutClick;
  874. D && D(O, () => T(!1));
  875. }), /* @__PURE__ */ h.jsxs("div", { className: Be.dataValidationDetail, children: [
  876. /* @__PURE__ */ h.jsx(
  877. Z,
  878. {
  879. label: g.t("dataValidation.panel.range"),
  880. error: !f.ranges.length || m ? g.t("dataValidation.panel.rangeError") : "",
  881. children: /* @__PURE__ */ h.jsx(
  882. za,
  883. {
  884. unitId: a,
  885. subUnitId: i,
  886. initValue: te,
  887. onChange: H,
  888. onFocus: () => T(!0),
  889. isFocus: F,
  890. actions: P.current,
  891. onVerify: (O) => y(!O)
  892. }
  893. )
  894. }
  895. ),
  896. /* @__PURE__ */ h.jsx(Z, { label: g.t("dataValidation.panel.type"), children: /* @__PURE__ */ h.jsx(
  897. tn,
  898. {
  899. options: I == null ? void 0 : I.map((O) => ({
  900. label: g.t(O.title),
  901. value: O.id
  902. })),
  903. value: f.type,
  904. onChange: q,
  905. className: Be.dataValidationDetailFormItem
  906. }
  907. ) }),
  908. A != null && A.length ? /* @__PURE__ */ h.jsx(Z, { label: g.t("dataValidation.panel.operator"), children: /* @__PURE__ */ h.jsx(
  909. tn,
  910. {
  911. options: A.map((O, D) => ({
  912. value: `${O}`,
  913. label: x[D]
  914. })),
  915. value: `${f.operator}`,
  916. onChange: (O) => {
  917. X({
  918. ...K,
  919. operator: O
  920. });
  921. },
  922. className: Be.dataValidationDetailFormItem
  923. }
  924. ) }) : null,
  925. ee ? /* @__PURE__ */ h.jsx(
  926. ee,
  927. {
  928. isTwoFormula: j,
  929. value: {
  930. formula1: f.formula1,
  931. formula2: f.formula2
  932. },
  933. onChange: (O) => {
  934. X({
  935. ...K,
  936. ...O
  937. });
  938. },
  939. showError: v,
  940. validResult: R.validatorFormula(f, a, i),
  941. unitId: a,
  942. subUnitId: i,
  943. ruleId: l
  944. },
  945. e + f.type
  946. ) : null,
  947. /* @__PURE__ */ h.jsx(Z, { children: /* @__PURE__ */ h.jsx(
  948. Ot,
  949. {
  950. checked: (se = f.allowBlank) != null ? se : !0,
  951. onChange: () => {
  952. var O;
  953. return X({
  954. ...K,
  955. allowBlank: !((O = f.allowBlank) == null || O)
  956. });
  957. },
  958. children: g.t("dataValidation.panel.allowBlank")
  959. }
  960. ) }),
  961. /* @__PURE__ */ h.jsx(Ai, { value: re, onChange: ae, extraComponent: R.optionsInput }),
  962. /* @__PURE__ */ h.jsxs("div", { className: Be.dataValidationDetailButtons, children: [
  963. /* @__PURE__ */ h.jsx(je, { className: Be.dataValidationDetailButton, onClick: k, children: g.t("dataValidation.panel.removeRule") }),
  964. /* @__PURE__ */ h.jsx(je, { className: Be.dataValidationDetailButton, type: "primary", onClick: N, children: g.t("dataValidation.panel.done") })
  965. ] })
  966. ] });
  967. }
  968. const ki = "univer-data-validation-item-container", Wi = "univer-data-validation-item-title", Hi = "univer-data-validation-item-content", Yi = "univer-data-validation-item-icon", ct = {
  969. dataValidationItemContainer: ki,
  970. dataValidationItemTitle: Wi,
  971. dataValidationItemContent: Hi,
  972. dataValidationItemIcon: Yi
  973. }, Xi = (e) => {
  974. const { rule: t, onClick: o, unitId: n, subUnitId: a, disable: i } = e, r = L(ye), l = L(Q), s = L(Ma), c = r.getValidatorItem(t.type), u = We(), [p, d] = W(!1), g = (f) => {
  975. l.executeCommand(so.id, {
  976. ruleId: t.uid,
  977. unitId: n,
  978. subUnitId: a
  979. }), f.stopPropagation();
  980. };
  981. return Ce(() => () => {
  982. var f;
  983. u.current && ((f = u.current) == null || f.forEach((C) => {
  984. C && s.removeShape(C);
  985. }));
  986. }, [s]), /* @__PURE__ */ h.jsxs(
  987. "div",
  988. {
  989. className: ct.dataValidationItemContainer,
  990. onClick: o,
  991. onMouseEnter: () => {
  992. i || (d(!0), u.current = t.ranges.map((f) => s.addShape({
  993. range: f,
  994. style: {
  995. // hasAutoFill: false,
  996. fill: "rgba(73, 184, 17, 0.05)",
  997. strokeWidth: 1,
  998. stroke: "#49B811",
  999. widgets: {}
  1000. },
  1001. primary: null
  1002. })));
  1003. },
  1004. onMouseLeave: () => {
  1005. var f;
  1006. d(!1), (f = u.current) == null || f.forEach((C) => {
  1007. C && s.removeShape(C);
  1008. }), u.current = void 0;
  1009. },
  1010. children: [
  1011. /* @__PURE__ */ h.jsx("div", { className: ct.dataValidationItemTitle, children: c == null ? void 0 : c.generateRuleName(t) }),
  1012. /* @__PURE__ */ h.jsx("div", { className: ct.dataValidationItemContent, children: t.ranges.map((f) => _o(f)).join(",") }),
  1013. p ? /* @__PURE__ */ h.jsx("div", { className: ct.dataValidationItemIcon, onClick: g, children: /* @__PURE__ */ h.jsx(Rn, {}) }) : null
  1014. ]
  1015. }
  1016. );
  1017. }, zi = "univer-data-validation-list", Ki = "univer-data-validation-list-buttons", Gi = "univer-data-validation-list-button", ut = {
  1018. dataValidationList: zi,
  1019. dataValidationListButtons: Ki,
  1020. dataValidationListButton: Gi
  1021. };
  1022. function Zi() {
  1023. const e = L(ge), t = Ne(
  1024. () => e.getCurrentTypeOfUnit$(Y.UNIVER_SHEET),
  1025. void 0,
  1026. void 0,
  1027. []
  1028. );
  1029. return t ? /* @__PURE__ */ h.jsx(qi, { workbook: t }) : null;
  1030. }
  1031. function qi(e) {
  1032. const t = L(oe), o = L(ge), n = L(Q), a = L(Fe), i = L(fe), r = L(J), [l, s] = W([]), { workbook: c } = e, u = Ne(c.activeSheet$, void 0, !0), p = c.getUnitId(), d = u == null ? void 0 : u.getSheetId();
  1033. Ce(() => {
  1034. s(t.getRules(p, d));
  1035. const w = t.ruleChange$.subscribe((I) => {
  1036. I.unitId === p && I.subUnitId === d && s(t.getRules(p, d));
  1037. });
  1038. return () => {
  1039. w.unsubscribe();
  1040. };
  1041. }, [p, d, t]);
  1042. const g = async () => {
  1043. const w = lo(a), I = {
  1044. unitId: p,
  1045. subUnitId: d,
  1046. rule: w
  1047. };
  1048. await n.executeCommand(_n.id, I), i.setActiveRule({
  1049. unitId: p,
  1050. subUnitId: d,
  1051. rule: w
  1052. });
  1053. }, f = () => {
  1054. n.executeCommand(Sa.id, {
  1055. unitId: p,
  1056. subUnitId: d
  1057. });
  1058. }, R = ((w) => {
  1059. const I = o.getCurrentUnitForType(Y.UNIVER_SHEET), V = I.getActiveSheet(), _ = I.getUnitId(), S = V.getSheetId();
  1060. return w.map((y) => ga(a, _, S, y.ranges) ? { ...y } : { ...y, disable: !0 });
  1061. })(l), v = R == null ? void 0 : R.some((w) => w.disable);
  1062. return /* @__PURE__ */ h.jsxs("div", { className: ut.dataValidationList, children: [
  1063. R == null ? void 0 : R.map((w) => {
  1064. var I;
  1065. return /* @__PURE__ */ h.jsx(
  1066. Xi,
  1067. {
  1068. unitId: p,
  1069. subUnitId: d,
  1070. onClick: () => {
  1071. w.disable || i.setActiveRule({
  1072. unitId: p,
  1073. subUnitId: d,
  1074. rule: w
  1075. });
  1076. },
  1077. rule: w,
  1078. disable: (I = w.disable) != null ? I : !1
  1079. },
  1080. w.uid
  1081. );
  1082. }),
  1083. /* @__PURE__ */ h.jsxs("div", { className: ut.dataValidationListButtons, children: [
  1084. l.length && !v ? /* @__PURE__ */ h.jsx(je, { className: ut.dataValidationListButton, onClick: f, children: r.t("dataValidation.panel.removeAll") }) : null,
  1085. /* @__PURE__ */ h.jsx(je, { className: ut.dataValidationListButton, type: "primary", onClick: g, children: r.t("dataValidation.panel.add") })
  1086. ] })
  1087. ] });
  1088. }
  1089. const Ji = () => {
  1090. const e = L(fe), t = Ne(e.activeRule$, e.activeRule);
  1091. return t ? /* @__PURE__ */ h.jsx($i, {}, t.rule.uid) : /* @__PURE__ */ h.jsx(Zi, {});
  1092. }, yn = "data-validation.list.dropdown", Oo = "data-validation.date.dropdown", At = {
  1093. type: Je.COMMAND,
  1094. id: "data-validation.command.addRuleAndOpen",
  1095. handler(e) {
  1096. const t = e.get(ge), o = eo(t);
  1097. if (!o) return !1;
  1098. const { workbook: n, worksheet: a } = o, i = lo(e), r = e.get(Q), l = n.getUnitId(), s = a.getSheetId(), c = {
  1099. rule: i,
  1100. unitId: l,
  1101. subUnitId: s
  1102. };
  1103. return r.syncExecuteCommand(_n.id, c) ? (r.syncExecuteCommand(Ue.id, {
  1104. ruleId: i.uid,
  1105. isAdd: !0
  1106. }), !0) : !1;
  1107. }
  1108. };
  1109. var Qi = Object.defineProperty, er = Object.getOwnPropertyDescriptor, tr = (e, t, o, n) => {
  1110. for (var a = n > 1 ? void 0 : n ? er(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  1111. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  1112. return n && a && Qi(t, o, a), a;
  1113. }, $e = (e, t) => (o, n) => t(o, n, e);
  1114. const Ee = "SHEET_DATA_VALIDATION_ALERT";
  1115. let lt = class extends De {
  1116. constructor(e, t, o, n, a, i) {
  1117. super(), this._hoverManagerService = e, this._cellAlertManagerService = t, this._univerInstanceService = o, this._localeService = n, this._zenZoneService = a, this._dataValidationModel = i, this._init();
  1118. }
  1119. _init() {
  1120. this._initCellAlertPopup(), this._initZenService();
  1121. }
  1122. _initCellAlertPopup() {
  1123. this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(wn(100)).subscribe((e) => {
  1124. var t;
  1125. if (e) {
  1126. const o = this._univerInstanceService.getUnit(e.location.unitId, Y.UNIVER_SHEET), n = o.getSheetBySheetId(e.location.subUnitId);
  1127. if (!n) return;
  1128. const a = this._dataValidationModel.getRuleByLocation(e.location.unitId, e.location.subUnitId, e.location.row, e.location.col);
  1129. if (!a) {
  1130. this._cellAlertManagerService.removeAlert(Ee);
  1131. return;
  1132. }
  1133. if (this._dataValidationModel.validator(a, { ...e.location, workbook: o, worksheet: n }) === rt.INVALID) {
  1134. const r = this._cellAlertManagerService.currentAlert.get(Ee), l = (t = r == null ? void 0 : r.alert) == null ? void 0 : t.location;
  1135. if (l && l.row === e.location.row && l.col === e.location.col && l.subUnitId === e.location.subUnitId && l.unitId === e.location.unitId) {
  1136. this._cellAlertManagerService.removeAlert(Ee);
  1137. return;
  1138. }
  1139. const s = this._dataValidationModel.getValidator(a.type);
  1140. if (!s) {
  1141. this._cellAlertManagerService.removeAlert(Ee);
  1142. return;
  1143. }
  1144. this._cellAlertManagerService.showAlert({
  1145. type: Oa.ERROR,
  1146. title: this._localeService.t("dataValidation.error.title"),
  1147. message: s == null ? void 0 : s.getRuleFinalError(a, e.location),
  1148. location: e.location,
  1149. width: 200,
  1150. height: 74,
  1151. key: Ee
  1152. });
  1153. return;
  1154. }
  1155. }
  1156. this._cellAlertManagerService.removeAlert(Ee);
  1157. }));
  1158. }
  1159. _initZenService() {
  1160. this.disposeWithMe(this._zenZoneService.visible$.subscribe((e) => {
  1161. e && this._cellAlertManagerService.removeAlert(Ee);
  1162. }));
  1163. }
  1164. };
  1165. lt = tr([
  1166. $e(0, b(ba)),
  1167. $e(1, b(Ea)),
  1168. $e(2, ge),
  1169. $e(3, b(J)),
  1170. $e(4, go),
  1171. $e(5, b(oe))
  1172. ], lt);
  1173. var nr = Object.defineProperty, or = Object.getOwnPropertyDescriptor, ar = (e, t, o, n) => {
  1174. for (var a = n > 1 ? void 0 : n ? or(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  1175. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  1176. return n && a && nr(t, o, a), a;
  1177. }, Bt = (e, t) => (o, n) => t(o, n, e);
  1178. let ze = class extends De {
  1179. constructor(e, t, o) {
  1180. super(), this._autoFillService = e, this._sheetDataValidationModel = t, this._injector = o, this._initAutoFill();
  1181. }
  1182. // eslint-disable-next-line max-lines-per-function
  1183. _initAutoFill() {
  1184. const e = () => ({ redos: [], undos: [] }), t = (n, a) => {
  1185. const { source: i, target: r, unitId: l, subUnitId: s } = n, c = this._sheetDataValidationModel.getRuleObjectMatrix(l, s).clone(), u = rn([i, r]), [p, d] = u.ranges, { mapFunc: g } = u, f = {
  1186. row: p.startRow,
  1187. col: p.startColumn
  1188. }, C = Pa(p, d), R = new _t(), v = /* @__PURE__ */ new Set();
  1189. C.forEach((S) => {
  1190. const m = S.repeatStartCell, y = S.relativeRange, P = {
  1191. startRow: f.row,
  1192. startColumn: f.col,
  1193. endColumn: f.col,
  1194. endRow: f.row
  1195. }, F = {
  1196. startRow: m.row,
  1197. startColumn: m.col,
  1198. endColumn: m.col,
  1199. endRow: m.row
  1200. };
  1201. Qo.foreach(y, (T, E) => {
  1202. const A = St.getPositionRange(
  1203. {
  1204. startRow: T,
  1205. startColumn: E,
  1206. endColumn: E,
  1207. endRow: T
  1208. },
  1209. P
  1210. ), { row: x, col: j } = g(A.startRow, A.startColumn), N = this._sheetDataValidationModel.getRuleIdByLocation(l, s, x, j) || "", H = St.getPositionRange(
  1211. {
  1212. startRow: T,
  1213. startColumn: E,
  1214. endColumn: E,
  1215. endRow: T
  1216. },
  1217. F
  1218. ), { row: X, col: k } = g(H.startRow, H.startColumn);
  1219. R.setValue(X, k, N), v.add(N);
  1220. });
  1221. });
  1222. const w = Array.from(v).map((S) => ({ id: S, ranges: Qt(R, (m) => m === S) }));
  1223. c.addRangeRules(w);
  1224. const I = c.diff(this._sheetDataValidationModel.getRules(l, s)), { redoMutations: V, undoMutations: _ } = an(l, s, I, this._injector, "patched", a === tt.ONLY_FORMAT);
  1225. return {
  1226. undos: _,
  1227. redos: V
  1228. };
  1229. }, o = {
  1230. id: co,
  1231. onBeforeFillData: (n) => {
  1232. const { source: a, unitId: i, subUnitId: r } = n;
  1233. for (const l of a.rows)
  1234. for (const s of a.cols) {
  1235. const c = this._sheetDataValidationModel.getRuleByLocation(i, r, l, s);
  1236. if (c && c.type === z.CHECKBOX) {
  1237. this._autoFillService.setDisableApplyType(tt.SERIES, !0);
  1238. return;
  1239. }
  1240. }
  1241. },
  1242. onFillData: (n, a, i) => i === tt.COPY || i === tt.ONLY_FORMAT || i === tt.SERIES ? t(n, i) : e(),
  1243. onAfterFillData: () => {
  1244. }
  1245. };
  1246. this.disposeWithMe(this._autoFillService.addHook(o));
  1247. }
  1248. };
  1249. ze = ar([
  1250. Bt(0, La),
  1251. Bt(1, b(oe)),
  1252. Bt(2, b(Fe))
  1253. ], ze);
  1254. var ir = Object.defineProperty, rr = Object.getOwnPropertyDescriptor, sr = (e, t, o, n) => {
  1255. for (var a = n > 1 ? void 0 : n ? rr(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  1256. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  1257. return n && a && ir(t, o, a), a;
  1258. }, $t = (e, t) => (o, n) => t(o, n, e);
  1259. let Ke = class extends De {
  1260. constructor(t, o, n) {
  1261. super();
  1262. M(this, "_copyInfo");
  1263. this._sheetClipboardService = t, this._sheetDataValidationModel = o, this._injector = n, this._initCopyPaste();
  1264. }
  1265. _initCopyPaste() {
  1266. this._sheetClipboardService.addClipboardHook({
  1267. id: co,
  1268. onBeforeCopy: (t, o, n) => this._collect(t, o, n),
  1269. onPasteCells: (t, o, n, a) => {
  1270. const { copyType: i = Pn.COPY, pasteType: r } = a, { range: l } = t || {}, { range: s, unitId: c, subUnitId: u } = o;
  1271. return this._generateMutations(s, { copyType: i, pasteType: r, copyRange: l, unitId: c, subUnitId: u });
  1272. }
  1273. });
  1274. }
  1275. _collect(t, o, n) {
  1276. const a = new _t();
  1277. this._copyInfo = {
  1278. unitId: t,
  1279. subUnitId: o,
  1280. matrix: a
  1281. };
  1282. const i = this._injector.invoke((s) => Ta(n, s, t, o));
  1283. if (!i)
  1284. return;
  1285. const { rows: r, cols: l } = i;
  1286. r.forEach((s, c) => {
  1287. l.forEach((u, p) => {
  1288. const d = this._sheetDataValidationModel.getRuleIdByLocation(t, o, s, u);
  1289. a.setValue(c, p, d != null ? d : "");
  1290. });
  1291. });
  1292. }
  1293. // eslint-disable-next-line max-lines-per-function
  1294. _generateMutations(t, o) {
  1295. if (!this._copyInfo)
  1296. return { redos: [], undos: [] };
  1297. if (o.copyType === Pn.CUT)
  1298. return this._copyInfo = null, { redos: [], undos: [] };
  1299. if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !o.copyRange)
  1300. return { redos: [], undos: [] };
  1301. if ([
  1302. dt.SPECIAL_PASTE_COL_WIDTH,
  1303. dt.SPECIAL_PASTE_VALUE,
  1304. dt.SPECIAL_PASTE_FORMAT,
  1305. dt.SPECIAL_PASTE_FORMULA
  1306. ].includes(o.pasteType))
  1307. return { redos: [], undos: [] };
  1308. const { unitId: a, subUnitId: i } = this._copyInfo;
  1309. if (o.unitId !== a || i !== o.subUnitId) {
  1310. const r = this._sheetDataValidationModel.getRuleObjectMatrix(o.unitId, o.subUnitId).clone(), l = new _t(), s = /* @__PURE__ */ new Set(), { ranges: [c, u], mapFunc: p } = rn([o.copyRange, t]), d = Tn(c, u, !0), g = /* @__PURE__ */ new Map();
  1311. d.forEach(({ startRange: v }) => {
  1312. var w;
  1313. (w = this._copyInfo) == null || w.matrix.forValue((I, V, _) => {
  1314. const S = St.getPositionRange(
  1315. {
  1316. startRow: I,
  1317. endRow: I,
  1318. startColumn: V,
  1319. endColumn: V
  1320. },
  1321. v
  1322. ), m = `${i}-${_}`, y = this._sheetDataValidationModel.getRuleById(a, i, _);
  1323. !this._sheetDataValidationModel.getRuleById(o.unitId, o.subUnitId, m) && y && g.set(m, { ...y, uid: m });
  1324. const { row: P, col: F } = p(S.startRow, S.startColumn);
  1325. s.add(m), l.setValue(P, F, m);
  1326. });
  1327. });
  1328. const f = Array.from(s).map((v) => ({ id: v, ranges: Qt(l, (w) => w === v) }));
  1329. r.addRangeRules(f);
  1330. const { redoMutations: C, undoMutations: R } = an(
  1331. o.unitId,
  1332. o.subUnitId,
  1333. r.diffWithAddition(this._sheetDataValidationModel.getRules(o.unitId, o.subUnitId), g.values()),
  1334. this._injector,
  1335. "patched",
  1336. !1
  1337. );
  1338. return {
  1339. redos: C,
  1340. undos: R
  1341. };
  1342. } else {
  1343. const r = this._sheetDataValidationModel.getRuleObjectMatrix(a, i).clone(), l = new _t(), s = /* @__PURE__ */ new Set(), { ranges: [c, u], mapFunc: p } = rn([o.copyRange, t]);
  1344. Tn(c, u, !0).forEach(({ startRange: R }) => {
  1345. var v;
  1346. (v = this._copyInfo) == null || v.matrix.forValue((w, I, V) => {
  1347. const _ = St.getPositionRange(
  1348. {
  1349. startRow: w,
  1350. endRow: w,
  1351. startColumn: I,
  1352. endColumn: I
  1353. },
  1354. R
  1355. ), { row: S, col: m } = p(_.startRow, _.startColumn);
  1356. l.setValue(S, m, V), s.add(V);
  1357. });
  1358. });
  1359. const g = Array.from(s).map((R) => ({ id: R, ranges: Qt(l, (v) => v === R) }));
  1360. r.addRangeRules(g);
  1361. const { redoMutations: f, undoMutations: C } = an(
  1362. a,
  1363. i,
  1364. r.diff(this._sheetDataValidationModel.getRules(a, i)),
  1365. this._injector,
  1366. "patched",
  1367. !1
  1368. );
  1369. return {
  1370. redos: f,
  1371. undos: C
  1372. };
  1373. }
  1374. }
  1375. };
  1376. Ke = sr([
  1377. $t(0, Aa),
  1378. $t(1, b(oe)),
  1379. $t(2, b(Fe))
  1380. ], Ke);
  1381. var lr = Object.defineProperty, dr = Object.getOwnPropertyDescriptor, cr = (e, t, o, n) => {
  1382. for (var a = n > 1 ? void 0 : n ? dr(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  1383. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  1384. return n && a && lr(t, o, a), a;
  1385. }, kt = (e, t) => (o, n) => t(o, n, e);
  1386. let Ge = class extends De {
  1387. constructor(e, t, o) {
  1388. super(), this._localeService = e, this._commandService = t, this._sheetPermissionCheckController = o, this._commandExecutedListener();
  1389. }
  1390. _commandExecutedListener() {
  1391. this.disposeWithMe(
  1392. this._commandService.beforeCommandExecuted((e) => {
  1393. e.id === _n.id && (this._sheetPermissionCheckController.permissionCheckWithRanges({
  1394. workbookTypes: [Ct],
  1395. rangeTypes: [It],
  1396. worksheetTypes: [wt, on]
  1397. }) || this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))), e.id === ro.id && (this._sheetPermissionCheckController.permissionCheckWithRanges({
  1398. workbookTypes: [Ct],
  1399. rangeTypes: [It],
  1400. worksheetTypes: [wt, on]
  1401. }, e.params.ranges) || this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")));
  1402. })
  1403. );
  1404. }
  1405. };
  1406. Ge = cr([
  1407. kt(0, b(J)),
  1408. kt(1, Q),
  1409. kt(2, b(to))
  1410. ], Ge);
  1411. const Lo = "data-validation-single", Po = "sheet.menu.data-validation";
  1412. function ur(e) {
  1413. return {
  1414. id: Po,
  1415. type: Cn.SUBITEMS,
  1416. icon: Lo,
  1417. tooltip: "dataValidation.title",
  1418. hidden$: Na(e, Y.UNIVER_SHEET),
  1419. disabled$: xa(e, { workbookTypes: [Ct], worksheetTypes: [on, wt], rangeTypes: [It] })
  1420. };
  1421. }
  1422. function hr(e) {
  1423. return {
  1424. id: Ue.id,
  1425. title: "dataValidation.panel.title",
  1426. type: Cn.BUTTON
  1427. };
  1428. }
  1429. function pr(e) {
  1430. return {
  1431. id: At.id,
  1432. title: "dataValidation.panel.add",
  1433. type: Cn.BUTTON
  1434. };
  1435. }
  1436. const fr = {
  1437. [Ua.FORMULAS_INSERT]: {
  1438. [Po]: {
  1439. order: 9,
  1440. menuItemFactory: ur,
  1441. [Ue.id]: {
  1442. order: 0,
  1443. menuItemFactory: hr
  1444. },
  1445. [At.id]: {
  1446. order: 1,
  1447. menuItemFactory: pr
  1448. }
  1449. }
  1450. }
  1451. };
  1452. var mr = Object.defineProperty, gr = Object.getOwnPropertyDescriptor, To = (e, t, o, n) => {
  1453. for (var a = n > 1 ? void 0 : n ? gr(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  1454. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  1455. return n && a && mr(t, o, a), a;
  1456. }, G = (e, t) => (o, n) => t(o, n, e);
  1457. const Ao = {
  1458. tr: {
  1459. size: 6,
  1460. color: "#fe4b4b"
  1461. }
  1462. };
  1463. let Ze = class extends fn {
  1464. constructor(e, t, o, n, a, i, r, l, s, c, u) {
  1465. super(), this._commandService = e, this._menuManagerService = t, this._renderManagerService = o, this._univerInstanceService = n, this._autoHeightController = a, this._dropdownManagerService = i, this._sheetDataValidationModel = r, this._dataValidatorRegistryService = l, this._sheetInterceptorService = s, this._dataValidationCacheService = c, this._editorBridgeService = u, this._initMenu(), this._initDropdown(), this._initViewModelIntercept(), this._initAutoHeight();
  1466. }
  1467. _initMenu() {
  1468. this._menuManagerService.mergeMenu(fr);
  1469. }
  1470. _initDropdown() {
  1471. this._editorBridgeService && this.disposeWithMe(this._editorBridgeService.visible$.subscribe((e) => {
  1472. var o;
  1473. if (!e.visible) {
  1474. ((o = this._dropdownManagerService.activeDropdown) == null ? void 0 : o.trigger) === "editor-bridge" && this._dropdownManagerService.hideDropdown();
  1475. return;
  1476. }
  1477. const t = this._editorBridgeService.getEditCellState();
  1478. if (t) {
  1479. const { unitId: n, sheetId: a, row: i, column: r } = t, l = this._univerInstanceService.getUniverSheetInstance(n);
  1480. if (!l)
  1481. return;
  1482. const s = this._sheetDataValidationModel.getRuleByLocation(n, a, i, r);
  1483. if (!s)
  1484. return;
  1485. const c = this._dataValidatorRegistryService.getValidatorItem(s.type);
  1486. if (!(c != null && c.dropdown))
  1487. return;
  1488. const u = l.getActiveSheet();
  1489. if (!u) return;
  1490. const p = this._dropdownManagerService.activeDropdown, d = p == null ? void 0 : p.location;
  1491. if (d && d.unitId === n && d.subUnitId === a && d.row === i && d.col === r)
  1492. return;
  1493. this._dropdownManagerService.showDropdown(
  1494. {
  1495. location: {
  1496. unitId: n,
  1497. subUnitId: a,
  1498. row: i,
  1499. col: r,
  1500. workbook: l,
  1501. worksheet: u
  1502. },
  1503. componentKey: c.dropdown,
  1504. onHide: () => {
  1505. },
  1506. trigger: "editor-bridge"
  1507. },
  1508. !1
  1509. );
  1510. }
  1511. }));
  1512. }
  1513. // eslint-disable-next-line max-lines-per-function
  1514. _initViewModelIntercept() {
  1515. this.disposeWithMe(
  1516. this._sheetInterceptorService.intercept(
  1517. no.CELL_CONTENT,
  1518. {
  1519. effect: Kn.Style,
  1520. // must be after numfmt
  1521. priority: oo.DATA_VALIDATION,
  1522. // eslint-disable-next-line max-lines-per-function, complexity
  1523. handler: (e, t, o) => {
  1524. var v, w, I, V, _;
  1525. const { row: n, col: a, unitId: i, subUnitId: r, workbook: l, worksheet: s } = t, c = this._sheetDataValidationModel.getRuleIdByLocation(i, r, n, a);
  1526. if (!c)
  1527. return o(e);
  1528. const u = this._sheetDataValidationModel.getRuleById(i, r, c);
  1529. if (!u)
  1530. return o(e);
  1531. const p = (v = this._dataValidationCacheService.getValue(i, r, n, a)) != null ? v : rt.VALID, d = this._dataValidatorRegistryService.getValidatorItem(u.type), g = t.rawData;
  1532. let f;
  1533. const C = {
  1534. get value() {
  1535. var S;
  1536. return f !== void 0 || (f = (S = ie(g)) != null ? S : null), f;
  1537. }
  1538. }, R = {
  1539. get value() {
  1540. var S;
  1541. return `${(S = C.value) != null ? S : ""}`;
  1542. }
  1543. };
  1544. return o({
  1545. ...e,
  1546. markers: {
  1547. ...e == null ? void 0 : e.markers,
  1548. ...p === rt.INVALID ? Ao : null
  1549. },
  1550. customRender: [
  1551. ...(w = e == null ? void 0 : e.customRender) != null ? w : [],
  1552. ...d != null && d.canvasRender ? [d.canvasRender] : []
  1553. ],
  1554. fontRenderExtension: {
  1555. ...e == null ? void 0 : e.fontRenderExtension,
  1556. isSkip: ((I = e == null ? void 0 : e.fontRenderExtension) == null ? void 0 : I.isSkip) || ((V = d == null ? void 0 : d.skipDefaultFontRender) == null ? void 0 : V.call(d, u, C.value, t))
  1557. },
  1558. interceptorStyle: {
  1559. ...e == null ? void 0 : e.interceptorStyle,
  1560. ...d == null ? void 0 : d.getExtraStyle(u, R.value, {
  1561. get style() {
  1562. const S = l.getStyles();
  1563. return (typeof (e == null ? void 0 : e.s) == "string" ? S.get(e == null ? void 0 : e.s) : e == null ? void 0 : e.s) || {};
  1564. }
  1565. }, n, a)
  1566. },
  1567. interceptorAutoHeight: () => {
  1568. var P, F, T, E, A, x;
  1569. const S = (F = (P = this._renderManagerService.getRenderById(i)) == null ? void 0 : P.with(Rt).getWorksheetSkeleton(r)) == null ? void 0 : F.skeleton;
  1570. if (!S)
  1571. return;
  1572. const m = S.worksheet.getMergedCell(n, a), y = {
  1573. data: e,
  1574. style: S.getsStyles().getStyleByCell(e),
  1575. primaryWithCoord: S.getCellWithCoordByIndex((T = m == null ? void 0 : m.startRow) != null ? T : n, (E = m == null ? void 0 : m.startColumn) != null ? E : a),
  1576. unitId: i,
  1577. subUnitId: r,
  1578. row: n,
  1579. col: a,
  1580. workbook: l,
  1581. worksheet: s
  1582. };
  1583. return (x = (A = d == null ? void 0 : d.canvasRender) == null ? void 0 : A.calcCellAutoHeight) == null ? void 0 : x.call(A, y);
  1584. },
  1585. interceptorAutoWidth: () => {
  1586. var P, F, T, E, A, x;
  1587. const S = (F = (P = this._renderManagerService.getRenderById(i)) == null ? void 0 : P.with(Rt).getWorksheetSkeleton(r)) == null ? void 0 : F.skeleton;
  1588. if (!S)
  1589. return;
  1590. const m = S.worksheet.getMergedCell(n, a), y = {
  1591. data: e,
  1592. style: S.getsStyles().getStyleByCell(e),
  1593. primaryWithCoord: S.getCellWithCoordByIndex((T = m == null ? void 0 : m.startRow) != null ? T : n, (E = m == null ? void 0 : m.startColumn) != null ? E : a),
  1594. unitId: i,
  1595. subUnitId: r,
  1596. row: n,
  1597. col: a,
  1598. workbook: l,
  1599. worksheet: s
  1600. };
  1601. return (x = (A = d == null ? void 0 : d.canvasRender) == null ? void 0 : A.calcCellAutoWidth) == null ? void 0 : x.call(A, y);
  1602. },
  1603. coverable: ((_ = e == null ? void 0 : e.coverable) != null ? _ : !0) && !(u.type === z.LIST || u.type === z.LIST_MULTIPLE)
  1604. });
  1605. }
  1606. }
  1607. )
  1608. );
  1609. }
  1610. _initAutoHeight() {
  1611. this._sheetDataValidationModel.ruleChange$.pipe(
  1612. // patched data-validation change don't need to re-calc row height
  1613. // re-calc of row height will be triggered precisely by the origin command
  1614. In((e) => e.source === "command"),
  1615. vo(100)
  1616. ).subscribe((e) => {
  1617. if (e.length === 0)
  1618. return;
  1619. const t = [];
  1620. if (e.forEach((o) => {
  1621. var n;
  1622. (o.rule.type === z.LIST_MULTIPLE || o.rule.type === z.LIST) && (n = o.rule) != null && n.ranges && t.push(...o.rule.ranges);
  1623. }), t.length) {
  1624. const o = this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);
  1625. Gn(o.redos, this._commandService);
  1626. }
  1627. });
  1628. }
  1629. };
  1630. Ze = To([
  1631. G(0, Q),
  1632. G(1, Ba),
  1633. G(2, Ve),
  1634. G(3, ge),
  1635. G(4, b(fo)),
  1636. G(5, b(Ie)),
  1637. G(6, b(oe)),
  1638. G(7, b(ye)),
  1639. G(8, b(gn)),
  1640. G(9, b(uo)),
  1641. G(10, ea(po))
  1642. ], Ze);
  1643. let $n = class extends fn {
  1644. constructor(e, t, o, n, a, i, r) {
  1645. super(), this._commandService = e, this._renderManagerService = t, this._autoHeightController = o, this._dataValidatorRegistryService = n, this._sheetInterceptorService = a, this._sheetDataValidationModel = i, this._dataValidationCacheService = r, this._initViewModelIntercept(), this._initAutoHeight();
  1646. }
  1647. _initViewModelIntercept() {
  1648. this.disposeWithMe(
  1649. this._sheetInterceptorService.intercept(
  1650. no.CELL_CONTENT,
  1651. {
  1652. effect: Kn.Style,
  1653. // must be after numfmt
  1654. priority: oo.DATA_VALIDATION,
  1655. // eslint-disable-next-line complexity
  1656. handler: (e, t, o) => {
  1657. var R, v, w, I, V;
  1658. const { row: n, col: a, unitId: i, subUnitId: r, workbook: l, worksheet: s } = t, c = this._sheetDataValidationModel.getRuleIdByLocation(i, r, n, a);
  1659. if (!c)
  1660. return o(e);
  1661. const u = this._sheetDataValidationModel.getRuleById(i, r, c);
  1662. if (!u)
  1663. return o(e);
  1664. const p = (R = this._dataValidationCacheService.getValue(i, r, n, a)) != null ? R : rt.VALID, d = this._dataValidatorRegistryService.getValidatorItem(u.type), g = s.getCellRaw(n, a), f = ie(g), C = `${f != null ? f : ""}`;
  1665. return o({
  1666. ...e,
  1667. markers: {
  1668. ...e == null ? void 0 : e.markers,
  1669. ...p === rt.INVALID ? Ao : null
  1670. },
  1671. customRender: [
  1672. ...(v = e == null ? void 0 : e.customRender) != null ? v : [],
  1673. ...d != null && d.canvasRender ? [d.canvasRender] : []
  1674. ],
  1675. fontRenderExtension: {
  1676. ...e == null ? void 0 : e.fontRenderExtension,
  1677. isSkip: ((w = e == null ? void 0 : e.fontRenderExtension) == null ? void 0 : w.isSkip) || ((I = d == null ? void 0 : d.skipDefaultFontRender) == null ? void 0 : I.call(d, u, f, t))
  1678. },
  1679. interceptorStyle: {
  1680. ...e == null ? void 0 : e.interceptorStyle,
  1681. ...d == null ? void 0 : d.getExtraStyle(u, C, {
  1682. get style() {
  1683. const _ = l.getStyles();
  1684. return (typeof (e == null ? void 0 : e.s) == "string" ? _.get(e == null ? void 0 : e.s) : e == null ? void 0 : e.s) || {};
  1685. }
  1686. }, n, a)
  1687. },
  1688. interceptorAutoHeight: () => {
  1689. var y, P, F, T, E, A;
  1690. const _ = (P = (y = this._renderManagerService.getRenderById(i)) == null ? void 0 : y.with(Rt).getWorksheetSkeleton(r)) == null ? void 0 : P.skeleton;
  1691. if (!_)
  1692. return;
  1693. const S = _.worksheet.getMergedCell(n, a), m = {
  1694. data: e,
  1695. style: _.getsStyles().getStyleByCell(e),
  1696. primaryWithCoord: _.getCellWithCoordByIndex((F = S == null ? void 0 : S.startRow) != null ? F : n, (T = S == null ? void 0 : S.startColumn) != null ? T : a),
  1697. unitId: i,
  1698. subUnitId: r,
  1699. row: n,
  1700. col: a,
  1701. workbook: l,
  1702. worksheet: s
  1703. };
  1704. return (A = (E = d == null ? void 0 : d.canvasRender) == null ? void 0 : E.calcCellAutoHeight) == null ? void 0 : A.call(E, m);
  1705. },
  1706. coverable: ((V = e == null ? void 0 : e.coverable) != null ? V : !0) && !(u.type === z.LIST || u.type === z.LIST_MULTIPLE)
  1707. });
  1708. }
  1709. }
  1710. )
  1711. );
  1712. }
  1713. _initAutoHeight() {
  1714. this._sheetDataValidationModel.ruleChange$.pipe(
  1715. In((e) => e.source === "command"),
  1716. vo(16)
  1717. ).subscribe((e) => {
  1718. const t = [];
  1719. if (e.forEach((o) => {
  1720. var n;
  1721. (n = o.rule) != null && n.ranges && t.push(...o.rule.ranges);
  1722. }), t.length) {
  1723. const o = this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);
  1724. Gn(o.redos, this._commandService);
  1725. }
  1726. });
  1727. }
  1728. };
  1729. $n = To([
  1730. G(0, Q),
  1731. G(1, Ve),
  1732. G(2, b(fo)),
  1733. G(3, b(ye)),
  1734. G(4, b(gn)),
  1735. G(5, b(oe)),
  1736. G(6, b(uo))
  1737. ], $n);
  1738. var vr = Object.defineProperty, _r = Object.getOwnPropertyDescriptor, Sr = (e, t, o, n) => {
  1739. for (var a = n > 1 ? void 0 : n ? _r(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  1740. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  1741. return n && a && vr(t, o, a), a;
  1742. }, kn = (e, t) => (o, n) => t(o, n, e);
  1743. let yt = class extends De {
  1744. constructor(e, t, o) {
  1745. super(), this._context = e, this._sheetDataValidationModel = t, this._sheetSkeletonManagerService = o, this._initSkeletonChange();
  1746. }
  1747. _initSkeletonChange() {
  1748. const e = (t) => {
  1749. var n;
  1750. if (!t.length)
  1751. return;
  1752. const o = /* @__PURE__ */ new Set();
  1753. t.forEach((a) => {
  1754. o.add(a.subUnitId);
  1755. }), o.forEach((a) => {
  1756. var i;
  1757. (i = this._sheetSkeletonManagerService.getWorksheetSkeleton(a)) == null || i.skeleton.makeDirty(!0);
  1758. }), (n = this._context.mainComponent) == null || n.makeForceDirty();
  1759. };
  1760. this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(ta(16)).subscribe(e));
  1761. }
  1762. };
  1763. yt = Sr([
  1764. kn(1, b(oe)),
  1765. kn(2, b(Rt))
  1766. ], yt);
  1767. const Cr = "univer-data-validation-formula", Ir = "univer-data-validation-formula-and", wr = "univer-data-validation-formula-list-item", Rr = "univer-data-validation-formula-list-item-icon", Dr = "univer-data-validation-formula-list-item-drag", Vr = "univer-data-validation-formula-list-add", yr = "univer-data-validation-formula-color-select", Mr = "univer-data-validation-formula-color-select-panel", br = "univer-data-validation-formula-color-item", ne = {
  1768. dataValidationFormula: Cr,
  1769. dataValidationFormulaAnd: Ir,
  1770. dataValidationFormulaListItem: wr,
  1771. dataValidationFormulaListItemIcon: Rr,
  1772. dataValidationFormulaListItemDrag: Dr,
  1773. dataValidationFormulaListAdd: Vr,
  1774. dataValidationFormulaColorSelect: yr,
  1775. dataValidationFormulaColorSelectPanel: Mr,
  1776. dataValidationFormulaColorItem: br
  1777. }, Er = (e) => {
  1778. const { isTwoFormula: t = !1, value: o, onChange: n, showError: a, validResult: i } = e, r = L(J), l = a ? i == null ? void 0 : i.formula1 : "", s = a ? i == null ? void 0 : i.formula2 : "";
  1779. return t ? /* @__PURE__ */ h.jsxs(h.Fragment, { children: [
  1780. /* @__PURE__ */ h.jsx(Z, { error: l, children: /* @__PURE__ */ h.jsx(
  1781. xe,
  1782. {
  1783. className: ne.dataValidationFormula,
  1784. placeholder: r.t("dataValidation.panel.formulaPlaceholder"),
  1785. value: o == null ? void 0 : o.formula1,
  1786. onChange: (c) => {
  1787. n == null || n({
  1788. ...o,
  1789. formula1: c
  1790. });
  1791. }
  1792. }
  1793. ) }),
  1794. /* @__PURE__ */ h.jsx("div", { className: ne.dataValidationFormulaAnd, children: r.t("dataValidation.panel.formulaAnd") }),
  1795. /* @__PURE__ */ h.jsx(Z, { error: s, children: /* @__PURE__ */ h.jsx(
  1796. xe,
  1797. {
  1798. className: ne.dataValidationFormula,
  1799. placeholder: r.t("dataValidation.panel.formulaPlaceholder"),
  1800. value: o == null ? void 0 : o.formula2,
  1801. onChange: (c) => {
  1802. n == null || n({
  1803. ...o,
  1804. formula2: c
  1805. });
  1806. }
  1807. }
  1808. ) })
  1809. ] }) : /* @__PURE__ */ h.jsx(Z, { error: l, children: /* @__PURE__ */ h.jsx(
  1810. xe,
  1811. {
  1812. className: ne.dataValidationFormula,
  1813. placeholder: r.t("dataValidation.panel.formulaPlaceholder"),
  1814. value: o == null ? void 0 : o.formula1,
  1815. onChange: (c) => {
  1816. n == null || n({ formula1: c });
  1817. }
  1818. }
  1819. ) });
  1820. };
  1821. function Or(e) {
  1822. const { value: t, onChange: o, showError: n, validResult: a } = e, i = L(J), r = n ? a == null ? void 0 : a.formula1 : "", l = n ? a == null ? void 0 : a.formula2 : "", [s, c] = W(!((t == null ? void 0 : t.formula1) === void 0 && (t == null ? void 0 : t.formula2) === void 0));
  1823. return /* @__PURE__ */ h.jsxs(h.Fragment, { children: [
  1824. /* @__PURE__ */ h.jsx(Z, { children: /* @__PURE__ */ h.jsx(
  1825. Ot,
  1826. {
  1827. checked: s,
  1828. onChange: (u) => {
  1829. u ? c(!0) : (c(!1), o == null || o({
  1830. ...t,
  1831. formula1: void 0,
  1832. formula2: void 0
  1833. }));
  1834. },
  1835. children: i.t("dataValidation.checkbox.tips")
  1836. }
  1837. ) }),
  1838. s ? /* @__PURE__ */ h.jsx(Z, { label: i.t("dataValidation.checkbox.checked"), error: r, children: /* @__PURE__ */ h.jsx(
  1839. xe,
  1840. {
  1841. className: ne.dataValidationFormula,
  1842. placeholder: i.t("dataValidation.panel.valuePlaceholder"),
  1843. value: t == null ? void 0 : t.formula1,
  1844. onChange: (u) => {
  1845. o == null || o({
  1846. ...t,
  1847. formula1: u || void 0
  1848. });
  1849. }
  1850. }
  1851. ) }) : null,
  1852. s ? /* @__PURE__ */ h.jsx(Z, { label: i.t("dataValidation.checkbox.unchecked"), error: l, children: /* @__PURE__ */ h.jsx(
  1853. xe,
  1854. {
  1855. className: ne.dataValidationFormula,
  1856. placeholder: i.t("dataValidation.panel.valuePlaceholder"),
  1857. value: t == null ? void 0 : t.formula2,
  1858. onChange: (u) => {
  1859. o == null || o({
  1860. ...t,
  1861. formula2: u || void 0
  1862. });
  1863. }
  1864. }
  1865. ) }) : null
  1866. ] });
  1867. }
  1868. function Lr(e) {
  1869. var p;
  1870. const { unitId: t, subUnitId: o, value: n, onChange: a, showError: i, validResult: r } = e, l = i ? r == null ? void 0 : r.formula1 : void 0, s = We({}), [c, u] = W(!1);
  1871. return Sn((d) => {
  1872. var f;
  1873. const g = (f = s.current) == null ? void 0 : f.handleOutClick;
  1874. g && g(d, () => u(!1));
  1875. }), /* @__PURE__ */ h.jsx(
  1876. So,
  1877. {
  1878. initValue: (p = n == null ? void 0 : n.formula1) != null ? p : "=",
  1879. unitId: t,
  1880. subUnitId: o,
  1881. isFocus: c,
  1882. onChange: (d) => {
  1883. const g = (d != null ? d : "").trim();
  1884. g !== (n == null ? void 0 : n.formula1) && (a == null || a({
  1885. ...n,
  1886. formula1: g
  1887. }));
  1888. },
  1889. errorText: l,
  1890. onFocus: () => u(!0),
  1891. actions: s.current,
  1892. isSupportAcrossSheet: !0
  1893. }
  1894. );
  1895. }
  1896. function xo(e) {
  1897. var t, o, n = "";
  1898. if (typeof e == "string" || typeof e == "number") n += e;
  1899. else if (typeof e == "object") if (Array.isArray(e)) {
  1900. var a = e.length;
  1901. for (t = 0; t < a; t++) e[t] && (o = xo(e[t])) && (n && (n += " "), n += o);
  1902. } else for (o in e) e[o] && (n && (n += " "), n += o);
  1903. return n;
  1904. }
  1905. function Pr() {
  1906. for (var e, t, o = 0, n = "", a = arguments.length; o < a; o++) (e = arguments[o]) && (t = xo(e)) && (n && (n += " "), n += t);
  1907. return n;
  1908. }
  1909. const Tr = [
  1910. "#FFFFFF",
  1911. "#FEE7E7",
  1912. "#FEF0E6",
  1913. "#EFFBD0",
  1914. "#E4F4FE",
  1915. "#E8ECFD",
  1916. "#F1EAFA",
  1917. "#FDE8F3",
  1918. "#E5E5E5",
  1919. "#FDCECE",
  1920. "#FDC49B",
  1921. "#DEF6A2",
  1922. "#9FDAFF",
  1923. "#D0D9FB",
  1924. "#E3D5F6",
  1925. "#FBD0E8",
  1926. "#656565",
  1927. "#FE4B4B",
  1928. "#FF8C51",
  1929. "#8BBB11",
  1930. "#0B9EFB",
  1931. "#3A60F7",
  1932. "#9E6DE3",
  1933. "#F248A6"
  1934. ], Ar = (e) => {
  1935. const { value: t, onChange: o, disabled: n } = e, [a, i] = W(!1);
  1936. return /* @__PURE__ */ h.jsx(
  1937. tn,
  1938. {
  1939. disabled: n,
  1940. open: a,
  1941. onDropdownVisibleChange: i,
  1942. dropdownStyle: { width: 112 },
  1943. style: { width: 96, cursor: "pointer" },
  1944. className: ne.dataValidationFormulaColorSelect,
  1945. value: t,
  1946. onChange: o,
  1947. labelRender: (r) => /* @__PURE__ */ h.jsx(
  1948. "div",
  1949. {
  1950. className: ne.dataValidationFormulaColorItem,
  1951. style: { background: r.value, marginTop: 5 }
  1952. }
  1953. ),
  1954. dropdownRender: () => /* @__PURE__ */ h.jsx("div", { className: ne.dataValidationFormulaColorSelectPanel, children: Tr.map(
  1955. (r) => /* @__PURE__ */ h.jsx(
  1956. "div",
  1957. {
  1958. onClick: () => {
  1959. o(r), i(!1);
  1960. },
  1961. className: ne.dataValidationFormulaColorItem,
  1962. style: { background: r }
  1963. },
  1964. r
  1965. )
  1966. ) })
  1967. }
  1968. );
  1969. }, Wn = (e) => {
  1970. const { item: t, commonProps: o, style: n } = e, { onItemChange: a, onItemDelete: i } = o;
  1971. return /* @__PURE__ */ h.jsxs("div", { className: ne.dataValidationFormulaListItem, style: n, children: [
  1972. t.isRef ? null : /* @__PURE__ */ h.jsx("div", { className: Pr(ne.dataValidationFormulaListItemDrag, "draggableHandle"), children: /* @__PURE__ */ h.jsx(yo, {}) }),
  1973. /* @__PURE__ */ h.jsx(
  1974. Ar,
  1975. {
  1976. value: t.color,
  1977. onChange: (r) => {
  1978. a(t.id, t.label, r);
  1979. }
  1980. }
  1981. ),
  1982. /* @__PURE__ */ h.jsx(
  1983. xe,
  1984. {
  1985. disabled: t.isRef,
  1986. value: t.label,
  1987. onChange: (r) => {
  1988. a(t.id, r, t.color);
  1989. }
  1990. }
  1991. ),
  1992. t.isRef ? null : /* @__PURE__ */ h.jsx("div", { className: ne.dataValidationFormulaListItemIcon, children: /* @__PURE__ */ h.jsx(Rn, { onClick: () => i(t.id) }) })
  1993. ] });
  1994. };
  1995. function xr(e) {
  1996. const { value: t, onChange: o = () => {
  1997. }, unitId: n, subUnitId: a, validResult: i, showError: r, ruleId: l } = e, { formula1: s = "", formula2: c = "" } = t || {}, u = We(null), [p, d] = W(() => Pe(s) ? "1" : "0"), [g, f] = W(p === "1" ? s : "="), [C, R] = W(p === "1" ? s : "="), v = L(J), w = L(ye), I = L(Pt), V = L(Ca), [_, S] = W(() => c.split(",")), m = w.getValidatorItem(z.LIST), [y, P] = W([]), [F, T] = W(""), E = r ? i == null ? void 0 : i.formula1 : "", A = He(() => I.ruleChange$.pipe(wn(16)), []), x = Ne(A), j = ln(o);
  1998. Ce(() => {
  1999. (async () => {
  2000. await new Promise((B) => {
  2001. setTimeout(() => B(!0), 100);
  2002. });
  2003. const D = I.getRuleById(n, a, l), U = D == null ? void 0 : D.formula1;
  2004. if (Pe(U) && m && D) {
  2005. const B = await m.getListAsync(D, n, a);
  2006. P(B);
  2007. }
  2008. })();
  2009. }, [I, x, m, l, a, n]), Ce(() => {
  2010. Pe(s) && s !== C && (f(s), R(C));
  2011. }, [C, s]);
  2012. const [N, H] = W(() => {
  2013. const D = p !== "1" ? ao(s) : [], U = c.split(",");
  2014. return D.map((B, $) => ({
  2015. label: B,
  2016. color: U[$] || Te,
  2017. isRef: !1,
  2018. id: en.generateRandomId(4)
  2019. }));
  2020. }), X = (D, U, B) => {
  2021. const $ = N.find((_e) => _e.id === D);
  2022. $ && ($.label = U, $.color = B, H([...N]));
  2023. }, k = (D) => {
  2024. const U = N.findIndex((B) => B.id === D);
  2025. U !== -1 && (N.splice(U, 1), H([...N]));
  2026. }, K = c.split(","), q = He(() => y.map((D, U) => ({
  2027. label: D,
  2028. color: K[U] || Te,
  2029. id: `${U}`,
  2030. isRef: !0
  2031. })), [K, y]), ee = (D, U, B) => {
  2032. const $ = [..._];
  2033. $[+D] = B, S($), j({
  2034. formula1: s,
  2035. formula2: $.join(",")
  2036. });
  2037. }, te = () => {
  2038. H([
  2039. ...N,
  2040. {
  2041. label: "",
  2042. color: Te,
  2043. isRef: !1,
  2044. id: en.generateRandomId(4)
  2045. }
  2046. ]);
  2047. };
  2048. Ce(() => {
  2049. if (p === "1")
  2050. return;
  2051. const D = /* @__PURE__ */ new Set(), U = [];
  2052. N.map((B) => ({
  2053. labelList: B.label.split(","),
  2054. item: B
  2055. })).forEach(({ item: B, labelList: $ }) => {
  2056. $.forEach((_e) => {
  2057. D.has(_e) || (D.add(_e), U.push({
  2058. label: _e,
  2059. color: B.color
  2060. }));
  2061. });
  2062. }), j({
  2063. formula1: io(U.map((B) => B.label)),
  2064. formula2: U.map((B) => B.color === Te ? "" : B.color).join(",")
  2065. });
  2066. }, [N, j, p, C, _]);
  2067. const re = ln(async (D) => {
  2068. if (!Pe(D)) {
  2069. j == null || j({
  2070. formula1: "",
  2071. formula2: c
  2072. });
  2073. return;
  2074. }
  2075. V.getFormulaRefCheck(D) ? (j == null || j({
  2076. formula1: Pe(D) ? D : "",
  2077. formula2: c
  2078. }), T("")) : (j == null || j({
  2079. formula1: "",
  2080. formula2: c
  2081. }), f("="), T(v.t("dataValidation.validFail.formulaError")));
  2082. }), ae = We({}), [se, O] = W(!1);
  2083. return Sn((D) => {
  2084. var B;
  2085. const U = (B = ae.current) == null ? void 0 : B.handleOutClick;
  2086. U && U(D, () => O(!1));
  2087. }), /* @__PURE__ */ h.jsxs(h.Fragment, { children: [
  2088. /* @__PURE__ */ h.jsx(Z, { label: v.t("dataValidation.list.options"), children: /* @__PURE__ */ h.jsxs(
  2089. mn,
  2090. {
  2091. value: p,
  2092. onChange: (D) => {
  2093. d(D), f(C), D === "1" && j({
  2094. formula1: C === "=" ? "" : C,
  2095. formula2: _.join(",")
  2096. });
  2097. },
  2098. children: [
  2099. /* @__PURE__ */ h.jsx(Ae, { value: "0", children: v.t("dataValidation.list.customOptions") }),
  2100. /* @__PURE__ */ h.jsx(Ae, { value: "1", children: v.t("dataValidation.list.refOptions") })
  2101. ]
  2102. }
  2103. ) }),
  2104. p === "1" ? /* @__PURE__ */ h.jsxs(h.Fragment, { children: [
  2105. /* @__PURE__ */ h.jsx(
  2106. So,
  2107. {
  2108. initValue: g,
  2109. unitId: n,
  2110. subUnitId: a,
  2111. isFocus: se,
  2112. onChange: (D = "") => {
  2113. const U = (D != null ? D : "").trim();
  2114. R(U), re(U);
  2115. },
  2116. errorText: E || F || void 0,
  2117. onFocus: () => O(!0),
  2118. actions: ae.current,
  2119. isSupportAcrossSheet: !0
  2120. }
  2121. ),
  2122. /* @__PURE__ */ h.jsx("div", { ref: u, style: { marginTop: "12px" }, children: q.map((D) => /* @__PURE__ */ h.jsx(Wn, { item: D, commonProps: { onItemChange: ee }, style: { marginBottom: 12 } }, D.id)) })
  2123. ] }) : /* @__PURE__ */ h.jsx(Z, { error: E, children: /* @__PURE__ */ h.jsxs("div", { ref: u, style: { marginTop: "-12px" }, children: [
  2124. /* @__PURE__ */ h.jsx(
  2125. sa,
  2126. {
  2127. list: N,
  2128. onListChange: H,
  2129. rowHeight: 32,
  2130. margin: [0, 12],
  2131. draggableHandle: ".draggableHandle",
  2132. itemRender: (D) => /* @__PURE__ */ h.jsx(
  2133. Wn,
  2134. {
  2135. item: D,
  2136. commonProps: {
  2137. onItemChange: X,
  2138. onItemDelete: k
  2139. }
  2140. },
  2141. D.id
  2142. ),
  2143. idKey: "id"
  2144. }
  2145. ),
  2146. /* @__PURE__ */ h.jsxs("a", { className: ne.dataValidationFormulaListAdd, onClick: te, children: [
  2147. /* @__PURE__ */ h.jsx(Ro, {}),
  2148. v.t("dataValidation.list.add")
  2149. ] })
  2150. ] }) })
  2151. ] });
  2152. }
  2153. const jo = "data-validation.custom-formula-input", xt = "data-validation.formula-input", Mn = "data-validation.list-formula-input", Fo = "data-validation.checkbox-formula-input", jr = [
  2154. [
  2155. jo,
  2156. Lr
  2157. ],
  2158. [
  2159. xt,
  2160. Er
  2161. ],
  2162. [
  2163. Mn,
  2164. xr
  2165. ],
  2166. [
  2167. Fo,
  2168. Or
  2169. ]
  2170. ], Fr = "LIST_RENDER_MODE_OPTION_INPUT";
  2171. function Mt(e) {
  2172. var a;
  2173. const { value: t, onChange: o } = e, n = L(J);
  2174. return /* @__PURE__ */ h.jsx(Z, { label: n.t("dataValidation.renderMode.label"), children: /* @__PURE__ */ h.jsxs(mn, { value: `${(a = t.renderMode) != null ? a : de.CUSTOM}`, onChange: (i) => o({ ...t, renderMode: +i }), children: [
  2175. /* @__PURE__ */ h.jsx(Ae, { value: `${de.CUSTOM}`, children: n.t("dataValidation.renderMode.chip") }),
  2176. /* @__PURE__ */ h.jsx(Ae, { value: `${de.ARROW}`, children: n.t("dataValidation.renderMode.arrow") }),
  2177. /* @__PURE__ */ h.jsx(Ae, { value: `${de.TEXT}`, children: n.t("dataValidation.renderMode.text") })
  2178. ] }) });
  2179. }
  2180. Mt.componentKey = Fr;
  2181. const Nr = "DATE_SHOW_TIME_OPTION";
  2182. function bt(e) {
  2183. var a;
  2184. const { value: t, onChange: o } = e, n = L(J);
  2185. return /* @__PURE__ */ h.jsx(Z, { children: /* @__PURE__ */ h.jsx(
  2186. Ot,
  2187. {
  2188. checked: (a = t.bizInfo) == null ? void 0 : a.showTime,
  2189. onChange: (i) => {
  2190. o({
  2191. ...t,
  2192. bizInfo: {
  2193. ...t.bizInfo,
  2194. showTime: i
  2195. }
  2196. });
  2197. },
  2198. children: n.t("dataValidation.showTime.label")
  2199. }
  2200. ) });
  2201. }
  2202. bt.componentKey = Nr;
  2203. var Ur = Object.defineProperty, Br = Object.getOwnPropertyDescriptor, $r = (e, t, o, n) => {
  2204. for (var a = n > 1 ? void 0 : n ? Br(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  2205. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  2206. return n && a && Ur(t, o, a), a;
  2207. }, at = (e, t) => (o, n) => t(o, n, e);
  2208. const ht = 6;
  2209. let dn = class {
  2210. constructor(e, t, o, n, a) {
  2211. this._commandService = e, this._formulaService = t, this._themeService = o, this._renderManagerService = n, this._dataValidationModel = a;
  2212. }
  2213. _calc(e, t) {
  2214. var c, u, p;
  2215. const { vt: o, ht: n } = t || {}, a = e.endX - e.startX - ht * 2, i = e.endY - e.startY, r = ((c = t == null ? void 0 : t.fs) != null ? c : 10) * 1.6;
  2216. let l = 0, s = 0;
  2217. switch (o) {
  2218. case ue.TOP:
  2219. s = 0;
  2220. break;
  2221. case ue.BOTTOM:
  2222. s = 0 + (i - r);
  2223. break;
  2224. default:
  2225. s = 0 + (i - r) / 2;
  2226. break;
  2227. }
  2228. switch (n) {
  2229. case Ye.LEFT:
  2230. l = ht;
  2231. break;
  2232. case Ye.RIGHT:
  2233. l = ht + (a - r);
  2234. break;
  2235. default:
  2236. l = ht + (a - r) / 2;
  2237. break;
  2238. }
  2239. return {
  2240. left: e.startX + l,
  2241. top: e.startY + s,
  2242. width: ((u = t == null ? void 0 : t.fs) != null ? u : 10) * 1.6,
  2243. height: ((p = t == null ? void 0 : t.fs) != null ? p : 10) * 1.6
  2244. };
  2245. }
  2246. calcCellAutoHeight(e) {
  2247. var o;
  2248. const { style: t } = e;
  2249. return ((o = t == null ? void 0 : t.fs) != null ? o : 10) * 1.6;
  2250. }
  2251. calcCellAutoWidth(e) {
  2252. var o;
  2253. const { style: t } = e;
  2254. return ((o = t == null ? void 0 : t.fs) != null ? o : 10) * 1.6;
  2255. }
  2256. async _parseFormula(e, t, o) {
  2257. var c, u, p, d, g, f, C, R, v;
  2258. const { formula1: n = Ra, formula2: a = Da } = e, i = await this._formulaService.getRuleFormulaResult(t, o, e.uid), r = Ft((p = (u = (c = i == null ? void 0 : i[0]) == null ? void 0 : c.result) == null ? void 0 : u[0]) == null ? void 0 : p[0]), l = Ft((f = (g = (d = i == null ? void 0 : i[1]) == null ? void 0 : d.result) == null ? void 0 : g[0]) == null ? void 0 : f[0]), s = Ln(String(r)) && Ln(String(l));
  2259. return {
  2260. formula1: Pe(n) ? Ft((v = (R = (C = i == null ? void 0 : i[0]) == null ? void 0 : C.result) == null ? void 0 : R[0]) == null ? void 0 : v[0]) : n,
  2261. formula2: Pe(a) ? l : a,
  2262. isFormulaValid: s
  2263. };
  2264. }
  2265. drawWith(e, t) {
  2266. var E, A, x, j;
  2267. const { style: o, primaryWithCoord: n, unitId: a, subUnitId: i, worksheet: r, row: l, col: s } = t, c = n.isMergedMainCell ? n.mergeInfo : n, u = ie(r.getCellRaw(l, s)), p = this._dataValidationModel.getRuleByLocation(a, i, l, s);
  2268. if (!p)
  2269. return;
  2270. const d = this._dataValidationModel.getValidator(p.type);
  2271. if (!d)
  2272. return;
  2273. const g = this._themeService.getCurrentTheme();
  2274. if (!((E = d.skipDefaultFontRender) != null && E.call(d, p, u, { unitId: a, subUnitId: i, row: l, column: s })))
  2275. return;
  2276. const f = d.parseFormulaSync(p, a, i), { formula1: C } = f, R = this._calc(c, o), { a: v, d: w } = e.getTransform(), I = En(R.left, v), V = En(R.top, w), _ = la.create().composeMatrix({
  2277. left: I,
  2278. top: V,
  2279. scaleX: 1,
  2280. scaleY: 1,
  2281. angle: 0,
  2282. skewX: 0,
  2283. skewY: 0,
  2284. flipX: !1,
  2285. flipY: !1
  2286. }), S = c.endX - c.startX, m = c.endY - c.startY;
  2287. e.save(), e.beginPath(), e.rect(c.startX, c.startY, S, m), e.clip();
  2288. const y = _.getMatrix();
  2289. e.transform(y[0], y[1], y[2], y[3], y[4], y[5]);
  2290. const P = ((A = o == null ? void 0 : o.fs) != null ? A : 10) * 1.6, F = String(u) === String(C), T = g.hyacinth500;
  2291. da.drawWith(e, {
  2292. checked: F,
  2293. width: P,
  2294. height: P,
  2295. fill: (j = (x = o == null ? void 0 : o.cl) == null ? void 0 : x.rgb) != null ? j : T
  2296. }), e.restore();
  2297. }
  2298. isHit(e, t) {
  2299. const o = t.primaryWithCoord.isMergedMainCell ? t.primaryWithCoord.mergeInfo : t.primaryWithCoord, n = this._calc(o, t.style), a = n.top, i = n.top + n.height, r = n.left, l = n.left + n.width, { x: s, y: c } = e;
  2300. return s <= l && s >= r && c <= i && c >= a;
  2301. }
  2302. async onPointerDown(e, t) {
  2303. var f;
  2304. if (t.button === 2)
  2305. return;
  2306. const { primaryWithCoord: o, unitId: n, subUnitId: a, worksheet: i, row: r, col: l } = e, s = ie(i.getCellRaw(r, l)), c = this._dataValidationModel.getRuleByLocation(n, a, r, l);
  2307. if (!c)
  2308. return;
  2309. const u = this._dataValidationModel.getValidator(c.type);
  2310. if (!u || !((f = u.skipDefaultFontRender) != null && f.call(u, c, s, { unitId: n, subUnitId: a, row: r, column: l })))
  2311. return;
  2312. const { formula1: p, formula2: d } = await this._parseFormula(c, n, a), g = {
  2313. range: {
  2314. startColumn: o.actualColumn,
  2315. endColumn: o.actualColumn,
  2316. startRow: o.actualRow,
  2317. endRow: o.actualRow
  2318. },
  2319. value: {
  2320. v: String(s) === wa(String(p)) ? d : p,
  2321. p: null
  2322. }
  2323. };
  2324. this._commandService.executeCommand(
  2325. vn.id,
  2326. g
  2327. );
  2328. }
  2329. onPointerEnter(e, t) {
  2330. var o, n;
  2331. (n = (o = this._renderManagerService.getCurrentTypeOfRenderer(Y.UNIVER_SHEET)) == null ? void 0 : o.mainComponent) == null || n.setCursor(Xe.POINTER);
  2332. }
  2333. onPointerLeave(e, t) {
  2334. var o, n;
  2335. (n = (o = this._renderManagerService.getCurrentTypeOfRenderer(Y.UNIVER_SHEET)) == null ? void 0 : o.mainComponent) == null || n.setCursor(Xe.DEFAULT);
  2336. }
  2337. };
  2338. dn = $r([
  2339. at(0, Q),
  2340. at(1, b(Ia)),
  2341. at(2, b(na)),
  2342. at(3, b(Ve)),
  2343. at(4, b(oe))
  2344. ], dn);
  2345. var kr = Object.defineProperty, Wr = Object.getOwnPropertyDescriptor, Hr = (e, t, o, n) => {
  2346. for (var a = n > 1 ? void 0 : n ? Wr(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  2347. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  2348. return n && a && kr(t, o, a), a;
  2349. }, Yr = (e, t) => (o, n) => t(o, n, e);
  2350. let me = class {
  2351. constructor(e) {
  2352. M(this, "canvasRender", null);
  2353. M(this, "dropdown");
  2354. M(this, "optionsInput");
  2355. M(this, "formulaInput", Mn);
  2356. this.injector = e;
  2357. }
  2358. };
  2359. me = Hr([
  2360. Yr(0, b(Fe))
  2361. ], me);
  2362. class Xr extends me {
  2363. constructor() {
  2364. super(...arguments);
  2365. M(this, "id", z.CHECKBOX);
  2366. M(this, "canvasRender", this.injector.createInstance(dn));
  2367. M(this, "formulaInput", Fo);
  2368. }
  2369. }
  2370. class zr extends me {
  2371. constructor() {
  2372. super(...arguments);
  2373. M(this, "id", z.CUSTOM);
  2374. M(this, "formulaInput", jo);
  2375. }
  2376. }
  2377. const Kr = "data-validation.formula-input";
  2378. class Gr extends me {
  2379. constructor() {
  2380. super(...arguments);
  2381. M(this, "id", z.DATE);
  2382. M(this, "formulaInput", Kr);
  2383. M(this, "optionsInput", bt.componentKey);
  2384. M(this, "dropdown", Oo);
  2385. }
  2386. }
  2387. class Zr extends me {
  2388. constructor() {
  2389. super(...arguments);
  2390. M(this, "id", z.DECIMAL);
  2391. M(this, "formulaInput", xt);
  2392. }
  2393. }
  2394. const No = 4, qr = 0, Wt = 4, Uo = 4, cn = 6, Et = 6, Le = 14;
  2395. function Jr(e, t) {
  2396. const o = ca.getTextSize(e, t), n = o.width + No * 2, { ba: a, bd: i } = o, r = a + i;
  2397. return {
  2398. width: n,
  2399. height: r + qr * 2,
  2400. ba: a
  2401. };
  2402. }
  2403. function Ht(e, t, o, n) {
  2404. const a = Le + cn * 2, i = o - a, r = n - Et * 2, l = e.map((d) => ({
  2405. layout: Jr(d, t),
  2406. text: d
  2407. }));
  2408. let s;
  2409. const c = [];
  2410. l.forEach((d) => {
  2411. const { layout: g } = d, { width: f, height: C } = g;
  2412. !s || s.width + f + Wt > i ? (s = {
  2413. width: f,
  2414. height: C,
  2415. items: [{
  2416. ...d,
  2417. left: 0
  2418. }]
  2419. }, c.push(s)) : (s.items.push({
  2420. ...d,
  2421. left: s.width + Wt
  2422. }), s.width = s.width + f + Wt);
  2423. });
  2424. let u = 0, p = 0;
  2425. return c.forEach((d, g) => {
  2426. p = Math.max(p, d.width), g === c.length - 1 ? u += d.height : u += d.height + Uo;
  2427. }), {
  2428. lines: c,
  2429. totalHeight: u,
  2430. contentWidth: i,
  2431. contentHeight: r,
  2432. cellAutoHeight: u + Et * 2,
  2433. calcAutoWidth: p + a
  2434. };
  2435. }
  2436. const Qr = 8;
  2437. class es extends ua {
  2438. static drawWith(t, o) {
  2439. const { fontString: n, info: a, fill: i, color: r } = o, { layout: l, text: s } = a;
  2440. t.save(), Jn.drawWith(t, {
  2441. width: l.width,
  2442. height: l.height,
  2443. radius: Qr,
  2444. fill: i || Te
  2445. }), t.translateWithPrecision(No, l.ba), t.font = n, t.fillStyle = r, t.fillText(s, 0, 0), t.restore();
  2446. }
  2447. }
  2448. var ts = Object.defineProperty, ns = Object.getOwnPropertyDescriptor, os = (e, t, o, n) => {
  2449. for (var a = n > 1 ? void 0 : n ? ns(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  2450. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  2451. return n && a && ts(t, o, a), a;
  2452. }, Yt = (e, t) => (o, n) => t(o, n, e);
  2453. const as = 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");
  2454. let un = class {
  2455. constructor(e, t, o) {
  2456. M(this, "zIndex");
  2457. M(this, "_dropdownInfoMap", /* @__PURE__ */ new Map());
  2458. this._commandService = e, this._renderManagerService = t, this._dataValidationModel = o;
  2459. }
  2460. _ensureMap(e) {
  2461. let t = this._dropdownInfoMap.get(e);
  2462. return t || (t = /* @__PURE__ */ new Map(), this._dropdownInfoMap.set(e, t)), t;
  2463. }
  2464. _generateKey(e, t) {
  2465. return `${e}.${t}`;
  2466. }
  2467. _drawDownIcon(e, t, o, n, a) {
  2468. const i = o - Le + 4;
  2469. let r = 4;
  2470. switch (a) {
  2471. case ue.MIDDLE:
  2472. r = (n - Le) / 2 + 4;
  2473. break;
  2474. case ue.BOTTOM:
  2475. r = n - Le + 4;
  2476. break;
  2477. }
  2478. e.save(), e.translateWithPrecision(t.startX + i, t.startY + r), e.fillStyle = "#565656", e.fill(as), e.restore();
  2479. }
  2480. // eslint-disable-next-line max-lines-per-function
  2481. drawWith(e, t, o, n) {
  2482. var X, k;
  2483. const { primaryWithCoord: a, row: i, col: r, style: l, data: s, subUnitId: c } = t, u = a.isMergedMainCell ? a.mergeInfo : a, p = s == null ? void 0 : s.fontRenderExtension, { leftOffset: d = 0, rightOffset: g = 0, topOffset: f = 0, downOffset: C = 0 } = p || {}, R = this._ensureMap(c), v = this._generateKey(i, r), w = this._dataValidationModel.getRuleByLocation(t.unitId, t.subUnitId, i, r);
  2484. if (!w)
  2485. return;
  2486. const I = this._dataValidationModel.getValidator(w.type);
  2487. if (!I)
  2488. return;
  2489. const V = {
  2490. startX: u.startX + d,
  2491. endX: u.endX - g,
  2492. startY: u.startY + f,
  2493. endY: u.endY - C
  2494. }, _ = V.endX - V.startX, S = V.endY - V.startY, { cl: m } = l || {}, y = (X = typeof m == "object" ? m == null ? void 0 : m.rgb : m) != null ? X : "#000", P = jt(l != null ? l : void 0), { vt: F, ht: T } = l || {}, E = F != null ? F : ue.MIDDLE, A = (k = ie(s)) != null ? k : "", x = I.parseCellValue(A), j = I.getListWithColorMap(w), N = Ht(x, P, _, S);
  2495. this._drawDownIcon(e, V, _, S, E), e.save(), e.translateWithPrecision(V.startX, V.startY), e.beginPath(), e.rect(0, 0, _ - Le, S), e.clip(), e.translateWithPrecision(cn, Et);
  2496. let H = 0;
  2497. switch (E) {
  2498. case ue.MIDDLE:
  2499. H = (N.contentHeight - N.totalHeight) / 2;
  2500. break;
  2501. case ue.BOTTOM:
  2502. H = N.contentHeight - N.totalHeight;
  2503. break;
  2504. }
  2505. e.translateWithPrecision(0, H), N.lines.forEach((K, q) => {
  2506. e.save();
  2507. const { width: ee, height: te, items: re } = K;
  2508. let ae = 0;
  2509. switch (T) {
  2510. case Ye.RIGHT:
  2511. ae = N.contentWidth - ee;
  2512. break;
  2513. case Ye.CENTER:
  2514. ae = (N.contentWidth - ee) / 2;
  2515. break;
  2516. }
  2517. e.translate(ae, q * (te + Uo)), re.forEach((se) => {
  2518. e.save(), e.translateWithPrecision(se.left, 0), es.drawWith(e, {
  2519. ...P,
  2520. info: se,
  2521. color: y,
  2522. fill: j[se.text]
  2523. }), e.restore();
  2524. }), e.restore();
  2525. }), e.restore(), R.set(v, {
  2526. left: V.startX,
  2527. top: V.startY,
  2528. width: N.contentWidth + cn + Le,
  2529. height: N.contentHeight + Et * 2
  2530. });
  2531. }
  2532. calcCellAutoHeight(e) {
  2533. var _;
  2534. const { primaryWithCoord: t, style: o, data: n, row: a, col: i } = e, r = n == null ? void 0 : n.fontRenderExtension, { leftOffset: l = 0, rightOffset: s = 0, topOffset: c = 0, downOffset: u = 0 } = r || {}, p = t.isMergedMainCell ? t.mergeInfo : t, d = {
  2535. startX: p.startX + l,
  2536. endX: p.endX - s,
  2537. startY: p.startY + c,
  2538. endY: p.endY - u
  2539. }, g = this._dataValidationModel.getRuleByLocation(e.unitId, e.subUnitId, a, i);
  2540. if (!g)
  2541. return;
  2542. const f = this._dataValidationModel.getValidator(g.type);
  2543. if (!f)
  2544. return;
  2545. const C = d.endX - d.startX, R = d.endY - d.startY, v = (_ = ie(n)) != null ? _ : "", w = f.parseCellValue(v), I = jt(o != null ? o : void 0);
  2546. return Ht(w, I, C, R).cellAutoHeight;
  2547. }
  2548. calcCellAutoWidth(e) {
  2549. var _;
  2550. const { primaryWithCoord: t, style: o, data: n, row: a, col: i } = e, r = n == null ? void 0 : n.fontRenderExtension, { leftOffset: l = 0, rightOffset: s = 0, topOffset: c = 0, downOffset: u = 0 } = r || {}, p = t.isMergedMainCell ? t.mergeInfo : t, d = {
  2551. startX: p.startX + l,
  2552. endX: p.endX - s,
  2553. startY: p.startY + c,
  2554. endY: p.endY - u
  2555. }, g = this._dataValidationModel.getRuleByLocation(e.unitId, e.subUnitId, a, i);
  2556. if (!g)
  2557. return;
  2558. const f = this._dataValidationModel.getValidator(g.type);
  2559. if (!f)
  2560. return;
  2561. const C = d.endX - d.startX, R = d.endY - d.startY, v = (_ = ie(n)) != null ? _ : "", w = f.parseCellValue(v), I = jt(o != null ? o : void 0);
  2562. return Ht(w, I, C, R).calcAutoWidth;
  2563. }
  2564. isHit(e, t) {
  2565. const { primaryWithCoord: o } = t, n = o.isMergedMainCell ? o.mergeInfo : o, { endX: a } = n, { x: i } = e;
  2566. return i >= a - Le && i <= a;
  2567. }
  2568. onPointerDown(e, t) {
  2569. if (t.button === 2)
  2570. return;
  2571. const { unitId: o, subUnitId: n, row: a, col: i } = e, r = {
  2572. unitId: o,
  2573. subUnitId: n,
  2574. row: a,
  2575. column: i
  2576. };
  2577. this._commandService.executeCommand(Tt.id, r);
  2578. }
  2579. onPointerEnter(e, t) {
  2580. var o, n;
  2581. (n = (o = this._renderManagerService.getCurrentTypeOfRenderer(Y.UNIVER_SHEET)) == null ? void 0 : o.mainComponent) == null || n.setCursor(Xe.POINTER);
  2582. }
  2583. onPointerLeave(e, t) {
  2584. var o, n;
  2585. (n = (o = this._renderManagerService.getCurrentTypeOfRenderer(Y.UNIVER_SHEET)) == null ? void 0 : o.mainComponent) == null || n.setCursor(Xe.DEFAULT);
  2586. }
  2587. };
  2588. un = os([
  2589. Yt(0, Q),
  2590. Yt(1, b(Ve)),
  2591. Yt(2, b(oe))
  2592. ], un);
  2593. class is extends me {
  2594. constructor() {
  2595. super(...arguments);
  2596. M(this, "id", z.LIST_MULTIPLE);
  2597. M(this, "canvasRender", this.injector.createInstance(un));
  2598. M(this, "dropdown", yn);
  2599. }
  2600. }
  2601. var rs = Object.defineProperty, ss = Object.getOwnPropertyDescriptor, ls = (e, t, o, n) => {
  2602. for (var a = n > 1 ? void 0 : n ? ss(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  2603. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  2604. return n && a && rs(t, o, a), a;
  2605. }, pt = (e, t) => (o, n) => t(o, n, e);
  2606. const Oe = 4, ft = 4, he = 14, pe = 6, ke = 4, Xt = 8, ds = "#565656", Hn = 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");
  2607. function cs(e, t) {
  2608. const o = e.length;
  2609. return {
  2610. id: "d",
  2611. body: {
  2612. dataStream: `${e}${aa}`,
  2613. textRuns: [
  2614. {
  2615. ts: {
  2616. fs: 11,
  2617. ff: void 0,
  2618. it: Qe.FALSE,
  2619. bl: Qe.FALSE,
  2620. ul: {
  2621. s: Qe.FALSE
  2622. },
  2623. st: {
  2624. s: Qe.FALSE
  2625. },
  2626. ol: {
  2627. s: Qe.FALSE
  2628. },
  2629. cl: void 0,
  2630. ...t,
  2631. bg: void 0,
  2632. bd: void 0
  2633. },
  2634. st: 0,
  2635. ed: o
  2636. }
  2637. ]
  2638. },
  2639. documentStyle: {
  2640. pageSize: {
  2641. width: Number.POSITIVE_INFINITY,
  2642. height: Number.POSITIVE_INFINITY
  2643. }
  2644. }
  2645. };
  2646. }
  2647. function Bo(e, t, o) {
  2648. const n = cs(e, o), a = new oa(n), i = new ha(a);
  2649. return {
  2650. documentSkeleton: pa.create(i, t),
  2651. docModel: a,
  2652. docViewModel: i
  2653. };
  2654. }
  2655. function mt(e, t, o) {
  2656. const {
  2657. documentSkeleton: n,
  2658. docModel: a,
  2659. docViewModel: i
  2660. } = Bo(e, t, o);
  2661. return {
  2662. documents: new fa(`DOCUMENTS_${en.generateRandomId()}`, n, {
  2663. pageMarginLeft: 0,
  2664. pageMarginTop: 0
  2665. }),
  2666. documentSkeleton: n,
  2667. docModel: a,
  2668. docViewModel: i
  2669. };
  2670. }
  2671. function Yn(e, t, o, n, a, i, r = !0) {
  2672. let l = 0;
  2673. const s = r ? ke : 0;
  2674. switch (a) {
  2675. case ue.BOTTOM:
  2676. l = t - n - s;
  2677. break;
  2678. case ue.MIDDLE:
  2679. l = (t - n) / 2;
  2680. break;
  2681. default:
  2682. l = s;
  2683. break;
  2684. }
  2685. l = Math.max(ke, l);
  2686. let c = 0;
  2687. switch (i) {
  2688. case Ye.CENTER:
  2689. c = (e - o) / 2;
  2690. break;
  2691. case Ye.RIGHT:
  2692. c = e - o;
  2693. break;
  2694. }
  2695. return c = Math.max(pe, c), {
  2696. paddingLeft: c,
  2697. paddingTop: l
  2698. };
  2699. }
  2700. let hn = class {
  2701. constructor(e, t, o, n) {
  2702. M(this, "_dropdownInfoMap", /* @__PURE__ */ new Map());
  2703. M(this, "zIndex");
  2704. this._localeService = e, this._commandService = t, this._renderManagerService = o, this._dataValidationModel = n;
  2705. }
  2706. _ensureMap(e) {
  2707. let t = this._dropdownInfoMap.get(e);
  2708. return t || (t = /* @__PURE__ */ new Map(), this._dropdownInfoMap.set(e, t)), t;
  2709. }
  2710. _generateKey(e, t) {
  2711. return `${e}.${t}`;
  2712. }
  2713. _drawDownIcon(e, t, o, n, a, i, r) {
  2714. const { t: l = le.pd.t, b: s = le.pd.b } = r, c = o - he;
  2715. let u;
  2716. switch (i) {
  2717. case ue.MIDDLE:
  2718. u = (n - ft) / 2;
  2719. break;
  2720. case ue.BOTTOM:
  2721. u = n - s - a - ke + (a / 2 - ft / 2);
  2722. break;
  2723. default:
  2724. u = l + ke + (a / 2 - ft / 2);
  2725. break;
  2726. }
  2727. e.save(), e.translateWithPrecision(t.startX + c, t.startY + u), e.fillStyle = "#565656", e.fill(Hn), e.restore();
  2728. }
  2729. // eslint-disable-next-line max-lines-per-function, complexity
  2730. drawWith(e, t, o) {
  2731. const { primaryWithCoord: n, row: a, col: i, style: r, data: l, subUnitId: s } = t, c = n.isMergedMainCell ? n.mergeInfo : n, u = this._dataValidationModel.getRuleByLocation(t.unitId, t.subUnitId, a, i);
  2732. if (!u)
  2733. return;
  2734. const p = this._dataValidationModel.getValidator(u.type);
  2735. if (!p)
  2736. return;
  2737. const d = l == null ? void 0 : l.fontRenderExtension, { leftOffset: g = 0, rightOffset: f = 0, topOffset: C = 0, downOffset: R = 0 } = d || {};
  2738. if (!u || !p || !p || p.id.indexOf(z.LIST) !== 0 || !p.skipDefaultFontRender(u))
  2739. return;
  2740. const v = {
  2741. startX: c.startX + g,
  2742. endX: c.endX - f,
  2743. startY: c.startY + C,
  2744. endY: c.endY - R
  2745. }, w = v.endX - v.startX, I = v.endY - v.startY, V = this._ensureMap(s), _ = this._generateKey(a, i), S = p.getListWithColor(u), m = ie(l), y = `${m != null ? m : ""}`, P = S.find((x) => x.label === y);
  2746. let { tb: F, vt: T, ht: E, pd: A } = r || {};
  2747. if (F = F != null ? F : Se.WRAP, T = T != null ? T : ue.BOTTOM, E = E != null ? E : le.ht, A = A != null ? A : le.pd, u.renderMode === de.ARROW) {
  2748. const { l: x = le.pd.l, t: j = le.pd.t, r: N = le.pd.r, b: H = le.pd.b } = A, X = w - x - N - he - 4, { documentSkeleton: k, documents: K, docModel: q } = mt(y, this._localeService, r);
  2749. F === Se.WRAP && q.updateDocumentDataPageSize(Math.max(X, 1)), k.calculate(), k.getActualSize();
  2750. const ee = et(k), { height: te, width: re } = ee, { paddingTop: ae, paddingLeft: se } = Yn(X, I - j - H, re, te, T, E, !0);
  2751. this._drawDownIcon(e, v, w, I, te, T, A), e.save(), e.translateWithPrecision(v.startX + x, v.startY + j), e.beginPath(), e.rect(0, 0, w - x - N, I - j - H), e.clip(), e.translateWithPrecision(0, ae), e.save(), e.translateWithPrecision(Oe, 0), e.beginPath(), e.rect(0, 0, X, te), e.clip(), K.render(e), e.translateWithPrecision(se, 0), e.restore(), e.restore(), V.set(_, {
  2752. left: v.endX + x + o.rowHeaderWidth - he,
  2753. top: v.startY + j + o.columnHeaderHeight,
  2754. width: he,
  2755. height: I - j - H
  2756. });
  2757. } else {
  2758. e.save(), e.translateWithPrecision(v.startX, v.startY), e.beginPath(), e.rect(0, 0, w, I), e.clip();
  2759. const x = w - pe * 2 - Oe - he - 4, { documentSkeleton: j, documents: N, docModel: H } = mt(y, this._localeService, r);
  2760. F === Se.WRAP && H.updateDocumentDataPageSize(Math.max(x, 1)), j.calculate();
  2761. const X = et(j), { height: k, width: K } = X, { paddingTop: q, paddingLeft: ee } = Yn(x, I, K, k, T, E);
  2762. e.translateWithPrecision(pe, q);
  2763. const te = Math.max(w - pe * 2, 1), re = k;
  2764. Jn.drawWith(e, {
  2765. width: te,
  2766. height: re,
  2767. fill: (P == null ? void 0 : P.color) || Te,
  2768. radius: Xt
  2769. }), e.save(), e.translateWithPrecision(Oe, 0), e.beginPath(), e.rect(0, 0, x, k), e.clip(), e.translateWithPrecision(ee, 0), N.render(e), e.restore(), e.translateWithPrecision(x + Oe + 4, (k - ft) / 2), e.fillStyle = ds, e.fill(Hn), e.restore(), V.set(_, {
  2770. left: v.startX + pe + o.rowHeaderWidth,
  2771. top: v.startY + q + o.columnHeaderHeight,
  2772. width: te,
  2773. height: re
  2774. });
  2775. }
  2776. }
  2777. calcCellAutoHeight(e) {
  2778. const { primaryWithCoord: t, style: o, data: n, row: a, col: i } = e, r = t.isMergedMainCell ? t.mergeInfo : t, l = n == null ? void 0 : n.fontRenderExtension, { leftOffset: s = 0, rightOffset: c = 0, topOffset: u = 0, downOffset: p = 0 } = l || {}, d = this._dataValidationModel.getRuleByLocation(e.unitId, e.subUnitId, a, i);
  2779. if (!d || d.renderMode === de.TEXT)
  2780. return;
  2781. const g = {
  2782. startX: r.startX + s,
  2783. endX: r.endX - c,
  2784. startY: r.startY + u,
  2785. endY: r.endY - p
  2786. }, f = g.endX - g.startX, C = ie(n), R = `${C != null ? C : ""}`;
  2787. let { tb: v, pd: w } = o || {};
  2788. const { t: I = le.pd.t, b: V = le.pd.b } = w != null ? w : {};
  2789. if (v = v != null ? v : Se.WRAP, d.renderMode === de.ARROW) {
  2790. const _ = f - he, { documentSkeleton: S, docModel: m } = mt(R, this._localeService, o);
  2791. v === Se.WRAP && m.updateDocumentDataPageSize(Math.max(_, 1)), S.calculate(), S.getActualSize();
  2792. const y = et(S), { height: P } = y;
  2793. return P + I + V + ke * 2;
  2794. } else {
  2795. const _ = f - pe * 2 - Oe - he, { documentSkeleton: S, docModel: m } = Bo(R, this._localeService, o);
  2796. v === Se.WRAP && m.updateDocumentDataPageSize(Math.max(_, 1)), S.calculate();
  2797. const y = et(S), {
  2798. height: P
  2799. } = y;
  2800. return P + ke * 2;
  2801. }
  2802. }
  2803. calcCellAutoWidth(e) {
  2804. const { primaryWithCoord: t, style: o, data: n, row: a, col: i } = e, r = t.isMergedMainCell ? t.mergeInfo : t, l = n == null ? void 0 : n.fontRenderExtension, { leftOffset: s = 0, rightOffset: c = 0, topOffset: u = 0, downOffset: p = 0 } = l || {}, d = this._dataValidationModel.getRuleByLocation(e.unitId, e.subUnitId, a, i);
  2805. if (!d || d.renderMode === de.TEXT)
  2806. return;
  2807. const g = {
  2808. startX: r.startX + s,
  2809. endX: r.endX - c,
  2810. startY: r.startY + u,
  2811. endY: r.endY - p
  2812. }, f = g.endX - g.startX, C = ie(n), R = `${C != null ? C : ""}`;
  2813. let { tb: v, pd: w } = o || {};
  2814. const { l: I = le.pd.l, r: V = le.pd.r } = w != null ? w : {};
  2815. v = v != null ? v : Se.WRAP;
  2816. let _ = pe * 2 + he;
  2817. switch (d.renderMode) {
  2818. case de.ARROW:
  2819. _ = he + pe * 2 + V + I;
  2820. break;
  2821. case de.CUSTOM:
  2822. _ = he + pe * 2 + Oe * 2 + V + I + Xt / 2 + 1;
  2823. break;
  2824. // default is CUSTOM
  2825. default:
  2826. _ = he + pe * 2 + Oe * 2 + V + I + Xt / 2 + 1;
  2827. }
  2828. const S = f - _, { documentSkeleton: m, docModel: y } = mt(R, this._localeService, o);
  2829. return v === Se.WRAP && y.updateDocumentDataPageSize(Math.max(S, 1)), m.calculate(), m.getActualSize(), et(m).width + _;
  2830. }
  2831. isHit(e, t) {
  2832. const { subUnitId: o, row: n, col: a } = t, r = this._ensureMap(o).get(this._generateKey(n, a)), l = this._dataValidationModel.getRuleByLocation(t.unitId, t.subUnitId, n, a);
  2833. if (!l || !r || l.renderMode === de.TEXT)
  2834. return !1;
  2835. const { top: s, left: c, width: u, height: p } = r, { x: d, y: g } = e;
  2836. return d >= c && d <= c + u && g >= s && g <= s + p;
  2837. }
  2838. onPointerDown(e, t) {
  2839. if (t.button === 2)
  2840. return;
  2841. const { unitId: o, subUnitId: n, row: a, col: i } = e, r = {
  2842. unitId: o,
  2843. subUnitId: n,
  2844. row: a,
  2845. column: i
  2846. };
  2847. this._commandService.executeCommand(Tt.id, r);
  2848. }
  2849. onPointerEnter(e, t) {
  2850. var o, n;
  2851. (n = (o = this._renderManagerService.getCurrentTypeOfRenderer(Y.UNIVER_SHEET)) == null ? void 0 : o.mainComponent) == null || n.setCursor(Xe.POINTER);
  2852. }
  2853. onPointerLeave(e, t) {
  2854. var o, n;
  2855. (n = (o = this._renderManagerService.getCurrentTypeOfRenderer(Y.UNIVER_SHEET)) == null ? void 0 : o.mainComponent) == null || n.setCursor(Xe.DEFAULT);
  2856. }
  2857. };
  2858. hn = ls([
  2859. pt(0, b(J)),
  2860. pt(1, Q),
  2861. pt(2, b(Ve)),
  2862. pt(3, b(oe))
  2863. ], hn);
  2864. class us extends me {
  2865. constructor() {
  2866. super(...arguments);
  2867. M(this, "id", z.LIST);
  2868. M(this, "canvasRender", this.injector.createInstance(hn));
  2869. M(this, "dropdown", yn);
  2870. M(this, "optionsInput", Mt.componentKey);
  2871. M(this, "formulaInput", Mn);
  2872. }
  2873. }
  2874. class hs extends me {
  2875. constructor() {
  2876. super(...arguments);
  2877. M(this, "id", z.TEXT_LENGTH);
  2878. M(this, "formulaInput", xt);
  2879. }
  2880. }
  2881. class ps extends me {
  2882. constructor() {
  2883. super(...arguments);
  2884. M(this, "id", z.WHOLE);
  2885. M(this, "formulaInput", xt);
  2886. }
  2887. }
  2888. var fs = Object.defineProperty, ms = Object.getOwnPropertyDescriptor, gs = (e, t, o, n) => {
  2889. for (var a = n > 1 ? void 0 : n ? ms(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  2890. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  2891. return n && a && fs(t, o, a), a;
  2892. }, zt = (e, t) => (o, n) => t(o, n, e);
  2893. let qe = class extends fn {
  2894. constructor(e, t, o) {
  2895. super(), this._injector = e, this._componentManger = t, this._dataValidatorRegistryService = o, this._initComponents(), this._registerValidatorViews();
  2896. }
  2897. _initComponents() {
  2898. [
  2899. [Lo, wo],
  2900. [Dt, Ji],
  2901. [Mo, vi],
  2902. [yn, Li],
  2903. [Oo, ni],
  2904. [Mt.componentKey, Mt],
  2905. [bt.componentKey, bt],
  2906. ...jr
  2907. ].forEach(([e, t]) => {
  2908. this.disposeWithMe(this._componentManger.register(
  2909. e,
  2910. t
  2911. ));
  2912. });
  2913. }
  2914. _registerValidatorViews() {
  2915. [
  2916. Zr,
  2917. ps,
  2918. hs,
  2919. Gr,
  2920. Xr,
  2921. us,
  2922. is,
  2923. zr
  2924. ].forEach((e) => {
  2925. const t = this._injector.createInstance(e), o = this._dataValidatorRegistryService.getValidatorItem(t.id);
  2926. o && (o.formulaInput = t.formulaInput, o.canvasRender = t.canvasRender, o.dropdown = t.dropdown, o.optionsInput = t.optionsInput);
  2927. });
  2928. }
  2929. };
  2930. qe = gs([
  2931. zt(0, b(Fe)),
  2932. zt(1, b(Lt)),
  2933. zt(2, b(ye))
  2934. ], qe);
  2935. var vs = Object.defineProperty, _s = Object.getOwnPropertyDescriptor, Ss = (e, t, o, n) => {
  2936. for (var a = n > 1 ? void 0 : n ? _s(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  2937. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  2938. return n && a && vs(t, o, a), a;
  2939. }, Kt = (e, t) => (o, n) => t(o, n, e);
  2940. const Cs = "SHEET_DATA_VALIDATION_UI_PLUGIN";
  2941. var gt;
  2942. let Xn = (gt = class extends Zn {
  2943. constructor(e = Vt, t, o, n) {
  2944. super(), this._config = e, this._injector = t, this._commandService = o, this._configService = n;
  2945. const { menu: a, ...i } = qn(
  2946. {},
  2947. Vt,
  2948. this._config
  2949. );
  2950. a && this._configService.setConfig("menu", a, { merge: !0 }), this._configService.setConfig(Vn, i);
  2951. }
  2952. onStarting() {
  2953. [
  2954. [fe],
  2955. [Ie],
  2956. [lt],
  2957. [ze],
  2958. [Ze],
  2959. [Ge],
  2960. [Ke],
  2961. [st],
  2962. [qe]
  2963. ].forEach((e) => {
  2964. this._injector.add(e);
  2965. }), [
  2966. At,
  2967. Tt,
  2968. Eo,
  2969. Dn,
  2970. Ue,
  2971. bo
  2972. ].forEach((e) => {
  2973. this._commandService.registerCommand(e);
  2974. });
  2975. }
  2976. onReady() {
  2977. this._injector.get(Ke), this._injector.get(Ge), this._injector.get(st), this._injector.get(lt), this._injector.get(Ve).registerRenderModule(
  2978. Y.UNIVER_SHEET,
  2979. [yt]
  2980. );
  2981. }
  2982. onRendered() {
  2983. this._injector.get(qe), this._injector.get(Ze);
  2984. }
  2985. onSteady() {
  2986. this._injector.get(ze);
  2987. }
  2988. }, M(gt, "pluginName", Cs), M(gt, "type", Y.UNIVER_SHEET), gt);
  2989. Xn = Ss([
  2990. Kt(1, b(Fe)),
  2991. Kt(2, Q),
  2992. Kt(3, pn)
  2993. ], Xn);
  2994. var Is = Object.defineProperty, ws = Object.getOwnPropertyDescriptor, Rs = (e, t, o, n) => {
  2995. for (var a = n > 1 ? void 0 : n ? ws(t, o) : t, i = e.length - 1, r; i >= 0; i--)
  2996. (r = e[i]) && (a = (n ? r(t, o, a) : r(a)) || a);
  2997. return n && a && Is(t, o, a), a;
  2998. }, Gt = (e, t) => (o, n) => t(o, n, e);
  2999. const Ds = "SHEET_DATA_VALIDATION_UI_PLUGIN";
  3000. var vt;
  3001. let zn = (vt = class extends Zn {
  3002. constructor(e = Vt, t, o, n) {
  3003. super(), this._config = e, this._injector = t, this._commandService = o, this._configService = n;
  3004. const { menu: a, ...i } = qn(
  3005. {},
  3006. Vt,
  3007. this._config
  3008. );
  3009. a && this._configService.setConfig("menu", a, { merge: !0 }), this._configService.setConfig(Vn, i);
  3010. }
  3011. onStarting() {
  3012. [
  3013. [fe],
  3014. [Ie],
  3015. [lt],
  3016. [ze],
  3017. [Ze],
  3018. [Ge],
  3019. [Ke],
  3020. [qe]
  3021. ].forEach((e) => {
  3022. this._injector.add(e);
  3023. }), [
  3024. At,
  3025. Tt,
  3026. Eo,
  3027. Dn,
  3028. Ue,
  3029. bo
  3030. ].forEach((e) => {
  3031. this._commandService.registerCommand(e);
  3032. });
  3033. }
  3034. onReady() {
  3035. this._injector.get(Ke), this._injector.get(Ge), this._injector.get(Ve).registerRenderModule(
  3036. Y.UNIVER_SHEET,
  3037. [yt]
  3038. );
  3039. }
  3040. onRendered() {
  3041. this._injector.get(qe), this._injector.get(Ze);
  3042. }
  3043. onSteady() {
  3044. this._injector.get(ze);
  3045. }
  3046. }, M(vt, "pluginName", Ds), M(vt, "type", Y.UNIVER_SHEET), vt);
  3047. zn = Rs([
  3048. Gt(1, b(Fe)),
  3049. Gt(2, Q),
  3050. Gt(3, pn)
  3051. ], zn);
  3052. export {
  3053. Oo as DATE_DROPDOWN_KEY,
  3054. yn as LIST_DROPDOWN_KEY,
  3055. zn as UniverSheetsDataValidationMobileUIPlugin,
  3056. Xn as UniverSheetsDataValidationUIPlugin
  3057. };