chunk-BW43Z7N3.js 370 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414
  1. import {
  2. $e,
  3. Fi,
  4. Gb,
  5. Ji,
  6. X,
  7. Xi,
  8. Yb,
  9. _f,
  10. ca,
  11. fn as fn2,
  12. g,
  13. mr,
  14. pr,
  15. sa
  16. } from "./chunk-QRYBFJ3R.js";
  17. import {
  18. $R,
  19. AC,
  20. BehaviorSubject,
  21. Bi,
  22. Ct,
  23. DC,
  24. De,
  25. Eu,
  26. Fe,
  27. Go,
  28. Gs,
  29. J0,
  30. K0,
  31. Ke,
  32. Ko,
  33. L0,
  34. LC,
  35. Mf,
  36. Mi,
  37. Mt,
  38. NE,
  39. OR,
  40. Ot,
  41. P0,
  42. Pt,
  43. Q_,
  44. Qo,
  45. Qr,
  46. Ra,
  47. SE,
  48. Subject,
  49. U0,
  50. UC,
  51. UE,
  52. Vn,
  53. Vo,
  54. Vr,
  55. Vs,
  56. WC,
  57. Xe,
  58. Xt,
  59. Ze,
  60. _C,
  61. _n,
  62. _s,
  63. ar,
  64. bE,
  65. bR,
  66. cn,
  67. cs,
  68. distinctUntilChanged,
  69. dn,
  70. en,
  71. fC,
  72. filter,
  73. first,
  74. fl,
  75. fn,
  76. fs,
  77. jt,
  78. kE,
  79. kt,
  80. map,
  81. merge,
  82. mu,
  83. nR,
  84. nf,
  85. nt,
  86. nu,
  87. of,
  88. ot,
  89. qt,
  90. rR,
  91. re,
  92. rr,
  93. shareReplay,
  94. skip,
  95. st,
  96. switchMap,
  97. takeUntil,
  98. tr,
  99. we,
  100. wo,
  101. wu,
  102. x_,
  103. yu,
  104. zn
  105. } from "./chunk-23V3HWTR.js";
  106. // node_modules/.pnpm/@univerjs+engine-numfmt@0.5.5/node_modules/@univerjs/engine-numfmt/lib/es/index.js
  107. var T = "@@@";
  108. // node_modules/.pnpm/@univerjs+sheets@0.5.5_@grpc+grpc-js@1.13.4_react@18.3.1_rxjs@7.8.1/node_modules/@univerjs/sheets/lib/es/index.js
  109. var ri = Object.defineProperty;
  110. var ii = (n, e, t) => e in n ? ri(n, e, { enumerable: true, configurable: true, writable: true, value: t }) : n[e] = t;
  111. var R = (n, e, t) => ii(n, typeof e != "symbol" ? e + "" : e, t);
  112. var Ji2 = ((n) => (n.OthersCanView = "othersCanView", n.NoOneElseCanView = "noOneElseCanView", n))(Ji2 || {});
  113. var Yi = ((n) => (n.DesignedUserCanEdit = "designedUserCanEdit", n.OnlyMe = "onlyMe", n))(Yi || {});
  114. var de = class {
  115. constructor() {
  116. R(this, "_model", /* @__PURE__ */ new Map());
  117. R(this, "_ruleChange", new Subject());
  118. R(this, "ruleChange$", this._ruleChange.asObservable());
  119. R(this, "_ruleRefresh", new Subject());
  120. R(this, "ruleRefresh$", this._ruleRefresh.asObservable());
  121. R(this, "_rangeRuleInitStateChange", new BehaviorSubject(false));
  122. R(this, "rangeRuleInitStateChange$", this._rangeRuleInitStateChange.asObservable());
  123. }
  124. ruleRefresh(e) {
  125. this._ruleRefresh.next(e);
  126. }
  127. getRangeRuleInitState() {
  128. return this._rangeRuleInitStateChange.value;
  129. }
  130. changeRuleInitState(e) {
  131. this._rangeRuleInitStateChange.next(e);
  132. }
  133. addRule(e, t, o) {
  134. this._ensureRuleMap(e, t).set(o.id, o), this._ruleChange.next({ unitId: e, subUnitId: t, rule: o, type: "add" });
  135. }
  136. deleteRule(e, t, o) {
  137. var r, i, a, u;
  138. const s = (i = (r = this._model.get(e)) == null ? void 0 : r.get(t)) == null ? void 0 : i.get(o);
  139. s && ((u = (a = this._model.get(e)) == null ? void 0 : a.get(t)) == null || u.delete(o), this._ruleChange.next({ unitId: e, subUnitId: t, rule: s, type: "delete" }));
  140. }
  141. setRule(e, t, o, s) {
  142. var i, a;
  143. const r = this.getRule(e, t, o);
  144. r && ((a = (i = this._model.get(e)) == null ? void 0 : i.get(t)) == null || a.set(o, s), this._ruleChange.next({ unitId: e, subUnitId: t, oldRule: r, rule: s, type: "set" }));
  145. }
  146. getRule(e, t, o) {
  147. var s, r;
  148. return (r = (s = this._model.get(e)) == null ? void 0 : s.get(t)) == null ? void 0 : r.get(o);
  149. }
  150. getSubunitRuleList(e, t) {
  151. var s;
  152. return [...(((s = this._model.get(e)) == null ? void 0 : s.get(t)) || /* @__PURE__ */ new Map()).values()];
  153. }
  154. getSubunitRuleListLength(e, t) {
  155. var s;
  156. const o = (s = this._model.get(e)) == null ? void 0 : s.get(t);
  157. return o ? o.size : 0;
  158. }
  159. _ensureRuleMap(e, t) {
  160. let o = this._model.get(e);
  161. o || (o = /* @__PURE__ */ new Map(), this._model.set(e, o));
  162. let s = o.get(t);
  163. return s || (s = /* @__PURE__ */ new Map(), o.set(t, s)), s;
  164. }
  165. toObject() {
  166. const e = {};
  167. return [...this._model.keys()].forEach((o) => {
  168. const s = this._model.get(o), r = [...s.keys()];
  169. e[o] = {}, r.forEach((i) => {
  170. const a = s.get(i);
  171. e[o][i] = [...a.values()];
  172. });
  173. }), e;
  174. }
  175. fromObject(e) {
  176. const t = /* @__PURE__ */ new Map();
  177. Object.keys(e).forEach((o) => {
  178. const s = e[o], r = /* @__PURE__ */ new Map();
  179. Object.keys(s).forEach((i) => {
  180. const a = s[i].reduce((u, l) => (u.set(l.id, l), u), /* @__PURE__ */ new Map());
  181. r.set(i, a);
  182. }), t.set(o, r);
  183. }), this._model = t;
  184. }
  185. deleteUnitModel(e) {
  186. this._model.delete(e);
  187. }
  188. createRuleId(e, t) {
  189. let o = re.generateRandomId(4);
  190. const s = this._ensureRuleMap(e, t);
  191. for (; s.has(o); )
  192. o = re.generateRandomId(4);
  193. return o;
  194. }
  195. getTargetByPermissionId(e, t) {
  196. const o = this._model.get(e);
  197. if (!o)
  198. return null;
  199. for (const [s, r] of o)
  200. for (const i of r.values())
  201. if (i.permissionId === t)
  202. return [e, s];
  203. return null;
  204. }
  205. };
  206. var Bd = (n, e) => {
  207. const t = n.get(de), o = e.ruleIds.map((r) => t.getRule(e.unitId, e.subUnitId, r)).filter((r) => !!r);
  208. return { id: Ne.id, params: { subUnitId: e.subUnitId, unitId: e.unitId, rules: o } };
  209. };
  210. var ze = {
  211. id: "sheet.mutation.delete-range-protection",
  212. type: ar.MUTATION,
  213. handler: (n, e) => {
  214. const { unitId: t, subUnitId: o, ruleIds: s } = e, r = n.get(de);
  215. return s.forEach((i) => {
  216. r.deleteRule(t, o, i);
  217. }), true;
  218. }
  219. };
  220. var Fd = (n) => {
  221. const e = { ...n, ruleIds: n.rules.map((t) => t.id) };
  222. return { id: ze.id, params: e };
  223. };
  224. var Ne = {
  225. id: "sheet.mutation.add-range-protection",
  226. type: ar.MUTATION,
  227. handler: (n, e) => {
  228. const { unitId: t, subUnitId: o, rules: s } = e, r = n.get(de);
  229. return s.forEach((i) => {
  230. r.addRule(t, o, i);
  231. }), true;
  232. }
  233. };
  234. var Xi2 = {
  235. type: ar.COMMAND,
  236. id: "sheet.command.add-range-protection",
  237. async handler(n, e) {
  238. if (!e)
  239. return false;
  240. const t = n.get(Pt), o = n.get(cn), s = n.get(de), { rule: r, permissionId: i } = e, { unitId: a, subUnitId: u, ranges: l, description: c, viewState: d, editState: h } = r, m = [{
  241. ranges: l,
  242. permissionId: i,
  243. id: s.createRuleId(a, u),
  244. description: c,
  245. unitType: r.unitType,
  246. unitId: a,
  247. subUnitId: u,
  248. viewState: d,
  249. editState: h
  250. }];
  251. if (await t.executeCommand(Ne.id, {
  252. unitId: a,
  253. subUnitId: u,
  254. rules: m
  255. })) {
  256. const f = [{ id: Ne.id, params: { unitId: a, subUnitId: u, rules: m } }], p = [{ id: ze.id, params: { unitId: a, subUnitId: u, ruleIds: m.map((C) => C.id) } }];
  257. o.pushUndoRedo({
  258. unitID: a,
  259. redoMutations: f,
  260. undoMutations: p
  261. });
  262. }
  263. return true;
  264. }
  265. };
  266. var Ye = class {
  267. constructor() {
  268. R(this, "_model", /* @__PURE__ */ new Map());
  269. R(this, "_ruleChange", new Subject());
  270. R(this, "_ruleRefresh", new Subject());
  271. R(this, "_resetOrder", new Subject());
  272. R(this, "ruleChange$", this._ruleChange.asObservable());
  273. R(this, "ruleRefresh$", this._ruleRefresh.asObservable());
  274. R(this, "resetOrder$", this._resetOrder.asObservable());
  275. R(this, "_worksheetRuleInitStateChange", new BehaviorSubject(false));
  276. R(this, "worksheetRuleInitStateChange$", this._worksheetRuleInitStateChange.asObservable());
  277. }
  278. changeRuleInitState(e) {
  279. this._worksheetRuleInitStateChange.next(e);
  280. }
  281. getSheetRuleInitState() {
  282. return this._worksheetRuleInitStateChange.value;
  283. }
  284. addRule(e, t) {
  285. this._ensureSubUnitMap(e).set(t.subUnitId, t), this._ruleChange.next({ unitId: e, rule: t, type: "add", subUnitId: t.subUnitId });
  286. }
  287. deleteRule(e, t) {
  288. var s, r, i;
  289. const o = (r = (s = this._model) == null ? void 0 : s.get(e)) == null ? void 0 : r.get(t);
  290. o && ((i = this._model.get(e)) == null || i.delete(t), this._ruleChange.next({ unitId: e, rule: o, type: "delete", subUnitId: t }));
  291. }
  292. setRule(e, t, o) {
  293. var r, i;
  294. const s = this.getRule(e, t);
  295. s && ((i = (r = this._model) == null ? void 0 : r.get(e)) == null || i.set(t, o), this._ruleChange.next({ unitId: e, oldRule: s, rule: o, type: "set", subUnitId: t }));
  296. }
  297. getRule(e, t) {
  298. var o, s;
  299. return (s = (o = this._model) == null ? void 0 : o.get(e)) == null ? void 0 : s.get(t);
  300. }
  301. toObject() {
  302. const e = {};
  303. return [...this._model.keys()].forEach((o) => {
  304. const s = this._model.get(o);
  305. s != null && s.size && (e[o] = [], [...s.keys()].forEach((i) => {
  306. const a = s.get(i);
  307. a && e[o].push(a);
  308. }));
  309. }), e;
  310. }
  311. fromObject(e) {
  312. const t = /* @__PURE__ */ new Map();
  313. Object.keys(e).forEach((o) => {
  314. const s = e[o];
  315. if (s != null && s.length) {
  316. const r = /* @__PURE__ */ new Map();
  317. s.forEach((i) => {
  318. r.set(i.subUnitId, i);
  319. }), t.set(o, r);
  320. }
  321. }), this._model = t;
  322. }
  323. deleteUnitModel(e) {
  324. this._model.delete(e);
  325. }
  326. _ensureSubUnitMap(e) {
  327. let t = this._model.get(e);
  328. return t || (t = /* @__PURE__ */ new Map(), this._model.set(e, t)), t;
  329. }
  330. ruleRefresh(e) {
  331. this._ruleRefresh.next(e);
  332. }
  333. resetOrder() {
  334. this._resetOrder.next(Math.random());
  335. }
  336. getTargetByPermissionId(e, t) {
  337. const o = this._model.get(e);
  338. if (!o)
  339. return null;
  340. for (const [s, r] of o)
  341. if (r.permissionId === t)
  342. return [e, s];
  343. }
  344. };
  345. var ct = {
  346. id: "sheet.mutation.add-worksheet-protection",
  347. type: ar.MUTATION,
  348. handler: (n, e) => {
  349. const { unitId: t, rule: o } = e;
  350. return n.get(Ye).addRule(t, o), true;
  351. }
  352. };
  353. var St = {
  354. id: "sheet.mutation.delete-worksheet-protection",
  355. type: ar.MUTATION,
  356. handler: (n, e) => {
  357. const { unitId: t, subUnitId: o } = e;
  358. return n.get(Ye).deleteRule(t, o), true;
  359. }
  360. };
  361. var qi = {
  362. type: ar.COMMAND,
  363. id: "sheet.command.add-worksheet-protection",
  364. async handler(n, e) {
  365. if (!e)
  366. return false;
  367. const t = n.get(Pt), o = n.get(cn), { rule: s, unitId: r } = e, i = s.subUnitId;
  368. if (await t.executeCommand(ct.id, {
  369. unitId: r,
  370. rule: s,
  371. subUnitId: s.subUnitId
  372. })) {
  373. const u = [{ id: ct.id, params: { unitId: r, rule: s, subUnitId: s.subUnitId } }], l = [{ id: St.id, params: { unitId: r, subUnitId: i } }];
  374. o.pushUndoRedo({
  375. unitID: r,
  376. redoMutations: u,
  377. undoMutations: l
  378. });
  379. }
  380. return true;
  381. }
  382. };
  383. var Zi = nR("CELL_CONTENT");
  384. var Qi = nR("ROW_FILTERED");
  385. var et = {
  386. CELL_CONTENT: Zi,
  387. ROW_FILTERED: Qi
  388. };
  389. var ea = ((n) => (n[n.DATA_VALIDATION = 9] = "DATA_VALIDATION", n[n.NUMFMT = 10] = "NUMFMT", n[n.CELL_IMAGE = 11] = "CELL_IMAGE", n))(ea || {});
  390. var Ns = "sheet.interceptor.range-theme-id";
  391. var jo = "sheet.interceptor.ignore-range-theme";
  392. var ta = Object.defineProperty;
  393. var na = Object.getOwnPropertyDescriptor;
  394. var oa = (n, e, t, o) => {
  395. for (var s = o > 1 ? void 0 : o ? na(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  396. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  397. return o && s && ta(e, t, s), s;
  398. };
  399. var sa2 = (n, e) => (t, o) => e(t, o, n);
  400. var Go2 = nR("BEFORE_CELL_EDIT");
  401. var qn = nR("AFTER_CELL_EDIT");
  402. var Zn = nR("AFTER_CELL_EDIT_ASYNC");
  403. var V = class extends nt {
  404. /** @ignore */
  405. constructor(e) {
  406. super();
  407. R(this, "_interceptorsByName", /* @__PURE__ */ new Map());
  408. R(this, "_commandInterceptors", []);
  409. R(this, "_rangeInterceptors", []);
  410. R(this, "_beforeCommandInterceptor", []);
  411. R(this, "_afterCommandInterceptors", []);
  412. R(this, "_workbookDisposables", /* @__PURE__ */ new Map());
  413. R(this, "_worksheetDisposables", /* @__PURE__ */ new Map());
  414. R(this, "_interceptorsDirty", false);
  415. R(this, "_composedInterceptorByKey", /* @__PURE__ */ new Map());
  416. R(this, "writeCellInterceptor", new rR({
  417. BEFORE_CELL_EDIT: Go2,
  418. AFTER_CELL_EDIT: qn,
  419. AFTER_CELL_EDIT_ASYNC: Zn
  420. }));
  421. this._univerInstanceService = e, this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(Fe.UNIVER_SHEET).subscribe((t) => {
  422. this._interceptWorkbook(t);
  423. })), this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(Fe.UNIVER_SHEET).subscribe(
  424. (t) => this._disposeWorkbookInterceptor(t)
  425. )), this.intercept(et.CELL_CONTENT, {
  426. priority: -1,
  427. effect: Vn.Style | Vn.Value,
  428. handler(t, o) {
  429. const s = o.worksheet.getCellRaw(o.row, o.col);
  430. return t ? { ...s, ...t } : s;
  431. }
  432. }), this.disposeWithMe(this.writeCellInterceptor.intercept(qn, {
  433. priority: -1,
  434. handler: (t) => t
  435. })), this.disposeWithMe(this.writeCellInterceptor.intercept(Go2, {
  436. priority: -1,
  437. handler: (t) => t
  438. })), this.disposeWithMe(this.writeCellInterceptor.intercept(Zn, {
  439. priority: -1,
  440. handler: (t) => t
  441. }));
  442. }
  443. dispose() {
  444. super.dispose(), this._workbookDisposables.forEach((e) => e.dispose()), this._workbookDisposables.clear(), this._worksheetDisposables.clear(), this._interceptorsByName.clear();
  445. }
  446. // #region intercept command execution
  447. /**
  448. * Add a listener function to a specific command to add affiliated mutations. It should be called in controllers.
  449. *
  450. * Pairs with {@link onCommandExecute}.
  451. *
  452. * @param interceptor
  453. * @returns
  454. */
  455. interceptCommand(e) {
  456. if (this._commandInterceptors.includes(e))
  457. throw new Error("[SheetInterceptorService]: Interceptor already exists!");
  458. return this._commandInterceptors.push(e), this._commandInterceptors.sort((t, o) => {
  459. var s, r;
  460. return ((s = o.priority) != null ? s : 0) - ((r = t.priority) != null ? r : 0);
  461. }), this.disposeWithMe(Ze(() => cs(this._commandInterceptors, e)));
  462. }
  463. /**
  464. * When command is executing, call this method to gether undo redo mutations from upper features.
  465. * @param command
  466. * @returns
  467. */
  468. onCommandExecute(e) {
  469. const t = this._commandInterceptors.map((o) => o.getMutations(e));
  470. return {
  471. preUndos: t.map((o) => {
  472. var s;
  473. return (s = o.preUndos) != null ? s : [];
  474. }).flat(),
  475. undos: t.map((o) => o.undos).flat(),
  476. preRedos: t.map((o) => {
  477. var s;
  478. return (s = o.preRedos) != null ? s : [];
  479. }).flat(),
  480. redos: t.map((o) => o.redos).flat()
  481. };
  482. }
  483. interceptAfterCommand(e) {
  484. if (this._afterCommandInterceptors.includes(e))
  485. throw new Error("[SheetInterceptorService]: Interceptor already exists!");
  486. return this._afterCommandInterceptors.push(e), this._afterCommandInterceptors.sort((t, o) => {
  487. var s, r;
  488. return ((s = o.priority) != null ? s : 0) - ((r = t.priority) != null ? r : 0);
  489. }), this.disposeWithMe(Ze(() => cs(this._afterCommandInterceptors, e)));
  490. }
  491. afterCommandExecute(e) {
  492. const t = this._afterCommandInterceptors.map((o) => o.getMutations(e));
  493. return {
  494. undos: t.map((o) => o.undos).flat(),
  495. redos: t.map((o) => o.redos).flat()
  496. };
  497. }
  498. /**
  499. * Add a listener function to a specific command to determine if the command can execute mutations. It should be
  500. * called in controllers.
  501. *
  502. * Pairs with {@link beforeCommandExecute}.
  503. *
  504. * @param interceptor
  505. * @returns
  506. */
  507. interceptBeforeCommand(e) {
  508. if (this._beforeCommandInterceptor.includes(e))
  509. throw new Error("[SheetInterceptorService]: Interceptor already exists!");
  510. return this._beforeCommandInterceptor.push(e), this._beforeCommandInterceptor.sort((t, o) => {
  511. var s, r;
  512. return ((s = o.priority) != null ? s : 0) - ((r = t.priority) != null ? r : 0);
  513. }), this.disposeWithMe(Ze(() => cs(this._beforeCommandInterceptor, e)));
  514. }
  515. /**
  516. * before command execute, call this method to get the flag of whether it can be executed the command,
  517. * @param info ICommandInfo
  518. * @returns Promise<boolean>
  519. */
  520. async beforeCommandExecute(e) {
  521. return (await Promise.all(this._beforeCommandInterceptor.map((o) => o.performCheck(e)))).every((o) => o);
  522. }
  523. // #endregion
  524. // #region intercept ranges - mainly for pivot table currently (2024/10/28).
  525. /**
  526. * By adding callbacks to some Ranges can get some additional mutations, such as clearing all plugin data in a certain area.
  527. * @param interceptor IRangeInterceptors
  528. * @returns IDisposable
  529. */
  530. interceptRanges(e) {
  531. if (this._rangeInterceptors.includes(e))
  532. throw new Error("[SheetInterceptorService]: Interceptor already exists!");
  533. return this._rangeInterceptors.push(e), this._rangeInterceptors.sort((t, o) => {
  534. var s, r;
  535. return ((s = o.priority) != null ? s : 0) - ((r = t.priority) != null ? r : 0);
  536. }), this.disposeWithMe(Ze(() => cs(this._rangeInterceptors, e)));
  537. }
  538. generateMutationsByRanges(e) {
  539. const t = this._rangeInterceptors.map((o) => o.getMutations(e));
  540. return {
  541. preUndos: t.map((o) => {
  542. var s;
  543. return (s = o.preUndos) != null ? s : [];
  544. }).flat(),
  545. undos: t.map((o) => o.undos).flat(),
  546. preRedos: t.map((o) => {
  547. var s;
  548. return (s = o.preRedos) != null ? s : [];
  549. }).flat(),
  550. redos: t.map((o) => o.redos).flat()
  551. };
  552. }
  553. // #endregion
  554. // #region intercept on writing cell
  555. async onWriteCell(e, t, o, s, r) {
  556. const i = {
  557. subUnitId: t.getSheetId(),
  558. unitId: e.getUnitId(),
  559. workbook: e,
  560. worksheet: t,
  561. row: o,
  562. col: s,
  563. origin: re.deepClone(r)
  564. }, a = this.writeCellInterceptor.fetchThroughInterceptors(qn)(r, i);
  565. return await this.writeCellInterceptor.fetchThroughInterceptors(Zn)(Promise.resolve(a), i);
  566. }
  567. // #endregion
  568. intercept(e, t) {
  569. const o = e;
  570. this._interceptorsByName.has(o) || this._interceptorsByName.set(o, []);
  571. const s = this._interceptorsByName.get(o);
  572. s.push(t);
  573. const r = s.sort((i, a) => {
  574. var u, l;
  575. return ((u = a.priority) != null ? u : 0) - ((l = i.priority) != null ? l : 0);
  576. });
  577. if (o === et.CELL_CONTENT) {
  578. this._interceptorsByName.set(
  579. `${o}-${Vn.Style | Vn.Value}`,
  580. r
  581. );
  582. const i = Vn.Style | Vn.Value;
  583. this._interceptorsByName.set(
  584. `${o}-${Vn.Style}`,
  585. r.filter((a) => ((a.effect || i) & Vn.Style) > 0)
  586. ), this._interceptorsByName.set(
  587. `${o}-${Vn.Value}`,
  588. r.filter((a) => ((a.effect || i) & Vn.Value) > 0)
  589. );
  590. } else
  591. this._interceptorsByName.set(
  592. o,
  593. r
  594. );
  595. return this._interceptorsDirty = true, this.disposeWithMe(Ze(() => cs(this._interceptorsByName.get(o), t)));
  596. }
  597. fetchThroughInterceptors(e, t, o, s) {
  598. const r = t === void 0 ? e : `${e}-${t}`, i = o != null ? o : r;
  599. let a = this._composedInterceptorByKey.get(i);
  600. if (!a || this._interceptorsDirty) {
  601. let u = this._interceptorsByName.get(r);
  602. u && s && (u = u.filter(s)), a = x_(u || []), this._composedInterceptorByKey.set(i, a);
  603. }
  604. return a;
  605. }
  606. _interceptWorkbook(e) {
  607. const t = new Mi(), o = e.getUnitId(), s = this, r = (i) => {
  608. const a = i.getSheetId();
  609. i.__interceptViewModel((u) => {
  610. const l = new Mi();
  611. s._worksheetDisposables.set(zo(o, i), l), l.add(u.registerCellContentInterceptor({
  612. getCell(c, d, h, m, g2) {
  613. const f = i.getCellRaw(c, d);
  614. return s.fetchThroughInterceptors(et.CELL_CONTENT, h, m, g2)(
  615. f,
  616. {
  617. unitId: o,
  618. subUnitId: a,
  619. row: c,
  620. col: d,
  621. worksheet: i,
  622. workbook: e,
  623. rawData: f
  624. }
  625. );
  626. }
  627. })), l.add(u.registerRowFilteredInterceptor({
  628. getRowFiltered(c) {
  629. return !!s.fetchThroughInterceptors(et.ROW_FILTERED)(
  630. false,
  631. {
  632. unitId: o,
  633. subUnitId: a,
  634. row: c,
  635. workbook: e,
  636. worksheet: i
  637. }
  638. );
  639. }
  640. }));
  641. });
  642. };
  643. e.getSheets().forEach((i) => r(i)), t.add(e.sheetCreated$.subscribe((i) => r(i))), t.add(Ze(() => e.getSheets().forEach((i) => this._disposeSheetInterceptor(o, i)))), t.add(e.sheetDisposed$.subscribe((i) => this._disposeSheetInterceptor(o, i))), this._workbookDisposables.set(o, t);
  644. }
  645. _disposeWorkbookInterceptor(e) {
  646. const t = e.getUnitId(), o = this._workbookDisposables.get(t);
  647. o && (o.dispose(), this._workbookDisposables.delete(t));
  648. }
  649. _disposeSheetInterceptor(e, t) {
  650. const o = zo(e, t), s = this._worksheetDisposables.get(o);
  651. s && (s.dispose(), this._worksheetDisposables.delete(o));
  652. }
  653. };
  654. V = oa([
  655. sa2(0, _n)
  656. ], V);
  657. function zo(n, e) {
  658. return `${n}|${e.getSheetId()}`;
  659. }
  660. var le = (n) => {
  661. const e = {};
  662. return n.bg && (e.bg = { ...n.bg }), n.ol && (e.ol = { ...n.ol }), n.bd && (e.bd = { ...n.bd }), n.cl && (e.cl = { ...n.cl }), n.ht && (e.ht = n.ht), n.vt && (e.vt = n.vt), n.bl !== void 0 && (e.bl = n.bl), e;
  663. };
  664. function ra(n) {
  665. const e = {};
  666. if (n.length === 1)
  667. return n[0];
  668. for (const t of n)
  669. t.bg && (e.bg = t.bg), t.ol && (e.ol = t.ol), t.bd && (e.bd = { ...e.bd, ...t.bd }), t.cl && (e.cl = t.cl), t.ht && (e.ht = t.ht), t.vt && (e.vt = t.vt), t.bl !== void 0 && (e.bl = t.bl);
  670. return e;
  671. }
  672. var ce = {
  673. wholeStyle: 1,
  674. headerRowStyle: 2,
  675. headerColumnStyle: 4,
  676. firstRowStyle: 8,
  677. secondRowStyle: 16,
  678. lastRowStyle: 32,
  679. firstColumnStyle: 128,
  680. secondColumnStyle: 256,
  681. lastColumnStyle: 512
  682. };
  683. var yt = class {
  684. /**
  685. * @constructor
  686. * @param {string} name The name of the range theme style, it used to identify the range theme style.
  687. * @param {IRangeThemeStyleJSON} [options] The options to initialize the range theme style.
  688. */
  689. constructor(e, t) {
  690. R(this, "_name");
  691. R(this, "wholeStyle", null);
  692. R(this, "headerRowStyle", null);
  693. R(this, "headerColumnStyle", null);
  694. R(this, "firstRowStyle", null);
  695. R(this, "secondRowStyle", null);
  696. R(this, "lastRowStyle", null);
  697. R(this, "firstColumnStyle", null);
  698. R(this, "secondColumnStyle", null);
  699. R(this, "lastColumnStyle", null);
  700. R(this, "_mergeCacheMap", /* @__PURE__ */ new Map());
  701. t && this.fromJson({ ...t, name: e }), this._name = e;
  702. }
  703. /**
  704. * Gets the name of the range theme style.The name is read only, and use to identifier the range theme style.
  705. * @returns {string} The name of the range theme style.
  706. */
  707. getName() {
  708. return this._name;
  709. }
  710. getWholeStyle() {
  711. return this.wholeStyle;
  712. }
  713. setWholeStyle(e) {
  714. this.wholeStyle = e;
  715. }
  716. getFirstRowStyle() {
  717. return this.firstRowStyle;
  718. }
  719. setFirstRowStyle(e) {
  720. this.firstRowStyle = e;
  721. }
  722. getSecondRowStyle() {
  723. return this.secondRowStyle;
  724. }
  725. setSecondRowStyle(e) {
  726. this.secondRowStyle = e;
  727. }
  728. getLastRowStyle() {
  729. return this.lastRowStyle;
  730. }
  731. setLastRowStyle(e) {
  732. this.lastRowStyle = e;
  733. }
  734. getFirstColumnStyle() {
  735. return this.firstColumnStyle;
  736. }
  737. setFirstColumnStyle(e) {
  738. this.firstColumnStyle = e;
  739. }
  740. getSecondColumnStyle() {
  741. return this.secondColumnStyle;
  742. }
  743. setSecondColumnStyle(e) {
  744. this.secondColumnStyle = e;
  745. }
  746. getLastColumnStyle() {
  747. return this.lastColumnStyle;
  748. }
  749. setLastColumnStyle(e) {
  750. this.lastColumnStyle = e;
  751. }
  752. getHeaderRowStyle() {
  753. return this.headerRowStyle;
  754. }
  755. setHeaderRowStyle(e) {
  756. this.headerRowStyle = e;
  757. }
  758. getHeaderColumnStyle() {
  759. return this.headerColumnStyle;
  760. }
  761. setHeaderColumnStyle(e) {
  762. this.headerColumnStyle = e;
  763. }
  764. getStyle(e, t, o, s) {
  765. let r = 0;
  766. return o && (r = r | ce.lastRowStyle), s && (r = r | ce.lastColumnStyle), e >= 0 && t >= 0 && (r = r | ce.wholeStyle), e % 2 === 1 && (r = r | ce.firstRowStyle), e % 2 === 0 && (r = r | ce.secondRowStyle), e === 0 && (r = r | ce.headerRowStyle), t === 0 && (r = r | ce.headerColumnStyle), t % 2 === 1 && (r = r | ce.firstColumnStyle), t % 2 === 0 && (r = r | ce.secondColumnStyle), r === 0 ? null : this._getMergeStyle(r);
  767. }
  768. _getMergeStyle(e) {
  769. let t = this._mergeCacheMap.get(e);
  770. return t || (t = this._mergeStyle(e), this._mergeCacheMap.set(e, t)), t;
  771. }
  772. _mergeStyle(e) {
  773. const t = [];
  774. return this.wholeStyle && e & ce.wholeStyle && t.push(this.wholeStyle), this.firstColumnStyle && e & ce.firstColumnStyle && t.push(this.firstColumnStyle), this.secondColumnStyle && e & ce.secondColumnStyle && t.push(this.secondColumnStyle), this.firstRowStyle && e & ce.firstRowStyle && t.push(this.firstRowStyle), this.secondRowStyle && e & ce.secondRowStyle && t.push(this.secondRowStyle), this.headerColumnStyle && e & ce.headerColumnStyle && t.push(this.headerColumnStyle), this.lastColumnStyle && e & ce.lastColumnStyle && t.push(this.lastColumnStyle), this.headerRowStyle && e & ce.headerRowStyle && t.push(this.headerRowStyle), this.lastRowStyle && e & ce.lastRowStyle && t.push(this.lastRowStyle), ra(t);
  775. }
  776. toJson() {
  777. const e = {
  778. name: this._name
  779. };
  780. return this.wholeStyle && (e.wholeStyle = le(this.wholeStyle)), this.headerRowStyle && (e.headerRowStyle = le(this.headerRowStyle)), this.headerColumnStyle && (e.headerColumnStyle = le(this.headerColumnStyle)), this.firstRowStyle && (e.firstRowStyle = le(this.firstRowStyle)), this.secondRowStyle && (e.secondRowStyle = le(this.secondRowStyle)), this.lastRowStyle && (e.lastRowStyle = le(this.lastRowStyle)), this.firstColumnStyle && (e.firstColumnStyle = le(this.firstColumnStyle)), this.secondColumnStyle && (e.secondColumnStyle = le(this.secondColumnStyle)), this.lastColumnStyle && (e.lastColumnStyle = le(this.lastColumnStyle)), e;
  781. }
  782. fromJson(e) {
  783. this._name = e.name, e.wholeStyle && (this.wholeStyle = le(e.wholeStyle)), e.headerRowStyle && (this.headerRowStyle = le(e.headerRowStyle)), e.headerColumnStyle && (this.headerColumnStyle = le(e.headerColumnStyle)), e.firstRowStyle && (this.firstRowStyle = le(e.firstRowStyle)), e.secondRowStyle && (this.secondRowStyle = le(e.secondRowStyle)), e.lastRowStyle && (this.lastRowStyle = le(e.lastRowStyle)), e.firstColumnStyle && (this.firstColumnStyle = le(e.firstColumnStyle)), e.secondColumnStyle && (this.secondColumnStyle = le(e.secondColumnStyle)), e.lastColumnStyle && (this.lastColumnStyle = le(e.lastColumnStyle));
  784. }
  785. dispose() {
  786. this._mergeCacheMap.clear();
  787. }
  788. };
  789. var ia = (n, e, t) => new yt(`light-${n}`, {
  790. headerRowStyle: {
  791. bg: {
  792. rgb: e
  793. }
  794. },
  795. firstColumnStyle: {
  796. bg: {
  797. rgb: "rgb(255, 255, 255)"
  798. }
  799. },
  800. secondColumnStyle: {
  801. bg: {
  802. rgb: t
  803. }
  804. },
  805. lastRowStyle: {
  806. bg: {
  807. rgb: e
  808. }
  809. }
  810. });
  811. var aa = (n, e, t) => new yt(`middle-${n}`, {
  812. headerRowStyle: {
  813. bg: {
  814. rgb: e
  815. }
  816. },
  817. headerColumnStyle: {
  818. bg: {
  819. rgb: t
  820. }
  821. },
  822. secondRowStyle: {
  823. bg: {
  824. rgb: t
  825. }
  826. },
  827. lastRowStyle: {
  828. bg: {
  829. rgb: e
  830. }
  831. },
  832. lastColumnStyle: {
  833. bg: {
  834. rgb: t
  835. }
  836. }
  837. });
  838. var ua = (n, e, t, o) => new yt(`dark-${n}`, {
  839. headerRowStyle: {
  840. bg: {
  841. rgb: e
  842. },
  843. cl: {
  844. rgb: "rgb(255, 255, 255)"
  845. },
  846. ht: Xt.CENTER,
  847. bl: we.TRUE
  848. },
  849. firstRowStyle: {
  850. bg: {
  851. rgb: t
  852. }
  853. },
  854. secondRowStyle: {
  855. bg: {
  856. rgb: o
  857. }
  858. },
  859. lastRowStyle: {
  860. bg: {
  861. rgb: e
  862. }
  863. }
  864. });
  865. var la = [
  866. {
  867. baseName: "blue",
  868. header: "rgb(164, 202, 254)",
  869. color: "rgb(225, 239, 254)"
  870. },
  871. {
  872. baseName: "grey",
  873. header: "rgb(205, 208, 216)",
  874. color: "rgb(238, 239, 241)"
  875. },
  876. {
  877. baseName: "red",
  878. header: "rgb(248, 180, 180)",
  879. color: "rgb(253, 232, 232)"
  880. },
  881. {
  882. baseName: "orange",
  883. header: "rgb(253, 186, 140)",
  884. color: "rgb(254, 236, 220)"
  885. },
  886. {
  887. baseName: "yellow",
  888. header: "rgb(250, 200, 21)",
  889. color: "rgb(255, 244, 185)"
  890. },
  891. {
  892. baseName: "green",
  893. header: "rgb(132, 225, 188)",
  894. color: "rgb(222, 247, 236)"
  895. },
  896. {
  897. baseName: "azure",
  898. header: "rgb(126, 220, 226)",
  899. color: "rgb(213, 245, 246)"
  900. },
  901. {
  902. baseName: "indigo",
  903. header: "rgb(186, 198, 248)",
  904. color: "rgb(233, 237, 255)"
  905. },
  906. {
  907. baseName: "purple",
  908. header: "rgb(202, 191, 253)",
  909. color: "rgb(237, 235, 254)"
  910. },
  911. {
  912. baseName: "magenta",
  913. header: "rgb(248, 180, 217)",
  914. color: "rgb(252, 232, 243)"
  915. }
  916. ];
  917. var ca2 = [
  918. {
  919. baseName: "blue",
  920. rowHeader: "rgb(63, 131, 248)",
  921. colHeader: "rgb(195, 221, 253)"
  922. },
  923. {
  924. baseName: "grey",
  925. rowHeader: "rgb(95, 101, 116)",
  926. colHeader: "rgb(227, 229, 234)"
  927. },
  928. {
  929. baseName: "red",
  930. rowHeader: "rgb(240, 82, 82)",
  931. colHeader: "rgb(251, 213, 213)"
  932. },
  933. {
  934. baseName: "orange",
  935. rowHeader: "rgb(255, 90, 31)",
  936. colHeader: "rgb(252, 217, 189)"
  937. },
  938. {
  939. baseName: "yellow",
  940. rowHeader: "rgb(212, 157, 15)",
  941. colHeader: "rgb(252, 220, 106)"
  942. },
  943. {
  944. baseName: "green",
  945. rowHeader: "rgb(13, 164, 113)",
  946. colHeader: "rgb(188, 240, 218)"
  947. },
  948. {
  949. baseName: "azure",
  950. rowHeader: "rgb(6, 148, 162)",
  951. colHeader: "rgb(175, 236, 239)"
  952. },
  953. {
  954. baseName: "indigo",
  955. rowHeader: "rgb(70, 106, 247)",
  956. colHeader: "rgb(210, 218, 250)"
  957. },
  958. {
  959. baseName: "purple",
  960. rowHeader: "rgb(144, 97, 249)",
  961. colHeader: "rgb(220, 215, 254)"
  962. },
  963. {
  964. baseName: "magenta",
  965. rowHeader: "rgb(231, 70, 148)",
  966. colHeader: "rgb(250, 209, 232)"
  967. }
  968. ];
  969. var da = [
  970. {
  971. baseName: "blue",
  972. rowHeader: "rgb(30, 66, 159)",
  973. firstRow: "rgb(195, 221, 253)",
  974. secondRow: "rgb(118, 169, 250)"
  975. },
  976. {
  977. baseName: "grey",
  978. rowHeader: "rgb(44, 48, 64)",
  979. firstRow: "rgb(227, 229, 234)",
  980. secondRow: "rgb(151, 157, 172)"
  981. },
  982. {
  983. baseName: "red",
  984. rowHeader: "rgb(155, 28, 28)",
  985. firstRow: "rgb(251, 213, 213)",
  986. secondRow: "rgb(249, 128, 128)"
  987. },
  988. {
  989. baseName: "orange",
  990. rowHeader: "rgb(180, 52, 3)",
  991. firstRow: "rgb(252, 217, 189)",
  992. secondRow: "rgb(255, 138, 76)"
  993. },
  994. {
  995. baseName: "yellow",
  996. rowHeader: "rgb(154, 109, 21)",
  997. firstRow: "rgb(252, 220, 106)",
  998. secondRow: "rgb(212, 157, 15)"
  999. },
  1000. {
  1001. baseName: "green",
  1002. rowHeader: "rgb(4, 108, 78)",
  1003. firstRow: "rgb(188, 240, 218)",
  1004. secondRow: "rgb(49, 196, 141)"
  1005. },
  1006. {
  1007. baseName: "azure",
  1008. rowHeader: "rgb(3, 102, 114)",
  1009. firstRow: "rgb(175, 236, 239)",
  1010. secondRow: "rgb(22, 189, 202)"
  1011. },
  1012. {
  1013. baseName: "indigo",
  1014. rowHeader: "rgb(16, 51, 191)",
  1015. firstRow: "rgb(210, 218, 250)",
  1016. secondRow: "rgb(98, 128, 249)"
  1017. },
  1018. {
  1019. baseName: "purple",
  1020. rowHeader: "rgb(74, 29, 150)",
  1021. firstRow: "rgb(220, 215, 254)",
  1022. secondRow: "rgb(172, 148, 250)"
  1023. },
  1024. {
  1025. baseName: "magenta",
  1026. rowHeader: "rgb(153, 21, 75)",
  1027. firstRow: "rgb(250, 209, 232)",
  1028. secondRow: "rgb(241, 126, 184)"
  1029. }
  1030. ];
  1031. var ha = la.map(({ baseName: n, header: e, color: t }) => ia(n, e, t));
  1032. var ma = ca2.map(({ baseName: n, rowHeader: e, colHeader: t }) => aa(n, e, t));
  1033. var ga = da.map(({ baseName: n, rowHeader: e, firstRow: t, secondRow: o }) => ua(n, e, t, o));
  1034. var fa = [
  1035. ...ha,
  1036. ...ma,
  1037. ...ga
  1038. ];
  1039. var Ra2 = {
  1040. headerRowStyle: {
  1041. bg: {
  1042. rgb: "rgb(68,114,196)"
  1043. },
  1044. cl: {
  1045. rgb: "rgb(255,255,255)"
  1046. },
  1047. ht: Xt.CENTER,
  1048. bl: we.TRUE
  1049. },
  1050. firstRowStyle: {
  1051. bg: {
  1052. rgb: "rgb(217,225,242)"
  1053. }
  1054. },
  1055. lastRowStyle: {
  1056. bd: {
  1057. t: {
  1058. s: Xe.THIN,
  1059. cl: {
  1060. rgb: "rgb(68,114,196)"
  1061. }
  1062. }
  1063. },
  1064. ht: Xt.CENTER,
  1065. bl: we.TRUE
  1066. }
  1067. };
  1068. var pa = new yt("default", Ra2);
  1069. var Ca = Object.defineProperty;
  1070. var Sa = Object.getOwnPropertyDescriptor;
  1071. var wa = (n, e, t, o) => {
  1072. for (var s = o > 1 ? void 0 : o ? Sa(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  1073. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  1074. return o && s && Ca(e, t, s), s;
  1075. };
  1076. var Ko2 = (n, e) => (t, o) => e(t, o, n);
  1077. var Ia = "SHEET_RANGE_THEME_MODEL_PLUGIN";
  1078. var He = class extends nt {
  1079. constructor(e, t) {
  1080. super();
  1081. R(this, "_rangeThemeStyleMap", /* @__PURE__ */ new Map());
  1082. R(this, "_rangeThemeStyleRuleMap", /* @__PURE__ */ new Map());
  1083. R(this, "_rTreeCollection", /* @__PURE__ */ new Map());
  1084. R(this, "_defaultRangeThemeMap", /* @__PURE__ */ new Map());
  1085. this._sheetInterceptorService = e, this._resourceManagerService = t, this._registerIntercept(), this._initSnapshot(), this._initDefaultTheme();
  1086. }
  1087. _initDefaultTheme() {
  1088. this.registerDefaultRangeTheme(pa);
  1089. for (const e of fa)
  1090. this.registerDefaultRangeTheme(e);
  1091. }
  1092. _ensureRangeThemeStyleMap(e) {
  1093. return this._rangeThemeStyleMap.has(e) || this._rangeThemeStyleMap.set(e, /* @__PURE__ */ new Map()), this._rangeThemeStyleMap.get(e);
  1094. }
  1095. _ensureRangeThemeStyleRuleMap(e) {
  1096. return this._rangeThemeStyleRuleMap.has(e) || this._rangeThemeStyleRuleMap.set(e, /* @__PURE__ */ new Map()), this._rangeThemeStyleRuleMap.get(e);
  1097. }
  1098. _ensureRTreeCollection(e) {
  1099. return this._rTreeCollection.has(e) || this._rTreeCollection.set(e, new $R()), this._rTreeCollection.get(e);
  1100. }
  1101. getDefaultRangeThemeStyle(e) {
  1102. return this._defaultRangeThemeMap.get(e);
  1103. }
  1104. /**
  1105. * Register range theme styles
  1106. * @param {string} themeName
  1107. * @param {IRangeThemeRangeInfo} rangeInfo
  1108. */
  1109. registerRangeThemeRule(e, t) {
  1110. const { unitId: o, subUnitId: s, range: r } = t, i = qt(), a = this._ensureRangeThemeStyleRuleMap(o), u = this._ensureRTreeCollection(o);
  1111. a.set(i, { rangeInfo: t, themeName: e }), u.insert({ unitId: o, sheetId: s, range: r, id: i });
  1112. }
  1113. getRegisteredRangeThemeStyle(e) {
  1114. const { unitId: t, subUnitId: o, range: s } = e, r = this._ensureRTreeCollection(t), i = Array.from(r.bulkSearch([{ unitId: t, sheetId: o, range: s }]));
  1115. if (i[0]) {
  1116. const u = this._ensureRangeThemeStyleRuleMap(t).get(i[0]);
  1117. if (u)
  1118. return u.themeName;
  1119. }
  1120. }
  1121. removeRangeThemeRule(e, t) {
  1122. const { unitId: o, subUnitId: s, range: r } = t, i = this._ensureRTreeCollection(o), a = Array.from(i.bulkSearch([{ unitId: o, sheetId: s, range: r }]));
  1123. if (a[0]) {
  1124. const u = this._ensureRangeThemeStyleRuleMap(o), l = u.get(a[0]);
  1125. l && l.themeName === e && (u.delete(a[0]), i.remove({ unitId: o, sheetId: s, range: r, id: a[0] }));
  1126. }
  1127. }
  1128. registerDefaultRangeTheme(e) {
  1129. this._defaultRangeThemeMap.set(e.getName(), e);
  1130. }
  1131. getRegisteredRangeThemes() {
  1132. return Array.from(this._defaultRangeThemeMap.keys());
  1133. }
  1134. /**
  1135. * Register custom range theme style.
  1136. * @param {string} unitId The unit id.
  1137. * @param {RangeThemeStyle} rangeThemeStyle The range theme style.
  1138. */
  1139. registerRangeThemeStyle(e, t) {
  1140. this._ensureRangeThemeStyleMap(e).set(t.getName(), t);
  1141. }
  1142. /**
  1143. * Unregister custom range theme style.
  1144. * @param {string} unitId The unit id.
  1145. * @param {string} name The name of the range theme style.
  1146. */
  1147. unregisterRangeThemeStyle(e, t) {
  1148. this._ensureRangeThemeStyleMap(e).delete(t);
  1149. }
  1150. /**
  1151. * Gets all custom register themes
  1152. * @return {string[]} The array of all custom registered themes.
  1153. */
  1154. getALLRegisteredTheme() {
  1155. return Array.from(this._rangeThemeStyleMap.keys());
  1156. }
  1157. getRangeThemeStyle(e, t) {
  1158. return this._defaultRangeThemeMap.has(t) ? this._defaultRangeThemeMap.get(t) : this._ensureRangeThemeStyleMap(e).get(t);
  1159. }
  1160. getCellStyle(e, t, o, s) {
  1161. const r = { startRow: o, startColumn: s, endRow: o, endColumn: s }, i = this._ensureRTreeCollection(e), a = Array.from(i.bulkSearch([{ unitId: e, sheetId: t, range: r }]));
  1162. if (a[0]) {
  1163. const l = this._ensureRangeThemeStyleRuleMap(e).get(a[0]);
  1164. if (l) {
  1165. const { rangeInfo: c, themeName: d } = l, h = o - c.range.startRow, m = s - c.range.startColumn;
  1166. return this.getRangeThemeStyle(e, d).getStyle(h, m, o === c.range.endRow, s === c.range.endColumn);
  1167. }
  1168. }
  1169. }
  1170. _registerIntercept() {
  1171. this.disposeWithMe(this._sheetInterceptorService.intercept(et.CELL_CONTENT, {
  1172. id: Ns,
  1173. effect: Vn.Style,
  1174. handler: (e, t, o) => {
  1175. const { row: s, col: r, unitId: i, subUnitId: a } = t, u = this.getCellStyle(i, a, s, r);
  1176. if (u) {
  1177. const l = { ...e };
  1178. return l.themeStyle = u, o(l);
  1179. }
  1180. return o(e);
  1181. }
  1182. }));
  1183. }
  1184. toJson(e) {
  1185. const t = this._ensureRangeThemeStyleRuleMap(e), o = this._ensureRangeThemeStyleMap(e);
  1186. if (o.size === 0 && t.size === 0)
  1187. return "{}";
  1188. const s = {};
  1189. t.forEach((i, a) => {
  1190. s[a] = i;
  1191. });
  1192. const r = {};
  1193. return o.forEach((i, a) => {
  1194. r[a] = i.toJson();
  1195. }), JSON.stringify({
  1196. rangeThemeStyleRuleMap: s,
  1197. rangeThemeStyleMapJson: r
  1198. });
  1199. }
  1200. fromJSON(e) {
  1201. const { rangeThemeStyleRuleMap: t, rangeThemeStyleMapJson: o } = e;
  1202. this._rangeThemeStyleMap.clear(), this._rangeThemeStyleRuleMap.clear(), this._rTreeCollection.clear(), !(!t || !o) && (Object.keys(t).forEach((s) => {
  1203. const r = t[s], { themeName: i, rangeInfo: a } = r;
  1204. this.registerRangeThemeRule(i, a), this._ensureRTreeCollection(a.unitId).insert({ unitId: s, sheetId: a.subUnitId, range: a.range, id: s });
  1205. }), Object.keys(o).forEach((s) => {
  1206. const r = o[s], i = new yt(r.name);
  1207. i.fromJson(r), this._ensureRangeThemeStyleMap(s).set(i.getName(), i);
  1208. }));
  1209. }
  1210. deleteUnitId(e) {
  1211. this._rangeThemeStyleMap.delete(e), this._rangeThemeStyleRuleMap.delete(e), this._rTreeCollection.delete(e);
  1212. }
  1213. _initSnapshot() {
  1214. this.disposeWithMe(this._resourceManagerService.registerPluginResource({
  1215. toJson: (e) => this.toJson(e),
  1216. parseJson: (e) => {
  1217. if (!e)
  1218. return {};
  1219. try {
  1220. return JSON.parse(e);
  1221. } catch {
  1222. return {};
  1223. }
  1224. },
  1225. businesses: [Fe.UNIVER_SHEET],
  1226. pluginName: Ia,
  1227. onLoad: (e, t) => {
  1228. this.fromJSON(t);
  1229. },
  1230. onUnLoad: (e) => {
  1231. this.deleteUnitId(e);
  1232. }
  1233. }));
  1234. }
  1235. dispose() {
  1236. super.dispose(), this._rangeThemeStyleMap.clear(), this._rangeThemeStyleRuleMap.clear(), this._defaultRangeThemeMap.clear(), this._rTreeCollection.clear();
  1237. }
  1238. };
  1239. He = wa([
  1240. Ko2(0, ot(V)),
  1241. Ko2(1, ot(Bi))
  1242. ], He);
  1243. function va(n, e) {
  1244. const { unitId: t } = e, o = t ? n.getUniverSheetInstance(t) : n.getCurrentUnitForType(Fe.UNIVER_SHEET);
  1245. return o ? {
  1246. workbook: o,
  1247. unitId: o.getUnitId()
  1248. } : null;
  1249. }
  1250. function N(n, e = {}) {
  1251. const { unitId: t, subUnitId: o } = e, s = t ? n.getUniverSheetInstance(t) : n.getCurrentUnitForType(Fe.UNIVER_SHEET);
  1252. if (!s)
  1253. return null;
  1254. const r = o ? s.getSheetBySheetId(o) : s.getActiveSheet(true);
  1255. return r ? {
  1256. worksheet: r,
  1257. workbook: s,
  1258. unitId: s.getUnitId(),
  1259. subUnitId: r.getSheetId()
  1260. } : null;
  1261. }
  1262. function Et(n, e) {
  1263. const { unitId: t, subUnitId: o } = e, s = n.getUniverSheetInstance(t);
  1264. if (!s)
  1265. return null;
  1266. const r = s.getSheetBySheetId(o);
  1267. return r ? {
  1268. worksheet: r,
  1269. workbook: s
  1270. } : null;
  1271. }
  1272. var zt = {
  1273. id: "sheet.mutation.set-worksheet-range-theme-style",
  1274. type: ar.MUTATION,
  1275. handler: (n, e) => {
  1276. const { unitId: t, subUnitId: o, range: s, themeName: r } = e, i = n.get(_n), a = N(i), u = n.get(He);
  1277. return a ? (u.registerRangeThemeRule(r, { range: s, unitId: t, subUnitId: o }), true) : false;
  1278. }
  1279. };
  1280. var Ma = (n, e) => {
  1281. const t = Et(n.get(_n), e);
  1282. if (!t)
  1283. throw new Error("[SetWorksheetRangeThemeStyleMutation]: worksheet is null error!");
  1284. const { worksheet: o } = t;
  1285. return {
  1286. unitId: e.unitId,
  1287. subUnitId: o.getSheetId(),
  1288. range: e.range,
  1289. themeName: e.themeName
  1290. };
  1291. };
  1292. var Kt = {
  1293. id: "sheet.mutation.remove-worksheet-range-theme-style",
  1294. type: ar.MUTATION,
  1295. handler: (n, e) => {
  1296. const { unitId: t, subUnitId: o, range: s, themeName: r } = e, i = n.get(_n), a = N(i), u = n.get(He);
  1297. return a ? (u.removeRangeThemeRule(r, { range: s, unitId: t, subUnitId: o }), true) : false;
  1298. }
  1299. };
  1300. var _a = (n, e) => {
  1301. const t = Et(n.get(_n), e);
  1302. if (!t)
  1303. throw new Error("[DeleteWorksheetRangeThemeStyleMutationFactory]: worksheet is null error!");
  1304. const { worksheet: o } = t;
  1305. return {
  1306. unitId: e.unitId,
  1307. subUnitId: o.getSheetId(),
  1308. range: e.range,
  1309. themeName: e.themeName
  1310. };
  1311. };
  1312. var ba = {
  1313. type: ar.COMMAND,
  1314. id: "sheet.command.set-worksheet-range-theme-style",
  1315. handler: (n, e) => {
  1316. const t = n.get(Pt), o = n.get(cn), { unitId: s } = e, r = Ma(n, e);
  1317. return t.syncExecuteCommand(zt.id, e) ? (o.pushUndoRedo({
  1318. unitID: s,
  1319. undoMutations: [{ id: Kt.id, params: r }],
  1320. redoMutations: [{ id: zt.id, params: e }]
  1321. }), true) : false;
  1322. }
  1323. };
  1324. var ya = (n, e, t = "") => n.reduce(
  1325. (o, s) => {
  1326. const r = s && s[e];
  1327. return typeof r != "string" ? (console.warn(s, `${e} is not string`), o) : (r ? (o[r] || (o[r] = []), o[r].push(s)) : o[t].push(s), o);
  1328. },
  1329. {}
  1330. );
  1331. var Ea = (n = 0) => {
  1332. let e = n;
  1333. return function() {
  1334. return e++;
  1335. };
  1336. };
  1337. function Os(n) {
  1338. const e = new kt();
  1339. return n.forEach((t) => {
  1340. const { startRow: o, startColumn: s, endRow: r, endColumn: i } = t;
  1341. for (let a = o; a <= r; a++)
  1342. for (let u = s; u <= i; u++)
  1343. e.setValue(a, u, null);
  1344. }), e.clone();
  1345. }
  1346. function Ua(n) {
  1347. const e = new kt();
  1348. return n.forEach((t) => {
  1349. const { startRow: o, startColumn: s, endRow: r, endColumn: i } = t;
  1350. for (let a = o; a <= r; a++)
  1351. for (let u = s; u <= i; u++)
  1352. e.setValue(a, u, {
  1353. v: null,
  1354. p: null,
  1355. f: null,
  1356. si: null,
  1357. custom: null
  1358. });
  1359. }), e.clone();
  1360. }
  1361. function Pa(n) {
  1362. const e = new kt();
  1363. return n.forEach((t) => {
  1364. const { startRow: o, startColumn: s, endRow: r, endColumn: i } = t;
  1365. for (let a = o; a <= r; a++)
  1366. for (let u = s; u <= i; u++)
  1367. e.setValue(a, u, {
  1368. s: null
  1369. });
  1370. }), e.clone();
  1371. }
  1372. var Ce = ((n) => (n[n.MOVE_START = 0] = "MOVE_START", n[n.MOVING = 1] = "MOVING", n[n.MOVE_END = 2] = "MOVE_END", n[n.ONLY_SET = 3] = "ONLY_SET", n))(Ce || {});
  1373. var Ta = class extends nt {
  1374. constructor(t) {
  1375. super();
  1376. R(this, "_worksheetSelections", /* @__PURE__ */ new Map());
  1377. R(this, "_selectionMoveStart$", new Subject());
  1378. R(this, "selectionMoveStart$", this._selectionMoveStart$.asObservable());
  1379. R(this, "_selectionMoving$", new Subject());
  1380. R(this, "selectionMoving$", this._selectionMoving$.asObservable());
  1381. R(this, "_selectionMoveEnd$", new BehaviorSubject([]));
  1382. R(this, "selectionMoveEnd$", this._selectionMoveEnd$.asObservable());
  1383. R(this, "_selectionSet$", new BehaviorSubject([]));
  1384. R(this, "selectionSet$", this._selectionSet$.asObservable());
  1385. R(this, "selectionChanged$");
  1386. R(this, "_beforeSelectionMoveEnd$", new BehaviorSubject([]));
  1387. R(this, "beforeSelectionMoveEnd$", this._beforeSelectionMoveEnd$.asObservable());
  1388. this._workbook = t, this.selectionChanged$ = merge(this._selectionMoveEnd$, this._selectionSet$);
  1389. }
  1390. dispose() {
  1391. super.dispose(), this._beforeSelectionMoveEnd$.complete(), this._selectionMoveEnd$.complete(), this._selectionMoving$.complete(), this._selectionMoveStart$.complete(), this._selectionSet$.complete();
  1392. }
  1393. addSelections(t, o) {
  1394. const s = this.getSelectionsOfWorksheet(t);
  1395. s.push(...o), this._selectionSet$.next(s);
  1396. }
  1397. /**
  1398. * Set selectionDatas to _worksheetSelections, and emit selectionDatas by type.
  1399. * @param sheetId
  1400. * @param selectionDatas
  1401. * @param type
  1402. */
  1403. setSelections(t, o = [], s) {
  1404. switch (this.setSelectionsOfWorksheet(t, o), s) {
  1405. case Ce.MOVE_START:
  1406. this._selectionMoveStart$.next(o);
  1407. break;
  1408. case Ce.MOVING:
  1409. this._selectionMoving$.next(o);
  1410. break;
  1411. case Ce.MOVE_END:
  1412. this._beforeSelectionMoveEnd$.next(o), this._selectionMoveEnd$.next(o);
  1413. break;
  1414. case Ce.ONLY_SET: {
  1415. this._selectionSet$.next(o);
  1416. break;
  1417. }
  1418. default:
  1419. this._selectionSet$.next(o);
  1420. break;
  1421. }
  1422. }
  1423. getCurrentSelections() {
  1424. return this._getCurrentSelections();
  1425. }
  1426. /**
  1427. * @deprecated use `getSelectionsOfWorksheet` instead.
  1428. * @param sheetId
  1429. * @returns
  1430. */
  1431. getSelectionOfWorksheet(t) {
  1432. return this.getSelectionsOfWorksheet(t);
  1433. }
  1434. getSelectionsOfWorksheet(t) {
  1435. return this._worksheetSelections.has(t) || this._worksheetSelections.set(t, []), this._worksheetSelections.get(t);
  1436. }
  1437. setSelectionsOfWorksheet(t, o) {
  1438. this._worksheetSelections.set(t, [...o]);
  1439. }
  1440. deleteSheetSelection(t) {
  1441. this._worksheetSelections.set(t, []);
  1442. }
  1443. /** Clear all selections in this workbook. */
  1444. clear() {
  1445. this._worksheetSelections.clear(), this._selectionSet$.next([]);
  1446. }
  1447. _getCurrentSelections() {
  1448. return this.getSelectionsOfWorksheet(this._workbook.getActiveSheet().getSheetId());
  1449. }
  1450. getCurrentLastSelection() {
  1451. const t = this._getCurrentSelections();
  1452. return t[t.length - 1];
  1453. }
  1454. };
  1455. var ka = Object.defineProperty;
  1456. var Na = Object.getOwnPropertyDescriptor;
  1457. var Oa = (n, e, t, o) => {
  1458. for (var s = o > 1 ? void 0 : o ? Na(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  1459. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  1460. return o && s && ka(e, t, s), s;
  1461. };
  1462. var Da = (n, e) => (t, o) => e(t, o, n);
  1463. var F = class extends J0 {
  1464. constructor(e) {
  1465. super();
  1466. R(this, "selectionMoveStart$");
  1467. R(this, "selectionMoving$");
  1468. R(this, "selectionMoveEnd$");
  1469. R(this, "selectionSet$");
  1470. R(this, "selectionChanged$");
  1471. R(this, "_workbookSelections", /* @__PURE__ */ new Map());
  1472. this._instanceSrv = e, this._init();
  1473. }
  1474. get _currentSelectionPos() {
  1475. const e = this._instanceSrv.getCurrentUnitForType(Fe.UNIVER_SHEET);
  1476. if (!e)
  1477. return null;
  1478. const t = e.getActiveSheet();
  1479. return { unitId: e.getUnitId(), sheetId: t.getSheetId() };
  1480. }
  1481. get currentSelectionParam() {
  1482. return this._currentSelectionPos;
  1483. }
  1484. _init() {
  1485. const e = this._instanceSrv.getCurrentTypeOfUnit$(Fe.UNIVER_SHEET).pipe(shareReplay(1), takeUntil(this.dispose$));
  1486. this.selectionMoveStart$ = e.pipe(switchMap((t) => t ? this._ensureWorkbookSelection(t.getUnitId()).selectionMoveStart$ : of())), this.selectionMoving$ = e.pipe(switchMap((t) => t ? this._ensureWorkbookSelection(t.getUnitId()).selectionMoving$ : of())), this.selectionMoveEnd$ = e.pipe(switchMap((t) => t ? this._ensureWorkbookSelection(t.getUnitId()).selectionMoveEnd$ : of([]))), this.selectionSet$ = e.pipe(switchMap((t) => t ? this._ensureWorkbookSelection(t.getUnitId()).selectionSet$ : of([]))), this.selectionChanged$ = e.pipe(switchMap((t) => t ? this._ensureWorkbookSelection(t.getUnitId()).selectionChanged$ : of([]))).pipe(
  1487. distinctUntilChanged((t, o) => t.length !== o.length ? false : t.length === 0 && o.length === 0 ? true : t.every((s, r) => JSON.stringify(s) === JSON.stringify(o[r]))),
  1488. skip(1)
  1489. ), this._instanceSrv.getTypeOfUnitDisposed$(Fe.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((t) => {
  1490. this._removeWorkbookSelection(t.getUnitId());
  1491. });
  1492. }
  1493. /**
  1494. * Clear all selections in all workbooks.
  1495. * invoked by prompt.controller
  1496. */
  1497. clear() {
  1498. this._workbookSelections.forEach((e) => e.clear());
  1499. }
  1500. getCurrentSelections() {
  1501. return this._getCurrentSelections();
  1502. }
  1503. getCurrentLastSelection() {
  1504. const e = this._getCurrentSelections();
  1505. return e == null ? void 0 : e[e.length - 1];
  1506. }
  1507. addSelections(e, t, o) {
  1508. if (typeof e == "string") {
  1509. this._ensureWorkbookSelection(e).addSelections(t, o);
  1510. return;
  1511. }
  1512. const s = this._currentSelectionPos;
  1513. if (!s)
  1514. throw new Error("[SheetsSelectionsService]: cannot find current selection position!");
  1515. const { unitId: r, sheetId: i } = s;
  1516. this._ensureWorkbookSelection(r).addSelections(i, e);
  1517. }
  1518. setSelections(e, t, o, s) {
  1519. if (typeof e == "string" && typeof t == "string") {
  1520. const u = e;
  1521. this._ensureWorkbookSelection(u).setSelections(
  1522. t,
  1523. o || [],
  1524. s != null ? s : Ce.ONLY_SET
  1525. );
  1526. return;
  1527. }
  1528. const r = this._currentSelectionPos;
  1529. if (!r)
  1530. throw new Error("[SheetsSelectionsService]: cannot find current selection position!");
  1531. const { unitId: i, sheetId: a } = r;
  1532. if (typeof e == "object") {
  1533. const u = e != null ? e : o, l = t != null ? t : Ce.ONLY_SET;
  1534. this._ensureWorkbookSelection(i).setSelections(a, u, l);
  1535. }
  1536. }
  1537. clearCurrentSelections() {
  1538. this._getCurrentSelections().splice(0);
  1539. }
  1540. /**
  1541. * Determine whether multiple current selections overlap
  1542. *
  1543. * @deprecated this should be extracted to an pure function
  1544. */
  1545. isOverlapping() {
  1546. const e = this.getCurrentSelections();
  1547. return e == null ? false : e.some(
  1548. ({ range: t }, o) => e.some(({ range: s }, r) => o === r ? false : t.startRow <= s.endRow && t.endRow >= s.startRow && t.startColumn <= s.endColumn && t.endColumn >= s.startColumn)
  1549. );
  1550. }
  1551. _getCurrentSelections() {
  1552. const e = this._currentSelectionPos;
  1553. if (!e)
  1554. return [];
  1555. const { unitId: t, sheetId: o } = e;
  1556. return this._ensureWorkbookSelection(t).getSelectionsOfWorksheet(o);
  1557. }
  1558. getWorkbookSelections(e) {
  1559. return this._ensureWorkbookSelection(e);
  1560. }
  1561. _ensureWorkbookSelection(e) {
  1562. let t = this._workbookSelections.get(e);
  1563. if (!t) {
  1564. const o = this._instanceSrv.getUnit(e);
  1565. if (!o)
  1566. throw new Error(`[SheetsSelectionsService]: cannot resolve unit with id "${e}"!`);
  1567. t = new Ta(o), this._workbookSelections.set(e, t);
  1568. }
  1569. return t;
  1570. }
  1571. _removeWorkbookSelection(e) {
  1572. this._workbookSelections.delete(e);
  1573. }
  1574. };
  1575. F = Oa([
  1576. Da(0, _n)
  1577. ], F);
  1578. var jd = "DISABLE_NORMAL_SELECTIONS";
  1579. var Gd = "SELECTIONS_ENABLED";
  1580. var Aa = "REF_SELECTIONS_ENABLED";
  1581. function xa(n, e, t) {
  1582. var i;
  1583. const o = n.getStyleByCell(e);
  1584. o == null && delete e.s, typeof t.s == "string" && (t.s = n.get(t.s));
  1585. const s = gn(o, t.s ? t.s : null);
  1586. s && (re.removeNull(s), Object.entries(s).forEach(([a, u]) => {
  1587. typeof u == "object" && u !== null && Object.keys(u).length === 0 && delete s[a];
  1588. })), re.isEmptyObject(s) ? delete e.s : e.s = n.setValue(s);
  1589. const r = t.v ? `${t.v}\r
  1590. ` : "";
  1591. !t.p && e.p && (r && r !== ((i = e.p.body) == null ? void 0 : i.dataStream) ? delete e.p : La(e.p, t.s ? t.s : null));
  1592. }
  1593. function $a(n, e) {
  1594. if (!e || !Object.keys(e).length)
  1595. return n;
  1596. const t = n || {};
  1597. for (const o in e)
  1598. o === "bd" ? t[o] = Wa(t[o] || {}, e[o]) : o in t || (t[o] = null);
  1599. return t;
  1600. }
  1601. function Wa(n, e) {
  1602. if (!e || !Object.keys(e).length)
  1603. return n;
  1604. for (const t in e)
  1605. t in n || (n[t] = null);
  1606. return n;
  1607. }
  1608. function gn(n, e, t = false) {
  1609. if (e === null)
  1610. return e;
  1611. if (e === void 0)
  1612. return n;
  1613. const o = re.deepClone(n) || {};
  1614. for (const s in e)
  1615. t && ["bd", "tr", "td", "ht", "vt", "tb", "pd", "bg"].includes(s) || (s in o && s === "bd" ? o[s] = Object.assign(o[s], e[s]) : o[s] = e[s]);
  1616. return "cl" in o && ("ul" in o && o.ul && (o.ul.cl = o.cl), "ol" in o && o.ol && (o.ol.cl = o.cl), "st" in o && o.st && (o.st.cl = o.cl)), o;
  1617. }
  1618. function Ds(n, e) {
  1619. return n.some((t) => t.startIndex === e) ? Ds(n, e + 1) : e;
  1620. }
  1621. function La(n, e) {
  1622. var i;
  1623. if (n.body == null)
  1624. return;
  1625. Array.isArray(n.body.textRuns) || (n.body.textRuns = []);
  1626. let t = 0;
  1627. const o = [], s = ((i = n.body) == null ? void 0 : i.paragraphs) || [];
  1628. for (const a of n.body.textRuns) {
  1629. const { st: u, ed: l, ts: c = {} } = a;
  1630. if (t < u) {
  1631. const h = {
  1632. st: t,
  1633. ed: u
  1634. }, m = gn({}, e, true);
  1635. m && re.removeNull(m), re.isEmptyObject(m) || (h.ts = m), o.push(h);
  1636. }
  1637. const d = gn(c, e, true);
  1638. d && re.removeNull(d), re.isEmptyObject(d) ? delete a.ts : a.ts = d, o.push(a), t = Ds(s, l);
  1639. }
  1640. const r = n.body.dataStream.endsWith(`\r
  1641. `) ? n.body.dataStream.length - 2 : n.body.dataStream.length;
  1642. if (t < r) {
  1643. const a = {
  1644. st: t,
  1645. ed: r
  1646. }, u = gn({}, e, true);
  1647. u && re.removeNull(u), re.isEmptyObject(u) || (a.ts = u), o.push(a);
  1648. }
  1649. n.body.textRuns = _s(o);
  1650. }
  1651. function Va(n, e, t) {
  1652. if (e.t)
  1653. return e.t;
  1654. if (e.v === null)
  1655. return null;
  1656. const o = n.getStyleByCell(e), s = n.getStyleByCell(t);
  1657. if (t.t === dn.FORCE_STRING) {
  1658. if (!Qn(s) && e.v !== void 0) {
  1659. if (DC(e.v))
  1660. return dn.NUMBER;
  1661. if (L0(`${e.v}`))
  1662. return dn.BOOLEAN;
  1663. }
  1664. return dn.FORCE_STRING;
  1665. }
  1666. return Ha(o) ? Qn(o) ? dn.STRING : Jo(e, t) : Qn(s) ? dn.STRING : Jo(e, t);
  1667. }
  1668. function Jo(n, e) {
  1669. return n.v !== void 0 ? Yo(n.v, n.t) : Yo(e.v, e.t);
  1670. }
  1671. function Ha(n) {
  1672. var e;
  1673. return !!((e = n == null ? void 0 : n.n) != null && e.pattern);
  1674. }
  1675. function Qn(n) {
  1676. var e;
  1677. return ((e = n == null ? void 0 : n.n) == null ? void 0 : e.pattern) === T;
  1678. }
  1679. function Yo(n, e) {
  1680. return n === null ? null : typeof n == "string" ? DC(n) ? (+n == 0 || +n == 1) && e === dn.BOOLEAN ? dn.BOOLEAN : dn.NUMBER : L0(n) ? dn.BOOLEAN : dn.STRING : typeof n == "number" ? (n === 0 || n === 1) && e === dn.BOOLEAN ? dn.BOOLEAN : dn.NUMBER : typeof n == "boolean" ? dn.BOOLEAN : dn.FORCE_STRING;
  1681. }
  1682. function Xo(n, e) {
  1683. return n === dn.NUMBER ? Number(e.v) : n === dn.BOOLEAN ? Ba(e.v) ? 1 : 0 : n === dn.STRING || n === dn.FORCE_STRING ? `${e.v}` : e.v;
  1684. }
  1685. function Ba(n) {
  1686. if (typeof n == "string") {
  1687. if (n.toUpperCase() === "TRUE")
  1688. return true;
  1689. if (n.toUpperCase() === "FALSE")
  1690. return false;
  1691. if (bR(n)) {
  1692. if (Number(n) === 0)
  1693. return false;
  1694. if (Number(n) === 1)
  1695. return true;
  1696. }
  1697. }
  1698. if (typeof n == "number") {
  1699. if (n === 0)
  1700. return false;
  1701. if (n === 1)
  1702. return true;
  1703. }
  1704. return typeof n == "boolean" ? n : null;
  1705. }
  1706. function Fa(n) {
  1707. return n == null ? null : (n.f === void 0 && (n.f = null), n.si === void 0 && (n.si = null), n.p === void 0 && (n.p = null), n.v === void 0 && (n.v = null), n.t === void 0 && (n.t = null), n.s === void 0 && (n.s = null), n.custom === void 0 && (n.custom = null), n);
  1708. }
  1709. var Ae = (n, e) => {
  1710. const { unitId: t, subUnitId: o, cellValue: s } = e, i = n.get(_n).getUniverSheetInstance(t);
  1711. if (i == null)
  1712. throw new Error("workbook is null error!");
  1713. const a = i.getSheetBySheetId(o);
  1714. if (a == null)
  1715. throw new Error("worksheet is null error!");
  1716. const u = a.getCellMatrix(), l = i.getStyles(), c = new kt();
  1717. return new kt(s).forValue((h, m, g2) => {
  1718. const f = re.deepClone(u == null ? void 0 : u.getValue(h, m)) || {}, p = l.getStyleByCell(f), C = l.getStyleByCell(g2);
  1719. f.s = $a(p, C), c.setValue(h, m, Fa(f));
  1720. }), {
  1721. ...e,
  1722. options: {},
  1723. cellValue: c.getMatrix()
  1724. };
  1725. };
  1726. var Q = {
  1727. id: "sheet.mutation.set-range-values",
  1728. type: ar.MUTATION,
  1729. handler: (n, e) => {
  1730. const { cellValue: t, subUnitId: o, unitId: s } = e, i = n.get(_n).getUnit(s);
  1731. if (!i)
  1732. return false;
  1733. const a = i.getSheetBySheetId(o);
  1734. if (!a)
  1735. return false;
  1736. const u = a.getCellMatrix(), l = i.getStyles();
  1737. return new kt(t).forValue((d, h, m) => {
  1738. if (!m)
  1739. u == null || u.setValue(d, h, {});
  1740. else {
  1741. const g2 = u.getValue(d, h) || {}, f = Va(l, m, g2);
  1742. m.f !== void 0 && (g2.f = m.f), m.si !== void 0 && (g2.si = m.si), m.p !== void 0 && (g2.p = m.p), m.v !== void 0 && (g2.v = Xo(f, m)), g2.v !== void 0 && (g2.t = f, g2.v = Xo(f, g2)), m.s !== void 0 && xa(l, g2, m), m.custom !== void 0 && (g2.custom = m.custom), u.setValue(d, h, re.removeNull(g2));
  1743. }
  1744. }), true;
  1745. }
  1746. };
  1747. var po = {
  1748. id: "sheet.command.clear-selection-all",
  1749. type: ar.COMMAND,
  1750. handler: (n, e) => {
  1751. var S;
  1752. const t = n.get(_n), o = n.get(Pt), s = n.get(F), r = n.get(cn), i = n.get(V), a = t.getCurrentUnitForType(Fe.UNIVER_SHEET);
  1753. if (!a)
  1754. return false;
  1755. const u = (e == null ? void 0 : e.unitId) || a.getUnitId(), l = a.getActiveSheet();
  1756. if (!l)
  1757. return false;
  1758. const c = (e == null ? void 0 : e.subUnitId) || l.getSheetId(), d = (e == null ? void 0 : e.ranges) || ((S = s.getCurrentSelections()) == null ? void 0 : S.map((I) => I.range));
  1759. if (!(d != null && d.length))
  1760. return false;
  1761. const h = [], m = [], g2 = {
  1762. subUnitId: c,
  1763. unitId: u,
  1764. cellValue: Os(d)
  1765. }, f = Ae(
  1766. n,
  1767. g2
  1768. );
  1769. h.push({
  1770. id: Q.id,
  1771. params: g2
  1772. }), m.push({
  1773. id: Q.id,
  1774. params: f
  1775. });
  1776. const p = i.onCommandExecute({ id: po.id });
  1777. return h.push(...p.redos), m.unshift(...p.undos), mu(h, o) ? (r.pushUndoRedo({
  1778. // If there are multiple mutations that form an encapsulated project, they must be encapsulated in the same undo redo element.
  1779. // Hooks can be used to hook the code of external controllers to add new actions.
  1780. unitID: u,
  1781. undoMutations: m,
  1782. redoMutations: h
  1783. }), true) : false;
  1784. }
  1785. };
  1786. var Co = {
  1787. id: "sheet.command.clear-selection-content",
  1788. type: ar.COMMAND,
  1789. handler: (n, e) => {
  1790. var S;
  1791. const t = n.get(_n), o = n.get(Pt), s = n.get(F), r = n.get(cn), i = n.get(V), a = t.getCurrentUnitForType(Fe.UNIVER_SHEET);
  1792. if (!a)
  1793. return false;
  1794. const u = (e == null ? void 0 : e.unitId) || a.getUnitId(), l = a.getActiveSheet();
  1795. if (!l)
  1796. return false;
  1797. const c = (e == null ? void 0 : e.subUnitId) || l.getSheetId(), d = (e == null ? void 0 : e.ranges) || ((S = s.getCurrentSelections()) == null ? void 0 : S.map((I) => I.range));
  1798. if (!(d != null && d.length))
  1799. return false;
  1800. const h = {
  1801. subUnitId: c,
  1802. unitId: u,
  1803. cellValue: Ua(d)
  1804. }, m = Ae(
  1805. n,
  1806. h
  1807. ), g2 = i.onCommandExecute({ id: Co.id }), f = [{ id: Q.id, params: h }, ...g2.redos], p = [...g2.undos, { id: Q.id, params: m }];
  1808. return mu(f, o).result ? (r.pushUndoRedo({
  1809. // If there are multiple mutations that form an encapsulated project, they must be encapsulated in the same undo redo element.
  1810. // Hooks can be used to hook the code of external controllers to add new actions.
  1811. unitID: u,
  1812. undoMutations: p,
  1813. redoMutations: f
  1814. }), true) : false;
  1815. }
  1816. };
  1817. var So = {
  1818. id: "sheet.command.clear-selection-format",
  1819. type: ar.COMMAND,
  1820. handler: (n, e) => {
  1821. var S;
  1822. const t = n.get(_n), o = n.get(Pt), s = n.get(F), r = n.get(cn), i = n.get(V), a = t.getCurrentUnitForType(Fe.UNIVER_SHEET);
  1823. if (!a)
  1824. return false;
  1825. const u = (e == null ? void 0 : e.unitId) || a.getUnitId(), l = a.getActiveSheet();
  1826. if (!l)
  1827. return false;
  1828. const c = (e == null ? void 0 : e.subUnitId) || l.getSheetId(), d = (e == null ? void 0 : e.ranges) || ((S = s.getCurrentSelections()) == null ? void 0 : S.map((I) => I.range));
  1829. if (!(d != null && d.length))
  1830. return false;
  1831. const h = [], m = [], g2 = {
  1832. subUnitId: c,
  1833. unitId: u,
  1834. cellValue: Pa(d)
  1835. }, f = Ae(
  1836. n,
  1837. g2
  1838. );
  1839. h.push({
  1840. id: Q.id,
  1841. params: g2
  1842. }), m.push({
  1843. id: Q.id,
  1844. params: f
  1845. });
  1846. const p = i.onCommandExecute({ id: So.id });
  1847. return h.push(...p.redos), m.unshift(...p.undos), mu(h, o) ? (r.pushUndoRedo({
  1848. // If there are multiple mutations that form an encapsulated project, they must be encapsulated in the same undo redo element.
  1849. // Hooks can be used to hook the code of external controllers to add new actions.
  1850. unitID: u,
  1851. undoMutations: m,
  1852. redoMutations: h
  1853. }), true) : false;
  1854. }
  1855. };
  1856. var As = (n, e) => ({
  1857. subUnitId: e.sheet.id,
  1858. unitId: e.unitId,
  1859. subUnitName: e.sheet.name
  1860. });
  1861. var Jt = {
  1862. id: "sheet.mutation.insert-sheet",
  1863. type: ar.MUTATION,
  1864. handler: (n, e) => {
  1865. const t = n.get(_n), { sheet: o, index: s, unitId: r } = e, i = t.getUniverSheetInstance(r);
  1866. return i ? i.addWorksheet(o.id, s, o) : false;
  1867. }
  1868. };
  1869. var ja = (n, e) => {
  1870. const t = n.get(_n), { subUnitId: o, unitId: s } = e, r = Et(t, e);
  1871. if (!r)
  1872. throw new Error("[RemoveSheetUndoMutationFactory]: Worksheet is null error!");
  1873. const { workbook: i, worksheet: a } = r, u = a.getConfig();
  1874. return {
  1875. index: i.getConfig().sheetOrder.findIndex((d) => d === o),
  1876. sheet: u,
  1877. unitId: s
  1878. };
  1879. };
  1880. var Ut = {
  1881. id: "sheet.mutation.remove-sheet",
  1882. type: ar.MUTATION,
  1883. handler: (n, e) => {
  1884. const t = n.get(_n), { subUnitId: o, unitId: s } = e, r = t.getUniverSheetInstance(s);
  1885. return r ? r.removeSheet(o) : false;
  1886. }
  1887. };
  1888. var xs = {
  1889. type: ar.COMMAND,
  1890. id: "sheet.command.copy-sheet",
  1891. handler: (n, e) => {
  1892. var w, b;
  1893. const t = n.get(Pt), o = n.get(cn), s = n.get(_n), r = n.get(V), i = n.get(Vr), a = N(s, e);
  1894. if (!a)
  1895. return false;
  1896. const { workbook: u, worksheet: l, unitId: c, subUnitId: d } = a, h = re.deepClone(l.getConfig());
  1897. h.name = Ga(u, i, h.name), h.id = re.generateRandomId();
  1898. const g2 = {
  1899. index: u.getSheetIndex(l) + 1,
  1900. sheet: h,
  1901. unitId: c
  1902. }, f = As(
  1903. n,
  1904. g2
  1905. ), p = r.onCommandExecute({
  1906. id: xs.id,
  1907. params: { unitId: c, subUnitId: d, targetSubUnitId: h.id }
  1908. }), C = [
  1909. ...(w = p.preRedos) != null ? w : [],
  1910. { id: Jt.id, params: g2 },
  1911. ...p.redos
  1912. ], S = [
  1913. ...(b = p.preUndos) != null ? b : [],
  1914. { id: Ut.id, params: f },
  1915. ...p.undos
  1916. ];
  1917. return mu(C, t).result ? (o.pushUndoRedo({
  1918. unitID: c,
  1919. undoMutations: S,
  1920. redoMutations: C
  1921. }), true) : false;
  1922. }
  1923. };
  1924. function Ga(n, e, t) {
  1925. let o = t + e.t("sheets.tabs.sheetCopy", ""), s = 2;
  1926. for (; n.checkSheetName(o); )
  1927. o = t + e.t("sheets.tabs.sheetCopy", `${s}`), s++;
  1928. return o;
  1929. }
  1930. var dt = {
  1931. id: "sheet.mutation.move-range",
  1932. type: ar.MUTATION,
  1933. handler: (n, e) => {
  1934. const { from: t, to: o } = e;
  1935. if (!t || !o)
  1936. return false;
  1937. const r = n.get(_n).getCurrentUnitForType(Fe.UNIVER_SHEET);
  1938. if (!r)
  1939. return false;
  1940. const i = r.getSheetBySheetId(e.from.subUnitId), a = r.getSheetBySheetId(e.to.subUnitId);
  1941. if (!i || !a)
  1942. return false;
  1943. const u = i.getCellMatrix(), l = a.getCellMatrix();
  1944. return new kt(t.value).forValue((c, d, h) => {
  1945. u.setValue(c, d, h);
  1946. }), new kt(o.value).forValue((c, d, h) => {
  1947. l.setValue(c, d, h);
  1948. }), true;
  1949. }
  1950. };
  1951. var za = Object.defineProperty;
  1952. var Ka = Object.getOwnPropertyDescriptor;
  1953. var Ja = (n, e, t, o) => {
  1954. for (var s = o > 1 ? void 0 : o ? Ka(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  1955. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  1956. return o && s && za(e, t, s), s;
  1957. };
  1958. var Ya = (n, e) => (t, o) => e(t, o, n);
  1959. var Xa = Ct("sheets-formula.ref-selections.service");
  1960. var qo = class extends F {
  1961. constructor(n) {
  1962. super(n);
  1963. }
  1964. _init() {
  1965. const n = this._getAliveWorkbooks$().pipe(takeUntil(this.dispose$));
  1966. this.selectionMoveStart$ = n.pipe(switchMap((e) => merge(...e.map((t) => t.selectionMoveStart$)))), this.selectionMoving$ = n.pipe(switchMap((e) => merge(...e.map((t) => t.selectionMoving$)))), this.selectionMoveEnd$ = n.pipe(switchMap((e) => merge(...e.map((t) => t.selectionMoveEnd$)))), this.selectionSet$ = n.pipe(switchMap((e) => merge(...e.map((t) => t.selectionSet$))));
  1967. }
  1968. _getAliveWorkbooks$() {
  1969. const n = this._instanceSrv.getAllUnitsForType(Fe.UNIVER_SHEET);
  1970. n.forEach((t) => this._ensureWorkbookSelection(t.getUnitId()));
  1971. const e = new BehaviorSubject(n);
  1972. return this.disposeWithMe(this._instanceSrv.getTypeOfUnitAdded$(Fe.UNIVER_SHEET).subscribe((t) => {
  1973. this._ensureWorkbookSelection(t.getUnitId()), e.next([...e.getValue(), t]);
  1974. })), this.disposeWithMe(this._instanceSrv.getTypeOfUnitDisposed$(Fe.UNIVER_SHEET).subscribe((t) => {
  1975. this._removeWorkbookSelection(t.getUnitId()), e.next(e.getValue().filter((o) => o !== t));
  1976. })), e.pipe(map((t) => t.map((o) => this._ensureWorkbookSelection(o.getUnitId()))));
  1977. }
  1978. };
  1979. qo = Ja([
  1980. Ya(0, _n)
  1981. ], qo);
  1982. function qa(n, e) {
  1983. const o = n.get(fs).getContextValue(Aa);
  1984. return n.get(o && !e ? Xa : F);
  1985. }
  1986. var re2 = {
  1987. id: "sheet.operation.set-selections",
  1988. type: ar.OPERATION,
  1989. handler: (n, e) => {
  1990. if (!e)
  1991. return false;
  1992. const { selections: t, type: o, unitId: s, subUnitId: r } = e;
  1993. return qa(n).setSelections(s, r, [...t], o), true;
  1994. }
  1995. };
  1996. function Ln(n, e, t = true) {
  1997. const o = e.getMatrixWithMergedCells(..._C(n)), s = [];
  1998. if (o.forValue((i, a, u) => {
  1999. if (u.colSpan !== void 0 && u.rowSpan !== void 0) {
  2000. const l = {
  2001. startRow: i,
  2002. startColumn: a,
  2003. endRow: i + u.rowSpan - 1,
  2004. endColumn: a + u.colSpan - 1
  2005. };
  2006. en.contains(n, l) || s.push(l);
  2007. }
  2008. }), s.length === 0)
  2009. return n;
  2010. const r = en.union(n, ...s);
  2011. return t ? Ln(r, e, t) : r;
  2012. }
  2013. function zd(n, e, t) {
  2014. let o = null;
  2015. return t.getMatrixWithMergedCells(n, e, n, e).forValue((r, i, a) => (o = {
  2016. actualRow: r,
  2017. actualColumn: i,
  2018. startRow: r,
  2019. startColumn: i,
  2020. isMerged: a.rowSpan !== void 0 || a.colSpan !== void 0,
  2021. isMergedMainCell: a.rowSpan !== void 0 && a.colSpan !== void 0,
  2022. endRow: r + (a.rowSpan !== void 0 ? a.rowSpan - 1 : 0),
  2023. endColumn: i + (a.colSpan !== void 0 ? a.colSpan - 1 : 0),
  2024. rangeType: De.NORMAL
  2025. }, false)), o || {
  2026. actualColumn: e,
  2027. actualRow: n,
  2028. startRow: n,
  2029. startColumn: e,
  2030. endRow: n,
  2031. endColumn: e,
  2032. isMerged: false,
  2033. isMergedMainCell: false,
  2034. rangeType: De.NORMAL
  2035. };
  2036. }
  2037. function Kd(n, e, t) {
  2038. const { startRow: o, startColumn: s, endRow: r, endColumn: i } = n;
  2039. return Number.isNaN(o) && (n.startRow = 0), Number.isNaN(r) && (n.endRow = e - 1), Number.isNaN(s) && (n.startColumn = 0), Number.isNaN(i) && (n.endColumn = t - 1), n;
  2040. }
  2041. function ve(n, e) {
  2042. const t = Number.isNaN(n.startRow) ? 0 : n.startRow, o = Number.isNaN(n.startColumn) ? 0 : n.startColumn, s = e.getMergedCell(t, o);
  2043. return s ? {
  2044. ...s,
  2045. actualRow: t,
  2046. actualColumn: o,
  2047. rangeType: De.NORMAL,
  2048. isMerged: true,
  2049. isMergedMainCell: true
  2050. } : {
  2051. startRow: t,
  2052. startColumn: o,
  2053. endRow: n.startRow,
  2054. endColumn: n.startColumn,
  2055. actualRow: t,
  2056. actualColumn: o,
  2057. rangeType: De.NORMAL,
  2058. isMerged: false,
  2059. isMergedMainCell: false
  2060. };
  2061. }
  2062. var Xe2 = (n, e, t) => ({
  2063. id: re2.id,
  2064. params: {
  2065. unitId: e.getUnitId(),
  2066. subUnitId: t.getSheetId(),
  2067. reveal: true,
  2068. selections: [{ range: n, primary: ve(n, t) }]
  2069. }
  2070. });
  2071. function Jd(n) {
  2072. if (!n)
  2073. return false;
  2074. const { range: e, primary: t } = n;
  2075. return en.equals(e, t);
  2076. }
  2077. function Za(n) {
  2078. function e(t, o) {
  2079. function s(r) {
  2080. for (let i = r.startRow; i <= r.endRow; i++)
  2081. if (!n.getRowFiltered(i))
  2082. for (let a = r.startColumn; a <= r.endColumn; a++)
  2083. o(i, a, r);
  2084. }
  2085. s(t);
  2086. }
  2087. return {
  2088. forOperableEach: e
  2089. };
  2090. }
  2091. var Zo = (n) => n.id !== Ns;
  2092. function Vn2(n, e, t, o, s, r, i) {
  2093. const a = {};
  2094. for (let u = e; u <= t; u++)
  2095. for (let l = o; l <= s; l++) {
  2096. const c = r ? n.getCellWithFilteredInterceptors(i, l, jo, Zo) : n.getCellWithFilteredInterceptors(u, i, jo, Zo);
  2097. !c || !c.s || (a[u] || (a[u] = {}), a[u][l] = { s: c.s });
  2098. }
  2099. return a;
  2100. }
  2101. var $s = "sheet.command.move-range";
  2102. var pt = {
  2103. type: ar.COMMAND,
  2104. id: $s,
  2105. handler: async (n, e) => {
  2106. var I, w;
  2107. const t = n.get(Pt), o = n.get(cn), s = n.get(_n), r = n.get(NE), i = n.get(Vr), a = n.get(V), u = N(s);
  2108. if (!u || !await a.beforeCommandExecute({ id: pt.id, params: e }))
  2109. return false;
  2110. const { worksheet: c, subUnitId: d, unitId: h } = u, m = wo2(
  2111. n,
  2112. { unitId: h, subUnitId: d, range: e.fromRange },
  2113. { unitId: h, subUnitId: d, range: e.toRange }
  2114. );
  2115. if (m === null)
  2116. return r.emit(i.t("sheets.info.acrossMergedCell")), false;
  2117. const g2 = a.onCommandExecute({
  2118. id: pt.id,
  2119. params: { ...e }
  2120. }), f = [
  2121. ...(I = g2.preRedos) != null ? I : [],
  2122. ...m.redos,
  2123. ...g2.redos,
  2124. {
  2125. id: re2.id,
  2126. params: {
  2127. unitId: h,
  2128. subUnitId: d,
  2129. selections: [{ range: e.toRange, primary: Qa(e.fromRange, e.toRange, c) }],
  2130. type: Ce.MOVE_END
  2131. }
  2132. }
  2133. ], p = [
  2134. ...(w = g2.preUndos) != null ? w : [],
  2135. ...m.undos,
  2136. ...g2.undos,
  2137. {
  2138. id: re2.id,
  2139. params: {
  2140. unitId: h,
  2141. subUnitId: d,
  2142. selections: [{ range: e.fromRange, primary: ve(e.fromRange, c) }],
  2143. type: Ce.MOVE_END
  2144. }
  2145. }
  2146. ], C = mu(f, t).result, S = a.afterCommandExecute({
  2147. id: pt.id,
  2148. params: { ...e }
  2149. });
  2150. return C ? (mu(S.redos, t), o.pushUndoRedo({
  2151. unitID: h,
  2152. undoMutations: [...p, ...S.undos],
  2153. redoMutations: [...f, ...S.redos]
  2154. }), true) : false;
  2155. }
  2156. };
  2157. function wo2(n, e, t, o = false) {
  2158. const s = [], r = [], { range: i, subUnitId: a, unitId: u } = e, { range: l, subUnitId: c } = t, h = n.get(_n).getUniverSheetInstance(u), m = h == null ? void 0 : h.getSheetBySheetId(c), g2 = h == null ? void 0 : h.getSheetBySheetId(a), f = m == null ? void 0 : m.getCellMatrix(), p = g2 == null ? void 0 : g2.getCellMatrix();
  2159. if (m && g2 && f && p) {
  2160. const C = Ln(l, m, false);
  2161. if (!en.equals(l, C) && !o)
  2162. return null;
  2163. const S = new kt(), I = new kt(), w = new kt();
  2164. tr.foreach(i, (U, P) => {
  2165. const A = p.getValue(U, P);
  2166. if (S.setValue(U, P, re.deepClone(A)), A) {
  2167. const j = h == null ? void 0 : h.getStyles().get(A.s);
  2168. w.setValue(U, P, re.deepClone(j));
  2169. }
  2170. I.setValue(U, P, null);
  2171. });
  2172. const b = new kt(), y = new kt();
  2173. tr.foreach(l, (U, P) => {
  2174. b.setValue(U, P, re.deepClone(f.getValue(U, P)));
  2175. }), tr.foreach(i, (U, P) => {
  2176. const A = AC(U, P), j = en.getRelativeRange(A, i), Z = en.getPositionRange(j, l), Y = re.deepClone(w.getValue(U, P)), ee = re.deepClone(S.getValue(U, P));
  2177. ee && Y && (ee.s = Y), y.setValue(Z.startRow, Z.startColumn, ee);
  2178. });
  2179. const x = {
  2180. fromRange: e.range,
  2181. toRange: t.range,
  2182. from: {
  2183. value: I.getMatrix(),
  2184. subUnitId: a
  2185. },
  2186. to: {
  2187. value: y.getMatrix(),
  2188. subUnitId: c
  2189. },
  2190. unitId: u
  2191. }, T2 = {
  2192. fromRange: t.range,
  2193. toRange: e.range,
  2194. from: {
  2195. value: S.getMatrix(),
  2196. subUnitId: a
  2197. },
  2198. to: {
  2199. value: b.getMatrix(),
  2200. subUnitId: c
  2201. },
  2202. unitId: u
  2203. };
  2204. s.push({ id: dt.id, params: x }), r.push({ id: dt.id, params: T2 });
  2205. }
  2206. return {
  2207. redos: s,
  2208. undos: r
  2209. };
  2210. }
  2211. function Qa(n, e, t) {
  2212. const o = n.startRow, s = n.startColumn, r = t.getMergedCell(o, s), i = ve(e, t);
  2213. if (r) {
  2214. const a = r.endRow - r.startRow + 1, u = r.endColumn - r.startColumn + 1;
  2215. i.endRow = i.startRow + a - 1, i.endColumn = i.startColumn + u - 1, i.actualRow = i.startRow, i.actualColumn = i.startColumn, i.isMerged = false, i.isMergedMainCell = true;
  2216. }
  2217. return i;
  2218. }
  2219. var Sn = ((n) => (n[n.UNIVER_UNKNOWN = 0] = "UNIVER_UNKNOWN", n[n.UNIVER_DOC = 1] = "UNIVER_DOC", n[n.UNIVER_SHEET = 2] = "UNIVER_SHEET", n[n.UNIVER_SLIDE = 3] = "UNIVER_SLIDE", n[n.UNIVER_PROJECT = 4] = "UNIVER_PROJECT", n[n.UNRECOGNIZED = -1] = "UNRECOGNIZED", n))(Sn || {});
  2220. var _ = ((n) => (n[n.View = 0] = "View", n[n.Edit = 1] = "Edit", n[n.ManageCollaborator = 2] = "ManageCollaborator", n[n.Print = 3] = "Print", n[n.Duplicate = 4] = "Duplicate", n[n.Comment = 5] = "Comment", n[n.Copy = 6] = "Copy", n[n.Share = 7] = "Share", n[n.Export = 8] = "Export", n[n.MoveWorksheet = 9] = "MoveWorksheet", n[n.DeleteWorksheet = 10] = "DeleteWorksheet", n[n.HideWorksheet = 11] = "HideWorksheet", n[n.RenameWorksheet = 12] = "RenameWorksheet", n[n.CreateWorksheet = 13] = "CreateWorksheet", n[n.SetWorksheetStyle = 14] = "SetWorksheetStyle", n[n.EditWorksheetCell = 15] = "EditWorksheetCell", n[n.InsertHyperlink = 16] = "InsertHyperlink", n[n.Sort = 17] = "Sort", n[n.Filter = 18] = "Filter", n[n.PivotTable = 19] = "PivotTable", n[n.FloatImg = 20] = "FloatImg", n[n.History = 21] = "History", n[n.RwHgtClWdt = 22] = "RwHgtClWdt", n[n.ViemRwHgtClWdt = 23] = "ViemRwHgtClWdt", n[n.ViewFilter = 24] = "ViewFilter", n[n.MoveSheet = 25] = "MoveSheet", n[n.DeleteSheet = 26] = "DeleteSheet", n[n.HideSheet = 27] = "HideSheet", n[n.CopySheet = 28] = "CopySheet", n[n.RenameSheet = 29] = "RenameSheet", n[n.CreateSheet = 30] = "CreateSheet", n[n.SelectProtectedCells = 31] = "SelectProtectedCells", n[n.SelectUnProtectedCells = 32] = "SelectUnProtectedCells", n[n.SetCellStyle = 33] = "SetCellStyle", n[n.SetCellValue = 34] = "SetCellValue", n[n.SetRowStyle = 35] = "SetRowStyle", n[n.SetColumnStyle = 36] = "SetColumnStyle", n[n.InsertRow = 37] = "InsertRow", n[n.InsertColumn = 38] = "InsertColumn", n[n.DeleteRow = 39] = "DeleteRow", n[n.DeleteColumn = 40] = "DeleteColumn", n[n.EditExtraObject = 41] = "EditExtraObject", n[n.Delete = 42] = "Delete", n[n.RecoverHistory = 43] = "RecoverHistory", n[n.ViewHistory = 44] = "ViewHistory", n[n.CreatePermissionObject = 45] = "CreatePermissionObject", n[n.UNRECOGNIZED = -1] = "UNRECOGNIZED", n))(_ || {});
  2221. var D = ((n) => (n[n.Unkonwn = 0] = "Unkonwn", n[n.Workbook = 1] = "Workbook", n[n.Worksheet = 2] = "Worksheet", n[n.SelectRange = 3] = "SelectRange", n[n.Document = 4] = "Document", n[n.Slide = 5] = "Slide", n[n.UNRECOGNIZED = -1] = "UNRECOGNIZED", n))(D || {});
  2222. var Pe = class {
  2223. constructor(e, t, o) {
  2224. R(this, "type", D.SelectRange);
  2225. R(this, "subType", _.Edit);
  2226. R(this, "status", fl.INIT);
  2227. R(this, "value", true);
  2228. R(this, "id");
  2229. R(this, "unitId");
  2230. R(this, "subUnitId");
  2231. R(this, "permissionId");
  2232. this.unitId = e, this.subUnitId = t, this.permissionId = o, this.id = `${D.SelectRange}.${_.Edit}.${o}`;
  2233. }
  2234. };
  2235. var Io = class {
  2236. constructor(e, t, o) {
  2237. R(this, "type", D.SelectRange);
  2238. R(this, "subType", _.View);
  2239. R(this, "status", fl.INIT);
  2240. R(this, "value", true);
  2241. R(this, "id");
  2242. R(this, "unitId");
  2243. R(this, "subUnitId");
  2244. R(this, "permissionId");
  2245. this.unitId = e, this.subUnitId = t, this.permissionId = o, this.id = `${D.SelectRange}.${_.View}.${o}`;
  2246. }
  2247. };
  2248. var Ws = class {
  2249. constructor(e) {
  2250. R(this, "id");
  2251. R(this, "value", true);
  2252. R(this, "type", D.Workbook);
  2253. R(this, "status", fl.INIT);
  2254. R(this, "subType", _.Comment);
  2255. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.Comment}_${e}`;
  2256. }
  2257. };
  2258. var Ls = class {
  2259. constructor(e) {
  2260. R(this, "id");
  2261. R(this, "value", true);
  2262. R(this, "type", D.Workbook);
  2263. R(this, "status", fl.INIT);
  2264. R(this, "subType", _.Copy);
  2265. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.Copy}_${e}`;
  2266. }
  2267. };
  2268. var eu = class {
  2269. constructor(e) {
  2270. R(this, "id");
  2271. R(this, "value", true);
  2272. R(this, "type", D.Workbook);
  2273. R(this, "subType", _.CopySheet);
  2274. R(this, "status", fl.INIT);
  2275. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.CopySheet}_${e}`;
  2276. }
  2277. };
  2278. var Vs2 = class {
  2279. constructor(e) {
  2280. R(this, "id");
  2281. R(this, "value", true);
  2282. R(this, "type", D.Workbook);
  2283. R(this, "status", fl.INIT);
  2284. R(this, "subType", _.CreatePermissionObject);
  2285. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.CreatePermissionObject}_${e}`;
  2286. }
  2287. };
  2288. var Hs = class {
  2289. constructor(e) {
  2290. R(this, "id");
  2291. R(this, "value", true);
  2292. R(this, "type", D.Workbook);
  2293. R(this, "status", fl.INIT);
  2294. R(this, "subType", _.CreateSheet);
  2295. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.CreateSheet}_${e}`;
  2296. }
  2297. };
  2298. var Bs = class {
  2299. constructor(e) {
  2300. R(this, "id");
  2301. R(this, "value", true);
  2302. R(this, "type", D.Workbook);
  2303. R(this, "status", fl.INIT);
  2304. R(this, "subType", _.DeleteSheet);
  2305. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.DeleteSheet}_${e}`;
  2306. }
  2307. };
  2308. var Fs = class {
  2309. constructor(e) {
  2310. R(this, "id");
  2311. R(this, "value", true);
  2312. R(this, "type", D.Workbook);
  2313. R(this, "status", fl.INIT);
  2314. R(this, "subType", _.Duplicate);
  2315. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.Duplicate}_${e}`;
  2316. }
  2317. };
  2318. var Me = class {
  2319. constructor(e) {
  2320. R(this, "id");
  2321. R(this, "value", true);
  2322. R(this, "type", D.Workbook);
  2323. R(this, "status", fl.INIT);
  2324. R(this, "subType", _.Edit);
  2325. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.Edit}_${e}`;
  2326. }
  2327. };
  2328. var js = class {
  2329. constructor(e) {
  2330. R(this, "id");
  2331. R(this, "value", true);
  2332. R(this, "type", D.Workbook);
  2333. R(this, "status", fl.INIT);
  2334. R(this, "subType", _.Export);
  2335. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.Export}_${e}`;
  2336. }
  2337. };
  2338. var vo = class {
  2339. constructor(e) {
  2340. R(this, "id");
  2341. R(this, "value", true);
  2342. R(this, "type", D.Workbook);
  2343. R(this, "status", fl.INIT);
  2344. R(this, "subType", _.HideSheet);
  2345. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.HideSheet}_${e}`;
  2346. }
  2347. };
  2348. var tu = class {
  2349. constructor(e) {
  2350. R(this, "id");
  2351. R(this, "value", true);
  2352. R(this, "type", D.Workbook);
  2353. R(this, "status", fl.INIT);
  2354. R(this, "subType", _.History);
  2355. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.History}_${e}`;
  2356. }
  2357. };
  2358. var Mo = class {
  2359. constructor(e) {
  2360. R(this, "id");
  2361. R(this, "value", true);
  2362. R(this, "type", D.Workbook);
  2363. R(this, "status", fl.INIT);
  2364. R(this, "subType", _.ManageCollaborator);
  2365. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.ManageCollaborator}_${e}`;
  2366. }
  2367. };
  2368. var _o = class {
  2369. constructor(e) {
  2370. R(this, "id");
  2371. R(this, "value", true);
  2372. R(this, "type", D.Workbook);
  2373. R(this, "status", fl.INIT);
  2374. R(this, "subType", _.MoveSheet);
  2375. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.MoveSheet}_${e}`;
  2376. }
  2377. };
  2378. var Gs2 = class {
  2379. constructor(e) {
  2380. R(this, "id");
  2381. R(this, "value", true);
  2382. R(this, "type", D.Workbook);
  2383. R(this, "status", fl.INIT);
  2384. R(this, "subType", _.Print);
  2385. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.Print}_${e}`;
  2386. }
  2387. };
  2388. var zs = class {
  2389. constructor(e) {
  2390. R(this, "id");
  2391. R(this, "value", true);
  2392. R(this, "type", D.Workbook);
  2393. R(this, "status", fl.INIT);
  2394. R(this, "subType", _.RecoverHistory);
  2395. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.RecoverHistory}_${e}`;
  2396. }
  2397. };
  2398. var bo = class {
  2399. constructor(e) {
  2400. R(this, "id");
  2401. R(this, "value", true);
  2402. R(this, "type", D.Workbook);
  2403. R(this, "status", fl.INIT);
  2404. R(this, "subType", _.RenameSheet);
  2405. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.RenameSheet}_${e}`;
  2406. }
  2407. };
  2408. var Ks = class {
  2409. constructor(e) {
  2410. R(this, "id");
  2411. R(this, "value", true);
  2412. R(this, "type", D.Workbook);
  2413. R(this, "status", fl.INIT);
  2414. R(this, "subType", _.Share);
  2415. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.Share}_${e}`;
  2416. }
  2417. };
  2418. var Js = class {
  2419. constructor(e) {
  2420. R(this, "id");
  2421. R(this, "value", true);
  2422. R(this, "type", D.Workbook);
  2423. R(this, "status", fl.INIT);
  2424. R(this, "subType", _.View);
  2425. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.View}_${e}`;
  2426. }
  2427. };
  2428. var Ys = class {
  2429. constructor(e) {
  2430. R(this, "id");
  2431. R(this, "value", true);
  2432. R(this, "type", D.Workbook);
  2433. R(this, "status", fl.INIT);
  2434. R(this, "subType", _.ViewHistory);
  2435. this.unitId = e, this.unitId = e, this.id = `${this.type}.${_.ViewHistory}_${e}`;
  2436. }
  2437. };
  2438. var Xs = class {
  2439. constructor(e, t) {
  2440. R(this, "value", true);
  2441. R(this, "type", D.Worksheet);
  2442. R(this, "status", fl.INIT);
  2443. R(this, "id");
  2444. R(this, "subType", _.Copy);
  2445. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.Copy}_${e}_${t}`;
  2446. }
  2447. };
  2448. var qs = class {
  2449. constructor(e, t) {
  2450. R(this, "value", true);
  2451. R(this, "type", D.Worksheet);
  2452. R(this, "status", fl.INIT);
  2453. R(this, "id");
  2454. R(this, "subType", _.DeleteColumn);
  2455. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.DeleteColumn}_${e}_${t}`;
  2456. }
  2457. };
  2458. var Zs = class {
  2459. constructor(e, t) {
  2460. R(this, "value", true);
  2461. R(this, "type", D.Worksheet);
  2462. R(this, "status", fl.INIT);
  2463. R(this, "id");
  2464. R(this, "subType", _.Delete);
  2465. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.Delete}_${e}_${t}`;
  2466. }
  2467. };
  2468. var Qs = class {
  2469. constructor(e, t) {
  2470. R(this, "value", true);
  2471. R(this, "type", D.Worksheet);
  2472. R(this, "status", fl.INIT);
  2473. R(this, "id");
  2474. R(this, "subType", _.DeleteRow);
  2475. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.DeleteRow}_${e}_${t}`;
  2476. }
  2477. };
  2478. var Te = class {
  2479. constructor(e, t) {
  2480. R(this, "value", true);
  2481. R(this, "type", D.Worksheet);
  2482. R(this, "status", fl.INIT);
  2483. R(this, "id");
  2484. R(this, "subType", _.Edit);
  2485. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.Edit}_${e}_${t}`;
  2486. }
  2487. };
  2488. var er = class {
  2489. constructor(e, t) {
  2490. R(this, "value", true);
  2491. R(this, "type", D.Worksheet);
  2492. R(this, "status", fl.INIT);
  2493. R(this, "id");
  2494. R(this, "subType", _.EditExtraObject);
  2495. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.EditExtraObject}_${e}_${t}`;
  2496. }
  2497. };
  2498. var tr2 = class {
  2499. constructor(e, t) {
  2500. R(this, "value", true);
  2501. R(this, "type", D.Worksheet);
  2502. R(this, "status", fl.INIT);
  2503. R(this, "id");
  2504. R(this, "subType", _.Filter);
  2505. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.Filter}_${e}_${t}`;
  2506. }
  2507. };
  2508. var nr = class {
  2509. constructor(e, t) {
  2510. R(this, "value", true);
  2511. R(this, "type", D.Worksheet);
  2512. R(this, "status", fl.INIT);
  2513. R(this, "id");
  2514. R(this, "subType", _.InsertColumn);
  2515. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.InsertColumn}_${e}_${t}`;
  2516. }
  2517. };
  2518. var or = class {
  2519. constructor(e, t) {
  2520. R(this, "value", true);
  2521. R(this, "type", D.Worksheet);
  2522. R(this, "status", fl.INIT);
  2523. R(this, "id");
  2524. R(this, "subType", _.InsertHyperlink);
  2525. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.InsertHyperlink}_${e}_${t}`;
  2526. }
  2527. };
  2528. var sr = class {
  2529. constructor(e, t) {
  2530. R(this, "value", true);
  2531. R(this, "type", D.Worksheet);
  2532. R(this, "status", fl.INIT);
  2533. R(this, "id");
  2534. R(this, "subType", _.InsertRow);
  2535. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.InsertRow}_${e}_${t}`;
  2536. }
  2537. };
  2538. var rr2 = class {
  2539. constructor(e, t) {
  2540. R(this, "value", true);
  2541. R(this, "type", D.Worksheet);
  2542. R(this, "status", fl.INIT);
  2543. R(this, "id");
  2544. R(this, "subType", _.ManageCollaborator);
  2545. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.ManageCollaborator}_${e}_${t}`;
  2546. }
  2547. };
  2548. var ir = class {
  2549. constructor(e, t) {
  2550. R(this, "value", true);
  2551. R(this, "type", D.Worksheet);
  2552. R(this, "status", fl.INIT);
  2553. R(this, "id");
  2554. R(this, "subType", _.PivotTable);
  2555. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.PivotTable}_${e}_${t}`;
  2556. }
  2557. };
  2558. var nu2 = class {
  2559. constructor(e, t) {
  2560. R(this, "value", true);
  2561. R(this, "type", D.Worksheet);
  2562. R(this, "status", fl.INIT);
  2563. R(this, "id");
  2564. R(this, "subType", _.SelectProtectedCells);
  2565. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.SelectProtectedCells}_${e}_${t}`;
  2566. }
  2567. };
  2568. var ou = class {
  2569. constructor(e, t) {
  2570. R(this, "value", true);
  2571. R(this, "type", D.Worksheet);
  2572. R(this, "status", fl.INIT);
  2573. R(this, "id");
  2574. R(this, "subType", _.SelectUnProtectedCells);
  2575. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.SelectUnProtectedCells}_${e}_${t}`;
  2576. }
  2577. };
  2578. var ar2 = class {
  2579. constructor(e, t) {
  2580. R(this, "value", true);
  2581. R(this, "type", D.Worksheet);
  2582. R(this, "status", fl.INIT);
  2583. R(this, "id");
  2584. R(this, "subType", _.SetCellStyle);
  2585. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.SetCellStyle}_${e}_${t}`;
  2586. }
  2587. };
  2588. var wn = class {
  2589. constructor(e, t) {
  2590. R(this, "value", true);
  2591. R(this, "type", D.Worksheet);
  2592. R(this, "status", fl.INIT);
  2593. R(this, "id");
  2594. R(this, "subType", _.SetCellValue);
  2595. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.SetCellValue}_${e}_${t}`;
  2596. }
  2597. };
  2598. var $t = class {
  2599. constructor(e, t) {
  2600. R(this, "value", true);
  2601. R(this, "type", D.Worksheet);
  2602. R(this, "status", fl.INIT);
  2603. R(this, "id");
  2604. R(this, "subType", _.SetColumnStyle);
  2605. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.SetColumnStyle}_${e}_${t}`;
  2606. }
  2607. };
  2608. var Wt = class {
  2609. constructor(e, t) {
  2610. R(this, "value", true);
  2611. R(this, "type", D.Worksheet);
  2612. R(this, "status", fl.INIT);
  2613. R(this, "id");
  2614. R(this, "subType", _.SetRowStyle);
  2615. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.SetRowStyle}_${e}_${t}`;
  2616. }
  2617. };
  2618. var ur = class {
  2619. constructor(e, t) {
  2620. R(this, "value", true);
  2621. R(this, "type", D.Worksheet);
  2622. R(this, "status", fl.INIT);
  2623. R(this, "id");
  2624. R(this, "subType", _.Sort);
  2625. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.Sort}_${e}_${t}`;
  2626. }
  2627. };
  2628. var Hn = class {
  2629. constructor(e, t) {
  2630. R(this, "value", true);
  2631. R(this, "type", D.Worksheet);
  2632. R(this, "status", fl.INIT);
  2633. R(this, "id");
  2634. R(this, "subType", _.View);
  2635. this.unitId = e, this.subUnitId = t, this.id = `${this.type}.${_.View}_${e}_${t}`;
  2636. }
  2637. };
  2638. var on = {
  2639. id: "sheet.command.set-range-values",
  2640. type: ar.COMMAND,
  2641. handler: (n, e) => {
  2642. var T2;
  2643. const t = n.get(Pt), o = n.get(cn), s = n.get(_n), r = n.get(F), i = n.get(V), a = n.get(UE), u = N(s, e);
  2644. if (!u)
  2645. return false;
  2646. const { subUnitId: l, unitId: c, workbook: d, worksheet: h } = u, { value: m, range: g2 } = e, f = g2 ? [g2] : (T2 = r.getCurrentSelections()) == null ? void 0 : T2.map((U) => U.range);
  2647. if (!f || !f.length || !a.getPermissionPoint(new Te(c, l).id))
  2648. return false;
  2649. const p = new kt();
  2650. let C;
  2651. if (re.isArray(m))
  2652. for (let U = 0; U < f.length; U++) {
  2653. const { startRow: P, startColumn: A, endRow: j, endColumn: Z } = f[U];
  2654. for (let Y = 0; Y <= j - P; Y++)
  2655. for (let ee = 0; ee <= Z - A; ee++)
  2656. p.setValue(Y + P, ee + A, m[Y][ee]);
  2657. }
  2658. else if (fC(m))
  2659. for (let U = 0; U < f.length; U++) {
  2660. const { startRow: P, startColumn: A, endRow: j, endColumn: Z } = f[U];
  2661. for (let Y = P; Y <= j; Y++)
  2662. for (let ee = A; ee <= Z; ee++)
  2663. p.setValue(Y, ee, m);
  2664. }
  2665. else
  2666. C = m;
  2667. const S = { subUnitId: l, unitId: c, cellValue: C != null ? C : p.getMatrix() }, I = Ae(n, S);
  2668. if (!t.syncExecuteCommand(Q.id, S))
  2669. return false;
  2670. const { undos: b, redos: y } = i.onCommandExecute({
  2671. id: on.id,
  2672. params: { ...S, range: f }
  2673. });
  2674. if (mu([...y], t).result) {
  2675. const U = Xe2(g2 != null ? g2 : p.getRange(), d, h);
  2676. return o.pushUndoRedo({
  2677. unitID: c,
  2678. undoMutations: [
  2679. { id: Q.id, params: I },
  2680. ...b,
  2681. U
  2682. ],
  2683. redoMutations: [
  2684. { id: Q.id, params: S },
  2685. ...y,
  2686. re.deepClone(U)
  2687. ]
  2688. }), true;
  2689. }
  2690. return false;
  2691. }
  2692. };
  2693. function lr(n, e) {
  2694. const t = [], o = [], { unitId: s, subUnitId: r, range: i, shiftDimension: a, cellValue: u = {} } = e, l = n.get(_n), c = n.get(V), d = l.getUniverSheetInstance(s), h = d == null ? void 0 : d.getSheetBySheetId(r);
  2695. if (h) {
  2696. const m = h.getCellMatrix(), g2 = m.getDataRange();
  2697. if (i.startColumn <= g2.endColumn || i.startRow <= g2.endRow) {
  2698. let I, w;
  2699. if (a === yu.COLUMNS) {
  2700. const y = Math.min(i.endRow, g2.endRow);
  2701. let x = 0;
  2702. for (let U = i.startRow; U <= y; U++) {
  2703. const P = m.getRow(U), A = P ? fn(P) - 1 : 0;
  2704. x = Math.max(x, A);
  2705. }
  2706. I = {
  2707. startRow: i.startRow,
  2708. startColumn: i.startColumn,
  2709. endRow: y,
  2710. endColumn: x
  2711. };
  2712. const T2 = i.endColumn - i.startColumn + 1;
  2713. w = {
  2714. startRow: i.startRow,
  2715. startColumn: I.startColumn + T2,
  2716. endRow: y,
  2717. endColumn: I.endColumn + T2
  2718. };
  2719. } else {
  2720. const y = Math.min(i.endColumn, g2.endColumn), x = g2.endRow;
  2721. I = {
  2722. startRow: i.startRow,
  2723. startColumn: i.startColumn,
  2724. endRow: x,
  2725. endColumn: y
  2726. };
  2727. const T2 = i.endRow - i.startRow + 1;
  2728. w = {
  2729. startRow: I.startRow + T2,
  2730. startColumn: i.startColumn,
  2731. endRow: I.endRow + T2,
  2732. endColumn: y
  2733. };
  2734. }
  2735. const b = wo2(
  2736. n,
  2737. { unitId: s, subUnitId: r, range: I },
  2738. { unitId: s, subUnitId: r, range: w },
  2739. true
  2740. );
  2741. b && (t.push(...b.redos), o.push(...b.undos));
  2742. }
  2743. if (Object.entries(u).length === 0)
  2744. for (let I = i.startRow; I <= i.endRow; I++) {
  2745. u[I] || (u[I] = {});
  2746. for (let w = i.startColumn; w <= i.endColumn; w++)
  2747. u[I][w] = null;
  2748. }
  2749. const f = {
  2750. subUnitId: r,
  2751. unitId: s,
  2752. cellValue: u
  2753. }, p = Ae(
  2754. n,
  2755. f
  2756. ), { undos: C, redos: S } = c.onCommandExecute({
  2757. id: on.id,
  2758. params: { ...f, range: i }
  2759. });
  2760. t.push({ id: Q.id, params: f }, ...S), o.push({ id: Q.id, params: p }, ...C);
  2761. }
  2762. return {
  2763. redo: t,
  2764. undo: o
  2765. };
  2766. }
  2767. function cr(n, e) {
  2768. const t = [], o = [], { unitId: s, subUnitId: r, range: i, shiftDimension: a } = e, u = n.get(_n), l = n.get(V), c = u.getUniverSheetInstance(s), d = c == null ? void 0 : c.getSheetBySheetId(r);
  2769. if (d) {
  2770. const h = d.getCellMatrix(), m = h.getDataRange(), g2 = {
  2771. subUnitId: r,
  2772. unitId: s,
  2773. cellValue: Os([i])
  2774. }, f = Ae(
  2775. n,
  2776. g2
  2777. ), p = l.onCommandExecute({
  2778. id: on.id,
  2779. params: g2
  2780. });
  2781. if (t.push({ id: Q.id, params: g2 }, ...p.redos), o.push(...p.undos, {
  2782. id: Q.id,
  2783. params: f
  2784. }), i.startColumn <= m.endColumn || i.startRow <= m.endRow) {
  2785. let C = null, S = null;
  2786. if (a === yu.COLUMNS && i.endColumn < m.endColumn) {
  2787. const I = Math.min(i.endRow, m.endRow);
  2788. let w = 0;
  2789. for (let y = i.startRow; y <= I; y++) {
  2790. const x = h.getRow(y), T2 = x ? fn(x) - 1 : 0;
  2791. w = Math.max(w, T2);
  2792. }
  2793. C = {
  2794. startRow: i.startRow,
  2795. startColumn: i.endColumn + 1,
  2796. endRow: I,
  2797. endColumn: w
  2798. };
  2799. const b = i.endColumn - i.startColumn + 1;
  2800. S = {
  2801. startRow: i.startRow,
  2802. startColumn: C.startColumn - b,
  2803. endRow: I,
  2804. endColumn: C.endColumn - b
  2805. };
  2806. }
  2807. if (a === yu.ROWS && i.endRow < m.endRow) {
  2808. const I = Math.min(i.endColumn, m.endColumn), w = m.endRow;
  2809. C = {
  2810. startRow: i.endRow + 1,
  2811. startColumn: i.startColumn,
  2812. endRow: w,
  2813. endColumn: I
  2814. };
  2815. const b = i.endRow - i.startRow + 1;
  2816. S = {
  2817. startRow: C.startRow - b,
  2818. startColumn: i.startColumn,
  2819. endRow: C.endRow - b,
  2820. endColumn: I
  2821. };
  2822. }
  2823. if (C && S) {
  2824. const I = wo2(
  2825. n,
  2826. { unitId: s, subUnitId: r, range: C },
  2827. { unitId: s, subUnitId: r, range: S },
  2828. true
  2829. );
  2830. I && (t.push(...I.redos), o.push(...I.undos));
  2831. }
  2832. }
  2833. }
  2834. return {
  2835. redo: t,
  2836. undo: o
  2837. };
  2838. }
  2839. function Yd(n, e, t, o, s, r) {
  2840. const { startRow: i, endRow: a, startColumn: u, endColumn: l } = e;
  2841. if (s === yu.ROWS) {
  2842. const c = a - i + 1;
  2843. for (let d = t; d >= i; d--)
  2844. for (let h = u; h <= l; h++) {
  2845. const m = n.getValue(d, h);
  2846. m == null ? n.realDeleteValue(d + c, h) : n.setValue(d + c, h, m);
  2847. }
  2848. for (let d = a; d >= i; d--)
  2849. for (let h = u; h <= l; h++)
  2850. r && r[d] && r[d][h] ? n.setValue(d, h, r[d][h]) : n.realDeleteValue(d, h);
  2851. } else if (s === yu.COLUMNS) {
  2852. const c = l - u + 1;
  2853. for (let d = i; d <= a; d++)
  2854. for (let h = o; h >= u; h--) {
  2855. const m = n.getValue(d, h);
  2856. m == null ? n.realDeleteValue(d, h + c) : n.setValue(d, h + c, m);
  2857. }
  2858. for (let d = i; d <= a; d++)
  2859. for (let h = l; h >= u; h--)
  2860. r && r[d] && r[d][h] ? n.setValue(d, h, r[d][h]) : n.realDeleteValue(d, h);
  2861. }
  2862. }
  2863. function Xd(n, e, t, o, s) {
  2864. const { startRow: r, endRow: i, startColumn: a, endColumn: u } = e, l = i - r + 1, c = u - a + 1;
  2865. if (s === yu.ROWS)
  2866. for (let d = r; d <= t; d++)
  2867. for (let h = a; h <= u; h++) {
  2868. const m = n.getValue(d + l, h);
  2869. m == null ? n.realDeleteValue(d, h) : n.setValue(d, h, m);
  2870. }
  2871. else if (s === yu.COLUMNS)
  2872. for (let d = r; d <= i; d++)
  2873. for (let h = a; h <= o; h++) {
  2874. const m = n.getValue(d, h + c);
  2875. m == null ? n.realDeleteValue(d, h) : n.setValue(d, h, m);
  2876. }
  2877. }
  2878. var dr = "sheet.command.delete-range-move-left";
  2879. var Pt2 = {
  2880. type: ar.COMMAND,
  2881. id: dr,
  2882. handler: async (n, e) => {
  2883. var w, b, y;
  2884. const t = n.get(Pt), o = n.get(cn), s = n.get(_n), r = n.get(F), i = n.get(V), a = N(s);
  2885. if (!a)
  2886. return false;
  2887. const { worksheet: u, workbook: l, subUnitId: c, unitId: d } = a;
  2888. let h = e == null ? void 0 : e.range;
  2889. if (h || (h = (w = r.getCurrentLastSelection()) == null ? void 0 : w.range), !h)
  2890. return false;
  2891. const m = {
  2892. range: h,
  2893. subUnitId: c,
  2894. unitId: d,
  2895. shiftDimension: yu.COLUMNS
  2896. }, g2 = i.onCommandExecute({
  2897. id: Pt2.id,
  2898. params: { range: h }
  2899. }), { redo: f, undo: p } = cr(
  2900. n,
  2901. m
  2902. ), C = [...(b = g2.preRedos) != null ? b : [], ...f], S = [...g2.undos, ...p];
  2903. return C.push(...g2.redos), C.push(Xe2(h, l, u)), S.push(...(y = g2.preUndos) != null ? y : []), mu(C, t).result ? (o.pushUndoRedo({
  2904. unitID: d,
  2905. undoMutations: S.reverse(),
  2906. redoMutations: C
  2907. }), true) : false;
  2908. }
  2909. // all subsequent mutations should succeed inorder to make the whole process succeed
  2910. // Promise.all([]).then(() => true),
  2911. };
  2912. var hr = "sheet.command.delete-range-move-up";
  2913. var Tt = {
  2914. type: ar.COMMAND,
  2915. id: hr,
  2916. handler: async (n, e) => {
  2917. var w, b, y;
  2918. const t = n.get(Pt), o = n.get(cn), s = n.get(_n), r = n.get(F), i = n.get(V), a = N(s);
  2919. if (!a)
  2920. return false;
  2921. const { unitId: u, subUnitId: l, workbook: c, worksheet: d } = a;
  2922. let h = e == null ? void 0 : e.range;
  2923. if (h || (h = (w = r.getCurrentLastSelection()) == null ? void 0 : w.range), !h)
  2924. return false;
  2925. const m = {
  2926. range: h,
  2927. subUnitId: l,
  2928. unitId: u,
  2929. shiftDimension: yu.ROWS
  2930. }, g2 = i.onCommandExecute({
  2931. id: Tt.id,
  2932. params: { range: h }
  2933. }), { redo: f, undo: p } = cr(
  2934. n,
  2935. m
  2936. ), C = [...(b = g2.preRedos) != null ? b : [], ...f], S = [...g2.undos, ...p];
  2937. return C.push(...g2.redos), C.push(Xe2(h, c, d)), S.push(...(y = g2.preUndos) != null ? y : []), mu(C, t).result ? (o.pushUndoRedo({
  2938. unitID: u,
  2939. undoMutations: S.reverse(),
  2940. redoMutations: C
  2941. }), true) : false;
  2942. }
  2943. // all subsequent mutations should succeed inorder to make the whole process succeed
  2944. // Promise.all([]).then(() => true),
  2945. };
  2946. var su = {
  2947. type: ar.COMMAND,
  2948. id: "sheet.command.delete-range-protection",
  2949. async handler(n, e) {
  2950. if (!e)
  2951. return false;
  2952. const t = n.get(Pt), o = n.get(cn), { unitId: s, subUnitId: r, rule: i } = e, a = {
  2953. unitId: s,
  2954. subUnitId: r,
  2955. ruleIds: [i.id]
  2956. };
  2957. return await t.executeCommand(ze.id, a) && o.pushUndoRedo({
  2958. unitID: s,
  2959. redoMutations: [{ id: ze.id, params: a }],
  2960. undoMutations: [{ id: Ne.id, params: { unitId: s, subUnitId: r, rules: [i] } }]
  2961. }), true;
  2962. }
  2963. };
  2964. var ru = {
  2965. type: ar.COMMAND,
  2966. id: "sheet.command.delete-worksheet-protection",
  2967. handler(n, e) {
  2968. if (!e)
  2969. return false;
  2970. const t = n.get(Pt), o = n.get(cn), { rule: s, unitId: r, subUnitId: i } = e;
  2971. t.executeCommand(St.id, {
  2972. unitId: r,
  2973. subUnitId: i
  2974. });
  2975. const a = [{ id: St.id, params: { unitId: r, subUnitId: i } }], u = [{ id: ct.id, params: { unitId: r, rule: s, subUnitId: i } }];
  2976. return o.pushUndoRedo({
  2977. unitID: r,
  2978. redoMutations: a,
  2979. undoMutations: u
  2980. }), true;
  2981. }
  2982. };
  2983. var iu = {
  2984. type: ar.COMMAND,
  2985. id: "sheet.command.remove-worksheet-range-theme-style",
  2986. handler: (n, e) => {
  2987. const t = n.get(Pt), o = n.get(cn), { unitId: s } = e, r = _a(n, e);
  2988. return t.syncExecuteCommand(Kt.id, e) ? (o.pushUndoRedo({
  2989. unitID: s,
  2990. undoMutations: [{ id: zt.id, params: r }],
  2991. redoMutations: [{ id: Kt.id, params: e }]
  2992. }), true) : false;
  2993. }
  2994. };
  2995. var au = {
  2996. id: "sheet.command.insert-defined-name",
  2997. type: ar.COMMAND,
  2998. handler: (n, e) => {
  2999. const t = n.get(Pt), o = n.get(cn);
  3000. if (!e)
  3001. return false;
  3002. const s = {
  3003. ...e
  3004. };
  3005. return t.syncExecuteCommand(sa.id, s) ? (o.pushUndoRedo({
  3006. unitID: e.unitId,
  3007. undoMutations: [{ id: Xi.id, params: s }],
  3008. redoMutations: [{ id: sa.id, params: s }]
  3009. }), true) : false;
  3010. }
  3011. };
  3012. var mr2 = (n, e) => {
  3013. if (n.get(_n).getUniverSheetInstance(e.unitId) == null)
  3014. throw new Error("universheet is null error!");
  3015. return {
  3016. unitId: e.unitId,
  3017. subUnitId: e.subUnitId,
  3018. range: e.range
  3019. };
  3020. };
  3021. var qe = {
  3022. id: "sheet.mutation.insert-row",
  3023. type: ar.MUTATION,
  3024. handler: (n, e) => {
  3025. var g2;
  3026. const { unitId: t, subUnitId: o, range: s, rowInfo: r } = e, a = n.get(_n).getUniverSheetInstance(t);
  3027. if (a == null)
  3028. throw new Error("universheet is null error!");
  3029. const u = a.getSheetBySheetId(o);
  3030. if (u == null)
  3031. throw new Error("worksheet is null error!");
  3032. const l = u.getRowManager().getRowData(), c = {
  3033. h: u.getConfig().defaultRowHeight,
  3034. hd: 0
  3035. }, d = s.startRow, h = s.endRow - s.startRow + 1;
  3036. for (let f = d; f < d + h; f++)
  3037. r ? Vo(f, (g2 = r[f - s.startRow]) != null ? g2 : c, l) : Vo(f, c, l);
  3038. return u.setRowCount(u.getRowCount() + s.endRow - s.startRow + 1), u.getCellMatrix().insertRows(s.startRow, h), true;
  3039. }
  3040. };
  3041. var yo = (n, e) => {
  3042. if (n.get(_n).getUniverSheetInstance(e.unitId) == null)
  3043. throw new Error("universheet is null error!");
  3044. return {
  3045. unitId: e.unitId,
  3046. subUnitId: e.subUnitId,
  3047. range: e.range
  3048. };
  3049. };
  3050. var je = {
  3051. id: "sheet.mutation.insert-col",
  3052. type: ar.MUTATION,
  3053. handler: (n, e) => {
  3054. var g2;
  3055. const o = n.get(_n).getUniverSheetInstance(e.unitId);
  3056. if (o == null)
  3057. throw new Error("universheet is null error!");
  3058. const s = o.getSheetBySheetId(e.subUnitId);
  3059. if (!s)
  3060. return false;
  3061. const r = s.getColumnManager(), { range: i, colInfo: a } = e, l = r.getColumnData(), c = i.startColumn, d = i.endColumn - i.startColumn + 1, h = s.getConfig().defaultColumnWidth;
  3062. for (let f = c; f < c + d; f++) {
  3063. const p = {
  3064. w: h,
  3065. hd: 0
  3066. };
  3067. a ? Vo(f, (g2 = a[f - i.startColumn]) != null ? g2 : p, l) : Vo(f, p, l);
  3068. }
  3069. return s.setColumnCount(s.getColumnCount() + i.endColumn - i.startColumn + 1), s.getCellMatrix().insertColumns(i.startColumn, d), true;
  3070. }
  3071. };
  3072. var uu = (n, e) => {
  3073. const s = e.getRowManager().getRowData(), r = {}, i = n.range, a = UC(i.startRow, i.endRow, s), u = LC(r, a);
  3074. return {
  3075. unitId: n.unitId,
  3076. subUnitId: n.subUnitId,
  3077. range: n.range,
  3078. rowInfo: u
  3079. };
  3080. };
  3081. var Be = {
  3082. id: "sheet.mutation.remove-rows",
  3083. type: ar.MUTATION,
  3084. handler: (n, e) => {
  3085. const o = n.get(_n).getUniverSheetInstance(e.unitId);
  3086. if (o == null)
  3087. throw new Error("universheet is null error!");
  3088. const s = o.getSheetBySheetId(e.subUnitId);
  3089. if (!s)
  3090. return false;
  3091. const r = e.range, a = s.getRowManager().getRowData();
  3092. for (let c = r.startRow; c <= r.endRow; c++)
  3093. s.getRowFiltered(c);
  3094. const u = r.endRow - r.startRow + 1;
  3095. return Go(r.startRow, u, a), s.getCellMatrix().removeRows(r.startRow, u), s.setRowCount(s.getRowCount() - u), true;
  3096. }
  3097. };
  3098. var lu = (n, e) => {
  3099. const o = n.get(_n).getUniverSheetInstance(e.unitId);
  3100. if (o == null)
  3101. throw new Error("universheet is null error!");
  3102. const s = o.getSheetBySheetId(e.subUnitId);
  3103. if (s == null)
  3104. throw new Error("worksheet is null error!");
  3105. const a = s.getColumnManager().getColumnData(), u = {}, l = e.range, c = UC(l.startColumn, l.endColumn, a), d = LC(u, c);
  3106. return {
  3107. unitId: e.unitId,
  3108. subUnitId: e.subUnitId,
  3109. range: e.range,
  3110. colInfo: d
  3111. };
  3112. };
  3113. var De2 = {
  3114. id: "sheet.mutation.remove-col",
  3115. type: ar.MUTATION,
  3116. handler: (n, e) => {
  3117. const o = n.get(_n).getUniverSheetInstance(e.unitId);
  3118. if (o == null)
  3119. throw new Error("universheet is null error!");
  3120. const s = o.getSheetBySheetId(e.subUnitId);
  3121. if (!s)
  3122. return false;
  3123. const r = e.range, a = s.getColumnManager().getColumnData(), u = r.endColumn - r.startColumn + 1;
  3124. return Go(r.startColumn, u, a), s.setColumnCount(s.getColumnCount() - u), s.getCellMatrix().removeColumns(r.startColumn, u), true;
  3125. }
  3126. };
  3127. var cu = "sheet.command.insert-range-move-down";
  3128. var sn = {
  3129. type: ar.COMMAND,
  3130. id: "sheet.command.insert-range-move-down",
  3131. // eslint-disable-next-line max-lines-per-function
  3132. handler: async (n, e) => {
  3133. var j, Z, Y;
  3134. const t = n.get(Pt), o = n.get(cn), s = n.get(_n), r = n.get(F), i = n.get(V), a = n.get(NE), u = n.get(Vr);
  3135. if (r.isOverlapping())
  3136. return a.emit(u.t("sheets.info.overlappingSelections")), false;
  3137. const l = N(s);
  3138. if (!l)
  3139. return false;
  3140. const { unitId: c, subUnitId: d, worksheet: h, workbook: m } = l;
  3141. let g2 = e == null ? void 0 : e.range;
  3142. if (g2 || (g2 = (j = r.getCurrentLastSelection()) == null ? void 0 : j.range), !g2)
  3143. return false;
  3144. const f = [], p = [], C = h.getCellMatrix(), S = C.getDataRange(), w = C.getSlice(S.startRow, S.endRow, g2.startColumn, g2.endColumn).getDataRange().endRow, b = Math.max(w + (g2.endRow - g2.startRow + 1) - S.endRow, 0);
  3145. if (b > 0) {
  3146. const ee = g2.startRow - 1, Re = h.getRowHeight(ee), ie = {
  3147. unitId: c,
  3148. subUnitId: d,
  3149. range: {
  3150. startRow: S.endRow + 1,
  3151. endRow: S.endRow + b,
  3152. startColumn: S.startColumn,
  3153. endColumn: S.endColumn
  3154. },
  3155. rowInfo: new Array(b).fill(void 0).map(() => ({
  3156. h: Re,
  3157. hd: we.FALSE
  3158. }))
  3159. };
  3160. f.push({
  3161. id: qe.id,
  3162. params: ie
  3163. });
  3164. const xe = mr2(
  3165. n,
  3166. ie
  3167. );
  3168. p.push({ id: Be.id, params: xe });
  3169. }
  3170. const y = {};
  3171. tr.foreach(g2, (ee, Re) => {
  3172. const ie = h.getCell(ee, Re);
  3173. ie && (y[ee] || (y[ee] = {}), y[ee][Re] = { s: ie.s });
  3174. });
  3175. const x = {
  3176. range: g2,
  3177. subUnitId: d,
  3178. unitId: c,
  3179. shiftDimension: yu.ROWS,
  3180. cellValue: y
  3181. }, { redo: T2, undo: U } = lr(
  3182. n,
  3183. x
  3184. );
  3185. f.push(...T2), p.push(...U);
  3186. const P = i.onCommandExecute({
  3187. id: sn.id,
  3188. params: { range: g2 }
  3189. });
  3190. return f.push(...P.redos), f.push(Xe2(g2, m, h)), p.push(...(Z = P.preUndos) != null ? Z : []), f.unshift(...(Y = P.preRedos) != null ? Y : []), p.unshift(...P.undos), mu(f, t) ? (o.pushUndoRedo({
  3191. unitID: c,
  3192. undoMutations: p.reverse(),
  3193. redoMutations: f
  3194. }), true) : false;
  3195. }
  3196. // all subsequent mutations should succeed inorder to make the whole process succeed
  3197. // Promise.all([]).then(() => true),
  3198. };
  3199. var Eo = "sheet.command.insert-range-move-right";
  3200. var Bn = {
  3201. type: ar.COMMAND,
  3202. id: Eo,
  3203. // eslint-disable-next-line max-lines-per-function
  3204. handler: async (n, e) => {
  3205. var j, Z, Y;
  3206. const t = n.get(Pt), o = n.get(cn), s = n.get(_n), r = n.get(F), i = n.get(V), a = n.get(NE), u = n.get(Vr);
  3207. if (r.isOverlapping())
  3208. return a.emit(u.t("sheets.info.overlappingSelections")), false;
  3209. const l = N(s);
  3210. if (!l)
  3211. return false;
  3212. const { workbook: c, worksheet: d, unitId: h, subUnitId: m } = l;
  3213. let g2 = e == null ? void 0 : e.range;
  3214. if (g2 || (g2 = (j = r.getCurrentLastSelection()) == null ? void 0 : j.range), !g2)
  3215. return false;
  3216. const f = [], p = [], C = d.getCellMatrix(), S = C.getDataRange(), w = C.getSlice(g2.startRow, g2.endRow, S.startColumn, S.endColumn).getDataRange().endColumn, b = Math.max(
  3217. w + (g2.endColumn - g2.startColumn + 1) - S.endColumn,
  3218. 0
  3219. );
  3220. if (b > 0) {
  3221. const ee = g2.startColumn - 1, Re = d.getColumnWidth(ee), ie = {
  3222. unitId: h,
  3223. subUnitId: m,
  3224. range: {
  3225. startRow: S.startRow + 1,
  3226. endRow: S.endRow,
  3227. startColumn: S.endColumn + 1,
  3228. endColumn: S.endColumn + b
  3229. },
  3230. colInfo: new Array(b).fill(void 0).map(() => ({
  3231. w: Re,
  3232. hd: we.FALSE
  3233. }))
  3234. };
  3235. f.push({
  3236. id: je.id,
  3237. params: ie
  3238. });
  3239. const xe = yo(
  3240. n,
  3241. ie
  3242. );
  3243. p.push({ id: De2.id, params: xe });
  3244. }
  3245. const y = {};
  3246. tr.foreach(g2, (ee, Re) => {
  3247. const ie = d.getCell(ee, Re);
  3248. !ie || !ie.s || (y[ee] || (y[ee] = {}), y[ee][Re] = { s: ie.s });
  3249. });
  3250. const x = {
  3251. range: g2,
  3252. subUnitId: m,
  3253. unitId: h,
  3254. shiftDimension: yu.COLUMNS,
  3255. cellValue: y
  3256. }, { redo: T2, undo: U } = lr(
  3257. n,
  3258. x
  3259. );
  3260. f.push(...T2), p.push(...U);
  3261. const P = i.onCommandExecute({
  3262. id: Bn.id,
  3263. params: { range: g2 }
  3264. });
  3265. return f.push(...P.redos), f.push(Xe2(g2, c, d)), p.push(...(Z = P.preUndos) != null ? Z : []), f.unshift(...(Y = P.preRedos) != null ? Y : []), p.unshift(...P.undos), mu(f, t).result ? (o.pushUndoRedo({
  3266. unitID: h,
  3267. undoMutations: p.reverse(),
  3268. redoMutations: f
  3269. }), true) : false;
  3270. }
  3271. // all subsequent mutations should succeed inorder to make the whole process succeed
  3272. // Promise.all([]).then(() => true),
  3273. };
  3274. var gr = "sheet.command.insert-row";
  3275. var mt = {
  3276. type: ar.COMMAND,
  3277. id: gr,
  3278. handler: async (n, e) => {
  3279. const t = n.get(Pt), o = n.get(V), { range: s, direction: r, unitId: i, subUnitId: a, cellValue: u } = e;
  3280. return await o.beforeCommandExecute({
  3281. id: mt.id,
  3282. params: e
  3283. }) ? t.syncExecuteCommand(fr.id, {
  3284. range: s,
  3285. direction: r,
  3286. unitId: i,
  3287. subUnitId: a,
  3288. cellValue: u
  3289. }) : false;
  3290. }
  3291. };
  3292. var fr = {
  3293. type: ar.COMMAND,
  3294. id: "sheet.command.insert-row-by-range",
  3295. handler: (n, e) => {
  3296. var T2, U, P, A;
  3297. const t = n.get(Pt), o = n.get(cn), s = n.get(_n), r = n.get(V), i = N(s, e);
  3298. if (!i)
  3299. return false;
  3300. const { workbook: a, worksheet: u } = i, { range: l, direction: c, unitId: d, subUnitId: h, cellValue: m } = e, { startRow: g2, endRow: f } = l;
  3301. l.rangeType = De.ROW;
  3302. const p = c === wu.UP ? g2 : g2 - 1, C = u.getRowHeight(p), S = {
  3303. unitId: d,
  3304. subUnitId: h,
  3305. range: l,
  3306. rowInfo: new Array(f - g2 + 1).fill(void 0).map(() => ({
  3307. h: C,
  3308. hd: we.FALSE
  3309. }))
  3310. // row height should inherit from the anchor row
  3311. }, I = mr2(
  3312. n,
  3313. S
  3314. ), w = [{ id: qe.id, params: S }], b = [{ id: Be.id, params: I }];
  3315. m && w.push({
  3316. id: Q.id,
  3317. params: {
  3318. unitId: d,
  3319. subUnitId: h,
  3320. cellValue: m
  3321. }
  3322. });
  3323. const y = r.onCommandExecute({
  3324. id: mt.id,
  3325. params: e
  3326. });
  3327. return w.unshift(...(T2 = y.preRedos) != null ? T2 : []), w.push(...(U = y.redos) != null ? U : []), w.push(Xe2(l, a, u)), b.unshift(...(P = y.preUndos) != null ? P : []), b.push(...(A = y.undos) != null ? A : []), mu(w, t).result ? (o.pushUndoRedo({
  3328. unitID: e.unitId,
  3329. undoMutations: b,
  3330. redoMutations: w
  3331. }), true) : false;
  3332. }
  3333. };
  3334. var du = {
  3335. type: ar.COMMAND,
  3336. id: "sheet.command.insert-row-before",
  3337. handler: async (n) => {
  3338. var g2;
  3339. const t = (g2 = n.get(F).getCurrentSelections()) == null ? void 0 : g2.map((f) => f.range);
  3340. let o;
  3341. if ((t == null ? void 0 : t.length) === 1)
  3342. o = t[0];
  3343. else
  3344. return false;
  3345. const s = n.get(_n), r = N(s);
  3346. if (!r)
  3347. return false;
  3348. const { worksheet: i, subUnitId: a, unitId: u } = r, { startRow: l, endRow: c } = o, d = 0, h = i.getColumnCount() - 1, m = {
  3349. unitId: u,
  3350. subUnitId: a,
  3351. direction: wu.UP,
  3352. range: {
  3353. startRow: l,
  3354. endRow: c,
  3355. startColumn: d,
  3356. endColumn: h
  3357. },
  3358. // copy styles from the row above
  3359. cellValue: Vn2(i, l, c, d, h, true, l - 1)
  3360. };
  3361. return n.get(Pt).executeCommand(mt.id, m);
  3362. }
  3363. };
  3364. var hu = {
  3365. type: ar.COMMAND,
  3366. id: "sheet.command.insert-row-after",
  3367. handler: async (n) => {
  3368. var f;
  3369. const t = (f = n.get(F).getCurrentSelections()) == null ? void 0 : f.map((p) => p.range);
  3370. let o;
  3371. if ((t == null ? void 0 : t.length) === 1)
  3372. o = t[0];
  3373. else
  3374. return false;
  3375. const s = n.get(_n), r = N(s);
  3376. if (!r)
  3377. return false;
  3378. const { worksheet: i, unitId: a, subUnitId: u } = r, l = o.endRow - o.startRow + 1, c = o.endRow + 1, d = o.endRow + l, h = 0, m = i.getColumnCount() - 1, g2 = {
  3379. unitId: a,
  3380. subUnitId: u,
  3381. direction: wu.DOWN,
  3382. range: {
  3383. startRow: c,
  3384. endRow: d,
  3385. startColumn: h,
  3386. endColumn: m,
  3387. rangeType: De.ROW
  3388. },
  3389. // copy styles from the row below
  3390. cellValue: Vn2(i, c, d, h, m, true, o.endRow)
  3391. };
  3392. return n.get(Pt).executeCommand(mt.id, g2);
  3393. }
  3394. };
  3395. var Rr = "sheet.command.insert-col";
  3396. var gt = {
  3397. type: ar.COMMAND,
  3398. id: Rr,
  3399. handler: async (n, e) => {
  3400. const t = n.get(Pt), o = n.get(V), { range: s, direction: r, subUnitId: i, unitId: a, cellValue: u } = e;
  3401. return await o.beforeCommandExecute({
  3402. id: gt.id,
  3403. params: e
  3404. }) ? t.syncExecuteCommand(pr2.id, {
  3405. range: s,
  3406. direction: r,
  3407. unitId: a,
  3408. subUnitId: i,
  3409. cellValue: u
  3410. }) : false;
  3411. }
  3412. };
  3413. var pr2 = {
  3414. type: ar.COMMAND,
  3415. id: "sheet.command.insert-col-by-range",
  3416. handler: (n, e) => {
  3417. var x, T2, U, P;
  3418. const t = n.get(Pt), o = n.get(cn), s = n.get(_n), r = n.get(V), { range: i, direction: a, subUnitId: u, unitId: l, cellValue: c } = e, { startColumn: d, endColumn: h } = e.range;
  3419. i.rangeType = De.COLUMN;
  3420. const m = s.getUniverSheetInstance(e.unitId), g2 = m.getSheetBySheetId(e.subUnitId), f = a === wu.LEFT ? d : d - 1, p = g2.getColumnWidth(f), C = {
  3421. unitId: l,
  3422. subUnitId: u,
  3423. range: i,
  3424. colInfo: new Array(h - d + 1).fill(void 0).map(() => ({
  3425. w: p,
  3426. hd: we.FALSE
  3427. }))
  3428. }, S = yo(
  3429. n,
  3430. C
  3431. ), I = [{ id: je.id, params: C }], w = [{ id: De2.id, params: S }];
  3432. c && I.push({
  3433. id: Q.id,
  3434. params: {
  3435. unitId: l,
  3436. subUnitId: u,
  3437. cellValue: c
  3438. }
  3439. });
  3440. const b = r.onCommandExecute({
  3441. id: gt.id,
  3442. params: e
  3443. });
  3444. return I.unshift(...(x = b.preRedos) != null ? x : []), I.push(...(T2 = b.redos) != null ? T2 : []), I.push(Xe2(i, m, g2)), w.unshift(...(U = b.preUndos) != null ? U : []), w.push(...(P = b.undos) != null ? P : []), mu(I, t).result ? (o.pushUndoRedo({
  3445. unitID: e.unitId,
  3446. undoMutations: w.filter(Boolean),
  3447. redoMutations: I.filter(Boolean)
  3448. }), true) : false;
  3449. }
  3450. };
  3451. var mu2 = {
  3452. type: ar.COMMAND,
  3453. id: "sheet.command.insert-col-before",
  3454. handler: async (n) => {
  3455. const t = n.get(F).getCurrentSelections();
  3456. let o;
  3457. if ((t == null ? void 0 : t.length) === 1)
  3458. o = t[0].range;
  3459. else
  3460. return false;
  3461. const s = n.get(_n), r = N(s);
  3462. if (!r)
  3463. return false;
  3464. const { worksheet: i, unitId: a, subUnitId: u } = r, { startColumn: l, endColumn: c } = o, d = 0, h = i.getRowCount() - 1, m = {
  3465. unitId: a,
  3466. subUnitId: u,
  3467. direction: wu.LEFT,
  3468. range: {
  3469. startColumn: l,
  3470. endColumn: c,
  3471. startRow: d,
  3472. endRow: h,
  3473. rangeType: De.COLUMN
  3474. },
  3475. // copy styles from the column before
  3476. cellValue: Vn2(i, d, h, l, c, false, l - 1)
  3477. };
  3478. return n.get(Pt).executeCommand(gt.id, m);
  3479. }
  3480. };
  3481. var gu = {
  3482. type: ar.COMMAND,
  3483. id: "sheet.command.insert-col-after",
  3484. handler: async (n) => {
  3485. const t = n.get(F).getCurrentSelections();
  3486. let o;
  3487. if ((t == null ? void 0 : t.length) === 1)
  3488. o = t[0].range;
  3489. else
  3490. return false;
  3491. const s = n.get(_n), r = N(s);
  3492. if (!r)
  3493. return false;
  3494. const { worksheet: i, unitId: a, subUnitId: u } = r, l = o.endColumn - o.startColumn + 1, c = o.endColumn + 1, d = o.endColumn + l, h = 0, m = i.getRowCount() - 1, g2 = {
  3495. unitId: a,
  3496. subUnitId: u,
  3497. direction: wu.RIGHT,
  3498. range: {
  3499. startColumn: c,
  3500. endColumn: d,
  3501. startRow: h,
  3502. endRow: m
  3503. },
  3504. // copy styles from the column after
  3505. cellValue: Vn2(i, h, m, c, d, false, o.endColumn)
  3506. };
  3507. return n.get(Pt).executeCommand(gt.id, g2);
  3508. }
  3509. };
  3510. var fu = {
  3511. id: "sheet.command.insert-sheet",
  3512. type: ar.COMMAND,
  3513. handler: (n, e) => {
  3514. var p;
  3515. const t = n.get(Pt), o = n.get(cn), s = n.get(_n), r = n.get(Vr), i = va(s, { unitId: e == null ? void 0 : e.unitId });
  3516. if (!i)
  3517. return false;
  3518. const { unitId: a, workbook: u } = i;
  3519. let l = u.getSheets().length;
  3520. const c = e == null ? void 0 : e.sheet, d = c == null ? void 0 : c.id, h = Q_(c || {});
  3521. e ? (l = (p = e.index) != null ? p : l, h.id = d || re.generateRandomId(), h.name = (c == null ? void 0 : c.name) || u.generateNewSheetName(`${r.t("sheets.tabs.sheet")}`)) : (h.id = re.generateRandomId(), h.name = u.generateNewSheetName(`${r.t("sheets.tabs.sheet")}`));
  3522. const m = {
  3523. index: l,
  3524. sheet: h,
  3525. unitId: a
  3526. }, g2 = As(
  3527. n,
  3528. m
  3529. );
  3530. return t.syncExecuteCommand(Jt.id, m) ? (o.pushUndoRedo({
  3531. unitID: a,
  3532. undoMutations: [{ id: Ut.id, params: g2 }],
  3533. redoMutations: [{ id: Jt.id, params: m }]
  3534. }), true) : false;
  3535. }
  3536. };
  3537. function Ru(n, e) {
  3538. const { unitId: t, subUnitId: o, sourceRange: s, targetRange: r } = e, i = s.startRow > r.startRow, a = s.endRow - s.startRow + 1;
  3539. return i ? {
  3540. unitId: t,
  3541. subUnitId: o,
  3542. sourceRange: en.clone(r),
  3543. targetRange: {
  3544. ...s,
  3545. endRow: s.endRow + a,
  3546. startRow: s.startRow + a
  3547. }
  3548. } : {
  3549. unitId: t,
  3550. subUnitId: o,
  3551. targetRange: en.clone(s),
  3552. sourceRange: {
  3553. ...r,
  3554. endRow: r.endRow - a,
  3555. startRow: r.startRow - a
  3556. }
  3557. };
  3558. }
  3559. var ot2 = {
  3560. id: "sheet.mutation.move-rows",
  3561. type: ar.MUTATION,
  3562. handler: (n, e) => {
  3563. const { unitId: t, subUnitId: o, sourceRange: s, targetRange: r } = e, a = n.get(_n).getUniverSheetInstance(t);
  3564. if (!a)
  3565. throw new Error("[MoveRowMutation] univerSheet is null!");
  3566. const u = a.getSheetBySheetId(o);
  3567. if (!u)
  3568. throw new Error("[MoveRowMutation] worksheet is null!");
  3569. const l = s.startRow, c = s.endRow - s.startRow + 1, d = r.startRow, h = u.getRowManager().getRowData();
  3570. return Ko(l, c, d, h), u.getCellMatrix().moveRows(l, c, d), true;
  3571. }
  3572. };
  3573. function pu(n, e) {
  3574. const { unitId: t, subUnitId: o, sourceRange: s, targetRange: r } = e, i = s.startColumn > r.startColumn, a = s.endColumn - s.startColumn + 1;
  3575. return i ? {
  3576. unitId: t,
  3577. subUnitId: o,
  3578. sourceRange: en.clone(r),
  3579. targetRange: {
  3580. ...s,
  3581. endColumn: s.endColumn + a,
  3582. startColumn: s.startColumn + a
  3583. }
  3584. } : {
  3585. unitId: t,
  3586. subUnitId: o,
  3587. targetRange: en.clone(s),
  3588. sourceRange: {
  3589. ...r,
  3590. startColumn: r.startColumn - a,
  3591. endColumn: r.endColumn - a
  3592. }
  3593. };
  3594. }
  3595. var st2 = {
  3596. id: "sheet.mutation.move-columns",
  3597. type: ar.MUTATION,
  3598. handler: (n, e) => {
  3599. const { unitId: t, subUnitId: o, sourceRange: s, targetRange: r } = e, a = n.get(_n).getUniverSheetInstance(t);
  3600. if (!a)
  3601. throw new Error("[MoveColumnMutation] univerSheet is null!");
  3602. const u = a.getSheetBySheetId(o);
  3603. if (!u)
  3604. throw new Error("[MoveColumnMutation] worksheet is null!");
  3605. const l = s.startColumn, c = s.endColumn - s.startColumn + 1, d = r.startColumn, h = u.getColumnManager().getColumnData();
  3606. return Ko(l, c, d, h), u.getCellMatrix().moveColumns(l, c, d), true;
  3607. }
  3608. };
  3609. function Cu(n, e) {
  3610. return e.getMergeData().some((t) => t.startRow < n && n <= t.endRow);
  3611. }
  3612. function Su(n, e) {
  3613. return e.getMergeData().some((t) => t.startColumn < n && n <= t.endColumn);
  3614. }
  3615. var Cr = "sheet.command.move-rows";
  3616. var Fn = {
  3617. id: Cr,
  3618. type: ar.COMMAND,
  3619. // eslint-disable-next-line max-lines-per-function
  3620. handler: (n, e) => {
  3621. var j, Z;
  3622. const t = n.get(F), {
  3623. fromRange: { startRow: o },
  3624. toRange: { startRow: s },
  3625. range: r
  3626. } = e, i = r ? [wr(r)] : t.getCurrentSelections(), a = i == null ? void 0 : i.filter(
  3627. (Y) => Y.range.rangeType === De.ROW && Y.range.startRow <= o && o <= Y.range.endRow
  3628. );
  3629. if ((a == null ? void 0 : a.length) !== 1)
  3630. return false;
  3631. const u = n.get(V), l = n.get(_n), c = N(l, e);
  3632. if (!c)
  3633. return false;
  3634. const { workbook: d, worksheet: h } = c, m = d.getUnitId(), g2 = h.getSheetId(), f = n.get(NE), p = n.get(Vr), C = a[0].range, S = a[0].primary, I = Ln(C, h, false);
  3635. if (!en.equals(C, I))
  3636. return f.emit(p.t("sheets.info.partOfCell")), false;
  3637. if (Cu(s, h))
  3638. return f.emit(p.t("sheets.info.acrossMergedCell")), false;
  3639. const w = {
  3640. ...C,
  3641. startRow: s,
  3642. endRow: s + C.endRow - C.startRow
  3643. }, b = {
  3644. unitId: m,
  3645. subUnitId: g2,
  3646. sourceRange: C,
  3647. targetRange: w
  3648. }, y = Ru(n, b), x = n.get(Pt), T2 = u.onCommandExecute({ id: Fn.id, params: e }), U = [
  3649. ...(j = T2.preRedos) != null ? j : [],
  3650. { id: ot2.id, params: b }
  3651. ], P = [
  3652. ...(Z = T2.preUndos) != null ? Z : [],
  3653. { id: ot2.id, params: y }
  3654. ];
  3655. if (S) {
  3656. const ee = s - o < 0, Re = C.endRow - C.startRow + 1, ie = ee ? w : {
  3657. ...w,
  3658. startRow: w.startRow - Re,
  3659. endRow: w.endRow - Re
  3660. }, xe = {
  3661. unitId: m,
  3662. subUnitId: g2,
  3663. type: Ce.MOVE_END,
  3664. selections: [{
  3665. range: ie,
  3666. primary: ve(ie, h),
  3667. style: null
  3668. }]
  3669. }, ft = {
  3670. unitId: m,
  3671. subUnitId: g2,
  3672. type: Ce.MOVE_END,
  3673. selections: [{ range: C, primary: S, style: null }]
  3674. };
  3675. U.push({ id: re2.id, params: xe }), P.push({ id: re2.id, params: ft });
  3676. }
  3677. return U.push(...T2.redos), P.push(...T2.undos), mu(U, x).result ? (n.get(cn).pushUndoRedo({
  3678. unitID: m,
  3679. undoMutations: P,
  3680. redoMutations: U
  3681. }), true) : false;
  3682. }
  3683. };
  3684. var Sr = "sheet.command.move-cols";
  3685. var jn = {
  3686. id: Sr,
  3687. type: ar.COMMAND,
  3688. // eslint-disable-next-line max-lines-per-function
  3689. handler: (n, e) => {
  3690. var j, Z;
  3691. const t = n.get(F), {
  3692. fromRange: { startColumn: o },
  3693. toRange: { startColumn: s },
  3694. range: r
  3695. } = e, i = r ? [wr(r)] : t.getCurrentSelections(), a = i == null ? void 0 : i.filter(
  3696. (Y) => Y.range.rangeType === De.COLUMN && Y.range.startColumn <= o && o <= Y.range.endColumn
  3697. );
  3698. if ((a == null ? void 0 : a.length) !== 1)
  3699. return false;
  3700. const u = n.get(V), l = n.get(_n), c = N(l, e);
  3701. if (!c)
  3702. return false;
  3703. const { workbook: d, worksheet: h } = c, m = d.getUnitId(), g2 = h.getSheetId(), f = n.get(NE), p = n.get(Vr), C = a[0].range, S = a[0].primary, I = Ln(C, h, false);
  3704. if (!en.equals(C, I))
  3705. return f.emit(p.t("sheets.info.partOfCell")), false;
  3706. if (Su(s, h))
  3707. return f.emit(p.t("sheets.info.acrossMergedCell")), false;
  3708. const w = {
  3709. ...C,
  3710. startColumn: s,
  3711. endColumn: s + C.endColumn - C.startColumn
  3712. }, b = {
  3713. unitId: m,
  3714. subUnitId: g2,
  3715. sourceRange: C,
  3716. targetRange: w
  3717. }, y = pu(n, b), x = n.get(Pt), T2 = u.onCommandExecute({ id: jn.id, params: e }), U = [
  3718. ...(j = T2.preRedos) != null ? j : [],
  3719. { id: st2.id, params: b }
  3720. ], P = [
  3721. ...(Z = T2.preUndos) != null ? Z : [],
  3722. { id: st2.id, params: y }
  3723. ];
  3724. if (S) {
  3725. const Y = C.endColumn - C.startColumn + 1, ie = s - o < 0 ? w : {
  3726. ...w,
  3727. startColumn: w.startColumn - Y,
  3728. endColumn: w.endColumn - Y
  3729. }, xe = {
  3730. unitId: m,
  3731. subUnitId: g2,
  3732. type: Ce.MOVE_END,
  3733. selections: [{ range: ie, primary: ve(ie, h), style: null }]
  3734. }, ft = {
  3735. unitId: m,
  3736. subUnitId: g2,
  3737. type: Ce.MOVE_END,
  3738. selections: [{ range: C, primary: S, style: null }]
  3739. };
  3740. U.push({ id: re2.id, params: xe }), P.push({ id: re2.id, params: ft });
  3741. }
  3742. return U.push(...T2.redos), P.push(...T2.undos), mu(U, x).result && n.get(cn).pushUndoRedo({
  3743. unitID: m,
  3744. undoMutations: P,
  3745. redoMutations: U
  3746. }), true;
  3747. }
  3748. };
  3749. function wr(n) {
  3750. return {
  3751. range: n,
  3752. primary: null,
  3753. style: null
  3754. };
  3755. }
  3756. var Yt = {
  3757. id: "sheet.mutation.register-worksheet-range-theme-style",
  3758. type: ar.MUTATION,
  3759. handler: (n, e) => {
  3760. const { unitId: t, rangeThemeStyleJson: o, themeName: s } = e, r = n.get(_n), i = N(r), a = n.get(He);
  3761. if (!i)
  3762. return false;
  3763. const u = new yt(s, o);
  3764. return a.registerRangeThemeStyle(t, u), true;
  3765. }
  3766. };
  3767. var Uo = {
  3768. id: "sheet.mutation.unregister-worksheet-range-theme-style",
  3769. type: ar.MUTATION,
  3770. handler: (n, e) => {
  3771. const { unitId: t, themeName: o } = e, s = n.get(_n), r = N(s), i = n.get(He);
  3772. return r ? (i.unregisterRangeThemeStyle(t, o), true) : false;
  3773. }
  3774. };
  3775. var wu2 = {
  3776. id: "sheet.command.register-worksheet-range-theme-style",
  3777. type: ar.COMMAND,
  3778. handler: (n, e) => {
  3779. if (!e)
  3780. return false;
  3781. const { unitId: t, rangeThemeStyle: o } = e, s = n.get(_n), r = n.get(Pt), i = n.get(cn);
  3782. if (!N(s))
  3783. return false;
  3784. const u = {
  3785. unitId: t,
  3786. themeName: o.getName(),
  3787. rangeThemeStyleJson: o.toJson()
  3788. }, l = {
  3789. unitId: t,
  3790. themeName: o.getName()
  3791. };
  3792. return r.syncExecuteCommand(Yt.id, e) && i.pushUndoRedo({
  3793. unitID: t,
  3794. undoMutations: [{ id: Uo.id, params: l }],
  3795. redoMutations: [{ id: Yt.id, params: u }]
  3796. }), true;
  3797. }
  3798. };
  3799. var Ir = {
  3800. id: "sheet.command.remove-defined-name",
  3801. type: ar.COMMAND,
  3802. handler: (n, e) => {
  3803. var c, d;
  3804. const t = n.get(Pt), o = n.get(cn), s = n.get(V);
  3805. if (!e)
  3806. return false;
  3807. const r = {
  3808. ...e
  3809. }, i = s.onCommandExecute({ id: Ir.id, params: e }), a = [
  3810. ...(c = i.preRedos) != null ? c : [],
  3811. { id: Xi.id, params: r },
  3812. ...i.redos
  3813. ], u = [
  3814. ...(d = i.preUndos) != null ? d : [],
  3815. { id: sa.id, params: r },
  3816. ...i.undos
  3817. ];
  3818. return mu(a, t) ? (o.pushUndoRedo({
  3819. unitID: e.unitId,
  3820. undoMutations: u.filter(Boolean),
  3821. redoMutations: a.filter(Boolean)
  3822. }), true) : false;
  3823. }
  3824. };
  3825. var Po = "sheet.command.remove-row";
  3826. var vr = {
  3827. type: ar.COMMAND,
  3828. id: "sheet.command.remove-row-by-range",
  3829. handler: (n, e) => {
  3830. var C, S, I;
  3831. if (!e)
  3832. return false;
  3833. const t = n.get(_n), o = N(t, e);
  3834. if (!o)
  3835. return false;
  3836. const { workbook: s, worksheet: r } = o, i = n.get(V), { range: a, unitId: u, subUnitId: l } = e, c = {
  3837. unitId: u,
  3838. subUnitId: l,
  3839. range: a
  3840. }, d = uu(
  3841. c,
  3842. r
  3843. ), h = r.getCellMatrix().getSlice(a.startRow, a.endRow, 0, r.getColumnCount() - 1), m = {
  3844. unitId: u,
  3845. subUnitId: l,
  3846. cellValue: h.getMatrix()
  3847. }, g2 = i.onCommandExecute({
  3848. id: Po,
  3849. params: { range: a }
  3850. }), f = n.get(Pt);
  3851. return mu(
  3852. [
  3853. ...(C = g2.preRedos) != null ? C : [],
  3854. { id: Be.id, params: c },
  3855. ...g2.redos,
  3856. Xe2(a, s, r)
  3857. ],
  3858. f
  3859. ).result ? (n.get(cn).pushUndoRedo({
  3860. unitID: u,
  3861. undoMutations: [
  3862. ...(S = g2.preUndos) != null ? S : [],
  3863. { id: qe.id, params: d },
  3864. { id: Q.id, params: m },
  3865. ...g2.undos
  3866. ],
  3867. redoMutations: [
  3868. ...(I = g2.preRedos) != null ? I : [],
  3869. { id: Be.id, params: c },
  3870. ...g2.redos
  3871. ]
  3872. }), true) : false;
  3873. }
  3874. };
  3875. var Gn = {
  3876. type: ar.COMMAND,
  3877. id: Po,
  3878. handler: async (n, e) => {
  3879. var h;
  3880. const t = n.get(F), o = n.get(V), s = n.get(Pt);
  3881. let r = e == null ? void 0 : e.range;
  3882. if (r || (r = (h = t.getCurrentLastSelection()) == null ? void 0 : h.range), !r)
  3883. return false;
  3884. const i = n.get(_n), a = N(i);
  3885. if (!a)
  3886. return false;
  3887. const { worksheet: u, subUnitId: l, unitId: c } = a;
  3888. return r = {
  3889. ...r,
  3890. startColumn: 0,
  3891. endColumn: Math.max(u.getMaxColumns() - 1, 0)
  3892. }, await o.beforeCommandExecute({
  3893. id: Gn.id,
  3894. params: { range: r }
  3895. }) ? s.syncExecuteCommand(vr.id, {
  3896. range: r,
  3897. unitId: c,
  3898. subUnitId: l
  3899. }) : false;
  3900. }
  3901. };
  3902. var To = "sheet.command.remove-col";
  3903. var Mr = {
  3904. type: ar.COMMAND,
  3905. id: "sheet.command.remove-col-by-range",
  3906. handler: (n, e) => {
  3907. var C, S, I;
  3908. if (!e)
  3909. return false;
  3910. const t = n.get(_n), o = N(t, e);
  3911. if (!o)
  3912. return false;
  3913. const { workbook: s, worksheet: r } = o, i = n.get(V), { range: a, unitId: u, subUnitId: l } = e, c = {
  3914. unitId: u,
  3915. subUnitId: l,
  3916. range: a
  3917. }, d = lu(n, c), h = r.getCellMatrix().getSlice(0, r.getRowCount() - 1, a.startColumn, a.endColumn), m = {
  3918. unitId: u,
  3919. subUnitId: l,
  3920. cellValue: h.getMatrix()
  3921. }, g2 = i.onCommandExecute({
  3922. id: To,
  3923. params: { range: a }
  3924. }), f = n.get(Pt);
  3925. return mu(
  3926. [
  3927. ...(C = g2.preRedos) != null ? C : [],
  3928. { id: De2.id, params: c },
  3929. ...g2.redos,
  3930. Xe2(a, s, r)
  3931. ],
  3932. f
  3933. ).result ? (n.get(cn).pushUndoRedo({
  3934. unitID: u,
  3935. undoMutations: [
  3936. ...(S = g2.preUndos) != null ? S : [],
  3937. { id: je.id, params: d },
  3938. { id: Q.id, params: m },
  3939. ...g2.undos
  3940. ],
  3941. redoMutations: [
  3942. ...(I = g2.preRedos) != null ? I : [],
  3943. { id: De2.id, params: c },
  3944. ...g2.redos
  3945. ]
  3946. }), true) : false;
  3947. }
  3948. };
  3949. var zn2 = {
  3950. type: ar.COMMAND,
  3951. id: To,
  3952. handler: async (n, e) => {
  3953. var h;
  3954. const t = n.get(F), o = n.get(V), s = n.get(Pt);
  3955. let r = e == null ? void 0 : e.range;
  3956. if (r || (r = (h = t.getCurrentLastSelection()) == null ? void 0 : h.range), !r)
  3957. return false;
  3958. const i = n.get(_n), a = N(i);
  3959. if (!a)
  3960. return false;
  3961. const { worksheet: u, subUnitId: l, unitId: c } = a;
  3962. return r = {
  3963. ...r,
  3964. startRow: 0,
  3965. endRow: Math.max(u.getMaxRows() - 1, 0)
  3966. }, await o.beforeCommandExecute({
  3967. id: zn2.id,
  3968. params: { range: r }
  3969. }) ? s.syncExecuteCommand(Mr.id, {
  3970. range: r,
  3971. unitId: c,
  3972. subUnitId: l
  3973. }) : false;
  3974. }
  3975. };
  3976. var ko = {
  3977. id: "sheet.command.remove-sheet",
  3978. type: ar.COMMAND,
  3979. handler: (n, e) => {
  3980. var C, S;
  3981. const t = n.get(Pt), o = n.get(cn), s = n.get(_n), r = n.get(V), i = N(s, e);
  3982. if (!i)
  3983. return false;
  3984. const { unitId: a, subUnitId: u, workbook: l, worksheet: c } = i;
  3985. if (l.getSheets().length <= 1)
  3986. return false;
  3987. const d = {
  3988. subUnitId: u,
  3989. unitId: a,
  3990. subUnitName: c.getName()
  3991. }, h = ja(
  3992. n,
  3993. d
  3994. ), m = r.onCommandExecute({
  3995. id: ko.id,
  3996. params: { unitId: a, subUnitId: u }
  3997. }), g2 = [...(C = m.preRedos) != null ? C : [], { id: Ut.id, params: d }, ...m.redos], f = [...(S = m.preUndos) != null ? S : [], { id: Jt.id, params: h }, ...m.undos];
  3998. return mu(g2, t).result ? (o.pushUndoRedo({
  3999. unitID: a,
  4000. undoMutations: f,
  4001. redoMutations: g2
  4002. }), true) : false;
  4003. }
  4004. };
  4005. var Ue = (n, e) => {
  4006. if (n.get(_n).getUniverSheetInstance(e.unitId) == null)
  4007. throw new Error("universheet is null error!");
  4008. return {
  4009. unitId: e.unitId,
  4010. subUnitId: e.subUnitId,
  4011. ranges: re.deepClone(e.ranges)
  4012. };
  4013. };
  4014. var ne = {
  4015. id: "sheet.mutation.add-worksheet-merge",
  4016. type: ar.MUTATION,
  4017. handler: (n, e) => {
  4018. const o = n.get(_n).getUniverSheetInstance(e.unitId);
  4019. if (o == null)
  4020. throw new Error("universheet is null error!");
  4021. const s = o.getSheetBySheetId(e.subUnitId);
  4022. if (!s)
  4023. return false;
  4024. const i = s.getConfig().mergeData, a = e.ranges;
  4025. for (let u = 0; u < a.length; u++)
  4026. i.push(a[u]);
  4027. return s.getSpanModel().rebuild(i), true;
  4028. }
  4029. };
  4030. var Se = (n, e) => {
  4031. const o = n.get(_n).getUniverSheetInstance(e.unitId);
  4032. if (o == null)
  4033. throw new Error("universheet is null error!");
  4034. const s = o.getSheetBySheetId(e.subUnitId);
  4035. if (s == null)
  4036. throw new Error("worksheet is null error!");
  4037. const i = s.getConfig().mergeData, a = e.ranges, u = [];
  4038. for (let l = 0; l < a.length; l++)
  4039. for (let c = i.length - 1; c >= 0; c--) {
  4040. const d = i[c], h = a[l];
  4041. en.intersects(d, h) && u.push(i[c]);
  4042. }
  4043. return {
  4044. unitId: e.unitId,
  4045. subUnitId: e.subUnitId,
  4046. ranges: u
  4047. };
  4048. };
  4049. var oe = {
  4050. id: "sheet.mutation.remove-worksheet-merge",
  4051. type: ar.MUTATION,
  4052. handler: (n, e) => {
  4053. const o = n.get(_n).getUniverSheetInstance(e.unitId);
  4054. if (o == null)
  4055. throw new Error("universheet is null error!");
  4056. const s = o.getSheetBySheetId(e.subUnitId);
  4057. if (!s)
  4058. return false;
  4059. const i = s.getConfig().mergeData, a = e.ranges;
  4060. for (let u = 0; u < a.length; u++)
  4061. for (let l = i.length - 1; l >= 0; l--) {
  4062. const c = i[l], d = a[u];
  4063. en.intersects(c, d) && i.splice(l, 1);
  4064. }
  4065. return s.getSpanModel().rebuild(i), true;
  4066. }
  4067. };
  4068. var Iu = {
  4069. type: ar.COMMAND,
  4070. id: "sheet.command.remove-worksheet-merge",
  4071. // eslint-disable-next-line max-lines-per-function
  4072. handler: (n, e) => {
  4073. var A;
  4074. const t = n.get(F), o = n.get(Pt), s = n.get(cn), r = n.get(_n), i = (e == null ? void 0 : e.ranges) || ((A = t.getCurrentSelections()) == null ? void 0 : A.map((j) => j.range));
  4075. if (!(i != null && i.length))
  4076. return false;
  4077. const a = N(r);
  4078. if (!a)
  4079. return false;
  4080. const { subUnitId: u, unitId: l, worksheet: c } = a, d = {
  4081. unitId: l,
  4082. subUnitId: u,
  4083. ranges: i
  4084. }, m = c.getConfig().mergeData.filter((j) => i.some((Z) => en.intersects(Z, j)));
  4085. if (!m.length)
  4086. return false;
  4087. const g2 = Se(
  4088. n,
  4089. d
  4090. ), f = t.getCurrentSelections();
  4091. if (!(f != null && f.length))
  4092. return false;
  4093. const p = re.deepClone(f), C = re.deepClone(f), S = C[C.length - 1], { startRow: I, startColumn: w } = S.range;
  4094. S.primary = {
  4095. startRow: I,
  4096. startColumn: w,
  4097. endRow: I,
  4098. endColumn: w,
  4099. actualRow: I,
  4100. actualColumn: w,
  4101. isMerged: false,
  4102. isMergedMainCell: false
  4103. };
  4104. const b = vu(c, m), y = {
  4105. unitId: l,
  4106. subUnitId: u,
  4107. cellValue: b.redoParams.getMatrix()
  4108. }, x = {
  4109. unitId: l,
  4110. subUnitId: u,
  4111. cellValue: b.undoParams.getMatrix()
  4112. }, T2 = [
  4113. { id: oe.id, params: g2 },
  4114. { id: Q.id, params: y },
  4115. { id: re2.id, params: { selections: C } }
  4116. ], U = [
  4117. { id: ne.id, params: g2 },
  4118. { id: Q.id, params: x },
  4119. { id: re2.id, params: { selections: p } }
  4120. ];
  4121. return mu(T2, o) ? (s.pushUndoRedo({
  4122. unitID: l,
  4123. undoMutations: U,
  4124. redoMutations: T2
  4125. }), true) : false;
  4126. }
  4127. };
  4128. function vu(n, e) {
  4129. const t = new kt(), o = new kt();
  4130. return e.forEach((s) => {
  4131. const { startRow: r, startColumn: i, endColumn: a, endRow: u } = s, l = n.getCellMatrix().getValue(r, i);
  4132. if (l != null && l.s)
  4133. for (let c = r; c <= u; c++)
  4134. for (let d = i; d <= a; d++)
  4135. (c !== r || d !== i) && (t.setValue(c, d, { s: l.s }), o.setValue(c, d, null));
  4136. }), {
  4137. redoParams: t,
  4138. undoParams: o
  4139. };
  4140. }
  4141. var Mu = (n) => {
  4142. const { order: e } = n, t = {};
  4143. return Object.keys(e).forEach((o) => {
  4144. t[e[Number(o)]] = Number(o);
  4145. }), {
  4146. ...n,
  4147. order: t
  4148. };
  4149. };
  4150. var In = {
  4151. id: "sheet.mutation.reorder-range",
  4152. type: ar.MUTATION,
  4153. handler: (n, e) => {
  4154. const { subUnitId: t, unitId: o, range: s, order: r } = e, u = n.get(_n).getUnit(o).getSheetBySheetId(t);
  4155. if (!u)
  4156. return false;
  4157. const l = new kt();
  4158. tr.foreach(s, (d, h) => {
  4159. if (r.hasOwnProperty(d)) {
  4160. const m = r[d], g2 = re.deepClone(u.getCellRaw(m, h));
  4161. l.setValue(d, h, g2);
  4162. }
  4163. });
  4164. const c = u.getCellMatrix();
  4165. return l.forValue((d, h, m) => {
  4166. c.setValue(d, h, m);
  4167. }), true;
  4168. }
  4169. };
  4170. var _r = "sheet.command.reorder-range";
  4171. var uo = {
  4172. id: _r,
  4173. type: ar.COMMAND,
  4174. handler: (n, e) => {
  4175. var f, p;
  4176. const { subUnitId: t, unitId: o, range: s, order: r } = e, i = n.get(Pt), a = {
  4177. id: In.id,
  4178. params: {
  4179. unitId: o,
  4180. subUnitId: t,
  4181. order: r,
  4182. range: s
  4183. }
  4184. }, u = {
  4185. id: In.id,
  4186. params: Mu(a.params)
  4187. }, l = n.get(V), c = l.onCommandExecute({ id: uo.id, params: e }), d = [
  4188. ...(f = c.preRedos) != null ? f : [],
  4189. a,
  4190. ...c.redos
  4191. ], h = [
  4192. ...(p = c.preUndos) != null ? p : [],
  4193. u,
  4194. ...c.undos
  4195. ], m = mu(d, i), g2 = l.afterCommandExecute({ id: uo.id, params: e });
  4196. return m.result ? (mu(g2.redos, i), n.get(cn).pushUndoRedo({
  4197. unitID: o,
  4198. undoMutations: [...h, ...g2.undos],
  4199. redoMutations: [...d, ...g2.redos]
  4200. }), true) : false;
  4201. }
  4202. };
  4203. var kt2 = class {
  4204. constructor() {
  4205. R(this, "_borderInfo", {
  4206. type: Eu.ALL,
  4207. color: "#000000",
  4208. style: Xe.THIN,
  4209. activeBorderType: false
  4210. });
  4211. R(this, "_borderInfo$", new BehaviorSubject(this._borderInfo));
  4212. R(this, "borderInfo$", this._borderInfo$.asObservable());
  4213. }
  4214. dispose() {
  4215. this._borderInfo$.complete();
  4216. }
  4217. setType(e) {
  4218. this._borderInfo.type = e, this.setActiveBorderType(true), this._refresh();
  4219. }
  4220. setColor(e) {
  4221. this._borderInfo.color = e, this._refresh();
  4222. }
  4223. setStyle(e) {
  4224. this._borderInfo.style = e, this._refresh();
  4225. }
  4226. setActiveBorderType(e) {
  4227. this._borderInfo.activeBorderType = e;
  4228. }
  4229. getBorderInfo() {
  4230. return this._borderInfo;
  4231. }
  4232. _refresh() {
  4233. this._borderInfo$.next(this._borderInfo);
  4234. }
  4235. };
  4236. function vn(n, e) {
  4237. const { startRow: t, startColumn: o, endRow: s, endColumn: r } = n;
  4238. for (let i = t; i <= s; i++)
  4239. for (let a = o; a <= r; a++)
  4240. e(i, a);
  4241. }
  4242. var No = (n, e, t, o) => {
  4243. const { mr: s, worksheet: r } = n;
  4244. e.startRow < 0 || e.startColumn < 0 || vn(e, (i, a) => {
  4245. var c, d;
  4246. const u = r.getMergedCell(i, a);
  4247. let l = t;
  4248. if (u && (t.bc_tr || t.ml_tr || t.bl_tr || t.tl_mr || t.tl_bc || t.tl_br)) {
  4249. if (o) {
  4250. const h = re.deepClone(
  4251. (c = s.getValue(u.startRow, u.startColumn)) == null ? void 0 : c.s
  4252. );
  4253. l = h != null && h.bd ? Object.assign(h.bd, t) : t;
  4254. }
  4255. s.setValue(u.startRow, u.startColumn, {
  4256. s: {
  4257. bd: l
  4258. }
  4259. });
  4260. } else {
  4261. if (o) {
  4262. const h = re.deepClone((d = s.getValue(i, a)) == null ? void 0 : d.s);
  4263. l = h != null && h.bd ? Object.assign(h.bd, t) : t;
  4264. }
  4265. s.setValue(i, a, { s: { bd: l } });
  4266. }
  4267. });
  4268. };
  4269. var _u = (n) => {
  4270. const e = {
  4271. startRow: n.startRow - 1,
  4272. startColumn: n.startColumn,
  4273. endRow: n.startRow - 1,
  4274. endColumn: n.endColumn
  4275. }, t = {
  4276. startRow: n.startRow,
  4277. startColumn: n.startColumn - 1,
  4278. endRow: n.endRow,
  4279. endColumn: n.startColumn - 1
  4280. }, o = {
  4281. startRow: n.endRow + 1,
  4282. startColumn: n.startColumn,
  4283. endRow: n.endRow + 1,
  4284. endColumn: n.endColumn
  4285. }, s = {
  4286. startRow: n.startRow,
  4287. startColumn: n.endColumn + 1,
  4288. endRow: n.endRow,
  4289. endColumn: n.endColumn + 1
  4290. }, r = {
  4291. startRow: n.startRow,
  4292. startColumn: n.startColumn,
  4293. endRow: n.startRow,
  4294. endColumn: n.endColumn
  4295. }, i = {
  4296. startRow: n.startRow,
  4297. startColumn: n.startColumn,
  4298. endRow: n.endRow,
  4299. endColumn: n.startColumn
  4300. }, a = {
  4301. startRow: n.endRow,
  4302. startColumn: n.startColumn,
  4303. endRow: n.endRow,
  4304. endColumn: n.endColumn
  4305. }, u = {
  4306. startRow: n.startRow,
  4307. startColumn: n.endColumn,
  4308. endRow: n.endRow,
  4309. endColumn: n.endColumn
  4310. };
  4311. return {
  4312. topRangeOut: e,
  4313. leftRangeOut: t,
  4314. bottomRangeOut: o,
  4315. rightRangeOut: s,
  4316. topRange: r,
  4317. leftRange: i,
  4318. bottomRange: a,
  4319. rightRange: u
  4320. };
  4321. };
  4322. function bu(n, e, t) {
  4323. const { style: o, color: s, type: r } = n.getBorderInfo(), i = r === Eu.TOP || r === Eu.ALL || r === Eu.OUTSIDE, a = r === Eu.LEFT || r === Eu.ALL || r === Eu.OUTSIDE, u = r === Eu.BOTTOM || r === Eu.ALL || r === Eu.OUTSIDE, l = r === Eu.RIGHT || r === Eu.ALL || r === Eu.OUTSIDE, c = r === Eu.VERTICAL || r === Eu.ALL || r === Eu.INSIDE, d = r === Eu.HORIZONTAL || r === Eu.ALL || r === Eu.INSIDE, h = r.indexOf("tlbr") > -1, m = r.indexOf("tlbc") > -1, g2 = r.indexOf("tlmr") > -1, f = r.indexOf("bltr") > -1, p = r.indexOf("mltr") > -1, C = r.indexOf("bctr") > -1, S = t[0], {
  4324. topRangeOut: I,
  4325. leftRangeOut: w,
  4326. bottomRangeOut: b,
  4327. rightRangeOut: y,
  4328. topRange: x,
  4329. leftRange: T2,
  4330. bottomRange: U,
  4331. rightRange: P
  4332. } = _u(S), A = new kt(), { worksheet: j, unitId: Z, subUnitId: Y } = e;
  4333. return {
  4334. worksheet: j,
  4335. unitId: Z,
  4336. subUnitId: Y,
  4337. style: o,
  4338. color: s,
  4339. type: r,
  4340. top: i,
  4341. left: a,
  4342. right: l,
  4343. bottom: u,
  4344. vertical: c,
  4345. horizontal: d,
  4346. tl_br: h,
  4347. tl_bc: m,
  4348. tl_mr: g2,
  4349. bl_tr: f,
  4350. ml_tr: p,
  4351. bc_tr: C,
  4352. topRangeOut: I,
  4353. leftRangeOut: w,
  4354. bottomRangeOut: b,
  4355. rightRangeOut: y,
  4356. topRange: x,
  4357. leftRange: T2,
  4358. bottomRange: U,
  4359. rightRange: P,
  4360. range: S,
  4361. mr: A,
  4362. borderStyle: {
  4363. s: o,
  4364. cl: {
  4365. rgb: s
  4366. }
  4367. }
  4368. };
  4369. }
  4370. var yu2 = (n) => {
  4371. const { range: e, mr: t, borderStyle: o, vertical: s, horizontal: r, worksheet: i } = n;
  4372. s && vn(e, (a, u) => {
  4373. var c, d, h;
  4374. const l = i.getMergedCell(a, u);
  4375. if (l) {
  4376. const m = (c = t.getValue(l.startRow, l.startColumn)) == null ? void 0 : c.s;
  4377. l.startColumn !== e.startColumn && t.setValue(a, u, {
  4378. s: {
  4379. bd: m != null && m.bd ? Object.assign(m.bd, { l: re.deepClone(o) }) : { l: re.deepClone(o) }
  4380. }
  4381. });
  4382. } else {
  4383. if (u !== e.endColumn) {
  4384. const m = (d = t.getValue(a, u)) == null ? void 0 : d.s;
  4385. t.setValue(a, u, {
  4386. s: {
  4387. bd: m != null && m.bd ? Object.assign(m.bd, { r: re.deepClone(o) }) : { r: re.deepClone(o) }
  4388. }
  4389. });
  4390. }
  4391. if (u !== e.startColumn) {
  4392. const m = (h = t.getValue(a, u)) == null ? void 0 : h.s;
  4393. t.setValue(a, u, {
  4394. s: {
  4395. bd: m != null && m.bd ? Object.assign(m.bd, { l: re.deepClone(o) }) : { l: re.deepClone(o) }
  4396. }
  4397. });
  4398. }
  4399. }
  4400. }), r && vn(e, (a, u) => {
  4401. var c, d, h;
  4402. const l = i.getMergedCell(a, u);
  4403. if (l) {
  4404. const m = (c = t.getValue(l.startRow, l.startColumn)) == null ? void 0 : c.s;
  4405. l.startRow !== e.startRow && t.setValue(a, u, {
  4406. s: {
  4407. bd: m != null && m.bd ? Object.assign(m.bd, { t: re.deepClone(o) }) : { t: re.deepClone(o) }
  4408. }
  4409. });
  4410. } else {
  4411. if (a !== e.endRow) {
  4412. const m = (d = t.getValue(a, u)) == null ? void 0 : d.s;
  4413. t.setValue(a, u, {
  4414. s: {
  4415. bd: m != null && m.bd ? Object.assign(m.bd, { b: re.deepClone(o) }) : { b: re.deepClone(o) }
  4416. }
  4417. });
  4418. }
  4419. if (a !== e.startRow) {
  4420. const m = (h = t.getValue(a, u)) == null ? void 0 : h.s;
  4421. t.setValue(a, u, {
  4422. s: {
  4423. bd: m != null && m.bd ? Object.assign(m.bd, { t: re.deepClone(o) }) : { t: re.deepClone(o) }
  4424. }
  4425. });
  4426. }
  4427. }
  4428. });
  4429. };
  4430. function Eu2(n) {
  4431. const { borderStyle: e, tl_br: t, tl_bc: o, tl_mr: s, bl_tr: r, ml_tr: i, bc_tr: a } = n, u = (l, c, d) => {
  4432. No(n, l, c, d);
  4433. };
  4434. t && u(n.range, { tl_br: re.deepClone(e) }, true), o && u(n.range, { tl_bc: re.deepClone(e) }, true), s && u(n.range, { tl_mr: re.deepClone(e) }, true), r && u(n.range, { bl_tr: re.deepClone(e) }, true), i && u(n.range, { ml_tr: re.deepClone(e) }, true), a && u(n.range, { bc_tr: re.deepClone(e) }, true);
  4435. }
  4436. var Uu = (n) => {
  4437. const { top: e, left: t, right: o, bottom: s, borderStyle: r, bottomRange: i, topRange: a, leftRange: u, rightRange: l, bottomRangeOut: c, topRangeOut: d, leftRangeOut: h, rightRangeOut: m } = n, g2 = (f, p, C) => {
  4438. No(n, f, p, C);
  4439. };
  4440. e && (g2(d, { b: null }), g2(a, { t: re.deepClone(r) }, true)), s && (g2(c, { t: null }), g2(i, { b: re.deepClone(r) }, true)), t && (g2(h, { r: null }), g2(u, { l: re.deepClone(r) }, true)), o && (g2(m, { l: null }), g2(l, { r: re.deepClone(r) }, true));
  4441. };
  4442. var Pu = (n) => {
  4443. const { range: e, worksheet: t, mr: o, top: s, bottom: r, left: i, right: a, vertical: u, horizontal: l, tl_br: c, tl_bc: d, tl_mr: h, bl_tr: m, ml_tr: g2, bc_tr: f, topRange: p, bottomRange: C, leftRange: S, rightRange: I, topRangeOut: w, bottomRangeOut: b, leftRangeOut: y, rightRangeOut: x } = n, T2 = (U, P, A) => {
  4444. No(n, U, P, A);
  4445. };
  4446. !s && !r && !i && !a && !u && !l && !c && !d && !h && !m && !g2 && !f && (vn(e, (U, P) => {
  4447. var j, Z, Y, ee, Re, ie, xe, ft;
  4448. const A = t.getMergedCell(U, P);
  4449. if (A) {
  4450. if (A.endColumn !== e.endColumn) {
  4451. const X2 = (j = o.getValue(A.startRow, A.startColumn)) == null ? void 0 : j.s;
  4452. o.setValue(U, P, {
  4453. s: {
  4454. bd: X2 != null && X2.bd ? Object.assign(X2.bd, { r: null }) : { r: null }
  4455. }
  4456. });
  4457. }
  4458. if (A.startColumn !== e.startColumn) {
  4459. const X2 = (Z = o.getValue(A.startRow, A.startColumn)) == null ? void 0 : Z.s;
  4460. o.setValue(U, P, {
  4461. s: {
  4462. bd: X2 != null && X2.bd ? Object.assign(X2.bd, { l: null }) : { l: null }
  4463. }
  4464. });
  4465. }
  4466. if (A.endRow !== e.endRow) {
  4467. const X2 = (Y = o.getValue(A.startRow, A.startColumn)) == null ? void 0 : Y.s;
  4468. o.setValue(U, P, {
  4469. s: {
  4470. bd: X2 != null && X2.bd ? Object.assign(X2.bd, { b: null }) : { b: null }
  4471. }
  4472. });
  4473. }
  4474. if (A.startRow !== e.startRow) {
  4475. const X2 = (ee = o.getValue(A.startRow, A.startColumn)) == null ? void 0 : ee.s;
  4476. o.setValue(U, P, {
  4477. s: {
  4478. bd: X2 != null && X2.bd ? Object.assign(X2.bd, { t: null }) : { t: null }
  4479. }
  4480. });
  4481. }
  4482. } else {
  4483. if (P !== e.endColumn) {
  4484. const X2 = (Re = o.getValue(U, P)) == null ? void 0 : Re.s;
  4485. o.setValue(U, P, {
  4486. s: {
  4487. bd: X2 != null && X2.bd ? Object.assign(X2.bd, { r: null }) : { r: null }
  4488. }
  4489. });
  4490. }
  4491. if (P !== e.startColumn) {
  4492. const X2 = (ie = o.getValue(U, P)) == null ? void 0 : ie.s;
  4493. o.setValue(U, P, {
  4494. s: {
  4495. bd: X2 != null && X2.bd ? Object.assign(X2.bd, { l: null }) : { l: null }
  4496. }
  4497. });
  4498. }
  4499. if (U !== e.endRow) {
  4500. const X2 = (xe = o.getValue(U, P)) == null ? void 0 : xe.s;
  4501. o.setValue(U, P, {
  4502. s: {
  4503. bd: X2 != null && X2.bd ? Object.assign(X2.bd, { b: null }) : { b: null }
  4504. }
  4505. });
  4506. }
  4507. if (U !== e.startRow) {
  4508. const X2 = (ft = o.getValue(U, P)) == null ? void 0 : ft.s;
  4509. o.setValue(U, P, {
  4510. s: {
  4511. bd: X2 != null && X2.bd ? Object.assign(X2.bd, { t: null }) : { t: null }
  4512. }
  4513. });
  4514. }
  4515. }
  4516. }), T2(w, { b: null }), T2(p, { t: null }, true), T2(b, { t: null }), T2(C, { b: null }, true), T2(y, { r: null }), T2(S, { l: null }, true), T2(x, { l: null }), T2(I, { r: null }, true), T2(e, { tl_br: null }, true), T2(e, { tl_bc: null }, true), T2(e, { tl_mr: null }, true), T2(e, { bl_tr: null }, true), T2(e, { ml_tr: null }, true), T2(e, { bc_tr: null }, true));
  4517. };
  4518. var rn = {
  4519. id: "sheet.command.set-border",
  4520. type: ar.COMMAND,
  4521. handler: (n, e) => {
  4522. var C;
  4523. const t = n.get(Pt), o = n.get(cn), s = n.get(_n), r = n.get(F), i = n.get(kt2), a = N(s, e);
  4524. if (!a)
  4525. return false;
  4526. const u = (C = r.getCurrentSelections()) == null ? void 0 : C.map((S) => S.range);
  4527. if (!(u != null && u.length))
  4528. return false;
  4529. const { activeBorderType: l } = i.getBorderInfo();
  4530. if (!l)
  4531. return false;
  4532. const c = bu(i, a, u);
  4533. yu2(c), Uu(c), Eu2(c), Pu(c);
  4534. const { unitId: d, subUnitId: h, mr: m } = c, g2 = {
  4535. unitId: d,
  4536. subUnitId: h,
  4537. cellValue: m.getData()
  4538. }, f = Ae(
  4539. n,
  4540. g2
  4541. );
  4542. return t.syncExecuteCommand(Q.id, g2) ? (o.pushUndoRedo({
  4543. unitID: d,
  4544. undoMutations: [{ id: Q.id, params: f }],
  4545. redoMutations: [{ id: Q.id, params: g2 }]
  4546. }), true) : false;
  4547. }
  4548. };
  4549. var Tu = {
  4550. id: "sheet.command.set-border-position",
  4551. type: ar.COMMAND,
  4552. handler: (n, e) => {
  4553. if (!e.value)
  4554. return false;
  4555. const t = n.get(Pt);
  4556. return n.get(kt2).setType(e.value), t.syncExecuteCommand(rn.id);
  4557. }
  4558. };
  4559. var ku = {
  4560. id: "sheet.command.set-border-style",
  4561. type: ar.COMMAND,
  4562. handler: (n, e) => {
  4563. const t = n.get(Pt);
  4564. return n.get(kt2).setStyle(e.value), t.syncExecuteCommand(rn.id);
  4565. }
  4566. };
  4567. var Nu = {
  4568. id: "sheet.command.set-border-color",
  4569. type: ar.COMMAND,
  4570. handler: (n, e) => {
  4571. const t = n.get(Pt);
  4572. return n.get(kt2).setColor(e.value), t.syncExecuteCommand(rn.id);
  4573. }
  4574. };
  4575. var Ou = {
  4576. id: "sheet.command.set-border-basic",
  4577. type: ar.COMMAND,
  4578. handler: (n, e) => {
  4579. const { unitId: t, subUnitId: o, value: s } = e, { type: r, color: i, style: a } = s, u = n.get(Pt), l = n.get(kt2);
  4580. return l.setType(r), i && l.setColor(i), l.setStyle(a), u.syncExecuteCommand(rn.id, {
  4581. unitId: t,
  4582. subUnitId: o
  4583. });
  4584. }
  4585. };
  4586. function Du(n, e) {
  4587. if (n == null)
  4588. return n;
  4589. const t = re.deepClone(n);
  4590. if (e == null)
  4591. return t;
  4592. const o = {};
  4593. return "h" in e && (o.h = t.h), "ia" in e && (o.ia = t.ia), "ah" in e && (o.ah = t.ah), "hd" in e && (o.hd = t.hd), "s" in e && (o.s = t.s), "custom" in e && (o.custom = t.custom), o;
  4594. }
  4595. function Au(n, e) {
  4596. if (n == null)
  4597. return n;
  4598. const t = re.deepClone(n);
  4599. if (e == null)
  4600. return t;
  4601. const o = {};
  4602. return "w" in e && (o.w = t.w), "hd" in e && (o.hd = t.hd), "s" in e && (o.s = t.s), "custom" in e && (o.custom = t.custom), o;
  4603. }
  4604. var xu = (n, e) => {
  4605. const { unitId: t, subUnitId: o, columnData: s } = n, r = {}, i = e.getColumnManager();
  4606. for (const a in s) {
  4607. const u = s[a], l = i.getColumn(Number(a));
  4608. r[a] = Au(l, u);
  4609. }
  4610. return {
  4611. unitId: t,
  4612. subUnitId: o,
  4613. columnData: r
  4614. };
  4615. };
  4616. var Lt = {
  4617. id: "sheet.mutation.set-col-data",
  4618. type: ar.MUTATION,
  4619. handler: (n, e) => {
  4620. const { columnData: t } = e, o = n.get(_n), s = N(o, e);
  4621. if (!s)
  4622. return false;
  4623. const { worksheet: r } = s, i = r.getColumnManager();
  4624. for (const a in t) {
  4625. const u = t[a];
  4626. if (u == null) {
  4627. i.removeColumn(Number(a));
  4628. continue;
  4629. }
  4630. const l = i.getColumnOrCreate(Number(a));
  4631. Object.assign(l, u);
  4632. }
  4633. return true;
  4634. }
  4635. };
  4636. var $u = {
  4637. type: ar.COMMAND,
  4638. id: "sheet.command.set-col-data",
  4639. handler: (n, e) => {
  4640. const t = n.get(Pt), o = n.get(cn), s = n.get(_n), r = N(s, e);
  4641. if (!r)
  4642. return false;
  4643. const { columnData: i } = e, { unitId: a, subUnitId: u, worksheet: l } = r, c = {
  4644. subUnitId: u,
  4645. unitId: a,
  4646. columnData: i
  4647. }, d = xu(c, l);
  4648. return t.syncExecuteCommand(Lt.id, c) ? (o.pushUndoRedo({
  4649. unitID: a,
  4650. undoMutations: [{ id: Lt.id, params: d }],
  4651. redoMutations: [{ id: Lt.id, params: c }]
  4652. }), true) : false;
  4653. }
  4654. };
  4655. var Wu = (n, e) => {
  4656. if (n.get(_n).getUniverSheetInstance(e.unitId) == null)
  4657. throw new Error("universheet is null error!");
  4658. return {
  4659. unitId: e.unitId,
  4660. subUnitId: e.subUnitId,
  4661. ranges: e.ranges
  4662. };
  4663. };
  4664. var Xt2 = {
  4665. id: "sheet.mutation.set-col-hidden",
  4666. type: ar.MUTATION,
  4667. handler: (n, e) => {
  4668. const o = n.get(_n).getUniverSheetInstance(e.unitId);
  4669. if (!o)
  4670. return false;
  4671. const s = o.getSheetBySheetId(e.subUnitId).getColumnManager();
  4672. for (let r = 0; r < e.ranges.length; r++) {
  4673. const i = e.ranges[r];
  4674. for (let a = i.startColumn; a < i.endColumn + 1; a++) {
  4675. const u = s.getColumnOrCreate(a);
  4676. u != null && (u.hd = we.TRUE);
  4677. }
  4678. }
  4679. return true;
  4680. }
  4681. };
  4682. var Lu = (n, e) => {
  4683. if (n.get(_n).getUniverSheetInstance(e.unitId) == null)
  4684. throw new Error("universheet is null error!");
  4685. return {
  4686. unitId: e.unitId,
  4687. subUnitId: e.subUnitId,
  4688. ranges: e.ranges
  4689. };
  4690. };
  4691. var qt2 = {
  4692. id: "sheet.mutation.set-col-visible",
  4693. type: ar.MUTATION,
  4694. handler: (n, e) => {
  4695. const o = n.get(_n).getUniverSheetInstance(e.unitId);
  4696. if (!o)
  4697. return false;
  4698. const s = o.getSheetBySheetId(e.subUnitId).getColumnManager();
  4699. for (let r = 0; r < e.ranges.length; r++) {
  4700. const i = e.ranges[r];
  4701. for (let a = i.startColumn; a < i.endColumn + 1; a++) {
  4702. const u = s.getColumnOrCreate(a);
  4703. u != null && (u.hd = we.FALSE);
  4704. }
  4705. }
  4706. return true;
  4707. }
  4708. };
  4709. var Kn = {
  4710. type: ar.COMMAND,
  4711. id: "sheet.command.set-col-visible-on-cols",
  4712. handler: (n, e) => {
  4713. var C, S;
  4714. const { unitId: t, subUnitId: o, ranges: s } = e, r = n.get(V), i = n.get(Pt), a = n.get(_n), u = N(a, { unitId: t, subUnitId: o });
  4715. if (!u)
  4716. return false;
  4717. const { worksheet: l } = u, c = {
  4718. unitId: t,
  4719. subUnitId: o,
  4720. ranges: s
  4721. }, d = {
  4722. unitId: t,
  4723. subUnitId: o,
  4724. reveal: true,
  4725. selections: s.map((I) => ({ range: I, primary: ve(I, l), style: null }))
  4726. }, h = Lu(n, c), m = {
  4727. unitId: t,
  4728. subUnitId: o,
  4729. selections: Er(s).map((I) => ({
  4730. range: I,
  4731. primary: ve(I, l),
  4732. style: null
  4733. }))
  4734. }, g2 = mu([
  4735. { id: qt2.id, params: c },
  4736. { id: re2.id, params: d }
  4737. ], i), f = r.onCommandExecute({
  4738. id: Kn.id,
  4739. params: e
  4740. }), p = mu([...f.redos], i);
  4741. return g2.result && p.result && n.get(cn).pushUndoRedo({
  4742. unitID: t,
  4743. undoMutations: [
  4744. { id: Xt2.id, params: h },
  4745. { id: re2.id, params: m },
  4746. ...(C = f.undos) != null ? C : []
  4747. ],
  4748. redoMutations: [
  4749. ...(S = f.preRedos) != null ? S : [],
  4750. { id: qt2.id, params: c },
  4751. { id: re2.id, params: d },
  4752. ...f.redos
  4753. ]
  4754. }), true;
  4755. }
  4756. };
  4757. var br = {
  4758. type: ar.COMMAND,
  4759. id: "sheet.command.set-selected-cols-visible",
  4760. handler: (n) => {
  4761. var l;
  4762. const e = n.get(F), t = n.get(Pt), o = (l = e.getCurrentSelections()) == null ? void 0 : l.map((c) => c.range).filter((c) => c.rangeType === De.COLUMN);
  4763. if (!(o != null && o.length))
  4764. return false;
  4765. const s = N(n.get(_n));
  4766. if (!s)
  4767. return false;
  4768. const { worksheet: r, unitId: i, subUnitId: a } = s, u = o.map((c) => r.getHiddenCols(c.startColumn, c.endColumn)).flat();
  4769. return t.executeCommand(Kn.id, {
  4770. unitId: i,
  4771. subUnitId: a,
  4772. ranges: u
  4773. });
  4774. }
  4775. };
  4776. var yr = {
  4777. type: ar.COMMAND,
  4778. id: "sheet.command.set-col-hidden",
  4779. handler: (n, e) => {
  4780. var S, I, w, b;
  4781. const t = n.get(F), o = n.get(V), s = n.get(_n), r = n.get(Pt);
  4782. let i = (S = e == null ? void 0 : e.ranges) != null && S.length ? e.ranges : (I = t.getCurrentSelections()) == null ? void 0 : I.map((y) => y.range).filter((y) => y.rangeType === De.COLUMN);
  4783. if (!(i != null && i.length))
  4784. return false;
  4785. const a = N(s, e);
  4786. if (!a)
  4787. return false;
  4788. const { worksheet: u, unitId: l, subUnitId: c } = a;
  4789. i = Vu(a.worksheet, i);
  4790. const d = { unitId: l, subUnitId: c, ranges: i }, h = {
  4791. unitId: l,
  4792. subUnitId: c,
  4793. selections: Er(i).map((y) => ({
  4794. range: y,
  4795. primary: ve(y, u),
  4796. style: null
  4797. }))
  4798. }, m = Wu(n, d), g2 = {
  4799. unitId: l,
  4800. subUnitId: c,
  4801. reveal: true,
  4802. selections: i.map((y) => ({
  4803. range: y,
  4804. primary: ve(y, u),
  4805. style: null
  4806. }))
  4807. }, f = mu([
  4808. { id: Xt2.id, params: d },
  4809. { id: re2.id, params: h }
  4810. ], r), p = o.onCommandExecute({
  4811. id: yr.id,
  4812. params: d
  4813. }), C = mu([...p.redos], r);
  4814. return f.result && C.result ? (n.get(cn).pushUndoRedo({
  4815. unitID: l,
  4816. undoMutations: [
  4817. { id: qt2.id, params: m },
  4818. { id: re2.id, params: g2 },
  4819. ...(w = p.undos) != null ? w : []
  4820. ],
  4821. redoMutations: [
  4822. ...(b = p.preRedos) != null ? b : [],
  4823. { id: Xt2.id, params: d },
  4824. { id: re2.id, params: h },
  4825. ...p.redos
  4826. ]
  4827. }), true) : false;
  4828. }
  4829. };
  4830. function Vu(n, e) {
  4831. const t = n.getRowCount() - 1, o = n.getHiddenCols(), s = [];
  4832. return e.forEach((r) => {
  4833. const i = o.filter((a) => a.startColumn >= r.startColumn && a.endColumn <= r.endColumn);
  4834. if (i.length) {
  4835. let a = r.startColumn;
  4836. i.forEach((u) => {
  4837. u.startColumn > a && (s.push({ startColumn: a, endColumn: u.startColumn - 1, startRow: 0, endRow: t }), a = u.endColumn + 1);
  4838. }), a <= r.endColumn && s.push({ startColumn: a, endColumn: r.endColumn, startRow: 0, endRow: t });
  4839. } else
  4840. s.push(r);
  4841. }), s;
  4842. }
  4843. function Er(n) {
  4844. return Hu(n).map((t) => {
  4845. const o = t.startColumn === 0 ? t.endColumn + 1 : t.startColumn - 1;
  4846. return {
  4847. ...t,
  4848. startColumn: o,
  4849. endColumn: o
  4850. };
  4851. });
  4852. }
  4853. function Hu(n) {
  4854. const e = [];
  4855. let t;
  4856. return n.sort((o, s) => o.startColumn - s.startColumn).forEach((o) => {
  4857. if (!t) {
  4858. t = o;
  4859. return;
  4860. }
  4861. t.endColumn === o.startColumn - 1 ? t.endColumn = o.endColumn : (e.push(t), t = o);
  4862. }), e.push(t), e;
  4863. }
  4864. var Ur = {
  4865. id: "sheet.command.set-defined-name",
  4866. type: ar.COMMAND,
  4867. handler: (n, e) => {
  4868. var d, h;
  4869. const t = n.get(Pt), o = n.get(cn), s = n.get(V);
  4870. if (!e)
  4871. return false;
  4872. const r = {
  4873. ...e
  4874. }, i = Yb(n, e), a = s.onCommandExecute({ id: Ur.id, params: e }), u = [
  4875. ...(d = a.preRedos) != null ? d : [],
  4876. { id: Xi.id, params: i },
  4877. { id: sa.id, params: r },
  4878. ...a.redos
  4879. ], l = [
  4880. ...(h = a.preUndos) != null ? h : [],
  4881. { id: Xi.id, params: r },
  4882. { id: sa.id, params: i },
  4883. ...a.undos
  4884. ];
  4885. return mu(u, t) ? (o.pushUndoRedo({
  4886. unitID: e.unitId,
  4887. undoMutations: l.filter(Boolean),
  4888. redoMutations: u.filter(Boolean)
  4889. }), true) : false;
  4890. }
  4891. };
  4892. var Pr = (n, e) => {
  4893. const o = n.get(_n).getUniverSheetInstance(e.unitId);
  4894. if (o == null)
  4895. throw new Error("universheet is null error!");
  4896. const s = o.getSheetBySheetId(e.subUnitId);
  4897. if (s == null)
  4898. throw new Error("worksheet is null error!");
  4899. const i = s.getConfig().freeze;
  4900. return {
  4901. unitId: e.unitId,
  4902. subUnitId: e.subUnitId,
  4903. ...i
  4904. };
  4905. };
  4906. var ut = {
  4907. id: "sheet.mutation.set-frozen",
  4908. type: ar.MUTATION,
  4909. handler: (n, e) => {
  4910. const o = n.get(_n).getUniverSheetInstance(e.unitId);
  4911. if (o == null)
  4912. throw new Error("universheet is null error!");
  4913. const s = o.getSheetBySheetId(e.subUnitId);
  4914. if (!s)
  4915. return false;
  4916. const r = s.getConfig(), { startRow: i, startColumn: a, ySplit: u, xSplit: l } = e;
  4917. return r.freeze = { startRow: i, startColumn: a, ySplit: u, xSplit: l }, true;
  4918. }
  4919. };
  4920. var Bu = {
  4921. type: ar.COMMAND,
  4922. id: "sheet.command.set-frozen",
  4923. handler: (n, e) => {
  4924. const t = n.get(Pt), o = n.get(cn), s = n.get(_n), r = N(s, { unitId: e.unitId, subUnitId: e.subUnitId });
  4925. if (!r)
  4926. return false;
  4927. const { unitId: i, subUnitId: a, worksheet: u } = r, { startColumn: l, startRow: c, xSplit: d, ySplit: h } = e;
  4928. if (c >= u.getRowCount() || l >= u.getColumnCount() || d >= u.getColumnCount() || h >= u.getRowCount())
  4929. return false;
  4930. const m = {
  4931. unitId: i,
  4932. subUnitId: a,
  4933. ...e
  4934. }, g2 = Pr(n, m);
  4935. return t.syncExecuteCommand(ut.id, m) ? (o.pushUndoRedo({
  4936. unitID: i,
  4937. undoMutations: [{ id: ut.id, params: g2 }],
  4938. redoMutations: [{ id: ut.id, params: m }]
  4939. }), true) : false;
  4940. }
  4941. };
  4942. var Fu = {
  4943. type: ar.COMMAND,
  4944. id: "sheet.command.cancel-frozen",
  4945. handler: (n, e) => {
  4946. const t = n.get(Pt), o = n.get(_n), s = n.get(cn), r = N(o, { unitId: e == null ? void 0 : e.unitId, subUnitId: e == null ? void 0 : e.subUnitId });
  4947. if (!r)
  4948. return false;
  4949. const { unitId: i, subUnitId: a } = r, u = {
  4950. unitId: i,
  4951. subUnitId: a,
  4952. startRow: -1,
  4953. startColumn: -1,
  4954. xSplit: 0,
  4955. ySplit: 0
  4956. }, l = Pr(n, u);
  4957. return t.syncExecuteCommand(ut.id, u) && s.pushUndoRedo({
  4958. unitID: i,
  4959. undoMutations: [{ id: ut.id, params: l }],
  4960. redoMutations: [{ id: ut.id, params: u }]
  4961. }), true;
  4962. }
  4963. };
  4964. var Vt = {
  4965. id: "sheet.mutation.set-gridlines-color",
  4966. type: ar.MUTATION,
  4967. handler: (n, e) => {
  4968. const t = N(n.get(_n), e);
  4969. if (!t)
  4970. return false;
  4971. const { worksheet: o } = t, s = o.getConfig();
  4972. return s.gridlinesColor = e.color, true;
  4973. }
  4974. };
  4975. var ju = {
  4976. type: ar.COMMAND,
  4977. id: "sheet.command.set-gridlines-color",
  4978. handler: (n, e) => {
  4979. const t = n.get(Pt), o = n.get(cn), s = n.get(_n), r = N(s);
  4980. if (!r)
  4981. return false;
  4982. const { worksheet: i } = r, a = i.getConfig().gridlinesColor;
  4983. if (a === (e == null ? void 0 : e.color))
  4984. return false;
  4985. const { unitId: u, subUnitId: l } = r, c = {
  4986. color: e == null ? void 0 : e.color,
  4987. unitId: u,
  4988. subUnitId: l
  4989. }, d = {
  4990. color: a,
  4991. unitId: u,
  4992. subUnitId: l
  4993. };
  4994. return t.syncExecuteCommand(Vt.id, c) ? (o.pushUndoRedo({
  4995. unitID: u,
  4996. undoMutations: [{ id: Vt.id, params: d }],
  4997. redoMutations: [{ id: Vt.id, params: c }]
  4998. }), true) : false;
  4999. }
  5000. };
  5001. var he = {
  5002. id: "sheet.mutation.set-range-protection",
  5003. type: ar.MUTATION,
  5004. handler: (n, e) => {
  5005. const { unitId: t, subUnitId: o, rule: s, ruleId: r } = e;
  5006. return n.get(de).setRule(t, o, r, s), true;
  5007. }
  5008. };
  5009. var qd = (n, e) => {
  5010. const { unitId: t, subUnitId: o, ruleId: s } = e, i = n.get(de).getRule(t, o, s);
  5011. return i ? {
  5012. id: he.id,
  5013. params: {
  5014. ...e,
  5015. rule: i
  5016. }
  5017. } : null;
  5018. };
  5019. var Ct2 = {
  5020. id: "sheet.mutation.set-worksheet-protection",
  5021. type: ar.MUTATION,
  5022. handler: (n, e) => {
  5023. const { unitId: t, subUnitId: o, rule: s } = e;
  5024. return n.get(Ye).setRule(t, o, s), true;
  5025. }
  5026. };
  5027. var Gu = {
  5028. type: ar.COMMAND,
  5029. id: "sheet.command.set-protection",
  5030. async handler(n, e) {
  5031. if (!e)
  5032. return false;
  5033. const t = n.get(Pt), o = n.get(cn), s = n.get(de), { rule: r, oldRule: i } = e, { unitId: a, subUnitId: u } = r, l = [], c = [];
  5034. return (i == null ? void 0 : i.unitType) === r.unitType ? r.unitType === D.Worksheet ? (l.push({ id: Ct2.id, params: { unitId: a, subUnitId: u, rule: r } }), c.push({ id: Ct2.id, params: { unitId: a, subUnitId: u, rule: i } })) : (l.push({ id: he.id, params: { unitId: a, subUnitId: u, rule: r, ruleId: r.id } }), c.push({ id: he.id, params: { unitId: a, subUnitId: u, ruleId: i.id, rule: i } })) : (i && (i.unitType === D.Worksheet ? (l.push({ id: St.id, params: { unitId: a, subUnitId: u } }), c.push({ id: ct.id, params: { unitId: a, rule: i, subUnitId: i.subUnitId } })) : i.unitType === D.SelectRange && (l.push({ id: ze.id, params: { unitId: a, subUnitId: u, ruleIds: [i.id] } }), c.push({ id: Ne.id, params: { unitId: a, subUnitId: u, rules: [i] } }))), r.unitType === D.Worksheet ? (l.push({ id: ct.id, params: { unitId: a, rule: r, subUnitId: r.subUnitId } }), c.unshift({ id: St.id, params: { unitId: a, subUnitId: u } })) : r.unitType === D.SelectRange && (r.id = s.createRuleId(a, u), l.push({ id: Ne.id, params: { unitId: a, subUnitId: u, rules: [r] } }), c.unshift({ id: ze.id, params: { unitId: a, subUnitId: u, ruleIds: [r.id] } }))), mu(l, t) && o.pushUndoRedo({
  5035. unitID: a,
  5036. undoMutations: c,
  5037. redoMutations: l
  5038. }), true;
  5039. }
  5040. };
  5041. var zu = (n, e) => {
  5042. const { unitId: t, subUnitId: o, rowData: s } = n, r = {}, i = e.getRowManager();
  5043. for (const a in s) {
  5044. const u = s[a], l = i.getRow(Number(a));
  5045. r[a] = Du(l, u);
  5046. }
  5047. return {
  5048. unitId: t,
  5049. subUnitId: o,
  5050. rowData: r
  5051. };
  5052. };
  5053. var Ht = {
  5054. id: "sheet.mutation.set-row-data",
  5055. type: ar.MUTATION,
  5056. handler: (n, e) => {
  5057. const { rowData: t } = e, o = n.get(_n), s = N(o, e);
  5058. if (!s)
  5059. return false;
  5060. const { worksheet: r } = s, i = r.getRowManager();
  5061. for (const a in t) {
  5062. const u = t[a];
  5063. if (u == null) {
  5064. i.removeRow(Number(a));
  5065. continue;
  5066. }
  5067. const l = i.getRowOrCreate(Number(a));
  5068. Object.assign(l, u);
  5069. }
  5070. return true;
  5071. }
  5072. };
  5073. var Ku = {
  5074. type: ar.COMMAND,
  5075. id: "sheet.command.set-row-data",
  5076. handler: (n, e) => {
  5077. const t = n.get(Pt), o = n.get(cn), s = n.get(_n), r = N(s, e);
  5078. if (!r)
  5079. return false;
  5080. const { rowData: i } = e, { unitId: a, subUnitId: u, worksheet: l } = r, c = {
  5081. subUnitId: u,
  5082. unitId: a,
  5083. rowData: i
  5084. }, d = zu(c, l);
  5085. return t.syncExecuteCommand(Ht.id, c) ? (o.pushUndoRedo({
  5086. unitID: a,
  5087. undoMutations: [{ id: Ht.id, params: d }],
  5088. redoMutations: [{ id: Ht.id, params: c }]
  5089. }), true) : false;
  5090. }
  5091. };
  5092. var Ju = (n, e) => {
  5093. if (n.get(_n).getUniverSheetInstance(e.unitId) == null)
  5094. throw new Error("universheet is null error!");
  5095. return {
  5096. unitId: e.unitId,
  5097. subUnitId: e.subUnitId,
  5098. ranges: e.ranges
  5099. };
  5100. };
  5101. var Zt = {
  5102. id: "sheet.mutation.set-row-visible",
  5103. type: ar.MUTATION,
  5104. handler: (n, e) => {
  5105. const o = n.get(_n).getUniverSheetInstance(e.unitId);
  5106. if (o == null)
  5107. throw new Error("universheet is null error!");
  5108. const s = o.getSheetBySheetId(e.subUnitId).getRowManager();
  5109. for (let r = 0; r < e.ranges.length; r++) {
  5110. const i = e.ranges[r];
  5111. for (let a = i.startRow; a < i.endRow + 1; a++) {
  5112. const u = s.getRowOrCreate(a);
  5113. u != null && (u.hd = 0);
  5114. }
  5115. }
  5116. return true;
  5117. }
  5118. };
  5119. var Yu = (n, e) => {
  5120. if (n.get(_n).getUniverSheetInstance(e.unitId) == null)
  5121. throw new Error("universheet is null error!");
  5122. return {
  5123. unitId: e.unitId,
  5124. subUnitId: e.subUnitId,
  5125. ranges: e.ranges
  5126. };
  5127. };
  5128. var Qt = {
  5129. id: "sheet.mutation.set-row-hidden",
  5130. type: ar.MUTATION,
  5131. handler: (n, e) => {
  5132. const o = n.get(_n).getUniverSheetInstance(e.unitId);
  5133. if (o == null)
  5134. throw new Error("universheet is null error!");
  5135. const s = o.getSheetBySheetId(e.subUnitId).getRowManager();
  5136. for (let r = 0; r < e.ranges.length; r++) {
  5137. const i = e.ranges[r];
  5138. for (let a = i.startRow; a < i.endRow + 1; a++) {
  5139. const u = s.getRowOrCreate(a);
  5140. u != null && (u.hd = 1);
  5141. }
  5142. }
  5143. return true;
  5144. }
  5145. };
  5146. var Jn = {
  5147. type: ar.COMMAND,
  5148. id: "sheet.command.set-specific-rows-visible",
  5149. handler: (n, e) => {
  5150. var C, S, I;
  5151. const { unitId: t, subUnitId: o, ranges: s } = e, r = n.get(Pt), i = n.get(cn), a = n.get(V), u = N(n.get(_n), { unitId: t, subUnitId: o });
  5152. if (!u)
  5153. return false;
  5154. const { worksheet: l } = u, c = { unitId: t, subUnitId: o, ranges: s }, d = {
  5155. unitId: t,
  5156. subUnitId: o,
  5157. reveal: true,
  5158. selections: s.map((w) => ({
  5159. range: w,
  5160. primary: ve(w, l),
  5161. style: null
  5162. }))
  5163. }, h = Ju(n, c), m = {
  5164. unitId: t,
  5165. subUnitId: o,
  5166. selections: Nr(s).map((w) => ({
  5167. range: w,
  5168. primary: ve(w, l),
  5169. style: null
  5170. }))
  5171. }, g2 = mu(
  5172. [
  5173. { id: Zt.id, params: c },
  5174. { id: re2.id, params: d }
  5175. ],
  5176. r
  5177. ), f = a.onCommandExecute({
  5178. id: Jn.id,
  5179. params: e
  5180. }), p = mu([...f.redos], r);
  5181. return g2.result && p.result && i.pushUndoRedo({
  5182. unitID: t,
  5183. undoMutations: [
  5184. ...(C = f.preUndos) != null ? C : [],
  5185. { id: Qt.id, params: h },
  5186. { id: re2.id, params: m },
  5187. ...(S = f.undos) != null ? S : []
  5188. ],
  5189. redoMutations: [
  5190. ...(I = f.preRedos) != null ? I : [],
  5191. { id: Zt.id, params: c },
  5192. { id: re2.id, params: d },
  5193. ...f.redos
  5194. ]
  5195. }), true;
  5196. }
  5197. };
  5198. var Tr = {
  5199. type: ar.COMMAND,
  5200. id: "sheet.command.set-selected-rows-visible",
  5201. handler: async (n) => {
  5202. var c;
  5203. const e = n.get(F), t = n.get(_n), o = n.get(Pt), s = (c = e.getCurrentSelections()) == null ? void 0 : c.map((d) => d.range).filter((d) => d.rangeType === De.ROW);
  5204. if (!(s != null && s.length))
  5205. return false;
  5206. const r = N(t);
  5207. if (!r)
  5208. return false;
  5209. const { worksheet: i, unitId: a, subUnitId: u } = r, l = s.map((d) => i.getHiddenRows(d.startRow, d.endRow)).flat();
  5210. return o.executeCommand(Jn.id, {
  5211. unitId: a,
  5212. subUnitId: u,
  5213. ranges: l
  5214. });
  5215. }
  5216. };
  5217. var kr = {
  5218. type: ar.COMMAND,
  5219. id: "sheet.command.set-rows-hidden",
  5220. handler: (n, e) => {
  5221. var S, I, w, b, y, x;
  5222. const t = n.get(F), o = n.get(Pt), s = n.get(cn), r = n.get(_n), i = n.get(V);
  5223. let a = (S = e == null ? void 0 : e.ranges) != null && S.length ? e.ranges : (I = t.getCurrentSelections()) == null ? void 0 : I.map((T2) => T2.range).filter((T2) => T2.rangeType === De.ROW);
  5224. if (!(a != null && a.length))
  5225. return false;
  5226. const u = N(r, e);
  5227. if (!u)
  5228. return false;
  5229. a = Xu(u.worksheet, a);
  5230. const { unitId: l, subUnitId: c, worksheet: d } = u, h = { unitId: l, subUnitId: c, ranges: a }, m = {
  5231. unitId: l,
  5232. subUnitId: c,
  5233. selections: Nr(a).map((T2) => ({
  5234. range: T2,
  5235. primary: ve(T2, d),
  5236. style: null
  5237. }))
  5238. }, g2 = Yu(n, h), f = {
  5239. unitId: l,
  5240. subUnitId: c,
  5241. reveal: true,
  5242. selections: a.map((T2) => ({
  5243. range: T2,
  5244. primary: ve(T2, d),
  5245. style: null
  5246. }))
  5247. }, p = i.onCommandExecute({ id: kr.id, params: h });
  5248. return mu([
  5249. ...(w = p.preRedos) != null ? w : [],
  5250. { id: Qt.id, params: h },
  5251. { id: re2.id, params: m },
  5252. ...p.redos
  5253. ], o).result && s.pushUndoRedo({
  5254. unitID: l,
  5255. undoMutations: [
  5256. ...(b = p.preUndos) != null ? b : [],
  5257. { id: Zt.id, params: g2 },
  5258. { id: re2.id, params: f },
  5259. ...(y = p.undos) != null ? y : []
  5260. ],
  5261. redoMutations: [
  5262. ...(x = p.preRedos) != null ? x : [],
  5263. { id: Qt.id, params: h },
  5264. { id: re2.id, params: m },
  5265. ...p.redos
  5266. ]
  5267. }), true;
  5268. }
  5269. };
  5270. function Xu(n, e) {
  5271. const t = n.getMaxColumns() - 1, o = n.getHiddenRows(), s = [];
  5272. return e.forEach((r) => {
  5273. const i = o.filter((a) => a.startRow >= r.startRow && a.endRow <= r.endRow);
  5274. if (i.length) {
  5275. let a = r.startRow;
  5276. i.forEach((u) => {
  5277. u.startRow > a && (s.push({ startRow: a, endRow: u.startRow - 1, startColumn: 0, endColumn: t }), a = u.endRow + 1);
  5278. }), a <= r.endRow && s.push({ startRow: a, endRow: r.endRow, startColumn: 0, endColumn: t });
  5279. } else
  5280. s.push(r);
  5281. }), s;
  5282. }
  5283. function Nr(n) {
  5284. return qu(n).map((t) => {
  5285. const o = t.startRow === 0 ? t.endRow + 1 : t.startRow - 1;
  5286. return {
  5287. ...t,
  5288. startRow: o,
  5289. endRow: o
  5290. };
  5291. });
  5292. }
  5293. function qu(n) {
  5294. const e = [];
  5295. let t;
  5296. return n.sort((o, s) => o.startRow - s.startRow).forEach((o) => {
  5297. if (!t) {
  5298. t = o;
  5299. return;
  5300. }
  5301. o.startRow === t.endRow + 1 ? t.endRow = o.endRow : (e.push(t), t = o);
  5302. }), e.push(t), e;
  5303. }
  5304. var fe = {
  5305. type: ar.COMMAND,
  5306. id: "sheet.command.set-style",
  5307. handler: (n, e) => {
  5308. var b;
  5309. const t = n.get(_n), o = N(t, e);
  5310. if (!o)
  5311. return false;
  5312. const { unitId: s, subUnitId: r, worksheet: i } = o, { range: a, style: u } = e, l = n.get(Pt), c = n.get(cn), d = n.get(F), h = a ? [a] : (b = d.getCurrentSelections()) == null ? void 0 : b.map((y) => y.range);
  5313. if (!(h != null && h.length))
  5314. return false;
  5315. const m = new kt(), g2 = Za(i);
  5316. if (re.isArray(u.value))
  5317. for (let y = 0; y < h.length; y++)
  5318. g2.forOperableEach(h[y], (x, T2, U) => {
  5319. m.setValue(x, T2, {
  5320. s: {
  5321. [u.type]: u.value[x - U.startRow][T2 - U.startColumn]
  5322. }
  5323. });
  5324. });
  5325. else
  5326. for (let y = 0; y < h.length; y++) {
  5327. const x = {
  5328. s: {
  5329. [u.type]: u.value
  5330. }
  5331. };
  5332. g2.forOperableEach(h[y], (T2, U) => m.setValue(T2, U, x));
  5333. }
  5334. const f = {
  5335. subUnitId: r,
  5336. unitId: s,
  5337. cellValue: m.getMatrix()
  5338. }, p = Ae(
  5339. n,
  5340. f
  5341. ), C = l.syncExecuteCommand(
  5342. Q.id,
  5343. f
  5344. ), { undos: S, redos: I } = n.get(V).onCommandExecute({
  5345. id: fe.id,
  5346. params: e
  5347. }), w = mu([...I], l);
  5348. return C && w.result ? (c.pushUndoRedo({
  5349. unitID: f.unitId,
  5350. undoMutations: [{ id: Q.id, params: p }, ...S],
  5351. redoMutations: [{ id: Q.id, params: f }, ...I]
  5352. }), true) : false;
  5353. }
  5354. };
  5355. var Zd = {
  5356. type: ar.COMMAND,
  5357. id: "sheet.command.set-bold",
  5358. handler: (n) => {
  5359. const e = n.get(F).getCurrentLastSelection();
  5360. if (!e)
  5361. return false;
  5362. const t = N(n.get(_n));
  5363. if (!t)
  5364. return false;
  5365. const { worksheet: o } = t, { actualRow: s, actualColumn: r } = e.primary, a = {
  5366. style: {
  5367. type: "bl",
  5368. value: o.getRange(s, r).getFontWeight() === Gs.BOLD ? we.FALSE : we.TRUE
  5369. }
  5370. };
  5371. return n.get(Pt).syncExecuteCommand(fe.id, a);
  5372. }
  5373. };
  5374. var Qd = {
  5375. type: ar.COMMAND,
  5376. id: "sheet.command.set-italic",
  5377. handler: (n) => {
  5378. const e = n.get(F).getCurrentLastSelection();
  5379. if (!e)
  5380. return false;
  5381. const t = N(n.get(_n));
  5382. if (!t)
  5383. return false;
  5384. const { worksheet: o } = t;
  5385. let s = true;
  5386. if (e.primary) {
  5387. const { startRow: i, startColumn: a } = e.primary;
  5388. s = o.getRange(i, a).getFontStyle() === Vs.ITALIC;
  5389. }
  5390. const r = {
  5391. style: {
  5392. type: "it",
  5393. value: s ? we.FALSE : we.TRUE
  5394. }
  5395. };
  5396. return n.get(Pt).syncExecuteCommand(fe.id, r);
  5397. }
  5398. };
  5399. var eh = {
  5400. type: ar.COMMAND,
  5401. id: "sheet.command.set-underline",
  5402. handler: (n) => {
  5403. const e = n.get(F).getCurrentLastSelection();
  5404. if (!e)
  5405. return false;
  5406. const t = N(n.get(_n));
  5407. if (!t)
  5408. return false;
  5409. const { worksheet: o } = t;
  5410. let s = true;
  5411. e.primary && (s = !!o.getRange(e.primary.startRow, e.primary.startColumn).getUnderline().s);
  5412. const r = {
  5413. style: {
  5414. type: "ul",
  5415. value: {
  5416. s: s ? we.FALSE : we.TRUE
  5417. }
  5418. }
  5419. };
  5420. return n.get(Pt).syncExecuteCommand(fe.id, r);
  5421. }
  5422. };
  5423. var th = {
  5424. type: ar.COMMAND,
  5425. id: "sheet.command.set-stroke",
  5426. handler: (n) => {
  5427. const e = n.get(F).getCurrentLastSelection();
  5428. if (!e)
  5429. return false;
  5430. const t = N(n.get(_n));
  5431. if (!t)
  5432. return false;
  5433. const { worksheet: o } = t;
  5434. let s = true;
  5435. e.primary && (s = !!o.getRange(e.primary.actualRow, e.primary.actualColumn).getStrikeThrough().s);
  5436. const r = {
  5437. style: {
  5438. type: "st",
  5439. value: { s: s ? we.FALSE : we.TRUE }
  5440. }
  5441. };
  5442. return n.get(Pt).syncExecuteCommand(fe.id, r);
  5443. }
  5444. };
  5445. var nh = {
  5446. type: ar.COMMAND,
  5447. id: "sheet.command.set-overline",
  5448. handler: (n) => {
  5449. const e = n.get(F).getCurrentLastSelection();
  5450. if (!e)
  5451. return false;
  5452. const t = N(n.get(_n));
  5453. if (!t)
  5454. return false;
  5455. const { worksheet: o } = t;
  5456. let s = true;
  5457. e.primary && (s = !!o.getRange(e.primary.startRow, e.primary.startColumn).getOverline().s);
  5458. const r = {
  5459. style: {
  5460. type: "ol",
  5461. value: {
  5462. s: s ? we.FALSE : we.TRUE
  5463. }
  5464. }
  5465. };
  5466. return n.get(Pt).syncExecuteCommand(fe.id, r);
  5467. }
  5468. };
  5469. var oh = {
  5470. type: ar.COMMAND,
  5471. id: "sheet.command.set-font-family",
  5472. handler: (n, e) => {
  5473. if (!e)
  5474. return false;
  5475. const t = n.get(Pt), o = {
  5476. style: {
  5477. type: "ff",
  5478. value: e.value
  5479. }
  5480. };
  5481. return t.syncExecuteCommand(fe.id, o);
  5482. }
  5483. };
  5484. var sh = {
  5485. type: ar.COMMAND,
  5486. id: "sheet.command.set-font-size",
  5487. handler: (n, e) => {
  5488. if (!e)
  5489. return false;
  5490. const t = n.get(Pt), o = {
  5491. style: {
  5492. type: "fs",
  5493. value: e.value
  5494. }
  5495. };
  5496. return t.syncExecuteCommand(fe.id, o);
  5497. }
  5498. };
  5499. var Zu = {
  5500. type: ar.COMMAND,
  5501. id: "sheet.command.set-text-color",
  5502. handler: (n, e) => {
  5503. if (!e)
  5504. return false;
  5505. const t = n.get(Pt), o = {
  5506. style: {
  5507. type: "cl",
  5508. value: {
  5509. rgb: e.value
  5510. }
  5511. }
  5512. };
  5513. return t.syncExecuteCommand(fe.id, o);
  5514. }
  5515. };
  5516. var Qu = {
  5517. type: ar.COMMAND,
  5518. id: "sheet.command.reset-text-color",
  5519. handler: (n) => {
  5520. const e = n.get(Pt), t = {
  5521. style: {
  5522. type: "cl",
  5523. value: {
  5524. rgb: null
  5525. // use null to reset text color
  5526. }
  5527. }
  5528. };
  5529. return e.syncExecuteCommand(fe.id, t);
  5530. }
  5531. };
  5532. var el = {
  5533. type: ar.COMMAND,
  5534. id: "sheet.command.set-background-color",
  5535. handler: (n, e) => {
  5536. if (!e || !e.value)
  5537. return false;
  5538. const t = n.get(Pt), o = {
  5539. style: {
  5540. type: "bg",
  5541. value: {
  5542. rgb: e.value
  5543. }
  5544. }
  5545. };
  5546. return t.syncExecuteCommand(fe.id, o);
  5547. }
  5548. };
  5549. var tl = {
  5550. type: ar.COMMAND,
  5551. id: "sheet.command.reset-background-color",
  5552. handler: (n) => {
  5553. const e = n.get(Pt), t = {
  5554. style: {
  5555. type: "bg",
  5556. value: {
  5557. rgb: null
  5558. // use null to reset background color
  5559. }
  5560. }
  5561. };
  5562. return e.syncExecuteCommand(fe.id, t);
  5563. }
  5564. };
  5565. var nl = {
  5566. type: ar.COMMAND,
  5567. id: "sheet.command.set-vertical-text-align",
  5568. handler: (n, e) => {
  5569. if (!e)
  5570. return false;
  5571. const t = n.get(Pt), o = {
  5572. unitId: e.unitId,
  5573. subUnitId: e.subUnitId,
  5574. range: e.range,
  5575. style: {
  5576. type: "vt",
  5577. value: e.value
  5578. }
  5579. };
  5580. return t.syncExecuteCommand(fe.id, o);
  5581. }
  5582. };
  5583. var ol = {
  5584. type: ar.COMMAND,
  5585. id: "sheet.command.set-horizontal-text-align",
  5586. handler: (n, e) => {
  5587. if (!e)
  5588. return false;
  5589. const t = n.get(Pt), o = {
  5590. unitId: e.unitId,
  5591. subUnitId: e.subUnitId,
  5592. range: e.range,
  5593. style: {
  5594. type: "ht",
  5595. value: e.value
  5596. }
  5597. };
  5598. return t.syncExecuteCommand(fe.id, o);
  5599. }
  5600. };
  5601. var sl = {
  5602. type: ar.COMMAND,
  5603. id: "sheet.command.set-text-wrap",
  5604. handler: (n, e) => {
  5605. if (!e)
  5606. return false;
  5607. const t = n.get(Pt), o = {
  5608. unitId: e.unitId,
  5609. subUnitId: e.subUnitId,
  5610. range: e.range,
  5611. style: {
  5612. type: "tb",
  5613. value: e.value
  5614. }
  5615. };
  5616. return t.syncExecuteCommand(fe.id, o);
  5617. }
  5618. };
  5619. var rl = {
  5620. type: ar.COMMAND,
  5621. id: "sheet.command.set-text-rotation",
  5622. handler: (n, e) => {
  5623. if (!e)
  5624. return false;
  5625. const t = typeof e.value == "number" ? { a: e.value } : { a: 0, v: we.TRUE }, o = n.get(Pt), s = {
  5626. style: {
  5627. type: "tr",
  5628. value: t
  5629. }
  5630. };
  5631. return o.syncExecuteCommand(fe.id, s);
  5632. }
  5633. };
  5634. var il = (n, e) => {
  5635. const r = n.get(_n).getUniverSheetInstance(e.unitId).getSheetBySheetId(e.subUnitId).getConfig().tabColor;
  5636. return {
  5637. ...re.deepClone(e),
  5638. color: r
  5639. };
  5640. };
  5641. var fn3 = {
  5642. id: "sheet.mutation.set-tab-color",
  5643. type: ar.MUTATION,
  5644. handler: (n, e) => {
  5645. const t = n.get(_n).getUniverSheetInstance(e.unitId);
  5646. if (!t)
  5647. return false;
  5648. const o = t.getSheetBySheetId(e.subUnitId);
  5649. return o ? (o.getConfig().tabColor = e.color, true) : false;
  5650. }
  5651. };
  5652. var al = {
  5653. type: ar.COMMAND,
  5654. id: "sheet.command.set-tab-color",
  5655. handler: (n, e) => {
  5656. const t = n.get(Pt), o = n.get(cn), s = N(n.get(_n));
  5657. if (!s)
  5658. return false;
  5659. const { unitId: r, subUnitId: i } = s, a = {
  5660. color: e.value,
  5661. unitId: r,
  5662. subUnitId: i
  5663. }, u = il(n, a);
  5664. return t.syncExecuteCommand(fn3.id, a) ? (o.pushUndoRedo({
  5665. unitID: r,
  5666. undoMutations: [{ id: fn3.id, params: u }],
  5667. redoMutations: [{ id: fn3.id, params: a }]
  5668. }), true) : false;
  5669. }
  5670. };
  5671. var Or = {
  5672. id: "sheet.mutation.set-workbook-name",
  5673. type: ar.MUTATION,
  5674. handler: (n, e) => {
  5675. const t = n.get(_n).getUnit(e.unitId, Fe.UNIVER_SHEET);
  5676. return t ? (t.setName(e.name), true) : false;
  5677. }
  5678. };
  5679. var Dr = {
  5680. type: ar.COMMAND,
  5681. id: "sheet.command.set-workbook-name",
  5682. handler: async (n, e) => {
  5683. var l;
  5684. if (!n.get(_n).getUnit(e.unitId, Fe.UNIVER_SHEET))
  5685. return false;
  5686. const r = n.get(V).onCommandExecute({
  5687. id: Dr.id,
  5688. params: e
  5689. }), i = {
  5690. name: e.name,
  5691. unitId: e.unitId
  5692. }, a = [
  5693. ...(l = r.preRedos) != null ? l : [],
  5694. { id: Or.id, params: i },
  5695. ...r.redos
  5696. ], u = n.get(Pt);
  5697. return mu(a, u).result;
  5698. }
  5699. };
  5700. var an = {
  5701. id: "sheet.operation.set-worksheet-active",
  5702. type: ar.OPERATION,
  5703. handler: (n, e) => {
  5704. const t = n.get(_n).getUniverSheetInstance(e.unitId);
  5705. if (!t)
  5706. return false;
  5707. const o = t.getWorksheets();
  5708. for (const [, s] of o)
  5709. if (s.getSheetId() === e.subUnitId)
  5710. return t.setActiveSheet(s), true;
  5711. return false;
  5712. }
  5713. };
  5714. var ul = 4;
  5715. var Ar = {
  5716. type: ar.COMMAND,
  5717. id: "sheet.command.set-worksheet-activate",
  5718. handler: (n, e, t) => {
  5719. const o = n.get(Pt), s = N(n.get(_n), e);
  5720. if (!s)
  5721. return false;
  5722. const { unitId: r, subUnitId: i } = s;
  5723. return new Promise((a) => {
  5724. setTimeout(() => {
  5725. const u = o.syncExecuteCommand(an.id, {
  5726. unitId: r,
  5727. subUnitId: i
  5728. }, t);
  5729. a(u);
  5730. }, ul);
  5731. });
  5732. }
  5733. };
  5734. var xr = (n, e) => {
  5735. const { unitId: t, subUnitId: o, ranges: s } = n, r = {}, i = e.getColumnManager();
  5736. for (let a = 0; a < s.length; a++) {
  5737. const u = s[a];
  5738. for (let l = u.startColumn; l < u.endColumn + 1; l++) {
  5739. const c = i.getColumnOrCreate(l);
  5740. r[l] = c.w;
  5741. }
  5742. }
  5743. return {
  5744. unitId: t,
  5745. subUnitId: o,
  5746. ranges: s,
  5747. colWidth: r
  5748. };
  5749. };
  5750. var tt = {
  5751. id: "sheet.mutation.set-worksheet-col-width",
  5752. type: ar.MUTATION,
  5753. handler: (n, e) => {
  5754. var u;
  5755. const t = n.get(_n), o = N(t, e);
  5756. if (!o)
  5757. return false;
  5758. const { worksheet: s } = o, r = s.getConfig().defaultColumnWidth, i = s.getColumnManager(), a = e.ranges;
  5759. for (let l = 0; l < a.length; l++) {
  5760. const c = a[l];
  5761. for (let d = c.startColumn; d < c.endColumn + 1; d++) {
  5762. if (!s.getColVisible(d))
  5763. continue;
  5764. const m = i.getColumnOrCreate(d);
  5765. typeof e.colWidth == "number" ? m.w = e.colWidth : m.w = (u = e.colWidth[d]) != null ? u : r;
  5766. }
  5767. }
  5768. return true;
  5769. }
  5770. };
  5771. var Oo = {
  5772. type: ar.COMMAND,
  5773. id: "sheet.command.delta-column-width",
  5774. // eslint-disable-next-line max-lines-per-function
  5775. handler: async (n, e) => {
  5776. const o = n.get(F).getCurrentSelections();
  5777. if (!(o != null && o.length))
  5778. return false;
  5779. const s = n.get(Pt), r = n.get(cn), i = N(n.get(_n));
  5780. if (!i)
  5781. return false;
  5782. const { worksheet: a, unitId: u, subUnitId: l } = i, { anchorCol: c, deltaX: d } = e, m = a.getColumnWidth(c) + d, g2 = o.length === 1 && o[0].range.rangeType === De.ALL, f = o.filter((x) => x.range.rangeType === De.COLUMN), p = g2 ? De.ALL : f.some(({ range: x }) => {
  5783. const { startColumn: T2, endColumn: U } = x;
  5784. return T2 <= c && c <= U;
  5785. }) ? De.COLUMN : De.NORMAL;
  5786. let C;
  5787. if (p === De.ALL) {
  5788. const x = a.getRowCount(), T2 = new Array(a.getColumnCount()).fill(void 0).map(
  5789. (U, P) => ({ startRow: 0, endRow: x - 1, startColumn: P, endColumn: P })
  5790. );
  5791. C = {
  5792. subUnitId: l,
  5793. unitId: u,
  5794. colWidth: m,
  5795. ranges: T2
  5796. };
  5797. } else
  5798. p === De.COLUMN ? C = {
  5799. subUnitId: l,
  5800. unitId: u,
  5801. ranges: f.map((x) => en.clone(x.range)),
  5802. colWidth: m
  5803. } : C = {
  5804. subUnitId: l,
  5805. unitId: u,
  5806. colWidth: m,
  5807. ranges: [
  5808. {
  5809. startRow: 0,
  5810. endRow: a.getMaxRows() - 1,
  5811. startColumn: c,
  5812. endColumn: c
  5813. }
  5814. ]
  5815. };
  5816. const { undos: S, redos: I } = n.get(V).onCommandExecute({
  5817. id: Oo.id,
  5818. params: C
  5819. }), w = xr(
  5820. C,
  5821. a
  5822. ), b = s.syncExecuteCommand(
  5823. tt.id,
  5824. C
  5825. ), y = mu([...I], s);
  5826. return b && y.result && r.pushUndoRedo({
  5827. unitID: u,
  5828. undoMutations: [{ id: tt.id, params: w }, ...S],
  5829. redoMutations: [{ id: tt.id, params: C }, ...I]
  5830. }), true;
  5831. }
  5832. };
  5833. var Mn = {
  5834. type: ar.COMMAND,
  5835. id: "sheet.command.set-worksheet-col-width",
  5836. handler: (n, e) => {
  5837. var S, I, w, b;
  5838. const t = n.get(F), o = n.get(Pt), s = n.get(cn), r = n.get(V), i = (S = e == null ? void 0 : e.ranges) != null && S.length ? e.ranges : (I = t.getCurrentSelections()) == null ? void 0 : I.map((y) => y.range);
  5839. if (!(i != null && i.length))
  5840. return false;
  5841. const a = N(n.get(_n), e);
  5842. if (!a)
  5843. return false;
  5844. const { subUnitId: u, unitId: l, worksheet: c } = a, d = {
  5845. subUnitId: u,
  5846. unitId: l,
  5847. ranges: i,
  5848. colWidth: e.value
  5849. }, h = xr(d, c), m = o.syncExecuteCommand(tt.id, d), { undos: g2, redos: f } = n.get(V).onCommandExecute({
  5850. id: Mn.id,
  5851. params: d
  5852. }), p = r.onCommandExecute({
  5853. id: Mn.id,
  5854. params: d
  5855. }), C = mu([...f, ...p.redos], o);
  5856. return m && C.result ? (s.pushUndoRedo({
  5857. unitID: l,
  5858. undoMutations: [...(w = p.preUndos) != null ? w : [], { id: tt.id, params: h }, ...g2],
  5859. redoMutations: [...(b = p.preRedos) != null ? b : [], { id: tt.id, params: d }, ...f]
  5860. }), true) : false;
  5861. }
  5862. };
  5863. var ll = {
  5864. type: ar.COMMAND,
  5865. id: "sheet.command.set-col-is-auto-width",
  5866. handler: async (n, e) => {
  5867. const t = n.get(Pt), o = n.get(cn), s = n.get(F), r = n.get(_n), i = N(r, e);
  5868. if (!i)
  5869. return false;
  5870. const { unitId: a, subUnitId: u } = i;
  5871. let l = [];
  5872. if (e != null && e.ranges)
  5873. l = [...e.ranges];
  5874. else {
  5875. const g2 = s.getCurrentSelections();
  5876. for (let f = 0; f < g2.length; f++)
  5877. l.push(g2[f].range);
  5878. }
  5879. if (!(l != null && l.length))
  5880. return false;
  5881. const c = {
  5882. unitId: a,
  5883. subUnitId: u,
  5884. ranges: l
  5885. }, { undos: d, redos: h } = n.get(V).onCommandExecute({
  5886. id: ll.id,
  5887. params: c
  5888. });
  5889. return mu([...h], t).result ? (o.pushUndoRedo({
  5890. unitID: a,
  5891. undoMutations: [...d],
  5892. redoMutations: [...h]
  5893. }), true) : false;
  5894. }
  5895. };
  5896. var Bt = {
  5897. id: "sheet.mutation.set-worksheet-default-style",
  5898. type: ar.MUTATION,
  5899. handler: (n, e) => {
  5900. const { defaultStyle: t } = e, o = n.get(_n), s = N(o);
  5901. if (!s)
  5902. return false;
  5903. const { worksheet: r } = s;
  5904. return r ? (r.setDefaultCellStyle(t), true) : false;
  5905. }
  5906. };
  5907. var cl = (n, e) => {
  5908. const t = Et(n.get(_n), e);
  5909. if (!t)
  5910. throw new Error("[SetWorksheetDefaultStyleMutationFactory]: worksheet is null error!");
  5911. const { worksheet: o } = t;
  5912. return {
  5913. unitId: e.unitId,
  5914. subUnitId: o.getSheetId(),
  5915. defaultStyle: o.getDefaultCellStyle()
  5916. };
  5917. };
  5918. var dl = {
  5919. type: ar.COMMAND,
  5920. id: "sheet.command.set-worksheet-default-style",
  5921. handler: (n, e) => {
  5922. const t = n.get(Pt), o = n.get(cn), { unitId: s } = e, r = cl(n, e);
  5923. return t.syncExecuteCommand(Bt.id, e) ? (o.pushUndoRedo({
  5924. unitID: s,
  5925. undoMutations: [{ id: Bt.id, params: r }],
  5926. redoMutations: [{ id: Bt.id, params: e }]
  5927. }), true) : false;
  5928. }
  5929. };
  5930. var $r = (n, e) => {
  5931. const t = Et(n.get(_n), e);
  5932. if (!t)
  5933. throw new Error("[SetWorksheetHideMutationFactory]: worksheet is null error!");
  5934. const { worksheet: o } = t;
  5935. return {
  5936. hidden: o.isSheetHidden(),
  5937. unitId: e.unitId,
  5938. subUnitId: o.getSheetId()
  5939. };
  5940. };
  5941. var lt = {
  5942. id: "sheet.mutation.set-worksheet-hidden",
  5943. type: ar.MUTATION,
  5944. handler: (n, e) => {
  5945. const t = n.get(_n).getUniverSheetInstance(e.unitId);
  5946. if (t == null)
  5947. return false;
  5948. const o = t.getSheetBySheetId(e.subUnitId);
  5949. return o ? (o.getConfig().hidden = e.hidden, true) : false;
  5950. }
  5951. };
  5952. var hl = {
  5953. type: ar.COMMAND,
  5954. id: "sheet.command.set-worksheet-hidden",
  5955. handler: (n, e) => {
  5956. const t = n.get(Pt), o = n.get(cn), s = n.get(NE), r = n.get(Vr), i = N(n.get(_n), e);
  5957. if (!i)
  5958. return false;
  5959. const { workbook: a, worksheet: u, unitId: l, subUnitId: c } = i;
  5960. if (u.getConfig().hidden === we.TRUE)
  5961. return false;
  5962. const h = {
  5963. unitId: l,
  5964. subUnitId: c,
  5965. hidden: we.TRUE
  5966. }, m = $r(n, h);
  5967. return a.getSheets().filter((C) => C.getConfig().hidden === we.FALSE).length === 1 ? (s.emit(r.t("sheets.info.hideSheet")), false) : t.syncExecuteCommand(lt.id, h) ? (o.pushUndoRedo({
  5968. unitID: l,
  5969. undoMutations: [{ id: lt.id, params: m }],
  5970. redoMutations: [{ id: lt.id, params: h }]
  5971. }), true) : false;
  5972. }
  5973. };
  5974. var ml = (n, e) => {
  5975. const t = Et(n.get(_n), e);
  5976. if (!t)
  5977. throw new Error("[SetWorksheetNameMutationFactory]: worksheet is null error!");
  5978. const { worksheet: o } = t;
  5979. return {
  5980. unitId: e.unitId,
  5981. name: o.getName(),
  5982. subUnitId: o.getSheetId()
  5983. };
  5984. };
  5985. var _n2 = {
  5986. id: "sheet.mutation.set-worksheet-name",
  5987. type: ar.MUTATION,
  5988. handler: (n, e) => {
  5989. const t = n.get(_n).getUniverSheetInstance(e.unitId);
  5990. if (t == null)
  5991. return false;
  5992. const o = t.getSheetBySheetId(e.subUnitId);
  5993. return o ? (o.getConfig().name = e.name, true) : false;
  5994. }
  5995. };
  5996. var Do = {
  5997. type: ar.COMMAND,
  5998. id: "sheet.command.set-worksheet-name",
  5999. handler: (n, e) => {
  6000. var g2, f;
  6001. const t = n.get(Pt), o = n.get(cn), s = n.get(V), r = N(n.get(_n), e);
  6002. if (!r)
  6003. return false;
  6004. const { unitId: i, subUnitId: a } = r, u = {
  6005. subUnitId: a,
  6006. name: e.name,
  6007. unitId: i
  6008. }, l = ml(
  6009. n,
  6010. u
  6011. ), c = s.onCommandExecute({
  6012. id: Do.id,
  6013. params: e
  6014. }), d = [
  6015. ...(g2 = c.preRedos) != null ? g2 : [],
  6016. { id: _n2.id, params: u },
  6017. ...c.redos
  6018. ], h = [
  6019. ...(f = c.preUndos) != null ? f : [],
  6020. { id: _n2.id, params: l },
  6021. ...c.undos
  6022. ];
  6023. return mu(d, t).result ? (o.pushUndoRedo({
  6024. unitID: i,
  6025. undoMutations: h,
  6026. redoMutations: d
  6027. }), true) : false;
  6028. }
  6029. };
  6030. var gl = (n, e) => ({
  6031. ...re.deepClone(e),
  6032. toOrder: e.fromOrder,
  6033. fromOrder: e.toOrder
  6034. });
  6035. var Rn = {
  6036. id: "sheet.mutation.set-worksheet-order",
  6037. type: ar.MUTATION,
  6038. handler: (n, e) => {
  6039. const t = n.get(_n).getUniverSheetInstance(e.unitId);
  6040. if (!t)
  6041. return false;
  6042. const o = t.getConfig();
  6043. return o.sheetOrder.splice(e.fromOrder, 1), o.sheetOrder.splice(e.toOrder, 0, e.subUnitId), true;
  6044. }
  6045. };
  6046. var Wr = {
  6047. type: ar.COMMAND,
  6048. id: "sheet.command.set-worksheet-order",
  6049. handler: (n, e) => {
  6050. const t = n.get(Pt), o = n.get(cn), s = N(n.get(_n), e);
  6051. if (!s)
  6052. return false;
  6053. const { workbook: r, unitId: i, subUnitId: a } = s, l = {
  6054. fromOrder: r.getConfig().sheetOrder.indexOf(a),
  6055. toOrder: e.order,
  6056. unitId: i,
  6057. subUnitId: a
  6058. }, c = gl(n, l);
  6059. return t.syncExecuteCommand(Rn.id, l) ? (o.pushUndoRedo({
  6060. unitID: i,
  6061. undoMutations: [{ id: Rn.id, params: c }],
  6062. redoMutations: [{ id: Rn.id, params: l }]
  6063. }), true) : false;
  6064. }
  6065. };
  6066. var un = class {
  6067. constructor() {
  6068. R(this, "_model", /* @__PURE__ */ new Map());
  6069. R(this, "_pointChange", new Subject());
  6070. R(this, "pointChange$", this._pointChange.asObservable());
  6071. }
  6072. addRule(e) {
  6073. this._ensureSubUnitMap(e.unitId).set(e.subUnitId, e), this._pointChange.next(e);
  6074. }
  6075. deleteRule(e, t) {
  6076. var s, r, i;
  6077. const o = (s = this._model.get(e)) == null ? void 0 : s.get(t);
  6078. o && ((i = (r = this._model) == null ? void 0 : r.get(e)) == null || i.delete(t), this._pointChange.next(o));
  6079. }
  6080. getRule(e, t) {
  6081. var o, s;
  6082. return (s = (o = this._model) == null ? void 0 : o.get(e)) == null ? void 0 : s.get(t);
  6083. }
  6084. toObject() {
  6085. const e = {};
  6086. return [...this._model.keys()].forEach((o) => {
  6087. const s = this._model.get(o);
  6088. s != null && s.size && (e[o] = [], [...s.keys()].forEach((i) => {
  6089. const a = s.get(i);
  6090. a && e[o].push(a);
  6091. }));
  6092. }), e;
  6093. }
  6094. fromObject(e) {
  6095. const t = /* @__PURE__ */ new Map();
  6096. Object.keys(e).forEach((o) => {
  6097. const s = e[o];
  6098. if (s != null && s.length) {
  6099. const r = /* @__PURE__ */ new Map();
  6100. s.forEach((i) => {
  6101. r.set(i.subUnitId, i);
  6102. }), t.set(o, r);
  6103. }
  6104. }), this._model = t;
  6105. }
  6106. deleteUnitModel(e) {
  6107. this._model.delete(e);
  6108. }
  6109. _ensureSubUnitMap(e) {
  6110. let t = this._model.get(e);
  6111. return t || (t = /* @__PURE__ */ new Map(), this._model.set(e, t)), t;
  6112. }
  6113. getTargetByPermissionId(e, t) {
  6114. const o = this._model.get(e);
  6115. if (!o)
  6116. return null;
  6117. for (const [s, r] of o)
  6118. if (r.permissionId === t)
  6119. return [e, s];
  6120. }
  6121. };
  6122. var Lr = class {
  6123. constructor(e, t, o) {
  6124. R(this, "type", D.SelectRange);
  6125. R(this, "subType", _.Delete);
  6126. R(this, "status", fl.INIT);
  6127. R(this, "value", true);
  6128. R(this, "id");
  6129. R(this, "unitId");
  6130. R(this, "subUnitId");
  6131. R(this, "permissionId");
  6132. this.unitId = e, this.subUnitId = t, this.permissionId = o, this.id = `${D.SelectRange}.${_.Delete}.${o}`;
  6133. }
  6134. };
  6135. var Vr2 = class {
  6136. constructor(e, t, o) {
  6137. R(this, "type", D.SelectRange);
  6138. R(this, "subType", _.ManageCollaborator);
  6139. R(this, "status", fl.INIT);
  6140. R(this, "value", true);
  6141. R(this, "id");
  6142. R(this, "unitId");
  6143. R(this, "subUnitId");
  6144. R(this, "permissionId");
  6145. this.unitId = e, this.subUnitId = t, this.permissionId = o, this.id = `${D.SelectRange}.${_.ManageCollaborator}.${o}`;
  6146. }
  6147. };
  6148. var Ie = () => [Io, Pe, Vr2, Lr];
  6149. var it = [_.Edit, _.View, _.ManageCollaborator, _.Delete];
  6150. var rh = (n = "unitId", e = "subUnitId", t = "permissionId") => Ie().reduce((o, s) => {
  6151. const r = new s(n, e, t);
  6152. return o[r.subType] = r.value, o;
  6153. }, {});
  6154. var en2 = () => [
  6155. Me,
  6156. Gs2,
  6157. Ws,
  6158. Js,
  6159. Ls,
  6160. js,
  6161. Mo,
  6162. Hs,
  6163. Bs,
  6164. bo,
  6165. vo,
  6166. Fs,
  6167. Ks,
  6168. _o,
  6169. eu,
  6170. Ys,
  6171. zs,
  6172. Vs2
  6173. ];
  6174. var fl2 = [
  6175. _.Edit,
  6176. _.Print,
  6177. _.Comment,
  6178. _.View,
  6179. _.Copy,
  6180. _.Export,
  6181. _.ManageCollaborator,
  6182. _.CreateSheet,
  6183. _.DeleteSheet,
  6184. _.RenameSheet,
  6185. _.HideSheet,
  6186. _.Duplicate,
  6187. _.Share,
  6188. _.MoveSheet,
  6189. _.CopySheet,
  6190. _.RecoverHistory,
  6191. _.ViewHistory,
  6192. _.CreatePermissionObject
  6193. ];
  6194. var we2 = () => [
  6195. Te,
  6196. Hn,
  6197. rr2,
  6198. Zs
  6199. ];
  6200. var ke = () => [
  6201. Xs,
  6202. qs,
  6203. Qs,
  6204. er,
  6205. tr2,
  6206. nr,
  6207. sr,
  6208. or,
  6209. ir,
  6210. ar2,
  6211. wn,
  6212. $t,
  6213. Wt,
  6214. ur
  6215. ];
  6216. var eo = [
  6217. _.Copy,
  6218. _.DeleteColumn,
  6219. _.DeleteRow,
  6220. _.EditExtraObject,
  6221. _.Filter,
  6222. _.InsertColumn,
  6223. _.InsertRow,
  6224. _.InsertHyperlink,
  6225. _.PivotTable,
  6226. _.SetCellStyle,
  6227. _.SetCellValue,
  6228. _.SetColumnStyle,
  6229. _.SetRowStyle,
  6230. _.Sort
  6231. ];
  6232. var Rl = Object.defineProperty;
  6233. var pl = Object.getOwnPropertyDescriptor;
  6234. var Cl = (n, e, t, o) => {
  6235. for (var s = o > 1 ? void 0 : o ? pl(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  6236. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  6237. return o && s && Rl(e, t, s), s;
  6238. };
  6239. var Ze2 = (n, e) => (t, o) => e(t, o, n);
  6240. var Sl = "SHEET_WORKSHEET_PROTECTION_PLUGIN";
  6241. var wl = "SHEET_WORKSHEET_PROTECTION_POINT_PLUGIN";
  6242. var bn = class extends J0 {
  6243. constructor(n, e, t, o, s, r, i, a) {
  6244. super(), this._permissionService = n, this._univerInstanceService = e, this._injector = t, this._worksheetProtectionRuleModel = o, this._worksheetProtectionPointRuleModel = s, this._resourceManagerService = r, this._rangeProtectionRuleModel = i, this._logService = a, this._init(), this._initRuleChange(), this._initRuleSnapshot(), this._initPointSnapshot();
  6245. }
  6246. _init() {
  6247. const n = (e) => {
  6248. const t = e.getUnitId(), o = (s) => {
  6249. const r = s.getSheetId();
  6250. [...we2(), ...ke()].forEach((i) => {
  6251. const a = new i(t, r);
  6252. this._permissionService.addPermissionPoint(a);
  6253. }), this._logService.debug("[WorksheetPermissionService]", "Initialization completed", t, r);
  6254. };
  6255. e.getSheets().forEach((s) => {
  6256. o(s);
  6257. }), e.sheetCreated$.subscribe((s) => {
  6258. o(s);
  6259. }), e.sheetDisposed$.subscribe((s) => {
  6260. const r = s.getSheetId();
  6261. this._rangeProtectionRuleModel.getSubunitRuleList(t, r).forEach((a) => {
  6262. [...Ie()].forEach((u) => {
  6263. const l = new u(t, r, a.permissionId);
  6264. this._permissionService.deletePermissionPoint(l.id);
  6265. });
  6266. }), [...we2(), ...ke()].forEach((a) => {
  6267. const u = new a(t, r);
  6268. this._permissionService.deletePermissionPoint(u.id);
  6269. });
  6270. });
  6271. };
  6272. this._univerInstanceService.getAllUnitsForType(Fe.UNIVER_SHEET).forEach((e) => {
  6273. n(e);
  6274. }), this._univerInstanceService.getTypeOfUnitAdded$(Fe.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe(n), this._univerInstanceService.getTypeOfUnitDisposed$(Fe.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((e) => {
  6275. e.getSheets().forEach((t) => {
  6276. const o = e.getUnitId(), s = t.getSheetId();
  6277. we2().forEach((r) => {
  6278. const i = new r(o, s);
  6279. this._permissionService.deletePermissionPoint(i.id);
  6280. });
  6281. });
  6282. });
  6283. }
  6284. _initRuleChange() {
  6285. this.disposeWithMe(
  6286. this._worksheetProtectionRuleModel.ruleChange$.subscribe((n) => {
  6287. switch (n.type) {
  6288. case "add":
  6289. break;
  6290. case "delete": {
  6291. we2().forEach((e) => {
  6292. const t = new e(n.unitId, n.subUnitId);
  6293. this._permissionService.updatePermissionPoint(t.id, true);
  6294. });
  6295. break;
  6296. }
  6297. case "set": {
  6298. we2().forEach((e) => {
  6299. const t = new e(n.unitId, n.subUnitId);
  6300. this._permissionService.updatePermissionPoint(t.id, n.rule);
  6301. });
  6302. break;
  6303. }
  6304. }
  6305. })
  6306. );
  6307. }
  6308. _initRuleSnapshot() {
  6309. const n = () => {
  6310. const t = this._worksheetProtectionRuleModel.toObject();
  6311. return JSON.stringify(t);
  6312. }, e = (t) => {
  6313. if (!t)
  6314. return {};
  6315. try {
  6316. return JSON.parse(t);
  6317. } catch {
  6318. return {};
  6319. }
  6320. };
  6321. this.disposeWithMe(
  6322. this._resourceManagerService.registerPluginResource({
  6323. toJson: n,
  6324. parseJson: e,
  6325. pluginName: Sl,
  6326. businesses: [Sn.UNIVER_SHEET],
  6327. onLoad: (t, o) => {
  6328. this._worksheetProtectionRuleModel.fromObject(o), Object.keys(o).forEach((s) => {
  6329. we2().forEach((r) => {
  6330. const i = new r(t, s);
  6331. i.value = false, this._permissionService.addPermissionPoint(i);
  6332. });
  6333. }), this._worksheetProtectionRuleModel.changeRuleInitState(true);
  6334. },
  6335. onUnLoad: (t) => {
  6336. const o = this._univerInstanceService.getUnit(t);
  6337. o && (o.getSheets().forEach((s) => {
  6338. const r = s.getSheetId();
  6339. [...we2(), ...ke()].forEach((i) => {
  6340. const a = new i(t, r);
  6341. this._permissionService.deletePermissionPoint(a.id);
  6342. });
  6343. }), en2().forEach((s) => {
  6344. const r = new s(t);
  6345. this._permissionService.deletePermissionPoint(r.id);
  6346. })), this._worksheetProtectionRuleModel.deleteUnitModel(t);
  6347. }
  6348. })
  6349. );
  6350. }
  6351. _initPointSnapshot() {
  6352. const n = () => {
  6353. const t = this._worksheetProtectionPointRuleModel.toObject();
  6354. return JSON.stringify(t);
  6355. }, e = (t) => {
  6356. if (!t)
  6357. return {};
  6358. try {
  6359. return JSON.parse(t);
  6360. } catch {
  6361. return {};
  6362. }
  6363. };
  6364. this.disposeWithMe(
  6365. this._resourceManagerService.registerPluginResource({
  6366. toJson: n,
  6367. parseJson: e,
  6368. pluginName: wl,
  6369. businesses: [Sn.UNIVER_SHEET],
  6370. onLoad: (t, o) => {
  6371. this._worksheetProtectionPointRuleModel.fromObject(o), Object.keys(o).forEach((s) => {
  6372. ke().forEach((r) => {
  6373. const i = new r(t, s);
  6374. this._permissionService.addPermissionPoint(i);
  6375. });
  6376. });
  6377. },
  6378. onUnLoad: (t) => {
  6379. this._worksheetProtectionPointRuleModel.deleteUnitModel(t);
  6380. }
  6381. })
  6382. );
  6383. }
  6384. };
  6385. bn = Cl([
  6386. Ze2(0, ot(UE)),
  6387. Ze2(1, ot(_n)),
  6388. Ze2(2, ot(Ot)),
  6389. Ze2(3, ot(Ye)),
  6390. Ze2(4, ot(un)),
  6391. Ze2(5, ot(Bi)),
  6392. Ze2(6, ot(de)),
  6393. Ze2(7, ot(Mt))
  6394. ], bn);
  6395. var Ao = {
  6396. id: "sheet.mutation.set-worksheet-permission-points",
  6397. type: ar.MUTATION,
  6398. handler: (n, e) => {
  6399. const { rule: t } = e;
  6400. return n.get(un).addRule(t), true;
  6401. }
  6402. };
  6403. var Il = {
  6404. type: ar.COMMAND,
  6405. id: "sheet.command.set-worksheet-permission-points",
  6406. async handler(n, e) {
  6407. if (!e)
  6408. return false;
  6409. const t = n.get(Pt), { rule: o } = e;
  6410. return t.executeCommand(Ao.id, {
  6411. rule: o,
  6412. unitId: o.unitId,
  6413. subUnitId: o.subUnitId
  6414. }), true;
  6415. }
  6416. };
  6417. var vl = {
  6418. type: ar.COMMAND,
  6419. id: "sheet.command.set-worksheet-protection",
  6420. async handler(n, e) {
  6421. if (!e)
  6422. return false;
  6423. const t = n.get(Pt), o = n.get(cn), { rule: s, permissionId: r, oldRule: i } = e, { unitId: a, subUnitId: u } = s, l = { ...s, permissionId: r };
  6424. if (await t.executeCommand(Ct2.id, {
  6425. unitId: a,
  6426. subUnitId: u,
  6427. newRule: l
  6428. })) {
  6429. const d = [{ id: Ct2.id, params: { unitId: a, subUnitId: u, newRule: l } }], h = [{ id: Ct2.id, params: { unitId: a, subUnitId: u, rule: i } }];
  6430. o.pushUndoRedo({
  6431. unitID: a,
  6432. redoMutations: d,
  6433. undoMutations: h
  6434. });
  6435. }
  6436. return true;
  6437. }
  6438. };
  6439. var Ml = 2e3;
  6440. var Hr = (n, e) => {
  6441. const { unitId: t, subUnitId: o, ranges: s } = n, r = {}, i = e.getRowManager();
  6442. for (const { startRow: a, endRow: u } of s)
  6443. for (let l = a; l < u + 1; l++) {
  6444. const c = i.getRowOrCreate(l);
  6445. r[l] = c.h;
  6446. }
  6447. return {
  6448. unitId: t,
  6449. subUnitId: o,
  6450. ranges: s,
  6451. rowHeight: r
  6452. };
  6453. };
  6454. var xo = (n, e) => {
  6455. const { unitId: t, subUnitId: o, ranges: s } = n, r = {}, i = e.getRowManager();
  6456. for (const { startRow: a, endRow: u } of s)
  6457. for (let l = a; l <= u; l++) {
  6458. const c = i.getRowOrCreate(l);
  6459. r[l] = c.ia;
  6460. }
  6461. return {
  6462. unitId: t,
  6463. subUnitId: o,
  6464. ranges: s,
  6465. autoHeightInfo: r
  6466. };
  6467. };
  6468. var ih = (n, e) => {
  6469. const { unitId: t, subUnitId: o, rowsAutoHeightInfo: s } = n, r = [], i = e.getRowManager();
  6470. for (const a of s) {
  6471. const { row: u } = a, { ah: l } = i.getRowOrCreate(u);
  6472. r.push({ row: u, autoHeight: l });
  6473. }
  6474. return {
  6475. unitId: t,
  6476. subUnitId: o,
  6477. rowsAutoHeightInfo: r
  6478. };
  6479. };
  6480. var nt2 = {
  6481. id: "sheet.mutation.set-worksheet-row-height",
  6482. type: ar.MUTATION,
  6483. handler: (n, e) => {
  6484. var l;
  6485. const { ranges: t, rowHeight: o } = e, s = n.get(_n), r = N(s, e);
  6486. if (!r)
  6487. return false;
  6488. const { worksheet: i } = r, a = i.getRowManager(), u = i.getConfig().defaultRowHeight;
  6489. for (const { startRow: c, endRow: d } of t)
  6490. for (let h = c; h <= d; h++) {
  6491. const m = a.getRowOrCreate(h);
  6492. typeof o == "number" ? m.h = o : m.h = (l = o[h]) != null ? l : u, m.h = Math.min(Ml, m.h);
  6493. }
  6494. return true;
  6495. }
  6496. };
  6497. var Oe = {
  6498. id: "sheet.mutation.set-worksheet-row-is-auto-height",
  6499. type: ar.MUTATION,
  6500. handler: (n, e) => {
  6501. var a;
  6502. const { ranges: t, autoHeightInfo: o } = e, s = n.get(_n), r = N(s, e);
  6503. if (!r)
  6504. return false;
  6505. const i = r.worksheet.getRowManager();
  6506. for (const { startRow: u, endRow: l } of t)
  6507. for (let c = u; c <= l; c++) {
  6508. const d = i.getRowOrCreate(c);
  6509. typeof o == "number" ? d.ia = o : d.ia = (a = o[c]) != null ? a : void 0;
  6510. }
  6511. return true;
  6512. }
  6513. };
  6514. var Br = {
  6515. id: "sheet.mutation.set-worksheet-row-auto-height",
  6516. type: ar.MUTATION,
  6517. handler: (n, e) => {
  6518. const { rowsAutoHeightInfo: t } = e, o = n.get(_n), s = N(o, e);
  6519. if (!s)
  6520. return false;
  6521. const r = s.worksheet.getRowManager();
  6522. for (const { row: i, autoHeight: a } of t) {
  6523. const u = r.getRowOrCreate(i);
  6524. u.ah = a;
  6525. }
  6526. return true;
  6527. }
  6528. };
  6529. var $o = {
  6530. type: ar.COMMAND,
  6531. id: "sheet.command.delta-row-height",
  6532. // eslint-disable-next-line max-lines-per-function
  6533. handler: async (n, e) => {
  6534. var U, P;
  6535. const o = n.get(F).getCurrentSelections(), s = n.get(V);
  6536. if (!(o != null && o.length))
  6537. return false;
  6538. const r = N(n.get(_n));
  6539. if (!r)
  6540. return false;
  6541. const { worksheet: i, subUnitId: a, unitId: u } = r, { anchorRow: l, deltaY: c } = e, h = i.getRowHeight(l) + c, m = o.length === 1 && o[0].range.rangeType === De.ALL, g2 = o.filter((A) => A.range.rangeType === De.ROW), f = m ? De.ALL : g2.some(({ range: A }) => {
  6542. const { startRow: j, endRow: Z } = A;
  6543. return j <= l && l <= Z;
  6544. }) ? De.ROW : De.NORMAL;
  6545. let p;
  6546. if (f === De.ALL) {
  6547. const A = i.getRowCount(), j = new Array(i.getColumnCount()).fill(void 0).map(
  6548. (Z, Y) => ({ startRow: Y, endRow: Y, startColumn: 0, endColumn: A - 1 })
  6549. );
  6550. p = {
  6551. subUnitId: a,
  6552. unitId: u,
  6553. rowHeight: h,
  6554. ranges: j
  6555. };
  6556. } else
  6557. f === De.ROW ? p = {
  6558. subUnitId: a,
  6559. unitId: u,
  6560. ranges: g2.map((A) => en.clone(A.range)),
  6561. rowHeight: h
  6562. } : p = {
  6563. subUnitId: a,
  6564. unitId: u,
  6565. rowHeight: h,
  6566. ranges: [
  6567. {
  6568. startRow: l,
  6569. endRow: l,
  6570. startColumn: 0,
  6571. endColumn: i.getMaxColumns() - 1
  6572. }
  6573. ]
  6574. };
  6575. const C = Hr(p, i), S = {
  6576. unitId: u,
  6577. subUnitId: a,
  6578. ranges: p.ranges,
  6579. autoHeightInfo: we.FALSE
  6580. }, I = xo(S, i), w = n.get(Pt), b = n.get(cn), y = s.onCommandExecute({
  6581. id: $o.id,
  6582. params: p
  6583. }), x = mu([
  6584. {
  6585. id: nt2.id,
  6586. params: p
  6587. },
  6588. {
  6589. id: Oe.id,
  6590. params: S
  6591. }
  6592. ], w), T2 = mu([...y.redos], w);
  6593. return x.result && T2.result ? (b.pushUndoRedo({
  6594. unitID: u,
  6595. undoMutations: [
  6596. ...(U = y.preUndos) != null ? U : [],
  6597. {
  6598. id: nt2.id,
  6599. params: C
  6600. },
  6601. {
  6602. id: Oe.id,
  6603. params: I
  6604. },
  6605. ...y.undos
  6606. ],
  6607. redoMutations: [
  6608. ...(P = y.preRedos) != null ? P : [],
  6609. {
  6610. id: nt2.id,
  6611. params: p
  6612. },
  6613. {
  6614. id: Oe.id,
  6615. params: S
  6616. },
  6617. ...y.redos
  6618. ]
  6619. }), true) : false;
  6620. }
  6621. };
  6622. var Wo = {
  6623. type: ar.COMMAND,
  6624. id: "sheet.command.set-row-height",
  6625. // eslint-disable-next-line max-lines-per-function
  6626. handler: (n, e) => {
  6627. var I, w, b, y;
  6628. const t = n.get(F), o = n.get(Pt), s = n.get(cn), r = n.get(_n), i = n.get(V), a = (I = e == null ? void 0 : e.ranges) != null && I.length ? e.ranges : (w = t.getCurrentSelections()) == null ? void 0 : w.map((x) => x.range);
  6629. if (!(a != null && a.length))
  6630. return false;
  6631. const u = N(r, e);
  6632. if (!u)
  6633. return false;
  6634. const { unitId: l, subUnitId: c, worksheet: d } = u, h = {
  6635. subUnitId: c,
  6636. unitId: l,
  6637. ranges: a,
  6638. rowHeight: e.value
  6639. }, m = Hr(h, d), g2 = {
  6640. unitId: l,
  6641. subUnitId: c,
  6642. ranges: h.ranges,
  6643. autoHeightInfo: we.FALSE
  6644. }, f = xo(g2, d), p = mu([
  6645. {
  6646. id: nt2.id,
  6647. params: h
  6648. },
  6649. {
  6650. id: Oe.id,
  6651. params: g2
  6652. }
  6653. ], o), C = i.onCommandExecute({
  6654. id: Wo.id,
  6655. params: h
  6656. }), S = mu([...C.redos], o);
  6657. return p.result && S.result ? (s.pushUndoRedo({
  6658. unitID: l,
  6659. undoMutations: [
  6660. ...(b = C.preRedos) != null ? b : [],
  6661. {
  6662. id: nt2.id,
  6663. params: m
  6664. },
  6665. {
  6666. id: Oe.id,
  6667. params: f
  6668. },
  6669. ...C.undos
  6670. ],
  6671. redoMutations: [
  6672. ...(y = C.preRedos) != null ? y : [],
  6673. {
  6674. id: nt2.id,
  6675. params: h
  6676. },
  6677. {
  6678. id: Oe.id,
  6679. params: g2
  6680. },
  6681. ...C.redos
  6682. ]
  6683. }), true) : false;
  6684. }
  6685. };
  6686. var Lo = {
  6687. type: ar.COMMAND,
  6688. id: "sheet.command.set-row-is-auto-height",
  6689. handler: (n, e) => {
  6690. var C, S;
  6691. const t = n.get(Pt), o = n.get(cn), s = n.get(F), r = n.get(_n), i = N(r, e);
  6692. if (!i)
  6693. return false;
  6694. const { unitId: a, subUnitId: u, worksheet: l } = i, c = (C = e == null ? void 0 : e.ranges) != null && C.length ? e.ranges : (S = s.getCurrentSelections()) == null ? void 0 : S.map((I) => I.range);
  6695. if (!(c != null && c.length))
  6696. return false;
  6697. const d = {
  6698. unitId: a,
  6699. subUnitId: u,
  6700. ranges: c,
  6701. autoHeightInfo: we.TRUE
  6702. // Hard code first, maybe it will change by the menu item in the future.
  6703. }, h = xo(d, l), m = t.syncExecuteCommand(
  6704. Oe.id,
  6705. d
  6706. ), { undos: g2, redos: f } = n.get(V).onCommandExecute({
  6707. id: Lo.id,
  6708. params: d
  6709. }), p = mu([...f], t);
  6710. return m && p.result ? (o.pushUndoRedo({
  6711. unitID: a,
  6712. undoMutations: [{ id: Oe.id, params: h }, ...g2],
  6713. redoMutations: [{ id: Oe.id, params: d }, ...f]
  6714. }), true) : false;
  6715. }
  6716. };
  6717. var Fr = {
  6718. type: ar.COMMAND,
  6719. id: "sheet.command.set-worksheet-show",
  6720. handler: (n, e) => {
  6721. const { unitId: t, subUnitId: o } = e, s = n.get(Pt), r = n.get(cn), i = n.get(_n);
  6722. if (!N(n.get(_n)))
  6723. return false;
  6724. const u = i.getCurrentUnitForType(Fe.UNIVER_SHEET);
  6725. if (!u)
  6726. return false;
  6727. const l = u.getSheetBySheetId(o);
  6728. if (!l || l.getConfig().hidden === we.FALSE)
  6729. return false;
  6730. const d = {
  6731. unitId: t,
  6732. subUnitId: o,
  6733. hidden: we.FALSE
  6734. }, h = $r(n, d), m = s.syncExecuteCommand(lt.id, d), g2 = {
  6735. unitId: t,
  6736. subUnitId: o
  6737. }, f = s.syncExecuteCommand(
  6738. an.id,
  6739. g2
  6740. );
  6741. return m && f ? (r.pushUndoRedo({
  6742. unitID: t,
  6743. undoMutations: [
  6744. { id: lt.id, params: h }
  6745. // { id: SetWorksheetActiveOperation.id, params: unActiveMutationParams },
  6746. ],
  6747. redoMutations: [
  6748. // { id: SetWorksheetActiveOperation.id, params: activeSheetMutationParams },
  6749. { id: lt.id, params: d }
  6750. ]
  6751. }), true) : false;
  6752. }
  6753. };
  6754. var _l = class {
  6755. constructor() {
  6756. R(this, "_tabCount", 0);
  6757. R(this, "_commaCount", 0);
  6758. R(this, "_semicolonCount", 0);
  6759. R(this, "_spaceCount", 0);
  6760. }
  6761. add(e) {
  6762. switch (e) {
  6763. case " ":
  6764. this._tabCount++;
  6765. break;
  6766. case ",":
  6767. this._commaCount++;
  6768. break;
  6769. case ";":
  6770. this._semicolonCount++;
  6771. break;
  6772. case " ":
  6773. this._spaceCount++;
  6774. break;
  6775. }
  6776. }
  6777. update(e) {
  6778. e && typeof e == "string" && (e.includes(" ") && this._tabCount++, e.includes(",") && this._commaCount++, e.includes(";") && this._semicolonCount++, e.trim().includes(" ") && this._spaceCount++);
  6779. }
  6780. getDelimiter() {
  6781. const e = Math.max(this._tabCount, this._commaCount, this._semicolonCount, this._spaceCount);
  6782. return e === 0 || e === this._tabCount ? 1 : e === this._commaCount ? 2 : e === this._semicolonCount ? 4 : e === this._spaceCount ? 8 : 1;
  6783. }
  6784. };
  6785. function bl(n, e, t) {
  6786. const o = [];
  6787. t !== void 0 && (n & 16) > 0 && o.push(t), (n & 1) > 0 && o.push(" "), (n & 2) > 0 && o.push(","), (n & 4) > 0 && o.push(";"), (n & 8) > 0 && o.push(" ");
  6788. let s = "";
  6789. for (const i of o)
  6790. s += yl(i);
  6791. let r = "[".concat(s, "]");
  6792. return e && (r += "+"), new RegExp(r);
  6793. }
  6794. function yl(n) {
  6795. return n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
  6796. }
  6797. var El = (n) => {
  6798. var t;
  6799. return ((t = n.body) == null ? void 0 : t.dataStream.replace(/\r\n$/, "")) || "";
  6800. };
  6801. function Ul(n) {
  6802. if (n != null) {
  6803. if (n.p)
  6804. return El(n.p);
  6805. if (n.v && typeof n.v == "string")
  6806. return n.v;
  6807. if (n.t && (n.t === dn.FORCE_STRING || n.t === dn.STRING))
  6808. return String(n.v);
  6809. }
  6810. }
  6811. function Pl(n, e, t, o, s = false) {
  6812. const r = tr.transformRange(e, n), { startColumn: i, startRow: a, endColumn: u, endRow: l } = r;
  6813. if (i !== u)
  6814. throw new Error("The range must be in the same column.");
  6815. if (t && (t & 16) > 0 && (o === void 0 || o.length !== 1))
  6816. throw new Error("The custom delimiter must a character.");
  6817. const c = t === void 0, d = c ? new _l() : null, h = [];
  6818. for (let I = a; I <= l; I++) {
  6819. const w = n.getCell(I, i), b = Ul(w);
  6820. h.push(b), d && d.update(b);
  6821. }
  6822. const m = c ? d.getDelimiter() : t, g2 = bl(m, s, o);
  6823. let f = -1, p = 0, C = 0;
  6824. const S = [];
  6825. for (const I of h) {
  6826. if (I !== void 0) {
  6827. const w = String(I).split(g2);
  6828. f < 0 ? f = w.length : f = Math.max(f, w.length), S.push(w), p = C;
  6829. } else
  6830. S.push(void 0);
  6831. C++;
  6832. }
  6833. return {
  6834. rs: S,
  6835. maxLength: f === -1 ? 0 : f,
  6836. lastRow: p
  6837. };
  6838. }
  6839. var Tl = {
  6840. type: ar.COMMAND,
  6841. id: "sheet.command.split-text-to-columns",
  6842. // eslint-disable-next-line max-lines-per-function
  6843. handler: (n, e) => {
  6844. const { unitId: t, subUnitId: o, range: s, delimiter: r, customDelimiter: i, treatMultipleDelimitersAsOne: a } = e, u = n.get(Pt), l = n.get(_n), c = n.get(cn);
  6845. if (!N(n.get(_n)))
  6846. return false;
  6847. const h = l.getCurrentUnitForType(Fe.UNIVER_SHEET);
  6848. if (!h)
  6849. return false;
  6850. const m = h.getSheetBySheetId(o);
  6851. if (!m)
  6852. return false;
  6853. const { lastRow: g2, rs: f, maxLength: p } = Pl(m, s, r, i, a), C = m.getColumnCount(), { startColumn: S } = tr.transformRange(s, m);
  6854. if (s.startColumn !== s.endColumn)
  6855. return false;
  6856. const I = [], w = [], b = S + p + 1 - C;
  6857. if (b > 0) {
  6858. const A = {
  6859. unitId: t,
  6860. subUnitId: o,
  6861. range: {
  6862. startRow: 0,
  6863. endRow: m.getRowCount() - 1,
  6864. startColumn: C - 1,
  6865. endColumn: C - 1 + b
  6866. }
  6867. };
  6868. I.push({
  6869. id: je.id,
  6870. params: A
  6871. });
  6872. const j = yo(
  6873. n,
  6874. A
  6875. );
  6876. w.push({ id: De2.id, params: j });
  6877. }
  6878. const y = {
  6879. startRow: s.startRow,
  6880. endRow: g2,
  6881. startColumn: S,
  6882. endColumn: S + p
  6883. }, x = new kt();
  6884. for (let A = y.startRow; A <= y.endRow; A++)
  6885. for (let j = y.startColumn; j <= y.endColumn; j++) {
  6886. const Z = f[A - y.startRow];
  6887. j === 0 && (Z == null ? void 0 : Z.length) === 1 ? x.setValue(A, j, m.getCell(A, j)) : x.setValue(A, j, {
  6888. v: (Z == null ? void 0 : Z[j - y.startColumn]) || null,
  6889. p: null,
  6890. f: null,
  6891. si: null,
  6892. custom: null
  6893. });
  6894. }
  6895. const T2 = {
  6896. unitId: t,
  6897. subUnitId: o,
  6898. cellValue: x.clone()
  6899. }, U = Ae(n, T2);
  6900. return I.push({
  6901. id: Q.id,
  6902. params: T2
  6903. }), w.unshift({
  6904. id: Q.id,
  6905. params: U
  6906. }), mu(I, u).result ? (c.pushUndoRedo({
  6907. unitID: t,
  6908. undoMutations: w,
  6909. redoMutations: I
  6910. }), true) : false;
  6911. }
  6912. };
  6913. var kl = {
  6914. id: "sheet.command.toggle-cell-checkbox",
  6915. type: ar.COMMAND,
  6916. handler: (n, e) => {
  6917. if (!e)
  6918. return false;
  6919. const { unitId: t, subUnitId: o, row: s, col: r, paragraphIndex: i } = e, u = n.get(_n).getUnit(t, Fe.UNIVER_SHEET), l = u == null ? void 0 : u.getSheetBySheetId(o), c = n.get(cn), d = n.get(Pt);
  6920. if (!l)
  6921. return false;
  6922. const h = l.getCell(s, r);
  6923. if (!(h != null && h.p))
  6924. return false;
  6925. const m = re.deepClone(h.p), g2 = new jt(m), f = st.paragraph.bullet.toggleChecklist({
  6926. document: g2,
  6927. paragraphIndex: i
  6928. });
  6929. if (!f)
  6930. return false;
  6931. Ke.apply(g2.getBody(), f.serialize());
  6932. const p = {
  6933. unitId: t,
  6934. subUnitId: o,
  6935. cellValue: {
  6936. [s]: {
  6937. [r]: {
  6938. p: m,
  6939. t: dn.STRING
  6940. }
  6941. }
  6942. }
  6943. }, C = {
  6944. id: Q.id,
  6945. params: p
  6946. }, S = Ae(n, p), I = {
  6947. id: Q.id,
  6948. params: S
  6949. }, w = [C], b = [I];
  6950. return c.pushUndoRedo({
  6951. redoMutations: w,
  6952. undoMutations: b,
  6953. unitID: t
  6954. }), d.syncExecuteCommand(C.id, C.params);
  6955. }
  6956. };
  6957. var Ft = {
  6958. id: "sheet.mutation.toggle-gridlines",
  6959. type: ar.MUTATION,
  6960. handler: (n, e) => {
  6961. const t = N(n.get(_n), e);
  6962. if (!t)
  6963. return false;
  6964. const { worksheet: o } = t, s = o.getConfig();
  6965. return s.showGridlines = e.showGridlines, true;
  6966. }
  6967. };
  6968. var Nl = {
  6969. type: ar.COMMAND,
  6970. id: "sheet.command.toggle-gridlines",
  6971. handler: (n, e) => {
  6972. const t = n.get(Pt), o = n.get(cn), s = n.get(_n), r = N(s);
  6973. if (!r)
  6974. return false;
  6975. const { worksheet: i } = r, a = i.getConfig().showGridlines;
  6976. if (a === (e == null ? void 0 : e.showGridlines))
  6977. return false;
  6978. const { unitId: u, subUnitId: l } = r, c = {
  6979. showGridlines: a === we.TRUE ? we.FALSE : we.TRUE,
  6980. unitId: u,
  6981. subUnitId: l
  6982. }, d = {
  6983. showGridlines: a,
  6984. unitId: u,
  6985. subUnitId: l
  6986. };
  6987. return t.syncExecuteCommand(Ft.id, c) ? (o.pushUndoRedo({
  6988. unitID: u,
  6989. undoMutations: [{ id: Ft.id, params: d }],
  6990. redoMutations: [{ id: Ft.id, params: c }]
  6991. }), true) : false;
  6992. }
  6993. };
  6994. var Ol = {
  6995. id: "sheet.command.unregister-worksheet-range-theme-style",
  6996. type: ar.COMMAND,
  6997. handler: (n, e) => {
  6998. var h;
  6999. if (!e)
  7000. return false;
  7001. const { unitId: t, themeName: o } = e, s = n.get(_n), r = n.get(Pt), i = n.get(cn), a = n.get(He);
  7002. if (!N(s))
  7003. return false;
  7004. const l = {
  7005. unitId: t,
  7006. themeName: o
  7007. }, c = {
  7008. unitId: t,
  7009. themeName: o,
  7010. rangeThemeStyleJson: (h = a.getRangeThemeStyle(t, o)) == null ? void 0 : h.toJson()
  7011. };
  7012. return r.syncExecuteCommand(Yt.id, e) && i.pushUndoRedo({
  7013. unitID: t,
  7014. undoMutations: [{ id: Yt.id, params: c }],
  7015. redoMutations: [{ id: Uo.id, params: l }]
  7016. }), true;
  7017. }
  7018. };
  7019. var Dl = {
  7020. id: "sheet.mutation.empty",
  7021. type: ar.MUTATION,
  7022. handler: () => true
  7023. };
  7024. var Al = (n) => {
  7025. const e = new kt();
  7026. return n.forEach((t) => {
  7027. tr.foreach(t, (o, s) => {
  7028. e.setValue(o, s, 1);
  7029. });
  7030. }), e.forValue((t, o) => {
  7031. const s = e.getValue(t - 1, o);
  7032. s && e.setValue(t, o, s + 1);
  7033. }), e;
  7034. };
  7035. var xl = (n) => {
  7036. const e = n;
  7037. return e.forValue((t, o) => {
  7038. const s = n.getValue(t - 1, o);
  7039. s && e.setValue(t, o, s + 1);
  7040. }), e;
  7041. };
  7042. var Qo2 = (n) => {
  7043. const e = {
  7044. area: 0
  7045. }, t = (o, s) => e.area < o ? (e.area = o, e.range = s, true) : false;
  7046. return n.forValue((o, s, r) => {
  7047. let i = 1, a = r;
  7048. t(i * a, {
  7049. startRow: o - a + 1,
  7050. endRow: o,
  7051. startColumn: s,
  7052. endColumn: s
  7053. });
  7054. const u = {
  7055. startRow: o - a + 1,
  7056. endRow: o,
  7057. startColumn: 0,
  7058. endColumn: s
  7059. };
  7060. for (let l = s - 1; l >= 0 && n.getValue(o, l); l--) {
  7061. a = Math.min(n.getValue(o, l) || 0, a), i++;
  7062. const c = a * i;
  7063. u.startColumn = l, u.startRow = o - a + 1, t(c, u);
  7064. }
  7065. }), e;
  7066. };
  7067. var $l = (n, e) => {
  7068. tr.foreach(e, (t, o) => {
  7069. n.realDeleteValue(t, o);
  7070. });
  7071. for (let t = e.startColumn; t <= e.endColumn; t++) {
  7072. const o = e.endRow + 1;
  7073. if (n.getValue(o, t) > 0) {
  7074. n.setValue(o, t, 1);
  7075. let r = o + 1;
  7076. for (; n.getValue(r, t) > 0; )
  7077. n.setValue(r, t, n.getValue(r - 1, t) + 1), r++;
  7078. }
  7079. }
  7080. return n;
  7081. };
  7082. var jr = (n) => {
  7083. const e = [];
  7084. let t = Qo2(n);
  7085. for (; t.area > 0; )
  7086. t.range && (e.push(t.range), $l(n, t.range)), t = Qo2(n);
  7087. return e;
  7088. };
  7089. var Gr = (n) => {
  7090. const e = Al(n);
  7091. return jr(e);
  7092. };
  7093. var ah = class {
  7094. constructor() {
  7095. R(this, "_matrix", new kt());
  7096. }
  7097. add(...e) {
  7098. return e.forEach((t) => {
  7099. tr.foreach(t, (o, s) => {
  7100. this._matrix.setValue(o, s, 1);
  7101. });
  7102. }), this;
  7103. }
  7104. subtract(...e) {
  7105. return e.forEach((t) => {
  7106. tr.foreach(t, (o, s) => {
  7107. this._matrix.realDeleteValue(o, s);
  7108. });
  7109. }), this;
  7110. }
  7111. merge() {
  7112. const e = xl(this._matrix);
  7113. return jr(e);
  7114. }
  7115. };
  7116. var wt = Ct("INumfmtService");
  7117. var uh = (n, e) => {
  7118. const t = n.get(wt), { values: o, unitId: s, subUnitId: r } = e, i = [], a = [];
  7119. Object.keys(o).forEach((l) => {
  7120. o[l].ranges.forEach((d) => {
  7121. tr.foreach(d, (h, m) => {
  7122. const g2 = t.getValue(s, r, h, m);
  7123. g2 ? i.push({
  7124. pattern: g2.pattern,
  7125. row: h,
  7126. col: m
  7127. }) : a.push({ startColumn: m, endColumn: m, startRow: h, endRow: h });
  7128. });
  7129. });
  7130. });
  7131. const u = [];
  7132. if (i.length) {
  7133. const l = lo(s, r, i);
  7134. Object.keys(l.values).forEach((c) => {
  7135. const d = l.values[c];
  7136. d.ranges = Gr(d.ranges);
  7137. }), u.push({
  7138. id: Vo2.id,
  7139. params: lo(s, r, i)
  7140. });
  7141. }
  7142. return a.length && u.push({
  7143. id: zr.id,
  7144. params: {
  7145. unitId: s,
  7146. subUnitId: r,
  7147. ranges: a
  7148. }
  7149. }), u;
  7150. };
  7151. var Vo2 = {
  7152. id: "sheet.mutation.set.numfmt",
  7153. type: ar.MUTATION,
  7154. handler: (n, e) => {
  7155. if (!e)
  7156. return false;
  7157. const { values: t, refMap: o } = e, s = n.get(wt), r = e.unitId, i = e.subUnitId, a = Object.keys(t).reduce(
  7158. (u, l) => {
  7159. const c = o[l], d = t[l].ranges;
  7160. return c && u.push({
  7161. ...c,
  7162. ranges: d
  7163. }), u;
  7164. },
  7165. []
  7166. );
  7167. return s.setValues(r, i, a), true;
  7168. }
  7169. };
  7170. var zr = {
  7171. id: "sheet.mutation.remove.numfmt",
  7172. type: ar.MUTATION,
  7173. handler: (n, e) => {
  7174. if (!e)
  7175. return false;
  7176. const { unitId: t, subUnitId: o, ranges: s } = e;
  7177. return n.get(wt).deleteValues(t, o, s), true;
  7178. }
  7179. };
  7180. var lh = (n, e) => {
  7181. const t = n.get(wt), { ranges: o, unitId: s, subUnitId: r } = e, i = [];
  7182. if (o.forEach((u) => {
  7183. tr.foreach(u, (l, c) => {
  7184. const d = t.getValue(s, r, l, c);
  7185. d && i.push({
  7186. pattern: d.pattern,
  7187. row: l,
  7188. col: c
  7189. });
  7190. });
  7191. }), !i.length)
  7192. return [];
  7193. const a = lo(s, r, i);
  7194. return Object.keys(a.values).forEach((u) => {
  7195. const l = a.values[u];
  7196. l.ranges = Gr(l.ranges);
  7197. }), [{ id: Vo2.id, params: a }];
  7198. };
  7199. var lo = (n, e, t) => {
  7200. const o = ya(t, "pattern"), s = {}, r = {}, i = Ea();
  7201. return Object.keys(o).forEach((a) => {
  7202. const u = o[a], l = i();
  7203. s[l] = {
  7204. pattern: a
  7205. }, u.forEach((c) => {
  7206. r[l] || (r[l] = { ranges: [] }), r[l].ranges.push(AC(c.row, c.col));
  7207. });
  7208. }), { unitId: n, subUnitId: e, refMap: s, values: r };
  7209. };
  7210. var Wl = {
  7211. id: "sheet.operation.scroll-to-cell",
  7212. type: ar.OPERATION,
  7213. handler: () => true
  7214. };
  7215. var Kr = "ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY";
  7216. var Ll = "maxCellsPerSheet";
  7217. var Vl = 3e6;
  7218. var Hl = Object.defineProperty;
  7219. var Bl = Object.getOwnPropertyDescriptor;
  7220. var Fl = (n, e, t, o) => {
  7221. for (var s = o > 1 ? void 0 : o ? Bl(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  7222. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  7223. return o && s && Hl(e, t, s), s;
  7224. };
  7225. var to = (n, e) => (t, o) => e(t, o, n);
  7226. var yn = class extends nt {
  7227. // eslint-disable-next-line max-lines-per-function
  7228. constructor(n, e, t) {
  7229. var s;
  7230. super(), this._commandService = n, this._configService = e, this._dataSyncPrimaryController = t, [
  7231. Q,
  7232. je,
  7233. qe,
  7234. Jt,
  7235. dt,
  7236. ot2,
  7237. st2,
  7238. De2,
  7239. Be,
  7240. Ut,
  7241. oe,
  7242. zr,
  7243. ne,
  7244. Or,
  7245. _n2,
  7246. Vo2,
  7247. In,
  7248. Dl,
  7249. Qt,
  7250. // formula SUBTOTAL
  7251. Zt,
  7252. Xt2,
  7253. qt2
  7254. ].forEach((r) => {
  7255. var i;
  7256. this._commandService.registerCommand(r), (i = this._dataSyncPrimaryController) == null || i.registerSyncingMutations(r);
  7257. }), ((s = this._configService.getConfig(Kr)) != null ? s : false) || [
  7258. po,
  7259. Co,
  7260. So,
  7261. xs,
  7262. Pt2,
  7263. Tt,
  7264. Oo,
  7265. $o,
  7266. gu,
  7267. mu2,
  7268. pr2,
  7269. gt,
  7270. sn,
  7271. Bn,
  7272. hu,
  7273. du,
  7274. fr,
  7275. mt,
  7276. fu,
  7277. jn,
  7278. pt,
  7279. Fn,
  7280. vr,
  7281. zn2,
  7282. Mr,
  7283. Gn,
  7284. ko,
  7285. uo,
  7286. Iu,
  7287. tl,
  7288. Qu,
  7289. el,
  7290. Ou,
  7291. Nu,
  7292. rn,
  7293. Tu,
  7294. ku,
  7295. yr,
  7296. Mn,
  7297. $u,
  7298. Lt,
  7299. Bu,
  7300. ut,
  7301. Fu,
  7302. ol,
  7303. on,
  7304. Wo,
  7305. kr,
  7306. Ku,
  7307. Ht,
  7308. br,
  7309. Tr,
  7310. Kn,
  7311. Jn,
  7312. fe,
  7313. al,
  7314. fn3,
  7315. Zu,
  7316. rl,
  7317. sl,
  7318. nl,
  7319. Dr,
  7320. Ar,
  7321. an,
  7322. hl,
  7323. lt,
  7324. Do,
  7325. Wr,
  7326. Rn,
  7327. Br,
  7328. nt2,
  7329. Lo,
  7330. Oe,
  7331. tt,
  7332. // SetWorksheetColIsAutoWidthCommand,
  7333. re2,
  7334. Wl,
  7335. au,
  7336. Ir,
  7337. Ur,
  7338. Fr,
  7339. Nl,
  7340. Ft,
  7341. ju,
  7342. Vt,
  7343. // permissions range protection
  7344. Il,
  7345. ct,
  7346. Ct2,
  7347. St,
  7348. Ao,
  7349. Xi2,
  7350. Gu,
  7351. su,
  7352. qi,
  7353. ru,
  7354. vl,
  7355. Ne,
  7356. ze,
  7357. he,
  7358. kl,
  7359. Bt,
  7360. dl,
  7361. Tl,
  7362. // range theme
  7363. Kt,
  7364. zt,
  7365. Uo,
  7366. Yt,
  7367. Ol,
  7368. wu2,
  7369. ba,
  7370. iu
  7371. ].forEach((r) => this.disposeWithMe(this._commandService.registerCommand(r))), this._configService.setConfig(Ll, Vl);
  7372. }
  7373. };
  7374. yn = Fl([
  7375. to(0, Pt),
  7376. to(1, SE),
  7377. to(2, nf(g))
  7378. ], yn);
  7379. var jl = Object.defineProperty;
  7380. var Gl = Object.getOwnPropertyDescriptor;
  7381. var zl = (n, e, t, o) => {
  7382. for (var s = o > 1 ? void 0 : o ? Gl(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  7383. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  7384. return o && s && jl(e, t, s), s;
  7385. };
  7386. var es = (n, e) => (t, o) => e(t, o, n);
  7387. var En = class extends nt {
  7388. constructor(n, e) {
  7389. super(), this._univerInstanceService = n, this._commandService = e, this._initialize();
  7390. }
  7391. _initialize() {
  7392. this.disposeWithMe(
  7393. this._commandService.onCommandExecuted((n) => {
  7394. if (n.id !== Ji.id)
  7395. return;
  7396. const e = n.params, { unitData: t } = e, o = Object.keys(t), s = [];
  7397. for (let i = 0; i < o.length; i++) {
  7398. const a = o[i], u = t[a];
  7399. if (u == null)
  7400. continue;
  7401. const l = Object.keys(u);
  7402. for (let c = 0; c < l.length; c++) {
  7403. const d = l[c], h = u[d];
  7404. if (h == null)
  7405. continue;
  7406. const m = this._getMergedCellData(a, d, h), g2 = {
  7407. subUnitId: d,
  7408. unitId: a,
  7409. cellValue: m
  7410. };
  7411. s.push({
  7412. id: Q.id,
  7413. params: g2
  7414. });
  7415. }
  7416. }
  7417. return s.every(
  7418. (i) => this._commandService.executeCommand(i.id, i.params, {
  7419. onlyLocal: true
  7420. })
  7421. );
  7422. })
  7423. );
  7424. }
  7425. /**
  7426. * Priority that mainly deals with number format in unitData
  7427. * @param unitId
  7428. * @param sheetId
  7429. * @param cellData
  7430. * @returns
  7431. */
  7432. _getMergedCellData(n, e, t) {
  7433. const o = this._univerInstanceService.getUniverSheetInstance(n), s = o == null ? void 0 : o.getStyles(), r = o == null ? void 0 : o.getSheetBySheetId(e), i = r == null ? void 0 : r.getCellMatrix(), a = new kt(t);
  7434. return a.forValue((u, l, c) => {
  7435. const d = i == null ? void 0 : i.getValue(u, l), h = Gb(d, c, s);
  7436. a.setValue(u, l, h);
  7437. }), a.getMatrix();
  7438. }
  7439. };
  7440. En = zl([
  7441. es(0, ot(_n)),
  7442. es(1, Pt)
  7443. ], En);
  7444. var Kl = "sheets.config";
  7445. var ts = {};
  7446. var Jl = Object.defineProperty;
  7447. var Yl = Object.getOwnPropertyDescriptor;
  7448. var Xl = (n, e, t, o) => {
  7449. for (var s = o > 1 ? void 0 : o ? Yl(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  7450. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  7451. return o && s && Jl(e, t, s), s;
  7452. };
  7453. var ns = (n, e) => (t, o) => e(t, o, n);
  7454. var ql = "SHEET_DEFINED_NAME_PLUGIN";
  7455. var ch = "AllDefaultWorkbook";
  7456. var Un = class extends nt {
  7457. constructor(n, e) {
  7458. super(), this._definedNamesService = n, this._resourceManagerService = e, this._initialize();
  7459. }
  7460. _initialize() {
  7461. this._initSnapshot();
  7462. }
  7463. _initSnapshot() {
  7464. const n = (t) => {
  7465. const o = this._definedNamesService.getDefinedNameMap(t);
  7466. return o ? JSON.stringify(o) : "";
  7467. }, e = (t) => {
  7468. if (!t)
  7469. return {};
  7470. try {
  7471. return JSON.parse(t);
  7472. } catch {
  7473. return {};
  7474. }
  7475. };
  7476. this.disposeWithMe(
  7477. this._resourceManagerService.registerPluginResource({
  7478. pluginName: ql,
  7479. businesses: [Fe.UNIVER_SHEET],
  7480. toJson: (t) => n(t),
  7481. parseJson: (t) => e(t),
  7482. onUnLoad: (t) => {
  7483. this._definedNamesService.removeUnitDefinedName(t);
  7484. },
  7485. onLoad: (t, o) => {
  7486. this._definedNamesService.registerDefinedNames(t, o);
  7487. }
  7488. })
  7489. );
  7490. }
  7491. };
  7492. Un = Xl([
  7493. ns(0, pr),
  7494. ns(1, Bi)
  7495. ], Un);
  7496. var $ = {
  7497. MoveRangeCommandId: $s,
  7498. InsertRowCommandId: gr,
  7499. InsertColCommandId: Rr,
  7500. RemoveColCommandId: To,
  7501. RemoveRowCommandId: Po,
  7502. DeleteRangeMoveLeftCommandId: dr,
  7503. DeleteRangeMoveUpCommandId: hr,
  7504. InsertRangeMoveDownCommandId: cu,
  7505. InsertRangeMoveRightCommandId: Eo,
  7506. MoveColsCommandId: Sr,
  7507. MoveRowsCommandId: Cr,
  7508. ReorderRangeCommandId: _r
  7509. };
  7510. var q = ((n) => (n[n.Set = 0] = "Set", n[n.Delete = 1] = "Delete", n[n.HorizontalMove = 2] = "HorizontalMove", n[n.VerticalMove = 3] = "VerticalMove", n[n.Unknown = 4] = "Unknown", n))(q || {});
  7511. var cn2 = Number.MAX_SAFE_INTEGER;
  7512. var Ve = (n) => {
  7513. const e = { ...n }, t = Number.isNaN(e.startRow) && Number.isNaN(e.endRow) && !Number.isNaN(e.startColumn) && !Number.isNaN(e.endColumn), o = Number.isNaN(e.startColumn) && Number.isNaN(e.endColumn) && !Number.isNaN(e.startRow) && !Number.isNaN(e.endRow);
  7514. return (e.rangeType === De.COLUMN || t) && (e.startRow = 0, e.endRow = cn2), (e.rangeType === De.ROW || o) && (e.startColumn = 0, e.endColumn = cn2), e.rangeType === De.ALL && (e.startColumn = 0, e.endColumn = cn2, e.startRow = 0, e.endRow = cn2), e;
  7515. };
  7516. var _e = (n) => {
  7517. let e = n.rangeType;
  7518. return n.rangeType === De.COLUMN ? e = De.ROW : n.rangeType === De.ROW && (e = De.COLUMN), {
  7519. startRow: n.startColumn,
  7520. endRow: n.endColumn,
  7521. startColumn: n.startRow,
  7522. endColumn: n.endRow,
  7523. rangeType: e
  7524. };
  7525. };
  7526. var Pn = (n, e, t) => {
  7527. const o = { ...t }, s = { ...e }, r = (f, p) => {
  7528. const C = Math.max(f.start, p.start), S = Math.min(f.end, p.end);
  7529. return S < C ? null : { start: C, end: S };
  7530. }, i = (f) => f.end - f.start + 1, a = (f, p) => ({
  7531. start: f.start - p.start,
  7532. end: f.start - p.start + f.end - f.start
  7533. }), u = (f, p) => ({
  7534. start: p.start + f.start,
  7535. end: p.start + f.start + f.end - f.start
  7536. }), l = e.start > n.start;
  7537. if (l) {
  7538. const f = Math.min(n.end, e.start) - n.start + 1;
  7539. s.start -= f, s.end -= f;
  7540. }
  7541. const c = i(n), d = c, h = r(n, o), m = h && i(h) >= i(o);
  7542. if (n.end < o.start)
  7543. o.start -= c, o.end -= c;
  7544. else if (h) {
  7545. const f = i(h);
  7546. if (m) {
  7547. const p = a(o, n), C = u(p, s);
  7548. o.start = C.start, o.end = C.end;
  7549. } else
  7550. h.start > n.start ? l ? (o.end -= f + c, o.start -= c) : o.end -= f : l ? o.end -= f : o.start > n.start && o.end > n.end ? (o.start -= c, o.end -= c + f) : o.end -= f;
  7551. }
  7552. const g2 = r(s, o);
  7553. return m || (s.start <= o.start ? (o.start += d, o.end += d) : g2 && (l ? s.end <= o.start || s.start <= o.start && s.end >= o.start ? (o.start += d, o.end += d) : s.start >= o.start && s.start <= o.end && (o.end += d) : o.start < s.start && o.end > s.start ? o.end += d : (o.start >= s.end || o.start >= s.start && o.start <= s.end) && (o.end += d, o.start += d))), {
  7554. step: o.start - t.start,
  7555. length: i(o) - i(t)
  7556. };
  7557. };
  7558. var Jr = (n, e) => {
  7559. const { fromRange: t, toRange: o } = n.params || {};
  7560. if (!o || !t)
  7561. return [];
  7562. const s = Ve(t), r = Ve(o), i = Ve(e), a = Pn(
  7563. { start: s.startRow, end: s.endRow },
  7564. { start: r.startRow, end: r.endRow },
  7565. { start: i.startRow, end: i.endRow }
  7566. );
  7567. return a === null ? [
  7568. {
  7569. type: q.Delete
  7570. }
  7571. ] : [
  7572. {
  7573. type: q.VerticalMove,
  7574. step: a.step || 0,
  7575. length: a.length || 0
  7576. }
  7577. ];
  7578. };
  7579. var Zl = (n, e) => {
  7580. const { fromRange: t, toRange: o } = n.params || {};
  7581. if (!t || !o)
  7582. return [e];
  7583. const s = t.startRow, r = t.endRow - t.startRow + 1, i = o.startRow, a = new kt();
  7584. return tr.foreach(e, (l, c) => {
  7585. a.setValue(l, c, 1);
  7586. }), a.moveRows(s, r, i), WC(a, (l) => l === 1);
  7587. };
  7588. var Ql = (n, e) => {
  7589. const { range: t, order: o } = n.params || {};
  7590. if (!t || !o)
  7591. return [e];
  7592. const s = new kt();
  7593. tr.foreach(e, (a, u) => {
  7594. s.setValue(a, u, 1);
  7595. });
  7596. const r = new kt();
  7597. return tr.foreach(t, (a, u) => {
  7598. var l;
  7599. if (o.hasOwnProperty(a)) {
  7600. const c = o[a], d = (l = s.getValue(c, u)) != null ? l : 0;
  7601. r.setValue(a, u, d);
  7602. }
  7603. }), r.forValue((a, u, l) => {
  7604. s.setValue(a, u, l);
  7605. }), WC(s, (a) => a === 1);
  7606. };
  7607. var Yr = (n, e) => {
  7608. const { fromRange: t, toRange: o } = n.params || {};
  7609. if (!o || !t)
  7610. return [];
  7611. const s = Ve(t), r = Ve(o), i = Ve(e), a = Pn(
  7612. { start: s.startColumn, end: s.endColumn },
  7613. { start: r.startColumn, end: r.endColumn },
  7614. { start: i.startColumn, end: i.endColumn }
  7615. );
  7616. return a === null ? [
  7617. {
  7618. type: q.Delete
  7619. }
  7620. ] : [
  7621. {
  7622. type: q.HorizontalMove,
  7623. step: a.step || 0,
  7624. length: a.length || 0
  7625. }
  7626. ];
  7627. };
  7628. var ec = (n, e) => {
  7629. const { fromRange: t, toRange: o } = n.params || {};
  7630. if (!t || !o)
  7631. return [e];
  7632. const s = t.startColumn, r = t.endColumn - t.startColumn + 1, i = o.startColumn, a = new kt();
  7633. return tr.foreach(e, (u, l) => {
  7634. a.setValue(u, l, 1);
  7635. }), a.moveColumns(s, r, i), WC(a, (u) => u === 1);
  7636. };
  7637. var tc = (n, e) => {
  7638. var r, i;
  7639. const t = (r = n.params) == null ? void 0 : r.toRange, o = (i = n.params) == null ? void 0 : i.fromRange;
  7640. if (!t || !o)
  7641. return [];
  7642. const s = [];
  7643. if (en.contains(t, e) && s.push({
  7644. type: q.Delete
  7645. }), en.contains(o, e)) {
  7646. s.push({
  7647. type: q.Delete
  7648. });
  7649. const a = en.getRelativeRange(e, o), u = en.getPositionRange(a, t);
  7650. return [
  7651. {
  7652. type: q.Set,
  7653. range: u
  7654. }
  7655. ];
  7656. }
  7657. return s;
  7658. };
  7659. var nc = (n, e) => {
  7660. var d, h;
  7661. const t = (d = n.params) == null ? void 0 : d.toRange, o = (h = n.params) == null ? void 0 : h.fromRange;
  7662. if (!t || !o)
  7663. return [e];
  7664. if (!en.intersects(o, e) && !en.intersects(t, e))
  7665. return [e];
  7666. if (en.contains(o, e)) {
  7667. const m = en.getRelativeRange(e, o);
  7668. return [en.getPositionRange(m, t)];
  7669. }
  7670. const s = new kt();
  7671. tr.foreach(e, (m, g2) => {
  7672. s.setValue(m, g2, 1);
  7673. });
  7674. const r = new kt(), i = en.getIntersects(o, e);
  7675. i && tr.foreach(i, (m, g2) => {
  7676. s.getValue(m, g2) && (s.setValue(m, g2, void 0), r.setValue(m, g2, 1));
  7677. });
  7678. const a = t.startColumn - o.startColumn, u = t.startRow - o.startRow, l = {
  7679. startColumn: t.startColumn - a,
  7680. endColumn: t.endColumn - a,
  7681. startRow: t.startRow - u,
  7682. endRow: t.endRow - u
  7683. };
  7684. return tr.foreach(l, (m, g2) => {
  7685. var C;
  7686. const f = m + u, p = g2 + a;
  7687. s.setValue(f, p, (C = r.getValue(m, g2)) != null ? C : 0);
  7688. }), WC(s, (m) => m === 1);
  7689. };
  7690. var It = (n, e) => {
  7691. const t = Ve(n), o = Ve(e), s = (i) => i.endColumn - i.startColumn + 1, r = (i) => i.endRow - i.startRow + 1;
  7692. if (t.startRow <= o.startRow && t.endRow >= o.endRow) {
  7693. if (
  7694. // 2
  7695. o.startColumn < t.startColumn && o.endColumn >= t.startColumn && o.endColumn <= t.endColumn || // 6
  7696. o.startColumn < t.startColumn && o.endColumn >= t.endColumn
  7697. ) {
  7698. const i = en.getIntersects(o, t);
  7699. if (i)
  7700. return { step: 0, length: -s(i) };
  7701. }
  7702. if (o.startColumn >= t.startColumn && o.endColumn <= t.endColumn && r(t) >= r(o))
  7703. return null;
  7704. if (o.startColumn >= t.startColumn && o.startColumn <= t.endColumn && o.endColumn > t.endColumn) {
  7705. const i = en.getIntersects(o, t);
  7706. if (i) {
  7707. const a = -s(i);
  7708. return { step: -(s(t) - s(i)), length: a };
  7709. }
  7710. }
  7711. if (o.startColumn > t.endColumn)
  7712. return { step: -s(t), length: 0 };
  7713. }
  7714. return { step: 0, length: 0 };
  7715. };
  7716. var Xr = (n, e) => {
  7717. var r;
  7718. const t = (r = n.params) == null ? void 0 : r.range;
  7719. if (!t)
  7720. return [];
  7721. const o = [], s = It(t, e);
  7722. if (!s)
  7723. o.push({ type: q.Delete });
  7724. else {
  7725. const { step: i, length: a } = s;
  7726. o.push({
  7727. type: q.HorizontalMove,
  7728. step: i,
  7729. length: a
  7730. });
  7731. }
  7732. return o;
  7733. };
  7734. var oc = (n, e) => {
  7735. var r;
  7736. const t = (r = n.params) == null ? void 0 : r.range;
  7737. if (!t)
  7738. return [];
  7739. const o = [], s = It(_e(t), _e(e));
  7740. if (!s)
  7741. o.push({ type: q.Delete });
  7742. else {
  7743. const { step: i, length: a } = s;
  7744. o.push({
  7745. type: q.VerticalMove,
  7746. step: i,
  7747. length: a
  7748. });
  7749. }
  7750. return o;
  7751. };
  7752. var sc = (n, e) => {
  7753. const { range: t, order: o } = n.params || {};
  7754. if (!t || !o)
  7755. return [];
  7756. if (en.contains(t, e) && e.endRow === e.startRow) {
  7757. const s = [], r = e.startRow;
  7758. for (const i in o)
  7759. if (o[i] === r) {
  7760. const a = Number(i);
  7761. return s.push({
  7762. type: q.VerticalMove,
  7763. step: a - r,
  7764. length: 0
  7765. }), s;
  7766. }
  7767. return [];
  7768. }
  7769. return [];
  7770. };
  7771. var vt = (n, e) => {
  7772. const t = Ve(n), o = Ve(e), s = (r) => r.endColumn - r.startColumn + 1;
  7773. if (t.startRow <= o.startRow && t.endRow >= o.endRow) {
  7774. if (
  7775. // 2
  7776. o.startColumn < t.startColumn && o.endColumn >= t.startColumn && o.endColumn <= t.endColumn || // 6
  7777. o.startColumn < t.startColumn && o.endColumn >= t.endColumn
  7778. )
  7779. return { step: 0, length: s(t) };
  7780. if (
  7781. // 3
  7782. o.startColumn >= t.startColumn && o.endColumn <= t.endColumn || // 4
  7783. o.startColumn > t.startColumn && o.startColumn <= t.endColumn && o.endColumn > t.endColumn || //5
  7784. o.startColumn >= t.endColumn
  7785. )
  7786. return { step: s(t), length: 0 };
  7787. }
  7788. return { step: 0, length: 0 };
  7789. };
  7790. function rc(n, e, t) {
  7791. const o = [];
  7792. if (en.contains(e, t) && o.push({
  7793. type: q.Delete
  7794. }), en.contains(n, t)) {
  7795. o.push({
  7796. type: q.Delete
  7797. });
  7798. const s = en.getRelativeRange(t, n), r = en.getPositionRange(s, e);
  7799. return [
  7800. {
  7801. type: q.Set,
  7802. range: r
  7803. }
  7804. ];
  7805. }
  7806. return o;
  7807. }
  7808. var ic = (n, e) => {
  7809. var a;
  7810. const t = (a = n.params) == null ? void 0 : a.range;
  7811. if (!t)
  7812. return [];
  7813. const o = [], s = vt(_e(t), _e(e)), { step: r, length: i } = s;
  7814. return o.push({
  7815. type: q.VerticalMove,
  7816. step: r,
  7817. length: i
  7818. }), o;
  7819. };
  7820. var ac = (n, e) => {
  7821. var a;
  7822. const t = (a = n.params) == null ? void 0 : a.range;
  7823. if (!t)
  7824. return [];
  7825. const o = [], s = vt(t, e), { step: r, length: i } = s;
  7826. return o.push({
  7827. type: q.HorizontalMove,
  7828. step: r,
  7829. length: i
  7830. }), o;
  7831. };
  7832. var uc = (n, e) => {
  7833. var a;
  7834. const t = (a = n.params) == null ? void 0 : a.range;
  7835. if (!t)
  7836. return [];
  7837. const o = [], s = vt(_e(t), _e(e)), { step: r, length: i } = s;
  7838. return o.push({
  7839. type: q.VerticalMove,
  7840. step: r,
  7841. length: i
  7842. }), o;
  7843. };
  7844. var lc = (n, e) => {
  7845. var u;
  7846. const t = (u = n.params) == null ? void 0 : u.range;
  7847. if (!t)
  7848. return [e];
  7849. const o = t.endRow - t.startRow + 1, s = {
  7850. ...t,
  7851. startRow: t.startRow,
  7852. endRow: Number.POSITIVE_INFINITY
  7853. }, r = en.subtract(e, s), i = en.getIntersects(s, e);
  7854. if (!i)
  7855. return [e];
  7856. const a = new kt();
  7857. return r.forEach((l) => {
  7858. tr.foreach(l, (c, d) => {
  7859. a.setValue(c, d, 1);
  7860. });
  7861. }), i && tr.foreach(i, (l, c) => {
  7862. a.setValue(l + o, c, 1);
  7863. }), WC(a, (l) => l === 1);
  7864. };
  7865. var cc = (n, e) => {
  7866. var a;
  7867. const t = (a = n.params) == null ? void 0 : a.range;
  7868. if (!t)
  7869. return [];
  7870. const o = [], s = vt(t, e), { step: r, length: i } = s;
  7871. return o.push({
  7872. type: q.HorizontalMove,
  7873. step: r,
  7874. length: i
  7875. }), o;
  7876. };
  7877. var dc = (n, e) => {
  7878. var u;
  7879. const t = (u = n.params) == null ? void 0 : u.range;
  7880. if (!t)
  7881. return [e];
  7882. const o = t.endColumn - t.startColumn + 1, s = {
  7883. ...t,
  7884. startColumn: t.startColumn,
  7885. endColumn: Number.POSITIVE_INFINITY
  7886. }, r = en.subtract(e, s), i = en.getIntersects(s, e);
  7887. if (!i)
  7888. return [e];
  7889. const a = new kt();
  7890. return r.forEach((l) => {
  7891. tr.foreach(l, (c, d) => {
  7892. a.setValue(c, d, 1);
  7893. });
  7894. }), i && tr.foreach(i, (l, c) => {
  7895. a.setValue(l, c + o, 1);
  7896. }), WC(a, (l) => l === 1);
  7897. };
  7898. var hc = (n, e) => {
  7899. var r;
  7900. const t = (r = n.params) == null ? void 0 : r.range;
  7901. if (!t)
  7902. return [];
  7903. const o = [], s = It(t, e);
  7904. if (!s)
  7905. o.push({ type: q.Delete });
  7906. else {
  7907. const { step: i, length: a } = s;
  7908. o.push({
  7909. type: q.HorizontalMove,
  7910. step: i,
  7911. length: a
  7912. });
  7913. }
  7914. return o;
  7915. };
  7916. var mc = (n, e) => {
  7917. var l;
  7918. const t = (l = n.params) == null ? void 0 : l.range;
  7919. if (!t)
  7920. return [e];
  7921. const o = {
  7922. startRow: t.startRow,
  7923. endRow: t.endRow,
  7924. startColumn: t.startColumn,
  7925. endColumn: Number.POSITIVE_INFINITY
  7926. }, s = t.endColumn - t.startColumn + 1, r = en.getIntersects(t, e), i = en.subtract(e, o), a = en.getIntersects(o, e);
  7927. if (!r && !a)
  7928. return [e];
  7929. const u = new kt();
  7930. return a && tr.foreach(a, (c, d) => {
  7931. u.setValue(c, d - s, 1);
  7932. }), r && tr.foreach(r, (c, d) => {
  7933. u.setValue(c, d - s, 0);
  7934. }), i.forEach((c) => {
  7935. tr.foreach(c, (d, h) => {
  7936. u.setValue(d, h, 1);
  7937. });
  7938. }), WC(u, (c) => c === 1);
  7939. };
  7940. var gc = (n, e) => {
  7941. var r;
  7942. const t = (r = n.params) == null ? void 0 : r.range;
  7943. if (!t)
  7944. return [];
  7945. const o = [], s = It(_e(t), _e(e));
  7946. if (!s)
  7947. o.push({ type: q.Delete });
  7948. else {
  7949. const { step: i, length: a } = s;
  7950. o.push({
  7951. type: q.VerticalMove,
  7952. step: i,
  7953. length: a
  7954. });
  7955. }
  7956. return o;
  7957. };
  7958. var fc = (n, e) => {
  7959. var l;
  7960. const t = (l = n.params) == null ? void 0 : l.range;
  7961. if (!t)
  7962. return [e];
  7963. const o = {
  7964. ...t,
  7965. startRow: t.startRow,
  7966. endRow: Number.POSITIVE_INFINITY
  7967. }, s = t.endRow - t.startRow + 1, r = en.getIntersects(t, e), i = en.subtract(e, o), a = en.getIntersects(o, e);
  7968. if (!r && !a)
  7969. return [e];
  7970. const u = new kt();
  7971. return a && tr.foreach(a, (c, d) => {
  7972. u.setValue(c - s, d, 1);
  7973. }), r && tr.foreach(r, (c, d) => {
  7974. u.setValue(c - s, d, 0);
  7975. }), i.forEach((c) => {
  7976. tr.foreach(c, (d, h) => {
  7977. u.setValue(d, h, 1);
  7978. });
  7979. }), WC(u, (c) => c === 1);
  7980. };
  7981. var Rc = (n, e) => {
  7982. var s;
  7983. const t = (s = n.ranges) != null ? s : [n.range], o = new kt();
  7984. return tr.foreach(e, (r, i) => {
  7985. o.setValue(r, i, 1);
  7986. }), t.forEach((r) => {
  7987. const i = r.startRow, u = r.endRow - i + 1;
  7988. o.removeRows(i, u);
  7989. }), WC(o, (r) => r === 1);
  7990. };
  7991. var pc = (n, e) => {
  7992. const t = n.params, o = t.range.startRow, s = t.range.endRow - t.range.startRow + 1, r = t.direction;
  7993. return r === wu.UP && o === e.startRow || r === wu.DOWN && o - 1 === e.endRow ? [
  7994. {
  7995. startRow: e.startRow,
  7996. endRow: e.endRow + s,
  7997. startColumn: e.startColumn,
  7998. endColumn: e.endColumn
  7999. }
  8000. ] : e.startRow >= o ? [{
  8001. startRow: e.startRow + s,
  8002. endRow: e.endRow + s,
  8003. startColumn: e.startColumn,
  8004. endColumn: e.endColumn
  8005. }] : e.endRow <= o ? [e] : [{
  8006. startRow: e.startRow,
  8007. endRow: e.endRow + s,
  8008. startColumn: e.startColumn,
  8009. endColumn: e.endColumn
  8010. }];
  8011. };
  8012. var Cc = (n, e) => {
  8013. const t = n.params, o = t.range.startColumn, s = t.range.endColumn - t.range.startColumn + 1, r = t.direction;
  8014. return r === wu.LEFT && o === e.startColumn || r === wu.RIGHT && o - 1 === e.endColumn ? [
  8015. {
  8016. startRow: e.startRow,
  8017. endRow: e.endRow,
  8018. startColumn: e.startColumn,
  8019. endColumn: e.endColumn + s
  8020. }
  8021. ] : e.startColumn >= o ? [{
  8022. startRow: e.startRow,
  8023. endRow: e.endRow,
  8024. startColumn: e.startColumn + s,
  8025. endColumn: e.endColumn + s
  8026. }] : e.endColumn <= o ? [e] : [{
  8027. startRow: e.startRow,
  8028. endRow: e.endRow,
  8029. startColumn: e.startColumn,
  8030. endColumn: e.endColumn + s
  8031. }];
  8032. };
  8033. var Mt2 = (n, e) => {
  8034. let t = { ...e };
  8035. return n.forEach((o) => {
  8036. switch (o.type) {
  8037. case q.Delete: {
  8038. t = null;
  8039. break;
  8040. }
  8041. case q.HorizontalMove: {
  8042. if (!t)
  8043. return;
  8044. t.startColumn += o.step, t.endColumn += o.step + (o.length || 0);
  8045. break;
  8046. }
  8047. case q.VerticalMove: {
  8048. if (!t)
  8049. return;
  8050. t.startRow += o.step, t.endRow += o.step + (o.length || 0);
  8051. break;
  8052. }
  8053. case q.Set: {
  8054. t = o.range;
  8055. break;
  8056. }
  8057. }
  8058. }), t && (t.endColumn < t.startColumn || t.endRow < t.startRow) ? null : t;
  8059. };
  8060. var os = (n, e) => {
  8061. let t = [];
  8062. switch (e.id) {
  8063. case $.DeleteRangeMoveLeftCommandId: {
  8064. t = hc(e, n);
  8065. break;
  8066. }
  8067. case $.DeleteRangeMoveUpCommandId: {
  8068. t = gc(e, n);
  8069. break;
  8070. }
  8071. case $.InsertColCommandId: {
  8072. t = ac(e, n);
  8073. break;
  8074. }
  8075. case $.InsertRangeMoveDownCommandId: {
  8076. t = uc(e, n);
  8077. break;
  8078. }
  8079. case $.InsertRangeMoveRightCommandId: {
  8080. t = cc(e, n);
  8081. break;
  8082. }
  8083. case $.InsertRowCommandId: {
  8084. t = ic(e, n);
  8085. break;
  8086. }
  8087. case $.MoveColsCommandId: {
  8088. t = Yr(e, n);
  8089. break;
  8090. }
  8091. case $.MoveRangeCommandId: {
  8092. t = tc(e, n);
  8093. break;
  8094. }
  8095. case $.MoveRowsCommandId: {
  8096. t = Jr(e, n);
  8097. break;
  8098. }
  8099. case $.RemoveColCommandId: {
  8100. t = Xr(e, n);
  8101. break;
  8102. }
  8103. case $.RemoveRowCommandId: {
  8104. t = oc(e, n);
  8105. break;
  8106. }
  8107. case $.ReorderRangeCommandId: {
  8108. t = sc(e, n);
  8109. break;
  8110. }
  8111. }
  8112. return Mt2(t, n);
  8113. };
  8114. var dh = (n, e, t) => [Pt2.id, Tt.id].includes(e.id) || qr(e, t).some((r) => en.intersects(r, n)) ? os(n, e) : n;
  8115. var ss = (n, e) => {
  8116. let t = [];
  8117. switch (e.id) {
  8118. case $.DeleteRangeMoveLeftCommandId:
  8119. return mc(e, n);
  8120. case $.DeleteRangeMoveUpCommandId:
  8121. return fc(e, n);
  8122. case $.InsertRangeMoveDownCommandId:
  8123. return lc(e, n);
  8124. case $.InsertRangeMoveRightCommandId:
  8125. return dc(e, n);
  8126. case $.InsertColCommandId:
  8127. return Cc(e, n);
  8128. case $.InsertRowCommandId:
  8129. return pc(e, n);
  8130. case $.MoveColsCommandId:
  8131. return ec(e, n);
  8132. case $.MoveRangeCommandId:
  8133. return nc(e, n);
  8134. case $.MoveRowsCommandId:
  8135. return Zl(e, n);
  8136. case $.ReorderRangeCommandId:
  8137. return Ql(e, n);
  8138. case $.RemoveColCommandId: {
  8139. t = Xr(e, n);
  8140. break;
  8141. }
  8142. case $.RemoveRowCommandId:
  8143. return Rc(e.params, n);
  8144. }
  8145. const o = Mt2(t, n);
  8146. return o ? [o] : [];
  8147. };
  8148. var hh = (n, e, t) => [Pt2.id, Tt.id, sn.id, Eo].includes(e.id) || qr(e, t).some((r) => en.intersects(r, n)) ? ss(n, e) : n;
  8149. function Sc(n, e) {
  8150. const { id: t, params: o } = e;
  8151. let s = {
  8152. length: 0,
  8153. step: 0,
  8154. type: q.Unknown
  8155. };
  8156. switch (t) {
  8157. case Ut.id:
  8158. s.type = q.Delete;
  8159. break;
  8160. case ot2.id:
  8161. s = Pn(
  8162. { start: o.sourceRange.startRow, end: o.sourceRange.endRow },
  8163. { start: o.targetRange.startRow, end: o.targetRange.endRow },
  8164. { start: n.startRow, end: n.endRow }
  8165. ), s.type = q.VerticalMove;
  8166. break;
  8167. case st2.id:
  8168. s = Pn(
  8169. { start: o.sourceRange.startColumn, end: o.sourceRange.endColumn },
  8170. { start: o.targetRange.startColumn, end: o.targetRange.endColumn },
  8171. { start: n.startColumn, end: n.endColumn }
  8172. ), s.type = q.HorizontalMove;
  8173. break;
  8174. case De2.id:
  8175. s = It(o.range, n), s ? s.type = q.HorizontalMove : s = { step: 0, length: 0, type: q.Delete };
  8176. break;
  8177. case Be.id:
  8178. s = It(_e(o.range), _e(n)), s ? s.type = q.VerticalMove : s = { step: 0, length: 0, type: q.Delete };
  8179. break;
  8180. case qe.id:
  8181. s = vt(_e(o.range), _e(n)), s.type = q.VerticalMove;
  8182. break;
  8183. case je.id:
  8184. s = vt(o.range, n), s.type = q.HorizontalMove;
  8185. break;
  8186. case dt.id:
  8187. {
  8188. const r = o.fromRange || new kt(o.from).getRange(), i = o.toRange || new kt(o.to).getRange();
  8189. s = rc(
  8190. r,
  8191. i,
  8192. n
  8193. );
  8194. }
  8195. break;
  8196. }
  8197. return s ? Array.isArray(s) ? Mt2(s, n) : Mt2([s], n) : n;
  8198. }
  8199. function qr(n, e) {
  8200. var o, s, r, i, a, u;
  8201. const { selectionManagerService: t } = e;
  8202. switch (n.id) {
  8203. case $.MoveColsCommandId: {
  8204. const l = n.params;
  8205. return [
  8206. l.fromRange,
  8207. {
  8208. ...l.toRange,
  8209. startColumn: l.toRange.startColumn - 0.5,
  8210. endColumn: l.toRange.endColumn - 0.5
  8211. }
  8212. ];
  8213. }
  8214. case $.MoveRowsCommandId: {
  8215. const l = n.params;
  8216. return [
  8217. l.fromRange,
  8218. {
  8219. ...l.toRange,
  8220. startRow: l.toRange.startRow - 0.5,
  8221. endRow: l.toRange.startRow - 0.5
  8222. }
  8223. ];
  8224. }
  8225. case $.MoveRangeCommandId: {
  8226. const l = n;
  8227. return [l.params.fromRange, l.params.toRange];
  8228. }
  8229. case $.InsertRowCommandId: {
  8230. const c = n.params.range;
  8231. return [
  8232. {
  8233. ...c,
  8234. startRow: c.startRow - 0.5,
  8235. endRow: c.endRow - 0.5
  8236. }
  8237. ];
  8238. }
  8239. case $.InsertColCommandId: {
  8240. const c = n.params.range;
  8241. return [
  8242. {
  8243. ...c,
  8244. startColumn: c.startColumn - 0.5,
  8245. endColumn: c.endColumn - 0.5
  8246. }
  8247. ];
  8248. }
  8249. case $.RemoveRowCommandId:
  8250. return [n.params.range];
  8251. case $.RemoveColCommandId:
  8252. return [n.params.range];
  8253. case $.DeleteRangeMoveUpCommandId:
  8254. case $.InsertRangeMoveDownCommandId: {
  8255. const c = ((o = n.params) == null ? void 0 : o.range) || ((r = (s = t.getCurrentSelections()) == null ? void 0 : s.map((d) => d.range)) == null ? void 0 : r[0]);
  8256. return c ? [c] : [];
  8257. }
  8258. case $.DeleteRangeMoveLeftCommandId:
  8259. case $.InsertRangeMoveRightCommandId: {
  8260. const c = ((i = n.params) == null ? void 0 : i.range) || ((u = (a = t.getCurrentSelections()) == null ? void 0 : a.map((d) => d.range)) == null ? void 0 : u[0]);
  8261. return c ? [c] : [];
  8262. }
  8263. case $.ReorderRangeCommandId: {
  8264. const l = n, { range: c, order: d } = l.params, h = [];
  8265. for (let m = c.startRow; m <= c.endRow; m++)
  8266. m in d && h.push({
  8267. startRow: m,
  8268. endRow: m,
  8269. startColumn: c.startColumn,
  8270. endColumn: c.endColumn
  8271. });
  8272. return h;
  8273. }
  8274. }
  8275. }
  8276. function wc(n) {
  8277. switch (n.id) {
  8278. case st2.id: {
  8279. const e = n.params;
  8280. return [
  8281. e.sourceRange,
  8282. {
  8283. ...e.targetRange,
  8284. startColumn: e.targetRange.startColumn - 0.5,
  8285. endColumn: e.targetRange.startColumn - 0.5
  8286. }
  8287. ];
  8288. }
  8289. case ot2.id: {
  8290. const e = n.params;
  8291. return [
  8292. e.sourceRange,
  8293. {
  8294. ...e.targetRange,
  8295. startRow: e.targetRange.startRow - 0.5,
  8296. endRow: e.targetRange.startRow - 0.5
  8297. }
  8298. ];
  8299. }
  8300. case dt.id: {
  8301. const e = n.params;
  8302. return [new kt(e.from.value).getRange(), new kt(e.to.value).getRange()];
  8303. }
  8304. case je.id: {
  8305. const t = n.params.range;
  8306. return [
  8307. {
  8308. ...t,
  8309. startColumn: t.startColumn - 0.5,
  8310. endColumn: t.startColumn - 0.5
  8311. }
  8312. ];
  8313. }
  8314. case qe.id: {
  8315. const t = n.params.range;
  8316. return [
  8317. {
  8318. ...t,
  8319. startRow: t.startRow - 0.5,
  8320. endRow: t.startRow - 0.5
  8321. }
  8322. ];
  8323. }
  8324. case De2.id:
  8325. return [n.params.range];
  8326. case Be.id:
  8327. return [n.params.range];
  8328. }
  8329. }
  8330. function mh(n, e) {
  8331. var s, r, i, a, u, l;
  8332. const t = n.get(_n), o = n.get(F);
  8333. switch (e.id) {
  8334. case $.MoveColsCommandId: {
  8335. const c = e.params, d = N(t, {
  8336. unitId: c.unitId,
  8337. subUnitId: c.subUnitId
  8338. });
  8339. return {
  8340. unitId: d.unitId,
  8341. subUnitId: d.subUnitId,
  8342. ranges: [
  8343. c.fromRange,
  8344. {
  8345. ...c.toRange,
  8346. startColumn: c.fromRange.startColumn < c.toRange.startColumn ? c.fromRange.endColumn + 1 : c.toRange.startColumn,
  8347. endColumn: c.fromRange.startColumn < c.toRange.startColumn ? c.toRange.endColumn - 1 : c.fromRange.startColumn - 1
  8348. }
  8349. ]
  8350. };
  8351. }
  8352. case $.MoveRowsCommandId: {
  8353. const c = e.params, d = N(t, {
  8354. unitId: c.unitId,
  8355. subUnitId: c.subUnitId
  8356. });
  8357. return {
  8358. unitId: d.unitId,
  8359. subUnitId: d.subUnitId,
  8360. ranges: [
  8361. c.fromRange,
  8362. {
  8363. ...c.toRange,
  8364. startRow: c.fromRange.startRow < c.toRange.startRow ? c.fromRange.endRow + 1 : c.toRange.startRow,
  8365. endRow: c.fromRange.startRow < c.toRange.startRow ? c.toRange.endRow - 1 : c.fromRange.startRow - 1
  8366. }
  8367. ]
  8368. };
  8369. }
  8370. case $.MoveRangeCommandId: {
  8371. const c = e.params, d = N(t);
  8372. return {
  8373. unitId: d.unitId,
  8374. subUnitId: d.subUnitId,
  8375. ranges: [c.fromRange, c.toRange]
  8376. };
  8377. }
  8378. case $.InsertRowCommandId: {
  8379. const c = e.params, d = c.range;
  8380. return {
  8381. unitId: c.unitId,
  8382. subUnitId: c.subUnitId,
  8383. ranges: [
  8384. ...d.startRow > 0 ? [{
  8385. ...d,
  8386. startRow: d.startRow - 1,
  8387. endRow: d.endRow - 1
  8388. }] : [],
  8389. {
  8390. ...d,
  8391. startRow: d.startRow,
  8392. endRow: Number.MAX_SAFE_INTEGER
  8393. }
  8394. ]
  8395. };
  8396. }
  8397. case $.InsertColCommandId: {
  8398. const c = e.params, d = c.range;
  8399. return {
  8400. unitId: c.unitId,
  8401. subUnitId: c.subUnitId,
  8402. ranges: [
  8403. ...d.startColumn > 0 ? [{
  8404. ...d,
  8405. startColumn: d.startColumn - 1,
  8406. endColumn: d.endColumn - 1
  8407. }] : [],
  8408. {
  8409. ...d,
  8410. startColumn: d.startColumn,
  8411. endColumn: Number.MAX_SAFE_INTEGER
  8412. }
  8413. ]
  8414. };
  8415. }
  8416. case $.RemoveRowCommandId: {
  8417. const d = e.params.range, h = N(t);
  8418. return {
  8419. unitId: h.unitId,
  8420. subUnitId: h.subUnitId,
  8421. ranges: [
  8422. d,
  8423. {
  8424. ...d,
  8425. startRow: d.endRow + 1,
  8426. endRow: Number.MAX_SAFE_INTEGER
  8427. }
  8428. ]
  8429. };
  8430. }
  8431. case $.RemoveColCommandId: {
  8432. const d = e.params.range, h = N(t);
  8433. return {
  8434. unitId: h.unitId,
  8435. subUnitId: h.subUnitId,
  8436. ranges: [
  8437. d,
  8438. {
  8439. ...d,
  8440. startColumn: d.endColumn + 1,
  8441. endColumn: Number.MAX_SAFE_INTEGER
  8442. }
  8443. ]
  8444. };
  8445. }
  8446. case $.DeleteRangeMoveUpCommandId:
  8447. case $.InsertRangeMoveDownCommandId: {
  8448. const c = e, d = N(t), h = ((s = c.params) == null ? void 0 : s.range) || ((i = (r = o.getCurrentSelections()) == null ? void 0 : r.map((m) => m.range)) == null ? void 0 : i[0]);
  8449. return h ? {
  8450. unitId: d.unitId,
  8451. subUnitId: d.subUnitId,
  8452. ranges: [
  8453. h,
  8454. {
  8455. ...h,
  8456. startRow: h.endRow + 1,
  8457. endRow: Number.MAX_SAFE_INTEGER
  8458. }
  8459. ]
  8460. } : {
  8461. unitId: d.unitId,
  8462. subUnitId: d.subUnitId,
  8463. ranges: []
  8464. };
  8465. }
  8466. case $.DeleteRangeMoveLeftCommandId:
  8467. case $.InsertRangeMoveRightCommandId: {
  8468. const d = ((a = e.params) == null ? void 0 : a.range) || ((l = (u = o.getCurrentSelections()) == null ? void 0 : u.map((m) => m.range)) == null ? void 0 : l[0]), h = N(t);
  8469. return d ? {
  8470. unitId: h.unitId,
  8471. subUnitId: h.subUnitId,
  8472. ranges: [
  8473. d,
  8474. {
  8475. ...d,
  8476. startColumn: d.endColumn + 1,
  8477. endColumn: Number.MAX_SAFE_INTEGER
  8478. }
  8479. ]
  8480. } : {
  8481. unitId: h.unitId,
  8482. subUnitId: h.subUnitId,
  8483. ranges: []
  8484. };
  8485. }
  8486. case $.ReorderRangeCommandId: {
  8487. const c = e, { range: d, order: h } = c.params, m = [];
  8488. for (let f = d.startRow; f <= d.endRow; f++)
  8489. f in h && m.push({
  8490. startRow: f,
  8491. endRow: f,
  8492. startColumn: d.startColumn,
  8493. endColumn: d.endColumn
  8494. });
  8495. const g2 = N(t);
  8496. return {
  8497. unitId: g2.unitId,
  8498. subUnitId: g2.subUnitId,
  8499. ranges: m
  8500. };
  8501. }
  8502. }
  8503. }
  8504. var Ic = Object.defineProperty;
  8505. var vc = Object.getOwnPropertyDescriptor;
  8506. var Mc = (n, e, t, o) => {
  8507. for (var s = o > 1 ? void 0 : o ? vc(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  8508. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  8509. return o && s && Ic(e, t, s), s;
  8510. };
  8511. var dn2 = (n, e) => (t, o) => e(t, o, n);
  8512. var _c = nR("MERGE_REDO");
  8513. var bc = nR("MERGE_UNDO");
  8514. var rs = Math.floor(Number.MAX_SAFE_INTEGER / 10);
  8515. var yc = class extends nt {
  8516. constructor(e, t, o, s, r = false) {
  8517. super(), this._unitId = e, this._subUnitId = t, this._range = o, this._callback = s, this._skipIntersects = r;
  8518. }
  8519. onMutation(e) {
  8520. var s, r;
  8521. if (((s = e.params) == null ? void 0 : s.unitId) !== this._unitId)
  8522. return;
  8523. if (e.id === dt.id) {
  8524. const i = e.params;
  8525. if (i.from.subUnitId !== this._subUnitId || i.to.subUnitId !== this._subUnitId)
  8526. return;
  8527. } else if (((r = e.params) == null ? void 0 : r.subUnitId) !== this._subUnitId)
  8528. return;
  8529. if (!this._range)
  8530. return;
  8531. if (this._skipIntersects) {
  8532. if (e.id === Ut.id)
  8533. return;
  8534. const i = wc(e);
  8535. if (i != null && i.some((a) => en.intersects(a, this._range)))
  8536. return;
  8537. }
  8538. const t = Sc(this._range, e);
  8539. if (t && en.equals(t, this._range))
  8540. return false;
  8541. const o = this._range;
  8542. this._range = t, this._callback(o, t);
  8543. }
  8544. };
  8545. var _t = class extends nt {
  8546. constructor(e, t, o, s) {
  8547. super();
  8548. R(this, "interceptor", new rR({ MERGE_REDO: _c, MERGE_UNDO: bc }));
  8549. R(this, "_watchRanges", /* @__PURE__ */ new Set());
  8550. R(this, "_refRangeManagerMap", /* @__PURE__ */ new Map());
  8551. R(this, "_serializer", Ec());
  8552. R(this, "_onRefRangeChange", () => {
  8553. this._sheetInterceptorService.interceptCommand({
  8554. // eslint-disable-next-line max-lines-per-function
  8555. getMutations: (e2) => {
  8556. const t2 = this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET).getActiveSheet(), o2 = is(this._univerInstanceService), s2 = as(this._univerInstanceService);
  8557. if (!t2 || !o2 || !s2)
  8558. return { redos: [], undos: [], preRedos: [], preUndos: [] };
  8559. const a = ((() => {
  8560. switch (e2.id) {
  8561. case $.MoveColsCommandId: {
  8562. const h = e2.params, m = Math.min(h.fromRange.startColumn, h.toRange.startColumn);
  8563. return this._checkRange(
  8564. [{ ...h.fromRange, startColumn: m, endColumn: t2.getColumnCount() - 1 }],
  8565. o2,
  8566. s2
  8567. );
  8568. }
  8569. case $.MoveRowsCommandId: {
  8570. const h = e2.params, m = Math.min(h.fromRange.startRow, h.toRange.startRow);
  8571. return this._checkRange(
  8572. [{ ...h.fromRange, startRow: m, endRow: t2.getRowCount() - 1 }],
  8573. o2,
  8574. s2
  8575. );
  8576. }
  8577. case $.MoveRangeCommandId: {
  8578. const h = e2;
  8579. return this._checkRange(
  8580. [h.params.fromRange, h.params.toRange],
  8581. o2,
  8582. s2
  8583. );
  8584. }
  8585. case $.InsertRowCommandId: {
  8586. const g2 = {
  8587. startRow: e2.params.range.startRow,
  8588. endRow: t2.getRowCount() - 1,
  8589. startColumn: 0,
  8590. endColumn: t2.getColumnCount() - 1,
  8591. rangeType: De.ROW
  8592. };
  8593. return this._checkRange([g2], o2, s2);
  8594. }
  8595. case $.InsertColCommandId: {
  8596. const m = e2.params.range.startColumn, g2 = {
  8597. startRow: 0,
  8598. endRow: t2.getRowCount() - 1,
  8599. startColumn: m,
  8600. endColumn: t2.getColumnCount() - 1,
  8601. rangeType: De.COLUMN
  8602. };
  8603. return this._checkRange([g2], o2, s2);
  8604. }
  8605. case $.RemoveRowCommandId: {
  8606. const g2 = {
  8607. startRow: e2.params.range.startRow,
  8608. endRow: t2.getRowCount() - 1,
  8609. startColumn: 0,
  8610. endColumn: t2.getColumnCount() - 1,
  8611. rangeType: De.ROW
  8612. };
  8613. return this._checkRange([g2], o2, s2);
  8614. }
  8615. case $.RemoveColCommandId: {
  8616. const m = e2.params.range.startColumn, g2 = {
  8617. startRow: 0,
  8618. endRow: t2.getRowCount() - 1,
  8619. startColumn: m,
  8620. endColumn: t2.getColumnCount() - 1,
  8621. rangeType: De.COLUMN
  8622. };
  8623. return this._checkRange([g2], o2, s2);
  8624. }
  8625. case $.DeleteRangeMoveUpCommandId:
  8626. case $.InsertRangeMoveDownCommandId: {
  8627. const m = e2.params.range || us(this._selectionManagerService)[0], g2 = {
  8628. startRow: m.startRow,
  8629. startColumn: m.startColumn,
  8630. endColumn: m.endColumn,
  8631. endRow: rs
  8632. };
  8633. return this._checkRange([g2], o2, s2);
  8634. }
  8635. case $.DeleteRangeMoveLeftCommandId:
  8636. case $.InsertRangeMoveRightCommandId: {
  8637. const m = e2.params.range || us(this._selectionManagerService)[0], g2 = {
  8638. startRow: m.startRow,
  8639. startColumn: m.startColumn,
  8640. endColumn: rs,
  8641. endRow: m.endRow
  8642. };
  8643. return this._checkRange([g2], o2, s2);
  8644. }
  8645. case $.ReorderRangeCommandId: {
  8646. const h = e2, { range: m, order: g2 } = h.params, f = [];
  8647. for (let p = m.startRow; p <= m.endRow; p++)
  8648. p in g2 && f.push({
  8649. startRow: p,
  8650. endRow: p,
  8651. startColumn: m.startColumn,
  8652. endColumn: m.endColumn
  8653. });
  8654. return this._checkRange(f, o2, s2);
  8655. }
  8656. }
  8657. })() || []).reduce(
  8658. (h, m) => {
  8659. const g2 = m(e2);
  8660. return h.push(g2), h;
  8661. },
  8662. []
  8663. ).reduce(
  8664. (h, m) => {
  8665. var g2, f;
  8666. return h.redos.push(...m.redos), h.undos.push(...m.undos), h.preRedos.push(...(g2 = m.preRedos) != null ? g2 : []), h.preUndos.push(...(f = m.preUndos) != null ? f : []), h;
  8667. },
  8668. { redos: [], undos: [], preUndos: [], preRedos: [] }
  8669. ), u = this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().MERGE_REDO)(
  8670. a.preRedos,
  8671. null
  8672. ) || [], l = this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().MERGE_REDO)(
  8673. a.redos,
  8674. null
  8675. ) || [], c = this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().MERGE_UNDO)(
  8676. a.preUndos,
  8677. null
  8678. ) || [], d = this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().MERGE_UNDO)(
  8679. a.undos,
  8680. null
  8681. ) || [];
  8682. return { redos: l, undos: d, preRedos: u, preUndos: c };
  8683. }
  8684. });
  8685. });
  8686. R(this, "_checkRange", (e2, t2, o2) => {
  8687. const s2 = ls(t2, o2), r = this._refRangeManagerMap.get(s2);
  8688. if (r) {
  8689. const i = /* @__PURE__ */ new Set();
  8690. return [...r.keys()].forEach((u) => {
  8691. const l = r.get(u), c = this._serializer.deserialize(u), d = {
  8692. ...c,
  8693. startRow: +c.startRow,
  8694. endRow: +c.endRow,
  8695. startColumn: +c.startColumn,
  8696. endColumn: +c.endColumn,
  8697. rangeType: c.rangeType && +c.rangeType
  8698. };
  8699. e2.some((h) => en.intersects(h, d)) && l && l.forEach((h) => {
  8700. i.add(h);
  8701. });
  8702. }), [...i];
  8703. }
  8704. return [];
  8705. });
  8706. R(this, "registerRefRange", (e2, t2, o2, s2) => {
  8707. const r = o2 || is(this._univerInstanceService), i = s2 || as(this._univerInstanceService);
  8708. if (!r || !i)
  8709. return Ze(() => {
  8710. });
  8711. const a = ls(r, i), u = this._serializer.serialize(e2);
  8712. let l = this._refRangeManagerMap.get(a);
  8713. l || (l = /* @__PURE__ */ new Map(), this._refRangeManagerMap.set(a, l));
  8714. const c = l.get(u);
  8715. return c ? c.add(t2) : l.set(u, /* @__PURE__ */ new Set([t2])), Ze(() => {
  8716. const d = l.get(u);
  8717. d && (d.delete(t2), d.size || (l.delete(u), l.size || this._refRangeManagerMap.delete(a)));
  8718. });
  8719. });
  8720. this._commandService = e, this._sheetInterceptorService = t, this._univerInstanceService = o, this._selectionManagerService = s, this._onRefRangeChange(), this.interceptor.intercept(this.interceptor.getInterceptPoints().MERGE_REDO, {
  8721. priority: -1,
  8722. handler: (r) => r
  8723. }), this.interceptor.intercept(this.interceptor.getInterceptPoints().MERGE_UNDO, {
  8724. priority: -1,
  8725. handler: (r) => r
  8726. });
  8727. }
  8728. watchRange(e, t, o, s, r) {
  8729. let i;
  8730. this._watchRanges.size === 0 && (i = this._commandService.onCommandExecuted((c) => {
  8731. if (c.type !== ar.MUTATION)
  8732. return false;
  8733. for (const d of this._watchRanges)
  8734. d.onMutation(c);
  8735. }));
  8736. const a = new yc(e, t, o, s, r);
  8737. this._watchRanges.add(a);
  8738. const u = Ze(() => {
  8739. this._watchRanges.delete(a), this._watchRanges.size === 0 && (i == null || i.dispose(), i = null);
  8740. }), l = this.disposeWithMe(u);
  8741. return Ze(() => {
  8742. l.dispose(), u.dispose();
  8743. });
  8744. }
  8745. };
  8746. _t = Mc([
  8747. dn2(0, Pt),
  8748. dn2(1, ot(V)),
  8749. dn2(2, ot(_n)),
  8750. dn2(3, ot(F))
  8751. ], _t);
  8752. function is(n) {
  8753. return n.getCurrentUnitForType(Fe.UNIVER_SHEET).getUnitId();
  8754. }
  8755. function as(n) {
  8756. var e;
  8757. return (e = n.getCurrentUnitForType(Fe.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : e.getSheetId();
  8758. }
  8759. function us(n) {
  8760. var e;
  8761. return ((e = n.getCurrentSelections()) == null ? void 0 : e.map((t) => t.range)) || [];
  8762. }
  8763. function ls(n, e) {
  8764. return `${n}_${e}`;
  8765. }
  8766. function Ec() {
  8767. const n = ["startRow", "startColumn", "endRow", "endColumn", "rangeType"], e = "_";
  8768. return {
  8769. deserialize: (t) => {
  8770. const o = n.reduce(
  8771. (r, i, a) => (r[String(a)] = i, r),
  8772. {}
  8773. );
  8774. return t.split(e).reduce(
  8775. (r, i, a) => {
  8776. const u = String(a);
  8777. return i && o[u] && (r[o[u]] = i), r;
  8778. },
  8779. {}
  8780. );
  8781. },
  8782. serialize: (t) => n.reduce((o, s, r) => {
  8783. const i = t[s];
  8784. return i !== void 0 ? `${o}${r > 0 ? e : ""}${i}` : `${o}`;
  8785. }, "")
  8786. };
  8787. }
  8788. var Uc = Object.defineProperty;
  8789. var Pc = Object.getOwnPropertyDescriptor;
  8790. var Tc = (n, e, t, o) => {
  8791. for (var s = o > 1 ? void 0 : o ? Pc(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  8792. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  8793. return o && s && Uc(e, t, s), s;
  8794. };
  8795. var Rt = (n, e) => (t, o) => e(t, o, n);
  8796. var kc = [je.id, qe.id, De2.id, Be.id];
  8797. var Nc = [ot2.id, st2.id];
  8798. function Zr(n, e) {
  8799. let t = n;
  8800. if (e !== void 0) {
  8801. const o = [];
  8802. for (let s = 0; s < t.length; s++) {
  8803. const { startRow: r, endRow: i, startColumn: a, endColumn: u } = t[s];
  8804. if (e === yu.ROWS)
  8805. for (let l = r; l <= i; l++) {
  8806. const c = {
  8807. startRow: l,
  8808. endRow: l,
  8809. startColumn: a,
  8810. endColumn: u
  8811. };
  8812. o.push(c);
  8813. }
  8814. else if (e === yu.COLUMNS)
  8815. for (let l = a; l <= u; l++) {
  8816. const c = {
  8817. startRow: r,
  8818. endRow: i,
  8819. startColumn: l,
  8820. endColumn: l
  8821. };
  8822. o.push(c);
  8823. }
  8824. }
  8825. t = o;
  8826. }
  8827. return t;
  8828. }
  8829. var Oc = nR("mergeCellPermissionCheck");
  8830. var Tn = class extends nt {
  8831. constructor(e, t, o, s, r, i) {
  8832. super();
  8833. R(this, "disposableCollection", new Mi());
  8834. R(this, "interceptor", new rR({ MERGE_CELL_INTERCEPTOR_CHECK: Oc }));
  8835. this._commandService = e, this._refRangeService = t, this._univerInstanceService = o, this._injector = s, this._sheetInterceptorService = r, this._selectionManagerService = i, this._onRefRangeChange(), this._initCommandInterceptor(), this._commandExecutedListener();
  8836. }
  8837. _initCommandInterceptor() {
  8838. const e = this;
  8839. this._sheetInterceptorService.interceptCommand({
  8840. getMutations(t) {
  8841. var o;
  8842. switch (t.id) {
  8843. case po.id:
  8844. case So.id: {
  8845. const s = e._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET), r = s.getUnitId(), i = s == null ? void 0 : s.getActiveSheet();
  8846. if (!i)
  8847. return { redos: [], undos: [] };
  8848. const a = i.getSheetId(), u = i.getConfig().mergeData, l = (o = e._selectionManagerService.getCurrentSelections()) == null ? void 0 : o.map((c) => c.range);
  8849. if (l && l.length > 0 && l.some(
  8850. (d) => u.some((h) => en.intersects(h, d))
  8851. )) {
  8852. const d = {
  8853. unitId: r,
  8854. subUnitId: a,
  8855. ranges: l
  8856. }, h = Se(e._injector, d), m = [
  8857. { id: oe.id, params: d }
  8858. ], g2 = [
  8859. { id: ne.id, params: h }
  8860. ];
  8861. return { redos: m, undos: g2 };
  8862. }
  8863. }
  8864. }
  8865. return { redos: [], undos: [] };
  8866. }
  8867. }), this._sheetInterceptorService.interceptRanges({
  8868. getMutations: ({ unitId: t, subUnitId: o, ranges: s }) => {
  8869. const r = [], i = [], a = { redos: r, undos: i };
  8870. if (!s || !s.length)
  8871. return a;
  8872. const u = N(this._univerInstanceService, { unitId: t, subUnitId: o });
  8873. if (!u)
  8874. return a;
  8875. const { worksheet: l } = u, d = l.getMergeData().filter((h) => s.some((m) => en.intersects(h, m)));
  8876. return d.length ? (r.push({
  8877. id: oe.id,
  8878. params: {
  8879. unitId: t,
  8880. subUnitId: o,
  8881. ranges: d
  8882. }
  8883. }), i.push({
  8884. id: ne.id,
  8885. params: {
  8886. unitId: t,
  8887. subUnitId: o,
  8888. ranges: d
  8889. }
  8890. }), { undos: i, redos: r }) : a;
  8891. }
  8892. });
  8893. }
  8894. refRangeHandle(e, t, o) {
  8895. switch (e.id) {
  8896. case $.MoveColsCommandId: {
  8897. const s = e.params;
  8898. return this._handleMoveColsCommand(s, t, o);
  8899. }
  8900. case $.MoveRowsCommandId: {
  8901. const s = e.params;
  8902. return this._handleMoveRowsCommand(s, t, o);
  8903. }
  8904. case mt.id: {
  8905. const s = e.params, r = s.unitId || t, i = s.subUnitId || o;
  8906. return this._handleInsertRowCommand(s, r, i);
  8907. }
  8908. case gt.id: {
  8909. const s = e.params, r = s.unitId || t, i = s.subUnitId || o;
  8910. return this._handleInsertColCommand(s, r, i);
  8911. }
  8912. case zn2.id: {
  8913. const s = e.params;
  8914. return this._handleRemoveColCommand(s, t, o);
  8915. }
  8916. case Gn.id: {
  8917. const s = e.params;
  8918. return this._handleRemoveRowCommand(s, t, o);
  8919. }
  8920. case pt.id: {
  8921. const s = e.params;
  8922. return this._handleMoveRangeCommand(s, t, o);
  8923. }
  8924. case Bn.id: {
  8925. const s = e.params;
  8926. return this._handleInsertRangeMoveRightCommand(s, t, o);
  8927. }
  8928. case sn.id: {
  8929. const s = e.params;
  8930. return this._handleInsertRangeMoveDownCommand(s, t, o);
  8931. }
  8932. case Tt.id: {
  8933. const s = e.params;
  8934. return this._handleDeleteRangeMoveUpCommand(s, t, o);
  8935. }
  8936. case Pt2.id: {
  8937. const s = e.params;
  8938. return this._handleDeleteRangeMoveLeftCommand(s, t, o);
  8939. }
  8940. }
  8941. return { redos: [], undos: [] };
  8942. }
  8943. _onRefRangeChange() {
  8944. const e = (t, o) => {
  8945. const s = this._univerInstanceService.getUniverSheetInstance(t);
  8946. if (!s)
  8947. return;
  8948. const r = s == null ? void 0 : s.getSheetBySheetId(o);
  8949. if (!r)
  8950. return;
  8951. this.disposableCollection.dispose();
  8952. const i = r.getMergeData(), a = (u) => this.refRangeHandle(u, t, o);
  8953. i.forEach((u) => {
  8954. this.disposableCollection.add(this._refRangeService.registerRefRange(u, a, t, o));
  8955. });
  8956. };
  8957. this.disposeWithMe(
  8958. this._commandService.onCommandExecuted((t) => {
  8959. if (t.id === an.id) {
  8960. const o = t.params, s = o.subUnitId, r = o.unitId;
  8961. if (!s || !r)
  8962. return;
  8963. e(r, s);
  8964. }
  8965. if (t.id === ne.id) {
  8966. const o = t.params, s = o.subUnitId, r = o.unitId;
  8967. if (!s || !r)
  8968. return;
  8969. e(o.unitId, o.subUnitId);
  8970. }
  8971. })
  8972. ), this._univerInstanceService.getCurrentTypeOfUnit$(Fe.UNIVER_SHEET).pipe(first((t) => !!t)).subscribe((t) => {
  8973. const o = t.getActiveSheet();
  8974. o && e(t.getUnitId(), o.getSheetId());
  8975. });
  8976. }
  8977. _handleMoveRowsCommand(e, t, o) {
  8978. const s = be(this._univerInstanceService, t);
  8979. if (!s)
  8980. return this._handleNull();
  8981. const r = ye(s, o);
  8982. if (!r)
  8983. return this._handleNull();
  8984. const i = [...r.getMergeData()], a = { unitId: t, subUnitId: o, ranges: [] }, u = { unitId: t, subUnitId: o, ranges: [] }, { fromRange: l } = e, { startRow: c, endRow: d } = l;
  8985. if (i.forEach((g2) => {
  8986. if (c <= g2.startRow && d >= g2.endRow) {
  8987. a.ranges.push(g2);
  8988. const f = Jr({ id: $.MoveRowsCommandId, params: e }, g2), p = Mt2(f, g2);
  8989. p && u.ranges.push(p);
  8990. }
  8991. }), a.ranges.length === 0)
  8992. return this._handleNull();
  8993. const h = Se(this._injector, a), m = Ue(this._injector, u);
  8994. return {
  8995. preRedos: [{ id: oe.id, params: a }],
  8996. redos: [{ id: ne.id, params: u }],
  8997. preUndos: [{ id: oe.id, params: m }],
  8998. undos: [{ id: ne.id, params: h }]
  8999. };
  9000. }
  9001. _handleMoveColsCommand(e, t, o) {
  9002. const s = be(this._univerInstanceService, t);
  9003. if (!s)
  9004. return this._handleNull();
  9005. const r = ye(s, o);
  9006. if (!r)
  9007. return this._handleNull();
  9008. const i = [...r.getMergeData()], a = { unitId: t, subUnitId: o, ranges: [] }, u = { unitId: t, subUnitId: o, ranges: [] }, { fromRange: l } = e, { startColumn: c, endColumn: d } = l;
  9009. if (i.forEach((g2) => {
  9010. if (c <= g2.startColumn && d >= g2.endColumn) {
  9011. a.ranges.push(g2);
  9012. const f = Yr({ id: $.MoveColsCommandId, params: e }, g2), p = Mt2(f, g2);
  9013. p && u.ranges.push(p);
  9014. }
  9015. }), a.ranges.length === 0)
  9016. return this._handleNull();
  9017. const h = Se(this._injector, a), m = Ue(this._injector, u);
  9018. return {
  9019. preRedos: [{ id: oe.id, params: a }],
  9020. redos: [{ id: ne.id, params: u }],
  9021. preUndos: [{ id: oe.id, params: m }],
  9022. undos: [{ id: ne.id, params: h }]
  9023. };
  9024. }
  9025. _handleMoveRangeCommand(e, t, o) {
  9026. const s = be(this._univerInstanceService, t);
  9027. if (!s)
  9028. return this._handleNull();
  9029. const r = ye(s, o);
  9030. if (!r)
  9031. return this._handleNull();
  9032. const i = r.getMergeData(), a = i.filter((m) => en.intersects(m, e.fromRange)), u = i.filter((m) => en.intersects(m, e.toRange)), l = a.map((m) => en.getRelativeRange(m, e.fromRange)).map((m) => en.getPositionRange(m, e.toRange)), c = Zr(l).filter(
  9033. (m) => !i.some((g2) => en.equals(m, g2))
  9034. ), d = [
  9035. {
  9036. id: oe.id,
  9037. params: {
  9038. unitId: t,
  9039. subUnitId: o,
  9040. ranges: a
  9041. }
  9042. },
  9043. {
  9044. id: oe.id,
  9045. params: {
  9046. unitId: t,
  9047. subUnitId: o,
  9048. ranges: u
  9049. }
  9050. },
  9051. {
  9052. id: ne.id,
  9053. params: {
  9054. unitId: t,
  9055. subUnitId: o,
  9056. ranges: c
  9057. }
  9058. }
  9059. ], h = [
  9060. {
  9061. id: oe.id,
  9062. params: {
  9063. unitId: t,
  9064. subUnitId: o,
  9065. ranges: c
  9066. }
  9067. },
  9068. {
  9069. id: ne.id,
  9070. params: {
  9071. unitId: t,
  9072. subUnitId: o,
  9073. ranges: u
  9074. }
  9075. },
  9076. {
  9077. id: ne.id,
  9078. params: {
  9079. unitId: t,
  9080. subUnitId: o,
  9081. ranges: a
  9082. }
  9083. }
  9084. ];
  9085. return { redos: d, undos: h };
  9086. }
  9087. _handleInsertRowCommand(e, t, o) {
  9088. const s = be(this._univerInstanceService, t);
  9089. if (!s)
  9090. return this._handleNull();
  9091. const r = ye(s, o);
  9092. if (!r)
  9093. return this._handleNull();
  9094. const { range: i } = e, { startRow: a, endRow: u } = i, l = re.deepClone(r.getMergeData()).reduce((C, S) => (a > S.startRow && a <= S.endRow && C.push(S), C), []);
  9095. if (l.length === 0)
  9096. return this._handleNull();
  9097. const c = re.deepClone(r.getMergeData()).reduce((C, S) => {
  9098. if (a > S.startRow && a <= S.endRow) {
  9099. const I = u - a + 1;
  9100. S.endRow += I, this._checkIsMergeCell(S) && C.push(S);
  9101. }
  9102. return C;
  9103. }, []), d = {
  9104. unitId: t,
  9105. subUnitId: o,
  9106. ranges: l
  9107. }, h = Se(
  9108. this._injector,
  9109. d
  9110. ), m = {
  9111. unitId: t,
  9112. subUnitId: o,
  9113. ranges: c
  9114. }, g2 = Ue(
  9115. this._injector,
  9116. m
  9117. ), f = [
  9118. { id: oe.id, params: d },
  9119. { id: ne.id, params: m }
  9120. ], p = [
  9121. { id: oe.id, params: g2 },
  9122. { id: ne.id, params: h }
  9123. ];
  9124. return { redos: f, undos: p };
  9125. }
  9126. _handleInsertColCommand(e, t, o) {
  9127. const { range: s } = e, r = be(this._univerInstanceService, t);
  9128. if (!r)
  9129. return this._handleNull();
  9130. const i = ye(r, o);
  9131. if (!i)
  9132. return this._handleNull();
  9133. const { startColumn: a, endColumn: u } = s, l = re.deepClone(i.getMergeData()).reduce((C, S) => (a > S.startColumn && a <= S.endColumn && C.push(S), C), []);
  9134. if (l.length === 0)
  9135. return this._handleNull();
  9136. const c = re.deepClone(i.getMergeData()).reduce((C, S) => {
  9137. if (a > S.startColumn && a <= S.endColumn) {
  9138. const I = u - a + 1;
  9139. S.endColumn += I, this._checkIsMergeCell(S) && C.push(S);
  9140. }
  9141. return C;
  9142. }, []), d = {
  9143. unitId: t,
  9144. subUnitId: o,
  9145. ranges: l
  9146. }, h = Se(
  9147. this._injector,
  9148. d
  9149. ), m = {
  9150. unitId: t,
  9151. subUnitId: o,
  9152. ranges: c
  9153. }, g2 = Ue(
  9154. this._injector,
  9155. m
  9156. ), f = [
  9157. { id: oe.id, params: d },
  9158. { id: ne.id, params: m }
  9159. ], p = [
  9160. { id: oe.id, params: g2 },
  9161. { id: ne.id, params: h }
  9162. ];
  9163. return { redos: f, undos: p };
  9164. }
  9165. _handleRemoveColCommand(e, t, o) {
  9166. const s = be(this._univerInstanceService, t);
  9167. if (!s)
  9168. return this._handleNull();
  9169. const r = ye(s, o);
  9170. if (!r)
  9171. return this._handleNull();
  9172. const { range: i } = e, { startColumn: a, endColumn: u } = i, l = re.deepClone(r.getMergeData()).reduce((I, w) => (en.intersects(i, w) && I.push(w), I), []);
  9173. if (l.length === 0)
  9174. return this._handleNull();
  9175. const c = re.deepClone(r.getMergeData()).reduce((I, w) => {
  9176. if (en.intersects(i, w)) {
  9177. if (a <= w.startColumn && u >= w.endColumn)
  9178. return I;
  9179. a >= w.startColumn && u <= w.endColumn ? w.endColumn -= u - a + 1 : a < w.startColumn ? (w.startColumn = a, w.endColumn -= u - a + 1) : u > w.endColumn && (w.endColumn = a - 1), this._checkIsMergeCell(w) && I.push(w);
  9180. }
  9181. return I;
  9182. }, []), d = {
  9183. unitId: t,
  9184. subUnitId: o,
  9185. ranges: l
  9186. }, h = Se(
  9187. this._injector,
  9188. d
  9189. ), m = {
  9190. unitId: t,
  9191. subUnitId: o,
  9192. ranges: c
  9193. }, g2 = Ue(
  9194. this._injector,
  9195. m
  9196. ), f = [{ id: oe.id, params: d }], p = [{ id: ne.id, params: m }], C = [{ id: oe.id, params: g2 }], S = [{ id: ne.id, params: h }];
  9197. return { preUndos: C, undos: S, preRedos: f, redos: p };
  9198. }
  9199. _handleRemoveRowCommand(e, t, o) {
  9200. const { range: s } = e, r = be(this._univerInstanceService, t);
  9201. if (!r)
  9202. return this._handleNull();
  9203. const i = ye(r, o);
  9204. if (!i)
  9205. return this._handleNull();
  9206. const { startRow: a, endRow: u } = s, l = re.deepClone(i.getMergeData()).reduce((I, w) => (en.intersects(s, w) && I.push(w), I), []);
  9207. if (l.length === 0)
  9208. return this._handleNull();
  9209. const c = re.deepClone(i.getMergeData()).reduce((I, w) => {
  9210. if (en.intersects(s, w)) {
  9211. if (a <= w.startRow && u >= w.endRow)
  9212. return I;
  9213. a >= w.startRow && u <= w.endRow ? w.endRow -= u - a + 1 : a < w.startRow ? (w.startRow = a, w.endRow -= u - a + 1) : u > w.endRow && (w.endRow = a - 1), this._checkIsMergeCell(w) && I.push(w);
  9214. }
  9215. return I;
  9216. }, []), d = {
  9217. unitId: t,
  9218. subUnitId: o,
  9219. ranges: l
  9220. }, h = Se(
  9221. this._injector,
  9222. d
  9223. ), m = {
  9224. unitId: t,
  9225. subUnitId: o,
  9226. ranges: c
  9227. }, g2 = Ue(
  9228. this._injector,
  9229. m
  9230. ), f = [{ id: oe.id, params: d }], p = [{ id: ne.id, params: m }], C = [{ id: oe.id, params: g2 }], S = [{ id: ne.id, params: h }];
  9231. return { preUndos: C, undos: S, preRedos: f, redos: p };
  9232. }
  9233. _handleInsertRangeMoveRightCommand(e, t, o) {
  9234. const s = be(this._univerInstanceService, t);
  9235. if (!s)
  9236. return this._handleNull();
  9237. const r = ye(s, o);
  9238. if (!r)
  9239. return this._handleNull();
  9240. const i = e.range, a = r.getMaxColumns() - 1, u = r.getMergeData(), l = [], c = [];
  9241. u.forEach((f) => {
  9242. const { startRow: p, endRow: C, startColumn: S, endColumn: I } = i;
  9243. if (en.intersects(
  9244. {
  9245. startRow: p,
  9246. startColumn: S,
  9247. endRow: C,
  9248. endColumn: a
  9249. },
  9250. f
  9251. ) && (l.push(f), en.contains(
  9252. {
  9253. startRow: p,
  9254. startColumn: S,
  9255. endRow: C,
  9256. endColumn: a
  9257. },
  9258. f
  9259. ))) {
  9260. const y = I - S + 1;
  9261. c.push({
  9262. startRow: f.startRow,
  9263. startColumn: f.startColumn + y,
  9264. endRow: f.endRow,
  9265. endColumn: f.endColumn + y
  9266. });
  9267. }
  9268. });
  9269. const d = {
  9270. unitId: t,
  9271. subUnitId: o,
  9272. ranges: l
  9273. }, h = Se(
  9274. this._injector,
  9275. d
  9276. ), m = {
  9277. unitId: t,
  9278. subUnitId: o,
  9279. ranges: c
  9280. }, g2 = Ue(
  9281. this._injector,
  9282. m
  9283. );
  9284. return {
  9285. preRedos: [
  9286. { id: oe.id, params: d }
  9287. ],
  9288. redos: [
  9289. {
  9290. id: ne.id,
  9291. params: m
  9292. }
  9293. ],
  9294. preUndos: [
  9295. { id: oe.id, params: g2 }
  9296. ],
  9297. undos: [
  9298. {
  9299. id: ne.id,
  9300. params: h
  9301. }
  9302. ]
  9303. };
  9304. }
  9305. _handleInsertRangeMoveDownCommand(e, t, o) {
  9306. const s = be(this._univerInstanceService, t);
  9307. if (!s)
  9308. return this._handleNull();
  9309. const r = ye(s, o);
  9310. if (!r)
  9311. return this._handleNull();
  9312. const i = e.range, a = r.getMaxRows() - 1, u = r.getMergeData(), l = [], c = [];
  9313. u.forEach((I) => {
  9314. const { startRow: w, startColumn: b, endColumn: y, endRow: x } = i;
  9315. if (en.intersects({ startRow: w, startColumn: b, endRow: a, endColumn: y }, I) && (l.push(I), en.contains({ startRow: w, startColumn: b, endRow: a, endColumn: y }, I))) {
  9316. const P = x - w + 1;
  9317. c.push({
  9318. startRow: I.startRow + P,
  9319. startColumn: I.startColumn,
  9320. endRow: I.endRow + P,
  9321. endColumn: I.endColumn
  9322. });
  9323. }
  9324. });
  9325. const d = {
  9326. unitId: t,
  9327. subUnitId: o,
  9328. ranges: l
  9329. }, h = Se(
  9330. this._injector,
  9331. d
  9332. ), m = {
  9333. unitId: t,
  9334. subUnitId: o,
  9335. ranges: c
  9336. }, g2 = Ue(
  9337. this._injector,
  9338. m
  9339. ), f = [
  9340. {
  9341. id: oe.id,
  9342. params: d
  9343. }
  9344. ], p = [
  9345. {
  9346. id: ne.id,
  9347. params: m
  9348. }
  9349. ], C = [
  9350. {
  9351. id: oe.id,
  9352. params: g2
  9353. }
  9354. ], S = [
  9355. {
  9356. id: ne.id,
  9357. params: h
  9358. }
  9359. ];
  9360. return { redos: p, undos: S, preRedos: f, preUndos: C };
  9361. }
  9362. _handleDeleteRangeMoveUpCommand(e, t, o) {
  9363. const s = be(this._univerInstanceService, t);
  9364. if (!s)
  9365. return this._handleNull();
  9366. const r = ye(s, o);
  9367. if (!r)
  9368. return this._handleNull();
  9369. const i = e.range, a = r.getMaxRows() - 1, u = r.getMergeData(), l = [], c = [];
  9370. u.forEach((I) => {
  9371. const { startRow: w, startColumn: b, endColumn: y, endRow: x } = i;
  9372. if (en.intersects({ startRow: w, startColumn: b, endRow: a, endColumn: y }, I) && (l.push(I), en.contains({ startRow: w, startColumn: b, endRow: a, endColumn: y }, I))) {
  9373. const P = x - w + 1, A = en.moveVertical(I, -P);
  9374. c.push(A);
  9375. }
  9376. });
  9377. const d = {
  9378. unitId: t,
  9379. subUnitId: o,
  9380. ranges: l
  9381. }, h = Se(
  9382. this._injector,
  9383. d
  9384. ), m = {
  9385. unitId: t,
  9386. subUnitId: o,
  9387. ranges: c
  9388. }, g2 = Ue(
  9389. this._injector,
  9390. m
  9391. ), f = [
  9392. {
  9393. id: oe.id,
  9394. params: d
  9395. }
  9396. ], p = [
  9397. {
  9398. id: ne.id,
  9399. params: m
  9400. }
  9401. ], C = [
  9402. {
  9403. id: oe.id,
  9404. params: g2
  9405. }
  9406. ], S = [
  9407. {
  9408. id: ne.id,
  9409. params: h
  9410. }
  9411. ];
  9412. return { redos: p, undos: S, preRedos: f, preUndos: C };
  9413. }
  9414. _handleDeleteRangeMoveLeftCommand(e, t, o) {
  9415. const s = be(this._univerInstanceService, t);
  9416. if (!s)
  9417. return this._handleNull();
  9418. const r = ye(s, o);
  9419. if (!r)
  9420. return this._handleNull();
  9421. const i = e.range, a = r.getMaxColumns() - 1, u = r.getMergeData(), l = [], c = [];
  9422. u.forEach((f) => {
  9423. const { startRow: p, endRow: C, startColumn: S, endColumn: I } = i;
  9424. if (en.intersects(
  9425. {
  9426. startRow: p,
  9427. startColumn: S,
  9428. endRow: C,
  9429. endColumn: a
  9430. },
  9431. f
  9432. ) && (l.push(f), en.contains(
  9433. {
  9434. startRow: p,
  9435. startColumn: S,
  9436. endRow: C,
  9437. endColumn: a
  9438. },
  9439. f
  9440. ))) {
  9441. const y = I - S + 1;
  9442. c.push({
  9443. startRow: f.startRow,
  9444. startColumn: f.startColumn - y,
  9445. endRow: f.endRow,
  9446. endColumn: f.endColumn - y
  9447. });
  9448. }
  9449. });
  9450. const d = {
  9451. unitId: t,
  9452. subUnitId: o,
  9453. ranges: l
  9454. }, h = Se(this._injector, d), m = {
  9455. unitId: t,
  9456. subUnitId: o,
  9457. ranges: c
  9458. }, g2 = Ue(this._injector, m);
  9459. return {
  9460. preRedos: [
  9461. { id: oe.id, params: d }
  9462. ],
  9463. redos: [
  9464. {
  9465. id: ne.id,
  9466. params: m
  9467. }
  9468. ],
  9469. undos: [
  9470. {
  9471. id: ne.id,
  9472. params: h
  9473. }
  9474. ],
  9475. preUndos: [
  9476. { id: oe.id, params: g2 }
  9477. ]
  9478. };
  9479. }
  9480. _checkIsMergeCell(e) {
  9481. return !(e.startRow === e.endRow && e.startColumn === e.endColumn);
  9482. }
  9483. _handleNull() {
  9484. return { redos: [], undos: [] };
  9485. }
  9486. _commandExecutedListener() {
  9487. this.disposeWithMe(this._commandService.onCommandExecuted((e) => {
  9488. if (Nc.includes(e.id)) {
  9489. if (!e.params)
  9490. return;
  9491. const t = this._univerInstanceService.getUniverSheetInstance(e.params.unitId);
  9492. if (!t)
  9493. return;
  9494. const o = t.getSheetBySheetId(e.params.subUnitId);
  9495. if (!o)
  9496. return;
  9497. const { sourceRange: s, targetRange: r } = e.params, i = s.startColumn === r.startColumn && s.endColumn === r.endColumn, a = i ? s.endRow - s.startRow + 1 : s.endColumn - s.startColumn + 1, u = i ? s.startRow : s.startColumn, l = i ? r.startRow : r.startColumn, c = o.getConfig().mergeData, d = [];
  9498. c.forEach((f) => {
  9499. let { startRow: p, endRow: C, startColumn: S, endColumn: I, rangeType: w } = f;
  9500. en.intersects(f, s) || (i ? u < p && l > C ? (p -= a, C -= a) : u > C && l <= p && (p += a, C += a) : u < S && l > I ? (S -= a, I -= a) : u > I && l <= S && (S += a, I += a)), f.startRow === f.endRow && f.startColumn === f.endColumn || d.push({ startRow: p, endRow: C, startColumn: S, endColumn: I, rangeType: w });
  9501. }), o.setMergeData(d), this.disposableCollection.dispose();
  9502. const { unitId: h, subUnitId: m } = e.params, g2 = (f) => this.refRangeHandle(f, h, m);
  9503. d.forEach((f) => {
  9504. this.disposableCollection.add(this._refRangeService.registerRefRange(f, g2, h, m));
  9505. });
  9506. }
  9507. if (kc.includes(e.id)) {
  9508. const t = this._univerInstanceService.getUniverSheetInstance(e.params.unitId);
  9509. if (!t)
  9510. return;
  9511. const o = t.getSheetBySheetId(e.params.subUnitId);
  9512. if (!o)
  9513. return;
  9514. const s = o.getConfig().mergeData, r = e.params;
  9515. if (!r)
  9516. return;
  9517. const { range: i } = r, a = e.id.includes("row"), u = e.id.includes("insert"), l = a ? i.startRow : i.startColumn, c = a ? i.endRow : i.endColumn, d = c - l + 1, h = [];
  9518. s.forEach((p) => {
  9519. let { startRow: C, endRow: S, startColumn: I, endColumn: w, rangeType: b } = p;
  9520. u ? a ? l <= C && (C += d, S += d) : l <= I && (I += d, w += d) : a ? c < C && (C -= d, S -= d) : c < I && (I -= d, w -= d), p.startRow === p.endRow && p.startColumn === p.endColumn || h.push({ startRow: C, endRow: S, startColumn: I, endColumn: w, rangeType: b });
  9521. }), o.setMergeData(h), this.disposableCollection.dispose();
  9522. const { unitId: m, subUnitId: g2 } = e.params, f = (p) => this.refRangeHandle(p, m, g2);
  9523. h.forEach((p) => {
  9524. this.disposableCollection.add(this._refRangeService.registerRefRange(p, f, m, g2));
  9525. });
  9526. }
  9527. }));
  9528. }
  9529. };
  9530. Tn = Tc([
  9531. Rt(0, ot(Pt)),
  9532. Rt(1, ot(_t)),
  9533. Rt(2, ot(_n)),
  9534. Rt(3, ot(Ot)),
  9535. Rt(4, ot(V)),
  9536. Rt(5, ot(F))
  9537. ], Tn);
  9538. function be(n, e) {
  9539. return e ? n.getUniverSheetInstance(e) : n.getCurrentUnitForType(Fe.UNIVER_SHEET);
  9540. }
  9541. function ye(n, e) {
  9542. return e ? n.getSheetBySheetId(e) : n.getActiveSheet();
  9543. }
  9544. var Dc = Object.defineProperty;
  9545. var Ac = Object.getOwnPropertyDescriptor;
  9546. var xc = (n, e, t, o) => {
  9547. for (var s = o > 1 ? void 0 : o ? Ac(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  9548. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  9549. return o && s && Dc(e, t, s), s;
  9550. };
  9551. var $c = (n, e) => (t, o) => e(t, o, n);
  9552. var kn = class extends nt {
  9553. constructor(n) {
  9554. super(), this._sheetInterceptorService = n, this._initialize();
  9555. }
  9556. _initialize() {
  9557. this._initInterceptorCellContent();
  9558. }
  9559. _initInterceptorCellContent() {
  9560. this.disposeWithMe(
  9561. this._sheetInterceptorService.intercept(et.CELL_CONTENT, {
  9562. priority: 11,
  9563. effect: Vn.Value | Vn.Style,
  9564. handler: (n, e, t) => {
  9565. var s;
  9566. const o = e.workbook.getStyles().getStyleByCell(n);
  9567. return (s = o == null ? void 0 : o.n) != null && s.pattern ? t({ ...n }) : (n == null ? void 0 : n.t) === dn.NUMBER && n.v !== void 0 && n.v !== null && DC(n.v) ? t({
  9568. ...n,
  9569. v: _f(Number(n.v))
  9570. }) : t({ ...n });
  9571. }
  9572. })
  9573. );
  9574. }
  9575. };
  9576. kn = xc([
  9577. $c(0, ot(V))
  9578. ], kn);
  9579. var Wc = Object.defineProperty;
  9580. var Lc = Object.getOwnPropertyDescriptor;
  9581. var Vc = (n, e, t, o) => {
  9582. for (var s = o > 1 ? void 0 : o ? Lc(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  9583. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  9584. return o && s && Wc(e, t, s), s;
  9585. };
  9586. var $e2 = (n, e) => (t, o) => e(t, o, n);
  9587. var Nn = class extends nt {
  9588. constructor(e, t, o, s, r, i, a, u, l, c) {
  9589. super();
  9590. R(this, "disposableCollection", new Mi());
  9591. R(this, "_triggerPermissionUIEvent$", new Subject());
  9592. R(this, "triggerPermissionUIEvent$", this._triggerPermissionUIEvent$.asObservable());
  9593. this._commandService = e, this._univerInstanceService = t, this._permissionService = o, this._selectionManagerService = s, this._rangeProtectionRuleModel = r, this._worksheetProtectionRuleModel = i, this._localeService = a, this._lexerTreeBuilder = u, this._contextService = l, this._definedNamesService = c, this._initialize();
  9594. }
  9595. blockExecuteWithoutPermission(e) {
  9596. throw this._triggerPermissionUIEvent$.next(e), new wo("have no permission");
  9597. }
  9598. _getPermissionCheck(e, t) {
  9599. let o = true, s = "";
  9600. switch (e) {
  9601. case on.id:
  9602. fC(t.value) && t.value.f ? (o = this._permissionCheckWithFormula(t), s = this._localeService.t("permission.dialog.formulaErr")) : o = this._permissionCheckBySetRangeValue({
  9603. workbookTypes: [Me],
  9604. rangeTypes: [Pe],
  9605. worksheetTypes: [wn, Te]
  9606. }, t);
  9607. break;
  9608. case Co.id:
  9609. o = this.permissionCheckWithRanges({
  9610. workbookTypes: [Me],
  9611. rangeTypes: [Pe],
  9612. worksheetTypes: [wn, Te]
  9613. }), s = this._localeService.t("permission.dialog.editErr");
  9614. break;
  9615. case Oo.id:
  9616. case Mn.id:
  9617. o = this.permissionCheckWithoutRange({
  9618. worksheetTypes: [$t]
  9619. }), s = this._localeService.t("permission.dialog.setRowColStyleErr");
  9620. break;
  9621. case $o.id:
  9622. case Wo.id:
  9623. case Lo.id:
  9624. o = this.permissionCheckWithoutRange({
  9625. worksheetTypes: [Wt]
  9626. }), s = this._localeService.t("permission.dialog.setRowColStyleErr");
  9627. break;
  9628. case jn.id:
  9629. case Fn.id:
  9630. o = this._permissionCheckByMoveCommand(t), s = this._localeService.t("permission.dialog.moveRowColErr");
  9631. break;
  9632. case pt.id:
  9633. o = this._permissionCheckByMoveRangeCommand(t), s = this._localeService.t("permission.dialog.moveRangeErr");
  9634. break;
  9635. case Wr.id:
  9636. o = this._permissionCheckByWorksheetCommand([Me, _o]), s = this._localeService.t("permission.dialog.operatorSheetErr"), o === false && this._worksheetProtectionRuleModel.resetOrder();
  9637. break;
  9638. case Do.id:
  9639. o = this._permissionCheckByWorksheetCommand([Me, bo]), s = this._localeService.t("permission.dialog.operatorSheetErr"), o === false && this._worksheetProtectionRuleModel.resetOrder();
  9640. break;
  9641. case Fr.id:
  9642. {
  9643. const { unitId: r, subUnitId: i } = t;
  9644. o = this._permissionCheckByWorksheetCommand([Me, vo], r, i), s = this._localeService.t("permission.dialog.operatorSheetErr"), o === false && this._worksheetProtectionRuleModel.resetOrder();
  9645. }
  9646. break;
  9647. case Kn.id:
  9648. o = this.permissionCheckWithRanges({
  9649. workbookTypes: [Me],
  9650. rangeTypes: [Pe],
  9651. worksheetTypes: [Te, $t]
  9652. }, t.ranges), s = this._localeService.t("permission.dialog.setRowColStyleErr");
  9653. break;
  9654. case Jn.id:
  9655. o = this.permissionCheckWithRanges({
  9656. workbookTypes: [Me],
  9657. rangeTypes: [Pe],
  9658. worksheetTypes: [Te, Wt]
  9659. }, t.ranges), s = this._localeService.t("permission.dialog.setRowColStyleErr");
  9660. break;
  9661. case br.id:
  9662. o = this.permissionCheckWithRanges({
  9663. workbookTypes: [Me],
  9664. rangeTypes: [Pe],
  9665. worksheetTypes: [Te, $t]
  9666. }), s = this._localeService.t("permission.dialog.setRowColStyleErr");
  9667. break;
  9668. case Tr.id:
  9669. o = this.permissionCheckWithRanges({
  9670. workbookTypes: [Me],
  9671. rangeTypes: [Pe],
  9672. worksheetTypes: [Te, Wt]
  9673. }), s = this._localeService.t("permission.dialog.setRowColStyleErr");
  9674. break;
  9675. case Bn.id:
  9676. o = this._permissionCheckWithInsertRangeMove("right"), s = this._localeService.t("permission.dialog.insertOrDeleteMoveRangeErr");
  9677. break;
  9678. case sn.id:
  9679. o = this._permissionCheckWithInsertRangeMove("bottom"), s = this._localeService.t("permission.dialog.insertOrDeleteMoveRangeErr");
  9680. break;
  9681. case Pt2.id:
  9682. o = this._permissionCheckWithInsertRangeMove("left"), s = this._localeService.t("permission.dialog.insertOrDeleteMoveRangeErr");
  9683. break;
  9684. case Tt.id:
  9685. o = this._permissionCheckWithInsertRangeMove("top"), s = this._localeService.t("permission.dialog.insertOrDeleteMoveRangeErr");
  9686. break;
  9687. }
  9688. o || this.blockExecuteWithoutPermission(s);
  9689. }
  9690. _initialize() {
  9691. this._commandExecutedListener();
  9692. }
  9693. _commandExecutedListener() {
  9694. this.disposeWithMe(
  9695. this._commandService.beforeCommandExecuted((e) => {
  9696. this._getPermissionCheck(e.id, e == null ? void 0 : e.params);
  9697. })
  9698. ), this.disposeWithMe(
  9699. this._commandService.onCommandExecuted((e) => {
  9700. var t;
  9701. if (e.id === _n2.id) {
  9702. const o = e.params, { unitId: s = (t = this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET)) == null ? void 0 : t.getUnitId(), subUnitId: r } = o;
  9703. if (!s || !r)
  9704. return;
  9705. const i = this._worksheetProtectionRuleModel.getRule(s, r), a = this._rangeProtectionRuleModel.getSubunitRuleList(s, r);
  9706. i && this._worksheetProtectionRuleModel.ruleRefresh(i.permissionId), a.length && this._rangeProtectionRuleModel.ruleRefresh(r);
  9707. }
  9708. })
  9709. );
  9710. }
  9711. _permissionCheckWithInsertRangeMove(e) {
  9712. var l;
  9713. const t = N(this._univerInstanceService);
  9714. if (!t)
  9715. return false;
  9716. const { worksheet: o, unitId: s, subUnitId: r } = t, i = re.deepClone((l = this._selectionManagerService.getCurrentLastSelection()) == null ? void 0 : l.range);
  9717. return !(!i || (e === "top" || e === "bottom" ? i.endRow = o.getRowCount() - 1 : (e === "left" || e === "right") && (i.endColumn = o.getColumnCount() - 1), this._rangeProtectionRuleModel.getSubunitRuleList(s, r).map((c) => c.ranges).flat().some((c) => en.getIntersects(i, c))));
  9718. }
  9719. _permissionCheckByWorksheetCommand(e, t, o) {
  9720. var l, c;
  9721. const s = N(this._univerInstanceService, { unitId: t, subUnitId: o });
  9722. if (!s)
  9723. return false;
  9724. const { unitId: r, subUnitId: i } = s, a = this._worksheetProtectionRuleModel.getRule(r, i), u = this._rangeProtectionRuleModel.getSubunitRuleList(r, i).length > 0;
  9725. return a || u ? (c = (l = this._permissionService.getPermissionPoint(new Mo(r).id)) == null ? void 0 : l.value) != null ? c : false : this._permissionService.composePermission(e.map((d) => new d(r).id)).every((d) => d.value);
  9726. }
  9727. permissionCheckWithoutRange(e) {
  9728. var h, m, g2, f;
  9729. const t = N(this._univerInstanceService);
  9730. if (!t)
  9731. return false;
  9732. const { worksheet: o, unitId: s, subUnitId: r } = t, i = this._selectionManagerService.getCurrentLastSelection();
  9733. if (!i)
  9734. return true;
  9735. const a = (m = (h = i == null ? void 0 : i.primary) == null ? void 0 : h.actualRow) != null ? m : 0, u = (f = (g2 = i == null ? void 0 : i.primary) == null ? void 0 : g2.actualColumn) != null ? f : 0, { workbookTypes: l, worksheetTypes: c, rangeTypes: d } = e;
  9736. return !(l && l.some((C) => {
  9737. var w, b;
  9738. const S = new C(s);
  9739. return ((b = (w = this._permissionService.getPermissionPoint(S.id)) == null ? void 0 : w.value) != null ? b : false) === false;
  9740. }) === true || c && c.some((C) => {
  9741. var w, b;
  9742. const S = new C(s, r);
  9743. return ((b = (w = this._permissionService.getPermissionPoint(S.id)) == null ? void 0 : w.value) != null ? b : false) === false;
  9744. }) === true || d && d.some((C) => {
  9745. var y, x, T2, U, P;
  9746. const S = (x = (y = o.getCell(a, u)) == null ? void 0 : y.selectionProtection) == null ? void 0 : x[0];
  9747. if (!(S != null && S.ruleId))
  9748. return false;
  9749. const I = (T2 = this._rangeProtectionRuleModel.getRule(s, r, S.ruleId)) == null ? void 0 : T2.permissionId;
  9750. if (!I)
  9751. return false;
  9752. const w = new C(s, r, I);
  9753. return ((P = (U = this._permissionService.getPermissionPoint(w.id)) == null ? void 0 : U.value) != null ? P : false) === false;
  9754. }) === true);
  9755. }
  9756. permissionCheckWithRanges(e, t, o, s) {
  9757. var m;
  9758. const r = N(this._univerInstanceService);
  9759. if (!r)
  9760. return false;
  9761. const { workbook: i, worksheet: a } = r;
  9762. o || (o = i.getUnitId()), s || (s = a.getSheetId());
  9763. const u = t != null ? t : (m = this._selectionManagerService.getCurrentSelections()) == null ? void 0 : m.map((g2) => g2.range);
  9764. if (!u)
  9765. return false;
  9766. const { workbookTypes: l, worksheetTypes: c, rangeTypes: d } = e, h = [];
  9767. return l && h.push(...l.map((g2) => new g2(o).id)), c && h.push(...c.map((g2) => new g2(o, s).id)), d && this._rangeProtectionRuleModel.getSubunitRuleList(o, s).forEach((g2) => {
  9768. u.some((p) => g2.ranges.some((C) => en.intersects(C, p))) && h.push(...d.map((p) => new p(o, s, g2.permissionId).id));
  9769. }), h.length ? this._permissionService.composePermission(h).every((g2) => g2.value) : true;
  9770. }
  9771. _permissionCheckByMoveCommand(e) {
  9772. const t = N(this._univerInstanceService);
  9773. if (!t)
  9774. return false;
  9775. const { worksheet: o, unitId: s, subUnitId: r } = t, i = e.toRange;
  9776. i.endRow === o.getRowCount() - 1 ? i.endColumn = i.startColumn : i.endRow = i.startRow;
  9777. const a = this._rangeProtectionRuleModel.getSubunitRuleList(s, r).reduce((u, l) => [...u, ...l.ranges], []).filter((u) => en.intersects(u, i));
  9778. return a.length > 0 ? false : (a.forEach((u) => {
  9779. var l, c;
  9780. for (let d = u.startRow; d <= u.endRow; d++)
  9781. for (let h = u.startColumn; h <= u.endColumn; h++) {
  9782. const m = (c = (l = o.getCell(d, h)) == null ? void 0 : l.selectionProtection) == null ? void 0 : c[0];
  9783. if ((m == null ? void 0 : m[_.Edit]) === false)
  9784. return false;
  9785. }
  9786. }), true);
  9787. }
  9788. _permissionCheckByMoveRangeCommand(e) {
  9789. const t = N(this._univerInstanceService);
  9790. if (!t)
  9791. return false;
  9792. const { worksheet: o, unitId: s, subUnitId: r } = t, i = e.toRange, a = this._rangeProtectionRuleModel.getSubunitRuleList(s, r).reduce((u, l) => [...u, ...l.ranges], []).filter((u) => en.intersects(u, i));
  9793. return a.length > 0 ? false : (a.forEach((u) => {
  9794. var l, c;
  9795. for (let d = u.startRow; d <= u.endRow; d++)
  9796. for (let h = u.startColumn; h <= u.endColumn; h++) {
  9797. const m = (c = (l = o.getCell(d, h)) == null ? void 0 : l.selectionProtection) == null ? void 0 : c[0];
  9798. if ((m == null ? void 0 : m[_.Edit]) === false)
  9799. return false;
  9800. }
  9801. }), true);
  9802. }
  9803. _permissionCheckBySetRangeValue(e, t) {
  9804. let o = [];
  9805. t.range ? o = [t.range] : o = [new kt(t.value).getDataRange()];
  9806. const { unitId: s, subUnitId: r } = t;
  9807. return this.permissionCheckWithRanges(e, o, s, r);
  9808. }
  9809. _permissionCheckWithFormula(e) {
  9810. var r, i, a, u, l;
  9811. const t = e.value, o = e.range, s = t.f;
  9812. if (s) {
  9813. const c = s.substring(1), d = this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET), h = (r = e.unitId) != null ? r : d.getUnitId(), m = this._definedNamesService.getValueByName(h, c);
  9814. if (m) {
  9815. let g2 = m.formulaOrRefString;
  9816. g2.startsWith(X.EQUALS) && (g2 = g2.slice(1));
  9817. const f = g2.split(",");
  9818. for (let p = 0; p < f.length; p++) {
  9819. const C = f[p], S = fn2(C);
  9820. if (S.sheetName) {
  9821. const I = d.getSheetBySheetName(S.sheetName);
  9822. if (!I)
  9823. return true;
  9824. const { startRow: w, endRow: b, startColumn: y, endColumn: x } = S.range;
  9825. for (let T2 = w; T2 <= b; T2++)
  9826. for (let U = y; U <= x; U++) {
  9827. const P = (a = (i = I.getCell(T2, U)) == null ? void 0 : i.selectionProtection) == null ? void 0 : a[0];
  9828. if ((P == null ? void 0 : P[_.View]) === false)
  9829. return false;
  9830. }
  9831. }
  9832. }
  9833. return true;
  9834. } else {
  9835. const g2 = this._lexerTreeBuilder.sequenceNodesBuilder(s);
  9836. if (!g2)
  9837. return true;
  9838. for (let f = 0; f < g2.length; f++) {
  9839. const p = g2[f];
  9840. if (typeof p == "string" || p.nodeType !== $e.REFERENCE)
  9841. continue;
  9842. const { token: C } = p, S = mr(C), I = S.unitId ? this._univerInstanceService.getUnit(S.unitId) : this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET);
  9843. if (!I)
  9844. return true;
  9845. let w = S.sheetName ? I.getSheetBySheetName(S.sheetName) : I.getActiveSheet();
  9846. const b = I.getUnitId();
  9847. if (S.sheetName) {
  9848. if (w = I.getSheetBySheetName(S.sheetName), !w)
  9849. return true;
  9850. const P = w == null ? void 0 : w.getSheetId();
  9851. if (!this._permissionService.getPermissionPoint(new Hn(b, P).id))
  9852. return false;
  9853. }
  9854. if (!w)
  9855. return true;
  9856. const { startRow: y, endRow: x, startColumn: T2, endColumn: U } = S.range;
  9857. for (let P = y; P <= x; P++)
  9858. for (let A = T2; A <= U; A++) {
  9859. const j = (l = (u = w.getCell(P, A)) == null ? void 0 : u.selectionProtection) == null ? void 0 : l[0];
  9860. if ((j == null ? void 0 : j[_.View]) === false)
  9861. return false;
  9862. }
  9863. }
  9864. return true;
  9865. }
  9866. }
  9867. if (o) {
  9868. const c = N(this._univerInstanceService);
  9869. if (!c)
  9870. return false;
  9871. const d = e.unitId || c.unitId, h = e.subUnitId || c.subUnitId, g2 = this._rangeProtectionRuleModel.getSubunitRuleList(d, h).filter((p) => p.ranges.some((C) => en.intersects(C, o))).map((p) => new Pe(d, h, p.permissionId).id);
  9872. if (!this._permissionService.composePermission(g2).every((p) => p.value))
  9873. return false;
  9874. }
  9875. return true;
  9876. }
  9877. };
  9878. Nn = Vc([
  9879. $e2(0, Pt),
  9880. $e2(1, _n),
  9881. $e2(2, UE),
  9882. $e2(3, ot(F)),
  9883. $e2(4, ot(de)),
  9884. $e2(5, ot(Ye)),
  9885. $e2(6, ot(Vr)),
  9886. $e2(7, ot(ca)),
  9887. $e2(8, fs),
  9888. $e2(9, pr)
  9889. ], Nn);
  9890. var Hc = Object.defineProperty;
  9891. var Bc = Object.getOwnPropertyDescriptor;
  9892. var Fc = (n, e, t, o) => {
  9893. for (var s = o > 1 ? void 0 : o ? Bc(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  9894. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  9895. return o && s && Hc(e, t, s), s;
  9896. };
  9897. var no = (n, e) => (t, o) => e(t, o, n);
  9898. var ht = class extends nt {
  9899. constructor(e, t, o) {
  9900. super();
  9901. R(this, "_cellRuleCache", /* @__PURE__ */ new Map());
  9902. R(this, "_permissionIdCache", /* @__PURE__ */ new Map());
  9903. R(this, "_cellInfoCache", /* @__PURE__ */ new Map());
  9904. R(this, "_rowInfoCache", /* @__PURE__ */ new Map());
  9905. R(this, "_colInfoCache", /* @__PURE__ */ new Map());
  9906. this._ruleModel = e, this._permissionService = t, this._univerInstanceService = o, this._initUpdateCellRuleCache(), this._initUpdateCellInfoCache(), this._initUpdateRowColInfoCache(), this._initCache();
  9907. }
  9908. _initCache() {
  9909. this._univerInstanceService.getAllUnitsForType(Fe.UNIVER_SHEET).forEach((e) => {
  9910. e.getSheets().forEach((t) => {
  9911. const o = e.getUnitId(), s = t.getSheetId();
  9912. this.reBuildCache(o, s);
  9913. });
  9914. });
  9915. }
  9916. _initUpdateCellInfoCache() {
  9917. this._permissionService.permissionPointUpdate$.pipe(
  9918. filter((e) => e.type === D.SelectRange),
  9919. map((e) => e)
  9920. ).subscribe((e) => {
  9921. const { subUnitId: t, unitId: o, permissionId: s } = e, r = this._permissionIdCache.get(s);
  9922. if (!r)
  9923. return;
  9924. const i = this._ruleModel.getRule(o, t, r);
  9925. if (!i)
  9926. return;
  9927. const a = this._ensureCellInfoMap(o, t);
  9928. i.ranges.forEach((u) => {
  9929. const { startRow: l, endRow: c, startColumn: d, endColumn: h } = u;
  9930. for (let m = l; m <= c; m++)
  9931. for (let g2 = d; g2 <= h; g2++)
  9932. a.delete(`${m}-${g2}`);
  9933. });
  9934. }), this._ruleModel.ruleChange$.subscribe((e) => {
  9935. var r;
  9936. const { unitId: t, subUnitId: o } = e, s = this._ensureCellInfoMap(t, o);
  9937. e.rule.ranges.forEach((i) => {
  9938. tr.foreach(i, (a, u) => {
  9939. s.delete(`${a}-${u}`);
  9940. });
  9941. }), e.type === "set" && ((r = e.oldRule) == null || r.ranges.forEach((i) => {
  9942. tr.foreach(i, (a, u) => {
  9943. this._cellInfoCache.delete(`${a}-${u}`);
  9944. });
  9945. }));
  9946. });
  9947. }
  9948. _initUpdateCellRuleCache() {
  9949. this._ruleModel.ruleChange$.subscribe((e) => {
  9950. const { type: t } = e;
  9951. t === "add" ? this._addCellRuleCache(e) : t === "delete" ? this._deleteCellRuleCache(e) : (this._deleteCellRuleCache({ ...e, rule: e.oldRule }), this._addCellRuleCache(e));
  9952. });
  9953. }
  9954. _ensureRuleMap(e, t) {
  9955. let o = this._cellRuleCache.get(e);
  9956. o || (o = /* @__PURE__ */ new Map(), this._cellRuleCache.set(e, o));
  9957. let s = o.get(t);
  9958. return s || (s = /* @__PURE__ */ new Map(), o.set(t, s)), s;
  9959. }
  9960. _ensureCellInfoMap(e, t) {
  9961. let o = this._cellInfoCache.get(e);
  9962. o || (o = /* @__PURE__ */ new Map(), this._cellInfoCache.set(e, o));
  9963. let s = o.get(t);
  9964. return s || (s = /* @__PURE__ */ new Map(), o.set(t, s)), s;
  9965. }
  9966. _ensureRowColInfoMap(e, t, o) {
  9967. let s = o === "row" ? this._rowInfoCache.get(e) : this._colInfoCache.get(e);
  9968. s || (s = /* @__PURE__ */ new Map(), o === "row" ? this._rowInfoCache.set(e, s) : this._colInfoCache.set(e, s));
  9969. let r = s.get(t);
  9970. return r || (r = /* @__PURE__ */ new Map(), s.set(t, r)), r;
  9971. }
  9972. _addCellRuleCache(e) {
  9973. const { subUnitId: t, unitId: o, rule: s } = e, r = this._ensureRuleMap(o, t);
  9974. s.ranges.forEach((i) => {
  9975. const { startRow: a, endRow: u, startColumn: l, endColumn: c } = i;
  9976. for (let d = a; d <= u; d++)
  9977. for (let h = l; h <= c; h++)
  9978. r.set(`${d}-${h}`, s.id);
  9979. }), this._permissionIdCache.set(s.permissionId, s.id);
  9980. }
  9981. _deleteCellRuleCache(e) {
  9982. const { subUnitId: t, unitId: o, rule: s } = e, r = this._ensureRuleMap(o, t), i = this._ensureCellInfoMap(o, t);
  9983. s.ranges.forEach((a) => {
  9984. const { startRow: u, endRow: l, startColumn: c, endColumn: d } = a;
  9985. for (let h = u; h <= l; h++)
  9986. for (let m = c; m <= d; m++)
  9987. r.delete(`${h}-${m}`), i.delete(`${h}-${m}`);
  9988. }), this._permissionIdCache.delete(s.permissionId);
  9989. }
  9990. _getSelectionActions(e, t, o) {
  9991. var l, c, d, h, m, g2, f, p, C, S, I, w;
  9992. const s = (d = (c = this._permissionService.getPermissionPoint((l = new Pe(e, t, o.permissionId)) == null ? void 0 : l.id)) == null ? void 0 : c.value) != null ? d : true, r = (g2 = (m = this._permissionService.getPermissionPoint((h = new Io(e, t, o.permissionId)) == null ? void 0 : h.id)) == null ? void 0 : m.value) != null ? g2 : true, i = (C = (p = this._permissionService.getPermissionPoint((f = new Vr2(e, t, o.permissionId)) == null ? void 0 : f.id)) == null ? void 0 : p.value) != null ? C : false, a = (w = (I = this._permissionService.getPermissionPoint((S = new Lr(e, t, o.permissionId)) == null ? void 0 : S.id)) == null ? void 0 : I.value) != null ? w : false;
  9993. return {
  9994. [_.Edit]: s,
  9995. [_.View]: r,
  9996. [_.ManageCollaborator]: i,
  9997. [_.Delete]: a
  9998. };
  9999. }
  10000. reBuildCache(e, t) {
  10001. const o = this._ensureRuleMap(e, t), s = this._ensureCellInfoMap(e, t);
  10002. o.clear(), s.clear();
  10003. const r = this._ensureRowColInfoMap(e, t, "row"), i = this._ensureRowColInfoMap(e, t, "col");
  10004. r.clear(), i.clear(), this._ruleModel.getSubunitRuleList(e, t).forEach((a) => {
  10005. const u = this._getSelectionActions(e, t, a), l = {
  10006. ...u,
  10007. ruleId: a.id,
  10008. ranges: a.ranges
  10009. };
  10010. a.ranges.forEach((c) => {
  10011. const { startRow: d, endRow: h, startColumn: m, endColumn: g2 } = c;
  10012. for (let f = d; f <= h; f++) {
  10013. const p = r.get(`${f}`);
  10014. p ? p.set(a.id, u) : r.set(`${f}`, /* @__PURE__ */ new Map([[a.id, u]]));
  10015. for (let C = m; C <= g2; C++) {
  10016. o.set(`${f}-${C}`, a.id), s.set(`${f}-${C}`, l);
  10017. const S = i.get(`${C}`);
  10018. S ? S.set(a.id, u) : i.set(`${C}`, /* @__PURE__ */ new Map([[a.id, u]]));
  10019. }
  10020. }
  10021. }), this._permissionIdCache.set(a.permissionId, a.id);
  10022. });
  10023. }
  10024. getRowPermissionInfo(e, t, o, s) {
  10025. var a;
  10026. const r = (a = this._rowInfoCache.get(e)) == null ? void 0 : a.get(t);
  10027. if (!r)
  10028. return true;
  10029. const i = r.get(`${o}`);
  10030. return i ? s.every((u) => {
  10031. for (const l of i.values())
  10032. if (l[u] === false)
  10033. return false;
  10034. return true;
  10035. }) : true;
  10036. }
  10037. getColPermissionInfo(e, t, o, s) {
  10038. var a;
  10039. const r = (a = this._colInfoCache.get(e)) == null ? void 0 : a.get(t);
  10040. if (!r)
  10041. return true;
  10042. const i = r.get(`${o}`);
  10043. return i ? s.every((u) => {
  10044. for (const l of i.values())
  10045. if (l[u] === false)
  10046. return false;
  10047. return true;
  10048. }) : true;
  10049. }
  10050. _initUpdateRowColInfoCache() {
  10051. this._permissionService.permissionPointUpdate$.pipe(
  10052. filter((e) => e.type === D.SelectRange),
  10053. map((e) => e)
  10054. ).subscribe({
  10055. next: (e) => {
  10056. const { subUnitId: t, unitId: o, permissionId: s } = e, r = this._permissionIdCache.get(s);
  10057. if (!r)
  10058. return;
  10059. const i = this._ruleModel.getRule(o, t, r);
  10060. if (!i)
  10061. return;
  10062. const a = this._ensureRowColInfoMap(o, t, "row"), u = this._ensureRowColInfoMap(o, t, "col"), l = this._getSelectionActions(o, t, i);
  10063. i.ranges.forEach((c) => {
  10064. const { startRow: d, endRow: h, startColumn: m, endColumn: g2 } = c;
  10065. for (let f = d; f <= h; f++) {
  10066. const p = a.get(`${f}`);
  10067. p ? p.set(r, l) : a.set(`${f}`, /* @__PURE__ */ new Map([[r, l]]));
  10068. for (let C = m; C <= g2; C++) {
  10069. const S = u.get(`${C}`);
  10070. S ? S.set(r, l) : u.set(`${C}`, /* @__PURE__ */ new Map([[r, l]]));
  10071. }
  10072. }
  10073. });
  10074. }
  10075. }), this._ruleModel.ruleChange$.subscribe((e) => {
  10076. if (e.type === "delete") {
  10077. const { unitId: t, subUnitId: o, rule: s } = e, r = this._ensureRowColInfoMap(t, o, "row"), i = this._ensureRowColInfoMap(t, o, "col");
  10078. s.ranges.forEach((a) => {
  10079. const { startRow: u, endRow: l, startColumn: c, endColumn: d } = a;
  10080. for (let h = u; h <= l; h++) {
  10081. const m = r.get(`${h}`);
  10082. m == null || m.delete(s.id);
  10083. for (let g2 = c; g2 <= d; g2++) {
  10084. const f = i.get(`${g2}`);
  10085. f == null || f.delete(s.id);
  10086. }
  10087. }
  10088. });
  10089. }
  10090. });
  10091. }
  10092. getCellInfo(e, t, o, s) {
  10093. var l, c;
  10094. const r = this._ensureCellInfoMap(e, t), i = r.get(`${o}-${s}`);
  10095. if (i)
  10096. return i;
  10097. const a = (c = (l = this._cellRuleCache.get(e)) == null ? void 0 : l.get(t)) == null ? void 0 : c.get(`${o}-${s}`);
  10098. if (!a)
  10099. return;
  10100. const u = this._ruleModel.getRule(e, t, a);
  10101. if (u) {
  10102. const h = {
  10103. ...this._getSelectionActions(e, t, u),
  10104. ruleId: a,
  10105. ranges: u.ranges
  10106. };
  10107. return r.set(`${o}-${s}`, h), h;
  10108. }
  10109. }
  10110. deleteUnit(e) {
  10111. this._cellRuleCache.delete(e), this._cellInfoCache.delete(e), this._rowInfoCache.delete(e), this._colInfoCache.delete(e);
  10112. const t = this._univerInstanceService.getUnit(e);
  10113. t == null || t.getSheets().forEach((o) => {
  10114. const s = o.getSheetId();
  10115. this._ruleModel.getSubunitRuleList(e, s).forEach((r) => {
  10116. this._permissionIdCache.delete(r.permissionId);
  10117. });
  10118. });
  10119. }
  10120. };
  10121. ht = Fc([
  10122. no(0, ot(de)),
  10123. no(1, ot(UE)),
  10124. no(2, ot(_n))
  10125. ], ht);
  10126. var jc = Object.defineProperty;
  10127. var Gc = Object.getOwnPropertyDescriptor;
  10128. var zc = (n, e, t, o) => {
  10129. for (var s = o > 1 ? void 0 : o ? Gc(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  10130. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  10131. return o && s && jc(e, t, s), s;
  10132. };
  10133. var Ee = (n, e) => (t, o) => e(t, o, n);
  10134. var On = class extends nt {
  10135. constructor(n, e, t, o, s, r, i, a, u, l, c) {
  10136. super(), this._univerInstanceService = n, this._permissionService = e, this._authzIoService = t, this._rangeProtectionRuleModel = o, this._worksheetProtectionRuleModel = s, this._userManagerService = r, this._worksheetProtectionPointRuleModel = i, this._sheetInterceptorService = a, this._undoRedoService = u, this._commandService = l, this._rangeProtectionCache = c, this._initRangePermissionFromSnapshot(), this._initRangePermissionChange(), this._initWorksheetPermissionFromSnapshot(), this._initWorksheetPermissionChange(), this._initWorksheetPermissionPointsChange(), this._initWorkbookPermissionFromSnapshot(), this._initUserChange(), this._refreshPermissionByCollaCreate();
  10137. }
  10138. async _initRangePermissionFromSnapshot() {
  10139. const n = async (e) => {
  10140. const t = [], o = e.getUnitId(), s = e.getSheets(), r = /* @__PURE__ */ new Map();
  10141. if (s.forEach((i) => {
  10142. const a = i.getSheetId();
  10143. this._rangeProtectionRuleModel.getSubunitRuleList(o, a).forEach((u) => {
  10144. r.set(u.permissionId, u), t.push({
  10145. objectID: u.permissionId,
  10146. unitID: o,
  10147. objectType: D.SelectRange,
  10148. actions: it
  10149. });
  10150. });
  10151. }), !t.length) {
  10152. this._rangeProtectionRuleModel.changeRuleInitState(true);
  10153. return;
  10154. }
  10155. this._authzIoService.batchAllowed(t).then((i) => {
  10156. i.forEach((a) => {
  10157. const u = r.get(a.objectID);
  10158. u && Ie().forEach((l) => {
  10159. const c = new l(o, u.subUnitId, a.objectID), d = c.subType, h = a.actions.find((m) => m.action === d);
  10160. (h == null ? void 0 : h.allowed) !== void 0 && this._permissionService.updatePermissionPoint(c.id, h.allowed);
  10161. });
  10162. }), this._rangeProtectionRuleModel.changeRuleInitState(true);
  10163. });
  10164. };
  10165. await Promise.all(this._univerInstanceService.getAllUnitsForType(Fe.UNIVER_SHEET).map((e) => n(e))), this._rangeProtectionRuleModel.changeRuleInitState(true);
  10166. }
  10167. _initRangePermissionChange() {
  10168. this.disposeWithMe(
  10169. this._rangeProtectionRuleModel.ruleChange$.subscribe((n) => {
  10170. n.type !== "delete" ? this._authzIoService.allowed({
  10171. objectID: n.rule.permissionId,
  10172. unitID: n.unitId,
  10173. objectType: D.SelectRange,
  10174. actions: it
  10175. }).then((e) => {
  10176. Ie().forEach((t) => {
  10177. if (n.type === "set") {
  10178. const { rule: a, oldRule: u } = n;
  10179. if (a.permissionId === (u == null ? void 0 : u.permissionId))
  10180. return;
  10181. }
  10182. const o = n.rule, s = new t(o.unitId, o.subUnitId, o.permissionId), r = s.subType, i = e.find((a) => a.action === r);
  10183. i && this._permissionService.updatePermissionPoint(s.id, i.allowed);
  10184. }), this._rangeProtectionRuleModel.ruleRefresh(n.rule.permissionId);
  10185. }) : this._rangeProtectionRuleModel.getSubunitRuleList(n.unitId, n.subUnitId).length === 0 && (this._worksheetProtectionPointRuleModel.deleteRule(n.unitId, n.subUnitId), [...ke()].forEach((t) => {
  10186. const o = new t(n.unitId, n.subUnitId);
  10187. this._permissionService.updatePermissionPoint(o.id, o.value);
  10188. }));
  10189. })
  10190. );
  10191. }
  10192. async initWorkbookPermissionChange(n) {
  10193. var t;
  10194. const e = n || ((t = this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET)) == null ? void 0 : t.getUnitId());
  10195. e && this._authzIoService.allowed({
  10196. objectID: e,
  10197. objectType: D.Workbook,
  10198. unitID: e,
  10199. actions: fl2
  10200. }).then((o) => {
  10201. en2().forEach((s) => {
  10202. const r = new s(e), i = r.subType, a = o.find((u) => u.action === i);
  10203. a && this._permissionService.updatePermissionPoint(r.id, a.allowed);
  10204. });
  10205. });
  10206. }
  10207. async _initWorkbookPermissionFromSnapshot() {
  10208. await Promise.all(this._univerInstanceService.getAllUnitsForType(Fe.UNIVER_SHEET).map((n) => this.initWorkbookPermissionChange(n.getUnitId())));
  10209. }
  10210. _initWorksheetPermissionChange() {
  10211. this.disposeWithMe(
  10212. this._worksheetProtectionRuleModel.ruleChange$.subscribe((n) => {
  10213. n.type !== "delete" ? this._authzIoService.allowed({
  10214. objectID: n.rule.permissionId,
  10215. unitID: n.unitId,
  10216. objectType: D.Worksheet,
  10217. actions: it
  10218. }).then((e) => {
  10219. we2().forEach((t) => {
  10220. const o = new t(n.unitId, n.subUnitId), s = o.subType, r = e.find((i) => i.action === s);
  10221. r && this._permissionService.updatePermissionPoint(o.id, r.allowed);
  10222. }), this._worksheetProtectionRuleModel.ruleRefresh(n.rule.permissionId);
  10223. }) : ([...we2(), ...ke()].forEach((e) => {
  10224. const t = new e(n.unitId, n.subUnitId);
  10225. this._permissionService.updatePermissionPoint(t.id, true);
  10226. }), this._worksheetProtectionPointRuleModel.deleteRule(n.unitId, n.subUnitId));
  10227. })
  10228. );
  10229. }
  10230. _initWorksheetPermissionPointsChange() {
  10231. this.disposeWithMe(
  10232. this._worksheetProtectionPointRuleModel.pointChange$.subscribe((n) => {
  10233. this._authzIoService.allowed({
  10234. objectID: n.permissionId,
  10235. unitID: n.unitId,
  10236. objectType: D.Worksheet,
  10237. actions: eo
  10238. }).then((e) => {
  10239. ke().forEach((t) => {
  10240. const o = new t(n.unitId, n.subUnitId), s = o.subType, r = e.find((i) => i.action === s);
  10241. r && this._permissionService.updatePermissionPoint(o.id, r.allowed);
  10242. });
  10243. });
  10244. })
  10245. );
  10246. }
  10247. async _initWorksheetPermissionFromSnapshot() {
  10248. const n = async (e) => {
  10249. const t = [], o = e.getUnitId(), s = e.getSheets(), r = /* @__PURE__ */ new Map();
  10250. if (s.forEach((i) => {
  10251. const a = i.getSheetId(), u = this._worksheetProtectionRuleModel.getRule(o, a);
  10252. u && (r.set(u.permissionId, u), t.push({
  10253. objectID: u.permissionId,
  10254. unitID: o,
  10255. objectType: D.Worksheet,
  10256. actions: it
  10257. }));
  10258. const l = this._worksheetProtectionPointRuleModel.getRule(o, a);
  10259. l && (r.set(l.permissionId, l), t.push({
  10260. objectID: l.permissionId,
  10261. unitID: o,
  10262. objectType: D.Worksheet,
  10263. actions: eo
  10264. }));
  10265. }), !t.length) {
  10266. this._worksheetProtectionRuleModel.changeRuleInitState(true);
  10267. return;
  10268. }
  10269. this._authzIoService.batchAllowed(t).then((i) => {
  10270. i.forEach((a) => {
  10271. const u = r.get(a.objectID);
  10272. u && [...we2(), ...ke()].forEach((l) => {
  10273. const c = new l(o, u.subUnitId), d = c.subType, h = a.actions.find((m) => m.action === d);
  10274. (h == null ? void 0 : h.allowed) !== void 0 && this._permissionService.updatePermissionPoint(c.id, h.allowed);
  10275. });
  10276. }), this._worksheetProtectionRuleModel.changeRuleInitState(true);
  10277. });
  10278. };
  10279. await Promise.all(this._univerInstanceService.getAllUnitsForType(Fe.UNIVER_SHEET).map((e) => n(e))), this._worksheetProtectionRuleModel.changeRuleInitState(true);
  10280. }
  10281. _initUserChange() {
  10282. this.disposeWithMe(
  10283. // When the user changes, the permission points are updated. The first modification needs to be filtered here because it is a Behavior type, but in fact the user information is ready when this controller is initialized.
  10284. this._userManagerService.currentUser$.pipe(skip(1)).subscribe(() => {
  10285. const n = this._permissionService.getAllPermissionPoint();
  10286. this._permissionService.clearPermissionMap(), this._worksheetProtectionRuleModel.changeRuleInitState(false), this._univerInstanceService.getAllUnitsForType(Fe.UNIVER_SHEET).forEach((t) => {
  10287. const o = t.getUnitId();
  10288. en2().forEach((s) => {
  10289. let r = new s(o);
  10290. n.has(r.id) && (r = n.get(r.id)), this._permissionService.addPermissionPoint(r);
  10291. }), t.getSheets().forEach((s) => {
  10292. const r = s.getSheetId();
  10293. [...we2(), ...ke()].forEach((a) => {
  10294. let u = new a(o, r);
  10295. n.has(u.id) && (u = n.get(u.id)), this._permissionService.addPermissionPoint(u);
  10296. }), this._rangeProtectionRuleModel.getSubunitRuleList(o, r).forEach((a) => {
  10297. Ie().forEach((u) => {
  10298. let l = new u(o, r, a.permissionId);
  10299. n.has(l.id) && (l = n.get(l.id)), this._permissionService.addPermissionPoint(l);
  10300. });
  10301. });
  10302. }), this._initWorkbookPermissionFromSnapshot(), this._initWorksheetPermissionFromSnapshot(), this._initRangePermissionFromSnapshot();
  10303. });
  10304. })
  10305. );
  10306. }
  10307. refreshPermission(n, e) {
  10308. const t = this._worksheetProtectionRuleModel.getTargetByPermissionId(n, e);
  10309. let o = false;
  10310. if (t) {
  10311. const [i, a] = t;
  10312. this._authzIoService.allowed({
  10313. objectID: e,
  10314. unitID: n,
  10315. objectType: D.Worksheet,
  10316. actions: it
  10317. }).then((u) => {
  10318. let l = "";
  10319. we2().forEach((c) => {
  10320. var g2;
  10321. const d = new c(n, a), h = d.subType, m = u.find((f) => f.action === h);
  10322. m && (((g2 = this._permissionService.getPermissionPoint(d.id)) == null ? void 0 : g2.value) !== m.allowed && (o = true), this._permissionService.updatePermissionPoint(d.id, m.allowed), l += `${m.action}_${m.allowed}`);
  10323. }), this._worksheetProtectionRuleModel.ruleRefresh(`${e}_${l}`), o && this._undoRedoService.clearUndoRedo(n);
  10324. });
  10325. }
  10326. const s = this._worksheetProtectionPointRuleModel.getTargetByPermissionId(n, e);
  10327. if (s) {
  10328. const [i, a] = s;
  10329. this._authzIoService.allowed({
  10330. objectID: e,
  10331. unitID: n,
  10332. objectType: D.Worksheet,
  10333. actions: eo
  10334. }).then((u) => {
  10335. ke().forEach((l) => {
  10336. var m;
  10337. const c = new l(n, a), d = c.subType, h = u.find((g2) => g2.action === d);
  10338. h && (((m = this._permissionService.getPermissionPoint(c.id)) == null ? void 0 : m.value) !== h.allowed && (o = true), this._permissionService.updatePermissionPoint(c.id, h.allowed));
  10339. }), o && this._undoRedoService.clearUndoRedo(n);
  10340. });
  10341. }
  10342. const r = this._rangeProtectionRuleModel.getTargetByPermissionId(n, e);
  10343. if (r) {
  10344. const [i, a] = r;
  10345. this._authzIoService.allowed({
  10346. objectID: e,
  10347. unitID: n,
  10348. objectType: D.SelectRange,
  10349. actions: it
  10350. }).then((u) => {
  10351. let l = "";
  10352. Ie().forEach((c) => {
  10353. var g2;
  10354. const d = new c(n, a, e), h = d.subType, m = u.find((f) => f.action === h);
  10355. m && (((g2 = this._permissionService.getPermissionPoint(d.id)) == null ? void 0 : g2.value) !== m.allowed && (o = true), this._permissionService.updatePermissionPoint(d.id, m.allowed), l += `${m.action}_${m.allowed}`);
  10356. }), this._rangeProtectionRuleModel.ruleRefresh(`${e}_${l}`), o && this._undoRedoService.clearUndoRedo(n);
  10357. });
  10358. }
  10359. }
  10360. _refreshPermissionByCollaCreate() {
  10361. this.disposeWithMe(
  10362. this._commandService.onCommandExecuted((n, e) => {
  10363. if (e != null && e.fromCollab && (n.id === Ne.id || n.id === ct.id || n.id === Ao.id)) {
  10364. const t = n.params;
  10365. this._undoRedoService.clearUndoRedo(t.unitId);
  10366. }
  10367. })
  10368. );
  10369. }
  10370. };
  10371. On = zc([
  10372. Ee(0, _n),
  10373. Ee(1, UE),
  10374. Ee(2, bE),
  10375. Ee(3, ot(de)),
  10376. Ee(4, ot(Ye)),
  10377. Ee(5, ot(rr)),
  10378. Ee(6, ot(un)),
  10379. Ee(7, ot(V)),
  10380. Ee(8, ot(cn)),
  10381. Ee(9, ot(Pt)),
  10382. Ee(10, ot(ht))
  10383. ], On);
  10384. var Kc = Object.defineProperty;
  10385. var Jc = Object.getOwnPropertyDescriptor;
  10386. var Yc = (n, e, t, o) => {
  10387. for (var s = o > 1 ? void 0 : o ? Jc(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  10388. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  10389. return o && s && Kc(e, t, s), s;
  10390. };
  10391. var hn = (n, e) => (t, o) => e(t, o, n);
  10392. var Dn = class extends nt {
  10393. constructor(n, e, t, o) {
  10394. super(), this._permissionService = n, this._worksheetProtectionRuleModel = e, this._sheetInterceptorService = t, this._rangeProtectionCache = o, this._initViewModelByRangeInterceptor(), this._initViewModelBySheetInterceptor();
  10395. }
  10396. _initViewModelByRangeInterceptor() {
  10397. this.disposeWithMe(this._sheetInterceptorService.intercept(
  10398. et.CELL_CONTENT,
  10399. {
  10400. // permissions are placed at a high level to prioritize whether to filter subsequent renderings.
  10401. priority: 999,
  10402. effect: Vn.Value | Vn.Style,
  10403. handler: (n = {}, e, t) => {
  10404. const { unitId: o, subUnitId: s, row: r, col: i } = e, a = this._rangeProtectionCache.getCellInfo(o, s, r, i);
  10405. if (a) {
  10406. const u = a[_.View] === false, l = { ...n, selectionProtection: [a] };
  10407. return u ? (delete l.s, delete l.v, delete l.p, l) : t(l);
  10408. }
  10409. return t(n);
  10410. }
  10411. }
  10412. ));
  10413. }
  10414. _initViewModelBySheetInterceptor() {
  10415. this.disposeWithMe(this._sheetInterceptorService.intercept(
  10416. et.CELL_CONTENT,
  10417. {
  10418. // permissions are placed at a high level to prioritize whether to filter subsequent renderings.
  10419. priority: 999,
  10420. effect: Vn.Value | Vn.Style,
  10421. handler: (n = {}, e, t) => {
  10422. var i, a, u, l, c;
  10423. const { unitId: o, subUnitId: s } = e, r = this._worksheetProtectionRuleModel.getRule(o, s);
  10424. if (r != null && r.permissionId) {
  10425. const d = [{
  10426. [_.View]: (a = (i = this._permissionService.getPermissionPoint(new Hn(o, s).id)) == null ? void 0 : i.value) != null ? a : false,
  10427. [_.Edit]: (l = (u = this._permissionService.getPermissionPoint(new Te(o, s).id)) == null ? void 0 : u.value) != null ? l : false
  10428. }], h = !((c = d[0]) != null && c[_.View]), m = { ...n, hasWorksheetRule: true, selectionProtection: d };
  10429. return h ? (delete m.s, delete m.v, delete m.p, m) : t(m);
  10430. }
  10431. return t(n);
  10432. }
  10433. }
  10434. ));
  10435. }
  10436. };
  10437. Dn = Yc([
  10438. hn(0, UE),
  10439. hn(1, ot(Ye)),
  10440. hn(2, ot(V)),
  10441. hn(3, ot(ht))
  10442. ], Dn);
  10443. var Xc = Object.defineProperty;
  10444. var qc = Object.getOwnPropertyDescriptor;
  10445. var Zc = (n, e, t, o) => {
  10446. for (var s = o > 1 ? void 0 : o ? qc(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  10447. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  10448. return o && s && Xc(e, t, s), s;
  10449. };
  10450. var cs2 = (n, e) => (t, o) => e(t, o, n);
  10451. var tn = class {
  10452. constructor(n, e) {
  10453. R(this, "_cache", new Qr(1e4));
  10454. this._selectionProtectionRuleModel = n, this._permissionService = e, this._init();
  10455. }
  10456. _init() {
  10457. this._permissionService.permissionPointUpdate$.pipe(
  10458. filter((n) => n.type === D.SelectRange),
  10459. filter((n) => Ie().some((e) => n instanceof e)),
  10460. map((n) => n)
  10461. ).subscribe((n) => {
  10462. const e = this._selectionProtectionRuleModel.getSubunitRuleList(n.unitId, n.subUnitId);
  10463. for (const t of e)
  10464. t.permissionId === n.permissionId && t.ranges.forEach((o) => {
  10465. tr.foreach(o, (s, r) => {
  10466. const i = this._createKey(n.unitId, n.subUnitId, s, r);
  10467. this._cache.delete(i);
  10468. });
  10469. });
  10470. }), this._selectionProtectionRuleModel.ruleChange$.subscribe((n) => {
  10471. var e;
  10472. n.rule.ranges.forEach((t) => {
  10473. tr.foreach(t, (o, s) => {
  10474. const r = this._createKey(n.unitId, n.subUnitId, o, s);
  10475. this._cache.delete(r);
  10476. });
  10477. }), n.type === "set" && ((e = n.oldRule) == null || e.ranges.forEach((t) => {
  10478. tr.foreach(t, (o, s) => {
  10479. const r = this._createKey(n.unitId, n.subUnitId, o, s);
  10480. this._cache.delete(r);
  10481. });
  10482. }));
  10483. });
  10484. }
  10485. _createKey(n, e, t, o) {
  10486. return `${n}_${e}_${t}_${o}`;
  10487. }
  10488. getCellInfo(n, e, t, o) {
  10489. const s = this._selectionProtectionRuleModel.getSubunitRuleList(n, e), r = [];
  10490. if (!s || !s.length)
  10491. return r;
  10492. const i = this._createKey(n, e, t, o), a = this._cache.get(i);
  10493. if (a)
  10494. return a;
  10495. const u = [];
  10496. for (const l of s)
  10497. if (l.ranges.some((c) => c.startRow <= t && c.endRow >= t && c.startColumn <= o && c.endColumn >= o)) {
  10498. const c = Ie().reduce((d, h) => {
  10499. var f;
  10500. const m = new h(n, e, l.permissionId), g2 = this._permissionService.getPermissionPoint(m.id);
  10501. return d[m.subType] = (f = g2 == null ? void 0 : g2.value) != null ? f : m.value, d;
  10502. }, {});
  10503. u.push({ ...c, ruleId: l.id, ranges: l.ranges });
  10504. }
  10505. return this._cache.set(i, u), u;
  10506. }
  10507. clear() {
  10508. this._cache.clear();
  10509. }
  10510. };
  10511. tn = Zc([
  10512. cs2(0, ot(de)),
  10513. cs2(1, ot(UE))
  10514. ], tn);
  10515. var ds = Ct("univer.exclusive-range-service");
  10516. var Qc = class extends nt {
  10517. constructor() {
  10518. super(...arguments);
  10519. R(this, "_exclusiveRanges", /* @__PURE__ */ new Map());
  10520. R(this, "_exclusiveRangesChange$", new Subject());
  10521. R(this, "exclusiveRangesChange$", this._exclusiveRangesChange$.asObservable());
  10522. }
  10523. _ensureUnitMap(t) {
  10524. return this._exclusiveRanges.has(t) || this._exclusiveRanges.set(t, /* @__PURE__ */ new Map()), this._exclusiveRanges.get(t);
  10525. }
  10526. _ensureSubunitMap(t, o) {
  10527. const s = this._ensureUnitMap(t);
  10528. return s.has(o) || s.set(o, /* @__PURE__ */ new Map()), s.get(o);
  10529. }
  10530. _ensureFeature(t, o, s) {
  10531. const r = this._ensureSubunitMap(t, o);
  10532. return r.has(s) || r.set(s, []), r.get(s);
  10533. }
  10534. addExclusiveRange(t, o, s, r) {
  10535. const i = this._ensureFeature(t, o, s);
  10536. i.push(...r), this._exclusiveRangesChange$.next({ unitId: t, subUnitId: o, ranges: i.map((a) => a.range) });
  10537. }
  10538. getExclusiveRanges(t, o, s) {
  10539. var r, i;
  10540. return (i = (r = this._exclusiveRanges.get(t)) == null ? void 0 : r.get(o)) == null ? void 0 : i.get(s);
  10541. }
  10542. clearExclusiveRanges(t, o, s) {
  10543. const r = this.getExclusiveRanges(t, o, s);
  10544. this._exclusiveRangesChange$.next({ unitId: t, subUnitId: o, ranges: (r == null ? void 0 : r.map((i) => i.range)) || [] }), this._ensureFeature(t, o, s), this._exclusiveRanges.get(t).get(o).set(s, []);
  10545. }
  10546. clearExclusiveRangesByGroupId(t, o, s, r) {
  10547. const i = this.getExclusiveRanges(t, o, s);
  10548. this._exclusiveRangesChange$.next({ unitId: t, subUnitId: o, ranges: (i == null ? void 0 : i.map((u) => u.range)) || [] });
  10549. const a = this.getExclusiveRanges(t, o, s);
  10550. if (a) {
  10551. const u = a.filter((l) => l.groupId !== r);
  10552. this._exclusiveRanges.get(t).get(o).set(s, u);
  10553. }
  10554. }
  10555. getInterestGroupId(t) {
  10556. const o = [];
  10557. return t.forEach((s) => {
  10558. var l;
  10559. const r = s.range, { unitId: i, sheetId: a } = r;
  10560. if (!i || !a)
  10561. return;
  10562. const u = (l = this._exclusiveRanges.get(i)) == null ? void 0 : l.get(a);
  10563. if (u)
  10564. for (const c of u.keys()) {
  10565. const d = u.get(c);
  10566. if (d) {
  10567. for (const h of d)
  10568. if (en.intersects(r, h.range)) {
  10569. o.push(c);
  10570. break;
  10571. }
  10572. }
  10573. }
  10574. }), o;
  10575. }
  10576. };
  10577. var ed = Object.defineProperty;
  10578. var td = Object.getOwnPropertyDescriptor;
  10579. var nd = (n, e, t, o) => {
  10580. for (var s = o > 1 ? void 0 : o ? td(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  10581. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  10582. return o && s && ed(e, t, s), s;
  10583. };
  10584. var oo = (n, e) => (t, o) => e(t, o, n);
  10585. var co = class extends nt {
  10586. constructor(n, e, t) {
  10587. super(), this._resourceManagerService = n, this._univerInstanceService = e, this._logService = t;
  10588. }
  10589. getValue(n, e, t, o) {
  10590. const s = this._univerInstanceService.getUniverSheetInstance(n);
  10591. if (!s)
  10592. return;
  10593. const r = s == null ? void 0 : s.getSheetBySheetId(e);
  10594. if (!r)
  10595. return;
  10596. const i = s.getStyles(), a = r.getCellRaw(t, o);
  10597. if (a != null && a.s) {
  10598. const u = i.get(a.s);
  10599. if (u != null && u.n)
  10600. return u.n;
  10601. }
  10602. return null;
  10603. }
  10604. deleteValues(n, e, t) {
  10605. const o = this._univerInstanceService.getUniverSheetInstance(n);
  10606. if (!o)
  10607. return;
  10608. const s = o == null ? void 0 : o.getSheetBySheetId(e);
  10609. if (!s)
  10610. return;
  10611. const r = o.getStyles();
  10612. t.forEach((i) => {
  10613. tr.foreach(i, (a, u) => {
  10614. const l = s.getCellRaw(a, u);
  10615. if (!l)
  10616. return;
  10617. const c = l == null ? void 0 : l.s, h = { ...c && r.get(c) || {} };
  10618. delete h.n;
  10619. const m = r.setValue(h);
  10620. l.s = m;
  10621. });
  10622. });
  10623. }
  10624. setValues(n, e, t) {
  10625. const o = this._univerInstanceService.getUniverSheetInstance(n);
  10626. if (!o)
  10627. return;
  10628. const s = o == null ? void 0 : o.getSheetBySheetId(e);
  10629. if (!s)
  10630. return;
  10631. const r = o.getStyles(), i = s.getCellMatrix();
  10632. t.forEach((a) => {
  10633. a.ranges.forEach((u) => {
  10634. tr.foreach(u, (l, c) => {
  10635. const d = s.getCellRaw(l, c);
  10636. if (d) {
  10637. const m = { ...r.getStyleByCell(d) || {}, n: { pattern: a.pattern } }, g2 = r.setValue(m);
  10638. d.s = g2, a.pattern === T && (d.t = dn.STRING);
  10639. } else {
  10640. const h = { n: { pattern: a.pattern } }, m = r.setValue(h);
  10641. m && i.setValue(l, c, { s: m });
  10642. }
  10643. });
  10644. });
  10645. });
  10646. }
  10647. };
  10648. co = nd([
  10649. oo(0, Bi),
  10650. oo(1, _n),
  10651. oo(2, Mt)
  10652. ], co);
  10653. var od = Object.defineProperty;
  10654. var sd = Object.getOwnPropertyDescriptor;
  10655. var rd = (n, e, t, o) => {
  10656. for (var s = o > 1 ? void 0 : o ? sd(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  10657. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  10658. return o && s && od(e, t, s), s;
  10659. };
  10660. var Qe = (n, e) => (t, o) => e(t, o, n);
  10661. var hs = [je.id, qe.id, De2.id, Be.id];
  10662. var ms = [ot2.id, st2.id];
  10663. var An = class extends nt {
  10664. constructor(e, t, o, s, r, i, a, u) {
  10665. super();
  10666. R(this, "disposableCollection", new Mi());
  10667. this._selectionProtectionRuleModel = e, this._univerInstanceService = t, this._commandService = o, this._refRangeService = s, this._selectionProtectionRenderModel = r, this._rangeProtectionCache = i, this._sheetInterceptorService = a, this._rangeProtectionRuleModel = u, this._onRefRangeChange(), this._correctPermissionRange(), this._initReBuildCache(), this._initRemoveSheet();
  10668. }
  10669. _onRefRangeChange() {
  10670. const e = (o, s) => {
  10671. const r = this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET);
  10672. if (!r || !(r == null ? void 0 : r.getSheetBySheetId(s)))
  10673. return;
  10674. this.disposableCollection.dispose();
  10675. const a = (l) => this.refRangeHandle(l, o, s);
  10676. this._selectionProtectionRuleModel.getSubunitRuleList(o, s).reduce((l, c) => [...l, ...c.ranges], []).forEach((l) => {
  10677. this.disposableCollection.add(this._refRangeService.registerRefRange(l, a, o, s));
  10678. });
  10679. };
  10680. this.disposeWithMe(
  10681. this._commandService.onCommandExecuted((o) => {
  10682. if (o.id === Ar.id) {
  10683. const s = o.params, r = s.subUnitId, i = s.unitId;
  10684. if (!r || !i)
  10685. return;
  10686. e(i, r);
  10687. }
  10688. if (o.id === he.id || o.id === Ne.id) {
  10689. const s = o.params, r = s.subUnitId, i = s.unitId;
  10690. if (!r || !i)
  10691. return;
  10692. e(i, r);
  10693. }
  10694. })
  10695. );
  10696. const t = this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET);
  10697. if (t) {
  10698. const o = t.getActiveSheet();
  10699. if (!o)
  10700. return;
  10701. e(t.getUnitId(), o.getSheetId());
  10702. }
  10703. }
  10704. refRangeHandle(e, t, o) {
  10705. switch (e.id) {
  10706. case Fn.id:
  10707. return this._getRefRangeMutationsByMoveRows(e.params, t, o);
  10708. case jn.id:
  10709. return this._getRefRangeMutationsByMoveCols(e.params, t, o);
  10710. case mt.id:
  10711. return this._getRefRangeMutationsByInsertRows(e.params, t, o);
  10712. case gt.id:
  10713. return this._getRefRangeMutationsByInsertCols(e.params, t, o);
  10714. case zn2.id:
  10715. return this._getRefRangeMutationsByDeleteCols(e.params, t, o);
  10716. case Gn.id:
  10717. return this._getRefRangeMutationsByDeleteRows(e.params, t, o);
  10718. }
  10719. return { redos: [], undos: [] };
  10720. }
  10721. _getRefRangeMutationsByDeleteCols(e, t, o) {
  10722. const s = this._selectionProtectionRuleModel.getSubunitRuleList(t, o).filter((i) => i.ranges.some((a) => en.intersects(a, e.range))), r = e.range;
  10723. if (s.length) {
  10724. const i = [], a = [];
  10725. return s.forEach((u) => {
  10726. const l = re.deepClone(u), c = l.ranges.reduce((d, h) => {
  10727. if (en.intersects(h, r)) {
  10728. const m = re.deepClone(h), { startColumn: g2, endColumn: f } = r;
  10729. if (g2 <= m.startColumn && f >= m.endColumn)
  10730. return d;
  10731. g2 >= m.startColumn && f <= m.endColumn ? m.endColumn -= f - g2 + 1 : g2 < m.startColumn ? (m.startColumn = g2, m.endColumn -= f - g2 + 1) : f > m.endColumn && (m.endColumn = g2 - 1), this._checkIsRightRange(m) && d.push(m);
  10732. }
  10733. return d;
  10734. }, []);
  10735. l.ranges = c, l.ranges.length ? (i.push({ id: he.id, params: { unitId: t, subUnitId: o, rule: l, ruleId: u.id } }), a.push({ id: he.id, params: { unitId: t, subUnitId: o, rule: u, ruleId: u.id } })) : (i.push({ id: ze.id, params: { unitId: t, subUnitId: o, ruleIds: [u.id] } }), a.push({ id: Ne.id, params: { unitId: t, subUnitId: o, name: "", rules: [u] } }));
  10736. }), { redos: i, undos: a };
  10737. }
  10738. return { undos: [], redos: [] };
  10739. }
  10740. _getRefRangeMutationsByDeleteRows(e, t, o) {
  10741. const s = this._selectionProtectionRuleModel.getSubunitRuleList(t, o).filter((i) => i.ranges.some((a) => en.intersects(a, e.range))), r = e.range;
  10742. if (s.length) {
  10743. const i = [], a = [];
  10744. return s.forEach((u) => {
  10745. const l = re.deepClone(u), c = l.ranges.reduce((d, h) => {
  10746. if (en.intersects(h, r)) {
  10747. const m = re.deepClone(h), { startRow: g2, endRow: f } = r;
  10748. if (g2 <= m.startRow && f >= m.endRow)
  10749. return d;
  10750. g2 >= m.startRow && f <= m.endRow ? m.endRow -= f - g2 + 1 : g2 < m.startRow ? (m.startRow = g2, m.endRow -= f - g2 + 1) : f > m.endRow && (m.endRow = g2 - 1), this._checkIsRightRange(m) && d.push(m);
  10751. }
  10752. return d;
  10753. }, []);
  10754. l.ranges = c, i.push({ id: he.id, params: { unitId: t, subUnitId: o, rule: l, ruleId: u.id } }), a.push({ id: he.id, params: { unitId: t, subUnitId: o, rule: u, ruleId: u.id } });
  10755. }), { redos: i, undos: a };
  10756. }
  10757. return { undos: [], redos: [] };
  10758. }
  10759. _getRefRangeMutationsByInsertCols(e, t, o) {
  10760. const s = e.range.startColumn, r = e.range.endColumn - e.range.startColumn + 1, i = this._selectionProtectionRuleModel.getSubunitRuleList(t, o).filter((a) => a.ranges.some((u) => s > u.startColumn && s <= u.endColumn));
  10761. if (i.length) {
  10762. const a = [], u = [];
  10763. return i.forEach((l) => {
  10764. const c = re.deepClone(l);
  10765. let d = false;
  10766. c.ranges.forEach((h) => {
  10767. s > h.startColumn && s <= h.endColumn && (h.endColumn += r, d = true);
  10768. }), d && (a.push({ id: he.id, params: { unitId: t, subUnitId: o, rule: c, ruleId: l.id } }), u.push({ id: he.id, params: { unitId: t, subUnitId: o, rule: l, ruleId: l.id } }));
  10769. }), { redos: a, undos: u };
  10770. }
  10771. return { undos: [], redos: [] };
  10772. }
  10773. _getRefRangeMutationsByInsertRows(e, t, o) {
  10774. const s = e.range.startRow, r = e.range.endRow - e.range.startRow + 1, i = this._selectionProtectionRuleModel.getSubunitRuleList(t, o).filter((a) => a.ranges.some((u) => s > u.startRow && s <= u.endRow));
  10775. if (i.length) {
  10776. const a = [], u = [];
  10777. return i.forEach((l) => {
  10778. const c = re.deepClone(l);
  10779. let d = false;
  10780. c.ranges.forEach((h) => {
  10781. s > h.startRow && s <= h.endRow && (h.endRow += r, d = true);
  10782. }), d && (a.push({ id: he.id, params: { unitId: t, subUnitId: o, rule: c, ruleId: l.id } }), u.push({ id: he.id, params: { unitId: t, subUnitId: o, rule: l, ruleId: l.id } }));
  10783. }), { redos: a, undos: u };
  10784. }
  10785. return { undos: [], redos: [] };
  10786. }
  10787. _getRefRangeMutationsByMoveRows(e, t, o) {
  10788. const s = e.toRange, r = s.startRow, i = s.endRow - s.startRow + 1, a = this._selectionProtectionRuleModel.getSubunitRuleList(t, o).filter((u) => u.ranges.some((l) => r > l.startRow && r <= l.endRow));
  10789. if (a.length) {
  10790. const u = [], l = [];
  10791. return a.forEach((c) => {
  10792. const d = re.deepClone(c), m = e.fromRange.startRow;
  10793. let g2 = false;
  10794. d.ranges.forEach((f) => {
  10795. r > f.startRow && r <= f.endRow && (m < f.startRow && (f.startRow = f.startRow - i, f.endRow = f.endRow - i), f.endRow += i, g2 = true);
  10796. }), g2 && (u.push({ id: he.id, params: { unitId: t, subUnitId: o, rule: d, ruleId: c.id } }), l.push({ id: he.id, params: { unitId: t, subUnitId: o, rule: c, ruleId: c.id } }));
  10797. }), { redos: u, undos: l };
  10798. }
  10799. return { undos: [], redos: [] };
  10800. }
  10801. _getRefRangeMutationsByMoveCols(e, t, o) {
  10802. const s = e.toRange, r = s.startColumn, i = s.endColumn - s.startColumn + 1, a = this._selectionProtectionRuleModel.getSubunitRuleList(t, o).filter((u) => u.ranges.some((l) => r > l.startColumn && r <= l.endColumn));
  10803. if (a.length) {
  10804. const u = [], l = [];
  10805. return a.forEach((c) => {
  10806. const d = re.deepClone(c), m = e.fromRange.startColumn;
  10807. let g2 = false;
  10808. d.ranges.forEach((f) => {
  10809. r > f.startColumn && r <= f.endColumn && (m < f.startColumn && (f.startColumn = f.startColumn - i, f.endColumn = f.endColumn - i), f.endColumn += i, g2 = true);
  10810. }), g2 && (u.push({ id: he.id, params: { unitId: t, subUnitId: o, rule: d, ruleId: c.id } }), l.push({ id: he.id, params: { unitId: t, subUnitId: o, rule: c, ruleId: c.id } }));
  10811. }), { redos: u, undos: l };
  10812. }
  10813. return { undos: [], redos: [] };
  10814. }
  10815. _correctPermissionRange() {
  10816. this.disposeWithMe(this._commandService.onCommandExecuted((e) => {
  10817. if (ms.includes(e.id)) {
  10818. if (!e.params)
  10819. return;
  10820. const t = this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET);
  10821. if (!t)
  10822. return;
  10823. const o = t.getSheetBySheetId(e.params.subUnitId);
  10824. if (!o)
  10825. return;
  10826. const { sourceRange: s, targetRange: r } = e.params, i = s.startColumn === r.startColumn && s.endColumn === r.endColumn, a = i ? s.endRow - s.startRow + 1 : s.endColumn - s.startColumn + 1, u = i ? s.startRow : s.startColumn, l = i ? r.startRow : r.startColumn;
  10827. this._selectionProtectionRuleModel.getSubunitRuleList(t.getUnitId(), o.getSheetId()).forEach((f) => {
  10828. f.ranges.forEach((C) => {
  10829. let { startRow: S, endRow: I, startColumn: w, endColumn: b } = C;
  10830. en.intersects(C, s) || (i ? u < S && l > I ? (S -= a, I -= a) : u > I && l <= S && (S += a, I += a) : u < w && l > b ? (w -= a, b -= a) : u > b && l <= w && (w += a, b += a)), this._checkIsRightRange({ startRow: S, endRow: I, startColumn: w, endColumn: b }) && (C.startColumn = w, C.endColumn = b, C.startRow = S, C.endRow = I);
  10831. });
  10832. }), this.disposableCollection.dispose();
  10833. const { unitId: d, subUnitId: h } = e.params, m = (f) => this.refRangeHandle(f, d, h);
  10834. this._selectionProtectionRuleModel.getSubunitRuleList(d, h).reduce((f, p) => [...f, ...p.ranges], []).forEach((f) => {
  10835. this.disposableCollection.add(this._refRangeService.registerRefRange(f, m, d, h));
  10836. }), this._selectionProtectionRenderModel.clear();
  10837. }
  10838. if (hs.includes(e.id)) {
  10839. const t = this._univerInstanceService.getUniverSheetInstance(e.params.unitId);
  10840. if (!t)
  10841. return;
  10842. const o = t.getSheetBySheetId(e.params.subUnitId);
  10843. if (!o)
  10844. return;
  10845. const s = e.params;
  10846. if (!s)
  10847. return;
  10848. const { range: r } = s, i = e.id.includes("row"), a = e.id.includes("insert"), u = i ? r.startRow : r.startColumn, l = i ? r.endRow : r.endColumn, c = l - u + 1;
  10849. this._selectionProtectionRuleModel.getSubunitRuleList(t.getUnitId(), o.getSheetId()).forEach((p) => {
  10850. p.ranges.forEach((S) => {
  10851. let { startRow: I, endRow: w, startColumn: b, endColumn: y } = S;
  10852. a ? i ? u <= I && (I += c, w += c) : u <= b && (b += c, y += c) : i ? l < I && (I -= c, w -= c) : l < b && (b -= c, y -= c), this._checkIsRightRange({ startRow: I, endRow: w, startColumn: b, endColumn: y }) && (S.startColumn = b, S.endColumn = y, S.startRow = I, S.endRow = w);
  10853. });
  10854. }), this.disposableCollection.dispose();
  10855. const { unitId: h, subUnitId: m } = e.params, g2 = (p) => this.refRangeHandle(p, h, m);
  10856. this._selectionProtectionRuleModel.getSubunitRuleList(h, m).reduce((p, C) => [...p, ...C.ranges], []).forEach((p) => {
  10857. this.disposableCollection.add(this._refRangeService.registerRefRange(p, g2, h, m));
  10858. }), this._selectionProtectionRenderModel.clear();
  10859. }
  10860. }));
  10861. }
  10862. _checkIsRightRange(e) {
  10863. return e.startRow <= e.endRow && e.startColumn <= e.endColumn;
  10864. }
  10865. _initReBuildCache() {
  10866. this.disposeWithMe(this._commandService.onCommandExecuted((e) => {
  10867. if (hs.includes(e.id) || ms.includes(e.id)) {
  10868. const { unitId: t, subUnitId: o } = e.params;
  10869. this._rangeProtectionCache.reBuildCache(t, o);
  10870. }
  10871. }));
  10872. }
  10873. _initRemoveSheet() {
  10874. this._sheetInterceptorService.interceptCommand(
  10875. {
  10876. getMutations: (e) => {
  10877. const t = [], o = [], s = [], r = [];
  10878. if (e.id === ko.id) {
  10879. const i = e.params, a = [], u = [];
  10880. this._rangeProtectionRuleModel.getSubunitRuleList(i.unitId, i.subUnitId).forEach((l) => {
  10881. a.push(l.id), u.push(l);
  10882. }), a.length && u.length && (s.push({ id: ze.id, params: { unitId: i.unitId, subUnitId: i.subUnitId, ruleIds: a } }), t.push({ id: Ne.id, params: { unitId: i.unitId, subUnitId: i.subUnitId, name: "", rules: u } }));
  10883. }
  10884. return {
  10885. redos: o,
  10886. undos: t,
  10887. preRedos: s,
  10888. preUndos: r
  10889. };
  10890. }
  10891. }
  10892. );
  10893. }
  10894. };
  10895. An = rd([
  10896. Qe(0, ot(de)),
  10897. Qe(1, ot(_n)),
  10898. Qe(2, Pt),
  10899. Qe(3, ot(_t)),
  10900. Qe(4, ot(tn)),
  10901. Qe(5, ot(ht)),
  10902. Qe(6, ot(V)),
  10903. Qe(7, ot(de))
  10904. ], An);
  10905. var id = Object.defineProperty;
  10906. var ad = Object.getOwnPropertyDescriptor;
  10907. var ud = (n, e, t, o) => {
  10908. for (var s = o > 1 ? void 0 : o ? ad(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  10909. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  10910. return o && s && id(e, t, s), s;
  10911. };
  10912. var Dt = (n, e) => (t, o) => e(t, o, n);
  10913. var ld = "SHEET_RANGE_PROTECTION_PLUGIN";
  10914. var xn = class extends nt {
  10915. constructor(n, e, t, o, s) {
  10916. super(), this._selectionProtectionRuleModel = n, this._permissionService = e, this._resourceManagerService = t, this._selectionProtectionCache = o, this._univerInstanceService = s, this._initSnapshot(), this._initRuleChange();
  10917. }
  10918. _initRuleChange() {
  10919. this.disposeWithMe(
  10920. this._selectionProtectionRuleModel.ruleChange$.subscribe((n) => {
  10921. switch (n.type) {
  10922. case "add": {
  10923. Ie().forEach((e) => {
  10924. const t = new e(n.unitId, n.subUnitId, n.rule.permissionId);
  10925. this._permissionService.addPermissionPoint(t);
  10926. });
  10927. break;
  10928. }
  10929. case "delete": {
  10930. Ie().forEach((e) => {
  10931. const t = new e(n.unitId, n.subUnitId, n.rule.permissionId);
  10932. this._permissionService.deletePermissionPoint(t.id);
  10933. });
  10934. break;
  10935. }
  10936. case "set": {
  10937. n.oldRule.permissionId !== n.rule.permissionId && Ie().forEach((e) => {
  10938. const t = new e(n.unitId, n.subUnitId, n.oldRule.permissionId);
  10939. this._permissionService.deletePermissionPoint(t.id);
  10940. const o = new e(n.unitId, n.subUnitId, n.rule.permissionId);
  10941. this._permissionService.addPermissionPoint(o);
  10942. });
  10943. break;
  10944. }
  10945. }
  10946. })
  10947. );
  10948. }
  10949. _initSnapshot() {
  10950. const n = (t) => {
  10951. const s = this._selectionProtectionRuleModel.toObject()[t];
  10952. return s ? JSON.stringify(s) : "";
  10953. }, e = (t) => {
  10954. if (!t)
  10955. return {};
  10956. try {
  10957. return JSON.parse(t);
  10958. } catch {
  10959. return {};
  10960. }
  10961. };
  10962. this.disposeWithMe(
  10963. this._resourceManagerService.registerPluginResource({
  10964. toJson: n,
  10965. parseJson: e,
  10966. pluginName: ld,
  10967. businesses: [Sn.UNIVER_SHEET],
  10968. onLoad: (t, o) => {
  10969. const s = this._selectionProtectionRuleModel.toObject();
  10970. s[t] = o, this._selectionProtectionRuleModel.fromObject(s);
  10971. const r = [];
  10972. Object.keys(o).forEach((i) => {
  10973. const a = o[i];
  10974. this._selectionProtectionRuleModel.getSubunitRuleList(t, i).forEach((u) => {
  10975. r.push({
  10976. objectID: u.permissionId,
  10977. unitID: t,
  10978. objectType: D.SelectRange,
  10979. actions: it
  10980. });
  10981. }), a.forEach((u) => {
  10982. Ie().forEach((l) => {
  10983. const c = new l(t, i, u.permissionId);
  10984. c.value = false, this._permissionService.addPermissionPoint(c);
  10985. });
  10986. }), this._selectionProtectionCache.reBuildCache(t, i);
  10987. });
  10988. },
  10989. onUnLoad: (t) => {
  10990. this._selectionProtectionCache.deleteUnit(t);
  10991. }
  10992. })
  10993. );
  10994. }
  10995. };
  10996. xn = ud([
  10997. Dt(0, ot(de)),
  10998. Dt(1, ot(UE)),
  10999. Dt(2, ot(Bi)),
  11000. Dt(3, ot(ht)),
  11001. Dt(4, ot(_n))
  11002. ], xn);
  11003. var cd = Object.defineProperty;
  11004. var dd = Object.getOwnPropertyDescriptor;
  11005. var hd = (n, e, t, o) => {
  11006. for (var s = o > 1 ? void 0 : o ? dd(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  11007. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  11008. return o && s && cd(e, t, s), s;
  11009. };
  11010. var At = (n, e) => (t, o) => e(t, o, n);
  11011. var $n = class extends nt {
  11012. constructor(n, e, t, o, s) {
  11013. super(), this._permissionService = n, this._univerInstanceService = e, this._rangeProtectionRuleModel = t, this._worksheetProtectionRuleModel = o, this._worksheetProtectionPointModel = s, this._init();
  11014. }
  11015. _init() {
  11016. const n = (e) => {
  11017. const t = e.getUnitId();
  11018. en2().forEach((o) => {
  11019. const s = new o(t);
  11020. this._permissionService.addPermissionPoint(s);
  11021. });
  11022. };
  11023. this._univerInstanceService.getAllUnitsForType(Fe.UNIVER_SHEET).forEach((e) => {
  11024. n(e);
  11025. }), this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(Fe.UNIVER_SHEET).subscribe((e) => {
  11026. n(e);
  11027. })), this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(Fe.UNIVER_SHEET).subscribe((e) => {
  11028. const t = e.getUnitId();
  11029. e.getSheets().forEach((o) => {
  11030. const s = o.getSheetId();
  11031. this._rangeProtectionRuleModel.getSubunitRuleList(t, s).forEach((i) => {
  11032. [...Ie()].forEach((a) => {
  11033. const u = new a(t, s, i.permissionId);
  11034. this._permissionService.deletePermissionPoint(u.id);
  11035. });
  11036. }), [...we2(), ...ke()].forEach((i) => {
  11037. const a = new i(t, s);
  11038. this._permissionService.deletePermissionPoint(a.id);
  11039. });
  11040. }), en2().forEach((o) => {
  11041. const s = new o(t);
  11042. this._permissionService.deletePermissionPoint(s.id);
  11043. }), this._rangeProtectionRuleModel.deleteUnitModel(t), this._worksheetProtectionPointModel.deleteUnitModel(t), this._worksheetProtectionRuleModel.deleteUnitModel(t);
  11044. }));
  11045. }
  11046. };
  11047. $n = hd([
  11048. At(0, ot(UE)),
  11049. At(1, ot(_n)),
  11050. At(2, ot(de)),
  11051. At(3, ot(Ye)),
  11052. At(4, ot(un))
  11053. ], $n);
  11054. var md = Object.defineProperty;
  11055. var gd = Object.getOwnPropertyDescriptor;
  11056. var fd = (n, e, t, o) => {
  11057. for (var s = o > 1 ? void 0 : o ? gd(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  11058. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  11059. return o && s && md(e, t, s), s;
  11060. };
  11061. var Rd = (n, e) => (t, o) => e(t, o, n);
  11062. var ho = class extends nt {
  11063. constructor(n) {
  11064. super(), this._sheetRangeThemeModel = n;
  11065. }
  11066. /**
  11067. * Register a custom range theme style.
  11068. * @param {string} unitId Which unit to register the range theme style.
  11069. * @param {RangeThemeStyle} rangeThemeStyle The range theme style to register.
  11070. */
  11071. registerRangeTheme(n, e) {
  11072. this._sheetRangeThemeModel.registerRangeThemeStyle(n, e);
  11073. }
  11074. /**
  11075. * Get custom register themes name list
  11076. * @returns {string[]} The list of custom register themes name.
  11077. */
  11078. getALLRegisterThemes() {
  11079. return this._sheetRangeThemeModel.getALLRegisteredTheme();
  11080. }
  11081. /**
  11082. * Register range theme style to the range.
  11083. * @param {string} themeName The defined theme name.
  11084. * @param {IRangeThemeRangeInfo} rangeInfo The range info to apply the theme style.
  11085. */
  11086. registerRangeThemeStyle(n, e) {
  11087. this._sheetRangeThemeModel.registerRangeThemeRule(n, e);
  11088. }
  11089. /**
  11090. * Get applied range theme style name.
  11091. * @param {IRangeThemeRangeInfo} rangeInfo The range info to get the applied theme style.
  11092. * @returns {string | undefined} The applied theme style name or not exist.
  11093. */
  11094. getAppliedRangeThemeStyle(n) {
  11095. return this._sheetRangeThemeModel.getRegisteredRangeThemeStyle(n);
  11096. }
  11097. /**
  11098. * Get registered build-in range theme style
  11099. */
  11100. getRegisteredRangeThemes() {
  11101. return this._sheetRangeThemeModel.getRegisteredRangeThemes();
  11102. }
  11103. };
  11104. ho = fd([
  11105. Rd(0, ot(He))
  11106. ], ho);
  11107. var Qr2 = Object.defineProperty;
  11108. var pd = Object.getOwnPropertyDescriptor;
  11109. var Cd = (n, e, t) => e in n ? Qr2(n, e, { enumerable: true, configurable: true, writable: true, value: t }) : n[e] = t;
  11110. var Sd = (n, e, t, o) => {
  11111. for (var s = o > 1 ? void 0 : o ? pd(e, t) : e, r = n.length - 1, i; r >= 0; r--)
  11112. (i = n[r]) && (s = (o ? i(e, t, s) : i(s)) || s);
  11113. return o && s && Qr2(e, t, s), s;
  11114. };
  11115. var gs = (n, e) => (t, o) => e(t, o, n);
  11116. var ei = (n, e, t) => Cd(n, typeof e != "symbol" ? e + "" : e, t);
  11117. var wd = "SHEET_PLUGIN";
  11118. var Wn = class extends Ra {
  11119. constructor(n = ts, e, t) {
  11120. super(), this._config = n, this._injector = e, this._configService = t;
  11121. const { ...o } = nu(
  11122. {},
  11123. ts,
  11124. this._config
  11125. );
  11126. this._configService.setConfig(Kl, o), this._initConfig(), this._initDependencies();
  11127. }
  11128. _initConfig() {
  11129. var n, e, t;
  11130. (n = this._config) != null && n.onlyRegisterFormulaRelatedMutations && this._configService.setConfig(Kr, true), (e = this._config) != null && e.isRowStylePrecedeColumnStyle && this._configService.setConfig(U0, true), (t = this._config) != null && t.autoHeightForMergedCells && this._configService.setConfig(P0, true);
  11131. }
  11132. _initDependencies() {
  11133. var e;
  11134. const n = [
  11135. // services
  11136. [kt2],
  11137. [F],
  11138. [_t],
  11139. [$n],
  11140. [wt, { useClass: co }],
  11141. [V],
  11142. [ho],
  11143. // controllers
  11144. [yn],
  11145. [Tn],
  11146. [kn],
  11147. [Un],
  11148. // permission
  11149. [bn],
  11150. [Ye],
  11151. [un],
  11152. [Dn],
  11153. [On],
  11154. [Nn],
  11155. // range theme
  11156. [He],
  11157. // range protection
  11158. [tn],
  11159. [de],
  11160. [ht],
  11161. [An],
  11162. [xn],
  11163. [ds, {
  11164. useClass: Qc,
  11165. deps: [F]
  11166. }]
  11167. ];
  11168. (e = this._config) != null && e.notExecuteFormula || n.push([En]), K0(this._injector, kE(n, this._config.override)), Mf(this._injector, [
  11169. [V],
  11170. [xn],
  11171. [ds]
  11172. ]);
  11173. }
  11174. onStarting() {
  11175. Mf(this._injector, [
  11176. [yn],
  11177. [Tn],
  11178. [$n],
  11179. [bn],
  11180. [Dn]
  11181. ]);
  11182. }
  11183. onRendered() {
  11184. Mf(this._injector, [
  11185. [wt],
  11186. [On]
  11187. ]);
  11188. }
  11189. onReady() {
  11190. Mf(this._injector, [
  11191. [En],
  11192. [Un],
  11193. [He],
  11194. [kn],
  11195. [tn],
  11196. [An],
  11197. [_t],
  11198. [Nn]
  11199. ]);
  11200. }
  11201. };
  11202. ei(Wn, "pluginName", wd);
  11203. ei(Wn, "type", Fe.UNIVER_SHEET);
  11204. Wn = Sd([
  11205. OR(Fi),
  11206. gs(1, ot(Ot)),
  11207. gs(2, SE)
  11208. ], Wn);
  11209. var Id = ((n) => (n.SET_WORKSHEET_ROW_HEIGHT = "sheet.mutation.set-worksheet-row-height", n.SET_WORKSHEET_ROW_IS_AUTO_HEIGHT = "sheet.mutation.set-worksheet-row-is-auto-height", n.SET_WORKSHEET_ROW_AUTO_HEIGHT = "sheet.mutation.set-worksheet-row-auto-height", n.SET_WORKSHEET_COL_WIDTH = "sheet.mutation.set-worksheet-col-width", n.SET_WORKSHEET_ACTIVE = "sheet.operation.set-worksheet-active", n.MOVE_ROWS = "sheet.mutation.move-rows", n.MOVE_COLUMNS = "sheet.mutation.move-columns", n.SET_COL_HIDDEN = "sheet.mutation.set-col-hidden", n.SET_COL_VISIBLE = "sheet.mutation.set-col-visible", n.SET_ROW_HIDDEN = "sheet.mutation.set-row-hidden", n.SET_ROW_VISIBLE = "sheet.mutation.set-row-visible", n.INSERT_COL = "sheet.mutation.insert-col", n.INSERT_ROW = "sheet.mutation.insert-row", n.REMOVE_COL = "sheet.mutation.remove-col", n.REMOVE_ROW = "sheet.mutation.remove-row", n.TOGGLE_GRIDLINES = "sheet.mutation.toggle-gridlines", n.SET_GRIDLINES_COLOR = "sheet.mutation.set-gridlines-color", n))(Id || {});
  11210. var vd = ((n) => (n.SET_RANGE_VALUES = "sheet.mutation.set-range-values", n.MOVE_RANGE = "sheet.mutation.move-range", n.REMOVE_WORKSHEET_MERGE = "sheet.mutation.remove-worksheet-merge", n.ADD_WORKSHEET_MERGE = "sheet.mutation.add-worksheet-merge", n.REORDER_RANGE = "sheet.mutation.reorder-range", n.SET_WORKSHEET_DEFAULT_STYLE = "sheet.mutation.set-worksheet-default-style", n.SET_ROW_DATA = "sheet.mutation.set-row-data", n.SET_COL_DATA = "sheet.mutation.set-col-data", n.SET_WORKSHEET_RANGE_THEME_STYLE = "sheet.mutation.set-worksheet-range-theme-style", n.DELETE_WORKSHEET_RANGE_THEME_STYLE = "sheet.mutation.delete-worksheet-range-theme-style", n))(vd || {});
  11211. var gh = [
  11212. nt2.id,
  11213. Oe.id,
  11214. Br.id,
  11215. tt.id,
  11216. an.id,
  11217. ot2.id,
  11218. st2.id,
  11219. Xt2.id,
  11220. qt2.id,
  11221. Qt.id,
  11222. Zt.id,
  11223. je.id,
  11224. qe.id,
  11225. De2.id,
  11226. Be.id,
  11227. Ft.id,
  11228. Vt.id
  11229. ];
  11230. var fh = [
  11231. Q.id,
  11232. dt.id,
  11233. oe.id,
  11234. ne.id,
  11235. In.id,
  11236. Bt.id,
  11237. Ht.id,
  11238. Lt.id,
  11239. zt.id,
  11240. Kt.id
  11241. ];
  11242. function Rh(n) {
  11243. switch (n.id) {
  11244. case "sheet.mutation.set-range-values": {
  11245. const e = n.params;
  11246. return e.cellValue ? [{
  11247. unitId: e.unitId,
  11248. subUnitId: e.subUnitId,
  11249. range: new kt(e.cellValue).getDataRange()
  11250. }] : [];
  11251. }
  11252. case "sheet.mutation.move-range": {
  11253. const e = n.params;
  11254. return [{
  11255. unitId: e.unitId,
  11256. subUnitId: e.from.subUnitId,
  11257. range: new kt(e.from.value).getRange()
  11258. }, {
  11259. unitId: e.unitId,
  11260. subUnitId: e.to.subUnitId,
  11261. range: new kt(e.to.value).getRange()
  11262. }];
  11263. }
  11264. case "sheet.mutation.remove-worksheet-merge": {
  11265. const e = n.params;
  11266. return e.ranges.map((t) => ({
  11267. unitId: e.unitId,
  11268. subUnitId: e.subUnitId,
  11269. range: t
  11270. }));
  11271. }
  11272. case "sheet.mutation.add-worksheet-merge": {
  11273. const e = n.params;
  11274. return e.ranges.map((t) => ({
  11275. unitId: e.unitId,
  11276. subUnitId: e.subUnitId,
  11277. range: t
  11278. }));
  11279. }
  11280. case "sheet.mutation.reorder-range": {
  11281. const e = n.params;
  11282. return [{
  11283. unitId: e.unitId,
  11284. subUnitId: e.subUnitId,
  11285. range: e.range
  11286. }];
  11287. }
  11288. case "sheet.mutation.set-worksheet-default-style": {
  11289. const e = n.params;
  11290. return [{
  11291. unitId: e.unitId,
  11292. subUnitId: e.subUnitId,
  11293. range: { startRow: 0, endRow: Number.MAX_SAFE_INTEGER, startColumn: 0, endColumn: Number.MAX_SAFE_INTEGER }
  11294. }];
  11295. }
  11296. case "sheet.mutation.set-row-data": {
  11297. const e = n.params, t = Object.keys(e.rowData).map(Number);
  11298. return t.length === 0 ? [] : [{
  11299. unitId: e.unitId,
  11300. subUnitId: e.subUnitId,
  11301. range: {
  11302. startRow: Math.min(...t),
  11303. endRow: Math.max(...t),
  11304. startColumn: 0,
  11305. endColumn: Number.MAX_SAFE_INTEGER
  11306. }
  11307. }];
  11308. }
  11309. case "sheet.mutation.set-col-data": {
  11310. const e = n.params, t = Object.keys(e.columnData).map(Number);
  11311. return t.length === 0 ? [] : [{
  11312. unitId: e.unitId,
  11313. subUnitId: e.subUnitId,
  11314. range: {
  11315. startRow: 0,
  11316. endRow: Number.MAX_SAFE_INTEGER,
  11317. startColumn: Math.min(...t),
  11318. endColumn: Math.max(...t)
  11319. }
  11320. }];
  11321. }
  11322. case "sheet.mutation.set-worksheet-range-theme-style":
  11323. case "sheet.mutation.delete-worksheet-range-theme-style": {
  11324. const e = n.params;
  11325. return [{
  11326. unitId: e.unitId,
  11327. subUnitId: e.subUnitId,
  11328. range: e.range
  11329. }];
  11330. }
  11331. default:
  11332. return [];
  11333. }
  11334. }
  11335. function ph(n) {
  11336. switch (n.id) {
  11337. case "sheet.mutation.set-worksheet-row-height":
  11338. case "sheet.mutation.set-worksheet-row-is-auto-height":
  11339. case "sheet.mutation.set-worksheet-row-auto-height": {
  11340. const e = n.params;
  11341. return e.ranges.map((t) => ({
  11342. unitId: e.unitId,
  11343. subUnitId: e.subUnitId,
  11344. range: {
  11345. ...t,
  11346. rangeType: De.ROW
  11347. }
  11348. }));
  11349. }
  11350. case "sheet.mutation.set-worksheet-col-width": {
  11351. const e = n.params;
  11352. return e.ranges.map((t) => ({
  11353. unitId: e.unitId,
  11354. subUnitId: e.subUnitId,
  11355. range: {
  11356. ...t,
  11357. rangeType: De.COLUMN
  11358. }
  11359. }));
  11360. }
  11361. case "sheet.mutation.move-rows":
  11362. case "sheet.mutation.move-columns": {
  11363. const e = n.params;
  11364. return [{
  11365. unitId: e.unitId,
  11366. subUnitId: e.subUnitId,
  11367. range: e.targetRange
  11368. }, {
  11369. unitId: e.unitId,
  11370. subUnitId: e.subUnitId,
  11371. range: e.sourceRange
  11372. }];
  11373. }
  11374. case "sheet.mutation.set-col-hidden":
  11375. case "sheet.mutation.set-col-visible": {
  11376. const e = n.params;
  11377. return e.ranges.map((t) => ({
  11378. unitId: e.unitId,
  11379. subUnitId: e.subUnitId,
  11380. range: {
  11381. ...t,
  11382. rangeType: De.COLUMN
  11383. }
  11384. }));
  11385. }
  11386. case "sheet.mutation.set-row-hidden":
  11387. case "sheet.mutation.set-row-visible": {
  11388. const e = n.params;
  11389. return e.ranges.map((t) => ({
  11390. unitId: e.unitId,
  11391. subUnitId: e.subUnitId,
  11392. range: {
  11393. ...t,
  11394. rangeType: De.ROW
  11395. }
  11396. }));
  11397. }
  11398. case "sheet.mutation.insert-col": {
  11399. const e = n.params;
  11400. return [{
  11401. unitId: e.unitId,
  11402. subUnitId: e.subUnitId,
  11403. range: {
  11404. ...e.range,
  11405. rangeType: De.COLUMN
  11406. }
  11407. }];
  11408. }
  11409. case "sheet.mutation.insert-row": {
  11410. const e = n.params;
  11411. return [{
  11412. unitId: e.unitId,
  11413. subUnitId: e.subUnitId,
  11414. range: {
  11415. ...e.range,
  11416. rangeType: De.ROW
  11417. }
  11418. }];
  11419. }
  11420. case "sheet.mutation.remove-col": {
  11421. const e = n.params;
  11422. return [{
  11423. unitId: e.unitId,
  11424. subUnitId: e.subUnitId,
  11425. range: {
  11426. ...e.range,
  11427. rangeType: De.COLUMN
  11428. }
  11429. }];
  11430. }
  11431. case "sheet.mutation.remove-row": {
  11432. const e = n.params;
  11433. return [{
  11434. unitId: e.unitId,
  11435. subUnitId: e.subUnitId,
  11436. range: {
  11437. ...e.range,
  11438. rangeType: De.ROW
  11439. }
  11440. }];
  11441. }
  11442. case "sheet.mutation.toggle-gridlines":
  11443. case "sheet.mutation.set-gridlines-color":
  11444. return [];
  11445. default:
  11446. return [];
  11447. }
  11448. }
  11449. var Ch = 1.5;
  11450. var Sh = "rgba(255, 255, 255, 0.01)";
  11451. function wh(n) {
  11452. const { rangeWithCoord: e, primaryWithCoord: t, style: o } = n, s = {
  11453. range: {
  11454. startRow: e.startRow,
  11455. startColumn: e.startColumn,
  11456. endRow: e.endRow,
  11457. endColumn: e.endColumn,
  11458. rangeType: e.rangeType,
  11459. unitId: e.unitId,
  11460. sheetId: e.sheetId
  11461. },
  11462. primary: null,
  11463. style: o
  11464. };
  11465. return t != null && (s.primary = Md(t)), s;
  11466. }
  11467. function Md(n) {
  11468. const { actualRow: e, actualColumn: t, isMerged: o, isMergedMainCell: s } = n, { startRow: r, startColumn: i, endRow: a, endColumn: u } = n.mergeInfo;
  11469. return {
  11470. actualRow: e,
  11471. actualColumn: t,
  11472. isMerged: o,
  11473. isMergedMainCell: s,
  11474. startRow: r,
  11475. startColumn: i,
  11476. endRow: a,
  11477. endColumn: u
  11478. };
  11479. }
  11480. var Ih = (n, e, t) => {
  11481. const s = n.get(F).getCurrentSelections(), { value: r, selections: i, unitId: a, subUnitId: u } = e;
  11482. if (s) {
  11483. const c = s[(s == null ? void 0 : s.length) - 1].primary;
  11484. if (c) {
  11485. const { actualColumn: d, actualRow: h } = c;
  11486. let { startRow: m, startColumn: g2, endRow: f, endColumn: p } = i[i.length - 1];
  11487. if (r === yu.COLUMNS) {
  11488. const w = t.find((b) => b.startColumn === d && b.endColumn === d && h === b.startRow);
  11489. w && (p = w.endColumn, m = w.startRow, f = w.endRow);
  11490. } else if (r === yu.ROWS) {
  11491. const w = t.find((b) => b.startRow === h && b.endRow === h && d === b.startColumn);
  11492. w && (f = w.endRow, g2 = w.startColumn, p = w.endColumn);
  11493. }
  11494. const C = {
  11495. startRow: m,
  11496. startColumn: g2,
  11497. endRow: f,
  11498. endColumn: p,
  11499. actualRow: h,
  11500. actualColumn: d,
  11501. isMerged: true,
  11502. isMergedMainCell: m === h && g2 === d
  11503. }, S = s.map((w, b, y) => ({
  11504. range: w.range,
  11505. style: null,
  11506. primary: b === y.length - 1 ? C : null
  11507. })), I = {
  11508. unitId: a,
  11509. subUnitId: u,
  11510. type: Ce.ONLY_SET,
  11511. selections: S
  11512. };
  11513. return {
  11514. id: re2.id,
  11515. params: I
  11516. };
  11517. }
  11518. return null;
  11519. }
  11520. return null;
  11521. };
  11522. var vh = (n, e) => {
  11523. const o = n.get(F).getCurrentSelections(), { unitId: s, subUnitId: r } = e;
  11524. if (o && o[(o == null ? void 0 : o.length) - 1].primary) {
  11525. const u = {
  11526. unitId: s,
  11527. subUnitId: r,
  11528. type: Ce.ONLY_SET,
  11529. selections: [...o]
  11530. };
  11531. return {
  11532. id: re2.id,
  11533. params: u
  11534. };
  11535. }
  11536. return null;
  11537. };
  11538. function fs2(n) {
  11539. return n == null ? false : n.v !== void 0 && n.v !== null && n.v !== "" || n.p !== void 0;
  11540. }
  11541. function Yn(n, e) {
  11542. return n && n.spanAnchor ? fs2(e.getValue(n.spanAnchor.startRow, n.spanAnchor.startColumn)) : fs2(n);
  11543. }
  11544. function _d(n, e, t, o, s) {
  11545. const r = n.getCellMatrix(), i = n.getSpanModel().getMergedCellRange(e, t, o, s), a = new kt();
  11546. return r.forValue((u, l) => {
  11547. const c = r.getValue(u, l);
  11548. c && a.setValue(u, l, c);
  11549. }), i.forEach((u) => {
  11550. const { startColumn: l, startRow: c, endColumn: d, endRow: h } = u;
  11551. Qo(c, h, l, d).forEach((m, g2) => {
  11552. m === c && g2 === l && a.setValue(m, g2, {
  11553. ...r.getValue(m, g2),
  11554. spanAnchor: { startRow: c, endRow: h, startColumn: l, endColumn: d }
  11555. }), (m !== c || g2 !== l) && (a.realDeleteValue(m, g2), a.setValue(m, g2, {
  11556. spanAnchor: { startRow: c, endRow: h, startColumn: l, endColumn: d }
  11557. }));
  11558. });
  11559. }), a;
  11560. }
  11561. function bd(n, e, t, o) {
  11562. const { startRow: s, startColumn: r, endRow: i } = n;
  11563. let a = null, u = false;
  11564. for (let l = s; l <= i; l++) {
  11565. const c = e.getValue(l, r - t);
  11566. if (u = u || Yn(c, e), !o && u)
  11567. break;
  11568. c && c.spanAnchor && (a ? a = {
  11569. startRow: Math.min(c.spanAnchor.startRow, a.startRow),
  11570. startColumn: Math.min(c.spanAnchor.startColumn, a.startColumn),
  11571. endRow: Math.max(c.spanAnchor.endRow, a.endRow),
  11572. endColumn: Math.max(c.spanAnchor.endColumn, a.endColumn)
  11573. } : a = {
  11574. startRow: c.spanAnchor.startRow,
  11575. startColumn: c.spanAnchor.startColumn,
  11576. endRow: c.spanAnchor.endRow,
  11577. endColumn: c.spanAnchor.endColumn
  11578. });
  11579. }
  11580. return u ? (n.startColumn = n.startColumn - t, {
  11581. spanAnchor: a,
  11582. hasValue: true,
  11583. range: n
  11584. }) : {
  11585. spanAnchor: null,
  11586. hasValue: false,
  11587. range: n
  11588. };
  11589. }
  11590. function yd(n, e, t, o) {
  11591. const { startRow: s, endColumn: r, endRow: i } = n;
  11592. let a = null, u = false;
  11593. for (let l = s; l <= i; l++) {
  11594. const c = e.getValue(l, r + t);
  11595. if (u = u || Yn(c, e), !o && u)
  11596. break;
  11597. c && c.spanAnchor && (a ? a = {
  11598. startRow: Math.min(c.spanAnchor.startRow, a.startRow),
  11599. startColumn: Math.min(c.spanAnchor.startColumn, a.startColumn),
  11600. endRow: Math.max(c.spanAnchor.endRow, a.endRow),
  11601. endColumn: Math.max(c.spanAnchor.endColumn, a.endColumn)
  11602. } : a = {
  11603. startRow: c.spanAnchor.startRow,
  11604. startColumn: c.spanAnchor.startColumn,
  11605. endRow: c.spanAnchor.endRow,
  11606. endColumn: c.spanAnchor.endColumn
  11607. });
  11608. }
  11609. return u ? (n.endColumn = n.endColumn + t, {
  11610. spanAnchor: a,
  11611. hasValue: true,
  11612. range: n
  11613. }) : {
  11614. spanAnchor: null,
  11615. hasValue: false,
  11616. range: n
  11617. };
  11618. }
  11619. function Ed(n, e, t, o) {
  11620. const { startRow: s, startColumn: r, endColumn: i } = n;
  11621. let a = null, u = false;
  11622. for (let l = r; l <= i; l++) {
  11623. const c = e.getValue(s - t, l);
  11624. if (u = u || Yn(c, e), !o && u)
  11625. break;
  11626. c && c.spanAnchor && (a ? a = {
  11627. startRow: Math.min(c.spanAnchor.startRow, a.startRow),
  11628. startColumn: Math.min(c.spanAnchor.startColumn, a.startColumn),
  11629. endRow: Math.max(c.spanAnchor.endRow, a.endRow),
  11630. endColumn: Math.max(c.spanAnchor.endColumn, a.endColumn)
  11631. } : a = {
  11632. startRow: c.spanAnchor.startRow,
  11633. startColumn: c.spanAnchor.startColumn,
  11634. endRow: c.spanAnchor.endRow,
  11635. endColumn: c.spanAnchor.endColumn
  11636. });
  11637. }
  11638. return u ? (n.startRow = n.startRow - t, {
  11639. spanAnchor: a,
  11640. hasValue: true,
  11641. range: n
  11642. }) : {
  11643. spanAnchor: null,
  11644. hasValue: false,
  11645. range: n
  11646. };
  11647. }
  11648. function Ud(n, e, t, o) {
  11649. const { startColumn: s, endColumn: r, endRow: i } = n;
  11650. let a = null, u = false;
  11651. for (let l = s; l <= r; l++) {
  11652. const c = e.getValue(i + t, l);
  11653. if (u = u || Yn(c, e), !o && u)
  11654. break;
  11655. c && c.spanAnchor && (a ? a = {
  11656. startRow: Math.min(c.spanAnchor.startRow, a.startRow),
  11657. startColumn: Math.min(c.spanAnchor.startColumn, a.startColumn),
  11658. endRow: Math.max(c.spanAnchor.endRow, a.endRow),
  11659. endColumn: Math.max(c.spanAnchor.endColumn, a.endColumn)
  11660. } : a = {
  11661. startRow: c.spanAnchor.startRow,
  11662. startColumn: c.spanAnchor.startColumn,
  11663. endRow: c.spanAnchor.endRow,
  11664. endColumn: c.spanAnchor.endColumn
  11665. });
  11666. }
  11667. return u ? (n.endRow = n.endRow + t, {
  11668. spanAnchor: a,
  11669. hasValue: true,
  11670. range: n
  11671. }) : {
  11672. spanAnchor: null,
  11673. hasValue: false,
  11674. range: n
  11675. };
  11676. }
  11677. function Mh(n, e, t) {
  11678. const o = t.getMaxRows(), s = t.getMaxColumns(), r = _d(t, 0, 0, o - 1, s - 1), i = t.getSnapshot().mergeData.length > 0, { left: a, right: u, up: l, down: c } = e;
  11679. let d = true, h = { ...n };
  11680. const m = [];
  11681. for (; d; ) {
  11682. if (d = false, l && h.startRow !== 0) {
  11683. const { hasValue: g2, range: f, spanAnchor: p } = Ed(h, r, 1, i);
  11684. if (p && m.push(p), g2) {
  11685. h = f, d = true;
  11686. continue;
  11687. }
  11688. }
  11689. if (c && h.endRow !== o - 1) {
  11690. const { hasValue: g2, range: f, spanAnchor: p } = Ud(h, r, 1, i);
  11691. if (p && m.push(p), g2) {
  11692. h = f, d = true;
  11693. continue;
  11694. }
  11695. }
  11696. if (a && h.startColumn !== 0) {
  11697. const { hasValue: g2, range: f, spanAnchor: p } = bd(h, r, 1, i);
  11698. if (p && m.push(p), g2) {
  11699. h = f, d = true;
  11700. continue;
  11701. }
  11702. }
  11703. if (u && h.endColumn !== s - 1) {
  11704. const { hasValue: g2, range: f, spanAnchor: p } = yd(h, r, 1, i);
  11705. if (p && m.push(p), g2) {
  11706. h = f, d = true;
  11707. continue;
  11708. }
  11709. }
  11710. }
  11711. return m.length > 0 && (h = en.union(h, ...m)), h;
  11712. }
  11713. var ti = (n, e, t, o = 1, s = true, r = true) => {
  11714. const i = tr.transformRange(n, e), { startRow: a, endRow: u } = i;
  11715. let l = t.startRow - o, c = e.getMergedCell(l, t.startColumn), d = !c || c.startRow === l && c.startColumn === t.startColumn;
  11716. for (; !e.getRowVisible(l) || !d; )
  11717. l--, c = e.getMergedCell(l, t.startColumn), d = !c || c.startRow === l && c.startColumn === t.startColumn;
  11718. if (l >= a)
  11719. return { ...t, startRow: l, endRow: l };
  11720. if (r) {
  11721. const h = { ...t, startRow: u, endRow: u };
  11722. return oi(n, e, h, o, s, false);
  11723. }
  11724. };
  11725. var ni = (n, e, t, o = 1, s = true, r = true) => {
  11726. const i = tr.transformRange(n, e), { startRow: a, endRow: u } = i;
  11727. let l = t.endRow + o, c = e.getMergedCell(l, t.startColumn), d = !c || c.startRow === l && c.startColumn === t.startColumn;
  11728. for (; !e.getRowVisible(l) || !d; )
  11729. l++, c = e.getMergedCell(l, t.startColumn), d = !c || c.startRow === l && c.startColumn === t.startColumn;
  11730. if (l <= u)
  11731. return { ...t, startRow: l, endRow: l };
  11732. if (r) {
  11733. const h = { ...t, startRow: a, endRow: a };
  11734. return si(n, e, h, o, s, false);
  11735. }
  11736. };
  11737. var oi = (n, e, t, o = 1, s = true, r = true) => {
  11738. const i = tr.transformRange(n, e), { startColumn: a, endColumn: u } = i;
  11739. let l = t.startColumn - o, c = e.getMergedCell(t.startRow, l), d = !c || c.startRow === t.startRow && c.startColumn === l;
  11740. for (; !e.getColVisible(l) || !d; )
  11741. l--, c = e.getMergedCell(t.startRow, l), d = !c || c.startRow === t.startRow && c.startColumn === l;
  11742. if (l >= a)
  11743. return { ...t, startColumn: l, endColumn: l };
  11744. if (r) {
  11745. const h = { ...t, startColumn: u, endColumn: u };
  11746. return ti(n, e, h, o, s, false);
  11747. }
  11748. };
  11749. var si = (n, e, t, o = 1, s = true, r = true) => {
  11750. const i = tr.transformRange(n, e), { startColumn: a, endColumn: u } = i;
  11751. let l = t.endColumn + o, c = e.getMergedCell(t.startRow, l), d = !c || c.startRow === t.startRow && c.startColumn === l;
  11752. for (; !e.getColVisible(l) || !d; )
  11753. l++, c = e.getMergedCell(t.startRow, l), d = !c || c.startRow === t.startRow && c.startColumn === l;
  11754. if (l <= u)
  11755. return { ...t, endColumn: l, startColumn: l };
  11756. if (r) {
  11757. const h = { ...t, startColumn: a, endColumn: a };
  11758. return ni(n, e, h, o, s, false);
  11759. }
  11760. };
  11761. function mn(n, e, t) {
  11762. let o = null;
  11763. return t.getMatrixWithMergedCells(n, e, n, e).forValue((r, i, a) => (o = {
  11764. actualRow: r,
  11765. actualColumn: i,
  11766. startRow: r,
  11767. startColumn: i,
  11768. isMerged: a.rowSpan !== void 0 || a.colSpan !== void 0,
  11769. isMergedMainCell: a.rowSpan !== void 0 && a.colSpan !== void 0,
  11770. endRow: r + (a.rowSpan !== void 0 ? a.rowSpan - 1 : 0),
  11771. endColumn: i + (a.colSpan !== void 0 ? a.colSpan - 1 : 0),
  11772. rangeType: De.NORMAL
  11773. }, false)), o || {
  11774. actualColumn: e,
  11775. actualRow: n,
  11776. startRow: n,
  11777. startColumn: e,
  11778. endRow: n,
  11779. endColumn: e,
  11780. isMerged: false,
  11781. isMergedMainCell: false,
  11782. rangeType: De.NORMAL
  11783. };
  11784. }
  11785. var Pd = (n, e, t, o, s = 1) => {
  11786. switch (o) {
  11787. case wu.UP:
  11788. return ti(n, e, t, s);
  11789. case wu.DOWN:
  11790. return ni(n, e, t, s);
  11791. case wu.LEFT:
  11792. return oi(n, e, t, s);
  11793. case wu.RIGHT:
  11794. return si(n, e, t, s);
  11795. }
  11796. };
  11797. var _h = (n, e, t) => {
  11798. let o, s = -1, r;
  11799. for (let C = 0; C < n.length; C++)
  11800. if (n[C].primary) {
  11801. o = n[C], s = C, r = o.primary;
  11802. break;
  11803. }
  11804. if (s === -1)
  11805. return null;
  11806. const i = e === wu.LEFT || e === wu.UP, a = i ? s - 1 >= 0 ? s - 1 : n.length - 1 : s + 1 < n.length ? s + 1 : 0, u = n[a];
  11807. if (!o || !r)
  11808. return null;
  11809. const l = { ...r }, { startRow: c, startColumn: d, endRow: h, endColumn: m } = o.range, g2 = i ? l.startRow === c && l.startColumn === d : l.endRow === h && l.endColumn === m, f = g2 && i;
  11810. if (!en.equals(o.range, l)) {
  11811. const C = g2 ? u.range : Pd(o.range, t, l, e);
  11812. if (!C)
  11813. return null;
  11814. const S = f ? mn(C.endRow, C.endColumn, t) : mn(C.startRow, C.startColumn, t);
  11815. return {
  11816. startRow: S.startRow,
  11817. startColumn: S.startColumn,
  11818. endRow: S.endRow,
  11819. endColumn: S.endColumn
  11820. };
  11821. }
  11822. const p = f ? mn(u.range.endRow, u.range.endColumn, t) : mn(u.range.startRow, u.range.startColumn, t);
  11823. return {
  11824. startRow: p.startRow,
  11825. startColumn: p.startColumn,
  11826. endRow: p.endRow,
  11827. endColumn: p.endColumn
  11828. };
  11829. };
  11830. var bh = {
  11831. WorkbookCommentPermission: Ws,
  11832. WorkbookCopyPermission: Ls,
  11833. WorkbookCreateProtectPermission: Vs2,
  11834. WorkbookCreateSheetPermission: Hs,
  11835. WorkbookDeleteSheetPermission: Bs,
  11836. WorkbookDuplicatePermission: Fs,
  11837. WorkbookEditablePermission: Me,
  11838. WorkbookExportPermission: js,
  11839. WorkbookHideSheetPermission: vo,
  11840. WorkbookHistoryPermission: tu,
  11841. WorkbookManageCollaboratorPermission: Mo,
  11842. WorkbookMoveSheetPermission: _o,
  11843. WorkbookPrintPermission: Gs2,
  11844. WorkbookRecoverHistoryPermission: zs,
  11845. WorkbookRenameSheetPermission: bo,
  11846. WorkbookSharePermission: Ks,
  11847. WorkbookViewHistoryPermission: Ys,
  11848. WorkbookViewPermission: Js,
  11849. WorksheetCopyPermission: Xs,
  11850. WorksheetDeleteColumnPermission: qs,
  11851. WorksheetDeleteProtectionPermission: Zs,
  11852. WorksheetDeleteRowPermission: Qs,
  11853. WorksheetEditExtraObjectPermission: er,
  11854. WorksheetEditPermission: Te,
  11855. WorksheetFilterPermission: tr2,
  11856. WorksheetInsertColumnPermission: nr,
  11857. WorksheetInsertHyperlinkPermission: or,
  11858. WorksheetInsertRowPermission: sr,
  11859. WorksheetManageCollaboratorPermission: rr2,
  11860. WorksheetPivotTablePermission: ir,
  11861. WorksheetSelectProtectedCellsPermission: nu2,
  11862. WorksheetSelectUnProtectedCellsPermission: ou,
  11863. WorksheetSetCellStylePermission: ar2,
  11864. WorksheetSetCellValuePermission: wn,
  11865. WorksheetSetColumnStylePermission: $t,
  11866. WorksheetSetRowStylePermission: Wt,
  11867. WorksheetSortPermission: ur,
  11868. WorksheetViewPermission: Hn,
  11869. RangeProtectionPermissionEditPoint: Pe,
  11870. RangeProtectionPermissionViewPoint: Io
  11871. };
  11872. var yh = (n, e, t, o) => {
  11873. const s = n.get(UE), r = n.get(de), i = s.getPermissionPoint(new Me(e).id);
  11874. if (!(i != null && i.value))
  11875. return false;
  11876. const a = s.getPermissionPoint(new Te(e, t).id);
  11877. if (!(a != null && a.value))
  11878. return false;
  11879. const l = r.getSubunitRuleList(e, t).filter((c) => c.ranges.some((d) => o.some((h) => en.intersects(d, h))));
  11880. return l.length ? l.every((c) => {
  11881. const d = c.permissionId, h = s.getPermissionPoint(new Pe(e, t, d).id);
  11882. return !!(h != null && h.value);
  11883. }) : true;
  11884. };
  11885. function Td(n, e) {
  11886. return e.some((t) => kd(n, t));
  11887. }
  11888. function kd(n, e) {
  11889. const { startRow: t, startColumn: o, endColumn: s, endRow: r } = e, i = n.getMatrixWithMergedCells(t, o, r, s);
  11890. let a = false;
  11891. return i.forValue((u, l, c) => {
  11892. if (c && (u !== t || l !== o) && n.cellHasValue(c))
  11893. return a = true, false;
  11894. }), a;
  11895. }
  11896. function Nd(n, e, t, o) {
  11897. const s = [], r = [], i = t.getSheetId();
  11898. return o.forEach((a) => {
  11899. const u = Od(t, a), l = {
  11900. unitId: e,
  11901. subUnitId: i,
  11902. cellValue: u.getData()
  11903. }, c = Ae(
  11904. n,
  11905. l
  11906. );
  11907. s.push({ id: Q.id, params: c }), r.push({ id: Q.id, params: l });
  11908. }), {
  11909. undos: s,
  11910. redos: r
  11911. };
  11912. }
  11913. function Od(n, e) {
  11914. const { startRow: t, startColumn: o, endColumn: s, endRow: r } = e, i = n.getMatrixWithMergedCells(t, o, r, s, zn.Intercepted), a = new kt();
  11915. return i.forValue((u, l, c) => {
  11916. c && (u !== t || l !== o) && a.setValue(u, l, null);
  11917. }), a;
  11918. }
  11919. var Xn = {
  11920. type: ar.COMMAND,
  11921. id: "sheet.command.add-worksheet-merge",
  11922. handler: (n, e) => {
  11923. const t = n.get(Pt), o = n.get(cn), s = n.get(_n), r = e.unitId, i = e.subUnitId, a = e.selections, u = Zr(a, e.value), l = s.getUniverSheetInstance(r).getSheetBySheetId(i), c = [], d = [], h = Td(l, u), m = {
  11924. unitId: r,
  11925. subUnitId: i,
  11926. ranges: u
  11927. }, g2 = {
  11928. unitId: r,
  11929. subUnitId: i,
  11930. ranges: u
  11931. };
  11932. c.push({ id: oe.id, params: m }), c.push({ id: ne.id, params: g2 });
  11933. const f = Se(n, m), p = Ue(n, g2);
  11934. if (d.push({ id: oe.id, params: p }), d.push({ id: ne.id, params: f }), h) {
  11935. const S = Nd(n, r, l, u);
  11936. c.unshift(...S.redos), d.push(...S.undos);
  11937. }
  11938. return mu(c, t).result ? (o.pushUndoRedo({
  11939. unitID: r,
  11940. undoMutations: d,
  11941. redoMutations: c
  11942. }), true) : false;
  11943. }
  11944. };
  11945. var Eh = {
  11946. type: ar.COMMAND,
  11947. id: "sheet.command.add-worksheet-merge-all",
  11948. handler: async (n) => {
  11949. var l;
  11950. const e = n.get(Pt), o = (l = n.get(F).getCurrentSelections()) == null ? void 0 : l.map((c) => c.range);
  11951. if (!(o != null && o.length))
  11952. return false;
  11953. const r = n.get(_n).getCurrentUnitForType(Fe.UNIVER_SHEET);
  11954. if (!r)
  11955. return false;
  11956. const i = r.getActiveSheet();
  11957. if (!i)
  11958. return false;
  11959. const a = r.getUnitId(), u = i.getSheetId();
  11960. return e.executeCommand(Xn.id, {
  11961. selections: o,
  11962. unitId: a,
  11963. subUnitId: u
  11964. });
  11965. }
  11966. };
  11967. var Uh = {
  11968. type: ar.COMMAND,
  11969. id: "sheet.command.add-worksheet-merge-vertical",
  11970. handler: async (n) => {
  11971. var l;
  11972. const e = n.get(Pt), o = (l = n.get(F).getCurrentSelections()) == null ? void 0 : l.map((c) => c.range);
  11973. if (!(o != null && o.length))
  11974. return false;
  11975. const r = n.get(_n).getCurrentUnitForType(Fe.UNIVER_SHEET);
  11976. if (!r)
  11977. return false;
  11978. const i = r.getActiveSheet();
  11979. if (!i)
  11980. return false;
  11981. const a = r.getUnitId(), u = i.getSheetId();
  11982. return e.executeCommand(Xn.id, {
  11983. value: yu.COLUMNS,
  11984. selections: o,
  11985. unitId: a,
  11986. subUnitId: u
  11987. });
  11988. }
  11989. };
  11990. var Ph = {
  11991. type: ar.COMMAND,
  11992. id: "sheet.command.add-worksheet-merge-horizontal",
  11993. handler: async (n) => {
  11994. var l;
  11995. const e = n.get(Pt), o = (l = n.get(F).getCurrentSelections()) == null ? void 0 : l.map((c) => c.range);
  11996. if (!(o != null && o.length))
  11997. return false;
  11998. const r = n.get(_n).getCurrentUnitForType(Fe.UNIVER_SHEET);
  11999. if (!r)
  12000. return false;
  12001. const i = r.getActiveSheet();
  12002. if (!i)
  12003. return false;
  12004. const a = r.getUnitId(), u = i.getSheetId();
  12005. return e.executeCommand(Xn.id, {
  12006. value: yu.ROWS,
  12007. selections: o,
  12008. unitId: a,
  12009. subUnitId: u
  12010. });
  12011. }
  12012. };
  12013. function Th(n, e, t, o, s) {
  12014. const r = n.get(_n), i = N(r, { unitId: e, subUnitId: t });
  12015. if (!i)
  12016. return;
  12017. const { worksheet: a } = i;
  12018. if (a.getMergeData().some((d) => o.some((h) => en.intersects(h, d))))
  12019. throw new Error("The ranges to be merged overlap with the existing merged cells");
  12020. n.get(Pt).executeCommand(Xn.id, {
  12021. unitId: e,
  12022. subUnitId: t,
  12023. selections: o,
  12024. defaultMerge: s
  12025. });
  12026. }
  12027. var Dd = (n, e) => {
  12028. const r = n.get(_n).getUniverSheetInstance(e.unitId).getSheetBySheetId(e.subUnitId).getConfig().rightToLeft;
  12029. return {
  12030. ...re.deepClone(e),
  12031. rightToLeft: r
  12032. };
  12033. };
  12034. var so = {
  12035. id: "sheet.mutation.set-worksheet-right-to-left",
  12036. type: ar.MUTATION,
  12037. handler: (n, e) => {
  12038. const t = n.get(_n).getUniverSheetInstance(e.unitId);
  12039. if (!t)
  12040. return false;
  12041. const o = t.getSheetBySheetId(e.subUnitId);
  12042. if (!o)
  12043. return false;
  12044. const s = o.getConfig();
  12045. return s.rightToLeft = e.rightToLeft, true;
  12046. }
  12047. };
  12048. var kh = {
  12049. type: ar.COMMAND,
  12050. id: "sheet.command.set-worksheet-right-to-left",
  12051. handler: async (n, e) => {
  12052. var d;
  12053. const t = n.get(Pt), o = n.get(cn), s = N(n.get(_n), e);
  12054. if (!s)
  12055. return false;
  12056. const { unitId: r, subUnitId: i } = s;
  12057. let a = we.FALSE;
  12058. e && (a = (d = e.rightToLeft) != null ? d : we.FALSE);
  12059. const u = {
  12060. rightToLeft: a,
  12061. unitId: r,
  12062. subUnitId: i
  12063. }, l = Dd(
  12064. n,
  12065. u
  12066. );
  12067. return t.syncExecuteCommand(
  12068. so.id,
  12069. u
  12070. ) ? (o.pushUndoRedo({
  12071. unitID: r,
  12072. undoMutations: [{ id: so.id, params: l }],
  12073. redoMutations: [
  12074. { id: so.id, params: u }
  12075. ]
  12076. }), true) : false;
  12077. }
  12078. };
  12079. export {
  12080. T,
  12081. Ji2 as Ji,
  12082. Yi,
  12083. de,
  12084. Bd,
  12085. ze,
  12086. Fd,
  12087. Ne,
  12088. Xi2 as Xi,
  12089. Ye,
  12090. ct,
  12091. St,
  12092. qi,
  12093. et,
  12094. ea,
  12095. Go2 as Go,
  12096. qn,
  12097. Zn,
  12098. V,
  12099. yt,
  12100. va,
  12101. N,
  12102. Et,
  12103. zt,
  12104. Ma,
  12105. Kt,
  12106. _a,
  12107. ba,
  12108. Os,
  12109. Ua,
  12110. Ce,
  12111. Ta,
  12112. F,
  12113. jd,
  12114. Gd,
  12115. Aa,
  12116. Ae,
  12117. Q,
  12118. po,
  12119. Co,
  12120. So,
  12121. As,
  12122. Jt,
  12123. ja,
  12124. Ut,
  12125. xs,
  12126. dt,
  12127. Xa,
  12128. qo,
  12129. qa,
  12130. re2 as re,
  12131. Ln,
  12132. zd,
  12133. Kd,
  12134. ve,
  12135. Xe2 as Xe,
  12136. Jd,
  12137. Vn2 as Vn,
  12138. pt,
  12139. wo2 as wo,
  12140. _,
  12141. D,
  12142. Pe,
  12143. Io,
  12144. Ws,
  12145. Ls,
  12146. eu,
  12147. Vs2 as Vs,
  12148. Hs,
  12149. Bs,
  12150. Fs,
  12151. Me,
  12152. js,
  12153. vo,
  12154. tu,
  12155. Mo,
  12156. _o,
  12157. Gs2 as Gs,
  12158. zs,
  12159. bo,
  12160. Ks,
  12161. Js,
  12162. Ys,
  12163. Xs,
  12164. qs,
  12165. Zs,
  12166. Qs,
  12167. Te,
  12168. er,
  12169. tr2 as tr,
  12170. nr,
  12171. or,
  12172. sr,
  12173. rr2 as rr,
  12174. ir,
  12175. nu2 as nu,
  12176. ou,
  12177. ar2 as ar,
  12178. wn,
  12179. $t,
  12180. Wt,
  12181. ur,
  12182. Hn,
  12183. on,
  12184. lr,
  12185. cr,
  12186. Yd,
  12187. Xd,
  12188. Pt2 as Pt,
  12189. Tt,
  12190. su,
  12191. ru,
  12192. iu,
  12193. au,
  12194. mr2 as mr,
  12195. qe,
  12196. yo,
  12197. je,
  12198. Be,
  12199. De2 as De,
  12200. sn,
  12201. Bn,
  12202. mt,
  12203. fr,
  12204. du,
  12205. hu,
  12206. gt,
  12207. pr2 as pr,
  12208. mu2 as mu,
  12209. gu,
  12210. fu,
  12211. Ru,
  12212. ot2 as ot,
  12213. pu,
  12214. st2 as st,
  12215. Fn,
  12216. jn,
  12217. Yt,
  12218. Uo,
  12219. wu2 as wu,
  12220. Ir,
  12221. vr,
  12222. Gn,
  12223. Mr,
  12224. zn2 as zn,
  12225. ko,
  12226. Ue,
  12227. ne,
  12228. Se,
  12229. oe,
  12230. Iu,
  12231. Mu,
  12232. In,
  12233. uo,
  12234. kt2 as kt,
  12235. rn,
  12236. Tu,
  12237. ku,
  12238. Nu,
  12239. Ou,
  12240. xu,
  12241. Lt,
  12242. $u,
  12243. Xt2 as Xt,
  12244. qt2 as qt,
  12245. Kn,
  12246. br,
  12247. yr,
  12248. Ur,
  12249. Pr,
  12250. ut,
  12251. Bu,
  12252. Fu,
  12253. Vt,
  12254. ju,
  12255. he,
  12256. qd,
  12257. Ct2 as Ct,
  12258. Gu,
  12259. zu,
  12260. Ht,
  12261. Ku,
  12262. Zt,
  12263. Qt,
  12264. Jn,
  12265. Tr,
  12266. kr,
  12267. fe,
  12268. Zd,
  12269. Qd,
  12270. eh,
  12271. th,
  12272. nh,
  12273. oh,
  12274. sh,
  12275. Zu,
  12276. Qu,
  12277. el,
  12278. tl,
  12279. nl,
  12280. ol,
  12281. sl,
  12282. rl,
  12283. fn3 as fn,
  12284. al,
  12285. Or,
  12286. Dr,
  12287. an,
  12288. Ar,
  12289. xr,
  12290. tt,
  12291. Oo,
  12292. Mn,
  12293. Bt,
  12294. cl,
  12295. dl,
  12296. lt,
  12297. hl,
  12298. _n2 as _n,
  12299. Do,
  12300. Rn,
  12301. Wr,
  12302. un,
  12303. Lr,
  12304. Vr2 as Vr,
  12305. Ie,
  12306. it,
  12307. rh,
  12308. en2 as en,
  12309. fl2 as fl,
  12310. we2 as we,
  12311. ke,
  12312. eo,
  12313. bn,
  12314. Ao,
  12315. Il,
  12316. vl,
  12317. ih,
  12318. nt2 as nt,
  12319. Oe,
  12320. Br,
  12321. $o,
  12322. Wo,
  12323. Lo,
  12324. Fr,
  12325. Pl,
  12326. Tl,
  12327. kl,
  12328. Ft,
  12329. Nl,
  12330. Ol,
  12331. Dl,
  12332. Al,
  12333. xl,
  12334. jr,
  12335. Gr,
  12336. ah,
  12337. wt,
  12338. uh,
  12339. Vo2 as Vo,
  12340. zr,
  12341. lh,
  12342. lo,
  12343. Wl,
  12344. Ll,
  12345. ch,
  12346. Un,
  12347. $,
  12348. q,
  12349. _e,
  12350. Pn,
  12351. Jr,
  12352. Yr,
  12353. tc,
  12354. It,
  12355. Xr,
  12356. oc,
  12357. vt,
  12358. ic,
  12359. ac,
  12360. uc,
  12361. cc,
  12362. hc,
  12363. gc,
  12364. Mt2 as Mt,
  12365. os,
  12366. dh,
  12367. ss,
  12368. hh,
  12369. Sc,
  12370. mh,
  12371. _t,
  12372. Zr,
  12373. Oc,
  12374. Tn,
  12375. Nn,
  12376. ht,
  12377. On,
  12378. tn,
  12379. ds,
  12380. Qc,
  12381. co,
  12382. An,
  12383. xn,
  12384. $n,
  12385. ho,
  12386. Wn,
  12387. Id,
  12388. vd,
  12389. gh,
  12390. fh,
  12391. Rh,
  12392. ph,
  12393. Ch,
  12394. Sh,
  12395. wh,
  12396. Md,
  12397. Ih,
  12398. vh,
  12399. Mh,
  12400. _h,
  12401. bh,
  12402. yh,
  12403. Xn,
  12404. Eh,
  12405. Uh,
  12406. Ph,
  12407. Th,
  12408. so,
  12409. kh
  12410. };
  12411. //# sourceMappingURL=chunk-BW43Z7N3.js.map