| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013 |
- import { watch as fe, reactive as ti, ref as ei, watchEffect as Sn, toRaw as Rr, computed as mh } from "vue";
- var Or = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
- function vh(s) {
- return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
- }
- var Cn = {}, V = {}, st = {}, $ = {};
- (function(s) {
- Object.defineProperty(s, "__esModule", { value: !0 }), s._registerNode = s.Konva = s.glob = void 0;
- const t = Math.PI / 180;
- function e() {
- return typeof window < "u" && ({}.toString.call(window) === "[object Window]" || {}.toString.call(window) === "[object global]");
- }
- s.glob = typeof Or < "u" ? Or : typeof window < "u" ? window : typeof WorkerGlobalScope < "u" ? self : {}, s.Konva = {
- _global: s.glob,
- version: "9.3.6",
- isBrowser: e(),
- isUnminified: /param/.test((function(n) {
- }).toString()),
- dblClickWindow: 400,
- getAngle(n) {
- return s.Konva.angleDeg ? n * t : n;
- },
- enableTrace: !1,
- pointerEventsEnabled: !0,
- autoDrawEnabled: !0,
- hitOnDragEnabled: !1,
- capturePointerEventsEnabled: !1,
- _mouseListenClick: !1,
- _touchListenClick: !1,
- _pointerListenClick: !1,
- _mouseInDblClickWindow: !1,
- _touchInDblClickWindow: !1,
- _pointerInDblClickWindow: !1,
- _mouseDblClickPointerId: null,
- _touchDblClickPointerId: null,
- _pointerDblClickPointerId: null,
- pixelRatio: typeof window < "u" && window.devicePixelRatio || 1,
- dragDistance: 3,
- angleDeg: !0,
- showWarnings: !0,
- dragButtons: [0, 1],
- isDragging() {
- return s.Konva.DD.isDragging;
- },
- isTransforming() {
- var n;
- return (n = s.Konva.Transformer) === null || n === void 0 ? void 0 : n.isTransforming();
- },
- isDragReady() {
- return !!s.Konva.DD.node;
- },
- releaseCanvasOnDestroy: !0,
- document: s.glob.document,
- _injectGlobal(n) {
- s.glob.Konva = n;
- }
- };
- const i = (n) => {
- s.Konva[n.prototype.getClassName()] = n;
- };
- s._registerNode = i, s.Konva._injectGlobal(s.Konva);
- })($);
- (function(s) {
- Object.defineProperty(s, "__esModule", { value: !0 }), s.Util = s.Transform = void 0;
- const t = $;
- class e {
- constructor(y = [1, 0, 0, 1, 0, 0]) {
- this.dirty = !1, this.m = y && y.slice() || [1, 0, 0, 1, 0, 0];
- }
- reset() {
- this.m[0] = 1, this.m[1] = 0, this.m[2] = 0, this.m[3] = 1, this.m[4] = 0, this.m[5] = 0;
- }
- copy() {
- return new e(this.m);
- }
- copyInto(y) {
- y.m[0] = this.m[0], y.m[1] = this.m[1], y.m[2] = this.m[2], y.m[3] = this.m[3], y.m[4] = this.m[4], y.m[5] = this.m[5];
- }
- point(y) {
- var x = this.m;
- return {
- x: x[0] * y.x + x[2] * y.y + x[4],
- y: x[1] * y.x + x[3] * y.y + x[5]
- };
- }
- translate(y, x) {
- return this.m[4] += this.m[0] * y + this.m[2] * x, this.m[5] += this.m[1] * y + this.m[3] * x, this;
- }
- scale(y, x) {
- return this.m[0] *= y, this.m[1] *= y, this.m[2] *= x, this.m[3] *= x, this;
- }
- rotate(y) {
- var x = Math.cos(y), b = Math.sin(y), C = this.m[0] * x + this.m[2] * b, w = this.m[1] * x + this.m[3] * b, E = this.m[0] * -b + this.m[2] * x, S = this.m[1] * -b + this.m[3] * x;
- return this.m[0] = C, this.m[1] = w, this.m[2] = E, this.m[3] = S, this;
- }
- getTranslation() {
- return {
- x: this.m[4],
- y: this.m[5]
- };
- }
- skew(y, x) {
- var b = this.m[0] + this.m[2] * x, C = this.m[1] + this.m[3] * x, w = this.m[2] + this.m[0] * y, E = this.m[3] + this.m[1] * y;
- return this.m[0] = b, this.m[1] = C, this.m[2] = w, this.m[3] = E, this;
- }
- multiply(y) {
- var x = this.m[0] * y.m[0] + this.m[2] * y.m[1], b = this.m[1] * y.m[0] + this.m[3] * y.m[1], C = this.m[0] * y.m[2] + this.m[2] * y.m[3], w = this.m[1] * y.m[2] + this.m[3] * y.m[3], E = this.m[0] * y.m[4] + this.m[2] * y.m[5] + this.m[4], S = this.m[1] * y.m[4] + this.m[3] * y.m[5] + this.m[5];
- return this.m[0] = x, this.m[1] = b, this.m[2] = C, this.m[3] = w, this.m[4] = E, this.m[5] = S, this;
- }
- invert() {
- var y = 1 / (this.m[0] * this.m[3] - this.m[1] * this.m[2]), x = this.m[3] * y, b = -this.m[1] * y, C = -this.m[2] * y, w = this.m[0] * y, E = y * (this.m[2] * this.m[5] - this.m[3] * this.m[4]), S = y * (this.m[1] * this.m[4] - this.m[0] * this.m[5]);
- return this.m[0] = x, this.m[1] = b, this.m[2] = C, this.m[3] = w, this.m[4] = E, this.m[5] = S, this;
- }
- getMatrix() {
- return this.m;
- }
- decompose() {
- var y = this.m[0], x = this.m[1], b = this.m[2], C = this.m[3], w = this.m[4], E = this.m[5], S = y * C - x * b;
- let P = {
- x: w,
- y: E,
- rotation: 0,
- scaleX: 0,
- scaleY: 0,
- skewX: 0,
- skewY: 0
- };
- if (y != 0 || x != 0) {
- var k = Math.sqrt(y * y + x * x);
- P.rotation = x > 0 ? Math.acos(y / k) : -Math.acos(y / k), P.scaleX = k, P.scaleY = S / k, P.skewX = (y * b + x * C) / S, P.skewY = 0;
- } else if (b != 0 || C != 0) {
- var F = Math.sqrt(b * b + C * C);
- P.rotation = Math.PI / 2 - (C > 0 ? Math.acos(-b / F) : -Math.acos(b / F)), P.scaleX = S / F, P.scaleY = F, P.skewX = 0, P.skewY = (y * b + x * C) / S;
- }
- return P.rotation = s.Util._getRotation(P.rotation), P;
- }
- }
- s.Transform = e;
- var i = "[object Array]", n = "[object Number]", r = "[object String]", a = "[object Boolean]", o = Math.PI / 180, h = 180 / Math.PI, l = "#", A = "", u = "0", f = "Konva warning: ", c = "Konva error: ", d = "rgb(", p = {
- aliceblue: [240, 248, 255],
- antiquewhite: [250, 235, 215],
- aqua: [0, 255, 255],
- aquamarine: [127, 255, 212],
- azure: [240, 255, 255],
- beige: [245, 245, 220],
- bisque: [255, 228, 196],
- black: [0, 0, 0],
- blanchedalmond: [255, 235, 205],
- blue: [0, 0, 255],
- blueviolet: [138, 43, 226],
- brown: [165, 42, 42],
- burlywood: [222, 184, 135],
- cadetblue: [95, 158, 160],
- chartreuse: [127, 255, 0],
- chocolate: [210, 105, 30],
- coral: [255, 127, 80],
- cornflowerblue: [100, 149, 237],
- cornsilk: [255, 248, 220],
- crimson: [220, 20, 60],
- cyan: [0, 255, 255],
- darkblue: [0, 0, 139],
- darkcyan: [0, 139, 139],
- darkgoldenrod: [184, 132, 11],
- darkgray: [169, 169, 169],
- darkgreen: [0, 100, 0],
- darkgrey: [169, 169, 169],
- darkkhaki: [189, 183, 107],
- darkmagenta: [139, 0, 139],
- darkolivegreen: [85, 107, 47],
- darkorange: [255, 140, 0],
- darkorchid: [153, 50, 204],
- darkred: [139, 0, 0],
- darksalmon: [233, 150, 122],
- darkseagreen: [143, 188, 143],
- darkslateblue: [72, 61, 139],
- darkslategray: [47, 79, 79],
- darkslategrey: [47, 79, 79],
- darkturquoise: [0, 206, 209],
- darkviolet: [148, 0, 211],
- deeppink: [255, 20, 147],
- deepskyblue: [0, 191, 255],
- dimgray: [105, 105, 105],
- dimgrey: [105, 105, 105],
- dodgerblue: [30, 144, 255],
- firebrick: [178, 34, 34],
- floralwhite: [255, 255, 240],
- forestgreen: [34, 139, 34],
- fuchsia: [255, 0, 255],
- gainsboro: [220, 220, 220],
- ghostwhite: [248, 248, 255],
- gold: [255, 215, 0],
- goldenrod: [218, 165, 32],
- gray: [128, 128, 128],
- green: [0, 128, 0],
- greenyellow: [173, 255, 47],
- grey: [128, 128, 128],
- honeydew: [240, 255, 240],
- hotpink: [255, 105, 180],
- indianred: [205, 92, 92],
- indigo: [75, 0, 130],
- ivory: [255, 255, 240],
- khaki: [240, 230, 140],
- lavender: [230, 230, 250],
- lavenderblush: [255, 240, 245],
- lawngreen: [124, 252, 0],
- lemonchiffon: [255, 250, 205],
- lightblue: [173, 216, 230],
- lightcoral: [240, 128, 128],
- lightcyan: [224, 255, 255],
- lightgoldenrodyellow: [250, 250, 210],
- lightgray: [211, 211, 211],
- lightgreen: [144, 238, 144],
- lightgrey: [211, 211, 211],
- lightpink: [255, 182, 193],
- lightsalmon: [255, 160, 122],
- lightseagreen: [32, 178, 170],
- lightskyblue: [135, 206, 250],
- lightslategray: [119, 136, 153],
- lightslategrey: [119, 136, 153],
- lightsteelblue: [176, 196, 222],
- lightyellow: [255, 255, 224],
- lime: [0, 255, 0],
- limegreen: [50, 205, 50],
- linen: [250, 240, 230],
- magenta: [255, 0, 255],
- maroon: [128, 0, 0],
- mediumaquamarine: [102, 205, 170],
- mediumblue: [0, 0, 205],
- mediumorchid: [186, 85, 211],
- mediumpurple: [147, 112, 219],
- mediumseagreen: [60, 179, 113],
- mediumslateblue: [123, 104, 238],
- mediumspringgreen: [0, 250, 154],
- mediumturquoise: [72, 209, 204],
- mediumvioletred: [199, 21, 133],
- midnightblue: [25, 25, 112],
- mintcream: [245, 255, 250],
- mistyrose: [255, 228, 225],
- moccasin: [255, 228, 181],
- navajowhite: [255, 222, 173],
- navy: [0, 0, 128],
- oldlace: [253, 245, 230],
- olive: [128, 128, 0],
- olivedrab: [107, 142, 35],
- orange: [255, 165, 0],
- orangered: [255, 69, 0],
- orchid: [218, 112, 214],
- palegoldenrod: [238, 232, 170],
- palegreen: [152, 251, 152],
- paleturquoise: [175, 238, 238],
- palevioletred: [219, 112, 147],
- papayawhip: [255, 239, 213],
- peachpuff: [255, 218, 185],
- peru: [205, 133, 63],
- pink: [255, 192, 203],
- plum: [221, 160, 203],
- powderblue: [176, 224, 230],
- purple: [128, 0, 128],
- rebeccapurple: [102, 51, 153],
- red: [255, 0, 0],
- rosybrown: [188, 143, 143],
- royalblue: [65, 105, 225],
- saddlebrown: [139, 69, 19],
- salmon: [250, 128, 114],
- sandybrown: [244, 164, 96],
- seagreen: [46, 139, 87],
- seashell: [255, 245, 238],
- sienna: [160, 82, 45],
- silver: [192, 192, 192],
- skyblue: [135, 206, 235],
- slateblue: [106, 90, 205],
- slategray: [119, 128, 144],
- slategrey: [119, 128, 144],
- snow: [255, 255, 250],
- springgreen: [0, 255, 127],
- steelblue: [70, 130, 180],
- tan: [210, 180, 140],
- teal: [0, 128, 128],
- thistle: [216, 191, 216],
- transparent: [255, 255, 255, 0],
- tomato: [255, 99, 71],
- turquoise: [64, 224, 208],
- violet: [238, 130, 238],
- wheat: [245, 222, 179],
- white: [255, 255, 255],
- whitesmoke: [245, 245, 245],
- yellow: [255, 255, 0],
- yellowgreen: [154, 205, 5]
- }, m = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/, v = [];
- const _ = typeof requestAnimationFrame < "u" && requestAnimationFrame || function(g) {
- setTimeout(g, 60);
- };
- s.Util = {
- _isElement(g) {
- return !!(g && g.nodeType == 1);
- },
- _isFunction(g) {
- return !!(g && g.constructor && g.call && g.apply);
- },
- _isPlainObject(g) {
- return !!g && g.constructor === Object;
- },
- _isArray(g) {
- return Object.prototype.toString.call(g) === i;
- },
- _isNumber(g) {
- return Object.prototype.toString.call(g) === n && !isNaN(g) && isFinite(g);
- },
- _isString(g) {
- return Object.prototype.toString.call(g) === r;
- },
- _isBoolean(g) {
- return Object.prototype.toString.call(g) === a;
- },
- isObject(g) {
- return g instanceof Object;
- },
- isValidSelector(g) {
- if (typeof g != "string")
- return !1;
- var y = g[0];
- return y === "#" || y === "." || y === y.toUpperCase();
- },
- _sign(g) {
- return g === 0 || g > 0 ? 1 : -1;
- },
- requestAnimFrame(g) {
- v.push(g), v.length === 1 && _(function() {
- const y = v;
- v = [], y.forEach(function(x) {
- x();
- });
- });
- },
- createCanvasElement() {
- var g = document.createElement("canvas");
- try {
- g.style = g.style || {};
- } catch {
- }
- return g;
- },
- createImageElement() {
- return document.createElement("img");
- },
- _isInDocument(g) {
- for (; g = g.parentNode; )
- if (g == document)
- return !0;
- return !1;
- },
- _urlToImage(g, y) {
- var x = s.Util.createImageElement();
- x.onload = function() {
- y(x);
- }, x.src = g;
- },
- _rgbToHex(g, y, x) {
- return ((1 << 24) + (g << 16) + (y << 8) + x).toString(16).slice(1);
- },
- _hexToRgb(g) {
- g = g.replace(l, A);
- var y = parseInt(g, 16);
- return {
- r: y >> 16 & 255,
- g: y >> 8 & 255,
- b: y & 255
- };
- },
- getRandomColor() {
- for (var g = (Math.random() * 16777215 << 0).toString(16); g.length < 6; )
- g = u + g;
- return l + g;
- },
- getRGB(g) {
- var y;
- return g in p ? (y = p[g], {
- r: y[0],
- g: y[1],
- b: y[2]
- }) : g[0] === l ? this._hexToRgb(g.substring(1)) : g.substr(0, 4) === d ? (y = m.exec(g.replace(/ /g, "")), {
- r: parseInt(y[1], 10),
- g: parseInt(y[2], 10),
- b: parseInt(y[3], 10)
- }) : {
- r: 0,
- g: 0,
- b: 0
- };
- },
- colorToRGBA(g) {
- return g = g || "black", s.Util._namedColorToRBA(g) || s.Util._hex3ColorToRGBA(g) || s.Util._hex4ColorToRGBA(g) || s.Util._hex6ColorToRGBA(g) || s.Util._hex8ColorToRGBA(g) || s.Util._rgbColorToRGBA(g) || s.Util._rgbaColorToRGBA(g) || s.Util._hslColorToRGBA(g);
- },
- _namedColorToRBA(g) {
- var y = p[g.toLowerCase()];
- return y ? {
- r: y[0],
- g: y[1],
- b: y[2],
- a: 1
- } : null;
- },
- _rgbColorToRGBA(g) {
- if (g.indexOf("rgb(") === 0) {
- g = g.match(/rgb\(([^)]+)\)/)[1];
- var y = g.split(/ *, */).map(Number);
- return {
- r: y[0],
- g: y[1],
- b: y[2],
- a: 1
- };
- }
- },
- _rgbaColorToRGBA(g) {
- if (g.indexOf("rgba(") === 0) {
- g = g.match(/rgba\(([^)]+)\)/)[1];
- var y = g.split(/ *, */).map((x, b) => x.slice(-1) === "%" ? b === 3 ? parseInt(x) / 100 : parseInt(x) / 100 * 255 : Number(x));
- return {
- r: y[0],
- g: y[1],
- b: y[2],
- a: y[3]
- };
- }
- },
- _hex8ColorToRGBA(g) {
- if (g[0] === "#" && g.length === 9)
- return {
- r: parseInt(g.slice(1, 3), 16),
- g: parseInt(g.slice(3, 5), 16),
- b: parseInt(g.slice(5, 7), 16),
- a: parseInt(g.slice(7, 9), 16) / 255
- };
- },
- _hex6ColorToRGBA(g) {
- if (g[0] === "#" && g.length === 7)
- return {
- r: parseInt(g.slice(1, 3), 16),
- g: parseInt(g.slice(3, 5), 16),
- b: parseInt(g.slice(5, 7), 16),
- a: 1
- };
- },
- _hex4ColorToRGBA(g) {
- if (g[0] === "#" && g.length === 5)
- return {
- r: parseInt(g[1] + g[1], 16),
- g: parseInt(g[2] + g[2], 16),
- b: parseInt(g[3] + g[3], 16),
- a: parseInt(g[4] + g[4], 16) / 255
- };
- },
- _hex3ColorToRGBA(g) {
- if (g[0] === "#" && g.length === 4)
- return {
- r: parseInt(g[1] + g[1], 16),
- g: parseInt(g[2] + g[2], 16),
- b: parseInt(g[3] + g[3], 16),
- a: 1
- };
- },
- _hslColorToRGBA(g) {
- if (/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(g)) {
- const [y, ...x] = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(g), b = Number(x[0]) / 360, C = Number(x[1]) / 100, w = Number(x[2]) / 100;
- let E, S, P;
- if (C === 0)
- return P = w * 255, {
- r: Math.round(P),
- g: Math.round(P),
- b: Math.round(P),
- a: 1
- };
- w < 0.5 ? E = w * (1 + C) : E = w + C - w * C;
- const k = 2 * w - E, F = [0, 0, 0];
- for (let L = 0; L < 3; L++)
- S = b + 1 / 3 * -(L - 1), S < 0 && S++, S > 1 && S--, 6 * S < 1 ? P = k + (E - k) * 6 * S : 2 * S < 1 ? P = E : 3 * S < 2 ? P = k + (E - k) * (2 / 3 - S) * 6 : P = k, F[L] = P * 255;
- return {
- r: Math.round(F[0]),
- g: Math.round(F[1]),
- b: Math.round(F[2]),
- a: 1
- };
- }
- },
- haveIntersection(g, y) {
- return !(y.x > g.x + g.width || y.x + y.width < g.x || y.y > g.y + g.height || y.y + y.height < g.y);
- },
- cloneObject(g) {
- var y = {};
- for (var x in g)
- this._isPlainObject(g[x]) ? y[x] = this.cloneObject(g[x]) : this._isArray(g[x]) ? y[x] = this.cloneArray(g[x]) : y[x] = g[x];
- return y;
- },
- cloneArray(g) {
- return g.slice(0);
- },
- degToRad(g) {
- return g * o;
- },
- radToDeg(g) {
- return g * h;
- },
- _degToRad(g) {
- return s.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."), s.Util.degToRad(g);
- },
- _radToDeg(g) {
- return s.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."), s.Util.radToDeg(g);
- },
- _getRotation(g) {
- return t.Konva.angleDeg ? s.Util.radToDeg(g) : g;
- },
- _capitalize(g) {
- return g.charAt(0).toUpperCase() + g.slice(1);
- },
- throw(g) {
- throw new Error(c + g);
- },
- error(g) {
- console.error(c + g);
- },
- warn(g) {
- t.Konva.showWarnings && console.warn(f + g);
- },
- each(g, y) {
- for (var x in g)
- y(x, g[x]);
- },
- _inRange(g, y, x) {
- return y <= g && g < x;
- },
- _getProjectionToSegment(g, y, x, b, C, w) {
- var E, S, P, k = (g - x) * (g - x) + (y - b) * (y - b);
- if (k == 0)
- E = g, S = y, P = (C - x) * (C - x) + (w - b) * (w - b);
- else {
- var F = ((C - g) * (x - g) + (w - y) * (b - y)) / k;
- F < 0 ? (E = g, S = y, P = (g - C) * (g - C) + (y - w) * (y - w)) : F > 1 ? (E = x, S = b, P = (x - C) * (x - C) + (b - w) * (b - w)) : (E = g + F * (x - g), S = y + F * (b - y), P = (E - C) * (E - C) + (S - w) * (S - w));
- }
- return [E, S, P];
- },
- _getProjectionToLine(g, y, x) {
- var b = s.Util.cloneObject(g), C = Number.MAX_VALUE;
- return y.forEach(function(w, E) {
- if (!(!x && E === y.length - 1)) {
- var S = y[(E + 1) % y.length], P = s.Util._getProjectionToSegment(w.x, w.y, S.x, S.y, g.x, g.y), k = P[0], F = P[1], L = P[2];
- L < C && (b.x = k, b.y = F, C = L);
- }
- }), b;
- },
- _prepareArrayForTween(g, y, x) {
- var b, C = [], w = [];
- if (g.length > y.length) {
- var E = y;
- y = g, g = E;
- }
- for (b = 0; b < g.length; b += 2)
- C.push({
- x: g[b],
- y: g[b + 1]
- });
- for (b = 0; b < y.length; b += 2)
- w.push({
- x: y[b],
- y: y[b + 1]
- });
- var S = [];
- return w.forEach(function(P) {
- var k = s.Util._getProjectionToLine(P, C, x);
- S.push(k.x), S.push(k.y);
- }), S;
- },
- _prepareToStringify(g) {
- var y;
- g.visitedByCircularReferenceRemoval = !0;
- for (var x in g)
- if (g.hasOwnProperty(x) && g[x] && typeof g[x] == "object") {
- if (y = Object.getOwnPropertyDescriptor(g, x), g[x].visitedByCircularReferenceRemoval || s.Util._isElement(g[x]))
- if (y.configurable)
- delete g[x];
- else
- return null;
- else if (s.Util._prepareToStringify(g[x]) === null)
- if (y.configurable)
- delete g[x];
- else
- return null;
- }
- return delete g.visitedByCircularReferenceRemoval, g;
- },
- _assign(g, y) {
- for (var x in y)
- g[x] = y[x];
- return g;
- },
- _getFirstPointerId(g) {
- return g.touches ? g.changedTouches[0].identifier : g.pointerId || 999;
- },
- releaseCanvas(...g) {
- t.Konva.releaseCanvasOnDestroy && g.forEach((y) => {
- y.width = 0, y.height = 0;
- });
- },
- drawRoundedRectPath(g, y, x, b) {
- let C = 0, w = 0, E = 0, S = 0;
- typeof b == "number" ? C = w = E = S = Math.min(b, y / 2, x / 2) : (C = Math.min(b[0] || 0, y / 2, x / 2), w = Math.min(b[1] || 0, y / 2, x / 2), S = Math.min(b[2] || 0, y / 2, x / 2), E = Math.min(b[3] || 0, y / 2, x / 2)), g.moveTo(C, 0), g.lineTo(y - w, 0), g.arc(y - w, w, w, Math.PI * 3 / 2, 0, !1), g.lineTo(y, x - S), g.arc(y - S, x - S, S, 0, Math.PI / 2, !1), g.lineTo(E, x), g.arc(E, x - E, E, Math.PI / 2, Math.PI, !1), g.lineTo(0, C), g.arc(C, C, C, Math.PI, Math.PI * 3 / 2, !1);
- }
- };
- })(st);
- var O = {};
- Object.defineProperty(O, "__esModule", { value: !0 });
- O.getComponentValidator = O.getBooleanValidator = O.getNumberArrayValidator = O.getFunctionValidator = O.getStringOrGradientValidator = O.getStringValidator = O.getNumberOrAutoValidator = O.getNumberOrArrayOfNumbersValidator = O.getNumberValidator = O.alphaComponent = O.RGBComponent = void 0;
- const Kt = $, ht = st;
- function Zt(s) {
- return ht.Util._isString(s) ? '"' + s + '"' : Object.prototype.toString.call(s) === "[object Number]" || ht.Util._isBoolean(s) ? s : Object.prototype.toString.call(s);
- }
- function _h(s) {
- return s > 255 ? 255 : s < 0 ? 0 : Math.round(s);
- }
- O.RGBComponent = _h;
- function xh(s) {
- return s > 1 ? 1 : s < 1e-4 ? 1e-4 : s;
- }
- O.alphaComponent = xh;
- function bh() {
- if (Kt.Konva.isUnminified)
- return function(s, t) {
- return ht.Util._isNumber(s) || ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a number.'), s;
- };
- }
- O.getNumberValidator = bh;
- function wh(s) {
- if (Kt.Konva.isUnminified)
- return function(t, e) {
- let i = ht.Util._isNumber(t), n = ht.Util._isArray(t) && t.length == s;
- return !i && !n && ht.Util.warn(Zt(t) + ' is a not valid value for "' + e + '" attribute. The value should be a number or Array<number>(' + s + ")"), t;
- };
- }
- O.getNumberOrArrayOfNumbersValidator = wh;
- function Sh() {
- if (Kt.Konva.isUnminified)
- return function(s, t) {
- var e = ht.Util._isNumber(s), i = s === "auto";
- return e || i || ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a number or "auto".'), s;
- };
- }
- O.getNumberOrAutoValidator = Sh;
- function Ch() {
- if (Kt.Konva.isUnminified)
- return function(s, t) {
- return ht.Util._isString(s) || ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a string.'), s;
- };
- }
- O.getStringValidator = Ch;
- function Mh() {
- if (Kt.Konva.isUnminified)
- return function(s, t) {
- const e = ht.Util._isString(s), i = Object.prototype.toString.call(s) === "[object CanvasGradient]" || s && s.addColorStop;
- return e || i || ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a string or a native gradient.'), s;
- };
- }
- O.getStringOrGradientValidator = Mh;
- function Ph() {
- if (Kt.Konva.isUnminified)
- return function(s, t) {
- return ht.Util._isFunction(s) || ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a function.'), s;
- };
- }
- O.getFunctionValidator = Ph;
- function Eh() {
- if (Kt.Konva.isUnminified)
- return function(s, t) {
- const e = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
- return e && s instanceof e || (ht.Util._isArray(s) ? s.forEach(function(i) {
- ht.Util._isNumber(i) || ht.Util.warn('"' + t + '" attribute has non numeric element ' + i + ". Make sure that all elements are numbers.");
- }) : ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a array of numbers.')), s;
- };
- }
- O.getNumberArrayValidator = Eh;
- function Fh() {
- if (Kt.Konva.isUnminified)
- return function(s, t) {
- var e = s === !0 || s === !1;
- return e || ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a boolean.'), s;
- };
- }
- O.getBooleanValidator = Fh;
- function kh(s) {
- if (Kt.Konva.isUnminified)
- return function(t, e) {
- return t == null || ht.Util.isObject(t) || ht.Util.warn(Zt(t) + ' is a not valid value for "' + e + '" attribute. The value should be an object with properties ' + s), t;
- };
- }
- O.getComponentValidator = kh;
- (function(s) {
- Object.defineProperty(s, "__esModule", { value: !0 }), s.Factory = void 0;
- const t = st, e = O;
- var i = "get", n = "set";
- s.Factory = {
- addGetterSetter(r, a, o, h, l) {
- s.Factory.addGetter(r, a, o), s.Factory.addSetter(r, a, h, l), s.Factory.addOverloadedGetterSetter(r, a);
- },
- addGetter(r, a, o) {
- var h = i + t.Util._capitalize(a);
- r.prototype[h] = r.prototype[h] || function() {
- var l = this.attrs[a];
- return l === void 0 ? o : l;
- };
- },
- addSetter(r, a, o, h) {
- var l = n + t.Util._capitalize(a);
- r.prototype[l] || s.Factory.overWriteSetter(r, a, o, h);
- },
- overWriteSetter(r, a, o, h) {
- var l = n + t.Util._capitalize(a);
- r.prototype[l] = function(A) {
- return o && A !== void 0 && A !== null && (A = o.call(this, A, a)), this._setAttr(a, A), h && h.call(this), this;
- };
- },
- addComponentsGetterSetter(r, a, o, h, l) {
- var A = o.length, u = t.Util._capitalize, f = i + u(a), c = n + u(a), d, p;
- r.prototype[f] = function() {
- var v = {};
- for (d = 0; d < A; d++)
- p = o[d], v[p] = this.getAttr(a + u(p));
- return v;
- };
- var m = (0, e.getComponentValidator)(o);
- r.prototype[c] = function(v) {
- var _ = this.attrs[a], g;
- h && (v = h.call(this, v)), m && m.call(this, v, a);
- for (g in v)
- v.hasOwnProperty(g) && this._setAttr(a + u(g), v[g]);
- return v || o.forEach((y) => {
- this._setAttr(a + u(y), void 0);
- }), this._fireChangeEvent(a, _, v), l && l.call(this), this;
- }, s.Factory.addOverloadedGetterSetter(r, a);
- },
- addOverloadedGetterSetter(r, a) {
- var o = t.Util._capitalize(a), h = n + o, l = i + o;
- r.prototype[a] = function() {
- return arguments.length ? (this[h](arguments[0]), this) : this[l]();
- };
- },
- addDeprecatedGetterSetter(r, a, o, h) {
- t.Util.error("Adding deprecated " + a);
- var l = i + t.Util._capitalize(a), A = a + " property is deprecated and will be removed soon. Look at Konva change log for more information.";
- r.prototype[l] = function() {
- t.Util.error(A);
- var u = this.attrs[a];
- return u === void 0 ? o : u;
- }, s.Factory.addSetter(r, a, h, function() {
- t.Util.error(A);
- }), s.Factory.addOverloadedGetterSetter(r, a);
- },
- backCompat(r, a) {
- t.Util.each(a, function(o, h) {
- var l = r.prototype[h], A = i + t.Util._capitalize(o), u = n + t.Util._capitalize(o);
- function f() {
- l.apply(this, arguments), t.Util.error('"' + o + '" method is deprecated and will be removed soon. Use ""' + h + '" instead.');
- }
- r.prototype[o] = f, r.prototype[A] = f, r.prototype[u] = f;
- });
- },
- afterSetFilter() {
- this._filterUpToDate = !1;
- }
- };
- })(V);
- var ft = {}, rt = {}, It = {}, Xt = {};
- Object.defineProperty(Xt, "__esModule", { value: !0 });
- Xt.HitContext = Xt.SceneContext = Xt.Context = void 0;
- const Ka = st, Dh = $;
- function Ih(s) {
- var t = [], e = s.length, i = Ka.Util, n, r;
- for (n = 0; n < e; n++)
- r = s[n], i._isNumber(r) ? r = Math.round(r * 1e3) / 1e3 : i._isString(r) || (r = r + ""), t.push(r);
- return t;
- }
- var Nr = ",", Th = "(", Lh = ")", Rh = "([", Oh = "])", Nh = ";", Gh = "()", Bh = "=", Gr = [
- "arc",
- "arcTo",
- "beginPath",
- "bezierCurveTo",
- "clearRect",
- "clip",
- "closePath",
- "createLinearGradient",
- "createPattern",
- "createRadialGradient",
- "drawImage",
- "ellipse",
- "fill",
- "fillText",
- "getImageData",
- "createImageData",
- "lineTo",
- "moveTo",
- "putImageData",
- "quadraticCurveTo",
- "rect",
- "roundRect",
- "restore",
- "rotate",
- "save",
- "scale",
- "setLineDash",
- "setTransform",
- "stroke",
- "strokeText",
- "transform",
- "translate"
- ], zh = [
- "fillStyle",
- "strokeStyle",
- "shadowColor",
- "shadowBlur",
- "shadowOffsetX",
- "shadowOffsetY",
- "letterSpacing",
- "lineCap",
- "lineDashOffset",
- "lineJoin",
- "lineWidth",
- "miterLimit",
- "direction",
- "font",
- "textAlign",
- "textBaseline",
- "globalAlpha",
- "globalCompositeOperation",
- "imageSmoothingEnabled"
- ];
- const Uh = 100;
- class Mn {
- constructor(t) {
- this.canvas = t, Dh.Konva.enableTrace && (this.traceArr = [], this._enableTrace());
- }
- fillShape(t) {
- t.fillEnabled() && this._fill(t);
- }
- _fill(t) {
- }
- strokeShape(t) {
- t.hasStroke() && this._stroke(t);
- }
- _stroke(t) {
- }
- fillStrokeShape(t) {
- t.attrs.fillAfterStrokeEnabled ? (this.strokeShape(t), this.fillShape(t)) : (this.fillShape(t), this.strokeShape(t));
- }
- getTrace(t, e) {
- var i = this.traceArr, n = i.length, r = "", a, o, h, l;
- for (a = 0; a < n; a++)
- o = i[a], h = o.method, h ? (l = o.args, r += h, t ? r += Gh : Ka.Util._isArray(l[0]) ? r += Rh + l.join(Nr) + Oh : (e && (l = l.map((A) => typeof A == "number" ? Math.floor(A) : A)), r += Th + l.join(Nr) + Lh)) : (r += o.property, t || (r += Bh + o.val)), r += Nh;
- return r;
- }
- clearTrace() {
- this.traceArr = [];
- }
- _trace(t) {
- var e = this.traceArr, i;
- e.push(t), i = e.length, i >= Uh && e.shift();
- }
- reset() {
- var t = this.getCanvas().getPixelRatio();
- this.setTransform(1 * t, 0, 0, 1 * t, 0, 0);
- }
- getCanvas() {
- return this.canvas;
- }
- clear(t) {
- var e = this.getCanvas();
- t ? this.clearRect(t.x || 0, t.y || 0, t.width || 0, t.height || 0) : this.clearRect(0, 0, e.getWidth() / e.pixelRatio, e.getHeight() / e.pixelRatio);
- }
- _applyLineCap(t) {
- const e = t.attrs.lineCap;
- e && this.setAttr("lineCap", e);
- }
- _applyOpacity(t) {
- var e = t.getAbsoluteOpacity();
- e !== 1 && this.setAttr("globalAlpha", e);
- }
- _applyLineJoin(t) {
- const e = t.attrs.lineJoin;
- e && this.setAttr("lineJoin", e);
- }
- setAttr(t, e) {
- this._context[t] = e;
- }
- arc(t, e, i, n, r, a) {
- this._context.arc(t, e, i, n, r, a);
- }
- arcTo(t, e, i, n, r) {
- this._context.arcTo(t, e, i, n, r);
- }
- beginPath() {
- this._context.beginPath();
- }
- bezierCurveTo(t, e, i, n, r, a) {
- this._context.bezierCurveTo(t, e, i, n, r, a);
- }
- clearRect(t, e, i, n) {
- this._context.clearRect(t, e, i, n);
- }
- clip(...t) {
- this._context.clip.apply(this._context, t);
- }
- closePath() {
- this._context.closePath();
- }
- createImageData(t, e) {
- var i = arguments;
- if (i.length === 2)
- return this._context.createImageData(t, e);
- if (i.length === 1)
- return this._context.createImageData(t);
- }
- createLinearGradient(t, e, i, n) {
- return this._context.createLinearGradient(t, e, i, n);
- }
- createPattern(t, e) {
- return this._context.createPattern(t, e);
- }
- createRadialGradient(t, e, i, n, r, a) {
- return this._context.createRadialGradient(t, e, i, n, r, a);
- }
- drawImage(t, e, i, n, r, a, o, h, l) {
- var A = arguments, u = this._context;
- A.length === 3 ? u.drawImage(t, e, i) : A.length === 5 ? u.drawImage(t, e, i, n, r) : A.length === 9 && u.drawImage(t, e, i, n, r, a, o, h, l);
- }
- ellipse(t, e, i, n, r, a, o, h) {
- this._context.ellipse(t, e, i, n, r, a, o, h);
- }
- isPointInPath(t, e, i, n) {
- return i ? this._context.isPointInPath(i, t, e, n) : this._context.isPointInPath(t, e, n);
- }
- fill(...t) {
- this._context.fill.apply(this._context, t);
- }
- fillRect(t, e, i, n) {
- this._context.fillRect(t, e, i, n);
- }
- strokeRect(t, e, i, n) {
- this._context.strokeRect(t, e, i, n);
- }
- fillText(t, e, i, n) {
- n ? this._context.fillText(t, e, i, n) : this._context.fillText(t, e, i);
- }
- measureText(t) {
- return this._context.measureText(t);
- }
- getImageData(t, e, i, n) {
- return this._context.getImageData(t, e, i, n);
- }
- lineTo(t, e) {
- this._context.lineTo(t, e);
- }
- moveTo(t, e) {
- this._context.moveTo(t, e);
- }
- rect(t, e, i, n) {
- this._context.rect(t, e, i, n);
- }
- roundRect(t, e, i, n, r) {
- this._context.roundRect(t, e, i, n, r);
- }
- putImageData(t, e, i) {
- this._context.putImageData(t, e, i);
- }
- quadraticCurveTo(t, e, i, n) {
- this._context.quadraticCurveTo(t, e, i, n);
- }
- restore() {
- this._context.restore();
- }
- rotate(t) {
- this._context.rotate(t);
- }
- save() {
- this._context.save();
- }
- scale(t, e) {
- this._context.scale(t, e);
- }
- setLineDash(t) {
- this._context.setLineDash ? this._context.setLineDash(t) : "mozDash" in this._context ? this._context.mozDash = t : "webkitLineDash" in this._context && (this._context.webkitLineDash = t);
- }
- getLineDash() {
- return this._context.getLineDash();
- }
- setTransform(t, e, i, n, r, a) {
- this._context.setTransform(t, e, i, n, r, a);
- }
- stroke(t) {
- t ? this._context.stroke(t) : this._context.stroke();
- }
- strokeText(t, e, i, n) {
- this._context.strokeText(t, e, i, n);
- }
- transform(t, e, i, n, r, a) {
- this._context.transform(t, e, i, n, r, a);
- }
- translate(t, e) {
- this._context.translate(t, e);
- }
- _enableTrace() {
- var t = this, e = Gr.length, i = this.setAttr, n, r, a = function(o) {
- var h = t[o], l;
- t[o] = function() {
- return r = Ih(Array.prototype.slice.call(arguments, 0)), l = h.apply(t, arguments), t._trace({
- method: o,
- args: r
- }), l;
- };
- };
- for (n = 0; n < e; n++)
- a(Gr[n]);
- t.setAttr = function() {
- i.apply(t, arguments);
- var o = arguments[0], h = arguments[1];
- (o === "shadowOffsetX" || o === "shadowOffsetY" || o === "shadowBlur") && (h = h / this.canvas.getPixelRatio()), t._trace({
- property: o,
- val: h
- });
- };
- }
- _applyGlobalCompositeOperation(t) {
- const e = t.attrs.globalCompositeOperation;
- var i = !e || e === "source-over";
- i || this.setAttr("globalCompositeOperation", e);
- }
- }
- Xt.Context = Mn;
- zh.forEach(function(s) {
- Object.defineProperty(Mn.prototype, s, {
- get() {
- return this._context[s];
- },
- set(t) {
- this._context[s] = t;
- }
- });
- });
- class Hh extends Mn {
- constructor(t, { willReadFrequently: e = !1 } = {}) {
- super(t), this._context = t._canvas.getContext("2d", {
- willReadFrequently: e
- });
- }
- _fillColor(t) {
- var e = t.fill();
- this.setAttr("fillStyle", e), t._fillFunc(this);
- }
- _fillPattern(t) {
- this.setAttr("fillStyle", t._getFillPattern()), t._fillFunc(this);
- }
- _fillLinearGradient(t) {
- var e = t._getLinearGradient();
- e && (this.setAttr("fillStyle", e), t._fillFunc(this));
- }
- _fillRadialGradient(t) {
- const e = t._getRadialGradient();
- e && (this.setAttr("fillStyle", e), t._fillFunc(this));
- }
- _fill(t) {
- const e = t.fill(), i = t.getFillPriority();
- if (e && i === "color") {
- this._fillColor(t);
- return;
- }
- const n = t.getFillPatternImage();
- if (n && i === "pattern") {
- this._fillPattern(t);
- return;
- }
- const r = t.getFillLinearGradientColorStops();
- if (r && i === "linear-gradient") {
- this._fillLinearGradient(t);
- return;
- }
- const a = t.getFillRadialGradientColorStops();
- if (a && i === "radial-gradient") {
- this._fillRadialGradient(t);
- return;
- }
- e ? this._fillColor(t) : n ? this._fillPattern(t) : r ? this._fillLinearGradient(t) : a && this._fillRadialGradient(t);
- }
- _strokeLinearGradient(t) {
- const e = t.getStrokeLinearGradientStartPoint(), i = t.getStrokeLinearGradientEndPoint(), n = t.getStrokeLinearGradientColorStops(), r = this.createLinearGradient(e.x, e.y, i.x, i.y);
- if (n) {
- for (var a = 0; a < n.length; a += 2)
- r.addColorStop(n[a], n[a + 1]);
- this.setAttr("strokeStyle", r);
- }
- }
- _stroke(t) {
- var e = t.dash(), i = t.getStrokeScaleEnabled();
- if (t.hasStroke()) {
- if (!i) {
- this.save();
- var n = this.getCanvas().getPixelRatio();
- this.setTransform(n, 0, 0, n, 0, 0);
- }
- this._applyLineCap(t), e && t.dashEnabled() && (this.setLineDash(e), this.setAttr("lineDashOffset", t.dashOffset())), this.setAttr("lineWidth", t.strokeWidth()), t.getShadowForStrokeEnabled() || this.setAttr("shadowColor", "rgba(0,0,0,0)");
- var r = t.getStrokeLinearGradientColorStops();
- r ? this._strokeLinearGradient(t) : this.setAttr("strokeStyle", t.stroke()), t._strokeFunc(this), i || this.restore();
- }
- }
- _applyShadow(t) {
- var e, i, n, r = (e = t.getShadowRGBA()) !== null && e !== void 0 ? e : "black", a = (i = t.getShadowBlur()) !== null && i !== void 0 ? i : 5, o = (n = t.getShadowOffset()) !== null && n !== void 0 ? n : {
- x: 0,
- y: 0
- }, h = t.getAbsoluteScale(), l = this.canvas.getPixelRatio(), A = h.x * l, u = h.y * l;
- this.setAttr("shadowColor", r), this.setAttr("shadowBlur", a * Math.min(Math.abs(A), Math.abs(u))), this.setAttr("shadowOffsetX", o.x * A), this.setAttr("shadowOffsetY", o.y * u);
- }
- }
- Xt.SceneContext = Hh;
- class Vh extends Mn {
- constructor(t) {
- super(t), this._context = t._canvas.getContext("2d", {
- willReadFrequently: !0
- });
- }
- _fill(t) {
- this.save(), this.setAttr("fillStyle", t.colorKey), t._fillFuncHit(this), this.restore();
- }
- strokeShape(t) {
- t.hasHitStroke() && this._stroke(t);
- }
- _stroke(t) {
- if (t.hasHitStroke()) {
- const r = t.getStrokeScaleEnabled();
- if (!r) {
- this.save();
- var e = this.getCanvas().getPixelRatio();
- this.setTransform(e, 0, 0, e, 0, 0);
- }
- this._applyLineCap(t);
- var i = t.hitStrokeWidth(), n = i === "auto" ? t.strokeWidth() : i;
- this.setAttr("lineWidth", n), this.setAttr("strokeStyle", t.colorKey), t._strokeFuncHit(this), r || this.restore();
- }
- }
- }
- Xt.HitContext = Vh;
- Object.defineProperty(It, "__esModule", { value: !0 });
- It.HitCanvas = It.SceneCanvas = It.Canvas = void 0;
- const on = st, Za = Xt, Ja = $, $h = V, Wh = O;
- var $i;
- function Yh() {
- if ($i)
- return $i;
- var s = on.Util.createCanvasElement(), t = s.getContext("2d");
- return $i = function() {
- var e = Ja.Konva._global.devicePixelRatio || 1, i = t.webkitBackingStorePixelRatio || t.mozBackingStorePixelRatio || t.msBackingStorePixelRatio || t.oBackingStorePixelRatio || t.backingStorePixelRatio || 1;
- return e / i;
- }(), on.Util.releaseCanvas(s), $i;
- }
- class Pn {
- constructor(t) {
- this.pixelRatio = 1, this.width = 0, this.height = 0, this.isCache = !1;
- var e = t || {}, i = e.pixelRatio || Ja.Konva.pixelRatio || Yh();
- this.pixelRatio = i, this._canvas = on.Util.createCanvasElement(), this._canvas.style.padding = "0", this._canvas.style.margin = "0", this._canvas.style.border = "0", this._canvas.style.background = "transparent", this._canvas.style.position = "absolute", this._canvas.style.top = "0", this._canvas.style.left = "0";
- }
- getContext() {
- return this.context;
- }
- getPixelRatio() {
- return this.pixelRatio;
- }
- setPixelRatio(t) {
- var e = this.pixelRatio;
- this.pixelRatio = t, this.setSize(this.getWidth() / e, this.getHeight() / e);
- }
- setWidth(t) {
- this.width = this._canvas.width = t * this.pixelRatio, this._canvas.style.width = t + "px";
- var e = this.pixelRatio, i = this.getContext()._context;
- i.scale(e, e);
- }
- setHeight(t) {
- this.height = this._canvas.height = t * this.pixelRatio, this._canvas.style.height = t + "px";
- var e = this.pixelRatio, i = this.getContext()._context;
- i.scale(e, e);
- }
- getWidth() {
- return this.width;
- }
- getHeight() {
- return this.height;
- }
- setSize(t, e) {
- this.setWidth(t || 0), this.setHeight(e || 0);
- }
- toDataURL(t, e) {
- try {
- return this._canvas.toDataURL(t, e);
- } catch {
- try {
- return this._canvas.toDataURL();
- } catch (n) {
- return on.Util.error("Unable to get data URL. " + n.message + " For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."), "";
- }
- }
- }
- }
- It.Canvas = Pn;
- $h.Factory.addGetterSetter(Pn, "pixelRatio", void 0, (0, Wh.getNumberValidator)());
- class Xh extends Pn {
- constructor(t = { width: 0, height: 0, willReadFrequently: !1 }) {
- super(t), this.context = new Za.SceneContext(this, {
- willReadFrequently: t.willReadFrequently
- }), this.setSize(t.width, t.height);
- }
- }
- It.SceneCanvas = Xh;
- class jh extends Pn {
- constructor(t = { width: 0, height: 0 }) {
- super(t), this.hitCanvas = !0, this.context = new Za.HitContext(this), this.setSize(t.width, t.height);
- }
- }
- It.HitCanvas = jh;
- var En = {};
- (function(s) {
- Object.defineProperty(s, "__esModule", { value: !0 }), s.DD = void 0;
- const t = $, e = st;
- s.DD = {
- get isDragging() {
- var i = !1;
- return s.DD._dragElements.forEach((n) => {
- n.dragStatus === "dragging" && (i = !0);
- }), i;
- },
- justDragged: !1,
- get node() {
- var i;
- return s.DD._dragElements.forEach((n) => {
- i = n.node;
- }), i;
- },
- _dragElements: /* @__PURE__ */ new Map(),
- _drag(i) {
- const n = [];
- s.DD._dragElements.forEach((r, a) => {
- const { node: o } = r, h = o.getStage();
- h.setPointersPositions(i), r.pointerId === void 0 && (r.pointerId = e.Util._getFirstPointerId(i));
- const l = h._changedPointerPositions.find((f) => f.id === r.pointerId);
- if (l) {
- if (r.dragStatus !== "dragging") {
- var A = o.dragDistance(), u = Math.max(Math.abs(l.x - r.startPointerPos.x), Math.abs(l.y - r.startPointerPos.y));
- if (u < A || (o.startDrag({ evt: i }), !o.isDragging()))
- return;
- }
- o._setDragPosition(i, r), n.push(o);
- }
- }), n.forEach((r) => {
- r.fire("dragmove", {
- type: "dragmove",
- target: r,
- evt: i
- }, !0);
- });
- },
- _endDragBefore(i) {
- const n = [];
- s.DD._dragElements.forEach((r) => {
- const { node: a } = r, o = a.getStage();
- if (i && o.setPointersPositions(i), !o._changedPointerPositions.find((A) => A.id === r.pointerId))
- return;
- (r.dragStatus === "dragging" || r.dragStatus === "stopped") && (s.DD.justDragged = !0, t.Konva._mouseListenClick = !1, t.Konva._touchListenClick = !1, t.Konva._pointerListenClick = !1, r.dragStatus = "stopped");
- const l = r.node.getLayer() || r.node instanceof t.Konva.Stage && r.node;
- l && n.indexOf(l) === -1 && n.push(l);
- }), n.forEach((r) => {
- r.draw();
- });
- },
- _endDragAfter(i) {
- s.DD._dragElements.forEach((n, r) => {
- n.dragStatus === "stopped" && n.node.fire("dragend", {
- type: "dragend",
- target: n.node,
- evt: i
- }, !0), n.dragStatus !== "dragging" && s.DD._dragElements.delete(r);
- });
- }
- }, t.Konva.isBrowser && (window.addEventListener("mouseup", s.DD._endDragBefore, !0), window.addEventListener("touchend", s.DD._endDragBefore, !0), window.addEventListener("mousemove", s.DD._drag), window.addEventListener("touchmove", s.DD._drag), window.addEventListener("mouseup", s.DD._endDragAfter, !1), window.addEventListener("touchend", s.DD._endDragAfter, !1));
- })(En);
- Object.defineProperty(rt, "__esModule", { value: !0 });
- rt.Node = void 0;
- const W = st, Oi = V, mi = It, se = $, Ct = En, ct = O;
- var rn = "absoluteOpacity", Wi = "allEventListeners", Wt = "absoluteTransform", Br = "absoluteScale", _e = "canvas", qh = "Change", Qh = "children", Kh = "konva", Ys = "listening", zr = "mouseenter", Ur = "mouseleave", Hr = "set", Vr = "Shape", an = " ", $r = "stage", he = "transform", Zh = "Stage", Xs = "visible", Jh = [
- "xChange.konva",
- "yChange.konva",
- "scaleXChange.konva",
- "scaleYChange.konva",
- "skewXChange.konva",
- "skewYChange.konva",
- "rotationChange.konva",
- "offsetXChange.konva",
- "offsetYChange.konva",
- "transformsEnabledChange.konva"
- ].join(an);
- let tl = 1, U = class js {
- constructor(t) {
- this._id = tl++, this.eventListeners = {}, this.attrs = {}, this.index = 0, this._allEventListeners = null, this.parent = null, this._cache = /* @__PURE__ */ new Map(), this._attachedDepsListeners = /* @__PURE__ */ new Map(), this._lastPos = null, this._batchingTransformChange = !1, this._needClearTransformCache = !1, this._filterUpToDate = !1, this._isUnderCache = !1, this._dragEventId = null, this._shouldFireChangeEvents = !1, this.setAttrs(t), this._shouldFireChangeEvents = !0;
- }
- hasChildren() {
- return !1;
- }
- _clearCache(t) {
- (t === he || t === Wt) && this._cache.get(t) ? this._cache.get(t).dirty = !0 : t ? this._cache.delete(t) : this._cache.clear();
- }
- _getCache(t, e) {
- var i = this._cache.get(t), n = t === he || t === Wt, r = i === void 0 || n && i.dirty === !0;
- return r && (i = e.call(this), this._cache.set(t, i)), i;
- }
- _calculate(t, e, i) {
- if (!this._attachedDepsListeners.get(t)) {
- const n = e.map((r) => r + "Change.konva").join(an);
- this.on(n, () => {
- this._clearCache(t);
- }), this._attachedDepsListeners.set(t, !0);
- }
- return this._getCache(t, i);
- }
- _getCanvasCache() {
- return this._cache.get(_e);
- }
- _clearSelfAndDescendantCache(t) {
- this._clearCache(t), t === Wt && this.fire("absoluteTransformChange");
- }
- clearCache() {
- if (this._cache.has(_e)) {
- const { scene: t, filter: e, hit: i } = this._cache.get(_e);
- W.Util.releaseCanvas(t, e, i), this._cache.delete(_e);
- }
- return this._clearSelfAndDescendantCache(), this._requestDraw(), this;
- }
- cache(t) {
- var e = t || {}, i = {};
- (e.x === void 0 || e.y === void 0 || e.width === void 0 || e.height === void 0) && (i = this.getClientRect({
- skipTransform: !0,
- relativeTo: this.getParent() || void 0
- }));
- var n = Math.ceil(e.width || i.width), r = Math.ceil(e.height || i.height), a = e.pixelRatio, o = e.x === void 0 ? Math.floor(i.x) : e.x, h = e.y === void 0 ? Math.floor(i.y) : e.y, l = e.offset || 0, A = e.drawBorder || !1, u = e.hitCanvasPixelRatio || 1;
- if (!n || !r) {
- W.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");
- return;
- }
- const f = Math.abs(Math.round(i.x) - o) > 0.5 ? 1 : 0, c = Math.abs(Math.round(i.y) - h) > 0.5 ? 1 : 0;
- n += l * 2 + f, r += l * 2 + c, o -= l, h -= l;
- var d = new mi.SceneCanvas({
- pixelRatio: a,
- width: n,
- height: r
- }), p = new mi.SceneCanvas({
- pixelRatio: a,
- width: 0,
- height: 0,
- willReadFrequently: !0
- }), m = new mi.HitCanvas({
- pixelRatio: u,
- width: n,
- height: r
- }), v = d.getContext(), _ = m.getContext();
- return m.isCache = !0, d.isCache = !0, this._cache.delete(_e), this._filterUpToDate = !1, e.imageSmoothingEnabled === !1 && (d.getContext()._context.imageSmoothingEnabled = !1, p.getContext()._context.imageSmoothingEnabled = !1), v.save(), _.save(), v.translate(-o, -h), _.translate(-o, -h), this._isUnderCache = !0, this._clearSelfAndDescendantCache(rn), this._clearSelfAndDescendantCache(Br), this.drawScene(d, this), this.drawHit(m, this), this._isUnderCache = !1, v.restore(), _.restore(), A && (v.save(), v.beginPath(), v.rect(0, 0, n, r), v.closePath(), v.setAttr("strokeStyle", "red"), v.setAttr("lineWidth", 5), v.stroke(), v.restore()), this._cache.set(_e, {
- scene: d,
- filter: p,
- hit: m,
- x: o,
- y: h
- }), this._requestDraw(), this;
- }
- isCached() {
- return this._cache.has(_e);
- }
- getClientRect(t) {
- throw new Error('abstract "getClientRect" method call');
- }
- _transformedRect(t, e) {
- var i = [
- { x: t.x, y: t.y },
- { x: t.x + t.width, y: t.y },
- { x: t.x + t.width, y: t.y + t.height },
- { x: t.x, y: t.y + t.height }
- ], n = 1 / 0, r = 1 / 0, a = -1 / 0, o = -1 / 0, h = this.getAbsoluteTransform(e);
- return i.forEach(function(l) {
- var A = h.point(l);
- n === void 0 && (n = a = A.x, r = o = A.y), n = Math.min(n, A.x), r = Math.min(r, A.y), a = Math.max(a, A.x), o = Math.max(o, A.y);
- }), {
- x: n,
- y: r,
- width: a - n,
- height: o - r
- };
- }
- _drawCachedSceneCanvas(t) {
- t.save(), t._applyOpacity(this), t._applyGlobalCompositeOperation(this);
- const e = this._getCanvasCache();
- t.translate(e.x, e.y);
- var i = this._getCachedSceneCanvas(), n = i.pixelRatio;
- t.drawImage(i._canvas, 0, 0, i.width / n, i.height / n), t.restore();
- }
- _drawCachedHitCanvas(t) {
- var e = this._getCanvasCache(), i = e.hit;
- t.save(), t.translate(e.x, e.y), t.drawImage(i._canvas, 0, 0, i.width / i.pixelRatio, i.height / i.pixelRatio), t.restore();
- }
- _getCachedSceneCanvas() {
- var t = this.filters(), e = this._getCanvasCache(), i = e.scene, n = e.filter, r = n.getContext(), a, o, h, l;
- if (t) {
- if (!this._filterUpToDate) {
- var A = i.pixelRatio;
- n.setSize(i.width / i.pixelRatio, i.height / i.pixelRatio);
- try {
- for (a = t.length, r.clear(), r.drawImage(i._canvas, 0, 0, i.getWidth() / A, i.getHeight() / A), o = r.getImageData(0, 0, n.getWidth(), n.getHeight()), h = 0; h < a; h++) {
- if (l = t[h], typeof l != "function") {
- W.Util.error("Filter should be type of function, but got " + typeof l + " instead. Please check correct filters");
- continue;
- }
- l.call(this, o), r.putImageData(o, 0, 0);
- }
- } catch (u) {
- W.Util.error("Unable to apply filter. " + u.message + " This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.");
- }
- this._filterUpToDate = !0;
- }
- return n;
- }
- return i;
- }
- on(t, e) {
- if (this._cache && this._cache.delete(Wi), arguments.length === 3)
- return this._delegate.apply(this, arguments);
- var i = t.split(an), n = i.length, r, a, o, h, l;
- for (r = 0; r < n; r++)
- a = i[r], o = a.split("."), h = o[0], l = o[1] || "", this.eventListeners[h] || (this.eventListeners[h] = []), this.eventListeners[h].push({
- name: l,
- handler: e
- });
- return this;
- }
- off(t, e) {
- var i = (t || "").split(an), n = i.length, r, a, o, h, l, A;
- if (this._cache && this._cache.delete(Wi), !t)
- for (a in this.eventListeners)
- this._off(a);
- for (r = 0; r < n; r++)
- if (o = i[r], h = o.split("."), l = h[0], A = h[1], l)
- this.eventListeners[l] && this._off(l, A, e);
- else
- for (a in this.eventListeners)
- this._off(a, A, e);
- return this;
- }
- dispatchEvent(t) {
- var e = {
- target: this,
- type: t.type,
- evt: t
- };
- return this.fire(t.type, e), this;
- }
- addEventListener(t, e) {
- return this.on(t, function(i) {
- e.call(this, i.evt);
- }), this;
- }
- removeEventListener(t) {
- return this.off(t), this;
- }
- _delegate(t, e, i) {
- var n = this;
- this.on(t, function(r) {
- for (var a = r.target.findAncestors(e, !0, n), o = 0; o < a.length; o++)
- r = W.Util.cloneObject(r), r.currentTarget = a[o], i.call(a[o], r);
- });
- }
- remove() {
- return this.isDragging() && this.stopDrag(), Ct.DD._dragElements.delete(this._id), this._remove(), this;
- }
- _clearCaches() {
- this._clearSelfAndDescendantCache(Wt), this._clearSelfAndDescendantCache(rn), this._clearSelfAndDescendantCache(Br), this._clearSelfAndDescendantCache($r), this._clearSelfAndDescendantCache(Xs), this._clearSelfAndDescendantCache(Ys);
- }
- _remove() {
- this._clearCaches();
- var t = this.getParent();
- t && t.children && (t.children.splice(this.index, 1), t._setChildrenIndices(), this.parent = null);
- }
- destroy() {
- return this.remove(), this.clearCache(), this;
- }
- getAttr(t) {
- var e = "get" + W.Util._capitalize(t);
- return W.Util._isFunction(this[e]) ? this[e]() : this.attrs[t];
- }
- getAncestors() {
- for (var t = this.getParent(), e = []; t; )
- e.push(t), t = t.getParent();
- return e;
- }
- getAttrs() {
- return this.attrs || {};
- }
- setAttrs(t) {
- return this._batchTransformChanges(() => {
- var e, i;
- if (!t)
- return this;
- for (e in t)
- e !== Qh && (i = Hr + W.Util._capitalize(e), W.Util._isFunction(this[i]) ? this[i](t[e]) : this._setAttr(e, t[e]));
- }), this;
- }
- isListening() {
- return this._getCache(Ys, this._isListening);
- }
- _isListening(t) {
- if (!this.listening())
- return !1;
- const i = this.getParent();
- return i && i !== t && this !== t ? i._isListening(t) : !0;
- }
- isVisible() {
- return this._getCache(Xs, this._isVisible);
- }
- _isVisible(t) {
- if (!this.visible())
- return !1;
- const i = this.getParent();
- return i && i !== t && this !== t ? i._isVisible(t) : !0;
- }
- shouldDrawHit(t, e = !1) {
- if (t)
- return this._isVisible(t) && this._isListening(t);
- var i = this.getLayer(), n = !1;
- Ct.DD._dragElements.forEach((a) => {
- a.dragStatus === "dragging" && (a.node.nodeType === "Stage" || a.node.getLayer() === i) && (n = !0);
- });
- var r = !e && !se.Konva.hitOnDragEnabled && (n || se.Konva.isTransforming());
- return this.isListening() && this.isVisible() && !r;
- }
- show() {
- return this.visible(!0), this;
- }
- hide() {
- return this.visible(!1), this;
- }
- getZIndex() {
- return this.index || 0;
- }
- getAbsoluteZIndex() {
- var t = this.getDepth(), e = this, i = 0, n, r, a, o;
- function h(A) {
- for (n = [], r = A.length, a = 0; a < r; a++)
- o = A[a], i++, o.nodeType !== Vr && (n = n.concat(o.getChildren().slice())), o._id === e._id && (a = r);
- n.length > 0 && n[0].getDepth() <= t && h(n);
- }
- const l = this.getStage();
- return e.nodeType !== Zh && l && h(l.getChildren()), i;
- }
- getDepth() {
- for (var t = 0, e = this.parent; e; )
- t++, e = e.parent;
- return t;
- }
- _batchTransformChanges(t) {
- this._batchingTransformChange = !0, t(), this._batchingTransformChange = !1, this._needClearTransformCache && (this._clearCache(he), this._clearSelfAndDescendantCache(Wt)), this._needClearTransformCache = !1;
- }
- setPosition(t) {
- return this._batchTransformChanges(() => {
- this.x(t.x), this.y(t.y);
- }), this;
- }
- getPosition() {
- return {
- x: this.x(),
- y: this.y()
- };
- }
- getRelativePointerPosition() {
- const t = this.getStage();
- if (!t)
- return null;
- var e = t.getPointerPosition();
- if (!e)
- return null;
- var i = this.getAbsoluteTransform().copy();
- return i.invert(), i.point(e);
- }
- getAbsolutePosition(t) {
- let e = !1, i = this.parent;
- for (; i; ) {
- if (i.isCached()) {
- e = !0;
- break;
- }
- i = i.parent;
- }
- e && !t && (t = !0);
- var n = this.getAbsoluteTransform(t).getMatrix(), r = new W.Transform(), a = this.offset();
- return r.m = n.slice(), r.translate(a.x, a.y), r.getTranslation();
- }
- setAbsolutePosition(t) {
- const { x: e, y: i, ...n } = this._clearTransform();
- this.attrs.x = e, this.attrs.y = i, this._clearCache(he);
- var r = this._getAbsoluteTransform().copy();
- return r.invert(), r.translate(t.x, t.y), t = {
- x: this.attrs.x + r.getTranslation().x,
- y: this.attrs.y + r.getTranslation().y
- }, this._setTransform(n), this.setPosition({ x: t.x, y: t.y }), this._clearCache(he), this._clearSelfAndDescendantCache(Wt), this;
- }
- _setTransform(t) {
- var e;
- for (e in t)
- this.attrs[e] = t[e];
- }
- _clearTransform() {
- var t = {
- x: this.x(),
- y: this.y(),
- rotation: this.rotation(),
- scaleX: this.scaleX(),
- scaleY: this.scaleY(),
- offsetX: this.offsetX(),
- offsetY: this.offsetY(),
- skewX: this.skewX(),
- skewY: this.skewY()
- };
- return this.attrs.x = 0, this.attrs.y = 0, this.attrs.rotation = 0, this.attrs.scaleX = 1, this.attrs.scaleY = 1, this.attrs.offsetX = 0, this.attrs.offsetY = 0, this.attrs.skewX = 0, this.attrs.skewY = 0, t;
- }
- move(t) {
- var e = t.x, i = t.y, n = this.x(), r = this.y();
- return e !== void 0 && (n += e), i !== void 0 && (r += i), this.setPosition({ x: n, y: r }), this;
- }
- _eachAncestorReverse(t, e) {
- var i = [], n = this.getParent(), r, a;
- if (!(e && e._id === this._id)) {
- for (i.unshift(this); n && (!e || n._id !== e._id); )
- i.unshift(n), n = n.parent;
- for (r = i.length, a = 0; a < r; a++)
- t(i[a]);
- }
- }
- rotate(t) {
- return this.rotation(this.rotation() + t), this;
- }
- moveToTop() {
- if (!this.parent)
- return W.Util.warn("Node has no parent. moveToTop function is ignored."), !1;
- var t = this.index, e = this.parent.getChildren().length;
- return t < e - 1 ? (this.parent.children.splice(t, 1), this.parent.children.push(this), this.parent._setChildrenIndices(), !0) : !1;
- }
- moveUp() {
- if (!this.parent)
- return W.Util.warn("Node has no parent. moveUp function is ignored."), !1;
- var t = this.index, e = this.parent.getChildren().length;
- return t < e - 1 ? (this.parent.children.splice(t, 1), this.parent.children.splice(t + 1, 0, this), this.parent._setChildrenIndices(), !0) : !1;
- }
- moveDown() {
- if (!this.parent)
- return W.Util.warn("Node has no parent. moveDown function is ignored."), !1;
- var t = this.index;
- return t > 0 ? (this.parent.children.splice(t, 1), this.parent.children.splice(t - 1, 0, this), this.parent._setChildrenIndices(), !0) : !1;
- }
- moveToBottom() {
- if (!this.parent)
- return W.Util.warn("Node has no parent. moveToBottom function is ignored."), !1;
- var t = this.index;
- return t > 0 ? (this.parent.children.splice(t, 1), this.parent.children.unshift(this), this.parent._setChildrenIndices(), !0) : !1;
- }
- setZIndex(t) {
- if (!this.parent)
- return W.Util.warn("Node has no parent. zIndex parameter is ignored."), this;
- (t < 0 || t >= this.parent.children.length) && W.Util.warn("Unexpected value " + t + " for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to " + (this.parent.children.length - 1) + ".");
- var e = this.index;
- return this.parent.children.splice(e, 1), this.parent.children.splice(t, 0, this), this.parent._setChildrenIndices(), this;
- }
- getAbsoluteOpacity() {
- return this._getCache(rn, this._getAbsoluteOpacity);
- }
- _getAbsoluteOpacity() {
- var t = this.opacity(), e = this.getParent();
- return e && !e._isUnderCache && (t *= e.getAbsoluteOpacity()), t;
- }
- moveTo(t) {
- return this.getParent() !== t && (this._remove(), t.add(this)), this;
- }
- toObject() {
- var t = this.getAttrs(), e, i, n, r, a;
- const o = {
- attrs: {},
- className: this.getClassName()
- };
- for (e in t)
- i = t[e], a = W.Util.isObject(i) && !W.Util._isPlainObject(i) && !W.Util._isArray(i), !a && (n = typeof this[e] == "function" && this[e], delete t[e], r = n ? n.call(this) : null, t[e] = i, r !== i && (o.attrs[e] = i));
- return W.Util._prepareToStringify(o);
- }
- toJSON() {
- return JSON.stringify(this.toObject());
- }
- getParent() {
- return this.parent;
- }
- findAncestors(t, e, i) {
- var n = [];
- e && this._isMatch(t) && n.push(this);
- for (var r = this.parent; r; ) {
- if (r === i)
- return n;
- r._isMatch(t) && n.push(r), r = r.parent;
- }
- return n;
- }
- isAncestorOf(t) {
- return !1;
- }
- findAncestor(t, e, i) {
- return this.findAncestors(t, e, i)[0];
- }
- _isMatch(t) {
- if (!t)
- return !1;
- if (typeof t == "function")
- return t(this);
- var e = t.replace(/ /g, "").split(","), i = e.length, n, r;
- for (n = 0; n < i; n++)
- if (r = e[n], W.Util.isValidSelector(r) || (W.Util.warn('Selector "' + r + '" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'), W.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'), W.Util.warn("Konva is awesome, right?")), r.charAt(0) === "#") {
- if (this.id() === r.slice(1))
- return !0;
- } else if (r.charAt(0) === ".") {
- if (this.hasName(r.slice(1)))
- return !0;
- } else if (this.className === r || this.nodeType === r)
- return !0;
- return !1;
- }
- getLayer() {
- var t = this.getParent();
- return t ? t.getLayer() : null;
- }
- getStage() {
- return this._getCache($r, this._getStage);
- }
- _getStage() {
- var t = this.getParent();
- return t ? t.getStage() : null;
- }
- fire(t, e = {}, i) {
- return e.target = e.target || this, i ? this._fireAndBubble(t, e) : this._fire(t, e), this;
- }
- getAbsoluteTransform(t) {
- return t ? this._getAbsoluteTransform(t) : this._getCache(Wt, this._getAbsoluteTransform);
- }
- _getAbsoluteTransform(t) {
- var e;
- if (t)
- return e = new W.Transform(), this._eachAncestorReverse(function(n) {
- var r = n.transformsEnabled();
- r === "all" ? e.multiply(n.getTransform()) : r === "position" && e.translate(n.x() - n.offsetX(), n.y() - n.offsetY());
- }, t), e;
- e = this._cache.get(Wt) || new W.Transform(), this.parent ? this.parent.getAbsoluteTransform().copyInto(e) : e.reset();
- var i = this.transformsEnabled();
- if (i === "all")
- e.multiply(this.getTransform());
- else if (i === "position") {
- const n = this.attrs.x || 0, r = this.attrs.y || 0, a = this.attrs.offsetX || 0, o = this.attrs.offsetY || 0;
- e.translate(n - a, r - o);
- }
- return e.dirty = !1, e;
- }
- getAbsoluteScale(t) {
- for (var e = this; e; )
- e._isUnderCache && (t = e), e = e.getParent();
- const n = this.getAbsoluteTransform(t).decompose();
- return {
- x: n.scaleX,
- y: n.scaleY
- };
- }
- getAbsoluteRotation() {
- return this.getAbsoluteTransform().decompose().rotation;
- }
- getTransform() {
- return this._getCache(he, this._getTransform);
- }
- _getTransform() {
- var t, e, i = this._cache.get(he) || new W.Transform();
- i.reset();
- var n = this.x(), r = this.y(), a = se.Konva.getAngle(this.rotation()), o = (t = this.attrs.scaleX) !== null && t !== void 0 ? t : 1, h = (e = this.attrs.scaleY) !== null && e !== void 0 ? e : 1, l = this.attrs.skewX || 0, A = this.attrs.skewY || 0, u = this.attrs.offsetX || 0, f = this.attrs.offsetY || 0;
- return (n !== 0 || r !== 0) && i.translate(n, r), a !== 0 && i.rotate(a), (l !== 0 || A !== 0) && i.skew(l, A), (o !== 1 || h !== 1) && i.scale(o, h), (u !== 0 || f !== 0) && i.translate(-1 * u, -1 * f), i.dirty = !1, i;
- }
- clone(t) {
- var e = W.Util.cloneObject(this.attrs), i, n, r, a, o;
- for (i in t)
- e[i] = t[i];
- var h = new this.constructor(e);
- for (i in this.eventListeners)
- for (n = this.eventListeners[i], r = n.length, a = 0; a < r; a++)
- o = n[a], o.name.indexOf(Kh) < 0 && (h.eventListeners[i] || (h.eventListeners[i] = []), h.eventListeners[i].push(o));
- return h;
- }
- _toKonvaCanvas(t) {
- t = t || {};
- var e = this.getClientRect(), i = this.getStage(), n = t.x !== void 0 ? t.x : Math.floor(e.x), r = t.y !== void 0 ? t.y : Math.floor(e.y), a = t.pixelRatio || 1, o = new mi.SceneCanvas({
- width: t.width || Math.ceil(e.width) || (i ? i.width() : 0),
- height: t.height || Math.ceil(e.height) || (i ? i.height() : 0),
- pixelRatio: a
- }), h = o.getContext();
- const l = new mi.SceneCanvas({
- width: o.width / o.pixelRatio + Math.abs(n),
- height: o.height / o.pixelRatio + Math.abs(r),
- pixelRatio: o.pixelRatio
- });
- return t.imageSmoothingEnabled === !1 && (h._context.imageSmoothingEnabled = !1), h.save(), (n || r) && h.translate(-1 * n, -1 * r), this.drawScene(o, void 0, l), h.restore(), o;
- }
- toCanvas(t) {
- return this._toKonvaCanvas(t)._canvas;
- }
- toDataURL(t) {
- t = t || {};
- var e = t.mimeType || null, i = t.quality || null, n = this._toKonvaCanvas(t).toDataURL(e, i);
- return t.callback && t.callback(n), n;
- }
- toImage(t) {
- return new Promise((e, i) => {
- try {
- const n = t == null ? void 0 : t.callback;
- n && delete t.callback, W.Util._urlToImage(this.toDataURL(t), function(r) {
- e(r), n == null || n(r);
- });
- } catch (n) {
- i(n);
- }
- });
- }
- toBlob(t) {
- return new Promise((e, i) => {
- try {
- const n = t == null ? void 0 : t.callback;
- n && delete t.callback, this.toCanvas(t).toBlob((r) => {
- e(r), n == null || n(r);
- }, t == null ? void 0 : t.mimeType, t == null ? void 0 : t.quality);
- } catch (n) {
- i(n);
- }
- });
- }
- setSize(t) {
- return this.width(t.width), this.height(t.height), this;
- }
- getSize() {
- return {
- width: this.width(),
- height: this.height()
- };
- }
- getClassName() {
- return this.className || this.nodeType;
- }
- getType() {
- return this.nodeType;
- }
- getDragDistance() {
- return this.attrs.dragDistance !== void 0 ? this.attrs.dragDistance : this.parent ? this.parent.getDragDistance() : se.Konva.dragDistance;
- }
- _off(t, e, i) {
- var n = this.eventListeners[t], r, a, o;
- for (r = 0; r < n.length; r++)
- if (a = n[r].name, o = n[r].handler, (a !== "konva" || e === "konva") && (!e || a === e) && (!i || i === o)) {
- if (n.splice(r, 1), n.length === 0) {
- delete this.eventListeners[t];
- break;
- }
- r--;
- }
- }
- _fireChangeEvent(t, e, i) {
- this._fire(t + qh, {
- oldVal: e,
- newVal: i
- });
- }
- addName(t) {
- if (!this.hasName(t)) {
- var e = this.name(), i = e ? e + " " + t : t;
- this.name(i);
- }
- return this;
- }
- hasName(t) {
- if (!t)
- return !1;
- const e = this.name();
- if (!e)
- return !1;
- var i = (e || "").split(/\s/g);
- return i.indexOf(t) !== -1;
- }
- removeName(t) {
- var e = (this.name() || "").split(/\s/g), i = e.indexOf(t);
- return i !== -1 && (e.splice(i, 1), this.name(e.join(" "))), this;
- }
- setAttr(t, e) {
- var i = this[Hr + W.Util._capitalize(t)];
- return W.Util._isFunction(i) ? i.call(this, e) : this._setAttr(t, e), this;
- }
- _requestDraw() {
- if (se.Konva.autoDrawEnabled) {
- const t = this.getLayer() || this.getStage();
- t == null || t.batchDraw();
- }
- }
- _setAttr(t, e) {
- var i = this.attrs[t];
- i === e && !W.Util.isObject(e) || (e == null ? delete this.attrs[t] : this.attrs[t] = e, this._shouldFireChangeEvents && this._fireChangeEvent(t, i, e), this._requestDraw());
- }
- _setComponentAttr(t, e, i) {
- var n;
- i !== void 0 && (n = this.attrs[t], n || (this.attrs[t] = this.getAttr(t)), this.attrs[t][e] = i, this._fireChangeEvent(t, n, i));
- }
- _fireAndBubble(t, e, i) {
- e && this.nodeType === Vr && (e.target = this);
- var n = (t === zr || t === Ur) && (i && (this === i || this.isAncestorOf && this.isAncestorOf(i)) || this.nodeType === "Stage" && !i);
- if (!n) {
- this._fire(t, e);
- var r = (t === zr || t === Ur) && i && i.isAncestorOf && i.isAncestorOf(this) && !i.isAncestorOf(this.parent);
- (e && !e.cancelBubble || !e) && this.parent && this.parent.isListening() && !r && (i && i.parent ? this._fireAndBubble.call(this.parent, t, e, i) : this._fireAndBubble.call(this.parent, t, e));
- }
- }
- _getProtoListeners(t) {
- var e, i, n;
- const r = (e = this._cache.get(Wi)) !== null && e !== void 0 ? e : {};
- let a = r == null ? void 0 : r[t];
- if (a === void 0) {
- a = [];
- let o = Object.getPrototypeOf(this);
- for (; o; ) {
- const h = (n = (i = o.eventListeners) === null || i === void 0 ? void 0 : i[t]) !== null && n !== void 0 ? n : [];
- a.push(...h), o = Object.getPrototypeOf(o);
- }
- r[t] = a, this._cache.set(Wi, r);
- }
- return a;
- }
- _fire(t, e) {
- e = e || {}, e.currentTarget = this, e.type = t;
- const i = this._getProtoListeners(t);
- if (i)
- for (var n = 0; n < i.length; n++)
- i[n].handler.call(this, e);
- const r = this.eventListeners[t];
- if (r)
- for (var n = 0; n < r.length; n++)
- r[n].handler.call(this, e);
- }
- draw() {
- return this.drawScene(), this.drawHit(), this;
- }
- _createDragElement(t) {
- var e = t ? t.pointerId : void 0, i = this.getStage(), n = this.getAbsolutePosition();
- if (i) {
- var r = i._getPointerById(e) || i._changedPointerPositions[0] || n;
- Ct.DD._dragElements.set(this._id, {
- node: this,
- startPointerPos: r,
- offset: {
- x: r.x - n.x,
- y: r.y - n.y
- },
- dragStatus: "ready",
- pointerId: e
- });
- }
- }
- startDrag(t, e = !0) {
- Ct.DD._dragElements.has(this._id) || this._createDragElement(t);
- const i = Ct.DD._dragElements.get(this._id);
- i.dragStatus = "dragging", this.fire("dragstart", {
- type: "dragstart",
- target: this,
- evt: t && t.evt
- }, e);
- }
- _setDragPosition(t, e) {
- const i = this.getStage()._getPointerById(e.pointerId);
- if (i) {
- var n = {
- x: i.x - e.offset.x,
- y: i.y - e.offset.y
- }, r = this.dragBoundFunc();
- if (r !== void 0) {
- const a = r.call(this, n, t);
- a ? n = a : W.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.");
- }
- (!this._lastPos || this._lastPos.x !== n.x || this._lastPos.y !== n.y) && (this.setAbsolutePosition(n), this._requestDraw()), this._lastPos = n;
- }
- }
- stopDrag(t) {
- const e = Ct.DD._dragElements.get(this._id);
- e && (e.dragStatus = "stopped"), Ct.DD._endDragBefore(t), Ct.DD._endDragAfter(t);
- }
- setDraggable(t) {
- this._setAttr("draggable", t), this._dragChange();
- }
- isDragging() {
- const t = Ct.DD._dragElements.get(this._id);
- return t ? t.dragStatus === "dragging" : !1;
- }
- _listenDrag() {
- this._dragCleanup(), this.on("mousedown.konva touchstart.konva", function(t) {
- var e = t.evt.button !== void 0, i = !e || se.Konva.dragButtons.indexOf(t.evt.button) >= 0;
- if (i && !this.isDragging()) {
- var n = !1;
- Ct.DD._dragElements.forEach((r) => {
- this.isAncestorOf(r.node) && (n = !0);
- }), n || this._createDragElement(t);
- }
- });
- }
- _dragChange() {
- if (this.attrs.draggable)
- this._listenDrag();
- else {
- this._dragCleanup();
- var t = this.getStage();
- if (!t)
- return;
- const e = Ct.DD._dragElements.get(this._id), i = e && e.dragStatus === "dragging", n = e && e.dragStatus === "ready";
- i ? this.stopDrag() : n && Ct.DD._dragElements.delete(this._id);
- }
- }
- _dragCleanup() {
- this.off("mousedown.konva"), this.off("touchstart.konva");
- }
- isClientRectOnScreen(t = { x: 0, y: 0 }) {
- const e = this.getStage();
- if (!e)
- return !1;
- const i = {
- x: -t.x,
- y: -t.y,
- width: e.width() + 2 * t.x,
- height: e.height() + 2 * t.y
- };
- return W.Util.haveIntersection(i, this.getClientRect());
- }
- static create(t, e) {
- return W.Util._isString(t) && (t = JSON.parse(t)), this._createNode(t, e);
- }
- static _createNode(t, e) {
- var i = js.prototype.getClassName.call(t), n = t.children, r, a, o;
- e && (t.attrs.container = e), se.Konva[i] || (W.Util.warn('Can not find a node with class name "' + i + '". Fallback to "Shape".'), i = "Shape");
- const h = se.Konva[i];
- if (r = new h(t.attrs), n)
- for (a = n.length, o = 0; o < a; o++)
- r.add(js._createNode(n[o]));
- return r;
- }
- };
- rt.Node = U;
- U.prototype.nodeType = "Node";
- U.prototype._attrsAffectingSize = [];
- U.prototype.eventListeners = {};
- U.prototype.on.call(U.prototype, Jh, function() {
- if (this._batchingTransformChange) {
- this._needClearTransformCache = !0;
- return;
- }
- this._clearCache(he), this._clearSelfAndDescendantCache(Wt);
- });
- U.prototype.on.call(U.prototype, "visibleChange.konva", function() {
- this._clearSelfAndDescendantCache(Xs);
- });
- U.prototype.on.call(U.prototype, "listeningChange.konva", function() {
- this._clearSelfAndDescendantCache(Ys);
- });
- U.prototype.on.call(U.prototype, "opacityChange.konva", function() {
- this._clearSelfAndDescendantCache(rn);
- });
- const J = Oi.Factory.addGetterSetter;
- J(U, "zIndex");
- J(U, "absolutePosition");
- J(U, "position");
- J(U, "x", 0, (0, ct.getNumberValidator)());
- J(U, "y", 0, (0, ct.getNumberValidator)());
- J(U, "globalCompositeOperation", "source-over", (0, ct.getStringValidator)());
- J(U, "opacity", 1, (0, ct.getNumberValidator)());
- J(U, "name", "", (0, ct.getStringValidator)());
- J(U, "id", "", (0, ct.getStringValidator)());
- J(U, "rotation", 0, (0, ct.getNumberValidator)());
- Oi.Factory.addComponentsGetterSetter(U, "scale", ["x", "y"]);
- J(U, "scaleX", 1, (0, ct.getNumberValidator)());
- J(U, "scaleY", 1, (0, ct.getNumberValidator)());
- Oi.Factory.addComponentsGetterSetter(U, "skew", ["x", "y"]);
- J(U, "skewX", 0, (0, ct.getNumberValidator)());
- J(U, "skewY", 0, (0, ct.getNumberValidator)());
- Oi.Factory.addComponentsGetterSetter(U, "offset", ["x", "y"]);
- J(U, "offsetX", 0, (0, ct.getNumberValidator)());
- J(U, "offsetY", 0, (0, ct.getNumberValidator)());
- J(U, "dragDistance", null, (0, ct.getNumberValidator)());
- J(U, "width", 0, (0, ct.getNumberValidator)());
- J(U, "height", 0, (0, ct.getNumberValidator)());
- J(U, "listening", !0, (0, ct.getBooleanValidator)());
- J(U, "preventDefault", !0, (0, ct.getBooleanValidator)());
- J(U, "filters", null, function(s) {
- return this._filterUpToDate = !1, s;
- });
- J(U, "visible", !0, (0, ct.getBooleanValidator)());
- J(U, "transformsEnabled", "all", (0, ct.getStringValidator)());
- J(U, "size");
- J(U, "dragBoundFunc");
- J(U, "draggable", !1, (0, ct.getBooleanValidator)());
- Oi.Factory.backCompat(U, {
- rotateDeg: "rotate",
- setRotationDeg: "setRotation",
- getRotationDeg: "getRotation"
- });
- var bt = {};
- Object.defineProperty(bt, "__esModule", { value: !0 });
- bt.releaseCapture = bt.setPointerCapture = bt.hasPointerCapture = bt.createEvent = bt.getCapturedShape = void 0;
- const el = $, Ei = /* @__PURE__ */ new Map(), to = el.Konva._global.PointerEvent !== void 0;
- function il(s) {
- return Ei.get(s);
- }
- bt.getCapturedShape = il;
- function Ar(s) {
- return {
- evt: s,
- pointerId: s.pointerId
- };
- }
- bt.createEvent = Ar;
- function nl(s, t) {
- return Ei.get(s) === t;
- }
- bt.hasPointerCapture = nl;
- function sl(s, t) {
- eo(s), t.getStage() && (Ei.set(s, t), to && t._fire("gotpointercapture", Ar(new PointerEvent("gotpointercapture"))));
- }
- bt.setPointerCapture = sl;
- function eo(s, t) {
- const e = Ei.get(s);
- if (!e)
- return;
- const i = e.getStage();
- i && i.content, Ei.delete(s), to && e._fire("lostpointercapture", Ar(new PointerEvent("lostpointercapture")));
- }
- bt.releaseCapture = eo;
- (function(s) {
- Object.defineProperty(s, "__esModule", { value: !0 }), s.Shape = s.shapes = void 0;
- const t = $, e = st, i = V, n = rt, r = O, a = $, o = bt;
- var h = "hasShadow", l = "shadowRGBA", A = "patternImage", u = "linearGradient", f = "radialGradient";
- let c;
- function d() {
- return c || (c = e.Util.createCanvasElement().getContext("2d"), c);
- }
- s.shapes = {};
- function p(E) {
- const S = this.attrs.fillRule;
- S ? E.fill(S) : E.fill();
- }
- function m(E) {
- E.stroke();
- }
- function v(E) {
- E.fill();
- }
- function _(E) {
- E.stroke();
- }
- function g() {
- this._clearCache(h);
- }
- function y() {
- this._clearCache(l);
- }
- function x() {
- this._clearCache(A);
- }
- function b() {
- this._clearCache(u);
- }
- function C() {
- this._clearCache(f);
- }
- class w extends n.Node {
- constructor(S) {
- super(S);
- let P;
- for (; P = e.Util.getRandomColor(), !(P && !(P in s.shapes)); )
- ;
- this.colorKey = P, s.shapes[P] = this;
- }
- getContext() {
- return e.Util.warn("shape.getContext() method is deprecated. Please do not use it."), this.getLayer().getContext();
- }
- getCanvas() {
- return e.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."), this.getLayer().getCanvas();
- }
- getSceneFunc() {
- return this.attrs.sceneFunc || this._sceneFunc;
- }
- getHitFunc() {
- return this.attrs.hitFunc || this._hitFunc;
- }
- hasShadow() {
- return this._getCache(h, this._hasShadow);
- }
- _hasShadow() {
- return this.shadowEnabled() && this.shadowOpacity() !== 0 && !!(this.shadowColor() || this.shadowBlur() || this.shadowOffsetX() || this.shadowOffsetY());
- }
- _getFillPattern() {
- return this._getCache(A, this.__getFillPattern);
- }
- __getFillPattern() {
- if (this.fillPatternImage()) {
- var S = d();
- const P = S.createPattern(this.fillPatternImage(), this.fillPatternRepeat() || "repeat");
- if (P && P.setTransform) {
- const k = new e.Transform();
- k.translate(this.fillPatternX(), this.fillPatternY()), k.rotate(t.Konva.getAngle(this.fillPatternRotation())), k.scale(this.fillPatternScaleX(), this.fillPatternScaleY()), k.translate(-1 * this.fillPatternOffsetX(), -1 * this.fillPatternOffsetY());
- const F = k.getMatrix(), L = typeof DOMMatrix > "u" ? {
- a: F[0],
- b: F[1],
- c: F[2],
- d: F[3],
- e: F[4],
- f: F[5]
- } : new DOMMatrix(F);
- P.setTransform(L);
- }
- return P;
- }
- }
- _getLinearGradient() {
- return this._getCache(u, this.__getLinearGradient);
- }
- __getLinearGradient() {
- var S = this.fillLinearGradientColorStops();
- if (S) {
- for (var P = d(), k = this.fillLinearGradientStartPoint(), F = this.fillLinearGradientEndPoint(), L = P.createLinearGradient(k.x, k.y, F.x, F.y), I = 0; I < S.length; I += 2)
- L.addColorStop(S[I], S[I + 1]);
- return L;
- }
- }
- _getRadialGradient() {
- return this._getCache(f, this.__getRadialGradient);
- }
- __getRadialGradient() {
- var S = this.fillRadialGradientColorStops();
- if (S) {
- for (var P = d(), k = this.fillRadialGradientStartPoint(), F = this.fillRadialGradientEndPoint(), L = P.createRadialGradient(k.x, k.y, this.fillRadialGradientStartRadius(), F.x, F.y, this.fillRadialGradientEndRadius()), I = 0; I < S.length; I += 2)
- L.addColorStop(S[I], S[I + 1]);
- return L;
- }
- }
- getShadowRGBA() {
- return this._getCache(l, this._getShadowRGBA);
- }
- _getShadowRGBA() {
- if (this.hasShadow()) {
- var S = e.Util.colorToRGBA(this.shadowColor());
- if (S)
- return "rgba(" + S.r + "," + S.g + "," + S.b + "," + S.a * (this.shadowOpacity() || 1) + ")";
- }
- }
- hasFill() {
- return this._calculate("hasFill", [
- "fillEnabled",
- "fill",
- "fillPatternImage",
- "fillLinearGradientColorStops",
- "fillRadialGradientColorStops"
- ], () => this.fillEnabled() && !!(this.fill() || this.fillPatternImage() || this.fillLinearGradientColorStops() || this.fillRadialGradientColorStops()));
- }
- hasStroke() {
- return this._calculate("hasStroke", [
- "strokeEnabled",
- "strokeWidth",
- "stroke",
- "strokeLinearGradientColorStops"
- ], () => this.strokeEnabled() && this.strokeWidth() && !!(this.stroke() || this.strokeLinearGradientColorStops()));
- }
- hasHitStroke() {
- const S = this.hitStrokeWidth();
- return S === "auto" ? this.hasStroke() : this.strokeEnabled() && !!S;
- }
- intersects(S) {
- var P = this.getStage();
- if (!P)
- return !1;
- const k = P.bufferHitCanvas;
- return k.getContext().clear(), this.drawHit(k, void 0, !0), k.context.getImageData(Math.round(S.x), Math.round(S.y), 1, 1).data[3] > 0;
- }
- destroy() {
- return n.Node.prototype.destroy.call(this), delete s.shapes[this.colorKey], delete this.colorKey, this;
- }
- _useBufferCanvas(S) {
- var P;
- if (!((P = this.attrs.perfectDrawEnabled) !== null && P !== void 0 ? P : !0))
- return !1;
- const F = S || this.hasFill(), L = this.hasStroke(), I = this.getAbsoluteOpacity() !== 1;
- if (F && L && I)
- return !0;
- const z = this.hasShadow(), T = this.shadowForStrokeEnabled();
- return !!(F && L && z && T);
- }
- setStrokeHitEnabled(S) {
- e.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."), S ? this.hitStrokeWidth("auto") : this.hitStrokeWidth(0);
- }
- getStrokeHitEnabled() {
- return this.hitStrokeWidth() !== 0;
- }
- getSelfRect() {
- var S = this.size();
- return {
- x: this._centroid ? -S.width / 2 : 0,
- y: this._centroid ? -S.height / 2 : 0,
- width: S.width,
- height: S.height
- };
- }
- getClientRect(S = {}) {
- const P = S.skipTransform, k = S.relativeTo, F = this.getSelfRect(), I = !S.skipStroke && this.hasStroke() && this.strokeWidth() || 0, z = F.width + I, T = F.height + I, G = !S.skipShadow && this.hasShadow(), H = G ? this.shadowOffsetX() : 0, R = G ? this.shadowOffsetY() : 0, N = z + Math.abs(H), q = T + Math.abs(R), et = G && this.shadowBlur() || 0, tt = N + et * 2, Ut = q + et * 2, dt = {
- width: tt,
- height: Ut,
- x: -(I / 2 + et) + Math.min(H, 0) + F.x,
- y: -(I / 2 + et) + Math.min(R, 0) + F.y
- };
- return P ? dt : this._transformedRect(dt, k);
- }
- drawScene(S, P, k) {
- var F = this.getLayer(), L = S || F.getCanvas(), I = L.getContext(), z = this._getCanvasCache(), T = this.getSceneFunc(), G = this.hasShadow(), H, R, N = L.isCache, q = P === this;
- if (!this.isVisible() && !q)
- return this;
- if (z) {
- I.save();
- var et = this.getAbsoluteTransform(P).getMatrix();
- return I.transform(et[0], et[1], et[2], et[3], et[4], et[5]), this._drawCachedSceneCanvas(I), I.restore(), this;
- }
- if (!T)
- return this;
- if (I.save(), this._useBufferCanvas() && !N) {
- H = this.getStage();
- const dt = k || H.bufferCanvas;
- R = dt.getContext(), R.clear(), R.save(), R._applyLineJoin(this);
- var tt = this.getAbsoluteTransform(P).getMatrix();
- R.transform(tt[0], tt[1], tt[2], tt[3], tt[4], tt[5]), T.call(this, R, this), R.restore();
- var Ut = dt.pixelRatio;
- G && I._applyShadow(this), I._applyOpacity(this), I._applyGlobalCompositeOperation(this), I.drawImage(dt._canvas, 0, 0, dt.width / Ut, dt.height / Ut);
- } else {
- if (I._applyLineJoin(this), !q) {
- var tt = this.getAbsoluteTransform(P).getMatrix();
- I.transform(tt[0], tt[1], tt[2], tt[3], tt[4], tt[5]), I._applyOpacity(this), I._applyGlobalCompositeOperation(this);
- }
- G && I._applyShadow(this), T.call(this, I, this);
- }
- return I.restore(), this;
- }
- drawHit(S, P, k = !1) {
- if (!this.shouldDrawHit(P, k))
- return this;
- var F = this.getLayer(), L = S || F.hitCanvas, I = L && L.getContext(), z = this.hitFunc() || this.sceneFunc(), T = this._getCanvasCache(), G = T && T.hit;
- if (this.colorKey || e.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"), G) {
- I.save();
- var H = this.getAbsoluteTransform(P).getMatrix();
- return I.transform(H[0], H[1], H[2], H[3], H[4], H[5]), this._drawCachedHitCanvas(I), I.restore(), this;
- }
- if (!z)
- return this;
- if (I.save(), I._applyLineJoin(this), !(this === P)) {
- var N = this.getAbsoluteTransform(P).getMatrix();
- I.transform(N[0], N[1], N[2], N[3], N[4], N[5]);
- }
- return z.call(this, I, this), I.restore(), this;
- }
- drawHitFromCache(S = 0) {
- var P = this._getCanvasCache(), k = this._getCachedSceneCanvas(), F = P.hit, L = F.getContext(), I = F.getWidth(), z = F.getHeight(), T, G, H, R, N, q;
- L.clear(), L.drawImage(k._canvas, 0, 0, I, z);
- try {
- for (T = L.getImageData(0, 0, I, z), G = T.data, H = G.length, R = e.Util._hexToRgb(this.colorKey), N = 0; N < H; N += 4)
- q = G[N + 3], q > S ? (G[N] = R.r, G[N + 1] = R.g, G[N + 2] = R.b, G[N + 3] = 255) : G[N + 3] = 0;
- L.putImageData(T, 0, 0);
- } catch (et) {
- e.Util.error("Unable to draw hit graph from cached scene canvas. " + et.message);
- }
- return this;
- }
- hasPointerCapture(S) {
- return o.hasPointerCapture(S, this);
- }
- setPointerCapture(S) {
- o.setPointerCapture(S, this);
- }
- releaseCapture(S) {
- o.releaseCapture(S, this);
- }
- }
- s.Shape = w, w.prototype._fillFunc = p, w.prototype._strokeFunc = m, w.prototype._fillFuncHit = v, w.prototype._strokeFuncHit = _, w.prototype._centroid = !1, w.prototype.nodeType = "Shape", (0, a._registerNode)(w), w.prototype.eventListeners = {}, w.prototype.on.call(w.prototype, "shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva", g), w.prototype.on.call(w.prototype, "shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva", y), w.prototype.on.call(w.prototype, "fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva", x), w.prototype.on.call(w.prototype, "fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva", b), w.prototype.on.call(w.prototype, "fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva", C), i.Factory.addGetterSetter(w, "stroke", void 0, (0, r.getStringOrGradientValidator)()), i.Factory.addGetterSetter(w, "strokeWidth", 2, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "fillAfterStrokeEnabled", !1), i.Factory.addGetterSetter(w, "hitStrokeWidth", "auto", (0, r.getNumberOrAutoValidator)()), i.Factory.addGetterSetter(w, "strokeHitEnabled", !0, (0, r.getBooleanValidator)()), i.Factory.addGetterSetter(w, "perfectDrawEnabled", !0, (0, r.getBooleanValidator)()), i.Factory.addGetterSetter(w, "shadowForStrokeEnabled", !0, (0, r.getBooleanValidator)()), i.Factory.addGetterSetter(w, "lineJoin"), i.Factory.addGetterSetter(w, "lineCap"), i.Factory.addGetterSetter(w, "sceneFunc"), i.Factory.addGetterSetter(w, "hitFunc"), i.Factory.addGetterSetter(w, "dash"), i.Factory.addGetterSetter(w, "dashOffset", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "shadowColor", void 0, (0, r.getStringValidator)()), i.Factory.addGetterSetter(w, "shadowBlur", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "shadowOpacity", 1, (0, r.getNumberValidator)()), i.Factory.addComponentsGetterSetter(w, "shadowOffset", ["x", "y"]), i.Factory.addGetterSetter(w, "shadowOffsetX", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "shadowOffsetY", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "fillPatternImage"), i.Factory.addGetterSetter(w, "fill", void 0, (0, r.getStringOrGradientValidator)()), i.Factory.addGetterSetter(w, "fillPatternX", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "fillPatternY", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "fillLinearGradientColorStops"), i.Factory.addGetterSetter(w, "strokeLinearGradientColorStops"), i.Factory.addGetterSetter(w, "fillRadialGradientStartRadius", 0), i.Factory.addGetterSetter(w, "fillRadialGradientEndRadius", 0), i.Factory.addGetterSetter(w, "fillRadialGradientColorStops"), i.Factory.addGetterSetter(w, "fillPatternRepeat", "repeat"), i.Factory.addGetterSetter(w, "fillEnabled", !0), i.Factory.addGetterSetter(w, "strokeEnabled", !0), i.Factory.addGetterSetter(w, "shadowEnabled", !0), i.Factory.addGetterSetter(w, "dashEnabled", !0), i.Factory.addGetterSetter(w, "strokeScaleEnabled", !0), i.Factory.addGetterSetter(w, "fillPriority", "color"), i.Factory.addComponentsGetterSetter(w, "fillPatternOffset", ["x", "y"]), i.Factory.addGetterSetter(w, "fillPatternOffsetX", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "fillPatternOffsetY", 0, (0, r.getNumberValidator)()), i.Factory.addComponentsGetterSetter(w, "fillPatternScale", ["x", "y"]), i.Factory.addGetterSetter(w, "fillPatternScaleX", 1, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "fillPatternScaleY", 1, (0, r.getNumberValidator)()), i.Factory.addComponentsGetterSetter(w, "fillLinearGradientStartPoint", [
- "x",
- "y"
- ]), i.Factory.addComponentsGetterSetter(w, "strokeLinearGradientStartPoint", [
- "x",
- "y"
- ]), i.Factory.addGetterSetter(w, "fillLinearGradientStartPointX", 0), i.Factory.addGetterSetter(w, "strokeLinearGradientStartPointX", 0), i.Factory.addGetterSetter(w, "fillLinearGradientStartPointY", 0), i.Factory.addGetterSetter(w, "strokeLinearGradientStartPointY", 0), i.Factory.addComponentsGetterSetter(w, "fillLinearGradientEndPoint", [
- "x",
- "y"
- ]), i.Factory.addComponentsGetterSetter(w, "strokeLinearGradientEndPoint", [
- "x",
- "y"
- ]), i.Factory.addGetterSetter(w, "fillLinearGradientEndPointX", 0), i.Factory.addGetterSetter(w, "strokeLinearGradientEndPointX", 0), i.Factory.addGetterSetter(w, "fillLinearGradientEndPointY", 0), i.Factory.addGetterSetter(w, "strokeLinearGradientEndPointY", 0), i.Factory.addComponentsGetterSetter(w, "fillRadialGradientStartPoint", [
- "x",
- "y"
- ]), i.Factory.addGetterSetter(w, "fillRadialGradientStartPointX", 0), i.Factory.addGetterSetter(w, "fillRadialGradientStartPointY", 0), i.Factory.addComponentsGetterSetter(w, "fillRadialGradientEndPoint", [
- "x",
- "y"
- ]), i.Factory.addGetterSetter(w, "fillRadialGradientEndPointX", 0), i.Factory.addGetterSetter(w, "fillRadialGradientEndPointY", 0), i.Factory.addGetterSetter(w, "fillPatternRotation", 0), i.Factory.addGetterSetter(w, "fillRule", void 0, (0, r.getStringValidator)()), i.Factory.backCompat(w, {
- dashArray: "dash",
- getDashArray: "getDash",
- setDashArray: "getDash",
- drawFunc: "sceneFunc",
- getDrawFunc: "getSceneFunc",
- setDrawFunc: "setSceneFunc",
- drawHitFunc: "hitFunc",
- getDrawHitFunc: "getHitFunc",
- setDrawHitFunc: "setHitFunc"
- });
- })(ft);
- Object.defineProperty(Cn, "__esModule", { value: !0 });
- var Ni = Cn.Circle = void 0;
- const rl = V, al = ft, ol = O, hl = $;
- class oi extends al.Shape {
- _sceneFunc(t) {
- t.beginPath(), t.arc(0, 0, this.attrs.radius || 0, 0, Math.PI * 2, !1), t.closePath(), t.fillStrokeShape(this);
- }
- getWidth() {
- return this.radius() * 2;
- }
- getHeight() {
- return this.radius() * 2;
- }
- setWidth(t) {
- this.radius() !== t / 2 && this.radius(t / 2);
- }
- setHeight(t) {
- this.radius() !== t / 2 && this.radius(t / 2);
- }
- }
- Ni = Cn.Circle = oi;
- oi.prototype._centroid = !0;
- oi.prototype.className = "Circle";
- oi.prototype._attrsAffectingSize = ["radius"];
- (0, hl._registerNode)(oi);
- rl.Factory.addGetterSetter(oi, "radius", 0, (0, ol.getNumberValidator)());
- var Gi = {};
- Object.defineProperty(Gi, "__esModule", { value: !0 });
- var Fn = Gi.Line = void 0;
- const kn = V, ll = ft, io = O, Al = $;
- function qs(s, t, e, i, n, r, a) {
- var o = Math.sqrt(Math.pow(e - s, 2) + Math.pow(i - t, 2)), h = Math.sqrt(Math.pow(n - e, 2) + Math.pow(r - i, 2)), l = a * o / (o + h), A = a * h / (o + h), u = e - l * (n - s), f = i - l * (r - t), c = e + A * (n - s), d = i + A * (r - t);
- return [u, f, c, d];
- }
- function Wr(s, t) {
- var e = s.length, i = [], n, r;
- for (n = 2; n < e - 2; n += 2)
- r = qs(s[n - 2], s[n - 1], s[n], s[n + 1], s[n + 2], s[n + 3], t), !isNaN(r[0]) && (i.push(r[0]), i.push(r[1]), i.push(s[n]), i.push(s[n + 1]), i.push(r[2]), i.push(r[3]));
- return i;
- }
- class ge extends ll.Shape {
- constructor(t) {
- super(t), this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva", function() {
- this._clearCache("tensionPoints");
- });
- }
- _sceneFunc(t) {
- var e = this.points(), i = e.length, n = this.tension(), r = this.closed(), a = this.bezier(), o, h, l;
- if (i) {
- if (t.beginPath(), t.moveTo(e[0], e[1]), n !== 0 && i > 4) {
- for (o = this.getTensionPoints(), h = o.length, l = r ? 0 : 4, r || t.quadraticCurveTo(o[0], o[1], o[2], o[3]); l < h - 2; )
- t.bezierCurveTo(o[l++], o[l++], o[l++], o[l++], o[l++], o[l++]);
- r || t.quadraticCurveTo(o[h - 2], o[h - 1], e[i - 2], e[i - 1]);
- } else if (a)
- for (l = 2; l < i; )
- t.bezierCurveTo(e[l++], e[l++], e[l++], e[l++], e[l++], e[l++]);
- else
- for (l = 2; l < i; l += 2)
- t.lineTo(e[l], e[l + 1]);
- r ? (t.closePath(), t.fillStrokeShape(this)) : t.strokeShape(this);
- }
- }
- getTensionPoints() {
- return this._getCache("tensionPoints", this._getTensionPoints);
- }
- _getTensionPoints() {
- return this.closed() ? this._getTensionPointsClosed() : Wr(this.points(), this.tension());
- }
- _getTensionPointsClosed() {
- var t = this.points(), e = t.length, i = this.tension(), n = qs(t[e - 2], t[e - 1], t[0], t[1], t[2], t[3], i), r = qs(t[e - 4], t[e - 3], t[e - 2], t[e - 1], t[0], t[1], i), a = Wr(t, i), o = [n[2], n[3]].concat(a).concat([
- r[0],
- r[1],
- t[e - 2],
- t[e - 1],
- r[2],
- r[3],
- n[0],
- n[1],
- t[0],
- t[1]
- ]);
- return o;
- }
- getWidth() {
- return this.getSelfRect().width;
- }
- getHeight() {
- return this.getSelfRect().height;
- }
- getSelfRect() {
- var t = this.points();
- if (t.length < 4)
- return {
- x: t[0] || 0,
- y: t[1] || 0,
- width: 0,
- height: 0
- };
- this.tension() !== 0 ? t = [
- t[0],
- t[1],
- ...this._getTensionPoints(),
- t[t.length - 2],
- t[t.length - 1]
- ] : t = this.points();
- for (var e = t[0], i = t[0], n = t[1], r = t[1], a, o, h = 0; h < t.length / 2; h++)
- a = t[h * 2], o = t[h * 2 + 1], e = Math.min(e, a), i = Math.max(i, a), n = Math.min(n, o), r = Math.max(r, o);
- return {
- x: e,
- y: n,
- width: i - e,
- height: r - n
- };
- }
- }
- Fn = Gi.Line = ge;
- ge.prototype.className = "Line";
- ge.prototype._attrsAffectingSize = ["points", "bezier", "tension"];
- (0, Al._registerNode)(ge);
- kn.Factory.addGetterSetter(ge, "closed", !1);
- kn.Factory.addGetterSetter(ge, "bezier", !1);
- kn.Factory.addGetterSetter(ge, "tension", 0, (0, io.getNumberValidator)());
- kn.Factory.addGetterSetter(ge, "points", [], (0, io.getNumberArrayValidator)());
- let qt = !1;
- const qe = navigator.userAgent, Xu = (s) => qt = s, no = /iPhone|iPad|iPod|Android/i.test(qe);
- let cl = /(?:Android)/.test(qe), dl = /(?:Firefox)/.test(qe);
- const ul = /(?:iPad|PlayBook|Tablet)/.test(qe) || cl && !/(?:Mobile)/.test(qe) || dl && /(?:Tablet)/.test(qe) || no && (window.innerWidth < window.innerHeight ? window.innerWidth : window.innerHeight) > 600, hn = no || ul;
- var hi = {}, so = {};
- (function(s) {
- Object.defineProperty(s, "__esModule", { value: !0 }), s.t2length = s.getQuadraticArcLength = s.getCubicArcLength = s.binomialCoefficients = s.cValues = s.tValues = void 0, s.tValues = [
- [],
- [],
- [
- -0.5773502691896257,
- 0.5773502691896257
- ],
- [
- 0,
- -0.7745966692414834,
- 0.7745966692414834
- ],
- [
- -0.33998104358485626,
- 0.33998104358485626,
- -0.8611363115940526,
- 0.8611363115940526
- ],
- [
- 0,
- -0.5384693101056831,
- 0.5384693101056831,
- -0.906179845938664,
- 0.906179845938664
- ],
- [
- 0.6612093864662645,
- -0.6612093864662645,
- -0.2386191860831969,
- 0.2386191860831969,
- -0.932469514203152,
- 0.932469514203152
- ],
- [
- 0,
- 0.4058451513773972,
- -0.4058451513773972,
- -0.7415311855993945,
- 0.7415311855993945,
- -0.9491079123427585,
- 0.9491079123427585
- ],
- [
- -0.1834346424956498,
- 0.1834346424956498,
- -0.525532409916329,
- 0.525532409916329,
- -0.7966664774136267,
- 0.7966664774136267,
- -0.9602898564975363,
- 0.9602898564975363
- ],
- [
- 0,
- -0.8360311073266358,
- 0.8360311073266358,
- -0.9681602395076261,
- 0.9681602395076261,
- -0.3242534234038089,
- 0.3242534234038089,
- -0.6133714327005904,
- 0.6133714327005904
- ],
- [
- -0.14887433898163122,
- 0.14887433898163122,
- -0.4333953941292472,
- 0.4333953941292472,
- -0.6794095682990244,
- 0.6794095682990244,
- -0.8650633666889845,
- 0.8650633666889845,
- -0.9739065285171717,
- 0.9739065285171717
- ],
- [
- 0,
- -0.26954315595234496,
- 0.26954315595234496,
- -0.5190961292068118,
- 0.5190961292068118,
- -0.7301520055740494,
- 0.7301520055740494,
- -0.8870625997680953,
- 0.8870625997680953,
- -0.978228658146057,
- 0.978228658146057
- ],
- [
- -0.1252334085114689,
- 0.1252334085114689,
- -0.3678314989981802,
- 0.3678314989981802,
- -0.5873179542866175,
- 0.5873179542866175,
- -0.7699026741943047,
- 0.7699026741943047,
- -0.9041172563704749,
- 0.9041172563704749,
- -0.9815606342467192,
- 0.9815606342467192
- ],
- [
- 0,
- -0.2304583159551348,
- 0.2304583159551348,
- -0.44849275103644687,
- 0.44849275103644687,
- -0.6423493394403402,
- 0.6423493394403402,
- -0.8015780907333099,
- 0.8015780907333099,
- -0.9175983992229779,
- 0.9175983992229779,
- -0.9841830547185881,
- 0.9841830547185881
- ],
- [
- -0.10805494870734367,
- 0.10805494870734367,
- -0.31911236892788974,
- 0.31911236892788974,
- -0.5152486363581541,
- 0.5152486363581541,
- -0.6872929048116855,
- 0.6872929048116855,
- -0.827201315069765,
- 0.827201315069765,
- -0.9284348836635735,
- 0.9284348836635735,
- -0.9862838086968123,
- 0.9862838086968123
- ],
- [
- 0,
- -0.20119409399743451,
- 0.20119409399743451,
- -0.3941513470775634,
- 0.3941513470775634,
- -0.5709721726085388,
- 0.5709721726085388,
- -0.7244177313601701,
- 0.7244177313601701,
- -0.8482065834104272,
- 0.8482065834104272,
- -0.937273392400706,
- 0.937273392400706,
- -0.9879925180204854,
- 0.9879925180204854
- ],
- [
- -0.09501250983763744,
- 0.09501250983763744,
- -0.2816035507792589,
- 0.2816035507792589,
- -0.45801677765722737,
- 0.45801677765722737,
- -0.6178762444026438,
- 0.6178762444026438,
- -0.755404408355003,
- 0.755404408355003,
- -0.8656312023878318,
- 0.8656312023878318,
- -0.9445750230732326,
- 0.9445750230732326,
- -0.9894009349916499,
- 0.9894009349916499
- ],
- [
- 0,
- -0.17848418149584785,
- 0.17848418149584785,
- -0.3512317634538763,
- 0.3512317634538763,
- -0.5126905370864769,
- 0.5126905370864769,
- -0.6576711592166907,
- 0.6576711592166907,
- -0.7815140038968014,
- 0.7815140038968014,
- -0.8802391537269859,
- 0.8802391537269859,
- -0.9506755217687678,
- 0.9506755217687678,
- -0.9905754753144174,
- 0.9905754753144174
- ],
- [
- -0.0847750130417353,
- 0.0847750130417353,
- -0.2518862256915055,
- 0.2518862256915055,
- -0.41175116146284263,
- 0.41175116146284263,
- -0.5597708310739475,
- 0.5597708310739475,
- -0.6916870430603532,
- 0.6916870430603532,
- -0.8037049589725231,
- 0.8037049589725231,
- -0.8926024664975557,
- 0.8926024664975557,
- -0.9558239495713977,
- 0.9558239495713977,
- -0.9915651684209309,
- 0.9915651684209309
- ],
- [
- 0,
- -0.16035864564022537,
- 0.16035864564022537,
- -0.31656409996362983,
- 0.31656409996362983,
- -0.46457074137596094,
- 0.46457074137596094,
- -0.600545304661681,
- 0.600545304661681,
- -0.7209661773352294,
- 0.7209661773352294,
- -0.8227146565371428,
- 0.8227146565371428,
- -0.9031559036148179,
- 0.9031559036148179,
- -0.96020815213483,
- 0.96020815213483,
- -0.9924068438435844,
- 0.9924068438435844
- ],
- [
- -0.07652652113349734,
- 0.07652652113349734,
- -0.22778585114164507,
- 0.22778585114164507,
- -0.37370608871541955,
- 0.37370608871541955,
- -0.5108670019508271,
- 0.5108670019508271,
- -0.636053680726515,
- 0.636053680726515,
- -0.7463319064601508,
- 0.7463319064601508,
- -0.8391169718222188,
- 0.8391169718222188,
- -0.912234428251326,
- 0.912234428251326,
- -0.9639719272779138,
- 0.9639719272779138,
- -0.9931285991850949,
- 0.9931285991850949
- ],
- [
- 0,
- -0.1455618541608951,
- 0.1455618541608951,
- -0.2880213168024011,
- 0.2880213168024011,
- -0.4243421202074388,
- 0.4243421202074388,
- -0.5516188358872198,
- 0.5516188358872198,
- -0.6671388041974123,
- 0.6671388041974123,
- -0.7684399634756779,
- 0.7684399634756779,
- -0.8533633645833173,
- 0.8533633645833173,
- -0.9200993341504008,
- 0.9200993341504008,
- -0.9672268385663063,
- 0.9672268385663063,
- -0.9937521706203895,
- 0.9937521706203895
- ],
- [
- -0.06973927331972223,
- 0.06973927331972223,
- -0.20786042668822127,
- 0.20786042668822127,
- -0.34193582089208424,
- 0.34193582089208424,
- -0.469355837986757,
- 0.469355837986757,
- -0.5876404035069116,
- 0.5876404035069116,
- -0.6944872631866827,
- 0.6944872631866827,
- -0.7878168059792081,
- 0.7878168059792081,
- -0.8658125777203002,
- 0.8658125777203002,
- -0.926956772187174,
- 0.926956772187174,
- -0.9700604978354287,
- 0.9700604978354287,
- -0.9942945854823992,
- 0.9942945854823992
- ],
- [
- 0,
- -0.1332568242984661,
- 0.1332568242984661,
- -0.26413568097034495,
- 0.26413568097034495,
- -0.3903010380302908,
- 0.3903010380302908,
- -0.5095014778460075,
- 0.5095014778460075,
- -0.6196098757636461,
- 0.6196098757636461,
- -0.7186613631319502,
- 0.7186613631319502,
- -0.8048884016188399,
- 0.8048884016188399,
- -0.8767523582704416,
- 0.8767523582704416,
- -0.9329710868260161,
- 0.9329710868260161,
- -0.9725424712181152,
- 0.9725424712181152,
- -0.9947693349975522,
- 0.9947693349975522
- ],
- [
- -0.06405689286260563,
- 0.06405689286260563,
- -0.1911188674736163,
- 0.1911188674736163,
- -0.3150426796961634,
- 0.3150426796961634,
- -0.4337935076260451,
- 0.4337935076260451,
- -0.5454214713888396,
- 0.5454214713888396,
- -0.6480936519369755,
- 0.6480936519369755,
- -0.7401241915785544,
- 0.7401241915785544,
- -0.820001985973903,
- 0.820001985973903,
- -0.8864155270044011,
- 0.8864155270044011,
- -0.9382745520027328,
- 0.9382745520027328,
- -0.9747285559713095,
- 0.9747285559713095,
- -0.9951872199970213,
- 0.9951872199970213
- ]
- ], s.cValues = [
- [],
- [],
- [1, 1],
- [
- 0.8888888888888888,
- 0.5555555555555556,
- 0.5555555555555556
- ],
- [
- 0.6521451548625461,
- 0.6521451548625461,
- 0.34785484513745385,
- 0.34785484513745385
- ],
- [
- 0.5688888888888889,
- 0.47862867049936647,
- 0.47862867049936647,
- 0.23692688505618908,
- 0.23692688505618908
- ],
- [
- 0.3607615730481386,
- 0.3607615730481386,
- 0.46791393457269104,
- 0.46791393457269104,
- 0.17132449237917036,
- 0.17132449237917036
- ],
- [
- 0.4179591836734694,
- 0.3818300505051189,
- 0.3818300505051189,
- 0.27970539148927664,
- 0.27970539148927664,
- 0.1294849661688697,
- 0.1294849661688697
- ],
- [
- 0.362683783378362,
- 0.362683783378362,
- 0.31370664587788727,
- 0.31370664587788727,
- 0.22238103445337448,
- 0.22238103445337448,
- 0.10122853629037626,
- 0.10122853629037626
- ],
- [
- 0.3302393550012598,
- 0.1806481606948574,
- 0.1806481606948574,
- 0.08127438836157441,
- 0.08127438836157441,
- 0.31234707704000286,
- 0.31234707704000286,
- 0.26061069640293544,
- 0.26061069640293544
- ],
- [
- 0.29552422471475287,
- 0.29552422471475287,
- 0.26926671930999635,
- 0.26926671930999635,
- 0.21908636251598204,
- 0.21908636251598204,
- 0.1494513491505806,
- 0.1494513491505806,
- 0.06667134430868814,
- 0.06667134430868814
- ],
- [
- 0.2729250867779006,
- 0.26280454451024665,
- 0.26280454451024665,
- 0.23319376459199048,
- 0.23319376459199048,
- 0.18629021092773426,
- 0.18629021092773426,
- 0.1255803694649046,
- 0.1255803694649046,
- 0.05566856711617366,
- 0.05566856711617366
- ],
- [
- 0.24914704581340277,
- 0.24914704581340277,
- 0.2334925365383548,
- 0.2334925365383548,
- 0.20316742672306592,
- 0.20316742672306592,
- 0.16007832854334622,
- 0.16007832854334622,
- 0.10693932599531843,
- 0.10693932599531843,
- 0.04717533638651183,
- 0.04717533638651183
- ],
- [
- 0.2325515532308739,
- 0.22628318026289723,
- 0.22628318026289723,
- 0.2078160475368885,
- 0.2078160475368885,
- 0.17814598076194574,
- 0.17814598076194574,
- 0.13887351021978725,
- 0.13887351021978725,
- 0.09212149983772845,
- 0.09212149983772845,
- 0.04048400476531588,
- 0.04048400476531588
- ],
- [
- 0.2152638534631578,
- 0.2152638534631578,
- 0.2051984637212956,
- 0.2051984637212956,
- 0.18553839747793782,
- 0.18553839747793782,
- 0.15720316715819355,
- 0.15720316715819355,
- 0.12151857068790319,
- 0.12151857068790319,
- 0.08015808715976021,
- 0.08015808715976021,
- 0.03511946033175186,
- 0.03511946033175186
- ],
- [
- 0.2025782419255613,
- 0.19843148532711158,
- 0.19843148532711158,
- 0.1861610000155622,
- 0.1861610000155622,
- 0.16626920581699392,
- 0.16626920581699392,
- 0.13957067792615432,
- 0.13957067792615432,
- 0.10715922046717194,
- 0.10715922046717194,
- 0.07036604748810812,
- 0.07036604748810812,
- 0.03075324199611727,
- 0.03075324199611727
- ],
- [
- 0.1894506104550685,
- 0.1894506104550685,
- 0.18260341504492358,
- 0.18260341504492358,
- 0.16915651939500254,
- 0.16915651939500254,
- 0.14959598881657674,
- 0.14959598881657674,
- 0.12462897125553388,
- 0.12462897125553388,
- 0.09515851168249279,
- 0.09515851168249279,
- 0.062253523938647894,
- 0.062253523938647894,
- 0.027152459411754096,
- 0.027152459411754096
- ],
- [
- 0.17944647035620653,
- 0.17656270536699264,
- 0.17656270536699264,
- 0.16800410215645004,
- 0.16800410215645004,
- 0.15404576107681028,
- 0.15404576107681028,
- 0.13513636846852548,
- 0.13513636846852548,
- 0.11188384719340397,
- 0.11188384719340397,
- 0.08503614831717918,
- 0.08503614831717918,
- 0.0554595293739872,
- 0.0554595293739872,
- 0.02414830286854793,
- 0.02414830286854793
- ],
- [
- 0.1691423829631436,
- 0.1691423829631436,
- 0.16427648374583273,
- 0.16427648374583273,
- 0.15468467512626524,
- 0.15468467512626524,
- 0.14064291467065065,
- 0.14064291467065065,
- 0.12255520671147846,
- 0.12255520671147846,
- 0.10094204410628717,
- 0.10094204410628717,
- 0.07642573025488905,
- 0.07642573025488905,
- 0.0497145488949698,
- 0.0497145488949698,
- 0.02161601352648331,
- 0.02161601352648331
- ],
- [
- 0.1610544498487837,
- 0.15896884339395434,
- 0.15896884339395434,
- 0.15276604206585967,
- 0.15276604206585967,
- 0.1426067021736066,
- 0.1426067021736066,
- 0.12875396253933621,
- 0.12875396253933621,
- 0.11156664554733399,
- 0.11156664554733399,
- 0.09149002162245,
- 0.09149002162245,
- 0.06904454273764123,
- 0.06904454273764123,
- 0.0448142267656996,
- 0.0448142267656996,
- 0.019461788229726478,
- 0.019461788229726478
- ],
- [
- 0.15275338713072584,
- 0.15275338713072584,
- 0.14917298647260374,
- 0.14917298647260374,
- 0.14209610931838204,
- 0.14209610931838204,
- 0.13168863844917664,
- 0.13168863844917664,
- 0.11819453196151841,
- 0.11819453196151841,
- 0.10193011981724044,
- 0.10193011981724044,
- 0.08327674157670475,
- 0.08327674157670475,
- 0.06267204833410907,
- 0.06267204833410907,
- 0.04060142980038694,
- 0.04060142980038694,
- 0.017614007139152118,
- 0.017614007139152118
- ],
- [
- 0.14608113364969041,
- 0.14452440398997005,
- 0.14452440398997005,
- 0.13988739479107315,
- 0.13988739479107315,
- 0.13226893863333747,
- 0.13226893863333747,
- 0.12183141605372853,
- 0.12183141605372853,
- 0.10879729916714838,
- 0.10879729916714838,
- 0.09344442345603386,
- 0.09344442345603386,
- 0.0761001136283793,
- 0.0761001136283793,
- 0.057134425426857205,
- 0.057134425426857205,
- 0.036953789770852494,
- 0.036953789770852494,
- 0.016017228257774335,
- 0.016017228257774335
- ],
- [
- 0.13925187285563198,
- 0.13925187285563198,
- 0.13654149834601517,
- 0.13654149834601517,
- 0.13117350478706238,
- 0.13117350478706238,
- 0.12325237681051242,
- 0.12325237681051242,
- 0.11293229608053922,
- 0.11293229608053922,
- 0.10041414444288096,
- 0.10041414444288096,
- 0.08594160621706773,
- 0.08594160621706773,
- 0.06979646842452049,
- 0.06979646842452049,
- 0.052293335152683286,
- 0.052293335152683286,
- 0.03377490158481415,
- 0.03377490158481415,
- 0.0146279952982722,
- 0.0146279952982722
- ],
- [
- 0.13365457218610619,
- 0.1324620394046966,
- 0.1324620394046966,
- 0.12890572218808216,
- 0.12890572218808216,
- 0.12304908430672953,
- 0.12304908430672953,
- 0.11499664022241136,
- 0.11499664022241136,
- 0.10489209146454141,
- 0.10489209146454141,
- 0.09291576606003515,
- 0.09291576606003515,
- 0.07928141177671895,
- 0.07928141177671895,
- 0.06423242140852585,
- 0.06423242140852585,
- 0.04803767173108467,
- 0.04803767173108467,
- 0.030988005856979445,
- 0.030988005856979445,
- 0.013411859487141771,
- 0.013411859487141771
- ],
- [
- 0.12793819534675216,
- 0.12793819534675216,
- 0.1258374563468283,
- 0.1258374563468283,
- 0.12167047292780339,
- 0.12167047292780339,
- 0.1155056680537256,
- 0.1155056680537256,
- 0.10744427011596563,
- 0.10744427011596563,
- 0.09761865210411388,
- 0.09761865210411388,
- 0.08619016153195327,
- 0.08619016153195327,
- 0.0733464814110803,
- 0.0733464814110803,
- 0.05929858491543678,
- 0.05929858491543678,
- 0.04427743881741981,
- 0.04427743881741981,
- 0.028531388628933663,
- 0.028531388628933663,
- 0.0123412297999872,
- 0.0123412297999872
- ]
- ], s.binomialCoefficients = [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]];
- const t = (a, o, h) => {
- let l, A, u;
- l = h / 2, A = 0;
- for (let c = 0; c < 20; c++)
- u = l * s.tValues[20][c] + l, A += s.cValues[20][c] * i(a, o, u);
- return l * A;
- };
- s.getCubicArcLength = t;
- const e = (a, o, h) => {
- h === void 0 && (h = 1);
- const l = a[0] - 2 * a[1] + a[2], A = o[0] - 2 * o[1] + o[2], u = 2 * a[1] - 2 * a[0], f = 2 * o[1] - 2 * o[0], c = 4 * (l * l + A * A), d = 4 * (l * u + A * f), p = u * u + f * f;
- if (c === 0)
- return h * Math.sqrt(Math.pow(a[2] - a[0], 2) + Math.pow(o[2] - o[0], 2));
- const m = d / (2 * c), v = p / c, _ = h + m, g = v - m * m, y = _ * _ + g > 0 ? Math.sqrt(_ * _ + g) : 0, x = m * m + g > 0 ? Math.sqrt(m * m + g) : 0, b = m + Math.sqrt(m * m + g) !== 0 ? g * Math.log(Math.abs((_ + y) / (m + x))) : 0;
- return Math.sqrt(c) / 2 * (_ * y - m * x + b);
- };
- s.getQuadraticArcLength = e;
- function i(a, o, h) {
- const l = n(1, h, a), A = n(1, h, o), u = l * l + A * A;
- return Math.sqrt(u);
- }
- const n = (a, o, h) => {
- const l = h.length - 1;
- let A, u;
- if (l === 0)
- return 0;
- if (a === 0) {
- u = 0;
- for (let f = 0; f <= l; f++)
- u += s.binomialCoefficients[l][f] * Math.pow(1 - o, l - f) * Math.pow(o, f) * h[f];
- return u;
- } else {
- A = new Array(l);
- for (let f = 0; f < l; f++)
- A[f] = l * (h[f + 1] - h[f]);
- return n(a - 1, o, A);
- }
- }, r = (a, o, h) => {
- let l = 1, A = a / o, u = (a - h(A)) / o, f = 0;
- for (; l > 1e-3; ) {
- const c = h(A + u), d = Math.abs(a - c) / o;
- if (d < l)
- l = d, A += u;
- else {
- const p = h(A - u), m = Math.abs(a - p) / o;
- m < l ? (l = m, A -= u) : u /= 2;
- }
- if (f++, f > 500)
- break;
- }
- return A;
- };
- s.t2length = r;
- })(so);
- Object.defineProperty(hi, "__esModule", { value: !0 });
- var Ci = hi.Path = void 0;
- const fl = V, gl = ft, pl = $, Ge = so;
- class ut extends gl.Shape {
- constructor(t) {
- super(t), this.dataArray = [], this.pathLength = 0, this._readDataAttribute(), this.on("dataChange.konva", function() {
- this._readDataAttribute();
- });
- }
- _readDataAttribute() {
- this.dataArray = ut.parsePathData(this.data()), this.pathLength = ut.getPathLength(this.dataArray);
- }
- _sceneFunc(t) {
- var e = this.dataArray;
- t.beginPath();
- for (var i = !1, n = 0; n < e.length; n++) {
- var r = e[n].command, a = e[n].points;
- switch (r) {
- case "L":
- t.lineTo(a[0], a[1]);
- break;
- case "M":
- t.moveTo(a[0], a[1]);
- break;
- case "C":
- t.bezierCurveTo(a[0], a[1], a[2], a[3], a[4], a[5]);
- break;
- case "Q":
- t.quadraticCurveTo(a[0], a[1], a[2], a[3]);
- break;
- case "A":
- var o = a[0], h = a[1], l = a[2], A = a[3], u = a[4], f = a[5], c = a[6], d = a[7], p = l > A ? l : A, m = l > A ? 1 : l / A, v = l > A ? A / l : 1;
- t.translate(o, h), t.rotate(c), t.scale(m, v), t.arc(0, 0, p, u, u + f, 1 - d), t.scale(1 / m, 1 / v), t.rotate(-c), t.translate(-o, -h);
- break;
- case "z":
- i = !0, t.closePath();
- break;
- }
- }
- !i && !this.hasFill() ? t.strokeShape(this) : t.fillStrokeShape(this);
- }
- getSelfRect() {
- var t = [];
- this.dataArray.forEach(function(l) {
- if (l.command === "A") {
- var A = l.points[4], u = l.points[5], f = l.points[4] + u, c = Math.PI / 180;
- if (Math.abs(A - f) < c && (c = Math.abs(A - f)), u < 0)
- for (let d = A - c; d > f; d -= c) {
- const p = ut.getPointOnEllipticalArc(l.points[0], l.points[1], l.points[2], l.points[3], d, 0);
- t.push(p.x, p.y);
- }
- else
- for (let d = A + c; d < f; d += c) {
- const p = ut.getPointOnEllipticalArc(l.points[0], l.points[1], l.points[2], l.points[3], d, 0);
- t.push(p.x, p.y);
- }
- } else if (l.command === "C")
- for (let d = 0; d <= 1; d += 0.01) {
- const p = ut.getPointOnCubicBezier(d, l.start.x, l.start.y, l.points[0], l.points[1], l.points[2], l.points[3], l.points[4], l.points[5]);
- t.push(p.x, p.y);
- }
- else
- t = t.concat(l.points);
- });
- for (var e = t[0], i = t[0], n = t[1], r = t[1], a, o, h = 0; h < t.length / 2; h++)
- a = t[h * 2], o = t[h * 2 + 1], isNaN(a) || (e = Math.min(e, a), i = Math.max(i, a)), isNaN(o) || (n = Math.min(n, o), r = Math.max(r, o));
- return {
- x: e,
- y: n,
- width: i - e,
- height: r - n
- };
- }
- getLength() {
- return this.pathLength;
- }
- getPointAtLength(t) {
- return ut.getPointAtLengthOfDataArray(t, this.dataArray);
- }
- static getLineLength(t, e, i, n) {
- return Math.sqrt((i - t) * (i - t) + (n - e) * (n - e));
- }
- static getPathLength(t) {
- let e = 0;
- for (var i = 0; i < t.length; ++i)
- e += t[i].pathLength;
- return e;
- }
- static getPointAtLengthOfDataArray(t, e) {
- var i, n = 0, r = e.length;
- if (!r)
- return null;
- for (; n < r && t > e[n].pathLength; )
- t -= e[n].pathLength, ++n;
- if (n === r)
- return i = e[n - 1].points.slice(-2), {
- x: i[0],
- y: i[1]
- };
- if (t < 0.01)
- return i = e[n].points.slice(0, 2), {
- x: i[0],
- y: i[1]
- };
- var a = e[n], o = a.points;
- switch (a.command) {
- case "L":
- return ut.getPointOnLine(t, a.start.x, a.start.y, o[0], o[1]);
- case "C":
- return ut.getPointOnCubicBezier((0, Ge.t2length)(t, ut.getPathLength(e), (p) => (0, Ge.getCubicArcLength)([a.start.x, o[0], o[2], o[4]], [a.start.y, o[1], o[3], o[5]], p)), a.start.x, a.start.y, o[0], o[1], o[2], o[3], o[4], o[5]);
- case "Q":
- return ut.getPointOnQuadraticBezier((0, Ge.t2length)(t, ut.getPathLength(e), (p) => (0, Ge.getQuadraticArcLength)([a.start.x, o[0], o[2]], [a.start.y, o[1], o[3]], p)), a.start.x, a.start.y, o[0], o[1], o[2], o[3]);
- case "A":
- var h = o[0], l = o[1], A = o[2], u = o[3], f = o[4], c = o[5], d = o[6];
- return f += c * t / a.pathLength, ut.getPointOnEllipticalArc(h, l, A, u, f, d);
- }
- return null;
- }
- static getPointOnLine(t, e, i, n, r, a, o) {
- a === void 0 && (a = e), o === void 0 && (o = i);
- var h = (r - i) / (n - e + 1e-8), l = Math.sqrt(t * t / (1 + h * h));
- n < e && (l *= -1);
- var A = h * l, u;
- if (n === e)
- u = {
- x: a,
- y: o + A
- };
- else if ((o - i) / (a - e + 1e-8) === h)
- u = {
- x: a + l,
- y: o + A
- };
- else {
- var f, c, d = this.getLineLength(e, i, n, r), p = (a - e) * (n - e) + (o - i) * (r - i);
- p = p / (d * d), f = e + p * (n - e), c = i + p * (r - i);
- var m = this.getLineLength(a, o, f, c), v = Math.sqrt(t * t - m * m);
- l = Math.sqrt(v * v / (1 + h * h)), n < e && (l *= -1), A = h * l, u = {
- x: f + l,
- y: c + A
- };
- }
- return u;
- }
- static getPointOnCubicBezier(t, e, i, n, r, a, o, h, l) {
- function A(m) {
- return m * m * m;
- }
- function u(m) {
- return 3 * m * m * (1 - m);
- }
- function f(m) {
- return 3 * m * (1 - m) * (1 - m);
- }
- function c(m) {
- return (1 - m) * (1 - m) * (1 - m);
- }
- var d = h * A(t) + a * u(t) + n * f(t) + e * c(t), p = l * A(t) + o * u(t) + r * f(t) + i * c(t);
- return {
- x: d,
- y: p
- };
- }
- static getPointOnQuadraticBezier(t, e, i, n, r, a, o) {
- function h(c) {
- return c * c;
- }
- function l(c) {
- return 2 * c * (1 - c);
- }
- function A(c) {
- return (1 - c) * (1 - c);
- }
- var u = a * h(t) + n * l(t) + e * A(t), f = o * h(t) + r * l(t) + i * A(t);
- return {
- x: u,
- y: f
- };
- }
- static getPointOnEllipticalArc(t, e, i, n, r, a) {
- var o = Math.cos(a), h = Math.sin(a), l = {
- x: i * Math.cos(r),
- y: n * Math.sin(r)
- };
- return {
- x: t + (l.x * o - l.y * h),
- y: e + (l.x * h + l.y * o)
- };
- }
- static parsePathData(t) {
- if (!t)
- return [];
- var e = t, i = [
- "m",
- "M",
- "l",
- "L",
- "v",
- "V",
- "h",
- "H",
- "z",
- "Z",
- "c",
- "C",
- "q",
- "Q",
- "t",
- "T",
- "s",
- "S",
- "a",
- "A"
- ];
- e = e.replace(new RegExp(" ", "g"), ",");
- for (var n = 0; n < i.length; n++)
- e = e.replace(new RegExp(i[n], "g"), "|" + i[n]);
- var r = e.split("|"), a = [], o = [], h = 0, l = 0, A = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi, u;
- for (n = 1; n < r.length; n++) {
- var f = r[n], c = f.charAt(0);
- for (f = f.slice(1), o.length = 0; u = A.exec(f); )
- o.push(u[0]);
- for (var d = [], p = 0, m = o.length; p < m; p++) {
- if (o[p] === "00") {
- d.push(0, 0);
- continue;
- }
- var v = parseFloat(o[p]);
- isNaN(v) ? d.push(0) : d.push(v);
- }
- for (; d.length > 0 && !isNaN(d[0]); ) {
- var _ = "", g = [], y = h, x = l, b, C, w, E, S, P, k, F, L, I;
- switch (c) {
- case "l":
- h += d.shift(), l += d.shift(), _ = "L", g.push(h, l);
- break;
- case "L":
- h = d.shift(), l = d.shift(), g.push(h, l);
- break;
- case "m":
- var z = d.shift(), T = d.shift();
- if (h += z, l += T, _ = "M", a.length > 2 && a[a.length - 1].command === "z") {
- for (var G = a.length - 2; G >= 0; G--)
- if (a[G].command === "M") {
- h = a[G].points[0] + z, l = a[G].points[1] + T;
- break;
- }
- }
- g.push(h, l), c = "l";
- break;
- case "M":
- h = d.shift(), l = d.shift(), _ = "M", g.push(h, l), c = "L";
- break;
- case "h":
- h += d.shift(), _ = "L", g.push(h, l);
- break;
- case "H":
- h = d.shift(), _ = "L", g.push(h, l);
- break;
- case "v":
- l += d.shift(), _ = "L", g.push(h, l);
- break;
- case "V":
- l = d.shift(), _ = "L", g.push(h, l);
- break;
- case "C":
- g.push(d.shift(), d.shift(), d.shift(), d.shift()), h = d.shift(), l = d.shift(), g.push(h, l);
- break;
- case "c":
- g.push(h + d.shift(), l + d.shift(), h + d.shift(), l + d.shift()), h += d.shift(), l += d.shift(), _ = "C", g.push(h, l);
- break;
- case "S":
- C = h, w = l, b = a[a.length - 1], b.command === "C" && (C = h + (h - b.points[2]), w = l + (l - b.points[3])), g.push(C, w, d.shift(), d.shift()), h = d.shift(), l = d.shift(), _ = "C", g.push(h, l);
- break;
- case "s":
- C = h, w = l, b = a[a.length - 1], b.command === "C" && (C = h + (h - b.points[2]), w = l + (l - b.points[3])), g.push(C, w, h + d.shift(), l + d.shift()), h += d.shift(), l += d.shift(), _ = "C", g.push(h, l);
- break;
- case "Q":
- g.push(d.shift(), d.shift()), h = d.shift(), l = d.shift(), g.push(h, l);
- break;
- case "q":
- g.push(h + d.shift(), l + d.shift()), h += d.shift(), l += d.shift(), _ = "Q", g.push(h, l);
- break;
- case "T":
- C = h, w = l, b = a[a.length - 1], b.command === "Q" && (C = h + (h - b.points[0]), w = l + (l - b.points[1])), h = d.shift(), l = d.shift(), _ = "Q", g.push(C, w, h, l);
- break;
- case "t":
- C = h, w = l, b = a[a.length - 1], b.command === "Q" && (C = h + (h - b.points[0]), w = l + (l - b.points[1])), h += d.shift(), l += d.shift(), _ = "Q", g.push(C, w, h, l);
- break;
- case "A":
- E = d.shift(), S = d.shift(), P = d.shift(), k = d.shift(), F = d.shift(), L = h, I = l, h = d.shift(), l = d.shift(), _ = "A", g = this.convertEndpointToCenterParameterization(L, I, h, l, k, F, E, S, P);
- break;
- case "a":
- E = d.shift(), S = d.shift(), P = d.shift(), k = d.shift(), F = d.shift(), L = h, I = l, h += d.shift(), l += d.shift(), _ = "A", g = this.convertEndpointToCenterParameterization(L, I, h, l, k, F, E, S, P);
- break;
- }
- a.push({
- command: _ || c,
- points: g,
- start: {
- x: y,
- y: x
- },
- pathLength: this.calcLength(y, x, _ || c, g)
- });
- }
- (c === "z" || c === "Z") && a.push({
- command: "z",
- points: [],
- start: void 0,
- pathLength: 0
- });
- }
- return a;
- }
- static calcLength(t, e, i, n) {
- var r, a, o, h, l = ut;
- switch (i) {
- case "L":
- return l.getLineLength(t, e, n[0], n[1]);
- case "C":
- return (0, Ge.getCubicArcLength)([t, n[0], n[2], n[4]], [e, n[1], n[3], n[5]], 1);
- case "Q":
- return (0, Ge.getQuadraticArcLength)([t, n[0], n[2]], [e, n[1], n[3]], 1);
- case "A":
- r = 0;
- var A = n[4], u = n[5], f = n[4] + u, c = Math.PI / 180;
- if (Math.abs(A - f) < c && (c = Math.abs(A - f)), a = l.getPointOnEllipticalArc(n[0], n[1], n[2], n[3], A, 0), u < 0)
- for (h = A - c; h > f; h -= c)
- o = l.getPointOnEllipticalArc(n[0], n[1], n[2], n[3], h, 0), r += l.getLineLength(a.x, a.y, o.x, o.y), a = o;
- else
- for (h = A + c; h < f; h += c)
- o = l.getPointOnEllipticalArc(n[0], n[1], n[2], n[3], h, 0), r += l.getLineLength(a.x, a.y, o.x, o.y), a = o;
- return o = l.getPointOnEllipticalArc(n[0], n[1], n[2], n[3], f, 0), r += l.getLineLength(a.x, a.y, o.x, o.y), r;
- }
- return 0;
- }
- static convertEndpointToCenterParameterization(t, e, i, n, r, a, o, h, l) {
- var A = l * (Math.PI / 180), u = Math.cos(A) * (t - i) / 2 + Math.sin(A) * (e - n) / 2, f = -1 * Math.sin(A) * (t - i) / 2 + Math.cos(A) * (e - n) / 2, c = u * u / (o * o) + f * f / (h * h);
- c > 1 && (o *= Math.sqrt(c), h *= Math.sqrt(c));
- var d = Math.sqrt((o * o * (h * h) - o * o * (f * f) - h * h * (u * u)) / (o * o * (f * f) + h * h * (u * u)));
- r === a && (d *= -1), isNaN(d) && (d = 0);
- var p = d * o * f / h, m = d * -h * u / o, v = (t + i) / 2 + Math.cos(A) * p - Math.sin(A) * m, _ = (e + n) / 2 + Math.sin(A) * p + Math.cos(A) * m, g = function(S) {
- return Math.sqrt(S[0] * S[0] + S[1] * S[1]);
- }, y = function(S, P) {
- return (S[0] * P[0] + S[1] * P[1]) / (g(S) * g(P));
- }, x = function(S, P) {
- return (S[0] * P[1] < S[1] * P[0] ? -1 : 1) * Math.acos(y(S, P));
- }, b = x([1, 0], [(u - p) / o, (f - m) / h]), C = [(u - p) / o, (f - m) / h], w = [(-1 * u - p) / o, (-1 * f - m) / h], E = x(C, w);
- return y(C, w) <= -1 && (E = Math.PI), y(C, w) >= 1 && (E = 0), a === 0 && E > 0 && (E = E - 2 * Math.PI), a === 1 && E < 0 && (E = E + 2 * Math.PI), [v, _, o, h, b, E, A, a];
- }
- }
- Ci = hi.Path = ut;
- ut.prototype.className = "Path";
- ut.prototype._attrsAffectingSize = ["data"];
- (0, pl._registerNode)(ut);
- fl.Factory.addGetterSetter(ut, "data");
- var Bi = {};
- Object.defineProperty(Bi, "__esModule", { value: !0 });
- var ro = Bi.Rect = void 0;
- const yl = V, ml = ft, vl = $, _l = st, xl = O;
- class Dn extends ml.Shape {
- _sceneFunc(t) {
- var e = this.cornerRadius(), i = this.width(), n = this.height();
- t.beginPath(), e ? _l.Util.drawRoundedRectPath(t, i, n, e) : t.rect(0, 0, i, n), t.closePath(), t.fillStrokeShape(this);
- }
- }
- ro = Bi.Rect = Dn;
- Dn.prototype.className = "Rect";
- (0, vl._registerNode)(Dn);
- yl.Factory.addGetterSetter(Dn, "cornerRadius", 0, (0, xl.getNumberOrArrayOfNumbersValidator)(4));
- const be = (s, t = !1) => {
- let e = s;
- const i = t ? s.getTransform().copy() : new st.Transform();
- for (; e = e.parent; )
- i.multiply(e.getTransform());
- return i;
- };
- function ju(s) {
- const [t, e, i, n] = s.m, r = Math.sqrt(t * t + i * i), a = Math.sqrt(e * e + n * n), o = Math.atan2(i, t), h = o, l = o + Math.PI / 2;
- return console.log(h, l), { x: r, y: a };
- }
- const Gt = (s, t, e = !1) => {
- let i = s, n = e ? s.scale() : { x: 1, y: 1 };
- for (; i = i.parent; ) {
- const r = i.scale();
- n.x *= r.x, n.y *= r.y;
- }
- return [t[0] / n.x, t[1] / n.y];
- };
- var li = {}, Ee = {};
- Object.defineProperty(Ee, "__esModule", { value: !0 });
- Ee.Container = void 0;
- const Ai = V, Ss = rt, In = O;
- let Fe = class extends Ss.Node {
- constructor() {
- super(...arguments), this.children = [];
- }
- getChildren(t) {
- if (!t)
- return this.children || [];
- const e = this.children || [];
- var i = [];
- return e.forEach(function(n) {
- t(n) && i.push(n);
- }), i;
- }
- hasChildren() {
- return this.getChildren().length > 0;
- }
- removeChildren() {
- return this.getChildren().forEach((t) => {
- t.parent = null, t.index = 0, t.remove();
- }), this.children = [], this._requestDraw(), this;
- }
- destroyChildren() {
- return this.getChildren().forEach((t) => {
- t.parent = null, t.index = 0, t.destroy();
- }), this.children = [], this._requestDraw(), this;
- }
- add(...t) {
- if (t.length === 0)
- return this;
- if (t.length > 1) {
- for (var e = 0; e < t.length; e++)
- this.add(t[e]);
- return this;
- }
- const i = t[0];
- return i.getParent() ? (i.moveTo(this), this) : (this._validateAdd(i), i.index = this.getChildren().length, i.parent = this, i._clearCaches(), this.getChildren().push(i), this._fire("add", {
- child: i
- }), this._requestDraw(), this);
- }
- destroy() {
- return this.hasChildren() && this.destroyChildren(), super.destroy(), this;
- }
- find(t) {
- return this._generalFind(t, !1);
- }
- findOne(t) {
- var e = this._generalFind(t, !0);
- return e.length > 0 ? e[0] : void 0;
- }
- _generalFind(t, e) {
- var i = [];
- return this._descendants((n) => {
- const r = n._isMatch(t);
- return r && i.push(n), !!(r && e);
- }), i;
- }
- _descendants(t) {
- let e = !1;
- const i = this.getChildren();
- for (const n of i) {
- if (e = t(n), e)
- return !0;
- if (n.hasChildren() && (e = n._descendants(t), e))
- return !0;
- }
- return !1;
- }
- toObject() {
- var t = Ss.Node.prototype.toObject.call(this);
- return t.children = [], this.getChildren().forEach((e) => {
- t.children.push(e.toObject());
- }), t;
- }
- isAncestorOf(t) {
- for (var e = t.getParent(); e; ) {
- if (e._id === this._id)
- return !0;
- e = e.getParent();
- }
- return !1;
- }
- clone(t) {
- var e = Ss.Node.prototype.clone.call(this, t);
- return this.getChildren().forEach(function(i) {
- e.add(i.clone());
- }), e;
- }
- getAllIntersections(t) {
- var e = [];
- return this.find("Shape").forEach((i) => {
- i.isVisible() && i.intersects(t) && e.push(i);
- }), e;
- }
- _clearSelfAndDescendantCache(t) {
- var e;
- super._clearSelfAndDescendantCache(t), !this.isCached() && ((e = this.children) === null || e === void 0 || e.forEach(function(i) {
- i._clearSelfAndDescendantCache(t);
- }));
- }
- _setChildrenIndices() {
- var t;
- (t = this.children) === null || t === void 0 || t.forEach(function(e, i) {
- e.index = i;
- }), this._requestDraw();
- }
- drawScene(t, e, i) {
- var n = this.getLayer(), r = t || n && n.getCanvas(), a = r && r.getContext(), o = this._getCanvasCache(), h = o && o.scene, l = r && r.isCache;
- if (!this.isVisible() && !l)
- return this;
- if (h) {
- a.save();
- var A = this.getAbsoluteTransform(e).getMatrix();
- a.transform(A[0], A[1], A[2], A[3], A[4], A[5]), this._drawCachedSceneCanvas(a), a.restore();
- } else
- this._drawChildren("drawScene", r, e, i);
- return this;
- }
- drawHit(t, e) {
- if (!this.shouldDrawHit(e))
- return this;
- var i = this.getLayer(), n = t || i && i.hitCanvas, r = n && n.getContext(), a = this._getCanvasCache(), o = a && a.hit;
- if (o) {
- r.save();
- var h = this.getAbsoluteTransform(e).getMatrix();
- r.transform(h[0], h[1], h[2], h[3], h[4], h[5]), this._drawCachedHitCanvas(r), r.restore();
- } else
- this._drawChildren("drawHit", n, e);
- return this;
- }
- _drawChildren(t, e, i, n) {
- var r, a = e && e.getContext(), o = this.clipWidth(), h = this.clipHeight(), l = this.clipFunc(), A = typeof o == "number" && typeof h == "number" || l;
- const u = i === this;
- if (A) {
- a.save();
- var f = this.getAbsoluteTransform(i), c = f.getMatrix();
- a.transform(c[0], c[1], c[2], c[3], c[4], c[5]), a.beginPath();
- let v;
- if (l)
- v = l.call(this, a, this);
- else {
- var d = this.clipX(), p = this.clipY();
- a.rect(d || 0, p || 0, o, h);
- }
- a.clip.apply(a, v), c = f.copy().invert().getMatrix(), a.transform(c[0], c[1], c[2], c[3], c[4], c[5]);
- }
- var m = !u && this.globalCompositeOperation() !== "source-over" && t === "drawScene";
- m && (a.save(), a._applyGlobalCompositeOperation(this)), (r = this.children) === null || r === void 0 || r.forEach(function(v) {
- v[t](e, i, n);
- }), m && a.restore(), A && a.restore();
- }
- getClientRect(t = {}) {
- var e, i = t.skipTransform, n = t.relativeTo, r, a, o, h, l = {
- x: 1 / 0,
- y: 1 / 0,
- width: 0,
- height: 0
- }, A = this;
- (e = this.children) === null || e === void 0 || e.forEach(function(p) {
- if (p.visible()) {
- var m = p.getClientRect({
- relativeTo: A,
- skipShadow: t.skipShadow,
- skipStroke: t.skipStroke
- });
- m.width === 0 && m.height === 0 || (r === void 0 ? (r = m.x, a = m.y, o = m.x + m.width, h = m.y + m.height) : (r = Math.min(r, m.x), a = Math.min(a, m.y), o = Math.max(o, m.x + m.width), h = Math.max(h, m.y + m.height)));
- }
- });
- for (var u = this.find("Shape"), f = !1, c = 0; c < u.length; c++) {
- var d = u[c];
- if (d._isVisible(this)) {
- f = !0;
- break;
- }
- }
- return f && r !== void 0 ? l = {
- x: r,
- y: a,
- width: o - r,
- height: h - a
- } : l = {
- x: 0,
- y: 0,
- width: 0,
- height: 0
- }, i ? l : this._transformedRect(l, n);
- }
- };
- Ee.Container = Fe;
- Ai.Factory.addComponentsGetterSetter(Fe, "clip", [
- "x",
- "y",
- "width",
- "height"
- ]);
- Ai.Factory.addGetterSetter(Fe, "clipX", void 0, (0, In.getNumberValidator)());
- Ai.Factory.addGetterSetter(Fe, "clipY", void 0, (0, In.getNumberValidator)());
- Ai.Factory.addGetterSetter(Fe, "clipWidth", void 0, (0, In.getNumberValidator)());
- Ai.Factory.addGetterSetter(Fe, "clipHeight", void 0, (0, In.getNumberValidator)());
- Ai.Factory.addGetterSetter(Fe, "clipFunc");
- Object.defineProperty(li, "__esModule", { value: !0 });
- var Nt = li.Group = void 0;
- const bl = st, wl = Ee, Sl = $;
- class cr extends wl.Container {
- _validateAdd(t) {
- var e = t.getType();
- e !== "Group" && e !== "Shape" && bl.Util.throw("You may only add groups and shapes to groups.");
- }
- }
- Nt = li.Group = cr;
- cr.prototype.nodeType = "Group";
- (0, Sl._registerNode)(cr);
- const Yr = document.createElement("div"), Cl = (s) => {
- Yr.innerHTML = s;
- const t = Yr.querySelector("svg"), e = [t.width.baseVal.value, t.height.baseVal.value];
- return {
- paths: Array.from(t.querySelectorAll("path")).map((r) => {
- const a = r.getAttribute("fill"), o = r.getAttribute("d"), h = r.getAttribute("stroke"), l = r.getAttribute("stroke-width");
- return {
- fill: a,
- data: o,
- stroke: h,
- strokeWidth: l && Number(l)
- };
- }),
- size: e
- };
- }, Ml = (s, t = !1) => {
- const e = s.size, n = (s.realWidth || s.size[0]) / e[0], r = e.map((m) => m * n), a = (s.offset || [0, 0]).map((m) => m * n), o = s.strokeWidth ? s.strokeWidth * n : 1, h = s.strokeColor || "#000", l = s.paths.map((m) => typeof m == "string" ? {
- strokeWidth: o,
- stroke: h,
- fill: h,
- data: m
- } : m), A = l.map(
- (m, v) => new Ci({
- data: m.data,
- id: `path-${v}`,
- name: "path",
- strokeScaleEnabled: !!s.fixed,
- scale: { x: n, y: n }
- })
- ), u = () => {
- A.forEach((m, v) => {
- const _ = l[v];
- _.fill && m.fill(_.fill), _.stroke && m.stroke(_.stroke), _.strokeWidth && m.strokeWidth(_.strokeWidth);
- });
- }, f = new ro({
- x: a[0],
- y: a[1],
- name: "rect",
- width: r[0],
- height: r[1],
- fill: `rgba(0, 0, 0, ${t ? 0.3 : 0})`
- }), c = () => {
- let [m, v] = Gt(p, [1, 1]);
- p.scale({ x: m, y: v });
- }, d = new Nt();
- d.add(...A, f), d.x(-r[0] / 2), d.y(-r[1] / 2);
- const p = new Nt();
- return p.add(d), {
- getSize: () => {
- const m = f.getSize();
- if (s.fixed) {
- let [v] = Gt(p, [1, 1]);
- return [m.width * v, m.height * v];
- }
- return [m.width, m.height];
- },
- shape: p,
- setData(m) {
- p.position(m), s.fixed && c(), m.rotate && p.rotation(m.rotate);
- },
- common: u
- };
- }, ao = (s) => {
- const e = s.evt.target.getBoundingClientRect(), i = s.evt.changedTouches[0].pageX - e.left, n = s.evt.changedTouches[0].pageY - e.top;
- return {
- offsetX: i,
- offsetY: n
- };
- };
- /**
- * @license
- * Copyright 2010-2024 Three.js Authors
- * SPDX-License-Identifier: MIT
- */
- const oo = "164", ho = 300, Xr = 1e3, Yi = 1001, jr = 1002, qr = 1003, Pl = 1006, El = 1008, Fl = 1009, kl = 1014, Dl = 1020, Il = 1023, Cs = 1026, Qr = 1027, lo = "", le = "srgb", dr = "srgb-linear", Tl = "display-p3", Ao = "display-p3-linear", Qs = "linear", Kr = "srgb", Zr = "rec709", Jr = "p3", Ll = 515, Xi = 2e3, ta = 2001;
- class co {
- addEventListener(t, e) {
- this._listeners === void 0 && (this._listeners = {});
- const i = this._listeners;
- i[t] === void 0 && (i[t] = []), i[t].indexOf(e) === -1 && i[t].push(e);
- }
- hasEventListener(t, e) {
- if (this._listeners === void 0)
- return !1;
- const i = this._listeners;
- return i[t] !== void 0 && i[t].indexOf(e) !== -1;
- }
- removeEventListener(t, e) {
- if (this._listeners === void 0)
- return;
- const n = this._listeners[t];
- if (n !== void 0) {
- const r = n.indexOf(e);
- r !== -1 && n.splice(r, 1);
- }
- }
- dispatchEvent(t) {
- if (this._listeners === void 0)
- return;
- const i = this._listeners[t.type];
- if (i !== void 0) {
- t.target = this;
- const n = i.slice(0);
- for (let r = 0, a = n.length; r < a; r++)
- n[r].call(this, t);
- t.target = null;
- }
- }
- }
- const pt = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"];
- let ea = 1234567;
- const uo = Math.PI / 180, fo = 180 / Math.PI;
- function Tn() {
- const s = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, i = Math.random() * 4294967295 | 0;
- return (pt[s & 255] + pt[s >> 8 & 255] + pt[s >> 16 & 255] + pt[s >> 24 & 255] + "-" + pt[t & 255] + pt[t >> 8 & 255] + "-" + pt[t >> 16 & 15 | 64] + pt[t >> 24 & 255] + "-" + pt[e & 63 | 128] + pt[e >> 8 & 255] + "-" + pt[e >> 16 & 255] + pt[e >> 24 & 255] + pt[i & 255] + pt[i >> 8 & 255] + pt[i >> 16 & 255] + pt[i >> 24 & 255]).toLowerCase();
- }
- function mt(s, t, e) {
- return Math.max(t, Math.min(e, s));
- }
- function ur(s, t) {
- return (s % t + t) % t;
- }
- function Rl(s, t, e, i, n) {
- return i + (s - t) * (n - i) / (e - t);
- }
- function Ol(s, t, e) {
- return s !== t ? (e - s) / (t - s) : 0;
- }
- function Mi(s, t, e) {
- return (1 - e) * s + e * t;
- }
- function Nl(s, t, e, i) {
- return Mi(s, t, 1 - Math.exp(-e * i));
- }
- function Gl(s, t = 1) {
- return t - Math.abs(ur(s, t * 2) - t);
- }
- function Bl(s, t, e) {
- return s <= t ? 0 : s >= e ? 1 : (s = (s - t) / (e - t), s * s * (3 - 2 * s));
- }
- function zl(s, t, e) {
- return s <= t ? 0 : s >= e ? 1 : (s = (s - t) / (e - t), s * s * s * (s * (s * 6 - 15) + 10));
- }
- function Ul(s, t) {
- return s + Math.floor(Math.random() * (t - s + 1));
- }
- function Hl(s, t) {
- return s + Math.random() * (t - s);
- }
- function Vl(s) {
- return s * (0.5 - Math.random());
- }
- function $l(s) {
- s !== void 0 && (ea = s);
- let t = ea += 1831565813;
- return t = Math.imul(t ^ t >>> 15, t | 1), t ^= t + Math.imul(t ^ t >>> 7, t | 61), ((t ^ t >>> 14) >>> 0) / 4294967296;
- }
- function Wl(s) {
- return s * uo;
- }
- function Yl(s) {
- return s * fo;
- }
- function Xl(s) {
- return (s & s - 1) === 0 && s !== 0;
- }
- function jl(s) {
- return Math.pow(2, Math.ceil(Math.log(s) / Math.LN2));
- }
- function ql(s) {
- return Math.pow(2, Math.floor(Math.log(s) / Math.LN2));
- }
- function Ql(s, t, e, i, n) {
- const r = Math.cos, a = Math.sin, o = r(e / 2), h = a(e / 2), l = r((t + i) / 2), A = a((t + i) / 2), u = r((t - i) / 2), f = a((t - i) / 2), c = r((i - t) / 2), d = a((i - t) / 2);
- switch (n) {
- case "XYX":
- s.set(o * A, h * u, h * f, o * l);
- break;
- case "YZY":
- s.set(h * f, o * A, h * u, o * l);
- break;
- case "ZXZ":
- s.set(h * u, h * f, o * A, o * l);
- break;
- case "XZX":
- s.set(o * A, h * d, h * c, o * l);
- break;
- case "YXY":
- s.set(h * c, o * A, h * d, o * l);
- break;
- case "ZYZ":
- s.set(h * d, h * c, o * A, o * l);
- break;
- default:
- console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + n);
- }
- }
- function Kl(s, t) {
- switch (t.constructor) {
- case Float32Array:
- return s;
- case Uint32Array:
- return s / 4294967295;
- case Uint16Array:
- return s / 65535;
- case Uint8Array:
- return s / 255;
- case Int32Array:
- return Math.max(s / 2147483647, -1);
- case Int16Array:
- return Math.max(s / 32767, -1);
- case Int8Array:
- return Math.max(s / 127, -1);
- default:
- throw new Error("Invalid component type.");
- }
- }
- function Zl(s, t) {
- switch (t.constructor) {
- case Float32Array:
- return s;
- case Uint32Array:
- return Math.round(s * 4294967295);
- case Uint16Array:
- return Math.round(s * 65535);
- case Uint8Array:
- return Math.round(s * 255);
- case Int32Array:
- return Math.round(s * 2147483647);
- case Int16Array:
- return Math.round(s * 32767);
- case Int8Array:
- return Math.round(s * 127);
- default:
- throw new Error("Invalid component type.");
- }
- }
- const Se = {
- DEG2RAD: uo,
- RAD2DEG: fo,
- generateUUID: Tn,
- clamp: mt,
- euclideanModulo: ur,
- mapLinear: Rl,
- inverseLerp: Ol,
- lerp: Mi,
- damp: Nl,
- pingpong: Gl,
- smoothstep: Bl,
- smootherstep: zl,
- randInt: Ul,
- randFloat: Hl,
- randFloatSpread: Vl,
- seededRandom: $l,
- degToRad: Wl,
- radToDeg: Yl,
- isPowerOfTwo: Xl,
- ceilPowerOfTwo: jl,
- floorPowerOfTwo: ql,
- setQuaternionFromProperEuler: Ql,
- normalize: Zl,
- denormalize: Kl
- };
- class X {
- constructor(t = 0, e = 0) {
- X.prototype.isVector2 = !0, this.x = t, this.y = e;
- }
- get width() {
- return this.x;
- }
- set width(t) {
- this.x = t;
- }
- get height() {
- return this.y;
- }
- set height(t) {
- this.y = t;
- }
- set(t, e) {
- return this.x = t, this.y = e, this;
- }
- setScalar(t) {
- return this.x = t, this.y = t, this;
- }
- setX(t) {
- return this.x = t, this;
- }
- setY(t) {
- return this.y = t, this;
- }
- setComponent(t, e) {
- switch (t) {
- case 0:
- this.x = e;
- break;
- case 1:
- this.y = e;
- break;
- default:
- throw new Error("index is out of range: " + t);
- }
- return this;
- }
- getComponent(t) {
- switch (t) {
- case 0:
- return this.x;
- case 1:
- return this.y;
- default:
- throw new Error("index is out of range: " + t);
- }
- }
- clone() {
- return new this.constructor(this.x, this.y);
- }
- copy(t) {
- return this.x = t.x, this.y = t.y, this;
- }
- add(t) {
- return this.x += t.x, this.y += t.y, this;
- }
- addScalar(t) {
- return this.x += t, this.y += t, this;
- }
- addVectors(t, e) {
- return this.x = t.x + e.x, this.y = t.y + e.y, this;
- }
- addScaledVector(t, e) {
- return this.x += t.x * e, this.y += t.y * e, this;
- }
- sub(t) {
- return this.x -= t.x, this.y -= t.y, this;
- }
- subScalar(t) {
- return this.x -= t, this.y -= t, this;
- }
- subVectors(t, e) {
- return this.x = t.x - e.x, this.y = t.y - e.y, this;
- }
- multiply(t) {
- return this.x *= t.x, this.y *= t.y, this;
- }
- multiplyScalar(t) {
- return this.x *= t, this.y *= t, this;
- }
- divide(t) {
- return this.x /= t.x, this.y /= t.y, this;
- }
- divideScalar(t) {
- return this.multiplyScalar(1 / t);
- }
- applyMatrix3(t) {
- const e = this.x, i = this.y, n = t.elements;
- return this.x = n[0] * e + n[3] * i + n[6], this.y = n[1] * e + n[4] * i + n[7], this;
- }
- min(t) {
- return this.x = Math.min(this.x, t.x), this.y = Math.min(this.y, t.y), this;
- }
- max(t) {
- return this.x = Math.max(this.x, t.x), this.y = Math.max(this.y, t.y), this;
- }
- clamp(t, e) {
- return this.x = Math.max(t.x, Math.min(e.x, this.x)), this.y = Math.max(t.y, Math.min(e.y, this.y)), this;
- }
- clampScalar(t, e) {
- return this.x = Math.max(t, Math.min(e, this.x)), this.y = Math.max(t, Math.min(e, this.y)), this;
- }
- clampLength(t, e) {
- const i = this.length();
- return this.divideScalar(i || 1).multiplyScalar(Math.max(t, Math.min(e, i)));
- }
- floor() {
- return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this;
- }
- ceil() {
- return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this;
- }
- round() {
- return this.x = Math.round(this.x), this.y = Math.round(this.y), this;
- }
- roundToZero() {
- return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this;
- }
- negate() {
- return this.x = -this.x, this.y = -this.y, this;
- }
- dot(t) {
- return this.x * t.x + this.y * t.y;
- }
- cross(t) {
- return this.x * t.y - this.y * t.x;
- }
- lengthSq() {
- return this.x * this.x + this.y * this.y;
- }
- length() {
- return Math.sqrt(this.x * this.x + this.y * this.y);
- }
- manhattanLength() {
- return Math.abs(this.x) + Math.abs(this.y);
- }
- normalize() {
- return this.divideScalar(this.length() || 1);
- }
- angle() {
- return Math.atan2(-this.y, -this.x) + Math.PI;
- }
- angleTo(t) {
- const e = Math.sqrt(this.lengthSq() * t.lengthSq());
- if (e === 0)
- return Math.PI / 2;
- const i = this.dot(t) / e;
- return Math.acos(mt(i, -1, 1));
- }
- distanceTo(t) {
- return Math.sqrt(this.distanceToSquared(t));
- }
- distanceToSquared(t) {
- const e = this.x - t.x, i = this.y - t.y;
- return e * e + i * i;
- }
- manhattanDistanceTo(t) {
- return Math.abs(this.x - t.x) + Math.abs(this.y - t.y);
- }
- setLength(t) {
- return this.normalize().multiplyScalar(t);
- }
- lerp(t, e) {
- return this.x += (t.x - this.x) * e, this.y += (t.y - this.y) * e, this;
- }
- lerpVectors(t, e, i) {
- return this.x = t.x + (e.x - t.x) * i, this.y = t.y + (e.y - t.y) * i, this;
- }
- equals(t) {
- return t.x === this.x && t.y === this.y;
- }
- fromArray(t, e = 0) {
- return this.x = t[e], this.y = t[e + 1], this;
- }
- toArray(t = [], e = 0) {
- return t[e] = this.x, t[e + 1] = this.y, t;
- }
- fromBufferAttribute(t, e) {
- return this.x = t.getX(e), this.y = t.getY(e), this;
- }
- rotateAround(t, e) {
- const i = Math.cos(e), n = Math.sin(e), r = this.x - t.x, a = this.y - t.y;
- return this.x = r * i - a * n + t.x, this.y = r * n + a * i + t.y, this;
- }
- random() {
- return this.x = Math.random(), this.y = Math.random(), this;
- }
- *[Symbol.iterator]() {
- yield this.x, yield this.y;
- }
- }
- class Jt {
- constructor(t, e, i, n, r, a, o, h, l) {
- Jt.prototype.isMatrix3 = !0, this.elements = [
- 1,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 1
- ], t !== void 0 && this.set(t, e, i, n, r, a, o, h, l);
- }
- set(t, e, i, n, r, a, o, h, l) {
- const A = this.elements;
- return A[0] = t, A[1] = n, A[2] = o, A[3] = e, A[4] = r, A[5] = h, A[6] = i, A[7] = a, A[8] = l, this;
- }
- identity() {
- return this.set(
- 1,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- copy(t) {
- const e = this.elements, i = t.elements;
- return e[0] = i[0], e[1] = i[1], e[2] = i[2], e[3] = i[3], e[4] = i[4], e[5] = i[5], e[6] = i[6], e[7] = i[7], e[8] = i[8], this;
- }
- extractBasis(t, e, i) {
- return t.setFromMatrix3Column(this, 0), e.setFromMatrix3Column(this, 1), i.setFromMatrix3Column(this, 2), this;
- }
- setFromMatrix4(t) {
- const e = t.elements;
- return this.set(
- e[0],
- e[4],
- e[8],
- e[1],
- e[5],
- e[9],
- e[2],
- e[6],
- e[10]
- ), this;
- }
- multiply(t) {
- return this.multiplyMatrices(this, t);
- }
- premultiply(t) {
- return this.multiplyMatrices(t, this);
- }
- multiplyMatrices(t, e) {
- const i = t.elements, n = e.elements, r = this.elements, a = i[0], o = i[3], h = i[6], l = i[1], A = i[4], u = i[7], f = i[2], c = i[5], d = i[8], p = n[0], m = n[3], v = n[6], _ = n[1], g = n[4], y = n[7], x = n[2], b = n[5], C = n[8];
- return r[0] = a * p + o * _ + h * x, r[3] = a * m + o * g + h * b, r[6] = a * v + o * y + h * C, r[1] = l * p + A * _ + u * x, r[4] = l * m + A * g + u * b, r[7] = l * v + A * y + u * C, r[2] = f * p + c * _ + d * x, r[5] = f * m + c * g + d * b, r[8] = f * v + c * y + d * C, this;
- }
- multiplyScalar(t) {
- const e = this.elements;
- return e[0] *= t, e[3] *= t, e[6] *= t, e[1] *= t, e[4] *= t, e[7] *= t, e[2] *= t, e[5] *= t, e[8] *= t, this;
- }
- determinant() {
- const t = this.elements, e = t[0], i = t[1], n = t[2], r = t[3], a = t[4], o = t[5], h = t[6], l = t[7], A = t[8];
- return e * a * A - e * o * l - i * r * A + i * o * h + n * r * l - n * a * h;
- }
- invert() {
- const t = this.elements, e = t[0], i = t[1], n = t[2], r = t[3], a = t[4], o = t[5], h = t[6], l = t[7], A = t[8], u = A * a - o * l, f = o * h - A * r, c = l * r - a * h, d = e * u + i * f + n * c;
- if (d === 0)
- return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
- const p = 1 / d;
- return t[0] = u * p, t[1] = (n * l - A * i) * p, t[2] = (o * i - n * a) * p, t[3] = f * p, t[4] = (A * e - n * h) * p, t[5] = (n * r - o * e) * p, t[6] = c * p, t[7] = (i * h - l * e) * p, t[8] = (a * e - i * r) * p, this;
- }
- transpose() {
- let t;
- const e = this.elements;
- return t = e[1], e[1] = e[3], e[3] = t, t = e[2], e[2] = e[6], e[6] = t, t = e[5], e[5] = e[7], e[7] = t, this;
- }
- getNormalMatrix(t) {
- return this.setFromMatrix4(t).invert().transpose();
- }
- transposeIntoArray(t) {
- const e = this.elements;
- return t[0] = e[0], t[1] = e[3], t[2] = e[6], t[3] = e[1], t[4] = e[4], t[5] = e[7], t[6] = e[2], t[7] = e[5], t[8] = e[8], this;
- }
- setUvTransform(t, e, i, n, r, a, o) {
- const h = Math.cos(r), l = Math.sin(r);
- return this.set(
- i * h,
- i * l,
- -i * (h * a + l * o) + a + t,
- -n * l,
- n * h,
- -n * (-l * a + h * o) + o + e,
- 0,
- 0,
- 1
- ), this;
- }
- //
- scale(t, e) {
- return this.premultiply(Ms.makeScale(t, e)), this;
- }
- rotate(t) {
- return this.premultiply(Ms.makeRotation(-t)), this;
- }
- translate(t, e) {
- return this.premultiply(Ms.makeTranslation(t, e)), this;
- }
- // for 2D Transforms
- makeTranslation(t, e) {
- return t.isVector2 ? this.set(
- 1,
- 0,
- t.x,
- 0,
- 1,
- t.y,
- 0,
- 0,
- 1
- ) : this.set(
- 1,
- 0,
- t,
- 0,
- 1,
- e,
- 0,
- 0,
- 1
- ), this;
- }
- makeRotation(t) {
- const e = Math.cos(t), i = Math.sin(t);
- return this.set(
- e,
- -i,
- 0,
- i,
- e,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- makeScale(t, e) {
- return this.set(
- t,
- 0,
- 0,
- 0,
- e,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- //
- equals(t) {
- const e = this.elements, i = t.elements;
- for (let n = 0; n < 9; n++)
- if (e[n] !== i[n])
- return !1;
- return !0;
- }
- fromArray(t, e = 0) {
- for (let i = 0; i < 9; i++)
- this.elements[i] = t[i + e];
- return this;
- }
- toArray(t = [], e = 0) {
- const i = this.elements;
- return t[e] = i[0], t[e + 1] = i[1], t[e + 2] = i[2], t[e + 3] = i[3], t[e + 4] = i[4], t[e + 5] = i[5], t[e + 6] = i[6], t[e + 7] = i[7], t[e + 8] = i[8], t;
- }
- clone() {
- return new this.constructor().fromArray(this.elements);
- }
- }
- const Ms = /* @__PURE__ */ new Jt();
- function ia(s) {
- return document.createElementNS("http://www.w3.org/1999/xhtml", s);
- }
- const na = /* @__PURE__ */ new Jt().set(
- 0.8224621,
- 0.177538,
- 0,
- 0.0331941,
- 0.9668058,
- 0,
- 0.0170827,
- 0.0723974,
- 0.9105199
- ), sa = /* @__PURE__ */ new Jt().set(
- 1.2249401,
- -0.2249404,
- 0,
- -0.0420569,
- 1.0420571,
- 0,
- -0.0196376,
- -0.0786361,
- 1.0982735
- ), ji = {
- [dr]: {
- transfer: Qs,
- primaries: Zr,
- toReference: (s) => s,
- fromReference: (s) => s
- },
- [le]: {
- transfer: Kr,
- primaries: Zr,
- toReference: (s) => s.convertSRGBToLinear(),
- fromReference: (s) => s.convertLinearToSRGB()
- },
- [Ao]: {
- transfer: Qs,
- primaries: Jr,
- toReference: (s) => s.applyMatrix3(sa),
- fromReference: (s) => s.applyMatrix3(na)
- },
- [Tl]: {
- transfer: Kr,
- primaries: Jr,
- toReference: (s) => s.convertSRGBToLinear().applyMatrix3(sa),
- fromReference: (s) => s.applyMatrix3(na).convertLinearToSRGB()
- }
- }, Jl = /* @__PURE__ */ new Set([dr, Ao]), Ft = {
- enabled: !0,
- _workingColorSpace: dr,
- get workingColorSpace() {
- return this._workingColorSpace;
- },
- set workingColorSpace(s) {
- if (!Jl.has(s))
- throw new Error(`Unsupported working color space, "${s}".`);
- this._workingColorSpace = s;
- },
- convert: function(s, t, e) {
- if (this.enabled === !1 || t === e || !t || !e)
- return s;
- const i = ji[t].toReference, n = ji[e].fromReference;
- return n(i(s));
- },
- fromWorkingColorSpace: function(s, t) {
- return this.convert(s, this._workingColorSpace, t);
- },
- toWorkingColorSpace: function(s, t) {
- return this.convert(s, t, this._workingColorSpace);
- },
- getPrimaries: function(s) {
- return ji[s].primaries;
- },
- getTransfer: function(s) {
- return s === lo ? Qs : ji[s].transfer;
- }
- };
- function Qe(s) {
- return s < 0.04045 ? s * 0.0773993808 : Math.pow(s * 0.9478672986 + 0.0521327014, 2.4);
- }
- function Ps(s) {
- return s < 31308e-7 ? s * 12.92 : 1.055 * Math.pow(s, 0.41666) - 0.055;
- }
- let Be;
- class tA {
- static getDataURL(t) {
- if (/^data:/i.test(t.src) || typeof HTMLCanvasElement > "u")
- return t.src;
- let e;
- if (t instanceof HTMLCanvasElement)
- e = t;
- else {
- Be === void 0 && (Be = ia("canvas")), Be.width = t.width, Be.height = t.height;
- const i = Be.getContext("2d");
- t instanceof ImageData ? i.putImageData(t, 0, 0) : i.drawImage(t, 0, 0, t.width, t.height), e = Be;
- }
- return e.width > 2048 || e.height > 2048 ? (console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons", t), e.toDataURL("image/jpeg", 0.6)) : e.toDataURL("image/png");
- }
- static sRGBToLinear(t) {
- if (typeof HTMLImageElement < "u" && t instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && t instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && t instanceof ImageBitmap) {
- const e = ia("canvas");
- e.width = t.width, e.height = t.height;
- const i = e.getContext("2d");
- i.drawImage(t, 0, 0, t.width, t.height);
- const n = i.getImageData(0, 0, t.width, t.height), r = n.data;
- for (let a = 0; a < r.length; a++)
- r[a] = Qe(r[a] / 255) * 255;
- return i.putImageData(n, 0, 0), e;
- } else if (t.data) {
- const e = t.data.slice(0);
- for (let i = 0; i < e.length; i++)
- e instanceof Uint8Array || e instanceof Uint8ClampedArray ? e[i] = Math.floor(Qe(e[i] / 255) * 255) : e[i] = Qe(e[i]);
- return {
- data: e,
- width: t.width,
- height: t.height
- };
- } else
- return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), t;
- }
- }
- let eA = 0;
- class iA {
- constructor(t = null) {
- this.isSource = !0, Object.defineProperty(this, "id", { value: eA++ }), this.uuid = Tn(), this.data = t, this.dataReady = !0, this.version = 0;
- }
- set needsUpdate(t) {
- t === !0 && this.version++;
- }
- toJSON(t) {
- const e = t === void 0 || typeof t == "string";
- if (!e && t.images[this.uuid] !== void 0)
- return t.images[this.uuid];
- const i = {
- uuid: this.uuid,
- url: ""
- }, n = this.data;
- if (n !== null) {
- let r;
- if (Array.isArray(n)) {
- r = [];
- for (let a = 0, o = n.length; a < o; a++)
- n[a].isDataTexture ? r.push(Es(n[a].image)) : r.push(Es(n[a]));
- } else
- r = Es(n);
- i.url = r;
- }
- return e || (t.images[this.uuid] = i), i;
- }
- }
- function Es(s) {
- return typeof HTMLImageElement < "u" && s instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && s instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && s instanceof ImageBitmap ? tA.getDataURL(s) : s.data ? {
- data: Array.from(s.data),
- width: s.width,
- height: s.height,
- type: s.data.constructor.name
- } : (console.warn("THREE.Texture: Unable to serialize Texture."), {});
- }
- let nA = 0;
- class Ae extends co {
- constructor(t = Ae.DEFAULT_IMAGE, e = Ae.DEFAULT_MAPPING, i = Yi, n = Yi, r = Pl, a = El, o = Il, h = Fl, l = Ae.DEFAULT_ANISOTROPY, A = lo) {
- super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: nA++ }), this.uuid = Tn(), this.name = "", this.source = new iA(t), this.mipmaps = [], this.mapping = e, this.channel = 0, this.wrapS = i, this.wrapT = n, this.magFilter = r, this.minFilter = a, this.anisotropy = l, this.format = o, this.internalFormat = null, this.type = h, this.offset = new X(0, 0), this.repeat = new X(1, 1), this.center = new X(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new Jt(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.colorSpace = A, this.userData = {}, this.version = 0, this.onUpdate = null, this.isRenderTargetTexture = !1, this.pmremVersion = 0;
- }
- get image() {
- return this.source.data;
- }
- set image(t = null) {
- this.source.data = t;
- }
- updateMatrix() {
- this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);
- }
- clone() {
- return new this.constructor().copy(this);
- }
- copy(t) {
- return this.name = t.name, this.source = t.source, this.mipmaps = t.mipmaps.slice(0), this.mapping = t.mapping, this.channel = t.channel, this.wrapS = t.wrapS, this.wrapT = t.wrapT, this.magFilter = t.magFilter, this.minFilter = t.minFilter, this.anisotropy = t.anisotropy, this.format = t.format, this.internalFormat = t.internalFormat, this.type = t.type, this.offset.copy(t.offset), this.repeat.copy(t.repeat), this.center.copy(t.center), this.rotation = t.rotation, this.matrixAutoUpdate = t.matrixAutoUpdate, this.matrix.copy(t.matrix), this.generateMipmaps = t.generateMipmaps, this.premultiplyAlpha = t.premultiplyAlpha, this.flipY = t.flipY, this.unpackAlignment = t.unpackAlignment, this.colorSpace = t.colorSpace, this.userData = JSON.parse(JSON.stringify(t.userData)), this.needsUpdate = !0, this;
- }
- toJSON(t) {
- const e = t === void 0 || typeof t == "string";
- if (!e && t.textures[this.uuid] !== void 0)
- return t.textures[this.uuid];
- const i = {
- metadata: {
- version: 4.6,
- type: "Texture",
- generator: "Texture.toJSON"
- },
- uuid: this.uuid,
- name: this.name,
- image: this.source.toJSON(t).uuid,
- mapping: this.mapping,
- channel: this.channel,
- repeat: [this.repeat.x, this.repeat.y],
- offset: [this.offset.x, this.offset.y],
- center: [this.center.x, this.center.y],
- rotation: this.rotation,
- wrap: [this.wrapS, this.wrapT],
- format: this.format,
- internalFormat: this.internalFormat,
- type: this.type,
- colorSpace: this.colorSpace,
- minFilter: this.minFilter,
- magFilter: this.magFilter,
- anisotropy: this.anisotropy,
- flipY: this.flipY,
- generateMipmaps: this.generateMipmaps,
- premultiplyAlpha: this.premultiplyAlpha,
- unpackAlignment: this.unpackAlignment
- };
- return Object.keys(this.userData).length > 0 && (i.userData = this.userData), e || (t.textures[this.uuid] = i), i;
- }
- dispose() {
- this.dispatchEvent({ type: "dispose" });
- }
- transformUv(t) {
- if (this.mapping !== ho)
- return t;
- if (t.applyMatrix3(this.matrix), t.x < 0 || t.x > 1)
- switch (this.wrapS) {
- case Xr:
- t.x = t.x - Math.floor(t.x);
- break;
- case Yi:
- t.x = t.x < 0 ? 0 : 1;
- break;
- case jr:
- Math.abs(Math.floor(t.x) % 2) === 1 ? t.x = Math.ceil(t.x) - t.x : t.x = t.x - Math.floor(t.x);
- break;
- }
- if (t.y < 0 || t.y > 1)
- switch (this.wrapT) {
- case Xr:
- t.y = t.y - Math.floor(t.y);
- break;
- case Yi:
- t.y = t.y < 0 ? 0 : 1;
- break;
- case jr:
- Math.abs(Math.floor(t.y) % 2) === 1 ? t.y = Math.ceil(t.y) - t.y : t.y = t.y - Math.floor(t.y);
- break;
- }
- return this.flipY && (t.y = 1 - t.y), t;
- }
- set needsUpdate(t) {
- t === !0 && (this.version++, this.source.needsUpdate = !0);
- }
- set needsPMREMUpdate(t) {
- t === !0 && this.pmremVersion++;
- }
- }
- Ae.DEFAULT_IMAGE = null;
- Ae.DEFAULT_MAPPING = ho;
- Ae.DEFAULT_ANISOTROPY = 1;
- class ci {
- constructor(t = 0, e = 0, i = 0, n = 1) {
- this.isQuaternion = !0, this._x = t, this._y = e, this._z = i, this._w = n;
- }
- static slerpFlat(t, e, i, n, r, a, o) {
- let h = i[n + 0], l = i[n + 1], A = i[n + 2], u = i[n + 3];
- const f = r[a + 0], c = r[a + 1], d = r[a + 2], p = r[a + 3];
- if (o === 0) {
- t[e + 0] = h, t[e + 1] = l, t[e + 2] = A, t[e + 3] = u;
- return;
- }
- if (o === 1) {
- t[e + 0] = f, t[e + 1] = c, t[e + 2] = d, t[e + 3] = p;
- return;
- }
- if (u !== p || h !== f || l !== c || A !== d) {
- let m = 1 - o;
- const v = h * f + l * c + A * d + u * p, _ = v >= 0 ? 1 : -1, g = 1 - v * v;
- if (g > Number.EPSILON) {
- const x = Math.sqrt(g), b = Math.atan2(x, v * _);
- m = Math.sin(m * b) / x, o = Math.sin(o * b) / x;
- }
- const y = o * _;
- if (h = h * m + f * y, l = l * m + c * y, A = A * m + d * y, u = u * m + p * y, m === 1 - o) {
- const x = 1 / Math.sqrt(h * h + l * l + A * A + u * u);
- h *= x, l *= x, A *= x, u *= x;
- }
- }
- t[e] = h, t[e + 1] = l, t[e + 2] = A, t[e + 3] = u;
- }
- static multiplyQuaternionsFlat(t, e, i, n, r, a) {
- const o = i[n], h = i[n + 1], l = i[n + 2], A = i[n + 3], u = r[a], f = r[a + 1], c = r[a + 2], d = r[a + 3];
- return t[e] = o * d + A * u + h * c - l * f, t[e + 1] = h * d + A * f + l * u - o * c, t[e + 2] = l * d + A * c + o * f - h * u, t[e + 3] = A * d - o * u - h * f - l * c, t;
- }
- get x() {
- return this._x;
- }
- set x(t) {
- this._x = t, this._onChangeCallback();
- }
- get y() {
- return this._y;
- }
- set y(t) {
- this._y = t, this._onChangeCallback();
- }
- get z() {
- return this._z;
- }
- set z(t) {
- this._z = t, this._onChangeCallback();
- }
- get w() {
- return this._w;
- }
- set w(t) {
- this._w = t, this._onChangeCallback();
- }
- set(t, e, i, n) {
- return this._x = t, this._y = e, this._z = i, this._w = n, this._onChangeCallback(), this;
- }
- clone() {
- return new this.constructor(this._x, this._y, this._z, this._w);
- }
- copy(t) {
- return this._x = t.x, this._y = t.y, this._z = t.z, this._w = t.w, this._onChangeCallback(), this;
- }
- setFromEuler(t, e = !0) {
- const i = t._x, n = t._y, r = t._z, a = t._order, o = Math.cos, h = Math.sin, l = o(i / 2), A = o(n / 2), u = o(r / 2), f = h(i / 2), c = h(n / 2), d = h(r / 2);
- switch (a) {
- case "XYZ":
- this._x = f * A * u + l * c * d, this._y = l * c * u - f * A * d, this._z = l * A * d + f * c * u, this._w = l * A * u - f * c * d;
- break;
- case "YXZ":
- this._x = f * A * u + l * c * d, this._y = l * c * u - f * A * d, this._z = l * A * d - f * c * u, this._w = l * A * u + f * c * d;
- break;
- case "ZXY":
- this._x = f * A * u - l * c * d, this._y = l * c * u + f * A * d, this._z = l * A * d + f * c * u, this._w = l * A * u - f * c * d;
- break;
- case "ZYX":
- this._x = f * A * u - l * c * d, this._y = l * c * u + f * A * d, this._z = l * A * d - f * c * u, this._w = l * A * u + f * c * d;
- break;
- case "YZX":
- this._x = f * A * u + l * c * d, this._y = l * c * u + f * A * d, this._z = l * A * d - f * c * u, this._w = l * A * u - f * c * d;
- break;
- case "XZY":
- this._x = f * A * u - l * c * d, this._y = l * c * u - f * A * d, this._z = l * A * d + f * c * u, this._w = l * A * u + f * c * d;
- break;
- default:
- console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + a);
- }
- return e === !0 && this._onChangeCallback(), this;
- }
- setFromAxisAngle(t, e) {
- const i = e / 2, n = Math.sin(i);
- return this._x = t.x * n, this._y = t.y * n, this._z = t.z * n, this._w = Math.cos(i), this._onChangeCallback(), this;
- }
- setFromRotationMatrix(t) {
- const e = t.elements, i = e[0], n = e[4], r = e[8], a = e[1], o = e[5], h = e[9], l = e[2], A = e[6], u = e[10], f = i + o + u;
- if (f > 0) {
- const c = 0.5 / Math.sqrt(f + 1);
- this._w = 0.25 / c, this._x = (A - h) * c, this._y = (r - l) * c, this._z = (a - n) * c;
- } else if (i > o && i > u) {
- const c = 2 * Math.sqrt(1 + i - o - u);
- this._w = (A - h) / c, this._x = 0.25 * c, this._y = (n + a) / c, this._z = (r + l) / c;
- } else if (o > u) {
- const c = 2 * Math.sqrt(1 + o - i - u);
- this._w = (r - l) / c, this._x = (n + a) / c, this._y = 0.25 * c, this._z = (h + A) / c;
- } else {
- const c = 2 * Math.sqrt(1 + u - i - o);
- this._w = (a - n) / c, this._x = (r + l) / c, this._y = (h + A) / c, this._z = 0.25 * c;
- }
- return this._onChangeCallback(), this;
- }
- setFromUnitVectors(t, e) {
- let i = t.dot(e) + 1;
- return i < Number.EPSILON ? (i = 0, Math.abs(t.x) > Math.abs(t.z) ? (this._x = -t.y, this._y = t.x, this._z = 0, this._w = i) : (this._x = 0, this._y = -t.z, this._z = t.y, this._w = i)) : (this._x = t.y * e.z - t.z * e.y, this._y = t.z * e.x - t.x * e.z, this._z = t.x * e.y - t.y * e.x, this._w = i), this.normalize();
- }
- angleTo(t) {
- return 2 * Math.acos(Math.abs(mt(this.dot(t), -1, 1)));
- }
- rotateTowards(t, e) {
- const i = this.angleTo(t);
- if (i === 0)
- return this;
- const n = Math.min(1, e / i);
- return this.slerp(t, n), this;
- }
- identity() {
- return this.set(0, 0, 0, 1);
- }
- invert() {
- return this.conjugate();
- }
- conjugate() {
- return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this;
- }
- dot(t) {
- return this._x * t._x + this._y * t._y + this._z * t._z + this._w * t._w;
- }
- lengthSq() {
- return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
- }
- length() {
- return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
- }
- normalize() {
- let t = this.length();
- return t === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (t = 1 / t, this._x = this._x * t, this._y = this._y * t, this._z = this._z * t, this._w = this._w * t), this._onChangeCallback(), this;
- }
- multiply(t) {
- return this.multiplyQuaternions(this, t);
- }
- premultiply(t) {
- return this.multiplyQuaternions(t, this);
- }
- multiplyQuaternions(t, e) {
- const i = t._x, n = t._y, r = t._z, a = t._w, o = e._x, h = e._y, l = e._z, A = e._w;
- return this._x = i * A + a * o + n * l - r * h, this._y = n * A + a * h + r * o - i * l, this._z = r * A + a * l + i * h - n * o, this._w = a * A - i * o - n * h - r * l, this._onChangeCallback(), this;
- }
- slerp(t, e) {
- if (e === 0)
- return this;
- if (e === 1)
- return this.copy(t);
- const i = this._x, n = this._y, r = this._z, a = this._w;
- let o = a * t._w + i * t._x + n * t._y + r * t._z;
- if (o < 0 ? (this._w = -t._w, this._x = -t._x, this._y = -t._y, this._z = -t._z, o = -o) : this.copy(t), o >= 1)
- return this._w = a, this._x = i, this._y = n, this._z = r, this;
- const h = 1 - o * o;
- if (h <= Number.EPSILON) {
- const c = 1 - e;
- return this._w = c * a + e * this._w, this._x = c * i + e * this._x, this._y = c * n + e * this._y, this._z = c * r + e * this._z, this.normalize(), this;
- }
- const l = Math.sqrt(h), A = Math.atan2(l, o), u = Math.sin((1 - e) * A) / l, f = Math.sin(e * A) / l;
- return this._w = a * u + this._w * f, this._x = i * u + this._x * f, this._y = n * u + this._y * f, this._z = r * u + this._z * f, this._onChangeCallback(), this;
- }
- slerpQuaternions(t, e, i) {
- return this.copy(t).slerp(e, i);
- }
- random() {
- const t = 2 * Math.PI * Math.random(), e = 2 * Math.PI * Math.random(), i = Math.random(), n = Math.sqrt(1 - i), r = Math.sqrt(i);
- return this.set(
- n * Math.sin(t),
- n * Math.cos(t),
- r * Math.sin(e),
- r * Math.cos(e)
- );
- }
- equals(t) {
- return t._x === this._x && t._y === this._y && t._z === this._z && t._w === this._w;
- }
- fromArray(t, e = 0) {
- return this._x = t[e], this._y = t[e + 1], this._z = t[e + 2], this._w = t[e + 3], this._onChangeCallback(), this;
- }
- toArray(t = [], e = 0) {
- return t[e] = this._x, t[e + 1] = this._y, t[e + 2] = this._z, t[e + 3] = this._w, t;
- }
- fromBufferAttribute(t, e) {
- return this._x = t.getX(e), this._y = t.getY(e), this._z = t.getZ(e), this._w = t.getW(e), this._onChangeCallback(), this;
- }
- toJSON() {
- return this.toArray();
- }
- _onChange(t) {
- return this._onChangeCallback = t, this;
- }
- _onChangeCallback() {
- }
- *[Symbol.iterator]() {
- yield this._x, yield this._y, yield this._z, yield this._w;
- }
- }
- class j {
- constructor(t = 0, e = 0, i = 0) {
- j.prototype.isVector3 = !0, this.x = t, this.y = e, this.z = i;
- }
- set(t, e, i) {
- return i === void 0 && (i = this.z), this.x = t, this.y = e, this.z = i, this;
- }
- setScalar(t) {
- return this.x = t, this.y = t, this.z = t, this;
- }
- setX(t) {
- return this.x = t, this;
- }
- setY(t) {
- return this.y = t, this;
- }
- setZ(t) {
- return this.z = t, this;
- }
- setComponent(t, e) {
- switch (t) {
- case 0:
- this.x = e;
- break;
- case 1:
- this.y = e;
- break;
- case 2:
- this.z = e;
- break;
- default:
- throw new Error("index is out of range: " + t);
- }
- return this;
- }
- getComponent(t) {
- switch (t) {
- case 0:
- return this.x;
- case 1:
- return this.y;
- case 2:
- return this.z;
- default:
- throw new Error("index is out of range: " + t);
- }
- }
- clone() {
- return new this.constructor(this.x, this.y, this.z);
- }
- copy(t) {
- return this.x = t.x, this.y = t.y, this.z = t.z, this;
- }
- add(t) {
- return this.x += t.x, this.y += t.y, this.z += t.z, this;
- }
- addScalar(t) {
- return this.x += t, this.y += t, this.z += t, this;
- }
- addVectors(t, e) {
- return this.x = t.x + e.x, this.y = t.y + e.y, this.z = t.z + e.z, this;
- }
- addScaledVector(t, e) {
- return this.x += t.x * e, this.y += t.y * e, this.z += t.z * e, this;
- }
- sub(t) {
- return this.x -= t.x, this.y -= t.y, this.z -= t.z, this;
- }
- subScalar(t) {
- return this.x -= t, this.y -= t, this.z -= t, this;
- }
- subVectors(t, e) {
- return this.x = t.x - e.x, this.y = t.y - e.y, this.z = t.z - e.z, this;
- }
- multiply(t) {
- return this.x *= t.x, this.y *= t.y, this.z *= t.z, this;
- }
- multiplyScalar(t) {
- return this.x *= t, this.y *= t, this.z *= t, this;
- }
- multiplyVectors(t, e) {
- return this.x = t.x * e.x, this.y = t.y * e.y, this.z = t.z * e.z, this;
- }
- applyEuler(t) {
- return this.applyQuaternion(ra.setFromEuler(t));
- }
- applyAxisAngle(t, e) {
- return this.applyQuaternion(ra.setFromAxisAngle(t, e));
- }
- applyMatrix3(t) {
- const e = this.x, i = this.y, n = this.z, r = t.elements;
- return this.x = r[0] * e + r[3] * i + r[6] * n, this.y = r[1] * e + r[4] * i + r[7] * n, this.z = r[2] * e + r[5] * i + r[8] * n, this;
- }
- applyNormalMatrix(t) {
- return this.applyMatrix3(t).normalize();
- }
- applyMatrix4(t) {
- const e = this.x, i = this.y, n = this.z, r = t.elements, a = 1 / (r[3] * e + r[7] * i + r[11] * n + r[15]);
- return this.x = (r[0] * e + r[4] * i + r[8] * n + r[12]) * a, this.y = (r[1] * e + r[5] * i + r[9] * n + r[13]) * a, this.z = (r[2] * e + r[6] * i + r[10] * n + r[14]) * a, this;
- }
- applyQuaternion(t) {
- const e = this.x, i = this.y, n = this.z, r = t.x, a = t.y, o = t.z, h = t.w, l = 2 * (a * n - o * i), A = 2 * (o * e - r * n), u = 2 * (r * i - a * e);
- return this.x = e + h * l + a * u - o * A, this.y = i + h * A + o * l - r * u, this.z = n + h * u + r * A - a * l, this;
- }
- project(t) {
- return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix);
- }
- unproject(t) {
- return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld);
- }
- transformDirection(t) {
- const e = this.x, i = this.y, n = this.z, r = t.elements;
- return this.x = r[0] * e + r[4] * i + r[8] * n, this.y = r[1] * e + r[5] * i + r[9] * n, this.z = r[2] * e + r[6] * i + r[10] * n, this.normalize();
- }
- divide(t) {
- return this.x /= t.x, this.y /= t.y, this.z /= t.z, this;
- }
- divideScalar(t) {
- return this.multiplyScalar(1 / t);
- }
- min(t) {
- return this.x = Math.min(this.x, t.x), this.y = Math.min(this.y, t.y), this.z = Math.min(this.z, t.z), this;
- }
- max(t) {
- return this.x = Math.max(this.x, t.x), this.y = Math.max(this.y, t.y), this.z = Math.max(this.z, t.z), this;
- }
- clamp(t, e) {
- return this.x = Math.max(t.x, Math.min(e.x, this.x)), this.y = Math.max(t.y, Math.min(e.y, this.y)), this.z = Math.max(t.z, Math.min(e.z, this.z)), this;
- }
- clampScalar(t, e) {
- return this.x = Math.max(t, Math.min(e, this.x)), this.y = Math.max(t, Math.min(e, this.y)), this.z = Math.max(t, Math.min(e, this.z)), this;
- }
- clampLength(t, e) {
- const i = this.length();
- return this.divideScalar(i || 1).multiplyScalar(Math.max(t, Math.min(e, i)));
- }
- floor() {
- return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this;
- }
- ceil() {
- return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this;
- }
- round() {
- return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this;
- }
- roundToZero() {
- return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this;
- }
- negate() {
- return this.x = -this.x, this.y = -this.y, this.z = -this.z, this;
- }
- dot(t) {
- return this.x * t.x + this.y * t.y + this.z * t.z;
- }
- // TODO lengthSquared?
- lengthSq() {
- return this.x * this.x + this.y * this.y + this.z * this.z;
- }
- length() {
- return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
- }
- manhattanLength() {
- return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
- }
- normalize() {
- return this.divideScalar(this.length() || 1);
- }
- setLength(t) {
- return this.normalize().multiplyScalar(t);
- }
- lerp(t, e) {
- return this.x += (t.x - this.x) * e, this.y += (t.y - this.y) * e, this.z += (t.z - this.z) * e, this;
- }
- lerpVectors(t, e, i) {
- return this.x = t.x + (e.x - t.x) * i, this.y = t.y + (e.y - t.y) * i, this.z = t.z + (e.z - t.z) * i, this;
- }
- cross(t) {
- return this.crossVectors(this, t);
- }
- crossVectors(t, e) {
- const i = t.x, n = t.y, r = t.z, a = e.x, o = e.y, h = e.z;
- return this.x = n * h - r * o, this.y = r * a - i * h, this.z = i * o - n * a, this;
- }
- projectOnVector(t) {
- const e = t.lengthSq();
- if (e === 0)
- return this.set(0, 0, 0);
- const i = t.dot(this) / e;
- return this.copy(t).multiplyScalar(i);
- }
- projectOnPlane(t) {
- return Fs.copy(this).projectOnVector(t), this.sub(Fs);
- }
- reflect(t) {
- return this.sub(Fs.copy(t).multiplyScalar(2 * this.dot(t)));
- }
- angleTo(t) {
- const e = Math.sqrt(this.lengthSq() * t.lengthSq());
- if (e === 0)
- return Math.PI / 2;
- const i = this.dot(t) / e;
- return Math.acos(mt(i, -1, 1));
- }
- distanceTo(t) {
- return Math.sqrt(this.distanceToSquared(t));
- }
- distanceToSquared(t) {
- const e = this.x - t.x, i = this.y - t.y, n = this.z - t.z;
- return e * e + i * i + n * n;
- }
- manhattanDistanceTo(t) {
- return Math.abs(this.x - t.x) + Math.abs(this.y - t.y) + Math.abs(this.z - t.z);
- }
- setFromSpherical(t) {
- return this.setFromSphericalCoords(t.radius, t.phi, t.theta);
- }
- setFromSphericalCoords(t, e, i) {
- const n = Math.sin(e) * t;
- return this.x = n * Math.sin(i), this.y = Math.cos(e) * t, this.z = n * Math.cos(i), this;
- }
- setFromCylindrical(t) {
- return this.setFromCylindricalCoords(t.radius, t.theta, t.y);
- }
- setFromCylindricalCoords(t, e, i) {
- return this.x = t * Math.sin(e), this.y = i, this.z = t * Math.cos(e), this;
- }
- setFromMatrixPosition(t) {
- const e = t.elements;
- return this.x = e[12], this.y = e[13], this.z = e[14], this;
- }
- setFromMatrixScale(t) {
- const e = this.setFromMatrixColumn(t, 0).length(), i = this.setFromMatrixColumn(t, 1).length(), n = this.setFromMatrixColumn(t, 2).length();
- return this.x = e, this.y = i, this.z = n, this;
- }
- setFromMatrixColumn(t, e) {
- return this.fromArray(t.elements, e * 4);
- }
- setFromMatrix3Column(t, e) {
- return this.fromArray(t.elements, e * 3);
- }
- setFromEuler(t) {
- return this.x = t._x, this.y = t._y, this.z = t._z, this;
- }
- setFromColor(t) {
- return this.x = t.r, this.y = t.g, this.z = t.b, this;
- }
- equals(t) {
- return t.x === this.x && t.y === this.y && t.z === this.z;
- }
- fromArray(t, e = 0) {
- return this.x = t[e], this.y = t[e + 1], this.z = t[e + 2], this;
- }
- toArray(t = [], e = 0) {
- return t[e] = this.x, t[e + 1] = this.y, t[e + 2] = this.z, t;
- }
- fromBufferAttribute(t, e) {
- return this.x = t.getX(e), this.y = t.getY(e), this.z = t.getZ(e), this;
- }
- random() {
- return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this;
- }
- randomDirection() {
- const t = Math.random() * Math.PI * 2, e = Math.random() * 2 - 1, i = Math.sqrt(1 - e * e);
- return this.x = i * Math.cos(t), this.y = e, this.z = i * Math.sin(t), this;
- }
- *[Symbol.iterator]() {
- yield this.x, yield this.y, yield this.z;
- }
- }
- const Fs = /* @__PURE__ */ new j(), ra = /* @__PURE__ */ new ci();
- class ot {
- constructor(t, e, i, n, r, a, o, h, l, A, u, f, c, d, p, m) {
- ot.prototype.isMatrix4 = !0, this.elements = [
- 1,
- 0,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1
- ], t !== void 0 && this.set(t, e, i, n, r, a, o, h, l, A, u, f, c, d, p, m);
- }
- set(t, e, i, n, r, a, o, h, l, A, u, f, c, d, p, m) {
- const v = this.elements;
- return v[0] = t, v[4] = e, v[8] = i, v[12] = n, v[1] = r, v[5] = a, v[9] = o, v[13] = h, v[2] = l, v[6] = A, v[10] = u, v[14] = f, v[3] = c, v[7] = d, v[11] = p, v[15] = m, this;
- }
- identity() {
- return this.set(
- 1,
- 0,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- clone() {
- return new ot().fromArray(this.elements);
- }
- copy(t) {
- const e = this.elements, i = t.elements;
- return e[0] = i[0], e[1] = i[1], e[2] = i[2], e[3] = i[3], e[4] = i[4], e[5] = i[5], e[6] = i[6], e[7] = i[7], e[8] = i[8], e[9] = i[9], e[10] = i[10], e[11] = i[11], e[12] = i[12], e[13] = i[13], e[14] = i[14], e[15] = i[15], this;
- }
- copyPosition(t) {
- const e = this.elements, i = t.elements;
- return e[12] = i[12], e[13] = i[13], e[14] = i[14], this;
- }
- setFromMatrix3(t) {
- const e = t.elements;
- return this.set(
- e[0],
- e[3],
- e[6],
- 0,
- e[1],
- e[4],
- e[7],
- 0,
- e[2],
- e[5],
- e[8],
- 0,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- extractBasis(t, e, i) {
- return t.setFromMatrixColumn(this, 0), e.setFromMatrixColumn(this, 1), i.setFromMatrixColumn(this, 2), this;
- }
- makeBasis(t, e, i) {
- return this.set(
- t.x,
- e.x,
- i.x,
- 0,
- t.y,
- e.y,
- i.y,
- 0,
- t.z,
- e.z,
- i.z,
- 0,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- extractRotation(t) {
- const e = this.elements, i = t.elements, n = 1 / ze.setFromMatrixColumn(t, 0).length(), r = 1 / ze.setFromMatrixColumn(t, 1).length(), a = 1 / ze.setFromMatrixColumn(t, 2).length();
- return e[0] = i[0] * n, e[1] = i[1] * n, e[2] = i[2] * n, e[3] = 0, e[4] = i[4] * r, e[5] = i[5] * r, e[6] = i[6] * r, e[7] = 0, e[8] = i[8] * a, e[9] = i[9] * a, e[10] = i[10] * a, e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0, e[15] = 1, this;
- }
- makeRotationFromEuler(t) {
- const e = this.elements, i = t.x, n = t.y, r = t.z, a = Math.cos(i), o = Math.sin(i), h = Math.cos(n), l = Math.sin(n), A = Math.cos(r), u = Math.sin(r);
- if (t.order === "XYZ") {
- const f = a * A, c = a * u, d = o * A, p = o * u;
- e[0] = h * A, e[4] = -h * u, e[8] = l, e[1] = c + d * l, e[5] = f - p * l, e[9] = -o * h, e[2] = p - f * l, e[6] = d + c * l, e[10] = a * h;
- } else if (t.order === "YXZ") {
- const f = h * A, c = h * u, d = l * A, p = l * u;
- e[0] = f + p * o, e[4] = d * o - c, e[8] = a * l, e[1] = a * u, e[5] = a * A, e[9] = -o, e[2] = c * o - d, e[6] = p + f * o, e[10] = a * h;
- } else if (t.order === "ZXY") {
- const f = h * A, c = h * u, d = l * A, p = l * u;
- e[0] = f - p * o, e[4] = -a * u, e[8] = d + c * o, e[1] = c + d * o, e[5] = a * A, e[9] = p - f * o, e[2] = -a * l, e[6] = o, e[10] = a * h;
- } else if (t.order === "ZYX") {
- const f = a * A, c = a * u, d = o * A, p = o * u;
- e[0] = h * A, e[4] = d * l - c, e[8] = f * l + p, e[1] = h * u, e[5] = p * l + f, e[9] = c * l - d, e[2] = -l, e[6] = o * h, e[10] = a * h;
- } else if (t.order === "YZX") {
- const f = a * h, c = a * l, d = o * h, p = o * l;
- e[0] = h * A, e[4] = p - f * u, e[8] = d * u + c, e[1] = u, e[5] = a * A, e[9] = -o * A, e[2] = -l * A, e[6] = c * u + d, e[10] = f - p * u;
- } else if (t.order === "XZY") {
- const f = a * h, c = a * l, d = o * h, p = o * l;
- e[0] = h * A, e[4] = -u, e[8] = l * A, e[1] = f * u + p, e[5] = a * A, e[9] = c * u - d, e[2] = d * u - c, e[6] = o * A, e[10] = p * u + f;
- }
- return e[3] = 0, e[7] = 0, e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0, e[15] = 1, this;
- }
- makeRotationFromQuaternion(t) {
- return this.compose(sA, t, rA);
- }
- lookAt(t, e, i) {
- const n = this.elements;
- return xt.subVectors(t, e), xt.lengthSq() === 0 && (xt.z = 1), xt.normalize(), re.crossVectors(i, xt), re.lengthSq() === 0 && (Math.abs(i.z) === 1 ? xt.x += 1e-4 : xt.z += 1e-4, xt.normalize(), re.crossVectors(i, xt)), re.normalize(), qi.crossVectors(xt, re), n[0] = re.x, n[4] = qi.x, n[8] = xt.x, n[1] = re.y, n[5] = qi.y, n[9] = xt.y, n[2] = re.z, n[6] = qi.z, n[10] = xt.z, this;
- }
- multiply(t) {
- return this.multiplyMatrices(this, t);
- }
- premultiply(t) {
- return this.multiplyMatrices(t, this);
- }
- multiplyMatrices(t, e) {
- const i = t.elements, n = e.elements, r = this.elements, a = i[0], o = i[4], h = i[8], l = i[12], A = i[1], u = i[5], f = i[9], c = i[13], d = i[2], p = i[6], m = i[10], v = i[14], _ = i[3], g = i[7], y = i[11], x = i[15], b = n[0], C = n[4], w = n[8], E = n[12], S = n[1], P = n[5], k = n[9], F = n[13], L = n[2], I = n[6], z = n[10], T = n[14], G = n[3], H = n[7], R = n[11], N = n[15];
- return r[0] = a * b + o * S + h * L + l * G, r[4] = a * C + o * P + h * I + l * H, r[8] = a * w + o * k + h * z + l * R, r[12] = a * E + o * F + h * T + l * N, r[1] = A * b + u * S + f * L + c * G, r[5] = A * C + u * P + f * I + c * H, r[9] = A * w + u * k + f * z + c * R, r[13] = A * E + u * F + f * T + c * N, r[2] = d * b + p * S + m * L + v * G, r[6] = d * C + p * P + m * I + v * H, r[10] = d * w + p * k + m * z + v * R, r[14] = d * E + p * F + m * T + v * N, r[3] = _ * b + g * S + y * L + x * G, r[7] = _ * C + g * P + y * I + x * H, r[11] = _ * w + g * k + y * z + x * R, r[15] = _ * E + g * F + y * T + x * N, this;
- }
- multiplyScalar(t) {
- const e = this.elements;
- return e[0] *= t, e[4] *= t, e[8] *= t, e[12] *= t, e[1] *= t, e[5] *= t, e[9] *= t, e[13] *= t, e[2] *= t, e[6] *= t, e[10] *= t, e[14] *= t, e[3] *= t, e[7] *= t, e[11] *= t, e[15] *= t, this;
- }
- determinant() {
- const t = this.elements, e = t[0], i = t[4], n = t[8], r = t[12], a = t[1], o = t[5], h = t[9], l = t[13], A = t[2], u = t[6], f = t[10], c = t[14], d = t[3], p = t[7], m = t[11], v = t[15];
- return d * (+r * h * u - n * l * u - r * o * f + i * l * f + n * o * c - i * h * c) + p * (+e * h * c - e * l * f + r * a * f - n * a * c + n * l * A - r * h * A) + m * (+e * l * u - e * o * c - r * a * u + i * a * c + r * o * A - i * l * A) + v * (-n * o * A - e * h * u + e * o * f + n * a * u - i * a * f + i * h * A);
- }
- transpose() {
- const t = this.elements;
- let e;
- return e = t[1], t[1] = t[4], t[4] = e, e = t[2], t[2] = t[8], t[8] = e, e = t[6], t[6] = t[9], t[9] = e, e = t[3], t[3] = t[12], t[12] = e, e = t[7], t[7] = t[13], t[13] = e, e = t[11], t[11] = t[14], t[14] = e, this;
- }
- setPosition(t, e, i) {
- const n = this.elements;
- return t.isVector3 ? (n[12] = t.x, n[13] = t.y, n[14] = t.z) : (n[12] = t, n[13] = e, n[14] = i), this;
- }
- invert() {
- const t = this.elements, e = t[0], i = t[1], n = t[2], r = t[3], a = t[4], o = t[5], h = t[6], l = t[7], A = t[8], u = t[9], f = t[10], c = t[11], d = t[12], p = t[13], m = t[14], v = t[15], _ = u * m * l - p * f * l + p * h * c - o * m * c - u * h * v + o * f * v, g = d * f * l - A * m * l - d * h * c + a * m * c + A * h * v - a * f * v, y = A * p * l - d * u * l + d * o * c - a * p * c - A * o * v + a * u * v, x = d * u * h - A * p * h - d * o * f + a * p * f + A * o * m - a * u * m, b = e * _ + i * g + n * y + r * x;
- if (b === 0)
- return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- const C = 1 / b;
- return t[0] = _ * C, t[1] = (p * f * r - u * m * r - p * n * c + i * m * c + u * n * v - i * f * v) * C, t[2] = (o * m * r - p * h * r + p * n * l - i * m * l - o * n * v + i * h * v) * C, t[3] = (u * h * r - o * f * r - u * n * l + i * f * l + o * n * c - i * h * c) * C, t[4] = g * C, t[5] = (A * m * r - d * f * r + d * n * c - e * m * c - A * n * v + e * f * v) * C, t[6] = (d * h * r - a * m * r - d * n * l + e * m * l + a * n * v - e * h * v) * C, t[7] = (a * f * r - A * h * r + A * n * l - e * f * l - a * n * c + e * h * c) * C, t[8] = y * C, t[9] = (d * u * r - A * p * r - d * i * c + e * p * c + A * i * v - e * u * v) * C, t[10] = (a * p * r - d * o * r + d * i * l - e * p * l - a * i * v + e * o * v) * C, t[11] = (A * o * r - a * u * r - A * i * l + e * u * l + a * i * c - e * o * c) * C, t[12] = x * C, t[13] = (A * p * n - d * u * n + d * i * f - e * p * f - A * i * m + e * u * m) * C, t[14] = (d * o * n - a * p * n - d * i * h + e * p * h + a * i * m - e * o * m) * C, t[15] = (a * u * n - A * o * n + A * i * h - e * u * h - a * i * f + e * o * f) * C, this;
- }
- scale(t) {
- const e = this.elements, i = t.x, n = t.y, r = t.z;
- return e[0] *= i, e[4] *= n, e[8] *= r, e[1] *= i, e[5] *= n, e[9] *= r, e[2] *= i, e[6] *= n, e[10] *= r, e[3] *= i, e[7] *= n, e[11] *= r, this;
- }
- getMaxScaleOnAxis() {
- const t = this.elements, e = t[0] * t[0] + t[1] * t[1] + t[2] * t[2], i = t[4] * t[4] + t[5] * t[5] + t[6] * t[6], n = t[8] * t[8] + t[9] * t[9] + t[10] * t[10];
- return Math.sqrt(Math.max(e, i, n));
- }
- makeTranslation(t, e, i) {
- return t.isVector3 ? this.set(
- 1,
- 0,
- 0,
- t.x,
- 0,
- 1,
- 0,
- t.y,
- 0,
- 0,
- 1,
- t.z,
- 0,
- 0,
- 0,
- 1
- ) : this.set(
- 1,
- 0,
- 0,
- t,
- 0,
- 1,
- 0,
- e,
- 0,
- 0,
- 1,
- i,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- makeRotationX(t) {
- const e = Math.cos(t), i = Math.sin(t);
- return this.set(
- 1,
- 0,
- 0,
- 0,
- 0,
- e,
- -i,
- 0,
- 0,
- i,
- e,
- 0,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- makeRotationY(t) {
- const e = Math.cos(t), i = Math.sin(t);
- return this.set(
- e,
- 0,
- i,
- 0,
- 0,
- 1,
- 0,
- 0,
- -i,
- 0,
- e,
- 0,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- makeRotationZ(t) {
- const e = Math.cos(t), i = Math.sin(t);
- return this.set(
- e,
- -i,
- 0,
- 0,
- i,
- e,
- 0,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- makeRotationAxis(t, e) {
- const i = Math.cos(e), n = Math.sin(e), r = 1 - i, a = t.x, o = t.y, h = t.z, l = r * a, A = r * o;
- return this.set(
- l * a + i,
- l * o - n * h,
- l * h + n * o,
- 0,
- l * o + n * h,
- A * o + i,
- A * h - n * a,
- 0,
- l * h - n * o,
- A * h + n * a,
- r * h * h + i,
- 0,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- makeScale(t, e, i) {
- return this.set(
- t,
- 0,
- 0,
- 0,
- 0,
- e,
- 0,
- 0,
- 0,
- 0,
- i,
- 0,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- makeShear(t, e, i, n, r, a) {
- return this.set(
- 1,
- i,
- r,
- 0,
- t,
- 1,
- a,
- 0,
- e,
- n,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- compose(t, e, i) {
- const n = this.elements, r = e._x, a = e._y, o = e._z, h = e._w, l = r + r, A = a + a, u = o + o, f = r * l, c = r * A, d = r * u, p = a * A, m = a * u, v = o * u, _ = h * l, g = h * A, y = h * u, x = i.x, b = i.y, C = i.z;
- return n[0] = (1 - (p + v)) * x, n[1] = (c + y) * x, n[2] = (d - g) * x, n[3] = 0, n[4] = (c - y) * b, n[5] = (1 - (f + v)) * b, n[6] = (m + _) * b, n[7] = 0, n[8] = (d + g) * C, n[9] = (m - _) * C, n[10] = (1 - (f + p)) * C, n[11] = 0, n[12] = t.x, n[13] = t.y, n[14] = t.z, n[15] = 1, this;
- }
- decompose(t, e, i) {
- const n = this.elements;
- let r = ze.set(n[0], n[1], n[2]).length();
- const a = ze.set(n[4], n[5], n[6]).length(), o = ze.set(n[8], n[9], n[10]).length();
- this.determinant() < 0 && (r = -r), t.x = n[12], t.y = n[13], t.z = n[14], kt.copy(this);
- const l = 1 / r, A = 1 / a, u = 1 / o;
- return kt.elements[0] *= l, kt.elements[1] *= l, kt.elements[2] *= l, kt.elements[4] *= A, kt.elements[5] *= A, kt.elements[6] *= A, kt.elements[8] *= u, kt.elements[9] *= u, kt.elements[10] *= u, e.setFromRotationMatrix(kt), i.x = r, i.y = a, i.z = o, this;
- }
- makePerspective(t, e, i, n, r, a, o = Xi) {
- const h = this.elements, l = 2 * r / (e - t), A = 2 * r / (i - n), u = (e + t) / (e - t), f = (i + n) / (i - n);
- let c, d;
- if (o === Xi)
- c = -(a + r) / (a - r), d = -2 * a * r / (a - r);
- else if (o === ta)
- c = -a / (a - r), d = -a * r / (a - r);
- else
- throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + o);
- return h[0] = l, h[4] = 0, h[8] = u, h[12] = 0, h[1] = 0, h[5] = A, h[9] = f, h[13] = 0, h[2] = 0, h[6] = 0, h[10] = c, h[14] = d, h[3] = 0, h[7] = 0, h[11] = -1, h[15] = 0, this;
- }
- makeOrthographic(t, e, i, n, r, a, o = Xi) {
- const h = this.elements, l = 1 / (e - t), A = 1 / (i - n), u = 1 / (a - r), f = (e + t) * l, c = (i + n) * A;
- let d, p;
- if (o === Xi)
- d = (a + r) * u, p = -2 * u;
- else if (o === ta)
- d = r * u, p = -1 * u;
- else
- throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + o);
- return h[0] = 2 * l, h[4] = 0, h[8] = 0, h[12] = -f, h[1] = 0, h[5] = 2 * A, h[9] = 0, h[13] = -c, h[2] = 0, h[6] = 0, h[10] = p, h[14] = -d, h[3] = 0, h[7] = 0, h[11] = 0, h[15] = 1, this;
- }
- equals(t) {
- const e = this.elements, i = t.elements;
- for (let n = 0; n < 16; n++)
- if (e[n] !== i[n])
- return !1;
- return !0;
- }
- fromArray(t, e = 0) {
- for (let i = 0; i < 16; i++)
- this.elements[i] = t[i + e];
- return this;
- }
- toArray(t = [], e = 0) {
- const i = this.elements;
- return t[e] = i[0], t[e + 1] = i[1], t[e + 2] = i[2], t[e + 3] = i[3], t[e + 4] = i[4], t[e + 5] = i[5], t[e + 6] = i[6], t[e + 7] = i[7], t[e + 8] = i[8], t[e + 9] = i[9], t[e + 10] = i[10], t[e + 11] = i[11], t[e + 12] = i[12], t[e + 13] = i[13], t[e + 14] = i[14], t[e + 15] = i[15], t;
- }
- }
- const ze = /* @__PURE__ */ new j(), kt = /* @__PURE__ */ new ot(), sA = /* @__PURE__ */ new j(0, 0, 0), rA = /* @__PURE__ */ new j(1, 1, 1), re = /* @__PURE__ */ new j(), qi = /* @__PURE__ */ new j(), xt = /* @__PURE__ */ new j(), aa = /* @__PURE__ */ new ot(), oa = /* @__PURE__ */ new ci();
- class zi {
- constructor(t = 0, e = 0, i = 0, n = zi.DEFAULT_ORDER) {
- this.isEuler = !0, this._x = t, this._y = e, this._z = i, this._order = n;
- }
- get x() {
- return this._x;
- }
- set x(t) {
- this._x = t, this._onChangeCallback();
- }
- get y() {
- return this._y;
- }
- set y(t) {
- this._y = t, this._onChangeCallback();
- }
- get z() {
- return this._z;
- }
- set z(t) {
- this._z = t, this._onChangeCallback();
- }
- get order() {
- return this._order;
- }
- set order(t) {
- this._order = t, this._onChangeCallback();
- }
- set(t, e, i, n = this._order) {
- return this._x = t, this._y = e, this._z = i, this._order = n, this._onChangeCallback(), this;
- }
- clone() {
- return new this.constructor(this._x, this._y, this._z, this._order);
- }
- copy(t) {
- return this._x = t._x, this._y = t._y, this._z = t._z, this._order = t._order, this._onChangeCallback(), this;
- }
- setFromRotationMatrix(t, e = this._order, i = !0) {
- const n = t.elements, r = n[0], a = n[4], o = n[8], h = n[1], l = n[5], A = n[9], u = n[2], f = n[6], c = n[10];
- switch (e) {
- case "XYZ":
- this._y = Math.asin(mt(o, -1, 1)), Math.abs(o) < 0.9999999 ? (this._x = Math.atan2(-A, c), this._z = Math.atan2(-a, r)) : (this._x = Math.atan2(f, l), this._z = 0);
- break;
- case "YXZ":
- this._x = Math.asin(-mt(A, -1, 1)), Math.abs(A) < 0.9999999 ? (this._y = Math.atan2(o, c), this._z = Math.atan2(h, l)) : (this._y = Math.atan2(-u, r), this._z = 0);
- break;
- case "ZXY":
- this._x = Math.asin(mt(f, -1, 1)), Math.abs(f) < 0.9999999 ? (this._y = Math.atan2(-u, c), this._z = Math.atan2(-a, l)) : (this._y = 0, this._z = Math.atan2(h, r));
- break;
- case "ZYX":
- this._y = Math.asin(-mt(u, -1, 1)), Math.abs(u) < 0.9999999 ? (this._x = Math.atan2(f, c), this._z = Math.atan2(h, r)) : (this._x = 0, this._z = Math.atan2(-a, l));
- break;
- case "YZX":
- this._z = Math.asin(mt(h, -1, 1)), Math.abs(h) < 0.9999999 ? (this._x = Math.atan2(-A, l), this._y = Math.atan2(-u, r)) : (this._x = 0, this._y = Math.atan2(o, c));
- break;
- case "XZY":
- this._z = Math.asin(-mt(a, -1, 1)), Math.abs(a) < 0.9999999 ? (this._x = Math.atan2(f, l), this._y = Math.atan2(o, r)) : (this._x = Math.atan2(-A, c), this._y = 0);
- break;
- default:
- console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + e);
- }
- return this._order = e, i === !0 && this._onChangeCallback(), this;
- }
- setFromQuaternion(t, e, i) {
- return aa.makeRotationFromQuaternion(t), this.setFromRotationMatrix(aa, e, i);
- }
- setFromVector3(t, e = this._order) {
- return this.set(t.x, t.y, t.z, e);
- }
- reorder(t) {
- return oa.setFromEuler(this), this.setFromQuaternion(oa, t);
- }
- equals(t) {
- return t._x === this._x && t._y === this._y && t._z === this._z && t._order === this._order;
- }
- fromArray(t) {
- return this._x = t[0], this._y = t[1], this._z = t[2], t[3] !== void 0 && (this._order = t[3]), this._onChangeCallback(), this;
- }
- toArray(t = [], e = 0) {
- return t[e] = this._x, t[e + 1] = this._y, t[e + 2] = this._z, t[e + 3] = this._order, t;
- }
- _onChange(t) {
- return this._onChangeCallback = t, this;
- }
- _onChangeCallback() {
- }
- *[Symbol.iterator]() {
- yield this._x, yield this._y, yield this._z, yield this._order;
- }
- }
- zi.DEFAULT_ORDER = "XYZ";
- class aA {
- constructor() {
- this.mask = 1;
- }
- set(t) {
- this.mask = (1 << t | 0) >>> 0;
- }
- enable(t) {
- this.mask |= 1 << t | 0;
- }
- enableAll() {
- this.mask = -1;
- }
- toggle(t) {
- this.mask ^= 1 << t | 0;
- }
- disable(t) {
- this.mask &= ~(1 << t | 0);
- }
- disableAll() {
- this.mask = 0;
- }
- test(t) {
- return (this.mask & t.mask) !== 0;
- }
- isEnabled(t) {
- return (this.mask & (1 << t | 0)) !== 0;
- }
- }
- let oA = 0;
- const ha = /* @__PURE__ */ new j(), Ue = /* @__PURE__ */ new ci(), Vt = /* @__PURE__ */ new ot(), Qi = /* @__PURE__ */ new j(), vi = /* @__PURE__ */ new j(), hA = /* @__PURE__ */ new j(), lA = /* @__PURE__ */ new ci(), la = /* @__PURE__ */ new j(1, 0, 0), Aa = /* @__PURE__ */ new j(0, 1, 0), ca = /* @__PURE__ */ new j(0, 0, 1), da = { type: "added" }, AA = { type: "removed" }, He = { type: "childadded", child: null }, ks = { type: "childremoved", child: null };
- class we extends co {
- constructor() {
- super(), this.isObject3D = !0, Object.defineProperty(this, "id", { value: oA++ }), this.uuid = Tn(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = we.DEFAULT_UP.clone();
- const t = new j(), e = new zi(), i = new ci(), n = new j(1, 1, 1);
- function r() {
- i.setFromEuler(e, !1);
- }
- function a() {
- e.setFromQuaternion(i, void 0, !1);
- }
- e._onChange(r), i._onChange(a), Object.defineProperties(this, {
- position: {
- configurable: !0,
- enumerable: !0,
- value: t
- },
- rotation: {
- configurable: !0,
- enumerable: !0,
- value: e
- },
- quaternion: {
- configurable: !0,
- enumerable: !0,
- value: i
- },
- scale: {
- configurable: !0,
- enumerable: !0,
- value: n
- },
- modelViewMatrix: {
- value: new ot()
- },
- normalMatrix: {
- value: new Jt()
- }
- }), this.matrix = new ot(), this.matrixWorld = new ot(), this.matrixAutoUpdate = we.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldAutoUpdate = we.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.layers = new aA(), this.visible = !0, this.castShadow = !1, this.receiveShadow = !1, this.frustumCulled = !0, this.renderOrder = 0, this.animations = [], this.userData = {};
- }
- onBeforeShadow() {
- }
- onAfterShadow() {
- }
- onBeforeRender() {
- }
- onAfterRender() {
- }
- applyMatrix4(t) {
- this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(t), this.matrix.decompose(this.position, this.quaternion, this.scale);
- }
- applyQuaternion(t) {
- return this.quaternion.premultiply(t), this;
- }
- setRotationFromAxisAngle(t, e) {
- this.quaternion.setFromAxisAngle(t, e);
- }
- setRotationFromEuler(t) {
- this.quaternion.setFromEuler(t, !0);
- }
- setRotationFromMatrix(t) {
- this.quaternion.setFromRotationMatrix(t);
- }
- setRotationFromQuaternion(t) {
- this.quaternion.copy(t);
- }
- rotateOnAxis(t, e) {
- return Ue.setFromAxisAngle(t, e), this.quaternion.multiply(Ue), this;
- }
- rotateOnWorldAxis(t, e) {
- return Ue.setFromAxisAngle(t, e), this.quaternion.premultiply(Ue), this;
- }
- rotateX(t) {
- return this.rotateOnAxis(la, t);
- }
- rotateY(t) {
- return this.rotateOnAxis(Aa, t);
- }
- rotateZ(t) {
- return this.rotateOnAxis(ca, t);
- }
- translateOnAxis(t, e) {
- return ha.copy(t).applyQuaternion(this.quaternion), this.position.add(ha.multiplyScalar(e)), this;
- }
- translateX(t) {
- return this.translateOnAxis(la, t);
- }
- translateY(t) {
- return this.translateOnAxis(Aa, t);
- }
- translateZ(t) {
- return this.translateOnAxis(ca, t);
- }
- localToWorld(t) {
- return this.updateWorldMatrix(!0, !1), t.applyMatrix4(this.matrixWorld);
- }
- worldToLocal(t) {
- return this.updateWorldMatrix(!0, !1), t.applyMatrix4(Vt.copy(this.matrixWorld).invert());
- }
- lookAt(t, e, i) {
- t.isVector3 ? Qi.copy(t) : Qi.set(t, e, i);
- const n = this.parent;
- this.updateWorldMatrix(!0, !1), vi.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? Vt.lookAt(vi, Qi, this.up) : Vt.lookAt(Qi, vi, this.up), this.quaternion.setFromRotationMatrix(Vt), n && (Vt.extractRotation(n.matrixWorld), Ue.setFromRotationMatrix(Vt), this.quaternion.premultiply(Ue.invert()));
- }
- add(t) {
- if (arguments.length > 1) {
- for (let e = 0; e < arguments.length; e++)
- this.add(arguments[e]);
- return this;
- }
- return t === this ? (console.error("THREE.Object3D.add: object can't be added as a child of itself.", t), this) : (t && t.isObject3D ? (t.removeFromParent(), t.parent = this, this.children.push(t), t.dispatchEvent(da), He.child = t, this.dispatchEvent(He), He.child = null) : console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", t), this);
- }
- remove(t) {
- if (arguments.length > 1) {
- for (let i = 0; i < arguments.length; i++)
- this.remove(arguments[i]);
- return this;
- }
- const e = this.children.indexOf(t);
- return e !== -1 && (t.parent = null, this.children.splice(e, 1), t.dispatchEvent(AA), ks.child = t, this.dispatchEvent(ks), ks.child = null), this;
- }
- removeFromParent() {
- const t = this.parent;
- return t !== null && t.remove(this), this;
- }
- clear() {
- return this.remove(...this.children);
- }
- attach(t) {
- return this.updateWorldMatrix(!0, !1), Vt.copy(this.matrixWorld).invert(), t.parent !== null && (t.parent.updateWorldMatrix(!0, !1), Vt.multiply(t.parent.matrixWorld)), t.applyMatrix4(Vt), t.removeFromParent(), t.parent = this, this.children.push(t), t.updateWorldMatrix(!1, !0), t.dispatchEvent(da), He.child = t, this.dispatchEvent(He), He.child = null, this;
- }
- getObjectById(t) {
- return this.getObjectByProperty("id", t);
- }
- getObjectByName(t) {
- return this.getObjectByProperty("name", t);
- }
- getObjectByProperty(t, e) {
- if (this[t] === e)
- return this;
- for (let i = 0, n = this.children.length; i < n; i++) {
- const a = this.children[i].getObjectByProperty(t, e);
- if (a !== void 0)
- return a;
- }
- }
- getObjectsByProperty(t, e, i = []) {
- this[t] === e && i.push(this);
- const n = this.children;
- for (let r = 0, a = n.length; r < a; r++)
- n[r].getObjectsByProperty(t, e, i);
- return i;
- }
- getWorldPosition(t) {
- return this.updateWorldMatrix(!0, !1), t.setFromMatrixPosition(this.matrixWorld);
- }
- getWorldQuaternion(t) {
- return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(vi, t, hA), t;
- }
- getWorldScale(t) {
- return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(vi, lA, t), t;
- }
- getWorldDirection(t) {
- this.updateWorldMatrix(!0, !1);
- const e = this.matrixWorld.elements;
- return t.set(e[8], e[9], e[10]).normalize();
- }
- raycast() {
- }
- traverse(t) {
- t(this);
- const e = this.children;
- for (let i = 0, n = e.length; i < n; i++)
- e[i].traverse(t);
- }
- traverseVisible(t) {
- if (this.visible === !1)
- return;
- t(this);
- const e = this.children;
- for (let i = 0, n = e.length; i < n; i++)
- e[i].traverseVisible(t);
- }
- traverseAncestors(t) {
- const e = this.parent;
- e !== null && (t(e), e.traverseAncestors(t));
- }
- updateMatrix() {
- this.matrix.compose(this.position, this.quaternion, this.scale), this.matrixWorldNeedsUpdate = !0;
- }
- updateMatrixWorld(t) {
- this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || t) && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), this.matrixWorldNeedsUpdate = !1, t = !0);
- const e = this.children;
- for (let i = 0, n = e.length; i < n; i++) {
- const r = e[i];
- (r.matrixWorldAutoUpdate === !0 || t === !0) && r.updateMatrixWorld(t);
- }
- }
- updateWorldMatrix(t, e) {
- const i = this.parent;
- if (t === !0 && i !== null && i.matrixWorldAutoUpdate === !0 && i.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), e === !0) {
- const n = this.children;
- for (let r = 0, a = n.length; r < a; r++) {
- const o = n[r];
- o.matrixWorldAutoUpdate === !0 && o.updateWorldMatrix(!1, !0);
- }
- }
- }
- toJSON(t) {
- const e = t === void 0 || typeof t == "string", i = {};
- e && (t = {
- geometries: {},
- materials: {},
- textures: {},
- images: {},
- shapes: {},
- skeletons: {},
- animations: {},
- nodes: {}
- }, i.metadata = {
- version: 4.6,
- type: "Object",
- generator: "Object3D.toJSON"
- });
- const n = {};
- n.uuid = this.uuid, n.type = this.type, this.name !== "" && (n.name = this.name), this.castShadow === !0 && (n.castShadow = !0), this.receiveShadow === !0 && (n.receiveShadow = !0), this.visible === !1 && (n.visible = !1), this.frustumCulled === !1 && (n.frustumCulled = !1), this.renderOrder !== 0 && (n.renderOrder = this.renderOrder), Object.keys(this.userData).length > 0 && (n.userData = this.userData), n.layers = this.layers.mask, n.matrix = this.matrix.toArray(), n.up = this.up.toArray(), this.matrixAutoUpdate === !1 && (n.matrixAutoUpdate = !1), this.isInstancedMesh && (n.type = "InstancedMesh", n.count = this.count, n.instanceMatrix = this.instanceMatrix.toJSON(), this.instanceColor !== null && (n.instanceColor = this.instanceColor.toJSON())), this.isBatchedMesh && (n.type = "BatchedMesh", n.perObjectFrustumCulled = this.perObjectFrustumCulled, n.sortObjects = this.sortObjects, n.drawRanges = this._drawRanges, n.reservedRanges = this._reservedRanges, n.visibility = this._visibility, n.active = this._active, n.bounds = this._bounds.map((o) => ({
- boxInitialized: o.boxInitialized,
- boxMin: o.box.min.toArray(),
- boxMax: o.box.max.toArray(),
- sphereInitialized: o.sphereInitialized,
- sphereRadius: o.sphere.radius,
- sphereCenter: o.sphere.center.toArray()
- })), n.maxGeometryCount = this._maxGeometryCount, n.maxVertexCount = this._maxVertexCount, n.maxIndexCount = this._maxIndexCount, n.geometryInitialized = this._geometryInitialized, n.geometryCount = this._geometryCount, n.matricesTexture = this._matricesTexture.toJSON(t), this.boundingSphere !== null && (n.boundingSphere = {
- center: n.boundingSphere.center.toArray(),
- radius: n.boundingSphere.radius
- }), this.boundingBox !== null && (n.boundingBox = {
- min: n.boundingBox.min.toArray(),
- max: n.boundingBox.max.toArray()
- }));
- function r(o, h) {
- return o[h.uuid] === void 0 && (o[h.uuid] = h.toJSON(t)), h.uuid;
- }
- if (this.isScene)
- this.background && (this.background.isColor ? n.background = this.background.toJSON() : this.background.isTexture && (n.background = this.background.toJSON(t).uuid)), this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== !0 && (n.environment = this.environment.toJSON(t).uuid);
- else if (this.isMesh || this.isLine || this.isPoints) {
- n.geometry = r(t.geometries, this.geometry);
- const o = this.geometry.parameters;
- if (o !== void 0 && o.shapes !== void 0) {
- const h = o.shapes;
- if (Array.isArray(h))
- for (let l = 0, A = h.length; l < A; l++) {
- const u = h[l];
- r(t.shapes, u);
- }
- else
- r(t.shapes, h);
- }
- }
- if (this.isSkinnedMesh && (n.bindMode = this.bindMode, n.bindMatrix = this.bindMatrix.toArray(), this.skeleton !== void 0 && (r(t.skeletons, this.skeleton), n.skeleton = this.skeleton.uuid)), this.material !== void 0)
- if (Array.isArray(this.material)) {
- const o = [];
- for (let h = 0, l = this.material.length; h < l; h++)
- o.push(r(t.materials, this.material[h]));
- n.material = o;
- } else
- n.material = r(t.materials, this.material);
- if (this.children.length > 0) {
- n.children = [];
- for (let o = 0; o < this.children.length; o++)
- n.children.push(this.children[o].toJSON(t).object);
- }
- if (this.animations.length > 0) {
- n.animations = [];
- for (let o = 0; o < this.animations.length; o++) {
- const h = this.animations[o];
- n.animations.push(r(t.animations, h));
- }
- }
- if (e) {
- const o = a(t.geometries), h = a(t.materials), l = a(t.textures), A = a(t.images), u = a(t.shapes), f = a(t.skeletons), c = a(t.animations), d = a(t.nodes);
- o.length > 0 && (i.geometries = o), h.length > 0 && (i.materials = h), l.length > 0 && (i.textures = l), A.length > 0 && (i.images = A), u.length > 0 && (i.shapes = u), f.length > 0 && (i.skeletons = f), c.length > 0 && (i.animations = c), d.length > 0 && (i.nodes = d);
- }
- return i.object = n, i;
- function a(o) {
- const h = [];
- for (const l in o) {
- const A = o[l];
- delete A.metadata, h.push(A);
- }
- return h;
- }
- }
- clone(t) {
- return new this.constructor().copy(this, t);
- }
- copy(t, e = !0) {
- if (this.name = t.name, this.up.copy(t.up), this.position.copy(t.position), this.rotation.order = t.rotation.order, this.quaternion.copy(t.quaternion), this.scale.copy(t.scale), this.matrix.copy(t.matrix), this.matrixWorld.copy(t.matrixWorld), this.matrixAutoUpdate = t.matrixAutoUpdate, this.matrixWorldAutoUpdate = t.matrixWorldAutoUpdate, this.matrixWorldNeedsUpdate = t.matrixWorldNeedsUpdate, this.layers.mask = t.layers.mask, this.visible = t.visible, this.castShadow = t.castShadow, this.receiveShadow = t.receiveShadow, this.frustumCulled = t.frustumCulled, this.renderOrder = t.renderOrder, this.animations = t.animations.slice(), this.userData = JSON.parse(JSON.stringify(t.userData)), e === !0)
- for (let i = 0; i < t.children.length; i++) {
- const n = t.children[i];
- this.add(n.clone());
- }
- return this;
- }
- }
- we.DEFAULT_UP = /* @__PURE__ */ new j(0, 1, 0);
- we.DEFAULT_MATRIX_AUTO_UPDATE = !0;
- we.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0;
- const go = {
- aliceblue: 15792383,
- antiquewhite: 16444375,
- aqua: 65535,
- aquamarine: 8388564,
- azure: 15794175,
- beige: 16119260,
- bisque: 16770244,
- black: 0,
- blanchedalmond: 16772045,
- blue: 255,
- blueviolet: 9055202,
- brown: 10824234,
- burlywood: 14596231,
- cadetblue: 6266528,
- chartreuse: 8388352,
- chocolate: 13789470,
- coral: 16744272,
- cornflowerblue: 6591981,
- cornsilk: 16775388,
- crimson: 14423100,
- cyan: 65535,
- darkblue: 139,
- darkcyan: 35723,
- darkgoldenrod: 12092939,
- darkgray: 11119017,
- darkgreen: 25600,
- darkgrey: 11119017,
- darkkhaki: 12433259,
- darkmagenta: 9109643,
- darkolivegreen: 5597999,
- darkorange: 16747520,
- darkorchid: 10040012,
- darkred: 9109504,
- darksalmon: 15308410,
- darkseagreen: 9419919,
- darkslateblue: 4734347,
- darkslategray: 3100495,
- darkslategrey: 3100495,
- darkturquoise: 52945,
- darkviolet: 9699539,
- deeppink: 16716947,
- deepskyblue: 49151,
- dimgray: 6908265,
- dimgrey: 6908265,
- dodgerblue: 2003199,
- firebrick: 11674146,
- floralwhite: 16775920,
- forestgreen: 2263842,
- fuchsia: 16711935,
- gainsboro: 14474460,
- ghostwhite: 16316671,
- gold: 16766720,
- goldenrod: 14329120,
- gray: 8421504,
- green: 32768,
- greenyellow: 11403055,
- grey: 8421504,
- honeydew: 15794160,
- hotpink: 16738740,
- indianred: 13458524,
- indigo: 4915330,
- ivory: 16777200,
- khaki: 15787660,
- lavender: 15132410,
- lavenderblush: 16773365,
- lawngreen: 8190976,
- lemonchiffon: 16775885,
- lightblue: 11393254,
- lightcoral: 15761536,
- lightcyan: 14745599,
- lightgoldenrodyellow: 16448210,
- lightgray: 13882323,
- lightgreen: 9498256,
- lightgrey: 13882323,
- lightpink: 16758465,
- lightsalmon: 16752762,
- lightseagreen: 2142890,
- lightskyblue: 8900346,
- lightslategray: 7833753,
- lightslategrey: 7833753,
- lightsteelblue: 11584734,
- lightyellow: 16777184,
- lime: 65280,
- limegreen: 3329330,
- linen: 16445670,
- magenta: 16711935,
- maroon: 8388608,
- mediumaquamarine: 6737322,
- mediumblue: 205,
- mediumorchid: 12211667,
- mediumpurple: 9662683,
- mediumseagreen: 3978097,
- mediumslateblue: 8087790,
- mediumspringgreen: 64154,
- mediumturquoise: 4772300,
- mediumvioletred: 13047173,
- midnightblue: 1644912,
- mintcream: 16121850,
- mistyrose: 16770273,
- moccasin: 16770229,
- navajowhite: 16768685,
- navy: 128,
- oldlace: 16643558,
- olive: 8421376,
- olivedrab: 7048739,
- orange: 16753920,
- orangered: 16729344,
- orchid: 14315734,
- palegoldenrod: 15657130,
- palegreen: 10025880,
- paleturquoise: 11529966,
- palevioletred: 14381203,
- papayawhip: 16773077,
- peachpuff: 16767673,
- peru: 13468991,
- pink: 16761035,
- plum: 14524637,
- powderblue: 11591910,
- purple: 8388736,
- rebeccapurple: 6697881,
- red: 16711680,
- rosybrown: 12357519,
- royalblue: 4286945,
- saddlebrown: 9127187,
- salmon: 16416882,
- sandybrown: 16032864,
- seagreen: 3050327,
- seashell: 16774638,
- sienna: 10506797,
- silver: 12632256,
- skyblue: 8900331,
- slateblue: 6970061,
- slategray: 7372944,
- slategrey: 7372944,
- snow: 16775930,
- springgreen: 65407,
- steelblue: 4620980,
- tan: 13808780,
- teal: 32896,
- thistle: 14204888,
- tomato: 16737095,
- turquoise: 4251856,
- violet: 15631086,
- wheat: 16113331,
- white: 16777215,
- whitesmoke: 16119285,
- yellow: 16776960,
- yellowgreen: 10145074
- }, ae = { h: 0, s: 0, l: 0 }, Ki = { h: 0, s: 0, l: 0 };
- function Ds(s, t, e) {
- return e < 0 && (e += 1), e > 1 && (e -= 1), e < 1 / 6 ? s + (t - s) * 6 * e : e < 1 / 2 ? t : e < 2 / 3 ? s + (t - s) * 6 * (2 / 3 - e) : s;
- }
- class fr {
- constructor(t, e, i) {
- return this.isColor = !0, this.r = 1, this.g = 1, this.b = 1, this.set(t, e, i);
- }
- set(t, e, i) {
- if (e === void 0 && i === void 0) {
- const n = t;
- n && n.isColor ? this.copy(n) : typeof n == "number" ? this.setHex(n) : typeof n == "string" && this.setStyle(n);
- } else
- this.setRGB(t, e, i);
- return this;
- }
- setScalar(t) {
- return this.r = t, this.g = t, this.b = t, this;
- }
- setHex(t, e = le) {
- return t = Math.floor(t), this.r = (t >> 16 & 255) / 255, this.g = (t >> 8 & 255) / 255, this.b = (t & 255) / 255, Ft.toWorkingColorSpace(this, e), this;
- }
- setRGB(t, e, i, n = Ft.workingColorSpace) {
- return this.r = t, this.g = e, this.b = i, Ft.toWorkingColorSpace(this, n), this;
- }
- setHSL(t, e, i, n = Ft.workingColorSpace) {
- if (t = ur(t, 1), e = mt(e, 0, 1), i = mt(i, 0, 1), e === 0)
- this.r = this.g = this.b = i;
- else {
- const r = i <= 0.5 ? i * (1 + e) : i + e - i * e, a = 2 * i - r;
- this.r = Ds(a, r, t + 1 / 3), this.g = Ds(a, r, t), this.b = Ds(a, r, t - 1 / 3);
- }
- return Ft.toWorkingColorSpace(this, n), this;
- }
- setStyle(t, e = le) {
- function i(r) {
- r !== void 0 && parseFloat(r) < 1 && console.warn("THREE.Color: Alpha component of " + t + " will be ignored.");
- }
- let n;
- if (n = /^(\w+)\(([^\)]*)\)/.exec(t)) {
- let r;
- const a = n[1], o = n[2];
- switch (a) {
- case "rgb":
- case "rgba":
- if (r = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))
- return i(r[4]), this.setRGB(
- Math.min(255, parseInt(r[1], 10)) / 255,
- Math.min(255, parseInt(r[2], 10)) / 255,
- Math.min(255, parseInt(r[3], 10)) / 255,
- e
- );
- if (r = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))
- return i(r[4]), this.setRGB(
- Math.min(100, parseInt(r[1], 10)) / 100,
- Math.min(100, parseInt(r[2], 10)) / 100,
- Math.min(100, parseInt(r[3], 10)) / 100,
- e
- );
- break;
- case "hsl":
- case "hsla":
- if (r = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))
- return i(r[4]), this.setHSL(
- parseFloat(r[1]) / 360,
- parseFloat(r[2]) / 100,
- parseFloat(r[3]) / 100,
- e
- );
- break;
- default:
- console.warn("THREE.Color: Unknown color model " + t);
- }
- } else if (n = /^\#([A-Fa-f\d]+)$/.exec(t)) {
- const r = n[1], a = r.length;
- if (a === 3)
- return this.setRGB(
- parseInt(r.charAt(0), 16) / 15,
- parseInt(r.charAt(1), 16) / 15,
- parseInt(r.charAt(2), 16) / 15,
- e
- );
- if (a === 6)
- return this.setHex(parseInt(r, 16), e);
- console.warn("THREE.Color: Invalid hex color " + t);
- } else if (t && t.length > 0)
- return this.setColorName(t, e);
- return this;
- }
- setColorName(t, e = le) {
- const i = go[t.toLowerCase()];
- return i !== void 0 ? this.setHex(i, e) : console.warn("THREE.Color: Unknown color " + t), this;
- }
- clone() {
- return new this.constructor(this.r, this.g, this.b);
- }
- copy(t) {
- return this.r = t.r, this.g = t.g, this.b = t.b, this;
- }
- copySRGBToLinear(t) {
- return this.r = Qe(t.r), this.g = Qe(t.g), this.b = Qe(t.b), this;
- }
- copyLinearToSRGB(t) {
- return this.r = Ps(t.r), this.g = Ps(t.g), this.b = Ps(t.b), this;
- }
- convertSRGBToLinear() {
- return this.copySRGBToLinear(this), this;
- }
- convertLinearToSRGB() {
- return this.copyLinearToSRGB(this), this;
- }
- getHex(t = le) {
- return Ft.fromWorkingColorSpace(yt.copy(this), t), Math.round(mt(yt.r * 255, 0, 255)) * 65536 + Math.round(mt(yt.g * 255, 0, 255)) * 256 + Math.round(mt(yt.b * 255, 0, 255));
- }
- getHexString(t = le) {
- return ("000000" + this.getHex(t).toString(16)).slice(-6);
- }
- getHSL(t, e = Ft.workingColorSpace) {
- Ft.fromWorkingColorSpace(yt.copy(this), e);
- const i = yt.r, n = yt.g, r = yt.b, a = Math.max(i, n, r), o = Math.min(i, n, r);
- let h, l;
- const A = (o + a) / 2;
- if (o === a)
- h = 0, l = 0;
- else {
- const u = a - o;
- switch (l = A <= 0.5 ? u / (a + o) : u / (2 - a - o), a) {
- case i:
- h = (n - r) / u + (n < r ? 6 : 0);
- break;
- case n:
- h = (r - i) / u + 2;
- break;
- case r:
- h = (i - n) / u + 4;
- break;
- }
- h /= 6;
- }
- return t.h = h, t.s = l, t.l = A, t;
- }
- getRGB(t, e = Ft.workingColorSpace) {
- return Ft.fromWorkingColorSpace(yt.copy(this), e), t.r = yt.r, t.g = yt.g, t.b = yt.b, t;
- }
- getStyle(t = le) {
- Ft.fromWorkingColorSpace(yt.copy(this), t);
- const e = yt.r, i = yt.g, n = yt.b;
- return t !== le ? `color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})` : `rgb(${Math.round(e * 255)},${Math.round(i * 255)},${Math.round(n * 255)})`;
- }
- offsetHSL(t, e, i) {
- return this.getHSL(ae), this.setHSL(ae.h + t, ae.s + e, ae.l + i);
- }
- add(t) {
- return this.r += t.r, this.g += t.g, this.b += t.b, this;
- }
- addColors(t, e) {
- return this.r = t.r + e.r, this.g = t.g + e.g, this.b = t.b + e.b, this;
- }
- addScalar(t) {
- return this.r += t, this.g += t, this.b += t, this;
- }
- sub(t) {
- return this.r = Math.max(0, this.r - t.r), this.g = Math.max(0, this.g - t.g), this.b = Math.max(0, this.b - t.b), this;
- }
- multiply(t) {
- return this.r *= t.r, this.g *= t.g, this.b *= t.b, this;
- }
- multiplyScalar(t) {
- return this.r *= t, this.g *= t, this.b *= t, this;
- }
- lerp(t, e) {
- return this.r += (t.r - this.r) * e, this.g += (t.g - this.g) * e, this.b += (t.b - this.b) * e, this;
- }
- lerpColors(t, e, i) {
- return this.r = t.r + (e.r - t.r) * i, this.g = t.g + (e.g - t.g) * i, this.b = t.b + (e.b - t.b) * i, this;
- }
- lerpHSL(t, e) {
- this.getHSL(ae), t.getHSL(Ki);
- const i = Mi(ae.h, Ki.h, e), n = Mi(ae.s, Ki.s, e), r = Mi(ae.l, Ki.l, e);
- return this.setHSL(i, n, r), this;
- }
- setFromVector3(t) {
- return this.r = t.x, this.g = t.y, this.b = t.z, this;
- }
- applyMatrix3(t) {
- const e = this.r, i = this.g, n = this.b, r = t.elements;
- return this.r = r[0] * e + r[3] * i + r[6] * n, this.g = r[1] * e + r[4] * i + r[7] * n, this.b = r[2] * e + r[5] * i + r[8] * n, this;
- }
- equals(t) {
- return t.r === this.r && t.g === this.g && t.b === this.b;
- }
- fromArray(t, e = 0) {
- return this.r = t[e], this.g = t[e + 1], this.b = t[e + 2], this;
- }
- toArray(t = [], e = 0) {
- return t[e] = this.r, t[e + 1] = this.g, t[e + 2] = this.b, t;
- }
- fromBufferAttribute(t, e) {
- return this.r = t.getX(e), this.g = t.getY(e), this.b = t.getZ(e), this;
- }
- toJSON() {
- return this.getHex();
- }
- *[Symbol.iterator]() {
- yield this.r, yield this.g, yield this.b;
- }
- }
- const yt = /* @__PURE__ */ new fr();
- fr.NAMES = go;
- class cA extends Ae {
- constructor(t, e, i, n, r, a, o, h, l, A) {
- if (A = A !== void 0 ? A : Cs, A !== Cs && A !== Qr)
- throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");
- i === void 0 && A === Cs && (i = kl), i === void 0 && A === Qr && (i = Dl), super(null, n, r, a, o, h, A, i, l), this.isDepthTexture = !0, this.image = { width: t, height: e }, this.magFilter = o !== void 0 ? o : qr, this.minFilter = h !== void 0 ? h : qr, this.flipY = !1, this.generateMipmaps = !1, this.compareFunction = null;
- }
- copy(t) {
- return super.copy(t), this.compareFunction = t.compareFunction, this;
- }
- toJSON(t) {
- const e = super.toJSON(t);
- return this.compareFunction !== null && (e.compareFunction = this.compareFunction), e;
- }
- }
- const dA = /* @__PURE__ */ new cA(1, 1);
- dA.compareFunction = Ll;
- const uA = {
- triangulate: function(s, t, e = 2) {
- const i = t && t.length, n = i ? t[0] * e : s.length;
- let r = po(s, 0, n, e, !0);
- const a = [];
- if (!r || r.next === r.prev)
- return a;
- let o, h, l, A, u, f, c;
- if (i && (r = mA(s, t, r, e)), s.length > 80 * e) {
- o = l = s[0], h = A = s[1];
- for (let d = e; d < n; d += e)
- u = s[d], f = s[d + 1], u < o && (o = u), f < h && (h = f), u > l && (l = u), f > A && (A = f);
- c = Math.max(l - o, A - h), c = c !== 0 ? 32767 / c : 0;
- }
- return Fi(r, a, e, o, h, c, 0), a;
- }
- };
- function po(s, t, e, i, n) {
- let r, a;
- if (n === FA(s, t, e, i) > 0)
- for (r = t; r < e; r += i)
- a = ua(r, s[r], s[r + 1], a);
- else
- for (r = e - i; r >= t; r -= i)
- a = ua(r, s[r], s[r + 1], a);
- return a && Ln(a, a.next) && (Di(a), a = a.next), a;
- }
- function Ce(s, t) {
- if (!s)
- return s;
- t || (t = s);
- let e = s, i;
- do
- if (i = !1, !e.steiner && (Ln(e, e.next) || at(e.prev, e, e.next) === 0)) {
- if (Di(e), e = t = e.prev, e === e.next)
- break;
- i = !0;
- } else
- e = e.next;
- while (i || e !== t);
- return t;
- }
- function Fi(s, t, e, i, n, r, a) {
- if (!s)
- return;
- !a && r && wA(s, i, n, r);
- let o = s, h, l;
- for (; s.prev !== s.next; ) {
- if (h = s.prev, l = s.next, r ? gA(s, i, n, r) : fA(s)) {
- t.push(h.i / e | 0), t.push(s.i / e | 0), t.push(l.i / e | 0), Di(s), s = l.next, o = l.next;
- continue;
- }
- if (s = l, s === o) {
- a ? a === 1 ? (s = pA(Ce(s), t, e), Fi(s, t, e, i, n, r, 2)) : a === 2 && yA(s, t, e, i, n, r) : Fi(Ce(s), t, e, i, n, r, 1);
- break;
- }
- }
- }
- function fA(s) {
- const t = s.prev, e = s, i = s.next;
- if (at(t, e, i) >= 0)
- return !1;
- const n = t.x, r = e.x, a = i.x, o = t.y, h = e.y, l = i.y, A = n < r ? n < a ? n : a : r < a ? r : a, u = o < h ? o < l ? o : l : h < l ? h : l, f = n > r ? n > a ? n : a : r > a ? r : a, c = o > h ? o > l ? o : l : h > l ? h : l;
- let d = i.next;
- for (; d !== t; ) {
- if (d.x >= A && d.x <= f && d.y >= u && d.y <= c && Ye(n, o, r, h, a, l, d.x, d.y) && at(d.prev, d, d.next) >= 0)
- return !1;
- d = d.next;
- }
- return !0;
- }
- function gA(s, t, e, i) {
- const n = s.prev, r = s, a = s.next;
- if (at(n, r, a) >= 0)
- return !1;
- const o = n.x, h = r.x, l = a.x, A = n.y, u = r.y, f = a.y, c = o < h ? o < l ? o : l : h < l ? h : l, d = A < u ? A < f ? A : f : u < f ? u : f, p = o > h ? o > l ? o : l : h > l ? h : l, m = A > u ? A > f ? A : f : u > f ? u : f, v = Ks(c, d, t, e, i), _ = Ks(p, m, t, e, i);
- let g = s.prevZ, y = s.nextZ;
- for (; g && g.z >= v && y && y.z <= _; ) {
- if (g.x >= c && g.x <= p && g.y >= d && g.y <= m && g !== n && g !== a && Ye(o, A, h, u, l, f, g.x, g.y) && at(g.prev, g, g.next) >= 0 || (g = g.prevZ, y.x >= c && y.x <= p && y.y >= d && y.y <= m && y !== n && y !== a && Ye(o, A, h, u, l, f, y.x, y.y) && at(y.prev, y, y.next) >= 0))
- return !1;
- y = y.nextZ;
- }
- for (; g && g.z >= v; ) {
- if (g.x >= c && g.x <= p && g.y >= d && g.y <= m && g !== n && g !== a && Ye(o, A, h, u, l, f, g.x, g.y) && at(g.prev, g, g.next) >= 0)
- return !1;
- g = g.prevZ;
- }
- for (; y && y.z <= _; ) {
- if (y.x >= c && y.x <= p && y.y >= d && y.y <= m && y !== n && y !== a && Ye(o, A, h, u, l, f, y.x, y.y) && at(y.prev, y, y.next) >= 0)
- return !1;
- y = y.nextZ;
- }
- return !0;
- }
- function pA(s, t, e) {
- let i = s;
- do {
- const n = i.prev, r = i.next.next;
- !Ln(n, r) && yo(n, i, i.next, r) && ki(n, r) && ki(r, n) && (t.push(n.i / e | 0), t.push(i.i / e | 0), t.push(r.i / e | 0), Di(i), Di(i.next), i = s = r), i = i.next;
- } while (i !== s);
- return Ce(i);
- }
- function yA(s, t, e, i, n, r) {
- let a = s;
- do {
- let o = a.next.next;
- for (; o !== a.prev; ) {
- if (a.i !== o.i && MA(a, o)) {
- let h = mo(a, o);
- a = Ce(a, a.next), h = Ce(h, h.next), Fi(a, t, e, i, n, r, 0), Fi(h, t, e, i, n, r, 0);
- return;
- }
- o = o.next;
- }
- a = a.next;
- } while (a !== s);
- }
- function mA(s, t, e, i) {
- const n = [];
- let r, a, o, h, l;
- for (r = 0, a = t.length; r < a; r++)
- o = t[r] * i, h = r < a - 1 ? t[r + 1] * i : s.length, l = po(s, o, h, i, !1), l === l.next && (l.steiner = !0), n.push(CA(l));
- for (n.sort(vA), r = 0; r < n.length; r++)
- e = _A(n[r], e);
- return e;
- }
- function vA(s, t) {
- return s.x - t.x;
- }
- function _A(s, t) {
- const e = xA(s, t);
- if (!e)
- return t;
- const i = mo(e, s);
- return Ce(i, i.next), Ce(e, e.next);
- }
- function xA(s, t) {
- let e = t, i = -1 / 0, n;
- const r = s.x, a = s.y;
- do {
- if (a <= e.y && a >= e.next.y && e.next.y !== e.y) {
- const f = e.x + (a - e.y) * (e.next.x - e.x) / (e.next.y - e.y);
- if (f <= r && f > i && (i = f, n = e.x < e.next.x ? e : e.next, f === r))
- return n;
- }
- e = e.next;
- } while (e !== t);
- if (!n)
- return null;
- const o = n, h = n.x, l = n.y;
- let A = 1 / 0, u;
- e = n;
- do
- r >= e.x && e.x >= h && r !== e.x && Ye(a < l ? r : i, a, h, l, a < l ? i : r, a, e.x, e.y) && (u = Math.abs(a - e.y) / (r - e.x), ki(e, s) && (u < A || u === A && (e.x > n.x || e.x === n.x && bA(n, e))) && (n = e, A = u)), e = e.next;
- while (e !== o);
- return n;
- }
- function bA(s, t) {
- return at(s.prev, s, t.prev) < 0 && at(t.next, s, s.next) < 0;
- }
- function wA(s, t, e, i) {
- let n = s;
- do
- n.z === 0 && (n.z = Ks(n.x, n.y, t, e, i)), n.prevZ = n.prev, n.nextZ = n.next, n = n.next;
- while (n !== s);
- n.prevZ.nextZ = null, n.prevZ = null, SA(n);
- }
- function SA(s) {
- let t, e, i, n, r, a, o, h, l = 1;
- do {
- for (e = s, s = null, r = null, a = 0; e; ) {
- for (a++, i = e, o = 0, t = 0; t < l && (o++, i = i.nextZ, !!i); t++)
- ;
- for (h = l; o > 0 || h > 0 && i; )
- o !== 0 && (h === 0 || !i || e.z <= i.z) ? (n = e, e = e.nextZ, o--) : (n = i, i = i.nextZ, h--), r ? r.nextZ = n : s = n, n.prevZ = r, r = n;
- e = i;
- }
- r.nextZ = null, l *= 2;
- } while (a > 1);
- return s;
- }
- function Ks(s, t, e, i, n) {
- return s = (s - e) * n | 0, t = (t - i) * n | 0, s = (s | s << 8) & 16711935, s = (s | s << 4) & 252645135, s = (s | s << 2) & 858993459, s = (s | s << 1) & 1431655765, t = (t | t << 8) & 16711935, t = (t | t << 4) & 252645135, t = (t | t << 2) & 858993459, t = (t | t << 1) & 1431655765, s | t << 1;
- }
- function CA(s) {
- let t = s, e = s;
- do
- (t.x < e.x || t.x === e.x && t.y < e.y) && (e = t), t = t.next;
- while (t !== s);
- return e;
- }
- function Ye(s, t, e, i, n, r, a, o) {
- return (n - a) * (t - o) >= (s - a) * (r - o) && (s - a) * (i - o) >= (e - a) * (t - o) && (e - a) * (r - o) >= (n - a) * (i - o);
- }
- function MA(s, t) {
- return s.next.i !== t.i && s.prev.i !== t.i && !PA(s, t) && // dones't intersect other edges
- (ki(s, t) && ki(t, s) && EA(s, t) && // locally visible
- (at(s.prev, s, t.prev) || at(s, t.prev, t)) || // does not create opposite-facing sectors
- Ln(s, t) && at(s.prev, s, s.next) > 0 && at(t.prev, t, t.next) > 0);
- }
- function at(s, t, e) {
- return (t.y - s.y) * (e.x - t.x) - (t.x - s.x) * (e.y - t.y);
- }
- function Ln(s, t) {
- return s.x === t.x && s.y === t.y;
- }
- function yo(s, t, e, i) {
- const n = Ji(at(s, t, e)), r = Ji(at(s, t, i)), a = Ji(at(e, i, s)), o = Ji(at(e, i, t));
- return !!(n !== r && a !== o || n === 0 && Zi(s, e, t) || r === 0 && Zi(s, i, t) || a === 0 && Zi(e, s, i) || o === 0 && Zi(e, t, i));
- }
- function Zi(s, t, e) {
- return t.x <= Math.max(s.x, e.x) && t.x >= Math.min(s.x, e.x) && t.y <= Math.max(s.y, e.y) && t.y >= Math.min(s.y, e.y);
- }
- function Ji(s) {
- return s > 0 ? 1 : s < 0 ? -1 : 0;
- }
- function PA(s, t) {
- let e = s;
- do {
- if (e.i !== s.i && e.next.i !== s.i && e.i !== t.i && e.next.i !== t.i && yo(e, e.next, s, t))
- return !0;
- e = e.next;
- } while (e !== s);
- return !1;
- }
- function ki(s, t) {
- return at(s.prev, s, s.next) < 0 ? at(s, t, s.next) >= 0 && at(s, s.prev, t) >= 0 : at(s, t, s.prev) < 0 || at(s, s.next, t) < 0;
- }
- function EA(s, t) {
- let e = s, i = !1;
- const n = (s.x + t.x) / 2, r = (s.y + t.y) / 2;
- do
- e.y > r != e.next.y > r && e.next.y !== e.y && n < (e.next.x - e.x) * (r - e.y) / (e.next.y - e.y) + e.x && (i = !i), e = e.next;
- while (e !== s);
- return i;
- }
- function mo(s, t) {
- const e = new Zs(s.i, s.x, s.y), i = new Zs(t.i, t.x, t.y), n = s.next, r = t.prev;
- return s.next = t, t.prev = s, e.next = n, n.prev = e, i.next = e, e.prev = i, r.next = i, i.prev = r, i;
- }
- function ua(s, t, e, i) {
- const n = new Zs(s, t, e);
- return i ? (n.next = i.next, n.prev = i, i.next.prev = n, i.next = n) : (n.prev = n, n.next = n), n;
- }
- function Di(s) {
- s.next.prev = s.prev, s.prev.next = s.next, s.prevZ && (s.prevZ.nextZ = s.nextZ), s.nextZ && (s.nextZ.prevZ = s.prevZ);
- }
- function Zs(s, t, e) {
- this.i = s, this.x = t, this.y = e, this.prev = null, this.next = null, this.z = 0, this.prevZ = null, this.nextZ = null, this.steiner = !1;
- }
- function FA(s, t, e, i) {
- let n = 0;
- for (let r = t, a = e - i; r < e; r += i)
- n += (s[a] - s[r]) * (s[r + 1] + s[a + 1]), a = r;
- return n;
- }
- class gr {
- // calculate area of the contour polygon
- static area(t) {
- const e = t.length;
- let i = 0;
- for (let n = e - 1, r = 0; r < e; n = r++)
- i += t[n].x * t[r].y - t[r].x * t[n].y;
- return i * 0.5;
- }
- static isClockWise(t) {
- return gr.area(t) < 0;
- }
- static triangulateShape(t, e) {
- const i = [], n = [], r = [];
- fa(t), ga(i, t);
- let a = t.length;
- e.forEach(fa);
- for (let h = 0; h < e.length; h++)
- n.push(a), a += e[h].length, ga(i, e[h]);
- const o = uA.triangulate(i, n);
- for (let h = 0; h < o.length; h += 3)
- r.push(o.slice(h, h + 3));
- return r;
- }
- }
- function fa(s) {
- const t = s.length;
- t > 2 && s[t - 1].equals(s[0]) && s.pop();
- }
- function ga(s, t) {
- for (let e = 0; e < t.length; e++)
- s.push(t[e].x), s.push(t[e].y);
- }
- const pa = /* @__PURE__ */ new j(), tn = /* @__PURE__ */ new j();
- class kA {
- constructor(t = new j(), e = new j()) {
- this.start = t, this.end = e;
- }
- set(t, e) {
- return this.start.copy(t), this.end.copy(e), this;
- }
- copy(t) {
- return this.start.copy(t.start), this.end.copy(t.end), this;
- }
- getCenter(t) {
- return t.addVectors(this.start, this.end).multiplyScalar(0.5);
- }
- delta(t) {
- return t.subVectors(this.end, this.start);
- }
- distanceSq() {
- return this.start.distanceToSquared(this.end);
- }
- distance() {
- return this.start.distanceTo(this.end);
- }
- at(t, e) {
- return this.delta(e).multiplyScalar(t).add(this.start);
- }
- closestPointToPointParameter(t, e) {
- pa.subVectors(t, this.start), tn.subVectors(this.end, this.start);
- const i = tn.dot(tn);
- let r = tn.dot(pa) / i;
- return e && (r = mt(r, 0, 1)), r;
- }
- closestPointToPoint(t, e, i) {
- const n = this.closestPointToPointParameter(t, e);
- return this.delta(i).multiplyScalar(n).add(this.start);
- }
- applyMatrix4(t) {
- return this.start.applyMatrix4(t), this.end.applyMatrix4(t), this;
- }
- equals(t) {
- return t.start.equals(this.start) && t.end.equals(this.end);
- }
- clone() {
- return new this.constructor().copy(this);
- }
- }
- typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: {
- revision: oo
- } }));
- typeof window < "u" && (window.__THREE__ ? console.warn("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = oo);
- const Js = (s) => new X(s[2] - s[0], s[3] - s[1]).normalize(), ya = 1e-6, oe = (s, t) => Math.abs(s[0] - t[0]) < ya && Math.abs(s[1] - t[1]) < ya, Et = (s, t) => new X(s[0], s[1]).distanceTo({ x: t[0], y: t[1] }), Qu = (s) => new X(s[0], s[1]).length(), ce = (s) => Js(s).toArray(), pr = (s) => new X(-s[1], s[0]).normalize().toArray(), DA = (s, t) => {
- const e = new Jt().set(
- Math.cos(t),
- -Math.sin(t),
- 0,
- Math.sin(t),
- Math.cos(t),
- 0,
- 0,
- 0,
- 1
- ), i = new X(s[0], s[1]);
- return i.applyMatrix3(e), i.toArray();
- }, Ke = (s, t, e) => {
- const i = new X(s[0], s[1]);
- return [
- ...t,
- ...i.multiplyScalar(e).add({ x: t[0], y: t[1] }).toArray()
- ];
- }, IA = (s) => pr(ce(s)), Ku = (s, t = [0, 0], e = 1) => {
- const i = pr(s), n = new X(i[0], i[1]);
- return n.multiplyScalar(e).add({ x: t[0], y: t[1] }), [...t, ...n.toArray()];
- }, Xe = (s, t) => {
- const e = new X(s[0], s[1]), i = new X(t[0], t[1]), n = e.angleTo(i);
- return e.cross(i) > 0 ? n : -n;
- }, TA = (s, t) => Xe(ce(s), ce(t)), LA = (s, t) => Xe(t, ce(s)), Zu = (s) => [(s[0] + s[2]) / 2, (s[1] + s[3]) / 2], Ot = (s, t = 2) => {
- const e = Math.pow(10, t);
- return Math.round(s * e) / e;
- };
- var vo = /* @__PURE__ */ ((s) => (s.Overlap = "Overlap", s.Intersect = "Intersect", s.ExtendIntersect = "ExtendIntersect", s.Parallel = "Parallel", s.Join = "Join", s.Equal = "Equal", s.None = "None", s))(vo || {});
- const RA = (s, t) => {
- const e = s.slice(0, 2), i = t.slice(0, 2), n = s.slice(2, 4), r = t.slice(2, 4);
- if (oe(e, i) && oe(n, r))
- return "Equal";
- const a = oe(e, i) || oe(e, r) || oe(n, i) || oe(n, r), o = Js(s), h = Js(t), l = new X(-o.y, o.x).normalize(), A = new X(-h.y, h.x).normalize(), u = new X(s[0], s[1]), f = new X(t[0], t[1]), c = new X(s[2], s[3]), d = new X(t[2], t[3]), p = Ot(
- A.dot(f.clone().sub(u).normalize()) / A.dot(o),
- 6
- ), m = Ot(
- l.dot(u.clone().sub(f).normalize()) / l.dot(h),
- 6
- ), v = A.negate();
- if (p === 0 && m === 0)
- return "Overlap";
- if (oe([l.x, l.y], [A.x, A.y]) || oe([l.x, l.y], [v.x, v.y]))
- return a ? "Overlap" : "Parallel";
- {
- if (a)
- return "Join";
- const _ = (d.y - f.y) * (c.x - u.x) - (d.x - f.x) * (c.y - u.y), g = Ot(
- ((d.x - f.x) * (u.y - f.y) - (d.y - f.y) * (u.x - f.x)) / _,
- 6
- ), y = Ot(
- ((c.x - u.x) * (u.y - f.y) - (c.y - u.y) * (u.x - f.x)) / _,
- 6
- );
- return g >= 0 && g <= 1 && y >= 0 && y <= 1 ? "Intersect" : "ExtendIntersect";
- }
- }, _o = (s, t, e = [
- "Overlap",
- "Intersect",
- "ExtendIntersect",
- "Parallel",
- "Join",
- "Equal",
- "None"
- /* None */
- ]) => {
- let i = RA(s, t);
- if (!e.includes(i))
- return null;
- const n = new X(s[0], s[1]), r = new X(s[2], s[3]), a = new X(t[0], t[1]), o = new X(t[2], t[3]), h = r.clone().sub(n), l = o.clone().sub(a), A = h.x, u = -l.x, f = h.y, c = -l.y, d = a.x - n.x, p = a.y - n.y, m = (c * d - u * p) / (A * c - u * f);
- return n.clone().add(h.clone().multiplyScalar(m)).toArray();
- }, Ui = (s, t) => {
- const e = new X(s[0], s[1]), i = new X(s[2], s[3]), n = new X(t[0], t[1]), r = i.clone().sub(e), o = n.clone().sub(e).dot(r.normalize()), h = e.add(r.multiplyScalar(o));
- return {
- point: h.toArray(),
- len: h.distanceTo(e)
- };
- }, OA = (s, t) => {
- const e = new kA(
- new j(s[0], s[1], 0),
- new j(s[2], s[3], 0)
- ), i = new j(t[0], t[1], 0), n = e.closestPointToPoint(i, !0, new j());
- return [n.x, n.y];
- }, NA = (s, t) => {
- const e = OA(s, t);
- return Et(t, e);
- }, Ju = (s) => {
- const t = s.map((e) => new X(e[0], e[1]));
- return gr.isClockWise(t);
- }, t1 = (s, t, e = 5) => {
- const i = [];
- for (let n = 0; n < e; n++) {
- const r = t.map((o) => o *= n + 1), a = Ui(s, [
- s[0] + r[0],
- s[1] + r[1]
- ]).point;
- i.push(a);
- }
- return i;
- };
- let xe = !1;
- const Pi = [], xo = () => {
- xe = !0, Pi.forEach((s) => s.draggable(!1));
- }, bo = () => {
- xe = !1, Pi.forEach((s) => s.draggable(!0));
- }, Is = (s, t = []) => ["draging", "active", "hover", "common"].find((i) => s[i] && !t.includes(i)), ma = (s, t, e = "mouse-style") => {
- s.listening(!0);
- const i = [], n = (_, g) => {
- s.on(_, g), i.push(_);
- };
- let r;
- t.bus && t.bus.on("statusChange", (_) => {
- r = _, A();
- });
- const a = {
- hover: !1,
- draging: !1,
- active: !1,
- common: !1
- };
- let o = "common", h = "common", l;
- const A = (_, g) => {
- const y = Is(a);
- if (t.bus && (h !== y || l !== g)) {
- const C = o;
- h = y, t.bus.emit("shapeStatusChange", {
- current: y,
- before: C,
- type: g
- });
- }
- let x = r ? Is(r) : xe ? null : y;
- const b = r ? [r, a] : [a];
- for (const C of b) {
- const w = { ...C };
- for (; x && !(x in t); )
- w[x] = !1, x = Is(w);
- if (x)
- break;
- }
- x = x || "common", o !== x && (t[x] && t[x](_), o = x);
- };
- n(`mouseenter.${e}`, (_) => {
- a.hover = !0, A(_, "mouse");
- }), n(`mouseleave.${e}`, (_) => {
- a.hover = !1, A(_, "mouse");
- });
- let u, f = 0;
- n(`click.${e} touchend.${e}`, (_) => {
- a.active = !0, A(_, "click"), f = Date.now();
- });
- const c = `click.${e}${s.id()} touchend.${e}${s.id()}`;
- let d = 3, p, m = !1;
- const v = setInterval(() => {
- if (!(p = s.getStage())) {
- d < -5 && clearInterval(v), --d < 0 && (m && console.error("可能发生资源泄露"), m = !0);
- return;
- }
- clearInterval(v), p.on(c, (_) => {
- Date.now() - f > 50 && _.target !== s && (a.active = !1, A(_, "click"));
- });
- }, 100);
- return u = () => {
- p && p.off(c), clearInterval(v);
- }, n(`dragstart.${e}`, (_) => {
- a.draging = !0, A(_, "mouse");
- }), n(`dragend.${e}`, (_) => {
- setTimeout(() => {
- a.draging = !1, A(_, "mouse");
- }, 16);
- }), () => {
- s.listening(!1), s.off(i.join(" ")), u && u();
- };
- }, yr = (s, t, e = !0, i = !1) => {
- let n = null;
- return xe || s.draggable(!0), Pi.push(s), s.dragBoundFunc((r, a) => {
- if (!xe) {
- let o = r;
- e && (o = be(s, i).invert().point(r)), t.moveHandler([o.x, o.y], n, a);
- }
- return s.absolutePosition();
- }), t.readyHandler && s.on("dragstart.drag", (r) => {
- xe || (n = t.readyHandler(r));
- }), t.endHandler && s.on("dragend.drag", (r) => {
- xe || t.endHandler(n, r);
- }), () => {
- const r = Pi.indexOf(s);
- ~r && Pi.splice(r, 1), s.draggable(!1), s.off("dragstart.drag dragend.drag");
- };
- }, ln = (s, t) => {
- s.enableDrag({
- readyHandler(e) {
- return t.readyHandler && t.readyHandler(s.attrib, e);
- },
- moveHandler(e, i, n) {
- return t.moveHandler(s.attrib, e, i, n);
- },
- endHandler(e, i) {
- return t.endHandler && t.endHandler(s.attrib, e, i);
- }
- });
- }, wo = (s, t) => {
- if (t(s))
- return s;
- if ("children" in s) {
- for (const e of s.children)
- if (wo(e, t))
- return e;
- }
- return null;
- }, So = (s, t) => {
- for (; s; ) {
- if (t(s))
- return s;
- s = s.parent;
- }
- return null;
- }, e1 = (s, t) => !!wo(s, (i) => i === t), GA = Object.prototype.toString, BA = (s) => GA.call(s), An = (s) => BA(s).slice(8, -1), We = (s, t, e) => {
- if (s === t)
- return !1;
- const i = An(s), n = An(t);
- if (i !== n)
- return !0;
- if (i === "String" || i === "Number" || i === "Boolean")
- return i === "Number" && isNaN(s) && isNaN(t) ? !1 : s !== t;
- const r = Array.from(e.values());
- for (const a of r)
- if (a.includes(s) && a.includes(t))
- return !1;
- if (e.add([s, t]), i === "Array")
- return s.length !== t.length || s.some((a, o) => We(a, t[o], e));
- if (i === "Object") {
- const a = Object.keys(s).sort(), o = Object.keys(t).sort();
- return We(a, o, e) || a.some((h) => We(s[h], t[h], e));
- } else if (i === "Map") {
- const a = Array.from(s.keys()).sort(), o = Array.from(t.keys()).sort();
- return We(a, o, e) || a.some((h) => We(s.get(h), t.get(h), e));
- } else
- return i === "Set" ? di(Array.from(s.values()), Array.from(t.values())) : s !== t;
- }, di = (s, t) => We(s, t, /* @__PURE__ */ new Set()), i1 = (s, t) => {
- for (const e in t)
- typeof s[e] == "function" && s[e](t[e]);
- }, Co = (s, t = []) => {
- const e = s.filter((r) => !t.includes(r)), i = t.filter((r) => !s.includes(r)), n = t.filter((r) => s.includes(r));
- return { addPort: e, delPort: i, holdPort: n };
- }, Rn = (s, t) => {
- const e = s.map(({ id: a }) => a), i = t.map(({ id: a }) => a), n = Co(e, i), r = s.filter(
- (a) => !t.includes(a) && i.includes(a.id)
- ).map((a) => a.id);
- return t = s, { ...n, changePort: r };
- }, n1 = (s, t, e = !0) => fe(
- () => [...s],
- (i, n = []) => {
- t(Rn(i, n));
- },
- { immediate: e, flush: "sync" }
- ), s1 = (s) => {
- const t = ti(s()), e = fe(s, (i) => {
- di(t, i) && (Array.isArray(i) ? i.forEach((n, r) => {
- t[r] = n;
- }) : (Object.keys(t).forEach((n) => delete t[n]), Object.assign(t, i)));
- });
- return {
- data: t,
- stop: e
- };
- }, r1 = (s) => {
- const t = ti(s()), e = fe(s, (i, n) => {
- const { addPort: r, delPort: a, changePort: o } = Rn(
- i,
- n
- );
- for (const h of a) {
- const l = t.findIndex((A) => A.id === h);
- ~l && t.splice(l, 1);
- }
- for (const h of r) {
- const l = i.find((A) => A.id === h);
- l && t.push(l);
- }
- for (const h of o) {
- const l = t.findIndex((u) => u.id === h), A = i.findIndex((u) => u.id === h);
- di(t[l], i[A]) && (t[l] = i[A]);
- }
- });
- return {
- data: t,
- stop: e
- };
- }, Ts = (s, t) => {
- var l, A;
- if (!di(s, t))
- return t;
- if (!t)
- return s;
- const e = s, i = t, n = An(e);
- if (An(t) !== n)
- return s;
- switch (n) {
- case "Array":
- if ((l = e[0]) != null && l.id || (A = i[0]) != null && A.id) {
- var { changePort: r, addPort: a, delPort: o } = Rn(e, i);
- a.forEach((p) => {
- i.push(e.find(({ id: m }) => m === p));
- }), o.forEach((p) => {
- const m = i.findIndex(({ id: v }) => v === p);
- ~m && i.splice(m, 1);
- }), r.forEach((p) => {
- const m = e.find(({ id: _ }) => _ === p), v = i.findIndex(({ id: _ }) => _ === p);
- i[v] = Ts(m, i[v]);
- });
- } else {
- for (let c = 0; c < e.length; c++)
- i[c] = Ts(e[c], i[c]);
- for (; i.length !== e.length; )
- i.pop();
- }
- break;
- case "Object":
- const u = Object.keys(i).sort(), f = Object.keys(e).sort();
- var { addPort: a, delPort: o, holdPort: h } = Co(f, u);
- for (let c = 0; c < h.length; c++)
- i[u[c]] = Ts(
- e[h[c]],
- i[h[c]]
- );
- a.forEach((c) => i[c] = e[c]), o.forEach((c) => delete i[c]);
- break;
- default:
- return s;
- }
- return t;
- }, a1 = (s, t) => {
- t.forEach((e) => {
- const i = new Ni({
- fill: "red",
- radius: 5,
- x: e[0],
- y: e[1]
- });
- s.children[0].add(i);
- });
- }, Mo = (s) => {
- const t = [];
- for (const e of s.children)
- t.push(e, ...Mo(e));
- return t;
- }, zA = (s) => (Math.max(1, ...s.map(({ id: t }) => Number(t))) + 1).toString(), mr = (...s) => () => {
- s.forEach((t) => {
- Array.isArray(t) ? t.forEach((e) => e()) : t();
- });
- }, UA = (s) => s ? {
- reactive: s.props.reactive,
- readonly: s.props.reactive
- } : {}, HA = (s, t, e, i, n) => {
- const r = new t({
- attrib: s,
- ...UA(e)
- });
- return i && i(r), e && (r.container = e.container, r.setParent(e)), r.init(), r.mount(r.teleport), e != null && e.isMounted && r.mounted(), n && n(r), r;
- }, Pt = (s, t, e, i) => {
- let n = [];
- const r = (l, A) => l.find((u) => u.id === A), a = {}, o = (l) => {
- const A = a[l];
- return A.destory(), delete a[l], A;
- }, h = (l) => {
- const A = HA(l, s, t, e, i);
- return a[l.id] = A, A;
- };
- return (l) => {
- const A = Array.isArray(l) ? l : [l], { addPort: u, delPort: f, changePort: c } = Rn(
- A,
- n
- ), d = f.map(o), p = u.map((v) => h(r(A, v))), m = c.map((v) => {
- const _ = r(A, v);
- return a[v].setAttrib(_), a[v];
- });
- return n = [...A], {
- adds: p,
- dels: d,
- upds: m
- };
- };
- }, VA = (s) => {
- const t = s.count || 1, e = s.dire || [1, 0], i = s.size, n = s.entity, r = n.shape.getPosition(), a = Ke(e, [r.x, r.y], 10), o = n.container.getSameLevelData(n);
- for (let h = 0; h < t; h++) {
- const l = i.map((f) => f *= h + 1), A = Ui(a, [
- r.x + l[0],
- r.y + l[1]
- ]).point, u = {
- ...s.factoryAttrib(A),
- id: zA(o)
- };
- o.push(u);
- }
- }, Ls = /* @__PURE__ */ new WeakMap(), o1 = (s, t) => {
- const e = Ls.get(s);
- e && e();
- let i = !1;
- const n = () => {
- i || (hn ? s.stage.off("touchend.addEntity") : s.stage.off("click.addEntity"), bo(), Ls.delete(s), i = !0);
- }, r = (A) => {
- n(), o(A);
- }, a = () => {
- n(), h("cancel");
- };
- let o, h;
- return {
- promise: new Promise((A, u) => {
- o = A, h = u;
- const f = (c) => {
- let d = c.evt;
- c.evt instanceof TouchEvent && (d = ao(c));
- const p = s.getRealFromStage([d.offsetX, d.offsetY]);
- r(t(p));
- };
- xo(), Ls.set(s, a), hn ? s.stage.on("touchend.addEntity", f) : s.stage.on("click.addEntity", f);
- }),
- interrupt: a
- };
- }, h1 = (s, t) => {
- s.bus.emit("statusChange", { [t]: !0 });
- }, $A = (s) => {
- const t = ei(!1), e = ei(!1);
- s.bus.on("shapeStatusChange", ({ current: r, type: a }) => {
- r === "active" ? e.value = !e.value : a === "click" ? e.value = !1 : e.value || (t.value = !!r);
- });
- const i = (r) => {
- s.bus.emit("statusChange", { [r]: !0 });
- }, n = fe(
- () => [t.value, e.value],
- ([r, a]) => {
- i(a ? "active" : r ? "hover" : "common");
- },
- { flush: "post" }
- );
- return {
- light: t,
- active: e,
- stop: n
- };
- }, l1 = (s) => {
- const t = ei(), e = ei(), i = s.map($A);
- s.forEach((n) => {
- n.bus.on("destroyed", () => {
- const r = s.indexOf(n);
- ~r && (i[r].stop(), i.splice(r, 1), s.splice(r, 1));
- });
- }), Sn(() => {
- for (let n = 0; n < i.length; n++) {
- const { active: r, light: a } = i[n];
- r.value ? t.value = s[n].attrib.id : t.value === s[n].attrib.id && (t.value = null), a.value ? e.value = s[n].attrib.id : e.value === s[n].attrib.id && (e.value = null);
- }
- });
- }, Mt = {
- fill: "#ffffff",
- radius: 6,
- stroke: "#409EFF",
- strokeWidth: 3,
- zIndex: 3,
- hitStrokeWidth: 5,
- activeFill: "#ffffff",
- activeStroke: "#E6A23C"
- }, On = () => {
- const s = new Ni({
- radius: Mt.radius,
- strokeWidth: Mt.strokeWidth,
- hitStrokeWidth: Mt.hitStrokeWidth
- }), t = () => {
- const [n] = Gt(s, [1, 1]);
- s.scale({ x: n, y: n });
- }, e = () => {
- t(), s.fill(Mt.fill).stroke(Mt.stroke);
- }, i = () => {
- t(), s.fill(Mt.activeFill).stroke(Mt.activeStroke);
- };
- return e(), {
- shape: s,
- setData(n) {
- t(), s.x(n[0]), s.y(n[1]);
- },
- common: e,
- hover: i,
- active: i,
- draging: i
- };
- }, je = {
- strokeWidth: 5,
- hitStrokeWidth: 20,
- stroke: "rgba(230, 162, 60, 1)",
- zIndex: 1,
- activeStroke: "rgba(64, 158, 255, 1)"
- }, ui = () => {
- const s = new Fn({
- strokeScaleEnabled: !1,
- strokeWidth: je.strokeWidth,
- hitStrokeWidth: je.hitStrokeWidth
- }), t = () => {
- s.stroke(je.stroke);
- }, e = () => {
- s.stroke(je.activeStroke);
- };
- return t(), {
- shape: s,
- setData(i) {
- s.points(i);
- },
- common: t,
- hover: t,
- active: e,
- draging: e
- };
- }, cn = {
- fill: "rgba(230, 162, 60, 0.30)",
- activeFill: "rgba(64, 158, 255, 0.3)",
- zIndex: 0
- }, Nn = (s = {}) => {
- let t = "rgba(0, 0, 0, 0)";
- if (qt) {
- const o = new fr();
- o.setHSL(Se.randFloat(0, 1), 1, 0.8), t = "#" + o.getHexString();
- }
- const e = new Nt(), i = new Fn({
- name: "polygon-line",
- closed: !0,
- fill: t
- }), n = s.autoClose ? s.lineFactory ? s.lineFactory() : ui() : null;
- e.add(i), n && e.add(n.shape);
- const r = (o) => {
- i.fill(cn.fill), n && n.common(o);
- }, a = (o) => {
- i.fill(cn.activeFill), n && n.active && n.active(o);
- };
- return r(), {
- closeLine: n,
- shape: e,
- setData(o) {
- if (i.points(o), n)
- if (o.length > 4) {
- const h = [o.length - 2, o.length - 1, 0, 1];
- n.setData(h.map((l) => o[l])), n.shape.visible(!0);
- } else
- n.shape.visible(!1);
- },
- common: r,
- hover: r,
- active: a,
- draging: a
- };
- }, A1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
- __proto__: null,
- line: je,
- lineShapeFactory: ui,
- point: Mt,
- pointShapeFactory: On,
- polygon: cn,
- polygonShapeFactory: Nn
- }, Symbol.toStringTag, { value: "Module" }));
- var vr = { exports: {} }, Gn = {}, Po = {}, Ii = {};
- (function(s) {
- Object.defineProperty(s, "__esModule", { value: !0 }), s.Stage = s.stages = void 0;
- const t = st, e = V, i = Ee, n = $, r = It, a = En, o = $, h = bt;
- var l = "Stage", A = "string", u = "px", f = "mouseout", c = "mouseleave", d = "mouseover", p = "mouseenter", m = "mousemove", v = "mousedown", _ = "mouseup", g = "pointermove", y = "pointerdown", x = "pointerup", b = "pointercancel", C = "lostpointercapture", w = "pointerout", E = "pointerleave", S = "pointerover", P = "pointerenter", k = "contextmenu", F = "touchstart", L = "touchend", I = "touchmove", z = "touchcancel", T = "wheel", G = 5, H = [
- [p, "_pointerenter"],
- [v, "_pointerdown"],
- [m, "_pointermove"],
- [_, "_pointerup"],
- [c, "_pointerleave"],
- [F, "_pointerdown"],
- [I, "_pointermove"],
- [L, "_pointerup"],
- [z, "_pointercancel"],
- [d, "_pointerover"],
- [T, "_wheel"],
- [k, "_contextmenu"],
- [y, "_pointerdown"],
- [g, "_pointermove"],
- [x, "_pointerup"],
- [b, "_pointercancel"],
- [C, "_lostpointercapture"]
- ];
- const R = {
- mouse: {
- [w]: f,
- [E]: c,
- [S]: d,
- [P]: p,
- [g]: m,
- [y]: v,
- [x]: _,
- [b]: "mousecancel",
- pointerclick: "click",
- pointerdblclick: "dblclick"
- },
- touch: {
- [w]: "touchout",
- [E]: "touchleave",
- [S]: "touchover",
- [P]: "touchenter",
- [g]: I,
- [y]: F,
- [x]: L,
- [b]: z,
- pointerclick: "tap",
- pointerdblclick: "dbltap"
- },
- pointer: {
- [w]: w,
- [E]: E,
- [S]: S,
- [P]: P,
- [g]: g,
- [y]: y,
- [x]: x,
- [b]: b,
- pointerclick: "pointerclick",
- pointerdblclick: "pointerdblclick"
- }
- }, N = (dt) => dt.indexOf("pointer") >= 0 ? "pointer" : dt.indexOf("touch") >= 0 ? "touch" : "mouse", q = (dt) => {
- const M = N(dt);
- if (M === "pointer")
- return n.Konva.pointerEventsEnabled && R.pointer;
- if (M === "touch")
- return R.touch;
- if (M === "mouse")
- return R.mouse;
- };
- function et(dt = {}) {
- return (dt.clipFunc || dt.clipWidth || dt.clipHeight) && t.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."), dt;
- }
- const tt = "Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);";
- s.stages = [];
- class Ut extends i.Container {
- constructor(M) {
- super(et(M)), this._pointerPositions = [], this._changedPointerPositions = [], this._buildDOM(), this._bindContentEvents(), s.stages.push(this), this.on("widthChange.konva heightChange.konva", this._resizeDOM), this.on("visibleChange.konva", this._checkVisibility), this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva", () => {
- et(this.attrs);
- }), this._checkVisibility();
- }
- _validateAdd(M) {
- const D = M.getType() === "Layer", B = M.getType() === "FastLayer";
- D || B || t.Util.throw("You may only add layers to the stage.");
- }
- _checkVisibility() {
- if (!this.content)
- return;
- const M = this.visible() ? "" : "none";
- this.content.style.display = M;
- }
- setContainer(M) {
- if (typeof M === A) {
- if (M.charAt(0) === ".") {
- var D = M.slice(1);
- M = document.getElementsByClassName(D)[0];
- } else {
- var B;
- M.charAt(0) !== "#" ? B = M : B = M.slice(1), M = document.getElementById(B);
- }
- if (!M)
- throw "Can not find container in document with id " + B;
- }
- return this._setAttr("container", M), this.content && (this.content.parentElement && this.content.parentElement.removeChild(this.content), M.appendChild(this.content)), this;
- }
- shouldDrawHit() {
- return !0;
- }
- clear() {
- var M = this.children, D = M.length, B;
- for (B = 0; B < D; B++)
- M[B].clear();
- return this;
- }
- clone(M) {
- return M || (M = {}), M.container = typeof document < "u" && document.createElement("div"), i.Container.prototype.clone.call(this, M);
- }
- destroy() {
- super.destroy();
- var M = this.content;
- M && t.Util._isInDocument(M) && this.container().removeChild(M);
- var D = s.stages.indexOf(this);
- return D > -1 && s.stages.splice(D, 1), t.Util.releaseCanvas(this.bufferCanvas._canvas, this.bufferHitCanvas._canvas), this;
- }
- getPointerPosition() {
- const M = this._pointerPositions[0] || this._changedPointerPositions[0];
- return M ? {
- x: M.x,
- y: M.y
- } : (t.Util.warn(tt), null);
- }
- _getPointerById(M) {
- return this._pointerPositions.find((D) => D.id === M);
- }
- getPointersPositions() {
- return this._pointerPositions;
- }
- getStage() {
- return this;
- }
- getContent() {
- return this.content;
- }
- _toKonvaCanvas(M) {
- M = M || {}, M.x = M.x || 0, M.y = M.y || 0, M.width = M.width || this.width(), M.height = M.height || this.height();
- var D = new r.SceneCanvas({
- width: M.width,
- height: M.height,
- pixelRatio: M.pixelRatio || 1
- }), B = D.getContext()._context, nt = this.children;
- return (M.x || M.y) && B.translate(-1 * M.x, -1 * M.y), nt.forEach(function(K) {
- if (K.isVisible()) {
- var At = K._toKonvaCanvas(M);
- B.drawImage(At._canvas, M.x, M.y, At.getWidth() / At.getPixelRatio(), At.getHeight() / At.getPixelRatio());
- }
- }), D;
- }
- getIntersection(M) {
- if (!M)
- return null;
- var D = this.children, B = D.length, nt = B - 1, K;
- for (K = nt; K >= 0; K--) {
- const At = D[K].getIntersection(M);
- if (At)
- return At;
- }
- return null;
- }
- _resizeDOM() {
- var M = this.width(), D = this.height();
- this.content && (this.content.style.width = M + u, this.content.style.height = D + u), this.bufferCanvas.setSize(M, D), this.bufferHitCanvas.setSize(M, D), this.children.forEach((B) => {
- B.setSize({ width: M, height: D }), B.draw();
- });
- }
- add(M, ...D) {
- if (arguments.length > 1) {
- for (var B = 0; B < arguments.length; B++)
- this.add(arguments[B]);
- return this;
- }
- super.add(M);
- var nt = this.children.length;
- return nt > G && t.Util.warn("The stage has " + nt + " layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."), M.setSize({ width: this.width(), height: this.height() }), M.draw(), n.Konva.isBrowser && this.content.appendChild(M.canvas._canvas), this;
- }
- getParent() {
- return null;
- }
- getLayer() {
- return null;
- }
- hasPointerCapture(M) {
- return h.hasPointerCapture(M, this);
- }
- setPointerCapture(M) {
- h.setPointerCapture(M, this);
- }
- releaseCapture(M) {
- h.releaseCapture(M, this);
- }
- getLayers() {
- return this.children;
- }
- _bindContentEvents() {
- n.Konva.isBrowser && H.forEach(([M, D]) => {
- this.content.addEventListener(M, (B) => {
- this[D](B);
- }, { passive: !1 });
- });
- }
- _pointerenter(M) {
- this.setPointersPositions(M);
- const D = q(M.type);
- D && this._fire(D.pointerenter, {
- evt: M,
- target: this,
- currentTarget: this
- });
- }
- _pointerover(M) {
- this.setPointersPositions(M);
- const D = q(M.type);
- D && this._fire(D.pointerover, {
- evt: M,
- target: this,
- currentTarget: this
- });
- }
- _getTargetShape(M) {
- let D = this[M + "targetShape"];
- return D && !D.getStage() && (D = null), D;
- }
- _pointerleave(M) {
- const D = q(M.type), B = N(M.type);
- if (D) {
- this.setPointersPositions(M);
- var nt = this._getTargetShape(B), K = !(n.Konva.isDragging() || n.Konva.isTransforming()) || n.Konva.hitOnDragEnabled;
- nt && K ? (nt._fireAndBubble(D.pointerout, { evt: M }), nt._fireAndBubble(D.pointerleave, { evt: M }), this._fire(D.pointerleave, {
- evt: M,
- target: this,
- currentTarget: this
- }), this[B + "targetShape"] = null) : K && (this._fire(D.pointerleave, {
- evt: M,
- target: this,
- currentTarget: this
- }), this._fire(D.pointerout, {
- evt: M,
- target: this,
- currentTarget: this
- })), this.pointerPos = null, this._pointerPositions = [];
- }
- }
- _pointerdown(M) {
- const D = q(M.type), B = N(M.type);
- if (D) {
- this.setPointersPositions(M);
- var nt = !1;
- this._changedPointerPositions.forEach((K) => {
- var At = this.getIntersection(K);
- if (a.DD.justDragged = !1, n.Konva["_" + B + "ListenClick"] = !0, !At || !At.isListening())
- return;
- n.Konva.capturePointerEventsEnabled && At.setPointerCapture(K.id), this[B + "ClickStartShape"] = At, At._fireAndBubble(D.pointerdown, {
- evt: M,
- pointerId: K.id
- }), nt = !0;
- const St = M.type.indexOf("touch") >= 0;
- At.preventDefault() && M.cancelable && St && M.preventDefault();
- }), nt || this._fire(D.pointerdown, {
- evt: M,
- target: this,
- currentTarget: this,
- pointerId: this._pointerPositions[0].id
- });
- }
- }
- _pointermove(M) {
- const D = q(M.type), B = N(M.type);
- if (!D)
- return;
- n.Konva.isDragging() && a.DD.node.preventDefault() && M.cancelable && M.preventDefault(), this.setPointersPositions(M);
- var nt = !(n.Konva.isDragging() || n.Konva.isTransforming()) || n.Konva.hitOnDragEnabled;
- if (!nt)
- return;
- var K = {};
- let At = !1;
- var St = this._getTargetShape(B);
- this._changedPointerPositions.forEach((ne) => {
- const it = h.getCapturedShape(ne.id) || this.getIntersection(ne), Oe = ne.id, Ht = { evt: M, pointerId: Oe };
- var Ne = St !== it;
- if (Ne && St && (St._fireAndBubble(D.pointerout, { ...Ht }, it), St._fireAndBubble(D.pointerleave, { ...Ht }, it)), it) {
- if (K[it._id])
- return;
- K[it._id] = !0;
- }
- it && it.isListening() ? (At = !0, Ne && (it._fireAndBubble(D.pointerover, { ...Ht }, St), it._fireAndBubble(D.pointerenter, { ...Ht }, St), this[B + "targetShape"] = it), it._fireAndBubble(D.pointermove, { ...Ht })) : St && (this._fire(D.pointerover, {
- evt: M,
- target: this,
- currentTarget: this,
- pointerId: Oe
- }), this[B + "targetShape"] = null);
- }), At || this._fire(D.pointermove, {
- evt: M,
- target: this,
- currentTarget: this,
- pointerId: this._changedPointerPositions[0].id
- });
- }
- _pointerup(M) {
- const D = q(M.type), B = N(M.type);
- if (!D)
- return;
- this.setPointersPositions(M);
- const nt = this[B + "ClickStartShape"], K = this[B + "ClickEndShape"];
- var At = {};
- let St = !1;
- this._changedPointerPositions.forEach((ne) => {
- const it = h.getCapturedShape(ne.id) || this.getIntersection(ne);
- if (it) {
- if (it.releaseCapture(ne.id), At[it._id])
- return;
- At[it._id] = !0;
- }
- const Oe = ne.id, Ht = { evt: M, pointerId: Oe };
- let Ne = !1;
- n.Konva["_" + B + "InDblClickWindow"] ? (Ne = !0, clearTimeout(this[B + "DblTimeout"])) : a.DD.justDragged || (n.Konva["_" + B + "InDblClickWindow"] = !0, clearTimeout(this[B + "DblTimeout"])), this[B + "DblTimeout"] = setTimeout(function() {
- n.Konva["_" + B + "InDblClickWindow"] = !1;
- }, n.Konva.dblClickWindow), it && it.isListening() ? (St = !0, this[B + "ClickEndShape"] = it, it._fireAndBubble(D.pointerup, { ...Ht }), n.Konva["_" + B + "ListenClick"] && nt && nt === it && (it._fireAndBubble(D.pointerclick, { ...Ht }), Ne && K && K === it && it._fireAndBubble(D.pointerdblclick, { ...Ht }))) : (this[B + "ClickEndShape"] = null, n.Konva["_" + B + "ListenClick"] && this._fire(D.pointerclick, {
- evt: M,
- target: this,
- currentTarget: this,
- pointerId: Oe
- }), Ne && this._fire(D.pointerdblclick, {
- evt: M,
- target: this,
- currentTarget: this,
- pointerId: Oe
- }));
- }), St || this._fire(D.pointerup, {
- evt: M,
- target: this,
- currentTarget: this,
- pointerId: this._changedPointerPositions[0].id
- }), n.Konva["_" + B + "ListenClick"] = !1, M.cancelable && B !== "touch" && M.preventDefault();
- }
- _contextmenu(M) {
- this.setPointersPositions(M);
- var D = this.getIntersection(this.getPointerPosition());
- D && D.isListening() ? D._fireAndBubble(k, { evt: M }) : this._fire(k, {
- evt: M,
- target: this,
- currentTarget: this
- });
- }
- _wheel(M) {
- this.setPointersPositions(M);
- var D = this.getIntersection(this.getPointerPosition());
- D && D.isListening() ? D._fireAndBubble(T, { evt: M }) : this._fire(T, {
- evt: M,
- target: this,
- currentTarget: this
- });
- }
- _pointercancel(M) {
- this.setPointersPositions(M);
- const D = h.getCapturedShape(M.pointerId) || this.getIntersection(this.getPointerPosition());
- D && D._fireAndBubble(x, h.createEvent(M)), h.releaseCapture(M.pointerId);
- }
- _lostpointercapture(M) {
- h.releaseCapture(M.pointerId);
- }
- setPointersPositions(M) {
- var D = this._getContentPosition(), B = null, nt = null;
- M = M || window.event, M.touches !== void 0 ? (this._pointerPositions = [], this._changedPointerPositions = [], Array.prototype.forEach.call(M.touches, (K) => {
- this._pointerPositions.push({
- id: K.identifier,
- x: (K.clientX - D.left) / D.scaleX,
- y: (K.clientY - D.top) / D.scaleY
- });
- }), Array.prototype.forEach.call(M.changedTouches || M.touches, (K) => {
- this._changedPointerPositions.push({
- id: K.identifier,
- x: (K.clientX - D.left) / D.scaleX,
- y: (K.clientY - D.top) / D.scaleY
- });
- })) : (B = (M.clientX - D.left) / D.scaleX, nt = (M.clientY - D.top) / D.scaleY, this.pointerPos = {
- x: B,
- y: nt
- }, this._pointerPositions = [{ x: B, y: nt, id: t.Util._getFirstPointerId(M) }], this._changedPointerPositions = [
- { x: B, y: nt, id: t.Util._getFirstPointerId(M) }
- ]);
- }
- _setPointerPosition(M) {
- t.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'), this.setPointersPositions(M);
- }
- _getContentPosition() {
- if (!this.content || !this.content.getBoundingClientRect)
- return {
- top: 0,
- left: 0,
- scaleX: 1,
- scaleY: 1
- };
- var M = this.content.getBoundingClientRect();
- return {
- top: M.top,
- left: M.left,
- scaleX: M.width / this.content.clientWidth || 1,
- scaleY: M.height / this.content.clientHeight || 1
- };
- }
- _buildDOM() {
- if (this.bufferCanvas = new r.SceneCanvas({
- width: this.width(),
- height: this.height()
- }), this.bufferHitCanvas = new r.HitCanvas({
- pixelRatio: 1,
- width: this.width(),
- height: this.height()
- }), !!n.Konva.isBrowser) {
- var M = this.container();
- if (!M)
- throw "Stage has no container. A container is required.";
- M.innerHTML = "", this.content = document.createElement("div"), this.content.style.position = "relative", this.content.style.userSelect = "none", this.content.className = "konvajs-content", this.content.setAttribute("role", "presentation"), M.appendChild(this.content), this._resizeDOM();
- }
- }
- cache() {
- return t.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."), this;
- }
- clearCache() {
- return this;
- }
- batchDraw() {
- return this.getChildren().forEach(function(M) {
- M.batchDraw();
- }), this;
- }
- }
- s.Stage = Ut, Ut.prototype.nodeType = l, (0, o._registerNode)(Ut), e.Factory.addGetterSetter(Ut, "container");
- })(Ii);
- var Hi = {};
- Object.defineProperty(Hi, "__esModule", { value: !0 });
- var _r = Hi.Layer = void 0;
- const $t = st, Rs = Ee, Ve = rt, xr = V, va = It, WA = O, YA = ft, XA = $;
- var jA = "#", qA = "beforeDraw", QA = "draw", Eo = [
- { x: 0, y: 0 },
- { x: -1, y: -1 },
- { x: 1, y: -1 },
- { x: 1, y: 1 },
- { x: -1, y: 1 }
- ], KA = Eo.length;
- class fi extends Rs.Container {
- constructor(t) {
- super(t), this.canvas = new va.SceneCanvas(), this.hitCanvas = new va.HitCanvas({
- pixelRatio: 1
- }), this._waitingForDraw = !1, this.on("visibleChange.konva", this._checkVisibility), this._checkVisibility(), this.on("imageSmoothingEnabledChange.konva", this._setSmoothEnabled), this._setSmoothEnabled();
- }
- createPNGStream() {
- return this.canvas._canvas.createPNGStream();
- }
- getCanvas() {
- return this.canvas;
- }
- getNativeCanvasElement() {
- return this.canvas._canvas;
- }
- getHitCanvas() {
- return this.hitCanvas;
- }
- getContext() {
- return this.getCanvas().getContext();
- }
- clear(t) {
- return this.getContext().clear(t), this.getHitCanvas().getContext().clear(t), this;
- }
- setZIndex(t) {
- super.setZIndex(t);
- var e = this.getStage();
- return e && e.content && (e.content.removeChild(this.getNativeCanvasElement()), t < e.children.length - 1 ? e.content.insertBefore(this.getNativeCanvasElement(), e.children[t + 1].getCanvas()._canvas) : e.content.appendChild(this.getNativeCanvasElement())), this;
- }
- moveToTop() {
- Ve.Node.prototype.moveToTop.call(this);
- var t = this.getStage();
- return t && t.content && (t.content.removeChild(this.getNativeCanvasElement()), t.content.appendChild(this.getNativeCanvasElement())), !0;
- }
- moveUp() {
- var t = Ve.Node.prototype.moveUp.call(this);
- if (!t)
- return !1;
- var e = this.getStage();
- return !e || !e.content ? !1 : (e.content.removeChild(this.getNativeCanvasElement()), this.index < e.children.length - 1 ? e.content.insertBefore(this.getNativeCanvasElement(), e.children[this.index + 1].getCanvas()._canvas) : e.content.appendChild(this.getNativeCanvasElement()), !0);
- }
- moveDown() {
- if (Ve.Node.prototype.moveDown.call(this)) {
- var t = this.getStage();
- if (t) {
- var e = t.children;
- t.content && (t.content.removeChild(this.getNativeCanvasElement()), t.content.insertBefore(this.getNativeCanvasElement(), e[this.index + 1].getCanvas()._canvas));
- }
- return !0;
- }
- return !1;
- }
- moveToBottom() {
- if (Ve.Node.prototype.moveToBottom.call(this)) {
- var t = this.getStage();
- if (t) {
- var e = t.children;
- t.content && (t.content.removeChild(this.getNativeCanvasElement()), t.content.insertBefore(this.getNativeCanvasElement(), e[1].getCanvas()._canvas));
- }
- return !0;
- }
- return !1;
- }
- getLayer() {
- return this;
- }
- remove() {
- var t = this.getNativeCanvasElement();
- return Ve.Node.prototype.remove.call(this), t && t.parentNode && $t.Util._isInDocument(t) && t.parentNode.removeChild(t), this;
- }
- getStage() {
- return this.parent;
- }
- setSize({ width: t, height: e }) {
- return this.canvas.setSize(t, e), this.hitCanvas.setSize(t, e), this._setSmoothEnabled(), this;
- }
- _validateAdd(t) {
- var e = t.getType();
- e !== "Group" && e !== "Shape" && $t.Util.throw("You may only add groups and shapes to a layer.");
- }
- _toKonvaCanvas(t) {
- return t = t || {}, t.width = t.width || this.getWidth(), t.height = t.height || this.getHeight(), t.x = t.x !== void 0 ? t.x : this.x(), t.y = t.y !== void 0 ? t.y : this.y(), Ve.Node.prototype._toKonvaCanvas.call(this, t);
- }
- _checkVisibility() {
- this.visible() ? this.canvas._canvas.style.display = "block" : this.canvas._canvas.style.display = "none";
- }
- _setSmoothEnabled() {
- this.getContext()._context.imageSmoothingEnabled = this.imageSmoothingEnabled();
- }
- getWidth() {
- if (this.parent)
- return this.parent.width();
- }
- setWidth() {
- $t.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.');
- }
- getHeight() {
- if (this.parent)
- return this.parent.height();
- }
- setHeight() {
- $t.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.');
- }
- batchDraw() {
- return this._waitingForDraw || (this._waitingForDraw = !0, $t.Util.requestAnimFrame(() => {
- this.draw(), this._waitingForDraw = !1;
- })), this;
- }
- getIntersection(t) {
- if (!this.isListening() || !this.isVisible())
- return null;
- for (var e = 1, i = !1; ; ) {
- for (let n = 0; n < KA; n++) {
- const r = Eo[n], a = this._getIntersection({
- x: t.x + r.x * e,
- y: t.y + r.y * e
- }), o = a.shape;
- if (o)
- return o;
- if (i = !!a.antialiased, !a.antialiased)
- break;
- }
- if (i)
- e += 1;
- else
- return null;
- }
- }
- _getIntersection(t) {
- const e = this.hitCanvas.pixelRatio, i = this.hitCanvas.context.getImageData(Math.round(t.x * e), Math.round(t.y * e), 1, 1).data, n = i[3];
- if (n === 255) {
- const r = $t.Util._rgbToHex(i[0], i[1], i[2]), a = YA.shapes[jA + r];
- return a ? {
- shape: a
- } : {
- antialiased: !0
- };
- } else if (n > 0)
- return {
- antialiased: !0
- };
- return {};
- }
- drawScene(t, e) {
- var i = this.getLayer(), n = t || i && i.getCanvas();
- return this._fire(qA, {
- node: this
- }), this.clearBeforeDraw() && n.getContext().clear(), Rs.Container.prototype.drawScene.call(this, n, e), this._fire(QA, {
- node: this
- }), this;
- }
- drawHit(t, e) {
- var i = this.getLayer(), n = t || i && i.hitCanvas;
- return i && i.clearBeforeDraw() && i.getHitCanvas().getContext().clear(), Rs.Container.prototype.drawHit.call(this, n, e), this;
- }
- enableHitGraph() {
- return this.hitGraphEnabled(!0), this;
- }
- disableHitGraph() {
- return this.hitGraphEnabled(!1), this;
- }
- setHitGraphEnabled(t) {
- $t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."), this.listening(t);
- }
- getHitGraphEnabled(t) {
- return $t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."), this.listening();
- }
- toggleHitCanvas() {
- if (!(!this.parent || !this.parent.content)) {
- var t = this.parent, e = !!this.hitCanvas._canvas.parentNode;
- e ? t.content.removeChild(this.hitCanvas._canvas) : t.content.appendChild(this.hitCanvas._canvas);
- }
- }
- destroy() {
- return $t.Util.releaseCanvas(this.getNativeCanvasElement(), this.getHitCanvas()._canvas), super.destroy();
- }
- }
- _r = Hi.Layer = fi;
- fi.prototype.nodeType = "Layer";
- (0, XA._registerNode)(fi);
- xr.Factory.addGetterSetter(fi, "imageSmoothingEnabled", !0);
- xr.Factory.addGetterSetter(fi, "clearBeforeDraw", !0);
- xr.Factory.addGetterSetter(fi, "hitGraphEnabled", !0, (0, WA.getBooleanValidator)());
- var Bn = {};
- Object.defineProperty(Bn, "__esModule", { value: !0 });
- Bn.FastLayer = void 0;
- const ZA = st, JA = Hi, t0 = $;
- class br extends JA.Layer {
- constructor(t) {
- super(t), this.listening(!1), ZA.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.');
- }
- }
- Bn.FastLayer = br;
- br.prototype.nodeType = "FastLayer";
- (0, t0._registerNode)(br);
- var gi = {};
- Object.defineProperty(gi, "__esModule", { value: !0 });
- gi.Animation = void 0;
- const Os = $, _a = st, Ns = function() {
- return Os.glob.performance && Os.glob.performance.now ? function() {
- return Os.glob.performance.now();
- } : function() {
- return (/* @__PURE__ */ new Date()).getTime();
- };
- }();
- class Rt {
- constructor(t, e) {
- this.id = Rt.animIdCounter++, this.frame = {
- time: 0,
- timeDiff: 0,
- lastTime: Ns(),
- frameRate: 0
- }, this.func = t, this.setLayers(e);
- }
- setLayers(t) {
- let e = [];
- return t && (e = Array.isArray(t) ? t : [t]), this.layers = e, this;
- }
- getLayers() {
- return this.layers;
- }
- addLayer(t) {
- const e = this.layers, i = e.length;
- for (let n = 0; n < i; n++)
- if (e[n]._id === t._id)
- return !1;
- return this.layers.push(t), !0;
- }
- isRunning() {
- const e = Rt.animations, i = e.length;
- for (let n = 0; n < i; n++)
- if (e[n].id === this.id)
- return !0;
- return !1;
- }
- start() {
- return this.stop(), this.frame.timeDiff = 0, this.frame.lastTime = Ns(), Rt._addAnimation(this), this;
- }
- stop() {
- return Rt._removeAnimation(this), this;
- }
- _updateFrameObject(t) {
- this.frame.timeDiff = t - this.frame.lastTime, this.frame.lastTime = t, this.frame.time += this.frame.timeDiff, this.frame.frameRate = 1e3 / this.frame.timeDiff;
- }
- static _addAnimation(t) {
- this.animations.push(t), this._handleAnimation();
- }
- static _removeAnimation(t) {
- const e = t.id, i = this.animations, n = i.length;
- for (let r = 0; r < n; r++)
- if (i[r].id === e) {
- this.animations.splice(r, 1);
- break;
- }
- }
- static _runFrames() {
- const t = {}, e = this.animations;
- for (let i = 0; i < e.length; i++) {
- const n = e[i], r = n.layers, a = n.func;
- n._updateFrameObject(Ns());
- const o = r.length;
- let h;
- if (a ? h = a.call(n, n.frame) !== !1 : h = !0, !!h)
- for (let l = 0; l < o; l++) {
- const A = r[l];
- A._id !== void 0 && (t[A._id] = A);
- }
- }
- for (let i in t)
- t.hasOwnProperty(i) && t[i].batchDraw();
- }
- static _animationLoop() {
- const t = Rt;
- t.animations.length ? (t._runFrames(), _a.Util.requestAnimFrame(t._animationLoop)) : t.animRunning = !1;
- }
- static _handleAnimation() {
- this.animRunning || (this.animRunning = !0, _a.Util.requestAnimFrame(this._animationLoop));
- }
- }
- gi.Animation = Rt;
- Rt.animations = [];
- Rt.animIdCounter = 0;
- Rt.animRunning = !1;
- var Fo = {};
- (function(s) {
- Object.defineProperty(s, "__esModule", { value: !0 }), s.Easings = s.Tween = void 0;
- const t = st, e = gi, i = rt, n = $;
- var r = {
- node: 1,
- duration: 1,
- easing: 1,
- onFinish: 1,
- yoyo: 1
- }, a = 1, o = 2, h = 3, l = 0, A = ["fill", "stroke", "shadowColor"];
- class u {
- constructor(d, p, m, v, _, g, y) {
- this.prop = d, this.propFunc = p, this.begin = v, this._pos = v, this.duration = g, this._change = 0, this.prevPos = 0, this.yoyo = y, this._time = 0, this._position = 0, this._startTime = 0, this._finish = 0, this.func = m, this._change = _ - this.begin, this.pause();
- }
- fire(d) {
- var p = this[d];
- p && p();
- }
- setTime(d) {
- d > this.duration ? this.yoyo ? (this._time = this.duration, this.reverse()) : this.finish() : d < 0 ? this.yoyo ? (this._time = 0, this.play()) : this.reset() : (this._time = d, this.update());
- }
- getTime() {
- return this._time;
- }
- setPosition(d) {
- this.prevPos = this._pos, this.propFunc(d), this._pos = d;
- }
- getPosition(d) {
- return d === void 0 && (d = this._time), this.func(d, this.begin, this._change, this.duration);
- }
- play() {
- this.state = o, this._startTime = this.getTimer() - this._time, this.onEnterFrame(), this.fire("onPlay");
- }
- reverse() {
- this.state = h, this._time = this.duration - this._time, this._startTime = this.getTimer() - this._time, this.onEnterFrame(), this.fire("onReverse");
- }
- seek(d) {
- this.pause(), this._time = d, this.update(), this.fire("onSeek");
- }
- reset() {
- this.pause(), this._time = 0, this.update(), this.fire("onReset");
- }
- finish() {
- this.pause(), this._time = this.duration, this.update(), this.fire("onFinish");
- }
- update() {
- this.setPosition(this.getPosition(this._time)), this.fire("onUpdate");
- }
- onEnterFrame() {
- var d = this.getTimer() - this._startTime;
- this.state === o ? this.setTime(d) : this.state === h && this.setTime(this.duration - d);
- }
- pause() {
- this.state = a, this.fire("onPause");
- }
- getTimer() {
- return (/* @__PURE__ */ new Date()).getTime();
- }
- }
- class f {
- constructor(d) {
- var p = this, m = d.node, v = m._id, _, g = d.easing || s.Easings.Linear, y = !!d.yoyo, x;
- typeof d.duration > "u" ? _ = 0.3 : d.duration === 0 ? _ = 1e-3 : _ = d.duration, this.node = m, this._id = l++;
- var b = m.getLayer() || (m instanceof n.Konva.Stage ? m.getLayers() : null);
- b || t.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."), this.anim = new e.Animation(function() {
- p.tween.onEnterFrame();
- }, b), this.tween = new u(x, function(C) {
- p._tweenFunc(C);
- }, g, 0, 1, _ * 1e3, y), this._addListeners(), f.attrs[v] || (f.attrs[v] = {}), f.attrs[v][this._id] || (f.attrs[v][this._id] = {}), f.tweens[v] || (f.tweens[v] = {});
- for (x in d)
- r[x] === void 0 && this._addAttr(x, d[x]);
- this.reset(), this.onFinish = d.onFinish, this.onReset = d.onReset, this.onUpdate = d.onUpdate;
- }
- _addAttr(d, p) {
- var m = this.node, v = m._id, _, g, y, x, b, C, w, E;
- if (y = f.tweens[v][d], y && delete f.attrs[v][y][d], _ = m.getAttr(d), t.Util._isArray(p))
- if (g = [], b = Math.max(p.length, _.length), d === "points" && p.length !== _.length && (p.length > _.length ? (w = _, _ = t.Util._prepareArrayForTween(_, p, m.closed())) : (C = p, p = t.Util._prepareArrayForTween(p, _, m.closed()))), d.indexOf("fill") === 0)
- for (x = 0; x < b; x++)
- if (x % 2 === 0)
- g.push(p[x] - _[x]);
- else {
- var S = t.Util.colorToRGBA(_[x]);
- E = t.Util.colorToRGBA(p[x]), _[x] = S, g.push({
- r: E.r - S.r,
- g: E.g - S.g,
- b: E.b - S.b,
- a: E.a - S.a
- });
- }
- else
- for (x = 0; x < b; x++)
- g.push(p[x] - _[x]);
- else
- A.indexOf(d) !== -1 ? (_ = t.Util.colorToRGBA(_), E = t.Util.colorToRGBA(p), g = {
- r: E.r - _.r,
- g: E.g - _.g,
- b: E.b - _.b,
- a: E.a - _.a
- }) : g = p - _;
- f.attrs[v][this._id][d] = {
- start: _,
- diff: g,
- end: p,
- trueEnd: C,
- trueStart: w
- }, f.tweens[v][d] = this._id;
- }
- _tweenFunc(d) {
- var p = this.node, m = f.attrs[p._id][this._id], v, _, g, y, x, b, C, w;
- for (v in m) {
- if (_ = m[v], g = _.start, y = _.diff, w = _.end, t.Util._isArray(g))
- if (x = [], C = Math.max(g.length, w.length), v.indexOf("fill") === 0)
- for (b = 0; b < C; b++)
- b % 2 === 0 ? x.push((g[b] || 0) + y[b] * d) : x.push("rgba(" + Math.round(g[b].r + y[b].r * d) + "," + Math.round(g[b].g + y[b].g * d) + "," + Math.round(g[b].b + y[b].b * d) + "," + (g[b].a + y[b].a * d) + ")");
- else
- for (b = 0; b < C; b++)
- x.push((g[b] || 0) + y[b] * d);
- else
- A.indexOf(v) !== -1 ? x = "rgba(" + Math.round(g.r + y.r * d) + "," + Math.round(g.g + y.g * d) + "," + Math.round(g.b + y.b * d) + "," + (g.a + y.a * d) + ")" : x = g + y * d;
- p.setAttr(v, x);
- }
- }
- _addListeners() {
- this.tween.onPlay = () => {
- this.anim.start();
- }, this.tween.onReverse = () => {
- this.anim.start();
- }, this.tween.onPause = () => {
- this.anim.stop();
- }, this.tween.onFinish = () => {
- var d = this.node, p = f.attrs[d._id][this._id];
- p.points && p.points.trueEnd && d.setAttr("points", p.points.trueEnd), this.onFinish && this.onFinish.call(this);
- }, this.tween.onReset = () => {
- var d = this.node, p = f.attrs[d._id][this._id];
- p.points && p.points.trueStart && d.points(p.points.trueStart), this.onReset && this.onReset();
- }, this.tween.onUpdate = () => {
- this.onUpdate && this.onUpdate.call(this);
- };
- }
- play() {
- return this.tween.play(), this;
- }
- reverse() {
- return this.tween.reverse(), this;
- }
- reset() {
- return this.tween.reset(), this;
- }
- seek(d) {
- return this.tween.seek(d * 1e3), this;
- }
- pause() {
- return this.tween.pause(), this;
- }
- finish() {
- return this.tween.finish(), this;
- }
- destroy() {
- var d = this.node._id, p = this._id, m = f.tweens[d], v;
- this.pause();
- for (v in m)
- delete f.tweens[d][v];
- delete f.attrs[d][p];
- }
- }
- s.Tween = f, f.attrs = {}, f.tweens = {}, i.Node.prototype.to = function(c) {
- var d = c.onFinish;
- c.node = this, c.onFinish = function() {
- this.destroy(), d && d();
- };
- var p = new f(c);
- p.play();
- }, s.Easings = {
- BackEaseIn(c, d, p, m) {
- var v = 1.70158;
- return p * (c /= m) * c * ((v + 1) * c - v) + d;
- },
- BackEaseOut(c, d, p, m) {
- var v = 1.70158;
- return p * ((c = c / m - 1) * c * ((v + 1) * c + v) + 1) + d;
- },
- BackEaseInOut(c, d, p, m) {
- var v = 1.70158;
- return (c /= m / 2) < 1 ? p / 2 * (c * c * (((v *= 1.525) + 1) * c - v)) + d : p / 2 * ((c -= 2) * c * (((v *= 1.525) + 1) * c + v) + 2) + d;
- },
- ElasticEaseIn(c, d, p, m, v, _) {
- var g = 0;
- return c === 0 ? d : (c /= m) === 1 ? d + p : (_ || (_ = m * 0.3), !v || v < Math.abs(p) ? (v = p, g = _ / 4) : g = _ / (2 * Math.PI) * Math.asin(p / v), -(v * Math.pow(2, 10 * (c -= 1)) * Math.sin((c * m - g) * (2 * Math.PI) / _)) + d);
- },
- ElasticEaseOut(c, d, p, m, v, _) {
- var g = 0;
- return c === 0 ? d : (c /= m) === 1 ? d + p : (_ || (_ = m * 0.3), !v || v < Math.abs(p) ? (v = p, g = _ / 4) : g = _ / (2 * Math.PI) * Math.asin(p / v), v * Math.pow(2, -10 * c) * Math.sin((c * m - g) * (2 * Math.PI) / _) + p + d);
- },
- ElasticEaseInOut(c, d, p, m, v, _) {
- var g = 0;
- return c === 0 ? d : (c /= m / 2) === 2 ? d + p : (_ || (_ = m * (0.3 * 1.5)), !v || v < Math.abs(p) ? (v = p, g = _ / 4) : g = _ / (2 * Math.PI) * Math.asin(p / v), c < 1 ? -0.5 * (v * Math.pow(2, 10 * (c -= 1)) * Math.sin((c * m - g) * (2 * Math.PI) / _)) + d : v * Math.pow(2, -10 * (c -= 1)) * Math.sin((c * m - g) * (2 * Math.PI) / _) * 0.5 + p + d);
- },
- BounceEaseOut(c, d, p, m) {
- return (c /= m) < 1 / 2.75 ? p * (7.5625 * c * c) + d : c < 2 / 2.75 ? p * (7.5625 * (c -= 1.5 / 2.75) * c + 0.75) + d : c < 2.5 / 2.75 ? p * (7.5625 * (c -= 2.25 / 2.75) * c + 0.9375) + d : p * (7.5625 * (c -= 2.625 / 2.75) * c + 0.984375) + d;
- },
- BounceEaseIn(c, d, p, m) {
- return p - s.Easings.BounceEaseOut(m - c, 0, p, m) + d;
- },
- BounceEaseInOut(c, d, p, m) {
- return c < m / 2 ? s.Easings.BounceEaseIn(c * 2, 0, p, m) * 0.5 + d : s.Easings.BounceEaseOut(c * 2 - m, 0, p, m) * 0.5 + p * 0.5 + d;
- },
- EaseIn(c, d, p, m) {
- return p * (c /= m) * c + d;
- },
- EaseOut(c, d, p, m) {
- return -p * (c /= m) * (c - 2) + d;
- },
- EaseInOut(c, d, p, m) {
- return (c /= m / 2) < 1 ? p / 2 * c * c + d : -p / 2 * (--c * (c - 2) - 1) + d;
- },
- StrongEaseIn(c, d, p, m) {
- return p * (c /= m) * c * c * c * c + d;
- },
- StrongEaseOut(c, d, p, m) {
- return p * ((c = c / m - 1) * c * c * c * c + 1) + d;
- },
- StrongEaseInOut(c, d, p, m) {
- return (c /= m / 2) < 1 ? p / 2 * c * c * c * c * c + d : p / 2 * ((c -= 2) * c * c * c * c + 2) + d;
- },
- Linear(c, d, p, m) {
- return p * c / m + d;
- }
- };
- })(Fo);
- (function(s) {
- Object.defineProperty(s, "__esModule", { value: !0 }), s.Konva = void 0;
- const t = $, e = st, i = rt, n = Ee, r = Ii, a = Hi, o = Bn, h = li, l = En, A = ft, u = gi, f = Fo, c = Xt, d = It;
- s.Konva = e.Util._assign(t.Konva, {
- Util: e.Util,
- Transform: e.Transform,
- Node: i.Node,
- Container: n.Container,
- Stage: r.Stage,
- stages: r.stages,
- Layer: a.Layer,
- FastLayer: o.FastLayer,
- Group: h.Group,
- DD: l.DD,
- Shape: A.Shape,
- shapes: A.shapes,
- Animation: u.Animation,
- Tween: f.Tween,
- Easings: f.Easings,
- Context: c.Context,
- Canvas: d.Canvas
- }), s.default = s.Konva;
- })(Po);
- var zn = {};
- Object.defineProperty(zn, "__esModule", { value: !0 });
- zn.Arc = void 0;
- const Un = V, e0 = ft, xa = $, Hn = O, i0 = $;
- class te extends e0.Shape {
- _sceneFunc(t) {
- var e = xa.Konva.getAngle(this.angle()), i = this.clockwise();
- t.beginPath(), t.arc(0, 0, this.outerRadius(), 0, e, i), t.arc(0, 0, this.innerRadius(), e, 0, !i), t.closePath(), t.fillStrokeShape(this);
- }
- getWidth() {
- return this.outerRadius() * 2;
- }
- getHeight() {
- return this.outerRadius() * 2;
- }
- setWidth(t) {
- this.outerRadius(t / 2);
- }
- setHeight(t) {
- this.outerRadius(t / 2);
- }
- getSelfRect() {
- const t = this.innerRadius(), e = this.outerRadius(), i = this.clockwise(), n = xa.Konva.getAngle(i ? 360 - this.angle() : this.angle()), r = Math.cos(Math.min(n, Math.PI)), a = 1, o = Math.sin(Math.min(Math.max(Math.PI, n), 3 * Math.PI / 2)), h = Math.sin(Math.min(n, Math.PI / 2)), l = r * (r > 0 ? t : e), A = a * e, u = o * (o > 0 ? t : e), f = h * (h > 0 ? e : t);
- return {
- x: l,
- y: i ? -1 * f : u,
- width: A - l,
- height: f - u
- };
- }
- }
- zn.Arc = te;
- te.prototype._centroid = !0;
- te.prototype.className = "Arc";
- te.prototype._attrsAffectingSize = ["innerRadius", "outerRadius"];
- (0, i0._registerNode)(te);
- Un.Factory.addGetterSetter(te, "innerRadius", 0, (0, Hn.getNumberValidator)());
- Un.Factory.addGetterSetter(te, "outerRadius", 0, (0, Hn.getNumberValidator)());
- Un.Factory.addGetterSetter(te, "angle", 0, (0, Hn.getNumberValidator)());
- Un.Factory.addGetterSetter(te, "clockwise", !1, (0, Hn.getBooleanValidator)());
- var Vn = {};
- Object.defineProperty(Vn, "__esModule", { value: !0 });
- Vn.Arrow = void 0;
- const $n = V, n0 = Gi, ko = O, s0 = $, ba = hi;
- class ke extends n0.Line {
- _sceneFunc(t) {
- super._sceneFunc(t);
- var e = Math.PI * 2, i = this.points(), n = i, r = this.tension() !== 0 && i.length > 4;
- r && (n = this.getTensionPoints());
- var a = this.pointerLength(), o = i.length, h, l;
- if (r) {
- const f = [
- n[n.length - 4],
- n[n.length - 3],
- n[n.length - 2],
- n[n.length - 1],
- i[o - 2],
- i[o - 1]
- ], c = ba.Path.calcLength(n[n.length - 4], n[n.length - 3], "C", f), d = ba.Path.getPointOnQuadraticBezier(Math.min(1, 1 - a / c), f[0], f[1], f[2], f[3], f[4], f[5]);
- h = i[o - 2] - d.x, l = i[o - 1] - d.y;
- } else
- h = i[o - 2] - i[o - 4], l = i[o - 1] - i[o - 3];
- var A = (Math.atan2(l, h) + e) % e, u = this.pointerWidth();
- this.pointerAtEnding() && (t.save(), t.beginPath(), t.translate(i[o - 2], i[o - 1]), t.rotate(A), t.moveTo(0, 0), t.lineTo(-a, u / 2), t.lineTo(-a, -u / 2), t.closePath(), t.restore(), this.__fillStroke(t)), this.pointerAtBeginning() && (t.save(), t.beginPath(), t.translate(i[0], i[1]), r ? (h = (n[0] + n[2]) / 2 - i[0], l = (n[1] + n[3]) / 2 - i[1]) : (h = i[2] - i[0], l = i[3] - i[1]), t.rotate((Math.atan2(-l, -h) + e) % e), t.moveTo(0, 0), t.lineTo(-a, u / 2), t.lineTo(-a, -u / 2), t.closePath(), t.restore(), this.__fillStroke(t));
- }
- __fillStroke(t) {
- var e = this.dashEnabled();
- e && (this.attrs.dashEnabled = !1, t.setLineDash([])), t.fillStrokeShape(this), e && (this.attrs.dashEnabled = !0);
- }
- getSelfRect() {
- const t = super.getSelfRect(), e = this.pointerWidth() / 2;
- return {
- x: t.x - e,
- y: t.y - e,
- width: t.width + e * 2,
- height: t.height + e * 2
- };
- }
- }
- Vn.Arrow = ke;
- ke.prototype.className = "Arrow";
- (0, s0._registerNode)(ke);
- $n.Factory.addGetterSetter(ke, "pointerLength", 10, (0, ko.getNumberValidator)());
- $n.Factory.addGetterSetter(ke, "pointerWidth", 10, (0, ko.getNumberValidator)());
- $n.Factory.addGetterSetter(ke, "pointerAtBeginning", !1);
- $n.Factory.addGetterSetter(ke, "pointerAtEnding", !0);
- var Wn = {};
- Object.defineProperty(Wn, "__esModule", { value: !0 });
- Wn.Ellipse = void 0;
- const wr = V, r0 = ft, Do = O, a0 = $;
- class pe extends r0.Shape {
- _sceneFunc(t) {
- var e = this.radiusX(), i = this.radiusY();
- t.beginPath(), t.save(), e !== i && t.scale(1, i / e), t.arc(0, 0, e, 0, Math.PI * 2, !1), t.restore(), t.closePath(), t.fillStrokeShape(this);
- }
- getWidth() {
- return this.radiusX() * 2;
- }
- getHeight() {
- return this.radiusY() * 2;
- }
- setWidth(t) {
- this.radiusX(t / 2);
- }
- setHeight(t) {
- this.radiusY(t / 2);
- }
- }
- Wn.Ellipse = pe;
- pe.prototype.className = "Ellipse";
- pe.prototype._centroid = !0;
- pe.prototype._attrsAffectingSize = ["radiusX", "radiusY"];
- (0, a0._registerNode)(pe);
- wr.Factory.addComponentsGetterSetter(pe, "radius", ["x", "y"]);
- wr.Factory.addGetterSetter(pe, "radiusX", 0, (0, Do.getNumberValidator)());
- wr.Factory.addGetterSetter(pe, "radiusY", 0, (0, Do.getNumberValidator)());
- var Yn = {};
- Object.defineProperty(Yn, "__esModule", { value: !0 });
- Yn.Image = void 0;
- const Gs = st, De = V, o0 = ft, h0 = $, Vi = O;
- let Bt = class Io extends o0.Shape {
- constructor(t) {
- super(t), this.on("imageChange.konva", () => {
- this._setImageLoad();
- }), this._setImageLoad();
- }
- _setImageLoad() {
- const t = this.image();
- t && t.complete || t && t.readyState === 4 || t && t.addEventListener && t.addEventListener("load", () => {
- this._requestDraw();
- });
- }
- _useBufferCanvas() {
- return super._useBufferCanvas(!0);
- }
- _sceneFunc(t) {
- const e = this.getWidth(), i = this.getHeight(), n = this.cornerRadius(), r = this.attrs.image;
- let a;
- if (r) {
- const o = this.attrs.cropWidth, h = this.attrs.cropHeight;
- o && h ? a = [
- r,
- this.cropX(),
- this.cropY(),
- o,
- h,
- 0,
- 0,
- e,
- i
- ] : a = [r, 0, 0, e, i];
- }
- (this.hasFill() || this.hasStroke() || n) && (t.beginPath(), n ? Gs.Util.drawRoundedRectPath(t, e, i, n) : t.rect(0, 0, e, i), t.closePath(), t.fillStrokeShape(this)), r && (n && t.clip(), t.drawImage.apply(t, a));
- }
- _hitFunc(t) {
- var e = this.width(), i = this.height(), n = this.cornerRadius();
- t.beginPath(), n ? Gs.Util.drawRoundedRectPath(t, e, i, n) : t.rect(0, 0, e, i), t.closePath(), t.fillStrokeShape(this);
- }
- getWidth() {
- var t, e;
- return (t = this.attrs.width) !== null && t !== void 0 ? t : (e = this.image()) === null || e === void 0 ? void 0 : e.width;
- }
- getHeight() {
- var t, e;
- return (t = this.attrs.height) !== null && t !== void 0 ? t : (e = this.image()) === null || e === void 0 ? void 0 : e.height;
- }
- static fromURL(t, e, i = null) {
- var n = Gs.Util.createImageElement();
- n.onload = function() {
- var r = new Io({
- image: n
- });
- e(r);
- }, n.onerror = i, n.crossOrigin = "Anonymous", n.src = t;
- }
- };
- Yn.Image = Bt;
- Bt.prototype.className = "Image";
- (0, h0._registerNode)(Bt);
- De.Factory.addGetterSetter(Bt, "cornerRadius", 0, (0, Vi.getNumberOrArrayOfNumbersValidator)(4));
- De.Factory.addGetterSetter(Bt, "image");
- De.Factory.addComponentsGetterSetter(Bt, "crop", ["x", "y", "width", "height"]);
- De.Factory.addGetterSetter(Bt, "cropX", 0, (0, Vi.getNumberValidator)());
- De.Factory.addGetterSetter(Bt, "cropY", 0, (0, Vi.getNumberValidator)());
- De.Factory.addGetterSetter(Bt, "cropWidth", 0, (0, Vi.getNumberValidator)());
- De.Factory.addGetterSetter(Bt, "cropHeight", 0, (0, Vi.getNumberValidator)());
- var ii = {};
- Object.defineProperty(ii, "__esModule", { value: !0 });
- var To = ii.Tag = Oo = ii.Label = void 0;
- const Xn = V, l0 = ft, A0 = li, Sr = O, Lo = $;
- var Ro = [
- "fontFamily",
- "fontSize",
- "fontStyle",
- "padding",
- "lineHeight",
- "text",
- "width",
- "height",
- "pointerDirection",
- "pointerWidth",
- "pointerHeight"
- ], c0 = "Change.konva", d0 = "none", tr = "up", er = "right", ir = "down", nr = "left", u0 = Ro.length;
- class Cr extends A0.Group {
- constructor(t) {
- super(t), this.on("add.konva", function(e) {
- this._addListeners(e.child), this._sync();
- });
- }
- getText() {
- return this.find("Text")[0];
- }
- getTag() {
- return this.find("Tag")[0];
- }
- _addListeners(t) {
- var e = this, i, n = function() {
- e._sync();
- };
- for (i = 0; i < u0; i++)
- t.on(Ro[i] + c0, n);
- }
- getWidth() {
- return this.getText().width();
- }
- getHeight() {
- return this.getText().height();
- }
- _sync() {
- var t = this.getText(), e = this.getTag(), i, n, r, a, o, h, l;
- if (t && e) {
- switch (i = t.width(), n = t.height(), r = e.pointerDirection(), a = e.pointerWidth(), l = e.pointerHeight(), o = 0, h = 0, r) {
- case tr:
- o = i / 2, h = -1 * l;
- break;
- case er:
- o = i + a, h = n / 2;
- break;
- case ir:
- o = i / 2, h = n + l;
- break;
- case nr:
- o = -1 * a, h = n / 2;
- break;
- }
- e.setAttrs({
- x: -1 * o,
- y: -1 * h,
- width: i,
- height: n
- }), t.setAttrs({
- x: -1 * o,
- y: -1 * h
- });
- }
- }
- }
- var Oo = ii.Label = Cr;
- Cr.prototype.className = "Label";
- (0, Lo._registerNode)(Cr);
- class Ie extends l0.Shape {
- _sceneFunc(t) {
- var e = this.width(), i = this.height(), n = this.pointerDirection(), r = this.pointerWidth(), a = this.pointerHeight(), o = this.cornerRadius();
- let h = 0, l = 0, A = 0, u = 0;
- typeof o == "number" ? h = l = A = u = Math.min(o, e / 2, i / 2) : (h = Math.min(o[0] || 0, e / 2, i / 2), l = Math.min(o[1] || 0, e / 2, i / 2), u = Math.min(o[2] || 0, e / 2, i / 2), A = Math.min(o[3] || 0, e / 2, i / 2)), t.beginPath(), t.moveTo(h, 0), n === tr && (t.lineTo((e - r) / 2, 0), t.lineTo(e / 2, -1 * a), t.lineTo((e + r) / 2, 0)), t.lineTo(e - l, 0), t.arc(e - l, l, l, Math.PI * 3 / 2, 0, !1), n === er && (t.lineTo(e, (i - a) / 2), t.lineTo(e + r, i / 2), t.lineTo(e, (i + a) / 2)), t.lineTo(e, i - u), t.arc(e - u, i - u, u, 0, Math.PI / 2, !1), n === ir && (t.lineTo((e + r) / 2, i), t.lineTo(e / 2, i + a), t.lineTo((e - r) / 2, i)), t.lineTo(A, i), t.arc(A, i - A, A, Math.PI / 2, Math.PI, !1), n === nr && (t.lineTo(0, (i + a) / 2), t.lineTo(-1 * r, i / 2), t.lineTo(0, (i - a) / 2)), t.lineTo(0, h), t.arc(h, h, h, Math.PI, Math.PI * 3 / 2, !1), t.closePath(), t.fillStrokeShape(this);
- }
- getSelfRect() {
- var t = 0, e = 0, i = this.pointerWidth(), n = this.pointerHeight(), r = this.pointerDirection(), a = this.width(), o = this.height();
- return r === tr ? (e -= n, o += n) : r === ir ? o += n : r === nr ? (t -= i * 1.5, a += i) : r === er && (a += i * 1.5), {
- x: t,
- y: e,
- width: a,
- height: o
- };
- }
- }
- To = ii.Tag = Ie;
- Ie.prototype.className = "Tag";
- (0, Lo._registerNode)(Ie);
- Xn.Factory.addGetterSetter(Ie, "pointerDirection", d0);
- Xn.Factory.addGetterSetter(Ie, "pointerWidth", 0, (0, Sr.getNumberValidator)());
- Xn.Factory.addGetterSetter(Ie, "pointerHeight", 0, (0, Sr.getNumberValidator)());
- Xn.Factory.addGetterSetter(Ie, "cornerRadius", 0, (0, Sr.getNumberOrArrayOfNumbersValidator)(4));
- var jn = {};
- Object.defineProperty(jn, "__esModule", { value: !0 });
- jn.RegularPolygon = void 0;
- const No = V, f0 = ft, Go = O, g0 = $;
- class Te extends f0.Shape {
- _sceneFunc(t) {
- const e = this._getPoints();
- t.beginPath(), t.moveTo(e[0].x, e[0].y);
- for (var i = 1; i < e.length; i++)
- t.lineTo(e[i].x, e[i].y);
- t.closePath(), t.fillStrokeShape(this);
- }
- _getPoints() {
- const t = this.attrs.sides, e = this.attrs.radius || 0, i = [];
- for (var n = 0; n < t; n++)
- i.push({
- x: e * Math.sin(n * 2 * Math.PI / t),
- y: -1 * e * Math.cos(n * 2 * Math.PI / t)
- });
- return i;
- }
- getSelfRect() {
- const t = this._getPoints();
- var e = t[0].x, i = t[0].y, n = t[0].x, r = t[0].y;
- return t.forEach((a) => {
- e = Math.min(e, a.x), i = Math.max(i, a.x), n = Math.min(n, a.y), r = Math.max(r, a.y);
- }), {
- x: e,
- y: n,
- width: i - e,
- height: r - n
- };
- }
- getWidth() {
- return this.radius() * 2;
- }
- getHeight() {
- return this.radius() * 2;
- }
- setWidth(t) {
- this.radius(t / 2);
- }
- setHeight(t) {
- this.radius(t / 2);
- }
- }
- jn.RegularPolygon = Te;
- Te.prototype.className = "RegularPolygon";
- Te.prototype._centroid = !0;
- Te.prototype._attrsAffectingSize = ["radius"];
- (0, g0._registerNode)(Te);
- No.Factory.addGetterSetter(Te, "radius", 0, (0, Go.getNumberValidator)());
- No.Factory.addGetterSetter(Te, "sides", 0, (0, Go.getNumberValidator)());
- var qn = {};
- Object.defineProperty(qn, "__esModule", { value: !0 });
- qn.Ring = void 0;
- const Bo = V, p0 = ft, zo = O, y0 = $;
- var wa = Math.PI * 2;
- class Le extends p0.Shape {
- _sceneFunc(t) {
- t.beginPath(), t.arc(0, 0, this.innerRadius(), 0, wa, !1), t.moveTo(this.outerRadius(), 0), t.arc(0, 0, this.outerRadius(), wa, 0, !0), t.closePath(), t.fillStrokeShape(this);
- }
- getWidth() {
- return this.outerRadius() * 2;
- }
- getHeight() {
- return this.outerRadius() * 2;
- }
- setWidth(t) {
- this.outerRadius(t / 2);
- }
- setHeight(t) {
- this.outerRadius(t / 2);
- }
- }
- qn.Ring = Le;
- Le.prototype.className = "Ring";
- Le.prototype._centroid = !0;
- Le.prototype._attrsAffectingSize = ["innerRadius", "outerRadius"];
- (0, y0._registerNode)(Le);
- Bo.Factory.addGetterSetter(Le, "innerRadius", 0, (0, zo.getNumberValidator)());
- Bo.Factory.addGetterSetter(Le, "outerRadius", 0, (0, zo.getNumberValidator)());
- var Qn = {};
- Object.defineProperty(Qn, "__esModule", { value: !0 });
- Qn.Sprite = void 0;
- const Re = V, m0 = ft, v0 = gi, Uo = O, _0 = $;
- class zt extends m0.Shape {
- constructor(t) {
- super(t), this._updated = !0, this.anim = new v0.Animation(() => {
- var e = this._updated;
- return this._updated = !1, e;
- }), this.on("animationChange.konva", function() {
- this.frameIndex(0);
- }), this.on("frameIndexChange.konva", function() {
- this._updated = !0;
- }), this.on("frameRateChange.konva", function() {
- this.anim.isRunning() && (clearInterval(this.interval), this._setInterval());
- });
- }
- _sceneFunc(t) {
- var e = this.animation(), i = this.frameIndex(), n = i * 4, r = this.animations()[e], a = this.frameOffsets(), o = r[n + 0], h = r[n + 1], l = r[n + 2], A = r[n + 3], u = this.image();
- if ((this.hasFill() || this.hasStroke()) && (t.beginPath(), t.rect(0, 0, l, A), t.closePath(), t.fillStrokeShape(this)), u)
- if (a) {
- var f = a[e], c = i * 2;
- t.drawImage(u, o, h, l, A, f[c + 0], f[c + 1], l, A);
- } else
- t.drawImage(u, o, h, l, A, 0, 0, l, A);
- }
- _hitFunc(t) {
- var e = this.animation(), i = this.frameIndex(), n = i * 4, r = this.animations()[e], a = this.frameOffsets(), o = r[n + 2], h = r[n + 3];
- if (t.beginPath(), a) {
- var l = a[e], A = i * 2;
- t.rect(l[A + 0], l[A + 1], o, h);
- } else
- t.rect(0, 0, o, h);
- t.closePath(), t.fillShape(this);
- }
- _useBufferCanvas() {
- return super._useBufferCanvas(!0);
- }
- _setInterval() {
- var t = this;
- this.interval = setInterval(function() {
- t._updateIndex();
- }, 1e3 / this.frameRate());
- }
- start() {
- if (!this.isRunning()) {
- var t = this.getLayer();
- this.anim.setLayers(t), this._setInterval(), this.anim.start();
- }
- }
- stop() {
- this.anim.stop(), clearInterval(this.interval);
- }
- isRunning() {
- return this.anim.isRunning();
- }
- _updateIndex() {
- var t = this.frameIndex(), e = this.animation(), i = this.animations(), n = i[e], r = n.length / 4;
- t < r - 1 ? this.frameIndex(t + 1) : this.frameIndex(0);
- }
- }
- Qn.Sprite = zt;
- zt.prototype.className = "Sprite";
- (0, _0._registerNode)(zt);
- Re.Factory.addGetterSetter(zt, "animation");
- Re.Factory.addGetterSetter(zt, "animations");
- Re.Factory.addGetterSetter(zt, "frameOffsets");
- Re.Factory.addGetterSetter(zt, "image");
- Re.Factory.addGetterSetter(zt, "frameIndex", 0, (0, Uo.getNumberValidator)());
- Re.Factory.addGetterSetter(zt, "frameRate", 17, (0, Uo.getNumberValidator)());
- Re.Factory.backCompat(zt, {
- index: "frameIndex",
- getIndex: "getFrameIndex",
- setIndex: "setFrameIndex"
- });
- var Kn = {};
- Object.defineProperty(Kn, "__esModule", { value: !0 });
- Kn.Star = void 0;
- const Mr = V, x0 = ft, Pr = O, b0 = $;
- class ye extends x0.Shape {
- _sceneFunc(t) {
- var e = this.innerRadius(), i = this.outerRadius(), n = this.numPoints();
- t.beginPath(), t.moveTo(0, 0 - i);
- for (var r = 1; r < n * 2; r++) {
- var a = r % 2 === 0 ? i : e, o = a * Math.sin(r * Math.PI / n), h = -1 * a * Math.cos(r * Math.PI / n);
- t.lineTo(o, h);
- }
- t.closePath(), t.fillStrokeShape(this);
- }
- getWidth() {
- return this.outerRadius() * 2;
- }
- getHeight() {
- return this.outerRadius() * 2;
- }
- setWidth(t) {
- this.outerRadius(t / 2);
- }
- setHeight(t) {
- this.outerRadius(t / 2);
- }
- }
- Kn.Star = ye;
- ye.prototype.className = "Star";
- ye.prototype._centroid = !0;
- ye.prototype._attrsAffectingSize = ["innerRadius", "outerRadius"];
- (0, b0._registerNode)(ye);
- Mr.Factory.addGetterSetter(ye, "numPoints", 5, (0, Pr.getNumberValidator)());
- Mr.Factory.addGetterSetter(ye, "innerRadius", 0, (0, Pr.getNumberValidator)());
- Mr.Factory.addGetterSetter(ye, "outerRadius", 0, (0, Pr.getNumberValidator)());
- var Me = {};
- Object.defineProperty(Me, "__esModule", { value: !0 });
- var dn = Me.Text = Me.stringToArray = void 0;
- const sr = st, vt = V, w0 = ft, me = O, S0 = $;
- function Ho(s) {
- return Array.from(s);
- }
- Me.stringToArray = Ho;
- var $e = "auto", C0 = "center", Vo = "inherit", _i = "justify", M0 = "Change.konva", P0 = "2d", Sa = "-", $o = "left", E0 = "text", F0 = "Text", k0 = "top", D0 = "bottom", Ca = "middle", Wo = "normal", I0 = "px ", en = " ", T0 = "right", Ma = "rtl", L0 = "word", R0 = "char", Pa = "none", Bs = "…", Yo = [
- "direction",
- "fontFamily",
- "fontSize",
- "fontStyle",
- "fontVariant",
- "padding",
- "align",
- "verticalAlign",
- "lineHeight",
- "text",
- "width",
- "height",
- "wrap",
- "ellipsis",
- "letterSpacing"
- ], O0 = Yo.length;
- function N0(s) {
- return s.split(",").map((t) => {
- t = t.trim();
- const e = t.indexOf(" ") >= 0, i = t.indexOf('"') >= 0 || t.indexOf("'") >= 0;
- return e && !i && (t = `"${t}"`), t;
- }).join(", ");
- }
- var nn;
- function zs() {
- return nn || (nn = sr.Util.createCanvasElement().getContext(P0), nn);
- }
- function G0(s) {
- s.fillText(this._partialText, this._partialTextX, this._partialTextY);
- }
- function B0(s) {
- s.setAttr("miterLimit", 2), s.strokeText(this._partialText, this._partialTextX, this._partialTextY);
- }
- function z0(s) {
- return s = s || {}, !s.fillLinearGradientColorStops && !s.fillRadialGradientColorStops && !s.fillPatternImage && (s.fill = s.fill || "black"), s;
- }
- class lt extends w0.Shape {
- constructor(t) {
- super(z0(t)), this._partialTextX = 0, this._partialTextY = 0;
- for (var e = 0; e < O0; e++)
- this.on(Yo[e] + M0, this._setTextData);
- this._setTextData();
- }
- _sceneFunc(t) {
- var e = this.textArr, i = e.length;
- if (this.text()) {
- var n = this.padding(), r = this.fontSize(), a = this.lineHeight() * r, o = this.verticalAlign(), h = this.direction(), l = 0, A = this.align(), u = this.getWidth(), f = this.letterSpacing(), c = this.fill(), d = this.textDecoration(), p = d.indexOf("underline") !== -1, m = d.indexOf("line-through") !== -1, v;
- h = h === Vo ? t.direction : h;
- var _ = 0, _ = a / 2, g = 0, y = 0;
- for (h === Ma && t.setAttr("direction", h), t.setAttr("font", this._getContextFont()), t.setAttr("textBaseline", Ca), t.setAttr("textAlign", $o), o === Ca ? l = (this.getHeight() - i * a - n * 2) / 2 : o === D0 && (l = this.getHeight() - i * a - n * 2), t.translate(n, l + n), v = 0; v < i; v++) {
- var g = 0, y = 0, x = e[v], b = x.text, C = x.width, w = x.lastInParagraph, E, S, P;
- if (t.save(), A === T0 ? g += u - C - n * 2 : A === C0 && (g += (u - C - n * 2) / 2), p) {
- t.save(), t.beginPath(), t.moveTo(g, _ + y + Math.round(r / 2)), E = b.split(" ").length - 1, S = E === 0, P = A === _i && !w ? u - n * 2 : C, t.lineTo(g + Math.round(P), _ + y + Math.round(r / 2)), t.lineWidth = r / 15;
- const T = this._getLinearGradient();
- t.strokeStyle = T || c, t.stroke(), t.restore();
- }
- if (m) {
- t.save(), t.beginPath(), t.moveTo(g, _ + y), E = b.split(" ").length - 1, S = E === 0, P = A === _i && w && !S ? u - n * 2 : C, t.lineTo(g + Math.round(P), _ + y), t.lineWidth = r / 15;
- const T = this._getLinearGradient();
- t.strokeStyle = T || c, t.stroke(), t.restore();
- }
- if (h !== Ma && (f !== 0 || A === _i)) {
- E = b.split(" ").length - 1;
- for (var k = Ho(b), F = 0; F < k.length; F++) {
- var L = k[F];
- L === " " && !w && A === _i && (g += (u - n * 2 - C) / E), this._partialTextX = g, this._partialTextY = _ + y, this._partialText = L, t.fillStrokeShape(this), g += this.measureSize(L).width + f;
- }
- } else
- f !== 0 && t.setAttr("letterSpacing", `${f}px`), this._partialTextX = g, this._partialTextY = _ + y, this._partialText = b, t.fillStrokeShape(this);
- t.restore(), i > 1 && (_ += a);
- }
- }
- }
- _hitFunc(t) {
- var e = this.getWidth(), i = this.getHeight();
- t.beginPath(), t.rect(0, 0, e, i), t.closePath(), t.fillStrokeShape(this);
- }
- setText(t) {
- var e = sr.Util._isString(t) ? t : t == null ? "" : t + "";
- return this._setAttr(E0, e), this;
- }
- getWidth() {
- var t = this.attrs.width === $e || this.attrs.width === void 0;
- return t ? this.getTextWidth() + this.padding() * 2 : this.attrs.width;
- }
- getHeight() {
- var t = this.attrs.height === $e || this.attrs.height === void 0;
- return t ? this.fontSize() * this.textArr.length * this.lineHeight() + this.padding() * 2 : this.attrs.height;
- }
- getTextWidth() {
- return this.textWidth;
- }
- getTextHeight() {
- return sr.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."), this.textHeight;
- }
- measureSize(t) {
- var e = zs(), i = this.fontSize(), n;
- return e.save(), e.font = this._getContextFont(), n = e.measureText(t), e.restore(), {
- width: n.width,
- height: i
- };
- }
- _getContextFont() {
- return this.fontStyle() + en + this.fontVariant() + en + (this.fontSize() + I0) + N0(this.fontFamily());
- }
- _addTextLine(t) {
- this.align() === _i && (t = t.trim());
- var i = this._getTextWidth(t);
- return this.textArr.push({
- text: t,
- width: i,
- lastInParagraph: !1
- });
- }
- _getTextWidth(t) {
- var e = this.letterSpacing(), i = t.length;
- return zs().measureText(t).width + (i ? e * (i - 1) : 0);
- }
- _setTextData() {
- var t = this.text().split(`
- `), e = +this.fontSize(), i = 0, n = this.lineHeight() * e, r = this.attrs.width, a = this.attrs.height, o = r !== $e && r !== void 0, h = a !== $e && a !== void 0, l = this.padding(), A = r - l * 2, u = a - l * 2, f = 0, c = this.wrap(), d = c !== Pa, p = c !== R0 && d, m = this.ellipsis();
- this.textArr = [], zs().font = this._getContextFont();
- for (var v = m ? this._getTextWidth(Bs) : 0, _ = 0, g = t.length; _ < g; ++_) {
- var y = t[_], x = this._getTextWidth(y);
- if (o && x > A)
- for (; y.length > 0; ) {
- for (var b = 0, C = y.length, w = "", E = 0; b < C; ) {
- var S = b + C >>> 1, P = y.slice(0, S + 1), k = this._getTextWidth(P) + v;
- k <= A ? (b = S + 1, w = P, E = k) : C = S;
- }
- if (w) {
- if (p) {
- var F, L = y[w.length], I = L === en || L === Sa;
- I && E <= A ? F = w.length : F = Math.max(w.lastIndexOf(en), w.lastIndexOf(Sa)) + 1, F > 0 && (b = F, w = w.slice(0, b), E = this._getTextWidth(w));
- }
- w = w.trimRight(), this._addTextLine(w), i = Math.max(i, E), f += n;
- var z = this._shouldHandleEllipsis(f);
- if (z) {
- this._tryToAddEllipsisToLastLine();
- break;
- }
- if (y = y.slice(b), y = y.trimLeft(), y.length > 0 && (x = this._getTextWidth(y), x <= A)) {
- this._addTextLine(y), f += n, i = Math.max(i, x);
- break;
- }
- } else
- break;
- }
- else
- this._addTextLine(y), f += n, i = Math.max(i, x), this._shouldHandleEllipsis(f) && _ < g - 1 && this._tryToAddEllipsisToLastLine();
- if (this.textArr[this.textArr.length - 1] && (this.textArr[this.textArr.length - 1].lastInParagraph = !0), h && f + n > u)
- break;
- }
- this.textHeight = e, this.textWidth = i;
- }
- _shouldHandleEllipsis(t) {
- var e = +this.fontSize(), i = this.lineHeight() * e, n = this.attrs.height, r = n !== $e && n !== void 0, a = this.padding(), o = n - a * 2, h = this.wrap(), l = h !== Pa;
- return !l || r && t + i > o;
- }
- _tryToAddEllipsisToLastLine() {
- var t = this.attrs.width, e = t !== $e && t !== void 0, i = this.padding(), n = t - i * 2, r = this.ellipsis(), a = this.textArr[this.textArr.length - 1];
- if (!(!a || !r)) {
- if (e) {
- var o = this._getTextWidth(a.text + Bs) < n;
- o || (a.text = a.text.slice(0, a.text.length - 3));
- }
- this.textArr.splice(this.textArr.length - 1, 1), this._addTextLine(a.text + Bs);
- }
- }
- getStrokeScaleEnabled() {
- return !0;
- }
- _useBufferCanvas() {
- const t = this.textDecoration().indexOf("underline") !== -1 || this.textDecoration().indexOf("line-through") !== -1, e = this.hasShadow();
- return t && e ? !0 : super._useBufferCanvas();
- }
- }
- dn = Me.Text = lt;
- lt.prototype._fillFunc = G0;
- lt.prototype._strokeFunc = B0;
- lt.prototype.className = F0;
- lt.prototype._attrsAffectingSize = [
- "text",
- "fontSize",
- "padding",
- "wrap",
- "lineHeight",
- "letterSpacing"
- ];
- (0, S0._registerNode)(lt);
- vt.Factory.overWriteSetter(lt, "width", (0, me.getNumberOrAutoValidator)());
- vt.Factory.overWriteSetter(lt, "height", (0, me.getNumberOrAutoValidator)());
- vt.Factory.addGetterSetter(lt, "direction", Vo);
- vt.Factory.addGetterSetter(lt, "fontFamily", "Arial");
- vt.Factory.addGetterSetter(lt, "fontSize", 12, (0, me.getNumberValidator)());
- vt.Factory.addGetterSetter(lt, "fontStyle", Wo);
- vt.Factory.addGetterSetter(lt, "fontVariant", Wo);
- vt.Factory.addGetterSetter(lt, "padding", 0, (0, me.getNumberValidator)());
- vt.Factory.addGetterSetter(lt, "align", $o);
- vt.Factory.addGetterSetter(lt, "verticalAlign", k0);
- vt.Factory.addGetterSetter(lt, "lineHeight", 1, (0, me.getNumberValidator)());
- vt.Factory.addGetterSetter(lt, "wrap", L0);
- vt.Factory.addGetterSetter(lt, "ellipsis", !1, (0, me.getBooleanValidator)());
- vt.Factory.addGetterSetter(lt, "letterSpacing", 0, (0, me.getNumberValidator)());
- vt.Factory.addGetterSetter(lt, "text", "", (0, me.getStringValidator)());
- vt.Factory.addGetterSetter(lt, "textDecoration", "");
- var Zn = {};
- Object.defineProperty(Zn, "__esModule", { value: !0 });
- Zn.TextPath = void 0;
- const Us = st, Lt = V, U0 = ft, xi = hi, Hs = Me, Xo = O, H0 = $;
- var V0 = "", jo = "normal";
- function qo(s) {
- s.fillText(this.partialText, 0, 0);
- }
- function Qo(s) {
- s.strokeText(this.partialText, 0, 0);
- }
- class gt extends U0.Shape {
- constructor(t) {
- super(t), this.dummyCanvas = Us.Util.createCanvasElement(), this.dataArray = [], this._readDataAttribute(), this.on("dataChange.konva", function() {
- this._readDataAttribute(), this._setTextData();
- }), this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva", this._setTextData), this._setTextData();
- }
- _getTextPathLength() {
- return xi.Path.getPathLength(this.dataArray);
- }
- _getPointAtLength(t) {
- if (!this.attrs.data)
- return null;
- const e = this.pathLength;
- return t - 1 > e ? null : xi.Path.getPointAtLengthOfDataArray(t, this.dataArray);
- }
- _readDataAttribute() {
- this.dataArray = xi.Path.parsePathData(this.attrs.data), this.pathLength = this._getTextPathLength();
- }
- _sceneFunc(t) {
- t.setAttr("font", this._getContextFont()), t.setAttr("textBaseline", this.textBaseline()), t.setAttr("textAlign", "left"), t.save();
- var e = this.textDecoration(), i = this.fill(), n = this.fontSize(), r = this.glyphInfo;
- e === "underline" && t.beginPath();
- for (var a = 0; a < r.length; a++) {
- t.save();
- var o = r[a].p0;
- t.translate(o.x, o.y), t.rotate(r[a].rotation), this.partialText = r[a].text, t.fillStrokeShape(this), e === "underline" && (a === 0 && t.moveTo(0, n / 2 + 1), t.lineTo(n, n / 2 + 1)), t.restore();
- }
- e === "underline" && (t.strokeStyle = i, t.lineWidth = n / 20, t.stroke()), t.restore();
- }
- _hitFunc(t) {
- t.beginPath();
- var e = this.glyphInfo;
- if (e.length >= 1) {
- var i = e[0].p0;
- t.moveTo(i.x, i.y);
- }
- for (var n = 0; n < e.length; n++) {
- var r = e[n].p1;
- t.lineTo(r.x, r.y);
- }
- t.setAttr("lineWidth", this.fontSize()), t.setAttr("strokeStyle", this.colorKey), t.stroke();
- }
- getTextWidth() {
- return this.textWidth;
- }
- getTextHeight() {
- return Us.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."), this.textHeight;
- }
- setText(t) {
- return Hs.Text.prototype.setText.call(this, t);
- }
- _getContextFont() {
- return Hs.Text.prototype._getContextFont.call(this);
- }
- _getTextSize(t) {
- var e = this.dummyCanvas, i = e.getContext("2d");
- i.save(), i.font = this._getContextFont();
- var n = i.measureText(t);
- return i.restore(), {
- width: n.width,
- height: parseInt(`${this.fontSize()}`, 10)
- };
- }
- _setTextData() {
- const { width: t, height: e } = this._getTextSize(this.attrs.text);
- if (this.textWidth = t, this.textHeight = e, this.glyphInfo = [], !this.attrs.data)
- return null;
- const i = this.letterSpacing(), n = this.align(), r = this.kerningFunc(), a = Math.max(this.textWidth + ((this.attrs.text || "").length - 1) * i, 0);
- let o = 0;
- n === "center" && (o = Math.max(0, this.pathLength / 2 - a / 2)), n === "right" && (o = Math.max(0, this.pathLength - a));
- const h = (0, Hs.stringToArray)(this.text());
- let l = o;
- for (var A = 0; A < h.length; A++) {
- const u = this._getPointAtLength(l);
- if (!u)
- return;
- let f = this._getTextSize(h[A]).width + i;
- if (h[A] === " " && n === "justify") {
- const _ = this.text().split(" ").length - 1;
- f += (this.pathLength - a) / _;
- }
- const c = this._getPointAtLength(l + f);
- if (!c)
- return;
- const d = xi.Path.getLineLength(u.x, u.y, c.x, c.y);
- let p = 0;
- if (r)
- try {
- p = r(h[A - 1], h[A]) * this.fontSize();
- } catch {
- p = 0;
- }
- u.x += p, c.x += p, this.textWidth += p;
- const m = xi.Path.getPointOnLine(p + d / 2, u.x, u.y, c.x, c.y), v = Math.atan2(c.y - u.y, c.x - u.x);
- this.glyphInfo.push({
- transposeX: m.x,
- transposeY: m.y,
- text: h[A],
- rotation: v,
- p0: u,
- p1: c
- }), l += f;
- }
- }
- getSelfRect() {
- if (!this.glyphInfo.length)
- return {
- x: 0,
- y: 0,
- width: 0,
- height: 0
- };
- var t = [];
- this.glyphInfo.forEach(function(A) {
- t.push(A.p0.x), t.push(A.p0.y), t.push(A.p1.x), t.push(A.p1.y);
- });
- for (var e = t[0] || 0, i = t[0] || 0, n = t[1] || 0, r = t[1] || 0, a, o, h = 0; h < t.length / 2; h++)
- a = t[h * 2], o = t[h * 2 + 1], e = Math.min(e, a), i = Math.max(i, a), n = Math.min(n, o), r = Math.max(r, o);
- var l = this.fontSize();
- return {
- x: e - l / 2,
- y: n - l / 2,
- width: i - e + l,
- height: r - n + l
- };
- }
- destroy() {
- return Us.Util.releaseCanvas(this.dummyCanvas), super.destroy();
- }
- }
- Zn.TextPath = gt;
- gt.prototype._fillFunc = qo;
- gt.prototype._strokeFunc = Qo;
- gt.prototype._fillFuncHit = qo;
- gt.prototype._strokeFuncHit = Qo;
- gt.prototype.className = "TextPath";
- gt.prototype._attrsAffectingSize = ["text", "fontSize", "data"];
- (0, H0._registerNode)(gt);
- Lt.Factory.addGetterSetter(gt, "data");
- Lt.Factory.addGetterSetter(gt, "fontFamily", "Arial");
- Lt.Factory.addGetterSetter(gt, "fontSize", 12, (0, Xo.getNumberValidator)());
- Lt.Factory.addGetterSetter(gt, "fontStyle", jo);
- Lt.Factory.addGetterSetter(gt, "align", "left");
- Lt.Factory.addGetterSetter(gt, "letterSpacing", 0, (0, Xo.getNumberValidator)());
- Lt.Factory.addGetterSetter(gt, "textBaseline", "middle");
- Lt.Factory.addGetterSetter(gt, "fontVariant", jo);
- Lt.Factory.addGetterSetter(gt, "text", V0);
- Lt.Factory.addGetterSetter(gt, "textDecoration", null);
- Lt.Factory.addGetterSetter(gt, "kerningFunc", null);
- var Jn = {};
- Object.defineProperty(Jn, "__esModule", { value: !0 });
- Jn.Transformer = void 0;
- const Z = st, Q = V, Ea = rt, $0 = ft, W0 = Bi, Fa = li, Dt = $, ve = O, Y0 = $;
- var Ko = "tr-konva", X0 = [
- "resizeEnabledChange",
- "rotateAnchorOffsetChange",
- "rotateEnabledChange",
- "enabledAnchorsChange",
- "anchorSizeChange",
- "borderEnabledChange",
- "borderStrokeChange",
- "borderStrokeWidthChange",
- "borderDashChange",
- "anchorStrokeChange",
- "anchorStrokeWidthChange",
- "anchorFillChange",
- "anchorCornerRadiusChange",
- "ignoreStrokeChange",
- "anchorStyleFuncChange"
- ].map((s) => s + `.${Ko}`).join(" "), ka = "nodesRect", j0 = [
- "widthChange",
- "heightChange",
- "scaleXChange",
- "scaleYChange",
- "skewXChange",
- "skewYChange",
- "rotationChange",
- "offsetXChange",
- "offsetYChange",
- "transformsEnabledChange",
- "strokeWidthChange"
- ], q0 = {
- "top-left": -45,
- "top-center": 0,
- "top-right": 45,
- "middle-right": -90,
- "middle-left": 90,
- "bottom-left": -135,
- "bottom-center": 180,
- "bottom-right": 135
- };
- const Q0 = "ontouchstart" in Dt.Konva._global;
- function K0(s, t, e) {
- if (s === "rotater")
- return e;
- t += Z.Util.degToRad(q0[s] || 0);
- var i = (Z.Util.radToDeg(t) % 360 + 360) % 360;
- return Z.Util._inRange(i, 315 + 22.5, 360) || Z.Util._inRange(i, 0, 22.5) ? "ns-resize" : Z.Util._inRange(i, 45 - 22.5, 45 + 22.5) ? "nesw-resize" : Z.Util._inRange(i, 90 - 22.5, 90 + 22.5) ? "ew-resize" : Z.Util._inRange(i, 135 - 22.5, 135 + 22.5) ? "nwse-resize" : Z.Util._inRange(i, 180 - 22.5, 180 + 22.5) ? "ns-resize" : Z.Util._inRange(i, 225 - 22.5, 225 + 22.5) ? "nesw-resize" : Z.Util._inRange(i, 270 - 22.5, 270 + 22.5) ? "ew-resize" : Z.Util._inRange(i, 315 - 22.5, 315 + 22.5) ? "nwse-resize" : (Z.Util.error("Transformer has unknown angle for cursor detection: " + i), "pointer");
- }
- var un = [
- "top-left",
- "top-center",
- "top-right",
- "middle-right",
- "middle-left",
- "bottom-left",
- "bottom-center",
- "bottom-right"
- ], Da = 1e8;
- function Z0(s) {
- return {
- x: s.x + s.width / 2 * Math.cos(s.rotation) + s.height / 2 * Math.sin(-s.rotation),
- y: s.y + s.height / 2 * Math.cos(s.rotation) + s.width / 2 * Math.sin(s.rotation)
- };
- }
- function Zo(s, t, e) {
- const i = e.x + (s.x - e.x) * Math.cos(t) - (s.y - e.y) * Math.sin(t), n = e.y + (s.x - e.x) * Math.sin(t) + (s.y - e.y) * Math.cos(t);
- return {
- ...s,
- rotation: s.rotation + t,
- x: i,
- y: n
- };
- }
- function J0(s, t) {
- const e = Z0(s);
- return Zo(s, t, e);
- }
- function tc(s, t, e) {
- let i = t;
- for (let n = 0; n < s.length; n++) {
- const r = Dt.Konva.getAngle(s[n]), a = Math.abs(r - t) % (Math.PI * 2);
- Math.min(a, Math.PI * 2 - a) < e && (i = r);
- }
- return i;
- }
- let rr = 0;
- class Y extends Fa.Group {
- constructor(t) {
- super(t), this._movingAnchorName = null, this._transforming = !1, this._createElements(), this._handleMouseMove = this._handleMouseMove.bind(this), this._handleMouseUp = this._handleMouseUp.bind(this), this.update = this.update.bind(this), this.on(X0, this.update), this.getNode() && this.update();
- }
- attachTo(t) {
- return this.setNode(t), this;
- }
- setNode(t) {
- return Z.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."), this.setNodes([t]);
- }
- getNode() {
- return this._nodes && this._nodes[0];
- }
- _getEventNamespace() {
- return Ko + this._id;
- }
- setNodes(t = []) {
- this._nodes && this._nodes.length && this.detach();
- const e = t.filter((n) => n.isAncestorOf(this) ? (Z.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"), !1) : !0);
- this._nodes = t = e, t.length === 1 && this.useSingleNodeRotation() ? this.rotation(t[0].getAbsoluteRotation()) : this.rotation(0), this._nodes.forEach((n) => {
- const r = () => {
- this.nodes().length === 1 && this.useSingleNodeRotation() && this.rotation(this.nodes()[0].getAbsoluteRotation()), this._resetTransformCache(), !this._transforming && !this.isDragging() && this.update();
- }, a = n._attrsAffectingSize.map((o) => o + "Change." + this._getEventNamespace()).join(" ");
- n.on(a, r), n.on(j0.map((o) => o + `.${this._getEventNamespace()}`).join(" "), r), n.on(`absoluteTransformChange.${this._getEventNamespace()}`, r), this._proxyDrag(n);
- }), this._resetTransformCache();
- var i = !!this.findOne(".top-left");
- return i && this.update(), this;
- }
- _proxyDrag(t) {
- let e;
- t.on(`dragstart.${this._getEventNamespace()}`, (i) => {
- e = t.getAbsolutePosition(), !this.isDragging() && t !== this.findOne(".back") && this.startDrag(i, !1);
- }), t.on(`dragmove.${this._getEventNamespace()}`, (i) => {
- if (!e)
- return;
- const n = t.getAbsolutePosition(), r = n.x - e.x, a = n.y - e.y;
- this.nodes().forEach((o) => {
- if (o === t || o.isDragging())
- return;
- const h = o.getAbsolutePosition();
- o.setAbsolutePosition({
- x: h.x + r,
- y: h.y + a
- }), o.startDrag(i);
- }), e = null;
- });
- }
- getNodes() {
- return this._nodes || [];
- }
- getActiveAnchor() {
- return this._movingAnchorName;
- }
- detach() {
- this._nodes && this._nodes.forEach((t) => {
- t.off("." + this._getEventNamespace());
- }), this._nodes = [], this._resetTransformCache();
- }
- _resetTransformCache() {
- this._clearCache(ka), this._clearCache("transform"), this._clearSelfAndDescendantCache("absoluteTransform");
- }
- _getNodeRect() {
- return this._getCache(ka, this.__getNodeRect);
- }
- __getNodeShape(t, e = this.rotation(), i) {
- var n = t.getClientRect({
- skipTransform: !0,
- skipShadow: !0,
- skipStroke: this.ignoreStroke()
- }), r = t.getAbsoluteScale(i), a = t.getAbsolutePosition(i), o = n.x * r.x - t.offsetX() * r.x, h = n.y * r.y - t.offsetY() * r.y;
- const l = (Dt.Konva.getAngle(t.getAbsoluteRotation()) + Math.PI * 2) % (Math.PI * 2), A = {
- x: a.x + o * Math.cos(l) + h * Math.sin(-l),
- y: a.y + h * Math.cos(l) + o * Math.sin(l),
- width: n.width * r.x,
- height: n.height * r.y,
- rotation: l
- };
- return Zo(A, -Dt.Konva.getAngle(e), {
- x: 0,
- y: 0
- });
- }
- __getNodeRect() {
- var t = this.getNode();
- if (!t)
- return {
- x: -Da,
- y: -Da,
- width: 0,
- height: 0,
- rotation: 0
- };
- const e = [];
- this.nodes().map((l) => {
- const A = l.getClientRect({
- skipTransform: !0,
- skipShadow: !0,
- skipStroke: this.ignoreStroke()
- });
- var u = [
- { x: A.x, y: A.y },
- { x: A.x + A.width, y: A.y },
- { x: A.x + A.width, y: A.y + A.height },
- { x: A.x, y: A.y + A.height }
- ], f = l.getAbsoluteTransform();
- u.forEach(function(c) {
- var d = f.point(c);
- e.push(d);
- });
- });
- const i = new Z.Transform();
- i.rotate(-Dt.Konva.getAngle(this.rotation()));
- var n = 1 / 0, r = 1 / 0, a = -1 / 0, o = -1 / 0;
- e.forEach(function(l) {
- var A = i.point(l);
- n === void 0 && (n = a = A.x, r = o = A.y), n = Math.min(n, A.x), r = Math.min(r, A.y), a = Math.max(a, A.x), o = Math.max(o, A.y);
- }), i.invert();
- const h = i.point({ x: n, y: r });
- return {
- x: h.x,
- y: h.y,
- width: a - n,
- height: o - r,
- rotation: Dt.Konva.getAngle(this.rotation())
- };
- }
- getX() {
- return this._getNodeRect().x;
- }
- getY() {
- return this._getNodeRect().y;
- }
- getWidth() {
- return this._getNodeRect().width;
- }
- getHeight() {
- return this._getNodeRect().height;
- }
- _createElements() {
- this._createBack(), un.forEach((t) => {
- this._createAnchor(t);
- }), this._createAnchor("rotater");
- }
- _createAnchor(t) {
- var e = new W0.Rect({
- stroke: "rgb(0, 161, 255)",
- fill: "white",
- strokeWidth: 1,
- name: t + " _anchor",
- dragDistance: 0,
- draggable: !0,
- hitStrokeWidth: Q0 ? 10 : "auto"
- }), i = this;
- e.on("mousedown touchstart", function(n) {
- i._handleMouseDown(n);
- }), e.on("dragstart", (n) => {
- e.stopDrag(), n.cancelBubble = !0;
- }), e.on("dragend", (n) => {
- n.cancelBubble = !0;
- }), e.on("mouseenter", () => {
- var n = Dt.Konva.getAngle(this.rotation()), r = this.rotateAnchorCursor(), a = K0(t, n, r);
- e.getStage().content && (e.getStage().content.style.cursor = a), this._cursorChange = !0;
- }), e.on("mouseout", () => {
- e.getStage().content && (e.getStage().content.style.cursor = ""), this._cursorChange = !1;
- }), this.add(e);
- }
- _createBack() {
- var t = new $0.Shape({
- name: "back",
- width: 0,
- height: 0,
- draggable: !0,
- sceneFunc(e, i) {
- var n = i.getParent(), r = n.padding();
- e.beginPath(), e.rect(-r, -r, i.width() + r * 2, i.height() + r * 2), e.moveTo(i.width() / 2, -r), n.rotateEnabled() && n.rotateLineVisible() && e.lineTo(i.width() / 2, -n.rotateAnchorOffset() * Z.Util._sign(i.height()) - r), e.fillStrokeShape(i);
- },
- hitFunc: (e, i) => {
- if (this.shouldOverdrawWholeArea()) {
- var n = this.padding();
- e.beginPath(), e.rect(-n, -n, i.width() + n * 2, i.height() + n * 2), e.fillStrokeShape(i);
- }
- }
- });
- this.add(t), this._proxyDrag(t), t.on("dragstart", (e) => {
- e.cancelBubble = !0;
- }), t.on("dragmove", (e) => {
- e.cancelBubble = !0;
- }), t.on("dragend", (e) => {
- e.cancelBubble = !0;
- }), this.on("dragmove", (e) => {
- this.update();
- });
- }
- _handleMouseDown(t) {
- this._movingAnchorName = t.target.name().split(" ")[0];
- var e = this._getNodeRect(), i = e.width, n = e.height, r = Math.sqrt(Math.pow(i, 2) + Math.pow(n, 2));
- this.sin = Math.abs(n / r), this.cos = Math.abs(i / r), typeof window < "u" && (window.addEventListener("mousemove", this._handleMouseMove), window.addEventListener("touchmove", this._handleMouseMove), window.addEventListener("mouseup", this._handleMouseUp, !0), window.addEventListener("touchend", this._handleMouseUp, !0)), this._transforming = !0;
- var a = t.target.getAbsolutePosition(), o = t.target.getStage().getPointerPosition();
- this._anchorDragOffset = {
- x: o.x - a.x,
- y: o.y - a.y
- }, rr++, this._fire("transformstart", { evt: t.evt, target: this.getNode() }), this._nodes.forEach((h) => {
- h._fire("transformstart", { evt: t.evt, target: h });
- });
- }
- _handleMouseMove(t) {
- var e, i, n, r = this.findOne("." + this._movingAnchorName), a = r.getStage();
- a.setPointersPositions(t);
- const o = a.getPointerPosition();
- let h = {
- x: o.x - this._anchorDragOffset.x,
- y: o.y - this._anchorDragOffset.y
- };
- const l = r.getAbsolutePosition();
- this.anchorDragBoundFunc() && (h = this.anchorDragBoundFunc()(l, h, t)), r.setAbsolutePosition(h);
- const A = r.getAbsolutePosition();
- if (!(l.x === A.x && l.y === A.y)) {
- if (this._movingAnchorName === "rotater") {
- var u = this._getNodeRect();
- e = r.x() - u.width / 2, i = -r.y() + u.height / 2;
- let F = Math.atan2(-i, e) + Math.PI / 2;
- u.height < 0 && (F -= Math.PI);
- var f = Dt.Konva.getAngle(this.rotation());
- const L = f + F, I = Dt.Konva.getAngle(this.rotationSnapTolerance()), T = tc(this.rotationSnaps(), L, I) - u.rotation, G = J0(u, T);
- this._fitNodesInto(G, t);
- return;
- }
- var c = this.shiftBehavior(), d;
- c === "inverted" ? d = this.keepRatio() && !t.shiftKey : c === "none" ? d = this.keepRatio() : d = this.keepRatio() || t.shiftKey;
- var g = this.centeredScaling() || t.altKey;
- if (this._movingAnchorName === "top-left") {
- if (d) {
- var p = g ? {
- x: this.width() / 2,
- y: this.height() / 2
- } : {
- x: this.findOne(".bottom-right").x(),
- y: this.findOne(".bottom-right").y()
- };
- n = Math.sqrt(Math.pow(p.x - r.x(), 2) + Math.pow(p.y - r.y(), 2));
- var m = this.findOne(".top-left").x() > p.x ? -1 : 1, v = this.findOne(".top-left").y() > p.y ? -1 : 1;
- e = n * this.cos * m, i = n * this.sin * v, this.findOne(".top-left").x(p.x - e), this.findOne(".top-left").y(p.y - i);
- }
- } else if (this._movingAnchorName === "top-center")
- this.findOne(".top-left").y(r.y());
- else if (this._movingAnchorName === "top-right") {
- if (d) {
- var p = g ? {
- x: this.width() / 2,
- y: this.height() / 2
- } : {
- x: this.findOne(".bottom-left").x(),
- y: this.findOne(".bottom-left").y()
- };
- n = Math.sqrt(Math.pow(r.x() - p.x, 2) + Math.pow(p.y - r.y(), 2));
- var m = this.findOne(".top-right").x() < p.x ? -1 : 1, v = this.findOne(".top-right").y() > p.y ? -1 : 1;
- e = n * this.cos * m, i = n * this.sin * v, this.findOne(".top-right").x(p.x + e), this.findOne(".top-right").y(p.y - i);
- }
- var _ = r.position();
- this.findOne(".top-left").y(_.y), this.findOne(".bottom-right").x(_.x);
- } else if (this._movingAnchorName === "middle-left")
- this.findOne(".top-left").x(r.x());
- else if (this._movingAnchorName === "middle-right")
- this.findOne(".bottom-right").x(r.x());
- else if (this._movingAnchorName === "bottom-left") {
- if (d) {
- var p = g ? {
- x: this.width() / 2,
- y: this.height() / 2
- } : {
- x: this.findOne(".top-right").x(),
- y: this.findOne(".top-right").y()
- };
- n = Math.sqrt(Math.pow(p.x - r.x(), 2) + Math.pow(r.y() - p.y, 2));
- var m = p.x < r.x() ? -1 : 1, v = r.y() < p.y ? -1 : 1;
- e = n * this.cos * m, i = n * this.sin * v, r.x(p.x - e), r.y(p.y + i);
- }
- _ = r.position(), this.findOne(".top-left").x(_.x), this.findOne(".bottom-right").y(_.y);
- } else if (this._movingAnchorName === "bottom-center")
- this.findOne(".bottom-right").y(r.y());
- else if (this._movingAnchorName === "bottom-right") {
- if (d) {
- var p = g ? {
- x: this.width() / 2,
- y: this.height() / 2
- } : {
- x: this.findOne(".top-left").x(),
- y: this.findOne(".top-left").y()
- };
- n = Math.sqrt(Math.pow(r.x() - p.x, 2) + Math.pow(r.y() - p.y, 2));
- var m = this.findOne(".bottom-right").x() < p.x ? -1 : 1, v = this.findOne(".bottom-right").y() < p.y ? -1 : 1;
- e = n * this.cos * m, i = n * this.sin * v, this.findOne(".bottom-right").x(p.x + e), this.findOne(".bottom-right").y(p.y + i);
- }
- } else
- console.error(new Error("Wrong position argument of selection resizer: " + this._movingAnchorName));
- var g = this.centeredScaling() || t.altKey;
- if (g) {
- var y = this.findOne(".top-left"), x = this.findOne(".bottom-right"), b = y.x(), C = y.y(), w = this.getWidth() - x.x(), E = this.getHeight() - x.y();
- x.move({
- x: -b,
- y: -C
- }), y.move({
- x: w,
- y: E
- });
- }
- var S = this.findOne(".top-left").getAbsolutePosition();
- e = S.x, i = S.y;
- var P = this.findOne(".bottom-right").x() - this.findOne(".top-left").x(), k = this.findOne(".bottom-right").y() - this.findOne(".top-left").y();
- this._fitNodesInto({
- x: e,
- y: i,
- width: P,
- height: k,
- rotation: Dt.Konva.getAngle(this.rotation())
- }, t);
- }
- }
- _handleMouseUp(t) {
- this._removeEvents(t);
- }
- getAbsoluteTransform() {
- return this.getTransform();
- }
- _removeEvents(t) {
- var e;
- if (this._transforming) {
- this._transforming = !1, typeof window < "u" && (window.removeEventListener("mousemove", this._handleMouseMove), window.removeEventListener("touchmove", this._handleMouseMove), window.removeEventListener("mouseup", this._handleMouseUp, !0), window.removeEventListener("touchend", this._handleMouseUp, !0));
- var i = this.getNode();
- rr--, this._fire("transformend", { evt: t, target: i }), (e = this.getLayer()) === null || e === void 0 || e.batchDraw(), i && this._nodes.forEach((n) => {
- var r;
- n._fire("transformend", { evt: t, target: n }), (r = n.getLayer()) === null || r === void 0 || r.batchDraw();
- }), this._movingAnchorName = null;
- }
- }
- _fitNodesInto(t, e) {
- var i = this._getNodeRect();
- const n = 1;
- if (Z.Util._inRange(t.width, -this.padding() * 2 - n, n)) {
- this.update();
- return;
- }
- if (Z.Util._inRange(t.height, -this.padding() * 2 - n, n)) {
- this.update();
- return;
- }
- var r = new Z.Transform();
- if (r.rotate(Dt.Konva.getAngle(this.rotation())), this._movingAnchorName && t.width < 0 && this._movingAnchorName.indexOf("left") >= 0) {
- const f = r.point({
- x: -this.padding() * 2,
- y: 0
- });
- t.x += f.x, t.y += f.y, t.width += this.padding() * 2, this._movingAnchorName = this._movingAnchorName.replace("left", "right"), this._anchorDragOffset.x -= f.x, this._anchorDragOffset.y -= f.y;
- } else if (this._movingAnchorName && t.width < 0 && this._movingAnchorName.indexOf("right") >= 0) {
- const f = r.point({
- x: this.padding() * 2,
- y: 0
- });
- this._movingAnchorName = this._movingAnchorName.replace("right", "left"), this._anchorDragOffset.x -= f.x, this._anchorDragOffset.y -= f.y, t.width += this.padding() * 2;
- }
- if (this._movingAnchorName && t.height < 0 && this._movingAnchorName.indexOf("top") >= 0) {
- const f = r.point({
- x: 0,
- y: -this.padding() * 2
- });
- t.x += f.x, t.y += f.y, this._movingAnchorName = this._movingAnchorName.replace("top", "bottom"), this._anchorDragOffset.x -= f.x, this._anchorDragOffset.y -= f.y, t.height += this.padding() * 2;
- } else if (this._movingAnchorName && t.height < 0 && this._movingAnchorName.indexOf("bottom") >= 0) {
- const f = r.point({
- x: 0,
- y: this.padding() * 2
- });
- this._movingAnchorName = this._movingAnchorName.replace("bottom", "top"), this._anchorDragOffset.x -= f.x, this._anchorDragOffset.y -= f.y, t.height += this.padding() * 2;
- }
- if (this.boundBoxFunc()) {
- const f = this.boundBoxFunc()(i, t);
- f ? t = f : Z.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!");
- }
- const a = 1e7, o = new Z.Transform();
- o.translate(i.x, i.y), o.rotate(i.rotation), o.scale(i.width / a, i.height / a);
- const h = new Z.Transform(), l = t.width / a, A = t.height / a;
- this.flipEnabled() === !1 ? (h.translate(t.x, t.y), h.rotate(t.rotation), h.translate(t.width < 0 ? t.width : 0, t.height < 0 ? t.height : 0), h.scale(Math.abs(l), Math.abs(A))) : (h.translate(t.x, t.y), h.rotate(t.rotation), h.scale(l, A));
- const u = h.multiply(o.invert());
- this._nodes.forEach((f) => {
- var c;
- const d = f.getParent().getAbsoluteTransform(), p = f.getTransform().copy();
- p.translate(f.offsetX(), f.offsetY());
- const m = new Z.Transform();
- m.multiply(d.copy().invert()).multiply(u).multiply(d).multiply(p);
- const v = m.decompose();
- f.setAttrs(v), (c = f.getLayer()) === null || c === void 0 || c.batchDraw();
- }), this.rotation(Z.Util._getRotation(t.rotation)), this._nodes.forEach((f) => {
- this._fire("transform", { evt: e, target: f }), f._fire("transform", { evt: e, target: f });
- }), this._resetTransformCache(), this.update(), this.getLayer().batchDraw();
- }
- forceUpdate() {
- this._resetTransformCache(), this.update();
- }
- _batchChangeChild(t, e) {
- this.findOne(t).setAttrs(e);
- }
- update() {
- var t, e = this._getNodeRect();
- this.rotation(Z.Util._getRotation(e.rotation));
- var i = e.width, n = e.height, r = this.enabledAnchors(), a = this.resizeEnabled(), o = this.padding(), h = this.anchorSize();
- const l = this.find("._anchor");
- l.forEach((u) => {
- u.setAttrs({
- width: h,
- height: h,
- offsetX: h / 2,
- offsetY: h / 2,
- stroke: this.anchorStroke(),
- strokeWidth: this.anchorStrokeWidth(),
- fill: this.anchorFill(),
- cornerRadius: this.anchorCornerRadius()
- });
- }), this._batchChangeChild(".top-left", {
- x: 0,
- y: 0,
- offsetX: h / 2 + o,
- offsetY: h / 2 + o,
- visible: a && r.indexOf("top-left") >= 0
- }), this._batchChangeChild(".top-center", {
- x: i / 2,
- y: 0,
- offsetY: h / 2 + o,
- visible: a && r.indexOf("top-center") >= 0
- }), this._batchChangeChild(".top-right", {
- x: i,
- y: 0,
- offsetX: h / 2 - o,
- offsetY: h / 2 + o,
- visible: a && r.indexOf("top-right") >= 0
- }), this._batchChangeChild(".middle-left", {
- x: 0,
- y: n / 2,
- offsetX: h / 2 + o,
- visible: a && r.indexOf("middle-left") >= 0
- }), this._batchChangeChild(".middle-right", {
- x: i,
- y: n / 2,
- offsetX: h / 2 - o,
- visible: a && r.indexOf("middle-right") >= 0
- }), this._batchChangeChild(".bottom-left", {
- x: 0,
- y: n,
- offsetX: h / 2 + o,
- offsetY: h / 2 - o,
- visible: a && r.indexOf("bottom-left") >= 0
- }), this._batchChangeChild(".bottom-center", {
- x: i / 2,
- y: n,
- offsetY: h / 2 - o,
- visible: a && r.indexOf("bottom-center") >= 0
- }), this._batchChangeChild(".bottom-right", {
- x: i,
- y: n,
- offsetX: h / 2 - o,
- offsetY: h / 2 - o,
- visible: a && r.indexOf("bottom-right") >= 0
- }), this._batchChangeChild(".rotater", {
- x: i / 2,
- y: -this.rotateAnchorOffset() * Z.Util._sign(n) - o,
- visible: this.rotateEnabled()
- }), this._batchChangeChild(".back", {
- width: i,
- height: n,
- visible: this.borderEnabled(),
- stroke: this.borderStroke(),
- strokeWidth: this.borderStrokeWidth(),
- dash: this.borderDash(),
- x: 0,
- y: 0
- });
- const A = this.anchorStyleFunc();
- A && l.forEach((u) => {
- A(u);
- }), (t = this.getLayer()) === null || t === void 0 || t.batchDraw();
- }
- isTransforming() {
- return this._transforming;
- }
- stopTransform() {
- if (this._transforming) {
- this._removeEvents();
- var t = this.findOne("." + this._movingAnchorName);
- t && t.stopDrag();
- }
- }
- destroy() {
- return this.getStage() && this._cursorChange && this.getStage().content && (this.getStage().content.style.cursor = ""), Fa.Group.prototype.destroy.call(this), this.detach(), this._removeEvents(), this;
- }
- toObject() {
- return Ea.Node.prototype.toObject.call(this);
- }
- clone(t) {
- var e = Ea.Node.prototype.clone.call(this, t);
- return e;
- }
- getClientRect() {
- return this.nodes().length > 0 ? super.getClientRect() : { x: 0, y: 0, width: 0, height: 0 };
- }
- }
- Jn.Transformer = Y;
- Y.isTransforming = () => rr > 0;
- function ec(s) {
- return s instanceof Array || Z.Util.warn("enabledAnchors value should be an array"), s instanceof Array && s.forEach(function(t) {
- un.indexOf(t) === -1 && Z.Util.warn("Unknown anchor name: " + t + ". Available names are: " + un.join(", "));
- }), s || [];
- }
- Y.prototype.className = "Transformer";
- (0, Y0._registerNode)(Y);
- Q.Factory.addGetterSetter(Y, "enabledAnchors", un, ec);
- Q.Factory.addGetterSetter(Y, "flipEnabled", !0, (0, ve.getBooleanValidator)());
- Q.Factory.addGetterSetter(Y, "resizeEnabled", !0);
- Q.Factory.addGetterSetter(Y, "anchorSize", 10, (0, ve.getNumberValidator)());
- Q.Factory.addGetterSetter(Y, "rotateEnabled", !0);
- Q.Factory.addGetterSetter(Y, "rotateLineVisible", !0);
- Q.Factory.addGetterSetter(Y, "rotationSnaps", []);
- Q.Factory.addGetterSetter(Y, "rotateAnchorOffset", 50, (0, ve.getNumberValidator)());
- Q.Factory.addGetterSetter(Y, "rotateAnchorCursor", "crosshair");
- Q.Factory.addGetterSetter(Y, "rotationSnapTolerance", 5, (0, ve.getNumberValidator)());
- Q.Factory.addGetterSetter(Y, "borderEnabled", !0);
- Q.Factory.addGetterSetter(Y, "anchorStroke", "rgb(0, 161, 255)");
- Q.Factory.addGetterSetter(Y, "anchorStrokeWidth", 1, (0, ve.getNumberValidator)());
- Q.Factory.addGetterSetter(Y, "anchorFill", "white");
- Q.Factory.addGetterSetter(Y, "anchorCornerRadius", 0, (0, ve.getNumberValidator)());
- Q.Factory.addGetterSetter(Y, "borderStroke", "rgb(0, 161, 255)");
- Q.Factory.addGetterSetter(Y, "borderStrokeWidth", 1, (0, ve.getNumberValidator)());
- Q.Factory.addGetterSetter(Y, "borderDash");
- Q.Factory.addGetterSetter(Y, "keepRatio", !0);
- Q.Factory.addGetterSetter(Y, "shiftBehavior", "default");
- Q.Factory.addGetterSetter(Y, "centeredScaling", !1);
- Q.Factory.addGetterSetter(Y, "ignoreStroke", !1);
- Q.Factory.addGetterSetter(Y, "padding", 0, (0, ve.getNumberValidator)());
- Q.Factory.addGetterSetter(Y, "node");
- Q.Factory.addGetterSetter(Y, "nodes");
- Q.Factory.addGetterSetter(Y, "boundBoxFunc");
- Q.Factory.addGetterSetter(Y, "anchorDragBoundFunc");
- Q.Factory.addGetterSetter(Y, "anchorStyleFunc");
- Q.Factory.addGetterSetter(Y, "shouldOverdrawWholeArea", !1);
- Q.Factory.addGetterSetter(Y, "useSingleNodeRotation", !0);
- Q.Factory.backCompat(Y, {
- lineEnabled: "borderEnabled",
- rotateHandlerOffset: "rotateAnchorOffset",
- enabledHandlers: "enabledAnchors"
- });
- var ts = {};
- Object.defineProperty(ts, "__esModule", { value: !0 });
- ts.Wedge = void 0;
- const es = V, ic = ft, nc = $, Jo = O, sc = $;
- class ee extends ic.Shape {
- _sceneFunc(t) {
- t.beginPath(), t.arc(0, 0, this.radius(), 0, nc.Konva.getAngle(this.angle()), this.clockwise()), t.lineTo(0, 0), t.closePath(), t.fillStrokeShape(this);
- }
- getWidth() {
- return this.radius() * 2;
- }
- getHeight() {
- return this.radius() * 2;
- }
- setWidth(t) {
- this.radius(t / 2);
- }
- setHeight(t) {
- this.radius(t / 2);
- }
- }
- ts.Wedge = ee;
- ee.prototype.className = "Wedge";
- ee.prototype._centroid = !0;
- ee.prototype._attrsAffectingSize = ["radius"];
- (0, sc._registerNode)(ee);
- es.Factory.addGetterSetter(ee, "radius", 0, (0, Jo.getNumberValidator)());
- es.Factory.addGetterSetter(ee, "angle", 0, (0, Jo.getNumberValidator)());
- es.Factory.addGetterSetter(ee, "clockwise", !1);
- es.Factory.backCompat(ee, {
- angleDeg: "angle",
- getAngleDeg: "getAngle",
- setAngleDeg: "setAngle"
- });
- var is = {};
- Object.defineProperty(is, "__esModule", { value: !0 });
- is.Blur = void 0;
- const Ia = V, rc = rt, ac = O;
- function Ta() {
- this.r = 0, this.g = 0, this.b = 0, this.a = 0, this.next = null;
- }
- var oc = [
- 512,
- 512,
- 456,
- 512,
- 328,
- 456,
- 335,
- 512,
- 405,
- 328,
- 271,
- 456,
- 388,
- 335,
- 292,
- 512,
- 454,
- 405,
- 364,
- 328,
- 298,
- 271,
- 496,
- 456,
- 420,
- 388,
- 360,
- 335,
- 312,
- 292,
- 273,
- 512,
- 482,
- 454,
- 428,
- 405,
- 383,
- 364,
- 345,
- 328,
- 312,
- 298,
- 284,
- 271,
- 259,
- 496,
- 475,
- 456,
- 437,
- 420,
- 404,
- 388,
- 374,
- 360,
- 347,
- 335,
- 323,
- 312,
- 302,
- 292,
- 282,
- 273,
- 265,
- 512,
- 497,
- 482,
- 468,
- 454,
- 441,
- 428,
- 417,
- 405,
- 394,
- 383,
- 373,
- 364,
- 354,
- 345,
- 337,
- 328,
- 320,
- 312,
- 305,
- 298,
- 291,
- 284,
- 278,
- 271,
- 265,
- 259,
- 507,
- 496,
- 485,
- 475,
- 465,
- 456,
- 446,
- 437,
- 428,
- 420,
- 412,
- 404,
- 396,
- 388,
- 381,
- 374,
- 367,
- 360,
- 354,
- 347,
- 341,
- 335,
- 329,
- 323,
- 318,
- 312,
- 307,
- 302,
- 297,
- 292,
- 287,
- 282,
- 278,
- 273,
- 269,
- 265,
- 261,
- 512,
- 505,
- 497,
- 489,
- 482,
- 475,
- 468,
- 461,
- 454,
- 447,
- 441,
- 435,
- 428,
- 422,
- 417,
- 411,
- 405,
- 399,
- 394,
- 389,
- 383,
- 378,
- 373,
- 368,
- 364,
- 359,
- 354,
- 350,
- 345,
- 341,
- 337,
- 332,
- 328,
- 324,
- 320,
- 316,
- 312,
- 309,
- 305,
- 301,
- 298,
- 294,
- 291,
- 287,
- 284,
- 281,
- 278,
- 274,
- 271,
- 268,
- 265,
- 262,
- 259,
- 257,
- 507,
- 501,
- 496,
- 491,
- 485,
- 480,
- 475,
- 470,
- 465,
- 460,
- 456,
- 451,
- 446,
- 442,
- 437,
- 433,
- 428,
- 424,
- 420,
- 416,
- 412,
- 408,
- 404,
- 400,
- 396,
- 392,
- 388,
- 385,
- 381,
- 377,
- 374,
- 370,
- 367,
- 363,
- 360,
- 357,
- 354,
- 350,
- 347,
- 344,
- 341,
- 338,
- 335,
- 332,
- 329,
- 326,
- 323,
- 320,
- 318,
- 315,
- 312,
- 310,
- 307,
- 304,
- 302,
- 299,
- 297,
- 294,
- 292,
- 289,
- 287,
- 285,
- 282,
- 280,
- 278,
- 275,
- 273,
- 271,
- 269,
- 267,
- 265,
- 263,
- 261,
- 259
- ], hc = [
- 9,
- 11,
- 12,
- 13,
- 13,
- 14,
- 14,
- 15,
- 15,
- 15,
- 15,
- 16,
- 16,
- 16,
- 16,
- 17,
- 17,
- 17,
- 17,
- 17,
- 17,
- 17,
- 18,
- 18,
- 18,
- 18,
- 18,
- 18,
- 18,
- 18,
- 18,
- 19,
- 19,
- 19,
- 19,
- 19,
- 19,
- 19,
- 19,
- 19,
- 19,
- 19,
- 19,
- 19,
- 19,
- 20,
- 20,
- 20,
- 20,
- 20,
- 20,
- 20,
- 20,
- 20,
- 20,
- 20,
- 20,
- 20,
- 20,
- 20,
- 20,
- 20,
- 20,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 21,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 22,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 23,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24,
- 24
- ];
- function lc(s, t) {
- var e = s.data, i = s.width, n = s.height, r, a, o, h, l, A, u, f, c, d, p, m, v, _, g, y, x, b, C, w, E, S, P, k, F = t + t + 1, L = i - 1, I = n - 1, z = t + 1, T = z * (z + 1) / 2, G = new Ta(), H = null, R = G, N = null, q = null, et = oc[t], tt = hc[t];
- for (o = 1; o < F; o++)
- R = R.next = new Ta(), o === z && (H = R);
- for (R.next = G, u = A = 0, a = 0; a < n; a++) {
- for (y = x = b = C = f = c = d = p = 0, m = z * (w = e[A]), v = z * (E = e[A + 1]), _ = z * (S = e[A + 2]), g = z * (P = e[A + 3]), f += T * w, c += T * E, d += T * S, p += T * P, R = G, o = 0; o < z; o++)
- R.r = w, R.g = E, R.b = S, R.a = P, R = R.next;
- for (o = 1; o < z; o++)
- h = A + ((L < o ? L : o) << 2), f += (R.r = w = e[h]) * (k = z - o), c += (R.g = E = e[h + 1]) * k, d += (R.b = S = e[h + 2]) * k, p += (R.a = P = e[h + 3]) * k, y += w, x += E, b += S, C += P, R = R.next;
- for (N = G, q = H, r = 0; r < i; r++)
- e[A + 3] = P = p * et >> tt, P !== 0 ? (P = 255 / P, e[A] = (f * et >> tt) * P, e[A + 1] = (c * et >> tt) * P, e[A + 2] = (d * et >> tt) * P) : e[A] = e[A + 1] = e[A + 2] = 0, f -= m, c -= v, d -= _, p -= g, m -= N.r, v -= N.g, _ -= N.b, g -= N.a, h = u + ((h = r + t + 1) < L ? h : L) << 2, y += N.r = e[h], x += N.g = e[h + 1], b += N.b = e[h + 2], C += N.a = e[h + 3], f += y, c += x, d += b, p += C, N = N.next, m += w = q.r, v += E = q.g, _ += S = q.b, g += P = q.a, y -= w, x -= E, b -= S, C -= P, q = q.next, A += 4;
- u += i;
- }
- for (r = 0; r < i; r++) {
- for (x = b = C = y = c = d = p = f = 0, A = r << 2, m = z * (w = e[A]), v = z * (E = e[A + 1]), _ = z * (S = e[A + 2]), g = z * (P = e[A + 3]), f += T * w, c += T * E, d += T * S, p += T * P, R = G, o = 0; o < z; o++)
- R.r = w, R.g = E, R.b = S, R.a = P, R = R.next;
- for (l = i, o = 1; o <= t; o++)
- A = l + r << 2, f += (R.r = w = e[A]) * (k = z - o), c += (R.g = E = e[A + 1]) * k, d += (R.b = S = e[A + 2]) * k, p += (R.a = P = e[A + 3]) * k, y += w, x += E, b += S, C += P, R = R.next, o < I && (l += i);
- for (A = r, N = G, q = H, a = 0; a < n; a++)
- h = A << 2, e[h + 3] = P = p * et >> tt, P > 0 ? (P = 255 / P, e[h] = (f * et >> tt) * P, e[h + 1] = (c * et >> tt) * P, e[h + 2] = (d * et >> tt) * P) : e[h] = e[h + 1] = e[h + 2] = 0, f -= m, c -= v, d -= _, p -= g, m -= N.r, v -= N.g, _ -= N.b, g -= N.a, h = r + ((h = a + z) < I ? h : I) * i << 2, f += y += N.r = e[h], c += x += N.g = e[h + 1], d += b += N.b = e[h + 2], p += C += N.a = e[h + 3], N = N.next, m += w = q.r, v += E = q.g, _ += S = q.b, g += P = q.a, y -= w, x -= E, b -= S, C -= P, q = q.next, A += i;
- }
- }
- const Ac = function(t) {
- var e = Math.round(this.blurRadius());
- e > 0 && lc(t, e);
- };
- is.Blur = Ac;
- Ia.Factory.addGetterSetter(rc.Node, "blurRadius", 0, (0, ac.getNumberValidator)(), Ia.Factory.afterSetFilter);
- var ns = {};
- Object.defineProperty(ns, "__esModule", { value: !0 });
- ns.Brighten = void 0;
- const La = V, cc = rt, dc = O, uc = function(s) {
- var t = this.brightness() * 255, e = s.data, i = e.length, n;
- for (n = 0; n < i; n += 4)
- e[n] += t, e[n + 1] += t, e[n + 2] += t;
- };
- ns.Brighten = uc;
- La.Factory.addGetterSetter(cc.Node, "brightness", 0, (0, dc.getNumberValidator)(), La.Factory.afterSetFilter);
- var ss = {};
- Object.defineProperty(ss, "__esModule", { value: !0 });
- ss.Contrast = void 0;
- const Ra = V, fc = rt, gc = O, pc = function(s) {
- var t = Math.pow((this.contrast() + 100) / 100, 2), e = s.data, i = e.length, n = 150, r = 150, a = 150, o;
- for (o = 0; o < i; o += 4)
- n = e[o], r = e[o + 1], a = e[o + 2], n /= 255, n -= 0.5, n *= t, n += 0.5, n *= 255, r /= 255, r -= 0.5, r *= t, r += 0.5, r *= 255, a /= 255, a -= 0.5, a *= t, a += 0.5, a *= 255, n = n < 0 ? 0 : n > 255 ? 255 : n, r = r < 0 ? 0 : r > 255 ? 255 : r, a = a < 0 ? 0 : a > 255 ? 255 : a, e[o] = n, e[o + 1] = r, e[o + 2] = a;
- };
- ss.Contrast = pc;
- Ra.Factory.addGetterSetter(fc.Node, "contrast", 0, (0, gc.getNumberValidator)(), Ra.Factory.afterSetFilter);
- var rs = {};
- Object.defineProperty(rs, "__esModule", { value: !0 });
- rs.Emboss = void 0;
- const de = V, as = rt, yc = st, th = O, mc = function(s) {
- var t = this.embossStrength() * 10, e = this.embossWhiteLevel() * 255, i = this.embossDirection(), n = this.embossBlend(), r = 0, a = 0, o = s.data, h = s.width, l = s.height, A = h * 4, u = l;
- switch (i) {
- case "top-left":
- r = -1, a = -1;
- break;
- case "top":
- r = -1, a = 0;
- break;
- case "top-right":
- r = -1, a = 1;
- break;
- case "right":
- r = 0, a = 1;
- break;
- case "bottom-right":
- r = 1, a = 1;
- break;
- case "bottom":
- r = 1, a = 0;
- break;
- case "bottom-left":
- r = 1, a = -1;
- break;
- case "left":
- r = 0, a = -1;
- break;
- default:
- yc.Util.error("Unknown emboss direction: " + i);
- }
- do {
- var f = (u - 1) * A, c = r;
- u + c < 1 && (c = 0), u + c > l && (c = 0);
- var d = (u - 1 + c) * h * 4, p = h;
- do {
- var m = f + (p - 1) * 4, v = a;
- p + v < 1 && (v = 0), p + v > h && (v = 0);
- var _ = d + (p - 1 + v) * 4, g = o[m] - o[_], y = o[m + 1] - o[_ + 1], x = o[m + 2] - o[_ + 2], b = g, C = b > 0 ? b : -b, w = y > 0 ? y : -y, E = x > 0 ? x : -x;
- if (w > C && (b = y), E > C && (b = x), b *= t, n) {
- var S = o[m] + b, P = o[m + 1] + b, k = o[m + 2] + b;
- o[m] = S > 255 ? 255 : S < 0 ? 0 : S, o[m + 1] = P > 255 ? 255 : P < 0 ? 0 : P, o[m + 2] = k > 255 ? 255 : k < 0 ? 0 : k;
- } else {
- var F = e - b;
- F < 0 ? F = 0 : F > 255 && (F = 255), o[m] = o[m + 1] = o[m + 2] = F;
- }
- } while (--p);
- } while (--u);
- };
- rs.Emboss = mc;
- de.Factory.addGetterSetter(as.Node, "embossStrength", 0.5, (0, th.getNumberValidator)(), de.Factory.afterSetFilter);
- de.Factory.addGetterSetter(as.Node, "embossWhiteLevel", 0.5, (0, th.getNumberValidator)(), de.Factory.afterSetFilter);
- de.Factory.addGetterSetter(as.Node, "embossDirection", "top-left", null, de.Factory.afterSetFilter);
- de.Factory.addGetterSetter(as.Node, "embossBlend", !1, null, de.Factory.afterSetFilter);
- var os = {};
- Object.defineProperty(os, "__esModule", { value: !0 });
- os.Enhance = void 0;
- const Oa = V, vc = rt, _c = O;
- function Vs(s, t, e, i, n) {
- var r = e - t, a = n - i, o;
- return r === 0 ? i + a / 2 : a === 0 ? i : (o = (s - t) / r, o = a * o + i, o);
- }
- const xc = function(s) {
- var t = s.data, e = t.length, i = t[0], n = i, r, a = t[1], o = a, h, l = t[2], A = l, u, f, c = this.enhance();
- if (c !== 0) {
- for (f = 0; f < e; f += 4)
- r = t[f + 0], r < i ? i = r : r > n && (n = r), h = t[f + 1], h < a ? a = h : h > o && (o = h), u = t[f + 2], u < l ? l = u : u > A && (A = u);
- n === i && (n = 255, i = 0), o === a && (o = 255, a = 0), A === l && (A = 255, l = 0);
- var d, p, m, v, _, g, y, x, b;
- for (c > 0 ? (p = n + c * (255 - n), m = i - c * (i - 0), _ = o + c * (255 - o), g = a - c * (a - 0), x = A + c * (255 - A), b = l - c * (l - 0)) : (d = (n + i) * 0.5, p = n + c * (n - d), m = i + c * (i - d), v = (o + a) * 0.5, _ = o + c * (o - v), g = a + c * (a - v), y = (A + l) * 0.5, x = A + c * (A - y), b = l + c * (l - y)), f = 0; f < e; f += 4)
- t[f + 0] = Vs(t[f + 0], i, n, m, p), t[f + 1] = Vs(t[f + 1], a, o, g, _), t[f + 2] = Vs(t[f + 2], l, A, b, x);
- }
- };
- os.Enhance = xc;
- Oa.Factory.addGetterSetter(vc.Node, "enhance", 0, (0, _c.getNumberValidator)(), Oa.Factory.afterSetFilter);
- var hs = {};
- Object.defineProperty(hs, "__esModule", { value: !0 });
- hs.Grayscale = void 0;
- const bc = function(s) {
- var t = s.data, e = t.length, i, n;
- for (i = 0; i < e; i += 4)
- n = 0.34 * t[i] + 0.5 * t[i + 1] + 0.16 * t[i + 2], t[i] = n, t[i + 1] = n, t[i + 2] = n;
- };
- hs.Grayscale = bc;
- var ls = {};
- Object.defineProperty(ls, "__esModule", { value: !0 });
- ls.HSL = void 0;
- const ni = V, Er = rt, Fr = O;
- ni.Factory.addGetterSetter(Er.Node, "hue", 0, (0, Fr.getNumberValidator)(), ni.Factory.afterSetFilter);
- ni.Factory.addGetterSetter(Er.Node, "saturation", 0, (0, Fr.getNumberValidator)(), ni.Factory.afterSetFilter);
- ni.Factory.addGetterSetter(Er.Node, "luminance", 0, (0, Fr.getNumberValidator)(), ni.Factory.afterSetFilter);
- const wc = function(s) {
- var t = s.data, e = t.length, i = 1, n = Math.pow(2, this.saturation()), r = Math.abs(this.hue() + 360) % 360, a = this.luminance() * 127, o, h = i * n * Math.cos(r * Math.PI / 180), l = i * n * Math.sin(r * Math.PI / 180), A = 0.299 * i + 0.701 * h + 0.167 * l, u = 0.587 * i - 0.587 * h + 0.33 * l, f = 0.114 * i - 0.114 * h - 0.497 * l, c = 0.299 * i - 0.299 * h - 0.328 * l, d = 0.587 * i + 0.413 * h + 0.035 * l, p = 0.114 * i - 0.114 * h + 0.293 * l, m = 0.299 * i - 0.3 * h + 1.25 * l, v = 0.587 * i - 0.586 * h - 1.05 * l, _ = 0.114 * i + 0.886 * h - 0.2 * l, g, y, x, b;
- for (o = 0; o < e; o += 4)
- g = t[o + 0], y = t[o + 1], x = t[o + 2], b = t[o + 3], t[o + 0] = A * g + u * y + f * x + a, t[o + 1] = c * g + d * y + p * x + a, t[o + 2] = m * g + v * y + _ * x + a, t[o + 3] = b;
- };
- ls.HSL = wc;
- var As = {};
- Object.defineProperty(As, "__esModule", { value: !0 });
- As.HSV = void 0;
- const si = V, kr = rt, Dr = O, Sc = function(s) {
- var t = s.data, e = t.length, i = Math.pow(2, this.value()), n = Math.pow(2, this.saturation()), r = Math.abs(this.hue() + 360) % 360, a, o = i * n * Math.cos(r * Math.PI / 180), h = i * n * Math.sin(r * Math.PI / 180), l = 0.299 * i + 0.701 * o + 0.167 * h, A = 0.587 * i - 0.587 * o + 0.33 * h, u = 0.114 * i - 0.114 * o - 0.497 * h, f = 0.299 * i - 0.299 * o - 0.328 * h, c = 0.587 * i + 0.413 * o + 0.035 * h, d = 0.114 * i - 0.114 * o + 0.293 * h, p = 0.299 * i - 0.3 * o + 1.25 * h, m = 0.587 * i - 0.586 * o - 1.05 * h, v = 0.114 * i + 0.886 * o - 0.2 * h, _, g, y, x;
- for (a = 0; a < e; a += 4)
- _ = t[a + 0], g = t[a + 1], y = t[a + 2], x = t[a + 3], t[a + 0] = l * _ + A * g + u * y, t[a + 1] = f * _ + c * g + d * y, t[a + 2] = p * _ + m * g + v * y, t[a + 3] = x;
- };
- As.HSV = Sc;
- si.Factory.addGetterSetter(kr.Node, "hue", 0, (0, Dr.getNumberValidator)(), si.Factory.afterSetFilter);
- si.Factory.addGetterSetter(kr.Node, "saturation", 0, (0, Dr.getNumberValidator)(), si.Factory.afterSetFilter);
- si.Factory.addGetterSetter(kr.Node, "value", 0, (0, Dr.getNumberValidator)(), si.Factory.afterSetFilter);
- var cs = {};
- Object.defineProperty(cs, "__esModule", { value: !0 });
- cs.Invert = void 0;
- const Cc = function(s) {
- var t = s.data, e = t.length, i;
- for (i = 0; i < e; i += 4)
- t[i] = 255 - t[i], t[i + 1] = 255 - t[i + 1], t[i + 2] = 255 - t[i + 2];
- };
- cs.Invert = Cc;
- var ds = {};
- Object.defineProperty(ds, "__esModule", { value: !0 });
- ds.Kaleidoscope = void 0;
- const fn = V, eh = rt, Na = st, ih = O;
- var Mc = function(s, t, e) {
- var i = s.data, n = t.data, r = s.width, a = s.height, o = e.polarCenterX || r / 2, h = e.polarCenterY || a / 2, l, A, u, f = 0, c = 0, d = 0, p = 0, m, v = Math.sqrt(o * o + h * h);
- A = r - o, u = a - h, m = Math.sqrt(A * A + u * u), v = m > v ? m : v;
- var _ = a, g = r, y, x, b = 360 / g * Math.PI / 180, C, w;
- for (x = 0; x < g; x += 1)
- for (C = Math.sin(x * b), w = Math.cos(x * b), y = 0; y < _; y += 1)
- A = Math.floor(o + v * y / _ * w), u = Math.floor(h + v * y / _ * C), l = (u * r + A) * 4, f = i[l + 0], c = i[l + 1], d = i[l + 2], p = i[l + 3], l = (x + y * r) * 4, n[l + 0] = f, n[l + 1] = c, n[l + 2] = d, n[l + 3] = p;
- }, Pc = function(s, t, e) {
- var i = s.data, n = t.data, r = s.width, a = s.height, o = e.polarCenterX || r / 2, h = e.polarCenterY || a / 2, l, A, u, f, c, d = 0, p = 0, m = 0, v = 0, _, g = Math.sqrt(o * o + h * h);
- A = r - o, u = a - h, _ = Math.sqrt(A * A + u * u), g = _ > g ? _ : g;
- var y = a, x = r, b, C, w = 0, E, S;
- for (A = 0; A < r; A += 1)
- for (u = 0; u < a; u += 1)
- f = A - o, c = u - h, b = Math.sqrt(f * f + c * c) * y / g, C = (Math.atan2(c, f) * 180 / Math.PI + 360 + w) % 360, C = C * x / 360, E = Math.floor(C), S = Math.floor(b), l = (S * r + E) * 4, d = i[l + 0], p = i[l + 1], m = i[l + 2], v = i[l + 3], l = (u * r + A) * 4, n[l + 0] = d, n[l + 1] = p, n[l + 2] = m, n[l + 3] = v;
- };
- const Ec = function(s) {
- var t = s.width, e = s.height, i, n, r, a, o, h, l, A, u, f, c = Math.round(this.kaleidoscopePower()), d = Math.round(this.kaleidoscopeAngle()), p = Math.floor(t * (d % 360) / 360);
- if (!(c < 1)) {
- var m = Na.Util.createCanvasElement();
- m.width = t, m.height = e;
- var v = m.getContext("2d").getImageData(0, 0, t, e);
- Na.Util.releaseCanvas(m), Mc(s, v, {
- polarCenterX: t / 2,
- polarCenterY: e / 2
- });
- for (var _ = t / Math.pow(2, c); _ <= 8; )
- _ = _ * 2, c -= 1;
- _ = Math.ceil(_);
- var g = _, y = 0, x = g, b = 1;
- for (p + _ > t && (y = g, x = 0, b = -1), n = 0; n < e; n += 1)
- for (i = y; i !== x; i += b)
- r = Math.round(i + p) % t, u = (t * n + r) * 4, o = v.data[u + 0], h = v.data[u + 1], l = v.data[u + 2], A = v.data[u + 3], f = (t * n + i) * 4, v.data[f + 0] = o, v.data[f + 1] = h, v.data[f + 2] = l, v.data[f + 3] = A;
- for (n = 0; n < e; n += 1)
- for (g = Math.floor(_), a = 0; a < c; a += 1) {
- for (i = 0; i < g + 1; i += 1)
- u = (t * n + i) * 4, o = v.data[u + 0], h = v.data[u + 1], l = v.data[u + 2], A = v.data[u + 3], f = (t * n + g * 2 - i - 1) * 4, v.data[f + 0] = o, v.data[f + 1] = h, v.data[f + 2] = l, v.data[f + 3] = A;
- g *= 2;
- }
- Pc(v, s, { polarRotation: 0 });
- }
- };
- ds.Kaleidoscope = Ec;
- fn.Factory.addGetterSetter(eh.Node, "kaleidoscopePower", 2, (0, ih.getNumberValidator)(), fn.Factory.afterSetFilter);
- fn.Factory.addGetterSetter(eh.Node, "kaleidoscopeAngle", 0, (0, ih.getNumberValidator)(), fn.Factory.afterSetFilter);
- var us = {};
- Object.defineProperty(us, "__esModule", { value: !0 });
- us.Mask = void 0;
- const Ga = V, Fc = rt, kc = O;
- function sn(s, t, e) {
- var i = (e * s.width + t) * 4, n = [];
- return n.push(s.data[i++], s.data[i++], s.data[i++], s.data[i++]), n;
- }
- function bi(s, t) {
- return Math.sqrt(Math.pow(s[0] - t[0], 2) + Math.pow(s[1] - t[1], 2) + Math.pow(s[2] - t[2], 2));
- }
- function Dc(s) {
- for (var t = [0, 0, 0], e = 0; e < s.length; e++)
- t[0] += s[e][0], t[1] += s[e][1], t[2] += s[e][2];
- return t[0] /= s.length, t[1] /= s.length, t[2] /= s.length, t;
- }
- function Ic(s, t) {
- var e = sn(s, 0, 0), i = sn(s, s.width - 1, 0), n = sn(s, 0, s.height - 1), r = sn(s, s.width - 1, s.height - 1), a = t || 10;
- if (bi(e, i) < a && bi(i, r) < a && bi(r, n) < a && bi(n, e) < a) {
- for (var o = Dc([i, e, r, n]), h = [], l = 0; l < s.width * s.height; l++) {
- var A = bi(o, [
- s.data[l * 4],
- s.data[l * 4 + 1],
- s.data[l * 4 + 2]
- ]);
- h[l] = A < a ? 0 : 255;
- }
- return h;
- }
- }
- function Tc(s, t) {
- for (var e = 0; e < s.width * s.height; e++)
- s.data[4 * e + 3] = t[e];
- }
- function Lc(s, t, e) {
- for (var i = [1, 1, 1, 1, 0, 1, 1, 1, 1], n = Math.round(Math.sqrt(i.length)), r = Math.floor(n / 2), a = [], o = 0; o < e; o++)
- for (var h = 0; h < t; h++) {
- for (var l = o * t + h, A = 0, u = 0; u < n; u++)
- for (var f = 0; f < n; f++) {
- var c = o + u - r, d = h + f - r;
- if (c >= 0 && c < e && d >= 0 && d < t) {
- var p = c * t + d, m = i[u * n + f];
- A += s[p] * m;
- }
- }
- a[l] = A === 255 * 8 ? 255 : 0;
- }
- return a;
- }
- function Rc(s, t, e) {
- for (var i = [1, 1, 1, 1, 1, 1, 1, 1, 1], n = Math.round(Math.sqrt(i.length)), r = Math.floor(n / 2), a = [], o = 0; o < e; o++)
- for (var h = 0; h < t; h++) {
- for (var l = o * t + h, A = 0, u = 0; u < n; u++)
- for (var f = 0; f < n; f++) {
- var c = o + u - r, d = h + f - r;
- if (c >= 0 && c < e && d >= 0 && d < t) {
- var p = c * t + d, m = i[u * n + f];
- A += s[p] * m;
- }
- }
- a[l] = A >= 255 * 4 ? 255 : 0;
- }
- return a;
- }
- function Oc(s, t, e) {
- for (var i = [0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111], n = Math.round(Math.sqrt(i.length)), r = Math.floor(n / 2), a = [], o = 0; o < e; o++)
- for (var h = 0; h < t; h++) {
- for (var l = o * t + h, A = 0, u = 0; u < n; u++)
- for (var f = 0; f < n; f++) {
- var c = o + u - r, d = h + f - r;
- if (c >= 0 && c < e && d >= 0 && d < t) {
- var p = c * t + d, m = i[u * n + f];
- A += s[p] * m;
- }
- }
- a[l] = A;
- }
- return a;
- }
- const Nc = function(s) {
- var t = this.threshold(), e = Ic(s, t);
- return e && (e = Lc(e, s.width, s.height), e = Rc(e, s.width, s.height), e = Oc(e, s.width, s.height), Tc(s, e)), s;
- };
- us.Mask = Nc;
- Ga.Factory.addGetterSetter(Fc.Node, "threshold", 0, (0, kc.getNumberValidator)(), Ga.Factory.afterSetFilter);
- var fs = {};
- Object.defineProperty(fs, "__esModule", { value: !0 });
- fs.Noise = void 0;
- const Ba = V, Gc = rt, Bc = O, zc = function(s) {
- var t = this.noise() * 255, e = s.data, i = e.length, n = t / 2, r;
- for (r = 0; r < i; r += 4)
- e[r + 0] += n - 2 * n * Math.random(), e[r + 1] += n - 2 * n * Math.random(), e[r + 2] += n - 2 * n * Math.random();
- };
- fs.Noise = zc;
- Ba.Factory.addGetterSetter(Gc.Node, "noise", 0.2, (0, Bc.getNumberValidator)(), Ba.Factory.afterSetFilter);
- var gs = {};
- Object.defineProperty(gs, "__esModule", { value: !0 });
- gs.Pixelate = void 0;
- const za = V, Uc = st, Hc = rt, Vc = O, $c = function(s) {
- var t = Math.ceil(this.pixelSize()), e = s.width, i = s.height, n, r, a, o, h, l, A, u = Math.ceil(e / t), f = Math.ceil(i / t), c, d, p, m, v, _, g, y = s.data;
- if (t <= 0) {
- Uc.Util.error("pixelSize value can not be <= 0");
- return;
- }
- for (v = 0; v < u; v += 1)
- for (_ = 0; _ < f; _ += 1) {
- for (o = 0, h = 0, l = 0, A = 0, c = v * t, d = c + t, p = _ * t, m = p + t, g = 0, n = c; n < d; n += 1)
- if (!(n >= e))
- for (r = p; r < m; r += 1)
- r >= i || (a = (e * r + n) * 4, o += y[a + 0], h += y[a + 1], l += y[a + 2], A += y[a + 3], g += 1);
- for (o = o / g, h = h / g, l = l / g, A = A / g, n = c; n < d; n += 1)
- if (!(n >= e))
- for (r = p; r < m; r += 1)
- r >= i || (a = (e * r + n) * 4, y[a + 0] = o, y[a + 1] = h, y[a + 2] = l, y[a + 3] = A);
- }
- };
- gs.Pixelate = $c;
- za.Factory.addGetterSetter(Hc.Node, "pixelSize", 8, (0, Vc.getNumberValidator)(), za.Factory.afterSetFilter);
- var ps = {};
- Object.defineProperty(ps, "__esModule", { value: !0 });
- ps.Posterize = void 0;
- const Ua = V, Wc = rt, Yc = O, Xc = function(s) {
- var t = Math.round(this.levels() * 254) + 1, e = s.data, i = e.length, n = 255 / t, r;
- for (r = 0; r < i; r += 1)
- e[r] = Math.floor(e[r] / n) * n;
- };
- ps.Posterize = Xc;
- Ua.Factory.addGetterSetter(Wc.Node, "levels", 0.5, (0, Yc.getNumberValidator)(), Ua.Factory.afterSetFilter);
- var ys = {};
- Object.defineProperty(ys, "__esModule", { value: !0 });
- ys.RGB = void 0;
- const gn = V, Ir = rt, jc = O, qc = function(s) {
- var t = s.data, e = t.length, i = this.red(), n = this.green(), r = this.blue(), a, o;
- for (a = 0; a < e; a += 4)
- o = (0.34 * t[a] + 0.5 * t[a + 1] + 0.16 * t[a + 2]) / 255, t[a] = o * i, t[a + 1] = o * n, t[a + 2] = o * r, t[a + 3] = t[a + 3];
- };
- ys.RGB = qc;
- gn.Factory.addGetterSetter(Ir.Node, "red", 0, function(s) {
- return this._filterUpToDate = !1, s > 255 ? 255 : s < 0 ? 0 : Math.round(s);
- });
- gn.Factory.addGetterSetter(Ir.Node, "green", 0, function(s) {
- return this._filterUpToDate = !1, s > 255 ? 255 : s < 0 ? 0 : Math.round(s);
- });
- gn.Factory.addGetterSetter(Ir.Node, "blue", 0, jc.RGBComponent, gn.Factory.afterSetFilter);
- var ms = {};
- Object.defineProperty(ms, "__esModule", { value: !0 });
- ms.RGBA = void 0;
- const Ti = V, vs = rt, Qc = O, Kc = function(s) {
- var t = s.data, e = t.length, i = this.red(), n = this.green(), r = this.blue(), a = this.alpha(), o, h;
- for (o = 0; o < e; o += 4)
- h = 1 - a, t[o] = i * a + t[o] * h, t[o + 1] = n * a + t[o + 1] * h, t[o + 2] = r * a + t[o + 2] * h;
- };
- ms.RGBA = Kc;
- Ti.Factory.addGetterSetter(vs.Node, "red", 0, function(s) {
- return this._filterUpToDate = !1, s > 255 ? 255 : s < 0 ? 0 : Math.round(s);
- });
- Ti.Factory.addGetterSetter(vs.Node, "green", 0, function(s) {
- return this._filterUpToDate = !1, s > 255 ? 255 : s < 0 ? 0 : Math.round(s);
- });
- Ti.Factory.addGetterSetter(vs.Node, "blue", 0, Qc.RGBComponent, Ti.Factory.afterSetFilter);
- Ti.Factory.addGetterSetter(vs.Node, "alpha", 1, function(s) {
- return this._filterUpToDate = !1, s > 1 ? 1 : s < 0 ? 0 : s;
- });
- var _s = {};
- Object.defineProperty(_s, "__esModule", { value: !0 });
- _s.Sepia = void 0;
- const Zc = function(s) {
- var t = s.data, e = t.length, i, n, r, a;
- for (i = 0; i < e; i += 4)
- n = t[i + 0], r = t[i + 1], a = t[i + 2], t[i + 0] = Math.min(255, n * 0.393 + r * 0.769 + a * 0.189), t[i + 1] = Math.min(255, n * 0.349 + r * 0.686 + a * 0.168), t[i + 2] = Math.min(255, n * 0.272 + r * 0.534 + a * 0.131);
- };
- _s.Sepia = Zc;
- var xs = {};
- Object.defineProperty(xs, "__esModule", { value: !0 });
- xs.Solarize = void 0;
- const Jc = function(s) {
- var t = s.data, e = s.width, i = s.height, n = e * 4, r = i;
- do {
- var a = (r - 1) * n, o = e;
- do {
- var h = a + (o - 1) * 4, l = t[h], A = t[h + 1], u = t[h + 2];
- l > 127 && (l = 255 - l), A > 127 && (A = 255 - A), u > 127 && (u = 255 - u), t[h] = l, t[h + 1] = A, t[h + 2] = u;
- } while (--o);
- } while (--r);
- };
- xs.Solarize = Jc;
- var bs = {};
- Object.defineProperty(bs, "__esModule", { value: !0 });
- bs.Threshold = void 0;
- const Ha = V, td = rt, ed = O, id = function(s) {
- var t = this.threshold() * 255, e = s.data, i = e.length, n;
- for (n = 0; n < i; n += 1)
- e[n] = e[n] < t ? 0 : 255;
- };
- bs.Threshold = id;
- Ha.Factory.addGetterSetter(td.Node, "threshold", 0.5, (0, ed.getNumberValidator)(), Ha.Factory.afterSetFilter);
- Object.defineProperty(Gn, "__esModule", { value: !0 });
- Gn.Konva = void 0;
- const Va = Po, nd = zn, sd = Vn, rd = Cn, ad = Wn, od = Yn, $a = ii, hd = Gi, ld = hi, Ad = Bi, cd = jn, dd = qn, ud = Qn, fd = Kn, gd = Me, pd = Zn, yd = Jn, md = ts, vd = is, _d = ns, xd = ss, bd = rs, wd = os, Sd = hs, Cd = ls, Md = As, Pd = cs, Ed = ds, Fd = us, kd = fs, Dd = gs, Id = ps, Td = ys, Ld = ms, Rd = _s, Od = xs, Nd = bs;
- Gn.Konva = Va.Konva.Util._assign(Va.Konva, {
- Arc: nd.Arc,
- Arrow: sd.Arrow,
- Circle: rd.Circle,
- Ellipse: ad.Ellipse,
- Image: od.Image,
- Label: $a.Label,
- Tag: $a.Tag,
- Line: hd.Line,
- Path: ld.Path,
- Rect: Ad.Rect,
- RegularPolygon: cd.RegularPolygon,
- Ring: dd.Ring,
- Sprite: ud.Sprite,
- Star: fd.Star,
- Text: gd.Text,
- TextPath: pd.TextPath,
- Transformer: yd.Transformer,
- Wedge: md.Wedge,
- Filters: {
- Blur: vd.Blur,
- Brighten: _d.Brighten,
- Contrast: xd.Contrast,
- Emboss: bd.Emboss,
- Enhance: wd.Enhance,
- Grayscale: Sd.Grayscale,
- HSL: Cd.HSL,
- HSV: Md.HSV,
- Invert: Pd.Invert,
- Kaleidoscope: Ed.Kaleidoscope,
- Mask: Fd.Mask,
- Noise: kd.Noise,
- Pixelate: Dd.Pixelate,
- Posterize: Id.Posterize,
- RGB: Td.RGB,
- RGBA: Ld.RGBA,
- Sepia: Rd.Sepia,
- Solarize: Od.Solarize,
- Threshold: Nd.Threshold
- }
- });
- var Gd = vr.exports;
- Object.defineProperty(Gd, "__esModule", { value: !0 });
- const Bd = Gn;
- vr.exports = Bd.Konva;
- var zd = vr.exports;
- const Yt = /* @__PURE__ */ vh(zd);
- function Tr(s) {
- return { all: s = s || /* @__PURE__ */ new Map(), on: function(t, e) {
- var i = s.get(t);
- i ? i.push(e) : s.set(t, [e]);
- }, off: function(t, e) {
- var i = s.get(t);
- i && (e ? i.splice(i.indexOf(e) >>> 0, 1) : s.set(t, []));
- }, emit: function(t, e) {
- var i = s.get(t);
- i && i.slice().map(function(n) {
- n(e);
- }), (i = s.get("*")) && i.slice().map(function(n) {
- n(t, e);
- });
- } };
- }
- class ie {
- constructor(t) {
- this.bus = Tr(), this.children = [], this.flush = "pre", this.isMounted = !1, this.name = t.name, this.teleport = t.teleport, this.props = t, this.attrib = t.reactive ? ti(t.attrib) : t.attrib, this.zIndex = t.zIndex || 0;
- }
- getShape() {
- return this.shape;
- }
- redraw() {
- this.diffRedraw(), this.children.forEach((t) => t.redraw());
- }
- setAttrib(t) {
- "id" in t && t.id !== this.attrib.id && (console.log(t, this.attrib, t.id, this.attrib.id), console.error("id 确定后无法更改")), t.id = this.attrib.id, this.props.reactive ? Rr(t) !== Rr(this.attrib) && (this.attrib = this.props.reactive ? ti(t) : t, this.bus.emit("updateAttrib"), this.initReactive()) : (this.attrib = t, this.diffRedraw());
- }
- initReactive(t = this.flush) {
- this.destoryReactive && this.destoryReactive();
- let e = !1;
- const i = Sn(
- () => {
- e || this.diffRedraw();
- },
- { flush: t }
- );
- return this.flush = t, () => {
- e = !0, i();
- };
- }
- init() {
- this.shape = this.initShape(), this.shape.id(this.name), this.bus.emit("created");
- }
- mount(t) {
- if (this.shape instanceof Ii.Stage)
- throw "stage 为顶级容器无法挂载";
- if (t && this.shape instanceof _r && !(t instanceof Ii.Stage))
- throw console.log(this.name, t), "layer 只能挂载到 Stage";
- if (this.teleport && this.teleport === t)
- return;
- this.children.sort((i, n) => i.zIndex - n.zIndex);
- const e = t || this.parent.shape;
- if (e.add(this.shape), this.teleport = e, this.setZIndex(this.zIndex), this.props.reactive && (this.destoryReactive = this.initReactive()), qt) {
- let i = { ...this.attrib };
- fe(
- () => this.attrib.id,
- (n, r) => {
- n !== r && console.error("changeId", i, this.attrib, n, r);
- },
- { flush: "sync" }
- );
- }
- }
- mounted() {
- this.diffRedraw(), this.children.forEach((t) => t.mounted()), this.isMounted = !0, this.bus.emit("mounted");
- }
- setParent(t) {
- if (this.parent) {
- const e = this.parent.children.indexOf(this);
- ~e && this.parent.children.splice(e, 1);
- }
- this.parent = t, t && this.parent.children.push(this);
- }
- getLevelNdx(t = this.parent) {
- if (t) {
- const e = t.children;
- for (let i = e.length - 1; i >= 0; i--)
- if (e[i] !== this && e[i].zIndex <= this.zIndex)
- return i;
- return -1;
- }
- return null;
- }
- setZIndex(t) {
- this.zIndex = t;
- const e = this.getLevelNdx();
- if (e === null)
- return;
- const i = this.parent.children;
- if (i.indexOf(this) !== e + 1) {
- let l = this;
- for (let A = e + 1; A < i.length; A++) {
- const u = i[A];
- i[A] = l, l = u;
- }
- }
- const r = this.teleport, a = r.children, o = e === -1 ? 0 : a.indexOf(i[e].getShape()) + 1;
- if (a.indexOf(this.shape) !== o)
- if (o !== 0) {
- let l = this.shape;
- for (let A = o; A < a.length; A++) {
- const u = a[A];
- r.add(l), l.zIndex(A), l = u;
- }
- } else
- this.shape.zIndex(0);
- }
- enableDrag(t) {
- this.disableDrag(), this.dragDestory = yr(this.shape, t);
- }
- disableDrag() {
- this.dragDestory && this.dragDestory(), this.dragDestory = null;
- }
- enableActive(t) {
- this.disableActive(), this.activeDestory = ma(
- this.shape,
- {
- active: () => t(!0),
- bus: this.bus,
- common: () => t(!1)
- },
- "mouse-active"
- );
- }
- disableActive() {
- this.activeDestory && this.activeDestory(), this.activeDestory = null;
- }
- enableMouseAct(t) {
- this.disableMouseAct(), this.mouseActDestory = ma(
- this.shape,
- { ...t, bus: this.bus },
- "act-mouse"
- );
- }
- disableMouseAct() {
- this.mouseActDestory && this.mouseActDestory(), this.mouseActDestory = null;
- }
- visible(t) {
- this.shape.visible(t);
- }
- destory() {
- for (; this.children.length; )
- this.children[0].destory();
- if (this.setParent(null), this.destoryReactive && this.destoryReactive(), this.disableDrag(), this.disableActive(), this.disableMouseAct(), qt && console.log(this.name, "destory"), this.shape instanceof Yt.Group ? this.shape.destroyChildren() : this.shape.destroy(), this.parent) {
- const t = this.parent.children.indexOf(this);
- ~t && this.parent.children.splice(t, 1);
- }
- this.bus.emit("destroyed"), this.bus.off("*");
- }
- find(t) {
- for (const e of this.children) {
- if (e.name === t)
- return e;
- const i = e.find(t);
- if (i)
- return i;
- }
- return null;
- }
- }
- const yn = class yn extends ie {
- constructor(t) {
- t.zIndex = t.zIndex || 4, t.name = t.name || yn.namespace + t.attrib.id, super(t);
- }
- setConfig(t) {
- this.config = t;
- }
- initShape() {
- const t = new Yt.Label({
- opacity: 0.75,
- name: "label",
- listening: !1
- });
- t.add(
- new Yt.Tag({
- name: "tag",
- fill: "rgba(0, 0, 0, 0.8)",
- pointerDirection: "down",
- pointerWidth: 5,
- pointerHeight: 5,
- lineJoin: "round",
- shadowColor: "black",
- shadowBlur: 10,
- shadowOffsetX: 10,
- shadowOffsetY: 10,
- shadowOpacity: 0.5,
- listening: !1
- }),
- new Yt.Text({
- name: "text",
- text: "text",
- fontFamily: "Calibri",
- fontSize: 10,
- padding: 3,
- fill: "white",
- listening: !1
- })
- );
- const e = 8, i = new Nt({ name: "offset" });
- return i.add(t).add(
- new Yt.Arrow({
- name: "arrow-1",
- visible: !1,
- points: [0, 0],
- pointerLength: e,
- pointerWidth: e,
- fill: "black",
- stroke: "black",
- strokeWidth: 4,
- listening: !1
- }),
- new Yt.Arrow({
- name: "arrow-2",
- visible: !1,
- points: [0, 0],
- pointerLength: e,
- pointerWidth: e,
- fill: "black",
- stroke: "black",
- strokeWidth: 4,
- listening: !1
- })
- ), i;
- }
- diffRedraw() {
- const t = this.attrib.pointIds.map(
- (o) => this.config.points.find((h) => h.id === o)
- );
- if (t.some((o) => !o))
- return null;
- let e = !1;
- const i = [];
- for (const o of this.config.polygons)
- for (const h of o.lineIds) {
- const l = this.config.lines.find(({ id: A }) => A === h);
- l.pointIds.includes(this.attrib.pointIds[0]) && l.pointIds.includes(this.attrib.pointIds[1]) && (i.push(`${l.id} [${l.pointIds.join(",")}]`), e = e || l.pointIds[0] === this.attrib.pointIds[1]);
- }
- const n = [];
- t.forEach(({ x: o, y: h }, l) => {
- n[l * 2] = o, n[l * 2 + 1] = h;
- });
- let r = Gt(
- this.shape.findOne(".label"),
- [1, 1]
- );
- const a = Se.radToDeg(LA(n, [0, 1]));
- this.shape.findOne(".label").x((n[0] + n[2]) / 2).y((n[1] + n[3]) / 2).scale({ x: r[0], y: r[1] }).rotation(a < 0 ? a + 90 : a - 90), this.shape.findOne(".arrow-1").x(n[2]).y(n[3]).scale({ x: r[0], y: r[1] }).rotation(a + 90).visible(!0), e ? this.shape.findOne(".arrow-2").x(n[0]).y(n[1]).rotation(a - 90).scale({ x: r[0], y: r[1] }).visible(!0) : this.shape.findOne(".arrow-2").visible(!1), this.shape.findOne(".text").text(i.join(" | "));
- }
- };
- yn.namespace = "line-helper";
- let ar = yn;
- const mn = class mn extends ie {
- constructor(t) {
- t.zIndex = t.zIndex || 5, t.name = t.name || mn.namespace + t.attrib.id, super(t);
- }
- initShape() {
- const t = new Yt.Label({ opacity: 0.75, name: "label" });
- return t.add(
- new Yt.Tag({
- name: "tag",
- fill: "rgba(0, 0, 0, 0.8)",
- pointerDirection: "down",
- pointerWidth: 5,
- pointerHeight: 5,
- lineJoin: "round",
- shadowColor: "black",
- shadowBlur: 10,
- shadowOffsetX: 10,
- shadowOffsetY: 10,
- shadowOpacity: 0.5
- }),
- new Yt.Text({
- name: "text",
- text: `P${this.attrib.id}`,
- fontFamily: "Calibri",
- fontSize: 10,
- padding: 3,
- fill: "white"
- })
- ), t;
- }
- diffRedraw() {
- this.shape.x(this.attrib.x).y(this.attrib.y);
- const t = Gt(this.shape, [1, 1]);
- this.shape.scale({ x: t[0], y: t[0] });
- }
- };
- mn.namespace = "point-helper";
- let or = mn;
- const vn = class vn extends ie {
- constructor(t) {
- t.zIndex = t.zIndex || Mt.zIndex, t.name = t.name || vn.namespace + t.attrib.id, super(t), this.actShapeFactory = On;
- }
- setActShapeFactory(t) {
- this.actShapeFactory = t;
- }
- initShape() {
- return this.actShape = this.actShapeFactory(this.attrib, this), this.actShape.shape;
- }
- diffRedraw() {
- this.actShape.setData([this.attrib.x, this.attrib.y]);
- }
- mounted() {
- super.mounted(), this.actShape.common(null);
- }
- };
- vn.namespace = "point";
- let Tt = vn, ws = 0;
- const Ud = (s) => ws = s, nh = (s) => (Math.max(1, ws, ...s.lines.map(({ id: t }) => Number(t))) + 1).toString(), sh = (s) => (Math.max(1, ws, ...s.points.map(({ id: t }) => Number(t))) + 1).toString(), rh = (s, t = []) => (Math.max(
- 1,
- ws,
- ...s.polygons.map(({ id: e }) => Number(e)),
- ...t.map(Number)
- ) + 1).toString(), Pe = (s, t) => s.points.find((e) => e.id === t), _t = (s, t) => t ? t.map((e) => Pe(s, e)) : s.points, ah = (s, t) => s.lines.filter(({ pointIds: e }) => e.includes(t)), Hd = (s, t, e = !1) => s.lines.filter(({ pointIds: i }) => {
- let n = i.includes(t[0]) && i.includes(t[1]);
- return n || (e && (n = i.includes(t[1]) && i.includes(t[0])), n);
- }), Vd = (s, t) => ah(s, t.id), wt = (s, t) => s.lines.find(({ id: e }) => e === t), oh = (s, t) => t.map((e) => wt(s, e)), pi = (s, t) => _t(s, wt(s, t).pointIds), c1 = (s) => s.lines.map((t) => _t(s, t.pointIds)), yi = (s, t) => s.polygons.find((e) => e.id === t), $d = (s, t) => yi(s, t).lineIds.map(
- (e) => pi(s, e)
- ), hh = (s, t) => {
- const e = yi(s, t);
- return e ? e.lineIds.map(
- (i) => wt(s, i)
- ) : [];
- }, d1 = (s, t) => s.lines.filter(({ pointIds: e }) => e.includes(t)).map((e) => pi(s, e.id)), lh = (s, t) => {
- const e = [];
- for (const i of s.polygons) {
- const n = i.lineIds.filter(
- (r) => wt(s, r).pointIds.includes(t)
- ).map((r) => pi(s, r));
- n.length && e.push({
- polygonId: i.id,
- lines: n
- });
- }
- return e;
- }, u1 = (s, t) => s.polygons.filter((e) => e.lineIds.some(
- (i) => wt(s, i).pointIds.includes(t)
- )), ri = (s, t) => {
- const e = yi(s, t);
- if (!e)
- return [];
- const { lineIds: i } = e, n = [];
- for (let r = 0; r < i.length; r++) {
- const a = wt(s, i[r]);
- n.push(Pe(s, a.pointIds[0])), r === i.length - 1 && n.push(Pe(s, a.pointIds[1]));
- }
- return n;
- }, Si = (...s) => {
- const t = {};
- for (const e of s)
- for (const i in e)
- if (!t[i])
- t[i] = Object.fromEntries(
- Object.entries(e[i]).map(([n, r]) => [
- n,
- [...r]
- ])
- );
- else
- for (const n in e[i]) {
- if (!t[i][n]) {
- t[i][n] = [...e[i][n]];
- break;
- }
- const r = e[i][n], a = t[i][n];
- for (const o of r)
- a.every(({ id: h }) => h !== o.id) && a.push(o);
- }
- return t;
- }, Ah = (s, t) => s.lines.findIndex(
- ({ pointIds: e }) => e[0] === t[0] && e[1] === t[1]
- ), ue = (s, t) => {
- const e = {
- lineChange: { add: [] }
- };
- let i = Ah(s, t);
- return ~i || (i = s.lines.push({
- id: nh(s),
- pointIds: [...t]
- }) - 1, e.lineChange.add.push(s.lines[i])), { line: s.lines[i], change: e };
- }, ai = (s, t, e = !0) => {
- const i = {
- lineChange: { del: [] },
- pointChange: { del: [] }
- }, n = Ah(s, t), r = s.lines[n];
- return ~n ? (s.polygons.every(
- ({ lineIds: o }) => !o.includes(r.id)
- ) && (s.lines.splice(n, 1), i.lineChange.del.push(r)), e && t.forEach((o) => {
- const h = s.points.findIndex(({ id: l }) => l === o);
- ~h && s.lines.every(({ pointIds: l }) => !l.includes(o)) && (i.pointChange.del.push(s.points[h]), s.points.splice(h, 1));
- }), { line: r, change: i }) : { change: i };
- }, ch = (s, t) => {
- const e = s.polygons.findIndex(({ id: i }) => t === i);
- if (~e) {
- const i = s.polygons[e];
- s.polygons.splice(e, 1), i.lineIds.map(
- (r) => wt(s, r)
- ).forEach((r) => {
- ai(s, r.pointIds);
- });
- }
- }, Wa = (s, t, e = !0) => {
- t = Array.isArray(t) ? t : [t];
- const i = {
- lineChange: {
- del: [],
- add: []
- },
- polygonChange: {
- update: [],
- del: []
- },
- pointChange: {
- del: []
- }
- };
- let n = 100;
- for (let r = 0; r < s.polygons.length; r++) {
- const a = s.polygons[r], o = a.lineIds;
- let h = o.length, l;
- for (let A = 0; A < h; A++) {
- const u = oh(s, o), f = u[A], c = t.includes(f.pointIds[0]), d = t.includes(f.pointIds[1]);
- if (!(c || d))
- continue;
- l = l || [...o];
- let p = A, m = null;
- if (d) {
- let v = A + 1;
- for (v; v < u.length; v++) {
- const _ = u[v].pointIds[1];
- if (!t.includes(_) && _ !== f.pointIds[0])
- break;
- }
- if (v !== u.length) {
- const _ = ue(s, [
- f.pointIds[0],
- u[v].pointIds[1]
- ]);
- i.lineChange.add.push(..._.change.lineChange.add), o[A] = _.line.id, m = _.line.id;
- }
- }
- if (~p) {
- const v = u[A].pointIds;
- m ? o.splice(A, 1, m) : (o.splice(A, 1), u.splice(A, 1), h--, A--);
- const _ = ai(
- s,
- v,
- e
- );
- if (i.lineChange.del.push(..._.change.lineChange.del), i.pointChange.del.push(..._.change.pointChange.del), n-- < 0)
- break;
- }
- }
- if (l) {
- const A = { ...a, lineIds: l };
- a.lineIds.length === 0 ? (s.polygons.splice(r--, 1), i.polygonChange.del.push(A)) : i.polygonChange.update.push({
- before: A,
- after: a
- });
- }
- }
- return e && t.forEach((r) => {
- if (!i.pointChange.del.some(({ id: a }) => a === r)) {
- const a = s.points.findIndex(({ id: o }) => o === r);
- ~a && (i.pointChange.del.push(s.points[a]), s.points.splice(a, 1));
- }
- }), i;
- }, hr = (s, t, e) => {
- const i = {
- lineChange: {
- del: [],
- add: []
- },
- polygonChange: {
- update: []
- },
- pointChange: {
- add: [],
- del: []
- }
- };
- let n = null;
- const r = t.map((a) => a.id);
- if (r.includes(e))
- return { addedPoints: n, change: i };
- for (const a of s.polygons) {
- let o;
- for (let h = 0; h < a.lineIds.length; h++) {
- const l = wt(s, a.lineIds[h]);
- if (r.includes(l.pointIds[0]) && r.includes(l.pointIds[1])) {
- o = o || [...a.lineIds], n = n || [
- l.pointIds[0],
- e,
- l.pointIds[1]
- ];
- const A = ue(s, [
- l.pointIds[0],
- e
- ]), u = ue(s, [
- e,
- l.pointIds[1]
- ]);
- i.lineChange.add.push(
- ...A.change.lineChange.add,
- ...u.change.lineChange.add
- ), a.lineIds.splice(h, 1, A.line.id, u.line.id);
- const f = ai(s, l.pointIds);
- i.lineChange.del.push(...f.change.lineChange.del), i.pointChange.del.push(...f.change.pointChange.del);
- }
- }
- o && i.polygonChange.update.push({
- before: { ...a, lineIds: o },
- after: a
- });
- }
- return { addedPoints: n, change: i };
- }, lr = (s, t, e) => {
- const i = {
- pointChange: {
- del: []
- },
- lineChange: {
- del: [],
- add: [],
- update: []
- },
- polygonChange: {
- del: [],
- update: []
- }
- }, n = [];
- for (let r = 0; r < s.polygons.length; r++) {
- const a = s.polygons[r];
- let o;
- for (const h of t) {
- if (h === e)
- break;
- for (let l = 0; l < a.lineIds.length; l++) {
- const A = wt(s, a.lineIds[l]);
- let u = A.pointIds.indexOf(h);
- if (!~u)
- continue;
- o = o || [...a.lineIds];
- const f = [...A.pointIds];
- if (f[u] = e, f[0] === f[1])
- a.lineIds.splice(l, 1);
- else {
- const c = ue(s, f);
- a.lineIds[l] = c.line.id, i.lineChange.del.push(...c.change.lineChange.add);
- }
- n.push(A.pointIds), l--;
- }
- if (o) {
- const l = { ...a, lineIds: o };
- a.lineIds.length === 0 ? (i.polygonChange.del.push(l), s.polygons.splice(r--, 1), console.log("del polygon")) : i.polygonChange.update.push({
- before: l,
- after: a
- });
- }
- }
- }
- return n.forEach((r) => {
- const a = ai(s, r);
- i.lineChange.del.push(...a.change.lineChange.del), i.pointChange.del.push(...a.change.pointChange.del);
- }), i;
- }, Wd = (s, t, e, i) => {
- const n = {
- lineChange: {
- update: [],
- add: []
- },
- polygonChange: {
- update: []
- }
- }, r = Hd(
- s,
- t.map(({ id: h }) => h),
- !0
- );
- s.lines.forEach((h) => {
- let l = -1;
- if (r.includes(h) || !~(l = h.pointIds.indexOf(e)))
- return;
- const A = [...h.pointIds];
- A[l] = i, n.lineChange.update.push({
- before: { ...h, pointIds: [...h.pointIds] },
- after: { ...h, pointIds: [...A] }
- }), h.pointIds = A;
- });
- let a, o;
- for (const h of s.polygons) {
- let l;
- for (let A = 0; A < h.lineIds.length; A++) {
- if (!r.some(({ id: v }) => v === h.lineIds[A]))
- continue;
- const f = wt(s, h.lineIds[A]).pointIds.indexOf(e) === 1, c = ((f ? A + 1 : A - 1) + h.lineIds.length) % h.lineIds.length, d = wt(s, h.lineIds[c]);
- if (f ? d.pointIds[0] === e : d.pointIds[1] === e)
- continue;
- l = l || [...h.lineIds];
- let p;
- if (f) {
- if (!o) {
- const { line: v, change: _ } = ue(s, [
- e,
- i
- ]);
- _.lineChange.add.push(..._.lineChange.add), o = v;
- }
- p = o;
- } else {
- if (!a) {
- const { line: v, change: _ } = ue(s, [
- i,
- e
- ]);
- _.lineChange.add.push(..._.lineChange.add), a = v;
- }
- p = a;
- }
- const m = f ? A + 1 : A;
- h.lineIds.splice(m, 0, p.id);
- }
- l && n.polygonChange.update.push({
- before: { ...h, lineIds: l },
- after: h
- });
- }
- return { change: n };
- }, _n = class _n extends ie {
- constructor(t) {
- t.zIndex = t.zIndex || je.zIndex, t.name = t.name || _n.namespace + t.attrib.id, super(t), this.actShapeFactory = ui;
- }
- setActShapeFactory(t) {
- this.actShapeFactory = t;
- }
- initShape() {
- return this.actShape = this.actShapeFactory(this.attrib, this), this.actShape.shape;
- }
- diffRedraw() {
- const t = this.getCoords();
- t.length ? this.actShape.setData(t) : console.error("line:", this.attrib, "找不到对应的点坐标", [
- ...this.config.points
- ]);
- }
- setConfig(t) {
- this.config = t;
- }
- getCoords() {
- const t = [], e = _t(this.config, this.attrib.pointIds);
- return e.some((i) => !i) || e.forEach(({ x: i, y: n }, r) => {
- t[r * 2] = i, t[r * 2 + 1] = n;
- }), t;
- }
- initReactive() {
- return super.initReactive("post");
- }
- mounted() {
- super.mounted(), this.actShape.common(null);
- }
- };
- _n.namespace = "line";
- let Qt = _n;
- const xn = class xn extends ie {
- constructor(t) {
- t.zIndex = t.zIndex || cn.zIndex, t.name = t.name || xn.namespace + t.attrib.id, super(t), this.actShapeFactory = Nn;
- }
- setActShapeFactory(t) {
- this.actShapeFactory = t;
- }
- initShape() {
- return this.actShape = this.actShapeFactory(this.attrib, this), this.actShape.shape;
- }
- diffRedraw() {
- this.actShape.setData(this.getCoords());
- }
- setConfig(t) {
- this.config = t;
- }
- getCoords() {
- const t = [], e = ri(this.config, this.attrib.id);
- return e.some((i) => !i) || e.forEach(({ x: i, y: n }, r) => {
- t[r * 2] = i, t[r * 2 + 1] = n;
- }), t;
- }
- mounted() {
- super.mounted(), this.actShape.common(null);
- }
- };
- xn.namespace = "polygon";
- let Li = xn;
- const bn = class bn extends ie {
- constructor(t) {
- t.name = t.name || bn.namespace + t.attrib.id, super(t);
- }
- initIncFactory() {
- this.incLinesFactory = Pt(
- Qt,
- this,
- (t) => {
- t.setConfig(this.attrib);
- }
- ), this.incPointsFactory = Pt(
- Tt,
- this
- ), this.incPolygonFactory = Pt(
- Li,
- this,
- (t) => {
- t.setConfig(this.attrib);
- }
- ), qt && (this.incLinesHelperFactory = Pt(
- ar,
- this,
- (t) => {
- t.setConfig(this.attrib);
- }
- ), this.incPointsHelperFactory = Pt(
- or,
- this
- ));
- }
- init() {
- this.initIncFactory(), super.init();
- }
- initShape() {
- return new Nt({ id: this.name });
- }
- getRedrawLines() {
- const t = [];
- for (let e = this.attrib.lines.length - 1; e >= 0; e--) {
- const i = this.attrib.lines[e];
- let n = 0;
- for (n = 0; n < e; n++) {
- const r = this.attrib.lines[n];
- if (r.pointIds.includes(i.pointIds[0]) && r.pointIds.includes(i.pointIds[1]))
- break;
- }
- e === n && t.push(i);
- }
- return t;
- }
- diffRedraw() {
- const t = this.getRedrawLines();
- qt && (this.incLinesHelperFactory(t), this.incPointsHelperFactory(this.attrib.points));
- const e = this.incPointsFactory(this.attrib.points), i = this.incLinesFactory(t), n = this.incPolygonFactory(
- this.attrib.polygons
- );
- return { lineEntityInc: i, pointEntityInc: e, polygonEntityInc: n };
- }
- initReactive() {
- return fe(
- () => ({
- pointIds: this.attrib.points.map(({ id: t }) => t),
- lineIds: this.attrib.lines.map(({ id: t }) => t)
- }),
- this.diffRedraw.bind(this),
- { immediate: !0, flush: "pre" }
- );
- }
- };
- bn.namespace = "whole-line";
- let Ri = bn, jt;
- const Yd = () => {
- const s = {}, t = {}, e = (n, r) => {
- s[n] = r, t[n] = r;
- }, i = (n) => {
- for (const r in s)
- s[r] = t[r] / n;
- };
- return e("WHOLE_LINE_POINT_EQ_DIST", 1e-3), e("WHOLE_LINE_POINT_MERGE_DIST", 10), e("WHOLE_LINE_POINT_CHECK_DIST", 500), {
- addConstant: e,
- updateConstantScale: i,
- use() {
- jt = s;
- },
- unuse() {
- jt === s && (jt = null);
- }
- };
- }, Ze = (s, t) => {
- const e = "id" in t && t.id ? t.id : sh(s);
- if (s.points.some(({ id: i }) => i === e))
- return t;
- {
- const i = {
- ...t,
- id: e
- };
- return s.points.push(i), i;
- }
- }, Xd = (s, t, e) => {
- const i = pi(s, t), n = Ui(
- i.flatMap(({ x: h, y: l }) => [h, l]),
- [e.x, e.y]
- ).point, r = Ze(s, {
- ...e,
- x: n[0],
- y: n[1]
- }), { change: a, addedPoints: o } = hr(
- s,
- i,
- r.id
- );
- return a.pointChange.add.push(r), { change: a, addedPoints: o };
- }, jd = (s, t, e) => {
- const i = yi(s, t);
- return qd(
- s,
- t,
- i.lineIds[i.lineIds.length - 1],
- e
- );
- }, qd = (s, t, e, i) => {
- const n = yi(s, t), r = pi(s, e), a = Ze(s, i);
- let { line: o, change: h } = ue(s, [
- r[1].id,
- a.id
- ]);
- return h = Si(h, {
- pointChange: {
- add: [a]
- },
- polygonChange: {
- update: [
- {
- before: { ...n, lineIds: [...n.lineIds] },
- after: {
- ...n,
- lineIds: [...n.lineIds, o.id]
- }
- }
- ]
- }
- }), n.lineIds.push(o.id), { line: o, change: h };
- }, Qd = (s) => {
- let t = Math.max(...s.points.map((e) => Number(e.id) || 0));
- return (e) => {
- const i = {
- ...e,
- id: (++t).toString()
- };
- return s.points.push(i), i;
- };
- }, Kd = (s) => {
- const t = (o) => [o[0].x, o[0].y, o[1].x, o[1].y].join("-"), e = {}, i = (o, h) => [t(o), t(h)].join("-"), n = {}, r = [], a = Qd(s);
- return (o) => {
- let h;
- const l = t(o);
- if (h = e[l])
- return h;
- if (h = e[t([o[1], o[0]])])
- return h = [...h].reverse(), e[l] = h, h;
- h = [];
- const A = o;
- for (const f of s.polygons) {
- const c = $d(s, f.id);
- for (const d of c) {
- const p = i(o, d), m = {
- polygonId: f.id,
- line: d
- };
- if (p in n)
- n[p] && h.push({
- passive: m,
- intersection: n[p]
- });
- else {
- const v = d, _ = _o(
- [A[0].x, A[0].y, A[1].x, A[1].y],
- [v[0].x, v[0].y, v[1].x, v[1].y],
- [vo.Intersect]
- );
- if (_) {
- qt && console.log("join split", A[0].id, A[1].id, v[0].id, v[1].id);
- let g = -1, y = Number.MAX_VALUE;
- for (let b = 0; b < r.length; b++) {
- const C = [r[b].x, r[b].y], w = Et(C, _);
- y > w && (g = b, y = w);
- }
- let x;
- y <= jt.WHOLE_LINE_POINT_EQ_DIST ? x = r[g] : (x = a({ x: _[0], y: _[1] }), console.log("add", x.id), r.push(x)), h.push({
- passive: m,
- intersection: x
- }), n[p] = x;
- } else
- n[p] = null;
- }
- }
- }
- const u = [A[0].x, A[0].y];
- return h.sort(
- (f, c) => Et([f.intersection.x, f.intersection.y], u) - Et([c.intersection.x, c.intersection.y], u)
- ), e[l] = h, h;
- };
- }, Ya = (s, t, e, i) => {
- const n = s.map(({ id: h }) => h);
- if (!(n.includes(e[0].id) && n.includes(e[1].id)))
- return s;
- let a = Number.MAX_VALUE, o = -1;
- for (let h = 1; h < i.length; h++) {
- const l = [i[h - 1], i[h]], A = NA(
- [l[0].x, l[0].y, l[1].x, l[1].y],
- [t.x, t.y]
- );
- A < a && (a = A, o = h);
- }
- return ~o ? s[0] === s[0] ? [i[o - 1], i[o]] : [i[o], i[o - 1]] : s;
- }, Zd = (s, t) => {
- const e = Kd(s), i = [];
- for (let n = 1; n < t.length; n++) {
- let r = 0;
- for (; r < n && !(t[n].includes(t[r][0]) && t[n].includes(t[r][1])); r++)
- ;
- r !== n && t.splice(n--, 1);
- }
- for (const n of t) {
- const r = e(n), a = n;
- r.forEach((o) => {
- const h = [...o.passive.line];
- i.some((A) => {
- if (o.intersection.id !== A.intersection.id)
- return !1;
- const u = [...A.passive], f = [...A.splitLine];
- return f.includes(a[0]) && f.includes(a[1]) && u.includes(h[0]) && u.includes(h[1]) || u.includes(a[0]) && u.includes(a[1]) && f.includes(h[0]) && f.includes(h[1]);
- }) || i.push({
- splitLine: n,
- passive: o.passive.line,
- intersection: o.intersection
- });
- });
- }
- for (let n = 0; n < i.length; n++) {
- const { passive: r, splitLine: a, intersection: o } = i[n], h = hr(
- s,
- a,
- o.id
- ).addedPoints, l = hr(
- s,
- r,
- o.id
- ).addedPoints;
- if (qt && (h || console.error(
- `添加 addedPointIds 失败,
- 交点:`,
- o.id,
- `
- 线段:`,
- a
- ), l || console.error(
- `添加 passiveAddedPointIds 失败,
- 交点:`,
- o,
- `
- 线段:`,
- r
- )), !h && !l)
- continue;
- const A = h && _t(s, h), u = l && _t(s, l), f = (c, d) => {
- const p = c;
- return h && (c = Ya(
- c,
- d,
- a,
- A
- )), l && (c = Ya(
- c,
- d,
- r,
- u
- )), qt && p !== c && console.log(
- "fix line",
- p.map(({ id: m }) => m),
- `
- after: ,`,
- c.map(({ id: m }) => m)
- ), c;
- };
- for (let c = n + 1; c < i.length; c++) {
- const d = i[c];
- d.passive = f(d.passive, d.intersection), d.splitLine = f(d.splitLine, d.intersection);
- }
- }
- }, $s = (s, t) => Zd(
- s,
- lh(s, t).reduce((e, i) => (e.push(...i.lines), e), [])
- ), Jd = (s, t) => {
- const e = [t], i = s.points.filter(
- (n) => !e.includes(n) && Et([n.x, n.y], [t.x, t.y]) < jt.WHOLE_LINE_POINT_MERGE_DIST
- );
- return i.length ? i.length > 1 ? {
- main: t,
- merges: i,
- mergeAfterPosition: [t.x, t.y]
- } : {
- main: i[0],
- merges: [t],
- mergeAfterPosition: [i[0].x, i[0].y]
- } : null;
- }, tu = (s, t) => {
- const e = Jd(
- s,
- Pe(s, t)
- );
- if (!e)
- return;
- const i = lr(
- s,
- e.merges.map(({ id: r }) => r),
- e.main.id
- ), n = Pe(s, e.main.id);
- return n && (n.x = e.mergeAfterPosition[0], n.y = e.mergeAfterPosition[1]), {
- info: e,
- change: i
- };
- }, eu = (s, t, e, i = [10, 170]) => {
- const n = {}, r = t.pointIds, a = _t(s, [r[0], r[1]]), o = ce([
- a[0].x,
- a[0].y,
- a[1].x,
- a[1].y
- ]), h = _t(s, [r[1], r[0]]), l = ce([
- h[0].x,
- h[0].y,
- h[1].x,
- h[1].y
- ]), A = (u, f) => {
- let c = !0;
- const d = r[f];
- if (!n[d])
- n[d] = {};
- else
- return c = !1, { ...n[d], isFirst: c };
- const p = ah(s, d).filter(
- (F) => !(F.pointIds.includes(r[0]) && F.pointIds.includes(r[1]))
- ), m = [], v = f === 0 ? o : l;
- let _ = Number.MAX_VALUE, g, y = null, x = -Number.MAX_VALUE, b, C = null;
- for (let { pointIds: F, id: L } of p) {
- F = [
- r[f],
- ...F.filter((G) => G !== r[f])
- ];
- const I = _t(s, F), z = ce([
- I[0].x,
- I[0].y,
- I[1].x,
- I[1].y
- ]);
- m.push(z);
- const T = Xe(v, z);
- T > 0 ? T < _ && (_ = T, g = L, y = z) : T > x && (x = T, b = L, C = z);
- }
- let w = null, E = null, S = null;
- !y || !C ? (w = y || C, S = y ? g : b, E = y ? _ : x) : Math.abs(Xe(u, y)) < Math.abs(Xe(u, C)) ? (w = y, S = g, E = _) : (w = C, S = b, E = x);
- let P = !1, k = Math.abs(Se.radToDeg(E));
- if (w !== null && k > i[1] || k < i[0])
- console.log(
- "夹角不在范围,分割",
- S,
- f === 0 ? a : h,
- k
- ), S = null, w = pr(w), P = !0;
- else if (p.length > 1) {
- const F = w;
- for (let L = 0; L < p.length; L++) {
- if (F === m[L])
- continue;
- const I = (Xe(F, m[L]) + Math.PI) % Math.PI;
- if (Ot(I, 3) > 0) {
- console.log("方向不同,分割"), P = !0;
- break;
- }
- }
- }
- return n[d].refDire = w, n[d].lineDire = v, n[d].id = S, n[d].split = P, n[d].isFirst = c, n[d];
- };
- return (u) => {
- const f = new X(u[0], u[1]).normalize().toArray(), c = [
- A(f, 0),
- A(f, 1)
- ], d = [
- [e[0][0] + u[0], e[0][1] + u[1]],
- [e[1][0] + u[0], e[1][1] + u[1]]
- ], p = _t(s, t.pointIds);
- if (c[0].refDire || c[1].refDire) {
- const m = [], v = c.map(
- ({ refDire: S }) => S === null ? c[0].refDire || c[1].refDire : S
- );
- for (let S = 0; S < c.length; S++) {
- const P = v[S], k = c[S].split && c[S].isFirst, F = Ke(P, e[S], 10);
- if (k) {
- const L = sh(s);
- s.points.push({
- ...p[S],
- id: L
- }), Wd(
- s,
- a,
- t.pointIds[S],
- L
- );
- }
- m[S] = Ui(F, d[S]).point;
- }
- const _ = Et(m[0], e[0]) < Et(m[1], e[1]), g = _ ? o : l, y = _ ? m[0] : m[1], x = _ ? v[1] : v[0], b = _ ? e[1] : e[0], C = Ke(g, y, 10), w = Ke(x, b, 10), E = _o(C, w);
- _ ? (d[0] = y, d[1] = E) : (d[1] = y, d[0] = E);
- }
- p[0].x = d[0][0], p[0].y = d[0][1], p[1].x = d[1][0], p[1].y = d[1][1];
- };
- }, Ws = (s) => {
- for (let e = 0; e < s.lines.length; e++) {
- const i = s.lines[e], n = _t(s, i.pointIds);
- if (Ot(
- Et([n[0].x, n[0].y], [n[1].x, n[1].y]),
- 4
- ) !== 0)
- continue;
- const a = lr(s, [n[1].id], n[0].id);
- e = Math.max(e - a.lineChange.del.length, 0);
- }
- const t = [];
- for (let e = 0; e < s.polygons.length; e++) {
- const i = s.polygons[e];
- for (let n = 0; n < i.lineIds.length; n++) {
- const r = wt(s, i.lineIds[n]), a = (n + 1) % i.lineIds.length, o = wt(s, i.lineIds[a]);
- if (r.pointIds[0] === o.pointIds[1] && r.pointIds[1] === o.pointIds[0]) {
- t.push(_t(s, r.pointIds)), n > a ? (i.lineIds.splice(n, 1), i.lineIds.splice(a, 1)) : (i.lineIds.splice(n, 2), n -= 1), ai(s, r.pointIds), ai(s, o.pointIds);
- continue;
- }
- const h = _t(s, r.pointIds);
- Et(
- [h[0].x, h[0].y],
- [h[1].x, h[1].y]
- ) < jt.WHOLE_LINE_POINT_MERGE_DIST && (lr(s, [h[0].id], h[1].id), n--);
- }
- i.lineIds.length === 0 && (console.log("del polygon"), s.polygons.splice(e--, 1));
- }
- t.forEach((e) => {
- if (e[0].id === e[1].id)
- return;
- const i = rh(s), n = nh(s);
- e = e.map((r) => s.points.some(({ id: a }) => a === r.id) ? r : Ze(s, { x: r.x, y: r.y })), s.lines.push({
- id: n,
- pointIds: e.map(({ id: r }) => r)
- }), s.polygons.push({
- id: i,
- lineIds: [n]
- });
- });
- }, iu = ({
- tree: s,
- position: t,
- refPointName: e = "adsord-point",
- exclusionIds: i = [],
- radius: n = 10
- }) => {
- const r = s.stage.find(`.${e}`).filter((a) => !i.includes(a.id())).map((a) => {
- const o = a.position();
- return [o.x, o.y];
- });
- return nu({ refPositions: r, radius: n, position: t });
- }, nu = ({
- position: s,
- radius: t = 10,
- refPositions: e
- }) => {
- let i = null, n = Number.MAX_VALUE;
- for (const r of e) {
- const a = Et(r, s);
- a < t && a < n && (n = a, i = r);
- }
- return i;
- }, wi = [0, 90, 180, 270, 360], dh = ({
- position: s,
- refLines: t,
- angle: e = 3
- }) => {
- let i = null, n = null, r = !1;
- for (const a of t) {
- const h = [
- [a[0], a[1]],
- [a[2], a[3]]
- ].map((u) => (Se.radToDeg(
- TA(a, [...u, ...s])
- ) + 360) % 360);
- let l = 0, A = 0;
- for (l = 0; l < h.length; l++) {
- for (A = 0; A < wi.length; A++) {
- const u = wi[A];
- if (h[l] >= u - e && h[l] <= u + e)
- break;
- }
- if (A !== wi.length)
- break;
- }
- if (A !== wi.length || l !== h.length) {
- n = a, i = wi[A];
- const u = DA(
- ce(n),
- Se.degToRad(i)
- ), f = Et([n[0], n[1]], s) > Et([n[2], n[3]], s) ? [n[2], n[3]] : [n[0], n[1]];
- n = Ke(u, f, 10), s = Ui(n, s).point, r = !0;
- }
- }
- if (r)
- return s;
- }, su = ({
- position: s,
- angle: t,
- points: e
- }) => {
- if (e != null && e.length && e.length === 1) {
- const i = e[0], n = [
- [i[0] - 1, i[1], i[0] + 1, i[1]],
- [i[0], i[1] - 1, i[0], i[1] + 1]
- ];
- return dh({ position: s, refLines: n, angle: t });
- }
- }, Xa = ({
- position: s,
- points: t,
- angle: e
- }) => {
- if (!(t != null && t.length))
- return;
- const i = t.slice(0, 2).flatMap((o) => o), n = t.slice(t.length - 2, t.length).flatMap((o) => o), r = [
- i,
- // createLineByDire(getVerticaLineDire(last), [last[2], last[3]], 10),
- Ke(IA(n), [n[2], n[3]], 10)
- ];
- let a;
- if (a = dh({
- position: s,
- refLines: r,
- angle: e
- }))
- return a;
- }, uh = (s) => {
- const t = s.position || s.tree.getRealFromStage(s.pixel);
- let e;
- if (e = iu({ ...s, position: t }))
- return e;
- if (e = su({ ...s, position: t }))
- return e;
- if (e = Xa({ ...s, position: t }))
- return e;
- if (s.pointsArray) {
- for (let i = 0; i < s.pointsArray.length; i++)
- if (e = Xa({
- ...s,
- position: t,
- points: s.pointsArray[i]
- }))
- return e;
- }
- return t;
- }, ja = ({
- tree: s,
- config: t,
- polygonId: e,
- pointAttribFactory: i,
- quotePoint: n,
- canOper: r,
- autoAdd: a,
- adsorbRadius: o,
- canDelPoint: h,
- closeAutoQuit: l,
- changePolygon: A,
- autoClose: u
- }) => {
- i = i || ((b) => ({
- x: b[0],
- y: b[1]
- }));
- const f = (b) => {
- if (b)
- return t.polygons.find(({ id: C }) => C === b);
- {
- const C = rh(t);
- return t.polygons.push({
- id: C,
- lineIds: []
- }), t.polygons[t.polygons.length - 1];
- }
- };
- let c, d = !1, p = null, m = !0;
- const v = (b) => {
- if (c = f(b), !c)
- throw `${b}的多边形不存在!`;
- A && A(c.id), e = c.id, d = !b, p = null, m = a || c.lineIds.length < 2;
- };
- v(e);
- const _ = () => {
- const b = t.polygons.indexOf(c);
- ~b && t.polygons.splice(b, 1);
- }, g = (b) => {
- let C = {
- lineChange: {
- del: [],
- update: [],
- add: []
- },
- polygonChange: {
- add: [],
- update: [],
- del: []
- },
- pointChange: {
- add: [],
- del: []
- }
- };
- const w = So(b.target, (T) => {
- const G = T.id();
- return G.includes(Qt.namespace) || G.includes(Tt.namespace);
- });
- let E = w && s.find(w.id());
- const S = [b.evt.offsetX, b.evt.offsetY];
- if (E instanceof Qt && (!r || r(E, b.target)) && c.lineIds.includes(E.attrib.id)) {
- const { change: T } = Xd(
- t,
- E.attrib.id,
- i(s.getRealFromStage(S))
- );
- return { change: Si(C, T), isClose: !1 };
- }
- let P;
- const k = ri(t, c.id);
- let F;
- for (; ; ) {
- if (E instanceof Tt) {
- if (r && !r(E, b.target))
- return { change: C, isClose: !1 };
- if (F = typeof n == "function" ? n(E.attrib) : !!n, P = F ? E.attrib : { ...E.attrib }, c.id === p)
- return { change: C, isClose: !1 };
- } else {
- let T;
- if (o) {
- const R = k.map(({ x: N, y: q }) => [N, q]);
- if (p) {
- const N = Pe(t, p);
- R.push([N.x, N.y]);
- }
- T = uh({
- tree: s,
- pixel: S,
- radius: o,
- points: [...R].reverse()
- });
- } else
- T = s.getRealFromStage(S);
- const G = Mo(s);
- let H = 0;
- for (; H < G.length; H++)
- if (G[H] instanceof Tt) {
- const R = G[H];
- if (Ot(R.attrib.x - T[0], 4) === 0 && Ot(R.attrib.y - T[1], 4) === 0) {
- E = s.children[H];
- break;
- }
- }
- if (H !== G.length) {
- E = G[H];
- continue;
- }
- P = i(T);
- }
- break;
- }
- const L = k.findIndex(({ id: T }) => T === P.id), I = L === 0 && (!u || k.length >= 3);
- if (L >= 0 && !I) {
- const T = Wa(
- t,
- P.id,
- !h || h(P, b)
- );
- if (C = Si(C, T), c.lineIds.length === 0) {
- ch(t, c.id);
- const G = T.pointChange.del.find(
- ({ id: R }) => R !== P.id
- );
- v(null);
- const H = Ze(t, { ...G, id: void 0 });
- p = H.id, C.pointChange.add.push(H);
- }
- return { change: C, isClose: I };
- }
- F || delete P.id;
- const z = (T) => (!l && I && v(null), { change: T, isClose: I });
- if (c.lineIds.length > 0)
- if (d) {
- const T = jd(
- t,
- e,
- P
- ).change;
- return z(Si(C, T));
- } else
- return m ? (v(null), g(b)) : { change: C, isClose: I };
- else if (p) {
- const [T] = Gt(s.stage, [4, 4], !0), G = Pe(t, p);
- if (!(Math.abs(P.x - G.x) > T || Math.abs(P.y - G.y) > T))
- return z(C);
- const { line: H, change: R } = ue(t, [
- p,
- Ze(t, P).id
- ]);
- return C = Si(C, R, {
- polygonChange: {
- update: [
- {
- before: { ...c, lineIds: [...c.lineIds] },
- after: {
- ...c,
- lineIds: [...c.lineIds, H.id]
- }
- }
- ]
- },
- pointChange: {
- add: [P]
- }
- }), c.lineIds.push(H.id), p = null, z(C);
- } else {
- const T = Ze(t, P);
- return p = T.id, C.pointChange.add.push(T), z(C);
- }
- };
- return {
- continuous: g,
- end: () => {
- c.lineIds.length === 0 && (p && Wa(t, p), _()), A && A(null);
- },
- getStatus: () => ({
- newMode: d,
- polyginAttribId: c.id,
- prevId: p,
- config: t
- }),
- setStatus: (b) => {
- d = b.newMode, c = b.config.polygons.find(
- ({ id: C }) => C === b.polyginAttribId
- ), e = c.id, p = b.prevId, t = b.config;
- }
- };
- }, ru = "data:image/x-icon;base64,AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAAAAAAMQOAADEDgAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAgAAAAH///8BAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAB////AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8BVVVVAwAAAAYAAAAIAAAABQAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAYAAAANAAAAFwAAADUAAAAUAAAACwAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAAAwAAAAMAAAAHAAAAEQAAACIAAACVAAAA8gAAAFIAAAAbAAAADH9/fwIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAM8AAAD/AAAAjwAAAAAAAAABAAAABAAAAAkSEhIOAAAAEgAAABMAAAASDg4OEgAAABcAAAAnAAAAmgAAAP8wMDD/AAAA8gAAAFcAAAAcAAAADH9/fwIAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACPICAg/5+fn/8AAAD/AAAAQhwcHAkAAAASAAAAHgAAACkAAABfAAAAYQMDA1MFBQUvAAAANQAAAJ4AAAD/f39///////9fX1//AAAA8gAAAFcAAAAcAAAAC1VVVQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAATwAAAL9gYGD//////wAAAP8AAACkAAAAUgQEBEQAAACyAAAA8gAAAP8AAAD/AAAA/wAAAPMAAADHAAAA/39/f/////////////////9fX1//AAAA8gAAAFcAAAAcAAAAC1VVVQMAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAN8AAAD/AAAA/2BgYP//////AAAA/wAAAP8AAAD/AAAA/yAgIP+fn5//z8/P/9/f3//f39//j4+P/09PT/9/f3////////////////////////////9fX1//AAAA8gMDA1cJCQkcGRkZCgAAAAMAAAAAAAAAAAAAAAAAAABgAAAA/9/f3////////////////////////////39/f/8AAAD///////////////////////////////////////////////////////////////////////////9fX1//AAAA8gAAAFMNDQ0TAAAABQAAAAAAAAAAAAAAAAAAACAAAAD/QEBA/2BgYP+fn5///////2BgYP9gYGD/ICAg/0BAQP////////////////////////////////////////////////////////////////////////////////8wMDD/AAAA8gAAACYAAAAHAAAAAQAAAAAAAAAAAAAAAAAAAEAAAACgAAAA4GBgYP//////AAAA/zAwMP9vb2//39/f////////////////////////////////////////////////////////////////////////////gICA/wAAAP8AAACWAAAAFwAAAAcAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAChUFBQ/9/f3/8AAAD/n5+f/////////////////////////////////////////////////////////////////////////////////4CAgP8AAAD/AAAAmgAAACIAAAANAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAFsAAAD/AAAA/yAgIP/v7+////////////////////////////////////////////////////////////////////////////+Pj4//AAAA/wAAAJ0AAAAmAAAAEDMzMwUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAIAAAAHAAAAJoQEBD/39/f///////////////////////v7+//n5+f/39/f/+/v7///////////////////////////////////////z8/P/8AAADSAAAAMwwMDBYAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAA4GBgYoAAAA8n9/f///////////////////////39/f/yAgIP8AAAD/AAAA/wAAAP+AgID/////////////////////////////////n5+f/wAAAPMAAAAtAAAAEAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFDAwMFgAAAGQAAAD/v7+///////////////////////9PT0//AAAA/wAAAP8AAAD/AAAA/wAAAP+/v7/////////////////////////////Pz8//AAAA/wAAAFIODg4SAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhwcHAkAAAAeAAAAp0BAQP///////////////////////////x8fH/8AAAD/AAAA/wAAAP8AAAD/AAAA/39/f////////////////////////////9/f3/8AAAD/AAAAYA4ODhIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAADgYGBikAAADyf39/////////////////////////////MDAw/wAAAP8AAAD/AAAA/wAAAP8AAAD/j4+P////////////////////////////39/f/wAAAP8AAABSAAAAEQAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAADMzMwUAAAAUAAAAVwAAAP+/v7////////////////////////////9fX1//AAAA/wAAAP8AAAD/AAAA/yAgIP/v7+////////////////////////////+Pj4//AAAA8wAAADQAAAAOAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABKioqBgAAABoAAACMEBAQ////////////////////////////gICA/wAAAP9gYGD/Pz8//x8fH/9gYGD/39/f////////////////////////////7+/v/yAgIP8AAACnAAAAHgAAAAkAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAALAAAAIgAAAM1gYGD//////////////////////4CAgP8AAAD/f39///////////////////////////////////////////////////////9wcHD/AAAA8wAAAEUAAAASAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxAQEBAGBgYqAAAA84+Pj/////////////////+AgID/AAAA/39/f///////////////////////////////////////////////////////gICA/wAAAP8AAAB9AAAAGxwcHAkAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAFAAAAEoAAAD/z8/P////////////gICA/wAAAP9/f3//////////////////////////////////////////////////39/f/19fX/8AAAD/AAAAlgAAAB4AAAAMAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAZAAAAfxAQEP///////////4CAgP8AAAD/f39/////////////////////////////////////////////39/f/4+Pj/8gICD/AAAA5gAAAGQAAAAdAAAADQAAAAT///8BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAACAAAAB4AAACnMDAw//////+AgID/AAAA/39/f///////////////////////////////////////39/f/19fX/8gICD/AAAA5wAAAJkAAAA2CwsLGBcXFwsAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAMAAAAJAAAAM5gYGD/gICA/wAAAP9/f3/////////////////////////////Pz8//f39//zAwMP8AAAD/AAAA5gAAAIAAAABDAAAAHRAQEBAAAAAIAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf39/AgAAAA4AAAApAAAA8yAgIP8AAAD/f39/////////////z8/P/4+Pj/9QUFD/ICAg/wAAAP8AAADmAAAAswAAAGQAAAAoCQkJGwAAABEgICAIAAAAAwAAAAL///8BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVVVUDAAAADwAAADcAAAD/AAAA/yAgIP9vb2//QEBA/wAAAP8AAAD/AAAA8wAAAM0AAACMAAAAVgAAACgAAAAeAAAAFgAAAA4AAAAIAAAAA////wEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAOAAAASgAAAP8AAAD/AAAA8wAAAM0AAACnAAAAfwAAAFYAAAArAAAAIwAAABsAAAAUAAAADgAAAAkAAAAEAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAgAAAAkAAAAVwUFBTgGBgYqBwcHJAAAAB4KCgoZDQ0NEwAAAA8XFxcLJCQkBwAAAAUAAAACAAAAAv///wEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAgSEhIOERERDwAAAA4AAAALAAAACCoqKgZAQEAEAAAAAwAAAAH///8BAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///wAAAAABAAAAAgAAAAMAAAADAAAAAwAAAAIAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////////////////7/+f/8f/D//Hxgf/AAAD/gAAAf4AAAD/wAAA/8AAAf/AAAP/4AAH/+AAB//AAAP/wAAD/8AAA/+AAAf/gAAH/4AAD/+AAA//AAAf/wAAf/8AAf//AAf//wA///4D///+f///////////////////8=", au = "data:image/x-icon;base64,AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAAAAAAMQOAADEDgAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAgAAAAH///8BAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAB////AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8BVVVVAwAAAAYAAAAIAAAABQAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAYAAAANAAAAFwAAADUAAAAUAAAACwAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAAAwAAAAMAAAAHAAAAEQAAACIAAACVAAAA8gAAAFIAAAAbAAAADH9/fwIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAABAAAAAkSEhIOAAAAEgAAABMAAAASDg4OEgAAABcAAAAnAAAAmgAAAP8wMDD/AAAA8gAAAFcAAAAcAAAADH9/fwIAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAxwcHAkAAAASAAAAHgAAACkAAABfAAAAYQMDA1MFBQUvAAAANQAAAJ4AAAD/f39///////9fX1//AAAA8gAAAFcAAAAcAAAAC1VVVQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAATwAAAF8AAABfAAAAYAAAAGIAAABmAAAAUgQEBEQAAACyAAAA8gAAAP8AAAD/AAAA/wAAAPMAAADHAAAA/39/f/////////////////9fX1//AAAA8gAAAFcAAAAcAAAAC1VVVQMAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAN8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/yAgIP+fn5//z8/P/9/f3//f39//j4+P/09PT/9/f3////////////////////////////9fX1//AAAA8gMDA1cJCQkcGRkZCgAAAAMAAAAAAAAAAAAAAAAAAABgAAAA/9/f3////////////////////////////39/f/8AAAD///////////////////////////////////////////////////////////////////////////9fX1//AAAA8gAAAFMNDQ0TAAAABQAAAAAAAAAAAAAAAAAAACAAAAD/QEBA/2BgYP9gYGD/YGBg/2BgYP9gYGD/ICAg/0BAQP////////////////////////////////////////////////////////////////////////////////8wMDD/AAAA8gAAACYAAAAHAAAAAQAAAAAAAAAAAAAAAAAAAEAAAACgAAAAogAAAKcAAAC+AAAA/zAwMP9vb2//39/f////////////////////////////////////////////////////////////////////////////gICA/wAAAP8AAACWAAAAFwAAAAcAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAKAAAAHgAAAJoQEBD/7+/v/////////////////////////////////////////////////////////////////////////////////4CAgP8AAAD/AAAAmgAAACIAAAANAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAABIAAAA5AAAA839/f/////////////////////////////////////////////////////////////////////////////////+Pj4//AAAA/wAAAJ0AAAAmAAAAEDMzMwUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAIAAAAHAAAAJoQEBD/7+/v///////////////////////v7+//n5+f/39/f/+/v7///////////////////////////////////////z8/P/8AAADSAAAAMwwMDBYAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAA4GBgYoAAAA8n9/f///////////////////////39/f/yAgIP8AAAD/AAAA/wAAAP+AgID/////////////////////////////////n5+f/wAAAPMAAAAtAAAAEAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFDAwMFgAAAGQAAAD/v7+///////////////////////9PT0//AAAA/wAAAP8AAAD/AAAA/wAAAP+/v7/////////////////////////////Pz8//AAAA/wAAAFIODg4SAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhwcHAkAAAAeAAAAp0BAQP///////////////////////////x8fH/8AAAD/AAAA/wAAAP8AAAD/AAAA/39/f////////////////////////////9/f3/8AAAD/AAAAYA4ODhIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAADgYGBikAAADyf39/////////////////////////////MDAw/wAAAP8AAAD/AAAA/wAAAP8AAAD/j4+P////////////////////////////39/f/wAAAP8AAABSAAAAEQAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAADMzMwUAAAAUAAAAVwAAAP+/v7////////////////////////////9fX1//AAAA/wAAAP8AAAD/AAAA/yAgIP/v7+////////////////////////////+Pj4//AAAA8wAAADQAAAAOAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABKioqBgAAABoAAACMEBAQ////////////////////////////gICA/wAAAP9gYGD/Pz8//x8fH/9gYGD/39/f////////////////////////////7+/v/yAgIP8AAACnAAAAHgAAAAkAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAALAAAAIgAAAM1gYGD//////////////////////4CAgP8AAAD/f39///////////////////////////////////////////////////////9wcHD/AAAA8wAAAEUAAAASAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxAQEBAGBgYqAAAA84+Pj/////////////////+AgID/AAAA/39/f///////////////////////////////////////////////////////gICA/wAAAP8AAAB9AAAAGxwcHAkAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAFAAAAEoAAAD/z8/P////////////gICA/wAAAP9/f3//////////////////////////////////////////////////39/f/19fX/8AAAD/AAAAlgAAAB4AAAAMAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAZAAAAfxAQEP///////////4CAgP8AAAD/f39/////////////////////////////////////////////39/f/4+Pj/8gICD/AAAA5gAAAGQAAAAdAAAADQAAAAT///8BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAACAAAAB4AAACnMDAw//////+AgID/AAAA/39/f///////////////////////////////////////39/f/19fX/8gICD/AAAA5wAAAJkAAAA2CwsLGBcXFwsAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAMAAAAJAAAAM5gYGD/gICA/wAAAP9/f3/////////////////////////////Pz8//f39//zAwMP8AAAD/AAAA5gAAAIAAAABDAAAAHRAQEBAAAAAIAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf39/AgAAAA4AAAApAAAA8yAgIP8AAAD/f39/////////////z8/P/4+Pj/9QUFD/ICAg/wAAAP8AAADmAAAAswAAAGQAAAAoCQkJGwAAABEgICAIAAAAAwAAAAL///8BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVVVUDAAAADwAAADcAAAD/AAAA/yAgIP9vb2//QEBA/wAAAP8AAAD/AAAA8wAAAM0AAACMAAAAVgAAACgAAAAeAAAAFgAAAA4AAAAIAAAAA////wEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAOAAAASgAAAP8AAAD/AAAA8wAAAM0AAACnAAAAfwAAAFYAAAArAAAAIwAAABsAAAAUAAAADgAAAAkAAAAEAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAgAAAAkAAAAVwUFBTgGBgYqBwcHJAAAAB4KCgoZDQ0NEwAAAA8XFxcLJCQkBwAAAAUAAAACAAAAAv///wEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAgSEhIOERERDwAAAA4AAAALAAAACCoqKgZAQEAEAAAAAwAAAAH///8BAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///wAAAAABAAAAAgAAAAMAAAADAAAAAwAAAAIAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////+f////D///xgf/AAAD/gAAAf4AAAD/8AAA//AAAf/wAAP/4AAH/+AAB//AAAP/wAAD/8AAA/+AAAf/gAAH/4AAD/+AAA//AAAf/wAAf/8AAf//AAf//wA///4D///+f///////////////////8=", ou = (s) => {
- const t = () => JSON.parse(JSON.stringify(s.config)), e = ja({ ...s }), i = ja({
- ...s,
- closeAutoQuit: !0,
- changePolygon: void 0,
- config: t()
- }), n = () => {
- const y = e.getStatus();
- i.setStatus({
- ...y,
- config: t()
- });
- }, r = s.tree.stage, a = ei();
- let o = !1;
- const h = () => {
- o = !0;
- }, l = (y) => {
- if (o)
- return;
- n();
- const { change: x } = i.continuous(y), { config: b } = i.getStatus();
- a.value = {
- change: x,
- config: b
- };
- }, A = (y) => {
- o = !1, l(y);
- };
- let u, f;
- const c = (y) => {
- const [x] = Gt(r, [4, 4], !0);
- u && Math.abs(y.evt.offsetX - u.x) < x && Math.abs(y.evt.offsetY - u.y) < x || (f = setTimeout(() => {
- const { isClose: b, change: C } = e.continuous(y);
- n(), b && s.closeAutoQuit && g(), s.onChange && s.onChange(C), u = null;
- }));
- }, d = (y) => {
- const x = ao(y);
- y.evt.offsetX = x.offsetX, y.evt.offsetY = x.offsetY;
- }, p = (y) => {
- y.evt.preventDefault(), d(y), l(y), !a.value.change.lineChange.add.length && !a.value.change.lineChange.del.length && (v(y), u = {
- x: y.evt.offsetX,
- y: y.evt.offsetY
- });
- }, m = (y) => {
- y.evt.preventDefault(), d(y), l(y);
- }, v = (y) => {
- y.evt.preventDefault(), d(y), c(y), a.value = void 0;
- }, _ = (y) => {
- clearTimeout(f), y instanceof KeyboardEvent ? y.key === "Escape" && g() : (g(), y.preventDefault());
- };
- let g = () => {
- hn ? (r.off("touchstart.editPolygonsMode", p), r.off("touchmove.editPolygonsMode", m), r.off("touchend.editPolygonsMode", v)) : (r.off("click.editPolygonsMode", c), r.off("mousedown.editPolygonsMode", h), r.off("mousemove.editPolygonsMode", l), r.off("mouseup.editPolygonsMode", A), document.removeEventListener("contextmenu", _), document.removeEventListener("keydown", _)), a.value = void 0, e.end(), i.end(), s.quitHandler && s.quitHandler();
- };
- return hn ? (r.on("touchstart.editPolygonsMode", p), r.on("touchmove.editPolygonsMode", m), r.on("touchend.editPolygonsMode", v)) : (r.on("click.editPolygonsMode", c), r.on("mousedown.editPolygonsMode", h), r.on("mousemove.editPolygonsMode", l), r.on("mouseup.editPolygonsMode", A), document.addEventListener("contextmenu", _), document.addEventListener("keydown", _)), {
- helperInfo: a,
- destory() {
- g && (g(), g = null);
- }
- };
- }, hu = (s, t) => {
- var o, h, l;
- const { lineChange: e, polygonChange: i } = s;
- if (!e || !((o = i == null ? void 0 : i.update) != null && o.length))
- return !1;
- const n = i.update.find(
- ({ after: A }) => A.id === t
- );
- if (!n)
- return !1;
- const { before: r, after: a } = n;
- if ((h = e.del) != null && h.length) {
- if ((l = e.add) != null && l.length)
- return !1;
- } else if (a.lineIds.length >= 2)
- return "after";
- if (a.lineIds.length !== r.lineIds.length)
- if (a.lineIds.includes(r.lineIds[r.lineIds.length - 1])) {
- if (!a.lineIds.includes(r.lineIds[0]))
- return "before";
- } else
- return "after";
- return !1;
- }, lu = (s, t = !1) => {
- var o, h, l, A, u, f, c, d, p, m, v, _, g, y, x, b;
- const e = [];
- (h = (o = s.change) == null ? void 0 : o.pointChange) != null && h.add && e.push(
- ...(A = (l = s.change) == null ? void 0 : l.pointChange) == null ? void 0 : A.add.map(({ x: C, y: w }) => [C, w])
- );
- const i = [];
- (f = (u = s.change) == null ? void 0 : u.pointChange) != null && f.del && i.push(...(d = (c = s.change) == null ? void 0 : c.pointChange) == null ? void 0 : d.del.map(({ id: C }) => C));
- const n = [];
- if ((m = (p = s.change) == null ? void 0 : p.lineChange) != null && m.add) {
- const C = s.change.lineChange.add.map(
- ({ pointIds: w }) => w
- );
- n.push(
- ...C.map((w) => _t(s.config, w).flatMap(({ x: S, y: P }) => [S, P]))
- );
- }
- const r = [];
- (_ = (v = s.change) == null ? void 0 : v.lineChange) != null && _.del && r.push(...(y = (g = s.change) == null ? void 0 : g.lineChange) == null ? void 0 : y.del.map(({ id: C }) => C));
- const a = {};
- return t && ((b = (x = s.change) == null ? void 0 : x.polygonChange) != null && b.update) && s.change.polygonChange.update.forEach((C) => {
- if (hu(s.change, C.after.id)) {
- const w = oh(s.config, [
- C.after.lineIds[C.after.lineIds.length - 1],
- C.after.lineIds[0]
- ]);
- a[C.after.id] = _t(s.config, [
- w[0].pointIds[1],
- w[1].pointIds[0]
- ]).flatMap(({ x: E, y: S }) => [E, S]);
- }
- }), {
- addLines: n,
- delLines: r,
- addPoints: e,
- delPoints: i,
- cloneLines: a
- };
- }, Lr = (s, t) => {
- const { helperInfo: e, destory: i } = ou({
- ...s,
- quitHandler: () => {
- o(), s.quitHandler && s.quitHandler();
- }
- }), n = mh(
- () => e.value && lu(e.value, s.autoClose)
- ), r = On();
- r.shape.listening(!1);
- const a = ui();
- a.active(), a.shape.dash([5, 5]), a.shape.listening(!1);
- const o = Sn((h) => {
- if (!n.value)
- return;
- const { addLines: l, cloneLines: A, addPoints: u } = n.value, f = [...l, ...Object.values(A)].map(
- (m) => (a.setData(m), a.shape.clone())
- ), [c] = Gt(t, [1, 1]), d = u.map((m) => (r.setData(m), r.shape.scale({ x: c, y: c }), r.shape.clone()));
- t.add(...f, ...d);
- let p;
- n.value.delPoints.length ? p = s.tree.setCursor(au) : u.length && (p = s.tree.setCursor(ru)), h(() => {
- [...f, ...d].forEach((m) => {
- m.remove();
- }), p && p();
- });
- });
- return i;
- };
- class f1 extends Ri {
- diffRedraw() {
- const t = super.diffRedraw();
- return t.lineEntityInc.adds.forEach((e) => {
- ln(e, this.lineDragHandler), e.enableMouseAct({ ...e.actShape, active: void 0 }), e.shape.name("adsord-line");
- }), t.pointEntityInc.adds.forEach((e) => {
- ln(e, this.pointDragHandler), e.enableMouseAct({ ...e.actShape, active: void 0 }), e.shape.addName("adsord-point");
- }), t;
- }
- getChildByPointsAttrib(t) {
- const e = [];
- for (let i = 0; i < t.length; i++) {
- const n = Tt.namespace + t[i].id;
- e.includes(n) || e.push(n), this.attrib.lines.filter(({ pointIds: r }) => r.includes(t[i].id)).forEach(({ id: r }) => {
- const a = Qt.namespace + r;
- e.includes(a) || e.push(a);
- });
- }
- return this.children.filter((i) => e.includes(i.name));
- }
- editPolygon(t) {
- xo(), this.container.constant.use();
- const e = /* @__PURE__ */ new Set();
- let i = !1;
- this.endCreatePolygon && this.endCreatePolygon(), this.container.bus.emit("dataChangeBefore");
- const n = Tr();
- let r = !1;
- const a = new Promise((o) => {
- this.endCreatePolygon = Lr(
- {
- polygonId: t,
- quotePoint: !0,
- autoClose: !1,
- tree: this.container,
- autoAdd: !0,
- adsorbRadius: jt.WHOLE_LINE_POINT_MERGE_DIST,
- config: this.attrib,
- changePolygon: (h) => {
- console.log("changePolygon", h), h && e.add(h);
- },
- onChange(h) {
- !r && h.pointChange.add.length && (n.emit("penStart"), r = !0);
- },
- quitHandler: () => {
- this.endCreatePolygon = null, e.forEach((h) => {
- const l = yi(this.attrib, h);
- l && (i ? ch(this.attrib, h) : this.polygonAfterHandler(l));
- }), o(i ? "cancel" : "submit"), bo(), this.container.constant.unuse(), this.container.bus.emit("dataChangeAfter");
- }
- },
- this.shape
- );
- });
- return {
- bus: n,
- submit: this.endCreatePolygon.bind(this),
- cancel: () => {
- i = !0, this.endCreatePolygon();
- },
- promise: a
- };
- }
- createPolygon() {
- return this.editPolygon();
- }
- pointAfterHandler(t) {
- this.container.constant.use();
- const e = tu(this.attrib, t.id);
- $s(
- this.attrib,
- (e == null ? void 0 : e.info.main.id) || t.id
- ), Ws(this.attrib), this.container.constant.unuse();
- }
- lineAfterHandler(t) {
- this.container.constant.use();
- for (let e = 0; e < t.pointIds.length; e++)
- $s(this.attrib, t.pointIds[e]);
- Ws(this.attrib), this.container.constant.unuse();
- }
- polygonAfterHandler(t) {
- this.container.constant.use(), ri(this.attrib, t.id).forEach(
- (e) => {
- this.attrib.points.includes(e) && $s(this.attrib, e.id);
- }
- ), Ws(this.attrib), this.container.constant.unuse();
- }
- init() {
- this.lineDragHandler = {
- readyHandler: (t) => {
- this.container.bus.emit("dataChangeBefore"), this.container.tempDraw();
- const e = pi(this.attrib, t.id);
- return eu(
- this.attrib,
- t,
- e.map(({ x: i, y: n }) => [i, n])
- );
- },
- moveHandler: (t, e, i) => {
- i(e);
- },
- endHandler: (t) => {
- this.lineAfterHandler(t), this.container.bus.emit("dataChangeAfter");
- }
- }, this.pointDragHandler = {
- readyHandler: (t) => (this.container.constant.use(), this.container.bus.emit("dataChangeBefore"), lh(
- this.attrib,
- t.id
- ).map(({ polygonId: n }) => {
- let r = ri(this.attrib, n);
- const a = r.indexOf(t), o = r[0] === r[r.length - 1] ? r.length - 1 : r.length;
- return r = [
- ...r.slice(a + 1, o),
- ...r.slice(0, a)
- ], console.log(r), r.map((h) => [h.x, h.y]);
- })),
- moveHandler: (t, e, i) => {
- const n = Vd(
- this.attrib,
- t
- ).map((a) => Qt.namespace + a.id);
- n.push(Tt.namespace + t.id);
- const r = uh({
- tree: this.container,
- position: e,
- radius: jt.WHOLE_LINE_POINT_MERGE_DIST,
- radiusInner: jt.WHOLE_LINE_POINT_CHECK_DIST,
- pointsArray: i,
- exclusionIds: n
- });
- t.x = r[0], t.y = r[1];
- },
- endHandler: (t) => {
- this.container.constant.unuse(), this.pointAfterHandler(t), this.container.bus.emit("dataChangeAfter");
- }
- }, super.init();
- }
- destory() {
- this.endCreatePolygon && this.endCreatePolygon(), super.destory();
- }
- }
- const Au = (s, t) => {
- const e = t.parent, i = ui(), n = () => !!(e.editPolygonId.value && hh(
- e.attrib,
- e.editPolygonId.value
- ).some(({ id: o }) => o === s.id)), r = () => {
- var o, h, l;
- ((l = (h = (o = e.helperInfo) == null ? void 0 : o.value) == null ? void 0 : h.delLines) == null ? void 0 : l.includes(s.id)) ? i.shape.stroke("rgba(0, 0, 0, 0)") : n() ? i.active() : i.common();
- };
- return {
- shape: i.shape,
- setData(a) {
- i.setData(a), r();
- },
- common: r
- };
- }, fh = (s) => (t, e) => {
- const i = e.parent, n = () => i.editPolygonId.value === t.id, r = Nn({ autoClose: s }), a = (o) => {
- n() ? r.active(o) : r.common(o);
- };
- return {
- shape: r.shape,
- setData(o) {
- var l, A, u, f;
- a(), r.setData(o);
- const h = (A = (l = i.helperInfo) == null ? void 0 : l.value) != null && A.cloneLines ? Object.keys((f = (u = i.helperInfo) == null ? void 0 : u.value) == null ? void 0 : f.cloneLines).includes(
- t.id
- ) : !1;
- r.shape.children[1].visible(!h);
- },
- common: a
- };
- }, cu = fh(!0), du = fh(!1);
- class g1 extends Ri {
- constructor() {
- super(...arguments), this.editPolygonId = ei(), this.autoClose = !0, this._leaveEditMode = void 0;
- }
- dragAttach(t) {
- t.pointEntityInc.adds.forEach((e) => {
- ln(e, {
- readyHandler: (i) => [i.x, i.y],
- moveHandler: (i, n) => {
- this.editPolygonId.value && (i.x = n[0], i.y = n[1]);
- }
- }), e.enableMouseAct(e.actShape);
- }), t.lineEntityInc.adds.forEach((e) => {
- e.enableMouseAct(e.actShape);
- }), t.polygonEntityInc.adds.forEach((e) => {
- e.enableMouseAct(e.actShape);
- });
- }
- diffRedraw() {
- const t = super.diffRedraw();
- return this.dragAttach(t), t;
- }
- initIncFactory() {
- super.initIncFactory(), this.incLinesFactory = Pt(
- Qt,
- this,
- (t) => {
- t.actShapeFactory = Au, t.setConfig(this.attrib);
- }
- ), this.incPointsFactory = Pt(
- Tt,
- this
- ), this.incPolygonFactory = Pt(
- Li,
- this,
- (t) => {
- t.actShapeFactory = this.autoClose ? cu : du, t.setConfig(this.attrib);
- }
- );
- }
- enterEditMode(t) {
- this._leaveEditMode && this._leaveEditMode(), this._leaveEditMode = Lr(
- {
- ...t,
- closeAutoQuit: !0,
- tree: this.container,
- autoAdd: !1,
- autoClose: this.autoClose,
- config: this.attrib,
- changePolygon: (e) => {
- this.editPolygonId.value = e;
- },
- quitHandler: () => {
- t.quitHandler && t.quitHandler();
- }
- },
- this.shape
- );
- }
- leaveEditMode() {
- this._leaveEditMode && this._leaveEditMode();
- }
- destory() {
- this.leaveEditMode(), super.destory();
- }
- }
- class uu extends ie {
- constructor(t) {
- for (const i in t.types)
- t.data[i] = t.data[i] || [];
- for (const i in t.data)
- i in t.types || delete t.data[i];
- super({
- name: "container",
- attrib: { id: "0", data: t.data },
- ...t
- }), this.entrys = {}, this.incFactorys = {}, this.constant = Yd(), this.config = t, this.container = this;
- const { dom: e } = this.config;
- this.stage = new Ii.Stage({
- container: e,
- width: e.offsetWidth,
- height: e.offsetHeight
- });
- }
- initShape() {
- return new _r();
- }
- init() {
- this.initIncFactory(), super.init(), this.mount(this.stage), this.mounted();
- }
- initIncFactory() {
- const t = this.config.types;
- for (const e in t)
- this.incFactorys[e] = Pt(
- t[e],
- this,
- (i) => {
- const n = i;
- this.entrys[e] || (this.entrys[e] = []), this.entrys[e].push(n), n.bus.on("destroyed", () => {
- const r = this.entrys[e].indexOf(n);
- ~r && this.entrys[e].splice(r, 1);
- });
- }
- );
- }
- diffRedraw() {
- const t = this.attrib.data, e = {};
- for (const i in t)
- i in this.incFactorys && (e[i] = this.incFactorys[i](t[i]));
- return e;
- }
- initReactive() {
- return super.initReactive("sync");
- }
- // 临时绘制
- tempDraw(...t) {
- const e = t.map((i) => i.teleport);
- return t.forEach((i) => {
- i.mount(this.tempLayer);
- }), () => {
- t.forEach((i, n) => {
- i.mount(e[n]);
- });
- };
- }
- getPixelFromStage(t) {
- const e = be(this.stage, !0), { x: i, y: n } = e.point({ x: t[0], y: t[1] });
- return [i, n];
- }
- getRealFromStage(t) {
- const e = be(this.stage, !0).invert(), { x: i, y: n } = e.point({ x: t[0], y: t[1] });
- return [i, n];
- }
- setCursor(t) {
- return t = ["move", "inherit", "pointer"].includes(t) ? t : t ? `url("${t}"), auto` : "inherit", this.config.dom.style.cursor = t, this.prevCursor = t, () => {
- this.prevCursor === t && (this.config.dom.style.cursor = "inherit", this.prevCursor = "inherit");
- };
- }
- getSameLevelData(t) {
- const e = this.attrib.data;
- for (const i in e)
- if (Array.isArray(e[i]) && ~e[i].indexOf(t.attrib))
- return e[i];
- }
- updateViewMat(t) {
- const e = new j(), i = new ci(), n = new j();
- t.decompose(e, i, n);
- const r = ["XYZ", "YZX", "ZXY", "XZY", "YXZ", "ZYX"];
- let a = new zi();
- for (let l = 0; l < r.length; l++) {
- a.setFromQuaternion(i, r[l]);
- const A = Math.abs(Se.radToDeg(a.z) % 90);
- if (Math.abs(A) < 5)
- break;
- }
- a.setFromQuaternion(i, "XYZ");
- const o = a.z, h = this.stage.scale();
- this.stage.scale({ x: n.x, y: n.y }), this.stage.position({ x: e.x, y: e.y }), this.stage.rotation(Se.radToDeg(o)), Math.abs(h.x - n.x) < 1e-3 && Math.abs(h.y - n.y) < 1e-3 || this.redraw(), this.shape.batchDraw(), this.constant.updateConstantScale(Math.min(n.x, n.y)), this.bus.emit("viewChange", {
- mat: be(this.shape, !0),
- size: [this.stage.width(), this.stage.height()]
- });
- }
- }
- const fu = () => {
- const s = new Ni({
- radius: 3,
- fill: "red"
- }), t = () => {
- const [e] = Gt(s, [1, 1]);
- s.scale({ x: e, y: e });
- };
- return {
- getSize: () => [3, 3],
- shape: s,
- common() {
- },
- setData(e) {
- t(), s.position(e), e.rotate && s.rotate(e.rotate);
- }
- };
- }, gh = {}, gu = (s, t) => {
- gh[s] = t;
- }, wn = class wn extends ie {
- constructor(t) {
- t.zIndex = t.zIndex || 5, t.name = t.name || wn.namespace + t.attrib.id, super(t), this.showLabel = !1;
- }
- setShowLabel(t) {
- this.showLabel = t, this.diffRedraw();
- }
- initShape() {
- const t = gh[this.attrib.type] || fu;
- return this.actShape = t(this.attrib, this), this.actShape.shape;
- }
- diffRedraw() {
- this.actShape.setData(this.attrib);
- }
- mounted() {
- super.mounted(), this.actShape.common(null);
- }
- };
- wn.namespace = "poi";
- let pn = wn;
- class p1 extends pn {
- mounted() {
- super.enableMouseAct(this.actShape), this.bus.on("shapeStatusChange", (t) => {
- t.type === "click" && (t.current === "active" ? this.container.bus.emit("active", { active: !0, entity: this }) : this.container.bus.emit("active", { active: !1, entity: this }));
- }), super.enableDrag({
- readyHandler: () => {
- this.container.bus.emit("dataChangeBefore");
- },
- moveHandler: (t) => {
- this.attrib.x = t[0], this.attrib.y = t[1];
- },
- endHandler: () => {
- this.container.bus.emit("dataChangeAfter");
- }
- }), super.mounted();
- }
- del() {
- const t = this.container.getSameLevelData(this);
- t && t.splice(t.indexOf(this.attrib), 1), this.container.bus.emit("dataChange");
- }
- copy(t = {}) {
- VA({
- ...t,
- entity: this,
- size: this.actShape.getSize(),
- factoryAttrib: (e) => ({
- x: e[0],
- y: e[1],
- type: this.attrib.type
- })
- }), this.container.bus.emit("dataChange");
- }
- }
- const pu = (s, t) => (i, n, r = !1) => {
- const a = document.createElement("div");
- a.style.width = "100%", a.style.height = "100%";
- const o = new uu({
- dom: a,
- readonly: r,
- types: s,
- data: n,
- reactive: !r
- });
- o.init();
- const h = {};
- if (t)
- for (const u in t) {
- const f = t[u];
- f.setTree(o), h[u] = f;
- }
- let l = null;
- const A = (u) => {
- a.parentElement && a.parentElement.removeChild(a), u.appendChild(a), a.style.width = "100%", a.style.height = "100%", o.stage.width(a.offsetWidth), o.stage.height(a.offsetHeight), l = u;
- };
- return i ? A(i) : (a.style.width = "300px", a.style.height = "300px"), {
- types: s,
- tree: o,
- setData(u) {
- o.setAttrib({ data: u });
- },
- getData() {
- return o.attrib.data;
- },
- destory() {
- for (const u in t) {
- const f = t[u];
- f.destory && f.destory();
- }
- o.destory();
- },
- mountedDom: l,
- mount: A,
- ...h
- };
- }, Je = new Jt(), yu = (s, t) => {
- Je.identity().translate(-t[0], -t[1]);
- const e = new X(s[0], s[1]).applyMatrix3(Je), i = new X(s[2], s[3]).applyMatrix3(Je);
- return [e.x, e.y, i.x, i.y];
- }, mu = (s, t, e) => {
- Je.identity().translate(-t[0], -t[1]).scale(e, e).translate(t[0], t[1]);
- const i = new X(s[0], s[1]).applyMatrix3(Je), n = new X(s[2], s[3]).applyMatrix3(Je);
- return [i.x, i.y, n.x, n.y];
- };
- class vu {
- constructor(t = {}) {
- this.bound = t.bound, this.props = t, this.props.move = t.move || !1, this.props.wheel = t.wheel || !1;
- }
- disableMove() {
- this.props.move = !1, this.dragDestory && this.dragDestory();
- }
- enableMove(t) {
- if (this.disableMove(), this.props.move = !0, !this.tree)
- return;
- const { stage: e } = this.tree;
- this.dragDestory = yr(
- e,
- {
- readyHandler: () => ({
- tf: be(e, !0).invert(),
- initBound: this.bound
- }),
- moveHandler: (i, { tf: n, initBound: r }) => {
- const a = n.point({ x: i[0], y: i[1] }), o = [a.x, a.y];
- let h = yu(r, o);
- if (t) {
- const l = t(h, o);
- if (typeof l != "boolean")
- h = l;
- else if (!l)
- return;
- }
- this.setBound(h);
- }
- },
- !1
- );
- }
- disableWheel() {
- this.props.wheel = !1, this.wheelDestory && this.wheelDestory();
- }
- enableWheel(t) {
- if (this.disableWheel(), this.props.wheel = !0, !this.tree)
- return;
- const {
- stage: e,
- config: { dom: i }
- } = this.tree, n = (r) => {
- const a = 1 + r.deltaY / 1e3, o = e.getRelativePointerPosition(), h = [o.x, o.y];
- let l = mu(this.bound, h, a);
- if (t) {
- const A = t(l, h, a);
- if (typeof A != "boolean")
- l = A;
- else if (!A)
- return;
- }
- this.bound = l, this.update();
- };
- i.addEventListener("wheel", n), this.wheelDestory = () => i.removeEventListener("wheel", n);
- }
- setBound(t) {
- this.bound = t, this.update();
- }
- setSize(t, e) {
- this.tree.stage.width(t), this.tree.stage.height(e);
- }
- setTree(t) {
- if (this.tree = t, !this.bound) {
- const e = t.stage.getSize(), i = t.stage.position();
- this.bound = [i.x, i.y, e.width, e.height];
- }
- this.props.move && this.enableMove(), this.props.wheel && this.enableWheel();
- }
- update() {
- const { stage: t } = this.tree, e = this.bound[2] - this.bound[0], i = this.bound[3] - this.bound[1], n = t.width() / e, r = t.height() / i, a = -this.bound[0] * n, o = -this.bound[1] * r;
- t.scale({ x: n, y: r }), t.position({ x: a, y: o }), this.tree.redraw(), this.tree.bus.emit("viewChange", {
- mat: t.getTransform(),
- size: [t.width(), t.height()]
- }), this.tree.shape.batchDraw();
- }
- }
- var ph = {};
- Object.defineProperty(ph, "__esModule", { value: !0 });
- var _u = function(t) {
- for (var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, i = t.length, n = e ^ i, r = 0, a = void 0; i >= 4; )
- a = t.charCodeAt(r) & 255 | (t.charCodeAt(++r) & 255) << 8 | (t.charCodeAt(++r) & 255) << 16 | (t.charCodeAt(++r) & 255) << 24, a = (a & 65535) * 1540483477 + (((a >>> 16) * 1540483477 & 65535) << 16), a ^= a >>> 24, a = (a & 65535) * 1540483477 + (((a >>> 16) * 1540483477 & 65535) << 16), n = (n & 65535) * 1540483477 + (((n >>> 16) * 1540483477 & 65535) << 16) ^ a, i -= 4, ++r;
- switch (i) {
- case 3:
- n ^= (t.charCodeAt(r + 2) & 255) << 16;
- case 2:
- n ^= (t.charCodeAt(r + 1) & 255) << 8;
- case 1:
- n ^= t.charCodeAt(r) & 255, n = (n & 65535) * 1540483477 + (((n >>> 16) * 1540483477 & 65535) << 16);
- }
- return n ^= n >>> 13, n = (n & 65535) * 1540483477 + (((n >>> 16) * 1540483477 & 65535) << 16), n ^= n >>> 15, n >>> 0;
- }, xu = _u, bu = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(s) {
- return typeof s;
- } : function(s) {
- return s && typeof Symbol == "function" && s.constructor === Symbol && s !== Symbol.prototype ? "symbol" : typeof s;
- };
- function wu(s) {
- var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 2, e = /* @__PURE__ */ new Set(), i = JSON.stringify(s, function(n, r) {
- return (typeof r > "u" ? "undefined" : bu(r)) === "object" && r !== null ? e.has(r) ? void 0 : e.add(r) && r : r;
- }, t);
- return e = null, i;
- }
- var qa = Object.assign || function(s) {
- for (var t = 1; t < arguments.length; t++) {
- var e = arguments[t];
- for (var i in e)
- Object.prototype.hasOwnProperty.call(e, i) && (s[i] = e[i]);
- }
- return s;
- };
- function Su(s) {
- if (Array.isArray(s)) {
- for (var t = 0, e = Array(s.length); t < s.length; t++)
- e[t] = s[t];
- return e;
- } else
- return Array.from(s);
- }
- var yh = {
- // StateNode => { Chunks, Children }
- toRecord: function(t) {
- return {
- chunks: [qa({}, t, { children: void 0 })],
- children: t.children
- };
- },
- // { Chunks, Children } => StateNode
- fromRecord: function(t) {
- var e = t.chunks, i = t.children;
- return qa({}, e[0], { children: i });
- }
- }, Cu = function s(t, e) {
- for (var i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null, r = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : -1, a = i.findIndex(function(v) {
- var _ = v.match;
- return _(t);
- }), o = i[a] || yh, h = o.toRecord(t), l = h.chunks, A = h.children, u = A, f = [], c = 0; c < l.length; c++) {
- var d = wu(l[c], 0), p = xu(d);
- f.push(p), e[p] = d;
- }
- if (r !== -1 && Array.isArray(n && n.children)) {
- var m = [].concat(Su(n.children));
- return m[r] = s(u[r], e, i), { hashes: f, ruleIndex: a, children: m };
- } else
- return {
- hashes: f,
- ruleIndex: a,
- children: A && A.map(function(v) {
- return s(v, e, i);
- })
- };
- }, Mu = function s(t, e) {
- var i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], n = t.hashes, r = t.ruleIndex, a = t.children, o = n.map(function(l) {
- return JSON.parse(e[l]);
- }), h = i[r] || yh;
- return h.fromRecord({
- chunks: o,
- children: a && a.map(function(l) {
- return s(l, e, i);
- })
- });
- }, Pu = /* @__PURE__ */ function() {
- function s(t, e) {
- for (var i = 0; i < e.length; i++) {
- var n = e[i];
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(t, n.key, n);
- }
- }
- return function(t, e, i) {
- return e && s(t.prototype, e), i && s(t, i), t;
- };
- }();
- function Eu(s, t) {
- if (!(s instanceof t))
- throw new TypeError("Cannot call a class as a function");
- }
- var Qa = function() {
- }, Fu = function() {
- function s() {
- var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
- initialState: void 0,
- rules: [],
- delay: 50,
- maxLength: 100,
- onChange: Qa,
- useChunks: !0
- };
- Eu(this, s), this.rules = t.rules || [], this.delay = t.delay || 50, this.maxLength = t.maxLength || 100, this.useChunks = t.useChunks === void 0 ? !0 : t.useChunks, this.onChange = Qa, this.$index = -1, this.$records = [], this.$chunks = {}, this.$pending = {
- state: null,
- pickIndex: null,
- onResolves: [],
- timer: null
- }, this.$debounceTime = null, t.initialState !== void 0 && this.pushSync(t.initialState), t.onChange && (this.onChange = t.onChange);
- }
- return Pu(s, [{
- key: "get",
- // void => State
- value: function() {
- var e = this.$records[this.$index], i = void 0;
- return e ? this.useChunks ? i = Mu(e, this.$chunks, this.rules) : i = e : i = null, this.onChange(i), i;
- }
- // (State, number?) => History
- }, {
- key: "pushSync",
- value: function(e) {
- var i = this, n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : -1, r = this.$records[this.$index] || null, a = this.useChunks ? Cu(e, this.$chunks, this.rules, r, n) : e;
- this.$index++, this.$records[this.$index] = a;
- for (var o = this.$index + 1; o < this.$records.length; o++)
- this.$records[o] = null;
- return this.$index >= this.maxLength && (this.$records[this.$index - this.maxLength] = null), this.$pending.timer && (clearTimeout(this.$pending.timer), this.$pending.state = null, this.$pending.pickIndex = null, this.$pending.timer = null, this.$debounceTime = null, this.$pending.onResolves.forEach(function(h) {
- return h(i);
- }), this.$pending.onResolves = []), this.onChange(e), this;
- }
- // (State, number?) => Promise<History>
- }, {
- key: "push",
- value: function(e) {
- var i = this, n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : -1, r = +/* @__PURE__ */ new Date(), a = function() {
- i.$pending.state = e, i.$pending.pickIndex = n, i.$debounceTime = r;
- var h = new Promise(function(l, A) {
- i.$pending.onResolves.push(l), i.$pending.timer = setTimeout(function() {
- i.pushSync(i.$pending.state, i.$pending.pickIndex);
- }, i.delay);
- });
- return h;
- };
- return this.$pending.timer === null ? a() : r - this.$debounceTime < this.delay ? (clearTimeout(this.$pending.timer), this.$pending.timer = null, a()) : Promise.reject(new Error("Invalid push ops"));
- }
- // void => History
- }, {
- key: "undo",
- value: function() {
- return this.hasUndo && this.$index--, this;
- }
- // void => History
- }, {
- key: "redo",
- value: function() {
- return this.hasRedo && this.$index++, this;
- }
- // void => History
- }, {
- key: "reset",
- value: function() {
- var e = this;
- return this.$index = -1, this.$records.forEach(function(i) {
- }), Object.keys(this.$chunks).forEach(function(i) {
- e.$chunks[i] = null;
- }), this.$records = [], this.$chunks = {}, clearTimeout(this.$pending.timer), this.$pending = {
- state: null,
- pickIndex: null,
- onResolves: [],
- timer: null
- }, this.$debounceTime = null, this;
- }
- }, {
- key: "hasRedo",
- get: function() {
- if (this.$index === this.$records.length - 1)
- return !1;
- for (var e = !1, i = this.$index + 1; i < this.$records.length; i++)
- this.$records[i] !== null && (e = !0);
- return e;
- }
- // : boolean
- }, {
- key: "hasUndo",
- get: function() {
- var e = Math.max(this.$records.length - this.maxLength, 0);
- return this.$index > e;
- }
- // : number
- }, {
- key: "length",
- get: function() {
- return Math.min(this.$records.length, this.maxLength);
- }
- }]), s;
- }(), ku = ph.History = Fu;
- class y1 {
- constructor() {
- this.state = ti({
- hasUndo: !1,
- hasRedo: !1
- }), this.disabled = !0;
- }
- setDisable(t) {
- this.disabled = t, t ? this.state.hasRedo = this.state.hasUndo = !1 : this.syncState();
- }
- syncState() {
- !this.history || this.disabled || (this.state.hasRedo = this.history.hasRedo, this.state.hasUndo = this.history.hasUndo);
- }
- setTree(t) {
- this.tree = t, this.history = new ku(), this.setDisable(!1), this.push(this.tree.attrib), this.timelyPush();
- }
- undo() {
- !this.disabled && this.history.hasUndo && (this.history.undo(), this.tree.setAttrib(this.history.get()), this.syncState());
- }
- redo() {
- !this.disabled && this.history.hasRedo && (this.history.redo(), this.tree.setAttrib(this.history.get()), this.syncState());
- }
- push(t) {
- const e = this.history.get();
- e && delete e.children, di(t, e) && (t = JSON.parse(JSON.stringify(t)), this.history.pushSync(t), this.syncState());
- }
- clear() {
- this.history.reset();
- }
- timelyPush() {
- this.timelyPushDestory && this.timelyPushDestory();
- const t = () => {
- this.push(this.tree.attrib);
- }, e = () => {
- this.setDisable(!0);
- }, i = () => {
- this.setDisable(!1), t();
- };
- this.tree.bus.on("dataChange", t), this.tree.bus.on("dataChangeBefore", e), this.tree.bus.on("dataChangeAfter", i), this.timelyPushDestory = () => {
- this.tree.bus.off("dataChange", t), this.tree.bus.off("dataChangeBefore", e), this.tree.bus.off("dataChangeAfter", i), this.timelyPushDestory = null;
- };
- }
- }
- class m1 {
- constructor(t = {}) {
- this.clipMat = new ot(), this.bus = Tr(), this.props = t, this.props.move = t.move || !1, this.props.wheel = t.wheel || !1, this.cameraMat = new ot(), this.retainScale = t.retainScale || !1, t.size && this.setSize(t.size[0], t.size[1]), t.bound && this.setBound(t.bound, t.padding);
- }
- disableMove() {
- this.props.move = !1, this.dragDestory && this.dragDestory();
- }
- enableMove() {
- if (this.disableMove(), this.props.move = !0, !this.tree)
- return;
- const { stage: t } = this.tree;
- this.dragDestory = yr(
- t,
- {
- readyHandler: () => this.cameraMat.clone(),
- moveHandler: (e, i) => {
- const n = this.clipMat.clone().multiply(i).invert(), r = new j(e[0], e[1], 0).applyMatrix4(n);
- this.move([r.x, r.y], i);
- }
- },
- !1
- );
- }
- disableWheel() {
- this.props.wheel = !1, this.wheelDestory && this.wheelDestory();
- }
- enableWheel() {
- if (this.disableWheel(), this.props.wheel = !0, !this.tree)
- return;
- const {
- config: { dom: t }
- } = this.tree, e = (i) => {
- const n = 1 - i.deltaY / 1e3, r = new j(i.offsetX, i.offsetY, 0).applyMatrix4(
- this.clipMat.clone().multiply(this.cameraMat).invert()
- );
- this.scale([r.x, r.y], n);
- };
- t.addEventListener("wheel", e), this.wheelDestory = () => t.removeEventListener("wheel", e);
- }
- move(t, e = this.cameraMat) {
- this.mutMat(
- new ot().setPosition(t[0], t[1], 0),
- e
- );
- }
- scale(t, e, i = this.cameraMat) {
- this.mutMat(
- new ot().makeTranslation(t[0], t[1], 0).multiply(
- new ot().makeScale(e, e, 1).multiply(new ot().makeTranslation(-t[0], -t[1], 0))
- ),
- i
- );
- }
- rotate(t, e, i = this.cameraMat) {
- this.mutMat(
- new ot().makeTranslation(t[0], t[1], 0).multiply(
- new ot().makeRotationAxis(new j(0, 0, 1), e).multiply(new ot().makeTranslation(-t[0], -t[1], 0))
- ),
- i
- );
- }
- mutMat(t, e = this.cameraMat) {
- t instanceof ot ? e = e.clone().multiply(t) : e = e.multiply(new ot().fromArray(t)), this.setCameraMat(e), this.bus.emit("cameraChange", this.cameraMat.toArray());
- }
- setCameraMat(t) {
- t instanceof ot ? this.cameraMat = t : this.cameraMat.fromArray(t), this.update();
- }
- autoBound(t, e = [".adsord-point"]) {
- const i = e.flatMap(
- (r) => this.tree.stage.find(r).map((a) => a.position())
- );
- if (i.length < 2)
- return;
- const n = [
- Number.MAX_VALUE,
- Number.MAX_VALUE,
- -Number.MAX_VALUE,
- -Number.MAX_VALUE
- ];
- for (const r of i)
- n[0] = Math.min(n[0], r.x), n[1] = Math.min(n[1], r.y), n[2] = Math.max(n[2], r.x), n[3] = Math.max(n[3], r.y);
- this.setBound(n, t);
- }
- setBound(t, e) {
- e = Array.isArray(e) ? e : [e || 0, e || 0], e.length === 1 && e.push(e[0]);
- const i = t[2] - t[0], n = t[3] - t[1], r = this.tree.stage.width(), a = this.tree.stage.height(), o = this.tree.stage.width() - e[0] * 2, h = this.tree.stage.height() - e[1] * 2;
- let l = o / i, A = h / n;
- if (this.retainScale) {
- const d = Math.min(l, A);
- l = d, A = d;
- }
- const u = (r - i * l) / 2 - t[0] * l, f = (a - n * A) / 2 - t[1] * A, c = new ot().scale(new j(l, A, 1)).setPosition(u, f, 0);
- this.bound = t, this.padding = e, this.clipMat = c, this.update();
- }
- updateSelfBound() {
- this.bound && this.setBound(this.bound, this.padding);
- }
- setRetainScale(t) {
- this.retainScale = t, this.updateSelfBound();
- }
- setSize(t, e) {
- this.tree.stage.width(t), this.tree.stage.height(e), this.updateSelfBound();
- }
- setTree(t) {
- this.tree = t, this.props.move && this.enableMove(), this.props.wheel && this.enableWheel();
- }
- update() {
- this.tree.updateViewMat(this.clipMat.clone().multiply(this.cameraMat));
- }
- }
- const Du = (s, t) => {
- const e = t.parent, i = { width: 43, height: 44 }, n = new Ci({
- data: "M22 44C32.6667 33.891 38 25.891 38 20C38 11.1634 30.8366 4 22 4C13.1634 4 6 11.1634 6 20C6 25.891 11.3333 33.891 22 44Z",
- strokeScaleEnabled: !0,
- stroke: "#ffffff",
- strokeWidth: 1
- }), r = new Ci({
- fill: "#fff",
- data: "M22 30C27.5228 30 32 25.5228 32 20C32 14.4772 27.5228 10 22 10C16.4772 10 12 14.4772 12 20C12 25.5228 16.4772 30 22 30Z"
- }), a = new Ci({
- fill: "#409EFF",
- offset: {
- x: -5,
- y: -5
- },
- data: "M20.5143 12.213C20.7983 12.497 20.7983 12.9575 20.5143 13.2415L15.2727 18.4831L11.8494 15.0597C11.5654 14.7757 11.5654 14.3152 11.8494 14.0312C12.1334 13.7472 12.5939 13.7472 12.8779 14.0312L15.2727 16.426L19.4857 12.213C19.7698 11.929 20.2302 11.929 20.5143 12.213Z"
- }), o = new Nt({
- name: "anchor-move"
- }), h = new Ni({
- name: "anchor-move",
- radius: Math.min(i.width, i.height) / 2,
- fill: "rgba(0, 0, 0, 0)",
- offset: { x: -i.width / 2, y: -i.height / 2 }
- }), l = On();
- Mt.radius = 5, Mt.hitStrokeWidth = Mt.strokeWidth = 4, l.shape.name("anchor-point");
- const A = new dn({
- name: "text",
- text: "1",
- fontFamily: "Calibri",
- fontSize: 12,
- padding: 5,
- offsetY: -8,
- fill: "#000"
- }), u = new Oo({
- visible: !1,
- opacity: 1,
- name: "label",
- offsetX: -i.width / 2,
- offsetY: -6
- });
- o.add(A, u, h);
- const f = new dn({
- name: "text",
- text: s.title || `P${s.id}`,
- fontFamily: "Inter",
- fontSize: 12,
- padding: 8,
- fill: "#303133"
- });
- u.add(
- new To({
- name: "tag",
- fill: "rgba(255, 255, 255, 1)",
- pointerDirection: "down",
- pointerWidth: 8,
- pointerHeight: 8,
- lineJoin: "round",
- shadowColor: "black",
- cornerRadius: 2,
- opacity: 1,
- shadowBlur: 10,
- shadowOffsetX: 10,
- shadowOffsetY: 10,
- shadowOpacity: 0.5
- }),
- f
- );
- const c = new Nt();
- c.add(n, r, a, o), c.x(-i.width / 2), c.y(-i.height);
- const d = new Nt();
- return d.add(c, l.shape), {
- shape: d,
- common() {
- n.fill(s.rtk ? "rgba(230, 162, 60, 1)" : "#409EFF"), a.fill(s.rtk ? "rgba(230, 162, 60, 1)" : "#409EFF"), l.common(), u.visible(!1);
- },
- hover: () => {
- u.visible(!0), s.rtk || (n.fill("#409EFF"), a.fill("#409EFF"));
- },
- setData(m) {
- let [v, _] = Gt(d, [1, 1]);
- d.scale({ x: v, y: _ }), d.x(m[0]), d.y(m[1]), f.text(t.attrib.title || `P${s.id}`), ~t.editPolygonNdx ? (A.text((t.editPolygonNdx + 1).toString()).visible(!0), A.offsetX(-h.width() / 2 + A.width() / 2), l.shape.visible(!0), a.visible(!1)) : (A.visible(!1), l.shape.visible(!1), a.visible(e.status.selectPoiIds.includes(s.id)));
- },
- draging() {
- ~t.editPolygonNdx && (n.fill("#e0403c"), a.fill("#e0403c"));
- }
- };
- };
- class Iu extends Tt {
- constructor() {
- super(...arguments), this.actShape = null;
- }
- get editPolygonNdx() {
- const t = this.parent;
- return t.status.editPolygonId ? ri(
- t.attrib,
- t.status.editPolygonId
- ).map(({ id: i }) => i).indexOf(this.attrib.id) : -1;
- }
- init() {
- this.actShapeFactory = Du, super.init(), this.enableMouseAct(this.actShape);
- }
- initReactive() {
- const t = this.parent;
- return this.bus.on("shapeStatusChange", ({ current: e, type: i }) => {
- e === "active" && i === "click" && t.bus.emit("clickPoint", this.attrib);
- }), mr(
- super.initReactive(),
- fe(
- () => this.editPolygonNdx,
- (e, i, n) => {
- if (!~e || this.attrib.rtk)
- return n(() => {
- });
- const r = this.shape.findOne(".anchor-move");
- let a = null;
- r.on("mouseenter.anchor", () => {
- a && a(), a = this.container.setCursor("move");
- }), r.on("mouseleave.anchor", () => {
- a && a(), a = null;
- }), ln(this, {
- readyHandler: (o) => [o.x, o.y],
- moveHandler: (o, h) => {
- ~this.editPolygonNdx && (o.x = h[0], o.y = h[1]);
- }
- }), n(() => {
- r.off("mouseenter.anchor mouseleave.anchor"), a && a(), this.disableDrag();
- });
- },
- { immediate: !0 }
- ),
- Sn(
- () => {
- t.status.lightPointId === this.attrib.id ? this.bus.emit("statusChange", { hover: !0 }) : this.bus.emit("statusChange", null);
- },
- { flush: "post" }
- )
- );
- }
- }
- const Tu = () => {
- const s = Nn({
- autoClose: !0
- }), t = s.shape.findOne(".polygon-line");
- return {
- ...s,
- common() {
- t.fill("rgba(0, 0, 0, 0)"), s.closeLine.common();
- },
- hover() {
- t.fill("rgba(230, 162, 60, 0.3)"), s.closeLine.hover();
- },
- active() {
- t.fill("rgba(64, 158, 255, 0.3)"), s.closeLine.active();
- }
- };
- };
- class Lu extends Li {
- constructor() {
- super(...arguments), this.actShapeFactory = Tu;
- }
- init() {
- super.init(), this.enableMouseAct(this.actShape);
- }
- initReactive() {
- const t = (i) => {
- this.bus.emit("statusChange", { [i]: !0 });
- };
- t("common");
- const e = this.parent;
- return this.bus.on("shapeStatusChange", ({ current: i, type: n }) => {
- e.status.editPolygonId || (i === "active" ? n === "click" && e.bus.emit("activePolygonId", this.attrib.id) : e.status.lightPolygonId === this.attrib.id ? n === "click" && e.bus.emit("activePolygonId", null) : t(i));
- }), mr(
- super.initReactive(),
- fe(
- () => [e.status.editPolygonId, e.status.lightPolygonId],
- ([i, n]) => {
- i === this.attrib.id ? t("active") : n === this.attrib.id ? t("hover") : t("common");
- },
- { flush: "post" }
- )
- );
- }
- }
- const Ru = (s) => ({
- rtk: !1,
- title: "",
- x: s[0],
- y: s[1]
- }), Ou = (s, t) => {
- const e = t.parent, i = ui(), n = () => !!(e.status.editPolygonId && hh(
- e.attrib,
- e.status.editPolygonId
- ).some(({ id: o }) => o === s.id)), r = () => {
- n() ? i.active() : i.common();
- };
- return {
- shape: i.shape,
- setData(a) {
- i.setData(a), r();
- },
- common: r
- };
- };
- class Nu extends Ri {
- constructor() {
- super(...arguments), this.status = ti({
- selectPoiIds: [],
- newModel: !1
- });
- }
- removePolygon(t) {
- const e = this.attrib.polygons.findIndex(({ id: r }) => r === t);
- if (!~e)
- return;
- const i = this.attrib.polygons[e].lineIds;
- let n = [];
- for (; i.length; ) {
- const r = this.attrib.lines.findIndex(
- ({ id: a }) => a === i[0]
- );
- ~r && (n.push(...this.attrib.lines[r].pointIds), this.attrib.lines.splice(r, 1)), i.shift();
- }
- for (n = Array.from(new Set(n)); n.length; ) {
- const r = this.attrib.points.findIndex(
- ({ id: a }) => a === n[0]
- );
- ~r && !this.attrib.points[r].rtk && this.attrib.points.splice(r, 1), n.shift();
- }
- this.attrib.polygons.splice(e, 1);
- }
- initIncFactory() {
- super.initIncFactory(), this.incPointsFactory = Pt(Iu, this), this.incLinesFactory = Pt(
- Qt,
- this,
- (t) => {
- t.setConfig(this.attrib), t.actShapeFactory = Ou;
- }
- ), this.incPolygonFactory = Pt(Lu, this, (t) => {
- t.setConfig(this.attrib);
- });
- }
- editPolygon(t) {
- return this.endEditPolygon && this.endEditPolygon(), this.status.newModel = !t, this.endEditPolygon = Lr(
- {
- polygonId: t,
- pointAttribFactory: Ru,
- canOper: (e, i) => {
- if (!e.name.includes(Tt.namespace))
- return !0;
- const n = ri(
- this.attrib,
- this.status.editPolygonId
- ), r = e.attrib.id, a = n.some(({ id: o }) => o === r);
- return !!So(
- i,
- (o) => o.name() === (a ? "anchor-point" : "anchor-move")
- );
- },
- quitHandler: () => {
- this.status.newModel = !1, this.bus.emit("penEndHandler"), this.endEditPolygon = null;
- },
- canDelPoint: (e) => !e.rtk,
- quotePoint: (e) => e.rtk,
- closeAutoQuit: !0,
- tree: this.container,
- autoAdd: !1,
- autoClose: !0,
- config: this.attrib,
- changePolygon: (e) => {
- this.status.editPolygonId = e;
- }
- },
- this.shape
- ), this.endEditPolygon;
- }
- destory() {
- this.endEditPolygon && this.endEditPolygon(), super.destory();
- }
- }
- function Gu(s) {
- const t = Bu();
- for (let e = 0, i = s.length; e < i; ++e)
- zu(t, s[e]);
- return t;
- }
- function Bu() {
- return [1 / 0, 1 / 0, -1 / 0, -1 / 0];
- }
- function zu(s, t) {
- t[0] < s[0] && (s[0] = t[0]), t[0] > s[2] && (s[2] = t[0]), t[1] < s[1] && (s[1] = t[1]), t[1] > s[3] && (s[3] = t[1]);
- }
- const Uu = `<svg width="96" height="96" viewBox="0 0 96 96" fill="none" xmlns="http://www.w3.org/2000/svg">
- <path
- d="M72 48C72 61.2548 61.2548 72 48 72C34.7452 72 24 61.2548 24 48C24 34.7452 34.7452 24 48 24C61.2548 24 72 34.7452 72 48Z"
- fill="white" />
- <path
- d="M38 58.2759L48 55.2017L58 58.2759L48 35L38 58.2759ZM48 37.5333L56.2281 56.685L48 54.1555V37.5333Z"
- fill="black" />
- <path
- d="M41.0838 11.1168L40.0239 11.4601L41.4821 14.7157L44.326 13.5088V16.0501H47.698V1.42212H44.326V4.62812H40.854V7.95812H44.326V9.95863C43.082 10.4198 41.9096 10.8493 41.0838 11.1168Z"
- fill="white" />
- <path
- d="M55.7856 5.90817L53.4853 3.10772L52.7077 3.8062C52.2849 4.18598 51.753 4.61099 51.17 5.03535V1.43612H47.784V12.6701C47.784 13.5379 47.8745 14.4323 48.4211 15.0717C49.0134 15.7645 49.8846 15.8821 50.66 15.8821H52.746C53.2147 15.8821 53.6913 15.8052 54.1254 15.5671C54.5733 15.3215 54.888 14.953 55.1053 14.5224C55.5006 13.7389 55.6219 12.635 55.6906 11.3515L55.7358 10.5057L54.9089 10.3219C54.6839 10.2719 54.2525 10.072 54.018 9.89612L52.4998 8.7575L52.4189 10.6535C52.3763 11.6524 52.3375 12.2352 52.2795 12.5801H51.17V8.87969C52.4714 8.15697 53.8241 7.34512 54.9329 6.53282L55.7856 5.90817Z"
- fill="white" />
- <path
- d="M41.3921 12.0681C42.3861 11.7461 43.8561 11.2001 45.3261 10.6541V6.95812H41.8541V5.62812H45.3261V2.42212H46.6981V15.0501H45.3261V11.9981L41.9941 13.4121L41.3921 12.0681ZM53.3761 4.55012L54.3421 5.72612C53.1381 6.60812 51.6121 7.50412 50.1701 8.28812V12.6981C50.1701 13.4541 50.2681 13.5801 50.8281 13.5801C51.0941 13.5801 52.3121 13.5801 52.6201 13.5801C53.2361 13.5801 53.3201 12.9921 53.4181 10.6961C53.7541 10.9481 54.3141 11.2141 54.6921 11.2981C54.5521 13.9161 54.2021 14.8821 52.7461 14.8821C52.4381 14.8821 50.9401 14.8821 50.6601 14.8821C49.2181 14.8821 48.7841 14.3921 48.7841 12.6701V2.43612H50.1701V6.91612C51.3601 6.17412 52.5501 5.29212 53.3761 4.55012Z"
- fill="black" />
- </svg>`;
- gu("compass", (s, t) => {
- const e = Ml({
- ...Cl(Uu),
- fixed: !0
- });
- return {
- ...e,
- setData(i) {
- const n = be(e.shape).copy().invert(), r = t.container.stage.width(), a = n.point({ x: r - 60, y: 120 });
- e.setData({ ...i, ...a });
- }
- };
- });
- class Hu extends ie {
- constructor(t) {
- t.name = t.name || "pixel-scale", t.zIndex = 1e3, !t.attrib.left && !t.attrib.right && (t.attrib.left = 10), !t.attrib.top && !t.attrib.bottom && (t.attrib.bottom = 10), super(t), this.allowable = 1e-3, this.fontSize = 12, this.padding = 4, this.getScaleUnit = (e) => Math.max(...e) * 1e4, this.getScaleText = (e) => e + "";
- }
- get height() {
- return this.fontSize + this.padding;
- }
- initShape() {
- const t = new Nt();
- return t.add(
- new Fn({
- name: "scale-line",
- points: [
- 0,
- this.height / 2,
- 0,
- this.height,
- 100,
- this.height,
- 100,
- this.height / 2
- ],
- strokeScaleEnabled: !1,
- strokeWidth: 1.5,
- stroke: "#fff"
- }),
- new dn({
- name: "scale-text",
- text: "",
- fontFamily: "Calibri",
- x: 0,
- y: 0,
- align: "center",
- fontSize: this.fontSize,
- fill: "#fff"
- })
- ), t;
- }
- setColor(t) {
- this.shape.findOne(".scale-line").stroke(t), this.shape.findOne(".scale-text").fill(t);
- }
- diffRedraw() {
- if (!this.mat || !this.pixelScale || isNaN(this.pixelScale))
- return;
- let t = 1, e, i;
- for (let c = this.attrib.minWidth; c <= this.attrib.maxWidth; c++) {
- const d = c * this.pixelScale, p = Ot(d, 10) - d;
- if (p < this.allowable && d % 5 < 1) {
- e = c, i = d;
- break;
- } else
- p < t && (e = c, i = d, t = p);
- }
- if (e === 0 || i === 0)
- return;
- const n = this.shape.findOne(".scale-line"), r = this.shape.findOne(".scale-text"), a = n.points();
- a[4] = a[6] = e, r.width(e), r.text(this.getScaleText(i));
- const o = this.container.stage;
- let h = this.attrib.left, l = this.attrib.top;
- typeof h != "number" && typeof this.attrib.right == "number" && (h = o.width() - e - this.attrib.right), typeof l != "number" && typeof this.attrib.bottom == "number" && (l = o.height() - this.height - this.attrib.bottom);
- const A = this.mat.point({ x: 1, y: 1 }), u = this.mat.point({ x: 0, y: 0 }), f = {
- x: A.x - u.x,
- y: A.y - u.y
- };
- this.shape.position(this.mat.point({ x: h, y: l })).scale(f), this.shape.draw();
- }
- setPixelScale(t, e) {
- t = t.copy().invert();
- const i = t.point({ x: 0, y: 0 }), n = t.point({ x: e[0], y: e[1] });
- this.mat = t, this.pixelScale = this.getScaleUnit([
- (n.x - i.x) / e[0],
- (n.y - i.y) / e[1]
- ]);
- }
- initReactive() {
- const t = ({ mat: e, size: i }) => {
- this.setPixelScale(e, i);
- };
- return this.container.bus.on("viewChange", t), mr(
- super.initReactive(),
- () => this.container.bus.off("viewChange", t)
- );
- }
- mounted() {
- super.mounted();
- const t = this.container.stage;
- this.setPixelScale(be(t, !0), [
- t.width(),
- t.height()
- ]), console.log(t), t.on("click", (e) => {
- console.log(
- this.container.getRealFromStage([e.evt.offsetX, e.evt.offsetY])
- );
- });
- }
- }
- const Vu = (s, t, e) => {
- let i = e == null ? void 0 : e.getView();
- const n = () => i.calculateExtent(e.getSize()), r = (h) => {
- const l = Gu([
- [h[0], h[1]],
- [h[2], h[3]]
- ]);
- i.fit(l, {
- size: e.getSize(),
- padding: [0, 0, 0, 0]
- // 根据需要调整边距
- });
- }, a = () => {
- if (t && e) {
- const h = n();
- (!s.bound || di(s.bound, h)) && (s.setSize(t.offsetWidth, t.offsetHeight), s.setBound([h[0], h[3], h[2], h[1]]));
- }
- }, o = (h) => {
- e && (i.removeEventListener("change:center", a), i.removeEventListener("change:resolution", a), e.removeEventListener("moveend", a)), i = h.getView(), i.addEventListener("change:center", a), i.addEventListener("change:resolution", a), e.addEventListener("moveend", a), e = h, a();
- };
- return s.enableMove((h) => (e && r(h), !0)), s.enableWheel((h) => (e && r(h), !0)), {
- setMap: o,
- setBoardBound: a,
- setMountDom(h) {
- t = h, a();
- },
- destory() {
- i.removeEventListener("change:center", a), i.removeEventListener("change:resolution", a), e.removeEventListener("moveend", a);
- }
- };
- };
- function $u(s, t, e) {
- const i = t.getSize();
- s.width = i[0] * e, s.height = i[1] * e, s.style.width = i[0] + "px", s.style.height = i[1] + "px";
- const n = s.getContext("2d"), r = t.getViewport().querySelector("canvas");
- return n.drawImage(r, 0, 0, s.width, s.height), s.toDataURL();
- }
- const Wu = pu(
- { polygons: Nu, compass: pn, scale: Hu },
- { bound: new vu() }
- );
- Ud(5e6);
- const v1 = (s = {}) => {
- const t = {
- id: "0",
- x: 0,
- y: 0,
- type: "compass"
- }, e = {
- id: "0",
- left: 20,
- bottom: 20,
- minWidth: 100,
- maxWidth: 150
- }, i = s.store || [
- { id: "0", points: [], polygons: [], lines: [] }
- ], n = Wu(s.dom, { polygons: i, compass: t, scale: e }, !1), r = Vu(n.bound, s.dom, s.map), a = (l = {}) => {
- l.dom && (n.mount(l.dom), r.setMountDom(l.dom)), l.map && r.setMap(l.map);
- };
- a(s);
- let o;
- const h = n.tree.entrys.scale[0];
- return h.allowable = 1e-11, h.getScaleUnit = (l) => {
- if (!s.map)
- return;
- const f = s.map.getView().getProjection().getMetersPerUnit();
- return l[0] * f;
- }, h.getScaleText = (l) => l > 1e3 ? Ot(l / 1e3, 1) + " km" : Math.floor(l) + " m", {
- raw: n,
- scale: h,
- setProps: a,
- getData() {
- return n.getData().polygons[0];
- },
- setData(l) {
- n.setData({ polygons: [l], compass: t, scale: e });
- },
- destory() {
- r.destory(), n.destory();
- },
- get polygon() {
- return n.tree.children[0];
- },
- getPixelFromCoordinate(l) {
- return n.tree.getPixelFromStage(l);
- },
- async toDataURL(l = 1) {
- const A = n.tree.stage.toDataURL({ pixelRatio: l });
- if (!s.map)
- return A;
- const u = [n.tree.stage.width(), n.tree.stage.height()];
- o || (o = document.createElement("canvas")), o.width = u[0] * l, o.height = u[1] * l, o.style.width = u[0] + "px", o.style.height = u[1] + "px";
- const f = o.getContext("2d");
- return f.clearRect(0, 0, o.width, o.height), f.save(), $u(o, s.map, l), f.restore(), new Promise((c, d) => {
- const p = new Image();
- p.src = A, p.onload = () => {
- f.drawImage(
- p,
- 0,
- 0,
- o.width,
- o.height
- );
- const m = o.toDataURL("image/png");
- c(m);
- }, p.onerror = d;
- });
- }
- };
- };
- export {
- vu as BoundQueryPlugin,
- m1 as CameraQueryPlugin,
- uu as Container,
- qt as DEV,
- p1 as EditPoi,
- f1 as EditWholeLine,
- ie as Entity,
- y1 as HistoryPlugin,
- g1 as PenEditWholeLine,
- Lu as PoPath,
- Iu as PoPoint,
- pn as Poi,
- Nu as Polygons,
- vo as RelationshipEnum,
- Ri as WholeLine,
- Qt as WholeLineLine,
- ar as WholeLineLineHelper,
- Tt as WholeLinePoint,
- or as WholeLinePointHelper,
- Li as WholeLinePolygon,
- o1 as addEntityAttrib,
- Cl as analysisSvg,
- Xu as changeEnv,
- cu as closePenPolygonActShapeFactory,
- VA as copyEntityAttrib,
- v1 as createBoard,
- Ke as createLineByDire,
- fu as defaultPoiShapeFactory,
- Ts as depPartialUpdate,
- s1 as deptComputed,
- xo as disableMouse,
- bo as enableMouse,
- $A as entityActiveDualControl,
- HA as entityFactory,
- l1 as entitysActiveDualControl,
- oe as eqPoint,
- Ws as fixWholeLineConfig,
- zA as generateId,
- nh as generateWholeLineLineId,
- sh as generateWholeLinePointId,
- rh as generateWholeLinePoygonId,
- be as getAbsoluteTransform,
- Is as getActiveKey,
- Rn as getChangeAllPoart,
- Co as getChangePart,
- Xe as getDire2Angle,
- Qu as getDireDist,
- Mo as getFlatChildren,
- TA as getLine2Angle,
- Zu as getLineCenter,
- ce as getLineDire,
- LA as getLineDireAngle,
- Et as getLineDist,
- t1 as getLineInnerContinuityPoints,
- _o as getLineIntersection,
- OA as getLineNearPoint,
- NA as getLineNearPointDist,
- Ui as getLineProjection,
- RA as getLineRelationship,
- Gt as getRealAbsoluteSize,
- DA as getRotateDire,
- ju as getTfScaleFactors,
- ao as getTouchOffset,
- IA as getVerticaLineDire,
- pr as getVerticalDire,
- Ku as getVerticalDireLine,
- pi as getWholeLineLine,
- Ah as getWholeLineLineNdxByPointIds,
- wt as getWholeLineLineRaw,
- c1 as getWholeLineLines,
- d1 as getWholeLineLinesByPointId,
- oh as getWholeLineLinesRaw,
- Vd as getWholeLineLinesRawByPoint,
- ah as getWholeLineLinesRawByPointId,
- Hd as getWholeLineLinesRawByPointIds,
- Pe as getWholeLinePoint,
- Jd as getWholeLinePointMerge,
- _t as getWholeLinePoints,
- u1 as getWholeLinePolygonByPoint,
- $d as getWholeLinePolygonLines,
- lh as getWholeLinePolygonLinesByPoint,
- hh as getWholeLinePolygonLinesRaw,
- ri as getWholeLinePolygonPoints,
- yi as getWholeLinePolygonRaw,
- hn as hasTouchEvents,
- di as inRevise,
- Pt as incEntitysFactoryGenerate,
- gu as injectPoiType,
- no as isMobile,
- ul as isTablet,
- Si as mergeChange,
- mr as mergeFuns,
- tu as mergeWholeLinePointsByPoint,
- hu as needUpdatePolygonClose,
- GA as objectToString,
- ln as openEntityDrag,
- yr as openShapeDrag,
- ma as openShapeMouseStyles,
- r1 as partialComputed,
- Ml as pathsToActShape,
- Au as penLineActShapeFactory,
- du as penPolygonActShapeFactory,
- ja as penWholeLinePoygonsEdit,
- ou as penWholeLinePoygonsEditWithHelperMouse,
- Lr as penWholeLinePoygonsEditWithHelperShapesMouse,
- gh as poiTypes,
- Ju as polygonCounterclockwise,
- pu as register,
- eu as repeatMoveWholeLineLine,
- Qd as repeatablePushWholeLinePoint,
- Kd as repeatableWholeLineLineIntersections,
- Ot as round,
- Ud as setGenerateStartId,
- i1 as setShapeConfig,
- So as shapeParentsEq,
- e1 as shapeTreeContain,
- wo as shapeTreeEq,
- Zd as spliceWholeLineLineByLines,
- $s as spliceWholeLineLineByPoint,
- a1 as testPoint,
- An as toRawType,
- BA as toTypeString,
- h1 as updateEntityStatus,
- n1 as watchAttribs,
- ue as wholeLineAddLineByPointIds,
- Ze as wholeLineAddPoint,
- lu as wholeLineAnalysisHelperInfo,
- ai as wholeLineDelLineByPointIds,
- Wa as wholeLineDelPointByPointIds,
- ch as wholeLineDelPolygon,
- Xd as wholeLineFixLineAddPoint,
- hr as wholeLineLineAddPoint,
- Wd as wholeLineLineIsolatePoint,
- qd as wholeLinePolygonAddPoint,
- jd as wholeLinePolygonLastAddPoint,
- lr as wholeLineReplacePoint,
- A1 as wholeLineStyle
- };
|