cherry-markdown.js 4.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995869968699786998869998700087001870028700387004870058700687007870088700987010870118701287013870148701587016870178701887019870208702187022870238702487025870268702787028870298703087031870328703387034870358703687037870388703987040870418704287043870448704587046870478704887049870508705187052870538705487055870568705787058870598706087061870628706387064870658706687067870688706987070870718707287073870748707587076870778707887079870808708187082870838708487085870868708787088870898709087091870928709387094870958709687097870988709987100871018710287103871048710587106871078710887109871108711187112871138711487115871168711787118871198712087121871228712387124871258712687127871288712987130871318713287133871348713587136871378713887139871408714187142871438714487145871468714787148871498715087151871528715387154871558715687157871588715987160871618716287163871648716587166871678716887169871708717187172871738717487175871768717787178871798718087181871828718387184871858718687187871888718987190871918719287193871948719587196871978719887199872008720187202872038720487205872068720787208872098721087211872128721387214872158721687217872188721987220872218722287223872248722587226872278722887229872308723187232872338723487235872368723787238872398724087241872428724387244872458724687247872488724987250872518725287253872548725587256872578725887259872608726187262872638726487265872668726787268872698727087271872728727387274872758727687277872788727987280872818728287283872848728587286872878728887289872908729187292872938729487295872968729787298872998730087301873028730387304873058730687307873088730987310873118731287313873148731587316873178731887319873208732187322873238732487325873268732787328873298733087331873328733387334873358733687337873388733987340873418734287343873448734587346873478734887349873508735187352873538735487355873568735787358873598736087361873628736387364873658736687367873688736987370873718737287373873748737587376873778737887379873808738187382873838738487385873868738787388873898739087391873928739387394873958739687397873988739987400874018740287403874048740587406874078740887409874108741187412874138741487415874168741787418874198742087421874228742387424874258742687427874288742987430874318743287433874348743587436874378743887439874408744187442874438744487445874468744787448874498745087451874528745387454874558745687457874588745987460874618746287463874648746587466874678746887469874708747187472874738747487475874768747787478874798748087481874828748387484874858748687487874888748987490874918749287493874948749587496874978749887499875008750187502875038750487505875068750787508875098751087511875128751387514875158751687517875188751987520875218752287523875248752587526875278752887529875308753187532875338753487535875368753787538875398754087541875428754387544875458754687547875488754987550875518755287553875548755587556875578755887559875608756187562875638756487565875668756787568875698757087571875728757387574875758757687577875788757987580875818758287583875848758587586875878758887589875908759187592875938759487595875968759787598875998760087601876028760387604876058760687607876088760987610876118761287613876148761587616876178761887619876208762187622876238762487625876268762787628876298763087631876328763387634876358763687637876388763987640876418764287643876448764587646876478764887649876508765187652876538765487655876568765787658876598766087661876628766387664876658766687667876688766987670876718767287673876748767587676876778767887679876808768187682876838768487685876868768787688876898769087691876928769387694876958769687697876988769987700877018770287703877048770587706877078770887709877108771187712877138771487715877168771787718877198772087721877228772387724877258772687727877288772987730877318773287733877348773587736877378773887739877408774187742877438774487745877468774787748877498775087751877528775387754877558775687757877588775987760877618776287763877648776587766877678776887769877708777187772877738777487775877768777787778877798778087781877828778387784877858778687787877888778987790877918779287793877948779587796877978779887799878008780187802878038780487805878068780787808878098781087811878128781387814878158781687817878188781987820878218782287823878248782587826878278782887829878308783187832878338783487835878368783787838878398784087841878428784387844878458784687847878488784987850878518785287853878548785587856878578785887859878608786187862878638786487865878668786787868878698787087871878728787387874878758787687877878788787987880878818788287883878848788587886878878788887889878908789187892878938789487895878968789787898878998790087901879028790387904879058790687907879088790987910879118791287913879148791587916879178791887919879208792187922879238792487925879268792787928879298793087931879328793387934879358793687937879388793987940879418794287943879448794587946879478794887949879508795187952879538795487955879568795787958879598796087961879628796387964879658796687967879688796987970879718797287973879748797587976879778797887979879808798187982879838798487985879868798787988879898799087991879928799387994879958799687997879988799988000880018800288003880048800588006880078800888009880108801188012880138801488015880168801788018880198802088021880228802388024880258802688027880288802988030880318803288033880348803588036880378803888039880408804188042880438804488045880468804788048880498805088051880528805388054880558805688057880588805988060880618806288063880648806588066880678806888069880708807188072880738807488075880768807788078880798808088081880828808388084880858808688087880888808988090880918809288093880948809588096880978809888099881008810188102881038810488105881068810788108881098811088111881128811388114881158811688117881188811988120881218812288123881248812588126881278812888129881308813188132881338813488135881368813788138881398814088141881428814388144881458814688147881488814988150881518815288153881548815588156881578815888159881608816188162881638816488165881668816788168881698817088171881728817388174881758817688177881788817988180881818818288183881848818588186881878818888189881908819188192881938819488195881968819788198881998820088201882028820388204882058820688207882088820988210882118821288213882148821588216882178821888219882208822188222882238822488225882268822788228882298823088231882328823388234882358823688237882388823988240882418824288243882448824588246882478824888249882508825188252882538825488255882568825788258882598826088261882628826388264882658826688267882688826988270882718827288273882748827588276882778827888279882808828188282882838828488285882868828788288882898829088291882928829388294882958829688297882988829988300883018830288303883048830588306883078830888309883108831188312883138831488315883168831788318883198832088321883228832388324883258832688327883288832988330883318833288333883348833588336883378833888339883408834188342883438834488345883468834788348883498835088351883528835388354883558835688357883588835988360883618836288363883648836588366883678836888369883708837188372883738837488375883768837788378883798838088381883828838388384883858838688387883888838988390883918839288393883948839588396883978839888399884008840188402884038840488405884068840788408884098841088411884128841388414884158841688417884188841988420884218842288423884248842588426884278842888429884308843188432884338843488435884368843788438884398844088441884428844388444884458844688447884488844988450884518845288453884548845588456884578845888459884608846188462884638846488465884668846788468884698847088471884728847388474884758847688477884788847988480884818848288483884848848588486884878848888489884908849188492884938849488495884968849788498884998850088501885028850388504885058850688507885088850988510885118851288513885148851588516885178851888519885208852188522885238852488525885268852788528885298853088531885328853388534885358853688537885388853988540885418854288543885448854588546885478854888549885508855188552885538855488555885568855788558885598856088561885628856388564885658856688567885688856988570885718857288573885748857588576885778857888579885808858188582885838858488585885868858788588885898859088591885928859388594885958859688597885988859988600886018860288603886048860588606886078860888609886108861188612886138861488615886168861788618886198862088621886228862388624886258862688627886288862988630886318863288633886348863588636886378863888639886408864188642886438864488645886468864788648886498865088651886528865388654886558865688657886588865988660886618866288663886648866588666886678866888669886708867188672886738867488675886768867788678886798868088681886828868388684886858868688687886888868988690886918869288693886948869588696886978869888699887008870188702887038870488705887068870788708887098871088711887128871388714887158871688717887188871988720887218872288723887248872588726887278872888729887308873188732887338873488735887368873788738887398874088741887428874388744887458874688747887488874988750887518875288753887548875588756887578875888759887608876188762887638876488765887668876788768887698877088771887728877388774887758877688777887788877988780887818878288783887848878588786887878878888789887908879188792887938879488795887968879788798887998880088801888028880388804888058880688807888088880988810888118881288813888148881588816888178881888819888208882188822888238882488825888268882788828888298883088831888328883388834888358883688837888388883988840888418884288843888448884588846888478884888849888508885188852888538885488855888568885788858888598886088861888628886388864888658886688867888688886988870888718887288873888748887588876888778887888879888808888188882888838888488885888868888788888888898889088891888928889388894888958889688897888988889988900889018890288903889048890588906889078890888909889108891188912889138891488915889168891788918889198892088921889228892388924889258892688927889288892988930889318893288933889348893588936889378893888939889408894188942889438894488945889468894788948889498895088951889528895388954889558895688957889588895988960889618896288963889648896588966889678896888969889708897188972889738897488975889768897788978889798898088981889828898388984889858898688987889888898988990889918899288993889948899588996889978899888999890008900189002890038900489005890068900789008890098901089011890128901389014890158901689017890188901989020890218902289023890248902589026890278902889029890308903189032890338903489035890368903789038890398904089041890428904389044890458904689047890488904989050890518905289053890548905589056890578905889059890608906189062890638906489065890668906789068890698907089071890728907389074890758907689077890788907989080890818908289083890848908589086890878908889089890908909189092890938909489095890968909789098890998910089101891028910389104891058910689107891088910989110891118911289113891148911589116891178911889119891208912189122891238912489125891268912789128891298913089131891328913389134891358913689137891388913989140891418914289143891448914589146891478914889149891508915189152891538915489155891568915789158891598916089161891628916389164891658916689167891688916989170891718917289173891748917589176891778917889179891808918189182891838918489185891868918789188891898919089191891928919389194891958919689197891988919989200892018920289203892048920589206892078920889209892108921189212892138921489215892168921789218892198922089221892228922389224892258922689227892288922989230892318923289233892348923589236892378923889239892408924189242892438924489245892468924789248892498925089251892528925389254892558925689257892588925989260892618926289263892648926589266892678926889269892708927189272892738927489275892768927789278892798928089281892828928389284892858928689287892888928989290892918929289293892948929589296892978929889299893008930189302893038930489305893068930789308893098931089311893128931389314893158931689317893188931989320893218932289323893248932589326893278932889329893308933189332893338933489335893368933789338893398934089341893428934389344893458934689347893488934989350893518935289353893548935589356893578935889359893608936189362893638936489365893668936789368893698937089371893728937389374893758937689377893788937989380893818938289383893848938589386893878938889389893908939189392893938939489395893968939789398893998940089401894028940389404894058940689407894088940989410894118941289413894148941589416894178941889419894208942189422894238942489425894268942789428894298943089431894328943389434894358943689437894388943989440894418944289443894448944589446894478944889449894508945189452894538945489455894568945789458894598946089461894628946389464894658946689467894688946989470894718947289473894748947589476894778947889479894808948189482894838948489485894868948789488894898949089491894928949389494894958949689497894988949989500895018950289503895048950589506895078950889509895108951189512895138951489515895168951789518895198952089521895228952389524895258952689527895288952989530895318953289533895348953589536895378953889539895408954189542895438954489545895468954789548895498955089551895528955389554895558955689557895588955989560895618956289563895648956589566895678956889569895708957189572895738957489575895768957789578895798958089581895828958389584895858958689587895888958989590895918959289593895948959589596895978959889599896008960189602896038960489605896068960789608896098961089611896128961389614896158961689617896188961989620896218962289623896248962589626896278962889629896308963189632896338963489635896368963789638896398964089641896428964389644896458964689647896488964989650896518965289653896548965589656896578965889659896608966189662896638966489665896668966789668896698967089671896728967389674896758967689677896788967989680896818968289683896848968589686896878968889689896908969189692896938969489695896968969789698896998970089701897028970389704897058970689707897088970989710897118971289713897148971589716897178971889719897208972189722897238972489725897268972789728897298973089731897328973389734897358973689737897388973989740897418974289743897448974589746897478974889749897508975189752897538975489755897568975789758897598976089761897628976389764897658976689767897688976989770897718977289773897748977589776897778977889779897808978189782897838978489785897868978789788897898979089791897928979389794897958979689797897988979989800898018980289803898048980589806898078980889809898108981189812898138981489815898168981789818898198982089821898228982389824898258982689827898288982989830898318983289833898348983589836898378983889839898408984189842898438984489845898468984789848898498985089851898528985389854898558985689857898588985989860898618986289863898648986589866898678986889869898708987189872898738987489875898768987789878898798988089881898828988389884898858988689887898888988989890898918989289893898948989589896898978989889899899008990189902899038990489905899068990789908899098991089911899128991389914899158991689917899188991989920899218992289923899248992589926899278992889929899308993189932899338993489935899368993789938899398994089941899428994389944899458994689947899488994989950899518995289953899548995589956899578995889959899608996189962899638996489965899668996789968899698997089971899728997389974899758997689977899788997989980899818998289983899848998589986899878998889989899908999189992899938999489995899968999789998899999000090001900029000390004900059000690007900089000990010900119001290013900149001590016900179001890019900209002190022900239002490025900269002790028900299003090031900329003390034900359003690037900389003990040900419004290043900449004590046900479004890049900509005190052900539005490055900569005790058900599006090061900629006390064900659006690067900689006990070900719007290073900749007590076900779007890079900809008190082900839008490085900869008790088900899009090091900929009390094900959009690097900989009990100901019010290103901049010590106901079010890109901109011190112901139011490115901169011790118901199012090121901229012390124901259012690127901289012990130901319013290133901349013590136901379013890139901409014190142901439014490145901469014790148901499015090151901529015390154901559015690157901589015990160901619016290163901649016590166901679016890169901709017190172901739017490175901769017790178901799018090181901829018390184901859018690187901889018990190901919019290193901949019590196901979019890199902009020190202902039020490205902069020790208902099021090211902129021390214902159021690217902189021990220902219022290223902249022590226902279022890229902309023190232902339023490235902369023790238902399024090241902429024390244902459024690247902489024990250902519025290253902549025590256902579025890259902609026190262902639026490265902669026790268902699027090271902729027390274902759027690277902789027990280902819028290283902849028590286902879028890289902909029190292902939029490295902969029790298902999030090301903029030390304903059030690307903089030990310903119031290313903149031590316903179031890319903209032190322903239032490325903269032790328903299033090331903329033390334903359033690337903389033990340903419034290343903449034590346903479034890349903509035190352903539035490355903569035790358903599036090361903629036390364903659036690367903689036990370903719037290373903749037590376903779037890379903809038190382903839038490385903869038790388903899039090391903929039390394903959039690397903989039990400904019040290403904049040590406904079040890409904109041190412904139041490415904169041790418904199042090421904229042390424904259042690427904289042990430904319043290433904349043590436904379043890439904409044190442904439044490445904469044790448904499045090451904529045390454904559045690457904589045990460904619046290463904649046590466904679046890469904709047190472904739047490475904769047790478904799048090481904829048390484904859048690487904889048990490904919049290493904949049590496904979049890499905009050190502905039050490505905069050790508905099051090511905129051390514905159051690517905189051990520905219052290523905249052590526905279052890529905309053190532905339053490535905369053790538905399054090541905429054390544905459054690547905489054990550905519055290553905549055590556905579055890559905609056190562905639056490565905669056790568905699057090571905729057390574905759057690577905789057990580905819058290583905849058590586905879058890589905909059190592905939059490595905969059790598905999060090601906029060390604906059060690607906089060990610906119061290613906149061590616906179061890619906209062190622906239062490625906269062790628906299063090631906329063390634906359063690637906389063990640906419064290643906449064590646906479064890649906509065190652906539065490655906569065790658906599066090661906629066390664906659066690667906689066990670906719067290673906749067590676906779067890679906809068190682906839068490685906869068790688906899069090691906929069390694906959069690697906989069990700907019070290703907049070590706907079070890709907109071190712907139071490715907169071790718907199072090721907229072390724907259072690727907289072990730907319073290733907349073590736907379073890739907409074190742907439074490745907469074790748907499075090751907529075390754907559075690757907589075990760907619076290763907649076590766907679076890769907709077190772907739077490775907769077790778907799078090781907829078390784907859078690787907889078990790907919079290793907949079590796907979079890799908009080190802908039080490805908069080790808908099081090811908129081390814908159081690817908189081990820908219082290823908249082590826908279082890829908309083190832908339083490835908369083790838908399084090841908429084390844908459084690847908489084990850908519085290853908549085590856908579085890859908609086190862908639086490865908669086790868908699087090871908729087390874908759087690877908789087990880908819088290883908849088590886908879088890889908909089190892908939089490895908969089790898908999090090901909029090390904909059090690907909089090990910909119091290913909149091590916909179091890919909209092190922909239092490925909269092790928909299093090931909329093390934909359093690937909389093990940909419094290943909449094590946909479094890949909509095190952909539095490955909569095790958909599096090961909629096390964909659096690967909689096990970909719097290973909749097590976909779097890979909809098190982909839098490985909869098790988909899099090991909929099390994909959099690997909989099991000910019100291003910049100591006910079100891009910109101191012910139101491015910169101791018910199102091021910229102391024910259102691027910289102991030910319103291033910349103591036910379103891039910409104191042910439104491045910469104791048910499105091051910529105391054910559105691057910589105991060910619106291063910649106591066910679106891069910709107191072910739107491075910769107791078910799108091081910829108391084910859108691087910889108991090910919109291093910949109591096910979109891099911009110191102911039110491105911069110791108911099111091111911129111391114911159111691117911189111991120911219112291123911249112591126911279112891129911309113191132911339113491135911369113791138911399114091141911429114391144911459114691147911489114991150911519115291153911549115591156911579115891159911609116191162911639116491165911669116791168911699117091171911729117391174911759117691177911789117991180911819118291183911849118591186911879118891189911909119191192911939119491195911969119791198911999120091201912029120391204912059120691207912089120991210912119121291213912149121591216912179121891219912209122191222912239122491225912269122791228912299123091231912329123391234912359123691237912389123991240912419124291243912449124591246912479124891249912509125191252912539125491255912569125791258912599126091261912629126391264912659126691267912689126991270912719127291273912749127591276912779127891279912809128191282912839128491285912869128791288912899129091291912929129391294912959129691297912989129991300913019130291303913049130591306913079130891309913109131191312913139131491315913169131791318913199132091321913229132391324913259132691327913289132991330913319133291333913349133591336913379133891339913409134191342913439134491345913469134791348913499135091351913529135391354913559135691357913589135991360913619136291363913649136591366913679136891369913709137191372913739137491375913769137791378913799138091381913829138391384913859138691387913889138991390913919139291393913949139591396913979139891399914009140191402914039140491405914069140791408914099141091411914129141391414914159141691417914189141991420914219142291423914249142591426914279142891429914309143191432914339143491435914369143791438914399144091441914429144391444914459144691447914489144991450914519145291453914549145591456914579145891459914609146191462914639146491465914669146791468914699147091471914729147391474914759147691477914789147991480914819148291483914849148591486914879148891489914909149191492914939149491495914969149791498914999150091501915029150391504915059150691507915089150991510915119151291513915149151591516915179151891519915209152191522915239152491525915269152791528915299153091531915329153391534915359153691537915389153991540915419154291543915449154591546915479154891549915509155191552915539155491555915569155791558915599156091561915629156391564915659156691567915689156991570915719157291573915749157591576915779157891579915809158191582915839158491585915869158791588915899159091591915929159391594915959159691597915989159991600916019160291603916049160591606916079160891609916109161191612916139161491615916169161791618916199162091621916229162391624916259162691627916289162991630916319163291633916349163591636916379163891639916409164191642916439164491645916469164791648916499165091651916529165391654916559165691657916589165991660916619166291663916649166591666916679166891669916709167191672916739167491675916769167791678916799168091681916829168391684916859168691687916889168991690916919169291693916949169591696916979169891699917009170191702917039170491705917069170791708917099171091711917129171391714917159171691717917189171991720917219172291723917249172591726917279172891729917309173191732917339173491735917369173791738917399174091741917429174391744917459174691747917489174991750917519175291753917549175591756917579175891759917609176191762917639176491765917669176791768917699177091771917729177391774917759177691777917789177991780917819178291783917849178591786917879178891789917909179191792917939179491795917969179791798917999180091801918029180391804918059180691807918089180991810918119181291813918149181591816918179181891819918209182191822918239182491825918269182791828918299183091831918329183391834918359183691837918389183991840918419184291843918449184591846918479184891849918509185191852918539185491855918569185791858918599186091861918629186391864918659186691867918689186991870918719187291873918749187591876918779187891879918809188191882918839188491885918869188791888918899189091891918929189391894918959189691897918989189991900919019190291903919049190591906919079190891909919109191191912919139191491915919169191791918919199192091921919229192391924919259192691927919289192991930919319193291933919349193591936919379193891939919409194191942919439194491945919469194791948919499195091951919529195391954919559195691957919589195991960919619196291963919649196591966919679196891969919709197191972919739197491975919769197791978919799198091981919829198391984919859198691987919889198991990919919199291993919949199591996919979199891999920009200192002920039200492005920069200792008920099201092011920129201392014920159201692017920189201992020920219202292023920249202592026920279202892029920309203192032920339203492035920369203792038920399204092041920429204392044920459204692047920489204992050920519205292053920549205592056920579205892059920609206192062920639206492065920669206792068920699207092071920729207392074920759207692077920789207992080920819208292083920849208592086920879208892089920909209192092920939209492095920969209792098920999210092101921029210392104921059210692107921089210992110921119211292113921149211592116921179211892119921209212192122921239212492125921269212792128921299213092131921329213392134921359213692137921389213992140921419214292143921449214592146921479214892149921509215192152921539215492155921569215792158921599216092161921629216392164921659216692167921689216992170921719217292173921749217592176921779217892179921809218192182921839218492185921869218792188921899219092191921929219392194921959219692197921989219992200922019220292203922049220592206922079220892209922109221192212922139221492215922169221792218922199222092221922229222392224922259222692227922289222992230922319223292233922349223592236922379223892239922409224192242922439224492245922469224792248922499225092251922529225392254922559225692257922589225992260922619226292263922649226592266922679226892269922709227192272922739227492275922769227792278922799228092281922829228392284922859228692287922889228992290922919229292293922949229592296922979229892299923009230192302923039230492305923069230792308923099231092311923129231392314923159231692317923189231992320923219232292323923249232592326923279232892329923309233192332923339233492335923369233792338923399234092341923429234392344923459234692347923489234992350923519235292353923549235592356923579235892359923609236192362923639236492365923669236792368923699237092371923729237392374923759237692377923789237992380923819238292383923849238592386923879238892389923909239192392923939239492395923969239792398923999240092401924029240392404924059240692407924089240992410924119241292413924149241592416924179241892419924209242192422924239242492425924269242792428924299243092431924329243392434924359243692437924389243992440924419244292443924449244592446924479244892449924509245192452924539245492455924569245792458924599246092461924629246392464924659246692467924689246992470924719247292473924749247592476924779247892479924809248192482924839248492485924869248792488924899249092491924929249392494924959249692497924989249992500925019250292503925049250592506925079250892509925109251192512925139251492515925169251792518925199252092521925229252392524925259252692527925289252992530925319253292533925349253592536925379253892539925409254192542925439254492545925469254792548925499255092551925529255392554925559255692557925589255992560925619256292563925649256592566925679256892569925709257192572925739257492575925769257792578925799258092581925829258392584925859258692587925889258992590925919259292593925949259592596925979259892599926009260192602926039260492605926069260792608926099261092611926129261392614926159261692617926189261992620926219262292623926249262592626926279262892629926309263192632926339263492635926369263792638926399264092641926429264392644926459264692647926489264992650926519265292653926549265592656926579265892659926609266192662926639266492665926669266792668926699267092671926729267392674926759267692677926789267992680926819268292683926849268592686926879268892689926909269192692926939269492695926969269792698926999270092701927029270392704927059270692707927089270992710927119271292713927149271592716927179271892719927209272192722927239272492725927269272792728927299273092731927329273392734927359273692737927389273992740927419274292743927449274592746927479274892749927509275192752927539275492755927569275792758927599276092761927629276392764927659276692767927689276992770927719277292773927749277592776927779277892779927809278192782927839278492785927869278792788927899279092791927929279392794927959279692797927989279992800928019280292803928049280592806928079280892809928109281192812928139281492815928169281792818928199282092821928229282392824928259282692827928289282992830928319283292833928349283592836928379283892839928409284192842928439284492845928469284792848928499285092851928529285392854928559285692857928589285992860928619286292863928649286592866928679286892869928709287192872928739287492875928769287792878928799288092881928829288392884928859288692887928889288992890928919289292893928949289592896928979289892899929009290192902929039290492905929069290792908929099291092911929129291392914929159291692917929189291992920929219292292923929249292592926929279292892929929309293192932929339293492935929369293792938929399294092941929429294392944929459294692947929489294992950929519295292953929549295592956929579295892959929609296192962929639296492965929669296792968929699297092971929729297392974929759297692977929789297992980929819298292983929849298592986929879298892989929909299192992929939299492995929969299792998929999300093001930029300393004930059300693007930089300993010930119301293013930149301593016930179301893019930209302193022930239302493025930269302793028930299303093031930329303393034930359303693037930389303993040930419304293043930449304593046930479304893049930509305193052930539305493055930569305793058930599306093061930629306393064930659306693067930689306993070930719307293073930749307593076930779307893079930809308193082930839308493085930869308793088930899309093091930929309393094930959309693097930989309993100931019310293103931049310593106931079310893109931109311193112931139311493115931169311793118931199312093121931229312393124931259312693127931289312993130931319313293133931349313593136931379313893139931409314193142931439314493145931469314793148931499315093151931529315393154931559315693157931589315993160931619316293163931649316593166931679316893169931709317193172931739317493175931769317793178931799318093181931829318393184931859318693187931889318993190931919319293193931949319593196931979319893199932009320193202932039320493205932069320793208932099321093211932129321393214932159321693217932189321993220932219322293223932249322593226932279322893229932309323193232932339323493235932369323793238932399324093241932429324393244932459324693247932489324993250932519325293253932549325593256932579325893259932609326193262932639326493265932669326793268932699327093271932729327393274932759327693277932789327993280932819328293283932849328593286932879328893289932909329193292932939329493295932969329793298932999330093301933029330393304933059330693307933089330993310933119331293313933149331593316933179331893319933209332193322933239332493325933269332793328933299333093331933329333393334933359333693337933389333993340933419334293343933449334593346933479334893349933509335193352933539335493355933569335793358933599336093361933629336393364933659336693367933689336993370933719337293373933749337593376933779337893379933809338193382933839338493385933869338793388933899339093391933929339393394933959339693397933989339993400934019340293403934049340593406934079340893409934109341193412934139341493415934169341793418934199342093421934229342393424934259342693427934289342993430934319343293433934349343593436934379343893439934409344193442934439344493445934469344793448934499345093451934529345393454934559345693457934589345993460934619346293463934649346593466934679346893469934709347193472934739347493475934769347793478934799348093481934829348393484934859348693487934889348993490934919349293493934949349593496934979349893499935009350193502935039350493505935069350793508935099351093511935129351393514935159351693517935189351993520935219352293523935249352593526935279352893529935309353193532935339353493535935369353793538935399354093541935429354393544935459354693547935489354993550935519355293553935549355593556935579355893559935609356193562935639356493565935669356793568935699357093571935729357393574935759357693577935789357993580935819358293583935849358593586935879358893589935909359193592935939359493595935969359793598935999360093601936029360393604936059360693607936089360993610936119361293613936149361593616936179361893619936209362193622936239362493625936269362793628936299363093631936329363393634936359363693637936389363993640936419364293643936449364593646936479364893649936509365193652936539365493655936569365793658936599366093661936629366393664936659366693667936689366993670936719367293673936749367593676936779367893679936809368193682936839368493685936869368793688936899369093691936929369393694936959369693697936989369993700937019370293703937049370593706937079370893709937109371193712937139371493715937169371793718937199372093721937229372393724937259372693727937289372993730937319373293733937349373593736937379373893739937409374193742937439374493745937469374793748937499375093751937529375393754937559375693757937589375993760937619376293763937649376593766937679376893769937709377193772937739377493775937769377793778937799378093781937829378393784937859378693787937889378993790937919379293793937949379593796937979379893799938009380193802938039380493805938069380793808938099381093811938129381393814938159381693817938189381993820938219382293823938249382593826938279382893829938309383193832938339383493835938369383793838938399384093841938429384393844938459384693847938489384993850938519385293853938549385593856938579385893859938609386193862938639386493865938669386793868938699387093871938729387393874938759387693877938789387993880938819388293883938849388593886938879388893889938909389193892938939389493895938969389793898938999390093901939029390393904939059390693907939089390993910939119391293913939149391593916939179391893919939209392193922939239392493925939269392793928939299393093931939329393393934939359393693937939389393993940939419394293943939449394593946939479394893949939509395193952939539395493955939569395793958939599396093961939629396393964939659396693967939689396993970939719397293973939749397593976939779397893979939809398193982939839398493985939869398793988939899399093991939929399393994939959399693997939989399994000940019400294003940049400594006940079400894009940109401194012940139401494015940169401794018940199402094021940229402394024940259402694027940289402994030940319403294033940349403594036940379403894039940409404194042940439404494045940469404794048940499405094051940529405394054940559405694057940589405994060940619406294063940649406594066940679406894069940709407194072940739407494075940769407794078940799408094081940829408394084940859408694087940889408994090940919409294093940949409594096940979409894099941009410194102941039410494105941069410794108941099411094111941129411394114941159411694117941189411994120941219412294123941249412594126941279412894129941309413194132941339413494135941369413794138941399414094141941429414394144941459414694147941489414994150941519415294153941549415594156941579415894159941609416194162941639416494165941669416794168941699417094171941729417394174941759417694177941789417994180941819418294183941849418594186941879418894189941909419194192941939419494195941969419794198941999420094201942029420394204942059420694207942089420994210942119421294213942149421594216942179421894219942209422194222942239422494225942269422794228942299423094231942329423394234942359423694237942389423994240942419424294243942449424594246942479424894249942509425194252942539425494255942569425794258942599426094261942629426394264942659426694267942689426994270942719427294273942749427594276942779427894279942809428194282942839428494285942869428794288942899429094291942929429394294942959429694297942989429994300943019430294303943049430594306943079430894309943109431194312943139431494315943169431794318943199432094321943229432394324943259432694327943289432994330943319433294333943349433594336943379433894339943409434194342943439434494345943469434794348943499435094351943529435394354943559435694357943589435994360943619436294363943649436594366943679436894369943709437194372943739437494375943769437794378943799438094381943829438394384943859438694387943889438994390943919439294393943949439594396943979439894399944009440194402944039440494405944069440794408944099441094411944129441394414944159441694417944189441994420944219442294423944249442594426944279442894429944309443194432944339443494435944369443794438944399444094441944429444394444944459444694447944489444994450944519445294453944549445594456944579445894459944609446194462944639446494465944669446794468944699447094471944729447394474944759447694477944789447994480944819448294483944849448594486944879448894489944909449194492944939449494495944969449794498944999450094501945029450394504945059450694507945089450994510945119451294513945149451594516945179451894519945209452194522945239452494525945269452794528945299453094531945329453394534945359453694537945389453994540945419454294543945449454594546945479454894549945509455194552945539455494555945569455794558945599456094561945629456394564945659456694567945689456994570945719457294573945749457594576945779457894579945809458194582945839458494585945869458794588945899459094591945929459394594945959459694597945989459994600946019460294603946049460594606946079460894609946109461194612946139461494615946169461794618946199462094621946229462394624946259462694627946289462994630946319463294633946349463594636946379463894639946409464194642946439464494645946469464794648946499465094651946529465394654946559465694657946589465994660946619466294663946649466594666946679466894669946709467194672946739467494675946769467794678946799468094681946829468394684946859468694687946889468994690946919469294693946949469594696946979469894699947009470194702947039470494705947069470794708947099471094711947129471394714947159471694717947189471994720947219472294723947249472594726947279472894729947309473194732947339473494735947369473794738947399474094741947429474394744947459474694747947489474994750947519475294753947549475594756947579475894759947609476194762947639476494765947669476794768947699477094771947729477394774947759477694777947789477994780947819478294783947849478594786947879478894789947909479194792947939479494795947969479794798947999480094801948029480394804948059480694807948089480994810948119481294813948149481594816948179481894819948209482194822948239482494825948269482794828948299483094831948329483394834
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  3. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  4. (global = global || self, factory(global.Cherry = {}));
  5. }(this, (function (exports) { 'use strict';
  6. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  7. function unwrapExports (x) {
  8. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  9. }
  10. function createCommonjsModule(fn, module) {
  11. return module = { exports: {} }, fn(module, module.exports), module.exports;
  12. }
  13. function getCjsExportFromNamespace (n) {
  14. return n && n['default'] || n;
  15. }
  16. var check = function (it) {
  17. return it && it.Math == Math && it;
  18. };
  19. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  20. var global_1 =
  21. // eslint-disable-next-line es-x/no-global-this -- safe
  22. check(typeof globalThis == 'object' && globalThis) ||
  23. check(typeof window == 'object' && window) ||
  24. // eslint-disable-next-line no-restricted-globals -- safe
  25. check(typeof self == 'object' && self) ||
  26. check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
  27. // eslint-disable-next-line no-new-func -- fallback
  28. (function () { return this; })() || Function('return this')();
  29. var fails = function (exec) {
  30. try {
  31. return !!exec();
  32. } catch (error) {
  33. return true;
  34. }
  35. };
  36. var functionBindNative = !fails(function () {
  37. // eslint-disable-next-line es-x/no-function-prototype-bind -- safe
  38. var test = (function () { /* empty */ }).bind();
  39. // eslint-disable-next-line no-prototype-builtins -- safe
  40. return typeof test != 'function' || test.hasOwnProperty('prototype');
  41. });
  42. var FunctionPrototype = Function.prototype;
  43. var apply = FunctionPrototype.apply;
  44. var call = FunctionPrototype.call;
  45. // eslint-disable-next-line es-x/no-reflect -- safe
  46. var functionApply = typeof Reflect == 'object' && Reflect.apply || (functionBindNative ? call.bind(apply) : function () {
  47. return call.apply(apply, arguments);
  48. });
  49. var FunctionPrototype$1 = Function.prototype;
  50. var bind = FunctionPrototype$1.bind;
  51. var call$1 = FunctionPrototype$1.call;
  52. var uncurryThis = functionBindNative && bind.bind(call$1, call$1);
  53. var functionUncurryThis = functionBindNative ? function (fn) {
  54. return fn && uncurryThis(fn);
  55. } : function (fn) {
  56. return fn && function () {
  57. return call$1.apply(fn, arguments);
  58. };
  59. };
  60. // `IsCallable` abstract operation
  61. // https://tc39.es/ecma262/#sec-iscallable
  62. var isCallable = function (argument) {
  63. return typeof argument == 'function';
  64. };
  65. // Detect IE8's incomplete defineProperty implementation
  66. var descriptors = !fails(function () {
  67. // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
  68. return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
  69. });
  70. var call$2 = Function.prototype.call;
  71. var functionCall = functionBindNative ? call$2.bind(call$2) : function () {
  72. return call$2.apply(call$2, arguments);
  73. };
  74. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  75. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  76. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  77. // Nashorn ~ JDK8 bug
  78. var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  79. // `Object.prototype.propertyIsEnumerable` method implementation
  80. // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
  81. var f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  82. var descriptor = getOwnPropertyDescriptor(this, V);
  83. return !!descriptor && descriptor.enumerable;
  84. } : $propertyIsEnumerable;
  85. var objectPropertyIsEnumerable = {
  86. f: f
  87. };
  88. var createPropertyDescriptor = function (bitmap, value) {
  89. return {
  90. enumerable: !(bitmap & 1),
  91. configurable: !(bitmap & 2),
  92. writable: !(bitmap & 4),
  93. value: value
  94. };
  95. };
  96. var toString = functionUncurryThis({}.toString);
  97. var stringSlice = functionUncurryThis(''.slice);
  98. var classofRaw = function (it) {
  99. return stringSlice(toString(it), 8, -1);
  100. };
  101. var Object$1 = global_1.Object;
  102. var split = functionUncurryThis(''.split);
  103. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  104. var indexedObject = fails(function () {
  105. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  106. // eslint-disable-next-line no-prototype-builtins -- safe
  107. return !Object$1('z').propertyIsEnumerable(0);
  108. }) ? function (it) {
  109. return classofRaw(it) == 'String' ? split(it, '') : Object$1(it);
  110. } : Object$1;
  111. var TypeError$1 = global_1.TypeError;
  112. // `RequireObjectCoercible` abstract operation
  113. // https://tc39.es/ecma262/#sec-requireobjectcoercible
  114. var requireObjectCoercible = function (it) {
  115. if (it == undefined) throw TypeError$1("Can't call method on " + it);
  116. return it;
  117. };
  118. // toObject with fallback for non-array-like ES3 strings
  119. var toIndexedObject = function (it) {
  120. return indexedObject(requireObjectCoercible(it));
  121. };
  122. var isObject = function (it) {
  123. return typeof it == 'object' ? it !== null : isCallable(it);
  124. };
  125. var path = {};
  126. var aFunction = function (variable) {
  127. return isCallable(variable) ? variable : undefined;
  128. };
  129. var getBuiltIn = function (namespace, method) {
  130. return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global_1[namespace])
  131. : path[namespace] && path[namespace][method] || global_1[namespace] && global_1[namespace][method];
  132. };
  133. var objectIsPrototypeOf = functionUncurryThis({}.isPrototypeOf);
  134. var engineUserAgent = getBuiltIn('navigator', 'userAgent') || '';
  135. var process$1 = global_1.process;
  136. var Deno$1 = global_1.Deno;
  137. var versions = process$1 && process$1.versions || Deno$1 && Deno$1.version;
  138. var v8 = versions && versions.v8;
  139. var match, version;
  140. if (v8) {
  141. match = v8.split('.');
  142. // in old Chrome, versions of V8 isn't V8 = Chrome / 10
  143. // but their correct versions are not interesting for us
  144. version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
  145. }
  146. // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
  147. // so check `userAgent` even if `.v8` exists, but 0
  148. if (!version && engineUserAgent) {
  149. match = engineUserAgent.match(/Edge\/(\d+)/);
  150. if (!match || match[1] >= 74) {
  151. match = engineUserAgent.match(/Chrome\/(\d+)/);
  152. if (match) version = +match[1];
  153. }
  154. }
  155. var engineV8Version = version;
  156. /* eslint-disable es-x/no-symbol -- required for testing */
  157. // eslint-disable-next-line es-x/no-object-getownpropertysymbols -- required for testing
  158. var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () {
  159. var symbol = Symbol();
  160. // Chrome 38 Symbol has incorrect toString conversion
  161. // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
  162. return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
  163. // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
  164. !Symbol.sham && engineV8Version && engineV8Version < 41;
  165. });
  166. /* eslint-disable es-x/no-symbol -- required for testing */
  167. var useSymbolAsUid = nativeSymbol
  168. && !Symbol.sham
  169. && typeof Symbol.iterator == 'symbol';
  170. var Object$2 = global_1.Object;
  171. var isSymbol = useSymbolAsUid ? function (it) {
  172. return typeof it == 'symbol';
  173. } : function (it) {
  174. var $Symbol = getBuiltIn('Symbol');
  175. return isCallable($Symbol) && objectIsPrototypeOf($Symbol.prototype, Object$2(it));
  176. };
  177. var String$1 = global_1.String;
  178. var tryToString = function (argument) {
  179. try {
  180. return String$1(argument);
  181. } catch (error) {
  182. return 'Object';
  183. }
  184. };
  185. var TypeError$2 = global_1.TypeError;
  186. // `Assert: IsCallable(argument) is true`
  187. var aCallable = function (argument) {
  188. if (isCallable(argument)) return argument;
  189. throw TypeError$2(tryToString(argument) + ' is not a function');
  190. };
  191. // `GetMethod` abstract operation
  192. // https://tc39.es/ecma262/#sec-getmethod
  193. var getMethod = function (V, P) {
  194. var func = V[P];
  195. return func == null ? undefined : aCallable(func);
  196. };
  197. var TypeError$3 = global_1.TypeError;
  198. // `OrdinaryToPrimitive` abstract operation
  199. // https://tc39.es/ecma262/#sec-ordinarytoprimitive
  200. var ordinaryToPrimitive = function (input, pref) {
  201. var fn, val;
  202. if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val;
  203. if (isCallable(fn = input.valueOf) && !isObject(val = functionCall(fn, input))) return val;
  204. if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val;
  205. throw TypeError$3("Can't convert object to primitive value");
  206. };
  207. var isPure = true;
  208. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  209. var defineProperty = Object.defineProperty;
  210. var defineGlobalProperty = function (key, value) {
  211. try {
  212. defineProperty(global_1, key, { value: value, configurable: true, writable: true });
  213. } catch (error) {
  214. global_1[key] = value;
  215. } return value;
  216. };
  217. var SHARED = '__core-js_shared__';
  218. var store = global_1[SHARED] || defineGlobalProperty(SHARED, {});
  219. var sharedStore = store;
  220. var shared = createCommonjsModule(function (module) {
  221. (module.exports = function (key, value) {
  222. return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
  223. })('versions', []).push({
  224. version: '3.22.6',
  225. mode: 'pure' ,
  226. copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
  227. license: 'https://github.com/zloirock/core-js/blob/v3.22.6/LICENSE',
  228. source: 'https://github.com/zloirock/core-js'
  229. });
  230. });
  231. var Object$3 = global_1.Object;
  232. // `ToObject` abstract operation
  233. // https://tc39.es/ecma262/#sec-toobject
  234. var toObject = function (argument) {
  235. return Object$3(requireObjectCoercible(argument));
  236. };
  237. var hasOwnProperty = functionUncurryThis({}.hasOwnProperty);
  238. // `HasOwnProperty` abstract operation
  239. // https://tc39.es/ecma262/#sec-hasownproperty
  240. // eslint-disable-next-line es-x/no-object-hasown -- safe
  241. var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
  242. return hasOwnProperty(toObject(it), key);
  243. };
  244. var id = 0;
  245. var postfix = Math.random();
  246. var toString$1 = functionUncurryThis(1.0.toString);
  247. var uid = function (key) {
  248. return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$1(++id + postfix, 36);
  249. };
  250. var WellKnownSymbolsStore = shared('wks');
  251. var Symbol$1 = global_1.Symbol;
  252. var symbolFor = Symbol$1 && Symbol$1['for'];
  253. var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid;
  254. var wellKnownSymbol = function (name) {
  255. if (!hasOwnProperty_1(WellKnownSymbolsStore, name) || !(nativeSymbol || typeof WellKnownSymbolsStore[name] == 'string')) {
  256. var description = 'Symbol.' + name;
  257. if (nativeSymbol && hasOwnProperty_1(Symbol$1, name)) {
  258. WellKnownSymbolsStore[name] = Symbol$1[name];
  259. } else if (useSymbolAsUid && symbolFor) {
  260. WellKnownSymbolsStore[name] = symbolFor(description);
  261. } else {
  262. WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
  263. }
  264. } return WellKnownSymbolsStore[name];
  265. };
  266. var TypeError$4 = global_1.TypeError;
  267. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  268. // `ToPrimitive` abstract operation
  269. // https://tc39.es/ecma262/#sec-toprimitive
  270. var toPrimitive = function (input, pref) {
  271. if (!isObject(input) || isSymbol(input)) return input;
  272. var exoticToPrim = getMethod(input, TO_PRIMITIVE);
  273. var result;
  274. if (exoticToPrim) {
  275. if (pref === undefined) pref = 'default';
  276. result = functionCall(exoticToPrim, input, pref);
  277. if (!isObject(result) || isSymbol(result)) return result;
  278. throw TypeError$4("Can't convert object to primitive value");
  279. }
  280. if (pref === undefined) pref = 'number';
  281. return ordinaryToPrimitive(input, pref);
  282. };
  283. // `ToPropertyKey` abstract operation
  284. // https://tc39.es/ecma262/#sec-topropertykey
  285. var toPropertyKey = function (argument) {
  286. var key = toPrimitive(argument, 'string');
  287. return isSymbol(key) ? key : key + '';
  288. };
  289. var document$1 = global_1.document;
  290. // typeof document.createElement is 'object' in old IE
  291. var EXISTS = isObject(document$1) && isObject(document$1.createElement);
  292. var documentCreateElement = function (it) {
  293. return EXISTS ? document$1.createElement(it) : {};
  294. };
  295. // Thanks to IE8 for its funny defineProperty
  296. var ie8DomDefine = !descriptors && !fails(function () {
  297. // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
  298. return Object.defineProperty(documentCreateElement('div'), 'a', {
  299. get: function () { return 7; }
  300. }).a != 7;
  301. });
  302. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  303. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  304. // `Object.getOwnPropertyDescriptor` method
  305. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  306. var f$1 = descriptors ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  307. O = toIndexedObject(O);
  308. P = toPropertyKey(P);
  309. if (ie8DomDefine) try {
  310. return $getOwnPropertyDescriptor(O, P);
  311. } catch (error) { /* empty */ }
  312. if (hasOwnProperty_1(O, P)) return createPropertyDescriptor(!functionCall(objectPropertyIsEnumerable.f, O, P), O[P]);
  313. };
  314. var objectGetOwnPropertyDescriptor = {
  315. f: f$1
  316. };
  317. var replacement = /#|\.prototype\./;
  318. var isForced = function (feature, detection) {
  319. var value = data[normalize(feature)];
  320. return value == POLYFILL ? true
  321. : value == NATIVE ? false
  322. : isCallable(detection) ? fails(detection)
  323. : !!detection;
  324. };
  325. var normalize = isForced.normalize = function (string) {
  326. return String(string).replace(replacement, '.').toLowerCase();
  327. };
  328. var data = isForced.data = {};
  329. var NATIVE = isForced.NATIVE = 'N';
  330. var POLYFILL = isForced.POLYFILL = 'P';
  331. var isForced_1 = isForced;
  332. var bind$1 = functionUncurryThis(functionUncurryThis.bind);
  333. // optional / simple context binding
  334. var functionBindContext = function (fn, that) {
  335. aCallable(fn);
  336. return that === undefined ? fn : functionBindNative ? bind$1(fn, that) : function (/* ...args */) {
  337. return fn.apply(that, arguments);
  338. };
  339. };
  340. // V8 ~ Chrome 36-
  341. // https://bugs.chromium.org/p/v8/issues/detail?id=3334
  342. var v8PrototypeDefineBug = descriptors && fails(function () {
  343. // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
  344. return Object.defineProperty(function () { /* empty */ }, 'prototype', {
  345. value: 42,
  346. writable: false
  347. }).prototype != 42;
  348. });
  349. var String$2 = global_1.String;
  350. var TypeError$5 = global_1.TypeError;
  351. // `Assert: Type(argument) is Object`
  352. var anObject = function (argument) {
  353. if (isObject(argument)) return argument;
  354. throw TypeError$5(String$2(argument) + ' is not an object');
  355. };
  356. var TypeError$6 = global_1.TypeError;
  357. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  358. var $defineProperty = Object.defineProperty;
  359. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  360. var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
  361. var ENUMERABLE = 'enumerable';
  362. var CONFIGURABLE = 'configurable';
  363. var WRITABLE = 'writable';
  364. // `Object.defineProperty` method
  365. // https://tc39.es/ecma262/#sec-object.defineproperty
  366. var f$2 = descriptors ? v8PrototypeDefineBug ? function defineProperty(O, P, Attributes) {
  367. anObject(O);
  368. P = toPropertyKey(P);
  369. anObject(Attributes);
  370. if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
  371. var current = $getOwnPropertyDescriptor$1(O, P);
  372. if (current && current[WRITABLE]) {
  373. O[P] = Attributes.value;
  374. Attributes = {
  375. configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE],
  376. enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
  377. writable: false
  378. };
  379. }
  380. } return $defineProperty(O, P, Attributes);
  381. } : $defineProperty : function defineProperty(O, P, Attributes) {
  382. anObject(O);
  383. P = toPropertyKey(P);
  384. anObject(Attributes);
  385. if (ie8DomDefine) try {
  386. return $defineProperty(O, P, Attributes);
  387. } catch (error) { /* empty */ }
  388. if ('get' in Attributes || 'set' in Attributes) throw TypeError$6('Accessors not supported');
  389. if ('value' in Attributes) O[P] = Attributes.value;
  390. return O;
  391. };
  392. var objectDefineProperty = {
  393. f: f$2
  394. };
  395. var createNonEnumerableProperty = descriptors ? function (object, key, value) {
  396. return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
  397. } : function (object, key, value) {
  398. object[key] = value;
  399. return object;
  400. };
  401. var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
  402. var wrapConstructor = function (NativeConstructor) {
  403. var Wrapper = function (a, b, c) {
  404. if (this instanceof Wrapper) {
  405. switch (arguments.length) {
  406. case 0: return new NativeConstructor();
  407. case 1: return new NativeConstructor(a);
  408. case 2: return new NativeConstructor(a, b);
  409. } return new NativeConstructor(a, b, c);
  410. } return functionApply(NativeConstructor, this, arguments);
  411. };
  412. Wrapper.prototype = NativeConstructor.prototype;
  413. return Wrapper;
  414. };
  415. /*
  416. options.target - name of the target object
  417. options.global - target is the global object
  418. options.stat - export as static methods of target
  419. options.proto - export as prototype methods of target
  420. options.real - real prototype method for the `pure` version
  421. options.forced - export even if the native feature is available
  422. options.bind - bind methods to the target, required for the `pure` version
  423. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  424. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  425. options.sham - add a flag to not completely full polyfills
  426. options.enumerable - export as enumerable property
  427. options.dontCallGetSet - prevent calling a getter on target
  428. options.name - the .name of the function if it does not match the key
  429. */
  430. var _export = function (options, source) {
  431. var TARGET = options.target;
  432. var GLOBAL = options.global;
  433. var STATIC = options.stat;
  434. var PROTO = options.proto;
  435. var nativeSource = GLOBAL ? global_1 : STATIC ? global_1[TARGET] : (global_1[TARGET] || {}).prototype;
  436. var target = GLOBAL ? path : path[TARGET] || createNonEnumerableProperty(path, TARGET, {})[TARGET];
  437. var targetPrototype = target.prototype;
  438. var FORCED, USE_NATIVE, VIRTUAL_PROTOTYPE;
  439. var key, sourceProperty, targetProperty, nativeProperty, resultProperty, descriptor;
  440. for (key in source) {
  441. FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  442. // contains in native
  443. USE_NATIVE = !FORCED && nativeSource && hasOwnProperty_1(nativeSource, key);
  444. targetProperty = target[key];
  445. if (USE_NATIVE) if (options.dontCallGetSet) {
  446. descriptor = getOwnPropertyDescriptor$1(nativeSource, key);
  447. nativeProperty = descriptor && descriptor.value;
  448. } else nativeProperty = nativeSource[key];
  449. // export native or implementation
  450. sourceProperty = (USE_NATIVE && nativeProperty) ? nativeProperty : source[key];
  451. if (USE_NATIVE && typeof targetProperty == typeof sourceProperty) continue;
  452. // bind timers to global for call from export context
  453. if (options.bind && USE_NATIVE) resultProperty = functionBindContext(sourceProperty, global_1);
  454. // wrap global constructors for prevent changs in this version
  455. else if (options.wrap && USE_NATIVE) resultProperty = wrapConstructor(sourceProperty);
  456. // make static versions for prototype methods
  457. else if (PROTO && isCallable(sourceProperty)) resultProperty = functionUncurryThis(sourceProperty);
  458. // default case
  459. else resultProperty = sourceProperty;
  460. // add a flag to not completely full polyfills
  461. if (options.sham || (sourceProperty && sourceProperty.sham) || (targetProperty && targetProperty.sham)) {
  462. createNonEnumerableProperty(resultProperty, 'sham', true);
  463. }
  464. createNonEnumerableProperty(target, key, resultProperty);
  465. if (PROTO) {
  466. VIRTUAL_PROTOTYPE = TARGET + 'Prototype';
  467. if (!hasOwnProperty_1(path, VIRTUAL_PROTOTYPE)) {
  468. createNonEnumerableProperty(path, VIRTUAL_PROTOTYPE, {});
  469. }
  470. // export virtual prototype methods
  471. createNonEnumerableProperty(path[VIRTUAL_PROTOTYPE], key, sourceProperty);
  472. // export real prototype methods
  473. if (options.real && targetPrototype && !targetPrototype[key]) {
  474. createNonEnumerableProperty(targetPrototype, key, sourceProperty);
  475. }
  476. }
  477. }
  478. };
  479. var arraySlice = functionUncurryThis([].slice);
  480. var Function$1 = global_1.Function;
  481. var concat = functionUncurryThis([].concat);
  482. var join = functionUncurryThis([].join);
  483. var factories = {};
  484. var construct = function (C, argsLength, args) {
  485. if (!hasOwnProperty_1(factories, argsLength)) {
  486. for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';
  487. factories[argsLength] = Function$1('C,a', 'return new C(' + join(list, ',') + ')');
  488. } return factories[argsLength](C, args);
  489. };
  490. // `Function.prototype.bind` method implementation
  491. // https://tc39.es/ecma262/#sec-function.prototype.bind
  492. var functionBind = functionBindNative ? Function$1.bind : function bind(that /* , ...args */) {
  493. var F = aCallable(this);
  494. var Prototype = F.prototype;
  495. var partArgs = arraySlice(arguments, 1);
  496. var boundFunction = function bound(/* args... */) {
  497. var args = concat(partArgs, arraySlice(arguments));
  498. return this instanceof boundFunction ? construct(F, args.length, args) : F.apply(that, args);
  499. };
  500. if (isObject(Prototype)) boundFunction.prototype = Prototype;
  501. return boundFunction;
  502. };
  503. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  504. var test = {};
  505. test[TO_STRING_TAG] = 'z';
  506. var toStringTagSupport = String(test) === '[object z]';
  507. var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag');
  508. var Object$4 = global_1.Object;
  509. // ES3 wrong here
  510. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  511. // fallback for IE11 Script Access Denied error
  512. var tryGet = function (it, key) {
  513. try {
  514. return it[key];
  515. } catch (error) { /* empty */ }
  516. };
  517. // getting tag from ES6+ `Object.prototype.toString`
  518. var classof = toStringTagSupport ? classofRaw : function (it) {
  519. var O, tag, result;
  520. return it === undefined ? 'Undefined' : it === null ? 'Null'
  521. // @@toStringTag case
  522. : typeof (tag = tryGet(O = Object$4(it), TO_STRING_TAG$1)) == 'string' ? tag
  523. // builtinTag case
  524. : CORRECT_ARGUMENTS ? classofRaw(O)
  525. // ES3 arguments fallback
  526. : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result;
  527. };
  528. var functionToString = functionUncurryThis(Function.toString);
  529. // this helper broken in `[email protected]`, so we can't use `shared` helper
  530. if (!isCallable(sharedStore.inspectSource)) {
  531. sharedStore.inspectSource = function (it) {
  532. return functionToString(it);
  533. };
  534. }
  535. var inspectSource = sharedStore.inspectSource;
  536. var noop = function () { /* empty */ };
  537. var empty = [];
  538. var construct$1 = getBuiltIn('Reflect', 'construct');
  539. var constructorRegExp = /^\s*(?:class|function)\b/;
  540. var exec = functionUncurryThis(constructorRegExp.exec);
  541. var INCORRECT_TO_STRING = !constructorRegExp.exec(noop);
  542. var isConstructorModern = function isConstructor(argument) {
  543. if (!isCallable(argument)) return false;
  544. try {
  545. construct$1(noop, empty, argument);
  546. return true;
  547. } catch (error) {
  548. return false;
  549. }
  550. };
  551. var isConstructorLegacy = function isConstructor(argument) {
  552. if (!isCallable(argument)) return false;
  553. switch (classof(argument)) {
  554. case 'AsyncFunction':
  555. case 'GeneratorFunction':
  556. case 'AsyncGeneratorFunction': return false;
  557. }
  558. try {
  559. // we can't check .prototype since constructors produced by .bind haven't it
  560. // `Function#toString` throws on some built-it function in some legacy engines
  561. // (for example, `DOMQuad` and similar in FF41-)
  562. return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
  563. } catch (error) {
  564. return true;
  565. }
  566. };
  567. isConstructorLegacy.sham = true;
  568. // `IsConstructor` abstract operation
  569. // https://tc39.es/ecma262/#sec-isconstructor
  570. var isConstructor = !construct$1 || fails(function () {
  571. var called;
  572. return isConstructorModern(isConstructorModern.call)
  573. || !isConstructorModern(Object)
  574. || !isConstructorModern(function () { called = true; })
  575. || called;
  576. }) ? isConstructorLegacy : isConstructorModern;
  577. var TypeError$7 = global_1.TypeError;
  578. // `Assert: IsConstructor(argument) is true`
  579. var aConstructor = function (argument) {
  580. if (isConstructor(argument)) return argument;
  581. throw TypeError$7(tryToString(argument) + ' is not a constructor');
  582. };
  583. var ceil = Math.ceil;
  584. var floor = Math.floor;
  585. // `Math.trunc` method
  586. // https://tc39.es/ecma262/#sec-math.trunc
  587. // eslint-disable-next-line es-x/no-math-trunc -- safe
  588. var mathTrunc = Math.trunc || function trunc(x) {
  589. var n = +x;
  590. return (n > 0 ? floor : ceil)(n);
  591. };
  592. // `ToIntegerOrInfinity` abstract operation
  593. // https://tc39.es/ecma262/#sec-tointegerorinfinity
  594. var toIntegerOrInfinity = function (argument) {
  595. var number = +argument;
  596. // eslint-disable-next-line no-self-compare -- NaN check
  597. return number !== number || number === 0 ? 0 : mathTrunc(number);
  598. };
  599. var max = Math.max;
  600. var min = Math.min;
  601. // Helper for a popular repeating case of the spec:
  602. // Let integer be ? ToInteger(index).
  603. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  604. var toAbsoluteIndex = function (index, length) {
  605. var integer = toIntegerOrInfinity(index);
  606. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  607. };
  608. var min$1 = Math.min;
  609. // `ToLength` abstract operation
  610. // https://tc39.es/ecma262/#sec-tolength
  611. var toLength = function (argument) {
  612. return argument > 0 ? min$1(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  613. };
  614. // `LengthOfArrayLike` abstract operation
  615. // https://tc39.es/ecma262/#sec-lengthofarraylike
  616. var lengthOfArrayLike = function (obj) {
  617. return toLength(obj.length);
  618. };
  619. // `Array.prototype.{ indexOf, includes }` methods implementation
  620. var createMethod = function (IS_INCLUDES) {
  621. return function ($this, el, fromIndex) {
  622. var O = toIndexedObject($this);
  623. var length = lengthOfArrayLike(O);
  624. var index = toAbsoluteIndex(fromIndex, length);
  625. var value;
  626. // Array#includes uses SameValueZero equality algorithm
  627. // eslint-disable-next-line no-self-compare -- NaN check
  628. if (IS_INCLUDES && el != el) while (length > index) {
  629. value = O[index++];
  630. // eslint-disable-next-line no-self-compare -- NaN check
  631. if (value != value) return true;
  632. // Array#indexOf ignores holes, Array#includes - not
  633. } else for (;length > index; index++) {
  634. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  635. } return !IS_INCLUDES && -1;
  636. };
  637. };
  638. var arrayIncludes = {
  639. // `Array.prototype.includes` method
  640. // https://tc39.es/ecma262/#sec-array.prototype.includes
  641. includes: createMethod(true),
  642. // `Array.prototype.indexOf` method
  643. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  644. indexOf: createMethod(false)
  645. };
  646. var hiddenKeys = {};
  647. var indexOf = arrayIncludes.indexOf;
  648. var push = functionUncurryThis([].push);
  649. var objectKeysInternal = function (object, names) {
  650. var O = toIndexedObject(object);
  651. var i = 0;
  652. var result = [];
  653. var key;
  654. for (key in O) !hasOwnProperty_1(hiddenKeys, key) && hasOwnProperty_1(O, key) && push(result, key);
  655. // Don't enum bug & hidden keys
  656. while (names.length > i) if (hasOwnProperty_1(O, key = names[i++])) {
  657. ~indexOf(result, key) || push(result, key);
  658. }
  659. return result;
  660. };
  661. // IE8- don't enum bug keys
  662. var enumBugKeys = [
  663. 'constructor',
  664. 'hasOwnProperty',
  665. 'isPrototypeOf',
  666. 'propertyIsEnumerable',
  667. 'toLocaleString',
  668. 'toString',
  669. 'valueOf'
  670. ];
  671. // `Object.keys` method
  672. // https://tc39.es/ecma262/#sec-object.keys
  673. // eslint-disable-next-line es-x/no-object-keys -- safe
  674. var objectKeys = Object.keys || function keys(O) {
  675. return objectKeysInternal(O, enumBugKeys);
  676. };
  677. // `Object.defineProperties` method
  678. // https://tc39.es/ecma262/#sec-object.defineproperties
  679. // eslint-disable-next-line es-x/no-object-defineproperties -- safe
  680. var f$3 = descriptors && !v8PrototypeDefineBug ? Object.defineProperties : function defineProperties(O, Properties) {
  681. anObject(O);
  682. var props = toIndexedObject(Properties);
  683. var keys = objectKeys(Properties);
  684. var length = keys.length;
  685. var index = 0;
  686. var key;
  687. while (length > index) objectDefineProperty.f(O, key = keys[index++], props[key]);
  688. return O;
  689. };
  690. var objectDefineProperties = {
  691. f: f$3
  692. };
  693. var html = getBuiltIn('document', 'documentElement');
  694. var keys = shared('keys');
  695. var sharedKey = function (key) {
  696. return keys[key] || (keys[key] = uid(key));
  697. };
  698. /* global ActiveXObject -- old IE, WSH */
  699. var GT = '>';
  700. var LT = '<';
  701. var PROTOTYPE = 'prototype';
  702. var SCRIPT = 'script';
  703. var IE_PROTO = sharedKey('IE_PROTO');
  704. var EmptyConstructor = function () { /* empty */ };
  705. var scriptTag = function (content) {
  706. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  707. };
  708. // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
  709. var NullProtoObjectViaActiveX = function (activeXDocument) {
  710. activeXDocument.write(scriptTag(''));
  711. activeXDocument.close();
  712. var temp = activeXDocument.parentWindow.Object;
  713. activeXDocument = null; // avoid memory leak
  714. return temp;
  715. };
  716. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  717. var NullProtoObjectViaIFrame = function () {
  718. // Thrash, waste and sodomy: IE GC bug
  719. var iframe = documentCreateElement('iframe');
  720. var JS = 'java' + SCRIPT + ':';
  721. var iframeDocument;
  722. iframe.style.display = 'none';
  723. html.appendChild(iframe);
  724. // https://github.com/zloirock/core-js/issues/475
  725. iframe.src = String(JS);
  726. iframeDocument = iframe.contentWindow.document;
  727. iframeDocument.open();
  728. iframeDocument.write(scriptTag('document.F=Object'));
  729. iframeDocument.close();
  730. return iframeDocument.F;
  731. };
  732. // Check for document.domain and active x support
  733. // No need to use active x approach when document.domain is not set
  734. // see https://github.com/es-shims/es5-shim/issues/150
  735. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  736. // avoid IE GC bug
  737. var activeXDocument;
  738. var NullProtoObject = function () {
  739. try {
  740. activeXDocument = new ActiveXObject('htmlfile');
  741. } catch (error) { /* ignore */ }
  742. NullProtoObject = typeof document != 'undefined'
  743. ? document.domain && activeXDocument
  744. ? NullProtoObjectViaActiveX(activeXDocument) // old IE
  745. : NullProtoObjectViaIFrame()
  746. : NullProtoObjectViaActiveX(activeXDocument); // WSH
  747. var length = enumBugKeys.length;
  748. while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  749. return NullProtoObject();
  750. };
  751. hiddenKeys[IE_PROTO] = true;
  752. // `Object.create` method
  753. // https://tc39.es/ecma262/#sec-object.create
  754. // eslint-disable-next-line es-x/no-object-create -- safe
  755. var objectCreate = Object.create || function create(O, Properties) {
  756. var result;
  757. if (O !== null) {
  758. EmptyConstructor[PROTOTYPE] = anObject(O);
  759. result = new EmptyConstructor();
  760. EmptyConstructor[PROTOTYPE] = null;
  761. // add "__proto__" for Object.getPrototypeOf polyfill
  762. result[IE_PROTO] = O;
  763. } else result = NullProtoObject();
  764. return Properties === undefined ? result : objectDefineProperties.f(result, Properties);
  765. };
  766. var nativeConstruct = getBuiltIn('Reflect', 'construct');
  767. var ObjectPrototype = Object.prototype;
  768. var push$1 = [].push;
  769. // `Reflect.construct` method
  770. // https://tc39.es/ecma262/#sec-reflect.construct
  771. // MS Edge supports only 2 arguments and argumentsList argument is optional
  772. // FF Nightly sets third argument as `new.target`, but does not create `this` from it
  773. var NEW_TARGET_BUG = fails(function () {
  774. function F() { /* empty */ }
  775. return !(nativeConstruct(function () { /* empty */ }, [], F) instanceof F);
  776. });
  777. var ARGS_BUG = !fails(function () {
  778. nativeConstruct(function () { /* empty */ });
  779. });
  780. var FORCED = NEW_TARGET_BUG || ARGS_BUG;
  781. _export({ target: 'Reflect', stat: true, forced: FORCED, sham: FORCED }, {
  782. construct: function construct(Target, args /* , newTarget */) {
  783. aConstructor(Target);
  784. anObject(args);
  785. var newTarget = arguments.length < 3 ? Target : aConstructor(arguments[2]);
  786. if (ARGS_BUG && !NEW_TARGET_BUG) return nativeConstruct(Target, args, newTarget);
  787. if (Target == newTarget) {
  788. // w/o altered newTarget, optimization for 0-4 arguments
  789. switch (args.length) {
  790. case 0: return new Target();
  791. case 1: return new Target(args[0]);
  792. case 2: return new Target(args[0], args[1]);
  793. case 3: return new Target(args[0], args[1], args[2]);
  794. case 4: return new Target(args[0], args[1], args[2], args[3]);
  795. }
  796. // w/o altered newTarget, lot of arguments case
  797. var $args = [null];
  798. functionApply(push$1, $args, args);
  799. return new (functionApply(functionBind, Target, $args))();
  800. }
  801. // with altered newTarget, not support built-in constructors
  802. var proto = newTarget.prototype;
  803. var instance = objectCreate(isObject(proto) ? proto : ObjectPrototype);
  804. var result = functionApply(Target, instance, args);
  805. return isObject(result) ? result : instance;
  806. }
  807. });
  808. var construct$2 = path.Reflect.construct;
  809. var construct$3 = construct$2;
  810. var construct$4 = construct$3;
  811. var FAILS_ON_PRIMITIVES = fails(function () { objectKeys(1); });
  812. // `Object.keys` method
  813. // https://tc39.es/ecma262/#sec-object.keys
  814. _export({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
  815. keys: function keys(it) {
  816. return objectKeys(toObject(it));
  817. }
  818. });
  819. var keys$1 = path.Object.keys;
  820. var keys$2 = keys$1;
  821. var keys$3 = keys$2;
  822. var String$3 = global_1.String;
  823. var toString_1 = function (argument) {
  824. if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
  825. return String$3(argument);
  826. };
  827. var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype');
  828. // `Object.getOwnPropertyNames` method
  829. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  830. // eslint-disable-next-line es-x/no-object-getownpropertynames -- safe
  831. var f$4 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  832. return objectKeysInternal(O, hiddenKeys$1);
  833. };
  834. var objectGetOwnPropertyNames = {
  835. f: f$4
  836. };
  837. var createProperty = function (object, key, value) {
  838. var propertyKey = toPropertyKey(key);
  839. if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));
  840. else object[propertyKey] = value;
  841. };
  842. var Array$1 = global_1.Array;
  843. var max$1 = Math.max;
  844. var arraySliceSimple = function (O, start, end) {
  845. var length = lengthOfArrayLike(O);
  846. var k = toAbsoluteIndex(start, length);
  847. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  848. var result = Array$1(max$1(fin - k, 0));
  849. for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]);
  850. result.length = n;
  851. return result;
  852. };
  853. /* eslint-disable es-x/no-object-getownpropertynames -- safe */
  854. var $getOwnPropertyNames = objectGetOwnPropertyNames.f;
  855. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  856. ? Object.getOwnPropertyNames(window) : [];
  857. var getWindowNames = function (it) {
  858. try {
  859. return $getOwnPropertyNames(it);
  860. } catch (error) {
  861. return arraySliceSimple(windowNames);
  862. }
  863. };
  864. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  865. var f$5 = function getOwnPropertyNames(it) {
  866. return windowNames && classofRaw(it) == 'Window'
  867. ? getWindowNames(it)
  868. : $getOwnPropertyNames(toIndexedObject(it));
  869. };
  870. var objectGetOwnPropertyNamesExternal = {
  871. f: f$5
  872. };
  873. // eslint-disable-next-line es-x/no-object-getownpropertysymbols -- safe
  874. var f$6 = Object.getOwnPropertySymbols;
  875. var objectGetOwnPropertySymbols = {
  876. f: f$6
  877. };
  878. var defineBuiltIn = function (target, key, value, options) {
  879. if (options && options.enumerable) target[key] = value;
  880. else createNonEnumerableProperty(target, key, value);
  881. return target;
  882. };
  883. var f$7 = wellKnownSymbol;
  884. var wellKnownSymbolWrapped = {
  885. f: f$7
  886. };
  887. var defineProperty$1 = objectDefineProperty.f;
  888. var defineWellKnownSymbol = function (NAME) {
  889. var Symbol = path.Symbol || (path.Symbol = {});
  890. if (!hasOwnProperty_1(Symbol, NAME)) defineProperty$1(Symbol, NAME, {
  891. value: wellKnownSymbolWrapped.f(NAME)
  892. });
  893. };
  894. var symbolDefineToPrimitive = function () {
  895. var Symbol = getBuiltIn('Symbol');
  896. var SymbolPrototype = Symbol && Symbol.prototype;
  897. var valueOf = SymbolPrototype && SymbolPrototype.valueOf;
  898. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  899. if (SymbolPrototype && !SymbolPrototype[TO_PRIMITIVE]) {
  900. // `Symbol.prototype[@@toPrimitive]` method
  901. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  902. // eslint-disable-next-line no-unused-vars -- required for .length
  903. defineBuiltIn(SymbolPrototype, TO_PRIMITIVE, function (hint) {
  904. return functionCall(valueOf, this);
  905. }, { arity: 1 });
  906. }
  907. };
  908. // `Object.prototype.toString` method implementation
  909. // https://tc39.es/ecma262/#sec-object.prototype.tostring
  910. var objectToString = toStringTagSupport ? {}.toString : function toString() {
  911. return '[object ' + classof(this) + ']';
  912. };
  913. var defineProperty$2 = objectDefineProperty.f;
  914. var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag');
  915. var setToStringTag = function (it, TAG, STATIC, SET_METHOD) {
  916. if (it) {
  917. var target = STATIC ? it : it.prototype;
  918. if (!hasOwnProperty_1(target, TO_STRING_TAG$2)) {
  919. defineProperty$2(target, TO_STRING_TAG$2, { configurable: true, value: TAG });
  920. }
  921. if (SET_METHOD && !toStringTagSupport) {
  922. createNonEnumerableProperty(target, 'toString', objectToString);
  923. }
  924. }
  925. };
  926. var WeakMap = global_1.WeakMap;
  927. var nativeWeakMap = isCallable(WeakMap) && /native code/.test(inspectSource(WeakMap));
  928. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  929. var TypeError$8 = global_1.TypeError;
  930. var WeakMap$1 = global_1.WeakMap;
  931. var set, get, has;
  932. var enforce = function (it) {
  933. return has(it) ? get(it) : set(it, {});
  934. };
  935. var getterFor = function (TYPE) {
  936. return function (it) {
  937. var state;
  938. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  939. throw TypeError$8('Incompatible receiver, ' + TYPE + ' required');
  940. } return state;
  941. };
  942. };
  943. if (nativeWeakMap || sharedStore.state) {
  944. var store$1 = sharedStore.state || (sharedStore.state = new WeakMap$1());
  945. var wmget = functionUncurryThis(store$1.get);
  946. var wmhas = functionUncurryThis(store$1.has);
  947. var wmset = functionUncurryThis(store$1.set);
  948. set = function (it, metadata) {
  949. if (wmhas(store$1, it)) throw new TypeError$8(OBJECT_ALREADY_INITIALIZED);
  950. metadata.facade = it;
  951. wmset(store$1, it, metadata);
  952. return metadata;
  953. };
  954. get = function (it) {
  955. return wmget(store$1, it) || {};
  956. };
  957. has = function (it) {
  958. return wmhas(store$1, it);
  959. };
  960. } else {
  961. var STATE = sharedKey('state');
  962. hiddenKeys[STATE] = true;
  963. set = function (it, metadata) {
  964. if (hasOwnProperty_1(it, STATE)) throw new TypeError$8(OBJECT_ALREADY_INITIALIZED);
  965. metadata.facade = it;
  966. createNonEnumerableProperty(it, STATE, metadata);
  967. return metadata;
  968. };
  969. get = function (it) {
  970. return hasOwnProperty_1(it, STATE) ? it[STATE] : {};
  971. };
  972. has = function (it) {
  973. return hasOwnProperty_1(it, STATE);
  974. };
  975. }
  976. var internalState = {
  977. set: set,
  978. get: get,
  979. has: has,
  980. enforce: enforce,
  981. getterFor: getterFor
  982. };
  983. // `IsArray` abstract operation
  984. // https://tc39.es/ecma262/#sec-isarray
  985. // eslint-disable-next-line es-x/no-array-isarray -- safe
  986. var isArray = Array.isArray || function isArray(argument) {
  987. return classofRaw(argument) == 'Array';
  988. };
  989. var SPECIES = wellKnownSymbol('species');
  990. var Array$2 = global_1.Array;
  991. // a part of `ArraySpeciesCreate` abstract operation
  992. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  993. var arraySpeciesConstructor = function (originalArray) {
  994. var C;
  995. if (isArray(originalArray)) {
  996. C = originalArray.constructor;
  997. // cross-realm fallback
  998. if (isConstructor(C) && (C === Array$2 || isArray(C.prototype))) C = undefined;
  999. else if (isObject(C)) {
  1000. C = C[SPECIES];
  1001. if (C === null) C = undefined;
  1002. }
  1003. } return C === undefined ? Array$2 : C;
  1004. };
  1005. // `ArraySpeciesCreate` abstract operation
  1006. // https://tc39.es/ecma262/#sec-arrayspeciescreate
  1007. var arraySpeciesCreate = function (originalArray, length) {
  1008. return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
  1009. };
  1010. var push$2 = functionUncurryThis([].push);
  1011. // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation
  1012. var createMethod$1 = function (TYPE) {
  1013. var IS_MAP = TYPE == 1;
  1014. var IS_FILTER = TYPE == 2;
  1015. var IS_SOME = TYPE == 3;
  1016. var IS_EVERY = TYPE == 4;
  1017. var IS_FIND_INDEX = TYPE == 6;
  1018. var IS_FILTER_REJECT = TYPE == 7;
  1019. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  1020. return function ($this, callbackfn, that, specificCreate) {
  1021. var O = toObject($this);
  1022. var self = indexedObject(O);
  1023. var boundFunction = functionBindContext(callbackfn, that);
  1024. var length = lengthOfArrayLike(self);
  1025. var index = 0;
  1026. var create = specificCreate || arraySpeciesCreate;
  1027. var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined;
  1028. var value, result;
  1029. for (;length > index; index++) if (NO_HOLES || index in self) {
  1030. value = self[index];
  1031. result = boundFunction(value, index, O);
  1032. if (TYPE) {
  1033. if (IS_MAP) target[index] = result; // map
  1034. else if (result) switch (TYPE) {
  1035. case 3: return true; // some
  1036. case 5: return value; // find
  1037. case 6: return index; // findIndex
  1038. case 2: push$2(target, value); // filter
  1039. } else switch (TYPE) {
  1040. case 4: return false; // every
  1041. case 7: push$2(target, value); // filterReject
  1042. }
  1043. }
  1044. }
  1045. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  1046. };
  1047. };
  1048. var arrayIteration = {
  1049. // `Array.prototype.forEach` method
  1050. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  1051. forEach: createMethod$1(0),
  1052. // `Array.prototype.map` method
  1053. // https://tc39.es/ecma262/#sec-array.prototype.map
  1054. map: createMethod$1(1),
  1055. // `Array.prototype.filter` method
  1056. // https://tc39.es/ecma262/#sec-array.prototype.filter
  1057. filter: createMethod$1(2),
  1058. // `Array.prototype.some` method
  1059. // https://tc39.es/ecma262/#sec-array.prototype.some
  1060. some: createMethod$1(3),
  1061. // `Array.prototype.every` method
  1062. // https://tc39.es/ecma262/#sec-array.prototype.every
  1063. every: createMethod$1(4),
  1064. // `Array.prototype.find` method
  1065. // https://tc39.es/ecma262/#sec-array.prototype.find
  1066. find: createMethod$1(5),
  1067. // `Array.prototype.findIndex` method
  1068. // https://tc39.es/ecma262/#sec-array.prototype.findIndex
  1069. findIndex: createMethod$1(6),
  1070. // `Array.prototype.filterReject` method
  1071. // https://github.com/tc39/proposal-array-filtering
  1072. filterReject: createMethod$1(7)
  1073. };
  1074. var $forEach = arrayIteration.forEach;
  1075. var HIDDEN = sharedKey('hidden');
  1076. var SYMBOL = 'Symbol';
  1077. var PROTOTYPE$1 = 'prototype';
  1078. var setInternalState = internalState.set;
  1079. var getInternalState = internalState.getterFor(SYMBOL);
  1080. var ObjectPrototype$1 = Object[PROTOTYPE$1];
  1081. var $Symbol = global_1.Symbol;
  1082. var SymbolPrototype = $Symbol && $Symbol[PROTOTYPE$1];
  1083. var TypeError$9 = global_1.TypeError;
  1084. var QObject = global_1.QObject;
  1085. var nativeGetOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  1086. var nativeDefineProperty = objectDefineProperty.f;
  1087. var nativeGetOwnPropertyNames = objectGetOwnPropertyNamesExternal.f;
  1088. var nativePropertyIsEnumerable = objectPropertyIsEnumerable.f;
  1089. var push$3 = functionUncurryThis([].push);
  1090. var AllSymbols = shared('symbols');
  1091. var ObjectPrototypeSymbols = shared('op-symbols');
  1092. var WellKnownSymbolsStore$1 = shared('wks');
  1093. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  1094. var USE_SETTER = !QObject || !QObject[PROTOTYPE$1] || !QObject[PROTOTYPE$1].findChild;
  1095. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  1096. var setSymbolDescriptor = descriptors && fails(function () {
  1097. return objectCreate(nativeDefineProperty({}, 'a', {
  1098. get: function () { return nativeDefineProperty(this, 'a', { value: 7 }).a; }
  1099. })).a != 7;
  1100. }) ? function (O, P, Attributes) {
  1101. var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype$1, P);
  1102. if (ObjectPrototypeDescriptor) delete ObjectPrototype$1[P];
  1103. nativeDefineProperty(O, P, Attributes);
  1104. if (ObjectPrototypeDescriptor && O !== ObjectPrototype$1) {
  1105. nativeDefineProperty(ObjectPrototype$1, P, ObjectPrototypeDescriptor);
  1106. }
  1107. } : nativeDefineProperty;
  1108. var wrap = function (tag, description) {
  1109. var symbol = AllSymbols[tag] = objectCreate(SymbolPrototype);
  1110. setInternalState(symbol, {
  1111. type: SYMBOL,
  1112. tag: tag,
  1113. description: description
  1114. });
  1115. if (!descriptors) symbol.description = description;
  1116. return symbol;
  1117. };
  1118. var $defineProperty$1 = function defineProperty(O, P, Attributes) {
  1119. if (O === ObjectPrototype$1) $defineProperty$1(ObjectPrototypeSymbols, P, Attributes);
  1120. anObject(O);
  1121. var key = toPropertyKey(P);
  1122. anObject(Attributes);
  1123. if (hasOwnProperty_1(AllSymbols, key)) {
  1124. if (!Attributes.enumerable) {
  1125. if (!hasOwnProperty_1(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {}));
  1126. O[HIDDEN][key] = true;
  1127. } else {
  1128. if (hasOwnProperty_1(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;
  1129. Attributes = objectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) });
  1130. } return setSymbolDescriptor(O, key, Attributes);
  1131. } return nativeDefineProperty(O, key, Attributes);
  1132. };
  1133. var $defineProperties = function defineProperties(O, Properties) {
  1134. anObject(O);
  1135. var properties = toIndexedObject(Properties);
  1136. var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));
  1137. $forEach(keys, function (key) {
  1138. if (!descriptors || functionCall($propertyIsEnumerable$1, properties, key)) $defineProperty$1(O, key, properties[key]);
  1139. });
  1140. return O;
  1141. };
  1142. var $create = function create(O, Properties) {
  1143. return Properties === undefined ? objectCreate(O) : $defineProperties(objectCreate(O), Properties);
  1144. };
  1145. var $propertyIsEnumerable$1 = function propertyIsEnumerable(V) {
  1146. var P = toPropertyKey(V);
  1147. var enumerable = functionCall(nativePropertyIsEnumerable, this, P);
  1148. if (this === ObjectPrototype$1 && hasOwnProperty_1(AllSymbols, P) && !hasOwnProperty_1(ObjectPrototypeSymbols, P)) return false;
  1149. return enumerable || !hasOwnProperty_1(this, P) || !hasOwnProperty_1(AllSymbols, P) || hasOwnProperty_1(this, HIDDEN) && this[HIDDEN][P]
  1150. ? enumerable : true;
  1151. };
  1152. var $getOwnPropertyDescriptor$2 = function getOwnPropertyDescriptor(O, P) {
  1153. var it = toIndexedObject(O);
  1154. var key = toPropertyKey(P);
  1155. if (it === ObjectPrototype$1 && hasOwnProperty_1(AllSymbols, key) && !hasOwnProperty_1(ObjectPrototypeSymbols, key)) return;
  1156. var descriptor = nativeGetOwnPropertyDescriptor(it, key);
  1157. if (descriptor && hasOwnProperty_1(AllSymbols, key) && !(hasOwnProperty_1(it, HIDDEN) && it[HIDDEN][key])) {
  1158. descriptor.enumerable = true;
  1159. }
  1160. return descriptor;
  1161. };
  1162. var $getOwnPropertyNames$1 = function getOwnPropertyNames(O) {
  1163. var names = nativeGetOwnPropertyNames(toIndexedObject(O));
  1164. var result = [];
  1165. $forEach(names, function (key) {
  1166. if (!hasOwnProperty_1(AllSymbols, key) && !hasOwnProperty_1(hiddenKeys, key)) push$3(result, key);
  1167. });
  1168. return result;
  1169. };
  1170. var $getOwnPropertySymbols = function (O) {
  1171. var IS_OBJECT_PROTOTYPE = O === ObjectPrototype$1;
  1172. var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));
  1173. var result = [];
  1174. $forEach(names, function (key) {
  1175. if (hasOwnProperty_1(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || hasOwnProperty_1(ObjectPrototype$1, key))) {
  1176. push$3(result, AllSymbols[key]);
  1177. }
  1178. });
  1179. return result;
  1180. };
  1181. // `Symbol` constructor
  1182. // https://tc39.es/ecma262/#sec-symbol-constructor
  1183. if (!nativeSymbol) {
  1184. $Symbol = function Symbol() {
  1185. if (objectIsPrototypeOf(SymbolPrototype, this)) throw TypeError$9('Symbol is not a constructor');
  1186. var description = !arguments.length || arguments[0] === undefined ? undefined : toString_1(arguments[0]);
  1187. var tag = uid(description);
  1188. var setter = function (value) {
  1189. if (this === ObjectPrototype$1) functionCall(setter, ObjectPrototypeSymbols, value);
  1190. if (hasOwnProperty_1(this, HIDDEN) && hasOwnProperty_1(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  1191. setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));
  1192. };
  1193. if (descriptors && USE_SETTER) setSymbolDescriptor(ObjectPrototype$1, tag, { configurable: true, set: setter });
  1194. return wrap(tag, description);
  1195. };
  1196. SymbolPrototype = $Symbol[PROTOTYPE$1];
  1197. defineBuiltIn(SymbolPrototype, 'toString', function toString() {
  1198. return getInternalState(this).tag;
  1199. });
  1200. defineBuiltIn($Symbol, 'withoutSetter', function (description) {
  1201. return wrap(uid(description), description);
  1202. });
  1203. objectPropertyIsEnumerable.f = $propertyIsEnumerable$1;
  1204. objectDefineProperty.f = $defineProperty$1;
  1205. objectDefineProperties.f = $defineProperties;
  1206. objectGetOwnPropertyDescriptor.f = $getOwnPropertyDescriptor$2;
  1207. objectGetOwnPropertyNames.f = objectGetOwnPropertyNamesExternal.f = $getOwnPropertyNames$1;
  1208. objectGetOwnPropertySymbols.f = $getOwnPropertySymbols;
  1209. wellKnownSymbolWrapped.f = function (name) {
  1210. return wrap(wellKnownSymbol(name), name);
  1211. };
  1212. if (descriptors) {
  1213. // https://github.com/tc39/proposal-Symbol-description
  1214. nativeDefineProperty(SymbolPrototype, 'description', {
  1215. configurable: true,
  1216. get: function description() {
  1217. return getInternalState(this).description;
  1218. }
  1219. });
  1220. }
  1221. }
  1222. _export({ global: true, constructor: true, wrap: true, forced: !nativeSymbol, sham: !nativeSymbol }, {
  1223. Symbol: $Symbol
  1224. });
  1225. $forEach(objectKeys(WellKnownSymbolsStore$1), function (name) {
  1226. defineWellKnownSymbol(name);
  1227. });
  1228. _export({ target: SYMBOL, stat: true, forced: !nativeSymbol }, {
  1229. useSetter: function () { USE_SETTER = true; },
  1230. useSimple: function () { USE_SETTER = false; }
  1231. });
  1232. _export({ target: 'Object', stat: true, forced: !nativeSymbol, sham: !descriptors }, {
  1233. // `Object.create` method
  1234. // https://tc39.es/ecma262/#sec-object.create
  1235. create: $create,
  1236. // `Object.defineProperty` method
  1237. // https://tc39.es/ecma262/#sec-object.defineproperty
  1238. defineProperty: $defineProperty$1,
  1239. // `Object.defineProperties` method
  1240. // https://tc39.es/ecma262/#sec-object.defineproperties
  1241. defineProperties: $defineProperties,
  1242. // `Object.getOwnPropertyDescriptor` method
  1243. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
  1244. getOwnPropertyDescriptor: $getOwnPropertyDescriptor$2
  1245. });
  1246. _export({ target: 'Object', stat: true, forced: !nativeSymbol }, {
  1247. // `Object.getOwnPropertyNames` method
  1248. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  1249. getOwnPropertyNames: $getOwnPropertyNames$1
  1250. });
  1251. // `Symbol.prototype[@@toPrimitive]` method
  1252. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  1253. symbolDefineToPrimitive();
  1254. // `Symbol.prototype[@@toStringTag]` property
  1255. // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag
  1256. setToStringTag($Symbol, SYMBOL);
  1257. hiddenKeys[HIDDEN] = true;
  1258. /* eslint-disable es-x/no-symbol -- safe */
  1259. var nativeSymbolRegistry = nativeSymbol && !!Symbol['for'] && !!Symbol.keyFor;
  1260. var StringToSymbolRegistry = shared('string-to-symbol-registry');
  1261. var SymbolToStringRegistry = shared('symbol-to-string-registry');
  1262. // `Symbol.for` method
  1263. // https://tc39.es/ecma262/#sec-symbol.for
  1264. _export({ target: 'Symbol', stat: true, forced: !nativeSymbolRegistry }, {
  1265. 'for': function (key) {
  1266. var string = toString_1(key);
  1267. if (hasOwnProperty_1(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];
  1268. var symbol = getBuiltIn('Symbol')(string);
  1269. StringToSymbolRegistry[string] = symbol;
  1270. SymbolToStringRegistry[symbol] = string;
  1271. return symbol;
  1272. }
  1273. });
  1274. var SymbolToStringRegistry$1 = shared('symbol-to-string-registry');
  1275. // `Symbol.keyFor` method
  1276. // https://tc39.es/ecma262/#sec-symbol.keyfor
  1277. _export({ target: 'Symbol', stat: true, forced: !nativeSymbolRegistry }, {
  1278. keyFor: function keyFor(sym) {
  1279. if (!isSymbol(sym)) throw TypeError(tryToString(sym) + ' is not a symbol');
  1280. if (hasOwnProperty_1(SymbolToStringRegistry$1, sym)) return SymbolToStringRegistry$1[sym];
  1281. }
  1282. });
  1283. var $stringify = getBuiltIn('JSON', 'stringify');
  1284. var exec$1 = functionUncurryThis(/./.exec);
  1285. var charAt = functionUncurryThis(''.charAt);
  1286. var charCodeAt = functionUncurryThis(''.charCodeAt);
  1287. var replace = functionUncurryThis(''.replace);
  1288. var numberToString = functionUncurryThis(1.0.toString);
  1289. var tester = /[\uD800-\uDFFF]/g;
  1290. var low = /^[\uD800-\uDBFF]$/;
  1291. var hi = /^[\uDC00-\uDFFF]$/;
  1292. var WRONG_SYMBOLS_CONVERSION = !nativeSymbol || fails(function () {
  1293. var symbol = getBuiltIn('Symbol')();
  1294. // MS Edge converts symbol values to JSON as {}
  1295. return $stringify([symbol]) != '[null]'
  1296. // WebKit converts symbol values to JSON as null
  1297. || $stringify({ a: symbol }) != '{}'
  1298. // V8 throws on boxed symbols
  1299. || $stringify(Object(symbol)) != '{}';
  1300. });
  1301. // https://github.com/tc39/proposal-well-formed-stringify
  1302. var ILL_FORMED_UNICODE = fails(function () {
  1303. return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"'
  1304. || $stringify('\uDEAD') !== '"\\udead"';
  1305. });
  1306. var stringifyWithSymbolsFix = function (it, replacer) {
  1307. var args = arraySlice(arguments);
  1308. var $replacer = replacer;
  1309. if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
  1310. if (!isArray(replacer)) replacer = function (key, value) {
  1311. if (isCallable($replacer)) value = functionCall($replacer, this, key, value);
  1312. if (!isSymbol(value)) return value;
  1313. };
  1314. args[1] = replacer;
  1315. return functionApply($stringify, null, args);
  1316. };
  1317. var fixIllFormed = function (match, offset, string) {
  1318. var prev = charAt(string, offset - 1);
  1319. var next = charAt(string, offset + 1);
  1320. if ((exec$1(low, match) && !exec$1(hi, next)) || (exec$1(hi, match) && !exec$1(low, prev))) {
  1321. return '\\u' + numberToString(charCodeAt(match, 0), 16);
  1322. } return match;
  1323. };
  1324. if ($stringify) {
  1325. // `JSON.stringify` method
  1326. // https://tc39.es/ecma262/#sec-json.stringify
  1327. _export({ target: 'JSON', stat: true, arity: 3, forced: WRONG_SYMBOLS_CONVERSION || ILL_FORMED_UNICODE }, {
  1328. // eslint-disable-next-line no-unused-vars -- required for `.length`
  1329. stringify: function stringify(it, replacer, space) {
  1330. var args = arraySlice(arguments);
  1331. var result = functionApply(WRONG_SYMBOLS_CONVERSION ? stringifyWithSymbolsFix : $stringify, null, args);
  1332. return ILL_FORMED_UNICODE && typeof result == 'string' ? replace(result, tester, fixIllFormed) : result;
  1333. }
  1334. });
  1335. }
  1336. // V8 ~ Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
  1337. // https://bugs.chromium.org/p/v8/issues/detail?id=3443
  1338. var FORCED$1 = !nativeSymbol || fails(function () { objectGetOwnPropertySymbols.f(1); });
  1339. // `Object.getOwnPropertySymbols` method
  1340. // https://tc39.es/ecma262/#sec-object.getownpropertysymbols
  1341. _export({ target: 'Object', stat: true, forced: FORCED$1 }, {
  1342. getOwnPropertySymbols: function getOwnPropertySymbols(it) {
  1343. var $getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
  1344. return $getOwnPropertySymbols ? $getOwnPropertySymbols(toObject(it)) : [];
  1345. }
  1346. });
  1347. var getOwnPropertySymbols = path.Object.getOwnPropertySymbols;
  1348. var getOwnPropertySymbols$1 = getOwnPropertySymbols;
  1349. var getOwnPropertySymbols$2 = getOwnPropertySymbols$1;
  1350. var SPECIES$1 = wellKnownSymbol('species');
  1351. var arrayMethodHasSpeciesSupport = function (METHOD_NAME) {
  1352. // We can't use this feature detection in V8 since it causes
  1353. // deoptimization and serious performance degradation
  1354. // https://github.com/zloirock/core-js/issues/677
  1355. return engineV8Version >= 51 || !fails(function () {
  1356. var array = [];
  1357. var constructor = array.constructor = {};
  1358. constructor[SPECIES$1] = function () {
  1359. return { foo: 1 };
  1360. };
  1361. return array[METHOD_NAME](Boolean).foo !== 1;
  1362. });
  1363. };
  1364. var $filter = arrayIteration.filter;
  1365. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter');
  1366. // `Array.prototype.filter` method
  1367. // https://tc39.es/ecma262/#sec-array.prototype.filter
  1368. // with adding support of @@species
  1369. _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  1370. filter: function filter(callbackfn /* , thisArg */) {
  1371. return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  1372. }
  1373. });
  1374. var entryVirtual = function (CONSTRUCTOR) {
  1375. return path[CONSTRUCTOR + 'Prototype'];
  1376. };
  1377. var filter = entryVirtual('Array').filter;
  1378. var ArrayPrototype = Array.prototype;
  1379. var filter$1 = function (it) {
  1380. var own = it.filter;
  1381. return it === ArrayPrototype || (objectIsPrototypeOf(ArrayPrototype, it) && own === ArrayPrototype.filter) ? filter : own;
  1382. };
  1383. var filter$2 = filter$1;
  1384. var filter$3 = filter$2;
  1385. var nativeGetOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
  1386. var FAILS_ON_PRIMITIVES$1 = fails(function () { nativeGetOwnPropertyDescriptor$1(1); });
  1387. var FORCED$2 = !descriptors || FAILS_ON_PRIMITIVES$1;
  1388. // `Object.getOwnPropertyDescriptor` method
  1389. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  1390. _export({ target: 'Object', stat: true, forced: FORCED$2, sham: !descriptors }, {
  1391. getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) {
  1392. return nativeGetOwnPropertyDescriptor$1(toIndexedObject(it), key);
  1393. }
  1394. });
  1395. var getOwnPropertyDescriptor_1 = createCommonjsModule(function (module) {
  1396. var Object = path.Object;
  1397. var getOwnPropertyDescriptor = module.exports = function getOwnPropertyDescriptor(it, key) {
  1398. return Object.getOwnPropertyDescriptor(it, key);
  1399. };
  1400. if (Object.getOwnPropertyDescriptor.sham) getOwnPropertyDescriptor.sham = true;
  1401. });
  1402. var getOwnPropertyDescriptor$2 = getOwnPropertyDescriptor_1;
  1403. var getOwnPropertyDescriptor$3 = getOwnPropertyDescriptor$2;
  1404. var iterators = {};
  1405. var FunctionPrototype$2 = Function.prototype;
  1406. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  1407. var getDescriptor = descriptors && Object.getOwnPropertyDescriptor;
  1408. var EXISTS$1 = hasOwnProperty_1(FunctionPrototype$2, 'name');
  1409. // additional protection from minified / mangled / dropped function names
  1410. var PROPER = EXISTS$1 && (function something() { /* empty */ }).name === 'something';
  1411. var CONFIGURABLE$1 = EXISTS$1 && (!descriptors || (descriptors && getDescriptor(FunctionPrototype$2, 'name').configurable));
  1412. var functionName = {
  1413. EXISTS: EXISTS$1,
  1414. PROPER: PROPER,
  1415. CONFIGURABLE: CONFIGURABLE$1
  1416. };
  1417. var correctPrototypeGetter = !fails(function () {
  1418. function F() { /* empty */ }
  1419. F.prototype.constructor = null;
  1420. // eslint-disable-next-line es-x/no-object-getprototypeof -- required for testing
  1421. return Object.getPrototypeOf(new F()) !== F.prototype;
  1422. });
  1423. var IE_PROTO$1 = sharedKey('IE_PROTO');
  1424. var Object$5 = global_1.Object;
  1425. var ObjectPrototype$2 = Object$5.prototype;
  1426. // `Object.getPrototypeOf` method
  1427. // https://tc39.es/ecma262/#sec-object.getprototypeof
  1428. var objectGetPrototypeOf = correctPrototypeGetter ? Object$5.getPrototypeOf : function (O) {
  1429. var object = toObject(O);
  1430. if (hasOwnProperty_1(object, IE_PROTO$1)) return object[IE_PROTO$1];
  1431. var constructor = object.constructor;
  1432. if (isCallable(constructor) && object instanceof constructor) {
  1433. return constructor.prototype;
  1434. } return object instanceof Object$5 ? ObjectPrototype$2 : null;
  1435. };
  1436. var ITERATOR = wellKnownSymbol('iterator');
  1437. var BUGGY_SAFARI_ITERATORS = false;
  1438. // `%IteratorPrototype%` object
  1439. // https://tc39.es/ecma262/#sec-%iteratorprototype%-object
  1440. var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
  1441. /* eslint-disable es-x/no-array-prototype-keys -- safe */
  1442. if ([].keys) {
  1443. arrayIterator = [].keys();
  1444. // Safari 8 has buggy iterators w/o `next`
  1445. if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
  1446. else {
  1447. PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator));
  1448. if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
  1449. }
  1450. }
  1451. var NEW_ITERATOR_PROTOTYPE = IteratorPrototype == undefined || fails(function () {
  1452. var test = {};
  1453. // FF44- legacy iterators case
  1454. return IteratorPrototype[ITERATOR].call(test) !== test;
  1455. });
  1456. if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {};
  1457. else IteratorPrototype = objectCreate(IteratorPrototype);
  1458. // `%IteratorPrototype%[@@iterator]()` method
  1459. // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
  1460. if (!isCallable(IteratorPrototype[ITERATOR])) {
  1461. defineBuiltIn(IteratorPrototype, ITERATOR, function () {
  1462. return this;
  1463. });
  1464. }
  1465. var iteratorsCore = {
  1466. IteratorPrototype: IteratorPrototype,
  1467. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  1468. };
  1469. var IteratorPrototype$1 = iteratorsCore.IteratorPrototype;
  1470. var returnThis = function () { return this; };
  1471. var createIteratorConstructor = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) {
  1472. var TO_STRING_TAG = NAME + ' Iterator';
  1473. IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) });
  1474. setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
  1475. iterators[TO_STRING_TAG] = returnThis;
  1476. return IteratorConstructor;
  1477. };
  1478. var String$4 = global_1.String;
  1479. var TypeError$a = global_1.TypeError;
  1480. var aPossiblePrototype = function (argument) {
  1481. if (typeof argument == 'object' || isCallable(argument)) return argument;
  1482. throw TypeError$a("Can't set " + String$4(argument) + ' as a prototype');
  1483. };
  1484. /* eslint-disable no-proto -- safe */
  1485. // `Object.setPrototypeOf` method
  1486. // https://tc39.es/ecma262/#sec-object.setprototypeof
  1487. // Works with __proto__ only. Old v8 can't work with null proto objects.
  1488. // eslint-disable-next-line es-x/no-object-setprototypeof -- safe
  1489. var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () {
  1490. var CORRECT_SETTER = false;
  1491. var test = {};
  1492. var setter;
  1493. try {
  1494. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  1495. setter = functionUncurryThis(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
  1496. setter(test, []);
  1497. CORRECT_SETTER = test instanceof Array;
  1498. } catch (error) { /* empty */ }
  1499. return function setPrototypeOf(O, proto) {
  1500. anObject(O);
  1501. aPossiblePrototype(proto);
  1502. if (CORRECT_SETTER) setter(O, proto);
  1503. else O.__proto__ = proto;
  1504. return O;
  1505. };
  1506. }() : undefined);
  1507. var PROPER_FUNCTION_NAME = functionName.PROPER;
  1508. var BUGGY_SAFARI_ITERATORS$1 = iteratorsCore.BUGGY_SAFARI_ITERATORS;
  1509. var ITERATOR$1 = wellKnownSymbol('iterator');
  1510. var KEYS = 'keys';
  1511. var VALUES = 'values';
  1512. var ENTRIES = 'entries';
  1513. var returnThis$1 = function () { return this; };
  1514. var defineIterator = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
  1515. createIteratorConstructor(IteratorConstructor, NAME, next);
  1516. var getIterationMethod = function (KIND) {
  1517. if (KIND === DEFAULT && defaultIterator) return defaultIterator;
  1518. if (!BUGGY_SAFARI_ITERATORS$1 && KIND in IterablePrototype) return IterablePrototype[KIND];
  1519. switch (KIND) {
  1520. case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
  1521. case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
  1522. case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
  1523. } return function () { return new IteratorConstructor(this); };
  1524. };
  1525. var TO_STRING_TAG = NAME + ' Iterator';
  1526. var INCORRECT_VALUES_NAME = false;
  1527. var IterablePrototype = Iterable.prototype;
  1528. var nativeIterator = IterablePrototype[ITERATOR$1]
  1529. || IterablePrototype['@@iterator']
  1530. || DEFAULT && IterablePrototype[DEFAULT];
  1531. var defaultIterator = !BUGGY_SAFARI_ITERATORS$1 && nativeIterator || getIterationMethod(DEFAULT);
  1532. var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
  1533. var CurrentIteratorPrototype, methods, KEY;
  1534. // fix native
  1535. if (anyNativeIterator) {
  1536. CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable()));
  1537. if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
  1538. // Set @@toStringTag to native iterators
  1539. setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
  1540. iterators[TO_STRING_TAG] = returnThis$1;
  1541. }
  1542. }
  1543. // fix Array.prototype.{ values, @@iterator }.name in V8 / FF
  1544. if (PROPER_FUNCTION_NAME && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
  1545. {
  1546. INCORRECT_VALUES_NAME = true;
  1547. defaultIterator = function values() { return functionCall(nativeIterator, this); };
  1548. }
  1549. }
  1550. // export additional methods
  1551. if (DEFAULT) {
  1552. methods = {
  1553. values: getIterationMethod(VALUES),
  1554. keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
  1555. entries: getIterationMethod(ENTRIES)
  1556. };
  1557. if (FORCED) for (KEY in methods) {
  1558. if (BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
  1559. defineBuiltIn(IterablePrototype, KEY, methods[KEY]);
  1560. }
  1561. } else _export({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME }, methods);
  1562. }
  1563. // define iterator
  1564. if (( FORCED) && IterablePrototype[ITERATOR$1] !== defaultIterator) {
  1565. defineBuiltIn(IterablePrototype, ITERATOR$1, defaultIterator, { name: DEFAULT });
  1566. }
  1567. iterators[NAME] = defaultIterator;
  1568. return methods;
  1569. };
  1570. var ARRAY_ITERATOR = 'Array Iterator';
  1571. var setInternalState$1 = internalState.set;
  1572. var getInternalState$1 = internalState.getterFor(ARRAY_ITERATOR);
  1573. // `Array.prototype.entries` method
  1574. // https://tc39.es/ecma262/#sec-array.prototype.entries
  1575. // `Array.prototype.keys` method
  1576. // https://tc39.es/ecma262/#sec-array.prototype.keys
  1577. // `Array.prototype.values` method
  1578. // https://tc39.es/ecma262/#sec-array.prototype.values
  1579. // `Array.prototype[@@iterator]` method
  1580. // https://tc39.es/ecma262/#sec-array.prototype-@@iterator
  1581. // `CreateArrayIterator` internal method
  1582. // https://tc39.es/ecma262/#sec-createarrayiterator
  1583. var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind) {
  1584. setInternalState$1(this, {
  1585. type: ARRAY_ITERATOR,
  1586. target: toIndexedObject(iterated), // target
  1587. index: 0, // next index
  1588. kind: kind // kind
  1589. });
  1590. // `%ArrayIteratorPrototype%.next` method
  1591. // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next
  1592. }, function () {
  1593. var state = getInternalState$1(this);
  1594. var target = state.target;
  1595. var kind = state.kind;
  1596. var index = state.index++;
  1597. if (!target || index >= target.length) {
  1598. state.target = undefined;
  1599. return { value: undefined, done: true };
  1600. }
  1601. if (kind == 'keys') return { value: index, done: false };
  1602. if (kind == 'values') return { value: target[index], done: false };
  1603. return { value: [index, target[index]], done: false };
  1604. }, 'values');
  1605. // argumentsList[@@iterator] is %ArrayProto_values%
  1606. // https://tc39.es/ecma262/#sec-createunmappedargumentsobject
  1607. // https://tc39.es/ecma262/#sec-createmappedargumentsobject
  1608. var values = iterators.Arguments = iterators.Array;
  1609. // iterable DOM collections
  1610. // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
  1611. var domIterables = {
  1612. CSSRuleList: 0,
  1613. CSSStyleDeclaration: 0,
  1614. CSSValueList: 0,
  1615. ClientRectList: 0,
  1616. DOMRectList: 0,
  1617. DOMStringList: 0,
  1618. DOMTokenList: 1,
  1619. DataTransferItemList: 0,
  1620. FileList: 0,
  1621. HTMLAllCollection: 0,
  1622. HTMLCollection: 0,
  1623. HTMLFormElement: 0,
  1624. HTMLSelectElement: 0,
  1625. MediaList: 0,
  1626. MimeTypeArray: 0,
  1627. NamedNodeMap: 0,
  1628. NodeList: 1,
  1629. PaintRequestList: 0,
  1630. Plugin: 0,
  1631. PluginArray: 0,
  1632. SVGLengthList: 0,
  1633. SVGNumberList: 0,
  1634. SVGPathSegList: 0,
  1635. SVGPointList: 0,
  1636. SVGStringList: 0,
  1637. SVGTransformList: 0,
  1638. SourceBufferList: 0,
  1639. StyleSheetList: 0,
  1640. TextTrackCueList: 0,
  1641. TextTrackList: 0,
  1642. TouchList: 0
  1643. };
  1644. var TO_STRING_TAG$3 = wellKnownSymbol('toStringTag');
  1645. for (var COLLECTION_NAME in domIterables) {
  1646. var Collection = global_1[COLLECTION_NAME];
  1647. var CollectionPrototype = Collection && Collection.prototype;
  1648. if (CollectionPrototype && classof(CollectionPrototype) !== TO_STRING_TAG$3) {
  1649. createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG$3, COLLECTION_NAME);
  1650. }
  1651. iterators[COLLECTION_NAME] = iterators.Array;
  1652. }
  1653. var arrayMethodIsStrict = function (METHOD_NAME, argument) {
  1654. var method = [][METHOD_NAME];
  1655. return !!method && fails(function () {
  1656. // eslint-disable-next-line no-useless-call -- required for testing
  1657. method.call(null, argument || function () { return 1; }, 1);
  1658. });
  1659. };
  1660. var $forEach$1 = arrayIteration.forEach;
  1661. var STRICT_METHOD = arrayMethodIsStrict('forEach');
  1662. // `Array.prototype.forEach` method implementation
  1663. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  1664. var arrayForEach = !STRICT_METHOD ? function forEach(callbackfn /* , thisArg */) {
  1665. return $forEach$1(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  1666. // eslint-disable-next-line es-x/no-array-prototype-foreach -- safe
  1667. } : [].forEach;
  1668. // `Array.prototype.forEach` method
  1669. // https://tc39.es/ecma262/#sec-array.prototype.foreach
  1670. // eslint-disable-next-line es-x/no-array-prototype-foreach -- safe
  1671. _export({ target: 'Array', proto: true, forced: [].forEach != arrayForEach }, {
  1672. forEach: arrayForEach
  1673. });
  1674. var forEach = entryVirtual('Array').forEach;
  1675. var forEach$1 = forEach;
  1676. var ArrayPrototype$1 = Array.prototype;
  1677. var DOMIterables = {
  1678. DOMTokenList: true,
  1679. NodeList: true
  1680. };
  1681. var forEach$2 = function (it) {
  1682. var own = it.forEach;
  1683. return it === ArrayPrototype$1 || (objectIsPrototypeOf(ArrayPrototype$1, it) && own === ArrayPrototype$1.forEach)
  1684. || hasOwnProperty_1(DOMIterables, classof(it)) ? forEach$1 : own;
  1685. };
  1686. var forEach$3 = forEach$2;
  1687. var concat$1 = functionUncurryThis([].concat);
  1688. // all object keys, includes non-enumerable and symbols
  1689. var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  1690. var keys = objectGetOwnPropertyNames.f(anObject(it));
  1691. var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
  1692. return getOwnPropertySymbols ? concat$1(keys, getOwnPropertySymbols(it)) : keys;
  1693. };
  1694. // `Object.getOwnPropertyDescriptors` method
  1695. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
  1696. _export({ target: 'Object', stat: true, sham: !descriptors }, {
  1697. getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
  1698. var O = toIndexedObject(object);
  1699. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  1700. var keys = ownKeys(O);
  1701. var result = {};
  1702. var index = 0;
  1703. var key, descriptor;
  1704. while (keys.length > index) {
  1705. descriptor = getOwnPropertyDescriptor(O, key = keys[index++]);
  1706. if (descriptor !== undefined) createProperty(result, key, descriptor);
  1707. }
  1708. return result;
  1709. }
  1710. });
  1711. var getOwnPropertyDescriptors = path.Object.getOwnPropertyDescriptors;
  1712. var getOwnPropertyDescriptors$1 = getOwnPropertyDescriptors;
  1713. var getOwnPropertyDescriptors$2 = getOwnPropertyDescriptors$1;
  1714. var defineProperties = objectDefineProperties.f;
  1715. // `Object.defineProperties` method
  1716. // https://tc39.es/ecma262/#sec-object.defineproperties
  1717. // eslint-disable-next-line es-x/no-object-defineproperties -- safe
  1718. _export({ target: 'Object', stat: true, forced: Object.defineProperties !== defineProperties, sham: !descriptors }, {
  1719. defineProperties: defineProperties
  1720. });
  1721. var defineProperties_1 = createCommonjsModule(function (module) {
  1722. var Object = path.Object;
  1723. var defineProperties = module.exports = function defineProperties(T, D) {
  1724. return Object.defineProperties(T, D);
  1725. };
  1726. if (Object.defineProperties.sham) defineProperties.sham = true;
  1727. });
  1728. var defineProperties$1 = defineProperties_1;
  1729. var defineProperties$2 = defineProperties$1;
  1730. var defineProperty$3 = objectDefineProperty.f;
  1731. // `Object.defineProperty` method
  1732. // https://tc39.es/ecma262/#sec-object.defineproperty
  1733. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  1734. _export({ target: 'Object', stat: true, forced: Object.defineProperty !== defineProperty$3, sham: !descriptors }, {
  1735. defineProperty: defineProperty$3
  1736. });
  1737. var defineProperty_1 = createCommonjsModule(function (module) {
  1738. var Object = path.Object;
  1739. var defineProperty = module.exports = function defineProperty(it, key, desc) {
  1740. return Object.defineProperty(it, key, desc);
  1741. };
  1742. if (Object.defineProperty.sham) defineProperty.sham = true;
  1743. });
  1744. var defineProperty$4 = defineProperty_1;
  1745. var defineProperty$5 = defineProperty$4;
  1746. var classCallCheck = createCommonjsModule(function (module) {
  1747. function _classCallCheck(instance, Constructor) {
  1748. if (!(instance instanceof Constructor)) {
  1749. throw new TypeError("Cannot call a class as a function");
  1750. }
  1751. }
  1752. module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
  1753. });
  1754. var _classCallCheck = unwrapExports(classCallCheck);
  1755. var defineProperty$6 = defineProperty$4;
  1756. var defineProperty$7 = defineProperty$6;
  1757. var defineProperty$8 = defineProperty$7;
  1758. var defineProperty$9 = defineProperty$8;
  1759. var createClass = createCommonjsModule(function (module) {
  1760. function _defineProperties(target, props) {
  1761. for (var i = 0; i < props.length; i++) {
  1762. var descriptor = props[i];
  1763. descriptor.enumerable = descriptor.enumerable || false;
  1764. descriptor.configurable = true;
  1765. if ("value" in descriptor) descriptor.writable = true;
  1766. defineProperty$9(target, descriptor.key, descriptor);
  1767. }
  1768. }
  1769. function _createClass(Constructor, protoProps, staticProps) {
  1770. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  1771. if (staticProps) _defineProperties(Constructor, staticProps);
  1772. defineProperty$9(Constructor, "prototype", {
  1773. writable: false
  1774. });
  1775. return Constructor;
  1776. }
  1777. module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
  1778. });
  1779. var _createClass = unwrapExports(createClass);
  1780. var assertThisInitialized = createCommonjsModule(function (module) {
  1781. function _assertThisInitialized(self) {
  1782. if (self === void 0) {
  1783. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  1784. }
  1785. return self;
  1786. }
  1787. module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
  1788. });
  1789. var _assertThisInitialized = unwrapExports(assertThisInitialized);
  1790. // TODO: Remove from `core-js@4`
  1791. // `Object.create` method
  1792. // https://tc39.es/ecma262/#sec-object.create
  1793. _export({ target: 'Object', stat: true, sham: !descriptors }, {
  1794. create: objectCreate
  1795. });
  1796. var Object$6 = path.Object;
  1797. var create = function create(P, D) {
  1798. return Object$6.create(P, D);
  1799. };
  1800. var create$1 = create;
  1801. var create$2 = create$1;
  1802. var create$3 = create$2;
  1803. var create$4 = create$3;
  1804. var create$5 = create$4;
  1805. // `Object.setPrototypeOf` method
  1806. // https://tc39.es/ecma262/#sec-object.setprototypeof
  1807. _export({ target: 'Object', stat: true }, {
  1808. setPrototypeOf: objectSetPrototypeOf
  1809. });
  1810. var setPrototypeOf = path.Object.setPrototypeOf;
  1811. var setPrototypeOf$1 = setPrototypeOf;
  1812. var setPrototypeOf$2 = setPrototypeOf$1;
  1813. var setPrototypeOf$3 = setPrototypeOf$2;
  1814. var setPrototypeOf$4 = setPrototypeOf$3;
  1815. var setPrototypeOf$5 = setPrototypeOf$4;
  1816. var setPrototypeOf$6 = createCommonjsModule(function (module) {
  1817. function _setPrototypeOf(o, p) {
  1818. module.exports = _setPrototypeOf = setPrototypeOf$5 || function _setPrototypeOf(o, p) {
  1819. o.__proto__ = p;
  1820. return o;
  1821. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  1822. return _setPrototypeOf(o, p);
  1823. }
  1824. module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
  1825. });
  1826. unwrapExports(setPrototypeOf$6);
  1827. var inherits = createCommonjsModule(function (module) {
  1828. function _inherits(subClass, superClass) {
  1829. if (typeof superClass !== "function" && superClass !== null) {
  1830. throw new TypeError("Super expression must either be null or a function");
  1831. }
  1832. subClass.prototype = create$5(superClass && superClass.prototype, {
  1833. constructor: {
  1834. value: subClass,
  1835. writable: true,
  1836. configurable: true
  1837. }
  1838. });
  1839. defineProperty$9(subClass, "prototype", {
  1840. writable: false
  1841. });
  1842. if (superClass) setPrototypeOf$6(subClass, superClass);
  1843. }
  1844. module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
  1845. });
  1846. var _inherits = unwrapExports(inherits);
  1847. var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
  1848. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
  1849. var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';
  1850. var TypeError$b = global_1.TypeError;
  1851. // We can't use this feature detection in V8 since it causes
  1852. // deoptimization and serious performance degradation
  1853. // https://github.com/zloirock/core-js/issues/679
  1854. var IS_CONCAT_SPREADABLE_SUPPORT = engineV8Version >= 51 || !fails(function () {
  1855. var array = [];
  1856. array[IS_CONCAT_SPREADABLE] = false;
  1857. return array.concat()[0] !== array;
  1858. });
  1859. var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');
  1860. var isConcatSpreadable = function (O) {
  1861. if (!isObject(O)) return false;
  1862. var spreadable = O[IS_CONCAT_SPREADABLE];
  1863. return spreadable !== undefined ? !!spreadable : isArray(O);
  1864. };
  1865. var FORCED$3 = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;
  1866. // `Array.prototype.concat` method
  1867. // https://tc39.es/ecma262/#sec-array.prototype.concat
  1868. // with adding support of @@isConcatSpreadable and @@species
  1869. _export({ target: 'Array', proto: true, arity: 1, forced: FORCED$3 }, {
  1870. // eslint-disable-next-line no-unused-vars -- required for `.length`
  1871. concat: function concat(arg) {
  1872. var O = toObject(this);
  1873. var A = arraySpeciesCreate(O, 0);
  1874. var n = 0;
  1875. var i, k, length, len, E;
  1876. for (i = -1, length = arguments.length; i < length; i++) {
  1877. E = i === -1 ? O : arguments[i];
  1878. if (isConcatSpreadable(E)) {
  1879. len = lengthOfArrayLike(E);
  1880. if (n + len > MAX_SAFE_INTEGER) throw TypeError$b(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
  1881. for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);
  1882. } else {
  1883. if (n >= MAX_SAFE_INTEGER) throw TypeError$b(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
  1884. createProperty(A, n++, E);
  1885. }
  1886. }
  1887. A.length = n;
  1888. return A;
  1889. }
  1890. });
  1891. // `Symbol.asyncIterator` well-known symbol
  1892. // https://tc39.es/ecma262/#sec-symbol.asynciterator
  1893. defineWellKnownSymbol('asyncIterator');
  1894. // `Symbol.hasInstance` well-known symbol
  1895. // https://tc39.es/ecma262/#sec-symbol.hasinstance
  1896. defineWellKnownSymbol('hasInstance');
  1897. // `Symbol.isConcatSpreadable` well-known symbol
  1898. // https://tc39.es/ecma262/#sec-symbol.isconcatspreadable
  1899. defineWellKnownSymbol('isConcatSpreadable');
  1900. // `Symbol.iterator` well-known symbol
  1901. // https://tc39.es/ecma262/#sec-symbol.iterator
  1902. defineWellKnownSymbol('iterator');
  1903. // `Symbol.match` well-known symbol
  1904. // https://tc39.es/ecma262/#sec-symbol.match
  1905. defineWellKnownSymbol('match');
  1906. // `Symbol.matchAll` well-known symbol
  1907. // https://tc39.es/ecma262/#sec-symbol.matchall
  1908. defineWellKnownSymbol('matchAll');
  1909. // `Symbol.replace` well-known symbol
  1910. // https://tc39.es/ecma262/#sec-symbol.replace
  1911. defineWellKnownSymbol('replace');
  1912. // `Symbol.search` well-known symbol
  1913. // https://tc39.es/ecma262/#sec-symbol.search
  1914. defineWellKnownSymbol('search');
  1915. // `Symbol.species` well-known symbol
  1916. // https://tc39.es/ecma262/#sec-symbol.species
  1917. defineWellKnownSymbol('species');
  1918. // `Symbol.split` well-known symbol
  1919. // https://tc39.es/ecma262/#sec-symbol.split
  1920. defineWellKnownSymbol('split');
  1921. // `Symbol.toPrimitive` well-known symbol
  1922. // https://tc39.es/ecma262/#sec-symbol.toprimitive
  1923. defineWellKnownSymbol('toPrimitive');
  1924. // `Symbol.prototype[@@toPrimitive]` method
  1925. // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
  1926. symbolDefineToPrimitive();
  1927. // `Symbol.toStringTag` well-known symbol
  1928. // https://tc39.es/ecma262/#sec-symbol.tostringtag
  1929. defineWellKnownSymbol('toStringTag');
  1930. // `Symbol.prototype[@@toStringTag]` property
  1931. // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag
  1932. setToStringTag(getBuiltIn('Symbol'), 'Symbol');
  1933. // `Symbol.unscopables` well-known symbol
  1934. // https://tc39.es/ecma262/#sec-symbol.unscopables
  1935. defineWellKnownSymbol('unscopables');
  1936. // JSON[@@toStringTag] property
  1937. // https://tc39.es/ecma262/#sec-json-@@tostringtag
  1938. setToStringTag(global_1.JSON, 'JSON', true);
  1939. var symbol = path.Symbol;
  1940. var symbol$1 = symbol;
  1941. var symbol$2 = symbol$1;
  1942. // `Symbol.asyncDispose` well-known symbol
  1943. // https://github.com/tc39/proposal-using-statement
  1944. defineWellKnownSymbol('asyncDispose');
  1945. // `Symbol.dispose` well-known symbol
  1946. // https://github.com/tc39/proposal-using-statement
  1947. defineWellKnownSymbol('dispose');
  1948. // `Symbol.matcher` well-known symbol
  1949. // https://github.com/tc39/proposal-pattern-matching
  1950. defineWellKnownSymbol('matcher');
  1951. // `Symbol.metadata` well-known symbol
  1952. // https://github.com/tc39/proposal-decorators
  1953. defineWellKnownSymbol('metadata');
  1954. // `Symbol.observable` well-known symbol
  1955. // https://github.com/tc39/proposal-observable
  1956. defineWellKnownSymbol('observable');
  1957. // TODO: remove from `core-js@4`
  1958. // `Symbol.patternMatch` well-known symbol
  1959. // https://github.com/tc39/proposal-pattern-matching
  1960. defineWellKnownSymbol('patternMatch');
  1961. // TODO: remove from `core-js@4`
  1962. defineWellKnownSymbol('replaceAll');
  1963. // TODO: Remove from `core-js@4`
  1964. // TODO: Remove from `core-js@4`
  1965. var symbol$3 = symbol$2;
  1966. var symbol$4 = symbol$3;
  1967. var symbol$5 = symbol$4;
  1968. var charAt$1 = functionUncurryThis(''.charAt);
  1969. var charCodeAt$1 = functionUncurryThis(''.charCodeAt);
  1970. var stringSlice$1 = functionUncurryThis(''.slice);
  1971. var createMethod$2 = function (CONVERT_TO_STRING) {
  1972. return function ($this, pos) {
  1973. var S = toString_1(requireObjectCoercible($this));
  1974. var position = toIntegerOrInfinity(pos);
  1975. var size = S.length;
  1976. var first, second;
  1977. if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
  1978. first = charCodeAt$1(S, position);
  1979. return first < 0xD800 || first > 0xDBFF || position + 1 === size
  1980. || (second = charCodeAt$1(S, position + 1)) < 0xDC00 || second > 0xDFFF
  1981. ? CONVERT_TO_STRING
  1982. ? charAt$1(S, position)
  1983. : first
  1984. : CONVERT_TO_STRING
  1985. ? stringSlice$1(S, position, position + 2)
  1986. : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
  1987. };
  1988. };
  1989. var stringMultibyte = {
  1990. // `String.prototype.codePointAt` method
  1991. // https://tc39.es/ecma262/#sec-string.prototype.codepointat
  1992. codeAt: createMethod$2(false),
  1993. // `String.prototype.at` method
  1994. // https://github.com/mathiasbynens/String.prototype.at
  1995. charAt: createMethod$2(true)
  1996. };
  1997. var charAt$2 = stringMultibyte.charAt;
  1998. var STRING_ITERATOR = 'String Iterator';
  1999. var setInternalState$2 = internalState.set;
  2000. var getInternalState$2 = internalState.getterFor(STRING_ITERATOR);
  2001. // `String.prototype[@@iterator]` method
  2002. // https://tc39.es/ecma262/#sec-string.prototype-@@iterator
  2003. defineIterator(String, 'String', function (iterated) {
  2004. setInternalState$2(this, {
  2005. type: STRING_ITERATOR,
  2006. string: toString_1(iterated),
  2007. index: 0
  2008. });
  2009. // `%StringIteratorPrototype%.next` method
  2010. // https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
  2011. }, function next() {
  2012. var state = getInternalState$2(this);
  2013. var string = state.string;
  2014. var index = state.index;
  2015. var point;
  2016. if (index >= string.length) return { value: undefined, done: true };
  2017. point = charAt$2(string, index);
  2018. state.index += point.length;
  2019. return { value: point, done: false };
  2020. });
  2021. var iterator = wellKnownSymbolWrapped.f('iterator');
  2022. var iterator$1 = iterator;
  2023. var iterator$2 = iterator$1;
  2024. var iterator$3 = iterator$2;
  2025. var iterator$4 = iterator$3;
  2026. var iterator$5 = iterator$4;
  2027. var _typeof_1 = createCommonjsModule(function (module) {
  2028. function _typeof(obj) {
  2029. "@babel/helpers - typeof";
  2030. return (module.exports = _typeof = "function" == typeof symbol$5 && "symbol" == typeof iterator$5 ? function (obj) {
  2031. return typeof obj;
  2032. } : function (obj) {
  2033. return obj && "function" == typeof symbol$5 && obj.constructor === symbol$5 && obj !== symbol$5.prototype ? "symbol" : typeof obj;
  2034. }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
  2035. }
  2036. module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2037. });
  2038. var _typeof = unwrapExports(_typeof_1);
  2039. var possibleConstructorReturn = createCommonjsModule(function (module) {
  2040. var _typeof = _typeof_1["default"];
  2041. function _possibleConstructorReturn(self, call) {
  2042. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  2043. return call;
  2044. } else if (call !== void 0) {
  2045. throw new TypeError("Derived constructors may only return object or undefined");
  2046. }
  2047. return assertThisInitialized(self);
  2048. }
  2049. module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2050. });
  2051. var _possibleConstructorReturn = unwrapExports(possibleConstructorReturn);
  2052. var FAILS_ON_PRIMITIVES$2 = fails(function () { objectGetPrototypeOf(1); });
  2053. // `Object.getPrototypeOf` method
  2054. // https://tc39.es/ecma262/#sec-object.getprototypeof
  2055. _export({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES$2, sham: !correctPrototypeGetter }, {
  2056. getPrototypeOf: function getPrototypeOf(it) {
  2057. return objectGetPrototypeOf(toObject(it));
  2058. }
  2059. });
  2060. var getPrototypeOf = path.Object.getPrototypeOf;
  2061. var getPrototypeOf$1 = getPrototypeOf;
  2062. var getPrototypeOf$2 = getPrototypeOf$1;
  2063. var getPrototypeOf$3 = getPrototypeOf$2;
  2064. var getPrototypeOf$4 = getPrototypeOf$3;
  2065. var getPrototypeOf$5 = getPrototypeOf$4;
  2066. var getPrototypeOf$6 = createCommonjsModule(function (module) {
  2067. function _getPrototypeOf(o) {
  2068. module.exports = _getPrototypeOf = setPrototypeOf$5 ? getPrototypeOf$5 : function _getPrototypeOf(o) {
  2069. return o.__proto__ || getPrototypeOf$5(o);
  2070. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2071. return _getPrototypeOf(o);
  2072. }
  2073. module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2074. });
  2075. var _getPrototypeOf = unwrapExports(getPrototypeOf$6);
  2076. var defineProperty$a = createCommonjsModule(function (module) {
  2077. function _defineProperty(obj, key, value) {
  2078. if (key in obj) {
  2079. defineProperty$9(obj, key, {
  2080. value: value,
  2081. enumerable: true,
  2082. configurable: true,
  2083. writable: true
  2084. });
  2085. } else {
  2086. obj[key] = value;
  2087. }
  2088. return obj;
  2089. }
  2090. module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
  2091. });
  2092. var _defineProperty = unwrapExports(defineProperty$a);
  2093. var concat$2 = entryVirtual('Array').concat;
  2094. var ArrayPrototype$2 = Array.prototype;
  2095. var concat$3 = function (it) {
  2096. var own = it.concat;
  2097. return it === ArrayPrototype$2 || (objectIsPrototypeOf(ArrayPrototype$2, it) && own === ArrayPrototype$2.concat) ? concat$2 : own;
  2098. };
  2099. var concat$4 = concat$3;
  2100. var concat$5 = concat$4;
  2101. // TODO: Remove from `core-js@4`
  2102. // `Function.prototype.bind` method
  2103. // https://tc39.es/ecma262/#sec-function.prototype.bind
  2104. _export({ target: 'Function', proto: true, forced: Function.bind !== functionBind }, {
  2105. bind: functionBind
  2106. });
  2107. var bind$2 = entryVirtual('Function').bind;
  2108. var FunctionPrototype$3 = Function.prototype;
  2109. var bind$3 = function (it) {
  2110. var own = it.bind;
  2111. return it === FunctionPrototype$3 || (objectIsPrototypeOf(FunctionPrototype$3, it) && own === FunctionPrototype$3.bind) ? bind$2 : own;
  2112. };
  2113. var bind$4 = bind$3;
  2114. var bind$5 = bind$4;
  2115. var TypeError$c = global_1.TypeError;
  2116. var validateArgumentsLength = function (passed, required) {
  2117. if (passed < required) throw TypeError$c('Not enough arguments');
  2118. return passed;
  2119. };
  2120. var MSIE = /MSIE .\./.test(engineUserAgent); // <- dirty ie9- check
  2121. var Function$2 = global_1.Function;
  2122. var wrap$1 = function (scheduler) {
  2123. return MSIE ? function (handler, timeout /* , ...arguments */) {
  2124. var boundArgs = validateArgumentsLength(arguments.length, 1) > 2;
  2125. var fn = isCallable(handler) ? handler : Function$2(handler);
  2126. var args = boundArgs ? arraySlice(arguments, 2) : undefined;
  2127. return scheduler(boundArgs ? function () {
  2128. functionApply(fn, this, args);
  2129. } : fn, timeout);
  2130. } : scheduler;
  2131. };
  2132. // ie9- setTimeout & setInterval additional parameters fix
  2133. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
  2134. var schedulersFix = {
  2135. // `setTimeout` method
  2136. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
  2137. setTimeout: wrap$1(global_1.setTimeout),
  2138. // `setInterval` method
  2139. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
  2140. setInterval: wrap$1(global_1.setInterval)
  2141. };
  2142. var setInterval$1 = schedulersFix.setInterval;
  2143. // ie9- setInterval additional parameters fix
  2144. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
  2145. _export({ global: true, bind: true, forced: global_1.setInterval !== setInterval$1 }, {
  2146. setInterval: setInterval$1
  2147. });
  2148. var setTimeout$1 = schedulersFix.setTimeout;
  2149. // ie9- setTimeout additional parameters fix
  2150. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
  2151. _export({ global: true, bind: true, forced: global_1.setTimeout !== setTimeout$1 }, {
  2152. setTimeout: setTimeout$1
  2153. });
  2154. var setTimeout$2 = path.setTimeout;
  2155. var setTimeout$3 = setTimeout$2;
  2156. /**
  2157. * Removes all key-value entries from the list cache.
  2158. *
  2159. * @private
  2160. * @name clear
  2161. * @memberOf ListCache
  2162. */
  2163. function listCacheClear() {
  2164. this.__data__ = [];
  2165. this.size = 0;
  2166. }
  2167. var _listCacheClear = listCacheClear;
  2168. /**
  2169. * Performs a
  2170. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  2171. * comparison between two values to determine if they are equivalent.
  2172. *
  2173. * @static
  2174. * @memberOf _
  2175. * @since 4.0.0
  2176. * @category Lang
  2177. * @param {*} value The value to compare.
  2178. * @param {*} other The other value to compare.
  2179. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  2180. * @example
  2181. *
  2182. * var object = { 'a': 1 };
  2183. * var other = { 'a': 1 };
  2184. *
  2185. * _.eq(object, object);
  2186. * // => true
  2187. *
  2188. * _.eq(object, other);
  2189. * // => false
  2190. *
  2191. * _.eq('a', 'a');
  2192. * // => true
  2193. *
  2194. * _.eq('a', Object('a'));
  2195. * // => false
  2196. *
  2197. * _.eq(NaN, NaN);
  2198. * // => true
  2199. */
  2200. function eq(value, other) {
  2201. return value === other || (value !== value && other !== other);
  2202. }
  2203. var eq_1 = eq;
  2204. /**
  2205. * Gets the index at which the `key` is found in `array` of key-value pairs.
  2206. *
  2207. * @private
  2208. * @param {Array} array The array to inspect.
  2209. * @param {*} key The key to search for.
  2210. * @returns {number} Returns the index of the matched value, else `-1`.
  2211. */
  2212. function assocIndexOf(array, key) {
  2213. var length = array.length;
  2214. while (length--) {
  2215. if (eq_1(array[length][0], key)) {
  2216. return length;
  2217. }
  2218. }
  2219. return -1;
  2220. }
  2221. var _assocIndexOf = assocIndexOf;
  2222. /** Used for built-in method references. */
  2223. var arrayProto = Array.prototype;
  2224. /** Built-in value references. */
  2225. var splice = arrayProto.splice;
  2226. /**
  2227. * Removes `key` and its value from the list cache.
  2228. *
  2229. * @private
  2230. * @name delete
  2231. * @memberOf ListCache
  2232. * @param {string} key The key of the value to remove.
  2233. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2234. */
  2235. function listCacheDelete(key) {
  2236. var data = this.__data__,
  2237. index = _assocIndexOf(data, key);
  2238. if (index < 0) {
  2239. return false;
  2240. }
  2241. var lastIndex = data.length - 1;
  2242. if (index == lastIndex) {
  2243. data.pop();
  2244. } else {
  2245. splice.call(data, index, 1);
  2246. }
  2247. --this.size;
  2248. return true;
  2249. }
  2250. var _listCacheDelete = listCacheDelete;
  2251. /**
  2252. * Gets the list cache value for `key`.
  2253. *
  2254. * @private
  2255. * @name get
  2256. * @memberOf ListCache
  2257. * @param {string} key The key of the value to get.
  2258. * @returns {*} Returns the entry value.
  2259. */
  2260. function listCacheGet(key) {
  2261. var data = this.__data__,
  2262. index = _assocIndexOf(data, key);
  2263. return index < 0 ? undefined : data[index][1];
  2264. }
  2265. var _listCacheGet = listCacheGet;
  2266. /**
  2267. * Checks if a list cache value for `key` exists.
  2268. *
  2269. * @private
  2270. * @name has
  2271. * @memberOf ListCache
  2272. * @param {string} key The key of the entry to check.
  2273. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2274. */
  2275. function listCacheHas(key) {
  2276. return _assocIndexOf(this.__data__, key) > -1;
  2277. }
  2278. var _listCacheHas = listCacheHas;
  2279. /**
  2280. * Sets the list cache `key` to `value`.
  2281. *
  2282. * @private
  2283. * @name set
  2284. * @memberOf ListCache
  2285. * @param {string} key The key of the value to set.
  2286. * @param {*} value The value to set.
  2287. * @returns {Object} Returns the list cache instance.
  2288. */
  2289. function listCacheSet(key, value) {
  2290. var data = this.__data__,
  2291. index = _assocIndexOf(data, key);
  2292. if (index < 0) {
  2293. ++this.size;
  2294. data.push([key, value]);
  2295. } else {
  2296. data[index][1] = value;
  2297. }
  2298. return this;
  2299. }
  2300. var _listCacheSet = listCacheSet;
  2301. /**
  2302. * Creates an list cache object.
  2303. *
  2304. * @private
  2305. * @constructor
  2306. * @param {Array} [entries] The key-value pairs to cache.
  2307. */
  2308. function ListCache(entries) {
  2309. var index = -1,
  2310. length = entries == null ? 0 : entries.length;
  2311. this.clear();
  2312. while (++index < length) {
  2313. var entry = entries[index];
  2314. this.set(entry[0], entry[1]);
  2315. }
  2316. }
  2317. // Add methods to `ListCache`.
  2318. ListCache.prototype.clear = _listCacheClear;
  2319. ListCache.prototype['delete'] = _listCacheDelete;
  2320. ListCache.prototype.get = _listCacheGet;
  2321. ListCache.prototype.has = _listCacheHas;
  2322. ListCache.prototype.set = _listCacheSet;
  2323. var _ListCache = ListCache;
  2324. /**
  2325. * Removes all key-value entries from the stack.
  2326. *
  2327. * @private
  2328. * @name clear
  2329. * @memberOf Stack
  2330. */
  2331. function stackClear() {
  2332. this.__data__ = new _ListCache;
  2333. this.size = 0;
  2334. }
  2335. var _stackClear = stackClear;
  2336. /**
  2337. * Removes `key` and its value from the stack.
  2338. *
  2339. * @private
  2340. * @name delete
  2341. * @memberOf Stack
  2342. * @param {string} key The key of the value to remove.
  2343. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2344. */
  2345. function stackDelete(key) {
  2346. var data = this.__data__,
  2347. result = data['delete'](key);
  2348. this.size = data.size;
  2349. return result;
  2350. }
  2351. var _stackDelete = stackDelete;
  2352. /**
  2353. * Gets the stack value for `key`.
  2354. *
  2355. * @private
  2356. * @name get
  2357. * @memberOf Stack
  2358. * @param {string} key The key of the value to get.
  2359. * @returns {*} Returns the entry value.
  2360. */
  2361. function stackGet(key) {
  2362. return this.__data__.get(key);
  2363. }
  2364. var _stackGet = stackGet;
  2365. /**
  2366. * Checks if a stack value for `key` exists.
  2367. *
  2368. * @private
  2369. * @name has
  2370. * @memberOf Stack
  2371. * @param {string} key The key of the entry to check.
  2372. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2373. */
  2374. function stackHas(key) {
  2375. return this.__data__.has(key);
  2376. }
  2377. var _stackHas = stackHas;
  2378. /** Detect free variable `global` from Node.js. */
  2379. var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  2380. var _freeGlobal = freeGlobal;
  2381. /** Detect free variable `self`. */
  2382. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  2383. /** Used as a reference to the global object. */
  2384. var root = _freeGlobal || freeSelf || Function('return this')();
  2385. var _root = root;
  2386. /** Built-in value references. */
  2387. var Symbol$2 = _root.Symbol;
  2388. var _Symbol = Symbol$2;
  2389. /** Used for built-in method references. */
  2390. var objectProto = Object.prototype;
  2391. /** Used to check objects for own properties. */
  2392. var hasOwnProperty$1 = objectProto.hasOwnProperty;
  2393. /**
  2394. * Used to resolve the
  2395. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  2396. * of values.
  2397. */
  2398. var nativeObjectToString = objectProto.toString;
  2399. /** Built-in value references. */
  2400. var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
  2401. /**
  2402. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  2403. *
  2404. * @private
  2405. * @param {*} value The value to query.
  2406. * @returns {string} Returns the raw `toStringTag`.
  2407. */
  2408. function getRawTag(value) {
  2409. var isOwn = hasOwnProperty$1.call(value, symToStringTag),
  2410. tag = value[symToStringTag];
  2411. try {
  2412. value[symToStringTag] = undefined;
  2413. var unmasked = true;
  2414. } catch (e) {}
  2415. var result = nativeObjectToString.call(value);
  2416. if (unmasked) {
  2417. if (isOwn) {
  2418. value[symToStringTag] = tag;
  2419. } else {
  2420. delete value[symToStringTag];
  2421. }
  2422. }
  2423. return result;
  2424. }
  2425. var _getRawTag = getRawTag;
  2426. /** Used for built-in method references. */
  2427. var objectProto$1 = Object.prototype;
  2428. /**
  2429. * Used to resolve the
  2430. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  2431. * of values.
  2432. */
  2433. var nativeObjectToString$1 = objectProto$1.toString;
  2434. /**
  2435. * Converts `value` to a string using `Object.prototype.toString`.
  2436. *
  2437. * @private
  2438. * @param {*} value The value to convert.
  2439. * @returns {string} Returns the converted string.
  2440. */
  2441. function objectToString$1(value) {
  2442. return nativeObjectToString$1.call(value);
  2443. }
  2444. var _objectToString = objectToString$1;
  2445. /** `Object#toString` result references. */
  2446. var nullTag = '[object Null]',
  2447. undefinedTag = '[object Undefined]';
  2448. /** Built-in value references. */
  2449. var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
  2450. /**
  2451. * The base implementation of `getTag` without fallbacks for buggy environments.
  2452. *
  2453. * @private
  2454. * @param {*} value The value to query.
  2455. * @returns {string} Returns the `toStringTag`.
  2456. */
  2457. function baseGetTag(value) {
  2458. if (value == null) {
  2459. return value === undefined ? undefinedTag : nullTag;
  2460. }
  2461. return (symToStringTag$1 && symToStringTag$1 in Object(value))
  2462. ? _getRawTag(value)
  2463. : _objectToString(value);
  2464. }
  2465. var _baseGetTag = baseGetTag;
  2466. /**
  2467. * Checks if `value` is the
  2468. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  2469. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  2470. *
  2471. * @static
  2472. * @memberOf _
  2473. * @since 0.1.0
  2474. * @category Lang
  2475. * @param {*} value The value to check.
  2476. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  2477. * @example
  2478. *
  2479. * _.isObject({});
  2480. * // => true
  2481. *
  2482. * _.isObject([1, 2, 3]);
  2483. * // => true
  2484. *
  2485. * _.isObject(_.noop);
  2486. * // => true
  2487. *
  2488. * _.isObject(null);
  2489. * // => false
  2490. */
  2491. function isObject$1(value) {
  2492. var type = typeof value;
  2493. return value != null && (type == 'object' || type == 'function');
  2494. }
  2495. var isObject_1 = isObject$1;
  2496. /** `Object#toString` result references. */
  2497. var asyncTag = '[object AsyncFunction]',
  2498. funcTag = '[object Function]',
  2499. genTag = '[object GeneratorFunction]',
  2500. proxyTag = '[object Proxy]';
  2501. /**
  2502. * Checks if `value` is classified as a `Function` object.
  2503. *
  2504. * @static
  2505. * @memberOf _
  2506. * @since 0.1.0
  2507. * @category Lang
  2508. * @param {*} value The value to check.
  2509. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  2510. * @example
  2511. *
  2512. * _.isFunction(_);
  2513. * // => true
  2514. *
  2515. * _.isFunction(/abc/);
  2516. * // => false
  2517. */
  2518. function isFunction(value) {
  2519. if (!isObject_1(value)) {
  2520. return false;
  2521. }
  2522. // The use of `Object#toString` avoids issues with the `typeof` operator
  2523. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  2524. var tag = _baseGetTag(value);
  2525. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  2526. }
  2527. var isFunction_1 = isFunction;
  2528. /** Used to detect overreaching core-js shims. */
  2529. var coreJsData = _root['__core-js_shared__'];
  2530. var _coreJsData = coreJsData;
  2531. /** Used to detect methods masquerading as native. */
  2532. var maskSrcKey = (function() {
  2533. var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
  2534. return uid ? ('Symbol(src)_1.' + uid) : '';
  2535. }());
  2536. /**
  2537. * Checks if `func` has its source masked.
  2538. *
  2539. * @private
  2540. * @param {Function} func The function to check.
  2541. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  2542. */
  2543. function isMasked(func) {
  2544. return !!maskSrcKey && (maskSrcKey in func);
  2545. }
  2546. var _isMasked = isMasked;
  2547. /** Used for built-in method references. */
  2548. var funcProto = Function.prototype;
  2549. /** Used to resolve the decompiled source of functions. */
  2550. var funcToString = funcProto.toString;
  2551. /**
  2552. * Converts `func` to its source code.
  2553. *
  2554. * @private
  2555. * @param {Function} func The function to convert.
  2556. * @returns {string} Returns the source code.
  2557. */
  2558. function toSource(func) {
  2559. if (func != null) {
  2560. try {
  2561. return funcToString.call(func);
  2562. } catch (e) {}
  2563. try {
  2564. return (func + '');
  2565. } catch (e) {}
  2566. }
  2567. return '';
  2568. }
  2569. var _toSource = toSource;
  2570. /**
  2571. * Used to match `RegExp`
  2572. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  2573. */
  2574. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  2575. /** Used to detect host constructors (Safari). */
  2576. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  2577. /** Used for built-in method references. */
  2578. var funcProto$1 = Function.prototype,
  2579. objectProto$2 = Object.prototype;
  2580. /** Used to resolve the decompiled source of functions. */
  2581. var funcToString$1 = funcProto$1.toString;
  2582. /** Used to check objects for own properties. */
  2583. var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
  2584. /** Used to detect if a method is native. */
  2585. var reIsNative = RegExp('^' +
  2586. funcToString$1.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
  2587. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  2588. );
  2589. /**
  2590. * The base implementation of `_.isNative` without bad shim checks.
  2591. *
  2592. * @private
  2593. * @param {*} value The value to check.
  2594. * @returns {boolean} Returns `true` if `value` is a native function,
  2595. * else `false`.
  2596. */
  2597. function baseIsNative(value) {
  2598. if (!isObject_1(value) || _isMasked(value)) {
  2599. return false;
  2600. }
  2601. var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
  2602. return pattern.test(_toSource(value));
  2603. }
  2604. var _baseIsNative = baseIsNative;
  2605. /**
  2606. * Gets the value at `key` of `object`.
  2607. *
  2608. * @private
  2609. * @param {Object} [object] The object to query.
  2610. * @param {string} key The key of the property to get.
  2611. * @returns {*} Returns the property value.
  2612. */
  2613. function getValue(object, key) {
  2614. return object == null ? undefined : object[key];
  2615. }
  2616. var _getValue = getValue;
  2617. /**
  2618. * Gets the native function at `key` of `object`.
  2619. *
  2620. * @private
  2621. * @param {Object} object The object to query.
  2622. * @param {string} key The key of the method to get.
  2623. * @returns {*} Returns the function if it's native, else `undefined`.
  2624. */
  2625. function getNative(object, key) {
  2626. var value = _getValue(object, key);
  2627. return _baseIsNative(value) ? value : undefined;
  2628. }
  2629. var _getNative = getNative;
  2630. /* Built-in method references that are verified to be native. */
  2631. var Map$1 = _getNative(_root, 'Map');
  2632. var _Map = Map$1;
  2633. /* Built-in method references that are verified to be native. */
  2634. var nativeCreate = _getNative(Object, 'create');
  2635. var _nativeCreate = nativeCreate;
  2636. /**
  2637. * Removes all key-value entries from the hash.
  2638. *
  2639. * @private
  2640. * @name clear
  2641. * @memberOf Hash
  2642. */
  2643. function hashClear() {
  2644. this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
  2645. this.size = 0;
  2646. }
  2647. var _hashClear = hashClear;
  2648. /**
  2649. * Removes `key` and its value from the hash.
  2650. *
  2651. * @private
  2652. * @name delete
  2653. * @memberOf Hash
  2654. * @param {Object} hash The hash to modify.
  2655. * @param {string} key The key of the value to remove.
  2656. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2657. */
  2658. function hashDelete(key) {
  2659. var result = this.has(key) && delete this.__data__[key];
  2660. this.size -= result ? 1 : 0;
  2661. return result;
  2662. }
  2663. var _hashDelete = hashDelete;
  2664. /** Used to stand-in for `undefined` hash values. */
  2665. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  2666. /** Used for built-in method references. */
  2667. var objectProto$3 = Object.prototype;
  2668. /** Used to check objects for own properties. */
  2669. var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
  2670. /**
  2671. * Gets the hash value for `key`.
  2672. *
  2673. * @private
  2674. * @name get
  2675. * @memberOf Hash
  2676. * @param {string} key The key of the value to get.
  2677. * @returns {*} Returns the entry value.
  2678. */
  2679. function hashGet(key) {
  2680. var data = this.__data__;
  2681. if (_nativeCreate) {
  2682. var result = data[key];
  2683. return result === HASH_UNDEFINED ? undefined : result;
  2684. }
  2685. return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
  2686. }
  2687. var _hashGet = hashGet;
  2688. /** Used for built-in method references. */
  2689. var objectProto$4 = Object.prototype;
  2690. /** Used to check objects for own properties. */
  2691. var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
  2692. /**
  2693. * Checks if a hash value for `key` exists.
  2694. *
  2695. * @private
  2696. * @name has
  2697. * @memberOf Hash
  2698. * @param {string} key The key of the entry to check.
  2699. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2700. */
  2701. function hashHas(key) {
  2702. var data = this.__data__;
  2703. return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$4.call(data, key);
  2704. }
  2705. var _hashHas = hashHas;
  2706. /** Used to stand-in for `undefined` hash values. */
  2707. var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
  2708. /**
  2709. * Sets the hash `key` to `value`.
  2710. *
  2711. * @private
  2712. * @name set
  2713. * @memberOf Hash
  2714. * @param {string} key The key of the value to set.
  2715. * @param {*} value The value to set.
  2716. * @returns {Object} Returns the hash instance.
  2717. */
  2718. function hashSet(key, value) {
  2719. var data = this.__data__;
  2720. this.size += this.has(key) ? 0 : 1;
  2721. data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
  2722. return this;
  2723. }
  2724. var _hashSet = hashSet;
  2725. /**
  2726. * Creates a hash object.
  2727. *
  2728. * @private
  2729. * @constructor
  2730. * @param {Array} [entries] The key-value pairs to cache.
  2731. */
  2732. function Hash(entries) {
  2733. var index = -1,
  2734. length = entries == null ? 0 : entries.length;
  2735. this.clear();
  2736. while (++index < length) {
  2737. var entry = entries[index];
  2738. this.set(entry[0], entry[1]);
  2739. }
  2740. }
  2741. // Add methods to `Hash`.
  2742. Hash.prototype.clear = _hashClear;
  2743. Hash.prototype['delete'] = _hashDelete;
  2744. Hash.prototype.get = _hashGet;
  2745. Hash.prototype.has = _hashHas;
  2746. Hash.prototype.set = _hashSet;
  2747. var _Hash = Hash;
  2748. /**
  2749. * Removes all key-value entries from the map.
  2750. *
  2751. * @private
  2752. * @name clear
  2753. * @memberOf MapCache
  2754. */
  2755. function mapCacheClear() {
  2756. this.size = 0;
  2757. this.__data__ = {
  2758. 'hash': new _Hash,
  2759. 'map': new (_Map || _ListCache),
  2760. 'string': new _Hash
  2761. };
  2762. }
  2763. var _mapCacheClear = mapCacheClear;
  2764. /**
  2765. * Checks if `value` is suitable for use as unique object key.
  2766. *
  2767. * @private
  2768. * @param {*} value The value to check.
  2769. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  2770. */
  2771. function isKeyable(value) {
  2772. var type = typeof value;
  2773. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  2774. ? (value !== '__proto__')
  2775. : (value === null);
  2776. }
  2777. var _isKeyable = isKeyable;
  2778. /**
  2779. * Gets the data for `map`.
  2780. *
  2781. * @private
  2782. * @param {Object} map The map to query.
  2783. * @param {string} key The reference key.
  2784. * @returns {*} Returns the map data.
  2785. */
  2786. function getMapData(map, key) {
  2787. var data = map.__data__;
  2788. return _isKeyable(key)
  2789. ? data[typeof key == 'string' ? 'string' : 'hash']
  2790. : data.map;
  2791. }
  2792. var _getMapData = getMapData;
  2793. /**
  2794. * Removes `key` and its value from the map.
  2795. *
  2796. * @private
  2797. * @name delete
  2798. * @memberOf MapCache
  2799. * @param {string} key The key of the value to remove.
  2800. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2801. */
  2802. function mapCacheDelete(key) {
  2803. var result = _getMapData(this, key)['delete'](key);
  2804. this.size -= result ? 1 : 0;
  2805. return result;
  2806. }
  2807. var _mapCacheDelete = mapCacheDelete;
  2808. /**
  2809. * Gets the map value for `key`.
  2810. *
  2811. * @private
  2812. * @name get
  2813. * @memberOf MapCache
  2814. * @param {string} key The key of the value to get.
  2815. * @returns {*} Returns the entry value.
  2816. */
  2817. function mapCacheGet(key) {
  2818. return _getMapData(this, key).get(key);
  2819. }
  2820. var _mapCacheGet = mapCacheGet;
  2821. /**
  2822. * Checks if a map value for `key` exists.
  2823. *
  2824. * @private
  2825. * @name has
  2826. * @memberOf MapCache
  2827. * @param {string} key The key of the entry to check.
  2828. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2829. */
  2830. function mapCacheHas(key) {
  2831. return _getMapData(this, key).has(key);
  2832. }
  2833. var _mapCacheHas = mapCacheHas;
  2834. /**
  2835. * Sets the map `key` to `value`.
  2836. *
  2837. * @private
  2838. * @name set
  2839. * @memberOf MapCache
  2840. * @param {string} key The key of the value to set.
  2841. * @param {*} value The value to set.
  2842. * @returns {Object} Returns the map cache instance.
  2843. */
  2844. function mapCacheSet(key, value) {
  2845. var data = _getMapData(this, key),
  2846. size = data.size;
  2847. data.set(key, value);
  2848. this.size += data.size == size ? 0 : 1;
  2849. return this;
  2850. }
  2851. var _mapCacheSet = mapCacheSet;
  2852. /**
  2853. * Creates a map cache object to store key-value pairs.
  2854. *
  2855. * @private
  2856. * @constructor
  2857. * @param {Array} [entries] The key-value pairs to cache.
  2858. */
  2859. function MapCache(entries) {
  2860. var index = -1,
  2861. length = entries == null ? 0 : entries.length;
  2862. this.clear();
  2863. while (++index < length) {
  2864. var entry = entries[index];
  2865. this.set(entry[0], entry[1]);
  2866. }
  2867. }
  2868. // Add methods to `MapCache`.
  2869. MapCache.prototype.clear = _mapCacheClear;
  2870. MapCache.prototype['delete'] = _mapCacheDelete;
  2871. MapCache.prototype.get = _mapCacheGet;
  2872. MapCache.prototype.has = _mapCacheHas;
  2873. MapCache.prototype.set = _mapCacheSet;
  2874. var _MapCache = MapCache;
  2875. /** Used as the size to enable large array optimizations. */
  2876. var LARGE_ARRAY_SIZE = 200;
  2877. /**
  2878. * Sets the stack `key` to `value`.
  2879. *
  2880. * @private
  2881. * @name set
  2882. * @memberOf Stack
  2883. * @param {string} key The key of the value to set.
  2884. * @param {*} value The value to set.
  2885. * @returns {Object} Returns the stack cache instance.
  2886. */
  2887. function stackSet(key, value) {
  2888. var data = this.__data__;
  2889. if (data instanceof _ListCache) {
  2890. var pairs = data.__data__;
  2891. if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  2892. pairs.push([key, value]);
  2893. this.size = ++data.size;
  2894. return this;
  2895. }
  2896. data = this.__data__ = new _MapCache(pairs);
  2897. }
  2898. data.set(key, value);
  2899. this.size = data.size;
  2900. return this;
  2901. }
  2902. var _stackSet = stackSet;
  2903. /**
  2904. * Creates a stack cache object to store key-value pairs.
  2905. *
  2906. * @private
  2907. * @constructor
  2908. * @param {Array} [entries] The key-value pairs to cache.
  2909. */
  2910. function Stack(entries) {
  2911. var data = this.__data__ = new _ListCache(entries);
  2912. this.size = data.size;
  2913. }
  2914. // Add methods to `Stack`.
  2915. Stack.prototype.clear = _stackClear;
  2916. Stack.prototype['delete'] = _stackDelete;
  2917. Stack.prototype.get = _stackGet;
  2918. Stack.prototype.has = _stackHas;
  2919. Stack.prototype.set = _stackSet;
  2920. var _Stack = Stack;
  2921. var defineProperty$b = (function() {
  2922. try {
  2923. var func = _getNative(Object, 'defineProperty');
  2924. func({}, '', {});
  2925. return func;
  2926. } catch (e) {}
  2927. }());
  2928. var _defineProperty$1 = defineProperty$b;
  2929. /**
  2930. * The base implementation of `assignValue` and `assignMergeValue` without
  2931. * value checks.
  2932. *
  2933. * @private
  2934. * @param {Object} object The object to modify.
  2935. * @param {string} key The key of the property to assign.
  2936. * @param {*} value The value to assign.
  2937. */
  2938. function baseAssignValue(object, key, value) {
  2939. if (key == '__proto__' && _defineProperty$1) {
  2940. _defineProperty$1(object, key, {
  2941. 'configurable': true,
  2942. 'enumerable': true,
  2943. 'value': value,
  2944. 'writable': true
  2945. });
  2946. } else {
  2947. object[key] = value;
  2948. }
  2949. }
  2950. var _baseAssignValue = baseAssignValue;
  2951. /**
  2952. * This function is like `assignValue` except that it doesn't assign
  2953. * `undefined` values.
  2954. *
  2955. * @private
  2956. * @param {Object} object The object to modify.
  2957. * @param {string} key The key of the property to assign.
  2958. * @param {*} value The value to assign.
  2959. */
  2960. function assignMergeValue(object, key, value) {
  2961. if ((value !== undefined && !eq_1(object[key], value)) ||
  2962. (value === undefined && !(key in object))) {
  2963. _baseAssignValue(object, key, value);
  2964. }
  2965. }
  2966. var _assignMergeValue = assignMergeValue;
  2967. /**
  2968. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  2969. *
  2970. * @private
  2971. * @param {boolean} [fromRight] Specify iterating from right to left.
  2972. * @returns {Function} Returns the new base function.
  2973. */
  2974. function createBaseFor(fromRight) {
  2975. return function(object, iteratee, keysFunc) {
  2976. var index = -1,
  2977. iterable = Object(object),
  2978. props = keysFunc(object),
  2979. length = props.length;
  2980. while (length--) {
  2981. var key = props[fromRight ? length : ++index];
  2982. if (iteratee(iterable[key], key, iterable) === false) {
  2983. break;
  2984. }
  2985. }
  2986. return object;
  2987. };
  2988. }
  2989. var _createBaseFor = createBaseFor;
  2990. /**
  2991. * The base implementation of `baseForOwn` which iterates over `object`
  2992. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  2993. * Iteratee functions may exit iteration early by explicitly returning `false`.
  2994. *
  2995. * @private
  2996. * @param {Object} object The object to iterate over.
  2997. * @param {Function} iteratee The function invoked per iteration.
  2998. * @param {Function} keysFunc The function to get the keys of `object`.
  2999. * @returns {Object} Returns `object`.
  3000. */
  3001. var baseFor = _createBaseFor();
  3002. var _baseFor = baseFor;
  3003. var _cloneBuffer = createCommonjsModule(function (module, exports) {
  3004. /** Detect free variable `exports`. */
  3005. var freeExports = exports && !exports.nodeType && exports;
  3006. /** Detect free variable `module`. */
  3007. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  3008. /** Detect the popular CommonJS extension `module.exports`. */
  3009. var moduleExports = freeModule && freeModule.exports === freeExports;
  3010. /** Built-in value references. */
  3011. var Buffer = moduleExports ? _root.Buffer : undefined,
  3012. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
  3013. /**
  3014. * Creates a clone of `buffer`.
  3015. *
  3016. * @private
  3017. * @param {Buffer} buffer The buffer to clone.
  3018. * @param {boolean} [isDeep] Specify a deep clone.
  3019. * @returns {Buffer} Returns the cloned buffer.
  3020. */
  3021. function cloneBuffer(buffer, isDeep) {
  3022. if (isDeep) {
  3023. return buffer.slice();
  3024. }
  3025. var length = buffer.length,
  3026. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  3027. buffer.copy(result);
  3028. return result;
  3029. }
  3030. module.exports = cloneBuffer;
  3031. });
  3032. /** Built-in value references. */
  3033. var Uint8Array$1 = _root.Uint8Array;
  3034. var _Uint8Array = Uint8Array$1;
  3035. /**
  3036. * Creates a clone of `arrayBuffer`.
  3037. *
  3038. * @private
  3039. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  3040. * @returns {ArrayBuffer} Returns the cloned array buffer.
  3041. */
  3042. function cloneArrayBuffer(arrayBuffer) {
  3043. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  3044. new _Uint8Array(result).set(new _Uint8Array(arrayBuffer));
  3045. return result;
  3046. }
  3047. var _cloneArrayBuffer = cloneArrayBuffer;
  3048. /**
  3049. * Creates a clone of `typedArray`.
  3050. *
  3051. * @private
  3052. * @param {Object} typedArray The typed array to clone.
  3053. * @param {boolean} [isDeep] Specify a deep clone.
  3054. * @returns {Object} Returns the cloned typed array.
  3055. */
  3056. function cloneTypedArray(typedArray, isDeep) {
  3057. var buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  3058. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  3059. }
  3060. var _cloneTypedArray = cloneTypedArray;
  3061. /**
  3062. * Copies the values of `source` to `array`.
  3063. *
  3064. * @private
  3065. * @param {Array} source The array to copy values from.
  3066. * @param {Array} [array=[]] The array to copy values to.
  3067. * @returns {Array} Returns `array`.
  3068. */
  3069. function copyArray(source, array) {
  3070. var index = -1,
  3071. length = source.length;
  3072. array || (array = Array(length));
  3073. while (++index < length) {
  3074. array[index] = source[index];
  3075. }
  3076. return array;
  3077. }
  3078. var _copyArray = copyArray;
  3079. /** Built-in value references. */
  3080. var objectCreate$1 = Object.create;
  3081. /**
  3082. * The base implementation of `_.create` without support for assigning
  3083. * properties to the created object.
  3084. *
  3085. * @private
  3086. * @param {Object} proto The object to inherit from.
  3087. * @returns {Object} Returns the new object.
  3088. */
  3089. var baseCreate = (function() {
  3090. function object() {}
  3091. return function(proto) {
  3092. if (!isObject_1(proto)) {
  3093. return {};
  3094. }
  3095. if (objectCreate$1) {
  3096. return objectCreate$1(proto);
  3097. }
  3098. object.prototype = proto;
  3099. var result = new object;
  3100. object.prototype = undefined;
  3101. return result;
  3102. };
  3103. }());
  3104. var _baseCreate = baseCreate;
  3105. /**
  3106. * Creates a unary function that invokes `func` with its argument transformed.
  3107. *
  3108. * @private
  3109. * @param {Function} func The function to wrap.
  3110. * @param {Function} transform The argument transform.
  3111. * @returns {Function} Returns the new function.
  3112. */
  3113. function overArg(func, transform) {
  3114. return function(arg) {
  3115. return func(transform(arg));
  3116. };
  3117. }
  3118. var _overArg = overArg;
  3119. /** Built-in value references. */
  3120. var getPrototype = _overArg(Object.getPrototypeOf, Object);
  3121. var _getPrototype = getPrototype;
  3122. /** Used for built-in method references. */
  3123. var objectProto$5 = Object.prototype;
  3124. /**
  3125. * Checks if `value` is likely a prototype object.
  3126. *
  3127. * @private
  3128. * @param {*} value The value to check.
  3129. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  3130. */
  3131. function isPrototype(value) {
  3132. var Ctor = value && value.constructor,
  3133. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$5;
  3134. return value === proto;
  3135. }
  3136. var _isPrototype = isPrototype;
  3137. /**
  3138. * Initializes an object clone.
  3139. *
  3140. * @private
  3141. * @param {Object} object The object to clone.
  3142. * @returns {Object} Returns the initialized clone.
  3143. */
  3144. function initCloneObject(object) {
  3145. return (typeof object.constructor == 'function' && !_isPrototype(object))
  3146. ? _baseCreate(_getPrototype(object))
  3147. : {};
  3148. }
  3149. var _initCloneObject = initCloneObject;
  3150. /**
  3151. * Checks if `value` is object-like. A value is object-like if it's not `null`
  3152. * and has a `typeof` result of "object".
  3153. *
  3154. * @static
  3155. * @memberOf _
  3156. * @since 4.0.0
  3157. * @category Lang
  3158. * @param {*} value The value to check.
  3159. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  3160. * @example
  3161. *
  3162. * _.isObjectLike({});
  3163. * // => true
  3164. *
  3165. * _.isObjectLike([1, 2, 3]);
  3166. * // => true
  3167. *
  3168. * _.isObjectLike(_.noop);
  3169. * // => false
  3170. *
  3171. * _.isObjectLike(null);
  3172. * // => false
  3173. */
  3174. function isObjectLike(value) {
  3175. return value != null && typeof value == 'object';
  3176. }
  3177. var isObjectLike_1 = isObjectLike;
  3178. /** `Object#toString` result references. */
  3179. var argsTag = '[object Arguments]';
  3180. /**
  3181. * The base implementation of `_.isArguments`.
  3182. *
  3183. * @private
  3184. * @param {*} value The value to check.
  3185. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  3186. */
  3187. function baseIsArguments(value) {
  3188. return isObjectLike_1(value) && _baseGetTag(value) == argsTag;
  3189. }
  3190. var _baseIsArguments = baseIsArguments;
  3191. /** Used for built-in method references. */
  3192. var objectProto$6 = Object.prototype;
  3193. /** Used to check objects for own properties. */
  3194. var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
  3195. /** Built-in value references. */
  3196. var propertyIsEnumerable = objectProto$6.propertyIsEnumerable;
  3197. /**
  3198. * Checks if `value` is likely an `arguments` object.
  3199. *
  3200. * @static
  3201. * @memberOf _
  3202. * @since 0.1.0
  3203. * @category Lang
  3204. * @param {*} value The value to check.
  3205. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  3206. * else `false`.
  3207. * @example
  3208. *
  3209. * _.isArguments(function() { return arguments; }());
  3210. * // => true
  3211. *
  3212. * _.isArguments([1, 2, 3]);
  3213. * // => false
  3214. */
  3215. var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
  3216. return isObjectLike_1(value) && hasOwnProperty$5.call(value, 'callee') &&
  3217. !propertyIsEnumerable.call(value, 'callee');
  3218. };
  3219. var isArguments_1 = isArguments;
  3220. /**
  3221. * Checks if `value` is classified as an `Array` object.
  3222. *
  3223. * @static
  3224. * @memberOf _
  3225. * @since 0.1.0
  3226. * @category Lang
  3227. * @param {*} value The value to check.
  3228. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  3229. * @example
  3230. *
  3231. * _.isArray([1, 2, 3]);
  3232. * // => true
  3233. *
  3234. * _.isArray(document.body.children);
  3235. * // => false
  3236. *
  3237. * _.isArray('abc');
  3238. * // => false
  3239. *
  3240. * _.isArray(_.noop);
  3241. * // => false
  3242. */
  3243. var isArray$1 = Array.isArray;
  3244. var isArray_1 = isArray$1;
  3245. /** Used as references for various `Number` constants. */
  3246. var MAX_SAFE_INTEGER$1 = 9007199254740991;
  3247. /**
  3248. * Checks if `value` is a valid array-like length.
  3249. *
  3250. * **Note:** This method is loosely based on
  3251. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  3252. *
  3253. * @static
  3254. * @memberOf _
  3255. * @since 4.0.0
  3256. * @category Lang
  3257. * @param {*} value The value to check.
  3258. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  3259. * @example
  3260. *
  3261. * _.isLength(3);
  3262. * // => true
  3263. *
  3264. * _.isLength(Number.MIN_VALUE);
  3265. * // => false
  3266. *
  3267. * _.isLength(Infinity);
  3268. * // => false
  3269. *
  3270. * _.isLength('3');
  3271. * // => false
  3272. */
  3273. function isLength(value) {
  3274. return typeof value == 'number' &&
  3275. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1;
  3276. }
  3277. var isLength_1 = isLength;
  3278. /**
  3279. * Checks if `value` is array-like. A value is considered array-like if it's
  3280. * not a function and has a `value.length` that's an integer greater than or
  3281. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  3282. *
  3283. * @static
  3284. * @memberOf _
  3285. * @since 4.0.0
  3286. * @category Lang
  3287. * @param {*} value The value to check.
  3288. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  3289. * @example
  3290. *
  3291. * _.isArrayLike([1, 2, 3]);
  3292. * // => true
  3293. *
  3294. * _.isArrayLike(document.body.children);
  3295. * // => true
  3296. *
  3297. * _.isArrayLike('abc');
  3298. * // => true
  3299. *
  3300. * _.isArrayLike(_.noop);
  3301. * // => false
  3302. */
  3303. function isArrayLike(value) {
  3304. return value != null && isLength_1(value.length) && !isFunction_1(value);
  3305. }
  3306. var isArrayLike_1 = isArrayLike;
  3307. /**
  3308. * This method is like `_.isArrayLike` except that it also checks if `value`
  3309. * is an object.
  3310. *
  3311. * @static
  3312. * @memberOf _
  3313. * @since 4.0.0
  3314. * @category Lang
  3315. * @param {*} value The value to check.
  3316. * @returns {boolean} Returns `true` if `value` is an array-like object,
  3317. * else `false`.
  3318. * @example
  3319. *
  3320. * _.isArrayLikeObject([1, 2, 3]);
  3321. * // => true
  3322. *
  3323. * _.isArrayLikeObject(document.body.children);
  3324. * // => true
  3325. *
  3326. * _.isArrayLikeObject('abc');
  3327. * // => false
  3328. *
  3329. * _.isArrayLikeObject(_.noop);
  3330. * // => false
  3331. */
  3332. function isArrayLikeObject(value) {
  3333. return isObjectLike_1(value) && isArrayLike_1(value);
  3334. }
  3335. var isArrayLikeObject_1 = isArrayLikeObject;
  3336. /**
  3337. * This method returns `false`.
  3338. *
  3339. * @static
  3340. * @memberOf _
  3341. * @since 4.13.0
  3342. * @category Util
  3343. * @returns {boolean} Returns `false`.
  3344. * @example
  3345. *
  3346. * _.times(2, _.stubFalse);
  3347. * // => [false, false]
  3348. */
  3349. function stubFalse() {
  3350. return false;
  3351. }
  3352. var stubFalse_1 = stubFalse;
  3353. var isBuffer_1 = createCommonjsModule(function (module, exports) {
  3354. /** Detect free variable `exports`. */
  3355. var freeExports = exports && !exports.nodeType && exports;
  3356. /** Detect free variable `module`. */
  3357. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  3358. /** Detect the popular CommonJS extension `module.exports`. */
  3359. var moduleExports = freeModule && freeModule.exports === freeExports;
  3360. /** Built-in value references. */
  3361. var Buffer = moduleExports ? _root.Buffer : undefined;
  3362. /* Built-in method references for those with the same name as other `lodash` methods. */
  3363. var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
  3364. /**
  3365. * Checks if `value` is a buffer.
  3366. *
  3367. * @static
  3368. * @memberOf _
  3369. * @since 4.3.0
  3370. * @category Lang
  3371. * @param {*} value The value to check.
  3372. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  3373. * @example
  3374. *
  3375. * _.isBuffer(new Buffer(2));
  3376. * // => true
  3377. *
  3378. * _.isBuffer(new Uint8Array(2));
  3379. * // => false
  3380. */
  3381. var isBuffer = nativeIsBuffer || stubFalse_1;
  3382. module.exports = isBuffer;
  3383. });
  3384. /** `Object#toString` result references. */
  3385. var objectTag = '[object Object]';
  3386. /** Used for built-in method references. */
  3387. var funcProto$2 = Function.prototype,
  3388. objectProto$7 = Object.prototype;
  3389. /** Used to resolve the decompiled source of functions. */
  3390. var funcToString$2 = funcProto$2.toString;
  3391. /** Used to check objects for own properties. */
  3392. var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
  3393. /** Used to infer the `Object` constructor. */
  3394. var objectCtorString = funcToString$2.call(Object);
  3395. /**
  3396. * Checks if `value` is a plain object, that is, an object created by the
  3397. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  3398. *
  3399. * @static
  3400. * @memberOf _
  3401. * @since 0.8.0
  3402. * @category Lang
  3403. * @param {*} value The value to check.
  3404. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  3405. * @example
  3406. *
  3407. * function Foo() {
  3408. * this.a = 1;
  3409. * }
  3410. *
  3411. * _.isPlainObject(new Foo);
  3412. * // => false
  3413. *
  3414. * _.isPlainObject([1, 2, 3]);
  3415. * // => false
  3416. *
  3417. * _.isPlainObject({ 'x': 0, 'y': 0 });
  3418. * // => true
  3419. *
  3420. * _.isPlainObject(Object.create(null));
  3421. * // => true
  3422. */
  3423. function isPlainObject(value) {
  3424. if (!isObjectLike_1(value) || _baseGetTag(value) != objectTag) {
  3425. return false;
  3426. }
  3427. var proto = _getPrototype(value);
  3428. if (proto === null) {
  3429. return true;
  3430. }
  3431. var Ctor = hasOwnProperty$6.call(proto, 'constructor') && proto.constructor;
  3432. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  3433. funcToString$2.call(Ctor) == objectCtorString;
  3434. }
  3435. var isPlainObject_1 = isPlainObject;
  3436. /** `Object#toString` result references. */
  3437. var argsTag$1 = '[object Arguments]',
  3438. arrayTag = '[object Array]',
  3439. boolTag = '[object Boolean]',
  3440. dateTag = '[object Date]',
  3441. errorTag = '[object Error]',
  3442. funcTag$1 = '[object Function]',
  3443. mapTag = '[object Map]',
  3444. numberTag = '[object Number]',
  3445. objectTag$1 = '[object Object]',
  3446. regexpTag = '[object RegExp]',
  3447. setTag = '[object Set]',
  3448. stringTag = '[object String]',
  3449. weakMapTag = '[object WeakMap]';
  3450. var arrayBufferTag = '[object ArrayBuffer]',
  3451. dataViewTag = '[object DataView]',
  3452. float32Tag = '[object Float32Array]',
  3453. float64Tag = '[object Float64Array]',
  3454. int8Tag = '[object Int8Array]',
  3455. int16Tag = '[object Int16Array]',
  3456. int32Tag = '[object Int32Array]',
  3457. uint8Tag = '[object Uint8Array]',
  3458. uint8ClampedTag = '[object Uint8ClampedArray]',
  3459. uint16Tag = '[object Uint16Array]',
  3460. uint32Tag = '[object Uint32Array]';
  3461. /** Used to identify `toStringTag` values of typed arrays. */
  3462. var typedArrayTags = {};
  3463. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  3464. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  3465. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  3466. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  3467. typedArrayTags[uint32Tag] = true;
  3468. typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
  3469. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  3470. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  3471. typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
  3472. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  3473. typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] =
  3474. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  3475. typedArrayTags[weakMapTag] = false;
  3476. /**
  3477. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  3478. *
  3479. * @private
  3480. * @param {*} value The value to check.
  3481. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  3482. */
  3483. function baseIsTypedArray(value) {
  3484. return isObjectLike_1(value) &&
  3485. isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
  3486. }
  3487. var _baseIsTypedArray = baseIsTypedArray;
  3488. /**
  3489. * The base implementation of `_.unary` without support for storing metadata.
  3490. *
  3491. * @private
  3492. * @param {Function} func The function to cap arguments for.
  3493. * @returns {Function} Returns the new capped function.
  3494. */
  3495. function baseUnary(func) {
  3496. return function(value) {
  3497. return func(value);
  3498. };
  3499. }
  3500. var _baseUnary = baseUnary;
  3501. var _nodeUtil = createCommonjsModule(function (module, exports) {
  3502. /** Detect free variable `exports`. */
  3503. var freeExports = exports && !exports.nodeType && exports;
  3504. /** Detect free variable `module`. */
  3505. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  3506. /** Detect the popular CommonJS extension `module.exports`. */
  3507. var moduleExports = freeModule && freeModule.exports === freeExports;
  3508. /** Detect free variable `process` from Node.js. */
  3509. var freeProcess = moduleExports && _freeGlobal.process;
  3510. /** Used to access faster Node.js helpers. */
  3511. var nodeUtil = (function() {
  3512. try {
  3513. // Use `util.types` for Node.js 10+.
  3514. var types = freeModule && freeModule.require && freeModule.require('util').types;
  3515. if (types) {
  3516. return types;
  3517. }
  3518. // Legacy `process.binding('util')` for Node.js < 10.
  3519. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  3520. } catch (e) {}
  3521. }());
  3522. module.exports = nodeUtil;
  3523. });
  3524. /* Node.js helper references. */
  3525. var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
  3526. /**
  3527. * Checks if `value` is classified as a typed array.
  3528. *
  3529. * @static
  3530. * @memberOf _
  3531. * @since 3.0.0
  3532. * @category Lang
  3533. * @param {*} value The value to check.
  3534. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  3535. * @example
  3536. *
  3537. * _.isTypedArray(new Uint8Array);
  3538. * // => true
  3539. *
  3540. * _.isTypedArray([]);
  3541. * // => false
  3542. */
  3543. var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
  3544. var isTypedArray_1 = isTypedArray;
  3545. /**
  3546. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  3547. *
  3548. * @private
  3549. * @param {Object} object The object to query.
  3550. * @param {string} key The key of the property to get.
  3551. * @returns {*} Returns the property value.
  3552. */
  3553. function safeGet(object, key) {
  3554. if (key === 'constructor' && typeof object[key] === 'function') {
  3555. return;
  3556. }
  3557. if (key == '__proto__') {
  3558. return;
  3559. }
  3560. return object[key];
  3561. }
  3562. var _safeGet = safeGet;
  3563. /** Used for built-in method references. */
  3564. var objectProto$8 = Object.prototype;
  3565. /** Used to check objects for own properties. */
  3566. var hasOwnProperty$7 = objectProto$8.hasOwnProperty;
  3567. /**
  3568. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  3569. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  3570. * for equality comparisons.
  3571. *
  3572. * @private
  3573. * @param {Object} object The object to modify.
  3574. * @param {string} key The key of the property to assign.
  3575. * @param {*} value The value to assign.
  3576. */
  3577. function assignValue(object, key, value) {
  3578. var objValue = object[key];
  3579. if (!(hasOwnProperty$7.call(object, key) && eq_1(objValue, value)) ||
  3580. (value === undefined && !(key in object))) {
  3581. _baseAssignValue(object, key, value);
  3582. }
  3583. }
  3584. var _assignValue = assignValue;
  3585. /**
  3586. * Copies properties of `source` to `object`.
  3587. *
  3588. * @private
  3589. * @param {Object} source The object to copy properties from.
  3590. * @param {Array} props The property identifiers to copy.
  3591. * @param {Object} [object={}] The object to copy properties to.
  3592. * @param {Function} [customizer] The function to customize copied values.
  3593. * @returns {Object} Returns `object`.
  3594. */
  3595. function copyObject(source, props, object, customizer) {
  3596. var isNew = !object;
  3597. object || (object = {});
  3598. var index = -1,
  3599. length = props.length;
  3600. while (++index < length) {
  3601. var key = props[index];
  3602. var newValue = customizer
  3603. ? customizer(object[key], source[key], key, object, source)
  3604. : undefined;
  3605. if (newValue === undefined) {
  3606. newValue = source[key];
  3607. }
  3608. if (isNew) {
  3609. _baseAssignValue(object, key, newValue);
  3610. } else {
  3611. _assignValue(object, key, newValue);
  3612. }
  3613. }
  3614. return object;
  3615. }
  3616. var _copyObject = copyObject;
  3617. /**
  3618. * The base implementation of `_.times` without support for iteratee shorthands
  3619. * or max array length checks.
  3620. *
  3621. * @private
  3622. * @param {number} n The number of times to invoke `iteratee`.
  3623. * @param {Function} iteratee The function invoked per iteration.
  3624. * @returns {Array} Returns the array of results.
  3625. */
  3626. function baseTimes(n, iteratee) {
  3627. var index = -1,
  3628. result = Array(n);
  3629. while (++index < n) {
  3630. result[index] = iteratee(index);
  3631. }
  3632. return result;
  3633. }
  3634. var _baseTimes = baseTimes;
  3635. /** Used as references for various `Number` constants. */
  3636. var MAX_SAFE_INTEGER$2 = 9007199254740991;
  3637. /** Used to detect unsigned integer values. */
  3638. var reIsUint = /^(?:0|[1-9]\d*)$/;
  3639. /**
  3640. * Checks if `value` is a valid array-like index.
  3641. *
  3642. * @private
  3643. * @param {*} value The value to check.
  3644. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  3645. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  3646. */
  3647. function isIndex(value, length) {
  3648. var type = typeof value;
  3649. length = length == null ? MAX_SAFE_INTEGER$2 : length;
  3650. return !!length &&
  3651. (type == 'number' ||
  3652. (type != 'symbol' && reIsUint.test(value))) &&
  3653. (value > -1 && value % 1 == 0 && value < length);
  3654. }
  3655. var _isIndex = isIndex;
  3656. /** Used for built-in method references. */
  3657. var objectProto$9 = Object.prototype;
  3658. /** Used to check objects for own properties. */
  3659. var hasOwnProperty$8 = objectProto$9.hasOwnProperty;
  3660. /**
  3661. * Creates an array of the enumerable property names of the array-like `value`.
  3662. *
  3663. * @private
  3664. * @param {*} value The value to query.
  3665. * @param {boolean} inherited Specify returning inherited property names.
  3666. * @returns {Array} Returns the array of property names.
  3667. */
  3668. function arrayLikeKeys(value, inherited) {
  3669. var isArr = isArray_1(value),
  3670. isArg = !isArr && isArguments_1(value),
  3671. isBuff = !isArr && !isArg && isBuffer_1(value),
  3672. isType = !isArr && !isArg && !isBuff && isTypedArray_1(value),
  3673. skipIndexes = isArr || isArg || isBuff || isType,
  3674. result = skipIndexes ? _baseTimes(value.length, String) : [],
  3675. length = result.length;
  3676. for (var key in value) {
  3677. if ((inherited || hasOwnProperty$8.call(value, key)) &&
  3678. !(skipIndexes && (
  3679. // Safari 9 has enumerable `arguments.length` in strict mode.
  3680. key == 'length' ||
  3681. // Node.js 0.10 has enumerable non-index properties on buffers.
  3682. (isBuff && (key == 'offset' || key == 'parent')) ||
  3683. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  3684. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  3685. // Skip index properties.
  3686. _isIndex(key, length)
  3687. ))) {
  3688. result.push(key);
  3689. }
  3690. }
  3691. return result;
  3692. }
  3693. var _arrayLikeKeys = arrayLikeKeys;
  3694. /**
  3695. * This function is like
  3696. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  3697. * except that it includes inherited enumerable properties.
  3698. *
  3699. * @private
  3700. * @param {Object} object The object to query.
  3701. * @returns {Array} Returns the array of property names.
  3702. */
  3703. function nativeKeysIn(object) {
  3704. var result = [];
  3705. if (object != null) {
  3706. for (var key in Object(object)) {
  3707. result.push(key);
  3708. }
  3709. }
  3710. return result;
  3711. }
  3712. var _nativeKeysIn = nativeKeysIn;
  3713. /** Used for built-in method references. */
  3714. var objectProto$a = Object.prototype;
  3715. /** Used to check objects for own properties. */
  3716. var hasOwnProperty$9 = objectProto$a.hasOwnProperty;
  3717. /**
  3718. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  3719. *
  3720. * @private
  3721. * @param {Object} object The object to query.
  3722. * @returns {Array} Returns the array of property names.
  3723. */
  3724. function baseKeysIn(object) {
  3725. if (!isObject_1(object)) {
  3726. return _nativeKeysIn(object);
  3727. }
  3728. var isProto = _isPrototype(object),
  3729. result = [];
  3730. for (var key in object) {
  3731. if (!(key == 'constructor' && (isProto || !hasOwnProperty$9.call(object, key)))) {
  3732. result.push(key);
  3733. }
  3734. }
  3735. return result;
  3736. }
  3737. var _baseKeysIn = baseKeysIn;
  3738. /**
  3739. * Creates an array of the own and inherited enumerable property names of `object`.
  3740. *
  3741. * **Note:** Non-object values are coerced to objects.
  3742. *
  3743. * @static
  3744. * @memberOf _
  3745. * @since 3.0.0
  3746. * @category Object
  3747. * @param {Object} object The object to query.
  3748. * @returns {Array} Returns the array of property names.
  3749. * @example
  3750. *
  3751. * function Foo() {
  3752. * this.a = 1;
  3753. * this.b = 2;
  3754. * }
  3755. *
  3756. * Foo.prototype.c = 3;
  3757. *
  3758. * _.keysIn(new Foo);
  3759. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  3760. */
  3761. function keysIn(object) {
  3762. return isArrayLike_1(object) ? _arrayLikeKeys(object, true) : _baseKeysIn(object);
  3763. }
  3764. var keysIn_1 = keysIn;
  3765. /**
  3766. * Converts `value` to a plain object flattening inherited enumerable string
  3767. * keyed properties of `value` to own properties of the plain object.
  3768. *
  3769. * @static
  3770. * @memberOf _
  3771. * @since 3.0.0
  3772. * @category Lang
  3773. * @param {*} value The value to convert.
  3774. * @returns {Object} Returns the converted plain object.
  3775. * @example
  3776. *
  3777. * function Foo() {
  3778. * this.b = 2;
  3779. * }
  3780. *
  3781. * Foo.prototype.c = 3;
  3782. *
  3783. * _.assign({ 'a': 1 }, new Foo);
  3784. * // => { 'a': 1, 'b': 2 }
  3785. *
  3786. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  3787. * // => { 'a': 1, 'b': 2, 'c': 3 }
  3788. */
  3789. function toPlainObject(value) {
  3790. return _copyObject(value, keysIn_1(value));
  3791. }
  3792. var toPlainObject_1 = toPlainObject;
  3793. /**
  3794. * A specialized version of `baseMerge` for arrays and objects which performs
  3795. * deep merges and tracks traversed objects enabling objects with circular
  3796. * references to be merged.
  3797. *
  3798. * @private
  3799. * @param {Object} object The destination object.
  3800. * @param {Object} source The source object.
  3801. * @param {string} key The key of the value to merge.
  3802. * @param {number} srcIndex The index of `source`.
  3803. * @param {Function} mergeFunc The function to merge values.
  3804. * @param {Function} [customizer] The function to customize assigned values.
  3805. * @param {Object} [stack] Tracks traversed source values and their merged
  3806. * counterparts.
  3807. */
  3808. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  3809. var objValue = _safeGet(object, key),
  3810. srcValue = _safeGet(source, key),
  3811. stacked = stack.get(srcValue);
  3812. if (stacked) {
  3813. _assignMergeValue(object, key, stacked);
  3814. return;
  3815. }
  3816. var newValue = customizer
  3817. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  3818. : undefined;
  3819. var isCommon = newValue === undefined;
  3820. if (isCommon) {
  3821. var isArr = isArray_1(srcValue),
  3822. isBuff = !isArr && isBuffer_1(srcValue),
  3823. isTyped = !isArr && !isBuff && isTypedArray_1(srcValue);
  3824. newValue = srcValue;
  3825. if (isArr || isBuff || isTyped) {
  3826. if (isArray_1(objValue)) {
  3827. newValue = objValue;
  3828. }
  3829. else if (isArrayLikeObject_1(objValue)) {
  3830. newValue = _copyArray(objValue);
  3831. }
  3832. else if (isBuff) {
  3833. isCommon = false;
  3834. newValue = _cloneBuffer(srcValue, true);
  3835. }
  3836. else if (isTyped) {
  3837. isCommon = false;
  3838. newValue = _cloneTypedArray(srcValue, true);
  3839. }
  3840. else {
  3841. newValue = [];
  3842. }
  3843. }
  3844. else if (isPlainObject_1(srcValue) || isArguments_1(srcValue)) {
  3845. newValue = objValue;
  3846. if (isArguments_1(objValue)) {
  3847. newValue = toPlainObject_1(objValue);
  3848. }
  3849. else if (!isObject_1(objValue) || isFunction_1(objValue)) {
  3850. newValue = _initCloneObject(srcValue);
  3851. }
  3852. }
  3853. else {
  3854. isCommon = false;
  3855. }
  3856. }
  3857. if (isCommon) {
  3858. // Recursively merge objects and arrays (susceptible to call stack limits).
  3859. stack.set(srcValue, newValue);
  3860. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  3861. stack['delete'](srcValue);
  3862. }
  3863. _assignMergeValue(object, key, newValue);
  3864. }
  3865. var _baseMergeDeep = baseMergeDeep;
  3866. /**
  3867. * The base implementation of `_.merge` without support for multiple sources.
  3868. *
  3869. * @private
  3870. * @param {Object} object The destination object.
  3871. * @param {Object} source The source object.
  3872. * @param {number} srcIndex The index of `source`.
  3873. * @param {Function} [customizer] The function to customize merged values.
  3874. * @param {Object} [stack] Tracks traversed source values and their merged
  3875. * counterparts.
  3876. */
  3877. function baseMerge(object, source, srcIndex, customizer, stack) {
  3878. if (object === source) {
  3879. return;
  3880. }
  3881. _baseFor(source, function(srcValue, key) {
  3882. stack || (stack = new _Stack);
  3883. if (isObject_1(srcValue)) {
  3884. _baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  3885. }
  3886. else {
  3887. var newValue = customizer
  3888. ? customizer(_safeGet(object, key), srcValue, (key + ''), object, source, stack)
  3889. : undefined;
  3890. if (newValue === undefined) {
  3891. newValue = srcValue;
  3892. }
  3893. _assignMergeValue(object, key, newValue);
  3894. }
  3895. }, keysIn_1);
  3896. }
  3897. var _baseMerge = baseMerge;
  3898. /**
  3899. * This method returns the first argument it receives.
  3900. *
  3901. * @static
  3902. * @since 0.1.0
  3903. * @memberOf _
  3904. * @category Util
  3905. * @param {*} value Any value.
  3906. * @returns {*} Returns `value`.
  3907. * @example
  3908. *
  3909. * var object = { 'a': 1 };
  3910. *
  3911. * console.log(_.identity(object) === object);
  3912. * // => true
  3913. */
  3914. function identity(value) {
  3915. return value;
  3916. }
  3917. var identity_1 = identity;
  3918. /**
  3919. * A faster alternative to `Function#apply`, this function invokes `func`
  3920. * with the `this` binding of `thisArg` and the arguments of `args`.
  3921. *
  3922. * @private
  3923. * @param {Function} func The function to invoke.
  3924. * @param {*} thisArg The `this` binding of `func`.
  3925. * @param {Array} args The arguments to invoke `func` with.
  3926. * @returns {*} Returns the result of `func`.
  3927. */
  3928. function apply$1(func, thisArg, args) {
  3929. switch (args.length) {
  3930. case 0: return func.call(thisArg);
  3931. case 1: return func.call(thisArg, args[0]);
  3932. case 2: return func.call(thisArg, args[0], args[1]);
  3933. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  3934. }
  3935. return func.apply(thisArg, args);
  3936. }
  3937. var _apply = apply$1;
  3938. /* Built-in method references for those with the same name as other `lodash` methods. */
  3939. var nativeMax = Math.max;
  3940. /**
  3941. * A specialized version of `baseRest` which transforms the rest array.
  3942. *
  3943. * @private
  3944. * @param {Function} func The function to apply a rest parameter to.
  3945. * @param {number} [start=func.length-1] The start position of the rest parameter.
  3946. * @param {Function} transform The rest array transform.
  3947. * @returns {Function} Returns the new function.
  3948. */
  3949. function overRest(func, start, transform) {
  3950. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  3951. return function() {
  3952. var args = arguments,
  3953. index = -1,
  3954. length = nativeMax(args.length - start, 0),
  3955. array = Array(length);
  3956. while (++index < length) {
  3957. array[index] = args[start + index];
  3958. }
  3959. index = -1;
  3960. var otherArgs = Array(start + 1);
  3961. while (++index < start) {
  3962. otherArgs[index] = args[index];
  3963. }
  3964. otherArgs[start] = transform(array);
  3965. return _apply(func, this, otherArgs);
  3966. };
  3967. }
  3968. var _overRest = overRest;
  3969. /**
  3970. * Creates a function that returns `value`.
  3971. *
  3972. * @static
  3973. * @memberOf _
  3974. * @since 2.4.0
  3975. * @category Util
  3976. * @param {*} value The value to return from the new function.
  3977. * @returns {Function} Returns the new constant function.
  3978. * @example
  3979. *
  3980. * var objects = _.times(2, _.constant({ 'a': 1 }));
  3981. *
  3982. * console.log(objects);
  3983. * // => [{ 'a': 1 }, { 'a': 1 }]
  3984. *
  3985. * console.log(objects[0] === objects[1]);
  3986. * // => true
  3987. */
  3988. function constant(value) {
  3989. return function() {
  3990. return value;
  3991. };
  3992. }
  3993. var constant_1 = constant;
  3994. /**
  3995. * The base implementation of `setToString` without support for hot loop shorting.
  3996. *
  3997. * @private
  3998. * @param {Function} func The function to modify.
  3999. * @param {Function} string The `toString` result.
  4000. * @returns {Function} Returns `func`.
  4001. */
  4002. var baseSetToString = !_defineProperty$1 ? identity_1 : function(func, string) {
  4003. return _defineProperty$1(func, 'toString', {
  4004. 'configurable': true,
  4005. 'enumerable': false,
  4006. 'value': constant_1(string),
  4007. 'writable': true
  4008. });
  4009. };
  4010. var _baseSetToString = baseSetToString;
  4011. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  4012. var HOT_COUNT = 800,
  4013. HOT_SPAN = 16;
  4014. /* Built-in method references for those with the same name as other `lodash` methods. */
  4015. var nativeNow = Date.now;
  4016. /**
  4017. * Creates a function that'll short out and invoke `identity` instead
  4018. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  4019. * milliseconds.
  4020. *
  4021. * @private
  4022. * @param {Function} func The function to restrict.
  4023. * @returns {Function} Returns the new shortable function.
  4024. */
  4025. function shortOut(func) {
  4026. var count = 0,
  4027. lastCalled = 0;
  4028. return function() {
  4029. var stamp = nativeNow(),
  4030. remaining = HOT_SPAN - (stamp - lastCalled);
  4031. lastCalled = stamp;
  4032. if (remaining > 0) {
  4033. if (++count >= HOT_COUNT) {
  4034. return arguments[0];
  4035. }
  4036. } else {
  4037. count = 0;
  4038. }
  4039. return func.apply(undefined, arguments);
  4040. };
  4041. }
  4042. var _shortOut = shortOut;
  4043. /**
  4044. * Sets the `toString` method of `func` to return `string`.
  4045. *
  4046. * @private
  4047. * @param {Function} func The function to modify.
  4048. * @param {Function} string The `toString` result.
  4049. * @returns {Function} Returns `func`.
  4050. */
  4051. var setToString = _shortOut(_baseSetToString);
  4052. var _setToString = setToString;
  4053. /**
  4054. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  4055. *
  4056. * @private
  4057. * @param {Function} func The function to apply a rest parameter to.
  4058. * @param {number} [start=func.length-1] The start position of the rest parameter.
  4059. * @returns {Function} Returns the new function.
  4060. */
  4061. function baseRest(func, start) {
  4062. return _setToString(_overRest(func, start, identity_1), func + '');
  4063. }
  4064. var _baseRest = baseRest;
  4065. /**
  4066. * Checks if the given arguments are from an iteratee call.
  4067. *
  4068. * @private
  4069. * @param {*} value The potential iteratee value argument.
  4070. * @param {*} index The potential iteratee index or key argument.
  4071. * @param {*} object The potential iteratee object argument.
  4072. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  4073. * else `false`.
  4074. */
  4075. function isIterateeCall(value, index, object) {
  4076. if (!isObject_1(object)) {
  4077. return false;
  4078. }
  4079. var type = typeof index;
  4080. if (type == 'number'
  4081. ? (isArrayLike_1(object) && _isIndex(index, object.length))
  4082. : (type == 'string' && index in object)
  4083. ) {
  4084. return eq_1(object[index], value);
  4085. }
  4086. return false;
  4087. }
  4088. var _isIterateeCall = isIterateeCall;
  4089. /**
  4090. * Creates a function like `_.assign`.
  4091. *
  4092. * @private
  4093. * @param {Function} assigner The function to assign values.
  4094. * @returns {Function} Returns the new assigner function.
  4095. */
  4096. function createAssigner(assigner) {
  4097. return _baseRest(function(object, sources) {
  4098. var index = -1,
  4099. length = sources.length,
  4100. customizer = length > 1 ? sources[length - 1] : undefined,
  4101. guard = length > 2 ? sources[2] : undefined;
  4102. customizer = (assigner.length > 3 && typeof customizer == 'function')
  4103. ? (length--, customizer)
  4104. : undefined;
  4105. if (guard && _isIterateeCall(sources[0], sources[1], guard)) {
  4106. customizer = length < 3 ? undefined : customizer;
  4107. length = 1;
  4108. }
  4109. object = Object(object);
  4110. while (++index < length) {
  4111. var source = sources[index];
  4112. if (source) {
  4113. assigner(object, source, index, customizer);
  4114. }
  4115. }
  4116. return object;
  4117. });
  4118. }
  4119. var _createAssigner = createAssigner;
  4120. /**
  4121. * This method is like `_.merge` except that it accepts `customizer` which
  4122. * is invoked to produce the merged values of the destination and source
  4123. * properties. If `customizer` returns `undefined`, merging is handled by the
  4124. * method instead. The `customizer` is invoked with six arguments:
  4125. * (objValue, srcValue, key, object, source, stack).
  4126. *
  4127. * **Note:** This method mutates `object`.
  4128. *
  4129. * @static
  4130. * @memberOf _
  4131. * @since 4.0.0
  4132. * @category Object
  4133. * @param {Object} object The destination object.
  4134. * @param {...Object} sources The source objects.
  4135. * @param {Function} customizer The function to customize assigned values.
  4136. * @returns {Object} Returns `object`.
  4137. * @example
  4138. *
  4139. * function customizer(objValue, srcValue) {
  4140. * if (_.isArray(objValue)) {
  4141. * return objValue.concat(srcValue);
  4142. * }
  4143. * }
  4144. *
  4145. * var object = { 'a': [1], 'b': [2] };
  4146. * var other = { 'a': [3], 'b': [4] };
  4147. *
  4148. * _.mergeWith(object, other, customizer);
  4149. * // => { 'a': [1, 3], 'b': [2, 4] }
  4150. */
  4151. var mergeWith = _createAssigner(function(object, source, srcIndex, customizer) {
  4152. _baseMerge(object, source, srcIndex, customizer);
  4153. });
  4154. var mergeWith_1 = mergeWith;
  4155. var getOwnPropertySymbols$3 = getOwnPropertySymbols$1;
  4156. var getOwnPropertySymbols$4 = getOwnPropertySymbols$3;
  4157. var getOwnPropertySymbols$5 = getOwnPropertySymbols$4;
  4158. var getOwnPropertySymbols$6 = getOwnPropertySymbols$5;
  4159. /* eslint-disable es-x/no-array-prototype-indexof -- required for testing */
  4160. var $IndexOf = arrayIncludes.indexOf;
  4161. var un$IndexOf = functionUncurryThis([].indexOf);
  4162. var NEGATIVE_ZERO = !!un$IndexOf && 1 / un$IndexOf([1], 1, -0) < 0;
  4163. var STRICT_METHOD$1 = arrayMethodIsStrict('indexOf');
  4164. // `Array.prototype.indexOf` method
  4165. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  4166. _export({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || !STRICT_METHOD$1 }, {
  4167. indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
  4168. var fromIndex = arguments.length > 1 ? arguments[1] : undefined;
  4169. return NEGATIVE_ZERO
  4170. // convert -0 to +0
  4171. ? un$IndexOf(this, searchElement, fromIndex) || 0
  4172. : $IndexOf(this, searchElement, fromIndex);
  4173. }
  4174. });
  4175. var indexOf$1 = entryVirtual('Array').indexOf;
  4176. var ArrayPrototype$3 = Array.prototype;
  4177. var indexOf$2 = function (it) {
  4178. var own = it.indexOf;
  4179. return it === ArrayPrototype$3 || (objectIsPrototypeOf(ArrayPrototype$3, it) && own === ArrayPrototype$3.indexOf) ? indexOf$1 : own;
  4180. };
  4181. var indexOf$3 = indexOf$2;
  4182. var indexOf$4 = indexOf$3;
  4183. var indexOf$5 = indexOf$4;
  4184. var indexOf$6 = indexOf$5;
  4185. var indexOf$7 = indexOf$6;
  4186. var keys$4 = keys$2;
  4187. var keys$5 = keys$4;
  4188. var keys$6 = keys$5;
  4189. var keys$7 = keys$6;
  4190. var objectWithoutPropertiesLoose = createCommonjsModule(function (module) {
  4191. function _objectWithoutPropertiesLoose(source, excluded) {
  4192. if (source == null) return {};
  4193. var target = {};
  4194. var sourceKeys = keys$7(source);
  4195. var key, i;
  4196. for (i = 0; i < sourceKeys.length; i++) {
  4197. key = sourceKeys[i];
  4198. if (indexOf$7(excluded).call(excluded, key) >= 0) continue;
  4199. target[key] = source[key];
  4200. }
  4201. return target;
  4202. }
  4203. module.exports = _objectWithoutPropertiesLoose, module.exports.__esModule = true, module.exports["default"] = module.exports;
  4204. });
  4205. unwrapExports(objectWithoutPropertiesLoose);
  4206. var objectWithoutProperties = createCommonjsModule(function (module) {
  4207. function _objectWithoutProperties(source, excluded) {
  4208. if (source == null) return {};
  4209. var target = objectWithoutPropertiesLoose(source, excluded);
  4210. var key, i;
  4211. if (getOwnPropertySymbols$6) {
  4212. var sourceSymbolKeys = getOwnPropertySymbols$6(source);
  4213. for (i = 0; i < sourceSymbolKeys.length; i++) {
  4214. key = sourceSymbolKeys[i];
  4215. if (indexOf$7(excluded).call(excluded, key) >= 0) continue;
  4216. if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
  4217. target[key] = source[key];
  4218. }
  4219. }
  4220. return target;
  4221. }
  4222. module.exports = _objectWithoutProperties, module.exports.__esModule = true, module.exports["default"] = module.exports;
  4223. });
  4224. var _objectWithoutProperties = unwrapExports(objectWithoutProperties);
  4225. // eslint-disable-next-line es-x/no-object-assign -- safe
  4226. var $assign = Object.assign;
  4227. // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
  4228. var defineProperty$c = Object.defineProperty;
  4229. var concat$6 = functionUncurryThis([].concat);
  4230. // `Object.assign` method
  4231. // https://tc39.es/ecma262/#sec-object.assign
  4232. var objectAssign = !$assign || fails(function () {
  4233. // should have correct order of operations (Edge bug)
  4234. if (descriptors && $assign({ b: 1 }, $assign(defineProperty$c({}, 'a', {
  4235. enumerable: true,
  4236. get: function () {
  4237. defineProperty$c(this, 'b', {
  4238. value: 3,
  4239. enumerable: false
  4240. });
  4241. }
  4242. }), { b: 2 })).b !== 1) return true;
  4243. // should work with symbols and should have deterministic property order (V8 bug)
  4244. var A = {};
  4245. var B = {};
  4246. // eslint-disable-next-line es-x/no-symbol -- safe
  4247. var symbol = Symbol();
  4248. var alphabet = 'abcdefghijklmnopqrst';
  4249. A[symbol] = 7;
  4250. alphabet.split('').forEach(function (chr) { B[chr] = chr; });
  4251. return $assign({}, A)[symbol] != 7 || objectKeys($assign({}, B)).join('') != alphabet;
  4252. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
  4253. var T = toObject(target);
  4254. var argumentsLength = arguments.length;
  4255. var index = 1;
  4256. var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
  4257. var propertyIsEnumerable = objectPropertyIsEnumerable.f;
  4258. while (argumentsLength > index) {
  4259. var S = indexedObject(arguments[index++]);
  4260. var keys = getOwnPropertySymbols ? concat$6(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S);
  4261. var length = keys.length;
  4262. var j = 0;
  4263. var key;
  4264. while (length > j) {
  4265. key = keys[j++];
  4266. if (!descriptors || functionCall(propertyIsEnumerable, S, key)) T[key] = S[key];
  4267. }
  4268. } return T;
  4269. } : $assign;
  4270. // `Object.assign` method
  4271. // https://tc39.es/ecma262/#sec-object.assign
  4272. // eslint-disable-next-line es-x/no-object-assign -- required for testing
  4273. _export({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== objectAssign }, {
  4274. assign: objectAssign
  4275. });
  4276. var assign = path.Object.assign;
  4277. var assign$1 = assign;
  4278. var assign$2 = assign$1;
  4279. // a string of all valid unicode whitespaces
  4280. var whitespaces = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
  4281. '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
  4282. var replace$1 = functionUncurryThis(''.replace);
  4283. var whitespace = '[' + whitespaces + ']';
  4284. var ltrim = RegExp('^' + whitespace + whitespace + '*');
  4285. var rtrim = RegExp(whitespace + whitespace + '*$');
  4286. // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
  4287. var createMethod$3 = function (TYPE) {
  4288. return function ($this) {
  4289. var string = toString_1(requireObjectCoercible($this));
  4290. if (TYPE & 1) string = replace$1(string, ltrim, '');
  4291. if (TYPE & 2) string = replace$1(string, rtrim, '');
  4292. return string;
  4293. };
  4294. };
  4295. var stringTrim = {
  4296. // `String.prototype.{ trimLeft, trimStart }` methods
  4297. // https://tc39.es/ecma262/#sec-string.prototype.trimstart
  4298. start: createMethod$3(1),
  4299. // `String.prototype.{ trimRight, trimEnd }` methods
  4300. // https://tc39.es/ecma262/#sec-string.prototype.trimend
  4301. end: createMethod$3(2),
  4302. // `String.prototype.trim` method
  4303. // https://tc39.es/ecma262/#sec-string.prototype.trim
  4304. trim: createMethod$3(3)
  4305. };
  4306. var PROPER_FUNCTION_NAME$1 = functionName.PROPER;
  4307. var non = '\u200B\u0085\u180E';
  4308. // check that a method works with the correct list
  4309. // of whitespaces and has a correct name
  4310. var stringTrimForced = function (METHOD_NAME) {
  4311. return fails(function () {
  4312. return !!whitespaces[METHOD_NAME]()
  4313. || non[METHOD_NAME]() !== non
  4314. || (PROPER_FUNCTION_NAME$1 && whitespaces[METHOD_NAME].name !== METHOD_NAME);
  4315. });
  4316. };
  4317. var $trim = stringTrim.trim;
  4318. // `String.prototype.trim` method
  4319. // https://tc39.es/ecma262/#sec-string.prototype.trim
  4320. _export({ target: 'String', proto: true, forced: stringTrimForced('trim') }, {
  4321. trim: function trim() {
  4322. return $trim(this);
  4323. }
  4324. });
  4325. var trim = entryVirtual('String').trim;
  4326. var StringPrototype = String.prototype;
  4327. var trim$1 = function (it) {
  4328. var own = it.trim;
  4329. return typeof it == 'string' || it === StringPrototype
  4330. || (objectIsPrototypeOf(StringPrototype, it) && own === StringPrototype.trim) ? trim : own;
  4331. };
  4332. var trim$2 = trim$1;
  4333. var trim$3 = trim$2;
  4334. var iteratorClose = function (iterator, kind, value) {
  4335. var innerResult, innerError;
  4336. anObject(iterator);
  4337. try {
  4338. innerResult = getMethod(iterator, 'return');
  4339. if (!innerResult) {
  4340. if (kind === 'throw') throw value;
  4341. return value;
  4342. }
  4343. innerResult = functionCall(innerResult, iterator);
  4344. } catch (error) {
  4345. innerError = true;
  4346. innerResult = error;
  4347. }
  4348. if (kind === 'throw') throw value;
  4349. if (innerError) throw innerResult;
  4350. anObject(innerResult);
  4351. return value;
  4352. };
  4353. // call something on iterator step with safe closing on error
  4354. var callWithSafeIterationClosing = function (iterator, fn, value, ENTRIES) {
  4355. try {
  4356. return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
  4357. } catch (error) {
  4358. iteratorClose(iterator, 'throw', error);
  4359. }
  4360. };
  4361. var ITERATOR$2 = wellKnownSymbol('iterator');
  4362. var ArrayPrototype$4 = Array.prototype;
  4363. // check on default Array iterator
  4364. var isArrayIteratorMethod = function (it) {
  4365. return it !== undefined && (iterators.Array === it || ArrayPrototype$4[ITERATOR$2] === it);
  4366. };
  4367. var ITERATOR$3 = wellKnownSymbol('iterator');
  4368. var getIteratorMethod = function (it) {
  4369. if (it != undefined) return getMethod(it, ITERATOR$3)
  4370. || getMethod(it, '@@iterator')
  4371. || iterators[classof(it)];
  4372. };
  4373. var TypeError$d = global_1.TypeError;
  4374. var getIterator = function (argument, usingIterator) {
  4375. var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator;
  4376. if (aCallable(iteratorMethod)) return anObject(functionCall(iteratorMethod, argument));
  4377. throw TypeError$d(tryToString(argument) + ' is not iterable');
  4378. };
  4379. var Array$3 = global_1.Array;
  4380. // `Array.from` method implementation
  4381. // https://tc39.es/ecma262/#sec-array.from
  4382. var arrayFrom = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
  4383. var O = toObject(arrayLike);
  4384. var IS_CONSTRUCTOR = isConstructor(this);
  4385. var argumentsLength = arguments.length;
  4386. var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
  4387. var mapping = mapfn !== undefined;
  4388. if (mapping) mapfn = functionBindContext(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
  4389. var iteratorMethod = getIteratorMethod(O);
  4390. var index = 0;
  4391. var length, result, step, iterator, next, value;
  4392. // if the target is not iterable or it's an array with the default iterator - use a simple case
  4393. if (iteratorMethod && !(this == Array$3 && isArrayIteratorMethod(iteratorMethod))) {
  4394. iterator = getIterator(O, iteratorMethod);
  4395. next = iterator.next;
  4396. result = IS_CONSTRUCTOR ? new this() : [];
  4397. for (;!(step = functionCall(next, iterator)).done; index++) {
  4398. value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
  4399. createProperty(result, index, value);
  4400. }
  4401. } else {
  4402. length = lengthOfArrayLike(O);
  4403. result = IS_CONSTRUCTOR ? new this(length) : Array$3(length);
  4404. for (;length > index; index++) {
  4405. value = mapping ? mapfn(O[index], index) : O[index];
  4406. createProperty(result, index, value);
  4407. }
  4408. }
  4409. result.length = index;
  4410. return result;
  4411. };
  4412. var ITERATOR$4 = wellKnownSymbol('iterator');
  4413. var SAFE_CLOSING = false;
  4414. try {
  4415. var called = 0;
  4416. var iteratorWithReturn = {
  4417. next: function () {
  4418. return { done: !!called++ };
  4419. },
  4420. 'return': function () {
  4421. SAFE_CLOSING = true;
  4422. }
  4423. };
  4424. iteratorWithReturn[ITERATOR$4] = function () {
  4425. return this;
  4426. };
  4427. // eslint-disable-next-line es-x/no-array-from, no-throw-literal -- required for testing
  4428. Array.from(iteratorWithReturn, function () { throw 2; });
  4429. } catch (error) { /* empty */ }
  4430. var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) {
  4431. if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
  4432. var ITERATION_SUPPORT = false;
  4433. try {
  4434. var object = {};
  4435. object[ITERATOR$4] = function () {
  4436. return {
  4437. next: function () {
  4438. return { done: ITERATION_SUPPORT = true };
  4439. }
  4440. };
  4441. };
  4442. exec(object);
  4443. } catch (error) { /* empty */ }
  4444. return ITERATION_SUPPORT;
  4445. };
  4446. var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
  4447. // eslint-disable-next-line es-x/no-array-from -- required for testing
  4448. Array.from(iterable);
  4449. });
  4450. // `Array.from` method
  4451. // https://tc39.es/ecma262/#sec-array.from
  4452. _export({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {
  4453. from: arrayFrom
  4454. });
  4455. var from_1 = path.Array.from;
  4456. var from_1$1 = from_1;
  4457. var from_1$2 = from_1$1;
  4458. var MATCH = wellKnownSymbol('match');
  4459. // `IsRegExp` abstract operation
  4460. // https://tc39.es/ecma262/#sec-isregexp
  4461. var isRegexp = function (it) {
  4462. var isRegExp;
  4463. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp');
  4464. };
  4465. var TypeError$e = global_1.TypeError;
  4466. var notARegexp = function (it) {
  4467. if (isRegexp(it)) {
  4468. throw TypeError$e("The method doesn't accept regular expressions");
  4469. } return it;
  4470. };
  4471. var MATCH$1 = wellKnownSymbol('match');
  4472. var correctIsRegexpLogic = function (METHOD_NAME) {
  4473. var regexp = /./;
  4474. try {
  4475. '/./'[METHOD_NAME](regexp);
  4476. } catch (error1) {
  4477. try {
  4478. regexp[MATCH$1] = false;
  4479. return '/./'[METHOD_NAME](regexp);
  4480. } catch (error2) { /* empty */ }
  4481. } return false;
  4482. };
  4483. // eslint-disable-next-line es-x/no-string-prototype-startswith -- safe
  4484. var un$StartsWith = functionUncurryThis(''.startsWith);
  4485. var stringSlice$2 = functionUncurryThis(''.slice);
  4486. var min$2 = Math.min;
  4487. var CORRECT_IS_REGEXP_LOGIC = correctIsRegexpLogic('startsWith');
  4488. // `String.prototype.startsWith` method
  4489. // https://tc39.es/ecma262/#sec-string.prototype.startswith
  4490. _export({ target: 'String', proto: true, forced: !CORRECT_IS_REGEXP_LOGIC }, {
  4491. startsWith: function startsWith(searchString /* , position = 0 */) {
  4492. var that = toString_1(requireObjectCoercible(this));
  4493. notARegexp(searchString);
  4494. var index = toLength(min$2(arguments.length > 1 ? arguments[1] : undefined, that.length));
  4495. var search = toString_1(searchString);
  4496. return un$StartsWith
  4497. ? un$StartsWith(that, search, index)
  4498. : stringSlice$2(that, index, index + search.length) === search;
  4499. }
  4500. });
  4501. var startsWith = entryVirtual('String').startsWith;
  4502. var StringPrototype$1 = String.prototype;
  4503. var startsWith$1 = function (it) {
  4504. var own = it.startsWith;
  4505. return typeof it == 'string' || it === StringPrototype$1
  4506. || (objectIsPrototypeOf(StringPrototype$1, it) && own === StringPrototype$1.startsWith) ? startsWith : own;
  4507. };
  4508. var startsWith$2 = startsWith$1;
  4509. var startsWith$3 = startsWith$2;
  4510. var $find = arrayIteration.find;
  4511. var FIND = 'find';
  4512. var SKIPS_HOLES = true;
  4513. // Shouldn't skip holes
  4514. if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
  4515. // `Array.prototype.find` method
  4516. // https://tc39.es/ecma262/#sec-array.prototype.find
  4517. _export({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
  4518. find: function find(callbackfn /* , that = undefined */) {
  4519. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  4520. }
  4521. });
  4522. var find = entryVirtual('Array').find;
  4523. var ArrayPrototype$5 = Array.prototype;
  4524. var find$1 = function (it) {
  4525. var own = it.find;
  4526. return it === ArrayPrototype$5 || (objectIsPrototypeOf(ArrayPrototype$5, it) && own === ArrayPrototype$5.find) ? find : own;
  4527. };
  4528. var find$2 = find$1;
  4529. var find$3 = find$2;
  4530. var codemirror = createCommonjsModule(function (module, exports) {
  4531. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  4532. // Distributed under an MIT license: https://codemirror.net/LICENSE
  4533. // This is CodeMirror (https://codemirror.net), a code editor
  4534. // implemented in JavaScript on top of the browser's DOM.
  4535. //
  4536. // You can find some technical background for some of the code below
  4537. // at http://marijnhaverbeke.nl/blog/#cm-internals .
  4538. (function (global, factory) {
  4539. module.exports = factory() ;
  4540. }(commonjsGlobal, (function () {
  4541. // Kludges for bugs and behavior differences that can't be feature
  4542. // detected are enabled based on userAgent etc sniffing.
  4543. var userAgent = navigator.userAgent;
  4544. var platform = navigator.platform;
  4545. var gecko = /gecko\/\d/i.test(userAgent);
  4546. var ie_upto10 = /MSIE \d/.test(userAgent);
  4547. var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
  4548. var edge = /Edge\/(\d+)/.exec(userAgent);
  4549. var ie = ie_upto10 || ie_11up || edge;
  4550. var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]);
  4551. var webkit = !edge && /WebKit\//.test(userAgent);
  4552. var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
  4553. var chrome = !edge && /Chrome\//.test(userAgent);
  4554. var presto = /Opera\//.test(userAgent);
  4555. var safari = /Apple Computer/.test(navigator.vendor);
  4556. var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
  4557. var phantom = /PhantomJS/.test(userAgent);
  4558. var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent);
  4559. var android = /Android/.test(userAgent);
  4560. // This is woefully incomplete. Suggestions for alternative methods welcome.
  4561. var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
  4562. var mac = ios || /Mac/.test(platform);
  4563. var chromeOS = /\bCrOS\b/.test(userAgent);
  4564. var windows = /win/i.test(platform);
  4565. var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/);
  4566. if (presto_version) { presto_version = Number(presto_version[1]); }
  4567. if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
  4568. // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
  4569. var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
  4570. var captureRightClick = gecko || (ie && ie_version >= 9);
  4571. function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*") }
  4572. var rmClass = function(node, cls) {
  4573. var current = node.className;
  4574. var match = classTest(cls).exec(current);
  4575. if (match) {
  4576. var after = current.slice(match.index + match[0].length);
  4577. node.className = current.slice(0, match.index) + (after ? match[1] + after : "");
  4578. }
  4579. };
  4580. function removeChildren(e) {
  4581. for (var count = e.childNodes.length; count > 0; --count)
  4582. { e.removeChild(e.firstChild); }
  4583. return e
  4584. }
  4585. function removeChildrenAndAdd(parent, e) {
  4586. return removeChildren(parent).appendChild(e)
  4587. }
  4588. function elt(tag, content, className, style) {
  4589. var e = document.createElement(tag);
  4590. if (className) { e.className = className; }
  4591. if (style) { e.style.cssText = style; }
  4592. if (typeof content == "string") { e.appendChild(document.createTextNode(content)); }
  4593. else if (content) { for (var i = 0; i < content.length; ++i) { e.appendChild(content[i]); } }
  4594. return e
  4595. }
  4596. // wrapper for elt, which removes the elt from the accessibility tree
  4597. function eltP(tag, content, className, style) {
  4598. var e = elt(tag, content, className, style);
  4599. e.setAttribute("role", "presentation");
  4600. return e
  4601. }
  4602. var range;
  4603. if (document.createRange) { range = function(node, start, end, endNode) {
  4604. var r = document.createRange();
  4605. r.setEnd(endNode || node, end);
  4606. r.setStart(node, start);
  4607. return r
  4608. }; }
  4609. else { range = function(node, start, end) {
  4610. var r = document.body.createTextRange();
  4611. try { r.moveToElementText(node.parentNode); }
  4612. catch(e) { return r }
  4613. r.collapse(true);
  4614. r.moveEnd("character", end);
  4615. r.moveStart("character", start);
  4616. return r
  4617. }; }
  4618. function contains(parent, child) {
  4619. if (child.nodeType == 3) // Android browser always returns false when child is a textnode
  4620. { child = child.parentNode; }
  4621. if (parent.contains)
  4622. { return parent.contains(child) }
  4623. do {
  4624. if (child.nodeType == 11) { child = child.host; }
  4625. if (child == parent) { return true }
  4626. } while (child = child.parentNode)
  4627. }
  4628. function activeElt() {
  4629. // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
  4630. // IE < 10 will throw when accessed while the page is loading or in an iframe.
  4631. // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
  4632. var activeElement;
  4633. try {
  4634. activeElement = document.activeElement;
  4635. } catch(e) {
  4636. activeElement = document.body || null;
  4637. }
  4638. while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement)
  4639. { activeElement = activeElement.shadowRoot.activeElement; }
  4640. return activeElement
  4641. }
  4642. function addClass(node, cls) {
  4643. var current = node.className;
  4644. if (!classTest(cls).test(current)) { node.className += (current ? " " : "") + cls; }
  4645. }
  4646. function joinClasses(a, b) {
  4647. var as = a.split(" ");
  4648. for (var i = 0; i < as.length; i++)
  4649. { if (as[i] && !classTest(as[i]).test(b)) { b += " " + as[i]; } }
  4650. return b
  4651. }
  4652. var selectInput = function(node) { node.select(); };
  4653. if (ios) // Mobile Safari apparently has a bug where select() is broken.
  4654. { selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; }; }
  4655. else if (ie) // Suppress mysterious IE10 errors
  4656. { selectInput = function(node) { try { node.select(); } catch(_e) {} }; }
  4657. function bind(f) {
  4658. var args = Array.prototype.slice.call(arguments, 1);
  4659. return function(){return f.apply(null, args)}
  4660. }
  4661. function copyObj(obj, target, overwrite) {
  4662. if (!target) { target = {}; }
  4663. for (var prop in obj)
  4664. { if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
  4665. { target[prop] = obj[prop]; } }
  4666. return target
  4667. }
  4668. // Counts the column offset in a string, taking tabs into account.
  4669. // Used mostly to find indentation.
  4670. function countColumn(string, end, tabSize, startIndex, startValue) {
  4671. if (end == null) {
  4672. end = string.search(/[^\s\u00a0]/);
  4673. if (end == -1) { end = string.length; }
  4674. }
  4675. for (var i = startIndex || 0, n = startValue || 0;;) {
  4676. var nextTab = string.indexOf("\t", i);
  4677. if (nextTab < 0 || nextTab >= end)
  4678. { return n + (end - i) }
  4679. n += nextTab - i;
  4680. n += tabSize - (n % tabSize);
  4681. i = nextTab + 1;
  4682. }
  4683. }
  4684. var Delayed = function() {
  4685. this.id = null;
  4686. this.f = null;
  4687. this.time = 0;
  4688. this.handler = bind(this.onTimeout, this);
  4689. };
  4690. Delayed.prototype.onTimeout = function (self) {
  4691. self.id = 0;
  4692. if (self.time <= +new Date) {
  4693. self.f();
  4694. } else {
  4695. setTimeout(self.handler, self.time - +new Date);
  4696. }
  4697. };
  4698. Delayed.prototype.set = function (ms, f) {
  4699. this.f = f;
  4700. var time = +new Date + ms;
  4701. if (!this.id || time < this.time) {
  4702. clearTimeout(this.id);
  4703. this.id = setTimeout(this.handler, ms);
  4704. this.time = time;
  4705. }
  4706. };
  4707. function indexOf(array, elt) {
  4708. for (var i = 0; i < array.length; ++i)
  4709. { if (array[i] == elt) { return i } }
  4710. return -1
  4711. }
  4712. // Number of pixels added to scroller and sizer to hide scrollbar
  4713. var scrollerGap = 50;
  4714. // Returned or thrown by various protocols to signal 'I'm not
  4715. // handling this'.
  4716. var Pass = {toString: function(){return "CodeMirror.Pass"}};
  4717. // Reused option objects for setSelection & friends
  4718. var sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"};
  4719. // The inverse of countColumn -- find the offset that corresponds to
  4720. // a particular column.
  4721. function findColumn(string, goal, tabSize) {
  4722. for (var pos = 0, col = 0;;) {
  4723. var nextTab = string.indexOf("\t", pos);
  4724. if (nextTab == -1) { nextTab = string.length; }
  4725. var skipped = nextTab - pos;
  4726. if (nextTab == string.length || col + skipped >= goal)
  4727. { return pos + Math.min(skipped, goal - col) }
  4728. col += nextTab - pos;
  4729. col += tabSize - (col % tabSize);
  4730. pos = nextTab + 1;
  4731. if (col >= goal) { return pos }
  4732. }
  4733. }
  4734. var spaceStrs = [""];
  4735. function spaceStr(n) {
  4736. while (spaceStrs.length <= n)
  4737. { spaceStrs.push(lst(spaceStrs) + " "); }
  4738. return spaceStrs[n]
  4739. }
  4740. function lst(arr) { return arr[arr.length-1] }
  4741. function map(array, f) {
  4742. var out = [];
  4743. for (var i = 0; i < array.length; i++) { out[i] = f(array[i], i); }
  4744. return out
  4745. }
  4746. function insertSorted(array, value, score) {
  4747. var pos = 0, priority = score(value);
  4748. while (pos < array.length && score(array[pos]) <= priority) { pos++; }
  4749. array.splice(pos, 0, value);
  4750. }
  4751. function nothing() {}
  4752. function createObj(base, props) {
  4753. var inst;
  4754. if (Object.create) {
  4755. inst = Object.create(base);
  4756. } else {
  4757. nothing.prototype = base;
  4758. inst = new nothing();
  4759. }
  4760. if (props) { copyObj(props, inst); }
  4761. return inst
  4762. }
  4763. var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
  4764. function isWordCharBasic(ch) {
  4765. return /\w/.test(ch) || ch > "\x80" &&
  4766. (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch))
  4767. }
  4768. function isWordChar(ch, helper) {
  4769. if (!helper) { return isWordCharBasic(ch) }
  4770. if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) { return true }
  4771. return helper.test(ch)
  4772. }
  4773. function isEmpty(obj) {
  4774. for (var n in obj) { if (obj.hasOwnProperty(n) && obj[n]) { return false } }
  4775. return true
  4776. }
  4777. // Extending unicode characters. A series of a non-extending char +
  4778. // any number of extending chars is treated as a single unit as far
  4779. // as editing and measuring is concerned. This is not fully correct,
  4780. // since some scripts/fonts/browsers also treat other configurations
  4781. // of code points as a group.
  4782. var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;
  4783. function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch) }
  4784. // Returns a number from the range [`0`; `str.length`] unless `pos` is outside that range.
  4785. function skipExtendingChars(str, pos, dir) {
  4786. while ((dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos))) { pos += dir; }
  4787. return pos
  4788. }
  4789. // Returns the value from the range [`from`; `to`] that satisfies
  4790. // `pred` and is closest to `from`. Assumes that at least `to`
  4791. // satisfies `pred`. Supports `from` being greater than `to`.
  4792. function findFirst(pred, from, to) {
  4793. // At any point we are certain `to` satisfies `pred`, don't know
  4794. // whether `from` does.
  4795. var dir = from > to ? -1 : 1;
  4796. for (;;) {
  4797. if (from == to) { return from }
  4798. var midF = (from + to) / 2, mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF);
  4799. if (mid == from) { return pred(mid) ? from : to }
  4800. if (pred(mid)) { to = mid; }
  4801. else { from = mid + dir; }
  4802. }
  4803. }
  4804. // BIDI HELPERS
  4805. function iterateBidiSections(order, from, to, f) {
  4806. if (!order) { return f(from, to, "ltr", 0) }
  4807. var found = false;
  4808. for (var i = 0; i < order.length; ++i) {
  4809. var part = order[i];
  4810. if (part.from < to && part.to > from || from == to && part.to == from) {
  4811. f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr", i);
  4812. found = true;
  4813. }
  4814. }
  4815. if (!found) { f(from, to, "ltr"); }
  4816. }
  4817. var bidiOther = null;
  4818. function getBidiPartAt(order, ch, sticky) {
  4819. var found;
  4820. bidiOther = null;
  4821. for (var i = 0; i < order.length; ++i) {
  4822. var cur = order[i];
  4823. if (cur.from < ch && cur.to > ch) { return i }
  4824. if (cur.to == ch) {
  4825. if (cur.from != cur.to && sticky == "before") { found = i; }
  4826. else { bidiOther = i; }
  4827. }
  4828. if (cur.from == ch) {
  4829. if (cur.from != cur.to && sticky != "before") { found = i; }
  4830. else { bidiOther = i; }
  4831. }
  4832. }
  4833. return found != null ? found : bidiOther
  4834. }
  4835. // Bidirectional ordering algorithm
  4836. // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm
  4837. // that this (partially) implements.
  4838. // One-char codes used for character types:
  4839. // L (L): Left-to-Right
  4840. // R (R): Right-to-Left
  4841. // r (AL): Right-to-Left Arabic
  4842. // 1 (EN): European Number
  4843. // + (ES): European Number Separator
  4844. // % (ET): European Number Terminator
  4845. // n (AN): Arabic Number
  4846. // , (CS): Common Number Separator
  4847. // m (NSM): Non-Spacing Mark
  4848. // b (BN): Boundary Neutral
  4849. // s (B): Paragraph Separator
  4850. // t (S): Segment Separator
  4851. // w (WS): Whitespace
  4852. // N (ON): Other Neutrals
  4853. // Returns null if characters are ordered as they appear
  4854. // (left-to-right), or an array of sections ({from, to, level}
  4855. // objects) in the order in which they occur visually.
  4856. var bidiOrdering = (function() {
  4857. // Character types for codepoints 0 to 0xff
  4858. var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";
  4859. // Character types for codepoints 0x600 to 0x6f9
  4860. var arabicTypes = "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";
  4861. function charType(code) {
  4862. if (code <= 0xf7) { return lowTypes.charAt(code) }
  4863. else if (0x590 <= code && code <= 0x5f4) { return "R" }
  4864. else if (0x600 <= code && code <= 0x6f9) { return arabicTypes.charAt(code - 0x600) }
  4865. else if (0x6ee <= code && code <= 0x8ac) { return "r" }
  4866. else if (0x2000 <= code && code <= 0x200b) { return "w" }
  4867. else if (code == 0x200c) { return "b" }
  4868. else { return "L" }
  4869. }
  4870. var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
  4871. var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;
  4872. function BidiSpan(level, from, to) {
  4873. this.level = level;
  4874. this.from = from; this.to = to;
  4875. }
  4876. return function(str, direction) {
  4877. var outerType = direction == "ltr" ? "L" : "R";
  4878. if (str.length == 0 || direction == "ltr" && !bidiRE.test(str)) { return false }
  4879. var len = str.length, types = [];
  4880. for (var i = 0; i < len; ++i)
  4881. { types.push(charType(str.charCodeAt(i))); }
  4882. // W1. Examine each non-spacing mark (NSM) in the level run, and
  4883. // change the type of the NSM to the type of the previous
  4884. // character. If the NSM is at the start of the level run, it will
  4885. // get the type of sor.
  4886. for (var i$1 = 0, prev = outerType; i$1 < len; ++i$1) {
  4887. var type = types[i$1];
  4888. if (type == "m") { types[i$1] = prev; }
  4889. else { prev = type; }
  4890. }
  4891. // W2. Search backwards from each instance of a European number
  4892. // until the first strong type (R, L, AL, or sor) is found. If an
  4893. // AL is found, change the type of the European number to Arabic
  4894. // number.
  4895. // W3. Change all ALs to R.
  4896. for (var i$2 = 0, cur = outerType; i$2 < len; ++i$2) {
  4897. var type$1 = types[i$2];
  4898. if (type$1 == "1" && cur == "r") { types[i$2] = "n"; }
  4899. else if (isStrong.test(type$1)) { cur = type$1; if (type$1 == "r") { types[i$2] = "R"; } }
  4900. }
  4901. // W4. A single European separator between two European numbers
  4902. // changes to a European number. A single common separator between
  4903. // two numbers of the same type changes to that type.
  4904. for (var i$3 = 1, prev$1 = types[0]; i$3 < len - 1; ++i$3) {
  4905. var type$2 = types[i$3];
  4906. if (type$2 == "+" && prev$1 == "1" && types[i$3+1] == "1") { types[i$3] = "1"; }
  4907. else if (type$2 == "," && prev$1 == types[i$3+1] &&
  4908. (prev$1 == "1" || prev$1 == "n")) { types[i$3] = prev$1; }
  4909. prev$1 = type$2;
  4910. }
  4911. // W5. A sequence of European terminators adjacent to European
  4912. // numbers changes to all European numbers.
  4913. // W6. Otherwise, separators and terminators change to Other
  4914. // Neutral.
  4915. for (var i$4 = 0; i$4 < len; ++i$4) {
  4916. var type$3 = types[i$4];
  4917. if (type$3 == ",") { types[i$4] = "N"; }
  4918. else if (type$3 == "%") {
  4919. var end = (void 0);
  4920. for (end = i$4 + 1; end < len && types[end] == "%"; ++end) {}
  4921. var replace = (i$4 && types[i$4-1] == "!") || (end < len && types[end] == "1") ? "1" : "N";
  4922. for (var j = i$4; j < end; ++j) { types[j] = replace; }
  4923. i$4 = end - 1;
  4924. }
  4925. }
  4926. // W7. Search backwards from each instance of a European number
  4927. // until the first strong type (R, L, or sor) is found. If an L is
  4928. // found, then change the type of the European number to L.
  4929. for (var i$5 = 0, cur$1 = outerType; i$5 < len; ++i$5) {
  4930. var type$4 = types[i$5];
  4931. if (cur$1 == "L" && type$4 == "1") { types[i$5] = "L"; }
  4932. else if (isStrong.test(type$4)) { cur$1 = type$4; }
  4933. }
  4934. // N1. A sequence of neutrals takes the direction of the
  4935. // surrounding strong text if the text on both sides has the same
  4936. // direction. European and Arabic numbers act as if they were R in
  4937. // terms of their influence on neutrals. Start-of-level-run (sor)
  4938. // and end-of-level-run (eor) are used at level run boundaries.
  4939. // N2. Any remaining neutrals take the embedding direction.
  4940. for (var i$6 = 0; i$6 < len; ++i$6) {
  4941. if (isNeutral.test(types[i$6])) {
  4942. var end$1 = (void 0);
  4943. for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1) {}
  4944. var before = (i$6 ? types[i$6-1] : outerType) == "L";
  4945. var after = (end$1 < len ? types[end$1] : outerType) == "L";
  4946. var replace$1 = before == after ? (before ? "L" : "R") : outerType;
  4947. for (var j$1 = i$6; j$1 < end$1; ++j$1) { types[j$1] = replace$1; }
  4948. i$6 = end$1 - 1;
  4949. }
  4950. }
  4951. // Here we depart from the documented algorithm, in order to avoid
  4952. // building up an actual levels array. Since there are only three
  4953. // levels (0, 1, 2) in an implementation that doesn't take
  4954. // explicit embedding into account, we can build up the order on
  4955. // the fly, without following the level-based algorithm.
  4956. var order = [], m;
  4957. for (var i$7 = 0; i$7 < len;) {
  4958. if (countsAsLeft.test(types[i$7])) {
  4959. var start = i$7;
  4960. for (++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7) {}
  4961. order.push(new BidiSpan(0, start, i$7));
  4962. } else {
  4963. var pos = i$7, at = order.length, isRTL = direction == "rtl" ? 1 : 0;
  4964. for (++i$7; i$7 < len && types[i$7] != "L"; ++i$7) {}
  4965. for (var j$2 = pos; j$2 < i$7;) {
  4966. if (countsAsNum.test(types[j$2])) {
  4967. if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)); at += isRTL; }
  4968. var nstart = j$2;
  4969. for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2) {}
  4970. order.splice(at, 0, new BidiSpan(2, nstart, j$2));
  4971. at += isRTL;
  4972. pos = j$2;
  4973. } else { ++j$2; }
  4974. }
  4975. if (pos < i$7) { order.splice(at, 0, new BidiSpan(1, pos, i$7)); }
  4976. }
  4977. }
  4978. if (direction == "ltr") {
  4979. if (order[0].level == 1 && (m = str.match(/^\s+/))) {
  4980. order[0].from = m[0].length;
  4981. order.unshift(new BidiSpan(0, 0, m[0].length));
  4982. }
  4983. if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
  4984. lst(order).to -= m[0].length;
  4985. order.push(new BidiSpan(0, len - m[0].length, len));
  4986. }
  4987. }
  4988. return direction == "rtl" ? order.reverse() : order
  4989. }
  4990. })();
  4991. // Get the bidi ordering for the given line (and cache it). Returns
  4992. // false for lines that are fully left-to-right, and an array of
  4993. // BidiSpan objects otherwise.
  4994. function getOrder(line, direction) {
  4995. var order = line.order;
  4996. if (order == null) { order = line.order = bidiOrdering(line.text, direction); }
  4997. return order
  4998. }
  4999. // EVENT HANDLING
  5000. // Lightweight event framework. on/off also work on DOM nodes,
  5001. // registering native DOM handlers.
  5002. var noHandlers = [];
  5003. var on = function(emitter, type, f) {
  5004. if (emitter.addEventListener) {
  5005. emitter.addEventListener(type, f, false);
  5006. } else if (emitter.attachEvent) {
  5007. emitter.attachEvent("on" + type, f);
  5008. } else {
  5009. var map = emitter._handlers || (emitter._handlers = {});
  5010. map[type] = (map[type] || noHandlers).concat(f);
  5011. }
  5012. };
  5013. function getHandlers(emitter, type) {
  5014. return emitter._handlers && emitter._handlers[type] || noHandlers
  5015. }
  5016. function off(emitter, type, f) {
  5017. if (emitter.removeEventListener) {
  5018. emitter.removeEventListener(type, f, false);
  5019. } else if (emitter.detachEvent) {
  5020. emitter.detachEvent("on" + type, f);
  5021. } else {
  5022. var map = emitter._handlers, arr = map && map[type];
  5023. if (arr) {
  5024. var index = indexOf(arr, f);
  5025. if (index > -1)
  5026. { map[type] = arr.slice(0, index).concat(arr.slice(index + 1)); }
  5027. }
  5028. }
  5029. }
  5030. function signal(emitter, type /*, values...*/) {
  5031. var handlers = getHandlers(emitter, type);
  5032. if (!handlers.length) { return }
  5033. var args = Array.prototype.slice.call(arguments, 2);
  5034. for (var i = 0; i < handlers.length; ++i) { handlers[i].apply(null, args); }
  5035. }
  5036. // The DOM events that CodeMirror handles can be overridden by
  5037. // registering a (non-DOM) handler on the editor for the event name,
  5038. // and preventDefault-ing the event in that handler.
  5039. function signalDOMEvent(cm, e, override) {
  5040. if (typeof e == "string")
  5041. { e = {type: e, preventDefault: function() { this.defaultPrevented = true; }}; }
  5042. signal(cm, override || e.type, cm, e);
  5043. return e_defaultPrevented(e) || e.codemirrorIgnore
  5044. }
  5045. function signalCursorActivity(cm) {
  5046. var arr = cm._handlers && cm._handlers.cursorActivity;
  5047. if (!arr) { return }
  5048. var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);
  5049. for (var i = 0; i < arr.length; ++i) { if (indexOf(set, arr[i]) == -1)
  5050. { set.push(arr[i]); } }
  5051. }
  5052. function hasHandler(emitter, type) {
  5053. return getHandlers(emitter, type).length > 0
  5054. }
  5055. // Add on and off methods to a constructor's prototype, to make
  5056. // registering events on such objects more convenient.
  5057. function eventMixin(ctor) {
  5058. ctor.prototype.on = function(type, f) {on(this, type, f);};
  5059. ctor.prototype.off = function(type, f) {off(this, type, f);};
  5060. }
  5061. // Due to the fact that we still support jurassic IE versions, some
  5062. // compatibility wrappers are needed.
  5063. function e_preventDefault(e) {
  5064. if (e.preventDefault) { e.preventDefault(); }
  5065. else { e.returnValue = false; }
  5066. }
  5067. function e_stopPropagation(e) {
  5068. if (e.stopPropagation) { e.stopPropagation(); }
  5069. else { e.cancelBubble = true; }
  5070. }
  5071. function e_defaultPrevented(e) {
  5072. return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false
  5073. }
  5074. function e_stop(e) {e_preventDefault(e); e_stopPropagation(e);}
  5075. function e_target(e) {return e.target || e.srcElement}
  5076. function e_button(e) {
  5077. var b = e.which;
  5078. if (b == null) {
  5079. if (e.button & 1) { b = 1; }
  5080. else if (e.button & 2) { b = 3; }
  5081. else if (e.button & 4) { b = 2; }
  5082. }
  5083. if (mac && e.ctrlKey && b == 1) { b = 3; }
  5084. return b
  5085. }
  5086. // Detect drag-and-drop
  5087. var dragAndDrop = function() {
  5088. // There is *some* kind of drag-and-drop support in IE6-8, but I
  5089. // couldn't get it to work yet.
  5090. if (ie && ie_version < 9) { return false }
  5091. var div = elt('div');
  5092. return "draggable" in div || "dragDrop" in div
  5093. }();
  5094. var zwspSupported;
  5095. function zeroWidthElement(measure) {
  5096. if (zwspSupported == null) {
  5097. var test = elt("span", "\u200b");
  5098. removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
  5099. if (measure.firstChild.offsetHeight != 0)
  5100. { zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8); }
  5101. }
  5102. var node = zwspSupported ? elt("span", "\u200b") :
  5103. elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px");
  5104. node.setAttribute("cm-text", "");
  5105. return node
  5106. }
  5107. // Feature-detect IE's crummy client rect reporting for bidi text
  5108. var badBidiRects;
  5109. function hasBadBidiRects(measure) {
  5110. if (badBidiRects != null) { return badBidiRects }
  5111. var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"));
  5112. var r0 = range(txt, 0, 1).getBoundingClientRect();
  5113. var r1 = range(txt, 1, 2).getBoundingClientRect();
  5114. removeChildren(measure);
  5115. if (!r0 || r0.left == r0.right) { return false } // Safari returns null in some cases (#2780)
  5116. return badBidiRects = (r1.right - r0.right < 3)
  5117. }
  5118. // See if "".split is the broken IE version, if so, provide an
  5119. // alternative way to split lines.
  5120. var splitLinesAuto = "\n\nb".split(/\n/).length != 3 ? function (string) {
  5121. var pos = 0, result = [], l = string.length;
  5122. while (pos <= l) {
  5123. var nl = string.indexOf("\n", pos);
  5124. if (nl == -1) { nl = string.length; }
  5125. var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl);
  5126. var rt = line.indexOf("\r");
  5127. if (rt != -1) {
  5128. result.push(line.slice(0, rt));
  5129. pos += rt + 1;
  5130. } else {
  5131. result.push(line);
  5132. pos = nl + 1;
  5133. }
  5134. }
  5135. return result
  5136. } : function (string) { return string.split(/\r\n?|\n/); };
  5137. var hasSelection = window.getSelection ? function (te) {
  5138. try { return te.selectionStart != te.selectionEnd }
  5139. catch(e) { return false }
  5140. } : function (te) {
  5141. var range;
  5142. try {range = te.ownerDocument.selection.createRange();}
  5143. catch(e) {}
  5144. if (!range || range.parentElement() != te) { return false }
  5145. return range.compareEndPoints("StartToEnd", range) != 0
  5146. };
  5147. var hasCopyEvent = (function () {
  5148. var e = elt("div");
  5149. if ("oncopy" in e) { return true }
  5150. e.setAttribute("oncopy", "return;");
  5151. return typeof e.oncopy == "function"
  5152. })();
  5153. var badZoomedRects = null;
  5154. function hasBadZoomedRects(measure) {
  5155. if (badZoomedRects != null) { return badZoomedRects }
  5156. var node = removeChildrenAndAdd(measure, elt("span", "x"));
  5157. var normal = node.getBoundingClientRect();
  5158. var fromRange = range(node, 0, 1).getBoundingClientRect();
  5159. return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1
  5160. }
  5161. // Known modes, by name and by MIME
  5162. var modes = {}, mimeModes = {};
  5163. // Extra arguments are stored as the mode's dependencies, which is
  5164. // used by (legacy) mechanisms like loadmode.js to automatically
  5165. // load a mode. (Preferred mechanism is the require/define calls.)
  5166. function defineMode(name, mode) {
  5167. if (arguments.length > 2)
  5168. { mode.dependencies = Array.prototype.slice.call(arguments, 2); }
  5169. modes[name] = mode;
  5170. }
  5171. function defineMIME(mime, spec) {
  5172. mimeModes[mime] = spec;
  5173. }
  5174. // Given a MIME type, a {name, ...options} config object, or a name
  5175. // string, return a mode config object.
  5176. function resolveMode(spec) {
  5177. if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
  5178. spec = mimeModes[spec];
  5179. } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
  5180. var found = mimeModes[spec.name];
  5181. if (typeof found == "string") { found = {name: found}; }
  5182. spec = createObj(found, spec);
  5183. spec.name = found.name;
  5184. } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
  5185. return resolveMode("application/xml")
  5186. } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) {
  5187. return resolveMode("application/json")
  5188. }
  5189. if (typeof spec == "string") { return {name: spec} }
  5190. else { return spec || {name: "null"} }
  5191. }
  5192. // Given a mode spec (anything that resolveMode accepts), find and
  5193. // initialize an actual mode object.
  5194. function getMode(options, spec) {
  5195. spec = resolveMode(spec);
  5196. var mfactory = modes[spec.name];
  5197. if (!mfactory) { return getMode(options, "text/plain") }
  5198. var modeObj = mfactory(options, spec);
  5199. if (modeExtensions.hasOwnProperty(spec.name)) {
  5200. var exts = modeExtensions[spec.name];
  5201. for (var prop in exts) {
  5202. if (!exts.hasOwnProperty(prop)) { continue }
  5203. if (modeObj.hasOwnProperty(prop)) { modeObj["_" + prop] = modeObj[prop]; }
  5204. modeObj[prop] = exts[prop];
  5205. }
  5206. }
  5207. modeObj.name = spec.name;
  5208. if (spec.helperType) { modeObj.helperType = spec.helperType; }
  5209. if (spec.modeProps) { for (var prop$1 in spec.modeProps)
  5210. { modeObj[prop$1] = spec.modeProps[prop$1]; } }
  5211. return modeObj
  5212. }
  5213. // This can be used to attach properties to mode objects from
  5214. // outside the actual mode definition.
  5215. var modeExtensions = {};
  5216. function extendMode(mode, properties) {
  5217. var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
  5218. copyObj(properties, exts);
  5219. }
  5220. function copyState(mode, state) {
  5221. if (state === true) { return state }
  5222. if (mode.copyState) { return mode.copyState(state) }
  5223. var nstate = {};
  5224. for (var n in state) {
  5225. var val = state[n];
  5226. if (val instanceof Array) { val = val.concat([]); }
  5227. nstate[n] = val;
  5228. }
  5229. return nstate
  5230. }
  5231. // Given a mode and a state (for that mode), find the inner mode and
  5232. // state at the position that the state refers to.
  5233. function innerMode(mode, state) {
  5234. var info;
  5235. while (mode.innerMode) {
  5236. info = mode.innerMode(state);
  5237. if (!info || info.mode == mode) { break }
  5238. state = info.state;
  5239. mode = info.mode;
  5240. }
  5241. return info || {mode: mode, state: state}
  5242. }
  5243. function startState(mode, a1, a2) {
  5244. return mode.startState ? mode.startState(a1, a2) : true
  5245. }
  5246. // STRING STREAM
  5247. // Fed to the mode parsers, provides helper functions to make
  5248. // parsers more succinct.
  5249. var StringStream = function(string, tabSize, lineOracle) {
  5250. this.pos = this.start = 0;
  5251. this.string = string;
  5252. this.tabSize = tabSize || 8;
  5253. this.lastColumnPos = this.lastColumnValue = 0;
  5254. this.lineStart = 0;
  5255. this.lineOracle = lineOracle;
  5256. };
  5257. StringStream.prototype.eol = function () {return this.pos >= this.string.length};
  5258. StringStream.prototype.sol = function () {return this.pos == this.lineStart};
  5259. StringStream.prototype.peek = function () {return this.string.charAt(this.pos) || undefined};
  5260. StringStream.prototype.next = function () {
  5261. if (this.pos < this.string.length)
  5262. { return this.string.charAt(this.pos++) }
  5263. };
  5264. StringStream.prototype.eat = function (match) {
  5265. var ch = this.string.charAt(this.pos);
  5266. var ok;
  5267. if (typeof match == "string") { ok = ch == match; }
  5268. else { ok = ch && (match.test ? match.test(ch) : match(ch)); }
  5269. if (ok) {++this.pos; return ch}
  5270. };
  5271. StringStream.prototype.eatWhile = function (match) {
  5272. var start = this.pos;
  5273. while (this.eat(match)){}
  5274. return this.pos > start
  5275. };
  5276. StringStream.prototype.eatSpace = function () {
  5277. var start = this.pos;
  5278. while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) { ++this.pos; }
  5279. return this.pos > start
  5280. };
  5281. StringStream.prototype.skipToEnd = function () {this.pos = this.string.length;};
  5282. StringStream.prototype.skipTo = function (ch) {
  5283. var found = this.string.indexOf(ch, this.pos);
  5284. if (found > -1) {this.pos = found; return true}
  5285. };
  5286. StringStream.prototype.backUp = function (n) {this.pos -= n;};
  5287. StringStream.prototype.column = function () {
  5288. if (this.lastColumnPos < this.start) {
  5289. this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
  5290. this.lastColumnPos = this.start;
  5291. }
  5292. return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
  5293. };
  5294. StringStream.prototype.indentation = function () {
  5295. return countColumn(this.string, null, this.tabSize) -
  5296. (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
  5297. };
  5298. StringStream.prototype.match = function (pattern, consume, caseInsensitive) {
  5299. if (typeof pattern == "string") {
  5300. var cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; };
  5301. var substr = this.string.substr(this.pos, pattern.length);
  5302. if (cased(substr) == cased(pattern)) {
  5303. if (consume !== false) { this.pos += pattern.length; }
  5304. return true
  5305. }
  5306. } else {
  5307. var match = this.string.slice(this.pos).match(pattern);
  5308. if (match && match.index > 0) { return null }
  5309. if (match && consume !== false) { this.pos += match[0].length; }
  5310. return match
  5311. }
  5312. };
  5313. StringStream.prototype.current = function (){return this.string.slice(this.start, this.pos)};
  5314. StringStream.prototype.hideFirstChars = function (n, inner) {
  5315. this.lineStart += n;
  5316. try { return inner() }
  5317. finally { this.lineStart -= n; }
  5318. };
  5319. StringStream.prototype.lookAhead = function (n) {
  5320. var oracle = this.lineOracle;
  5321. return oracle && oracle.lookAhead(n)
  5322. };
  5323. StringStream.prototype.baseToken = function () {
  5324. var oracle = this.lineOracle;
  5325. return oracle && oracle.baseToken(this.pos)
  5326. };
  5327. // Find the line object corresponding to the given line number.
  5328. function getLine(doc, n) {
  5329. n -= doc.first;
  5330. if (n < 0 || n >= doc.size) { throw new Error("There is no line " + (n + doc.first) + " in the document.") }
  5331. var chunk = doc;
  5332. while (!chunk.lines) {
  5333. for (var i = 0;; ++i) {
  5334. var child = chunk.children[i], sz = child.chunkSize();
  5335. if (n < sz) { chunk = child; break }
  5336. n -= sz;
  5337. }
  5338. }
  5339. return chunk.lines[n]
  5340. }
  5341. // Get the part of a document between two positions, as an array of
  5342. // strings.
  5343. function getBetween(doc, start, end) {
  5344. var out = [], n = start.line;
  5345. doc.iter(start.line, end.line + 1, function (line) {
  5346. var text = line.text;
  5347. if (n == end.line) { text = text.slice(0, end.ch); }
  5348. if (n == start.line) { text = text.slice(start.ch); }
  5349. out.push(text);
  5350. ++n;
  5351. });
  5352. return out
  5353. }
  5354. // Get the lines between from and to, as array of strings.
  5355. function getLines(doc, from, to) {
  5356. var out = [];
  5357. doc.iter(from, to, function (line) { out.push(line.text); }); // iter aborts when callback returns truthy value
  5358. return out
  5359. }
  5360. // Update the height of a line, propagating the height change
  5361. // upwards to parent nodes.
  5362. function updateLineHeight(line, height) {
  5363. var diff = height - line.height;
  5364. if (diff) { for (var n = line; n; n = n.parent) { n.height += diff; } }
  5365. }
  5366. // Given a line object, find its line number by walking up through
  5367. // its parent links.
  5368. function lineNo(line) {
  5369. if (line.parent == null) { return null }
  5370. var cur = line.parent, no = indexOf(cur.lines, line);
  5371. for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
  5372. for (var i = 0;; ++i) {
  5373. if (chunk.children[i] == cur) { break }
  5374. no += chunk.children[i].chunkSize();
  5375. }
  5376. }
  5377. return no + cur.first
  5378. }
  5379. // Find the line at the given vertical position, using the height
  5380. // information in the document tree.
  5381. function lineAtHeight(chunk, h) {
  5382. var n = chunk.first;
  5383. outer: do {
  5384. for (var i$1 = 0; i$1 < chunk.children.length; ++i$1) {
  5385. var child = chunk.children[i$1], ch = child.height;
  5386. if (h < ch) { chunk = child; continue outer }
  5387. h -= ch;
  5388. n += child.chunkSize();
  5389. }
  5390. return n
  5391. } while (!chunk.lines)
  5392. var i = 0;
  5393. for (; i < chunk.lines.length; ++i) {
  5394. var line = chunk.lines[i], lh = line.height;
  5395. if (h < lh) { break }
  5396. h -= lh;
  5397. }
  5398. return n + i
  5399. }
  5400. function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size}
  5401. function lineNumberFor(options, i) {
  5402. return String(options.lineNumberFormatter(i + options.firstLineNumber))
  5403. }
  5404. // A Pos instance represents a position within the text.
  5405. function Pos(line, ch, sticky) {
  5406. if ( sticky === void 0 ) sticky = null;
  5407. if (!(this instanceof Pos)) { return new Pos(line, ch, sticky) }
  5408. this.line = line;
  5409. this.ch = ch;
  5410. this.sticky = sticky;
  5411. }
  5412. // Compare two positions, return 0 if they are the same, a negative
  5413. // number when a is less, and a positive number otherwise.
  5414. function cmp(a, b) { return a.line - b.line || a.ch - b.ch }
  5415. function equalCursorPos(a, b) { return a.sticky == b.sticky && cmp(a, b) == 0 }
  5416. function copyPos(x) {return Pos(x.line, x.ch)}
  5417. function maxPos(a, b) { return cmp(a, b) < 0 ? b : a }
  5418. function minPos(a, b) { return cmp(a, b) < 0 ? a : b }
  5419. // Most of the external API clips given positions to make sure they
  5420. // actually exist within the document.
  5421. function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1))}
  5422. function clipPos(doc, pos) {
  5423. if (pos.line < doc.first) { return Pos(doc.first, 0) }
  5424. var last = doc.first + doc.size - 1;
  5425. if (pos.line > last) { return Pos(last, getLine(doc, last).text.length) }
  5426. return clipToLen(pos, getLine(doc, pos.line).text.length)
  5427. }
  5428. function clipToLen(pos, linelen) {
  5429. var ch = pos.ch;
  5430. if (ch == null || ch > linelen) { return Pos(pos.line, linelen) }
  5431. else if (ch < 0) { return Pos(pos.line, 0) }
  5432. else { return pos }
  5433. }
  5434. function clipPosArray(doc, array) {
  5435. var out = [];
  5436. for (var i = 0; i < array.length; i++) { out[i] = clipPos(doc, array[i]); }
  5437. return out
  5438. }
  5439. var SavedContext = function(state, lookAhead) {
  5440. this.state = state;
  5441. this.lookAhead = lookAhead;
  5442. };
  5443. var Context = function(doc, state, line, lookAhead) {
  5444. this.state = state;
  5445. this.doc = doc;
  5446. this.line = line;
  5447. this.maxLookAhead = lookAhead || 0;
  5448. this.baseTokens = null;
  5449. this.baseTokenPos = 1;
  5450. };
  5451. Context.prototype.lookAhead = function (n) {
  5452. var line = this.doc.getLine(this.line + n);
  5453. if (line != null && n > this.maxLookAhead) { this.maxLookAhead = n; }
  5454. return line
  5455. };
  5456. Context.prototype.baseToken = function (n) {
  5457. if (!this.baseTokens) { return null }
  5458. while (this.baseTokens[this.baseTokenPos] <= n)
  5459. { this.baseTokenPos += 2; }
  5460. var type = this.baseTokens[this.baseTokenPos + 1];
  5461. return {type: type && type.replace(/( |^)overlay .*/, ""),
  5462. size: this.baseTokens[this.baseTokenPos] - n}
  5463. };
  5464. Context.prototype.nextLine = function () {
  5465. this.line++;
  5466. if (this.maxLookAhead > 0) { this.maxLookAhead--; }
  5467. };
  5468. Context.fromSaved = function (doc, saved, line) {
  5469. if (saved instanceof SavedContext)
  5470. { return new Context(doc, copyState(doc.mode, saved.state), line, saved.lookAhead) }
  5471. else
  5472. { return new Context(doc, copyState(doc.mode, saved), line) }
  5473. };
  5474. Context.prototype.save = function (copy) {
  5475. var state = copy !== false ? copyState(this.doc.mode, this.state) : this.state;
  5476. return this.maxLookAhead > 0 ? new SavedContext(state, this.maxLookAhead) : state
  5477. };
  5478. // Compute a style array (an array starting with a mode generation
  5479. // -- for invalidation -- followed by pairs of end positions and
  5480. // style strings), which is used to highlight the tokens on the
  5481. // line.
  5482. function highlightLine(cm, line, context, forceToEnd) {
  5483. // A styles array always starts with a number identifying the
  5484. // mode/overlays that it is based on (for easy invalidation).
  5485. var st = [cm.state.modeGen], lineClasses = {};
  5486. // Compute the base array of styles
  5487. runMode(cm, line.text, cm.doc.mode, context, function (end, style) { return st.push(end, style); },
  5488. lineClasses, forceToEnd);
  5489. var state = context.state;
  5490. // Run overlays, adjust style array.
  5491. var loop = function ( o ) {
  5492. context.baseTokens = st;
  5493. var overlay = cm.state.overlays[o], i = 1, at = 0;
  5494. context.state = true;
  5495. runMode(cm, line.text, overlay.mode, context, function (end, style) {
  5496. var start = i;
  5497. // Ensure there's a token end at the current position, and that i points at it
  5498. while (at < end) {
  5499. var i_end = st[i];
  5500. if (i_end > end)
  5501. { st.splice(i, 1, end, st[i+1], i_end); }
  5502. i += 2;
  5503. at = Math.min(end, i_end);
  5504. }
  5505. if (!style) { return }
  5506. if (overlay.opaque) {
  5507. st.splice(start, i - start, end, "overlay " + style);
  5508. i = start + 2;
  5509. } else {
  5510. for (; start < i; start += 2) {
  5511. var cur = st[start+1];
  5512. st[start+1] = (cur ? cur + " " : "") + "overlay " + style;
  5513. }
  5514. }
  5515. }, lineClasses);
  5516. context.state = state;
  5517. context.baseTokens = null;
  5518. context.baseTokenPos = 1;
  5519. };
  5520. for (var o = 0; o < cm.state.overlays.length; ++o) loop( o );
  5521. return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null}
  5522. }
  5523. function getLineStyles(cm, line, updateFrontier) {
  5524. if (!line.styles || line.styles[0] != cm.state.modeGen) {
  5525. var context = getContextBefore(cm, lineNo(line));
  5526. var resetState = line.text.length > cm.options.maxHighlightLength && copyState(cm.doc.mode, context.state);
  5527. var result = highlightLine(cm, line, context);
  5528. if (resetState) { context.state = resetState; }
  5529. line.stateAfter = context.save(!resetState);
  5530. line.styles = result.styles;
  5531. if (result.classes) { line.styleClasses = result.classes; }
  5532. else if (line.styleClasses) { line.styleClasses = null; }
  5533. if (updateFrontier === cm.doc.highlightFrontier)
  5534. { cm.doc.modeFrontier = Math.max(cm.doc.modeFrontier, ++cm.doc.highlightFrontier); }
  5535. }
  5536. return line.styles
  5537. }
  5538. function getContextBefore(cm, n, precise) {
  5539. var doc = cm.doc, display = cm.display;
  5540. if (!doc.mode.startState) { return new Context(doc, true, n) }
  5541. var start = findStartLine(cm, n, precise);
  5542. var saved = start > doc.first && getLine(doc, start - 1).stateAfter;
  5543. var context = saved ? Context.fromSaved(doc, saved, start) : new Context(doc, startState(doc.mode), start);
  5544. doc.iter(start, n, function (line) {
  5545. processLine(cm, line.text, context);
  5546. var pos = context.line;
  5547. line.stateAfter = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo ? context.save() : null;
  5548. context.nextLine();
  5549. });
  5550. if (precise) { doc.modeFrontier = context.line; }
  5551. return context
  5552. }
  5553. // Lightweight form of highlight -- proceed over this line and
  5554. // update state, but don't save a style array. Used for lines that
  5555. // aren't currently visible.
  5556. function processLine(cm, text, context, startAt) {
  5557. var mode = cm.doc.mode;
  5558. var stream = new StringStream(text, cm.options.tabSize, context);
  5559. stream.start = stream.pos = startAt || 0;
  5560. if (text == "") { callBlankLine(mode, context.state); }
  5561. while (!stream.eol()) {
  5562. readToken(mode, stream, context.state);
  5563. stream.start = stream.pos;
  5564. }
  5565. }
  5566. function callBlankLine(mode, state) {
  5567. if (mode.blankLine) { return mode.blankLine(state) }
  5568. if (!mode.innerMode) { return }
  5569. var inner = innerMode(mode, state);
  5570. if (inner.mode.blankLine) { return inner.mode.blankLine(inner.state) }
  5571. }
  5572. function readToken(mode, stream, state, inner) {
  5573. for (var i = 0; i < 10; i++) {
  5574. if (inner) { inner[0] = innerMode(mode, state).mode; }
  5575. var style = mode.token(stream, state);
  5576. if (stream.pos > stream.start) { return style }
  5577. }
  5578. throw new Error("Mode " + mode.name + " failed to advance stream.")
  5579. }
  5580. var Token = function(stream, type, state) {
  5581. this.start = stream.start; this.end = stream.pos;
  5582. this.string = stream.current();
  5583. this.type = type || null;
  5584. this.state = state;
  5585. };
  5586. // Utility for getTokenAt and getLineTokens
  5587. function takeToken(cm, pos, precise, asArray) {
  5588. var doc = cm.doc, mode = doc.mode, style;
  5589. pos = clipPos(doc, pos);
  5590. var line = getLine(doc, pos.line), context = getContextBefore(cm, pos.line, precise);
  5591. var stream = new StringStream(line.text, cm.options.tabSize, context), tokens;
  5592. if (asArray) { tokens = []; }
  5593. while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
  5594. stream.start = stream.pos;
  5595. style = readToken(mode, stream, context.state);
  5596. if (asArray) { tokens.push(new Token(stream, style, copyState(doc.mode, context.state))); }
  5597. }
  5598. return asArray ? tokens : new Token(stream, style, context.state)
  5599. }
  5600. function extractLineClasses(type, output) {
  5601. if (type) { for (;;) {
  5602. var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/);
  5603. if (!lineClass) { break }
  5604. type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);
  5605. var prop = lineClass[1] ? "bgClass" : "textClass";
  5606. if (output[prop] == null)
  5607. { output[prop] = lineClass[2]; }
  5608. else if (!(new RegExp("(?:^|\\s)" + lineClass[2] + "(?:$|\\s)")).test(output[prop]))
  5609. { output[prop] += " " + lineClass[2]; }
  5610. } }
  5611. return type
  5612. }
  5613. // Run the given mode's parser over a line, calling f for each token.
  5614. function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) {
  5615. var flattenSpans = mode.flattenSpans;
  5616. if (flattenSpans == null) { flattenSpans = cm.options.flattenSpans; }
  5617. var curStart = 0, curStyle = null;
  5618. var stream = new StringStream(text, cm.options.tabSize, context), style;
  5619. var inner = cm.options.addModeClass && [null];
  5620. if (text == "") { extractLineClasses(callBlankLine(mode, context.state), lineClasses); }
  5621. while (!stream.eol()) {
  5622. if (stream.pos > cm.options.maxHighlightLength) {
  5623. flattenSpans = false;
  5624. if (forceToEnd) { processLine(cm, text, context, stream.pos); }
  5625. stream.pos = text.length;
  5626. style = null;
  5627. } else {
  5628. style = extractLineClasses(readToken(mode, stream, context.state, inner), lineClasses);
  5629. }
  5630. if (inner) {
  5631. var mName = inner[0].name;
  5632. if (mName) { style = "m-" + (style ? mName + " " + style : mName); }
  5633. }
  5634. if (!flattenSpans || curStyle != style) {
  5635. while (curStart < stream.start) {
  5636. curStart = Math.min(stream.start, curStart + 5000);
  5637. f(curStart, curStyle);
  5638. }
  5639. curStyle = style;
  5640. }
  5641. stream.start = stream.pos;
  5642. }
  5643. while (curStart < stream.pos) {
  5644. // Webkit seems to refuse to render text nodes longer than 57444
  5645. // characters, and returns inaccurate measurements in nodes
  5646. // starting around 5000 chars.
  5647. var pos = Math.min(stream.pos, curStart + 5000);
  5648. f(pos, curStyle);
  5649. curStart = pos;
  5650. }
  5651. }
  5652. // Finds the line to start with when starting a parse. Tries to
  5653. // find a line with a stateAfter, so that it can start with a
  5654. // valid state. If that fails, it returns the line with the
  5655. // smallest indentation, which tends to need the least context to
  5656. // parse correctly.
  5657. function findStartLine(cm, n, precise) {
  5658. var minindent, minline, doc = cm.doc;
  5659. var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
  5660. for (var search = n; search > lim; --search) {
  5661. if (search <= doc.first) { return doc.first }
  5662. var line = getLine(doc, search - 1), after = line.stateAfter;
  5663. if (after && (!precise || search + (after instanceof SavedContext ? after.lookAhead : 0) <= doc.modeFrontier))
  5664. { return search }
  5665. var indented = countColumn(line.text, null, cm.options.tabSize);
  5666. if (minline == null || minindent > indented) {
  5667. minline = search - 1;
  5668. minindent = indented;
  5669. }
  5670. }
  5671. return minline
  5672. }
  5673. function retreatFrontier(doc, n) {
  5674. doc.modeFrontier = Math.min(doc.modeFrontier, n);
  5675. if (doc.highlightFrontier < n - 10) { return }
  5676. var start = doc.first;
  5677. for (var line = n - 1; line > start; line--) {
  5678. var saved = getLine(doc, line).stateAfter;
  5679. // change is on 3
  5680. // state on line 1 looked ahead 2 -- so saw 3
  5681. // test 1 + 2 < 3 should cover this
  5682. if (saved && (!(saved instanceof SavedContext) || line + saved.lookAhead < n)) {
  5683. start = line + 1;
  5684. break
  5685. }
  5686. }
  5687. doc.highlightFrontier = Math.min(doc.highlightFrontier, start);
  5688. }
  5689. // Optimize some code when these features are not used.
  5690. var sawReadOnlySpans = false, sawCollapsedSpans = false;
  5691. function seeReadOnlySpans() {
  5692. sawReadOnlySpans = true;
  5693. }
  5694. function seeCollapsedSpans() {
  5695. sawCollapsedSpans = true;
  5696. }
  5697. // TEXTMARKER SPANS
  5698. function MarkedSpan(marker, from, to) {
  5699. this.marker = marker;
  5700. this.from = from; this.to = to;
  5701. }
  5702. // Search an array of spans for a span matching the given marker.
  5703. function getMarkedSpanFor(spans, marker) {
  5704. if (spans) { for (var i = 0; i < spans.length; ++i) {
  5705. var span = spans[i];
  5706. if (span.marker == marker) { return span }
  5707. } }
  5708. }
  5709. // Remove a span from an array, returning undefined if no spans are
  5710. // left (we don't store arrays for lines without spans).
  5711. function removeMarkedSpan(spans, span) {
  5712. var r;
  5713. for (var i = 0; i < spans.length; ++i)
  5714. { if (spans[i] != span) { (r || (r = [])).push(spans[i]); } }
  5715. return r
  5716. }
  5717. // Add a span to a line.
  5718. function addMarkedSpan(line, span) {
  5719. line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
  5720. span.marker.attachLine(line);
  5721. }
  5722. // Used for the algorithm that adjusts markers for a change in the
  5723. // document. These functions cut an array of spans at a given
  5724. // character position, returning an array of remaining chunks (or
  5725. // undefined if nothing remains).
  5726. function markedSpansBefore(old, startCh, isInsert) {
  5727. var nw;
  5728. if (old) { for (var i = 0; i < old.length; ++i) {
  5729. var span = old[i], marker = span.marker;
  5730. var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
  5731. if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
  5732. var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh)
  5733. ;(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to));
  5734. }
  5735. } }
  5736. return nw
  5737. }
  5738. function markedSpansAfter(old, endCh, isInsert) {
  5739. var nw;
  5740. if (old) { for (var i = 0; i < old.length; ++i) {
  5741. var span = old[i], marker = span.marker;
  5742. var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
  5743. if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
  5744. var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh)
  5745. ;(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,
  5746. span.to == null ? null : span.to - endCh));
  5747. }
  5748. } }
  5749. return nw
  5750. }
  5751. // Given a change object, compute the new set of marker spans that
  5752. // cover the line in which the change took place. Removes spans
  5753. // entirely within the change, reconnects spans belonging to the
  5754. // same marker that appear on both sides of the change, and cuts off
  5755. // spans partially within the change. Returns an array of span
  5756. // arrays with one element for each line in (after) the change.
  5757. function stretchSpansOverChange(doc, change) {
  5758. if (change.full) { return null }
  5759. var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans;
  5760. var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans;
  5761. if (!oldFirst && !oldLast) { return null }
  5762. var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0;
  5763. // Get the spans that 'stick out' on both sides
  5764. var first = markedSpansBefore(oldFirst, startCh, isInsert);
  5765. var last = markedSpansAfter(oldLast, endCh, isInsert);
  5766. // Next, merge those two ends
  5767. var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0);
  5768. if (first) {
  5769. // Fix up .to properties of first
  5770. for (var i = 0; i < first.length; ++i) {
  5771. var span = first[i];
  5772. if (span.to == null) {
  5773. var found = getMarkedSpanFor(last, span.marker);
  5774. if (!found) { span.to = startCh; }
  5775. else if (sameLine) { span.to = found.to == null ? null : found.to + offset; }
  5776. }
  5777. }
  5778. }
  5779. if (last) {
  5780. // Fix up .from in last (or move them into first in case of sameLine)
  5781. for (var i$1 = 0; i$1 < last.length; ++i$1) {
  5782. var span$1 = last[i$1];
  5783. if (span$1.to != null) { span$1.to += offset; }
  5784. if (span$1.from == null) {
  5785. var found$1 = getMarkedSpanFor(first, span$1.marker);
  5786. if (!found$1) {
  5787. span$1.from = offset;
  5788. if (sameLine) { (first || (first = [])).push(span$1); }
  5789. }
  5790. } else {
  5791. span$1.from += offset;
  5792. if (sameLine) { (first || (first = [])).push(span$1); }
  5793. }
  5794. }
  5795. }
  5796. // Make sure we didn't create any zero-length spans
  5797. if (first) { first = clearEmptySpans(first); }
  5798. if (last && last != first) { last = clearEmptySpans(last); }
  5799. var newMarkers = [first];
  5800. if (!sameLine) {
  5801. // Fill gap with whole-line-spans
  5802. var gap = change.text.length - 2, gapMarkers;
  5803. if (gap > 0 && first)
  5804. { for (var i$2 = 0; i$2 < first.length; ++i$2)
  5805. { if (first[i$2].to == null)
  5806. { (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i$2].marker, null, null)); } } }
  5807. for (var i$3 = 0; i$3 < gap; ++i$3)
  5808. { newMarkers.push(gapMarkers); }
  5809. newMarkers.push(last);
  5810. }
  5811. return newMarkers
  5812. }
  5813. // Remove spans that are empty and don't have a clearWhenEmpty
  5814. // option of false.
  5815. function clearEmptySpans(spans) {
  5816. for (var i = 0; i < spans.length; ++i) {
  5817. var span = spans[i];
  5818. if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
  5819. { spans.splice(i--, 1); }
  5820. }
  5821. if (!spans.length) { return null }
  5822. return spans
  5823. }
  5824. // Used to 'clip' out readOnly ranges when making a change.
  5825. function removeReadOnlyRanges(doc, from, to) {
  5826. var markers = null;
  5827. doc.iter(from.line, to.line + 1, function (line) {
  5828. if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {
  5829. var mark = line.markedSpans[i].marker;
  5830. if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
  5831. { (markers || (markers = [])).push(mark); }
  5832. } }
  5833. });
  5834. if (!markers) { return null }
  5835. var parts = [{from: from, to: to}];
  5836. for (var i = 0; i < markers.length; ++i) {
  5837. var mk = markers[i], m = mk.find(0);
  5838. for (var j = 0; j < parts.length; ++j) {
  5839. var p = parts[j];
  5840. if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) { continue }
  5841. var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
  5842. if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
  5843. { newParts.push({from: p.from, to: m.from}); }
  5844. if (dto > 0 || !mk.inclusiveRight && !dto)
  5845. { newParts.push({from: m.to, to: p.to}); }
  5846. parts.splice.apply(parts, newParts);
  5847. j += newParts.length - 3;
  5848. }
  5849. }
  5850. return parts
  5851. }
  5852. // Connect or disconnect spans from a line.
  5853. function detachMarkedSpans(line) {
  5854. var spans = line.markedSpans;
  5855. if (!spans) { return }
  5856. for (var i = 0; i < spans.length; ++i)
  5857. { spans[i].marker.detachLine(line); }
  5858. line.markedSpans = null;
  5859. }
  5860. function attachMarkedSpans(line, spans) {
  5861. if (!spans) { return }
  5862. for (var i = 0; i < spans.length; ++i)
  5863. { spans[i].marker.attachLine(line); }
  5864. line.markedSpans = spans;
  5865. }
  5866. // Helpers used when computing which overlapping collapsed span
  5867. // counts as the larger one.
  5868. function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0 }
  5869. function extraRight(marker) { return marker.inclusiveRight ? 1 : 0 }
  5870. // Returns a number indicating which of two overlapping collapsed
  5871. // spans is larger (and thus includes the other). Falls back to
  5872. // comparing ids when the spans cover exactly the same range.
  5873. function compareCollapsedMarkers(a, b) {
  5874. var lenDiff = a.lines.length - b.lines.length;
  5875. if (lenDiff != 0) { return lenDiff }
  5876. var aPos = a.find(), bPos = b.find();
  5877. var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);
  5878. if (fromCmp) { return -fromCmp }
  5879. var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);
  5880. if (toCmp) { return toCmp }
  5881. return b.id - a.id
  5882. }
  5883. // Find out whether a line ends or starts in a collapsed span. If
  5884. // so, return the marker for that span.
  5885. function collapsedSpanAtSide(line, start) {
  5886. var sps = sawCollapsedSpans && line.markedSpans, found;
  5887. if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {
  5888. sp = sps[i];
  5889. if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
  5890. (!found || compareCollapsedMarkers(found, sp.marker) < 0))
  5891. { found = sp.marker; }
  5892. } }
  5893. return found
  5894. }
  5895. function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true) }
  5896. function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false) }
  5897. function collapsedSpanAround(line, ch) {
  5898. var sps = sawCollapsedSpans && line.markedSpans, found;
  5899. if (sps) { for (var i = 0; i < sps.length; ++i) {
  5900. var sp = sps[i];
  5901. if (sp.marker.collapsed && (sp.from == null || sp.from < ch) && (sp.to == null || sp.to > ch) &&
  5902. (!found || compareCollapsedMarkers(found, sp.marker) < 0)) { found = sp.marker; }
  5903. } }
  5904. return found
  5905. }
  5906. // Test whether there exists a collapsed span that partially
  5907. // overlaps (covers the start or end, but not both) of a new span.
  5908. // Such overlap is not allowed.
  5909. function conflictingCollapsedRange(doc, lineNo, from, to, marker) {
  5910. var line = getLine(doc, lineNo);
  5911. var sps = sawCollapsedSpans && line.markedSpans;
  5912. if (sps) { for (var i = 0; i < sps.length; ++i) {
  5913. var sp = sps[i];
  5914. if (!sp.marker.collapsed) { continue }
  5915. var found = sp.marker.find(0);
  5916. var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
  5917. var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
  5918. if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) { continue }
  5919. if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) ||
  5920. fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0))
  5921. { return true }
  5922. } }
  5923. }
  5924. // A visual line is a line as drawn on the screen. Folding, for
  5925. // example, can cause multiple logical lines to appear on the same
  5926. // visual line. This finds the start of the visual line that the
  5927. // given line is part of (usually that is the line itself).
  5928. function visualLine(line) {
  5929. var merged;
  5930. while (merged = collapsedSpanAtStart(line))
  5931. { line = merged.find(-1, true).line; }
  5932. return line
  5933. }
  5934. function visualLineEnd(line) {
  5935. var merged;
  5936. while (merged = collapsedSpanAtEnd(line))
  5937. { line = merged.find(1, true).line; }
  5938. return line
  5939. }
  5940. // Returns an array of logical lines that continue the visual line
  5941. // started by the argument, or undefined if there are no such lines.
  5942. function visualLineContinued(line) {
  5943. var merged, lines;
  5944. while (merged = collapsedSpanAtEnd(line)) {
  5945. line = merged.find(1, true).line
  5946. ;(lines || (lines = [])).push(line);
  5947. }
  5948. return lines
  5949. }
  5950. // Get the line number of the start of the visual line that the
  5951. // given line number is part of.
  5952. function visualLineNo(doc, lineN) {
  5953. var line = getLine(doc, lineN), vis = visualLine(line);
  5954. if (line == vis) { return lineN }
  5955. return lineNo(vis)
  5956. }
  5957. // Get the line number of the start of the next visual line after
  5958. // the given line.
  5959. function visualLineEndNo(doc, lineN) {
  5960. if (lineN > doc.lastLine()) { return lineN }
  5961. var line = getLine(doc, lineN), merged;
  5962. if (!lineIsHidden(doc, line)) { return lineN }
  5963. while (merged = collapsedSpanAtEnd(line))
  5964. { line = merged.find(1, true).line; }
  5965. return lineNo(line) + 1
  5966. }
  5967. // Compute whether a line is hidden. Lines count as hidden when they
  5968. // are part of a visual line that starts with another line, or when
  5969. // they are entirely covered by collapsed, non-widget span.
  5970. function lineIsHidden(doc, line) {
  5971. var sps = sawCollapsedSpans && line.markedSpans;
  5972. if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {
  5973. sp = sps[i];
  5974. if (!sp.marker.collapsed) { continue }
  5975. if (sp.from == null) { return true }
  5976. if (sp.marker.widgetNode) { continue }
  5977. if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
  5978. { return true }
  5979. } }
  5980. }
  5981. function lineIsHiddenInner(doc, line, span) {
  5982. if (span.to == null) {
  5983. var end = span.marker.find(1, true);
  5984. return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker))
  5985. }
  5986. if (span.marker.inclusiveRight && span.to == line.text.length)
  5987. { return true }
  5988. for (var sp = (void 0), i = 0; i < line.markedSpans.length; ++i) {
  5989. sp = line.markedSpans[i];
  5990. if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
  5991. (sp.to == null || sp.to != span.from) &&
  5992. (sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
  5993. lineIsHiddenInner(doc, line, sp)) { return true }
  5994. }
  5995. }
  5996. // Find the height above the given line.
  5997. function heightAtLine(lineObj) {
  5998. lineObj = visualLine(lineObj);
  5999. var h = 0, chunk = lineObj.parent;
  6000. for (var i = 0; i < chunk.lines.length; ++i) {
  6001. var line = chunk.lines[i];
  6002. if (line == lineObj) { break }
  6003. else { h += line.height; }
  6004. }
  6005. for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
  6006. for (var i$1 = 0; i$1 < p.children.length; ++i$1) {
  6007. var cur = p.children[i$1];
  6008. if (cur == chunk) { break }
  6009. else { h += cur.height; }
  6010. }
  6011. }
  6012. return h
  6013. }
  6014. // Compute the character length of a line, taking into account
  6015. // collapsed ranges (see markText) that might hide parts, and join
  6016. // other lines onto it.
  6017. function lineLength(line) {
  6018. if (line.height == 0) { return 0 }
  6019. var len = line.text.length, merged, cur = line;
  6020. while (merged = collapsedSpanAtStart(cur)) {
  6021. var found = merged.find(0, true);
  6022. cur = found.from.line;
  6023. len += found.from.ch - found.to.ch;
  6024. }
  6025. cur = line;
  6026. while (merged = collapsedSpanAtEnd(cur)) {
  6027. var found$1 = merged.find(0, true);
  6028. len -= cur.text.length - found$1.from.ch;
  6029. cur = found$1.to.line;
  6030. len += cur.text.length - found$1.to.ch;
  6031. }
  6032. return len
  6033. }
  6034. // Find the longest line in the document.
  6035. function findMaxLine(cm) {
  6036. var d = cm.display, doc = cm.doc;
  6037. d.maxLine = getLine(doc, doc.first);
  6038. d.maxLineLength = lineLength(d.maxLine);
  6039. d.maxLineChanged = true;
  6040. doc.iter(function (line) {
  6041. var len = lineLength(line);
  6042. if (len > d.maxLineLength) {
  6043. d.maxLineLength = len;
  6044. d.maxLine = line;
  6045. }
  6046. });
  6047. }
  6048. // LINE DATA STRUCTURE
  6049. // Line objects. These hold state related to a line, including
  6050. // highlighting info (the styles array).
  6051. var Line = function(text, markedSpans, estimateHeight) {
  6052. this.text = text;
  6053. attachMarkedSpans(this, markedSpans);
  6054. this.height = estimateHeight ? estimateHeight(this) : 1;
  6055. };
  6056. Line.prototype.lineNo = function () { return lineNo(this) };
  6057. eventMixin(Line);
  6058. // Change the content (text, markers) of a line. Automatically
  6059. // invalidates cached information and tries to re-estimate the
  6060. // line's height.
  6061. function updateLine(line, text, markedSpans, estimateHeight) {
  6062. line.text = text;
  6063. if (line.stateAfter) { line.stateAfter = null; }
  6064. if (line.styles) { line.styles = null; }
  6065. if (line.order != null) { line.order = null; }
  6066. detachMarkedSpans(line);
  6067. attachMarkedSpans(line, markedSpans);
  6068. var estHeight = estimateHeight ? estimateHeight(line) : 1;
  6069. if (estHeight != line.height) { updateLineHeight(line, estHeight); }
  6070. }
  6071. // Detach a line from the document tree and its markers.
  6072. function cleanUpLine(line) {
  6073. line.parent = null;
  6074. detachMarkedSpans(line);
  6075. }
  6076. // Convert a style as returned by a mode (either null, or a string
  6077. // containing one or more styles) to a CSS style. This is cached,
  6078. // and also looks for line-wide styles.
  6079. var styleToClassCache = {}, styleToClassCacheWithMode = {};
  6080. function interpretTokenStyle(style, options) {
  6081. if (!style || /^\s*$/.test(style)) { return null }
  6082. var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
  6083. return cache[style] ||
  6084. (cache[style] = style.replace(/\S+/g, "cm-$&"))
  6085. }
  6086. // Render the DOM representation of the text of a line. Also builds
  6087. // up a 'line map', which points at the DOM nodes that represent
  6088. // specific stretches of text, and is used by the measuring code.
  6089. // The returned object contains the DOM node, this map, and
  6090. // information about line-wide styles that were set by the mode.
  6091. function buildLineContent(cm, lineView) {
  6092. // The padding-right forces the element to have a 'border', which
  6093. // is needed on Webkit to be able to get line-level bounding
  6094. // rectangles for it (in measureChar).
  6095. var content = eltP("span", null, null, webkit ? "padding-right: .1px" : null);
  6096. var builder = {pre: eltP("pre", [content], "CodeMirror-line"), content: content,
  6097. col: 0, pos: 0, cm: cm,
  6098. trailingSpace: false,
  6099. splitSpaces: cm.getOption("lineWrapping")};
  6100. lineView.measure = {};
  6101. // Iterate over the logical lines that make up this visual line.
  6102. for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
  6103. var line = i ? lineView.rest[i - 1] : lineView.line, order = (void 0);
  6104. builder.pos = 0;
  6105. builder.addToken = buildToken;
  6106. // Optionally wire in some hacks into the token-rendering
  6107. // algorithm, to deal with browser quirks.
  6108. if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line, cm.doc.direction)))
  6109. { builder.addToken = buildTokenBadBidi(builder.addToken, order); }
  6110. builder.map = [];
  6111. var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line);
  6112. insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate));
  6113. if (line.styleClasses) {
  6114. if (line.styleClasses.bgClass)
  6115. { builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || ""); }
  6116. if (line.styleClasses.textClass)
  6117. { builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || ""); }
  6118. }
  6119. // Ensure at least a single node is present, for measuring.
  6120. if (builder.map.length == 0)
  6121. { builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))); }
  6122. // Store the map and a cache object for the current logical line
  6123. if (i == 0) {
  6124. lineView.measure.map = builder.map;
  6125. lineView.measure.cache = {};
  6126. } else {
  6127. (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map)
  6128. ;(lineView.measure.caches || (lineView.measure.caches = [])).push({});
  6129. }
  6130. }
  6131. // See issue #2901
  6132. if (webkit) {
  6133. var last = builder.content.lastChild;
  6134. if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab")))
  6135. { builder.content.className = "cm-tab-wrap-hack"; }
  6136. }
  6137. signal(cm, "renderLine", cm, lineView.line, builder.pre);
  6138. if (builder.pre.className)
  6139. { builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); }
  6140. return builder
  6141. }
  6142. function defaultSpecialCharPlaceholder(ch) {
  6143. var token = elt("span", "\u2022", "cm-invalidchar");
  6144. token.title = "\\u" + ch.charCodeAt(0).toString(16);
  6145. token.setAttribute("aria-label", token.title);
  6146. return token
  6147. }
  6148. // Build up the DOM representation for a single token, and add it to
  6149. // the line map. Takes care to render special characters separately.
  6150. function buildToken(builder, text, style, startStyle, endStyle, css, attributes) {
  6151. if (!text) { return }
  6152. var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text;
  6153. var special = builder.cm.state.specialChars, mustWrap = false;
  6154. var content;
  6155. if (!special.test(text)) {
  6156. builder.col += text.length;
  6157. content = document.createTextNode(displayText);
  6158. builder.map.push(builder.pos, builder.pos + text.length, content);
  6159. if (ie && ie_version < 9) { mustWrap = true; }
  6160. builder.pos += text.length;
  6161. } else {
  6162. content = document.createDocumentFragment();
  6163. var pos = 0;
  6164. while (true) {
  6165. special.lastIndex = pos;
  6166. var m = special.exec(text);
  6167. var skipped = m ? m.index - pos : text.length - pos;
  6168. if (skipped) {
  6169. var txt = document.createTextNode(displayText.slice(pos, pos + skipped));
  6170. if (ie && ie_version < 9) { content.appendChild(elt("span", [txt])); }
  6171. else { content.appendChild(txt); }
  6172. builder.map.push(builder.pos, builder.pos + skipped, txt);
  6173. builder.col += skipped;
  6174. builder.pos += skipped;
  6175. }
  6176. if (!m) { break }
  6177. pos += skipped + 1;
  6178. var txt$1 = (void 0);
  6179. if (m[0] == "\t") {
  6180. var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
  6181. txt$1 = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
  6182. txt$1.setAttribute("role", "presentation");
  6183. txt$1.setAttribute("cm-text", "\t");
  6184. builder.col += tabWidth;
  6185. } else if (m[0] == "\r" || m[0] == "\n") {
  6186. txt$1 = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar"));
  6187. txt$1.setAttribute("cm-text", m[0]);
  6188. builder.col += 1;
  6189. } else {
  6190. txt$1 = builder.cm.options.specialCharPlaceholder(m[0]);
  6191. txt$1.setAttribute("cm-text", m[0]);
  6192. if (ie && ie_version < 9) { content.appendChild(elt("span", [txt$1])); }
  6193. else { content.appendChild(txt$1); }
  6194. builder.col += 1;
  6195. }
  6196. builder.map.push(builder.pos, builder.pos + 1, txt$1);
  6197. builder.pos++;
  6198. }
  6199. }
  6200. builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32;
  6201. if (style || startStyle || endStyle || mustWrap || css || attributes) {
  6202. var fullStyle = style || "";
  6203. if (startStyle) { fullStyle += startStyle; }
  6204. if (endStyle) { fullStyle += endStyle; }
  6205. var token = elt("span", [content], fullStyle, css);
  6206. if (attributes) {
  6207. for (var attr in attributes) { if (attributes.hasOwnProperty(attr) && attr != "style" && attr != "class")
  6208. { token.setAttribute(attr, attributes[attr]); } }
  6209. }
  6210. return builder.content.appendChild(token)
  6211. }
  6212. builder.content.appendChild(content);
  6213. }
  6214. // Change some spaces to NBSP to prevent the browser from collapsing
  6215. // trailing spaces at the end of a line when rendering text (issue #1362).
  6216. function splitSpaces(text, trailingBefore) {
  6217. if (text.length > 1 && !/ /.test(text)) { return text }
  6218. var spaceBefore = trailingBefore, result = "";
  6219. for (var i = 0; i < text.length; i++) {
  6220. var ch = text.charAt(i);
  6221. if (ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32))
  6222. { ch = "\u00a0"; }
  6223. result += ch;
  6224. spaceBefore = ch == " ";
  6225. }
  6226. return result
  6227. }
  6228. // Work around nonsense dimensions being reported for stretches of
  6229. // right-to-left text.
  6230. function buildTokenBadBidi(inner, order) {
  6231. return function (builder, text, style, startStyle, endStyle, css, attributes) {
  6232. style = style ? style + " cm-force-border" : "cm-force-border";
  6233. var start = builder.pos, end = start + text.length;
  6234. for (;;) {
  6235. // Find the part that overlaps with the start of this text
  6236. var part = (void 0);
  6237. for (var i = 0; i < order.length; i++) {
  6238. part = order[i];
  6239. if (part.to > start && part.from <= start) { break }
  6240. }
  6241. if (part.to >= end) { return inner(builder, text, style, startStyle, endStyle, css, attributes) }
  6242. inner(builder, text.slice(0, part.to - start), style, startStyle, null, css, attributes);
  6243. startStyle = null;
  6244. text = text.slice(part.to - start);
  6245. start = part.to;
  6246. }
  6247. }
  6248. }
  6249. function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
  6250. var widget = !ignoreWidget && marker.widgetNode;
  6251. if (widget) { builder.map.push(builder.pos, builder.pos + size, widget); }
  6252. if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {
  6253. if (!widget)
  6254. { widget = builder.content.appendChild(document.createElement("span")); }
  6255. widget.setAttribute("cm-marker", marker.id);
  6256. }
  6257. if (widget) {
  6258. builder.cm.display.input.setUneditable(widget);
  6259. builder.content.appendChild(widget);
  6260. }
  6261. builder.pos += size;
  6262. builder.trailingSpace = false;
  6263. }
  6264. // Outputs a number of spans to make up a line, taking highlighting
  6265. // and marked text into account.
  6266. function insertLineContent(line, builder, styles) {
  6267. var spans = line.markedSpans, allText = line.text, at = 0;
  6268. if (!spans) {
  6269. for (var i$1 = 1; i$1 < styles.length; i$1+=2)
  6270. { builder.addToken(builder, allText.slice(at, at = styles[i$1]), interpretTokenStyle(styles[i$1+1], builder.cm.options)); }
  6271. return
  6272. }
  6273. var len = allText.length, pos = 0, i = 1, text = "", style, css;
  6274. var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, collapsed, attributes;
  6275. for (;;) {
  6276. if (nextChange == pos) { // Update current marker set
  6277. spanStyle = spanEndStyle = spanStartStyle = css = "";
  6278. attributes = null;
  6279. collapsed = null; nextChange = Infinity;
  6280. var foundBookmarks = [], endStyles = (void 0);
  6281. for (var j = 0; j < spans.length; ++j) {
  6282. var sp = spans[j], m = sp.marker;
  6283. if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
  6284. foundBookmarks.push(m);
  6285. } else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) {
  6286. if (sp.to != null && sp.to != pos && nextChange > sp.to) {
  6287. nextChange = sp.to;
  6288. spanEndStyle = "";
  6289. }
  6290. if (m.className) { spanStyle += " " + m.className; }
  6291. if (m.css) { css = (css ? css + ";" : "") + m.css; }
  6292. if (m.startStyle && sp.from == pos) { spanStartStyle += " " + m.startStyle; }
  6293. if (m.endStyle && sp.to == nextChange) { (endStyles || (endStyles = [])).push(m.endStyle, sp.to); }
  6294. // support for the old title property
  6295. // https://github.com/codemirror/CodeMirror/pull/5673
  6296. if (m.title) { (attributes || (attributes = {})).title = m.title; }
  6297. if (m.attributes) {
  6298. for (var attr in m.attributes)
  6299. { (attributes || (attributes = {}))[attr] = m.attributes[attr]; }
  6300. }
  6301. if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
  6302. { collapsed = sp; }
  6303. } else if (sp.from > pos && nextChange > sp.from) {
  6304. nextChange = sp.from;
  6305. }
  6306. }
  6307. if (endStyles) { for (var j$1 = 0; j$1 < endStyles.length; j$1 += 2)
  6308. { if (endStyles[j$1 + 1] == nextChange) { spanEndStyle += " " + endStyles[j$1]; } } }
  6309. if (!collapsed || collapsed.from == pos) { for (var j$2 = 0; j$2 < foundBookmarks.length; ++j$2)
  6310. { buildCollapsedSpan(builder, 0, foundBookmarks[j$2]); } }
  6311. if (collapsed && (collapsed.from || 0) == pos) {
  6312. buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
  6313. collapsed.marker, collapsed.from == null);
  6314. if (collapsed.to == null) { return }
  6315. if (collapsed.to == pos) { collapsed = false; }
  6316. }
  6317. }
  6318. if (pos >= len) { break }
  6319. var upto = Math.min(len, nextChange);
  6320. while (true) {
  6321. if (text) {
  6322. var end = pos + text.length;
  6323. if (!collapsed) {
  6324. var tokenText = end > upto ? text.slice(0, upto - pos) : text;
  6325. builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
  6326. spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", css, attributes);
  6327. }
  6328. if (end >= upto) {text = text.slice(upto - pos); pos = upto; break}
  6329. pos = end;
  6330. spanStartStyle = "";
  6331. }
  6332. text = allText.slice(at, at = styles[i++]);
  6333. style = interpretTokenStyle(styles[i++], builder.cm.options);
  6334. }
  6335. }
  6336. }
  6337. // These objects are used to represent the visible (currently drawn)
  6338. // part of the document. A LineView may correspond to multiple
  6339. // logical lines, if those are connected by collapsed ranges.
  6340. function LineView(doc, line, lineN) {
  6341. // The starting line
  6342. this.line = line;
  6343. // Continuing lines, if any
  6344. this.rest = visualLineContinued(line);
  6345. // Number of logical lines in this visual line
  6346. this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;
  6347. this.node = this.text = null;
  6348. this.hidden = lineIsHidden(doc, line);
  6349. }
  6350. // Create a range of LineView objects for the given lines.
  6351. function buildViewArray(cm, from, to) {
  6352. var array = [], nextPos;
  6353. for (var pos = from; pos < to; pos = nextPos) {
  6354. var view = new LineView(cm.doc, getLine(cm.doc, pos), pos);
  6355. nextPos = pos + view.size;
  6356. array.push(view);
  6357. }
  6358. return array
  6359. }
  6360. var operationGroup = null;
  6361. function pushOperation(op) {
  6362. if (operationGroup) {
  6363. operationGroup.ops.push(op);
  6364. } else {
  6365. op.ownsGroup = operationGroup = {
  6366. ops: [op],
  6367. delayedCallbacks: []
  6368. };
  6369. }
  6370. }
  6371. function fireCallbacksForOps(group) {
  6372. // Calls delayed callbacks and cursorActivity handlers until no
  6373. // new ones appear
  6374. var callbacks = group.delayedCallbacks, i = 0;
  6375. do {
  6376. for (; i < callbacks.length; i++)
  6377. { callbacks[i].call(null); }
  6378. for (var j = 0; j < group.ops.length; j++) {
  6379. var op = group.ops[j];
  6380. if (op.cursorActivityHandlers)
  6381. { while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
  6382. { op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm); } }
  6383. }
  6384. } while (i < callbacks.length)
  6385. }
  6386. function finishOperation(op, endCb) {
  6387. var group = op.ownsGroup;
  6388. if (!group) { return }
  6389. try { fireCallbacksForOps(group); }
  6390. finally {
  6391. operationGroup = null;
  6392. endCb(group);
  6393. }
  6394. }
  6395. var orphanDelayedCallbacks = null;
  6396. // Often, we want to signal events at a point where we are in the
  6397. // middle of some work, but don't want the handler to start calling
  6398. // other methods on the editor, which might be in an inconsistent
  6399. // state or simply not expect any other events to happen.
  6400. // signalLater looks whether there are any handlers, and schedules
  6401. // them to be executed when the last operation ends, or, if no
  6402. // operation is active, when a timeout fires.
  6403. function signalLater(emitter, type /*, values...*/) {
  6404. var arr = getHandlers(emitter, type);
  6405. if (!arr.length) { return }
  6406. var args = Array.prototype.slice.call(arguments, 2), list;
  6407. if (operationGroup) {
  6408. list = operationGroup.delayedCallbacks;
  6409. } else if (orphanDelayedCallbacks) {
  6410. list = orphanDelayedCallbacks;
  6411. } else {
  6412. list = orphanDelayedCallbacks = [];
  6413. setTimeout(fireOrphanDelayed, 0);
  6414. }
  6415. var loop = function ( i ) {
  6416. list.push(function () { return arr[i].apply(null, args); });
  6417. };
  6418. for (var i = 0; i < arr.length; ++i)
  6419. loop( i );
  6420. }
  6421. function fireOrphanDelayed() {
  6422. var delayed = orphanDelayedCallbacks;
  6423. orphanDelayedCallbacks = null;
  6424. for (var i = 0; i < delayed.length; ++i) { delayed[i](); }
  6425. }
  6426. // When an aspect of a line changes, a string is added to
  6427. // lineView.changes. This updates the relevant part of the line's
  6428. // DOM structure.
  6429. function updateLineForChanges(cm, lineView, lineN, dims) {
  6430. for (var j = 0; j < lineView.changes.length; j++) {
  6431. var type = lineView.changes[j];
  6432. if (type == "text") { updateLineText(cm, lineView); }
  6433. else if (type == "gutter") { updateLineGutter(cm, lineView, lineN, dims); }
  6434. else if (type == "class") { updateLineClasses(cm, lineView); }
  6435. else if (type == "widget") { updateLineWidgets(cm, lineView, dims); }
  6436. }
  6437. lineView.changes = null;
  6438. }
  6439. // Lines with gutter elements, widgets or a background class need to
  6440. // be wrapped, and have the extra elements added to the wrapper div
  6441. function ensureLineWrapped(lineView) {
  6442. if (lineView.node == lineView.text) {
  6443. lineView.node = elt("div", null, null, "position: relative");
  6444. if (lineView.text.parentNode)
  6445. { lineView.text.parentNode.replaceChild(lineView.node, lineView.text); }
  6446. lineView.node.appendChild(lineView.text);
  6447. if (ie && ie_version < 8) { lineView.node.style.zIndex = 2; }
  6448. }
  6449. return lineView.node
  6450. }
  6451. function updateLineBackground(cm, lineView) {
  6452. var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
  6453. if (cls) { cls += " CodeMirror-linebackground"; }
  6454. if (lineView.background) {
  6455. if (cls) { lineView.background.className = cls; }
  6456. else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }
  6457. } else if (cls) {
  6458. var wrap = ensureLineWrapped(lineView);
  6459. lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
  6460. cm.display.input.setUneditable(lineView.background);
  6461. }
  6462. }
  6463. // Wrapper around buildLineContent which will reuse the structure
  6464. // in display.externalMeasured when possible.
  6465. function getLineContent(cm, lineView) {
  6466. var ext = cm.display.externalMeasured;
  6467. if (ext && ext.line == lineView.line) {
  6468. cm.display.externalMeasured = null;
  6469. lineView.measure = ext.measure;
  6470. return ext.built
  6471. }
  6472. return buildLineContent(cm, lineView)
  6473. }
  6474. // Redraw the line's text. Interacts with the background and text
  6475. // classes because the mode may output tokens that influence these
  6476. // classes.
  6477. function updateLineText(cm, lineView) {
  6478. var cls = lineView.text.className;
  6479. var built = getLineContent(cm, lineView);
  6480. if (lineView.text == lineView.node) { lineView.node = built.pre; }
  6481. lineView.text.parentNode.replaceChild(built.pre, lineView.text);
  6482. lineView.text = built.pre;
  6483. if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
  6484. lineView.bgClass = built.bgClass;
  6485. lineView.textClass = built.textClass;
  6486. updateLineClasses(cm, lineView);
  6487. } else if (cls) {
  6488. lineView.text.className = cls;
  6489. }
  6490. }
  6491. function updateLineClasses(cm, lineView) {
  6492. updateLineBackground(cm, lineView);
  6493. if (lineView.line.wrapClass)
  6494. { ensureLineWrapped(lineView).className = lineView.line.wrapClass; }
  6495. else if (lineView.node != lineView.text)
  6496. { lineView.node.className = ""; }
  6497. var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
  6498. lineView.text.className = textClass || "";
  6499. }
  6500. function updateLineGutter(cm, lineView, lineN, dims) {
  6501. if (lineView.gutter) {
  6502. lineView.node.removeChild(lineView.gutter);
  6503. lineView.gutter = null;
  6504. }
  6505. if (lineView.gutterBackground) {
  6506. lineView.node.removeChild(lineView.gutterBackground);
  6507. lineView.gutterBackground = null;
  6508. }
  6509. if (lineView.line.gutterClass) {
  6510. var wrap = ensureLineWrapped(lineView);
  6511. lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
  6512. ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px; width: " + (dims.gutterTotalWidth) + "px"));
  6513. cm.display.input.setUneditable(lineView.gutterBackground);
  6514. wrap.insertBefore(lineView.gutterBackground, lineView.text);
  6515. }
  6516. var markers = lineView.line.gutterMarkers;
  6517. if (cm.options.lineNumbers || markers) {
  6518. var wrap$1 = ensureLineWrapped(lineView);
  6519. var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"));
  6520. cm.display.input.setUneditable(gutterWrap);
  6521. wrap$1.insertBefore(gutterWrap, lineView.text);
  6522. if (lineView.line.gutterClass)
  6523. { gutterWrap.className += " " + lineView.line.gutterClass; }
  6524. if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
  6525. { lineView.lineNumber = gutterWrap.appendChild(
  6526. elt("div", lineNumberFor(cm.options, lineN),
  6527. "CodeMirror-linenumber CodeMirror-gutter-elt",
  6528. ("left: " + (dims.gutterLeft["CodeMirror-linenumbers"]) + "px; width: " + (cm.display.lineNumInnerWidth) + "px"))); }
  6529. if (markers) { for (var k = 0; k < cm.display.gutterSpecs.length; ++k) {
  6530. var id = cm.display.gutterSpecs[k].className, found = markers.hasOwnProperty(id) && markers[id];
  6531. if (found)
  6532. { gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt",
  6533. ("left: " + (dims.gutterLeft[id]) + "px; width: " + (dims.gutterWidth[id]) + "px"))); }
  6534. } }
  6535. }
  6536. }
  6537. function updateLineWidgets(cm, lineView, dims) {
  6538. if (lineView.alignable) { lineView.alignable = null; }
  6539. var isWidget = classTest("CodeMirror-linewidget");
  6540. for (var node = lineView.node.firstChild, next = (void 0); node; node = next) {
  6541. next = node.nextSibling;
  6542. if (isWidget.test(node.className)) { lineView.node.removeChild(node); }
  6543. }
  6544. insertLineWidgets(cm, lineView, dims);
  6545. }
  6546. // Build a line's DOM representation from scratch
  6547. function buildLineElement(cm, lineView, lineN, dims) {
  6548. var built = getLineContent(cm, lineView);
  6549. lineView.text = lineView.node = built.pre;
  6550. if (built.bgClass) { lineView.bgClass = built.bgClass; }
  6551. if (built.textClass) { lineView.textClass = built.textClass; }
  6552. updateLineClasses(cm, lineView);
  6553. updateLineGutter(cm, lineView, lineN, dims);
  6554. insertLineWidgets(cm, lineView, dims);
  6555. return lineView.node
  6556. }
  6557. // A lineView may contain multiple logical lines (when merged by
  6558. // collapsed spans). The widgets for all of them need to be drawn.
  6559. function insertLineWidgets(cm, lineView, dims) {
  6560. insertLineWidgetsFor(cm, lineView.line, lineView, dims, true);
  6561. if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)
  6562. { insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false); } }
  6563. }
  6564. function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
  6565. if (!line.widgets) { return }
  6566. var wrap = ensureLineWrapped(lineView);
  6567. for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
  6568. var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget" + (widget.className ? " " + widget.className : ""));
  6569. if (!widget.handleMouseEvents) { node.setAttribute("cm-ignore-events", "true"); }
  6570. positionLineWidget(widget, node, lineView, dims);
  6571. cm.display.input.setUneditable(node);
  6572. if (allowAbove && widget.above)
  6573. { wrap.insertBefore(node, lineView.gutter || lineView.text); }
  6574. else
  6575. { wrap.appendChild(node); }
  6576. signalLater(widget, "redraw");
  6577. }
  6578. }
  6579. function positionLineWidget(widget, node, lineView, dims) {
  6580. if (widget.noHScroll) {
  6581. (lineView.alignable || (lineView.alignable = [])).push(node);
  6582. var width = dims.wrapperWidth;
  6583. node.style.left = dims.fixedPos + "px";
  6584. if (!widget.coverGutter) {
  6585. width -= dims.gutterTotalWidth;
  6586. node.style.paddingLeft = dims.gutterTotalWidth + "px";
  6587. }
  6588. node.style.width = width + "px";
  6589. }
  6590. if (widget.coverGutter) {
  6591. node.style.zIndex = 5;
  6592. node.style.position = "relative";
  6593. if (!widget.noHScroll) { node.style.marginLeft = -dims.gutterTotalWidth + "px"; }
  6594. }
  6595. }
  6596. function widgetHeight(widget) {
  6597. if (widget.height != null) { return widget.height }
  6598. var cm = widget.doc.cm;
  6599. if (!cm) { return 0 }
  6600. if (!contains(document.body, widget.node)) {
  6601. var parentStyle = "position: relative;";
  6602. if (widget.coverGutter)
  6603. { parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;"; }
  6604. if (widget.noHScroll)
  6605. { parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;"; }
  6606. removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle));
  6607. }
  6608. return widget.height = widget.node.parentNode.offsetHeight
  6609. }
  6610. // Return true when the given mouse event happened in a widget
  6611. function eventInWidget(display, e) {
  6612. for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
  6613. if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") ||
  6614. (n.parentNode == display.sizer && n != display.mover))
  6615. { return true }
  6616. }
  6617. }
  6618. // POSITION MEASUREMENT
  6619. function paddingTop(display) {return display.lineSpace.offsetTop}
  6620. function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight}
  6621. function paddingH(display) {
  6622. if (display.cachedPaddingH) { return display.cachedPaddingH }
  6623. var e = removeChildrenAndAdd(display.measure, elt("pre", "x", "CodeMirror-line-like"));
  6624. var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
  6625. var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};
  6626. if (!isNaN(data.left) && !isNaN(data.right)) { display.cachedPaddingH = data; }
  6627. return data
  6628. }
  6629. function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth }
  6630. function displayWidth(cm) {
  6631. return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth
  6632. }
  6633. function displayHeight(cm) {
  6634. return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight
  6635. }
  6636. // Ensure the lineView.wrapping.heights array is populated. This is
  6637. // an array of bottom offsets for the lines that make up a drawn
  6638. // line. When lineWrapping is on, there might be more than one
  6639. // height.
  6640. function ensureLineHeights(cm, lineView, rect) {
  6641. var wrapping = cm.options.lineWrapping;
  6642. var curWidth = wrapping && displayWidth(cm);
  6643. if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
  6644. var heights = lineView.measure.heights = [];
  6645. if (wrapping) {
  6646. lineView.measure.width = curWidth;
  6647. var rects = lineView.text.firstChild.getClientRects();
  6648. for (var i = 0; i < rects.length - 1; i++) {
  6649. var cur = rects[i], next = rects[i + 1];
  6650. if (Math.abs(cur.bottom - next.bottom) > 2)
  6651. { heights.push((cur.bottom + next.top) / 2 - rect.top); }
  6652. }
  6653. }
  6654. heights.push(rect.bottom - rect.top);
  6655. }
  6656. }
  6657. // Find a line map (mapping character offsets to text nodes) and a
  6658. // measurement cache for the given line number. (A line view might
  6659. // contain multiple lines when collapsed ranges are present.)
  6660. function mapFromLineView(lineView, line, lineN) {
  6661. if (lineView.line == line)
  6662. { return {map: lineView.measure.map, cache: lineView.measure.cache} }
  6663. for (var i = 0; i < lineView.rest.length; i++)
  6664. { if (lineView.rest[i] == line)
  6665. { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } }
  6666. for (var i$1 = 0; i$1 < lineView.rest.length; i$1++)
  6667. { if (lineNo(lineView.rest[i$1]) > lineN)
  6668. { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } }
  6669. }
  6670. // Render a line into the hidden node display.externalMeasured. Used
  6671. // when measurement is needed for a line that's not in the viewport.
  6672. function updateExternalMeasurement(cm, line) {
  6673. line = visualLine(line);
  6674. var lineN = lineNo(line);
  6675. var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);
  6676. view.lineN = lineN;
  6677. var built = view.built = buildLineContent(cm, view);
  6678. view.text = built.pre;
  6679. removeChildrenAndAdd(cm.display.lineMeasure, built.pre);
  6680. return view
  6681. }
  6682. // Get a {top, bottom, left, right} box (in line-local coordinates)
  6683. // for a given character.
  6684. function measureChar(cm, line, ch, bias) {
  6685. return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias)
  6686. }
  6687. // Find a line view that corresponds to the given line number.
  6688. function findViewForLine(cm, lineN) {
  6689. if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
  6690. { return cm.display.view[findViewIndex(cm, lineN)] }
  6691. var ext = cm.display.externalMeasured;
  6692. if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
  6693. { return ext }
  6694. }
  6695. // Measurement can be split in two steps, the set-up work that
  6696. // applies to the whole line, and the measurement of the actual
  6697. // character. Functions like coordsChar, that need to do a lot of
  6698. // measurements in a row, can thus ensure that the set-up work is
  6699. // only done once.
  6700. function prepareMeasureForLine(cm, line) {
  6701. var lineN = lineNo(line);
  6702. var view = findViewForLine(cm, lineN);
  6703. if (view && !view.text) {
  6704. view = null;
  6705. } else if (view && view.changes) {
  6706. updateLineForChanges(cm, view, lineN, getDimensions(cm));
  6707. cm.curOp.forceUpdate = true;
  6708. }
  6709. if (!view)
  6710. { view = updateExternalMeasurement(cm, line); }
  6711. var info = mapFromLineView(view, line, lineN);
  6712. return {
  6713. line: line, view: view, rect: null,
  6714. map: info.map, cache: info.cache, before: info.before,
  6715. hasHeights: false
  6716. }
  6717. }
  6718. // Given a prepared measurement object, measures the position of an
  6719. // actual character (or fetches it from the cache).
  6720. function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
  6721. if (prepared.before) { ch = -1; }
  6722. var key = ch + (bias || ""), found;
  6723. if (prepared.cache.hasOwnProperty(key)) {
  6724. found = prepared.cache[key];
  6725. } else {
  6726. if (!prepared.rect)
  6727. { prepared.rect = prepared.view.text.getBoundingClientRect(); }
  6728. if (!prepared.hasHeights) {
  6729. ensureLineHeights(cm, prepared.view, prepared.rect);
  6730. prepared.hasHeights = true;
  6731. }
  6732. found = measureCharInner(cm, prepared, ch, bias);
  6733. if (!found.bogus) { prepared.cache[key] = found; }
  6734. }
  6735. return {left: found.left, right: found.right,
  6736. top: varHeight ? found.rtop : found.top,
  6737. bottom: varHeight ? found.rbottom : found.bottom}
  6738. }
  6739. var nullRect = {left: 0, right: 0, top: 0, bottom: 0};
  6740. function nodeAndOffsetInLineMap(map, ch, bias) {
  6741. var node, start, end, collapse, mStart, mEnd;
  6742. // First, search the line map for the text node corresponding to,
  6743. // or closest to, the target character.
  6744. for (var i = 0; i < map.length; i += 3) {
  6745. mStart = map[i];
  6746. mEnd = map[i + 1];
  6747. if (ch < mStart) {
  6748. start = 0; end = 1;
  6749. collapse = "left";
  6750. } else if (ch < mEnd) {
  6751. start = ch - mStart;
  6752. end = start + 1;
  6753. } else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) {
  6754. end = mEnd - mStart;
  6755. start = end - 1;
  6756. if (ch >= mEnd) { collapse = "right"; }
  6757. }
  6758. if (start != null) {
  6759. node = map[i + 2];
  6760. if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right"))
  6761. { collapse = bias; }
  6762. if (bias == "left" && start == 0)
  6763. { while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) {
  6764. node = map[(i -= 3) + 2];
  6765. collapse = "left";
  6766. } }
  6767. if (bias == "right" && start == mEnd - mStart)
  6768. { while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) {
  6769. node = map[(i += 3) + 2];
  6770. collapse = "right";
  6771. } }
  6772. break
  6773. }
  6774. }
  6775. return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd}
  6776. }
  6777. function getUsefulRect(rects, bias) {
  6778. var rect = nullRect;
  6779. if (bias == "left") { for (var i = 0; i < rects.length; i++) {
  6780. if ((rect = rects[i]).left != rect.right) { break }
  6781. } } else { for (var i$1 = rects.length - 1; i$1 >= 0; i$1--) {
  6782. if ((rect = rects[i$1]).left != rect.right) { break }
  6783. } }
  6784. return rect
  6785. }
  6786. function measureCharInner(cm, prepared, ch, bias) {
  6787. var place = nodeAndOffsetInLineMap(prepared.map, ch, bias);
  6788. var node = place.node, start = place.start, end = place.end, collapse = place.collapse;
  6789. var rect;
  6790. if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.
  6791. for (var i$1 = 0; i$1 < 4; i$1++) { // Retry a maximum of 4 times when nonsense rectangles are returned
  6792. while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) { --start; }
  6793. while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) { ++end; }
  6794. if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart)
  6795. { rect = node.parentNode.getBoundingClientRect(); }
  6796. else
  6797. { rect = getUsefulRect(range(node, start, end).getClientRects(), bias); }
  6798. if (rect.left || rect.right || start == 0) { break }
  6799. end = start;
  6800. start = start - 1;
  6801. collapse = "right";
  6802. }
  6803. if (ie && ie_version < 11) { rect = maybeUpdateRectForZooming(cm.display.measure, rect); }
  6804. } else { // If it is a widget, simply get the box for the whole widget.
  6805. if (start > 0) { collapse = bias = "right"; }
  6806. var rects;
  6807. if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)
  6808. { rect = rects[bias == "right" ? rects.length - 1 : 0]; }
  6809. else
  6810. { rect = node.getBoundingClientRect(); }
  6811. }
  6812. if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
  6813. var rSpan = node.parentNode.getClientRects()[0];
  6814. if (rSpan)
  6815. { rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom}; }
  6816. else
  6817. { rect = nullRect; }
  6818. }
  6819. var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top;
  6820. var mid = (rtop + rbot) / 2;
  6821. var heights = prepared.view.measure.heights;
  6822. var i = 0;
  6823. for (; i < heights.length - 1; i++)
  6824. { if (mid < heights[i]) { break } }
  6825. var top = i ? heights[i - 1] : 0, bot = heights[i];
  6826. var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
  6827. right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
  6828. top: top, bottom: bot};
  6829. if (!rect.left && !rect.right) { result.bogus = true; }
  6830. if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; }
  6831. return result
  6832. }
  6833. // Work around problem with bounding client rects on ranges being
  6834. // returned incorrectly when zoomed on IE10 and below.
  6835. function maybeUpdateRectForZooming(measure, rect) {
  6836. if (!window.screen || screen.logicalXDPI == null ||
  6837. screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))
  6838. { return rect }
  6839. var scaleX = screen.logicalXDPI / screen.deviceXDPI;
  6840. var scaleY = screen.logicalYDPI / screen.deviceYDPI;
  6841. return {left: rect.left * scaleX, right: rect.right * scaleX,
  6842. top: rect.top * scaleY, bottom: rect.bottom * scaleY}
  6843. }
  6844. function clearLineMeasurementCacheFor(lineView) {
  6845. if (lineView.measure) {
  6846. lineView.measure.cache = {};
  6847. lineView.measure.heights = null;
  6848. if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)
  6849. { lineView.measure.caches[i] = {}; } }
  6850. }
  6851. }
  6852. function clearLineMeasurementCache(cm) {
  6853. cm.display.externalMeasure = null;
  6854. removeChildren(cm.display.lineMeasure);
  6855. for (var i = 0; i < cm.display.view.length; i++)
  6856. { clearLineMeasurementCacheFor(cm.display.view[i]); }
  6857. }
  6858. function clearCaches(cm) {
  6859. clearLineMeasurementCache(cm);
  6860. cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;
  6861. if (!cm.options.lineWrapping) { cm.display.maxLineChanged = true; }
  6862. cm.display.lineNumChars = null;
  6863. }
  6864. function pageScrollX() {
  6865. // Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206
  6866. // which causes page_Offset and bounding client rects to use
  6867. // different reference viewports and invalidate our calculations.
  6868. if (chrome && android) { return -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft)) }
  6869. return window.pageXOffset || (document.documentElement || document.body).scrollLeft
  6870. }
  6871. function pageScrollY() {
  6872. if (chrome && android) { return -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop)) }
  6873. return window.pageYOffset || (document.documentElement || document.body).scrollTop
  6874. }
  6875. function widgetTopHeight(lineObj) {
  6876. var height = 0;
  6877. if (lineObj.widgets) { for (var i = 0; i < lineObj.widgets.length; ++i) { if (lineObj.widgets[i].above)
  6878. { height += widgetHeight(lineObj.widgets[i]); } } }
  6879. return height
  6880. }
  6881. // Converts a {top, bottom, left, right} box from line-local
  6882. // coordinates into another coordinate system. Context may be one of
  6883. // "line", "div" (display.lineDiv), "local"./null (editor), "window",
  6884. // or "page".
  6885. function intoCoordSystem(cm, lineObj, rect, context, includeWidgets) {
  6886. if (!includeWidgets) {
  6887. var height = widgetTopHeight(lineObj);
  6888. rect.top += height; rect.bottom += height;
  6889. }
  6890. if (context == "line") { return rect }
  6891. if (!context) { context = "local"; }
  6892. var yOff = heightAtLine(lineObj);
  6893. if (context == "local") { yOff += paddingTop(cm.display); }
  6894. else { yOff -= cm.display.viewOffset; }
  6895. if (context == "page" || context == "window") {
  6896. var lOff = cm.display.lineSpace.getBoundingClientRect();
  6897. yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
  6898. var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
  6899. rect.left += xOff; rect.right += xOff;
  6900. }
  6901. rect.top += yOff; rect.bottom += yOff;
  6902. return rect
  6903. }
  6904. // Coverts a box from "div" coords to another coordinate system.
  6905. // Context may be "window", "page", "div", or "local"./null.
  6906. function fromCoordSystem(cm, coords, context) {
  6907. if (context == "div") { return coords }
  6908. var left = coords.left, top = coords.top;
  6909. // First move into "page" coordinate system
  6910. if (context == "page") {
  6911. left -= pageScrollX();
  6912. top -= pageScrollY();
  6913. } else if (context == "local" || !context) {
  6914. var localBox = cm.display.sizer.getBoundingClientRect();
  6915. left += localBox.left;
  6916. top += localBox.top;
  6917. }
  6918. var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
  6919. return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top}
  6920. }
  6921. function charCoords(cm, pos, context, lineObj, bias) {
  6922. if (!lineObj) { lineObj = getLine(cm.doc, pos.line); }
  6923. return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context)
  6924. }
  6925. // Returns a box for a given cursor position, which may have an
  6926. // 'other' property containing the position of the secondary cursor
  6927. // on a bidi boundary.
  6928. // A cursor Pos(line, char, "before") is on the same visual line as `char - 1`
  6929. // and after `char - 1` in writing order of `char - 1`
  6930. // A cursor Pos(line, char, "after") is on the same visual line as `char`
  6931. // and before `char` in writing order of `char`
  6932. // Examples (upper-case letters are RTL, lower-case are LTR):
  6933. // Pos(0, 1, ...)
  6934. // before after
  6935. // ab a|b a|b
  6936. // aB a|B aB|
  6937. // Ab |Ab A|b
  6938. // AB B|A B|A
  6939. // Every position after the last character on a line is considered to stick
  6940. // to the last character on the line.
  6941. function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
  6942. lineObj = lineObj || getLine(cm.doc, pos.line);
  6943. if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); }
  6944. function get(ch, right) {
  6945. var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
  6946. if (right) { m.left = m.right; } else { m.right = m.left; }
  6947. return intoCoordSystem(cm, lineObj, m, context)
  6948. }
  6949. var order = getOrder(lineObj, cm.doc.direction), ch = pos.ch, sticky = pos.sticky;
  6950. if (ch >= lineObj.text.length) {
  6951. ch = lineObj.text.length;
  6952. sticky = "before";
  6953. } else if (ch <= 0) {
  6954. ch = 0;
  6955. sticky = "after";
  6956. }
  6957. if (!order) { return get(sticky == "before" ? ch - 1 : ch, sticky == "before") }
  6958. function getBidi(ch, partPos, invert) {
  6959. var part = order[partPos], right = part.level == 1;
  6960. return get(invert ? ch - 1 : ch, right != invert)
  6961. }
  6962. var partPos = getBidiPartAt(order, ch, sticky);
  6963. var other = bidiOther;
  6964. var val = getBidi(ch, partPos, sticky == "before");
  6965. if (other != null) { val.other = getBidi(ch, other, sticky != "before"); }
  6966. return val
  6967. }
  6968. // Used to cheaply estimate the coordinates for a position. Used for
  6969. // intermediate scroll updates.
  6970. function estimateCoords(cm, pos) {
  6971. var left = 0;
  6972. pos = clipPos(cm.doc, pos);
  6973. if (!cm.options.lineWrapping) { left = charWidth(cm.display) * pos.ch; }
  6974. var lineObj = getLine(cm.doc, pos.line);
  6975. var top = heightAtLine(lineObj) + paddingTop(cm.display);
  6976. return {left: left, right: left, top: top, bottom: top + lineObj.height}
  6977. }
  6978. // Positions returned by coordsChar contain some extra information.
  6979. // xRel is the relative x position of the input coordinates compared
  6980. // to the found position (so xRel > 0 means the coordinates are to
  6981. // the right of the character position, for example). When outside
  6982. // is true, that means the coordinates lie outside the line's
  6983. // vertical range.
  6984. function PosWithInfo(line, ch, sticky, outside, xRel) {
  6985. var pos = Pos(line, ch, sticky);
  6986. pos.xRel = xRel;
  6987. if (outside) { pos.outside = outside; }
  6988. return pos
  6989. }
  6990. // Compute the character position closest to the given coordinates.
  6991. // Input must be lineSpace-local ("div" coordinate system).
  6992. function coordsChar(cm, x, y) {
  6993. var doc = cm.doc;
  6994. y += cm.display.viewOffset;
  6995. if (y < 0) { return PosWithInfo(doc.first, 0, null, -1, -1) }
  6996. var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
  6997. if (lineN > last)
  6998. { return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, 1, 1) }
  6999. if (x < 0) { x = 0; }
  7000. var lineObj = getLine(doc, lineN);
  7001. for (;;) {
  7002. var found = coordsCharInner(cm, lineObj, lineN, x, y);
  7003. var collapsed = collapsedSpanAround(lineObj, found.ch + (found.xRel > 0 || found.outside > 0 ? 1 : 0));
  7004. if (!collapsed) { return found }
  7005. var rangeEnd = collapsed.find(1);
  7006. if (rangeEnd.line == lineN) { return rangeEnd }
  7007. lineObj = getLine(doc, lineN = rangeEnd.line);
  7008. }
  7009. }
  7010. function wrappedLineExtent(cm, lineObj, preparedMeasure, y) {
  7011. y -= widgetTopHeight(lineObj);
  7012. var end = lineObj.text.length;
  7013. var begin = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch - 1).bottom <= y; }, end, 0);
  7014. end = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch).top > y; }, begin, end);
  7015. return {begin: begin, end: end}
  7016. }
  7017. function wrappedLineExtentChar(cm, lineObj, preparedMeasure, target) {
  7018. if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); }
  7019. var targetTop = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, target), "line").top;
  7020. return wrappedLineExtent(cm, lineObj, preparedMeasure, targetTop)
  7021. }
  7022. // Returns true if the given side of a box is after the given
  7023. // coordinates, in top-to-bottom, left-to-right order.
  7024. function boxIsAfter(box, x, y, left) {
  7025. return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x
  7026. }
  7027. function coordsCharInner(cm, lineObj, lineNo, x, y) {
  7028. // Move y into line-local coordinate space
  7029. y -= heightAtLine(lineObj);
  7030. var preparedMeasure = prepareMeasureForLine(cm, lineObj);
  7031. // When directly calling `measureCharPrepared`, we have to adjust
  7032. // for the widgets at this line.
  7033. var widgetHeight = widgetTopHeight(lineObj);
  7034. var begin = 0, end = lineObj.text.length, ltr = true;
  7035. var order = getOrder(lineObj, cm.doc.direction);
  7036. // If the line isn't plain left-to-right text, first figure out
  7037. // which bidi section the coordinates fall into.
  7038. if (order) {
  7039. var part = (cm.options.lineWrapping ? coordsBidiPartWrapped : coordsBidiPart)
  7040. (cm, lineObj, lineNo, preparedMeasure, order, x, y);
  7041. ltr = part.level != 1;
  7042. // The awkward -1 offsets are needed because findFirst (called
  7043. // on these below) will treat its first bound as inclusive,
  7044. // second as exclusive, but we want to actually address the
  7045. // characters in the part's range
  7046. begin = ltr ? part.from : part.to - 1;
  7047. end = ltr ? part.to : part.from - 1;
  7048. }
  7049. // A binary search to find the first character whose bounding box
  7050. // starts after the coordinates. If we run across any whose box wrap
  7051. // the coordinates, store that.
  7052. var chAround = null, boxAround = null;
  7053. var ch = findFirst(function (ch) {
  7054. var box = measureCharPrepared(cm, preparedMeasure, ch);
  7055. box.top += widgetHeight; box.bottom += widgetHeight;
  7056. if (!boxIsAfter(box, x, y, false)) { return false }
  7057. if (box.top <= y && box.left <= x) {
  7058. chAround = ch;
  7059. boxAround = box;
  7060. }
  7061. return true
  7062. }, begin, end);
  7063. var baseX, sticky, outside = false;
  7064. // If a box around the coordinates was found, use that
  7065. if (boxAround) {
  7066. // Distinguish coordinates nearer to the left or right side of the box
  7067. var atLeft = x - boxAround.left < boxAround.right - x, atStart = atLeft == ltr;
  7068. ch = chAround + (atStart ? 0 : 1);
  7069. sticky = atStart ? "after" : "before";
  7070. baseX = atLeft ? boxAround.left : boxAround.right;
  7071. } else {
  7072. // (Adjust for extended bound, if necessary.)
  7073. if (!ltr && (ch == end || ch == begin)) { ch++; }
  7074. // To determine which side to associate with, get the box to the
  7075. // left of the character and compare it's vertical position to the
  7076. // coordinates
  7077. sticky = ch == 0 ? "after" : ch == lineObj.text.length ? "before" :
  7078. (measureCharPrepared(cm, preparedMeasure, ch - (ltr ? 1 : 0)).bottom + widgetHeight <= y) == ltr ?
  7079. "after" : "before";
  7080. // Now get accurate coordinates for this place, in order to get a
  7081. // base X position
  7082. var coords = cursorCoords(cm, Pos(lineNo, ch, sticky), "line", lineObj, preparedMeasure);
  7083. baseX = coords.left;
  7084. outside = y < coords.top ? -1 : y >= coords.bottom ? 1 : 0;
  7085. }
  7086. ch = skipExtendingChars(lineObj.text, ch, 1);
  7087. return PosWithInfo(lineNo, ch, sticky, outside, x - baseX)
  7088. }
  7089. function coordsBidiPart(cm, lineObj, lineNo, preparedMeasure, order, x, y) {
  7090. // Bidi parts are sorted left-to-right, and in a non-line-wrapping
  7091. // situation, we can take this ordering to correspond to the visual
  7092. // ordering. This finds the first part whose end is after the given
  7093. // coordinates.
  7094. var index = findFirst(function (i) {
  7095. var part = order[i], ltr = part.level != 1;
  7096. return boxIsAfter(cursorCoords(cm, Pos(lineNo, ltr ? part.to : part.from, ltr ? "before" : "after"),
  7097. "line", lineObj, preparedMeasure), x, y, true)
  7098. }, 0, order.length - 1);
  7099. var part = order[index];
  7100. // If this isn't the first part, the part's start is also after
  7101. // the coordinates, and the coordinates aren't on the same line as
  7102. // that start, move one part back.
  7103. if (index > 0) {
  7104. var ltr = part.level != 1;
  7105. var start = cursorCoords(cm, Pos(lineNo, ltr ? part.from : part.to, ltr ? "after" : "before"),
  7106. "line", lineObj, preparedMeasure);
  7107. if (boxIsAfter(start, x, y, true) && start.top > y)
  7108. { part = order[index - 1]; }
  7109. }
  7110. return part
  7111. }
  7112. function coordsBidiPartWrapped(cm, lineObj, _lineNo, preparedMeasure, order, x, y) {
  7113. // In a wrapped line, rtl text on wrapping boundaries can do things
  7114. // that don't correspond to the ordering in our `order` array at
  7115. // all, so a binary search doesn't work, and we want to return a
  7116. // part that only spans one line so that the binary search in
  7117. // coordsCharInner is safe. As such, we first find the extent of the
  7118. // wrapped line, and then do a flat search in which we discard any
  7119. // spans that aren't on the line.
  7120. var ref = wrappedLineExtent(cm, lineObj, preparedMeasure, y);
  7121. var begin = ref.begin;
  7122. var end = ref.end;
  7123. if (/\s/.test(lineObj.text.charAt(end - 1))) { end--; }
  7124. var part = null, closestDist = null;
  7125. for (var i = 0; i < order.length; i++) {
  7126. var p = order[i];
  7127. if (p.from >= end || p.to <= begin) { continue }
  7128. var ltr = p.level != 1;
  7129. var endX = measureCharPrepared(cm, preparedMeasure, ltr ? Math.min(end, p.to) - 1 : Math.max(begin, p.from)).right;
  7130. // Weigh against spans ending before this, so that they are only
  7131. // picked if nothing ends after
  7132. var dist = endX < x ? x - endX + 1e9 : endX - x;
  7133. if (!part || closestDist > dist) {
  7134. part = p;
  7135. closestDist = dist;
  7136. }
  7137. }
  7138. if (!part) { part = order[order.length - 1]; }
  7139. // Clip the part to the wrapped line.
  7140. if (part.from < begin) { part = {from: begin, to: part.to, level: part.level}; }
  7141. if (part.to > end) { part = {from: part.from, to: end, level: part.level}; }
  7142. return part
  7143. }
  7144. var measureText;
  7145. // Compute the default text height.
  7146. function textHeight(display) {
  7147. if (display.cachedTextHeight != null) { return display.cachedTextHeight }
  7148. if (measureText == null) {
  7149. measureText = elt("pre", null, "CodeMirror-line-like");
  7150. // Measure a bunch of lines, for browsers that compute
  7151. // fractional heights.
  7152. for (var i = 0; i < 49; ++i) {
  7153. measureText.appendChild(document.createTextNode("x"));
  7154. measureText.appendChild(elt("br"));
  7155. }
  7156. measureText.appendChild(document.createTextNode("x"));
  7157. }
  7158. removeChildrenAndAdd(display.measure, measureText);
  7159. var height = measureText.offsetHeight / 50;
  7160. if (height > 3) { display.cachedTextHeight = height; }
  7161. removeChildren(display.measure);
  7162. return height || 1
  7163. }
  7164. // Compute the default character width.
  7165. function charWidth(display) {
  7166. if (display.cachedCharWidth != null) { return display.cachedCharWidth }
  7167. var anchor = elt("span", "xxxxxxxxxx");
  7168. var pre = elt("pre", [anchor], "CodeMirror-line-like");
  7169. removeChildrenAndAdd(display.measure, pre);
  7170. var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
  7171. if (width > 2) { display.cachedCharWidth = width; }
  7172. return width || 10
  7173. }
  7174. // Do a bulk-read of the DOM positions and sizes needed to draw the
  7175. // view, so that we don't interleave reading and writing to the DOM.
  7176. function getDimensions(cm) {
  7177. var d = cm.display, left = {}, width = {};
  7178. var gutterLeft = d.gutters.clientLeft;
  7179. for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
  7180. var id = cm.display.gutterSpecs[i].className;
  7181. left[id] = n.offsetLeft + n.clientLeft + gutterLeft;
  7182. width[id] = n.clientWidth;
  7183. }
  7184. return {fixedPos: compensateForHScroll(d),
  7185. gutterTotalWidth: d.gutters.offsetWidth,
  7186. gutterLeft: left,
  7187. gutterWidth: width,
  7188. wrapperWidth: d.wrapper.clientWidth}
  7189. }
  7190. // Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
  7191. // but using getBoundingClientRect to get a sub-pixel-accurate
  7192. // result.
  7193. function compensateForHScroll(display) {
  7194. return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left
  7195. }
  7196. // Returns a function that estimates the height of a line, to use as
  7197. // first approximation until the line becomes visible (and is thus
  7198. // properly measurable).
  7199. function estimateHeight(cm) {
  7200. var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
  7201. var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
  7202. return function (line) {
  7203. if (lineIsHidden(cm.doc, line)) { return 0 }
  7204. var widgetsHeight = 0;
  7205. if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) {
  7206. if (line.widgets[i].height) { widgetsHeight += line.widgets[i].height; }
  7207. } }
  7208. if (wrapping)
  7209. { return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th }
  7210. else
  7211. { return widgetsHeight + th }
  7212. }
  7213. }
  7214. function estimateLineHeights(cm) {
  7215. var doc = cm.doc, est = estimateHeight(cm);
  7216. doc.iter(function (line) {
  7217. var estHeight = est(line);
  7218. if (estHeight != line.height) { updateLineHeight(line, estHeight); }
  7219. });
  7220. }
  7221. // Given a mouse event, find the corresponding position. If liberal
  7222. // is false, it checks whether a gutter or scrollbar was clicked,
  7223. // and returns null if it was. forRect is used by rectangular
  7224. // selections, and tries to estimate a character position even for
  7225. // coordinates beyond the right of the text.
  7226. function posFromMouse(cm, e, liberal, forRect) {
  7227. var display = cm.display;
  7228. if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") { return null }
  7229. var x, y, space = display.lineSpace.getBoundingClientRect();
  7230. // Fails unpredictably on IE[67] when mouse is dragged around quickly.
  7231. try { x = e.clientX - space.left; y = e.clientY - space.top; }
  7232. catch (e$1) { return null }
  7233. var coords = coordsChar(cm, x, y), line;
  7234. if (forRect && coords.xRel > 0 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
  7235. var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
  7236. coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
  7237. }
  7238. return coords
  7239. }
  7240. // Find the view element corresponding to a given line. Return null
  7241. // when the line isn't visible.
  7242. function findViewIndex(cm, n) {
  7243. if (n >= cm.display.viewTo) { return null }
  7244. n -= cm.display.viewFrom;
  7245. if (n < 0) { return null }
  7246. var view = cm.display.view;
  7247. for (var i = 0; i < view.length; i++) {
  7248. n -= view[i].size;
  7249. if (n < 0) { return i }
  7250. }
  7251. }
  7252. // Updates the display.view data structure for a given change to the
  7253. // document. From and to are in pre-change coordinates. Lendiff is
  7254. // the amount of lines added or subtracted by the change. This is
  7255. // used for changes that span multiple lines, or change the way
  7256. // lines are divided into visual lines. regLineChange (below)
  7257. // registers single-line changes.
  7258. function regChange(cm, from, to, lendiff) {
  7259. if (from == null) { from = cm.doc.first; }
  7260. if (to == null) { to = cm.doc.first + cm.doc.size; }
  7261. if (!lendiff) { lendiff = 0; }
  7262. var display = cm.display;
  7263. if (lendiff && to < display.viewTo &&
  7264. (display.updateLineNumbers == null || display.updateLineNumbers > from))
  7265. { display.updateLineNumbers = from; }
  7266. cm.curOp.viewChanged = true;
  7267. if (from >= display.viewTo) { // Change after
  7268. if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)
  7269. { resetView(cm); }
  7270. } else if (to <= display.viewFrom) { // Change before
  7271. if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
  7272. resetView(cm);
  7273. } else {
  7274. display.viewFrom += lendiff;
  7275. display.viewTo += lendiff;
  7276. }
  7277. } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap
  7278. resetView(cm);
  7279. } else if (from <= display.viewFrom) { // Top overlap
  7280. var cut = viewCuttingPoint(cm, to, to + lendiff, 1);
  7281. if (cut) {
  7282. display.view = display.view.slice(cut.index);
  7283. display.viewFrom = cut.lineN;
  7284. display.viewTo += lendiff;
  7285. } else {
  7286. resetView(cm);
  7287. }
  7288. } else if (to >= display.viewTo) { // Bottom overlap
  7289. var cut$1 = viewCuttingPoint(cm, from, from, -1);
  7290. if (cut$1) {
  7291. display.view = display.view.slice(0, cut$1.index);
  7292. display.viewTo = cut$1.lineN;
  7293. } else {
  7294. resetView(cm);
  7295. }
  7296. } else { // Gap in the middle
  7297. var cutTop = viewCuttingPoint(cm, from, from, -1);
  7298. var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1);
  7299. if (cutTop && cutBot) {
  7300. display.view = display.view.slice(0, cutTop.index)
  7301. .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))
  7302. .concat(display.view.slice(cutBot.index));
  7303. display.viewTo += lendiff;
  7304. } else {
  7305. resetView(cm);
  7306. }
  7307. }
  7308. var ext = display.externalMeasured;
  7309. if (ext) {
  7310. if (to < ext.lineN)
  7311. { ext.lineN += lendiff; }
  7312. else if (from < ext.lineN + ext.size)
  7313. { display.externalMeasured = null; }
  7314. }
  7315. }
  7316. // Register a change to a single line. Type must be one of "text",
  7317. // "gutter", "class", "widget"
  7318. function regLineChange(cm, line, type) {
  7319. cm.curOp.viewChanged = true;
  7320. var display = cm.display, ext = cm.display.externalMeasured;
  7321. if (ext && line >= ext.lineN && line < ext.lineN + ext.size)
  7322. { display.externalMeasured = null; }
  7323. if (line < display.viewFrom || line >= display.viewTo) { return }
  7324. var lineView = display.view[findViewIndex(cm, line)];
  7325. if (lineView.node == null) { return }
  7326. var arr = lineView.changes || (lineView.changes = []);
  7327. if (indexOf(arr, type) == -1) { arr.push(type); }
  7328. }
  7329. // Clear the view.
  7330. function resetView(cm) {
  7331. cm.display.viewFrom = cm.display.viewTo = cm.doc.first;
  7332. cm.display.view = [];
  7333. cm.display.viewOffset = 0;
  7334. }
  7335. function viewCuttingPoint(cm, oldN, newN, dir) {
  7336. var index = findViewIndex(cm, oldN), diff, view = cm.display.view;
  7337. if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
  7338. { return {index: index, lineN: newN} }
  7339. var n = cm.display.viewFrom;
  7340. for (var i = 0; i < index; i++)
  7341. { n += view[i].size; }
  7342. if (n != oldN) {
  7343. if (dir > 0) {
  7344. if (index == view.length - 1) { return null }
  7345. diff = (n + view[index].size) - oldN;
  7346. index++;
  7347. } else {
  7348. diff = n - oldN;
  7349. }
  7350. oldN += diff; newN += diff;
  7351. }
  7352. while (visualLineNo(cm.doc, newN) != newN) {
  7353. if (index == (dir < 0 ? 0 : view.length - 1)) { return null }
  7354. newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
  7355. index += dir;
  7356. }
  7357. return {index: index, lineN: newN}
  7358. }
  7359. // Force the view to cover a given range, adding empty view element
  7360. // or clipping off existing ones as needed.
  7361. function adjustView(cm, from, to) {
  7362. var display = cm.display, view = display.view;
  7363. if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
  7364. display.view = buildViewArray(cm, from, to);
  7365. display.viewFrom = from;
  7366. } else {
  7367. if (display.viewFrom > from)
  7368. { display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view); }
  7369. else if (display.viewFrom < from)
  7370. { display.view = display.view.slice(findViewIndex(cm, from)); }
  7371. display.viewFrom = from;
  7372. if (display.viewTo < to)
  7373. { display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)); }
  7374. else if (display.viewTo > to)
  7375. { display.view = display.view.slice(0, findViewIndex(cm, to)); }
  7376. }
  7377. display.viewTo = to;
  7378. }
  7379. // Count the number of lines in the view whose DOM representation is
  7380. // out of date (or nonexistent).
  7381. function countDirtyView(cm) {
  7382. var view = cm.display.view, dirty = 0;
  7383. for (var i = 0; i < view.length; i++) {
  7384. var lineView = view[i];
  7385. if (!lineView.hidden && (!lineView.node || lineView.changes)) { ++dirty; }
  7386. }
  7387. return dirty
  7388. }
  7389. function updateSelection(cm) {
  7390. cm.display.input.showSelection(cm.display.input.prepareSelection());
  7391. }
  7392. function prepareSelection(cm, primary) {
  7393. if ( primary === void 0 ) primary = true;
  7394. var doc = cm.doc, result = {};
  7395. var curFragment = result.cursors = document.createDocumentFragment();
  7396. var selFragment = result.selection = document.createDocumentFragment();
  7397. for (var i = 0; i < doc.sel.ranges.length; i++) {
  7398. if (!primary && i == doc.sel.primIndex) { continue }
  7399. var range = doc.sel.ranges[i];
  7400. if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) { continue }
  7401. var collapsed = range.empty();
  7402. if (collapsed || cm.options.showCursorWhenSelecting)
  7403. { drawSelectionCursor(cm, range.head, curFragment); }
  7404. if (!collapsed)
  7405. { drawSelectionRange(cm, range, selFragment); }
  7406. }
  7407. return result
  7408. }
  7409. // Draws a cursor for the given range
  7410. function drawSelectionCursor(cm, head, output) {
  7411. var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine);
  7412. var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
  7413. cursor.style.left = pos.left + "px";
  7414. cursor.style.top = pos.top + "px";
  7415. cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
  7416. if (pos.other) {
  7417. // Secondary cursor, shown when on a 'jump' in bi-directional text
  7418. var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
  7419. otherCursor.style.display = "";
  7420. otherCursor.style.left = pos.other.left + "px";
  7421. otherCursor.style.top = pos.other.top + "px";
  7422. otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
  7423. }
  7424. }
  7425. function cmpCoords(a, b) { return a.top - b.top || a.left - b.left }
  7426. // Draws the given range as a highlighted selection
  7427. function drawSelectionRange(cm, range, output) {
  7428. var display = cm.display, doc = cm.doc;
  7429. var fragment = document.createDocumentFragment();
  7430. var padding = paddingH(cm.display), leftSide = padding.left;
  7431. var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right;
  7432. var docLTR = doc.direction == "ltr";
  7433. function add(left, top, width, bottom) {
  7434. if (top < 0) { top = 0; }
  7435. top = Math.round(top);
  7436. bottom = Math.round(bottom);
  7437. fragment.appendChild(elt("div", null, "CodeMirror-selected", ("position: absolute; left: " + left + "px;\n top: " + top + "px; width: " + (width == null ? rightSide - left : width) + "px;\n height: " + (bottom - top) + "px")));
  7438. }
  7439. function drawForLine(line, fromArg, toArg) {
  7440. var lineObj = getLine(doc, line);
  7441. var lineLen = lineObj.text.length;
  7442. var start, end;
  7443. function coords(ch, bias) {
  7444. return charCoords(cm, Pos(line, ch), "div", lineObj, bias)
  7445. }
  7446. function wrapX(pos, dir, side) {
  7447. var extent = wrappedLineExtentChar(cm, lineObj, null, pos);
  7448. var prop = (dir == "ltr") == (side == "after") ? "left" : "right";
  7449. var ch = side == "after" ? extent.begin : extent.end - (/\s/.test(lineObj.text.charAt(extent.end - 1)) ? 2 : 1);
  7450. return coords(ch, prop)[prop]
  7451. }
  7452. var order = getOrder(lineObj, doc.direction);
  7453. iterateBidiSections(order, fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir, i) {
  7454. var ltr = dir == "ltr";
  7455. var fromPos = coords(from, ltr ? "left" : "right");
  7456. var toPos = coords(to - 1, ltr ? "right" : "left");
  7457. var openStart = fromArg == null && from == 0, openEnd = toArg == null && to == lineLen;
  7458. var first = i == 0, last = !order || i == order.length - 1;
  7459. if (toPos.top - fromPos.top <= 3) { // Single line
  7460. var openLeft = (docLTR ? openStart : openEnd) && first;
  7461. var openRight = (docLTR ? openEnd : openStart) && last;
  7462. var left = openLeft ? leftSide : (ltr ? fromPos : toPos).left;
  7463. var right = openRight ? rightSide : (ltr ? toPos : fromPos).right;
  7464. add(left, fromPos.top, right - left, fromPos.bottom);
  7465. } else { // Multiple lines
  7466. var topLeft, topRight, botLeft, botRight;
  7467. if (ltr) {
  7468. topLeft = docLTR && openStart && first ? leftSide : fromPos.left;
  7469. topRight = docLTR ? rightSide : wrapX(from, dir, "before");
  7470. botLeft = docLTR ? leftSide : wrapX(to, dir, "after");
  7471. botRight = docLTR && openEnd && last ? rightSide : toPos.right;
  7472. } else {
  7473. topLeft = !docLTR ? leftSide : wrapX(from, dir, "before");
  7474. topRight = !docLTR && openStart && first ? rightSide : fromPos.right;
  7475. botLeft = !docLTR && openEnd && last ? leftSide : toPos.left;
  7476. botRight = !docLTR ? rightSide : wrapX(to, dir, "after");
  7477. }
  7478. add(topLeft, fromPos.top, topRight - topLeft, fromPos.bottom);
  7479. if (fromPos.bottom < toPos.top) { add(leftSide, fromPos.bottom, null, toPos.top); }
  7480. add(botLeft, toPos.top, botRight - botLeft, toPos.bottom);
  7481. }
  7482. if (!start || cmpCoords(fromPos, start) < 0) { start = fromPos; }
  7483. if (cmpCoords(toPos, start) < 0) { start = toPos; }
  7484. if (!end || cmpCoords(fromPos, end) < 0) { end = fromPos; }
  7485. if (cmpCoords(toPos, end) < 0) { end = toPos; }
  7486. });
  7487. return {start: start, end: end}
  7488. }
  7489. var sFrom = range.from(), sTo = range.to();
  7490. if (sFrom.line == sTo.line) {
  7491. drawForLine(sFrom.line, sFrom.ch, sTo.ch);
  7492. } else {
  7493. var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);
  7494. var singleVLine = visualLine(fromLine) == visualLine(toLine);
  7495. var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
  7496. var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
  7497. if (singleVLine) {
  7498. if (leftEnd.top < rightStart.top - 2) {
  7499. add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
  7500. add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
  7501. } else {
  7502. add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
  7503. }
  7504. }
  7505. if (leftEnd.bottom < rightStart.top)
  7506. { add(leftSide, leftEnd.bottom, null, rightStart.top); }
  7507. }
  7508. output.appendChild(fragment);
  7509. }
  7510. // Cursor-blinking
  7511. function restartBlink(cm) {
  7512. if (!cm.state.focused) { return }
  7513. var display = cm.display;
  7514. clearInterval(display.blinker);
  7515. var on = true;
  7516. display.cursorDiv.style.visibility = "";
  7517. if (cm.options.cursorBlinkRate > 0)
  7518. { display.blinker = setInterval(function () {
  7519. if (!cm.hasFocus()) { onBlur(cm); }
  7520. display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden";
  7521. }, cm.options.cursorBlinkRate); }
  7522. else if (cm.options.cursorBlinkRate < 0)
  7523. { display.cursorDiv.style.visibility = "hidden"; }
  7524. }
  7525. function ensureFocus(cm) {
  7526. if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
  7527. }
  7528. function delayBlurEvent(cm) {
  7529. cm.state.delayingBlurEvent = true;
  7530. setTimeout(function () { if (cm.state.delayingBlurEvent) {
  7531. cm.state.delayingBlurEvent = false;
  7532. onBlur(cm);
  7533. } }, 100);
  7534. }
  7535. function onFocus(cm, e) {
  7536. if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false; }
  7537. if (cm.options.readOnly == "nocursor") { return }
  7538. if (!cm.state.focused) {
  7539. signal(cm, "focus", cm, e);
  7540. cm.state.focused = true;
  7541. addClass(cm.display.wrapper, "CodeMirror-focused");
  7542. // This test prevents this from firing when a context
  7543. // menu is closed (since the input reset would kill the
  7544. // select-all detection hack)
  7545. if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
  7546. cm.display.input.reset();
  7547. if (webkit) { setTimeout(function () { return cm.display.input.reset(true); }, 20); } // Issue #1730
  7548. }
  7549. cm.display.input.receivedFocus();
  7550. }
  7551. restartBlink(cm);
  7552. }
  7553. function onBlur(cm, e) {
  7554. if (cm.state.delayingBlurEvent) { return }
  7555. if (cm.state.focused) {
  7556. signal(cm, "blur", cm, e);
  7557. cm.state.focused = false;
  7558. rmClass(cm.display.wrapper, "CodeMirror-focused");
  7559. }
  7560. clearInterval(cm.display.blinker);
  7561. setTimeout(function () { if (!cm.state.focused) { cm.display.shift = false; } }, 150);
  7562. }
  7563. // Read the actual heights of the rendered lines, and update their
  7564. // stored heights to match.
  7565. function updateHeightsInViewport(cm) {
  7566. var display = cm.display;
  7567. var prevBottom = display.lineDiv.offsetTop;
  7568. for (var i = 0; i < display.view.length; i++) {
  7569. var cur = display.view[i], wrapping = cm.options.lineWrapping;
  7570. var height = (void 0), width = 0;
  7571. if (cur.hidden) { continue }
  7572. if (ie && ie_version < 8) {
  7573. var bot = cur.node.offsetTop + cur.node.offsetHeight;
  7574. height = bot - prevBottom;
  7575. prevBottom = bot;
  7576. } else {
  7577. var box = cur.node.getBoundingClientRect();
  7578. height = box.bottom - box.top;
  7579. // Check that lines don't extend past the right of the current
  7580. // editor width
  7581. if (!wrapping && cur.text.firstChild)
  7582. { width = cur.text.firstChild.getBoundingClientRect().right - box.left - 1; }
  7583. }
  7584. var diff = cur.line.height - height;
  7585. if (diff > .005 || diff < -.005) {
  7586. updateLineHeight(cur.line, height);
  7587. updateWidgetHeight(cur.line);
  7588. if (cur.rest) { for (var j = 0; j < cur.rest.length; j++)
  7589. { updateWidgetHeight(cur.rest[j]); } }
  7590. }
  7591. if (width > cm.display.sizerWidth) {
  7592. var chWidth = Math.ceil(width / charWidth(cm.display));
  7593. if (chWidth > cm.display.maxLineLength) {
  7594. cm.display.maxLineLength = chWidth;
  7595. cm.display.maxLine = cur.line;
  7596. cm.display.maxLineChanged = true;
  7597. }
  7598. }
  7599. }
  7600. }
  7601. // Read and store the height of line widgets associated with the
  7602. // given line.
  7603. function updateWidgetHeight(line) {
  7604. if (line.widgets) { for (var i = 0; i < line.widgets.length; ++i) {
  7605. var w = line.widgets[i], parent = w.node.parentNode;
  7606. if (parent) { w.height = parent.offsetHeight; }
  7607. } }
  7608. }
  7609. // Compute the lines that are visible in a given viewport (defaults
  7610. // the the current scroll position). viewport may contain top,
  7611. // height, and ensure (see op.scrollToPos) properties.
  7612. function visibleLines(display, doc, viewport) {
  7613. var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
  7614. top = Math.floor(top - paddingTop(display));
  7615. var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
  7616. var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
  7617. // Ensure is a {from: {line, ch}, to: {line, ch}} object, and
  7618. // forces those lines into the viewport (if possible).
  7619. if (viewport && viewport.ensure) {
  7620. var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
  7621. if (ensureFrom < from) {
  7622. from = ensureFrom;
  7623. to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
  7624. } else if (Math.min(ensureTo, doc.lastLine()) >= to) {
  7625. from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
  7626. to = ensureTo;
  7627. }
  7628. }
  7629. return {from: from, to: Math.max(to, from + 1)}
  7630. }
  7631. // SCROLLING THINGS INTO VIEW
  7632. // If an editor sits on the top or bottom of the window, partially
  7633. // scrolled out of view, this ensures that the cursor is visible.
  7634. function maybeScrollWindow(cm, rect) {
  7635. if (signalDOMEvent(cm, "scrollCursorIntoView")) { return }
  7636. var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
  7637. if (rect.top + box.top < 0) { doScroll = true; }
  7638. else if (rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false; }
  7639. if (doScroll != null && !phantom) {
  7640. var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (rect.left) + "px; width: " + (Math.max(2, rect.right - rect.left)) + "px;"));
  7641. cm.display.lineSpace.appendChild(scrollNode);
  7642. scrollNode.scrollIntoView(doScroll);
  7643. cm.display.lineSpace.removeChild(scrollNode);
  7644. }
  7645. }
  7646. // Scroll a given position into view (immediately), verifying that
  7647. // it actually became visible (as line heights are accurately
  7648. // measured, the position of something may 'drift' during drawing).
  7649. function scrollPosIntoView(cm, pos, end, margin) {
  7650. if (margin == null) { margin = 0; }
  7651. var rect;
  7652. if (!cm.options.lineWrapping && pos == end) {
  7653. // Set pos and end to the cursor positions around the character pos sticks to
  7654. // If pos.sticky == "before", that is around pos.ch - 1, otherwise around pos.ch
  7655. // If pos == Pos(_, 0, "before"), pos and end are unchanged
  7656. pos = pos.ch ? Pos(pos.line, pos.sticky == "before" ? pos.ch - 1 : pos.ch, "after") : pos;
  7657. end = pos.sticky == "before" ? Pos(pos.line, pos.ch + 1, "before") : pos;
  7658. }
  7659. for (var limit = 0; limit < 5; limit++) {
  7660. var changed = false;
  7661. var coords = cursorCoords(cm, pos);
  7662. var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
  7663. rect = {left: Math.min(coords.left, endCoords.left),
  7664. top: Math.min(coords.top, endCoords.top) - margin,
  7665. right: Math.max(coords.left, endCoords.left),
  7666. bottom: Math.max(coords.bottom, endCoords.bottom) + margin};
  7667. var scrollPos = calculateScrollPos(cm, rect);
  7668. var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;
  7669. if (scrollPos.scrollTop != null) {
  7670. updateScrollTop(cm, scrollPos.scrollTop);
  7671. if (Math.abs(cm.doc.scrollTop - startTop) > 1) { changed = true; }
  7672. }
  7673. if (scrollPos.scrollLeft != null) {
  7674. setScrollLeft(cm, scrollPos.scrollLeft);
  7675. if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) { changed = true; }
  7676. }
  7677. if (!changed) { break }
  7678. }
  7679. return rect
  7680. }
  7681. // Scroll a given set of coordinates into view (immediately).
  7682. function scrollIntoView(cm, rect) {
  7683. var scrollPos = calculateScrollPos(cm, rect);
  7684. if (scrollPos.scrollTop != null) { updateScrollTop(cm, scrollPos.scrollTop); }
  7685. if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft); }
  7686. }
  7687. // Calculate a new scroll position needed to scroll the given
  7688. // rectangle into view. Returns an object with scrollTop and
  7689. // scrollLeft properties. When these are undefined, the
  7690. // vertical/horizontal position does not need to be adjusted.
  7691. function calculateScrollPos(cm, rect) {
  7692. var display = cm.display, snapMargin = textHeight(cm.display);
  7693. if (rect.top < 0) { rect.top = 0; }
  7694. var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop;
  7695. var screen = displayHeight(cm), result = {};
  7696. if (rect.bottom - rect.top > screen) { rect.bottom = rect.top + screen; }
  7697. var docBottom = cm.doc.height + paddingVert(display);
  7698. var atTop = rect.top < snapMargin, atBottom = rect.bottom > docBottom - snapMargin;
  7699. if (rect.top < screentop) {
  7700. result.scrollTop = atTop ? 0 : rect.top;
  7701. } else if (rect.bottom > screentop + screen) {
  7702. var newTop = Math.min(rect.top, (atBottom ? docBottom : rect.bottom) - screen);
  7703. if (newTop != screentop) { result.scrollTop = newTop; }
  7704. }
  7705. var gutterSpace = cm.options.fixedGutter ? 0 : display.gutters.offsetWidth;
  7706. var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft - gutterSpace;
  7707. var screenw = displayWidth(cm) - display.gutters.offsetWidth;
  7708. var tooWide = rect.right - rect.left > screenw;
  7709. if (tooWide) { rect.right = rect.left + screenw; }
  7710. if (rect.left < 10)
  7711. { result.scrollLeft = 0; }
  7712. else if (rect.left < screenleft)
  7713. { result.scrollLeft = Math.max(0, rect.left + gutterSpace - (tooWide ? 0 : 10)); }
  7714. else if (rect.right > screenw + screenleft - 3)
  7715. { result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw; }
  7716. return result
  7717. }
  7718. // Store a relative adjustment to the scroll position in the current
  7719. // operation (to be applied when the operation finishes).
  7720. function addToScrollTop(cm, top) {
  7721. if (top == null) { return }
  7722. resolveScrollToPos(cm);
  7723. cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top;
  7724. }
  7725. // Make sure that at the end of the operation the current cursor is
  7726. // shown.
  7727. function ensureCursorVisible(cm) {
  7728. resolveScrollToPos(cm);
  7729. var cur = cm.getCursor();
  7730. cm.curOp.scrollToPos = {from: cur, to: cur, margin: cm.options.cursorScrollMargin};
  7731. }
  7732. function scrollToCoords(cm, x, y) {
  7733. if (x != null || y != null) { resolveScrollToPos(cm); }
  7734. if (x != null) { cm.curOp.scrollLeft = x; }
  7735. if (y != null) { cm.curOp.scrollTop = y; }
  7736. }
  7737. function scrollToRange(cm, range) {
  7738. resolveScrollToPos(cm);
  7739. cm.curOp.scrollToPos = range;
  7740. }
  7741. // When an operation has its scrollToPos property set, and another
  7742. // scroll action is applied before the end of the operation, this
  7743. // 'simulates' scrolling that position into view in a cheap way, so
  7744. // that the effect of intermediate scroll commands is not ignored.
  7745. function resolveScrollToPos(cm) {
  7746. var range = cm.curOp.scrollToPos;
  7747. if (range) {
  7748. cm.curOp.scrollToPos = null;
  7749. var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to);
  7750. scrollToCoordsRange(cm, from, to, range.margin);
  7751. }
  7752. }
  7753. function scrollToCoordsRange(cm, from, to, margin) {
  7754. var sPos = calculateScrollPos(cm, {
  7755. left: Math.min(from.left, to.left),
  7756. top: Math.min(from.top, to.top) - margin,
  7757. right: Math.max(from.right, to.right),
  7758. bottom: Math.max(from.bottom, to.bottom) + margin
  7759. });
  7760. scrollToCoords(cm, sPos.scrollLeft, sPos.scrollTop);
  7761. }
  7762. // Sync the scrollable area and scrollbars, ensure the viewport
  7763. // covers the visible area.
  7764. function updateScrollTop(cm, val) {
  7765. if (Math.abs(cm.doc.scrollTop - val) < 2) { return }
  7766. if (!gecko) { updateDisplaySimple(cm, {top: val}); }
  7767. setScrollTop(cm, val, true);
  7768. if (gecko) { updateDisplaySimple(cm); }
  7769. startWorker(cm, 100);
  7770. }
  7771. function setScrollTop(cm, val, forceScroll) {
  7772. val = Math.max(0, Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val));
  7773. if (cm.display.scroller.scrollTop == val && !forceScroll) { return }
  7774. cm.doc.scrollTop = val;
  7775. cm.display.scrollbars.setScrollTop(val);
  7776. if (cm.display.scroller.scrollTop != val) { cm.display.scroller.scrollTop = val; }
  7777. }
  7778. // Sync scroller and scrollbar, ensure the gutter elements are
  7779. // aligned.
  7780. function setScrollLeft(cm, val, isScroller, forceScroll) {
  7781. val = Math.max(0, Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth));
  7782. if ((isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) && !forceScroll) { return }
  7783. cm.doc.scrollLeft = val;
  7784. alignHorizontally(cm);
  7785. if (cm.display.scroller.scrollLeft != val) { cm.display.scroller.scrollLeft = val; }
  7786. cm.display.scrollbars.setScrollLeft(val);
  7787. }
  7788. // SCROLLBARS
  7789. // Prepare DOM reads needed to update the scrollbars. Done in one
  7790. // shot to minimize update/measure roundtrips.
  7791. function measureForScrollbars(cm) {
  7792. var d = cm.display, gutterW = d.gutters.offsetWidth;
  7793. var docH = Math.round(cm.doc.height + paddingVert(cm.display));
  7794. return {
  7795. clientHeight: d.scroller.clientHeight,
  7796. viewHeight: d.wrapper.clientHeight,
  7797. scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
  7798. viewWidth: d.wrapper.clientWidth,
  7799. barLeft: cm.options.fixedGutter ? gutterW : 0,
  7800. docHeight: docH,
  7801. scrollHeight: docH + scrollGap(cm) + d.barHeight,
  7802. nativeBarWidth: d.nativeBarWidth,
  7803. gutterWidth: gutterW
  7804. }
  7805. }
  7806. var NativeScrollbars = function(place, scroll, cm) {
  7807. this.cm = cm;
  7808. var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
  7809. var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
  7810. vert.tabIndex = horiz.tabIndex = -1;
  7811. place(vert); place(horiz);
  7812. on(vert, "scroll", function () {
  7813. if (vert.clientHeight) { scroll(vert.scrollTop, "vertical"); }
  7814. });
  7815. on(horiz, "scroll", function () {
  7816. if (horiz.clientWidth) { scroll(horiz.scrollLeft, "horizontal"); }
  7817. });
  7818. this.checkedZeroWidth = false;
  7819. // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
  7820. if (ie && ie_version < 8) { this.horiz.style.minHeight = this.vert.style.minWidth = "18px"; }
  7821. };
  7822. NativeScrollbars.prototype.update = function (measure) {
  7823. var needsH = measure.scrollWidth > measure.clientWidth + 1;
  7824. var needsV = measure.scrollHeight > measure.clientHeight + 1;
  7825. var sWidth = measure.nativeBarWidth;
  7826. if (needsV) {
  7827. this.vert.style.display = "block";
  7828. this.vert.style.bottom = needsH ? sWidth + "px" : "0";
  7829. var totalHeight = measure.viewHeight - (needsH ? sWidth : 0);
  7830. // A bug in IE8 can cause this value to be negative, so guard it.
  7831. this.vert.firstChild.style.height =
  7832. Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
  7833. } else {
  7834. this.vert.style.display = "";
  7835. this.vert.firstChild.style.height = "0";
  7836. }
  7837. if (needsH) {
  7838. this.horiz.style.display = "block";
  7839. this.horiz.style.right = needsV ? sWidth + "px" : "0";
  7840. this.horiz.style.left = measure.barLeft + "px";
  7841. var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0);
  7842. this.horiz.firstChild.style.width =
  7843. Math.max(0, measure.scrollWidth - measure.clientWidth + totalWidth) + "px";
  7844. } else {
  7845. this.horiz.style.display = "";
  7846. this.horiz.firstChild.style.width = "0";
  7847. }
  7848. if (!this.checkedZeroWidth && measure.clientHeight > 0) {
  7849. if (sWidth == 0) { this.zeroWidthHack(); }
  7850. this.checkedZeroWidth = true;
  7851. }
  7852. return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0}
  7853. };
  7854. NativeScrollbars.prototype.setScrollLeft = function (pos) {
  7855. if (this.horiz.scrollLeft != pos) { this.horiz.scrollLeft = pos; }
  7856. if (this.disableHoriz) { this.enableZeroWidthBar(this.horiz, this.disableHoriz, "horiz"); }
  7857. };
  7858. NativeScrollbars.prototype.setScrollTop = function (pos) {
  7859. if (this.vert.scrollTop != pos) { this.vert.scrollTop = pos; }
  7860. if (this.disableVert) { this.enableZeroWidthBar(this.vert, this.disableVert, "vert"); }
  7861. };
  7862. NativeScrollbars.prototype.zeroWidthHack = function () {
  7863. var w = mac && !mac_geMountainLion ? "12px" : "18px";
  7864. this.horiz.style.height = this.vert.style.width = w;
  7865. this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none";
  7866. this.disableHoriz = new Delayed;
  7867. this.disableVert = new Delayed;
  7868. };
  7869. NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay, type) {
  7870. bar.style.pointerEvents = "auto";
  7871. function maybeDisable() {
  7872. // To find out whether the scrollbar is still visible, we
  7873. // check whether the element under the pixel in the bottom
  7874. // right corner of the scrollbar box is the scrollbar box
  7875. // itself (when the bar is still visible) or its filler child
  7876. // (when the bar is hidden). If it is still visible, we keep
  7877. // it enabled, if it's hidden, we disable pointer events.
  7878. var box = bar.getBoundingClientRect();
  7879. var elt = type == "vert" ? document.elementFromPoint(box.right - 1, (box.top + box.bottom) / 2)
  7880. : document.elementFromPoint((box.right + box.left) / 2, box.bottom - 1);
  7881. if (elt != bar) { bar.style.pointerEvents = "none"; }
  7882. else { delay.set(1000, maybeDisable); }
  7883. }
  7884. delay.set(1000, maybeDisable);
  7885. };
  7886. NativeScrollbars.prototype.clear = function () {
  7887. var parent = this.horiz.parentNode;
  7888. parent.removeChild(this.horiz);
  7889. parent.removeChild(this.vert);
  7890. };
  7891. var NullScrollbars = function () {};
  7892. NullScrollbars.prototype.update = function () { return {bottom: 0, right: 0} };
  7893. NullScrollbars.prototype.setScrollLeft = function () {};
  7894. NullScrollbars.prototype.setScrollTop = function () {};
  7895. NullScrollbars.prototype.clear = function () {};
  7896. function updateScrollbars(cm, measure) {
  7897. if (!measure) { measure = measureForScrollbars(cm); }
  7898. var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;
  7899. updateScrollbarsInner(cm, measure);
  7900. for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
  7901. if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
  7902. { updateHeightsInViewport(cm); }
  7903. updateScrollbarsInner(cm, measureForScrollbars(cm));
  7904. startWidth = cm.display.barWidth; startHeight = cm.display.barHeight;
  7905. }
  7906. }
  7907. // Re-synchronize the fake scrollbars with the actual size of the
  7908. // content.
  7909. function updateScrollbarsInner(cm, measure) {
  7910. var d = cm.display;
  7911. var sizes = d.scrollbars.update(measure);
  7912. d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
  7913. d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
  7914. d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent";
  7915. if (sizes.right && sizes.bottom) {
  7916. d.scrollbarFiller.style.display = "block";
  7917. d.scrollbarFiller.style.height = sizes.bottom + "px";
  7918. d.scrollbarFiller.style.width = sizes.right + "px";
  7919. } else { d.scrollbarFiller.style.display = ""; }
  7920. if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
  7921. d.gutterFiller.style.display = "block";
  7922. d.gutterFiller.style.height = sizes.bottom + "px";
  7923. d.gutterFiller.style.width = measure.gutterWidth + "px";
  7924. } else { d.gutterFiller.style.display = ""; }
  7925. }
  7926. var scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars};
  7927. function initScrollbars(cm) {
  7928. if (cm.display.scrollbars) {
  7929. cm.display.scrollbars.clear();
  7930. if (cm.display.scrollbars.addClass)
  7931. { rmClass(cm.display.wrapper, cm.display.scrollbars.addClass); }
  7932. }
  7933. cm.display.scrollbars = new scrollbarModel[cm.options.scrollbarStyle](function (node) {
  7934. cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
  7935. // Prevent clicks in the scrollbars from killing focus
  7936. on(node, "mousedown", function () {
  7937. if (cm.state.focused) { setTimeout(function () { return cm.display.input.focus(); }, 0); }
  7938. });
  7939. node.setAttribute("cm-not-content", "true");
  7940. }, function (pos, axis) {
  7941. if (axis == "horizontal") { setScrollLeft(cm, pos); }
  7942. else { updateScrollTop(cm, pos); }
  7943. }, cm);
  7944. if (cm.display.scrollbars.addClass)
  7945. { addClass(cm.display.wrapper, cm.display.scrollbars.addClass); }
  7946. }
  7947. // Operations are used to wrap a series of changes to the editor
  7948. // state in such a way that each change won't have to update the
  7949. // cursor and display (which would be awkward, slow, and
  7950. // error-prone). Instead, display updates are batched and then all
  7951. // combined and executed at once.
  7952. var nextOpId = 0;
  7953. // Start a new operation.
  7954. function startOperation(cm) {
  7955. cm.curOp = {
  7956. cm: cm,
  7957. viewChanged: false, // Flag that indicates that lines might need to be redrawn
  7958. startHeight: cm.doc.height, // Used to detect need to update scrollbar
  7959. forceUpdate: false, // Used to force a redraw
  7960. updateInput: 0, // Whether to reset the input textarea
  7961. typing: false, // Whether this reset should be careful to leave existing text (for compositing)
  7962. changeObjs: null, // Accumulated changes, for firing change events
  7963. cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
  7964. cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already
  7965. selectionChanged: false, // Whether the selection needs to be redrawn
  7966. updateMaxLine: false, // Set when the widest line needs to be determined anew
  7967. scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
  7968. scrollToPos: null, // Used to scroll to a specific position
  7969. focus: false,
  7970. id: ++nextOpId // Unique ID
  7971. };
  7972. pushOperation(cm.curOp);
  7973. }
  7974. // Finish an operation, updating the display and signalling delayed events
  7975. function endOperation(cm) {
  7976. var op = cm.curOp;
  7977. if (op) { finishOperation(op, function (group) {
  7978. for (var i = 0; i < group.ops.length; i++)
  7979. { group.ops[i].cm.curOp = null; }
  7980. endOperations(group);
  7981. }); }
  7982. }
  7983. // The DOM updates done when an operation finishes are batched so
  7984. // that the minimum number of relayouts are required.
  7985. function endOperations(group) {
  7986. var ops = group.ops;
  7987. for (var i = 0; i < ops.length; i++) // Read DOM
  7988. { endOperation_R1(ops[i]); }
  7989. for (var i$1 = 0; i$1 < ops.length; i$1++) // Write DOM (maybe)
  7990. { endOperation_W1(ops[i$1]); }
  7991. for (var i$2 = 0; i$2 < ops.length; i$2++) // Read DOM
  7992. { endOperation_R2(ops[i$2]); }
  7993. for (var i$3 = 0; i$3 < ops.length; i$3++) // Write DOM (maybe)
  7994. { endOperation_W2(ops[i$3]); }
  7995. for (var i$4 = 0; i$4 < ops.length; i$4++) // Read DOM
  7996. { endOperation_finish(ops[i$4]); }
  7997. }
  7998. function endOperation_R1(op) {
  7999. var cm = op.cm, display = cm.display;
  8000. maybeClipScrollbars(cm);
  8001. if (op.updateMaxLine) { findMaxLine(cm); }
  8002. op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null ||
  8003. op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||
  8004. op.scrollToPos.to.line >= display.viewTo) ||
  8005. display.maxLineChanged && cm.options.lineWrapping;
  8006. op.update = op.mustUpdate &&
  8007. new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate);
  8008. }
  8009. function endOperation_W1(op) {
  8010. op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update);
  8011. }
  8012. function endOperation_R2(op) {
  8013. var cm = op.cm, display = cm.display;
  8014. if (op.updatedDisplay) { updateHeightsInViewport(cm); }
  8015. op.barMeasure = measureForScrollbars(cm);
  8016. // If the max line changed since it was last measured, measure it,
  8017. // and ensure the document's width matches it.
  8018. // updateDisplay_W2 will use these properties to do the actual resizing
  8019. if (display.maxLineChanged && !cm.options.lineWrapping) {
  8020. op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3;
  8021. cm.display.sizerWidth = op.adjustWidthTo;
  8022. op.barMeasure.scrollWidth =
  8023. Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth);
  8024. op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm));
  8025. }
  8026. if (op.updatedDisplay || op.selectionChanged)
  8027. { op.preparedSelection = display.input.prepareSelection(); }
  8028. }
  8029. function endOperation_W2(op) {
  8030. var cm = op.cm;
  8031. if (op.adjustWidthTo != null) {
  8032. cm.display.sizer.style.minWidth = op.adjustWidthTo + "px";
  8033. if (op.maxScrollLeft < cm.doc.scrollLeft)
  8034. { setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true); }
  8035. cm.display.maxLineChanged = false;
  8036. }
  8037. var takeFocus = op.focus && op.focus == activeElt();
  8038. if (op.preparedSelection)
  8039. { cm.display.input.showSelection(op.preparedSelection, takeFocus); }
  8040. if (op.updatedDisplay || op.startHeight != cm.doc.height)
  8041. { updateScrollbars(cm, op.barMeasure); }
  8042. if (op.updatedDisplay)
  8043. { setDocumentHeight(cm, op.barMeasure); }
  8044. if (op.selectionChanged) { restartBlink(cm); }
  8045. if (cm.state.focused && op.updateInput)
  8046. { cm.display.input.reset(op.typing); }
  8047. if (takeFocus) { ensureFocus(op.cm); }
  8048. }
  8049. function endOperation_finish(op) {
  8050. var cm = op.cm, display = cm.display, doc = cm.doc;
  8051. if (op.updatedDisplay) { postUpdateDisplay(cm, op.update); }
  8052. // Abort mouse wheel delta measurement, when scrolling explicitly
  8053. if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos))
  8054. { display.wheelStartX = display.wheelStartY = null; }
  8055. // Propagate the scroll position to the actual DOM scroller
  8056. if (op.scrollTop != null) { setScrollTop(cm, op.scrollTop, op.forceScroll); }
  8057. if (op.scrollLeft != null) { setScrollLeft(cm, op.scrollLeft, true, true); }
  8058. // If we need to scroll a specific position into view, do so.
  8059. if (op.scrollToPos) {
  8060. var rect = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),
  8061. clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin);
  8062. maybeScrollWindow(cm, rect);
  8063. }
  8064. // Fire events for markers that are hidden/unidden by editing or
  8065. // undoing
  8066. var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers;
  8067. if (hidden) { for (var i = 0; i < hidden.length; ++i)
  8068. { if (!hidden[i].lines.length) { signal(hidden[i], "hide"); } } }
  8069. if (unhidden) { for (var i$1 = 0; i$1 < unhidden.length; ++i$1)
  8070. { if (unhidden[i$1].lines.length) { signal(unhidden[i$1], "unhide"); } } }
  8071. if (display.wrapper.offsetHeight)
  8072. { doc.scrollTop = cm.display.scroller.scrollTop; }
  8073. // Fire change events, and delayed event handlers
  8074. if (op.changeObjs)
  8075. { signal(cm, "changes", cm, op.changeObjs); }
  8076. if (op.update)
  8077. { op.update.finish(); }
  8078. }
  8079. // Run the given function in an operation
  8080. function runInOp(cm, f) {
  8081. if (cm.curOp) { return f() }
  8082. startOperation(cm);
  8083. try { return f() }
  8084. finally { endOperation(cm); }
  8085. }
  8086. // Wraps a function in an operation. Returns the wrapped function.
  8087. function operation(cm, f) {
  8088. return function() {
  8089. if (cm.curOp) { return f.apply(cm, arguments) }
  8090. startOperation(cm);
  8091. try { return f.apply(cm, arguments) }
  8092. finally { endOperation(cm); }
  8093. }
  8094. }
  8095. // Used to add methods to editor and doc instances, wrapping them in
  8096. // operations.
  8097. function methodOp(f) {
  8098. return function() {
  8099. if (this.curOp) { return f.apply(this, arguments) }
  8100. startOperation(this);
  8101. try { return f.apply(this, arguments) }
  8102. finally { endOperation(this); }
  8103. }
  8104. }
  8105. function docMethodOp(f) {
  8106. return function() {
  8107. var cm = this.cm;
  8108. if (!cm || cm.curOp) { return f.apply(this, arguments) }
  8109. startOperation(cm);
  8110. try { return f.apply(this, arguments) }
  8111. finally { endOperation(cm); }
  8112. }
  8113. }
  8114. // HIGHLIGHT WORKER
  8115. function startWorker(cm, time) {
  8116. if (cm.doc.highlightFrontier < cm.display.viewTo)
  8117. { cm.state.highlight.set(time, bind(highlightWorker, cm)); }
  8118. }
  8119. function highlightWorker(cm) {
  8120. var doc = cm.doc;
  8121. if (doc.highlightFrontier >= cm.display.viewTo) { return }
  8122. var end = +new Date + cm.options.workTime;
  8123. var context = getContextBefore(cm, doc.highlightFrontier);
  8124. var changedLines = [];
  8125. doc.iter(context.line, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function (line) {
  8126. if (context.line >= cm.display.viewFrom) { // Visible
  8127. var oldStyles = line.styles;
  8128. var resetState = line.text.length > cm.options.maxHighlightLength ? copyState(doc.mode, context.state) : null;
  8129. var highlighted = highlightLine(cm, line, context, true);
  8130. if (resetState) { context.state = resetState; }
  8131. line.styles = highlighted.styles;
  8132. var oldCls = line.styleClasses, newCls = highlighted.classes;
  8133. if (newCls) { line.styleClasses = newCls; }
  8134. else if (oldCls) { line.styleClasses = null; }
  8135. var ischange = !oldStyles || oldStyles.length != line.styles.length ||
  8136. oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
  8137. for (var i = 0; !ischange && i < oldStyles.length; ++i) { ischange = oldStyles[i] != line.styles[i]; }
  8138. if (ischange) { changedLines.push(context.line); }
  8139. line.stateAfter = context.save();
  8140. context.nextLine();
  8141. } else {
  8142. if (line.text.length <= cm.options.maxHighlightLength)
  8143. { processLine(cm, line.text, context); }
  8144. line.stateAfter = context.line % 5 == 0 ? context.save() : null;
  8145. context.nextLine();
  8146. }
  8147. if (+new Date > end) {
  8148. startWorker(cm, cm.options.workDelay);
  8149. return true
  8150. }
  8151. });
  8152. doc.highlightFrontier = context.line;
  8153. doc.modeFrontier = Math.max(doc.modeFrontier, context.line);
  8154. if (changedLines.length) { runInOp(cm, function () {
  8155. for (var i = 0; i < changedLines.length; i++)
  8156. { regLineChange(cm, changedLines[i], "text"); }
  8157. }); }
  8158. }
  8159. // DISPLAY DRAWING
  8160. var DisplayUpdate = function(cm, viewport, force) {
  8161. var display = cm.display;
  8162. this.viewport = viewport;
  8163. // Store some values that we'll need later (but don't want to force a relayout for)
  8164. this.visible = visibleLines(display, cm.doc, viewport);
  8165. this.editorIsHidden = !display.wrapper.offsetWidth;
  8166. this.wrapperHeight = display.wrapper.clientHeight;
  8167. this.wrapperWidth = display.wrapper.clientWidth;
  8168. this.oldDisplayWidth = displayWidth(cm);
  8169. this.force = force;
  8170. this.dims = getDimensions(cm);
  8171. this.events = [];
  8172. };
  8173. DisplayUpdate.prototype.signal = function (emitter, type) {
  8174. if (hasHandler(emitter, type))
  8175. { this.events.push(arguments); }
  8176. };
  8177. DisplayUpdate.prototype.finish = function () {
  8178. for (var i = 0; i < this.events.length; i++)
  8179. { signal.apply(null, this.events[i]); }
  8180. };
  8181. function maybeClipScrollbars(cm) {
  8182. var display = cm.display;
  8183. if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
  8184. display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
  8185. display.heightForcer.style.height = scrollGap(cm) + "px";
  8186. display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
  8187. display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
  8188. display.scrollbarsClipped = true;
  8189. }
  8190. }
  8191. function selectionSnapshot(cm) {
  8192. if (cm.hasFocus()) { return null }
  8193. var active = activeElt();
  8194. if (!active || !contains(cm.display.lineDiv, active)) { return null }
  8195. var result = {activeElt: active};
  8196. if (window.getSelection) {
  8197. var sel = window.getSelection();
  8198. if (sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode)) {
  8199. result.anchorNode = sel.anchorNode;
  8200. result.anchorOffset = sel.anchorOffset;
  8201. result.focusNode = sel.focusNode;
  8202. result.focusOffset = sel.focusOffset;
  8203. }
  8204. }
  8205. return result
  8206. }
  8207. function restoreSelection(snapshot) {
  8208. if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) { return }
  8209. snapshot.activeElt.focus();
  8210. if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) &&
  8211. snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
  8212. var sel = window.getSelection(), range = document.createRange();
  8213. range.setEnd(snapshot.anchorNode, snapshot.anchorOffset);
  8214. range.collapse(false);
  8215. sel.removeAllRanges();
  8216. sel.addRange(range);
  8217. sel.extend(snapshot.focusNode, snapshot.focusOffset);
  8218. }
  8219. }
  8220. // Does the actual updating of the line display. Bails out
  8221. // (returning false) when there is nothing to be done and forced is
  8222. // false.
  8223. function updateDisplayIfNeeded(cm, update) {
  8224. var display = cm.display, doc = cm.doc;
  8225. if (update.editorIsHidden) {
  8226. resetView(cm);
  8227. return false
  8228. }
  8229. // Bail out if the visible area is already rendered and nothing changed.
  8230. if (!update.force &&
  8231. update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
  8232. (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
  8233. display.renderedView == display.view && countDirtyView(cm) == 0)
  8234. { return false }
  8235. if (maybeUpdateLineNumberWidth(cm)) {
  8236. resetView(cm);
  8237. update.dims = getDimensions(cm);
  8238. }
  8239. // Compute a suitable new viewport (from & to)
  8240. var end = doc.first + doc.size;
  8241. var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
  8242. var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
  8243. if (display.viewFrom < from && from - display.viewFrom < 20) { from = Math.max(doc.first, display.viewFrom); }
  8244. if (display.viewTo > to && display.viewTo - to < 20) { to = Math.min(end, display.viewTo); }
  8245. if (sawCollapsedSpans) {
  8246. from = visualLineNo(cm.doc, from);
  8247. to = visualLineEndNo(cm.doc, to);
  8248. }
  8249. var different = from != display.viewFrom || to != display.viewTo ||
  8250. display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
  8251. adjustView(cm, from, to);
  8252. display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
  8253. // Position the mover div to align with the current scroll position
  8254. cm.display.mover.style.top = display.viewOffset + "px";
  8255. var toUpdate = countDirtyView(cm);
  8256. if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
  8257. (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
  8258. { return false }
  8259. // For big changes, we hide the enclosing element during the
  8260. // update, since that speeds up the operations on most browsers.
  8261. var selSnapshot = selectionSnapshot(cm);
  8262. if (toUpdate > 4) { display.lineDiv.style.display = "none"; }
  8263. patchDisplay(cm, display.updateLineNumbers, update.dims);
  8264. if (toUpdate > 4) { display.lineDiv.style.display = ""; }
  8265. display.renderedView = display.view;
  8266. // There might have been a widget with a focused element that got
  8267. // hidden or updated, if so re-focus it.
  8268. restoreSelection(selSnapshot);
  8269. // Prevent selection and cursors from interfering with the scroll
  8270. // width and height.
  8271. removeChildren(display.cursorDiv);
  8272. removeChildren(display.selectionDiv);
  8273. display.gutters.style.height = display.sizer.style.minHeight = 0;
  8274. if (different) {
  8275. display.lastWrapHeight = update.wrapperHeight;
  8276. display.lastWrapWidth = update.wrapperWidth;
  8277. startWorker(cm, 400);
  8278. }
  8279. display.updateLineNumbers = null;
  8280. return true
  8281. }
  8282. function postUpdateDisplay(cm, update) {
  8283. var viewport = update.viewport;
  8284. for (var first = true;; first = false) {
  8285. if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
  8286. // Clip forced viewport to actual scrollable area.
  8287. if (viewport && viewport.top != null)
  8288. { viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)}; }
  8289. // Updated line heights might result in the drawn area not
  8290. // actually covering the viewport. Keep looping until it does.
  8291. update.visible = visibleLines(cm.display, cm.doc, viewport);
  8292. if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
  8293. { break }
  8294. } else if (first) {
  8295. update.visible = visibleLines(cm.display, cm.doc, viewport);
  8296. }
  8297. if (!updateDisplayIfNeeded(cm, update)) { break }
  8298. updateHeightsInViewport(cm);
  8299. var barMeasure = measureForScrollbars(cm);
  8300. updateSelection(cm);
  8301. updateScrollbars(cm, barMeasure);
  8302. setDocumentHeight(cm, barMeasure);
  8303. update.force = false;
  8304. }
  8305. update.signal(cm, "update", cm);
  8306. if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
  8307. update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
  8308. cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;
  8309. }
  8310. }
  8311. function updateDisplaySimple(cm, viewport) {
  8312. var update = new DisplayUpdate(cm, viewport);
  8313. if (updateDisplayIfNeeded(cm, update)) {
  8314. updateHeightsInViewport(cm);
  8315. postUpdateDisplay(cm, update);
  8316. var barMeasure = measureForScrollbars(cm);
  8317. updateSelection(cm);
  8318. updateScrollbars(cm, barMeasure);
  8319. setDocumentHeight(cm, barMeasure);
  8320. update.finish();
  8321. }
  8322. }
  8323. // Sync the actual display DOM structure with display.view, removing
  8324. // nodes for lines that are no longer in view, and creating the ones
  8325. // that are not there yet, and updating the ones that are out of
  8326. // date.
  8327. function patchDisplay(cm, updateNumbersFrom, dims) {
  8328. var display = cm.display, lineNumbers = cm.options.lineNumbers;
  8329. var container = display.lineDiv, cur = container.firstChild;
  8330. function rm(node) {
  8331. var next = node.nextSibling;
  8332. // Works around a throw-scroll bug in OS X Webkit
  8333. if (webkit && mac && cm.display.currentWheelTarget == node)
  8334. { node.style.display = "none"; }
  8335. else
  8336. { node.parentNode.removeChild(node); }
  8337. return next
  8338. }
  8339. var view = display.view, lineN = display.viewFrom;
  8340. // Loop over the elements in the view, syncing cur (the DOM nodes
  8341. // in display.lineDiv) with the view as we go.
  8342. for (var i = 0; i < view.length; i++) {
  8343. var lineView = view[i];
  8344. if (lineView.hidden) ; else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
  8345. var node = buildLineElement(cm, lineView, lineN, dims);
  8346. container.insertBefore(node, cur);
  8347. } else { // Already drawn
  8348. while (cur != lineView.node) { cur = rm(cur); }
  8349. var updateNumber = lineNumbers && updateNumbersFrom != null &&
  8350. updateNumbersFrom <= lineN && lineView.lineNumber;
  8351. if (lineView.changes) {
  8352. if (indexOf(lineView.changes, "gutter") > -1) { updateNumber = false; }
  8353. updateLineForChanges(cm, lineView, lineN, dims);
  8354. }
  8355. if (updateNumber) {
  8356. removeChildren(lineView.lineNumber);
  8357. lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
  8358. }
  8359. cur = lineView.node.nextSibling;
  8360. }
  8361. lineN += lineView.size;
  8362. }
  8363. while (cur) { cur = rm(cur); }
  8364. }
  8365. function updateGutterSpace(display) {
  8366. var width = display.gutters.offsetWidth;
  8367. display.sizer.style.marginLeft = width + "px";
  8368. }
  8369. function setDocumentHeight(cm, measure) {
  8370. cm.display.sizer.style.minHeight = measure.docHeight + "px";
  8371. cm.display.heightForcer.style.top = measure.docHeight + "px";
  8372. cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px";
  8373. }
  8374. // Re-align line numbers and gutter marks to compensate for
  8375. // horizontal scrolling.
  8376. function alignHorizontally(cm) {
  8377. var display = cm.display, view = display.view;
  8378. if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) { return }
  8379. var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
  8380. var gutterW = display.gutters.offsetWidth, left = comp + "px";
  8381. for (var i = 0; i < view.length; i++) { if (!view[i].hidden) {
  8382. if (cm.options.fixedGutter) {
  8383. if (view[i].gutter)
  8384. { view[i].gutter.style.left = left; }
  8385. if (view[i].gutterBackground)
  8386. { view[i].gutterBackground.style.left = left; }
  8387. }
  8388. var align = view[i].alignable;
  8389. if (align) { for (var j = 0; j < align.length; j++)
  8390. { align[j].style.left = left; } }
  8391. } }
  8392. if (cm.options.fixedGutter)
  8393. { display.gutters.style.left = (comp + gutterW) + "px"; }
  8394. }
  8395. // Used to ensure that the line number gutter is still the right
  8396. // size for the current document size. Returns true when an update
  8397. // is needed.
  8398. function maybeUpdateLineNumberWidth(cm) {
  8399. if (!cm.options.lineNumbers) { return false }
  8400. var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
  8401. if (last.length != display.lineNumChars) {
  8402. var test = display.measure.appendChild(elt("div", [elt("div", last)],
  8403. "CodeMirror-linenumber CodeMirror-gutter-elt"));
  8404. var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
  8405. display.lineGutter.style.width = "";
  8406. display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;
  8407. display.lineNumWidth = display.lineNumInnerWidth + padding;
  8408. display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
  8409. display.lineGutter.style.width = display.lineNumWidth + "px";
  8410. updateGutterSpace(cm.display);
  8411. return true
  8412. }
  8413. return false
  8414. }
  8415. function getGutters(gutters, lineNumbers) {
  8416. var result = [], sawLineNumbers = false;
  8417. for (var i = 0; i < gutters.length; i++) {
  8418. var name = gutters[i], style = null;
  8419. if (typeof name != "string") { style = name.style; name = name.className; }
  8420. if (name == "CodeMirror-linenumbers") {
  8421. if (!lineNumbers) { continue }
  8422. else { sawLineNumbers = true; }
  8423. }
  8424. result.push({className: name, style: style});
  8425. }
  8426. if (lineNumbers && !sawLineNumbers) { result.push({className: "CodeMirror-linenumbers", style: null}); }
  8427. return result
  8428. }
  8429. // Rebuild the gutter elements, ensure the margin to the left of the
  8430. // code matches their width.
  8431. function renderGutters(display) {
  8432. var gutters = display.gutters, specs = display.gutterSpecs;
  8433. removeChildren(gutters);
  8434. display.lineGutter = null;
  8435. for (var i = 0; i < specs.length; ++i) {
  8436. var ref = specs[i];
  8437. var className = ref.className;
  8438. var style = ref.style;
  8439. var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + className));
  8440. if (style) { gElt.style.cssText = style; }
  8441. if (className == "CodeMirror-linenumbers") {
  8442. display.lineGutter = gElt;
  8443. gElt.style.width = (display.lineNumWidth || 1) + "px";
  8444. }
  8445. }
  8446. gutters.style.display = specs.length ? "" : "none";
  8447. updateGutterSpace(display);
  8448. }
  8449. function updateGutters(cm) {
  8450. renderGutters(cm.display);
  8451. regChange(cm);
  8452. alignHorizontally(cm);
  8453. }
  8454. // The display handles the DOM integration, both for input reading
  8455. // and content drawing. It holds references to DOM nodes and
  8456. // display-related state.
  8457. function Display(place, doc, input, options) {
  8458. var d = this;
  8459. this.input = input;
  8460. // Covers bottom-right square when both scrollbars are present.
  8461. d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
  8462. d.scrollbarFiller.setAttribute("cm-not-content", "true");
  8463. // Covers bottom of gutter when coverGutterNextToScrollbar is on
  8464. // and h scrollbar is present.
  8465. d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
  8466. d.gutterFiller.setAttribute("cm-not-content", "true");
  8467. // Will contain the actual code, positioned to cover the viewport.
  8468. d.lineDiv = eltP("div", null, "CodeMirror-code");
  8469. // Elements are added to these to represent selection and cursors.
  8470. d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
  8471. d.cursorDiv = elt("div", null, "CodeMirror-cursors");
  8472. // A visibility: hidden element used to find the size of things.
  8473. d.measure = elt("div", null, "CodeMirror-measure");
  8474. // When lines outside of the viewport are measured, they are drawn in this.
  8475. d.lineMeasure = elt("div", null, "CodeMirror-measure");
  8476. // Wraps everything that needs to exist inside the vertically-padded coordinate system
  8477. d.lineSpace = eltP("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
  8478. null, "position: relative; outline: none");
  8479. var lines = eltP("div", [d.lineSpace], "CodeMirror-lines");
  8480. // Moved around its parent to cover visible view.
  8481. d.mover = elt("div", [lines], null, "position: relative");
  8482. // Set to the height of the document, allowing scrolling.
  8483. d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
  8484. d.sizerWidth = null;
  8485. // Behavior of elts with overflow: auto and padding is
  8486. // inconsistent across browsers. This is used to ensure the
  8487. // scrollable area is big enough.
  8488. d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
  8489. // Will contain the gutters, if any.
  8490. d.gutters = elt("div", null, "CodeMirror-gutters");
  8491. d.lineGutter = null;
  8492. // Actual scrollable element.
  8493. d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
  8494. d.scroller.setAttribute("tabIndex", "-1");
  8495. // The element in which the editor lives.
  8496. d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
  8497. // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
  8498. if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
  8499. if (!webkit && !(gecko && mobile)) { d.scroller.draggable = true; }
  8500. if (place) {
  8501. if (place.appendChild) { place.appendChild(d.wrapper); }
  8502. else { place(d.wrapper); }
  8503. }
  8504. // Current rendered range (may be bigger than the view window).
  8505. d.viewFrom = d.viewTo = doc.first;
  8506. d.reportedViewFrom = d.reportedViewTo = doc.first;
  8507. // Information about the rendered lines.
  8508. d.view = [];
  8509. d.renderedView = null;
  8510. // Holds info about a single rendered line when it was rendered
  8511. // for measurement, while not in view.
  8512. d.externalMeasured = null;
  8513. // Empty space (in pixels) above the view
  8514. d.viewOffset = 0;
  8515. d.lastWrapHeight = d.lastWrapWidth = 0;
  8516. d.updateLineNumbers = null;
  8517. d.nativeBarWidth = d.barHeight = d.barWidth = 0;
  8518. d.scrollbarsClipped = false;
  8519. // Used to only resize the line number gutter when necessary (when
  8520. // the amount of lines crosses a boundary that makes its width change)
  8521. d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
  8522. // Set to true when a non-horizontal-scrolling line widget is
  8523. // added. As an optimization, line widget aligning is skipped when
  8524. // this is false.
  8525. d.alignWidgets = false;
  8526. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
  8527. // Tracks the maximum line length so that the horizontal scrollbar
  8528. // can be kept static when scrolling.
  8529. d.maxLine = null;
  8530. d.maxLineLength = 0;
  8531. d.maxLineChanged = false;
  8532. // Used for measuring wheel scrolling granularity
  8533. d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
  8534. // True when shift is held down.
  8535. d.shift = false;
  8536. // Used to track whether anything happened since the context menu
  8537. // was opened.
  8538. d.selForContextMenu = null;
  8539. d.activeTouch = null;
  8540. d.gutterSpecs = getGutters(options.gutters, options.lineNumbers);
  8541. renderGutters(d);
  8542. input.init(d);
  8543. }
  8544. // Since the delta values reported on mouse wheel events are
  8545. // unstandardized between browsers and even browser versions, and
  8546. // generally horribly unpredictable, this code starts by measuring
  8547. // the scroll effect that the first few mouse wheel events have,
  8548. // and, from that, detects the way it can convert deltas to pixel
  8549. // offsets afterwards.
  8550. //
  8551. // The reason we want to know the amount a wheel event will scroll
  8552. // is that it gives us a chance to update the display before the
  8553. // actual scrolling happens, reducing flickering.
  8554. var wheelSamples = 0, wheelPixelsPerUnit = null;
  8555. // Fill in a browser-detected starting value on browsers where we
  8556. // know one. These don't have to be accurate -- the result of them
  8557. // being wrong would just be a slight flicker on the first wheel
  8558. // scroll (if it is large enough).
  8559. if (ie) { wheelPixelsPerUnit = -.53; }
  8560. else if (gecko) { wheelPixelsPerUnit = 15; }
  8561. else if (chrome) { wheelPixelsPerUnit = -.7; }
  8562. else if (safari) { wheelPixelsPerUnit = -1/3; }
  8563. function wheelEventDelta(e) {
  8564. var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
  8565. if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) { dx = e.detail; }
  8566. if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) { dy = e.detail; }
  8567. else if (dy == null) { dy = e.wheelDelta; }
  8568. return {x: dx, y: dy}
  8569. }
  8570. function wheelEventPixels(e) {
  8571. var delta = wheelEventDelta(e);
  8572. delta.x *= wheelPixelsPerUnit;
  8573. delta.y *= wheelPixelsPerUnit;
  8574. return delta
  8575. }
  8576. function onScrollWheel(cm, e) {
  8577. var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y;
  8578. var display = cm.display, scroll = display.scroller;
  8579. // Quit if there's nothing to scroll here
  8580. var canScrollX = scroll.scrollWidth > scroll.clientWidth;
  8581. var canScrollY = scroll.scrollHeight > scroll.clientHeight;
  8582. if (!(dx && canScrollX || dy && canScrollY)) { return }
  8583. // Webkit browsers on OS X abort momentum scrolls when the target
  8584. // of the scroll event is removed from the scrollable element.
  8585. // This hack (see related code in patchDisplay) makes sure the
  8586. // element is kept around.
  8587. if (dy && mac && webkit) {
  8588. outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {
  8589. for (var i = 0; i < view.length; i++) {
  8590. if (view[i].node == cur) {
  8591. cm.display.currentWheelTarget = cur;
  8592. break outer
  8593. }
  8594. }
  8595. }
  8596. }
  8597. // On some browsers, horizontal scrolling will cause redraws to
  8598. // happen before the gutter has been realigned, causing it to
  8599. // wriggle around in a most unseemly way. When we have an
  8600. // estimated pixels/delta value, we just handle horizontal
  8601. // scrolling entirely here. It'll be slightly off from native, but
  8602. // better than glitching out.
  8603. if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
  8604. if (dy && canScrollY)
  8605. { updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * wheelPixelsPerUnit)); }
  8606. setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * wheelPixelsPerUnit));
  8607. // Only prevent default scrolling if vertical scrolling is
  8608. // actually possible. Otherwise, it causes vertical scroll
  8609. // jitter on OSX trackpads when deltaX is small and deltaY
  8610. // is large (issue #3579)
  8611. if (!dy || (dy && canScrollY))
  8612. { e_preventDefault(e); }
  8613. display.wheelStartX = null; // Abort measurement, if in progress
  8614. return
  8615. }
  8616. // 'Project' the visible viewport to cover the area that is being
  8617. // scrolled into view (if we know enough to estimate it).
  8618. if (dy && wheelPixelsPerUnit != null) {
  8619. var pixels = dy * wheelPixelsPerUnit;
  8620. var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
  8621. if (pixels < 0) { top = Math.max(0, top + pixels - 50); }
  8622. else { bot = Math.min(cm.doc.height, bot + pixels + 50); }
  8623. updateDisplaySimple(cm, {top: top, bottom: bot});
  8624. }
  8625. if (wheelSamples < 20) {
  8626. if (display.wheelStartX == null) {
  8627. display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;
  8628. display.wheelDX = dx; display.wheelDY = dy;
  8629. setTimeout(function () {
  8630. if (display.wheelStartX == null) { return }
  8631. var movedX = scroll.scrollLeft - display.wheelStartX;
  8632. var movedY = scroll.scrollTop - display.wheelStartY;
  8633. var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||
  8634. (movedX && display.wheelDX && movedX / display.wheelDX);
  8635. display.wheelStartX = display.wheelStartY = null;
  8636. if (!sample) { return }
  8637. wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);
  8638. ++wheelSamples;
  8639. }, 200);
  8640. } else {
  8641. display.wheelDX += dx; display.wheelDY += dy;
  8642. }
  8643. }
  8644. }
  8645. // Selection objects are immutable. A new one is created every time
  8646. // the selection changes. A selection is one or more non-overlapping
  8647. // (and non-touching) ranges, sorted, and an integer that indicates
  8648. // which one is the primary selection (the one that's scrolled into
  8649. // view, that getCursor returns, etc).
  8650. var Selection = function(ranges, primIndex) {
  8651. this.ranges = ranges;
  8652. this.primIndex = primIndex;
  8653. };
  8654. Selection.prototype.primary = function () { return this.ranges[this.primIndex] };
  8655. Selection.prototype.equals = function (other) {
  8656. if (other == this) { return true }
  8657. if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) { return false }
  8658. for (var i = 0; i < this.ranges.length; i++) {
  8659. var here = this.ranges[i], there = other.ranges[i];
  8660. if (!equalCursorPos(here.anchor, there.anchor) || !equalCursorPos(here.head, there.head)) { return false }
  8661. }
  8662. return true
  8663. };
  8664. Selection.prototype.deepCopy = function () {
  8665. var out = [];
  8666. for (var i = 0; i < this.ranges.length; i++)
  8667. { out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head)); }
  8668. return new Selection(out, this.primIndex)
  8669. };
  8670. Selection.prototype.somethingSelected = function () {
  8671. for (var i = 0; i < this.ranges.length; i++)
  8672. { if (!this.ranges[i].empty()) { return true } }
  8673. return false
  8674. };
  8675. Selection.prototype.contains = function (pos, end) {
  8676. if (!end) { end = pos; }
  8677. for (var i = 0; i < this.ranges.length; i++) {
  8678. var range = this.ranges[i];
  8679. if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
  8680. { return i }
  8681. }
  8682. return -1
  8683. };
  8684. var Range = function(anchor, head) {
  8685. this.anchor = anchor; this.head = head;
  8686. };
  8687. Range.prototype.from = function () { return minPos(this.anchor, this.head) };
  8688. Range.prototype.to = function () { return maxPos(this.anchor, this.head) };
  8689. Range.prototype.empty = function () { return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch };
  8690. // Take an unsorted, potentially overlapping set of ranges, and
  8691. // build a selection out of it. 'Consumes' ranges array (modifying
  8692. // it).
  8693. function normalizeSelection(cm, ranges, primIndex) {
  8694. var mayTouch = cm && cm.options.selectionsMayTouch;
  8695. var prim = ranges[primIndex];
  8696. ranges.sort(function (a, b) { return cmp(a.from(), b.from()); });
  8697. primIndex = indexOf(ranges, prim);
  8698. for (var i = 1; i < ranges.length; i++) {
  8699. var cur = ranges[i], prev = ranges[i - 1];
  8700. var diff = cmp(prev.to(), cur.from());
  8701. if (mayTouch && !cur.empty() ? diff > 0 : diff >= 0) {
  8702. var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());
  8703. var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
  8704. if (i <= primIndex) { --primIndex; }
  8705. ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
  8706. }
  8707. }
  8708. return new Selection(ranges, primIndex)
  8709. }
  8710. function simpleSelection(anchor, head) {
  8711. return new Selection([new Range(anchor, head || anchor)], 0)
  8712. }
  8713. // Compute the position of the end of a change (its 'to' property
  8714. // refers to the pre-change end).
  8715. function changeEnd(change) {
  8716. if (!change.text) { return change.to }
  8717. return Pos(change.from.line + change.text.length - 1,
  8718. lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0))
  8719. }
  8720. // Adjust a position to refer to the post-change position of the
  8721. // same text, or the end of the change if the change covers it.
  8722. function adjustForChange(pos, change) {
  8723. if (cmp(pos, change.from) < 0) { return pos }
  8724. if (cmp(pos, change.to) <= 0) { return changeEnd(change) }
  8725. var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
  8726. if (pos.line == change.to.line) { ch += changeEnd(change).ch - change.to.ch; }
  8727. return Pos(line, ch)
  8728. }
  8729. function computeSelAfterChange(doc, change) {
  8730. var out = [];
  8731. for (var i = 0; i < doc.sel.ranges.length; i++) {
  8732. var range = doc.sel.ranges[i];
  8733. out.push(new Range(adjustForChange(range.anchor, change),
  8734. adjustForChange(range.head, change)));
  8735. }
  8736. return normalizeSelection(doc.cm, out, doc.sel.primIndex)
  8737. }
  8738. function offsetPos(pos, old, nw) {
  8739. if (pos.line == old.line)
  8740. { return Pos(nw.line, pos.ch - old.ch + nw.ch) }
  8741. else
  8742. { return Pos(nw.line + (pos.line - old.line), pos.ch) }
  8743. }
  8744. // Used by replaceSelections to allow moving the selection to the
  8745. // start or around the replaced test. Hint may be "start" or "around".
  8746. function computeReplacedSel(doc, changes, hint) {
  8747. var out = [];
  8748. var oldPrev = Pos(doc.first, 0), newPrev = oldPrev;
  8749. for (var i = 0; i < changes.length; i++) {
  8750. var change = changes[i];
  8751. var from = offsetPos(change.from, oldPrev, newPrev);
  8752. var to = offsetPos(changeEnd(change), oldPrev, newPrev);
  8753. oldPrev = change.to;
  8754. newPrev = to;
  8755. if (hint == "around") {
  8756. var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0;
  8757. out[i] = new Range(inv ? to : from, inv ? from : to);
  8758. } else {
  8759. out[i] = new Range(from, from);
  8760. }
  8761. }
  8762. return new Selection(out, doc.sel.primIndex)
  8763. }
  8764. // Used to get the editor into a consistent state again when options change.
  8765. function loadMode(cm) {
  8766. cm.doc.mode = getMode(cm.options, cm.doc.modeOption);
  8767. resetModeState(cm);
  8768. }
  8769. function resetModeState(cm) {
  8770. cm.doc.iter(function (line) {
  8771. if (line.stateAfter) { line.stateAfter = null; }
  8772. if (line.styles) { line.styles = null; }
  8773. });
  8774. cm.doc.modeFrontier = cm.doc.highlightFrontier = cm.doc.first;
  8775. startWorker(cm, 100);
  8776. cm.state.modeGen++;
  8777. if (cm.curOp) { regChange(cm); }
  8778. }
  8779. // DOCUMENT DATA STRUCTURE
  8780. // By default, updates that start and end at the beginning of a line
  8781. // are treated specially, in order to make the association of line
  8782. // widgets and marker elements with the text behave more intuitive.
  8783. function isWholeLineUpdate(doc, change) {
  8784. return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" &&
  8785. (!doc.cm || doc.cm.options.wholeLineUpdateBefore)
  8786. }
  8787. // Perform a change on the document data structure.
  8788. function updateDoc(doc, change, markedSpans, estimateHeight) {
  8789. function spansFor(n) {return markedSpans ? markedSpans[n] : null}
  8790. function update(line, text, spans) {
  8791. updateLine(line, text, spans, estimateHeight);
  8792. signalLater(line, "change", line, change);
  8793. }
  8794. function linesFor(start, end) {
  8795. var result = [];
  8796. for (var i = start; i < end; ++i)
  8797. { result.push(new Line(text[i], spansFor(i), estimateHeight)); }
  8798. return result
  8799. }
  8800. var from = change.from, to = change.to, text = change.text;
  8801. var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line);
  8802. var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;
  8803. // Adjust the line structure
  8804. if (change.full) {
  8805. doc.insert(0, linesFor(0, text.length));
  8806. doc.remove(text.length, doc.size - text.length);
  8807. } else if (isWholeLineUpdate(doc, change)) {
  8808. // This is a whole-line replace. Treated specially to make
  8809. // sure line objects move the way they are supposed to.
  8810. var added = linesFor(0, text.length - 1);
  8811. update(lastLine, lastLine.text, lastSpans);
  8812. if (nlines) { doc.remove(from.line, nlines); }
  8813. if (added.length) { doc.insert(from.line, added); }
  8814. } else if (firstLine == lastLine) {
  8815. if (text.length == 1) {
  8816. update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);
  8817. } else {
  8818. var added$1 = linesFor(1, text.length - 1);
  8819. added$1.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight));
  8820. update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
  8821. doc.insert(from.line + 1, added$1);
  8822. }
  8823. } else if (text.length == 1) {
  8824. update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0));
  8825. doc.remove(from.line + 1, nlines);
  8826. } else {
  8827. update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
  8828. update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);
  8829. var added$2 = linesFor(1, text.length - 1);
  8830. if (nlines > 1) { doc.remove(from.line + 1, nlines - 1); }
  8831. doc.insert(from.line + 1, added$2);
  8832. }
  8833. signalLater(doc, "change", doc, change);
  8834. }
  8835. // Call f for all linked documents.
  8836. function linkedDocs(doc, f, sharedHistOnly) {
  8837. function propagate(doc, skip, sharedHist) {
  8838. if (doc.linked) { for (var i = 0; i < doc.linked.length; ++i) {
  8839. var rel = doc.linked[i];
  8840. if (rel.doc == skip) { continue }
  8841. var shared = sharedHist && rel.sharedHist;
  8842. if (sharedHistOnly && !shared) { continue }
  8843. f(rel.doc, shared);
  8844. propagate(rel.doc, doc, shared);
  8845. } }
  8846. }
  8847. propagate(doc, null, true);
  8848. }
  8849. // Attach a document to an editor.
  8850. function attachDoc(cm, doc) {
  8851. if (doc.cm) { throw new Error("This document is already in use.") }
  8852. cm.doc = doc;
  8853. doc.cm = cm;
  8854. estimateLineHeights(cm);
  8855. loadMode(cm);
  8856. setDirectionClass(cm);
  8857. if (!cm.options.lineWrapping) { findMaxLine(cm); }
  8858. cm.options.mode = doc.modeOption;
  8859. regChange(cm);
  8860. }
  8861. function setDirectionClass(cm) {
  8862. (cm.doc.direction == "rtl" ? addClass : rmClass)(cm.display.lineDiv, "CodeMirror-rtl");
  8863. }
  8864. function directionChanged(cm) {
  8865. runInOp(cm, function () {
  8866. setDirectionClass(cm);
  8867. regChange(cm);
  8868. });
  8869. }
  8870. function History(startGen) {
  8871. // Arrays of change events and selections. Doing something adds an
  8872. // event to done and clears undo. Undoing moves events from done
  8873. // to undone, redoing moves them in the other direction.
  8874. this.done = []; this.undone = [];
  8875. this.undoDepth = Infinity;
  8876. // Used to track when changes can be merged into a single undo
  8877. // event
  8878. this.lastModTime = this.lastSelTime = 0;
  8879. this.lastOp = this.lastSelOp = null;
  8880. this.lastOrigin = this.lastSelOrigin = null;
  8881. // Used by the isClean() method
  8882. this.generation = this.maxGeneration = startGen || 1;
  8883. }
  8884. // Create a history change event from an updateDoc-style change
  8885. // object.
  8886. function historyChangeFromChange(doc, change) {
  8887. var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)};
  8888. attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);
  8889. linkedDocs(doc, function (doc) { return attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); }, true);
  8890. return histChange
  8891. }
  8892. // Pop all selection events off the end of a history array. Stop at
  8893. // a change event.
  8894. function clearSelectionEvents(array) {
  8895. while (array.length) {
  8896. var last = lst(array);
  8897. if (last.ranges) { array.pop(); }
  8898. else { break }
  8899. }
  8900. }
  8901. // Find the top change event in the history. Pop off selection
  8902. // events that are in the way.
  8903. function lastChangeEvent(hist, force) {
  8904. if (force) {
  8905. clearSelectionEvents(hist.done);
  8906. return lst(hist.done)
  8907. } else if (hist.done.length && !lst(hist.done).ranges) {
  8908. return lst(hist.done)
  8909. } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
  8910. hist.done.pop();
  8911. return lst(hist.done)
  8912. }
  8913. }
  8914. // Register a change in the history. Merges changes that are within
  8915. // a single operation, or are close together with an origin that
  8916. // allows merging (starting with "+") into a single event.
  8917. function addChangeToHistory(doc, change, selAfter, opId) {
  8918. var hist = doc.history;
  8919. hist.undone.length = 0;
  8920. var time = +new Date, cur;
  8921. var last;
  8922. if ((hist.lastOp == opId ||
  8923. hist.lastOrigin == change.origin && change.origin &&
  8924. ((change.origin.charAt(0) == "+" && hist.lastModTime > time - (doc.cm ? doc.cm.options.historyEventDelay : 500)) ||
  8925. change.origin.charAt(0) == "*")) &&
  8926. (cur = lastChangeEvent(hist, hist.lastOp == opId))) {
  8927. // Merge this change into the last event
  8928. last = lst(cur.changes);
  8929. if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {
  8930. // Optimized case for simple insertion -- don't want to add
  8931. // new changesets for every character typed
  8932. last.to = changeEnd(change);
  8933. } else {
  8934. // Add new sub-event
  8935. cur.changes.push(historyChangeFromChange(doc, change));
  8936. }
  8937. } else {
  8938. // Can not be merged, start a new event.
  8939. var before = lst(hist.done);
  8940. if (!before || !before.ranges)
  8941. { pushSelectionToHistory(doc.sel, hist.done); }
  8942. cur = {changes: [historyChangeFromChange(doc, change)],
  8943. generation: hist.generation};
  8944. hist.done.push(cur);
  8945. while (hist.done.length > hist.undoDepth) {
  8946. hist.done.shift();
  8947. if (!hist.done[0].ranges) { hist.done.shift(); }
  8948. }
  8949. }
  8950. hist.done.push(selAfter);
  8951. hist.generation = ++hist.maxGeneration;
  8952. hist.lastModTime = hist.lastSelTime = time;
  8953. hist.lastOp = hist.lastSelOp = opId;
  8954. hist.lastOrigin = hist.lastSelOrigin = change.origin;
  8955. if (!last) { signal(doc, "historyAdded"); }
  8956. }
  8957. function selectionEventCanBeMerged(doc, origin, prev, sel) {
  8958. var ch = origin.charAt(0);
  8959. return ch == "*" ||
  8960. ch == "+" &&
  8961. prev.ranges.length == sel.ranges.length &&
  8962. prev.somethingSelected() == sel.somethingSelected() &&
  8963. new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500)
  8964. }
  8965. // Called whenever the selection changes, sets the new selection as
  8966. // the pending selection in the history, and pushes the old pending
  8967. // selection into the 'done' array when it was significantly
  8968. // different (in number of selected ranges, emptiness, or time).
  8969. function addSelectionToHistory(doc, sel, opId, options) {
  8970. var hist = doc.history, origin = options && options.origin;
  8971. // A new event is started when the previous origin does not match
  8972. // the current, or the origins don't allow matching. Origins
  8973. // starting with * are always merged, those starting with + are
  8974. // merged when similar and close together in time.
  8975. if (opId == hist.lastSelOp ||
  8976. (origin && hist.lastSelOrigin == origin &&
  8977. (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||
  8978. selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))
  8979. { hist.done[hist.done.length - 1] = sel; }
  8980. else
  8981. { pushSelectionToHistory(sel, hist.done); }
  8982. hist.lastSelTime = +new Date;
  8983. hist.lastSelOrigin = origin;
  8984. hist.lastSelOp = opId;
  8985. if (options && options.clearRedo !== false)
  8986. { clearSelectionEvents(hist.undone); }
  8987. }
  8988. function pushSelectionToHistory(sel, dest) {
  8989. var top = lst(dest);
  8990. if (!(top && top.ranges && top.equals(sel)))
  8991. { dest.push(sel); }
  8992. }
  8993. // Used to store marked span information in the history.
  8994. function attachLocalSpans(doc, change, from, to) {
  8995. var existing = change["spans_" + doc.id], n = 0;
  8996. doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function (line) {
  8997. if (line.markedSpans)
  8998. { (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans; }
  8999. ++n;
  9000. });
  9001. }
  9002. // When un/re-doing restores text containing marked spans, those
  9003. // that have been explicitly cleared should not be restored.
  9004. function removeClearedSpans(spans) {
  9005. if (!spans) { return null }
  9006. var out;
  9007. for (var i = 0; i < spans.length; ++i) {
  9008. if (spans[i].marker.explicitlyCleared) { if (!out) { out = spans.slice(0, i); } }
  9009. else if (out) { out.push(spans[i]); }
  9010. }
  9011. return !out ? spans : out.length ? out : null
  9012. }
  9013. // Retrieve and filter the old marked spans stored in a change event.
  9014. function getOldSpans(doc, change) {
  9015. var found = change["spans_" + doc.id];
  9016. if (!found) { return null }
  9017. var nw = [];
  9018. for (var i = 0; i < change.text.length; ++i)
  9019. { nw.push(removeClearedSpans(found[i])); }
  9020. return nw
  9021. }
  9022. // Used for un/re-doing changes from the history. Combines the
  9023. // result of computing the existing spans with the set of spans that
  9024. // existed in the history (so that deleting around a span and then
  9025. // undoing brings back the span).
  9026. function mergeOldSpans(doc, change) {
  9027. var old = getOldSpans(doc, change);
  9028. var stretched = stretchSpansOverChange(doc, change);
  9029. if (!old) { return stretched }
  9030. if (!stretched) { return old }
  9031. for (var i = 0; i < old.length; ++i) {
  9032. var oldCur = old[i], stretchCur = stretched[i];
  9033. if (oldCur && stretchCur) {
  9034. spans: for (var j = 0; j < stretchCur.length; ++j) {
  9035. var span = stretchCur[j];
  9036. for (var k = 0; k < oldCur.length; ++k)
  9037. { if (oldCur[k].marker == span.marker) { continue spans } }
  9038. oldCur.push(span);
  9039. }
  9040. } else if (stretchCur) {
  9041. old[i] = stretchCur;
  9042. }
  9043. }
  9044. return old
  9045. }
  9046. // Used both to provide a JSON-safe object in .getHistory, and, when
  9047. // detaching a document, to split the history in two
  9048. function copyHistoryArray(events, newGroup, instantiateSel) {
  9049. var copy = [];
  9050. for (var i = 0; i < events.length; ++i) {
  9051. var event = events[i];
  9052. if (event.ranges) {
  9053. copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);
  9054. continue
  9055. }
  9056. var changes = event.changes, newChanges = [];
  9057. copy.push({changes: newChanges});
  9058. for (var j = 0; j < changes.length; ++j) {
  9059. var change = changes[j], m = (void 0);
  9060. newChanges.push({from: change.from, to: change.to, text: change.text});
  9061. if (newGroup) { for (var prop in change) { if (m = prop.match(/^spans_(\d+)$/)) {
  9062. if (indexOf(newGroup, Number(m[1])) > -1) {
  9063. lst(newChanges)[prop] = change[prop];
  9064. delete change[prop];
  9065. }
  9066. } } }
  9067. }
  9068. }
  9069. return copy
  9070. }
  9071. // The 'scroll' parameter given to many of these indicated whether
  9072. // the new cursor position should be scrolled into view after
  9073. // modifying the selection.
  9074. // If shift is held or the extend flag is set, extends a range to
  9075. // include a given position (and optionally a second position).
  9076. // Otherwise, simply returns the range between the given positions.
  9077. // Used for cursor motion and such.
  9078. function extendRange(range, head, other, extend) {
  9079. if (extend) {
  9080. var anchor = range.anchor;
  9081. if (other) {
  9082. var posBefore = cmp(head, anchor) < 0;
  9083. if (posBefore != (cmp(other, anchor) < 0)) {
  9084. anchor = head;
  9085. head = other;
  9086. } else if (posBefore != (cmp(head, other) < 0)) {
  9087. head = other;
  9088. }
  9089. }
  9090. return new Range(anchor, head)
  9091. } else {
  9092. return new Range(other || head, head)
  9093. }
  9094. }
  9095. // Extend the primary selection range, discard the rest.
  9096. function extendSelection(doc, head, other, options, extend) {
  9097. if (extend == null) { extend = doc.cm && (doc.cm.display.shift || doc.extend); }
  9098. setSelection(doc, new Selection([extendRange(doc.sel.primary(), head, other, extend)], 0), options);
  9099. }
  9100. // Extend all selections (pos is an array of selections with length
  9101. // equal the number of selections)
  9102. function extendSelections(doc, heads, options) {
  9103. var out = [];
  9104. var extend = doc.cm && (doc.cm.display.shift || doc.extend);
  9105. for (var i = 0; i < doc.sel.ranges.length; i++)
  9106. { out[i] = extendRange(doc.sel.ranges[i], heads[i], null, extend); }
  9107. var newSel = normalizeSelection(doc.cm, out, doc.sel.primIndex);
  9108. setSelection(doc, newSel, options);
  9109. }
  9110. // Updates a single range in the selection.
  9111. function replaceOneSelection(doc, i, range, options) {
  9112. var ranges = doc.sel.ranges.slice(0);
  9113. ranges[i] = range;
  9114. setSelection(doc, normalizeSelection(doc.cm, ranges, doc.sel.primIndex), options);
  9115. }
  9116. // Reset the selection to a single range.
  9117. function setSimpleSelection(doc, anchor, head, options) {
  9118. setSelection(doc, simpleSelection(anchor, head), options);
  9119. }
  9120. // Give beforeSelectionChange handlers a change to influence a
  9121. // selection update.
  9122. function filterSelectionChange(doc, sel, options) {
  9123. var obj = {
  9124. ranges: sel.ranges,
  9125. update: function(ranges) {
  9126. this.ranges = [];
  9127. for (var i = 0; i < ranges.length; i++)
  9128. { this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
  9129. clipPos(doc, ranges[i].head)); }
  9130. },
  9131. origin: options && options.origin
  9132. };
  9133. signal(doc, "beforeSelectionChange", doc, obj);
  9134. if (doc.cm) { signal(doc.cm, "beforeSelectionChange", doc.cm, obj); }
  9135. if (obj.ranges != sel.ranges) { return normalizeSelection(doc.cm, obj.ranges, obj.ranges.length - 1) }
  9136. else { return sel }
  9137. }
  9138. function setSelectionReplaceHistory(doc, sel, options) {
  9139. var done = doc.history.done, last = lst(done);
  9140. if (last && last.ranges) {
  9141. done[done.length - 1] = sel;
  9142. setSelectionNoUndo(doc, sel, options);
  9143. } else {
  9144. setSelection(doc, sel, options);
  9145. }
  9146. }
  9147. // Set a new selection.
  9148. function setSelection(doc, sel, options) {
  9149. setSelectionNoUndo(doc, sel, options);
  9150. addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);
  9151. }
  9152. function setSelectionNoUndo(doc, sel, options) {
  9153. if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
  9154. { sel = filterSelectionChange(doc, sel, options); }
  9155. var bias = options && options.bias ||
  9156. (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
  9157. setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
  9158. if (!(options && options.scroll === false) && doc.cm)
  9159. { ensureCursorVisible(doc.cm); }
  9160. }
  9161. function setSelectionInner(doc, sel) {
  9162. if (sel.equals(doc.sel)) { return }
  9163. doc.sel = sel;
  9164. if (doc.cm) {
  9165. doc.cm.curOp.updateInput = 1;
  9166. doc.cm.curOp.selectionChanged = true;
  9167. signalCursorActivity(doc.cm);
  9168. }
  9169. signalLater(doc, "cursorActivity", doc);
  9170. }
  9171. // Verify that the selection does not partially select any atomic
  9172. // marked ranges.
  9173. function reCheckSelection(doc) {
  9174. setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false));
  9175. }
  9176. // Return a selection that does not partially select any atomic
  9177. // ranges.
  9178. function skipAtomicInSelection(doc, sel, bias, mayClear) {
  9179. var out;
  9180. for (var i = 0; i < sel.ranges.length; i++) {
  9181. var range = sel.ranges[i];
  9182. var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i];
  9183. var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear);
  9184. var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear);
  9185. if (out || newAnchor != range.anchor || newHead != range.head) {
  9186. if (!out) { out = sel.ranges.slice(0, i); }
  9187. out[i] = new Range(newAnchor, newHead);
  9188. }
  9189. }
  9190. return out ? normalizeSelection(doc.cm, out, sel.primIndex) : sel
  9191. }
  9192. function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
  9193. var line = getLine(doc, pos.line);
  9194. if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {
  9195. var sp = line.markedSpans[i], m = sp.marker;
  9196. // Determine if we should prevent the cursor being placed to the left/right of an atomic marker
  9197. // Historically this was determined using the inclusiveLeft/Right option, but the new way to control it
  9198. // is with selectLeft/Right
  9199. var preventCursorLeft = ("selectLeft" in m) ? !m.selectLeft : m.inclusiveLeft;
  9200. var preventCursorRight = ("selectRight" in m) ? !m.selectRight : m.inclusiveRight;
  9201. if ((sp.from == null || (preventCursorLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&
  9202. (sp.to == null || (preventCursorRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
  9203. if (mayClear) {
  9204. signal(m, "beforeCursorEnter");
  9205. if (m.explicitlyCleared) {
  9206. if (!line.markedSpans) { break }
  9207. else {--i; continue}
  9208. }
  9209. }
  9210. if (!m.atomic) { continue }
  9211. if (oldPos) {
  9212. var near = m.find(dir < 0 ? 1 : -1), diff = (void 0);
  9213. if (dir < 0 ? preventCursorRight : preventCursorLeft)
  9214. { near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null); }
  9215. if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
  9216. { return skipAtomicInner(doc, near, pos, dir, mayClear) }
  9217. }
  9218. var far = m.find(dir < 0 ? -1 : 1);
  9219. if (dir < 0 ? preventCursorLeft : preventCursorRight)
  9220. { far = movePos(doc, far, dir, far.line == pos.line ? line : null); }
  9221. return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null
  9222. }
  9223. } }
  9224. return pos
  9225. }
  9226. // Ensure a given position is not inside an atomic range.
  9227. function skipAtomic(doc, pos, oldPos, bias, mayClear) {
  9228. var dir = bias || 1;
  9229. var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) ||
  9230. (!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) ||
  9231. skipAtomicInner(doc, pos, oldPos, -dir, mayClear) ||
  9232. (!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true));
  9233. if (!found) {
  9234. doc.cantEdit = true;
  9235. return Pos(doc.first, 0)
  9236. }
  9237. return found
  9238. }
  9239. function movePos(doc, pos, dir, line) {
  9240. if (dir < 0 && pos.ch == 0) {
  9241. if (pos.line > doc.first) { return clipPos(doc, Pos(pos.line - 1)) }
  9242. else { return null }
  9243. } else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) {
  9244. if (pos.line < doc.first + doc.size - 1) { return Pos(pos.line + 1, 0) }
  9245. else { return null }
  9246. } else {
  9247. return new Pos(pos.line, pos.ch + dir)
  9248. }
  9249. }
  9250. function selectAll(cm) {
  9251. cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);
  9252. }
  9253. // UPDATING
  9254. // Allow "beforeChange" event handlers to influence a change
  9255. function filterChange(doc, change, update) {
  9256. var obj = {
  9257. canceled: false,
  9258. from: change.from,
  9259. to: change.to,
  9260. text: change.text,
  9261. origin: change.origin,
  9262. cancel: function () { return obj.canceled = true; }
  9263. };
  9264. if (update) { obj.update = function (from, to, text, origin) {
  9265. if (from) { obj.from = clipPos(doc, from); }
  9266. if (to) { obj.to = clipPos(doc, to); }
  9267. if (text) { obj.text = text; }
  9268. if (origin !== undefined) { obj.origin = origin; }
  9269. }; }
  9270. signal(doc, "beforeChange", doc, obj);
  9271. if (doc.cm) { signal(doc.cm, "beforeChange", doc.cm, obj); }
  9272. if (obj.canceled) {
  9273. if (doc.cm) { doc.cm.curOp.updateInput = 2; }
  9274. return null
  9275. }
  9276. return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin}
  9277. }
  9278. // Apply a change to a document, and add it to the document's
  9279. // history, and propagating it to all linked documents.
  9280. function makeChange(doc, change, ignoreReadOnly) {
  9281. if (doc.cm) {
  9282. if (!doc.cm.curOp) { return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly) }
  9283. if (doc.cm.state.suppressEdits) { return }
  9284. }
  9285. if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
  9286. change = filterChange(doc, change, true);
  9287. if (!change) { return }
  9288. }
  9289. // Possibly split or suppress the update based on the presence
  9290. // of read-only spans in its range.
  9291. var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
  9292. if (split) {
  9293. for (var i = split.length - 1; i >= 0; --i)
  9294. { makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text, origin: change.origin}); }
  9295. } else {
  9296. makeChangeInner(doc, change);
  9297. }
  9298. }
  9299. function makeChangeInner(doc, change) {
  9300. if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) { return }
  9301. var selAfter = computeSelAfterChange(doc, change);
  9302. addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);
  9303. makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change));
  9304. var rebased = [];
  9305. linkedDocs(doc, function (doc, sharedHist) {
  9306. if (!sharedHist && indexOf(rebased, doc.history) == -1) {
  9307. rebaseHist(doc.history, change);
  9308. rebased.push(doc.history);
  9309. }
  9310. makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change));
  9311. });
  9312. }
  9313. // Revert a change stored in a document's history.
  9314. function makeChangeFromHistory(doc, type, allowSelectionOnly) {
  9315. var suppress = doc.cm && doc.cm.state.suppressEdits;
  9316. if (suppress && !allowSelectionOnly) { return }
  9317. var hist = doc.history, event, selAfter = doc.sel;
  9318. var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done;
  9319. // Verify that there is a useable event (so that ctrl-z won't
  9320. // needlessly clear selection events)
  9321. var i = 0;
  9322. for (; i < source.length; i++) {
  9323. event = source[i];
  9324. if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)
  9325. { break }
  9326. }
  9327. if (i == source.length) { return }
  9328. hist.lastOrigin = hist.lastSelOrigin = null;
  9329. for (;;) {
  9330. event = source.pop();
  9331. if (event.ranges) {
  9332. pushSelectionToHistory(event, dest);
  9333. if (allowSelectionOnly && !event.equals(doc.sel)) {
  9334. setSelection(doc, event, {clearRedo: false});
  9335. return
  9336. }
  9337. selAfter = event;
  9338. } else if (suppress) {
  9339. source.push(event);
  9340. return
  9341. } else { break }
  9342. }
  9343. // Build up a reverse change object to add to the opposite history
  9344. // stack (redo when undoing, and vice versa).
  9345. var antiChanges = [];
  9346. pushSelectionToHistory(selAfter, dest);
  9347. dest.push({changes: antiChanges, generation: hist.generation});
  9348. hist.generation = event.generation || ++hist.maxGeneration;
  9349. var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange");
  9350. var loop = function ( i ) {
  9351. var change = event.changes[i];
  9352. change.origin = type;
  9353. if (filter && !filterChange(doc, change, false)) {
  9354. source.length = 0;
  9355. return {}
  9356. }
  9357. antiChanges.push(historyChangeFromChange(doc, change));
  9358. var after = i ? computeSelAfterChange(doc, change) : lst(source);
  9359. makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));
  9360. if (!i && doc.cm) { doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)}); }
  9361. var rebased = [];
  9362. // Propagate to the linked documents
  9363. linkedDocs(doc, function (doc, sharedHist) {
  9364. if (!sharedHist && indexOf(rebased, doc.history) == -1) {
  9365. rebaseHist(doc.history, change);
  9366. rebased.push(doc.history);
  9367. }
  9368. makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));
  9369. });
  9370. };
  9371. for (var i$1 = event.changes.length - 1; i$1 >= 0; --i$1) {
  9372. var returned = loop( i$1 );
  9373. if ( returned ) return returned.v;
  9374. }
  9375. }
  9376. // Sub-views need their line numbers shifted when text is added
  9377. // above or below them in the parent document.
  9378. function shiftDoc(doc, distance) {
  9379. if (distance == 0) { return }
  9380. doc.first += distance;
  9381. doc.sel = new Selection(map(doc.sel.ranges, function (range) { return new Range(
  9382. Pos(range.anchor.line + distance, range.anchor.ch),
  9383. Pos(range.head.line + distance, range.head.ch)
  9384. ); }), doc.sel.primIndex);
  9385. if (doc.cm) {
  9386. regChange(doc.cm, doc.first, doc.first - distance, distance);
  9387. for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
  9388. { regLineChange(doc.cm, l, "gutter"); }
  9389. }
  9390. }
  9391. // More lower-level change function, handling only a single document
  9392. // (not linked ones).
  9393. function makeChangeSingleDoc(doc, change, selAfter, spans) {
  9394. if (doc.cm && !doc.cm.curOp)
  9395. { return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans) }
  9396. if (change.to.line < doc.first) {
  9397. shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
  9398. return
  9399. }
  9400. if (change.from.line > doc.lastLine()) { return }
  9401. // Clip the change to the size of this doc
  9402. if (change.from.line < doc.first) {
  9403. var shift = change.text.length - 1 - (doc.first - change.from.line);
  9404. shiftDoc(doc, shift);
  9405. change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
  9406. text: [lst(change.text)], origin: change.origin};
  9407. }
  9408. var last = doc.lastLine();
  9409. if (change.to.line > last) {
  9410. change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
  9411. text: [change.text[0]], origin: change.origin};
  9412. }
  9413. change.removed = getBetween(doc, change.from, change.to);
  9414. if (!selAfter) { selAfter = computeSelAfterChange(doc, change); }
  9415. if (doc.cm) { makeChangeSingleDocInEditor(doc.cm, change, spans); }
  9416. else { updateDoc(doc, change, spans); }
  9417. setSelectionNoUndo(doc, selAfter, sel_dontScroll);
  9418. if (doc.cantEdit && skipAtomic(doc, Pos(doc.firstLine(), 0)))
  9419. { doc.cantEdit = false; }
  9420. }
  9421. // Handle the interaction of a change to a document with the editor
  9422. // that this document is part of.
  9423. function makeChangeSingleDocInEditor(cm, change, spans) {
  9424. var doc = cm.doc, display = cm.display, from = change.from, to = change.to;
  9425. var recomputeMaxLength = false, checkWidthStart = from.line;
  9426. if (!cm.options.lineWrapping) {
  9427. checkWidthStart = lineNo(visualLine(getLine(doc, from.line)));
  9428. doc.iter(checkWidthStart, to.line + 1, function (line) {
  9429. if (line == display.maxLine) {
  9430. recomputeMaxLength = true;
  9431. return true
  9432. }
  9433. });
  9434. }
  9435. if (doc.sel.contains(change.from, change.to) > -1)
  9436. { signalCursorActivity(cm); }
  9437. updateDoc(doc, change, spans, estimateHeight(cm));
  9438. if (!cm.options.lineWrapping) {
  9439. doc.iter(checkWidthStart, from.line + change.text.length, function (line) {
  9440. var len = lineLength(line);
  9441. if (len > display.maxLineLength) {
  9442. display.maxLine = line;
  9443. display.maxLineLength = len;
  9444. display.maxLineChanged = true;
  9445. recomputeMaxLength = false;
  9446. }
  9447. });
  9448. if (recomputeMaxLength) { cm.curOp.updateMaxLine = true; }
  9449. }
  9450. retreatFrontier(doc, from.line);
  9451. startWorker(cm, 400);
  9452. var lendiff = change.text.length - (to.line - from.line) - 1;
  9453. // Remember that these lines changed, for updating the display
  9454. if (change.full)
  9455. { regChange(cm); }
  9456. else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
  9457. { regLineChange(cm, from.line, "text"); }
  9458. else
  9459. { regChange(cm, from.line, to.line + 1, lendiff); }
  9460. var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change");
  9461. if (changeHandler || changesHandler) {
  9462. var obj = {
  9463. from: from, to: to,
  9464. text: change.text,
  9465. removed: change.removed,
  9466. origin: change.origin
  9467. };
  9468. if (changeHandler) { signalLater(cm, "change", cm, obj); }
  9469. if (changesHandler) { (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj); }
  9470. }
  9471. cm.display.selForContextMenu = null;
  9472. }
  9473. function replaceRange(doc, code, from, to, origin) {
  9474. var assign;
  9475. if (!to) { to = from; }
  9476. if (cmp(to, from) < 0) { (assign = [to, from], from = assign[0], to = assign[1]); }
  9477. if (typeof code == "string") { code = doc.splitLines(code); }
  9478. makeChange(doc, {from: from, to: to, text: code, origin: origin});
  9479. }
  9480. // Rebasing/resetting history to deal with externally-sourced changes
  9481. function rebaseHistSelSingle(pos, from, to, diff) {
  9482. if (to < pos.line) {
  9483. pos.line += diff;
  9484. } else if (from < pos.line) {
  9485. pos.line = from;
  9486. pos.ch = 0;
  9487. }
  9488. }
  9489. // Tries to rebase an array of history events given a change in the
  9490. // document. If the change touches the same lines as the event, the
  9491. // event, and everything 'behind' it, is discarded. If the change is
  9492. // before the event, the event's positions are updated. Uses a
  9493. // copy-on-write scheme for the positions, to avoid having to
  9494. // reallocate them all on every rebase, but also avoid problems with
  9495. // shared position objects being unsafely updated.
  9496. function rebaseHistArray(array, from, to, diff) {
  9497. for (var i = 0; i < array.length; ++i) {
  9498. var sub = array[i], ok = true;
  9499. if (sub.ranges) {
  9500. if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }
  9501. for (var j = 0; j < sub.ranges.length; j++) {
  9502. rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
  9503. rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
  9504. }
  9505. continue
  9506. }
  9507. for (var j$1 = 0; j$1 < sub.changes.length; ++j$1) {
  9508. var cur = sub.changes[j$1];
  9509. if (to < cur.from.line) {
  9510. cur.from = Pos(cur.from.line + diff, cur.from.ch);
  9511. cur.to = Pos(cur.to.line + diff, cur.to.ch);
  9512. } else if (from <= cur.to.line) {
  9513. ok = false;
  9514. break
  9515. }
  9516. }
  9517. if (!ok) {
  9518. array.splice(0, i + 1);
  9519. i = 0;
  9520. }
  9521. }
  9522. }
  9523. function rebaseHist(hist, change) {
  9524. var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;
  9525. rebaseHistArray(hist.done, from, to, diff);
  9526. rebaseHistArray(hist.undone, from, to, diff);
  9527. }
  9528. // Utility for applying a change to a line by handle or number,
  9529. // returning the number and optionally registering the line as
  9530. // changed.
  9531. function changeLine(doc, handle, changeType, op) {
  9532. var no = handle, line = handle;
  9533. if (typeof handle == "number") { line = getLine(doc, clipLine(doc, handle)); }
  9534. else { no = lineNo(handle); }
  9535. if (no == null) { return null }
  9536. if (op(line, no) && doc.cm) { regLineChange(doc.cm, no, changeType); }
  9537. return line
  9538. }
  9539. // The document is represented as a BTree consisting of leaves, with
  9540. // chunk of lines in them, and branches, with up to ten leaves or
  9541. // other branch nodes below them. The top node is always a branch
  9542. // node, and is the document object itself (meaning it has
  9543. // additional methods and properties).
  9544. //
  9545. // All nodes have parent links. The tree is used both to go from
  9546. // line numbers to line objects, and to go from objects to numbers.
  9547. // It also indexes by height, and is used to convert between height
  9548. // and line object, and to find the total height of the document.
  9549. //
  9550. // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
  9551. function LeafChunk(lines) {
  9552. this.lines = lines;
  9553. this.parent = null;
  9554. var height = 0;
  9555. for (var i = 0; i < lines.length; ++i) {
  9556. lines[i].parent = this;
  9557. height += lines[i].height;
  9558. }
  9559. this.height = height;
  9560. }
  9561. LeafChunk.prototype = {
  9562. chunkSize: function() { return this.lines.length },
  9563. // Remove the n lines at offset 'at'.
  9564. removeInner: function(at, n) {
  9565. for (var i = at, e = at + n; i < e; ++i) {
  9566. var line = this.lines[i];
  9567. this.height -= line.height;
  9568. cleanUpLine(line);
  9569. signalLater(line, "delete");
  9570. }
  9571. this.lines.splice(at, n);
  9572. },
  9573. // Helper used to collapse a small branch into a single leaf.
  9574. collapse: function(lines) {
  9575. lines.push.apply(lines, this.lines);
  9576. },
  9577. // Insert the given array of lines at offset 'at', count them as
  9578. // having the given height.
  9579. insertInner: function(at, lines, height) {
  9580. this.height += height;
  9581. this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
  9582. for (var i = 0; i < lines.length; ++i) { lines[i].parent = this; }
  9583. },
  9584. // Used to iterate over a part of the tree.
  9585. iterN: function(at, n, op) {
  9586. for (var e = at + n; at < e; ++at)
  9587. { if (op(this.lines[at])) { return true } }
  9588. }
  9589. };
  9590. function BranchChunk(children) {
  9591. this.children = children;
  9592. var size = 0, height = 0;
  9593. for (var i = 0; i < children.length; ++i) {
  9594. var ch = children[i];
  9595. size += ch.chunkSize(); height += ch.height;
  9596. ch.parent = this;
  9597. }
  9598. this.size = size;
  9599. this.height = height;
  9600. this.parent = null;
  9601. }
  9602. BranchChunk.prototype = {
  9603. chunkSize: function() { return this.size },
  9604. removeInner: function(at, n) {
  9605. this.size -= n;
  9606. for (var i = 0; i < this.children.length; ++i) {
  9607. var child = this.children[i], sz = child.chunkSize();
  9608. if (at < sz) {
  9609. var rm = Math.min(n, sz - at), oldHeight = child.height;
  9610. child.removeInner(at, rm);
  9611. this.height -= oldHeight - child.height;
  9612. if (sz == rm) { this.children.splice(i--, 1); child.parent = null; }
  9613. if ((n -= rm) == 0) { break }
  9614. at = 0;
  9615. } else { at -= sz; }
  9616. }
  9617. // If the result is smaller than 25 lines, ensure that it is a
  9618. // single leaf node.
  9619. if (this.size - n < 25 &&
  9620. (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
  9621. var lines = [];
  9622. this.collapse(lines);
  9623. this.children = [new LeafChunk(lines)];
  9624. this.children[0].parent = this;
  9625. }
  9626. },
  9627. collapse: function(lines) {
  9628. for (var i = 0; i < this.children.length; ++i) { this.children[i].collapse(lines); }
  9629. },
  9630. insertInner: function(at, lines, height) {
  9631. this.size += lines.length;
  9632. this.height += height;
  9633. for (var i = 0; i < this.children.length; ++i) {
  9634. var child = this.children[i], sz = child.chunkSize();
  9635. if (at <= sz) {
  9636. child.insertInner(at, lines, height);
  9637. if (child.lines && child.lines.length > 50) {
  9638. // To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced.
  9639. // Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest.
  9640. var remaining = child.lines.length % 25 + 25;
  9641. for (var pos = remaining; pos < child.lines.length;) {
  9642. var leaf = new LeafChunk(child.lines.slice(pos, pos += 25));
  9643. child.height -= leaf.height;
  9644. this.children.splice(++i, 0, leaf);
  9645. leaf.parent = this;
  9646. }
  9647. child.lines = child.lines.slice(0, remaining);
  9648. this.maybeSpill();
  9649. }
  9650. break
  9651. }
  9652. at -= sz;
  9653. }
  9654. },
  9655. // When a node has grown, check whether it should be split.
  9656. maybeSpill: function() {
  9657. if (this.children.length <= 10) { return }
  9658. var me = this;
  9659. do {
  9660. var spilled = me.children.splice(me.children.length - 5, 5);
  9661. var sibling = new BranchChunk(spilled);
  9662. if (!me.parent) { // Become the parent node
  9663. var copy = new BranchChunk(me.children);
  9664. copy.parent = me;
  9665. me.children = [copy, sibling];
  9666. me = copy;
  9667. } else {
  9668. me.size -= sibling.size;
  9669. me.height -= sibling.height;
  9670. var myIndex = indexOf(me.parent.children, me);
  9671. me.parent.children.splice(myIndex + 1, 0, sibling);
  9672. }
  9673. sibling.parent = me.parent;
  9674. } while (me.children.length > 10)
  9675. me.parent.maybeSpill();
  9676. },
  9677. iterN: function(at, n, op) {
  9678. for (var i = 0; i < this.children.length; ++i) {
  9679. var child = this.children[i], sz = child.chunkSize();
  9680. if (at < sz) {
  9681. var used = Math.min(n, sz - at);
  9682. if (child.iterN(at, used, op)) { return true }
  9683. if ((n -= used) == 0) { break }
  9684. at = 0;
  9685. } else { at -= sz; }
  9686. }
  9687. }
  9688. };
  9689. // Line widgets are block elements displayed above or below a line.
  9690. var LineWidget = function(doc, node, options) {
  9691. if (options) { for (var opt in options) { if (options.hasOwnProperty(opt))
  9692. { this[opt] = options[opt]; } } }
  9693. this.doc = doc;
  9694. this.node = node;
  9695. };
  9696. LineWidget.prototype.clear = function () {
  9697. var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line);
  9698. if (no == null || !ws) { return }
  9699. for (var i = 0; i < ws.length; ++i) { if (ws[i] == this) { ws.splice(i--, 1); } }
  9700. if (!ws.length) { line.widgets = null; }
  9701. var height = widgetHeight(this);
  9702. updateLineHeight(line, Math.max(0, line.height - height));
  9703. if (cm) {
  9704. runInOp(cm, function () {
  9705. adjustScrollWhenAboveVisible(cm, line, -height);
  9706. regLineChange(cm, no, "widget");
  9707. });
  9708. signalLater(cm, "lineWidgetCleared", cm, this, no);
  9709. }
  9710. };
  9711. LineWidget.prototype.changed = function () {
  9712. var this$1 = this;
  9713. var oldH = this.height, cm = this.doc.cm, line = this.line;
  9714. this.height = null;
  9715. var diff = widgetHeight(this) - oldH;
  9716. if (!diff) { return }
  9717. if (!lineIsHidden(this.doc, line)) { updateLineHeight(line, line.height + diff); }
  9718. if (cm) {
  9719. runInOp(cm, function () {
  9720. cm.curOp.forceUpdate = true;
  9721. adjustScrollWhenAboveVisible(cm, line, diff);
  9722. signalLater(cm, "lineWidgetChanged", cm, this$1, lineNo(line));
  9723. });
  9724. }
  9725. };
  9726. eventMixin(LineWidget);
  9727. function adjustScrollWhenAboveVisible(cm, line, diff) {
  9728. if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
  9729. { addToScrollTop(cm, diff); }
  9730. }
  9731. function addLineWidget(doc, handle, node, options) {
  9732. var widget = new LineWidget(doc, node, options);
  9733. var cm = doc.cm;
  9734. if (cm && widget.noHScroll) { cm.display.alignWidgets = true; }
  9735. changeLine(doc, handle, "widget", function (line) {
  9736. var widgets = line.widgets || (line.widgets = []);
  9737. if (widget.insertAt == null) { widgets.push(widget); }
  9738. else { widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget); }
  9739. widget.line = line;
  9740. if (cm && !lineIsHidden(doc, line)) {
  9741. var aboveVisible = heightAtLine(line) < doc.scrollTop;
  9742. updateLineHeight(line, line.height + widgetHeight(widget));
  9743. if (aboveVisible) { addToScrollTop(cm, widget.height); }
  9744. cm.curOp.forceUpdate = true;
  9745. }
  9746. return true
  9747. });
  9748. if (cm) { signalLater(cm, "lineWidgetAdded", cm, widget, typeof handle == "number" ? handle : lineNo(handle)); }
  9749. return widget
  9750. }
  9751. // TEXTMARKERS
  9752. // Created with markText and setBookmark methods. A TextMarker is a
  9753. // handle that can be used to clear or find a marked position in the
  9754. // document. Line objects hold arrays (markedSpans) containing
  9755. // {from, to, marker} object pointing to such marker objects, and
  9756. // indicating that such a marker is present on that line. Multiple
  9757. // lines may point to the same marker when it spans across lines.
  9758. // The spans will have null for their from/to properties when the
  9759. // marker continues beyond the start/end of the line. Markers have
  9760. // links back to the lines they currently touch.
  9761. // Collapsed markers have unique ids, in order to be able to order
  9762. // them, which is needed for uniquely determining an outer marker
  9763. // when they overlap (they may nest, but not partially overlap).
  9764. var nextMarkerId = 0;
  9765. var TextMarker = function(doc, type) {
  9766. this.lines = [];
  9767. this.type = type;
  9768. this.doc = doc;
  9769. this.id = ++nextMarkerId;
  9770. };
  9771. // Clear the marker.
  9772. TextMarker.prototype.clear = function () {
  9773. if (this.explicitlyCleared) { return }
  9774. var cm = this.doc.cm, withOp = cm && !cm.curOp;
  9775. if (withOp) { startOperation(cm); }
  9776. if (hasHandler(this, "clear")) {
  9777. var found = this.find();
  9778. if (found) { signalLater(this, "clear", found.from, found.to); }
  9779. }
  9780. var min = null, max = null;
  9781. for (var i = 0; i < this.lines.length; ++i) {
  9782. var line = this.lines[i];
  9783. var span = getMarkedSpanFor(line.markedSpans, this);
  9784. if (cm && !this.collapsed) { regLineChange(cm, lineNo(line), "text"); }
  9785. else if (cm) {
  9786. if (span.to != null) { max = lineNo(line); }
  9787. if (span.from != null) { min = lineNo(line); }
  9788. }
  9789. line.markedSpans = removeMarkedSpan(line.markedSpans, span);
  9790. if (span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm)
  9791. { updateLineHeight(line, textHeight(cm.display)); }
  9792. }
  9793. if (cm && this.collapsed && !cm.options.lineWrapping) { for (var i$1 = 0; i$1 < this.lines.length; ++i$1) {
  9794. var visual = visualLine(this.lines[i$1]), len = lineLength(visual);
  9795. if (len > cm.display.maxLineLength) {
  9796. cm.display.maxLine = visual;
  9797. cm.display.maxLineLength = len;
  9798. cm.display.maxLineChanged = true;
  9799. }
  9800. } }
  9801. if (min != null && cm && this.collapsed) { regChange(cm, min, max + 1); }
  9802. this.lines.length = 0;
  9803. this.explicitlyCleared = true;
  9804. if (this.atomic && this.doc.cantEdit) {
  9805. this.doc.cantEdit = false;
  9806. if (cm) { reCheckSelection(cm.doc); }
  9807. }
  9808. if (cm) { signalLater(cm, "markerCleared", cm, this, min, max); }
  9809. if (withOp) { endOperation(cm); }
  9810. if (this.parent) { this.parent.clear(); }
  9811. };
  9812. // Find the position of the marker in the document. Returns a {from,
  9813. // to} object by default. Side can be passed to get a specific side
  9814. // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
  9815. // Pos objects returned contain a line object, rather than a line
  9816. // number (used to prevent looking up the same line twice).
  9817. TextMarker.prototype.find = function (side, lineObj) {
  9818. if (side == null && this.type == "bookmark") { side = 1; }
  9819. var from, to;
  9820. for (var i = 0; i < this.lines.length; ++i) {
  9821. var line = this.lines[i];
  9822. var span = getMarkedSpanFor(line.markedSpans, this);
  9823. if (span.from != null) {
  9824. from = Pos(lineObj ? line : lineNo(line), span.from);
  9825. if (side == -1) { return from }
  9826. }
  9827. if (span.to != null) {
  9828. to = Pos(lineObj ? line : lineNo(line), span.to);
  9829. if (side == 1) { return to }
  9830. }
  9831. }
  9832. return from && {from: from, to: to}
  9833. };
  9834. // Signals that the marker's widget changed, and surrounding layout
  9835. // should be recomputed.
  9836. TextMarker.prototype.changed = function () {
  9837. var this$1 = this;
  9838. var pos = this.find(-1, true), widget = this, cm = this.doc.cm;
  9839. if (!pos || !cm) { return }
  9840. runInOp(cm, function () {
  9841. var line = pos.line, lineN = lineNo(pos.line);
  9842. var view = findViewForLine(cm, lineN);
  9843. if (view) {
  9844. clearLineMeasurementCacheFor(view);
  9845. cm.curOp.selectionChanged = cm.curOp.forceUpdate = true;
  9846. }
  9847. cm.curOp.updateMaxLine = true;
  9848. if (!lineIsHidden(widget.doc, line) && widget.height != null) {
  9849. var oldHeight = widget.height;
  9850. widget.height = null;
  9851. var dHeight = widgetHeight(widget) - oldHeight;
  9852. if (dHeight)
  9853. { updateLineHeight(line, line.height + dHeight); }
  9854. }
  9855. signalLater(cm, "markerChanged", cm, this$1);
  9856. });
  9857. };
  9858. TextMarker.prototype.attachLine = function (line) {
  9859. if (!this.lines.length && this.doc.cm) {
  9860. var op = this.doc.cm.curOp;
  9861. if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
  9862. { (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this); }
  9863. }
  9864. this.lines.push(line);
  9865. };
  9866. TextMarker.prototype.detachLine = function (line) {
  9867. this.lines.splice(indexOf(this.lines, line), 1);
  9868. if (!this.lines.length && this.doc.cm) {
  9869. var op = this.doc.cm.curOp
  9870. ;(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this);
  9871. }
  9872. };
  9873. eventMixin(TextMarker);
  9874. // Create a marker, wire it up to the right lines, and
  9875. function markText(doc, from, to, options, type) {
  9876. // Shared markers (across linked documents) are handled separately
  9877. // (markTextShared will call out to this again, once per
  9878. // document).
  9879. if (options && options.shared) { return markTextShared(doc, from, to, options, type) }
  9880. // Ensure we are in an operation.
  9881. if (doc.cm && !doc.cm.curOp) { return operation(doc.cm, markText)(doc, from, to, options, type) }
  9882. var marker = new TextMarker(doc, type), diff = cmp(from, to);
  9883. if (options) { copyObj(options, marker, false); }
  9884. // Don't connect empty markers unless clearWhenEmpty is false
  9885. if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)
  9886. { return marker }
  9887. if (marker.replacedWith) {
  9888. // Showing up as a widget implies collapsed (widget replaces text)
  9889. marker.collapsed = true;
  9890. marker.widgetNode = eltP("span", [marker.replacedWith], "CodeMirror-widget");
  9891. if (!options.handleMouseEvents) { marker.widgetNode.setAttribute("cm-ignore-events", "true"); }
  9892. if (options.insertLeft) { marker.widgetNode.insertLeft = true; }
  9893. }
  9894. if (marker.collapsed) {
  9895. if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||
  9896. from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))
  9897. { throw new Error("Inserting collapsed marker partially overlapping an existing one") }
  9898. seeCollapsedSpans();
  9899. }
  9900. if (marker.addToHistory)
  9901. { addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN); }
  9902. var curLine = from.line, cm = doc.cm, updateMaxLine;
  9903. doc.iter(curLine, to.line + 1, function (line) {
  9904. if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)
  9905. { updateMaxLine = true; }
  9906. if (marker.collapsed && curLine != from.line) { updateLineHeight(line, 0); }
  9907. addMarkedSpan(line, new MarkedSpan(marker,
  9908. curLine == from.line ? from.ch : null,
  9909. curLine == to.line ? to.ch : null));
  9910. ++curLine;
  9911. });
  9912. // lineIsHidden depends on the presence of the spans, so needs a second pass
  9913. if (marker.collapsed) { doc.iter(from.line, to.line + 1, function (line) {
  9914. if (lineIsHidden(doc, line)) { updateLineHeight(line, 0); }
  9915. }); }
  9916. if (marker.clearOnEnter) { on(marker, "beforeCursorEnter", function () { return marker.clear(); }); }
  9917. if (marker.readOnly) {
  9918. seeReadOnlySpans();
  9919. if (doc.history.done.length || doc.history.undone.length)
  9920. { doc.clearHistory(); }
  9921. }
  9922. if (marker.collapsed) {
  9923. marker.id = ++nextMarkerId;
  9924. marker.atomic = true;
  9925. }
  9926. if (cm) {
  9927. // Sync editor state
  9928. if (updateMaxLine) { cm.curOp.updateMaxLine = true; }
  9929. if (marker.collapsed)
  9930. { regChange(cm, from.line, to.line + 1); }
  9931. else if (marker.className || marker.startStyle || marker.endStyle || marker.css ||
  9932. marker.attributes || marker.title)
  9933. { for (var i = from.line; i <= to.line; i++) { regLineChange(cm, i, "text"); } }
  9934. if (marker.atomic) { reCheckSelection(cm.doc); }
  9935. signalLater(cm, "markerAdded", cm, marker);
  9936. }
  9937. return marker
  9938. }
  9939. // SHARED TEXTMARKERS
  9940. // A shared marker spans multiple linked documents. It is
  9941. // implemented as a meta-marker-object controlling multiple normal
  9942. // markers.
  9943. var SharedTextMarker = function(markers, primary) {
  9944. this.markers = markers;
  9945. this.primary = primary;
  9946. for (var i = 0; i < markers.length; ++i)
  9947. { markers[i].parent = this; }
  9948. };
  9949. SharedTextMarker.prototype.clear = function () {
  9950. if (this.explicitlyCleared) { return }
  9951. this.explicitlyCleared = true;
  9952. for (var i = 0; i < this.markers.length; ++i)
  9953. { this.markers[i].clear(); }
  9954. signalLater(this, "clear");
  9955. };
  9956. SharedTextMarker.prototype.find = function (side, lineObj) {
  9957. return this.primary.find(side, lineObj)
  9958. };
  9959. eventMixin(SharedTextMarker);
  9960. function markTextShared(doc, from, to, options, type) {
  9961. options = copyObj(options);
  9962. options.shared = false;
  9963. var markers = [markText(doc, from, to, options, type)], primary = markers[0];
  9964. var widget = options.widgetNode;
  9965. linkedDocs(doc, function (doc) {
  9966. if (widget) { options.widgetNode = widget.cloneNode(true); }
  9967. markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type));
  9968. for (var i = 0; i < doc.linked.length; ++i)
  9969. { if (doc.linked[i].isParent) { return } }
  9970. primary = lst(markers);
  9971. });
  9972. return new SharedTextMarker(markers, primary)
  9973. }
  9974. function findSharedMarkers(doc) {
  9975. return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), function (m) { return m.parent; })
  9976. }
  9977. function copySharedMarkers(doc, markers) {
  9978. for (var i = 0; i < markers.length; i++) {
  9979. var marker = markers[i], pos = marker.find();
  9980. var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to);
  9981. if (cmp(mFrom, mTo)) {
  9982. var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type);
  9983. marker.markers.push(subMark);
  9984. subMark.parent = marker;
  9985. }
  9986. }
  9987. }
  9988. function detachSharedMarkers(markers) {
  9989. var loop = function ( i ) {
  9990. var marker = markers[i], linked = [marker.primary.doc];
  9991. linkedDocs(marker.primary.doc, function (d) { return linked.push(d); });
  9992. for (var j = 0; j < marker.markers.length; j++) {
  9993. var subMarker = marker.markers[j];
  9994. if (indexOf(linked, subMarker.doc) == -1) {
  9995. subMarker.parent = null;
  9996. marker.markers.splice(j--, 1);
  9997. }
  9998. }
  9999. };
  10000. for (var i = 0; i < markers.length; i++) loop( i );
  10001. }
  10002. var nextDocId = 0;
  10003. var Doc = function(text, mode, firstLine, lineSep, direction) {
  10004. if (!(this instanceof Doc)) { return new Doc(text, mode, firstLine, lineSep, direction) }
  10005. if (firstLine == null) { firstLine = 0; }
  10006. BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
  10007. this.first = firstLine;
  10008. this.scrollTop = this.scrollLeft = 0;
  10009. this.cantEdit = false;
  10010. this.cleanGeneration = 1;
  10011. this.modeFrontier = this.highlightFrontier = firstLine;
  10012. var start = Pos(firstLine, 0);
  10013. this.sel = simpleSelection(start);
  10014. this.history = new History(null);
  10015. this.id = ++nextDocId;
  10016. this.modeOption = mode;
  10017. this.lineSep = lineSep;
  10018. this.direction = (direction == "rtl") ? "rtl" : "ltr";
  10019. this.extend = false;
  10020. if (typeof text == "string") { text = this.splitLines(text); }
  10021. updateDoc(this, {from: start, to: start, text: text});
  10022. setSelection(this, simpleSelection(start), sel_dontScroll);
  10023. };
  10024. Doc.prototype = createObj(BranchChunk.prototype, {
  10025. constructor: Doc,
  10026. // Iterate over the document. Supports two forms -- with only one
  10027. // argument, it calls that for each line in the document. With
  10028. // three, it iterates over the range given by the first two (with
  10029. // the second being non-inclusive).
  10030. iter: function(from, to, op) {
  10031. if (op) { this.iterN(from - this.first, to - from, op); }
  10032. else { this.iterN(this.first, this.first + this.size, from); }
  10033. },
  10034. // Non-public interface for adding and removing lines.
  10035. insert: function(at, lines) {
  10036. var height = 0;
  10037. for (var i = 0; i < lines.length; ++i) { height += lines[i].height; }
  10038. this.insertInner(at - this.first, lines, height);
  10039. },
  10040. remove: function(at, n) { this.removeInner(at - this.first, n); },
  10041. // From here, the methods are part of the public interface. Most
  10042. // are also available from CodeMirror (editor) instances.
  10043. getValue: function(lineSep) {
  10044. var lines = getLines(this, this.first, this.first + this.size);
  10045. if (lineSep === false) { return lines }
  10046. return lines.join(lineSep || this.lineSeparator())
  10047. },
  10048. setValue: docMethodOp(function(code) {
  10049. var top = Pos(this.first, 0), last = this.first + this.size - 1;
  10050. makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
  10051. text: this.splitLines(code), origin: "setValue", full: true}, true);
  10052. if (this.cm) { scrollToCoords(this.cm, 0, 0); }
  10053. setSelection(this, simpleSelection(top), sel_dontScroll);
  10054. }),
  10055. replaceRange: function(code, from, to, origin) {
  10056. from = clipPos(this, from);
  10057. to = to ? clipPos(this, to) : from;
  10058. replaceRange(this, code, from, to, origin);
  10059. },
  10060. getRange: function(from, to, lineSep) {
  10061. var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
  10062. if (lineSep === false) { return lines }
  10063. return lines.join(lineSep || this.lineSeparator())
  10064. },
  10065. getLine: function(line) {var l = this.getLineHandle(line); return l && l.text},
  10066. getLineHandle: function(line) {if (isLine(this, line)) { return getLine(this, line) }},
  10067. getLineNumber: function(line) {return lineNo(line)},
  10068. getLineHandleVisualStart: function(line) {
  10069. if (typeof line == "number") { line = getLine(this, line); }
  10070. return visualLine(line)
  10071. },
  10072. lineCount: function() {return this.size},
  10073. firstLine: function() {return this.first},
  10074. lastLine: function() {return this.first + this.size - 1},
  10075. clipPos: function(pos) {return clipPos(this, pos)},
  10076. getCursor: function(start) {
  10077. var range = this.sel.primary(), pos;
  10078. if (start == null || start == "head") { pos = range.head; }
  10079. else if (start == "anchor") { pos = range.anchor; }
  10080. else if (start == "end" || start == "to" || start === false) { pos = range.to(); }
  10081. else { pos = range.from(); }
  10082. return pos
  10083. },
  10084. listSelections: function() { return this.sel.ranges },
  10085. somethingSelected: function() {return this.sel.somethingSelected()},
  10086. setCursor: docMethodOp(function(line, ch, options) {
  10087. setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options);
  10088. }),
  10089. setSelection: docMethodOp(function(anchor, head, options) {
  10090. setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options);
  10091. }),
  10092. extendSelection: docMethodOp(function(head, other, options) {
  10093. extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
  10094. }),
  10095. extendSelections: docMethodOp(function(heads, options) {
  10096. extendSelections(this, clipPosArray(this, heads), options);
  10097. }),
  10098. extendSelectionsBy: docMethodOp(function(f, options) {
  10099. var heads = map(this.sel.ranges, f);
  10100. extendSelections(this, clipPosArray(this, heads), options);
  10101. }),
  10102. setSelections: docMethodOp(function(ranges, primary, options) {
  10103. if (!ranges.length) { return }
  10104. var out = [];
  10105. for (var i = 0; i < ranges.length; i++)
  10106. { out[i] = new Range(clipPos(this, ranges[i].anchor),
  10107. clipPos(this, ranges[i].head)); }
  10108. if (primary == null) { primary = Math.min(ranges.length - 1, this.sel.primIndex); }
  10109. setSelection(this, normalizeSelection(this.cm, out, primary), options);
  10110. }),
  10111. addSelection: docMethodOp(function(anchor, head, options) {
  10112. var ranges = this.sel.ranges.slice(0);
  10113. ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)));
  10114. setSelection(this, normalizeSelection(this.cm, ranges, ranges.length - 1), options);
  10115. }),
  10116. getSelection: function(lineSep) {
  10117. var ranges = this.sel.ranges, lines;
  10118. for (var i = 0; i < ranges.length; i++) {
  10119. var sel = getBetween(this, ranges[i].from(), ranges[i].to());
  10120. lines = lines ? lines.concat(sel) : sel;
  10121. }
  10122. if (lineSep === false) { return lines }
  10123. else { return lines.join(lineSep || this.lineSeparator()) }
  10124. },
  10125. getSelections: function(lineSep) {
  10126. var parts = [], ranges = this.sel.ranges;
  10127. for (var i = 0; i < ranges.length; i++) {
  10128. var sel = getBetween(this, ranges[i].from(), ranges[i].to());
  10129. if (lineSep !== false) { sel = sel.join(lineSep || this.lineSeparator()); }
  10130. parts[i] = sel;
  10131. }
  10132. return parts
  10133. },
  10134. replaceSelection: function(code, collapse, origin) {
  10135. var dup = [];
  10136. for (var i = 0; i < this.sel.ranges.length; i++)
  10137. { dup[i] = code; }
  10138. this.replaceSelections(dup, collapse, origin || "+input");
  10139. },
  10140. replaceSelections: docMethodOp(function(code, collapse, origin) {
  10141. var changes = [], sel = this.sel;
  10142. for (var i = 0; i < sel.ranges.length; i++) {
  10143. var range = sel.ranges[i];
  10144. changes[i] = {from: range.from(), to: range.to(), text: this.splitLines(code[i]), origin: origin};
  10145. }
  10146. var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
  10147. for (var i$1 = changes.length - 1; i$1 >= 0; i$1--)
  10148. { makeChange(this, changes[i$1]); }
  10149. if (newSel) { setSelectionReplaceHistory(this, newSel); }
  10150. else if (this.cm) { ensureCursorVisible(this.cm); }
  10151. }),
  10152. undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}),
  10153. redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}),
  10154. undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}),
  10155. redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}),
  10156. setExtending: function(val) {this.extend = val;},
  10157. getExtending: function() {return this.extend},
  10158. historySize: function() {
  10159. var hist = this.history, done = 0, undone = 0;
  10160. for (var i = 0; i < hist.done.length; i++) { if (!hist.done[i].ranges) { ++done; } }
  10161. for (var i$1 = 0; i$1 < hist.undone.length; i$1++) { if (!hist.undone[i$1].ranges) { ++undone; } }
  10162. return {undo: done, redo: undone}
  10163. },
  10164. clearHistory: function() {
  10165. var this$1 = this;
  10166. this.history = new History(this.history.maxGeneration);
  10167. linkedDocs(this, function (doc) { return doc.history = this$1.history; }, true);
  10168. },
  10169. markClean: function() {
  10170. this.cleanGeneration = this.changeGeneration(true);
  10171. },
  10172. changeGeneration: function(forceSplit) {
  10173. if (forceSplit)
  10174. { this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null; }
  10175. return this.history.generation
  10176. },
  10177. isClean: function (gen) {
  10178. return this.history.generation == (gen || this.cleanGeneration)
  10179. },
  10180. getHistory: function() {
  10181. return {done: copyHistoryArray(this.history.done),
  10182. undone: copyHistoryArray(this.history.undone)}
  10183. },
  10184. setHistory: function(histData) {
  10185. var hist = this.history = new History(this.history.maxGeneration);
  10186. hist.done = copyHistoryArray(histData.done.slice(0), null, true);
  10187. hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
  10188. },
  10189. setGutterMarker: docMethodOp(function(line, gutterID, value) {
  10190. return changeLine(this, line, "gutter", function (line) {
  10191. var markers = line.gutterMarkers || (line.gutterMarkers = {});
  10192. markers[gutterID] = value;
  10193. if (!value && isEmpty(markers)) { line.gutterMarkers = null; }
  10194. return true
  10195. })
  10196. }),
  10197. clearGutter: docMethodOp(function(gutterID) {
  10198. var this$1 = this;
  10199. this.iter(function (line) {
  10200. if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
  10201. changeLine(this$1, line, "gutter", function () {
  10202. line.gutterMarkers[gutterID] = null;
  10203. if (isEmpty(line.gutterMarkers)) { line.gutterMarkers = null; }
  10204. return true
  10205. });
  10206. }
  10207. });
  10208. }),
  10209. lineInfo: function(line) {
  10210. var n;
  10211. if (typeof line == "number") {
  10212. if (!isLine(this, line)) { return null }
  10213. n = line;
  10214. line = getLine(this, line);
  10215. if (!line) { return null }
  10216. } else {
  10217. n = lineNo(line);
  10218. if (n == null) { return null }
  10219. }
  10220. return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
  10221. textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
  10222. widgets: line.widgets}
  10223. },
  10224. addLineClass: docMethodOp(function(handle, where, cls) {
  10225. return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
  10226. var prop = where == "text" ? "textClass"
  10227. : where == "background" ? "bgClass"
  10228. : where == "gutter" ? "gutterClass" : "wrapClass";
  10229. if (!line[prop]) { line[prop] = cls; }
  10230. else if (classTest(cls).test(line[prop])) { return false }
  10231. else { line[prop] += " " + cls; }
  10232. return true
  10233. })
  10234. }),
  10235. removeLineClass: docMethodOp(function(handle, where, cls) {
  10236. return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
  10237. var prop = where == "text" ? "textClass"
  10238. : where == "background" ? "bgClass"
  10239. : where == "gutter" ? "gutterClass" : "wrapClass";
  10240. var cur = line[prop];
  10241. if (!cur) { return false }
  10242. else if (cls == null) { line[prop] = null; }
  10243. else {
  10244. var found = cur.match(classTest(cls));
  10245. if (!found) { return false }
  10246. var end = found.index + found[0].length;
  10247. line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null;
  10248. }
  10249. return true
  10250. })
  10251. }),
  10252. addLineWidget: docMethodOp(function(handle, node, options) {
  10253. return addLineWidget(this, handle, node, options)
  10254. }),
  10255. removeLineWidget: function(widget) { widget.clear(); },
  10256. markText: function(from, to, options) {
  10257. return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range")
  10258. },
  10259. setBookmark: function(pos, options) {
  10260. var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
  10261. insertLeft: options && options.insertLeft,
  10262. clearWhenEmpty: false, shared: options && options.shared,
  10263. handleMouseEvents: options && options.handleMouseEvents};
  10264. pos = clipPos(this, pos);
  10265. return markText(this, pos, pos, realOpts, "bookmark")
  10266. },
  10267. findMarksAt: function(pos) {
  10268. pos = clipPos(this, pos);
  10269. var markers = [], spans = getLine(this, pos.line).markedSpans;
  10270. if (spans) { for (var i = 0; i < spans.length; ++i) {
  10271. var span = spans[i];
  10272. if ((span.from == null || span.from <= pos.ch) &&
  10273. (span.to == null || span.to >= pos.ch))
  10274. { markers.push(span.marker.parent || span.marker); }
  10275. } }
  10276. return markers
  10277. },
  10278. findMarks: function(from, to, filter) {
  10279. from = clipPos(this, from); to = clipPos(this, to);
  10280. var found = [], lineNo = from.line;
  10281. this.iter(from.line, to.line + 1, function (line) {
  10282. var spans = line.markedSpans;
  10283. if (spans) { for (var i = 0; i < spans.length; i++) {
  10284. var span = spans[i];
  10285. if (!(span.to != null && lineNo == from.line && from.ch >= span.to ||
  10286. span.from == null && lineNo != from.line ||
  10287. span.from != null && lineNo == to.line && span.from >= to.ch) &&
  10288. (!filter || filter(span.marker)))
  10289. { found.push(span.marker.parent || span.marker); }
  10290. } }
  10291. ++lineNo;
  10292. });
  10293. return found
  10294. },
  10295. getAllMarks: function() {
  10296. var markers = [];
  10297. this.iter(function (line) {
  10298. var sps = line.markedSpans;
  10299. if (sps) { for (var i = 0; i < sps.length; ++i)
  10300. { if (sps[i].from != null) { markers.push(sps[i].marker); } } }
  10301. });
  10302. return markers
  10303. },
  10304. posFromIndex: function(off) {
  10305. var ch, lineNo = this.first, sepSize = this.lineSeparator().length;
  10306. this.iter(function (line) {
  10307. var sz = line.text.length + sepSize;
  10308. if (sz > off) { ch = off; return true }
  10309. off -= sz;
  10310. ++lineNo;
  10311. });
  10312. return clipPos(this, Pos(lineNo, ch))
  10313. },
  10314. indexFromPos: function (coords) {
  10315. coords = clipPos(this, coords);
  10316. var index = coords.ch;
  10317. if (coords.line < this.first || coords.ch < 0) { return 0 }
  10318. var sepSize = this.lineSeparator().length;
  10319. this.iter(this.first, coords.line, function (line) { // iter aborts when callback returns a truthy value
  10320. index += line.text.length + sepSize;
  10321. });
  10322. return index
  10323. },
  10324. copy: function(copyHistory) {
  10325. var doc = new Doc(getLines(this, this.first, this.first + this.size),
  10326. this.modeOption, this.first, this.lineSep, this.direction);
  10327. doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
  10328. doc.sel = this.sel;
  10329. doc.extend = false;
  10330. if (copyHistory) {
  10331. doc.history.undoDepth = this.history.undoDepth;
  10332. doc.setHistory(this.getHistory());
  10333. }
  10334. return doc
  10335. },
  10336. linkedDoc: function(options) {
  10337. if (!options) { options = {}; }
  10338. var from = this.first, to = this.first + this.size;
  10339. if (options.from != null && options.from > from) { from = options.from; }
  10340. if (options.to != null && options.to < to) { to = options.to; }
  10341. var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep, this.direction);
  10342. if (options.sharedHist) { copy.history = this.history
  10343. ; }(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
  10344. copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
  10345. copySharedMarkers(copy, findSharedMarkers(this));
  10346. return copy
  10347. },
  10348. unlinkDoc: function(other) {
  10349. if (other instanceof CodeMirror) { other = other.doc; }
  10350. if (this.linked) { for (var i = 0; i < this.linked.length; ++i) {
  10351. var link = this.linked[i];
  10352. if (link.doc != other) { continue }
  10353. this.linked.splice(i, 1);
  10354. other.unlinkDoc(this);
  10355. detachSharedMarkers(findSharedMarkers(this));
  10356. break
  10357. } }
  10358. // If the histories were shared, split them again
  10359. if (other.history == this.history) {
  10360. var splitIds = [other.id];
  10361. linkedDocs(other, function (doc) { return splitIds.push(doc.id); }, true);
  10362. other.history = new History(null);
  10363. other.history.done = copyHistoryArray(this.history.done, splitIds);
  10364. other.history.undone = copyHistoryArray(this.history.undone, splitIds);
  10365. }
  10366. },
  10367. iterLinkedDocs: function(f) {linkedDocs(this, f);},
  10368. getMode: function() {return this.mode},
  10369. getEditor: function() {return this.cm},
  10370. splitLines: function(str) {
  10371. if (this.lineSep) { return str.split(this.lineSep) }
  10372. return splitLinesAuto(str)
  10373. },
  10374. lineSeparator: function() { return this.lineSep || "\n" },
  10375. setDirection: docMethodOp(function (dir) {
  10376. if (dir != "rtl") { dir = "ltr"; }
  10377. if (dir == this.direction) { return }
  10378. this.direction = dir;
  10379. this.iter(function (line) { return line.order = null; });
  10380. if (this.cm) { directionChanged(this.cm); }
  10381. })
  10382. });
  10383. // Public alias.
  10384. Doc.prototype.eachLine = Doc.prototype.iter;
  10385. // Kludge to work around strange IE behavior where it'll sometimes
  10386. // re-fire a series of drag-related events right after the drop (#1551)
  10387. var lastDrop = 0;
  10388. function onDrop(e) {
  10389. var cm = this;
  10390. clearDragCursor(cm);
  10391. if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
  10392. { return }
  10393. e_preventDefault(e);
  10394. if (ie) { lastDrop = +new Date; }
  10395. var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
  10396. if (!pos || cm.isReadOnly()) { return }
  10397. // Might be a file drop, in which case we simply extract the text
  10398. // and insert it.
  10399. if (files && files.length && window.FileReader && window.File) {
  10400. var n = files.length, text = Array(n), read = 0;
  10401. var markAsReadAndPasteIfAllFilesAreRead = function () {
  10402. if (++read == n) {
  10403. operation(cm, function () {
  10404. pos = clipPos(cm.doc, pos);
  10405. var change = {from: pos, to: pos,
  10406. text: cm.doc.splitLines(
  10407. text.filter(function (t) { return t != null; }).join(cm.doc.lineSeparator())),
  10408. origin: "paste"};
  10409. makeChange(cm.doc, change);
  10410. setSelectionReplaceHistory(cm.doc, simpleSelection(clipPos(cm.doc, pos), clipPos(cm.doc, changeEnd(change))));
  10411. })();
  10412. }
  10413. };
  10414. var readTextFromFile = function (file, i) {
  10415. if (cm.options.allowDropFileTypes &&
  10416. indexOf(cm.options.allowDropFileTypes, file.type) == -1) {
  10417. markAsReadAndPasteIfAllFilesAreRead();
  10418. return
  10419. }
  10420. var reader = new FileReader;
  10421. reader.onerror = function () { return markAsReadAndPasteIfAllFilesAreRead(); };
  10422. reader.onload = function () {
  10423. var content = reader.result;
  10424. if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) {
  10425. markAsReadAndPasteIfAllFilesAreRead();
  10426. return
  10427. }
  10428. text[i] = content;
  10429. markAsReadAndPasteIfAllFilesAreRead();
  10430. };
  10431. reader.readAsText(file);
  10432. };
  10433. for (var i = 0; i < files.length; i++) { readTextFromFile(files[i], i); }
  10434. } else { // Normal drop
  10435. // Don't do a replace if the drop happened inside of the selected text.
  10436. if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
  10437. cm.state.draggingText(e);
  10438. // Ensure the editor is re-focused
  10439. setTimeout(function () { return cm.display.input.focus(); }, 20);
  10440. return
  10441. }
  10442. try {
  10443. var text$1 = e.dataTransfer.getData("Text");
  10444. if (text$1) {
  10445. var selected;
  10446. if (cm.state.draggingText && !cm.state.draggingText.copy)
  10447. { selected = cm.listSelections(); }
  10448. setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
  10449. if (selected) { for (var i$1 = 0; i$1 < selected.length; ++i$1)
  10450. { replaceRange(cm.doc, "", selected[i$1].anchor, selected[i$1].head, "drag"); } }
  10451. cm.replaceSelection(text$1, "around", "paste");
  10452. cm.display.input.focus();
  10453. }
  10454. }
  10455. catch(e$1){}
  10456. }
  10457. }
  10458. function onDragStart(cm, e) {
  10459. if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return }
  10460. if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) { return }
  10461. e.dataTransfer.setData("Text", cm.getSelection());
  10462. e.dataTransfer.effectAllowed = "copyMove";
  10463. // Use dummy image instead of default browsers image.
  10464. // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
  10465. if (e.dataTransfer.setDragImage && !safari) {
  10466. var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
  10467. img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
  10468. if (presto) {
  10469. img.width = img.height = 1;
  10470. cm.display.wrapper.appendChild(img);
  10471. // Force a relayout, or Opera won't use our image for some obscure reason
  10472. img._top = img.offsetTop;
  10473. }
  10474. e.dataTransfer.setDragImage(img, 0, 0);
  10475. if (presto) { img.parentNode.removeChild(img); }
  10476. }
  10477. }
  10478. function onDragOver(cm, e) {
  10479. var pos = posFromMouse(cm, e);
  10480. if (!pos) { return }
  10481. var frag = document.createDocumentFragment();
  10482. drawSelectionCursor(cm, pos, frag);
  10483. if (!cm.display.dragCursor) {
  10484. cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors");
  10485. cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv);
  10486. }
  10487. removeChildrenAndAdd(cm.display.dragCursor, frag);
  10488. }
  10489. function clearDragCursor(cm) {
  10490. if (cm.display.dragCursor) {
  10491. cm.display.lineSpace.removeChild(cm.display.dragCursor);
  10492. cm.display.dragCursor = null;
  10493. }
  10494. }
  10495. // These must be handled carefully, because naively registering a
  10496. // handler for each editor will cause the editors to never be
  10497. // garbage collected.
  10498. function forEachCodeMirror(f) {
  10499. if (!document.getElementsByClassName) { return }
  10500. var byClass = document.getElementsByClassName("CodeMirror"), editors = [];
  10501. for (var i = 0; i < byClass.length; i++) {
  10502. var cm = byClass[i].CodeMirror;
  10503. if (cm) { editors.push(cm); }
  10504. }
  10505. if (editors.length) { editors[0].operation(function () {
  10506. for (var i = 0; i < editors.length; i++) { f(editors[i]); }
  10507. }); }
  10508. }
  10509. var globalsRegistered = false;
  10510. function ensureGlobalHandlers() {
  10511. if (globalsRegistered) { return }
  10512. registerGlobalHandlers();
  10513. globalsRegistered = true;
  10514. }
  10515. function registerGlobalHandlers() {
  10516. // When the window resizes, we need to refresh active editors.
  10517. var resizeTimer;
  10518. on(window, "resize", function () {
  10519. if (resizeTimer == null) { resizeTimer = setTimeout(function () {
  10520. resizeTimer = null;
  10521. forEachCodeMirror(onResize);
  10522. }, 100); }
  10523. });
  10524. // When the window loses focus, we want to show the editor as blurred
  10525. on(window, "blur", function () { return forEachCodeMirror(onBlur); });
  10526. }
  10527. // Called when the window resizes
  10528. function onResize(cm) {
  10529. var d = cm.display;
  10530. // Might be a text scaling operation, clear size caches.
  10531. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
  10532. d.scrollbarsClipped = false;
  10533. cm.setSize();
  10534. }
  10535. var keyNames = {
  10536. 3: "Pause", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
  10537. 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
  10538. 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
  10539. 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod",
  10540. 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 145: "ScrollLock",
  10541. 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
  10542. 221: "]", 222: "'", 224: "Mod", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
  10543. 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"
  10544. };
  10545. // Number keys
  10546. for (var i = 0; i < 10; i++) { keyNames[i + 48] = keyNames[i + 96] = String(i); }
  10547. // Alphabetic keys
  10548. for (var i$1 = 65; i$1 <= 90; i$1++) { keyNames[i$1] = String.fromCharCode(i$1); }
  10549. // Function keys
  10550. for (var i$2 = 1; i$2 <= 12; i$2++) { keyNames[i$2 + 111] = keyNames[i$2 + 63235] = "F" + i$2; }
  10551. var keyMap = {};
  10552. keyMap.basic = {
  10553. "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
  10554. "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
  10555. "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
  10556. "Tab": "defaultTab", "Shift-Tab": "indentAuto",
  10557. "Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
  10558. "Esc": "singleSelection"
  10559. };
  10560. // Note that the save and find-related commands aren't defined by
  10561. // default. User code or addons can define them. Unknown commands
  10562. // are simply ignored.
  10563. keyMap.pcDefault = {
  10564. "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
  10565. "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown",
  10566. "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
  10567. "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
  10568. "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
  10569. "Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
  10570. "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",
  10571. "fallthrough": "basic"
  10572. };
  10573. // Very basic readline/emacs-style bindings, which are standard on Mac.
  10574. keyMap.emacsy = {
  10575. "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
  10576. "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
  10577. "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
  10578. "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars",
  10579. "Ctrl-O": "openLine"
  10580. };
  10581. keyMap.macDefault = {
  10582. "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
  10583. "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
  10584. "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore",
  10585. "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
  10586. "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
  10587. "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",
  10588. "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd",
  10589. "fallthrough": ["basic", "emacsy"]
  10590. };
  10591. keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
  10592. // KEYMAP DISPATCH
  10593. function normalizeKeyName(name) {
  10594. var parts = name.split(/-(?!$)/);
  10595. name = parts[parts.length - 1];
  10596. var alt, ctrl, shift, cmd;
  10597. for (var i = 0; i < parts.length - 1; i++) {
  10598. var mod = parts[i];
  10599. if (/^(cmd|meta|m)$/i.test(mod)) { cmd = true; }
  10600. else if (/^a(lt)?$/i.test(mod)) { alt = true; }
  10601. else if (/^(c|ctrl|control)$/i.test(mod)) { ctrl = true; }
  10602. else if (/^s(hift)?$/i.test(mod)) { shift = true; }
  10603. else { throw new Error("Unrecognized modifier name: " + mod) }
  10604. }
  10605. if (alt) { name = "Alt-" + name; }
  10606. if (ctrl) { name = "Ctrl-" + name; }
  10607. if (cmd) { name = "Cmd-" + name; }
  10608. if (shift) { name = "Shift-" + name; }
  10609. return name
  10610. }
  10611. // This is a kludge to keep keymaps mostly working as raw objects
  10612. // (backwards compatibility) while at the same time support features
  10613. // like normalization and multi-stroke key bindings. It compiles a
  10614. // new normalized keymap, and then updates the old object to reflect
  10615. // this.
  10616. function normalizeKeyMap(keymap) {
  10617. var copy = {};
  10618. for (var keyname in keymap) { if (keymap.hasOwnProperty(keyname)) {
  10619. var value = keymap[keyname];
  10620. if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) { continue }
  10621. if (value == "...") { delete keymap[keyname]; continue }
  10622. var keys = map(keyname.split(" "), normalizeKeyName);
  10623. for (var i = 0; i < keys.length; i++) {
  10624. var val = (void 0), name = (void 0);
  10625. if (i == keys.length - 1) {
  10626. name = keys.join(" ");
  10627. val = value;
  10628. } else {
  10629. name = keys.slice(0, i + 1).join(" ");
  10630. val = "...";
  10631. }
  10632. var prev = copy[name];
  10633. if (!prev) { copy[name] = val; }
  10634. else if (prev != val) { throw new Error("Inconsistent bindings for " + name) }
  10635. }
  10636. delete keymap[keyname];
  10637. } }
  10638. for (var prop in copy) { keymap[prop] = copy[prop]; }
  10639. return keymap
  10640. }
  10641. function lookupKey(key, map, handle, context) {
  10642. map = getKeyMap(map);
  10643. var found = map.call ? map.call(key, context) : map[key];
  10644. if (found === false) { return "nothing" }
  10645. if (found === "...") { return "multi" }
  10646. if (found != null && handle(found)) { return "handled" }
  10647. if (map.fallthrough) {
  10648. if (Object.prototype.toString.call(map.fallthrough) != "[object Array]")
  10649. { return lookupKey(key, map.fallthrough, handle, context) }
  10650. for (var i = 0; i < map.fallthrough.length; i++) {
  10651. var result = lookupKey(key, map.fallthrough[i], handle, context);
  10652. if (result) { return result }
  10653. }
  10654. }
  10655. }
  10656. // Modifier key presses don't count as 'real' key presses for the
  10657. // purpose of keymap fallthrough.
  10658. function isModifierKey(value) {
  10659. var name = typeof value == "string" ? value : keyNames[value.keyCode];
  10660. return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod"
  10661. }
  10662. function addModifierNames(name, event, noShift) {
  10663. var base = name;
  10664. if (event.altKey && base != "Alt") { name = "Alt-" + name; }
  10665. if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") { name = "Ctrl-" + name; }
  10666. if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Mod") { name = "Cmd-" + name; }
  10667. if (!noShift && event.shiftKey && base != "Shift") { name = "Shift-" + name; }
  10668. return name
  10669. }
  10670. // Look up the name of a key as indicated by an event object.
  10671. function keyName(event, noShift) {
  10672. if (presto && event.keyCode == 34 && event["char"]) { return false }
  10673. var name = keyNames[event.keyCode];
  10674. if (name == null || event.altGraphKey) { return false }
  10675. // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,
  10676. // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)
  10677. if (event.keyCode == 3 && event.code) { name = event.code; }
  10678. return addModifierNames(name, event, noShift)
  10679. }
  10680. function getKeyMap(val) {
  10681. return typeof val == "string" ? keyMap[val] : val
  10682. }
  10683. // Helper for deleting text near the selection(s), used to implement
  10684. // backspace, delete, and similar functionality.
  10685. function deleteNearSelection(cm, compute) {
  10686. var ranges = cm.doc.sel.ranges, kill = [];
  10687. // Build up a set of ranges to kill first, merging overlapping
  10688. // ranges.
  10689. for (var i = 0; i < ranges.length; i++) {
  10690. var toKill = compute(ranges[i]);
  10691. while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
  10692. var replaced = kill.pop();
  10693. if (cmp(replaced.from, toKill.from) < 0) {
  10694. toKill.from = replaced.from;
  10695. break
  10696. }
  10697. }
  10698. kill.push(toKill);
  10699. }
  10700. // Next, remove those actual ranges.
  10701. runInOp(cm, function () {
  10702. for (var i = kill.length - 1; i >= 0; i--)
  10703. { replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete"); }
  10704. ensureCursorVisible(cm);
  10705. });
  10706. }
  10707. function moveCharLogically(line, ch, dir) {
  10708. var target = skipExtendingChars(line.text, ch + dir, dir);
  10709. return target < 0 || target > line.text.length ? null : target
  10710. }
  10711. function moveLogically(line, start, dir) {
  10712. var ch = moveCharLogically(line, start.ch, dir);
  10713. return ch == null ? null : new Pos(start.line, ch, dir < 0 ? "after" : "before")
  10714. }
  10715. function endOfLine(visually, cm, lineObj, lineNo, dir) {
  10716. if (visually) {
  10717. if (cm.doc.direction == "rtl") { dir = -dir; }
  10718. var order = getOrder(lineObj, cm.doc.direction);
  10719. if (order) {
  10720. var part = dir < 0 ? lst(order) : order[0];
  10721. var moveInStorageOrder = (dir < 0) == (part.level == 1);
  10722. var sticky = moveInStorageOrder ? "after" : "before";
  10723. var ch;
  10724. // With a wrapped rtl chunk (possibly spanning multiple bidi parts),
  10725. // it could be that the last bidi part is not on the last visual line,
  10726. // since visual lines contain content order-consecutive chunks.
  10727. // Thus, in rtl, we are looking for the first (content-order) character
  10728. // in the rtl chunk that is on the last line (that is, the same line
  10729. // as the last (content-order) character).
  10730. if (part.level > 0 || cm.doc.direction == "rtl") {
  10731. var prep = prepareMeasureForLine(cm, lineObj);
  10732. ch = dir < 0 ? lineObj.text.length - 1 : 0;
  10733. var targetTop = measureCharPrepared(cm, prep, ch).top;
  10734. ch = findFirst(function (ch) { return measureCharPrepared(cm, prep, ch).top == targetTop; }, (dir < 0) == (part.level == 1) ? part.from : part.to - 1, ch);
  10735. if (sticky == "before") { ch = moveCharLogically(lineObj, ch, 1); }
  10736. } else { ch = dir < 0 ? part.to : part.from; }
  10737. return new Pos(lineNo, ch, sticky)
  10738. }
  10739. }
  10740. return new Pos(lineNo, dir < 0 ? lineObj.text.length : 0, dir < 0 ? "before" : "after")
  10741. }
  10742. function moveVisually(cm, line, start, dir) {
  10743. var bidi = getOrder(line, cm.doc.direction);
  10744. if (!bidi) { return moveLogically(line, start, dir) }
  10745. if (start.ch >= line.text.length) {
  10746. start.ch = line.text.length;
  10747. start.sticky = "before";
  10748. } else if (start.ch <= 0) {
  10749. start.ch = 0;
  10750. start.sticky = "after";
  10751. }
  10752. var partPos = getBidiPartAt(bidi, start.ch, start.sticky), part = bidi[partPos];
  10753. if (cm.doc.direction == "ltr" && part.level % 2 == 0 && (dir > 0 ? part.to > start.ch : part.from < start.ch)) {
  10754. // Case 1: We move within an ltr part in an ltr editor. Even with wrapped lines,
  10755. // nothing interesting happens.
  10756. return moveLogically(line, start, dir)
  10757. }
  10758. var mv = function (pos, dir) { return moveCharLogically(line, pos instanceof Pos ? pos.ch : pos, dir); };
  10759. var prep;
  10760. var getWrappedLineExtent = function (ch) {
  10761. if (!cm.options.lineWrapping) { return {begin: 0, end: line.text.length} }
  10762. prep = prep || prepareMeasureForLine(cm, line);
  10763. return wrappedLineExtentChar(cm, line, prep, ch)
  10764. };
  10765. var wrappedLineExtent = getWrappedLineExtent(start.sticky == "before" ? mv(start, -1) : start.ch);
  10766. if (cm.doc.direction == "rtl" || part.level == 1) {
  10767. var moveInStorageOrder = (part.level == 1) == (dir < 0);
  10768. var ch = mv(start, moveInStorageOrder ? 1 : -1);
  10769. if (ch != null && (!moveInStorageOrder ? ch >= part.from && ch >= wrappedLineExtent.begin : ch <= part.to && ch <= wrappedLineExtent.end)) {
  10770. // Case 2: We move within an rtl part or in an rtl editor on the same visual line
  10771. var sticky = moveInStorageOrder ? "before" : "after";
  10772. return new Pos(start.line, ch, sticky)
  10773. }
  10774. }
  10775. // Case 3: Could not move within this bidi part in this visual line, so leave
  10776. // the current bidi part
  10777. var searchInVisualLine = function (partPos, dir, wrappedLineExtent) {
  10778. var getRes = function (ch, moveInStorageOrder) { return moveInStorageOrder
  10779. ? new Pos(start.line, mv(ch, 1), "before")
  10780. : new Pos(start.line, ch, "after"); };
  10781. for (; partPos >= 0 && partPos < bidi.length; partPos += dir) {
  10782. var part = bidi[partPos];
  10783. var moveInStorageOrder = (dir > 0) == (part.level != 1);
  10784. var ch = moveInStorageOrder ? wrappedLineExtent.begin : mv(wrappedLineExtent.end, -1);
  10785. if (part.from <= ch && ch < part.to) { return getRes(ch, moveInStorageOrder) }
  10786. ch = moveInStorageOrder ? part.from : mv(part.to, -1);
  10787. if (wrappedLineExtent.begin <= ch && ch < wrappedLineExtent.end) { return getRes(ch, moveInStorageOrder) }
  10788. }
  10789. };
  10790. // Case 3a: Look for other bidi parts on the same visual line
  10791. var res = searchInVisualLine(partPos + dir, dir, wrappedLineExtent);
  10792. if (res) { return res }
  10793. // Case 3b: Look for other bidi parts on the next visual line
  10794. var nextCh = dir > 0 ? wrappedLineExtent.end : mv(wrappedLineExtent.begin, -1);
  10795. if (nextCh != null && !(dir > 0 && nextCh == line.text.length)) {
  10796. res = searchInVisualLine(dir > 0 ? 0 : bidi.length - 1, dir, getWrappedLineExtent(nextCh));
  10797. if (res) { return res }
  10798. }
  10799. // Case 4: Nowhere to move
  10800. return null
  10801. }
  10802. // Commands are parameter-less actions that can be performed on an
  10803. // editor, mostly used for keybindings.
  10804. var commands = {
  10805. selectAll: selectAll,
  10806. singleSelection: function (cm) { return cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll); },
  10807. killLine: function (cm) { return deleteNearSelection(cm, function (range) {
  10808. if (range.empty()) {
  10809. var len = getLine(cm.doc, range.head.line).text.length;
  10810. if (range.head.ch == len && range.head.line < cm.lastLine())
  10811. { return {from: range.head, to: Pos(range.head.line + 1, 0)} }
  10812. else
  10813. { return {from: range.head, to: Pos(range.head.line, len)} }
  10814. } else {
  10815. return {from: range.from(), to: range.to()}
  10816. }
  10817. }); },
  10818. deleteLine: function (cm) { return deleteNearSelection(cm, function (range) { return ({
  10819. from: Pos(range.from().line, 0),
  10820. to: clipPos(cm.doc, Pos(range.to().line + 1, 0))
  10821. }); }); },
  10822. delLineLeft: function (cm) { return deleteNearSelection(cm, function (range) { return ({
  10823. from: Pos(range.from().line, 0), to: range.from()
  10824. }); }); },
  10825. delWrappedLineLeft: function (cm) { return deleteNearSelection(cm, function (range) {
  10826. var top = cm.charCoords(range.head, "div").top + 5;
  10827. var leftPos = cm.coordsChar({left: 0, top: top}, "div");
  10828. return {from: leftPos, to: range.from()}
  10829. }); },
  10830. delWrappedLineRight: function (cm) { return deleteNearSelection(cm, function (range) {
  10831. var top = cm.charCoords(range.head, "div").top + 5;
  10832. var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
  10833. return {from: range.from(), to: rightPos }
  10834. }); },
  10835. undo: function (cm) { return cm.undo(); },
  10836. redo: function (cm) { return cm.redo(); },
  10837. undoSelection: function (cm) { return cm.undoSelection(); },
  10838. redoSelection: function (cm) { return cm.redoSelection(); },
  10839. goDocStart: function (cm) { return cm.extendSelection(Pos(cm.firstLine(), 0)); },
  10840. goDocEnd: function (cm) { return cm.extendSelection(Pos(cm.lastLine())); },
  10841. goLineStart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStart(cm, range.head.line); },
  10842. {origin: "+move", bias: 1}
  10843. ); },
  10844. goLineStartSmart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStartSmart(cm, range.head); },
  10845. {origin: "+move", bias: 1}
  10846. ); },
  10847. goLineEnd: function (cm) { return cm.extendSelectionsBy(function (range) { return lineEnd(cm, range.head.line); },
  10848. {origin: "+move", bias: -1}
  10849. ); },
  10850. goLineRight: function (cm) { return cm.extendSelectionsBy(function (range) {
  10851. var top = cm.cursorCoords(range.head, "div").top + 5;
  10852. return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div")
  10853. }, sel_move); },
  10854. goLineLeft: function (cm) { return cm.extendSelectionsBy(function (range) {
  10855. var top = cm.cursorCoords(range.head, "div").top + 5;
  10856. return cm.coordsChar({left: 0, top: top}, "div")
  10857. }, sel_move); },
  10858. goLineLeftSmart: function (cm) { return cm.extendSelectionsBy(function (range) {
  10859. var top = cm.cursorCoords(range.head, "div").top + 5;
  10860. var pos = cm.coordsChar({left: 0, top: top}, "div");
  10861. if (pos.ch < cm.getLine(pos.line).search(/\S/)) { return lineStartSmart(cm, range.head) }
  10862. return pos
  10863. }, sel_move); },
  10864. goLineUp: function (cm) { return cm.moveV(-1, "line"); },
  10865. goLineDown: function (cm) { return cm.moveV(1, "line"); },
  10866. goPageUp: function (cm) { return cm.moveV(-1, "page"); },
  10867. goPageDown: function (cm) { return cm.moveV(1, "page"); },
  10868. goCharLeft: function (cm) { return cm.moveH(-1, "char"); },
  10869. goCharRight: function (cm) { return cm.moveH(1, "char"); },
  10870. goColumnLeft: function (cm) { return cm.moveH(-1, "column"); },
  10871. goColumnRight: function (cm) { return cm.moveH(1, "column"); },
  10872. goWordLeft: function (cm) { return cm.moveH(-1, "word"); },
  10873. goGroupRight: function (cm) { return cm.moveH(1, "group"); },
  10874. goGroupLeft: function (cm) { return cm.moveH(-1, "group"); },
  10875. goWordRight: function (cm) { return cm.moveH(1, "word"); },
  10876. delCharBefore: function (cm) { return cm.deleteH(-1, "codepoint"); },
  10877. delCharAfter: function (cm) { return cm.deleteH(1, "char"); },
  10878. delWordBefore: function (cm) { return cm.deleteH(-1, "word"); },
  10879. delWordAfter: function (cm) { return cm.deleteH(1, "word"); },
  10880. delGroupBefore: function (cm) { return cm.deleteH(-1, "group"); },
  10881. delGroupAfter: function (cm) { return cm.deleteH(1, "group"); },
  10882. indentAuto: function (cm) { return cm.indentSelection("smart"); },
  10883. indentMore: function (cm) { return cm.indentSelection("add"); },
  10884. indentLess: function (cm) { return cm.indentSelection("subtract"); },
  10885. insertTab: function (cm) { return cm.replaceSelection("\t"); },
  10886. insertSoftTab: function (cm) {
  10887. var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize;
  10888. for (var i = 0; i < ranges.length; i++) {
  10889. var pos = ranges[i].from();
  10890. var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);
  10891. spaces.push(spaceStr(tabSize - col % tabSize));
  10892. }
  10893. cm.replaceSelections(spaces);
  10894. },
  10895. defaultTab: function (cm) {
  10896. if (cm.somethingSelected()) { cm.indentSelection("add"); }
  10897. else { cm.execCommand("insertTab"); }
  10898. },
  10899. // Swap the two chars left and right of each selection's head.
  10900. // Move cursor behind the two swapped characters afterwards.
  10901. //
  10902. // Doesn't consider line feeds a character.
  10903. // Doesn't scan more than one line above to find a character.
  10904. // Doesn't do anything on an empty line.
  10905. // Doesn't do anything with non-empty selections.
  10906. transposeChars: function (cm) { return runInOp(cm, function () {
  10907. var ranges = cm.listSelections(), newSel = [];
  10908. for (var i = 0; i < ranges.length; i++) {
  10909. if (!ranges[i].empty()) { continue }
  10910. var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text;
  10911. if (line) {
  10912. if (cur.ch == line.length) { cur = new Pos(cur.line, cur.ch - 1); }
  10913. if (cur.ch > 0) {
  10914. cur = new Pos(cur.line, cur.ch + 1);
  10915. cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),
  10916. Pos(cur.line, cur.ch - 2), cur, "+transpose");
  10917. } else if (cur.line > cm.doc.first) {
  10918. var prev = getLine(cm.doc, cur.line - 1).text;
  10919. if (prev) {
  10920. cur = new Pos(cur.line, 1);
  10921. cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() +
  10922. prev.charAt(prev.length - 1),
  10923. Pos(cur.line - 1, prev.length - 1), cur, "+transpose");
  10924. }
  10925. }
  10926. }
  10927. newSel.push(new Range(cur, cur));
  10928. }
  10929. cm.setSelections(newSel);
  10930. }); },
  10931. newlineAndIndent: function (cm) { return runInOp(cm, function () {
  10932. var sels = cm.listSelections();
  10933. for (var i = sels.length - 1; i >= 0; i--)
  10934. { cm.replaceRange(cm.doc.lineSeparator(), sels[i].anchor, sels[i].head, "+input"); }
  10935. sels = cm.listSelections();
  10936. for (var i$1 = 0; i$1 < sels.length; i$1++)
  10937. { cm.indentLine(sels[i$1].from().line, null, true); }
  10938. ensureCursorVisible(cm);
  10939. }); },
  10940. openLine: function (cm) { return cm.replaceSelection("\n", "start"); },
  10941. toggleOverwrite: function (cm) { return cm.toggleOverwrite(); }
  10942. };
  10943. function lineStart(cm, lineN) {
  10944. var line = getLine(cm.doc, lineN);
  10945. var visual = visualLine(line);
  10946. if (visual != line) { lineN = lineNo(visual); }
  10947. return endOfLine(true, cm, visual, lineN, 1)
  10948. }
  10949. function lineEnd(cm, lineN) {
  10950. var line = getLine(cm.doc, lineN);
  10951. var visual = visualLineEnd(line);
  10952. if (visual != line) { lineN = lineNo(visual); }
  10953. return endOfLine(true, cm, line, lineN, -1)
  10954. }
  10955. function lineStartSmart(cm, pos) {
  10956. var start = lineStart(cm, pos.line);
  10957. var line = getLine(cm.doc, start.line);
  10958. var order = getOrder(line, cm.doc.direction);
  10959. if (!order || order[0].level == 0) {
  10960. var firstNonWS = Math.max(start.ch, line.text.search(/\S/));
  10961. var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch;
  10962. return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky)
  10963. }
  10964. return start
  10965. }
  10966. // Run a handler that was bound to a key.
  10967. function doHandleBinding(cm, bound, dropShift) {
  10968. if (typeof bound == "string") {
  10969. bound = commands[bound];
  10970. if (!bound) { return false }
  10971. }
  10972. // Ensure previous input has been read, so that the handler sees a
  10973. // consistent view of the document
  10974. cm.display.input.ensurePolled();
  10975. var prevShift = cm.display.shift, done = false;
  10976. try {
  10977. if (cm.isReadOnly()) { cm.state.suppressEdits = true; }
  10978. if (dropShift) { cm.display.shift = false; }
  10979. done = bound(cm) != Pass;
  10980. } finally {
  10981. cm.display.shift = prevShift;
  10982. cm.state.suppressEdits = false;
  10983. }
  10984. return done
  10985. }
  10986. function lookupKeyForEditor(cm, name, handle) {
  10987. for (var i = 0; i < cm.state.keyMaps.length; i++) {
  10988. var result = lookupKey(name, cm.state.keyMaps[i], handle, cm);
  10989. if (result) { return result }
  10990. }
  10991. return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm))
  10992. || lookupKey(name, cm.options.keyMap, handle, cm)
  10993. }
  10994. // Note that, despite the name, this function is also used to check
  10995. // for bound mouse clicks.
  10996. var stopSeq = new Delayed;
  10997. function dispatchKey(cm, name, e, handle) {
  10998. var seq = cm.state.keySeq;
  10999. if (seq) {
  11000. if (isModifierKey(name)) { return "handled" }
  11001. if (/\'$/.test(name))
  11002. { cm.state.keySeq = null; }
  11003. else
  11004. { stopSeq.set(50, function () {
  11005. if (cm.state.keySeq == seq) {
  11006. cm.state.keySeq = null;
  11007. cm.display.input.reset();
  11008. }
  11009. }); }
  11010. if (dispatchKeyInner(cm, seq + " " + name, e, handle)) { return true }
  11011. }
  11012. return dispatchKeyInner(cm, name, e, handle)
  11013. }
  11014. function dispatchKeyInner(cm, name, e, handle) {
  11015. var result = lookupKeyForEditor(cm, name, handle);
  11016. if (result == "multi")
  11017. { cm.state.keySeq = name; }
  11018. if (result == "handled")
  11019. { signalLater(cm, "keyHandled", cm, name, e); }
  11020. if (result == "handled" || result == "multi") {
  11021. e_preventDefault(e);
  11022. restartBlink(cm);
  11023. }
  11024. return !!result
  11025. }
  11026. // Handle a key from the keydown event.
  11027. function handleKeyBinding(cm, e) {
  11028. var name = keyName(e, true);
  11029. if (!name) { return false }
  11030. if (e.shiftKey && !cm.state.keySeq) {
  11031. // First try to resolve full name (including 'Shift-'). Failing
  11032. // that, see if there is a cursor-motion command (starting with
  11033. // 'go') bound to the keyname without 'Shift-'.
  11034. return dispatchKey(cm, "Shift-" + name, e, function (b) { return doHandleBinding(cm, b, true); })
  11035. || dispatchKey(cm, name, e, function (b) {
  11036. if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
  11037. { return doHandleBinding(cm, b) }
  11038. })
  11039. } else {
  11040. return dispatchKey(cm, name, e, function (b) { return doHandleBinding(cm, b); })
  11041. }
  11042. }
  11043. // Handle a key from the keypress event
  11044. function handleCharBinding(cm, e, ch) {
  11045. return dispatchKey(cm, "'" + ch + "'", e, function (b) { return doHandleBinding(cm, b, true); })
  11046. }
  11047. var lastStoppedKey = null;
  11048. function onKeyDown(e) {
  11049. var cm = this;
  11050. if (e.target && e.target != cm.display.input.getField()) { return }
  11051. cm.curOp.focus = activeElt();
  11052. if (signalDOMEvent(cm, e)) { return }
  11053. // IE does strange things with escape.
  11054. if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; }
  11055. var code = e.keyCode;
  11056. cm.display.shift = code == 16 || e.shiftKey;
  11057. var handled = handleKeyBinding(cm, e);
  11058. if (presto) {
  11059. lastStoppedKey = handled ? code : null;
  11060. // Opera has no cut event... we try to at least catch the key combo
  11061. if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))
  11062. { cm.replaceSelection("", null, "cut"); }
  11063. }
  11064. if (gecko && !mac && !handled && code == 46 && e.shiftKey && !e.ctrlKey && document.execCommand)
  11065. { document.execCommand("cut"); }
  11066. // Turn mouse into crosshair when Alt is held on Mac.
  11067. if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className))
  11068. { showCrossHair(cm); }
  11069. }
  11070. function showCrossHair(cm) {
  11071. var lineDiv = cm.display.lineDiv;
  11072. addClass(lineDiv, "CodeMirror-crosshair");
  11073. function up(e) {
  11074. if (e.keyCode == 18 || !e.altKey) {
  11075. rmClass(lineDiv, "CodeMirror-crosshair");
  11076. off(document, "keyup", up);
  11077. off(document, "mouseover", up);
  11078. }
  11079. }
  11080. on(document, "keyup", up);
  11081. on(document, "mouseover", up);
  11082. }
  11083. function onKeyUp(e) {
  11084. if (e.keyCode == 16) { this.doc.sel.shift = false; }
  11085. signalDOMEvent(this, e);
  11086. }
  11087. function onKeyPress(e) {
  11088. var cm = this;
  11089. if (e.target && e.target != cm.display.input.getField()) { return }
  11090. if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) { return }
  11091. var keyCode = e.keyCode, charCode = e.charCode;
  11092. if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return}
  11093. if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) { return }
  11094. var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
  11095. // Some browsers fire keypress events for backspace
  11096. if (ch == "\x08") { return }
  11097. if (handleCharBinding(cm, e, ch)) { return }
  11098. cm.display.input.onKeyPress(e);
  11099. }
  11100. var DOUBLECLICK_DELAY = 400;
  11101. var PastClick = function(time, pos, button) {
  11102. this.time = time;
  11103. this.pos = pos;
  11104. this.button = button;
  11105. };
  11106. PastClick.prototype.compare = function (time, pos, button) {
  11107. return this.time + DOUBLECLICK_DELAY > time &&
  11108. cmp(pos, this.pos) == 0 && button == this.button
  11109. };
  11110. var lastClick, lastDoubleClick;
  11111. function clickRepeat(pos, button) {
  11112. var now = +new Date;
  11113. if (lastDoubleClick && lastDoubleClick.compare(now, pos, button)) {
  11114. lastClick = lastDoubleClick = null;
  11115. return "triple"
  11116. } else if (lastClick && lastClick.compare(now, pos, button)) {
  11117. lastDoubleClick = new PastClick(now, pos, button);
  11118. lastClick = null;
  11119. return "double"
  11120. } else {
  11121. lastClick = new PastClick(now, pos, button);
  11122. lastDoubleClick = null;
  11123. return "single"
  11124. }
  11125. }
  11126. // A mouse down can be a single click, double click, triple click,
  11127. // start of selection drag, start of text drag, new cursor
  11128. // (ctrl-click), rectangle drag (alt-drag), or xwin
  11129. // middle-click-paste. Or it might be a click on something we should
  11130. // not interfere with, such as a scrollbar or widget.
  11131. function onMouseDown(e) {
  11132. var cm = this, display = cm.display;
  11133. if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) { return }
  11134. display.input.ensurePolled();
  11135. display.shift = e.shiftKey;
  11136. if (eventInWidget(display, e)) {
  11137. if (!webkit) {
  11138. // Briefly turn off draggability, to allow widgets to do
  11139. // normal dragging things.
  11140. display.scroller.draggable = false;
  11141. setTimeout(function () { return display.scroller.draggable = true; }, 100);
  11142. }
  11143. return
  11144. }
  11145. if (clickInGutter(cm, e)) { return }
  11146. var pos = posFromMouse(cm, e), button = e_button(e), repeat = pos ? clickRepeat(pos, button) : "single";
  11147. window.focus();
  11148. // #3261: make sure, that we're not starting a second selection
  11149. if (button == 1 && cm.state.selectingText)
  11150. { cm.state.selectingText(e); }
  11151. if (pos && handleMappedButton(cm, button, pos, repeat, e)) { return }
  11152. if (button == 1) {
  11153. if (pos) { leftButtonDown(cm, pos, repeat, e); }
  11154. else if (e_target(e) == display.scroller) { e_preventDefault(e); }
  11155. } else if (button == 2) {
  11156. if (pos) { extendSelection(cm.doc, pos); }
  11157. setTimeout(function () { return display.input.focus(); }, 20);
  11158. } else if (button == 3) {
  11159. if (captureRightClick) { cm.display.input.onContextMenu(e); }
  11160. else { delayBlurEvent(cm); }
  11161. }
  11162. }
  11163. function handleMappedButton(cm, button, pos, repeat, event) {
  11164. var name = "Click";
  11165. if (repeat == "double") { name = "Double" + name; }
  11166. else if (repeat == "triple") { name = "Triple" + name; }
  11167. name = (button == 1 ? "Left" : button == 2 ? "Middle" : "Right") + name;
  11168. return dispatchKey(cm, addModifierNames(name, event), event, function (bound) {
  11169. if (typeof bound == "string") { bound = commands[bound]; }
  11170. if (!bound) { return false }
  11171. var done = false;
  11172. try {
  11173. if (cm.isReadOnly()) { cm.state.suppressEdits = true; }
  11174. done = bound(cm, pos) != Pass;
  11175. } finally {
  11176. cm.state.suppressEdits = false;
  11177. }
  11178. return done
  11179. })
  11180. }
  11181. function configureMouse(cm, repeat, event) {
  11182. var option = cm.getOption("configureMouse");
  11183. var value = option ? option(cm, repeat, event) : {};
  11184. if (value.unit == null) {
  11185. var rect = chromeOS ? event.shiftKey && event.metaKey : event.altKey;
  11186. value.unit = rect ? "rectangle" : repeat == "single" ? "char" : repeat == "double" ? "word" : "line";
  11187. }
  11188. if (value.extend == null || cm.doc.extend) { value.extend = cm.doc.extend || event.shiftKey; }
  11189. if (value.addNew == null) { value.addNew = mac ? event.metaKey : event.ctrlKey; }
  11190. if (value.moveOnDrag == null) { value.moveOnDrag = !(mac ? event.altKey : event.ctrlKey); }
  11191. return value
  11192. }
  11193. function leftButtonDown(cm, pos, repeat, event) {
  11194. if (ie) { setTimeout(bind(ensureFocus, cm), 0); }
  11195. else { cm.curOp.focus = activeElt(); }
  11196. var behavior = configureMouse(cm, repeat, event);
  11197. var sel = cm.doc.sel, contained;
  11198. if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() &&
  11199. repeat == "single" && (contained = sel.contains(pos)) > -1 &&
  11200. (cmp((contained = sel.ranges[contained]).from(), pos) < 0 || pos.xRel > 0) &&
  11201. (cmp(contained.to(), pos) > 0 || pos.xRel < 0))
  11202. { leftButtonStartDrag(cm, event, pos, behavior); }
  11203. else
  11204. { leftButtonSelect(cm, event, pos, behavior); }
  11205. }
  11206. // Start a text drag. When it ends, see if any dragging actually
  11207. // happen, and treat as a click if it didn't.
  11208. function leftButtonStartDrag(cm, event, pos, behavior) {
  11209. var display = cm.display, moved = false;
  11210. var dragEnd = operation(cm, function (e) {
  11211. if (webkit) { display.scroller.draggable = false; }
  11212. cm.state.draggingText = false;
  11213. off(display.wrapper.ownerDocument, "mouseup", dragEnd);
  11214. off(display.wrapper.ownerDocument, "mousemove", mouseMove);
  11215. off(display.scroller, "dragstart", dragStart);
  11216. off(display.scroller, "drop", dragEnd);
  11217. if (!moved) {
  11218. e_preventDefault(e);
  11219. if (!behavior.addNew)
  11220. { extendSelection(cm.doc, pos, null, null, behavior.extend); }
  11221. // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
  11222. if ((webkit && !safari) || ie && ie_version == 9)
  11223. { setTimeout(function () {display.wrapper.ownerDocument.body.focus({preventScroll: true}); display.input.focus();}, 20); }
  11224. else
  11225. { display.input.focus(); }
  11226. }
  11227. });
  11228. var mouseMove = function(e2) {
  11229. moved = moved || Math.abs(event.clientX - e2.clientX) + Math.abs(event.clientY - e2.clientY) >= 10;
  11230. };
  11231. var dragStart = function () { return moved = true; };
  11232. // Let the drag handler handle this.
  11233. if (webkit) { display.scroller.draggable = true; }
  11234. cm.state.draggingText = dragEnd;
  11235. dragEnd.copy = !behavior.moveOnDrag;
  11236. // IE's approach to draggable
  11237. if (display.scroller.dragDrop) { display.scroller.dragDrop(); }
  11238. on(display.wrapper.ownerDocument, "mouseup", dragEnd);
  11239. on(display.wrapper.ownerDocument, "mousemove", mouseMove);
  11240. on(display.scroller, "dragstart", dragStart);
  11241. on(display.scroller, "drop", dragEnd);
  11242. delayBlurEvent(cm);
  11243. setTimeout(function () { return display.input.focus(); }, 20);
  11244. }
  11245. function rangeForUnit(cm, pos, unit) {
  11246. if (unit == "char") { return new Range(pos, pos) }
  11247. if (unit == "word") { return cm.findWordAt(pos) }
  11248. if (unit == "line") { return new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))) }
  11249. var result = unit(cm, pos);
  11250. return new Range(result.from, result.to)
  11251. }
  11252. // Normal selection, as opposed to text dragging.
  11253. function leftButtonSelect(cm, event, start, behavior) {
  11254. var display = cm.display, doc = cm.doc;
  11255. e_preventDefault(event);
  11256. var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
  11257. if (behavior.addNew && !behavior.extend) {
  11258. ourIndex = doc.sel.contains(start);
  11259. if (ourIndex > -1)
  11260. { ourRange = ranges[ourIndex]; }
  11261. else
  11262. { ourRange = new Range(start, start); }
  11263. } else {
  11264. ourRange = doc.sel.primary();
  11265. ourIndex = doc.sel.primIndex;
  11266. }
  11267. if (behavior.unit == "rectangle") {
  11268. if (!behavior.addNew) { ourRange = new Range(start, start); }
  11269. start = posFromMouse(cm, event, true, true);
  11270. ourIndex = -1;
  11271. } else {
  11272. var range = rangeForUnit(cm, start, behavior.unit);
  11273. if (behavior.extend)
  11274. { ourRange = extendRange(ourRange, range.anchor, range.head, behavior.extend); }
  11275. else
  11276. { ourRange = range; }
  11277. }
  11278. if (!behavior.addNew) {
  11279. ourIndex = 0;
  11280. setSelection(doc, new Selection([ourRange], 0), sel_mouse);
  11281. startSel = doc.sel;
  11282. } else if (ourIndex == -1) {
  11283. ourIndex = ranges.length;
  11284. setSelection(doc, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex),
  11285. {scroll: false, origin: "*mouse"});
  11286. } else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) {
  11287. setSelection(doc, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
  11288. {scroll: false, origin: "*mouse"});
  11289. startSel = doc.sel;
  11290. } else {
  11291. replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
  11292. }
  11293. var lastPos = start;
  11294. function extendTo(pos) {
  11295. if (cmp(lastPos, pos) == 0) { return }
  11296. lastPos = pos;
  11297. if (behavior.unit == "rectangle") {
  11298. var ranges = [], tabSize = cm.options.tabSize;
  11299. var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
  11300. var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
  11301. var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
  11302. for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
  11303. line <= end; line++) {
  11304. var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
  11305. if (left == right)
  11306. { ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); }
  11307. else if (text.length > leftPos)
  11308. { ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); }
  11309. }
  11310. if (!ranges.length) { ranges.push(new Range(start, start)); }
  11311. setSelection(doc, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
  11312. {origin: "*mouse", scroll: false});
  11313. cm.scrollIntoView(pos);
  11314. } else {
  11315. var oldRange = ourRange;
  11316. var range = rangeForUnit(cm, pos, behavior.unit);
  11317. var anchor = oldRange.anchor, head;
  11318. if (cmp(range.anchor, anchor) > 0) {
  11319. head = range.head;
  11320. anchor = minPos(oldRange.from(), range.anchor);
  11321. } else {
  11322. head = range.anchor;
  11323. anchor = maxPos(oldRange.to(), range.head);
  11324. }
  11325. var ranges$1 = startSel.ranges.slice(0);
  11326. ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head));
  11327. setSelection(doc, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse);
  11328. }
  11329. }
  11330. var editorSize = display.wrapper.getBoundingClientRect();
  11331. // Used to ensure timeout re-tries don't fire when another extend
  11332. // happened in the meantime (clearTimeout isn't reliable -- at
  11333. // least on Chrome, the timeouts still happen even when cleared,
  11334. // if the clear happens after their scheduled firing time).
  11335. var counter = 0;
  11336. function extend(e) {
  11337. var curCount = ++counter;
  11338. var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle");
  11339. if (!cur) { return }
  11340. if (cmp(cur, lastPos) != 0) {
  11341. cm.curOp.focus = activeElt();
  11342. extendTo(cur);
  11343. var visible = visibleLines(display, doc);
  11344. if (cur.line >= visible.to || cur.line < visible.from)
  11345. { setTimeout(operation(cm, function () {if (counter == curCount) { extend(e); }}), 150); }
  11346. } else {
  11347. var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;
  11348. if (outside) { setTimeout(operation(cm, function () {
  11349. if (counter != curCount) { return }
  11350. display.scroller.scrollTop += outside;
  11351. extend(e);
  11352. }), 50); }
  11353. }
  11354. }
  11355. function done(e) {
  11356. cm.state.selectingText = false;
  11357. counter = Infinity;
  11358. // If e is null or undefined we interpret this as someone trying
  11359. // to explicitly cancel the selection rather than the user
  11360. // letting go of the mouse button.
  11361. if (e) {
  11362. e_preventDefault(e);
  11363. display.input.focus();
  11364. }
  11365. off(display.wrapper.ownerDocument, "mousemove", move);
  11366. off(display.wrapper.ownerDocument, "mouseup", up);
  11367. doc.history.lastSelOrigin = null;
  11368. }
  11369. var move = operation(cm, function (e) {
  11370. if (e.buttons === 0 || !e_button(e)) { done(e); }
  11371. else { extend(e); }
  11372. });
  11373. var up = operation(cm, done);
  11374. cm.state.selectingText = up;
  11375. on(display.wrapper.ownerDocument, "mousemove", move);
  11376. on(display.wrapper.ownerDocument, "mouseup", up);
  11377. }
  11378. // Used when mouse-selecting to adjust the anchor to the proper side
  11379. // of a bidi jump depending on the visual position of the head.
  11380. function bidiSimplify(cm, range) {
  11381. var anchor = range.anchor;
  11382. var head = range.head;
  11383. var anchorLine = getLine(cm.doc, anchor.line);
  11384. if (cmp(anchor, head) == 0 && anchor.sticky == head.sticky) { return range }
  11385. var order = getOrder(anchorLine);
  11386. if (!order) { return range }
  11387. var index = getBidiPartAt(order, anchor.ch, anchor.sticky), part = order[index];
  11388. if (part.from != anchor.ch && part.to != anchor.ch) { return range }
  11389. var boundary = index + ((part.from == anchor.ch) == (part.level != 1) ? 0 : 1);
  11390. if (boundary == 0 || boundary == order.length) { return range }
  11391. // Compute the relative visual position of the head compared to the
  11392. // anchor (<0 is to the left, >0 to the right)
  11393. var leftSide;
  11394. if (head.line != anchor.line) {
  11395. leftSide = (head.line - anchor.line) * (cm.doc.direction == "ltr" ? 1 : -1) > 0;
  11396. } else {
  11397. var headIndex = getBidiPartAt(order, head.ch, head.sticky);
  11398. var dir = headIndex - index || (head.ch - anchor.ch) * (part.level == 1 ? -1 : 1);
  11399. if (headIndex == boundary - 1 || headIndex == boundary)
  11400. { leftSide = dir < 0; }
  11401. else
  11402. { leftSide = dir > 0; }
  11403. }
  11404. var usePart = order[boundary + (leftSide ? -1 : 0)];
  11405. var from = leftSide == (usePart.level == 1);
  11406. var ch = from ? usePart.from : usePart.to, sticky = from ? "after" : "before";
  11407. return anchor.ch == ch && anchor.sticky == sticky ? range : new Range(new Pos(anchor.line, ch, sticky), head)
  11408. }
  11409. // Determines whether an event happened in the gutter, and fires the
  11410. // handlers for the corresponding event.
  11411. function gutterEvent(cm, e, type, prevent) {
  11412. var mX, mY;
  11413. if (e.touches) {
  11414. mX = e.touches[0].clientX;
  11415. mY = e.touches[0].clientY;
  11416. } else {
  11417. try { mX = e.clientX; mY = e.clientY; }
  11418. catch(e$1) { return false }
  11419. }
  11420. if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) { return false }
  11421. if (prevent) { e_preventDefault(e); }
  11422. var display = cm.display;
  11423. var lineBox = display.lineDiv.getBoundingClientRect();
  11424. if (mY > lineBox.bottom || !hasHandler(cm, type)) { return e_defaultPrevented(e) }
  11425. mY -= lineBox.top - display.viewOffset;
  11426. for (var i = 0; i < cm.display.gutterSpecs.length; ++i) {
  11427. var g = display.gutters.childNodes[i];
  11428. if (g && g.getBoundingClientRect().right >= mX) {
  11429. var line = lineAtHeight(cm.doc, mY);
  11430. var gutter = cm.display.gutterSpecs[i];
  11431. signal(cm, type, cm, line, gutter.className, e);
  11432. return e_defaultPrevented(e)
  11433. }
  11434. }
  11435. }
  11436. function clickInGutter(cm, e) {
  11437. return gutterEvent(cm, e, "gutterClick", true)
  11438. }
  11439. // CONTEXT MENU HANDLING
  11440. // To make the context menu work, we need to briefly unhide the
  11441. // textarea (making it as unobtrusive as possible) to let the
  11442. // right-click take effect on it.
  11443. function onContextMenu(cm, e) {
  11444. if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) { return }
  11445. if (signalDOMEvent(cm, e, "contextmenu")) { return }
  11446. if (!captureRightClick) { cm.display.input.onContextMenu(e); }
  11447. }
  11448. function contextMenuInGutter(cm, e) {
  11449. if (!hasHandler(cm, "gutterContextMenu")) { return false }
  11450. return gutterEvent(cm, e, "gutterContextMenu", false)
  11451. }
  11452. function themeChanged(cm) {
  11453. cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
  11454. cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
  11455. clearCaches(cm);
  11456. }
  11457. var Init = {toString: function(){return "CodeMirror.Init"}};
  11458. var defaults = {};
  11459. var optionHandlers = {};
  11460. function defineOptions(CodeMirror) {
  11461. var optionHandlers = CodeMirror.optionHandlers;
  11462. function option(name, deflt, handle, notOnInit) {
  11463. CodeMirror.defaults[name] = deflt;
  11464. if (handle) { optionHandlers[name] =
  11465. notOnInit ? function (cm, val, old) {if (old != Init) { handle(cm, val, old); }} : handle; }
  11466. }
  11467. CodeMirror.defineOption = option;
  11468. // Passed to option handlers when there is no old value.
  11469. CodeMirror.Init = Init;
  11470. // These two are, on init, called from the constructor because they
  11471. // have to be initialized before the editor can start at all.
  11472. option("value", "", function (cm, val) { return cm.setValue(val); }, true);
  11473. option("mode", null, function (cm, val) {
  11474. cm.doc.modeOption = val;
  11475. loadMode(cm);
  11476. }, true);
  11477. option("indentUnit", 2, loadMode, true);
  11478. option("indentWithTabs", false);
  11479. option("smartIndent", true);
  11480. option("tabSize", 4, function (cm) {
  11481. resetModeState(cm);
  11482. clearCaches(cm);
  11483. regChange(cm);
  11484. }, true);
  11485. option("lineSeparator", null, function (cm, val) {
  11486. cm.doc.lineSep = val;
  11487. if (!val) { return }
  11488. var newBreaks = [], lineNo = cm.doc.first;
  11489. cm.doc.iter(function (line) {
  11490. for (var pos = 0;;) {
  11491. var found = line.text.indexOf(val, pos);
  11492. if (found == -1) { break }
  11493. pos = found + val.length;
  11494. newBreaks.push(Pos(lineNo, found));
  11495. }
  11496. lineNo++;
  11497. });
  11498. for (var i = newBreaks.length - 1; i >= 0; i--)
  11499. { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); }
  11500. });
  11501. option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) {
  11502. cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
  11503. if (old != Init) { cm.refresh(); }
  11504. });
  11505. option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function (cm) { return cm.refresh(); }, true);
  11506. option("electricChars", true);
  11507. option("inputStyle", mobile ? "contenteditable" : "textarea", function () {
  11508. throw new Error("inputStyle can not (yet) be changed in a running editor") // FIXME
  11509. }, true);
  11510. option("spellcheck", false, function (cm, val) { return cm.getInputField().spellcheck = val; }, true);
  11511. option("autocorrect", false, function (cm, val) { return cm.getInputField().autocorrect = val; }, true);
  11512. option("autocapitalize", false, function (cm, val) { return cm.getInputField().autocapitalize = val; }, true);
  11513. option("rtlMoveVisually", !windows);
  11514. option("wholeLineUpdateBefore", true);
  11515. option("theme", "default", function (cm) {
  11516. themeChanged(cm);
  11517. updateGutters(cm);
  11518. }, true);
  11519. option("keyMap", "default", function (cm, val, old) {
  11520. var next = getKeyMap(val);
  11521. var prev = old != Init && getKeyMap(old);
  11522. if (prev && prev.detach) { prev.detach(cm, next); }
  11523. if (next.attach) { next.attach(cm, prev || null); }
  11524. });
  11525. option("extraKeys", null);
  11526. option("configureMouse", null);
  11527. option("lineWrapping", false, wrappingChanged, true);
  11528. option("gutters", [], function (cm, val) {
  11529. cm.display.gutterSpecs = getGutters(val, cm.options.lineNumbers);
  11530. updateGutters(cm);
  11531. }, true);
  11532. option("fixedGutter", true, function (cm, val) {
  11533. cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
  11534. cm.refresh();
  11535. }, true);
  11536. option("coverGutterNextToScrollbar", false, function (cm) { return updateScrollbars(cm); }, true);
  11537. option("scrollbarStyle", "native", function (cm) {
  11538. initScrollbars(cm);
  11539. updateScrollbars(cm);
  11540. cm.display.scrollbars.setScrollTop(cm.doc.scrollTop);
  11541. cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft);
  11542. }, true);
  11543. option("lineNumbers", false, function (cm, val) {
  11544. cm.display.gutterSpecs = getGutters(cm.options.gutters, val);
  11545. updateGutters(cm);
  11546. }, true);
  11547. option("firstLineNumber", 1, updateGutters, true);
  11548. option("lineNumberFormatter", function (integer) { return integer; }, updateGutters, true);
  11549. option("showCursorWhenSelecting", false, updateSelection, true);
  11550. option("resetSelectionOnContextMenu", true);
  11551. option("lineWiseCopyCut", true);
  11552. option("pasteLinesPerSelection", true);
  11553. option("selectionsMayTouch", false);
  11554. option("readOnly", false, function (cm, val) {
  11555. if (val == "nocursor") {
  11556. onBlur(cm);
  11557. cm.display.input.blur();
  11558. }
  11559. cm.display.input.readOnlyChanged(val);
  11560. });
  11561. option("screenReaderLabel", null, function (cm, val) {
  11562. val = (val === '') ? null : val;
  11563. cm.display.input.screenReaderLabelChanged(val);
  11564. });
  11565. option("disableInput", false, function (cm, val) {if (!val) { cm.display.input.reset(); }}, true);
  11566. option("dragDrop", true, dragDropChanged);
  11567. option("allowDropFileTypes", null);
  11568. option("cursorBlinkRate", 530);
  11569. option("cursorScrollMargin", 0);
  11570. option("cursorHeight", 1, updateSelection, true);
  11571. option("singleCursorHeightPerLine", true, updateSelection, true);
  11572. option("workTime", 100);
  11573. option("workDelay", 100);
  11574. option("flattenSpans", true, resetModeState, true);
  11575. option("addModeClass", false, resetModeState, true);
  11576. option("pollInterval", 100);
  11577. option("undoDepth", 200, function (cm, val) { return cm.doc.history.undoDepth = val; });
  11578. option("historyEventDelay", 1250);
  11579. option("viewportMargin", 10, function (cm) { return cm.refresh(); }, true);
  11580. option("maxHighlightLength", 10000, resetModeState, true);
  11581. option("moveInputWithCursor", true, function (cm, val) {
  11582. if (!val) { cm.display.input.resetPosition(); }
  11583. });
  11584. option("tabindex", null, function (cm, val) { return cm.display.input.getField().tabIndex = val || ""; });
  11585. option("autofocus", null);
  11586. option("direction", "ltr", function (cm, val) { return cm.doc.setDirection(val); }, true);
  11587. option("phrases", null);
  11588. }
  11589. function dragDropChanged(cm, value, old) {
  11590. var wasOn = old && old != Init;
  11591. if (!value != !wasOn) {
  11592. var funcs = cm.display.dragFunctions;
  11593. var toggle = value ? on : off;
  11594. toggle(cm.display.scroller, "dragstart", funcs.start);
  11595. toggle(cm.display.scroller, "dragenter", funcs.enter);
  11596. toggle(cm.display.scroller, "dragover", funcs.over);
  11597. toggle(cm.display.scroller, "dragleave", funcs.leave);
  11598. toggle(cm.display.scroller, "drop", funcs.drop);
  11599. }
  11600. }
  11601. function wrappingChanged(cm) {
  11602. if (cm.options.lineWrapping) {
  11603. addClass(cm.display.wrapper, "CodeMirror-wrap");
  11604. cm.display.sizer.style.minWidth = "";
  11605. cm.display.sizerWidth = null;
  11606. } else {
  11607. rmClass(cm.display.wrapper, "CodeMirror-wrap");
  11608. findMaxLine(cm);
  11609. }
  11610. estimateLineHeights(cm);
  11611. regChange(cm);
  11612. clearCaches(cm);
  11613. setTimeout(function () { return updateScrollbars(cm); }, 100);
  11614. }
  11615. // A CodeMirror instance represents an editor. This is the object
  11616. // that user code is usually dealing with.
  11617. function CodeMirror(place, options) {
  11618. var this$1 = this;
  11619. if (!(this instanceof CodeMirror)) { return new CodeMirror(place, options) }
  11620. this.options = options = options ? copyObj(options) : {};
  11621. // Determine effective options based on given values and defaults.
  11622. copyObj(defaults, options, false);
  11623. var doc = options.value;
  11624. if (typeof doc == "string") { doc = new Doc(doc, options.mode, null, options.lineSeparator, options.direction); }
  11625. else if (options.mode) { doc.modeOption = options.mode; }
  11626. this.doc = doc;
  11627. var input = new CodeMirror.inputStyles[options.inputStyle](this);
  11628. var display = this.display = new Display(place, doc, input, options);
  11629. display.wrapper.CodeMirror = this;
  11630. themeChanged(this);
  11631. if (options.lineWrapping)
  11632. { this.display.wrapper.className += " CodeMirror-wrap"; }
  11633. initScrollbars(this);
  11634. this.state = {
  11635. keyMaps: [], // stores maps added by addKeyMap
  11636. overlays: [], // highlighting overlays, as added by addOverlay
  11637. modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
  11638. overwrite: false,
  11639. delayingBlurEvent: false,
  11640. focused: false,
  11641. suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
  11642. pasteIncoming: -1, cutIncoming: -1, // help recognize paste/cut edits in input.poll
  11643. selectingText: false,
  11644. draggingText: false,
  11645. highlight: new Delayed(), // stores highlight worker timeout
  11646. keySeq: null, // Unfinished key sequence
  11647. specialChars: null
  11648. };
  11649. if (options.autofocus && !mobile) { display.input.focus(); }
  11650. // Override magic textarea content restore that IE sometimes does
  11651. // on our hidden textarea on reload
  11652. if (ie && ie_version < 11) { setTimeout(function () { return this$1.display.input.reset(true); }, 20); }
  11653. registerEventHandlers(this);
  11654. ensureGlobalHandlers();
  11655. startOperation(this);
  11656. this.curOp.forceUpdate = true;
  11657. attachDoc(this, doc);
  11658. if ((options.autofocus && !mobile) || this.hasFocus())
  11659. { setTimeout(function () {
  11660. if (this$1.hasFocus() && !this$1.state.focused) { onFocus(this$1); }
  11661. }, 20); }
  11662. else
  11663. { onBlur(this); }
  11664. for (var opt in optionHandlers) { if (optionHandlers.hasOwnProperty(opt))
  11665. { optionHandlers[opt](this, options[opt], Init); } }
  11666. maybeUpdateLineNumberWidth(this);
  11667. if (options.finishInit) { options.finishInit(this); }
  11668. for (var i = 0; i < initHooks.length; ++i) { initHooks[i](this); }
  11669. endOperation(this);
  11670. // Suppress optimizelegibility in Webkit, since it breaks text
  11671. // measuring on line wrapping boundaries.
  11672. if (webkit && options.lineWrapping &&
  11673. getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
  11674. { display.lineDiv.style.textRendering = "auto"; }
  11675. }
  11676. // The default configuration options.
  11677. CodeMirror.defaults = defaults;
  11678. // Functions to run when options are changed.
  11679. CodeMirror.optionHandlers = optionHandlers;
  11680. // Attach the necessary event handlers when initializing the editor
  11681. function registerEventHandlers(cm) {
  11682. var d = cm.display;
  11683. on(d.scroller, "mousedown", operation(cm, onMouseDown));
  11684. // Older IE's will not fire a second mousedown for a double click
  11685. if (ie && ie_version < 11)
  11686. { on(d.scroller, "dblclick", operation(cm, function (e) {
  11687. if (signalDOMEvent(cm, e)) { return }
  11688. var pos = posFromMouse(cm, e);
  11689. if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) { return }
  11690. e_preventDefault(e);
  11691. var word = cm.findWordAt(pos);
  11692. extendSelection(cm.doc, word.anchor, word.head);
  11693. })); }
  11694. else
  11695. { on(d.scroller, "dblclick", function (e) { return signalDOMEvent(cm, e) || e_preventDefault(e); }); }
  11696. // Some browsers fire contextmenu *after* opening the menu, at
  11697. // which point we can't mess with it anymore. Context menu is
  11698. // handled in onMouseDown for these browsers.
  11699. on(d.scroller, "contextmenu", function (e) { return onContextMenu(cm, e); });
  11700. on(d.input.getField(), "contextmenu", function (e) {
  11701. if (!d.scroller.contains(e.target)) { onContextMenu(cm, e); }
  11702. });
  11703. // Used to suppress mouse event handling when a touch happens
  11704. var touchFinished, prevTouch = {end: 0};
  11705. function finishTouch() {
  11706. if (d.activeTouch) {
  11707. touchFinished = setTimeout(function () { return d.activeTouch = null; }, 1000);
  11708. prevTouch = d.activeTouch;
  11709. prevTouch.end = +new Date;
  11710. }
  11711. }
  11712. function isMouseLikeTouchEvent(e) {
  11713. if (e.touches.length != 1) { return false }
  11714. var touch = e.touches[0];
  11715. return touch.radiusX <= 1 && touch.radiusY <= 1
  11716. }
  11717. function farAway(touch, other) {
  11718. if (other.left == null) { return true }
  11719. var dx = other.left - touch.left, dy = other.top - touch.top;
  11720. return dx * dx + dy * dy > 20 * 20
  11721. }
  11722. on(d.scroller, "touchstart", function (e) {
  11723. if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e) && !clickInGutter(cm, e)) {
  11724. d.input.ensurePolled();
  11725. clearTimeout(touchFinished);
  11726. var now = +new Date;
  11727. d.activeTouch = {start: now, moved: false,
  11728. prev: now - prevTouch.end <= 300 ? prevTouch : null};
  11729. if (e.touches.length == 1) {
  11730. d.activeTouch.left = e.touches[0].pageX;
  11731. d.activeTouch.top = e.touches[0].pageY;
  11732. }
  11733. }
  11734. });
  11735. on(d.scroller, "touchmove", function () {
  11736. if (d.activeTouch) { d.activeTouch.moved = true; }
  11737. });
  11738. on(d.scroller, "touchend", function (e) {
  11739. var touch = d.activeTouch;
  11740. if (touch && !eventInWidget(d, e) && touch.left != null &&
  11741. !touch.moved && new Date - touch.start < 300) {
  11742. var pos = cm.coordsChar(d.activeTouch, "page"), range;
  11743. if (!touch.prev || farAway(touch, touch.prev)) // Single tap
  11744. { range = new Range(pos, pos); }
  11745. else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap
  11746. { range = cm.findWordAt(pos); }
  11747. else // Triple tap
  11748. { range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))); }
  11749. cm.setSelection(range.anchor, range.head);
  11750. cm.focus();
  11751. e_preventDefault(e);
  11752. }
  11753. finishTouch();
  11754. });
  11755. on(d.scroller, "touchcancel", finishTouch);
  11756. // Sync scrolling between fake scrollbars and real scrollable
  11757. // area, ensure viewport is updated when scrolling.
  11758. on(d.scroller, "scroll", function () {
  11759. if (d.scroller.clientHeight) {
  11760. updateScrollTop(cm, d.scroller.scrollTop);
  11761. setScrollLeft(cm, d.scroller.scrollLeft, true);
  11762. signal(cm, "scroll", cm);
  11763. }
  11764. });
  11765. // Listen to wheel events in order to try and update the viewport on time.
  11766. on(d.scroller, "mousewheel", function (e) { return onScrollWheel(cm, e); });
  11767. on(d.scroller, "DOMMouseScroll", function (e) { return onScrollWheel(cm, e); });
  11768. // Prevent wrapper from ever scrolling
  11769. on(d.wrapper, "scroll", function () { return d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
  11770. d.dragFunctions = {
  11771. enter: function (e) {if (!signalDOMEvent(cm, e)) { e_stop(e); }},
  11772. over: function (e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }},
  11773. start: function (e) { return onDragStart(cm, e); },
  11774. drop: operation(cm, onDrop),
  11775. leave: function (e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm); }}
  11776. };
  11777. var inp = d.input.getField();
  11778. on(inp, "keyup", function (e) { return onKeyUp.call(cm, e); });
  11779. on(inp, "keydown", operation(cm, onKeyDown));
  11780. on(inp, "keypress", operation(cm, onKeyPress));
  11781. on(inp, "focus", function (e) { return onFocus(cm, e); });
  11782. on(inp, "blur", function (e) { return onBlur(cm, e); });
  11783. }
  11784. var initHooks = [];
  11785. CodeMirror.defineInitHook = function (f) { return initHooks.push(f); };
  11786. // Indent the given line. The how parameter can be "smart",
  11787. // "add"/null, "subtract", or "prev". When aggressive is false
  11788. // (typically set to true for forced single-line indents), empty
  11789. // lines are not indented, and places where the mode returns Pass
  11790. // are left alone.
  11791. function indentLine(cm, n, how, aggressive) {
  11792. var doc = cm.doc, state;
  11793. if (how == null) { how = "add"; }
  11794. if (how == "smart") {
  11795. // Fall back to "prev" when the mode doesn't have an indentation
  11796. // method.
  11797. if (!doc.mode.indent) { how = "prev"; }
  11798. else { state = getContextBefore(cm, n).state; }
  11799. }
  11800. var tabSize = cm.options.tabSize;
  11801. var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize);
  11802. if (line.stateAfter) { line.stateAfter = null; }
  11803. var curSpaceString = line.text.match(/^\s*/)[0], indentation;
  11804. if (!aggressive && !/\S/.test(line.text)) {
  11805. indentation = 0;
  11806. how = "not";
  11807. } else if (how == "smart") {
  11808. indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
  11809. if (indentation == Pass || indentation > 150) {
  11810. if (!aggressive) { return }
  11811. how = "prev";
  11812. }
  11813. }
  11814. if (how == "prev") {
  11815. if (n > doc.first) { indentation = countColumn(getLine(doc, n-1).text, null, tabSize); }
  11816. else { indentation = 0; }
  11817. } else if (how == "add") {
  11818. indentation = curSpace + cm.options.indentUnit;
  11819. } else if (how == "subtract") {
  11820. indentation = curSpace - cm.options.indentUnit;
  11821. } else if (typeof how == "number") {
  11822. indentation = curSpace + how;
  11823. }
  11824. indentation = Math.max(0, indentation);
  11825. var indentString = "", pos = 0;
  11826. if (cm.options.indentWithTabs)
  11827. { for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";} }
  11828. if (pos < indentation) { indentString += spaceStr(indentation - pos); }
  11829. if (indentString != curSpaceString) {
  11830. replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
  11831. line.stateAfter = null;
  11832. return true
  11833. } else {
  11834. // Ensure that, if the cursor was in the whitespace at the start
  11835. // of the line, it is moved to the end of that space.
  11836. for (var i$1 = 0; i$1 < doc.sel.ranges.length; i$1++) {
  11837. var range = doc.sel.ranges[i$1];
  11838. if (range.head.line == n && range.head.ch < curSpaceString.length) {
  11839. var pos$1 = Pos(n, curSpaceString.length);
  11840. replaceOneSelection(doc, i$1, new Range(pos$1, pos$1));
  11841. break
  11842. }
  11843. }
  11844. }
  11845. }
  11846. // This will be set to a {lineWise: bool, text: [string]} object, so
  11847. // that, when pasting, we know what kind of selections the copied
  11848. // text was made out of.
  11849. var lastCopied = null;
  11850. function setLastCopied(newLastCopied) {
  11851. lastCopied = newLastCopied;
  11852. }
  11853. function applyTextInput(cm, inserted, deleted, sel, origin) {
  11854. var doc = cm.doc;
  11855. cm.display.shift = false;
  11856. if (!sel) { sel = doc.sel; }
  11857. var recent = +new Date - 200;
  11858. var paste = origin == "paste" || cm.state.pasteIncoming > recent;
  11859. var textLines = splitLinesAuto(inserted), multiPaste = null;
  11860. // When pasting N lines into N selections, insert one line per selection
  11861. if (paste && sel.ranges.length > 1) {
  11862. if (lastCopied && lastCopied.text.join("\n") == inserted) {
  11863. if (sel.ranges.length % lastCopied.text.length == 0) {
  11864. multiPaste = [];
  11865. for (var i = 0; i < lastCopied.text.length; i++)
  11866. { multiPaste.push(doc.splitLines(lastCopied.text[i])); }
  11867. }
  11868. } else if (textLines.length == sel.ranges.length && cm.options.pasteLinesPerSelection) {
  11869. multiPaste = map(textLines, function (l) { return [l]; });
  11870. }
  11871. }
  11872. var updateInput = cm.curOp.updateInput;
  11873. // Normal behavior is to insert the new text into every selection
  11874. for (var i$1 = sel.ranges.length - 1; i$1 >= 0; i$1--) {
  11875. var range = sel.ranges[i$1];
  11876. var from = range.from(), to = range.to();
  11877. if (range.empty()) {
  11878. if (deleted && deleted > 0) // Handle deletion
  11879. { from = Pos(from.line, from.ch - deleted); }
  11880. else if (cm.state.overwrite && !paste) // Handle overwrite
  11881. { to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)); }
  11882. else if (paste && lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == textLines.join("\n"))
  11883. { from = to = Pos(from.line, 0); }
  11884. }
  11885. var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i$1 % multiPaste.length] : textLines,
  11886. origin: origin || (paste ? "paste" : cm.state.cutIncoming > recent ? "cut" : "+input")};
  11887. makeChange(cm.doc, changeEvent);
  11888. signalLater(cm, "inputRead", cm, changeEvent);
  11889. }
  11890. if (inserted && !paste)
  11891. { triggerElectric(cm, inserted); }
  11892. ensureCursorVisible(cm);
  11893. if (cm.curOp.updateInput < 2) { cm.curOp.updateInput = updateInput; }
  11894. cm.curOp.typing = true;
  11895. cm.state.pasteIncoming = cm.state.cutIncoming = -1;
  11896. }
  11897. function handlePaste(e, cm) {
  11898. var pasted = e.clipboardData && e.clipboardData.getData("Text");
  11899. if (pasted) {
  11900. e.preventDefault();
  11901. if (!cm.isReadOnly() && !cm.options.disableInput)
  11902. { runInOp(cm, function () { return applyTextInput(cm, pasted, 0, null, "paste"); }); }
  11903. return true
  11904. }
  11905. }
  11906. function triggerElectric(cm, inserted) {
  11907. // When an 'electric' character is inserted, immediately trigger a reindent
  11908. if (!cm.options.electricChars || !cm.options.smartIndent) { return }
  11909. var sel = cm.doc.sel;
  11910. for (var i = sel.ranges.length - 1; i >= 0; i--) {
  11911. var range = sel.ranges[i];
  11912. if (range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line)) { continue }
  11913. var mode = cm.getModeAt(range.head);
  11914. var indented = false;
  11915. if (mode.electricChars) {
  11916. for (var j = 0; j < mode.electricChars.length; j++)
  11917. { if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
  11918. indented = indentLine(cm, range.head.line, "smart");
  11919. break
  11920. } }
  11921. } else if (mode.electricInput) {
  11922. if (mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch)))
  11923. { indented = indentLine(cm, range.head.line, "smart"); }
  11924. }
  11925. if (indented) { signalLater(cm, "electricInput", cm, range.head.line); }
  11926. }
  11927. }
  11928. function copyableRanges(cm) {
  11929. var text = [], ranges = [];
  11930. for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
  11931. var line = cm.doc.sel.ranges[i].head.line;
  11932. var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
  11933. ranges.push(lineRange);
  11934. text.push(cm.getRange(lineRange.anchor, lineRange.head));
  11935. }
  11936. return {text: text, ranges: ranges}
  11937. }
  11938. function disableBrowserMagic(field, spellcheck, autocorrect, autocapitalize) {
  11939. field.setAttribute("autocorrect", autocorrect ? "" : "off");
  11940. field.setAttribute("autocapitalize", autocapitalize ? "" : "off");
  11941. field.setAttribute("spellcheck", !!spellcheck);
  11942. }
  11943. function hiddenTextarea() {
  11944. var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none");
  11945. var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
  11946. // The textarea is kept positioned near the cursor to prevent the
  11947. // fact that it'll be scrolled into view on input from scrolling
  11948. // our fake cursor out of view. On webkit, when wrap=off, paste is
  11949. // very slow. So make the area wide instead.
  11950. if (webkit) { te.style.width = "1000px"; }
  11951. else { te.setAttribute("wrap", "off"); }
  11952. // If border: 0; -- iOS fails to open keyboard (issue #1287)
  11953. if (ios) { te.style.border = "1px solid black"; }
  11954. disableBrowserMagic(te);
  11955. return div
  11956. }
  11957. // The publicly visible API. Note that methodOp(f) means
  11958. // 'wrap f in an operation, performed on its `this` parameter'.
  11959. // This is not the complete set of editor methods. Most of the
  11960. // methods defined on the Doc type are also injected into
  11961. // CodeMirror.prototype, for backwards compatibility and
  11962. // convenience.
  11963. function addEditorMethods(CodeMirror) {
  11964. var optionHandlers = CodeMirror.optionHandlers;
  11965. var helpers = CodeMirror.helpers = {};
  11966. CodeMirror.prototype = {
  11967. constructor: CodeMirror,
  11968. focus: function(){window.focus(); this.display.input.focus();},
  11969. setOption: function(option, value) {
  11970. var options = this.options, old = options[option];
  11971. if (options[option] == value && option != "mode") { return }
  11972. options[option] = value;
  11973. if (optionHandlers.hasOwnProperty(option))
  11974. { operation(this, optionHandlers[option])(this, value, old); }
  11975. signal(this, "optionChange", this, option);
  11976. },
  11977. getOption: function(option) {return this.options[option]},
  11978. getDoc: function() {return this.doc},
  11979. addKeyMap: function(map, bottom) {
  11980. this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map));
  11981. },
  11982. removeKeyMap: function(map) {
  11983. var maps = this.state.keyMaps;
  11984. for (var i = 0; i < maps.length; ++i)
  11985. { if (maps[i] == map || maps[i].name == map) {
  11986. maps.splice(i, 1);
  11987. return true
  11988. } }
  11989. },
  11990. addOverlay: methodOp(function(spec, options) {
  11991. var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
  11992. if (mode.startState) { throw new Error("Overlays may not be stateful.") }
  11993. insertSorted(this.state.overlays,
  11994. {mode: mode, modeSpec: spec, opaque: options && options.opaque,
  11995. priority: (options && options.priority) || 0},
  11996. function (overlay) { return overlay.priority; });
  11997. this.state.modeGen++;
  11998. regChange(this);
  11999. }),
  12000. removeOverlay: methodOp(function(spec) {
  12001. var overlays = this.state.overlays;
  12002. for (var i = 0; i < overlays.length; ++i) {
  12003. var cur = overlays[i].modeSpec;
  12004. if (cur == spec || typeof spec == "string" && cur.name == spec) {
  12005. overlays.splice(i, 1);
  12006. this.state.modeGen++;
  12007. regChange(this);
  12008. return
  12009. }
  12010. }
  12011. }),
  12012. indentLine: methodOp(function(n, dir, aggressive) {
  12013. if (typeof dir != "string" && typeof dir != "number") {
  12014. if (dir == null) { dir = this.options.smartIndent ? "smart" : "prev"; }
  12015. else { dir = dir ? "add" : "subtract"; }
  12016. }
  12017. if (isLine(this.doc, n)) { indentLine(this, n, dir, aggressive); }
  12018. }),
  12019. indentSelection: methodOp(function(how) {
  12020. var ranges = this.doc.sel.ranges, end = -1;
  12021. for (var i = 0; i < ranges.length; i++) {
  12022. var range = ranges[i];
  12023. if (!range.empty()) {
  12024. var from = range.from(), to = range.to();
  12025. var start = Math.max(end, from.line);
  12026. end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1;
  12027. for (var j = start; j < end; ++j)
  12028. { indentLine(this, j, how); }
  12029. var newRanges = this.doc.sel.ranges;
  12030. if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0)
  12031. { replaceOneSelection(this.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll); }
  12032. } else if (range.head.line > end) {
  12033. indentLine(this, range.head.line, how, true);
  12034. end = range.head.line;
  12035. if (i == this.doc.sel.primIndex) { ensureCursorVisible(this); }
  12036. }
  12037. }
  12038. }),
  12039. // Fetch the parser token for a given character. Useful for hacks
  12040. // that want to inspect the mode state (say, for completion).
  12041. getTokenAt: function(pos, precise) {
  12042. return takeToken(this, pos, precise)
  12043. },
  12044. getLineTokens: function(line, precise) {
  12045. return takeToken(this, Pos(line), precise, true)
  12046. },
  12047. getTokenTypeAt: function(pos) {
  12048. pos = clipPos(this.doc, pos);
  12049. var styles = getLineStyles(this, getLine(this.doc, pos.line));
  12050. var before = 0, after = (styles.length - 1) / 2, ch = pos.ch;
  12051. var type;
  12052. if (ch == 0) { type = styles[2]; }
  12053. else { for (;;) {
  12054. var mid = (before + after) >> 1;
  12055. if ((mid ? styles[mid * 2 - 1] : 0) >= ch) { after = mid; }
  12056. else if (styles[mid * 2 + 1] < ch) { before = mid + 1; }
  12057. else { type = styles[mid * 2 + 2]; break }
  12058. } }
  12059. var cut = type ? type.indexOf("overlay ") : -1;
  12060. return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1)
  12061. },
  12062. getModeAt: function(pos) {
  12063. var mode = this.doc.mode;
  12064. if (!mode.innerMode) { return mode }
  12065. return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode
  12066. },
  12067. getHelper: function(pos, type) {
  12068. return this.getHelpers(pos, type)[0]
  12069. },
  12070. getHelpers: function(pos, type) {
  12071. var found = [];
  12072. if (!helpers.hasOwnProperty(type)) { return found }
  12073. var help = helpers[type], mode = this.getModeAt(pos);
  12074. if (typeof mode[type] == "string") {
  12075. if (help[mode[type]]) { found.push(help[mode[type]]); }
  12076. } else if (mode[type]) {
  12077. for (var i = 0; i < mode[type].length; i++) {
  12078. var val = help[mode[type][i]];
  12079. if (val) { found.push(val); }
  12080. }
  12081. } else if (mode.helperType && help[mode.helperType]) {
  12082. found.push(help[mode.helperType]);
  12083. } else if (help[mode.name]) {
  12084. found.push(help[mode.name]);
  12085. }
  12086. for (var i$1 = 0; i$1 < help._global.length; i$1++) {
  12087. var cur = help._global[i$1];
  12088. if (cur.pred(mode, this) && indexOf(found, cur.val) == -1)
  12089. { found.push(cur.val); }
  12090. }
  12091. return found
  12092. },
  12093. getStateAfter: function(line, precise) {
  12094. var doc = this.doc;
  12095. line = clipLine(doc, line == null ? doc.first + doc.size - 1: line);
  12096. return getContextBefore(this, line + 1, precise).state
  12097. },
  12098. cursorCoords: function(start, mode) {
  12099. var pos, range = this.doc.sel.primary();
  12100. if (start == null) { pos = range.head; }
  12101. else if (typeof start == "object") { pos = clipPos(this.doc, start); }
  12102. else { pos = start ? range.from() : range.to(); }
  12103. return cursorCoords(this, pos, mode || "page")
  12104. },
  12105. charCoords: function(pos, mode) {
  12106. return charCoords(this, clipPos(this.doc, pos), mode || "page")
  12107. },
  12108. coordsChar: function(coords, mode) {
  12109. coords = fromCoordSystem(this, coords, mode || "page");
  12110. return coordsChar(this, coords.left, coords.top)
  12111. },
  12112. lineAtHeight: function(height, mode) {
  12113. height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top;
  12114. return lineAtHeight(this.doc, height + this.display.viewOffset)
  12115. },
  12116. heightAtLine: function(line, mode, includeWidgets) {
  12117. var end = false, lineObj;
  12118. if (typeof line == "number") {
  12119. var last = this.doc.first + this.doc.size - 1;
  12120. if (line < this.doc.first) { line = this.doc.first; }
  12121. else if (line > last) { line = last; end = true; }
  12122. lineObj = getLine(this.doc, line);
  12123. } else {
  12124. lineObj = line;
  12125. }
  12126. return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page", includeWidgets || end).top +
  12127. (end ? this.doc.height - heightAtLine(lineObj) : 0)
  12128. },
  12129. defaultTextHeight: function() { return textHeight(this.display) },
  12130. defaultCharWidth: function() { return charWidth(this.display) },
  12131. getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo}},
  12132. addWidget: function(pos, node, scroll, vert, horiz) {
  12133. var display = this.display;
  12134. pos = cursorCoords(this, clipPos(this.doc, pos));
  12135. var top = pos.bottom, left = pos.left;
  12136. node.style.position = "absolute";
  12137. node.setAttribute("cm-ignore-events", "true");
  12138. this.display.input.setUneditable(node);
  12139. display.sizer.appendChild(node);
  12140. if (vert == "over") {
  12141. top = pos.top;
  12142. } else if (vert == "above" || vert == "near") {
  12143. var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),
  12144. hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth);
  12145. // Default to positioning above (if specified and possible); otherwise default to positioning below
  12146. if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight)
  12147. { top = pos.top - node.offsetHeight; }
  12148. else if (pos.bottom + node.offsetHeight <= vspace)
  12149. { top = pos.bottom; }
  12150. if (left + node.offsetWidth > hspace)
  12151. { left = hspace - node.offsetWidth; }
  12152. }
  12153. node.style.top = top + "px";
  12154. node.style.left = node.style.right = "";
  12155. if (horiz == "right") {
  12156. left = display.sizer.clientWidth - node.offsetWidth;
  12157. node.style.right = "0px";
  12158. } else {
  12159. if (horiz == "left") { left = 0; }
  12160. else if (horiz == "middle") { left = (display.sizer.clientWidth - node.offsetWidth) / 2; }
  12161. node.style.left = left + "px";
  12162. }
  12163. if (scroll)
  12164. { scrollIntoView(this, {left: left, top: top, right: left + node.offsetWidth, bottom: top + node.offsetHeight}); }
  12165. },
  12166. triggerOnKeyDown: methodOp(onKeyDown),
  12167. triggerOnKeyPress: methodOp(onKeyPress),
  12168. triggerOnKeyUp: onKeyUp,
  12169. triggerOnMouseDown: methodOp(onMouseDown),
  12170. execCommand: function(cmd) {
  12171. if (commands.hasOwnProperty(cmd))
  12172. { return commands[cmd].call(null, this) }
  12173. },
  12174. triggerElectric: methodOp(function(text) { triggerElectric(this, text); }),
  12175. findPosH: function(from, amount, unit, visually) {
  12176. var dir = 1;
  12177. if (amount < 0) { dir = -1; amount = -amount; }
  12178. var cur = clipPos(this.doc, from);
  12179. for (var i = 0; i < amount; ++i) {
  12180. cur = findPosH(this.doc, cur, dir, unit, visually);
  12181. if (cur.hitSide) { break }
  12182. }
  12183. return cur
  12184. },
  12185. moveH: methodOp(function(dir, unit) {
  12186. var this$1 = this;
  12187. this.extendSelectionsBy(function (range) {
  12188. if (this$1.display.shift || this$1.doc.extend || range.empty())
  12189. { return findPosH(this$1.doc, range.head, dir, unit, this$1.options.rtlMoveVisually) }
  12190. else
  12191. { return dir < 0 ? range.from() : range.to() }
  12192. }, sel_move);
  12193. }),
  12194. deleteH: methodOp(function(dir, unit) {
  12195. var sel = this.doc.sel, doc = this.doc;
  12196. if (sel.somethingSelected())
  12197. { doc.replaceSelection("", null, "+delete"); }
  12198. else
  12199. { deleteNearSelection(this, function (range) {
  12200. var other = findPosH(doc, range.head, dir, unit, false);
  12201. return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other}
  12202. }); }
  12203. }),
  12204. findPosV: function(from, amount, unit, goalColumn) {
  12205. var dir = 1, x = goalColumn;
  12206. if (amount < 0) { dir = -1; amount = -amount; }
  12207. var cur = clipPos(this.doc, from);
  12208. for (var i = 0; i < amount; ++i) {
  12209. var coords = cursorCoords(this, cur, "div");
  12210. if (x == null) { x = coords.left; }
  12211. else { coords.left = x; }
  12212. cur = findPosV(this, coords, dir, unit);
  12213. if (cur.hitSide) { break }
  12214. }
  12215. return cur
  12216. },
  12217. moveV: methodOp(function(dir, unit) {
  12218. var this$1 = this;
  12219. var doc = this.doc, goals = [];
  12220. var collapse = !this.display.shift && !doc.extend && doc.sel.somethingSelected();
  12221. doc.extendSelectionsBy(function (range) {
  12222. if (collapse)
  12223. { return dir < 0 ? range.from() : range.to() }
  12224. var headPos = cursorCoords(this$1, range.head, "div");
  12225. if (range.goalColumn != null) { headPos.left = range.goalColumn; }
  12226. goals.push(headPos.left);
  12227. var pos = findPosV(this$1, headPos, dir, unit);
  12228. if (unit == "page" && range == doc.sel.primary())
  12229. { addToScrollTop(this$1, charCoords(this$1, pos, "div").top - headPos.top); }
  12230. return pos
  12231. }, sel_move);
  12232. if (goals.length) { for (var i = 0; i < doc.sel.ranges.length; i++)
  12233. { doc.sel.ranges[i].goalColumn = goals[i]; } }
  12234. }),
  12235. // Find the word at the given position (as returned by coordsChar).
  12236. findWordAt: function(pos) {
  12237. var doc = this.doc, line = getLine(doc, pos.line).text;
  12238. var start = pos.ch, end = pos.ch;
  12239. if (line) {
  12240. var helper = this.getHelper(pos, "wordChars");
  12241. if ((pos.sticky == "before" || end == line.length) && start) { --start; } else { ++end; }
  12242. var startChar = line.charAt(start);
  12243. var check = isWordChar(startChar, helper)
  12244. ? function (ch) { return isWordChar(ch, helper); }
  12245. : /\s/.test(startChar) ? function (ch) { return /\s/.test(ch); }
  12246. : function (ch) { return (!/\s/.test(ch) && !isWordChar(ch)); };
  12247. while (start > 0 && check(line.charAt(start - 1))) { --start; }
  12248. while (end < line.length && check(line.charAt(end))) { ++end; }
  12249. }
  12250. return new Range(Pos(pos.line, start), Pos(pos.line, end))
  12251. },
  12252. toggleOverwrite: function(value) {
  12253. if (value != null && value == this.state.overwrite) { return }
  12254. if (this.state.overwrite = !this.state.overwrite)
  12255. { addClass(this.display.cursorDiv, "CodeMirror-overwrite"); }
  12256. else
  12257. { rmClass(this.display.cursorDiv, "CodeMirror-overwrite"); }
  12258. signal(this, "overwriteToggle", this, this.state.overwrite);
  12259. },
  12260. hasFocus: function() { return this.display.input.getField() == activeElt() },
  12261. isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) },
  12262. scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }),
  12263. getScrollInfo: function() {
  12264. var scroller = this.display.scroller;
  12265. return {left: scroller.scrollLeft, top: scroller.scrollTop,
  12266. height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight,
  12267. width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth,
  12268. clientHeight: displayHeight(this), clientWidth: displayWidth(this)}
  12269. },
  12270. scrollIntoView: methodOp(function(range, margin) {
  12271. if (range == null) {
  12272. range = {from: this.doc.sel.primary().head, to: null};
  12273. if (margin == null) { margin = this.options.cursorScrollMargin; }
  12274. } else if (typeof range == "number") {
  12275. range = {from: Pos(range, 0), to: null};
  12276. } else if (range.from == null) {
  12277. range = {from: range, to: null};
  12278. }
  12279. if (!range.to) { range.to = range.from; }
  12280. range.margin = margin || 0;
  12281. if (range.from.line != null) {
  12282. scrollToRange(this, range);
  12283. } else {
  12284. scrollToCoordsRange(this, range.from, range.to, range.margin);
  12285. }
  12286. }),
  12287. setSize: methodOp(function(width, height) {
  12288. var this$1 = this;
  12289. var interpret = function (val) { return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val; };
  12290. if (width != null) { this.display.wrapper.style.width = interpret(width); }
  12291. if (height != null) { this.display.wrapper.style.height = interpret(height); }
  12292. if (this.options.lineWrapping) { clearLineMeasurementCache(this); }
  12293. var lineNo = this.display.viewFrom;
  12294. this.doc.iter(lineNo, this.display.viewTo, function (line) {
  12295. if (line.widgets) { for (var i = 0; i < line.widgets.length; i++)
  12296. { if (line.widgets[i].noHScroll) { regLineChange(this$1, lineNo, "widget"); break } } }
  12297. ++lineNo;
  12298. });
  12299. this.curOp.forceUpdate = true;
  12300. signal(this, "refresh", this);
  12301. }),
  12302. operation: function(f){return runInOp(this, f)},
  12303. startOperation: function(){return startOperation(this)},
  12304. endOperation: function(){return endOperation(this)},
  12305. refresh: methodOp(function() {
  12306. var oldHeight = this.display.cachedTextHeight;
  12307. regChange(this);
  12308. this.curOp.forceUpdate = true;
  12309. clearCaches(this);
  12310. scrollToCoords(this, this.doc.scrollLeft, this.doc.scrollTop);
  12311. updateGutterSpace(this.display);
  12312. if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5 || this.options.lineWrapping)
  12313. { estimateLineHeights(this); }
  12314. signal(this, "refresh", this);
  12315. }),
  12316. swapDoc: methodOp(function(doc) {
  12317. var old = this.doc;
  12318. old.cm = null;
  12319. // Cancel the current text selection if any (#5821)
  12320. if (this.state.selectingText) { this.state.selectingText(); }
  12321. attachDoc(this, doc);
  12322. clearCaches(this);
  12323. this.display.input.reset();
  12324. scrollToCoords(this, doc.scrollLeft, doc.scrollTop);
  12325. this.curOp.forceScroll = true;
  12326. signalLater(this, "swapDoc", this, old);
  12327. return old
  12328. }),
  12329. phrase: function(phraseText) {
  12330. var phrases = this.options.phrases;
  12331. return phrases && Object.prototype.hasOwnProperty.call(phrases, phraseText) ? phrases[phraseText] : phraseText
  12332. },
  12333. getInputField: function(){return this.display.input.getField()},
  12334. getWrapperElement: function(){return this.display.wrapper},
  12335. getScrollerElement: function(){return this.display.scroller},
  12336. getGutterElement: function(){return this.display.gutters}
  12337. };
  12338. eventMixin(CodeMirror);
  12339. CodeMirror.registerHelper = function(type, name, value) {
  12340. if (!helpers.hasOwnProperty(type)) { helpers[type] = CodeMirror[type] = {_global: []}; }
  12341. helpers[type][name] = value;
  12342. };
  12343. CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {
  12344. CodeMirror.registerHelper(type, name, value);
  12345. helpers[type]._global.push({pred: predicate, val: value});
  12346. };
  12347. }
  12348. // Used for horizontal relative motion. Dir is -1 or 1 (left or
  12349. // right), unit can be "codepoint", "char", "column" (like char, but
  12350. // doesn't cross line boundaries), "word" (across next word), or
  12351. // "group" (to the start of next group of word or
  12352. // non-word-non-whitespace chars). The visually param controls
  12353. // whether, in right-to-left text, direction 1 means to move towards
  12354. // the next index in the string, or towards the character to the right
  12355. // of the current position. The resulting position will have a
  12356. // hitSide=true property if it reached the end of the document.
  12357. function findPosH(doc, pos, dir, unit, visually) {
  12358. var oldPos = pos;
  12359. var origDir = dir;
  12360. var lineObj = getLine(doc, pos.line);
  12361. var lineDir = visually && doc.direction == "rtl" ? -dir : dir;
  12362. function findNextLine() {
  12363. var l = pos.line + lineDir;
  12364. if (l < doc.first || l >= doc.first + doc.size) { return false }
  12365. pos = new Pos(l, pos.ch, pos.sticky);
  12366. return lineObj = getLine(doc, l)
  12367. }
  12368. function moveOnce(boundToLine) {
  12369. var next;
  12370. if (unit == "codepoint") {
  12371. var ch = lineObj.text.charCodeAt(pos.ch + (unit > 0 ? 0 : -1));
  12372. if (isNaN(ch)) { next = null; }
  12373. else { next = new Pos(pos.line, Math.max(0, Math.min(lineObj.text.length, pos.ch + dir * (ch >= 0xD800 && ch < 0xDC00 ? 2 : 1))),
  12374. -dir); }
  12375. } else if (visually) {
  12376. next = moveVisually(doc.cm, lineObj, pos, dir);
  12377. } else {
  12378. next = moveLogically(lineObj, pos, dir);
  12379. }
  12380. if (next == null) {
  12381. if (!boundToLine && findNextLine())
  12382. { pos = endOfLine(visually, doc.cm, lineObj, pos.line, lineDir); }
  12383. else
  12384. { return false }
  12385. } else {
  12386. pos = next;
  12387. }
  12388. return true
  12389. }
  12390. if (unit == "char" || unit == "codepoint") {
  12391. moveOnce();
  12392. } else if (unit == "column") {
  12393. moveOnce(true);
  12394. } else if (unit == "word" || unit == "group") {
  12395. var sawType = null, group = unit == "group";
  12396. var helper = doc.cm && doc.cm.getHelper(pos, "wordChars");
  12397. for (var first = true;; first = false) {
  12398. if (dir < 0 && !moveOnce(!first)) { break }
  12399. var cur = lineObj.text.charAt(pos.ch) || "\n";
  12400. var type = isWordChar(cur, helper) ? "w"
  12401. : group && cur == "\n" ? "n"
  12402. : !group || /\s/.test(cur) ? null
  12403. : "p";
  12404. if (group && !first && !type) { type = "s"; }
  12405. if (sawType && sawType != type) {
  12406. if (dir < 0) {dir = 1; moveOnce(); pos.sticky = "after";}
  12407. break
  12408. }
  12409. if (type) { sawType = type; }
  12410. if (dir > 0 && !moveOnce(!first)) { break }
  12411. }
  12412. }
  12413. var result = skipAtomic(doc, pos, oldPos, origDir, true);
  12414. if (equalCursorPos(oldPos, result)) { result.hitSide = true; }
  12415. return result
  12416. }
  12417. // For relative vertical movement. Dir may be -1 or 1. Unit can be
  12418. // "page" or "line". The resulting position will have a hitSide=true
  12419. // property if it reached the end of the document.
  12420. function findPosV(cm, pos, dir, unit) {
  12421. var doc = cm.doc, x = pos.left, y;
  12422. if (unit == "page") {
  12423. var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
  12424. var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3);
  12425. y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount;
  12426. } else if (unit == "line") {
  12427. y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
  12428. }
  12429. var target;
  12430. for (;;) {
  12431. target = coordsChar(cm, x, y);
  12432. if (!target.outside) { break }
  12433. if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break }
  12434. y += dir * 5;
  12435. }
  12436. return target
  12437. }
  12438. // CONTENTEDITABLE INPUT STYLE
  12439. var ContentEditableInput = function(cm) {
  12440. this.cm = cm;
  12441. this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null;
  12442. this.polling = new Delayed();
  12443. this.composing = null;
  12444. this.gracePeriod = false;
  12445. this.readDOMTimeout = null;
  12446. };
  12447. ContentEditableInput.prototype.init = function (display) {
  12448. var this$1 = this;
  12449. var input = this, cm = input.cm;
  12450. var div = input.div = display.lineDiv;
  12451. disableBrowserMagic(div, cm.options.spellcheck, cm.options.autocorrect, cm.options.autocapitalize);
  12452. function belongsToInput(e) {
  12453. for (var t = e.target; t; t = t.parentNode) {
  12454. if (t == div) { return true }
  12455. if (/\bCodeMirror-(?:line)?widget\b/.test(t.className)) { break }
  12456. }
  12457. return false
  12458. }
  12459. on(div, "paste", function (e) {
  12460. if (!belongsToInput(e) || signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
  12461. // IE doesn't fire input events, so we schedule a read for the pasted content in this way
  12462. if (ie_version <= 11) { setTimeout(operation(cm, function () { return this$1.updateFromDOM(); }), 20); }
  12463. });
  12464. on(div, "compositionstart", function (e) {
  12465. this$1.composing = {data: e.data, done: false};
  12466. });
  12467. on(div, "compositionupdate", function (e) {
  12468. if (!this$1.composing) { this$1.composing = {data: e.data, done: false}; }
  12469. });
  12470. on(div, "compositionend", function (e) {
  12471. if (this$1.composing) {
  12472. if (e.data != this$1.composing.data) { this$1.readFromDOMSoon(); }
  12473. this$1.composing.done = true;
  12474. }
  12475. });
  12476. on(div, "touchstart", function () { return input.forceCompositionEnd(); });
  12477. on(div, "input", function () {
  12478. if (!this$1.composing) { this$1.readFromDOMSoon(); }
  12479. });
  12480. function onCopyCut(e) {
  12481. if (!belongsToInput(e) || signalDOMEvent(cm, e)) { return }
  12482. if (cm.somethingSelected()) {
  12483. setLastCopied({lineWise: false, text: cm.getSelections()});
  12484. if (e.type == "cut") { cm.replaceSelection("", null, "cut"); }
  12485. } else if (!cm.options.lineWiseCopyCut) {
  12486. return
  12487. } else {
  12488. var ranges = copyableRanges(cm);
  12489. setLastCopied({lineWise: true, text: ranges.text});
  12490. if (e.type == "cut") {
  12491. cm.operation(function () {
  12492. cm.setSelections(ranges.ranges, 0, sel_dontScroll);
  12493. cm.replaceSelection("", null, "cut");
  12494. });
  12495. }
  12496. }
  12497. if (e.clipboardData) {
  12498. e.clipboardData.clearData();
  12499. var content = lastCopied.text.join("\n");
  12500. // iOS exposes the clipboard API, but seems to discard content inserted into it
  12501. e.clipboardData.setData("Text", content);
  12502. if (e.clipboardData.getData("Text") == content) {
  12503. e.preventDefault();
  12504. return
  12505. }
  12506. }
  12507. // Old-fashioned briefly-focus-a-textarea hack
  12508. var kludge = hiddenTextarea(), te = kludge.firstChild;
  12509. cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
  12510. te.value = lastCopied.text.join("\n");
  12511. var hadFocus = document.activeElement;
  12512. selectInput(te);
  12513. setTimeout(function () {
  12514. cm.display.lineSpace.removeChild(kludge);
  12515. hadFocus.focus();
  12516. if (hadFocus == div) { input.showPrimarySelection(); }
  12517. }, 50);
  12518. }
  12519. on(div, "copy", onCopyCut);
  12520. on(div, "cut", onCopyCut);
  12521. };
  12522. ContentEditableInput.prototype.screenReaderLabelChanged = function (label) {
  12523. // Label for screenreaders, accessibility
  12524. if(label) {
  12525. this.div.setAttribute('aria-label', label);
  12526. } else {
  12527. this.div.removeAttribute('aria-label');
  12528. }
  12529. };
  12530. ContentEditableInput.prototype.prepareSelection = function () {
  12531. var result = prepareSelection(this.cm, false);
  12532. result.focus = document.activeElement == this.div;
  12533. return result
  12534. };
  12535. ContentEditableInput.prototype.showSelection = function (info, takeFocus) {
  12536. if (!info || !this.cm.display.view.length) { return }
  12537. if (info.focus || takeFocus) { this.showPrimarySelection(); }
  12538. this.showMultipleSelections(info);
  12539. };
  12540. ContentEditableInput.prototype.getSelection = function () {
  12541. return this.cm.display.wrapper.ownerDocument.getSelection()
  12542. };
  12543. ContentEditableInput.prototype.showPrimarySelection = function () {
  12544. var sel = this.getSelection(), cm = this.cm, prim = cm.doc.sel.primary();
  12545. var from = prim.from(), to = prim.to();
  12546. if (cm.display.viewTo == cm.display.viewFrom || from.line >= cm.display.viewTo || to.line < cm.display.viewFrom) {
  12547. sel.removeAllRanges();
  12548. return
  12549. }
  12550. var curAnchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
  12551. var curFocus = domToPos(cm, sel.focusNode, sel.focusOffset);
  12552. if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
  12553. cmp(minPos(curAnchor, curFocus), from) == 0 &&
  12554. cmp(maxPos(curAnchor, curFocus), to) == 0)
  12555. { return }
  12556. var view = cm.display.view;
  12557. var start = (from.line >= cm.display.viewFrom && posToDOM(cm, from)) ||
  12558. {node: view[0].measure.map[2], offset: 0};
  12559. var end = to.line < cm.display.viewTo && posToDOM(cm, to);
  12560. if (!end) {
  12561. var measure = view[view.length - 1].measure;
  12562. var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map;
  12563. end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]};
  12564. }
  12565. if (!start || !end) {
  12566. sel.removeAllRanges();
  12567. return
  12568. }
  12569. var old = sel.rangeCount && sel.getRangeAt(0), rng;
  12570. try { rng = range(start.node, start.offset, end.offset, end.node); }
  12571. catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
  12572. if (rng) {
  12573. if (!gecko && cm.state.focused) {
  12574. sel.collapse(start.node, start.offset);
  12575. if (!rng.collapsed) {
  12576. sel.removeAllRanges();
  12577. sel.addRange(rng);
  12578. }
  12579. } else {
  12580. sel.removeAllRanges();
  12581. sel.addRange(rng);
  12582. }
  12583. if (old && sel.anchorNode == null) { sel.addRange(old); }
  12584. else if (gecko) { this.startGracePeriod(); }
  12585. }
  12586. this.rememberSelection();
  12587. };
  12588. ContentEditableInput.prototype.startGracePeriod = function () {
  12589. var this$1 = this;
  12590. clearTimeout(this.gracePeriod);
  12591. this.gracePeriod = setTimeout(function () {
  12592. this$1.gracePeriod = false;
  12593. if (this$1.selectionChanged())
  12594. { this$1.cm.operation(function () { return this$1.cm.curOp.selectionChanged = true; }); }
  12595. }, 20);
  12596. };
  12597. ContentEditableInput.prototype.showMultipleSelections = function (info) {
  12598. removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors);
  12599. removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection);
  12600. };
  12601. ContentEditableInput.prototype.rememberSelection = function () {
  12602. var sel = this.getSelection();
  12603. this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset;
  12604. this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset;
  12605. };
  12606. ContentEditableInput.prototype.selectionInEditor = function () {
  12607. var sel = this.getSelection();
  12608. if (!sel.rangeCount) { return false }
  12609. var node = sel.getRangeAt(0).commonAncestorContainer;
  12610. return contains(this.div, node)
  12611. };
  12612. ContentEditableInput.prototype.focus = function () {
  12613. if (this.cm.options.readOnly != "nocursor") {
  12614. if (!this.selectionInEditor() || document.activeElement != this.div)
  12615. { this.showSelection(this.prepareSelection(), true); }
  12616. this.div.focus();
  12617. }
  12618. };
  12619. ContentEditableInput.prototype.blur = function () { this.div.blur(); };
  12620. ContentEditableInput.prototype.getField = function () { return this.div };
  12621. ContentEditableInput.prototype.supportsTouch = function () { return true };
  12622. ContentEditableInput.prototype.receivedFocus = function () {
  12623. var input = this;
  12624. if (this.selectionInEditor())
  12625. { this.pollSelection(); }
  12626. else
  12627. { runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }); }
  12628. function poll() {
  12629. if (input.cm.state.focused) {
  12630. input.pollSelection();
  12631. input.polling.set(input.cm.options.pollInterval, poll);
  12632. }
  12633. }
  12634. this.polling.set(this.cm.options.pollInterval, poll);
  12635. };
  12636. ContentEditableInput.prototype.selectionChanged = function () {
  12637. var sel = this.getSelection();
  12638. return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||
  12639. sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset
  12640. };
  12641. ContentEditableInput.prototype.pollSelection = function () {
  12642. if (this.readDOMTimeout != null || this.gracePeriod || !this.selectionChanged()) { return }
  12643. var sel = this.getSelection(), cm = this.cm;
  12644. // On Android Chrome (version 56, at least), backspacing into an
  12645. // uneditable block element will put the cursor in that element,
  12646. // and then, because it's not editable, hide the virtual keyboard.
  12647. // Because Android doesn't allow us to actually detect backspace
  12648. // presses in a sane way, this code checks for when that happens
  12649. // and simulates a backspace press in this case.
  12650. if (android && chrome && this.cm.display.gutterSpecs.length && isInGutter(sel.anchorNode)) {
  12651. this.cm.triggerOnKeyDown({type: "keydown", keyCode: 8, preventDefault: Math.abs});
  12652. this.blur();
  12653. this.focus();
  12654. return
  12655. }
  12656. if (this.composing) { return }
  12657. this.rememberSelection();
  12658. var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
  12659. var head = domToPos(cm, sel.focusNode, sel.focusOffset);
  12660. if (anchor && head) { runInOp(cm, function () {
  12661. setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll);
  12662. if (anchor.bad || head.bad) { cm.curOp.selectionChanged = true; }
  12663. }); }
  12664. };
  12665. ContentEditableInput.prototype.pollContent = function () {
  12666. if (this.readDOMTimeout != null) {
  12667. clearTimeout(this.readDOMTimeout);
  12668. this.readDOMTimeout = null;
  12669. }
  12670. var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary();
  12671. var from = sel.from(), to = sel.to();
  12672. if (from.ch == 0 && from.line > cm.firstLine())
  12673. { from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length); }
  12674. if (to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine())
  12675. { to = Pos(to.line + 1, 0); }
  12676. if (from.line < display.viewFrom || to.line > display.viewTo - 1) { return false }
  12677. var fromIndex, fromLine, fromNode;
  12678. if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
  12679. fromLine = lineNo(display.view[0].line);
  12680. fromNode = display.view[0].node;
  12681. } else {
  12682. fromLine = lineNo(display.view[fromIndex].line);
  12683. fromNode = display.view[fromIndex - 1].node.nextSibling;
  12684. }
  12685. var toIndex = findViewIndex(cm, to.line);
  12686. var toLine, toNode;
  12687. if (toIndex == display.view.length - 1) {
  12688. toLine = display.viewTo - 1;
  12689. toNode = display.lineDiv.lastChild;
  12690. } else {
  12691. toLine = lineNo(display.view[toIndex + 1].line) - 1;
  12692. toNode = display.view[toIndex + 1].node.previousSibling;
  12693. }
  12694. if (!fromNode) { return false }
  12695. var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
  12696. var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
  12697. while (newText.length > 1 && oldText.length > 1) {
  12698. if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }
  12699. else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; }
  12700. else { break }
  12701. }
  12702. var cutFront = 0, cutEnd = 0;
  12703. var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length);
  12704. while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))
  12705. { ++cutFront; }
  12706. var newBot = lst(newText), oldBot = lst(oldText);
  12707. var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),
  12708. oldBot.length - (oldText.length == 1 ? cutFront : 0));
  12709. while (cutEnd < maxCutEnd &&
  12710. newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
  12711. { ++cutEnd; }
  12712. // Try to move start of change to start of selection if ambiguous
  12713. if (newText.length == 1 && oldText.length == 1 && fromLine == from.line) {
  12714. while (cutFront && cutFront > from.ch &&
  12715. newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) {
  12716. cutFront--;
  12717. cutEnd++;
  12718. }
  12719. }
  12720. newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\u200b+/, "");
  12721. newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, "");
  12722. var chFrom = Pos(fromLine, cutFront);
  12723. var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0);
  12724. if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
  12725. replaceRange(cm.doc, newText, chFrom, chTo, "+input");
  12726. return true
  12727. }
  12728. };
  12729. ContentEditableInput.prototype.ensurePolled = function () {
  12730. this.forceCompositionEnd();
  12731. };
  12732. ContentEditableInput.prototype.reset = function () {
  12733. this.forceCompositionEnd();
  12734. };
  12735. ContentEditableInput.prototype.forceCompositionEnd = function () {
  12736. if (!this.composing) { return }
  12737. clearTimeout(this.readDOMTimeout);
  12738. this.composing = null;
  12739. this.updateFromDOM();
  12740. this.div.blur();
  12741. this.div.focus();
  12742. };
  12743. ContentEditableInput.prototype.readFromDOMSoon = function () {
  12744. var this$1 = this;
  12745. if (this.readDOMTimeout != null) { return }
  12746. this.readDOMTimeout = setTimeout(function () {
  12747. this$1.readDOMTimeout = null;
  12748. if (this$1.composing) {
  12749. if (this$1.composing.done) { this$1.composing = null; }
  12750. else { return }
  12751. }
  12752. this$1.updateFromDOM();
  12753. }, 80);
  12754. };
  12755. ContentEditableInput.prototype.updateFromDOM = function () {
  12756. var this$1 = this;
  12757. if (this.cm.isReadOnly() || !this.pollContent())
  12758. { runInOp(this.cm, function () { return regChange(this$1.cm); }); }
  12759. };
  12760. ContentEditableInput.prototype.setUneditable = function (node) {
  12761. node.contentEditable = "false";
  12762. };
  12763. ContentEditableInput.prototype.onKeyPress = function (e) {
  12764. if (e.charCode == 0 || this.composing) { return }
  12765. e.preventDefault();
  12766. if (!this.cm.isReadOnly())
  12767. { operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0); }
  12768. };
  12769. ContentEditableInput.prototype.readOnlyChanged = function (val) {
  12770. this.div.contentEditable = String(val != "nocursor");
  12771. };
  12772. ContentEditableInput.prototype.onContextMenu = function () {};
  12773. ContentEditableInput.prototype.resetPosition = function () {};
  12774. ContentEditableInput.prototype.needsContentAttribute = true;
  12775. function posToDOM(cm, pos) {
  12776. var view = findViewForLine(cm, pos.line);
  12777. if (!view || view.hidden) { return null }
  12778. var line = getLine(cm.doc, pos.line);
  12779. var info = mapFromLineView(view, line, pos.line);
  12780. var order = getOrder(line, cm.doc.direction), side = "left";
  12781. if (order) {
  12782. var partPos = getBidiPartAt(order, pos.ch);
  12783. side = partPos % 2 ? "right" : "left";
  12784. }
  12785. var result = nodeAndOffsetInLineMap(info.map, pos.ch, side);
  12786. result.offset = result.collapse == "right" ? result.end : result.start;
  12787. return result
  12788. }
  12789. function isInGutter(node) {
  12790. for (var scan = node; scan; scan = scan.parentNode)
  12791. { if (/CodeMirror-gutter-wrapper/.test(scan.className)) { return true } }
  12792. return false
  12793. }
  12794. function badPos(pos, bad) { if (bad) { pos.bad = true; } return pos }
  12795. function domTextBetween(cm, from, to, fromLine, toLine) {
  12796. var text = "", closing = false, lineSep = cm.doc.lineSeparator(), extraLinebreak = false;
  12797. function recognizeMarker(id) { return function (marker) { return marker.id == id; } }
  12798. function close() {
  12799. if (closing) {
  12800. text += lineSep;
  12801. if (extraLinebreak) { text += lineSep; }
  12802. closing = extraLinebreak = false;
  12803. }
  12804. }
  12805. function addText(str) {
  12806. if (str) {
  12807. close();
  12808. text += str;
  12809. }
  12810. }
  12811. function walk(node) {
  12812. if (node.nodeType == 1) {
  12813. var cmText = node.getAttribute("cm-text");
  12814. if (cmText) {
  12815. addText(cmText);
  12816. return
  12817. }
  12818. var markerID = node.getAttribute("cm-marker"), range;
  12819. if (markerID) {
  12820. var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
  12821. if (found.length && (range = found[0].find(0)))
  12822. { addText(getBetween(cm.doc, range.from, range.to).join(lineSep)); }
  12823. return
  12824. }
  12825. if (node.getAttribute("contenteditable") == "false") { return }
  12826. var isBlock = /^(pre|div|p|li|table|br)$/i.test(node.nodeName);
  12827. if (!/^br$/i.test(node.nodeName) && node.textContent.length == 0) { return }
  12828. if (isBlock) { close(); }
  12829. for (var i = 0; i < node.childNodes.length; i++)
  12830. { walk(node.childNodes[i]); }
  12831. if (/^(pre|p)$/i.test(node.nodeName)) { extraLinebreak = true; }
  12832. if (isBlock) { closing = true; }
  12833. } else if (node.nodeType == 3) {
  12834. addText(node.nodeValue.replace(/\u200b/g, "").replace(/\u00a0/g, " "));
  12835. }
  12836. }
  12837. for (;;) {
  12838. walk(from);
  12839. if (from == to) { break }
  12840. from = from.nextSibling;
  12841. extraLinebreak = false;
  12842. }
  12843. return text
  12844. }
  12845. function domToPos(cm, node, offset) {
  12846. var lineNode;
  12847. if (node == cm.display.lineDiv) {
  12848. lineNode = cm.display.lineDiv.childNodes[offset];
  12849. if (!lineNode) { return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true) }
  12850. node = null; offset = 0;
  12851. } else {
  12852. for (lineNode = node;; lineNode = lineNode.parentNode) {
  12853. if (!lineNode || lineNode == cm.display.lineDiv) { return null }
  12854. if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) { break }
  12855. }
  12856. }
  12857. for (var i = 0; i < cm.display.view.length; i++) {
  12858. var lineView = cm.display.view[i];
  12859. if (lineView.node == lineNode)
  12860. { return locateNodeInLineView(lineView, node, offset) }
  12861. }
  12862. }
  12863. function locateNodeInLineView(lineView, node, offset) {
  12864. var wrapper = lineView.text.firstChild, bad = false;
  12865. if (!node || !contains(wrapper, node)) { return badPos(Pos(lineNo(lineView.line), 0), true) }
  12866. if (node == wrapper) {
  12867. bad = true;
  12868. node = wrapper.childNodes[offset];
  12869. offset = 0;
  12870. if (!node) {
  12871. var line = lineView.rest ? lst(lineView.rest) : lineView.line;
  12872. return badPos(Pos(lineNo(line), line.text.length), bad)
  12873. }
  12874. }
  12875. var textNode = node.nodeType == 3 ? node : null, topNode = node;
  12876. if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
  12877. textNode = node.firstChild;
  12878. if (offset) { offset = textNode.nodeValue.length; }
  12879. }
  12880. while (topNode.parentNode != wrapper) { topNode = topNode.parentNode; }
  12881. var measure = lineView.measure, maps = measure.maps;
  12882. function find(textNode, topNode, offset) {
  12883. for (var i = -1; i < (maps ? maps.length : 0); i++) {
  12884. var map = i < 0 ? measure.map : maps[i];
  12885. for (var j = 0; j < map.length; j += 3) {
  12886. var curNode = map[j + 2];
  12887. if (curNode == textNode || curNode == topNode) {
  12888. var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]);
  12889. var ch = map[j] + offset;
  12890. if (offset < 0 || curNode != textNode) { ch = map[j + (offset ? 1 : 0)]; }
  12891. return Pos(line, ch)
  12892. }
  12893. }
  12894. }
  12895. }
  12896. var found = find(textNode, topNode, offset);
  12897. if (found) { return badPos(found, bad) }
  12898. // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems
  12899. for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
  12900. found = find(after, after.firstChild, 0);
  12901. if (found)
  12902. { return badPos(Pos(found.line, found.ch - dist), bad) }
  12903. else
  12904. { dist += after.textContent.length; }
  12905. }
  12906. for (var before = topNode.previousSibling, dist$1 = offset; before; before = before.previousSibling) {
  12907. found = find(before, before.firstChild, -1);
  12908. if (found)
  12909. { return badPos(Pos(found.line, found.ch + dist$1), bad) }
  12910. else
  12911. { dist$1 += before.textContent.length; }
  12912. }
  12913. }
  12914. // TEXTAREA INPUT STYLE
  12915. var TextareaInput = function(cm) {
  12916. this.cm = cm;
  12917. // See input.poll and input.reset
  12918. this.prevInput = "";
  12919. // Flag that indicates whether we expect input to appear real soon
  12920. // now (after some event like 'keypress' or 'input') and are
  12921. // polling intensively.
  12922. this.pollingFast = false;
  12923. // Self-resetting timeout for the poller
  12924. this.polling = new Delayed();
  12925. // Used to work around IE issue with selection being forgotten when focus moves away from textarea
  12926. this.hasSelection = false;
  12927. this.composing = null;
  12928. };
  12929. TextareaInput.prototype.init = function (display) {
  12930. var this$1 = this;
  12931. var input = this, cm = this.cm;
  12932. this.createField(display);
  12933. var te = this.textarea;
  12934. display.wrapper.insertBefore(this.wrapper, display.wrapper.firstChild);
  12935. // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
  12936. if (ios) { te.style.width = "0px"; }
  12937. on(te, "input", function () {
  12938. if (ie && ie_version >= 9 && this$1.hasSelection) { this$1.hasSelection = null; }
  12939. input.poll();
  12940. });
  12941. on(te, "paste", function (e) {
  12942. if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
  12943. cm.state.pasteIncoming = +new Date;
  12944. input.fastPoll();
  12945. });
  12946. function prepareCopyCut(e) {
  12947. if (signalDOMEvent(cm, e)) { return }
  12948. if (cm.somethingSelected()) {
  12949. setLastCopied({lineWise: false, text: cm.getSelections()});
  12950. } else if (!cm.options.lineWiseCopyCut) {
  12951. return
  12952. } else {
  12953. var ranges = copyableRanges(cm);
  12954. setLastCopied({lineWise: true, text: ranges.text});
  12955. if (e.type == "cut") {
  12956. cm.setSelections(ranges.ranges, null, sel_dontScroll);
  12957. } else {
  12958. input.prevInput = "";
  12959. te.value = ranges.text.join("\n");
  12960. selectInput(te);
  12961. }
  12962. }
  12963. if (e.type == "cut") { cm.state.cutIncoming = +new Date; }
  12964. }
  12965. on(te, "cut", prepareCopyCut);
  12966. on(te, "copy", prepareCopyCut);
  12967. on(display.scroller, "paste", function (e) {
  12968. if (eventInWidget(display, e) || signalDOMEvent(cm, e)) { return }
  12969. if (!te.dispatchEvent) {
  12970. cm.state.pasteIncoming = +new Date;
  12971. input.focus();
  12972. return
  12973. }
  12974. // Pass the `paste` event to the textarea so it's handled by its event listener.
  12975. var event = new Event("paste");
  12976. event.clipboardData = e.clipboardData;
  12977. te.dispatchEvent(event);
  12978. });
  12979. // Prevent normal selection in the editor (we handle our own)
  12980. on(display.lineSpace, "selectstart", function (e) {
  12981. if (!eventInWidget(display, e)) { e_preventDefault(e); }
  12982. });
  12983. on(te, "compositionstart", function () {
  12984. var start = cm.getCursor("from");
  12985. if (input.composing) { input.composing.range.clear(); }
  12986. input.composing = {
  12987. start: start,
  12988. range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
  12989. };
  12990. });
  12991. on(te, "compositionend", function () {
  12992. if (input.composing) {
  12993. input.poll();
  12994. input.composing.range.clear();
  12995. input.composing = null;
  12996. }
  12997. });
  12998. };
  12999. TextareaInput.prototype.createField = function (_display) {
  13000. // Wraps and hides input textarea
  13001. this.wrapper = hiddenTextarea();
  13002. // The semihidden textarea that is focused when the editor is
  13003. // focused, and receives input.
  13004. this.textarea = this.wrapper.firstChild;
  13005. };
  13006. TextareaInput.prototype.screenReaderLabelChanged = function (label) {
  13007. // Label for screenreaders, accessibility
  13008. if(label) {
  13009. this.textarea.setAttribute('aria-label', label);
  13010. } else {
  13011. this.textarea.removeAttribute('aria-label');
  13012. }
  13013. };
  13014. TextareaInput.prototype.prepareSelection = function () {
  13015. // Redraw the selection and/or cursor
  13016. var cm = this.cm, display = cm.display, doc = cm.doc;
  13017. var result = prepareSelection(cm);
  13018. // Move the hidden textarea near the cursor to prevent scrolling artifacts
  13019. if (cm.options.moveInputWithCursor) {
  13020. var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
  13021. var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
  13022. result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
  13023. headPos.top + lineOff.top - wrapOff.top));
  13024. result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
  13025. headPos.left + lineOff.left - wrapOff.left));
  13026. }
  13027. return result
  13028. };
  13029. TextareaInput.prototype.showSelection = function (drawn) {
  13030. var cm = this.cm, display = cm.display;
  13031. removeChildrenAndAdd(display.cursorDiv, drawn.cursors);
  13032. removeChildrenAndAdd(display.selectionDiv, drawn.selection);
  13033. if (drawn.teTop != null) {
  13034. this.wrapper.style.top = drawn.teTop + "px";
  13035. this.wrapper.style.left = drawn.teLeft + "px";
  13036. }
  13037. };
  13038. // Reset the input to correspond to the selection (or to be empty,
  13039. // when not typing and nothing is selected)
  13040. TextareaInput.prototype.reset = function (typing) {
  13041. if (this.contextMenuPending || this.composing) { return }
  13042. var cm = this.cm;
  13043. if (cm.somethingSelected()) {
  13044. this.prevInput = "";
  13045. var content = cm.getSelection();
  13046. this.textarea.value = content;
  13047. if (cm.state.focused) { selectInput(this.textarea); }
  13048. if (ie && ie_version >= 9) { this.hasSelection = content; }
  13049. } else if (!typing) {
  13050. this.prevInput = this.textarea.value = "";
  13051. if (ie && ie_version >= 9) { this.hasSelection = null; }
  13052. }
  13053. };
  13054. TextareaInput.prototype.getField = function () { return this.textarea };
  13055. TextareaInput.prototype.supportsTouch = function () { return false };
  13056. TextareaInput.prototype.focus = function () {
  13057. if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
  13058. try { this.textarea.focus(); }
  13059. catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
  13060. }
  13061. };
  13062. TextareaInput.prototype.blur = function () { this.textarea.blur(); };
  13063. TextareaInput.prototype.resetPosition = function () {
  13064. this.wrapper.style.top = this.wrapper.style.left = 0;
  13065. };
  13066. TextareaInput.prototype.receivedFocus = function () { this.slowPoll(); };
  13067. // Poll for input changes, using the normal rate of polling. This
  13068. // runs as long as the editor is focused.
  13069. TextareaInput.prototype.slowPoll = function () {
  13070. var this$1 = this;
  13071. if (this.pollingFast) { return }
  13072. this.polling.set(this.cm.options.pollInterval, function () {
  13073. this$1.poll();
  13074. if (this$1.cm.state.focused) { this$1.slowPoll(); }
  13075. });
  13076. };
  13077. // When an event has just come in that is likely to add or change
  13078. // something in the input textarea, we poll faster, to ensure that
  13079. // the change appears on the screen quickly.
  13080. TextareaInput.prototype.fastPoll = function () {
  13081. var missed = false, input = this;
  13082. input.pollingFast = true;
  13083. function p() {
  13084. var changed = input.poll();
  13085. if (!changed && !missed) {missed = true; input.polling.set(60, p);}
  13086. else {input.pollingFast = false; input.slowPoll();}
  13087. }
  13088. input.polling.set(20, p);
  13089. };
  13090. // Read input from the textarea, and update the document to match.
  13091. // When something is selected, it is present in the textarea, and
  13092. // selected (unless it is huge, in which case a placeholder is
  13093. // used). When nothing is selected, the cursor sits after previously
  13094. // seen text (can be empty), which is stored in prevInput (we must
  13095. // not reset the textarea when typing, because that breaks IME).
  13096. TextareaInput.prototype.poll = function () {
  13097. var this$1 = this;
  13098. var cm = this.cm, input = this.textarea, prevInput = this.prevInput;
  13099. // Since this is called a *lot*, try to bail out as cheaply as
  13100. // possible when it is clear that nothing happened. hasSelection
  13101. // will be the case when there is a lot of text in the textarea,
  13102. // in which case reading its value would be expensive.
  13103. if (this.contextMenuPending || !cm.state.focused ||
  13104. (hasSelection(input) && !prevInput && !this.composing) ||
  13105. cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
  13106. { return false }
  13107. var text = input.value;
  13108. // If nothing changed, bail.
  13109. if (text == prevInput && !cm.somethingSelected()) { return false }
  13110. // Work around nonsensical selection resetting in IE9/10, and
  13111. // inexplicable appearance of private area unicode characters on
  13112. // some key combos in Mac (#2689).
  13113. if (ie && ie_version >= 9 && this.hasSelection === text ||
  13114. mac && /[\uf700-\uf7ff]/.test(text)) {
  13115. cm.display.input.reset();
  13116. return false
  13117. }
  13118. if (cm.doc.sel == cm.display.selForContextMenu) {
  13119. var first = text.charCodeAt(0);
  13120. if (first == 0x200b && !prevInput) { prevInput = "\u200b"; }
  13121. if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo") }
  13122. }
  13123. // Find the part of the input that is actually new
  13124. var same = 0, l = Math.min(prevInput.length, text.length);
  13125. while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) { ++same; }
  13126. runInOp(cm, function () {
  13127. applyTextInput(cm, text.slice(same), prevInput.length - same,
  13128. null, this$1.composing ? "*compose" : null);
  13129. // Don't leave long text in the textarea, since it makes further polling slow
  13130. if (text.length > 1000 || text.indexOf("\n") > -1) { input.value = this$1.prevInput = ""; }
  13131. else { this$1.prevInput = text; }
  13132. if (this$1.composing) {
  13133. this$1.composing.range.clear();
  13134. this$1.composing.range = cm.markText(this$1.composing.start, cm.getCursor("to"),
  13135. {className: "CodeMirror-composing"});
  13136. }
  13137. });
  13138. return true
  13139. };
  13140. TextareaInput.prototype.ensurePolled = function () {
  13141. if (this.pollingFast && this.poll()) { this.pollingFast = false; }
  13142. };
  13143. TextareaInput.prototype.onKeyPress = function () {
  13144. if (ie && ie_version >= 9) { this.hasSelection = null; }
  13145. this.fastPoll();
  13146. };
  13147. TextareaInput.prototype.onContextMenu = function (e) {
  13148. var input = this, cm = input.cm, display = cm.display, te = input.textarea;
  13149. if (input.contextMenuPending) { input.contextMenuPending(); }
  13150. var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
  13151. if (!pos || presto) { return } // Opera is difficult.
  13152. // Reset the current text selection only if the click is done outside of the selection
  13153. // and 'resetSelectionOnContextMenu' option is true.
  13154. var reset = cm.options.resetSelectionOnContextMenu;
  13155. if (reset && cm.doc.sel.contains(pos) == -1)
  13156. { operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll); }
  13157. var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText;
  13158. var wrapperBox = input.wrapper.offsetParent.getBoundingClientRect();
  13159. input.wrapper.style.cssText = "position: static";
  13160. te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
  13161. var oldScrollY;
  13162. if (webkit) { oldScrollY = window.scrollY; } // Work around Chrome issue (#2712)
  13163. display.input.focus();
  13164. if (webkit) { window.scrollTo(null, oldScrollY); }
  13165. display.input.reset();
  13166. // Adds "Select all" to context menu in FF
  13167. if (!cm.somethingSelected()) { te.value = input.prevInput = " "; }
  13168. input.contextMenuPending = rehide;
  13169. display.selForContextMenu = cm.doc.sel;
  13170. clearTimeout(display.detectingSelectAll);
  13171. // Select-all will be greyed out if there's nothing to select, so
  13172. // this adds a zero-width space so that we can later check whether
  13173. // it got selected.
  13174. function prepareSelectAllHack() {
  13175. if (te.selectionStart != null) {
  13176. var selected = cm.somethingSelected();
  13177. var extval = "\u200b" + (selected ? te.value : "");
  13178. te.value = "\u21da"; // Used to catch context-menu undo
  13179. te.value = extval;
  13180. input.prevInput = selected ? "" : "\u200b";
  13181. te.selectionStart = 1; te.selectionEnd = extval.length;
  13182. // Re-set this, in case some other handler touched the
  13183. // selection in the meantime.
  13184. display.selForContextMenu = cm.doc.sel;
  13185. }
  13186. }
  13187. function rehide() {
  13188. if (input.contextMenuPending != rehide) { return }
  13189. input.contextMenuPending = false;
  13190. input.wrapper.style.cssText = oldWrapperCSS;
  13191. te.style.cssText = oldCSS;
  13192. if (ie && ie_version < 9) { display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos); }
  13193. // Try to detect the user choosing select-all
  13194. if (te.selectionStart != null) {
  13195. if (!ie || (ie && ie_version < 9)) { prepareSelectAllHack(); }
  13196. var i = 0, poll = function () {
  13197. if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
  13198. te.selectionEnd > 0 && input.prevInput == "\u200b") {
  13199. operation(cm, selectAll)(cm);
  13200. } else if (i++ < 10) {
  13201. display.detectingSelectAll = setTimeout(poll, 500);
  13202. } else {
  13203. display.selForContextMenu = null;
  13204. display.input.reset();
  13205. }
  13206. };
  13207. display.detectingSelectAll = setTimeout(poll, 200);
  13208. }
  13209. }
  13210. if (ie && ie_version >= 9) { prepareSelectAllHack(); }
  13211. if (captureRightClick) {
  13212. e_stop(e);
  13213. var mouseup = function () {
  13214. off(window, "mouseup", mouseup);
  13215. setTimeout(rehide, 20);
  13216. };
  13217. on(window, "mouseup", mouseup);
  13218. } else {
  13219. setTimeout(rehide, 50);
  13220. }
  13221. };
  13222. TextareaInput.prototype.readOnlyChanged = function (val) {
  13223. if (!val) { this.reset(); }
  13224. this.textarea.disabled = val == "nocursor";
  13225. this.textarea.readOnly = !!val;
  13226. };
  13227. TextareaInput.prototype.setUneditable = function () {};
  13228. TextareaInput.prototype.needsContentAttribute = false;
  13229. function fromTextArea(textarea, options) {
  13230. options = options ? copyObj(options) : {};
  13231. options.value = textarea.value;
  13232. if (!options.tabindex && textarea.tabIndex)
  13233. { options.tabindex = textarea.tabIndex; }
  13234. if (!options.placeholder && textarea.placeholder)
  13235. { options.placeholder = textarea.placeholder; }
  13236. // Set autofocus to true if this textarea is focused, or if it has
  13237. // autofocus and no other element is focused.
  13238. if (options.autofocus == null) {
  13239. var hasFocus = activeElt();
  13240. options.autofocus = hasFocus == textarea ||
  13241. textarea.getAttribute("autofocus") != null && hasFocus == document.body;
  13242. }
  13243. function save() {textarea.value = cm.getValue();}
  13244. var realSubmit;
  13245. if (textarea.form) {
  13246. on(textarea.form, "submit", save);
  13247. // Deplorable hack to make the submit method do the right thing.
  13248. if (!options.leaveSubmitMethodAlone) {
  13249. var form = textarea.form;
  13250. realSubmit = form.submit;
  13251. try {
  13252. var wrappedSubmit = form.submit = function () {
  13253. save();
  13254. form.submit = realSubmit;
  13255. form.submit();
  13256. form.submit = wrappedSubmit;
  13257. };
  13258. } catch(e) {}
  13259. }
  13260. }
  13261. options.finishInit = function (cm) {
  13262. cm.save = save;
  13263. cm.getTextArea = function () { return textarea; };
  13264. cm.toTextArea = function () {
  13265. cm.toTextArea = isNaN; // Prevent this from being ran twice
  13266. save();
  13267. textarea.parentNode.removeChild(cm.getWrapperElement());
  13268. textarea.style.display = "";
  13269. if (textarea.form) {
  13270. off(textarea.form, "submit", save);
  13271. if (!options.leaveSubmitMethodAlone && typeof textarea.form.submit == "function")
  13272. { textarea.form.submit = realSubmit; }
  13273. }
  13274. };
  13275. };
  13276. textarea.style.display = "none";
  13277. var cm = CodeMirror(function (node) { return textarea.parentNode.insertBefore(node, textarea.nextSibling); },
  13278. options);
  13279. return cm
  13280. }
  13281. function addLegacyProps(CodeMirror) {
  13282. CodeMirror.off = off;
  13283. CodeMirror.on = on;
  13284. CodeMirror.wheelEventPixels = wheelEventPixels;
  13285. CodeMirror.Doc = Doc;
  13286. CodeMirror.splitLines = splitLinesAuto;
  13287. CodeMirror.countColumn = countColumn;
  13288. CodeMirror.findColumn = findColumn;
  13289. CodeMirror.isWordChar = isWordCharBasic;
  13290. CodeMirror.Pass = Pass;
  13291. CodeMirror.signal = signal;
  13292. CodeMirror.Line = Line;
  13293. CodeMirror.changeEnd = changeEnd;
  13294. CodeMirror.scrollbarModel = scrollbarModel;
  13295. CodeMirror.Pos = Pos;
  13296. CodeMirror.cmpPos = cmp;
  13297. CodeMirror.modes = modes;
  13298. CodeMirror.mimeModes = mimeModes;
  13299. CodeMirror.resolveMode = resolveMode;
  13300. CodeMirror.getMode = getMode;
  13301. CodeMirror.modeExtensions = modeExtensions;
  13302. CodeMirror.extendMode = extendMode;
  13303. CodeMirror.copyState = copyState;
  13304. CodeMirror.startState = startState;
  13305. CodeMirror.innerMode = innerMode;
  13306. CodeMirror.commands = commands;
  13307. CodeMirror.keyMap = keyMap;
  13308. CodeMirror.keyName = keyName;
  13309. CodeMirror.isModifierKey = isModifierKey;
  13310. CodeMirror.lookupKey = lookupKey;
  13311. CodeMirror.normalizeKeyMap = normalizeKeyMap;
  13312. CodeMirror.StringStream = StringStream;
  13313. CodeMirror.SharedTextMarker = SharedTextMarker;
  13314. CodeMirror.TextMarker = TextMarker;
  13315. CodeMirror.LineWidget = LineWidget;
  13316. CodeMirror.e_preventDefault = e_preventDefault;
  13317. CodeMirror.e_stopPropagation = e_stopPropagation;
  13318. CodeMirror.e_stop = e_stop;
  13319. CodeMirror.addClass = addClass;
  13320. CodeMirror.contains = contains;
  13321. CodeMirror.rmClass = rmClass;
  13322. CodeMirror.keyNames = keyNames;
  13323. }
  13324. // EDITOR CONSTRUCTOR
  13325. defineOptions(CodeMirror);
  13326. addEditorMethods(CodeMirror);
  13327. // Set up methods on CodeMirror's prototype to redirect to the editor's document.
  13328. var dontDelegate = "iter insert remove copy getEditor constructor".split(" ");
  13329. for (var prop in Doc.prototype) { if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
  13330. { CodeMirror.prototype[prop] = (function(method) {
  13331. return function() {return method.apply(this.doc, arguments)}
  13332. })(Doc.prototype[prop]); } }
  13333. eventMixin(Doc);
  13334. CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput};
  13335. // Extra arguments are stored as the mode's dependencies, which is
  13336. // used by (legacy) mechanisms like loadmode.js to automatically
  13337. // load a mode. (Preferred mechanism is the require/define calls.)
  13338. CodeMirror.defineMode = function(name/*, mode, …*/) {
  13339. if (!CodeMirror.defaults.mode && name != "null") { CodeMirror.defaults.mode = name; }
  13340. defineMode.apply(this, arguments);
  13341. };
  13342. CodeMirror.defineMIME = defineMIME;
  13343. // Minimal default mode.
  13344. CodeMirror.defineMode("null", function () { return ({token: function (stream) { return stream.skipToEnd(); }}); });
  13345. CodeMirror.defineMIME("text/plain", "null");
  13346. // EXTENSIONS
  13347. CodeMirror.defineExtension = function (name, func) {
  13348. CodeMirror.prototype[name] = func;
  13349. };
  13350. CodeMirror.defineDocExtension = function (name, func) {
  13351. Doc.prototype[name] = func;
  13352. };
  13353. CodeMirror.fromTextArea = fromTextArea;
  13354. addLegacyProps(CodeMirror);
  13355. CodeMirror.version = "5.58.2";
  13356. return CodeMirror;
  13357. })));
  13358. });
  13359. var xml = createCommonjsModule(function (module, exports) {
  13360. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  13361. // Distributed under an MIT license: https://codemirror.net/LICENSE
  13362. (function(mod) {
  13363. mod(codemirror);
  13364. })(function(CodeMirror) {
  13365. var htmlConfig = {
  13366. autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
  13367. 'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
  13368. 'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
  13369. 'track': true, 'wbr': true, 'menuitem': true},
  13370. implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
  13371. 'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
  13372. 'th': true, 'tr': true},
  13373. contextGrabbers: {
  13374. 'dd': {'dd': true, 'dt': true},
  13375. 'dt': {'dd': true, 'dt': true},
  13376. 'li': {'li': true},
  13377. 'option': {'option': true, 'optgroup': true},
  13378. 'optgroup': {'optgroup': true},
  13379. 'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
  13380. 'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
  13381. 'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
  13382. 'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
  13383. 'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
  13384. 'rp': {'rp': true, 'rt': true},
  13385. 'rt': {'rp': true, 'rt': true},
  13386. 'tbody': {'tbody': true, 'tfoot': true},
  13387. 'td': {'td': true, 'th': true},
  13388. 'tfoot': {'tbody': true},
  13389. 'th': {'td': true, 'th': true},
  13390. 'thead': {'tbody': true, 'tfoot': true},
  13391. 'tr': {'tr': true}
  13392. },
  13393. doNotIndent: {"pre": true},
  13394. allowUnquoted: true,
  13395. allowMissing: true,
  13396. caseFold: true
  13397. };
  13398. var xmlConfig = {
  13399. autoSelfClosers: {},
  13400. implicitlyClosed: {},
  13401. contextGrabbers: {},
  13402. doNotIndent: {},
  13403. allowUnquoted: false,
  13404. allowMissing: false,
  13405. allowMissingTagName: false,
  13406. caseFold: false
  13407. };
  13408. CodeMirror.defineMode("xml", function(editorConf, config_) {
  13409. var indentUnit = editorConf.indentUnit;
  13410. var config = {};
  13411. var defaults = config_.htmlMode ? htmlConfig : xmlConfig;
  13412. for (var prop in defaults) config[prop] = defaults[prop];
  13413. for (var prop in config_) config[prop] = config_[prop];
  13414. // Return variables for tokenizers
  13415. var type, setStyle;
  13416. function inText(stream, state) {
  13417. function chain(parser) {
  13418. state.tokenize = parser;
  13419. return parser(stream, state);
  13420. }
  13421. var ch = stream.next();
  13422. if (ch == "<") {
  13423. if (stream.eat("!")) {
  13424. if (stream.eat("[")) {
  13425. if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
  13426. else return null;
  13427. } else if (stream.match("--")) {
  13428. return chain(inBlock("comment", "-->"));
  13429. } else if (stream.match("DOCTYPE", true, true)) {
  13430. stream.eatWhile(/[\w\._\-]/);
  13431. return chain(doctype(1));
  13432. } else {
  13433. return null;
  13434. }
  13435. } else if (stream.eat("?")) {
  13436. stream.eatWhile(/[\w\._\-]/);
  13437. state.tokenize = inBlock("meta", "?>");
  13438. return "meta";
  13439. } else {
  13440. type = stream.eat("/") ? "closeTag" : "openTag";
  13441. state.tokenize = inTag;
  13442. return "tag bracket";
  13443. }
  13444. } else if (ch == "&") {
  13445. var ok;
  13446. if (stream.eat("#")) {
  13447. if (stream.eat("x")) {
  13448. ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
  13449. } else {
  13450. ok = stream.eatWhile(/[\d]/) && stream.eat(";");
  13451. }
  13452. } else {
  13453. ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
  13454. }
  13455. return ok ? "atom" : "error";
  13456. } else {
  13457. stream.eatWhile(/[^&<]/);
  13458. return null;
  13459. }
  13460. }
  13461. inText.isInText = true;
  13462. function inTag(stream, state) {
  13463. var ch = stream.next();
  13464. if (ch == ">" || (ch == "/" && stream.eat(">"))) {
  13465. state.tokenize = inText;
  13466. type = ch == ">" ? "endTag" : "selfcloseTag";
  13467. return "tag bracket";
  13468. } else if (ch == "=") {
  13469. type = "equals";
  13470. return null;
  13471. } else if (ch == "<") {
  13472. state.tokenize = inText;
  13473. state.state = baseState;
  13474. state.tagName = state.tagStart = null;
  13475. var next = state.tokenize(stream, state);
  13476. return next ? next + " tag error" : "tag error";
  13477. } else if (/[\'\"]/.test(ch)) {
  13478. state.tokenize = inAttribute(ch);
  13479. state.stringStartCol = stream.column();
  13480. return state.tokenize(stream, state);
  13481. } else {
  13482. stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);
  13483. return "word";
  13484. }
  13485. }
  13486. function inAttribute(quote) {
  13487. var closure = function(stream, state) {
  13488. while (!stream.eol()) {
  13489. if (stream.next() == quote) {
  13490. state.tokenize = inTag;
  13491. break;
  13492. }
  13493. }
  13494. return "string";
  13495. };
  13496. closure.isInAttribute = true;
  13497. return closure;
  13498. }
  13499. function inBlock(style, terminator) {
  13500. return function(stream, state) {
  13501. while (!stream.eol()) {
  13502. if (stream.match(terminator)) {
  13503. state.tokenize = inText;
  13504. break;
  13505. }
  13506. stream.next();
  13507. }
  13508. return style;
  13509. }
  13510. }
  13511. function doctype(depth) {
  13512. return function(stream, state) {
  13513. var ch;
  13514. while ((ch = stream.next()) != null) {
  13515. if (ch == "<") {
  13516. state.tokenize = doctype(depth + 1);
  13517. return state.tokenize(stream, state);
  13518. } else if (ch == ">") {
  13519. if (depth == 1) {
  13520. state.tokenize = inText;
  13521. break;
  13522. } else {
  13523. state.tokenize = doctype(depth - 1);
  13524. return state.tokenize(stream, state);
  13525. }
  13526. }
  13527. }
  13528. return "meta";
  13529. };
  13530. }
  13531. function Context(state, tagName, startOfLine) {
  13532. this.prev = state.context;
  13533. this.tagName = tagName;
  13534. this.indent = state.indented;
  13535. this.startOfLine = startOfLine;
  13536. if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
  13537. this.noIndent = true;
  13538. }
  13539. function popContext(state) {
  13540. if (state.context) state.context = state.context.prev;
  13541. }
  13542. function maybePopContext(state, nextTagName) {
  13543. var parentTagName;
  13544. while (true) {
  13545. if (!state.context) {
  13546. return;
  13547. }
  13548. parentTagName = state.context.tagName;
  13549. if (!config.contextGrabbers.hasOwnProperty(parentTagName) ||
  13550. !config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
  13551. return;
  13552. }
  13553. popContext(state);
  13554. }
  13555. }
  13556. function baseState(type, stream, state) {
  13557. if (type == "openTag") {
  13558. state.tagStart = stream.column();
  13559. return tagNameState;
  13560. } else if (type == "closeTag") {
  13561. return closeTagNameState;
  13562. } else {
  13563. return baseState;
  13564. }
  13565. }
  13566. function tagNameState(type, stream, state) {
  13567. if (type == "word") {
  13568. state.tagName = stream.current();
  13569. setStyle = "tag";
  13570. return attrState;
  13571. } else if (config.allowMissingTagName && type == "endTag") {
  13572. setStyle = "tag bracket";
  13573. return attrState(type, stream, state);
  13574. } else {
  13575. setStyle = "error";
  13576. return tagNameState;
  13577. }
  13578. }
  13579. function closeTagNameState(type, stream, state) {
  13580. if (type == "word") {
  13581. var tagName = stream.current();
  13582. if (state.context && state.context.tagName != tagName &&
  13583. config.implicitlyClosed.hasOwnProperty(state.context.tagName))
  13584. popContext(state);
  13585. if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) {
  13586. setStyle = "tag";
  13587. return closeState;
  13588. } else {
  13589. setStyle = "tag error";
  13590. return closeStateErr;
  13591. }
  13592. } else if (config.allowMissingTagName && type == "endTag") {
  13593. setStyle = "tag bracket";
  13594. return closeState(type, stream, state);
  13595. } else {
  13596. setStyle = "error";
  13597. return closeStateErr;
  13598. }
  13599. }
  13600. function closeState(type, _stream, state) {
  13601. if (type != "endTag") {
  13602. setStyle = "error";
  13603. return closeState;
  13604. }
  13605. popContext(state);
  13606. return baseState;
  13607. }
  13608. function closeStateErr(type, stream, state) {
  13609. setStyle = "error";
  13610. return closeState(type, stream, state);
  13611. }
  13612. function attrState(type, _stream, state) {
  13613. if (type == "word") {
  13614. setStyle = "attribute";
  13615. return attrEqState;
  13616. } else if (type == "endTag" || type == "selfcloseTag") {
  13617. var tagName = state.tagName, tagStart = state.tagStart;
  13618. state.tagName = state.tagStart = null;
  13619. if (type == "selfcloseTag" ||
  13620. config.autoSelfClosers.hasOwnProperty(tagName)) {
  13621. maybePopContext(state, tagName);
  13622. } else {
  13623. maybePopContext(state, tagName);
  13624. state.context = new Context(state, tagName, tagStart == state.indented);
  13625. }
  13626. return baseState;
  13627. }
  13628. setStyle = "error";
  13629. return attrState;
  13630. }
  13631. function attrEqState(type, stream, state) {
  13632. if (type == "equals") return attrValueState;
  13633. if (!config.allowMissing) setStyle = "error";
  13634. return attrState(type, stream, state);
  13635. }
  13636. function attrValueState(type, stream, state) {
  13637. if (type == "string") return attrContinuedState;
  13638. if (type == "word" && config.allowUnquoted) {setStyle = "string"; return attrState;}
  13639. setStyle = "error";
  13640. return attrState(type, stream, state);
  13641. }
  13642. function attrContinuedState(type, stream, state) {
  13643. if (type == "string") return attrContinuedState;
  13644. return attrState(type, stream, state);
  13645. }
  13646. return {
  13647. startState: function(baseIndent) {
  13648. var state = {tokenize: inText,
  13649. state: baseState,
  13650. indented: baseIndent || 0,
  13651. tagName: null, tagStart: null,
  13652. context: null};
  13653. if (baseIndent != null) state.baseIndent = baseIndent;
  13654. return state
  13655. },
  13656. token: function(stream, state) {
  13657. if (!state.tagName && stream.sol())
  13658. state.indented = stream.indentation();
  13659. if (stream.eatSpace()) return null;
  13660. type = null;
  13661. var style = state.tokenize(stream, state);
  13662. if ((style || type) && style != "comment") {
  13663. setStyle = null;
  13664. state.state = state.state(type || style, stream, state);
  13665. if (setStyle)
  13666. style = setStyle == "error" ? style + " error" : setStyle;
  13667. }
  13668. return style;
  13669. },
  13670. indent: function(state, textAfter, fullLine) {
  13671. var context = state.context;
  13672. // Indent multi-line strings (e.g. css).
  13673. if (state.tokenize.isInAttribute) {
  13674. if (state.tagStart == state.indented)
  13675. return state.stringStartCol + 1;
  13676. else
  13677. return state.indented + indentUnit;
  13678. }
  13679. if (context && context.noIndent) return CodeMirror.Pass;
  13680. if (state.tokenize != inTag && state.tokenize != inText)
  13681. return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
  13682. // Indent the starts of attribute names.
  13683. if (state.tagName) {
  13684. if (config.multilineTagIndentPastTag !== false)
  13685. return state.tagStart + state.tagName.length + 2;
  13686. else
  13687. return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1);
  13688. }
  13689. if (config.alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
  13690. var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
  13691. if (tagAfter && tagAfter[1]) { // Closing tag spotted
  13692. while (context) {
  13693. if (context.tagName == tagAfter[2]) {
  13694. context = context.prev;
  13695. break;
  13696. } else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) {
  13697. context = context.prev;
  13698. } else {
  13699. break;
  13700. }
  13701. }
  13702. } else if (tagAfter) { // Opening tag spotted
  13703. while (context) {
  13704. var grabbers = config.contextGrabbers[context.tagName];
  13705. if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
  13706. context = context.prev;
  13707. else
  13708. break;
  13709. }
  13710. }
  13711. while (context && context.prev && !context.startOfLine)
  13712. context = context.prev;
  13713. if (context) return context.indent + indentUnit;
  13714. else return state.baseIndent || 0;
  13715. },
  13716. electricInput: /<\/[\s\w:]+>$/,
  13717. blockCommentStart: "<!--",
  13718. blockCommentEnd: "-->",
  13719. configuration: config.htmlMode ? "html" : "xml",
  13720. helperType: config.htmlMode ? "html" : "xml",
  13721. skipAttribute: function(state) {
  13722. if (state.state == attrValueState)
  13723. state.state = attrState;
  13724. },
  13725. xmlCurrentTag: function(state) {
  13726. return state.tagName ? {name: state.tagName, close: state.type == "closeTag"} : null
  13727. },
  13728. xmlCurrentContext: function(state) {
  13729. var context = [];
  13730. for (var cx = state.context; cx; cx = cx.prev)
  13731. if (cx.tagName) context.push(cx.tagName);
  13732. return context.reverse()
  13733. }
  13734. };
  13735. });
  13736. CodeMirror.defineMIME("text/xml", "xml");
  13737. CodeMirror.defineMIME("application/xml", "xml");
  13738. if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
  13739. CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
  13740. });
  13741. });
  13742. var meta = createCommonjsModule(function (module, exports) {
  13743. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  13744. // Distributed under an MIT license: https://codemirror.net/LICENSE
  13745. (function(mod) {
  13746. mod(codemirror);
  13747. })(function(CodeMirror) {
  13748. CodeMirror.modeInfo = [
  13749. {name: "APL", mime: "text/apl", mode: "apl", ext: ["dyalog", "apl"]},
  13750. {name: "PGP", mimes: ["application/pgp", "application/pgp-encrypted", "application/pgp-keys", "application/pgp-signature"], mode: "asciiarmor", ext: ["asc", "pgp", "sig"]},
  13751. {name: "ASN.1", mime: "text/x-ttcn-asn", mode: "asn.1", ext: ["asn", "asn1"]},
  13752. {name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk", file: /^extensions\.conf$/i},
  13753. {name: "Brainfuck", mime: "text/x-brainfuck", mode: "brainfuck", ext: ["b", "bf"]},
  13754. {name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h", "ino"]},
  13755. {name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"]},
  13756. {name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]},
  13757. {name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp", "cs"]},
  13758. {name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj", "cljc", "cljx"]},
  13759. {name: "ClojureScript", mime: "text/x-clojurescript", mode: "clojure", ext: ["cljs"]},
  13760. {name: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"]},
  13761. {name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists\.txt$/},
  13762. {name: "CoffeeScript", mimes: ["application/vnd.coffeescript", "text/coffeescript", "text/x-coffeescript"], mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]},
  13763. {name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]},
  13764. {name: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"]},
  13765. {name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]},
  13766. {name: "Crystal", mime: "text/x-crystal", mode: "crystal", ext: ["cr"]},
  13767. {name: "CSS", mime: "text/css", mode: "css", ext: ["css"]},
  13768. {name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"]},
  13769. {name: "D", mime: "text/x-d", mode: "d", ext: ["d"]},
  13770. {name: "Dart", mimes: ["application/dart", "text/x-dart"], mode: "dart", ext: ["dart"]},
  13771. {name: "diff", mime: "text/x-diff", mode: "diff", ext: ["diff", "patch"]},
  13772. {name: "Django", mime: "text/x-django", mode: "django"},
  13773. {name: "Dockerfile", mime: "text/x-dockerfile", mode: "dockerfile", file: /^Dockerfile$/},
  13774. {name: "DTD", mime: "application/xml-dtd", mode: "dtd", ext: ["dtd"]},
  13775. {name: "Dylan", mime: "text/x-dylan", mode: "dylan", ext: ["dylan", "dyl", "intr"]},
  13776. {name: "EBNF", mime: "text/x-ebnf", mode: "ebnf"},
  13777. {name: "ECL", mime: "text/x-ecl", mode: "ecl", ext: ["ecl"]},
  13778. {name: "edn", mime: "application/edn", mode: "clojure", ext: ["edn"]},
  13779. {name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel", ext: ["e"]},
  13780. {name: "Elm", mime: "text/x-elm", mode: "elm", ext: ["elm"]},
  13781. {name: "Embedded Javascript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]},
  13782. {name: "Embedded Ruby", mime: "application/x-erb", mode: "htmlembedded", ext: ["erb"]},
  13783. {name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]},
  13784. {name: "Esper", mime: "text/x-esper", mode: "sql"},
  13785. {name: "Factor", mime: "text/x-factor", mode: "factor", ext: ["factor"]},
  13786. {name: "FCL", mime: "text/x-fcl", mode: "fcl"},
  13787. {name: "Forth", mime: "text/x-forth", mode: "forth", ext: ["forth", "fth", "4th"]},
  13788. {name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90", "f95"]},
  13789. {name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]},
  13790. {name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]},
  13791. {name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
  13792. {name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history)\.md$/i},
  13793. {name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]},
  13794. {name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"], file: /^Jenkinsfile$/},
  13795. {name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
  13796. {name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]},
  13797. {name: "Haskell (Literate)", mime: "text/x-literate-haskell", mode: "haskell-literate", ext: ["lhs"]},
  13798. {name: "Haxe", mime: "text/x-haxe", mode: "haxe", ext: ["hx"]},
  13799. {name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"]},
  13800. {name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"], alias: ["asp", "aspx"]},
  13801. {name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm", "handlebars", "hbs"], alias: ["xhtml"]},
  13802. {name: "HTTP", mime: "message/http", mode: "http"},
  13803. {name: "IDL", mime: "text/x-idl", mode: "idl", ext: ["pro"]},
  13804. {name: "Pug", mime: "text/x-pug", mode: "pug", ext: ["jade", "pug"], alias: ["jade"]},
  13805. {name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]},
  13806. {name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]},
  13807. {name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"],
  13808. mode: "javascript", ext: ["js"], alias: ["ecmascript", "js", "node"]},
  13809. {name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"]},
  13810. {name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]},
  13811. {name: "JSX", mime: "text/jsx", mode: "jsx", ext: ["jsx"]},
  13812. {name: "Jinja2", mime: "text/jinja2", mode: "jinja2", ext: ["j2", "jinja", "jinja2"]},
  13813. {name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]},
  13814. {name: "Kotlin", mime: "text/x-kotlin", mode: "clike", ext: ["kt"]},
  13815. {name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"]},
  13816. {name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"], alias: ["ls"]},
  13817. {name: "Lua", mime: "text/x-lua", mode: "lua", ext: ["lua"]},
  13818. {name: "Markdown", mime: "text/x-markdown", mode: "markdown", ext: ["markdown", "md", "mkd"]},
  13819. {name: "mIRC", mime: "text/mirc", mode: "mirc"},
  13820. {name: "MariaDB SQL", mime: "text/x-mariadb", mode: "sql"},
  13821. {name: "Mathematica", mime: "text/x-mathematica", mode: "mathematica", ext: ["m", "nb", "wl", "wls"]},
  13822. {name: "Modelica", mime: "text/x-modelica", mode: "modelica", ext: ["mo"]},
  13823. {name: "MUMPS", mime: "text/x-mumps", mode: "mumps", ext: ["mps"]},
  13824. {name: "MS SQL", mime: "text/x-mssql", mode: "sql"},
  13825. {name: "mbox", mime: "application/mbox", mode: "mbox", ext: ["mbox"]},
  13826. {name: "MySQL", mime: "text/x-mysql", mode: "sql"},
  13827. {name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx", file: /nginx.*\.conf$/i},
  13828. {name: "NSIS", mime: "text/x-nsis", mode: "nsis", ext: ["nsh", "nsi"]},
  13829. {name: "NTriples", mimes: ["application/n-triples", "application/n-quads", "text/n-triples"],
  13830. mode: "ntriples", ext: ["nt", "nq"]},
  13831. {name: "Objective-C", mime: "text/x-objectivec", mode: "clike", ext: ["m"], alias: ["objective-c", "objc"]},
  13832. {name: "Objective-C++", mime: "text/x-objectivec++", mode: "clike", ext: ["mm"], alias: ["objective-c++", "objc++"]},
  13833. {name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"]},
  13834. {name: "Octave", mime: "text/x-octave", mode: "octave", ext: ["m"]},
  13835. {name: "Oz", mime: "text/x-oz", mode: "oz", ext: ["oz"]},
  13836. {name: "Pascal", mime: "text/x-pascal", mode: "pascal", ext: ["p", "pas"]},
  13837. {name: "PEG.js", mime: "null", mode: "pegjs", ext: ["jsonld"]},
  13838. {name: "Perl", mime: "text/x-perl", mode: "perl", ext: ["pl", "pm"]},
  13839. {name: "PHP", mimes: ["text/x-php", "application/x-httpd-php", "application/x-httpd-php-open"], mode: "php", ext: ["php", "php3", "php4", "php5", "php7", "phtml"]},
  13840. {name: "Pig", mime: "text/x-pig", mode: "pig", ext: ["pig"]},
  13841. {name: "Plain Text", mime: "text/plain", mode: "null", ext: ["txt", "text", "conf", "def", "list", "log"]},
  13842. {name: "PLSQL", mime: "text/x-plsql", mode: "sql", ext: ["pls"]},
  13843. {name: "PostgreSQL", mime: "text/x-pgsql", mode: "sql"},
  13844. {name: "PowerShell", mime: "application/x-powershell", mode: "powershell", ext: ["ps1", "psd1", "psm1"]},
  13845. {name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"], alias: ["ini", "properties"]},
  13846. {name: "ProtoBuf", mime: "text/x-protobuf", mode: "protobuf", ext: ["proto"]},
  13847. {name: "Python", mime: "text/x-python", mode: "python", ext: ["BUILD", "bzl", "py", "pyw"], file: /^(BUCK|BUILD)$/},
  13848. {name: "Puppet", mime: "text/x-puppet", mode: "puppet", ext: ["pp"]},
  13849. {name: "Q", mime: "text/x-q", mode: "q", ext: ["q"]},
  13850. {name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r", "R"], alias: ["rscript"]},
  13851. {name: "reStructuredText", mime: "text/x-rst", mode: "rst", ext: ["rst"], alias: ["rst"]},
  13852. {name: "RPM Changes", mime: "text/x-rpm-changes", mode: "rpm"},
  13853. {name: "RPM Spec", mime: "text/x-rpm-spec", mode: "rpm", ext: ["spec"]},
  13854. {name: "Ruby", mime: "text/x-ruby", mode: "ruby", ext: ["rb"], alias: ["jruby", "macruby", "rake", "rb", "rbx"]},
  13855. {name: "Rust", mime: "text/x-rustsrc", mode: "rust", ext: ["rs"]},
  13856. {name: "SAS", mime: "text/x-sas", mode: "sas", ext: ["sas"]},
  13857. {name: "Sass", mime: "text/x-sass", mode: "sass", ext: ["sass"]},
  13858. {name: "Scala", mime: "text/x-scala", mode: "clike", ext: ["scala"]},
  13859. {name: "Scheme", mime: "text/x-scheme", mode: "scheme", ext: ["scm", "ss"]},
  13860. {name: "SCSS", mime: "text/x-scss", mode: "css", ext: ["scss"]},
  13861. {name: "Shell", mimes: ["text/x-sh", "application/x-sh"], mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"], file: /^PKGBUILD$/},
  13862. {name: "Sieve", mime: "application/sieve", mode: "sieve", ext: ["siv", "sieve"]},
  13863. {name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim", ext: ["slim"]},
  13864. {name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk", ext: ["st"]},
  13865. {name: "Smarty", mime: "text/x-smarty", mode: "smarty", ext: ["tpl"]},
  13866. {name: "Solr", mime: "text/x-solr", mode: "solr"},
  13867. {name: "SML", mime: "text/x-sml", mode: "mllike", ext: ["sml", "sig", "fun", "smackspec"]},
  13868. {name: "Soy", mime: "text/x-soy", mode: "soy", ext: ["soy"], alias: ["closure template"]},
  13869. {name: "SPARQL", mime: "application/sparql-query", mode: "sparql", ext: ["rq", "sparql"], alias: ["sparul"]},
  13870. {name: "Spreadsheet", mime: "text/x-spreadsheet", mode: "spreadsheet", alias: ["excel", "formula"]},
  13871. {name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]},
  13872. {name: "SQLite", mime: "text/x-sqlite", mode: "sql"},
  13873. {name: "Squirrel", mime: "text/x-squirrel", mode: "clike", ext: ["nut"]},
  13874. {name: "Stylus", mime: "text/x-styl", mode: "stylus", ext: ["styl"]},
  13875. {name: "Swift", mime: "text/x-swift", mode: "swift", ext: ["swift"]},
  13876. {name: "sTeX", mime: "text/x-stex", mode: "stex"},
  13877. {name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx", "tex"], alias: ["tex"]},
  13878. {name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v", "sv", "svh"]},
  13879. {name: "Tcl", mime: "text/x-tcl", mode: "tcl", ext: ["tcl"]},
  13880. {name: "Textile", mime: "text/x-textile", mode: "textile", ext: ["textile"]},
  13881. {name: "TiddlyWiki", mime: "text/x-tiddlywiki", mode: "tiddlywiki"},
  13882. {name: "Tiki wiki", mime: "text/tiki", mode: "tiki"},
  13883. {name: "TOML", mime: "text/x-toml", mode: "toml", ext: ["toml"]},
  13884. {name: "Tornado", mime: "text/x-tornado", mode: "tornado"},
  13885. {name: "troff", mime: "text/troff", mode: "troff", ext: ["1", "2", "3", "4", "5", "6", "7", "8", "9"]},
  13886. {name: "TTCN", mime: "text/x-ttcn", mode: "ttcn", ext: ["ttcn", "ttcn3", "ttcnpp"]},
  13887. {name: "TTCN_CFG", mime: "text/x-ttcn-cfg", mode: "ttcn-cfg", ext: ["cfg"]},
  13888. {name: "Turtle", mime: "text/turtle", mode: "turtle", ext: ["ttl"]},
  13889. {name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"], alias: ["ts"]},
  13890. {name: "TypeScript-JSX", mime: "text/typescript-jsx", mode: "jsx", ext: ["tsx"], alias: ["tsx"]},
  13891. {name: "Twig", mime: "text/x-twig", mode: "twig"},
  13892. {name: "Web IDL", mime: "text/x-webidl", mode: "webidl", ext: ["webidl"]},
  13893. {name: "VB.NET", mime: "text/x-vb", mode: "vb", ext: ["vb"]},
  13894. {name: "VBScript", mime: "text/vbscript", mode: "vbscript", ext: ["vbs"]},
  13895. {name: "Velocity", mime: "text/velocity", mode: "velocity", ext: ["vtl"]},
  13896. {name: "Verilog", mime: "text/x-verilog", mode: "verilog", ext: ["v"]},
  13897. {name: "VHDL", mime: "text/x-vhdl", mode: "vhdl", ext: ["vhd", "vhdl"]},
  13898. {name: "Vue.js Component", mimes: ["script/x-vue", "text/x-vue"], mode: "vue", ext: ["vue"]},
  13899. {name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd", "svg"], alias: ["rss", "wsdl", "xsd"]},
  13900. {name: "XQuery", mime: "application/xquery", mode: "xquery", ext: ["xy", "xquery"]},
  13901. {name: "Yacas", mime: "text/x-yacas", mode: "yacas", ext: ["ys"]},
  13902. {name: "YAML", mimes: ["text/x-yaml", "text/yaml"], mode: "yaml", ext: ["yaml", "yml"], alias: ["yml"]},
  13903. {name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]},
  13904. {name: "mscgen", mime: "text/x-mscgen", mode: "mscgen", ext: ["mscgen", "mscin", "msc"]},
  13905. {name: "xu", mime: "text/x-xu", mode: "mscgen", ext: ["xu"]},
  13906. {name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]},
  13907. {name: "WebAssembly", mime: "text/webassembly", mode: "wast", ext: ["wat", "wast"]},
  13908. ];
  13909. // Ensure all modes have a mime property for backwards compatibility
  13910. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  13911. var info = CodeMirror.modeInfo[i];
  13912. if (info.mimes) info.mime = info.mimes[0];
  13913. }
  13914. CodeMirror.findModeByMIME = function(mime) {
  13915. mime = mime.toLowerCase();
  13916. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  13917. var info = CodeMirror.modeInfo[i];
  13918. if (info.mime == mime) return info;
  13919. if (info.mimes) for (var j = 0; j < info.mimes.length; j++)
  13920. if (info.mimes[j] == mime) return info;
  13921. }
  13922. if (/\+xml$/.test(mime)) return CodeMirror.findModeByMIME("application/xml")
  13923. if (/\+json$/.test(mime)) return CodeMirror.findModeByMIME("application/json")
  13924. };
  13925. CodeMirror.findModeByExtension = function(ext) {
  13926. ext = ext.toLowerCase();
  13927. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  13928. var info = CodeMirror.modeInfo[i];
  13929. if (info.ext) for (var j = 0; j < info.ext.length; j++)
  13930. if (info.ext[j] == ext) return info;
  13931. }
  13932. };
  13933. CodeMirror.findModeByFileName = function(filename) {
  13934. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  13935. var info = CodeMirror.modeInfo[i];
  13936. if (info.file && info.file.test(filename)) return info;
  13937. }
  13938. var dot = filename.lastIndexOf(".");
  13939. var ext = dot > -1 && filename.substring(dot + 1, filename.length);
  13940. if (ext) return CodeMirror.findModeByExtension(ext);
  13941. };
  13942. CodeMirror.findModeByName = function(name) {
  13943. name = name.toLowerCase();
  13944. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  13945. var info = CodeMirror.modeInfo[i];
  13946. if (info.name.toLowerCase() == name) return info;
  13947. if (info.alias) for (var j = 0; j < info.alias.length; j++)
  13948. if (info.alias[j].toLowerCase() == name) return info;
  13949. }
  13950. };
  13951. });
  13952. });
  13953. var markdown = createCommonjsModule(function (module, exports) {
  13954. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  13955. // Distributed under an MIT license: https://codemirror.net/LICENSE
  13956. (function(mod) {
  13957. mod(codemirror, xml, meta);
  13958. })(function(CodeMirror) {
  13959. CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
  13960. var htmlMode = CodeMirror.getMode(cmCfg, "text/html");
  13961. var htmlModeMissing = htmlMode.name == "null";
  13962. function getMode(name) {
  13963. if (CodeMirror.findModeByName) {
  13964. var found = CodeMirror.findModeByName(name);
  13965. if (found) name = found.mime || found.mimes[0];
  13966. }
  13967. var mode = CodeMirror.getMode(cmCfg, name);
  13968. return mode.name == "null" ? null : mode;
  13969. }
  13970. // Should characters that affect highlighting be highlighted separate?
  13971. // Does not include characters that will be output (such as `1.` and `-` for lists)
  13972. if (modeCfg.highlightFormatting === undefined)
  13973. modeCfg.highlightFormatting = false;
  13974. // Maximum number of nested blockquotes. Set to 0 for infinite nesting.
  13975. // Excess `>` will emit `error` token.
  13976. if (modeCfg.maxBlockquoteDepth === undefined)
  13977. modeCfg.maxBlockquoteDepth = 0;
  13978. // Turn on task lists? ("- [ ] " and "- [x] ")
  13979. if (modeCfg.taskLists === undefined) modeCfg.taskLists = false;
  13980. // Turn on strikethrough syntax
  13981. if (modeCfg.strikethrough === undefined)
  13982. modeCfg.strikethrough = false;
  13983. if (modeCfg.emoji === undefined)
  13984. modeCfg.emoji = false;
  13985. if (modeCfg.fencedCodeBlockHighlighting === undefined)
  13986. modeCfg.fencedCodeBlockHighlighting = true;
  13987. if (modeCfg.fencedCodeBlockDefaultMode === undefined)
  13988. modeCfg.fencedCodeBlockDefaultMode = 'text/plain';
  13989. if (modeCfg.xml === undefined)
  13990. modeCfg.xml = true;
  13991. // Allow token types to be overridden by user-provided token types.
  13992. if (modeCfg.tokenTypeOverrides === undefined)
  13993. modeCfg.tokenTypeOverrides = {};
  13994. var tokenTypes = {
  13995. header: "header",
  13996. code: "comment",
  13997. quote: "quote",
  13998. list1: "variable-2",
  13999. list2: "variable-3",
  14000. list3: "keyword",
  14001. hr: "hr",
  14002. image: "image",
  14003. imageAltText: "image-alt-text",
  14004. imageMarker: "image-marker",
  14005. formatting: "formatting",
  14006. linkInline: "link",
  14007. linkEmail: "link",
  14008. linkText: "link",
  14009. linkHref: "string",
  14010. em: "em",
  14011. strong: "strong",
  14012. strikethrough: "strikethrough",
  14013. emoji: "builtin"
  14014. };
  14015. for (var tokenType in tokenTypes) {
  14016. if (tokenTypes.hasOwnProperty(tokenType) && modeCfg.tokenTypeOverrides[tokenType]) {
  14017. tokenTypes[tokenType] = modeCfg.tokenTypeOverrides[tokenType];
  14018. }
  14019. }
  14020. var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/
  14021. , listRE = /^(?:[*\-+]|^[0-9]+([.)]))\s+/
  14022. , taskListRE = /^\[(x| )\](?=\s)/i // Must follow listRE
  14023. , atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/
  14024. , setextHeaderRE = /^ {0,3}(?:\={1,}|-{2,})\s*$/
  14025. , textRE = /^[^#!\[\]*_\\<>` "'(~:]+/
  14026. , fencedCodeRE = /^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/
  14027. , linkDefRE = /^\s*\[[^\]]+?\]:.*$/ // naive link-definition
  14028. , punctuation = /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/
  14029. , expandedTab = " "; // CommonMark specifies tab as 4 spaces
  14030. function switchInline(stream, state, f) {
  14031. state.f = state.inline = f;
  14032. return f(stream, state);
  14033. }
  14034. function switchBlock(stream, state, f) {
  14035. state.f = state.block = f;
  14036. return f(stream, state);
  14037. }
  14038. function lineIsEmpty(line) {
  14039. return !line || !/\S/.test(line.string)
  14040. }
  14041. // Blocks
  14042. function blankLine(state) {
  14043. // Reset linkTitle state
  14044. state.linkTitle = false;
  14045. state.linkHref = false;
  14046. state.linkText = false;
  14047. // Reset EM state
  14048. state.em = false;
  14049. // Reset STRONG state
  14050. state.strong = false;
  14051. // Reset strikethrough state
  14052. state.strikethrough = false;
  14053. // Reset state.quote
  14054. state.quote = 0;
  14055. // Reset state.indentedCode
  14056. state.indentedCode = false;
  14057. if (state.f == htmlBlock) {
  14058. var exit = htmlModeMissing;
  14059. if (!exit) {
  14060. var inner = CodeMirror.innerMode(htmlMode, state.htmlState);
  14061. exit = inner.mode.name == "xml" && inner.state.tagStart === null &&
  14062. (!inner.state.context && inner.state.tokenize.isInText);
  14063. }
  14064. if (exit) {
  14065. state.f = inlineNormal;
  14066. state.block = blockNormal;
  14067. state.htmlState = null;
  14068. }
  14069. }
  14070. // Reset state.trailingSpace
  14071. state.trailingSpace = 0;
  14072. state.trailingSpaceNewLine = false;
  14073. // Mark this line as blank
  14074. state.prevLine = state.thisLine;
  14075. state.thisLine = {stream: null};
  14076. return null;
  14077. }
  14078. function blockNormal(stream, state) {
  14079. var firstTokenOnLine = stream.column() === state.indentation;
  14080. var prevLineLineIsEmpty = lineIsEmpty(state.prevLine.stream);
  14081. var prevLineIsIndentedCode = state.indentedCode;
  14082. var prevLineIsHr = state.prevLine.hr;
  14083. var prevLineIsList = state.list !== false;
  14084. var maxNonCodeIndentation = (state.listStack[state.listStack.length - 1] || 0) + 3;
  14085. state.indentedCode = false;
  14086. var lineIndentation = state.indentation;
  14087. // compute once per line (on first token)
  14088. if (state.indentationDiff === null) {
  14089. state.indentationDiff = state.indentation;
  14090. if (prevLineIsList) {
  14091. state.list = null;
  14092. // While this list item's marker's indentation is less than the deepest
  14093. // list item's content's indentation,pop the deepest list item
  14094. // indentation off the stack, and update block indentation state
  14095. while (lineIndentation < state.listStack[state.listStack.length - 1]) {
  14096. state.listStack.pop();
  14097. if (state.listStack.length) {
  14098. state.indentation = state.listStack[state.listStack.length - 1];
  14099. // less than the first list's indent -> the line is no longer a list
  14100. } else {
  14101. state.list = false;
  14102. }
  14103. }
  14104. if (state.list !== false) {
  14105. state.indentationDiff = lineIndentation - state.listStack[state.listStack.length - 1];
  14106. }
  14107. }
  14108. }
  14109. // not comprehensive (currently only for setext detection purposes)
  14110. var allowsInlineContinuation = (
  14111. !prevLineLineIsEmpty && !prevLineIsHr && !state.prevLine.header &&
  14112. (!prevLineIsList || !prevLineIsIndentedCode) &&
  14113. !state.prevLine.fencedCodeEnd
  14114. );
  14115. var isHr = (state.list === false || prevLineIsHr || prevLineLineIsEmpty) &&
  14116. state.indentation <= maxNonCodeIndentation && stream.match(hrRE);
  14117. var match = null;
  14118. if (state.indentationDiff >= 4 && (prevLineIsIndentedCode || state.prevLine.fencedCodeEnd ||
  14119. state.prevLine.header || prevLineLineIsEmpty)) {
  14120. stream.skipToEnd();
  14121. state.indentedCode = true;
  14122. return tokenTypes.code;
  14123. } else if (stream.eatSpace()) {
  14124. return null;
  14125. } else if (firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(atxHeaderRE)) && match[1].length <= 6) {
  14126. state.quote = 0;
  14127. state.header = match[1].length;
  14128. state.thisLine.header = true;
  14129. if (modeCfg.highlightFormatting) state.formatting = "header";
  14130. state.f = state.inline;
  14131. return getType(state);
  14132. } else if (state.indentation <= maxNonCodeIndentation && stream.eat('>')) {
  14133. state.quote = firstTokenOnLine ? 1 : state.quote + 1;
  14134. if (modeCfg.highlightFormatting) state.formatting = "quote";
  14135. stream.eatSpace();
  14136. return getType(state);
  14137. } else if (!isHr && !state.setext && firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(listRE))) {
  14138. var listType = match[1] ? "ol" : "ul";
  14139. state.indentation = lineIndentation + stream.current().length;
  14140. state.list = true;
  14141. state.quote = 0;
  14142. // Add this list item's content's indentation to the stack
  14143. state.listStack.push(state.indentation);
  14144. // Reset inline styles which shouldn't propagate aross list items
  14145. state.em = false;
  14146. state.strong = false;
  14147. state.code = false;
  14148. state.strikethrough = false;
  14149. if (modeCfg.taskLists && stream.match(taskListRE, false)) {
  14150. state.taskList = true;
  14151. }
  14152. state.f = state.inline;
  14153. if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType];
  14154. return getType(state);
  14155. } else if (firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(fencedCodeRE, true))) {
  14156. state.quote = 0;
  14157. state.fencedEndRE = new RegExp(match[1] + "+ *$");
  14158. // try switching mode
  14159. state.localMode = modeCfg.fencedCodeBlockHighlighting && getMode(match[2] || modeCfg.fencedCodeBlockDefaultMode );
  14160. if (state.localMode) state.localState = CodeMirror.startState(state.localMode);
  14161. state.f = state.block = local;
  14162. if (modeCfg.highlightFormatting) state.formatting = "code-block";
  14163. state.code = -1;
  14164. return getType(state);
  14165. // SETEXT has lowest block-scope precedence after HR, so check it after
  14166. // the others (code, blockquote, list...)
  14167. } else if (
  14168. // if setext set, indicates line after ---/===
  14169. state.setext || (
  14170. // line before ---/===
  14171. (!allowsInlineContinuation || !prevLineIsList) && !state.quote && state.list === false &&
  14172. !state.code && !isHr && !linkDefRE.test(stream.string) &&
  14173. (match = stream.lookAhead(1)) && (match = match.match(setextHeaderRE))
  14174. )
  14175. ) {
  14176. if ( !state.setext ) {
  14177. state.header = match[0].charAt(0) == '=' ? 1 : 2;
  14178. state.setext = state.header;
  14179. } else {
  14180. state.header = state.setext;
  14181. // has no effect on type so we can reset it now
  14182. state.setext = 0;
  14183. stream.skipToEnd();
  14184. if (modeCfg.highlightFormatting) state.formatting = "header";
  14185. }
  14186. state.thisLine.header = true;
  14187. state.f = state.inline;
  14188. return getType(state);
  14189. } else if (isHr) {
  14190. stream.skipToEnd();
  14191. state.hr = true;
  14192. state.thisLine.hr = true;
  14193. return tokenTypes.hr;
  14194. } else if (stream.peek() === '[') {
  14195. return switchInline(stream, state, footnoteLink);
  14196. }
  14197. return switchInline(stream, state, state.inline);
  14198. }
  14199. function htmlBlock(stream, state) {
  14200. var style = htmlMode.token(stream, state.htmlState);
  14201. if (!htmlModeMissing) {
  14202. var inner = CodeMirror.innerMode(htmlMode, state.htmlState);
  14203. if ((inner.mode.name == "xml" && inner.state.tagStart === null &&
  14204. (!inner.state.context && inner.state.tokenize.isInText)) ||
  14205. (state.md_inside && stream.current().indexOf(">") > -1)) {
  14206. state.f = inlineNormal;
  14207. state.block = blockNormal;
  14208. state.htmlState = null;
  14209. }
  14210. }
  14211. return style;
  14212. }
  14213. function local(stream, state) {
  14214. var currListInd = state.listStack[state.listStack.length - 1] || 0;
  14215. var hasExitedList = state.indentation < currListInd;
  14216. var maxFencedEndInd = currListInd + 3;
  14217. if (state.fencedEndRE && state.indentation <= maxFencedEndInd && (hasExitedList || stream.match(state.fencedEndRE))) {
  14218. if (modeCfg.highlightFormatting) state.formatting = "code-block";
  14219. var returnType;
  14220. if (!hasExitedList) returnType = getType(state);
  14221. state.localMode = state.localState = null;
  14222. state.block = blockNormal;
  14223. state.f = inlineNormal;
  14224. state.fencedEndRE = null;
  14225. state.code = 0;
  14226. state.thisLine.fencedCodeEnd = true;
  14227. if (hasExitedList) return switchBlock(stream, state, state.block);
  14228. return returnType;
  14229. } else if (state.localMode) {
  14230. return state.localMode.token(stream, state.localState);
  14231. } else {
  14232. stream.skipToEnd();
  14233. return tokenTypes.code;
  14234. }
  14235. }
  14236. // Inline
  14237. function getType(state) {
  14238. var styles = [];
  14239. if (state.formatting) {
  14240. styles.push(tokenTypes.formatting);
  14241. if (typeof state.formatting === "string") state.formatting = [state.formatting];
  14242. for (var i = 0; i < state.formatting.length; i++) {
  14243. styles.push(tokenTypes.formatting + "-" + state.formatting[i]);
  14244. if (state.formatting[i] === "header") {
  14245. styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.header);
  14246. }
  14247. // Add `formatting-quote` and `formatting-quote-#` for blockquotes
  14248. // Add `error` instead if the maximum blockquote nesting depth is passed
  14249. if (state.formatting[i] === "quote") {
  14250. if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
  14251. styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.quote);
  14252. } else {
  14253. styles.push("error");
  14254. }
  14255. }
  14256. }
  14257. }
  14258. if (state.taskOpen) {
  14259. styles.push("meta");
  14260. return styles.length ? styles.join(' ') : null;
  14261. }
  14262. if (state.taskClosed) {
  14263. styles.push("property");
  14264. return styles.length ? styles.join(' ') : null;
  14265. }
  14266. if (state.linkHref) {
  14267. styles.push(tokenTypes.linkHref, "url");
  14268. } else { // Only apply inline styles to non-url text
  14269. if (state.strong) { styles.push(tokenTypes.strong); }
  14270. if (state.em) { styles.push(tokenTypes.em); }
  14271. if (state.strikethrough) { styles.push(tokenTypes.strikethrough); }
  14272. if (state.emoji) { styles.push(tokenTypes.emoji); }
  14273. if (state.linkText) { styles.push(tokenTypes.linkText); }
  14274. if (state.code) { styles.push(tokenTypes.code); }
  14275. if (state.image) { styles.push(tokenTypes.image); }
  14276. if (state.imageAltText) { styles.push(tokenTypes.imageAltText, "link"); }
  14277. if (state.imageMarker) { styles.push(tokenTypes.imageMarker); }
  14278. }
  14279. if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); }
  14280. if (state.quote) {
  14281. styles.push(tokenTypes.quote);
  14282. // Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth
  14283. if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
  14284. styles.push(tokenTypes.quote + "-" + state.quote);
  14285. } else {
  14286. styles.push(tokenTypes.quote + "-" + modeCfg.maxBlockquoteDepth);
  14287. }
  14288. }
  14289. if (state.list !== false) {
  14290. var listMod = (state.listStack.length - 1) % 3;
  14291. if (!listMod) {
  14292. styles.push(tokenTypes.list1);
  14293. } else if (listMod === 1) {
  14294. styles.push(tokenTypes.list2);
  14295. } else {
  14296. styles.push(tokenTypes.list3);
  14297. }
  14298. }
  14299. if (state.trailingSpaceNewLine) {
  14300. styles.push("trailing-space-new-line");
  14301. } else if (state.trailingSpace) {
  14302. styles.push("trailing-space-" + (state.trailingSpace % 2 ? "a" : "b"));
  14303. }
  14304. return styles.length ? styles.join(' ') : null;
  14305. }
  14306. function handleText(stream, state) {
  14307. if (stream.match(textRE, true)) {
  14308. return getType(state);
  14309. }
  14310. return undefined;
  14311. }
  14312. function inlineNormal(stream, state) {
  14313. var style = state.text(stream, state);
  14314. if (typeof style !== 'undefined')
  14315. return style;
  14316. if (state.list) { // List marker (*, +, -, 1., etc)
  14317. state.list = null;
  14318. return getType(state);
  14319. }
  14320. if (state.taskList) {
  14321. var taskOpen = stream.match(taskListRE, true)[1] === " ";
  14322. if (taskOpen) state.taskOpen = true;
  14323. else state.taskClosed = true;
  14324. if (modeCfg.highlightFormatting) state.formatting = "task";
  14325. state.taskList = false;
  14326. return getType(state);
  14327. }
  14328. state.taskOpen = false;
  14329. state.taskClosed = false;
  14330. if (state.header && stream.match(/^#+$/, true)) {
  14331. if (modeCfg.highlightFormatting) state.formatting = "header";
  14332. return getType(state);
  14333. }
  14334. var ch = stream.next();
  14335. // Matches link titles present on next line
  14336. if (state.linkTitle) {
  14337. state.linkTitle = false;
  14338. var matchCh = ch;
  14339. if (ch === '(') {
  14340. matchCh = ')';
  14341. }
  14342. matchCh = (matchCh+'').replace(/([.?*+^\[\]\\(){}|-])/g, "\\$1");
  14343. var regex = '^\\s*(?:[^' + matchCh + '\\\\]+|\\\\\\\\|\\\\.)' + matchCh;
  14344. if (stream.match(new RegExp(regex), true)) {
  14345. return tokenTypes.linkHref;
  14346. }
  14347. }
  14348. // If this block is changed, it may need to be updated in GFM mode
  14349. if (ch === '`') {
  14350. var previousFormatting = state.formatting;
  14351. if (modeCfg.highlightFormatting) state.formatting = "code";
  14352. stream.eatWhile('`');
  14353. var count = stream.current().length;
  14354. if (state.code == 0 && (!state.quote || count == 1)) {
  14355. state.code = count;
  14356. return getType(state)
  14357. } else if (count == state.code) { // Must be exact
  14358. var t = getType(state);
  14359. state.code = 0;
  14360. return t
  14361. } else {
  14362. state.formatting = previousFormatting;
  14363. return getType(state)
  14364. }
  14365. } else if (state.code) {
  14366. return getType(state);
  14367. }
  14368. if (ch === '\\') {
  14369. stream.next();
  14370. if (modeCfg.highlightFormatting) {
  14371. var type = getType(state);
  14372. var formattingEscape = tokenTypes.formatting + "-escape";
  14373. return type ? type + " " + formattingEscape : formattingEscape;
  14374. }
  14375. }
  14376. if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
  14377. state.imageMarker = true;
  14378. state.image = true;
  14379. if (modeCfg.highlightFormatting) state.formatting = "image";
  14380. return getType(state);
  14381. }
  14382. if (ch === '[' && state.imageMarker && stream.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/, false)) {
  14383. state.imageMarker = false;
  14384. state.imageAltText = true;
  14385. if (modeCfg.highlightFormatting) state.formatting = "image";
  14386. return getType(state);
  14387. }
  14388. if (ch === ']' && state.imageAltText) {
  14389. if (modeCfg.highlightFormatting) state.formatting = "image";
  14390. var type = getType(state);
  14391. state.imageAltText = false;
  14392. state.image = false;
  14393. state.inline = state.f = linkHref;
  14394. return type;
  14395. }
  14396. if (ch === '[' && !state.image) {
  14397. if (state.linkText && stream.match(/^.*?\]/)) return getType(state)
  14398. state.linkText = true;
  14399. if (modeCfg.highlightFormatting) state.formatting = "link";
  14400. return getType(state);
  14401. }
  14402. if (ch === ']' && state.linkText) {
  14403. if (modeCfg.highlightFormatting) state.formatting = "link";
  14404. var type = getType(state);
  14405. state.linkText = false;
  14406. state.inline = state.f = stream.match(/\(.*?\)| ?\[.*?\]/, false) ? linkHref : inlineNormal;
  14407. return type;
  14408. }
  14409. if (ch === '<' && stream.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/, false)) {
  14410. state.f = state.inline = linkInline;
  14411. if (modeCfg.highlightFormatting) state.formatting = "link";
  14412. var type = getType(state);
  14413. if (type){
  14414. type += " ";
  14415. } else {
  14416. type = "";
  14417. }
  14418. return type + tokenTypes.linkInline;
  14419. }
  14420. if (ch === '<' && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, false)) {
  14421. state.f = state.inline = linkInline;
  14422. if (modeCfg.highlightFormatting) state.formatting = "link";
  14423. var type = getType(state);
  14424. if (type){
  14425. type += " ";
  14426. } else {
  14427. type = "";
  14428. }
  14429. return type + tokenTypes.linkEmail;
  14430. }
  14431. if (modeCfg.xml && ch === '<' && stream.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i, false)) {
  14432. var end = stream.string.indexOf(">", stream.pos);
  14433. if (end != -1) {
  14434. var atts = stream.string.substring(stream.start, end);
  14435. if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) state.md_inside = true;
  14436. }
  14437. stream.backUp(1);
  14438. state.htmlState = CodeMirror.startState(htmlMode);
  14439. return switchBlock(stream, state, htmlBlock);
  14440. }
  14441. if (modeCfg.xml && ch === '<' && stream.match(/^\/\w*?>/)) {
  14442. state.md_inside = false;
  14443. return "tag";
  14444. } else if (ch === "*" || ch === "_") {
  14445. var len = 1, before = stream.pos == 1 ? " " : stream.string.charAt(stream.pos - 2);
  14446. while (len < 3 && stream.eat(ch)) len++;
  14447. var after = stream.peek() || " ";
  14448. // See http://spec.commonmark.org/0.27/#emphasis-and-strong-emphasis
  14449. var leftFlanking = !/\s/.test(after) && (!punctuation.test(after) || /\s/.test(before) || punctuation.test(before));
  14450. var rightFlanking = !/\s/.test(before) && (!punctuation.test(before) || /\s/.test(after) || punctuation.test(after));
  14451. var setEm = null, setStrong = null;
  14452. if (len % 2) { // Em
  14453. if (!state.em && leftFlanking && (ch === "*" || !rightFlanking || punctuation.test(before)))
  14454. setEm = true;
  14455. else if (state.em == ch && rightFlanking && (ch === "*" || !leftFlanking || punctuation.test(after)))
  14456. setEm = false;
  14457. }
  14458. if (len > 1) { // Strong
  14459. if (!state.strong && leftFlanking && (ch === "*" || !rightFlanking || punctuation.test(before)))
  14460. setStrong = true;
  14461. else if (state.strong == ch && rightFlanking && (ch === "*" || !leftFlanking || punctuation.test(after)))
  14462. setStrong = false;
  14463. }
  14464. if (setStrong != null || setEm != null) {
  14465. if (modeCfg.highlightFormatting) state.formatting = setEm == null ? "strong" : setStrong == null ? "em" : "strong em";
  14466. if (setEm === true) state.em = ch;
  14467. if (setStrong === true) state.strong = ch;
  14468. var t = getType(state);
  14469. if (setEm === false) state.em = false;
  14470. if (setStrong === false) state.strong = false;
  14471. return t
  14472. }
  14473. } else if (ch === ' ') {
  14474. if (stream.eat('*') || stream.eat('_')) { // Probably surrounded by spaces
  14475. if (stream.peek() === ' ') { // Surrounded by spaces, ignore
  14476. return getType(state);
  14477. } else { // Not surrounded by spaces, back up pointer
  14478. stream.backUp(1);
  14479. }
  14480. }
  14481. }
  14482. if (modeCfg.strikethrough) {
  14483. if (ch === '~' && stream.eatWhile(ch)) {
  14484. if (state.strikethrough) {// Remove strikethrough
  14485. if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
  14486. var t = getType(state);
  14487. state.strikethrough = false;
  14488. return t;
  14489. } else if (stream.match(/^[^\s]/, false)) {// Add strikethrough
  14490. state.strikethrough = true;
  14491. if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
  14492. return getType(state);
  14493. }
  14494. } else if (ch === ' ') {
  14495. if (stream.match(/^~~/, true)) { // Probably surrounded by space
  14496. if (stream.peek() === ' ') { // Surrounded by spaces, ignore
  14497. return getType(state);
  14498. } else { // Not surrounded by spaces, back up pointer
  14499. stream.backUp(2);
  14500. }
  14501. }
  14502. }
  14503. }
  14504. if (modeCfg.emoji && ch === ":" && stream.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)) {
  14505. state.emoji = true;
  14506. if (modeCfg.highlightFormatting) state.formatting = "emoji";
  14507. var retType = getType(state);
  14508. state.emoji = false;
  14509. return retType;
  14510. }
  14511. if (ch === ' ') {
  14512. if (stream.match(/^ +$/, false)) {
  14513. state.trailingSpace++;
  14514. } else if (state.trailingSpace) {
  14515. state.trailingSpaceNewLine = true;
  14516. }
  14517. }
  14518. return getType(state);
  14519. }
  14520. function linkInline(stream, state) {
  14521. var ch = stream.next();
  14522. if (ch === ">") {
  14523. state.f = state.inline = inlineNormal;
  14524. if (modeCfg.highlightFormatting) state.formatting = "link";
  14525. var type = getType(state);
  14526. if (type){
  14527. type += " ";
  14528. } else {
  14529. type = "";
  14530. }
  14531. return type + tokenTypes.linkInline;
  14532. }
  14533. stream.match(/^[^>]+/, true);
  14534. return tokenTypes.linkInline;
  14535. }
  14536. function linkHref(stream, state) {
  14537. // Check if space, and return NULL if so (to avoid marking the space)
  14538. if(stream.eatSpace()){
  14539. return null;
  14540. }
  14541. var ch = stream.next();
  14542. if (ch === '(' || ch === '[') {
  14543. state.f = state.inline = getLinkHrefInside(ch === "(" ? ")" : "]");
  14544. if (modeCfg.highlightFormatting) state.formatting = "link-string";
  14545. state.linkHref = true;
  14546. return getType(state);
  14547. }
  14548. return 'error';
  14549. }
  14550. var linkRE = {
  14551. ")": /^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,
  14552. "]": /^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/
  14553. };
  14554. function getLinkHrefInside(endChar) {
  14555. return function(stream, state) {
  14556. var ch = stream.next();
  14557. if (ch === endChar) {
  14558. state.f = state.inline = inlineNormal;
  14559. if (modeCfg.highlightFormatting) state.formatting = "link-string";
  14560. var returnState = getType(state);
  14561. state.linkHref = false;
  14562. return returnState;
  14563. }
  14564. stream.match(linkRE[endChar]);
  14565. state.linkHref = true;
  14566. return getType(state);
  14567. };
  14568. }
  14569. function footnoteLink(stream, state) {
  14570. if (stream.match(/^([^\]\\]|\\.)*\]:/, false)) {
  14571. state.f = footnoteLinkInside;
  14572. stream.next(); // Consume [
  14573. if (modeCfg.highlightFormatting) state.formatting = "link";
  14574. state.linkText = true;
  14575. return getType(state);
  14576. }
  14577. return switchInline(stream, state, inlineNormal);
  14578. }
  14579. function footnoteLinkInside(stream, state) {
  14580. if (stream.match(/^\]:/, true)) {
  14581. state.f = state.inline = footnoteUrl;
  14582. if (modeCfg.highlightFormatting) state.formatting = "link";
  14583. var returnType = getType(state);
  14584. state.linkText = false;
  14585. return returnType;
  14586. }
  14587. stream.match(/^([^\]\\]|\\.)+/, true);
  14588. return tokenTypes.linkText;
  14589. }
  14590. function footnoteUrl(stream, state) {
  14591. // Check if space, and return NULL if so (to avoid marking the space)
  14592. if(stream.eatSpace()){
  14593. return null;
  14594. }
  14595. // Match URL
  14596. stream.match(/^[^\s]+/, true);
  14597. // Check for link title
  14598. if (stream.peek() === undefined) { // End of line, set flag to check next line
  14599. state.linkTitle = true;
  14600. } else { // More content on line, check if link title
  14601. stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true);
  14602. }
  14603. state.f = state.inline = inlineNormal;
  14604. return tokenTypes.linkHref + " url";
  14605. }
  14606. var mode = {
  14607. startState: function() {
  14608. return {
  14609. f: blockNormal,
  14610. prevLine: {stream: null},
  14611. thisLine: {stream: null},
  14612. block: blockNormal,
  14613. htmlState: null,
  14614. indentation: 0,
  14615. inline: inlineNormal,
  14616. text: handleText,
  14617. formatting: false,
  14618. linkText: false,
  14619. linkHref: false,
  14620. linkTitle: false,
  14621. code: 0,
  14622. em: false,
  14623. strong: false,
  14624. header: 0,
  14625. setext: 0,
  14626. hr: false,
  14627. taskList: false,
  14628. list: false,
  14629. listStack: [],
  14630. quote: 0,
  14631. trailingSpace: 0,
  14632. trailingSpaceNewLine: false,
  14633. strikethrough: false,
  14634. emoji: false,
  14635. fencedEndRE: null
  14636. };
  14637. },
  14638. copyState: function(s) {
  14639. return {
  14640. f: s.f,
  14641. prevLine: s.prevLine,
  14642. thisLine: s.thisLine,
  14643. block: s.block,
  14644. htmlState: s.htmlState && CodeMirror.copyState(htmlMode, s.htmlState),
  14645. indentation: s.indentation,
  14646. localMode: s.localMode,
  14647. localState: s.localMode ? CodeMirror.copyState(s.localMode, s.localState) : null,
  14648. inline: s.inline,
  14649. text: s.text,
  14650. formatting: false,
  14651. linkText: s.linkText,
  14652. linkTitle: s.linkTitle,
  14653. linkHref: s.linkHref,
  14654. code: s.code,
  14655. em: s.em,
  14656. strong: s.strong,
  14657. strikethrough: s.strikethrough,
  14658. emoji: s.emoji,
  14659. header: s.header,
  14660. setext: s.setext,
  14661. hr: s.hr,
  14662. taskList: s.taskList,
  14663. list: s.list,
  14664. listStack: s.listStack.slice(0),
  14665. quote: s.quote,
  14666. indentedCode: s.indentedCode,
  14667. trailingSpace: s.trailingSpace,
  14668. trailingSpaceNewLine: s.trailingSpaceNewLine,
  14669. md_inside: s.md_inside,
  14670. fencedEndRE: s.fencedEndRE
  14671. };
  14672. },
  14673. token: function(stream, state) {
  14674. // Reset state.formatting
  14675. state.formatting = false;
  14676. if (stream != state.thisLine.stream) {
  14677. state.header = 0;
  14678. state.hr = false;
  14679. if (stream.match(/^\s*$/, true)) {
  14680. blankLine(state);
  14681. return null;
  14682. }
  14683. state.prevLine = state.thisLine;
  14684. state.thisLine = {stream: stream};
  14685. // Reset state.taskList
  14686. state.taskList = false;
  14687. // Reset state.trailingSpace
  14688. state.trailingSpace = 0;
  14689. state.trailingSpaceNewLine = false;
  14690. if (!state.localState) {
  14691. state.f = state.block;
  14692. if (state.f != htmlBlock) {
  14693. var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, expandedTab).length;
  14694. state.indentation = indentation;
  14695. state.indentationDiff = null;
  14696. if (indentation > 0) return null;
  14697. }
  14698. }
  14699. }
  14700. return state.f(stream, state);
  14701. },
  14702. innerMode: function(state) {
  14703. if (state.block == htmlBlock) return {state: state.htmlState, mode: htmlMode};
  14704. if (state.localState) return {state: state.localState, mode: state.localMode};
  14705. return {state: state, mode: mode};
  14706. },
  14707. indent: function(state, textAfter, line) {
  14708. if (state.block == htmlBlock && htmlMode.indent) return htmlMode.indent(state.htmlState, textAfter, line)
  14709. if (state.localState && state.localMode.indent) return state.localMode.indent(state.localState, textAfter, line)
  14710. return CodeMirror.Pass
  14711. },
  14712. blankLine: blankLine,
  14713. getType: getType,
  14714. blockCommentStart: "<!--",
  14715. blockCommentEnd: "-->",
  14716. closeBrackets: "()[]{}''\"\"``",
  14717. fold: "markdown"
  14718. };
  14719. return mode;
  14720. }, "xml");
  14721. CodeMirror.defineMIME("text/markdown", "markdown");
  14722. CodeMirror.defineMIME("text/x-markdown", "markdown");
  14723. });
  14724. });
  14725. var overlay = createCommonjsModule(function (module, exports) {
  14726. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  14727. // Distributed under an MIT license: https://codemirror.net/LICENSE
  14728. // Utility function that allows modes to be combined. The mode given
  14729. // as the base argument takes care of most of the normal mode
  14730. // functionality, but a second (typically simple) mode is used, which
  14731. // can override the style of text. Both modes get to parse all of the
  14732. // text, but when both assign a non-null style to a piece of code, the
  14733. // overlay wins, unless the combine argument was true and not overridden,
  14734. // or state.overlay.combineTokens was true, in which case the styles are
  14735. // combined.
  14736. (function(mod) {
  14737. mod(codemirror);
  14738. })(function(CodeMirror) {
  14739. CodeMirror.overlayMode = function(base, overlay, combine) {
  14740. return {
  14741. startState: function() {
  14742. return {
  14743. base: CodeMirror.startState(base),
  14744. overlay: CodeMirror.startState(overlay),
  14745. basePos: 0, baseCur: null,
  14746. overlayPos: 0, overlayCur: null,
  14747. streamSeen: null
  14748. };
  14749. },
  14750. copyState: function(state) {
  14751. return {
  14752. base: CodeMirror.copyState(base, state.base),
  14753. overlay: CodeMirror.copyState(overlay, state.overlay),
  14754. basePos: state.basePos, baseCur: null,
  14755. overlayPos: state.overlayPos, overlayCur: null
  14756. };
  14757. },
  14758. token: function(stream, state) {
  14759. if (stream != state.streamSeen ||
  14760. Math.min(state.basePos, state.overlayPos) < stream.start) {
  14761. state.streamSeen = stream;
  14762. state.basePos = state.overlayPos = stream.start;
  14763. }
  14764. if (stream.start == state.basePos) {
  14765. state.baseCur = base.token(stream, state.base);
  14766. state.basePos = stream.pos;
  14767. }
  14768. if (stream.start == state.overlayPos) {
  14769. stream.pos = stream.start;
  14770. state.overlayCur = overlay.token(stream, state.overlay);
  14771. state.overlayPos = stream.pos;
  14772. }
  14773. stream.pos = Math.min(state.basePos, state.overlayPos);
  14774. // state.overlay.combineTokens always takes precedence over combine,
  14775. // unless set to null
  14776. if (state.overlayCur == null) return state.baseCur;
  14777. else if (state.baseCur != null &&
  14778. state.overlay.combineTokens ||
  14779. combine && state.overlay.combineTokens == null)
  14780. return state.baseCur + " " + state.overlayCur;
  14781. else return state.overlayCur;
  14782. },
  14783. indent: base.indent && function(state, textAfter, line) {
  14784. return base.indent(state.base, textAfter, line);
  14785. },
  14786. electricChars: base.electricChars,
  14787. innerMode: function(state) { return {state: state.base, mode: base}; },
  14788. blankLine: function(state) {
  14789. var baseToken, overlayToken;
  14790. if (base.blankLine) baseToken = base.blankLine(state.base);
  14791. if (overlay.blankLine) overlayToken = overlay.blankLine(state.overlay);
  14792. return overlayToken == null ?
  14793. baseToken :
  14794. (combine && baseToken != null ? baseToken + " " + overlayToken : overlayToken);
  14795. }
  14796. };
  14797. };
  14798. });
  14799. });
  14800. var gfm = createCommonjsModule(function (module, exports) {
  14801. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  14802. // Distributed under an MIT license: https://codemirror.net/LICENSE
  14803. (function(mod) {
  14804. mod(codemirror, markdown, overlay);
  14805. })(function(CodeMirror) {
  14806. var urlRE = /^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|tag|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i;
  14807. CodeMirror.defineMode("gfm", function(config, modeConfig) {
  14808. var codeDepth = 0;
  14809. function blankLine(state) {
  14810. state.code = false;
  14811. return null;
  14812. }
  14813. var gfmOverlay = {
  14814. startState: function() {
  14815. return {
  14816. code: false,
  14817. codeBlock: false,
  14818. ateSpace: false
  14819. };
  14820. },
  14821. copyState: function(s) {
  14822. return {
  14823. code: s.code,
  14824. codeBlock: s.codeBlock,
  14825. ateSpace: s.ateSpace
  14826. };
  14827. },
  14828. token: function(stream, state) {
  14829. state.combineTokens = null;
  14830. // Hack to prevent formatting override inside code blocks (block and inline)
  14831. if (state.codeBlock) {
  14832. if (stream.match(/^```+/)) {
  14833. state.codeBlock = false;
  14834. return null;
  14835. }
  14836. stream.skipToEnd();
  14837. return null;
  14838. }
  14839. if (stream.sol()) {
  14840. state.code = false;
  14841. }
  14842. if (stream.sol() && stream.match(/^```+/)) {
  14843. stream.skipToEnd();
  14844. state.codeBlock = true;
  14845. return null;
  14846. }
  14847. // If this block is changed, it may need to be updated in Markdown mode
  14848. if (stream.peek() === '`') {
  14849. stream.next();
  14850. var before = stream.pos;
  14851. stream.eatWhile('`');
  14852. var difference = 1 + stream.pos - before;
  14853. if (!state.code) {
  14854. codeDepth = difference;
  14855. state.code = true;
  14856. } else {
  14857. if (difference === codeDepth) { // Must be exact
  14858. state.code = false;
  14859. }
  14860. }
  14861. return null;
  14862. } else if (state.code) {
  14863. stream.next();
  14864. return null;
  14865. }
  14866. // Check if space. If so, links can be formatted later on
  14867. if (stream.eatSpace()) {
  14868. state.ateSpace = true;
  14869. return null;
  14870. }
  14871. if (stream.sol() || state.ateSpace) {
  14872. state.ateSpace = false;
  14873. if (modeConfig.gitHubSpice !== false) {
  14874. if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?=.{0,6}\d)(?:[a-f0-9]{7,40}\b)/)) {
  14875. // User/Project@SHA
  14876. // User@SHA
  14877. // SHA
  14878. state.combineTokens = true;
  14879. return "link";
  14880. } else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) {
  14881. // User/Project#Num
  14882. // User#Num
  14883. // #Num
  14884. state.combineTokens = true;
  14885. return "link";
  14886. }
  14887. }
  14888. }
  14889. if (stream.match(urlRE) &&
  14890. stream.string.slice(stream.start - 2, stream.start) != "](" &&
  14891. (stream.start == 0 || /\W/.test(stream.string.charAt(stream.start - 1)))) {
  14892. // URLs
  14893. // Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
  14894. // And then (issue #1160) simplified to make it not crash the Chrome Regexp engine
  14895. // And then limited url schemes to the CommonMark list, so foo:bar isn't matched as a URL
  14896. state.combineTokens = true;
  14897. return "link";
  14898. }
  14899. stream.next();
  14900. return null;
  14901. },
  14902. blankLine: blankLine
  14903. };
  14904. var markdownConfig = {
  14905. taskLists: true,
  14906. strikethrough: true,
  14907. emoji: true
  14908. };
  14909. for (var attr in modeConfig) {
  14910. markdownConfig[attr] = modeConfig[attr];
  14911. }
  14912. markdownConfig.name = "markdown";
  14913. return CodeMirror.overlayMode(CodeMirror.getMode(config, markdownConfig), gfmOverlay);
  14914. }, "markdown");
  14915. CodeMirror.defineMIME("text/x-gfm", "gfm");
  14916. });
  14917. });
  14918. var continuelist = createCommonjsModule(function (module, exports) {
  14919. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  14920. // Distributed under an MIT license: https://codemirror.net/LICENSE
  14921. (function(mod) {
  14922. mod(codemirror);
  14923. })(function(CodeMirror) {
  14924. var listRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/,
  14925. emptyListRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/,
  14926. unorderedListRE = /[*+-]\s/;
  14927. CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
  14928. if (cm.getOption("disableInput")) return CodeMirror.Pass;
  14929. var ranges = cm.listSelections(), replacements = [];
  14930. for (var i = 0; i < ranges.length; i++) {
  14931. var pos = ranges[i].head;
  14932. // If we're not in Markdown mode, fall back to normal newlineAndIndent
  14933. var eolState = cm.getStateAfter(pos.line);
  14934. var inner = CodeMirror.innerMode(cm.getMode(), eolState);
  14935. if (inner.mode.name !== "markdown") {
  14936. cm.execCommand("newlineAndIndent");
  14937. return;
  14938. } else {
  14939. eolState = inner.state;
  14940. }
  14941. var inList = eolState.list !== false;
  14942. var inQuote = eolState.quote !== 0;
  14943. var line = cm.getLine(pos.line), match = listRE.exec(line);
  14944. var cursorBeforeBullet = /^\s*$/.test(line.slice(0, pos.ch));
  14945. if (!ranges[i].empty() || (!inList && !inQuote) || !match || cursorBeforeBullet) {
  14946. cm.execCommand("newlineAndIndent");
  14947. return;
  14948. }
  14949. if (emptyListRE.test(line)) {
  14950. var endOfQuote = inQuote && />\s*$/.test(line);
  14951. var endOfList = !/>\s*$/.test(line);
  14952. if (endOfQuote || endOfList) cm.replaceRange("", {
  14953. line: pos.line, ch: 0
  14954. }, {
  14955. line: pos.line, ch: pos.ch + 1
  14956. });
  14957. replacements[i] = "\n";
  14958. } else {
  14959. var indent = match[1], after = match[5];
  14960. var numbered = !(unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0);
  14961. var bullet = numbered ? (parseInt(match[3], 10) + 1) + match[4] : match[2].replace("x", " ");
  14962. replacements[i] = "\n" + indent + bullet + after;
  14963. if (numbered) incrementRemainingMarkdownListNumbers(cm, pos);
  14964. }
  14965. }
  14966. cm.replaceSelections(replacements);
  14967. };
  14968. // Auto-updating Markdown list numbers when a new item is added to the
  14969. // middle of a list
  14970. function incrementRemainingMarkdownListNumbers(cm, pos) {
  14971. var startLine = pos.line, lookAhead = 0, skipCount = 0;
  14972. var startItem = listRE.exec(cm.getLine(startLine)), startIndent = startItem[1];
  14973. do {
  14974. lookAhead += 1;
  14975. var nextLineNumber = startLine + lookAhead;
  14976. var nextLine = cm.getLine(nextLineNumber), nextItem = listRE.exec(nextLine);
  14977. if (nextItem) {
  14978. var nextIndent = nextItem[1];
  14979. var newNumber = (parseInt(startItem[3], 10) + lookAhead - skipCount);
  14980. var nextNumber = (parseInt(nextItem[3], 10)), itemNumber = nextNumber;
  14981. if (startIndent === nextIndent && !isNaN(nextNumber)) {
  14982. if (newNumber === nextNumber) itemNumber = nextNumber + 1;
  14983. if (newNumber > nextNumber) itemNumber = newNumber + 1;
  14984. cm.replaceRange(
  14985. nextLine.replace(listRE, nextIndent + itemNumber + nextItem[4] + nextItem[5]),
  14986. {
  14987. line: nextLineNumber, ch: 0
  14988. }, {
  14989. line: nextLineNumber, ch: nextLine.length
  14990. });
  14991. } else {
  14992. if (startIndent.length > nextIndent.length) return;
  14993. // This doesn't run if the next line immediatley indents, as it is
  14994. // not clear of the users intention (new indented item or same level)
  14995. if ((startIndent.length < nextIndent.length) && (lookAhead === 1)) return;
  14996. skipCount += 1;
  14997. }
  14998. }
  14999. } while (nextItem);
  15000. }
  15001. });
  15002. });
  15003. var xmlFold = createCommonjsModule(function (module, exports) {
  15004. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  15005. // Distributed under an MIT license: https://codemirror.net/LICENSE
  15006. (function(mod) {
  15007. mod(codemirror);
  15008. })(function(CodeMirror) {
  15009. var Pos = CodeMirror.Pos;
  15010. function cmp(a, b) { return a.line - b.line || a.ch - b.ch; }
  15011. var nameStartChar = "A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
  15012. var nameChar = nameStartChar + "\-\:\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
  15013. var xmlTagStart = new RegExp("<(/?)([" + nameStartChar + "][" + nameChar + "]*)", "g");
  15014. function Iter(cm, line, ch, range) {
  15015. this.line = line; this.ch = ch;
  15016. this.cm = cm; this.text = cm.getLine(line);
  15017. this.min = range ? Math.max(range.from, cm.firstLine()) : cm.firstLine();
  15018. this.max = range ? Math.min(range.to - 1, cm.lastLine()) : cm.lastLine();
  15019. }
  15020. function tagAt(iter, ch) {
  15021. var type = iter.cm.getTokenTypeAt(Pos(iter.line, ch));
  15022. return type && /\btag\b/.test(type);
  15023. }
  15024. function nextLine(iter) {
  15025. if (iter.line >= iter.max) return;
  15026. iter.ch = 0;
  15027. iter.text = iter.cm.getLine(++iter.line);
  15028. return true;
  15029. }
  15030. function prevLine(iter) {
  15031. if (iter.line <= iter.min) return;
  15032. iter.text = iter.cm.getLine(--iter.line);
  15033. iter.ch = iter.text.length;
  15034. return true;
  15035. }
  15036. function toTagEnd(iter) {
  15037. for (;;) {
  15038. var gt = iter.text.indexOf(">", iter.ch);
  15039. if (gt == -1) { if (nextLine(iter)) continue; else return; }
  15040. if (!tagAt(iter, gt + 1)) { iter.ch = gt + 1; continue; }
  15041. var lastSlash = iter.text.lastIndexOf("/", gt);
  15042. var selfClose = lastSlash > -1 && !/\S/.test(iter.text.slice(lastSlash + 1, gt));
  15043. iter.ch = gt + 1;
  15044. return selfClose ? "selfClose" : "regular";
  15045. }
  15046. }
  15047. function toTagStart(iter) {
  15048. for (;;) {
  15049. var lt = iter.ch ? iter.text.lastIndexOf("<", iter.ch - 1) : -1;
  15050. if (lt == -1) { if (prevLine(iter)) continue; else return; }
  15051. if (!tagAt(iter, lt + 1)) { iter.ch = lt; continue; }
  15052. xmlTagStart.lastIndex = lt;
  15053. iter.ch = lt;
  15054. var match = xmlTagStart.exec(iter.text);
  15055. if (match && match.index == lt) return match;
  15056. }
  15057. }
  15058. function toNextTag(iter) {
  15059. for (;;) {
  15060. xmlTagStart.lastIndex = iter.ch;
  15061. var found = xmlTagStart.exec(iter.text);
  15062. if (!found) { if (nextLine(iter)) continue; else return; }
  15063. if (!tagAt(iter, found.index + 1)) { iter.ch = found.index + 1; continue; }
  15064. iter.ch = found.index + found[0].length;
  15065. return found;
  15066. }
  15067. }
  15068. function toPrevTag(iter) {
  15069. for (;;) {
  15070. var gt = iter.ch ? iter.text.lastIndexOf(">", iter.ch - 1) : -1;
  15071. if (gt == -1) { if (prevLine(iter)) continue; else return; }
  15072. if (!tagAt(iter, gt + 1)) { iter.ch = gt; continue; }
  15073. var lastSlash = iter.text.lastIndexOf("/", gt);
  15074. var selfClose = lastSlash > -1 && !/\S/.test(iter.text.slice(lastSlash + 1, gt));
  15075. iter.ch = gt + 1;
  15076. return selfClose ? "selfClose" : "regular";
  15077. }
  15078. }
  15079. function findMatchingClose(iter, tag) {
  15080. var stack = [];
  15081. for (;;) {
  15082. var next = toNextTag(iter), end, startLine = iter.line, startCh = iter.ch - (next ? next[0].length : 0);
  15083. if (!next || !(end = toTagEnd(iter))) return;
  15084. if (end == "selfClose") continue;
  15085. if (next[1]) { // closing tag
  15086. for (var i = stack.length - 1; i >= 0; --i) if (stack[i] == next[2]) {
  15087. stack.length = i;
  15088. break;
  15089. }
  15090. if (i < 0 && (!tag || tag == next[2])) return {
  15091. tag: next[2],
  15092. from: Pos(startLine, startCh),
  15093. to: Pos(iter.line, iter.ch)
  15094. };
  15095. } else { // opening tag
  15096. stack.push(next[2]);
  15097. }
  15098. }
  15099. }
  15100. function findMatchingOpen(iter, tag) {
  15101. var stack = [];
  15102. for (;;) {
  15103. var prev = toPrevTag(iter);
  15104. if (!prev) return;
  15105. if (prev == "selfClose") { toTagStart(iter); continue; }
  15106. var endLine = iter.line, endCh = iter.ch;
  15107. var start = toTagStart(iter);
  15108. if (!start) return;
  15109. if (start[1]) { // closing tag
  15110. stack.push(start[2]);
  15111. } else { // opening tag
  15112. for (var i = stack.length - 1; i >= 0; --i) if (stack[i] == start[2]) {
  15113. stack.length = i;
  15114. break;
  15115. }
  15116. if (i < 0 && (!tag || tag == start[2])) return {
  15117. tag: start[2],
  15118. from: Pos(iter.line, iter.ch),
  15119. to: Pos(endLine, endCh)
  15120. };
  15121. }
  15122. }
  15123. }
  15124. CodeMirror.registerHelper("fold", "xml", function(cm, start) {
  15125. var iter = new Iter(cm, start.line, 0);
  15126. for (;;) {
  15127. var openTag = toNextTag(iter);
  15128. if (!openTag || iter.line != start.line) return
  15129. var end = toTagEnd(iter);
  15130. if (!end) return
  15131. if (!openTag[1] && end != "selfClose") {
  15132. var startPos = Pos(iter.line, iter.ch);
  15133. var endPos = findMatchingClose(iter, openTag[2]);
  15134. return endPos && cmp(endPos.from, startPos) > 0 ? {from: startPos, to: endPos.from} : null
  15135. }
  15136. }
  15137. });
  15138. CodeMirror.findMatchingTag = function(cm, pos, range) {
  15139. var iter = new Iter(cm, pos.line, pos.ch, range);
  15140. if (iter.text.indexOf(">") == -1 && iter.text.indexOf("<") == -1) return;
  15141. var end = toTagEnd(iter), to = end && Pos(iter.line, iter.ch);
  15142. var start = end && toTagStart(iter);
  15143. if (!end || !start || cmp(iter, pos) > 0) return;
  15144. var here = {from: Pos(iter.line, iter.ch), to: to, tag: start[2]};
  15145. if (end == "selfClose") return {open: here, close: null, at: "open"};
  15146. if (start[1]) { // closing tag
  15147. return {open: findMatchingOpen(iter, start[2]), close: here, at: "close"};
  15148. } else { // opening tag
  15149. iter = new Iter(cm, to.line, to.ch, range);
  15150. return {open: here, close: findMatchingClose(iter, start[2]), at: "open"};
  15151. }
  15152. };
  15153. CodeMirror.findEnclosingTag = function(cm, pos, range, tag) {
  15154. var iter = new Iter(cm, pos.line, pos.ch, range);
  15155. for (;;) {
  15156. var open = findMatchingOpen(iter, tag);
  15157. if (!open) break;
  15158. var forward = new Iter(cm, pos.line, pos.ch, range);
  15159. var close = findMatchingClose(forward, open.tag);
  15160. if (close) return {open: open, close: close};
  15161. }
  15162. };
  15163. // Used by addon/edit/closetag.js
  15164. CodeMirror.scanForClosingTag = function(cm, pos, name, end) {
  15165. var iter = new Iter(cm, pos.line, pos.ch, end ? {from: 0, to: end} : null);
  15166. return findMatchingClose(iter, name);
  15167. };
  15168. });
  15169. });
  15170. var closetag = createCommonjsModule(function (module, exports) {
  15171. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  15172. // Distributed under an MIT license: https://codemirror.net/LICENSE
  15173. /**
  15174. * Tag-closer extension for CodeMirror.
  15175. *
  15176. * This extension adds an "autoCloseTags" option that can be set to
  15177. * either true to get the default behavior, or an object to further
  15178. * configure its behavior.
  15179. *
  15180. * These are supported options:
  15181. *
  15182. * `whenClosing` (default true)
  15183. * Whether to autoclose when the '/' of a closing tag is typed.
  15184. * `whenOpening` (default true)
  15185. * Whether to autoclose the tag when the final '>' of an opening
  15186. * tag is typed.
  15187. * `dontCloseTags` (default is empty tags for HTML, none for XML)
  15188. * An array of tag names that should not be autoclosed.
  15189. * `indentTags` (default is block tags for HTML, none for XML)
  15190. * An array of tag names that should, when opened, cause a
  15191. * blank line to be added inside the tag, and the blank line and
  15192. * closing line to be indented.
  15193. * `emptyTags` (default is none)
  15194. * An array of XML tag names that should be autoclosed with '/>'.
  15195. *
  15196. * See demos/closetag.html for a usage example.
  15197. */
  15198. (function(mod) {
  15199. mod(codemirror, xmlFold);
  15200. })(function(CodeMirror) {
  15201. CodeMirror.defineOption("autoCloseTags", false, function(cm, val, old) {
  15202. if (old != CodeMirror.Init && old)
  15203. cm.removeKeyMap("autoCloseTags");
  15204. if (!val) return;
  15205. var map = {name: "autoCloseTags"};
  15206. if (typeof val != "object" || val.whenClosing !== false)
  15207. map["'/'"] = function(cm) { return autoCloseSlash(cm); };
  15208. if (typeof val != "object" || val.whenOpening !== false)
  15209. map["'>'"] = function(cm) { return autoCloseGT(cm); };
  15210. cm.addKeyMap(map);
  15211. });
  15212. var htmlDontClose = ["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param",
  15213. "source", "track", "wbr"];
  15214. var htmlIndent = ["applet", "blockquote", "body", "button", "div", "dl", "fieldset", "form", "frameset", "h1", "h2", "h3", "h4",
  15215. "h5", "h6", "head", "html", "iframe", "layer", "legend", "object", "ol", "p", "select", "table", "ul"];
  15216. function autoCloseGT(cm) {
  15217. if (cm.getOption("disableInput")) return CodeMirror.Pass;
  15218. var ranges = cm.listSelections(), replacements = [];
  15219. var opt = cm.getOption("autoCloseTags");
  15220. for (var i = 0; i < ranges.length; i++) {
  15221. if (!ranges[i].empty()) return CodeMirror.Pass;
  15222. var pos = ranges[i].head, tok = cm.getTokenAt(pos);
  15223. var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
  15224. var tagInfo = inner.mode.xmlCurrentTag && inner.mode.xmlCurrentTag(state);
  15225. var tagName = tagInfo && tagInfo.name;
  15226. if (!tagName) return CodeMirror.Pass
  15227. var html = inner.mode.configuration == "html";
  15228. var dontCloseTags = (typeof opt == "object" && opt.dontCloseTags) || (html && htmlDontClose);
  15229. var indentTags = (typeof opt == "object" && opt.indentTags) || (html && htmlIndent);
  15230. if (tok.end > pos.ch) tagName = tagName.slice(0, tagName.length - tok.end + pos.ch);
  15231. var lowerTagName = tagName.toLowerCase();
  15232. // Don't process the '>' at the end of an end-tag or self-closing tag
  15233. if (!tagName ||
  15234. tok.type == "string" && (tok.end != pos.ch || !/[\"\']/.test(tok.string.charAt(tok.string.length - 1)) || tok.string.length == 1) ||
  15235. tok.type == "tag" && tagInfo.close ||
  15236. tok.string.indexOf("/") == (pos.ch - tok.start - 1) || // match something like <someTagName />
  15237. dontCloseTags && indexOf(dontCloseTags, lowerTagName) > -1 ||
  15238. closingTagExists(cm, inner.mode.xmlCurrentContext && inner.mode.xmlCurrentContext(state) || [], tagName, pos, true))
  15239. return CodeMirror.Pass;
  15240. var emptyTags = typeof opt == "object" && opt.emptyTags;
  15241. if (emptyTags && indexOf(emptyTags, tagName) > -1) {
  15242. replacements[i] = { text: "/>", newPos: CodeMirror.Pos(pos.line, pos.ch + 2) };
  15243. continue;
  15244. }
  15245. var indent = indentTags && indexOf(indentTags, lowerTagName) > -1;
  15246. replacements[i] = {indent: indent,
  15247. text: ">" + (indent ? "\n\n" : "") + "</" + tagName + ">",
  15248. newPos: indent ? CodeMirror.Pos(pos.line + 1, 0) : CodeMirror.Pos(pos.line, pos.ch + 1)};
  15249. }
  15250. var dontIndentOnAutoClose = (typeof opt == "object" && opt.dontIndentOnAutoClose);
  15251. for (var i = ranges.length - 1; i >= 0; i--) {
  15252. var info = replacements[i];
  15253. cm.replaceRange(info.text, ranges[i].head, ranges[i].anchor, "+insert");
  15254. var sel = cm.listSelections().slice(0);
  15255. sel[i] = {head: info.newPos, anchor: info.newPos};
  15256. cm.setSelections(sel);
  15257. if (!dontIndentOnAutoClose && info.indent) {
  15258. cm.indentLine(info.newPos.line, null, true);
  15259. cm.indentLine(info.newPos.line + 1, null, true);
  15260. }
  15261. }
  15262. }
  15263. function autoCloseCurrent(cm, typingSlash) {
  15264. var ranges = cm.listSelections(), replacements = [];
  15265. var head = typingSlash ? "/" : "</";
  15266. var opt = cm.getOption("autoCloseTags");
  15267. var dontIndentOnAutoClose = (typeof opt == "object" && opt.dontIndentOnSlash);
  15268. for (var i = 0; i < ranges.length; i++) {
  15269. if (!ranges[i].empty()) return CodeMirror.Pass;
  15270. var pos = ranges[i].head, tok = cm.getTokenAt(pos);
  15271. var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
  15272. if (typingSlash && (tok.type == "string" || tok.string.charAt(0) != "<" ||
  15273. tok.start != pos.ch - 1))
  15274. return CodeMirror.Pass;
  15275. // Kludge to get around the fact that we are not in XML mode
  15276. // when completing in JS/CSS snippet in htmlmixed mode. Does not
  15277. // work for other XML embedded languages (there is no general
  15278. // way to go from a mixed mode to its current XML state).
  15279. var replacement, mixed = inner.mode.name != "xml" && cm.getMode().name == "htmlmixed";
  15280. if (mixed && inner.mode.name == "javascript") {
  15281. replacement = head + "script";
  15282. } else if (mixed && inner.mode.name == "css") {
  15283. replacement = head + "style";
  15284. } else {
  15285. var context = inner.mode.xmlCurrentContext && inner.mode.xmlCurrentContext(state);
  15286. if (!context || (context.length && closingTagExists(cm, context, context[context.length - 1], pos)))
  15287. return CodeMirror.Pass;
  15288. replacement = head + context[context.length - 1];
  15289. }
  15290. if (cm.getLine(pos.line).charAt(tok.end) != ">") replacement += ">";
  15291. replacements[i] = replacement;
  15292. }
  15293. cm.replaceSelections(replacements);
  15294. ranges = cm.listSelections();
  15295. if (!dontIndentOnAutoClose) {
  15296. for (var i = 0; i < ranges.length; i++)
  15297. if (i == ranges.length - 1 || ranges[i].head.line < ranges[i + 1].head.line)
  15298. cm.indentLine(ranges[i].head.line);
  15299. }
  15300. }
  15301. function autoCloseSlash(cm) {
  15302. if (cm.getOption("disableInput")) return CodeMirror.Pass;
  15303. return autoCloseCurrent(cm, true);
  15304. }
  15305. CodeMirror.commands.closeTag = function(cm) { return autoCloseCurrent(cm); };
  15306. function indexOf(collection, elt) {
  15307. if (collection.indexOf) return collection.indexOf(elt);
  15308. for (var i = 0, e = collection.length; i < e; ++i)
  15309. if (collection[i] == elt) return i;
  15310. return -1;
  15311. }
  15312. // If xml-fold is loaded, we use its functionality to try and verify
  15313. // whether a given tag is actually unclosed.
  15314. function closingTagExists(cm, context, tagName, pos, newTag) {
  15315. if (!CodeMirror.scanForClosingTag) return false;
  15316. var end = Math.min(cm.lastLine() + 1, pos.line + 500);
  15317. var nextClose = CodeMirror.scanForClosingTag(cm, pos, null, end);
  15318. if (!nextClose || nextClose.tag != tagName) return false;
  15319. // If the immediate wrapping context contains onCx instances of
  15320. // the same tag, a closing tag only exists if there are at least
  15321. // that many closing tags of that type following.
  15322. var onCx = newTag ? 1 : 0;
  15323. for (var i = context.length - 1; i >= 0; i--) {
  15324. if (context[i] == tagName) ++onCx;
  15325. else break
  15326. }
  15327. pos = nextClose.to;
  15328. for (var i = 1; i < onCx; i++) {
  15329. var next = CodeMirror.scanForClosingTag(cm, pos, null, end);
  15330. if (!next || next.tag != tagName) return false;
  15331. pos = next.to;
  15332. }
  15333. return true;
  15334. }
  15335. });
  15336. });
  15337. var matchtags = createCommonjsModule(function (module, exports) {
  15338. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  15339. // Distributed under an MIT license: https://codemirror.net/LICENSE
  15340. (function(mod) {
  15341. mod(codemirror, xmlFold);
  15342. })(function(CodeMirror) {
  15343. CodeMirror.defineOption("matchTags", false, function(cm, val, old) {
  15344. if (old && old != CodeMirror.Init) {
  15345. cm.off("cursorActivity", doMatchTags);
  15346. cm.off("viewportChange", maybeUpdateMatch);
  15347. clear(cm);
  15348. }
  15349. if (val) {
  15350. cm.state.matchBothTags = typeof val == "object" && val.bothTags;
  15351. cm.on("cursorActivity", doMatchTags);
  15352. cm.on("viewportChange", maybeUpdateMatch);
  15353. doMatchTags(cm);
  15354. }
  15355. });
  15356. function clear(cm) {
  15357. if (cm.state.tagHit) cm.state.tagHit.clear();
  15358. if (cm.state.tagOther) cm.state.tagOther.clear();
  15359. cm.state.tagHit = cm.state.tagOther = null;
  15360. }
  15361. function doMatchTags(cm) {
  15362. cm.state.failedTagMatch = false;
  15363. cm.operation(function() {
  15364. clear(cm);
  15365. if (cm.somethingSelected()) return;
  15366. var cur = cm.getCursor(), range = cm.getViewport();
  15367. range.from = Math.min(range.from, cur.line); range.to = Math.max(cur.line + 1, range.to);
  15368. var match = CodeMirror.findMatchingTag(cm, cur, range);
  15369. if (!match) return;
  15370. if (cm.state.matchBothTags) {
  15371. var hit = match.at == "open" ? match.open : match.close;
  15372. if (hit) cm.state.tagHit = cm.markText(hit.from, hit.to, {className: "CodeMirror-matchingtag"});
  15373. }
  15374. var other = match.at == "close" ? match.open : match.close;
  15375. if (other)
  15376. cm.state.tagOther = cm.markText(other.from, other.to, {className: "CodeMirror-matchingtag"});
  15377. else
  15378. cm.state.failedTagMatch = true;
  15379. });
  15380. }
  15381. function maybeUpdateMatch(cm) {
  15382. if (cm.state.failedTagMatch) doMatchTags(cm);
  15383. }
  15384. CodeMirror.commands.toMatchingTag = function(cm) {
  15385. var found = CodeMirror.findMatchingTag(cm, cm.getCursor());
  15386. if (found) {
  15387. var other = found.at == "close" ? found.open : found.close;
  15388. if (other) cm.extendSelection(other.to, other.from);
  15389. }
  15390. };
  15391. });
  15392. });
  15393. var searchcursor = createCommonjsModule(function (module, exports) {
  15394. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  15395. // Distributed under an MIT license: https://codemirror.net/LICENSE
  15396. (function(mod) {
  15397. mod(codemirror);
  15398. })(function(CodeMirror) {
  15399. var Pos = CodeMirror.Pos;
  15400. function regexpFlags(regexp) {
  15401. var flags = regexp.flags;
  15402. return flags != null ? flags : (regexp.ignoreCase ? "i" : "")
  15403. + (regexp.global ? "g" : "")
  15404. + (regexp.multiline ? "m" : "")
  15405. }
  15406. function ensureFlags(regexp, flags) {
  15407. var current = regexpFlags(regexp), target = current;
  15408. for (var i = 0; i < flags.length; i++) if (target.indexOf(flags.charAt(i)) == -1)
  15409. target += flags.charAt(i);
  15410. return current == target ? regexp : new RegExp(regexp.source, target)
  15411. }
  15412. function maybeMultiline(regexp) {
  15413. return /\\s|\\n|\n|\\W|\\D|\[\^/.test(regexp.source)
  15414. }
  15415. function searchRegexpForward(doc, regexp, start) {
  15416. regexp = ensureFlags(regexp, "g");
  15417. for (var line = start.line, ch = start.ch, last = doc.lastLine(); line <= last; line++, ch = 0) {
  15418. regexp.lastIndex = ch;
  15419. var string = doc.getLine(line), match = regexp.exec(string);
  15420. if (match)
  15421. return {from: Pos(line, match.index),
  15422. to: Pos(line, match.index + match[0].length),
  15423. match: match}
  15424. }
  15425. }
  15426. function searchRegexpForwardMultiline(doc, regexp, start) {
  15427. if (!maybeMultiline(regexp)) return searchRegexpForward(doc, regexp, start)
  15428. regexp = ensureFlags(regexp, "gm");
  15429. var string, chunk = 1;
  15430. for (var line = start.line, last = doc.lastLine(); line <= last;) {
  15431. // This grows the search buffer in exponentially-sized chunks
  15432. // between matches, so that nearby matches are fast and don't
  15433. // require concatenating the whole document (in case we're
  15434. // searching for something that has tons of matches), but at the
  15435. // same time, the amount of retries is limited.
  15436. for (var i = 0; i < chunk; i++) {
  15437. if (line > last) break
  15438. var curLine = doc.getLine(line++);
  15439. string = string == null ? curLine : string + "\n" + curLine;
  15440. }
  15441. chunk = chunk * 2;
  15442. regexp.lastIndex = start.ch;
  15443. var match = regexp.exec(string);
  15444. if (match) {
  15445. var before = string.slice(0, match.index).split("\n"), inside = match[0].split("\n");
  15446. var startLine = start.line + before.length - 1, startCh = before[before.length - 1].length;
  15447. return {from: Pos(startLine, startCh),
  15448. to: Pos(startLine + inside.length - 1,
  15449. inside.length == 1 ? startCh + inside[0].length : inside[inside.length - 1].length),
  15450. match: match}
  15451. }
  15452. }
  15453. }
  15454. function lastMatchIn(string, regexp, endMargin) {
  15455. var match, from = 0;
  15456. while (from <= string.length) {
  15457. regexp.lastIndex = from;
  15458. var newMatch = regexp.exec(string);
  15459. if (!newMatch) break
  15460. var end = newMatch.index + newMatch[0].length;
  15461. if (end > string.length - endMargin) break
  15462. if (!match || end > match.index + match[0].length)
  15463. match = newMatch;
  15464. from = newMatch.index + 1;
  15465. }
  15466. return match
  15467. }
  15468. function searchRegexpBackward(doc, regexp, start) {
  15469. regexp = ensureFlags(regexp, "g");
  15470. for (var line = start.line, ch = start.ch, first = doc.firstLine(); line >= first; line--, ch = -1) {
  15471. var string = doc.getLine(line);
  15472. var match = lastMatchIn(string, regexp, ch < 0 ? 0 : string.length - ch);
  15473. if (match)
  15474. return {from: Pos(line, match.index),
  15475. to: Pos(line, match.index + match[0].length),
  15476. match: match}
  15477. }
  15478. }
  15479. function searchRegexpBackwardMultiline(doc, regexp, start) {
  15480. if (!maybeMultiline(regexp)) return searchRegexpBackward(doc, regexp, start)
  15481. regexp = ensureFlags(regexp, "gm");
  15482. var string, chunkSize = 1, endMargin = doc.getLine(start.line).length - start.ch;
  15483. for (var line = start.line, first = doc.firstLine(); line >= first;) {
  15484. for (var i = 0; i < chunkSize && line >= first; i++) {
  15485. var curLine = doc.getLine(line--);
  15486. string = string == null ? curLine : curLine + "\n" + string;
  15487. }
  15488. chunkSize *= 2;
  15489. var match = lastMatchIn(string, regexp, endMargin);
  15490. if (match) {
  15491. var before = string.slice(0, match.index).split("\n"), inside = match[0].split("\n");
  15492. var startLine = line + before.length, startCh = before[before.length - 1].length;
  15493. return {from: Pos(startLine, startCh),
  15494. to: Pos(startLine + inside.length - 1,
  15495. inside.length == 1 ? startCh + inside[0].length : inside[inside.length - 1].length),
  15496. match: match}
  15497. }
  15498. }
  15499. }
  15500. var doFold, noFold;
  15501. if (String.prototype.normalize) {
  15502. doFold = function(str) { return str.normalize("NFD").toLowerCase() };
  15503. noFold = function(str) { return str.normalize("NFD") };
  15504. } else {
  15505. doFold = function(str) { return str.toLowerCase() };
  15506. noFold = function(str) { return str };
  15507. }
  15508. // Maps a position in a case-folded line back to a position in the original line
  15509. // (compensating for codepoints increasing in number during folding)
  15510. function adjustPos(orig, folded, pos, foldFunc) {
  15511. if (orig.length == folded.length) return pos
  15512. for (var min = 0, max = pos + Math.max(0, orig.length - folded.length);;) {
  15513. if (min == max) return min
  15514. var mid = (min + max) >> 1;
  15515. var len = foldFunc(orig.slice(0, mid)).length;
  15516. if (len == pos) return mid
  15517. else if (len > pos) max = mid;
  15518. else min = mid + 1;
  15519. }
  15520. }
  15521. function searchStringForward(doc, query, start, caseFold) {
  15522. // Empty string would match anything and never progress, so we
  15523. // define it to match nothing instead.
  15524. if (!query.length) return null
  15525. var fold = caseFold ? doFold : noFold;
  15526. var lines = fold(query).split(/\r|\n\r?/);
  15527. search: for (var line = start.line, ch = start.ch, last = doc.lastLine() + 1 - lines.length; line <= last; line++, ch = 0) {
  15528. var orig = doc.getLine(line).slice(ch), string = fold(orig);
  15529. if (lines.length == 1) {
  15530. var found = string.indexOf(lines[0]);
  15531. if (found == -1) continue search
  15532. var start = adjustPos(orig, string, found, fold) + ch;
  15533. return {from: Pos(line, adjustPos(orig, string, found, fold) + ch),
  15534. to: Pos(line, adjustPos(orig, string, found + lines[0].length, fold) + ch)}
  15535. } else {
  15536. var cutFrom = string.length - lines[0].length;
  15537. if (string.slice(cutFrom) != lines[0]) continue search
  15538. for (var i = 1; i < lines.length - 1; i++)
  15539. if (fold(doc.getLine(line + i)) != lines[i]) continue search
  15540. var end = doc.getLine(line + lines.length - 1), endString = fold(end), lastLine = lines[lines.length - 1];
  15541. if (endString.slice(0, lastLine.length) != lastLine) continue search
  15542. return {from: Pos(line, adjustPos(orig, string, cutFrom, fold) + ch),
  15543. to: Pos(line + lines.length - 1, adjustPos(end, endString, lastLine.length, fold))}
  15544. }
  15545. }
  15546. }
  15547. function searchStringBackward(doc, query, start, caseFold) {
  15548. if (!query.length) return null
  15549. var fold = caseFold ? doFold : noFold;
  15550. var lines = fold(query).split(/\r|\n\r?/);
  15551. search: for (var line = start.line, ch = start.ch, first = doc.firstLine() - 1 + lines.length; line >= first; line--, ch = -1) {
  15552. var orig = doc.getLine(line);
  15553. if (ch > -1) orig = orig.slice(0, ch);
  15554. var string = fold(orig);
  15555. if (lines.length == 1) {
  15556. var found = string.lastIndexOf(lines[0]);
  15557. if (found == -1) continue search
  15558. return {from: Pos(line, adjustPos(orig, string, found, fold)),
  15559. to: Pos(line, adjustPos(orig, string, found + lines[0].length, fold))}
  15560. } else {
  15561. var lastLine = lines[lines.length - 1];
  15562. if (string.slice(0, lastLine.length) != lastLine) continue search
  15563. for (var i = 1, start = line - lines.length + 1; i < lines.length - 1; i++)
  15564. if (fold(doc.getLine(start + i)) != lines[i]) continue search
  15565. var top = doc.getLine(line + 1 - lines.length), topString = fold(top);
  15566. if (topString.slice(topString.length - lines[0].length) != lines[0]) continue search
  15567. return {from: Pos(line + 1 - lines.length, adjustPos(top, topString, top.length - lines[0].length, fold)),
  15568. to: Pos(line, adjustPos(orig, string, lastLine.length, fold))}
  15569. }
  15570. }
  15571. }
  15572. function SearchCursor(doc, query, pos, options) {
  15573. this.atOccurrence = false;
  15574. this.doc = doc;
  15575. pos = pos ? doc.clipPos(pos) : Pos(0, 0);
  15576. this.pos = {from: pos, to: pos};
  15577. var caseFold;
  15578. if (typeof options == "object") {
  15579. caseFold = options.caseFold;
  15580. } else { // Backwards compat for when caseFold was the 4th argument
  15581. caseFold = options;
  15582. options = null;
  15583. }
  15584. if (typeof query == "string") {
  15585. if (caseFold == null) caseFold = false;
  15586. this.matches = function(reverse, pos) {
  15587. return (reverse ? searchStringBackward : searchStringForward)(doc, query, pos, caseFold)
  15588. };
  15589. } else {
  15590. query = ensureFlags(query, "gm");
  15591. if (!options || options.multiline !== false)
  15592. this.matches = function(reverse, pos) {
  15593. return (reverse ? searchRegexpBackwardMultiline : searchRegexpForwardMultiline)(doc, query, pos)
  15594. };
  15595. else
  15596. this.matches = function(reverse, pos) {
  15597. return (reverse ? searchRegexpBackward : searchRegexpForward)(doc, query, pos)
  15598. };
  15599. }
  15600. }
  15601. SearchCursor.prototype = {
  15602. findNext: function() {return this.find(false)},
  15603. findPrevious: function() {return this.find(true)},
  15604. find: function(reverse) {
  15605. var result = this.matches(reverse, this.doc.clipPos(reverse ? this.pos.from : this.pos.to));
  15606. // Implements weird auto-growing behavior on null-matches for
  15607. // backwards-compatibility with the vim code (unfortunately)
  15608. while (result && CodeMirror.cmpPos(result.from, result.to) == 0) {
  15609. if (reverse) {
  15610. if (result.from.ch) result.from = Pos(result.from.line, result.from.ch - 1);
  15611. else if (result.from.line == this.doc.firstLine()) result = null;
  15612. else result = this.matches(reverse, this.doc.clipPos(Pos(result.from.line - 1)));
  15613. } else {
  15614. if (result.to.ch < this.doc.getLine(result.to.line).length) result.to = Pos(result.to.line, result.to.ch + 1);
  15615. else if (result.to.line == this.doc.lastLine()) result = null;
  15616. else result = this.matches(reverse, Pos(result.to.line + 1, 0));
  15617. }
  15618. }
  15619. if (result) {
  15620. this.pos = result;
  15621. this.atOccurrence = true;
  15622. return this.pos.match || true
  15623. } else {
  15624. var end = Pos(reverse ? this.doc.firstLine() : this.doc.lastLine() + 1, 0);
  15625. this.pos = {from: end, to: end};
  15626. return this.atOccurrence = false
  15627. }
  15628. },
  15629. from: function() {if (this.atOccurrence) return this.pos.from},
  15630. to: function() {if (this.atOccurrence) return this.pos.to},
  15631. replace: function(newText, origin) {
  15632. if (!this.atOccurrence) return
  15633. var lines = CodeMirror.splitLines(newText);
  15634. this.doc.replaceRange(lines, this.pos.from, this.pos.to, origin);
  15635. this.pos.to = Pos(this.pos.from.line + lines.length - 1,
  15636. lines[lines.length - 1].length + (lines.length == 1 ? this.pos.from.ch : 0));
  15637. }
  15638. };
  15639. CodeMirror.defineExtension("getSearchCursor", function(query, pos, caseFold) {
  15640. return new SearchCursor(this.doc, query, pos, caseFold)
  15641. });
  15642. CodeMirror.defineDocExtension("getSearchCursor", function(query, pos, caseFold) {
  15643. return new SearchCursor(this, query, pos, caseFold)
  15644. });
  15645. CodeMirror.defineExtension("selectMatches", function(query, caseFold) {
  15646. var ranges = [];
  15647. var cur = this.getSearchCursor(query, this.getCursor("from"), caseFold);
  15648. while (cur.findNext()) {
  15649. if (CodeMirror.cmpPos(cur.to(), this.getCursor("to")) > 0) break
  15650. ranges.push({anchor: cur.from(), head: cur.to()});
  15651. }
  15652. if (ranges.length)
  15653. this.setSelections(ranges, 0);
  15654. });
  15655. });
  15656. });
  15657. var placeholder = createCommonjsModule(function (module, exports) {
  15658. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  15659. // Distributed under an MIT license: https://codemirror.net/LICENSE
  15660. (function(mod) {
  15661. mod(codemirror);
  15662. })(function(CodeMirror) {
  15663. CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
  15664. var prev = old && old != CodeMirror.Init;
  15665. if (val && !prev) {
  15666. cm.on("blur", onBlur);
  15667. cm.on("change", onChange);
  15668. cm.on("swapDoc", onChange);
  15669. CodeMirror.on(cm.getInputField(), "compositionupdate", cm.state.placeholderCompose = function() { onComposition(cm); });
  15670. onChange(cm);
  15671. } else if (!val && prev) {
  15672. cm.off("blur", onBlur);
  15673. cm.off("change", onChange);
  15674. cm.off("swapDoc", onChange);
  15675. CodeMirror.off(cm.getInputField(), "compositionupdate", cm.state.placeholderCompose);
  15676. clearPlaceholder(cm);
  15677. var wrapper = cm.getWrapperElement();
  15678. wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
  15679. }
  15680. if (val && !cm.hasFocus()) onBlur(cm);
  15681. });
  15682. function clearPlaceholder(cm) {
  15683. if (cm.state.placeholder) {
  15684. cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
  15685. cm.state.placeholder = null;
  15686. }
  15687. }
  15688. function setPlaceholder(cm) {
  15689. clearPlaceholder(cm);
  15690. var elt = cm.state.placeholder = document.createElement("pre");
  15691. elt.style.cssText = "height: 0; overflow: visible";
  15692. elt.style.direction = cm.getOption("direction");
  15693. elt.className = "CodeMirror-placeholder CodeMirror-line-like";
  15694. var placeHolder = cm.getOption("placeholder");
  15695. if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder);
  15696. elt.appendChild(placeHolder);
  15697. cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
  15698. }
  15699. function onComposition(cm) {
  15700. setTimeout(function() {
  15701. var empty = false, input = cm.getInputField();
  15702. if (input.nodeName == "TEXTAREA")
  15703. empty = !input.value;
  15704. else if (cm.lineCount() == 1)
  15705. empty = !/[^\u200b]/.test(input.querySelector(".CodeMirror-line").textContent);
  15706. if (empty) setPlaceholder(cm);
  15707. else clearPlaceholder(cm);
  15708. }, 20);
  15709. }
  15710. function onBlur(cm) {
  15711. if (isEmpty(cm)) setPlaceholder(cm);
  15712. }
  15713. function onChange(cm) {
  15714. var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
  15715. wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");
  15716. if (empty) setPlaceholder(cm);
  15717. else clearPlaceholder(cm);
  15718. }
  15719. function isEmpty(cm) {
  15720. return (cm.lineCount() === 1) && (cm.getLine(0) === "");
  15721. }
  15722. });
  15723. });
  15724. var matchbrackets = createCommonjsModule(function (module, exports) {
  15725. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  15726. // Distributed under an MIT license: https://codemirror.net/LICENSE
  15727. (function(mod) {
  15728. mod(codemirror);
  15729. })(function(CodeMirror) {
  15730. var ie_lt8 = /MSIE \d/.test(navigator.userAgent) &&
  15731. (document.documentMode == null || document.documentMode < 8);
  15732. var Pos = CodeMirror.Pos;
  15733. var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<", "<": ">>", ">": "<<"};
  15734. function bracketRegex(config) {
  15735. return config && config.bracketRegex || /[(){}[\]]/
  15736. }
  15737. function findMatchingBracket(cm, where, config) {
  15738. var line = cm.getLineHandle(where.line), pos = where.ch - 1;
  15739. var afterCursor = config && config.afterCursor;
  15740. if (afterCursor == null)
  15741. afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className);
  15742. var re = bracketRegex(config);
  15743. // A cursor is defined as between two characters, but in in vim command mode
  15744. // (i.e. not insert mode), the cursor is visually represented as a
  15745. // highlighted box on top of the 2nd character. Otherwise, we allow matches
  15746. // from before or after the cursor.
  15747. var match = (!afterCursor && pos >= 0 && re.test(line.text.charAt(pos)) && matching[line.text.charAt(pos)]) ||
  15748. re.test(line.text.charAt(pos + 1)) && matching[line.text.charAt(++pos)];
  15749. if (!match) return null;
  15750. var dir = match.charAt(1) == ">" ? 1 : -1;
  15751. if (config && config.strict && (dir > 0) != (pos == where.ch)) return null;
  15752. var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
  15753. var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config);
  15754. if (found == null) return null;
  15755. return {from: Pos(where.line, pos), to: found && found.pos,
  15756. match: found && found.ch == match.charAt(0), forward: dir > 0};
  15757. }
  15758. // bracketRegex is used to specify which type of bracket to scan
  15759. // should be a regexp, e.g. /[[\]]/
  15760. //
  15761. // Note: If "where" is on an open bracket, then this bracket is ignored.
  15762. //
  15763. // Returns false when no bracket was found, null when it reached
  15764. // maxScanLines and gave up
  15765. function scanForBracket(cm, where, dir, style, config) {
  15766. var maxScanLen = (config && config.maxScanLineLength) || 10000;
  15767. var maxScanLines = (config && config.maxScanLines) || 1000;
  15768. var stack = [];
  15769. var re = bracketRegex(config);
  15770. var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1)
  15771. : Math.max(cm.firstLine() - 1, where.line - maxScanLines);
  15772. for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) {
  15773. var line = cm.getLine(lineNo);
  15774. if (!line) continue;
  15775. var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1;
  15776. if (line.length > maxScanLen) continue;
  15777. if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
  15778. for (; pos != end; pos += dir) {
  15779. var ch = line.charAt(pos);
  15780. if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
  15781. var match = matching[ch];
  15782. if (match && (match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
  15783. else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
  15784. else stack.pop();
  15785. }
  15786. }
  15787. }
  15788. return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null;
  15789. }
  15790. function matchBrackets(cm, autoclear, config) {
  15791. // Disable brace matching in long lines, since it'll cause hugely slow updates
  15792. var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000;
  15793. var marks = [], ranges = cm.listSelections();
  15794. for (var i = 0; i < ranges.length; i++) {
  15795. var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config);
  15796. if (match && cm.getLine(match.from.line).length <= maxHighlightLen) {
  15797. var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
  15798. marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style}));
  15799. if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen)
  15800. marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style}));
  15801. }
  15802. }
  15803. if (marks.length) {
  15804. // Kludge to work around the IE bug from issue #1193, where text
  15805. // input stops going to the textare whever this fires.
  15806. if (ie_lt8 && cm.state.focused) cm.focus();
  15807. var clear = function() {
  15808. cm.operation(function() {
  15809. for (var i = 0; i < marks.length; i++) marks[i].clear();
  15810. });
  15811. };
  15812. if (autoclear) setTimeout(clear, 800);
  15813. else return clear;
  15814. }
  15815. }
  15816. function doMatchBrackets(cm) {
  15817. cm.operation(function() {
  15818. if (cm.state.matchBrackets.currentlyHighlighted) {
  15819. cm.state.matchBrackets.currentlyHighlighted();
  15820. cm.state.matchBrackets.currentlyHighlighted = null;
  15821. }
  15822. cm.state.matchBrackets.currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets);
  15823. });
  15824. }
  15825. CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
  15826. function clear(cm) {
  15827. if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) {
  15828. cm.state.matchBrackets.currentlyHighlighted();
  15829. cm.state.matchBrackets.currentlyHighlighted = null;
  15830. }
  15831. }
  15832. if (old && old != CodeMirror.Init) {
  15833. cm.off("cursorActivity", doMatchBrackets);
  15834. cm.off("focus", doMatchBrackets);
  15835. cm.off("blur", clear);
  15836. clear(cm);
  15837. }
  15838. if (val) {
  15839. cm.state.matchBrackets = typeof val == "object" ? val : {};
  15840. cm.on("cursorActivity", doMatchBrackets);
  15841. cm.on("focus", doMatchBrackets);
  15842. cm.on("blur", clear);
  15843. }
  15844. });
  15845. CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);});
  15846. CodeMirror.defineExtension("findMatchingBracket", function(pos, config, oldConfig){
  15847. // Backwards-compatibility kludge
  15848. if (oldConfig || typeof config == "boolean") {
  15849. if (!oldConfig) {
  15850. config = config ? {strict: true} : null;
  15851. } else {
  15852. oldConfig.strict = config;
  15853. config = oldConfig;
  15854. }
  15855. }
  15856. return findMatchingBracket(this, pos, config)
  15857. });
  15858. CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){
  15859. return scanForBracket(this, pos, dir, style, config);
  15860. });
  15861. });
  15862. });
  15863. var sublime = createCommonjsModule(function (module, exports) {
  15864. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  15865. // Distributed under an MIT license: https://codemirror.net/LICENSE
  15866. // A rough approximation of Sublime Text's keybindings
  15867. // Depends on addon/search/searchcursor.js and optionally addon/dialog/dialogs.js
  15868. (function(mod) {
  15869. mod(codemirror, searchcursor, matchbrackets);
  15870. })(function(CodeMirror) {
  15871. var cmds = CodeMirror.commands;
  15872. var Pos = CodeMirror.Pos;
  15873. // This is not exactly Sublime's algorithm. I couldn't make heads or tails of that.
  15874. function findPosSubword(doc, start, dir) {
  15875. if (dir < 0 && start.ch == 0) return doc.clipPos(Pos(start.line - 1));
  15876. var line = doc.getLine(start.line);
  15877. if (dir > 0 && start.ch >= line.length) return doc.clipPos(Pos(start.line + 1, 0));
  15878. var state = "start", type, startPos = start.ch;
  15879. for (var pos = startPos, e = dir < 0 ? 0 : line.length, i = 0; pos != e; pos += dir, i++) {
  15880. var next = line.charAt(dir < 0 ? pos - 1 : pos);
  15881. var cat = next != "_" && CodeMirror.isWordChar(next) ? "w" : "o";
  15882. if (cat == "w" && next.toUpperCase() == next) cat = "W";
  15883. if (state == "start") {
  15884. if (cat != "o") { state = "in"; type = cat; }
  15885. else startPos = pos + dir;
  15886. } else if (state == "in") {
  15887. if (type != cat) {
  15888. if (type == "w" && cat == "W" && dir < 0) pos--;
  15889. if (type == "W" && cat == "w" && dir > 0) { // From uppercase to lowercase
  15890. if (pos == startPos + 1) { type = "w"; continue; }
  15891. else pos--;
  15892. }
  15893. break;
  15894. }
  15895. }
  15896. }
  15897. return Pos(start.line, pos);
  15898. }
  15899. function moveSubword(cm, dir) {
  15900. cm.extendSelectionsBy(function(range) {
  15901. if (cm.display.shift || cm.doc.extend || range.empty())
  15902. return findPosSubword(cm.doc, range.head, dir);
  15903. else
  15904. return dir < 0 ? range.from() : range.to();
  15905. });
  15906. }
  15907. cmds.goSubwordLeft = function(cm) { moveSubword(cm, -1); };
  15908. cmds.goSubwordRight = function(cm) { moveSubword(cm, 1); };
  15909. cmds.scrollLineUp = function(cm) {
  15910. var info = cm.getScrollInfo();
  15911. if (!cm.somethingSelected()) {
  15912. var visibleBottomLine = cm.lineAtHeight(info.top + info.clientHeight, "local");
  15913. if (cm.getCursor().line >= visibleBottomLine)
  15914. cm.execCommand("goLineUp");
  15915. }
  15916. cm.scrollTo(null, info.top - cm.defaultTextHeight());
  15917. };
  15918. cmds.scrollLineDown = function(cm) {
  15919. var info = cm.getScrollInfo();
  15920. if (!cm.somethingSelected()) {
  15921. var visibleTopLine = cm.lineAtHeight(info.top, "local")+1;
  15922. if (cm.getCursor().line <= visibleTopLine)
  15923. cm.execCommand("goLineDown");
  15924. }
  15925. cm.scrollTo(null, info.top + cm.defaultTextHeight());
  15926. };
  15927. cmds.splitSelectionByLine = function(cm) {
  15928. var ranges = cm.listSelections(), lineRanges = [];
  15929. for (var i = 0; i < ranges.length; i++) {
  15930. var from = ranges[i].from(), to = ranges[i].to();
  15931. for (var line = from.line; line <= to.line; ++line)
  15932. if (!(to.line > from.line && line == to.line && to.ch == 0))
  15933. lineRanges.push({anchor: line == from.line ? from : Pos(line, 0),
  15934. head: line == to.line ? to : Pos(line)});
  15935. }
  15936. cm.setSelections(lineRanges, 0);
  15937. };
  15938. cmds.singleSelectionTop = function(cm) {
  15939. var range = cm.listSelections()[0];
  15940. cm.setSelection(range.anchor, range.head, {scroll: false});
  15941. };
  15942. cmds.selectLine = function(cm) {
  15943. var ranges = cm.listSelections(), extended = [];
  15944. for (var i = 0; i < ranges.length; i++) {
  15945. var range = ranges[i];
  15946. extended.push({anchor: Pos(range.from().line, 0),
  15947. head: Pos(range.to().line + 1, 0)});
  15948. }
  15949. cm.setSelections(extended);
  15950. };
  15951. function insertLine(cm, above) {
  15952. if (cm.isReadOnly()) return CodeMirror.Pass
  15953. cm.operation(function() {
  15954. var len = cm.listSelections().length, newSelection = [], last = -1;
  15955. for (var i = 0; i < len; i++) {
  15956. var head = cm.listSelections()[i].head;
  15957. if (head.line <= last) continue;
  15958. var at = Pos(head.line + (above ? 0 : 1), 0);
  15959. cm.replaceRange("\n", at, null, "+insertLine");
  15960. cm.indentLine(at.line, null, true);
  15961. newSelection.push({head: at, anchor: at});
  15962. last = head.line + 1;
  15963. }
  15964. cm.setSelections(newSelection);
  15965. });
  15966. cm.execCommand("indentAuto");
  15967. }
  15968. cmds.insertLineAfter = function(cm) { return insertLine(cm, false); };
  15969. cmds.insertLineBefore = function(cm) { return insertLine(cm, true); };
  15970. function wordAt(cm, pos) {
  15971. var start = pos.ch, end = start, line = cm.getLine(pos.line);
  15972. while (start && CodeMirror.isWordChar(line.charAt(start - 1))) --start;
  15973. while (end < line.length && CodeMirror.isWordChar(line.charAt(end))) ++end;
  15974. return {from: Pos(pos.line, start), to: Pos(pos.line, end), word: line.slice(start, end)};
  15975. }
  15976. cmds.selectNextOccurrence = function(cm) {
  15977. var from = cm.getCursor("from"), to = cm.getCursor("to");
  15978. var fullWord = cm.state.sublimeFindFullWord == cm.doc.sel;
  15979. if (CodeMirror.cmpPos(from, to) == 0) {
  15980. var word = wordAt(cm, from);
  15981. if (!word.word) return;
  15982. cm.setSelection(word.from, word.to);
  15983. fullWord = true;
  15984. } else {
  15985. var text = cm.getRange(from, to);
  15986. var query = fullWord ? new RegExp("\\b" + text + "\\b") : text;
  15987. var cur = cm.getSearchCursor(query, to);
  15988. var found = cur.findNext();
  15989. if (!found) {
  15990. cur = cm.getSearchCursor(query, Pos(cm.firstLine(), 0));
  15991. found = cur.findNext();
  15992. }
  15993. if (!found || isSelectedRange(cm.listSelections(), cur.from(), cur.to())) return
  15994. cm.addSelection(cur.from(), cur.to());
  15995. }
  15996. if (fullWord)
  15997. cm.state.sublimeFindFullWord = cm.doc.sel;
  15998. };
  15999. cmds.skipAndSelectNextOccurrence = function(cm) {
  16000. var prevAnchor = cm.getCursor("anchor"), prevHead = cm.getCursor("head");
  16001. cmds.selectNextOccurrence(cm);
  16002. if (CodeMirror.cmpPos(prevAnchor, prevHead) != 0) {
  16003. cm.doc.setSelections(cm.doc.listSelections()
  16004. .filter(function (sel) {
  16005. return sel.anchor != prevAnchor || sel.head != prevHead;
  16006. }));
  16007. }
  16008. };
  16009. function addCursorToSelection(cm, dir) {
  16010. var ranges = cm.listSelections(), newRanges = [];
  16011. for (var i = 0; i < ranges.length; i++) {
  16012. var range = ranges[i];
  16013. var newAnchor = cm.findPosV(
  16014. range.anchor, dir, "line", range.anchor.goalColumn);
  16015. var newHead = cm.findPosV(
  16016. range.head, dir, "line", range.head.goalColumn);
  16017. newAnchor.goalColumn = range.anchor.goalColumn != null ?
  16018. range.anchor.goalColumn : cm.cursorCoords(range.anchor, "div").left;
  16019. newHead.goalColumn = range.head.goalColumn != null ?
  16020. range.head.goalColumn : cm.cursorCoords(range.head, "div").left;
  16021. var newRange = {anchor: newAnchor, head: newHead};
  16022. newRanges.push(range);
  16023. newRanges.push(newRange);
  16024. }
  16025. cm.setSelections(newRanges);
  16026. }
  16027. cmds.addCursorToPrevLine = function(cm) { addCursorToSelection(cm, -1); };
  16028. cmds.addCursorToNextLine = function(cm) { addCursorToSelection(cm, 1); };
  16029. function isSelectedRange(ranges, from, to) {
  16030. for (var i = 0; i < ranges.length; i++)
  16031. if (CodeMirror.cmpPos(ranges[i].from(), from) == 0 &&
  16032. CodeMirror.cmpPos(ranges[i].to(), to) == 0) return true
  16033. return false
  16034. }
  16035. var mirror = "(){}[]";
  16036. function selectBetweenBrackets(cm) {
  16037. var ranges = cm.listSelections(), newRanges = [];
  16038. for (var i = 0; i < ranges.length; i++) {
  16039. var range = ranges[i], pos = range.head, opening = cm.scanForBracket(pos, -1);
  16040. if (!opening) return false;
  16041. for (;;) {
  16042. var closing = cm.scanForBracket(pos, 1);
  16043. if (!closing) return false;
  16044. if (closing.ch == mirror.charAt(mirror.indexOf(opening.ch) + 1)) {
  16045. var startPos = Pos(opening.pos.line, opening.pos.ch + 1);
  16046. if (CodeMirror.cmpPos(startPos, range.from()) == 0 &&
  16047. CodeMirror.cmpPos(closing.pos, range.to()) == 0) {
  16048. opening = cm.scanForBracket(opening.pos, -1);
  16049. if (!opening) return false;
  16050. } else {
  16051. newRanges.push({anchor: startPos, head: closing.pos});
  16052. break;
  16053. }
  16054. }
  16055. pos = Pos(closing.pos.line, closing.pos.ch + 1);
  16056. }
  16057. }
  16058. cm.setSelections(newRanges);
  16059. return true;
  16060. }
  16061. cmds.selectScope = function(cm) {
  16062. selectBetweenBrackets(cm) || cm.execCommand("selectAll");
  16063. };
  16064. cmds.selectBetweenBrackets = function(cm) {
  16065. if (!selectBetweenBrackets(cm)) return CodeMirror.Pass;
  16066. };
  16067. function puncType(type) {
  16068. return !type ? null : /\bpunctuation\b/.test(type) ? type : undefined
  16069. }
  16070. cmds.goToBracket = function(cm) {
  16071. cm.extendSelectionsBy(function(range) {
  16072. var next = cm.scanForBracket(range.head, 1, puncType(cm.getTokenTypeAt(range.head)));
  16073. if (next && CodeMirror.cmpPos(next.pos, range.head) != 0) return next.pos;
  16074. var prev = cm.scanForBracket(range.head, -1, puncType(cm.getTokenTypeAt(Pos(range.head.line, range.head.ch + 1))));
  16075. return prev && Pos(prev.pos.line, prev.pos.ch + 1) || range.head;
  16076. });
  16077. };
  16078. cmds.swapLineUp = function(cm) {
  16079. if (cm.isReadOnly()) return CodeMirror.Pass
  16080. var ranges = cm.listSelections(), linesToMove = [], at = cm.firstLine() - 1, newSels = [];
  16081. for (var i = 0; i < ranges.length; i++) {
  16082. var range = ranges[i], from = range.from().line - 1, to = range.to().line;
  16083. newSels.push({anchor: Pos(range.anchor.line - 1, range.anchor.ch),
  16084. head: Pos(range.head.line - 1, range.head.ch)});
  16085. if (range.to().ch == 0 && !range.empty()) --to;
  16086. if (from > at) linesToMove.push(from, to);
  16087. else if (linesToMove.length) linesToMove[linesToMove.length - 1] = to;
  16088. at = to;
  16089. }
  16090. cm.operation(function() {
  16091. for (var i = 0; i < linesToMove.length; i += 2) {
  16092. var from = linesToMove[i], to = linesToMove[i + 1];
  16093. var line = cm.getLine(from);
  16094. cm.replaceRange("", Pos(from, 0), Pos(from + 1, 0), "+swapLine");
  16095. if (to > cm.lastLine())
  16096. cm.replaceRange("\n" + line, Pos(cm.lastLine()), null, "+swapLine");
  16097. else
  16098. cm.replaceRange(line + "\n", Pos(to, 0), null, "+swapLine");
  16099. }
  16100. cm.setSelections(newSels);
  16101. cm.scrollIntoView();
  16102. });
  16103. };
  16104. cmds.swapLineDown = function(cm) {
  16105. if (cm.isReadOnly()) return CodeMirror.Pass
  16106. var ranges = cm.listSelections(), linesToMove = [], at = cm.lastLine() + 1;
  16107. for (var i = ranges.length - 1; i >= 0; i--) {
  16108. var range = ranges[i], from = range.to().line + 1, to = range.from().line;
  16109. if (range.to().ch == 0 && !range.empty()) from--;
  16110. if (from < at) linesToMove.push(from, to);
  16111. else if (linesToMove.length) linesToMove[linesToMove.length - 1] = to;
  16112. at = to;
  16113. }
  16114. cm.operation(function() {
  16115. for (var i = linesToMove.length - 2; i >= 0; i -= 2) {
  16116. var from = linesToMove[i], to = linesToMove[i + 1];
  16117. var line = cm.getLine(from);
  16118. if (from == cm.lastLine())
  16119. cm.replaceRange("", Pos(from - 1), Pos(from), "+swapLine");
  16120. else
  16121. cm.replaceRange("", Pos(from, 0), Pos(from + 1, 0), "+swapLine");
  16122. cm.replaceRange(line + "\n", Pos(to, 0), null, "+swapLine");
  16123. }
  16124. cm.scrollIntoView();
  16125. });
  16126. };
  16127. cmds.toggleCommentIndented = function(cm) {
  16128. cm.toggleComment({ indent: true });
  16129. };
  16130. cmds.joinLines = function(cm) {
  16131. var ranges = cm.listSelections(), joined = [];
  16132. for (var i = 0; i < ranges.length; i++) {
  16133. var range = ranges[i], from = range.from();
  16134. var start = from.line, end = range.to().line;
  16135. while (i < ranges.length - 1 && ranges[i + 1].from().line == end)
  16136. end = ranges[++i].to().line;
  16137. joined.push({start: start, end: end, anchor: !range.empty() && from});
  16138. }
  16139. cm.operation(function() {
  16140. var offset = 0, ranges = [];
  16141. for (var i = 0; i < joined.length; i++) {
  16142. var obj = joined[i];
  16143. var anchor = obj.anchor && Pos(obj.anchor.line - offset, obj.anchor.ch), head;
  16144. for (var line = obj.start; line <= obj.end; line++) {
  16145. var actual = line - offset;
  16146. if (line == obj.end) head = Pos(actual, cm.getLine(actual).length + 1);
  16147. if (actual < cm.lastLine()) {
  16148. cm.replaceRange(" ", Pos(actual), Pos(actual + 1, /^\s*/.exec(cm.getLine(actual + 1))[0].length));
  16149. ++offset;
  16150. }
  16151. }
  16152. ranges.push({anchor: anchor || head, head: head});
  16153. }
  16154. cm.setSelections(ranges, 0);
  16155. });
  16156. };
  16157. cmds.duplicateLine = function(cm) {
  16158. cm.operation(function() {
  16159. var rangeCount = cm.listSelections().length;
  16160. for (var i = 0; i < rangeCount; i++) {
  16161. var range = cm.listSelections()[i];
  16162. if (range.empty())
  16163. cm.replaceRange(cm.getLine(range.head.line) + "\n", Pos(range.head.line, 0));
  16164. else
  16165. cm.replaceRange(cm.getRange(range.from(), range.to()), range.from());
  16166. }
  16167. cm.scrollIntoView();
  16168. });
  16169. };
  16170. function sortLines(cm, caseSensitive) {
  16171. if (cm.isReadOnly()) return CodeMirror.Pass
  16172. var ranges = cm.listSelections(), toSort = [], selected;
  16173. for (var i = 0; i < ranges.length; i++) {
  16174. var range = ranges[i];
  16175. if (range.empty()) continue;
  16176. var from = range.from().line, to = range.to().line;
  16177. while (i < ranges.length - 1 && ranges[i + 1].from().line == to)
  16178. to = ranges[++i].to().line;
  16179. if (!ranges[i].to().ch) to--;
  16180. toSort.push(from, to);
  16181. }
  16182. if (toSort.length) selected = true;
  16183. else toSort.push(cm.firstLine(), cm.lastLine());
  16184. cm.operation(function() {
  16185. var ranges = [];
  16186. for (var i = 0; i < toSort.length; i += 2) {
  16187. var from = toSort[i], to = toSort[i + 1];
  16188. var start = Pos(from, 0), end = Pos(to);
  16189. var lines = cm.getRange(start, end, false);
  16190. if (caseSensitive)
  16191. lines.sort();
  16192. else
  16193. lines.sort(function(a, b) {
  16194. var au = a.toUpperCase(), bu = b.toUpperCase();
  16195. if (au != bu) { a = au; b = bu; }
  16196. return a < b ? -1 : a == b ? 0 : 1;
  16197. });
  16198. cm.replaceRange(lines, start, end);
  16199. if (selected) ranges.push({anchor: start, head: Pos(to + 1, 0)});
  16200. }
  16201. if (selected) cm.setSelections(ranges, 0);
  16202. });
  16203. }
  16204. cmds.sortLines = function(cm) { sortLines(cm, true); };
  16205. cmds.sortLinesInsensitive = function(cm) { sortLines(cm, false); };
  16206. cmds.nextBookmark = function(cm) {
  16207. var marks = cm.state.sublimeBookmarks;
  16208. if (marks) while (marks.length) {
  16209. var current = marks.shift();
  16210. var found = current.find();
  16211. if (found) {
  16212. marks.push(current);
  16213. return cm.setSelection(found.from, found.to);
  16214. }
  16215. }
  16216. };
  16217. cmds.prevBookmark = function(cm) {
  16218. var marks = cm.state.sublimeBookmarks;
  16219. if (marks) while (marks.length) {
  16220. marks.unshift(marks.pop());
  16221. var found = marks[marks.length - 1].find();
  16222. if (!found)
  16223. marks.pop();
  16224. else
  16225. return cm.setSelection(found.from, found.to);
  16226. }
  16227. };
  16228. cmds.toggleBookmark = function(cm) {
  16229. var ranges = cm.listSelections();
  16230. var marks = cm.state.sublimeBookmarks || (cm.state.sublimeBookmarks = []);
  16231. for (var i = 0; i < ranges.length; i++) {
  16232. var from = ranges[i].from(), to = ranges[i].to();
  16233. var found = ranges[i].empty() ? cm.findMarksAt(from) : cm.findMarks(from, to);
  16234. for (var j = 0; j < found.length; j++) {
  16235. if (found[j].sublimeBookmark) {
  16236. found[j].clear();
  16237. for (var k = 0; k < marks.length; k++)
  16238. if (marks[k] == found[j])
  16239. marks.splice(k--, 1);
  16240. break;
  16241. }
  16242. }
  16243. if (j == found.length)
  16244. marks.push(cm.markText(from, to, {sublimeBookmark: true, clearWhenEmpty: false}));
  16245. }
  16246. };
  16247. cmds.clearBookmarks = function(cm) {
  16248. var marks = cm.state.sublimeBookmarks;
  16249. if (marks) for (var i = 0; i < marks.length; i++) marks[i].clear();
  16250. marks.length = 0;
  16251. };
  16252. cmds.selectBookmarks = function(cm) {
  16253. var marks = cm.state.sublimeBookmarks, ranges = [];
  16254. if (marks) for (var i = 0; i < marks.length; i++) {
  16255. var found = marks[i].find();
  16256. if (!found)
  16257. marks.splice(i--, 0);
  16258. else
  16259. ranges.push({anchor: found.from, head: found.to});
  16260. }
  16261. if (ranges.length)
  16262. cm.setSelections(ranges, 0);
  16263. };
  16264. function modifyWordOrSelection(cm, mod) {
  16265. cm.operation(function() {
  16266. var ranges = cm.listSelections(), indices = [], replacements = [];
  16267. for (var i = 0; i < ranges.length; i++) {
  16268. var range = ranges[i];
  16269. if (range.empty()) { indices.push(i); replacements.push(""); }
  16270. else replacements.push(mod(cm.getRange(range.from(), range.to())));
  16271. }
  16272. cm.replaceSelections(replacements, "around", "case");
  16273. for (var i = indices.length - 1, at; i >= 0; i--) {
  16274. var range = ranges[indices[i]];
  16275. if (at && CodeMirror.cmpPos(range.head, at) > 0) continue;
  16276. var word = wordAt(cm, range.head);
  16277. at = word.from;
  16278. cm.replaceRange(mod(word.word), word.from, word.to);
  16279. }
  16280. });
  16281. }
  16282. cmds.smartBackspace = function(cm) {
  16283. if (cm.somethingSelected()) return CodeMirror.Pass;
  16284. cm.operation(function() {
  16285. var cursors = cm.listSelections();
  16286. var indentUnit = cm.getOption("indentUnit");
  16287. for (var i = cursors.length - 1; i >= 0; i--) {
  16288. var cursor = cursors[i].head;
  16289. var toStartOfLine = cm.getRange({line: cursor.line, ch: 0}, cursor);
  16290. var column = CodeMirror.countColumn(toStartOfLine, null, cm.getOption("tabSize"));
  16291. // Delete by one character by default
  16292. var deletePos = cm.findPosH(cursor, -1, "char", false);
  16293. if (toStartOfLine && !/\S/.test(toStartOfLine) && column % indentUnit == 0) {
  16294. var prevIndent = new Pos(cursor.line,
  16295. CodeMirror.findColumn(toStartOfLine, column - indentUnit, indentUnit));
  16296. // Smart delete only if we found a valid prevIndent location
  16297. if (prevIndent.ch != cursor.ch) deletePos = prevIndent;
  16298. }
  16299. cm.replaceRange("", deletePos, cursor, "+delete");
  16300. }
  16301. });
  16302. };
  16303. cmds.delLineRight = function(cm) {
  16304. cm.operation(function() {
  16305. var ranges = cm.listSelections();
  16306. for (var i = ranges.length - 1; i >= 0; i--)
  16307. cm.replaceRange("", ranges[i].anchor, Pos(ranges[i].to().line), "+delete");
  16308. cm.scrollIntoView();
  16309. });
  16310. };
  16311. cmds.upcaseAtCursor = function(cm) {
  16312. modifyWordOrSelection(cm, function(str) { return str.toUpperCase(); });
  16313. };
  16314. cmds.downcaseAtCursor = function(cm) {
  16315. modifyWordOrSelection(cm, function(str) { return str.toLowerCase(); });
  16316. };
  16317. cmds.setSublimeMark = function(cm) {
  16318. if (cm.state.sublimeMark) cm.state.sublimeMark.clear();
  16319. cm.state.sublimeMark = cm.setBookmark(cm.getCursor());
  16320. };
  16321. cmds.selectToSublimeMark = function(cm) {
  16322. var found = cm.state.sublimeMark && cm.state.sublimeMark.find();
  16323. if (found) cm.setSelection(cm.getCursor(), found);
  16324. };
  16325. cmds.deleteToSublimeMark = function(cm) {
  16326. var found = cm.state.sublimeMark && cm.state.sublimeMark.find();
  16327. if (found) {
  16328. var from = cm.getCursor(), to = found;
  16329. if (CodeMirror.cmpPos(from, to) > 0) { var tmp = to; to = from; from = tmp; }
  16330. cm.state.sublimeKilled = cm.getRange(from, to);
  16331. cm.replaceRange("", from, to);
  16332. }
  16333. };
  16334. cmds.swapWithSublimeMark = function(cm) {
  16335. var found = cm.state.sublimeMark && cm.state.sublimeMark.find();
  16336. if (found) {
  16337. cm.state.sublimeMark.clear();
  16338. cm.state.sublimeMark = cm.setBookmark(cm.getCursor());
  16339. cm.setCursor(found);
  16340. }
  16341. };
  16342. cmds.sublimeYank = function(cm) {
  16343. if (cm.state.sublimeKilled != null)
  16344. cm.replaceSelection(cm.state.sublimeKilled, null, "paste");
  16345. };
  16346. cmds.showInCenter = function(cm) {
  16347. var pos = cm.cursorCoords(null, "local");
  16348. cm.scrollTo(null, (pos.top + pos.bottom) / 2 - cm.getScrollInfo().clientHeight / 2);
  16349. };
  16350. function getTarget(cm) {
  16351. var from = cm.getCursor("from"), to = cm.getCursor("to");
  16352. if (CodeMirror.cmpPos(from, to) == 0) {
  16353. var word = wordAt(cm, from);
  16354. if (!word.word) return;
  16355. from = word.from;
  16356. to = word.to;
  16357. }
  16358. return {from: from, to: to, query: cm.getRange(from, to), word: word};
  16359. }
  16360. function findAndGoTo(cm, forward) {
  16361. var target = getTarget(cm);
  16362. if (!target) return;
  16363. var query = target.query;
  16364. var cur = cm.getSearchCursor(query, forward ? target.to : target.from);
  16365. if (forward ? cur.findNext() : cur.findPrevious()) {
  16366. cm.setSelection(cur.from(), cur.to());
  16367. } else {
  16368. cur = cm.getSearchCursor(query, forward ? Pos(cm.firstLine(), 0)
  16369. : cm.clipPos(Pos(cm.lastLine())));
  16370. if (forward ? cur.findNext() : cur.findPrevious())
  16371. cm.setSelection(cur.from(), cur.to());
  16372. else if (target.word)
  16373. cm.setSelection(target.from, target.to);
  16374. }
  16375. } cmds.findUnder = function(cm) { findAndGoTo(cm, true); };
  16376. cmds.findUnderPrevious = function(cm) { findAndGoTo(cm,false); };
  16377. cmds.findAllUnder = function(cm) {
  16378. var target = getTarget(cm);
  16379. if (!target) return;
  16380. var cur = cm.getSearchCursor(target.query);
  16381. var matches = [];
  16382. var primaryIndex = -1;
  16383. while (cur.findNext()) {
  16384. matches.push({anchor: cur.from(), head: cur.to()});
  16385. if (cur.from().line <= target.from.line && cur.from().ch <= target.from.ch)
  16386. primaryIndex++;
  16387. }
  16388. cm.setSelections(matches, primaryIndex);
  16389. };
  16390. var keyMap = CodeMirror.keyMap;
  16391. keyMap.macSublime = {
  16392. "Cmd-Left": "goLineStartSmart",
  16393. "Shift-Tab": "indentLess",
  16394. "Shift-Ctrl-K": "deleteLine",
  16395. "Alt-Q": "wrapLines",
  16396. "Ctrl-Left": "goSubwordLeft",
  16397. "Ctrl-Right": "goSubwordRight",
  16398. "Ctrl-Alt-Up": "scrollLineUp",
  16399. "Ctrl-Alt-Down": "scrollLineDown",
  16400. "Cmd-L": "selectLine",
  16401. "Shift-Cmd-L": "splitSelectionByLine",
  16402. "Esc": "singleSelectionTop",
  16403. "Cmd-Enter": "insertLineAfter",
  16404. "Shift-Cmd-Enter": "insertLineBefore",
  16405. "Cmd-D": "selectNextOccurrence",
  16406. "Shift-Cmd-Space": "selectScope",
  16407. "Shift-Cmd-M": "selectBetweenBrackets",
  16408. "Cmd-M": "goToBracket",
  16409. "Cmd-Ctrl-Up": "swapLineUp",
  16410. "Cmd-Ctrl-Down": "swapLineDown",
  16411. "Cmd-/": "toggleCommentIndented",
  16412. "Cmd-J": "joinLines",
  16413. "Shift-Cmd-D": "duplicateLine",
  16414. "F5": "sortLines",
  16415. "Cmd-F5": "sortLinesInsensitive",
  16416. "F2": "nextBookmark",
  16417. "Shift-F2": "prevBookmark",
  16418. "Cmd-F2": "toggleBookmark",
  16419. "Shift-Cmd-F2": "clearBookmarks",
  16420. "Alt-F2": "selectBookmarks",
  16421. "Backspace": "smartBackspace",
  16422. "Cmd-K Cmd-D": "skipAndSelectNextOccurrence",
  16423. "Cmd-K Cmd-K": "delLineRight",
  16424. "Cmd-K Cmd-U": "upcaseAtCursor",
  16425. "Cmd-K Cmd-L": "downcaseAtCursor",
  16426. "Cmd-K Cmd-Space": "setSublimeMark",
  16427. "Cmd-K Cmd-A": "selectToSublimeMark",
  16428. "Cmd-K Cmd-W": "deleteToSublimeMark",
  16429. "Cmd-K Cmd-X": "swapWithSublimeMark",
  16430. "Cmd-K Cmd-Y": "sublimeYank",
  16431. "Cmd-K Cmd-C": "showInCenter",
  16432. "Cmd-K Cmd-G": "clearBookmarks",
  16433. "Cmd-K Cmd-Backspace": "delLineLeft",
  16434. "Cmd-K Cmd-1": "foldAll",
  16435. "Cmd-K Cmd-0": "unfoldAll",
  16436. "Cmd-K Cmd-J": "unfoldAll",
  16437. "Ctrl-Shift-Up": "addCursorToPrevLine",
  16438. "Ctrl-Shift-Down": "addCursorToNextLine",
  16439. "Cmd-F3": "findUnder",
  16440. "Shift-Cmd-F3": "findUnderPrevious",
  16441. "Alt-F3": "findAllUnder",
  16442. "Shift-Cmd-[": "fold",
  16443. "Shift-Cmd-]": "unfold",
  16444. "Cmd-I": "findIncremental",
  16445. "Shift-Cmd-I": "findIncrementalReverse",
  16446. "Cmd-H": "replace",
  16447. "F3": "findNext",
  16448. "Shift-F3": "findPrev",
  16449. "fallthrough": "macDefault"
  16450. };
  16451. CodeMirror.normalizeKeyMap(keyMap.macSublime);
  16452. keyMap.pcSublime = {
  16453. "Shift-Tab": "indentLess",
  16454. "Shift-Ctrl-K": "deleteLine",
  16455. "Alt-Q": "wrapLines",
  16456. "Ctrl-T": "transposeChars",
  16457. "Alt-Left": "goSubwordLeft",
  16458. "Alt-Right": "goSubwordRight",
  16459. "Ctrl-Up": "scrollLineUp",
  16460. "Ctrl-Down": "scrollLineDown",
  16461. "Ctrl-L": "selectLine",
  16462. "Shift-Ctrl-L": "splitSelectionByLine",
  16463. "Esc": "singleSelectionTop",
  16464. "Ctrl-Enter": "insertLineAfter",
  16465. "Shift-Ctrl-Enter": "insertLineBefore",
  16466. "Ctrl-D": "selectNextOccurrence",
  16467. "Shift-Ctrl-Space": "selectScope",
  16468. "Shift-Ctrl-M": "selectBetweenBrackets",
  16469. "Ctrl-M": "goToBracket",
  16470. "Shift-Ctrl-Up": "swapLineUp",
  16471. "Shift-Ctrl-Down": "swapLineDown",
  16472. "Ctrl-/": "toggleCommentIndented",
  16473. "Ctrl-J": "joinLines",
  16474. "Shift-Ctrl-D": "duplicateLine",
  16475. "F9": "sortLines",
  16476. "Ctrl-F9": "sortLinesInsensitive",
  16477. "F2": "nextBookmark",
  16478. "Shift-F2": "prevBookmark",
  16479. "Ctrl-F2": "toggleBookmark",
  16480. "Shift-Ctrl-F2": "clearBookmarks",
  16481. "Alt-F2": "selectBookmarks",
  16482. "Backspace": "smartBackspace",
  16483. "Ctrl-K Ctrl-D": "skipAndSelectNextOccurrence",
  16484. "Ctrl-K Ctrl-K": "delLineRight",
  16485. "Ctrl-K Ctrl-U": "upcaseAtCursor",
  16486. "Ctrl-K Ctrl-L": "downcaseAtCursor",
  16487. "Ctrl-K Ctrl-Space": "setSublimeMark",
  16488. "Ctrl-K Ctrl-A": "selectToSublimeMark",
  16489. "Ctrl-K Ctrl-W": "deleteToSublimeMark",
  16490. "Ctrl-K Ctrl-X": "swapWithSublimeMark",
  16491. "Ctrl-K Ctrl-Y": "sublimeYank",
  16492. "Ctrl-K Ctrl-C": "showInCenter",
  16493. "Ctrl-K Ctrl-G": "clearBookmarks",
  16494. "Ctrl-K Ctrl-Backspace": "delLineLeft",
  16495. "Ctrl-K Ctrl-1": "foldAll",
  16496. "Ctrl-K Ctrl-0": "unfoldAll",
  16497. "Ctrl-K Ctrl-J": "unfoldAll",
  16498. "Ctrl-Alt-Up": "addCursorToPrevLine",
  16499. "Ctrl-Alt-Down": "addCursorToNextLine",
  16500. "Ctrl-F3": "findUnder",
  16501. "Shift-Ctrl-F3": "findUnderPrevious",
  16502. "Alt-F3": "findAllUnder",
  16503. "Shift-Ctrl-[": "fold",
  16504. "Shift-Ctrl-]": "unfold",
  16505. "Ctrl-I": "findIncremental",
  16506. "Shift-Ctrl-I": "findIncrementalReverse",
  16507. "Ctrl-H": "replace",
  16508. "F3": "findNext",
  16509. "Shift-F3": "findPrev",
  16510. "fallthrough": "pcDefault"
  16511. };
  16512. CodeMirror.normalizeKeyMap(keyMap.pcSublime);
  16513. var mac = keyMap.default == keyMap.macDefault;
  16514. keyMap.sublime = mac ? keyMap.macSublime : keyMap.pcSublime;
  16515. });
  16516. });
  16517. var search = createCommonjsModule(function (module, exports) {
  16518. (function (mod) {
  16519. mod(codemirror);
  16520. })(function (CodeMirror) {
  16521. var Search;
  16522. CodeMirror.defineOption("searchbox", false, function (cm) {
  16523. cm.addKeyMap({
  16524. "Ctrl-F": function () {
  16525. var cmEle = cm.display.wrapper;
  16526. if (!Search || !cmEle.parentElement.contains(Search.searchBox)) {
  16527. Search = new SearchBox(cm);
  16528. }
  16529. var isReplace = false;
  16530. if (cmEle.parentElement.querySelector("[action=toggleReplace]")) {
  16531. isReplace =
  16532. cmEle.parentElement.querySelector("[action=toggleReplace]")
  16533. .innerText === "-";
  16534. }
  16535. Search.show(cm.getSelection(), isReplace);
  16536. },
  16537. Esc: function () {
  16538. if (!Search || !Search.isVisible()) return CodeMirror.Pass;
  16539. Search.hide();
  16540. if (typeof event !== "undefined") event.stopPropagation();
  16541. },
  16542. "Cmd-F": function () {
  16543. if (!Search) Search = new SearchBox(cm);
  16544. Search.show();
  16545. },
  16546. });
  16547. });
  16548. function SearchBox(cm) {
  16549. var self = this;
  16550. init();
  16551. function initElements(el) {
  16552. self.searchBox = el.querySelector(".ace_search_form");
  16553. self.replaceBox = el.querySelector(".ace_replace_form");
  16554. self.searchOptions = el.querySelector(".ace_search_options");
  16555. self.regExpOption = el.querySelector("[action=toggleRegexpMode]");
  16556. self.caseSensitiveOption = el.querySelector(
  16557. "[action=toggleCaseSensitive]"
  16558. );
  16559. self.wholeWordOption = el.querySelector("[action=toggleWholeWords]");
  16560. self.searchInput = self.searchBox.querySelector(".ace_search_field");
  16561. self.replaceInput = self.replaceBox.querySelector(".ace_search_field");
  16562. }
  16563. function init() {
  16564. var el = (self.element = addHtml());
  16565. addStyle();
  16566. initElements(el);
  16567. bindKeys();
  16568. el.addEventListener("mousedown", function (e) {
  16569. setTimeout(function () {
  16570. self.activeInput.focus();
  16571. }, 0);
  16572. e.stopPropagation();
  16573. });
  16574. el.addEventListener("click", function (e) {
  16575. var t = e.target || e.srcElement;
  16576. var action = t.getAttribute("action");
  16577. if (action && self[action]) self[action]();
  16578. else if (self.commands[action]) self.commands[action]();
  16579. e.stopPropagation();
  16580. });
  16581. self.searchInput.addEventListener("input", function () {
  16582. self.$onChange.schedule(20);
  16583. });
  16584. self.searchInput.addEventListener("focus", function () {
  16585. self.activeInput = self.searchInput;
  16586. });
  16587. self.replaceInput.addEventListener("focus", function () {
  16588. self.activeInput = self.replaceInput;
  16589. });
  16590. self.$onChange = delayedCall(function () {
  16591. self.find(false, false);
  16592. });
  16593. }
  16594. function bindKeys() {
  16595. var sb = self,
  16596. obj = {
  16597. "Ctrl-F|Cmd-F|Ctrl-H|Command-Alt-F": function () {
  16598. var isReplace = (sb.isReplace = !sb.isReplace);
  16599. sb.replaceBox.style.display = isReplace ? "" : "none";
  16600. sb[isReplace ? "replaceInput" : "searchInput"].focus();
  16601. },
  16602. "Ctrl-G|Cmd-G": function () {
  16603. sb.findNext();
  16604. },
  16605. "Ctrl-Shift-G|Cmd-Shift-G": function () {
  16606. sb.findPrev();
  16607. },
  16608. Esc: function () {
  16609. setTimeout(function () {
  16610. sb.hide();
  16611. });
  16612. },
  16613. Enter: function () {
  16614. if (sb.activeInput === sb.replaceInput) sb.replace();
  16615. sb.findNext();
  16616. },
  16617. "Shift-Enter": function () {
  16618. if (sb.activeInput === sb.replaceInput) sb.replace();
  16619. sb.findPrev();
  16620. },
  16621. "Alt-Enter": function () {
  16622. if (sb.activeInput === sb.replaceInput) sb.replaceAll();
  16623. sb.findAll();
  16624. },
  16625. Tab: function () {
  16626. if (self.activeInput === self.replaceInput)
  16627. self.searchInput.focus();
  16628. else self.replaceInput.focus();
  16629. },
  16630. };
  16631. self.element.addEventListener("keydown", function (event) {
  16632. Object.keys(obj).some(function (name) {
  16633. var is = key(name, event);
  16634. if (is) {
  16635. event.stopPropagation();
  16636. event.preventDefault();
  16637. obj[name](event);
  16638. }
  16639. return is;
  16640. });
  16641. });
  16642. }
  16643. this.commands = {
  16644. toggleRegexpMode: function () {
  16645. self.regExpOption.checked = !self.regExpOption.checked;
  16646. self.$syncOptions();
  16647. },
  16648. toggleCaseSensitive: function () {
  16649. self.caseSensitiveOption.checked = !self.caseSensitiveOption.checked;
  16650. self.$syncOptions();
  16651. },
  16652. toggleWholeWords: function () {
  16653. self.wholeWordOption.checked = !self.wholeWordOption.checked;
  16654. self.$syncOptions();
  16655. },
  16656. };
  16657. this.$syncOptions = function () {
  16658. setCssClass(this.regExpOption, "checked", this.regExpOption.checked);
  16659. setCssClass(
  16660. this.wholeWordOption,
  16661. "checked",
  16662. this.wholeWordOption.checked
  16663. );
  16664. setCssClass(
  16665. this.caseSensitiveOption,
  16666. "checked",
  16667. this.caseSensitiveOption.checked
  16668. );
  16669. this.find(false, false);
  16670. };
  16671. this.find = function (skipCurrent, backwards) {
  16672. var value = this.searchInput.value,
  16673. options = {
  16674. skipCurrent: skipCurrent,
  16675. backwards: backwards,
  16676. regExp: this.regExpOption.checked,
  16677. caseSensitive: this.caseSensitiveOption.checked,
  16678. wholeWord: this.wholeWordOption.checked,
  16679. };
  16680. find(value, options, function (searchCursor) {
  16681. var current = searchCursor.matches(false, searchCursor.from());
  16682. cm.setSelection(current.from, current.to);
  16683. });
  16684. };
  16685. function find(value, options, callback) {
  16686. if (!value) {
  16687. clearSearch(cm);
  16688. updateCount();
  16689. return;
  16690. }
  16691. var done,
  16692. noMatch,
  16693. searchCursor,
  16694. next,
  16695. prev,
  16696. matches,
  16697. cursor,
  16698. position,
  16699. val = value,
  16700. o = options,
  16701. is = true,
  16702. caseSensitive = o.caseSensitive,
  16703. regExp = o.regExp,
  16704. wholeWord = o.wholeWord;
  16705. if (regExp) {
  16706. val = val.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
  16707. }
  16708. if (wholeWord) {
  16709. if (caseSensitive) {
  16710. val = val = RegExp("\\b" + val + "\\b");
  16711. } else {
  16712. val = RegExp("\\b" + val + "\\b", "i");
  16713. }
  16714. }
  16715. if (regExp) {
  16716. val = RegExp(val);
  16717. }
  16718. clearSearch(cm);
  16719. doSearch(cm, val, caseSensitive);
  16720. updateCount();
  16721. if (o.backwards) position = o.skipCurrent ? "from" : "to";
  16722. else position = o.skipCurrent ? "to" : "from";
  16723. cursor = cm.getCursor(position);
  16724. searchCursor = cm.getSearchCursor(val, cursor, !caseSensitive);
  16725. (next = searchCursor.findNext.bind(searchCursor)),
  16726. (prev = searchCursor.findPrevious.bind(searchCursor)),
  16727. (matches = searchCursor.matches.bind(searchCursor));
  16728. if (o.backwards && !prev()) {
  16729. is = next();
  16730. if (is) {
  16731. cm.setCursor(cm.doc.size - 1, 0);
  16732. find(value, options, callback);
  16733. done = true;
  16734. }
  16735. } else if (!o.backwards && !next()) {
  16736. is = prev();
  16737. if (is) {
  16738. cm.setCursor(0, 0);
  16739. find(value, options, callback);
  16740. done = true;
  16741. }
  16742. }
  16743. noMatch = !is && self.searchInput.value;
  16744. setCssClass(self.searchBox, "ace_nomatch", noMatch);
  16745. if (!done && is) callback(searchCursor);
  16746. }
  16747. this.findNext = function () {
  16748. this.find(true, false);
  16749. };
  16750. this.findPrev = function () {
  16751. this.find(true, true);
  16752. };
  16753. this.findAll = function () {
  16754. var value = this.searchInput.value,
  16755. noMatch = this.searchInput.value;
  16756. setCssClass(this.searchBox, "ace_nomatch", noMatch);
  16757. if (cm.showMatchesOnScrollbar) cm.showMatchesOnScrollbar(value);
  16758. this.hide();
  16759. };
  16760. this.replace = function () {
  16761. var readOnly = cm.getOption("readOnly"),
  16762. isSelection = !!cm.getSelection();
  16763. if (!readOnly && isSelection)
  16764. cm.replaceSelection(this.replaceInput.value, "start");
  16765. updateCount();
  16766. };
  16767. this.replaceAndFindNext = function () {
  16768. var readOnly = cm.getOption("readOnly");
  16769. if (!readOnly) {
  16770. this.replace();
  16771. this.findNext();
  16772. }
  16773. };
  16774. this.replaceAll = function () {
  16775. var value,
  16776. cursor,
  16777. from = this.searchInput.value,
  16778. to = this.replaceInput.value,
  16779. reg = RegExp(from, this.caseSensitiveOption.checked ? "g" : "gi");
  16780. if (this.wholeWordOption.checked && !this.regExpOption.checked) {
  16781. if (this.caseSensitiveOption.checked) {
  16782. reg = RegExp("\\b" + from + "\\b", 'g');
  16783. } else {
  16784. reg = RegExp("\\b" + from + "\\b", "gi");
  16785. }
  16786. }
  16787. if (!cm.getOption("readOnly") && cm.getSelection()) {
  16788. cursor = cm.getCursor();
  16789. value = cm.getValue();
  16790. value = value.replace(reg, to);
  16791. cm.setValue(value);
  16792. cm.setCursor(cursor);
  16793. }
  16794. updateCount();
  16795. };
  16796. this.toggleReplace = function () {
  16797. var cmEle = cm.display.wrapper;
  16798. if (
  16799. cmEle.parentElement.querySelector("[action=toggleReplace]")
  16800. .innerText === "+"
  16801. ) {
  16802. cmEle.parentElement.querySelector("[action=toggleReplace]").innerText =
  16803. "-";
  16804. this.replaceBox.style.display = "";
  16805. this.isReplace = true;
  16806. } else {
  16807. cmEle.parentElement.querySelector("[action=toggleReplace]").innerText =
  16808. "+";
  16809. this.replaceBox.style.display = "none";
  16810. this.isReplace = false;
  16811. }
  16812. };
  16813. this.hide = function () {
  16814. clearSearch(cm);
  16815. var cmEle = cm.getWrapperElement();
  16816. Search = null;
  16817. cmEle.removeChild(this.element);
  16818. cm.focus();
  16819. };
  16820. this.isVisible = function () {
  16821. var is = this.element.style.display === "";
  16822. return is;
  16823. };
  16824. this.show = function (value, isReplace) {
  16825. this.element.style.display = "";
  16826. if (!isReplace) {
  16827. this.replaceBox.style.display = isReplace ? "" : "none";
  16828. }
  16829. this.isReplace = isReplace;
  16830. if (value) {
  16831. this.searchInput.value = value;
  16832. this.find(false, false);
  16833. }
  16834. this.searchInput.focus();
  16835. this.searchInput.select();
  16836. };
  16837. this.isFocused = function () {
  16838. var el = document.activeElement;
  16839. return el === this.searchInput || el === this.replaceInput;
  16840. };
  16841. function doSearch(cm, value, caseSensitive) {
  16842. var state = getSearchState(cm);
  16843. var query = value;
  16844. if (query && query !== state.queryText) {
  16845. startSearch(cm, state, query, caseSensitive);
  16846. state.posFrom = state.posTo = cm.getCursor();
  16847. }
  16848. }
  16849. function parseString(string) {
  16850. return string.replace(/\\([nrt\\])/g, function (match, ch) {
  16851. if (ch == "n") return "\n";
  16852. if (ch == "r") return "\r";
  16853. if (ch == "t") return "\t";
  16854. if (ch == "\\") return "\\";
  16855. return match;
  16856. });
  16857. }
  16858. function parseQuery(query) {
  16859. var reStr = typeof query === "object" ? query.toString() : query;
  16860. var isRE = reStr.match(/^\/(.*)\/([a-z]*)$/);
  16861. if (isRE) {
  16862. try {
  16863. query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i");
  16864. } catch (e) {} // Not a regular expression after all, do a string search
  16865. } else {
  16866. query = parseString(query);
  16867. }
  16868. if (typeof query == "string" ? query == "" : query.test("")) query = /x^/;
  16869. return query;
  16870. }
  16871. function startSearch(cm, state, query, caseSensitive) {
  16872. state.queryText = query;
  16873. state.query = parseQuery(query);
  16874. cm.removeOverlay(
  16875. state.overlay,
  16876. queryCaseInsensitive(state.query, caseSensitive)
  16877. );
  16878. state.overlay = searchOverlay(
  16879. state.query,
  16880. queryCaseInsensitive(state.query, caseSensitive)
  16881. );
  16882. cm.addOverlay(state.overlay);
  16883. if (cm.showMatchesOnScrollbar) {
  16884. if (state.annotate) {
  16885. state.annotate.clear();
  16886. state.annotate = null;
  16887. }
  16888. state.annotate = cm.showMatchesOnScrollbar(
  16889. state.query,
  16890. queryCaseInsensitive(state.query, caseSensitive)
  16891. );
  16892. }
  16893. }
  16894. function queryCaseInsensitive(query, caseSensitive) {
  16895. return typeof query == "string" && !caseSensitive;
  16896. }
  16897. function searchOverlay(query, caseInsensitive) {
  16898. if (typeof query == "string")
  16899. query = new RegExp(
  16900. query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"),
  16901. caseInsensitive ? "gi" : "g"
  16902. );
  16903. else if (!query.global)
  16904. query = new RegExp(query.source, query.ignoreCase ? "gi" : "g");
  16905. return {
  16906. token: function (stream) {
  16907. query.lastIndex = stream.pos;
  16908. var match = query.exec(stream.string);
  16909. if (match && match.index == stream.pos) {
  16910. stream.pos += match[0].length || 1;
  16911. return "searching";
  16912. } else if (match) {
  16913. stream.pos = match.index;
  16914. } else {
  16915. stream.skipToEnd();
  16916. }
  16917. },
  16918. };
  16919. }
  16920. function SearchState() {
  16921. this.posFrom = this.posTo = this.lastQuery = this.query = null;
  16922. this.overlay = null;
  16923. }
  16924. function getSearchState(cm) {
  16925. return cm.state.search || (cm.state.search = new SearchState());
  16926. }
  16927. function clearSearch(cm) {
  16928. cm.operation(function () {
  16929. var state = getSearchState(cm);
  16930. state.lastQuery = state.query;
  16931. if (!state.query) return;
  16932. state.query = state.queryText = null;
  16933. cm.removeOverlay(state.overlay);
  16934. if (state.annotate) {
  16935. state.annotate.clear();
  16936. state.annotate = null;
  16937. }
  16938. });
  16939. }
  16940. function updateCount() {
  16941. var val = self.searchInput.value;
  16942. var matches = [];
  16943. if (val) {
  16944. val = val.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
  16945. var reg;
  16946. if (self.caseSensitiveOption.checked) {
  16947. reg = RegExp(val, "g");
  16948. } else {
  16949. reg = RegExp(val, "gi");
  16950. }
  16951. if (self.wholeWordOption.checked) {
  16952. if (self.caseSensitiveOption.checked) {
  16953. reg = RegExp("\\b" + val + "\\b", "g");
  16954. } else {
  16955. reg = RegExp("\\b" + val + "\\b", "gi");
  16956. }
  16957. }
  16958. if (self.regExpOption.checked) {
  16959. reg = RegExp(val, "gi");
  16960. }
  16961. matches = cm.getValue().match(reg);
  16962. }
  16963. var count = matches ? matches.length : 0;
  16964. var cmEle = cm.display.wrapper;
  16965. var countEle = cmEle.parentElement.querySelector(".ace_search_counter");
  16966. if (countEle) {
  16967. countEle.innerText = count + " matches found.";
  16968. }
  16969. if (count === 0){
  16970. cm.setSelection({ch: 0, line: 0},{ch: 0, line: 0});
  16971. }
  16972. }
  16973. function addStyle() {
  16974. var style = document.createElement("style"),
  16975. css = [
  16976. ".ace_search {",
  16977. "color: black;",
  16978. "background-color: #ddd;",
  16979. "border: 1px solid #cbcbcb;",
  16980. "border-top: 0 none;",
  16981. "max-width: 325px;",
  16982. "overflow: hidden;",
  16983. "margin: 0;",
  16984. "padding: 4px;",
  16985. "padding-right: 6px;",
  16986. "padding-bottom: 0;",
  16987. "position: absolute;",
  16988. "top: 0px;",
  16989. "z-index: 99;",
  16990. "white-space: normal;",
  16991. "font-size: 12px;",
  16992. "}",
  16993. ".ace_search.left {",
  16994. "border-left: 0 none;",
  16995. "border-radius: 0px 0px 5px 0px;",
  16996. "left: 0;",
  16997. "}",
  16998. ".ace_search.right {",
  16999. "border-radius: 0px 0px 0px 5px;",
  17000. "border-right: 0 none;",
  17001. "right: 0;",
  17002. "}",
  17003. ".ace_search_form, .ace_replace_form {",
  17004. "border-radius: 3px;",
  17005. "border: 1px solid #cbcbcb;",
  17006. "float: left;",
  17007. "margin-bottom: 4px;",
  17008. "overflow: hidden;",
  17009. "}",
  17010. ".ace_search_form.ace_nomatch {",
  17011. "outline: 1px solid red;",
  17012. "}",
  17013. ".ace_search_field {",
  17014. "background-color: white;",
  17015. "border-right: 1px solid #cbcbcb;",
  17016. "border: 0 none;",
  17017. "-webkit-box-sizing: border-box;",
  17018. "-moz-box-sizing: border-box;",
  17019. "box-sizing: border-box;",
  17020. "float: left;",
  17021. "height: 22px;",
  17022. "outline: 0;",
  17023. "padding: 0 7px;",
  17024. "width: 238px;",
  17025. "margin: 0;",
  17026. "}",
  17027. ".ace_searchbtn,",
  17028. ".ace_replacebtn {",
  17029. "background: #fff;",
  17030. "border: 0 none;",
  17031. "border-left: 1px solid #dcdcdc;",
  17032. "cursor: pointer;",
  17033. "float: left;",
  17034. "height: 22px;",
  17035. "padding: 0 5px;",
  17036. "margin: 0;",
  17037. "position: relative;",
  17038. "}",
  17039. ".ace_searchbtn:last-child,",
  17040. ".ace_replacebtn:last-child {",
  17041. "border-top-right-radius: 3px;",
  17042. "border-bottom-right-radius: 3px;",
  17043. "}",
  17044. ".ace_searchbtn:disabled {",
  17045. "background: none;",
  17046. "cursor: default;",
  17047. "}",
  17048. ".ace_searchbtn {",
  17049. "background-position: 50% 50%;",
  17050. "background-repeat: no-repeat;",
  17051. "width: 27px;",
  17052. "}",
  17053. ".ace_searchbtn.prev {",
  17054. "background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAFCAYAAAB4ka1VAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADFJREFUeNpiSU1NZUAC/6E0I0yACYskCpsJiySKIiY0SUZk40FyTEgCjGgKwTRAgAEAQJUIPCE+qfkAAAAASUVORK5CYII=); ",
  17055. "}",
  17056. ".ace_searchbtn.next {",
  17057. "background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAFCAYAAAB4ka1VAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADRJREFUeNpiTE1NZQCC/0DMyIAKwGJMUAYDEo3M/s+EpvM/mkKwCQxYjIeLMaELoLMBAgwAU7UJObTKsvAAAAAASUVORK5CYII=); ",
  17058. "}",
  17059. ".ace_searchbtn_close {",
  17060. "background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAcCAYAAABRVo5BAAAAZ0lEQVR42u2SUQrAMAhDvazn8OjZBilCkYVVxiis8H4CT0VrAJb4WHT3C5xU2a2IQZXJjiQIRMdkEoJ5Q2yMqpfDIo+XY4k6h+YXOyKqTIj5REaxloNAd0xiKmAtsTHqW8sR2W5f7gCu5nWFUpVjZwAAAABJRU5ErkJggg==) no-repeat 50% 0;",
  17061. "border-radius: 50%;",
  17062. "border: 0 none;",
  17063. "color: #656565;",
  17064. "cursor: pointer;",
  17065. "float: right;",
  17066. "font: 16px/16px Arial;",
  17067. "height: 14px;",
  17068. "margin: 5px 1px 9px 5px;",
  17069. "padding: 0;",
  17070. "text-align: center;",
  17071. "width: 14px;",
  17072. "}",
  17073. ".ace_searchbtn_close:hover {",
  17074. "background-color: #656565;",
  17075. "background-position: 50% 100%;",
  17076. "color: white;",
  17077. "}",
  17078. ".ace_replacebtn.prev {",
  17079. "width: 54px",
  17080. "}",
  17081. ".ace_replacebtn.next {",
  17082. "width: 27px",
  17083. "}",
  17084. ".ace_button {",
  17085. "margin-left: 2px;",
  17086. "cursor: pointer;",
  17087. "-webkit-user-select: none;",
  17088. "-moz-user-select: none;",
  17089. "-o-user-select: none;",
  17090. "-ms-user-select: none;",
  17091. "user-select: none;",
  17092. "overflow: hidden;",
  17093. "opacity: 0.7;",
  17094. "border: 1px solid rgba(100,100,100,0.23);",
  17095. "padding: 1px;",
  17096. "-moz-box-sizing: border-box;",
  17097. "box-sizing: border-box;",
  17098. "color: black;",
  17099. "}",
  17100. ".ace_button:hover {",
  17101. "background-color: #eee;",
  17102. "opacity:1;",
  17103. "}",
  17104. ".ace_button:active {",
  17105. "background-color: #ddd;",
  17106. "}",
  17107. ".ace_button.checked {",
  17108. "border-color: #3399ff;",
  17109. "opacity:1;",
  17110. "}",
  17111. ".ace_search_options{",
  17112. "clear: both;",
  17113. "margin: 4px 0;",
  17114. "text-align: right;",
  17115. "-webkit-user-select: none;",
  17116. "-moz-user-select: none;",
  17117. "-o-user-select: none;",
  17118. "-ms-user-select: none;",
  17119. "user-select: none;",
  17120. "}",
  17121. ".replace_toggle{",
  17122. "float: left;",
  17123. "margin-top: -2px;",
  17124. "padding: 0 5px;",
  17125. " }",
  17126. ".ace_search_counter{",
  17127. "float: left;",
  17128. "font-family: arial;",
  17129. "padding: 0 8px;",
  17130. "}",
  17131. "button svg,path {",
  17132. "pointer-events: none;",
  17133. "}",
  17134. ].join("");
  17135. style.setAttribute("data-name", "js-searchbox");
  17136. style.textContent = css;
  17137. document.head.appendChild(style);
  17138. }
  17139. function addHtml() {
  17140. var elSearch,
  17141. el = cm.getWrapperElement(),
  17142. div = document.createElement("div"),
  17143. html = [
  17144. '<div class="ace_search right">',
  17145. '<button type="button" action="hide" class="ace_searchbtn_close"></button>',
  17146. '<div class="ace_search_form">',
  17147. '<input class="ace_search_field" placeholder="Search for" spellcheck="false"></input>',
  17148. '<button type="button" action="findNext" class="ace_searchbtn next"></button>',
  17149. '<button type="button" action="findPrev" class="ace_searchbtn prev"></button>',
  17150. "</div>",
  17151. '<div class="ace_replace_form">',
  17152. '<input class="ace_search_field" placeholder="Replace with" spellcheck="false"></input>',
  17153. '<button type="button" action="replaceAndFindNext" title="Replace" class="ace_replacebtn">',
  17154. '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">',
  17155. '<path fill-rule="evenodd" clip-rule="evenodd" d="M3.221 3.739L5.482 6.008L7.7 3.784L7 3.084L5.988 4.091L5.98 2.491C5.97909 2.35567 6.03068 2.22525 6.12392 2.12716C6.21716 2.02908 6.3448 1.97095 6.48 1.965H8V1H6.48C6.28496 1.00026 6.09189 1.03902 5.91186 1.11405C5.73183 1.18908 5.56838 1.29892 5.43088 1.43725C5.29338 1.57558 5.18455 1.73969 5.11061 1.92018C5.03667 2.10066 4.99908 2.29396 5 2.489V4.1L3.927 3.033L3.221 3.739ZM9.89014 5.53277H9.90141C10.0836 5.84426 10.3521 6 10.707 6C11.0995 6 11.4131 5.83236 11.6479 5.49708C11.8826 5.1618 12 4.71728 12 4.16353C12 3.65304 11.8995 3.2507 11.6986 2.95652C11.4977 2.66234 11.2113 2.51525 10.8394 2.51525C10.4338 2.51525 10.1211 2.70885 9.90141 3.09604H9.89014V1H9V5.91888H9.89014V5.53277ZM9.87606 4.47177V4.13108C9.87606 3.88449 9.93427 3.6844 10.0507 3.53082C10.169 3.37724 10.3174 3.30045 10.4958 3.30045C10.6854 3.30045 10.831 3.37833 10.9324 3.53407C11.0357 3.68765 11.0873 3.9018 11.0873 4.17651C11.0873 4.50746 11.031 4.76379 10.9183 4.94549C10.8075 5.12503 10.6507 5.2148 10.4479 5.2148C10.2808 5.2148 10.1437 5.14449 10.0366 5.00389C9.92958 4.86329 9.87606 4.68592 9.87606 4.47177ZM9 12.7691C8.74433 12.923 8.37515 13 7.89247 13C7.32855 13 6.87216 12.8225 6.5233 12.4674C6.17443 12.1124 6 11.6543 6 11.0931C6 10.4451 6.18638 9.93484 6.55914 9.5624C6.93429 9.18747 7.43489 9.00001 8.06093 9.00001C8.49343 9.00001 8.80645 9.0596 9 9.17878V10.1769C8.76344 9.99319 8.4994 9.90132 8.20789 9.90132C7.88292 9.90132 7.62485 10.0006 7.43369 10.1993C7.24492 10.3954 7.15054 10.6673 7.15054 11.0149C7.15054 11.3526 7.24134 11.6183 7.42294 11.8119C7.60454 12.0031 7.85424 12.0987 8.17204 12.0987C8.454 12.0987 8.72999 12.0068 9 11.8231V12.7691ZM4 7L3 8V14L4 15H11L12 14V8L11 7H4ZM4 8H5H10H11V9V13V14H10H5H4V13V9V8Z" fill="#656565"/>',
  17156. "</svg></button>",
  17157. '<button type="button" action="replaceAll" title="Replace All" class="ace_replacebtn">',
  17158. '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">',
  17159. '<path fill-rule="evenodd" clip-rule="evenodd" d="M11.6009 2.67683C11.7474 2.36708 11.9559 2.2122 12.2263 2.2122C12.4742 2.2122 12.6651 2.32987 12.7991 2.56522C12.933 2.80056 13 3.12243 13 3.53082C13 3.97383 12.9218 4.32944 12.7653 4.59766C12.6088 4.86589 12.3997 5 12.138 5C11.9014 5 11.7224 4.87541 11.6009 4.62622H11.5934V4.93511H11V1H11.5934V2.67683H11.6009ZM11.584 3.77742C11.584 3.94873 11.6197 4.09063 11.6911 4.20311C11.7624 4.3156 11.8538 4.37184 11.9653 4.37184C12.1005 4.37184 12.205 4.30002 12.2789 4.15639C12.354 4.01103 12.3915 3.80597 12.3915 3.54121C12.3915 3.32144 12.3571 3.15012 12.2883 3.02726C12.2207 2.90266 12.1236 2.84036 11.9972 2.84036C11.8782 2.84036 11.7793 2.9018 11.7005 3.02466C11.6228 3.14752 11.584 3.30759 11.584 3.50487V3.77742ZM4.11969 7.695L2 5.56781L2.66188 4.90594L3.66781 5.90625V4.39594C3.66695 4.21309 3.70219 4.03187 3.7715 3.86266C3.84082 3.69346 3.94286 3.53961 4.07176 3.40992C4.20066 3.28023 4.3539 3.17727 4.52268 3.10692C4.69146 3.03658 4.87246 3.00024 5.05531 3H7.39906V3.90469H5.05531C4.92856 3.91026 4.8089 3.96476 4.72149 4.05672C4.63408 4.14868 4.58571 4.27094 4.58656 4.39781L4.59406 5.89781L5.54281 4.95375L6.19906 5.61L4.11969 7.695ZM9.3556 4.93017H10V3.22067C10 2.40689 9.68534 2 9.05603 2C8.92098 2 8.77083 2.02421 8.6056 2.07263C8.44181 2.12104 8.3125 2.17691 8.21767 2.24022V2.90503C8.45474 2.70205 8.70474 2.60056 8.96767 2.60056C9.22917 2.60056 9.35991 2.75698 9.35991 3.06983L8.76078 3.17318C8.25359 3.25885 8 3.57914 8 4.13408C8 4.39665 8.06106 4.60708 8.18319 4.76536C8.30675 4.92179 8.47557 5 8.68966 5C8.97989 5 9.19899 4.83985 9.34698 4.51955H9.3556V4.93017ZM9.35991 3.57542V3.76816C9.35991 3.9432 9.31968 4.08845 9.23922 4.20391C9.15876 4.3175 9.0546 4.3743 8.92672 4.3743C8.83477 4.3743 8.76149 4.34264 8.7069 4.27933C8.65374 4.21415 8.62716 4.13128 8.62716 4.03073C8.62716 3.80912 8.73779 3.6797 8.95905 3.64246L9.35991 3.57542ZM7 12.9302H6.3556V12.5196H6.34698C6.19899 12.8399 5.97989 13 5.68966 13C5.47557 13 5.30675 12.9218 5.18319 12.7654C5.06106 12.6071 5 12.3966 5 12.1341C5 11.5791 5.25359 11.2588 5.76078 11.1732L6.35991 11.0698C6.35991 10.757 6.22917 10.6006 5.96767 10.6006C5.70474 10.6006 5.45474 10.702 5.21767 10.905V10.2402C5.3125 10.1769 5.44181 10.121 5.6056 10.0726C5.77083 10.0242 5.92098 10 6.05603 10C6.68534 10 7 10.4069 7 11.2207V12.9302ZM6.35991 11.7682V11.5754L5.95905 11.6425C5.73779 11.6797 5.62716 11.8091 5.62716 12.0307C5.62716 12.1313 5.65374 12.2142 5.7069 12.2793C5.76149 12.3426 5.83477 12.3743 5.92672 12.3743C6.0546 12.3743 6.15876 12.3175 6.23922 12.2039C6.31968 12.0885 6.35991 11.9432 6.35991 11.7682ZM9.26165 13C9.58343 13 9.82955 12.9423 10 12.8268V12.1173C9.81999 12.2551 9.636 12.324 9.44803 12.324C9.23616 12.324 9.06969 12.2523 8.94863 12.1089C8.82756 11.9637 8.76702 11.7644 8.76702 11.5112C8.76702 11.2505 8.82995 11.0466 8.95579 10.8994C9.08323 10.7505 9.25528 10.676 9.47192 10.676C9.66627 10.676 9.84229 10.7449 10 10.8827V10.1341C9.87097 10.0447 9.66229 10 9.37395 10C8.95659 10 8.62286 10.1406 8.37276 10.4218C8.12425 10.7011 8 11.0838 8 11.5698C8 11.9907 8.11629 12.3343 8.34887 12.6006C8.58144 12.8669 8.8857 13 9.26165 13ZM2 9L3 8H12L13 9V14L12 15H3L2 14V9ZM3 9V14H12V9H3ZM6 7L7 6H14L15 7V12L14 13V12V7H7H6Z" fill="#656565"/>',
  17160. "</svg></button>",
  17161. "</div>",
  17162. '<div class="ace_search_options">',
  17163. '<span action="toggleReplace" class="ace_button replace_toggle">+</span>',
  17164. '<span class="ace_search_counter">0 matches found.</span>',
  17165. '<span action="toggleRegexpMode" title="RegExp Search"></span>',
  17166. '<span action="toggleCaseSensitive" class="ace_button" title="CaseSensitive Search">Aa</span>',
  17167. '<span action="toggleWholeWords" title="Whole Word Search"></span>',
  17168. "</div>",
  17169. "</div>",
  17170. ].join("");
  17171. div.innerHTML = html;
  17172. elSearch = div.firstChild;
  17173. el.appendChild(elSearch);
  17174. return elSearch;
  17175. }
  17176. }
  17177. function setCssClass(el, className, condition) {
  17178. var list = el.classList;
  17179. list[condition ? "add" : "remove"](className);
  17180. }
  17181. function delayedCall(fcn, defaultTimeout) {
  17182. var timer,
  17183. callback = function () {
  17184. timer = null;
  17185. fcn();
  17186. },
  17187. _self = function (timeout) {
  17188. if (!timer) timer = setTimeout(callback, timeout || defaultTimeout);
  17189. };
  17190. _self.delay = function (timeout) {
  17191. timer && clearTimeout(timer);
  17192. timer = setTimeout(callback, timeout || defaultTimeout);
  17193. };
  17194. _self.schedule = _self;
  17195. _self.call = function () {
  17196. this.cancel();
  17197. fcn();
  17198. };
  17199. _self.cancel = function () {
  17200. timer && clearTimeout(timer);
  17201. timer = null;
  17202. };
  17203. _self.isPending = function () {
  17204. return timer;
  17205. };
  17206. return _self;
  17207. }
  17208. /* https://github.com/coderaiser/key */
  17209. function key(str, event) {
  17210. var right,
  17211. KEY = {
  17212. BACKSPACE: 8,
  17213. TAB: 9,
  17214. ENTER: 13,
  17215. ESC: 27,
  17216. SPACE: 32,
  17217. PAGE_UP: 33,
  17218. PAGE_DOWN: 34,
  17219. END: 35,
  17220. HOME: 36,
  17221. UP: 38,
  17222. DOWN: 40,
  17223. INSERT: 45,
  17224. DELETE: 46,
  17225. INSERT_MAC: 96,
  17226. ASTERISK: 106,
  17227. PLUS: 107,
  17228. MINUS: 109,
  17229. F1: 112,
  17230. F2: 113,
  17231. F3: 114,
  17232. F4: 115,
  17233. F5: 116,
  17234. F6: 117,
  17235. F7: 118,
  17236. F8: 119,
  17237. F9: 120,
  17238. F10: 121,
  17239. SLASH: 191,
  17240. TRA: 192 /* Typewritten Reverse Apostrophe (`) */,
  17241. BACKSLASH: 220,
  17242. };
  17243. keyCheck(str, event);
  17244. right = str.split("|").some(function (combination) {
  17245. var wrong;
  17246. wrong = combination.split("-").some(function (key) {
  17247. var right;
  17248. switch (key) {
  17249. case "Ctrl":
  17250. right = event.ctrlKey;
  17251. break;
  17252. case "Shift":
  17253. right = event.shiftKey;
  17254. break;
  17255. case "Alt":
  17256. right = event.altKey;
  17257. break;
  17258. case "Cmd":
  17259. right = event.metaKey;
  17260. break;
  17261. default:
  17262. if (key.length === 1) right = event.keyCode === key.charCodeAt(0);
  17263. else
  17264. Object.keys(KEY).some(function (name) {
  17265. var up = key.toUpperCase();
  17266. if (up === name) right = event.keyCode === KEY[name];
  17267. });
  17268. break;
  17269. }
  17270. return !right;
  17271. });
  17272. return !wrong;
  17273. });
  17274. return right;
  17275. }
  17276. function keyCheck(str, event) {
  17277. if (typeof str !== "string") throw Error("str should be string!");
  17278. if (typeof event !== "object") throw Error("event should be object!");
  17279. }
  17280. });
  17281. });
  17282. var annotatescrollbar = createCommonjsModule(function (module, exports) {
  17283. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  17284. // Distributed under an MIT license: https://codemirror.net/LICENSE
  17285. (function(mod) {
  17286. mod(codemirror);
  17287. })(function(CodeMirror) {
  17288. CodeMirror.defineExtension("annotateScrollbar", function(options) {
  17289. if (typeof options == "string") options = {className: options};
  17290. return new Annotation(this, options);
  17291. });
  17292. CodeMirror.defineOption("scrollButtonHeight", 0);
  17293. function Annotation(cm, options) {
  17294. this.cm = cm;
  17295. this.options = options;
  17296. this.buttonHeight = options.scrollButtonHeight || cm.getOption("scrollButtonHeight");
  17297. this.annotations = [];
  17298. this.doRedraw = this.doUpdate = null;
  17299. this.div = cm.getWrapperElement().appendChild(document.createElement("div"));
  17300. this.div.style.cssText = "position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none";
  17301. this.computeScale();
  17302. function scheduleRedraw(delay) {
  17303. clearTimeout(self.doRedraw);
  17304. self.doRedraw = setTimeout(function() { self.redraw(); }, delay);
  17305. }
  17306. var self = this;
  17307. cm.on("refresh", this.resizeHandler = function() {
  17308. clearTimeout(self.doUpdate);
  17309. self.doUpdate = setTimeout(function() {
  17310. if (self.computeScale()) scheduleRedraw(20);
  17311. }, 100);
  17312. });
  17313. cm.on("markerAdded", this.resizeHandler);
  17314. cm.on("markerCleared", this.resizeHandler);
  17315. if (options.listenForChanges !== false)
  17316. cm.on("changes", this.changeHandler = function() {
  17317. scheduleRedraw(250);
  17318. });
  17319. }
  17320. Annotation.prototype.computeScale = function() {
  17321. var cm = this.cm;
  17322. var hScale = (cm.getWrapperElement().clientHeight - cm.display.barHeight - this.buttonHeight * 2) /
  17323. cm.getScrollerElement().scrollHeight;
  17324. if (hScale != this.hScale) {
  17325. this.hScale = hScale;
  17326. return true;
  17327. }
  17328. };
  17329. Annotation.prototype.update = function(annotations) {
  17330. this.annotations = annotations;
  17331. this.redraw();
  17332. };
  17333. Annotation.prototype.redraw = function(compute) {
  17334. if (compute !== false) this.computeScale();
  17335. var cm = this.cm, hScale = this.hScale;
  17336. var frag = document.createDocumentFragment(), anns = this.annotations;
  17337. var wrapping = cm.getOption("lineWrapping");
  17338. var singleLineH = wrapping && cm.defaultTextHeight() * 1.5;
  17339. var curLine = null, curLineObj = null;
  17340. function getY(pos, top) {
  17341. if (curLine != pos.line) {
  17342. curLine = pos.line;
  17343. curLineObj = cm.getLineHandle(pos.line);
  17344. var visual = cm.getLineHandleVisualStart(curLineObj);
  17345. if (visual != curLineObj) {
  17346. curLine = cm.getLineNumber(visual);
  17347. curLineObj = visual;
  17348. }
  17349. }
  17350. if ((curLineObj.widgets && curLineObj.widgets.length) ||
  17351. (wrapping && curLineObj.height > singleLineH))
  17352. return cm.charCoords(pos, "local")[top ? "top" : "bottom"];
  17353. var topY = cm.heightAtLine(curLineObj, "local");
  17354. return topY + (top ? 0 : curLineObj.height);
  17355. }
  17356. var lastLine = cm.lastLine();
  17357. if (cm.display.barWidth) for (var i = 0, nextTop; i < anns.length; i++) {
  17358. var ann = anns[i];
  17359. if (ann.to.line > lastLine) continue;
  17360. var top = nextTop || getY(ann.from, true) * hScale;
  17361. var bottom = getY(ann.to, false) * hScale;
  17362. while (i < anns.length - 1) {
  17363. if (anns[i + 1].to.line > lastLine) break;
  17364. nextTop = getY(anns[i + 1].from, true) * hScale;
  17365. if (nextTop > bottom + .9) break;
  17366. ann = anns[++i];
  17367. bottom = getY(ann.to, false) * hScale;
  17368. }
  17369. if (bottom == top) continue;
  17370. var height = Math.max(bottom - top, 3);
  17371. var elt = frag.appendChild(document.createElement("div"));
  17372. elt.style.cssText = "position: absolute; right: 0px; width: " + Math.max(cm.display.barWidth - 1, 2) + "px; top: "
  17373. + (top + this.buttonHeight) + "px; height: " + height + "px";
  17374. elt.className = this.options.className;
  17375. if (ann.id) {
  17376. elt.setAttribute("annotation-id", ann.id);
  17377. }
  17378. }
  17379. this.div.textContent = "";
  17380. this.div.appendChild(frag);
  17381. };
  17382. Annotation.prototype.clear = function() {
  17383. this.cm.off("refresh", this.resizeHandler);
  17384. this.cm.off("markerAdded", this.resizeHandler);
  17385. this.cm.off("markerCleared", this.resizeHandler);
  17386. if (this.changeHandler) this.cm.off("changes", this.changeHandler);
  17387. this.div.parentNode.removeChild(this.div);
  17388. };
  17389. });
  17390. });
  17391. var matchesonscrollbar = createCommonjsModule(function (module, exports) {
  17392. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  17393. // Distributed under an MIT license: https://codemirror.net/LICENSE
  17394. (function(mod) {
  17395. mod(codemirror, searchcursor, annotatescrollbar);
  17396. })(function(CodeMirror) {
  17397. CodeMirror.defineExtension("showMatchesOnScrollbar", function(query, caseFold, options) {
  17398. if (typeof options == "string") options = {className: options};
  17399. if (!options) options = {};
  17400. return new SearchAnnotation(this, query, caseFold, options);
  17401. });
  17402. function SearchAnnotation(cm, query, caseFold, options) {
  17403. this.cm = cm;
  17404. this.options = options;
  17405. var annotateOptions = {listenForChanges: false};
  17406. for (var prop in options) annotateOptions[prop] = options[prop];
  17407. if (!annotateOptions.className) annotateOptions.className = "CodeMirror-search-match";
  17408. this.annotation = cm.annotateScrollbar(annotateOptions);
  17409. this.query = query;
  17410. this.caseFold = caseFold;
  17411. this.gap = {from: cm.firstLine(), to: cm.lastLine() + 1};
  17412. this.matches = [];
  17413. this.update = null;
  17414. this.findMatches();
  17415. this.annotation.update(this.matches);
  17416. var self = this;
  17417. cm.on("change", this.changeHandler = function(_cm, change) { self.onChange(change); });
  17418. }
  17419. var MAX_MATCHES = 1000;
  17420. SearchAnnotation.prototype.findMatches = function() {
  17421. if (!this.gap) return;
  17422. for (var i = 0; i < this.matches.length; i++) {
  17423. var match = this.matches[i];
  17424. if (match.from.line >= this.gap.to) break;
  17425. if (match.to.line >= this.gap.from) this.matches.splice(i--, 1);
  17426. }
  17427. var cursor = this.cm.getSearchCursor(this.query, CodeMirror.Pos(this.gap.from, 0), {caseFold: this.caseFold, multiline: this.options.multiline});
  17428. var maxMatches = this.options && this.options.maxMatches || MAX_MATCHES;
  17429. while (cursor.findNext()) {
  17430. var match = {from: cursor.from(), to: cursor.to()};
  17431. if (match.from.line >= this.gap.to) break;
  17432. this.matches.splice(i++, 0, match);
  17433. if (this.matches.length > maxMatches) break;
  17434. }
  17435. this.gap = null;
  17436. };
  17437. function offsetLine(line, changeStart, sizeChange) {
  17438. if (line <= changeStart) return line;
  17439. return Math.max(changeStart, line + sizeChange);
  17440. }
  17441. SearchAnnotation.prototype.onChange = function(change) {
  17442. var startLine = change.from.line;
  17443. var endLine = CodeMirror.changeEnd(change).line;
  17444. var sizeChange = endLine - change.to.line;
  17445. if (this.gap) {
  17446. this.gap.from = Math.min(offsetLine(this.gap.from, startLine, sizeChange), change.from.line);
  17447. this.gap.to = Math.max(offsetLine(this.gap.to, startLine, sizeChange), change.from.line);
  17448. } else {
  17449. this.gap = {from: change.from.line, to: endLine + 1};
  17450. }
  17451. if (sizeChange) for (var i = 0; i < this.matches.length; i++) {
  17452. var match = this.matches[i];
  17453. var newFrom = offsetLine(match.from.line, startLine, sizeChange);
  17454. if (newFrom != match.from.line) match.from = CodeMirror.Pos(newFrom, match.from.ch);
  17455. var newTo = offsetLine(match.to.line, startLine, sizeChange);
  17456. if (newTo != match.to.line) match.to = CodeMirror.Pos(newTo, match.to.ch);
  17457. }
  17458. clearTimeout(this.update);
  17459. var self = this;
  17460. this.update = setTimeout(function() { self.updateAfterChange(); }, 250);
  17461. };
  17462. SearchAnnotation.prototype.updateAfterChange = function() {
  17463. this.findMatches();
  17464. this.annotation.update(this.matches);
  17465. };
  17466. SearchAnnotation.prototype.clear = function() {
  17467. this.cm.off("change", this.changeHandler);
  17468. this.annotation.clear();
  17469. };
  17470. });
  17471. });
  17472. // `Array.isArray` method
  17473. // https://tc39.es/ecma262/#sec-array.isarray
  17474. _export({ target: 'Array', stat: true }, {
  17475. isArray: isArray
  17476. });
  17477. var isArray$2 = path.Array.isArray;
  17478. var isArray$3 = isArray$2;
  17479. var isArray$4 = isArray$3;
  17480. var isArray$5 = isArray$4;
  17481. var isArray$6 = isArray$5;
  17482. var isArray$7 = isArray$6;
  17483. var arrayWithHoles = createCommonjsModule(function (module) {
  17484. function _arrayWithHoles(arr) {
  17485. if (isArray$7(arr)) return arr;
  17486. }
  17487. module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17488. });
  17489. unwrapExports(arrayWithHoles);
  17490. var getIteratorMethod_1 = getIteratorMethod;
  17491. var getIteratorMethod$1 = getIteratorMethod_1;
  17492. var getIteratorMethod$2 = getIteratorMethod$1;
  17493. var getIteratorMethod$3 = getIteratorMethod$2;
  17494. var getIteratorMethod$4 = getIteratorMethod$3;
  17495. var getIteratorMethod$5 = getIteratorMethod$4;
  17496. var iterableToArrayLimit = createCommonjsModule(function (module) {
  17497. function _iterableToArrayLimit(arr, i) {
  17498. var _i = arr == null ? null : typeof symbol$5 !== "undefined" && getIteratorMethod$5(arr) || arr["@@iterator"];
  17499. if (_i == null) return;
  17500. var _arr = [];
  17501. var _n = true;
  17502. var _d = false;
  17503. var _s, _e;
  17504. try {
  17505. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  17506. _arr.push(_s.value);
  17507. if (i && _arr.length === i) break;
  17508. }
  17509. } catch (err) {
  17510. _d = true;
  17511. _e = err;
  17512. } finally {
  17513. try {
  17514. if (!_n && _i["return"] != null) _i["return"]();
  17515. } finally {
  17516. if (_d) throw _e;
  17517. }
  17518. }
  17519. return _arr;
  17520. }
  17521. module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17522. });
  17523. unwrapExports(iterableToArrayLimit);
  17524. var HAS_SPECIES_SUPPORT$1 = arrayMethodHasSpeciesSupport('slice');
  17525. var SPECIES$2 = wellKnownSymbol('species');
  17526. var Array$4 = global_1.Array;
  17527. var max$2 = Math.max;
  17528. // `Array.prototype.slice` method
  17529. // https://tc39.es/ecma262/#sec-array.prototype.slice
  17530. // fallback for not array-like ES3 strings and DOM objects
  17531. _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$1 }, {
  17532. slice: function slice(start, end) {
  17533. var O = toIndexedObject(this);
  17534. var length = lengthOfArrayLike(O);
  17535. var k = toAbsoluteIndex(start, length);
  17536. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  17537. // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
  17538. var Constructor, result, n;
  17539. if (isArray(O)) {
  17540. Constructor = O.constructor;
  17541. // cross-realm fallback
  17542. if (isConstructor(Constructor) && (Constructor === Array$4 || isArray(Constructor.prototype))) {
  17543. Constructor = undefined;
  17544. } else if (isObject(Constructor)) {
  17545. Constructor = Constructor[SPECIES$2];
  17546. if (Constructor === null) Constructor = undefined;
  17547. }
  17548. if (Constructor === Array$4 || Constructor === undefined) {
  17549. return arraySlice(O, k, fin);
  17550. }
  17551. }
  17552. result = new (Constructor === undefined ? Array$4 : Constructor)(max$2(fin - k, 0));
  17553. for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
  17554. result.length = n;
  17555. return result;
  17556. }
  17557. });
  17558. var slice = entryVirtual('Array').slice;
  17559. var ArrayPrototype$6 = Array.prototype;
  17560. var slice$1 = function (it) {
  17561. var own = it.slice;
  17562. return it === ArrayPrototype$6 || (objectIsPrototypeOf(ArrayPrototype$6, it) && own === ArrayPrototype$6.slice) ? slice : own;
  17563. };
  17564. var slice$2 = slice$1;
  17565. var slice$3 = slice$2;
  17566. var slice$4 = slice$3;
  17567. var slice$5 = slice$4;
  17568. var slice$6 = slice$5;
  17569. var from_1$3 = from_1$1;
  17570. var from_1$4 = from_1$3;
  17571. var from_1$5 = from_1$4;
  17572. var from_1$6 = from_1$5;
  17573. var arrayLikeToArray = createCommonjsModule(function (module) {
  17574. function _arrayLikeToArray(arr, len) {
  17575. if (len == null || len > arr.length) len = arr.length;
  17576. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  17577. arr2[i] = arr[i];
  17578. }
  17579. return arr2;
  17580. }
  17581. module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17582. });
  17583. unwrapExports(arrayLikeToArray);
  17584. var unsupportedIterableToArray = createCommonjsModule(function (module) {
  17585. function _unsupportedIterableToArray(o, minLen) {
  17586. var _context;
  17587. if (!o) return;
  17588. if (typeof o === "string") return arrayLikeToArray(o, minLen);
  17589. var n = slice$6(_context = Object.prototype.toString.call(o)).call(_context, 8, -1);
  17590. if (n === "Object" && o.constructor) n = o.constructor.name;
  17591. if (n === "Map" || n === "Set") return from_1$6(o);
  17592. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);
  17593. }
  17594. module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17595. });
  17596. unwrapExports(unsupportedIterableToArray);
  17597. var nonIterableRest = createCommonjsModule(function (module) {
  17598. function _nonIterableRest() {
  17599. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  17600. }
  17601. module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17602. });
  17603. unwrapExports(nonIterableRest);
  17604. var slicedToArray = createCommonjsModule(function (module) {
  17605. function _slicedToArray(arr, i) {
  17606. return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
  17607. }
  17608. module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  17609. });
  17610. var _slicedToArray = unwrapExports(slicedToArray);
  17611. var indexOf$8 = indexOf$3;
  17612. var create$6 = create$1;
  17613. var slice$7 = slice$2;
  17614. var trim$4 = stringTrim.trim;
  17615. var $parseInt = global_1.parseInt;
  17616. var Symbol$3 = global_1.Symbol;
  17617. var ITERATOR$5 = Symbol$3 && Symbol$3.iterator;
  17618. var hex = /^[+-]?0x/i;
  17619. var exec$2 = functionUncurryThis(hex.exec);
  17620. var FORCED$4 = $parseInt(whitespaces + '08') !== 8 || $parseInt(whitespaces + '0x16') !== 22
  17621. // MS Edge 18- broken with boxed symbols
  17622. || (ITERATOR$5 && !fails(function () { $parseInt(Object(ITERATOR$5)); }));
  17623. // `parseInt` method
  17624. // https://tc39.es/ecma262/#sec-parseint-string-radix
  17625. var numberParseInt = FORCED$4 ? function parseInt(string, radix) {
  17626. var S = trim$4(toString_1(string));
  17627. return $parseInt(S, (radix >>> 0) || (exec$2(hex, S) ? 16 : 10));
  17628. } : $parseInt;
  17629. // `parseInt` method
  17630. // https://tc39.es/ecma262/#sec-parseint-string-radix
  17631. _export({ global: true, forced: parseInt != numberParseInt }, {
  17632. parseInt: numberParseInt
  17633. });
  17634. var _parseInt = path.parseInt;
  17635. var _parseInt$1 = _parseInt;
  17636. var _parseInt$2 = _parseInt$1;
  17637. /**
  17638. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  17639. *
  17640. * Licensed under the Apache License, Version 2.0 (the "License");
  17641. * you may not use this file except in compliance with the License.
  17642. * You may obtain a copy of the License at
  17643. *
  17644. * http://www.apache.org/licenses/LICENSE-2.0
  17645. *
  17646. * Unless required by applicable law or agreed to in writing, software
  17647. * distributed under the License is distributed on an "AS IS" BASIS,
  17648. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17649. * See the License for the specific language governing permissions and
  17650. * limitations under the License.
  17651. */
  17652. // @ts-nocheck
  17653. /**
  17654. * 将html内容转换成md内容的工具
  17655. * 调用方式为:htmlParser.run(htmlStr)
  17656. * 主要流程为:
  17657. * 1、接收html字符串
  17658. * 2、根据html字符串生成html语法树
  17659. * 3、递归遍历语法树,将标签替换为对应的markdown语法
  17660. **/
  17661. var htmlParser = {
  17662. /**
  17663. * 入口函数,负责将传入的html字符串转成对应的markdown源码
  17664. * @param {string} htmlStr
  17665. * @returns {string} 对应的markdown源码
  17666. */
  17667. run: function run(htmlStr) {
  17668. var _context;
  17669. var $htmlStr = "<div>".concat(htmlStr, "</div>"); // 挂载对应的格式化引擎,这里挂载的是markdown逆向引擎,后续可以扩展支持其他标记语言
  17670. this.tagParser.formatEngine = this.mdFormatEngine; // 去掉注释
  17671. $htmlStr = $htmlStr.replace(/<!--[\s\S]*?-->/g, ''); // 将html字符串解析成html语法树
  17672. var htmlparsedArrays = this.htmlParser.parseHtml($htmlStr); // 预处理,去掉一些不需要的样式、属性
  17673. htmlparsedArrays = this.paragraphStyleClear(htmlparsedArrays); // 核心逻辑,遍历html语法树,生成对应的markdown源码
  17674. return trim$3(_context = this.$dealHtml(htmlparsedArrays).replace(/\n{3,}/g, '\n\n\n').replace(/&gt;/g, '>').replace(/&lt;/g, '<').replace(/&amp;/g, '&')).call(_context, '\n');
  17675. },
  17676. /**
  17677. * 解析html语法树
  17678. * @param {Array} arr
  17679. * @returns {string} 对应的markdown源码
  17680. */
  17681. $dealHtml: function $dealHtml(arr) {
  17682. var ret = '';
  17683. for (var i = 0; i < arr.length; i++) {
  17684. var temObj = arr[i];
  17685. if (temObj.type === 'tag') ret = this.$handleTagObject(temObj, ret);else if (temObj.type === 'text' && temObj.content.length > 0) {
  17686. ret += temObj.content.replace(/&nbsp;/g, ' ').replace(/[\n]+/g, '\n').replace(/^[ \t\n]+\n\s*$/, '\n');
  17687. }
  17688. }
  17689. return ret;
  17690. },
  17691. /**
  17692. * 处理html标签内容
  17693. * @param {object} temObj
  17694. * @param {string} returnString
  17695. */
  17696. $handleTagObject: function $handleTagObject(temObj, returnString) {
  17697. var ret = returnString;
  17698. if (temObj.attrs["class"] && /(ch-icon-square|ch-icon-check)/.test(temObj.attrs["class"])) {
  17699. var _context2;
  17700. // 针对checklist
  17701. if (indexOf$8(_context2 = temObj.attrs["class"]).call(_context2, 'ch-icon-check') >= 0) {
  17702. ret += '[x]';
  17703. } else {
  17704. ret += '[ ]';
  17705. }
  17706. } else if (temObj.attrs["class"] && /cherry-code-preview-lang-select/.test(temObj.attrs["class"])) {
  17707. // 如果是代码块的选择语言标签,则不做任何处理
  17708. ret += '';
  17709. } else {
  17710. // 如果是标签
  17711. ret += this.$dealTag(temObj);
  17712. }
  17713. return ret;
  17714. },
  17715. /**
  17716. * 解析具体的html标签
  17717. * @param {HTMLElement} obj
  17718. * @returns {string} 对应的markdown源码
  17719. */
  17720. $dealTag: function $dealTag(obj) {
  17721. var self = this;
  17722. var tmpText = '';
  17723. if (obj.children) {
  17724. // 递归每一个子元素
  17725. tmpText = self.$dealHtml(obj.children);
  17726. }
  17727. if (obj.name === 'style') {
  17728. // 不解析样式属性,只处理行内样式
  17729. return '';
  17730. }
  17731. if (obj.name === 'code' || obj.name === 'pre') {
  17732. // 解析代码块 或 行内代码
  17733. // pre时,强制转成代码块
  17734. return self.tagParser.codeParser(obj, self.$dealCodeTag(obj), obj.name === 'pre');
  17735. }
  17736. if (typeof self.tagParser["".concat(obj.name, "Parser")] === 'function') {
  17737. // 解析对应的具体标签
  17738. return self.tagParser["".concat(obj.name, "Parser")](obj, tmpText);
  17739. }
  17740. return tmpText;
  17741. },
  17742. /**
  17743. * 解析代码块
  17744. * 本函数认为代码块是由text标签和li标签组成的
  17745. * @param {HTMLElement} obj
  17746. * @returns {string} 对应的markdown源码
  17747. */
  17748. $dealCodeTag: function $dealCodeTag(obj) {
  17749. var self = this;
  17750. if (obj.children.length < 0) {
  17751. return '';
  17752. }
  17753. var ret = '';
  17754. for (var i = 0; i < obj.children.length; i++) {
  17755. var temObj = obj.children[i];
  17756. if (temObj.type !== 'text') {
  17757. // 如果是非text标签,则需要处理换行逻辑
  17758. if (temObj.name === 'li') {
  17759. ret += '\n';
  17760. }
  17761. if (temObj.name === 'br') {
  17762. ret += '\n';
  17763. } // 递归找到对应的代码文本
  17764. ret += self.$dealCodeTag(temObj);
  17765. } else {
  17766. ret += temObj.content;
  17767. }
  17768. }
  17769. return ret;
  17770. },
  17771. /** **
  17772. * html解析器
  17773. * 将html解析成对象数组
  17774. * https://github.com/HenrikJoreteg/html-parse-stringify
  17775. **/
  17776. htmlParser: {
  17777. attrRE: /([\w-]+)|['"]{1}([^'"]*)['"]{1}/g,
  17778. lookup: {
  17779. area: true,
  17780. base: true,
  17781. br: true,
  17782. col: true,
  17783. embed: true,
  17784. hr: true,
  17785. img: true,
  17786. video: true,
  17787. input: true,
  17788. keygen: true,
  17789. link: true,
  17790. menuitem: true,
  17791. meta: true,
  17792. param: true,
  17793. source: true,
  17794. track: true,
  17795. wbr: true
  17796. },
  17797. tagRE: /<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>/g,
  17798. empty: create$6 ? create$6(null) : {},
  17799. parseTags: function parseTags(tag) {
  17800. var self = this;
  17801. var i = 0;
  17802. var key;
  17803. var res = {
  17804. type: 'tag',
  17805. name: '',
  17806. voidElement: false,
  17807. attrs: {},
  17808. children: []
  17809. };
  17810. tag.replace(this.attrRE, function (match) {
  17811. if (i % 2) {
  17812. key = match;
  17813. } else {
  17814. if (i === 0) {
  17815. if (self.lookup[match] || tag.charAt(tag.length - 2) === '/') {
  17816. res.voidElement = true;
  17817. }
  17818. res.name = match;
  17819. } else {
  17820. res.attrs[key] = match.replace(/['"]/g, '');
  17821. }
  17822. }
  17823. i += 1;
  17824. });
  17825. return res;
  17826. },
  17827. parseHtml: function parseHtml(html, options) {
  17828. var self = this;
  17829. var $options = options || {};
  17830. $options.components || ($options.components = this.empty);
  17831. var result = [];
  17832. var current;
  17833. var level = -1;
  17834. var arr = [];
  17835. var byTag = {};
  17836. var inComponent = false;
  17837. html.replace(this.tagRE, function (tag, index) {
  17838. if (inComponent) {
  17839. if (tag !== "</".concat(current.name, ">")) {
  17840. return;
  17841. }
  17842. inComponent = false;
  17843. }
  17844. var isOpen = tag.charAt(1) !== '/';
  17845. var start = index + tag.length;
  17846. var nextChar = html.charAt(start);
  17847. var parent;
  17848. if (isOpen) {
  17849. level += 1;
  17850. current = self.parseTags(tag);
  17851. if (current.type === 'tag' && $options.components[current.name]) {
  17852. current.type = 'component';
  17853. inComponent = true;
  17854. }
  17855. if (!current.voidElement && !inComponent && nextChar && nextChar !== '<') {
  17856. current.children.push({
  17857. type: 'text',
  17858. content: slice$7(html).call(html, start, indexOf$8(html).call(html, '<', start))
  17859. });
  17860. }
  17861. byTag[current.tagName] = current; // if we're at root, push new base node
  17862. if (level === 0) {
  17863. result.push(current);
  17864. }
  17865. parent = arr[level - 1];
  17866. if (parent) {
  17867. parent.children.push(current);
  17868. }
  17869. arr[level] = current;
  17870. }
  17871. if (!isOpen || current.voidElement) {
  17872. level -= 1;
  17873. if (!inComponent && nextChar !== '<' && nextChar) {
  17874. // trailing text node
  17875. if (arr[level]) {
  17876. arr[level].children.push({
  17877. type: 'text',
  17878. content: slice$7(html).call(html, start, indexOf$8(html).call(html, '<', start))
  17879. });
  17880. }
  17881. }
  17882. }
  17883. });
  17884. return result;
  17885. }
  17886. },
  17887. /** **
  17888. * 标签解析器
  17889. * 解析对应的标签,并调用格式化引擎生成对应格式内容
  17890. **/
  17891. tagParser: {
  17892. // 挂载的解析引擎,一次只能挂在一个解析引擎,目前只实现和挂载了markdown解析引擎
  17893. formatEngine: {},
  17894. /**
  17895. * 解析p标签
  17896. * @param {HTMLElement} obj
  17897. * @param {string} str 需要回填的字符串
  17898. * @returns {string} str
  17899. */
  17900. pParser: function pParser(obj, str) {
  17901. var $str = str;
  17902. if (/\n$/.test($str)) {
  17903. return $str;
  17904. }
  17905. return "".concat($str, "\n");
  17906. },
  17907. /**
  17908. * 解析div标签
  17909. * @param {HTMLElement} obj
  17910. * @param {string} str 需要回填的字符串
  17911. * @returns {string} str
  17912. */
  17913. divParser: function divParser(obj, str) {
  17914. var $str = str;
  17915. if (/\n$/.test($str)) {
  17916. return $str;
  17917. }
  17918. return "".concat($str, "\n");
  17919. },
  17920. /**
  17921. * 解析span标签
  17922. * @param {HTMLElement} obj
  17923. * @param {string} str 需要回填的字符串
  17924. * @returns {string} str
  17925. */
  17926. spanParser: function spanParser(obj, str) {
  17927. var $str = str.replace(/\t/g, '').replace(/\n/g, ' '); // span标签里不应该有\n的,有的话就转化成空格
  17928. if (obj.attrs && obj.attrs.style) ;
  17929. return $str;
  17930. },
  17931. /**
  17932. * 解析code标签
  17933. * @param {HTMLElement} obj
  17934. * @param {string} str 需要回填的字符串
  17935. * @param {boolean} isBlock 是否强制为代码块
  17936. * @returns {string} str
  17937. */
  17938. codeParser: function codeParser(obj, str) {
  17939. var isBlock = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  17940. return this.formatEngine.convertCode(str, isBlock);
  17941. },
  17942. /**
  17943. * 解析br标签
  17944. * @param {HTMLElement} obj
  17945. * @param {string} str 需要回填的字符串
  17946. * @returns {string} str
  17947. */
  17948. brParser: function brParser(obj, str) {
  17949. return this.formatEngine.convertBr(str, '\n');
  17950. },
  17951. /**
  17952. * 解析img标签
  17953. * @param {HTMLElement} obj
  17954. * @param {string} str 需要回填的字符串
  17955. * @returns {string} str
  17956. */
  17957. imgParser: function imgParser(obj, str) {
  17958. if (obj.attrs && obj.attrs['data-control'] === 'tapd-graph') {
  17959. return this.formatEngine.convertGraph(obj.attrs.title, obj.attrs.src, obj.attrs['data-origin-xml'], obj);
  17960. }
  17961. if (obj.attrs && obj.attrs.src) {
  17962. return this.formatEngine.convertImg(obj.attrs.alt, obj.attrs.src);
  17963. }
  17964. },
  17965. /**
  17966. * 解析video标签
  17967. * @param {HTMLElement} obj
  17968. * @param {string} str 需要回填的字符串
  17969. * @returns {string} str
  17970. */
  17971. videoParser: function videoParser(obj, str) {
  17972. if (obj.attrs && obj.attrs.src) {
  17973. return this.formatEngine.convertVideo(str, obj.attrs.src, obj.attrs.poster, obj.attrs.title);
  17974. }
  17975. },
  17976. /**
  17977. * 解析b标签
  17978. * @param {HTMLElement} obj
  17979. * @param {string} str 需要回填的字符串
  17980. * @returns {string} str
  17981. */
  17982. bParser: function bParser(obj, str) {
  17983. var strArr = str.split('\n');
  17984. var ret = [];
  17985. for (var i = 0; i < strArr.length; i++) {
  17986. ret.push(this.formatEngine.convertB(strArr[i]));
  17987. }
  17988. return ret.join('\n');
  17989. },
  17990. /**
  17991. * 解析i标签
  17992. * @param {HTMLElement} obj
  17993. * @param {string} str 需要回填的字符串
  17994. * @returns {string} str
  17995. */
  17996. iParser: function iParser(obj, str) {
  17997. var strArr = str.split('\n');
  17998. var ret = [];
  17999. for (var i = 0; i < strArr.length; i++) {
  18000. ret.push(this.formatEngine.convertI(strArr[i]));
  18001. }
  18002. return ret.join('\n');
  18003. },
  18004. /**
  18005. * 解析strike标签
  18006. * @param {HTMLElement} obj
  18007. * @param {string} str 需要回填的字符串
  18008. * @returns {string} str
  18009. */
  18010. strikeParser: function strikeParser(obj, str) {
  18011. var strArr = str.split('\n');
  18012. var ret = [];
  18013. for (var i = 0; i < strArr.length; i++) {
  18014. ret.push(this.formatEngine.convertStrike(strArr[i]));
  18015. }
  18016. return ret.join('\n');
  18017. },
  18018. /**
  18019. * 解析del标签
  18020. * @param {HTMLElement} obj
  18021. * @param {string} str 需要回填的字符串
  18022. * @returns {string} str
  18023. */
  18024. delParser: function delParser(obj, str) {
  18025. var strArr = str.split('\n');
  18026. var ret = [];
  18027. for (var i = 0; i < strArr.length; i++) {
  18028. ret.push(this.formatEngine.convertDel(strArr[i]));
  18029. }
  18030. return ret.join('\n');
  18031. },
  18032. /**
  18033. * 解析u标签
  18034. * @param {HTMLElement} obj
  18035. * @param {string} str 需要回填的字符串
  18036. * @returns {string} str
  18037. */
  18038. uParser: function uParser(obj, str) {
  18039. var strArr = str.split('\n');
  18040. var ret = [];
  18041. for (var i = 0; i < strArr.length; i++) {
  18042. ret.push(this.formatEngine.convertU(strArr[i]));
  18043. }
  18044. return ret.join('\n');
  18045. },
  18046. /**
  18047. * 解析a标签
  18048. * @param {HTMLElement} obj
  18049. * @param {string} str 需要回填的字符串
  18050. * @returns {string} str
  18051. */
  18052. aParser: function aParser(obj, str) {
  18053. if (obj.attrs && obj.attrs.href) {
  18054. return this.formatEngine.convertA(str, obj.attrs.href);
  18055. }
  18056. return '';
  18057. },
  18058. /**
  18059. * 解析sup标签
  18060. * @param {HTMLElement} obj
  18061. * @param {string} str 需要回填的字符串
  18062. * @returns {string} str
  18063. */
  18064. supParser: function supParser(obj, str) {
  18065. return this.formatEngine.convertSup(str);
  18066. },
  18067. /**
  18068. * 解析sub标签
  18069. * @param {HTMLElement} obj
  18070. * @param {string} str 需要回填的字符串
  18071. * @returns {string} str
  18072. */
  18073. subParser: function subParser(obj, str) {
  18074. return this.formatEngine.convertSub(str);
  18075. },
  18076. /**
  18077. * 解析td标签
  18078. * @param {HTMLElement} obj
  18079. * @param {string} str 需要回填的字符串
  18080. * @returns {string} str
  18081. */
  18082. tdParser: function tdParser(obj, str) {
  18083. return this.formatEngine.convertTd(str);
  18084. },
  18085. /**
  18086. * 解析tr标签
  18087. * @param {HTMLElement} obj
  18088. * @param {string} str 需要回填的字符串
  18089. * @returns {string} str
  18090. */
  18091. trParser: function trParser(obj, str) {
  18092. return this.formatEngine.convertTr(str);
  18093. },
  18094. /**
  18095. * 解析th标签
  18096. * @param {HTMLElement} obj
  18097. * @param {string} str 需要回填的字符串
  18098. * @returns {string} str
  18099. */
  18100. thParser: function thParser(obj, str) {
  18101. return this.formatEngine.convertTh(str);
  18102. },
  18103. /**
  18104. * 解析thead标签
  18105. * @param {HTMLElement} obj
  18106. * @param {string} str 需要回填的字符串
  18107. * @returns {string} str
  18108. */
  18109. theadParser: function theadParser(obj, str) {
  18110. return this.formatEngine.convertThead(str);
  18111. },
  18112. /**
  18113. * 解析table标签
  18114. * @param {HTMLElement} obj
  18115. * @param {string} str 需要回填的字符串
  18116. * @returns {string} str
  18117. */
  18118. tableParser: function tableParser(obj, str) {
  18119. return this.formatEngine.convertTable(str);
  18120. },
  18121. /**
  18122. * 解析li标签
  18123. * @param {HTMLElement} obj
  18124. * @param {string} str 需要回填的字符串
  18125. * @returns {string} str
  18126. */
  18127. liParser: function liParser(obj, str) {
  18128. return this.formatEngine.convertLi(str);
  18129. },
  18130. /**
  18131. * 解析ul标签
  18132. * @param {HTMLElement} obj
  18133. * @param {string} str 需要回填的字符串
  18134. * @returns {string} str
  18135. */
  18136. ulParser: function ulParser(obj, str) {
  18137. return this.formatEngine.convertUl(str);
  18138. },
  18139. /**
  18140. * 解析ol标签
  18141. * @param {HTMLElement} obj
  18142. * @param {string} str 需要回填的字符串
  18143. * @returns {string} str
  18144. */
  18145. olParser: function olParser(obj, str) {
  18146. return this.formatEngine.convertOl(str);
  18147. },
  18148. /**
  18149. * 解析strong标签
  18150. * @param {HTMLElement} obj
  18151. * @param {string} str 需要回填的字符串
  18152. * @returns {string} str
  18153. */
  18154. strongParser: function strongParser(obj, str) {
  18155. return this.formatEngine.convertStrong(str);
  18156. },
  18157. /**
  18158. * 解析hr标签
  18159. * @param {HTMLElement} obj
  18160. * @param {string} str 需要回填的字符串
  18161. * @returns {string} str
  18162. */
  18163. hrParser: function hrParser(obj, str) {
  18164. return this.formatEngine.convertHr(str);
  18165. },
  18166. /**
  18167. * 解析h1标签
  18168. * @param {HTMLElement} obj
  18169. * @param {string} str 需要回填的字符串
  18170. * @returns {string} str
  18171. */
  18172. h1Parser: function h1Parser(obj, str) {
  18173. return this.formatEngine.convertH1(str);
  18174. },
  18175. /**
  18176. * 解析h2标签
  18177. * @param {HTMLElement} obj
  18178. * @param {string} str 需要回填的字符串
  18179. * @returns {string} str
  18180. */
  18181. h2Parser: function h2Parser(obj, str) {
  18182. return this.formatEngine.convertH2(str);
  18183. },
  18184. /**
  18185. * 解析h3标签
  18186. * @param {HTMLElement} obj
  18187. * @param {string} str 需要回填的字符串
  18188. * @returns {string} str
  18189. */
  18190. h3Parser: function h3Parser(obj, str) {
  18191. return this.formatEngine.convertH3(str);
  18192. },
  18193. /**
  18194. * 解析h4标签
  18195. * @param {HTMLElement} obj
  18196. * @param {string} str 需要回填的字符串
  18197. * @returns {string} str
  18198. */
  18199. h4Parser: function h4Parser(obj, str) {
  18200. return this.formatEngine.convertH4(str);
  18201. },
  18202. /**
  18203. * 解析h5标签
  18204. * @param {HTMLElement} obj
  18205. * @param {string} str 需要回填的字符串
  18206. * @returns {string} str
  18207. */
  18208. h5Parser: function h5Parser(obj, str) {
  18209. return this.formatEngine.convertH5(str);
  18210. },
  18211. /**
  18212. * 解析h6标签
  18213. * @param {HTMLElement} obj
  18214. * @param {string} str 需要回填的字符串
  18215. * @returns {string} str
  18216. */
  18217. h6Parser: function h6Parser(obj, str) {
  18218. return this.formatEngine.convertH6(str);
  18219. },
  18220. /**
  18221. * 解析blockquote标签
  18222. * @param {HTMLElement} obj
  18223. * @param {string} str 需要回填的字符串
  18224. * @returns {string} str
  18225. */
  18226. blockquoteParser: function blockquoteParser(obj, str) {
  18227. return this.formatEngine.convertBlockquote(str.replace(/\n+/g, '\n'));
  18228. },
  18229. /**
  18230. * 解析address标签
  18231. * @param {HTMLElement} obj
  18232. * @param {string} str 需要回填的字符串
  18233. * @returns {string} str
  18234. */
  18235. addressParser: function addressParser(obj, str) {
  18236. return this.formatEngine.convertAddress(str.replace(/\n+/g, '\n'));
  18237. },
  18238. // 样式解析器
  18239. styleParser: {
  18240. // 识别字体颜色 color
  18241. colorAttrParser: function colorAttrParser(style) {
  18242. var color = style.match(/color:\s*(#[a-zA-Z0-9]{3,6});/);
  18243. if (color && color[1]) {
  18244. return color[1];
  18245. }
  18246. return '';
  18247. },
  18248. // 识别字体大小 font-size
  18249. sizeAttrParser: function sizeAttrParser(style) {
  18250. var fontSize = style.match(/font-size:\s*([a-zA-Z0-9-]+?);/);
  18251. if (fontSize && fontSize[1]) {
  18252. var size = 0;
  18253. if (/[0-9]+px/.test(fontSize[1])) {
  18254. var _context3;
  18255. size = trim$3(_context3 = fontSize[1].replace(/px/, '')).call(_context3);
  18256. } else {
  18257. switch (fontSize[1]) {
  18258. case 'x-small':
  18259. size = 10;
  18260. break;
  18261. case 'small':
  18262. size = 12;
  18263. break;
  18264. case 'medium':
  18265. size = 16;
  18266. break;
  18267. case 'large':
  18268. size = 18;
  18269. break;
  18270. case 'x-large':
  18271. size = 24;
  18272. break;
  18273. case 'xx-large':
  18274. size = 32;
  18275. break;
  18276. default:
  18277. size = '';
  18278. }
  18279. }
  18280. return size > 0 ? size : '';
  18281. }
  18282. return '';
  18283. },
  18284. // 识别字体背景颜色 background-color
  18285. bgColorAttrParser: function bgColorAttrParser(style) {
  18286. var color = style.match(/background-color:\s*([^;]+?);/);
  18287. if (color && color[1]) {
  18288. var bgColor = '';
  18289. if (/rgb\([ 0-9]+,[ 0-9]+,[ 0-9]+\)/.test(color[1])) {
  18290. var values = color[1].match(/rgb\(([ 0-9]+),([ 0-9]+),([ 0-9]+)\)/);
  18291. if (values[1] && values[2] && values[3]) {
  18292. var _context4, _context5, _context6, _context7, _context8;
  18293. values[1] = _parseInt$2(trim$3(_context4 = values[1]).call(_context4), 10);
  18294. values[2] = _parseInt$2(trim$3(_context5 = values[2]).call(_context5), 10);
  18295. values[3] = _parseInt$2(trim$3(_context6 = values[3]).call(_context6), 10);
  18296. bgColor = concat$5(_context7 = concat$5(_context8 = "#".concat(values[1].toString(16))).call(_context8, values[2].toString(16))).call(_context7, values[3].toString(16));
  18297. }
  18298. } else {
  18299. var _color = _slicedToArray(color, 2);
  18300. bgColor = _color[1];
  18301. }
  18302. return bgColor;
  18303. }
  18304. return '';
  18305. }
  18306. }
  18307. },
  18308. /**
  18309. * 一个格式化引擎
  18310. * 将字符串格式化成markdown语法的引擎
  18311. **/
  18312. mdFormatEngine: {
  18313. convertColor: function convertColor(str, attr) {
  18314. var _context9;
  18315. var $str = trim$3(str).call(str);
  18316. if (!$str || /\n/.test($str)) {
  18317. return $str;
  18318. }
  18319. return attr ? concat$5(_context9 = "!!".concat(attr, " ")).call(_context9, $str, "!!") : $str;
  18320. },
  18321. convertSize: function convertSize(str, attr) {
  18322. var _context10;
  18323. var $str = trim$3(str).call(str);
  18324. if (!$str || /\n/.test($str)) {
  18325. return $str;
  18326. }
  18327. return attr ? concat$5(_context10 = "!".concat(attr, " ")).call(_context10, $str, "!") : $str;
  18328. },
  18329. convertBgColor: function convertBgColor(str, attr) {
  18330. var _context11;
  18331. var $str = trim$3(str).call(str);
  18332. if (!$str || /\n/.test($str)) {
  18333. return $str;
  18334. }
  18335. return attr ? concat$5(_context11 = "!!!".concat(attr, " ")).call(_context11, $str, "!!!") : $str;
  18336. },
  18337. convertBr: function convertBr(str, attr) {
  18338. return str + attr;
  18339. },
  18340. convertCode: function convertCode(str) {
  18341. var isBlock = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  18342. if (/\n/.test(str) || isBlock) {
  18343. return "```\n".concat(str.replace(/\n+$/, ''), "\n```");
  18344. }
  18345. return "`".concat(str.replace(/`/g, '\\`'), "`");
  18346. },
  18347. convertB: function convertB(str) {
  18348. return /^\s*$/.test(str) ? '' : "**".concat(str, "**");
  18349. },
  18350. convertI: function convertI(str) {
  18351. return /^\s*$/.test(str) ? '' : "*".concat(str, "*");
  18352. },
  18353. convertU: function convertU(str) {
  18354. return /^\s*$/.test(str) ? '' : " /".concat(str, "/ ");
  18355. },
  18356. convertImg: function convertImg(alt, src) {
  18357. var _context12;
  18358. var $alt = alt && alt.length > 0 ? alt : 'image';
  18359. return concat$5(_context12 = "![".concat($alt, "](")).call(_context12, src, ")");
  18360. },
  18361. convertGraph: function convertGraph(str, attr, data, obj) {
  18362. var _context15, _context16, _context17;
  18363. var $str = str && str.length > 0 ? str : 'graph';
  18364. var moreAttrs = '';
  18365. if (obj) {
  18366. try {
  18367. var _context13;
  18368. var attrs = obj.attrs;
  18369. forEach$3(_context13 = keys$3(attrs)).call(_context13, function (prop) {
  18370. if (Object.prototype.hasOwnProperty.call(attrs, prop)) {
  18371. if (indexOf$8(prop).call(prop, 'data-graph-') >= 0 && attrs[prop]) {
  18372. var _context14;
  18373. moreAttrs += concat$5(_context14 = " ".concat(prop, "=")).call(_context14, attrs[prop]);
  18374. }
  18375. }
  18376. });
  18377. } catch (error) {// console.log('error', error)
  18378. }
  18379. }
  18380. return concat$5(_context15 = concat$5(_context16 = concat$5(_context17 = "![".concat($str, "](")).call(_context17, attr, "){data-control=tapd-graph data-origin-xml=")).call(_context16, data)).call(_context15, moreAttrs, "}");
  18381. },
  18382. convertVideo: function convertVideo(str, src, poster, title) {
  18383. var _context18, _context19;
  18384. var $title = title && title.length > 0 ? title : 'video';
  18385. return concat$5(_context18 = concat$5(_context19 = "!video[".concat($title, "](")).call(_context19, src, "){poster=")).call(_context18, poster, "}");
  18386. },
  18387. convertA: function convertA(str, attr) {
  18388. var _context20;
  18389. if (str === attr) {
  18390. return "".concat(str, " ");
  18391. }
  18392. var $str = trim$3(str).call(str);
  18393. if (!$str) {
  18394. return $str;
  18395. }
  18396. return concat$5(_context20 = "[".concat($str, "](")).call(_context20, attr, ")");
  18397. },
  18398. convertSup: function convertSup(str) {
  18399. return "^".concat(trim$3(str).call(str).replace(/\^/g, '\\^'), "^");
  18400. },
  18401. convertSub: function convertSub(str) {
  18402. return "^^".concat(trim$3(str).call(str).replace(/\^\^/g, '\\^\\^'), "^^");
  18403. },
  18404. convertTd: function convertTd(str) {
  18405. return "~|".concat(trim$3(str).call(str).replace(/\n{1,}/g, '<br>'), " ~|");
  18406. },
  18407. convertTh: function convertTh(str) {
  18408. return "~|".concat(trim$3(str).call(str).replace(/\n{1,}/g, '<br>'), " ~|");
  18409. },
  18410. convertTr: function convertTr(str) {
  18411. return "".concat(str.replace(/\n/g, ''), "\n");
  18412. },
  18413. convertThead: function convertThead(str) {
  18414. return "".concat(str.replace(/~\|~\|/g, '~|').replace(/~\|/g, '|'), "|:--|\n");
  18415. },
  18416. convertTable: function convertTable(str) {
  18417. var ret = "\n".concat(str.replace(/~\|~\|/g, '~|').replace(/~\|/g, '|'), "\n").replace(/\n{2,}/g, '\n');
  18418. if (/\|:--\|/.test(ret)) {
  18419. return ret;
  18420. }
  18421. return "\n| |\n|:--|".concat(ret);
  18422. },
  18423. convertLi: function convertLi(str) {
  18424. return "- ".concat(str.replace(/^\n/, '').replace(/\n+$/, '').replace(/\n+/g, '\n\t'), "\n");
  18425. },
  18426. convertUl: function convertUl(str) {
  18427. return "".concat(str, "\n");
  18428. },
  18429. convertOl: function convertOl(str) {
  18430. var arr = str.split('\n');
  18431. var index = 1;
  18432. for (var i = 0; i < arr.length; i++) {
  18433. if (/^- /.test(arr[i])) {
  18434. arr[i] = arr[i].replace(/^- /, "".concat(index, ". "));
  18435. index += 1;
  18436. }
  18437. }
  18438. var $str = arr.join('\n');
  18439. return "".concat($str, "\n");
  18440. },
  18441. convertStrong: function convertStrong(str) {
  18442. return /^\s*$/.test(str) ? '' : "**".concat(str, "**");
  18443. },
  18444. convertStrike: function convertStrike(str) {
  18445. return /^\s*$/.test(str) ? '' : "~~".concat(str, "~~");
  18446. },
  18447. convertDel: function convertDel(str) {
  18448. return /^\s*$/.test(str) ? '' : "~~".concat(str, "~~");
  18449. },
  18450. convertHr: function convertHr(str) {
  18451. return /^\s*$/.test(str) ? '\n\n----\n' : "\n\n----\n".concat(str);
  18452. },
  18453. convertH1: function convertH1(str) {
  18454. return "# ".concat(trim$3(str).call(str).replace(/\n+$/, ''), "\n\n");
  18455. },
  18456. convertH2: function convertH2(str) {
  18457. return "## ".concat(trim$3(str).call(str).replace(/\n+$/, ''), "\n\n");
  18458. },
  18459. convertH3: function convertH3(str) {
  18460. return "### ".concat(trim$3(str).call(str).replace(/\n+$/, ''), "\n\n");
  18461. },
  18462. convertH4: function convertH4(str) {
  18463. return "#### ".concat(trim$3(str).call(str).replace(/\n+$/, ''), "\n\n");
  18464. },
  18465. convertH5: function convertH5(str) {
  18466. return "##### ".concat(trim$3(str).call(str).replace(/\n+$/, ''), "\n\n");
  18467. },
  18468. convertH6: function convertH6(str) {
  18469. return "###### ".concat(trim$3(str).call(str).replace(/\n+$/, ''), "\n\n");
  18470. },
  18471. convertBlockquote: function convertBlockquote(str) {
  18472. return ">".concat(trim$3(str).call(str), "\n\n");
  18473. },
  18474. convertAddress: function convertAddress(str) {
  18475. return ">".concat(trim$3(str).call(str), "\n\n");
  18476. }
  18477. },
  18478. /**
  18479. * 清除整段的样式、方便编辑
  18480. * 暂时先屏蔽字体色和背景色
  18481. * @param {Array} htmlparsedArrays 由HTMLElement组成的数组
  18482. */
  18483. paragraphStyleClear: function paragraphStyleClear(htmlparsedArrays) {
  18484. for (var index = 0; index < htmlparsedArrays[0].children.length; index++) {
  18485. var htmlItem = htmlparsedArrays[0].children[index];
  18486. var stack = [htmlItem];
  18487. var paragraphs = [];
  18488. while (stack.length) {
  18489. var temp = stack.shift();
  18490. var childCount = this.notEmptyTagCount(temp);
  18491. if (childCount === 1) {
  18492. paragraphs.push(temp);
  18493. } else if (childCount > 1) {
  18494. for (var k = 0; k < temp.children.length; k++) {
  18495. stack.push(temp.children[k]);
  18496. }
  18497. } else {
  18498. if (paragraphs.length === 1) {
  18499. this.clearChildColorAttrs(paragraphs.pop());
  18500. }
  18501. paragraphs = [];
  18502. }
  18503. }
  18504. if (paragraphs.length === 1) {
  18505. this.clearChildColorAttrs(paragraphs.pop());
  18506. }
  18507. }
  18508. return htmlparsedArrays;
  18509. },
  18510. /**
  18511. * 非空子元素数量
  18512. */
  18513. notEmptyTagCount: function notEmptyTagCount(htmlItem) {
  18514. if (!htmlItem || htmlItem.voidElement || htmlItem.type === 'tag' && !htmlItem.children.length || htmlItem.type === 'text' && !htmlItem.content.replace(/(\r|\n|\s)+/g, '')) {
  18515. return 0;
  18516. }
  18517. if (htmlItem.children && htmlItem.children.length) {
  18518. var res = 0;
  18519. for (var index = 0; index < htmlItem.children.length; index++) {
  18520. res += this.notEmptyTagCount(htmlItem.children[index]);
  18521. }
  18522. return res;
  18523. }
  18524. return 1;
  18525. },
  18526. clearChildColorAttrs: function clearChildColorAttrs(htmlItems) {
  18527. var self = this;
  18528. this.forEachHtmlParsedItems(htmlItems, function (htmlItem) {
  18529. self.clearSelfNodeColorAttrs(htmlItem);
  18530. });
  18531. },
  18532. clearSelfNodeColorAttrs: function clearSelfNodeColorAttrs(htmlItem) {
  18533. if (htmlItem.attrs && htmlItem.attrs.style) {
  18534. var styles = htmlItem.attrs.style.split(';');
  18535. var newStyles = [];
  18536. for (var index = 0; index < styles.length; index++) {
  18537. var _context21;
  18538. if (styles[index] && indexOf$8(_context21 = styles[index]).call(_context21, 'color') === -1) {
  18539. newStyles.push(styles[index]);
  18540. }
  18541. }
  18542. if (newStyles.length) {
  18543. htmlItem.attrs.style = "".concat(newStyles.join(';'), ";");
  18544. } else {
  18545. delete htmlItem.attrs.style;
  18546. }
  18547. }
  18548. },
  18549. forEachHtmlParsedItems: function forEachHtmlParsedItems(htmlItems, cb) {
  18550. if (htmlItems) {
  18551. cb(htmlItems);
  18552. if (htmlItems.children && htmlItems.children.length) {
  18553. for (var index = 0; index < htmlItems.children.length; index++) {
  18554. this.forEachHtmlParsedItems(htmlItems.children[index], cb);
  18555. }
  18556. }
  18557. }
  18558. }
  18559. };
  18560. var assign$3 = assign$1;
  18561. var assign$4 = assign$3;
  18562. var assign$5 = assign$4;
  18563. var assign$6 = assign$5;
  18564. var _extends_1 = createCommonjsModule(function (module) {
  18565. function _extends() {
  18566. module.exports = _extends = assign$6 || function (target) {
  18567. for (var i = 1; i < arguments.length; i++) {
  18568. var source = arguments[i];
  18569. for (var key in source) {
  18570. if (Object.prototype.hasOwnProperty.call(source, key)) {
  18571. target[key] = source[key];
  18572. }
  18573. }
  18574. }
  18575. return target;
  18576. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18577. return _extends.apply(this, arguments);
  18578. }
  18579. module.exports = _extends, module.exports.__esModule = true, module.exports["default"] = module.exports;
  18580. });
  18581. var _extends = unwrapExports(_extends_1);
  18582. var trim$5 = stringTrim.trim;
  18583. var charAt$3 = functionUncurryThis(''.charAt);
  18584. var n$ParseFloat = global_1.parseFloat;
  18585. var Symbol$4 = global_1.Symbol;
  18586. var ITERATOR$6 = Symbol$4 && Symbol$4.iterator;
  18587. var FORCED$5 = 1 / n$ParseFloat(whitespaces + '-0') !== -Infinity
  18588. // MS Edge 18- broken with boxed symbols
  18589. || (ITERATOR$6 && !fails(function () { n$ParseFloat(Object(ITERATOR$6)); }));
  18590. // `parseFloat` method
  18591. // https://tc39.es/ecma262/#sec-parsefloat-string
  18592. var numberParseFloat = FORCED$5 ? function parseFloat(string) {
  18593. var trimmedString = trim$5(toString_1(string));
  18594. var result = n$ParseFloat(trimmedString);
  18595. return result === 0 && charAt$3(trimmedString, 0) == '-' ? -0 : result;
  18596. } : n$ParseFloat;
  18597. // `parseFloat` method
  18598. // https://tc39.es/ecma262/#sec-parsefloat-string
  18599. _export({ global: true, forced: parseFloat != numberParseFloat }, {
  18600. parseFloat: numberParseFloat
  18601. });
  18602. var _parseFloat = path.parseFloat;
  18603. var _parseFloat$1 = _parseFloat;
  18604. var _parseFloat$2 = _parseFloat$1;
  18605. /**
  18606. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  18607. *
  18608. * Licensed under the Apache License, Version 2.0 (the "License");
  18609. * you may not use this file except in compliance with the License.
  18610. * You may obtain a copy of the License at
  18611. *
  18612. * http://www.apache.org/licenses/LICENSE-2.0
  18613. *
  18614. * Unless required by applicable law or agreed to in writing, software
  18615. * distributed under the License is distributed on an "AS IS" BASIS,
  18616. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18617. * See the License for the specific language governing permissions and
  18618. * limitations under the License.
  18619. */
  18620. function mergeMarginBottom(bottom, top) {
  18621. var currentBottom = _parseFloat$2(bottom);
  18622. var nextTop = _parseFloat$2(top);
  18623. if (nextTop >= 0) {
  18624. // 不受合并影响
  18625. return currentBottom;
  18626. }
  18627. if (currentBottom >= 0) {
  18628. return currentBottom + nextTop;
  18629. } // 同时为负数,取最小的
  18630. return Math.min(currentBottom, nextTop);
  18631. }
  18632. function mergeMarginTop(bottom, top) {
  18633. var prevBottom = _parseFloat$2(bottom);
  18634. var currentTop = _parseFloat$2(top);
  18635. if (currentTop < 0) {
  18636. // 负数的margin都被上一个区块吸收了
  18637. return 0;
  18638. }
  18639. if (prevBottom >= 0) {
  18640. // 如果当前margin-top比上一个margin-bottom要大,则只合并部分;反之合并全部,归属于上一个区块
  18641. return Math.max(currentTop - prevBottom, 0);
  18642. } // 上一个margin-bottom为负数不受影响
  18643. return currentTop;
  18644. }
  18645. /**
  18646. * 用于解决块级元素边距合并问题
  18647. * @param {HTMLElement} element
  18648. */
  18649. function getBlockTopAndHeightWithMargin(element) {
  18650. var prevSibling = element.previousElementSibling;
  18651. var nextSibling = element.nextElementSibling;
  18652. if (!prevSibling) {
  18653. var _style = getComputedStyle(element);
  18654. var _rect = element.getBoundingClientRect();
  18655. if (!nextSibling) {
  18656. return {
  18657. // marginBottom可能为负数
  18658. height: Math.max(_parseFloat$2(_style.marginTop) + _rect.height + _parseFloat$2(_style.marginBottom), 0),
  18659. offsetTop: element.offsetTop - Math.abs(_parseFloat$2(_style.marginTop))
  18660. };
  18661. }
  18662. var _nextSibStyle = getComputedStyle(nextSibling);
  18663. var _marginBottom = mergeMarginBottom(_style.marginBottom, _nextSibStyle.marginTop);
  18664. return {
  18665. height: Math.max(_parseFloat$2(_style.marginTop) + _rect.height + _marginBottom, 0),
  18666. // marginBottom可能为负数
  18667. offsetTop: element.offsetTop - Math.abs(_parseFloat$2(_style.marginTop))
  18668. };
  18669. }
  18670. var style = getComputedStyle(element);
  18671. var rect = element.getBoundingClientRect();
  18672. var prevSibStyle = getComputedStyle(prevSibling);
  18673. var marginTop = mergeMarginTop(prevSibStyle.marginBottom, style.marginTop);
  18674. if (!nextSibling) {
  18675. return {
  18676. height: Math.max(marginTop + rect.height + _parseFloat$2(style.marginBottom), 0),
  18677. // marginBottom可能为负数
  18678. offsetTop: element.offsetTop - Math.abs(_parseFloat$2(style.marginTop))
  18679. };
  18680. }
  18681. var nextSibStyle = getComputedStyle(nextSibling);
  18682. var marginBottom = mergeMarginBottom(style.marginBottom, nextSibStyle.marginTop);
  18683. return {
  18684. height: Math.max(marginTop + rect.height + marginBottom, 0),
  18685. // marginBottom可能为负数
  18686. offsetTop: element.offsetTop - Math.abs(marginTop)
  18687. };
  18688. }
  18689. /**
  18690. * document.elementsFromPoint polyfill
  18691. * ref: https://github.com/JSmith01/elementsfrompoint-polyfill/blob/master/index.js
  18692. * @param {number} x
  18693. * @param {number} y
  18694. */
  18695. function elementsFromPoint(x, y) {
  18696. // see https://caniuse.com/#search=elementsFromPoint
  18697. if (typeof document.elementsFromPoint === 'function') {
  18698. return document.elementsFromPoint(x, y);
  18699. }
  18700. if (typeof
  18701. /** @type {any}*/
  18702. document.msElementsFromPoint === 'function') {
  18703. var nodeList =
  18704. /** @type {any}*/
  18705. document.msElementsFromPoint(x, y);
  18706. return nodeList !== null ? from_1$2(nodeList) : nodeList;
  18707. }
  18708. var elements = [];
  18709. var pointerEvents = [];
  18710. /** @type {HTMLElement} */
  18711. var ele;
  18712. do {
  18713. var currentElement =
  18714. /** @type {HTMLElement} */
  18715. document.elementFromPoint(x, y);
  18716. if (ele !== currentElement) {
  18717. ele = currentElement;
  18718. elements.push(ele);
  18719. pointerEvents.push(ele.style.pointerEvents);
  18720. ele.style.pointerEvents = 'none';
  18721. } else {
  18722. ele = null;
  18723. }
  18724. } while (ele);
  18725. forEach$3(elements).call(elements, function (e, index) {
  18726. e.style.pointerEvents = pointerEvents[index];
  18727. });
  18728. return elements;
  18729. }
  18730. function getHTML(who, deep) {
  18731. if (!who || !who.tagName) {
  18732. return '';
  18733. }
  18734. var txt;
  18735. var ax;
  18736. var el = document.createElement('div');
  18737. el.appendChild(who.cloneNode(false));
  18738. txt = el.innerHTML;
  18739. if (deep) {
  18740. ax = indexOf$8(txt).call(txt, '>') + 1;
  18741. txt = txt.substring(0, ax) + who.innerHTML + txt.substring(ax);
  18742. }
  18743. el = null;
  18744. return txt;
  18745. }
  18746. /**
  18747. * @template {keyof HTMLElementTagNameMap} K
  18748. * @param {K} tagName 标签名
  18749. * @param {string} className 元素类名
  18750. * @param {Record<string,string>} attributes 附加属性
  18751. * @returns {HTMLElementTagNameMap[K]}
  18752. */
  18753. function createElement(tagName) {
  18754. var className = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  18755. var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  18756. var element = document.createElement(tagName);
  18757. element.className = className;
  18758. if (typeof attributes !== 'undefined') {
  18759. var _context;
  18760. forEach$3(_context = keys$3(attributes)).call(_context, function (key) {
  18761. var value = attributes[key];
  18762. if (startsWith$3(key).call(key, 'data-')) {
  18763. var dataName = key.replace(/^data-/, '');
  18764. element.dataset[dataName] = value;
  18765. return;
  18766. }
  18767. element.setAttribute(key, value);
  18768. });
  18769. }
  18770. return element;
  18771. }
  18772. var SAFE_AREA_MARGIN = 15;
  18773. /**
  18774. * Cherry实现了将粘贴的html内容转成对应的markdown源码的功能
  18775. * 本工具主要实现将粘贴html转成的markdown源码在编辑器中选中,并给出切换按钮
  18776. * 可以切换为纯文本内容,或者markdown内容
  18777. */
  18778. var pasteHelper = {
  18779. /**
  18780. * 核心方法,粘贴后展示切换按钮
  18781. * 只有粘贴html时才会出现切换按钮
  18782. * @param {Object} currentCursor 当前的光标位置
  18783. * @param {Object} editor 编辑器对象
  18784. * @param {string} html html里的纯文本内容
  18785. * @param {string} md html对应的markdown源码
  18786. * @returns
  18787. */
  18788. showSwitchBtnAfterPasteHtml: function showSwitchBtnAfterPasteHtml($cherry, currentCursor, editor, html, md) {
  18789. if (trim$3(html).call(html) === trim$3(md).call(md)) {
  18790. return;
  18791. }
  18792. this.init($cherry, currentCursor, editor, html, md);
  18793. this.setSelection();
  18794. this.bindListener();
  18795. this.initBubble();
  18796. this.showBubble(); // 默认粘贴成markdown格式,如果用户上次选择粘贴为纯文本,则需要切换为text
  18797. if (this.getTypeFromLocalStorage() === 'text') {
  18798. this.switchTextClick();
  18799. }
  18800. },
  18801. init: function init($cherry, currentCursor, editor, html, md) {
  18802. this.$cherry = $cherry;
  18803. this.html = html;
  18804. this.md = md;
  18805. this.codemirror = editor;
  18806. this.currentCursor = currentCursor;
  18807. this.locale = $cherry.locale;
  18808. },
  18809. /**
  18810. * 获取缓存中的复制粘贴类型
  18811. */
  18812. getTypeFromLocalStorage: function getTypeFromLocalStorage() {
  18813. if (typeof localStorage === 'undefined') {
  18814. return 'md';
  18815. }
  18816. return localStorage.getItem('cherry-paste-type') || 'md';
  18817. },
  18818. /**
  18819. * 记忆最近一次用户选择的粘贴类型
  18820. */
  18821. setTypeToLocalStorage: function setTypeToLocalStorage(type) {
  18822. if (typeof localStorage === 'undefined') {
  18823. return;
  18824. }
  18825. localStorage.setItem('cherry-paste-type', type);
  18826. },
  18827. /**
  18828. * 在编辑器中自动选中刚刚粘贴的内容
  18829. */
  18830. setSelection: function setSelection() {
  18831. var _this$codemirror$getC = this.codemirror.getCursor(),
  18832. end = _extends({}, _this$codemirror$getC);
  18833. var begin = this.currentCursor;
  18834. this.codemirror.setSelection(begin, end);
  18835. },
  18836. /**
  18837. * 绑定事件
  18838. * 当编辑器选中区域改变、内容改变时,隐藏切换按钮
  18839. * 当编辑器滚动时,实时更新切换按钮的位置
  18840. * @returns null
  18841. */
  18842. bindListener: function bindListener() {
  18843. var _this = this;
  18844. if (!this.hasBindListener) {
  18845. this.hasBindListener = true;
  18846. } else {
  18847. return true;
  18848. }
  18849. this.codemirror.on('beforeSelectionChange', function (codemirror, info) {
  18850. _this.hideBubble();
  18851. });
  18852. this.codemirror.on('beforeChange', function (codemirror, info) {
  18853. _this.hideBubble();
  18854. });
  18855. this.codemirror.on('scroll', function (codemirror) {
  18856. _this.updatePositionWhenScroll();
  18857. });
  18858. },
  18859. isHidden: function isHidden() {
  18860. return this.bubbleDom.style.display === 'none';
  18861. },
  18862. toggleBubbleDisplay: function toggleBubbleDisplay() {
  18863. if (this.isHidden()) {
  18864. this.bubbleDom.style.display = '';
  18865. return;
  18866. }
  18867. this.bubbleDom.style.display = 'none';
  18868. return;
  18869. },
  18870. hideBubble: function hideBubble() {
  18871. if (this.noHide) {
  18872. return true;
  18873. }
  18874. if (this.isHidden()) {
  18875. return;
  18876. }
  18877. this.toggleBubbleDisplay();
  18878. },
  18879. updatePositionWhenScroll: function updatePositionWhenScroll() {
  18880. if (this.isHidden()) {
  18881. return;
  18882. } // FIXME: update position when stick to the bottom
  18883. // const isStickToBottom = !this.bubbleDom.style.top;
  18884. var offset = this.bubbleDom.dataset.scrollTop - this.getScrollTop();
  18885. this.bubbleDom.style.marginTop = "".concat(offset, "px");
  18886. },
  18887. getScrollTop: function getScrollTop() {
  18888. return this.codemirror.getScrollInfo().top;
  18889. },
  18890. showBubble: function showBubble() {
  18891. var _this$getLastSelected = this.getLastSelectedPosition(),
  18892. top = _this$getLastSelected.top;
  18893. if (this.isHidden()) {
  18894. this.toggleBubbleDisplay();
  18895. this.bubbleDom.style.marginTop = '0';
  18896. this.bubbleDom.dataset.scrollTop = this.getScrollTop();
  18897. }
  18898. /**
  18899. * @type {HTMLDivElement}
  18900. */
  18901. var codemirrorWrapper = this.codemirror.getWrapperElement();
  18902. var maxTop = codemirrorWrapper.clientHeight - this.bubbleDom.getBoundingClientRect().height - SAFE_AREA_MARGIN;
  18903. if (top > maxTop) {
  18904. this.bubbleDom.style.top = '';
  18905. this.bubbleDom.style.bottom = "".concat(SAFE_AREA_MARGIN, "px");
  18906. } else {
  18907. this.bubbleDom.style.top = "".concat(top, "px");
  18908. this.bubbleDom.style.bottom = '';
  18909. }
  18910. },
  18911. initBubble: function initBubble() {
  18912. var _context, _context2;
  18913. if (this.bubbleDom) {
  18914. this.bubbleDom.setAttribute('data-type', 'md');
  18915. return true;
  18916. }
  18917. var dom = createElement('div', 'cherry-bubble cherry-bubble--centered cherry-switch-paste');
  18918. dom.style.display = 'none';
  18919. var switchText = createElement('span', 'cherry-toolbar-button cherry-text-btn', {
  18920. title: this.locale.pastePlain
  18921. });
  18922. switchText.innerText = 'TEXT';
  18923. var switchMd = createElement('span', 'cherry-toolbar-button cherry-md-btn', {
  18924. title: this.locale.pasteMarkdown
  18925. });
  18926. switchMd.innerText = 'Markdown';
  18927. var switchBG = createElement('span', 'switch-btn--bg');
  18928. this.bubbleDom = dom;
  18929. this.switchText = switchText;
  18930. this.switchMd = switchMd;
  18931. this.switchBG = switchBG;
  18932. this.bubbleDom.appendChild(switchText);
  18933. this.bubbleDom.appendChild(switchMd);
  18934. this.bubbleDom.appendChild(switchBG);
  18935. this.bubbleDom.setAttribute('data-type', 'md');
  18936. this.codemirror.getWrapperElement().appendChild(this.bubbleDom);
  18937. this.switchMd.addEventListener('click', bind$5(_context = this.switchMDClick).call(_context, this));
  18938. this.switchText.addEventListener('click', bind$5(_context2 = this.switchTextClick).call(_context2, this));
  18939. },
  18940. switchMDClick: function switchMDClick(event) {
  18941. this.setTypeToLocalStorage('md');
  18942. if (this.bubbleDom.getAttribute('data-type') === 'md') {
  18943. return;
  18944. }
  18945. this.noHide = true;
  18946. this.bubbleDom.setAttribute('data-type', 'md');
  18947. this.codemirror.doc.replaceSelection(this.md);
  18948. this.setSelection();
  18949. this.showBubble();
  18950. this.noHide = false;
  18951. },
  18952. switchTextClick: function switchTextClick(event) {
  18953. this.setTypeToLocalStorage('text');
  18954. if (this.bubbleDom.getAttribute('data-type') === 'text') {
  18955. return;
  18956. }
  18957. this.noHide = true;
  18958. this.bubbleDom.setAttribute('data-type', 'text');
  18959. this.codemirror.doc.replaceSelection(this.html);
  18960. this.setSelection();
  18961. this.showBubble();
  18962. this.noHide = false;
  18963. },
  18964. getLastSelectedPosition: function getLastSelectedPosition() {
  18965. var selectedObjs = from_1$2(this.codemirror.getWrapperElement().getElementsByClassName('CodeMirror-selected'));
  18966. var width = 0;
  18967. var top = 0;
  18968. if (selectedObjs.length <= 0) {
  18969. this.hideBubble();
  18970. return {};
  18971. } // FIXME: remove redundant width calculation
  18972. for (var key = 0; key < selectedObjs.length; key++) {
  18973. var item = selectedObjs[key];
  18974. var position = item.getBoundingClientRect();
  18975. var tmpWidth = position.left + position.width / 2;
  18976. var tmpTop = position.top + position.height;
  18977. if (tmpTop > top && tmpWidth >= width) {
  18978. top = tmpTop;
  18979. }
  18980. if (tmpWidth > width) {
  18981. width = tmpWidth;
  18982. }
  18983. }
  18984. return {
  18985. top: top
  18986. };
  18987. }
  18988. };
  18989. /**
  18990. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  18991. *
  18992. * Licensed under the Apache License, Version 2.0 (the "License");
  18993. * you may not use this file except in compliance with the License.
  18994. * You may obtain a copy of the License at
  18995. *
  18996. * http://www.apache.org/licenses/LICENSE-2.0
  18997. *
  18998. * Unless required by applicable law or agreed to in writing, software
  18999. * distributed under the License is distributed on an "AS IS" BASIS,
  19000. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19001. * See the License for the specific language governing permissions and
  19002. * limitations under the License.
  19003. */
  19004. function addEvent(elm, evType, fn, useCapture) {
  19005. if (elm.addEventListener) {
  19006. elm.addEventListener(evType, fn, useCapture); // DOM2.0
  19007. return true;
  19008. }
  19009. if (elm.attachEvent) {
  19010. var r = elm.attachEvent("on".concat(evType), fn); // IE5+
  19011. return r;
  19012. }
  19013. elm["on".concat(evType)] = fn; // DOM 0
  19014. }
  19015. function removeEvent(elm, evType, fn, useCapture) {
  19016. if (elm.removeEventListener) {
  19017. elm.removeEventListener(evType, fn, useCapture); // DOM2.0
  19018. } else if (elm.detachEvent) {
  19019. var r = elm.detachEvent("on".concat(evType), fn); // IE5+
  19020. return r;
  19021. } else {
  19022. elm["on".concat(evType)] = null; // DOM 0
  19023. }
  19024. }
  19025. /**
  19026. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  19027. *
  19028. * Licensed under the Apache License, Version 2.0 (the "License");
  19029. * you may not use this file except in compliance with the License.
  19030. * You may obtain a copy of the License at
  19031. *
  19032. * http://www.apache.org/licenses/LICENSE-2.0
  19033. *
  19034. * Unless required by applicable law or agreed to in writing, software
  19035. * distributed under the License is distributed on an "AS IS" BASIS,
  19036. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19037. * See the License for the specific language governing permissions and
  19038. * limitations under the License.
  19039. */
  19040. // @ts-check
  19041. /** @type {Partial<Console>} */
  19042. var Logger = new Proxy({}, {
  19043. get: function get(target, prop, receiver) {
  19044. // @ts-ignore
  19045. if ( typeof console !== 'undefined' && prop in console) {
  19046. return console[prop];
  19047. }
  19048. return function () {};
  19049. }
  19050. });
  19051. function mitt(n){return {all:n=n||new Map,on:function(t,e){var i=n.get(t);i?i.push(e):n.set(t,[e]);},off:function(t,e){var i=n.get(t);i&&(e?i.splice(i.indexOf(e)>>>0,1):n.set(t,[]));},emit:function(t,e){var i=n.get(t);i&&i.slice().map(function(n){n(e);}),(i=n.get("*"))&&i.slice().map(function(n){n(t,e);});}}}
  19052. /**
  19053. * 事件管理
  19054. */
  19055. var Event$1 = new ( /*#__PURE__*/function () {
  19056. function Event() {
  19057. _classCallCheck(this, Event);
  19058. _defineProperty(this, "Events", {
  19059. previewerClose: 'previewer:close',
  19060. previewerOpen: 'previewer:open',
  19061. editorClose: 'editor:close',
  19062. editorOpen: 'editor:open',
  19063. toolbarHide: 'toolbar:hide',
  19064. toolbarShow: 'toolbar:show',
  19065. cleanAllSubMenus: 'cleanAllSubMenus' // 清除所有子菜单弹窗
  19066. });
  19067. _defineProperty(this, "emitter", mitt());
  19068. }
  19069. _createClass(Event, [{
  19070. key: "on",
  19071. value:
  19072. /**
  19073. * 注册监听事件
  19074. * @param {string} instanceId 接收消息的频道
  19075. * @param {string} event 要注册监听的事件
  19076. * @param {(event: any) => void} handler 事件回调
  19077. */
  19078. function on(instanceId, event, handler) {
  19079. var _context;
  19080. this.emitter.on(concat$5(_context = "".concat(instanceId, ":")).call(_context, event), handler);
  19081. }
  19082. /**
  19083. * 触发事件
  19084. * @param {string} instanceId 发送消息的频道
  19085. * @param {string} event 要触发的事件
  19086. */
  19087. }, {
  19088. key: "emit",
  19089. value: function emit(instanceId, event) {
  19090. var _context2;
  19091. this.emitter.emit(concat$5(_context2 = "".concat(instanceId, ":")).call(_context2, event));
  19092. }
  19093. }]);
  19094. return Event;
  19095. }())();
  19096. /**
  19097. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  19098. *
  19099. * Licensed under the Apache License, Version 2.0 (the "License");
  19100. * you may not use this file except in compliance with the License.
  19101. * You may obtain a copy of the License at
  19102. *
  19103. * http://www.apache.org/licenses/LICENSE-2.0
  19104. *
  19105. * Unless required by applicable law or agreed to in writing, software
  19106. * distributed under the License is distributed on an "AS IS" BASIS,
  19107. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19108. * See the License for the specific language governing permissions and
  19109. * limitations under the License.
  19110. */
  19111. /**
  19112. * 上传文件的逻辑,如果有callback,则不再走默认的替换文本的逻辑,而是调用callback
  19113. * @param {string} type 上传文件的类型
  19114. */
  19115. function handleUpload(editor) {
  19116. var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'image';
  19117. var accept = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '*';
  19118. // var callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  19119. // type为上传文件类型 image|video|audio|pdf|word
  19120. var input = document.createElement('input');
  19121. input.type = 'file';
  19122. input.id = 'fileUpload';
  19123. input.value = '';
  19124. input.style.display = 'none';
  19125. input.accept = accept; // document.body.appendChild(input);
  19126. input.multiple = 'multiple';
  19127. input.addEventListener('change', function (event) {
  19128. // @ts-ignore
  19129. // var _event$target$files = _slicedToArray(event.target.files, 1),
  19130. // file = _event$target$files[0]; // 文件上传后的回调函数可以由调用方自己实现
  19131. // 3xxx 20240607
  19132. let files = event.target.files;
  19133. for (let i = 0; i < files.length; i++) {
  19134. var file = files[i]
  19135. editor.options.fileUpload(file, function (url) {
  19136. var callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  19137. var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  19138. // 文件上传的默认回调行数,调用方可以完全不使用该函数
  19139. if (typeof url !== 'string' || !url) {
  19140. return;
  19141. }
  19142. if (callback) {
  19143. return callback(file.name, url, params);
  19144. }
  19145. var code = '';
  19146. if (type === 'image') {
  19147. var _context;
  19148. // 如果是图片,则返回固定的图片markdown源码
  19149. code = concat$5(_context = "![".concat(file.name, "](")).call(_context, url, ")");
  19150. } else if (type === 'video') {
  19151. var _context2;
  19152. // 如果是视频,则返回固定的视频markdown源码
  19153. code = concat$5(_context2 = "!video[".concat(file.name, "](")).call(_context2, url, ")");
  19154. } else if (type === 'audio') {
  19155. var _context3;
  19156. // 如果是音频,则返回固定的音频markdown源码
  19157. code = concat$5(_context3 = "!audio[".concat(file.name, "](")).call(_context3, url, ")");
  19158. } else {
  19159. var _context4;
  19160. // 默认返回超链接
  19161. code = concat$5(_context4 = "[".concat(file.name, "](")).call(_context4, url, ")");
  19162. } // 替换选中区域
  19163. // @ts-ignore
  19164. editor.editor.doc.replaceSelection(code);
  19165. });
  19166. }
  19167. });
  19168. input.click();
  19169. }
  19170. /**
  19171. * 解析params参数
  19172. * @param params?.isBorder 是否有边框样式(图片场景下生效)
  19173. * @param params?.isShadow 是否有阴影样式(图片场景下生效)
  19174. * @param params?.isRadius 是否有圆角样式(图片场景下生效)
  19175. * @param params?.width 设置宽度,可以是像素、也可以是百分比(图片、视频场景下生效)
  19176. * @param params?.height 设置高度,可以是像素、也可以是百分比(图片、视频场景下生效)
  19177. */
  19178. function handelParams(params) {
  19179. var ret = [];
  19180. if (params.isBorder) {
  19181. ret.push('#B');
  19182. }
  19183. if (params.isShadow) {
  19184. ret.push('#S');
  19185. }
  19186. if (params.isRadius) {
  19187. ret.push('#R');
  19188. }
  19189. if (params.width) {
  19190. ret.push("#".concat(params.width));
  19191. }
  19192. if (params.height) {
  19193. if (!params.width) {
  19194. ret.push('#auto');
  19195. }
  19196. ret.push("#".concat(params.height));
  19197. }
  19198. return ret.join(' ');
  19199. }
  19200. /**
  19201. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  19202. *
  19203. * Licensed under the Apache License, Version 2.0 (the "License");
  19204. * you may not use this file except in compliance with the License.
  19205. * You may obtain a copy of the License at
  19206. *
  19207. * http://www.apache.org/licenses/LICENSE-2.0
  19208. *
  19209. * Unless required by applicable law or agreed to in writing, software
  19210. * distributed under the License is distributed on an "AS IS" BASIS,
  19211. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19212. * See the License for the specific language governing permissions and
  19213. * limitations under the License.
  19214. */
  19215. function compileRegExp(obj, flags, allowExtendedFlags) {
  19216. var source = obj.begin + obj.content + obj.end;
  19217. if (allowExtendedFlags) {
  19218. // Extend \h for horizontal whitespace
  19219. source = source.replace(/\[\\h\]/g, HORIZONTAL_WHITESPACE).replace(/\\h/g, HORIZONTAL_WHITESPACE);
  19220. }
  19221. return new RegExp(source, flags || 'g');
  19222. }
  19223. function isLookbehindSupported() {
  19224. try {
  19225. new RegExp('(?<=.)');
  19226. return true;
  19227. } catch (ignore) {}
  19228. return false;
  19229. }
  19230. var HORIZONTAL_WHITESPACE = "[ \\t\\u00a0]"; // 仅适用非多行模式的正则
  19231. var ALLOW_WHITESPACE_MULTILINE = '(?:.*?)(?:(?:\\n.*?)*?)';
  19232. var DO_NOT_STARTS_AND_END_WITH_SPACES_MULTILINE_ALLOW_EMPTY = '(?:(?:\\S|(?:\\S.*?\\S))(?:[ \\t]*\\n.*?)*?)';
  19233. var NOT_ALL_WHITE_SPACES_INLINE = '(?:[^\\n]*?\\S[^\\n]*?)';
  19234. // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., / (U+0021–2F),
  19235. // :, ;, <, =, >, ?, @ (U+003A–0040),
  19236. // [, \, ], ^, _, ` (U+005B–0060),
  19237. // {, |, }, or ~ (U+007B–007E).
  19238. var PUNCTUATION = "[\\u0021-\\u002F\\u003a-\\u0040\\u005b-\\u0060\\u007b-\\u007e]"; // extra punctuations
  19239. var UNDERSCORE_EMPHASIS_BOUNDARY = '[' + "\\u0021-\\u002F\\u003a-\\u0040\\u005b\\u005d\\u005e\\u0060\\u007b-\\u007e" + // punctuations defined in commonmark
  19240. ' ' + '\\t\\n' + '!“”¥‘’(),。—:;《》?【】「」·~|' + // chinese punctuations
  19241. ']'; // https://html.spec.whatwg.org/multipage/input.html#e-mail-state-(type%3Demail)
  19242. var EMAIL_INLINE = new RegExp([/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+/.source, '@', /[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*/.source].join(''));
  19243. var EMAIL = new RegExp("^".concat(EMAIL_INLINE.source, "$")); // https://gist.github.com/dperini/729294
  19244. // [USERNAME[:PASSWORD]@](IP|HOST)[:PORT][/SOURCE_PATH?QUERY_PARAMS#HASH]
  19245. var URL_INLINE_NO_SLASH = new RegExp('' + // 针对eslint的特殊处理
  19246. '(?:\\S+(?::\\S*)?@)?' + '(?:' + // IP address exclusion
  19247. // IP address dotted notation octets
  19248. // excludes loopback network 0.0.0.0
  19249. // excludes reserved space >= 224.0.0.0
  19250. // excludes network & broadcast addresses
  19251. // (first & last IP address of each class)
  19252. '(?:1\\d\\d|2[01]\\d|22[0-3]|[1-9]\\d?)' + '(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}' + '(?:\\.(?:1\\d\\d|2[0-4]\\d|25[0-4]|[1-9]\\d?))' + '|' + // host & domain names, may end with dot
  19253. '(?![-_])(?:[-\\w\\xa1-\\xff]{0,63}[^-_]\\.)+' + // TLD identifier name, may end with dot
  19254. '(?:[a-zA-Z\\xa1-\\xff]{2,}\\.?)' + ')' + // port number (optional)
  19255. '(?::\\d{2,5})?' + // resource path (optional)
  19256. '(?:[/?#][^\\s<>\\x00-\\x1f"\\(\\)]*)?');
  19257. var URL_INLINE = new RegExp( // eslint特殊处理
  19258. // protocol identifier (optional)
  19259. // short syntax // still required
  19260. // '(?:(?:(?:https?|ftp):)?\\/\\/)' +
  19261. "(?:\\/\\/)".concat(URL_INLINE_NO_SLASH.source));
  19262. var URL_NO_SLASH = new RegExp("^".concat(URL_INLINE_NO_SLASH.source, "$"));
  19263. var URL$1 = new RegExp("^".concat(URL_INLINE.source, "$"));
  19264. function getTableRule() {
  19265. var _context;
  19266. var merge = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  19267. // ^(\|[^\n]+\|\r?\n)((?:\|:?[-]+:?)+\|)(\n(?:\|[^\n]+\|\r?\n?)*)?$
  19268. // (\\|?[^\\n|]+\\|?\\n)(?:\\|?[\\s]*:?[-]{2,}:?[\\s]*
  19269. // (?:\\|[\\s]*:?[-]{2,}:?[\\s]*)+\\|?)(\\n\\|?(\\|[^\\n|]+)*\\|?)?
  19270. /**
  19271. * (\|[^\n]+\|\n) Headers
  19272. * ((\|[\s]*:?[-]{2,}:?[\s]*)+\|) Column Options
  19273. * ((?:\n\|[^\n]+\|)*) Rows
  19274. */
  19275. var strict = {
  19276. begin: '(?:^|\\n)(\\n*)',
  19277. content: ['(\\h*\\|[^\\n]+\\|?\\h*)', // Header
  19278. '\\n', '(?:(?:\\h*\\|\\h*:?[-]{1,}:?\\h*)+\\|?\\h*)', // Column Options
  19279. '((\\n\\h*\\|[^\\n]+\\|?\\h*)*)' // Rows
  19280. ].join(''),
  19281. end: '(?=$|\\n)'
  19282. };
  19283. strict.reg = compileRegExp(strict, 'g', true);
  19284. var loose = {
  19285. begin: '(?:^|\\n)(\\n*)',
  19286. content: ['(\\|?[^\\n|]+(\\|[^\\n|]+)+\\|?)', // Header
  19287. '\\n', '(?:\\|?\\h*:?[-]{1,}:?[\\h]*(?:\\|[\\h]*:?[-]{1,}:?\\h*)+\\|?)', // Column Options
  19288. '((\\n\\|?([^\\n|]+(\\|[^\\n|]*)+)\\|?)*)' // Rows
  19289. ].join(''),
  19290. end: '(?=$|\\n)'
  19291. };
  19292. loose.reg = compileRegExp(loose, 'g', true);
  19293. if (merge === false) {
  19294. return {
  19295. strict: strict,
  19296. loose: loose
  19297. };
  19298. }
  19299. var regStr = concat$5(_context = "(?:".concat(strict.begin + strict.content + strict.end, "|")).call(_context, loose.begin + loose.content + loose.end, ")");
  19300. return compileRegExp({
  19301. begin: '',
  19302. content: regStr,
  19303. end: ''
  19304. }, 'g', true);
  19305. }
  19306. function getCodeBlockRule() {
  19307. var codeBlock = {
  19308. /**
  19309. * (?:^|\n)是区块的通用开头
  19310. * (\n*)捕获区块前的所有换行
  19311. * ((?:>\s*)*) 捕获代码块前面的引用("> > > " 这种东西)
  19312. * (?:[^\S\n]*)捕获```前置的空格字符
  19313. * 只要有连续3个及以上`并且前后`的数量相等,则认为是代码快语法
  19314. */
  19315. begin: /(?:^|\n)(\n*((?:>[\t ]*)*)(?:[^\S\n]*))(`{3,})([^`]*?)\n/,
  19316. content: /([\w\W]*?)/,
  19317. // '([\\w\\W]*?)',
  19318. end: /[^\S\n]*\3[ \t]*(?=$|\n+)/ // '\\s*```[ \\t]*(?=$|\\n+)',
  19319. };
  19320. codeBlock.reg = new RegExp(codeBlock.begin.source + codeBlock.content.source + codeBlock.end.source, 'g');
  19321. return codeBlock;
  19322. }
  19323. /**
  19324. * 从selection里获取列表语法
  19325. * @param {*} selection
  19326. * @param {('ol'|'ul'|'checklist')} type 列表类型
  19327. * @returns {String}
  19328. */
  19329. function getListFromStr(selection, type) {
  19330. var $selection = selection ? selection : 'Item 1\n Item 1.1\nItem 2';
  19331. $selection = $selection.replace(/^\n+/, '').replace(/\n+$/, '');
  19332. var pre = '1.';
  19333. switch (type) {
  19334. case 'ol':
  19335. pre = '1.';
  19336. break;
  19337. case 'ul':
  19338. pre = '-';
  19339. break;
  19340. case 'checklist':
  19341. pre = '- [x]';
  19342. break;
  19343. }
  19344. $selection = $selection.replace(/^(\s*)([0-9a-zA-Z]+\.|- \[x\]|- \[ \]|-) /gm, '$1'); // 对有序列表进行序号自增处理
  19345. if (pre === '1.') {
  19346. var listNum = {};
  19347. $selection = $selection.replace(/^(\s*)(\S[\s\S]*?)$/gm, function (match, p1, p2) {
  19348. var _p1$match, _context2, _context3;
  19349. var space = ((_p1$match = p1.match(/[ \t]/g)) === null || _p1$match === void 0 ? void 0 : _p1$match.length) || 0;
  19350. listNum[space] = listNum[space] ? listNum[space] + 1 : 1;
  19351. return concat$5(_context2 = concat$5(_context3 = "".concat(p1)).call(_context3, listNum[space], ". ")).call(_context2, p2);
  19352. });
  19353. } else {
  19354. $selection = $selection.replace(/^(\s*)(\S[\s\S]*?)$/gm, "$1".concat(pre, " $2"));
  19355. }
  19356. return $selection;
  19357. }
  19358. /**
  19359. * 信息面板的识别正则
  19360. * @returns {object}
  19361. */
  19362. function getPanelRule() {
  19363. var ret = {
  19364. begin: /(?:^|\n)(\n*(?:[^\S\n]*)):::([^:][^\n]+?)\s*\n/,
  19365. content: /([\w\W]*?)/,
  19366. end: /\n[ \t]*:::[ \t]*(?=$|\n+)/
  19367. };
  19368. ret.reg = new RegExp(ret.begin.source + ret.content.source + ret.end.source, 'g');
  19369. return ret;
  19370. }
  19371. /**
  19372. * 手风琴/detail语法的识别正则
  19373. * 例:
  19374. * +++(-) 点击查看详情
  19375. * body
  19376. * body
  19377. * ++ 标题(默认收起内容)
  19378. * 内容
  19379. * ++- 标题(默认展开内容)
  19380. * 内容2
  19381. * +++
  19382. * @returns {object}
  19383. */
  19384. function getDetailRule() {
  19385. var ret = {
  19386. begin: /(?:^|\n)(\n*(?:[^\S\n]*))\+\+\+([-]{0,1})\s+([^\n]+)\n/,
  19387. content: /([\w\W]+?)/,
  19388. end: /\n[ \t]*\+\+\+[ \t]*(?=$|\n+)/
  19389. };
  19390. ret.reg = new RegExp(ret.begin.source + ret.content.source + ret.end.source, 'g');
  19391. return ret;
  19392. } // 匹配图片URL里的base64
  19393. var imgBase64Reg = /(!\[[^\n]*?\]\(data:image\/png;base64,)([^)]+)\)/g; // 匹配图片{}里的data-xml属性
  19394. var imgDrawioXmlReg = /(!\[[^\n]*?\]\([^)]+\)\{[^}]* data-xml=)([^}]+)\}/g;
  19395. /**
  19396. * 匹配draw.io的图片语法
  19397. * 图片的语法为 ![alt](${base64}){data-type=drawio data-xml=${xml}}
  19398. */
  19399. var imgDrawioReg = /(!\[[^\n]*?\]\(data:image\/png;base64,[^)]+\)\{data-type=drawio data-xml=[^}]+\})/g;
  19400. /**
  19401. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  19402. *
  19403. * Licensed under the Apache License, Version 2.0 (the "License");
  19404. * you may not use this file except in compliance with the License.
  19405. * You may obtain a copy of the License at
  19406. *
  19407. * http://www.apache.org/licenses/LICENSE-2.0
  19408. *
  19409. * Unless required by applicable law or agreed to in writing, software
  19410. * distributed under the License is distributed on an "AS IS" BASIS,
  19411. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19412. * See the License for the specific language governing permissions and
  19413. * limitations under the License.
  19414. */
  19415. /**
  19416. * @param {CodeMirror.Editor} cm
  19417. */
  19418. function handleNewlineIndentList(cm) {
  19419. if (handleCherryList(cm)) return;
  19420. cm.execCommand('newlineAndIndentContinueMarkdownList');
  19421. }
  19422. function handleCherryList(cm) {
  19423. var cherryListRE = /^(\s*)([I一二三四五六七八九十]+)\.(\s+)/;
  19424. var cherryListEmptyRE = /^(\s*)([I一二三四五六七八九十]+)\.(\s+)$/;
  19425. if (cm.getOption('disableInput')) return false;
  19426. var ranges = cm.listSelections();
  19427. var replacements = [];
  19428. for (var i = 0; i < ranges.length; i++) {
  19429. var pos = ranges[i].head;
  19430. var line = cm.getLine(pos.line);
  19431. var match = cherryListRE.exec(line);
  19432. var cursorBeforeBullet = /^\s*$/.test(slice$7(line).call(line, 0, pos.ch));
  19433. if (!ranges[i].empty() || cursorBeforeBullet || !match) return;
  19434. if (cherryListEmptyRE.test(line)) {
  19435. cm.replaceRange('', {
  19436. line: pos.line,
  19437. ch: 0
  19438. }, {
  19439. line: pos.line,
  19440. ch: pos.ch + 1
  19441. });
  19442. replacements[i] = '\n';
  19443. } else {
  19444. var _context;
  19445. var indent = match[1];
  19446. var after = match[3];
  19447. replacements[i] = concat$5(_context = "\n".concat(indent, "I.")).call(_context, after);
  19448. }
  19449. }
  19450. cm.replaceSelections(replacements);
  19451. return true;
  19452. }
  19453. var _excluded = ["codemirror"];
  19454. /**
  19455. * @typedef {import('~types/editor').EditorConfiguration} EditorConfiguration
  19456. * @typedef {import('~types/editor').EditorEventCallback} EditorEventCallback
  19457. * @typedef {import('codemirror')} CodeMirror
  19458. */
  19459. /** @type {import('~types/editor')} */
  19460. var Editor = /*#__PURE__*/function () {
  19461. /**
  19462. * @constructor
  19463. * @param {Partial<EditorConfiguration>} options
  19464. */
  19465. function Editor(options) {
  19466. var _this = this;
  19467. _classCallCheck(this, Editor);
  19468. _defineProperty(this, "dealBigData", function () {
  19469. if (_this.noChange) {
  19470. _this.noChange = false;
  19471. return;
  19472. }
  19473. _this.formatBigData2Mark(imgBase64Reg, 'cm-url base64');
  19474. _this.formatBigData2Mark(imgDrawioXmlReg, 'cm-url drawio');
  19475. });
  19476. _defineProperty(this, "formatBigData2Mark", function (reg, className) {
  19477. var codemirror = _this.editor;
  19478. var searcher = codemirror.getSearchCursor(reg);
  19479. var oneSearch = searcher.findNext();
  19480. for (; oneSearch !== false; oneSearch = searcher.findNext()) {
  19481. var _oneSearch$, _oneSearch$2;
  19482. var target = searcher.from();
  19483. if (!target) {
  19484. continue;
  19485. }
  19486. var bigString = (_oneSearch$ = oneSearch[2]) !== null && _oneSearch$ !== void 0 ? _oneSearch$ : '';
  19487. var targetChFrom = target.ch + ((_oneSearch$2 = oneSearch[1]) === null || _oneSearch$2 === void 0 ? void 0 : _oneSearch$2.length);
  19488. var targetChTo = targetChFrom + bigString.length;
  19489. var targetLine = target.line;
  19490. var begin = {
  19491. line: targetLine,
  19492. ch: targetChFrom
  19493. };
  19494. var end = {
  19495. line: targetLine,
  19496. ch: targetChTo
  19497. }; // 如果所在区域已经有mark了,则不再增加mark
  19498. if (codemirror.findMarks(begin, end).length > 0) {
  19499. continue;
  19500. }
  19501. var newSpan = createElement('span', "cm-string ".concat(className), {
  19502. title: bigString
  19503. });
  19504. newSpan.textContent = bigString;
  19505. _this.noChange = true;
  19506. codemirror.markText(begin, end, {
  19507. replacedWith: newSpan,
  19508. atomic: true
  19509. });
  19510. }
  19511. });
  19512. _defineProperty(this, "onKeyup", function (e, codemirror) {
  19513. var _codemirror$getCursor = codemirror.getCursor(),
  19514. targetLine = _codemirror$getCursor.line;
  19515. _this.previewer.highlightLine(targetLine + 1);
  19516. });
  19517. _defineProperty(this, "onScroll", function (codemirror) {
  19518. Event$1.emit(_this.instanceId, Event$1.Events.cleanAllSubMenus); // 滚动时清除所有子菜单,这不应该在Bubble中处理,我们关注的是编辑器的滚动 add by ufec
  19519. if (_this.disableScrollListener) {
  19520. _this.disableScrollListener = false;
  19521. return;
  19522. }
  19523. var scroller = codemirror.getScrollerElement();
  19524. if (scroller.scrollTop <= 0) {
  19525. _this.previewer.scrollToLineNum(0);
  19526. return;
  19527. }
  19528. if (scroller.scrollTop + scroller.clientHeight >= scroller.scrollHeight - 20) {
  19529. _this.previewer.scrollToLineNum(null); // 滚动到底
  19530. return;
  19531. }
  19532. var currentTop = codemirror.getScrollInfo().top;
  19533. var targetLine = codemirror.lineAtHeight(currentTop, 'local');
  19534. var lineRect = codemirror.charCoords({
  19535. line: targetLine,
  19536. ch: 0
  19537. }, 'local');
  19538. var lineHeight = codemirror.getLineHandle(targetLine).height;
  19539. var lineTop = lineRect.bottom - lineHeight; // 直接用lineRect.top在自动折行时计算的是最后一行的top
  19540. var percent = 100 * (currentTop - lineTop) / lineHeight / 100; // console.log(percent);
  19541. // codemirror中行号以0开始,所以需要+1
  19542. _this.previewer.scrollToLineNum(targetLine + 1, percent);
  19543. });
  19544. _defineProperty(this, "onMouseDown", function (codemirror, evt) {
  19545. Event$1.emit(_this.instanceId, Event$1.Events.cleanAllSubMenus); // Bubble中处理需要考虑太多,直接在编辑器中处理可包括Bubble中所有情况,因为产生Bubble的前提是光标在编辑器中 add by ufec
  19546. var _codemirror$getCursor2 = codemirror.getCursor(),
  19547. targetLine = _codemirror$getCursor2.line;
  19548. var top = Math.abs(evt.y - codemirror.getWrapperElement().getBoundingClientRect().y);
  19549. _this.previewer.scrollToLineNumWithOffset(targetLine + 1, top);
  19550. });
  19551. _defineProperty(this, "onCursorActivity", function () {
  19552. _this.refreshWritingStatus();
  19553. });
  19554. /**
  19555. * @property
  19556. * @type {EditorConfiguration}
  19557. */
  19558. this.options = {
  19559. id: 'code',
  19560. // textarea 的id属性值
  19561. name: 'code',
  19562. // textarea 的name属性值
  19563. autoSave2Textarea: false,
  19564. editorDom: document.createElement('div'),
  19565. wrapperDom: null,
  19566. autoScrollByCursor: true,
  19567. convertWhenPaste: true,
  19568. codemirror: {
  19569. lineNumbers: false,
  19570. // 显示行数
  19571. cursorHeight: 0.85,
  19572. // 光标高度,0.85好看一些
  19573. indentUnit: 4,
  19574. // 缩进单位为4
  19575. tabSize: 4,
  19576. // 一个tab转换成的空格数量
  19577. // styleActiveLine: false, // 当前行背景高亮
  19578. // matchBrackets: true, // 括号匹配
  19579. mode: 'gfm',
  19580. // 从markdown模式改成gfm模式,以使用默认高亮规则
  19581. lineWrapping: true,
  19582. // 自动换行
  19583. indentWithTabs: true,
  19584. // 缩进用tab表示
  19585. autofocus: true,
  19586. theme: 'default',
  19587. autoCloseTags: true,
  19588. // 输入html标签时自动补充闭合标签
  19589. extraKeys: {
  19590. Enter: handleNewlineIndentList
  19591. },
  19592. // 增加markdown回车自动补全
  19593. matchTags: {
  19594. bothTags: true
  19595. },
  19596. // 自动高亮选中的闭合html标签
  19597. placeholder: '',
  19598. // 设置为 contenteditable 对输入法定位更友好
  19599. // 但已知会影响某些悬浮菜单的定位,如粘贴选择文本或markdown模式的菜单
  19600. // inputStyle: 'contenteditable',
  19601. keyMap: 'sublime'
  19602. },
  19603. toolbars: {},
  19604. onKeydown: function onKeydown() {},
  19605. onChange: function onChange() {},
  19606. onFocus: function onFocus() {},
  19607. onBlur: function onBlur() {},
  19608. onPaste: this.onPaste,
  19609. onScroll: this.onScroll
  19610. };
  19611. /**
  19612. * @property
  19613. * @private
  19614. * @type {{ timer?: number; destinationTop?: number }}
  19615. */
  19616. this.animation = {};
  19617. var _codemirror = options.codemirror,
  19618. restOptions = _objectWithoutProperties(options, _excluded);
  19619. if (_codemirror) {
  19620. assign$2(this.options.codemirror, _codemirror);
  19621. }
  19622. assign$2(this.options, restOptions);
  19623. this.$cherry = this.options.$cherry;
  19624. this.instanceId = this.$cherry.getInstanceId();
  19625. }
  19626. /**
  19627. * 处理draw.io的xml数据和图片的base64数据,对这种超大的数据增加省略号
  19628. */
  19629. _createClass(Editor, [{
  19630. key: "onPaste",
  19631. value:
  19632. /**
  19633. *
  19634. * @param {ClipboardEvent} e
  19635. * @param {CodeMirror.Editor} codemirror
  19636. */
  19637. function onPaste(e, codemirror) {
  19638. var clipboardData = e.clipboardData;
  19639. if (clipboardData) {
  19640. this.handlePaste(e, clipboardData, codemirror);
  19641. } else {
  19642. var _window = window;
  19643. clipboardData = _window.clipboardData;
  19644. this.handlePaste(e, clipboardData, codemirror);
  19645. }
  19646. }
  19647. /**
  19648. *
  19649. * @param {ClipboardEvent} event
  19650. * @param {ClipboardEvent['clipboardData']} clipboardData
  19651. * @param {CodeMirror.Editor} codemirror
  19652. * @returns {boolean | void}
  19653. */
  19654. }, {
  19655. key: "handlePaste",
  19656. value: function handlePaste(event, clipboardData, codemirror) {
  19657. var _test$match;
  19658. var items = clipboardData.items;
  19659. var types = clipboardData.types || [];
  19660. var codemirrorDoc = codemirror.getDoc();
  19661. for (var i = 0; i < types.length; i++) {
  19662. var item = items[i]; // 判断是否为图片数据
  19663. if (item && item.kind === 'file' && item.type.match(/^image\//i)) {
  19664. // 读取该图片
  19665. var file = item.getAsFile();
  19666. this.options.fileUpload(file, function (url) {
  19667. if (typeof url !== 'string') {
  19668. return;
  19669. }
  19670. codemirrorDoc.replaceSelection("![enter image description here](".concat(url, ")"));
  19671. });
  19672. event.preventDefault();
  19673. }
  19674. } // 复制html转换markdown
  19675. var htmlText = clipboardData.getData('text/plain');
  19676. var html = clipboardData.getData('Text/Html');
  19677. if (!html || !this.options.convertWhenPaste) {
  19678. return true;
  19679. }
  19680. /**
  19681. * 这里需要处理一个特殊逻辑:
  19682. * 从excel中复制而来的内容,剪切板里会有一张图片(一个<img>元素)和一段纯文本,在这种场景下,需要丢掉图片,直接粘贴纯文本
  19683. * 与此同时,当剪切板里有图片和其他html标签时(从web页面上复制的内容),则需要走下面的html转md的逻辑
  19684. * 基于上述两个场景,才有了下面四行奇葩的代码
  19685. */
  19686. var test = html.replace(/<(html|head|body|!)/g, '');
  19687. if (((_test$match = test.match(/<[a-zA-Z]/g)) === null || _test$match === void 0 ? void 0 : _test$match.length) <= 1 && /<img/.test(test)) {
  19688. return true;
  19689. }
  19690. var divObj = document.createElement('DIV');
  19691. divObj.innerHTML = html;
  19692. html = divObj.innerHTML;
  19693. var mdText = htmlParser.run(html);
  19694. if (typeof mdText === 'string' && trim$3(mdText).call(mdText).length > 0) {
  19695. var range = codemirror.listSelections();
  19696. if (codemirror.getSelections().length <= 1 && range[0] && range[0].anchor) {
  19697. var currentCursor = {};
  19698. currentCursor.line = range[0].anchor.line;
  19699. currentCursor.ch = range[0].anchor.ch;
  19700. codemirrorDoc.replaceSelection(mdText);
  19701. pasteHelper.showSwitchBtnAfterPasteHtml(this.$cherry, currentCursor, codemirror, htmlText, mdText);
  19702. } else {
  19703. codemirrorDoc.replaceSelection(mdText);
  19704. }
  19705. event.preventDefault();
  19706. }
  19707. divObj = null;
  19708. }
  19709. /**
  19710. *
  19711. * @param {CodeMirror.Editor} codemirror
  19712. */
  19713. }, {
  19714. key: "init",
  19715. value:
  19716. /**
  19717. *
  19718. * @param {*} previewer
  19719. */
  19720. function init(previewer) {
  19721. var _this2 = this;
  19722. var textArea = this.options.editorDom.querySelector("#".concat(this.options.id));
  19723. if (!(textArea instanceof HTMLTextAreaElement)) {
  19724. throw new Error('The specific element is not a textarea.');
  19725. }
  19726. var editor = codemirror.fromTextArea(textArea, this.options.codemirror);
  19727. editor.addOverlay({
  19728. name: 'invisibles',
  19729. token: function nextToken(stream) {
  19730. var tokenClass;
  19731. var spaces = 0;
  19732. var peek = stream.peek() === ' ';
  19733. if (peek) {
  19734. while (peek && spaces < Number.MAX_VALUE) {
  19735. spaces += 1;
  19736. stream.next();
  19737. peek = stream.peek() === ' ';
  19738. }
  19739. tokenClass = "whitespace whitespace-".concat(spaces);
  19740. } else {
  19741. while (!stream.eol()) {
  19742. stream.next();
  19743. }
  19744. tokenClass = '';
  19745. }
  19746. return tokenClass;
  19747. }
  19748. });
  19749. this.previewer = previewer;
  19750. this.disableScrollListener = false;
  19751. if (this.options.value) {
  19752. editor.setOption('value', this.options.value);
  19753. }
  19754. editor.on('blur', function (codemirror, evt) {
  19755. _this2.options.onBlur(evt, codemirror);
  19756. });
  19757. editor.on('focus', function (codemirror, evt) {
  19758. _this2.options.onFocus(evt, codemirror);
  19759. });
  19760. editor.on('change', function (codemirror, evt) {
  19761. _this2.options.onChange(evt, codemirror);
  19762. _this2.dealBigData();
  19763. if (_this2.options.autoSave2Textarea) {
  19764. // @ts-ignore
  19765. // 将codemirror里的内容回写到textarea里
  19766. codemirror.save();
  19767. }
  19768. });
  19769. editor.on('keydown', function (codemirror, evt) {
  19770. _this2.options.onKeydown(evt, codemirror);
  19771. });
  19772. editor.on('keyup', function (codemirror, evt) {
  19773. _this2.onKeyup(evt, codemirror);
  19774. });
  19775. editor.on('paste', function (codemirror, evt) {
  19776. _this2.options.onPaste.call(_this2, evt, codemirror);
  19777. });
  19778. if (this.options.autoScrollByCursor) {
  19779. editor.on('mousedown', function (codemirror, evt) {
  19780. setTimeout$3(function () {
  19781. _this2.onMouseDown(codemirror, evt);
  19782. });
  19783. });
  19784. }
  19785. editor.on('drop', function (codemirror, evt) {
  19786. var files = evt.dataTransfer.files || [];
  19787. if (files && files.length > 0) {
  19788. // 增加延时,让drop的位置变成codemirror的光标位置
  19789. setTimeout$3(function () {
  19790. var _loop = function _loop(i, _needBr) {
  19791. var file = files[i];
  19792. var fileType = file.type || ''; // 文本类型或者无类型的,直接读取内容,不做上传文件的操作
  19793. if (fileType === '' || /^text/i.test(fileType)) {
  19794. needBr = _needBr;
  19795. return "continue";
  19796. }
  19797. _this2.options.fileUpload(file, function (url) {
  19798. var _context, _context2, _context3, _context4;
  19799. var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  19800. if (typeof url !== 'string') {
  19801. needBr = _needBr;
  19802. return;
  19803. } // 拖拽上传文件时,强制改成没有文字选择区的状态
  19804. codemirror.setSelection(codemirror.getCursor());
  19805. var name = params.name ? params.name : file.name;
  19806. var type = '';
  19807. var poster = '';
  19808. if (/video/i.test(file.type)) {
  19809. type = '!video';
  19810. poster = params.poster ? "{poster=".concat(params.poster, "}") : '';
  19811. }
  19812. if (/audio/i.test(file.type)) {
  19813. type = '!audio';
  19814. }
  19815. if (/image/i.test(file.type)) {
  19816. type = '!';
  19817. }
  19818. var style = type ? handelParams(params) : '';
  19819. type = _needBr ? "\n".concat(type) : type;
  19820. var insertValue = concat$5(_context = concat$5(_context2 = concat$5(_context3 = concat$5(_context4 = "".concat(type, "[")).call(_context4, name)).call(_context3, style, "](")).call(_context2, url, ")")).call(_context, poster); // 当批量上传文件时,每个被插入的文件中间需要加个换行,但单个上传文件的时候不需要加换行
  19821. _needBr = true;
  19822. codemirror.replaceSelection(insertValue);
  19823. });
  19824. needBr = _needBr;
  19825. };
  19826. for (var i = 0, needBr = false; i < files.length; i++) {
  19827. var _ret = _loop(i, needBr);
  19828. if (_ret === "continue") continue;
  19829. }
  19830. }, 50);
  19831. }
  19832. });
  19833. editor.on('scroll', function (codemirror) {
  19834. _this2.options.onScroll(codemirror);
  19835. _this2.options.writingStyle === 'focus' && _this2.refreshWritingStatus();
  19836. });
  19837. editor.on('cursorActivity', function () {
  19838. _this2.onCursorActivity();
  19839. });
  19840. addEvent(this.getEditorDom(), 'wheel', function () {
  19841. // 鼠标滚轮滚动时,强制监听滚动事件
  19842. _this2.disableScrollListener = false; // 打断滚动动画
  19843. cancelAnimationFrame(_this2.animation.timer);
  19844. _this2.animation.timer = 0;
  19845. }, false);
  19846. /**
  19847. * @property
  19848. * @type {CodeMirror.Editor}
  19849. */
  19850. this.editor = editor;
  19851. if (this.options.writingStyle !== 'normal') {
  19852. this.initWritingStyle();
  19853. }
  19854. }
  19855. /**
  19856. *
  19857. * @param {number | null} beginLine 起始行,传入null时跳转到文档尾部
  19858. * @param {number} [endLine] 终止行
  19859. * @param {number} [percent] 百分比,取值0~1
  19860. */
  19861. }, {
  19862. key: "jumpToLine",
  19863. value: function jumpToLine(beginLine, endLine, percent) {
  19864. var _this3 = this;
  19865. if (beginLine === null) {
  19866. cancelAnimationFrame(this.animation.timer);
  19867. this.disableScrollListener = true;
  19868. this.editor.scrollIntoView({
  19869. line: this.editor.lineCount() - 1,
  19870. ch: 1
  19871. });
  19872. this.animation.timer = 0;
  19873. return;
  19874. }
  19875. var position = this.editor.charCoords({
  19876. line: beginLine,
  19877. ch: 0
  19878. }, 'local');
  19879. var top = position.top;
  19880. var positionEnd = this.editor.charCoords({
  19881. line: beginLine + endLine,
  19882. ch: 0
  19883. }, 'local');
  19884. var height = positionEnd.top - position.top;
  19885. top += height * percent;
  19886. this.animation.destinationTop = Math.ceil(top - 15);
  19887. if (this.animation.timer) {
  19888. return;
  19889. }
  19890. var animationHandler = function animationHandler() {
  19891. var currentTop = _this3.editor.getScrollInfo().top;
  19892. var delta = _this3.animation.destinationTop - currentTop; // 100毫秒内完成动画
  19893. var move = Math.ceil(Math.min(Math.abs(delta), Math.max(1, Math.abs(delta) / (100 / 16.7)))); // console.log('should scroll: ', move, delta, currentTop, this.animation.destinationTop);
  19894. if (delta > 0) {
  19895. if (currentTop >= _this3.animation.destinationTop) {
  19896. _this3.animation.timer = 0;
  19897. return;
  19898. }
  19899. _this3.disableScrollListener = true;
  19900. _this3.editor.scrollTo(null, currentTop + move);
  19901. } else if (delta < 0) {
  19902. if (currentTop <= _this3.animation.destinationTop || currentTop <= 0) {
  19903. _this3.animation.timer = 0;
  19904. return;
  19905. }
  19906. _this3.disableScrollListener = true;
  19907. _this3.editor.scrollTo(null, currentTop - move);
  19908. } else {
  19909. _this3.animation.timer = 0;
  19910. return;
  19911. } // 无法再继续滚动
  19912. if (currentTop === _this3.editor.getScrollInfo().top || move >= Math.abs(delta)) {
  19913. _this3.animation.timer = 0;
  19914. return;
  19915. }
  19916. _this3.animation.timer = requestAnimationFrame(animationHandler);
  19917. };
  19918. this.animation.timer = requestAnimationFrame(animationHandler);
  19919. }
  19920. /**
  19921. *
  19922. * @param {number | null} lineNum
  19923. * @param {number} [endLine]
  19924. * @param {number} [percent]
  19925. */
  19926. }, {
  19927. key: "scrollToLineNum",
  19928. value: function scrollToLineNum(lineNum, endLine, percent) {
  19929. if (lineNum === null) {
  19930. this.jumpToLine(null);
  19931. return;
  19932. }
  19933. var $lineNum = Math.max(0, lineNum);
  19934. this.jumpToLine($lineNum, endLine, percent);
  19935. // Logger.log('滚动预览区域,左侧应scroll to ', $lineNum);
  19936. }
  19937. /**
  19938. *
  19939. * @returns {HTMLElement}
  19940. */
  19941. }, {
  19942. key: "getEditorDom",
  19943. value: function getEditorDom() {
  19944. return this.options.editorDom;
  19945. }
  19946. /**
  19947. *
  19948. * @param {string} event 事件名
  19949. * @param {EditorEventCallback} callback 回调函数
  19950. */
  19951. }, {
  19952. key: "addListener",
  19953. value: function addListener(event, callback) {
  19954. this.editor.on(event, callback);
  19955. }
  19956. /**
  19957. * 初始化书写风格
  19958. */
  19959. }, {
  19960. key: "initWritingStyle",
  19961. value: function initWritingStyle() {
  19962. var _context5, _context6;
  19963. var writingStyle = this.options.writingStyle;
  19964. var className = "cherry-editor-writing-style--".concat(writingStyle);
  19965. var editorDom = this.getEditorDom(); // 重置状态
  19966. forEach$3(_context5 = filter$3(_context6 = from_1$2(editorDom.classList)).call(_context6, function (className) {
  19967. return startsWith$3(className).call(className, 'cherry-editor-writing-style--');
  19968. })).call(_context5, function (className) {
  19969. return editorDom.classList.remove(className);
  19970. });
  19971. if (writingStyle === 'normal') {
  19972. return;
  19973. }
  19974. editorDom.classList.add(className);
  19975. this.refreshWritingStatus();
  19976. }
  19977. /**
  19978. * 刷新书写状态
  19979. */
  19980. }, {
  19981. key: "refreshWritingStatus",
  19982. value: function refreshWritingStatus() {
  19983. var _context7, _context8;
  19984. var writingStyle = this.options.writingStyle;
  19985. var className = "cherry-editor-writing-style--".concat(writingStyle);
  19986. /**
  19987. * @type {HTMLStyleElement}
  19988. */
  19989. var style = document.querySelector('#cherry-editor-writing-style') || document.createElement('style');
  19990. style.id = 'cherry-editor-writing-style';
  19991. find$3(_context7 = from_1$2(document.head.childNodes)).call(_context7, function (node) {
  19992. return node === style;
  19993. }) || document.head.appendChild(style);
  19994. var sheet = style.sheet;
  19995. forEach$3(_context8 = from_1$2(Array(sheet.cssRules.length))).call(_context8, function () {
  19996. return sheet.deleteRule(0);
  19997. });
  19998. if (writingStyle === 'focus') {
  19999. var _context9, _context10;
  20000. var editorDomRect = this.getEditorDom().getBoundingClientRect(); // 获取光标所在位置
  20001. var _this$editor$charCoor = this.editor.charCoords(this.editor.getCursor()),
  20002. top = _this$editor$charCoor.top,
  20003. bottom = _this$editor$charCoor.bottom; // 光标上部距离编辑器顶部距离(不包含菜单)
  20004. var topHeight = top - editorDomRect.top; // 光标下部距离编辑器底部距离
  20005. var bottomHeight = editorDomRect.height - (bottom - editorDomRect.top);
  20006. sheet.insertRule(concat$5(_context9 = ".".concat(className, "::before { height: ")).call(_context9, topHeight > 0 ? topHeight : 0, "px; }"), 0);
  20007. sheet.insertRule(concat$5(_context10 = ".".concat(className, "::after { height: ")).call(_context10, bottomHeight > 0 ? bottomHeight : 0, "px; }"), 0);
  20008. }
  20009. if (writingStyle === 'typewriter') {
  20010. var _context11, _context12;
  20011. // 编辑器顶/底部填充的空白高度 (用于内容不足时使光标所在行滚动到编辑器中央)
  20012. var height = this.editor.getScrollInfo().clientHeight / 2;
  20013. sheet.insertRule(concat$5(_context11 = ".".concat(className, " .CodeMirror-lines::before { height: ")).call(_context11, height, "px; }"), 0);
  20014. sheet.insertRule(concat$5(_context12 = ".".concat(className, " .CodeMirror-lines::after { height: ")).call(_context12, height, "px; }"), 0);
  20015. this.editor.scrollTo(null, this.editor.cursorCoords(null, 'local').top - height);
  20016. }
  20017. }
  20018. /**
  20019. * 修改书写风格
  20020. */
  20021. }, {
  20022. key: "setWritingStyle",
  20023. value: function setWritingStyle(writingStyle) {
  20024. this.options.writingStyle = writingStyle;
  20025. this.initWritingStyle();
  20026. }
  20027. }]);
  20028. return Editor;
  20029. }();
  20030. var $findIndex = arrayIteration.findIndex;
  20031. var FIND_INDEX = 'findIndex';
  20032. var SKIPS_HOLES$1 = true;
  20033. // Shouldn't skip holes
  20034. if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES$1 = false; });
  20035. // `Array.prototype.findIndex` method
  20036. // https://tc39.es/ecma262/#sec-array.prototype.findindex
  20037. _export({ target: 'Array', proto: true, forced: SKIPS_HOLES$1 }, {
  20038. findIndex: function findIndex(callbackfn /* , that = undefined */) {
  20039. return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  20040. }
  20041. });
  20042. var findIndex = entryVirtual('Array').findIndex;
  20043. var ArrayPrototype$7 = Array.prototype;
  20044. var findIndex$1 = function (it) {
  20045. var own = it.findIndex;
  20046. return it === ArrayPrototype$7 || (objectIsPrototypeOf(ArrayPrototype$7, it) && own === ArrayPrototype$7.findIndex) ? findIndex : own;
  20047. };
  20048. var findIndex$2 = findIndex$1;
  20049. var findIndex$3 = findIndex$2;
  20050. var HAS_SPECIES_SUPPORT$2 = arrayMethodHasSpeciesSupport('splice');
  20051. var TypeError$f = global_1.TypeError;
  20052. var max$3 = Math.max;
  20053. var min$3 = Math.min;
  20054. var MAX_SAFE_INTEGER$3 = 0x1FFFFFFFFFFFFF;
  20055. var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded';
  20056. // `Array.prototype.splice` method
  20057. // https://tc39.es/ecma262/#sec-array.prototype.splice
  20058. // with adding support of @@species
  20059. _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$2 }, {
  20060. splice: function splice(start, deleteCount /* , ...items */) {
  20061. var O = toObject(this);
  20062. var len = lengthOfArrayLike(O);
  20063. var actualStart = toAbsoluteIndex(start, len);
  20064. var argumentsLength = arguments.length;
  20065. var insertCount, actualDeleteCount, A, k, from, to;
  20066. if (argumentsLength === 0) {
  20067. insertCount = actualDeleteCount = 0;
  20068. } else if (argumentsLength === 1) {
  20069. insertCount = 0;
  20070. actualDeleteCount = len - actualStart;
  20071. } else {
  20072. insertCount = argumentsLength - 2;
  20073. actualDeleteCount = min$3(max$3(toIntegerOrInfinity(deleteCount), 0), len - actualStart);
  20074. }
  20075. if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER$3) {
  20076. throw TypeError$f(MAXIMUM_ALLOWED_LENGTH_EXCEEDED);
  20077. }
  20078. A = arraySpeciesCreate(O, actualDeleteCount);
  20079. for (k = 0; k < actualDeleteCount; k++) {
  20080. from = actualStart + k;
  20081. if (from in O) createProperty(A, k, O[from]);
  20082. }
  20083. A.length = actualDeleteCount;
  20084. if (insertCount < actualDeleteCount) {
  20085. for (k = actualStart; k < len - actualDeleteCount; k++) {
  20086. from = k + actualDeleteCount;
  20087. to = k + insertCount;
  20088. if (from in O) O[to] = O[from];
  20089. else delete O[to];
  20090. }
  20091. for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1];
  20092. } else if (insertCount > actualDeleteCount) {
  20093. for (k = len - actualDeleteCount; k > actualStart; k--) {
  20094. from = k + actualDeleteCount - 1;
  20095. to = k + insertCount - 1;
  20096. if (from in O) O[to] = O[from];
  20097. else delete O[to];
  20098. }
  20099. }
  20100. for (k = 0; k < insertCount; k++) {
  20101. O[k + actualStart] = arguments[k + 2];
  20102. }
  20103. O.length = len - actualDeleteCount + insertCount;
  20104. return A;
  20105. }
  20106. });
  20107. var splice$1 = entryVirtual('Array').splice;
  20108. var ArrayPrototype$8 = Array.prototype;
  20109. var splice$2 = function (it) {
  20110. var own = it.splice;
  20111. return it === ArrayPrototype$8 || (objectIsPrototypeOf(ArrayPrototype$8, it) && own === ArrayPrototype$8.splice) ? splice$1 : own;
  20112. };
  20113. var splice$3 = splice$2;
  20114. var splice$4 = splice$3;
  20115. /**
  20116. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  20117. *
  20118. * Licensed under the Apache License, Version 2.0 (the "License");
  20119. * you may not use this file except in compliance with the License.
  20120. * You may obtain a copy of the License at
  20121. *
  20122. * http://www.apache.org/licenses/LICENSE-2.0
  20123. *
  20124. * Unless required by applicable law or agreed to in writing, software
  20125. * distributed under the License is distributed on an "AS IS" BASIS,
  20126. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20127. * See the License for the specific language governing permissions and
  20128. * limitations under the License.
  20129. */
  20130. /**
  20131. * @typedef {import('~types/syntax').HookType} HookType
  20132. * @typedef {import('~types/syntax').HookTypesList} HookTypesList
  20133. * @typedef {import('~types/syntax').EditorConfig} EditorConfig
  20134. * @typedef {import('~types/syntax').HookRegexpRule} HookRegexpRule
  20135. */
  20136. /** @type {boolean} */
  20137. var isMathjaxConfig = false;
  20138. /**
  20139. * @type {HookTypesList}
  20140. */
  20141. var HOOKS_TYPE_LIST = {
  20142. SEN: 'sentence',
  20143. PAR: 'paragraph',
  20144. DEFAULT: 'sentence'
  20145. };
  20146. var SyntaxBase = /*#__PURE__*/function () {
  20147. /**
  20148. * @static
  20149. * @type {string}
  20150. */
  20151. /**
  20152. * @static
  20153. * @type {HookType}
  20154. */
  20155. /**
  20156. * @protected
  20157. * @type {import('../Engine').default}
  20158. */
  20159. /**
  20160. * @constructor
  20161. * @param {Partial<EditorConfig>} editorConfig
  20162. */
  20163. function SyntaxBase(editorConfig) {
  20164. _classCallCheck(this, SyntaxBase);
  20165. _defineProperty(this, "$engine", void 0);
  20166. _defineProperty(this, "$locale", void 0);
  20167. // editorConfig.pageHooks: 已实例化的页面级hook
  20168. // editorConfig.syntaxOptions: 当前Hook的用户配置
  20169. // editorConfig.externals: 第三方库
  20170. this.RULE = this.rule(editorConfig);
  20171. }
  20172. _createClass(SyntaxBase, [{
  20173. key: "getType",
  20174. value: function getType() {
  20175. return (
  20176. /** @type {typeof SyntaxBase} */
  20177. this.constructor.HOOK_TYPE || HOOKS_TYPE_LIST.DEFAULT
  20178. );
  20179. }
  20180. }, {
  20181. key: "getName",
  20182. value: function getName() {
  20183. return (
  20184. /** @type {typeof SyntaxBase} */
  20185. this.constructor.HOOK_NAME
  20186. );
  20187. }
  20188. }, {
  20189. key: "afterInit",
  20190. value: function afterInit(callback) {
  20191. if (typeof callback === 'function') {
  20192. callback();
  20193. }
  20194. }
  20195. }, {
  20196. key: "setLocale",
  20197. value: function setLocale(locale) {
  20198. this.$locale = locale;
  20199. }
  20200. /**
  20201. * 生命周期函数
  20202. * @param {string} str 待处理的markdown文本
  20203. * @returns {string} 处理后的文本,一般为html
  20204. */
  20205. }, {
  20206. key: "beforeMakeHtml",
  20207. value: function beforeMakeHtml(str) {
  20208. return str;
  20209. }
  20210. /**
  20211. * 生命周期函数
  20212. * @param {string} str 待处理的markdown文本
  20213. * @returns {string} 处理后的文本,一般为html
  20214. */
  20215. }, {
  20216. key: "makeHtml",
  20217. value: function makeHtml(str) {
  20218. return str;
  20219. }
  20220. /**
  20221. * 生命周期函数
  20222. * @param {string} str 待处理的markdown文本
  20223. * @returns {string} 处理后的文本,一般为html
  20224. */
  20225. }, {
  20226. key: "afterMakeHtml",
  20227. value: function afterMakeHtml(str) {
  20228. return str;
  20229. } // getMakeHtml() {
  20230. // return this.makeHtml || false;
  20231. // }
  20232. /**
  20233. *
  20234. * @param {KeyboardEvent} e 触发事件
  20235. * @param {*} str
  20236. */
  20237. }, {
  20238. key: "onKeyDown",
  20239. value: function onKeyDown(e, str) {}
  20240. }, {
  20241. key: "getOnKeyDown",
  20242. value: function getOnKeyDown() {
  20243. return this.onKeyDown || false;
  20244. }
  20245. }, {
  20246. key: "getAttributesTest",
  20247. value: function getAttributesTest() {
  20248. return /^(color|fontSize|font-size|id|title|class|target|underline|line-through|overline|sub|super)$/;
  20249. }
  20250. /**
  20251. *
  20252. * @param {string} attr
  20253. * @param {() => {}} func 回调函数
  20254. */
  20255. }, {
  20256. key: "$testAttributes",
  20257. value: function $testAttributes(attr, func) {
  20258. if (this.getAttributesTest().test(attr)) {
  20259. func();
  20260. }
  20261. }
  20262. /**
  20263. * 提取属性
  20264. * @param {string} str 待提取字符串
  20265. * @returns {{attrs: Record<string,any>; str: string}}
  20266. */
  20267. }, {
  20268. key: "getAttributes",
  20269. value: function getAttributes(str) {
  20270. var ret = {
  20271. attrs: {},
  20272. str: str
  20273. }; // if(/(?<=[^\\]){([a-zA-Z-]+=[0-9a-z-]+(?=;|\||}))+}$/.test(str)) {
  20274. // str.match(/(?<=[^\\]){[^\n]+?}$/)[0]
  20275. // .match(/([a-zA-Z-]+=[0-9a-z-]+(?=;|\||}))+/g)
  20276. // .foreach((one) => {
  20277. // one = one.split('=');
  20278. // this._testAttributes(one[0], ()=>{
  20279. // ret.attrs[one[0]] = one[1];
  20280. // });
  20281. // });
  20282. // ret.str = str.replace(/(?<=[^\\]){[^\n]+?}$/, '');
  20283. // }
  20284. return ret;
  20285. }
  20286. }, {
  20287. key: "test",
  20288. value:
  20289. /**
  20290. * 测试输入的字符串是否匹配当前Hook规则
  20291. * @param {string} str 待匹配文本
  20292. * @returns {boolean}
  20293. */
  20294. function test(str) {
  20295. return this.RULE.reg ? this.RULE.reg.test(str) : false;
  20296. }
  20297. /**
  20298. *
  20299. * @param {Partial<EditorConfig>} editorConfig
  20300. * @returns {HookRegexpRule}
  20301. */
  20302. }, {
  20303. key: "rule",
  20304. value: function rule(editorConfig) {
  20305. return {
  20306. begin: '',
  20307. end: '',
  20308. content: '',
  20309. reg: new RegExp('')
  20310. };
  20311. }
  20312. }, {
  20313. key: "mounted",
  20314. value: function mounted() {// console.log('base mounted');
  20315. }
  20316. }], [{
  20317. key: "getMathJaxConfig",
  20318. value: function getMathJaxConfig() {
  20319. return isMathjaxConfig;
  20320. }
  20321. /**
  20322. *
  20323. * @param {boolean} version 指定mathJax是否使用MathJax
  20324. */
  20325. }, {
  20326. key: "setMathJaxConfig",
  20327. value: function setMathJaxConfig(version) {
  20328. isMathjaxConfig = version;
  20329. }
  20330. }]);
  20331. return SyntaxBase;
  20332. }();
  20333. _defineProperty(SyntaxBase, "HOOK_NAME", 'default');
  20334. _defineProperty(SyntaxBase, "HOOK_TYPE", HOOKS_TYPE_LIST.DEFAULT);
  20335. var $map = arrayIteration.map;
  20336. var HAS_SPECIES_SUPPORT$3 = arrayMethodHasSpeciesSupport('map');
  20337. // `Array.prototype.map` method
  20338. // https://tc39.es/ecma262/#sec-array.prototype.map
  20339. // with adding support of @@species
  20340. _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$3 }, {
  20341. map: function map(callbackfn /* , thisArg */) {
  20342. return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  20343. }
  20344. });
  20345. var map = entryVirtual('Array').map;
  20346. var ArrayPrototype$9 = Array.prototype;
  20347. var map$1 = function (it) {
  20348. var own = it.map;
  20349. return it === ArrayPrototype$9 || (objectIsPrototypeOf(ArrayPrototype$9, it) && own === ArrayPrototype$9.map) ? map : own;
  20350. };
  20351. var map$2 = map$1;
  20352. var map$3 = map$2;
  20353. /**
  20354. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  20355. *
  20356. * Licensed under the Apache License, Version 2.0 (the "License");
  20357. * you may not use this file except in compliance with the License.
  20358. * You may obtain a copy of the License at
  20359. *
  20360. * http://www.apache.org/licenses/LICENSE-2.0
  20361. *
  20362. * Unless required by applicable law or agreed to in writing, software
  20363. * distributed under the License is distributed on an "AS IS" BASIS,
  20364. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20365. * See the License for the specific language governing permissions and
  20366. * limitations under the License.
  20367. */
  20368. /**
  20369. * 为段落前加换行符
  20370. * @param {string} match 匹配全文
  20371. * @param {string} processedContent 加入的内容
  20372. */
  20373. function prependLineFeedForParagraph(match, processedContent) {
  20374. var canNestedInList = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  20375. if (!/^\n/.test(match)) {
  20376. return processedContent;
  20377. }
  20378. if (canNestedInList) {
  20379. var _match$match$0$length, _match$match, _match$match$;
  20380. var leadingLinesCount = (_match$match$0$length = (_match$match = match.match(/^\n+/g)) === null || _match$match === void 0 ? void 0 : (_match$match$ = _match$match[0]) === null || _match$match$ === void 0 ? void 0 : _match$match$.length) !== null && _match$match$0$length !== void 0 ? _match$match$0$length : 0; // 前置换行符数量大于2时,补充两个换行符,否则只补充一个
  20381. if (leadingLinesCount > 1) {
  20382. return "\n\n".concat(processedContent);
  20383. }
  20384. return "\n".concat(processedContent);
  20385. }
  20386. return "\n\n".concat(processedContent);
  20387. }
  20388. /**
  20389. * 计算段落所占行数,必须传入通过 prependLineFeedForParagraph 方法处理后的内容,才能计算准确
  20390. * @param {string} preLinesMatch 前置匹配行
  20391. * @param {number} contentLines 实际内容行数
  20392. */
  20393. function calculateLinesOfParagraph(preLinesMatch, contentLines) {
  20394. var preLineCount = (preLinesMatch.match(/\n/g) || []).length; // 前置行匹配文本为空,说明是全文开头
  20395. // 非全文开头前面必有两个从 prependLineFeed 方法新增加的换行符
  20396. if (preLinesMatch !== '') {
  20397. preLineCount -= 2;
  20398. }
  20399. return preLineCount + contentLines;
  20400. }
  20401. var isArray$8 = isArray$3;
  20402. /**
  20403. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  20404. *
  20405. * Licensed under the Apache License, Version 2.0 (the "License");
  20406. * you may not use this file except in compliance with the License.
  20407. * You may obtain a copy of the License at
  20408. *
  20409. * http://www.apache.org/licenses/LICENSE-2.0
  20410. *
  20411. * Unless required by applicable law or agreed to in writing, software
  20412. * distributed under the License is distributed on an "AS IS" BASIS,
  20413. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20414. * See the License for the specific language governing permissions and
  20415. * limitations under the License.
  20416. */
  20417. /**
  20418. * 用于lodash.mergeWith的customizer
  20419. * @param {any} objValue
  20420. * @param {any} srcValue
  20421. * @returns
  20422. */
  20423. function customizer(objValue, srcValue) {
  20424. if (isArray$8(srcValue)) {
  20425. return srcValue;
  20426. }
  20427. }
  20428. /**
  20429. * 检查本地有没有值
  20430. * @param {string} key
  20431. */
  20432. function testKeyInLocal(key) {
  20433. if (typeof localStorage !== 'undefined') {
  20434. return localStorage.getItem("cherry-".concat(key)) !== null;
  20435. }
  20436. return false;
  20437. }
  20438. /**
  20439. * 保存是否经典换行
  20440. * @param {boolean} isClassicBr
  20441. */
  20442. function saveIsClassicBrToLocal(isClassicBr) {
  20443. if (typeof localStorage !== 'undefined') {
  20444. localStorage.setItem('cherry-classicBr', isClassicBr ? 'true' : 'false');
  20445. }
  20446. }
  20447. /**
  20448. * 是否经典换行
  20449. */
  20450. function getIsClassicBrFromLocal() {
  20451. var ret = 'false';
  20452. if (typeof localStorage !== 'undefined') {
  20453. ret = localStorage.getItem('cherry-classicBr');
  20454. }
  20455. return ret === 'true';
  20456. }
  20457. /**
  20458. * 保存当前主题
  20459. * @param {string} theme
  20460. */
  20461. function saveThemeToLocal(theme) {
  20462. if (typeof localStorage !== 'undefined') {
  20463. localStorage.setItem('cherry-theme', theme);
  20464. }
  20465. }
  20466. /**
  20467. * 获取当前主题
  20468. * @returns {string} 主题名
  20469. */
  20470. function getThemeFromLocal() {
  20471. var fullClass = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  20472. var ret = 'default';
  20473. if (typeof localStorage !== 'undefined') {
  20474. var localTheme = localStorage.getItem('cherry-theme');
  20475. if (localTheme) {
  20476. ret = localTheme;
  20477. }
  20478. }
  20479. return fullClass ? "theme__".concat(ret) : ret;
  20480. }
  20481. /**
  20482. * 修改主题
  20483. * @param {object} $cherry
  20484. * @param {string} theme 如果没有传theme,则从本地缓存里取
  20485. */
  20486. function changeTheme($cherry) {
  20487. var theme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  20488. var newTheme = (theme ? theme : getThemeFromLocal()).replace(/^.*theme__/, '');
  20489. var newClass = " theme__".concat(newTheme);
  20490. $cherry.wrapperDom.className = $cherry.wrapperDom.className.replace(/ theme__[^ $]+?( |$)/g, '') + newClass;
  20491. $cherry.previewer.getDomContainer().className = $cherry.previewer.getDomContainer().className.replace(/ theme__[^ $]+?( |$)/g, '') + newClass;
  20492. saveThemeToLocal(newTheme);
  20493. }
  20494. var RangeError$1 = global_1.RangeError;
  20495. var fromCharCode = String.fromCharCode;
  20496. // eslint-disable-next-line es-x/no-string-fromcodepoint -- required for testing
  20497. var $fromCodePoint = String.fromCodePoint;
  20498. var join$1 = functionUncurryThis([].join);
  20499. // length should be 1, old FF problem
  20500. var INCORRECT_LENGTH = !!$fromCodePoint && $fromCodePoint.length != 1;
  20501. // `String.fromCodePoint` method
  20502. // https://tc39.es/ecma262/#sec-string.fromcodepoint
  20503. _export({ target: 'String', stat: true, arity: 1, forced: INCORRECT_LENGTH }, {
  20504. // eslint-disable-next-line no-unused-vars -- required for `.length`
  20505. fromCodePoint: function fromCodePoint(x) {
  20506. var elements = [];
  20507. var length = arguments.length;
  20508. var i = 0;
  20509. var code;
  20510. while (length > i) {
  20511. code = +arguments[i++];
  20512. if (toAbsoluteIndex(code, 0x10FFFF) !== code) throw RangeError$1(code + ' is not a valid code point');
  20513. elements[i] = code < 0x10000
  20514. ? fromCharCode(code)
  20515. : fromCharCode(((code -= 0x10000) >> 10) + 0xD800, code % 0x400 + 0xDC00);
  20516. } return join$1(elements, '');
  20517. }
  20518. });
  20519. var fromCodePoint = path.String.fromCodePoint;
  20520. var fromCodePoint$1 = fromCodePoint;
  20521. var fromCodePoint$2 = fromCodePoint$1;
  20522. var _context, _context2;
  20523. function ownKeys$1(object, enumerableOnly) { var keys = keys$3(object); if (getOwnPropertySymbols$2) { var symbols = getOwnPropertySymbols$2(object); enumerableOnly && (symbols = filter$3(symbols).call(symbols, function (sym) { return getOwnPropertyDescriptor$3(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  20524. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? forEach$3(_context3 = ownKeys$1(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : getOwnPropertyDescriptors$2 ? defineProperties$2(target, getOwnPropertyDescriptors$2(source)) : forEach$3(_context4 = ownKeys$1(Object(source))).call(_context4, function (key) { defineProperty$5(target, key, getOwnPropertyDescriptor$3(source, key)); }); } return target; }
  20525. /**
  20526. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  20527. *
  20528. * Licensed under the Apache License, Version 2.0 (the "License");
  20529. * you may not use this file except in compliance with the License.
  20530. * You may obtain a copy of the License at
  20531. *
  20532. * http://www.apache.org/licenses/LICENSE-2.0
  20533. *
  20534. * Unless required by applicable law or agreed to in writing, software
  20535. * distributed under the License is distributed on an "AS IS" BASIS,
  20536. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20537. * See the License for the specific language governing permissions and
  20538. * limitations under the License.
  20539. */
  20540. var escapeMap = {
  20541. '<': '&lt;',
  20542. '>': '&gt;',
  20543. '&': '&amp;',
  20544. '"': '&quot;',
  20545. "'": '&#x27;'
  20546. };
  20547. var unescapeMap = {
  20548. lt: '<',
  20549. gt: '>',
  20550. amp: '&',
  20551. quot: '"',
  20552. apos: "'"
  20553. }; // refs: https://www.freeformatter.com/html-entities.html
  20554. var ASCIICharacters = {
  20555. 34: '&quot;',
  20556. 38: '&amp;',
  20557. 39: '&apos;',
  20558. 60: '&lt;',
  20559. 62: '&gt;'
  20560. };
  20561. var ISO88591Characters = {
  20562. 192: '&Agrave;',
  20563. 193: '&Aacute;',
  20564. 194: '&Acirc;',
  20565. 195: '&Atilde;',
  20566. 196: '&Auml;',
  20567. 197: '&Aring;',
  20568. 198: '&AElig;',
  20569. 199: '&Ccedil;',
  20570. 200: '&Egrave;',
  20571. 201: '&Eacute;',
  20572. 202: '&Ecirc;',
  20573. 203: '&Euml;',
  20574. 204: '&Igrave;',
  20575. 205: '&Iacute;',
  20576. 206: '&Icirc;',
  20577. 207: '&Iuml;',
  20578. 208: '&ETH;',
  20579. 209: '&Ntilde;',
  20580. 210: '&Ograve;',
  20581. 211: '&Oacute;',
  20582. 212: '&Ocirc;',
  20583. 213: '&Otilde;',
  20584. 214: '&Ouml;',
  20585. 216: '&Oslash;',
  20586. 217: '&Ugrave;',
  20587. 218: '&Uacute;',
  20588. 219: '&Ucirc;',
  20589. 220: '&Uuml;',
  20590. 221: '&Yacute;',
  20591. 222: '&THORN;',
  20592. 223: '&szlig;',
  20593. 224: '&agrave;',
  20594. 225: '&aacute;',
  20595. 226: '&acirc;',
  20596. 227: '&atilde;',
  20597. 228: '&auml;',
  20598. 229: '&aring;',
  20599. 230: '&aelig;',
  20600. 231: '&ccedil;',
  20601. 232: '&egrave;',
  20602. 233: '&eacute;',
  20603. 234: '&ecirc;',
  20604. 235: '&euml;',
  20605. 236: '&igrave;',
  20606. 237: '&iacute;',
  20607. 238: '&icirc;',
  20608. 239: '&iuml;',
  20609. 240: '&eth;',
  20610. 241: '&ntilde;',
  20611. 242: '&ograve;',
  20612. 243: '&oacute;',
  20613. 244: '&ocirc;',
  20614. 245: '&otilde;',
  20615. 246: '&ouml;',
  20616. 248: '&oslash;',
  20617. 249: '&ugrave;',
  20618. 250: '&uacute;',
  20619. 251: '&ucirc;',
  20620. 252: '&uuml;',
  20621. 253: '&yacute;',
  20622. 254: '&thorn;',
  20623. 255: '&yuml;'
  20624. };
  20625. var ISO88591Symbols = {
  20626. 160: '&nbsp;',
  20627. 161: '&iexcl;',
  20628. 162: '&cent;',
  20629. 163: '&pound;',
  20630. 164: '&curren;',
  20631. 165: '&yen;',
  20632. 166: '&brvbar;',
  20633. 167: '&sect;',
  20634. 168: '&uml;',
  20635. 169: '&copy;',
  20636. 170: '&ordf;',
  20637. 171: '&laquo;',
  20638. 172: '&not;',
  20639. 173: '&shy;',
  20640. 174: '&reg;',
  20641. 175: '&macr;',
  20642. 176: '&deg;',
  20643. 177: '&plusmn;',
  20644. 178: '&sup2;',
  20645. 179: '&sup3;',
  20646. 180: '&acute;',
  20647. 181: '&micro;',
  20648. 182: '&para;',
  20649. 184: '&cedil;',
  20650. 185: '&sup1;',
  20651. 186: '&ordm;',
  20652. 187: '&raquo;',
  20653. 188: '&frac14;',
  20654. 189: '&frac12;',
  20655. 190: '&frac34;',
  20656. 191: '&iquest;',
  20657. 215: '&times;',
  20658. 247: '&divide;'
  20659. };
  20660. var MathSymbols = {
  20661. 8704: '&forall;',
  20662. 8706: '&part;',
  20663. 8707: '&exist;',
  20664. 8709: '&empty;',
  20665. 8711: '&nabla;',
  20666. 8712: '&isin;',
  20667. 8713: '&notin;',
  20668. 8715: '&ni;',
  20669. 8719: '&prod;',
  20670. 8721: '&sum;',
  20671. 8722: '&minus;',
  20672. 8727: '&lowast;',
  20673. 8730: '&radic;',
  20674. 8733: '&prop;',
  20675. 8734: '&infin;',
  20676. 8736: '&ang;',
  20677. 8743: '&and;',
  20678. 8744: '&or;',
  20679. 8745: '&cap;',
  20680. 8746: '&cup;',
  20681. 8747: '&int;',
  20682. 8756: '&there4;',
  20683. 8764: '&sim;',
  20684. 8773: '&cong;',
  20685. 8776: '&asymp;',
  20686. 8800: '&ne;',
  20687. 8801: '&equiv;',
  20688. 8804: '&le;',
  20689. 8805: '&ge;',
  20690. 8834: '&sub;',
  20691. 8835: '&sup;',
  20692. 8836: '&nsub;',
  20693. 8838: '&sube;',
  20694. 8839: '&supe;',
  20695. 8853: '&oplus;',
  20696. 8855: '&otimes;',
  20697. 8869: '&perp;',
  20698. 8901: '&sdot;'
  20699. };
  20700. var GreekLetters = {
  20701. 913: '&Alpha;',
  20702. 914: '&Beta;',
  20703. 915: '&Gamma;',
  20704. 916: '&Delta;',
  20705. 917: '&Epsilon;',
  20706. 918: '&Zeta;',
  20707. 919: '&Eta;',
  20708. 920: '&Theta;',
  20709. 921: '&Iota;',
  20710. 922: '&Kappa;',
  20711. 923: '&Lambda;',
  20712. 924: '&Mu;',
  20713. 925: '&Nu;',
  20714. 926: '&Xi;',
  20715. 927: '&Omicron;',
  20716. 928: '&Pi;',
  20717. 929: '&Rho;',
  20718. 931: '&Sigma;',
  20719. 932: '&Tau;',
  20720. 933: '&Upsilon;',
  20721. 934: '&Phi;',
  20722. 935: '&Chi;',
  20723. 936: '&Psi;',
  20724. 937: '&Omega;',
  20725. 945: '&alpha;',
  20726. 946: '&beta;',
  20727. 947: '&gamma;',
  20728. 948: '&delta;',
  20729. 949: '&epsilon;',
  20730. 950: '&zeta;',
  20731. 951: '&eta;',
  20732. 952: '&theta;',
  20733. 953: '&iota;',
  20734. 954: '&kappa;',
  20735. 955: '&lambda;',
  20736. 956: '&mu;',
  20737. 957: '&nu;',
  20738. 958: '&xi;',
  20739. 959: '&omicron;',
  20740. 960: '&pi;',
  20741. 961: '&rho;',
  20742. 962: '&sigmaf;',
  20743. 963: '&sigma;',
  20744. 964: '&tau;',
  20745. 965: '&upsilon;',
  20746. 966: '&phi;',
  20747. 967: '&chi;',
  20748. 968: '&psi;',
  20749. 969: '&omega;',
  20750. 977: '&thetasym;',
  20751. 978: '&upsih;',
  20752. 982: '&piv;'
  20753. };
  20754. var MiscellaneousHTMLEntities = {
  20755. 338: '&OElig;',
  20756. 339: '&oelig;',
  20757. 352: '&Scaron;',
  20758. 353: '&scaron;',
  20759. 376: '&Yuml;',
  20760. 402: '&fnof;',
  20761. 710: '&circ;',
  20762. 732: '&tilde;',
  20763. 8194: '&ensp;',
  20764. 8195: '&emsp;',
  20765. 8201: '&thinsp;',
  20766. 8204: '&zwnj;',
  20767. 8205: '&zwj;',
  20768. 8206: '&lrm;',
  20769. 8207: '&rlm;',
  20770. 8211: '&ndash;',
  20771. 8212: '&mdash;',
  20772. 8216: '&lsquo;',
  20773. 8217: '&rsquo;',
  20774. 8218: '&sbquo;',
  20775. 8220: '&ldquo;',
  20776. 8221: '&rdquo;',
  20777. 8222: '&bdquo;',
  20778. 8224: '&dagger;',
  20779. 8225: '&Dagger;',
  20780. 8226: '&bull;',
  20781. 8230: '&hellip;',
  20782. 8240: '&permil;',
  20783. 8242: '&prime;',
  20784. 8243: '&Prime;',
  20785. 8249: '&lsaquo;',
  20786. 8250: '&rsaquo;',
  20787. 8254: '&oline;',
  20788. 8364: '&euro;',
  20789. 8482: '&trade;',
  20790. 8592: '&larr;',
  20791. 8593: '&uarr;',
  20792. 8594: '&rarr;',
  20793. 8595: '&darr;',
  20794. 8596: '&harr;',
  20795. 8629: '&crarr;',
  20796. 8968: '&lceil;',
  20797. 8969: '&rceil;',
  20798. 8970: '&lfloor;',
  20799. 8971: '&rfloor;',
  20800. 9674: '&loz;',
  20801. 9824: '&spades;',
  20802. 9827: '&clubs;',
  20803. 9829: '&hearts;',
  20804. 9830: '&diams;'
  20805. }; // TODO: 使用whatwg的entities.json
  20806. var htmlEntitiesMap = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, ASCIICharacters), ISO88591Characters), ISO88591Symbols), MathSymbols), GreekLetters), MiscellaneousHTMLEntities);
  20807. var htmlEntitiesCodePoint = keys$3(htmlEntitiesMap);
  20808. var htmlEntitiesWithoutSemicolon = map$3(htmlEntitiesCodePoint).call(htmlEntitiesCodePoint, function (code) {
  20809. return htmlEntitiesMap[code].replace(/^&(\w+);$/g, function (match, name) {
  20810. return name.toLowerCase();
  20811. });
  20812. });
  20813. /**
  20814. * 非字符串类型与长度为0的字符串都认为是空串
  20815. * @param {any} str 需要判断的字符串
  20816. * @returns {boolean}
  20817. */
  20818. var isEmptyString = function isEmptyString(str) {
  20819. return typeof str !== 'string' || str.length <= 0;
  20820. };
  20821. var isValidStringCodePoint = function isValidStringCodePoint(codePoint) {
  20822. try {
  20823. var string = fromCodePoint$2(codePoint);
  20824. return !isEmptyString(string); // 如果转换的为空串,说明CodePoint不合法
  20825. } catch (e) {
  20826. // 转换出错,也是不合法的CodePoint
  20827. return false;
  20828. }
  20829. };
  20830. function escapeHTMLEntitiesWithoutSemicolon(content) {
  20831. if (typeof content !== 'string') {
  20832. return '';
  20833. } // 先处理字符实体
  20834. var namedRegex = /&(\w+);?/g;
  20835. var escaped = content.replace(namedRegex, function (match, name) {
  20836. // 不在合法列表里的全部转义,无分号的情况也转义
  20837. if (indexOf$8(match).call(match, ';') === -1 || indexOf$8(htmlEntitiesWithoutSemicolon).call(htmlEntitiesWithoutSemicolon, name.toLowerCase()) === -1) {
  20838. return match.replace(/&/g, '&amp;');
  20839. }
  20840. return match;
  20841. }); // 处理十进制数字实体,需要防止误匹配16进制
  20842. var numericRegex = /&#(?!x)(\d*);?/gi;
  20843. escaped = escaped.replace(numericRegex, function (match, decimalCodePoint) {
  20844. // 不在合法列表里的全部转义,无分号的情况也转义
  20845. // 且位数不能大于7,否则可能导致溢出: https://spec.commonmark.org/0.29/#decimal-numeric-character
  20846. if (isEmptyString(decimalCodePoint) || indexOf$8(match).call(match, ';') === -1 || decimalCodePoint.lenth > 7 || // Object.keys(htmlEntitiesMap).indexOf(+decimalCodePoint) === -1 ||
  20847. !isValidStringCodePoint(decimalCodePoint)) {
  20848. return match.replace(/&/g, '&amp;');
  20849. }
  20850. return match;
  20851. }); // 处理十六进制数字实体
  20852. var hexRegex = /&#x([0-9a-f]*);?/gi;
  20853. escaped = escaped.replace(hexRegex, function (match, hexCodePoint) {
  20854. if (isEmptyString(hexCodePoint)) {
  20855. return match.replace(/&/g, '&amp;');
  20856. }
  20857. var hexCode = "0x".concat(hexCodePoint);
  20858. var decimalCodePoint = _parseInt$2(hexCode, 16); // parseInt非数字、不在合法列表里、无分号的情况全部转义
  20859. // 且位数不能大于6: https://spec.commonmark.org/0.29/#hexadecimal-numeric-character
  20860. if (isNaN(decimalCodePoint) || indexOf$8(match).call(match, ';') === -1 || hexCodePoint.lenth > 6 || // Object.keys(htmlEntitiesMap).indexOf(decimalCodePoint) === -1
  20861. !isValidStringCodePoint(hexCode)) {
  20862. return match.replace(/&/g, '&amp;');
  20863. }
  20864. return match;
  20865. });
  20866. return escaped;
  20867. }
  20868. var blockNames = ['h1|h2|h3|h4|h5|h6', 'ul|ol|li|dd|dl|dt', 'table|thead|tbody|tfoot|col|colgroup|th|td|tr', 'div|article|section|footer|aside|details|summary|code|audio|video|canvas|figure', 'address|center|cite|p|pre|blockquote|marquee|caption|figcaption|track|source|output|svg'].join('|');
  20869. var inlineNames = ['span|a|link|b|s|i|del|u|em|strong|sup|sub|kbd', 'nav|font|bdi|samp|map|area|small|time|bdo|var|wbr|meter|dfn', 'ruby|rt|rp|mark|q|progress|input|textarea|select|ins'].join('|');
  20870. var inlineBlock = 'br|img|hr';
  20871. var whiteList = new RegExp(concat$5(_context = concat$5(_context2 = "^(".concat(blockNames, "|")).call(_context2, inlineNames, "|")).call(_context, inlineBlock, ")( |$|/)"), 'i');
  20872. function escapeHTMLSpecialChar(content, enableQuote) {
  20873. if (typeof content !== 'string') {
  20874. return '';
  20875. }
  20876. if (enableQuote) {
  20877. return content.replace(/[<>&]/g, function (_char) {
  20878. return escapeMap[_char] || _char;
  20879. });
  20880. }
  20881. return content.replace(/[<>&"']/g, function (_char2) {
  20882. return escapeMap[_char2] || _char2;
  20883. });
  20884. }
  20885. function unescapeHTMLSpecialChar(content) {
  20886. if (typeof content !== 'string') {
  20887. return '';
  20888. }
  20889. return content.replace(/&(\w+);?/g, function (escaped, name) {
  20890. return unescapeMap[name] || escaped;
  20891. });
  20892. }
  20893. function escapeHTMLSpecialCharOnce(content, enableQuote) {
  20894. if (typeof content !== 'string') {
  20895. return '';
  20896. }
  20897. var str = convertHTMLNumberToName(content);
  20898. str = unescapeHTMLSpecialChar(str);
  20899. return escapeHTMLSpecialChar(str, enableQuote);
  20900. }
  20901. function convertHTMLNumberToName(html) {
  20902. var entities = /&#(\d+);?/g;
  20903. return html.replace(entities, function (match, codePoint) {
  20904. return htmlEntitiesMap[codePoint] || match;
  20905. });
  20906. }
  20907. function unescapeHTMLNumberEntities(html) {
  20908. var entities = /&#(\d+);?/g;
  20909. return html.replace(entities, function (match, codePoint) {
  20910. try {
  20911. var escaped = fromCodePoint$2(codePoint);
  20912. return escaped;
  20913. } catch (e) {
  20914. return match;
  20915. }
  20916. });
  20917. }
  20918. function unescapeHTMLHexEntities(html) {
  20919. var entities = /&#x([0-9a-f]+);?/gi;
  20920. return html.replace(entities, function (match, codePoint) {
  20921. var hexCode = _parseInt$2("0x".concat(codePoint), 16);
  20922. try {
  20923. var escaped = fromCodePoint$2(hexCode);
  20924. return escaped;
  20925. } catch (e) {
  20926. return match;
  20927. }
  20928. });
  20929. }
  20930. function isValidScheme(url) {
  20931. var regex = /^\s*([\w\W]+?)(?=:)/i;
  20932. var match = unescapeHTMLHexEntities(unescapeHTMLNumberEntities(url)).match(regex);
  20933. if (!match) {
  20934. return true;
  20935. }
  20936. var SCHEME_BLACKLIST = ['javascript', 'data'];
  20937. var scheme = match[1].replace(/[\s]/g, ''); // 协议中间可能会出现空白字符绕过检查
  20938. if (indexOf$8(SCHEME_BLACKLIST).call(SCHEME_BLACKLIST, scheme.toLowerCase()) !== -1) {
  20939. return false;
  20940. }
  20941. return true;
  20942. }
  20943. /**
  20944. * ref: https://stackoverflow.com/questions/9245333/should-encodeuri-ever-be-used
  20945. * @param {string} str
  20946. */
  20947. function encodeURIOnce(str) {
  20948. return encodeURI(str).replace(/[!'()*]/g, function (_char4) {
  20949. return "%".concat(_char4.charCodeAt(0).toString(16));
  20950. }).replace(/%25/g, '%');
  20951. }
  20952. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  20953. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  20954. var cacheCounter = 0; // ~~C${cacheCounter}I${cacheIndex}$
  20955. // let cacheMap = {};
  20956. var ParagraphBase = /*#__PURE__*/function (_SyntaxBase) {
  20957. _inherits(ParagraphBase, _SyntaxBase);
  20958. var _super = _createSuper(ParagraphBase);
  20959. // 不需要排他的sign前缀,如~~C0I${IN_PARAGRAPH_CACHE_KEY_PREFIX}sign$
  20960. function ParagraphBase() {
  20961. var _this;
  20962. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  20963. needCache: false
  20964. },
  20965. needCache = _ref.needCache,
  20966. _ref$defaultCache = _ref.defaultCache,
  20967. defaultCache = _ref$defaultCache === void 0 ? {} : _ref$defaultCache;
  20968. _classCallCheck(this, ParagraphBase);
  20969. _this = _super.call(this, {});
  20970. _this.needCache = !!needCache;
  20971. _this.sign = '';
  20972. if (needCache) {
  20973. _this.cache = defaultCache || {};
  20974. _this.cacheKey = "~~C".concat(cacheCounter);
  20975. cacheCounter += 1;
  20976. }
  20977. return _this;
  20978. }
  20979. _createClass(ParagraphBase, [{
  20980. key: "initBrReg",
  20981. value: function initBrReg() {
  20982. var classicBr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  20983. // 是否启用经典换行逻辑
  20984. // true:一个换行会被忽略,两个以上连续换行会分割成段落,
  20985. // false: 一个换行会转成<br>,两个连续换行会分割成段落,三个以上连续换行会转成<br>并分割段落
  20986. this.classicBr = testKeyInLocal('classicBr') ? getIsClassicBrFromLocal() : classicBr;
  20987. this.removeBrAfterBlock = null;
  20988. this.removeBrBeforeBlock = null;
  20989. this.removeNewlinesBetweenTags = null;
  20990. }
  20991. /**
  20992. * 处理经典换行问题
  20993. * @param {string} str markdown源码
  20994. * @returns markdown源码
  20995. */
  20996. }, {
  20997. key: "$cleanParagraph",
  20998. value: function $cleanParagraph(str) {
  20999. // remove leading and trailing newlines
  21000. var trimedPar = str.replace(/^\n+/, '').replace(/\n+$/, '');
  21001. if (this.classicBr) {
  21002. return trimedPar;
  21003. }
  21004. var minifiedPar = this.joinRawHtml(trimedPar);
  21005. return minifiedPar.replace(/\n/g, '<br>').replace(/\r/g, '\n'); // recover \n from \r
  21006. }
  21007. /**
  21008. * remove all newlines in html text
  21009. *
  21010. * @param {string} textContainsHtml
  21011. */
  21012. }, {
  21013. key: "joinRawHtml",
  21014. value: function joinRawHtml(textContainsHtml) {
  21015. if (!this.removeBrAfterBlock) {
  21016. var _this$$engine$htmlWhi, _this$$engine$htmlWhi2, _context, _context2;
  21017. // preprocess custom white list
  21018. var customTagWhiteList = (_this$$engine$htmlWhi = (_this$$engine$htmlWhi2 = this.$engine.htmlWhiteListAppend) === null || _this$$engine$htmlWhi2 === void 0 ? void 0 : _this$$engine$htmlWhi2.split('|')) !== null && _this$$engine$htmlWhi !== void 0 ? _this$$engine$htmlWhi : [];
  21019. customTagWhiteList = filter$3(_context = map$3(customTagWhiteList).call(customTagWhiteList, function (tag) {
  21020. if (/[a-z-]+/gi.test(tag)) {
  21021. return tag;
  21022. }
  21023. return null;
  21024. })).call(_context, function (tag) {
  21025. return tag !== null;
  21026. }); // concat all white list
  21027. var allBlockNames = concat$5(customTagWhiteList).call(customTagWhiteList, blockNames).join('|'); // 段落标签自然换行,所以去掉段落标签两边的换行符
  21028. /**
  21029. * remove newlines after start tag, and remove whitespaces before newline
  21030. * e.g.
  21031. * <p> \n text</p> => <p> text</p>
  21032. * ^^
  21033. * $1$2
  21034. */
  21035. this.removeBrAfterBlock = new RegExp("<(".concat(allBlockNames, ")(>| [^>]*?>)[^\\S\\n]*?\\n"), 'ig');
  21036. /**
  21037. * remove newlines before end tag, and whitespaces before end tag will be preserved
  21038. * e.g.
  21039. * <p> text\n </p> => <p> text </p>
  21040. * ^
  21041. * $1
  21042. */
  21043. this.removeBrBeforeBlock = new RegExp("\\n[^\\S\\n]*?<\\/(".concat(allBlockNames, ")>[^\\S\\n]*?\\n"), 'ig');
  21044. /**
  21045. * remove newlines between end tag & start tag
  21046. * e.g.
  21047. * </p> \n <p foo="bar"> => </p>\r <p foo="bar">
  21048. * ^ ^^ ^ ^^^^^^^^^^^^
  21049. * $1 $2 $3 $4
  21050. */
  21051. this.removeNewlinesBetweenTags = new RegExp(concat$5(_context2 = "<\\/(".concat(allBlockNames, ")>[^\\S\\n]*?\\n([^\\S\\n]*?)<(")).call(_context2, allBlockNames, ")(>| [^>]*?>)"), 'ig');
  21052. }
  21053. return textContainsHtml.replace(this.removeBrAfterBlock, '<$1$2').replace(this.removeBrBeforeBlock, '</$1>').replace(this.removeNewlinesBetweenTags, '</$1>\r$2<$3$4'); // replace \n to \r
  21054. }
  21055. }, {
  21056. key: "toHtml",
  21057. value: function toHtml(str, sentenceMakeFunc) {
  21058. return str;
  21059. }
  21060. }, {
  21061. key: "makeHtml",
  21062. value: function makeHtml(str, sentenceMakeFunc) {
  21063. return sentenceMakeFunc(str).html;
  21064. }
  21065. }, {
  21066. key: "afterMakeHtml",
  21067. value: function afterMakeHtml(html) {
  21068. return this.restoreCache(html);
  21069. }
  21070. }, {
  21071. key: "isContainsCache",
  21072. value: function isContainsCache(str, fullMatch) {
  21073. if (fullMatch) {
  21074. // 如果是全匹配:不能包含CherryINPRAGRAPH
  21075. var containsParagraphCache = /^(\s*~~C\d+I\w+\$\s*)+$/g.test(str);
  21076. var containsInParagraphCache = new RegExp("~~C\\d+I".concat(ParagraphBase.IN_PARAGRAPH_CACHE_KEY_PREFIX_REGEX, "\\w+\\$"), 'g').test(str);
  21077. return containsParagraphCache && !containsInParagraphCache;
  21078. } // 如果是局部匹配: 不能只包含CherryINPRAGRAPH
  21079. // const containsParagraphCache = /~~C\d+I\w+\$/g.test(str);
  21080. // const containsInParagraphCache = new RegExp(
  21081. // `~~C\\d+I${ParagraphBase.IN_PARAGRAPH_CACHE_KEY_PREFIX}\\w+\\$`, 'g').test(str);
  21082. var containsNonInParagraphCache = new RegExp("~~C\\d+I(?!".concat(ParagraphBase.IN_PARAGRAPH_CACHE_KEY_PREFIX_REGEX, ")\\w+\\$"), 'g').test(str);
  21083. return containsNonInParagraphCache; // return fullMatch ?
  21084. // /^(\s*~~C\d+I\w+\$\s*)+$/g.test(str) && !/^(\s*~~C\d+ICherryINPRAGRAPH\w+\$\s*)+$/g.test(str) :
  21085. // /~~C\d+I\w+\$/g.test(str) && !(/~~C\d+ICherryINPRAGRAPH\w+\$/g.test(str)
  21086. // && !/~~C\d+I(?!CherryINPRAGRAPH)\w+\$/g.test(str));
  21087. }
  21088. /**
  21089. *
  21090. * @param {string} html
  21091. * @return
  21092. */
  21093. }, {
  21094. key: "$splitHtmlByCache",
  21095. value: function $splitHtmlByCache(html) {
  21096. // ~~C0I(?!prefix)sign$
  21097. var regex = new RegExp("\\n*~~C\\d+I(?!".concat(ParagraphBase.IN_PARAGRAPH_CACHE_KEY_PREFIX_REGEX, ")\\w+\\$\\n?"), 'g');
  21098. return {
  21099. caches: html.match(regex),
  21100. contents: html.split(regex)
  21101. };
  21102. }
  21103. }, {
  21104. key: "makeExcludingCached",
  21105. value: function makeExcludingCached(content, processor) {
  21106. var _this$$splitHtmlByCac = this.$splitHtmlByCache(content),
  21107. caches = _this$$splitHtmlByCac.caches,
  21108. contents = _this$$splitHtmlByCac.contents;
  21109. var paragraphs = map$3(contents).call(contents, processor);
  21110. var ret = '';
  21111. for (var i = 0; i < paragraphs.length; i++) {
  21112. ret += paragraphs[i];
  21113. if (caches && caches[i]) {
  21114. var _context3;
  21115. ret += trim$3(_context3 = caches[i]).call(_context3);
  21116. }
  21117. }
  21118. return ret;
  21119. }
  21120. /**
  21121. * 获取非捕获匹配丢掉的换行,适用于能被【嵌套】的段落语法
  21122. *
  21123. * @param {string} cache 需要返回的cache
  21124. * @param {string} md 原始的md字符串
  21125. * @param {boolean} alwaysAlone 是否能被【嵌套】,true:不能被嵌套,如标题、注释等;false:能被嵌套,如代码块、有序列表等
  21126. * @return {string} str
  21127. */
  21128. }, {
  21129. key: "getCacheWithSpace",
  21130. value: function getCacheWithSpace(cache, md) {
  21131. var _md$match$, _md$match, _md$match$2, _md$match2, _context4, _context5;
  21132. var alwaysAlone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  21133. var preSpace = (_md$match$ = (_md$match = md.match(/^\n+/)) === null || _md$match === void 0 ? void 0 : _md$match[0]) !== null && _md$match$ !== void 0 ? _md$match$ : '';
  21134. var afterSpace = (_md$match$2 = (_md$match2 = md.match(/\n+$/)) === null || _md$match2 === void 0 ? void 0 : _md$match2[0]) !== null && _md$match$2 !== void 0 ? _md$match$2 : '';
  21135. if (alwaysAlone) {
  21136. return prependLineFeedForParagraph(md, cache);
  21137. }
  21138. return concat$5(_context4 = concat$5(_context5 = "".concat(preSpace)).call(_context5, cache)).call(_context4, afterSpace);
  21139. }
  21140. /**
  21141. * 获取行号,只负责向上计算\n
  21142. * 会计算cache的行号
  21143. *
  21144. * @param {string} md md内容
  21145. * @param {string} preSpace 前置换行
  21146. * @return {number} 行数
  21147. */
  21148. }, {
  21149. key: "getLineCount",
  21150. value: function getLineCount(md) {
  21151. var _preSpace$match$0$len, _preSpace$match, _preSpace$match$;
  21152. var preSpace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  21153. var content = md;
  21154. /**
  21155. * 前置换行个数,【注意】:前置换行个数不包括上文的最后一个\n
  21156. * 例:
  21157. * - aa\n
  21158. * - bb\n
  21159. * \n
  21160. * cc\n
  21161. *
  21162. * cc的前置换行个数为 1,bb后的\n不计算在内
  21163. * cc的正则为:/(?:^|\n)(\n*)xxxxxx/
  21164. */
  21165. var preLineCount = (_preSpace$match$0$len = (_preSpace$match = preSpace.match(/^\n+/g)) === null || _preSpace$match === void 0 ? void 0 : (_preSpace$match$ = _preSpace$match[0]) === null || _preSpace$match$ === void 0 ? void 0 : _preSpace$match$.length) !== null && _preSpace$match$0$len !== void 0 ? _preSpace$match$0$len : 0;
  21166. preLineCount = preLineCount === 1 ? 1 : 0; // 前置换行超过2个就交给BR进行渲染
  21167. content = content.replace(/^\n+/g, '');
  21168. var regex = new RegExp("\n*~~C\\d+I(?:".concat(ParagraphBase.IN_PARAGRAPH_CACHE_KEY_PREFIX_REGEX, ")?\\w+?_L(\\d+)\\$"), 'g');
  21169. var cacheLineCount = 0;
  21170. content = content.replace(regex, function (match, lineCount) {
  21171. cacheLineCount += _parseInt$2(lineCount, 10);
  21172. return match.replace(/^\n+/g, '');
  21173. });
  21174. return preLineCount + cacheLineCount + (content.match(/\n/g) || []).length + 1; // 实际内容所占行数,至少为1行
  21175. }
  21176. /**
  21177. *
  21178. * @param {string} str 渲染后的内容
  21179. * @param {string} sign 签名
  21180. * @param {number} lineCount md原文的行数
  21181. * @return {string} cacheKey ~~C0I0_L1$
  21182. */
  21183. }, {
  21184. key: "pushCache",
  21185. value: function pushCache(str) {
  21186. var _context6, _context7;
  21187. var sign = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  21188. var lineCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  21189. if (!this.needCache) {
  21190. return;
  21191. }
  21192. var $sign = sign || this.$engine.md5(str);
  21193. this.cache[$sign] = {
  21194. content: str,
  21195. using: true
  21196. };
  21197. return concat$5(_context6 = concat$5(_context7 = "".concat(this.cacheKey, "I")).call(_context7, $sign, "_L")).call(_context6, lineCount, "$");
  21198. }
  21199. }, {
  21200. key: "popCache",
  21201. value: function popCache(sign) {
  21202. if (!this.needCache) {
  21203. return;
  21204. }
  21205. return this.cache[sign].content || '';
  21206. }
  21207. }, {
  21208. key: "resetCache",
  21209. value: function resetCache() {
  21210. if (!this.needCache) {
  21211. return;
  21212. }
  21213. for (var _i = 0, _Object$keys = keys$3(this.cache); _i < _Object$keys.length; _i++) {
  21214. var key = _Object$keys[_i];
  21215. if (!this.cache[key].using) delete this.cache[key];
  21216. }
  21217. for (var _i2 = 0, _Object$keys3 = keys$3(this.cache); _i2 < _Object$keys3.length; _i2++) {
  21218. var _key = _Object$keys3[_i2];
  21219. this.cache[_key].using = false;
  21220. }
  21221. }
  21222. }, {
  21223. key: "restoreCache",
  21224. value: function restoreCache(html) {
  21225. var _context8,
  21226. _this2 = this;
  21227. // restore cached content
  21228. if (!this.needCache) {
  21229. return html;
  21230. }
  21231. var regex = new RegExp(concat$5(_context8 = "".concat(this.cacheKey, "I((?:")).call(_context8, ParagraphBase.IN_PARAGRAPH_CACHE_KEY_PREFIX_REGEX, ")?\\w+)\\$"), 'g');
  21232. var $html = html.replace(regex, function (match, cacheSign) {
  21233. return _this2.popCache(cacheSign.replace(/_L\d+$/, ''));
  21234. });
  21235. this.resetCache();
  21236. return $html;
  21237. }
  21238. /**
  21239. *
  21240. * @param {string} wholeMatch whole match
  21241. */
  21242. }, {
  21243. key: "checkCache",
  21244. value: function checkCache(wholeMatch, sentenceMakeFunc) {
  21245. var _context9, _context10;
  21246. var lineCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  21247. this.sign = this.$engine.md5(wholeMatch); // miss cache
  21248. if (!this.cache[this.sign]) {
  21249. return this.toHtml(wholeMatch, sentenceMakeFunc);
  21250. } // hit & mark cache
  21251. this.cache[this.sign].using = true;
  21252. return concat$5(_context9 = concat$5(_context10 = "".concat(this.cacheKey, "I")).call(_context10, this.sign, "_L")).call(_context9, lineCount, "$");
  21253. }
  21254. }, {
  21255. key: "mounted",
  21256. value: function mounted() {// console.log('base mounted');
  21257. }
  21258. }, {
  21259. key: "signWithCache",
  21260. value: function signWithCache(html) {
  21261. return false;
  21262. }
  21263. }]);
  21264. return ParagraphBase;
  21265. }(SyntaxBase);
  21266. _defineProperty(ParagraphBase, "HOOK_TYPE", HOOKS_TYPE_LIST.PAR);
  21267. _defineProperty(ParagraphBase, "IN_PARAGRAPH_CACHE_KEY_PREFIX", '!');
  21268. _defineProperty(ParagraphBase, "IN_PARAGRAPH_CACHE_KEY_PREFIX_REGEX", '\\!');
  21269. // FF26- bug: ArrayBuffers are non-extensible, but Object.isExtensible does not report it
  21270. var arrayBufferNonExtensible = fails(function () {
  21271. if (typeof ArrayBuffer == 'function') {
  21272. var buffer = new ArrayBuffer(8);
  21273. // eslint-disable-next-line es-x/no-object-isextensible, es-x/no-object-defineproperty -- safe
  21274. if (Object.isExtensible(buffer)) Object.defineProperty(buffer, 'a', { value: 8 });
  21275. }
  21276. });
  21277. // eslint-disable-next-line es-x/no-object-isextensible -- safe
  21278. var $isExtensible = Object.isExtensible;
  21279. var FAILS_ON_PRIMITIVES$3 = fails(function () { $isExtensible(1); });
  21280. // `Object.isExtensible` method
  21281. // https://tc39.es/ecma262/#sec-object.isextensible
  21282. var objectIsExtensible = (FAILS_ON_PRIMITIVES$3 || arrayBufferNonExtensible) ? function isExtensible(it) {
  21283. if (!isObject(it)) return false;
  21284. if (arrayBufferNonExtensible && classofRaw(it) == 'ArrayBuffer') return false;
  21285. return $isExtensible ? $isExtensible(it) : true;
  21286. } : $isExtensible;
  21287. var freezing = !fails(function () {
  21288. // eslint-disable-next-line es-x/no-object-isextensible, es-x/no-object-preventextensions -- required for testing
  21289. return Object.isExtensible(Object.preventExtensions({}));
  21290. });
  21291. var internalMetadata = createCommonjsModule(function (module) {
  21292. var defineProperty = objectDefineProperty.f;
  21293. var REQUIRED = false;
  21294. var METADATA = uid('meta');
  21295. var id = 0;
  21296. var setMetadata = function (it) {
  21297. defineProperty(it, METADATA, { value: {
  21298. objectID: 'O' + id++, // object ID
  21299. weakData: {} // weak collections IDs
  21300. } });
  21301. };
  21302. var fastKey = function (it, create) {
  21303. // return a primitive with prefix
  21304. if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  21305. if (!hasOwnProperty_1(it, METADATA)) {
  21306. // can't set metadata to uncaught frozen object
  21307. if (!objectIsExtensible(it)) return 'F';
  21308. // not necessary to add metadata
  21309. if (!create) return 'E';
  21310. // add missing metadata
  21311. setMetadata(it);
  21312. // return object ID
  21313. } return it[METADATA].objectID;
  21314. };
  21315. var getWeakData = function (it, create) {
  21316. if (!hasOwnProperty_1(it, METADATA)) {
  21317. // can't set metadata to uncaught frozen object
  21318. if (!objectIsExtensible(it)) return true;
  21319. // not necessary to add metadata
  21320. if (!create) return false;
  21321. // add missing metadata
  21322. setMetadata(it);
  21323. // return the store of weak collections IDs
  21324. } return it[METADATA].weakData;
  21325. };
  21326. // add metadata on freeze-family methods calling
  21327. var onFreeze = function (it) {
  21328. if (freezing && REQUIRED && objectIsExtensible(it) && !hasOwnProperty_1(it, METADATA)) setMetadata(it);
  21329. return it;
  21330. };
  21331. var enable = function () {
  21332. meta.enable = function () { /* empty */ };
  21333. REQUIRED = true;
  21334. var getOwnPropertyNames = objectGetOwnPropertyNames.f;
  21335. var splice = functionUncurryThis([].splice);
  21336. var test = {};
  21337. test[METADATA] = 1;
  21338. // prevent exposing of metadata key
  21339. if (getOwnPropertyNames(test).length) {
  21340. objectGetOwnPropertyNames.f = function (it) {
  21341. var result = getOwnPropertyNames(it);
  21342. for (var i = 0, length = result.length; i < length; i++) {
  21343. if (result[i] === METADATA) {
  21344. splice(result, i, 1);
  21345. break;
  21346. }
  21347. } return result;
  21348. };
  21349. _export({ target: 'Object', stat: true, forced: true }, {
  21350. getOwnPropertyNames: objectGetOwnPropertyNamesExternal.f
  21351. });
  21352. }
  21353. };
  21354. var meta = module.exports = {
  21355. enable: enable,
  21356. fastKey: fastKey,
  21357. getWeakData: getWeakData,
  21358. onFreeze: onFreeze
  21359. };
  21360. hiddenKeys[METADATA] = true;
  21361. });
  21362. var internalMetadata_1 = internalMetadata.enable;
  21363. var internalMetadata_2 = internalMetadata.fastKey;
  21364. var internalMetadata_3 = internalMetadata.getWeakData;
  21365. var internalMetadata_4 = internalMetadata.onFreeze;
  21366. var TypeError$g = global_1.TypeError;
  21367. var Result = function (stopped, result) {
  21368. this.stopped = stopped;
  21369. this.result = result;
  21370. };
  21371. var ResultPrototype = Result.prototype;
  21372. var iterate = function (iterable, unboundFunction, options) {
  21373. var that = options && options.that;
  21374. var AS_ENTRIES = !!(options && options.AS_ENTRIES);
  21375. var IS_ITERATOR = !!(options && options.IS_ITERATOR);
  21376. var INTERRUPTED = !!(options && options.INTERRUPTED);
  21377. var fn = functionBindContext(unboundFunction, that);
  21378. var iterator, iterFn, index, length, result, next, step;
  21379. var stop = function (condition) {
  21380. if (iterator) iteratorClose(iterator, 'normal', condition);
  21381. return new Result(true, condition);
  21382. };
  21383. var callFn = function (value) {
  21384. if (AS_ENTRIES) {
  21385. anObject(value);
  21386. return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
  21387. } return INTERRUPTED ? fn(value, stop) : fn(value);
  21388. };
  21389. if (IS_ITERATOR) {
  21390. iterator = iterable;
  21391. } else {
  21392. iterFn = getIteratorMethod(iterable);
  21393. if (!iterFn) throw TypeError$g(tryToString(iterable) + ' is not iterable');
  21394. // optimisation for array iterators
  21395. if (isArrayIteratorMethod(iterFn)) {
  21396. for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
  21397. result = callFn(iterable[index]);
  21398. if (result && objectIsPrototypeOf(ResultPrototype, result)) return result;
  21399. } return new Result(false);
  21400. }
  21401. iterator = getIterator(iterable, iterFn);
  21402. }
  21403. next = iterator.next;
  21404. while (!(step = functionCall(next, iterator)).done) {
  21405. try {
  21406. result = callFn(step.value);
  21407. } catch (error) {
  21408. iteratorClose(iterator, 'throw', error);
  21409. }
  21410. if (typeof result == 'object' && result && objectIsPrototypeOf(ResultPrototype, result)) return result;
  21411. } return new Result(false);
  21412. };
  21413. var TypeError$h = global_1.TypeError;
  21414. var anInstance = function (it, Prototype) {
  21415. if (objectIsPrototypeOf(Prototype, it)) return it;
  21416. throw TypeError$h('Incorrect invocation');
  21417. };
  21418. var defineProperty$d = objectDefineProperty.f;
  21419. var forEach$4 = arrayIteration.forEach;
  21420. var setInternalState$3 = internalState.set;
  21421. var internalStateGetterFor = internalState.getterFor;
  21422. var collection = function (CONSTRUCTOR_NAME, wrapper, common) {
  21423. var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;
  21424. var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;
  21425. var ADDER = IS_MAP ? 'set' : 'add';
  21426. var NativeConstructor = global_1[CONSTRUCTOR_NAME];
  21427. var NativePrototype = NativeConstructor && NativeConstructor.prototype;
  21428. var exported = {};
  21429. var Constructor;
  21430. if (!descriptors || !isCallable(NativeConstructor)
  21431. || !(IS_WEAK || NativePrototype.forEach && !fails(function () { new NativeConstructor().entries().next(); }))
  21432. ) {
  21433. // create collection constructor
  21434. Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
  21435. internalMetadata.enable();
  21436. } else {
  21437. Constructor = wrapper(function (target, iterable) {
  21438. setInternalState$3(anInstance(target, Prototype), {
  21439. type: CONSTRUCTOR_NAME,
  21440. collection: new NativeConstructor()
  21441. });
  21442. if (iterable != undefined) iterate(iterable, target[ADDER], { that: target, AS_ENTRIES: IS_MAP });
  21443. });
  21444. var Prototype = Constructor.prototype;
  21445. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  21446. forEach$4(['add', 'clear', 'delete', 'forEach', 'get', 'has', 'set', 'keys', 'values', 'entries'], function (KEY) {
  21447. var IS_ADDER = KEY == 'add' || KEY == 'set';
  21448. if (KEY in NativePrototype && !(IS_WEAK && KEY == 'clear')) {
  21449. createNonEnumerableProperty(Prototype, KEY, function (a, b) {
  21450. var collection = getInternalState(this).collection;
  21451. if (!IS_ADDER && IS_WEAK && !isObject(a)) return KEY == 'get' ? undefined : false;
  21452. var result = collection[KEY](a === 0 ? 0 : a, b);
  21453. return IS_ADDER ? this : result;
  21454. });
  21455. }
  21456. });
  21457. IS_WEAK || defineProperty$d(Prototype, 'size', {
  21458. configurable: true,
  21459. get: function () {
  21460. return getInternalState(this).collection.size;
  21461. }
  21462. });
  21463. }
  21464. setToStringTag(Constructor, CONSTRUCTOR_NAME, false, true);
  21465. exported[CONSTRUCTOR_NAME] = Constructor;
  21466. _export({ global: true, forced: true }, exported);
  21467. if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
  21468. return Constructor;
  21469. };
  21470. var defineBuiltIns = function (target, src, options) {
  21471. for (var key in src) {
  21472. if (options && options.unsafe && target[key]) target[key] = src[key];
  21473. else defineBuiltIn(target, key, src[key], options);
  21474. } return target;
  21475. };
  21476. var SPECIES$3 = wellKnownSymbol('species');
  21477. var setSpecies = function (CONSTRUCTOR_NAME) {
  21478. var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
  21479. var defineProperty = objectDefineProperty.f;
  21480. if (descriptors && Constructor && !Constructor[SPECIES$3]) {
  21481. defineProperty(Constructor, SPECIES$3, {
  21482. configurable: true,
  21483. get: function () { return this; }
  21484. });
  21485. }
  21486. };
  21487. var defineProperty$e = objectDefineProperty.f;
  21488. var fastKey = internalMetadata.fastKey;
  21489. var setInternalState$4 = internalState.set;
  21490. var internalStateGetterFor$1 = internalState.getterFor;
  21491. var collectionStrong = {
  21492. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  21493. var Constructor = wrapper(function (that, iterable) {
  21494. anInstance(that, Prototype);
  21495. setInternalState$4(that, {
  21496. type: CONSTRUCTOR_NAME,
  21497. index: objectCreate(null),
  21498. first: undefined,
  21499. last: undefined,
  21500. size: 0
  21501. });
  21502. if (!descriptors) that.size = 0;
  21503. if (iterable != undefined) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
  21504. });
  21505. var Prototype = Constructor.prototype;
  21506. var getInternalState = internalStateGetterFor$1(CONSTRUCTOR_NAME);
  21507. var define = function (that, key, value) {
  21508. var state = getInternalState(that);
  21509. var entry = getEntry(that, key);
  21510. var previous, index;
  21511. // change existing entry
  21512. if (entry) {
  21513. entry.value = value;
  21514. // create new entry
  21515. } else {
  21516. state.last = entry = {
  21517. index: index = fastKey(key, true),
  21518. key: key,
  21519. value: value,
  21520. previous: previous = state.last,
  21521. next: undefined,
  21522. removed: false
  21523. };
  21524. if (!state.first) state.first = entry;
  21525. if (previous) previous.next = entry;
  21526. if (descriptors) state.size++;
  21527. else that.size++;
  21528. // add to index
  21529. if (index !== 'F') state.index[index] = entry;
  21530. } return that;
  21531. };
  21532. var getEntry = function (that, key) {
  21533. var state = getInternalState(that);
  21534. // fast case
  21535. var index = fastKey(key);
  21536. var entry;
  21537. if (index !== 'F') return state.index[index];
  21538. // frozen object case
  21539. for (entry = state.first; entry; entry = entry.next) {
  21540. if (entry.key == key) return entry;
  21541. }
  21542. };
  21543. defineBuiltIns(Prototype, {
  21544. // `{ Map, Set }.prototype.clear()` methods
  21545. // https://tc39.es/ecma262/#sec-map.prototype.clear
  21546. // https://tc39.es/ecma262/#sec-set.prototype.clear
  21547. clear: function clear() {
  21548. var that = this;
  21549. var state = getInternalState(that);
  21550. var data = state.index;
  21551. var entry = state.first;
  21552. while (entry) {
  21553. entry.removed = true;
  21554. if (entry.previous) entry.previous = entry.previous.next = undefined;
  21555. delete data[entry.index];
  21556. entry = entry.next;
  21557. }
  21558. state.first = state.last = undefined;
  21559. if (descriptors) state.size = 0;
  21560. else that.size = 0;
  21561. },
  21562. // `{ Map, Set }.prototype.delete(key)` methods
  21563. // https://tc39.es/ecma262/#sec-map.prototype.delete
  21564. // https://tc39.es/ecma262/#sec-set.prototype.delete
  21565. 'delete': function (key) {
  21566. var that = this;
  21567. var state = getInternalState(that);
  21568. var entry = getEntry(that, key);
  21569. if (entry) {
  21570. var next = entry.next;
  21571. var prev = entry.previous;
  21572. delete state.index[entry.index];
  21573. entry.removed = true;
  21574. if (prev) prev.next = next;
  21575. if (next) next.previous = prev;
  21576. if (state.first == entry) state.first = next;
  21577. if (state.last == entry) state.last = prev;
  21578. if (descriptors) state.size--;
  21579. else that.size--;
  21580. } return !!entry;
  21581. },
  21582. // `{ Map, Set }.prototype.forEach(callbackfn, thisArg = undefined)` methods
  21583. // https://tc39.es/ecma262/#sec-map.prototype.foreach
  21584. // https://tc39.es/ecma262/#sec-set.prototype.foreach
  21585. forEach: function forEach(callbackfn /* , that = undefined */) {
  21586. var state = getInternalState(this);
  21587. var boundFunction = functionBindContext(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  21588. var entry;
  21589. while (entry = entry ? entry.next : state.first) {
  21590. boundFunction(entry.value, entry.key, this);
  21591. // revert to the last existing entry
  21592. while (entry && entry.removed) entry = entry.previous;
  21593. }
  21594. },
  21595. // `{ Map, Set}.prototype.has(key)` methods
  21596. // https://tc39.es/ecma262/#sec-map.prototype.has
  21597. // https://tc39.es/ecma262/#sec-set.prototype.has
  21598. has: function has(key) {
  21599. return !!getEntry(this, key);
  21600. }
  21601. });
  21602. defineBuiltIns(Prototype, IS_MAP ? {
  21603. // `Map.prototype.get(key)` method
  21604. // https://tc39.es/ecma262/#sec-map.prototype.get
  21605. get: function get(key) {
  21606. var entry = getEntry(this, key);
  21607. return entry && entry.value;
  21608. },
  21609. // `Map.prototype.set(key, value)` method
  21610. // https://tc39.es/ecma262/#sec-map.prototype.set
  21611. set: function set(key, value) {
  21612. return define(this, key === 0 ? 0 : key, value);
  21613. }
  21614. } : {
  21615. // `Set.prototype.add(value)` method
  21616. // https://tc39.es/ecma262/#sec-set.prototype.add
  21617. add: function add(value) {
  21618. return define(this, value = value === 0 ? 0 : value, value);
  21619. }
  21620. });
  21621. if (descriptors) defineProperty$e(Prototype, 'size', {
  21622. get: function () {
  21623. return getInternalState(this).size;
  21624. }
  21625. });
  21626. return Constructor;
  21627. },
  21628. setStrong: function (Constructor, CONSTRUCTOR_NAME, IS_MAP) {
  21629. var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator';
  21630. var getInternalCollectionState = internalStateGetterFor$1(CONSTRUCTOR_NAME);
  21631. var getInternalIteratorState = internalStateGetterFor$1(ITERATOR_NAME);
  21632. // `{ Map, Set }.prototype.{ keys, values, entries, @@iterator }()` methods
  21633. // https://tc39.es/ecma262/#sec-map.prototype.entries
  21634. // https://tc39.es/ecma262/#sec-map.prototype.keys
  21635. // https://tc39.es/ecma262/#sec-map.prototype.values
  21636. // https://tc39.es/ecma262/#sec-map.prototype-@@iterator
  21637. // https://tc39.es/ecma262/#sec-set.prototype.entries
  21638. // https://tc39.es/ecma262/#sec-set.prototype.keys
  21639. // https://tc39.es/ecma262/#sec-set.prototype.values
  21640. // https://tc39.es/ecma262/#sec-set.prototype-@@iterator
  21641. defineIterator(Constructor, CONSTRUCTOR_NAME, function (iterated, kind) {
  21642. setInternalState$4(this, {
  21643. type: ITERATOR_NAME,
  21644. target: iterated,
  21645. state: getInternalCollectionState(iterated),
  21646. kind: kind,
  21647. last: undefined
  21648. });
  21649. }, function () {
  21650. var state = getInternalIteratorState(this);
  21651. var kind = state.kind;
  21652. var entry = state.last;
  21653. // revert to the last existing entry
  21654. while (entry && entry.removed) entry = entry.previous;
  21655. // get next entry
  21656. if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {
  21657. // or finish the iteration
  21658. state.target = undefined;
  21659. return { value: undefined, done: true };
  21660. }
  21661. // return step by kind
  21662. if (kind == 'keys') return { value: entry.key, done: false };
  21663. if (kind == 'values') return { value: entry.value, done: false };
  21664. return { value: [entry.key, entry.value], done: false };
  21665. }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
  21666. // `{ Map, Set }.prototype[@@species]` accessors
  21667. // https://tc39.es/ecma262/#sec-get-map-@@species
  21668. // https://tc39.es/ecma262/#sec-get-set-@@species
  21669. setSpecies(CONSTRUCTOR_NAME);
  21670. }
  21671. };
  21672. // `Map` constructor
  21673. // https://tc39.es/ecma262/#sec-map-objects
  21674. collection('Map', function (init) {
  21675. return function Map() { return init(this, arguments.length ? arguments[0] : undefined); };
  21676. }, collectionStrong);
  21677. var map$4 = path.Map;
  21678. var map$5 = map$4;
  21679. var map$6 = map$5;
  21680. // https://tc39.github.io/proposal-setmap-offrom/
  21681. var push$4 = [].push;
  21682. var collectionFrom = function from(source /* , mapFn, thisArg */) {
  21683. var length = arguments.length;
  21684. var mapFn = length > 1 ? arguments[1] : undefined;
  21685. var mapping, array, n, boundFunction;
  21686. aConstructor(this);
  21687. mapping = mapFn !== undefined;
  21688. if (mapping) aCallable(mapFn);
  21689. if (source == undefined) return new this();
  21690. array = [];
  21691. if (mapping) {
  21692. n = 0;
  21693. boundFunction = functionBindContext(mapFn, length > 2 ? arguments[2] : undefined);
  21694. iterate(source, function (nextItem) {
  21695. functionCall(push$4, array, boundFunction(nextItem, n++));
  21696. });
  21697. } else {
  21698. iterate(source, push$4, { that: array });
  21699. }
  21700. return new this(array);
  21701. };
  21702. // `Map.from` method
  21703. // https://tc39.github.io/proposal-setmap-offrom/#sec-map.from
  21704. _export({ target: 'Map', stat: true, forced: true }, {
  21705. from: collectionFrom
  21706. });
  21707. // https://tc39.github.io/proposal-setmap-offrom/
  21708. var collectionOf = function of() {
  21709. return new this(arraySlice(arguments));
  21710. };
  21711. // `Map.of` method
  21712. // https://tc39.github.io/proposal-setmap-offrom/#sec-map.of
  21713. _export({ target: 'Map', stat: true, forced: true }, {
  21714. of: collectionOf
  21715. });
  21716. // https://github.com/tc39/collection-methods
  21717. var collectionDeleteAll = function deleteAll(/* ...elements */) {
  21718. var collection = anObject(this);
  21719. var remover = aCallable(collection['delete']);
  21720. var allDeleted = true;
  21721. var wasDeleted;
  21722. for (var k = 0, len = arguments.length; k < len; k++) {
  21723. wasDeleted = functionCall(remover, collection, arguments[k]);
  21724. allDeleted = allDeleted && wasDeleted;
  21725. }
  21726. return !!allDeleted;
  21727. };
  21728. // `Map.prototype.deleteAll` method
  21729. // https://github.com/tc39/proposal-collection-methods
  21730. _export({ target: 'Map', proto: true, real: true, forced: true }, {
  21731. deleteAll: collectionDeleteAll
  21732. });
  21733. // `Map.prototype.emplace` method
  21734. // https://github.com/thumbsupep/proposal-upsert
  21735. var mapEmplace = function emplace(key, handler) {
  21736. var map = anObject(this);
  21737. var get = aCallable(map.get);
  21738. var has = aCallable(map.has);
  21739. var set = aCallable(map.set);
  21740. var value = (functionCall(has, map, key) && 'update' in handler)
  21741. ? handler.update(functionCall(get, map, key), key, map)
  21742. : handler.insert(key, map);
  21743. functionCall(set, map, key, value);
  21744. return value;
  21745. };
  21746. // `Map.prototype.emplace` method
  21747. // https://github.com/thumbsupep/proposal-upsert
  21748. _export({ target: 'Map', proto: true, real: true, forced: true }, {
  21749. emplace: mapEmplace
  21750. });
  21751. var getMapIterator = getIterator;
  21752. // `Map.prototype.every` method
  21753. // https://github.com/tc39/proposal-collection-methods
  21754. _export({ target: 'Map', proto: true, real: true, forced: true }, {
  21755. every: function every(callbackfn /* , thisArg */) {
  21756. var map = anObject(this);
  21757. var iterator = getMapIterator(map);
  21758. var boundFunction = functionBindContext(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  21759. return !iterate(iterator, function (key, value, stop) {
  21760. if (!boundFunction(value, key, map)) return stop();
  21761. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
  21762. }
  21763. });
  21764. var SPECIES$4 = wellKnownSymbol('species');
  21765. // `SpeciesConstructor` abstract operation
  21766. // https://tc39.es/ecma262/#sec-speciesconstructor
  21767. var speciesConstructor = function (O, defaultConstructor) {
  21768. var C = anObject(O).constructor;
  21769. var S;
  21770. return C === undefined || (S = anObject(C)[SPECIES$4]) == undefined ? defaultConstructor : aConstructor(S);
  21771. };
  21772. // `Map.prototype.filter` method
  21773. // https://github.com/tc39/proposal-collection-methods
  21774. _export({ target: 'Map', proto: true, real: true, forced: true }, {
  21775. filter: function filter(callbackfn /* , thisArg */) {
  21776. var map = anObject(this);
  21777. var iterator = getMapIterator(map);
  21778. var boundFunction = functionBindContext(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  21779. var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();
  21780. var setter = aCallable(newMap.set);
  21781. iterate(iterator, function (key, value) {
  21782. if (boundFunction(value, key, map)) functionCall(setter, newMap, key, value);
  21783. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  21784. return newMap;
  21785. }
  21786. });
  21787. // `Map.prototype.find` method
  21788. // https://github.com/tc39/proposal-collection-methods
  21789. _export({ target: 'Map', proto: true, real: true, forced: true }, {
  21790. find: function find(callbackfn /* , thisArg */) {
  21791. var map = anObject(this);
  21792. var iterator = getMapIterator(map);
  21793. var boundFunction = functionBindContext(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  21794. return iterate(iterator, function (key, value, stop) {
  21795. if (boundFunction(value, key, map)) return stop(value);
  21796. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
  21797. }
  21798. });
  21799. // `Map.prototype.findKey` method
  21800. // https://github.com/tc39/proposal-collection-methods
  21801. _export({ target: 'Map', proto: true, real: true, forced: true }, {
  21802. findKey: function findKey(callbackfn /* , thisArg */) {
  21803. var map = anObject(this);
  21804. var iterator = getMapIterator(map);
  21805. var boundFunction = functionBindContext(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  21806. return iterate(iterator, function (key, value, stop) {
  21807. if (boundFunction(value, key, map)) return stop(key);
  21808. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
  21809. }
  21810. });
  21811. var push$5 = functionUncurryThis([].push);
  21812. // `Map.groupBy` method
  21813. // https://github.com/tc39/proposal-collection-methods
  21814. _export({ target: 'Map', stat: true, forced: true }, {
  21815. groupBy: function groupBy(iterable, keyDerivative) {
  21816. aCallable(keyDerivative);
  21817. var iterator = getIterator(iterable);
  21818. var newMap = new this();
  21819. var has = aCallable(newMap.has);
  21820. var get = aCallable(newMap.get);
  21821. var set = aCallable(newMap.set);
  21822. iterate(iterator, function (element) {
  21823. var derivedKey = keyDerivative(element);
  21824. if (!functionCall(has, newMap, derivedKey)) functionCall(set, newMap, derivedKey, [element]);
  21825. else push$5(functionCall(get, newMap, derivedKey), element);
  21826. }, { IS_ITERATOR: true });
  21827. return newMap;
  21828. }
  21829. });
  21830. // `SameValueZero` abstract operation
  21831. // https://tc39.es/ecma262/#sec-samevaluezero
  21832. var sameValueZero = function (x, y) {
  21833. // eslint-disable-next-line no-self-compare -- NaN check
  21834. return x === y || x != x && y != y;
  21835. };
  21836. // `Map.prototype.includes` method
  21837. // https://github.com/tc39/proposal-collection-methods
  21838. _export({ target: 'Map', proto: true, real: true, forced: true }, {
  21839. includes: function includes(searchElement) {
  21840. return iterate(getMapIterator(anObject(this)), function (key, value, stop) {
  21841. if (sameValueZero(value, searchElement)) return stop();
  21842. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
  21843. }
  21844. });
  21845. // `Map.keyBy` method
  21846. // https://github.com/tc39/proposal-collection-methods
  21847. _export({ target: 'Map', stat: true, forced: true }, {
  21848. keyBy: function keyBy(iterable, keyDerivative) {
  21849. var newMap = new this();
  21850. aCallable(keyDerivative);
  21851. var setter = aCallable(newMap.set);
  21852. iterate(iterable, function (element) {
  21853. functionCall(setter, newMap, keyDerivative(element), element);
  21854. });
  21855. return newMap;
  21856. }
  21857. });
  21858. // `Map.prototype.keyOf` method
  21859. // https://github.com/tc39/proposal-collection-methods
  21860. _export({ target: 'Map', proto: true, real: true, forced: true }, {
  21861. keyOf: function keyOf(searchElement) {
  21862. return iterate(getMapIterator(anObject(this)), function (key, value, stop) {
  21863. if (value === searchElement) return stop(key);
  21864. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
  21865. }
  21866. });
  21867. // `Map.prototype.mapKeys` method
  21868. // https://github.com/tc39/proposal-collection-methods
  21869. _export({ target: 'Map', proto: true, real: true, forced: true }, {
  21870. mapKeys: function mapKeys(callbackfn /* , thisArg */) {
  21871. var map = anObject(this);
  21872. var iterator = getMapIterator(map);
  21873. var boundFunction = functionBindContext(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  21874. var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();
  21875. var setter = aCallable(newMap.set);
  21876. iterate(iterator, function (key, value) {
  21877. functionCall(setter, newMap, boundFunction(value, key, map), value);
  21878. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  21879. return newMap;
  21880. }
  21881. });
  21882. // `Map.prototype.mapValues` method
  21883. // https://github.com/tc39/proposal-collection-methods
  21884. _export({ target: 'Map', proto: true, real: true, forced: true }, {
  21885. mapValues: function mapValues(callbackfn /* , thisArg */) {
  21886. var map = anObject(this);
  21887. var iterator = getMapIterator(map);
  21888. var boundFunction = functionBindContext(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  21889. var newMap = new (speciesConstructor(map, getBuiltIn('Map')))();
  21890. var setter = aCallable(newMap.set);
  21891. iterate(iterator, function (key, value) {
  21892. functionCall(setter, newMap, key, boundFunction(value, key, map));
  21893. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  21894. return newMap;
  21895. }
  21896. });
  21897. // `Map.prototype.merge` method
  21898. // https://github.com/tc39/proposal-collection-methods
  21899. _export({ target: 'Map', proto: true, real: true, arity: 1, forced: true }, {
  21900. // eslint-disable-next-line no-unused-vars -- required for `.length`
  21901. merge: function merge(iterable /* ...iterables */) {
  21902. var map = anObject(this);
  21903. var setter = aCallable(map.set);
  21904. var argumentsLength = arguments.length;
  21905. var i = 0;
  21906. while (i < argumentsLength) {
  21907. iterate(arguments[i++], setter, { that: map, AS_ENTRIES: true });
  21908. }
  21909. return map;
  21910. }
  21911. });
  21912. var TypeError$i = global_1.TypeError;
  21913. // `Map.prototype.reduce` method
  21914. // https://github.com/tc39/proposal-collection-methods
  21915. _export({ target: 'Map', proto: true, real: true, forced: true }, {
  21916. reduce: function reduce(callbackfn /* , initialValue */) {
  21917. var map = anObject(this);
  21918. var iterator = getMapIterator(map);
  21919. var noInitial = arguments.length < 2;
  21920. var accumulator = noInitial ? undefined : arguments[1];
  21921. aCallable(callbackfn);
  21922. iterate(iterator, function (key, value) {
  21923. if (noInitial) {
  21924. noInitial = false;
  21925. accumulator = value;
  21926. } else {
  21927. accumulator = callbackfn(accumulator, value, key, map);
  21928. }
  21929. }, { AS_ENTRIES: true, IS_ITERATOR: true });
  21930. if (noInitial) throw TypeError$i('Reduce of empty map with no initial value');
  21931. return accumulator;
  21932. }
  21933. });
  21934. // `Set.prototype.some` method
  21935. // https://github.com/tc39/proposal-collection-methods
  21936. _export({ target: 'Map', proto: true, real: true, forced: true }, {
  21937. some: function some(callbackfn /* , thisArg */) {
  21938. var map = anObject(this);
  21939. var iterator = getMapIterator(map);
  21940. var boundFunction = functionBindContext(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  21941. return iterate(iterator, function (key, value, stop) {
  21942. if (boundFunction(value, key, map)) return stop();
  21943. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
  21944. }
  21945. });
  21946. var TypeError$j = global_1.TypeError;
  21947. // `Set.prototype.update` method
  21948. // https://github.com/tc39/proposal-collection-methods
  21949. _export({ target: 'Map', proto: true, real: true, forced: true }, {
  21950. update: function update(key, callback /* , thunk */) {
  21951. var map = anObject(this);
  21952. var get = aCallable(map.get);
  21953. var has = aCallable(map.has);
  21954. var set = aCallable(map.set);
  21955. var length = arguments.length;
  21956. aCallable(callback);
  21957. var isPresentInMap = functionCall(has, map, key);
  21958. if (!isPresentInMap && length < 3) {
  21959. throw TypeError$j('Updating absent value');
  21960. }
  21961. var value = isPresentInMap ? functionCall(get, map, key) : aCallable(length > 2 ? arguments[2] : undefined)(key, map);
  21962. functionCall(set, map, key, callback(value, key, map));
  21963. return map;
  21964. }
  21965. });
  21966. var TypeError$k = global_1.TypeError;
  21967. // `Map.prototype.upsert` method
  21968. // https://github.com/thumbsupep/proposal-upsert
  21969. var mapUpsert = function upsert(key, updateFn /* , insertFn */) {
  21970. var map = anObject(this);
  21971. var get = aCallable(map.get);
  21972. var has = aCallable(map.has);
  21973. var set = aCallable(map.set);
  21974. var insertFn = arguments.length > 2 ? arguments[2] : undefined;
  21975. var value;
  21976. if (!isCallable(updateFn) && !isCallable(insertFn)) {
  21977. throw TypeError$k('At least one callback required');
  21978. }
  21979. if (functionCall(has, map, key)) {
  21980. value = functionCall(get, map, key);
  21981. if (isCallable(updateFn)) {
  21982. value = updateFn(value);
  21983. functionCall(set, map, key, value);
  21984. }
  21985. } else if (isCallable(insertFn)) {
  21986. value = insertFn();
  21987. functionCall(set, map, key, value);
  21988. } return value;
  21989. };
  21990. // TODO: remove from `core-js@4`
  21991. // `Map.prototype.upsert` method (replaced by `Map.prototype.emplace`)
  21992. // https://github.com/thumbsupep/proposal-upsert
  21993. _export({ target: 'Map', proto: true, real: true, forced: true }, {
  21994. upsert: mapUpsert
  21995. });
  21996. // TODO: remove from `core-js@4`
  21997. // `Map.prototype.updateOrInsert` method (replaced by `Map.prototype.emplace`)
  21998. // https://github.com/thumbsupep/proposal-upsert
  21999. _export({ target: 'Map', proto: true, real: true, name: 'upsert', forced: true }, {
  22000. updateOrInsert: mapUpsert
  22001. });
  22002. // TODO: remove from `core-js@4`
  22003. // TODO: remove from `core-js@4`
  22004. var map$7 = map$6;
  22005. var map$8 = map$7;
  22006. var map$9 = map$8;
  22007. var isNativeFunction = createCommonjsModule(function (module) {
  22008. function _isNativeFunction(fn) {
  22009. var _context;
  22010. return indexOf$7(_context = Function.toString.call(fn)).call(_context, "[native code]") !== -1;
  22011. }
  22012. module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22013. });
  22014. unwrapExports(isNativeFunction);
  22015. var construct$5 = construct$3;
  22016. var construct$6 = construct$5;
  22017. var construct$7 = construct$6;
  22018. var construct$8 = construct$7;
  22019. var bind$6 = bind$4;
  22020. var bind$7 = bind$6;
  22021. var bind$8 = bind$7;
  22022. var bind$9 = bind$8;
  22023. var isNativeReflectConstruct = createCommonjsModule(function (module) {
  22024. function _isNativeReflectConstruct() {
  22025. if (typeof Reflect === "undefined" || !construct$8) return false;
  22026. if (construct$8.sham) return false;
  22027. if (typeof Proxy === "function") return true;
  22028. try {
  22029. Boolean.prototype.valueOf.call(construct$8(Boolean, [], function () {}));
  22030. return true;
  22031. } catch (e) {
  22032. return false;
  22033. }
  22034. }
  22035. module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22036. });
  22037. unwrapExports(isNativeReflectConstruct);
  22038. var construct$9 = createCommonjsModule(function (module) {
  22039. function _construct(Parent, args, Class) {
  22040. if (isNativeReflectConstruct()) {
  22041. module.exports = _construct = construct$8, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22042. } else {
  22043. module.exports = _construct = function _construct(Parent, args, Class) {
  22044. var a = [null];
  22045. a.push.apply(a, args);
  22046. var Constructor = bind$9(Function).apply(Parent, a);
  22047. var instance = new Constructor();
  22048. if (Class) setPrototypeOf$6(instance, Class.prototype);
  22049. return instance;
  22050. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22051. }
  22052. return _construct.apply(null, arguments);
  22053. }
  22054. module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22055. });
  22056. var _construct = unwrapExports(construct$9);
  22057. var wrapNativeSuper = createCommonjsModule(function (module) {
  22058. function _wrapNativeSuper(Class) {
  22059. var _cache = typeof map$9 === "function" ? new map$9() : undefined;
  22060. module.exports = _wrapNativeSuper = function _wrapNativeSuper(Class) {
  22061. if (Class === null || !isNativeFunction(Class)) return Class;
  22062. if (typeof Class !== "function") {
  22063. throw new TypeError("Super expression must either be null or a function");
  22064. }
  22065. if (typeof _cache !== "undefined") {
  22066. if (_cache.has(Class)) return _cache.get(Class);
  22067. _cache.set(Class, Wrapper);
  22068. }
  22069. function Wrapper() {
  22070. return construct$9(Class, arguments, getPrototypeOf$6(this).constructor);
  22071. }
  22072. Wrapper.prototype = create$5(Class.prototype, {
  22073. constructor: {
  22074. value: Wrapper,
  22075. enumerable: false,
  22076. writable: true,
  22077. configurable: true
  22078. }
  22079. });
  22080. return setPrototypeOf$6(Wrapper, Class);
  22081. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22082. return _wrapNativeSuper(Class);
  22083. }
  22084. module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22085. });
  22086. var _wrapNativeSuper = unwrapExports(wrapNativeSuper);
  22087. function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  22088. function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  22089. /**
  22090. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  22091. *
  22092. * Licensed under the Apache License, Version 2.0 (the "License");
  22093. * you may not use this file except in compliance with the License.
  22094. * You may obtain a copy of the License at
  22095. *
  22096. * http://www.apache.org/licenses/LICENSE-2.0
  22097. *
  22098. * Unless required by applicable law or agreed to in writing, software
  22099. * distributed under the License is distributed on an "AS IS" BASIS,
  22100. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22101. * See the License for the specific language governing permissions and
  22102. * limitations under the License.
  22103. */
  22104. /**
  22105. * 三个地方的错误异常校验
  22106. * 1. markdown 对象参数校验
  22107. * 2. editText 用户输入校验,执行engine过程以防异常
  22108. * 3. 自定义hook校验 对外开发者开发标准校验
  22109. */
  22110. var $expectTarget = function $expectTarget(target, Constructor) {
  22111. if (!isArray$8(target) && _typeof(target) !== Constructor.name.toLowerCase() || !isArray$8(target) && Constructor.name.toLowerCase() === 'array') {
  22112. throw new TypeError("parameter given must be ".concat(Constructor.name));
  22113. }
  22114. return true;
  22115. };
  22116. var $expectInherit = function $expectInherit(target, parent) {
  22117. if (!(target instanceof parent)) {
  22118. throw new Error('the hook does not correctly inherit');
  22119. }
  22120. return true;
  22121. };
  22122. var $expectInstance = function $expectInstance(target) {
  22123. if (_typeof(target) !== 'object') {
  22124. throw new Error('the hook must be a instance, not a class');
  22125. }
  22126. return true;
  22127. }; // ref: https://github.com/mdlavin/nested-error-stacks
  22128. var NestedError = /*#__PURE__*/function (_Error) {
  22129. _inherits(NestedError, _Error);
  22130. var _super = _createSuper$1(NestedError);
  22131. function NestedError(message, nested) {
  22132. var _this;
  22133. _classCallCheck(this, NestedError);
  22134. _this = _super.call(this, message);
  22135. _this.name = 'Error';
  22136. _this.stack = _this.buildStackTrace(nested);
  22137. return _this;
  22138. }
  22139. _createClass(NestedError, [{
  22140. key: "buildStackTrace",
  22141. value: function buildStackTrace(nested) {
  22142. var _context;
  22143. var stack = nested && nested.stack ? nested.stack : '';
  22144. var newStack = concat$5(_context = "".concat(this.stack, "\nCaused By: ")).call(_context, stack);
  22145. return newStack;
  22146. }
  22147. }]);
  22148. return NestedError;
  22149. }( /*#__PURE__*/_wrapNativeSuper(Error));
  22150. /**
  22151. * @typedef {import('~types/cherry').CherryOptions} CherryOptions
  22152. * @typedef {import('~types/cherry').CherryEngineOptions} CherryEngineOptions
  22153. * @typedef {import('~types/cherry').CustomSyntaxRegConfig} CustomSyntaxRegConfig
  22154. * @typedef { (SyntaxBase | ParagraphBase) & { Cherry$$CUSTOM: true } } CustomSyntax
  22155. * @typedef { (typeof SyntaxBase | typeof ParagraphBase) & { Cherry$$CUSTOM: true } } CustomSyntaxClass
  22156. */
  22157. var WARN_DUPLICATED = -1;
  22158. var WARN_NOT_A_VALID_HOOK = -2;
  22159. /**
  22160. * 处理报错信息,在dev模式下才会输出报错信息
  22161. * @param {number} type
  22162. * @param {any} objClass
  22163. * @param {number} index
  22164. */
  22165. function processWarning(type, objClass, index) {
  22166. if (type === WARN_DUPLICATED) {
  22167. var _context, _context2;
  22168. Logger.warn(concat$5(_context = concat$5(_context2 = "Duplicate hook name [".concat(objClass.HOOK_NAME, "] found, hook [")).call(_context2, objClass.toString(), "] ")).call(_context, isNaN(index) ? '' : "at index [".concat(index, "] "), "will not take effect."));
  22169. } else if (type === WARN_NOT_A_VALID_HOOK) {
  22170. var _context3;
  22171. Logger.warn(concat$5(_context3 = "Hook [".concat(objClass.toString(), "] ")).call(_context3, isNaN(index) ? '' : "at index [".concat(index, "] "), "is not a valid hook, and will not take effect."));
  22172. }
  22173. }
  22174. /**
  22175. * 是否一个合法的 HookClass
  22176. * @param {any} HookClass
  22177. * @returns { HookClass is (typeof SyntaxBase | typeof ParagraphBase) }
  22178. */
  22179. function isHookValid(HookClass) {
  22180. return isProtoOfSyntaxBase(HookClass) || isProtoOfParagraphBase(HookClass);
  22181. }
  22182. /**
  22183. * 传入的类是否 SyntaxBase 的子类
  22184. * @param {any} value
  22185. * @returns { value is typeof SyntaxBase }
  22186. */
  22187. function isProtoOfSyntaxBase(value) {
  22188. return Object.prototype.isPrototypeOf.call(SyntaxBase, value);
  22189. }
  22190. /**
  22191. * 传入的类是否 ParagraphBase 的子类
  22192. * @param {any} value
  22193. * @returns { value is typeof ParagraphBase }
  22194. */
  22195. function isProtoOfParagraphBase(value) {
  22196. return Object.prototype.isPrototypeOf.call(ParagraphBase, value);
  22197. }
  22198. /**
  22199. * 是否一个配置型的自定义语法
  22200. * @param {any} value
  22201. * @returns { value is CustomSyntaxRegConfig }
  22202. */
  22203. function isCustomSyntaxConfig(value) {
  22204. var syntaxClass =
  22205. /** @type {any} */
  22206. /** @type {CustomSyntaxRegConfig} */
  22207. value === null || value === void 0 ? void 0 : value.syntaxClass;
  22208. return isProtoOfSyntaxBase(syntaxClass) || isProtoOfParagraphBase(syntaxClass);
  22209. }
  22210. /**
  22211. * 是否一个已注册的自定义语法hook类
  22212. * @param {any} value
  22213. * @returns { value is CustomSyntaxClass }
  22214. */
  22215. function isRegisteredCustomSyntaxClass(value) {
  22216. return isHookValid(value) &&
  22217. /** @type {CustomSyntaxClass} */
  22218. (value === null || value === void 0 ? void 0 : value.Cherry$$CUSTOM) === true;
  22219. }
  22220. /**
  22221. * 语法注册中心
  22222. */
  22223. var HookCenter = /*#__PURE__*/function () {
  22224. /**
  22225. *
  22226. * @param {(typeof SyntaxBase)[]} hooksConfig
  22227. * @param {Partial<CherryOptions>} editorConfig
  22228. */
  22229. function HookCenter(hooksConfig, editorConfig, cherry) {
  22230. _classCallCheck(this, HookCenter);
  22231. this.$locale = cherry.locale;
  22232. /**
  22233. * @property
  22234. * @type {Record<import('./SyntaxBase').HookType, SyntaxBase[]>} hookList hook 名称 -> hook 类型的映射
  22235. */
  22236. this.hookList =
  22237. /** @type {any} */
  22238. {};
  22239. /**
  22240. * @property
  22241. * @type {Record<string, { type: import('./SyntaxBase').HookType }>} hookNameList hook 名称 -> hook 类型的映射
  22242. */
  22243. this.hookNameList = {};
  22244. $expectTarget(hooksConfig, Array);
  22245. this.registerInternalHooks(hooksConfig, editorConfig);
  22246. this.registerCustomHooks(editorConfig.engine.customSyntax, editorConfig);
  22247. }
  22248. /**
  22249. * 注册系统默认的语法hook
  22250. * @param {any[]} hooksConfig 在hookconfig.js里定义的配置
  22251. * @param {Partial<CherryOptions>} editorConfig 编辑器配置
  22252. */
  22253. _createClass(HookCenter, [{
  22254. key: "registerInternalHooks",
  22255. value: function registerInternalHooks(hooksConfig, editorConfig) {
  22256. var _this = this;
  22257. forEach$3(hooksConfig).call(hooksConfig,
  22258. /**
  22259. *
  22260. * @param {typeof SyntaxBase} HookClass
  22261. * @param {number} index
  22262. */
  22263. function (HookClass, index) {
  22264. var result = _this.register(HookClass, editorConfig);
  22265. processWarning(result, HookClass, index);
  22266. });
  22267. }
  22268. /**
  22269. * 注册第三方的语法hook
  22270. * @param {CherryEngineOptions['customSyntax']} customHooks 用户传入的配置
  22271. * @param {Partial<CherryOptions>} editorConfig 编辑器配置
  22272. */
  22273. }, {
  22274. key: "registerCustomHooks",
  22275. value: function registerCustomHooks(customHooks, editorConfig) {
  22276. var _this2 = this;
  22277. if (!customHooks) {
  22278. return;
  22279. }
  22280. var hookNames = keys$3(customHooks);
  22281. forEach$3(hookNames).call(hookNames, function (hookName) {
  22282. /** @type {number} */
  22283. var result;
  22284. /** @type {typeof SyntaxBase} */
  22285. var HookClass;
  22286. var customHookConfig = {};
  22287. var hookClassOrConfig = customHooks[hookName];
  22288. if (isProtoOfSyntaxBase(hookClassOrConfig)) {
  22289. HookClass = hookClassOrConfig;
  22290. } else if (isCustomSyntaxConfig(hookClassOrConfig)) {
  22291. HookClass = hookClassOrConfig.syntaxClass;
  22292. customHookConfig.force = Boolean(hookClassOrConfig.force);
  22293. if (hookClassOrConfig.before) {
  22294. customHookConfig.before = hookClassOrConfig.before;
  22295. } else if (hookClassOrConfig.after) {
  22296. customHookConfig.after = hookClassOrConfig.after;
  22297. }
  22298. } else {
  22299. return;
  22300. }
  22301. if (isHookValid(HookClass)) {
  22302. // 自定义Hook标识
  22303. defineProperty$5(HookClass, 'Cherry$$CUSTOM', {
  22304. enumerable: false,
  22305. configurable: false,
  22306. writable: false,
  22307. value: true
  22308. });
  22309. result = _this2.register(HookClass, editorConfig, customHookConfig);
  22310. } else {
  22311. result = WARN_NOT_A_VALID_HOOK;
  22312. }
  22313. processWarning(result, HookClass, undefined);
  22314. });
  22315. }
  22316. }, {
  22317. key: "getHookList",
  22318. value: function getHookList() {
  22319. return this.hookList;
  22320. }
  22321. }, {
  22322. key: "getHookNameList",
  22323. value: function getHookNameList() {
  22324. return this.hookNameList;
  22325. }
  22326. /**
  22327. *
  22328. * @param {((...args: any[]) => any) | typeof SyntaxBase} HookClass
  22329. * @param {Partial<CherryOptions>} editorConfig
  22330. * @param {Omit<CustomSyntaxRegConfig, 'syntaxClass'>} [customHookConfig]
  22331. * @returns
  22332. */
  22333. }, {
  22334. key: "register",
  22335. value: function register(HookClass, editorConfig, customHookConfig) {
  22336. var _this3 = this;
  22337. // filter Configs Here
  22338. var externals = editorConfig.externals,
  22339. engine = editorConfig.engine;
  22340. var syntax = engine.syntax;
  22341. /** @type {SyntaxBase | CustomSyntax} */
  22342. var instance;
  22343. /** @type {string} */
  22344. var hookName; // 首先校验Hook是否合法
  22345. if (!isHookValid(HookClass)) {
  22346. // 可能是一个function hook
  22347. if (typeof HookClass === 'function') {
  22348. var funcHook = HookClass;
  22349. instance = funcHook(editorConfig);
  22350. if (!instance || !isHookValid(instance.constructor)) {
  22351. return WARN_NOT_A_VALID_HOOK;
  22352. }
  22353. hookName = instance.getName();
  22354. } else {
  22355. return WARN_NOT_A_VALID_HOOK;
  22356. }
  22357. } else {
  22358. hookName = HookClass.HOOK_NAME; // TODO: 需要考虑自定义 hook 配置的传入方式
  22359. var config = (syntax === null || syntax === void 0 ? void 0 : syntax[hookName]) || {};
  22360. instance = new HookClass({
  22361. externals: externals,
  22362. config: config,
  22363. globalConfig: engine.global
  22364. });
  22365. instance.afterInit(function () {
  22366. instance.setLocale(_this3.$locale);
  22367. });
  22368. } // TODO: 待校验是否需要跳过禁用的自定义 hook
  22369. // Skip Disabled Internal Hooks
  22370. if (syntax[hookName] === false && !isRegisteredCustomSyntaxClass(HookClass)) {
  22371. return;
  22372. } // 下面处理的都是 CustomSyntax
  22373. var hookType = instance.getType();
  22374. if (this.hookNameList[hookName]) {
  22375. var _context4;
  22376. // 内置 hook 重名
  22377. if (!isRegisteredCustomSyntaxClass(HookClass)) {
  22378. return WARN_DUPLICATED;
  22379. } // 自定义 hook 重名且没有开启覆盖的选项
  22380. if (!customHookConfig.force) {
  22381. return WARN_DUPLICATED;
  22382. } // 强制覆盖以前的Hook,所以需要移除
  22383. var duplicateHookType = this.hookNameList[hookName].type;
  22384. this.hookList[duplicateHookType] = filter$3(_context4 = this.hookList[duplicateHookType]).call(_context4, function (hook) {
  22385. return hook.getName() !== hookName;
  22386. });
  22387. }
  22388. this.hookNameList[hookName] = {
  22389. type: hookType
  22390. };
  22391. this.hookList[hookType] = this.hookList[hookType] || []; // 内置Hook直接push到结尾
  22392. if (!isRegisteredCustomSyntaxClass(HookClass)) {
  22393. this.hookList[hookType].push(instance);
  22394. return;
  22395. } // 插入自定义Hook
  22396. var insertIndex = -1;
  22397. if (customHookConfig.before) {
  22398. var _context5;
  22399. insertIndex = findIndex$3(_context5 = this.hookList[hookType]).call(_context5, function (hook) {
  22400. return hook.getName() === customHookConfig.before;
  22401. });
  22402. if (insertIndex === -1) {
  22403. var _context6;
  22404. Logger.warn(concat$5(_context6 = "Cannot find hook named [".concat(customHookConfig.before, "],\n custom hook [")).call(_context6, hookName, "] will append to the end of the hooks."));
  22405. }
  22406. } else if (customHookConfig.after) {
  22407. var _context7, _context8;
  22408. insertIndex = findIndex$3(_context7 = this.hookList[hookType]).call(_context7, function (hook) {
  22409. return hook.getName() === customHookConfig.after;
  22410. });
  22411. insertIndex === -1 ? Logger.warn(concat$5(_context8 = "Cannot find hook named [".concat(customHookConfig.after, "],\n custom hook [")).call(_context8, hookName, "] will append to the end of the hooks.")) : insertIndex += 1; // 统一处理往前插入的逻辑,所以要插入某Hook之后,索引需要加一
  22412. } // 无需插入或目标索引为数组结尾
  22413. if (insertIndex < 0 || insertIndex >= this.hookList[hookType].length) {
  22414. this.hookList[hookType].push(instance);
  22415. } else {
  22416. var _context9;
  22417. splice$4(_context9 = this.hookList[hookType]).call(_context9, insertIndex, 0, instance);
  22418. } // console.log(this.hookList[hookType]);
  22419. }
  22420. }]);
  22421. return HookCenter;
  22422. }();
  22423. var arrayWithoutHoles = createCommonjsModule(function (module) {
  22424. function _arrayWithoutHoles(arr) {
  22425. if (isArray$7(arr)) return arrayLikeToArray(arr);
  22426. }
  22427. module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22428. });
  22429. unwrapExports(arrayWithoutHoles);
  22430. var iterableToArray = createCommonjsModule(function (module) {
  22431. function _iterableToArray(iter) {
  22432. if (typeof symbol$5 !== "undefined" && getIteratorMethod$5(iter) != null || iter["@@iterator"] != null) return from_1$6(iter);
  22433. }
  22434. module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22435. });
  22436. unwrapExports(iterableToArray);
  22437. var nonIterableSpread = createCommonjsModule(function (module) {
  22438. function _nonIterableSpread() {
  22439. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  22440. }
  22441. module.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22442. });
  22443. unwrapExports(nonIterableSpread);
  22444. var toConsumableArray = createCommonjsModule(function (module) {
  22445. function _toConsumableArray(arr) {
  22446. return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();
  22447. }
  22448. module.exports = _toConsumableArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22449. });
  22450. var _toConsumableArray = unwrapExports(toConsumableArray);
  22451. var toArray = createCommonjsModule(function (module) {
  22452. function _toArray(arr) {
  22453. return arrayWithHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableRest();
  22454. }
  22455. module.exports = _toArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
  22456. });
  22457. var _toArray = unwrapExports(toArray);
  22458. function ownKeys$2(object, enumerableOnly) { var keys = keys$3(object); if (getOwnPropertySymbols$2) { var symbols = getOwnPropertySymbols$2(object); enumerableOnly && (symbols = filter$3(symbols).call(symbols, function (sym) { return getOwnPropertyDescriptor$3(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  22459. function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? forEach$3(_context2 = ownKeys$2(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : getOwnPropertyDescriptors$2 ? defineProperties$2(target, getOwnPropertyDescriptors$2(source)) : forEach$3(_context3 = ownKeys$2(Object(source))).call(_context3, function (key) { defineProperty$5(target, key, getOwnPropertyDescriptor$3(source, key)); }); } return target; }
  22460. /**
  22461. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  22462. *
  22463. * Licensed under the Apache License, Version 2.0 (the "License");
  22464. * you may not use this file except in compliance with the License.
  22465. * You may obtain a copy of the License at
  22466. *
  22467. * http://www.apache.org/licenses/LICENSE-2.0
  22468. *
  22469. * Unless required by applicable law or agreed to in writing, software
  22470. * distributed under the License is distributed on an "AS IS" BASIS,
  22471. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22472. * See the License for the specific language governing permissions and
  22473. * limitations under the License.
  22474. */
  22475. /**
  22476. *
  22477. * @param {string} str
  22478. * @param {{replacedText:string;begin:number;length:number;}[]} buffer
  22479. */
  22480. function replaceStringByBuffer(str, buffer) {
  22481. if (!buffer.length) {
  22482. return str;
  22483. }
  22484. var slicedString = [];
  22485. var offset = 0;
  22486. forEach$3(buffer).call(buffer, function (buf, index) {
  22487. slicedString.push(slice$7(str).call(str, offset, buf.begin));
  22488. slicedString.push(buf.replacedText);
  22489. offset = buf.begin + buf.length;
  22490. if (index === buffer.length - 1) {
  22491. slicedString.push(slice$7(str).call(str, offset));
  22492. }
  22493. }); // console.log(slicedString, slicedString.join(''));
  22494. return slicedString.join('');
  22495. }
  22496. /**
  22497. * @param {string} str 原始字符串
  22498. * @param {RegExp} regex 正则
  22499. * @param {(...args: any[])=>string} replacer 字符串替换函数
  22500. * @param {boolean} [continuousMatch=false] 是否连续匹配,主要用于需要后向断言的连续语法匹配
  22501. * @param {number} [rollbackLength=1] 连续匹配时,每次指针回退的长度,默认为 1
  22502. */
  22503. function replaceLookbehind(str, regex, replacer) {
  22504. var continuousMatch = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  22505. var rollbackLength = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
  22506. if (!regex) {
  22507. return str;
  22508. } // 从头开始匹配
  22509. regex.lastIndex = 0;
  22510. var args;
  22511. var lastIndex = 0;
  22512. var replaceBuffer = [];
  22513. while ((args = regex.exec(str)) !== null) {
  22514. var replaceInfo = {
  22515. begin: args.index,
  22516. length: args[0].length
  22517. };
  22518. if (continuousMatch && args.index === lastIndex - rollbackLength) {
  22519. var _context;
  22520. var _args = args,
  22521. _args2 = _toArray(_args),
  22522. match = _args2[0],
  22523. restArgs = slice$7(_args2).call(_args2, 2); // 丢弃 leadingChar,需要调整begin和length
  22524. replaceBuffer.push({
  22525. begin: replaceInfo.begin + rollbackLength,
  22526. length: replaceInfo.length - rollbackLength,
  22527. replacedText: replacer.apply(void 0, concat$5(_context = [slice$7(match).call(match, rollbackLength), '']).call(_context, _toConsumableArray(restArgs)))
  22528. });
  22529. } else {
  22530. replaceBuffer.push(_objectSpread$1(_objectSpread$1({}, replaceInfo), {}, {
  22531. replacedText: replacer.apply(void 0, _toConsumableArray(args))
  22532. }));
  22533. } // console.log(args);
  22534. lastIndex = regex.lastIndex;
  22535. regex.lastIndex -= rollbackLength;
  22536. } // 正则复位,避免影响其他逻辑
  22537. regex.lastIndex = 0;
  22538. return replaceStringByBuffer(str, replaceBuffer);
  22539. }
  22540. function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  22541. function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  22542. var Color = /*#__PURE__*/function (_SyntaxBase) {
  22543. _inherits(Color, _SyntaxBase);
  22544. var _super = _createSuper$2(Color);
  22545. function Color() {
  22546. _classCallCheck(this, Color);
  22547. return _super.apply(this, arguments);
  22548. }
  22549. _createClass(Color, [{
  22550. key: "toHtml",
  22551. value: // constructor() {
  22552. // super();
  22553. // }
  22554. function toHtml(whole, leadingChar, m1, m2) {
  22555. var _context, _context2;
  22556. return concat$5(_context = concat$5(_context2 = "".concat(leadingChar, "<span style=\"color:")).call(_context2, m1, "\">")).call(_context, m2, "</span>");
  22557. }
  22558. }, {
  22559. key: "makeHtml",
  22560. value: function makeHtml(str) {
  22561. if (isLookbehindSupported()) {
  22562. return str.replace(this.RULE.reg, this.toHtml);
  22563. }
  22564. return replaceLookbehind(str, this.RULE.reg, this.toHtml, true, 1);
  22565. }
  22566. }, {
  22567. key: "rule",
  22568. value: function rule() {
  22569. var ret = {
  22570. begin: isLookbehindSupported() ? '((?<!\\\\))!!' : '(^|[^\\\\])!!',
  22571. end: '!!',
  22572. content: '(#[0-9a-zA-Z]{3,6}|[a-z]{3,20})[\\s]([\\w\\W]+?)'
  22573. };
  22574. ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
  22575. return ret;
  22576. }
  22577. }]);
  22578. return Color;
  22579. }(SyntaxBase);
  22580. _defineProperty(Color, "HOOK_NAME", 'fontColor');
  22581. function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  22582. function _isNativeReflectConstruct$3() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  22583. var BackgroundColor = /*#__PURE__*/function (_SyntaxBase) {
  22584. _inherits(BackgroundColor, _SyntaxBase);
  22585. var _super = _createSuper$3(BackgroundColor);
  22586. function BackgroundColor() {
  22587. _classCallCheck(this, BackgroundColor);
  22588. return _super.apply(this, arguments);
  22589. }
  22590. _createClass(BackgroundColor, [{
  22591. key: "toHtml",
  22592. value: // constructor() {
  22593. // super();
  22594. // }
  22595. function toHtml(whole, leadingChar, m1, m2) {
  22596. var _context, _context2;
  22597. return concat$5(_context = concat$5(_context2 = "".concat(leadingChar, "<span style=\"background-color:")).call(_context2, m1, "\">")).call(_context, m2, "</span>");
  22598. }
  22599. }, {
  22600. key: "makeHtml",
  22601. value: function makeHtml(str) {
  22602. if (isLookbehindSupported()) {
  22603. return str.replace(this.RULE.reg, this.toHtml);
  22604. }
  22605. return replaceLookbehind(str, this.RULE.reg, this.toHtml, true, 1);
  22606. }
  22607. }, {
  22608. key: "rule",
  22609. value: function rule() {
  22610. var ret = {
  22611. begin: isLookbehindSupported() ? '((?<!\\\\))!!!' : '(^|[^\\\\])!!!',
  22612. end: '!!!',
  22613. content: '(#[0-9a-zA-Z]{3,6}|[a-z]{3,10})[\\s]([\\w\\W]+?)'
  22614. };
  22615. ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
  22616. return ret;
  22617. }
  22618. }]);
  22619. return BackgroundColor;
  22620. }(SyntaxBase);
  22621. _defineProperty(BackgroundColor, "HOOK_NAME", 'bgColor');
  22622. function _createSuper$4(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$4(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  22623. function _isNativeReflectConstruct$4() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  22624. var Size = /*#__PURE__*/function (_SyntaxBase) {
  22625. _inherits(Size, _SyntaxBase);
  22626. var _super = _createSuper$4(Size);
  22627. function Size() {
  22628. _classCallCheck(this, Size);
  22629. return _super.apply(this, arguments);
  22630. }
  22631. _createClass(Size, [{
  22632. key: "toHtml",
  22633. value: // constructor() {
  22634. // super();
  22635. // }
  22636. function toHtml(whole, m1, m2, m3) {
  22637. var _context, _context2;
  22638. return concat$5(_context = concat$5(_context2 = "".concat(m1, "<span style=\"font-size:")).call(_context2, m2, "px;line-height:1em;\">")).call(_context, m3, "</span>");
  22639. }
  22640. }, {
  22641. key: "makeHtml",
  22642. value: function makeHtml(str) {
  22643. if (!this.test(str)) {
  22644. return str;
  22645. }
  22646. if (isLookbehindSupported()) {
  22647. return str.replace(this.RULE.reg, this.toHtml);
  22648. }
  22649. return replaceLookbehind(str, this.RULE.reg, this.toHtml, true, 1);
  22650. }
  22651. }, {
  22652. key: "rule",
  22653. value: function rule() {
  22654. var ret = {
  22655. begin: isLookbehindSupported() ? '((?<!\\\\))!' : '(^|[^\\\\])!',
  22656. end: '!',
  22657. content: '([0-9]{1,2})[\\s]([\\w\\W]*?)'
  22658. };
  22659. ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
  22660. return ret;
  22661. }
  22662. }]);
  22663. return Size;
  22664. }(SyntaxBase);
  22665. _defineProperty(Size, "HOOK_NAME", 'fontSize');
  22666. function _createSuper$5(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$5(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  22667. function _isNativeReflectConstruct$5() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  22668. /**
  22669. * 删除线语法
  22670. */
  22671. var Strikethrough = /*#__PURE__*/function (_SyntaxBase) {
  22672. _inherits(Strikethrough, _SyntaxBase);
  22673. var _super = _createSuper$5(Strikethrough);
  22674. function Strikethrough() {
  22675. var _this;
  22676. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  22677. config: undefined
  22678. },
  22679. config = _ref.config;
  22680. _classCallCheck(this, Strikethrough);
  22681. _this = _super.call(this, {
  22682. config: config
  22683. });
  22684. if (!config) {
  22685. return _possibleConstructorReturn(_this);
  22686. }
  22687. _this.needWhitespace = !!config.needWhitespace;
  22688. return _this;
  22689. }
  22690. /**
  22691. * 主要逻辑
  22692. * @param {string} str markdown源码
  22693. * @returns {string} html内容
  22694. */
  22695. _createClass(Strikethrough, [{
  22696. key: "makeHtml",
  22697. value: function makeHtml(str) {
  22698. if (!this.test(str)) {
  22699. return str;
  22700. }
  22701. return str.replace(this.RULE.reg, '$1<del>$2</del>');
  22702. }
  22703. }, {
  22704. key: "rule",
  22705. value: function rule() {
  22706. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  22707. config: undefined
  22708. },
  22709. config = _ref2.config;
  22710. /** @type {Partial<import('~types/syntax').BasicHookRegexpRule>} */
  22711. var ret = {};
  22712. if (!!config.needWhitespace) {
  22713. ret = {
  22714. begin: '(^|[\\s])\\~T\\~T',
  22715. end: '\\~T\\~T(?=\\s|$)',
  22716. content: '([\\w\\W]+?)'
  22717. };
  22718. } else {
  22719. ret = {
  22720. begin: '(^|[^\\\\])\\~T\\~T',
  22721. end: '\\~T\\~T',
  22722. content: '([\\w\\W]+?)'
  22723. };
  22724. }
  22725. ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
  22726. return ret;
  22727. }
  22728. }]);
  22729. return Strikethrough;
  22730. }(SyntaxBase);
  22731. _defineProperty(Strikethrough, "HOOK_NAME", 'strikethrough');
  22732. function _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$6(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  22733. function _isNativeReflectConstruct$6() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  22734. var Sup = /*#__PURE__*/function (_SyntaxBase) {
  22735. _inherits(Sup, _SyntaxBase);
  22736. var _super = _createSuper$6(Sup);
  22737. function Sup() {
  22738. _classCallCheck(this, Sup);
  22739. return _super.apply(this, arguments);
  22740. }
  22741. _createClass(Sup, [{
  22742. key: "toHtml",
  22743. value: // constructor() {
  22744. // super();
  22745. // }
  22746. function toHtml(whole, leadingChar, m1) {
  22747. var _context;
  22748. return concat$5(_context = "".concat(leadingChar, "<sup>")).call(_context, m1, "</sup>");
  22749. }
  22750. }, {
  22751. key: "makeHtml",
  22752. value: function makeHtml(str) {
  22753. if (isLookbehindSupported()) {
  22754. return str.replace(this.RULE.reg, this.toHtml);
  22755. }
  22756. return replaceLookbehind(str, this.RULE.reg, this.toHtml, true, 1);
  22757. }
  22758. }, {
  22759. key: "rule",
  22760. value: function rule() {
  22761. var ret = {
  22762. begin: isLookbehindSupported() ? '((?<!\\\\))\\^' : '(^|[^\\\\])\\^',
  22763. end: '\\^',
  22764. content: '([\\w\\W]+?)'
  22765. };
  22766. ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
  22767. return ret;
  22768. }
  22769. }]);
  22770. return Sup;
  22771. }(SyntaxBase);
  22772. _defineProperty(Sup, "HOOK_NAME", 'sup');
  22773. function _createSuper$7(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$7(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  22774. function _isNativeReflectConstruct$7() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  22775. var Sub = /*#__PURE__*/function (_SyntaxBase) {
  22776. _inherits(Sub, _SyntaxBase);
  22777. var _super = _createSuper$7(Sub);
  22778. function Sub() {
  22779. _classCallCheck(this, Sub);
  22780. return _super.apply(this, arguments);
  22781. }
  22782. _createClass(Sub, [{
  22783. key: "toHtml",
  22784. value: // constructor() {
  22785. // super();
  22786. // }
  22787. function toHtml(whole, leadingChar, m1) {
  22788. var _context;
  22789. return concat$5(_context = "".concat(leadingChar, "<sub>")).call(_context, m1, "</sub>");
  22790. }
  22791. }, {
  22792. key: "makeHtml",
  22793. value: function makeHtml(str) {
  22794. if (isLookbehindSupported()) {
  22795. return str.replace(this.RULE.reg, this.toHtml);
  22796. }
  22797. return replaceLookbehind(str, this.RULE.reg, this.toHtml, true, 1);
  22798. }
  22799. }, {
  22800. key: "rule",
  22801. value: function rule() {
  22802. var ret = {
  22803. begin: isLookbehindSupported() ? '((?<!\\\\))\\^\\^' : '(^|[^\\\\])\\^\\^',
  22804. end: '\\^\\^',
  22805. content: '([\\w\\W]+?)'
  22806. };
  22807. ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
  22808. return ret;
  22809. }
  22810. }]);
  22811. return Sub;
  22812. }(SyntaxBase);
  22813. _defineProperty(Sub, "HOOK_NAME", 'sub');
  22814. var prismCore = createCommonjsModule(function (module) {
  22815. /// <reference lib="WebWorker"/>
  22816. var _self = (typeof window !== 'undefined')
  22817. ? window // if in browser
  22818. : (
  22819. (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
  22820. ? self // if in worker
  22821. : {} // if in node js
  22822. );
  22823. /**
  22824. * Prism: Lightweight, robust, elegant syntax highlighting
  22825. *
  22826. * @license MIT <https://opensource.org/licenses/MIT>
  22827. * @author Lea Verou <https://lea.verou.me>
  22828. * @namespace
  22829. * @public
  22830. */
  22831. var Prism = (function (_self) {
  22832. // Private helper vars
  22833. var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
  22834. var uniqueId = 0;
  22835. // The grammar object for plaintext
  22836. var plainTextGrammar = {};
  22837. var _ = {
  22838. /**
  22839. * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
  22840. * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
  22841. * additional languages or plugins yourself.
  22842. *
  22843. * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
  22844. *
  22845. * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
  22846. * empty Prism object into the global scope before loading the Prism script like this:
  22847. *
  22848. * ```js
  22849. * window.Prism = window.Prism || {};
  22850. * Prism.manual = true;
  22851. * // add a new <script> to load Prism's script
  22852. * ```
  22853. *
  22854. * @default false
  22855. * @type {boolean}
  22856. * @memberof Prism
  22857. * @public
  22858. */
  22859. manual: _self.Prism && _self.Prism.manual,
  22860. /**
  22861. * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
  22862. * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
  22863. * own worker, you don't want it to do this.
  22864. *
  22865. * By setting this value to `true`, Prism will not add its own listeners to the worker.
  22866. *
  22867. * You obviously have to change this value before Prism executes. To do this, you can add an
  22868. * empty Prism object into the global scope before loading the Prism script like this:
  22869. *
  22870. * ```js
  22871. * window.Prism = window.Prism || {};
  22872. * Prism.disableWorkerMessageHandler = true;
  22873. * // Load Prism's script
  22874. * ```
  22875. *
  22876. * @default false
  22877. * @type {boolean}
  22878. * @memberof Prism
  22879. * @public
  22880. */
  22881. disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
  22882. /**
  22883. * A namespace for utility methods.
  22884. *
  22885. * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
  22886. * change or disappear at any time.
  22887. *
  22888. * @namespace
  22889. * @memberof Prism
  22890. */
  22891. util: {
  22892. encode: function encode(tokens) {
  22893. if (tokens instanceof Token) {
  22894. return new Token(tokens.type, encode(tokens.content), tokens.alias);
  22895. } else if (Array.isArray(tokens)) {
  22896. return tokens.map(encode);
  22897. } else {
  22898. return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
  22899. }
  22900. },
  22901. /**
  22902. * Returns the name of the type of the given value.
  22903. *
  22904. * @param {any} o
  22905. * @returns {string}
  22906. * @example
  22907. * type(null) === 'Null'
  22908. * type(undefined) === 'Undefined'
  22909. * type(123) === 'Number'
  22910. * type('foo') === 'String'
  22911. * type(true) === 'Boolean'
  22912. * type([1, 2]) === 'Array'
  22913. * type({}) === 'Object'
  22914. * type(String) === 'Function'
  22915. * type(/abc+/) === 'RegExp'
  22916. */
  22917. type: function (o) {
  22918. return Object.prototype.toString.call(o).slice(8, -1);
  22919. },
  22920. /**
  22921. * Returns a unique number for the given object. Later calls will still return the same number.
  22922. *
  22923. * @param {Object} obj
  22924. * @returns {number}
  22925. */
  22926. objId: function (obj) {
  22927. if (!obj['__id']) {
  22928. Object.defineProperty(obj, '__id', { value: ++uniqueId });
  22929. }
  22930. return obj['__id'];
  22931. },
  22932. /**
  22933. * Creates a deep clone of the given object.
  22934. *
  22935. * The main intended use of this function is to clone language definitions.
  22936. *
  22937. * @param {T} o
  22938. * @param {Record<number, any>} [visited]
  22939. * @returns {T}
  22940. * @template T
  22941. */
  22942. clone: function deepClone(o, visited) {
  22943. visited = visited || {};
  22944. var clone; var id;
  22945. switch (_.util.type(o)) {
  22946. case 'Object':
  22947. id = _.util.objId(o);
  22948. if (visited[id]) {
  22949. return visited[id];
  22950. }
  22951. clone = /** @type {Record<string, any>} */ ({});
  22952. visited[id] = clone;
  22953. for (var key in o) {
  22954. if (o.hasOwnProperty(key)) {
  22955. clone[key] = deepClone(o[key], visited);
  22956. }
  22957. }
  22958. return /** @type {any} */ (clone);
  22959. case 'Array':
  22960. id = _.util.objId(o);
  22961. if (visited[id]) {
  22962. return visited[id];
  22963. }
  22964. clone = [];
  22965. visited[id] = clone;
  22966. (/** @type {Array} */(/** @type {any} */(o))).forEach(function (v, i) {
  22967. clone[i] = deepClone(v, visited);
  22968. });
  22969. return /** @type {any} */ (clone);
  22970. default:
  22971. return o;
  22972. }
  22973. },
  22974. /**
  22975. * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
  22976. *
  22977. * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
  22978. *
  22979. * @param {Element} element
  22980. * @returns {string}
  22981. */
  22982. getLanguage: function (element) {
  22983. while (element) {
  22984. var m = lang.exec(element.className);
  22985. if (m) {
  22986. return m[1].toLowerCase();
  22987. }
  22988. element = element.parentElement;
  22989. }
  22990. return 'none';
  22991. },
  22992. /**
  22993. * Sets the Prism `language-xxxx` class of the given element.
  22994. *
  22995. * @param {Element} element
  22996. * @param {string} language
  22997. * @returns {void}
  22998. */
  22999. setLanguage: function (element, language) {
  23000. // remove all `language-xxxx` classes
  23001. // (this might leave behind a leading space)
  23002. element.className = element.className.replace(RegExp(lang, 'gi'), '');
  23003. // add the new `language-xxxx` class
  23004. // (using `classList` will automatically clean up spaces for us)
  23005. element.classList.add('language-' + language);
  23006. },
  23007. /**
  23008. * Returns the script element that is currently executing.
  23009. *
  23010. * This does __not__ work for line script element.
  23011. *
  23012. * @returns {HTMLScriptElement | null}
  23013. */
  23014. currentScript: function () {
  23015. if (typeof document === 'undefined') {
  23016. return null;
  23017. }
  23018. if ('currentScript' in document && 1 < 2 /* hack to trip TS' flow analysis */) {
  23019. return /** @type {any} */ (document.currentScript);
  23020. }
  23021. // IE11 workaround
  23022. // we'll get the src of the current script by parsing IE11's error stack trace
  23023. // this will not work for inline scripts
  23024. try {
  23025. throw new Error();
  23026. } catch (err) {
  23027. // Get file src url from stack. Specifically works with the format of stack traces in IE.
  23028. // A stack will look like this:
  23029. //
  23030. // Error
  23031. // at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
  23032. // at Global code (http://localhost/components/prism-core.js:606:1)
  23033. var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
  23034. if (src) {
  23035. var scripts = document.getElementsByTagName('script');
  23036. for (var i in scripts) {
  23037. if (scripts[i].src == src) {
  23038. return scripts[i];
  23039. }
  23040. }
  23041. }
  23042. return null;
  23043. }
  23044. },
  23045. /**
  23046. * Returns whether a given class is active for `element`.
  23047. *
  23048. * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
  23049. * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
  23050. * given class is just the given class with a `no-` prefix.
  23051. *
  23052. * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
  23053. * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
  23054. * ancestors have the given class or the negated version of it, then the default activation will be returned.
  23055. *
  23056. * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
  23057. * version of it, the class is considered active.
  23058. *
  23059. * @param {Element} element
  23060. * @param {string} className
  23061. * @param {boolean} [defaultActivation=false]
  23062. * @returns {boolean}
  23063. */
  23064. isActive: function (element, className, defaultActivation) {
  23065. var no = 'no-' + className;
  23066. while (element) {
  23067. var classList = element.classList;
  23068. if (classList.contains(className)) {
  23069. return true;
  23070. }
  23071. if (classList.contains(no)) {
  23072. return false;
  23073. }
  23074. element = element.parentElement;
  23075. }
  23076. return !!defaultActivation;
  23077. }
  23078. },
  23079. /**
  23080. * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
  23081. *
  23082. * @namespace
  23083. * @memberof Prism
  23084. * @public
  23085. */
  23086. languages: {
  23087. /**
  23088. * The grammar for plain, unformatted text.
  23089. */
  23090. plain: plainTextGrammar,
  23091. plaintext: plainTextGrammar,
  23092. text: plainTextGrammar,
  23093. txt: plainTextGrammar,
  23094. /**
  23095. * Creates a deep copy of the language with the given id and appends the given tokens.
  23096. *
  23097. * If a token in `redef` also appears in the copied language, then the existing token in the copied language
  23098. * will be overwritten at its original position.
  23099. *
  23100. * ## Best practices
  23101. *
  23102. * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
  23103. * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
  23104. * understand the language definition because, normally, the order of tokens matters in Prism grammars.
  23105. *
  23106. * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
  23107. * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
  23108. *
  23109. * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
  23110. * @param {Grammar} redef The new tokens to append.
  23111. * @returns {Grammar} The new language created.
  23112. * @public
  23113. * @example
  23114. * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
  23115. * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
  23116. * // at its original position
  23117. * 'comment': { ... },
  23118. * // CSS doesn't have a 'color' token, so this token will be appended
  23119. * 'color': /\b(?:red|green|blue)\b/
  23120. * });
  23121. */
  23122. extend: function (id, redef) {
  23123. var lang = _.util.clone(_.languages[id]);
  23124. for (var key in redef) {
  23125. lang[key] = redef[key];
  23126. }
  23127. return lang;
  23128. },
  23129. /**
  23130. * Inserts tokens _before_ another token in a language definition or any other grammar.
  23131. *
  23132. * ## Usage
  23133. *
  23134. * This helper method makes it easy to modify existing languages. For example, the CSS language definition
  23135. * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
  23136. * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
  23137. * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
  23138. * this:
  23139. *
  23140. * ```js
  23141. * Prism.languages.markup.style = {
  23142. * // token
  23143. * };
  23144. * ```
  23145. *
  23146. * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
  23147. * before existing tokens. For the CSS example above, you would use it like this:
  23148. *
  23149. * ```js
  23150. * Prism.languages.insertBefore('markup', 'cdata', {
  23151. * 'style': {
  23152. * // token
  23153. * }
  23154. * });
  23155. * ```
  23156. *
  23157. * ## Special cases
  23158. *
  23159. * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
  23160. * will be ignored.
  23161. *
  23162. * This behavior can be used to insert tokens after `before`:
  23163. *
  23164. * ```js
  23165. * Prism.languages.insertBefore('markup', 'comment', {
  23166. * 'comment': Prism.languages.markup.comment,
  23167. * // tokens after 'comment'
  23168. * });
  23169. * ```
  23170. *
  23171. * ## Limitations
  23172. *
  23173. * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
  23174. * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
  23175. * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
  23176. * deleting properties which is necessary to insert at arbitrary positions.
  23177. *
  23178. * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
  23179. * Instead, it will create a new object and replace all references to the target object with the new one. This
  23180. * can be done without temporarily deleting properties, so the iteration order is well-defined.
  23181. *
  23182. * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
  23183. * you hold the target object in a variable, then the value of the variable will not change.
  23184. *
  23185. * ```js
  23186. * var oldMarkup = Prism.languages.markup;
  23187. * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
  23188. *
  23189. * assert(oldMarkup !== Prism.languages.markup);
  23190. * assert(newMarkup === Prism.languages.markup);
  23191. * ```
  23192. *
  23193. * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
  23194. * object to be modified.
  23195. * @param {string} before The key to insert before.
  23196. * @param {Grammar} insert An object containing the key-value pairs to be inserted.
  23197. * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
  23198. * object to be modified.
  23199. *
  23200. * Defaults to `Prism.languages`.
  23201. * @returns {Grammar} The new grammar object.
  23202. * @public
  23203. */
  23204. insertBefore: function (inside, before, insert, root) {
  23205. root = root || /** @type {any} */ (_.languages);
  23206. var grammar = root[inside];
  23207. /** @type {Grammar} */
  23208. var ret = {};
  23209. for (var token in grammar) {
  23210. if (grammar.hasOwnProperty(token)) {
  23211. if (token == before) {
  23212. for (var newToken in insert) {
  23213. if (insert.hasOwnProperty(newToken)) {
  23214. ret[newToken] = insert[newToken];
  23215. }
  23216. }
  23217. }
  23218. // Do not insert token which also occur in insert. See #1525
  23219. if (!insert.hasOwnProperty(token)) {
  23220. ret[token] = grammar[token];
  23221. }
  23222. }
  23223. }
  23224. var old = root[inside];
  23225. root[inside] = ret;
  23226. // Update references in other language definitions
  23227. _.languages.DFS(_.languages, function (key, value) {
  23228. if (value === old && key != inside) {
  23229. this[key] = ret;
  23230. }
  23231. });
  23232. return ret;
  23233. },
  23234. // Traverse a language definition with Depth First Search
  23235. DFS: function DFS(o, callback, type, visited) {
  23236. visited = visited || {};
  23237. var objId = _.util.objId;
  23238. for (var i in o) {
  23239. if (o.hasOwnProperty(i)) {
  23240. callback.call(o, i, o[i], type || i);
  23241. var property = o[i];
  23242. var propertyType = _.util.type(property);
  23243. if (propertyType === 'Object' && !visited[objId(property)]) {
  23244. visited[objId(property)] = true;
  23245. DFS(property, callback, null, visited);
  23246. } else if (propertyType === 'Array' && !visited[objId(property)]) {
  23247. visited[objId(property)] = true;
  23248. DFS(property, callback, i, visited);
  23249. }
  23250. }
  23251. }
  23252. }
  23253. },
  23254. plugins: {},
  23255. /**
  23256. * This is the most high-level function in Prism’s API.
  23257. * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
  23258. * each one of them.
  23259. *
  23260. * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
  23261. *
  23262. * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
  23263. * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
  23264. * @memberof Prism
  23265. * @public
  23266. */
  23267. highlightAll: function (async, callback) {
  23268. _.highlightAllUnder(document, async, callback);
  23269. },
  23270. /**
  23271. * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
  23272. * {@link Prism.highlightElement} on each one of them.
  23273. *
  23274. * The following hooks will be run:
  23275. * 1. `before-highlightall`
  23276. * 2. `before-all-elements-highlight`
  23277. * 3. All hooks of {@link Prism.highlightElement} for each element.
  23278. *
  23279. * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
  23280. * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
  23281. * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
  23282. * @memberof Prism
  23283. * @public
  23284. */
  23285. highlightAllUnder: function (container, async, callback) {
  23286. var env = {
  23287. callback: callback,
  23288. container: container,
  23289. selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
  23290. };
  23291. _.hooks.run('before-highlightall', env);
  23292. env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
  23293. _.hooks.run('before-all-elements-highlight', env);
  23294. for (var i = 0, element; (element = env.elements[i++]);) {
  23295. _.highlightElement(element, async === true, env.callback);
  23296. }
  23297. },
  23298. /**
  23299. * Highlights the code inside a single element.
  23300. *
  23301. * The following hooks will be run:
  23302. * 1. `before-sanity-check`
  23303. * 2. `before-highlight`
  23304. * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
  23305. * 4. `before-insert`
  23306. * 5. `after-highlight`
  23307. * 6. `complete`
  23308. *
  23309. * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
  23310. * the element's language.
  23311. *
  23312. * @param {Element} element The element containing the code.
  23313. * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
  23314. * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
  23315. * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
  23316. * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
  23317. *
  23318. * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
  23319. * asynchronous highlighting to work. You can build your own bundle on the
  23320. * [Download page](https://prismjs.com/download.html).
  23321. * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
  23322. * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
  23323. * @memberof Prism
  23324. * @public
  23325. */
  23326. highlightElement: function (element, async, callback) {
  23327. // Find language
  23328. var language = _.util.getLanguage(element);
  23329. var grammar = _.languages[language];
  23330. // Set language on the element, if not present
  23331. _.util.setLanguage(element, language);
  23332. // Set language on the parent, for styling
  23333. var parent = element.parentElement;
  23334. if (parent && parent.nodeName.toLowerCase() === 'pre') {
  23335. _.util.setLanguage(parent, language);
  23336. }
  23337. var code = element.textContent;
  23338. var env = {
  23339. element: element,
  23340. language: language,
  23341. grammar: grammar,
  23342. code: code
  23343. };
  23344. function insertHighlightedCode(highlightedCode) {
  23345. env.highlightedCode = highlightedCode;
  23346. _.hooks.run('before-insert', env);
  23347. env.element.innerHTML = env.highlightedCode;
  23348. _.hooks.run('after-highlight', env);
  23349. _.hooks.run('complete', env);
  23350. callback && callback.call(env.element);
  23351. }
  23352. _.hooks.run('before-sanity-check', env);
  23353. // plugins may change/add the parent/element
  23354. parent = env.element.parentElement;
  23355. if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) {
  23356. parent.setAttribute('tabindex', '0');
  23357. }
  23358. if (!env.code) {
  23359. _.hooks.run('complete', env);
  23360. callback && callback.call(env.element);
  23361. return;
  23362. }
  23363. _.hooks.run('before-highlight', env);
  23364. if (!env.grammar) {
  23365. insertHighlightedCode(_.util.encode(env.code));
  23366. return;
  23367. }
  23368. if (async && _self.Worker) {
  23369. var worker = new Worker(_.filename);
  23370. worker.onmessage = function (evt) {
  23371. insertHighlightedCode(evt.data);
  23372. };
  23373. worker.postMessage(JSON.stringify({
  23374. language: env.language,
  23375. code: env.code,
  23376. immediateClose: true
  23377. }));
  23378. } else {
  23379. insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
  23380. }
  23381. },
  23382. /**
  23383. * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
  23384. * and the language definitions to use, and returns a string with the HTML produced.
  23385. *
  23386. * The following hooks will be run:
  23387. * 1. `before-tokenize`
  23388. * 2. `after-tokenize`
  23389. * 3. `wrap`: On each {@link Token}.
  23390. *
  23391. * @param {string} text A string with the code to be highlighted.
  23392. * @param {Grammar} grammar An object containing the tokens to use.
  23393. *
  23394. * Usually a language definition like `Prism.languages.markup`.
  23395. * @param {string} language The name of the language definition passed to `grammar`.
  23396. * @returns {string} The highlighted HTML.
  23397. * @memberof Prism
  23398. * @public
  23399. * @example
  23400. * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
  23401. */
  23402. highlight: function (text, grammar, language) {
  23403. var env = {
  23404. code: text,
  23405. grammar: grammar,
  23406. language: language
  23407. };
  23408. _.hooks.run('before-tokenize', env);
  23409. if (!env.grammar) {
  23410. throw new Error('The language "' + env.language + '" has no grammar.');
  23411. }
  23412. env.tokens = _.tokenize(env.code, env.grammar);
  23413. _.hooks.run('after-tokenize', env);
  23414. return Token.stringify(_.util.encode(env.tokens), env.language);
  23415. },
  23416. /**
  23417. * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
  23418. * and the language definitions to use, and returns an array with the tokenized code.
  23419. *
  23420. * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
  23421. *
  23422. * This method could be useful in other contexts as well, as a very crude parser.
  23423. *
  23424. * @param {string} text A string with the code to be highlighted.
  23425. * @param {Grammar} grammar An object containing the tokens to use.
  23426. *
  23427. * Usually a language definition like `Prism.languages.markup`.
  23428. * @returns {TokenStream} An array of strings and tokens, a token stream.
  23429. * @memberof Prism
  23430. * @public
  23431. * @example
  23432. * let code = `var foo = 0;`;
  23433. * let tokens = Prism.tokenize(code, Prism.languages.javascript);
  23434. * tokens.forEach(token => {
  23435. * if (token instanceof Prism.Token && token.type === 'number') {
  23436. * console.log(`Found numeric literal: ${token.content}`);
  23437. * }
  23438. * });
  23439. */
  23440. tokenize: function (text, grammar) {
  23441. var rest = grammar.rest;
  23442. if (rest) {
  23443. for (var token in rest) {
  23444. grammar[token] = rest[token];
  23445. }
  23446. delete grammar.rest;
  23447. }
  23448. var tokenList = new LinkedList();
  23449. addAfter(tokenList, tokenList.head, text);
  23450. matchGrammar(text, tokenList, grammar, tokenList.head, 0);
  23451. return toArray(tokenList);
  23452. },
  23453. /**
  23454. * @namespace
  23455. * @memberof Prism
  23456. * @public
  23457. */
  23458. hooks: {
  23459. all: {},
  23460. /**
  23461. * Adds the given callback to the list of callbacks for the given hook.
  23462. *
  23463. * The callback will be invoked when the hook it is registered for is run.
  23464. * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
  23465. *
  23466. * One callback function can be registered to multiple hooks and the same hook multiple times.
  23467. *
  23468. * @param {string} name The name of the hook.
  23469. * @param {HookCallback} callback The callback function which is given environment variables.
  23470. * @public
  23471. */
  23472. add: function (name, callback) {
  23473. var hooks = _.hooks.all;
  23474. hooks[name] = hooks[name] || [];
  23475. hooks[name].push(callback);
  23476. },
  23477. /**
  23478. * Runs a hook invoking all registered callbacks with the given environment variables.
  23479. *
  23480. * Callbacks will be invoked synchronously and in the order in which they were registered.
  23481. *
  23482. * @param {string} name The name of the hook.
  23483. * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
  23484. * @public
  23485. */
  23486. run: function (name, env) {
  23487. var callbacks = _.hooks.all[name];
  23488. if (!callbacks || !callbacks.length) {
  23489. return;
  23490. }
  23491. for (var i = 0, callback; (callback = callbacks[i++]);) {
  23492. callback(env);
  23493. }
  23494. }
  23495. },
  23496. Token: Token
  23497. };
  23498. _self.Prism = _;
  23499. // Typescript note:
  23500. // The following can be used to import the Token type in JSDoc:
  23501. //
  23502. // @typedef {InstanceType<import("./prism-core")["Token"]>} Token
  23503. /**
  23504. * Creates a new token.
  23505. *
  23506. * @param {string} type See {@link Token#type type}
  23507. * @param {string | TokenStream} content See {@link Token#content content}
  23508. * @param {string|string[]} [alias] The alias(es) of the token.
  23509. * @param {string} [matchedStr=""] A copy of the full string this token was created from.
  23510. * @class
  23511. * @global
  23512. * @public
  23513. */
  23514. function Token(type, content, alias, matchedStr) {
  23515. /**
  23516. * The type of the token.
  23517. *
  23518. * This is usually the key of a pattern in a {@link Grammar}.
  23519. *
  23520. * @type {string}
  23521. * @see GrammarToken
  23522. * @public
  23523. */
  23524. this.type = type;
  23525. /**
  23526. * The strings or tokens contained by this token.
  23527. *
  23528. * This will be a token stream if the pattern matched also defined an `inside` grammar.
  23529. *
  23530. * @type {string | TokenStream}
  23531. * @public
  23532. */
  23533. this.content = content;
  23534. /**
  23535. * The alias(es) of the token.
  23536. *
  23537. * @type {string|string[]}
  23538. * @see GrammarToken
  23539. * @public
  23540. */
  23541. this.alias = alias;
  23542. // Copy of the full string this token was created from
  23543. this.length = (matchedStr || '').length | 0;
  23544. }
  23545. /**
  23546. * A token stream is an array of strings and {@link Token Token} objects.
  23547. *
  23548. * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
  23549. * them.
  23550. *
  23551. * 1. No adjacent strings.
  23552. * 2. No empty strings.
  23553. *
  23554. * The only exception here is the token stream that only contains the empty string and nothing else.
  23555. *
  23556. * @typedef {Array<string | Token>} TokenStream
  23557. * @global
  23558. * @public
  23559. */
  23560. /**
  23561. * Converts the given token or token stream to an HTML representation.
  23562. *
  23563. * The following hooks will be run:
  23564. * 1. `wrap`: On each {@link Token}.
  23565. *
  23566. * @param {string | Token | TokenStream} o The token or token stream to be converted.
  23567. * @param {string} language The name of current language.
  23568. * @returns {string} The HTML representation of the token or token stream.
  23569. * @memberof Token
  23570. * @static
  23571. */
  23572. Token.stringify = function stringify(o, language) {
  23573. if (typeof o == 'string') {
  23574. return o;
  23575. }
  23576. if (Array.isArray(o)) {
  23577. var s = '';
  23578. o.forEach(function (e) {
  23579. s += stringify(e, language);
  23580. });
  23581. return s;
  23582. }
  23583. var env = {
  23584. type: o.type,
  23585. content: stringify(o.content, language),
  23586. tag: 'span',
  23587. classes: ['token', o.type],
  23588. attributes: {},
  23589. language: language
  23590. };
  23591. var aliases = o.alias;
  23592. if (aliases) {
  23593. if (Array.isArray(aliases)) {
  23594. Array.prototype.push.apply(env.classes, aliases);
  23595. } else {
  23596. env.classes.push(aliases);
  23597. }
  23598. }
  23599. _.hooks.run('wrap', env);
  23600. var attributes = '';
  23601. for (var name in env.attributes) {
  23602. attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
  23603. }
  23604. return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
  23605. };
  23606. /**
  23607. * @param {RegExp} pattern
  23608. * @param {number} pos
  23609. * @param {string} text
  23610. * @param {boolean} lookbehind
  23611. * @returns {RegExpExecArray | null}
  23612. */
  23613. function matchPattern(pattern, pos, text, lookbehind) {
  23614. pattern.lastIndex = pos;
  23615. var match = pattern.exec(text);
  23616. if (match && lookbehind && match[1]) {
  23617. // change the match to remove the text matched by the Prism lookbehind group
  23618. var lookbehindLength = match[1].length;
  23619. match.index += lookbehindLength;
  23620. match[0] = match[0].slice(lookbehindLength);
  23621. }
  23622. return match;
  23623. }
  23624. /**
  23625. * @param {string} text
  23626. * @param {LinkedList<string | Token>} tokenList
  23627. * @param {any} grammar
  23628. * @param {LinkedListNode<string | Token>} startNode
  23629. * @param {number} startPos
  23630. * @param {RematchOptions} [rematch]
  23631. * @returns {void}
  23632. * @private
  23633. *
  23634. * @typedef RematchOptions
  23635. * @property {string} cause
  23636. * @property {number} reach
  23637. */
  23638. function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
  23639. for (var token in grammar) {
  23640. if (!grammar.hasOwnProperty(token) || !grammar[token]) {
  23641. continue;
  23642. }
  23643. var patterns = grammar[token];
  23644. patterns = Array.isArray(patterns) ? patterns : [patterns];
  23645. for (var j = 0; j < patterns.length; ++j) {
  23646. if (rematch && rematch.cause == token + ',' + j) {
  23647. return;
  23648. }
  23649. var patternObj = patterns[j];
  23650. var inside = patternObj.inside;
  23651. var lookbehind = !!patternObj.lookbehind;
  23652. var greedy = !!patternObj.greedy;
  23653. var alias = patternObj.alias;
  23654. if (greedy && !patternObj.pattern.global) {
  23655. // Without the global flag, lastIndex won't work
  23656. var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
  23657. patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
  23658. }
  23659. /** @type {RegExp} */
  23660. var pattern = patternObj.pattern || patternObj;
  23661. for ( // iterate the token list and keep track of the current token/string position
  23662. var currentNode = startNode.next, pos = startPos;
  23663. currentNode !== tokenList.tail;
  23664. pos += currentNode.value.length, currentNode = currentNode.next
  23665. ) {
  23666. if (rematch && pos >= rematch.reach) {
  23667. break;
  23668. }
  23669. var str = currentNode.value;
  23670. if (tokenList.length > text.length) {
  23671. // Something went terribly wrong, ABORT, ABORT!
  23672. return;
  23673. }
  23674. if (str instanceof Token) {
  23675. continue;
  23676. }
  23677. var removeCount = 1; // this is the to parameter of removeBetween
  23678. var match;
  23679. if (greedy) {
  23680. match = matchPattern(pattern, pos, text, lookbehind);
  23681. if (!match || match.index >= text.length) {
  23682. break;
  23683. }
  23684. var from = match.index;
  23685. var to = match.index + match[0].length;
  23686. var p = pos;
  23687. // find the node that contains the match
  23688. p += currentNode.value.length;
  23689. while (from >= p) {
  23690. currentNode = currentNode.next;
  23691. p += currentNode.value.length;
  23692. }
  23693. // adjust pos (and p)
  23694. p -= currentNode.value.length;
  23695. pos = p;
  23696. // the current node is a Token, then the match starts inside another Token, which is invalid
  23697. if (currentNode.value instanceof Token) {
  23698. continue;
  23699. }
  23700. // find the last node which is affected by this match
  23701. for (
  23702. var k = currentNode;
  23703. k !== tokenList.tail && (p < to || typeof k.value === 'string');
  23704. k = k.next
  23705. ) {
  23706. removeCount++;
  23707. p += k.value.length;
  23708. }
  23709. removeCount--;
  23710. // replace with the new match
  23711. str = text.slice(pos, p);
  23712. match.index -= pos;
  23713. } else {
  23714. match = matchPattern(pattern, 0, str, lookbehind);
  23715. if (!match) {
  23716. continue;
  23717. }
  23718. }
  23719. // eslint-disable-next-line no-redeclare
  23720. var from = match.index;
  23721. var matchStr = match[0];
  23722. var before = str.slice(0, from);
  23723. var after = str.slice(from + matchStr.length);
  23724. var reach = pos + str.length;
  23725. if (rematch && reach > rematch.reach) {
  23726. rematch.reach = reach;
  23727. }
  23728. var removeFrom = currentNode.prev;
  23729. if (before) {
  23730. removeFrom = addAfter(tokenList, removeFrom, before);
  23731. pos += before.length;
  23732. }
  23733. removeRange(tokenList, removeFrom, removeCount);
  23734. var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
  23735. currentNode = addAfter(tokenList, removeFrom, wrapped);
  23736. if (after) {
  23737. addAfter(tokenList, currentNode, after);
  23738. }
  23739. if (removeCount > 1) {
  23740. // at least one Token object was removed, so we have to do some rematching
  23741. // this can only happen if the current pattern is greedy
  23742. /** @type {RematchOptions} */
  23743. var nestedRematch = {
  23744. cause: token + ',' + j,
  23745. reach: reach
  23746. };
  23747. matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
  23748. // the reach might have been extended because of the rematching
  23749. if (rematch && nestedRematch.reach > rematch.reach) {
  23750. rematch.reach = nestedRematch.reach;
  23751. }
  23752. }
  23753. }
  23754. }
  23755. }
  23756. }
  23757. /**
  23758. * @typedef LinkedListNode
  23759. * @property {T} value
  23760. * @property {LinkedListNode<T> | null} prev The previous node.
  23761. * @property {LinkedListNode<T> | null} next The next node.
  23762. * @template T
  23763. * @private
  23764. */
  23765. /**
  23766. * @template T
  23767. * @private
  23768. */
  23769. function LinkedList() {
  23770. /** @type {LinkedListNode<T>} */
  23771. var head = { value: null, prev: null, next: null };
  23772. /** @type {LinkedListNode<T>} */
  23773. var tail = { value: null, prev: head, next: null };
  23774. head.next = tail;
  23775. /** @type {LinkedListNode<T>} */
  23776. this.head = head;
  23777. /** @type {LinkedListNode<T>} */
  23778. this.tail = tail;
  23779. this.length = 0;
  23780. }
  23781. /**
  23782. * Adds a new node with the given value to the list.
  23783. *
  23784. * @param {LinkedList<T>} list
  23785. * @param {LinkedListNode<T>} node
  23786. * @param {T} value
  23787. * @returns {LinkedListNode<T>} The added node.
  23788. * @template T
  23789. */
  23790. function addAfter(list, node, value) {
  23791. // assumes that node != list.tail && values.length >= 0
  23792. var next = node.next;
  23793. var newNode = { value: value, prev: node, next: next };
  23794. node.next = newNode;
  23795. next.prev = newNode;
  23796. list.length++;
  23797. return newNode;
  23798. }
  23799. /**
  23800. * Removes `count` nodes after the given node. The given node will not be removed.
  23801. *
  23802. * @param {LinkedList<T>} list
  23803. * @param {LinkedListNode<T>} node
  23804. * @param {number} count
  23805. * @template T
  23806. */
  23807. function removeRange(list, node, count) {
  23808. var next = node.next;
  23809. for (var i = 0; i < count && next !== list.tail; i++) {
  23810. next = next.next;
  23811. }
  23812. node.next = next;
  23813. next.prev = node;
  23814. list.length -= i;
  23815. }
  23816. /**
  23817. * @param {LinkedList<T>} list
  23818. * @returns {T[]}
  23819. * @template T
  23820. */
  23821. function toArray(list) {
  23822. var array = [];
  23823. var node = list.head.next;
  23824. while (node !== list.tail) {
  23825. array.push(node.value);
  23826. node = node.next;
  23827. }
  23828. return array;
  23829. }
  23830. if (!_self.document) {
  23831. if (!_self.addEventListener) {
  23832. // in Node.js
  23833. return _;
  23834. }
  23835. if (!_.disableWorkerMessageHandler) {
  23836. // In worker
  23837. _self.addEventListener('message', function (evt) {
  23838. var message = JSON.parse(evt.data);
  23839. var lang = message.language;
  23840. var code = message.code;
  23841. var immediateClose = message.immediateClose;
  23842. _self.postMessage(_.highlight(code, _.languages[lang], lang));
  23843. if (immediateClose) {
  23844. _self.close();
  23845. }
  23846. }, false);
  23847. }
  23848. return _;
  23849. }
  23850. // Get current script and highlight
  23851. var script = _.util.currentScript();
  23852. if (script) {
  23853. _.filename = script.src;
  23854. if (script.hasAttribute('data-manual')) {
  23855. _.manual = true;
  23856. }
  23857. }
  23858. function highlightAutomaticallyCallback() {
  23859. if (!_.manual) {
  23860. _.highlightAll();
  23861. }
  23862. }
  23863. if (!_.manual) {
  23864. // If the document state is "loading", then we'll use DOMContentLoaded.
  23865. // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
  23866. // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
  23867. // might take longer one animation frame to execute which can create a race condition where only some plugins have
  23868. // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
  23869. // See https://github.com/PrismJS/prism/issues/2102
  23870. var readyState = document.readyState;
  23871. if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
  23872. document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
  23873. } else {
  23874. if (window.requestAnimationFrame) {
  23875. window.requestAnimationFrame(highlightAutomaticallyCallback);
  23876. } else {
  23877. window.setTimeout(highlightAutomaticallyCallback, 16);
  23878. }
  23879. }
  23880. }
  23881. return _;
  23882. }(_self));
  23883. if ( module.exports) {
  23884. module.exports = Prism;
  23885. }
  23886. // hack for components to work correctly in node.js
  23887. if (typeof commonjsGlobal !== 'undefined') {
  23888. commonjsGlobal.Prism = Prism;
  23889. }
  23890. // some additional documentation/types
  23891. /**
  23892. * The expansion of a simple `RegExp` literal to support additional properties.
  23893. *
  23894. * @typedef GrammarToken
  23895. * @property {RegExp} pattern The regular expression of the token.
  23896. * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively)
  23897. * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token.
  23898. * @property {boolean} [greedy=false] Whether the token is greedy.
  23899. * @property {string|string[]} [alias] An optional alias or list of aliases.
  23900. * @property {Grammar} [inside] The nested grammar of this token.
  23901. *
  23902. * The `inside` grammar will be used to tokenize the text value of each token of this kind.
  23903. *
  23904. * This can be used to make nested and even recursive language definitions.
  23905. *
  23906. * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into
  23907. * each another.
  23908. * @global
  23909. * @public
  23910. */
  23911. /**
  23912. * @typedef Grammar
  23913. * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}
  23914. * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.
  23915. * @global
  23916. * @public
  23917. */
  23918. /**
  23919. * A function which will invoked after an element was successfully highlighted.
  23920. *
  23921. * @callback HighlightCallback
  23922. * @param {Element} element The element successfully highlighted.
  23923. * @returns {void}
  23924. * @global
  23925. * @public
  23926. */
  23927. /**
  23928. * @callback HookCallback
  23929. * @param {Object<string, any>} env The environment variables of the hook.
  23930. * @returns {void}
  23931. * @global
  23932. * @public
  23933. */
  23934. });
  23935. Prism.languages.clike = {
  23936. 'comment': [
  23937. {
  23938. pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
  23939. lookbehind: true,
  23940. greedy: true
  23941. },
  23942. {
  23943. pattern: /(^|[^\\:])\/\/.*/,
  23944. lookbehind: true,
  23945. greedy: true
  23946. }
  23947. ],
  23948. 'string': {
  23949. pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
  23950. greedy: true
  23951. },
  23952. 'class-name': {
  23953. pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
  23954. lookbehind: true,
  23955. inside: {
  23956. 'punctuation': /[.\\]/
  23957. }
  23958. },
  23959. 'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
  23960. 'boolean': /\b(?:false|true)\b/,
  23961. 'function': /\b\w+(?=\()/,
  23962. 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
  23963. 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
  23964. 'punctuation': /[{}[\];(),.:]/
  23965. };
  23966. Prism.languages.c = Prism.languages.extend('clike', {
  23967. 'comment': {
  23968. pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
  23969. greedy: true
  23970. },
  23971. 'string': {
  23972. // https://en.cppreference.com/w/c/language/string_literal
  23973. pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
  23974. greedy: true
  23975. },
  23976. 'class-name': {
  23977. pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
  23978. lookbehind: true
  23979. },
  23980. 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,
  23981. 'function': /\b[a-z_]\w*(?=\s*\()/i,
  23982. 'number': /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
  23983. 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
  23984. });
  23985. Prism.languages.insertBefore('c', 'string', {
  23986. 'char': {
  23987. // https://en.cppreference.com/w/c/language/character_constant
  23988. pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
  23989. greedy: true
  23990. }
  23991. });
  23992. Prism.languages.insertBefore('c', 'string', {
  23993. 'macro': {
  23994. // allow for multiline macro definitions
  23995. // spaces after the # character compile fine with gcc
  23996. pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
  23997. lookbehind: true,
  23998. greedy: true,
  23999. alias: 'property',
  24000. inside: {
  24001. 'string': [
  24002. {
  24003. // highlight the path of the include statement as a string
  24004. pattern: /^(#\s*include\s*)<[^>]+>/,
  24005. lookbehind: true
  24006. },
  24007. Prism.languages.c['string']
  24008. ],
  24009. 'char': Prism.languages.c['char'],
  24010. 'comment': Prism.languages.c['comment'],
  24011. 'macro-name': [
  24012. {
  24013. pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
  24014. lookbehind: true
  24015. },
  24016. {
  24017. pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
  24018. lookbehind: true,
  24019. alias: 'function'
  24020. }
  24021. ],
  24022. // highlight macro directives as keywords
  24023. 'directive': {
  24024. pattern: /^(#\s*)[a-z]+/,
  24025. lookbehind: true,
  24026. alias: 'keyword'
  24027. },
  24028. 'directive-hash': /^#/,
  24029. 'punctuation': /##|\\(?=[\r\n])/,
  24030. 'expression': {
  24031. pattern: /\S[\s\S]*/,
  24032. inside: Prism.languages.c
  24033. }
  24034. }
  24035. }
  24036. });
  24037. Prism.languages.insertBefore('c', 'function', {
  24038. // highlight predefined macros as constants
  24039. 'constant': /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
  24040. });
  24041. delete Prism.languages.c['boolean'];
  24042. (function (Prism) {
  24043. /**
  24044. * Replaces all placeholders "<<n>>" of given pattern with the n-th replacement (zero based).
  24045. *
  24046. * Note: This is a simple text based replacement. Be careful when using backreferences!
  24047. *
  24048. * @param {string} pattern the given pattern.
  24049. * @param {string[]} replacements a list of replacement which can be inserted into the given pattern.
  24050. * @returns {string} the pattern with all placeholders replaced with their corresponding replacements.
  24051. * @example replace(/a<<0>>a/.source, [/b+/.source]) === /a(?:b+)a/.source
  24052. */
  24053. function replace(pattern, replacements) {
  24054. return pattern.replace(/<<(\d+)>>/g, function (m, index) {
  24055. return '(?:' + replacements[+index] + ')';
  24056. });
  24057. }
  24058. /**
  24059. * @param {string} pattern
  24060. * @param {string[]} replacements
  24061. * @param {string} [flags]
  24062. * @returns {RegExp}
  24063. */
  24064. function re(pattern, replacements, flags) {
  24065. return RegExp(replace(pattern, replacements), flags || '');
  24066. }
  24067. /**
  24068. * Creates a nested pattern where all occurrences of the string `<<self>>` are replaced with the pattern itself.
  24069. *
  24070. * @param {string} pattern
  24071. * @param {number} depthLog2
  24072. * @returns {string}
  24073. */
  24074. function nested(pattern, depthLog2) {
  24075. for (var i = 0; i < depthLog2; i++) {
  24076. pattern = pattern.replace(/<<self>>/g, function () { return '(?:' + pattern + ')'; });
  24077. }
  24078. return pattern.replace(/<<self>>/g, '[^\\s\\S]');
  24079. }
  24080. // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/
  24081. var keywordKinds = {
  24082. // keywords which represent a return or variable type
  24083. type: 'bool byte char decimal double dynamic float int long object sbyte short string uint ulong ushort var void',
  24084. // keywords which are used to declare a type
  24085. typeDeclaration: 'class enum interface record struct',
  24086. // contextual keywords
  24087. // ("var" and "dynamic" are missing because they are used like types)
  24088. contextual: 'add alias and ascending async await by descending from(?=\\s*(?:\\w|$)) get global group into init(?=\\s*;) join let nameof not notnull on or orderby partial remove select set unmanaged value when where with(?=\\s*{)',
  24089. // all other keywords
  24090. other: 'abstract as base break case catch checked const continue default delegate do else event explicit extern finally fixed for foreach goto if implicit in internal is lock namespace new null operator out override params private protected public readonly ref return sealed sizeof stackalloc static switch this throw try typeof unchecked unsafe using virtual volatile while yield'
  24091. };
  24092. // keywords
  24093. function keywordsToPattern(words) {
  24094. return '\\b(?:' + words.trim().replace(/ /g, '|') + ')\\b';
  24095. }
  24096. var typeDeclarationKeywords = keywordsToPattern(keywordKinds.typeDeclaration);
  24097. var keywords = RegExp(keywordsToPattern(keywordKinds.type + ' ' + keywordKinds.typeDeclaration + ' ' + keywordKinds.contextual + ' ' + keywordKinds.other));
  24098. var nonTypeKeywords = keywordsToPattern(keywordKinds.typeDeclaration + ' ' + keywordKinds.contextual + ' ' + keywordKinds.other);
  24099. var nonContextualKeywords = keywordsToPattern(keywordKinds.type + ' ' + keywordKinds.typeDeclaration + ' ' + keywordKinds.other);
  24100. // types
  24101. var generic = nested(/<(?:[^<>;=+\-*/%&|^]|<<self>>)*>/.source, 2); // the idea behind the other forbidden characters is to prevent false positives. Same for tupleElement.
  24102. var nestedRound = nested(/\((?:[^()]|<<self>>)*\)/.source, 2);
  24103. var name = /@?\b[A-Za-z_]\w*\b/.source;
  24104. var genericName = replace(/<<0>>(?:\s*<<1>>)?/.source, [name, generic]);
  24105. var identifier = replace(/(?!<<0>>)<<1>>(?:\s*\.\s*<<1>>)*/.source, [nonTypeKeywords, genericName]);
  24106. var array = /\[\s*(?:,\s*)*\]/.source;
  24107. var typeExpressionWithoutTuple = replace(/<<0>>(?:\s*(?:\?\s*)?<<1>>)*(?:\s*\?)?/.source, [identifier, array]);
  24108. var tupleElement = replace(/[^,()<>[\];=+\-*/%&|^]|<<0>>|<<1>>|<<2>>/.source, [generic, nestedRound, array]);
  24109. var tuple = replace(/\(<<0>>+(?:,<<0>>+)+\)/.source, [tupleElement]);
  24110. var typeExpression = replace(/(?:<<0>>|<<1>>)(?:\s*(?:\?\s*)?<<2>>)*(?:\s*\?)?/.source, [tuple, identifier, array]);
  24111. var typeInside = {
  24112. 'keyword': keywords,
  24113. 'punctuation': /[<>()?,.:[\]]/
  24114. };
  24115. // strings & characters
  24116. // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#character-literals
  24117. // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#string-literals
  24118. var character = /'(?:[^\r\n'\\]|\\.|\\[Uux][\da-fA-F]{1,8})'/.source; // simplified pattern
  24119. var regularString = /"(?:\\.|[^\\"\r\n])*"/.source;
  24120. var verbatimString = /@"(?:""|\\[\s\S]|[^\\"])*"(?!")/.source;
  24121. Prism.languages.csharp = Prism.languages.extend('clike', {
  24122. 'string': [
  24123. {
  24124. pattern: re(/(^|[^$\\])<<0>>/.source, [verbatimString]),
  24125. lookbehind: true,
  24126. greedy: true
  24127. },
  24128. {
  24129. pattern: re(/(^|[^@$\\])<<0>>/.source, [regularString]),
  24130. lookbehind: true,
  24131. greedy: true
  24132. }
  24133. ],
  24134. 'class-name': [
  24135. {
  24136. // Using static
  24137. // using static System.Math;
  24138. pattern: re(/(\busing\s+static\s+)<<0>>(?=\s*;)/.source, [identifier]),
  24139. lookbehind: true,
  24140. inside: typeInside
  24141. },
  24142. {
  24143. // Using alias (type)
  24144. // using Project = PC.MyCompany.Project;
  24145. pattern: re(/(\busing\s+<<0>>\s*=\s*)<<1>>(?=\s*;)/.source, [name, typeExpression]),
  24146. lookbehind: true,
  24147. inside: typeInside
  24148. },
  24149. {
  24150. // Using alias (alias)
  24151. // using Project = PC.MyCompany.Project;
  24152. pattern: re(/(\busing\s+)<<0>>(?=\s*=)/.source, [name]),
  24153. lookbehind: true
  24154. },
  24155. {
  24156. // Type declarations
  24157. // class Foo<A, B>
  24158. // interface Foo<out A, B>
  24159. pattern: re(/(\b<<0>>\s+)<<1>>/.source, [typeDeclarationKeywords, genericName]),
  24160. lookbehind: true,
  24161. inside: typeInside
  24162. },
  24163. {
  24164. // Single catch exception declaration
  24165. // catch(Foo)
  24166. // (things like catch(Foo e) is covered by variable declaration)
  24167. pattern: re(/(\bcatch\s*\(\s*)<<0>>/.source, [identifier]),
  24168. lookbehind: true,
  24169. inside: typeInside
  24170. },
  24171. {
  24172. // Name of the type parameter of generic constraints
  24173. // where Foo : class
  24174. pattern: re(/(\bwhere\s+)<<0>>/.source, [name]),
  24175. lookbehind: true
  24176. },
  24177. {
  24178. // Casts and checks via as and is.
  24179. // as Foo<A>, is Bar<B>
  24180. // (things like if(a is Foo b) is covered by variable declaration)
  24181. pattern: re(/(\b(?:is(?:\s+not)?|as)\s+)<<0>>/.source, [typeExpressionWithoutTuple]),
  24182. lookbehind: true,
  24183. inside: typeInside
  24184. },
  24185. {
  24186. // Variable, field and parameter declaration
  24187. // (Foo bar, Bar baz, Foo[,,] bay, Foo<Bar, FooBar<Bar>> bax)
  24188. pattern: re(/\b<<0>>(?=\s+(?!<<1>>|with\s*\{)<<2>>(?:\s*[=,;:{)\]]|\s+(?:in|when)\b))/.source, [typeExpression, nonContextualKeywords, name]),
  24189. inside: typeInside
  24190. }
  24191. ],
  24192. 'keyword': keywords,
  24193. // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#literals
  24194. 'number': /(?:\b0(?:x[\da-f_]*[\da-f]|b[01_]*[01])|(?:\B\.\d+(?:_+\d+)*|\b\d+(?:_+\d+)*(?:\.\d+(?:_+\d+)*)?)(?:e[-+]?\d+(?:_+\d+)*)?)(?:[dflmu]|lu|ul)?\b/i,
  24195. 'operator': />>=?|<<=?|[-=]>|([-+&|])\1|~|\?\?=?|[-+*/%&|^!=<>]=?/,
  24196. 'punctuation': /\?\.?|::|[{}[\];(),.:]/
  24197. });
  24198. Prism.languages.insertBefore('csharp', 'number', {
  24199. 'range': {
  24200. pattern: /\.\./,
  24201. alias: 'operator'
  24202. }
  24203. });
  24204. Prism.languages.insertBefore('csharp', 'punctuation', {
  24205. 'named-parameter': {
  24206. pattern: re(/([(,]\s*)<<0>>(?=\s*:)/.source, [name]),
  24207. lookbehind: true,
  24208. alias: 'punctuation'
  24209. }
  24210. });
  24211. Prism.languages.insertBefore('csharp', 'class-name', {
  24212. 'namespace': {
  24213. // namespace Foo.Bar {}
  24214. // using Foo.Bar;
  24215. pattern: re(/(\b(?:namespace|using)\s+)<<0>>(?:\s*\.\s*<<0>>)*(?=\s*[;{])/.source, [name]),
  24216. lookbehind: true,
  24217. inside: {
  24218. 'punctuation': /\./
  24219. }
  24220. },
  24221. 'type-expression': {
  24222. // default(Foo), typeof(Foo<Bar>), sizeof(int)
  24223. pattern: re(/(\b(?:default|sizeof|typeof)\s*\(\s*(?!\s))(?:[^()\s]|\s(?!\s)|<<0>>)*(?=\s*\))/.source, [nestedRound]),
  24224. lookbehind: true,
  24225. alias: 'class-name',
  24226. inside: typeInside
  24227. },
  24228. 'return-type': {
  24229. // Foo<Bar> ForBar(); Foo IFoo.Bar() => 0
  24230. // int this[int index] => 0; T IReadOnlyList<T>.this[int index] => this[index];
  24231. // int Foo => 0; int Foo { get; set } = 0;
  24232. pattern: re(/<<0>>(?=\s+(?:<<1>>\s*(?:=>|[({]|\.\s*this\s*\[)|this\s*\[))/.source, [typeExpression, identifier]),
  24233. inside: typeInside,
  24234. alias: 'class-name'
  24235. },
  24236. 'constructor-invocation': {
  24237. // new List<Foo<Bar[]>> { }
  24238. pattern: re(/(\bnew\s+)<<0>>(?=\s*[[({])/.source, [typeExpression]),
  24239. lookbehind: true,
  24240. inside: typeInside,
  24241. alias: 'class-name'
  24242. },
  24243. /*'explicit-implementation': {
  24244. // int IFoo<Foo>.Bar => 0; void IFoo<Foo<Foo>>.Foo<T>();
  24245. pattern: replace(/\b<<0>>(?=\.<<1>>)/, className, methodOrPropertyDeclaration),
  24246. inside: classNameInside,
  24247. alias: 'class-name'
  24248. },*/
  24249. 'generic-method': {
  24250. // foo<Bar>()
  24251. pattern: re(/<<0>>\s*<<1>>(?=\s*\()/.source, [name, generic]),
  24252. inside: {
  24253. 'function': re(/^<<0>>/.source, [name]),
  24254. 'generic': {
  24255. pattern: RegExp(generic),
  24256. alias: 'class-name',
  24257. inside: typeInside
  24258. }
  24259. }
  24260. },
  24261. 'type-list': {
  24262. // The list of types inherited or of generic constraints
  24263. // class Foo<F> : Bar, IList<FooBar>
  24264. // where F : Bar, IList<int>
  24265. pattern: re(
  24266. /\b((?:<<0>>\s+<<1>>|record\s+<<1>>\s*<<5>>|where\s+<<2>>)\s*:\s*)(?:<<3>>|<<4>>|<<1>>\s*<<5>>|<<6>>)(?:\s*,\s*(?:<<3>>|<<4>>|<<6>>))*(?=\s*(?:where|[{;]|=>|$))/.source,
  24267. [typeDeclarationKeywords, genericName, name, typeExpression, keywords.source, nestedRound, /\bnew\s*\(\s*\)/.source]
  24268. ),
  24269. lookbehind: true,
  24270. inside: {
  24271. 'record-arguments': {
  24272. pattern: re(/(^(?!new\s*\()<<0>>\s*)<<1>>/.source, [genericName, nestedRound]),
  24273. lookbehind: true,
  24274. greedy: true,
  24275. inside: Prism.languages.csharp
  24276. },
  24277. 'keyword': keywords,
  24278. 'class-name': {
  24279. pattern: RegExp(typeExpression),
  24280. greedy: true,
  24281. inside: typeInside
  24282. },
  24283. 'punctuation': /[,()]/
  24284. }
  24285. },
  24286. 'preprocessor': {
  24287. pattern: /(^[\t ]*)#.*/m,
  24288. lookbehind: true,
  24289. alias: 'property',
  24290. inside: {
  24291. // highlight preprocessor directives as keywords
  24292. 'directive': {
  24293. pattern: /(#)\b(?:define|elif|else|endif|endregion|error|if|line|nullable|pragma|region|undef|warning)\b/,
  24294. lookbehind: true,
  24295. alias: 'keyword'
  24296. }
  24297. }
  24298. }
  24299. });
  24300. // attributes
  24301. var regularStringOrCharacter = regularString + '|' + character;
  24302. var regularStringCharacterOrComment = replace(/\/(?![*/])|\/\/[^\r\n]*[\r\n]|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>/.source, [regularStringOrCharacter]);
  24303. var roundExpression = nested(replace(/[^"'/()]|<<0>>|\(<<self>>*\)/.source, [regularStringCharacterOrComment]), 2);
  24304. // https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/attributes/#attribute-targets
  24305. var attrTarget = /\b(?:assembly|event|field|method|module|param|property|return|type)\b/.source;
  24306. var attr = replace(/<<0>>(?:\s*\(<<1>>*\))?/.source, [identifier, roundExpression]);
  24307. Prism.languages.insertBefore('csharp', 'class-name', {
  24308. 'attribute': {
  24309. // Attributes
  24310. // [Foo], [Foo(1), Bar(2, Prop = "foo")], [return: Foo(1), Bar(2)], [assembly: Foo(Bar)]
  24311. pattern: re(/((?:^|[^\s\w>)?])\s*\[\s*)(?:<<0>>\s*:\s*)?<<1>>(?:\s*,\s*<<1>>)*(?=\s*\])/.source, [attrTarget, attr]),
  24312. lookbehind: true,
  24313. greedy: true,
  24314. inside: {
  24315. 'target': {
  24316. pattern: re(/^<<0>>(?=\s*:)/.source, [attrTarget]),
  24317. alias: 'keyword'
  24318. },
  24319. 'attribute-arguments': {
  24320. pattern: re(/\(<<0>>*\)/.source, [roundExpression]),
  24321. inside: Prism.languages.csharp
  24322. },
  24323. 'class-name': {
  24324. pattern: RegExp(identifier),
  24325. inside: {
  24326. 'punctuation': /\./
  24327. }
  24328. },
  24329. 'punctuation': /[:,]/
  24330. }
  24331. }
  24332. });
  24333. // string interpolation
  24334. var formatString = /:[^}\r\n]+/.source;
  24335. // multi line
  24336. var mInterpolationRound = nested(replace(/[^"'/()]|<<0>>|\(<<self>>*\)/.source, [regularStringCharacterOrComment]), 2);
  24337. var mInterpolation = replace(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source, [mInterpolationRound, formatString]);
  24338. // single line
  24339. var sInterpolationRound = nested(replace(/[^"'/()]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>|\(<<self>>*\)/.source, [regularStringOrCharacter]), 2);
  24340. var sInterpolation = replace(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source, [sInterpolationRound, formatString]);
  24341. function createInterpolationInside(interpolation, interpolationRound) {
  24342. return {
  24343. 'interpolation': {
  24344. pattern: re(/((?:^|[^{])(?:\{\{)*)<<0>>/.source, [interpolation]),
  24345. lookbehind: true,
  24346. inside: {
  24347. 'format-string': {
  24348. pattern: re(/(^\{(?:(?![}:])<<0>>)*)<<1>>(?=\}$)/.source, [interpolationRound, formatString]),
  24349. lookbehind: true,
  24350. inside: {
  24351. 'punctuation': /^:/
  24352. }
  24353. },
  24354. 'punctuation': /^\{|\}$/,
  24355. 'expression': {
  24356. pattern: /[\s\S]+/,
  24357. alias: 'language-csharp',
  24358. inside: Prism.languages.csharp
  24359. }
  24360. }
  24361. },
  24362. 'string': /[\s\S]+/
  24363. };
  24364. }
  24365. Prism.languages.insertBefore('csharp', 'string', {
  24366. 'interpolation-string': [
  24367. {
  24368. pattern: re(/(^|[^\\])(?:\$@|@\$)"(?:""|\\[\s\S]|\{\{|<<0>>|[^\\{"])*"/.source, [mInterpolation]),
  24369. lookbehind: true,
  24370. greedy: true,
  24371. inside: createInterpolationInside(mInterpolation, mInterpolationRound),
  24372. },
  24373. {
  24374. pattern: re(/(^|[^@\\])\$"(?:\\.|\{\{|<<0>>|[^\\"{])*"/.source, [sInterpolation]),
  24375. lookbehind: true,
  24376. greedy: true,
  24377. inside: createInterpolationInside(sInterpolation, sInterpolationRound),
  24378. }
  24379. ],
  24380. 'char': {
  24381. pattern: RegExp(character),
  24382. greedy: true
  24383. }
  24384. });
  24385. Prism.languages.dotnet = Prism.languages.cs = Prism.languages.csharp;
  24386. }(Prism));
  24387. (function (Prism) {
  24388. var keyword = /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/;
  24389. var modName = /\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g, function () { return keyword.source; });
  24390. Prism.languages.cpp = Prism.languages.extend('c', {
  24391. 'class-name': [
  24392. {
  24393. pattern: RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source
  24394. .replace(/<keyword>/g, function () { return keyword.source; })),
  24395. lookbehind: true
  24396. },
  24397. // This is intended to capture the class name of method implementations like:
  24398. // void foo::bar() const {}
  24399. // However! The `foo` in the above example could also be a namespace, so we only capture the class name if
  24400. // it starts with an uppercase letter. This approximation should give decent results.
  24401. /\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,
  24402. // This will capture the class name before destructors like:
  24403. // Foo::~Foo() {}
  24404. /\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,
  24405. // This also intends to capture the class name of method implementations but here the class has template
  24406. // parameters, so it can't be a namespace (until C++ adds generic namespaces).
  24407. /\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/
  24408. ],
  24409. 'keyword': keyword,
  24410. 'number': {
  24411. pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,
  24412. greedy: true
  24413. },
  24414. 'operator': />>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
  24415. 'boolean': /\b(?:false|true)\b/
  24416. });
  24417. Prism.languages.insertBefore('cpp', 'string', {
  24418. 'module': {
  24419. // https://en.cppreference.com/w/cpp/language/modules
  24420. pattern: RegExp(
  24421. /(\b(?:import|module)\s+)/.source +
  24422. '(?:' +
  24423. // header-name
  24424. /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source +
  24425. '|' +
  24426. // module name or partition or both
  24427. /<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/g, function () { return modName; }) +
  24428. ')'
  24429. ),
  24430. lookbehind: true,
  24431. greedy: true,
  24432. inside: {
  24433. 'string': /^[<"][\s\S]+/,
  24434. 'operator': /:/,
  24435. 'punctuation': /\./
  24436. }
  24437. },
  24438. 'raw-string': {
  24439. pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
  24440. alias: 'string',
  24441. greedy: true
  24442. }
  24443. });
  24444. Prism.languages.insertBefore('cpp', 'keyword', {
  24445. 'generic-function': {
  24446. pattern: /\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,
  24447. inside: {
  24448. 'function': /^\w+/,
  24449. 'generic': {
  24450. pattern: /<[\s\S]+/,
  24451. alias: 'class-name',
  24452. inside: Prism.languages.cpp
  24453. }
  24454. }
  24455. }
  24456. });
  24457. Prism.languages.insertBefore('cpp', 'operator', {
  24458. 'double-colon': {
  24459. pattern: /::/,
  24460. alias: 'punctuation'
  24461. }
  24462. });
  24463. Prism.languages.insertBefore('cpp', 'class-name', {
  24464. // the base clause is an optional list of parent classes
  24465. // https://en.cppreference.com/w/cpp/language/class
  24466. 'base-clause': {
  24467. pattern: /(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,
  24468. lookbehind: true,
  24469. greedy: true,
  24470. inside: Prism.languages.extend('cpp', {})
  24471. }
  24472. });
  24473. Prism.languages.insertBefore('inside', 'double-colon', {
  24474. // All untokenized words that are not namespaces should be class names
  24475. 'class-name': /\b[a-z_]\w*\b(?!\s*::)/i
  24476. }, Prism.languages.cpp['base-clause']);
  24477. }(Prism));
  24478. Prism.languages.markup = {
  24479. 'comment': {
  24480. pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
  24481. greedy: true
  24482. },
  24483. 'prolog': {
  24484. pattern: /<\?[\s\S]+?\?>/,
  24485. greedy: true
  24486. },
  24487. 'doctype': {
  24488. // https://www.w3.org/TR/xml/#NT-doctypedecl
  24489. pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
  24490. greedy: true,
  24491. inside: {
  24492. 'internal-subset': {
  24493. pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
  24494. lookbehind: true,
  24495. greedy: true,
  24496. inside: null // see below
  24497. },
  24498. 'string': {
  24499. pattern: /"[^"]*"|'[^']*'/,
  24500. greedy: true
  24501. },
  24502. 'punctuation': /^<!|>$|[[\]]/,
  24503. 'doctype-tag': /^DOCTYPE/i,
  24504. 'name': /[^\s<>'"]+/
  24505. }
  24506. },
  24507. 'cdata': {
  24508. pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
  24509. greedy: true
  24510. },
  24511. 'tag': {
  24512. pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
  24513. greedy: true,
  24514. inside: {
  24515. 'tag': {
  24516. pattern: /^<\/?[^\s>\/]+/,
  24517. inside: {
  24518. 'punctuation': /^<\/?/,
  24519. 'namespace': /^[^\s>\/:]+:/
  24520. }
  24521. },
  24522. 'special-attr': [],
  24523. 'attr-value': {
  24524. pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
  24525. inside: {
  24526. 'punctuation': [
  24527. {
  24528. pattern: /^=/,
  24529. alias: 'attr-equals'
  24530. },
  24531. /"|'/
  24532. ]
  24533. }
  24534. },
  24535. 'punctuation': /\/?>/,
  24536. 'attr-name': {
  24537. pattern: /[^\s>\/]+/,
  24538. inside: {
  24539. 'namespace': /^[^\s>\/:]+:/
  24540. }
  24541. }
  24542. }
  24543. },
  24544. 'entity': [
  24545. {
  24546. pattern: /&[\da-z]{1,8};/i,
  24547. alias: 'named-entity'
  24548. },
  24549. /&#x?[\da-f]{1,8};/i
  24550. ]
  24551. };
  24552. Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
  24553. Prism.languages.markup['entity'];
  24554. Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
  24555. // Plugin to make entity title show the real entity, idea by Roman Komarov
  24556. Prism.hooks.add('wrap', function (env) {
  24557. if (env.type === 'entity') {
  24558. env.attributes['title'] = env.content.replace(/&amp;/, '&');
  24559. }
  24560. });
  24561. Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
  24562. /**
  24563. * Adds an inlined language to markup.
  24564. *
  24565. * An example of an inlined language is CSS with `<style>` tags.
  24566. *
  24567. * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
  24568. * case insensitive.
  24569. * @param {string} lang The language key.
  24570. * @example
  24571. * addInlined('style', 'css');
  24572. */
  24573. value: function addInlined(tagName, lang) {
  24574. var includedCdataInside = {};
  24575. includedCdataInside['language-' + lang] = {
  24576. pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
  24577. lookbehind: true,
  24578. inside: Prism.languages[lang]
  24579. };
  24580. includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
  24581. var inside = {
  24582. 'included-cdata': {
  24583. pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
  24584. inside: includedCdataInside
  24585. }
  24586. };
  24587. inside['language-' + lang] = {
  24588. pattern: /[\s\S]+/,
  24589. inside: Prism.languages[lang]
  24590. };
  24591. var def = {};
  24592. def[tagName] = {
  24593. pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
  24594. lookbehind: true,
  24595. greedy: true,
  24596. inside: inside
  24597. };
  24598. Prism.languages.insertBefore('markup', 'cdata', def);
  24599. }
  24600. });
  24601. Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
  24602. /**
  24603. * Adds an pattern to highlight languages embedded in HTML attributes.
  24604. *
  24605. * An example of an inlined language is CSS with `style` attributes.
  24606. *
  24607. * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
  24608. * case insensitive.
  24609. * @param {string} lang The language key.
  24610. * @example
  24611. * addAttribute('style', 'css');
  24612. */
  24613. value: function (attrName, lang) {
  24614. Prism.languages.markup.tag.inside['special-attr'].push({
  24615. pattern: RegExp(
  24616. /(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
  24617. 'i'
  24618. ),
  24619. lookbehind: true,
  24620. inside: {
  24621. 'attr-name': /^[^\s=]+/,
  24622. 'attr-value': {
  24623. pattern: /=[\s\S]+/,
  24624. inside: {
  24625. 'value': {
  24626. pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
  24627. lookbehind: true,
  24628. alias: [lang, 'language-' + lang],
  24629. inside: Prism.languages[lang]
  24630. },
  24631. 'punctuation': [
  24632. {
  24633. pattern: /^=/,
  24634. alias: 'attr-equals'
  24635. },
  24636. /"|'/
  24637. ]
  24638. }
  24639. }
  24640. }
  24641. });
  24642. }
  24643. });
  24644. Prism.languages.html = Prism.languages.markup;
  24645. Prism.languages.mathml = Prism.languages.markup;
  24646. Prism.languages.svg = Prism.languages.markup;
  24647. Prism.languages.xml = Prism.languages.extend('markup', {});
  24648. Prism.languages.ssml = Prism.languages.xml;
  24649. Prism.languages.atom = Prism.languages.xml;
  24650. Prism.languages.rss = Prism.languages.xml;
  24651. (function (Prism) {
  24652. var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
  24653. Prism.languages.css = {
  24654. 'comment': /\/\*[\s\S]*?\*\//,
  24655. 'atrule': {
  24656. pattern: /@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,
  24657. inside: {
  24658. 'rule': /^@[\w-]+/,
  24659. 'selector-function-argument': {
  24660. pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
  24661. lookbehind: true,
  24662. alias: 'selector'
  24663. },
  24664. 'keyword': {
  24665. pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
  24666. lookbehind: true
  24667. }
  24668. // See rest below
  24669. }
  24670. },
  24671. 'url': {
  24672. // https://drafts.csswg.org/css-values-3/#urls
  24673. pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
  24674. greedy: true,
  24675. inside: {
  24676. 'function': /^url/i,
  24677. 'punctuation': /^\(|\)$/,
  24678. 'string': {
  24679. pattern: RegExp('^' + string.source + '$'),
  24680. alias: 'url'
  24681. }
  24682. }
  24683. },
  24684. 'selector': {
  24685. pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
  24686. lookbehind: true
  24687. },
  24688. 'string': {
  24689. pattern: string,
  24690. greedy: true
  24691. },
  24692. 'property': {
  24693. pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
  24694. lookbehind: true
  24695. },
  24696. 'important': /!important\b/i,
  24697. 'function': {
  24698. pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
  24699. lookbehind: true
  24700. },
  24701. 'punctuation': /[(){};:,]/
  24702. };
  24703. Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
  24704. var markup = Prism.languages.markup;
  24705. if (markup) {
  24706. markup.tag.addInlined('style', 'css');
  24707. markup.tag.addAttribute('style', 'css');
  24708. }
  24709. }(Prism));
  24710. (function (Prism) {
  24711. var keywords = [
  24712. /\b(?:async|sync|yield)\*/,
  24713. /\b(?:abstract|assert|async|await|break|case|catch|class|const|continue|covariant|default|deferred|do|dynamic|else|enum|export|extends|extension|external|factory|final|finally|for|get|hide|if|implements|import|in|interface|library|mixin|new|null|on|operator|part|rethrow|return|set|show|static|super|switch|sync|this|throw|try|typedef|var|void|while|with|yield)\b/
  24714. ];
  24715. // Handles named imports, such as http.Client
  24716. var packagePrefix = /(^|[^\w.])(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source;
  24717. // based on the dart naming conventions
  24718. var className = {
  24719. pattern: RegExp(packagePrefix + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),
  24720. lookbehind: true,
  24721. inside: {
  24722. 'namespace': {
  24723. pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,
  24724. inside: {
  24725. 'punctuation': /\./
  24726. }
  24727. },
  24728. }
  24729. };
  24730. Prism.languages.dart = Prism.languages.extend('clike', {
  24731. 'class-name': [
  24732. className,
  24733. {
  24734. // variables and parameters
  24735. // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
  24736. pattern: RegExp(packagePrefix + /[A-Z]\w*(?=\s+\w+\s*[;,=()])/.source),
  24737. lookbehind: true,
  24738. inside: className.inside
  24739. }
  24740. ],
  24741. 'keyword': keywords,
  24742. 'operator': /\bis!|\b(?:as|is)\b|\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?/
  24743. });
  24744. Prism.languages.insertBefore('dart', 'string', {
  24745. 'string-literal': {
  24746. pattern: /r?(?:("""|''')[\s\S]*?\1|(["'])(?:\\.|(?!\2)[^\\\r\n])*\2(?!\2))/,
  24747. greedy: true,
  24748. inside: {
  24749. 'interpolation': {
  24750. pattern: /((?:^|[^\\])(?:\\{2})*)\$(?:\w+|\{(?:[^{}]|\{[^{}]*\})*\})/,
  24751. lookbehind: true,
  24752. inside: {
  24753. 'punctuation': /^\$\{?|\}$/,
  24754. 'expression': {
  24755. pattern: /[\s\S]+/,
  24756. inside: Prism.languages.dart
  24757. }
  24758. }
  24759. },
  24760. 'string': /[\s\S]+/
  24761. }
  24762. },
  24763. 'string': undefined
  24764. });
  24765. Prism.languages.insertBefore('dart', 'class-name', {
  24766. 'metadata': {
  24767. pattern: /@\w+/,
  24768. alias: 'function'
  24769. }
  24770. });
  24771. Prism.languages.insertBefore('dart', 'class-name', {
  24772. 'generics': {
  24773. pattern: /<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<[\w\s,.&?]*>)*>)*>)*>/,
  24774. inside: {
  24775. 'class-name': className,
  24776. 'keyword': keywords,
  24777. 'punctuation': /[<>(),.:]/,
  24778. 'operator': /[?&|]/
  24779. }
  24780. },
  24781. });
  24782. }(Prism));
  24783. (function (Prism) {
  24784. Prism.languages.diff = {
  24785. 'coord': [
  24786. // Match all kinds of coord lines (prefixed by "+++", "---" or "***").
  24787. /^(?:\*{3}|-{3}|\+{3}).*$/m,
  24788. // Match "@@ ... @@" coord lines in unified diff.
  24789. /^@@.*@@$/m,
  24790. // Match coord lines in normal diff (starts with a number).
  24791. /^\d.*$/m
  24792. ]
  24793. // deleted, inserted, unchanged, diff
  24794. };
  24795. /**
  24796. * A map from the name of a block to its line prefix.
  24797. *
  24798. * @type {Object<string, string>}
  24799. */
  24800. var PREFIXES = {
  24801. 'deleted-sign': '-',
  24802. 'deleted-arrow': '<',
  24803. 'inserted-sign': '+',
  24804. 'inserted-arrow': '>',
  24805. 'unchanged': ' ',
  24806. 'diff': '!',
  24807. };
  24808. // add a token for each prefix
  24809. Object.keys(PREFIXES).forEach(function (name) {
  24810. var prefix = PREFIXES[name];
  24811. var alias = [];
  24812. if (!/^\w+$/.test(name)) { // "deleted-sign" -> "deleted"
  24813. alias.push(/\w+/.exec(name)[0]);
  24814. }
  24815. if (name === 'diff') {
  24816. alias.push('bold');
  24817. }
  24818. Prism.languages.diff[name] = {
  24819. pattern: RegExp('^(?:[' + prefix + '].*(?:\r\n?|\n|(?![\\s\\S])))+', 'm'),
  24820. alias: alias,
  24821. inside: {
  24822. 'line': {
  24823. pattern: /(.)(?=[\s\S]).*(?:\r\n?|\n)?/,
  24824. lookbehind: true
  24825. },
  24826. 'prefix': {
  24827. pattern: /[\s\S]/,
  24828. alias: /\w+/.exec(name)[0]
  24829. }
  24830. }
  24831. };
  24832. });
  24833. // make prefixes available to Diff plugin
  24834. Object.defineProperty(Prism.languages.diff, 'PREFIXES', {
  24835. value: PREFIXES
  24836. });
  24837. }(Prism));
  24838. (function (Prism) {
  24839. // Many of the following regexes will contain negated lookaheads like `[ \t]+(?![ \t])`. This is a trick to ensure
  24840. // that quantifiers behave *atomically*. Atomic quantifiers are necessary to prevent exponential backtracking.
  24841. var spaceAfterBackSlash = /\\[\r\n](?:\s|\\[\r\n]|#.*(?!.))*(?![\s#]|\\[\r\n])/.source;
  24842. // At least one space, comment, or line break
  24843. var space = /(?:[ \t]+(?![ \t])(?:<SP_BS>)?|<SP_BS>)/.source
  24844. .replace(/<SP_BS>/g, function () { return spaceAfterBackSlash; });
  24845. var string = /"(?:[^"\\\r\n]|\\(?:\r\n|[\s\S]))*"|'(?:[^'\\\r\n]|\\(?:\r\n|[\s\S]))*'/.source;
  24846. var option = /--[\w-]+=(?:<STR>|(?!["'])(?:[^\s\\]|\\.)+)/.source.replace(/<STR>/g, function () { return string; });
  24847. var stringRule = {
  24848. pattern: RegExp(string),
  24849. greedy: true
  24850. };
  24851. var commentRule = {
  24852. pattern: /(^[ \t]*)#.*/m,
  24853. lookbehind: true,
  24854. greedy: true
  24855. };
  24856. /**
  24857. * @param {string} source
  24858. * @param {string} flags
  24859. * @returns {RegExp}
  24860. */
  24861. function re(source, flags) {
  24862. source = source
  24863. .replace(/<OPT>/g, function () { return option; })
  24864. .replace(/<SP>/g, function () { return space; });
  24865. return RegExp(source, flags);
  24866. }
  24867. Prism.languages.docker = {
  24868. 'instruction': {
  24869. pattern: /(^[ \t]*)(?:ADD|ARG|CMD|COPY|ENTRYPOINT|ENV|EXPOSE|FROM|HEALTHCHECK|LABEL|MAINTAINER|ONBUILD|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR)(?=\s)(?:\\.|[^\r\n\\])*(?:\\$(?:\s|#.*$)*(?![\s#])(?:\\.|[^\r\n\\])*)*/im,
  24870. lookbehind: true,
  24871. greedy: true,
  24872. inside: {
  24873. 'options': {
  24874. pattern: re(/(^(?:ONBUILD<SP>)?\w+<SP>)<OPT>(?:<SP><OPT>)*/.source, 'i'),
  24875. lookbehind: true,
  24876. greedy: true,
  24877. inside: {
  24878. 'property': {
  24879. pattern: /(^|\s)--[\w-]+/,
  24880. lookbehind: true
  24881. },
  24882. 'string': [
  24883. stringRule,
  24884. {
  24885. pattern: /(=)(?!["'])(?:[^\s\\]|\\.)+/,
  24886. lookbehind: true
  24887. }
  24888. ],
  24889. 'operator': /\\$/m,
  24890. 'punctuation': /=/
  24891. }
  24892. },
  24893. 'keyword': [
  24894. {
  24895. // https://docs.docker.com/engine/reference/builder/#healthcheck
  24896. pattern: re(/(^(?:ONBUILD<SP>)?HEALTHCHECK<SP>(?:<OPT><SP>)*)(?:CMD|NONE)\b/.source, 'i'),
  24897. lookbehind: true,
  24898. greedy: true
  24899. },
  24900. {
  24901. // https://docs.docker.com/engine/reference/builder/#from
  24902. pattern: re(/(^(?:ONBUILD<SP>)?FROM<SP>(?:<OPT><SP>)*(?!--)[^ \t\\]+<SP>)AS/.source, 'i'),
  24903. lookbehind: true,
  24904. greedy: true
  24905. },
  24906. {
  24907. // https://docs.docker.com/engine/reference/builder/#onbuild
  24908. pattern: re(/(^ONBUILD<SP>)\w+/.source, 'i'),
  24909. lookbehind: true,
  24910. greedy: true
  24911. },
  24912. {
  24913. pattern: /^\w+/,
  24914. greedy: true
  24915. }
  24916. ],
  24917. 'comment': commentRule,
  24918. 'string': stringRule,
  24919. 'variable': /\$(?:\w+|\{[^{}"'\\]*\})/,
  24920. 'operator': /\\$/m
  24921. }
  24922. },
  24923. 'comment': commentRule
  24924. };
  24925. Prism.languages.dockerfile = Prism.languages.docker;
  24926. }(Prism));
  24927. Prism.languages.git = {
  24928. /*
  24929. * A simple one line comment like in a git status command
  24930. * For instance:
  24931. * $ git status
  24932. * # On branch infinite-scroll
  24933. * # Your branch and 'origin/sharedBranches/frontendTeam/infinite-scroll' have diverged,
  24934. * # and have 1 and 2 different commits each, respectively.
  24935. * nothing to commit (working directory clean)
  24936. */
  24937. 'comment': /^#.*/m,
  24938. /*
  24939. * Regexp to match the changed lines in a git diff output. Check the example below.
  24940. */
  24941. 'deleted': /^[-–].*/m,
  24942. 'inserted': /^\+.*/m,
  24943. /*
  24944. * a string (double and simple quote)
  24945. */
  24946. 'string': /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
  24947. /*
  24948. * a git command. It starts with a random prompt finishing by a $, then "git" then some other parameters
  24949. * For instance:
  24950. * $ git add file.txt
  24951. */
  24952. 'command': {
  24953. pattern: /^.*\$ git .*$/m,
  24954. inside: {
  24955. /*
  24956. * A git command can contain a parameter starting by a single or a double dash followed by a string
  24957. * For instance:
  24958. * $ git diff --cached
  24959. * $ git log -p
  24960. */
  24961. 'parameter': /\s--?\w+/
  24962. }
  24963. },
  24964. /*
  24965. * Coordinates displayed in a git diff command
  24966. * For instance:
  24967. * $ git diff
  24968. * diff --git file.txt file.txt
  24969. * index 6214953..1d54a52 100644
  24970. * --- file.txt
  24971. * +++ file.txt
  24972. * @@ -1 +1,2 @@
  24973. * -Here's my tetx file
  24974. * +Here's my text file
  24975. * +And this is the second line
  24976. */
  24977. 'coord': /^@@.*@@$/m,
  24978. /*
  24979. * Match a "commit [SHA1]" line in a git log output.
  24980. * For instance:
  24981. * $ git log
  24982. * commit a11a14ef7e26f2ca62d4b35eac455ce636d0dc09
  24983. * Author: lgiraudel
  24984. * Date: Mon Feb 17 11:18:34 2014 +0100
  24985. *
  24986. * Add of a new line
  24987. */
  24988. 'commit-sha1': /^commit \w{40}$/m
  24989. };
  24990. Prism.languages.glsl = Prism.languages.extend('c', {
  24991. 'keyword': /\b(?:active|asm|atomic_uint|attribute|[ibdu]?vec[234]|bool|break|buffer|case|cast|centroid|class|coherent|common|const|continue|d?mat[234](?:x[234])?|default|discard|do|double|else|enum|extern|external|false|filter|fixed|flat|float|for|fvec[234]|goto|half|highp|hvec[234]|[iu]?sampler2DMS(?:Array)?|[iu]?sampler2DRect|[iu]?samplerBuffer|[iu]?samplerCube|[iu]?samplerCubeArray|[iu]?sampler[123]D|[iu]?sampler[12]DArray|[iu]?image2DMS(?:Array)?|[iu]?image2DRect|[iu]?imageBuffer|[iu]?imageCube|[iu]?imageCubeArray|[iu]?image[123]D|[iu]?image[12]DArray|if|in|inline|inout|input|int|interface|invariant|layout|long|lowp|mediump|namespace|noinline|noperspective|out|output|partition|patch|precise|precision|public|readonly|resource|restrict|return|sample|sampler[12]DArrayShadow|sampler[12]DShadow|sampler2DRectShadow|sampler3DRect|samplerCubeArrayShadow|samplerCubeShadow|shared|short|sizeof|smooth|static|struct|subroutine|superp|switch|template|this|true|typedef|uint|uniform|union|unsigned|using|varying|void|volatile|while|writeonly)\b/
  24992. });
  24993. Prism.languages.go = Prism.languages.extend('clike', {
  24994. 'string': {
  24995. pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,
  24996. lookbehind: true,
  24997. greedy: true
  24998. },
  24999. 'keyword': /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
  25000. 'boolean': /\b(?:_|false|iota|nil|true)\b/,
  25001. 'number': [
  25002. // binary and octal integers
  25003. /\b0(?:b[01_]+|o[0-7_]+)i?\b/i,
  25004. // hexadecimal integers and floats
  25005. /\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,
  25006. // decimal integers and floats
  25007. /(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i
  25008. ],
  25009. 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
  25010. 'builtin': /\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/
  25011. });
  25012. Prism.languages.insertBefore('go', 'string', {
  25013. 'char': {
  25014. pattern: /'(?:\\.|[^'\\\r\n]){0,10}'/,
  25015. greedy: true
  25016. }
  25017. });
  25018. delete Prism.languages.go['class-name'];
  25019. // https://go.dev/ref/mod#go-mod-file-module
  25020. Prism.languages['go-mod'] = Prism.languages['go-module'] = {
  25021. 'comment': {
  25022. pattern: /\/\/.*/,
  25023. greedy: true
  25024. },
  25025. 'version': {
  25026. pattern: /(^|[\s()[\],])v\d+\.\d+\.\d+(?:[+-][-+.\w]*)?(?![^\s()[\],])/,
  25027. lookbehind: true,
  25028. alias: 'number'
  25029. },
  25030. 'go-version': {
  25031. pattern: /((?:^|\s)go\s+)\d+(?:\.\d+){1,2}/,
  25032. lookbehind: true,
  25033. alias: 'number'
  25034. },
  25035. 'keyword': {
  25036. pattern: /^([ \t]*)(?:exclude|go|module|replace|require|retract)\b/m,
  25037. lookbehind: true
  25038. },
  25039. 'operator': /=>/,
  25040. 'punctuation': /[()[\],]/
  25041. };
  25042. (function (Prism) {
  25043. // https://yaml.org/spec/1.2/spec.html#c-ns-anchor-property
  25044. // https://yaml.org/spec/1.2/spec.html#c-ns-alias-node
  25045. var anchorOrAlias = /[*&][^\s[\]{},]+/;
  25046. // https://yaml.org/spec/1.2/spec.html#c-ns-tag-property
  25047. var tag = /!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/;
  25048. // https://yaml.org/spec/1.2/spec.html#c-ns-properties(n,c)
  25049. var properties = '(?:' + tag.source + '(?:[ \t]+' + anchorOrAlias.source + ')?|'
  25050. + anchorOrAlias.source + '(?:[ \t]+' + tag.source + ')?)';
  25051. // https://yaml.org/spec/1.2/spec.html#ns-plain(n,c)
  25052. // This is a simplified version that doesn't support "#" and multiline keys
  25053. // All these long scarry character classes are simplified versions of YAML's characters
  25054. var plainKey = /(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*/.source
  25055. .replace(/<PLAIN>/g, function () { return /[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source; });
  25056. var string = /"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;
  25057. /**
  25058. *
  25059. * @param {string} value
  25060. * @param {string} [flags]
  25061. * @returns {RegExp}
  25062. */
  25063. function createValuePattern(value, flags) {
  25064. flags = (flags || '').replace(/m/g, '') + 'm'; // add m flag
  25065. var pattern = /([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source
  25066. .replace(/<<prop>>/g, function () { return properties; }).replace(/<<value>>/g, function () { return value; });
  25067. return RegExp(pattern, flags);
  25068. }
  25069. Prism.languages.yaml = {
  25070. 'scalar': {
  25071. pattern: RegExp(/([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source
  25072. .replace(/<<prop>>/g, function () { return properties; })),
  25073. lookbehind: true,
  25074. alias: 'string'
  25075. },
  25076. 'comment': /#.*/,
  25077. 'key': {
  25078. pattern: RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source
  25079. .replace(/<<prop>>/g, function () { return properties; })
  25080. .replace(/<<key>>/g, function () { return '(?:' + plainKey + '|' + string + ')'; })),
  25081. lookbehind: true,
  25082. greedy: true,
  25083. alias: 'atrule'
  25084. },
  25085. 'directive': {
  25086. pattern: /(^[ \t]*)%.+/m,
  25087. lookbehind: true,
  25088. alias: 'important'
  25089. },
  25090. 'datetime': {
  25091. pattern: createValuePattern(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),
  25092. lookbehind: true,
  25093. alias: 'number'
  25094. },
  25095. 'boolean': {
  25096. pattern: createValuePattern(/false|true/.source, 'i'),
  25097. lookbehind: true,
  25098. alias: 'important'
  25099. },
  25100. 'null': {
  25101. pattern: createValuePattern(/null|~/.source, 'i'),
  25102. lookbehind: true,
  25103. alias: 'important'
  25104. },
  25105. 'string': {
  25106. pattern: createValuePattern(string),
  25107. lookbehind: true,
  25108. greedy: true
  25109. },
  25110. 'number': {
  25111. pattern: createValuePattern(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source, 'i'),
  25112. lookbehind: true
  25113. },
  25114. 'tag': tag,
  25115. 'important': anchorOrAlias,
  25116. 'punctuation': /---|[:[\]{}\-,|>?]|\.\.\./
  25117. };
  25118. Prism.languages.yml = Prism.languages.yaml;
  25119. }(Prism));
  25120. (function (Prism) {
  25121. // Allow only one line break
  25122. var inner = /(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/.source;
  25123. /**
  25124. * This function is intended for the creation of the bold or italic pattern.
  25125. *
  25126. * This also adds a lookbehind group to the given pattern to ensure that the pattern is not backslash-escaped.
  25127. *
  25128. * _Note:_ Keep in mind that this adds a capturing group.
  25129. *
  25130. * @param {string} pattern
  25131. * @returns {RegExp}
  25132. */
  25133. function createInline(pattern) {
  25134. pattern = pattern.replace(/<inner>/g, function () { return inner; });
  25135. return RegExp(/((?:^|[^\\])(?:\\{2})*)/.source + '(?:' + pattern + ')');
  25136. }
  25137. var tableCell = /(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source;
  25138. var tableRow = /\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g, function () { return tableCell; });
  25139. var tableLine = /\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/.source;
  25140. Prism.languages.markdown = Prism.languages.extend('markup', {});
  25141. Prism.languages.insertBefore('markdown', 'prolog', {
  25142. 'front-matter-block': {
  25143. pattern: /(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,
  25144. lookbehind: true,
  25145. greedy: true,
  25146. inside: {
  25147. 'punctuation': /^---|---$/,
  25148. 'front-matter': {
  25149. pattern: /\S+(?:\s+\S+)*/,
  25150. alias: ['yaml', 'language-yaml'],
  25151. inside: Prism.languages.yaml
  25152. }
  25153. }
  25154. },
  25155. 'blockquote': {
  25156. // > ...
  25157. pattern: /^>(?:[\t ]*>)*/m,
  25158. alias: 'punctuation'
  25159. },
  25160. 'table': {
  25161. pattern: RegExp('^' + tableRow + tableLine + '(?:' + tableRow + ')*', 'm'),
  25162. inside: {
  25163. 'table-data-rows': {
  25164. pattern: RegExp('^(' + tableRow + tableLine + ')(?:' + tableRow + ')*$'),
  25165. lookbehind: true,
  25166. inside: {
  25167. 'table-data': {
  25168. pattern: RegExp(tableCell),
  25169. inside: Prism.languages.markdown
  25170. },
  25171. 'punctuation': /\|/
  25172. }
  25173. },
  25174. 'table-line': {
  25175. pattern: RegExp('^(' + tableRow + ')' + tableLine + '$'),
  25176. lookbehind: true,
  25177. inside: {
  25178. 'punctuation': /\||:?-{3,}:?/
  25179. }
  25180. },
  25181. 'table-header-row': {
  25182. pattern: RegExp('^' + tableRow + '$'),
  25183. inside: {
  25184. 'table-header': {
  25185. pattern: RegExp(tableCell),
  25186. alias: 'important',
  25187. inside: Prism.languages.markdown
  25188. },
  25189. 'punctuation': /\|/
  25190. }
  25191. }
  25192. }
  25193. },
  25194. 'code': [
  25195. {
  25196. // Prefixed by 4 spaces or 1 tab and preceded by an empty line
  25197. pattern: /((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,
  25198. lookbehind: true,
  25199. alias: 'keyword'
  25200. },
  25201. {
  25202. // ```optional language
  25203. // code block
  25204. // ```
  25205. pattern: /^```[\s\S]*?^```$/m,
  25206. greedy: true,
  25207. inside: {
  25208. 'code-block': {
  25209. pattern: /^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,
  25210. lookbehind: true
  25211. },
  25212. 'code-language': {
  25213. pattern: /^(```).+/,
  25214. lookbehind: true
  25215. },
  25216. 'punctuation': /```/
  25217. }
  25218. }
  25219. ],
  25220. 'title': [
  25221. {
  25222. // title 1
  25223. // =======
  25224. // title 2
  25225. // -------
  25226. pattern: /\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,
  25227. alias: 'important',
  25228. inside: {
  25229. punctuation: /==+$|--+$/
  25230. }
  25231. },
  25232. {
  25233. // # title 1
  25234. // ###### title 6
  25235. pattern: /(^\s*)#.+/m,
  25236. lookbehind: true,
  25237. alias: 'important',
  25238. inside: {
  25239. punctuation: /^#+|#+$/
  25240. }
  25241. }
  25242. ],
  25243. 'hr': {
  25244. // ***
  25245. // ---
  25246. // * * *
  25247. // -----------
  25248. pattern: /(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,
  25249. lookbehind: true,
  25250. alias: 'punctuation'
  25251. },
  25252. 'list': {
  25253. // * item
  25254. // + item
  25255. // - item
  25256. // 1. item
  25257. pattern: /(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,
  25258. lookbehind: true,
  25259. alias: 'punctuation'
  25260. },
  25261. 'url-reference': {
  25262. // [id]: http://example.com "Optional title"
  25263. // [id]: http://example.com 'Optional title'
  25264. // [id]: http://example.com (Optional title)
  25265. // [id]: <http://example.com> "Optional title"
  25266. pattern: /!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,
  25267. inside: {
  25268. 'variable': {
  25269. pattern: /^(!?\[)[^\]]+/,
  25270. lookbehind: true
  25271. },
  25272. 'string': /(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,
  25273. 'punctuation': /^[\[\]!:]|[<>]/
  25274. },
  25275. alias: 'url'
  25276. },
  25277. 'bold': {
  25278. // **strong**
  25279. // __strong__
  25280. // allow one nested instance of italic text using the same delimiter
  25281. pattern: createInline(/\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\b|\*\*(?:(?!\*)<inner>|\*(?:(?!\*)<inner>)+\*)+\*\*/.source),
  25282. lookbehind: true,
  25283. greedy: true,
  25284. inside: {
  25285. 'content': {
  25286. pattern: /(^..)[\s\S]+(?=..$)/,
  25287. lookbehind: true,
  25288. inside: {} // see below
  25289. },
  25290. 'punctuation': /\*\*|__/
  25291. }
  25292. },
  25293. 'italic': {
  25294. // *em*
  25295. // _em_
  25296. // allow one nested instance of bold text using the same delimiter
  25297. pattern: createInline(/\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\b|\*(?:(?!\*)<inner>|\*\*(?:(?!\*)<inner>)+\*\*)+\*/.source),
  25298. lookbehind: true,
  25299. greedy: true,
  25300. inside: {
  25301. 'content': {
  25302. pattern: /(^.)[\s\S]+(?=.$)/,
  25303. lookbehind: true,
  25304. inside: {} // see below
  25305. },
  25306. 'punctuation': /[*_]/
  25307. }
  25308. },
  25309. 'strike': {
  25310. // ~~strike through~~
  25311. // ~strike~
  25312. // eslint-disable-next-line regexp/strict
  25313. pattern: createInline(/(~~?)(?:(?!~)<inner>)+\2/.source),
  25314. lookbehind: true,
  25315. greedy: true,
  25316. inside: {
  25317. 'content': {
  25318. pattern: /(^~~?)[\s\S]+(?=\1$)/,
  25319. lookbehind: true,
  25320. inside: {} // see below
  25321. },
  25322. 'punctuation': /~~?/
  25323. }
  25324. },
  25325. 'code-snippet': {
  25326. // `code`
  25327. // ``code``
  25328. pattern: /(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,
  25329. lookbehind: true,
  25330. greedy: true,
  25331. alias: ['code', 'keyword']
  25332. },
  25333. 'url': {
  25334. // [example](http://example.com "Optional title")
  25335. // [example][id]
  25336. // [example] [id]
  25337. pattern: createInline(/!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)|[ \t]?\[(?:(?!\])<inner>)+\])/.source),
  25338. lookbehind: true,
  25339. greedy: true,
  25340. inside: {
  25341. 'operator': /^!/,
  25342. 'content': {
  25343. pattern: /(^\[)[^\]]+(?=\])/,
  25344. lookbehind: true,
  25345. inside: {} // see below
  25346. },
  25347. 'variable': {
  25348. pattern: /(^\][ \t]?\[)[^\]]+(?=\]$)/,
  25349. lookbehind: true
  25350. },
  25351. 'url': {
  25352. pattern: /(^\]\()[^\s)]+/,
  25353. lookbehind: true
  25354. },
  25355. 'string': {
  25356. pattern: /(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,
  25357. lookbehind: true
  25358. }
  25359. }
  25360. }
  25361. });
  25362. ['url', 'bold', 'italic', 'strike'].forEach(function (token) {
  25363. ['url', 'bold', 'italic', 'strike', 'code-snippet'].forEach(function (inside) {
  25364. if (token !== inside) {
  25365. Prism.languages.markdown[token].inside.content.inside[inside] = Prism.languages.markdown[inside];
  25366. }
  25367. });
  25368. });
  25369. Prism.hooks.add('after-tokenize', function (env) {
  25370. if (env.language !== 'markdown' && env.language !== 'md') {
  25371. return;
  25372. }
  25373. function walkTokens(tokens) {
  25374. if (!tokens || typeof tokens === 'string') {
  25375. return;
  25376. }
  25377. for (var i = 0, l = tokens.length; i < l; i++) {
  25378. var token = tokens[i];
  25379. if (token.type !== 'code') {
  25380. walkTokens(token.content);
  25381. continue;
  25382. }
  25383. /*
  25384. * Add the correct `language-xxxx` class to this code block. Keep in mind that the `code-language` token
  25385. * is optional. But the grammar is defined so that there is only one case we have to handle:
  25386. *
  25387. * token.content = [
  25388. * <span class="punctuation">```</span>,
  25389. * <span class="code-language">xxxx</span>,
  25390. * '\n', // exactly one new lines (\r or \n or \r\n)
  25391. * <span class="code-block">...</span>,
  25392. * '\n', // exactly one new lines again
  25393. * <span class="punctuation">```</span>
  25394. * ];
  25395. */
  25396. var codeLang = token.content[1];
  25397. var codeBlock = token.content[3];
  25398. if (codeLang && codeBlock &&
  25399. codeLang.type === 'code-language' && codeBlock.type === 'code-block' &&
  25400. typeof codeLang.content === 'string') {
  25401. // this might be a language that Prism does not support
  25402. // do some replacements to support C++, C#, and F#
  25403. var lang = codeLang.content.replace(/\b#/g, 'sharp').replace(/\b\+\+/g, 'pp');
  25404. // only use the first word
  25405. lang = (/[a-z][\w-]*/i.exec(lang) || [''])[0].toLowerCase();
  25406. var alias = 'language-' + lang;
  25407. // add alias
  25408. if (!codeBlock.alias) {
  25409. codeBlock.alias = [alias];
  25410. } else if (typeof codeBlock.alias === 'string') {
  25411. codeBlock.alias = [codeBlock.alias, alias];
  25412. } else {
  25413. codeBlock.alias.push(alias);
  25414. }
  25415. }
  25416. }
  25417. }
  25418. walkTokens(env.tokens);
  25419. });
  25420. Prism.hooks.add('wrap', function (env) {
  25421. if (env.type !== 'code-block') {
  25422. return;
  25423. }
  25424. var codeLang = '';
  25425. for (var i = 0, l = env.classes.length; i < l; i++) {
  25426. var cls = env.classes[i];
  25427. var match = /language-(.+)/.exec(cls);
  25428. if (match) {
  25429. codeLang = match[1];
  25430. break;
  25431. }
  25432. }
  25433. var grammar = Prism.languages[codeLang];
  25434. if (!grammar) {
  25435. if (codeLang && codeLang !== 'none' && Prism.plugins.autoloader) {
  25436. var id = 'md-' + new Date().valueOf() + '-' + Math.floor(Math.random() * 1e16);
  25437. env.attributes['id'] = id;
  25438. Prism.plugins.autoloader.loadLanguages(codeLang, function () {
  25439. var ele = document.getElementById(id);
  25440. if (ele) {
  25441. ele.innerHTML = Prism.highlight(ele.textContent, Prism.languages[codeLang], codeLang);
  25442. }
  25443. });
  25444. }
  25445. } else {
  25446. env.content = Prism.highlight(textContent(env.content), grammar, codeLang);
  25447. }
  25448. });
  25449. var tagPattern = RegExp(Prism.languages.markup.tag.pattern.source, 'gi');
  25450. /**
  25451. * A list of known entity names.
  25452. *
  25453. * This will always be incomplete to save space. The current list is the one used by lowdash's unescape function.
  25454. *
  25455. * @see {@link https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/unescape.js#L2}
  25456. */
  25457. var KNOWN_ENTITY_NAMES = {
  25458. 'amp': '&',
  25459. 'lt': '<',
  25460. 'gt': '>',
  25461. 'quot': '"',
  25462. };
  25463. // IE 11 doesn't support `String.fromCodePoint`
  25464. var fromCodePoint = String.fromCodePoint || String.fromCharCode;
  25465. /**
  25466. * Returns the text content of a given HTML source code string.
  25467. *
  25468. * @param {string} html
  25469. * @returns {string}
  25470. */
  25471. function textContent(html) {
  25472. // remove all tags
  25473. var text = html.replace(tagPattern, '');
  25474. // decode known entities
  25475. text = text.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi, function (m, code) {
  25476. code = code.toLowerCase();
  25477. if (code[0] === '#') {
  25478. var value;
  25479. if (code[1] === 'x') {
  25480. value = parseInt(code.slice(2), 16);
  25481. } else {
  25482. value = Number(code.slice(1));
  25483. }
  25484. return fromCodePoint(value);
  25485. } else {
  25486. var known = KNOWN_ENTITY_NAMES[code];
  25487. if (known) {
  25488. return known;
  25489. }
  25490. // unable to decode
  25491. return m;
  25492. }
  25493. });
  25494. return text;
  25495. }
  25496. Prism.languages.md = Prism.languages.markdown;
  25497. }(Prism));
  25498. Prism.languages.graphql = {
  25499. 'comment': /#.*/,
  25500. 'description': {
  25501. pattern: /(?:"""(?:[^"]|(?!""")")*"""|"(?:\\.|[^\\"\r\n])*")(?=\s*[a-z_])/i,
  25502. greedy: true,
  25503. alias: 'string',
  25504. inside: {
  25505. 'language-markdown': {
  25506. pattern: /(^"(?:"")?)(?!\1)[\s\S]+(?=\1$)/,
  25507. lookbehind: true,
  25508. inside: Prism.languages.markdown
  25509. }
  25510. }
  25511. },
  25512. 'string': {
  25513. pattern: /"""(?:[^"]|(?!""")")*"""|"(?:\\.|[^\\"\r\n])*"/,
  25514. greedy: true
  25515. },
  25516. 'number': /(?:\B-|\b)\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
  25517. 'boolean': /\b(?:false|true)\b/,
  25518. 'variable': /\$[a-z_]\w*/i,
  25519. 'directive': {
  25520. pattern: /@[a-z_]\w*/i,
  25521. alias: 'function'
  25522. },
  25523. 'attr-name': {
  25524. pattern: /\b[a-z_]\w*(?=\s*(?:\((?:[^()"]|"(?:\\.|[^\\"\r\n])*")*\))?:)/i,
  25525. greedy: true
  25526. },
  25527. 'atom-input': {
  25528. pattern: /\b[A-Z]\w*Input\b/,
  25529. alias: 'class-name'
  25530. },
  25531. 'scalar': /\b(?:Boolean|Float|ID|Int|String)\b/,
  25532. 'constant': /\b[A-Z][A-Z_\d]*\b/,
  25533. 'class-name': {
  25534. pattern: /(\b(?:enum|implements|interface|on|scalar|type|union)\s+|&\s*|:\s*|\[)[A-Z_]\w*/,
  25535. lookbehind: true
  25536. },
  25537. 'fragment': {
  25538. pattern: /(\bfragment\s+|\.{3}\s*(?!on\b))[a-zA-Z_]\w*/,
  25539. lookbehind: true,
  25540. alias: 'function'
  25541. },
  25542. 'definition-mutation': {
  25543. pattern: /(\bmutation\s+)[a-zA-Z_]\w*/,
  25544. lookbehind: true,
  25545. alias: 'function'
  25546. },
  25547. 'definition-query': {
  25548. pattern: /(\bquery\s+)[a-zA-Z_]\w*/,
  25549. lookbehind: true,
  25550. alias: 'function'
  25551. },
  25552. 'keyword': /\b(?:directive|enum|extend|fragment|implements|input|interface|mutation|on|query|repeatable|scalar|schema|subscription|type|union)\b/,
  25553. 'operator': /[!=|&]|\.{3}/,
  25554. 'property-query': /\w+(?=\s*\()/,
  25555. 'object': /\w+(?=\s*\{)/,
  25556. 'punctuation': /[!(){}\[\]:=,]/,
  25557. 'property': /\w+/
  25558. };
  25559. Prism.hooks.add('after-tokenize', function afterTokenizeGraphql(env) {
  25560. if (env.language !== 'graphql') {
  25561. return;
  25562. }
  25563. /**
  25564. * get the graphql token stream that we want to customize
  25565. *
  25566. * @typedef {InstanceType<import("./prism-core")["Token"]>} Token
  25567. * @type {Token[]}
  25568. */
  25569. var validTokens = env.tokens.filter(function (token) {
  25570. return typeof token !== 'string' && token.type !== 'comment' && token.type !== 'scalar';
  25571. });
  25572. var currentIndex = 0;
  25573. /**
  25574. * Returns whether the token relative to the current index has the given type.
  25575. *
  25576. * @param {number} offset
  25577. * @returns {Token | undefined}
  25578. */
  25579. function getToken(offset) {
  25580. return validTokens[currentIndex + offset];
  25581. }
  25582. /**
  25583. * Returns whether the token relative to the current index has the given type.
  25584. *
  25585. * @param {readonly string[]} types
  25586. * @param {number} [offset=0]
  25587. * @returns {boolean}
  25588. */
  25589. function isTokenType(types, offset) {
  25590. offset = offset || 0;
  25591. for (var i = 0; i < types.length; i++) {
  25592. var token = getToken(i + offset);
  25593. if (!token || token.type !== types[i]) {
  25594. return false;
  25595. }
  25596. }
  25597. return true;
  25598. }
  25599. /**
  25600. * Returns the index of the closing bracket to an opening bracket.
  25601. *
  25602. * It is assumed that `token[currentIndex - 1]` is an opening bracket.
  25603. *
  25604. * If no closing bracket could be found, `-1` will be returned.
  25605. *
  25606. * @param {RegExp} open
  25607. * @param {RegExp} close
  25608. * @returns {number}
  25609. */
  25610. function findClosingBracket(open, close) {
  25611. var stackHeight = 1;
  25612. for (var i = currentIndex; i < validTokens.length; i++) {
  25613. var token = validTokens[i];
  25614. var content = token.content;
  25615. if (token.type === 'punctuation' && typeof content === 'string') {
  25616. if (open.test(content)) {
  25617. stackHeight++;
  25618. } else if (close.test(content)) {
  25619. stackHeight--;
  25620. if (stackHeight === 0) {
  25621. return i;
  25622. }
  25623. }
  25624. }
  25625. }
  25626. return -1;
  25627. }
  25628. /**
  25629. * Adds an alias to the given token.
  25630. *
  25631. * @param {Token} token
  25632. * @param {string} alias
  25633. * @returns {void}
  25634. */
  25635. function addAlias(token, alias) {
  25636. var aliases = token.alias;
  25637. if (!aliases) {
  25638. token.alias = aliases = [];
  25639. } else if (!Array.isArray(aliases)) {
  25640. token.alias = aliases = [aliases];
  25641. }
  25642. aliases.push(alias);
  25643. }
  25644. for (; currentIndex < validTokens.length;) {
  25645. var startToken = validTokens[currentIndex++];
  25646. // add special aliases for mutation tokens
  25647. if (startToken.type === 'keyword' && startToken.content === 'mutation') {
  25648. // any array of the names of all input variables (if any)
  25649. var inputVariables = [];
  25650. if (isTokenType(['definition-mutation', 'punctuation']) && getToken(1).content === '(') {
  25651. // definition
  25652. currentIndex += 2; // skip 'definition-mutation' and 'punctuation'
  25653. var definitionEnd = findClosingBracket(/^\($/, /^\)$/);
  25654. if (definitionEnd === -1) {
  25655. continue;
  25656. }
  25657. // find all input variables
  25658. for (; currentIndex < definitionEnd; currentIndex++) {
  25659. var t = getToken(0);
  25660. if (t.type === 'variable') {
  25661. addAlias(t, 'variable-input');
  25662. inputVariables.push(t.content);
  25663. }
  25664. }
  25665. currentIndex = definitionEnd + 1;
  25666. }
  25667. if (isTokenType(['punctuation', 'property-query']) && getToken(0).content === '{') {
  25668. currentIndex++; // skip opening bracket
  25669. addAlias(getToken(0), 'property-mutation');
  25670. if (inputVariables.length > 0) {
  25671. var mutationEnd = findClosingBracket(/^\{$/, /^\}$/);
  25672. if (mutationEnd === -1) {
  25673. continue;
  25674. }
  25675. // give references to input variables a special alias
  25676. for (var i = currentIndex; i < mutationEnd; i++) {
  25677. var varToken = validTokens[i];
  25678. if (varToken.type === 'variable' && inputVariables.indexOf(varToken.content) >= 0) {
  25679. addAlias(varToken, 'variable-input');
  25680. }
  25681. }
  25682. }
  25683. }
  25684. }
  25685. }
  25686. });
  25687. /**
  25688. * Original by Samuel Flores
  25689. *
  25690. * Adds the following new token classes:
  25691. * constant, builtin, variable, symbol, regex
  25692. */
  25693. (function (Prism) {
  25694. Prism.languages.ruby = Prism.languages.extend('clike', {
  25695. 'comment': {
  25696. pattern: /#.*|^=begin\s[\s\S]*?^=end/m,
  25697. greedy: true
  25698. },
  25699. 'class-name': {
  25700. pattern: /(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,
  25701. lookbehind: true,
  25702. inside: {
  25703. 'punctuation': /[.\\]/
  25704. }
  25705. },
  25706. 'keyword': /\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/,
  25707. 'operator': /\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,
  25708. 'punctuation': /[(){}[\].,;]/,
  25709. });
  25710. Prism.languages.insertBefore('ruby', 'operator', {
  25711. 'double-colon': {
  25712. pattern: /::/,
  25713. alias: 'punctuation'
  25714. },
  25715. });
  25716. var interpolation = {
  25717. pattern: /((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,
  25718. lookbehind: true,
  25719. inside: {
  25720. 'content': {
  25721. pattern: /^(#\{)[\s\S]+(?=\}$)/,
  25722. lookbehind: true,
  25723. inside: Prism.languages.ruby
  25724. },
  25725. 'delimiter': {
  25726. pattern: /^#\{|\}$/,
  25727. alias: 'punctuation'
  25728. }
  25729. }
  25730. };
  25731. delete Prism.languages.ruby.function;
  25732. var percentExpression = '(?:' + [
  25733. /([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
  25734. /\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,
  25735. /\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,
  25736. /\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,
  25737. /<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source
  25738. ].join('|') + ')';
  25739. var symbolName = /(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;
  25740. Prism.languages.insertBefore('ruby', 'keyword', {
  25741. 'regex-literal': [
  25742. {
  25743. pattern: RegExp(/%r/.source + percentExpression + /[egimnosux]{0,6}/.source),
  25744. greedy: true,
  25745. inside: {
  25746. 'interpolation': interpolation,
  25747. 'regex': /[\s\S]+/
  25748. }
  25749. },
  25750. {
  25751. pattern: /(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,
  25752. lookbehind: true,
  25753. greedy: true,
  25754. inside: {
  25755. 'interpolation': interpolation,
  25756. 'regex': /[\s\S]+/
  25757. }
  25758. }
  25759. ],
  25760. 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
  25761. 'symbol': [
  25762. {
  25763. pattern: RegExp(/(^|[^:]):/.source + symbolName),
  25764. lookbehind: true,
  25765. greedy: true
  25766. },
  25767. {
  25768. pattern: RegExp(/([\r\n{(,][ \t]*)/.source + symbolName + /(?=:(?!:))/.source),
  25769. lookbehind: true,
  25770. greedy: true
  25771. },
  25772. ],
  25773. 'method-definition': {
  25774. pattern: /(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,
  25775. lookbehind: true,
  25776. inside: {
  25777. 'function': /\b\w+$/,
  25778. 'keyword': /^self\b/,
  25779. 'class-name': /^\w+/,
  25780. 'punctuation': /\./
  25781. }
  25782. }
  25783. });
  25784. Prism.languages.insertBefore('ruby', 'string', {
  25785. 'string-literal': [
  25786. {
  25787. pattern: RegExp(/%[qQiIwWs]?/.source + percentExpression),
  25788. greedy: true,
  25789. inside: {
  25790. 'interpolation': interpolation,
  25791. 'string': /[\s\S]+/
  25792. }
  25793. },
  25794. {
  25795. pattern: /("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,
  25796. greedy: true,
  25797. inside: {
  25798. 'interpolation': interpolation,
  25799. 'string': /[\s\S]+/
  25800. }
  25801. },
  25802. {
  25803. pattern: /<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
  25804. alias: 'heredoc-string',
  25805. greedy: true,
  25806. inside: {
  25807. 'delimiter': {
  25808. pattern: /^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,
  25809. inside: {
  25810. 'symbol': /\b\w+/,
  25811. 'punctuation': /^<<[-~]?/
  25812. }
  25813. },
  25814. 'interpolation': interpolation,
  25815. 'string': /[\s\S]+/
  25816. }
  25817. },
  25818. {
  25819. pattern: /<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
  25820. alias: 'heredoc-string',
  25821. greedy: true,
  25822. inside: {
  25823. 'delimiter': {
  25824. pattern: /^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,
  25825. inside: {
  25826. 'symbol': /\b\w+/,
  25827. 'punctuation': /^<<[-~]?'|'$/,
  25828. }
  25829. },
  25830. 'string': /[\s\S]+/
  25831. }
  25832. }
  25833. ],
  25834. 'command-literal': [
  25835. {
  25836. pattern: RegExp(/%x/.source + percentExpression),
  25837. greedy: true,
  25838. inside: {
  25839. 'interpolation': interpolation,
  25840. 'command': {
  25841. pattern: /[\s\S]+/,
  25842. alias: 'string'
  25843. }
  25844. }
  25845. },
  25846. {
  25847. pattern: /`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,
  25848. greedy: true,
  25849. inside: {
  25850. 'interpolation': interpolation,
  25851. 'command': {
  25852. pattern: /[\s\S]+/,
  25853. alias: 'string'
  25854. }
  25855. }
  25856. }
  25857. ]
  25858. });
  25859. delete Prism.languages.ruby.string;
  25860. Prism.languages.insertBefore('ruby', 'number', {
  25861. 'builtin': /\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,
  25862. 'constant': /\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/
  25863. });
  25864. Prism.languages.rb = Prism.languages.ruby;
  25865. }(Prism));
  25866. (function (Prism) {
  25867. var specialEscape = {
  25868. pattern: /\\[\\(){}[\]^$+*?|.]/,
  25869. alias: 'escape'
  25870. };
  25871. var escape = /\\(?:x[\da-fA-F]{2}|u[\da-fA-F]{4}|u\{[\da-fA-F]+\}|0[0-7]{0,2}|[123][0-7]{2}|c[a-zA-Z]|.)/;
  25872. var charSet = {
  25873. pattern: /\.|\\[wsd]|\\p\{[^{}]+\}/i,
  25874. alias: 'class-name'
  25875. };
  25876. var charSetWithoutDot = {
  25877. pattern: /\\[wsd]|\\p\{[^{}]+\}/i,
  25878. alias: 'class-name'
  25879. };
  25880. var rangeChar = '(?:[^\\\\-]|' + escape.source + ')';
  25881. var range = RegExp(rangeChar + '-' + rangeChar);
  25882. // the name of a capturing group
  25883. var groupName = {
  25884. pattern: /(<|')[^<>']+(?=[>']$)/,
  25885. lookbehind: true,
  25886. alias: 'variable'
  25887. };
  25888. Prism.languages.regex = {
  25889. 'char-class': {
  25890. pattern: /((?:^|[^\\])(?:\\\\)*)\[(?:[^\\\]]|\\[\s\S])*\]/,
  25891. lookbehind: true,
  25892. inside: {
  25893. 'char-class-negation': {
  25894. pattern: /(^\[)\^/,
  25895. lookbehind: true,
  25896. alias: 'operator'
  25897. },
  25898. 'char-class-punctuation': {
  25899. pattern: /^\[|\]$/,
  25900. alias: 'punctuation'
  25901. },
  25902. 'range': {
  25903. pattern: range,
  25904. inside: {
  25905. 'escape': escape,
  25906. 'range-punctuation': {
  25907. pattern: /-/,
  25908. alias: 'operator'
  25909. }
  25910. }
  25911. },
  25912. 'special-escape': specialEscape,
  25913. 'char-set': charSetWithoutDot,
  25914. 'escape': escape
  25915. }
  25916. },
  25917. 'special-escape': specialEscape,
  25918. 'char-set': charSet,
  25919. 'backreference': [
  25920. {
  25921. // a backreference which is not an octal escape
  25922. pattern: /\\(?![123][0-7]{2})[1-9]/,
  25923. alias: 'keyword'
  25924. },
  25925. {
  25926. pattern: /\\k<[^<>']+>/,
  25927. alias: 'keyword',
  25928. inside: {
  25929. 'group-name': groupName
  25930. }
  25931. }
  25932. ],
  25933. 'anchor': {
  25934. pattern: /[$^]|\\[ABbGZz]/,
  25935. alias: 'function'
  25936. },
  25937. 'escape': escape,
  25938. 'group': [
  25939. {
  25940. // https://docs.oracle.com/javase/10/docs/api/java/util/regex/Pattern.html
  25941. // https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference?view=netframework-4.7.2#grouping-constructs
  25942. // (), (?<name>), (?'name'), (?>), (?:), (?=), (?!), (?<=), (?<!), (?is-m), (?i-m:)
  25943. pattern: /\((?:\?(?:<[^<>']+>|'[^<>']+'|[>:]|<?[=!]|[idmnsuxU]+(?:-[idmnsuxU]+)?:?))?/,
  25944. alias: 'punctuation',
  25945. inside: {
  25946. 'group-name': groupName
  25947. }
  25948. },
  25949. {
  25950. pattern: /\)/,
  25951. alias: 'punctuation'
  25952. }
  25953. ],
  25954. 'quantifier': {
  25955. pattern: /(?:[+*?]|\{\d+(?:,\d*)?\})[?+]?/,
  25956. alias: 'number'
  25957. },
  25958. 'alternation': {
  25959. pattern: /\|/,
  25960. alias: 'keyword'
  25961. }
  25962. };
  25963. }(Prism));
  25964. Prism.languages.javascript = Prism.languages.extend('clike', {
  25965. 'class-name': [
  25966. Prism.languages.clike['class-name'],
  25967. {
  25968. pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
  25969. lookbehind: true
  25970. }
  25971. ],
  25972. 'keyword': [
  25973. {
  25974. pattern: /((?:^|\})\s*)catch\b/,
  25975. lookbehind: true
  25976. },
  25977. {
  25978. pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
  25979. lookbehind: true
  25980. },
  25981. ],
  25982. // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
  25983. 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
  25984. 'number': {
  25985. pattern: RegExp(
  25986. /(^|[^\w$])/.source +
  25987. '(?:' +
  25988. (
  25989. // constant
  25990. /NaN|Infinity/.source +
  25991. '|' +
  25992. // binary integer
  25993. /0[bB][01]+(?:_[01]+)*n?/.source +
  25994. '|' +
  25995. // octal integer
  25996. /0[oO][0-7]+(?:_[0-7]+)*n?/.source +
  25997. '|' +
  25998. // hexadecimal integer
  25999. /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source +
  26000. '|' +
  26001. // decimal bigint
  26002. /\d+(?:_\d+)*n/.source +
  26003. '|' +
  26004. // decimal number (integer or float) but no bigint
  26005. /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source
  26006. ) +
  26007. ')' +
  26008. /(?![\w$])/.source
  26009. ),
  26010. lookbehind: true
  26011. },
  26012. 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
  26013. });
  26014. Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
  26015. Prism.languages.insertBefore('javascript', 'keyword', {
  26016. 'regex': {
  26017. pattern: RegExp(
  26018. // lookbehind
  26019. // eslint-disable-next-line regexp/no-dupe-characters-character-class
  26020. /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
  26021. // Regex pattern:
  26022. // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
  26023. // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
  26024. // with the only syntax, so we have to define 2 different regex patterns.
  26025. /\//.source +
  26026. '(?:' +
  26027. /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source +
  26028. '|' +
  26029. // `v` flag syntax. This supports 3 levels of nested character classes.
  26030. /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source +
  26031. ')' +
  26032. // lookahead
  26033. /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
  26034. ),
  26035. lookbehind: true,
  26036. greedy: true,
  26037. inside: {
  26038. 'regex-source': {
  26039. pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
  26040. lookbehind: true,
  26041. alias: 'language-regex',
  26042. inside: Prism.languages.regex
  26043. },
  26044. 'regex-delimiter': /^\/|\/$/,
  26045. 'regex-flags': /^[a-z]+$/,
  26046. }
  26047. },
  26048. // This must be declared before keyword because we use "function" inside the look-forward
  26049. 'function-variable': {
  26050. pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
  26051. alias: 'function'
  26052. },
  26053. 'parameter': [
  26054. {
  26055. pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
  26056. lookbehind: true,
  26057. inside: Prism.languages.javascript
  26058. },
  26059. {
  26060. pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
  26061. lookbehind: true,
  26062. inside: Prism.languages.javascript
  26063. },
  26064. {
  26065. pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
  26066. lookbehind: true,
  26067. inside: Prism.languages.javascript
  26068. },
  26069. {
  26070. pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
  26071. lookbehind: true,
  26072. inside: Prism.languages.javascript
  26073. }
  26074. ],
  26075. 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
  26076. });
  26077. Prism.languages.insertBefore('javascript', 'string', {
  26078. 'hashbang': {
  26079. pattern: /^#!.*/,
  26080. greedy: true,
  26081. alias: 'comment'
  26082. },
  26083. 'template-string': {
  26084. pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
  26085. greedy: true,
  26086. inside: {
  26087. 'template-punctuation': {
  26088. pattern: /^`|`$/,
  26089. alias: 'string'
  26090. },
  26091. 'interpolation': {
  26092. pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
  26093. lookbehind: true,
  26094. inside: {
  26095. 'interpolation-punctuation': {
  26096. pattern: /^\$\{|\}$/,
  26097. alias: 'punctuation'
  26098. },
  26099. rest: Prism.languages.javascript
  26100. }
  26101. },
  26102. 'string': /[\s\S]+/
  26103. }
  26104. },
  26105. 'string-property': {
  26106. pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
  26107. lookbehind: true,
  26108. greedy: true,
  26109. alias: 'property'
  26110. }
  26111. });
  26112. Prism.languages.insertBefore('javascript', 'operator', {
  26113. 'literal-property': {
  26114. pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
  26115. lookbehind: true,
  26116. alias: 'property'
  26117. },
  26118. });
  26119. if (Prism.languages.markup) {
  26120. Prism.languages.markup.tag.addInlined('script', 'javascript');
  26121. // add attribute support for all DOM events.
  26122. // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
  26123. Prism.languages.markup.tag.addAttribute(
  26124. /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
  26125. 'javascript'
  26126. );
  26127. }
  26128. Prism.languages.js = Prism.languages.javascript;
  26129. (function (Prism) {
  26130. /**
  26131. * Returns the placeholder for the given language id and index.
  26132. *
  26133. * @param {string} language
  26134. * @param {string|number} index
  26135. * @returns {string}
  26136. */
  26137. function getPlaceholder(language, index) {
  26138. return '___' + language.toUpperCase() + index + '___';
  26139. }
  26140. Object.defineProperties(Prism.languages['markup-templating'] = {}, {
  26141. buildPlaceholders: {
  26142. /**
  26143. * Tokenize all inline templating expressions matching `placeholderPattern`.
  26144. *
  26145. * If `replaceFilter` is provided, only matches of `placeholderPattern` for which `replaceFilter` returns
  26146. * `true` will be replaced.
  26147. *
  26148. * @param {object} env The environment of the `before-tokenize` hook.
  26149. * @param {string} language The language id.
  26150. * @param {RegExp} placeholderPattern The matches of this pattern will be replaced by placeholders.
  26151. * @param {(match: string) => boolean} [replaceFilter]
  26152. */
  26153. value: function (env, language, placeholderPattern, replaceFilter) {
  26154. if (env.language !== language) {
  26155. return;
  26156. }
  26157. var tokenStack = env.tokenStack = [];
  26158. env.code = env.code.replace(placeholderPattern, function (match) {
  26159. if (typeof replaceFilter === 'function' && !replaceFilter(match)) {
  26160. return match;
  26161. }
  26162. var i = tokenStack.length;
  26163. var placeholder;
  26164. // Check for existing strings
  26165. while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1) {
  26166. ++i;
  26167. }
  26168. // Create a sparse array
  26169. tokenStack[i] = match;
  26170. return placeholder;
  26171. });
  26172. // Switch the grammar to markup
  26173. env.grammar = Prism.languages.markup;
  26174. }
  26175. },
  26176. tokenizePlaceholders: {
  26177. /**
  26178. * Replace placeholders with proper tokens after tokenizing.
  26179. *
  26180. * @param {object} env The environment of the `after-tokenize` hook.
  26181. * @param {string} language The language id.
  26182. */
  26183. value: function (env, language) {
  26184. if (env.language !== language || !env.tokenStack) {
  26185. return;
  26186. }
  26187. // Switch the grammar back
  26188. env.grammar = Prism.languages[language];
  26189. var j = 0;
  26190. var keys = Object.keys(env.tokenStack);
  26191. function walkTokens(tokens) {
  26192. for (var i = 0; i < tokens.length; i++) {
  26193. // all placeholders are replaced already
  26194. if (j >= keys.length) {
  26195. break;
  26196. }
  26197. var token = tokens[i];
  26198. if (typeof token === 'string' || (token.content && typeof token.content === 'string')) {
  26199. var k = keys[j];
  26200. var t = env.tokenStack[k];
  26201. var s = typeof token === 'string' ? token : token.content;
  26202. var placeholder = getPlaceholder(language, k);
  26203. var index = s.indexOf(placeholder);
  26204. if (index > -1) {
  26205. ++j;
  26206. var before = s.substring(0, index);
  26207. var middle = new Prism.Token(language, Prism.tokenize(t, env.grammar), 'language-' + language, t);
  26208. var after = s.substring(index + placeholder.length);
  26209. var replacement = [];
  26210. if (before) {
  26211. replacement.push.apply(replacement, walkTokens([before]));
  26212. }
  26213. replacement.push(middle);
  26214. if (after) {
  26215. replacement.push.apply(replacement, walkTokens([after]));
  26216. }
  26217. if (typeof token === 'string') {
  26218. tokens.splice.apply(tokens, [i, 1].concat(replacement));
  26219. } else {
  26220. token.content = replacement;
  26221. }
  26222. }
  26223. } else if (token.content /* && typeof token.content !== 'string' */) {
  26224. walkTokens(token.content);
  26225. }
  26226. }
  26227. return tokens;
  26228. }
  26229. walkTokens(env.tokens);
  26230. }
  26231. }
  26232. });
  26233. }(Prism));
  26234. /* FIXME :
  26235. :extend() is not handled specifically : its highlighting is buggy.
  26236. Mixin usage must be inside a ruleset to be highlighted.
  26237. At-rules (e.g. import) containing interpolations are buggy.
  26238. Detached rulesets are highlighted as at-rules.
  26239. A comment before a mixin usage prevents the latter to be properly highlighted.
  26240. */
  26241. Prism.languages.less = Prism.languages.extend('css', {
  26242. 'comment': [
  26243. /\/\*[\s\S]*?\*\//,
  26244. {
  26245. pattern: /(^|[^\\])\/\/.*/,
  26246. lookbehind: true
  26247. }
  26248. ],
  26249. 'atrule': {
  26250. pattern: /@[\w-](?:\((?:[^(){}]|\([^(){}]*\))*\)|[^(){};\s]|\s+(?!\s))*?(?=\s*\{)/,
  26251. inside: {
  26252. 'punctuation': /[:()]/
  26253. }
  26254. },
  26255. // selectors and mixins are considered the same
  26256. 'selector': {
  26257. pattern: /(?:@\{[\w-]+\}|[^{};\s@])(?:@\{[\w-]+\}|\((?:[^(){}]|\([^(){}]*\))*\)|[^(){};@\s]|\s+(?!\s))*?(?=\s*\{)/,
  26258. inside: {
  26259. // mixin parameters
  26260. 'variable': /@+[\w-]+/
  26261. }
  26262. },
  26263. 'property': /(?:@\{[\w-]+\}|[\w-])+(?:\+_?)?(?=\s*:)/,
  26264. 'operator': /[+\-*\/]/
  26265. });
  26266. Prism.languages.insertBefore('less', 'property', {
  26267. 'variable': [
  26268. // Variable declaration (the colon must be consumed!)
  26269. {
  26270. pattern: /@[\w-]+\s*:/,
  26271. inside: {
  26272. 'punctuation': /:/
  26273. }
  26274. },
  26275. // Variable usage
  26276. /@@?[\w-]+/
  26277. ],
  26278. 'mixin-usage': {
  26279. pattern: /([{;]\s*)[.#](?!\d)[\w-].*?(?=[(;])/,
  26280. lookbehind: true,
  26281. alias: 'function'
  26282. }
  26283. });
  26284. Prism.languages.scss = Prism.languages.extend('css', {
  26285. 'comment': {
  26286. pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
  26287. lookbehind: true
  26288. },
  26289. 'atrule': {
  26290. pattern: /@[\w-](?:\([^()]+\)|[^()\s]|\s+(?!\s))*?(?=\s+[{;])/,
  26291. inside: {
  26292. 'rule': /@[\w-]+/
  26293. // See rest below
  26294. }
  26295. },
  26296. // url, compassified
  26297. 'url': /(?:[-a-z]+-)?url(?=\()/i,
  26298. // CSS selector regex is not appropriate for Sass
  26299. // since there can be lot more things (var, @ directive, nesting..)
  26300. // a selector must start at the end of a property or after a brace (end of other rules or nesting)
  26301. // it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
  26302. // the end of a selector is found when there is no rules in it ( {} or {\s}) or if there is a property (because an interpolated var
  26303. // can "pass" as a selector- e.g: proper#{$erty})
  26304. // this one was hard to do, so please be careful if you edit this one :)
  26305. 'selector': {
  26306. // Initial look-ahead is used to prevent matching of blank selectors
  26307. pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()\s]|\s+(?!\s)|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}][^:{}]*[:{][^}]))/,
  26308. inside: {
  26309. 'parent': {
  26310. pattern: /&/,
  26311. alias: 'important'
  26312. },
  26313. 'placeholder': /%[-\w]+/,
  26314. 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
  26315. }
  26316. },
  26317. 'property': {
  26318. pattern: /(?:[-\w]|\$[-\w]|#\{\$[-\w]+\})+(?=\s*:)/,
  26319. inside: {
  26320. 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
  26321. }
  26322. }
  26323. });
  26324. Prism.languages.insertBefore('scss', 'atrule', {
  26325. 'keyword': [
  26326. /@(?:content|debug|each|else(?: if)?|extend|for|forward|function|if|import|include|mixin|return|use|warn|while)\b/i,
  26327. {
  26328. pattern: /( )(?:from|through)(?= )/,
  26329. lookbehind: true
  26330. }
  26331. ]
  26332. });
  26333. Prism.languages.insertBefore('scss', 'important', {
  26334. // var and interpolated vars
  26335. 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
  26336. });
  26337. Prism.languages.insertBefore('scss', 'function', {
  26338. 'module-modifier': {
  26339. pattern: /\b(?:as|hide|show|with)\b/i,
  26340. alias: 'keyword'
  26341. },
  26342. 'placeholder': {
  26343. pattern: /%[-\w]+/,
  26344. alias: 'selector'
  26345. },
  26346. 'statement': {
  26347. pattern: /\B!(?:default|optional)\b/i,
  26348. alias: 'keyword'
  26349. },
  26350. 'boolean': /\b(?:false|true)\b/,
  26351. 'null': {
  26352. pattern: /\bnull\b/,
  26353. alias: 'keyword'
  26354. },
  26355. 'operator': {
  26356. pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|not|or)(?=\s)/,
  26357. lookbehind: true
  26358. }
  26359. });
  26360. Prism.languages.scss['atrule'].inside.rest = Prism.languages.scss;
  26361. /* TODO
  26362. Handle multiline code after tag
  26363. %foo= some |
  26364. multiline |
  26365. code |
  26366. */
  26367. (function (Prism) {
  26368. Prism.languages.haml = {
  26369. // Multiline stuff should appear before the rest
  26370. 'multiline-comment': {
  26371. pattern: /((?:^|\r?\n|\r)([\t ]*))(?:\/|-#).*(?:(?:\r?\n|\r)\2[\t ].+)*/,
  26372. lookbehind: true,
  26373. alias: 'comment'
  26374. },
  26375. 'multiline-code': [
  26376. {
  26377. pattern: /((?:^|\r?\n|\r)([\t ]*)(?:[~-]|[&!]?=)).*,[\t ]*(?:(?:\r?\n|\r)\2[\t ].*,[\t ]*)*(?:(?:\r?\n|\r)\2[\t ].+)/,
  26378. lookbehind: true,
  26379. inside: Prism.languages.ruby
  26380. },
  26381. {
  26382. pattern: /((?:^|\r?\n|\r)([\t ]*)(?:[~-]|[&!]?=)).*\|[\t ]*(?:(?:\r?\n|\r)\2[\t ].*\|[\t ]*)*/,
  26383. lookbehind: true,
  26384. inside: Prism.languages.ruby
  26385. }
  26386. ],
  26387. // See at the end of the file for known filters
  26388. 'filter': {
  26389. pattern: /((?:^|\r?\n|\r)([\t ]*)):[\w-]+(?:(?:\r?\n|\r)(?:\2[\t ].+|\s*?(?=\r?\n|\r)))+/,
  26390. lookbehind: true,
  26391. inside: {
  26392. 'filter-name': {
  26393. pattern: /^:[\w-]+/,
  26394. alias: 'symbol'
  26395. }
  26396. }
  26397. },
  26398. 'markup': {
  26399. pattern: /((?:^|\r?\n|\r)[\t ]*)<.+/,
  26400. lookbehind: true,
  26401. inside: Prism.languages.markup
  26402. },
  26403. 'doctype': {
  26404. pattern: /((?:^|\r?\n|\r)[\t ]*)!!!(?: .+)?/,
  26405. lookbehind: true
  26406. },
  26407. 'tag': {
  26408. // Allows for one nested group of braces
  26409. pattern: /((?:^|\r?\n|\r)[\t ]*)[%.#][\w\-#.]*[\w\-](?:\([^)]+\)|\{(?:\{[^}]+\}|[^{}])+\}|\[[^\]]+\])*[\/<>]*/,
  26410. lookbehind: true,
  26411. inside: {
  26412. 'attributes': [
  26413. {
  26414. // Lookbehind tries to prevent interpolations from breaking it all
  26415. // Allows for one nested group of braces
  26416. pattern: /(^|[^#])\{(?:\{[^}]+\}|[^{}])+\}/,
  26417. lookbehind: true,
  26418. inside: Prism.languages.ruby
  26419. },
  26420. {
  26421. pattern: /\([^)]+\)/,
  26422. inside: {
  26423. 'attr-value': {
  26424. pattern: /(=\s*)(?:"(?:\\.|[^\\"\r\n])*"|[^)\s]+)/,
  26425. lookbehind: true
  26426. },
  26427. 'attr-name': /[\w:-]+(?=\s*!?=|\s*[,)])/,
  26428. 'punctuation': /[=(),]/
  26429. }
  26430. },
  26431. {
  26432. pattern: /\[[^\]]+\]/,
  26433. inside: Prism.languages.ruby
  26434. }
  26435. ],
  26436. 'punctuation': /[<>]/
  26437. }
  26438. },
  26439. 'code': {
  26440. pattern: /((?:^|\r?\n|\r)[\t ]*(?:[~-]|[&!]?=)).+/,
  26441. lookbehind: true,
  26442. inside: Prism.languages.ruby
  26443. },
  26444. // Interpolations in plain text
  26445. 'interpolation': {
  26446. pattern: /#\{[^}]+\}/,
  26447. inside: {
  26448. 'delimiter': {
  26449. pattern: /^#\{|\}$/,
  26450. alias: 'punctuation'
  26451. },
  26452. 'ruby': {
  26453. pattern: /[\s\S]+/,
  26454. inside: Prism.languages.ruby
  26455. }
  26456. }
  26457. },
  26458. 'punctuation': {
  26459. pattern: /((?:^|\r?\n|\r)[\t ]*)[~=\-&!]+/,
  26460. lookbehind: true
  26461. }
  26462. };
  26463. var filter_pattern = '((?:^|\\r?\\n|\\r)([\\t ]*)):{{filter_name}}(?:(?:\\r?\\n|\\r)(?:\\2[\\t ].+|\\s*?(?=\\r?\\n|\\r)))+';
  26464. // Non exhaustive list of available filters and associated languages
  26465. var filters = [
  26466. 'css',
  26467. { filter: 'coffee', language: 'coffeescript' },
  26468. 'erb',
  26469. 'javascript',
  26470. 'less',
  26471. 'markdown',
  26472. 'ruby',
  26473. 'scss',
  26474. 'textile'
  26475. ];
  26476. var all_filters = {};
  26477. for (var i = 0, l = filters.length; i < l; i++) {
  26478. var filter = filters[i];
  26479. filter = typeof filter === 'string' ? { filter: filter, language: filter } : filter;
  26480. if (Prism.languages[filter.language]) {
  26481. all_filters['filter-' + filter.filter] = {
  26482. pattern: RegExp(filter_pattern.replace('{{filter_name}}', function () { return filter.filter; })),
  26483. lookbehind: true,
  26484. inside: {
  26485. 'filter-name': {
  26486. pattern: /^:[\w-]+/,
  26487. alias: 'symbol'
  26488. },
  26489. 'text': {
  26490. pattern: /[\s\S]+/,
  26491. alias: [filter.language, 'language-' + filter.language],
  26492. inside: Prism.languages[filter.language]
  26493. }
  26494. }
  26495. };
  26496. }
  26497. }
  26498. Prism.languages.insertBefore('haml', 'filter', all_filters);
  26499. }(Prism));
  26500. Prism.languages.ini = {
  26501. /**
  26502. * The component mimics the behavior of the Win32 API parser.
  26503. *
  26504. * @see {@link https://github.com/PrismJS/prism/issues/2775#issuecomment-787477723}
  26505. */
  26506. 'comment': {
  26507. pattern: /(^[ \f\t\v]*)[#;][^\n\r]*/m,
  26508. lookbehind: true
  26509. },
  26510. 'section': {
  26511. pattern: /(^[ \f\t\v]*)\[[^\n\r\]]*\]?/m,
  26512. lookbehind: true,
  26513. inside: {
  26514. 'section-name': {
  26515. pattern: /(^\[[ \f\t\v]*)[^ \f\t\v\]]+(?:[ \f\t\v]+[^ \f\t\v\]]+)*/,
  26516. lookbehind: true,
  26517. alias: 'selector'
  26518. },
  26519. 'punctuation': /\[|\]/
  26520. }
  26521. },
  26522. 'key': {
  26523. pattern: /(^[ \f\t\v]*)[^ \f\n\r\t\v=]+(?:[ \f\t\v]+[^ \f\n\r\t\v=]+)*(?=[ \f\t\v]*=)/m,
  26524. lookbehind: true,
  26525. alias: 'attr-name'
  26526. },
  26527. 'value': {
  26528. pattern: /(=[ \f\t\v]*)[^ \f\n\r\t\v]+(?:[ \f\t\v]+[^ \f\n\r\t\v]+)*/,
  26529. lookbehind: true,
  26530. alias: 'attr-value',
  26531. inside: {
  26532. 'inner-value': {
  26533. pattern: /^("|').+(?=\1$)/,
  26534. lookbehind: true
  26535. }
  26536. }
  26537. },
  26538. 'punctuation': /=/
  26539. };
  26540. (function (Prism) {
  26541. var keywords = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/;
  26542. // full package (optional) + parent classes (optional)
  26543. var classNamePrefix = /(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source;
  26544. // based on the java naming conventions
  26545. var className = {
  26546. pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),
  26547. lookbehind: true,
  26548. inside: {
  26549. 'namespace': {
  26550. pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,
  26551. inside: {
  26552. 'punctuation': /\./
  26553. }
  26554. },
  26555. 'punctuation': /\./
  26556. }
  26557. };
  26558. Prism.languages.java = Prism.languages.extend('clike', {
  26559. 'string': {
  26560. pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,
  26561. lookbehind: true,
  26562. greedy: true
  26563. },
  26564. 'class-name': [
  26565. className,
  26566. {
  26567. // variables, parameters, and constructor references
  26568. // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
  26569. pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),
  26570. lookbehind: true,
  26571. inside: className.inside
  26572. },
  26573. {
  26574. // class names based on keyword
  26575. // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
  26576. pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + classNamePrefix + /[A-Z]\w*\b/.source),
  26577. lookbehind: true,
  26578. inside: className.inside
  26579. }
  26580. ],
  26581. 'keyword': keywords,
  26582. 'function': [
  26583. Prism.languages.clike.function,
  26584. {
  26585. pattern: /(::\s*)[a-z_]\w*/,
  26586. lookbehind: true
  26587. }
  26588. ],
  26589. 'number': /\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,
  26590. 'operator': {
  26591. pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,
  26592. lookbehind: true
  26593. }
  26594. });
  26595. Prism.languages.insertBefore('java', 'string', {
  26596. 'triple-quoted-string': {
  26597. // http://openjdk.java.net/jeps/355#Description
  26598. pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
  26599. greedy: true,
  26600. alias: 'string'
  26601. },
  26602. 'char': {
  26603. pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/,
  26604. greedy: true
  26605. }
  26606. });
  26607. Prism.languages.insertBefore('java', 'class-name', {
  26608. 'annotation': {
  26609. pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/,
  26610. lookbehind: true,
  26611. alias: 'punctuation'
  26612. },
  26613. 'generics': {
  26614. pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,
  26615. inside: {
  26616. 'class-name': className,
  26617. 'keyword': keywords,
  26618. 'punctuation': /[<>(),.:]/,
  26619. 'operator': /[?&|]/
  26620. }
  26621. },
  26622. 'import': [
  26623. {
  26624. pattern: RegExp(/(\bimport\s+)/.source + classNamePrefix + /(?:[A-Z]\w*|\*)(?=\s*;)/.source),
  26625. lookbehind: true,
  26626. inside: {
  26627. 'namespace': className.inside.namespace,
  26628. 'punctuation': /\./,
  26629. 'operator': /\*/,
  26630. 'class-name': /\w+/
  26631. }
  26632. },
  26633. {
  26634. pattern: RegExp(/(\bimport\s+static\s+)/.source + classNamePrefix + /(?:\w+|\*)(?=\s*;)/.source),
  26635. lookbehind: true,
  26636. alias: 'static',
  26637. inside: {
  26638. 'namespace': className.inside.namespace,
  26639. 'static': /\b\w+$/,
  26640. 'punctuation': /\./,
  26641. 'operator': /\*/,
  26642. 'class-name': /\w+/
  26643. }
  26644. }
  26645. ],
  26646. 'namespace': {
  26647. pattern: RegExp(
  26648. /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/
  26649. .source.replace(/<keyword>/g, function () { return keywords.source; })),
  26650. lookbehind: true,
  26651. inside: {
  26652. 'punctuation': /\./,
  26653. }
  26654. }
  26655. });
  26656. }(Prism));
  26657. // https://www.json.org/json-en.html
  26658. Prism.languages.json = {
  26659. 'property': {
  26660. pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
  26661. lookbehind: true,
  26662. greedy: true
  26663. },
  26664. 'string': {
  26665. pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
  26666. lookbehind: true,
  26667. greedy: true
  26668. },
  26669. 'comment': {
  26670. pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
  26671. greedy: true
  26672. },
  26673. 'number': /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
  26674. 'punctuation': /[{}[\],]/,
  26675. 'operator': /:/,
  26676. 'boolean': /\b(?:false|true)\b/,
  26677. 'null': {
  26678. pattern: /\bnull\b/,
  26679. alias: 'keyword'
  26680. }
  26681. };
  26682. Prism.languages.webmanifest = Prism.languages.json;
  26683. (function (Prism) {
  26684. var string = /("|')(?:\\(?:\r\n?|\n|.)|(?!\1)[^\\\r\n])*\1/;
  26685. Prism.languages.json5 = Prism.languages.extend('json', {
  26686. 'property': [
  26687. {
  26688. pattern: RegExp(string.source + '(?=\\s*:)'),
  26689. greedy: true
  26690. },
  26691. {
  26692. pattern: /(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/,
  26693. alias: 'unquoted'
  26694. }
  26695. ],
  26696. 'string': {
  26697. pattern: string,
  26698. greedy: true
  26699. },
  26700. 'number': /[+-]?\b(?:NaN|Infinity|0x[a-fA-F\d]+)\b|[+-]?(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[eE][+-]?\d+\b)?/
  26701. });
  26702. }(Prism));
  26703. Prism.languages.lua = {
  26704. 'comment': /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,
  26705. // \z may be used to skip the following space
  26706. 'string': {
  26707. pattern: /(["'])(?:(?!\1)[^\\\r\n]|\\z(?:\r\n|\s)|\\(?:\r\n|[^z]))*\1|\[(=*)\[[\s\S]*?\]\2\]/,
  26708. greedy: true
  26709. },
  26710. 'number': /\b0x[a-f\d]+(?:\.[a-f\d]*)?(?:p[+-]?\d+)?\b|\b\d+(?:\.\B|(?:\.\d*)?(?:e[+-]?\d+)?\b)|\B\.\d+(?:e[+-]?\d+)?\b/i,
  26711. 'keyword': /\b(?:and|break|do|else|elseif|end|false|for|function|goto|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/,
  26712. 'function': /(?!\d)\w+(?=\s*(?:[({]))/,
  26713. 'operator': [
  26714. /[-+*%^&|#]|\/\/?|<[<=]?|>[>=]?|[=~]=?/,
  26715. {
  26716. // Match ".." but don't break "..."
  26717. pattern: /(^|[^.])\.\.(?!\.)/,
  26718. lookbehind: true
  26719. }
  26720. ],
  26721. 'punctuation': /[\[\](){},;]|\.+|:+/
  26722. };
  26723. Prism.languages.matlab = {
  26724. 'comment': [
  26725. /%\{[\s\S]*?\}%/,
  26726. /%.+/
  26727. ],
  26728. 'string': {
  26729. pattern: /\B'(?:''|[^'\r\n])*'/,
  26730. greedy: true
  26731. },
  26732. // FIXME We could handle imaginary numbers as a whole
  26733. 'number': /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[eE][+-]?\d+)?(?:[ij])?|\b[ij]\b/,
  26734. 'keyword': /\b(?:NaN|break|case|catch|continue|else|elseif|end|for|function|if|inf|otherwise|parfor|pause|pi|return|switch|try|while)\b/,
  26735. 'function': /\b(?!\d)\w+(?=\s*\()/,
  26736. 'operator': /\.?[*^\/\\']|[+\-:@]|[<>=~]=?|&&?|\|\|?/,
  26737. 'punctuation': /\.{3}|[.,;\[\](){}!]/
  26738. };
  26739. (function (Prism) {
  26740. var operators = [
  26741. // query and projection
  26742. '$eq', '$gt', '$gte', '$in', '$lt', '$lte', '$ne', '$nin', '$and', '$not', '$nor', '$or',
  26743. '$exists', '$type', '$expr', '$jsonSchema', '$mod', '$regex', '$text', '$where', '$geoIntersects',
  26744. '$geoWithin', '$near', '$nearSphere', '$all', '$elemMatch', '$size', '$bitsAllClear', '$bitsAllSet',
  26745. '$bitsAnyClear', '$bitsAnySet', '$comment', '$elemMatch', '$meta', '$slice',
  26746. // update
  26747. '$currentDate', '$inc', '$min', '$max', '$mul', '$rename', '$set', '$setOnInsert', '$unset',
  26748. '$addToSet', '$pop', '$pull', '$push', '$pullAll', '$each', '$position', '$slice', '$sort', '$bit',
  26749. // aggregation pipeline stages
  26750. '$addFields', '$bucket', '$bucketAuto', '$collStats', '$count', '$currentOp', '$facet', '$geoNear',
  26751. '$graphLookup', '$group', '$indexStats', '$limit', '$listLocalSessions', '$listSessions', '$lookup',
  26752. '$match', '$merge', '$out', '$planCacheStats', '$project', '$redact', '$replaceRoot', '$replaceWith',
  26753. '$sample', '$set', '$skip', '$sort', '$sortByCount', '$unionWith', '$unset', '$unwind', '$setWindowFields',
  26754. // aggregation pipeline operators
  26755. '$abs', '$accumulator', '$acos', '$acosh', '$add', '$addToSet', '$allElementsTrue', '$and',
  26756. '$anyElementTrue', '$arrayElemAt', '$arrayToObject', '$asin', '$asinh', '$atan', '$atan2',
  26757. '$atanh', '$avg', '$binarySize', '$bsonSize', '$ceil', '$cmp', '$concat', '$concatArrays', '$cond',
  26758. '$convert', '$cos', '$dateFromParts', '$dateToParts', '$dateFromString', '$dateToString', '$dayOfMonth',
  26759. '$dayOfWeek', '$dayOfYear', '$degreesToRadians', '$divide', '$eq', '$exp', '$filter', '$first',
  26760. '$floor', '$function', '$gt', '$gte', '$hour', '$ifNull', '$in', '$indexOfArray', '$indexOfBytes',
  26761. '$indexOfCP', '$isArray', '$isNumber', '$isoDayOfWeek', '$isoWeek', '$isoWeekYear', '$last',
  26762. '$last', '$let', '$literal', '$ln', '$log', '$log10', '$lt', '$lte', '$ltrim', '$map', '$max',
  26763. '$mergeObjects', '$meta', '$min', '$millisecond', '$minute', '$mod', '$month', '$multiply', '$ne',
  26764. '$not', '$objectToArray', '$or', '$pow', '$push', '$radiansToDegrees', '$range', '$reduce',
  26765. '$regexFind', '$regexFindAll', '$regexMatch', '$replaceOne', '$replaceAll', '$reverseArray', '$round',
  26766. '$rtrim', '$second', '$setDifference', '$setEquals', '$setIntersection', '$setIsSubset', '$setUnion',
  26767. '$size', '$sin', '$slice', '$split', '$sqrt', '$stdDevPop', '$stdDevSamp', '$strcasecmp', '$strLenBytes',
  26768. '$strLenCP', '$substr', '$substrBytes', '$substrCP', '$subtract', '$sum', '$switch', '$tan',
  26769. '$toBool', '$toDate', '$toDecimal', '$toDouble', '$toInt', '$toLong', '$toObjectId', '$toString',
  26770. '$toLower', '$toUpper', '$trim', '$trunc', '$type', '$week', '$year', '$zip', '$count', '$dateAdd',
  26771. '$dateDiff', '$dateSubtract', '$dateTrunc', '$getField', '$rand', '$sampleRate', '$setField', '$unsetField',
  26772. // aggregation pipeline query modifiers
  26773. '$comment', '$explain', '$hint', '$max', '$maxTimeMS', '$min', '$orderby', '$query',
  26774. '$returnKey', '$showDiskLoc', '$natural',
  26775. ];
  26776. var builtinFunctions = [
  26777. 'ObjectId',
  26778. 'Code',
  26779. 'BinData',
  26780. 'DBRef',
  26781. 'Timestamp',
  26782. 'NumberLong',
  26783. 'NumberDecimal',
  26784. 'MaxKey',
  26785. 'MinKey',
  26786. 'RegExp',
  26787. 'ISODate',
  26788. 'UUID',
  26789. ];
  26790. operators = operators.map(function (operator) {
  26791. return operator.replace('$', '\\$');
  26792. });
  26793. var operatorsSource = '(?:' + operators.join('|') + ')\\b';
  26794. Prism.languages.mongodb = Prism.languages.extend('javascript', {});
  26795. Prism.languages.insertBefore('mongodb', 'string', {
  26796. 'property': {
  26797. pattern: /(?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)(?=\s*:)/,
  26798. greedy: true,
  26799. inside: {
  26800. 'keyword': RegExp('^([\'"])?' + operatorsSource + '(?:\\1)?$')
  26801. }
  26802. }
  26803. });
  26804. Prism.languages.mongodb.string.inside = {
  26805. url: {
  26806. // url pattern
  26807. pattern: /https?:\/\/[-\w@:%.+~#=]{1,256}\.[a-z0-9()]{1,6}\b[-\w()@:%+.~#?&/=]*/i,
  26808. greedy: true
  26809. },
  26810. entity: {
  26811. // ipv4
  26812. pattern: /\b(?:(?:[01]?\d\d?|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d\d?|2[0-4]\d|25[0-5])\b/,
  26813. greedy: true
  26814. }
  26815. };
  26816. Prism.languages.insertBefore('mongodb', 'constant', {
  26817. 'builtin': {
  26818. pattern: RegExp('\\b(?:' + builtinFunctions.join('|') + ')\\b'),
  26819. alias: 'keyword'
  26820. }
  26821. });
  26822. }(Prism));
  26823. (function (Prism) {
  26824. var variable = /\$(?:\w[a-z\d]*(?:_[^\x00-\x1F\s"'\\()$]*)?|\{[^}\s"'\\]+\})/i;
  26825. Prism.languages.nginx = {
  26826. 'comment': {
  26827. pattern: /(^|[\s{};])#.*/,
  26828. lookbehind: true,
  26829. greedy: true
  26830. },
  26831. 'directive': {
  26832. pattern: /(^|\s)\w(?:[^;{}"'\\\s]|\\.|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\s+(?:#.*(?!.)|(?![#\s])))*?(?=\s*[;{])/,
  26833. lookbehind: true,
  26834. greedy: true,
  26835. inside: {
  26836. 'string': {
  26837. pattern: /((?:^|[^\\])(?:\\\\)*)(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')/,
  26838. lookbehind: true,
  26839. greedy: true,
  26840. inside: {
  26841. 'escape': {
  26842. pattern: /\\["'\\nrt]/,
  26843. alias: 'entity'
  26844. },
  26845. 'variable': variable
  26846. }
  26847. },
  26848. 'comment': {
  26849. pattern: /(\s)#.*/,
  26850. lookbehind: true,
  26851. greedy: true
  26852. },
  26853. 'keyword': {
  26854. pattern: /^\S+/,
  26855. greedy: true
  26856. },
  26857. // other patterns
  26858. 'boolean': {
  26859. pattern: /(\s)(?:off|on)(?!\S)/,
  26860. lookbehind: true
  26861. },
  26862. 'number': {
  26863. pattern: /(\s)\d+[a-z]*(?!\S)/i,
  26864. lookbehind: true
  26865. },
  26866. 'variable': variable
  26867. }
  26868. },
  26869. 'punctuation': /[{};]/
  26870. };
  26871. }(Prism));
  26872. Prism.languages.objectivec = Prism.languages.extend('c', {
  26873. 'string': {
  26874. pattern: /@?"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
  26875. greedy: true
  26876. },
  26877. 'keyword': /\b(?:asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|in|inline|int|long|register|return|self|short|signed|sizeof|static|struct|super|switch|typedef|typeof|union|unsigned|void|volatile|while)\b|(?:@interface|@end|@implementation|@protocol|@class|@public|@protected|@private|@property|@try|@catch|@finally|@throw|@synthesize|@dynamic|@selector)\b/,
  26878. 'operator': /-[->]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/@]/
  26879. });
  26880. delete Prism.languages.objectivec['class-name'];
  26881. Prism.languages.objc = Prism.languages.objectivec;
  26882. // Based on Free Pascal
  26883. /* TODO
  26884. Support inline asm ?
  26885. */
  26886. Prism.languages.pascal = {
  26887. 'directive': {
  26888. pattern: /\{\$[\s\S]*?\}/,
  26889. greedy: true,
  26890. alias: ['marco', 'property']
  26891. },
  26892. 'comment': {
  26893. pattern: /\(\*[\s\S]*?\*\)|\{[\s\S]*?\}|\/\/.*/,
  26894. greedy: true
  26895. },
  26896. 'string': {
  26897. pattern: /(?:'(?:''|[^'\r\n])*'(?!')|#[&$%]?[a-f\d]+)+|\^[a-z]/i,
  26898. greedy: true
  26899. },
  26900. 'asm': {
  26901. pattern: /(\basm\b)[\s\S]+?(?=\bend\s*[;[])/i,
  26902. lookbehind: true,
  26903. greedy: true,
  26904. inside: null // see below
  26905. },
  26906. 'keyword': [
  26907. {
  26908. // Turbo Pascal
  26909. pattern: /(^|[^&])\b(?:absolute|array|asm|begin|case|const|constructor|destructor|do|downto|else|end|file|for|function|goto|if|implementation|inherited|inline|interface|label|nil|object|of|operator|packed|procedure|program|record|reintroduce|repeat|self|set|string|then|to|type|unit|until|uses|var|while|with)\b/i,
  26910. lookbehind: true
  26911. },
  26912. {
  26913. // Free Pascal
  26914. pattern: /(^|[^&])\b(?:dispose|exit|false|new|true)\b/i,
  26915. lookbehind: true
  26916. },
  26917. {
  26918. // Object Pascal
  26919. pattern: /(^|[^&])\b(?:class|dispinterface|except|exports|finalization|finally|initialization|inline|library|on|out|packed|property|raise|resourcestring|threadvar|try)\b/i,
  26920. lookbehind: true
  26921. },
  26922. {
  26923. // Modifiers
  26924. pattern: /(^|[^&])\b(?:absolute|abstract|alias|assembler|bitpacked|break|cdecl|continue|cppdecl|cvar|default|deprecated|dynamic|enumerator|experimental|export|external|far|far16|forward|generic|helper|implements|index|interrupt|iochecks|local|message|name|near|nodefault|noreturn|nostackframe|oldfpccall|otherwise|overload|override|pascal|platform|private|protected|public|published|read|register|reintroduce|result|safecall|saveregisters|softfloat|specialize|static|stdcall|stored|strict|unaligned|unimplemented|varargs|virtual|write)\b/i,
  26925. lookbehind: true
  26926. }
  26927. ],
  26928. 'number': [
  26929. // Hexadecimal, octal and binary
  26930. /(?:[&%]\d+|\$[a-f\d]+)/i,
  26931. // Decimal
  26932. /\b\d+(?:\.\d+)?(?:e[+-]?\d+)?/i
  26933. ],
  26934. 'operator': [
  26935. /\.\.|\*\*|:=|<[<=>]?|>[>=]?|[+\-*\/]=?|[@^=]/,
  26936. {
  26937. pattern: /(^|[^&])\b(?:and|as|div|exclude|in|include|is|mod|not|or|shl|shr|xor)\b/,
  26938. lookbehind: true
  26939. }
  26940. ],
  26941. 'punctuation': /\(\.|\.\)|[()\[\]:;,.]/
  26942. };
  26943. Prism.languages.pascal.asm.inside = Prism.languages.extend('pascal', {
  26944. 'asm': undefined,
  26945. 'keyword': undefined,
  26946. 'operator': undefined
  26947. });
  26948. Prism.languages.objectpascal = Prism.languages.pascal;
  26949. /**
  26950. * Original by Aaron Harun: http://aahacreative.com/2012/07/31/php-syntax-highlighting-prism/
  26951. * Modified by Miles Johnson: http://milesj.me
  26952. * Rewritten by Tom Pavelec
  26953. *
  26954. * Supports PHP 5.3 - 8.0
  26955. */
  26956. (function (Prism) {
  26957. var comment = /\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/;
  26958. var constant = [
  26959. {
  26960. pattern: /\b(?:false|true)\b/i,
  26961. alias: 'boolean'
  26962. },
  26963. {
  26964. pattern: /(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,
  26965. greedy: true,
  26966. lookbehind: true,
  26967. },
  26968. {
  26969. pattern: /(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,
  26970. greedy: true,
  26971. lookbehind: true,
  26972. },
  26973. /\b(?:null)\b/i,
  26974. /\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/,
  26975. ];
  26976. var number = /\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i;
  26977. var operator = /<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/;
  26978. var punctuation = /[{}\[\](),:;]/;
  26979. Prism.languages.php = {
  26980. 'delimiter': {
  26981. pattern: /\?>$|^<\?(?:php(?=\s)|=)?/i,
  26982. alias: 'important'
  26983. },
  26984. 'comment': comment,
  26985. 'variable': /\$+(?:\w+\b|(?=\{))/,
  26986. 'package': {
  26987. pattern: /(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
  26988. lookbehind: true,
  26989. inside: {
  26990. 'punctuation': /\\/
  26991. }
  26992. },
  26993. 'class-name-definition': {
  26994. pattern: /(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,
  26995. lookbehind: true,
  26996. alias: 'class-name'
  26997. },
  26998. 'function-definition': {
  26999. pattern: /(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,
  27000. lookbehind: true,
  27001. alias: 'function'
  27002. },
  27003. 'keyword': [
  27004. {
  27005. pattern: /(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i,
  27006. alias: 'type-casting',
  27007. greedy: true,
  27008. lookbehind: true
  27009. },
  27010. {
  27011. pattern: /([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i,
  27012. alias: 'type-hint',
  27013. greedy: true,
  27014. lookbehind: true
  27015. },
  27016. {
  27017. pattern: /(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,
  27018. alias: 'return-type',
  27019. greedy: true,
  27020. lookbehind: true
  27021. },
  27022. {
  27023. pattern: /\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,
  27024. alias: 'type-declaration',
  27025. greedy: true
  27026. },
  27027. {
  27028. pattern: /(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,
  27029. alias: 'type-declaration',
  27030. greedy: true,
  27031. lookbehind: true
  27032. },
  27033. {
  27034. pattern: /\b(?:parent|self|static)(?=\s*::)/i,
  27035. alias: 'static-context',
  27036. greedy: true
  27037. },
  27038. {
  27039. // yield from
  27040. pattern: /(\byield\s+)from\b/i,
  27041. lookbehind: true
  27042. },
  27043. // `class` is always a keyword unlike other keywords
  27044. /\bclass\b/i,
  27045. {
  27046. // https://www.php.net/manual/en/reserved.keywords.php
  27047. //
  27048. // keywords cannot be preceded by "->"
  27049. // the complex lookbehind means `(?<!(?:->|::)\s*)`
  27050. pattern: /((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,
  27051. lookbehind: true
  27052. }
  27053. ],
  27054. 'argument-name': {
  27055. pattern: /([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,
  27056. lookbehind: true
  27057. },
  27058. 'class-name': [
  27059. {
  27060. pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,
  27061. greedy: true,
  27062. lookbehind: true
  27063. },
  27064. {
  27065. pattern: /(\|\s*)\b[a-z_]\w*(?!\\)\b/i,
  27066. greedy: true,
  27067. lookbehind: true
  27068. },
  27069. {
  27070. pattern: /\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,
  27071. greedy: true
  27072. },
  27073. {
  27074. pattern: /(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,
  27075. alias: 'class-name-fully-qualified',
  27076. greedy: true,
  27077. lookbehind: true,
  27078. inside: {
  27079. 'punctuation': /\\/
  27080. }
  27081. },
  27082. {
  27083. pattern: /(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,
  27084. alias: 'class-name-fully-qualified',
  27085. greedy: true,
  27086. inside: {
  27087. 'punctuation': /\\/
  27088. }
  27089. },
  27090. {
  27091. pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
  27092. alias: 'class-name-fully-qualified',
  27093. greedy: true,
  27094. lookbehind: true,
  27095. inside: {
  27096. 'punctuation': /\\/
  27097. }
  27098. },
  27099. {
  27100. pattern: /\b[a-z_]\w*(?=\s*\$)/i,
  27101. alias: 'type-declaration',
  27102. greedy: true
  27103. },
  27104. {
  27105. pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
  27106. alias: ['class-name-fully-qualified', 'type-declaration'],
  27107. greedy: true,
  27108. inside: {
  27109. 'punctuation': /\\/
  27110. }
  27111. },
  27112. {
  27113. pattern: /\b[a-z_]\w*(?=\s*::)/i,
  27114. alias: 'static-context',
  27115. greedy: true
  27116. },
  27117. {
  27118. pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,
  27119. alias: ['class-name-fully-qualified', 'static-context'],
  27120. greedy: true,
  27121. inside: {
  27122. 'punctuation': /\\/
  27123. }
  27124. },
  27125. {
  27126. pattern: /([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,
  27127. alias: 'type-hint',
  27128. greedy: true,
  27129. lookbehind: true
  27130. },
  27131. {
  27132. pattern: /([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
  27133. alias: ['class-name-fully-qualified', 'type-hint'],
  27134. greedy: true,
  27135. lookbehind: true,
  27136. inside: {
  27137. 'punctuation': /\\/
  27138. }
  27139. },
  27140. {
  27141. pattern: /(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,
  27142. alias: 'return-type',
  27143. greedy: true,
  27144. lookbehind: true
  27145. },
  27146. {
  27147. pattern: /(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
  27148. alias: ['class-name-fully-qualified', 'return-type'],
  27149. greedy: true,
  27150. lookbehind: true,
  27151. inside: {
  27152. 'punctuation': /\\/
  27153. }
  27154. }
  27155. ],
  27156. 'constant': constant,
  27157. 'function': {
  27158. pattern: /(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,
  27159. lookbehind: true,
  27160. inside: {
  27161. 'punctuation': /\\/
  27162. }
  27163. },
  27164. 'property': {
  27165. pattern: /(->\s*)\w+/,
  27166. lookbehind: true
  27167. },
  27168. 'number': number,
  27169. 'operator': operator,
  27170. 'punctuation': punctuation
  27171. };
  27172. var string_interpolation = {
  27173. pattern: /\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,
  27174. lookbehind: true,
  27175. inside: Prism.languages.php
  27176. };
  27177. var string = [
  27178. {
  27179. pattern: /<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,
  27180. alias: 'nowdoc-string',
  27181. greedy: true,
  27182. inside: {
  27183. 'delimiter': {
  27184. pattern: /^<<<'[^']+'|[a-z_]\w*;$/i,
  27185. alias: 'symbol',
  27186. inside: {
  27187. 'punctuation': /^<<<'?|[';]$/
  27188. }
  27189. }
  27190. }
  27191. },
  27192. {
  27193. pattern: /<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,
  27194. alias: 'heredoc-string',
  27195. greedy: true,
  27196. inside: {
  27197. 'delimiter': {
  27198. pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,
  27199. alias: 'symbol',
  27200. inside: {
  27201. 'punctuation': /^<<<"?|[";]$/
  27202. }
  27203. },
  27204. 'interpolation': string_interpolation
  27205. }
  27206. },
  27207. {
  27208. pattern: /`(?:\\[\s\S]|[^\\`])*`/,
  27209. alias: 'backtick-quoted-string',
  27210. greedy: true
  27211. },
  27212. {
  27213. pattern: /'(?:\\[\s\S]|[^\\'])*'/,
  27214. alias: 'single-quoted-string',
  27215. greedy: true
  27216. },
  27217. {
  27218. pattern: /"(?:\\[\s\S]|[^\\"])*"/,
  27219. alias: 'double-quoted-string',
  27220. greedy: true,
  27221. inside: {
  27222. 'interpolation': string_interpolation
  27223. }
  27224. }
  27225. ];
  27226. Prism.languages.insertBefore('php', 'variable', {
  27227. 'string': string,
  27228. 'attribute': {
  27229. pattern: /#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,
  27230. greedy: true,
  27231. inside: {
  27232. 'attribute-content': {
  27233. pattern: /^(#\[)[\s\S]+(?=\]$)/,
  27234. lookbehind: true,
  27235. // inside can appear subset of php
  27236. inside: {
  27237. 'comment': comment,
  27238. 'string': string,
  27239. 'attribute-class-name': [
  27240. {
  27241. pattern: /([^:]|^)\b[a-z_]\w*(?!\\)\b/i,
  27242. alias: 'class-name',
  27243. greedy: true,
  27244. lookbehind: true
  27245. },
  27246. {
  27247. pattern: /([^:]|^)(?:\\?\b[a-z_]\w*)+/i,
  27248. alias: [
  27249. 'class-name',
  27250. 'class-name-fully-qualified'
  27251. ],
  27252. greedy: true,
  27253. lookbehind: true,
  27254. inside: {
  27255. 'punctuation': /\\/
  27256. }
  27257. }
  27258. ],
  27259. 'constant': constant,
  27260. 'number': number,
  27261. 'operator': operator,
  27262. 'punctuation': punctuation
  27263. }
  27264. },
  27265. 'delimiter': {
  27266. pattern: /^#\[|\]$/,
  27267. alias: 'punctuation'
  27268. }
  27269. }
  27270. },
  27271. });
  27272. Prism.hooks.add('before-tokenize', function (env) {
  27273. if (!/<\?/.test(env.code)) {
  27274. return;
  27275. }
  27276. var phpPattern = /<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g;
  27277. Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern);
  27278. });
  27279. Prism.hooks.add('after-tokenize', function (env) {
  27280. Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
  27281. });
  27282. }(Prism));
  27283. (function (Prism) {
  27284. var builtinTypes = /\b(?:bool|bytes|double|s?fixed(?:32|64)|float|[su]?int(?:32|64)|string)\b/;
  27285. Prism.languages.protobuf = Prism.languages.extend('clike', {
  27286. 'class-name': [
  27287. {
  27288. pattern: /(\b(?:enum|extend|message|service)\s+)[A-Za-z_]\w*(?=\s*\{)/,
  27289. lookbehind: true
  27290. },
  27291. {
  27292. pattern: /(\b(?:rpc\s+\w+|returns)\s*\(\s*(?:stream\s+)?)\.?[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*(?=\s*\))/,
  27293. lookbehind: true
  27294. }
  27295. ],
  27296. 'keyword': /\b(?:enum|extend|extensions|import|message|oneof|option|optional|package|public|repeated|required|reserved|returns|rpc(?=\s+\w)|service|stream|syntax|to)\b(?!\s*=\s*\d)/,
  27297. 'function': /\b[a-z_]\w*(?=\s*\()/i
  27298. });
  27299. Prism.languages.insertBefore('protobuf', 'operator', {
  27300. 'map': {
  27301. pattern: /\bmap<\s*[\w.]+\s*,\s*[\w.]+\s*>(?=\s+[a-z_]\w*\s*[=;])/i,
  27302. alias: 'class-name',
  27303. inside: {
  27304. 'punctuation': /[<>.,]/,
  27305. 'builtin': builtinTypes
  27306. }
  27307. },
  27308. 'builtin': builtinTypes,
  27309. 'positional-class-name': {
  27310. pattern: /(?:\b|\B\.)[a-z_]\w*(?:\.[a-z_]\w*)*(?=\s+[a-z_]\w*\s*[=;])/i,
  27311. alias: 'class-name',
  27312. inside: {
  27313. 'punctuation': /\./
  27314. }
  27315. },
  27316. 'annotation': {
  27317. pattern: /(\[\s*)[a-z_]\w*(?=\s*=)/i,
  27318. lookbehind: true
  27319. }
  27320. });
  27321. }(Prism));
  27322. Prism.languages.python = {
  27323. 'comment': {
  27324. pattern: /(^|[^\\])#.*/,
  27325. lookbehind: true,
  27326. greedy: true
  27327. },
  27328. 'string-interpolation': {
  27329. pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
  27330. greedy: true,
  27331. inside: {
  27332. 'interpolation': {
  27333. // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
  27334. pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
  27335. lookbehind: true,
  27336. inside: {
  27337. 'format-spec': {
  27338. pattern: /(:)[^:(){}]+(?=\}$)/,
  27339. lookbehind: true
  27340. },
  27341. 'conversion-option': {
  27342. pattern: /![sra](?=[:}]$)/,
  27343. alias: 'punctuation'
  27344. },
  27345. rest: null
  27346. }
  27347. },
  27348. 'string': /[\s\S]+/
  27349. }
  27350. },
  27351. 'triple-quoted-string': {
  27352. pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
  27353. greedy: true,
  27354. alias: 'string'
  27355. },
  27356. 'string': {
  27357. pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
  27358. greedy: true
  27359. },
  27360. 'function': {
  27361. pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
  27362. lookbehind: true
  27363. },
  27364. 'class-name': {
  27365. pattern: /(\bclass\s+)\w+/i,
  27366. lookbehind: true
  27367. },
  27368. 'decorator': {
  27369. pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
  27370. lookbehind: true,
  27371. alias: ['annotation', 'punctuation'],
  27372. inside: {
  27373. 'punctuation': /\./
  27374. }
  27375. },
  27376. 'keyword': /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
  27377. 'builtin': /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
  27378. 'boolean': /\b(?:False|None|True)\b/,
  27379. 'number': /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
  27380. 'operator': /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
  27381. 'punctuation': /[{}[\];(),.:]/
  27382. };
  27383. Prism.languages.python['string-interpolation'].inside['interpolation'].inside.rest = Prism.languages.python;
  27384. Prism.languages.py = Prism.languages.python;
  27385. Prism.languages.r = {
  27386. 'comment': /#.*/,
  27387. 'string': {
  27388. pattern: /(['"])(?:\\.|(?!\1)[^\\\r\n])*\1/,
  27389. greedy: true
  27390. },
  27391. 'percent-operator': {
  27392. // Includes user-defined operators
  27393. // and %%, %*%, %/%, %in%, %o%, %x%
  27394. pattern: /%[^%\s]*%/,
  27395. alias: 'operator'
  27396. },
  27397. 'boolean': /\b(?:FALSE|TRUE)\b/,
  27398. 'ellipsis': /\.\.(?:\.|\d+)/,
  27399. 'number': [
  27400. /\b(?:Inf|NaN)\b/,
  27401. /(?:\b0x[\dA-Fa-f]+(?:\.\d*)?|\b\d+(?:\.\d*)?|\B\.\d+)(?:[EePp][+-]?\d+)?[iL]?/
  27402. ],
  27403. 'keyword': /\b(?:NA|NA_character_|NA_complex_|NA_integer_|NA_real_|NULL|break|else|for|function|if|in|next|repeat|while)\b/,
  27404. 'operator': /->?>?|<(?:=|<?-)?|[>=!]=?|::?|&&?|\|\|?|[+*\/^$@~]/,
  27405. 'punctuation': /[(){}\[\],;]/
  27406. };
  27407. (function (Prism) {
  27408. var multilineComment = /\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source;
  27409. for (var i = 0; i < 2; i++) {
  27410. // support 4 levels of nested comments
  27411. multilineComment = multilineComment.replace(/<self>/g, function () { return multilineComment; });
  27412. }
  27413. multilineComment = multilineComment.replace(/<self>/g, function () { return /[^\s\S]/.source; });
  27414. Prism.languages.rust = {
  27415. 'comment': [
  27416. {
  27417. pattern: RegExp(/(^|[^\\])/.source + multilineComment),
  27418. lookbehind: true,
  27419. greedy: true
  27420. },
  27421. {
  27422. pattern: /(^|[^\\:])\/\/.*/,
  27423. lookbehind: true,
  27424. greedy: true
  27425. }
  27426. ],
  27427. 'string': {
  27428. pattern: /b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,
  27429. greedy: true
  27430. },
  27431. 'char': {
  27432. pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,
  27433. greedy: true
  27434. },
  27435. 'attribute': {
  27436. pattern: /#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,
  27437. greedy: true,
  27438. alias: 'attr-name',
  27439. inside: {
  27440. 'string': null // see below
  27441. }
  27442. },
  27443. // Closure params should not be confused with bitwise OR |
  27444. 'closure-params': {
  27445. pattern: /([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,
  27446. lookbehind: true,
  27447. greedy: true,
  27448. inside: {
  27449. 'closure-punctuation': {
  27450. pattern: /^\||\|$/,
  27451. alias: 'punctuation'
  27452. },
  27453. rest: null // see below
  27454. }
  27455. },
  27456. 'lifetime-annotation': {
  27457. pattern: /'\w+/,
  27458. alias: 'symbol'
  27459. },
  27460. 'fragment-specifier': {
  27461. pattern: /(\$\w+:)[a-z]+/,
  27462. lookbehind: true,
  27463. alias: 'punctuation'
  27464. },
  27465. 'variable': /\$\w+/,
  27466. 'function-definition': {
  27467. pattern: /(\bfn\s+)\w+/,
  27468. lookbehind: true,
  27469. alias: 'function'
  27470. },
  27471. 'type-definition': {
  27472. pattern: /(\b(?:enum|struct|trait|type|union)\s+)\w+/,
  27473. lookbehind: true,
  27474. alias: 'class-name'
  27475. },
  27476. 'module-declaration': [
  27477. {
  27478. pattern: /(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,
  27479. lookbehind: true,
  27480. alias: 'namespace'
  27481. },
  27482. {
  27483. pattern: /(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,
  27484. lookbehind: true,
  27485. alias: 'namespace',
  27486. inside: {
  27487. 'punctuation': /::/
  27488. }
  27489. }
  27490. ],
  27491. 'keyword': [
  27492. // https://github.com/rust-lang/reference/blob/master/src/keywords.md
  27493. /\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,
  27494. // primitives and str
  27495. // https://doc.rust-lang.org/stable/rust-by-example/primitives.html
  27496. /\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/
  27497. ],
  27498. // functions can technically start with an upper-case letter, but this will introduce a lot of false positives
  27499. // and Rust's naming conventions recommend snake_case anyway.
  27500. // https://doc.rust-lang.org/1.0.0/style/style/naming/README.html
  27501. 'function': /\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,
  27502. 'macro': {
  27503. pattern: /\b\w+!/,
  27504. alias: 'property'
  27505. },
  27506. 'constant': /\b[A-Z_][A-Z_\d]+\b/,
  27507. 'class-name': /\b[A-Z]\w*\b/,
  27508. 'namespace': {
  27509. pattern: /(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,
  27510. inside: {
  27511. 'punctuation': /::/
  27512. }
  27513. },
  27514. // Hex, oct, bin, dec numbers with visual separators and type suffix
  27515. 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,
  27516. 'boolean': /\b(?:false|true)\b/,
  27517. 'punctuation': /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
  27518. 'operator': /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
  27519. };
  27520. Prism.languages.rust['closure-params'].inside.rest = Prism.languages.rust;
  27521. Prism.languages.rust['attribute'].inside['string'] = Prism.languages.rust['string'];
  27522. }(Prism));
  27523. Prism.languages.sql = {
  27524. 'comment': {
  27525. pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
  27526. lookbehind: true
  27527. },
  27528. 'variable': [
  27529. {
  27530. pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
  27531. greedy: true
  27532. },
  27533. /@[\w.$]+/
  27534. ],
  27535. 'string': {
  27536. pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,
  27537. greedy: true,
  27538. lookbehind: true
  27539. },
  27540. 'identifier': {
  27541. pattern: /(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,
  27542. greedy: true,
  27543. lookbehind: true,
  27544. inside: {
  27545. 'punctuation': /^`|`$/
  27546. }
  27547. },
  27548. 'function': /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i, // Should we highlight user defined functions too?
  27549. 'keyword': /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,
  27550. 'boolean': /\b(?:FALSE|NULL|TRUE)\b/i,
  27551. 'number': /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,
  27552. 'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
  27553. 'punctuation': /[;[\]()`,.]/
  27554. };
  27555. (function (Prism) {
  27556. Prism.languages.typescript = Prism.languages.extend('javascript', {
  27557. 'class-name': {
  27558. pattern: /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,
  27559. lookbehind: true,
  27560. greedy: true,
  27561. inside: null // see below
  27562. },
  27563. 'builtin': /\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/,
  27564. });
  27565. // The keywords TypeScript adds to JavaScript
  27566. Prism.languages.typescript.keyword.push(
  27567. /\b(?:abstract|declare|is|keyof|readonly|require)\b/,
  27568. // keywords that have to be followed by an identifier
  27569. /\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,
  27570. // This is for `import type *, {}`
  27571. /\btype\b(?=\s*(?:[\{*]|$))/
  27572. );
  27573. // doesn't work with TS because TS is too complex
  27574. delete Prism.languages.typescript['parameter'];
  27575. delete Prism.languages.typescript['literal-property'];
  27576. // a version of typescript specifically for highlighting types
  27577. var typeInside = Prism.languages.extend('typescript', {});
  27578. delete typeInside['class-name'];
  27579. Prism.languages.typescript['class-name'].inside = typeInside;
  27580. Prism.languages.insertBefore('typescript', 'function', {
  27581. 'decorator': {
  27582. pattern: /@[$\w\xA0-\uFFFF]+/,
  27583. inside: {
  27584. 'at': {
  27585. pattern: /^@/,
  27586. alias: 'operator'
  27587. },
  27588. 'function': /^[\s\S]+/
  27589. }
  27590. },
  27591. 'generic-function': {
  27592. // e.g. foo<T extends "bar" | "baz">( ...
  27593. pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,
  27594. greedy: true,
  27595. inside: {
  27596. 'function': /^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,
  27597. 'generic': {
  27598. pattern: /<[\s\S]+/, // everything after the first <
  27599. alias: 'class-name',
  27600. inside: typeInside
  27601. }
  27602. }
  27603. }
  27604. });
  27605. Prism.languages.ts = Prism.languages.typescript;
  27606. }(Prism));
  27607. (function (Prism) {
  27608. var javascript = Prism.util.clone(Prism.languages.javascript);
  27609. var space = /(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source;
  27610. var braces = /(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source;
  27611. var spread = /(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;
  27612. /**
  27613. * @param {string} source
  27614. * @param {string} [flags]
  27615. */
  27616. function re(source, flags) {
  27617. source = source
  27618. .replace(/<S>/g, function () { return space; })
  27619. .replace(/<BRACES>/g, function () { return braces; })
  27620. .replace(/<SPREAD>/g, function () { return spread; });
  27621. return RegExp(source, flags);
  27622. }
  27623. spread = re(spread).source;
  27624. Prism.languages.jsx = Prism.languages.extend('markup', javascript);
  27625. Prism.languages.jsx.tag.pattern = re(
  27626. /<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source
  27627. );
  27628. Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/;
  27629. Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/;
  27630. Prism.languages.jsx.tag.inside['tag'].inside['class-name'] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
  27631. Prism.languages.jsx.tag.inside['comment'] = javascript['comment'];
  27632. Prism.languages.insertBefore('inside', 'attr-name', {
  27633. 'spread': {
  27634. pattern: re(/<SPREAD>/.source),
  27635. inside: Prism.languages.jsx
  27636. }
  27637. }, Prism.languages.jsx.tag);
  27638. Prism.languages.insertBefore('inside', 'special-attr', {
  27639. 'script': {
  27640. // Allow for two levels of nesting
  27641. pattern: re(/=<BRACES>/.source),
  27642. alias: 'language-javascript',
  27643. inside: {
  27644. 'script-punctuation': {
  27645. pattern: /^=(?=\{)/,
  27646. alias: 'punctuation'
  27647. },
  27648. rest: Prism.languages.jsx
  27649. },
  27650. }
  27651. }, Prism.languages.jsx.tag);
  27652. // The following will handle plain text inside tags
  27653. var stringifyToken = function (token) {
  27654. if (!token) {
  27655. return '';
  27656. }
  27657. if (typeof token === 'string') {
  27658. return token;
  27659. }
  27660. if (typeof token.content === 'string') {
  27661. return token.content;
  27662. }
  27663. return token.content.map(stringifyToken).join('');
  27664. };
  27665. var walkTokens = function (tokens) {
  27666. var openedTags = [];
  27667. for (var i = 0; i < tokens.length; i++) {
  27668. var token = tokens[i];
  27669. var notTagNorBrace = false;
  27670. if (typeof token !== 'string') {
  27671. if (token.type === 'tag' && token.content[0] && token.content[0].type === 'tag') {
  27672. // We found a tag, now find its kind
  27673. if (token.content[0].content[0].content === '</') {
  27674. // Closing tag
  27675. if (openedTags.length > 0 && openedTags[openedTags.length - 1].tagName === stringifyToken(token.content[0].content[1])) {
  27676. // Pop matching opening tag
  27677. openedTags.pop();
  27678. }
  27679. } else {
  27680. if (token.content[token.content.length - 1].content === '/>') ; else {
  27681. // Opening tag
  27682. openedTags.push({
  27683. tagName: stringifyToken(token.content[0].content[1]),
  27684. openedBraces: 0
  27685. });
  27686. }
  27687. }
  27688. } else if (openedTags.length > 0 && token.type === 'punctuation' && token.content === '{') {
  27689. // Here we might have entered a JSX context inside a tag
  27690. openedTags[openedTags.length - 1].openedBraces++;
  27691. } else if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces > 0 && token.type === 'punctuation' && token.content === '}') {
  27692. // Here we might have left a JSX context inside a tag
  27693. openedTags[openedTags.length - 1].openedBraces--;
  27694. } else {
  27695. notTagNorBrace = true;
  27696. }
  27697. }
  27698. if (notTagNorBrace || typeof token === 'string') {
  27699. if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces === 0) {
  27700. // Here we are inside a tag, and not inside a JSX context.
  27701. // That's plain text: drop any tokens matched.
  27702. var plainText = stringifyToken(token);
  27703. // And merge text with adjacent text
  27704. if (i < tokens.length - 1 && (typeof tokens[i + 1] === 'string' || tokens[i + 1].type === 'plain-text')) {
  27705. plainText += stringifyToken(tokens[i + 1]);
  27706. tokens.splice(i + 1, 1);
  27707. }
  27708. if (i > 0 && (typeof tokens[i - 1] === 'string' || tokens[i - 1].type === 'plain-text')) {
  27709. plainText = stringifyToken(tokens[i - 1]) + plainText;
  27710. tokens.splice(i - 1, 1);
  27711. i--;
  27712. }
  27713. tokens[i] = new Prism.Token('plain-text', plainText, null, plainText);
  27714. }
  27715. }
  27716. if (token.content && typeof token.content !== 'string') {
  27717. walkTokens(token.content);
  27718. }
  27719. }
  27720. };
  27721. Prism.hooks.add('after-tokenize', function (env) {
  27722. if (env.language !== 'jsx' && env.language !== 'tsx') {
  27723. return;
  27724. }
  27725. walkTokens(env.tokens);
  27726. });
  27727. }(Prism));
  27728. (function (Prism) {
  27729. var typescript = Prism.util.clone(Prism.languages.typescript);
  27730. Prism.languages.tsx = Prism.languages.extend('jsx', typescript);
  27731. // doesn't work with TS because TS is too complex
  27732. delete Prism.languages.tsx['parameter'];
  27733. delete Prism.languages.tsx['literal-property'];
  27734. // This will prevent collisions between TSX tags and TS generic types.
  27735. // Idea by https://github.com/karlhorky
  27736. // Discussion: https://github.com/PrismJS/prism/issues/2594#issuecomment-710666928
  27737. var tag = Prism.languages.tsx.tag;
  27738. tag.pattern = RegExp(/(^|[^\w$]|(?=<\/))/.source + '(?:' + tag.pattern.source + ')', tag.pattern.flags);
  27739. tag.lookbehind = true;
  27740. }(Prism));
  27741. (function (Prism) {
  27742. Prism.languages.sass = Prism.languages.extend('css', {
  27743. // Sass comments don't need to be closed, only indented
  27744. 'comment': {
  27745. pattern: /^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t].+)*/m,
  27746. lookbehind: true,
  27747. greedy: true
  27748. }
  27749. });
  27750. Prism.languages.insertBefore('sass', 'atrule', {
  27751. // We want to consume the whole line
  27752. 'atrule-line': {
  27753. // Includes support for = and + shortcuts
  27754. pattern: /^(?:[ \t]*)[@+=].+/m,
  27755. greedy: true,
  27756. inside: {
  27757. 'atrule': /(?:@[\w-]+|[+=])/
  27758. }
  27759. }
  27760. });
  27761. delete Prism.languages.sass.atrule;
  27762. var variable = /\$[-\w]+|#\{\$[-\w]+\}/;
  27763. var operator = [
  27764. /[+*\/%]|[=!]=|<=?|>=?|\b(?:and|not|or)\b/,
  27765. {
  27766. pattern: /(\s)-(?=\s)/,
  27767. lookbehind: true
  27768. }
  27769. ];
  27770. Prism.languages.insertBefore('sass', 'property', {
  27771. // We want to consume the whole line
  27772. 'variable-line': {
  27773. pattern: /^[ \t]*\$.+/m,
  27774. greedy: true,
  27775. inside: {
  27776. 'punctuation': /:/,
  27777. 'variable': variable,
  27778. 'operator': operator
  27779. }
  27780. },
  27781. // We want to consume the whole line
  27782. 'property-line': {
  27783. pattern: /^[ \t]*(?:[^:\s]+ *:.*|:[^:\s].*)/m,
  27784. greedy: true,
  27785. inside: {
  27786. 'property': [
  27787. /[^:\s]+(?=\s*:)/,
  27788. {
  27789. pattern: /(:)[^:\s]+/,
  27790. lookbehind: true
  27791. }
  27792. ],
  27793. 'punctuation': /:/,
  27794. 'variable': variable,
  27795. 'operator': operator,
  27796. 'important': Prism.languages.sass.important
  27797. }
  27798. }
  27799. });
  27800. delete Prism.languages.sass.property;
  27801. delete Prism.languages.sass.important;
  27802. // Now that whole lines for other patterns are consumed,
  27803. // what's left should be selectors
  27804. Prism.languages.insertBefore('sass', 'punctuation', {
  27805. 'selector': {
  27806. pattern: /^([ \t]*)\S(?:,[^,\r\n]+|[^,\r\n]*)(?:,[^,\r\n]+)*(?:,(?:\r?\n|\r)\1[ \t]+\S(?:,[^,\r\n]+|[^,\r\n]*)(?:,[^,\r\n]+)*)*/m,
  27807. lookbehind: true,
  27808. greedy: true
  27809. }
  27810. });
  27811. }(Prism));
  27812. (function (Prism) {
  27813. // $ set | grep '^[A-Z][^[:space:]]*=' | cut -d= -f1 | tr '\n' '|'
  27814. // + LC_ALL, RANDOM, REPLY, SECONDS.
  27815. // + make sure PS1..4 are here as they are not always set,
  27816. // - some useless things.
  27817. var envVars = '\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b';
  27818. var commandAfterHeredoc = {
  27819. pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
  27820. lookbehind: true,
  27821. alias: 'punctuation', // this looks reasonably well in all themes
  27822. inside: null // see below
  27823. };
  27824. var insideString = {
  27825. 'bash': commandAfterHeredoc,
  27826. 'environment': {
  27827. pattern: RegExp('\\$' + envVars),
  27828. alias: 'constant'
  27829. },
  27830. 'variable': [
  27831. // [0]: Arithmetic Environment
  27832. {
  27833. pattern: /\$?\(\([\s\S]+?\)\)/,
  27834. greedy: true,
  27835. inside: {
  27836. // If there is a $ sign at the beginning highlight $(( and )) as variable
  27837. 'variable': [
  27838. {
  27839. pattern: /(^\$\(\([\s\S]+)\)\)/,
  27840. lookbehind: true
  27841. },
  27842. /^\$\(\(/
  27843. ],
  27844. 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
  27845. // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
  27846. 'operator': /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
  27847. // If there is no $ sign at the beginning highlight (( and )) as punctuation
  27848. 'punctuation': /\(\(?|\)\)?|,|;/
  27849. }
  27850. },
  27851. // [1]: Command Substitution
  27852. {
  27853. pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
  27854. greedy: true,
  27855. inside: {
  27856. 'variable': /^\$\(|^`|\)$|`$/
  27857. }
  27858. },
  27859. // [2]: Brace expansion
  27860. {
  27861. pattern: /\$\{[^}]+\}/,
  27862. greedy: true,
  27863. inside: {
  27864. 'operator': /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
  27865. 'punctuation': /[\[\]]/,
  27866. 'environment': {
  27867. pattern: RegExp('(\\{)' + envVars),
  27868. lookbehind: true,
  27869. alias: 'constant'
  27870. }
  27871. }
  27872. },
  27873. /\$(?:\w+|[#?*!@$])/
  27874. ],
  27875. // Escape sequences from echo and printf's manuals, and escaped quotes.
  27876. 'entity': /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/
  27877. };
  27878. Prism.languages.bash = {
  27879. 'shebang': {
  27880. pattern: /^#!\s*\/.*/,
  27881. alias: 'important'
  27882. },
  27883. 'comment': {
  27884. pattern: /(^|[^"{\\$])#.*/,
  27885. lookbehind: true
  27886. },
  27887. 'function-name': [
  27888. // a) function foo {
  27889. // b) foo() {
  27890. // c) function foo() {
  27891. // but not “foo {”
  27892. {
  27893. // a) and c)
  27894. pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
  27895. lookbehind: true,
  27896. alias: 'function'
  27897. },
  27898. {
  27899. // b)
  27900. pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/,
  27901. alias: 'function'
  27902. }
  27903. ],
  27904. // Highlight variable names as variables in for and select beginnings.
  27905. 'for-or-select': {
  27906. pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
  27907. alias: 'variable',
  27908. lookbehind: true
  27909. },
  27910. // Highlight variable names as variables in the left-hand part
  27911. // of assignments (“=” and “+=”).
  27912. 'assign-left': {
  27913. pattern: /(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,
  27914. inside: {
  27915. 'environment': {
  27916. pattern: RegExp('(^|[\\s;|&]|[<>]\\()' + envVars),
  27917. lookbehind: true,
  27918. alias: 'constant'
  27919. }
  27920. },
  27921. alias: 'variable',
  27922. lookbehind: true
  27923. },
  27924. 'string': [
  27925. // Support for Here-documents https://en.wikipedia.org/wiki/Here_document
  27926. {
  27927. pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
  27928. lookbehind: true,
  27929. greedy: true,
  27930. inside: insideString
  27931. },
  27932. // Here-document with quotes around the tag
  27933. // → No expansion (so no “inside”).
  27934. {
  27935. pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
  27936. lookbehind: true,
  27937. greedy: true,
  27938. inside: {
  27939. 'bash': commandAfterHeredoc
  27940. }
  27941. },
  27942. // “Normal” string
  27943. {
  27944. // https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html
  27945. pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
  27946. lookbehind: true,
  27947. greedy: true,
  27948. inside: insideString
  27949. },
  27950. {
  27951. // https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
  27952. pattern: /(^|[^$\\])'[^']*'/,
  27953. lookbehind: true,
  27954. greedy: true
  27955. },
  27956. {
  27957. // https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
  27958. pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
  27959. greedy: true,
  27960. inside: {
  27961. 'entity': insideString.entity
  27962. }
  27963. }
  27964. ],
  27965. 'environment': {
  27966. pattern: RegExp('\\$?' + envVars),
  27967. alias: 'constant'
  27968. },
  27969. 'variable': insideString.variable,
  27970. 'function': {
  27971. pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
  27972. lookbehind: true
  27973. },
  27974. 'keyword': {
  27975. pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,
  27976. lookbehind: true
  27977. },
  27978. // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
  27979. 'builtin': {
  27980. pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,
  27981. lookbehind: true,
  27982. // Alias added to make those easier to distinguish from strings.
  27983. alias: 'class-name'
  27984. },
  27985. 'boolean': {
  27986. pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,
  27987. lookbehind: true
  27988. },
  27989. 'file-descriptor': {
  27990. pattern: /\B&\d\b/,
  27991. alias: 'important'
  27992. },
  27993. 'operator': {
  27994. // Lots of redirections here, but not just that.
  27995. pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
  27996. inside: {
  27997. 'file-descriptor': {
  27998. pattern: /^\d/,
  27999. alias: 'important'
  28000. }
  28001. }
  28002. },
  28003. 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
  28004. 'number': {
  28005. pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
  28006. lookbehind: true
  28007. }
  28008. };
  28009. commandAfterHeredoc.inside = Prism.languages.bash;
  28010. /* Patterns in command substitution. */
  28011. var toBeCopied = [
  28012. 'comment',
  28013. 'function-name',
  28014. 'for-or-select',
  28015. 'assign-left',
  28016. 'string',
  28017. 'environment',
  28018. 'function',
  28019. 'keyword',
  28020. 'builtin',
  28021. 'boolean',
  28022. 'file-descriptor',
  28023. 'operator',
  28024. 'punctuation',
  28025. 'number'
  28026. ];
  28027. var inside = insideString.variable[1].inside;
  28028. for (var i = 0; i < toBeCopied.length; i++) {
  28029. inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]];
  28030. }
  28031. Prism.languages.shell = Prism.languages.bash;
  28032. }(Prism));
  28033. Prism.languages.swift = {
  28034. 'comment': {
  28035. // Nested comments are supported up to 2 levels
  28036. pattern: /(^|[^\\:])(?:\/\/.*|\/\*(?:[^/*]|\/(?!\*)|\*(?!\/)|\/\*(?:[^*]|\*(?!\/))*\*\/)*\*\/)/,
  28037. lookbehind: true,
  28038. greedy: true
  28039. },
  28040. 'string-literal': [
  28041. // https://docs.swift.org/swift-book/LanguageGuide/StringsAndCharacters.html
  28042. {
  28043. pattern: RegExp(
  28044. /(^|[^"#])/.source
  28045. + '(?:'
  28046. // single-line string
  28047. + /"(?:\\(?:\((?:[^()]|\([^()]*\))*\)|\r\n|[^(])|[^\\\r\n"])*"/.source
  28048. + '|'
  28049. // multi-line string
  28050. + /"""(?:\\(?:\((?:[^()]|\([^()]*\))*\)|[^(])|[^\\"]|"(?!""))*"""/.source
  28051. + ')'
  28052. + /(?!["#])/.source
  28053. ),
  28054. lookbehind: true,
  28055. greedy: true,
  28056. inside: {
  28057. 'interpolation': {
  28058. pattern: /(\\\()(?:[^()]|\([^()]*\))*(?=\))/,
  28059. lookbehind: true,
  28060. inside: null // see below
  28061. },
  28062. 'interpolation-punctuation': {
  28063. pattern: /^\)|\\\($/,
  28064. alias: 'punctuation'
  28065. },
  28066. 'punctuation': /\\(?=[\r\n])/,
  28067. 'string': /[\s\S]+/
  28068. }
  28069. },
  28070. {
  28071. pattern: RegExp(
  28072. /(^|[^"#])(#+)/.source
  28073. + '(?:'
  28074. // single-line string
  28075. + /"(?:\\(?:#+\((?:[^()]|\([^()]*\))*\)|\r\n|[^#])|[^\\\r\n])*?"/.source
  28076. + '|'
  28077. // multi-line string
  28078. + /"""(?:\\(?:#+\((?:[^()]|\([^()]*\))*\)|[^#])|[^\\])*?"""/.source
  28079. + ')'
  28080. + '\\2'
  28081. ),
  28082. lookbehind: true,
  28083. greedy: true,
  28084. inside: {
  28085. 'interpolation': {
  28086. pattern: /(\\#+\()(?:[^()]|\([^()]*\))*(?=\))/,
  28087. lookbehind: true,
  28088. inside: null // see below
  28089. },
  28090. 'interpolation-punctuation': {
  28091. pattern: /^\)|\\#+\($/,
  28092. alias: 'punctuation'
  28093. },
  28094. 'string': /[\s\S]+/
  28095. }
  28096. },
  28097. ],
  28098. 'directive': {
  28099. // directives with conditions
  28100. pattern: RegExp(
  28101. /#/.source
  28102. + '(?:'
  28103. + (
  28104. /(?:elseif|if)\b/.source
  28105. + '(?:[ \t]*'
  28106. // This regex is a little complex. It's equivalent to this:
  28107. // (?:![ \t]*)?(?:\b\w+\b(?:[ \t]*<round>)?|<round>)(?:[ \t]*(?:&&|\|\|))?
  28108. // where <round> is a general parentheses expression.
  28109. + /(?:![ \t]*)?(?:\b\w+\b(?:[ \t]*\((?:[^()]|\([^()]*\))*\))?|\((?:[^()]|\([^()]*\))*\))(?:[ \t]*(?:&&|\|\|))?/.source
  28110. + ')+'
  28111. )
  28112. + '|'
  28113. + /(?:else|endif)\b/.source
  28114. + ')'
  28115. ),
  28116. alias: 'property',
  28117. inside: {
  28118. 'directive-name': /^#\w+/,
  28119. 'boolean': /\b(?:false|true)\b/,
  28120. 'number': /\b\d+(?:\.\d+)*\b/,
  28121. 'operator': /!|&&|\|\||[<>]=?/,
  28122. 'punctuation': /[(),]/
  28123. }
  28124. },
  28125. 'literal': {
  28126. pattern: /#(?:colorLiteral|column|dsohandle|file(?:ID|Literal|Path)?|function|imageLiteral|line)\b/,
  28127. alias: 'constant'
  28128. },
  28129. 'other-directive': {
  28130. pattern: /#\w+\b/,
  28131. alias: 'property'
  28132. },
  28133. 'attribute': {
  28134. pattern: /@\w+/,
  28135. alias: 'atrule'
  28136. },
  28137. 'function-definition': {
  28138. pattern: /(\bfunc\s+)\w+/,
  28139. lookbehind: true,
  28140. alias: 'function'
  28141. },
  28142. 'label': {
  28143. // https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html#ID141
  28144. pattern: /\b(break|continue)\s+\w+|\b[a-zA-Z_]\w*(?=\s*:\s*(?:for|repeat|while)\b)/,
  28145. lookbehind: true,
  28146. alias: 'important'
  28147. },
  28148. 'keyword': /\b(?:Any|Protocol|Self|Type|actor|as|assignment|associatedtype|associativity|async|await|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|else|enum|extension|fallthrough|fileprivate|final|for|func|get|guard|higherThan|if|import|in|indirect|infix|init|inout|internal|is|isolated|lazy|left|let|lowerThan|mutating|none|nonisolated|nonmutating|open|operator|optional|override|postfix|precedencegroup|prefix|private|protocol|public|repeat|required|rethrows|return|right|safe|self|set|some|static|struct|subscript|super|switch|throw|throws|try|typealias|unowned|unsafe|var|weak|where|while|willSet)\b/,
  28149. 'boolean': /\b(?:false|true)\b/,
  28150. 'nil': {
  28151. pattern: /\bnil\b/,
  28152. alias: 'constant'
  28153. },
  28154. 'short-argument': /\$\d+\b/,
  28155. 'omit': {
  28156. pattern: /\b_\b/,
  28157. alias: 'keyword'
  28158. },
  28159. 'number': /\b(?:[\d_]+(?:\.[\de_]+)?|0x[a-f0-9_]+(?:\.[a-f0-9p_]+)?|0b[01_]+|0o[0-7_]+)\b/i,
  28160. // A class name must start with an upper-case letter and be either 1 letter long or contain a lower-case letter.
  28161. 'class-name': /\b[A-Z](?:[A-Z_\d]*[a-z]\w*)?\b/,
  28162. 'function': /\b[a-z_]\w*(?=\s*\()/i,
  28163. 'constant': /\b(?:[A-Z_]{2,}|k[A-Z][A-Za-z_]+)\b/,
  28164. // Operators are generic in Swift. Developers can even create new operators (e.g. +++).
  28165. // https://docs.swift.org/swift-book/ReferenceManual/zzSummaryOfTheGrammar.html#ID481
  28166. // This regex only supports ASCII operators.
  28167. 'operator': /[-+*/%=!<>&|^~?]+|\.[.\-+*/%=!<>&|^~?]+/,
  28168. 'punctuation': /[{}[\]();,.:\\]/
  28169. };
  28170. Prism.languages.swift['string-literal'].forEach(function (rule) {
  28171. rule.inside['interpolation'].inside = Prism.languages.swift;
  28172. });
  28173. Prism.languages['visual-basic'] = {
  28174. 'comment': {
  28175. pattern: /(?:['‘’]|REM\b)(?:[^\r\n_]|_(?:\r\n?|\n)?)*/i,
  28176. inside: {
  28177. 'keyword': /^REM/i
  28178. }
  28179. },
  28180. 'directive': {
  28181. pattern: /#(?:Const|Else|ElseIf|End|ExternalChecksum|ExternalSource|If|Region)(?:\b_[ \t]*(?:\r\n?|\n)|.)+/i,
  28182. alias: 'property',
  28183. greedy: true
  28184. },
  28185. 'string': {
  28186. pattern: /\$?["“”](?:["“”]{2}|[^"“”])*["“”]C?/i,
  28187. greedy: true
  28188. },
  28189. 'date': {
  28190. pattern: /#[ \t]*(?:\d+([/-])\d+\1\d+(?:[ \t]+(?:\d+[ \t]*(?:AM|PM)|\d+:\d+(?::\d+)?(?:[ \t]*(?:AM|PM))?))?|\d+[ \t]*(?:AM|PM)|\d+:\d+(?::\d+)?(?:[ \t]*(?:AM|PM))?)[ \t]*#/i,
  28191. alias: 'number'
  28192. },
  28193. 'number': /(?:(?:\b\d+(?:\.\d+)?|\.\d+)(?:E[+-]?\d+)?|&[HO][\dA-F]+)(?:[FRD]|U?[ILS])?/i,
  28194. 'boolean': /\b(?:False|Nothing|True)\b/i,
  28195. 'keyword': /\b(?:AddHandler|AddressOf|Alias|And(?:Also)?|As|Boolean|ByRef|Byte|ByVal|Call|Case|Catch|C(?:Bool|Byte|Char|Date|Dbl|Dec|Int|Lng|Obj|SByte|Short|Sng|Str|Type|UInt|ULng|UShort)|Char|Class|Const|Continue|Currency|Date|Decimal|Declare|Default|Delegate|Dim|DirectCast|Do|Double|Each|Else(?:If)?|End(?:If)?|Enum|Erase|Error|Event|Exit|Finally|For|Friend|Function|Get(?:Type|XMLNamespace)?|Global|GoSub|GoTo|Handles|If|Implements|Imports|In|Inherits|Integer|Interface|Is|IsNot|Let|Lib|Like|Long|Loop|Me|Mod|Module|Must(?:Inherit|Override)|My(?:Base|Class)|Namespace|Narrowing|New|Next|Not(?:Inheritable|Overridable)?|Object|Of|On|Operator|Option(?:al)?|Or(?:Else)?|Out|Overloads|Overridable|Overrides|ParamArray|Partial|Private|Property|Protected|Public|RaiseEvent|ReadOnly|ReDim|RemoveHandler|Resume|Return|SByte|Select|Set|Shadows|Shared|short|Single|Static|Step|Stop|String|Structure|Sub|SyncLock|Then|Throw|To|Try|TryCast|Type|TypeOf|U(?:Integer|Long|Short)|Until|Using|Variant|Wend|When|While|Widening|With(?:Events)?|WriteOnly|Xor)\b/i,
  28196. 'operator': /[+\-*/\\^<=>&#@$%!]|\b_(?=[ \t]*[\r\n])/,
  28197. 'punctuation': /[{}().,:?]/
  28198. };
  28199. Prism.languages.vb = Prism.languages['visual-basic'];
  28200. Prism.languages.vba = Prism.languages['visual-basic'];
  28201. Prism.languages.wasm = {
  28202. 'comment': [
  28203. /\(;[\s\S]*?;\)/,
  28204. {
  28205. pattern: /;;.*/,
  28206. greedy: true
  28207. }
  28208. ],
  28209. 'string': {
  28210. pattern: /"(?:\\[\s\S]|[^"\\])*"/,
  28211. greedy: true
  28212. },
  28213. 'keyword': [
  28214. {
  28215. pattern: /\b(?:align|offset)=/,
  28216. inside: {
  28217. 'operator': /=/
  28218. }
  28219. },
  28220. {
  28221. pattern: /\b(?:(?:f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|neg?|nearest|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|sqrt|store(?:8|16|32)?|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))?|memory\.(?:grow|size))\b/,
  28222. inside: {
  28223. 'punctuation': /\./
  28224. }
  28225. },
  28226. /\b(?:anyfunc|block|br(?:_if|_table)?|call(?:_indirect)?|data|drop|elem|else|end|export|func|get_(?:global|local)|global|if|import|local|loop|memory|module|mut|nop|offset|param|result|return|select|set_(?:global|local)|start|table|tee_local|then|type|unreachable)\b/
  28227. ],
  28228. 'variable': /\$[\w!#$%&'*+\-./:<=>?@\\^`|~]+/,
  28229. 'number': /[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/,
  28230. 'punctuation': /[()]/
  28231. };
  28232. // 预览区域代码块可切换语言功能: https://github.com/Tencent/cherry-markdown/issues/433;
  28233. var CODE_PREVIEWER_LANG_SELECT_CLASS_NAME = 'cherry-code-preview-lang-select';
  28234. /**
  28235. * 生成preview区域的代码语言设置区域
  28236. */
  28237. var getCodePreviewLangSelectElement = function getCodePreviewLangSelectElement(lang) {
  28238. var optionsElement = map$3(codePreviewLangSelectList).call(codePreviewLangSelectList, function (item) {
  28239. var _context2;
  28240. if (lang === item) {
  28241. var _context;
  28242. return concat$5(_context = "<option value=\"".concat(item, "\" selected=\"selected\">")).call(_context, item, "</option>");
  28243. }
  28244. return concat$5(_context2 = "<option value=\"".concat(item, "\">")).call(_context2, item, "</option>");
  28245. });
  28246. return "<select id=\"code-preview-lang-select\" style=\"display:none;\" class=\"".concat(CODE_PREVIEWER_LANG_SELECT_CLASS_NAME, "\">\n <option value=\"\" selected disabled hidden>Choose here</option>\n ").concat(optionsElement.join(''), "\n </select>");
  28247. }; // program language list:
  28248. var codePreviewLangSelectList = ['javascript', 'typescript', 'html', 'css', 'shell', 'python', 'golang', 'java', 'c', 'c++', 'c#', 'php', 'ruby', 'swift', 'kotlin', 'scala', 'rust', 'dart', 'elixir', 'haskell', 'lua', 'perl', 'r', 'sql'];
  28249. function ownKeys$3(object, enumerableOnly) { var keys = keys$3(object); if (getOwnPropertySymbols$2) { var symbols = getOwnPropertySymbols$2(object); enumerableOnly && (symbols = filter$3(symbols).call(symbols, function (sym) { return getOwnPropertyDescriptor$3(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  28250. function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var _context22, _context23; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? forEach$3(_context22 = ownKeys$3(Object(source), !0)).call(_context22, function (key) { _defineProperty(target, key, source[key]); }) : getOwnPropertyDescriptors$2 ? defineProperties$2(target, getOwnPropertyDescriptors$2(source)) : forEach$3(_context23 = ownKeys$3(Object(source))).call(_context23, function (key) { defineProperty$5(target, key, getOwnPropertyDescriptor$3(source, key)); }); } return target; }
  28251. function _createSuper$8(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$8(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  28252. function _isNativeReflectConstruct$8() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  28253. prismCore.manual = true;
  28254. var CUSTOM_WRAPPER = {
  28255. figure: 'figure'
  28256. };
  28257. var CodeBlock = /*#__PURE__*/function (_ParagraphBase) {
  28258. _inherits(CodeBlock, _ParagraphBase);
  28259. var _super = _createSuper$8(CodeBlock);
  28260. function CodeBlock(_ref) {
  28261. var _this;
  28262. var externals = _ref.externals,
  28263. config = _ref.config;
  28264. _classCallCheck(this, CodeBlock);
  28265. _this = _super.call(this, {
  28266. needCache: true
  28267. });
  28268. CodeBlock.inlineCodeCache = {};
  28269. _this.codeCache = {};
  28270. _this.customLang = [];
  28271. _this.customParser = {};
  28272. _this.wrap = config.wrap; // 超出是否换行
  28273. _this.lineNumber = config.lineNumber; // 是否显示行号
  28274. _this.copyCode = config.copyCode; // 是否显示“复制”按钮
  28275. _this.mermaid = config.mermaid; // mermaid的配置,目前仅支持格式设置,svg2img=true 展示成图片,false 展示成svg
  28276. _this.indentedCodeBlock = typeof config.indentedCodeBlock === 'undefined' ? true : config.indentedCodeBlock; // 是否支持缩进代码块
  28277. _this.INLINE_CODE_REGEX = /(`+)(.+?(?:\n.+?)*?)\1/g;
  28278. if (config && config.customRenderer) {
  28279. var _context;
  28280. _this.customLang = map$3(_context = keys$3(config.customRenderer)).call(_context, function (lang) {
  28281. return lang.toLowerCase();
  28282. });
  28283. _this.customParser = _objectSpread$2({}, config.customRenderer);
  28284. }
  28285. _this.customHighlighter = config.highlighter;
  28286. return _this;
  28287. }
  28288. _createClass(CodeBlock, [{
  28289. key: "$codeCache",
  28290. value: function $codeCache(sign, str) {
  28291. if (sign && str) {
  28292. this.codeCache[sign] = str;
  28293. }
  28294. if (this.codeCache[sign]) {
  28295. return this.codeCache[sign];
  28296. }
  28297. if (this.codeCache.length > 40) {
  28298. this.codeCache.length = 0;
  28299. }
  28300. return false;
  28301. } // 渲染特定语言代码块
  28302. }, {
  28303. key: "parseCustomLanguage",
  28304. value: function parseCustomLanguage(lang, codeSrc, props) {
  28305. var _context2, _context3, _context4, _context5, _context6;
  28306. var engine = this.customParser[lang];
  28307. if (!engine || typeof engine.render !== 'function') {
  28308. return false;
  28309. }
  28310. var html = engine.render(codeSrc, props.sign, this.$engine, this.mermaid);
  28311. if (!html) {
  28312. return false;
  28313. }
  28314. var tag = CUSTOM_WRAPPER[engine.constructor.TYPE] || 'div';
  28315. return concat$5(_context2 = concat$5(_context3 = concat$5(_context4 = concat$5(_context5 = concat$5(_context6 = "<".concat(tag, " data-sign=\"")).call(_context6, props.sign, "\" data-type=\"")).call(_context5, lang, "\" data-lines=\"")).call(_context4, props.lines, "\">")).call(_context3, html, "</")).call(_context2, tag, ">");
  28316. } // 修复渲染行号时打散的标签
  28317. }, {
  28318. key: "fillTag",
  28319. value: function fillTag(lines) {
  28320. var tagStack = []; // 存储未闭合标签
  28321. return map$3(lines).call(lines, function (rawLine) {
  28322. if (!rawLine) return '';
  28323. var line = rawLine; // 补全上一行未闭合标签
  28324. while (tagStack.length) {
  28325. var _context7;
  28326. var tag = tagStack.pop();
  28327. line = concat$5(_context7 = "".concat(tag)).call(_context7, line);
  28328. } // 计算未闭合标签
  28329. var tags = line.match(/<span class="(.+?)">|<\/span>/g);
  28330. var close = 0;
  28331. if (!tags) return line;
  28332. while (tags.length) {
  28333. var _tag = tags.pop();
  28334. if (/<\/span>/.test(_tag)) close += 1;else if (!close) {
  28335. tagStack.unshift(_tag.match(/<span class="(.+?)">/)[0]);
  28336. } else {
  28337. close -= 1;
  28338. }
  28339. } // 补全未闭合标签
  28340. for (var i = 0; i < tagStack.length; i++) {
  28341. line = "".concat(line, "</span>");
  28342. }
  28343. return line;
  28344. });
  28345. } // 渲染行号
  28346. }, {
  28347. key: "renderLineNumber",
  28348. value: function renderLineNumber(code) {
  28349. if (!this.lineNumber) return code;
  28350. var codeLines = code.split('\n');
  28351. codeLines.pop(); // 末尾回车不增加行号
  28352. codeLines = this.fillTag(codeLines);
  28353. return "<span class=\"code-line\">".concat(codeLines.join('</span>\n<span class="code-line">'), "</span>");
  28354. }
  28355. /**
  28356. * 判断内置转换语法是否被覆盖
  28357. * @param {string} lang
  28358. */
  28359. }, {
  28360. key: "isInternalCustomLangCovered",
  28361. value: function isInternalCustomLangCovered(lang) {
  28362. var _context8;
  28363. return indexOf$8(_context8 = this.customLang).call(_context8, lang) !== -1;
  28364. }
  28365. /**
  28366. * 预处理代码块
  28367. * @param {string} match
  28368. * @param {string} leadingContent
  28369. * @param {string} code
  28370. */
  28371. }, {
  28372. key: "computeLines",
  28373. value: function computeLines(match, leadingContent, code) {
  28374. var leadingSpaces = leadingContent;
  28375. var lines = this.getLineCount(match, leadingSpaces);
  28376. var sign = this.$engine.md5(match.replace(/^\n+/, '') + lines);
  28377. return {
  28378. sign: sign,
  28379. lines: lines
  28380. };
  28381. }
  28382. /**
  28383. * 补齐用codeBlock承载的mermaid
  28384. * @param {string} $code
  28385. * @param {string} $lang
  28386. */
  28387. }, {
  28388. key: "appendMermaid",
  28389. value: function appendMermaid($code, $lang) {
  28390. var code = $code,
  28391. lang = $lang; // 临时实现流程图、时序图缩略写法
  28392. if (/^flow([ ](TD|LR))?$/i.test(lang) && !this.isInternalCustomLangCovered(lang)) {
  28393. var _context9;
  28394. var suffix = lang.match(/^flow(?:[ ](TD|LR))?$/i) || [];
  28395. code = concat$5(_context9 = "graph ".concat(suffix[1] || 'TD', "\n")).call(_context9, code);
  28396. lang = 'mermaid';
  28397. }
  28398. if (/^seq$/i.test(lang) && !this.isInternalCustomLangCovered(lang)) {
  28399. code = "sequenceDiagram\n".concat(code);
  28400. lang = 'mermaid';
  28401. }
  28402. if (lang === 'mermaid') {
  28403. // 8.4.8版本兼容8.5.2版本的语法
  28404. code = code.replace(/(^[\s]*)stateDiagram-v2\n/, '$1stateDiagram\n'); // code = code.replace(/(^[\s]*)sequenceDiagram[ \t]*\n[\s]*autonumber[ \t]*\n/, '$1sequenceDiagram\n');
  28405. }
  28406. return [code, lang];
  28407. }
  28408. /**
  28409. * 包裹代码块,解决单行代码超出长度
  28410. * @param {string} $code
  28411. * @param {string} lang
  28412. */
  28413. }, {
  28414. key: "wrapCode",
  28415. value: function wrapCode($code, lang) {
  28416. var _context10, _context11;
  28417. return concat$5(_context10 = concat$5(_context11 = "<code class=\"language-".concat(lang)).call(_context11, this.wrap ? ' wrap' : '', "\">")).call(_context10, $code, "</code>");
  28418. }
  28419. /**
  28420. * 使用渲染引擎处理代码块
  28421. * @param {string} $code
  28422. * @param {string} $lang
  28423. * @param {string} sign
  28424. * @param {number} lines
  28425. */
  28426. }, {
  28427. key: "renderCodeBlock",
  28428. value: function renderCodeBlock($code, $lang, sign, lines) {
  28429. var _context12, _context13, _context14, _context15, _context16;
  28430. var cacheCode = $code;
  28431. var lang = $lang;
  28432. if (this.customHighlighter) {
  28433. // 平台自定义代码块样式
  28434. cacheCode = this.customHighlighter(cacheCode, lang);
  28435. } else {
  28436. // 默认使用prism渲染代码块
  28437. if (!lang || !prismCore.languages[lang]) lang = 'javascript'; // 如果没有写语言,默认用js样式渲染
  28438. cacheCode = prismCore.highlight(cacheCode, prismCore.languages[lang], lang);
  28439. cacheCode = this.renderLineNumber(cacheCode);
  28440. }
  28441. cacheCode = concat$5(_context12 = concat$5(_context13 = concat$5(_context14 = concat$5(_context15 = concat$5(_context16 = "<div data-sign=\"".concat(sign, "\" data-type=\"codeBlock\" data-lines=\"")).call(_context16, lines, "\">\n ")).call(_context15, getCodePreviewLangSelectElement($lang), "\n ")).call(_context14, this.copyCode ? '<div class="cherry-copy-code-block" style="display:none;"><i class="ch-icon ch-icon-copy" title="copy"></i></div>' : '', "\n <pre class=\"language-")).call(_context13, lang, "\">")).call(_context12, this.wrapCode(cacheCode, lang), "</pre>\n </div>");
  28442. return cacheCode;
  28443. }
  28444. /**
  28445. * 获取缩进代码块语法的正则
  28446. * 缩进代码块必须要以连续两个以上的换行符开头
  28447. */
  28448. }, {
  28449. key: "$getIndentedCodeReg",
  28450. value: function $getIndentedCodeReg() {
  28451. var ret = {
  28452. begin: '(?:^|\\n\\s*\\n)(?: {4}|\\t)',
  28453. end: '(?=$|\\n( {0,3}[^ \\t\\n]|\\n[^ \\t\\n]))',
  28454. content: '([\\s\\S]+?)'
  28455. };
  28456. return new RegExp(ret.begin + ret.content + ret.end, 'g');
  28457. }
  28458. /**
  28459. * 生成缩进代码块(没有行号、没有代码高亮)
  28460. */
  28461. }, {
  28462. key: "$getIndentCodeBlock",
  28463. value: function $getIndentCodeBlock(str) {
  28464. var _this2 = this;
  28465. if (!this.indentedCodeBlock) {
  28466. return str;
  28467. }
  28468. return this.$recoverCodeInIndent(str).replace(this.$getIndentedCodeReg(), function (match, code) {
  28469. var _context17, _context18;
  28470. var lineCount = (match.match(/\n/g) || []).length;
  28471. var sign = _this2.$engine.md5(match);
  28472. var html = concat$5(_context17 = concat$5(_context18 = "<pre data-sign=\"".concat(sign, "\" data-lines=\"")).call(_context18, lineCount, "\"><code>")).call(_context17, escapeHTMLSpecialChar(code.replace(/\n( {4}|\t)/g, '\n')), "</code></pre>"); // return this.getCacheWithSpace(this.pushCache(html), match, true);
  28473. return prependLineFeedForParagraph(match, _this2.pushCache(html, sign, lineCount));
  28474. });
  28475. }
  28476. /**
  28477. * 预处理缩进代码块,将缩进代码块里的高亮代码块和行内代码进行占位处理
  28478. */
  28479. }, {
  28480. key: "$replaceCodeInIndent",
  28481. value: function $replaceCodeInIndent(str) {
  28482. if (!this.indentedCodeBlock) {
  28483. return str;
  28484. }
  28485. return str.replace(this.$getIndentedCodeReg(), function (match) {
  28486. return match.replace(/`/g, '~~~IndentCode');
  28487. });
  28488. }
  28489. /**
  28490. * 恢复预处理的内容
  28491. */
  28492. }, {
  28493. key: "$recoverCodeInIndent",
  28494. value: function $recoverCodeInIndent(str) {
  28495. if (!this.indentedCodeBlock) {
  28496. return str;
  28497. }
  28498. return str.replace(this.$getIndentedCodeReg(), function (match) {
  28499. return match.replace(/~~~IndentCode/g, '`');
  28500. });
  28501. }
  28502. }, {
  28503. key: "beforeMakeHtml",
  28504. value: function beforeMakeHtml(str, sentenceMakeFunc, markdownParams) {
  28505. var _this3 = this;
  28506. var $str = str; // 预处理缩进代码块
  28507. $str = this.$replaceCodeInIndent($str);
  28508. $str = $str.replace(this.RULE.reg, function (match, leadingContent, leadingContentBlockQuote, begin, lang, code) {
  28509. var _leadingContent$match, _leadingContent$match2, _context20;
  28510. function addBlockQuoteSignToResult(result) {
  28511. if (leadingContentBlockQuote) {
  28512. var regex = new RegExp("^\n*", '');
  28513. var leadingNewline = result.match(regex)[0]; // eslint-disable-next-line no-param-reassign
  28514. result = leadingNewline + leadingContentBlockQuote + result.replace(regex, function (_) {
  28515. return '';
  28516. });
  28517. }
  28518. return result;
  28519. }
  28520. var $code = code;
  28521. var _this3$computeLines = _this3.computeLines(match, leadingContent, code),
  28522. sign = _this3$computeLines.sign,
  28523. lines = _this3$computeLines.lines; // 从缓存中获取html
  28524. var cacheCode = _this3.$codeCache(sign);
  28525. if (cacheCode && cacheCode !== '') {
  28526. // 别忘了把 ">"(引用块)加回来
  28527. var _result = _this3.getCacheWithSpace(_this3.pushCache(cacheCode, sign, lines), match);
  28528. return addBlockQuoteSignToResult(_result);
  28529. }
  28530. $code = _this3.$recoverCodeInIndent($code);
  28531. $code = $code.replace(/~D/g, '$');
  28532. $code = $code.replace(/~T/g, '~');
  28533. /** 处理缩进 - start: 当首行反引号前存在多个空格缩进时,代码内容要相应去除相同数量的空格 */
  28534. var indentSpaces = (_leadingContent$match = leadingContent === null || leadingContent === void 0 ? void 0 : (_leadingContent$match2 = leadingContent.match(/[ ]/g)) === null || _leadingContent$match2 === void 0 ? void 0 : _leadingContent$match2.length) !== null && _leadingContent$match !== void 0 ? _leadingContent$match : 0;
  28535. if (indentSpaces > 0) {
  28536. var regex = new RegExp("(^|\\n)[ ]{1,".concat(indentSpaces, "}"), 'g');
  28537. $code = $code.replace(regex, '$1');
  28538. }
  28539. /** 处理缩进 - end */
  28540. // 如果本代码块处于一个引用块(形如 "> " 或 "> > ")中,那么需要从代码中每一行去掉引用块的符号
  28541. if (leadingContentBlockQuote) {
  28542. var _regex = new RegExp("(^|\\n)".concat(leadingContentBlockQuote), 'g');
  28543. $code = $code.replace(_regex, '$1');
  28544. } // 未命中缓存,执行渲染
  28545. var $lang = trim$3(lang).call(lang); // 如果是公式关键字,则直接返回
  28546. if (/^(math|katex|latex)$/i.test($lang) && !_this3.isInternalCustomLangCovered($lang)) {
  28547. var _context19;
  28548. var prefix = match.match(/^\s*/g); // ~D为经编辑器中间转义后的$,code结尾包含结束```前的所有换行符,所以不需要补换行
  28549. return concat$5(_context19 = "".concat(prefix, "~D~D\n")).call(_context19, $code, "~D~D"); // 提供公式语法供公式钩子解析
  28550. }
  28551. var _this3$appendMermaid = _this3.appendMermaid($code, $lang);
  28552. var _this3$appendMermaid2 = _slicedToArray(_this3$appendMermaid, 2);
  28553. $code = _this3$appendMermaid2[0];
  28554. $lang = _this3$appendMermaid2[1];
  28555. // 自定义语言渲染,可覆盖内置的自定义语言逻辑
  28556. if (indexOf$8(_context20 = _this3.customLang).call(_context20, $lang.toLowerCase()) !== -1) {
  28557. cacheCode = _this3.parseCustomLanguage($lang, $code, {
  28558. lines: lines,
  28559. sign: sign
  28560. });
  28561. if (cacheCode && cacheCode !== '') {
  28562. _this3.$codeCache(sign, cacheCode);
  28563. return _this3.getCacheWithSpace(_this3.pushCache(cacheCode, sign, lines), match);
  28564. } // 渲染出错则按正常code进行渲染
  28565. } // $code = this.$replaceSpecialChar($code);
  28566. $code = $code.replace(/~X/g, '\\`');
  28567. cacheCode = _this3.renderCodeBlock($code, $lang, sign, lines);
  28568. cacheCode = cacheCode.replace(/\\/g, '\\\\');
  28569. cacheCode = _this3.$codeCache(sign, cacheCode);
  28570. var result = _this3.getCacheWithSpace(_this3.pushCache(cacheCode, sign, lines), match);
  28571. return addBlockQuoteSignToResult(result);
  28572. }); // 表格里处理行内代码,让一个td里的行内代码语法生效,让跨td的行内代码语法失效
  28573. $str = $str.replace(getTableRule(true), function (whole) {
  28574. var _context21;
  28575. return map$3(_context21 = whole.split('|')).call(_context21, function (oneTd) {
  28576. return _this3.makeInlineCode(oneTd);
  28577. }).join('|').replace(/`/g, '\\`');
  28578. }); // 为了避免InlineCode被HtmlBlock转义,需要在这里提前缓存
  28579. // InlineBlock只需要在afterMakeHtml还原即可
  28580. $str = this.makeInlineCode($str); // 处理缩进代码块
  28581. $str = this.$getIndentCodeBlock($str);
  28582. return $str;
  28583. }
  28584. }, {
  28585. key: "makeInlineCode",
  28586. value: function makeInlineCode(str) {
  28587. var _this4 = this;
  28588. var $str = str;
  28589. if (this.INLINE_CODE_REGEX.test($str)) {
  28590. $str = $str.replace(/\\`/g, '~~not~inlineCode');
  28591. $str = $str.replace(this.INLINE_CODE_REGEX, function (match, syntax, code) {
  28592. if (trim$3(code).call(code) === '`') {
  28593. return match;
  28594. }
  28595. var $code = code.replace(/~~not~inlineCode/g, '\\`');
  28596. $code = _this4.$replaceSpecialChar($code);
  28597. $code = $code.replace(/\\/g, '\\\\');
  28598. var html = "<code>".concat(escapeHTMLSpecialChar($code), "</code>");
  28599. var sign = _this4.$engine.md5(html);
  28600. CodeBlock.inlineCodeCache[sign] = html;
  28601. return "~~CODE".concat(sign, "$");
  28602. });
  28603. $str = $str.replace(/~~not~inlineCode/g, '\\`');
  28604. }
  28605. return $str;
  28606. }
  28607. }, {
  28608. key: "makeHtml",
  28609. value: function makeHtml(str) {
  28610. return str;
  28611. }
  28612. }, {
  28613. key: "$replaceSpecialChar",
  28614. value: function $replaceSpecialChar(str) {
  28615. var $str = str.replace(/~Q/g, '\\~');
  28616. $str = $str.replace(/~Y/g, '\\!');
  28617. $str = $str.replace(/~Z/g, '\\#');
  28618. $str = $str.replace(/~&/g, '\\&');
  28619. $str = $str.replace(/~K/g, '\\/'); // $str = $str.replace(/~D/g, '$');
  28620. // $str = $str.replace(/~T/g, '~');
  28621. return $str;
  28622. }
  28623. }, {
  28624. key: "rule",
  28625. value: function rule() {
  28626. return getCodeBlockRule();
  28627. }
  28628. }, {
  28629. key: "mounted",
  28630. value: function mounted(dom) {// prettyPrint.prettyPrint();
  28631. }
  28632. }]);
  28633. return CodeBlock;
  28634. }(ParagraphBase);
  28635. _defineProperty(CodeBlock, "HOOK_NAME", 'codeBlock');
  28636. _defineProperty(CodeBlock, "inlineCodeCache", {});
  28637. function _createSuper$9(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$9(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  28638. function _isNativeReflectConstruct$9() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  28639. var InlineCode = /*#__PURE__*/function (_ParagraphBase) {
  28640. _inherits(InlineCode, _ParagraphBase);
  28641. var _super = _createSuper$9(InlineCode);
  28642. function InlineCode() {
  28643. _classCallCheck(this, InlineCode);
  28644. return _super.apply(this, arguments);
  28645. }
  28646. _createClass(InlineCode, [{
  28647. key: "makeHtml",
  28648. value: // constructor() {
  28649. // super();
  28650. // }
  28651. function makeHtml(str) {
  28652. return str;
  28653. }
  28654. }, {
  28655. key: "afterMakeHtml",
  28656. value: function afterMakeHtml(str) {
  28657. var $str = str;
  28658. if (keys$3(CodeBlock.inlineCodeCache).length > 0) {
  28659. $str = $str.replace(/~~CODE([0-9a-zA-Z]+)\$/g, function (match, sign) {
  28660. return CodeBlock.inlineCodeCache[sign];
  28661. });
  28662. CodeBlock.inlineCodeCache = {};
  28663. }
  28664. return $str;
  28665. }
  28666. }, {
  28667. key: "rule",
  28668. value: function rule() {
  28669. var ret = {
  28670. begin: '(`+)[ ]*',
  28671. end: '[ ]*\\1',
  28672. content: '(.+?(?:\\n.+?)*?)'
  28673. };
  28674. ret.reg = compileRegExp(ret, 'g');
  28675. return ret;
  28676. }
  28677. }]);
  28678. return InlineCode;
  28679. }(ParagraphBase);
  28680. _defineProperty(InlineCode, "HOOK_NAME", 'inlineCode');
  28681. var crypt = createCommonjsModule(function (module) {
  28682. (function() {
  28683. var base64map
  28684. = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
  28685. crypt = {
  28686. // Bit-wise rotation left
  28687. rotl: function(n, b) {
  28688. return (n << b) | (n >>> (32 - b));
  28689. },
  28690. // Bit-wise rotation right
  28691. rotr: function(n, b) {
  28692. return (n << (32 - b)) | (n >>> b);
  28693. },
  28694. // Swap big-endian to little-endian and vice versa
  28695. endian: function(n) {
  28696. // If number given, swap endian
  28697. if (n.constructor == Number) {
  28698. return crypt.rotl(n, 8) & 0x00FF00FF | crypt.rotl(n, 24) & 0xFF00FF00;
  28699. }
  28700. // Else, assume array and swap all items
  28701. for (var i = 0; i < n.length; i++)
  28702. n[i] = crypt.endian(n[i]);
  28703. return n;
  28704. },
  28705. // Generate an array of any length of random bytes
  28706. randomBytes: function(n) {
  28707. for (var bytes = []; n > 0; n--)
  28708. bytes.push(Math.floor(Math.random() * 256));
  28709. return bytes;
  28710. },
  28711. // Convert a byte array to big-endian 32-bit words
  28712. bytesToWords: function(bytes) {
  28713. for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8)
  28714. words[b >>> 5] |= bytes[i] << (24 - b % 32);
  28715. return words;
  28716. },
  28717. // Convert big-endian 32-bit words to a byte array
  28718. wordsToBytes: function(words) {
  28719. for (var bytes = [], b = 0; b < words.length * 32; b += 8)
  28720. bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);
  28721. return bytes;
  28722. },
  28723. // Convert a byte array to a hex string
  28724. bytesToHex: function(bytes) {
  28725. for (var hex = [], i = 0; i < bytes.length; i++) {
  28726. hex.push((bytes[i] >>> 4).toString(16));
  28727. hex.push((bytes[i] & 0xF).toString(16));
  28728. }
  28729. return hex.join('');
  28730. },
  28731. // Convert a hex string to a byte array
  28732. hexToBytes: function(hex) {
  28733. for (var bytes = [], c = 0; c < hex.length; c += 2)
  28734. bytes.push(parseInt(hex.substr(c, 2), 16));
  28735. return bytes;
  28736. },
  28737. // Convert a byte array to a base-64 string
  28738. bytesToBase64: function(bytes) {
  28739. for (var base64 = [], i = 0; i < bytes.length; i += 3) {
  28740. var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
  28741. for (var j = 0; j < 4; j++)
  28742. if (i * 8 + j * 6 <= bytes.length * 8)
  28743. base64.push(base64map.charAt((triplet >>> 6 * (3 - j)) & 0x3F));
  28744. else
  28745. base64.push('=');
  28746. }
  28747. return base64.join('');
  28748. },
  28749. // Convert a base-64 string to a byte array
  28750. base64ToBytes: function(base64) {
  28751. // Remove non-base-64 characters
  28752. base64 = base64.replace(/[^A-Z0-9+\/]/ig, '');
  28753. for (var bytes = [], i = 0, imod4 = 0; i < base64.length;
  28754. imod4 = ++i % 4) {
  28755. if (imod4 == 0) continue;
  28756. bytes.push(((base64map.indexOf(base64.charAt(i - 1))
  28757. & (Math.pow(2, -2 * imod4 + 8) - 1)) << (imod4 * 2))
  28758. | (base64map.indexOf(base64.charAt(i)) >>> (6 - imod4 * 2)));
  28759. }
  28760. return bytes;
  28761. }
  28762. };
  28763. module.exports = crypt;
  28764. })();
  28765. });
  28766. var charenc = {
  28767. // UTF-8 encoding
  28768. utf8: {
  28769. // Convert a string to a byte array
  28770. stringToBytes: function(str) {
  28771. return charenc.bin.stringToBytes(unescape(encodeURIComponent(str)));
  28772. },
  28773. // Convert a byte array to a string
  28774. bytesToString: function(bytes) {
  28775. return decodeURIComponent(escape(charenc.bin.bytesToString(bytes)));
  28776. }
  28777. },
  28778. // Binary encoding
  28779. bin: {
  28780. // Convert a string to a byte array
  28781. stringToBytes: function(str) {
  28782. for (var bytes = [], i = 0; i < str.length; i++)
  28783. bytes.push(str.charCodeAt(i) & 0xFF);
  28784. return bytes;
  28785. },
  28786. // Convert a byte array to a string
  28787. bytesToString: function(bytes) {
  28788. for (var str = [], i = 0; i < bytes.length; i++)
  28789. str.push(String.fromCharCode(bytes[i]));
  28790. return str.join('');
  28791. }
  28792. }
  28793. };
  28794. var charenc_1 = charenc;
  28795. /*!
  28796. * Determine if an object is a Buffer
  28797. *
  28798. * @author Feross Aboukhadijeh <https://feross.org>
  28799. * @license MIT
  28800. */
  28801. // The _isBuffer check is for Safari 5-7 support, because it's missing
  28802. // Object.prototype.constructor. Remove this eventually
  28803. var isBuffer_1$1 = function (obj) {
  28804. return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
  28805. };
  28806. function isBuffer (obj) {
  28807. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  28808. }
  28809. // For Node v0.10 support. Remove this eventually.
  28810. function isSlowBuffer (obj) {
  28811. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
  28812. }
  28813. var md5 = createCommonjsModule(function (module) {
  28814. (function(){
  28815. var crypt$1 = crypt,
  28816. utf8 = charenc_1.utf8,
  28817. isBuffer = isBuffer_1$1,
  28818. bin = charenc_1.bin,
  28819. // The core
  28820. md5 = function (message, options) {
  28821. // Convert to byte array
  28822. if (message.constructor == String)
  28823. if (options && options.encoding === 'binary')
  28824. message = bin.stringToBytes(message);
  28825. else
  28826. message = utf8.stringToBytes(message);
  28827. else if (isBuffer(message))
  28828. message = Array.prototype.slice.call(message, 0);
  28829. else if (!Array.isArray(message) && message.constructor !== Uint8Array)
  28830. message = message.toString();
  28831. // else, assume byte array already
  28832. var m = crypt$1.bytesToWords(message),
  28833. l = message.length * 8,
  28834. a = 1732584193,
  28835. b = -271733879,
  28836. c = -1732584194,
  28837. d = 271733878;
  28838. // Swap endian
  28839. for (var i = 0; i < m.length; i++) {
  28840. m[i] = ((m[i] << 8) | (m[i] >>> 24)) & 0x00FF00FF |
  28841. ((m[i] << 24) | (m[i] >>> 8)) & 0xFF00FF00;
  28842. }
  28843. // Padding
  28844. m[l >>> 5] |= 0x80 << (l % 32);
  28845. m[(((l + 64) >>> 9) << 4) + 14] = l;
  28846. // Method shortcuts
  28847. var FF = md5._ff,
  28848. GG = md5._gg,
  28849. HH = md5._hh,
  28850. II = md5._ii;
  28851. for (var i = 0; i < m.length; i += 16) {
  28852. var aa = a,
  28853. bb = b,
  28854. cc = c,
  28855. dd = d;
  28856. a = FF(a, b, c, d, m[i+ 0], 7, -680876936);
  28857. d = FF(d, a, b, c, m[i+ 1], 12, -389564586);
  28858. c = FF(c, d, a, b, m[i+ 2], 17, 606105819);
  28859. b = FF(b, c, d, a, m[i+ 3], 22, -1044525330);
  28860. a = FF(a, b, c, d, m[i+ 4], 7, -176418897);
  28861. d = FF(d, a, b, c, m[i+ 5], 12, 1200080426);
  28862. c = FF(c, d, a, b, m[i+ 6], 17, -1473231341);
  28863. b = FF(b, c, d, a, m[i+ 7], 22, -45705983);
  28864. a = FF(a, b, c, d, m[i+ 8], 7, 1770035416);
  28865. d = FF(d, a, b, c, m[i+ 9], 12, -1958414417);
  28866. c = FF(c, d, a, b, m[i+10], 17, -42063);
  28867. b = FF(b, c, d, a, m[i+11], 22, -1990404162);
  28868. a = FF(a, b, c, d, m[i+12], 7, 1804603682);
  28869. d = FF(d, a, b, c, m[i+13], 12, -40341101);
  28870. c = FF(c, d, a, b, m[i+14], 17, -1502002290);
  28871. b = FF(b, c, d, a, m[i+15], 22, 1236535329);
  28872. a = GG(a, b, c, d, m[i+ 1], 5, -165796510);
  28873. d = GG(d, a, b, c, m[i+ 6], 9, -1069501632);
  28874. c = GG(c, d, a, b, m[i+11], 14, 643717713);
  28875. b = GG(b, c, d, a, m[i+ 0], 20, -373897302);
  28876. a = GG(a, b, c, d, m[i+ 5], 5, -701558691);
  28877. d = GG(d, a, b, c, m[i+10], 9, 38016083);
  28878. c = GG(c, d, a, b, m[i+15], 14, -660478335);
  28879. b = GG(b, c, d, a, m[i+ 4], 20, -405537848);
  28880. a = GG(a, b, c, d, m[i+ 9], 5, 568446438);
  28881. d = GG(d, a, b, c, m[i+14], 9, -1019803690);
  28882. c = GG(c, d, a, b, m[i+ 3], 14, -187363961);
  28883. b = GG(b, c, d, a, m[i+ 8], 20, 1163531501);
  28884. a = GG(a, b, c, d, m[i+13], 5, -1444681467);
  28885. d = GG(d, a, b, c, m[i+ 2], 9, -51403784);
  28886. c = GG(c, d, a, b, m[i+ 7], 14, 1735328473);
  28887. b = GG(b, c, d, a, m[i+12], 20, -1926607734);
  28888. a = HH(a, b, c, d, m[i+ 5], 4, -378558);
  28889. d = HH(d, a, b, c, m[i+ 8], 11, -2022574463);
  28890. c = HH(c, d, a, b, m[i+11], 16, 1839030562);
  28891. b = HH(b, c, d, a, m[i+14], 23, -35309556);
  28892. a = HH(a, b, c, d, m[i+ 1], 4, -1530992060);
  28893. d = HH(d, a, b, c, m[i+ 4], 11, 1272893353);
  28894. c = HH(c, d, a, b, m[i+ 7], 16, -155497632);
  28895. b = HH(b, c, d, a, m[i+10], 23, -1094730640);
  28896. a = HH(a, b, c, d, m[i+13], 4, 681279174);
  28897. d = HH(d, a, b, c, m[i+ 0], 11, -358537222);
  28898. c = HH(c, d, a, b, m[i+ 3], 16, -722521979);
  28899. b = HH(b, c, d, a, m[i+ 6], 23, 76029189);
  28900. a = HH(a, b, c, d, m[i+ 9], 4, -640364487);
  28901. d = HH(d, a, b, c, m[i+12], 11, -421815835);
  28902. c = HH(c, d, a, b, m[i+15], 16, 530742520);
  28903. b = HH(b, c, d, a, m[i+ 2], 23, -995338651);
  28904. a = II(a, b, c, d, m[i+ 0], 6, -198630844);
  28905. d = II(d, a, b, c, m[i+ 7], 10, 1126891415);
  28906. c = II(c, d, a, b, m[i+14], 15, -1416354905);
  28907. b = II(b, c, d, a, m[i+ 5], 21, -57434055);
  28908. a = II(a, b, c, d, m[i+12], 6, 1700485571);
  28909. d = II(d, a, b, c, m[i+ 3], 10, -1894986606);
  28910. c = II(c, d, a, b, m[i+10], 15, -1051523);
  28911. b = II(b, c, d, a, m[i+ 1], 21, -2054922799);
  28912. a = II(a, b, c, d, m[i+ 8], 6, 1873313359);
  28913. d = II(d, a, b, c, m[i+15], 10, -30611744);
  28914. c = II(c, d, a, b, m[i+ 6], 15, -1560198380);
  28915. b = II(b, c, d, a, m[i+13], 21, 1309151649);
  28916. a = II(a, b, c, d, m[i+ 4], 6, -145523070);
  28917. d = II(d, a, b, c, m[i+11], 10, -1120210379);
  28918. c = II(c, d, a, b, m[i+ 2], 15, 718787259);
  28919. b = II(b, c, d, a, m[i+ 9], 21, -343485551);
  28920. a = (a + aa) >>> 0;
  28921. b = (b + bb) >>> 0;
  28922. c = (c + cc) >>> 0;
  28923. d = (d + dd) >>> 0;
  28924. }
  28925. return crypt$1.endian([a, b, c, d]);
  28926. };
  28927. // Auxiliary functions
  28928. md5._ff = function (a, b, c, d, x, s, t) {
  28929. var n = a + (b & c | ~b & d) + (x >>> 0) + t;
  28930. return ((n << s) | (n >>> (32 - s))) + b;
  28931. };
  28932. md5._gg = function (a, b, c, d, x, s, t) {
  28933. var n = a + (b & d | c & ~d) + (x >>> 0) + t;
  28934. return ((n << s) | (n >>> (32 - s))) + b;
  28935. };
  28936. md5._hh = function (a, b, c, d, x, s, t) {
  28937. var n = a + (b ^ c ^ d) + (x >>> 0) + t;
  28938. return ((n << s) | (n >>> (32 - s))) + b;
  28939. };
  28940. md5._ii = function (a, b, c, d, x, s, t) {
  28941. var n = a + (c ^ (b | ~d)) + (x >>> 0) + t;
  28942. return ((n << s) | (n >>> (32 - s))) + b;
  28943. };
  28944. // Package private blocksize
  28945. md5._blocksize = 16;
  28946. md5._digestsize = 16;
  28947. module.exports = function (message, options) {
  28948. if (message === undefined || message === null)
  28949. throw new Error('Illegal argument ' + message);
  28950. var digestbytes = crypt$1.wordsToBytes(md5(message, options));
  28951. return options && options.asBytes ? digestbytes :
  28952. options && options.asString ? bin.bytesToString(digestbytes) :
  28953. crypt$1.bytesToHex(digestbytes);
  28954. };
  28955. })();
  28956. });
  28957. var urlCache = {};
  28958. var cherryInnerLinkRegex = /^cherry-inner:\/\/([0-9a-f]+)$/i;
  28959. function urlProcessorProxy(urlProcessor) {
  28960. return function (url, srcType) {
  28961. if (UrlCache.isInnerLink(url)) {
  28962. var newUrl = urlProcessor(UrlCache.get(url), srcType);
  28963. return UrlCache.replace(url, newUrl);
  28964. }
  28965. return urlProcessor(url, srcType);
  28966. };
  28967. }
  28968. var UrlCache = /*#__PURE__*/function () {
  28969. function UrlCache() {
  28970. _classCallCheck(this, UrlCache);
  28971. }
  28972. _createClass(UrlCache, null, [{
  28973. key: "isInnerLink",
  28974. value:
  28975. /**
  28976. * 判断url是否Cherry的内部链接
  28977. * @param {string} url 要检测的URL
  28978. * @returns
  28979. */
  28980. function isInnerLink(url) {
  28981. return cherryInnerLinkRegex.test(url);
  28982. }
  28983. /**
  28984. * 缓存url为内部链接,主要用于缩短超长链接,避免正则超时
  28985. * @param {string} url 要转换为内部链接的URL
  28986. * @returns
  28987. */
  28988. }, {
  28989. key: "set",
  28990. value: function set(url) {
  28991. var urlSign = md5(url);
  28992. urlCache[urlSign] = url;
  28993. return "cherry-inner://".concat(urlSign);
  28994. }
  28995. /**
  28996. * 获取原始链接
  28997. * @param {string} innerUrl 内部链接
  28998. * @returns
  28999. */
  29000. }, {
  29001. key: "get",
  29002. value: function get(innerUrl) {
  29003. var _innerUrl$match;
  29004. var _ref = (_innerUrl$match = innerUrl.match(cherryInnerLinkRegex)) !== null && _innerUrl$match !== void 0 ? _innerUrl$match : [],
  29005. _ref2 = _slicedToArray(_ref, 2),
  29006. urlSign = _ref2[1];
  29007. if (!urlSign) {
  29008. return;
  29009. }
  29010. return urlCache[urlSign];
  29011. }
  29012. /**
  29013. * 替换指定内部链接的真实地址
  29014. * @param {string} innerUrl 原始内部链接
  29015. * @param {string} newUrl 需要替换的链接
  29016. */
  29017. }, {
  29018. key: "replace",
  29019. value: function replace(innerUrl, newUrl) {
  29020. var _innerUrl$match2;
  29021. var _ref3 = (_innerUrl$match2 = innerUrl.match(cherryInnerLinkRegex)) !== null && _innerUrl$match2 !== void 0 ? _innerUrl$match2 : [],
  29022. _ref4 = _slicedToArray(_ref3, 2),
  29023. urlSign = _ref4[1];
  29024. if (!urlSign) {
  29025. return;
  29026. }
  29027. urlCache[urlSign] = newUrl;
  29028. return innerUrl;
  29029. }
  29030. /**
  29031. * 替换所有内部链接为原始的真实地址
  29032. * @param {string} html 包含 cherry-inner 协议地址的 html 文本
  29033. */
  29034. }, {
  29035. key: "restoreAll",
  29036. value: function restoreAll(html) {
  29037. var cherryInnerLinkRegex = /cherry-inner:\/\/([0-9a-f]+)/gi;
  29038. var $html = html.replace(cherryInnerLinkRegex, function (match) {
  29039. var originalUrl = UrlCache.get(match);
  29040. return originalUrl || match;
  29041. });
  29042. return $html;
  29043. }
  29044. /**
  29045. * 清空缓存
  29046. */
  29047. }, {
  29048. key: "clear",
  29049. value: function clear() {
  29050. urlCache = {};
  29051. }
  29052. }]);
  29053. return UrlCache;
  29054. }();
  29055. function _createSuper$a(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$a(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  29056. function _isNativeReflectConstruct$a() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  29057. var Link = /*#__PURE__*/function (_SyntaxBase) {
  29058. _inherits(Link, _SyntaxBase);
  29059. var _super = _createSuper$a(Link);
  29060. function Link(_ref) {
  29061. var _this;
  29062. var config = _ref.config,
  29063. globalConfig = _ref.globalConfig;
  29064. _classCallCheck(this, Link);
  29065. _this = _super.call(this, {
  29066. config: config
  29067. });
  29068. _this.urlProcessor = globalConfig.urlProcessor; // eslint-disable-next-line no-nested-ternary
  29069. _this.target = config.target ? "target=\"".concat(config.target, "\"") : !!config.openNewPage ? 'target="_blank"' : '';
  29070. _this.rel = config.rel ? "rel=\"".concat(config.rel, "\"") : '';
  29071. return _this;
  29072. }
  29073. /**
  29074. * 校验link中text的方括号是否符合规则
  29075. * @param {string} rawText
  29076. */
  29077. _createClass(Link, [{
  29078. key: "checkBrackets",
  29079. value: function checkBrackets(rawText) {
  29080. var stack = [];
  29081. var text = "[".concat(rawText, "]"); // 前方有奇数个\当前字符被转义
  29082. var checkEscape = function checkEscape(place) {
  29083. return slice$7(text).call(text, 0, place).match(/\\*$/)[0].length & 1;
  29084. };
  29085. for (var i = text.length - 1; text[i]; i--) {
  29086. if (i === text.length - 1 && checkEscape(i)) break;
  29087. if (text[i] === ']' && !checkEscape(i)) stack.push(']');
  29088. if (text[i] === '[' && !checkEscape(i)) {
  29089. stack.pop();
  29090. if (!stack.length) {
  29091. return {
  29092. isValid: true,
  29093. coreText: slice$7(text).call(text, i + 1, text.length - 1),
  29094. extraLeadingChar: slice$7(text).call(text, 0, i)
  29095. };
  29096. }
  29097. }
  29098. }
  29099. return {
  29100. isValid: false,
  29101. // 方括号匹配不上
  29102. coreText: rawText,
  29103. extraLeadingChar: ''
  29104. };
  29105. }
  29106. /**
  29107. *
  29108. * @param {string} match 匹配的完整字符串
  29109. * @param {string} leadingChar 正则分组一:前置字符
  29110. * @param {string} text 正则分组二:链接文字
  29111. * @param {string|undefined} link 正则分组三:链接URL
  29112. * @param {string|undefined} title 正则分组四:链接title
  29113. * @param {string|undefined} ref 正则分组五:链接引用
  29114. * @param {string|undefined} target 正则分组六:新窗口打开
  29115. * @returns
  29116. */
  29117. }, {
  29118. key: "toHtml",
  29119. value: function toHtml(match, leadingChar, text, link, title, ref, target) {
  29120. var refType = typeof link === 'undefined' ? 'ref' : 'url';
  29121. var attrs = '';
  29122. if (refType === 'ref') {
  29123. // 全局引用,理应在CommentReference中被替换,没有被替换说明没有定义引用项
  29124. return match;
  29125. }
  29126. if (refType === 'url') {
  29127. var _context5;
  29128. var _this$checkBrackets = this.checkBrackets(text),
  29129. isValid = _this$checkBrackets.isValid,
  29130. coreText = _this$checkBrackets.coreText,
  29131. extraLeadingChar = _this$checkBrackets.extraLeadingChar;
  29132. if (!isValid) return match;
  29133. attrs = title && trim$3(title).call(title) !== '' ? " title=\"".concat(escapeHTMLSpecialChar(title.replace(/["']/g, '')), "\"") : '';
  29134. if (target) {
  29135. attrs += " target=\"".concat(target.replace(/{target\s*=\s*(.*?)}/, '$1'), "\"");
  29136. } else if (this.target) {
  29137. attrs += " ".concat(this.target);
  29138. }
  29139. var processedURL = trim$3(link).call(link).replace(/~1D/g, '~D'); // 还原替换的$符号
  29140. var processedText = coreText.replace(/~1D/g, '~D'); // 还原替换的$符号
  29141. // text可能是html标签,依赖htmlBlock进行处理
  29142. if (isValidScheme(processedURL)) {
  29143. var _context, _context2, _context3, _context4;
  29144. processedURL = this.urlProcessor(processedURL, 'link');
  29145. processedURL = encodeURIOnce(processedURL);
  29146. return concat$5(_context = concat$5(_context2 = concat$5(_context3 = concat$5(_context4 = "".concat(leadingChar + extraLeadingChar, "<a href=\"")).call(_context4, UrlCache.set(processedURL), "\" ")).call(_context3, this.rel, " ")).call(_context2, attrs, ">")).call(_context, processedText, "</a>");
  29147. }
  29148. return concat$5(_context5 = "".concat(leadingChar + extraLeadingChar, "<span>")).call(_context5, text, "</span>");
  29149. } // should never happen
  29150. return match;
  29151. }
  29152. }, {
  29153. key: "toStdMarkdown",
  29154. value: function toStdMarkdown(match) {
  29155. return match;
  29156. }
  29157. }, {
  29158. key: "makeHtml",
  29159. value: function makeHtml(str) {
  29160. var $str = str.replace(this.RULE.reg, function (match) {
  29161. return match.replace(/~D/g, '~1D');
  29162. });
  29163. if (isLookbehindSupported()) {
  29164. var _context6;
  29165. $str = $str.replace(this.RULE.reg, bind$5(_context6 = this.toHtml).call(_context6, this));
  29166. } else {
  29167. var _context7;
  29168. $str = replaceLookbehind($str, this.RULE.reg, bind$5(_context7 = this.toHtml).call(_context7, this), true, 1);
  29169. }
  29170. $str = $str.replace(this.RULE.reg, function (match) {
  29171. return match.replace(/~1D/g, '~D');
  29172. });
  29173. return $str;
  29174. }
  29175. }, {
  29176. key: "rule",
  29177. value: function rule() {
  29178. // (?<protocol>\\w+:)\\/\\/
  29179. var ret = {
  29180. // lookbehind启用分组是为了和不兼容lookbehind的场景共用一个回调
  29181. begin: isLookbehindSupported() ? '((?<!\\\\))' : '(^|[^\\\\])',
  29182. content: ['\\[([^\\n]+?)\\]', // ?<text>
  29183. '[ \\t]*', // any spaces
  29184. "".concat('(?:' + '\\(' +
  29185. /**
  29186. * allow double quotes
  29187. * e.g.
  29188. * [link](") ⭕️ valid
  29189. * [link]("") ⭕️ valid
  29190. * [link](" ") ❌ invalid
  29191. */
  29192. '([^\\s)]+)' + // ?<link> url
  29193. '(?:[ \\t]((?:".*?")|(?:\'.*?\')))?' + // ?<title> optional
  29194. '\\)' + '|' + // or
  29195. '\\[(').concat(NOT_ALL_WHITE_SPACES_INLINE, ")\\]") + // ?<ref> global ref
  29196. ')', '(\\{target\\s*=\\s*(_blank|_parent|_self|_top)\\})?'].join(''),
  29197. end: ''
  29198. }; // let ret = {begin:'((^|[^\\\\])\\*\\*|([\\s]|^)__)',
  29199. // end:'(\\*\\*([\\s\\S]|$)|__([\\s]|$))', content:'([^\\n]+?)'};
  29200. ret.reg = compileRegExp(ret, 'g');
  29201. return ret;
  29202. }
  29203. }]);
  29204. return Link;
  29205. }(SyntaxBase);
  29206. _defineProperty(Link, "HOOK_NAME", 'link');
  29207. var RangeError$2 = global_1.RangeError;
  29208. // `String.prototype.repeat` method implementation
  29209. // https://tc39.es/ecma262/#sec-string.prototype.repeat
  29210. var stringRepeat = function repeat(count) {
  29211. var str = toString_1(requireObjectCoercible(this));
  29212. var result = '';
  29213. var n = toIntegerOrInfinity(count);
  29214. if (n < 0 || n == Infinity) throw RangeError$2('Wrong number of repetitions');
  29215. for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str;
  29216. return result;
  29217. };
  29218. // `String.prototype.repeat` method
  29219. // https://tc39.es/ecma262/#sec-string.prototype.repeat
  29220. _export({ target: 'String', proto: true }, {
  29221. repeat: stringRepeat
  29222. });
  29223. var repeat = entryVirtual('String').repeat;
  29224. var StringPrototype$2 = String.prototype;
  29225. var repeat$1 = function (it) {
  29226. var own = it.repeat;
  29227. return typeof it == 'string' || it === StringPrototype$2
  29228. || (objectIsPrototypeOf(StringPrototype$2, it) && own === StringPrototype$2.repeat) ? repeat : own;
  29229. };
  29230. var repeat$2 = repeat$1;
  29231. var repeat$3 = repeat$2;
  29232. function _createSuper$b(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$b(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  29233. function _isNativeReflectConstruct$b() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  29234. var Emphasis = /*#__PURE__*/function (_SyntaxBase) {
  29235. _inherits(Emphasis, _SyntaxBase);
  29236. var _super = _createSuper$b(Emphasis);
  29237. function Emphasis() {
  29238. var _this;
  29239. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  29240. config: undefined
  29241. },
  29242. config = _ref.config;
  29243. _classCallCheck(this, Emphasis);
  29244. _this = _super.call(this, {
  29245. config: config
  29246. });
  29247. if (!config) {
  29248. return _possibleConstructorReturn(_this);
  29249. }
  29250. _this.allowWhitespace = !!config.allowWhitespace;
  29251. return _this;
  29252. }
  29253. _createClass(Emphasis, [{
  29254. key: "makeHtml",
  29255. value: function makeHtml(str, sentenceMakeFunc) {
  29256. var converAsterisk = function converAsterisk(match, leading, symbol, text) {
  29257. var _context, _context2, _context3, _context4, _context5;
  29258. var tagType = symbol.length % 2 === 1 ? 'em' : 'strong';
  29259. var repeat = Math.floor(symbol.length / 2);
  29260. var prefix = repeat$3(_context = '<strong>').call(_context, repeat);
  29261. var suffix = repeat$3(_context2 = '</strong>').call(_context2, repeat);
  29262. if (tagType === 'em') {
  29263. prefix += '<em>';
  29264. suffix = "</em>".concat(suffix);
  29265. } // 这里转义_是为了避免跨标签识别
  29266. var result = concat$5(_context3 = concat$5(_context4 = concat$5(_context5 = "".concat(leading)).call(_context5, prefix)).call(_context4, sentenceMakeFunc(text).html.replace(/_/g, '~U'))).call(_context3, suffix);
  29267. return result;
  29268. };
  29269. var $str = str;
  29270. if (this.allowWhitespace) {
  29271. $str = $str.replace(/(^|\n[\s]*)(\*)([^\s*](?:.*?)(?:(?:\n.*?)*?))\*/g, converAsterisk);
  29272. $str = $str.replace(/(^|\n[\s]*)(\*{2,})((?:.*?)(?:(?:\n.*?)*?))\2/g, converAsterisk);
  29273. $str = $str.replace(/([^\n*\\\s][ ]*)(\*+)((?:.*?)(?:(?:\n.*?)*?))\2/g, converAsterisk);
  29274. } else {
  29275. $str = $str.replace(this.RULE.asterisk.reg, converAsterisk);
  29276. }
  29277. $str = $str.replace(this.RULE.underscore.reg, function (match, leading, symbol, text, index, string) {
  29278. var _context6, _context7, _context8, _context9, _context10;
  29279. if (trim$3(text).call(text) === '') {
  29280. return match;
  29281. }
  29282. var tagType = symbol.length % 2 === 1 ? 'em' : 'strong';
  29283. var repeat = Math.floor(symbol.length / 2);
  29284. var prefix = repeat$3(_context6 = '<strong>').call(_context6, repeat);
  29285. var suffix = repeat$3(_context7 = '</strong>').call(_context7, repeat);
  29286. var innerText = sentenceMakeFunc(text).html;
  29287. if (tagType === 'em') {
  29288. // if(/<em>.*?<\/em>/.test(innerText)) {
  29289. // prefix += symbol;
  29290. // suffix = symbol + suffix;
  29291. // } else {
  29292. prefix += '<em>';
  29293. suffix = "</em>".concat(suffix); // }
  29294. }
  29295. var result = concat$5(_context8 = concat$5(_context9 = concat$5(_context10 = "".concat(leading)).call(_context10, prefix)).call(_context9, innerText)).call(_context8, suffix);
  29296. return result;
  29297. });
  29298. return $str.replace(/~U/g, '_');
  29299. }
  29300. }, {
  29301. key: "test",
  29302. value: function test(str, flavor) {
  29303. return this.RULE[flavor].reg && this.RULE[flavor].reg.test(str);
  29304. }
  29305. }, {
  29306. key: "rule",
  29307. value: function rule() {
  29308. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  29309. config: undefined
  29310. },
  29311. config = _ref2.config;
  29312. var allowWhitespace = config ? !!config.allowWhitespace : false;
  29313. var REGEX = allowWhitespace ? ALLOW_WHITESPACE_MULTILINE : DO_NOT_STARTS_AND_END_WITH_SPACES_MULTILINE_ALLOW_EMPTY;
  29314. var asterisk = {
  29315. begin: '(^|[^\\\\])(\\*+)',
  29316. // ?<leading>, ?<symbol>
  29317. content: "(".concat(REGEX, ")"),
  29318. // ?<text>
  29319. end: '\\2'
  29320. }; // UNDERSCORE_EMPHASIS_BORDER:允许除下划线以外的「标点符号」和空格出现,使用[^\w\S \t]或[\W\s]会有性能问题
  29321. var underscore = {
  29322. begin: "(^|".concat(UNDERSCORE_EMPHASIS_BOUNDARY, ")(_+)"),
  29323. // ?<leading>, ?<symbol>
  29324. content: "(".concat(REGEX, ")"),
  29325. // ?<text>
  29326. end: "\\2(?=".concat(UNDERSCORE_EMPHASIS_BOUNDARY, "|$)")
  29327. };
  29328. asterisk.reg = compileRegExp(asterisk, 'g');
  29329. underscore.reg = compileRegExp(underscore, 'g');
  29330. return {
  29331. asterisk: asterisk,
  29332. underscore: underscore
  29333. };
  29334. }
  29335. }]);
  29336. return Emphasis;
  29337. }(SyntaxBase);
  29338. _defineProperty(Emphasis, "HOOK_NAME", 'fontEmphasis');
  29339. function _createSuper$c(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$c(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  29340. function _isNativeReflectConstruct$c() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  29341. /**
  29342. * 段落级语法
  29343. * 段落级语法可以具备以下特性:
  29344. * 1、排他性,可以排除将当前语法之后的所有段落语法
  29345. * 2、可排序,在../HooksConfig.js里设置排序,顺序在前面的段落语法先渲染
  29346. * 3、可嵌套行内语法
  29347. *
  29348. * 段落级语法有以下义务:
  29349. * 1、维护签名,签名用来实现预览区域的局部更新功能
  29350. * 2、维护行号,行号用来实现编辑区和预览区同步滚动
  29351. * 每个段落语法负责计算上文的行号,上文行号不是0就是1,大于1会由BR语法计算行号
  29352. */
  29353. var Paragraph = /*#__PURE__*/function (_ParagraphBase) {
  29354. _inherits(Paragraph, _ParagraphBase);
  29355. var _super = _createSuper$c(Paragraph);
  29356. function Paragraph(options) {
  29357. var _this;
  29358. _classCallCheck(this, Paragraph);
  29359. _this = _super.call(this);
  29360. _this.initBrReg(options.globalConfig.classicBr);
  29361. return _this;
  29362. }
  29363. /**
  29364. * 段落语法的核心渲染函数
  29365. * @param {string} str markdown源码
  29366. * @param {Function} sentenceMakeFunc 行内语法渲染器
  29367. * @returns {string} html内容
  29368. */
  29369. _createClass(Paragraph, [{
  29370. key: "makeHtml",
  29371. value: function makeHtml(str, sentenceMakeFunc) {
  29372. var _this2 = this;
  29373. if (!this.test(str)) {
  29374. return str;
  29375. }
  29376. return str.replace(this.RULE.reg, function (match, preLines, content) {
  29377. var _context8;
  29378. if (_this2.isContainsCache(match, true)) {
  29379. return match;
  29380. } // 判断当前内容里是否包含段落渲染引擎暂存缓存关键字
  29381. var cacheMixedInMatches = _this2.isContainsCache(content);
  29382. var processor = function processor(p) {
  29383. var _context, _context2, _context3, _context4, _context5, _context6;
  29384. if (trim$3(p).call(p) === '') {
  29385. return '';
  29386. } // 调用行内语法,获得段落的签名和对应html内容
  29387. var _sentenceMakeFunc = sentenceMakeFunc(p),
  29388. sign = _sentenceMakeFunc.sign,
  29389. html = _sentenceMakeFunc.html;
  29390. var domName = 'p'; // 如果包含html块级标签(比如div、blockquote等),则当前段落外层用div包裹,反之用p包裹
  29391. var isContainBlockTest = new RegExp("<(".concat(blockNames, ")[^>]*>"), 'i');
  29392. if (isContainBlockTest.test(html)) {
  29393. domName = 'div';
  29394. } // 计算行号
  29395. var lines = _this2.getLineCount(p, p);
  29396. return concat$5(_context = concat$5(_context2 = concat$5(_context3 = concat$5(_context4 = concat$5(_context5 = concat$5(_context6 = "<".concat(domName, " data-sign=\"")).call(_context6, sign)).call(_context5, lines, "\" data-type=\"")).call(_context4, domName, "\" data-lines=\"")).call(_context3, lines, "\">")).call(_context2, _this2.$cleanParagraph(html), "</")).call(_context, domName, ">");
  29397. };
  29398. if (cacheMixedInMatches) {
  29399. var _context7;
  29400. return _this2.makeExcludingCached(concat$5(_context7 = "".concat(preLines)).call(_context7, content), processor);
  29401. }
  29402. return processor(concat$5(_context8 = "".concat(preLines)).call(_context8, content));
  29403. });
  29404. }
  29405. }, {
  29406. key: "rule",
  29407. value: function rule() {
  29408. var ret = {
  29409. begin: '(?:^|\\n)(\\n*)',
  29410. end: '(?=\\s*$|\\n\\n)',
  29411. content: '([\\s\\S]+?)'
  29412. };
  29413. ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
  29414. return ret;
  29415. }
  29416. }]);
  29417. return Paragraph;
  29418. }(ParagraphBase);
  29419. _defineProperty(Paragraph, "HOOK_NAME", 'normalParagraph');
  29420. var isDataDescriptor = function (descriptor) {
  29421. return descriptor !== undefined && (hasOwnProperty_1(descriptor, 'value') || hasOwnProperty_1(descriptor, 'writable'));
  29422. };
  29423. // `Reflect.get` method
  29424. // https://tc39.es/ecma262/#sec-reflect.get
  29425. function get$1(target, propertyKey /* , receiver */) {
  29426. var receiver = arguments.length < 3 ? target : arguments[2];
  29427. var descriptor, prototype;
  29428. if (anObject(target) === receiver) return target[propertyKey];
  29429. descriptor = objectGetOwnPropertyDescriptor.f(target, propertyKey);
  29430. if (descriptor) return isDataDescriptor(descriptor)
  29431. ? descriptor.value
  29432. : descriptor.get === undefined ? undefined : functionCall(descriptor.get, receiver);
  29433. if (isObject(prototype = objectGetPrototypeOf(target))) return get$1(prototype, propertyKey, receiver);
  29434. }
  29435. _export({ target: 'Reflect', stat: true }, {
  29436. get: get$1
  29437. });
  29438. var get$2 = path.Reflect.get;
  29439. var get$3 = get$2;
  29440. var get$4 = get$3;
  29441. var get$5 = get$4;
  29442. var get$6 = get$5;
  29443. var get$7 = get$6;
  29444. var getOwnPropertyDescriptor$4 = getOwnPropertyDescriptor$2;
  29445. var getOwnPropertyDescriptor$5 = getOwnPropertyDescriptor$4;
  29446. var getOwnPropertyDescriptor$6 = getOwnPropertyDescriptor$5;
  29447. var getOwnPropertyDescriptor$7 = getOwnPropertyDescriptor$6;
  29448. var superPropBase = createCommonjsModule(function (module) {
  29449. function _superPropBase(object, property) {
  29450. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  29451. object = getPrototypeOf$6(object);
  29452. if (object === null) break;
  29453. }
  29454. return object;
  29455. }
  29456. module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
  29457. });
  29458. unwrapExports(superPropBase);
  29459. var get$8 = createCommonjsModule(function (module) {
  29460. function _get() {
  29461. if (typeof Reflect !== "undefined" && get$7) {
  29462. module.exports = _get = get$7, module.exports.__esModule = true, module.exports["default"] = module.exports;
  29463. } else {
  29464. module.exports = _get = function _get(target, property, receiver) {
  29465. var base = superPropBase(target, property);
  29466. if (!base) return;
  29467. var desc = getOwnPropertyDescriptor$7(base, property);
  29468. if (desc.get) {
  29469. return desc.get.call(arguments.length < 3 ? target : receiver);
  29470. }
  29471. return desc.value;
  29472. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  29473. }
  29474. return _get.apply(this, arguments);
  29475. }
  29476. module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
  29477. });
  29478. var _get = unwrapExports(get$8);
  29479. function _createSuper$d(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$d(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  29480. function _isNativeReflectConstruct$d() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  29481. var ATX_HEADER = 'atx';
  29482. var SETEXT_HEADER = 'setext';
  29483. var toDashChars = /[\s\-_]/;
  29484. var alphabetic = /[A-Za-z]/;
  29485. var numeric = /[0-9]/;
  29486. var Header = /*#__PURE__*/function (_ParagraphBase) {
  29487. _inherits(Header, _ParagraphBase);
  29488. var _super = _createSuper$d(Header);
  29489. function Header() {
  29490. var _this;
  29491. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  29492. config: undefined,
  29493. externals: undefined
  29494. },
  29495. externals = _ref.externals,
  29496. config = _ref.config;
  29497. _classCallCheck(this, Header);
  29498. _this = _super.call(this, {
  29499. needCache: true
  29500. });
  29501. _this.strict = config ? !!config.strict : true;
  29502. _this.RULE = _this.rule();
  29503. _this.headerIDCache = [];
  29504. _this.headerIDCounter = {};
  29505. _this.config = config || {}; // TODO: AllowCustomID
  29506. return _this;
  29507. }
  29508. _createClass(Header, [{
  29509. key: "$parseTitleText",
  29510. value: function $parseTitleText() {
  29511. var html = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  29512. if (typeof html !== 'string') {
  29513. return '';
  29514. }
  29515. return html.replace(/<.*?>/g, '').replace(/&#60;/g, '<').replace(/&#62;/g, '>');
  29516. }
  29517. /**
  29518. * refer:
  29519. * @see https://github.com/vsch/flexmark-java/blob/8bf621924158dfed8b84120479c82704020a6927/flexmark
  29520. * /src/main/java/com/vladsch/flexmark/html/renderer/HeaderIdGenerator.java#L90-L113
  29521. *
  29522. * @param {string} headerText
  29523. * @param {boolean} [toLowerCase]
  29524. * @returns
  29525. */
  29526. }, {
  29527. key: "$generateId",
  29528. value: function $generateId(headerText) {
  29529. var toLowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  29530. var len = headerText.length;
  29531. var id = '';
  29532. for (var i = 0; i < len; i++) {
  29533. var c = headerText.charAt(i);
  29534. if (alphabetic.test(c)) {
  29535. id += toLowerCase ? c.toLowerCase() : c;
  29536. } else if (numeric.test(c)) {
  29537. id += c;
  29538. } else if (toDashChars.test(c)) {
  29539. id += id.length < 1 || id.charAt(id.length - 1) !== '-' ? '-' : '';
  29540. } else if (c.charCodeAt(0) > 255) {
  29541. // unicode
  29542. try {
  29543. id += encodeURIComponent(c);
  29544. } catch (error) {// empty
  29545. }
  29546. }
  29547. }
  29548. return id;
  29549. }
  29550. }, {
  29551. key: "generateIDNoDup",
  29552. value: function generateIDNoDup(headerText) {
  29553. var _context;
  29554. // 处理被引擎转换过的实体字符
  29555. var unescapedHeaderText = headerText.replace(/&#60;/g, '<').replace(/&#62;/g, '>');
  29556. var newId = this.$generateId(unescapedHeaderText, true);
  29557. var idIndex = indexOf$8(_context = this.headerIDCache).call(_context, newId);
  29558. if (idIndex !== -1) {
  29559. this.headerIDCounter[idIndex] += 1;
  29560. newId += "-".concat(this.headerIDCounter[idIndex] + 1);
  29561. } else {
  29562. var newIndex = this.headerIDCache.push(newId);
  29563. this.headerIDCounter[newIndex - 1] = 1;
  29564. }
  29565. return newId;
  29566. }
  29567. }, {
  29568. key: "$wrapHeader",
  29569. value: function $wrapHeader(text, level, dataLines, sentenceMakeFunc) {
  29570. var _context2, _context3, _context4, _context5, _context6, _context7;
  29571. // 需要经过一次escape
  29572. var processedText = sentenceMakeFunc(trim$3(text).call(text));
  29573. var html = processedText.html; // TODO: allowCustomID开关
  29574. // let htmlAttr = this.getAttributes(html);
  29575. // html = htmlAttr.str;
  29576. // let attrs = htmlAttr.attrs;
  29577. // console.log(attrs);
  29578. var customIDRegex = /\s+\{#([A-Za-z0-9-]+)\}$/; // ?<id>
  29579. var idMatch = html.match(customIDRegex);
  29580. var anchorID;
  29581. if (idMatch !== null) {
  29582. html = html.substring(0, idMatch.index);
  29583. var _idMatch = _slicedToArray(idMatch, 2);
  29584. anchorID = _idMatch[1];
  29585. }
  29586. var headerTextRaw = this.$parseTitleText(html);
  29587. if (!anchorID) {
  29588. var replaceFootNote = /~fn#([0-9]+)#/g;
  29589. anchorID = this.generateIDNoDup(headerTextRaw.replace(replaceFootNote, ''));
  29590. }
  29591. var safeAnchorID = "safe_".concat(anchorID); // transform header id to avoid being sanitized
  29592. var sign = this.$engine.md5(concat$5(_context2 = concat$5(_context3 = concat$5(_context4 = "".concat(level, "-")).call(_context4, processedText.sign, "-")).call(_context3, anchorID, "-")).call(_context2, dataLines));
  29593. var result = [concat$5(_context5 = concat$5(_context6 = concat$5(_context7 = "<h".concat(level, " id=\"")).call(_context7, safeAnchorID, "\" data-sign=\"")).call(_context6, sign, "\" data-lines=\"")).call(_context5, dataLines, "\">"), this.$getAnchor(anchorID), "".concat(html), "</h".concat(level, ">")].join('');
  29594. return {
  29595. html: result,
  29596. sign: "".concat(sign)
  29597. };
  29598. }
  29599. }, {
  29600. key: "$getAnchor",
  29601. value: function $getAnchor(anchorID) {
  29602. var anchorStyle = this.config.anchorStyle || 'default';
  29603. if (anchorStyle === 'none') {
  29604. return '';
  29605. }
  29606. return "<a class=\"anchor\" href=\"#".concat(anchorID, "\"></a>");
  29607. }
  29608. }, {
  29609. key: "beforeMakeHtml",
  29610. value: function beforeMakeHtml(str) {
  29611. var _this2 = this;
  29612. var $str = str; // atx 优先
  29613. if (this.test($str, ATX_HEADER)) {
  29614. $str = $str.replace(this.RULE[ATX_HEADER].reg, function (match, lines, level, text) {
  29615. if (trim$3(text).call(text) === '') {
  29616. return match;
  29617. }
  29618. return _this2.getCacheWithSpace(_this2.pushCache(match), match, true);
  29619. });
  29620. } // 按照目前的引擎,每个hook只会执行一次,所以需要并行执行替换
  29621. if (this.test($str, SETEXT_HEADER)) {
  29622. $str = $str.replace(this.RULE[SETEXT_HEADER].reg, function (match, lines, text) {
  29623. if (trim$3(text).call(text) === '' || _this2.isContainsCache(text)) {
  29624. return match;
  29625. }
  29626. return _this2.getCacheWithSpace(_this2.pushCache(match), match, true);
  29627. });
  29628. }
  29629. return $str;
  29630. }
  29631. }, {
  29632. key: "makeHtml",
  29633. value: function makeHtml(str, sentenceMakeFunc) {
  29634. var _this3 = this;
  29635. // 先还原
  29636. var $str = this.restoreCache(str); // atx 优先
  29637. if (this.test($str, ATX_HEADER)) {
  29638. $str = $str.replace(this.RULE[ATX_HEADER].reg, function (match, lines, level, text) {
  29639. // 其中有两行是beforeMake加上的
  29640. var lineCount = calculateLinesOfParagraph(lines, _this3.getLineCount(match.replace(/^\n+/, '')));
  29641. var $text = text.replace(/\s+#+\s*$/, ''); // close tag
  29642. var _this3$$wrapHeader = _this3.$wrapHeader($text, level.length, lineCount, sentenceMakeFunc),
  29643. result = _this3$$wrapHeader.html,
  29644. sign = _this3$$wrapHeader.sign; // 文章的开头不加换行
  29645. return _this3.getCacheWithSpace(_this3.pushCache(result, sign, lineCount), match, true);
  29646. });
  29647. } // 按照目前的引擎,每个hook只会执行一次,所以需要并行执行替换
  29648. if (this.test($str, SETEXT_HEADER)) {
  29649. $str = $str.replace(this.RULE[SETEXT_HEADER].reg, function (match, lines, text, level) {
  29650. if (_this3.isContainsCache(text)) {
  29651. return match;
  29652. } // 其中有两行是beforeMake加上的
  29653. var lineCount = calculateLinesOfParagraph(lines, _this3.getLineCount(match.replace(/^\n+/, '')));
  29654. var headerLevel = level[0] === '-' ? 2 : 1; // =: H1, -: H2
  29655. var _this3$$wrapHeader2 = _this3.$wrapHeader(text, headerLevel, lineCount, sentenceMakeFunc),
  29656. result = _this3$$wrapHeader2.html,
  29657. sign = _this3$$wrapHeader2.sign; // 文章的开头不加换行
  29658. return _this3.getCacheWithSpace(_this3.pushCache(result, sign, lineCount), match, true);
  29659. });
  29660. }
  29661. return $str;
  29662. }
  29663. }, {
  29664. key: "afterMakeHtml",
  29665. value: function afterMakeHtml(html) {
  29666. var $html = _get(_getPrototypeOf(Header.prototype), "afterMakeHtml", this).call(this, html);
  29667. this.headerIDCache = [];
  29668. this.headerIDCounter = {};
  29669. return $html;
  29670. }
  29671. }, {
  29672. key: "test",
  29673. value: function test(str, flavor) {
  29674. return this.RULE[flavor].reg && this.RULE[flavor].reg.test(str);
  29675. }
  29676. }, {
  29677. key: "rule",
  29678. value: function rule() {
  29679. // setext Header
  29680. // TODO: 支持多行标题
  29681. var setext = {
  29682. begin: '(?:^|\\n)(\\n*)',
  29683. // (?<lines>\\n*)
  29684. content: ['(?:\\h*', '(.+)', // (?<text>.+)
  29685. ')\\n', '(?:\\h*', '([=]+|[-]+)', // (?<level>[=]+|[-]+)
  29686. ')'].join(''),
  29687. end: '(?=$|\\n)'
  29688. };
  29689. setext.reg = compileRegExp(setext, 'g', true); // atx header
  29690. var atx = {
  29691. begin: '(?:^|\\n)(\\n*)(?:\\h*(#{1,6}))',
  29692. // (?<lines>\\n*), (?<level>#{1,6})
  29693. content: '(.+?)',
  29694. // '(?<text>.+?)'
  29695. end: '(?=$|\\n)'
  29696. };
  29697. this.strict && (atx.begin += '(?=\\h+)'); // (?=\\s+) for strict mode
  29698. atx.reg = compileRegExp(atx, 'g', true);
  29699. return {
  29700. setext: setext,
  29701. atx: atx
  29702. };
  29703. }
  29704. }]);
  29705. return Header;
  29706. }(ParagraphBase);
  29707. _defineProperty(Header, "HOOK_NAME", 'header');
  29708. function _createSuper$e(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$e(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  29709. function _isNativeReflectConstruct$e() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  29710. var Transfer = /*#__PURE__*/function (_SyntaxBase) {
  29711. _inherits(Transfer, _SyntaxBase);
  29712. var _super = _createSuper$e(Transfer);
  29713. function Transfer() {
  29714. _classCallCheck(this, Transfer);
  29715. return _super.apply(this, arguments);
  29716. }
  29717. _createClass(Transfer, [{
  29718. key: "rule",
  29719. value: // constructor() {
  29720. // super();
  29721. // }
  29722. function rule() {
  29723. var ret = {};
  29724. ret.reg = new RegExp('');
  29725. return ret;
  29726. }
  29727. }, {
  29728. key: "beforeMakeHtml",
  29729. value: function beforeMakeHtml(str) {
  29730. return str.replace(/\\\n/g, '\\ \n');
  29731. }
  29732. }, {
  29733. key: "afterMakeHtml",
  29734. value: function afterMakeHtml(str) {
  29735. var $str = str.replace(/~Q/g, '~');
  29736. $str = $str.replace(/~X/g, '`');
  29737. $str = $str.replace(/~Y/g, '!');
  29738. $str = $str.replace(/~Z/g, '#');
  29739. $str = $str.replace(/~&/g, '&');
  29740. $str = $str.replace(/~K/g, '/');
  29741. return $str;
  29742. }
  29743. }]);
  29744. return Transfer;
  29745. }(SyntaxBase);
  29746. _defineProperty(Transfer, "HOOK_NAME", 'transfer');
  29747. var TypeError$l = global_1.TypeError;
  29748. // `Array.prototype.{ reduce, reduceRight }` methods implementation
  29749. var createMethod$4 = function (IS_RIGHT) {
  29750. return function (that, callbackfn, argumentsLength, memo) {
  29751. aCallable(callbackfn);
  29752. var O = toObject(that);
  29753. var self = indexedObject(O);
  29754. var length = lengthOfArrayLike(O);
  29755. var index = IS_RIGHT ? length - 1 : 0;
  29756. var i = IS_RIGHT ? -1 : 1;
  29757. if (argumentsLength < 2) while (true) {
  29758. if (index in self) {
  29759. memo = self[index];
  29760. index += i;
  29761. break;
  29762. }
  29763. index += i;
  29764. if (IS_RIGHT ? index < 0 : length <= index) {
  29765. throw TypeError$l('Reduce of empty array with no initial value');
  29766. }
  29767. }
  29768. for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
  29769. memo = callbackfn(memo, self[index], index, O);
  29770. }
  29771. return memo;
  29772. };
  29773. };
  29774. var arrayReduce = {
  29775. // `Array.prototype.reduce` method
  29776. // https://tc39.es/ecma262/#sec-array.prototype.reduce
  29777. left: createMethod$4(false),
  29778. // `Array.prototype.reduceRight` method
  29779. // https://tc39.es/ecma262/#sec-array.prototype.reduceright
  29780. right: createMethod$4(true)
  29781. };
  29782. var engineIsNode = classofRaw(global_1.process) == 'process';
  29783. var $reduce = arrayReduce.left;
  29784. var STRICT_METHOD$2 = arrayMethodIsStrict('reduce');
  29785. // Chrome 80-82 has a critical bug
  29786. // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
  29787. var CHROME_BUG = !engineIsNode && engineV8Version > 79 && engineV8Version < 83;
  29788. // `Array.prototype.reduce` method
  29789. // https://tc39.es/ecma262/#sec-array.prototype.reduce
  29790. _export({ target: 'Array', proto: true, forced: !STRICT_METHOD$2 || CHROME_BUG }, {
  29791. reduce: function reduce(callbackfn /* , initialValue */) {
  29792. var length = arguments.length;
  29793. return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
  29794. }
  29795. });
  29796. var reduce = entryVirtual('Array').reduce;
  29797. var ArrayPrototype$a = Array.prototype;
  29798. var reduce$1 = function (it) {
  29799. var own = it.reduce;
  29800. return it === ArrayPrototype$a || (objectIsPrototypeOf(ArrayPrototype$a, it) && own === ArrayPrototype$a.reduce) ? reduce : own;
  29801. };
  29802. var reduce$2 = reduce$1;
  29803. var reduce$3 = reduce$2;
  29804. function ownKeys$4(object, enumerableOnly) { var keys = keys$3(object); if (getOwnPropertySymbols$2) { var symbols = getOwnPropertySymbols$2(object); enumerableOnly && (symbols = filter$3(symbols).call(symbols, function (sym) { return getOwnPropertyDescriptor$3(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  29805. function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var _context21, _context22; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? forEach$3(_context21 = ownKeys$4(Object(source), !0)).call(_context21, function (key) { _defineProperty(target, key, source[key]); }) : getOwnPropertyDescriptors$2 ? defineProperties$2(target, getOwnPropertyDescriptors$2(source)) : forEach$3(_context22 = ownKeys$4(Object(source))).call(_context22, function (key) { defineProperty$5(target, key, getOwnPropertyDescriptor$3(source, key)); }); } return target; }
  29806. function _createSuper$f(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$f(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  29807. function _isNativeReflectConstruct$f() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  29808. var TABLE_LOOSE = 'loose';
  29809. var TABLE_STRICT = 'strict';
  29810. var Table = /*#__PURE__*/function (_ParagraphBase) {
  29811. _inherits(Table, _ParagraphBase);
  29812. var _super = _createSuper$f(Table);
  29813. function Table(_ref) {
  29814. var _this;
  29815. var externals = _ref.externals,
  29816. config = _ref.config;
  29817. _classCallCheck(this, Table);
  29818. _this = _super.call(this, {
  29819. needCache: true
  29820. });
  29821. var enableChart = config.enableChart,
  29822. ChartRenderEngine = config.chartRenderEngine,
  29823. requiredPackages = config.externals,
  29824. _config$chartEngineOp = config.chartEngineOptions,
  29825. chartEngineOptions = _config$chartEngineOp === void 0 ? {} : _config$chartEngineOp;
  29826. _this.chartRenderEngine = null;
  29827. if (enableChart === true) {
  29828. try {
  29829. _this.chartRenderEngine = new ChartRenderEngine(_objectSpread$3(_objectSpread$3({}, externals && requiredPackages instanceof Array && reduce$3(requiredPackages).call(requiredPackages, function (acc, pkg) {
  29830. delete chartEngineOptions[pkg]; // 过滤第三方包选项
  29831. return _objectSpread$3(_objectSpread$3({}, acc), {}, _defineProperty({}, pkg, externals[pkg]));
  29832. }, {})), {}, {
  29833. renderer: 'svg',
  29834. width: 500,
  29835. height: 300
  29836. }, chartEngineOptions));
  29837. } catch (error) {
  29838. console.warn(error);
  29839. }
  29840. }
  29841. return _this;
  29842. } // 保持每列长度一致
  29843. _createClass(Table, [{
  29844. key: "$extendColumns",
  29845. value: function $extendColumns(row, colCount) {
  29846. var _context;
  29847. var delta = colCount - row.length;
  29848. if (delta < 1) {
  29849. return row;
  29850. }
  29851. return concat$5(row).call(row, repeat$3(_context = '&nbsp;|').call(_context, delta).split('|', delta));
  29852. }
  29853. }, {
  29854. key: "$parseChartOptions",
  29855. value: function $parseChartOptions(cell) {
  29856. // 初始化失败
  29857. if (!this.chartRenderEngine) {
  29858. return null;
  29859. }
  29860. var CHART_REGEX = /^[ ]*:(\w+):(?:[ ]*{(.*?)}[ ]*)?$/;
  29861. if (!CHART_REGEX.test(cell)) {
  29862. return null;
  29863. }
  29864. var match = cell.match(CHART_REGEX);
  29865. var _match = _slicedToArray(match, 3),
  29866. chartType = _match[1],
  29867. axisOptions = _match[2];
  29868. var DEFAULT_AXIS_OPTIONS = ['x', 'y'];
  29869. return {
  29870. type: chartType,
  29871. options: axisOptions ? axisOptions.split(/\s*,\s*/) : DEFAULT_AXIS_OPTIONS
  29872. };
  29873. }
  29874. }, {
  29875. key: "$parseColumnAlignRules",
  29876. value: function $parseColumnAlignRules(row) {
  29877. var COLUMN_ALIGN_MAP = {
  29878. L: 'left',
  29879. R: 'right',
  29880. C: 'center'
  29881. };
  29882. var COLUMN_ALIGN_CACHE_SIGN = ['U', 'L', 'R', 'C']; // U for undefined
  29883. var textAlignRules = map$3(row).call(row, function (rule) {
  29884. var $rule = trim$3(rule).call(rule);
  29885. var index = 0;
  29886. if (/^:/.test($rule)) {
  29887. index += 1;
  29888. }
  29889. if (/:$/.test($rule)) {
  29890. index += 2;
  29891. }
  29892. return COLUMN_ALIGN_CACHE_SIGN[index];
  29893. });
  29894. return {
  29895. textAlignRules: textAlignRules,
  29896. COLUMN_ALIGN_MAP: COLUMN_ALIGN_MAP
  29897. };
  29898. }
  29899. }, {
  29900. key: "$parseTable",
  29901. value: function $parseTable(lines, sentenceMakeFunc, dataLines) {
  29902. var _context2,
  29903. _this2 = this,
  29904. _context8,
  29905. _context9,
  29906. _context10,
  29907. _context11,
  29908. _context12;
  29909. var maxCol = 0;
  29910. var rows = map$3(lines).call(lines, function (line, index) {
  29911. var cols = line.replace(/\\\|/g, '~CS').split('|');
  29912. if (cols[0] === '') {
  29913. cols.shift();
  29914. }
  29915. if (cols[cols.length - 1] === '') {
  29916. cols.pop();
  29917. } // 文本对齐相关列,不作为最多列数的参考依据
  29918. index !== 1 && (maxCol = Math.max(maxCol, cols.length));
  29919. return cols;
  29920. });
  29921. var _this$$parseColumnAli = this.$parseColumnAlignRules(rows[1]),
  29922. textAlignRules = _this$$parseColumnAli.textAlignRules,
  29923. COLUMN_ALIGN_MAP = _this$$parseColumnAli.COLUMN_ALIGN_MAP;
  29924. var tableObject = {
  29925. header: [],
  29926. rows: [],
  29927. colLength: maxCol,
  29928. rowLength: rows.length - 2 // 去除表头和控制行
  29929. };
  29930. var chartOptions = this.$parseChartOptions(rows[0][0]);
  29931. var chartOptionsSign = this.$engine.md5(rows[0][0]); // 如果需要生成图表,
  29932. if (chartOptions) {
  29933. rows[0][0] = '';
  29934. }
  29935. /**
  29936. * ~CTHD: <thead>
  29937. * ~CTHD$: </thead>
  29938. * ~CTBD: <tbody>
  29939. * ~CTBD$: </tbody>
  29940. * ~CTR: <tr>
  29941. * ~CTR$: </tr>
  29942. * ~CTH(L|R|C|U): <th>
  29943. * ~CTH$: </th>
  29944. * ~CTD(L|R|C|U): <td>
  29945. * ~CTD$: </td>
  29946. */
  29947. var tableHeader = map$3(_context2 = this.$extendColumns(rows[0], maxCol)).call(_context2, function (cell, col) {
  29948. var _context3, _context4;
  29949. tableObject.header.push(cell.replace(/~CS/g, '\\|'));
  29950. var _sentenceMakeFunc = sentenceMakeFunc(trim$3(_context3 = cell.replace(/~CS/g, '\\|')).call(_context3)),
  29951. cellHtml = _sentenceMakeFunc.html; // 前后补一个空格,否则自动链接会将缓存的内容全部收入链接内部
  29952. return concat$5(_context4 = "~CTH".concat(textAlignRules[col] || 'U', " ")).call(_context4, cellHtml, " ~CTH$");
  29953. }).join('');
  29954. var tableRows = reduce$3(rows).call(rows, function (table, row, line) {
  29955. var _context5;
  29956. if (line <= 1) {
  29957. return table;
  29958. }
  29959. var currentRowCountWithoutHeader = line - 2;
  29960. tableObject.rows[currentRowCountWithoutHeader] = [];
  29961. var $extendedColumns = map$3(_context5 = _this2.$extendColumns(row, maxCol)).call(_context5, function (cell, col) {
  29962. var _context6, _context7;
  29963. tableObject.rows[currentRowCountWithoutHeader].push(cell.replace(/~CS/g, '\\|'));
  29964. var _sentenceMakeFunc2 = sentenceMakeFunc(trim$3(_context6 = cell.replace(/~CS/g, '\\|')).call(_context6)),
  29965. cellHtml = _sentenceMakeFunc2.html; // 前后补一个空格,否则自动链接会将缓存的内容全部收入链接内部
  29966. return concat$5(_context7 = "~CTD".concat(textAlignRules[col] || 'U', " ")).call(_context7, cellHtml, " ~CTD$");
  29967. });
  29968. table.push("~CTR".concat($extendedColumns.join(''), "~CTR$"));
  29969. return table;
  29970. }, []).join(''); // console.log('obj', tableObject);
  29971. var tableResult = this.$renderTable(COLUMN_ALIGN_MAP, tableHeader, tableRows, dataLines);
  29972. if (!chartOptions) {
  29973. return tableResult;
  29974. }
  29975. var chart = this.chartRenderEngine.render(chartOptions.type, chartOptions.options, tableObject);
  29976. var chartHtml = concat$5(_context8 = concat$5(_context9 = concat$5(_context10 = concat$5(_context11 = "<figure id=\"table_chart_".concat(chartOptionsSign, "_")).call(_context11, tableResult.sign, "\"\n data-sign=\"table_chart_")).call(_context10, chartOptionsSign, "_")).call(_context9, tableResult.sign, "\" data-lines=\"0\">")).call(_context8, chart, "</figure>");
  29977. return {
  29978. html: concat$5(_context12 = "".concat(chartHtml)).call(_context12, tableResult.html),
  29979. sign: chartOptionsSign + tableResult.sign
  29980. };
  29981. }
  29982. /**
  29983. * 如果table.head是空的,就不渲染<thead>了
  29984. * @param {String} str
  29985. * @returns {Boolean}
  29986. */
  29987. }, {
  29988. key: "$testHeadEmpty",
  29989. value: function $testHeadEmpty(str) {
  29990. var test = str.replace(/&nbsp;/g, '').replace(/\s/g, '').replace(/(~CTH\$|~CTHU|~CTHL|~CTHR|~CTHC)/g, '');
  29991. return (test === null || test === void 0 ? void 0 : test.length) > 0;
  29992. }
  29993. }, {
  29994. key: "$renderTable",
  29995. value: function $renderTable(COLUMN_ALIGN_MAP, tableHeader, tableRows, dataLines) {
  29996. var _context13, _context14, _context15, _context16;
  29997. var cacheSrc = this.$testHeadEmpty(tableHeader) ? concat$5(_context13 = "~CTHD".concat(tableHeader, "~CTHD$~CTBD")).call(_context13, tableRows, "~CTBD$") : "~CTBD".concat(tableRows, "~CTBD$");
  29998. var html = cacheSrc;
  29999. var sign = this.$engine.md5(html);
  30000. var renderHtml = html.replace(/~CTHD\$/g, '</thead>').replace(/~CTHD/g, '<thead>').replace(/~CTBD\$/g, '</tbody>').replace(/~CTBD/g, '</tbody>').replace(/~CTR\$/g, '</tr>').replace(/~CTR/g, '<tr>').replace(/[ ]?~CTH\$/g, '</th>').replace(/[ ]?~CTD\$/g, '</td>') // 在这里将加上的空格还原回来
  30001. .replace(/~CT(D|H)(L|R|C|U)[ ]?/g, function (match, type, align) {
  30002. var tag = "<t".concat(type);
  30003. if (align === 'U') {
  30004. tag += '>';
  30005. } else {
  30006. tag += " align=\"".concat(COLUMN_ALIGN_MAP[align], "\">");
  30007. }
  30008. return tag;
  30009. }).replace(/\\\|/g, '|'); // escape \|
  30010. return {
  30011. html: concat$5(_context14 = concat$5(_context15 = concat$5(_context16 = "<div class=\"cherry-table-container\" data-sign=\"".concat(sign)).call(_context16, dataLines, "\" data-lines=\"")).call(_context15, dataLines, "\">\n <table class=\"cherry-table\">")).call(_context14, renderHtml, "</table></div>"),
  30012. sign: sign
  30013. };
  30014. }
  30015. }, {
  30016. key: "makeHtml",
  30017. value: function makeHtml(str, sentenceMakeFunc) {
  30018. var _this3 = this;
  30019. var $str = str; // strict fenced mode
  30020. if (this.test($str, TABLE_STRICT)) {
  30021. $str = $str.replace(this.RULE[TABLE_STRICT].reg, function (match, leading) {
  30022. var _context17;
  30023. var dataLines = _this3.getLineCount(match, leading); // 必须先trim,否则分割出来的结果不对
  30024. // 将fenced mode转换为loose mode
  30025. var lines = map$3(_context17 = trim$3(match).call(match).split(/\n/)).call(_context17, function (line) {
  30026. var _context18;
  30027. return trim$3(_context18 = String(line)).call(_context18);
  30028. });
  30029. var _this3$$parseTable = _this3.$parseTable(lines, sentenceMakeFunc, dataLines),
  30030. table = _this3$$parseTable.html,
  30031. sign = _this3$$parseTable.sign;
  30032. return _this3.getCacheWithSpace(_this3.pushCache(table, sign, dataLines), match);
  30033. });
  30034. } // loose mode
  30035. if (this.test($str, TABLE_LOOSE)) {
  30036. // console.log(TABLE_LOOSE);
  30037. $str = $str.replace(this.RULE[TABLE_LOOSE].reg, function (match, leading) {
  30038. var _context19;
  30039. var dataLines = _this3.getLineCount(match, leading); // 必须先trim,否则分割出来的结果不对
  30040. var lines = map$3(_context19 = trim$3(match).call(match).split(/\n/)).call(_context19, function (line) {
  30041. var _context20;
  30042. return trim$3(_context20 = String(line)).call(_context20);
  30043. });
  30044. var _this3$$parseTable2 = _this3.$parseTable(lines, sentenceMakeFunc, dataLines),
  30045. table = _this3$$parseTable2.html,
  30046. sign = _this3$$parseTable2.sign;
  30047. return _this3.getCacheWithSpace(_this3.pushCache(table, sign, dataLines), match);
  30048. });
  30049. }
  30050. return $str;
  30051. }
  30052. }, {
  30053. key: "test",
  30054. value: function test(str, flavor) {
  30055. return this.RULE[flavor].reg && this.RULE[flavor].reg.test(str);
  30056. }
  30057. }, {
  30058. key: "rule",
  30059. value: function rule() {
  30060. return getTableRule();
  30061. }
  30062. }]);
  30063. return Table;
  30064. }(ParagraphBase);
  30065. _defineProperty(Table, "HOOK_NAME", 'table');
  30066. /**
  30067. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  30068. *
  30069. * Licensed under the Apache License, Version 2.0 (the "License");
  30070. * you may not use this file except in compliance with the License.
  30071. * You may obtain a copy of the License at
  30072. *
  30073. * http://www.apache.org/licenses/LICENSE-2.0
  30074. *
  30075. * Unless required by applicable law or agreed to in writing, software
  30076. * distributed under the License is distributed on an "AS IS" BASIS,
  30077. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  30078. * See the License for the specific language governing permissions and
  30079. * limitations under the License.
  30080. */
  30081. /**
  30082. * 判断当前是否浏览器环境
  30083. * @returns
  30084. */
  30085. function isBrowser() {
  30086. return (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object';
  30087. }
  30088. function _createSuper$g(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$g(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  30089. function _isNativeReflectConstruct$g() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  30090. var Br = /*#__PURE__*/function (_ParagraphBase) {
  30091. _inherits(Br, _ParagraphBase);
  30092. var _super = _createSuper$g(Br);
  30093. function Br(options) {
  30094. var _this;
  30095. _classCallCheck(this, Br);
  30096. _this = _super.call(this, {
  30097. needCache: true
  30098. });
  30099. _this.classicBr = testKeyInLocal('classicBr') ? getIsClassicBrFromLocal() : options.globalConfig.classicBr;
  30100. return _this;
  30101. }
  30102. _createClass(Br, [{
  30103. key: "beforeMakeHtml",
  30104. value: function beforeMakeHtml(str) {
  30105. var _this2 = this;
  30106. if (!this.test(str)) {
  30107. return str;
  30108. }
  30109. return str.replace(this.RULE.reg, function (match, lines, index) {
  30110. var _lines$match$length, _lines$match;
  30111. // 不处理全文开头的连续空行
  30112. if (index === 0) {
  30113. return match;
  30114. }
  30115. var lineCount = (_lines$match$length = (_lines$match = lines.match(/\n/g)) === null || _lines$match === void 0 ? void 0 : _lines$match.length) !== null && _lines$match$length !== void 0 ? _lines$match$length : 0;
  30116. var sign = "br".concat(lineCount);
  30117. var html = '';
  30118. if (isBrowser()) {
  30119. // 为了同步滚动
  30120. if (_this2.classicBr) {
  30121. var _context;
  30122. html = concat$5(_context = "<span data-sign=\"".concat(sign, "\" data-type=\"br\" data-lines=\"")).call(_context, lineCount, "\"></span>");
  30123. } else {
  30124. var _context2;
  30125. html = concat$5(_context2 = "<p data-sign=\"".concat(sign, "\" data-type=\"br\" data-lines=\"")).call(_context2, lineCount, "\">&nbsp;</p>");
  30126. }
  30127. } else {
  30128. // node环境下直接输出br
  30129. html = _this2.classicBr ? '' : '<br/>';
  30130. }
  30131. var placeHolder = _this2.pushCache(html, sign, lineCount); // 结尾只补充一个\n是因为Br将下一个段落中间的所有换行都替换掉了,而两个换行符会导致下一个区块行数计算错误
  30132. return "\n\n".concat(placeHolder, "\n");
  30133. });
  30134. }
  30135. }, {
  30136. key: "makeHtml",
  30137. value: function makeHtml(str, sentenceMakeFunc) {
  30138. return str;
  30139. } // afterMakeHtml(str) {
  30140. // return str.replace(/~~B/g, (match) => {
  30141. // let lines = that.brCache.shift() - 1;
  30142. // return '<p data-sign="br' + lines + '" data-type="br" data-lines="' + lines + '">&nbsp;</p>';
  30143. // });
  30144. // }
  30145. // default: this.restoreCache();
  30146. }, {
  30147. key: "rule",
  30148. value: function rule() {
  30149. /**
  30150. * 样例:
  30151. * block1\n
  30152. * \n
  30153. * \n
  30154. * block2
  30155. *
  30156. * 匹配逻辑:
  30157. * 开头必为一个换行符,所以后续只需要匹配至少两个空行即可生成一个换行,行数即content匹配到的换行符个数
  30158. */
  30159. var ret = {
  30160. begin: '(?:\\n)',
  30161. end: '',
  30162. content: '((?:\\h*\\n){2,})'
  30163. };
  30164. ret.reg = compileRegExp(ret, 'g', true);
  30165. return ret;
  30166. }
  30167. }]);
  30168. return Br;
  30169. }(ParagraphBase);
  30170. _defineProperty(Br, "HOOK_NAME", 'br');
  30171. function _createSuper$h(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$h(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  30172. function _isNativeReflectConstruct$h() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  30173. /**
  30174. * 分割线语法
  30175. */
  30176. var Hr = /*#__PURE__*/function (_ParagraphBase) {
  30177. _inherits(Hr, _ParagraphBase);
  30178. var _super = _createSuper$h(Hr);
  30179. function Hr() {
  30180. _classCallCheck(this, Hr);
  30181. return _super.call(this, {
  30182. needCache: true
  30183. });
  30184. }
  30185. _createClass(Hr, [{
  30186. key: "beforeMakeHtml",
  30187. value: function beforeMakeHtml(str) {
  30188. var _this = this;
  30189. return str.replace(this.RULE.reg, function (match, preLines) {
  30190. var _context;
  30191. var lineCount = (preLines.match(/\n/g) || []).length + 1; // 计算签名,签名可能会重复,符合预期
  30192. var sign = "hr".concat(lineCount);
  30193. var placeHolder = _this.pushCache(concat$5(_context = "<hr data-sign=\"".concat(sign, "\" data-lines=\"")).call(_context, lineCount, "\" />"), sign);
  30194. return prependLineFeedForParagraph(match, placeHolder);
  30195. });
  30196. }
  30197. }, {
  30198. key: "makeHtml",
  30199. value: function makeHtml(str, sentenceMakeFunc) {
  30200. return str;
  30201. }
  30202. }, {
  30203. key: "rule",
  30204. value: function rule() {
  30205. // 分割线必须有从新行开始,比如以换行结束
  30206. var ret = {
  30207. begin: '(?:^|\\n)(\\n*)[ ]*',
  30208. end: '(?=$|\\n)',
  30209. content: '((?:-[ \\t]*){3,}|(?:\\*[ \\t]*){3,}|(?:_[ \\t]*){3,})'
  30210. };
  30211. ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
  30212. return ret;
  30213. }
  30214. }]);
  30215. return Hr;
  30216. }(ParagraphBase);
  30217. _defineProperty(Hr, "HOOK_NAME", 'hr');
  30218. /**
  30219. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  30220. *
  30221. * Licensed under the Apache License, Version 2.0 (the "License");
  30222. * you may not use this file except in compliance with the License.
  30223. * You may obtain a copy of the License at
  30224. *
  30225. * http://www.apache.org/licenses/LICENSE-2.0
  30226. *
  30227. * Unless required by applicable law or agreed to in writing, software
  30228. * distributed under the License is distributed on an "AS IS" BASIS,
  30229. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  30230. * See the License for the specific language governing permissions and
  30231. * limitations under the License.
  30232. */
  30233. var imgAltHelper = {
  30234. /**
  30235. * 提取alt部分的扩展属性
  30236. * @param {string} alt 图片引用中的alt部分
  30237. * @returns
  30238. */
  30239. processExtendAttributesInAlt: function processExtendAttributesInAlt(alt) {
  30240. var attrRegex = /#([0-9]+(px|em|pt|pc|in|mm|cm|ex|%)|auto)/g;
  30241. var info = alt.match(attrRegex);
  30242. if (!info) {
  30243. return '';
  30244. }
  30245. var extendAttrs = '';
  30246. var _info = _slicedToArray(info, 2),
  30247. width = _info[0],
  30248. height = _info[1];
  30249. if (width) {
  30250. extendAttrs = " width=\"".concat(width.replace(/[ #]*/g, ''), "\"");
  30251. }
  30252. if (height) {
  30253. extendAttrs += " height=\"".concat(height.replace(/[ #]*/g, ''), "\"");
  30254. }
  30255. return extendAttrs;
  30256. },
  30257. /**
  30258. * 提取alt部分的扩展样式
  30259. * @param {string} alt 图片引用中的alt部分
  30260. * @returns {{extendStyles:string, extendClasses:string}}
  30261. */
  30262. processExtendStyleInAlt: function processExtendStyleInAlt(alt) {
  30263. var extendStyles = this.$getAlignment(alt);
  30264. var extendClasses = '';
  30265. var info = alt.match(/#(border|shadow|radius|B|S|R)/g);
  30266. if (info) {
  30267. for (var i = 0; i < info.length; i++) {
  30268. switch (info[i]) {
  30269. case '#border':
  30270. case '#B':
  30271. extendStyles += 'border:1px solid #888888;padding: 2px;box-sizing: border-box;';
  30272. extendClasses += ' cherry-img-border';
  30273. break;
  30274. case '#shadow':
  30275. case '#S':
  30276. extendStyles += 'box-shadow:0 2px 15px -5px rgb(0 0 0 / 50%);';
  30277. extendClasses += ' cherry-img-shadow';
  30278. break;
  30279. case '#radius':
  30280. case '#R':
  30281. extendStyles += 'border-radius: 15px;';
  30282. extendClasses += ' cherry-img-radius';
  30283. break;
  30284. }
  30285. }
  30286. }
  30287. return {
  30288. extendStyles: extendStyles,
  30289. extendClasses: extendClasses
  30290. };
  30291. },
  30292. /**
  30293. * 从alt中提取对齐方式信息
  30294. * @param {string} alt
  30295. * @returns {string}
  30296. */
  30297. $getAlignment: function $getAlignment(alt) {
  30298. var styleRegex = /#(center|right|left|float-right|float-left)/i;
  30299. var info = alt.match(styleRegex);
  30300. if (!info) {
  30301. return '';
  30302. }
  30303. var _info2 = _slicedToArray(info, 2),
  30304. alignment = _info2[1];
  30305. switch (alignment) {
  30306. case 'center':
  30307. return 'transform:translateX(-50%);margin-left:50%;display:block;';
  30308. case 'right':
  30309. return 'transform:translateX(-100%);margin-left:100%;margin-right:-100%;display:block;';
  30310. case 'left':
  30311. return 'transform:translateX(0);margin-left:0;display:block;';
  30312. case 'float-right':
  30313. return 'float:right;transform:translateX(0);margin-left:0;display:block;';
  30314. case 'float-left':
  30315. return 'float:left;transform:translateX(0);margin-left:0;display:block;';
  30316. }
  30317. }
  30318. };
  30319. function ownKeys$5(object, enumerableOnly) { var keys = keys$3(object); if (getOwnPropertySymbols$2) { var symbols = getOwnPropertySymbols$2(object); enumerableOnly && (symbols = filter$3(symbols).call(symbols, function (sym) { return getOwnPropertyDescriptor$3(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  30320. function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var _context22, _context23; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? forEach$3(_context22 = ownKeys$5(Object(source), !0)).call(_context22, function (key) { _defineProperty(target, key, source[key]); }) : getOwnPropertyDescriptors$2 ? defineProperties$2(target, getOwnPropertyDescriptors$2(source)) : forEach$3(_context23 = ownKeys$5(Object(source))).call(_context23, function (key) { defineProperty$5(target, key, getOwnPropertyDescriptor$3(source, key)); }); } return target; }
  30321. function _createSuper$i(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$i(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  30322. function _isNativeReflectConstruct$i() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  30323. var replacerFactory = function replacerFactory(type, match, leadingChar, alt, link, title, posterContent, config, globalConfig) {
  30324. var refType = typeof link === 'undefined' ? 'ref' : 'url';
  30325. var attrs = '';
  30326. if (refType === 'ref') {
  30327. // TODO: 全局引用
  30328. return match;
  30329. }
  30330. if (refType === 'url') {
  30331. var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8;
  30332. var extent = imgAltHelper.processExtendAttributesInAlt(alt);
  30333. var _imgAltHelper$process = imgAltHelper.processExtendStyleInAlt(alt),
  30334. style = _imgAltHelper$process.extendStyles,
  30335. classes = _imgAltHelper$process.extendClasses;
  30336. if (style) {
  30337. style = " style=\"".concat(style, "\" ");
  30338. }
  30339. if (classes) {
  30340. classes = " class=\"".concat(classes, "\" ");
  30341. }
  30342. attrs = title && trim$3(title).call(title) !== '' ? " title=\"".concat(escapeHTMLSpecialCharOnce(title), "\"") : '';
  30343. if (posterContent) {
  30344. attrs += " poster=".concat(encodeURIOnce(posterContent));
  30345. }
  30346. var processedURL = globalConfig.urlProcessor(link, type);
  30347. var defaultWrapper = concat$5(_context = concat$5(_context2 = concat$5(_context3 = concat$5(_context4 = concat$5(_context5 = concat$5(_context6 = concat$5(_context7 = "<".concat(type, " src=\"")).call(_context7, UrlCache.set(encodeURIOnce(processedURL)), "\"")).call(_context6, attrs, " ")).call(_context5, extent, " ")).call(_context4, style, " ")).call(_context3, classes, " controls=\"controls\">")).call(_context2, escapeHTMLSpecialCharOnce(alt || ''), "</")).call(_context, type, ">");
  30348. return concat$5(_context8 = "".concat(leadingChar)).call(_context8, config.videoWrapper ? config.videoWrapper(link) : defaultWrapper);
  30349. } // should never happen
  30350. return match;
  30351. };
  30352. var Image$1 = /*#__PURE__*/function (_SyntaxBase) {
  30353. _inherits(Image, _SyntaxBase);
  30354. var _super = _createSuper$i(Image);
  30355. function Image(_ref) {
  30356. var _this;
  30357. var config = _ref.config,
  30358. globalConfig = _ref.globalConfig;
  30359. _classCallCheck(this, Image);
  30360. _this = _super.call(this, null);
  30361. _this.urlProcessor = globalConfig.urlProcessor; // TODO: URL Validator
  30362. _this.extendMedia = {
  30363. tag: ['video', 'audio'],
  30364. replacer: {
  30365. video: function video(match, leadingChar, alt, link, title, poster) {
  30366. return replacerFactory('video', match, leadingChar, alt, link, title, poster, config, globalConfig);
  30367. },
  30368. audio: function audio(match, leadingChar, alt, link, title, poster) {
  30369. return replacerFactory('audio', match, leadingChar, alt, link, title, poster, config, globalConfig);
  30370. }
  30371. }
  30372. };
  30373. _this.RULE = _this.rule(_this.extendMedia);
  30374. return _this;
  30375. }
  30376. _createClass(Image, [{
  30377. key: "toHtml",
  30378. value: function toHtml(match, leadingChar, alt, link, title, ref, extendAttrs) {
  30379. // console.log(match, alt, link, ref, title);
  30380. var refType = typeof link === 'undefined' ? 'ref' : 'url';
  30381. var attrs = '';
  30382. if (refType === 'ref') {
  30383. // 全局引用,理应在CommentReference中被替换,没有被替换说明没有定义引用项
  30384. return match;
  30385. }
  30386. if (refType === 'url') {
  30387. var _context9, _context10, _context11, _context12, _context13, _context14, _context15, _context16;
  30388. var extent = imgAltHelper.processExtendAttributesInAlt(alt);
  30389. var _imgAltHelper$process2 = imgAltHelper.processExtendStyleInAlt(alt),
  30390. style = _imgAltHelper$process2.extendStyles,
  30391. classes = _imgAltHelper$process2.extendClasses;
  30392. if (style) {
  30393. style = " style=\"".concat(style, "\" ");
  30394. }
  30395. if (classes) {
  30396. classes = " class=\"".concat(classes, "\" ");
  30397. }
  30398. attrs = title && trim$3(title).call(title) !== '' ? " title=\"".concat(escapeHTMLSpecialCharOnce(title.replace(/["']/g, '')), "\"") : '';
  30399. var srcProp = 'src';
  30400. var srcValue;
  30401. var cherryOptions = this.$engine.$cherry.options;
  30402. if (cherryOptions.callback && cherryOptions.callback.beforeImageMounted) {
  30403. var imgAttrs = cherryOptions.callback.beforeImageMounted(srcProp, link);
  30404. srcProp = imgAttrs.srcProp || srcProp;
  30405. srcValue = imgAttrs.src || link;
  30406. }
  30407. var extendAttrStr = extendAttrs ? extendAttrs.replace(/[{}]/g, '').replace(/([^=\s]+)=([^\s]+)/g, '$1="$2"').replace(/&/g, '&amp;') // 对&多做一次转义,cherry现有的机制会自动把&amp;转成&,只有多做一次转义才能抵消cherry的机制
  30408. : '';
  30409. return concat$5(_context9 = concat$5(_context10 = concat$5(_context11 = concat$5(_context12 = concat$5(_context13 = concat$5(_context14 = concat$5(_context15 = concat$5(_context16 = "".concat(leadingChar, "<img ")).call(_context16, srcProp, "=\"")).call(_context15, UrlCache.set(encodeURIOnce(this.urlProcessor(srcValue, 'image'))), "\" ")).call(_context14, extent, " ")).call(_context13, style, " ")).call(_context12, classes, " alt=\"")).call(_context11, escapeHTMLSpecialCharOnce(alt || ''), "\"")).call(_context10, attrs, " ")).call(_context9, extendAttrStr, "/>");
  30410. } // should never happen
  30411. return match;
  30412. }
  30413. }, {
  30414. key: "toMediaHtml",
  30415. value: function toMediaHtml(match, leadingChar, mediaType, alt, link, title, ref, posterWrap, poster) {
  30416. var _this$extendMedia$rep, _context17;
  30417. if (!this.extendMedia.replacer[mediaType]) {
  30418. return match;
  30419. }
  30420. for (var _len = arguments.length, args = new Array(_len > 9 ? _len - 9 : 0), _key = 9; _key < _len; _key++) {
  30421. args[_key - 9] = arguments[_key];
  30422. }
  30423. return (_this$extendMedia$rep = this.extendMedia.replacer[mediaType]).call.apply(_this$extendMedia$rep, concat$5(_context17 = [this, match, leadingChar, alt, link, title, poster]).call(_context17, args));
  30424. }
  30425. }, {
  30426. key: "makeHtml",
  30427. value: function makeHtml(str) {
  30428. var $str = str;
  30429. if (this.test($str)) {
  30430. if (isLookbehindSupported()) {
  30431. var _context18;
  30432. $str = $str.replace(this.RULE.reg, bind$5(_context18 = this.toHtml).call(_context18, this));
  30433. } else {
  30434. var _context19;
  30435. $str = replaceLookbehind($str, this.RULE.reg, bind$5(_context19 = this.toHtml).call(_context19, this), true, 1);
  30436. }
  30437. }
  30438. if (this.testMedia($str)) {
  30439. if (isLookbehindSupported()) {
  30440. var _context20;
  30441. $str = $str.replace(this.RULE.regExtend, bind$5(_context20 = this.toMediaHtml).call(_context20, this));
  30442. } else {
  30443. var _context21;
  30444. $str = replaceLookbehind($str, this.RULE.regExtend, bind$5(_context21 = this.toMediaHtml).call(_context21, this), true, 1);
  30445. }
  30446. }
  30447. return $str;
  30448. } // afterMakeHtml(str) {
  30449. // return UrlCache.restoreAll(str);
  30450. // }
  30451. }, {
  30452. key: "testMedia",
  30453. value: function testMedia(str) {
  30454. return this.RULE.regExtend && this.RULE.regExtend.test(str);
  30455. }
  30456. }, {
  30457. key: "rule",
  30458. value: function rule(extendMedia) {
  30459. var ret = {
  30460. // lookbehind启用分组是为了和不兼容lookbehind的场景共用一个回调
  30461. begin: isLookbehindSupported() ? '((?<!\\\\))!' : '(^|[^\\\\])!',
  30462. content: ['\\[([^\\n]*?)\\]', // ?<alt>
  30463. '[ \\t]*', // any spaces
  30464. "".concat('(?:' + '\\(' + '([^"][^\\s]+?)' + // ?<link> url
  30465. '(?:[ \\t]((?:".*?")|(?:\'.*?\')))?' + // ?<title> optional
  30466. '\\)' + '|' + // or
  30467. '\\[(').concat(NOT_ALL_WHITE_SPACES_INLINE, ")\\]") + // ?<ref> global ref
  30468. ')'].join(''),
  30469. end: '({[^{}]+?})?' // extend attrs e.g. {width=50 height=60}
  30470. };
  30471. if (extendMedia) {
  30472. var extend = _objectSpread$4({}, ret); // TODO: 支持Lookbehind
  30473. extend.begin = isLookbehindSupported() ? "((?<!\\\\))!(".concat(extendMedia.tag.join('|'), ")") : "(^|[^\\\\])!(".concat(extendMedia.tag.join('|'), ")");
  30474. extend.end = '({poster=(.*)})?';
  30475. ret.regExtend = compileRegExp(extend, 'g');
  30476. }
  30477. ret.reg = compileRegExp(ret, 'g');
  30478. return ret;
  30479. }
  30480. }]);
  30481. return Image;
  30482. }(SyntaxBase);
  30483. _defineProperty(Image$1, "HOOK_NAME", 'image');
  30484. function ownKeys$6(object, enumerableOnly) { var keys = keys$3(object); if (getOwnPropertySymbols$2) { var symbols = getOwnPropertySymbols$2(object); enumerableOnly && (symbols = filter$3(symbols).call(symbols, function (sym) { return getOwnPropertyDescriptor$3(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  30485. function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var _context10, _context11; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? forEach$3(_context10 = ownKeys$6(Object(source), !0)).call(_context10, function (key) { _defineProperty(target, key, source[key]); }) : getOwnPropertyDescriptors$2 ? defineProperties$2(target, getOwnPropertyDescriptors$2(source)) : forEach$3(_context11 = ownKeys$6(Object(source))).call(_context11, function (key) { defineProperty$5(target, key, getOwnPropertyDescriptor$3(source, key)); }); } return target; }
  30486. function _createSuper$j(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$j(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  30487. function _isNativeReflectConstruct$j() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  30488. var INDENT_SPACE_NUM = 4; // commonmark default use 1~4 spaces for indent
  30489. var TAB_SPACE_NUM = 4; // 1 tab === 4 space
  30490. function attrsToAttributeString(object) {
  30491. var _context;
  30492. if (_typeof(object) !== 'object' && keys$3(object).length < 1) {
  30493. return '';
  30494. }
  30495. var attrs = ['']; // 为了join一步到位
  30496. forEach$3(_context = keys$3(object)).call(_context, function (key) {
  30497. var _context2;
  30498. attrs.push(concat$5(_context2 = "".concat(key, "=\"")).call(_context2, object[key], "\""));
  30499. });
  30500. return attrs.join(' ');
  30501. }
  30502. function makeChecklist(text) {
  30503. return text.replace(/^((?:|[\t ]+)[*+-]\s+)\[(\s|x)\]/gm, function (whole, pre, test) {
  30504. var _context3;
  30505. var checkHtml = /\s/.test(test) ? '<span class="ch-icon ch-icon-square"></span>' : '<span class="ch-icon ch-icon-check"></span>';
  30506. return concat$5(_context3 = "".concat(pre)).call(_context3, checkHtml);
  30507. });
  30508. } // 缩进处理
  30509. function handleIndent(str, node) {
  30510. var indentRegex = /^(\t|[ ])/;
  30511. var $str = str;
  30512. while (indentRegex.test($str)) {
  30513. node.space += $str[0] === '\t' ? TAB_SPACE_NUM : 1;
  30514. $str = $str.replace(indentRegex, '');
  30515. }
  30516. return $str;
  30517. } // 序号样式处理
  30518. function getListStyle(m2) {
  30519. if (/^[a-z]/.test(m2)) {
  30520. return 'lower-greek';
  30521. }
  30522. if (/^[一二三四五六七八九十]/.test(m2)) {
  30523. return 'cjk-ideographic';
  30524. }
  30525. if (/^I/.test(m2)) {
  30526. return 'upper-roman';
  30527. }
  30528. if (/^\+/.test(m2)) {
  30529. return 'circle';
  30530. }
  30531. if (/^\*/.test(m2)) {
  30532. return 'square';
  30533. }
  30534. return 'default';
  30535. } // 标识符处理
  30536. function handleMark(str, node) {
  30537. var listRegex = /^((([*+-]|\d+[.]|[a-z]\.|[I一二三四五六七八九十]+\.)[ \t]+)([^\r]*?)($|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.]|[a-z]\.|[I一二三四五六七八九十]+\.)[ \t]+)))/;
  30538. if (!listRegex.test(str)) {
  30539. node.type = 'blank';
  30540. return str;
  30541. }
  30542. return str.replace(listRegex, function (wholeMatch, m1, m2, m3, m4) {
  30543. node.type = m2.search(/[*+-]/g) > -1 ? 'ul' : 'ol';
  30544. node.listStyle = getListStyle(m2);
  30545. node.start = Number(m2.replace('.', '')) ? Number(m2.replace('.', '')) : 1;
  30546. return m4;
  30547. });
  30548. }
  30549. var Node$1 = /*#__PURE__*/_createClass( // 列表树节点
  30550. function Node() {
  30551. _classCallCheck(this, Node);
  30552. this.index = 0;
  30553. this.space = 0;
  30554. this.type = '';
  30555. this.start = 1;
  30556. this.listStyle = '';
  30557. this.strs = [];
  30558. this.children = [];
  30559. this.lines = 0;
  30560. });
  30561. var List = /*#__PURE__*/function (_ParagraphBase) {
  30562. _inherits(List, _ParagraphBase);
  30563. var _super = _createSuper$j(List);
  30564. function List(_ref) {
  30565. var _this;
  30566. var config = _ref.config;
  30567. _classCallCheck(this, List);
  30568. _this = _super.call(this, {
  30569. needCache: true
  30570. });
  30571. _this.config = config || {};
  30572. _this.tree = [];
  30573. _this.emptyLines = 0;
  30574. _this.indentSpace = Math.max(_this.config.indentSpace, 2);
  30575. return _this;
  30576. }
  30577. _createClass(List, [{
  30578. key: "addNode",
  30579. value: function addNode(node, current, parent, last) {
  30580. if (node.type === 'blank') {
  30581. this.tree[last].strs.push(node.strs[0]);
  30582. } else {
  30583. this.tree[parent].children.push(current);
  30584. this.tree[current] = _objectSpread$5(_objectSpread$5({}, node), {}, {
  30585. parent: parent
  30586. });
  30587. }
  30588. }
  30589. }, {
  30590. key: "buildTree",
  30591. value: function buildTree(html, sentenceMakeFunc) {
  30592. var items = html.split('\n');
  30593. this.tree = [];
  30594. items.unshift(''); // 列表结尾换行符个数
  30595. var endLineFlagLength = html.match(/\n*$/g)[0].length;
  30596. for (var i = 0; i < items.length - endLineFlagLength; i++) {
  30597. var node = new Node$1();
  30598. items[i] = handleIndent(items[i], node);
  30599. items[i] = handleMark(items[i], node);
  30600. node.strs.push(sentenceMakeFunc(items[i]).html);
  30601. node.index = i;
  30602. if (i === 0) {
  30603. // 根节点
  30604. node.space = -2;
  30605. this.tree.push(node);
  30606. continue;
  30607. }
  30608. var last = i - 1;
  30609. while (!this.tree[last]) {
  30610. last -= 1;
  30611. }
  30612. if (node.type === 'blank') {
  30613. this.addNode(node, i, this.tree[last].parent, last);
  30614. } else {
  30615. while (!this.tree[last] || this.tree[last].space > node.space) {
  30616. last -= 1;
  30617. }
  30618. var space = node.space;
  30619. var lastSpace = this.tree[last].space;
  30620. if (space < lastSpace + this.indentSpace) {
  30621. // 成为同级节点
  30622. if (this.config.listNested && this.tree[last].type !== node.type) {
  30623. this.addNode(node, i, last);
  30624. } else {
  30625. this.addNode(node, i, this.tree[last].parent);
  30626. }
  30627. } else if (space < lastSpace + this.indentSpace + INDENT_SPACE_NUM) {
  30628. // 成为子节点
  30629. this.addNode(node, i, last);
  30630. } else {
  30631. // 纯文本
  30632. node.type = 'blank';
  30633. this.addNode(node, i, this.tree[last].parent, last);
  30634. }
  30635. }
  30636. }
  30637. }
  30638. }, {
  30639. key: "renderSubTree",
  30640. value: function renderSubTree(node, children, type) {
  30641. var _this2 = this,
  30642. _context7,
  30643. _context8,
  30644. _context9;
  30645. var lines = 0;
  30646. var attr = {};
  30647. var content = reduce$3(children).call(children, function (html, item) {
  30648. var _context4, _context5, _context6;
  30649. var child = _this2.tree[item];
  30650. var itemAttr = {};
  30651. var str = "<p>".concat(child.strs.join('<br>'), "</p>");
  30652. child.lines += _this2.getLineCount(child.strs.join('\n'));
  30653. var children = child.children.length ? _this2.renderTree(item) : '';
  30654. node.lines += child.lines;
  30655. lines += child.lines; // checklist 样式适配
  30656. var checklistRegex = /<span class="ch-icon ch-icon-(square|check)"><\/span>/;
  30657. if (checklistRegex.test(str)) {
  30658. itemAttr["class"] = 'check-list-item';
  30659. }
  30660. return concat$5(_context4 = concat$5(_context5 = concat$5(_context6 = "".concat(html, "<li")).call(_context6, attrsToAttributeString(itemAttr), ">")).call(_context5, str)).call(_context4, children, "</li>");
  30661. }, '');
  30662. if (node.parent === undefined) {
  30663. // 根节点增加属性
  30664. attr['data-lines'] = node.index === 0 ? lines + this.emptyLines : lines;
  30665. attr['data-sign'] = this.sign;
  30666. }
  30667. if (children[0] && type === 'ol') {
  30668. attr.start = this.tree[children[0]].start;
  30669. }
  30670. attr["class"] = "cherry-list__".concat(this.tree[children[0]].listStyle);
  30671. return concat$5(_context7 = concat$5(_context8 = concat$5(_context9 = "<".concat(type)).call(_context9, attrsToAttributeString(attr), ">")).call(_context8, content, "</")).call(_context7, type, ">");
  30672. }
  30673. }, {
  30674. key: "renderTree",
  30675. value: function renderTree(current) {
  30676. var _this3 = this;
  30677. var from = 0;
  30678. var node = this.tree[current];
  30679. var children = node.children;
  30680. var html = reduce$3(children).call(children, function (html, item, index) {
  30681. if (index === 0) return html;
  30682. if (_this3.tree[children[index]].type === _this3.tree[children[index - 1]].type) {
  30683. return html;
  30684. }
  30685. var subTree = _this3.renderSubTree(node, slice$7(children).call(children, from, index), _this3.tree[children[index - 1]].type);
  30686. from = index;
  30687. return html + subTree;
  30688. }, '');
  30689. var childrenHtml = children.length ? this.renderSubTree(node, slice$7(children).call(children, from, children.length), this.tree[children[children.length - 1]].type) : '';
  30690. return html + childrenHtml;
  30691. }
  30692. }, {
  30693. key: "toHtml",
  30694. value: function toHtml(wholeMatch, sentenceMakeFunc) {
  30695. var _wholeMatch$match$len, _wholeMatch$match;
  30696. // 行数计算吸收的空行
  30697. this.emptyLines = (_wholeMatch$match$len = (_wholeMatch$match = wholeMatch.match(/^\n\n/)) === null || _wholeMatch$match === void 0 ? void 0 : _wholeMatch$match.length) !== null && _wholeMatch$match$len !== void 0 ? _wholeMatch$match$len : 0;
  30698. var text = wholeMatch.replace(/~0$/g, '').replace(/^\n+/, '');
  30699. this.buildTree(makeChecklist(text), sentenceMakeFunc);
  30700. var result = this.renderTree(0);
  30701. return this.pushCache(result, this.sign, this.$getLineNum(wholeMatch));
  30702. }
  30703. }, {
  30704. key: "$getLineNum",
  30705. value: function $getLineNum(str) {
  30706. var _str$match$length, _str$match, _$str$match$length, _$str$match;
  30707. var beginLine = (_str$match$length = (_str$match = str.match(/^\n\n/)) === null || _str$match === void 0 ? void 0 : _str$match.length) !== null && _str$match$length !== void 0 ? _str$match$length : 0;
  30708. var $str = str.replace(/^\n+/, '').replace(/\n+$/, '\n');
  30709. return (_$str$match$length = (_$str$match = $str.match(/\n/g)) === null || _$str$match === void 0 ? void 0 : _$str$match.length) !== null && _$str$match$length !== void 0 ? _$str$match$length : 0 + beginLine;
  30710. }
  30711. }, {
  30712. key: "makeHtml",
  30713. value: function makeHtml(str, sentenceMakeFunc) {
  30714. var _this4 = this;
  30715. var $str = "".concat(str, "~0");
  30716. if (this.test($str)) {
  30717. $str = $str.replace(this.RULE.reg, function (wholeMatch) {
  30718. return _this4.getCacheWithSpace(_this4.checkCache(wholeMatch, sentenceMakeFunc, _this4.$getLineNum(wholeMatch)), wholeMatch);
  30719. });
  30720. }
  30721. $str = $str.replace(/~0$/g, '');
  30722. return $str;
  30723. }
  30724. }, {
  30725. key: "rule",
  30726. value: function rule() {
  30727. var ret = {
  30728. begin: '(?:^|\n)(\n*)(([ ]{0,3}([*+-]|\\d+[.]|[a-z]\\.|[I一二三四五六七八九十]+\\.)[ \\t]+)',
  30729. content: '([^\\r]+?)',
  30730. end: '(~0|\\n{2,}(?=\\S)(?![ \\t]*(?:[*+-]|\\d+[.]|[a-z]\\.|[I一二三四五六七八九十]+\\.)[ \\t]+)))'
  30731. };
  30732. ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'gm');
  30733. return ret;
  30734. }
  30735. }]);
  30736. return List;
  30737. }(ParagraphBase);
  30738. _defineProperty(List, "HOOK_NAME", 'list');
  30739. function _createSuper$k(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$k(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  30740. function _isNativeReflectConstruct$k() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  30741. function computeLeadingSpaces(leadingChars) {
  30742. var indentRegex = /^(\t|[ ]{1,4})/;
  30743. var leadingCharsTemp = leadingChars;
  30744. var indent = 0;
  30745. while (indentRegex.test(leadingCharsTemp)) {
  30746. leadingCharsTemp = leadingCharsTemp.replace(/^(\t|[ ]{1,4})/g, '');
  30747. indent += 1;
  30748. }
  30749. return indent;
  30750. }
  30751. var Blockquote = /*#__PURE__*/function (_ParagraphBase) {
  30752. _inherits(Blockquote, _ParagraphBase);
  30753. var _super = _createSuper$k(Blockquote);
  30754. function Blockquote() {
  30755. _classCallCheck(this, Blockquote);
  30756. return _super.call(this, {
  30757. needCache: true
  30758. }); // TODO: String.prototype.repeat polyfill
  30759. }
  30760. _createClass(Blockquote, [{
  30761. key: "handleMatch",
  30762. value: function handleMatch(str, sentenceMakeFunc) {
  30763. var _this = this;
  30764. return str.replace(this.RULE.reg, function (match, lines, content) {
  30765. var _context, _context2, _context4;
  30766. var _sentenceMakeFunc = sentenceMakeFunc(content),
  30767. contentSign = _sentenceMakeFunc.sign,
  30768. parsedHtml = _sentenceMakeFunc.html;
  30769. var sign = _this.signWithCache(parsedHtml) || contentSign;
  30770. var lineCount = _this.getLineCount(match, lines); // 段落所占行数
  30771. var listRegex = /^(([ \t]{0,3}([*+-]|\d+[.]|[a-z]\.|[I一二三四五六七八九十]+\.)[ \t]+)([^\r]+?)($|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.]|[a-z]\.|[I一二三四五六七八九十]+\.)[ \t]+)))/;
  30772. var lastIndent = computeLeadingSpaces(lines); // 逐行处理
  30773. var contentLines = parsedHtml.split('\n');
  30774. var replaceReg = /^[>\s]+/;
  30775. var countReg = />/g;
  30776. var lastLevel = 1;
  30777. var level = 0;
  30778. var handledHtml = concat$5(_context = concat$5(_context2 = "<blockquote data-sign=\"".concat(sign, "_")).call(_context2, lineCount, "\" data-lines=\"")).call(_context, lineCount, "\">");
  30779. for (var i = 0; contentLines[i]; i++) {
  30780. if (i !== 0) {
  30781. var leadIndent = computeLeadingSpaces(contentLines[i]);
  30782. if (leadIndent <= lastIndent && listRegex.test(contentLines[i])) {
  30783. break;
  30784. }
  30785. lastIndent = leadIndent;
  30786. }
  30787. /* eslint-disable no-loop-func */
  30788. var $line = contentLines[i].replace(replaceReg, function (leadSymbol) {
  30789. var leadSymbols = leadSymbol.match(countReg); // 本行引用嵌套层级比上层要多
  30790. if (leadSymbols && leadSymbols.length > lastLevel) {
  30791. level = leadSymbols.length;
  30792. } else {
  30793. // 否则保持当前缩进层级
  30794. level = lastLevel;
  30795. }
  30796. return '';
  30797. }); // 同层级,且不为首行时补充一个换行
  30798. if (lastLevel === level && i !== 0) {
  30799. handledHtml += '<br>';
  30800. } // 补充缩进
  30801. if (lastLevel < level) {
  30802. var _context3;
  30803. handledHtml += repeat$3(_context3 = '<blockquote>').call(_context3, level - lastLevel);
  30804. lastLevel = level;
  30805. } // 插入当前行内容
  30806. handledHtml += $line;
  30807. } // 标签闭合
  30808. handledHtml += repeat$3(_context4 = '</blockquote>').call(_context4, lastLevel);
  30809. return _this.getCacheWithSpace(_this.pushCache(handledHtml, sign, lineCount), match);
  30810. });
  30811. }
  30812. }, {
  30813. key: "makeHtml",
  30814. value: function makeHtml(str, sentenceMakeFunc) {
  30815. if (!this.test(str)) {
  30816. return str;
  30817. }
  30818. return this.handleMatch(str, sentenceMakeFunc);
  30819. }
  30820. }, {
  30821. key: "rule",
  30822. value: function rule() {
  30823. var ret = {
  30824. begin: '(?:^|\\n)(\\s*)',
  30825. content: ['(', '>(?:.+?\\n(?![*+-]|\\d+[.]|[a-z]\\.))(?:>*.+?\\n(?![*+-]|\\d+[.]|[a-z]\\.))*(?:>*.+?)', // multiline
  30826. '|', // or
  30827. '>(?:.+?)', // single line
  30828. ')'].join(''),
  30829. end: '(?=(\\n)|$)'
  30830. };
  30831. ret.reg = compileRegExp(ret, 'g');
  30832. return ret;
  30833. }
  30834. }]);
  30835. return Blockquote;
  30836. }(ParagraphBase);
  30837. _defineProperty(Blockquote, "HOOK_NAME", 'blockquote');
  30838. function _createSuper$l(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$l(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  30839. function _isNativeReflectConstruct$l() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  30840. var AutoLink = /*#__PURE__*/function (_SyntaxBase) {
  30841. _inherits(AutoLink, _SyntaxBase);
  30842. var _super = _createSuper$l(AutoLink);
  30843. function AutoLink(_ref) {
  30844. var _this;
  30845. var config = _ref.config,
  30846. globalConfig = _ref.globalConfig;
  30847. _classCallCheck(this, AutoLink);
  30848. _this = _super.call(this, {
  30849. config: config
  30850. });
  30851. _this.urlProcessor = globalConfig.urlProcessor;
  30852. _this.enableShortLink = !!config.enableShortLink;
  30853. _this.shortLinkLength = config.shortLinkLength; // eslint-disable-next-line no-nested-ternary
  30854. _this.target = config.target ? "target=\"".concat(config.target, "\"") : !!config.openNewPage ? 'target="_blank"' : '';
  30855. _this.rel = config.rel ? "rel=\"".concat(config.rel, "\"") : '';
  30856. return _this;
  30857. }
  30858. _createClass(AutoLink, [{
  30859. key: "isLinkInHtmlAttribute",
  30860. value: function isLinkInHtmlAttribute(str, index, linkLength) {
  30861. var xmlTagRegex = new RegExp(['<', // tag start
  30862. '([a-zA-Z][a-zA-Z0-9-]*)', // tagName
  30863. '(', // attrs start
  30864. ['\\s+[a-zA-Z_:][a-zA-Z0-9_.:-]*', // attr name
  30865. '(', // attr value start
  30866. ['\\s*=\\s*', '(', ['([^\\s"\'=<>`]+)', // unquoted value
  30867. "('[^']*')", // single-quoted value
  30868. '("[^"]*")' // double-quoted value
  30869. ].join('|'), // either is ok
  30870. ')'].join(''), ')?' // attr value end
  30871. ].join(''), ')*', // attrs end
  30872. '\\s*[/]?>' // tag end
  30873. ].join(''), 'g');
  30874. var match;
  30875. while ((match = xmlTagRegex.exec(str)) !== null) {
  30876. // 搜索范围超过了字符串匹配到的位置
  30877. if (match.index > index + linkLength) {
  30878. break;
  30879. } // 正好在范围内,说明是HTML的属性,取等号是因为AutoLink的正则可能会匹配到标签的结束符号,如<img src="http://www.google.com">
  30880. if (match.index < index && match.index + match[0].length >= index + linkLength) {
  30881. return true;
  30882. }
  30883. }
  30884. return false;
  30885. }
  30886. /**
  30887. * 判断链接是否被包裹在a标签内部,如果被包裹,则不识别为自动链接
  30888. * @param {string} str
  30889. * @param {number} index
  30890. * @param {number} linkLength
  30891. */
  30892. }, {
  30893. key: "isLinkInATag",
  30894. value: function isLinkInATag(str, index, linkLength) {
  30895. var aTagRegex = /<a.*>[^<]*<\/a>/g;
  30896. var match;
  30897. while ((match = aTagRegex.exec(str)) !== null) {
  30898. // 搜索范围超过了字符串匹配到的位置
  30899. if (match.index > index + linkLength) {
  30900. break;
  30901. } // 正好在范围内,说明是HTML的属性,取等号是因为AutoLink的正则可能会匹配到标签的结束符号
  30902. // 如<a href="http://www.google.com">http://www.google.com</a>
  30903. if (match.index < index && match.index + match[0].length >= index + linkLength) {
  30904. return true;
  30905. }
  30906. }
  30907. return false;
  30908. }
  30909. }, {
  30910. key: "makeHtml",
  30911. value: function makeHtml(str, sentenceMakeFunc) {
  30912. var _this2 = this;
  30913. if (!(this.test(str) && (EMAIL_INLINE.test(str) || URL_INLINE_NO_SLASH.test(str)))) {
  30914. return str;
  30915. }
  30916. return str.replace(this.RULE.reg, function (match, left, protocol, address, right, index, str) {
  30917. var _context17, _context18, _context19;
  30918. // 数字实体字符系临时处理方法,详情参见HTMLBlock注释
  30919. // maybe a html attr, skip it
  30920. if ( // ((left !== '<' || left !== '&#60;') && (right !== '>' || right !== '&#62;')) ||
  30921. _this2.isLinkInHtmlAttribute(str, index, protocol.length + address.length) || _this2.isLinkInATag(str, index, protocol.length + address.length)) {
  30922. return match;
  30923. }
  30924. var $protocol = protocol.toLowerCase();
  30925. var prefix = '';
  30926. var suffix = '';
  30927. var isWrappedByBracket = true; // not a pair
  30928. if (!((left === '<' || left === '&#60;') && (right === '>' || right === '&#62;'))) {
  30929. prefix = left;
  30930. suffix = right;
  30931. isWrappedByBracket = false;
  30932. } // not a valid address
  30933. // 不被尖括号包裹,不带协议头,且不以www.开头的不识别
  30934. if (trim$3(address).call(address) === '' || !isWrappedByBracket && $protocol === '' && !/www\./.test(address)) {
  30935. return match;
  30936. }
  30937. switch ($protocol) {
  30938. case 'javascript:':
  30939. return match;
  30940. case 'mailto:':
  30941. // email
  30942. if (EMAIL.test(address)) {
  30943. var _context, _context2, _context3, _context4, _context5, _context6;
  30944. return concat$5(_context = concat$5(_context2 = concat$5(_context3 = concat$5(_context4 = concat$5(_context5 = "".concat(prefix, "<a href=\"")).call(_context5, encodeURIOnce(concat$5(_context6 = "".concat($protocol)).call(_context6, address)), "\" ")).call(_context4, _this2.target, " ")).call(_context3, _this2.rel, ">")).call(_context2, escapeHTMLSpecialCharOnce(address), "</a>")).call(_context, suffix);
  30945. }
  30946. return match;
  30947. case '':
  30948. // 协议为空
  30949. // 不被<>包裹或单边无效包裹,prefix === suffix 时都为空串
  30950. if (prefix === suffix || !isWrappedByBracket) {
  30951. // mailto
  30952. if (EMAIL.test(address)) {
  30953. var _context7, _context8, _context9, _context10, _context11;
  30954. return concat$5(_context7 = concat$5(_context8 = concat$5(_context9 = concat$5(_context10 = concat$5(_context11 = "".concat(prefix, "<a href=\"mailto:")).call(_context11, encodeURIOnce(address), "\" ")).call(_context10, _this2.target, " ")).call(_context9, _this2.rel, ">")).call(_context8, escapeHTMLSpecialCharOnce(address), "</a>")).call(_context7, suffix);
  30955. } // 不识别无协议头的URL,且开头不应该含有斜杠
  30956. if (URL_NO_SLASH.test(address)) {
  30957. var _context12, _context13;
  30958. return concat$5(_context12 = concat$5(_context13 = "".concat(prefix)).call(_context13, _this2.renderLink("//".concat(address), address))).call(_context12, suffix);
  30959. } // 其他的属于非法情况
  30960. return match;
  30961. } // 被<>包裹
  30962. if (isWrappedByBracket) {
  30963. // mailto
  30964. if (EMAIL.test(address)) {
  30965. var _context14, _context15, _context16;
  30966. return concat$5(_context14 = concat$5(_context15 = concat$5(_context16 = "<a href=\"mailto:".concat(encodeURIOnce(address), "\" ")).call(_context16, _this2.target, " ")).call(_context15, _this2.rel, ">")).call(_context14, escapeHTMLSpecialCharOnce(address), "</a>");
  30967. } // 可识别任意协议的URL,或不以斜杠开头的URL
  30968. if (URL$1.test(address) || URL_NO_SLASH.test(address)) {
  30969. return _this2.renderLink(address);
  30970. } // 其他非法
  30971. return match;
  30972. }
  30973. default:
  30974. // 协议头不为空时的非法URL
  30975. if (!URL$1.test(address)) {
  30976. return match;
  30977. } // TODO: Url Validator
  30978. return concat$5(_context17 = concat$5(_context18 = "".concat(prefix)).call(_context18, _this2.renderLink(concat$5(_context19 = "".concat($protocol)).call(_context19, address)))).call(_context17, suffix);
  30979. } // this should never happen
  30980. return match;
  30981. });
  30982. }
  30983. }, {
  30984. key: "rule",
  30985. value: function rule() {
  30986. var _context20;
  30987. // (?<protocol>\\w+:)\\/\\/
  30988. var ret = {
  30989. // ?<left>
  30990. begin: '(<?)',
  30991. content: [// ?<protocol>
  30992. '((?:[a-z][a-z0-9+.-]{1,31}:)?)', // protocol is any seq of 2-32 chars beginning with letter
  30993. // '(?<slash>(?:\\/{2})?)',
  30994. // ?<address>
  30995. // '([^\\s\\x00-\\x1f"<>]+)',
  30996. concat$5(_context20 = "((?:".concat(URL_INLINE.source, ")|(?:")).call(_context20, EMAIL_INLINE.source, "))") // [
  30997. // `(?<url>${ URL_INLINE.source })`,
  30998. // `(?<email>${ EMAIL_INLINE.source })`, // email
  30999. // ].join('|'),
  31000. // ')'
  31001. ].join(''),
  31002. // ?<right>
  31003. end: '(>?)' // TODO: extend attrs e.g. {target=_blank}
  31004. };
  31005. ret.reg = compileRegExp(ret, 'ig');
  31006. return ret;
  31007. }
  31008. /**
  31009. * 渲染链接为a标签,返回html
  31010. * @param {string} url src链接
  31011. * @param {string} [text] 展示的链接文本,不传默认使用url
  31012. * @returns 渲染的a标签
  31013. */
  31014. }, {
  31015. key: "renderLink",
  31016. value: function renderLink(url, text) {
  31017. var _context22, _context23, _context24, _context25;
  31018. var linkText = text;
  31019. if (typeof linkText !== 'string') {
  31020. if (this.enableShortLink) {
  31021. var _context21;
  31022. var Url = url.replace(/^https?:\/\//i, '');
  31023. linkText = concat$5(_context21 = "".concat(Url.substring(0, this.shortLinkLength))).call(_context21, Url.length > this.shortLinkLength ? '...' : '');
  31024. } else {
  31025. linkText = url;
  31026. }
  31027. }
  31028. var processedURL = this.urlProcessor(url, 'autolink');
  31029. return concat$5(_context22 = concat$5(_context23 = concat$5(_context24 = concat$5(_context25 = "<a ".concat(this.target, " ")).call(_context25, this.rel, " title=\"")).call(_context24, escapeHTMLSpecialCharOnce(url).replace(/_/g, '\\_'), "\" href=\"")).call(_context23, encodeURIOnce(processedURL).replace(/_/g, '\\_'), "\">")).call(_context22, escapeHTMLSpecialCharOnce(linkText).replace(/_/g, '\\_'), "</a>");
  31030. }
  31031. }]);
  31032. return AutoLink;
  31033. }(SyntaxBase);
  31034. _defineProperty(AutoLink, "HOOK_NAME", 'autoLink');
  31035. /**
  31036. * 装饰器,挂载对应的模块到实例上
  31037. */
  31038. function LoadMathModule() {
  31039. var _this$externals$katex, _this$externals, _this$externals$MathJ, _this$externals2;
  31040. if (!isBrowser()) {
  31041. return;
  31042. } // @ts-ignore
  31043. this.katex = (_this$externals$katex = (_this$externals = this.externals) === null || _this$externals === void 0 ? void 0 : _this$externals.katex) !== null && _this$externals$katex !== void 0 ? _this$externals$katex : window.katex; // @ts-ignore
  31044. this.MathJax = (_this$externals$MathJ = (_this$externals2 = this.externals) === null || _this$externals2 === void 0 ? void 0 : _this$externals2.MathJax) !== null && _this$externals$MathJ !== void 0 ? _this$externals$MathJ : window.MathJax;
  31045. }
  31046. var configureMathJax = function configureMathJax(usePlugins) {
  31047. if (!isBrowser()) {
  31048. console.log('mathjax disabled');
  31049. return;
  31050. }
  31051. var plugins = usePlugins ? ['input/asciimath', '[tex]/noerrors', '[tex]/cancel', '[tex]/color', '[tex]/boldsymbol'] : []; // @ts-ignore
  31052. window.MathJax = {
  31053. startup: {
  31054. elements: ['.Cherry-Math', '.Cherry-InlineMath'],
  31055. typeset: true
  31056. },
  31057. tex: {
  31058. inlineMath: [['$', '$'], ['\\(', '\\)']],
  31059. displayMath: [['$$', '$$'], ['\\[', '\\]']],
  31060. tags: 'ams',
  31061. packages: {
  31062. '[+]': ['noerrors', 'cancel', 'color']
  31063. },
  31064. macros: {
  31065. bm: ['{\\boldsymbol{#1}}', 1]
  31066. }
  31067. },
  31068. options: {
  31069. skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code', 'a'],
  31070. ignoreHtmlClass: 'tex2jax_ignore',
  31071. processHtmlClass: 'tex2jax_process',
  31072. // 关闭 mathjax 菜单
  31073. enableMenu: false
  31074. },
  31075. loader: {
  31076. load: plugins
  31077. }
  31078. };
  31079. };
  31080. var noEscape = ['&', '<', '>', '"', "'"]; // 需要转换为HTML实体字符的符号
  31081. // 用于预处理会在Markdown中被反转义的字符,如:\\ 会被反转义为 \
  31082. var escapeFormulaPunctuations = function escapeFormulaPunctuations(formula) {
  31083. var $formula = formula.replace(new RegExp(PUNCTUATION, 'g'), function (match) {
  31084. if (indexOf$8(noEscape).call(noEscape, match) !== -1) {
  31085. // HTML特殊字符需要转换为实体字符,防XSS注入
  31086. return escapeHTMLSpecialChar(match);
  31087. }
  31088. return "\\".concat(match); // 先转义特殊字符,防止在afterMakeHtml中被反转义
  31089. });
  31090. return $formula;
  31091. };
  31092. function _createSuper$m(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$m(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  31093. function _isNativeReflectConstruct$m() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  31094. var MathBlock = /*#__PURE__*/function (_ParagraphBase) {
  31095. _inherits(MathBlock, _ParagraphBase);
  31096. var _super = _createSuper$m(MathBlock);
  31097. /**
  31098. * 块级公式语法
  31099. * 该语法具有排他性,并且需要优先其他段落级语法进行渲染
  31100. * @type {'katex' | 'MathJax' | 'node'}
  31101. */
  31102. // 渲染引擎,默认为MathJax,MathJax支持2.x与3.x版本
  31103. function MathBlock(_ref) {
  31104. var _config$engine;
  31105. var _this;
  31106. var config = _ref.config;
  31107. _classCallCheck(this, MathBlock);
  31108. _this = _super.call(this, {
  31109. needCache: true
  31110. }); // 非浏览器环境下配置为 node
  31111. _defineProperty(_assertThisInitialized(_this), "engine", 'MathJax');
  31112. _defineProperty(_assertThisInitialized(_this), "katex", void 0);
  31113. _defineProperty(_assertThisInitialized(_this), "MathJax", void 0);
  31114. _this.engine = isBrowser() ? (_config$engine = config.engine) !== null && _config$engine !== void 0 ? _config$engine : 'MathJax' : 'node';
  31115. return _this;
  31116. }
  31117. _createClass(MathBlock, [{
  31118. key: "toHtml",
  31119. value: function toHtml(wholeMatch, lineSpace, leadingChar, content) {
  31120. var _this$MathJax, _context5, _context6;
  31121. bind$5(LoadMathModule).call(LoadMathModule, this)('engine'); // 去掉开头的空字符,去掉结尾的换行符
  31122. var wholeMatchWithoutSpace = wholeMatch.replace(/^[ \f\r\t\v]*/, '').replace(/\s*$/, ''); // 去掉匹配到的第一个换行符
  31123. var lineSpaceWithoutPreSpace = lineSpace.replace(/^[ \f\r\t\v]*\n/, '');
  31124. var sign = this.$engine.md5(wholeMatch);
  31125. var lines = this.getLineCount(wholeMatchWithoutSpace, lineSpaceWithoutPreSpace); // 判断公式是不是新行输入,如果不是新行,则行号减1
  31126. if (!/\n/.test(lineSpace)) {
  31127. lines -= 1;
  31128. } // 判断公式后面有没有尾接内容,如果尾接了内容,则行号减1
  31129. if (!/\n\s*$/.test(wholeMatch)) {
  31130. lines -= 1;
  31131. } // 目前的机制还没有测过lines为负数的情况,先不处理
  31132. lines = lines > 0 ? lines : 0;
  31133. if (this.engine === 'katex') {
  31134. var _context, _context2;
  31135. // katex渲染
  31136. var html = this.katex.renderToString(content, {
  31137. throwOnError: false,
  31138. displayMode: true
  31139. });
  31140. var _result = concat$5(_context = concat$5(_context2 = "<div data-sign=\"".concat(sign, "\" class=\"Cherry-Math\" data-type=\"mathBlock\"\n data-lines=\"")).call(_context2, lines, "\">")).call(_context, html, "</div>");
  31141. return leadingChar + this.getCacheWithSpace(this.pushCache(_result, sign, lines), wholeMatch);
  31142. }
  31143. if ((_this$MathJax = this.MathJax) !== null && _this$MathJax !== void 0 && _this$MathJax.tex2svg) {
  31144. var _context3, _context4;
  31145. // MathJax渲染
  31146. var svg = getHTML(this.MathJax.tex2svg(content), true);
  31147. var _result2 = concat$5(_context3 = concat$5(_context4 = "<div data-sign=\"".concat(sign, "\" class=\"Cherry-Math\" data-type=\"mathBlock\"\n data-lines=\"")).call(_context4, lines, "\">")).call(_context3, svg, "</div>");
  31148. return leadingChar + this.getCacheWithSpace(this.pushCache(_result2, sign, lines), wholeMatch);
  31149. } // 既无MathJax又无katex时,原样输出
  31150. var result = concat$5(_context5 = concat$5(_context6 = "<div data-sign=\"".concat(sign, "\" class=\"Cherry-Math\" data-type=\"mathBlock\"\n data-lines=\"")).call(_context6, lines, "\">$$")).call(_context5, escapeFormulaPunctuations(content), "$$</div>");
  31151. return leadingChar + this.getCacheWithSpace(this.pushCache(result, sign, lines), wholeMatch);
  31152. }
  31153. }, {
  31154. key: "beforeMakeHtml",
  31155. value: function beforeMakeHtml(str) {
  31156. var _context8;
  31157. if (isLookbehindSupported()) {
  31158. var _context7;
  31159. return str.replace(this.RULE.reg, bind$5(_context7 = this.toHtml).call(_context7, this));
  31160. }
  31161. return replaceLookbehind(str, this.RULE.reg, bind$5(_context8 = this.toHtml).call(_context8, this), true, 1);
  31162. }
  31163. }, {
  31164. key: "makeHtml",
  31165. value: function makeHtml(str) {
  31166. return str;
  31167. }
  31168. }, {
  31169. key: "rule",
  31170. value: function rule() {
  31171. var ret = {
  31172. begin: isLookbehindSupported() ? '(\\s*)((?<!\\\\))~D~D\\s*' : '(\\s*)(^|[^\\\\])~D~D\\s*',
  31173. content: '([\\w\\W]*?)',
  31174. end: '(\\s*)~D~D(?:\\s{0,1})'
  31175. };
  31176. ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
  31177. return ret;
  31178. }
  31179. }]);
  31180. return MathBlock;
  31181. }(ParagraphBase);
  31182. _defineProperty(MathBlock, "HOOK_NAME", 'mathBlock');
  31183. function _createSuper$n(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$n(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  31184. function _isNativeReflectConstruct$n() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  31185. /**
  31186. * 行内公式的语法
  31187. * 虽然叫做行内公式,Cherry依然将其视为“段落级语法”,因为其具备排他性并且需要优先渲染
  31188. */
  31189. var InlineMath = /*#__PURE__*/function (_ParagraphBase) {
  31190. _inherits(InlineMath, _ParagraphBase);
  31191. var _super = _createSuper$n(InlineMath);
  31192. /** @type {'katex' | 'MathJax' | 'node'} */
  31193. // 渲染引擎,默认为MathJax,MathJax支持2.x与3.x版本
  31194. function InlineMath(_ref) {
  31195. var _config$engine;
  31196. var _this;
  31197. var config = _ref.config;
  31198. _classCallCheck(this, InlineMath);
  31199. _this = _super.call(this, {
  31200. needCache: true
  31201. }); // 非浏览器环境下配置为 node
  31202. _defineProperty(_assertThisInitialized(_this), "engine", 'MathJax');
  31203. _defineProperty(_assertThisInitialized(_this), "katex", void 0);
  31204. _defineProperty(_assertThisInitialized(_this), "MathJax", void 0);
  31205. _this.engine = isBrowser() ? (_config$engine = config.engine) !== null && _config$engine !== void 0 ? _config$engine : 'MathJax' : 'node';
  31206. return _this;
  31207. }
  31208. _createClass(InlineMath, [{
  31209. key: "toHtml",
  31210. value: function toHtml(wholeMatch, leadingChar, m1) {
  31211. var _this$katex, _this$MathJax, _context5, _context6;
  31212. if (!m1) {
  31213. return wholeMatch;
  31214. }
  31215. bind$5(LoadMathModule).call(LoadMathModule, this)('engine');
  31216. var linesArr = m1.match(/\n/g);
  31217. var lines = linesArr ? linesArr.length + 2 : 2;
  31218. var sign = this.$engine.md5(wholeMatch);
  31219. if (this.engine === 'katex' && (_this$katex = this.katex) !== null && _this$katex !== void 0 && _this$katex.renderToString) {
  31220. var _context, _context2;
  31221. // katex渲染
  31222. var html = this.katex.renderToString(m1, {
  31223. throwOnError: false
  31224. });
  31225. var _result = concat$5(_context = concat$5(_context2 = "".concat(leadingChar, "<span class=\"Cherry-InlineMath\" data-type=\"mathBlock\" data-lines=\"")).call(_context2, lines, "\">")).call(_context, html, "</span>");
  31226. return this.pushCache(_result, ParagraphBase.IN_PARAGRAPH_CACHE_KEY_PREFIX + sign);
  31227. }
  31228. if ((_this$MathJax = this.MathJax) !== null && _this$MathJax !== void 0 && _this$MathJax.tex2svg) {
  31229. var _context3, _context4;
  31230. // MathJax渲染
  31231. var svg = getHTML(this.MathJax.tex2svg(m1, {
  31232. em: 12,
  31233. ex: 6,
  31234. display: false
  31235. }), true);
  31236. var _result2 = concat$5(_context3 = concat$5(_context4 = "".concat(leadingChar, "<span class=\"Cherry-InlineMath\" data-type=\"mathBlock\" data-lines=\"")).call(_context4, lines, "\">")).call(_context3, svg, "</span>");
  31237. return this.pushCache(_result2, ParagraphBase.IN_PARAGRAPH_CACHE_KEY_PREFIX + sign);
  31238. } // 既无MathJax又无katex时,原样输出
  31239. var result = concat$5(_context5 = concat$5(_context6 = "".concat(leadingChar, "<span class=\"Cherry-InlineMath\" data-type=\"mathBlock\"\n data-lines=\"")).call(_context6, lines, "\">$")).call(_context5, escapeFormulaPunctuations(m1), "$</span>");
  31240. return this.pushCache(result, ParagraphBase.IN_PARAGRAPH_CACHE_KEY_PREFIX + sign);
  31241. }
  31242. }, {
  31243. key: "beforeMakeHtml",
  31244. value: function beforeMakeHtml(str) {
  31245. var _this2 = this;
  31246. var $str = str; // 格里处理行内公式,让一个td里的行内公式语法生效,让跨td的行内公式语法失效
  31247. $str = $str.replace(getTableRule(true), function (whole) {
  31248. var _context7;
  31249. return map$3(_context7 = whole.split('|')).call(_context7, function (oneTd) {
  31250. return _this2.makeInlineMath(oneTd);
  31251. }).join('|').replace(/\\~D/g, '~D') // 出现反斜杠的情况(如/$e=m^2$)会导致多一个反斜杠,这里替换掉
  31252. .replace(/~D/g, '\\~D');
  31253. });
  31254. return this.makeInlineMath($str);
  31255. }
  31256. }, {
  31257. key: "makeInlineMath",
  31258. value: function makeInlineMath(str) {
  31259. var _context9;
  31260. if (!this.test(str)) {
  31261. return str;
  31262. }
  31263. if (isLookbehindSupported()) {
  31264. var _context8;
  31265. return str.replace(this.RULE.reg, bind$5(_context8 = this.toHtml).call(_context8, this));
  31266. }
  31267. return replaceLookbehind(str, this.RULE.reg, bind$5(_context9 = this.toHtml).call(_context9, this), true, 1);
  31268. }
  31269. }, {
  31270. key: "makeHtml",
  31271. value: function makeHtml(str) {
  31272. return str;
  31273. }
  31274. }, {
  31275. key: "rule",
  31276. value: function rule() {
  31277. var ret = {
  31278. begin: isLookbehindSupported() ? '((?<!\\\\))~D\\n?' : '(^|[^\\\\])~D\\n?',
  31279. content: '(.*?)\\n?',
  31280. end: '~D'
  31281. };
  31282. ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
  31283. return ret;
  31284. }
  31285. }]);
  31286. return InlineMath;
  31287. }(ParagraphBase);
  31288. _defineProperty(InlineMath, "HOOK_NAME", 'inlineMath');
  31289. // `Array.prototype.fill` method implementation
  31290. // https://tc39.es/ecma262/#sec-array.prototype.fill
  31291. var arrayFill = function fill(value /* , start = 0, end = @length */) {
  31292. var O = toObject(this);
  31293. var length = lengthOfArrayLike(O);
  31294. var argumentsLength = arguments.length;
  31295. var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length);
  31296. var end = argumentsLength > 2 ? arguments[2] : undefined;
  31297. var endPos = end === undefined ? length : toAbsoluteIndex(end, length);
  31298. while (endPos > index) O[index++] = value;
  31299. return O;
  31300. };
  31301. // `Array.prototype.fill` method
  31302. // https://tc39.es/ecma262/#sec-array.prototype.fill
  31303. _export({ target: 'Array', proto: true }, {
  31304. fill: arrayFill
  31305. });
  31306. var fill = entryVirtual('Array').fill;
  31307. var ArrayPrototype$b = Array.prototype;
  31308. var fill$1 = function (it) {
  31309. var own = it.fill;
  31310. return it === ArrayPrototype$b || (objectIsPrototypeOf(ArrayPrototype$b, it) && own === ArrayPrototype$b.fill) ? fill : own;
  31311. };
  31312. var fill$2 = fill$1;
  31313. var fill$3 = fill$2;
  31314. function _createSuper$o(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$o(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  31315. function _isNativeReflectConstruct$o() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  31316. function defaultLinkProcessor(link) {
  31317. return link;
  31318. }
  31319. var defaultOptions = {
  31320. tocStyle: 'plain',
  31321. // plain or nested
  31322. tocNodeClass: 'toc-li',
  31323. tocContainerClass: 'toc',
  31324. tocTitleClass: 'toc-title',
  31325. linkProcessor: defaultLinkProcessor
  31326. };
  31327. var emptyLinePlaceholder = '<p data-sign="empty-toc" data-lines="1">&nbsp;</p>';
  31328. var Toc = /*#__PURE__*/function (_ParagraphBase) {
  31329. _inherits(Toc, _ParagraphBase);
  31330. var _super = _createSuper$o(Toc);
  31331. // plain or nested
  31332. /** 标记当前是否处于第一个toc,且仅渲染一个toc */
  31333. /** 允许渲染多个TOC */
  31334. function Toc(_ref) {
  31335. var _context;
  31336. var _this;
  31337. var externals = _ref.externals,
  31338. config = _ref.config;
  31339. _classCallCheck(this, Toc);
  31340. _this = _super.call(this, {
  31341. needCache: true
  31342. });
  31343. _defineProperty(_assertThisInitialized(_this), "tocStyle", 'nested');
  31344. _defineProperty(_assertThisInitialized(_this), "tocNodeClass", 'toc-li');
  31345. _defineProperty(_assertThisInitialized(_this), "tocContainerClass", 'toc');
  31346. _defineProperty(_assertThisInitialized(_this), "tocTitleClass", 'toc-title');
  31347. _defineProperty(_assertThisInitialized(_this), "linkProcessor", defaultLinkProcessor);
  31348. _defineProperty(_assertThisInitialized(_this), "baseLevel", 1);
  31349. _defineProperty(_assertThisInitialized(_this), "isFirstTocToken", true);
  31350. _defineProperty(_assertThisInitialized(_this), "allowMultiToc", false);
  31351. forEach$3(_context = keys$3(defaultOptions)).call(_context, function (key) {
  31352. _this[key] = config[key] || defaultOptions[key];
  31353. });
  31354. return _this;
  31355. }
  31356. _createClass(Toc, [{
  31357. key: "beforeMakeHtml",
  31358. value: function beforeMakeHtml(str) {
  31359. var _this2 = this;
  31360. var $str = str;
  31361. if (this.test($str, 'extend')) {
  31362. $str = $str.replace(this.RULE.extend.reg, function (match, lines, toc) {
  31363. if (!_this2.allowMultiToc && !_this2.isFirstTocToken) {
  31364. var _context2;
  31365. // 需要补齐非捕获的\n,以及第一个分组中的\n
  31366. return concat$5(_context2 = "\n".concat(lines)).call(_context2, emptyLinePlaceholder);
  31367. }
  31368. var placeHolder = _this2.pushCache(match);
  31369. _this2.isFirstTocToken = false;
  31370. return prependLineFeedForParagraph(match, placeHolder);
  31371. });
  31372. }
  31373. if (this.test($str, 'standard')) {
  31374. $str = $str.replace(this.RULE.standard.reg, function (match, lines, toc) {
  31375. if (!_this2.allowMultiToc && !_this2.isFirstTocToken) {
  31376. var _context3;
  31377. // 需要补齐非捕获的\n,以及第一个分组中的\n
  31378. return concat$5(_context3 = "\n".concat(lines)).call(_context3, emptyLinePlaceholder);
  31379. }
  31380. _this2.isFirstTocToken = false;
  31381. var placeHolder = _this2.pushCache(match);
  31382. return prependLineFeedForParagraph(match, placeHolder);
  31383. });
  31384. }
  31385. return $str;
  31386. }
  31387. }, {
  31388. key: "makeHtml",
  31389. value: function makeHtml(str) {
  31390. return str;
  31391. }
  31392. }, {
  31393. key: "$makeLevel",
  31394. value: function $makeLevel(num) {
  31395. var ret = '';
  31396. for (var i = this.baseLevel; i < num; i++) {
  31397. ret += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  31398. }
  31399. return ret;
  31400. }
  31401. /**
  31402. * 生成TOC节点HTML
  31403. * @param {{ level: number; id: string; text: string }} node Toc节点对象
  31404. * @param {boolean} prependWhitespaceIndent 是否在文本前插入缩进空格
  31405. * @param {boolean} [closeTag=true] 是否闭合标签
  31406. * @returns {string}
  31407. */
  31408. }, {
  31409. key: "$makeTocItem",
  31410. value: function $makeTocItem(node, prependWhitespaceIndent) {
  31411. var _context4, _context5, _context6, _context7, _context8;
  31412. var closeTag = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  31413. var nodePrefix = '';
  31414. if (prependWhitespaceIndent) {
  31415. nodePrefix = this.$makeLevel(node.level);
  31416. }
  31417. var tocLink = this.linkProcessor("#".concat(node.id).replace(/safe_/g, '')); // transform header id to avoid being sanitized
  31418. return concat$5(_context4 = concat$5(_context5 = concat$5(_context6 = concat$5(_context7 = concat$5(_context8 = "<li class=\"".concat(this.tocNodeClass, "\">")).call(_context8, nodePrefix, "<a href=\"")).call(_context7, tocLink, "\" class=\"level-")).call(_context6, node.level, "\">")).call(_context5, node.text, "</a>")).call(_context4, closeTag ? '</li>' : '');
  31419. }
  31420. }, {
  31421. key: "$makePlainToc",
  31422. value: function $makePlainToc(tocNodeList) {
  31423. var _this3 = this;
  31424. // this.baseLevel = Math.min(...tocNodeList.map((node) => node.level));
  31425. var items = map$3(tocNodeList).call(tocNodeList, function (node) {
  31426. return _this3.$makeTocItem(node, true);
  31427. });
  31428. return items.join('');
  31429. }
  31430. /**
  31431. * 生成嵌套的TOC列表,算法思路参考flexmark
  31432. * @see https://github.com/vsch/flexmark-java/blob/master/flexmark-ext-toc/
  31433. * src/main/java/com/vladsch/flexmark/ext/toc/TocUtils.java#L140-L227
  31434. *
  31435. * @param {{ level:number; id:string; text:string }[]} nodeList 节点列表
  31436. * @returns {string}
  31437. */
  31438. }, {
  31439. key: "$makeNestedToc",
  31440. value: function $makeNestedToc(nodeList) {
  31441. var _context9,
  31442. _context10,
  31443. _this4 = this;
  31444. var lastLevel = 0;
  31445. var unclosedItem = fill$3(_context9 = new Array(7)).call(_context9, false);
  31446. var unclosedList = fill$3(_context10 = new Array(7)).call(_context10, false); // lists nodes for debug
  31447. // const lists = [];
  31448. // const nodes = [];
  31449. var html = '';
  31450. forEach$3(nodeList).call(nodeList, function (node) {
  31451. var nodeLevel = node.level;
  31452. if (lastLevel === 0) {
  31453. for (var i = nodeLevel; i >= _this4.baseLevel; i--) {
  31454. html += '<ul>'; // lists.push('ul');
  31455. // nodes.push(null);
  31456. unclosedList[i] = true;
  31457. }
  31458. html += _this4.$makeTocItem(node, false, false); // lists.push('li');
  31459. // nodes.push(node);
  31460. unclosedItem[nodeLevel] = true;
  31461. lastLevel = nodeLevel;
  31462. return;
  31463. }
  31464. if (nodeLevel < lastLevel) {
  31465. // 减少层级
  31466. for (var _i = lastLevel; _i >= nodeLevel; _i--) {
  31467. if (unclosedItem[_i]) {
  31468. html += '</li>'; // lists.push('/li');
  31469. // nodes.push(null);
  31470. unclosedItem[_i] = false;
  31471. } // 减少层级时,不闭合当前层级的列表,只闭合同层级的列表项
  31472. if (unclosedList[_i] && _i > nodeLevel) {
  31473. html += '</ul>'; // lists.push('/ul');
  31474. // nodes.push(null);
  31475. unclosedList[_i] = false;
  31476. }
  31477. }
  31478. unclosedItem[nodeLevel] = true;
  31479. html += _this4.$makeTocItem(node, false, false); // lists.push('li');
  31480. // nodes.push(node);
  31481. lastLevel = nodeLevel;
  31482. } else if (nodeLevel === lastLevel) {
  31483. if (unclosedItem[lastLevel]) {
  31484. html += '</li>'; // lists.push('/li');
  31485. // nodes.push(null);
  31486. }
  31487. html += _this4.$makeTocItem(node, false, false); // lists.push('li');
  31488. // nodes.push(node);
  31489. unclosedItem[nodeLevel] = true;
  31490. unclosedList[nodeLevel] = true;
  31491. } else {
  31492. // 增加层级
  31493. for (var _i2 = lastLevel + 1; _i2 <= nodeLevel; _i2++) {
  31494. html += '<ul>'; // lists.push('ul');
  31495. // nodes.push(null);
  31496. unclosedList[_i2] = true;
  31497. }
  31498. unclosedItem[nodeLevel] = true;
  31499. html += _this4.$makeTocItem(node, false, false); // lists.push('li');
  31500. // nodes.push(node);
  31501. lastLevel = nodeLevel;
  31502. }
  31503. });
  31504. for (var i = lastLevel; i >= this.baseLevel; i--) {
  31505. if (unclosedItem[i]) {
  31506. html += '</li>'; // lists.push('/li');
  31507. // nodes.push(null);
  31508. unclosedItem[i] = false;
  31509. }
  31510. if (unclosedList[i]) {
  31511. html += '</ul>'; // lists.push('/ul');
  31512. // nodes.push(null);
  31513. unclosedList[i] = false;
  31514. }
  31515. } // console.log(lists, nodes);
  31516. // console.log(html);
  31517. return html;
  31518. }
  31519. }, {
  31520. key: "$makeToc",
  31521. value: function $makeToc(arr, dataSign, preLinesMatch) {
  31522. var _context11, _context12, _context13;
  31523. var lines = calculateLinesOfParagraph(preLinesMatch, 1);
  31524. var ret = concat$5(_context11 = concat$5(_context12 = concat$5(_context13 = "<dir class=\"".concat(this.tocContainerClass, "\" data-sign=\"")).call(_context13, dataSign, "-")).call(_context12, lines, "\" data-lines=\"")).call(_context11, lines, "\">");
  31525. ret += "<p class=\"".concat(this.tocTitleClass, "\">\u76EE\u5F55</p>");
  31526. if (arr.length <= 0) {
  31527. return '';
  31528. }
  31529. this.baseLevel = Math.min.apply(Math, _toConsumableArray(map$3(arr).call(arr, function (node) {
  31530. return node.level;
  31531. })));
  31532. if (this.tocStyle === 'nested') {
  31533. ret += this.$makeNestedToc(arr);
  31534. } else {
  31535. ret += this.$makePlainToc(arr);
  31536. }
  31537. ret += '</dir>';
  31538. return ret;
  31539. }
  31540. }, {
  31541. key: "afterMakeHtml",
  31542. value: function afterMakeHtml(str) {
  31543. var _this5 = this;
  31544. var $str = _get(_getPrototypeOf(Toc.prototype), "afterMakeHtml", this).call(this, str);
  31545. var headerList = [];
  31546. var headerRegex = /<h([1-6])[^>]*? id="([^"]+?)"[^>]*?>(?:<a[^/]+?\/a>|)(.+?)<\/h\1>/g;
  31547. var str2Md5 = '';
  31548. $str.replace(headerRegex, function (match, level, id, text) {
  31549. var _context14;
  31550. var $text = text.replace(/~fn#[0-9]+#/g, '');
  31551. headerList.push({
  31552. level: +level,
  31553. id: id,
  31554. text: $text
  31555. });
  31556. str2Md5 += concat$5(_context14 = "".concat(level)).call(_context14, id);
  31557. });
  31558. str2Md5 = this.$engine.md5(str2Md5);
  31559. $str = $str.replace(/(?:^|\n)(\[\[|\[|【【)(toc|TOC)(\]\]|\]|】】)([<~])/, function (match) {
  31560. return match.replace(/(\]\]|\]|】】)([<~])/, '$1\n$2');
  31561. }); // 首先识别扩展语法
  31562. $str = $str.replace(this.RULE.extend.reg, function (match, preLinesMatch) {
  31563. return _this5.$makeToc(headerList, str2Md5, preLinesMatch);
  31564. }); // 处理标准语法
  31565. $str = $str.replace(this.RULE.standard.reg, function (match, preLinesMatch) {
  31566. return _this5.$makeToc(headerList, str2Md5, preLinesMatch);
  31567. }); // 重置toc状态
  31568. this.isFirstTocToken = true;
  31569. return $str;
  31570. }
  31571. }, {
  31572. key: "test",
  31573. value: function test(str, flavor) {
  31574. return this.RULE[flavor].reg ? this.RULE[flavor].reg.test(str) : false;
  31575. }
  31576. }, {
  31577. key: "rule",
  31578. value: function rule() {
  31579. var extend = {
  31580. begin: '(?:^|\\n)(\\n*)',
  31581. end: '(?=$|\\n)',
  31582. content: '[ ]*((?:【【|\\[\\[)(?:toc|TOC)(?:\\]\\]|】】))[ ]*'
  31583. };
  31584. extend.reg = new RegExp(extend.begin + extend.content + extend.end, 'g');
  31585. var standard = {
  31586. begin: '(?:^|\\n)(\\n*)',
  31587. end: '(?=$|\\n)',
  31588. content: '[ ]*(\\[(?:toc|TOC)\\])[ ]*'
  31589. };
  31590. standard.reg = new RegExp(standard.begin + standard.content + standard.end, 'g');
  31591. return {
  31592. extend: extend,
  31593. standard: standard
  31594. };
  31595. }
  31596. }]);
  31597. return Toc;
  31598. }(ParagraphBase);
  31599. _defineProperty(Toc, "HOOK_NAME", 'toc');
  31600. function _createSuper$p(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$p(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  31601. function _isNativeReflectConstruct$p() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  31602. var Footnote = /*#__PURE__*/function (_ParagraphBase) {
  31603. _inherits(Footnote, _ParagraphBase);
  31604. var _super = _createSuper$p(Footnote);
  31605. function Footnote(_ref) {
  31606. var _this;
  31607. var externals = _ref.externals,
  31608. config = _ref.config;
  31609. _classCallCheck(this, Footnote);
  31610. _this = _super.call(this);
  31611. _this.footnoteCache = {};
  31612. _this.footnoteMap = {}; // 角标缓存索引
  31613. _this.footnote = [];
  31614. return _this;
  31615. }
  31616. _createClass(Footnote, [{
  31617. key: "$cleanCache",
  31618. value: function $cleanCache() {
  31619. this.footnoteCache = {};
  31620. this.footnoteMap = {}; // 角标缓存索引
  31621. this.footnote = [];
  31622. }
  31623. }, {
  31624. key: "pushFootnoteCache",
  31625. value: function pushFootnoteCache(key, cache) {
  31626. this.footnoteCache[key] = cache;
  31627. }
  31628. }, {
  31629. key: "getFootnoteCache",
  31630. value: function getFootnoteCache(key) {
  31631. return this.footnoteCache[key] || null;
  31632. }
  31633. }, {
  31634. key: "pushFootNote",
  31635. value: function pushFootNote(key, note) {
  31636. var _context, _context2, _context3, _context4, _context5, _context6;
  31637. if (this.footnoteMap[key]) {
  31638. // 重复引用时返回已缓存下标
  31639. return this.footnoteMap[key];
  31640. }
  31641. var num = this.footnote.length + 1;
  31642. var fn = {};
  31643. fn.fn = concat$5(_context = concat$5(_context2 = concat$5(_context3 = "<sup><a href=\"#fn:".concat(num, "\" id=\"fnref:")).call(_context3, num, "\" title=\"")).call(_context2, key, "\" class=\"footnote\">[")).call(_context, num, "]</a></sup>");
  31644. fn.fnref = concat$5(_context4 = concat$5(_context5 = concat$5(_context6 = "<a href=\"#fnref:".concat(num, "\" id=\"fn:")).call(_context6, num, "\" title=\"")).call(_context5, key, "\" class=\"footnote-ref\">[")).call(_context4, num, "]</a>");
  31645. fn.num = num;
  31646. fn.note = trim$3(note).call(note);
  31647. this.footnote.push(fn);
  31648. var replaceKey = "\0~fn#".concat(num - 1, "#\0");
  31649. this.footnoteMap[key] = replaceKey;
  31650. return replaceKey;
  31651. }
  31652. }, {
  31653. key: "getFootNote",
  31654. value: function getFootNote() {
  31655. return this.footnote;
  31656. }
  31657. }, {
  31658. key: "formatFootNote",
  31659. value: function formatFootNote() {
  31660. var _context8;
  31661. var footnote = this.getFootNote();
  31662. if (footnote.length <= 0) {
  31663. return '';
  31664. }
  31665. var html = map$3(footnote).call(footnote, function (note) {
  31666. var _context7;
  31667. return concat$5(_context7 = "<div class=\"one-footnote\">\n".concat(note.fnref)).call(_context7, note.note, "\n</div>");
  31668. }).join('');
  31669. var sign = this.$engine.md5(html);
  31670. html = concat$5(_context8 = "<div class=\"footnote\" data-sign=\"".concat(sign, "\" data-lines=\"0\"><div class=\"footnote-title\">\u811A\u6CE8</div>")).call(_context8, html, "</div>");
  31671. return html;
  31672. } // getParagraphHook() {
  31673. // return this.commentPAR;
  31674. // }
  31675. }, {
  31676. key: "beforeMakeHtml",
  31677. value: function beforeMakeHtml(str) {
  31678. var _this2 = this;
  31679. // 单行注释,TODO: 替换为引用
  31680. // str = str.replace(/(^|\n)\[([^^][^\]]*?)\]:([^\n]+?)(?=$|\n)/g, '$1');
  31681. var $str = str;
  31682. if (this.test($str)) {
  31683. $str = $str.replace(this.RULE.reg, function (match, leading, key, content) {
  31684. _this2.pushFootnoteCache(key, content);
  31685. var LF = match.match(/\n/g) || [];
  31686. return LF.join('');
  31687. }); // 替换实际引用
  31688. $str = $str.replace(/\[\^([^\]]+?)\](?!:)/g, function (match, key) {
  31689. var cache = _this2.getFootnoteCache(key);
  31690. if (cache) {
  31691. return _this2.pushFootNote(key, cache);
  31692. }
  31693. return match;
  31694. });
  31695. $str += this.formatFootNote();
  31696. }
  31697. return $str;
  31698. }
  31699. }, {
  31700. key: "makeHtml",
  31701. value: function makeHtml(str, sentenceMakeFunc) {
  31702. return str;
  31703. }
  31704. }, {
  31705. key: "afterMakeHtml",
  31706. value: function afterMakeHtml(str) {
  31707. var footNotes = this.getFootNote();
  31708. var $str = str.replace(/\0~fn#([0-9]+)#\0/g, function (match, num) {
  31709. return footNotes[num].fn;
  31710. });
  31711. this.$cleanCache();
  31712. return $str;
  31713. }
  31714. }, {
  31715. key: "rule",
  31716. value: function rule() {
  31717. var ret = {
  31718. begin: '(^|\\n)[ \t]*',
  31719. content: ['\\[\\^([^\\]]+?)\\]:\\h*', // footnote key
  31720. '([\\s\\S]+?)' // footnote content
  31721. ].join(''),
  31722. end: '(?=\\s*$|\\n\\n)'
  31723. };
  31724. ret.reg = compileRegExp(ret, 'g', true);
  31725. return ret;
  31726. }
  31727. }]);
  31728. return Footnote;
  31729. }(ParagraphBase);
  31730. _defineProperty(Footnote, "HOOK_NAME", 'footnote');
  31731. function _createSuper$q(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$q(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  31732. function _isNativeReflectConstruct$q() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  31733. /**
  31734. * 脚注和引用语法
  31735. * 示例:
  31736. * 这里需要一个脚注[^脚注别名1],另外这里也需要一个脚注[^another]。
  31737. * [^脚注别名1]: 无论脚注内容写在哪里,脚注的内容总会显示在页面最底部
  31738. * 以两次回车结束
  31739. *
  31740. * [^another]: 另外,脚注里也可以使用一些简单的markdown语法
  31741. * >比如 !!#ff0000 这里!!有一段**引用**
  31742. */
  31743. var CommentReference = /*#__PURE__*/function (_ParagraphBase) {
  31744. _inherits(CommentReference, _ParagraphBase);
  31745. var _super = _createSuper$q(CommentReference);
  31746. function CommentReference(_ref) {
  31747. var _this;
  31748. var externals = _ref.externals,
  31749. config = _ref.config;
  31750. _classCallCheck(this, CommentReference);
  31751. _this = _super.call(this);
  31752. _this.commentCache = {};
  31753. return _this;
  31754. }
  31755. _createClass(CommentReference, [{
  31756. key: "$cleanCache",
  31757. value: function $cleanCache() {
  31758. this.commentCache = {};
  31759. }
  31760. }, {
  31761. key: "pushCommentReferenceCache",
  31762. value: function pushCommentReferenceCache(key, cache) {
  31763. var _context;
  31764. var _cache$split = cache.split(/[ ]+/g),
  31765. _cache$split2 = _toArray(_cache$split),
  31766. url = _cache$split2[0],
  31767. args = slice$7(_cache$split2).call(_cache$split2, 1);
  31768. var innerUrl = UrlCache.set(url);
  31769. this.commentCache["".concat(key).toLowerCase()] = concat$5(_context = [innerUrl]).call(_context, _toConsumableArray(args)).join(' ');
  31770. }
  31771. }, {
  31772. key: "getCommentReferenceCache",
  31773. value: function getCommentReferenceCache(key) {
  31774. return this.commentCache["".concat(key).toLowerCase()] || null;
  31775. }
  31776. }, {
  31777. key: "beforeMakeHtml",
  31778. value: function beforeMakeHtml(str) {
  31779. var _this2 = this;
  31780. var $str = str;
  31781. if (this.test($str)) {
  31782. $str = $str.replace(this.RULE.reg, function (match, leading, key, content) {
  31783. var _match$match;
  31784. _this2.pushCommentReferenceCache(key, content);
  31785. var lineFeeds = (_match$match = match.match(/\n/g)) !== null && _match$match !== void 0 ? _match$match : [];
  31786. return lineFeeds.join('');
  31787. }); // 替换实际引用
  31788. var refRegex = /(\[[^\]\n]+?\])?(?:\[([^\]\n]+?)\])/g; // 匹配[xxx][ref]形式的内容,不严格大小写
  31789. $str = $str.replace(refRegex, function (match, leadingContent, key) {
  31790. var cache = _this2.getCommentReferenceCache(key);
  31791. if (cache) {
  31792. var _context3;
  31793. if (leadingContent) {
  31794. var _context2;
  31795. return concat$5(_context2 = "".concat(leadingContent, "(")).call(_context2, cache, ")"); // 替换为[xx](cache)形式,交给Link或多媒体标签处理
  31796. }
  31797. return concat$5(_context3 = "[".concat(key, "](")).call(_context3, cache, ")"); // 替换为[ref](cache)形式,交给Link或多媒体标签处理
  31798. }
  31799. return match;
  31800. });
  31801. this.$cleanCache();
  31802. }
  31803. return $str;
  31804. }
  31805. }, {
  31806. key: "makeHtml",
  31807. value: function makeHtml(str, sentenceMakeFunc) {
  31808. return str;
  31809. }
  31810. }, {
  31811. key: "afterMakeHtml",
  31812. value: function afterMakeHtml(str) {
  31813. return UrlCache.restoreAll(str);
  31814. }
  31815. }, {
  31816. key: "rule",
  31817. value: function rule() {
  31818. var ret = {
  31819. begin: '(^|\\n)[ \t]*',
  31820. content: ['\\[([^^][^\\]]*?)\\]:\\h*', // comment key
  31821. '([^\\n]+?)' // comment content
  31822. ].join(''),
  31823. end: '(?=$|\\n)'
  31824. };
  31825. ret.reg = compileRegExp(ret, 'g', true);
  31826. return ret;
  31827. }
  31828. }]);
  31829. return CommentReference;
  31830. }(ParagraphBase);
  31831. _defineProperty(CommentReference, "HOOK_NAME", 'commentReference');
  31832. var $some = arrayIteration.some;
  31833. var STRICT_METHOD$3 = arrayMethodIsStrict('some');
  31834. // `Array.prototype.some` method
  31835. // https://tc39.es/ecma262/#sec-array.prototype.some
  31836. _export({ target: 'Array', proto: true, forced: !STRICT_METHOD$3 }, {
  31837. some: function some(callbackfn /* , thisArg */) {
  31838. return $some(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  31839. }
  31840. });
  31841. var some = entryVirtual('Array').some;
  31842. var ArrayPrototype$c = Array.prototype;
  31843. var some$1 = function (it) {
  31844. var own = it.some;
  31845. return it === ArrayPrototype$c || (objectIsPrototypeOf(ArrayPrototype$c, it) && own === ArrayPrototype$c.some) ? some : own;
  31846. };
  31847. var some$2 = some$1;
  31848. var some$3 = some$2;
  31849. var purify = createCommonjsModule(function (module, exports) {
  31850. /*! @license DOMPurify 2.4.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.0/LICENSE */
  31851. (function (global, factory) {
  31852. module.exports = factory() ;
  31853. })(commonjsGlobal, (function () {
  31854. function _typeof(obj) {
  31855. "@babel/helpers - typeof";
  31856. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
  31857. return typeof obj;
  31858. } : function (obj) {
  31859. return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  31860. }, _typeof(obj);
  31861. }
  31862. function _setPrototypeOf(o, p) {
  31863. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  31864. o.__proto__ = p;
  31865. return o;
  31866. };
  31867. return _setPrototypeOf(o, p);
  31868. }
  31869. function _isNativeReflectConstruct() {
  31870. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  31871. if (Reflect.construct.sham) return false;
  31872. if (typeof Proxy === "function") return true;
  31873. try {
  31874. Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
  31875. return true;
  31876. } catch (e) {
  31877. return false;
  31878. }
  31879. }
  31880. function _construct(Parent, args, Class) {
  31881. if (_isNativeReflectConstruct()) {
  31882. _construct = Reflect.construct;
  31883. } else {
  31884. _construct = function _construct(Parent, args, Class) {
  31885. var a = [null];
  31886. a.push.apply(a, args);
  31887. var Constructor = Function.bind.apply(Parent, a);
  31888. var instance = new Constructor();
  31889. if (Class) _setPrototypeOf(instance, Class.prototype);
  31890. return instance;
  31891. };
  31892. }
  31893. return _construct.apply(null, arguments);
  31894. }
  31895. function _toConsumableArray(arr) {
  31896. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  31897. }
  31898. function _arrayWithoutHoles(arr) {
  31899. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  31900. }
  31901. function _iterableToArray(iter) {
  31902. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
  31903. }
  31904. function _unsupportedIterableToArray(o, minLen) {
  31905. if (!o) return;
  31906. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  31907. var n = Object.prototype.toString.call(o).slice(8, -1);
  31908. if (n === "Object" && o.constructor) n = o.constructor.name;
  31909. if (n === "Map" || n === "Set") return Array.from(o);
  31910. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  31911. }
  31912. function _arrayLikeToArray(arr, len) {
  31913. if (len == null || len > arr.length) len = arr.length;
  31914. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  31915. return arr2;
  31916. }
  31917. function _nonIterableSpread() {
  31918. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  31919. }
  31920. var hasOwnProperty = Object.hasOwnProperty,
  31921. setPrototypeOf = Object.setPrototypeOf,
  31922. isFrozen = Object.isFrozen,
  31923. getPrototypeOf = Object.getPrototypeOf,
  31924. getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  31925. var freeze = Object.freeze,
  31926. seal = Object.seal,
  31927. create = Object.create; // eslint-disable-line import/no-mutable-exports
  31928. var _ref = typeof Reflect !== 'undefined' && Reflect,
  31929. apply = _ref.apply,
  31930. construct = _ref.construct;
  31931. if (!apply) {
  31932. apply = function apply(fun, thisValue, args) {
  31933. return fun.apply(thisValue, args);
  31934. };
  31935. }
  31936. if (!freeze) {
  31937. freeze = function freeze(x) {
  31938. return x;
  31939. };
  31940. }
  31941. if (!seal) {
  31942. seal = function seal(x) {
  31943. return x;
  31944. };
  31945. }
  31946. if (!construct) {
  31947. construct = function construct(Func, args) {
  31948. return _construct(Func, _toConsumableArray(args));
  31949. };
  31950. }
  31951. var arrayForEach = unapply(Array.prototype.forEach);
  31952. var arrayPop = unapply(Array.prototype.pop);
  31953. var arrayPush = unapply(Array.prototype.push);
  31954. var stringToLowerCase = unapply(String.prototype.toLowerCase);
  31955. var stringMatch = unapply(String.prototype.match);
  31956. var stringReplace = unapply(String.prototype.replace);
  31957. var stringIndexOf = unapply(String.prototype.indexOf);
  31958. var stringTrim = unapply(String.prototype.trim);
  31959. var regExpTest = unapply(RegExp.prototype.test);
  31960. var typeErrorCreate = unconstruct(TypeError);
  31961. function unapply(func) {
  31962. return function (thisArg) {
  31963. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  31964. args[_key - 1] = arguments[_key];
  31965. }
  31966. return apply(func, thisArg, args);
  31967. };
  31968. }
  31969. function unconstruct(func) {
  31970. return function () {
  31971. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  31972. args[_key2] = arguments[_key2];
  31973. }
  31974. return construct(func, args);
  31975. };
  31976. }
  31977. /* Add properties to a lookup table */
  31978. function addToSet(set, array, transformCaseFunc) {
  31979. transformCaseFunc = transformCaseFunc ? transformCaseFunc : stringToLowerCase;
  31980. if (setPrototypeOf) {
  31981. // Make 'in' and truthy checks like Boolean(set.constructor)
  31982. // independent of any properties defined on Object.prototype.
  31983. // Prevent prototype setters from intercepting set as a this value.
  31984. setPrototypeOf(set, null);
  31985. }
  31986. var l = array.length;
  31987. while (l--) {
  31988. var element = array[l];
  31989. if (typeof element === 'string') {
  31990. var lcElement = transformCaseFunc(element);
  31991. if (lcElement !== element) {
  31992. // Config presets (e.g. tags.js, attrs.js) are immutable.
  31993. if (!isFrozen(array)) {
  31994. array[l] = lcElement;
  31995. }
  31996. element = lcElement;
  31997. }
  31998. }
  31999. set[element] = true;
  32000. }
  32001. return set;
  32002. }
  32003. /* Shallow clone an object */
  32004. function clone(object) {
  32005. var newObject = create(null);
  32006. var property;
  32007. for (property in object) {
  32008. if (apply(hasOwnProperty, object, [property])) {
  32009. newObject[property] = object[property];
  32010. }
  32011. }
  32012. return newObject;
  32013. }
  32014. /* IE10 doesn't support __lookupGetter__ so lets'
  32015. * simulate it. It also automatically checks
  32016. * if the prop is function or getter and behaves
  32017. * accordingly. */
  32018. function lookupGetter(object, prop) {
  32019. while (object !== null) {
  32020. var desc = getOwnPropertyDescriptor(object, prop);
  32021. if (desc) {
  32022. if (desc.get) {
  32023. return unapply(desc.get);
  32024. }
  32025. if (typeof desc.value === 'function') {
  32026. return unapply(desc.value);
  32027. }
  32028. }
  32029. object = getPrototypeOf(object);
  32030. }
  32031. function fallbackValue(element) {
  32032. console.warn('fallback value for', element);
  32033. return null;
  32034. }
  32035. return fallbackValue;
  32036. }
  32037. var html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']); // SVG
  32038. var svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
  32039. var svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); // List of SVG elements that are disallowed by default.
  32040. // We still need to know them so that we can do namespace
  32041. // checks properly in case one wants to add them to
  32042. // allow-list.
  32043. var svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'fedropshadow', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
  32044. var mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover']); // Similarly to SVG, we want to know all MathML elements,
  32045. // even those that we disallow by default.
  32046. var mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
  32047. var text = freeze(['#text']);
  32048. var html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns', 'slot']);
  32049. var svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
  32050. var mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
  32051. var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
  32052. var MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
  32053. var ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
  32054. var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
  32055. var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
  32056. var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
  32057. );
  32058. var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
  32059. var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
  32060. );
  32061. var DOCTYPE_NAME = seal(/^html$/i);
  32062. var getGlobal = function getGlobal() {
  32063. return typeof window === 'undefined' ? null : window;
  32064. };
  32065. /**
  32066. * Creates a no-op policy for internal use only.
  32067. * Don't export this function outside this module!
  32068. * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
  32069. * @param {Document} document The document object (to determine policy name suffix)
  32070. * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
  32071. * are not supported).
  32072. */
  32073. var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) {
  32074. if (_typeof(trustedTypes) !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
  32075. return null;
  32076. } // Allow the callers to control the unique policy name
  32077. // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
  32078. // Policy creation with duplicate names throws in Trusted Types.
  32079. var suffix = null;
  32080. var ATTR_NAME = 'data-tt-policy-suffix';
  32081. if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) {
  32082. suffix = document.currentScript.getAttribute(ATTR_NAME);
  32083. }
  32084. var policyName = 'dompurify' + (suffix ? '#' + suffix : '');
  32085. try {
  32086. return trustedTypes.createPolicy(policyName, {
  32087. createHTML: function createHTML(html) {
  32088. return html;
  32089. },
  32090. createScriptURL: function createScriptURL(scriptUrl) {
  32091. return scriptUrl;
  32092. }
  32093. });
  32094. } catch (_) {
  32095. // Policy creation failed (most likely another DOMPurify script has
  32096. // already run). Skip creating the policy, as this will only cause errors
  32097. // if TT are enforced.
  32098. console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
  32099. return null;
  32100. }
  32101. };
  32102. function createDOMPurify() {
  32103. var window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
  32104. var DOMPurify = function DOMPurify(root) {
  32105. return createDOMPurify(root);
  32106. };
  32107. /**
  32108. * Version label, exposed for easier checks
  32109. * if DOMPurify is up to date or not
  32110. */
  32111. DOMPurify.version = '2.4.0';
  32112. /**
  32113. * Array of elements that DOMPurify removed during sanitation.
  32114. * Empty if nothing was removed.
  32115. */
  32116. DOMPurify.removed = [];
  32117. if (!window || !window.document || window.document.nodeType !== 9) {
  32118. // Not running in a browser, provide a factory function
  32119. // so that you can pass your own Window
  32120. DOMPurify.isSupported = false;
  32121. return DOMPurify;
  32122. }
  32123. var originalDocument = window.document;
  32124. var document = window.document;
  32125. var DocumentFragment = window.DocumentFragment,
  32126. HTMLTemplateElement = window.HTMLTemplateElement,
  32127. Node = window.Node,
  32128. Element = window.Element,
  32129. NodeFilter = window.NodeFilter,
  32130. _window$NamedNodeMap = window.NamedNodeMap,
  32131. NamedNodeMap = _window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap,
  32132. HTMLFormElement = window.HTMLFormElement,
  32133. DOMParser = window.DOMParser,
  32134. trustedTypes = window.trustedTypes;
  32135. var ElementPrototype = Element.prototype;
  32136. var cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
  32137. var getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
  32138. var getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
  32139. var getParentNode = lookupGetter(ElementPrototype, 'parentNode'); // As per issue #47, the web-components registry is inherited by a
  32140. // new document created via createHTMLDocument. As per the spec
  32141. // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
  32142. // a new empty registry is used when creating a template contents owner
  32143. // document, so we use that as our parent document to ensure nothing
  32144. // is inherited.
  32145. if (typeof HTMLTemplateElement === 'function') {
  32146. var template = document.createElement('template');
  32147. if (template.content && template.content.ownerDocument) {
  32148. document = template.content.ownerDocument;
  32149. }
  32150. }
  32151. var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument);
  32152. var emptyHTML = trustedTypesPolicy ? trustedTypesPolicy.createHTML('') : '';
  32153. var _document = document,
  32154. implementation = _document.implementation,
  32155. createNodeIterator = _document.createNodeIterator,
  32156. createDocumentFragment = _document.createDocumentFragment,
  32157. getElementsByTagName = _document.getElementsByTagName;
  32158. var importNode = originalDocument.importNode;
  32159. var documentMode = {};
  32160. try {
  32161. documentMode = clone(document).documentMode ? document.documentMode : {};
  32162. } catch (_) {}
  32163. var hooks = {};
  32164. /**
  32165. * Expose whether this browser supports running the full DOMPurify.
  32166. */
  32167. DOMPurify.isSupported = typeof getParentNode === 'function' && implementation && typeof implementation.createHTMLDocument !== 'undefined' && documentMode !== 9;
  32168. var MUSTACHE_EXPR$1 = MUSTACHE_EXPR,
  32169. ERB_EXPR$1 = ERB_EXPR,
  32170. DATA_ATTR$1 = DATA_ATTR,
  32171. ARIA_ATTR$1 = ARIA_ATTR,
  32172. IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA,
  32173. ATTR_WHITESPACE$1 = ATTR_WHITESPACE;
  32174. var IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
  32175. /**
  32176. * We consider the elements and attributes below to be safe. Ideally
  32177. * don't add any new ones but feel free to remove unwanted ones.
  32178. */
  32179. /* allowed element names */
  32180. var ALLOWED_TAGS = null;
  32181. var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray(html$1), _toConsumableArray(svg$1), _toConsumableArray(svgFilters), _toConsumableArray(mathMl$1), _toConsumableArray(text)));
  32182. /* Allowed attribute names */
  32183. var ALLOWED_ATTR = null;
  32184. var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray(html), _toConsumableArray(svg), _toConsumableArray(mathMl), _toConsumableArray(xml)));
  32185. /*
  32186. * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.
  32187. * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
  32188. * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
  32189. * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
  32190. */
  32191. var CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, {
  32192. tagNameCheck: {
  32193. writable: true,
  32194. configurable: false,
  32195. enumerable: true,
  32196. value: null
  32197. },
  32198. attributeNameCheck: {
  32199. writable: true,
  32200. configurable: false,
  32201. enumerable: true,
  32202. value: null
  32203. },
  32204. allowCustomizedBuiltInElements: {
  32205. writable: true,
  32206. configurable: false,
  32207. enumerable: true,
  32208. value: false
  32209. }
  32210. }));
  32211. /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
  32212. var FORBID_TAGS = null;
  32213. /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
  32214. var FORBID_ATTR = null;
  32215. /* Decide if ARIA attributes are okay */
  32216. var ALLOW_ARIA_ATTR = true;
  32217. /* Decide if custom data attributes are okay */
  32218. var ALLOW_DATA_ATTR = true;
  32219. /* Decide if unknown protocols are okay */
  32220. var ALLOW_UNKNOWN_PROTOCOLS = false;
  32221. /* Output should be safe for common template engines.
  32222. * This means, DOMPurify removes data attributes, mustaches and ERB
  32223. */
  32224. var SAFE_FOR_TEMPLATES = false;
  32225. /* Decide if document with <html>... should be returned */
  32226. var WHOLE_DOCUMENT = false;
  32227. /* Track whether config is already set on this instance of DOMPurify. */
  32228. var SET_CONFIG = false;
  32229. /* Decide if all elements (e.g. style, script) must be children of
  32230. * document.body. By default, browsers might move them to document.head */
  32231. var FORCE_BODY = false;
  32232. /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
  32233. * string (or a TrustedHTML object if Trusted Types are supported).
  32234. * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
  32235. */
  32236. var RETURN_DOM = false;
  32237. /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
  32238. * string (or a TrustedHTML object if Trusted Types are supported) */
  32239. var RETURN_DOM_FRAGMENT = false;
  32240. /* Try to return a Trusted Type object instead of a string, return a string in
  32241. * case Trusted Types are not supported */
  32242. var RETURN_TRUSTED_TYPE = false;
  32243. /* Output should be free from DOM clobbering attacks?
  32244. * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
  32245. */
  32246. var SANITIZE_DOM = true;
  32247. /* Achieve full DOM Clobbering protection by isolating the namespace of named
  32248. * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
  32249. *
  32250. * HTML/DOM spec rules that enable DOM Clobbering:
  32251. * - Named Access on Window (§7.3.3)
  32252. * - DOM Tree Accessors (§3.1.5)
  32253. * - Form Element Parent-Child Relations (§4.10.3)
  32254. * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
  32255. * - HTMLCollection (§4.2.10.2)
  32256. *
  32257. * Namespace isolation is implemented by prefixing `id` and `name` attributes
  32258. * with a constant string, i.e., `user-content-`
  32259. */
  32260. var SANITIZE_NAMED_PROPS = false;
  32261. var SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
  32262. /* Keep element content when removing element? */
  32263. var KEEP_CONTENT = true;
  32264. /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
  32265. * of importing it into a new Document and returning a sanitized copy */
  32266. var IN_PLACE = false;
  32267. /* Allow usage of profiles like html, svg and mathMl */
  32268. var USE_PROFILES = {};
  32269. /* Tags to ignore content of when KEEP_CONTENT is true */
  32270. var FORBID_CONTENTS = null;
  32271. var DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
  32272. /* Tags that are safe for data: URIs */
  32273. var DATA_URI_TAGS = null;
  32274. var DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
  32275. /* Attributes safe for values like "javascript:" */
  32276. var URI_SAFE_ATTRIBUTES = null;
  32277. var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
  32278. var MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
  32279. var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
  32280. var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
  32281. /* Document namespace */
  32282. var NAMESPACE = HTML_NAMESPACE;
  32283. var IS_EMPTY_INPUT = false;
  32284. /* Parsing of strict XHTML documents */
  32285. var PARSER_MEDIA_TYPE;
  32286. var SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
  32287. var DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
  32288. var transformCaseFunc;
  32289. /* Keep a reference to config to pass to hooks */
  32290. var CONFIG = null;
  32291. /* Ideally, do not touch anything below this line */
  32292. /* ______________________________________________ */
  32293. var formElement = document.createElement('form');
  32294. var isRegexOrFunction = function isRegexOrFunction(testValue) {
  32295. return testValue instanceof RegExp || testValue instanceof Function;
  32296. };
  32297. /**
  32298. * _parseConfig
  32299. *
  32300. * @param {Object} cfg optional config literal
  32301. */
  32302. // eslint-disable-next-line complexity
  32303. var _parseConfig = function _parseConfig(cfg) {
  32304. if (CONFIG && CONFIG === cfg) {
  32305. return;
  32306. }
  32307. /* Shield configuration object from tampering */
  32308. if (!cfg || _typeof(cfg) !== 'object') {
  32309. cfg = {};
  32310. }
  32311. /* Shield configuration object from prototype pollution */
  32312. cfg = clone(cfg);
  32313. PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
  32314. SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE; // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
  32315. transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? function (x) {
  32316. return x;
  32317. } : stringToLowerCase;
  32318. /* Set configuration parameters */
  32319. ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
  32320. ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
  32321. URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), // eslint-disable-line indent
  32322. cfg.ADD_URI_SAFE_ATTR, // eslint-disable-line indent
  32323. transformCaseFunc // eslint-disable-line indent
  32324. ) // eslint-disable-line indent
  32325. : DEFAULT_URI_SAFE_ATTRIBUTES;
  32326. DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), // eslint-disable-line indent
  32327. cfg.ADD_DATA_URI_TAGS, // eslint-disable-line indent
  32328. transformCaseFunc // eslint-disable-line indent
  32329. ) // eslint-disable-line indent
  32330. : DEFAULT_DATA_URI_TAGS;
  32331. FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
  32332. FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
  32333. FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
  32334. USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
  32335. ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
  32336. ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
  32337. ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
  32338. SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
  32339. WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
  32340. RETURN_DOM = cfg.RETURN_DOM || false; // Default false
  32341. RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
  32342. RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
  32343. FORCE_BODY = cfg.FORCE_BODY || false; // Default false
  32344. SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
  32345. SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
  32346. KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
  32347. IN_PLACE = cfg.IN_PLACE || false; // Default false
  32348. IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$1;
  32349. NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
  32350. if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
  32351. CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
  32352. }
  32353. if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
  32354. CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
  32355. }
  32356. if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
  32357. CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
  32358. }
  32359. if (SAFE_FOR_TEMPLATES) {
  32360. ALLOW_DATA_ATTR = false;
  32361. }
  32362. if (RETURN_DOM_FRAGMENT) {
  32363. RETURN_DOM = true;
  32364. }
  32365. /* Parse profile info */
  32366. if (USE_PROFILES) {
  32367. ALLOWED_TAGS = addToSet({}, _toConsumableArray(text));
  32368. ALLOWED_ATTR = [];
  32369. if (USE_PROFILES.html === true) {
  32370. addToSet(ALLOWED_TAGS, html$1);
  32371. addToSet(ALLOWED_ATTR, html);
  32372. }
  32373. if (USE_PROFILES.svg === true) {
  32374. addToSet(ALLOWED_TAGS, svg$1);
  32375. addToSet(ALLOWED_ATTR, svg);
  32376. addToSet(ALLOWED_ATTR, xml);
  32377. }
  32378. if (USE_PROFILES.svgFilters === true) {
  32379. addToSet(ALLOWED_TAGS, svgFilters);
  32380. addToSet(ALLOWED_ATTR, svg);
  32381. addToSet(ALLOWED_ATTR, xml);
  32382. }
  32383. if (USE_PROFILES.mathMl === true) {
  32384. addToSet(ALLOWED_TAGS, mathMl$1);
  32385. addToSet(ALLOWED_ATTR, mathMl);
  32386. addToSet(ALLOWED_ATTR, xml);
  32387. }
  32388. }
  32389. /* Merge configuration parameters */
  32390. if (cfg.ADD_TAGS) {
  32391. if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
  32392. ALLOWED_TAGS = clone(ALLOWED_TAGS);
  32393. }
  32394. addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
  32395. }
  32396. if (cfg.ADD_ATTR) {
  32397. if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
  32398. ALLOWED_ATTR = clone(ALLOWED_ATTR);
  32399. }
  32400. addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
  32401. }
  32402. if (cfg.ADD_URI_SAFE_ATTR) {
  32403. addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
  32404. }
  32405. if (cfg.FORBID_CONTENTS) {
  32406. if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
  32407. FORBID_CONTENTS = clone(FORBID_CONTENTS);
  32408. }
  32409. addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
  32410. }
  32411. /* Add #text in case KEEP_CONTENT is set to true */
  32412. if (KEEP_CONTENT) {
  32413. ALLOWED_TAGS['#text'] = true;
  32414. }
  32415. /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
  32416. if (WHOLE_DOCUMENT) {
  32417. addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
  32418. }
  32419. /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
  32420. if (ALLOWED_TAGS.table) {
  32421. addToSet(ALLOWED_TAGS, ['tbody']);
  32422. delete FORBID_TAGS.tbody;
  32423. } // Prevent further manipulation of configuration.
  32424. // Not available in IE8, Safari 5, etc.
  32425. if (freeze) {
  32426. freeze(cfg);
  32427. }
  32428. CONFIG = cfg;
  32429. };
  32430. var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
  32431. var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); // Certain elements are allowed in both SVG and HTML
  32432. // namespace. We need to specify them explicitly
  32433. // so that they don't get erroneously deleted from
  32434. // HTML namespace.
  32435. var COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
  32436. /* Keep track of all possible SVG and MathML tags
  32437. * so that we can perform the namespace checks
  32438. * correctly. */
  32439. var ALL_SVG_TAGS = addToSet({}, svg$1);
  32440. addToSet(ALL_SVG_TAGS, svgFilters);
  32441. addToSet(ALL_SVG_TAGS, svgDisallowed);
  32442. var ALL_MATHML_TAGS = addToSet({}, mathMl$1);
  32443. addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
  32444. /**
  32445. *
  32446. *
  32447. * @param {Element} element a DOM element whose namespace is being checked
  32448. * @returns {boolean} Return false if the element has a
  32449. * namespace that a spec-compliant parser would never
  32450. * return. Return true otherwise.
  32451. */
  32452. var _checkValidNamespace = function _checkValidNamespace(element) {
  32453. var parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode
  32454. // can be null. We just simulate parent in this case.
  32455. if (!parent || !parent.tagName) {
  32456. parent = {
  32457. namespaceURI: HTML_NAMESPACE,
  32458. tagName: 'template'
  32459. };
  32460. }
  32461. var tagName = stringToLowerCase(element.tagName);
  32462. var parentTagName = stringToLowerCase(parent.tagName);
  32463. if (element.namespaceURI === SVG_NAMESPACE) {
  32464. // The only way to switch from HTML namespace to SVG
  32465. // is via <svg>. If it happens via any other tag, then
  32466. // it should be killed.
  32467. if (parent.namespaceURI === HTML_NAMESPACE) {
  32468. return tagName === 'svg';
  32469. } // The only way to switch from MathML to SVG is via
  32470. // svg if parent is either <annotation-xml> or MathML
  32471. // text integration points.
  32472. if (parent.namespaceURI === MATHML_NAMESPACE) {
  32473. return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
  32474. } // We only allow elements that are defined in SVG
  32475. // spec. All others are disallowed in SVG namespace.
  32476. return Boolean(ALL_SVG_TAGS[tagName]);
  32477. }
  32478. if (element.namespaceURI === MATHML_NAMESPACE) {
  32479. // The only way to switch from HTML namespace to MathML
  32480. // is via <math>. If it happens via any other tag, then
  32481. // it should be killed.
  32482. if (parent.namespaceURI === HTML_NAMESPACE) {
  32483. return tagName === 'math';
  32484. } // The only way to switch from SVG to MathML is via
  32485. // <math> and HTML integration points
  32486. if (parent.namespaceURI === SVG_NAMESPACE) {
  32487. return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
  32488. } // We only allow elements that are defined in MathML
  32489. // spec. All others are disallowed in MathML namespace.
  32490. return Boolean(ALL_MATHML_TAGS[tagName]);
  32491. }
  32492. if (element.namespaceURI === HTML_NAMESPACE) {
  32493. // The only way to switch from SVG to HTML is via
  32494. // HTML integration points, and from MathML to HTML
  32495. // is via MathML text integration points
  32496. if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
  32497. return false;
  32498. }
  32499. if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
  32500. return false;
  32501. } // We disallow tags that are specific for MathML
  32502. // or SVG and should never appear in HTML namespace
  32503. return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
  32504. } // The code should never reach this place (this means
  32505. // that the element somehow got namespace that is not
  32506. // HTML, SVG or MathML). Return false just in case.
  32507. return false;
  32508. };
  32509. /**
  32510. * _forceRemove
  32511. *
  32512. * @param {Node} node a DOM node
  32513. */
  32514. var _forceRemove = function _forceRemove(node) {
  32515. arrayPush(DOMPurify.removed, {
  32516. element: node
  32517. });
  32518. try {
  32519. // eslint-disable-next-line unicorn/prefer-dom-node-remove
  32520. node.parentNode.removeChild(node);
  32521. } catch (_) {
  32522. try {
  32523. node.outerHTML = emptyHTML;
  32524. } catch (_) {
  32525. node.remove();
  32526. }
  32527. }
  32528. };
  32529. /**
  32530. * _removeAttribute
  32531. *
  32532. * @param {String} name an Attribute name
  32533. * @param {Node} node a DOM node
  32534. */
  32535. var _removeAttribute = function _removeAttribute(name, node) {
  32536. try {
  32537. arrayPush(DOMPurify.removed, {
  32538. attribute: node.getAttributeNode(name),
  32539. from: node
  32540. });
  32541. } catch (_) {
  32542. arrayPush(DOMPurify.removed, {
  32543. attribute: null,
  32544. from: node
  32545. });
  32546. }
  32547. node.removeAttribute(name); // We void attribute values for unremovable "is"" attributes
  32548. if (name === 'is' && !ALLOWED_ATTR[name]) {
  32549. if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
  32550. try {
  32551. _forceRemove(node);
  32552. } catch (_) {}
  32553. } else {
  32554. try {
  32555. node.setAttribute(name, '');
  32556. } catch (_) {}
  32557. }
  32558. }
  32559. };
  32560. /**
  32561. * _initDocument
  32562. *
  32563. * @param {String} dirty a string of dirty markup
  32564. * @return {Document} a DOM, filled with the dirty markup
  32565. */
  32566. var _initDocument = function _initDocument(dirty) {
  32567. /* Create a HTML document */
  32568. var doc;
  32569. var leadingWhitespace;
  32570. if (FORCE_BODY) {
  32571. dirty = '<remove></remove>' + dirty;
  32572. } else {
  32573. /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
  32574. var matches = stringMatch(dirty, /^[\r\n\t ]+/);
  32575. leadingWhitespace = matches && matches[0];
  32576. }
  32577. if (PARSER_MEDIA_TYPE === 'application/xhtml+xml') {
  32578. // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
  32579. dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
  32580. }
  32581. var dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
  32582. /*
  32583. * Use the DOMParser API by default, fallback later if needs be
  32584. * DOMParser not work for svg when has multiple root element.
  32585. */
  32586. if (NAMESPACE === HTML_NAMESPACE) {
  32587. try {
  32588. doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
  32589. } catch (_) {}
  32590. }
  32591. /* Use createHTMLDocument in case DOMParser is not available */
  32592. if (!doc || !doc.documentElement) {
  32593. doc = implementation.createDocument(NAMESPACE, 'template', null);
  32594. try {
  32595. doc.documentElement.innerHTML = IS_EMPTY_INPUT ? '' : dirtyPayload;
  32596. } catch (_) {// Syntax error if dirtyPayload is invalid xml
  32597. }
  32598. }
  32599. var body = doc.body || doc.documentElement;
  32600. if (dirty && leadingWhitespace) {
  32601. body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
  32602. }
  32603. /* Work on whole document or just its body */
  32604. if (NAMESPACE === HTML_NAMESPACE) {
  32605. return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
  32606. }
  32607. return WHOLE_DOCUMENT ? doc.documentElement : body;
  32608. };
  32609. /**
  32610. * _createIterator
  32611. *
  32612. * @param {Document} root document/fragment to create iterator for
  32613. * @return {Iterator} iterator instance
  32614. */
  32615. var _createIterator = function _createIterator(root) {
  32616. return createNodeIterator.call(root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise
  32617. NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
  32618. };
  32619. /**
  32620. * _isClobbered
  32621. *
  32622. * @param {Node} elm element to check for clobbering attacks
  32623. * @return {Boolean} true if clobbered, false if safe
  32624. */
  32625. var _isClobbered = function _isClobbered(elm) {
  32626. return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function');
  32627. };
  32628. /**
  32629. * _isNode
  32630. *
  32631. * @param {Node} obj object to check whether it's a DOM node
  32632. * @return {Boolean} true is object is a DOM node
  32633. */
  32634. var _isNode = function _isNode(object) {
  32635. return _typeof(Node) === 'object' ? object instanceof Node : object && _typeof(object) === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string';
  32636. };
  32637. /**
  32638. * _executeHook
  32639. * Execute user configurable hooks
  32640. *
  32641. * @param {String} entryPoint Name of the hook's entry point
  32642. * @param {Node} currentNode node to work on with the hook
  32643. * @param {Object} data additional hook parameters
  32644. */
  32645. var _executeHook = function _executeHook(entryPoint, currentNode, data) {
  32646. if (!hooks[entryPoint]) {
  32647. return;
  32648. }
  32649. arrayForEach(hooks[entryPoint], function (hook) {
  32650. hook.call(DOMPurify, currentNode, data, CONFIG);
  32651. });
  32652. };
  32653. /**
  32654. * _sanitizeElements
  32655. *
  32656. * @protect nodeName
  32657. * @protect textContent
  32658. * @protect removeChild
  32659. *
  32660. * @param {Node} currentNode to check for permission to exist
  32661. * @return {Boolean} true if node was killed, false if left alive
  32662. */
  32663. var _sanitizeElements = function _sanitizeElements(currentNode) {
  32664. var content;
  32665. /* Execute a hook if present */
  32666. _executeHook('beforeSanitizeElements', currentNode, null);
  32667. /* Check if element is clobbered or can clobber */
  32668. if (_isClobbered(currentNode)) {
  32669. _forceRemove(currentNode);
  32670. return true;
  32671. }
  32672. /* Check if tagname contains Unicode */
  32673. if (regExpTest(/[\u0080-\uFFFF]/, currentNode.nodeName)) {
  32674. _forceRemove(currentNode);
  32675. return true;
  32676. }
  32677. /* Now let's check the element's type and name */
  32678. var tagName = transformCaseFunc(currentNode.nodeName);
  32679. /* Execute a hook if present */
  32680. _executeHook('uponSanitizeElement', currentNode, {
  32681. tagName: tagName,
  32682. allowedTags: ALLOWED_TAGS
  32683. });
  32684. /* Detect mXSS attempts abusing namespace confusion */
  32685. if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
  32686. _forceRemove(currentNode);
  32687. return true;
  32688. }
  32689. /* Mitigate a problem with templates inside select */
  32690. if (tagName === 'select' && regExpTest(/<template/i, currentNode.innerHTML)) {
  32691. _forceRemove(currentNode);
  32692. return true;
  32693. }
  32694. /* Remove element if anything forbids its presence */
  32695. if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
  32696. /* Check if we have a custom element to handle */
  32697. if (!FORBID_TAGS[tagName] && _basicCustomElementTest(tagName)) {
  32698. if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
  32699. if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) return false;
  32700. }
  32701. /* Keep content except for bad-listed elements */
  32702. if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
  32703. var parentNode = getParentNode(currentNode) || currentNode.parentNode;
  32704. var childNodes = getChildNodes(currentNode) || currentNode.childNodes;
  32705. if (childNodes && parentNode) {
  32706. var childCount = childNodes.length;
  32707. for (var i = childCount - 1; i >= 0; --i) {
  32708. parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
  32709. }
  32710. }
  32711. }
  32712. _forceRemove(currentNode);
  32713. return true;
  32714. }
  32715. /* Check whether element has a valid namespace */
  32716. if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
  32717. _forceRemove(currentNode);
  32718. return true;
  32719. }
  32720. if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) {
  32721. _forceRemove(currentNode);
  32722. return true;
  32723. }
  32724. /* Sanitize element content to be template-safe */
  32725. if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
  32726. /* Get the element's text content */
  32727. content = currentNode.textContent;
  32728. content = stringReplace(content, MUSTACHE_EXPR$1, ' ');
  32729. content = stringReplace(content, ERB_EXPR$1, ' ');
  32730. if (currentNode.textContent !== content) {
  32731. arrayPush(DOMPurify.removed, {
  32732. element: currentNode.cloneNode()
  32733. });
  32734. currentNode.textContent = content;
  32735. }
  32736. }
  32737. /* Execute a hook if present */
  32738. _executeHook('afterSanitizeElements', currentNode, null);
  32739. return false;
  32740. };
  32741. /**
  32742. * _isValidAttribute
  32743. *
  32744. * @param {string} lcTag Lowercase tag name of containing element.
  32745. * @param {string} lcName Lowercase attribute name.
  32746. * @param {string} value Attribute value.
  32747. * @return {Boolean} Returns true if `value` is valid, otherwise false.
  32748. */
  32749. // eslint-disable-next-line complexity
  32750. var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
  32751. /* Make sure attribute cannot clobber */
  32752. if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
  32753. return false;
  32754. }
  32755. /* Allow valid data-* attributes: At least one character after "-"
  32756. (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
  32757. XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
  32758. We don't need to check the value; it's always URI safe. */
  32759. if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
  32760. if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND
  32761. // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
  32762. // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
  32763. _basicCustomElementTest(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) || // Alternative, second condition checks if it's an `is`-attribute, AND
  32764. // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
  32765. lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {
  32766. return false;
  32767. }
  32768. /* Check value is safe. First, is attr inert? If so, is safe */
  32769. } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) ; else if (!value) ; else {
  32770. return false;
  32771. }
  32772. return true;
  32773. };
  32774. /**
  32775. * _basicCustomElementCheck
  32776. * checks if at least one dash is included in tagName, and it's not the first char
  32777. * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
  32778. * @param {string} tagName name of the tag of the node to sanitize
  32779. */
  32780. var _basicCustomElementTest = function _basicCustomElementTest(tagName) {
  32781. return tagName.indexOf('-') > 0;
  32782. };
  32783. /**
  32784. * _sanitizeAttributes
  32785. *
  32786. * @protect attributes
  32787. * @protect nodeName
  32788. * @protect removeAttribute
  32789. * @protect setAttribute
  32790. *
  32791. * @param {Node} currentNode to sanitize
  32792. */
  32793. var _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
  32794. var attr;
  32795. var value;
  32796. var lcName;
  32797. var l;
  32798. /* Execute a hook if present */
  32799. _executeHook('beforeSanitizeAttributes', currentNode, null);
  32800. var attributes = currentNode.attributes;
  32801. /* Check if we have attributes; if not we might have a text node */
  32802. if (!attributes) {
  32803. return;
  32804. }
  32805. var hookEvent = {
  32806. attrName: '',
  32807. attrValue: '',
  32808. keepAttr: true,
  32809. allowedAttributes: ALLOWED_ATTR
  32810. };
  32811. l = attributes.length;
  32812. /* Go backwards over all attributes; safely remove bad ones */
  32813. while (l--) {
  32814. attr = attributes[l];
  32815. var _attr = attr,
  32816. name = _attr.name,
  32817. namespaceURI = _attr.namespaceURI;
  32818. value = name === 'value' ? attr.value : stringTrim(attr.value);
  32819. lcName = transformCaseFunc(name);
  32820. /* Execute a hook if present */
  32821. hookEvent.attrName = lcName;
  32822. hookEvent.attrValue = value;
  32823. hookEvent.keepAttr = true;
  32824. hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
  32825. _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
  32826. value = hookEvent.attrValue;
  32827. /* Did the hooks approve of the attribute? */
  32828. if (hookEvent.forceKeepAttr) {
  32829. continue;
  32830. }
  32831. /* Remove attribute */
  32832. _removeAttribute(name, currentNode);
  32833. /* Did the hooks approve of the attribute? */
  32834. if (!hookEvent.keepAttr) {
  32835. continue;
  32836. }
  32837. /* Work around a security issue in jQuery 3.0 */
  32838. if (regExpTest(/\/>/i, value)) {
  32839. _removeAttribute(name, currentNode);
  32840. continue;
  32841. }
  32842. /* Sanitize attribute content to be template-safe */
  32843. if (SAFE_FOR_TEMPLATES) {
  32844. value = stringReplace(value, MUSTACHE_EXPR$1, ' ');
  32845. value = stringReplace(value, ERB_EXPR$1, ' ');
  32846. }
  32847. /* Is `value` valid for this attribute? */
  32848. var lcTag = transformCaseFunc(currentNode.nodeName);
  32849. if (!_isValidAttribute(lcTag, lcName, value)) {
  32850. continue;
  32851. }
  32852. /* Full DOM Clobbering protection via namespace isolation,
  32853. * Prefix id and name attributes with `user-content-`
  32854. */
  32855. if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
  32856. // Remove the attribute with this value
  32857. _removeAttribute(name, currentNode); // Prefix the value and later re-create the attribute with the sanitized value
  32858. value = SANITIZE_NAMED_PROPS_PREFIX + value;
  32859. }
  32860. /* Handle attributes that require Trusted Types */
  32861. if (trustedTypesPolicy && _typeof(trustedTypes) === 'object' && typeof trustedTypes.getAttributeType === 'function') {
  32862. if (namespaceURI) ; else {
  32863. switch (trustedTypes.getAttributeType(lcTag, lcName)) {
  32864. case 'TrustedHTML':
  32865. value = trustedTypesPolicy.createHTML(value);
  32866. break;
  32867. case 'TrustedScriptURL':
  32868. value = trustedTypesPolicy.createScriptURL(value);
  32869. break;
  32870. }
  32871. }
  32872. }
  32873. /* Handle invalid data-* attribute set by try-catching it */
  32874. try {
  32875. if (namespaceURI) {
  32876. currentNode.setAttributeNS(namespaceURI, name, value);
  32877. } else {
  32878. /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
  32879. currentNode.setAttribute(name, value);
  32880. }
  32881. arrayPop(DOMPurify.removed);
  32882. } catch (_) {}
  32883. }
  32884. /* Execute a hook if present */
  32885. _executeHook('afterSanitizeAttributes', currentNode, null);
  32886. };
  32887. /**
  32888. * _sanitizeShadowDOM
  32889. *
  32890. * @param {DocumentFragment} fragment to iterate over recursively
  32891. */
  32892. var _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
  32893. var shadowNode;
  32894. var shadowIterator = _createIterator(fragment);
  32895. /* Execute a hook if present */
  32896. _executeHook('beforeSanitizeShadowDOM', fragment, null);
  32897. while (shadowNode = shadowIterator.nextNode()) {
  32898. /* Execute a hook if present */
  32899. _executeHook('uponSanitizeShadowNode', shadowNode, null);
  32900. /* Sanitize tags and elements */
  32901. if (_sanitizeElements(shadowNode)) {
  32902. continue;
  32903. }
  32904. /* Deep shadow DOM detected */
  32905. if (shadowNode.content instanceof DocumentFragment) {
  32906. _sanitizeShadowDOM(shadowNode.content);
  32907. }
  32908. /* Check attributes, sanitize if necessary */
  32909. _sanitizeAttributes(shadowNode);
  32910. }
  32911. /* Execute a hook if present */
  32912. _executeHook('afterSanitizeShadowDOM', fragment, null);
  32913. };
  32914. /**
  32915. * Sanitize
  32916. * Public method providing core sanitation functionality
  32917. *
  32918. * @param {String|Node} dirty string or DOM node
  32919. * @param {Object} configuration object
  32920. */
  32921. // eslint-disable-next-line complexity
  32922. DOMPurify.sanitize = function (dirty) {
  32923. var cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  32924. var body;
  32925. var importedNode;
  32926. var currentNode;
  32927. var oldNode;
  32928. var returnNode;
  32929. /* Make sure we have a string to sanitize.
  32930. DO NOT return early, as this will return the wrong type if
  32931. the user has requested a DOM object rather than a string */
  32932. IS_EMPTY_INPUT = !dirty;
  32933. if (IS_EMPTY_INPUT) {
  32934. dirty = '<!-->';
  32935. }
  32936. /* Stringify, in case dirty is an object */
  32937. if (typeof dirty !== 'string' && !_isNode(dirty)) {
  32938. // eslint-disable-next-line no-negated-condition
  32939. if (typeof dirty.toString !== 'function') {
  32940. throw typeErrorCreate('toString is not a function');
  32941. } else {
  32942. dirty = dirty.toString();
  32943. if (typeof dirty !== 'string') {
  32944. throw typeErrorCreate('dirty is not a string, aborting');
  32945. }
  32946. }
  32947. }
  32948. /* Check we can run. Otherwise fall back or ignore */
  32949. if (!DOMPurify.isSupported) {
  32950. if (_typeof(window.toStaticHTML) === 'object' || typeof window.toStaticHTML === 'function') {
  32951. if (typeof dirty === 'string') {
  32952. return window.toStaticHTML(dirty);
  32953. }
  32954. if (_isNode(dirty)) {
  32955. return window.toStaticHTML(dirty.outerHTML);
  32956. }
  32957. }
  32958. return dirty;
  32959. }
  32960. /* Assign config vars */
  32961. if (!SET_CONFIG) {
  32962. _parseConfig(cfg);
  32963. }
  32964. /* Clean up removed elements */
  32965. DOMPurify.removed = [];
  32966. /* Check if dirty is correctly typed for IN_PLACE */
  32967. if (typeof dirty === 'string') {
  32968. IN_PLACE = false;
  32969. }
  32970. if (IN_PLACE) {
  32971. /* Do some early pre-sanitization to avoid unsafe root nodes */
  32972. if (dirty.nodeName) {
  32973. var tagName = transformCaseFunc(dirty.nodeName);
  32974. if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
  32975. throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
  32976. }
  32977. }
  32978. } else if (dirty instanceof Node) {
  32979. /* If dirty is a DOM element, append to an empty document to avoid
  32980. elements being stripped by the parser */
  32981. body = _initDocument('<!---->');
  32982. importedNode = body.ownerDocument.importNode(dirty, true);
  32983. if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
  32984. /* Node is already a body, use as is */
  32985. body = importedNode;
  32986. } else if (importedNode.nodeName === 'HTML') {
  32987. body = importedNode;
  32988. } else {
  32989. // eslint-disable-next-line unicorn/prefer-dom-node-append
  32990. body.appendChild(importedNode);
  32991. }
  32992. } else {
  32993. /* Exit directly if we have nothing to do */
  32994. if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
  32995. dirty.indexOf('<') === -1) {
  32996. return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
  32997. }
  32998. /* Initialize the document to work on */
  32999. body = _initDocument(dirty);
  33000. /* Check we have a DOM node from the data */
  33001. if (!body) {
  33002. return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
  33003. }
  33004. }
  33005. /* Remove first element node (ours) if FORCE_BODY is set */
  33006. if (body && FORCE_BODY) {
  33007. _forceRemove(body.firstChild);
  33008. }
  33009. /* Get node iterator */
  33010. var nodeIterator = _createIterator(IN_PLACE ? dirty : body);
  33011. /* Now start iterating over the created document */
  33012. while (currentNode = nodeIterator.nextNode()) {
  33013. /* Fix IE's strange behavior with manipulated textNodes #89 */
  33014. if (currentNode.nodeType === 3 && currentNode === oldNode) {
  33015. continue;
  33016. }
  33017. /* Sanitize tags and elements */
  33018. if (_sanitizeElements(currentNode)) {
  33019. continue;
  33020. }
  33021. /* Shadow DOM detected, sanitize it */
  33022. if (currentNode.content instanceof DocumentFragment) {
  33023. _sanitizeShadowDOM(currentNode.content);
  33024. }
  33025. /* Check attributes, sanitize if necessary */
  33026. _sanitizeAttributes(currentNode);
  33027. oldNode = currentNode;
  33028. }
  33029. oldNode = null;
  33030. /* If we sanitized `dirty` in-place, return it. */
  33031. if (IN_PLACE) {
  33032. return dirty;
  33033. }
  33034. /* Return sanitized string or DOM */
  33035. if (RETURN_DOM) {
  33036. if (RETURN_DOM_FRAGMENT) {
  33037. returnNode = createDocumentFragment.call(body.ownerDocument);
  33038. while (body.firstChild) {
  33039. // eslint-disable-next-line unicorn/prefer-dom-node-append
  33040. returnNode.appendChild(body.firstChild);
  33041. }
  33042. } else {
  33043. returnNode = body;
  33044. }
  33045. if (ALLOWED_ATTR.shadowroot) {
  33046. /*
  33047. AdoptNode() is not used because internal state is not reset
  33048. (e.g. the past names map of a HTMLFormElement), this is safe
  33049. in theory but we would rather not risk another attack vector.
  33050. The state that is cloned by importNode() is explicitly defined
  33051. by the specs.
  33052. */
  33053. returnNode = importNode.call(originalDocument, returnNode, true);
  33054. }
  33055. return returnNode;
  33056. }
  33057. var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
  33058. /* Serialize doctype if allowed */
  33059. if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
  33060. serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
  33061. }
  33062. /* Sanitize final string template-safe */
  33063. if (SAFE_FOR_TEMPLATES) {
  33064. serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$1, ' ');
  33065. serializedHTML = stringReplace(serializedHTML, ERB_EXPR$1, ' ');
  33066. }
  33067. return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
  33068. };
  33069. /**
  33070. * Public method to set the configuration once
  33071. * setConfig
  33072. *
  33073. * @param {Object} cfg configuration object
  33074. */
  33075. DOMPurify.setConfig = function (cfg) {
  33076. _parseConfig(cfg);
  33077. SET_CONFIG = true;
  33078. };
  33079. /**
  33080. * Public method to remove the configuration
  33081. * clearConfig
  33082. *
  33083. */
  33084. DOMPurify.clearConfig = function () {
  33085. CONFIG = null;
  33086. SET_CONFIG = false;
  33087. };
  33088. /**
  33089. * Public method to check if an attribute value is valid.
  33090. * Uses last set config, if any. Otherwise, uses config defaults.
  33091. * isValidAttribute
  33092. *
  33093. * @param {string} tag Tag name of containing element.
  33094. * @param {string} attr Attribute name.
  33095. * @param {string} value Attribute value.
  33096. * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
  33097. */
  33098. DOMPurify.isValidAttribute = function (tag, attr, value) {
  33099. /* Initialize shared config vars if necessary. */
  33100. if (!CONFIG) {
  33101. _parseConfig({});
  33102. }
  33103. var lcTag = transformCaseFunc(tag);
  33104. var lcName = transformCaseFunc(attr);
  33105. return _isValidAttribute(lcTag, lcName, value);
  33106. };
  33107. /**
  33108. * AddHook
  33109. * Public method to add DOMPurify hooks
  33110. *
  33111. * @param {String} entryPoint entry point for the hook to add
  33112. * @param {Function} hookFunction function to execute
  33113. */
  33114. DOMPurify.addHook = function (entryPoint, hookFunction) {
  33115. if (typeof hookFunction !== 'function') {
  33116. return;
  33117. }
  33118. hooks[entryPoint] = hooks[entryPoint] || [];
  33119. arrayPush(hooks[entryPoint], hookFunction);
  33120. };
  33121. /**
  33122. * RemoveHook
  33123. * Public method to remove a DOMPurify hook at a given entryPoint
  33124. * (pops it from the stack of hooks if more are present)
  33125. *
  33126. * @param {String} entryPoint entry point for the hook to remove
  33127. * @return {Function} removed(popped) hook
  33128. */
  33129. DOMPurify.removeHook = function (entryPoint) {
  33130. if (hooks[entryPoint]) {
  33131. return arrayPop(hooks[entryPoint]);
  33132. }
  33133. };
  33134. /**
  33135. * RemoveHooks
  33136. * Public method to remove all DOMPurify hooks at a given entryPoint
  33137. *
  33138. * @param {String} entryPoint entry point for the hooks to remove
  33139. */
  33140. DOMPurify.removeHooks = function (entryPoint) {
  33141. if (hooks[entryPoint]) {
  33142. hooks[entryPoint] = [];
  33143. }
  33144. };
  33145. /**
  33146. * RemoveAllHooks
  33147. * Public method to remove all DOMPurify hooks
  33148. *
  33149. */
  33150. DOMPurify.removeAllHooks = function () {
  33151. hooks = {};
  33152. };
  33153. return DOMPurify;
  33154. }
  33155. var purify = createDOMPurify();
  33156. return purify;
  33157. }));
  33158. });
  33159. var sanitizer = purify(window);
  33160. function _createSuper$r(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$r(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  33161. function _isNativeReflectConstruct$r() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  33162. var HtmlBlock = /*#__PURE__*/function (_ParagraphBase) {
  33163. _inherits(HtmlBlock, _ParagraphBase);
  33164. var _super = _createSuper$r(HtmlBlock);
  33165. function HtmlBlock() {
  33166. _classCallCheck(this, HtmlBlock);
  33167. return _super.call(this, {
  33168. needCache: true
  33169. });
  33170. } // ref: http://www.vfmd.org/vfmd-spec/specification/#procedure-for-detecting-automatic-links
  33171. _createClass(HtmlBlock, [{
  33172. key: "isAutoLinkTag",
  33173. value: function isAutoLinkTag(tagMatch) {
  33174. var REGEX_GROUP = [/^<([a-z][a-z0-9+.-]{1,31}:\/\/[^<> `]+)>$/i, /^<(mailto:[^<> `]+)>$/i, /^<([^()<>[\]:'@\\,"\s`]+@[^()<>[\]:'@\\,"\s`.]+\.[^()<>[\]:'@\\,"\s`]+)>$/i];
  33175. return some$3(REGEX_GROUP).call(REGEX_GROUP, function (regex) {
  33176. return regex.test(tagMatch);
  33177. });
  33178. }
  33179. }, {
  33180. key: "isHtmlComment",
  33181. value: function isHtmlComment(match) {
  33182. var htmlComment = /^<!--.*?-->$/;
  33183. return htmlComment.test(match);
  33184. }
  33185. }, {
  33186. key: "beforeMakeHtml",
  33187. value: function beforeMakeHtml(str, sentenceMakeFunc) {
  33188. var _this = this;
  33189. if (this.$engine.htmlWhiteListAppend) {
  33190. /**
  33191. * @property
  33192. * @type {false | RegExp}
  33193. */
  33194. this.htmlWhiteListAppend = new RegExp("^(".concat(this.$engine.htmlWhiteListAppend, ")( |$|/)"), 'i');
  33195. /**
  33196. * @property
  33197. * @type {string[]}
  33198. */
  33199. this.htmlWhiteList = this.$engine.htmlWhiteListAppend.split('|');
  33200. } else {
  33201. this.htmlWhiteListAppend = false;
  33202. this.htmlWhiteList = [];
  33203. }
  33204. var $str = str;
  33205. $str = convertHTMLNumberToName($str);
  33206. $str = escapeHTMLEntitiesWithoutSemicolon($str);
  33207. $str = $str.replace(/<[/]?(.*?)>/g, function (whole, m1) {
  33208. // 匹配到非白名单且非AutoLink语法的尖括号会被转义
  33209. // 如果是HTML注释,放行
  33210. if (!whiteList.test(m1) && !_this.isAutoLinkTag(whole) && !_this.isHtmlComment(whole)) {
  33211. if (_this.htmlWhiteListAppend === false || !_this.htmlWhiteListAppend.test(m1)) {
  33212. return whole.replace(/</g, '&#60;').replace(/>/g, '&#62;');
  33213. }
  33214. } // 到达此分支的包含被尖括号包裹的AutoLink语法以及在白名单内的HTML标签
  33215. // 没有被AutoLink解析并渲染的标签会被DOMPurify过滤掉,正常情况下不会出现遗漏
  33216. // 临时替换完整的HTML标签首尾为$#60;和$#62;,供下一步剔除损坏的HTML标签
  33217. return whole.replace(/</g, '$#60;').replace(/>/g, '$#62;');
  33218. }); // 替换所有形如「<abcd」和「</abcd」的左尖括号
  33219. $str = $str.replace(/<(?=\/?(\w|\n|$))/g, '&#60;'); // 还原被替换的尖括号
  33220. $str = $str.replace(/\$#60;/g, '<').replace(/\$#62;/g, '>');
  33221. return $str;
  33222. } // beforeMakeHtml(str) {
  33223. // return str;
  33224. // }
  33225. }, {
  33226. key: "makeHtml",
  33227. value: function makeHtml(str, sentenceMakeFunc) {
  33228. return str;
  33229. }
  33230. }, {
  33231. key: "afterMakeHtml",
  33232. value: function afterMakeHtml(str) {
  33233. var $str = str;
  33234. var config = {
  33235. ALLOW_UNKNOWN_PROTOCOLS: true,
  33236. ADD_ATTR: ['target']
  33237. };
  33238. if (this.htmlWhiteListAppend !== false) {
  33239. config.ADD_TAGS = this.htmlWhiteList;
  33240. if (this.htmlWhiteListAppend.test('style') || this.htmlWhiteListAppend.test('ALL')) {
  33241. $str = $str.replace(/<style(>| [^>]*>).*?<\/style>/gi, function (match) {
  33242. return match.replace(/<br>/gi, '');
  33243. });
  33244. }
  33245. if (this.htmlWhiteListAppend.test('iframe') || this.htmlWhiteListAppend.test('ALL')) {
  33246. var _context;
  33247. config.ADD_ATTR = concat$5(_context = config.ADD_ATTR).call(_context, ['align', 'frameborder', 'height', 'longdesc', 'marginheight', 'marginwidth', 'name', 'sandbox', 'scrolling', 'seamless', 'src', 'srcdoc', 'width']);
  33248. config.SANITIZE_DOM = false;
  33249. $str = $str.replace(/<iframe(>| [^>]*>).*?<\/iframe>/gi, function (match) {
  33250. return match.replace(/<br>/gi, '').replace(/\n/g, '');
  33251. });
  33252. }
  33253. if (this.htmlWhiteListAppend.test('script') || this.htmlWhiteListAppend.test('ALL')) {
  33254. // 如果允许script或者输入了ALL,则不做任何过滤了
  33255. $str = $str.replace(/<script(>| [^>]*>).*?<\/script>/gi, function (match) {
  33256. return match.replace(/<br>/gi, '');
  33257. });
  33258. return $str;
  33259. }
  33260. } // node 环境下不输出sign和lines
  33261. if (!isBrowser()) {
  33262. config.FORBID_ATTR = ['data-sign', 'data-lines'];
  33263. }
  33264. return sanitizer.sanitize($str, config);
  33265. }
  33266. }]);
  33267. return HtmlBlock;
  33268. }(ParagraphBase);
  33269. _defineProperty(HtmlBlock, "HOOK_NAME", 'htmlBlock');
  33270. /**
  33271. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  33272. *
  33273. * Licensed under the Apache License, Version 2.0 (the "License");
  33274. * you may not use this file except in compliance with the License.
  33275. * You may obtain a copy of the License at
  33276. *
  33277. * http://www.apache.org/licenses/LICENSE-2.0
  33278. *
  33279. * Unless required by applicable law or agreed to in writing, software
  33280. * distributed under the License is distributed on an "AS IS" BASIS,
  33281. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  33282. * See the License for the specific language governing permissions and
  33283. * limitations under the License.
  33284. */
  33285. var gfmUnicode = {
  33286. defaultURL: 'https://github.githubassets.com/images/icons/emoji/unicode/${code}.png?v8',
  33287. emojis: {
  33288. '+1': '1f44d',
  33289. '-1': '1f44e',
  33290. 100: '1f4af',
  33291. 1234: '1f522',
  33292. '1st_place_medal': '1f947',
  33293. '2nd_place_medal': '1f948',
  33294. '3rd_place_medal': '1f949',
  33295. '8ball': '1f3b1',
  33296. a: '1f170',
  33297. ab: '1f18e',
  33298. abacus: '1f9ee',
  33299. abc: '1f524',
  33300. abcd: '1f521',
  33301. accept: '1f251',
  33302. adhesive_bandage: '1fa79',
  33303. adult: '1f9d1',
  33304. aerial_tramway: '1f6a1',
  33305. afghanistan: '1f1e6-1f1eb',
  33306. airplane: '2708',
  33307. aland_islands: '1f1e6-1f1fd',
  33308. alarm_clock: '23f0',
  33309. albania: '1f1e6-1f1f1',
  33310. alembic: '2697',
  33311. algeria: '1f1e9-1f1ff',
  33312. alien: '1f47d',
  33313. ambulance: '1f691',
  33314. american_samoa: '1f1e6-1f1f8',
  33315. amphora: '1f3fa',
  33316. anchor: '2693',
  33317. andorra: '1f1e6-1f1e9',
  33318. angel: '1f47c',
  33319. anger: '1f4a2',
  33320. angola: '1f1e6-1f1f4',
  33321. angry: '1f620',
  33322. anguilla: '1f1e6-1f1ee',
  33323. anguished: '1f627',
  33324. ant: '1f41c',
  33325. antarctica: '1f1e6-1f1f6',
  33326. antigua_barbuda: '1f1e6-1f1ec',
  33327. apple: '1f34e',
  33328. aquarius: '2652',
  33329. argentina: '1f1e6-1f1f7',
  33330. aries: '2648',
  33331. armenia: '1f1e6-1f1f2',
  33332. arrow_backward: '25c0',
  33333. arrow_double_down: '23ec',
  33334. arrow_double_up: '23eb',
  33335. arrow_down: '2b07',
  33336. arrow_down_small: '1f53d',
  33337. arrow_forward: '25b6',
  33338. arrow_heading_down: '2935',
  33339. arrow_heading_up: '2934',
  33340. arrow_left: '2b05',
  33341. arrow_lower_left: '2199',
  33342. arrow_lower_right: '2198',
  33343. arrow_right: '27a1',
  33344. arrow_right_hook: '21aa',
  33345. arrow_up: '2b06',
  33346. arrow_up_down: '2195',
  33347. arrow_up_small: '1f53c',
  33348. arrow_upper_left: '2196',
  33349. arrow_upper_right: '2197',
  33350. arrows_clockwise: '1f503',
  33351. arrows_counterclockwise: '1f504',
  33352. art: '1f3a8',
  33353. articulated_lorry: '1f69b',
  33354. artificial_satellite: '1f6f0',
  33355. artist: '1f9d1-1f3a8',
  33356. aruba: '1f1e6-1f1fc',
  33357. ascension_island: '1f1e6-1f1e8',
  33358. asterisk: '002a-20e3',
  33359. astonished: '1f632',
  33360. astronaut: '1f9d1-1f680',
  33361. athletic_shoe: '1f45f',
  33362. atm: '1f3e7',
  33363. atom_symbol: '269b',
  33364. australia: '1f1e6-1f1fa',
  33365. austria: '1f1e6-1f1f9',
  33366. auto_rickshaw: '1f6fa',
  33367. avocado: '1f951',
  33368. axe: '1fa93',
  33369. azerbaijan: '1f1e6-1f1ff',
  33370. b: '1f171',
  33371. baby: '1f476',
  33372. baby_bottle: '1f37c',
  33373. baby_chick: '1f424',
  33374. baby_symbol: '1f6bc',
  33375. back: '1f519',
  33376. bacon: '1f953',
  33377. badger: '1f9a1',
  33378. badminton: '1f3f8',
  33379. bagel: '1f96f',
  33380. baggage_claim: '1f6c4',
  33381. baguette_bread: '1f956',
  33382. bahamas: '1f1e7-1f1f8',
  33383. bahrain: '1f1e7-1f1ed',
  33384. balance_scale: '2696',
  33385. bald_man: '1f468-1f9b2',
  33386. bald_woman: '1f469-1f9b2',
  33387. ballet_shoes: '1fa70',
  33388. balloon: '1f388',
  33389. ballot_box: '1f5f3',
  33390. ballot_box_with_check: '2611',
  33391. bamboo: '1f38d',
  33392. banana: '1f34c',
  33393. bangbang: '203c',
  33394. bangladesh: '1f1e7-1f1e9',
  33395. banjo: '1fa95',
  33396. bank: '1f3e6',
  33397. bar_chart: '1f4ca',
  33398. barbados: '1f1e7-1f1e7',
  33399. barber: '1f488',
  33400. baseball: '26be',
  33401. basket: '1f9fa',
  33402. basketball: '1f3c0',
  33403. basketball_man: '26f9-2642',
  33404. basketball_woman: '26f9-2640',
  33405. bat: '1f987',
  33406. bath: '1f6c0',
  33407. bathtub: '1f6c1',
  33408. battery: '1f50b',
  33409. beach_umbrella: '1f3d6',
  33410. bear: '1f43b',
  33411. bearded_person: '1f9d4',
  33412. bed: '1f6cf',
  33413. bee: '1f41d',
  33414. beer: '1f37a',
  33415. beers: '1f37b',
  33416. beetle: '1f41e',
  33417. beginner: '1f530',
  33418. belarus: '1f1e7-1f1fe',
  33419. belgium: '1f1e7-1f1ea',
  33420. belize: '1f1e7-1f1ff',
  33421. bell: '1f514',
  33422. bellhop_bell: '1f6ce',
  33423. benin: '1f1e7-1f1ef',
  33424. bento: '1f371',
  33425. bermuda: '1f1e7-1f1f2',
  33426. beverage_box: '1f9c3',
  33427. bhutan: '1f1e7-1f1f9',
  33428. bicyclist: '1f6b4',
  33429. bike: '1f6b2',
  33430. biking_man: '1f6b4-2642',
  33431. biking_woman: '1f6b4-2640',
  33432. bikini: '1f459',
  33433. billed_cap: '1f9e2',
  33434. biohazard: '2623',
  33435. bird: '1f426',
  33436. birthday: '1f382',
  33437. black_circle: '26ab',
  33438. black_flag: '1f3f4',
  33439. black_heart: '1f5a4',
  33440. black_joker: '1f0cf',
  33441. black_large_square: '2b1b',
  33442. black_medium_small_square: '25fe',
  33443. black_medium_square: '25fc',
  33444. black_nib: '2712',
  33445. black_small_square: '25aa',
  33446. black_square_button: '1f532',
  33447. blond_haired_man: '1f471-2642',
  33448. blond_haired_person: '1f471',
  33449. blond_haired_woman: '1f471-2640',
  33450. blonde_woman: '1f471-2640',
  33451. blossom: '1f33c',
  33452. blowfish: '1f421',
  33453. blue_book: '1f4d8',
  33454. blue_car: '1f699',
  33455. blue_heart: '1f499',
  33456. blue_square: '1f7e6',
  33457. blush: '1f60a',
  33458. boar: '1f417',
  33459. boat: '26f5',
  33460. bolivia: '1f1e7-1f1f4',
  33461. bomb: '1f4a3',
  33462. bone: '1f9b4',
  33463. book: '1f4d6',
  33464. bookmark: '1f516',
  33465. bookmark_tabs: '1f4d1',
  33466. books: '1f4da',
  33467. boom: '1f4a5',
  33468. boot: '1f462',
  33469. bosnia_herzegovina: '1f1e7-1f1e6',
  33470. botswana: '1f1e7-1f1fc',
  33471. bouncing_ball_man: '26f9-2642',
  33472. bouncing_ball_person: '26f9',
  33473. bouncing_ball_woman: '26f9-2640',
  33474. bouquet: '1f490',
  33475. bouvet_island: '1f1e7-1f1fb',
  33476. bow: '1f647',
  33477. bow_and_arrow: '1f3f9',
  33478. bowing_man: '1f647-2642',
  33479. bowing_woman: '1f647-2640',
  33480. bowl_with_spoon: '1f963',
  33481. bowling: '1f3b3',
  33482. boxing_glove: '1f94a',
  33483. boy: '1f466',
  33484. brain: '1f9e0',
  33485. brazil: '1f1e7-1f1f7',
  33486. bread: '1f35e',
  33487. breast_feeding: '1f931',
  33488. bricks: '1f9f1',
  33489. bride_with_veil: '1f470',
  33490. bridge_at_night: '1f309',
  33491. briefcase: '1f4bc',
  33492. british_indian_ocean_territory: '1f1ee-1f1f4',
  33493. british_virgin_islands: '1f1fb-1f1ec',
  33494. broccoli: '1f966',
  33495. broken_heart: '1f494',
  33496. broom: '1f9f9',
  33497. brown_circle: '1f7e4',
  33498. brown_heart: '1f90e',
  33499. brown_square: '1f7eb',
  33500. brunei: '1f1e7-1f1f3',
  33501. bug: '1f41b',
  33502. building_construction: '1f3d7',
  33503. bulb: '1f4a1',
  33504. bulgaria: '1f1e7-1f1ec',
  33505. bullettrain_front: '1f685',
  33506. bullettrain_side: '1f684',
  33507. burkina_faso: '1f1e7-1f1eb',
  33508. burrito: '1f32f',
  33509. burundi: '1f1e7-1f1ee',
  33510. bus: '1f68c',
  33511. business_suit_levitating: '1f574',
  33512. busstop: '1f68f',
  33513. bust_in_silhouette: '1f464',
  33514. busts_in_silhouette: '1f465',
  33515. butter: '1f9c8',
  33516. butterfly: '1f98b',
  33517. cactus: '1f335',
  33518. cake: '1f370',
  33519. calendar: '1f4c6',
  33520. call_me_hand: '1f919',
  33521. calling: '1f4f2',
  33522. cambodia: '1f1f0-1f1ed',
  33523. camel: '1f42b',
  33524. camera: '1f4f7',
  33525. camera_flash: '1f4f8',
  33526. cameroon: '1f1e8-1f1f2',
  33527. camping: '1f3d5',
  33528. canada: '1f1e8-1f1e6',
  33529. canary_islands: '1f1ee-1f1e8',
  33530. cancer: '264b',
  33531. candle: '1f56f',
  33532. candy: '1f36c',
  33533. canned_food: '1f96b',
  33534. canoe: '1f6f6',
  33535. cape_verde: '1f1e8-1f1fb',
  33536. capital_abcd: '1f520',
  33537. capricorn: '2651',
  33538. car: '1f697',
  33539. card_file_box: '1f5c3',
  33540. card_index: '1f4c7',
  33541. card_index_dividers: '1f5c2',
  33542. caribbean_netherlands: '1f1e7-1f1f6',
  33543. carousel_horse: '1f3a0',
  33544. carrot: '1f955',
  33545. cartwheeling: '1f938',
  33546. cat: '1f431',
  33547. cat2: '1f408',
  33548. cayman_islands: '1f1f0-1f1fe',
  33549. cd: '1f4bf',
  33550. central_african_republic: '1f1e8-1f1eb',
  33551. ceuta_melilla: '1f1ea-1f1e6',
  33552. chad: '1f1f9-1f1e9',
  33553. chains: '26d3',
  33554. chair: '1fa91',
  33555. champagne: '1f37e',
  33556. chart: '1f4b9',
  33557. chart_with_downwards_trend: '1f4c9',
  33558. chart_with_upwards_trend: '1f4c8',
  33559. checkered_flag: '1f3c1',
  33560. cheese: '1f9c0',
  33561. cherries: '1f352',
  33562. cherry_blossom: '1f338',
  33563. chess_pawn: '265f',
  33564. chestnut: '1f330',
  33565. chicken: '1f414',
  33566. child: '1f9d2',
  33567. children_crossing: '1f6b8',
  33568. chile: '1f1e8-1f1f1',
  33569. chipmunk: '1f43f',
  33570. chocolate_bar: '1f36b',
  33571. chopsticks: '1f962',
  33572. christmas_island: '1f1e8-1f1fd',
  33573. christmas_tree: '1f384',
  33574. church: '26ea',
  33575. cinema: '1f3a6',
  33576. circus_tent: '1f3aa',
  33577. city_sunrise: '1f307',
  33578. city_sunset: '1f306',
  33579. cityscape: '1f3d9',
  33580. cl: '1f191',
  33581. clamp: '1f5dc',
  33582. clap: '1f44f',
  33583. clapper: '1f3ac',
  33584. classical_building: '1f3db',
  33585. climbing: '1f9d7',
  33586. climbing_man: '1f9d7-2642',
  33587. climbing_woman: '1f9d7-2640',
  33588. clinking_glasses: '1f942',
  33589. clipboard: '1f4cb',
  33590. clipperton_island: '1f1e8-1f1f5',
  33591. clock1: '1f550',
  33592. clock10: '1f559',
  33593. clock1030: '1f565',
  33594. clock11: '1f55a',
  33595. clock1130: '1f566',
  33596. clock12: '1f55b',
  33597. clock1230: '1f567',
  33598. clock130: '1f55c',
  33599. clock2: '1f551',
  33600. clock230: '1f55d',
  33601. clock3: '1f552',
  33602. clock330: '1f55e',
  33603. clock4: '1f553',
  33604. clock430: '1f55f',
  33605. clock5: '1f554',
  33606. clock530: '1f560',
  33607. clock6: '1f555',
  33608. clock630: '1f561',
  33609. clock7: '1f556',
  33610. clock730: '1f562',
  33611. clock8: '1f557',
  33612. clock830: '1f563',
  33613. clock9: '1f558',
  33614. clock930: '1f564',
  33615. closed_book: '1f4d5',
  33616. closed_lock_with_key: '1f510',
  33617. closed_umbrella: '1f302',
  33618. cloud: '2601',
  33619. cloud_with_lightning: '1f329',
  33620. cloud_with_lightning_and_rain: '26c8',
  33621. cloud_with_rain: '1f327',
  33622. cloud_with_snow: '1f328',
  33623. clown_face: '1f921',
  33624. clubs: '2663',
  33625. cn: '1f1e8-1f1f3',
  33626. coat: '1f9e5',
  33627. cocktail: '1f378',
  33628. coconut: '1f965',
  33629. cocos_islands: '1f1e8-1f1e8',
  33630. coffee: '2615',
  33631. coffin: '26b0',
  33632. cold_face: '1f976',
  33633. cold_sweat: '1f630',
  33634. collision: '1f4a5',
  33635. colombia: '1f1e8-1f1f4',
  33636. comet: '2604',
  33637. comoros: '1f1f0-1f1f2',
  33638. compass: '1f9ed',
  33639. computer: '1f4bb',
  33640. computer_mouse: '1f5b1',
  33641. confetti_ball: '1f38a',
  33642. confounded: '1f616',
  33643. confused: '1f615',
  33644. congo_brazzaville: '1f1e8-1f1ec',
  33645. congo_kinshasa: '1f1e8-1f1e9',
  33646. congratulations: '3297',
  33647. construction: '1f6a7',
  33648. construction_worker: '1f477',
  33649. construction_worker_man: '1f477-2642',
  33650. construction_worker_woman: '1f477-2640',
  33651. control_knobs: '1f39b',
  33652. convenience_store: '1f3ea',
  33653. cook: '1f9d1-1f373',
  33654. cook_islands: '1f1e8-1f1f0',
  33655. cookie: '1f36a',
  33656. cool: '1f192',
  33657. cop: '1f46e',
  33658. copyright: '00a9',
  33659. corn: '1f33d',
  33660. costa_rica: '1f1e8-1f1f7',
  33661. cote_divoire: '1f1e8-1f1ee',
  33662. couch_and_lamp: '1f6cb',
  33663. couple: '1f46b',
  33664. couple_with_heart: '1f491',
  33665. couple_with_heart_man_man: '1f468-2764-1f468',
  33666. couple_with_heart_woman_man: '1f469-2764-1f468',
  33667. couple_with_heart_woman_woman: '1f469-2764-1f469',
  33668. couplekiss: '1f48f',
  33669. couplekiss_man_man: '1f468-2764-1f48b-1f468',
  33670. couplekiss_man_woman: '1f469-2764-1f48b-1f468',
  33671. couplekiss_woman_woman: '1f469-2764-1f48b-1f469',
  33672. cow: '1f42e',
  33673. cow2: '1f404',
  33674. cowboy_hat_face: '1f920',
  33675. crab: '1f980',
  33676. crayon: '1f58d',
  33677. credit_card: '1f4b3',
  33678. crescent_moon: '1f319',
  33679. cricket: '1f997',
  33680. cricket_game: '1f3cf',
  33681. croatia: '1f1ed-1f1f7',
  33682. crocodile: '1f40a',
  33683. croissant: '1f950',
  33684. crossed_fingers: '1f91e',
  33685. crossed_flags: '1f38c',
  33686. crossed_swords: '2694',
  33687. crown: '1f451',
  33688. cry: '1f622',
  33689. crying_cat_face: '1f63f',
  33690. crystal_ball: '1f52e',
  33691. cuba: '1f1e8-1f1fa',
  33692. cucumber: '1f952',
  33693. cup_with_straw: '1f964',
  33694. cupcake: '1f9c1',
  33695. cupid: '1f498',
  33696. curacao: '1f1e8-1f1fc',
  33697. curling_stone: '1f94c',
  33698. curly_haired_man: '1f468-1f9b1',
  33699. curly_haired_woman: '1f469-1f9b1',
  33700. curly_loop: '27b0',
  33701. currency_exchange: '1f4b1',
  33702. curry: '1f35b',
  33703. cursing_face: '1f92c',
  33704. custard: '1f36e',
  33705. customs: '1f6c3',
  33706. cut_of_meat: '1f969',
  33707. cyclone: '1f300',
  33708. cyprus: '1f1e8-1f1fe',
  33709. czech_republic: '1f1e8-1f1ff',
  33710. dagger: '1f5e1',
  33711. dancer: '1f483',
  33712. dancers: '1f46f',
  33713. dancing_men: '1f46f-2642',
  33714. dancing_women: '1f46f-2640',
  33715. dango: '1f361',
  33716. dark_sunglasses: '1f576',
  33717. dart: '1f3af',
  33718. dash: '1f4a8',
  33719. date: '1f4c5',
  33720. de: '1f1e9-1f1ea',
  33721. deaf_man: '1f9cf-2642',
  33722. deaf_person: '1f9cf',
  33723. deaf_woman: '1f9cf-2640',
  33724. deciduous_tree: '1f333',
  33725. deer: '1f98c',
  33726. denmark: '1f1e9-1f1f0',
  33727. department_store: '1f3ec',
  33728. derelict_house: '1f3da',
  33729. desert: '1f3dc',
  33730. desert_island: '1f3dd',
  33731. desktop_computer: '1f5a5',
  33732. detective: '1f575',
  33733. diamond_shape_with_a_dot_inside: '1f4a0',
  33734. diamonds: '2666',
  33735. diego_garcia: '1f1e9-1f1ec',
  33736. disappointed: '1f61e',
  33737. disappointed_relieved: '1f625',
  33738. diving_mask: '1f93f',
  33739. diya_lamp: '1fa94',
  33740. dizzy: '1f4ab',
  33741. dizzy_face: '1f635',
  33742. djibouti: '1f1e9-1f1ef',
  33743. dna: '1f9ec',
  33744. do_not_litter: '1f6af',
  33745. dog: '1f436',
  33746. dog2: '1f415',
  33747. dollar: '1f4b5',
  33748. dolls: '1f38e',
  33749. dolphin: '1f42c',
  33750. dominica: '1f1e9-1f1f2',
  33751. dominican_republic: '1f1e9-1f1f4',
  33752. door: '1f6aa',
  33753. doughnut: '1f369',
  33754. dove: '1f54a',
  33755. dragon: '1f409',
  33756. dragon_face: '1f432',
  33757. dress: '1f457',
  33758. dromedary_camel: '1f42a',
  33759. drooling_face: '1f924',
  33760. drop_of_blood: '1fa78',
  33761. droplet: '1f4a7',
  33762. drum: '1f941',
  33763. duck: '1f986',
  33764. dumpling: '1f95f',
  33765. dvd: '1f4c0',
  33766. 'e-mail': '1f4e7',
  33767. eagle: '1f985',
  33768. ear: '1f442',
  33769. ear_of_rice: '1f33e',
  33770. ear_with_hearing_aid: '1f9bb',
  33771. earth_africa: '1f30d',
  33772. earth_americas: '1f30e',
  33773. earth_asia: '1f30f',
  33774. ecuador: '1f1ea-1f1e8',
  33775. egg: '1f95a',
  33776. eggplant: '1f346',
  33777. egypt: '1f1ea-1f1ec',
  33778. eight: '0038-20e3',
  33779. eight_pointed_black_star: '2734',
  33780. eight_spoked_asterisk: '2733',
  33781. eject_button: '23cf',
  33782. el_salvador: '1f1f8-1f1fb',
  33783. electric_plug: '1f50c',
  33784. elephant: '1f418',
  33785. elf: '1f9dd',
  33786. elf_man: '1f9dd-2642',
  33787. elf_woman: '1f9dd-2640',
  33788. email: '2709',
  33789. end: '1f51a',
  33790. england: '1f3f4-e0067-e0062-e0065-e006e-e0067-e007f',
  33791. envelope: '2709',
  33792. envelope_with_arrow: '1f4e9',
  33793. equatorial_guinea: '1f1ec-1f1f6',
  33794. eritrea: '1f1ea-1f1f7',
  33795. es: '1f1ea-1f1f8',
  33796. estonia: '1f1ea-1f1ea',
  33797. ethiopia: '1f1ea-1f1f9',
  33798. eu: '1f1ea-1f1fa',
  33799. euro: '1f4b6',
  33800. european_castle: '1f3f0',
  33801. european_post_office: '1f3e4',
  33802. european_union: '1f1ea-1f1fa',
  33803. evergreen_tree: '1f332',
  33804. exclamation: '2757',
  33805. exploding_head: '1f92f',
  33806. expressionless: '1f611',
  33807. eye: '1f441',
  33808. eye_speech_bubble: '1f441-1f5e8',
  33809. eyeglasses: '1f453',
  33810. eyes: '1f440',
  33811. face_with_head_bandage: '1f915',
  33812. face_with_thermometer: '1f912',
  33813. facepalm: '1f926',
  33814. facepunch: '1f44a',
  33815. factory: '1f3ed',
  33816. factory_worker: '1f9d1-1f3ed',
  33817. fairy: '1f9da',
  33818. fairy_man: '1f9da-2642',
  33819. fairy_woman: '1f9da-2640',
  33820. falafel: '1f9c6',
  33821. falkland_islands: '1f1eb-1f1f0',
  33822. fallen_leaf: '1f342',
  33823. family: '1f46a',
  33824. family_man_boy: '1f468-1f466',
  33825. family_man_boy_boy: '1f468-1f466-1f466',
  33826. family_man_girl: '1f468-1f467',
  33827. family_man_girl_boy: '1f468-1f467-1f466',
  33828. family_man_girl_girl: '1f468-1f467-1f467',
  33829. family_man_man_boy: '1f468-1f468-1f466',
  33830. family_man_man_boy_boy: '1f468-1f468-1f466-1f466',
  33831. family_man_man_girl: '1f468-1f468-1f467',
  33832. family_man_man_girl_boy: '1f468-1f468-1f467-1f466',
  33833. family_man_man_girl_girl: '1f468-1f468-1f467-1f467',
  33834. family_man_woman_boy: '1f468-1f469-1f466',
  33835. family_man_woman_boy_boy: '1f468-1f469-1f466-1f466',
  33836. family_man_woman_girl: '1f468-1f469-1f467',
  33837. family_man_woman_girl_boy: '1f468-1f469-1f467-1f466',
  33838. family_man_woman_girl_girl: '1f468-1f469-1f467-1f467',
  33839. family_woman_boy: '1f469-1f466',
  33840. family_woman_boy_boy: '1f469-1f466-1f466',
  33841. family_woman_girl: '1f469-1f467',
  33842. family_woman_girl_boy: '1f469-1f467-1f466',
  33843. family_woman_girl_girl: '1f469-1f467-1f467',
  33844. family_woman_woman_boy: '1f469-1f469-1f466',
  33845. family_woman_woman_boy_boy: '1f469-1f469-1f466-1f466',
  33846. family_woman_woman_girl: '1f469-1f469-1f467',
  33847. family_woman_woman_girl_boy: '1f469-1f469-1f467-1f466',
  33848. family_woman_woman_girl_girl: '1f469-1f469-1f467-1f467',
  33849. farmer: '1f9d1-1f33e',
  33850. faroe_islands: '1f1eb-1f1f4',
  33851. fast_forward: '23e9',
  33852. fax: '1f4e0',
  33853. fearful: '1f628',
  33854. feet: '1f43e',
  33855. female_detective: '1f575-2640',
  33856. female_sign: '2640',
  33857. ferris_wheel: '1f3a1',
  33858. ferry: '26f4',
  33859. field_hockey: '1f3d1',
  33860. fiji: '1f1eb-1f1ef',
  33861. file_cabinet: '1f5c4',
  33862. file_folder: '1f4c1',
  33863. film_projector: '1f4fd',
  33864. film_strip: '1f39e',
  33865. finland: '1f1eb-1f1ee',
  33866. fire: '1f525',
  33867. fire_engine: '1f692',
  33868. fire_extinguisher: '1f9ef',
  33869. firecracker: '1f9e8',
  33870. firefighter: '1f9d1-1f692',
  33871. fireworks: '1f386',
  33872. first_quarter_moon: '1f313',
  33873. first_quarter_moon_with_face: '1f31b',
  33874. fish: '1f41f',
  33875. fish_cake: '1f365',
  33876. fishing_pole_and_fish: '1f3a3',
  33877. fist: '270a',
  33878. fist_left: '1f91b',
  33879. fist_oncoming: '1f44a',
  33880. fist_raised: '270a',
  33881. fist_right: '1f91c',
  33882. five: '0035-20e3',
  33883. flags: '1f38f',
  33884. flamingo: '1f9a9',
  33885. flashlight: '1f526',
  33886. flat_shoe: '1f97f',
  33887. fleur_de_lis: '269c',
  33888. flight_arrival: '1f6ec',
  33889. flight_departure: '1f6eb',
  33890. flipper: '1f42c',
  33891. floppy_disk: '1f4be',
  33892. flower_playing_cards: '1f3b4',
  33893. flushed: '1f633',
  33894. flying_disc: '1f94f',
  33895. flying_saucer: '1f6f8',
  33896. fog: '1f32b',
  33897. foggy: '1f301',
  33898. foot: '1f9b6',
  33899. football: '1f3c8',
  33900. footprints: '1f463',
  33901. fork_and_knife: '1f374',
  33902. fortune_cookie: '1f960',
  33903. fountain: '26f2',
  33904. fountain_pen: '1f58b',
  33905. four: '0034-20e3',
  33906. four_leaf_clover: '1f340',
  33907. fox_face: '1f98a',
  33908. fr: '1f1eb-1f1f7',
  33909. framed_picture: '1f5bc',
  33910. free: '1f193',
  33911. french_guiana: '1f1ec-1f1eb',
  33912. french_polynesia: '1f1f5-1f1eb',
  33913. french_southern_territories: '1f1f9-1f1eb',
  33914. fried_egg: '1f373',
  33915. fried_shrimp: '1f364',
  33916. fries: '1f35f',
  33917. frog: '1f438',
  33918. frowning: '1f626',
  33919. frowning_face: '2639',
  33920. frowning_man: '1f64d-2642',
  33921. frowning_person: '1f64d',
  33922. frowning_woman: '1f64d-2640',
  33923. fu: '1f595',
  33924. fuelpump: '26fd',
  33925. full_moon: '1f315',
  33926. full_moon_with_face: '1f31d',
  33927. funeral_urn: '26b1',
  33928. gabon: '1f1ec-1f1e6',
  33929. gambia: '1f1ec-1f1f2',
  33930. game_die: '1f3b2',
  33931. garlic: '1f9c4',
  33932. gb: '1f1ec-1f1e7',
  33933. gear: '2699',
  33934. gem: '1f48e',
  33935. gemini: '264a',
  33936. genie: '1f9de',
  33937. genie_man: '1f9de-2642',
  33938. genie_woman: '1f9de-2640',
  33939. georgia: '1f1ec-1f1ea',
  33940. ghana: '1f1ec-1f1ed',
  33941. ghost: '1f47b',
  33942. gibraltar: '1f1ec-1f1ee',
  33943. gift: '1f381',
  33944. gift_heart: '1f49d',
  33945. giraffe: '1f992',
  33946. girl: '1f467',
  33947. globe_with_meridians: '1f310',
  33948. gloves: '1f9e4',
  33949. goal_net: '1f945',
  33950. goat: '1f410',
  33951. goggles: '1f97d',
  33952. golf: '26f3',
  33953. golfing: '1f3cc',
  33954. golfing_man: '1f3cc-2642',
  33955. golfing_woman: '1f3cc-2640',
  33956. gorilla: '1f98d',
  33957. grapes: '1f347',
  33958. greece: '1f1ec-1f1f7',
  33959. green_apple: '1f34f',
  33960. green_book: '1f4d7',
  33961. green_circle: '1f7e2',
  33962. green_heart: '1f49a',
  33963. green_salad: '1f957',
  33964. green_square: '1f7e9',
  33965. greenland: '1f1ec-1f1f1',
  33966. grenada: '1f1ec-1f1e9',
  33967. grey_exclamation: '2755',
  33968. grey_question: '2754',
  33969. grimacing: '1f62c',
  33970. grin: '1f601',
  33971. grinning: '1f600',
  33972. guadeloupe: '1f1ec-1f1f5',
  33973. guam: '1f1ec-1f1fa',
  33974. guard: '1f482',
  33975. guardsman: '1f482-2642',
  33976. guardswoman: '1f482-2640',
  33977. guatemala: '1f1ec-1f1f9',
  33978. guernsey: '1f1ec-1f1ec',
  33979. guide_dog: '1f9ae',
  33980. guinea: '1f1ec-1f1f3',
  33981. guinea_bissau: '1f1ec-1f1fc',
  33982. guitar: '1f3b8',
  33983. gun: '1f52b',
  33984. guyana: '1f1ec-1f1fe',
  33985. haircut: '1f487',
  33986. haircut_man: '1f487-2642',
  33987. haircut_woman: '1f487-2640',
  33988. haiti: '1f1ed-1f1f9',
  33989. hamburger: '1f354',
  33990. hammer: '1f528',
  33991. hammer_and_pick: '2692',
  33992. hammer_and_wrench: '1f6e0',
  33993. hamster: '1f439',
  33994. hand: '270b',
  33995. hand_over_mouth: '1f92d',
  33996. handbag: '1f45c',
  33997. handball_person: '1f93e',
  33998. handshake: '1f91d',
  33999. hankey: '1f4a9',
  34000. hash: '0023-20e3',
  34001. hatched_chick: '1f425',
  34002. hatching_chick: '1f423',
  34003. headphones: '1f3a7',
  34004. health_worker: '1f9d1-2695',
  34005. hear_no_evil: '1f649',
  34006. heard_mcdonald_islands: '1f1ed-1f1f2',
  34007. heart: '2764',
  34008. heart_decoration: '1f49f',
  34009. heart_eyes: '1f60d',
  34010. heart_eyes_cat: '1f63b',
  34011. heartbeat: '1f493',
  34012. heartpulse: '1f497',
  34013. hearts: '2665',
  34014. heavy_check_mark: '2714',
  34015. heavy_division_sign: '2797',
  34016. heavy_dollar_sign: '1f4b2',
  34017. heavy_exclamation_mark: '2757',
  34018. heavy_heart_exclamation: '2763',
  34019. heavy_minus_sign: '2796',
  34020. heavy_multiplication_x: '2716',
  34021. heavy_plus_sign: '2795',
  34022. hedgehog: '1f994',
  34023. helicopter: '1f681',
  34024. herb: '1f33f',
  34025. hibiscus: '1f33a',
  34026. high_brightness: '1f506',
  34027. high_heel: '1f460',
  34028. hiking_boot: '1f97e',
  34029. hindu_temple: '1f6d5',
  34030. hippopotamus: '1f99b',
  34031. hocho: '1f52a',
  34032. hole: '1f573',
  34033. honduras: '1f1ed-1f1f3',
  34034. honey_pot: '1f36f',
  34035. honeybee: '1f41d',
  34036. hong_kong: '1f1ed-1f1f0',
  34037. horse: '1f434',
  34038. horse_racing: '1f3c7',
  34039. hospital: '1f3e5',
  34040. hot_face: '1f975',
  34041. hot_pepper: '1f336',
  34042. hotdog: '1f32d',
  34043. hotel: '1f3e8',
  34044. hotsprings: '2668',
  34045. hourglass: '231b',
  34046. hourglass_flowing_sand: '23f3',
  34047. house: '1f3e0',
  34048. house_with_garden: '1f3e1',
  34049. houses: '1f3d8',
  34050. hugs: '1f917',
  34051. hungary: '1f1ed-1f1fa',
  34052. hushed: '1f62f',
  34053. ice_cream: '1f368',
  34054. ice_cube: '1f9ca',
  34055. ice_hockey: '1f3d2',
  34056. ice_skate: '26f8',
  34057. icecream: '1f366',
  34058. iceland: '1f1ee-1f1f8',
  34059. id: '1f194',
  34060. ideograph_advantage: '1f250',
  34061. imp: '1f47f',
  34062. inbox_tray: '1f4e5',
  34063. incoming_envelope: '1f4e8',
  34064. india: '1f1ee-1f1f3',
  34065. indonesia: '1f1ee-1f1e9',
  34066. infinity: '267e',
  34067. information_desk_person: '1f481',
  34068. information_source: '2139',
  34069. innocent: '1f607',
  34070. interrobang: '2049',
  34071. iphone: '1f4f1',
  34072. iran: '1f1ee-1f1f7',
  34073. iraq: '1f1ee-1f1f6',
  34074. ireland: '1f1ee-1f1ea',
  34075. isle_of_man: '1f1ee-1f1f2',
  34076. israel: '1f1ee-1f1f1',
  34077. it: '1f1ee-1f1f9',
  34078. izakaya_lantern: '1f3ee',
  34079. jack_o_lantern: '1f383',
  34080. jamaica: '1f1ef-1f1f2',
  34081. japan: '1f5fe',
  34082. japanese_castle: '1f3ef',
  34083. japanese_goblin: '1f47a',
  34084. japanese_ogre: '1f479',
  34085. jeans: '1f456',
  34086. jersey: '1f1ef-1f1ea',
  34087. jigsaw: '1f9e9',
  34088. jordan: '1f1ef-1f1f4',
  34089. joy: '1f602',
  34090. joy_cat: '1f639',
  34091. joystick: '1f579',
  34092. jp: '1f1ef-1f1f5',
  34093. judge: '1f9d1-2696',
  34094. juggling_person: '1f939',
  34095. kaaba: '1f54b',
  34096. kangaroo: '1f998',
  34097. kazakhstan: '1f1f0-1f1ff',
  34098. kenya: '1f1f0-1f1ea',
  34099. key: '1f511',
  34100. keyboard: '2328',
  34101. keycap_ten: '1f51f',
  34102. kick_scooter: '1f6f4',
  34103. kimono: '1f458',
  34104. kiribati: '1f1f0-1f1ee',
  34105. kiss: '1f48b',
  34106. kissing: '1f617',
  34107. kissing_cat: '1f63d',
  34108. kissing_closed_eyes: '1f61a',
  34109. kissing_heart: '1f618',
  34110. kissing_smiling_eyes: '1f619',
  34111. kite: '1fa81',
  34112. kiwi_fruit: '1f95d',
  34113. kneeling_man: '1f9ce-2642',
  34114. kneeling_person: '1f9ce',
  34115. kneeling_woman: '1f9ce-2640',
  34116. knife: '1f52a',
  34117. koala: '1f428',
  34118. koko: '1f201',
  34119. kosovo: '1f1fd-1f1f0',
  34120. kr: '1f1f0-1f1f7',
  34121. kuwait: '1f1f0-1f1fc',
  34122. kyrgyzstan: '1f1f0-1f1ec',
  34123. lab_coat: '1f97c',
  34124. label: '1f3f7',
  34125. lacrosse: '1f94d',
  34126. lantern: '1f3ee',
  34127. laos: '1f1f1-1f1e6',
  34128. large_blue_circle: '1f535',
  34129. large_blue_diamond: '1f537',
  34130. large_orange_diamond: '1f536',
  34131. last_quarter_moon: '1f317',
  34132. last_quarter_moon_with_face: '1f31c',
  34133. latin_cross: '271d',
  34134. latvia: '1f1f1-1f1fb',
  34135. laughing: '1f606',
  34136. leafy_green: '1f96c',
  34137. leaves: '1f343',
  34138. lebanon: '1f1f1-1f1e7',
  34139. ledger: '1f4d2',
  34140. left_luggage: '1f6c5',
  34141. left_right_arrow: '2194',
  34142. left_speech_bubble: '1f5e8',
  34143. leftwards_arrow_with_hook: '21a9',
  34144. leg: '1f9b5',
  34145. lemon: '1f34b',
  34146. leo: '264c',
  34147. leopard: '1f406',
  34148. lesotho: '1f1f1-1f1f8',
  34149. level_slider: '1f39a',
  34150. liberia: '1f1f1-1f1f7',
  34151. libra: '264e',
  34152. libya: '1f1f1-1f1fe',
  34153. liechtenstein: '1f1f1-1f1ee',
  34154. light_rail: '1f688',
  34155. link: '1f517',
  34156. lion: '1f981',
  34157. lips: '1f444',
  34158. lipstick: '1f484',
  34159. lithuania: '1f1f1-1f1f9',
  34160. lizard: '1f98e',
  34161. llama: '1f999',
  34162. lobster: '1f99e',
  34163. lock: '1f512',
  34164. lock_with_ink_pen: '1f50f',
  34165. lollipop: '1f36d',
  34166. loop: '27bf',
  34167. lotion_bottle: '1f9f4',
  34168. lotus_position: '1f9d8',
  34169. lotus_position_man: '1f9d8-2642',
  34170. lotus_position_woman: '1f9d8-2640',
  34171. loud_sound: '1f50a',
  34172. loudspeaker: '1f4e2',
  34173. love_hotel: '1f3e9',
  34174. love_letter: '1f48c',
  34175. love_you_gesture: '1f91f',
  34176. low_brightness: '1f505',
  34177. luggage: '1f9f3',
  34178. luxembourg: '1f1f1-1f1fa',
  34179. lying_face: '1f925',
  34180. m: '24c2',
  34181. macau: '1f1f2-1f1f4',
  34182. macedonia: '1f1f2-1f1f0',
  34183. madagascar: '1f1f2-1f1ec',
  34184. mag: '1f50d',
  34185. mag_right: '1f50e',
  34186. mage: '1f9d9',
  34187. mage_man: '1f9d9-2642',
  34188. mage_woman: '1f9d9-2640',
  34189. magnet: '1f9f2',
  34190. mahjong: '1f004',
  34191. mailbox: '1f4eb',
  34192. mailbox_closed: '1f4ea',
  34193. mailbox_with_mail: '1f4ec',
  34194. mailbox_with_no_mail: '1f4ed',
  34195. malawi: '1f1f2-1f1fc',
  34196. malaysia: '1f1f2-1f1fe',
  34197. maldives: '1f1f2-1f1fb',
  34198. male_detective: '1f575-2642',
  34199. male_sign: '2642',
  34200. mali: '1f1f2-1f1f1',
  34201. malta: '1f1f2-1f1f9',
  34202. man: '1f468',
  34203. man_artist: '1f468-1f3a8',
  34204. man_astronaut: '1f468-1f680',
  34205. man_cartwheeling: '1f938-2642',
  34206. man_cook: '1f468-1f373',
  34207. man_dancing: '1f57a',
  34208. man_facepalming: '1f926-2642',
  34209. man_factory_worker: '1f468-1f3ed',
  34210. man_farmer: '1f468-1f33e',
  34211. man_firefighter: '1f468-1f692',
  34212. man_health_worker: '1f468-2695',
  34213. man_in_manual_wheelchair: '1f468-1f9bd',
  34214. man_in_motorized_wheelchair: '1f468-1f9bc',
  34215. man_in_tuxedo: '1f935',
  34216. man_judge: '1f468-2696',
  34217. man_juggling: '1f939-2642',
  34218. man_mechanic: '1f468-1f527',
  34219. man_office_worker: '1f468-1f4bc',
  34220. man_pilot: '1f468-2708',
  34221. man_playing_handball: '1f93e-2642',
  34222. man_playing_water_polo: '1f93d-2642',
  34223. man_scientist: '1f468-1f52c',
  34224. man_shrugging: '1f937-2642',
  34225. man_singer: '1f468-1f3a4',
  34226. man_student: '1f468-1f393',
  34227. man_teacher: '1f468-1f3eb',
  34228. man_technologist: '1f468-1f4bb',
  34229. man_with_gua_pi_mao: '1f472',
  34230. man_with_probing_cane: '1f468-1f9af',
  34231. man_with_turban: '1f473-2642',
  34232. mandarin: '1f34a',
  34233. mango: '1f96d',
  34234. mans_shoe: '1f45e',
  34235. mantelpiece_clock: '1f570',
  34236. manual_wheelchair: '1f9bd',
  34237. maple_leaf: '1f341',
  34238. marshall_islands: '1f1f2-1f1ed',
  34239. martial_arts_uniform: '1f94b',
  34240. martinique: '1f1f2-1f1f6',
  34241. mask: '1f637',
  34242. massage: '1f486',
  34243. massage_man: '1f486-2642',
  34244. massage_woman: '1f486-2640',
  34245. mate: '1f9c9',
  34246. mauritania: '1f1f2-1f1f7',
  34247. mauritius: '1f1f2-1f1fa',
  34248. mayotte: '1f1fe-1f1f9',
  34249. meat_on_bone: '1f356',
  34250. mechanic: '1f9d1-1f527',
  34251. mechanical_arm: '1f9be',
  34252. mechanical_leg: '1f9bf',
  34253. medal_military: '1f396',
  34254. medal_sports: '1f3c5',
  34255. medical_symbol: '2695',
  34256. mega: '1f4e3',
  34257. melon: '1f348',
  34258. memo: '1f4dd',
  34259. men_wrestling: '1f93c-2642',
  34260. menorah: '1f54e',
  34261. mens: '1f6b9',
  34262. mermaid: '1f9dc-2640',
  34263. merman: '1f9dc-2642',
  34264. merperson: '1f9dc',
  34265. metal: '1f918',
  34266. metro: '1f687',
  34267. mexico: '1f1f2-1f1fd',
  34268. microbe: '1f9a0',
  34269. micronesia: '1f1eb-1f1f2',
  34270. microphone: '1f3a4',
  34271. microscope: '1f52c',
  34272. middle_finger: '1f595',
  34273. milk_glass: '1f95b',
  34274. milky_way: '1f30c',
  34275. minibus: '1f690',
  34276. minidisc: '1f4bd',
  34277. mobile_phone_off: '1f4f4',
  34278. moldova: '1f1f2-1f1e9',
  34279. monaco: '1f1f2-1f1e8',
  34280. money_mouth_face: '1f911',
  34281. money_with_wings: '1f4b8',
  34282. moneybag: '1f4b0',
  34283. mongolia: '1f1f2-1f1f3',
  34284. monkey: '1f412',
  34285. monkey_face: '1f435',
  34286. monocle_face: '1f9d0',
  34287. monorail: '1f69d',
  34288. montenegro: '1f1f2-1f1ea',
  34289. montserrat: '1f1f2-1f1f8',
  34290. moon: '1f314',
  34291. moon_cake: '1f96e',
  34292. morocco: '1f1f2-1f1e6',
  34293. mortar_board: '1f393',
  34294. mosque: '1f54c',
  34295. mosquito: '1f99f',
  34296. motor_boat: '1f6e5',
  34297. motor_scooter: '1f6f5',
  34298. motorcycle: '1f3cd',
  34299. motorized_wheelchair: '1f9bc',
  34300. motorway: '1f6e3',
  34301. mount_fuji: '1f5fb',
  34302. mountain: '26f0',
  34303. mountain_bicyclist: '1f6b5',
  34304. mountain_biking_man: '1f6b5-2642',
  34305. mountain_biking_woman: '1f6b5-2640',
  34306. mountain_cableway: '1f6a0',
  34307. mountain_railway: '1f69e',
  34308. mountain_snow: '1f3d4',
  34309. mouse: '1f42d',
  34310. mouse2: '1f401',
  34311. movie_camera: '1f3a5',
  34312. moyai: '1f5ff',
  34313. mozambique: '1f1f2-1f1ff',
  34314. mrs_claus: '1f936',
  34315. muscle: '1f4aa',
  34316. mushroom: '1f344',
  34317. musical_keyboard: '1f3b9',
  34318. musical_note: '1f3b5',
  34319. musical_score: '1f3bc',
  34320. mute: '1f507',
  34321. myanmar: '1f1f2-1f1f2',
  34322. nail_care: '1f485',
  34323. name_badge: '1f4db',
  34324. namibia: '1f1f3-1f1e6',
  34325. national_park: '1f3de',
  34326. nauru: '1f1f3-1f1f7',
  34327. nauseated_face: '1f922',
  34328. nazar_amulet: '1f9ff',
  34329. necktie: '1f454',
  34330. negative_squared_cross_mark: '274e',
  34331. nepal: '1f1f3-1f1f5',
  34332. nerd_face: '1f913',
  34333. netherlands: '1f1f3-1f1f1',
  34334. neutral_face: '1f610',
  34335. "new": '1f195',
  34336. new_caledonia: '1f1f3-1f1e8',
  34337. new_moon: '1f311',
  34338. new_moon_with_face: '1f31a',
  34339. new_zealand: '1f1f3-1f1ff',
  34340. newspaper: '1f4f0',
  34341. newspaper_roll: '1f5de',
  34342. next_track_button: '23ed',
  34343. ng: '1f196',
  34344. ng_man: '1f645-2642',
  34345. ng_woman: '1f645-2640',
  34346. nicaragua: '1f1f3-1f1ee',
  34347. niger: '1f1f3-1f1ea',
  34348. nigeria: '1f1f3-1f1ec',
  34349. night_with_stars: '1f303',
  34350. nine: '0039-20e3',
  34351. niue: '1f1f3-1f1fa',
  34352. no_bell: '1f515',
  34353. no_bicycles: '1f6b3',
  34354. no_entry: '26d4',
  34355. no_entry_sign: '1f6ab',
  34356. no_good: '1f645',
  34357. no_good_man: '1f645-2642',
  34358. no_good_woman: '1f645-2640',
  34359. no_mobile_phones: '1f4f5',
  34360. no_mouth: '1f636',
  34361. no_pedestrians: '1f6b7',
  34362. no_smoking: '1f6ad',
  34363. 'non-potable_water': '1f6b1',
  34364. norfolk_island: '1f1f3-1f1eb',
  34365. north_korea: '1f1f0-1f1f5',
  34366. northern_mariana_islands: '1f1f2-1f1f5',
  34367. norway: '1f1f3-1f1f4',
  34368. nose: '1f443',
  34369. notebook: '1f4d3',
  34370. notebook_with_decorative_cover: '1f4d4',
  34371. notes: '1f3b6',
  34372. nut_and_bolt: '1f529',
  34373. o: '2b55',
  34374. o2: '1f17e',
  34375. ocean: '1f30a',
  34376. octopus: '1f419',
  34377. oden: '1f362',
  34378. office: '1f3e2',
  34379. office_worker: '1f9d1-1f4bc',
  34380. oil_drum: '1f6e2',
  34381. ok: '1f197',
  34382. ok_hand: '1f44c',
  34383. ok_man: '1f646-2642',
  34384. ok_person: '1f646',
  34385. ok_woman: '1f646-2640',
  34386. old_key: '1f5dd',
  34387. older_adult: '1f9d3',
  34388. older_man: '1f474',
  34389. older_woman: '1f475',
  34390. om: '1f549',
  34391. oman: '1f1f4-1f1f2',
  34392. on: '1f51b',
  34393. oncoming_automobile: '1f698',
  34394. oncoming_bus: '1f68d',
  34395. oncoming_police_car: '1f694',
  34396. oncoming_taxi: '1f696',
  34397. one: '0031-20e3',
  34398. one_piece_swimsuit: '1fa71',
  34399. onion: '1f9c5',
  34400. open_book: '1f4d6',
  34401. open_file_folder: '1f4c2',
  34402. open_hands: '1f450',
  34403. open_mouth: '1f62e',
  34404. open_umbrella: '2602',
  34405. ophiuchus: '26ce',
  34406. orange: '1f34a',
  34407. orange_book: '1f4d9',
  34408. orange_circle: '1f7e0',
  34409. orange_heart: '1f9e1',
  34410. orange_square: '1f7e7',
  34411. orangutan: '1f9a7',
  34412. orthodox_cross: '2626',
  34413. otter: '1f9a6',
  34414. outbox_tray: '1f4e4',
  34415. owl: '1f989',
  34416. ox: '1f402',
  34417. oyster: '1f9aa',
  34418. "package": '1f4e6',
  34419. page_facing_up: '1f4c4',
  34420. page_with_curl: '1f4c3',
  34421. pager: '1f4df',
  34422. paintbrush: '1f58c',
  34423. pakistan: '1f1f5-1f1f0',
  34424. palau: '1f1f5-1f1fc',
  34425. palestinian_territories: '1f1f5-1f1f8',
  34426. palm_tree: '1f334',
  34427. palms_up_together: '1f932',
  34428. panama: '1f1f5-1f1e6',
  34429. pancakes: '1f95e',
  34430. panda_face: '1f43c',
  34431. paperclip: '1f4ce',
  34432. paperclips: '1f587',
  34433. papua_new_guinea: '1f1f5-1f1ec',
  34434. parachute: '1fa82',
  34435. paraguay: '1f1f5-1f1fe',
  34436. parasol_on_ground: '26f1',
  34437. parking: '1f17f',
  34438. parrot: '1f99c',
  34439. part_alternation_mark: '303d',
  34440. partly_sunny: '26c5',
  34441. partying_face: '1f973',
  34442. passenger_ship: '1f6f3',
  34443. passport_control: '1f6c2',
  34444. pause_button: '23f8',
  34445. paw_prints: '1f43e',
  34446. peace_symbol: '262e',
  34447. peach: '1f351',
  34448. peacock: '1f99a',
  34449. peanuts: '1f95c',
  34450. pear: '1f350',
  34451. pen: '1f58a',
  34452. pencil: '1f4dd',
  34453. pencil2: '270f',
  34454. penguin: '1f427',
  34455. pensive: '1f614',
  34456. people_holding_hands: '1f9d1-1f91d-1f9d1',
  34457. performing_arts: '1f3ad',
  34458. persevere: '1f623',
  34459. person_bald: '1f9d1-1f9b2',
  34460. person_curly_hair: '1f9d1-1f9b1',
  34461. person_fencing: '1f93a',
  34462. person_in_manual_wheelchair: '1f9d1-1f9bd',
  34463. person_in_motorized_wheelchair: '1f9d1-1f9bc',
  34464. person_red_hair: '1f9d1-1f9b0',
  34465. person_white_hair: '1f9d1-1f9b3',
  34466. person_with_probing_cane: '1f9d1-1f9af',
  34467. person_with_turban: '1f473',
  34468. peru: '1f1f5-1f1ea',
  34469. petri_dish: '1f9eb',
  34470. philippines: '1f1f5-1f1ed',
  34471. phone: '260e',
  34472. pick: '26cf',
  34473. pie: '1f967',
  34474. pig: '1f437',
  34475. pig2: '1f416',
  34476. pig_nose: '1f43d',
  34477. pill: '1f48a',
  34478. pilot: '1f9d1-2708',
  34479. pinching_hand: '1f90f',
  34480. pineapple: '1f34d',
  34481. ping_pong: '1f3d3',
  34482. pirate_flag: '1f3f4-2620',
  34483. pisces: '2653',
  34484. pitcairn_islands: '1f1f5-1f1f3',
  34485. pizza: '1f355',
  34486. place_of_worship: '1f6d0',
  34487. plate_with_cutlery: '1f37d',
  34488. play_or_pause_button: '23ef',
  34489. pleading_face: '1f97a',
  34490. point_down: '1f447',
  34491. point_left: '1f448',
  34492. point_right: '1f449',
  34493. point_up: '261d',
  34494. point_up_2: '1f446',
  34495. poland: '1f1f5-1f1f1',
  34496. police_car: '1f693',
  34497. police_officer: '1f46e',
  34498. policeman: '1f46e-2642',
  34499. policewoman: '1f46e-2640',
  34500. poodle: '1f429',
  34501. poop: '1f4a9',
  34502. popcorn: '1f37f',
  34503. portugal: '1f1f5-1f1f9',
  34504. post_office: '1f3e3',
  34505. postal_horn: '1f4ef',
  34506. postbox: '1f4ee',
  34507. potable_water: '1f6b0',
  34508. potato: '1f954',
  34509. pouch: '1f45d',
  34510. poultry_leg: '1f357',
  34511. pound: '1f4b7',
  34512. pout: '1f621',
  34513. pouting_cat: '1f63e',
  34514. pouting_face: '1f64e',
  34515. pouting_man: '1f64e-2642',
  34516. pouting_woman: '1f64e-2640',
  34517. pray: '1f64f',
  34518. prayer_beads: '1f4ff',
  34519. pregnant_woman: '1f930',
  34520. pretzel: '1f968',
  34521. previous_track_button: '23ee',
  34522. prince: '1f934',
  34523. princess: '1f478',
  34524. printer: '1f5a8',
  34525. probing_cane: '1f9af',
  34526. puerto_rico: '1f1f5-1f1f7',
  34527. punch: '1f44a',
  34528. purple_circle: '1f7e3',
  34529. purple_heart: '1f49c',
  34530. purple_square: '1f7ea',
  34531. purse: '1f45b',
  34532. pushpin: '1f4cc',
  34533. put_litter_in_its_place: '1f6ae',
  34534. qatar: '1f1f6-1f1e6',
  34535. question: '2753',
  34536. rabbit: '1f430',
  34537. rabbit2: '1f407',
  34538. raccoon: '1f99d',
  34539. racehorse: '1f40e',
  34540. racing_car: '1f3ce',
  34541. radio: '1f4fb',
  34542. radio_button: '1f518',
  34543. radioactive: '2622',
  34544. rage: '1f621',
  34545. railway_car: '1f683',
  34546. railway_track: '1f6e4',
  34547. rainbow: '1f308',
  34548. rainbow_flag: '1f3f3-1f308',
  34549. raised_back_of_hand: '1f91a',
  34550. raised_eyebrow: '1f928',
  34551. raised_hand: '270b',
  34552. raised_hand_with_fingers_splayed: '1f590',
  34553. raised_hands: '1f64c',
  34554. raising_hand: '1f64b',
  34555. raising_hand_man: '1f64b-2642',
  34556. raising_hand_woman: '1f64b-2640',
  34557. ram: '1f40f',
  34558. ramen: '1f35c',
  34559. rat: '1f400',
  34560. razor: '1fa92',
  34561. receipt: '1f9fe',
  34562. record_button: '23fa',
  34563. recycle: '267b',
  34564. red_car: '1f697',
  34565. red_circle: '1f534',
  34566. red_envelope: '1f9e7',
  34567. red_haired_man: '1f468-1f9b0',
  34568. red_haired_woman: '1f469-1f9b0',
  34569. red_square: '1f7e5',
  34570. registered: '00ae',
  34571. relaxed: '263a',
  34572. relieved: '1f60c',
  34573. reminder_ribbon: '1f397',
  34574. repeat: '1f501',
  34575. repeat_one: '1f502',
  34576. rescue_worker_helmet: '26d1',
  34577. restroom: '1f6bb',
  34578. reunion: '1f1f7-1f1ea',
  34579. revolving_hearts: '1f49e',
  34580. rewind: '23ea',
  34581. rhinoceros: '1f98f',
  34582. ribbon: '1f380',
  34583. rice: '1f35a',
  34584. rice_ball: '1f359',
  34585. rice_cracker: '1f358',
  34586. rice_scene: '1f391',
  34587. right_anger_bubble: '1f5ef',
  34588. ring: '1f48d',
  34589. ringed_planet: '1fa90',
  34590. robot: '1f916',
  34591. rocket: '1f680',
  34592. rofl: '1f923',
  34593. roll_eyes: '1f644',
  34594. roll_of_paper: '1f9fb',
  34595. roller_coaster: '1f3a2',
  34596. romania: '1f1f7-1f1f4',
  34597. rooster: '1f413',
  34598. rose: '1f339',
  34599. rosette: '1f3f5',
  34600. rotating_light: '1f6a8',
  34601. round_pushpin: '1f4cd',
  34602. rowboat: '1f6a3',
  34603. rowing_man: '1f6a3-2642',
  34604. rowing_woman: '1f6a3-2640',
  34605. ru: '1f1f7-1f1fa',
  34606. rugby_football: '1f3c9',
  34607. runner: '1f3c3',
  34608. running: '1f3c3',
  34609. running_man: '1f3c3-2642',
  34610. running_shirt_with_sash: '1f3bd',
  34611. running_woman: '1f3c3-2640',
  34612. rwanda: '1f1f7-1f1fc',
  34613. sa: '1f202',
  34614. safety_pin: '1f9f7',
  34615. safety_vest: '1f9ba',
  34616. sagittarius: '2650',
  34617. sailboat: '26f5',
  34618. sake: '1f376',
  34619. salt: '1f9c2',
  34620. samoa: '1f1fc-1f1f8',
  34621. san_marino: '1f1f8-1f1f2',
  34622. sandal: '1f461',
  34623. sandwich: '1f96a',
  34624. santa: '1f385',
  34625. sao_tome_principe: '1f1f8-1f1f9',
  34626. sari: '1f97b',
  34627. sassy_man: '1f481-2642',
  34628. sassy_woman: '1f481-2640',
  34629. satellite: '1f4e1',
  34630. satisfied: '1f606',
  34631. saudi_arabia: '1f1f8-1f1e6',
  34632. sauna_man: '1f9d6-2642',
  34633. sauna_person: '1f9d6',
  34634. sauna_woman: '1f9d6-2640',
  34635. sauropod: '1f995',
  34636. saxophone: '1f3b7',
  34637. scarf: '1f9e3',
  34638. school: '1f3eb',
  34639. school_satchel: '1f392',
  34640. scientist: '1f9d1-1f52c',
  34641. scissors: '2702',
  34642. scorpion: '1f982',
  34643. scorpius: '264f',
  34644. scotland: '1f3f4-e0067-e0062-e0073-e0063-e0074-e007f',
  34645. scream: '1f631',
  34646. scream_cat: '1f640',
  34647. scroll: '1f4dc',
  34648. seat: '1f4ba',
  34649. secret: '3299',
  34650. see_no_evil: '1f648',
  34651. seedling: '1f331',
  34652. selfie: '1f933',
  34653. senegal: '1f1f8-1f1f3',
  34654. serbia: '1f1f7-1f1f8',
  34655. service_dog: '1f415-1f9ba',
  34656. seven: '0037-20e3',
  34657. seychelles: '1f1f8-1f1e8',
  34658. shallow_pan_of_food: '1f958',
  34659. shamrock: '2618',
  34660. shark: '1f988',
  34661. shaved_ice: '1f367',
  34662. sheep: '1f411',
  34663. shell: '1f41a',
  34664. shield: '1f6e1',
  34665. shinto_shrine: '26e9',
  34666. ship: '1f6a2',
  34667. shirt: '1f455',
  34668. poo: '1f4a9',
  34669. shoe: '1f45e',
  34670. shopping: '1f6cd',
  34671. shopping_cart: '1f6d2',
  34672. shorts: '1fa73',
  34673. shower: '1f6bf',
  34674. shrimp: '1f990',
  34675. shrug: '1f937',
  34676. shushing_face: '1f92b',
  34677. sierra_leone: '1f1f8-1f1f1',
  34678. signal_strength: '1f4f6',
  34679. singapore: '1f1f8-1f1ec',
  34680. singer: '1f9d1-1f3a4',
  34681. sint_maarten: '1f1f8-1f1fd',
  34682. six: '0036-20e3',
  34683. six_pointed_star: '1f52f',
  34684. skateboard: '1f6f9',
  34685. ski: '1f3bf',
  34686. skier: '26f7',
  34687. skull: '1f480',
  34688. skull_and_crossbones: '2620',
  34689. skunk: '1f9a8',
  34690. sled: '1f6f7',
  34691. sleeping: '1f634',
  34692. sleeping_bed: '1f6cc',
  34693. sleepy: '1f62a',
  34694. slightly_frowning_face: '1f641',
  34695. slightly_smiling_face: '1f642',
  34696. slot_machine: '1f3b0',
  34697. sloth: '1f9a5',
  34698. slovakia: '1f1f8-1f1f0',
  34699. slovenia: '1f1f8-1f1ee',
  34700. small_airplane: '1f6e9',
  34701. small_blue_diamond: '1f539',
  34702. small_orange_diamond: '1f538',
  34703. small_red_triangle: '1f53a',
  34704. small_red_triangle_down: '1f53b',
  34705. smile: '1f604',
  34706. smile_cat: '1f638',
  34707. smiley: '1f603',
  34708. smiley_cat: '1f63a',
  34709. smiling_face_with_three_hearts: '1f970',
  34710. smiling_imp: '1f608',
  34711. smirk: '1f60f',
  34712. smirk_cat: '1f63c',
  34713. smoking: '1f6ac',
  34714. snail: '1f40c',
  34715. snake: '1f40d',
  34716. sneezing_face: '1f927',
  34717. snowboarder: '1f3c2',
  34718. snowflake: '2744',
  34719. snowman: '26c4',
  34720. snowman_with_snow: '2603',
  34721. soap: '1f9fc',
  34722. sob: '1f62d',
  34723. soccer: '26bd',
  34724. socks: '1f9e6',
  34725. softball: '1f94e',
  34726. solomon_islands: '1f1f8-1f1e7',
  34727. somalia: '1f1f8-1f1f4',
  34728. soon: '1f51c',
  34729. sos: '1f198',
  34730. sound: '1f509',
  34731. south_africa: '1f1ff-1f1e6',
  34732. south_georgia_south_sandwich_islands: '1f1ec-1f1f8',
  34733. south_sudan: '1f1f8-1f1f8',
  34734. space_invader: '1f47e',
  34735. spades: '2660',
  34736. spaghetti: '1f35d',
  34737. sparkle: '2747',
  34738. sparkler: '1f387',
  34739. sparkles: '2728',
  34740. sparkling_heart: '1f496',
  34741. speak_no_evil: '1f64a',
  34742. speaker: '1f508',
  34743. speaking_head: '1f5e3',
  34744. speech_balloon: '1f4ac',
  34745. speedboat: '1f6a4',
  34746. spider: '1f577',
  34747. spider_web: '1f578',
  34748. spiral_calendar: '1f5d3',
  34749. spiral_notepad: '1f5d2',
  34750. sponge: '1f9fd',
  34751. spoon: '1f944',
  34752. squid: '1f991',
  34753. sri_lanka: '1f1f1-1f1f0',
  34754. st_barthelemy: '1f1e7-1f1f1',
  34755. st_helena: '1f1f8-1f1ed',
  34756. st_kitts_nevis: '1f1f0-1f1f3',
  34757. st_lucia: '1f1f1-1f1e8',
  34758. st_martin: '1f1f2-1f1eb',
  34759. st_pierre_miquelon: '1f1f5-1f1f2',
  34760. st_vincent_grenadines: '1f1fb-1f1e8',
  34761. stadium: '1f3df',
  34762. standing_man: '1f9cd-2642',
  34763. standing_person: '1f9cd',
  34764. standing_woman: '1f9cd-2640',
  34765. star: '2b50',
  34766. star2: '1f31f',
  34767. star_and_crescent: '262a',
  34768. star_of_david: '2721',
  34769. star_struck: '1f929',
  34770. stars: '1f320',
  34771. station: '1f689',
  34772. statue_of_liberty: '1f5fd',
  34773. steam_locomotive: '1f682',
  34774. stethoscope: '1fa7a',
  34775. stew: '1f372',
  34776. stop_button: '23f9',
  34777. stop_sign: '1f6d1',
  34778. stopwatch: '23f1',
  34779. straight_ruler: '1f4cf',
  34780. strawberry: '1f353',
  34781. stuck_out_tongue: '1f61b',
  34782. stuck_out_tongue_closed_eyes: '1f61d',
  34783. stuck_out_tongue_winking_eye: '1f61c',
  34784. student: '1f9d1-1f393',
  34785. studio_microphone: '1f399',
  34786. stuffed_flatbread: '1f959',
  34787. sudan: '1f1f8-1f1e9',
  34788. sun_behind_large_cloud: '1f325',
  34789. sun_behind_rain_cloud: '1f326',
  34790. sun_behind_small_cloud: '1f324',
  34791. sun_with_face: '1f31e',
  34792. sunflower: '1f33b',
  34793. sunglasses: '1f60e',
  34794. sunny: '2600',
  34795. sunrise: '1f305',
  34796. sunrise_over_mountains: '1f304',
  34797. superhero: '1f9b8',
  34798. superhero_man: '1f9b8-2642',
  34799. superhero_woman: '1f9b8-2640',
  34800. supervillain: '1f9b9',
  34801. supervillain_man: '1f9b9-2642',
  34802. supervillain_woman: '1f9b9-2640',
  34803. surfer: '1f3c4',
  34804. surfing_man: '1f3c4-2642',
  34805. surfing_woman: '1f3c4-2640',
  34806. suriname: '1f1f8-1f1f7',
  34807. sushi: '1f363',
  34808. suspension_railway: '1f69f',
  34809. svalbard_jan_mayen: '1f1f8-1f1ef',
  34810. swan: '1f9a2',
  34811. swaziland: '1f1f8-1f1ff',
  34812. sweat: '1f613',
  34813. sweat_drops: '1f4a6',
  34814. sweat_smile: '1f605',
  34815. sweden: '1f1f8-1f1ea',
  34816. sweet_potato: '1f360',
  34817. swim_brief: '1fa72',
  34818. swimmer: '1f3ca',
  34819. swimming_man: '1f3ca-2642',
  34820. swimming_woman: '1f3ca-2640',
  34821. switzerland: '1f1e8-1f1ed',
  34822. symbols: '1f523',
  34823. synagogue: '1f54d',
  34824. syria: '1f1f8-1f1fe',
  34825. syringe: '1f489',
  34826. 't-rex': '1f996',
  34827. taco: '1f32e',
  34828. tada: '1f389',
  34829. taiwan: '1f1f9-1f1fc',
  34830. tajikistan: '1f1f9-1f1ef',
  34831. takeout_box: '1f961',
  34832. tanabata_tree: '1f38b',
  34833. tangerine: '1f34a',
  34834. tanzania: '1f1f9-1f1ff',
  34835. taurus: '2649',
  34836. taxi: '1f695',
  34837. tea: '1f375',
  34838. teacher: '1f9d1-1f3eb',
  34839. technologist: '1f9d1-1f4bb',
  34840. teddy_bear: '1f9f8',
  34841. telephone: '260e',
  34842. telephone_receiver: '1f4de',
  34843. telescope: '1f52d',
  34844. tennis: '1f3be',
  34845. tent: '26fa',
  34846. test_tube: '1f9ea',
  34847. thailand: '1f1f9-1f1ed',
  34848. thermometer: '1f321',
  34849. thinking: '1f914',
  34850. thought_balloon: '1f4ad',
  34851. thread: '1f9f5',
  34852. three: '0033-20e3',
  34853. thumbsdown: '1f44e',
  34854. thumbsup: '1f44d',
  34855. ticket: '1f3ab',
  34856. tickets: '1f39f',
  34857. tiger: '1f42f',
  34858. tiger2: '1f405',
  34859. timer_clock: '23f2',
  34860. timor_leste: '1f1f9-1f1f1',
  34861. tipping_hand_man: '1f481-2642',
  34862. tipping_hand_person: '1f481',
  34863. tipping_hand_woman: '1f481-2640',
  34864. tired_face: '1f62b',
  34865. tm: '2122',
  34866. togo: '1f1f9-1f1ec',
  34867. toilet: '1f6bd',
  34868. tokelau: '1f1f9-1f1f0',
  34869. tokyo_tower: '1f5fc',
  34870. tomato: '1f345',
  34871. tonga: '1f1f9-1f1f4',
  34872. tongue: '1f445',
  34873. toolbox: '1f9f0',
  34874. tooth: '1f9b7',
  34875. top: '1f51d',
  34876. tophat: '1f3a9',
  34877. tornado: '1f32a',
  34878. tr: '1f1f9-1f1f7',
  34879. trackball: '1f5b2',
  34880. tractor: '1f69c',
  34881. traffic_light: '1f6a5',
  34882. train: '1f68b',
  34883. train2: '1f686',
  34884. tram: '1f68a',
  34885. triangular_flag_on_post: '1f6a9',
  34886. triangular_ruler: '1f4d0',
  34887. trident: '1f531',
  34888. trinidad_tobago: '1f1f9-1f1f9',
  34889. tristan_da_cunha: '1f1f9-1f1e6',
  34890. triumph: '1f624',
  34891. trolleybus: '1f68e',
  34892. trophy: '1f3c6',
  34893. tropical_drink: '1f379',
  34894. tropical_fish: '1f420',
  34895. truck: '1f69a',
  34896. trumpet: '1f3ba',
  34897. tshirt: '1f455',
  34898. tulip: '1f337',
  34899. tumbler_glass: '1f943',
  34900. tunisia: '1f1f9-1f1f3',
  34901. turkey: '1f983',
  34902. turkmenistan: '1f1f9-1f1f2',
  34903. turks_caicos_islands: '1f1f9-1f1e8',
  34904. turtle: '1f422',
  34905. tuvalu: '1f1f9-1f1fb',
  34906. tv: '1f4fa',
  34907. twisted_rightwards_arrows: '1f500',
  34908. two: '0032-20e3',
  34909. two_hearts: '1f495',
  34910. two_men_holding_hands: '1f46c',
  34911. two_women_holding_hands: '1f46d',
  34912. u5272: '1f239',
  34913. u5408: '1f234',
  34914. u55b6: '1f23a',
  34915. u6307: '1f22f',
  34916. u6708: '1f237',
  34917. u6709: '1f236',
  34918. u6e80: '1f235',
  34919. u7121: '1f21a',
  34920. u7533: '1f238',
  34921. u7981: '1f232',
  34922. u7a7a: '1f233',
  34923. uganda: '1f1fa-1f1ec',
  34924. uk: '1f1ec-1f1e7',
  34925. ukraine: '1f1fa-1f1e6',
  34926. umbrella: '2614',
  34927. unamused: '1f612',
  34928. underage: '1f51e',
  34929. unicorn: '1f984',
  34930. united_arab_emirates: '1f1e6-1f1ea',
  34931. united_nations: '1f1fa-1f1f3',
  34932. unlock: '1f513',
  34933. up: '1f199',
  34934. upside_down_face: '1f643',
  34935. uruguay: '1f1fa-1f1fe',
  34936. us: '1f1fa-1f1f8',
  34937. us_outlying_islands: '1f1fa-1f1f2',
  34938. us_virgin_islands: '1f1fb-1f1ee',
  34939. uzbekistan: '1f1fa-1f1ff',
  34940. v: '270c',
  34941. vampire: '1f9db',
  34942. vampire_man: '1f9db-2642',
  34943. vampire_woman: '1f9db-2640',
  34944. vanuatu: '1f1fb-1f1fa',
  34945. vatican_city: '1f1fb-1f1e6',
  34946. venezuela: '1f1fb-1f1ea',
  34947. vertical_traffic_light: '1f6a6',
  34948. vhs: '1f4fc',
  34949. vibration_mode: '1f4f3',
  34950. video_camera: '1f4f9',
  34951. video_game: '1f3ae',
  34952. vietnam: '1f1fb-1f1f3',
  34953. violin: '1f3bb',
  34954. virgo: '264d',
  34955. volcano: '1f30b',
  34956. volleyball: '1f3d0',
  34957. vomiting_face: '1f92e',
  34958. vs: '1f19a',
  34959. vulcan_salute: '1f596',
  34960. waffle: '1f9c7',
  34961. wales: '1f3f4-e0067-e0062-e0077-e006c-e0073-e007f',
  34962. walking: '1f6b6',
  34963. walking_man: '1f6b6-2642',
  34964. walking_woman: '1f6b6-2640',
  34965. wallis_futuna: '1f1fc-1f1eb',
  34966. waning_crescent_moon: '1f318',
  34967. waning_gibbous_moon: '1f316',
  34968. warning: '26a0',
  34969. wastebasket: '1f5d1',
  34970. watch: '231a',
  34971. water_buffalo: '1f403',
  34972. water_polo: '1f93d',
  34973. watermelon: '1f349',
  34974. wave: '1f44b',
  34975. wavy_dash: '3030',
  34976. waxing_crescent_moon: '1f312',
  34977. waxing_gibbous_moon: '1f314',
  34978. wc: '1f6be',
  34979. weary: '1f629',
  34980. wedding: '1f492',
  34981. weight_lifting: '1f3cb',
  34982. weight_lifting_man: '1f3cb-2642',
  34983. weight_lifting_woman: '1f3cb-2640',
  34984. western_sahara: '1f1ea-1f1ed',
  34985. whale: '1f433',
  34986. whale2: '1f40b',
  34987. wheel_of_dharma: '2638',
  34988. wheelchair: '267f',
  34989. white_check_mark: '2705',
  34990. white_circle: '26aa',
  34991. white_flag: '1f3f3',
  34992. white_flower: '1f4ae',
  34993. white_haired_man: '1f468-1f9b3',
  34994. white_haired_woman: '1f469-1f9b3',
  34995. white_heart: '1f90d',
  34996. white_large_square: '2b1c',
  34997. white_medium_small_square: '25fd',
  34998. white_medium_square: '25fb',
  34999. white_small_square: '25ab',
  35000. white_square_button: '1f533',
  35001. wilted_flower: '1f940',
  35002. wind_chime: '1f390',
  35003. wind_face: '1f32c',
  35004. wine_glass: '1f377',
  35005. wink: '1f609',
  35006. wolf: '1f43a',
  35007. woman: '1f469',
  35008. woman_artist: '1f469-1f3a8',
  35009. woman_astronaut: '1f469-1f680',
  35010. woman_cartwheeling: '1f938-2640',
  35011. woman_cook: '1f469-1f373',
  35012. woman_dancing: '1f483',
  35013. woman_facepalming: '1f926-2640',
  35014. woman_factory_worker: '1f469-1f3ed',
  35015. woman_farmer: '1f469-1f33e',
  35016. woman_firefighter: '1f469-1f692',
  35017. woman_health_worker: '1f469-2695',
  35018. woman_in_manual_wheelchair: '1f469-1f9bd',
  35019. woman_in_motorized_wheelchair: '1f469-1f9bc',
  35020. woman_judge: '1f469-2696',
  35021. woman_juggling: '1f939-2640',
  35022. woman_mechanic: '1f469-1f527',
  35023. woman_office_worker: '1f469-1f4bc',
  35024. woman_pilot: '1f469-2708',
  35025. woman_playing_handball: '1f93e-2640',
  35026. woman_playing_water_polo: '1f93d-2640',
  35027. woman_scientist: '1f469-1f52c',
  35028. woman_shrugging: '1f937-2640',
  35029. woman_singer: '1f469-1f3a4',
  35030. woman_student: '1f469-1f393',
  35031. woman_teacher: '1f469-1f3eb',
  35032. woman_technologist: '1f469-1f4bb',
  35033. woman_with_headscarf: '1f9d5',
  35034. woman_with_probing_cane: '1f469-1f9af',
  35035. woman_with_turban: '1f473-2640',
  35036. womans_clothes: '1f45a',
  35037. womans_hat: '1f452',
  35038. women_wrestling: '1f93c-2640',
  35039. womens: '1f6ba',
  35040. woozy_face: '1f974',
  35041. world_map: '1f5fa',
  35042. worried: '1f61f',
  35043. wrench: '1f527',
  35044. wrestling: '1f93c',
  35045. writing_hand: '270d',
  35046. x: '274c',
  35047. yarn: '1f9f6',
  35048. yawning_face: '1f971',
  35049. yellow_circle: '1f7e1',
  35050. yellow_heart: '1f49b',
  35051. yellow_square: '1f7e8',
  35052. yemen: '1f1fe-1f1ea',
  35053. yen: '1f4b4',
  35054. yin_yang: '262f',
  35055. yo_yo: '1fa80',
  35056. yum: '1f60b',
  35057. zambia: '1f1ff-1f1f2',
  35058. zany_face: '1f92a',
  35059. zap: '26a1',
  35060. zebra: '1f993',
  35061. zero: '0030-20e3',
  35062. zimbabwe: '1f1ff-1f1fc',
  35063. zipper_mouth_face: '1f910',
  35064. zombie: '1f9df',
  35065. zombie_man: '1f9df-2642',
  35066. zombie_woman: '1f9df-2640',
  35067. zzz: '1f4a4'
  35068. }
  35069. };
  35070. function ownKeys$7(object, enumerableOnly) { var keys = keys$3(object); if (getOwnPropertySymbols$2) { var symbols = getOwnPropertySymbols$2(object); enumerableOnly && (symbols = filter$3(symbols).call(symbols, function (sym) { return getOwnPropertyDescriptor$3(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  35071. function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? forEach$3(_context3 = ownKeys$7(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : getOwnPropertyDescriptors$2 ? defineProperties$2(target, getOwnPropertyDescriptors$2(source)) : forEach$3(_context4 = ownKeys$7(Object(source))).call(_context4, function (key) { defineProperty$5(target, key, getOwnPropertyDescriptor$3(source, key)); }); } return target; }
  35072. function _createSuper$s(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$s(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  35073. function _isNativeReflectConstruct$s() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  35074. function fromCodePoint$3() {
  35075. var codeUnits = [];
  35076. var codeLen = 0;
  35077. var result = '';
  35078. for (var index = 0, len = arguments.length; index !== len; ++index) {
  35079. var codePoint = +(index < 0 || arguments.length <= index ? undefined : arguments[index]); // correctly handles all cases including `NaN`, `-Infinity`, `+Infinity`
  35080. // The surrounding `!(...)` is required to correctly handle `NaN` cases
  35081. // The (codePoint>>>0) === codePoint clause handles decimals and negatives
  35082. if (!(codePoint < 0x10ffff && codePoint >>> 0 === codePoint)) {
  35083. throw new RangeError("Invalid code point: ".concat(codePoint));
  35084. }
  35085. if (codePoint <= 0xffff) {
  35086. // BMP code point
  35087. codeLen = codeUnits.push(codePoint);
  35088. } else {
  35089. // Astral code point; split in surrogate halves
  35090. // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  35091. codePoint -= 0x10000;
  35092. codeLen = codeUnits.push((codePoint >> 10) + 0xd800, // highSurrogate
  35093. codePoint % 0x400 + 0xdc00 // lowSurrogate
  35094. );
  35095. }
  35096. if (codeLen >= 0x3fff) {
  35097. result += String.fromCharCode.apply(null, codeUnits);
  35098. codeUnits.length = 0;
  35099. }
  35100. }
  35101. return result + String.fromCharCode.apply(null, codeUnits);
  35102. }
  35103. var Emoji = /*#__PURE__*/function (_SyntaxBase) {
  35104. _inherits(Emoji, _SyntaxBase);
  35105. var _super = _createSuper$s(Emoji);
  35106. function Emoji() {
  35107. var _this;
  35108. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  35109. config: undefined
  35110. },
  35111. config = _ref.config;
  35112. _classCallCheck(this, Emoji);
  35113. _this = _super.call(this, {
  35114. config: config
  35115. });
  35116. _this.options = {
  35117. useUnicode: true,
  35118. upperCase: false,
  35119. customHandled: false,
  35120. resourceURL: 'https://github.githubassets.com/images/icons/emoji/unicode/${code}.png?v8',
  35121. emojis: _objectSpread$6({}, gfmUnicode.emojis)
  35122. };
  35123. if (_typeof(config) !== 'object') {
  35124. return _possibleConstructorReturn(_this);
  35125. }
  35126. var useUnicode = config.useUnicode,
  35127. customResourceURL = config.customResourceURL,
  35128. customRenderer = config.customRenderer,
  35129. upperCase = config.upperCase;
  35130. _this.options.useUnicode = typeof useUnicode === 'boolean' ? useUnicode : _this.options.useUnicode;
  35131. _this.options.upperCase = typeof useUnicode === 'boolean' ? upperCase : _this.options.upperCase;
  35132. if (useUnicode === false && typeof customResourceURL === 'string') {
  35133. _this.options.resourceURL = customResourceURL;
  35134. }
  35135. if (typeof customRenderer === 'function') {
  35136. _this.options.customHandled = true;
  35137. _this.options.customRenderer = customRenderer;
  35138. } // TODO: URL Validator
  35139. return _this;
  35140. }
  35141. _createClass(Emoji, [{
  35142. key: "makeHtml",
  35143. value: function makeHtml(str, sentenceMakeFunc) {
  35144. var _this2 = this;
  35145. if (!this.test(str)) {
  35146. return str;
  35147. }
  35148. return str.replace(this.RULE.reg, function (match, emojiKey) {
  35149. var _context2;
  35150. // 先走自定义渲染逻辑
  35151. if (_this2.options.customHandled && typeof _this2.options.customRenderer === 'function') {
  35152. return _this2.options.customRenderer(emojiKey);
  35153. }
  35154. var emojiCode = _this2.options.emojis[emojiKey];
  35155. if (typeof emojiCode !== 'string') {
  35156. return match;
  35157. }
  35158. if (_this2.options.useUnicode) {
  35159. var _context;
  35160. var codes = map$3(_context = emojiCode.split('-')).call(_context, function (unicode) {
  35161. return "0x".concat(unicode);
  35162. }); // convert to hex string
  35163. return fromCodePoint$3.apply(void 0, _toConsumableArray(codes));
  35164. }
  35165. if (_this2.options.upperCase) {
  35166. emojiCode = emojiCode.toUpperCase();
  35167. }
  35168. var src = _this2.options.resourceURL.replace(/\$\{code\}/g, emojiCode);
  35169. return concat$5(_context2 = "<img class=\"emoji\" src=\"".concat(src, "\" alt=\"")).call(_context2, escapeHTMLSpecialCharOnce(emojiKey), "\" />");
  35170. });
  35171. }
  35172. }, {
  35173. key: "rule",
  35174. value: function rule() {
  35175. // (?<protocol>\\w+:)\\/\\/
  35176. var ret = {
  35177. // ?<left>
  35178. begin: ':',
  35179. content: '([a-zA-Z0-9+_]+?)',
  35180. // ?<right>
  35181. end: ':'
  35182. };
  35183. ret.reg = compileRegExp(ret, 'g');
  35184. return ret;
  35185. }
  35186. }]);
  35187. return Emoji;
  35188. }(SyntaxBase);
  35189. _defineProperty(Emoji, "HOOK_NAME", 'emoji');
  35190. function _createSuper$t(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$t(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  35191. function _isNativeReflectConstruct$t() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  35192. var Underline = /*#__PURE__*/function (_SyntaxBase) {
  35193. _inherits(Underline, _SyntaxBase);
  35194. var _super = _createSuper$t(Underline);
  35195. function Underline() {
  35196. _classCallCheck(this, Underline);
  35197. return _super.apply(this, arguments);
  35198. }
  35199. _createClass(Underline, [{
  35200. key: "makeHtml",
  35201. value: // constructor() {
  35202. // super();
  35203. // }
  35204. function makeHtml(str) {
  35205. if (!this.test(str)) {
  35206. return str;
  35207. }
  35208. return str.replace(this.RULE.reg, '$1<span style="text-decoration: underline;">$2</span>$3');
  35209. }
  35210. }, {
  35211. key: "rule",
  35212. value: function rule() {
  35213. var ret = {
  35214. begin: '(^| )\\/',
  35215. end: '\\/( |$)',
  35216. content: '([^\\n]+?)'
  35217. };
  35218. ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
  35219. return ret;
  35220. }
  35221. }]);
  35222. return Underline;
  35223. }(SyntaxBase);
  35224. _defineProperty(Underline, "HOOK_NAME", 'underline');
  35225. function _createSuper$u(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$u(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  35226. function _isNativeReflectConstruct$u() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  35227. var HighLight = /*#__PURE__*/function (_SyntaxBase) {
  35228. _inherits(HighLight, _SyntaxBase);
  35229. var _super = _createSuper$u(HighLight);
  35230. function HighLight() {
  35231. _classCallCheck(this, HighLight);
  35232. return _super.apply(this, arguments);
  35233. }
  35234. _createClass(HighLight, [{
  35235. key: "makeHtml",
  35236. value: function makeHtml(str) {
  35237. if (!this.test(str)) {
  35238. return str;
  35239. }
  35240. return str.replace(this.RULE.reg, '$1<mark>$2</mark>$3');
  35241. }
  35242. }, {
  35243. key: "rule",
  35244. value: function rule() {
  35245. var ret = {
  35246. begin: '(^| )==',
  35247. end: '==( |$|\\n)',
  35248. content: '([^\\n]+?)'
  35249. };
  35250. ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
  35251. return ret;
  35252. }
  35253. }]);
  35254. return HighLight;
  35255. }(SyntaxBase);
  35256. _defineProperty(HighLight, "HOOK_NAME", 'highLight');
  35257. // eslint-disable-next-line es-x/no-json -- safe
  35258. if (!path.JSON) path.JSON = { stringify: JSON.stringify };
  35259. // eslint-disable-next-line no-unused-vars -- required for `.length`
  35260. var stringify = function stringify(it, replacer, space) {
  35261. return functionApply(path.JSON.stringify, null, arguments);
  35262. };
  35263. var stringify$1 = stringify;
  35264. var stringify$2 = stringify$1;
  35265. var $includes = arrayIncludes.includes;
  35266. // FF99+ bug
  35267. var BROKEN_ON_SPARSE = fails(function () {
  35268. return !Array(1).includes();
  35269. });
  35270. // `Array.prototype.includes` method
  35271. // https://tc39.es/ecma262/#sec-array.prototype.includes
  35272. _export({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
  35273. includes: function includes(el /* , fromIndex = 0 */) {
  35274. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  35275. }
  35276. });
  35277. var includes = entryVirtual('Array').includes;
  35278. var stringIndexOf = functionUncurryThis(''.indexOf);
  35279. // `String.prototype.includes` method
  35280. // https://tc39.es/ecma262/#sec-string.prototype.includes
  35281. _export({ target: 'String', proto: true, forced: !correctIsRegexpLogic('includes') }, {
  35282. includes: function includes(searchString /* , position = 0 */) {
  35283. return !!~stringIndexOf(
  35284. toString_1(requireObjectCoercible(this)),
  35285. toString_1(notARegexp(searchString)),
  35286. arguments.length > 1 ? arguments[1] : undefined
  35287. );
  35288. }
  35289. });
  35290. var includes$1 = entryVirtual('String').includes;
  35291. var ArrayPrototype$d = Array.prototype;
  35292. var StringPrototype$3 = String.prototype;
  35293. var includes$2 = function (it) {
  35294. var own = it.includes;
  35295. if (it === ArrayPrototype$d || (objectIsPrototypeOf(ArrayPrototype$d, it) && own === ArrayPrototype$d.includes)) return includes;
  35296. if (typeof it == 'string' || it === StringPrototype$3 || (objectIsPrototypeOf(StringPrototype$3, it) && own === StringPrototype$3.includes)) {
  35297. return includes$1;
  35298. } return own;
  35299. };
  35300. var includes$3 = includes$2;
  35301. var includes$4 = includes$3;
  35302. /**
  35303. * A specialized version of `_.map` for arrays without support for iteratee
  35304. * shorthands.
  35305. *
  35306. * @private
  35307. * @param {Array} [array] The array to iterate over.
  35308. * @param {Function} iteratee The function invoked per iteration.
  35309. * @returns {Array} Returns the new mapped array.
  35310. */
  35311. function arrayMap(array, iteratee) {
  35312. var index = -1,
  35313. length = array == null ? 0 : array.length,
  35314. result = Array(length);
  35315. while (++index < length) {
  35316. result[index] = iteratee(array[index], index, array);
  35317. }
  35318. return result;
  35319. }
  35320. var _arrayMap = arrayMap;
  35321. /** `Object#toString` result references. */
  35322. var symbolTag = '[object Symbol]';
  35323. /**
  35324. * Checks if `value` is classified as a `Symbol` primitive or object.
  35325. *
  35326. * @static
  35327. * @memberOf _
  35328. * @since 4.0.0
  35329. * @category Lang
  35330. * @param {*} value The value to check.
  35331. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  35332. * @example
  35333. *
  35334. * _.isSymbol(Symbol.iterator);
  35335. * // => true
  35336. *
  35337. * _.isSymbol('abc');
  35338. * // => false
  35339. */
  35340. function isSymbol$1(value) {
  35341. return typeof value == 'symbol' ||
  35342. (isObjectLike_1(value) && _baseGetTag(value) == symbolTag);
  35343. }
  35344. var isSymbol_1 = isSymbol$1;
  35345. /** Used as references for various `Number` constants. */
  35346. var INFINITY = 1 / 0;
  35347. /** Used to convert symbols to primitives and strings. */
  35348. var symbolProto = _Symbol ? _Symbol.prototype : undefined,
  35349. symbolToString = symbolProto ? symbolProto.toString : undefined;
  35350. /**
  35351. * The base implementation of `_.toString` which doesn't convert nullish
  35352. * values to empty strings.
  35353. *
  35354. * @private
  35355. * @param {*} value The value to process.
  35356. * @returns {string} Returns the string.
  35357. */
  35358. function baseToString(value) {
  35359. // Exit early for strings to avoid a performance hit in some environments.
  35360. if (typeof value == 'string') {
  35361. return value;
  35362. }
  35363. if (isArray_1(value)) {
  35364. // Recursively convert values (susceptible to call stack limits).
  35365. return _arrayMap(value, baseToString) + '';
  35366. }
  35367. if (isSymbol_1(value)) {
  35368. return symbolToString ? symbolToString.call(value) : '';
  35369. }
  35370. var result = (value + '');
  35371. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  35372. }
  35373. var _baseToString = baseToString;
  35374. /**
  35375. * Converts `value` to a string. An empty string is returned for `null`
  35376. * and `undefined` values. The sign of `-0` is preserved.
  35377. *
  35378. * @static
  35379. * @memberOf _
  35380. * @since 4.0.0
  35381. * @category Lang
  35382. * @param {*} value The value to convert.
  35383. * @returns {string} Returns the converted string.
  35384. * @example
  35385. *
  35386. * _.toString(null);
  35387. * // => ''
  35388. *
  35389. * _.toString(-0);
  35390. * // => '-0'
  35391. *
  35392. * _.toString([1, 2, 3]);
  35393. * // => '1,2,3'
  35394. */
  35395. function toString$2(value) {
  35396. return value == null ? '' : _baseToString(value);
  35397. }
  35398. var toString_1$1 = toString$2;
  35399. /**
  35400. * Used to match `RegExp`
  35401. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  35402. */
  35403. var reRegExpChar$1 = /[\\^$.*+?()[\]{}|]/g,
  35404. reHasRegExpChar = RegExp(reRegExpChar$1.source);
  35405. /**
  35406. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  35407. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  35408. *
  35409. * @static
  35410. * @memberOf _
  35411. * @since 3.0.0
  35412. * @category String
  35413. * @param {string} [string=''] The string to escape.
  35414. * @returns {string} Returns the escaped string.
  35415. * @example
  35416. *
  35417. * _.escapeRegExp('[lodash](https://lodash.com/)');
  35418. * // => '\[lodash\]\(https://lodash\.com/\)'
  35419. */
  35420. function escapeRegExp(string) {
  35421. string = toString_1$1(string);
  35422. return (string && reHasRegExpChar.test(string))
  35423. ? string.replace(reRegExpChar$1, '\\$&')
  35424. : string;
  35425. }
  35426. var escapeRegExp_1 = escapeRegExp;
  35427. // handling this'.
  35428. var Pass = {
  35429. toString: function toString() {
  35430. return "CodeMirror.Pass";
  35431. }
  35432. }; // Reused option objects for setSelection & friends
  35433. function _createSuper$v(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$v(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  35434. function _isNativeReflectConstruct$v() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  35435. /**
  35436. * @typedef {import('codemirror')} CodeMirror
  35437. */
  35438. /**
  35439. * @typedef { Object } SuggestListItemObject 推荐列表项对象
  35440. * @property { string } icon 图标
  35441. * @property { string } label 候选列表回显的内容
  35442. * @property { string } value 点击候选项的时候回填的值
  35443. * @property { string } keyword 关键词,通过关键词控制候选项的显隐
  35444. * @typedef { SuggestListItemObject | string } SuggestListItem 推荐列表项
  35445. * @typedef { Array<SuggestListItem> } SuggestList 推荐列表
  35446. */
  35447. /**
  35448. * @typedef {object} SuggesterConfigItem
  35449. * @property {function(string, function(SuggestList): void): void} suggestList
  35450. * @property {string} keyword
  35451. * @property {function} suggestListRender
  35452. * @property {function} echo
  35453. * @typedef {object} SuggesterConfig
  35454. * @property {Array<SuggesterConfigItem>} suggester
  35455. */
  35456. var Suggester = /*#__PURE__*/function (_SyntaxBase) {
  35457. _inherits(Suggester, _SyntaxBase);
  35458. var _super = _createSuper$v(Suggester);
  35459. function Suggester(_ref) {
  35460. var _this;
  35461. var config = _ref.config;
  35462. _classCallCheck(this, Suggester);
  35463. /**
  35464. * config.suggester 内容
  35465. * [{
  35466. * 请求url
  35467. suggestList: '',
  35468. 唤醒关键字
  35469. keyword: '@',
  35470. 建议模板 function
  35471. suggestListRender(valueArray) {
  35472. },
  35473. 回填回调 function
  35474. echo(value) {
  35475. }]
  35476. *
  35477. */
  35478. _this = _super.call(this, {
  35479. needCache: true
  35480. });
  35481. _this.config = config;
  35482. _this.RULE = _this.rule();
  35483. return _this;
  35484. }
  35485. _createClass(Suggester, [{
  35486. key: "afterInit",
  35487. value: function afterInit(callback) {
  35488. if (typeof callback === 'function') {
  35489. callback();
  35490. }
  35491. this.initConfig(this.config);
  35492. }
  35493. /**
  35494. * 获取系统默认的候选项列表
  35495. * TODO:后面考虑增加层级机制,比如“公式”是一级,“集合、逻辑运算、方程式”是公式的二级候选值
  35496. */
  35497. }, {
  35498. key: "getSystemSuggestList",
  35499. value: function getSystemSuggestList() {
  35500. var locales = this.$locale;
  35501. var suggestList = [{
  35502. icon: 'h1',
  35503. label: locales['H1 Heading'],
  35504. keyword: 'head1',
  35505. value: '# '
  35506. }, {
  35507. icon: 'h2',
  35508. label: locales['H2 Heading'],
  35509. keyword: 'head2',
  35510. value: '## '
  35511. }, {
  35512. icon: 'h3',
  35513. label: locales['H3 Heading'],
  35514. keyword: 'head3',
  35515. value: '### '
  35516. }, {
  35517. icon: 'table',
  35518. label: locales.table,
  35519. keyword: 'table',
  35520. value: '| Header | Header | Header |\n| --- | --- | --- |\n| Content | Content | Content |\n'
  35521. }, {
  35522. icon: 'code',
  35523. label: locales.code,
  35524. keyword: 'code',
  35525. value: '```\n\n```\n'
  35526. }, {
  35527. icon: 'link',
  35528. label: locales.link,
  35529. keyword: 'link',
  35530. value: "[title](https://url)"
  35531. }, {
  35532. icon: 'checklist',
  35533. label: locales.checklist,
  35534. keyword: 'checklist',
  35535. value: "- [ ] item\n- [x] item"
  35536. }, {
  35537. icon: 'tips',
  35538. label: locales.panel,
  35539. keyword: 'panel tips info warning danger success',
  35540. value: "::: primary title\ncontent\n:::\n"
  35541. }, {
  35542. icon: 'insertFlow',
  35543. label: locales.detail,
  35544. keyword: 'detail',
  35545. value: "+++ \u70B9\u51FB\u5C55\u5F00\u66F4\u591A\n\u5185\u5BB9\n++- \u9ED8\u8BA4\u5C55\u5F00\n\u5185\u5BB9\n++ \u9ED8\u8BA4\u6536\u8D77\n\u5185\u5BB9\n+++\n"
  35546. } // {
  35547. // icon: 'pen',
  35548. // label: '续写',
  35549. // keyword: 'xu xie chatgpt',
  35550. // value: () => {
  35551. // if (!this.$engine.$cherry.options.openai.apiKey) {
  35552. // return '请先配置openai apiKey';
  35553. // }
  35554. // this.$engine.$cherry.toolbar.toolbarHandlers.chatgpt('complement');
  35555. // return `\n`;
  35556. // },
  35557. // },
  35558. // {
  35559. // icon: 'pen',
  35560. // label: '总结',
  35561. // keyword: 'zong jie chatgpt',
  35562. // value: () => {
  35563. // if (!this.$engine.$cherry.options.openai.apiKey) {
  35564. // return '请先配置openai apiKey';
  35565. // }
  35566. // this.$engine.$cherry.toolbar.toolbarHandlers.chatgpt('summary');
  35567. // return `\n`;
  35568. // },
  35569. // },
  35570. ];
  35571. return suggestList;
  35572. }
  35573. /**
  35574. * 初始化配置
  35575. * @param {SuggesterConfig} config
  35576. */
  35577. }, {
  35578. key: "initConfig",
  35579. value: function initConfig(config) {
  35580. var _this2 = this;
  35581. var suggester = config.suggester;
  35582. this.suggester = {};
  35583. if (!suggester) {
  35584. suggester = [];
  35585. }
  35586. var systemSuggestList = this.getSystemSuggestList(); // 默认的唤醒关键字
  35587. suggester.unshift({
  35588. keyword: '/',
  35589. suggestList: function suggestList(word, callback) {
  35590. var $word = word.replace(/^\//, ''); // 加个空格就直接退出联想
  35591. if (/^\s$/.test($word)) {
  35592. callback(false);
  35593. return;
  35594. }
  35595. var keyword = $word.replace(/\s+/g, '').split('').join('.*?');
  35596. var test = new RegExp("^.*?".concat(keyword, ".*?$"), 'i');
  35597. var suggestList = filter$3(systemSuggestList).call(systemSuggestList, function (item) {
  35598. // TODO: 首次联想的时候会把所有的候选项列出来,后续可以增加一些机制改成默认拉取一部分候选项
  35599. return !$word || test.test(item.keyword);
  35600. });
  35601. callback(suggestList);
  35602. }
  35603. });
  35604. forEach$3(suggester).call(suggester, function (configItem) {
  35605. if (!configItem.suggestList) {
  35606. console.warn('[cherry-suggester]: the suggestList of config is missing.');
  35607. return;
  35608. }
  35609. if (!configItem.keyword) {
  35610. configItem.keyword = '@';
  35611. }
  35612. _this2.suggester[configItem.keyword] = configItem;
  35613. }); // 反复初始化时, 缓存还在, dom 已更新情况
  35614. if (suggesterPanel.hasEditor()) {
  35615. suggesterPanel.editor = null;
  35616. }
  35617. }
  35618. }, {
  35619. key: "makeHtml",
  35620. value: function makeHtml(str) {
  35621. var _context2;
  35622. if (!this.RULE.reg) return str;
  35623. if (!suggesterPanel.hasEditor() && isBrowser()) {
  35624. var editor = this.$engine.$cherry.editor;
  35625. suggesterPanel.setEditor(editor);
  35626. suggesterPanel.setSuggester(this.suggester);
  35627. suggesterPanel.bindEvent();
  35628. }
  35629. if (isLookbehindSupported()) {
  35630. var _context;
  35631. return str.replace(this.RULE.reg, bind$5(_context = this.toHtml).call(_context, this));
  35632. }
  35633. return replaceLookbehind(str, this.RULE.reg, bind$5(_context2 = this.toHtml).call(_context2, this), true, 1);
  35634. }
  35635. }, {
  35636. key: "toHtml",
  35637. value: function toHtml(wholeMatch, leadingChar, keyword, text) {
  35638. var _this$suggester$keywo3;
  35639. if (text) {
  35640. var _this$suggester$keywo, _this$suggester$keywo2, _context3, _context4;
  35641. return ((_this$suggester$keywo = this.suggester[keyword]) === null || _this$suggester$keywo === void 0 ? void 0 : (_this$suggester$keywo2 = _this$suggester$keywo.echo) === null || _this$suggester$keywo2 === void 0 ? void 0 : _this$suggester$keywo2.call(this, text)) || concat$5(_context3 = concat$5(_context4 = "".concat(leadingChar, "<span class=\"cherry-suggestion\">")).call(_context4, keyword)).call(_context3, text, "</span>");
  35642. }
  35643. if (((_this$suggester$keywo3 = this.suggester[keyword]) === null || _this$suggester$keywo3 === void 0 ? void 0 : _this$suggester$keywo3.echo) === false) {
  35644. return "".concat(leadingChar);
  35645. }
  35646. if (!this.suggester[keyword]) {
  35647. return leadingChar + text;
  35648. }
  35649. return text ? leadingChar + text : "".concat(leadingChar);
  35650. }
  35651. }, {
  35652. key: "rule",
  35653. value: function rule() {
  35654. var _context5, _context6, _context7;
  35655. if (!this.suggester || keys$3(this.suggester).length <= 0) {
  35656. return {};
  35657. }
  35658. var keys = map$3(_context5 = keys$3(this.suggester)).call(_context5, function (key) {
  35659. return escapeRegExp_1(key);
  35660. }).join('|');
  35661. var reg = new RegExp(concat$5(_context6 = concat$5(_context7 = "".concat(isLookbehindSupported() ? '((?<!\\\\))[ ]' : '(^|[^\\\\])[ ]', "(")).call(_context7, keys, ")(([^")).call(_context6, keys, "\\s])+)"), 'g');
  35662. return {
  35663. reg: reg
  35664. };
  35665. }
  35666. }, {
  35667. key: "mounted",
  35668. value: function mounted() {
  35669. if (!suggesterPanel.hasEditor() && isBrowser()) {
  35670. var editor = this.$engine.$cherry.editor;
  35671. suggesterPanel.setEditor(editor);
  35672. suggesterPanel.setSuggester(this.suggester);
  35673. suggesterPanel.bindEvent();
  35674. }
  35675. }
  35676. }]);
  35677. return Suggester;
  35678. }(SyntaxBase);
  35679. _defineProperty(Suggester, "HOOK_NAME", 'suggester');
  35680. var SuggesterPanel = /*#__PURE__*/function () {
  35681. function SuggesterPanel() {
  35682. _classCallCheck(this, SuggesterPanel);
  35683. this.searchCache = false;
  35684. this.searchKeyCache = [];
  35685. this.optionList = [];
  35686. this.cursorMove = true;
  35687. this.suggesterConfig = {};
  35688. if (!this.$suggesterPanel && isBrowser() && document) {
  35689. var _document, _document$body, _document2;
  35690. (_document = document) === null || _document === void 0 ? void 0 : (_document$body = _document.body) === null || _document$body === void 0 ? void 0 : _document$body.appendChild(this.createDom(SuggesterPanel.panelWrap));
  35691. this.$suggesterPanel = (_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.querySelector('.cherry-suggester-panel');
  35692. }
  35693. }
  35694. _createClass(SuggesterPanel, [{
  35695. key: "hasEditor",
  35696. value: function hasEditor() {
  35697. return !!this.editor && !!this.editor.editor.display && !!this.editor.editor.display.wrapper;
  35698. }
  35699. /**
  35700. * 设置编辑器
  35701. * @param {import('@/Editor').default} editor
  35702. */
  35703. }, {
  35704. key: "setEditor",
  35705. value: function setEditor(editor) {
  35706. this.editor = editor;
  35707. }
  35708. }, {
  35709. key: "setSuggester",
  35710. value: function setSuggester(suggester) {
  35711. this.suggesterConfig = suggester;
  35712. }
  35713. }, {
  35714. key: "bindEvent",
  35715. value: function bindEvent() {
  35716. var _this3 = this;
  35717. var keyAction = false;
  35718. this.editor.editor.on('change', function (codemirror, evt) {
  35719. keyAction = true;
  35720. _this3.onCodeMirrorChange(codemirror, evt);
  35721. });
  35722. this.editor.editor.on('keydown', function (codemirror, evt) {
  35723. keyAction = true;
  35724. if (_this3.enableRelate()) {
  35725. _this3.onKeyDown(codemirror, evt);
  35726. }
  35727. });
  35728. this.editor.editor.on('cursorActivity', function () {
  35729. // 当编辑区光标位置改变时触发
  35730. if (!keyAction) {
  35731. _this3.stopRelate();
  35732. }
  35733. keyAction = false;
  35734. });
  35735. var extraKeys = this.editor.editor.getOption('extraKeys');
  35736. var decorateKeys = ['Up', 'Down', 'Enter'];
  35737. forEach$3(decorateKeys).call(decorateKeys, function (key) {
  35738. if (typeof extraKeys[key] === 'function') {
  35739. var proxyTarget = extraKeys[key];
  35740. extraKeys[key] = function (codemirror) {
  35741. if (suggesterPanel.cursorMove) {
  35742. var res = proxyTarget.call(codemirror, codemirror);
  35743. if (res) {
  35744. return res;
  35745. } // logic to decide whether to move up or not
  35746. // return Pass.toString();
  35747. }
  35748. };
  35749. } else if (!extraKeys[key]) {
  35750. extraKeys[key] = function () {
  35751. if (suggesterPanel.cursorMove) {
  35752. // logic to decide whether to move up or not
  35753. return Pass.toString();
  35754. }
  35755. };
  35756. } else if (typeof extraKeys[key] === 'string') {
  35757. var command = extraKeys[key];
  35758. extraKeys[key] = function (codemirror) {
  35759. if (suggesterPanel.cursorMove) {
  35760. _this3.editor.editor.execCommand(command); // logic to decide whether to move up or not
  35761. // return Pass.toString();
  35762. }
  35763. };
  35764. }
  35765. });
  35766. this.editor.editor.setOption('extraKeys', extraKeys);
  35767. this.editor.editor.on('scroll', function (codemirror, evt) {
  35768. if (!_this3.searchCache) {
  35769. return;
  35770. } // 当编辑器滚动时触发
  35771. _this3.relocatePanel(_this3.editor.editor);
  35772. });
  35773. this.onClickPancelItem();
  35774. }
  35775. }, {
  35776. key: "onClickPancelItem",
  35777. value: function onClickPancelItem() {
  35778. var _this4 = this;
  35779. this.$suggesterPanel.addEventListener('click', function (evt) {
  35780. var idx = isChildNode(_this4.$suggesterPanel, evt.target);
  35781. if (idx > -1) {
  35782. _this4.pasteSelectResult(idx);
  35783. }
  35784. _this4.stopRelate();
  35785. }, false);
  35786. function isChildNode(parent, node) {
  35787. var _context8;
  35788. var res = -1;
  35789. forEach$3(_context8 = parent.childNodes).call(_context8, function (item, idx) {
  35790. return item === node ? res = idx : '';
  35791. });
  35792. return res;
  35793. }
  35794. }
  35795. }, {
  35796. key: "showsuggesterPanel",
  35797. value: function showsuggesterPanel(_ref2) {
  35798. var left = _ref2.left,
  35799. top = _ref2.top,
  35800. items = _ref2.items;
  35801. if (!this.$suggesterPanel && isBrowser()) {
  35802. document.body.appendChild(this.createDom(SuggesterPanel.panelWrap));
  35803. this.$suggesterPanel = document.querySelector('.cherry-suggester-panel');
  35804. }
  35805. this.updatePanel(items);
  35806. this.$suggesterPanel.style.left = "".concat(left, "px");
  35807. this.$suggesterPanel.style.top = "".concat(top, "px");
  35808. this.$suggesterPanel.style.display = 'block';
  35809. this.$suggesterPanel.style.position = 'absolute';
  35810. this.$suggesterPanel.style.zIndex = '100';
  35811. }
  35812. }, {
  35813. key: "hidesuggesterPanel",
  35814. value: function hidesuggesterPanel() {
  35815. // const $suggesterPanel = document.querySelector('.cherry-suggester-panel');
  35816. if (this.$suggesterPanel) {
  35817. this.$suggesterPanel.style.display = 'none';
  35818. }
  35819. }
  35820. /**
  35821. * 更新suggesterPanel
  35822. * @param {SuggestList} suggestList
  35823. */
  35824. }, {
  35825. key: "updatePanel",
  35826. value: function updatePanel(suggestList) {
  35827. var _this5 = this;
  35828. var defaultValue = map$3(suggestList).call(suggestList, function (suggest, idx) {
  35829. if (_typeof(suggest) === 'object' && suggest !== null) {
  35830. var renderContent = suggest.label;
  35831. if (suggest !== null && suggest !== void 0 && suggest.icon) {
  35832. var _context9;
  35833. renderContent = concat$5(_context9 = "<i class=\"ch-icon ch-icon-".concat(suggest.icon, "\"></i>")).call(_context9, renderContent);
  35834. }
  35835. return _this5.renderPanelItem(renderContent, idx === 0);
  35836. }
  35837. return _this5.renderPanelItem(suggest, idx === 0);
  35838. }).join('');
  35839. /**
  35840. * @type { SuggesterConfigItem }
  35841. */
  35842. var suggesterConfig = this.suggesterConfig[this.keyword]; // 用户自定义渲染逻辑 suggestListRender
  35843. if (suggesterConfig && typeof suggesterConfig.suggestListRender === 'function') {
  35844. defaultValue = suggesterConfig.suggestListRender.call(this, suggestList) || defaultValue;
  35845. }
  35846. this.$suggesterPanel.innerHTML = ''; // 清空
  35847. if (typeof defaultValue === 'string') {
  35848. this.$suggesterPanel.innerHTML = defaultValue;
  35849. } else if (isArray$8(defaultValue) && defaultValue.length > 0) {
  35850. forEach$3(defaultValue).call(defaultValue, function (item) {
  35851. _this5.$suggesterPanel.appendChild(item);
  35852. });
  35853. } else if (_typeof(defaultValue) === 'object' && defaultValue.nodeType === 1) {
  35854. this.$suggesterPanel.appendChild(defaultValue);
  35855. }
  35856. }
  35857. /**
  35858. * 渲染suggesterPanel item
  35859. * @param {string} item 渲染内容
  35860. * @param {boolean} selected 是否选中
  35861. * @returns {string} html
  35862. */
  35863. }, {
  35864. key: "renderPanelItem",
  35865. value: function renderPanelItem(item, selected) {
  35866. if (selected) {
  35867. return "<div class=\"cherry-suggester-panel__item cherry-suggester-panel__item--selected\">".concat(item, "</div>");
  35868. }
  35869. return "<div class=\"cherry-suggester-panel__item\">".concat(item, "</div>");
  35870. }
  35871. }, {
  35872. key: "createDom",
  35873. value: function createDom() {
  35874. var string = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  35875. if (!this.template) {
  35876. this.template = document.createElement('div');
  35877. }
  35878. this.template.innerHTML = trim$3(string).call(string); // Change this to div.childNodes to support multiple top-level nodes
  35879. var frag = document.createDocumentFragment();
  35880. map$3(Array.prototype).call(this.template.childNodes, function (item, idx) {
  35881. frag.appendChild(item);
  35882. });
  35883. return frag;
  35884. } // 面板重定位
  35885. }, {
  35886. key: "relocatePanel",
  35887. value: function relocatePanel(codemirror) {
  35888. var $cursor = document.querySelector('.CodeMirror-cursors .CodeMirror-cursor');
  35889. if (!$cursor) {
  35890. return false;
  35891. }
  35892. var pos = codemirror.getCursor();
  35893. var lineHeight = codemirror.lineInfo(pos.line).handle.height;
  35894. var rect = $cursor.getBoundingClientRect();
  35895. var top = rect.top + lineHeight;
  35896. var left = rect.left;
  35897. this.showsuggesterPanel({
  35898. left: left,
  35899. top: top,
  35900. items: this.optionList
  35901. });
  35902. }
  35903. /**
  35904. * 获取光标位置
  35905. * @param {CodeMirror} codemirror
  35906. * @returns {{ left: number, top: number }}
  35907. */
  35908. }, {
  35909. key: "getCursorPos",
  35910. value: function getCursorPos(codemirror) {
  35911. var $cursor = document.querySelector('.CodeMirror-cursors .CodeMirror-cursor');
  35912. if (!$cursor) return null;
  35913. var pos = codemirror.getCursor();
  35914. var lineHeight = codemirror.lineInfo(pos.line).handle.height;
  35915. var rect = $cursor.getBoundingClientRect();
  35916. var top = rect.top + lineHeight;
  35917. var left = rect.left;
  35918. return {
  35919. left: left,
  35920. top: top
  35921. };
  35922. } // 开启关联
  35923. }, {
  35924. key: "startRelate",
  35925. value: function startRelate(codemirror, keyword, from) {
  35926. this.cursorFrom = from;
  35927. this.keyword = keyword;
  35928. this.searchCache = true;
  35929. this.relocatePanel(codemirror);
  35930. } // 关闭关联
  35931. }, {
  35932. key: "stopRelate",
  35933. value: function stopRelate() {
  35934. this.hidesuggesterPanel();
  35935. this.cursorFrom = null;
  35936. this.cursorTo = null;
  35937. this.keyword = '';
  35938. this.searchKeyCache = [];
  35939. this.searchCache = false;
  35940. this.cursorMove = true;
  35941. this.optionList = [];
  35942. }
  35943. /**
  35944. * 粘贴选择结果
  35945. * @param {number} idx 选择的结果索引
  35946. * @param {KeyboardEvent} evt 键盘事件
  35947. */
  35948. }, {
  35949. key: "pasteSelectResult",
  35950. value: function pasteSelectResult(idx, evt) {
  35951. if (!this.cursorTo) {
  35952. this.cursorTo = JSON.parse(stringify$2(this.cursorFrom));
  35953. }
  35954. if (!this.cursorTo) {
  35955. return;
  35956. }
  35957. this.cursorTo.ch += 1;
  35958. var cursorFrom = this.cursorFrom,
  35959. cursorTo = this.cursorTo; // 缓存光标位置
  35960. if (this.optionList[idx]) {
  35961. var result = '';
  35962. if (_typeof(this.optionList[idx]) === 'object' && this.optionList[idx] !== null && typeof this.optionList[idx].value === 'string') {
  35963. result = this.optionList[idx].value;
  35964. }
  35965. if (_typeof(this.optionList[idx]) === 'object' && this.optionList[idx] !== null && typeof this.optionList[idx].value === 'function') {
  35966. result = this.optionList[idx].value();
  35967. }
  35968. if (typeof this.optionList[idx] === 'string') {
  35969. var _context10;
  35970. result = concat$5(_context10 = " ".concat(this.keyword)).call(_context10, this.optionList[idx], " ");
  35971. } // this.cursorTo.ch = this.cursorFrom.ch + result.length;
  35972. if (result) {
  35973. this.editor.editor.replaceRange(result, cursorFrom, cursorTo);
  35974. }
  35975. }
  35976. }
  35977. /**
  35978. * 寻找当前选中项的索引
  35979. * @returns {number}
  35980. */
  35981. }, {
  35982. key: "findSelectedItemIndex",
  35983. value: function findSelectedItemIndex() {
  35984. return findIndex$3(Array.prototype).call(this.$suggesterPanel.childNodes, function (item) {
  35985. return item.classList.contains('cherry-suggester-panel__item--selected');
  35986. });
  35987. }
  35988. }, {
  35989. key: "enableRelate",
  35990. value: function enableRelate() {
  35991. return this.searchCache;
  35992. }
  35993. /**
  35994. * codeMirror change事件
  35995. * @param {CodeMirror.Editor} codemirror
  35996. * @param {CodeMirror.EditorChange} evt
  35997. * @returns
  35998. */
  35999. }, {
  36000. key: "onCodeMirrorChange",
  36001. value: function onCodeMirrorChange(codemirror, evt) {
  36002. var _this6 = this;
  36003. var text = evt.text,
  36004. from = evt.from,
  36005. to = evt.to,
  36006. origin = evt.origin;
  36007. var changeValue = text.length === 1 ? text[0] : ''; // 首次输入命中关键词的时候开启联想
  36008. if (!this.enableRelate() && this.suggesterConfig[changeValue]) {
  36009. this.startRelate(codemirror, changeValue, from);
  36010. }
  36011. if (this.enableRelate() && (changeValue || origin === '+delete')) {
  36012. var _this$suggesterConfig;
  36013. this.cursorTo = to;
  36014. if (changeValue) {
  36015. this.searchKeyCache.push(changeValue);
  36016. } else if (origin === '+delete') {
  36017. this.searchKeyCache.pop();
  36018. if (this.searchKeyCache.length === 0) {
  36019. this.stopRelate();
  36020. return;
  36021. }
  36022. } // 展示推荐列表
  36023. if (typeof ((_this$suggesterConfig = this.suggesterConfig[this.keyword]) === null || _this$suggesterConfig === void 0 ? void 0 : _this$suggesterConfig.suggestList) === 'function') {
  36024. // 请求api 返回结果拼凑
  36025. this.suggesterConfig[this.keyword].suggestList(this.searchKeyCache.join(''), function (res) {
  36026. // 如果返回了false,则强制退出联想
  36027. if (res === false) {
  36028. _this6.stopRelate();
  36029. return;
  36030. } // 回显命中的结果
  36031. _this6.optionList = !res || !res.length ? [] : res;
  36032. _this6.updatePanel(_this6.optionList);
  36033. });
  36034. }
  36035. }
  36036. }
  36037. /**
  36038. * 监听方向键选择 options
  36039. * @param {CodeMirror.Editor} codemirror
  36040. * @param {KeyboardEvent} evt
  36041. */
  36042. }, {
  36043. key: "onKeyDown",
  36044. value: function onKeyDown(codemirror, evt) {
  36045. var _context11,
  36046. _this7 = this;
  36047. if (!this.$suggesterPanel) {
  36048. return false;
  36049. }
  36050. var keyCode = evt.keyCode; // up down
  36051. if (includes$4(_context11 = [38, 40]).call(_context11, keyCode)) {
  36052. this.cursorMove = false;
  36053. var selectedItem = this.$suggesterPanel.querySelector('.cherry-suggester-panel__item--selected');
  36054. var nextElement = null;
  36055. if (keyCode === 38 && !selectedItem.previousElementSibling) {
  36056. nextElement = this.$suggesterPanel.lastElementChild; // codemirror.focus();
  36057. } else if (keyCode === 40 && !selectedItem.nextElementSibling) {
  36058. nextElement = this.$suggesterPanel.firstElementChild; // codemirror.focus();
  36059. } else {
  36060. if (keyCode === 38) {
  36061. nextElement = selectedItem.previousElementSibling;
  36062. } else if (keyCode === 40) {
  36063. nextElement = selectedItem.nextElementSibling;
  36064. }
  36065. }
  36066. selectedItem.classList.remove('cherry-suggester-panel__item--selected');
  36067. nextElement.classList.add('cherry-suggester-panel__item--selected');
  36068. } else if (keyCode === 13) {
  36069. evt.stopPropagation();
  36070. this.cursorMove = false;
  36071. this.pasteSelectResult(this.findSelectedItemIndex(), evt);
  36072. codemirror.focus(); // const cache = JSON.parse(JSON.stringify(this.cursorTo));
  36073. // setTimeout(() => {
  36074. // codemirror.setCursor(cache);
  36075. // }, 100);
  36076. setTimeout$3(function () {
  36077. _this7.stopRelate();
  36078. }, 0);
  36079. } else if (keyCode === 27) {
  36080. // 按下esc的时候退出联想
  36081. evt.stopPropagation();
  36082. codemirror.focus();
  36083. setTimeout$3(function () {
  36084. _this7.stopRelate();
  36085. }, 0);
  36086. }
  36087. }
  36088. }]);
  36089. return SuggesterPanel;
  36090. }();
  36091. _defineProperty(SuggesterPanel, "panelWrap", "<div class=\"cherry-suggester-panel\"></div>");
  36092. var suggesterPanel = new SuggesterPanel();
  36093. function _createSuper$w(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$w(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  36094. function _isNativeReflectConstruct$w() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  36095. var Ruby = /*#__PURE__*/function (_SyntaxBase) {
  36096. _inherits(Ruby, _SyntaxBase);
  36097. var _super = _createSuper$w(Ruby);
  36098. function Ruby() {
  36099. _classCallCheck(this, Ruby);
  36100. return _super.apply(this, arguments);
  36101. }
  36102. _createClass(Ruby, [{
  36103. key: "makeHtml",
  36104. value: function makeHtml(str) {
  36105. if (!this.test(str)) {
  36106. return str;
  36107. }
  36108. return str.replace(this.RULE.reg, "$1<ruby>$2<rt>$3</rt></ruby>$4");
  36109. }
  36110. }, {
  36111. key: "rule",
  36112. value: function rule() {
  36113. var ret = {
  36114. begin: '(^| )\\{',
  36115. end: '\\}( |$)',
  36116. content: '([^\n]+?)\\|([^\n]+?)'
  36117. };
  36118. ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
  36119. return ret;
  36120. }
  36121. }]);
  36122. return Ruby;
  36123. }(SyntaxBase);
  36124. _defineProperty(Ruby, "HOOK_NAME", 'ruby');
  36125. function _createSuper$x(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$x(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  36126. function _isNativeReflectConstruct$x() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  36127. /**
  36128. * 面板语法
  36129. * 例:
  36130. * :::tip
  36131. * 这是一段提示信息
  36132. * :::
  36133. * :::warning
  36134. * 这是一段警告信息
  36135. * :::
  36136. * :::danger
  36137. * 这是一段危险信息
  36138. * :::
  36139. */
  36140. var Panel = /*#__PURE__*/function (_ParagraphBase) {
  36141. _inherits(Panel, _ParagraphBase);
  36142. var _super = _createSuper$x(Panel);
  36143. function Panel(options) {
  36144. var _this;
  36145. _classCallCheck(this, Panel);
  36146. _this = _super.call(this, {
  36147. needCache: true
  36148. });
  36149. _this.initBrReg(options.globalConfig.classicBr);
  36150. return _this;
  36151. }
  36152. _createClass(Panel, [{
  36153. key: "makeHtml",
  36154. value: function makeHtml(str, sentenceMakeFunc) {
  36155. var _this2 = this;
  36156. return str.replace(this.RULE.reg, function (match, preLines, name, content) {
  36157. var _context, _context2, _context3, _context4, _context5;
  36158. var lineCount = _this2.getLineCount(match, preLines);
  36159. var sign = _this2.$engine.md5(match);
  36160. var _this2$$getPanelInfo = _this2.$getPanelInfo(name, content, sentenceMakeFunc),
  36161. title = _this2$$getPanelInfo.title,
  36162. body = _this2$$getPanelInfo.body,
  36163. appendStyle = _this2$$getPanelInfo.appendStyle,
  36164. className = _this2$$getPanelInfo.className;
  36165. var ret = _this2.pushCache(concat$5(_context = concat$5(_context2 = concat$5(_context3 = concat$5(_context4 = concat$5(_context5 = "<div class=\"".concat(className, "\" data-sign=\"")).call(_context5, sign, "\" data-lines=\"")).call(_context4, lineCount, "\" ")).call(_context3, appendStyle, ">")).call(_context2, title)).call(_context, body, "</div>"), sign, lineCount);
  36166. return prependLineFeedForParagraph(match, ret);
  36167. });
  36168. }
  36169. }, {
  36170. key: "$getClassByType",
  36171. value: function $getClassByType(type) {
  36172. if (/(left|right|center)/i.test(type)) {
  36173. return "cherry-text-align cherry-text-align__".concat(type);
  36174. }
  36175. return "cherry-panel cherry-panel__".concat(type);
  36176. }
  36177. }, {
  36178. key: "$getPanelInfo",
  36179. value: function $getPanelInfo(name, str, sentenceMakeFunc) {
  36180. var _context6,
  36181. _this3 = this;
  36182. var ret = {
  36183. type: this.$getTargetType(name),
  36184. title: sentenceMakeFunc(this.$getTitle(name)).html,
  36185. body: str,
  36186. appendStyle: '',
  36187. className: ''
  36188. };
  36189. ret.className = this.$getClassByType(ret.type);
  36190. if (/(left|right|center)/i.test(ret.type)) {
  36191. ret.appendStyle = "style=\"text-align:".concat(ret.type, ";\"");
  36192. }
  36193. ret.title = concat$5(_context6 = "<div class=\"cherry-panel--title ".concat(ret.title ? 'cherry-panel--title__not-empty' : '', "\">")).call(_context6, ret.title, "</div>");
  36194. var paragraphProcessor = function paragraphProcessor(str) {
  36195. var _context7, _context8;
  36196. if (trim$3(str).call(str) === '') {
  36197. return '';
  36198. } // 调用行内语法,获得段落的签名和对应html内容
  36199. var _sentenceMakeFunc = sentenceMakeFunc(str),
  36200. html = _sentenceMakeFunc.html;
  36201. var domName = 'p'; // 如果包含html块级标签(比如div、blockquote等),则当前段落外层用div包裹,反之用p包裹
  36202. var isContainBlockTest = new RegExp("<(".concat(blockNames, ")[^>]*>"), 'i');
  36203. if (isContainBlockTest.test(html)) {
  36204. domName = 'div';
  36205. }
  36206. return concat$5(_context7 = concat$5(_context8 = "<".concat(domName, ">")).call(_context8, _this3.$cleanParagraph(html), "</")).call(_context7, domName, ">");
  36207. };
  36208. var $body = '';
  36209. if (this.isContainsCache(ret.body)) {
  36210. $body = this.makeExcludingCached(ret.body, paragraphProcessor);
  36211. } else {
  36212. $body = paragraphProcessor(ret.body);
  36213. }
  36214. ret.body = "<div class=\"cherry-panel--body\">".concat($body, "</div>");
  36215. return ret;
  36216. }
  36217. }, {
  36218. key: "$getTitle",
  36219. value: function $getTitle(name) {
  36220. var $name = trim$3(name).call(name);
  36221. return /\s/.test($name) ? $name.replace(/[^\s]+\s/, '') : '';
  36222. }
  36223. }, {
  36224. key: "$getTargetType",
  36225. value: function $getTargetType(name) {
  36226. var $name = /\s/.test(trim$3(name).call(name)) ? trim$3(name).call(name).replace(/\s.*$/, '') : name;
  36227. switch (trim$3($name).call($name).toLowerCase()) {
  36228. case 'primary':
  36229. case 'p':
  36230. return 'primary';
  36231. case 'info':
  36232. case 'i':
  36233. return 'info';
  36234. case 'warning':
  36235. case 'w':
  36236. return 'warning';
  36237. case 'danger':
  36238. case 'd':
  36239. return 'danger';
  36240. case 'success':
  36241. case 's':
  36242. return 'success';
  36243. case 'right':
  36244. case 'r':
  36245. return 'right';
  36246. case 'center':
  36247. case 'c':
  36248. return 'center';
  36249. case 'left':
  36250. case 'l':
  36251. return 'left';
  36252. default:
  36253. return 'primary';
  36254. }
  36255. }
  36256. }, {
  36257. key: "rule",
  36258. value: function rule() {
  36259. return getPanelRule();
  36260. }
  36261. }]);
  36262. return Panel;
  36263. }(ParagraphBase);
  36264. _defineProperty(Panel, "HOOK_NAME", 'panel');
  36265. function _createSuper$y(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$y(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  36266. function _isNativeReflectConstruct$y() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  36267. /**
  36268. * +++(-) 点击查看详情
  36269. * body
  36270. * body
  36271. * ++ 标题(默认收起内容)
  36272. * 内容
  36273. * ++- 标题(默认展开内容)
  36274. * 内容2
  36275. * +++
  36276. */
  36277. var Detail = /*#__PURE__*/function (_ParagraphBase) {
  36278. _inherits(Detail, _ParagraphBase);
  36279. var _super = _createSuper$y(Detail);
  36280. function Detail() {
  36281. _classCallCheck(this, Detail);
  36282. return _super.call(this, {
  36283. needCache: true
  36284. });
  36285. }
  36286. _createClass(Detail, [{
  36287. key: "makeHtml",
  36288. value: function makeHtml(str, sentenceMakeFunc) {
  36289. var _this = this;
  36290. return str.replace(this.RULE.reg, function (match, preLines, isOpen, title, content) {
  36291. var _context, _context2, _context3;
  36292. var lineCount = _this.getLineCount(match, preLines);
  36293. var sign = _this.$engine.md5(match);
  36294. var _this$$getDetailInfo = _this.$getDetailInfo(isOpen, title, content, sentenceMakeFunc),
  36295. type = _this$$getDetailInfo.type,
  36296. html = _this$$getDetailInfo.html;
  36297. var ret = _this.pushCache(concat$5(_context = concat$5(_context2 = concat$5(_context3 = "<div class=\"cherry-detail cherry-detail__".concat(type, "\" data-sign=\"")).call(_context3, sign, "\" data-lines=\"")).call(_context2, lineCount, "\" >")).call(_context, html, "</div>"), sign, lineCount);
  36298. return prependLineFeedForParagraph(match, ret);
  36299. });
  36300. }
  36301. }, {
  36302. key: "$getDetailInfo",
  36303. value: function $getDetailInfo(isOpen, title, str, sentenceMakeFunc) {
  36304. var _this2 = this;
  36305. var type = /\n\s*(\+\+|\+\+-)\s*[^\n]+\n/.test(str) ? 'multiple' : 'single';
  36306. var arr = str.split(/\n\s*(\+\+[-]{0,1}\s*[^\n]+)\n/);
  36307. var defaultOpen = isOpen === '-';
  36308. var currentTitle = title;
  36309. var html = '';
  36310. if (type === 'multiple') {
  36311. forEach$3(arr).call(arr, function (item) {
  36312. if (/\+\+/.test(item)) {
  36313. defaultOpen = /\+\+-/.test(item);
  36314. currentTitle = item.replace(/\+\+[-]{0,1}\s*([^\n]+)$/, '$1');
  36315. return true;
  36316. }
  36317. html += _this2.$getDetailHtml(defaultOpen, currentTitle, item, sentenceMakeFunc);
  36318. });
  36319. } else {
  36320. html = this.$getDetailHtml(defaultOpen, currentTitle, str, sentenceMakeFunc);
  36321. }
  36322. return {
  36323. type: type,
  36324. html: html
  36325. };
  36326. }
  36327. }, {
  36328. key: "$getDetailHtml",
  36329. value: function $getDetailHtml(defaultOpen, title, str, sentenceMakeFunc) {
  36330. var _this3 = this;
  36331. var ret = "<details ".concat(defaultOpen ? 'open' : '', ">");
  36332. var paragraphProcessor = function paragraphProcessor(str) {
  36333. var _context4, _context5;
  36334. if (trim$3(str).call(str) === '') {
  36335. return '';
  36336. } // 调用行内语法,获得段落的签名和对应html内容
  36337. var _sentenceMakeFunc = sentenceMakeFunc(str),
  36338. html = _sentenceMakeFunc.html;
  36339. var domName = 'p'; // 如果包含html块级标签(比如div、blockquote等),则当前段落外层用div包裹,反之用p包裹
  36340. var isContainBlockTest = new RegExp("<(".concat(blockNames, ")[^>]*>"), 'i');
  36341. if (isContainBlockTest.test(html)) {
  36342. domName = 'div';
  36343. }
  36344. return concat$5(_context4 = concat$5(_context5 = "<".concat(domName, ">")).call(_context5, _this3.$cleanParagraph(html), "</")).call(_context4, domName, ">");
  36345. };
  36346. ret += "<summary>".concat(sentenceMakeFunc(title).html, "</summary>");
  36347. var $body = '';
  36348. if (this.isContainsCache(str)) {
  36349. $body = this.makeExcludingCached(str, paragraphProcessor);
  36350. } else {
  36351. $body = paragraphProcessor(str);
  36352. }
  36353. ret += "<div class=\"cherry-detail-body\">".concat($body, "</div>");
  36354. ret += "</details>";
  36355. return ret;
  36356. }
  36357. }, {
  36358. key: "rule",
  36359. value: function rule() {
  36360. return getDetailRule();
  36361. }
  36362. }]);
  36363. return Detail;
  36364. }(ParagraphBase);
  36365. _defineProperty(Detail, "HOOK_NAME", 'detail');
  36366. /**
  36367. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  36368. *
  36369. * Licensed under the Apache License, Version 2.0 (the "License");
  36370. * you may not use this file except in compliance with the License.
  36371. * You may obtain a copy of the License at
  36372. *
  36373. * http://www.apache.org/licenses/LICENSE-2.0
  36374. *
  36375. * Unless required by applicable law or agreed to in writing, software
  36376. * distributed under the License is distributed on an "AS IS" BASIS,
  36377. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  36378. * See the License for the specific language governing permissions and
  36379. * limitations under the License.
  36380. */
  36381. /**
  36382. * 引擎各语法的配置
  36383. * 主要决定支持哪些语法,以及各语法的执行顺序
  36384. */
  36385. var hooksConfig = [// 段落级 Hook
  36386. // 引擎会按当前排序顺序执行beforeMake、makeHtml方法
  36387. // 引擎会按当前排序逆序执行afterMake方法
  36388. CodeBlock, InlineCode, MathBlock, InlineMath, HtmlBlock, Footnote, CommentReference, Transfer, Br, Table, Blockquote, Toc, Header, // 处理标题, 传入strict属性严格要求ATX风格标题#后带空格
  36389. Hr, List, Detail, Panel, Paragraph, // 普通段落
  36390. // 行内Hook
  36391. // 引擎会按当前顺序执行makeHtml方法
  36392. Emoji, Image$1, Link, AutoLink, Emphasis, BackgroundColor, Color, Size, Sub, Sup, Ruby, Strikethrough, Underline, HighLight, Suggester];
  36393. var Engine = /*#__PURE__*/function () {
  36394. /**
  36395. *
  36396. * @param {Partial<import('./Cherry').CherryOptions>} markdownParams 初始化Cherry时传入的选项
  36397. * @param {import('./Cherry').default} cherry Cherry实例
  36398. */
  36399. function Engine(markdownParams, cherry) {
  36400. _classCallCheck(this, Engine);
  36401. this.$cherry = cherry; // Deprecated
  36402. defineProperty$5(this, '_cherry', {
  36403. get: function get() {
  36404. Logger.warn('`_engine._cherry` is deprecated. Use `$engine.$cherry` instead.');
  36405. return this.$cherry;
  36406. }
  36407. });
  36408. this.initMath(markdownParams);
  36409. this.$configInit(markdownParams);
  36410. this.hookCenter = new HookCenter(hooksConfig, markdownParams, cherry);
  36411. this.hooks = this.hookCenter.getHookList();
  36412. this.md5Cache = {};
  36413. this.md5StrMap = {};
  36414. this.markdownParams = markdownParams;
  36415. this.currentStrMd5 = [];
  36416. this.htmlWhiteListAppend = markdownParams.engine.global.htmlWhiteList;
  36417. }
  36418. _createClass(Engine, [{
  36419. key: "initMath",
  36420. value: function initMath(opts) {
  36421. // 无论MathJax还是Katex,都可以先进行MathJax配置
  36422. var externals = opts.externals,
  36423. engine = opts.engine;
  36424. var syntax = engine.syntax;
  36425. var plugins = syntax.mathBlock.plugins; // 未开启公式
  36426. if (!isBrowser() || !syntax.mathBlock.src && !syntax.inlineMath.src) {
  36427. return;
  36428. } // 已经加载过MathJax
  36429. if (externals.MathJax || window.MathJax) {
  36430. return;
  36431. }
  36432. configureMathJax(plugins); // 等待MathJax各种插件加载
  36433. var script = document.createElement('script');
  36434. script.src = syntax.mathBlock.src ? syntax.mathBlock.src : syntax.inlineMath.src;
  36435. script.async = true;
  36436. if (script.src) document.head.appendChild(script);
  36437. }
  36438. }, {
  36439. key: "$configInit",
  36440. value: function $configInit(params) {
  36441. if (params.hooksConfig && $expectTarget(params.hooksConfig.hooksList, Array)) {
  36442. for (var key = 0; key < params.hooksConfig.hooksList.length; key++) {
  36443. var hook = params.hooksConfig.hooksList[key];
  36444. try {
  36445. if (hook.getType() === 'sentence') {
  36446. $expectInherit(hook, SyntaxBase);
  36447. }
  36448. if (hook.getType() === 'paragraph') {
  36449. $expectInherit(hook, ParagraphBase);
  36450. }
  36451. $expectInstance(hook);
  36452. hooksConfig.push(hook);
  36453. } catch (e) {
  36454. throw new Error('the hook does not correctly inherit');
  36455. }
  36456. }
  36457. }
  36458. }
  36459. }, {
  36460. key: "$beforeMakeHtml",
  36461. value: function $beforeMakeHtml(str) {
  36462. var $str = str.replace(/~/g, '~T');
  36463. $str = $str.replace(/\$/g, '~D');
  36464. $str = $str.replace(/\r\n/g, '\n'); // DOS to Unix
  36465. $str = $str.replace(/\r/g, '\n'); // Mac to Unix
  36466. // 避免正则性能问题,如/.+\n/.test(' '.repeat(99999)), 回溯次数过多
  36467. // 参考文章:http://www.alloyteam.com/2019/07/13574/
  36468. if ($str[$str.length - 1] !== '\n') {
  36469. $str += '\n';
  36470. }
  36471. $str = this.$fireHookAction($str, 'sentence', 'beforeMakeHtml');
  36472. $str = this.$fireHookAction($str, 'paragraph', 'beforeMakeHtml');
  36473. return $str;
  36474. }
  36475. }, {
  36476. key: "$afterMakeHtml",
  36477. value: function $afterMakeHtml(str) {
  36478. var $str = this.$fireHookAction(str, 'paragraph', 'afterMakeHtml'); // str = this._fireHookAction(str, 'sentence', 'afterMakeHtml');
  36479. $str = $str.replace(/~D/g, '$');
  36480. $str = $str.replace(/~T/g, '~');
  36481. $str = $str.replace(/\\<\//g, '\\ </');
  36482. $str = $str.replace(new RegExp("\\\\(".concat(PUNCTUATION, ")"), 'g'), function (match, escapeChar) {
  36483. if (escapeChar === '&') {
  36484. // & 字符需要特殊处理
  36485. return match;
  36486. }
  36487. return escapeHTMLSpecialChar(escapeChar);
  36488. }).replace(/\\&(?!(amp|lt|gt|quot|apos);)/, function () {
  36489. return '&amp;';
  36490. });
  36491. $str = $str.replace(/\\ <\//g, '\\</');
  36492. $str = $str.replace(/id="safe_(?=.*?")/g, 'id="'); // transform header id to avoid being sanitized
  36493. $str = UrlCache.restoreAll($str);
  36494. return $str;
  36495. }
  36496. }, {
  36497. key: "$dealSentenceByCache",
  36498. value: function $dealSentenceByCache(md) {
  36499. var _this = this;
  36500. return this.$checkCache(md, function (str) {
  36501. return _this.$dealSentence(str);
  36502. });
  36503. }
  36504. }, {
  36505. key: "$dealSentence",
  36506. value: function $dealSentence(md) {
  36507. var _context;
  36508. return this.$fireHookAction(md, 'sentence', 'makeHtml', bind$5(_context = this.$dealSentenceByCache).call(_context, this));
  36509. }
  36510. }, {
  36511. key: "$fireHookAction",
  36512. value: function $fireHookAction(md, type, action, actionArgs) {
  36513. var _this2 = this;
  36514. var $md = md;
  36515. var method = action === 'afterMakeHtml' ? 'reduceRight' : 'reduce';
  36516. if (!this.hooks && !this.hooks[type] && !this.hooks[type][method]) {
  36517. return $md;
  36518. }
  36519. try {
  36520. $md = this.hooks[type][method](function (newMd, oneHook) {
  36521. if (!oneHook.$engine) {
  36522. oneHook.$engine = _this2; // Deprecated
  36523. defineProperty$5(oneHook, '_engine', {
  36524. get: function get() {
  36525. Logger.warn('`this._engine` is deprecated. Use `this.$engine` instead.');
  36526. return this.$engine;
  36527. }
  36528. });
  36529. }
  36530. if (!oneHook[action]) {
  36531. return newMd;
  36532. }
  36533. return oneHook[action](newMd, actionArgs, _this2.markdownParams);
  36534. }, $md);
  36535. } catch (e) {
  36536. throw new NestedError(e);
  36537. }
  36538. return $md;
  36539. }
  36540. }, {
  36541. key: "md5",
  36542. value: function md5$1(str) {
  36543. if (!this.md5StrMap[str]) {
  36544. this.md5StrMap[str] = md5(str);
  36545. }
  36546. return this.md5StrMap[str];
  36547. }
  36548. }, {
  36549. key: "$checkCache",
  36550. value: function $checkCache(str, func) {
  36551. var sign = this.md5(str);
  36552. if (typeof this.md5Cache[sign] === 'undefined') {
  36553. this.md5Cache[sign] = func(str);
  36554. {
  36555. // 生产环境屏蔽
  36556. // Logger.log('markdown引擎渲染了:', str);
  36557. }
  36558. }
  36559. return {
  36560. sign: sign,
  36561. html: this.md5Cache[sign]
  36562. };
  36563. }
  36564. }, {
  36565. key: "$dealParagraph",
  36566. value: function $dealParagraph(md) {
  36567. var _context2;
  36568. return this.$fireHookAction(md, 'paragraph', 'makeHtml', bind$5(_context2 = this.$dealSentenceByCache).call(_context2, this));
  36569. }
  36570. }, {
  36571. key: "makeHtml",
  36572. value: function makeHtml(md) {
  36573. var $md = this.$beforeMakeHtml(md);
  36574. $md = this.$dealParagraph($md);
  36575. $md = this.$afterMakeHtml($md);
  36576. return $md;
  36577. }
  36578. }, {
  36579. key: "mounted",
  36580. value: function mounted() {
  36581. this.$fireHookAction('', 'sentence', 'mounted');
  36582. this.$fireHookAction('', 'paragraph', 'mounted'); // UrlCache.clear();
  36583. }
  36584. }, {
  36585. key: "makeMarkdown",
  36586. value: function makeMarkdown(html) {
  36587. return htmlParser.run(html);
  36588. }
  36589. }]);
  36590. return Engine;
  36591. }();
  36592. var nativeIsArray = Array.isArray;
  36593. var toString$3 = Object.prototype.toString;
  36594. var xIsArray = nativeIsArray || isArray$9;
  36595. function isArray$9(obj) {
  36596. return toString$3.call(obj) === "[object Array]"
  36597. }
  36598. var version$1 = "2";
  36599. var isVnode = isVirtualNode;
  36600. function isVirtualNode(x) {
  36601. return x && x.type === "VirtualNode" && x.version === version$1
  36602. }
  36603. var isWidget_1 = isWidget;
  36604. function isWidget(w) {
  36605. return w && w.type === "Widget"
  36606. }
  36607. var isThunk_1 = isThunk;
  36608. function isThunk(t) {
  36609. return t && t.type === "Thunk"
  36610. }
  36611. var isVhook = isHook;
  36612. function isHook(hook) {
  36613. return hook &&
  36614. (typeof hook.hook === "function" && !hook.hasOwnProperty("hook") ||
  36615. typeof hook.unhook === "function" && !hook.hasOwnProperty("unhook"))
  36616. }
  36617. var vnode = VirtualNode;
  36618. var noProperties = {};
  36619. var noChildren = [];
  36620. function VirtualNode(tagName, properties, children, key, namespace) {
  36621. this.tagName = tagName;
  36622. this.properties = properties || noProperties;
  36623. this.children = children || noChildren;
  36624. this.key = key != null ? String(key) : undefined;
  36625. this.namespace = (typeof namespace === "string") ? namespace : null;
  36626. var count = (children && children.length) || 0;
  36627. var descendants = 0;
  36628. var hasWidgets = false;
  36629. var hasThunks = false;
  36630. var descendantHooks = false;
  36631. var hooks;
  36632. for (var propName in properties) {
  36633. if (properties.hasOwnProperty(propName)) {
  36634. var property = properties[propName];
  36635. if (isVhook(property) && property.unhook) {
  36636. if (!hooks) {
  36637. hooks = {};
  36638. }
  36639. hooks[propName] = property;
  36640. }
  36641. }
  36642. }
  36643. for (var i = 0; i < count; i++) {
  36644. var child = children[i];
  36645. if (isVnode(child)) {
  36646. descendants += child.count || 0;
  36647. if (!hasWidgets && child.hasWidgets) {
  36648. hasWidgets = true;
  36649. }
  36650. if (!hasThunks && child.hasThunks) {
  36651. hasThunks = true;
  36652. }
  36653. if (!descendantHooks && (child.hooks || child.descendantHooks)) {
  36654. descendantHooks = true;
  36655. }
  36656. } else if (!hasWidgets && isWidget_1(child)) {
  36657. if (typeof child.destroy === "function") {
  36658. hasWidgets = true;
  36659. }
  36660. } else if (!hasThunks && isThunk_1(child)) {
  36661. hasThunks = true;
  36662. }
  36663. }
  36664. this.count = count + descendants;
  36665. this.hasWidgets = hasWidgets;
  36666. this.hasThunks = hasThunks;
  36667. this.hooks = hooks;
  36668. this.descendantHooks = descendantHooks;
  36669. }
  36670. VirtualNode.prototype.version = version$1;
  36671. VirtualNode.prototype.type = "VirtualNode";
  36672. var vtext = VirtualText;
  36673. function VirtualText(text) {
  36674. this.text = String(text);
  36675. }
  36676. VirtualText.prototype.version = version$1;
  36677. VirtualText.prototype.type = "VirtualText";
  36678. var isVtext = isVirtualText;
  36679. function isVirtualText(x) {
  36680. return x && x.type === "VirtualText" && x.version === version$1
  36681. }
  36682. /*!
  36683. * Cross-Browser Split 1.1.1
  36684. * Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
  36685. * Available under the MIT License
  36686. * ECMAScript compliant, uniform cross-browser split method
  36687. */
  36688. /**
  36689. * Splits a string into an array of strings using a regex or string separator. Matches of the
  36690. * separator are not included in the result array. However, if `separator` is a regex that contains
  36691. * capturing groups, backreferences are spliced into the result each time `separator` is matched.
  36692. * Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably
  36693. * cross-browser.
  36694. * @param {String} str String to split.
  36695. * @param {RegExp|String} separator Regex or string to use for separating the string.
  36696. * @param {Number} [limit] Maximum number of items to include in the result array.
  36697. * @returns {Array} Array of substrings.
  36698. * @example
  36699. *
  36700. * // Basic use
  36701. * split('a b c d', ' ');
  36702. * // -> ['a', 'b', 'c', 'd']
  36703. *
  36704. * // With limit
  36705. * split('a b c d', ' ', 2);
  36706. * // -> ['a', 'b']
  36707. *
  36708. * // Backreferences in result array
  36709. * split('..word1 word2..', /([a-z]+)(\d+)/i);
  36710. * // -> ['..', 'word', '1', ' ', 'word', '2', '..']
  36711. */
  36712. var browserSplit = (function split(undef) {
  36713. var nativeSplit = String.prototype.split,
  36714. compliantExecNpcg = /()??/.exec("")[1] === undef,
  36715. // NPCG: nonparticipating capturing group
  36716. self;
  36717. self = function(str, separator, limit) {
  36718. // If `separator` is not a regex, use `nativeSplit`
  36719. if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
  36720. return nativeSplit.call(str, separator, limit);
  36721. }
  36722. var output = [],
  36723. flags = (separator.ignoreCase ? "i" : "") + (separator.multiline ? "m" : "") + (separator.extended ? "x" : "") + // Proposed for ES6
  36724. (separator.sticky ? "y" : ""),
  36725. // Firefox 3+
  36726. lastLastIndex = 0,
  36727. // Make `global` and avoid `lastIndex` issues by working with a copy
  36728. separator = new RegExp(separator.source, flags + "g"),
  36729. separator2, match, lastIndex, lastLength;
  36730. str += ""; // Type-convert
  36731. if (!compliantExecNpcg) {
  36732. // Doesn't need flags gy, but they don't hurt
  36733. separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
  36734. }
  36735. /* Values for `limit`, per the spec:
  36736. * If undefined: 4294967295 // Math.pow(2, 32) - 1
  36737. * If 0, Infinity, or NaN: 0
  36738. * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
  36739. * If negative number: 4294967296 - Math.floor(Math.abs(limit))
  36740. * If other: Type-convert, then use the above rules
  36741. */
  36742. limit = limit === undef ? -1 >>> 0 : // Math.pow(2, 32) - 1
  36743. limit >>> 0; // ToUint32(limit)
  36744. while (match = separator.exec(str)) {
  36745. // `separator.lastIndex` is not reliable cross-browser
  36746. lastIndex = match.index + match[0].length;
  36747. if (lastIndex > lastLastIndex) {
  36748. output.push(str.slice(lastLastIndex, match.index));
  36749. // Fix browsers whose `exec` methods don't consistently return `undefined` for
  36750. // nonparticipating capturing groups
  36751. if (!compliantExecNpcg && match.length > 1) {
  36752. match[0].replace(separator2, function() {
  36753. for (var i = 1; i < arguments.length - 2; i++) {
  36754. if (arguments[i] === undef) {
  36755. match[i] = undef;
  36756. }
  36757. }
  36758. });
  36759. }
  36760. if (match.length > 1 && match.index < str.length) {
  36761. Array.prototype.push.apply(output, match.slice(1));
  36762. }
  36763. lastLength = match[0].length;
  36764. lastLastIndex = lastIndex;
  36765. if (output.length >= limit) {
  36766. break;
  36767. }
  36768. }
  36769. if (separator.lastIndex === match.index) {
  36770. separator.lastIndex++; // Avoid an infinite loop
  36771. }
  36772. }
  36773. if (lastLastIndex === str.length) {
  36774. if (lastLength || !separator.test("")) {
  36775. output.push("");
  36776. }
  36777. } else {
  36778. output.push(str.slice(lastLastIndex));
  36779. }
  36780. return output.length > limit ? output.slice(0, limit) : output;
  36781. };
  36782. return self;
  36783. })();
  36784. var classIdSplit = /([\.#]?[a-zA-Z0-9\u007F-\uFFFF_:-]+)/;
  36785. var notClassId = /^\.|#/;
  36786. var parseTag_1 = parseTag;
  36787. function parseTag(tag, props) {
  36788. if (!tag) {
  36789. return 'DIV';
  36790. }
  36791. var noId = !(props.hasOwnProperty('id'));
  36792. var tagParts = browserSplit(tag, classIdSplit);
  36793. var tagName = null;
  36794. if (notClassId.test(tagParts[1])) {
  36795. tagName = 'DIV';
  36796. }
  36797. var classes, part, type, i;
  36798. for (i = 0; i < tagParts.length; i++) {
  36799. part = tagParts[i];
  36800. if (!part) {
  36801. continue;
  36802. }
  36803. type = part.charAt(0);
  36804. if (!tagName) {
  36805. tagName = part;
  36806. } else if (type === '.') {
  36807. classes = classes || [];
  36808. classes.push(part.substring(1, part.length));
  36809. } else if (type === '#' && noId) {
  36810. props.id = part.substring(1, part.length);
  36811. }
  36812. }
  36813. if (classes) {
  36814. if (props.className) {
  36815. classes.push(props.className);
  36816. }
  36817. props.className = classes.join(' ');
  36818. }
  36819. return props.namespace ? tagName : tagName.toUpperCase();
  36820. }
  36821. var softSetHook = SoftSetHook;
  36822. function SoftSetHook(value) {
  36823. if (!(this instanceof SoftSetHook)) {
  36824. return new SoftSetHook(value);
  36825. }
  36826. this.value = value;
  36827. }
  36828. SoftSetHook.prototype.hook = function (node, propertyName) {
  36829. if (node[propertyName] !== this.value) {
  36830. node[propertyName] = this.value;
  36831. }
  36832. };
  36833. /*global window, global*/
  36834. var root$1 = typeof window !== 'undefined' ?
  36835. window : typeof commonjsGlobal !== 'undefined' ?
  36836. commonjsGlobal : {};
  36837. var individual = Individual;
  36838. function Individual(key, value) {
  36839. if (key in root$1) {
  36840. return root$1[key];
  36841. }
  36842. root$1[key] = value;
  36843. return value;
  36844. }
  36845. var oneVersion = OneVersion;
  36846. function OneVersion(moduleName, version, defaultValue) {
  36847. var key = '__INDIVIDUAL_ONE_VERSION_' + moduleName;
  36848. var enforceKey = key + '_ENFORCE_SINGLETON';
  36849. var versionValue = individual(enforceKey, version);
  36850. if (versionValue !== version) {
  36851. throw new Error('Can only have one copy of ' +
  36852. moduleName + '.\n' +
  36853. 'You already have version ' + versionValue +
  36854. ' installed.\n' +
  36855. 'This means you cannot install version ' + version);
  36856. }
  36857. return individual(key, defaultValue);
  36858. }
  36859. var MY_VERSION = '7';
  36860. oneVersion('ev-store', MY_VERSION);
  36861. var hashKey = '__EV_STORE_KEY@' + MY_VERSION;
  36862. var evStore = EvStore;
  36863. function EvStore(elem) {
  36864. var hash = elem[hashKey];
  36865. if (!hash) {
  36866. hash = elem[hashKey] = {};
  36867. }
  36868. return hash;
  36869. }
  36870. var evHook = EvHook;
  36871. function EvHook(value) {
  36872. if (!(this instanceof EvHook)) {
  36873. return new EvHook(value);
  36874. }
  36875. this.value = value;
  36876. }
  36877. EvHook.prototype.hook = function (node, propertyName) {
  36878. var es = evStore(node);
  36879. var propName = propertyName.substr(3);
  36880. es[propName] = this.value;
  36881. };
  36882. EvHook.prototype.unhook = function(node, propertyName) {
  36883. var es = evStore(node);
  36884. var propName = propertyName.substr(3);
  36885. es[propName] = undefined;
  36886. };
  36887. var virtualHyperscript = h;
  36888. function h(tagName, properties, children) {
  36889. var childNodes = [];
  36890. var tag, props, key, namespace;
  36891. if (!children && isChildren(properties)) {
  36892. children = properties;
  36893. props = {};
  36894. }
  36895. props = props || properties || {};
  36896. tag = parseTag_1(tagName, props);
  36897. // support keys
  36898. if (props.hasOwnProperty('key')) {
  36899. key = props.key;
  36900. props.key = undefined;
  36901. }
  36902. // support namespace
  36903. if (props.hasOwnProperty('namespace')) {
  36904. namespace = props.namespace;
  36905. props.namespace = undefined;
  36906. }
  36907. // fix cursor bug
  36908. if (tag === 'INPUT' &&
  36909. !namespace &&
  36910. props.hasOwnProperty('value') &&
  36911. props.value !== undefined &&
  36912. !isVhook(props.value)
  36913. ) {
  36914. props.value = softSetHook(props.value);
  36915. }
  36916. transformProperties(props);
  36917. if (children !== undefined && children !== null) {
  36918. addChild(children, childNodes, tag, props);
  36919. }
  36920. return new vnode(tag, props, childNodes, key, namespace);
  36921. }
  36922. function addChild(c, childNodes, tag, props) {
  36923. if (typeof c === 'string') {
  36924. childNodes.push(new vtext(c));
  36925. } else if (typeof c === 'number') {
  36926. childNodes.push(new vtext(String(c)));
  36927. } else if (isChild(c)) {
  36928. childNodes.push(c);
  36929. } else if (xIsArray(c)) {
  36930. for (var i = 0; i < c.length; i++) {
  36931. addChild(c[i], childNodes, tag, props);
  36932. }
  36933. } else if (c === null || c === undefined) {
  36934. return;
  36935. } else {
  36936. throw UnexpectedVirtualElement({
  36937. foreignObject: c,
  36938. parentVnode: {
  36939. tagName: tag,
  36940. properties: props
  36941. }
  36942. });
  36943. }
  36944. }
  36945. function transformProperties(props) {
  36946. for (var propName in props) {
  36947. if (props.hasOwnProperty(propName)) {
  36948. var value = props[propName];
  36949. if (isVhook(value)) {
  36950. continue;
  36951. }
  36952. if (propName.substr(0, 3) === 'ev-') {
  36953. // add ev-foo support
  36954. props[propName] = evHook(value);
  36955. }
  36956. }
  36957. }
  36958. }
  36959. function isChild(x) {
  36960. return isVnode(x) || isVtext(x) || isWidget_1(x) || isThunk_1(x);
  36961. }
  36962. function isChildren(x) {
  36963. return typeof x === 'string' || xIsArray(x) || isChild(x);
  36964. }
  36965. function UnexpectedVirtualElement(data) {
  36966. var err = new Error();
  36967. err.type = 'virtual-hyperscript.unexpected.virtual-element';
  36968. err.message = 'Unexpected virtual child passed to h().\n' +
  36969. 'Expected a VNode / Vthunk / VWidget / string but:\n' +
  36970. 'got:\n' +
  36971. errorString(data.foreignObject) +
  36972. '.\n' +
  36973. 'The parent vnode is:\n' +
  36974. errorString(data.parentVnode);
  36975. err.foreignObject = data.foreignObject;
  36976. err.parentVnode = data.parentVnode;
  36977. return err;
  36978. }
  36979. function errorString(obj) {
  36980. try {
  36981. return JSON.stringify(obj, null, ' ');
  36982. } catch (e) {
  36983. return String(obj);
  36984. }
  36985. }
  36986. var h_1 = virtualHyperscript;
  36987. VirtualPatch.NONE = 0;
  36988. VirtualPatch.VTEXT = 1;
  36989. VirtualPatch.VNODE = 2;
  36990. VirtualPatch.WIDGET = 3;
  36991. VirtualPatch.PROPS = 4;
  36992. VirtualPatch.ORDER = 5;
  36993. VirtualPatch.INSERT = 6;
  36994. VirtualPatch.REMOVE = 7;
  36995. VirtualPatch.THUNK = 8;
  36996. var vpatch = VirtualPatch;
  36997. function VirtualPatch(type, vNode, patch) {
  36998. this.type = Number(type);
  36999. this.vNode = vNode;
  37000. this.patch = patch;
  37001. }
  37002. VirtualPatch.prototype.version = version$1;
  37003. VirtualPatch.prototype.type = "VirtualPatch";
  37004. var handleThunk_1 = handleThunk;
  37005. function handleThunk(a, b) {
  37006. var renderedA = a;
  37007. var renderedB = b;
  37008. if (isThunk_1(b)) {
  37009. renderedB = renderThunk(b, a);
  37010. }
  37011. if (isThunk_1(a)) {
  37012. renderedA = renderThunk(a, null);
  37013. }
  37014. return {
  37015. a: renderedA,
  37016. b: renderedB
  37017. }
  37018. }
  37019. function renderThunk(thunk, previous) {
  37020. var renderedThunk = thunk.vnode;
  37021. if (!renderedThunk) {
  37022. renderedThunk = thunk.vnode = thunk.render(previous);
  37023. }
  37024. if (!(isVnode(renderedThunk) ||
  37025. isVtext(renderedThunk) ||
  37026. isWidget_1(renderedThunk))) {
  37027. throw new Error("thunk did not return a valid node");
  37028. }
  37029. return renderedThunk
  37030. }
  37031. var isObject$2 = function isObject(x) {
  37032. return typeof x === 'object' && x !== null;
  37033. };
  37034. var diffProps_1 = diffProps;
  37035. function diffProps(a, b) {
  37036. var diff;
  37037. for (var aKey in a) {
  37038. if (!(aKey in b)) {
  37039. diff = diff || {};
  37040. diff[aKey] = undefined;
  37041. }
  37042. var aValue = a[aKey];
  37043. var bValue = b[aKey];
  37044. if (aValue === bValue) {
  37045. continue
  37046. } else if (isObject$2(aValue) && isObject$2(bValue)) {
  37047. if (getPrototype$1(bValue) !== getPrototype$1(aValue)) {
  37048. diff = diff || {};
  37049. diff[aKey] = bValue;
  37050. } else if (isVhook(bValue)) {
  37051. diff = diff || {};
  37052. diff[aKey] = bValue;
  37053. } else {
  37054. var objectDiff = diffProps(aValue, bValue);
  37055. if (objectDiff) {
  37056. diff = diff || {};
  37057. diff[aKey] = objectDiff;
  37058. }
  37059. }
  37060. } else {
  37061. diff = diff || {};
  37062. diff[aKey] = bValue;
  37063. }
  37064. }
  37065. for (var bKey in b) {
  37066. if (!(bKey in a)) {
  37067. diff = diff || {};
  37068. diff[bKey] = b[bKey];
  37069. }
  37070. }
  37071. return diff
  37072. }
  37073. function getPrototype$1(value) {
  37074. if (Object.getPrototypeOf) {
  37075. return Object.getPrototypeOf(value)
  37076. } else if (value.__proto__) {
  37077. return value.__proto__
  37078. } else if (value.constructor) {
  37079. return value.constructor.prototype
  37080. }
  37081. }
  37082. var diff_1 = diff;
  37083. function diff(a, b) {
  37084. var patch = { a: a };
  37085. walk(a, b, patch, 0);
  37086. return patch
  37087. }
  37088. function walk(a, b, patch, index) {
  37089. if (a === b) {
  37090. return
  37091. }
  37092. var apply = patch[index];
  37093. var applyClear = false;
  37094. if (isThunk_1(a) || isThunk_1(b)) {
  37095. thunks(a, b, patch, index);
  37096. } else if (b == null) {
  37097. // If a is a widget we will add a remove patch for it
  37098. // Otherwise any child widgets/hooks must be destroyed.
  37099. // This prevents adding two remove patches for a widget.
  37100. if (!isWidget_1(a)) {
  37101. clearState(a, patch, index);
  37102. apply = patch[index];
  37103. }
  37104. apply = appendPatch(apply, new vpatch(vpatch.REMOVE, a, b));
  37105. } else if (isVnode(b)) {
  37106. if (isVnode(a)) {
  37107. if (a.tagName === b.tagName &&
  37108. a.namespace === b.namespace &&
  37109. a.key === b.key) {
  37110. var propsPatch = diffProps_1(a.properties, b.properties);
  37111. if (propsPatch) {
  37112. apply = appendPatch(apply,
  37113. new vpatch(vpatch.PROPS, a, propsPatch));
  37114. }
  37115. apply = diffChildren(a, b, patch, apply, index);
  37116. } else {
  37117. apply = appendPatch(apply, new vpatch(vpatch.VNODE, a, b));
  37118. applyClear = true;
  37119. }
  37120. } else {
  37121. apply = appendPatch(apply, new vpatch(vpatch.VNODE, a, b));
  37122. applyClear = true;
  37123. }
  37124. } else if (isVtext(b)) {
  37125. if (!isVtext(a)) {
  37126. apply = appendPatch(apply, new vpatch(vpatch.VTEXT, a, b));
  37127. applyClear = true;
  37128. } else if (a.text !== b.text) {
  37129. apply = appendPatch(apply, new vpatch(vpatch.VTEXT, a, b));
  37130. }
  37131. } else if (isWidget_1(b)) {
  37132. if (!isWidget_1(a)) {
  37133. applyClear = true;
  37134. }
  37135. apply = appendPatch(apply, new vpatch(vpatch.WIDGET, a, b));
  37136. }
  37137. if (apply) {
  37138. patch[index] = apply;
  37139. }
  37140. if (applyClear) {
  37141. clearState(a, patch, index);
  37142. }
  37143. }
  37144. function diffChildren(a, b, patch, apply, index) {
  37145. var aChildren = a.children;
  37146. var orderedSet = reorder(aChildren, b.children);
  37147. var bChildren = orderedSet.children;
  37148. var aLen = aChildren.length;
  37149. var bLen = bChildren.length;
  37150. var len = aLen > bLen ? aLen : bLen;
  37151. for (var i = 0; i < len; i++) {
  37152. var leftNode = aChildren[i];
  37153. var rightNode = bChildren[i];
  37154. index += 1;
  37155. if (!leftNode) {
  37156. if (rightNode) {
  37157. // Excess nodes in b need to be added
  37158. apply = appendPatch(apply,
  37159. new vpatch(vpatch.INSERT, null, rightNode));
  37160. }
  37161. } else {
  37162. walk(leftNode, rightNode, patch, index);
  37163. }
  37164. if (isVnode(leftNode) && leftNode.count) {
  37165. index += leftNode.count;
  37166. }
  37167. }
  37168. if (orderedSet.moves) {
  37169. // Reorder nodes last
  37170. apply = appendPatch(apply, new vpatch(
  37171. vpatch.ORDER,
  37172. a,
  37173. orderedSet.moves
  37174. ));
  37175. }
  37176. return apply
  37177. }
  37178. function clearState(vNode, patch, index) {
  37179. // TODO: Make this a single walk, not two
  37180. unhook(vNode, patch, index);
  37181. destroyWidgets(vNode, patch, index);
  37182. }
  37183. // Patch records for all destroyed widgets must be added because we need
  37184. // a DOM node reference for the destroy function
  37185. function destroyWidgets(vNode, patch, index) {
  37186. if (isWidget_1(vNode)) {
  37187. if (typeof vNode.destroy === "function") {
  37188. patch[index] = appendPatch(
  37189. patch[index],
  37190. new vpatch(vpatch.REMOVE, vNode, null)
  37191. );
  37192. }
  37193. } else if (isVnode(vNode) && (vNode.hasWidgets || vNode.hasThunks)) {
  37194. var children = vNode.children;
  37195. var len = children.length;
  37196. for (var i = 0; i < len; i++) {
  37197. var child = children[i];
  37198. index += 1;
  37199. destroyWidgets(child, patch, index);
  37200. if (isVnode(child) && child.count) {
  37201. index += child.count;
  37202. }
  37203. }
  37204. } else if (isThunk_1(vNode)) {
  37205. thunks(vNode, null, patch, index);
  37206. }
  37207. }
  37208. // Create a sub-patch for thunks
  37209. function thunks(a, b, patch, index) {
  37210. var nodes = handleThunk_1(a, b);
  37211. var thunkPatch = diff(nodes.a, nodes.b);
  37212. if (hasPatches(thunkPatch)) {
  37213. patch[index] = new vpatch(vpatch.THUNK, null, thunkPatch);
  37214. }
  37215. }
  37216. function hasPatches(patch) {
  37217. for (var index in patch) {
  37218. if (index !== "a") {
  37219. return true
  37220. }
  37221. }
  37222. return false
  37223. }
  37224. // Execute hooks when two nodes are identical
  37225. function unhook(vNode, patch, index) {
  37226. if (isVnode(vNode)) {
  37227. if (vNode.hooks) {
  37228. patch[index] = appendPatch(
  37229. patch[index],
  37230. new vpatch(
  37231. vpatch.PROPS,
  37232. vNode,
  37233. undefinedKeys(vNode.hooks)
  37234. )
  37235. );
  37236. }
  37237. if (vNode.descendantHooks || vNode.hasThunks) {
  37238. var children = vNode.children;
  37239. var len = children.length;
  37240. for (var i = 0; i < len; i++) {
  37241. var child = children[i];
  37242. index += 1;
  37243. unhook(child, patch, index);
  37244. if (isVnode(child) && child.count) {
  37245. index += child.count;
  37246. }
  37247. }
  37248. }
  37249. } else if (isThunk_1(vNode)) {
  37250. thunks(vNode, null, patch, index);
  37251. }
  37252. }
  37253. function undefinedKeys(obj) {
  37254. var result = {};
  37255. for (var key in obj) {
  37256. result[key] = undefined;
  37257. }
  37258. return result
  37259. }
  37260. // List diff, naive left to right reordering
  37261. function reorder(aChildren, bChildren) {
  37262. // O(M) time, O(M) memory
  37263. var bChildIndex = keyIndex(bChildren);
  37264. var bKeys = bChildIndex.keys;
  37265. var bFree = bChildIndex.free;
  37266. if (bFree.length === bChildren.length) {
  37267. return {
  37268. children: bChildren,
  37269. moves: null
  37270. }
  37271. }
  37272. // O(N) time, O(N) memory
  37273. var aChildIndex = keyIndex(aChildren);
  37274. var aKeys = aChildIndex.keys;
  37275. var aFree = aChildIndex.free;
  37276. if (aFree.length === aChildren.length) {
  37277. return {
  37278. children: bChildren,
  37279. moves: null
  37280. }
  37281. }
  37282. // O(MAX(N, M)) memory
  37283. var newChildren = [];
  37284. var freeIndex = 0;
  37285. var freeCount = bFree.length;
  37286. var deletedItems = 0;
  37287. // Iterate through a and match a node in b
  37288. // O(N) time,
  37289. for (var i = 0 ; i < aChildren.length; i++) {
  37290. var aItem = aChildren[i];
  37291. var itemIndex;
  37292. if (aItem.key) {
  37293. if (bKeys.hasOwnProperty(aItem.key)) {
  37294. // Match up the old keys
  37295. itemIndex = bKeys[aItem.key];
  37296. newChildren.push(bChildren[itemIndex]);
  37297. } else {
  37298. // Remove old keyed items
  37299. itemIndex = i - deletedItems++;
  37300. newChildren.push(null);
  37301. }
  37302. } else {
  37303. // Match the item in a with the next free item in b
  37304. if (freeIndex < freeCount) {
  37305. itemIndex = bFree[freeIndex++];
  37306. newChildren.push(bChildren[itemIndex]);
  37307. } else {
  37308. // There are no free items in b to match with
  37309. // the free items in a, so the extra free nodes
  37310. // are deleted.
  37311. itemIndex = i - deletedItems++;
  37312. newChildren.push(null);
  37313. }
  37314. }
  37315. }
  37316. var lastFreeIndex = freeIndex >= bFree.length ?
  37317. bChildren.length :
  37318. bFree[freeIndex];
  37319. // Iterate through b and append any new keys
  37320. // O(M) time
  37321. for (var j = 0; j < bChildren.length; j++) {
  37322. var newItem = bChildren[j];
  37323. if (newItem.key) {
  37324. if (!aKeys.hasOwnProperty(newItem.key)) {
  37325. // Add any new keyed items
  37326. // We are adding new items to the end and then sorting them
  37327. // in place. In future we should insert new items in place.
  37328. newChildren.push(newItem);
  37329. }
  37330. } else if (j >= lastFreeIndex) {
  37331. // Add any leftover non-keyed items
  37332. newChildren.push(newItem);
  37333. }
  37334. }
  37335. var simulate = newChildren.slice();
  37336. var simulateIndex = 0;
  37337. var removes = [];
  37338. var inserts = [];
  37339. var simulateItem;
  37340. for (var k = 0; k < bChildren.length;) {
  37341. var wantedItem = bChildren[k];
  37342. simulateItem = simulate[simulateIndex];
  37343. // remove items
  37344. while (simulateItem === null && simulate.length) {
  37345. removes.push(remove(simulate, simulateIndex, null));
  37346. simulateItem = simulate[simulateIndex];
  37347. }
  37348. if (!simulateItem || simulateItem.key !== wantedItem.key) {
  37349. // if we need a key in this position...
  37350. if (wantedItem.key) {
  37351. if (simulateItem && simulateItem.key) {
  37352. // if an insert doesn't put this key in place, it needs to move
  37353. if (bKeys[simulateItem.key] !== k + 1) {
  37354. removes.push(remove(simulate, simulateIndex, simulateItem.key));
  37355. simulateItem = simulate[simulateIndex];
  37356. // if the remove didn't put the wanted item in place, we need to insert it
  37357. if (!simulateItem || simulateItem.key !== wantedItem.key) {
  37358. inserts.push({key: wantedItem.key, to: k});
  37359. }
  37360. // items are matching, so skip ahead
  37361. else {
  37362. simulateIndex++;
  37363. }
  37364. }
  37365. else {
  37366. inserts.push({key: wantedItem.key, to: k});
  37367. }
  37368. }
  37369. else {
  37370. inserts.push({key: wantedItem.key, to: k});
  37371. }
  37372. k++;
  37373. }
  37374. // a key in simulate has no matching wanted key, remove it
  37375. else if (simulateItem && simulateItem.key) {
  37376. removes.push(remove(simulate, simulateIndex, simulateItem.key));
  37377. }
  37378. }
  37379. else {
  37380. simulateIndex++;
  37381. k++;
  37382. }
  37383. }
  37384. // remove all the remaining nodes from simulate
  37385. while(simulateIndex < simulate.length) {
  37386. simulateItem = simulate[simulateIndex];
  37387. removes.push(remove(simulate, simulateIndex, simulateItem && simulateItem.key));
  37388. }
  37389. // If the only moves we have are deletes then we can just
  37390. // let the delete patch remove these items.
  37391. if (removes.length === deletedItems && !inserts.length) {
  37392. return {
  37393. children: newChildren,
  37394. moves: null
  37395. }
  37396. }
  37397. return {
  37398. children: newChildren,
  37399. moves: {
  37400. removes: removes,
  37401. inserts: inserts
  37402. }
  37403. }
  37404. }
  37405. function remove(arr, index, key) {
  37406. arr.splice(index, 1);
  37407. return {
  37408. from: index,
  37409. key: key
  37410. }
  37411. }
  37412. function keyIndex(children) {
  37413. var keys = {};
  37414. var free = [];
  37415. var length = children.length;
  37416. for (var i = 0; i < length; i++) {
  37417. var child = children[i];
  37418. if (child.key) {
  37419. keys[child.key] = i;
  37420. } else {
  37421. free.push(i);
  37422. }
  37423. }
  37424. return {
  37425. keys: keys, // A hash of key name to index
  37426. free: free // An array of unkeyed item indices
  37427. }
  37428. }
  37429. function appendPatch(apply, patch) {
  37430. if (apply) {
  37431. if (xIsArray(apply)) {
  37432. apply.push(patch);
  37433. } else {
  37434. apply = [apply, patch];
  37435. }
  37436. return apply
  37437. } else {
  37438. return patch
  37439. }
  37440. }
  37441. var diff_1$1 = diff_1;
  37442. var _nodeResolve_empty = {};
  37443. var _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({
  37444. __proto__: null,
  37445. 'default': _nodeResolve_empty
  37446. });
  37447. var minDoc = getCjsExportFromNamespace(_nodeResolve_empty$1);
  37448. var topLevel = typeof commonjsGlobal !== 'undefined' ? commonjsGlobal :
  37449. typeof window !== 'undefined' ? window : {};
  37450. var doccy;
  37451. if (typeof document !== 'undefined') {
  37452. doccy = document;
  37453. } else {
  37454. doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];
  37455. if (!doccy) {
  37456. doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
  37457. }
  37458. }
  37459. var document_1 = doccy;
  37460. var applyProperties_1 = applyProperties;
  37461. function applyProperties(node, props, previous) {
  37462. for (var propName in props) {
  37463. var propValue = props[propName];
  37464. if (propValue === undefined) {
  37465. removeProperty(node, propName, propValue, previous);
  37466. } else if (isVhook(propValue)) {
  37467. removeProperty(node, propName, propValue, previous);
  37468. if (propValue.hook) {
  37469. propValue.hook(node,
  37470. propName,
  37471. previous ? previous[propName] : undefined);
  37472. }
  37473. } else {
  37474. if (isObject$2(propValue)) {
  37475. patchObject(node, props, previous, propName, propValue);
  37476. } else {
  37477. node[propName] = propValue;
  37478. }
  37479. }
  37480. }
  37481. }
  37482. function removeProperty(node, propName, propValue, previous) {
  37483. if (previous) {
  37484. var previousValue = previous[propName];
  37485. if (!isVhook(previousValue)) {
  37486. if (propName === "attributes") {
  37487. for (var attrName in previousValue) {
  37488. node.removeAttribute(attrName);
  37489. }
  37490. } else if (propName === "style") {
  37491. for (var i in previousValue) {
  37492. node.style[i] = "";
  37493. }
  37494. } else if (typeof previousValue === "string") {
  37495. node[propName] = "";
  37496. } else {
  37497. node[propName] = null;
  37498. }
  37499. } else if (previousValue.unhook) {
  37500. previousValue.unhook(node, propName, propValue);
  37501. }
  37502. }
  37503. }
  37504. function patchObject(node, props, previous, propName, propValue) {
  37505. var previousValue = previous ? previous[propName] : undefined;
  37506. // Set attributes
  37507. if (propName === "attributes") {
  37508. for (var attrName in propValue) {
  37509. var attrValue = propValue[attrName];
  37510. if (attrValue === undefined) {
  37511. node.removeAttribute(attrName);
  37512. } else {
  37513. node.setAttribute(attrName, attrValue);
  37514. }
  37515. }
  37516. return
  37517. }
  37518. if(previousValue && isObject$2(previousValue) &&
  37519. getPrototype$2(previousValue) !== getPrototype$2(propValue)) {
  37520. node[propName] = propValue;
  37521. return
  37522. }
  37523. if (!isObject$2(node[propName])) {
  37524. node[propName] = {};
  37525. }
  37526. var replacer = propName === "style" ? "" : undefined;
  37527. for (var k in propValue) {
  37528. var value = propValue[k];
  37529. node[propName][k] = (value === undefined) ? replacer : value;
  37530. }
  37531. }
  37532. function getPrototype$2(value) {
  37533. if (Object.getPrototypeOf) {
  37534. return Object.getPrototypeOf(value)
  37535. } else if (value.__proto__) {
  37536. return value.__proto__
  37537. } else if (value.constructor) {
  37538. return value.constructor.prototype
  37539. }
  37540. }
  37541. var createElement_1 = createElement$1;
  37542. function createElement$1(vnode, opts) {
  37543. var doc = opts ? opts.document || document_1 : document_1;
  37544. var warn = opts ? opts.warn : null;
  37545. vnode = handleThunk_1(vnode).a;
  37546. if (isWidget_1(vnode)) {
  37547. return vnode.init()
  37548. } else if (isVtext(vnode)) {
  37549. return doc.createTextNode(vnode.text)
  37550. } else if (!isVnode(vnode)) {
  37551. if (warn) {
  37552. warn("Item is not a valid virtual dom node", vnode);
  37553. }
  37554. return null
  37555. }
  37556. var node = (vnode.namespace === null) ?
  37557. doc.createElement(vnode.tagName) :
  37558. doc.createElementNS(vnode.namespace, vnode.tagName);
  37559. var props = vnode.properties;
  37560. applyProperties_1(node, props);
  37561. var children = vnode.children;
  37562. for (var i = 0; i < children.length; i++) {
  37563. var childNode = createElement$1(children[i], opts);
  37564. if (childNode) {
  37565. node.appendChild(childNode);
  37566. }
  37567. }
  37568. return node
  37569. }
  37570. // Maps a virtual DOM tree onto a real DOM tree in an efficient manner.
  37571. // We don't want to read all of the DOM nodes in the tree so we use
  37572. // the in-order tree indexing to eliminate recursion down certain branches.
  37573. // We only recurse into a DOM node if we know that it contains a child of
  37574. // interest.
  37575. var noChild = {};
  37576. var domIndex_1 = domIndex;
  37577. function domIndex(rootNode, tree, indices, nodes) {
  37578. if (!indices || indices.length === 0) {
  37579. return {}
  37580. } else {
  37581. indices.sort(ascending);
  37582. return recurse(rootNode, tree, indices, nodes, 0)
  37583. }
  37584. }
  37585. function recurse(rootNode, tree, indices, nodes, rootIndex) {
  37586. nodes = nodes || {};
  37587. if (rootNode) {
  37588. if (indexInRange(indices, rootIndex, rootIndex)) {
  37589. nodes[rootIndex] = rootNode;
  37590. }
  37591. var vChildren = tree.children;
  37592. if (vChildren) {
  37593. var childNodes = rootNode.childNodes;
  37594. for (var i = 0; i < tree.children.length; i++) {
  37595. rootIndex += 1;
  37596. var vChild = vChildren[i] || noChild;
  37597. var nextIndex = rootIndex + (vChild.count || 0);
  37598. // skip recursion down the tree if there are no nodes down here
  37599. if (indexInRange(indices, rootIndex, nextIndex)) {
  37600. recurse(childNodes[i], vChild, indices, nodes, rootIndex);
  37601. }
  37602. rootIndex = nextIndex;
  37603. }
  37604. }
  37605. }
  37606. return nodes
  37607. }
  37608. // Binary search for an index in the interval [left, right]
  37609. function indexInRange(indices, left, right) {
  37610. if (indices.length === 0) {
  37611. return false
  37612. }
  37613. var minIndex = 0;
  37614. var maxIndex = indices.length - 1;
  37615. var currentIndex;
  37616. var currentItem;
  37617. while (minIndex <= maxIndex) {
  37618. currentIndex = ((maxIndex + minIndex) / 2) >> 0;
  37619. currentItem = indices[currentIndex];
  37620. if (minIndex === maxIndex) {
  37621. return currentItem >= left && currentItem <= right
  37622. } else if (currentItem < left) {
  37623. minIndex = currentIndex + 1;
  37624. } else if (currentItem > right) {
  37625. maxIndex = currentIndex - 1;
  37626. } else {
  37627. return true
  37628. }
  37629. }
  37630. return false;
  37631. }
  37632. function ascending(a, b) {
  37633. return a > b ? 1 : -1
  37634. }
  37635. var updateWidget_1 = updateWidget;
  37636. function updateWidget(a, b) {
  37637. if (isWidget_1(a) && isWidget_1(b)) {
  37638. if ("name" in a && "name" in b) {
  37639. return a.id === b.id
  37640. } else {
  37641. return a.init === b.init
  37642. }
  37643. }
  37644. return false
  37645. }
  37646. var patchOp = applyPatch;
  37647. function applyPatch(vpatch$1, domNode, renderOptions) {
  37648. var type = vpatch$1.type;
  37649. var vNode = vpatch$1.vNode;
  37650. var patch = vpatch$1.patch;
  37651. switch (type) {
  37652. case vpatch.REMOVE:
  37653. return removeNode(domNode, vNode)
  37654. case vpatch.INSERT:
  37655. return insertNode(domNode, patch, renderOptions)
  37656. case vpatch.VTEXT:
  37657. return stringPatch(domNode, vNode, patch, renderOptions)
  37658. case vpatch.WIDGET:
  37659. return widgetPatch(domNode, vNode, patch, renderOptions)
  37660. case vpatch.VNODE:
  37661. return vNodePatch(domNode, vNode, patch, renderOptions)
  37662. case vpatch.ORDER:
  37663. reorderChildren(domNode, patch);
  37664. return domNode
  37665. case vpatch.PROPS:
  37666. applyProperties_1(domNode, patch, vNode.properties);
  37667. return domNode
  37668. case vpatch.THUNK:
  37669. return replaceRoot(domNode,
  37670. renderOptions.patch(domNode, patch, renderOptions))
  37671. default:
  37672. return domNode
  37673. }
  37674. }
  37675. function removeNode(domNode, vNode) {
  37676. var parentNode = domNode.parentNode;
  37677. if (parentNode) {
  37678. parentNode.removeChild(domNode);
  37679. }
  37680. destroyWidget(domNode, vNode);
  37681. return null
  37682. }
  37683. function insertNode(parentNode, vNode, renderOptions) {
  37684. var newNode = renderOptions.render(vNode, renderOptions);
  37685. if (parentNode) {
  37686. parentNode.appendChild(newNode);
  37687. }
  37688. return parentNode
  37689. }
  37690. function stringPatch(domNode, leftVNode, vText, renderOptions) {
  37691. var newNode;
  37692. if (domNode.nodeType === 3) {
  37693. domNode.replaceData(0, domNode.length, vText.text);
  37694. newNode = domNode;
  37695. } else {
  37696. var parentNode = domNode.parentNode;
  37697. newNode = renderOptions.render(vText, renderOptions);
  37698. if (parentNode && newNode !== domNode) {
  37699. parentNode.replaceChild(newNode, domNode);
  37700. }
  37701. }
  37702. return newNode
  37703. }
  37704. function widgetPatch(domNode, leftVNode, widget, renderOptions) {
  37705. var updating = updateWidget_1(leftVNode, widget);
  37706. var newNode;
  37707. if (updating) {
  37708. newNode = widget.update(leftVNode, domNode) || domNode;
  37709. } else {
  37710. newNode = renderOptions.render(widget, renderOptions);
  37711. }
  37712. var parentNode = domNode.parentNode;
  37713. if (parentNode && newNode !== domNode) {
  37714. parentNode.replaceChild(newNode, domNode);
  37715. }
  37716. if (!updating) {
  37717. destroyWidget(domNode, leftVNode);
  37718. }
  37719. return newNode
  37720. }
  37721. function vNodePatch(domNode, leftVNode, vNode, renderOptions) {
  37722. var parentNode = domNode.parentNode;
  37723. var newNode = renderOptions.render(vNode, renderOptions);
  37724. if (parentNode && newNode !== domNode) {
  37725. parentNode.replaceChild(newNode, domNode);
  37726. }
  37727. return newNode
  37728. }
  37729. function destroyWidget(domNode, w) {
  37730. if (typeof w.destroy === "function" && isWidget_1(w)) {
  37731. w.destroy(domNode);
  37732. }
  37733. }
  37734. function reorderChildren(domNode, moves) {
  37735. var childNodes = domNode.childNodes;
  37736. var keyMap = {};
  37737. var node;
  37738. var remove;
  37739. var insert;
  37740. for (var i = 0; i < moves.removes.length; i++) {
  37741. remove = moves.removes[i];
  37742. node = childNodes[remove.from];
  37743. if (remove.key) {
  37744. keyMap[remove.key] = node;
  37745. }
  37746. domNode.removeChild(node);
  37747. }
  37748. var length = childNodes.length;
  37749. for (var j = 0; j < moves.inserts.length; j++) {
  37750. insert = moves.inserts[j];
  37751. node = keyMap[insert.key];
  37752. // this is the weirdest bug i've ever seen in webkit
  37753. domNode.insertBefore(node, insert.to >= length++ ? null : childNodes[insert.to]);
  37754. }
  37755. }
  37756. function replaceRoot(oldRoot, newRoot) {
  37757. if (oldRoot && newRoot && oldRoot !== newRoot && oldRoot.parentNode) {
  37758. oldRoot.parentNode.replaceChild(newRoot, oldRoot);
  37759. }
  37760. return newRoot;
  37761. }
  37762. var patch_1 = patch;
  37763. function patch(rootNode, patches, renderOptions) {
  37764. renderOptions = renderOptions || {};
  37765. renderOptions.patch = renderOptions.patch && renderOptions.patch !== patch
  37766. ? renderOptions.patch
  37767. : patchRecursive;
  37768. renderOptions.render = renderOptions.render || createElement_1;
  37769. return renderOptions.patch(rootNode, patches, renderOptions)
  37770. }
  37771. function patchRecursive(rootNode, patches, renderOptions) {
  37772. var indices = patchIndices(patches);
  37773. if (indices.length === 0) {
  37774. return rootNode
  37775. }
  37776. var index = domIndex_1(rootNode, patches.a, indices);
  37777. var ownerDocument = rootNode.ownerDocument;
  37778. if (!renderOptions.document && ownerDocument !== document_1) {
  37779. renderOptions.document = ownerDocument;
  37780. }
  37781. for (var i = 0; i < indices.length; i++) {
  37782. var nodeIndex = indices[i];
  37783. rootNode = applyPatch$1(rootNode,
  37784. index[nodeIndex],
  37785. patches[nodeIndex],
  37786. renderOptions);
  37787. }
  37788. return rootNode
  37789. }
  37790. function applyPatch$1(rootNode, domNode, patchList, renderOptions) {
  37791. if (!domNode) {
  37792. return rootNode
  37793. }
  37794. var newNode;
  37795. if (xIsArray(patchList)) {
  37796. for (var i = 0; i < patchList.length; i++) {
  37797. newNode = patchOp(patchList[i], domNode, renderOptions);
  37798. if (domNode === rootNode) {
  37799. rootNode = newNode;
  37800. }
  37801. }
  37802. } else {
  37803. newNode = patchOp(patchList, domNode, renderOptions);
  37804. if (domNode === rootNode) {
  37805. rootNode = newNode;
  37806. }
  37807. }
  37808. return rootNode
  37809. }
  37810. function patchIndices(patches) {
  37811. var indices = [];
  37812. for (var key in patches) {
  37813. if (key !== "a") {
  37814. indices.push(Number(key));
  37815. }
  37816. }
  37817. return indices
  37818. }
  37819. var patch_1$1 = patch_1;
  37820. var MyersDiff = /*#__PURE__*/function () {
  37821. function MyersDiff(newObj, oldObj, getElement) {
  37822. _classCallCheck(this, MyersDiff);
  37823. this.options = {
  37824. newObj: newObj,
  37825. // 用于diff的新列表/字符串
  37826. oldObj: oldObj,
  37827. // 用于diff的旧列表/字符串
  37828. getElement: getElement // 获取用于比较的元素的函数
  37829. };
  37830. }
  37831. /**
  37832. * 执行diff操作
  37833. */
  37834. _createClass(MyersDiff, [{
  37835. key: "doDiff",
  37836. value: function doDiff() {
  37837. var snakes = this.findSnakes(this.options.newObj, this.options.oldObj);
  37838. var result = this.assembleResult(snakes, this.options.newObj, this.options.oldObj);
  37839. return result;
  37840. }
  37841. /**
  37842. * 用于判断列表/字符串元素是否相等的判据函数
  37843. */
  37844. }, {
  37845. key: "getElement",
  37846. value: function getElement(obj, index) {
  37847. if (typeof this.options.getElement === 'function') {
  37848. // 支持传入自定义的比较函数
  37849. return this.options.getElement(obj, index);
  37850. }
  37851. return obj[index];
  37852. }
  37853. /**
  37854. * 寻找从起点到终点的折线
  37855. */
  37856. }, {
  37857. key: "findSnakes",
  37858. value: function findSnakes(newObj, oldObj) {
  37859. var newLen = newObj.length || 0; // 新diff对象的长度
  37860. var oldLen = oldObj.length || 0; // 旧diff对象的长度
  37861. var lengthSum = newLen + oldLen; // 长度之和
  37862. var v = {
  37863. 1: 0
  37864. }; // "每个节点的深度值"的缓存对象
  37865. var allSnakes = {
  37866. 0: {
  37867. 1: 0
  37868. }
  37869. }; // "每个节点对应的折线"的缓存对象
  37870. // d是起点到对应节点的编辑距离,简而言之,若把新增一个节点或删除一个节点都视作一次"操作",那么通过d次操作可以从起点到达对应节点
  37871. for (var d = 0; d <= lengthSum; d++) {
  37872. var tmp = {};
  37873. for (var k = -d; k <= d; k += 2) {
  37874. // 转换坐标系,k可以视为对应节点(x,y)的x坐标值减y坐标值
  37875. var down = k === -d || k !== d && v[k - 1] < v[k + 1];
  37876. var kPrev = down ? k + 1 : k - 1;
  37877. var xStart = v[kPrev]; // let yStart = xStart - kPrev;
  37878. var xMid = down ? xStart : xStart + 1;
  37879. var yMid = xMid - k;
  37880. var xEnd = xMid;
  37881. var yEnd = yMid;
  37882. while (xEnd < oldLen && yEnd < newLen && this.getElement(oldObj, xEnd) === this.getElement(newObj, yEnd)) {
  37883. xEnd += 1;
  37884. yEnd += 1;
  37885. }
  37886. v[k] = xEnd;
  37887. tmp[k] = xEnd;
  37888. if (xEnd >= oldLen && yEnd >= newLen) {
  37889. // 成功抵达终点
  37890. allSnakes[d] = tmp;
  37891. return this.$backtraceSnakes(allSnakes, newLen, oldLen, d);
  37892. }
  37893. }
  37894. allSnakes[d] = tmp;
  37895. }
  37896. return [];
  37897. }
  37898. /**
  37899. * 回溯,找出关键路径对应的折线
  37900. */
  37901. }, {
  37902. key: "$backtraceSnakes",
  37903. value: function $backtraceSnakes(allSnakes, newLen, oldLen, d) {
  37904. var keySnakes = [];
  37905. var p = {
  37906. x: oldLen,
  37907. y: newLen
  37908. }; // 模拟节点,从终点开始
  37909. // 执行回溯,倒回起点,找到并记录关键路径
  37910. for (var i = d; i > 0; i--) {
  37911. var v = allSnakes[i];
  37912. var vPrev = allSnakes[i - 1];
  37913. var k = p.x - p.y;
  37914. var xEnd = v[k]; // let yEnd = xEnd - k;
  37915. var down = k === -i || k !== i && vPrev[k + 1] > vPrev[k - 1];
  37916. var kPrev = down ? k + 1 : k - 1;
  37917. var xStart = vPrev[kPrev];
  37918. var yStart = xStart - kPrev;
  37919. var xMid = down ? xStart : xStart + 1; // let yMid = xMid - k;
  37920. keySnakes.unshift({
  37921. xStart: xStart,
  37922. xMid: xMid,
  37923. xEnd: xEnd
  37924. });
  37925. p.x = xStart;
  37926. p.y = yStart;
  37927. }
  37928. return keySnakes;
  37929. }
  37930. /**
  37931. * 组装出返回值
  37932. */
  37933. }, {
  37934. key: "assembleResult",
  37935. value: function assembleResult(snakes, newObj, oldObj) {
  37936. var _this = this,
  37937. _context;
  37938. var grayColor = 'color: gray';
  37939. var redColor = 'color: red';
  37940. var greenColor = 'color: green';
  37941. var blueColor = 'color: blue';
  37942. var consoleStr = '';
  37943. var args = [];
  37944. var yOffset = 0;
  37945. var result = []; // 返回的操作集
  37946. var change = {}; // 本次操作
  37947. var lastChange = {}; // 缓存上一次操作
  37948. var firstDeleteChange = {}; // 连续删除时用来缓存最初的删除
  37949. forEach$3(snakes).call(snakes, function (snake, index) {
  37950. var currentPos = snake.xStart;
  37951. if (index === 0 && snake.xStart !== 0) {
  37952. for (var j = 0; j < snake.xStart; j++) {
  37953. consoleStr += "%c".concat(_this.getElement(oldObj, j), ", ");
  37954. args.push(grayColor);
  37955. yOffset += 1;
  37956. }
  37957. }
  37958. if (snake.xMid - snake.xStart === 1) {
  37959. // 删除
  37960. change = {
  37961. type: 'delete',
  37962. oldIndex: snake.xStart,
  37963. newIndex: 0
  37964. };
  37965. if (lastChange.type === 'delete' && lastChange.oldIndex === change.oldIndex - 1) {
  37966. // 检测到连续删除,缓存最初的删除
  37967. firstDeleteChange = firstDeleteChange ? lastChange : firstDeleteChange;
  37968. }
  37969. result.push(change);
  37970. lastChange = change;
  37971. consoleStr += "%c".concat(_this.getElement(oldObj, snake.xStart), ", ");
  37972. args.push(redColor);
  37973. currentPos = snake.xMid;
  37974. } else {
  37975. // 添加
  37976. change = {
  37977. type: 'insert',
  37978. oldIndex: snake.xStart,
  37979. newIndex: yOffset
  37980. };
  37981. if (lastChange.type === 'delete' && lastChange.oldIndex === change.oldIndex - 1) {
  37982. // 和上一条删除合并为"更新"
  37983. result.pop();
  37984. firstDeleteChange = firstDeleteChange ? lastChange : firstDeleteChange;
  37985. change = {
  37986. type: 'update',
  37987. oldIndex: firstDeleteChange.oldIndex,
  37988. // 合并时,更新目标定位连续删除块中的首个元素
  37989. newIndex: yOffset
  37990. };
  37991. args.push(blueColor);
  37992. } else {
  37993. args.push(greenColor);
  37994. }
  37995. firstDeleteChange = {};
  37996. result.push(change);
  37997. lastChange = change;
  37998. consoleStr += "%c".concat(_this.getElement(newObj, yOffset), ", ");
  37999. yOffset += 1;
  38000. } // 不变
  38001. for (var i = 0; i < snake.xEnd - currentPos; i++) {
  38002. consoleStr += "%c".concat(_this.getElement(oldObj, currentPos + i), ", ");
  38003. args.push(grayColor);
  38004. yOffset += 1;
  38005. }
  38006. });
  38007. Logger.log.apply(Logger, concat$5(_context = [consoleStr]).call(_context, args));
  38008. return result;
  38009. }
  38010. }]);
  38011. return MyersDiff;
  38012. }();
  38013. var ITERATOR$7 = wellKnownSymbol('iterator');
  38014. var nativeUrl = !fails(function () {
  38015. // eslint-disable-next-line unicorn/relative-url-style -- required for testing
  38016. var url = new URL('b?a=1&b=2&c=3', 'http://a');
  38017. var searchParams = url.searchParams;
  38018. var result = '';
  38019. url.pathname = 'c%20d';
  38020. searchParams.forEach(function (value, key) {
  38021. searchParams['delete']('b');
  38022. result += key + value;
  38023. });
  38024. return (isPure && !url.toJSON)
  38025. || !searchParams.sort
  38026. || url.href !== 'http://a/c%20d?a=1&c=3'
  38027. || searchParams.get('c') !== '3'
  38028. || String(new URLSearchParams('?a=1')) !== 'a=1'
  38029. || !searchParams[ITERATOR$7]
  38030. // throws in Edge
  38031. || new URL('https://a@b').username !== 'a'
  38032. || new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b'
  38033. // not punycoded in Edge
  38034. || new URL('http://тест').host !== 'xn--e1aybc'
  38035. // not escaped in Chrome 62-
  38036. || new URL('http://a#б').hash !== '#%D0%B1'
  38037. // fails in Chrome 66-
  38038. || result !== 'a1c3'
  38039. // throws in Safari
  38040. || new URL('http://x', undefined).host !== 'x';
  38041. });
  38042. var defineBuiltInAccessor = function (target, name, descriptor) {
  38043. return objectDefineProperty.f(target, name, descriptor);
  38044. };
  38045. // based on https://github.com/bestiejs/punycode.js/blob/master/punycode.js
  38046. var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
  38047. var base = 36;
  38048. var tMin = 1;
  38049. var tMax = 26;
  38050. var skew = 38;
  38051. var damp = 700;
  38052. var initialBias = 72;
  38053. var initialN = 128; // 0x80
  38054. var delimiter = '-'; // '\x2D'
  38055. var regexNonASCII = /[^\0-\u007E]/; // non-ASCII chars
  38056. var regexSeparators = /[.\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
  38057. var OVERFLOW_ERROR = 'Overflow: input needs wider integers to process';
  38058. var baseMinusTMin = base - tMin;
  38059. var RangeError$3 = global_1.RangeError;
  38060. var exec$3 = functionUncurryThis(regexSeparators.exec);
  38061. var floor$1 = Math.floor;
  38062. var fromCharCode$1 = String.fromCharCode;
  38063. var charCodeAt$2 = functionUncurryThis(''.charCodeAt);
  38064. var join$2 = functionUncurryThis([].join);
  38065. var push$6 = functionUncurryThis([].push);
  38066. var replace$2 = functionUncurryThis(''.replace);
  38067. var split$1 = functionUncurryThis(''.split);
  38068. var toLowerCase = functionUncurryThis(''.toLowerCase);
  38069. /**
  38070. * Creates an array containing the numeric code points of each Unicode
  38071. * character in the string. While JavaScript uses UCS-2 internally,
  38072. * this function will convert a pair of surrogate halves (each of which
  38073. * UCS-2 exposes as separate characters) into a single code point,
  38074. * matching UTF-16.
  38075. */
  38076. var ucs2decode = function (string) {
  38077. var output = [];
  38078. var counter = 0;
  38079. var length = string.length;
  38080. while (counter < length) {
  38081. var value = charCodeAt$2(string, counter++);
  38082. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  38083. // It's a high surrogate, and there is a next character.
  38084. var extra = charCodeAt$2(string, counter++);
  38085. if ((extra & 0xFC00) == 0xDC00) { // Low surrogate.
  38086. push$6(output, ((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  38087. } else {
  38088. // It's an unmatched surrogate; only append this code unit, in case the
  38089. // next code unit is the high surrogate of a surrogate pair.
  38090. push$6(output, value);
  38091. counter--;
  38092. }
  38093. } else {
  38094. push$6(output, value);
  38095. }
  38096. }
  38097. return output;
  38098. };
  38099. /**
  38100. * Converts a digit/integer into a basic code point.
  38101. */
  38102. var digitToBasic = function (digit) {
  38103. // 0..25 map to ASCII a..z or A..Z
  38104. // 26..35 map to ASCII 0..9
  38105. return digit + 22 + 75 * (digit < 26);
  38106. };
  38107. /**
  38108. * Bias adaptation function as per section 3.4 of RFC 3492.
  38109. * https://tools.ietf.org/html/rfc3492#section-3.4
  38110. */
  38111. var adapt = function (delta, numPoints, firstTime) {
  38112. var k = 0;
  38113. delta = firstTime ? floor$1(delta / damp) : delta >> 1;
  38114. delta += floor$1(delta / numPoints);
  38115. while (delta > baseMinusTMin * tMax >> 1) {
  38116. delta = floor$1(delta / baseMinusTMin);
  38117. k += base;
  38118. }
  38119. return floor$1(k + (baseMinusTMin + 1) * delta / (delta + skew));
  38120. };
  38121. /**
  38122. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  38123. * Punycode string of ASCII-only symbols.
  38124. */
  38125. var encode = function (input) {
  38126. var output = [];
  38127. // Convert the input in UCS-2 to an array of Unicode code points.
  38128. input = ucs2decode(input);
  38129. // Cache the length.
  38130. var inputLength = input.length;
  38131. // Initialize the state.
  38132. var n = initialN;
  38133. var delta = 0;
  38134. var bias = initialBias;
  38135. var i, currentValue;
  38136. // Handle the basic code points.
  38137. for (i = 0; i < input.length; i++) {
  38138. currentValue = input[i];
  38139. if (currentValue < 0x80) {
  38140. push$6(output, fromCharCode$1(currentValue));
  38141. }
  38142. }
  38143. var basicLength = output.length; // number of basic code points.
  38144. var handledCPCount = basicLength; // number of code points that have been handled;
  38145. // Finish the basic string with a delimiter unless it's empty.
  38146. if (basicLength) {
  38147. push$6(output, delimiter);
  38148. }
  38149. // Main encoding loop:
  38150. while (handledCPCount < inputLength) {
  38151. // All non-basic code points < n have been handled already. Find the next larger one:
  38152. var m = maxInt;
  38153. for (i = 0; i < input.length; i++) {
  38154. currentValue = input[i];
  38155. if (currentValue >= n && currentValue < m) {
  38156. m = currentValue;
  38157. }
  38158. }
  38159. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>, but guard against overflow.
  38160. var handledCPCountPlusOne = handledCPCount + 1;
  38161. if (m - n > floor$1((maxInt - delta) / handledCPCountPlusOne)) {
  38162. throw RangeError$3(OVERFLOW_ERROR);
  38163. }
  38164. delta += (m - n) * handledCPCountPlusOne;
  38165. n = m;
  38166. for (i = 0; i < input.length; i++) {
  38167. currentValue = input[i];
  38168. if (currentValue < n && ++delta > maxInt) {
  38169. throw RangeError$3(OVERFLOW_ERROR);
  38170. }
  38171. if (currentValue == n) {
  38172. // Represent delta as a generalized variable-length integer.
  38173. var q = delta;
  38174. var k = base;
  38175. while (true) {
  38176. var t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  38177. if (q < t) break;
  38178. var qMinusT = q - t;
  38179. var baseMinusT = base - t;
  38180. push$6(output, fromCharCode$1(digitToBasic(t + qMinusT % baseMinusT)));
  38181. q = floor$1(qMinusT / baseMinusT);
  38182. k += base;
  38183. }
  38184. push$6(output, fromCharCode$1(digitToBasic(q)));
  38185. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  38186. delta = 0;
  38187. handledCPCount++;
  38188. }
  38189. }
  38190. delta++;
  38191. n++;
  38192. }
  38193. return join$2(output, '');
  38194. };
  38195. var stringPunycodeToAscii = function (input) {
  38196. var encoded = [];
  38197. var labels = split$1(replace$2(toLowerCase(input), regexSeparators, '\u002E'), '.');
  38198. var i, label;
  38199. for (i = 0; i < labels.length; i++) {
  38200. label = labels[i];
  38201. push$6(encoded, exec$3(regexNonASCII, label) ? 'xn--' + encode(label) : label);
  38202. }
  38203. return join$2(encoded, '.');
  38204. };
  38205. var floor$2 = Math.floor;
  38206. var mergeSort = function (array, comparefn) {
  38207. var length = array.length;
  38208. var middle = floor$2(length / 2);
  38209. return length < 8 ? insertionSort(array, comparefn) : merge(
  38210. array,
  38211. mergeSort(arraySliceSimple(array, 0, middle), comparefn),
  38212. mergeSort(arraySliceSimple(array, middle), comparefn),
  38213. comparefn
  38214. );
  38215. };
  38216. var insertionSort = function (array, comparefn) {
  38217. var length = array.length;
  38218. var i = 1;
  38219. var element, j;
  38220. while (i < length) {
  38221. j = i;
  38222. element = array[i];
  38223. while (j && comparefn(array[j - 1], element) > 0) {
  38224. array[j] = array[--j];
  38225. }
  38226. if (j !== i++) array[j] = element;
  38227. } return array;
  38228. };
  38229. var merge = function (array, left, right, comparefn) {
  38230. var llength = left.length;
  38231. var rlength = right.length;
  38232. var lindex = 0;
  38233. var rindex = 0;
  38234. while (lindex < llength || rindex < rlength) {
  38235. array[lindex + rindex] = (lindex < llength && rindex < rlength)
  38236. ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]
  38237. : lindex < llength ? left[lindex++] : right[rindex++];
  38238. } return array;
  38239. };
  38240. var arraySort = mergeSort;
  38241. // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
  38242. var ITERATOR$8 = wellKnownSymbol('iterator');
  38243. var URL_SEARCH_PARAMS = 'URLSearchParams';
  38244. var URL_SEARCH_PARAMS_ITERATOR = URL_SEARCH_PARAMS + 'Iterator';
  38245. var setInternalState$5 = internalState.set;
  38246. var getInternalParamsState = internalState.getterFor(URL_SEARCH_PARAMS);
  38247. var getInternalIteratorState = internalState.getterFor(URL_SEARCH_PARAMS_ITERATOR);
  38248. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  38249. var getOwnPropertyDescriptor$8 = Object.getOwnPropertyDescriptor;
  38250. // Avoid NodeJS experimental warning
  38251. var safeGetBuiltIn = function (name) {
  38252. if (!descriptors) return global_1[name];
  38253. var descriptor = getOwnPropertyDescriptor$8(global_1, name);
  38254. return descriptor && descriptor.value;
  38255. };
  38256. var nativeFetch = safeGetBuiltIn('fetch');
  38257. var NativeRequest = safeGetBuiltIn('Request');
  38258. var Headers = safeGetBuiltIn('Headers');
  38259. var RequestPrototype = NativeRequest && NativeRequest.prototype;
  38260. var HeadersPrototype = Headers && Headers.prototype;
  38261. var RegExp$1 = global_1.RegExp;
  38262. var TypeError$m = global_1.TypeError;
  38263. var decodeURIComponent$1 = global_1.decodeURIComponent;
  38264. var encodeURIComponent$1 = global_1.encodeURIComponent;
  38265. var charAt$4 = functionUncurryThis(''.charAt);
  38266. var join$3 = functionUncurryThis([].join);
  38267. var push$7 = functionUncurryThis([].push);
  38268. var replace$3 = functionUncurryThis(''.replace);
  38269. var shift = functionUncurryThis([].shift);
  38270. var splice$5 = functionUncurryThis([].splice);
  38271. var split$2 = functionUncurryThis(''.split);
  38272. var stringSlice$3 = functionUncurryThis(''.slice);
  38273. var plus = /\+/g;
  38274. var sequences = Array(4);
  38275. var percentSequence = function (bytes) {
  38276. return sequences[bytes - 1] || (sequences[bytes - 1] = RegExp$1('((?:%[\\da-f]{2}){' + bytes + '})', 'gi'));
  38277. };
  38278. var percentDecode = function (sequence) {
  38279. try {
  38280. return decodeURIComponent$1(sequence);
  38281. } catch (error) {
  38282. return sequence;
  38283. }
  38284. };
  38285. var deserialize = function (it) {
  38286. var result = replace$3(it, plus, ' ');
  38287. var bytes = 4;
  38288. try {
  38289. return decodeURIComponent$1(result);
  38290. } catch (error) {
  38291. while (bytes) {
  38292. result = replace$3(result, percentSequence(bytes--), percentDecode);
  38293. }
  38294. return result;
  38295. }
  38296. };
  38297. var find$4 = /[!'()~]|%20/g;
  38298. var replacements = {
  38299. '!': '%21',
  38300. "'": '%27',
  38301. '(': '%28',
  38302. ')': '%29',
  38303. '~': '%7E',
  38304. '%20': '+'
  38305. };
  38306. var replacer = function (match) {
  38307. return replacements[match];
  38308. };
  38309. var serialize = function (it) {
  38310. return replace$3(encodeURIComponent$1(it), find$4, replacer);
  38311. };
  38312. var URLSearchParamsIterator = createIteratorConstructor(function Iterator(params, kind) {
  38313. setInternalState$5(this, {
  38314. type: URL_SEARCH_PARAMS_ITERATOR,
  38315. iterator: getIterator(getInternalParamsState(params).entries),
  38316. kind: kind
  38317. });
  38318. }, 'Iterator', function next() {
  38319. var state = getInternalIteratorState(this);
  38320. var kind = state.kind;
  38321. var step = state.iterator.next();
  38322. var entry = step.value;
  38323. if (!step.done) {
  38324. step.value = kind === 'keys' ? entry.key : kind === 'values' ? entry.value : [entry.key, entry.value];
  38325. } return step;
  38326. }, true);
  38327. var URLSearchParamsState = function (init) {
  38328. this.entries = [];
  38329. this.url = null;
  38330. if (init !== undefined) {
  38331. if (isObject(init)) this.parseObject(init);
  38332. else this.parseQuery(typeof init == 'string' ? charAt$4(init, 0) === '?' ? stringSlice$3(init, 1) : init : toString_1(init));
  38333. }
  38334. };
  38335. URLSearchParamsState.prototype = {
  38336. type: URL_SEARCH_PARAMS,
  38337. bindURL: function (url) {
  38338. this.url = url;
  38339. this.update();
  38340. },
  38341. parseObject: function (object) {
  38342. var iteratorMethod = getIteratorMethod(object);
  38343. var iterator, next, step, entryIterator, entryNext, first, second;
  38344. if (iteratorMethod) {
  38345. iterator = getIterator(object, iteratorMethod);
  38346. next = iterator.next;
  38347. while (!(step = functionCall(next, iterator)).done) {
  38348. entryIterator = getIterator(anObject(step.value));
  38349. entryNext = entryIterator.next;
  38350. if (
  38351. (first = functionCall(entryNext, entryIterator)).done ||
  38352. (second = functionCall(entryNext, entryIterator)).done ||
  38353. !functionCall(entryNext, entryIterator).done
  38354. ) throw TypeError$m('Expected sequence with length 2');
  38355. push$7(this.entries, { key: toString_1(first.value), value: toString_1(second.value) });
  38356. }
  38357. } else for (var key in object) if (hasOwnProperty_1(object, key)) {
  38358. push$7(this.entries, { key: key, value: toString_1(object[key]) });
  38359. }
  38360. },
  38361. parseQuery: function (query) {
  38362. if (query) {
  38363. var attributes = split$2(query, '&');
  38364. var index = 0;
  38365. var attribute, entry;
  38366. while (index < attributes.length) {
  38367. attribute = attributes[index++];
  38368. if (attribute.length) {
  38369. entry = split$2(attribute, '=');
  38370. push$7(this.entries, {
  38371. key: deserialize(shift(entry)),
  38372. value: deserialize(join$3(entry, '='))
  38373. });
  38374. }
  38375. }
  38376. }
  38377. },
  38378. serialize: function () {
  38379. var entries = this.entries;
  38380. var result = [];
  38381. var index = 0;
  38382. var entry;
  38383. while (index < entries.length) {
  38384. entry = entries[index++];
  38385. push$7(result, serialize(entry.key) + '=' + serialize(entry.value));
  38386. } return join$3(result, '&');
  38387. },
  38388. update: function () {
  38389. this.entries.length = 0;
  38390. this.parseQuery(this.url.query);
  38391. },
  38392. updateURL: function () {
  38393. if (this.url) this.url.update();
  38394. }
  38395. };
  38396. // `URLSearchParams` constructor
  38397. // https://url.spec.whatwg.org/#interface-urlsearchparams
  38398. var URLSearchParamsConstructor = function URLSearchParams(/* init */) {
  38399. anInstance(this, URLSearchParamsPrototype);
  38400. var init = arguments.length > 0 ? arguments[0] : undefined;
  38401. setInternalState$5(this, new URLSearchParamsState(init));
  38402. };
  38403. var URLSearchParamsPrototype = URLSearchParamsConstructor.prototype;
  38404. defineBuiltIns(URLSearchParamsPrototype, {
  38405. // `URLSearchParams.prototype.append` method
  38406. // https://url.spec.whatwg.org/#dom-urlsearchparams-append
  38407. append: function append(name, value) {
  38408. validateArgumentsLength(arguments.length, 2);
  38409. var state = getInternalParamsState(this);
  38410. push$7(state.entries, { key: toString_1(name), value: toString_1(value) });
  38411. state.updateURL();
  38412. },
  38413. // `URLSearchParams.prototype.delete` method
  38414. // https://url.spec.whatwg.org/#dom-urlsearchparams-delete
  38415. 'delete': function (name) {
  38416. validateArgumentsLength(arguments.length, 1);
  38417. var state = getInternalParamsState(this);
  38418. var entries = state.entries;
  38419. var key = toString_1(name);
  38420. var index = 0;
  38421. while (index < entries.length) {
  38422. if (entries[index].key === key) splice$5(entries, index, 1);
  38423. else index++;
  38424. }
  38425. state.updateURL();
  38426. },
  38427. // `URLSearchParams.prototype.get` method
  38428. // https://url.spec.whatwg.org/#dom-urlsearchparams-get
  38429. get: function get(name) {
  38430. validateArgumentsLength(arguments.length, 1);
  38431. var entries = getInternalParamsState(this).entries;
  38432. var key = toString_1(name);
  38433. var index = 0;
  38434. for (; index < entries.length; index++) {
  38435. if (entries[index].key === key) return entries[index].value;
  38436. }
  38437. return null;
  38438. },
  38439. // `URLSearchParams.prototype.getAll` method
  38440. // https://url.spec.whatwg.org/#dom-urlsearchparams-getall
  38441. getAll: function getAll(name) {
  38442. validateArgumentsLength(arguments.length, 1);
  38443. var entries = getInternalParamsState(this).entries;
  38444. var key = toString_1(name);
  38445. var result = [];
  38446. var index = 0;
  38447. for (; index < entries.length; index++) {
  38448. if (entries[index].key === key) push$7(result, entries[index].value);
  38449. }
  38450. return result;
  38451. },
  38452. // `URLSearchParams.prototype.has` method
  38453. // https://url.spec.whatwg.org/#dom-urlsearchparams-has
  38454. has: function has(name) {
  38455. validateArgumentsLength(arguments.length, 1);
  38456. var entries = getInternalParamsState(this).entries;
  38457. var key = toString_1(name);
  38458. var index = 0;
  38459. while (index < entries.length) {
  38460. if (entries[index++].key === key) return true;
  38461. }
  38462. return false;
  38463. },
  38464. // `URLSearchParams.prototype.set` method
  38465. // https://url.spec.whatwg.org/#dom-urlsearchparams-set
  38466. set: function set(name, value) {
  38467. validateArgumentsLength(arguments.length, 1);
  38468. var state = getInternalParamsState(this);
  38469. var entries = state.entries;
  38470. var found = false;
  38471. var key = toString_1(name);
  38472. var val = toString_1(value);
  38473. var index = 0;
  38474. var entry;
  38475. for (; index < entries.length; index++) {
  38476. entry = entries[index];
  38477. if (entry.key === key) {
  38478. if (found) splice$5(entries, index--, 1);
  38479. else {
  38480. found = true;
  38481. entry.value = val;
  38482. }
  38483. }
  38484. }
  38485. if (!found) push$7(entries, { key: key, value: val });
  38486. state.updateURL();
  38487. },
  38488. // `URLSearchParams.prototype.sort` method
  38489. // https://url.spec.whatwg.org/#dom-urlsearchparams-sort
  38490. sort: function sort() {
  38491. var state = getInternalParamsState(this);
  38492. arraySort(state.entries, function (a, b) {
  38493. return a.key > b.key ? 1 : -1;
  38494. });
  38495. state.updateURL();
  38496. },
  38497. // `URLSearchParams.prototype.forEach` method
  38498. forEach: function forEach(callback /* , thisArg */) {
  38499. var entries = getInternalParamsState(this).entries;
  38500. var boundFunction = functionBindContext(callback, arguments.length > 1 ? arguments[1] : undefined);
  38501. var index = 0;
  38502. var entry;
  38503. while (index < entries.length) {
  38504. entry = entries[index++];
  38505. boundFunction(entry.value, entry.key, this);
  38506. }
  38507. },
  38508. // `URLSearchParams.prototype.keys` method
  38509. keys: function keys() {
  38510. return new URLSearchParamsIterator(this, 'keys');
  38511. },
  38512. // `URLSearchParams.prototype.values` method
  38513. values: function values() {
  38514. return new URLSearchParamsIterator(this, 'values');
  38515. },
  38516. // `URLSearchParams.prototype.entries` method
  38517. entries: function entries() {
  38518. return new URLSearchParamsIterator(this, 'entries');
  38519. }
  38520. }, { enumerable: true });
  38521. // `URLSearchParams.prototype[@@iterator]` method
  38522. defineBuiltIn(URLSearchParamsPrototype, ITERATOR$8, URLSearchParamsPrototype.entries, { name: 'entries' });
  38523. // `URLSearchParams.prototype.toString` method
  38524. // https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior
  38525. defineBuiltIn(URLSearchParamsPrototype, 'toString', function toString() {
  38526. return getInternalParamsState(this).serialize();
  38527. }, { enumerable: true });
  38528. setToStringTag(URLSearchParamsConstructor, URL_SEARCH_PARAMS);
  38529. _export({ global: true, constructor: true, forced: !nativeUrl }, {
  38530. URLSearchParams: URLSearchParamsConstructor
  38531. });
  38532. // Wrap `fetch` and `Request` for correct work with polyfilled `URLSearchParams`
  38533. if (!nativeUrl && isCallable(Headers)) {
  38534. var headersHas = functionUncurryThis(HeadersPrototype.has);
  38535. var headersSet = functionUncurryThis(HeadersPrototype.set);
  38536. var wrapRequestOptions = function (init) {
  38537. if (isObject(init)) {
  38538. var body = init.body;
  38539. var headers;
  38540. if (classof(body) === URL_SEARCH_PARAMS) {
  38541. headers = init.headers ? new Headers(init.headers) : new Headers();
  38542. if (!headersHas(headers, 'content-type')) {
  38543. headersSet(headers, 'content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
  38544. }
  38545. return objectCreate(init, {
  38546. body: createPropertyDescriptor(0, toString_1(body)),
  38547. headers: createPropertyDescriptor(0, headers)
  38548. });
  38549. }
  38550. } return init;
  38551. };
  38552. if (isCallable(nativeFetch)) {
  38553. _export({ global: true, enumerable: true, dontCallGetSet: true, forced: true }, {
  38554. fetch: function fetch(input /* , init */) {
  38555. return nativeFetch(input, arguments.length > 1 ? wrapRequestOptions(arguments[1]) : {});
  38556. }
  38557. });
  38558. }
  38559. if (isCallable(NativeRequest)) {
  38560. var RequestConstructor = function Request(input /* , init */) {
  38561. anInstance(this, RequestPrototype);
  38562. return new NativeRequest(input, arguments.length > 1 ? wrapRequestOptions(arguments[1]) : {});
  38563. };
  38564. RequestPrototype.constructor = RequestConstructor;
  38565. RequestConstructor.prototype = RequestPrototype;
  38566. _export({ global: true, constructor: true, dontCallGetSet: true, forced: true }, {
  38567. Request: RequestConstructor
  38568. });
  38569. }
  38570. }
  38571. var web_urlSearchParams_constructor = {
  38572. URLSearchParams: URLSearchParamsConstructor,
  38573. getState: getInternalParamsState
  38574. };
  38575. // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
  38576. var codeAt = stringMultibyte.codeAt;
  38577. var setInternalState$6 = internalState.set;
  38578. var getInternalURLState = internalState.getterFor('URL');
  38579. var URLSearchParams$1 = web_urlSearchParams_constructor.URLSearchParams;
  38580. var getInternalSearchParamsState = web_urlSearchParams_constructor.getState;
  38581. var NativeURL = global_1.URL;
  38582. var TypeError$n = global_1.TypeError;
  38583. var parseInt$1 = global_1.parseInt;
  38584. var floor$3 = Math.floor;
  38585. var pow = Math.pow;
  38586. var charAt$5 = functionUncurryThis(''.charAt);
  38587. var exec$4 = functionUncurryThis(/./.exec);
  38588. var join$4 = functionUncurryThis([].join);
  38589. var numberToString$1 = functionUncurryThis(1.0.toString);
  38590. var pop = functionUncurryThis([].pop);
  38591. var push$8 = functionUncurryThis([].push);
  38592. var replace$4 = functionUncurryThis(''.replace);
  38593. var shift$1 = functionUncurryThis([].shift);
  38594. var split$3 = functionUncurryThis(''.split);
  38595. var stringSlice$4 = functionUncurryThis(''.slice);
  38596. var toLowerCase$1 = functionUncurryThis(''.toLowerCase);
  38597. var unshift = functionUncurryThis([].unshift);
  38598. var INVALID_AUTHORITY = 'Invalid authority';
  38599. var INVALID_SCHEME = 'Invalid scheme';
  38600. var INVALID_HOST = 'Invalid host';
  38601. var INVALID_PORT = 'Invalid port';
  38602. var ALPHA = /[a-z]/i;
  38603. // eslint-disable-next-line regexp/no-obscure-range -- safe
  38604. var ALPHANUMERIC = /[\d+-.a-z]/i;
  38605. var DIGIT = /\d/;
  38606. var HEX_START = /^0x/i;
  38607. var OCT = /^[0-7]+$/;
  38608. var DEC = /^\d+$/;
  38609. var HEX = /^[\da-f]+$/i;
  38610. /* eslint-disable regexp/no-control-character -- safe */
  38611. var FORBIDDEN_HOST_CODE_POINT = /[\0\t\n\r #%/:<>?@[\\\]^|]/;
  38612. var FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\0\t\n\r #/:<>?@[\\\]^|]/;
  38613. var LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE = /^[\u0000-\u0020]+|[\u0000-\u0020]+$/g;
  38614. var TAB_AND_NEW_LINE = /[\t\n\r]/g;
  38615. /* eslint-enable regexp/no-control-character -- safe */
  38616. var EOF;
  38617. // https://url.spec.whatwg.org/#ipv4-number-parser
  38618. var parseIPv4 = function (input) {
  38619. var parts = split$3(input, '.');
  38620. var partsLength, numbers, index, part, radix, number, ipv4;
  38621. if (parts.length && parts[parts.length - 1] == '') {
  38622. parts.length--;
  38623. }
  38624. partsLength = parts.length;
  38625. if (partsLength > 4) return input;
  38626. numbers = [];
  38627. for (index = 0; index < partsLength; index++) {
  38628. part = parts[index];
  38629. if (part == '') return input;
  38630. radix = 10;
  38631. if (part.length > 1 && charAt$5(part, 0) == '0') {
  38632. radix = exec$4(HEX_START, part) ? 16 : 8;
  38633. part = stringSlice$4(part, radix == 8 ? 1 : 2);
  38634. }
  38635. if (part === '') {
  38636. number = 0;
  38637. } else {
  38638. if (!exec$4(radix == 10 ? DEC : radix == 8 ? OCT : HEX, part)) return input;
  38639. number = parseInt$1(part, radix);
  38640. }
  38641. push$8(numbers, number);
  38642. }
  38643. for (index = 0; index < partsLength; index++) {
  38644. number = numbers[index];
  38645. if (index == partsLength - 1) {
  38646. if (number >= pow(256, 5 - partsLength)) return null;
  38647. } else if (number > 255) return null;
  38648. }
  38649. ipv4 = pop(numbers);
  38650. for (index = 0; index < numbers.length; index++) {
  38651. ipv4 += numbers[index] * pow(256, 3 - index);
  38652. }
  38653. return ipv4;
  38654. };
  38655. // https://url.spec.whatwg.org/#concept-ipv6-parser
  38656. // eslint-disable-next-line max-statements -- TODO
  38657. var parseIPv6 = function (input) {
  38658. var address = [0, 0, 0, 0, 0, 0, 0, 0];
  38659. var pieceIndex = 0;
  38660. var compress = null;
  38661. var pointer = 0;
  38662. var value, length, numbersSeen, ipv4Piece, number, swaps, swap;
  38663. var chr = function () {
  38664. return charAt$5(input, pointer);
  38665. };
  38666. if (chr() == ':') {
  38667. if (charAt$5(input, 1) != ':') return;
  38668. pointer += 2;
  38669. pieceIndex++;
  38670. compress = pieceIndex;
  38671. }
  38672. while (chr()) {
  38673. if (pieceIndex == 8) return;
  38674. if (chr() == ':') {
  38675. if (compress !== null) return;
  38676. pointer++;
  38677. pieceIndex++;
  38678. compress = pieceIndex;
  38679. continue;
  38680. }
  38681. value = length = 0;
  38682. while (length < 4 && exec$4(HEX, chr())) {
  38683. value = value * 16 + parseInt$1(chr(), 16);
  38684. pointer++;
  38685. length++;
  38686. }
  38687. if (chr() == '.') {
  38688. if (length == 0) return;
  38689. pointer -= length;
  38690. if (pieceIndex > 6) return;
  38691. numbersSeen = 0;
  38692. while (chr()) {
  38693. ipv4Piece = null;
  38694. if (numbersSeen > 0) {
  38695. if (chr() == '.' && numbersSeen < 4) pointer++;
  38696. else return;
  38697. }
  38698. if (!exec$4(DIGIT, chr())) return;
  38699. while (exec$4(DIGIT, chr())) {
  38700. number = parseInt$1(chr(), 10);
  38701. if (ipv4Piece === null) ipv4Piece = number;
  38702. else if (ipv4Piece == 0) return;
  38703. else ipv4Piece = ipv4Piece * 10 + number;
  38704. if (ipv4Piece > 255) return;
  38705. pointer++;
  38706. }
  38707. address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece;
  38708. numbersSeen++;
  38709. if (numbersSeen == 2 || numbersSeen == 4) pieceIndex++;
  38710. }
  38711. if (numbersSeen != 4) return;
  38712. break;
  38713. } else if (chr() == ':') {
  38714. pointer++;
  38715. if (!chr()) return;
  38716. } else if (chr()) return;
  38717. address[pieceIndex++] = value;
  38718. }
  38719. if (compress !== null) {
  38720. swaps = pieceIndex - compress;
  38721. pieceIndex = 7;
  38722. while (pieceIndex != 0 && swaps > 0) {
  38723. swap = address[pieceIndex];
  38724. address[pieceIndex--] = address[compress + swaps - 1];
  38725. address[compress + --swaps] = swap;
  38726. }
  38727. } else if (pieceIndex != 8) return;
  38728. return address;
  38729. };
  38730. var findLongestZeroSequence = function (ipv6) {
  38731. var maxIndex = null;
  38732. var maxLength = 1;
  38733. var currStart = null;
  38734. var currLength = 0;
  38735. var index = 0;
  38736. for (; index < 8; index++) {
  38737. if (ipv6[index] !== 0) {
  38738. if (currLength > maxLength) {
  38739. maxIndex = currStart;
  38740. maxLength = currLength;
  38741. }
  38742. currStart = null;
  38743. currLength = 0;
  38744. } else {
  38745. if (currStart === null) currStart = index;
  38746. ++currLength;
  38747. }
  38748. }
  38749. if (currLength > maxLength) {
  38750. maxIndex = currStart;
  38751. maxLength = currLength;
  38752. }
  38753. return maxIndex;
  38754. };
  38755. // https://url.spec.whatwg.org/#host-serializing
  38756. var serializeHost = function (host) {
  38757. var result, index, compress, ignore0;
  38758. // ipv4
  38759. if (typeof host == 'number') {
  38760. result = [];
  38761. for (index = 0; index < 4; index++) {
  38762. unshift(result, host % 256);
  38763. host = floor$3(host / 256);
  38764. } return join$4(result, '.');
  38765. // ipv6
  38766. } else if (typeof host == 'object') {
  38767. result = '';
  38768. compress = findLongestZeroSequence(host);
  38769. for (index = 0; index < 8; index++) {
  38770. if (ignore0 && host[index] === 0) continue;
  38771. if (ignore0) ignore0 = false;
  38772. if (compress === index) {
  38773. result += index ? ':' : '::';
  38774. ignore0 = true;
  38775. } else {
  38776. result += numberToString$1(host[index], 16);
  38777. if (index < 7) result += ':';
  38778. }
  38779. }
  38780. return '[' + result + ']';
  38781. } return host;
  38782. };
  38783. var C0ControlPercentEncodeSet = {};
  38784. var fragmentPercentEncodeSet = objectAssign({}, C0ControlPercentEncodeSet, {
  38785. ' ': 1, '"': 1, '<': 1, '>': 1, '`': 1
  38786. });
  38787. var pathPercentEncodeSet = objectAssign({}, fragmentPercentEncodeSet, {
  38788. '#': 1, '?': 1, '{': 1, '}': 1
  38789. });
  38790. var userinfoPercentEncodeSet = objectAssign({}, pathPercentEncodeSet, {
  38791. '/': 1, ':': 1, ';': 1, '=': 1, '@': 1, '[': 1, '\\': 1, ']': 1, '^': 1, '|': 1
  38792. });
  38793. var percentEncode = function (chr, set) {
  38794. var code = codeAt(chr, 0);
  38795. return code > 0x20 && code < 0x7F && !hasOwnProperty_1(set, chr) ? chr : encodeURIComponent(chr);
  38796. };
  38797. // https://url.spec.whatwg.org/#special-scheme
  38798. var specialSchemes = {
  38799. ftp: 21,
  38800. file: null,
  38801. http: 80,
  38802. https: 443,
  38803. ws: 80,
  38804. wss: 443
  38805. };
  38806. // https://url.spec.whatwg.org/#windows-drive-letter
  38807. var isWindowsDriveLetter = function (string, normalized) {
  38808. var second;
  38809. return string.length == 2 && exec$4(ALPHA, charAt$5(string, 0))
  38810. && ((second = charAt$5(string, 1)) == ':' || (!normalized && second == '|'));
  38811. };
  38812. // https://url.spec.whatwg.org/#start-with-a-windows-drive-letter
  38813. var startsWithWindowsDriveLetter = function (string) {
  38814. var third;
  38815. return string.length > 1 && isWindowsDriveLetter(stringSlice$4(string, 0, 2)) && (
  38816. string.length == 2 ||
  38817. ((third = charAt$5(string, 2)) === '/' || third === '\\' || third === '?' || third === '#')
  38818. );
  38819. };
  38820. // https://url.spec.whatwg.org/#single-dot-path-segment
  38821. var isSingleDot = function (segment) {
  38822. return segment === '.' || toLowerCase$1(segment) === '%2e';
  38823. };
  38824. // https://url.spec.whatwg.org/#double-dot-path-segment
  38825. var isDoubleDot = function (segment) {
  38826. segment = toLowerCase$1(segment);
  38827. return segment === '..' || segment === '%2e.' || segment === '.%2e' || segment === '%2e%2e';
  38828. };
  38829. // States:
  38830. var SCHEME_START = {};
  38831. var SCHEME = {};
  38832. var NO_SCHEME = {};
  38833. var SPECIAL_RELATIVE_OR_AUTHORITY = {};
  38834. var PATH_OR_AUTHORITY = {};
  38835. var RELATIVE = {};
  38836. var RELATIVE_SLASH = {};
  38837. var SPECIAL_AUTHORITY_SLASHES = {};
  38838. var SPECIAL_AUTHORITY_IGNORE_SLASHES = {};
  38839. var AUTHORITY = {};
  38840. var HOST = {};
  38841. var HOSTNAME = {};
  38842. var PORT = {};
  38843. var FILE = {};
  38844. var FILE_SLASH = {};
  38845. var FILE_HOST = {};
  38846. var PATH_START = {};
  38847. var PATH = {};
  38848. var CANNOT_BE_A_BASE_URL_PATH = {};
  38849. var QUERY = {};
  38850. var FRAGMENT = {};
  38851. var URLState = function (url, isBase, base) {
  38852. var urlString = toString_1(url);
  38853. var baseState, failure, searchParams;
  38854. if (isBase) {
  38855. failure = this.parse(urlString);
  38856. if (failure) throw TypeError$n(failure);
  38857. this.searchParams = null;
  38858. } else {
  38859. if (base !== undefined) baseState = new URLState(base, true);
  38860. failure = this.parse(urlString, null, baseState);
  38861. if (failure) throw TypeError$n(failure);
  38862. searchParams = getInternalSearchParamsState(new URLSearchParams$1());
  38863. searchParams.bindURL(this);
  38864. this.searchParams = searchParams;
  38865. }
  38866. };
  38867. URLState.prototype = {
  38868. type: 'URL',
  38869. // https://url.spec.whatwg.org/#url-parsing
  38870. // eslint-disable-next-line max-statements -- TODO
  38871. parse: function (input, stateOverride, base) {
  38872. var url = this;
  38873. var state = stateOverride || SCHEME_START;
  38874. var pointer = 0;
  38875. var buffer = '';
  38876. var seenAt = false;
  38877. var seenBracket = false;
  38878. var seenPasswordToken = false;
  38879. var codePoints, chr, bufferCodePoints, failure;
  38880. input = toString_1(input);
  38881. if (!stateOverride) {
  38882. url.scheme = '';
  38883. url.username = '';
  38884. url.password = '';
  38885. url.host = null;
  38886. url.port = null;
  38887. url.path = [];
  38888. url.query = null;
  38889. url.fragment = null;
  38890. url.cannotBeABaseURL = false;
  38891. input = replace$4(input, LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE, '');
  38892. }
  38893. input = replace$4(input, TAB_AND_NEW_LINE, '');
  38894. codePoints = arrayFrom(input);
  38895. while (pointer <= codePoints.length) {
  38896. chr = codePoints[pointer];
  38897. switch (state) {
  38898. case SCHEME_START:
  38899. if (chr && exec$4(ALPHA, chr)) {
  38900. buffer += toLowerCase$1(chr);
  38901. state = SCHEME;
  38902. } else if (!stateOverride) {
  38903. state = NO_SCHEME;
  38904. continue;
  38905. } else return INVALID_SCHEME;
  38906. break;
  38907. case SCHEME:
  38908. if (chr && (exec$4(ALPHANUMERIC, chr) || chr == '+' || chr == '-' || chr == '.')) {
  38909. buffer += toLowerCase$1(chr);
  38910. } else if (chr == ':') {
  38911. if (stateOverride && (
  38912. (url.isSpecial() != hasOwnProperty_1(specialSchemes, buffer)) ||
  38913. (buffer == 'file' && (url.includesCredentials() || url.port !== null)) ||
  38914. (url.scheme == 'file' && !url.host)
  38915. )) return;
  38916. url.scheme = buffer;
  38917. if (stateOverride) {
  38918. if (url.isSpecial() && specialSchemes[url.scheme] == url.port) url.port = null;
  38919. return;
  38920. }
  38921. buffer = '';
  38922. if (url.scheme == 'file') {
  38923. state = FILE;
  38924. } else if (url.isSpecial() && base && base.scheme == url.scheme) {
  38925. state = SPECIAL_RELATIVE_OR_AUTHORITY;
  38926. } else if (url.isSpecial()) {
  38927. state = SPECIAL_AUTHORITY_SLASHES;
  38928. } else if (codePoints[pointer + 1] == '/') {
  38929. state = PATH_OR_AUTHORITY;
  38930. pointer++;
  38931. } else {
  38932. url.cannotBeABaseURL = true;
  38933. push$8(url.path, '');
  38934. state = CANNOT_BE_A_BASE_URL_PATH;
  38935. }
  38936. } else if (!stateOverride) {
  38937. buffer = '';
  38938. state = NO_SCHEME;
  38939. pointer = 0;
  38940. continue;
  38941. } else return INVALID_SCHEME;
  38942. break;
  38943. case NO_SCHEME:
  38944. if (!base || (base.cannotBeABaseURL && chr != '#')) return INVALID_SCHEME;
  38945. if (base.cannotBeABaseURL && chr == '#') {
  38946. url.scheme = base.scheme;
  38947. url.path = arraySliceSimple(base.path);
  38948. url.query = base.query;
  38949. url.fragment = '';
  38950. url.cannotBeABaseURL = true;
  38951. state = FRAGMENT;
  38952. break;
  38953. }
  38954. state = base.scheme == 'file' ? FILE : RELATIVE;
  38955. continue;
  38956. case SPECIAL_RELATIVE_OR_AUTHORITY:
  38957. if (chr == '/' && codePoints[pointer + 1] == '/') {
  38958. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  38959. pointer++;
  38960. } else {
  38961. state = RELATIVE;
  38962. continue;
  38963. } break;
  38964. case PATH_OR_AUTHORITY:
  38965. if (chr == '/') {
  38966. state = AUTHORITY;
  38967. break;
  38968. } else {
  38969. state = PATH;
  38970. continue;
  38971. }
  38972. case RELATIVE:
  38973. url.scheme = base.scheme;
  38974. if (chr == EOF) {
  38975. url.username = base.username;
  38976. url.password = base.password;
  38977. url.host = base.host;
  38978. url.port = base.port;
  38979. url.path = arraySliceSimple(base.path);
  38980. url.query = base.query;
  38981. } else if (chr == '/' || (chr == '\\' && url.isSpecial())) {
  38982. state = RELATIVE_SLASH;
  38983. } else if (chr == '?') {
  38984. url.username = base.username;
  38985. url.password = base.password;
  38986. url.host = base.host;
  38987. url.port = base.port;
  38988. url.path = arraySliceSimple(base.path);
  38989. url.query = '';
  38990. state = QUERY;
  38991. } else if (chr == '#') {
  38992. url.username = base.username;
  38993. url.password = base.password;
  38994. url.host = base.host;
  38995. url.port = base.port;
  38996. url.path = arraySliceSimple(base.path);
  38997. url.query = base.query;
  38998. url.fragment = '';
  38999. state = FRAGMENT;
  39000. } else {
  39001. url.username = base.username;
  39002. url.password = base.password;
  39003. url.host = base.host;
  39004. url.port = base.port;
  39005. url.path = arraySliceSimple(base.path);
  39006. url.path.length--;
  39007. state = PATH;
  39008. continue;
  39009. } break;
  39010. case RELATIVE_SLASH:
  39011. if (url.isSpecial() && (chr == '/' || chr == '\\')) {
  39012. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  39013. } else if (chr == '/') {
  39014. state = AUTHORITY;
  39015. } else {
  39016. url.username = base.username;
  39017. url.password = base.password;
  39018. url.host = base.host;
  39019. url.port = base.port;
  39020. state = PATH;
  39021. continue;
  39022. } break;
  39023. case SPECIAL_AUTHORITY_SLASHES:
  39024. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  39025. if (chr != '/' || charAt$5(buffer, pointer + 1) != '/') continue;
  39026. pointer++;
  39027. break;
  39028. case SPECIAL_AUTHORITY_IGNORE_SLASHES:
  39029. if (chr != '/' && chr != '\\') {
  39030. state = AUTHORITY;
  39031. continue;
  39032. } break;
  39033. case AUTHORITY:
  39034. if (chr == '@') {
  39035. if (seenAt) buffer = '%40' + buffer;
  39036. seenAt = true;
  39037. bufferCodePoints = arrayFrom(buffer);
  39038. for (var i = 0; i < bufferCodePoints.length; i++) {
  39039. var codePoint = bufferCodePoints[i];
  39040. if (codePoint == ':' && !seenPasswordToken) {
  39041. seenPasswordToken = true;
  39042. continue;
  39043. }
  39044. var encodedCodePoints = percentEncode(codePoint, userinfoPercentEncodeSet);
  39045. if (seenPasswordToken) url.password += encodedCodePoints;
  39046. else url.username += encodedCodePoints;
  39047. }
  39048. buffer = '';
  39049. } else if (
  39050. chr == EOF || chr == '/' || chr == '?' || chr == '#' ||
  39051. (chr == '\\' && url.isSpecial())
  39052. ) {
  39053. if (seenAt && buffer == '') return INVALID_AUTHORITY;
  39054. pointer -= arrayFrom(buffer).length + 1;
  39055. buffer = '';
  39056. state = HOST;
  39057. } else buffer += chr;
  39058. break;
  39059. case HOST:
  39060. case HOSTNAME:
  39061. if (stateOverride && url.scheme == 'file') {
  39062. state = FILE_HOST;
  39063. continue;
  39064. } else if (chr == ':' && !seenBracket) {
  39065. if (buffer == '') return INVALID_HOST;
  39066. failure = url.parseHost(buffer);
  39067. if (failure) return failure;
  39068. buffer = '';
  39069. state = PORT;
  39070. if (stateOverride == HOSTNAME) return;
  39071. } else if (
  39072. chr == EOF || chr == '/' || chr == '?' || chr == '#' ||
  39073. (chr == '\\' && url.isSpecial())
  39074. ) {
  39075. if (url.isSpecial() && buffer == '') return INVALID_HOST;
  39076. if (stateOverride && buffer == '' && (url.includesCredentials() || url.port !== null)) return;
  39077. failure = url.parseHost(buffer);
  39078. if (failure) return failure;
  39079. buffer = '';
  39080. state = PATH_START;
  39081. if (stateOverride) return;
  39082. continue;
  39083. } else {
  39084. if (chr == '[') seenBracket = true;
  39085. else if (chr == ']') seenBracket = false;
  39086. buffer += chr;
  39087. } break;
  39088. case PORT:
  39089. if (exec$4(DIGIT, chr)) {
  39090. buffer += chr;
  39091. } else if (
  39092. chr == EOF || chr == '/' || chr == '?' || chr == '#' ||
  39093. (chr == '\\' && url.isSpecial()) ||
  39094. stateOverride
  39095. ) {
  39096. if (buffer != '') {
  39097. var port = parseInt$1(buffer, 10);
  39098. if (port > 0xFFFF) return INVALID_PORT;
  39099. url.port = (url.isSpecial() && port === specialSchemes[url.scheme]) ? null : port;
  39100. buffer = '';
  39101. }
  39102. if (stateOverride) return;
  39103. state = PATH_START;
  39104. continue;
  39105. } else return INVALID_PORT;
  39106. break;
  39107. case FILE:
  39108. url.scheme = 'file';
  39109. if (chr == '/' || chr == '\\') state = FILE_SLASH;
  39110. else if (base && base.scheme == 'file') {
  39111. if (chr == EOF) {
  39112. url.host = base.host;
  39113. url.path = arraySliceSimple(base.path);
  39114. url.query = base.query;
  39115. } else if (chr == '?') {
  39116. url.host = base.host;
  39117. url.path = arraySliceSimple(base.path);
  39118. url.query = '';
  39119. state = QUERY;
  39120. } else if (chr == '#') {
  39121. url.host = base.host;
  39122. url.path = arraySliceSimple(base.path);
  39123. url.query = base.query;
  39124. url.fragment = '';
  39125. state = FRAGMENT;
  39126. } else {
  39127. if (!startsWithWindowsDriveLetter(join$4(arraySliceSimple(codePoints, pointer), ''))) {
  39128. url.host = base.host;
  39129. url.path = arraySliceSimple(base.path);
  39130. url.shortenPath();
  39131. }
  39132. state = PATH;
  39133. continue;
  39134. }
  39135. } else {
  39136. state = PATH;
  39137. continue;
  39138. } break;
  39139. case FILE_SLASH:
  39140. if (chr == '/' || chr == '\\') {
  39141. state = FILE_HOST;
  39142. break;
  39143. }
  39144. if (base && base.scheme == 'file' && !startsWithWindowsDriveLetter(join$4(arraySliceSimple(codePoints, pointer), ''))) {
  39145. if (isWindowsDriveLetter(base.path[0], true)) push$8(url.path, base.path[0]);
  39146. else url.host = base.host;
  39147. }
  39148. state = PATH;
  39149. continue;
  39150. case FILE_HOST:
  39151. if (chr == EOF || chr == '/' || chr == '\\' || chr == '?' || chr == '#') {
  39152. if (!stateOverride && isWindowsDriveLetter(buffer)) {
  39153. state = PATH;
  39154. } else if (buffer == '') {
  39155. url.host = '';
  39156. if (stateOverride) return;
  39157. state = PATH_START;
  39158. } else {
  39159. failure = url.parseHost(buffer);
  39160. if (failure) return failure;
  39161. if (url.host == 'localhost') url.host = '';
  39162. if (stateOverride) return;
  39163. buffer = '';
  39164. state = PATH_START;
  39165. } continue;
  39166. } else buffer += chr;
  39167. break;
  39168. case PATH_START:
  39169. if (url.isSpecial()) {
  39170. state = PATH;
  39171. if (chr != '/' && chr != '\\') continue;
  39172. } else if (!stateOverride && chr == '?') {
  39173. url.query = '';
  39174. state = QUERY;
  39175. } else if (!stateOverride && chr == '#') {
  39176. url.fragment = '';
  39177. state = FRAGMENT;
  39178. } else if (chr != EOF) {
  39179. state = PATH;
  39180. if (chr != '/') continue;
  39181. } break;
  39182. case PATH:
  39183. if (
  39184. chr == EOF || chr == '/' ||
  39185. (chr == '\\' && url.isSpecial()) ||
  39186. (!stateOverride && (chr == '?' || chr == '#'))
  39187. ) {
  39188. if (isDoubleDot(buffer)) {
  39189. url.shortenPath();
  39190. if (chr != '/' && !(chr == '\\' && url.isSpecial())) {
  39191. push$8(url.path, '');
  39192. }
  39193. } else if (isSingleDot(buffer)) {
  39194. if (chr != '/' && !(chr == '\\' && url.isSpecial())) {
  39195. push$8(url.path, '');
  39196. }
  39197. } else {
  39198. if (url.scheme == 'file' && !url.path.length && isWindowsDriveLetter(buffer)) {
  39199. if (url.host) url.host = '';
  39200. buffer = charAt$5(buffer, 0) + ':'; // normalize windows drive letter
  39201. }
  39202. push$8(url.path, buffer);
  39203. }
  39204. buffer = '';
  39205. if (url.scheme == 'file' && (chr == EOF || chr == '?' || chr == '#')) {
  39206. while (url.path.length > 1 && url.path[0] === '') {
  39207. shift$1(url.path);
  39208. }
  39209. }
  39210. if (chr == '?') {
  39211. url.query = '';
  39212. state = QUERY;
  39213. } else if (chr == '#') {
  39214. url.fragment = '';
  39215. state = FRAGMENT;
  39216. }
  39217. } else {
  39218. buffer += percentEncode(chr, pathPercentEncodeSet);
  39219. } break;
  39220. case CANNOT_BE_A_BASE_URL_PATH:
  39221. if (chr == '?') {
  39222. url.query = '';
  39223. state = QUERY;
  39224. } else if (chr == '#') {
  39225. url.fragment = '';
  39226. state = FRAGMENT;
  39227. } else if (chr != EOF) {
  39228. url.path[0] += percentEncode(chr, C0ControlPercentEncodeSet);
  39229. } break;
  39230. case QUERY:
  39231. if (!stateOverride && chr == '#') {
  39232. url.fragment = '';
  39233. state = FRAGMENT;
  39234. } else if (chr != EOF) {
  39235. if (chr == "'" && url.isSpecial()) url.query += '%27';
  39236. else if (chr == '#') url.query += '%23';
  39237. else url.query += percentEncode(chr, C0ControlPercentEncodeSet);
  39238. } break;
  39239. case FRAGMENT:
  39240. if (chr != EOF) url.fragment += percentEncode(chr, fragmentPercentEncodeSet);
  39241. break;
  39242. }
  39243. pointer++;
  39244. }
  39245. },
  39246. // https://url.spec.whatwg.org/#host-parsing
  39247. parseHost: function (input) {
  39248. var result, codePoints, index;
  39249. if (charAt$5(input, 0) == '[') {
  39250. if (charAt$5(input, input.length - 1) != ']') return INVALID_HOST;
  39251. result = parseIPv6(stringSlice$4(input, 1, -1));
  39252. if (!result) return INVALID_HOST;
  39253. this.host = result;
  39254. // opaque host
  39255. } else if (!this.isSpecial()) {
  39256. if (exec$4(FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT, input)) return INVALID_HOST;
  39257. result = '';
  39258. codePoints = arrayFrom(input);
  39259. for (index = 0; index < codePoints.length; index++) {
  39260. result += percentEncode(codePoints[index], C0ControlPercentEncodeSet);
  39261. }
  39262. this.host = result;
  39263. } else {
  39264. input = stringPunycodeToAscii(input);
  39265. if (exec$4(FORBIDDEN_HOST_CODE_POINT, input)) return INVALID_HOST;
  39266. result = parseIPv4(input);
  39267. if (result === null) return INVALID_HOST;
  39268. this.host = result;
  39269. }
  39270. },
  39271. // https://url.spec.whatwg.org/#cannot-have-a-username-password-port
  39272. cannotHaveUsernamePasswordPort: function () {
  39273. return !this.host || this.cannotBeABaseURL || this.scheme == 'file';
  39274. },
  39275. // https://url.spec.whatwg.org/#include-credentials
  39276. includesCredentials: function () {
  39277. return this.username != '' || this.password != '';
  39278. },
  39279. // https://url.spec.whatwg.org/#is-special
  39280. isSpecial: function () {
  39281. return hasOwnProperty_1(specialSchemes, this.scheme);
  39282. },
  39283. // https://url.spec.whatwg.org/#shorten-a-urls-path
  39284. shortenPath: function () {
  39285. var path = this.path;
  39286. var pathSize = path.length;
  39287. if (pathSize && (this.scheme != 'file' || pathSize != 1 || !isWindowsDriveLetter(path[0], true))) {
  39288. path.length--;
  39289. }
  39290. },
  39291. // https://url.spec.whatwg.org/#concept-url-serializer
  39292. serialize: function () {
  39293. var url = this;
  39294. var scheme = url.scheme;
  39295. var username = url.username;
  39296. var password = url.password;
  39297. var host = url.host;
  39298. var port = url.port;
  39299. var path = url.path;
  39300. var query = url.query;
  39301. var fragment = url.fragment;
  39302. var output = scheme + ':';
  39303. if (host !== null) {
  39304. output += '//';
  39305. if (url.includesCredentials()) {
  39306. output += username + (password ? ':' + password : '') + '@';
  39307. }
  39308. output += serializeHost(host);
  39309. if (port !== null) output += ':' + port;
  39310. } else if (scheme == 'file') output += '//';
  39311. output += url.cannotBeABaseURL ? path[0] : path.length ? '/' + join$4(path, '/') : '';
  39312. if (query !== null) output += '?' + query;
  39313. if (fragment !== null) output += '#' + fragment;
  39314. return output;
  39315. },
  39316. // https://url.spec.whatwg.org/#dom-url-href
  39317. setHref: function (href) {
  39318. var failure = this.parse(href);
  39319. if (failure) throw TypeError$n(failure);
  39320. this.searchParams.update();
  39321. },
  39322. // https://url.spec.whatwg.org/#dom-url-origin
  39323. getOrigin: function () {
  39324. var scheme = this.scheme;
  39325. var port = this.port;
  39326. if (scheme == 'blob') try {
  39327. return new URLConstructor(scheme.path[0]).origin;
  39328. } catch (error) {
  39329. return 'null';
  39330. }
  39331. if (scheme == 'file' || !this.isSpecial()) return 'null';
  39332. return scheme + '://' + serializeHost(this.host) + (port !== null ? ':' + port : '');
  39333. },
  39334. // https://url.spec.whatwg.org/#dom-url-protocol
  39335. getProtocol: function () {
  39336. return this.scheme + ':';
  39337. },
  39338. setProtocol: function (protocol) {
  39339. this.parse(toString_1(protocol) + ':', SCHEME_START);
  39340. },
  39341. // https://url.spec.whatwg.org/#dom-url-username
  39342. getUsername: function () {
  39343. return this.username;
  39344. },
  39345. setUsername: function (username) {
  39346. var codePoints = arrayFrom(toString_1(username));
  39347. if (this.cannotHaveUsernamePasswordPort()) return;
  39348. this.username = '';
  39349. for (var i = 0; i < codePoints.length; i++) {
  39350. this.username += percentEncode(codePoints[i], userinfoPercentEncodeSet);
  39351. }
  39352. },
  39353. // https://url.spec.whatwg.org/#dom-url-password
  39354. getPassword: function () {
  39355. return this.password;
  39356. },
  39357. setPassword: function (password) {
  39358. var codePoints = arrayFrom(toString_1(password));
  39359. if (this.cannotHaveUsernamePasswordPort()) return;
  39360. this.password = '';
  39361. for (var i = 0; i < codePoints.length; i++) {
  39362. this.password += percentEncode(codePoints[i], userinfoPercentEncodeSet);
  39363. }
  39364. },
  39365. // https://url.spec.whatwg.org/#dom-url-host
  39366. getHost: function () {
  39367. var host = this.host;
  39368. var port = this.port;
  39369. return host === null ? ''
  39370. : port === null ? serializeHost(host)
  39371. : serializeHost(host) + ':' + port;
  39372. },
  39373. setHost: function (host) {
  39374. if (this.cannotBeABaseURL) return;
  39375. this.parse(host, HOST);
  39376. },
  39377. // https://url.spec.whatwg.org/#dom-url-hostname
  39378. getHostname: function () {
  39379. var host = this.host;
  39380. return host === null ? '' : serializeHost(host);
  39381. },
  39382. setHostname: function (hostname) {
  39383. if (this.cannotBeABaseURL) return;
  39384. this.parse(hostname, HOSTNAME);
  39385. },
  39386. // https://url.spec.whatwg.org/#dom-url-port
  39387. getPort: function () {
  39388. var port = this.port;
  39389. return port === null ? '' : toString_1(port);
  39390. },
  39391. setPort: function (port) {
  39392. if (this.cannotHaveUsernamePasswordPort()) return;
  39393. port = toString_1(port);
  39394. if (port == '') this.port = null;
  39395. else this.parse(port, PORT);
  39396. },
  39397. // https://url.spec.whatwg.org/#dom-url-pathname
  39398. getPathname: function () {
  39399. var path = this.path;
  39400. return this.cannotBeABaseURL ? path[0] : path.length ? '/' + join$4(path, '/') : '';
  39401. },
  39402. setPathname: function (pathname) {
  39403. if (this.cannotBeABaseURL) return;
  39404. this.path = [];
  39405. this.parse(pathname, PATH_START);
  39406. },
  39407. // https://url.spec.whatwg.org/#dom-url-search
  39408. getSearch: function () {
  39409. var query = this.query;
  39410. return query ? '?' + query : '';
  39411. },
  39412. setSearch: function (search) {
  39413. search = toString_1(search);
  39414. if (search == '') {
  39415. this.query = null;
  39416. } else {
  39417. if ('?' == charAt$5(search, 0)) search = stringSlice$4(search, 1);
  39418. this.query = '';
  39419. this.parse(search, QUERY);
  39420. }
  39421. this.searchParams.update();
  39422. },
  39423. // https://url.spec.whatwg.org/#dom-url-searchparams
  39424. getSearchParams: function () {
  39425. return this.searchParams.facade;
  39426. },
  39427. // https://url.spec.whatwg.org/#dom-url-hash
  39428. getHash: function () {
  39429. var fragment = this.fragment;
  39430. return fragment ? '#' + fragment : '';
  39431. },
  39432. setHash: function (hash) {
  39433. hash = toString_1(hash);
  39434. if (hash == '') {
  39435. this.fragment = null;
  39436. return;
  39437. }
  39438. if ('#' == charAt$5(hash, 0)) hash = stringSlice$4(hash, 1);
  39439. this.fragment = '';
  39440. this.parse(hash, FRAGMENT);
  39441. },
  39442. update: function () {
  39443. this.query = this.searchParams.serialize() || null;
  39444. }
  39445. };
  39446. // `URL` constructor
  39447. // https://url.spec.whatwg.org/#url-class
  39448. var URLConstructor = function URL(url /* , base */) {
  39449. var that = anInstance(this, URLPrototype);
  39450. var base = validateArgumentsLength(arguments.length, 1) > 1 ? arguments[1] : undefined;
  39451. var state = setInternalState$6(that, new URLState(url, false, base));
  39452. if (!descriptors) {
  39453. that.href = state.serialize();
  39454. that.origin = state.getOrigin();
  39455. that.protocol = state.getProtocol();
  39456. that.username = state.getUsername();
  39457. that.password = state.getPassword();
  39458. that.host = state.getHost();
  39459. that.hostname = state.getHostname();
  39460. that.port = state.getPort();
  39461. that.pathname = state.getPathname();
  39462. that.search = state.getSearch();
  39463. that.searchParams = state.getSearchParams();
  39464. that.hash = state.getHash();
  39465. }
  39466. };
  39467. var URLPrototype = URLConstructor.prototype;
  39468. var accessorDescriptor = function (getter, setter) {
  39469. return {
  39470. get: function () {
  39471. return getInternalURLState(this)[getter]();
  39472. },
  39473. set: setter && function (value) {
  39474. return getInternalURLState(this)[setter](value);
  39475. },
  39476. configurable: true,
  39477. enumerable: true
  39478. };
  39479. };
  39480. if (descriptors) {
  39481. // `URL.prototype.href` accessors pair
  39482. // https://url.spec.whatwg.org/#dom-url-href
  39483. defineBuiltInAccessor(URLPrototype, 'href', accessorDescriptor('serialize', 'setHref'));
  39484. // `URL.prototype.origin` getter
  39485. // https://url.spec.whatwg.org/#dom-url-origin
  39486. defineBuiltInAccessor(URLPrototype, 'origin', accessorDescriptor('getOrigin'));
  39487. // `URL.prototype.protocol` accessors pair
  39488. // https://url.spec.whatwg.org/#dom-url-protocol
  39489. defineBuiltInAccessor(URLPrototype, 'protocol', accessorDescriptor('getProtocol', 'setProtocol'));
  39490. // `URL.prototype.username` accessors pair
  39491. // https://url.spec.whatwg.org/#dom-url-username
  39492. defineBuiltInAccessor(URLPrototype, 'username', accessorDescriptor('getUsername', 'setUsername'));
  39493. // `URL.prototype.password` accessors pair
  39494. // https://url.spec.whatwg.org/#dom-url-password
  39495. defineBuiltInAccessor(URLPrototype, 'password', accessorDescriptor('getPassword', 'setPassword'));
  39496. // `URL.prototype.host` accessors pair
  39497. // https://url.spec.whatwg.org/#dom-url-host
  39498. defineBuiltInAccessor(URLPrototype, 'host', accessorDescriptor('getHost', 'setHost'));
  39499. // `URL.prototype.hostname` accessors pair
  39500. // https://url.spec.whatwg.org/#dom-url-hostname
  39501. defineBuiltInAccessor(URLPrototype, 'hostname', accessorDescriptor('getHostname', 'setHostname'));
  39502. // `URL.prototype.port` accessors pair
  39503. // https://url.spec.whatwg.org/#dom-url-port
  39504. defineBuiltInAccessor(URLPrototype, 'port', accessorDescriptor('getPort', 'setPort'));
  39505. // `URL.prototype.pathname` accessors pair
  39506. // https://url.spec.whatwg.org/#dom-url-pathname
  39507. defineBuiltInAccessor(URLPrototype, 'pathname', accessorDescriptor('getPathname', 'setPathname'));
  39508. // `URL.prototype.search` accessors pair
  39509. // https://url.spec.whatwg.org/#dom-url-search
  39510. defineBuiltInAccessor(URLPrototype, 'search', accessorDescriptor('getSearch', 'setSearch'));
  39511. // `URL.prototype.searchParams` getter
  39512. // https://url.spec.whatwg.org/#dom-url-searchparams
  39513. defineBuiltInAccessor(URLPrototype, 'searchParams', accessorDescriptor('getSearchParams'));
  39514. // `URL.prototype.hash` accessors pair
  39515. // https://url.spec.whatwg.org/#dom-url-hash
  39516. defineBuiltInAccessor(URLPrototype, 'hash', accessorDescriptor('getHash', 'setHash'));
  39517. }
  39518. // `URL.prototype.toJSON` method
  39519. // https://url.spec.whatwg.org/#dom-url-tojson
  39520. defineBuiltIn(URLPrototype, 'toJSON', function toJSON() {
  39521. return getInternalURLState(this).serialize();
  39522. }, { enumerable: true });
  39523. // `URL.prototype.toString` method
  39524. // https://url.spec.whatwg.org/#URL-stringification-behavior
  39525. defineBuiltIn(URLPrototype, 'toString', function toString() {
  39526. return getInternalURLState(this).serialize();
  39527. }, { enumerable: true });
  39528. if (NativeURL) {
  39529. var nativeCreateObjectURL = NativeURL.createObjectURL;
  39530. var nativeRevokeObjectURL = NativeURL.revokeObjectURL;
  39531. // `URL.createObjectURL` method
  39532. // https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
  39533. if (nativeCreateObjectURL) defineBuiltIn(URLConstructor, 'createObjectURL', functionBindContext(nativeCreateObjectURL, NativeURL));
  39534. // `URL.revokeObjectURL` method
  39535. // https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL
  39536. if (nativeRevokeObjectURL) defineBuiltIn(URLConstructor, 'revokeObjectURL', functionBindContext(nativeRevokeObjectURL, NativeURL));
  39537. }
  39538. setToStringTag(URLConstructor, 'URL');
  39539. _export({ global: true, constructor: true, forced: !nativeUrl, sham: !descriptors }, {
  39540. URL: URLConstructor
  39541. });
  39542. var url = path.URL;
  39543. var url$1 = url;
  39544. var url$2 = url$1;
  39545. var html2canvas = createCommonjsModule(function (module, exports) {
  39546. /*!
  39547. * html2canvas 1.4.1 <https://html2canvas.hertzen.com>
  39548. * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
  39549. * Released under MIT License
  39550. */
  39551. (function (global, factory) {
  39552. module.exports = factory() ;
  39553. }(commonjsGlobal, (function () {
  39554. /*! *****************************************************************************
  39555. Copyright (c) Microsoft Corporation.
  39556. Permission to use, copy, modify, and/or distribute this software for any
  39557. purpose with or without fee is hereby granted.
  39558. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  39559. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  39560. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  39561. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  39562. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  39563. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  39564. PERFORMANCE OF THIS SOFTWARE.
  39565. ***************************************************************************** */
  39566. /* global Reflect, Promise */
  39567. var extendStatics = function(d, b) {
  39568. extendStatics = Object.setPrototypeOf ||
  39569. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39570. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  39571. return extendStatics(d, b);
  39572. };
  39573. function __extends(d, b) {
  39574. if (typeof b !== "function" && b !== null)
  39575. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  39576. extendStatics(d, b);
  39577. function __() { this.constructor = d; }
  39578. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39579. }
  39580. var __assign = function() {
  39581. __assign = Object.assign || function __assign(t) {
  39582. for (var s, i = 1, n = arguments.length; i < n; i++) {
  39583. s = arguments[i];
  39584. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  39585. }
  39586. return t;
  39587. };
  39588. return __assign.apply(this, arguments);
  39589. };
  39590. function __awaiter(thisArg, _arguments, P, generator) {
  39591. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  39592. return new (P || (P = Promise))(function (resolve, reject) {
  39593. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  39594. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  39595. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  39596. step((generator = generator.apply(thisArg, _arguments || [])).next());
  39597. });
  39598. }
  39599. function __generator(thisArg, body) {
  39600. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  39601. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  39602. function verb(n) { return function (v) { return step([n, v]); }; }
  39603. function step(op) {
  39604. if (f) throw new TypeError("Generator is already executing.");
  39605. while (_) try {
  39606. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  39607. if (y = 0, t) op = [op[0] & 2, t.value];
  39608. switch (op[0]) {
  39609. case 0: case 1: t = op; break;
  39610. case 4: _.label++; return { value: op[1], done: false };
  39611. case 5: _.label++; y = op[1]; op = [0]; continue;
  39612. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  39613. default:
  39614. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  39615. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  39616. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  39617. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  39618. if (t[2]) _.ops.pop();
  39619. _.trys.pop(); continue;
  39620. }
  39621. op = body.call(thisArg, _);
  39622. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  39623. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  39624. }
  39625. }
  39626. function __spreadArray(to, from, pack) {
  39627. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  39628. if (ar || !(i in from)) {
  39629. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  39630. ar[i] = from[i];
  39631. }
  39632. }
  39633. return to.concat(ar || from);
  39634. }
  39635. var Bounds = /** @class */ (function () {
  39636. function Bounds(left, top, width, height) {
  39637. this.left = left;
  39638. this.top = top;
  39639. this.width = width;
  39640. this.height = height;
  39641. }
  39642. Bounds.prototype.add = function (x, y, w, h) {
  39643. return new Bounds(this.left + x, this.top + y, this.width + w, this.height + h);
  39644. };
  39645. Bounds.fromClientRect = function (context, clientRect) {
  39646. return new Bounds(clientRect.left + context.windowBounds.left, clientRect.top + context.windowBounds.top, clientRect.width, clientRect.height);
  39647. };
  39648. Bounds.fromDOMRectList = function (context, domRectList) {
  39649. var domRect = Array.from(domRectList).find(function (rect) { return rect.width !== 0; });
  39650. return domRect
  39651. ? new Bounds(domRect.left + context.windowBounds.left, domRect.top + context.windowBounds.top, domRect.width, domRect.height)
  39652. : Bounds.EMPTY;
  39653. };
  39654. Bounds.EMPTY = new Bounds(0, 0, 0, 0);
  39655. return Bounds;
  39656. }());
  39657. var parseBounds = function (context, node) {
  39658. return Bounds.fromClientRect(context, node.getBoundingClientRect());
  39659. };
  39660. var parseDocumentSize = function (document) {
  39661. var body = document.body;
  39662. var documentElement = document.documentElement;
  39663. if (!body || !documentElement) {
  39664. throw new Error("Unable to get document size");
  39665. }
  39666. var width = Math.max(Math.max(body.scrollWidth, documentElement.scrollWidth), Math.max(body.offsetWidth, documentElement.offsetWidth), Math.max(body.clientWidth, documentElement.clientWidth));
  39667. var height = Math.max(Math.max(body.scrollHeight, documentElement.scrollHeight), Math.max(body.offsetHeight, documentElement.offsetHeight), Math.max(body.clientHeight, documentElement.clientHeight));
  39668. return new Bounds(0, 0, width, height);
  39669. };
  39670. /*
  39671. * css-line-break 2.1.0 <https://github.com/niklasvh/css-line-break#readme>
  39672. * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
  39673. * Released under MIT License
  39674. */
  39675. var toCodePoints$1 = function (str) {
  39676. var codePoints = [];
  39677. var i = 0;
  39678. var length = str.length;
  39679. while (i < length) {
  39680. var value = str.charCodeAt(i++);
  39681. if (value >= 0xd800 && value <= 0xdbff && i < length) {
  39682. var extra = str.charCodeAt(i++);
  39683. if ((extra & 0xfc00) === 0xdc00) {
  39684. codePoints.push(((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000);
  39685. }
  39686. else {
  39687. codePoints.push(value);
  39688. i--;
  39689. }
  39690. }
  39691. else {
  39692. codePoints.push(value);
  39693. }
  39694. }
  39695. return codePoints;
  39696. };
  39697. var fromCodePoint$1 = function () {
  39698. var codePoints = [];
  39699. for (var _i = 0; _i < arguments.length; _i++) {
  39700. codePoints[_i] = arguments[_i];
  39701. }
  39702. if (String.fromCodePoint) {
  39703. return String.fromCodePoint.apply(String, codePoints);
  39704. }
  39705. var length = codePoints.length;
  39706. if (!length) {
  39707. return '';
  39708. }
  39709. var codeUnits = [];
  39710. var index = -1;
  39711. var result = '';
  39712. while (++index < length) {
  39713. var codePoint = codePoints[index];
  39714. if (codePoint <= 0xffff) {
  39715. codeUnits.push(codePoint);
  39716. }
  39717. else {
  39718. codePoint -= 0x10000;
  39719. codeUnits.push((codePoint >> 10) + 0xd800, (codePoint % 0x400) + 0xdc00);
  39720. }
  39721. if (index + 1 === length || codeUnits.length > 0x4000) {
  39722. result += String.fromCharCode.apply(String, codeUnits);
  39723. codeUnits.length = 0;
  39724. }
  39725. }
  39726. return result;
  39727. };
  39728. var chars$2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  39729. // Use a lookup table to find the index.
  39730. var lookup$2 = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);
  39731. for (var i$2 = 0; i$2 < chars$2.length; i$2++) {
  39732. lookup$2[chars$2.charCodeAt(i$2)] = i$2;
  39733. }
  39734. /*
  39735. * utrie 1.0.2 <https://github.com/niklasvh/utrie>
  39736. * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
  39737. * Released under MIT License
  39738. */
  39739. var chars$1$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  39740. // Use a lookup table to find the index.
  39741. var lookup$1$1 = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);
  39742. for (var i$1$1 = 0; i$1$1 < chars$1$1.length; i$1$1++) {
  39743. lookup$1$1[chars$1$1.charCodeAt(i$1$1)] = i$1$1;
  39744. }
  39745. var decode$1 = function (base64) {
  39746. var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;
  39747. if (base64[base64.length - 1] === '=') {
  39748. bufferLength--;
  39749. if (base64[base64.length - 2] === '=') {
  39750. bufferLength--;
  39751. }
  39752. }
  39753. var buffer = typeof ArrayBuffer !== 'undefined' &&
  39754. typeof Uint8Array !== 'undefined' &&
  39755. typeof Uint8Array.prototype.slice !== 'undefined'
  39756. ? new ArrayBuffer(bufferLength)
  39757. : new Array(bufferLength);
  39758. var bytes = Array.isArray(buffer) ? buffer : new Uint8Array(buffer);
  39759. for (i = 0; i < len; i += 4) {
  39760. encoded1 = lookup$1$1[base64.charCodeAt(i)];
  39761. encoded2 = lookup$1$1[base64.charCodeAt(i + 1)];
  39762. encoded3 = lookup$1$1[base64.charCodeAt(i + 2)];
  39763. encoded4 = lookup$1$1[base64.charCodeAt(i + 3)];
  39764. bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
  39765. bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
  39766. bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
  39767. }
  39768. return buffer;
  39769. };
  39770. var polyUint16Array$1 = function (buffer) {
  39771. var length = buffer.length;
  39772. var bytes = [];
  39773. for (var i = 0; i < length; i += 2) {
  39774. bytes.push((buffer[i + 1] << 8) | buffer[i]);
  39775. }
  39776. return bytes;
  39777. };
  39778. var polyUint32Array$1 = function (buffer) {
  39779. var length = buffer.length;
  39780. var bytes = [];
  39781. for (var i = 0; i < length; i += 4) {
  39782. bytes.push((buffer[i + 3] << 24) | (buffer[i + 2] << 16) | (buffer[i + 1] << 8) | buffer[i]);
  39783. }
  39784. return bytes;
  39785. };
  39786. /** Shift size for getting the index-2 table offset. */
  39787. var UTRIE2_SHIFT_2$1 = 5;
  39788. /** Shift size for getting the index-1 table offset. */
  39789. var UTRIE2_SHIFT_1$1 = 6 + 5;
  39790. /**
  39791. * Shift size for shifting left the index array values.
  39792. * Increases possible data size with 16-bit index values at the cost
  39793. * of compactability.
  39794. * This requires data blocks to be aligned by UTRIE2_DATA_GRANULARITY.
  39795. */
  39796. var UTRIE2_INDEX_SHIFT$1 = 2;
  39797. /**
  39798. * Difference between the two shift sizes,
  39799. * for getting an index-1 offset from an index-2 offset. 6=11-5
  39800. */
  39801. var UTRIE2_SHIFT_1_2$1 = UTRIE2_SHIFT_1$1 - UTRIE2_SHIFT_2$1;
  39802. /**
  39803. * The part of the index-2 table for U+D800..U+DBFF stores values for
  39804. * lead surrogate code _units_ not code _points_.
  39805. * Values for lead surrogate code _points_ are indexed with this portion of the table.
  39806. * Length=32=0x20=0x400>>UTRIE2_SHIFT_2. (There are 1024=0x400 lead surrogates.)
  39807. */
  39808. var UTRIE2_LSCP_INDEX_2_OFFSET$1 = 0x10000 >> UTRIE2_SHIFT_2$1;
  39809. /** Number of entries in a data block. 32=0x20 */
  39810. var UTRIE2_DATA_BLOCK_LENGTH$1 = 1 << UTRIE2_SHIFT_2$1;
  39811. /** Mask for getting the lower bits for the in-data-block offset. */
  39812. var UTRIE2_DATA_MASK$1 = UTRIE2_DATA_BLOCK_LENGTH$1 - 1;
  39813. var UTRIE2_LSCP_INDEX_2_LENGTH$1 = 0x400 >> UTRIE2_SHIFT_2$1;
  39814. /** Count the lengths of both BMP pieces. 2080=0x820 */
  39815. var UTRIE2_INDEX_2_BMP_LENGTH$1 = UTRIE2_LSCP_INDEX_2_OFFSET$1 + UTRIE2_LSCP_INDEX_2_LENGTH$1;
  39816. /**
  39817. * The 2-byte UTF-8 version of the index-2 table follows at offset 2080=0x820.
  39818. * Length 32=0x20 for lead bytes C0..DF, regardless of UTRIE2_SHIFT_2.
  39819. */
  39820. var UTRIE2_UTF8_2B_INDEX_2_OFFSET$1 = UTRIE2_INDEX_2_BMP_LENGTH$1;
  39821. var UTRIE2_UTF8_2B_INDEX_2_LENGTH$1 = 0x800 >> 6; /* U+0800 is the first code point after 2-byte UTF-8 */
  39822. /**
  39823. * The index-1 table, only used for supplementary code points, at offset 2112=0x840.
  39824. * Variable length, for code points up to highStart, where the last single-value range starts.
  39825. * Maximum length 512=0x200=0x100000>>UTRIE2_SHIFT_1.
  39826. * (For 0x100000 supplementary code points U+10000..U+10ffff.)
  39827. *
  39828. * The part of the index-2 table for supplementary code points starts
  39829. * after this index-1 table.
  39830. *
  39831. * Both the index-1 table and the following part of the index-2 table
  39832. * are omitted completely if there is only BMP data.
  39833. */
  39834. var UTRIE2_INDEX_1_OFFSET$1 = UTRIE2_UTF8_2B_INDEX_2_OFFSET$1 + UTRIE2_UTF8_2B_INDEX_2_LENGTH$1;
  39835. /**
  39836. * Number of index-1 entries for the BMP. 32=0x20
  39837. * This part of the index-1 table is omitted from the serialized form.
  39838. */
  39839. var UTRIE2_OMITTED_BMP_INDEX_1_LENGTH$1 = 0x10000 >> UTRIE2_SHIFT_1$1;
  39840. /** Number of entries in an index-2 block. 64=0x40 */
  39841. var UTRIE2_INDEX_2_BLOCK_LENGTH$1 = 1 << UTRIE2_SHIFT_1_2$1;
  39842. /** Mask for getting the lower bits for the in-index-2-block offset. */
  39843. var UTRIE2_INDEX_2_MASK$1 = UTRIE2_INDEX_2_BLOCK_LENGTH$1 - 1;
  39844. var slice16$1 = function (view, start, end) {
  39845. if (view.slice) {
  39846. return view.slice(start, end);
  39847. }
  39848. return new Uint16Array(Array.prototype.slice.call(view, start, end));
  39849. };
  39850. var slice32$1 = function (view, start, end) {
  39851. if (view.slice) {
  39852. return view.slice(start, end);
  39853. }
  39854. return new Uint32Array(Array.prototype.slice.call(view, start, end));
  39855. };
  39856. var createTrieFromBase64$1 = function (base64, _byteLength) {
  39857. var buffer = decode$1(base64);
  39858. var view32 = Array.isArray(buffer) ? polyUint32Array$1(buffer) : new Uint32Array(buffer);
  39859. var view16 = Array.isArray(buffer) ? polyUint16Array$1(buffer) : new Uint16Array(buffer);
  39860. var headerLength = 24;
  39861. var index = slice16$1(view16, headerLength / 2, view32[4] / 2);
  39862. var data = view32[5] === 2
  39863. ? slice16$1(view16, (headerLength + view32[4]) / 2)
  39864. : slice32$1(view32, Math.ceil((headerLength + view32[4]) / 4));
  39865. return new Trie$1(view32[0], view32[1], view32[2], view32[3], index, data);
  39866. };
  39867. var Trie$1 = /** @class */ (function () {
  39868. function Trie(initialValue, errorValue, highStart, highValueIndex, index, data) {
  39869. this.initialValue = initialValue;
  39870. this.errorValue = errorValue;
  39871. this.highStart = highStart;
  39872. this.highValueIndex = highValueIndex;
  39873. this.index = index;
  39874. this.data = data;
  39875. }
  39876. /**
  39877. * Get the value for a code point as stored in the Trie.
  39878. *
  39879. * @param codePoint the code point
  39880. * @return the value
  39881. */
  39882. Trie.prototype.get = function (codePoint) {
  39883. var ix;
  39884. if (codePoint >= 0) {
  39885. if (codePoint < 0x0d800 || (codePoint > 0x0dbff && codePoint <= 0x0ffff)) {
  39886. // Ordinary BMP code point, excluding leading surrogates.
  39887. // BMP uses a single level lookup. BMP index starts at offset 0 in the Trie2 index.
  39888. // 16 bit data is stored in the index array itself.
  39889. ix = this.index[codePoint >> UTRIE2_SHIFT_2$1];
  39890. ix = (ix << UTRIE2_INDEX_SHIFT$1) + (codePoint & UTRIE2_DATA_MASK$1);
  39891. return this.data[ix];
  39892. }
  39893. if (codePoint <= 0xffff) {
  39894. // Lead Surrogate Code Point. A Separate index section is stored for
  39895. // lead surrogate code units and code points.
  39896. // The main index has the code unit data.
  39897. // For this function, we need the code point data.
  39898. // Note: this expression could be refactored for slightly improved efficiency, but
  39899. // surrogate code points will be so rare in practice that it's not worth it.
  39900. ix = this.index[UTRIE2_LSCP_INDEX_2_OFFSET$1 + ((codePoint - 0xd800) >> UTRIE2_SHIFT_2$1)];
  39901. ix = (ix << UTRIE2_INDEX_SHIFT$1) + (codePoint & UTRIE2_DATA_MASK$1);
  39902. return this.data[ix];
  39903. }
  39904. if (codePoint < this.highStart) {
  39905. // Supplemental code point, use two-level lookup.
  39906. ix = UTRIE2_INDEX_1_OFFSET$1 - UTRIE2_OMITTED_BMP_INDEX_1_LENGTH$1 + (codePoint >> UTRIE2_SHIFT_1$1);
  39907. ix = this.index[ix];
  39908. ix += (codePoint >> UTRIE2_SHIFT_2$1) & UTRIE2_INDEX_2_MASK$1;
  39909. ix = this.index[ix];
  39910. ix = (ix << UTRIE2_INDEX_SHIFT$1) + (codePoint & UTRIE2_DATA_MASK$1);
  39911. return this.data[ix];
  39912. }
  39913. if (codePoint <= 0x10ffff) {
  39914. return this.data[this.highValueIndex];
  39915. }
  39916. }
  39917. // Fall through. The code point is outside of the legal range of 0..0x10ffff.
  39918. return this.errorValue;
  39919. };
  39920. return Trie;
  39921. }());
  39922. /*
  39923. * base64-arraybuffer 1.0.2 <https://github.com/niklasvh/base64-arraybuffer>
  39924. * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
  39925. * Released under MIT License
  39926. */
  39927. var chars$3 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  39928. // Use a lookup table to find the index.
  39929. var lookup$3 = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);
  39930. for (var i$3 = 0; i$3 < chars$3.length; i$3++) {
  39931. lookup$3[chars$3.charCodeAt(i$3)] = i$3;
  39932. }
  39933. var base64$1 = 'KwAAAAAAAAAACA4AUD0AADAgAAACAAAAAAAIABAAGABAAEgAUABYAGAAaABgAGgAYgBqAF8AZwBgAGgAcQB5AHUAfQCFAI0AlQCdAKIAqgCyALoAYABoAGAAaABgAGgAwgDKAGAAaADGAM4A0wDbAOEA6QDxAPkAAQEJAQ8BFwF1AH0AHAEkASwBNAE6AUIBQQFJAVEBWQFhAWgBcAF4ATAAgAGGAY4BlQGXAZ8BpwGvAbUBvQHFAc0B0wHbAeMB6wHxAfkBAQIJAvEBEQIZAiECKQIxAjgCQAJGAk4CVgJeAmQCbAJ0AnwCgQKJApECmQKgAqgCsAK4ArwCxAIwAMwC0wLbAjAA4wLrAvMC+AIAAwcDDwMwABcDHQMlAy0DNQN1AD0DQQNJA0kDSQNRA1EDVwNZA1kDdQB1AGEDdQBpA20DdQN1AHsDdQCBA4kDkQN1AHUAmQOhA3UAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AKYDrgN1AHUAtgO+A8YDzgPWAxcD3gPjA+sD8wN1AHUA+wMDBAkEdQANBBUEHQQlBCoEFwMyBDgEYABABBcDSARQBFgEYARoBDAAcAQzAXgEgASIBJAEdQCXBHUAnwSnBK4EtgS6BMIEyAR1AHUAdQB1AHUAdQCVANAEYABgAGAAYABgAGAAYABgANgEYADcBOQEYADsBPQE/AQEBQwFFAUcBSQFLAU0BWQEPAVEBUsFUwVbBWAAYgVgAGoFcgV6BYIFigWRBWAAmQWfBaYFYABgAGAAYABgAKoFYACxBbAFuQW6BcEFwQXHBcEFwQXPBdMF2wXjBeoF8gX6BQIGCgYSBhoGIgYqBjIGOgZgAD4GRgZMBmAAUwZaBmAAYABgAGAAYABgAGAAYABgAGAAYABgAGIGYABpBnAGYABgAGAAYABgAGAAYABgAGAAYAB4Bn8GhQZgAGAAYAB1AHcDFQSLBmAAYABgAJMGdQA9A3UAmwajBqsGqwaVALMGuwbDBjAAywbSBtIG1QbSBtIG0gbSBtIG0gbdBuMG6wbzBvsGAwcLBxMHAwcbByMHJwcsBywHMQcsB9IGOAdAB0gHTgfSBkgHVgfSBtIG0gbSBtIG0gbSBtIG0gbSBiwHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAdgAGAALAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAdbB2MHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsB2kH0gZwB64EdQB1AHUAdQB1AHUAdQB1AHUHfQdgAIUHjQd1AHUAlQedB2AAYAClB6sHYACzB7YHvgfGB3UAzgfWBzMB3gfmB1EB7gf1B/0HlQENAQUIDQh1ABUIHQglCBcDLQg1CD0IRQhNCEEDUwh1AHUAdQBbCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIcAh3CHoIMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIgggwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAALAcsBywHLAcsBywHLAcsBywHLAcsB4oILAcsB44I0gaWCJ4Ipgh1AHUAqgiyCHUAdQB1AHUAdQB1AHUAdQB1AHUAtwh8AXUAvwh1AMUIyQjRCNkI4AjoCHUAdQB1AO4I9gj+CAYJDgkTCS0HGwkjCYIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiAAIAAAAFAAYABgAGIAXwBgAHEAdQBFAJUAogCyAKAAYABgAEIA4ABGANMA4QDxAMEBDwE1AFwBLAE6AQEBUQF4QkhCmEKoQrhCgAHIQsAB0MLAAcABwAHAAeDC6ABoAHDCwMMAAcABwAHAAdDDGMMAAcAB6MM4wwjDWMNow3jDaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAEjDqABWw6bDqABpg6gAaABoAHcDvwOPA+gAaABfA/8DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DpcPAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcAB9cPKwkyCToJMAB1AHUAdQBCCUoJTQl1AFUJXAljCWcJawkwADAAMAAwAHMJdQB2CX4JdQCECYoJjgmWCXUAngkwAGAAYABxAHUApgn3A64JtAl1ALkJdQDACTAAMAAwADAAdQB1AHUAdQB1AHUAdQB1AHUAowYNBMUIMAAwADAAMADICcsJ0wnZCRUE4QkwAOkJ8An4CTAAMAB1AAAKvwh1AAgKDwoXCh8KdQAwACcKLgp1ADYKqAmICT4KRgowADAAdQB1AE4KMAB1AFYKdQBeCnUAZQowADAAMAAwADAAMAAwADAAMAAVBHUAbQowADAAdQC5CXUKMAAwAHwBxAijBogEMgF9CoQKiASMCpQKmgqIBKIKqgquCogEDQG2Cr4KxgrLCjAAMADTCtsKCgHjCusK8Qr5CgELMAAwADAAMAB1AIsECQsRC3UANAEZCzAAMAAwADAAMAB1ACELKQswAHUANAExCzkLdQBBC0kLMABRC1kLMAAwADAAMAAwADAAdQBhCzAAMAAwAGAAYABpC3ELdwt/CzAAMACHC4sLkwubC58Lpwt1AK4Ltgt1APsDMAAwADAAMAAwADAAMAAwAL4LwwvLC9IL1wvdCzAAMADlC+kL8Qv5C/8LSQswADAAMAAwADAAMAAwADAAMAAHDDAAMAAwADAAMAAODBYMHgx1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1ACYMMAAwADAAdQB1AHUALgx1AHUAdQB1AHUAdQA2DDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AD4MdQBGDHUAdQB1AHUAdQB1AEkMdQB1AHUAdQB1AFAMMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQBYDHUAdQB1AF8MMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUA+wMVBGcMMAAwAHwBbwx1AHcMfwyHDI8MMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAYABgAJcMMAAwADAAdQB1AJ8MlQClDDAAMACtDCwHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsB7UMLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AA0EMAC9DDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAsBywHLAcsBywHLAcsBywHLQcwAMEMyAwsBywHLAcsBywHLAcsBywHLAcsBywHzAwwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1ANQM2QzhDDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMABgAGAAYABgAGAAYABgAOkMYADxDGAA+AwADQYNYABhCWAAYAAODTAAMAAwADAAFg1gAGAAHg37AzAAMAAwADAAYABgACYNYAAsDTQNPA1gAEMNPg1LDWAAYABgAGAAYABgAGAAYABgAGAAUg1aDYsGVglhDV0NcQBnDW0NdQ15DWAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAlQCBDZUAiA2PDZcNMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAnw2nDTAAMAAwADAAMAAwAHUArw23DTAAMAAwADAAMAAwADAAMAAwADAAMAB1AL8NMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAB1AHUAdQB1AHUAdQDHDTAAYABgAM8NMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAA1w11ANwNMAAwAD0B5A0wADAAMAAwADAAMADsDfQN/A0EDgwOFA4wABsOMAAwADAAMAAwADAAMAAwANIG0gbSBtIG0gbSBtIG0gYjDigOwQUuDsEFMw7SBjoO0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGQg5KDlIOVg7SBtIGXg5lDm0OdQ7SBtIGfQ6EDooOjQ6UDtIGmg6hDtIG0gaoDqwO0ga0DrwO0gZgAGAAYADEDmAAYAAkBtIGzA5gANIOYADaDokO0gbSBt8O5w7SBu8O0gb1DvwO0gZgAGAAxA7SBtIG0gbSBtIGYABgAGAAYAAED2AAsAUMD9IG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGFA8sBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAccD9IGLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHJA8sBywHLAcsBywHLAccDywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywPLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAc0D9IG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAccD9IG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGFA8sBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHPA/SBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gYUD0QPlQCVAJUAMAAwADAAMACVAJUAlQCVAJUAlQCVAEwPMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAA//8EAAQABAAEAAQABAAEAAQABAANAAMAAQABAAIABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQACgATABcAHgAbABoAHgAXABYAEgAeABsAGAAPABgAHABLAEsASwBLAEsASwBLAEsASwBLABgAGAAeAB4AHgATAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABYAGwASAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAWAA0AEQAeAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAFAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAJABYAGgAbABsAGwAeAB0AHQAeAE8AFwAeAA0AHgAeABoAGwBPAE8ADgBQAB0AHQAdAE8ATwAXAE8ATwBPABYAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAFAATwBAAE8ATwBPAEAATwBQAFAATwBQAB4AHgAeAB4AHgAeAB0AHQAdAB0AHgAdAB4ADgBQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgBQAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAJAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAkACQAJAAkACQAJAAkABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAFAAHgAeAB4AKwArAFAAUABQAFAAGABQACsAKwArACsAHgAeAFAAHgBQAFAAUAArAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUAAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAYAA0AKwArAB4AHgAbACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQADQAEAB4ABAAEAB4ABAAEABMABAArACsAKwArACsAKwArACsAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAKwArACsAKwBWAFYAVgBWAB4AHgArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AGgAaABoAGAAYAB4AHgAEAAQABAAEAAQABAAEAAQABAAEAAQAEwAEACsAEwATAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABLAEsASwBLAEsASwBLAEsASwBLABoAGQAZAB4AUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABMAUAAEAAQABAAEAAQABAAEAB4AHgAEAAQABAAEAAQABABQAFAABAAEAB4ABAAEAAQABABQAFAASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUAAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAFAABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQAUABQAB4AHgAYABMAUAArACsABAAbABsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAFAABAAEAAQABAAEAFAABAAEAAQAUAAEAAQABAAEAAQAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAArACsAHgArAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAUAAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAABAAEAA0ADQBLAEsASwBLAEsASwBLAEsASwBLAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUAArACsAKwBQAFAAUABQACsAKwAEAFAABAAEAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABABQACsAKwArACsAKwArACsAKwAEACsAKwArACsAUABQACsAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUAAaABoAUABQAFAAUABQAEwAHgAbAFAAHgAEACsAKwAEAAQABAArAFAAUABQAFAAUABQACsAKwArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQACsAUABQACsAKwAEACsABAAEAAQABAAEACsAKwArACsABAAEACsAKwAEAAQABAArACsAKwAEACsAKwArACsAKwArACsAUABQAFAAUAArAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLAAQABABQAFAAUAAEAB4AKwArACsAKwArACsAKwArACsAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQACsAKwAEAFAABAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAArACsAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAB4AGwArACsAKwArACsAKwArAFAABAAEAAQABAAEAAQAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABAArACsAKwArACsAKwArAAQABAAEACsAKwArACsAUABQACsAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAB4AUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAAQAUAArAFAAUABQAFAAUABQACsAKwArAFAAUABQACsAUABQAFAAUAArACsAKwBQAFAAKwBQACsAUABQACsAKwArAFAAUAArACsAKwBQAFAAUAArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArAAQABAAEAAQABAArACsAKwAEAAQABAArAAQABAAEAAQAKwArAFAAKwArACsAKwArACsABAArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAHgAeAB4AHgAeAB4AGwAeACsAKwArACsAKwAEAAQABAAEAAQAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAUAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAAEACsAKwArACsAKwArACsABAAEACsAUABQAFAAKwArACsAKwArAFAAUAAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKwAOAFAAUABQAFAAUABQAFAAHgBQAAQABAAEAA4AUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAKwArAAQAUAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAAEACsAKwArACsAKwArACsABAAEACsAKwArACsAKwArACsAUAArAFAAUAAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwBQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAFAABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQABABQAB4AKwArACsAKwBQAFAAUAAEAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQABoAUABQAFAAUABQAFAAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQACsAUAArACsAUABQAFAAUABQAFAAUAArACsAKwAEACsAKwArACsABAAEAAQABAAEAAQAKwAEACsABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArAAQABAAeACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAXAAqACoAKgAqACoAKgAqACsAKwArACsAGwBcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAeAEsASwBLAEsASwBLAEsASwBLAEsADQANACsAKwArACsAKwBcAFwAKwBcACsAXABcAFwAXABcACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAXAArAFwAXABcAFwAXABcAFwAXABcAFwAKgBcAFwAKgAqACoAKgAqACoAKgAqACoAXAArACsAXABcAFwAXABcACsAXAArACoAKgAqACoAKgAqACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwBcAFwAXABcAFAADgAOAA4ADgAeAA4ADgAJAA4ADgANAAkAEwATABMAEwATAAkAHgATAB4AHgAeAAQABAAeAB4AHgAeAB4AHgBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQAFAADQAEAB4ABAAeAAQAFgARABYAEQAEAAQAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQADQAEAAQABAAEAAQADQAEAAQAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAA0ADQAeAB4AHgAeAB4AHgAEAB4AHgAeAB4AHgAeACsAHgAeAA4ADgANAA4AHgAeAB4AHgAeAAkACQArACsAKwArACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgBcAEsASwBLAEsASwBLAEsASwBLAEsADQANAB4AHgAeAB4AXABcAFwAXABcAFwAKgAqACoAKgBcAFwAXABcACoAKgAqAFwAKgAqACoAXABcACoAKgAqACoAKgAqACoAXABcAFwAKgAqACoAKgBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKgAqAFwAKgBLAEsASwBLAEsASwBLAEsASwBLACoAKgAqACoAKgAqAFAAUABQAFAAUABQACsAUAArACsAKwArACsAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgBQAFAAUABQAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAKwBQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsABAAEAAQAHgANAB4AHgAeAB4AHgAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUAArACsADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAWABEAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAA0ADQANAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAANAA0AKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUAArAAQABAArACsAKwArACsAKwArACsAKwArACsAKwBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqAA0ADQAVAFwADQAeAA0AGwBcACoAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwAeAB4AEwATAA0ADQAOAB4AEwATAB4ABAAEAAQACQArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUAAEAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAHgArACsAKwATABMASwBLAEsASwBLAEsASwBLAEsASwBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAArACsAXABcAFwAXABcACsAKwArACsAKwArACsAKwArACsAKwBcAFwAXABcAFwAXABcAFwAXABcAFwAXAArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAXAArACsAKwAqACoAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAArACsAHgAeAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKwAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKwArAAQASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArACoAKgAqACoAKgAqACoAXAAqACoAKgAqACoAKgArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABABQAFAAUABQAFAAUABQACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwANAA0AHgANAA0ADQANAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQAHgAeAB4AHgAeAB4AHgAeAB4AKwArACsABAAEAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwAeAB4AHgAeAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArAA0ADQANAA0ADQBLAEsASwBLAEsASwBLAEsASwBLACsAKwArAFAAUABQAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAA0ADQBQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUAAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArAAQABAAEAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAAQAUABQAFAAUABQAFAABABQAFAABAAEAAQAUAArACsAKwArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAKwBQACsAUAArAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAFAAUABQACsAHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQACsAKwAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAFAAUABQACsAHgAeAB4AHgAeAB4AHgAOAB4AKwANAA0ADQANAA0ADQANAAkADQANAA0ACAAEAAsABAAEAA0ACQANAA0ADAAdAB0AHgAXABcAFgAXABcAFwAWABcAHQAdAB4AHgAUABQAFAANAAEAAQAEAAQABAAEAAQACQAaABoAGgAaABoAGgAaABoAHgAXABcAHQAVABUAHgAeAB4AHgAeAB4AGAAWABEAFQAVABUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ADQAeAA0ADQANAA0AHgANAA0ADQAHAB4AHgAeAB4AKwAEAAQABAAEAAQABAAEAAQABAAEAFAAUAArACsATwBQAFAAUABQAFAAHgAeAB4AFgARAE8AUABPAE8ATwBPAFAAUABQAFAAUAAeAB4AHgAWABEAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArABsAGwAbABsAGwAbABsAGgAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGgAbABsAGwAbABoAGwAbABoAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAHgAeAFAAGgAeAB0AHgBQAB4AGgAeAB4AHgAeAB4AHgAeAB4AHgBPAB4AUAAbAB4AHgBQAFAAUABQAFAAHgAeAB4AHQAdAB4AUAAeAFAAHgBQAB4AUABPAFAAUAAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAHgBQAFAAUABQAE8ATwBQAFAAUABQAFAATwBQAFAATwBQAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAFAAUABQAFAATwBPAE8ATwBPAE8ATwBPAE8ATwBQAFAAUABQAFAAUABQAFAAUAAeAB4AUABQAFAAUABPAB4AHgArACsAKwArAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHQAdAB4AHgAeAB0AHQAeAB4AHQAeAB4AHgAdAB4AHQAbABsAHgAdAB4AHgAeAB4AHQAeAB4AHQAdAB0AHQAeAB4AHQAeAB0AHgAdAB0AHQAdAB0AHQAeAB0AHgAeAB4AHgAeAB0AHQAdAB0AHgAeAB4AHgAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHgAeAB0AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAeAB0AHQAdAB0AHgAeAB0AHQAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAeAB4AHgAdAB4AHgAeAB4AHgAeAB4AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABYAEQAWABEAHgAeAB4AHgAeAB4AHQAeAB4AHgAeAB4AHgAeACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAWABEAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAFAAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAeAB4AHQAdAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB4AHQAdAB4AHgAeAB4AHQAdAB4AHgAeAB4AHQAdAB0AHgAeAB0AHgAeAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlAB4AHQAdAB4AHgAdAB4AHgAeAB4AHQAdAB4AHgAeAB4AJQAlAB0AHQAlAB4AJQAlACUAIAAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAeAB4AHgAeAB0AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAdAB0AHQAeAB0AJQAdAB0AHgAdAB0AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAdAB0AHQAdACUAHgAlACUAJQAdACUAJQAdAB0AHQAlACUAHQAdACUAHQAdACUAJQAlAB4AHQAeAB4AHgAeAB0AHQAlAB0AHQAdAB0AHQAdACUAJQAlACUAJQAdACUAJQAgACUAHQAdACUAJQAlACUAJQAlACUAJQAeAB4AHgAlACUAIAAgACAAIAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AFwAXABcAFwAXABcAHgATABMAJQAeAB4AHgAWABEAFgARABYAEQAWABEAFgARABYAEQAWABEATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAWABEAFgARABYAEQAWABEAFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFgARABYAEQAWABEAFgARABYAEQAWABEAFgARABYAEQAWABEAFgARABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAWABEAFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAEAAQABAAeAB4AKwArACsAKwArABMADQANAA0AUAATAA0AUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUAANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAA0ADQANAA0ADQANAA0ADQAeAA0AFgANAB4AHgAXABcAHgAeABcAFwAWABEAFgARABYAEQAWABEADQANAA0ADQATAFAADQANAB4ADQANAB4AHgAeAB4AHgAMAAwADQANAA0AHgANAA0AFgANAA0ADQANAA0ADQANAA0AHgANAB4ADQANAB4AHgAeACsAKwArACsAKwArACsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwArACsAKwArACsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArAA0AEQARACUAJQBHAFcAVwAWABEAFgARABYAEQAWABEAFgARACUAJQAWABEAFgARABYAEQAWABEAFQAWABEAEQAlAFcAVwBXAFcAVwBXAFcAVwBXAAQABAAEAAQABAAEACUAVwBXAFcAVwA2ACUAJQBXAFcAVwBHAEcAJQAlACUAKwBRAFcAUQBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFEAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBRAFcAUQBXAFEAVwBXAFcAVwBXAFcAUQBXAFcAVwBXAFcAVwBRAFEAKwArAAQABAAVABUARwBHAFcAFQBRAFcAUQBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBRAFcAVwBXAFcAVwBXAFEAUQBXAFcAVwBXABUAUQBHAEcAVwArACsAKwArACsAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwAlACUAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACsAKwArACsAKwArACsAKwArACsAKwArAFEAUQBRAFEAUQBRAFEAUQBRAFEAUQBRAFEAUQBRAFEAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBPAE8ATwBPAE8ATwBPAE8AJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADQATAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABLAEsASwBLAEsASwBLAEsASwBLAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAABAAEAAQABAAeAAQABAAEAAQABAAEAAQABAAEAAQAHgBQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUABQAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAeAA0ADQANAA0ADQArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAB4AHgAeAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAAQAUABQAFAABABQAFAAUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAeAB4AHgAeAAQAKwArACsAUABQAFAAUABQAFAAHgAeABoAHgArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADgAOABMAEwArACsAKwArACsAKwArACsABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwANAA0ASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUAAeAB4AHgBQAA4AUABQAAQAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAA0ADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArAB4AWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYACsAKwArAAQAHgAeAB4AHgAeAB4ADQANAA0AHgAeAB4AHgArAFAASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArAB4AHgBcAFwAXABcAFwAKgBcAFwAXABcAFwAXABcAFwAXABcAEsASwBLAEsASwBLAEsASwBLAEsAXABcAFwAXABcACsAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArAFAAUABQAAQAUABQAFAAUABQAFAAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAHgANAA0ADQBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAXAAqACoAKgBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAKgAqACoAXABcACoAKgBcAFwAXABcAFwAKgAqAFwAKgBcACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcACoAKgBQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAA0ADQBQAFAAUAAEAAQAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQADQAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAVABVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBUAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVACsAKwArACsAKwArACsAKwArACsAKwArAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAKwArACsAKwBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAKwArACsAKwAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAKwArACsAKwArAFYABABWAFYAVgBWAFYAVgBWAFYAVgBWAB4AVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgArAFYAVgBWAFYAVgArAFYAKwBWAFYAKwBWAFYAKwBWAFYAVgBWAFYAVgBWAFYAVgBWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAEQAWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAaAB4AKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAGAARABEAGAAYABMAEwAWABEAFAArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACUAJQAlACUAJQAWABEAFgARABYAEQAWABEAFgARABYAEQAlACUAFgARACUAJQAlACUAJQAlACUAEQAlABEAKwAVABUAEwATACUAFgARABYAEQAWABEAJQAlACUAJQAlACUAJQAlACsAJQAbABoAJQArACsAKwArAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAcAKwATACUAJQAbABoAJQAlABYAEQAlACUAEQAlABEAJQBXAFcAVwBXAFcAVwBXAFcAVwBXABUAFQAlACUAJQATACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXABYAJQARACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAWACUAEQAlABYAEQARABYAEQARABUAVwBRAFEAUQBRAFEAUQBRAFEAUQBRAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcARwArACsAVwBXAFcAVwBXAFcAKwArAFcAVwBXAFcAVwBXACsAKwBXAFcAVwBXAFcAVwArACsAVwBXAFcAKwArACsAGgAbACUAJQAlABsAGwArAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwAEAAQABAAQAB0AKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsADQANAA0AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAAQAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAA0AUABQAFAAUAArACsAKwArAFAAUABQAFAAUABQAFAAUAANAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAKwArAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUAArACsAKwBQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAUABQAFAAUABQAAQABAAEACsABAAEACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAKwBQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEACsAKwArACsABABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAA0ADQANAA0ADQANAA0ADQAeACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAArACsAKwArAFAAUABQAFAAUAANAA0ADQANAA0ADQAUACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsADQANAA0ADQANAA0ADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAAQABAAEAAQAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArAAQABAANACsAKwBQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAB4AHgAeAB4AHgArACsAKwArACsAKwAEAAQABAAEAAQABAAEAA0ADQAeAB4AHgAeAB4AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwAeACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsASwBLAEsASwBLAEsASwBLAEsASwANAA0ADQANAFAABAAEAFAAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAeAA4AUAArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAADQANAB4ADQAEAAQABAAEAB4ABAAEAEsASwBLAEsASwBLAEsASwBLAEsAUAAOAFAADQANAA0AKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAANAA0AHgANAA0AHgAEACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAA0AKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsABAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQACsABAAEAFAABAAEAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABAArACsAUAArACsAKwArACsAKwAEACsAKwArACsAKwBQAFAAUABQAFAABAAEACsAKwAEAAQABAAEAAQABAAEACsAKwArAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAQABABQAFAAUABQAA0ADQANAA0AHgBLAEsASwBLAEsASwBLAEsASwBLAA0ADQArAB4ABABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAFAAUAAeAFAAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAArACsABAAEAAQABAAEAAQABAAEAAQADgANAA0AEwATAB4AHgAeAA0ADQANAA0ADQANAA0ADQANAA0ADQANAA0ADQANAFAAUABQAFAABAAEACsAKwAEAA0ADQAeAFAAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKwArACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBcAFwADQANAA0AKgBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAKwArAFAAKwArAFAAUABQAFAAUABQAFAAUAArAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQAKwAEAAQAKwArAAQABAAEAAQAUAAEAFAABAAEAA0ADQANACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAArACsABAAEAAQABAAEAAQABABQAA4AUAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAFAABAAEAAQABAAOAB4ADQANAA0ADQAOAB4ABAArACsAKwArACsAKwArACsAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAA0ADQANAFAADgAOAA4ADQANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAAQABAAEAFAADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwAOABMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAArACsAKwAEACsABAAEACsABAAEAAQABAAEAAQABABQAAQAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAKwBQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQAKwAEAAQAKwAEAAQABAAEAAQAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAaABoAGgAaAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABIAEgAQwBDAEMAUABQAFAAUABDAFAAUABQAEgAQwBIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABDAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwAJAAkACQAJAAkACQAJABYAEQArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwANAA0AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAANACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAA0ADQANAB4AHgAeAB4AHgAeAFAAUABQAFAADQAeACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAANAA0AHgAeACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwAEAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAARwBHABUARwAJACsAKwArACsAKwArACsAKwArACsAKwAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACsAKwArACsAKwArACsAKwBXAFcAVwBXAFcAVwBXAFcAVwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUQBRAFEAKwArACsAKwArACsAKwArACsAKwArACsAKwBRAFEAUQBRACsAKwArACsAKwArACsAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArACsAHgAEAAQADQAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAAQABAAEAAQABAAeAB4AHgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4AHgAEAAQABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQAHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwBQAFAAKwArAFAAKwArAFAAUAArACsAUABQAFAAUAArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAUAArAFAAUABQAFAAUABQAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAHgAeAFAAUABQAFAAUAArAFAAKwArACsAUABQAFAAUABQAFAAUAArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeACsAKwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4ABAAeAB4AHgAeAB4AHgAeAB4AHgAeAAQAHgAeAA0ADQANAA0AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAAQAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArAAQABAAEAAQABAAEAAQAKwAEAAQAKwAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwBQAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArABsAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArAB4AHgAeAB4ABAAEAAQABAAEAAQABABQACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArABYAFgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAGgBQAFAAUAAaAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAKwBQACsAKwBQACsAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwBQACsAUAArACsAKwArACsAKwBQACsAKwArACsAUAArAFAAKwBQACsAUABQAFAAKwBQAFAAKwBQACsAKwBQACsAUAArAFAAKwBQACsAUAArAFAAUAArAFAAKwArAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUAArAFAAUABQAFAAKwBQACsAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAKwBQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8AJQAlACUAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB4AHgAeACUAJQAlAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAlACUAJQAlACUAHgAlACUAJQAlACUAIAAgACAAJQAlACAAJQAlACAAIAAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACEAIQAhACEAIQAlACUAIAAgACUAJQAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAIAAlACUAJQAlACAAIAAgACUAIAAgACAAJQAlACUAJQAlACUAJQAgACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAlAB4AJQAeACUAJQAlACUAJQAgACUAJQAlACUAHgAlAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAJQAlACUAJQAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACAAIAAgACUAJQAlACAAIAAgACAAIAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABcAFwAXABUAFQAVAB4AHgAeAB4AJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACUAJQAlACUAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAgACUAJQAgACUAJQAlACUAJQAlACUAJQAgACAAIAAgACAAIAAgACAAJQAlACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAgACAAIAAgACAAIAAgACAAIAAgACUAJQAgACAAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAlACAAIAAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAgACAAIAAlACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACUAVwBXACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAA==';
  39934. var LETTER_NUMBER_MODIFIER = 50;
  39935. // Non-tailorable Line Breaking Classes
  39936. var BK = 1; // Cause a line break (after)
  39937. var CR$1 = 2; // Cause a line break (after), except between CR and LF
  39938. var LF$1 = 3; // Cause a line break (after)
  39939. var CM = 4; // Prohibit a line break between the character and the preceding character
  39940. var NL = 5; // Cause a line break (after)
  39941. var WJ = 7; // Prohibit line breaks before and after
  39942. var ZW = 8; // Provide a break opportunity
  39943. var GL = 9; // Prohibit line breaks before and after
  39944. var SP = 10; // Enable indirect line breaks
  39945. var ZWJ$1 = 11; // Prohibit line breaks within joiner sequences
  39946. // Break Opportunities
  39947. var B2 = 12; // Provide a line break opportunity before and after the character
  39948. var BA = 13; // Generally provide a line break opportunity after the character
  39949. var BB = 14; // Generally provide a line break opportunity before the character
  39950. var HY = 15; // Provide a line break opportunity after the character, except in numeric context
  39951. var CB = 16; // Provide a line break opportunity contingent on additional information
  39952. // Characters Prohibiting Certain Breaks
  39953. var CL = 17; // Prohibit line breaks before
  39954. var CP = 18; // Prohibit line breaks before
  39955. var EX = 19; // Prohibit line breaks before
  39956. var IN = 20; // Allow only indirect line breaks between pairs
  39957. var NS = 21; // Allow only indirect line breaks before
  39958. var OP = 22; // Prohibit line breaks after
  39959. var QU = 23; // Act like they are both opening and closing
  39960. // Numeric Context
  39961. var IS = 24; // Prevent breaks after any and before numeric
  39962. var NU = 25; // Form numeric expressions for line breaking purposes
  39963. var PO = 26; // Do not break following a numeric expression
  39964. var PR = 27; // Do not break in front of a numeric expression
  39965. var SY = 28; // Prevent a break before; and allow a break after
  39966. // Other Characters
  39967. var AI = 29; // Act like AL when the resolvedEAW is N; otherwise; act as ID
  39968. var AL = 30; // Are alphabetic characters or symbols that are used with alphabetic characters
  39969. var CJ = 31; // Treat as NS or ID for strict or normal breaking.
  39970. var EB = 32; // Do not break from following Emoji Modifier
  39971. var EM = 33; // Do not break from preceding Emoji Base
  39972. var H2 = 34; // Form Korean syllable blocks
  39973. var H3 = 35; // Form Korean syllable blocks
  39974. var HL = 36; // Do not break around a following hyphen; otherwise act as Alphabetic
  39975. var ID = 37; // Break before or after; except in some numeric context
  39976. var JL = 38; // Form Korean syllable blocks
  39977. var JV = 39; // Form Korean syllable blocks
  39978. var JT = 40; // Form Korean syllable blocks
  39979. var RI$1 = 41; // Keep pairs together. For pairs; break before and after other classes
  39980. var SA = 42; // Provide a line break opportunity contingent on additional, language-specific context analysis
  39981. var XX = 43; // Have as yet unknown line breaking behavior or unassigned code positions
  39982. var ea_OP = [0x2329, 0xff08];
  39983. var BREAK_MANDATORY = '!';
  39984. var BREAK_NOT_ALLOWED$1 = '×';
  39985. var BREAK_ALLOWED$1 = '÷';
  39986. var UnicodeTrie$1 = createTrieFromBase64$1(base64$1);
  39987. var ALPHABETICS = [AL, HL];
  39988. var HARD_LINE_BREAKS = [BK, CR$1, LF$1, NL];
  39989. var SPACE$1 = [SP, ZW];
  39990. var PREFIX_POSTFIX = [PR, PO];
  39991. var LINE_BREAKS = HARD_LINE_BREAKS.concat(SPACE$1);
  39992. var KOREAN_SYLLABLE_BLOCK = [JL, JV, JT, H2, H3];
  39993. var HYPHEN = [HY, BA];
  39994. var codePointsToCharacterClasses = function (codePoints, lineBreak) {
  39995. if (lineBreak === void 0) { lineBreak = 'strict'; }
  39996. var types = [];
  39997. var indices = [];
  39998. var categories = [];
  39999. codePoints.forEach(function (codePoint, index) {
  40000. var classType = UnicodeTrie$1.get(codePoint);
  40001. if (classType > LETTER_NUMBER_MODIFIER) {
  40002. categories.push(true);
  40003. classType -= LETTER_NUMBER_MODIFIER;
  40004. }
  40005. else {
  40006. categories.push(false);
  40007. }
  40008. if (['normal', 'auto', 'loose'].indexOf(lineBreak) !== -1) {
  40009. // U+2010, – U+2013, 〜 U+301C, ゠ U+30A0
  40010. if ([0x2010, 0x2013, 0x301c, 0x30a0].indexOf(codePoint) !== -1) {
  40011. indices.push(index);
  40012. return types.push(CB);
  40013. }
  40014. }
  40015. if (classType === CM || classType === ZWJ$1) {
  40016. // LB10 Treat any remaining combining mark or ZWJ as AL.
  40017. if (index === 0) {
  40018. indices.push(index);
  40019. return types.push(AL);
  40020. }
  40021. // LB9 Do not break a combining character sequence; treat it as if it has the line breaking class of
  40022. // the base character in all of the following rules. Treat ZWJ as if it were CM.
  40023. var prev = types[index - 1];
  40024. if (LINE_BREAKS.indexOf(prev) === -1) {
  40025. indices.push(indices[index - 1]);
  40026. return types.push(prev);
  40027. }
  40028. indices.push(index);
  40029. return types.push(AL);
  40030. }
  40031. indices.push(index);
  40032. if (classType === CJ) {
  40033. return types.push(lineBreak === 'strict' ? NS : ID);
  40034. }
  40035. if (classType === SA) {
  40036. return types.push(AL);
  40037. }
  40038. if (classType === AI) {
  40039. return types.push(AL);
  40040. }
  40041. // For supplementary characters, a useful default is to treat characters in the range 10000..1FFFD as AL
  40042. // and characters in the ranges 20000..2FFFD and 30000..3FFFD as ID, until the implementation can be revised
  40043. // to take into account the actual line breaking properties for these characters.
  40044. if (classType === XX) {
  40045. if ((codePoint >= 0x20000 && codePoint <= 0x2fffd) || (codePoint >= 0x30000 && codePoint <= 0x3fffd)) {
  40046. return types.push(ID);
  40047. }
  40048. else {
  40049. return types.push(AL);
  40050. }
  40051. }
  40052. types.push(classType);
  40053. });
  40054. return [indices, types, categories];
  40055. };
  40056. var isAdjacentWithSpaceIgnored = function (a, b, currentIndex, classTypes) {
  40057. var current = classTypes[currentIndex];
  40058. if (Array.isArray(a) ? a.indexOf(current) !== -1 : a === current) {
  40059. var i = currentIndex;
  40060. while (i <= classTypes.length) {
  40061. i++;
  40062. var next = classTypes[i];
  40063. if (next === b) {
  40064. return true;
  40065. }
  40066. if (next !== SP) {
  40067. break;
  40068. }
  40069. }
  40070. }
  40071. if (current === SP) {
  40072. var i = currentIndex;
  40073. while (i > 0) {
  40074. i--;
  40075. var prev = classTypes[i];
  40076. if (Array.isArray(a) ? a.indexOf(prev) !== -1 : a === prev) {
  40077. var n = currentIndex;
  40078. while (n <= classTypes.length) {
  40079. n++;
  40080. var next = classTypes[n];
  40081. if (next === b) {
  40082. return true;
  40083. }
  40084. if (next !== SP) {
  40085. break;
  40086. }
  40087. }
  40088. }
  40089. if (prev !== SP) {
  40090. break;
  40091. }
  40092. }
  40093. }
  40094. return false;
  40095. };
  40096. var previousNonSpaceClassType = function (currentIndex, classTypes) {
  40097. var i = currentIndex;
  40098. while (i >= 0) {
  40099. var type = classTypes[i];
  40100. if (type === SP) {
  40101. i--;
  40102. }
  40103. else {
  40104. return type;
  40105. }
  40106. }
  40107. return 0;
  40108. };
  40109. var _lineBreakAtIndex = function (codePoints, classTypes, indicies, index, forbiddenBreaks) {
  40110. if (indicies[index] === 0) {
  40111. return BREAK_NOT_ALLOWED$1;
  40112. }
  40113. var currentIndex = index - 1;
  40114. if (Array.isArray(forbiddenBreaks) && forbiddenBreaks[currentIndex] === true) {
  40115. return BREAK_NOT_ALLOWED$1;
  40116. }
  40117. var beforeIndex = currentIndex - 1;
  40118. var afterIndex = currentIndex + 1;
  40119. var current = classTypes[currentIndex];
  40120. // LB4 Always break after hard line breaks.
  40121. // LB5 Treat CR followed by LF, as well as CR, LF, and NL as hard line breaks.
  40122. var before = beforeIndex >= 0 ? classTypes[beforeIndex] : 0;
  40123. var next = classTypes[afterIndex];
  40124. if (current === CR$1 && next === LF$1) {
  40125. return BREAK_NOT_ALLOWED$1;
  40126. }
  40127. if (HARD_LINE_BREAKS.indexOf(current) !== -1) {
  40128. return BREAK_MANDATORY;
  40129. }
  40130. // LB6 Do not break before hard line breaks.
  40131. if (HARD_LINE_BREAKS.indexOf(next) !== -1) {
  40132. return BREAK_NOT_ALLOWED$1;
  40133. }
  40134. // LB7 Do not break before spaces or zero width space.
  40135. if (SPACE$1.indexOf(next) !== -1) {
  40136. return BREAK_NOT_ALLOWED$1;
  40137. }
  40138. // LB8 Break before any character following a zero-width space, even if one or more spaces intervene.
  40139. if (previousNonSpaceClassType(currentIndex, classTypes) === ZW) {
  40140. return BREAK_ALLOWED$1;
  40141. }
  40142. // LB8a Do not break after a zero width joiner.
  40143. if (UnicodeTrie$1.get(codePoints[currentIndex]) === ZWJ$1) {
  40144. return BREAK_NOT_ALLOWED$1;
  40145. }
  40146. // zwj emojis
  40147. if ((current === EB || current === EM) && UnicodeTrie$1.get(codePoints[afterIndex]) === ZWJ$1) {
  40148. return BREAK_NOT_ALLOWED$1;
  40149. }
  40150. // LB11 Do not break before or after Word joiner and related characters.
  40151. if (current === WJ || next === WJ) {
  40152. return BREAK_NOT_ALLOWED$1;
  40153. }
  40154. // LB12 Do not break after NBSP and related characters.
  40155. if (current === GL) {
  40156. return BREAK_NOT_ALLOWED$1;
  40157. }
  40158. // LB12a Do not break before NBSP and related characters, except after spaces and hyphens.
  40159. if ([SP, BA, HY].indexOf(current) === -1 && next === GL) {
  40160. return BREAK_NOT_ALLOWED$1;
  40161. }
  40162. // LB13 Do not break before ‘]’ or ‘!’ or ‘;’ or ‘/’, even after spaces.
  40163. if ([CL, CP, EX, IS, SY].indexOf(next) !== -1) {
  40164. return BREAK_NOT_ALLOWED$1;
  40165. }
  40166. // LB14 Do not break after ‘[’, even after spaces.
  40167. if (previousNonSpaceClassType(currentIndex, classTypes) === OP) {
  40168. return BREAK_NOT_ALLOWED$1;
  40169. }
  40170. // LB15 Do not break within ‘”[’, even with intervening spaces.
  40171. if (isAdjacentWithSpaceIgnored(QU, OP, currentIndex, classTypes)) {
  40172. return BREAK_NOT_ALLOWED$1;
  40173. }
  40174. // LB16 Do not break between closing punctuation and a nonstarter (lb=NS), even with intervening spaces.
  40175. if (isAdjacentWithSpaceIgnored([CL, CP], NS, currentIndex, classTypes)) {
  40176. return BREAK_NOT_ALLOWED$1;
  40177. }
  40178. // LB17 Do not break within ‘——’, even with intervening spaces.
  40179. if (isAdjacentWithSpaceIgnored(B2, B2, currentIndex, classTypes)) {
  40180. return BREAK_NOT_ALLOWED$1;
  40181. }
  40182. // LB18 Break after spaces.
  40183. if (current === SP) {
  40184. return BREAK_ALLOWED$1;
  40185. }
  40186. // LB19 Do not break before or after quotation marks, such as ‘ ” ’.
  40187. if (current === QU || next === QU) {
  40188. return BREAK_NOT_ALLOWED$1;
  40189. }
  40190. // LB20 Break before and after unresolved CB.
  40191. if (next === CB || current === CB) {
  40192. return BREAK_ALLOWED$1;
  40193. }
  40194. // LB21 Do not break before hyphen-minus, other hyphens, fixed-width spaces, small kana, and other non-starters, or after acute accents.
  40195. if ([BA, HY, NS].indexOf(next) !== -1 || current === BB) {
  40196. return BREAK_NOT_ALLOWED$1;
  40197. }
  40198. // LB21a Don't break after Hebrew + Hyphen.
  40199. if (before === HL && HYPHEN.indexOf(current) !== -1) {
  40200. return BREAK_NOT_ALLOWED$1;
  40201. }
  40202. // LB21b Don’t break between Solidus and Hebrew letters.
  40203. if (current === SY && next === HL) {
  40204. return BREAK_NOT_ALLOWED$1;
  40205. }
  40206. // LB22 Do not break before ellipsis.
  40207. if (next === IN) {
  40208. return BREAK_NOT_ALLOWED$1;
  40209. }
  40210. // LB23 Do not break between digits and letters.
  40211. if ((ALPHABETICS.indexOf(next) !== -1 && current === NU) || (ALPHABETICS.indexOf(current) !== -1 && next === NU)) {
  40212. return BREAK_NOT_ALLOWED$1;
  40213. }
  40214. // LB23a Do not break between numeric prefixes and ideographs, or between ideographs and numeric postfixes.
  40215. if ((current === PR && [ID, EB, EM].indexOf(next) !== -1) ||
  40216. ([ID, EB, EM].indexOf(current) !== -1 && next === PO)) {
  40217. return BREAK_NOT_ALLOWED$1;
  40218. }
  40219. // LB24 Do not break between numeric prefix/postfix and letters, or between letters and prefix/postfix.
  40220. if ((ALPHABETICS.indexOf(current) !== -1 && PREFIX_POSTFIX.indexOf(next) !== -1) ||
  40221. (PREFIX_POSTFIX.indexOf(current) !== -1 && ALPHABETICS.indexOf(next) !== -1)) {
  40222. return BREAK_NOT_ALLOWED$1;
  40223. }
  40224. // LB25 Do not break between the following pairs of classes relevant to numbers:
  40225. if (
  40226. // (PR | PO) × ( OP | HY )? NU
  40227. ([PR, PO].indexOf(current) !== -1 &&
  40228. (next === NU || ([OP, HY].indexOf(next) !== -1 && classTypes[afterIndex + 1] === NU))) ||
  40229. // ( OP | HY ) × NU
  40230. ([OP, HY].indexOf(current) !== -1 && next === NU) ||
  40231. // NU × (NU | SY | IS)
  40232. (current === NU && [NU, SY, IS].indexOf(next) !== -1)) {
  40233. return BREAK_NOT_ALLOWED$1;
  40234. }
  40235. // NU (NU | SY | IS)* × (NU | SY | IS | CL | CP)
  40236. if ([NU, SY, IS, CL, CP].indexOf(next) !== -1) {
  40237. var prevIndex = currentIndex;
  40238. while (prevIndex >= 0) {
  40239. var type = classTypes[prevIndex];
  40240. if (type === NU) {
  40241. return BREAK_NOT_ALLOWED$1;
  40242. }
  40243. else if ([SY, IS].indexOf(type) !== -1) {
  40244. prevIndex--;
  40245. }
  40246. else {
  40247. break;
  40248. }
  40249. }
  40250. }
  40251. // NU (NU | SY | IS)* (CL | CP)? × (PO | PR))
  40252. if ([PR, PO].indexOf(next) !== -1) {
  40253. var prevIndex = [CL, CP].indexOf(current) !== -1 ? beforeIndex : currentIndex;
  40254. while (prevIndex >= 0) {
  40255. var type = classTypes[prevIndex];
  40256. if (type === NU) {
  40257. return BREAK_NOT_ALLOWED$1;
  40258. }
  40259. else if ([SY, IS].indexOf(type) !== -1) {
  40260. prevIndex--;
  40261. }
  40262. else {
  40263. break;
  40264. }
  40265. }
  40266. }
  40267. // LB26 Do not break a Korean syllable.
  40268. if ((JL === current && [JL, JV, H2, H3].indexOf(next) !== -1) ||
  40269. ([JV, H2].indexOf(current) !== -1 && [JV, JT].indexOf(next) !== -1) ||
  40270. ([JT, H3].indexOf(current) !== -1 && next === JT)) {
  40271. return BREAK_NOT_ALLOWED$1;
  40272. }
  40273. // LB27 Treat a Korean Syllable Block the same as ID.
  40274. if ((KOREAN_SYLLABLE_BLOCK.indexOf(current) !== -1 && [IN, PO].indexOf(next) !== -1) ||
  40275. (KOREAN_SYLLABLE_BLOCK.indexOf(next) !== -1 && current === PR)) {
  40276. return BREAK_NOT_ALLOWED$1;
  40277. }
  40278. // LB28 Do not break between alphabetics (“at”).
  40279. if (ALPHABETICS.indexOf(current) !== -1 && ALPHABETICS.indexOf(next) !== -1) {
  40280. return BREAK_NOT_ALLOWED$1;
  40281. }
  40282. // LB29 Do not break between numeric punctuation and alphabetics (“e.g.”).
  40283. if (current === IS && ALPHABETICS.indexOf(next) !== -1) {
  40284. return BREAK_NOT_ALLOWED$1;
  40285. }
  40286. // LB30 Do not break between letters, numbers, or ordinary symbols and opening or closing parentheses.
  40287. if ((ALPHABETICS.concat(NU).indexOf(current) !== -1 &&
  40288. next === OP &&
  40289. ea_OP.indexOf(codePoints[afterIndex]) === -1) ||
  40290. (ALPHABETICS.concat(NU).indexOf(next) !== -1 && current === CP)) {
  40291. return BREAK_NOT_ALLOWED$1;
  40292. }
  40293. // LB30a Break between two regional indicator symbols if and only if there are an even number of regional
  40294. // indicators preceding the position of the break.
  40295. if (current === RI$1 && next === RI$1) {
  40296. var i = indicies[currentIndex];
  40297. var count = 1;
  40298. while (i > 0) {
  40299. i--;
  40300. if (classTypes[i] === RI$1) {
  40301. count++;
  40302. }
  40303. else {
  40304. break;
  40305. }
  40306. }
  40307. if (count % 2 !== 0) {
  40308. return BREAK_NOT_ALLOWED$1;
  40309. }
  40310. }
  40311. // LB30b Do not break between an emoji base and an emoji modifier.
  40312. if (current === EB && next === EM) {
  40313. return BREAK_NOT_ALLOWED$1;
  40314. }
  40315. return BREAK_ALLOWED$1;
  40316. };
  40317. var cssFormattedClasses = function (codePoints, options) {
  40318. if (!options) {
  40319. options = { lineBreak: 'normal', wordBreak: 'normal' };
  40320. }
  40321. var _a = codePointsToCharacterClasses(codePoints, options.lineBreak), indicies = _a[0], classTypes = _a[1], isLetterNumber = _a[2];
  40322. if (options.wordBreak === 'break-all' || options.wordBreak === 'break-word') {
  40323. classTypes = classTypes.map(function (type) { return ([NU, AL, SA].indexOf(type) !== -1 ? ID : type); });
  40324. }
  40325. var forbiddenBreakpoints = options.wordBreak === 'keep-all'
  40326. ? isLetterNumber.map(function (letterNumber, i) {
  40327. return letterNumber && codePoints[i] >= 0x4e00 && codePoints[i] <= 0x9fff;
  40328. })
  40329. : undefined;
  40330. return [indicies, classTypes, forbiddenBreakpoints];
  40331. };
  40332. var Break = /** @class */ (function () {
  40333. function Break(codePoints, lineBreak, start, end) {
  40334. this.codePoints = codePoints;
  40335. this.required = lineBreak === BREAK_MANDATORY;
  40336. this.start = start;
  40337. this.end = end;
  40338. }
  40339. Break.prototype.slice = function () {
  40340. return fromCodePoint$1.apply(void 0, this.codePoints.slice(this.start, this.end));
  40341. };
  40342. return Break;
  40343. }());
  40344. var LineBreaker = function (str, options) {
  40345. var codePoints = toCodePoints$1(str);
  40346. var _a = cssFormattedClasses(codePoints, options), indicies = _a[0], classTypes = _a[1], forbiddenBreakpoints = _a[2];
  40347. var length = codePoints.length;
  40348. var lastEnd = 0;
  40349. var nextIndex = 0;
  40350. return {
  40351. next: function () {
  40352. if (nextIndex >= length) {
  40353. return { done: true, value: null };
  40354. }
  40355. var lineBreak = BREAK_NOT_ALLOWED$1;
  40356. while (nextIndex < length &&
  40357. (lineBreak = _lineBreakAtIndex(codePoints, classTypes, indicies, ++nextIndex, forbiddenBreakpoints)) ===
  40358. BREAK_NOT_ALLOWED$1) { }
  40359. if (lineBreak !== BREAK_NOT_ALLOWED$1 || nextIndex === length) {
  40360. var value = new Break(codePoints, lineBreak, lastEnd, nextIndex);
  40361. lastEnd = nextIndex;
  40362. return { value: value, done: false };
  40363. }
  40364. return { done: true, value: null };
  40365. },
  40366. };
  40367. };
  40368. // https://www.w3.org/TR/css-syntax-3
  40369. var FLAG_UNRESTRICTED = 1 << 0;
  40370. var FLAG_ID = 1 << 1;
  40371. var FLAG_INTEGER = 1 << 2;
  40372. var FLAG_NUMBER = 1 << 3;
  40373. var LINE_FEED = 0x000a;
  40374. var SOLIDUS = 0x002f;
  40375. var REVERSE_SOLIDUS = 0x005c;
  40376. var CHARACTER_TABULATION = 0x0009;
  40377. var SPACE = 0x0020;
  40378. var QUOTATION_MARK = 0x0022;
  40379. var EQUALS_SIGN = 0x003d;
  40380. var NUMBER_SIGN = 0x0023;
  40381. var DOLLAR_SIGN = 0x0024;
  40382. var PERCENTAGE_SIGN = 0x0025;
  40383. var APOSTROPHE = 0x0027;
  40384. var LEFT_PARENTHESIS = 0x0028;
  40385. var RIGHT_PARENTHESIS = 0x0029;
  40386. var LOW_LINE = 0x005f;
  40387. var HYPHEN_MINUS = 0x002d;
  40388. var EXCLAMATION_MARK = 0x0021;
  40389. var LESS_THAN_SIGN = 0x003c;
  40390. var GREATER_THAN_SIGN = 0x003e;
  40391. var COMMERCIAL_AT = 0x0040;
  40392. var LEFT_SQUARE_BRACKET = 0x005b;
  40393. var RIGHT_SQUARE_BRACKET = 0x005d;
  40394. var CIRCUMFLEX_ACCENT = 0x003d;
  40395. var LEFT_CURLY_BRACKET = 0x007b;
  40396. var QUESTION_MARK = 0x003f;
  40397. var RIGHT_CURLY_BRACKET = 0x007d;
  40398. var VERTICAL_LINE = 0x007c;
  40399. var TILDE = 0x007e;
  40400. var CONTROL = 0x0080;
  40401. var REPLACEMENT_CHARACTER = 0xfffd;
  40402. var ASTERISK = 0x002a;
  40403. var PLUS_SIGN = 0x002b;
  40404. var COMMA = 0x002c;
  40405. var COLON = 0x003a;
  40406. var SEMICOLON = 0x003b;
  40407. var FULL_STOP = 0x002e;
  40408. var NULL = 0x0000;
  40409. var BACKSPACE = 0x0008;
  40410. var LINE_TABULATION = 0x000b;
  40411. var SHIFT_OUT = 0x000e;
  40412. var INFORMATION_SEPARATOR_ONE = 0x001f;
  40413. var DELETE = 0x007f;
  40414. var EOF = -1;
  40415. var ZERO = 0x0030;
  40416. var a = 0x0061;
  40417. var e = 0x0065;
  40418. var f = 0x0066;
  40419. var u = 0x0075;
  40420. var z = 0x007a;
  40421. var A = 0x0041;
  40422. var E = 0x0045;
  40423. var F = 0x0046;
  40424. var U = 0x0055;
  40425. var Z = 0x005a;
  40426. var isDigit = function (codePoint) { return codePoint >= ZERO && codePoint <= 0x0039; };
  40427. var isSurrogateCodePoint = function (codePoint) { return codePoint >= 0xd800 && codePoint <= 0xdfff; };
  40428. var isHex = function (codePoint) {
  40429. return isDigit(codePoint) || (codePoint >= A && codePoint <= F) || (codePoint >= a && codePoint <= f);
  40430. };
  40431. var isLowerCaseLetter = function (codePoint) { return codePoint >= a && codePoint <= z; };
  40432. var isUpperCaseLetter = function (codePoint) { return codePoint >= A && codePoint <= Z; };
  40433. var isLetter = function (codePoint) { return isLowerCaseLetter(codePoint) || isUpperCaseLetter(codePoint); };
  40434. var isNonASCIICodePoint = function (codePoint) { return codePoint >= CONTROL; };
  40435. var isWhiteSpace = function (codePoint) {
  40436. return codePoint === LINE_FEED || codePoint === CHARACTER_TABULATION || codePoint === SPACE;
  40437. };
  40438. var isNameStartCodePoint = function (codePoint) {
  40439. return isLetter(codePoint) || isNonASCIICodePoint(codePoint) || codePoint === LOW_LINE;
  40440. };
  40441. var isNameCodePoint = function (codePoint) {
  40442. return isNameStartCodePoint(codePoint) || isDigit(codePoint) || codePoint === HYPHEN_MINUS;
  40443. };
  40444. var isNonPrintableCodePoint = function (codePoint) {
  40445. return ((codePoint >= NULL && codePoint <= BACKSPACE) ||
  40446. codePoint === LINE_TABULATION ||
  40447. (codePoint >= SHIFT_OUT && codePoint <= INFORMATION_SEPARATOR_ONE) ||
  40448. codePoint === DELETE);
  40449. };
  40450. var isValidEscape = function (c1, c2) {
  40451. if (c1 !== REVERSE_SOLIDUS) {
  40452. return false;
  40453. }
  40454. return c2 !== LINE_FEED;
  40455. };
  40456. var isIdentifierStart = function (c1, c2, c3) {
  40457. if (c1 === HYPHEN_MINUS) {
  40458. return isNameStartCodePoint(c2) || isValidEscape(c2, c3);
  40459. }
  40460. else if (isNameStartCodePoint(c1)) {
  40461. return true;
  40462. }
  40463. else if (c1 === REVERSE_SOLIDUS && isValidEscape(c1, c2)) {
  40464. return true;
  40465. }
  40466. return false;
  40467. };
  40468. var isNumberStart = function (c1, c2, c3) {
  40469. if (c1 === PLUS_SIGN || c1 === HYPHEN_MINUS) {
  40470. if (isDigit(c2)) {
  40471. return true;
  40472. }
  40473. return c2 === FULL_STOP && isDigit(c3);
  40474. }
  40475. if (c1 === FULL_STOP) {
  40476. return isDigit(c2);
  40477. }
  40478. return isDigit(c1);
  40479. };
  40480. var stringToNumber = function (codePoints) {
  40481. var c = 0;
  40482. var sign = 1;
  40483. if (codePoints[c] === PLUS_SIGN || codePoints[c] === HYPHEN_MINUS) {
  40484. if (codePoints[c] === HYPHEN_MINUS) {
  40485. sign = -1;
  40486. }
  40487. c++;
  40488. }
  40489. var integers = [];
  40490. while (isDigit(codePoints[c])) {
  40491. integers.push(codePoints[c++]);
  40492. }
  40493. var int = integers.length ? parseInt(fromCodePoint$1.apply(void 0, integers), 10) : 0;
  40494. if (codePoints[c] === FULL_STOP) {
  40495. c++;
  40496. }
  40497. var fraction = [];
  40498. while (isDigit(codePoints[c])) {
  40499. fraction.push(codePoints[c++]);
  40500. }
  40501. var fracd = fraction.length;
  40502. var frac = fracd ? parseInt(fromCodePoint$1.apply(void 0, fraction), 10) : 0;
  40503. if (codePoints[c] === E || codePoints[c] === e) {
  40504. c++;
  40505. }
  40506. var expsign = 1;
  40507. if (codePoints[c] === PLUS_SIGN || codePoints[c] === HYPHEN_MINUS) {
  40508. if (codePoints[c] === HYPHEN_MINUS) {
  40509. expsign = -1;
  40510. }
  40511. c++;
  40512. }
  40513. var exponent = [];
  40514. while (isDigit(codePoints[c])) {
  40515. exponent.push(codePoints[c++]);
  40516. }
  40517. var exp = exponent.length ? parseInt(fromCodePoint$1.apply(void 0, exponent), 10) : 0;
  40518. return sign * (int + frac * Math.pow(10, -fracd)) * Math.pow(10, expsign * exp);
  40519. };
  40520. var LEFT_PARENTHESIS_TOKEN = {
  40521. type: 2 /* LEFT_PARENTHESIS_TOKEN */
  40522. };
  40523. var RIGHT_PARENTHESIS_TOKEN = {
  40524. type: 3 /* RIGHT_PARENTHESIS_TOKEN */
  40525. };
  40526. var COMMA_TOKEN = { type: 4 /* COMMA_TOKEN */ };
  40527. var SUFFIX_MATCH_TOKEN = { type: 13 /* SUFFIX_MATCH_TOKEN */ };
  40528. var PREFIX_MATCH_TOKEN = { type: 8 /* PREFIX_MATCH_TOKEN */ };
  40529. var COLUMN_TOKEN = { type: 21 /* COLUMN_TOKEN */ };
  40530. var DASH_MATCH_TOKEN = { type: 9 /* DASH_MATCH_TOKEN */ };
  40531. var INCLUDE_MATCH_TOKEN = { type: 10 /* INCLUDE_MATCH_TOKEN */ };
  40532. var LEFT_CURLY_BRACKET_TOKEN = {
  40533. type: 11 /* LEFT_CURLY_BRACKET_TOKEN */
  40534. };
  40535. var RIGHT_CURLY_BRACKET_TOKEN = {
  40536. type: 12 /* RIGHT_CURLY_BRACKET_TOKEN */
  40537. };
  40538. var SUBSTRING_MATCH_TOKEN = { type: 14 /* SUBSTRING_MATCH_TOKEN */ };
  40539. var BAD_URL_TOKEN = { type: 23 /* BAD_URL_TOKEN */ };
  40540. var BAD_STRING_TOKEN = { type: 1 /* BAD_STRING_TOKEN */ };
  40541. var CDO_TOKEN = { type: 25 /* CDO_TOKEN */ };
  40542. var CDC_TOKEN = { type: 24 /* CDC_TOKEN */ };
  40543. var COLON_TOKEN = { type: 26 /* COLON_TOKEN */ };
  40544. var SEMICOLON_TOKEN = { type: 27 /* SEMICOLON_TOKEN */ };
  40545. var LEFT_SQUARE_BRACKET_TOKEN = {
  40546. type: 28 /* LEFT_SQUARE_BRACKET_TOKEN */
  40547. };
  40548. var RIGHT_SQUARE_BRACKET_TOKEN = {
  40549. type: 29 /* RIGHT_SQUARE_BRACKET_TOKEN */
  40550. };
  40551. var WHITESPACE_TOKEN = { type: 31 /* WHITESPACE_TOKEN */ };
  40552. var EOF_TOKEN = { type: 32 /* EOF_TOKEN */ };
  40553. var Tokenizer = /** @class */ (function () {
  40554. function Tokenizer() {
  40555. this._value = [];
  40556. }
  40557. Tokenizer.prototype.write = function (chunk) {
  40558. this._value = this._value.concat(toCodePoints$1(chunk));
  40559. };
  40560. Tokenizer.prototype.read = function () {
  40561. var tokens = [];
  40562. var token = this.consumeToken();
  40563. while (token !== EOF_TOKEN) {
  40564. tokens.push(token);
  40565. token = this.consumeToken();
  40566. }
  40567. return tokens;
  40568. };
  40569. Tokenizer.prototype.consumeToken = function () {
  40570. var codePoint = this.consumeCodePoint();
  40571. switch (codePoint) {
  40572. case QUOTATION_MARK:
  40573. return this.consumeStringToken(QUOTATION_MARK);
  40574. case NUMBER_SIGN:
  40575. var c1 = this.peekCodePoint(0);
  40576. var c2 = this.peekCodePoint(1);
  40577. var c3 = this.peekCodePoint(2);
  40578. if (isNameCodePoint(c1) || isValidEscape(c2, c3)) {
  40579. var flags = isIdentifierStart(c1, c2, c3) ? FLAG_ID : FLAG_UNRESTRICTED;
  40580. var value = this.consumeName();
  40581. return { type: 5 /* HASH_TOKEN */, value: value, flags: flags };
  40582. }
  40583. break;
  40584. case DOLLAR_SIGN:
  40585. if (this.peekCodePoint(0) === EQUALS_SIGN) {
  40586. this.consumeCodePoint();
  40587. return SUFFIX_MATCH_TOKEN;
  40588. }
  40589. break;
  40590. case APOSTROPHE:
  40591. return this.consumeStringToken(APOSTROPHE);
  40592. case LEFT_PARENTHESIS:
  40593. return LEFT_PARENTHESIS_TOKEN;
  40594. case RIGHT_PARENTHESIS:
  40595. return RIGHT_PARENTHESIS_TOKEN;
  40596. case ASTERISK:
  40597. if (this.peekCodePoint(0) === EQUALS_SIGN) {
  40598. this.consumeCodePoint();
  40599. return SUBSTRING_MATCH_TOKEN;
  40600. }
  40601. break;
  40602. case PLUS_SIGN:
  40603. if (isNumberStart(codePoint, this.peekCodePoint(0), this.peekCodePoint(1))) {
  40604. this.reconsumeCodePoint(codePoint);
  40605. return this.consumeNumericToken();
  40606. }
  40607. break;
  40608. case COMMA:
  40609. return COMMA_TOKEN;
  40610. case HYPHEN_MINUS:
  40611. var e1 = codePoint;
  40612. var e2 = this.peekCodePoint(0);
  40613. var e3 = this.peekCodePoint(1);
  40614. if (isNumberStart(e1, e2, e3)) {
  40615. this.reconsumeCodePoint(codePoint);
  40616. return this.consumeNumericToken();
  40617. }
  40618. if (isIdentifierStart(e1, e2, e3)) {
  40619. this.reconsumeCodePoint(codePoint);
  40620. return this.consumeIdentLikeToken();
  40621. }
  40622. if (e2 === HYPHEN_MINUS && e3 === GREATER_THAN_SIGN) {
  40623. this.consumeCodePoint();
  40624. this.consumeCodePoint();
  40625. return CDC_TOKEN;
  40626. }
  40627. break;
  40628. case FULL_STOP:
  40629. if (isNumberStart(codePoint, this.peekCodePoint(0), this.peekCodePoint(1))) {
  40630. this.reconsumeCodePoint(codePoint);
  40631. return this.consumeNumericToken();
  40632. }
  40633. break;
  40634. case SOLIDUS:
  40635. if (this.peekCodePoint(0) === ASTERISK) {
  40636. this.consumeCodePoint();
  40637. while (true) {
  40638. var c = this.consumeCodePoint();
  40639. if (c === ASTERISK) {
  40640. c = this.consumeCodePoint();
  40641. if (c === SOLIDUS) {
  40642. return this.consumeToken();
  40643. }
  40644. }
  40645. if (c === EOF) {
  40646. return this.consumeToken();
  40647. }
  40648. }
  40649. }
  40650. break;
  40651. case COLON:
  40652. return COLON_TOKEN;
  40653. case SEMICOLON:
  40654. return SEMICOLON_TOKEN;
  40655. case LESS_THAN_SIGN:
  40656. if (this.peekCodePoint(0) === EXCLAMATION_MARK &&
  40657. this.peekCodePoint(1) === HYPHEN_MINUS &&
  40658. this.peekCodePoint(2) === HYPHEN_MINUS) {
  40659. this.consumeCodePoint();
  40660. this.consumeCodePoint();
  40661. return CDO_TOKEN;
  40662. }
  40663. break;
  40664. case COMMERCIAL_AT:
  40665. var a1 = this.peekCodePoint(0);
  40666. var a2 = this.peekCodePoint(1);
  40667. var a3 = this.peekCodePoint(2);
  40668. if (isIdentifierStart(a1, a2, a3)) {
  40669. var value = this.consumeName();
  40670. return { type: 7 /* AT_KEYWORD_TOKEN */, value: value };
  40671. }
  40672. break;
  40673. case LEFT_SQUARE_BRACKET:
  40674. return LEFT_SQUARE_BRACKET_TOKEN;
  40675. case REVERSE_SOLIDUS:
  40676. if (isValidEscape(codePoint, this.peekCodePoint(0))) {
  40677. this.reconsumeCodePoint(codePoint);
  40678. return this.consumeIdentLikeToken();
  40679. }
  40680. break;
  40681. case RIGHT_SQUARE_BRACKET:
  40682. return RIGHT_SQUARE_BRACKET_TOKEN;
  40683. case CIRCUMFLEX_ACCENT:
  40684. if (this.peekCodePoint(0) === EQUALS_SIGN) {
  40685. this.consumeCodePoint();
  40686. return PREFIX_MATCH_TOKEN;
  40687. }
  40688. break;
  40689. case LEFT_CURLY_BRACKET:
  40690. return LEFT_CURLY_BRACKET_TOKEN;
  40691. case RIGHT_CURLY_BRACKET:
  40692. return RIGHT_CURLY_BRACKET_TOKEN;
  40693. case u:
  40694. case U:
  40695. var u1 = this.peekCodePoint(0);
  40696. var u2 = this.peekCodePoint(1);
  40697. if (u1 === PLUS_SIGN && (isHex(u2) || u2 === QUESTION_MARK)) {
  40698. this.consumeCodePoint();
  40699. this.consumeUnicodeRangeToken();
  40700. }
  40701. this.reconsumeCodePoint(codePoint);
  40702. return this.consumeIdentLikeToken();
  40703. case VERTICAL_LINE:
  40704. if (this.peekCodePoint(0) === EQUALS_SIGN) {
  40705. this.consumeCodePoint();
  40706. return DASH_MATCH_TOKEN;
  40707. }
  40708. if (this.peekCodePoint(0) === VERTICAL_LINE) {
  40709. this.consumeCodePoint();
  40710. return COLUMN_TOKEN;
  40711. }
  40712. break;
  40713. case TILDE:
  40714. if (this.peekCodePoint(0) === EQUALS_SIGN) {
  40715. this.consumeCodePoint();
  40716. return INCLUDE_MATCH_TOKEN;
  40717. }
  40718. break;
  40719. case EOF:
  40720. return EOF_TOKEN;
  40721. }
  40722. if (isWhiteSpace(codePoint)) {
  40723. this.consumeWhiteSpace();
  40724. return WHITESPACE_TOKEN;
  40725. }
  40726. if (isDigit(codePoint)) {
  40727. this.reconsumeCodePoint(codePoint);
  40728. return this.consumeNumericToken();
  40729. }
  40730. if (isNameStartCodePoint(codePoint)) {
  40731. this.reconsumeCodePoint(codePoint);
  40732. return this.consumeIdentLikeToken();
  40733. }
  40734. return { type: 6 /* DELIM_TOKEN */, value: fromCodePoint$1(codePoint) };
  40735. };
  40736. Tokenizer.prototype.consumeCodePoint = function () {
  40737. var value = this._value.shift();
  40738. return typeof value === 'undefined' ? -1 : value;
  40739. };
  40740. Tokenizer.prototype.reconsumeCodePoint = function (codePoint) {
  40741. this._value.unshift(codePoint);
  40742. };
  40743. Tokenizer.prototype.peekCodePoint = function (delta) {
  40744. if (delta >= this._value.length) {
  40745. return -1;
  40746. }
  40747. return this._value[delta];
  40748. };
  40749. Tokenizer.prototype.consumeUnicodeRangeToken = function () {
  40750. var digits = [];
  40751. var codePoint = this.consumeCodePoint();
  40752. while (isHex(codePoint) && digits.length < 6) {
  40753. digits.push(codePoint);
  40754. codePoint = this.consumeCodePoint();
  40755. }
  40756. var questionMarks = false;
  40757. while (codePoint === QUESTION_MARK && digits.length < 6) {
  40758. digits.push(codePoint);
  40759. codePoint = this.consumeCodePoint();
  40760. questionMarks = true;
  40761. }
  40762. if (questionMarks) {
  40763. var start_1 = parseInt(fromCodePoint$1.apply(void 0, digits.map(function (digit) { return (digit === QUESTION_MARK ? ZERO : digit); })), 16);
  40764. var end = parseInt(fromCodePoint$1.apply(void 0, digits.map(function (digit) { return (digit === QUESTION_MARK ? F : digit); })), 16);
  40765. return { type: 30 /* UNICODE_RANGE_TOKEN */, start: start_1, end: end };
  40766. }
  40767. var start = parseInt(fromCodePoint$1.apply(void 0, digits), 16);
  40768. if (this.peekCodePoint(0) === HYPHEN_MINUS && isHex(this.peekCodePoint(1))) {
  40769. this.consumeCodePoint();
  40770. codePoint = this.consumeCodePoint();
  40771. var endDigits = [];
  40772. while (isHex(codePoint) && endDigits.length < 6) {
  40773. endDigits.push(codePoint);
  40774. codePoint = this.consumeCodePoint();
  40775. }
  40776. var end = parseInt(fromCodePoint$1.apply(void 0, endDigits), 16);
  40777. return { type: 30 /* UNICODE_RANGE_TOKEN */, start: start, end: end };
  40778. }
  40779. else {
  40780. return { type: 30 /* UNICODE_RANGE_TOKEN */, start: start, end: start };
  40781. }
  40782. };
  40783. Tokenizer.prototype.consumeIdentLikeToken = function () {
  40784. var value = this.consumeName();
  40785. if (value.toLowerCase() === 'url' && this.peekCodePoint(0) === LEFT_PARENTHESIS) {
  40786. this.consumeCodePoint();
  40787. return this.consumeUrlToken();
  40788. }
  40789. else if (this.peekCodePoint(0) === LEFT_PARENTHESIS) {
  40790. this.consumeCodePoint();
  40791. return { type: 19 /* FUNCTION_TOKEN */, value: value };
  40792. }
  40793. return { type: 20 /* IDENT_TOKEN */, value: value };
  40794. };
  40795. Tokenizer.prototype.consumeUrlToken = function () {
  40796. var value = [];
  40797. this.consumeWhiteSpace();
  40798. if (this.peekCodePoint(0) === EOF) {
  40799. return { type: 22 /* URL_TOKEN */, value: '' };
  40800. }
  40801. var next = this.peekCodePoint(0);
  40802. if (next === APOSTROPHE || next === QUOTATION_MARK) {
  40803. var stringToken = this.consumeStringToken(this.consumeCodePoint());
  40804. if (stringToken.type === 0 /* STRING_TOKEN */) {
  40805. this.consumeWhiteSpace();
  40806. if (this.peekCodePoint(0) === EOF || this.peekCodePoint(0) === RIGHT_PARENTHESIS) {
  40807. this.consumeCodePoint();
  40808. return { type: 22 /* URL_TOKEN */, value: stringToken.value };
  40809. }
  40810. }
  40811. this.consumeBadUrlRemnants();
  40812. return BAD_URL_TOKEN;
  40813. }
  40814. while (true) {
  40815. var codePoint = this.consumeCodePoint();
  40816. if (codePoint === EOF || codePoint === RIGHT_PARENTHESIS) {
  40817. return { type: 22 /* URL_TOKEN */, value: fromCodePoint$1.apply(void 0, value) };
  40818. }
  40819. else if (isWhiteSpace(codePoint)) {
  40820. this.consumeWhiteSpace();
  40821. if (this.peekCodePoint(0) === EOF || this.peekCodePoint(0) === RIGHT_PARENTHESIS) {
  40822. this.consumeCodePoint();
  40823. return { type: 22 /* URL_TOKEN */, value: fromCodePoint$1.apply(void 0, value) };
  40824. }
  40825. this.consumeBadUrlRemnants();
  40826. return BAD_URL_TOKEN;
  40827. }
  40828. else if (codePoint === QUOTATION_MARK ||
  40829. codePoint === APOSTROPHE ||
  40830. codePoint === LEFT_PARENTHESIS ||
  40831. isNonPrintableCodePoint(codePoint)) {
  40832. this.consumeBadUrlRemnants();
  40833. return BAD_URL_TOKEN;
  40834. }
  40835. else if (codePoint === REVERSE_SOLIDUS) {
  40836. if (isValidEscape(codePoint, this.peekCodePoint(0))) {
  40837. value.push(this.consumeEscapedCodePoint());
  40838. }
  40839. else {
  40840. this.consumeBadUrlRemnants();
  40841. return BAD_URL_TOKEN;
  40842. }
  40843. }
  40844. else {
  40845. value.push(codePoint);
  40846. }
  40847. }
  40848. };
  40849. Tokenizer.prototype.consumeWhiteSpace = function () {
  40850. while (isWhiteSpace(this.peekCodePoint(0))) {
  40851. this.consumeCodePoint();
  40852. }
  40853. };
  40854. Tokenizer.prototype.consumeBadUrlRemnants = function () {
  40855. while (true) {
  40856. var codePoint = this.consumeCodePoint();
  40857. if (codePoint === RIGHT_PARENTHESIS || codePoint === EOF) {
  40858. return;
  40859. }
  40860. if (isValidEscape(codePoint, this.peekCodePoint(0))) {
  40861. this.consumeEscapedCodePoint();
  40862. }
  40863. }
  40864. };
  40865. Tokenizer.prototype.consumeStringSlice = function (count) {
  40866. var SLICE_STACK_SIZE = 50000;
  40867. var value = '';
  40868. while (count > 0) {
  40869. var amount = Math.min(SLICE_STACK_SIZE, count);
  40870. value += fromCodePoint$1.apply(void 0, this._value.splice(0, amount));
  40871. count -= amount;
  40872. }
  40873. this._value.shift();
  40874. return value;
  40875. };
  40876. Tokenizer.prototype.consumeStringToken = function (endingCodePoint) {
  40877. var value = '';
  40878. var i = 0;
  40879. do {
  40880. var codePoint = this._value[i];
  40881. if (codePoint === EOF || codePoint === undefined || codePoint === endingCodePoint) {
  40882. value += this.consumeStringSlice(i);
  40883. return { type: 0 /* STRING_TOKEN */, value: value };
  40884. }
  40885. if (codePoint === LINE_FEED) {
  40886. this._value.splice(0, i);
  40887. return BAD_STRING_TOKEN;
  40888. }
  40889. if (codePoint === REVERSE_SOLIDUS) {
  40890. var next = this._value[i + 1];
  40891. if (next !== EOF && next !== undefined) {
  40892. if (next === LINE_FEED) {
  40893. value += this.consumeStringSlice(i);
  40894. i = -1;
  40895. this._value.shift();
  40896. }
  40897. else if (isValidEscape(codePoint, next)) {
  40898. value += this.consumeStringSlice(i);
  40899. value += fromCodePoint$1(this.consumeEscapedCodePoint());
  40900. i = -1;
  40901. }
  40902. }
  40903. }
  40904. i++;
  40905. } while (true);
  40906. };
  40907. Tokenizer.prototype.consumeNumber = function () {
  40908. var repr = [];
  40909. var type = FLAG_INTEGER;
  40910. var c1 = this.peekCodePoint(0);
  40911. if (c1 === PLUS_SIGN || c1 === HYPHEN_MINUS) {
  40912. repr.push(this.consumeCodePoint());
  40913. }
  40914. while (isDigit(this.peekCodePoint(0))) {
  40915. repr.push(this.consumeCodePoint());
  40916. }
  40917. c1 = this.peekCodePoint(0);
  40918. var c2 = this.peekCodePoint(1);
  40919. if (c1 === FULL_STOP && isDigit(c2)) {
  40920. repr.push(this.consumeCodePoint(), this.consumeCodePoint());
  40921. type = FLAG_NUMBER;
  40922. while (isDigit(this.peekCodePoint(0))) {
  40923. repr.push(this.consumeCodePoint());
  40924. }
  40925. }
  40926. c1 = this.peekCodePoint(0);
  40927. c2 = this.peekCodePoint(1);
  40928. var c3 = this.peekCodePoint(2);
  40929. if ((c1 === E || c1 === e) && (((c2 === PLUS_SIGN || c2 === HYPHEN_MINUS) && isDigit(c3)) || isDigit(c2))) {
  40930. repr.push(this.consumeCodePoint(), this.consumeCodePoint());
  40931. type = FLAG_NUMBER;
  40932. while (isDigit(this.peekCodePoint(0))) {
  40933. repr.push(this.consumeCodePoint());
  40934. }
  40935. }
  40936. return [stringToNumber(repr), type];
  40937. };
  40938. Tokenizer.prototype.consumeNumericToken = function () {
  40939. var _a = this.consumeNumber(), number = _a[0], flags = _a[1];
  40940. var c1 = this.peekCodePoint(0);
  40941. var c2 = this.peekCodePoint(1);
  40942. var c3 = this.peekCodePoint(2);
  40943. if (isIdentifierStart(c1, c2, c3)) {
  40944. var unit = this.consumeName();
  40945. return { type: 15 /* DIMENSION_TOKEN */, number: number, flags: flags, unit: unit };
  40946. }
  40947. if (c1 === PERCENTAGE_SIGN) {
  40948. this.consumeCodePoint();
  40949. return { type: 16 /* PERCENTAGE_TOKEN */, number: number, flags: flags };
  40950. }
  40951. return { type: 17 /* NUMBER_TOKEN */, number: number, flags: flags };
  40952. };
  40953. Tokenizer.prototype.consumeEscapedCodePoint = function () {
  40954. var codePoint = this.consumeCodePoint();
  40955. if (isHex(codePoint)) {
  40956. var hex = fromCodePoint$1(codePoint);
  40957. while (isHex(this.peekCodePoint(0)) && hex.length < 6) {
  40958. hex += fromCodePoint$1(this.consumeCodePoint());
  40959. }
  40960. if (isWhiteSpace(this.peekCodePoint(0))) {
  40961. this.consumeCodePoint();
  40962. }
  40963. var hexCodePoint = parseInt(hex, 16);
  40964. if (hexCodePoint === 0 || isSurrogateCodePoint(hexCodePoint) || hexCodePoint > 0x10ffff) {
  40965. return REPLACEMENT_CHARACTER;
  40966. }
  40967. return hexCodePoint;
  40968. }
  40969. if (codePoint === EOF) {
  40970. return REPLACEMENT_CHARACTER;
  40971. }
  40972. return codePoint;
  40973. };
  40974. Tokenizer.prototype.consumeName = function () {
  40975. var result = '';
  40976. while (true) {
  40977. var codePoint = this.consumeCodePoint();
  40978. if (isNameCodePoint(codePoint)) {
  40979. result += fromCodePoint$1(codePoint);
  40980. }
  40981. else if (isValidEscape(codePoint, this.peekCodePoint(0))) {
  40982. result += fromCodePoint$1(this.consumeEscapedCodePoint());
  40983. }
  40984. else {
  40985. this.reconsumeCodePoint(codePoint);
  40986. return result;
  40987. }
  40988. }
  40989. };
  40990. return Tokenizer;
  40991. }());
  40992. var Parser = /** @class */ (function () {
  40993. function Parser(tokens) {
  40994. this._tokens = tokens;
  40995. }
  40996. Parser.create = function (value) {
  40997. var tokenizer = new Tokenizer();
  40998. tokenizer.write(value);
  40999. return new Parser(tokenizer.read());
  41000. };
  41001. Parser.parseValue = function (value) {
  41002. return Parser.create(value).parseComponentValue();
  41003. };
  41004. Parser.parseValues = function (value) {
  41005. return Parser.create(value).parseComponentValues();
  41006. };
  41007. Parser.prototype.parseComponentValue = function () {
  41008. var token = this.consumeToken();
  41009. while (token.type === 31 /* WHITESPACE_TOKEN */) {
  41010. token = this.consumeToken();
  41011. }
  41012. if (token.type === 32 /* EOF_TOKEN */) {
  41013. throw new SyntaxError("Error parsing CSS component value, unexpected EOF");
  41014. }
  41015. this.reconsumeToken(token);
  41016. var value = this.consumeComponentValue();
  41017. do {
  41018. token = this.consumeToken();
  41019. } while (token.type === 31 /* WHITESPACE_TOKEN */);
  41020. if (token.type === 32 /* EOF_TOKEN */) {
  41021. return value;
  41022. }
  41023. throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one");
  41024. };
  41025. Parser.prototype.parseComponentValues = function () {
  41026. var values = [];
  41027. while (true) {
  41028. var value = this.consumeComponentValue();
  41029. if (value.type === 32 /* EOF_TOKEN */) {
  41030. return values;
  41031. }
  41032. values.push(value);
  41033. values.push();
  41034. }
  41035. };
  41036. Parser.prototype.consumeComponentValue = function () {
  41037. var token = this.consumeToken();
  41038. switch (token.type) {
  41039. case 11 /* LEFT_CURLY_BRACKET_TOKEN */:
  41040. case 28 /* LEFT_SQUARE_BRACKET_TOKEN */:
  41041. case 2 /* LEFT_PARENTHESIS_TOKEN */:
  41042. return this.consumeSimpleBlock(token.type);
  41043. case 19 /* FUNCTION_TOKEN */:
  41044. return this.consumeFunction(token);
  41045. }
  41046. return token;
  41047. };
  41048. Parser.prototype.consumeSimpleBlock = function (type) {
  41049. var block = { type: type, values: [] };
  41050. var token = this.consumeToken();
  41051. while (true) {
  41052. if (token.type === 32 /* EOF_TOKEN */ || isEndingTokenFor(token, type)) {
  41053. return block;
  41054. }
  41055. this.reconsumeToken(token);
  41056. block.values.push(this.consumeComponentValue());
  41057. token = this.consumeToken();
  41058. }
  41059. };
  41060. Parser.prototype.consumeFunction = function (functionToken) {
  41061. var cssFunction = {
  41062. name: functionToken.value,
  41063. values: [],
  41064. type: 18 /* FUNCTION */
  41065. };
  41066. while (true) {
  41067. var token = this.consumeToken();
  41068. if (token.type === 32 /* EOF_TOKEN */ || token.type === 3 /* RIGHT_PARENTHESIS_TOKEN */) {
  41069. return cssFunction;
  41070. }
  41071. this.reconsumeToken(token);
  41072. cssFunction.values.push(this.consumeComponentValue());
  41073. }
  41074. };
  41075. Parser.prototype.consumeToken = function () {
  41076. var token = this._tokens.shift();
  41077. return typeof token === 'undefined' ? EOF_TOKEN : token;
  41078. };
  41079. Parser.prototype.reconsumeToken = function (token) {
  41080. this._tokens.unshift(token);
  41081. };
  41082. return Parser;
  41083. }());
  41084. var isDimensionToken = function (token) { return token.type === 15 /* DIMENSION_TOKEN */; };
  41085. var isNumberToken = function (token) { return token.type === 17 /* NUMBER_TOKEN */; };
  41086. var isIdentToken = function (token) { return token.type === 20 /* IDENT_TOKEN */; };
  41087. var isStringToken = function (token) { return token.type === 0 /* STRING_TOKEN */; };
  41088. var isIdentWithValue = function (token, value) {
  41089. return isIdentToken(token) && token.value === value;
  41090. };
  41091. var nonWhiteSpace = function (token) { return token.type !== 31 /* WHITESPACE_TOKEN */; };
  41092. var nonFunctionArgSeparator = function (token) {
  41093. return token.type !== 31 /* WHITESPACE_TOKEN */ && token.type !== 4 /* COMMA_TOKEN */;
  41094. };
  41095. var parseFunctionArgs = function (tokens) {
  41096. var args = [];
  41097. var arg = [];
  41098. tokens.forEach(function (token) {
  41099. if (token.type === 4 /* COMMA_TOKEN */) {
  41100. if (arg.length === 0) {
  41101. throw new Error("Error parsing function args, zero tokens for arg");
  41102. }
  41103. args.push(arg);
  41104. arg = [];
  41105. return;
  41106. }
  41107. if (token.type !== 31 /* WHITESPACE_TOKEN */) {
  41108. arg.push(token);
  41109. }
  41110. });
  41111. if (arg.length) {
  41112. args.push(arg);
  41113. }
  41114. return args;
  41115. };
  41116. var isEndingTokenFor = function (token, type) {
  41117. if (type === 11 /* LEFT_CURLY_BRACKET_TOKEN */ && token.type === 12 /* RIGHT_CURLY_BRACKET_TOKEN */) {
  41118. return true;
  41119. }
  41120. if (type === 28 /* LEFT_SQUARE_BRACKET_TOKEN */ && token.type === 29 /* RIGHT_SQUARE_BRACKET_TOKEN */) {
  41121. return true;
  41122. }
  41123. return type === 2 /* LEFT_PARENTHESIS_TOKEN */ && token.type === 3 /* RIGHT_PARENTHESIS_TOKEN */;
  41124. };
  41125. var isLength = function (token) {
  41126. return token.type === 17 /* NUMBER_TOKEN */ || token.type === 15 /* DIMENSION_TOKEN */;
  41127. };
  41128. var isLengthPercentage = function (token) {
  41129. return token.type === 16 /* PERCENTAGE_TOKEN */ || isLength(token);
  41130. };
  41131. var parseLengthPercentageTuple = function (tokens) {
  41132. return tokens.length > 1 ? [tokens[0], tokens[1]] : [tokens[0]];
  41133. };
  41134. var ZERO_LENGTH = {
  41135. type: 17 /* NUMBER_TOKEN */,
  41136. number: 0,
  41137. flags: FLAG_INTEGER
  41138. };
  41139. var FIFTY_PERCENT = {
  41140. type: 16 /* PERCENTAGE_TOKEN */,
  41141. number: 50,
  41142. flags: FLAG_INTEGER
  41143. };
  41144. var HUNDRED_PERCENT = {
  41145. type: 16 /* PERCENTAGE_TOKEN */,
  41146. number: 100,
  41147. flags: FLAG_INTEGER
  41148. };
  41149. var getAbsoluteValueForTuple = function (tuple, width, height) {
  41150. var x = tuple[0], y = tuple[1];
  41151. return [getAbsoluteValue(x, width), getAbsoluteValue(typeof y !== 'undefined' ? y : x, height)];
  41152. };
  41153. var getAbsoluteValue = function (token, parent) {
  41154. if (token.type === 16 /* PERCENTAGE_TOKEN */) {
  41155. return (token.number / 100) * parent;
  41156. }
  41157. if (isDimensionToken(token)) {
  41158. switch (token.unit) {
  41159. case 'rem':
  41160. case 'em':
  41161. return 16 * token.number; // TODO use correct font-size
  41162. case 'px':
  41163. default:
  41164. return token.number;
  41165. }
  41166. }
  41167. return token.number;
  41168. };
  41169. var DEG = 'deg';
  41170. var GRAD = 'grad';
  41171. var RAD = 'rad';
  41172. var TURN = 'turn';
  41173. var angle = {
  41174. name: 'angle',
  41175. parse: function (_context, value) {
  41176. if (value.type === 15 /* DIMENSION_TOKEN */) {
  41177. switch (value.unit) {
  41178. case DEG:
  41179. return (Math.PI * value.number) / 180;
  41180. case GRAD:
  41181. return (Math.PI / 200) * value.number;
  41182. case RAD:
  41183. return value.number;
  41184. case TURN:
  41185. return Math.PI * 2 * value.number;
  41186. }
  41187. }
  41188. throw new Error("Unsupported angle type");
  41189. }
  41190. };
  41191. var isAngle = function (value) {
  41192. if (value.type === 15 /* DIMENSION_TOKEN */) {
  41193. if (value.unit === DEG || value.unit === GRAD || value.unit === RAD || value.unit === TURN) {
  41194. return true;
  41195. }
  41196. }
  41197. return false;
  41198. };
  41199. var parseNamedSide = function (tokens) {
  41200. var sideOrCorner = tokens
  41201. .filter(isIdentToken)
  41202. .map(function (ident) { return ident.value; })
  41203. .join(' ');
  41204. switch (sideOrCorner) {
  41205. case 'to bottom right':
  41206. case 'to right bottom':
  41207. case 'left top':
  41208. case 'top left':
  41209. return [ZERO_LENGTH, ZERO_LENGTH];
  41210. case 'to top':
  41211. case 'bottom':
  41212. return deg(0);
  41213. case 'to bottom left':
  41214. case 'to left bottom':
  41215. case 'right top':
  41216. case 'top right':
  41217. return [ZERO_LENGTH, HUNDRED_PERCENT];
  41218. case 'to right':
  41219. case 'left':
  41220. return deg(90);
  41221. case 'to top left':
  41222. case 'to left top':
  41223. case 'right bottom':
  41224. case 'bottom right':
  41225. return [HUNDRED_PERCENT, HUNDRED_PERCENT];
  41226. case 'to bottom':
  41227. case 'top':
  41228. return deg(180);
  41229. case 'to top right':
  41230. case 'to right top':
  41231. case 'left bottom':
  41232. case 'bottom left':
  41233. return [HUNDRED_PERCENT, ZERO_LENGTH];
  41234. case 'to left':
  41235. case 'right':
  41236. return deg(270);
  41237. }
  41238. return 0;
  41239. };
  41240. var deg = function (deg) { return (Math.PI * deg) / 180; };
  41241. var color$1 = {
  41242. name: 'color',
  41243. parse: function (context, value) {
  41244. if (value.type === 18 /* FUNCTION */) {
  41245. var colorFunction = SUPPORTED_COLOR_FUNCTIONS[value.name];
  41246. if (typeof colorFunction === 'undefined') {
  41247. throw new Error("Attempting to parse an unsupported color function \"" + value.name + "\"");
  41248. }
  41249. return colorFunction(context, value.values);
  41250. }
  41251. if (value.type === 5 /* HASH_TOKEN */) {
  41252. if (value.value.length === 3) {
  41253. var r = value.value.substring(0, 1);
  41254. var g = value.value.substring(1, 2);
  41255. var b = value.value.substring(2, 3);
  41256. return pack(parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), 1);
  41257. }
  41258. if (value.value.length === 4) {
  41259. var r = value.value.substring(0, 1);
  41260. var g = value.value.substring(1, 2);
  41261. var b = value.value.substring(2, 3);
  41262. var a = value.value.substring(3, 4);
  41263. return pack(parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), parseInt(a + a, 16) / 255);
  41264. }
  41265. if (value.value.length === 6) {
  41266. var r = value.value.substring(0, 2);
  41267. var g = value.value.substring(2, 4);
  41268. var b = value.value.substring(4, 6);
  41269. return pack(parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), 1);
  41270. }
  41271. if (value.value.length === 8) {
  41272. var r = value.value.substring(0, 2);
  41273. var g = value.value.substring(2, 4);
  41274. var b = value.value.substring(4, 6);
  41275. var a = value.value.substring(6, 8);
  41276. return pack(parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), parseInt(a, 16) / 255);
  41277. }
  41278. }
  41279. if (value.type === 20 /* IDENT_TOKEN */) {
  41280. var namedColor = COLORS[value.value.toUpperCase()];
  41281. if (typeof namedColor !== 'undefined') {
  41282. return namedColor;
  41283. }
  41284. }
  41285. return COLORS.TRANSPARENT;
  41286. }
  41287. };
  41288. var isTransparent = function (color) { return (0xff & color) === 0; };
  41289. var asString = function (color) {
  41290. var alpha = 0xff & color;
  41291. var blue = 0xff & (color >> 8);
  41292. var green = 0xff & (color >> 16);
  41293. var red = 0xff & (color >> 24);
  41294. return alpha < 255 ? "rgba(" + red + "," + green + "," + blue + "," + alpha / 255 + ")" : "rgb(" + red + "," + green + "," + blue + ")";
  41295. };
  41296. var pack = function (r, g, b, a) {
  41297. return ((r << 24) | (g << 16) | (b << 8) | (Math.round(a * 255) << 0)) >>> 0;
  41298. };
  41299. var getTokenColorValue = function (token, i) {
  41300. if (token.type === 17 /* NUMBER_TOKEN */) {
  41301. return token.number;
  41302. }
  41303. if (token.type === 16 /* PERCENTAGE_TOKEN */) {
  41304. var max = i === 3 ? 1 : 255;
  41305. return i === 3 ? (token.number / 100) * max : Math.round((token.number / 100) * max);
  41306. }
  41307. return 0;
  41308. };
  41309. var rgb = function (_context, args) {
  41310. var tokens = args.filter(nonFunctionArgSeparator);
  41311. if (tokens.length === 3) {
  41312. var _a = tokens.map(getTokenColorValue), r = _a[0], g = _a[1], b = _a[2];
  41313. return pack(r, g, b, 1);
  41314. }
  41315. if (tokens.length === 4) {
  41316. var _b = tokens.map(getTokenColorValue), r = _b[0], g = _b[1], b = _b[2], a = _b[3];
  41317. return pack(r, g, b, a);
  41318. }
  41319. return 0;
  41320. };
  41321. function hue2rgb(t1, t2, hue) {
  41322. if (hue < 0) {
  41323. hue += 1;
  41324. }
  41325. if (hue >= 1) {
  41326. hue -= 1;
  41327. }
  41328. if (hue < 1 / 6) {
  41329. return (t2 - t1) * hue * 6 + t1;
  41330. }
  41331. else if (hue < 1 / 2) {
  41332. return t2;
  41333. }
  41334. else if (hue < 2 / 3) {
  41335. return (t2 - t1) * 6 * (2 / 3 - hue) + t1;
  41336. }
  41337. else {
  41338. return t1;
  41339. }
  41340. }
  41341. var hsl = function (context, args) {
  41342. var tokens = args.filter(nonFunctionArgSeparator);
  41343. var hue = tokens[0], saturation = tokens[1], lightness = tokens[2], alpha = tokens[3];
  41344. var h = (hue.type === 17 /* NUMBER_TOKEN */ ? deg(hue.number) : angle.parse(context, hue)) / (Math.PI * 2);
  41345. var s = isLengthPercentage(saturation) ? saturation.number / 100 : 0;
  41346. var l = isLengthPercentage(lightness) ? lightness.number / 100 : 0;
  41347. var a = typeof alpha !== 'undefined' && isLengthPercentage(alpha) ? getAbsoluteValue(alpha, 1) : 1;
  41348. if (s === 0) {
  41349. return pack(l * 255, l * 255, l * 255, 1);
  41350. }
  41351. var t2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
  41352. var t1 = l * 2 - t2;
  41353. var r = hue2rgb(t1, t2, h + 1 / 3);
  41354. var g = hue2rgb(t1, t2, h);
  41355. var b = hue2rgb(t1, t2, h - 1 / 3);
  41356. return pack(r * 255, g * 255, b * 255, a);
  41357. };
  41358. var SUPPORTED_COLOR_FUNCTIONS = {
  41359. hsl: hsl,
  41360. hsla: hsl,
  41361. rgb: rgb,
  41362. rgba: rgb
  41363. };
  41364. var parseColor = function (context, value) {
  41365. return color$1.parse(context, Parser.create(value).parseComponentValue());
  41366. };
  41367. var COLORS = {
  41368. ALICEBLUE: 0xf0f8ffff,
  41369. ANTIQUEWHITE: 0xfaebd7ff,
  41370. AQUA: 0x00ffffff,
  41371. AQUAMARINE: 0x7fffd4ff,
  41372. AZURE: 0xf0ffffff,
  41373. BEIGE: 0xf5f5dcff,
  41374. BISQUE: 0xffe4c4ff,
  41375. BLACK: 0x000000ff,
  41376. BLANCHEDALMOND: 0xffebcdff,
  41377. BLUE: 0x0000ffff,
  41378. BLUEVIOLET: 0x8a2be2ff,
  41379. BROWN: 0xa52a2aff,
  41380. BURLYWOOD: 0xdeb887ff,
  41381. CADETBLUE: 0x5f9ea0ff,
  41382. CHARTREUSE: 0x7fff00ff,
  41383. CHOCOLATE: 0xd2691eff,
  41384. CORAL: 0xff7f50ff,
  41385. CORNFLOWERBLUE: 0x6495edff,
  41386. CORNSILK: 0xfff8dcff,
  41387. CRIMSON: 0xdc143cff,
  41388. CYAN: 0x00ffffff,
  41389. DARKBLUE: 0x00008bff,
  41390. DARKCYAN: 0x008b8bff,
  41391. DARKGOLDENROD: 0xb886bbff,
  41392. DARKGRAY: 0xa9a9a9ff,
  41393. DARKGREEN: 0x006400ff,
  41394. DARKGREY: 0xa9a9a9ff,
  41395. DARKKHAKI: 0xbdb76bff,
  41396. DARKMAGENTA: 0x8b008bff,
  41397. DARKOLIVEGREEN: 0x556b2fff,
  41398. DARKORANGE: 0xff8c00ff,
  41399. DARKORCHID: 0x9932ccff,
  41400. DARKRED: 0x8b0000ff,
  41401. DARKSALMON: 0xe9967aff,
  41402. DARKSEAGREEN: 0x8fbc8fff,
  41403. DARKSLATEBLUE: 0x483d8bff,
  41404. DARKSLATEGRAY: 0x2f4f4fff,
  41405. DARKSLATEGREY: 0x2f4f4fff,
  41406. DARKTURQUOISE: 0x00ced1ff,
  41407. DARKVIOLET: 0x9400d3ff,
  41408. DEEPPINK: 0xff1493ff,
  41409. DEEPSKYBLUE: 0x00bfffff,
  41410. DIMGRAY: 0x696969ff,
  41411. DIMGREY: 0x696969ff,
  41412. DODGERBLUE: 0x1e90ffff,
  41413. FIREBRICK: 0xb22222ff,
  41414. FLORALWHITE: 0xfffaf0ff,
  41415. FORESTGREEN: 0x228b22ff,
  41416. FUCHSIA: 0xff00ffff,
  41417. GAINSBORO: 0xdcdcdcff,
  41418. GHOSTWHITE: 0xf8f8ffff,
  41419. GOLD: 0xffd700ff,
  41420. GOLDENROD: 0xdaa520ff,
  41421. GRAY: 0x808080ff,
  41422. GREEN: 0x008000ff,
  41423. GREENYELLOW: 0xadff2fff,
  41424. GREY: 0x808080ff,
  41425. HONEYDEW: 0xf0fff0ff,
  41426. HOTPINK: 0xff69b4ff,
  41427. INDIANRED: 0xcd5c5cff,
  41428. INDIGO: 0x4b0082ff,
  41429. IVORY: 0xfffff0ff,
  41430. KHAKI: 0xf0e68cff,
  41431. LAVENDER: 0xe6e6faff,
  41432. LAVENDERBLUSH: 0xfff0f5ff,
  41433. LAWNGREEN: 0x7cfc00ff,
  41434. LEMONCHIFFON: 0xfffacdff,
  41435. LIGHTBLUE: 0xadd8e6ff,
  41436. LIGHTCORAL: 0xf08080ff,
  41437. LIGHTCYAN: 0xe0ffffff,
  41438. LIGHTGOLDENRODYELLOW: 0xfafad2ff,
  41439. LIGHTGRAY: 0xd3d3d3ff,
  41440. LIGHTGREEN: 0x90ee90ff,
  41441. LIGHTGREY: 0xd3d3d3ff,
  41442. LIGHTPINK: 0xffb6c1ff,
  41443. LIGHTSALMON: 0xffa07aff,
  41444. LIGHTSEAGREEN: 0x20b2aaff,
  41445. LIGHTSKYBLUE: 0x87cefaff,
  41446. LIGHTSLATEGRAY: 0x778899ff,
  41447. LIGHTSLATEGREY: 0x778899ff,
  41448. LIGHTSTEELBLUE: 0xb0c4deff,
  41449. LIGHTYELLOW: 0xffffe0ff,
  41450. LIME: 0x00ff00ff,
  41451. LIMEGREEN: 0x32cd32ff,
  41452. LINEN: 0xfaf0e6ff,
  41453. MAGENTA: 0xff00ffff,
  41454. MAROON: 0x800000ff,
  41455. MEDIUMAQUAMARINE: 0x66cdaaff,
  41456. MEDIUMBLUE: 0x0000cdff,
  41457. MEDIUMORCHID: 0xba55d3ff,
  41458. MEDIUMPURPLE: 0x9370dbff,
  41459. MEDIUMSEAGREEN: 0x3cb371ff,
  41460. MEDIUMSLATEBLUE: 0x7b68eeff,
  41461. MEDIUMSPRINGGREEN: 0x00fa9aff,
  41462. MEDIUMTURQUOISE: 0x48d1ccff,
  41463. MEDIUMVIOLETRED: 0xc71585ff,
  41464. MIDNIGHTBLUE: 0x191970ff,
  41465. MINTCREAM: 0xf5fffaff,
  41466. MISTYROSE: 0xffe4e1ff,
  41467. MOCCASIN: 0xffe4b5ff,
  41468. NAVAJOWHITE: 0xffdeadff,
  41469. NAVY: 0x000080ff,
  41470. OLDLACE: 0xfdf5e6ff,
  41471. OLIVE: 0x808000ff,
  41472. OLIVEDRAB: 0x6b8e23ff,
  41473. ORANGE: 0xffa500ff,
  41474. ORANGERED: 0xff4500ff,
  41475. ORCHID: 0xda70d6ff,
  41476. PALEGOLDENROD: 0xeee8aaff,
  41477. PALEGREEN: 0x98fb98ff,
  41478. PALETURQUOISE: 0xafeeeeff,
  41479. PALEVIOLETRED: 0xdb7093ff,
  41480. PAPAYAWHIP: 0xffefd5ff,
  41481. PEACHPUFF: 0xffdab9ff,
  41482. PERU: 0xcd853fff,
  41483. PINK: 0xffc0cbff,
  41484. PLUM: 0xdda0ddff,
  41485. POWDERBLUE: 0xb0e0e6ff,
  41486. PURPLE: 0x800080ff,
  41487. REBECCAPURPLE: 0x663399ff,
  41488. RED: 0xff0000ff,
  41489. ROSYBROWN: 0xbc8f8fff,
  41490. ROYALBLUE: 0x4169e1ff,
  41491. SADDLEBROWN: 0x8b4513ff,
  41492. SALMON: 0xfa8072ff,
  41493. SANDYBROWN: 0xf4a460ff,
  41494. SEAGREEN: 0x2e8b57ff,
  41495. SEASHELL: 0xfff5eeff,
  41496. SIENNA: 0xa0522dff,
  41497. SILVER: 0xc0c0c0ff,
  41498. SKYBLUE: 0x87ceebff,
  41499. SLATEBLUE: 0x6a5acdff,
  41500. SLATEGRAY: 0x708090ff,
  41501. SLATEGREY: 0x708090ff,
  41502. SNOW: 0xfffafaff,
  41503. SPRINGGREEN: 0x00ff7fff,
  41504. STEELBLUE: 0x4682b4ff,
  41505. TAN: 0xd2b48cff,
  41506. TEAL: 0x008080ff,
  41507. THISTLE: 0xd8bfd8ff,
  41508. TOMATO: 0xff6347ff,
  41509. TRANSPARENT: 0x00000000,
  41510. TURQUOISE: 0x40e0d0ff,
  41511. VIOLET: 0xee82eeff,
  41512. WHEAT: 0xf5deb3ff,
  41513. WHITE: 0xffffffff,
  41514. WHITESMOKE: 0xf5f5f5ff,
  41515. YELLOW: 0xffff00ff,
  41516. YELLOWGREEN: 0x9acd32ff
  41517. };
  41518. var backgroundClip = {
  41519. name: 'background-clip',
  41520. initialValue: 'border-box',
  41521. prefix: false,
  41522. type: 1 /* LIST */,
  41523. parse: function (_context, tokens) {
  41524. return tokens.map(function (token) {
  41525. if (isIdentToken(token)) {
  41526. switch (token.value) {
  41527. case 'padding-box':
  41528. return 1 /* PADDING_BOX */;
  41529. case 'content-box':
  41530. return 2 /* CONTENT_BOX */;
  41531. }
  41532. }
  41533. return 0 /* BORDER_BOX */;
  41534. });
  41535. }
  41536. };
  41537. var backgroundColor = {
  41538. name: "background-color",
  41539. initialValue: 'transparent',
  41540. prefix: false,
  41541. type: 3 /* TYPE_VALUE */,
  41542. format: 'color'
  41543. };
  41544. var parseColorStop = function (context, args) {
  41545. var color = color$1.parse(context, args[0]);
  41546. var stop = args[1];
  41547. return stop && isLengthPercentage(stop) ? { color: color, stop: stop } : { color: color, stop: null };
  41548. };
  41549. var processColorStops = function (stops, lineLength) {
  41550. var first = stops[0];
  41551. var last = stops[stops.length - 1];
  41552. if (first.stop === null) {
  41553. first.stop = ZERO_LENGTH;
  41554. }
  41555. if (last.stop === null) {
  41556. last.stop = HUNDRED_PERCENT;
  41557. }
  41558. var processStops = [];
  41559. var previous = 0;
  41560. for (var i = 0; i < stops.length; i++) {
  41561. var stop_1 = stops[i].stop;
  41562. if (stop_1 !== null) {
  41563. var absoluteValue = getAbsoluteValue(stop_1, lineLength);
  41564. if (absoluteValue > previous) {
  41565. processStops.push(absoluteValue);
  41566. }
  41567. else {
  41568. processStops.push(previous);
  41569. }
  41570. previous = absoluteValue;
  41571. }
  41572. else {
  41573. processStops.push(null);
  41574. }
  41575. }
  41576. var gapBegin = null;
  41577. for (var i = 0; i < processStops.length; i++) {
  41578. var stop_2 = processStops[i];
  41579. if (stop_2 === null) {
  41580. if (gapBegin === null) {
  41581. gapBegin = i;
  41582. }
  41583. }
  41584. else if (gapBegin !== null) {
  41585. var gapLength = i - gapBegin;
  41586. var beforeGap = processStops[gapBegin - 1];
  41587. var gapValue = (stop_2 - beforeGap) / (gapLength + 1);
  41588. for (var g = 1; g <= gapLength; g++) {
  41589. processStops[gapBegin + g - 1] = gapValue * g;
  41590. }
  41591. gapBegin = null;
  41592. }
  41593. }
  41594. return stops.map(function (_a, i) {
  41595. var color = _a.color;
  41596. return { color: color, stop: Math.max(Math.min(1, processStops[i] / lineLength), 0) };
  41597. });
  41598. };
  41599. var getAngleFromCorner = function (corner, width, height) {
  41600. var centerX = width / 2;
  41601. var centerY = height / 2;
  41602. var x = getAbsoluteValue(corner[0], width) - centerX;
  41603. var y = centerY - getAbsoluteValue(corner[1], height);
  41604. return (Math.atan2(y, x) + Math.PI * 2) % (Math.PI * 2);
  41605. };
  41606. var calculateGradientDirection = function (angle, width, height) {
  41607. var radian = typeof angle === 'number' ? angle : getAngleFromCorner(angle, width, height);
  41608. var lineLength = Math.abs(width * Math.sin(radian)) + Math.abs(height * Math.cos(radian));
  41609. var halfWidth = width / 2;
  41610. var halfHeight = height / 2;
  41611. var halfLineLength = lineLength / 2;
  41612. var yDiff = Math.sin(radian - Math.PI / 2) * halfLineLength;
  41613. var xDiff = Math.cos(radian - Math.PI / 2) * halfLineLength;
  41614. return [lineLength, halfWidth - xDiff, halfWidth + xDiff, halfHeight - yDiff, halfHeight + yDiff];
  41615. };
  41616. var distance = function (a, b) { return Math.sqrt(a * a + b * b); };
  41617. var findCorner = function (width, height, x, y, closest) {
  41618. var corners = [
  41619. [0, 0],
  41620. [0, height],
  41621. [width, 0],
  41622. [width, height]
  41623. ];
  41624. return corners.reduce(function (stat, corner) {
  41625. var cx = corner[0], cy = corner[1];
  41626. var d = distance(x - cx, y - cy);
  41627. if (closest ? d < stat.optimumDistance : d > stat.optimumDistance) {
  41628. return {
  41629. optimumCorner: corner,
  41630. optimumDistance: d
  41631. };
  41632. }
  41633. return stat;
  41634. }, {
  41635. optimumDistance: closest ? Infinity : -Infinity,
  41636. optimumCorner: null
  41637. }).optimumCorner;
  41638. };
  41639. var calculateRadius = function (gradient, x, y, width, height) {
  41640. var rx = 0;
  41641. var ry = 0;
  41642. switch (gradient.size) {
  41643. case 0 /* CLOSEST_SIDE */:
  41644. // The ending shape is sized so that that it exactly meets the side of the gradient box closest to the gradient’s center.
  41645. // If the shape is an ellipse, it exactly meets the closest side in each dimension.
  41646. if (gradient.shape === 0 /* CIRCLE */) {
  41647. rx = ry = Math.min(Math.abs(x), Math.abs(x - width), Math.abs(y), Math.abs(y - height));
  41648. }
  41649. else if (gradient.shape === 1 /* ELLIPSE */) {
  41650. rx = Math.min(Math.abs(x), Math.abs(x - width));
  41651. ry = Math.min(Math.abs(y), Math.abs(y - height));
  41652. }
  41653. break;
  41654. case 2 /* CLOSEST_CORNER */:
  41655. // The ending shape is sized so that that it passes through the corner of the gradient box closest to the gradient’s center.
  41656. // If the shape is an ellipse, the ending shape is given the same aspect-ratio it would have if closest-side were specified.
  41657. if (gradient.shape === 0 /* CIRCLE */) {
  41658. rx = ry = Math.min(distance(x, y), distance(x, y - height), distance(x - width, y), distance(x - width, y - height));
  41659. }
  41660. else if (gradient.shape === 1 /* ELLIPSE */) {
  41661. // Compute the ratio ry/rx (which is to be the same as for "closest-side")
  41662. var c = Math.min(Math.abs(y), Math.abs(y - height)) / Math.min(Math.abs(x), Math.abs(x - width));
  41663. var _a = findCorner(width, height, x, y, true), cx = _a[0], cy = _a[1];
  41664. rx = distance(cx - x, (cy - y) / c);
  41665. ry = c * rx;
  41666. }
  41667. break;
  41668. case 1 /* FARTHEST_SIDE */:
  41669. // Same as closest-side, except the ending shape is sized based on the farthest side(s)
  41670. if (gradient.shape === 0 /* CIRCLE */) {
  41671. rx = ry = Math.max(Math.abs(x), Math.abs(x - width), Math.abs(y), Math.abs(y - height));
  41672. }
  41673. else if (gradient.shape === 1 /* ELLIPSE */) {
  41674. rx = Math.max(Math.abs(x), Math.abs(x - width));
  41675. ry = Math.max(Math.abs(y), Math.abs(y - height));
  41676. }
  41677. break;
  41678. case 3 /* FARTHEST_CORNER */:
  41679. // Same as closest-corner, except the ending shape is sized based on the farthest corner.
  41680. // If the shape is an ellipse, the ending shape is given the same aspect ratio it would have if farthest-side were specified.
  41681. if (gradient.shape === 0 /* CIRCLE */) {
  41682. rx = ry = Math.max(distance(x, y), distance(x, y - height), distance(x - width, y), distance(x - width, y - height));
  41683. }
  41684. else if (gradient.shape === 1 /* ELLIPSE */) {
  41685. // Compute the ratio ry/rx (which is to be the same as for "farthest-side")
  41686. var c = Math.max(Math.abs(y), Math.abs(y - height)) / Math.max(Math.abs(x), Math.abs(x - width));
  41687. var _b = findCorner(width, height, x, y, false), cx = _b[0], cy = _b[1];
  41688. rx = distance(cx - x, (cy - y) / c);
  41689. ry = c * rx;
  41690. }
  41691. break;
  41692. }
  41693. if (Array.isArray(gradient.size)) {
  41694. rx = getAbsoluteValue(gradient.size[0], width);
  41695. ry = gradient.size.length === 2 ? getAbsoluteValue(gradient.size[1], height) : rx;
  41696. }
  41697. return [rx, ry];
  41698. };
  41699. var linearGradient = function (context, tokens) {
  41700. var angle$1 = deg(180);
  41701. var stops = [];
  41702. parseFunctionArgs(tokens).forEach(function (arg, i) {
  41703. if (i === 0) {
  41704. var firstToken = arg[0];
  41705. if (firstToken.type === 20 /* IDENT_TOKEN */ && firstToken.value === 'to') {
  41706. angle$1 = parseNamedSide(arg);
  41707. return;
  41708. }
  41709. else if (isAngle(firstToken)) {
  41710. angle$1 = angle.parse(context, firstToken);
  41711. return;
  41712. }
  41713. }
  41714. var colorStop = parseColorStop(context, arg);
  41715. stops.push(colorStop);
  41716. });
  41717. return { angle: angle$1, stops: stops, type: 1 /* LINEAR_GRADIENT */ };
  41718. };
  41719. var prefixLinearGradient = function (context, tokens) {
  41720. var angle$1 = deg(180);
  41721. var stops = [];
  41722. parseFunctionArgs(tokens).forEach(function (arg, i) {
  41723. if (i === 0) {
  41724. var firstToken = arg[0];
  41725. if (firstToken.type === 20 /* IDENT_TOKEN */ &&
  41726. ['top', 'left', 'right', 'bottom'].indexOf(firstToken.value) !== -1) {
  41727. angle$1 = parseNamedSide(arg);
  41728. return;
  41729. }
  41730. else if (isAngle(firstToken)) {
  41731. angle$1 = (angle.parse(context, firstToken) + deg(270)) % deg(360);
  41732. return;
  41733. }
  41734. }
  41735. var colorStop = parseColorStop(context, arg);
  41736. stops.push(colorStop);
  41737. });
  41738. return {
  41739. angle: angle$1,
  41740. stops: stops,
  41741. type: 1 /* LINEAR_GRADIENT */
  41742. };
  41743. };
  41744. var webkitGradient = function (context, tokens) {
  41745. var angle = deg(180);
  41746. var stops = [];
  41747. var type = 1 /* LINEAR_GRADIENT */;
  41748. var shape = 0 /* CIRCLE */;
  41749. var size = 3 /* FARTHEST_CORNER */;
  41750. var position = [];
  41751. parseFunctionArgs(tokens).forEach(function (arg, i) {
  41752. var firstToken = arg[0];
  41753. if (i === 0) {
  41754. if (isIdentToken(firstToken) && firstToken.value === 'linear') {
  41755. type = 1 /* LINEAR_GRADIENT */;
  41756. return;
  41757. }
  41758. else if (isIdentToken(firstToken) && firstToken.value === 'radial') {
  41759. type = 2 /* RADIAL_GRADIENT */;
  41760. return;
  41761. }
  41762. }
  41763. if (firstToken.type === 18 /* FUNCTION */) {
  41764. if (firstToken.name === 'from') {
  41765. var color = color$1.parse(context, firstToken.values[0]);
  41766. stops.push({ stop: ZERO_LENGTH, color: color });
  41767. }
  41768. else if (firstToken.name === 'to') {
  41769. var color = color$1.parse(context, firstToken.values[0]);
  41770. stops.push({ stop: HUNDRED_PERCENT, color: color });
  41771. }
  41772. else if (firstToken.name === 'color-stop') {
  41773. var values = firstToken.values.filter(nonFunctionArgSeparator);
  41774. if (values.length === 2) {
  41775. var color = color$1.parse(context, values[1]);
  41776. var stop_1 = values[0];
  41777. if (isNumberToken(stop_1)) {
  41778. stops.push({
  41779. stop: { type: 16 /* PERCENTAGE_TOKEN */, number: stop_1.number * 100, flags: stop_1.flags },
  41780. color: color
  41781. });
  41782. }
  41783. }
  41784. }
  41785. }
  41786. });
  41787. return type === 1 /* LINEAR_GRADIENT */
  41788. ? {
  41789. angle: (angle + deg(180)) % deg(360),
  41790. stops: stops,
  41791. type: type
  41792. }
  41793. : { size: size, shape: shape, stops: stops, position: position, type: type };
  41794. };
  41795. var CLOSEST_SIDE = 'closest-side';
  41796. var FARTHEST_SIDE = 'farthest-side';
  41797. var CLOSEST_CORNER = 'closest-corner';
  41798. var FARTHEST_CORNER = 'farthest-corner';
  41799. var CIRCLE = 'circle';
  41800. var ELLIPSE = 'ellipse';
  41801. var COVER = 'cover';
  41802. var CONTAIN = 'contain';
  41803. var radialGradient = function (context, tokens) {
  41804. var shape = 0 /* CIRCLE */;
  41805. var size = 3 /* FARTHEST_CORNER */;
  41806. var stops = [];
  41807. var position = [];
  41808. parseFunctionArgs(tokens).forEach(function (arg, i) {
  41809. var isColorStop = true;
  41810. if (i === 0) {
  41811. var isAtPosition_1 = false;
  41812. isColorStop = arg.reduce(function (acc, token) {
  41813. if (isAtPosition_1) {
  41814. if (isIdentToken(token)) {
  41815. switch (token.value) {
  41816. case 'center':
  41817. position.push(FIFTY_PERCENT);
  41818. return acc;
  41819. case 'top':
  41820. case 'left':
  41821. position.push(ZERO_LENGTH);
  41822. return acc;
  41823. case 'right':
  41824. case 'bottom':
  41825. position.push(HUNDRED_PERCENT);
  41826. return acc;
  41827. }
  41828. }
  41829. else if (isLengthPercentage(token) || isLength(token)) {
  41830. position.push(token);
  41831. }
  41832. }
  41833. else if (isIdentToken(token)) {
  41834. switch (token.value) {
  41835. case CIRCLE:
  41836. shape = 0 /* CIRCLE */;
  41837. return false;
  41838. case ELLIPSE:
  41839. shape = 1 /* ELLIPSE */;
  41840. return false;
  41841. case 'at':
  41842. isAtPosition_1 = true;
  41843. return false;
  41844. case CLOSEST_SIDE:
  41845. size = 0 /* CLOSEST_SIDE */;
  41846. return false;
  41847. case COVER:
  41848. case FARTHEST_SIDE:
  41849. size = 1 /* FARTHEST_SIDE */;
  41850. return false;
  41851. case CONTAIN:
  41852. case CLOSEST_CORNER:
  41853. size = 2 /* CLOSEST_CORNER */;
  41854. return false;
  41855. case FARTHEST_CORNER:
  41856. size = 3 /* FARTHEST_CORNER */;
  41857. return false;
  41858. }
  41859. }
  41860. else if (isLength(token) || isLengthPercentage(token)) {
  41861. if (!Array.isArray(size)) {
  41862. size = [];
  41863. }
  41864. size.push(token);
  41865. return false;
  41866. }
  41867. return acc;
  41868. }, isColorStop);
  41869. }
  41870. if (isColorStop) {
  41871. var colorStop = parseColorStop(context, arg);
  41872. stops.push(colorStop);
  41873. }
  41874. });
  41875. return { size: size, shape: shape, stops: stops, position: position, type: 2 /* RADIAL_GRADIENT */ };
  41876. };
  41877. var prefixRadialGradient = function (context, tokens) {
  41878. var shape = 0 /* CIRCLE */;
  41879. var size = 3 /* FARTHEST_CORNER */;
  41880. var stops = [];
  41881. var position = [];
  41882. parseFunctionArgs(tokens).forEach(function (arg, i) {
  41883. var isColorStop = true;
  41884. if (i === 0) {
  41885. isColorStop = arg.reduce(function (acc, token) {
  41886. if (isIdentToken(token)) {
  41887. switch (token.value) {
  41888. case 'center':
  41889. position.push(FIFTY_PERCENT);
  41890. return false;
  41891. case 'top':
  41892. case 'left':
  41893. position.push(ZERO_LENGTH);
  41894. return false;
  41895. case 'right':
  41896. case 'bottom':
  41897. position.push(HUNDRED_PERCENT);
  41898. return false;
  41899. }
  41900. }
  41901. else if (isLengthPercentage(token) || isLength(token)) {
  41902. position.push(token);
  41903. return false;
  41904. }
  41905. return acc;
  41906. }, isColorStop);
  41907. }
  41908. else if (i === 1) {
  41909. isColorStop = arg.reduce(function (acc, token) {
  41910. if (isIdentToken(token)) {
  41911. switch (token.value) {
  41912. case CIRCLE:
  41913. shape = 0 /* CIRCLE */;
  41914. return false;
  41915. case ELLIPSE:
  41916. shape = 1 /* ELLIPSE */;
  41917. return false;
  41918. case CONTAIN:
  41919. case CLOSEST_SIDE:
  41920. size = 0 /* CLOSEST_SIDE */;
  41921. return false;
  41922. case FARTHEST_SIDE:
  41923. size = 1 /* FARTHEST_SIDE */;
  41924. return false;
  41925. case CLOSEST_CORNER:
  41926. size = 2 /* CLOSEST_CORNER */;
  41927. return false;
  41928. case COVER:
  41929. case FARTHEST_CORNER:
  41930. size = 3 /* FARTHEST_CORNER */;
  41931. return false;
  41932. }
  41933. }
  41934. else if (isLength(token) || isLengthPercentage(token)) {
  41935. if (!Array.isArray(size)) {
  41936. size = [];
  41937. }
  41938. size.push(token);
  41939. return false;
  41940. }
  41941. return acc;
  41942. }, isColorStop);
  41943. }
  41944. if (isColorStop) {
  41945. var colorStop = parseColorStop(context, arg);
  41946. stops.push(colorStop);
  41947. }
  41948. });
  41949. return { size: size, shape: shape, stops: stops, position: position, type: 2 /* RADIAL_GRADIENT */ };
  41950. };
  41951. var isLinearGradient = function (background) {
  41952. return background.type === 1 /* LINEAR_GRADIENT */;
  41953. };
  41954. var isRadialGradient = function (background) {
  41955. return background.type === 2 /* RADIAL_GRADIENT */;
  41956. };
  41957. var image = {
  41958. name: 'image',
  41959. parse: function (context, value) {
  41960. if (value.type === 22 /* URL_TOKEN */) {
  41961. var image_1 = { url: value.value, type: 0 /* URL */ };
  41962. context.cache.addImage(value.value);
  41963. return image_1;
  41964. }
  41965. if (value.type === 18 /* FUNCTION */) {
  41966. var imageFunction = SUPPORTED_IMAGE_FUNCTIONS[value.name];
  41967. if (typeof imageFunction === 'undefined') {
  41968. throw new Error("Attempting to parse an unsupported image function \"" + value.name + "\"");
  41969. }
  41970. return imageFunction(context, value.values);
  41971. }
  41972. throw new Error("Unsupported image type " + value.type);
  41973. }
  41974. };
  41975. function isSupportedImage(value) {
  41976. return (!(value.type === 20 /* IDENT_TOKEN */ && value.value === 'none') &&
  41977. (value.type !== 18 /* FUNCTION */ || !!SUPPORTED_IMAGE_FUNCTIONS[value.name]));
  41978. }
  41979. var SUPPORTED_IMAGE_FUNCTIONS = {
  41980. 'linear-gradient': linearGradient,
  41981. '-moz-linear-gradient': prefixLinearGradient,
  41982. '-ms-linear-gradient': prefixLinearGradient,
  41983. '-o-linear-gradient': prefixLinearGradient,
  41984. '-webkit-linear-gradient': prefixLinearGradient,
  41985. 'radial-gradient': radialGradient,
  41986. '-moz-radial-gradient': prefixRadialGradient,
  41987. '-ms-radial-gradient': prefixRadialGradient,
  41988. '-o-radial-gradient': prefixRadialGradient,
  41989. '-webkit-radial-gradient': prefixRadialGradient,
  41990. '-webkit-gradient': webkitGradient
  41991. };
  41992. var backgroundImage = {
  41993. name: 'background-image',
  41994. initialValue: 'none',
  41995. type: 1 /* LIST */,
  41996. prefix: false,
  41997. parse: function (context, tokens) {
  41998. if (tokens.length === 0) {
  41999. return [];
  42000. }
  42001. var first = tokens[0];
  42002. if (first.type === 20 /* IDENT_TOKEN */ && first.value === 'none') {
  42003. return [];
  42004. }
  42005. return tokens
  42006. .filter(function (value) { return nonFunctionArgSeparator(value) && isSupportedImage(value); })
  42007. .map(function (value) { return image.parse(context, value); });
  42008. }
  42009. };
  42010. var backgroundOrigin = {
  42011. name: 'background-origin',
  42012. initialValue: 'border-box',
  42013. prefix: false,
  42014. type: 1 /* LIST */,
  42015. parse: function (_context, tokens) {
  42016. return tokens.map(function (token) {
  42017. if (isIdentToken(token)) {
  42018. switch (token.value) {
  42019. case 'padding-box':
  42020. return 1 /* PADDING_BOX */;
  42021. case 'content-box':
  42022. return 2 /* CONTENT_BOX */;
  42023. }
  42024. }
  42025. return 0 /* BORDER_BOX */;
  42026. });
  42027. }
  42028. };
  42029. var backgroundPosition = {
  42030. name: 'background-position',
  42031. initialValue: '0% 0%',
  42032. type: 1 /* LIST */,
  42033. prefix: false,
  42034. parse: function (_context, tokens) {
  42035. return parseFunctionArgs(tokens)
  42036. .map(function (values) { return values.filter(isLengthPercentage); })
  42037. .map(parseLengthPercentageTuple);
  42038. }
  42039. };
  42040. var backgroundRepeat = {
  42041. name: 'background-repeat',
  42042. initialValue: 'repeat',
  42043. prefix: false,
  42044. type: 1 /* LIST */,
  42045. parse: function (_context, tokens) {
  42046. return parseFunctionArgs(tokens)
  42047. .map(function (values) {
  42048. return values
  42049. .filter(isIdentToken)
  42050. .map(function (token) { return token.value; })
  42051. .join(' ');
  42052. })
  42053. .map(parseBackgroundRepeat);
  42054. }
  42055. };
  42056. var parseBackgroundRepeat = function (value) {
  42057. switch (value) {
  42058. case 'no-repeat':
  42059. return 1 /* NO_REPEAT */;
  42060. case 'repeat-x':
  42061. case 'repeat no-repeat':
  42062. return 2 /* REPEAT_X */;
  42063. case 'repeat-y':
  42064. case 'no-repeat repeat':
  42065. return 3 /* REPEAT_Y */;
  42066. case 'repeat':
  42067. default:
  42068. return 0 /* REPEAT */;
  42069. }
  42070. };
  42071. var BACKGROUND_SIZE;
  42072. (function (BACKGROUND_SIZE) {
  42073. BACKGROUND_SIZE["AUTO"] = "auto";
  42074. BACKGROUND_SIZE["CONTAIN"] = "contain";
  42075. BACKGROUND_SIZE["COVER"] = "cover";
  42076. })(BACKGROUND_SIZE || (BACKGROUND_SIZE = {}));
  42077. var backgroundSize = {
  42078. name: 'background-size',
  42079. initialValue: '0',
  42080. prefix: false,
  42081. type: 1 /* LIST */,
  42082. parse: function (_context, tokens) {
  42083. return parseFunctionArgs(tokens).map(function (values) { return values.filter(isBackgroundSizeInfoToken); });
  42084. }
  42085. };
  42086. var isBackgroundSizeInfoToken = function (value) {
  42087. return isIdentToken(value) || isLengthPercentage(value);
  42088. };
  42089. var borderColorForSide = function (side) { return ({
  42090. name: "border-" + side + "-color",
  42091. initialValue: 'transparent',
  42092. prefix: false,
  42093. type: 3 /* TYPE_VALUE */,
  42094. format: 'color'
  42095. }); };
  42096. var borderTopColor = borderColorForSide('top');
  42097. var borderRightColor = borderColorForSide('right');
  42098. var borderBottomColor = borderColorForSide('bottom');
  42099. var borderLeftColor = borderColorForSide('left');
  42100. var borderRadiusForSide = function (side) { return ({
  42101. name: "border-radius-" + side,
  42102. initialValue: '0 0',
  42103. prefix: false,
  42104. type: 1 /* LIST */,
  42105. parse: function (_context, tokens) {
  42106. return parseLengthPercentageTuple(tokens.filter(isLengthPercentage));
  42107. }
  42108. }); };
  42109. var borderTopLeftRadius = borderRadiusForSide('top-left');
  42110. var borderTopRightRadius = borderRadiusForSide('top-right');
  42111. var borderBottomRightRadius = borderRadiusForSide('bottom-right');
  42112. var borderBottomLeftRadius = borderRadiusForSide('bottom-left');
  42113. var borderStyleForSide = function (side) { return ({
  42114. name: "border-" + side + "-style",
  42115. initialValue: 'solid',
  42116. prefix: false,
  42117. type: 2 /* IDENT_VALUE */,
  42118. parse: function (_context, style) {
  42119. switch (style) {
  42120. case 'none':
  42121. return 0 /* NONE */;
  42122. case 'dashed':
  42123. return 2 /* DASHED */;
  42124. case 'dotted':
  42125. return 3 /* DOTTED */;
  42126. case 'double':
  42127. return 4 /* DOUBLE */;
  42128. }
  42129. return 1 /* SOLID */;
  42130. }
  42131. }); };
  42132. var borderTopStyle = borderStyleForSide('top');
  42133. var borderRightStyle = borderStyleForSide('right');
  42134. var borderBottomStyle = borderStyleForSide('bottom');
  42135. var borderLeftStyle = borderStyleForSide('left');
  42136. var borderWidthForSide = function (side) { return ({
  42137. name: "border-" + side + "-width",
  42138. initialValue: '0',
  42139. type: 0 /* VALUE */,
  42140. prefix: false,
  42141. parse: function (_context, token) {
  42142. if (isDimensionToken(token)) {
  42143. return token.number;
  42144. }
  42145. return 0;
  42146. }
  42147. }); };
  42148. var borderTopWidth = borderWidthForSide('top');
  42149. var borderRightWidth = borderWidthForSide('right');
  42150. var borderBottomWidth = borderWidthForSide('bottom');
  42151. var borderLeftWidth = borderWidthForSide('left');
  42152. var color = {
  42153. name: "color",
  42154. initialValue: 'transparent',
  42155. prefix: false,
  42156. type: 3 /* TYPE_VALUE */,
  42157. format: 'color'
  42158. };
  42159. var direction = {
  42160. name: 'direction',
  42161. initialValue: 'ltr',
  42162. prefix: false,
  42163. type: 2 /* IDENT_VALUE */,
  42164. parse: function (_context, direction) {
  42165. switch (direction) {
  42166. case 'rtl':
  42167. return 1 /* RTL */;
  42168. case 'ltr':
  42169. default:
  42170. return 0 /* LTR */;
  42171. }
  42172. }
  42173. };
  42174. var display = {
  42175. name: 'display',
  42176. initialValue: 'inline-block',
  42177. prefix: false,
  42178. type: 1 /* LIST */,
  42179. parse: function (_context, tokens) {
  42180. return tokens.filter(isIdentToken).reduce(function (bit, token) {
  42181. return bit | parseDisplayValue(token.value);
  42182. }, 0 /* NONE */);
  42183. }
  42184. };
  42185. var parseDisplayValue = function (display) {
  42186. switch (display) {
  42187. case 'block':
  42188. case '-webkit-box':
  42189. return 2 /* BLOCK */;
  42190. case 'inline':
  42191. return 4 /* INLINE */;
  42192. case 'run-in':
  42193. return 8 /* RUN_IN */;
  42194. case 'flow':
  42195. return 16 /* FLOW */;
  42196. case 'flow-root':
  42197. return 32 /* FLOW_ROOT */;
  42198. case 'table':
  42199. return 64 /* TABLE */;
  42200. case 'flex':
  42201. case '-webkit-flex':
  42202. return 128 /* FLEX */;
  42203. case 'grid':
  42204. case '-ms-grid':
  42205. return 256 /* GRID */;
  42206. case 'ruby':
  42207. return 512 /* RUBY */;
  42208. case 'subgrid':
  42209. return 1024 /* SUBGRID */;
  42210. case 'list-item':
  42211. return 2048 /* LIST_ITEM */;
  42212. case 'table-row-group':
  42213. return 4096 /* TABLE_ROW_GROUP */;
  42214. case 'table-header-group':
  42215. return 8192 /* TABLE_HEADER_GROUP */;
  42216. case 'table-footer-group':
  42217. return 16384 /* TABLE_FOOTER_GROUP */;
  42218. case 'table-row':
  42219. return 32768 /* TABLE_ROW */;
  42220. case 'table-cell':
  42221. return 65536 /* TABLE_CELL */;
  42222. case 'table-column-group':
  42223. return 131072 /* TABLE_COLUMN_GROUP */;
  42224. case 'table-column':
  42225. return 262144 /* TABLE_COLUMN */;
  42226. case 'table-caption':
  42227. return 524288 /* TABLE_CAPTION */;
  42228. case 'ruby-base':
  42229. return 1048576 /* RUBY_BASE */;
  42230. case 'ruby-text':
  42231. return 2097152 /* RUBY_TEXT */;
  42232. case 'ruby-base-container':
  42233. return 4194304 /* RUBY_BASE_CONTAINER */;
  42234. case 'ruby-text-container':
  42235. return 8388608 /* RUBY_TEXT_CONTAINER */;
  42236. case 'contents':
  42237. return 16777216 /* CONTENTS */;
  42238. case 'inline-block':
  42239. return 33554432 /* INLINE_BLOCK */;
  42240. case 'inline-list-item':
  42241. return 67108864 /* INLINE_LIST_ITEM */;
  42242. case 'inline-table':
  42243. return 134217728 /* INLINE_TABLE */;
  42244. case 'inline-flex':
  42245. return 268435456 /* INLINE_FLEX */;
  42246. case 'inline-grid':
  42247. return 536870912 /* INLINE_GRID */;
  42248. }
  42249. return 0 /* NONE */;
  42250. };
  42251. var float = {
  42252. name: 'float',
  42253. initialValue: 'none',
  42254. prefix: false,
  42255. type: 2 /* IDENT_VALUE */,
  42256. parse: function (_context, float) {
  42257. switch (float) {
  42258. case 'left':
  42259. return 1 /* LEFT */;
  42260. case 'right':
  42261. return 2 /* RIGHT */;
  42262. case 'inline-start':
  42263. return 3 /* INLINE_START */;
  42264. case 'inline-end':
  42265. return 4 /* INLINE_END */;
  42266. }
  42267. return 0 /* NONE */;
  42268. }
  42269. };
  42270. var letterSpacing = {
  42271. name: 'letter-spacing',
  42272. initialValue: '0',
  42273. prefix: false,
  42274. type: 0 /* VALUE */,
  42275. parse: function (_context, token) {
  42276. if (token.type === 20 /* IDENT_TOKEN */ && token.value === 'normal') {
  42277. return 0;
  42278. }
  42279. if (token.type === 17 /* NUMBER_TOKEN */) {
  42280. return token.number;
  42281. }
  42282. if (token.type === 15 /* DIMENSION_TOKEN */) {
  42283. return token.number;
  42284. }
  42285. return 0;
  42286. }
  42287. };
  42288. var LINE_BREAK;
  42289. (function (LINE_BREAK) {
  42290. LINE_BREAK["NORMAL"] = "normal";
  42291. LINE_BREAK["STRICT"] = "strict";
  42292. })(LINE_BREAK || (LINE_BREAK = {}));
  42293. var lineBreak = {
  42294. name: 'line-break',
  42295. initialValue: 'normal',
  42296. prefix: false,
  42297. type: 2 /* IDENT_VALUE */,
  42298. parse: function (_context, lineBreak) {
  42299. switch (lineBreak) {
  42300. case 'strict':
  42301. return LINE_BREAK.STRICT;
  42302. case 'normal':
  42303. default:
  42304. return LINE_BREAK.NORMAL;
  42305. }
  42306. }
  42307. };
  42308. var lineHeight = {
  42309. name: 'line-height',
  42310. initialValue: 'normal',
  42311. prefix: false,
  42312. type: 4 /* TOKEN_VALUE */
  42313. };
  42314. var computeLineHeight = function (token, fontSize) {
  42315. if (isIdentToken(token) && token.value === 'normal') {
  42316. return 1.2 * fontSize;
  42317. }
  42318. else if (token.type === 17 /* NUMBER_TOKEN */) {
  42319. return fontSize * token.number;
  42320. }
  42321. else if (isLengthPercentage(token)) {
  42322. return getAbsoluteValue(token, fontSize);
  42323. }
  42324. return fontSize;
  42325. };
  42326. var listStyleImage = {
  42327. name: 'list-style-image',
  42328. initialValue: 'none',
  42329. type: 0 /* VALUE */,
  42330. prefix: false,
  42331. parse: function (context, token) {
  42332. if (token.type === 20 /* IDENT_TOKEN */ && token.value === 'none') {
  42333. return null;
  42334. }
  42335. return image.parse(context, token);
  42336. }
  42337. };
  42338. var listStylePosition = {
  42339. name: 'list-style-position',
  42340. initialValue: 'outside',
  42341. prefix: false,
  42342. type: 2 /* IDENT_VALUE */,
  42343. parse: function (_context, position) {
  42344. switch (position) {
  42345. case 'inside':
  42346. return 0 /* INSIDE */;
  42347. case 'outside':
  42348. default:
  42349. return 1 /* OUTSIDE */;
  42350. }
  42351. }
  42352. };
  42353. var listStyleType = {
  42354. name: 'list-style-type',
  42355. initialValue: 'none',
  42356. prefix: false,
  42357. type: 2 /* IDENT_VALUE */,
  42358. parse: function (_context, type) {
  42359. switch (type) {
  42360. case 'disc':
  42361. return 0 /* DISC */;
  42362. case 'circle':
  42363. return 1 /* CIRCLE */;
  42364. case 'square':
  42365. return 2 /* SQUARE */;
  42366. case 'decimal':
  42367. return 3 /* DECIMAL */;
  42368. case 'cjk-decimal':
  42369. return 4 /* CJK_DECIMAL */;
  42370. case 'decimal-leading-zero':
  42371. return 5 /* DECIMAL_LEADING_ZERO */;
  42372. case 'lower-roman':
  42373. return 6 /* LOWER_ROMAN */;
  42374. case 'upper-roman':
  42375. return 7 /* UPPER_ROMAN */;
  42376. case 'lower-greek':
  42377. return 8 /* LOWER_GREEK */;
  42378. case 'lower-alpha':
  42379. return 9 /* LOWER_ALPHA */;
  42380. case 'upper-alpha':
  42381. return 10 /* UPPER_ALPHA */;
  42382. case 'arabic-indic':
  42383. return 11 /* ARABIC_INDIC */;
  42384. case 'armenian':
  42385. return 12 /* ARMENIAN */;
  42386. case 'bengali':
  42387. return 13 /* BENGALI */;
  42388. case 'cambodian':
  42389. return 14 /* CAMBODIAN */;
  42390. case 'cjk-earthly-branch':
  42391. return 15 /* CJK_EARTHLY_BRANCH */;
  42392. case 'cjk-heavenly-stem':
  42393. return 16 /* CJK_HEAVENLY_STEM */;
  42394. case 'cjk-ideographic':
  42395. return 17 /* CJK_IDEOGRAPHIC */;
  42396. case 'devanagari':
  42397. return 18 /* DEVANAGARI */;
  42398. case 'ethiopic-numeric':
  42399. return 19 /* ETHIOPIC_NUMERIC */;
  42400. case 'georgian':
  42401. return 20 /* GEORGIAN */;
  42402. case 'gujarati':
  42403. return 21 /* GUJARATI */;
  42404. case 'gurmukhi':
  42405. return 22 /* GURMUKHI */;
  42406. case 'hebrew':
  42407. return 22 /* HEBREW */;
  42408. case 'hiragana':
  42409. return 23 /* HIRAGANA */;
  42410. case 'hiragana-iroha':
  42411. return 24 /* HIRAGANA_IROHA */;
  42412. case 'japanese-formal':
  42413. return 25 /* JAPANESE_FORMAL */;
  42414. case 'japanese-informal':
  42415. return 26 /* JAPANESE_INFORMAL */;
  42416. case 'kannada':
  42417. return 27 /* KANNADA */;
  42418. case 'katakana':
  42419. return 28 /* KATAKANA */;
  42420. case 'katakana-iroha':
  42421. return 29 /* KATAKANA_IROHA */;
  42422. case 'khmer':
  42423. return 30 /* KHMER */;
  42424. case 'korean-hangul-formal':
  42425. return 31 /* KOREAN_HANGUL_FORMAL */;
  42426. case 'korean-hanja-formal':
  42427. return 32 /* KOREAN_HANJA_FORMAL */;
  42428. case 'korean-hanja-informal':
  42429. return 33 /* KOREAN_HANJA_INFORMAL */;
  42430. case 'lao':
  42431. return 34 /* LAO */;
  42432. case 'lower-armenian':
  42433. return 35 /* LOWER_ARMENIAN */;
  42434. case 'malayalam':
  42435. return 36 /* MALAYALAM */;
  42436. case 'mongolian':
  42437. return 37 /* MONGOLIAN */;
  42438. case 'myanmar':
  42439. return 38 /* MYANMAR */;
  42440. case 'oriya':
  42441. return 39 /* ORIYA */;
  42442. case 'persian':
  42443. return 40 /* PERSIAN */;
  42444. case 'simp-chinese-formal':
  42445. return 41 /* SIMP_CHINESE_FORMAL */;
  42446. case 'simp-chinese-informal':
  42447. return 42 /* SIMP_CHINESE_INFORMAL */;
  42448. case 'tamil':
  42449. return 43 /* TAMIL */;
  42450. case 'telugu':
  42451. return 44 /* TELUGU */;
  42452. case 'thai':
  42453. return 45 /* THAI */;
  42454. case 'tibetan':
  42455. return 46 /* TIBETAN */;
  42456. case 'trad-chinese-formal':
  42457. return 47 /* TRAD_CHINESE_FORMAL */;
  42458. case 'trad-chinese-informal':
  42459. return 48 /* TRAD_CHINESE_INFORMAL */;
  42460. case 'upper-armenian':
  42461. return 49 /* UPPER_ARMENIAN */;
  42462. case 'disclosure-open':
  42463. return 50 /* DISCLOSURE_OPEN */;
  42464. case 'disclosure-closed':
  42465. return 51 /* DISCLOSURE_CLOSED */;
  42466. case 'none':
  42467. default:
  42468. return -1 /* NONE */;
  42469. }
  42470. }
  42471. };
  42472. var marginForSide = function (side) { return ({
  42473. name: "margin-" + side,
  42474. initialValue: '0',
  42475. prefix: false,
  42476. type: 4 /* TOKEN_VALUE */
  42477. }); };
  42478. var marginTop = marginForSide('top');
  42479. var marginRight = marginForSide('right');
  42480. var marginBottom = marginForSide('bottom');
  42481. var marginLeft = marginForSide('left');
  42482. var overflow = {
  42483. name: 'overflow',
  42484. initialValue: 'visible',
  42485. prefix: false,
  42486. type: 1 /* LIST */,
  42487. parse: function (_context, tokens) {
  42488. return tokens.filter(isIdentToken).map(function (overflow) {
  42489. switch (overflow.value) {
  42490. case 'hidden':
  42491. return 1 /* HIDDEN */;
  42492. case 'scroll':
  42493. return 2 /* SCROLL */;
  42494. case 'clip':
  42495. return 3 /* CLIP */;
  42496. case 'auto':
  42497. return 4 /* AUTO */;
  42498. case 'visible':
  42499. default:
  42500. return 0 /* VISIBLE */;
  42501. }
  42502. });
  42503. }
  42504. };
  42505. var overflowWrap = {
  42506. name: 'overflow-wrap',
  42507. initialValue: 'normal',
  42508. prefix: false,
  42509. type: 2 /* IDENT_VALUE */,
  42510. parse: function (_context, overflow) {
  42511. switch (overflow) {
  42512. case 'break-word':
  42513. return "break-word" /* BREAK_WORD */;
  42514. case 'normal':
  42515. default:
  42516. return "normal" /* NORMAL */;
  42517. }
  42518. }
  42519. };
  42520. var paddingForSide = function (side) { return ({
  42521. name: "padding-" + side,
  42522. initialValue: '0',
  42523. prefix: false,
  42524. type: 3 /* TYPE_VALUE */,
  42525. format: 'length-percentage'
  42526. }); };
  42527. var paddingTop = paddingForSide('top');
  42528. var paddingRight = paddingForSide('right');
  42529. var paddingBottom = paddingForSide('bottom');
  42530. var paddingLeft = paddingForSide('left');
  42531. var textAlign = {
  42532. name: 'text-align',
  42533. initialValue: 'left',
  42534. prefix: false,
  42535. type: 2 /* IDENT_VALUE */,
  42536. parse: function (_context, textAlign) {
  42537. switch (textAlign) {
  42538. case 'right':
  42539. return 2 /* RIGHT */;
  42540. case 'center':
  42541. case 'justify':
  42542. return 1 /* CENTER */;
  42543. case 'left':
  42544. default:
  42545. return 0 /* LEFT */;
  42546. }
  42547. }
  42548. };
  42549. var position = {
  42550. name: 'position',
  42551. initialValue: 'static',
  42552. prefix: false,
  42553. type: 2 /* IDENT_VALUE */,
  42554. parse: function (_context, position) {
  42555. switch (position) {
  42556. case 'relative':
  42557. return 1 /* RELATIVE */;
  42558. case 'absolute':
  42559. return 2 /* ABSOLUTE */;
  42560. case 'fixed':
  42561. return 3 /* FIXED */;
  42562. case 'sticky':
  42563. return 4 /* STICKY */;
  42564. }
  42565. return 0 /* STATIC */;
  42566. }
  42567. };
  42568. var textShadow = {
  42569. name: 'text-shadow',
  42570. initialValue: 'none',
  42571. type: 1 /* LIST */,
  42572. prefix: false,
  42573. parse: function (context, tokens) {
  42574. if (tokens.length === 1 && isIdentWithValue(tokens[0], 'none')) {
  42575. return [];
  42576. }
  42577. return parseFunctionArgs(tokens).map(function (values) {
  42578. var shadow = {
  42579. color: COLORS.TRANSPARENT,
  42580. offsetX: ZERO_LENGTH,
  42581. offsetY: ZERO_LENGTH,
  42582. blur: ZERO_LENGTH
  42583. };
  42584. var c = 0;
  42585. for (var i = 0; i < values.length; i++) {
  42586. var token = values[i];
  42587. if (isLength(token)) {
  42588. if (c === 0) {
  42589. shadow.offsetX = token;
  42590. }
  42591. else if (c === 1) {
  42592. shadow.offsetY = token;
  42593. }
  42594. else {
  42595. shadow.blur = token;
  42596. }
  42597. c++;
  42598. }
  42599. else {
  42600. shadow.color = color$1.parse(context, token);
  42601. }
  42602. }
  42603. return shadow;
  42604. });
  42605. }
  42606. };
  42607. var textTransform = {
  42608. name: 'text-transform',
  42609. initialValue: 'none',
  42610. prefix: false,
  42611. type: 2 /* IDENT_VALUE */,
  42612. parse: function (_context, textTransform) {
  42613. switch (textTransform) {
  42614. case 'uppercase':
  42615. return 2 /* UPPERCASE */;
  42616. case 'lowercase':
  42617. return 1 /* LOWERCASE */;
  42618. case 'capitalize':
  42619. return 3 /* CAPITALIZE */;
  42620. }
  42621. return 0 /* NONE */;
  42622. }
  42623. };
  42624. var transform$1 = {
  42625. name: 'transform',
  42626. initialValue: 'none',
  42627. prefix: true,
  42628. type: 0 /* VALUE */,
  42629. parse: function (_context, token) {
  42630. if (token.type === 20 /* IDENT_TOKEN */ && token.value === 'none') {
  42631. return null;
  42632. }
  42633. if (token.type === 18 /* FUNCTION */) {
  42634. var transformFunction = SUPPORTED_TRANSFORM_FUNCTIONS[token.name];
  42635. if (typeof transformFunction === 'undefined') {
  42636. throw new Error("Attempting to parse an unsupported transform function \"" + token.name + "\"");
  42637. }
  42638. return transformFunction(token.values);
  42639. }
  42640. return null;
  42641. }
  42642. };
  42643. var matrix = function (args) {
  42644. var values = args.filter(function (arg) { return arg.type === 17 /* NUMBER_TOKEN */; }).map(function (arg) { return arg.number; });
  42645. return values.length === 6 ? values : null;
  42646. };
  42647. // doesn't support 3D transforms at the moment
  42648. var matrix3d = function (args) {
  42649. var values = args.filter(function (arg) { return arg.type === 17 /* NUMBER_TOKEN */; }).map(function (arg) { return arg.number; });
  42650. var a1 = values[0], b1 = values[1]; values[2]; values[3]; var a2 = values[4], b2 = values[5]; values[6]; values[7]; values[8]; values[9]; values[10]; values[11]; var a4 = values[12], b4 = values[13]; values[14]; values[15];
  42651. return values.length === 16 ? [a1, b1, a2, b2, a4, b4] : null;
  42652. };
  42653. var SUPPORTED_TRANSFORM_FUNCTIONS = {
  42654. matrix: matrix,
  42655. matrix3d: matrix3d
  42656. };
  42657. var DEFAULT_VALUE = {
  42658. type: 16 /* PERCENTAGE_TOKEN */,
  42659. number: 50,
  42660. flags: FLAG_INTEGER
  42661. };
  42662. var DEFAULT = [DEFAULT_VALUE, DEFAULT_VALUE];
  42663. var transformOrigin = {
  42664. name: 'transform-origin',
  42665. initialValue: '50% 50%',
  42666. prefix: true,
  42667. type: 1 /* LIST */,
  42668. parse: function (_context, tokens) {
  42669. var origins = tokens.filter(isLengthPercentage);
  42670. if (origins.length !== 2) {
  42671. return DEFAULT;
  42672. }
  42673. return [origins[0], origins[1]];
  42674. }
  42675. };
  42676. var visibility = {
  42677. name: 'visible',
  42678. initialValue: 'none',
  42679. prefix: false,
  42680. type: 2 /* IDENT_VALUE */,
  42681. parse: function (_context, visibility) {
  42682. switch (visibility) {
  42683. case 'hidden':
  42684. return 1 /* HIDDEN */;
  42685. case 'collapse':
  42686. return 2 /* COLLAPSE */;
  42687. case 'visible':
  42688. default:
  42689. return 0 /* VISIBLE */;
  42690. }
  42691. }
  42692. };
  42693. var WORD_BREAK;
  42694. (function (WORD_BREAK) {
  42695. WORD_BREAK["NORMAL"] = "normal";
  42696. WORD_BREAK["BREAK_ALL"] = "break-all";
  42697. WORD_BREAK["KEEP_ALL"] = "keep-all";
  42698. })(WORD_BREAK || (WORD_BREAK = {}));
  42699. var wordBreak = {
  42700. name: 'word-break',
  42701. initialValue: 'normal',
  42702. prefix: false,
  42703. type: 2 /* IDENT_VALUE */,
  42704. parse: function (_context, wordBreak) {
  42705. switch (wordBreak) {
  42706. case 'break-all':
  42707. return WORD_BREAK.BREAK_ALL;
  42708. case 'keep-all':
  42709. return WORD_BREAK.KEEP_ALL;
  42710. case 'normal':
  42711. default:
  42712. return WORD_BREAK.NORMAL;
  42713. }
  42714. }
  42715. };
  42716. var zIndex = {
  42717. name: 'z-index',
  42718. initialValue: 'auto',
  42719. prefix: false,
  42720. type: 0 /* VALUE */,
  42721. parse: function (_context, token) {
  42722. if (token.type === 20 /* IDENT_TOKEN */) {
  42723. return { auto: true, order: 0 };
  42724. }
  42725. if (isNumberToken(token)) {
  42726. return { auto: false, order: token.number };
  42727. }
  42728. throw new Error("Invalid z-index number parsed");
  42729. }
  42730. };
  42731. var time = {
  42732. name: 'time',
  42733. parse: function (_context, value) {
  42734. if (value.type === 15 /* DIMENSION_TOKEN */) {
  42735. switch (value.unit.toLowerCase()) {
  42736. case 's':
  42737. return 1000 * value.number;
  42738. case 'ms':
  42739. return value.number;
  42740. }
  42741. }
  42742. throw new Error("Unsupported time type");
  42743. }
  42744. };
  42745. var opacity = {
  42746. name: 'opacity',
  42747. initialValue: '1',
  42748. type: 0 /* VALUE */,
  42749. prefix: false,
  42750. parse: function (_context, token) {
  42751. if (isNumberToken(token)) {
  42752. return token.number;
  42753. }
  42754. return 1;
  42755. }
  42756. };
  42757. var textDecorationColor = {
  42758. name: "text-decoration-color",
  42759. initialValue: 'transparent',
  42760. prefix: false,
  42761. type: 3 /* TYPE_VALUE */,
  42762. format: 'color'
  42763. };
  42764. var textDecorationLine = {
  42765. name: 'text-decoration-line',
  42766. initialValue: 'none',
  42767. prefix: false,
  42768. type: 1 /* LIST */,
  42769. parse: function (_context, tokens) {
  42770. return tokens
  42771. .filter(isIdentToken)
  42772. .map(function (token) {
  42773. switch (token.value) {
  42774. case 'underline':
  42775. return 1 /* UNDERLINE */;
  42776. case 'overline':
  42777. return 2 /* OVERLINE */;
  42778. case 'line-through':
  42779. return 3 /* LINE_THROUGH */;
  42780. case 'none':
  42781. return 4 /* BLINK */;
  42782. }
  42783. return 0 /* NONE */;
  42784. })
  42785. .filter(function (line) { return line !== 0 /* NONE */; });
  42786. }
  42787. };
  42788. var fontFamily = {
  42789. name: "font-family",
  42790. initialValue: '',
  42791. prefix: false,
  42792. type: 1 /* LIST */,
  42793. parse: function (_context, tokens) {
  42794. var accumulator = [];
  42795. var results = [];
  42796. tokens.forEach(function (token) {
  42797. switch (token.type) {
  42798. case 20 /* IDENT_TOKEN */:
  42799. case 0 /* STRING_TOKEN */:
  42800. accumulator.push(token.value);
  42801. break;
  42802. case 17 /* NUMBER_TOKEN */:
  42803. accumulator.push(token.number.toString());
  42804. break;
  42805. case 4 /* COMMA_TOKEN */:
  42806. results.push(accumulator.join(' '));
  42807. accumulator.length = 0;
  42808. break;
  42809. }
  42810. });
  42811. if (accumulator.length) {
  42812. results.push(accumulator.join(' '));
  42813. }
  42814. return results.map(function (result) { return (result.indexOf(' ') === -1 ? result : "'" + result + "'"); });
  42815. }
  42816. };
  42817. var fontSize = {
  42818. name: "font-size",
  42819. initialValue: '0',
  42820. prefix: false,
  42821. type: 3 /* TYPE_VALUE */,
  42822. format: 'length'
  42823. };
  42824. var fontWeight = {
  42825. name: 'font-weight',
  42826. initialValue: 'normal',
  42827. type: 0 /* VALUE */,
  42828. prefix: false,
  42829. parse: function (_context, token) {
  42830. if (isNumberToken(token)) {
  42831. return token.number;
  42832. }
  42833. if (isIdentToken(token)) {
  42834. switch (token.value) {
  42835. case 'bold':
  42836. return 700;
  42837. case 'normal':
  42838. default:
  42839. return 400;
  42840. }
  42841. }
  42842. return 400;
  42843. }
  42844. };
  42845. var fontVariant = {
  42846. name: 'font-variant',
  42847. initialValue: 'none',
  42848. type: 1 /* LIST */,
  42849. prefix: false,
  42850. parse: function (_context, tokens) {
  42851. return tokens.filter(isIdentToken).map(function (token) { return token.value; });
  42852. }
  42853. };
  42854. var fontStyle = {
  42855. name: 'font-style',
  42856. initialValue: 'normal',
  42857. prefix: false,
  42858. type: 2 /* IDENT_VALUE */,
  42859. parse: function (_context, overflow) {
  42860. switch (overflow) {
  42861. case 'oblique':
  42862. return "oblique" /* OBLIQUE */;
  42863. case 'italic':
  42864. return "italic" /* ITALIC */;
  42865. case 'normal':
  42866. default:
  42867. return "normal" /* NORMAL */;
  42868. }
  42869. }
  42870. };
  42871. var contains = function (bit, value) { return (bit & value) !== 0; };
  42872. var content = {
  42873. name: 'content',
  42874. initialValue: 'none',
  42875. type: 1 /* LIST */,
  42876. prefix: false,
  42877. parse: function (_context, tokens) {
  42878. if (tokens.length === 0) {
  42879. return [];
  42880. }
  42881. var first = tokens[0];
  42882. if (first.type === 20 /* IDENT_TOKEN */ && first.value === 'none') {
  42883. return [];
  42884. }
  42885. return tokens;
  42886. }
  42887. };
  42888. var counterIncrement = {
  42889. name: 'counter-increment',
  42890. initialValue: 'none',
  42891. prefix: true,
  42892. type: 1 /* LIST */,
  42893. parse: function (_context, tokens) {
  42894. if (tokens.length === 0) {
  42895. return null;
  42896. }
  42897. var first = tokens[0];
  42898. if (first.type === 20 /* IDENT_TOKEN */ && first.value === 'none') {
  42899. return null;
  42900. }
  42901. var increments = [];
  42902. var filtered = tokens.filter(nonWhiteSpace);
  42903. for (var i = 0; i < filtered.length; i++) {
  42904. var counter = filtered[i];
  42905. var next = filtered[i + 1];
  42906. if (counter.type === 20 /* IDENT_TOKEN */) {
  42907. var increment = next && isNumberToken(next) ? next.number : 1;
  42908. increments.push({ counter: counter.value, increment: increment });
  42909. }
  42910. }
  42911. return increments;
  42912. }
  42913. };
  42914. var counterReset = {
  42915. name: 'counter-reset',
  42916. initialValue: 'none',
  42917. prefix: true,
  42918. type: 1 /* LIST */,
  42919. parse: function (_context, tokens) {
  42920. if (tokens.length === 0) {
  42921. return [];
  42922. }
  42923. var resets = [];
  42924. var filtered = tokens.filter(nonWhiteSpace);
  42925. for (var i = 0; i < filtered.length; i++) {
  42926. var counter = filtered[i];
  42927. var next = filtered[i + 1];
  42928. if (isIdentToken(counter) && counter.value !== 'none') {
  42929. var reset = next && isNumberToken(next) ? next.number : 0;
  42930. resets.push({ counter: counter.value, reset: reset });
  42931. }
  42932. }
  42933. return resets;
  42934. }
  42935. };
  42936. var duration = {
  42937. name: 'duration',
  42938. initialValue: '0s',
  42939. prefix: false,
  42940. type: 1 /* LIST */,
  42941. parse: function (context, tokens) {
  42942. return tokens.filter(isDimensionToken).map(function (token) { return time.parse(context, token); });
  42943. }
  42944. };
  42945. var quotes = {
  42946. name: 'quotes',
  42947. initialValue: 'none',
  42948. prefix: true,
  42949. type: 1 /* LIST */,
  42950. parse: function (_context, tokens) {
  42951. if (tokens.length === 0) {
  42952. return null;
  42953. }
  42954. var first = tokens[0];
  42955. if (first.type === 20 /* IDENT_TOKEN */ && first.value === 'none') {
  42956. return null;
  42957. }
  42958. var quotes = [];
  42959. var filtered = tokens.filter(isStringToken);
  42960. if (filtered.length % 2 !== 0) {
  42961. return null;
  42962. }
  42963. for (var i = 0; i < filtered.length; i += 2) {
  42964. var open_1 = filtered[i].value;
  42965. var close_1 = filtered[i + 1].value;
  42966. quotes.push({ open: open_1, close: close_1 });
  42967. }
  42968. return quotes;
  42969. }
  42970. };
  42971. var getQuote = function (quotes, depth, open) {
  42972. if (!quotes) {
  42973. return '';
  42974. }
  42975. var quote = quotes[Math.min(depth, quotes.length - 1)];
  42976. if (!quote) {
  42977. return '';
  42978. }
  42979. return open ? quote.open : quote.close;
  42980. };
  42981. var boxShadow = {
  42982. name: 'box-shadow',
  42983. initialValue: 'none',
  42984. type: 1 /* LIST */,
  42985. prefix: false,
  42986. parse: function (context, tokens) {
  42987. if (tokens.length === 1 && isIdentWithValue(tokens[0], 'none')) {
  42988. return [];
  42989. }
  42990. return parseFunctionArgs(tokens).map(function (values) {
  42991. var shadow = {
  42992. color: 0x000000ff,
  42993. offsetX: ZERO_LENGTH,
  42994. offsetY: ZERO_LENGTH,
  42995. blur: ZERO_LENGTH,
  42996. spread: ZERO_LENGTH,
  42997. inset: false
  42998. };
  42999. var c = 0;
  43000. for (var i = 0; i < values.length; i++) {
  43001. var token = values[i];
  43002. if (isIdentWithValue(token, 'inset')) {
  43003. shadow.inset = true;
  43004. }
  43005. else if (isLength(token)) {
  43006. if (c === 0) {
  43007. shadow.offsetX = token;
  43008. }
  43009. else if (c === 1) {
  43010. shadow.offsetY = token;
  43011. }
  43012. else if (c === 2) {
  43013. shadow.blur = token;
  43014. }
  43015. else {
  43016. shadow.spread = token;
  43017. }
  43018. c++;
  43019. }
  43020. else {
  43021. shadow.color = color$1.parse(context, token);
  43022. }
  43023. }
  43024. return shadow;
  43025. });
  43026. }
  43027. };
  43028. var paintOrder = {
  43029. name: 'paint-order',
  43030. initialValue: 'normal',
  43031. prefix: false,
  43032. type: 1 /* LIST */,
  43033. parse: function (_context, tokens) {
  43034. var DEFAULT_VALUE = [0 /* FILL */, 1 /* STROKE */, 2 /* MARKERS */];
  43035. var layers = [];
  43036. tokens.filter(isIdentToken).forEach(function (token) {
  43037. switch (token.value) {
  43038. case 'stroke':
  43039. layers.push(1 /* STROKE */);
  43040. break;
  43041. case 'fill':
  43042. layers.push(0 /* FILL */);
  43043. break;
  43044. case 'markers':
  43045. layers.push(2 /* MARKERS */);
  43046. break;
  43047. }
  43048. });
  43049. DEFAULT_VALUE.forEach(function (value) {
  43050. if (layers.indexOf(value) === -1) {
  43051. layers.push(value);
  43052. }
  43053. });
  43054. return layers;
  43055. }
  43056. };
  43057. var webkitTextStrokeColor = {
  43058. name: "-webkit-text-stroke-color",
  43059. initialValue: 'currentcolor',
  43060. prefix: false,
  43061. type: 3 /* TYPE_VALUE */,
  43062. format: 'color'
  43063. };
  43064. var webkitTextStrokeWidth = {
  43065. name: "-webkit-text-stroke-width",
  43066. initialValue: '0',
  43067. type: 0 /* VALUE */,
  43068. prefix: false,
  43069. parse: function (_context, token) {
  43070. if (isDimensionToken(token)) {
  43071. return token.number;
  43072. }
  43073. return 0;
  43074. }
  43075. };
  43076. var CSSParsedDeclaration = /** @class */ (function () {
  43077. function CSSParsedDeclaration(context, declaration) {
  43078. var _a, _b;
  43079. this.animationDuration = parse(context, duration, declaration.animationDuration);
  43080. this.backgroundClip = parse(context, backgroundClip, declaration.backgroundClip);
  43081. this.backgroundColor = parse(context, backgroundColor, declaration.backgroundColor);
  43082. this.backgroundImage = parse(context, backgroundImage, declaration.backgroundImage);
  43083. this.backgroundOrigin = parse(context, backgroundOrigin, declaration.backgroundOrigin);
  43084. this.backgroundPosition = parse(context, backgroundPosition, declaration.backgroundPosition);
  43085. this.backgroundRepeat = parse(context, backgroundRepeat, declaration.backgroundRepeat);
  43086. this.backgroundSize = parse(context, backgroundSize, declaration.backgroundSize);
  43087. this.borderTopColor = parse(context, borderTopColor, declaration.borderTopColor);
  43088. this.borderRightColor = parse(context, borderRightColor, declaration.borderRightColor);
  43089. this.borderBottomColor = parse(context, borderBottomColor, declaration.borderBottomColor);
  43090. this.borderLeftColor = parse(context, borderLeftColor, declaration.borderLeftColor);
  43091. this.borderTopLeftRadius = parse(context, borderTopLeftRadius, declaration.borderTopLeftRadius);
  43092. this.borderTopRightRadius = parse(context, borderTopRightRadius, declaration.borderTopRightRadius);
  43093. this.borderBottomRightRadius = parse(context, borderBottomRightRadius, declaration.borderBottomRightRadius);
  43094. this.borderBottomLeftRadius = parse(context, borderBottomLeftRadius, declaration.borderBottomLeftRadius);
  43095. this.borderTopStyle = parse(context, borderTopStyle, declaration.borderTopStyle);
  43096. this.borderRightStyle = parse(context, borderRightStyle, declaration.borderRightStyle);
  43097. this.borderBottomStyle = parse(context, borderBottomStyle, declaration.borderBottomStyle);
  43098. this.borderLeftStyle = parse(context, borderLeftStyle, declaration.borderLeftStyle);
  43099. this.borderTopWidth = parse(context, borderTopWidth, declaration.borderTopWidth);
  43100. this.borderRightWidth = parse(context, borderRightWidth, declaration.borderRightWidth);
  43101. this.borderBottomWidth = parse(context, borderBottomWidth, declaration.borderBottomWidth);
  43102. this.borderLeftWidth = parse(context, borderLeftWidth, declaration.borderLeftWidth);
  43103. this.boxShadow = parse(context, boxShadow, declaration.boxShadow);
  43104. this.color = parse(context, color, declaration.color);
  43105. this.direction = parse(context, direction, declaration.direction);
  43106. this.display = parse(context, display, declaration.display);
  43107. this.float = parse(context, float, declaration.cssFloat);
  43108. this.fontFamily = parse(context, fontFamily, declaration.fontFamily);
  43109. this.fontSize = parse(context, fontSize, declaration.fontSize);
  43110. this.fontStyle = parse(context, fontStyle, declaration.fontStyle);
  43111. this.fontVariant = parse(context, fontVariant, declaration.fontVariant);
  43112. this.fontWeight = parse(context, fontWeight, declaration.fontWeight);
  43113. this.letterSpacing = parse(context, letterSpacing, declaration.letterSpacing);
  43114. this.lineBreak = parse(context, lineBreak, declaration.lineBreak);
  43115. this.lineHeight = parse(context, lineHeight, declaration.lineHeight);
  43116. this.listStyleImage = parse(context, listStyleImage, declaration.listStyleImage);
  43117. this.listStylePosition = parse(context, listStylePosition, declaration.listStylePosition);
  43118. this.listStyleType = parse(context, listStyleType, declaration.listStyleType);
  43119. this.marginTop = parse(context, marginTop, declaration.marginTop);
  43120. this.marginRight = parse(context, marginRight, declaration.marginRight);
  43121. this.marginBottom = parse(context, marginBottom, declaration.marginBottom);
  43122. this.marginLeft = parse(context, marginLeft, declaration.marginLeft);
  43123. this.opacity = parse(context, opacity, declaration.opacity);
  43124. var overflowTuple = parse(context, overflow, declaration.overflow);
  43125. this.overflowX = overflowTuple[0];
  43126. this.overflowY = overflowTuple[overflowTuple.length > 1 ? 1 : 0];
  43127. this.overflowWrap = parse(context, overflowWrap, declaration.overflowWrap);
  43128. this.paddingTop = parse(context, paddingTop, declaration.paddingTop);
  43129. this.paddingRight = parse(context, paddingRight, declaration.paddingRight);
  43130. this.paddingBottom = parse(context, paddingBottom, declaration.paddingBottom);
  43131. this.paddingLeft = parse(context, paddingLeft, declaration.paddingLeft);
  43132. this.paintOrder = parse(context, paintOrder, declaration.paintOrder);
  43133. this.position = parse(context, position, declaration.position);
  43134. this.textAlign = parse(context, textAlign, declaration.textAlign);
  43135. this.textDecorationColor = parse(context, textDecorationColor, (_a = declaration.textDecorationColor) !== null && _a !== void 0 ? _a : declaration.color);
  43136. this.textDecorationLine = parse(context, textDecorationLine, (_b = declaration.textDecorationLine) !== null && _b !== void 0 ? _b : declaration.textDecoration);
  43137. this.textShadow = parse(context, textShadow, declaration.textShadow);
  43138. this.textTransform = parse(context, textTransform, declaration.textTransform);
  43139. this.transform = parse(context, transform$1, declaration.transform);
  43140. this.transformOrigin = parse(context, transformOrigin, declaration.transformOrigin);
  43141. this.visibility = parse(context, visibility, declaration.visibility);
  43142. this.webkitTextStrokeColor = parse(context, webkitTextStrokeColor, declaration.webkitTextStrokeColor);
  43143. this.webkitTextStrokeWidth = parse(context, webkitTextStrokeWidth, declaration.webkitTextStrokeWidth);
  43144. this.wordBreak = parse(context, wordBreak, declaration.wordBreak);
  43145. this.zIndex = parse(context, zIndex, declaration.zIndex);
  43146. }
  43147. CSSParsedDeclaration.prototype.isVisible = function () {
  43148. return this.display > 0 && this.opacity > 0 && this.visibility === 0 /* VISIBLE */;
  43149. };
  43150. CSSParsedDeclaration.prototype.isTransparent = function () {
  43151. return isTransparent(this.backgroundColor);
  43152. };
  43153. CSSParsedDeclaration.prototype.isTransformed = function () {
  43154. return this.transform !== null;
  43155. };
  43156. CSSParsedDeclaration.prototype.isPositioned = function () {
  43157. return this.position !== 0 /* STATIC */;
  43158. };
  43159. CSSParsedDeclaration.prototype.isPositionedWithZIndex = function () {
  43160. return this.isPositioned() && !this.zIndex.auto;
  43161. };
  43162. CSSParsedDeclaration.prototype.isFloating = function () {
  43163. return this.float !== 0 /* NONE */;
  43164. };
  43165. CSSParsedDeclaration.prototype.isInlineLevel = function () {
  43166. return (contains(this.display, 4 /* INLINE */) ||
  43167. contains(this.display, 33554432 /* INLINE_BLOCK */) ||
  43168. contains(this.display, 268435456 /* INLINE_FLEX */) ||
  43169. contains(this.display, 536870912 /* INLINE_GRID */) ||
  43170. contains(this.display, 67108864 /* INLINE_LIST_ITEM */) ||
  43171. contains(this.display, 134217728 /* INLINE_TABLE */));
  43172. };
  43173. return CSSParsedDeclaration;
  43174. }());
  43175. var CSSParsedPseudoDeclaration = /** @class */ (function () {
  43176. function CSSParsedPseudoDeclaration(context, declaration) {
  43177. this.content = parse(context, content, declaration.content);
  43178. this.quotes = parse(context, quotes, declaration.quotes);
  43179. }
  43180. return CSSParsedPseudoDeclaration;
  43181. }());
  43182. var CSSParsedCounterDeclaration = /** @class */ (function () {
  43183. function CSSParsedCounterDeclaration(context, declaration) {
  43184. this.counterIncrement = parse(context, counterIncrement, declaration.counterIncrement);
  43185. this.counterReset = parse(context, counterReset, declaration.counterReset);
  43186. }
  43187. return CSSParsedCounterDeclaration;
  43188. }());
  43189. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  43190. var parse = function (context, descriptor, style) {
  43191. var tokenizer = new Tokenizer();
  43192. var value = style !== null && typeof style !== 'undefined' ? style.toString() : descriptor.initialValue;
  43193. tokenizer.write(value);
  43194. var parser = new Parser(tokenizer.read());
  43195. switch (descriptor.type) {
  43196. case 2 /* IDENT_VALUE */:
  43197. var token = parser.parseComponentValue();
  43198. return descriptor.parse(context, isIdentToken(token) ? token.value : descriptor.initialValue);
  43199. case 0 /* VALUE */:
  43200. return descriptor.parse(context, parser.parseComponentValue());
  43201. case 1 /* LIST */:
  43202. return descriptor.parse(context, parser.parseComponentValues());
  43203. case 4 /* TOKEN_VALUE */:
  43204. return parser.parseComponentValue();
  43205. case 3 /* TYPE_VALUE */:
  43206. switch (descriptor.format) {
  43207. case 'angle':
  43208. return angle.parse(context, parser.parseComponentValue());
  43209. case 'color':
  43210. return color$1.parse(context, parser.parseComponentValue());
  43211. case 'image':
  43212. return image.parse(context, parser.parseComponentValue());
  43213. case 'length':
  43214. var length_1 = parser.parseComponentValue();
  43215. return isLength(length_1) ? length_1 : ZERO_LENGTH;
  43216. case 'length-percentage':
  43217. var value_1 = parser.parseComponentValue();
  43218. return isLengthPercentage(value_1) ? value_1 : ZERO_LENGTH;
  43219. case 'time':
  43220. return time.parse(context, parser.parseComponentValue());
  43221. }
  43222. break;
  43223. }
  43224. };
  43225. var elementDebuggerAttribute = 'data-html2canvas-debug';
  43226. var getElementDebugType = function (element) {
  43227. var attribute = element.getAttribute(elementDebuggerAttribute);
  43228. switch (attribute) {
  43229. case 'all':
  43230. return 1 /* ALL */;
  43231. case 'clone':
  43232. return 2 /* CLONE */;
  43233. case 'parse':
  43234. return 3 /* PARSE */;
  43235. case 'render':
  43236. return 4 /* RENDER */;
  43237. default:
  43238. return 0 /* NONE */;
  43239. }
  43240. };
  43241. var isDebugging = function (element, type) {
  43242. var elementType = getElementDebugType(element);
  43243. return elementType === 1 /* ALL */ || type === elementType;
  43244. };
  43245. var ElementContainer = /** @class */ (function () {
  43246. function ElementContainer(context, element) {
  43247. this.context = context;
  43248. this.textNodes = [];
  43249. this.elements = [];
  43250. this.flags = 0;
  43251. if (isDebugging(element, 3 /* PARSE */)) {
  43252. debugger;
  43253. }
  43254. this.styles = new CSSParsedDeclaration(context, window.getComputedStyle(element, null));
  43255. if (isHTMLElementNode(element)) {
  43256. if (this.styles.animationDuration.some(function (duration) { return duration > 0; })) {
  43257. element.style.animationDuration = '0s';
  43258. }
  43259. if (this.styles.transform !== null) {
  43260. // getBoundingClientRect takes transforms into account
  43261. element.style.transform = 'none';
  43262. }
  43263. }
  43264. this.bounds = parseBounds(this.context, element);
  43265. if (isDebugging(element, 4 /* RENDER */)) {
  43266. this.flags |= 16 /* DEBUG_RENDER */;
  43267. }
  43268. }
  43269. return ElementContainer;
  43270. }());
  43271. /*
  43272. * text-segmentation 1.0.3 <https://github.com/niklasvh/text-segmentation>
  43273. * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
  43274. * Released under MIT License
  43275. */
  43276. var base64 = 'AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAMDvwAIAAgAJAIIAAgACAAIAAgACAAIAAgACwMTAwgACAB9BOsEGwMjAwgAKwMyAwsFYgE3A/MEPwMIAEUDTQNRAwgAWQOsAGEDCAAIAAgACAAIAAgACABpAzQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFIQUoBSwFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABtAwgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABMAEwACAAIAAgACAAIABgACAAIAAgACAC/AAgACAAyAQgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACAAIAAwAAgACAAIAAgACAAIAAgACAAIAAAARABIAAgACAAIABQASAAIAAgAIABwAEAAjgCIABsAqAC2AL0AigDQAtwC+IJIQqVAZUBWQqVAZUBlQGVAZUBlQGrC5UBlQGVAZUBlQGVAZUBlQGVAXsKlQGVAbAK6wsrDGUMpQzlDJUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAfAKAAuZA64AtwCJALoC6ADwAAgAuACgA/oEpgO6AqsD+AAIAAgAswMIAAgACAAIAIkAuwP5AfsBwwPLAwgACAAIAAgACADRA9kDCAAIAOED6QMIAAgACAAIAAgACADuA/YDCAAIAP4DyQAIAAgABgQIAAgAXQAOBAgACAAIAAgACAAIABMECAAIAAgACAAIAAgACAD8AAQBCAAIAAgAGgQiBCoECAExBAgAEAEIAAgACAAIAAgACAAIAAgACAAIAAgACAA4BAgACABABEYECAAIAAgATAQYAQgAVAQIAAgACAAIAAgACAAIAAgACAAIAFoECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAOQEIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAB+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBd0FXwUIAOIF6gXxBYoF3gT5BQAGCAaKBYoFigWKBYoFigWKBYoFigWKBYoFigXWBIoFigWKBYoFigWKBYoFigWKBYsFEAaKBYoFigWKBYoFigWKBRQGCACKBYoFigWKBQgACAAIANEECAAIABgGigUgBggAJgYIAC4GMwaKBYoF0wQ3Bj4GigWKBYoFigWKBYoFigWKBYoFigWKBYoFigUIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWLBf///////wQABAAEAAQABAAEAAQABAAEAAQAAwAEAAQAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAQADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUAAAAFAAUAAAAFAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAQAAAAUABQAFAAUABQAFAAAAAAAFAAUAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAFAAUAAQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAAABwAHAAcAAAAHAAcABwAFAAEAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAcABwAFAAUAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAQABAAAAAAAAAAAAAAAFAAUABQAFAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAHAAcAAAAHAAcAAAAAAAUABQAHAAUAAQAHAAEABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwABAAUABQAFAAUAAAAAAAAAAAAAAAEAAQABAAEAAQABAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABQANAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAABQAHAAUABQAFAAAAAAAAAAcABQAFAAUABQAFAAQABAAEAAQABAAEAAQABAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUAAAAFAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAUAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAcABwAFAAcABwAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUABwAHAAUABQAFAAUAAAAAAAcABwAAAAAABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAAAAAAAAAAABQAFAAAAAAAFAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAFAAUABQAFAAUAAAAFAAUABwAAAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABwAFAAUABQAFAAAAAAAHAAcAAAAAAAcABwAFAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAAAAAAAAAHAAcABwAAAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAUABQAFAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAHAAcABQAHAAcAAAAFAAcABwAAAAcABwAFAAUAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAFAAcABwAFAAUABQAAAAUAAAAHAAcABwAHAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAHAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUAAAAFAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAUAAAAFAAUAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABwAFAAUABQAFAAUABQAAAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABQAFAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAFAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAHAAUABQAFAAUABQAFAAUABwAHAAcABwAHAAcABwAHAAUABwAHAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABwAHAAcABwAFAAUABwAHAAcAAAAAAAAAAAAHAAcABQAHAAcABwAHAAcABwAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAUABQAFAAUABQAFAAUAAAAFAAAABQAAAAAABQAFAAUABQAFAAUABQAFAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAUABQAFAAUABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABwAFAAcABwAHAAcABwAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAUABQAFAAUABwAHAAUABQAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABQAFAAcABwAHAAUABwAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAcABQAFAAUABQAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAAAAAABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAUABQAHAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAFAAUABQAFAAcABwAFAAUABwAHAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAcABwAFAAUABwAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABQAAAAAABQAFAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAcABwAAAAAAAAAAAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAcABwAFAAcABwAAAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAFAAUABQAAAAUABQAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABwAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAHAAcABQAHAAUABQAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAAABwAHAAAAAAAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAFAAUABwAFAAcABwAFAAcABQAFAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAAAAAABwAHAAcABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAFAAcABwAFAAUABQAFAAUABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAUABQAFAAcABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABQAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAAAAAAFAAUABwAHAAcABwAFAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAHAAUABQAFAAUABQAFAAUABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAABQAAAAUABQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAHAAcAAAAFAAUAAAAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABQAFAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAABQAFAAUABQAFAAUABQAAAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAFAAUABQAFAAUADgAOAA4ADgAOAA4ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAMAAwADAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAAAAAAAAAAAAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAAAAAAAAAAAAsADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwACwAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAADgAOAA4AAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAAAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4AAAAOAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAAAAAAAAAAAA4AAAAOAAAAAAAAAAAADgAOAA4AAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAA=';
  43277. /*
  43278. * utrie 1.0.2 <https://github.com/niklasvh/utrie>
  43279. * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
  43280. * Released under MIT License
  43281. */
  43282. var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  43283. // Use a lookup table to find the index.
  43284. var lookup$1 = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);
  43285. for (var i$1 = 0; i$1 < chars$1.length; i$1++) {
  43286. lookup$1[chars$1.charCodeAt(i$1)] = i$1;
  43287. }
  43288. var decode = function (base64) {
  43289. var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;
  43290. if (base64[base64.length - 1] === '=') {
  43291. bufferLength--;
  43292. if (base64[base64.length - 2] === '=') {
  43293. bufferLength--;
  43294. }
  43295. }
  43296. var buffer = typeof ArrayBuffer !== 'undefined' &&
  43297. typeof Uint8Array !== 'undefined' &&
  43298. typeof Uint8Array.prototype.slice !== 'undefined'
  43299. ? new ArrayBuffer(bufferLength)
  43300. : new Array(bufferLength);
  43301. var bytes = Array.isArray(buffer) ? buffer : new Uint8Array(buffer);
  43302. for (i = 0; i < len; i += 4) {
  43303. encoded1 = lookup$1[base64.charCodeAt(i)];
  43304. encoded2 = lookup$1[base64.charCodeAt(i + 1)];
  43305. encoded3 = lookup$1[base64.charCodeAt(i + 2)];
  43306. encoded4 = lookup$1[base64.charCodeAt(i + 3)];
  43307. bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
  43308. bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
  43309. bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
  43310. }
  43311. return buffer;
  43312. };
  43313. var polyUint16Array = function (buffer) {
  43314. var length = buffer.length;
  43315. var bytes = [];
  43316. for (var i = 0; i < length; i += 2) {
  43317. bytes.push((buffer[i + 1] << 8) | buffer[i]);
  43318. }
  43319. return bytes;
  43320. };
  43321. var polyUint32Array = function (buffer) {
  43322. var length = buffer.length;
  43323. var bytes = [];
  43324. for (var i = 0; i < length; i += 4) {
  43325. bytes.push((buffer[i + 3] << 24) | (buffer[i + 2] << 16) | (buffer[i + 1] << 8) | buffer[i]);
  43326. }
  43327. return bytes;
  43328. };
  43329. /** Shift size for getting the index-2 table offset. */
  43330. var UTRIE2_SHIFT_2 = 5;
  43331. /** Shift size for getting the index-1 table offset. */
  43332. var UTRIE2_SHIFT_1 = 6 + 5;
  43333. /**
  43334. * Shift size for shifting left the index array values.
  43335. * Increases possible data size with 16-bit index values at the cost
  43336. * of compactability.
  43337. * This requires data blocks to be aligned by UTRIE2_DATA_GRANULARITY.
  43338. */
  43339. var UTRIE2_INDEX_SHIFT = 2;
  43340. /**
  43341. * Difference between the two shift sizes,
  43342. * for getting an index-1 offset from an index-2 offset. 6=11-5
  43343. */
  43344. var UTRIE2_SHIFT_1_2 = UTRIE2_SHIFT_1 - UTRIE2_SHIFT_2;
  43345. /**
  43346. * The part of the index-2 table for U+D800..U+DBFF stores values for
  43347. * lead surrogate code _units_ not code _points_.
  43348. * Values for lead surrogate code _points_ are indexed with this portion of the table.
  43349. * Length=32=0x20=0x400>>UTRIE2_SHIFT_2. (There are 1024=0x400 lead surrogates.)
  43350. */
  43351. var UTRIE2_LSCP_INDEX_2_OFFSET = 0x10000 >> UTRIE2_SHIFT_2;
  43352. /** Number of entries in a data block. 32=0x20 */
  43353. var UTRIE2_DATA_BLOCK_LENGTH = 1 << UTRIE2_SHIFT_2;
  43354. /** Mask for getting the lower bits for the in-data-block offset. */
  43355. var UTRIE2_DATA_MASK = UTRIE2_DATA_BLOCK_LENGTH - 1;
  43356. var UTRIE2_LSCP_INDEX_2_LENGTH = 0x400 >> UTRIE2_SHIFT_2;
  43357. /** Count the lengths of both BMP pieces. 2080=0x820 */
  43358. var UTRIE2_INDEX_2_BMP_LENGTH = UTRIE2_LSCP_INDEX_2_OFFSET + UTRIE2_LSCP_INDEX_2_LENGTH;
  43359. /**
  43360. * The 2-byte UTF-8 version of the index-2 table follows at offset 2080=0x820.
  43361. * Length 32=0x20 for lead bytes C0..DF, regardless of UTRIE2_SHIFT_2.
  43362. */
  43363. var UTRIE2_UTF8_2B_INDEX_2_OFFSET = UTRIE2_INDEX_2_BMP_LENGTH;
  43364. var UTRIE2_UTF8_2B_INDEX_2_LENGTH = 0x800 >> 6; /* U+0800 is the first code point after 2-byte UTF-8 */
  43365. /**
  43366. * The index-1 table, only used for supplementary code points, at offset 2112=0x840.
  43367. * Variable length, for code points up to highStart, where the last single-value range starts.
  43368. * Maximum length 512=0x200=0x100000>>UTRIE2_SHIFT_1.
  43369. * (For 0x100000 supplementary code points U+10000..U+10ffff.)
  43370. *
  43371. * The part of the index-2 table for supplementary code points starts
  43372. * after this index-1 table.
  43373. *
  43374. * Both the index-1 table and the following part of the index-2 table
  43375. * are omitted completely if there is only BMP data.
  43376. */
  43377. var UTRIE2_INDEX_1_OFFSET = UTRIE2_UTF8_2B_INDEX_2_OFFSET + UTRIE2_UTF8_2B_INDEX_2_LENGTH;
  43378. /**
  43379. * Number of index-1 entries for the BMP. 32=0x20
  43380. * This part of the index-1 table is omitted from the serialized form.
  43381. */
  43382. var UTRIE2_OMITTED_BMP_INDEX_1_LENGTH = 0x10000 >> UTRIE2_SHIFT_1;
  43383. /** Number of entries in an index-2 block. 64=0x40 */
  43384. var UTRIE2_INDEX_2_BLOCK_LENGTH = 1 << UTRIE2_SHIFT_1_2;
  43385. /** Mask for getting the lower bits for the in-index-2-block offset. */
  43386. var UTRIE2_INDEX_2_MASK = UTRIE2_INDEX_2_BLOCK_LENGTH - 1;
  43387. var slice16 = function (view, start, end) {
  43388. if (view.slice) {
  43389. return view.slice(start, end);
  43390. }
  43391. return new Uint16Array(Array.prototype.slice.call(view, start, end));
  43392. };
  43393. var slice32 = function (view, start, end) {
  43394. if (view.slice) {
  43395. return view.slice(start, end);
  43396. }
  43397. return new Uint32Array(Array.prototype.slice.call(view, start, end));
  43398. };
  43399. var createTrieFromBase64 = function (base64, _byteLength) {
  43400. var buffer = decode(base64);
  43401. var view32 = Array.isArray(buffer) ? polyUint32Array(buffer) : new Uint32Array(buffer);
  43402. var view16 = Array.isArray(buffer) ? polyUint16Array(buffer) : new Uint16Array(buffer);
  43403. var headerLength = 24;
  43404. var index = slice16(view16, headerLength / 2, view32[4] / 2);
  43405. var data = view32[5] === 2
  43406. ? slice16(view16, (headerLength + view32[4]) / 2)
  43407. : slice32(view32, Math.ceil((headerLength + view32[4]) / 4));
  43408. return new Trie(view32[0], view32[1], view32[2], view32[3], index, data);
  43409. };
  43410. var Trie = /** @class */ (function () {
  43411. function Trie(initialValue, errorValue, highStart, highValueIndex, index, data) {
  43412. this.initialValue = initialValue;
  43413. this.errorValue = errorValue;
  43414. this.highStart = highStart;
  43415. this.highValueIndex = highValueIndex;
  43416. this.index = index;
  43417. this.data = data;
  43418. }
  43419. /**
  43420. * Get the value for a code point as stored in the Trie.
  43421. *
  43422. * @param codePoint the code point
  43423. * @return the value
  43424. */
  43425. Trie.prototype.get = function (codePoint) {
  43426. var ix;
  43427. if (codePoint >= 0) {
  43428. if (codePoint < 0x0d800 || (codePoint > 0x0dbff && codePoint <= 0x0ffff)) {
  43429. // Ordinary BMP code point, excluding leading surrogates.
  43430. // BMP uses a single level lookup. BMP index starts at offset 0 in the Trie2 index.
  43431. // 16 bit data is stored in the index array itself.
  43432. ix = this.index[codePoint >> UTRIE2_SHIFT_2];
  43433. ix = (ix << UTRIE2_INDEX_SHIFT) + (codePoint & UTRIE2_DATA_MASK);
  43434. return this.data[ix];
  43435. }
  43436. if (codePoint <= 0xffff) {
  43437. // Lead Surrogate Code Point. A Separate index section is stored for
  43438. // lead surrogate code units and code points.
  43439. // The main index has the code unit data.
  43440. // For this function, we need the code point data.
  43441. // Note: this expression could be refactored for slightly improved efficiency, but
  43442. // surrogate code points will be so rare in practice that it's not worth it.
  43443. ix = this.index[UTRIE2_LSCP_INDEX_2_OFFSET + ((codePoint - 0xd800) >> UTRIE2_SHIFT_2)];
  43444. ix = (ix << UTRIE2_INDEX_SHIFT) + (codePoint & UTRIE2_DATA_MASK);
  43445. return this.data[ix];
  43446. }
  43447. if (codePoint < this.highStart) {
  43448. // Supplemental code point, use two-level lookup.
  43449. ix = UTRIE2_INDEX_1_OFFSET - UTRIE2_OMITTED_BMP_INDEX_1_LENGTH + (codePoint >> UTRIE2_SHIFT_1);
  43450. ix = this.index[ix];
  43451. ix += (codePoint >> UTRIE2_SHIFT_2) & UTRIE2_INDEX_2_MASK;
  43452. ix = this.index[ix];
  43453. ix = (ix << UTRIE2_INDEX_SHIFT) + (codePoint & UTRIE2_DATA_MASK);
  43454. return this.data[ix];
  43455. }
  43456. if (codePoint <= 0x10ffff) {
  43457. return this.data[this.highValueIndex];
  43458. }
  43459. }
  43460. // Fall through. The code point is outside of the legal range of 0..0x10ffff.
  43461. return this.errorValue;
  43462. };
  43463. return Trie;
  43464. }());
  43465. /*
  43466. * base64-arraybuffer 1.0.2 <https://github.com/niklasvh/base64-arraybuffer>
  43467. * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
  43468. * Released under MIT License
  43469. */
  43470. var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  43471. // Use a lookup table to find the index.
  43472. var lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);
  43473. for (var i = 0; i < chars.length; i++) {
  43474. lookup[chars.charCodeAt(i)] = i;
  43475. }
  43476. var Prepend = 1;
  43477. var CR = 2;
  43478. var LF = 3;
  43479. var Control = 4;
  43480. var Extend = 5;
  43481. var SpacingMark = 7;
  43482. var L = 8;
  43483. var V = 9;
  43484. var T = 10;
  43485. var LV = 11;
  43486. var LVT = 12;
  43487. var ZWJ = 13;
  43488. var Extended_Pictographic = 14;
  43489. var RI = 15;
  43490. var toCodePoints = function (str) {
  43491. var codePoints = [];
  43492. var i = 0;
  43493. var length = str.length;
  43494. while (i < length) {
  43495. var value = str.charCodeAt(i++);
  43496. if (value >= 0xd800 && value <= 0xdbff && i < length) {
  43497. var extra = str.charCodeAt(i++);
  43498. if ((extra & 0xfc00) === 0xdc00) {
  43499. codePoints.push(((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000);
  43500. }
  43501. else {
  43502. codePoints.push(value);
  43503. i--;
  43504. }
  43505. }
  43506. else {
  43507. codePoints.push(value);
  43508. }
  43509. }
  43510. return codePoints;
  43511. };
  43512. var fromCodePoint = function () {
  43513. var codePoints = [];
  43514. for (var _i = 0; _i < arguments.length; _i++) {
  43515. codePoints[_i] = arguments[_i];
  43516. }
  43517. if (String.fromCodePoint) {
  43518. return String.fromCodePoint.apply(String, codePoints);
  43519. }
  43520. var length = codePoints.length;
  43521. if (!length) {
  43522. return '';
  43523. }
  43524. var codeUnits = [];
  43525. var index = -1;
  43526. var result = '';
  43527. while (++index < length) {
  43528. var codePoint = codePoints[index];
  43529. if (codePoint <= 0xffff) {
  43530. codeUnits.push(codePoint);
  43531. }
  43532. else {
  43533. codePoint -= 0x10000;
  43534. codeUnits.push((codePoint >> 10) + 0xd800, (codePoint % 0x400) + 0xdc00);
  43535. }
  43536. if (index + 1 === length || codeUnits.length > 0x4000) {
  43537. result += String.fromCharCode.apply(String, codeUnits);
  43538. codeUnits.length = 0;
  43539. }
  43540. }
  43541. return result;
  43542. };
  43543. var UnicodeTrie = createTrieFromBase64(base64);
  43544. var BREAK_NOT_ALLOWED = '×';
  43545. var BREAK_ALLOWED = '÷';
  43546. var codePointToClass = function (codePoint) { return UnicodeTrie.get(codePoint); };
  43547. var _graphemeBreakAtIndex = function (_codePoints, classTypes, index) {
  43548. var prevIndex = index - 2;
  43549. var prev = classTypes[prevIndex];
  43550. var current = classTypes[index - 1];
  43551. var next = classTypes[index];
  43552. // GB3 Do not break between a CR and LF
  43553. if (current === CR && next === LF) {
  43554. return BREAK_NOT_ALLOWED;
  43555. }
  43556. // GB4 Otherwise, break before and after controls.
  43557. if (current === CR || current === LF || current === Control) {
  43558. return BREAK_ALLOWED;
  43559. }
  43560. // GB5
  43561. if (next === CR || next === LF || next === Control) {
  43562. return BREAK_ALLOWED;
  43563. }
  43564. // Do not break Hangul syllable sequences.
  43565. // GB6
  43566. if (current === L && [L, V, LV, LVT].indexOf(next) !== -1) {
  43567. return BREAK_NOT_ALLOWED;
  43568. }
  43569. // GB7
  43570. if ((current === LV || current === V) && (next === V || next === T)) {
  43571. return BREAK_NOT_ALLOWED;
  43572. }
  43573. // GB8
  43574. if ((current === LVT || current === T) && next === T) {
  43575. return BREAK_NOT_ALLOWED;
  43576. }
  43577. // GB9 Do not break before extending characters or ZWJ.
  43578. if (next === ZWJ || next === Extend) {
  43579. return BREAK_NOT_ALLOWED;
  43580. }
  43581. // Do not break before SpacingMarks, or after Prepend characters.
  43582. // GB9a
  43583. if (next === SpacingMark) {
  43584. return BREAK_NOT_ALLOWED;
  43585. }
  43586. // GB9a
  43587. if (current === Prepend) {
  43588. return BREAK_NOT_ALLOWED;
  43589. }
  43590. // GB11 Do not break within emoji modifier sequences or emoji zwj sequences.
  43591. if (current === ZWJ && next === Extended_Pictographic) {
  43592. while (prev === Extend) {
  43593. prev = classTypes[--prevIndex];
  43594. }
  43595. if (prev === Extended_Pictographic) {
  43596. return BREAK_NOT_ALLOWED;
  43597. }
  43598. }
  43599. // GB12 Do not break within emoji flag sequences.
  43600. // That is, do not break between regional indicator (RI) symbols
  43601. // if there is an odd number of RI characters before the break point.
  43602. if (current === RI && next === RI) {
  43603. var countRI = 0;
  43604. while (prev === RI) {
  43605. countRI++;
  43606. prev = classTypes[--prevIndex];
  43607. }
  43608. if (countRI % 2 === 0) {
  43609. return BREAK_NOT_ALLOWED;
  43610. }
  43611. }
  43612. return BREAK_ALLOWED;
  43613. };
  43614. var GraphemeBreaker = function (str) {
  43615. var codePoints = toCodePoints(str);
  43616. var length = codePoints.length;
  43617. var index = 0;
  43618. var lastEnd = 0;
  43619. var classTypes = codePoints.map(codePointToClass);
  43620. return {
  43621. next: function () {
  43622. if (index >= length) {
  43623. return { done: true, value: null };
  43624. }
  43625. var graphemeBreak = BREAK_NOT_ALLOWED;
  43626. while (index < length &&
  43627. (graphemeBreak = _graphemeBreakAtIndex(codePoints, classTypes, ++index)) === BREAK_NOT_ALLOWED) { }
  43628. if (graphemeBreak !== BREAK_NOT_ALLOWED || index === length) {
  43629. var value = fromCodePoint.apply(null, codePoints.slice(lastEnd, index));
  43630. lastEnd = index;
  43631. return { value: value, done: false };
  43632. }
  43633. return { done: true, value: null };
  43634. },
  43635. };
  43636. };
  43637. var splitGraphemes = function (str) {
  43638. var breaker = GraphemeBreaker(str);
  43639. var graphemes = [];
  43640. var bk;
  43641. while (!(bk = breaker.next()).done) {
  43642. if (bk.value) {
  43643. graphemes.push(bk.value.slice());
  43644. }
  43645. }
  43646. return graphemes;
  43647. };
  43648. var testRangeBounds = function (document) {
  43649. var TEST_HEIGHT = 123;
  43650. if (document.createRange) {
  43651. var range = document.createRange();
  43652. if (range.getBoundingClientRect) {
  43653. var testElement = document.createElement('boundtest');
  43654. testElement.style.height = TEST_HEIGHT + "px";
  43655. testElement.style.display = 'block';
  43656. document.body.appendChild(testElement);
  43657. range.selectNode(testElement);
  43658. var rangeBounds = range.getBoundingClientRect();
  43659. var rangeHeight = Math.round(rangeBounds.height);
  43660. document.body.removeChild(testElement);
  43661. if (rangeHeight === TEST_HEIGHT) {
  43662. return true;
  43663. }
  43664. }
  43665. }
  43666. return false;
  43667. };
  43668. var testIOSLineBreak = function (document) {
  43669. var testElement = document.createElement('boundtest');
  43670. testElement.style.width = '50px';
  43671. testElement.style.display = 'block';
  43672. testElement.style.fontSize = '12px';
  43673. testElement.style.letterSpacing = '0px';
  43674. testElement.style.wordSpacing = '0px';
  43675. document.body.appendChild(testElement);
  43676. var range = document.createRange();
  43677. testElement.innerHTML = typeof ''.repeat === 'function' ? '&#128104;'.repeat(10) : '';
  43678. var node = testElement.firstChild;
  43679. var textList = toCodePoints$1(node.data).map(function (i) { return fromCodePoint$1(i); });
  43680. var offset = 0;
  43681. var prev = {};
  43682. // ios 13 does not handle range getBoundingClientRect line changes correctly #2177
  43683. var supports = textList.every(function (text, i) {
  43684. range.setStart(node, offset);
  43685. range.setEnd(node, offset + text.length);
  43686. var rect = range.getBoundingClientRect();
  43687. offset += text.length;
  43688. var boundAhead = rect.x > prev.x || rect.y > prev.y;
  43689. prev = rect;
  43690. if (i === 0) {
  43691. return true;
  43692. }
  43693. return boundAhead;
  43694. });
  43695. document.body.removeChild(testElement);
  43696. return supports;
  43697. };
  43698. var testCORS = function () { return typeof new Image().crossOrigin !== 'undefined'; };
  43699. var testResponseType = function () { return typeof new XMLHttpRequest().responseType === 'string'; };
  43700. var testSVG = function (document) {
  43701. var img = new Image();
  43702. var canvas = document.createElement('canvas');
  43703. var ctx = canvas.getContext('2d');
  43704. if (!ctx) {
  43705. return false;
  43706. }
  43707. img.src = "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";
  43708. try {
  43709. ctx.drawImage(img, 0, 0);
  43710. canvas.toDataURL();
  43711. }
  43712. catch (e) {
  43713. return false;
  43714. }
  43715. return true;
  43716. };
  43717. var isGreenPixel = function (data) {
  43718. return data[0] === 0 && data[1] === 255 && data[2] === 0 && data[3] === 255;
  43719. };
  43720. var testForeignObject = function (document) {
  43721. var canvas = document.createElement('canvas');
  43722. var size = 100;
  43723. canvas.width = size;
  43724. canvas.height = size;
  43725. var ctx = canvas.getContext('2d');
  43726. if (!ctx) {
  43727. return Promise.reject(false);
  43728. }
  43729. ctx.fillStyle = 'rgb(0, 255, 0)';
  43730. ctx.fillRect(0, 0, size, size);
  43731. var img = new Image();
  43732. var greenImageSrc = canvas.toDataURL();
  43733. img.src = greenImageSrc;
  43734. var svg = createForeignObjectSVG(size, size, 0, 0, img);
  43735. ctx.fillStyle = 'red';
  43736. ctx.fillRect(0, 0, size, size);
  43737. return loadSerializedSVG$1(svg)
  43738. .then(function (img) {
  43739. ctx.drawImage(img, 0, 0);
  43740. var data = ctx.getImageData(0, 0, size, size).data;
  43741. ctx.fillStyle = 'red';
  43742. ctx.fillRect(0, 0, size, size);
  43743. var node = document.createElement('div');
  43744. node.style.backgroundImage = "url(" + greenImageSrc + ")";
  43745. node.style.height = size + "px";
  43746. // Firefox 55 does not render inline <img /> tags
  43747. return isGreenPixel(data)
  43748. ? loadSerializedSVG$1(createForeignObjectSVG(size, size, 0, 0, node))
  43749. : Promise.reject(false);
  43750. })
  43751. .then(function (img) {
  43752. ctx.drawImage(img, 0, 0);
  43753. // Edge does not render background-images
  43754. return isGreenPixel(ctx.getImageData(0, 0, size, size).data);
  43755. })
  43756. .catch(function () { return false; });
  43757. };
  43758. var createForeignObjectSVG = function (width, height, x, y, node) {
  43759. var xmlns = 'http://www.w3.org/2000/svg';
  43760. var svg = document.createElementNS(xmlns, 'svg');
  43761. var foreignObject = document.createElementNS(xmlns, 'foreignObject');
  43762. svg.setAttributeNS(null, 'width', width.toString());
  43763. svg.setAttributeNS(null, 'height', height.toString());
  43764. foreignObject.setAttributeNS(null, 'width', '100%');
  43765. foreignObject.setAttributeNS(null, 'height', '100%');
  43766. foreignObject.setAttributeNS(null, 'x', x.toString());
  43767. foreignObject.setAttributeNS(null, 'y', y.toString());
  43768. foreignObject.setAttributeNS(null, 'externalResourcesRequired', 'true');
  43769. svg.appendChild(foreignObject);
  43770. foreignObject.appendChild(node);
  43771. return svg;
  43772. };
  43773. var loadSerializedSVG$1 = function (svg) {
  43774. return new Promise(function (resolve, reject) {
  43775. var img = new Image();
  43776. img.onload = function () { return resolve(img); };
  43777. img.onerror = reject;
  43778. img.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(svg));
  43779. });
  43780. };
  43781. var FEATURES = {
  43782. get SUPPORT_RANGE_BOUNDS() {
  43783. var value = testRangeBounds(document);
  43784. Object.defineProperty(FEATURES, 'SUPPORT_RANGE_BOUNDS', { value: value });
  43785. return value;
  43786. },
  43787. get SUPPORT_WORD_BREAKING() {
  43788. var value = FEATURES.SUPPORT_RANGE_BOUNDS && testIOSLineBreak(document);
  43789. Object.defineProperty(FEATURES, 'SUPPORT_WORD_BREAKING', { value: value });
  43790. return value;
  43791. },
  43792. get SUPPORT_SVG_DRAWING() {
  43793. var value = testSVG(document);
  43794. Object.defineProperty(FEATURES, 'SUPPORT_SVG_DRAWING', { value: value });
  43795. return value;
  43796. },
  43797. get SUPPORT_FOREIGNOBJECT_DRAWING() {
  43798. var value = typeof Array.from === 'function' && typeof window.fetch === 'function'
  43799. ? testForeignObject(document)
  43800. : Promise.resolve(false);
  43801. Object.defineProperty(FEATURES, 'SUPPORT_FOREIGNOBJECT_DRAWING', { value: value });
  43802. return value;
  43803. },
  43804. get SUPPORT_CORS_IMAGES() {
  43805. var value = testCORS();
  43806. Object.defineProperty(FEATURES, 'SUPPORT_CORS_IMAGES', { value: value });
  43807. return value;
  43808. },
  43809. get SUPPORT_RESPONSE_TYPE() {
  43810. var value = testResponseType();
  43811. Object.defineProperty(FEATURES, 'SUPPORT_RESPONSE_TYPE', { value: value });
  43812. return value;
  43813. },
  43814. get SUPPORT_CORS_XHR() {
  43815. var value = 'withCredentials' in new XMLHttpRequest();
  43816. Object.defineProperty(FEATURES, 'SUPPORT_CORS_XHR', { value: value });
  43817. return value;
  43818. },
  43819. get SUPPORT_NATIVE_TEXT_SEGMENTATION() {
  43820. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  43821. var value = !!(typeof Intl !== 'undefined' && Intl.Segmenter);
  43822. Object.defineProperty(FEATURES, 'SUPPORT_NATIVE_TEXT_SEGMENTATION', { value: value });
  43823. return value;
  43824. }
  43825. };
  43826. var TextBounds = /** @class */ (function () {
  43827. function TextBounds(text, bounds) {
  43828. this.text = text;
  43829. this.bounds = bounds;
  43830. }
  43831. return TextBounds;
  43832. }());
  43833. var parseTextBounds = function (context, value, styles, node) {
  43834. var textList = breakText(value, styles);
  43835. var textBounds = [];
  43836. var offset = 0;
  43837. textList.forEach(function (text) {
  43838. if (styles.textDecorationLine.length || text.trim().length > 0) {
  43839. if (FEATURES.SUPPORT_RANGE_BOUNDS) {
  43840. var clientRects = createRange(node, offset, text.length).getClientRects();
  43841. if (clientRects.length > 1) {
  43842. var subSegments = segmentGraphemes(text);
  43843. var subOffset_1 = 0;
  43844. subSegments.forEach(function (subSegment) {
  43845. textBounds.push(new TextBounds(subSegment, Bounds.fromDOMRectList(context, createRange(node, subOffset_1 + offset, subSegment.length).getClientRects())));
  43846. subOffset_1 += subSegment.length;
  43847. });
  43848. }
  43849. else {
  43850. textBounds.push(new TextBounds(text, Bounds.fromDOMRectList(context, clientRects)));
  43851. }
  43852. }
  43853. else {
  43854. var replacementNode = node.splitText(text.length);
  43855. textBounds.push(new TextBounds(text, getWrapperBounds(context, node)));
  43856. node = replacementNode;
  43857. }
  43858. }
  43859. else if (!FEATURES.SUPPORT_RANGE_BOUNDS) {
  43860. node = node.splitText(text.length);
  43861. }
  43862. offset += text.length;
  43863. });
  43864. return textBounds;
  43865. };
  43866. var getWrapperBounds = function (context, node) {
  43867. var ownerDocument = node.ownerDocument;
  43868. if (ownerDocument) {
  43869. var wrapper = ownerDocument.createElement('html2canvaswrapper');
  43870. wrapper.appendChild(node.cloneNode(true));
  43871. var parentNode = node.parentNode;
  43872. if (parentNode) {
  43873. parentNode.replaceChild(wrapper, node);
  43874. var bounds = parseBounds(context, wrapper);
  43875. if (wrapper.firstChild) {
  43876. parentNode.replaceChild(wrapper.firstChild, wrapper);
  43877. }
  43878. return bounds;
  43879. }
  43880. }
  43881. return Bounds.EMPTY;
  43882. };
  43883. var createRange = function (node, offset, length) {
  43884. var ownerDocument = node.ownerDocument;
  43885. if (!ownerDocument) {
  43886. throw new Error('Node has no owner document');
  43887. }
  43888. var range = ownerDocument.createRange();
  43889. range.setStart(node, offset);
  43890. range.setEnd(node, offset + length);
  43891. return range;
  43892. };
  43893. var segmentGraphemes = function (value) {
  43894. if (FEATURES.SUPPORT_NATIVE_TEXT_SEGMENTATION) {
  43895. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  43896. var segmenter = new Intl.Segmenter(void 0, { granularity: 'grapheme' });
  43897. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  43898. return Array.from(segmenter.segment(value)).map(function (segment) { return segment.segment; });
  43899. }
  43900. return splitGraphemes(value);
  43901. };
  43902. var segmentWords = function (value, styles) {
  43903. if (FEATURES.SUPPORT_NATIVE_TEXT_SEGMENTATION) {
  43904. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  43905. var segmenter = new Intl.Segmenter(void 0, {
  43906. granularity: 'word'
  43907. });
  43908. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  43909. return Array.from(segmenter.segment(value)).map(function (segment) { return segment.segment; });
  43910. }
  43911. return breakWords(value, styles);
  43912. };
  43913. var breakText = function (value, styles) {
  43914. return styles.letterSpacing !== 0 ? segmentGraphemes(value) : segmentWords(value, styles);
  43915. };
  43916. // https://drafts.csswg.org/css-text/#word-separator
  43917. var wordSeparators = [0x0020, 0x00a0, 0x1361, 0x10100, 0x10101, 0x1039, 0x1091];
  43918. var breakWords = function (str, styles) {
  43919. var breaker = LineBreaker(str, {
  43920. lineBreak: styles.lineBreak,
  43921. wordBreak: styles.overflowWrap === "break-word" /* BREAK_WORD */ ? 'break-word' : styles.wordBreak
  43922. });
  43923. var words = [];
  43924. var bk;
  43925. var _loop_1 = function () {
  43926. if (bk.value) {
  43927. var value = bk.value.slice();
  43928. var codePoints = toCodePoints$1(value);
  43929. var word_1 = '';
  43930. codePoints.forEach(function (codePoint) {
  43931. if (wordSeparators.indexOf(codePoint) === -1) {
  43932. word_1 += fromCodePoint$1(codePoint);
  43933. }
  43934. else {
  43935. if (word_1.length) {
  43936. words.push(word_1);
  43937. }
  43938. words.push(fromCodePoint$1(codePoint));
  43939. word_1 = '';
  43940. }
  43941. });
  43942. if (word_1.length) {
  43943. words.push(word_1);
  43944. }
  43945. }
  43946. };
  43947. while (!(bk = breaker.next()).done) {
  43948. _loop_1();
  43949. }
  43950. return words;
  43951. };
  43952. var TextContainer = /** @class */ (function () {
  43953. function TextContainer(context, node, styles) {
  43954. this.text = transform(node.data, styles.textTransform);
  43955. this.textBounds = parseTextBounds(context, this.text, styles, node);
  43956. }
  43957. return TextContainer;
  43958. }());
  43959. var transform = function (text, transform) {
  43960. switch (transform) {
  43961. case 1 /* LOWERCASE */:
  43962. return text.toLowerCase();
  43963. case 3 /* CAPITALIZE */:
  43964. return text.replace(CAPITALIZE, capitalize);
  43965. case 2 /* UPPERCASE */:
  43966. return text.toUpperCase();
  43967. default:
  43968. return text;
  43969. }
  43970. };
  43971. var CAPITALIZE = /(^|\s|:|-|\(|\))([a-z])/g;
  43972. var capitalize = function (m, p1, p2) {
  43973. if (m.length > 0) {
  43974. return p1 + p2.toUpperCase();
  43975. }
  43976. return m;
  43977. };
  43978. var ImageElementContainer = /** @class */ (function (_super) {
  43979. __extends(ImageElementContainer, _super);
  43980. function ImageElementContainer(context, img) {
  43981. var _this = _super.call(this, context, img) || this;
  43982. _this.src = img.currentSrc || img.src;
  43983. _this.intrinsicWidth = img.naturalWidth;
  43984. _this.intrinsicHeight = img.naturalHeight;
  43985. _this.context.cache.addImage(_this.src);
  43986. return _this;
  43987. }
  43988. return ImageElementContainer;
  43989. }(ElementContainer));
  43990. var CanvasElementContainer = /** @class */ (function (_super) {
  43991. __extends(CanvasElementContainer, _super);
  43992. function CanvasElementContainer(context, canvas) {
  43993. var _this = _super.call(this, context, canvas) || this;
  43994. _this.canvas = canvas;
  43995. _this.intrinsicWidth = canvas.width;
  43996. _this.intrinsicHeight = canvas.height;
  43997. return _this;
  43998. }
  43999. return CanvasElementContainer;
  44000. }(ElementContainer));
  44001. var SVGElementContainer = /** @class */ (function (_super) {
  44002. __extends(SVGElementContainer, _super);
  44003. function SVGElementContainer(context, img) {
  44004. var _this = _super.call(this, context, img) || this;
  44005. var s = new XMLSerializer();
  44006. var bounds = parseBounds(context, img);
  44007. img.setAttribute('width', bounds.width + "px");
  44008. img.setAttribute('height', bounds.height + "px");
  44009. _this.svg = "data:image/svg+xml," + encodeURIComponent(s.serializeToString(img));
  44010. _this.intrinsicWidth = img.width.baseVal.value;
  44011. _this.intrinsicHeight = img.height.baseVal.value;
  44012. _this.context.cache.addImage(_this.svg);
  44013. return _this;
  44014. }
  44015. return SVGElementContainer;
  44016. }(ElementContainer));
  44017. var LIElementContainer = /** @class */ (function (_super) {
  44018. __extends(LIElementContainer, _super);
  44019. function LIElementContainer(context, element) {
  44020. var _this = _super.call(this, context, element) || this;
  44021. _this.value = element.value;
  44022. return _this;
  44023. }
  44024. return LIElementContainer;
  44025. }(ElementContainer));
  44026. var OLElementContainer = /** @class */ (function (_super) {
  44027. __extends(OLElementContainer, _super);
  44028. function OLElementContainer(context, element) {
  44029. var _this = _super.call(this, context, element) || this;
  44030. _this.start = element.start;
  44031. _this.reversed = typeof element.reversed === 'boolean' && element.reversed === true;
  44032. return _this;
  44033. }
  44034. return OLElementContainer;
  44035. }(ElementContainer));
  44036. var CHECKBOX_BORDER_RADIUS = [
  44037. {
  44038. type: 15 /* DIMENSION_TOKEN */,
  44039. flags: 0,
  44040. unit: 'px',
  44041. number: 3
  44042. }
  44043. ];
  44044. var RADIO_BORDER_RADIUS = [
  44045. {
  44046. type: 16 /* PERCENTAGE_TOKEN */,
  44047. flags: 0,
  44048. number: 50
  44049. }
  44050. ];
  44051. var reformatInputBounds = function (bounds) {
  44052. if (bounds.width > bounds.height) {
  44053. return new Bounds(bounds.left + (bounds.width - bounds.height) / 2, bounds.top, bounds.height, bounds.height);
  44054. }
  44055. else if (bounds.width < bounds.height) {
  44056. return new Bounds(bounds.left, bounds.top + (bounds.height - bounds.width) / 2, bounds.width, bounds.width);
  44057. }
  44058. return bounds;
  44059. };
  44060. var getInputValue = function (node) {
  44061. var value = node.type === PASSWORD ? new Array(node.value.length + 1).join('\u2022') : node.value;
  44062. return value.length === 0 ? node.placeholder || '' : value;
  44063. };
  44064. var CHECKBOX = 'checkbox';
  44065. var RADIO = 'radio';
  44066. var PASSWORD = 'password';
  44067. var INPUT_COLOR = 0x2a2a2aff;
  44068. var InputElementContainer = /** @class */ (function (_super) {
  44069. __extends(InputElementContainer, _super);
  44070. function InputElementContainer(context, input) {
  44071. var _this = _super.call(this, context, input) || this;
  44072. _this.type = input.type.toLowerCase();
  44073. _this.checked = input.checked;
  44074. _this.value = getInputValue(input);
  44075. if (_this.type === CHECKBOX || _this.type === RADIO) {
  44076. _this.styles.backgroundColor = 0xdededeff;
  44077. _this.styles.borderTopColor =
  44078. _this.styles.borderRightColor =
  44079. _this.styles.borderBottomColor =
  44080. _this.styles.borderLeftColor =
  44081. 0xa5a5a5ff;
  44082. _this.styles.borderTopWidth =
  44083. _this.styles.borderRightWidth =
  44084. _this.styles.borderBottomWidth =
  44085. _this.styles.borderLeftWidth =
  44086. 1;
  44087. _this.styles.borderTopStyle =
  44088. _this.styles.borderRightStyle =
  44089. _this.styles.borderBottomStyle =
  44090. _this.styles.borderLeftStyle =
  44091. 1 /* SOLID */;
  44092. _this.styles.backgroundClip = [0 /* BORDER_BOX */];
  44093. _this.styles.backgroundOrigin = [0 /* BORDER_BOX */];
  44094. _this.bounds = reformatInputBounds(_this.bounds);
  44095. }
  44096. switch (_this.type) {
  44097. case CHECKBOX:
  44098. _this.styles.borderTopRightRadius =
  44099. _this.styles.borderTopLeftRadius =
  44100. _this.styles.borderBottomRightRadius =
  44101. _this.styles.borderBottomLeftRadius =
  44102. CHECKBOX_BORDER_RADIUS;
  44103. break;
  44104. case RADIO:
  44105. _this.styles.borderTopRightRadius =
  44106. _this.styles.borderTopLeftRadius =
  44107. _this.styles.borderBottomRightRadius =
  44108. _this.styles.borderBottomLeftRadius =
  44109. RADIO_BORDER_RADIUS;
  44110. break;
  44111. }
  44112. return _this;
  44113. }
  44114. return InputElementContainer;
  44115. }(ElementContainer));
  44116. var SelectElementContainer = /** @class */ (function (_super) {
  44117. __extends(SelectElementContainer, _super);
  44118. function SelectElementContainer(context, element) {
  44119. var _this = _super.call(this, context, element) || this;
  44120. var option = element.options[element.selectedIndex || 0];
  44121. _this.value = option ? option.text || '' : '';
  44122. return _this;
  44123. }
  44124. return SelectElementContainer;
  44125. }(ElementContainer));
  44126. var TextareaElementContainer = /** @class */ (function (_super) {
  44127. __extends(TextareaElementContainer, _super);
  44128. function TextareaElementContainer(context, element) {
  44129. var _this = _super.call(this, context, element) || this;
  44130. _this.value = element.value;
  44131. return _this;
  44132. }
  44133. return TextareaElementContainer;
  44134. }(ElementContainer));
  44135. var IFrameElementContainer = /** @class */ (function (_super) {
  44136. __extends(IFrameElementContainer, _super);
  44137. function IFrameElementContainer(context, iframe) {
  44138. var _this = _super.call(this, context, iframe) || this;
  44139. _this.src = iframe.src;
  44140. _this.width = parseInt(iframe.width, 10) || 0;
  44141. _this.height = parseInt(iframe.height, 10) || 0;
  44142. _this.backgroundColor = _this.styles.backgroundColor;
  44143. try {
  44144. if (iframe.contentWindow &&
  44145. iframe.contentWindow.document &&
  44146. iframe.contentWindow.document.documentElement) {
  44147. _this.tree = parseTree(context, iframe.contentWindow.document.documentElement);
  44148. // http://www.w3.org/TR/css3-background/#special-backgrounds
  44149. var documentBackgroundColor = iframe.contentWindow.document.documentElement
  44150. ? parseColor(context, getComputedStyle(iframe.contentWindow.document.documentElement).backgroundColor)
  44151. : COLORS.TRANSPARENT;
  44152. var bodyBackgroundColor = iframe.contentWindow.document.body
  44153. ? parseColor(context, getComputedStyle(iframe.contentWindow.document.body).backgroundColor)
  44154. : COLORS.TRANSPARENT;
  44155. _this.backgroundColor = isTransparent(documentBackgroundColor)
  44156. ? isTransparent(bodyBackgroundColor)
  44157. ? _this.styles.backgroundColor
  44158. : bodyBackgroundColor
  44159. : documentBackgroundColor;
  44160. }
  44161. }
  44162. catch (e) { }
  44163. return _this;
  44164. }
  44165. return IFrameElementContainer;
  44166. }(ElementContainer));
  44167. var LIST_OWNERS = ['OL', 'UL', 'MENU'];
  44168. var parseNodeTree = function (context, node, parent, root) {
  44169. for (var childNode = node.firstChild, nextNode = void 0; childNode; childNode = nextNode) {
  44170. nextNode = childNode.nextSibling;
  44171. if (isTextNode(childNode) && childNode.data.trim().length > 0) {
  44172. parent.textNodes.push(new TextContainer(context, childNode, parent.styles));
  44173. }
  44174. else if (isElementNode(childNode)) {
  44175. if (isSlotElement(childNode) && childNode.assignedNodes) {
  44176. childNode.assignedNodes().forEach(function (childNode) { return parseNodeTree(context, childNode, parent, root); });
  44177. }
  44178. else {
  44179. var container = createContainer(context, childNode);
  44180. if (container.styles.isVisible()) {
  44181. if (createsRealStackingContext(childNode, container, root)) {
  44182. container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;
  44183. }
  44184. else if (createsStackingContext(container.styles)) {
  44185. container.flags |= 2 /* CREATES_STACKING_CONTEXT */;
  44186. }
  44187. if (LIST_OWNERS.indexOf(childNode.tagName) !== -1) {
  44188. container.flags |= 8 /* IS_LIST_OWNER */;
  44189. }
  44190. parent.elements.push(container);
  44191. childNode.slot;
  44192. if (childNode.shadowRoot) {
  44193. parseNodeTree(context, childNode.shadowRoot, container, root);
  44194. }
  44195. else if (!isTextareaElement(childNode) &&
  44196. !isSVGElement(childNode) &&
  44197. !isSelectElement(childNode)) {
  44198. parseNodeTree(context, childNode, container, root);
  44199. }
  44200. }
  44201. }
  44202. }
  44203. }
  44204. };
  44205. var createContainer = function (context, element) {
  44206. if (isImageElement(element)) {
  44207. return new ImageElementContainer(context, element);
  44208. }
  44209. if (isCanvasElement(element)) {
  44210. return new CanvasElementContainer(context, element);
  44211. }
  44212. if (isSVGElement(element)) {
  44213. return new SVGElementContainer(context, element);
  44214. }
  44215. if (isLIElement(element)) {
  44216. return new LIElementContainer(context, element);
  44217. }
  44218. if (isOLElement(element)) {
  44219. return new OLElementContainer(context, element);
  44220. }
  44221. if (isInputElement(element)) {
  44222. return new InputElementContainer(context, element);
  44223. }
  44224. if (isSelectElement(element)) {
  44225. return new SelectElementContainer(context, element);
  44226. }
  44227. if (isTextareaElement(element)) {
  44228. return new TextareaElementContainer(context, element);
  44229. }
  44230. if (isIFrameElement(element)) {
  44231. return new IFrameElementContainer(context, element);
  44232. }
  44233. return new ElementContainer(context, element);
  44234. };
  44235. var parseTree = function (context, element) {
  44236. var container = createContainer(context, element);
  44237. container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;
  44238. parseNodeTree(context, element, container, container);
  44239. return container;
  44240. };
  44241. var createsRealStackingContext = function (node, container, root) {
  44242. return (container.styles.isPositionedWithZIndex() ||
  44243. container.styles.opacity < 1 ||
  44244. container.styles.isTransformed() ||
  44245. (isBodyElement(node) && root.styles.isTransparent()));
  44246. };
  44247. var createsStackingContext = function (styles) { return styles.isPositioned() || styles.isFloating(); };
  44248. var isTextNode = function (node) { return node.nodeType === Node.TEXT_NODE; };
  44249. var isElementNode = function (node) { return node.nodeType === Node.ELEMENT_NODE; };
  44250. var isHTMLElementNode = function (node) {
  44251. return isElementNode(node) && typeof node.style !== 'undefined' && !isSVGElementNode(node);
  44252. };
  44253. var isSVGElementNode = function (element) {
  44254. return typeof element.className === 'object';
  44255. };
  44256. var isLIElement = function (node) { return node.tagName === 'LI'; };
  44257. var isOLElement = function (node) { return node.tagName === 'OL'; };
  44258. var isInputElement = function (node) { return node.tagName === 'INPUT'; };
  44259. var isHTMLElement = function (node) { return node.tagName === 'HTML'; };
  44260. var isSVGElement = function (node) { return node.tagName === 'svg'; };
  44261. var isBodyElement = function (node) { return node.tagName === 'BODY'; };
  44262. var isCanvasElement = function (node) { return node.tagName === 'CANVAS'; };
  44263. var isVideoElement = function (node) { return node.tagName === 'VIDEO'; };
  44264. var isImageElement = function (node) { return node.tagName === 'IMG'; };
  44265. var isIFrameElement = function (node) { return node.tagName === 'IFRAME'; };
  44266. var isStyleElement = function (node) { return node.tagName === 'STYLE'; };
  44267. var isScriptElement = function (node) { return node.tagName === 'SCRIPT'; };
  44268. var isTextareaElement = function (node) { return node.tagName === 'TEXTAREA'; };
  44269. var isSelectElement = function (node) { return node.tagName === 'SELECT'; };
  44270. var isSlotElement = function (node) { return node.tagName === 'SLOT'; };
  44271. // https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
  44272. var isCustomElement = function (node) { return node.tagName.indexOf('-') > 0; };
  44273. var CounterState = /** @class */ (function () {
  44274. function CounterState() {
  44275. this.counters = {};
  44276. }
  44277. CounterState.prototype.getCounterValue = function (name) {
  44278. var counter = this.counters[name];
  44279. if (counter && counter.length) {
  44280. return counter[counter.length - 1];
  44281. }
  44282. return 1;
  44283. };
  44284. CounterState.prototype.getCounterValues = function (name) {
  44285. var counter = this.counters[name];
  44286. return counter ? counter : [];
  44287. };
  44288. CounterState.prototype.pop = function (counters) {
  44289. var _this = this;
  44290. counters.forEach(function (counter) { return _this.counters[counter].pop(); });
  44291. };
  44292. CounterState.prototype.parse = function (style) {
  44293. var _this = this;
  44294. var counterIncrement = style.counterIncrement;
  44295. var counterReset = style.counterReset;
  44296. var canReset = true;
  44297. if (counterIncrement !== null) {
  44298. counterIncrement.forEach(function (entry) {
  44299. var counter = _this.counters[entry.counter];
  44300. if (counter && entry.increment !== 0) {
  44301. canReset = false;
  44302. if (!counter.length) {
  44303. counter.push(1);
  44304. }
  44305. counter[Math.max(0, counter.length - 1)] += entry.increment;
  44306. }
  44307. });
  44308. }
  44309. var counterNames = [];
  44310. if (canReset) {
  44311. counterReset.forEach(function (entry) {
  44312. var counter = _this.counters[entry.counter];
  44313. counterNames.push(entry.counter);
  44314. if (!counter) {
  44315. counter = _this.counters[entry.counter] = [];
  44316. }
  44317. counter.push(entry.reset);
  44318. });
  44319. }
  44320. return counterNames;
  44321. };
  44322. return CounterState;
  44323. }());
  44324. var ROMAN_UPPER = {
  44325. integers: [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1],
  44326. values: ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
  44327. };
  44328. var ARMENIAN = {
  44329. integers: [
  44330. 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70,
  44331. 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
  44332. ],
  44333. values: [
  44334. 'Ք',
  44335. 'Փ',
  44336. 'Ւ',
  44337. 'Ց',
  44338. 'Ր',
  44339. 'Տ',
  44340. 'Վ',
  44341. 'Ս',
  44342. 'Ռ',
  44343. 'Ջ',
  44344. 'Պ',
  44345. 'Չ',
  44346. 'Ո',
  44347. 'Շ',
  44348. 'Ն',
  44349. 'Յ',
  44350. 'Մ',
  44351. 'Ճ',
  44352. 'Ղ',
  44353. 'Ձ',
  44354. 'Հ',
  44355. 'Կ',
  44356. 'Ծ',
  44357. 'Խ',
  44358. 'Լ',
  44359. 'Ի',
  44360. 'Ժ',
  44361. 'Թ',
  44362. 'Ը',
  44363. 'Է',
  44364. 'Զ',
  44365. 'Ե',
  44366. 'Դ',
  44367. 'Գ',
  44368. 'Բ',
  44369. 'Ա'
  44370. ]
  44371. };
  44372. var HEBREW = {
  44373. integers: [
  44374. 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20,
  44375. 19, 18, 17, 16, 15, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
  44376. ],
  44377. values: [
  44378. 'י׳',
  44379. 'ט׳',
  44380. 'ח׳',
  44381. 'ז׳',
  44382. 'ו׳',
  44383. 'ה׳',
  44384. 'ד׳',
  44385. 'ג׳',
  44386. 'ב׳',
  44387. 'א׳',
  44388. 'ת',
  44389. 'ש',
  44390. 'ר',
  44391. 'ק',
  44392. 'צ',
  44393. 'פ',
  44394. 'ע',
  44395. 'ס',
  44396. 'נ',
  44397. 'מ',
  44398. 'ל',
  44399. 'כ',
  44400. 'יט',
  44401. 'יח',
  44402. 'יז',
  44403. 'טז',
  44404. 'טו',
  44405. 'י',
  44406. 'ט',
  44407. 'ח',
  44408. 'ז',
  44409. 'ו',
  44410. 'ה',
  44411. 'ד',
  44412. 'ג',
  44413. 'ב',
  44414. 'א'
  44415. ]
  44416. };
  44417. var GEORGIAN = {
  44418. integers: [
  44419. 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90,
  44420. 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
  44421. ],
  44422. values: [
  44423. 'ჵ',
  44424. 'ჰ',
  44425. 'ჯ',
  44426. 'ჴ',
  44427. 'ხ',
  44428. 'ჭ',
  44429. 'წ',
  44430. 'ძ',
  44431. 'ც',
  44432. 'ჩ',
  44433. 'შ',
  44434. 'ყ',
  44435. 'ღ',
  44436. 'ქ',
  44437. 'ფ',
  44438. 'ჳ',
  44439. 'ტ',
  44440. 'ს',
  44441. 'რ',
  44442. 'ჟ',
  44443. 'პ',
  44444. 'ო',
  44445. 'ჲ',
  44446. 'ნ',
  44447. 'მ',
  44448. 'ლ',
  44449. 'კ',
  44450. 'ი',
  44451. 'თ',
  44452. 'ჱ',
  44453. 'ზ',
  44454. 'ვ',
  44455. 'ე',
  44456. 'დ',
  44457. 'გ',
  44458. 'ბ',
  44459. 'ა'
  44460. ]
  44461. };
  44462. var createAdditiveCounter = function (value, min, max, symbols, fallback, suffix) {
  44463. if (value < min || value > max) {
  44464. return createCounterText(value, fallback, suffix.length > 0);
  44465. }
  44466. return (symbols.integers.reduce(function (string, integer, index) {
  44467. while (value >= integer) {
  44468. value -= integer;
  44469. string += symbols.values[index];
  44470. }
  44471. return string;
  44472. }, '') + suffix);
  44473. };
  44474. var createCounterStyleWithSymbolResolver = function (value, codePointRangeLength, isNumeric, resolver) {
  44475. var string = '';
  44476. do {
  44477. if (!isNumeric) {
  44478. value--;
  44479. }
  44480. string = resolver(value) + string;
  44481. value /= codePointRangeLength;
  44482. } while (value * codePointRangeLength >= codePointRangeLength);
  44483. return string;
  44484. };
  44485. var createCounterStyleFromRange = function (value, codePointRangeStart, codePointRangeEnd, isNumeric, suffix) {
  44486. var codePointRangeLength = codePointRangeEnd - codePointRangeStart + 1;
  44487. return ((value < 0 ? '-' : '') +
  44488. (createCounterStyleWithSymbolResolver(Math.abs(value), codePointRangeLength, isNumeric, function (codePoint) {
  44489. return fromCodePoint$1(Math.floor(codePoint % codePointRangeLength) + codePointRangeStart);
  44490. }) +
  44491. suffix));
  44492. };
  44493. var createCounterStyleFromSymbols = function (value, symbols, suffix) {
  44494. if (suffix === void 0) { suffix = '. '; }
  44495. var codePointRangeLength = symbols.length;
  44496. return (createCounterStyleWithSymbolResolver(Math.abs(value), codePointRangeLength, false, function (codePoint) { return symbols[Math.floor(codePoint % codePointRangeLength)]; }) + suffix);
  44497. };
  44498. var CJK_ZEROS = 1 << 0;
  44499. var CJK_TEN_COEFFICIENTS = 1 << 1;
  44500. var CJK_TEN_HIGH_COEFFICIENTS = 1 << 2;
  44501. var CJK_HUNDRED_COEFFICIENTS = 1 << 3;
  44502. var createCJKCounter = function (value, numbers, multipliers, negativeSign, suffix, flags) {
  44503. if (value < -9999 || value > 9999) {
  44504. return createCounterText(value, 4 /* CJK_DECIMAL */, suffix.length > 0);
  44505. }
  44506. var tmp = Math.abs(value);
  44507. var string = suffix;
  44508. if (tmp === 0) {
  44509. return numbers[0] + string;
  44510. }
  44511. for (var digit = 0; tmp > 0 && digit <= 4; digit++) {
  44512. var coefficient = tmp % 10;
  44513. if (coefficient === 0 && contains(flags, CJK_ZEROS) && string !== '') {
  44514. string = numbers[coefficient] + string;
  44515. }
  44516. else if (coefficient > 1 ||
  44517. (coefficient === 1 && digit === 0) ||
  44518. (coefficient === 1 && digit === 1 && contains(flags, CJK_TEN_COEFFICIENTS)) ||
  44519. (coefficient === 1 && digit === 1 && contains(flags, CJK_TEN_HIGH_COEFFICIENTS) && value > 100) ||
  44520. (coefficient === 1 && digit > 1 && contains(flags, CJK_HUNDRED_COEFFICIENTS))) {
  44521. string = numbers[coefficient] + (digit > 0 ? multipliers[digit - 1] : '') + string;
  44522. }
  44523. else if (coefficient === 1 && digit > 0) {
  44524. string = multipliers[digit - 1] + string;
  44525. }
  44526. tmp = Math.floor(tmp / 10);
  44527. }
  44528. return (value < 0 ? negativeSign : '') + string;
  44529. };
  44530. var CHINESE_INFORMAL_MULTIPLIERS = '十百千萬';
  44531. var CHINESE_FORMAL_MULTIPLIERS = '拾佰仟萬';
  44532. var JAPANESE_NEGATIVE = 'マイナス';
  44533. var KOREAN_NEGATIVE = '마이너스';
  44534. var createCounterText = function (value, type, appendSuffix) {
  44535. var defaultSuffix = appendSuffix ? '. ' : '';
  44536. var cjkSuffix = appendSuffix ? '、' : '';
  44537. var koreanSuffix = appendSuffix ? ', ' : '';
  44538. var spaceSuffix = appendSuffix ? ' ' : '';
  44539. switch (type) {
  44540. case 0 /* DISC */:
  44541. return '•' + spaceSuffix;
  44542. case 1 /* CIRCLE */:
  44543. return '◦' + spaceSuffix;
  44544. case 2 /* SQUARE */:
  44545. return '◾' + spaceSuffix;
  44546. case 5 /* DECIMAL_LEADING_ZERO */:
  44547. var string = createCounterStyleFromRange(value, 48, 57, true, defaultSuffix);
  44548. return string.length < 4 ? "0" + string : string;
  44549. case 4 /* CJK_DECIMAL */:
  44550. return createCounterStyleFromSymbols(value, '〇一二三四五六七八九', cjkSuffix);
  44551. case 6 /* LOWER_ROMAN */:
  44552. return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, 3 /* DECIMAL */, defaultSuffix).toLowerCase();
  44553. case 7 /* UPPER_ROMAN */:
  44554. return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, 3 /* DECIMAL */, defaultSuffix);
  44555. case 8 /* LOWER_GREEK */:
  44556. return createCounterStyleFromRange(value, 945, 969, false, defaultSuffix);
  44557. case 9 /* LOWER_ALPHA */:
  44558. return createCounterStyleFromRange(value, 97, 122, false, defaultSuffix);
  44559. case 10 /* UPPER_ALPHA */:
  44560. return createCounterStyleFromRange(value, 65, 90, false, defaultSuffix);
  44561. case 11 /* ARABIC_INDIC */:
  44562. return createCounterStyleFromRange(value, 1632, 1641, true, defaultSuffix);
  44563. case 12 /* ARMENIAN */:
  44564. case 49 /* UPPER_ARMENIAN */:
  44565. return createAdditiveCounter(value, 1, 9999, ARMENIAN, 3 /* DECIMAL */, defaultSuffix);
  44566. case 35 /* LOWER_ARMENIAN */:
  44567. return createAdditiveCounter(value, 1, 9999, ARMENIAN, 3 /* DECIMAL */, defaultSuffix).toLowerCase();
  44568. case 13 /* BENGALI */:
  44569. return createCounterStyleFromRange(value, 2534, 2543, true, defaultSuffix);
  44570. case 14 /* CAMBODIAN */:
  44571. case 30 /* KHMER */:
  44572. return createCounterStyleFromRange(value, 6112, 6121, true, defaultSuffix);
  44573. case 15 /* CJK_EARTHLY_BRANCH */:
  44574. return createCounterStyleFromSymbols(value, '子丑寅卯辰巳午未申酉戌亥', cjkSuffix);
  44575. case 16 /* CJK_HEAVENLY_STEM */:
  44576. return createCounterStyleFromSymbols(value, '甲乙丙丁戊己庚辛壬癸', cjkSuffix);
  44577. case 17 /* CJK_IDEOGRAPHIC */:
  44578. case 48 /* TRAD_CHINESE_INFORMAL */:
  44579. return createCJKCounter(value, '零一二三四五六七八九', CHINESE_INFORMAL_MULTIPLIERS, '負', cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
  44580. case 47 /* TRAD_CHINESE_FORMAL */:
  44581. return createCJKCounter(value, '零壹貳參肆伍陸柒捌玖', CHINESE_FORMAL_MULTIPLIERS, '負', cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
  44582. case 42 /* SIMP_CHINESE_INFORMAL */:
  44583. return createCJKCounter(value, '零一二三四五六七八九', CHINESE_INFORMAL_MULTIPLIERS, '负', cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
  44584. case 41 /* SIMP_CHINESE_FORMAL */:
  44585. return createCJKCounter(value, '零壹贰叁肆伍陆柒捌玖', CHINESE_FORMAL_MULTIPLIERS, '负', cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
  44586. case 26 /* JAPANESE_INFORMAL */:
  44587. return createCJKCounter(value, '〇一二三四五六七八九', '十百千万', JAPANESE_NEGATIVE, cjkSuffix, 0);
  44588. case 25 /* JAPANESE_FORMAL */:
  44589. return createCJKCounter(value, '零壱弐参四伍六七八九', '拾百千万', JAPANESE_NEGATIVE, cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);
  44590. case 31 /* KOREAN_HANGUL_FORMAL */:
  44591. return createCJKCounter(value, '영일이삼사오육칠팔구', '십백천만', KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);
  44592. case 33 /* KOREAN_HANJA_INFORMAL */:
  44593. return createCJKCounter(value, '零一二三四五六七八九', '十百千萬', KOREAN_NEGATIVE, koreanSuffix, 0);
  44594. case 32 /* KOREAN_HANJA_FORMAL */:
  44595. return createCJKCounter(value, '零壹貳參四五六七八九', '拾百千', KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);
  44596. case 18 /* DEVANAGARI */:
  44597. return createCounterStyleFromRange(value, 0x966, 0x96f, true, defaultSuffix);
  44598. case 20 /* GEORGIAN */:
  44599. return createAdditiveCounter(value, 1, 19999, GEORGIAN, 3 /* DECIMAL */, defaultSuffix);
  44600. case 21 /* GUJARATI */:
  44601. return createCounterStyleFromRange(value, 0xae6, 0xaef, true, defaultSuffix);
  44602. case 22 /* GURMUKHI */:
  44603. return createCounterStyleFromRange(value, 0xa66, 0xa6f, true, defaultSuffix);
  44604. case 22 /* HEBREW */:
  44605. return createAdditiveCounter(value, 1, 10999, HEBREW, 3 /* DECIMAL */, defaultSuffix);
  44606. case 23 /* HIRAGANA */:
  44607. return createCounterStyleFromSymbols(value, 'あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん');
  44608. case 24 /* HIRAGANA_IROHA */:
  44609. return createCounterStyleFromSymbols(value, 'いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす');
  44610. case 27 /* KANNADA */:
  44611. return createCounterStyleFromRange(value, 0xce6, 0xcef, true, defaultSuffix);
  44612. case 28 /* KATAKANA */:
  44613. return createCounterStyleFromSymbols(value, 'アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン', cjkSuffix);
  44614. case 29 /* KATAKANA_IROHA */:
  44615. return createCounterStyleFromSymbols(value, 'イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス', cjkSuffix);
  44616. case 34 /* LAO */:
  44617. return createCounterStyleFromRange(value, 0xed0, 0xed9, true, defaultSuffix);
  44618. case 37 /* MONGOLIAN */:
  44619. return createCounterStyleFromRange(value, 0x1810, 0x1819, true, defaultSuffix);
  44620. case 38 /* MYANMAR */:
  44621. return createCounterStyleFromRange(value, 0x1040, 0x1049, true, defaultSuffix);
  44622. case 39 /* ORIYA */:
  44623. return createCounterStyleFromRange(value, 0xb66, 0xb6f, true, defaultSuffix);
  44624. case 40 /* PERSIAN */:
  44625. return createCounterStyleFromRange(value, 0x6f0, 0x6f9, true, defaultSuffix);
  44626. case 43 /* TAMIL */:
  44627. return createCounterStyleFromRange(value, 0xbe6, 0xbef, true, defaultSuffix);
  44628. case 44 /* TELUGU */:
  44629. return createCounterStyleFromRange(value, 0xc66, 0xc6f, true, defaultSuffix);
  44630. case 45 /* THAI */:
  44631. return createCounterStyleFromRange(value, 0xe50, 0xe59, true, defaultSuffix);
  44632. case 46 /* TIBETAN */:
  44633. return createCounterStyleFromRange(value, 0xf20, 0xf29, true, defaultSuffix);
  44634. case 3 /* DECIMAL */:
  44635. default:
  44636. return createCounterStyleFromRange(value, 48, 57, true, defaultSuffix);
  44637. }
  44638. };
  44639. var IGNORE_ATTRIBUTE = 'data-html2canvas-ignore';
  44640. var DocumentCloner = /** @class */ (function () {
  44641. function DocumentCloner(context, element, options) {
  44642. this.context = context;
  44643. this.options = options;
  44644. this.scrolledElements = [];
  44645. this.referenceElement = element;
  44646. this.counters = new CounterState();
  44647. this.quoteDepth = 0;
  44648. if (!element.ownerDocument) {
  44649. throw new Error('Cloned element does not have an owner document');
  44650. }
  44651. this.documentElement = this.cloneNode(element.ownerDocument.documentElement, false);
  44652. }
  44653. DocumentCloner.prototype.toIFrame = function (ownerDocument, windowSize) {
  44654. var _this = this;
  44655. var iframe = createIFrameContainer(ownerDocument, windowSize);
  44656. if (!iframe.contentWindow) {
  44657. return Promise.reject("Unable to find iframe window");
  44658. }
  44659. var scrollX = ownerDocument.defaultView.pageXOffset;
  44660. var scrollY = ownerDocument.defaultView.pageYOffset;
  44661. var cloneWindow = iframe.contentWindow;
  44662. var documentClone = cloneWindow.document;
  44663. /* Chrome doesn't detect relative background-images assigned in inline <style> sheets when fetched through getComputedStyle
  44664. if window url is about:blank, we can assign the url to current by writing onto the document
  44665. */
  44666. var iframeLoad = iframeLoader(iframe).then(function () { return __awaiter(_this, void 0, void 0, function () {
  44667. var onclone, referenceElement;
  44668. return __generator(this, function (_a) {
  44669. switch (_a.label) {
  44670. case 0:
  44671. this.scrolledElements.forEach(restoreNodeScroll);
  44672. if (cloneWindow) {
  44673. cloneWindow.scrollTo(windowSize.left, windowSize.top);
  44674. if (/(iPad|iPhone|iPod)/g.test(navigator.userAgent) &&
  44675. (cloneWindow.scrollY !== windowSize.top || cloneWindow.scrollX !== windowSize.left)) {
  44676. this.context.logger.warn('Unable to restore scroll position for cloned document');
  44677. this.context.windowBounds = this.context.windowBounds.add(cloneWindow.scrollX - windowSize.left, cloneWindow.scrollY - windowSize.top, 0, 0);
  44678. }
  44679. }
  44680. onclone = this.options.onclone;
  44681. referenceElement = this.clonedReferenceElement;
  44682. if (typeof referenceElement === 'undefined') {
  44683. return [2 /*return*/, Promise.reject("Error finding the " + this.referenceElement.nodeName + " in the cloned document")];
  44684. }
  44685. if (!(documentClone.fonts && documentClone.fonts.ready)) return [3 /*break*/, 2];
  44686. return [4 /*yield*/, documentClone.fonts.ready];
  44687. case 1:
  44688. _a.sent();
  44689. _a.label = 2;
  44690. case 2:
  44691. if (!/(AppleWebKit)/g.test(navigator.userAgent)) return [3 /*break*/, 4];
  44692. return [4 /*yield*/, imagesReady(documentClone)];
  44693. case 3:
  44694. _a.sent();
  44695. _a.label = 4;
  44696. case 4:
  44697. if (typeof onclone === 'function') {
  44698. return [2 /*return*/, Promise.resolve()
  44699. .then(function () { return onclone(documentClone, referenceElement); })
  44700. .then(function () { return iframe; })];
  44701. }
  44702. return [2 /*return*/, iframe];
  44703. }
  44704. });
  44705. }); });
  44706. documentClone.open();
  44707. documentClone.write(serializeDoctype(document.doctype) + "<html></html>");
  44708. // Chrome scrolls the parent document for some reason after the write to the cloned window???
  44709. restoreOwnerScroll(this.referenceElement.ownerDocument, scrollX, scrollY);
  44710. documentClone.replaceChild(documentClone.adoptNode(this.documentElement), documentClone.documentElement);
  44711. documentClone.close();
  44712. return iframeLoad;
  44713. };
  44714. DocumentCloner.prototype.createElementClone = function (node) {
  44715. if (isDebugging(node, 2 /* CLONE */)) {
  44716. debugger;
  44717. }
  44718. if (isCanvasElement(node)) {
  44719. return this.createCanvasClone(node);
  44720. }
  44721. if (isVideoElement(node)) {
  44722. return this.createVideoClone(node);
  44723. }
  44724. if (isStyleElement(node)) {
  44725. return this.createStyleClone(node);
  44726. }
  44727. var clone = node.cloneNode(false);
  44728. if (isImageElement(clone)) {
  44729. if (isImageElement(node) && node.currentSrc && node.currentSrc !== node.src) {
  44730. clone.src = node.currentSrc;
  44731. clone.srcset = '';
  44732. }
  44733. if (clone.loading === 'lazy') {
  44734. clone.loading = 'eager';
  44735. }
  44736. }
  44737. if (isCustomElement(clone)) {
  44738. return this.createCustomElementClone(clone);
  44739. }
  44740. return clone;
  44741. };
  44742. DocumentCloner.prototype.createCustomElementClone = function (node) {
  44743. var clone = document.createElement('html2canvascustomelement');
  44744. copyCSSStyles(node.style, clone);
  44745. return clone;
  44746. };
  44747. DocumentCloner.prototype.createStyleClone = function (node) {
  44748. try {
  44749. var sheet = node.sheet;
  44750. if (sheet && sheet.cssRules) {
  44751. var css = [].slice.call(sheet.cssRules, 0).reduce(function (css, rule) {
  44752. if (rule && typeof rule.cssText === 'string') {
  44753. return css + rule.cssText;
  44754. }
  44755. return css;
  44756. }, '');
  44757. var style = node.cloneNode(false);
  44758. style.textContent = css;
  44759. return style;
  44760. }
  44761. }
  44762. catch (e) {
  44763. // accessing node.sheet.cssRules throws a DOMException
  44764. this.context.logger.error('Unable to access cssRules property', e);
  44765. if (e.name !== 'SecurityError') {
  44766. throw e;
  44767. }
  44768. }
  44769. return node.cloneNode(false);
  44770. };
  44771. DocumentCloner.prototype.createCanvasClone = function (canvas) {
  44772. var _a;
  44773. if (this.options.inlineImages && canvas.ownerDocument) {
  44774. var img = canvas.ownerDocument.createElement('img');
  44775. try {
  44776. img.src = canvas.toDataURL();
  44777. return img;
  44778. }
  44779. catch (e) {
  44780. this.context.logger.info("Unable to inline canvas contents, canvas is tainted", canvas);
  44781. }
  44782. }
  44783. var clonedCanvas = canvas.cloneNode(false);
  44784. try {
  44785. clonedCanvas.width = canvas.width;
  44786. clonedCanvas.height = canvas.height;
  44787. var ctx = canvas.getContext('2d');
  44788. var clonedCtx = clonedCanvas.getContext('2d');
  44789. if (clonedCtx) {
  44790. if (!this.options.allowTaint && ctx) {
  44791. clonedCtx.putImageData(ctx.getImageData(0, 0, canvas.width, canvas.height), 0, 0);
  44792. }
  44793. else {
  44794. var gl = (_a = canvas.getContext('webgl2')) !== null && _a !== void 0 ? _a : canvas.getContext('webgl');
  44795. if (gl) {
  44796. var attribs = gl.getContextAttributes();
  44797. if ((attribs === null || attribs === void 0 ? void 0 : attribs.preserveDrawingBuffer) === false) {
  44798. this.context.logger.warn('Unable to clone WebGL context as it has preserveDrawingBuffer=false', canvas);
  44799. }
  44800. }
  44801. clonedCtx.drawImage(canvas, 0, 0);
  44802. }
  44803. }
  44804. return clonedCanvas;
  44805. }
  44806. catch (e) {
  44807. this.context.logger.info("Unable to clone canvas as it is tainted", canvas);
  44808. }
  44809. return clonedCanvas;
  44810. };
  44811. DocumentCloner.prototype.createVideoClone = function (video) {
  44812. var canvas = video.ownerDocument.createElement('canvas');
  44813. canvas.width = video.offsetWidth;
  44814. canvas.height = video.offsetHeight;
  44815. var ctx = canvas.getContext('2d');
  44816. try {
  44817. if (ctx) {
  44818. ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
  44819. if (!this.options.allowTaint) {
  44820. ctx.getImageData(0, 0, canvas.width, canvas.height);
  44821. }
  44822. }
  44823. return canvas;
  44824. }
  44825. catch (e) {
  44826. this.context.logger.info("Unable to clone video as it is tainted", video);
  44827. }
  44828. var blankCanvas = video.ownerDocument.createElement('canvas');
  44829. blankCanvas.width = video.offsetWidth;
  44830. blankCanvas.height = video.offsetHeight;
  44831. return blankCanvas;
  44832. };
  44833. DocumentCloner.prototype.appendChildNode = function (clone, child, copyStyles) {
  44834. if (!isElementNode(child) ||
  44835. (!isScriptElement(child) &&
  44836. !child.hasAttribute(IGNORE_ATTRIBUTE) &&
  44837. (typeof this.options.ignoreElements !== 'function' || !this.options.ignoreElements(child)))) {
  44838. if (!this.options.copyStyles || !isElementNode(child) || !isStyleElement(child)) {
  44839. clone.appendChild(this.cloneNode(child, copyStyles));
  44840. }
  44841. }
  44842. };
  44843. DocumentCloner.prototype.cloneChildNodes = function (node, clone, copyStyles) {
  44844. var _this = this;
  44845. for (var child = node.shadowRoot ? node.shadowRoot.firstChild : node.firstChild; child; child = child.nextSibling) {
  44846. if (isElementNode(child) && isSlotElement(child) && typeof child.assignedNodes === 'function') {
  44847. var assignedNodes = child.assignedNodes();
  44848. if (assignedNodes.length) {
  44849. assignedNodes.forEach(function (assignedNode) { return _this.appendChildNode(clone, assignedNode, copyStyles); });
  44850. }
  44851. }
  44852. else {
  44853. this.appendChildNode(clone, child, copyStyles);
  44854. }
  44855. }
  44856. };
  44857. DocumentCloner.prototype.cloneNode = function (node, copyStyles) {
  44858. if (isTextNode(node)) {
  44859. return document.createTextNode(node.data);
  44860. }
  44861. if (!node.ownerDocument) {
  44862. return node.cloneNode(false);
  44863. }
  44864. var window = node.ownerDocument.defaultView;
  44865. if (window && isElementNode(node) && (isHTMLElementNode(node) || isSVGElementNode(node))) {
  44866. var clone = this.createElementClone(node);
  44867. clone.style.transitionProperty = 'none';
  44868. var style = window.getComputedStyle(node);
  44869. var styleBefore = window.getComputedStyle(node, ':before');
  44870. var styleAfter = window.getComputedStyle(node, ':after');
  44871. if (this.referenceElement === node && isHTMLElementNode(clone)) {
  44872. this.clonedReferenceElement = clone;
  44873. }
  44874. if (isBodyElement(clone)) {
  44875. createPseudoHideStyles(clone);
  44876. }
  44877. var counters = this.counters.parse(new CSSParsedCounterDeclaration(this.context, style));
  44878. var before = this.resolvePseudoContent(node, clone, styleBefore, PseudoElementType.BEFORE);
  44879. if (isCustomElement(node)) {
  44880. copyStyles = true;
  44881. }
  44882. if (!isVideoElement(node)) {
  44883. this.cloneChildNodes(node, clone, copyStyles);
  44884. }
  44885. if (before) {
  44886. clone.insertBefore(before, clone.firstChild);
  44887. }
  44888. var after = this.resolvePseudoContent(node, clone, styleAfter, PseudoElementType.AFTER);
  44889. if (after) {
  44890. clone.appendChild(after);
  44891. }
  44892. this.counters.pop(counters);
  44893. if ((style && (this.options.copyStyles || isSVGElementNode(node)) && !isIFrameElement(node)) ||
  44894. copyStyles) {
  44895. copyCSSStyles(style, clone);
  44896. }
  44897. if (node.scrollTop !== 0 || node.scrollLeft !== 0) {
  44898. this.scrolledElements.push([clone, node.scrollLeft, node.scrollTop]);
  44899. }
  44900. if ((isTextareaElement(node) || isSelectElement(node)) &&
  44901. (isTextareaElement(clone) || isSelectElement(clone))) {
  44902. clone.value = node.value;
  44903. }
  44904. return clone;
  44905. }
  44906. return node.cloneNode(false);
  44907. };
  44908. DocumentCloner.prototype.resolvePseudoContent = function (node, clone, style, pseudoElt) {
  44909. var _this = this;
  44910. if (!style) {
  44911. return;
  44912. }
  44913. var value = style.content;
  44914. var document = clone.ownerDocument;
  44915. if (!document || !value || value === 'none' || value === '-moz-alt-content' || style.display === 'none') {
  44916. return;
  44917. }
  44918. this.counters.parse(new CSSParsedCounterDeclaration(this.context, style));
  44919. var declaration = new CSSParsedPseudoDeclaration(this.context, style);
  44920. var anonymousReplacedElement = document.createElement('html2canvaspseudoelement');
  44921. copyCSSStyles(style, anonymousReplacedElement);
  44922. declaration.content.forEach(function (token) {
  44923. if (token.type === 0 /* STRING_TOKEN */) {
  44924. anonymousReplacedElement.appendChild(document.createTextNode(token.value));
  44925. }
  44926. else if (token.type === 22 /* URL_TOKEN */) {
  44927. var img = document.createElement('img');
  44928. img.src = token.value;
  44929. img.style.opacity = '1';
  44930. anonymousReplacedElement.appendChild(img);
  44931. }
  44932. else if (token.type === 18 /* FUNCTION */) {
  44933. if (token.name === 'attr') {
  44934. var attr = token.values.filter(isIdentToken);
  44935. if (attr.length) {
  44936. anonymousReplacedElement.appendChild(document.createTextNode(node.getAttribute(attr[0].value) || ''));
  44937. }
  44938. }
  44939. else if (token.name === 'counter') {
  44940. var _a = token.values.filter(nonFunctionArgSeparator), counter = _a[0], counterStyle = _a[1];
  44941. if (counter && isIdentToken(counter)) {
  44942. var counterState = _this.counters.getCounterValue(counter.value);
  44943. var counterType = counterStyle && isIdentToken(counterStyle)
  44944. ? listStyleType.parse(_this.context, counterStyle.value)
  44945. : 3 /* DECIMAL */;
  44946. anonymousReplacedElement.appendChild(document.createTextNode(createCounterText(counterState, counterType, false)));
  44947. }
  44948. }
  44949. else if (token.name === 'counters') {
  44950. var _b = token.values.filter(nonFunctionArgSeparator), counter = _b[0], delim = _b[1], counterStyle = _b[2];
  44951. if (counter && isIdentToken(counter)) {
  44952. var counterStates = _this.counters.getCounterValues(counter.value);
  44953. var counterType_1 = counterStyle && isIdentToken(counterStyle)
  44954. ? listStyleType.parse(_this.context, counterStyle.value)
  44955. : 3 /* DECIMAL */;
  44956. var separator = delim && delim.type === 0 /* STRING_TOKEN */ ? delim.value : '';
  44957. var text = counterStates
  44958. .map(function (value) { return createCounterText(value, counterType_1, false); })
  44959. .join(separator);
  44960. anonymousReplacedElement.appendChild(document.createTextNode(text));
  44961. }
  44962. }
  44963. }
  44964. else if (token.type === 20 /* IDENT_TOKEN */) {
  44965. switch (token.value) {
  44966. case 'open-quote':
  44967. anonymousReplacedElement.appendChild(document.createTextNode(getQuote(declaration.quotes, _this.quoteDepth++, true)));
  44968. break;
  44969. case 'close-quote':
  44970. anonymousReplacedElement.appendChild(document.createTextNode(getQuote(declaration.quotes, --_this.quoteDepth, false)));
  44971. break;
  44972. default:
  44973. // safari doesn't parse string tokens correctly because of lack of quotes
  44974. anonymousReplacedElement.appendChild(document.createTextNode(token.value));
  44975. }
  44976. }
  44977. });
  44978. anonymousReplacedElement.className = PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + " " + PSEUDO_HIDE_ELEMENT_CLASS_AFTER;
  44979. var newClassName = pseudoElt === PseudoElementType.BEFORE
  44980. ? " " + PSEUDO_HIDE_ELEMENT_CLASS_BEFORE
  44981. : " " + PSEUDO_HIDE_ELEMENT_CLASS_AFTER;
  44982. if (isSVGElementNode(clone)) {
  44983. clone.className.baseValue += newClassName;
  44984. }
  44985. else {
  44986. clone.className += newClassName;
  44987. }
  44988. return anonymousReplacedElement;
  44989. };
  44990. DocumentCloner.destroy = function (container) {
  44991. if (container.parentNode) {
  44992. container.parentNode.removeChild(container);
  44993. return true;
  44994. }
  44995. return false;
  44996. };
  44997. return DocumentCloner;
  44998. }());
  44999. var PseudoElementType;
  45000. (function (PseudoElementType) {
  45001. PseudoElementType[PseudoElementType["BEFORE"] = 0] = "BEFORE";
  45002. PseudoElementType[PseudoElementType["AFTER"] = 1] = "AFTER";
  45003. })(PseudoElementType || (PseudoElementType = {}));
  45004. var createIFrameContainer = function (ownerDocument, bounds) {
  45005. var cloneIframeContainer = ownerDocument.createElement('iframe');
  45006. cloneIframeContainer.className = 'html2canvas-container';
  45007. cloneIframeContainer.style.visibility = 'hidden';
  45008. cloneIframeContainer.style.position = 'fixed';
  45009. cloneIframeContainer.style.left = '-10000px';
  45010. cloneIframeContainer.style.top = '0px';
  45011. cloneIframeContainer.style.border = '0';
  45012. cloneIframeContainer.width = bounds.width.toString();
  45013. cloneIframeContainer.height = bounds.height.toString();
  45014. cloneIframeContainer.scrolling = 'no'; // ios won't scroll without it
  45015. cloneIframeContainer.setAttribute(IGNORE_ATTRIBUTE, 'true');
  45016. ownerDocument.body.appendChild(cloneIframeContainer);
  45017. return cloneIframeContainer;
  45018. };
  45019. var imageReady = function (img) {
  45020. return new Promise(function (resolve) {
  45021. if (img.complete) {
  45022. resolve();
  45023. return;
  45024. }
  45025. if (!img.src) {
  45026. resolve();
  45027. return;
  45028. }
  45029. img.onload = resolve;
  45030. img.onerror = resolve;
  45031. });
  45032. };
  45033. var imagesReady = function (document) {
  45034. return Promise.all([].slice.call(document.images, 0).map(imageReady));
  45035. };
  45036. var iframeLoader = function (iframe) {
  45037. return new Promise(function (resolve, reject) {
  45038. var cloneWindow = iframe.contentWindow;
  45039. if (!cloneWindow) {
  45040. return reject("No window assigned for iframe");
  45041. }
  45042. var documentClone = cloneWindow.document;
  45043. cloneWindow.onload = iframe.onload = function () {
  45044. cloneWindow.onload = iframe.onload = null;
  45045. var interval = setInterval(function () {
  45046. if (documentClone.body.childNodes.length > 0 && documentClone.readyState === 'complete') {
  45047. clearInterval(interval);
  45048. resolve(iframe);
  45049. }
  45050. }, 50);
  45051. };
  45052. });
  45053. };
  45054. var ignoredStyleProperties = [
  45055. 'all',
  45056. 'd',
  45057. 'content' // Safari shows pseudoelements if content is set
  45058. ];
  45059. var copyCSSStyles = function (style, target) {
  45060. // Edge does not provide value for cssText
  45061. for (var i = style.length - 1; i >= 0; i--) {
  45062. var property = style.item(i);
  45063. if (ignoredStyleProperties.indexOf(property) === -1) {
  45064. target.style.setProperty(property, style.getPropertyValue(property));
  45065. }
  45066. }
  45067. return target;
  45068. };
  45069. var serializeDoctype = function (doctype) {
  45070. var str = '';
  45071. if (doctype) {
  45072. str += '<!DOCTYPE ';
  45073. if (doctype.name) {
  45074. str += doctype.name;
  45075. }
  45076. if (doctype.internalSubset) {
  45077. str += doctype.internalSubset;
  45078. }
  45079. if (doctype.publicId) {
  45080. str += "\"" + doctype.publicId + "\"";
  45081. }
  45082. if (doctype.systemId) {
  45083. str += "\"" + doctype.systemId + "\"";
  45084. }
  45085. str += '>';
  45086. }
  45087. return str;
  45088. };
  45089. var restoreOwnerScroll = function (ownerDocument, x, y) {
  45090. if (ownerDocument &&
  45091. ownerDocument.defaultView &&
  45092. (x !== ownerDocument.defaultView.pageXOffset || y !== ownerDocument.defaultView.pageYOffset)) {
  45093. ownerDocument.defaultView.scrollTo(x, y);
  45094. }
  45095. };
  45096. var restoreNodeScroll = function (_a) {
  45097. var element = _a[0], x = _a[1], y = _a[2];
  45098. element.scrollLeft = x;
  45099. element.scrollTop = y;
  45100. };
  45101. var PSEUDO_BEFORE = ':before';
  45102. var PSEUDO_AFTER = ':after';
  45103. var PSEUDO_HIDE_ELEMENT_CLASS_BEFORE = '___html2canvas___pseudoelement_before';
  45104. var PSEUDO_HIDE_ELEMENT_CLASS_AFTER = '___html2canvas___pseudoelement_after';
  45105. var PSEUDO_HIDE_ELEMENT_STYLE = "{\n content: \"\" !important;\n display: none !important;\n}";
  45106. var createPseudoHideStyles = function (body) {
  45107. createStyles(body, "." + PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + PSEUDO_BEFORE + PSEUDO_HIDE_ELEMENT_STYLE + "\n ." + PSEUDO_HIDE_ELEMENT_CLASS_AFTER + PSEUDO_AFTER + PSEUDO_HIDE_ELEMENT_STYLE);
  45108. };
  45109. var createStyles = function (body, styles) {
  45110. var document = body.ownerDocument;
  45111. if (document) {
  45112. var style = document.createElement('style');
  45113. style.textContent = styles;
  45114. body.appendChild(style);
  45115. }
  45116. };
  45117. var CacheStorage = /** @class */ (function () {
  45118. function CacheStorage() {
  45119. }
  45120. CacheStorage.getOrigin = function (url) {
  45121. var link = CacheStorage._link;
  45122. if (!link) {
  45123. return 'about:blank';
  45124. }
  45125. link.href = url;
  45126. link.href = link.href; // IE9, LOL! - http://jsfiddle.net/niklasvh/2e48b/
  45127. return link.protocol + link.hostname + link.port;
  45128. };
  45129. CacheStorage.isSameOrigin = function (src) {
  45130. return CacheStorage.getOrigin(src) === CacheStorage._origin;
  45131. };
  45132. CacheStorage.setContext = function (window) {
  45133. CacheStorage._link = window.document.createElement('a');
  45134. CacheStorage._origin = CacheStorage.getOrigin(window.location.href);
  45135. };
  45136. CacheStorage._origin = 'about:blank';
  45137. return CacheStorage;
  45138. }());
  45139. var Cache = /** @class */ (function () {
  45140. function Cache(context, _options) {
  45141. this.context = context;
  45142. this._options = _options;
  45143. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  45144. this._cache = {};
  45145. }
  45146. Cache.prototype.addImage = function (src) {
  45147. var result = Promise.resolve();
  45148. if (this.has(src)) {
  45149. return result;
  45150. }
  45151. if (isBlobImage(src) || isRenderable(src)) {
  45152. (this._cache[src] = this.loadImage(src)).catch(function () {
  45153. // prevent unhandled rejection
  45154. });
  45155. return result;
  45156. }
  45157. return result;
  45158. };
  45159. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  45160. Cache.prototype.match = function (src) {
  45161. return this._cache[src];
  45162. };
  45163. Cache.prototype.loadImage = function (key) {
  45164. return __awaiter(this, void 0, void 0, function () {
  45165. var isSameOrigin, useCORS, useProxy, src;
  45166. var _this = this;
  45167. return __generator(this, function (_a) {
  45168. switch (_a.label) {
  45169. case 0:
  45170. isSameOrigin = CacheStorage.isSameOrigin(key);
  45171. useCORS = !isInlineImage(key) && this._options.useCORS === true && FEATURES.SUPPORT_CORS_IMAGES && !isSameOrigin;
  45172. useProxy = !isInlineImage(key) &&
  45173. !isSameOrigin &&
  45174. !isBlobImage(key) &&
  45175. typeof this._options.proxy === 'string' &&
  45176. FEATURES.SUPPORT_CORS_XHR &&
  45177. !useCORS;
  45178. if (!isSameOrigin &&
  45179. this._options.allowTaint === false &&
  45180. !isInlineImage(key) &&
  45181. !isBlobImage(key) &&
  45182. !useProxy &&
  45183. !useCORS) {
  45184. return [2 /*return*/];
  45185. }
  45186. src = key;
  45187. if (!useProxy) return [3 /*break*/, 2];
  45188. return [4 /*yield*/, this.proxy(src)];
  45189. case 1:
  45190. src = _a.sent();
  45191. _a.label = 2;
  45192. case 2:
  45193. this.context.logger.debug("Added image " + key.substring(0, 256));
  45194. return [4 /*yield*/, new Promise(function (resolve, reject) {
  45195. var img = new Image();
  45196. img.onload = function () { return resolve(img); };
  45197. img.onerror = reject;
  45198. //ios safari 10.3 taints canvas with data urls unless crossOrigin is set to anonymous
  45199. if (isInlineBase64Image(src) || useCORS) {
  45200. img.crossOrigin = 'anonymous';
  45201. }
  45202. img.src = src;
  45203. if (img.complete === true) {
  45204. // Inline XML images may fail to parse, throwing an Error later on
  45205. setTimeout(function () { return resolve(img); }, 500);
  45206. }
  45207. if (_this._options.imageTimeout > 0) {
  45208. setTimeout(function () { return reject("Timed out (" + _this._options.imageTimeout + "ms) loading image"); }, _this._options.imageTimeout);
  45209. }
  45210. })];
  45211. case 3: return [2 /*return*/, _a.sent()];
  45212. }
  45213. });
  45214. });
  45215. };
  45216. Cache.prototype.has = function (key) {
  45217. return typeof this._cache[key] !== 'undefined';
  45218. };
  45219. Cache.prototype.keys = function () {
  45220. return Promise.resolve(Object.keys(this._cache));
  45221. };
  45222. Cache.prototype.proxy = function (src) {
  45223. var _this = this;
  45224. var proxy = this._options.proxy;
  45225. if (!proxy) {
  45226. throw new Error('No proxy defined');
  45227. }
  45228. var key = src.substring(0, 256);
  45229. return new Promise(function (resolve, reject) {
  45230. var responseType = FEATURES.SUPPORT_RESPONSE_TYPE ? 'blob' : 'text';
  45231. var xhr = new XMLHttpRequest();
  45232. xhr.onload = function () {
  45233. if (xhr.status === 200) {
  45234. if (responseType === 'text') {
  45235. resolve(xhr.response);
  45236. }
  45237. else {
  45238. var reader_1 = new FileReader();
  45239. reader_1.addEventListener('load', function () { return resolve(reader_1.result); }, false);
  45240. reader_1.addEventListener('error', function (e) { return reject(e); }, false);
  45241. reader_1.readAsDataURL(xhr.response);
  45242. }
  45243. }
  45244. else {
  45245. reject("Failed to proxy resource " + key + " with status code " + xhr.status);
  45246. }
  45247. };
  45248. xhr.onerror = reject;
  45249. var queryString = proxy.indexOf('?') > -1 ? '&' : '?';
  45250. xhr.open('GET', "" + proxy + queryString + "url=" + encodeURIComponent(src) + "&responseType=" + responseType);
  45251. if (responseType !== 'text' && xhr instanceof XMLHttpRequest) {
  45252. xhr.responseType = responseType;
  45253. }
  45254. if (_this._options.imageTimeout) {
  45255. var timeout_1 = _this._options.imageTimeout;
  45256. xhr.timeout = timeout_1;
  45257. xhr.ontimeout = function () { return reject("Timed out (" + timeout_1 + "ms) proxying " + key); };
  45258. }
  45259. xhr.send();
  45260. });
  45261. };
  45262. return Cache;
  45263. }());
  45264. var INLINE_SVG = /^data:image\/svg\+xml/i;
  45265. var INLINE_BASE64 = /^data:image\/.*;base64,/i;
  45266. var INLINE_IMG = /^data:image\/.*/i;
  45267. var isRenderable = function (src) { return FEATURES.SUPPORT_SVG_DRAWING || !isSVG(src); };
  45268. var isInlineImage = function (src) { return INLINE_IMG.test(src); };
  45269. var isInlineBase64Image = function (src) { return INLINE_BASE64.test(src); };
  45270. var isBlobImage = function (src) { return src.substr(0, 4) === 'blob'; };
  45271. var isSVG = function (src) { return src.substr(-3).toLowerCase() === 'svg' || INLINE_SVG.test(src); };
  45272. var Vector = /** @class */ (function () {
  45273. function Vector(x, y) {
  45274. this.type = 0 /* VECTOR */;
  45275. this.x = x;
  45276. this.y = y;
  45277. }
  45278. Vector.prototype.add = function (deltaX, deltaY) {
  45279. return new Vector(this.x + deltaX, this.y + deltaY);
  45280. };
  45281. return Vector;
  45282. }());
  45283. var lerp = function (a, b, t) {
  45284. return new Vector(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t);
  45285. };
  45286. var BezierCurve = /** @class */ (function () {
  45287. function BezierCurve(start, startControl, endControl, end) {
  45288. this.type = 1 /* BEZIER_CURVE */;
  45289. this.start = start;
  45290. this.startControl = startControl;
  45291. this.endControl = endControl;
  45292. this.end = end;
  45293. }
  45294. BezierCurve.prototype.subdivide = function (t, firstHalf) {
  45295. var ab = lerp(this.start, this.startControl, t);
  45296. var bc = lerp(this.startControl, this.endControl, t);
  45297. var cd = lerp(this.endControl, this.end, t);
  45298. var abbc = lerp(ab, bc, t);
  45299. var bccd = lerp(bc, cd, t);
  45300. var dest = lerp(abbc, bccd, t);
  45301. return firstHalf ? new BezierCurve(this.start, ab, abbc, dest) : new BezierCurve(dest, bccd, cd, this.end);
  45302. };
  45303. BezierCurve.prototype.add = function (deltaX, deltaY) {
  45304. return new BezierCurve(this.start.add(deltaX, deltaY), this.startControl.add(deltaX, deltaY), this.endControl.add(deltaX, deltaY), this.end.add(deltaX, deltaY));
  45305. };
  45306. BezierCurve.prototype.reverse = function () {
  45307. return new BezierCurve(this.end, this.endControl, this.startControl, this.start);
  45308. };
  45309. return BezierCurve;
  45310. }());
  45311. var isBezierCurve = function (path) { return path.type === 1 /* BEZIER_CURVE */; };
  45312. var BoundCurves = /** @class */ (function () {
  45313. function BoundCurves(element) {
  45314. var styles = element.styles;
  45315. var bounds = element.bounds;
  45316. var _a = getAbsoluteValueForTuple(styles.borderTopLeftRadius, bounds.width, bounds.height), tlh = _a[0], tlv = _a[1];
  45317. var _b = getAbsoluteValueForTuple(styles.borderTopRightRadius, bounds.width, bounds.height), trh = _b[0], trv = _b[1];
  45318. var _c = getAbsoluteValueForTuple(styles.borderBottomRightRadius, bounds.width, bounds.height), brh = _c[0], brv = _c[1];
  45319. var _d = getAbsoluteValueForTuple(styles.borderBottomLeftRadius, bounds.width, bounds.height), blh = _d[0], blv = _d[1];
  45320. var factors = [];
  45321. factors.push((tlh + trh) / bounds.width);
  45322. factors.push((blh + brh) / bounds.width);
  45323. factors.push((tlv + blv) / bounds.height);
  45324. factors.push((trv + brv) / bounds.height);
  45325. var maxFactor = Math.max.apply(Math, factors);
  45326. if (maxFactor > 1) {
  45327. tlh /= maxFactor;
  45328. tlv /= maxFactor;
  45329. trh /= maxFactor;
  45330. trv /= maxFactor;
  45331. brh /= maxFactor;
  45332. brv /= maxFactor;
  45333. blh /= maxFactor;
  45334. blv /= maxFactor;
  45335. }
  45336. var topWidth = bounds.width - trh;
  45337. var rightHeight = bounds.height - brv;
  45338. var bottomWidth = bounds.width - brh;
  45339. var leftHeight = bounds.height - blv;
  45340. var borderTopWidth = styles.borderTopWidth;
  45341. var borderRightWidth = styles.borderRightWidth;
  45342. var borderBottomWidth = styles.borderBottomWidth;
  45343. var borderLeftWidth = styles.borderLeftWidth;
  45344. var paddingTop = getAbsoluteValue(styles.paddingTop, element.bounds.width);
  45345. var paddingRight = getAbsoluteValue(styles.paddingRight, element.bounds.width);
  45346. var paddingBottom = getAbsoluteValue(styles.paddingBottom, element.bounds.width);
  45347. var paddingLeft = getAbsoluteValue(styles.paddingLeft, element.bounds.width);
  45348. this.topLeftBorderDoubleOuterBox =
  45349. tlh > 0 || tlv > 0
  45350. ? getCurvePoints(bounds.left + borderLeftWidth / 3, bounds.top + borderTopWidth / 3, tlh - borderLeftWidth / 3, tlv - borderTopWidth / 3, CORNER.TOP_LEFT)
  45351. : new Vector(bounds.left + borderLeftWidth / 3, bounds.top + borderTopWidth / 3);
  45352. this.topRightBorderDoubleOuterBox =
  45353. tlh > 0 || tlv > 0
  45354. ? getCurvePoints(bounds.left + topWidth, bounds.top + borderTopWidth / 3, trh - borderRightWidth / 3, trv - borderTopWidth / 3, CORNER.TOP_RIGHT)
  45355. : new Vector(bounds.left + bounds.width - borderRightWidth / 3, bounds.top + borderTopWidth / 3);
  45356. this.bottomRightBorderDoubleOuterBox =
  45357. brh > 0 || brv > 0
  45358. ? getCurvePoints(bounds.left + bottomWidth, bounds.top + rightHeight, brh - borderRightWidth / 3, brv - borderBottomWidth / 3, CORNER.BOTTOM_RIGHT)
  45359. : new Vector(bounds.left + bounds.width - borderRightWidth / 3, bounds.top + bounds.height - borderBottomWidth / 3);
  45360. this.bottomLeftBorderDoubleOuterBox =
  45361. blh > 0 || blv > 0
  45362. ? getCurvePoints(bounds.left + borderLeftWidth / 3, bounds.top + leftHeight, blh - borderLeftWidth / 3, blv - borderBottomWidth / 3, CORNER.BOTTOM_LEFT)
  45363. : new Vector(bounds.left + borderLeftWidth / 3, bounds.top + bounds.height - borderBottomWidth / 3);
  45364. this.topLeftBorderDoubleInnerBox =
  45365. tlh > 0 || tlv > 0
  45366. ? getCurvePoints(bounds.left + (borderLeftWidth * 2) / 3, bounds.top + (borderTopWidth * 2) / 3, tlh - (borderLeftWidth * 2) / 3, tlv - (borderTopWidth * 2) / 3, CORNER.TOP_LEFT)
  45367. : new Vector(bounds.left + (borderLeftWidth * 2) / 3, bounds.top + (borderTopWidth * 2) / 3);
  45368. this.topRightBorderDoubleInnerBox =
  45369. tlh > 0 || tlv > 0
  45370. ? getCurvePoints(bounds.left + topWidth, bounds.top + (borderTopWidth * 2) / 3, trh - (borderRightWidth * 2) / 3, trv - (borderTopWidth * 2) / 3, CORNER.TOP_RIGHT)
  45371. : new Vector(bounds.left + bounds.width - (borderRightWidth * 2) / 3, bounds.top + (borderTopWidth * 2) / 3);
  45372. this.bottomRightBorderDoubleInnerBox =
  45373. brh > 0 || brv > 0
  45374. ? getCurvePoints(bounds.left + bottomWidth, bounds.top + rightHeight, brh - (borderRightWidth * 2) / 3, brv - (borderBottomWidth * 2) / 3, CORNER.BOTTOM_RIGHT)
  45375. : new Vector(bounds.left + bounds.width - (borderRightWidth * 2) / 3, bounds.top + bounds.height - (borderBottomWidth * 2) / 3);
  45376. this.bottomLeftBorderDoubleInnerBox =
  45377. blh > 0 || blv > 0
  45378. ? getCurvePoints(bounds.left + (borderLeftWidth * 2) / 3, bounds.top + leftHeight, blh - (borderLeftWidth * 2) / 3, blv - (borderBottomWidth * 2) / 3, CORNER.BOTTOM_LEFT)
  45379. : new Vector(bounds.left + (borderLeftWidth * 2) / 3, bounds.top + bounds.height - (borderBottomWidth * 2) / 3);
  45380. this.topLeftBorderStroke =
  45381. tlh > 0 || tlv > 0
  45382. ? getCurvePoints(bounds.left + borderLeftWidth / 2, bounds.top + borderTopWidth / 2, tlh - borderLeftWidth / 2, tlv - borderTopWidth / 2, CORNER.TOP_LEFT)
  45383. : new Vector(bounds.left + borderLeftWidth / 2, bounds.top + borderTopWidth / 2);
  45384. this.topRightBorderStroke =
  45385. tlh > 0 || tlv > 0
  45386. ? getCurvePoints(bounds.left + topWidth, bounds.top + borderTopWidth / 2, trh - borderRightWidth / 2, trv - borderTopWidth / 2, CORNER.TOP_RIGHT)
  45387. : new Vector(bounds.left + bounds.width - borderRightWidth / 2, bounds.top + borderTopWidth / 2);
  45388. this.bottomRightBorderStroke =
  45389. brh > 0 || brv > 0
  45390. ? getCurvePoints(bounds.left + bottomWidth, bounds.top + rightHeight, brh - borderRightWidth / 2, brv - borderBottomWidth / 2, CORNER.BOTTOM_RIGHT)
  45391. : new Vector(bounds.left + bounds.width - borderRightWidth / 2, bounds.top + bounds.height - borderBottomWidth / 2);
  45392. this.bottomLeftBorderStroke =
  45393. blh > 0 || blv > 0
  45394. ? getCurvePoints(bounds.left + borderLeftWidth / 2, bounds.top + leftHeight, blh - borderLeftWidth / 2, blv - borderBottomWidth / 2, CORNER.BOTTOM_LEFT)
  45395. : new Vector(bounds.left + borderLeftWidth / 2, bounds.top + bounds.height - borderBottomWidth / 2);
  45396. this.topLeftBorderBox =
  45397. tlh > 0 || tlv > 0
  45398. ? getCurvePoints(bounds.left, bounds.top, tlh, tlv, CORNER.TOP_LEFT)
  45399. : new Vector(bounds.left, bounds.top);
  45400. this.topRightBorderBox =
  45401. trh > 0 || trv > 0
  45402. ? getCurvePoints(bounds.left + topWidth, bounds.top, trh, trv, CORNER.TOP_RIGHT)
  45403. : new Vector(bounds.left + bounds.width, bounds.top);
  45404. this.bottomRightBorderBox =
  45405. brh > 0 || brv > 0
  45406. ? getCurvePoints(bounds.left + bottomWidth, bounds.top + rightHeight, brh, brv, CORNER.BOTTOM_RIGHT)
  45407. : new Vector(bounds.left + bounds.width, bounds.top + bounds.height);
  45408. this.bottomLeftBorderBox =
  45409. blh > 0 || blv > 0
  45410. ? getCurvePoints(bounds.left, bounds.top + leftHeight, blh, blv, CORNER.BOTTOM_LEFT)
  45411. : new Vector(bounds.left, bounds.top + bounds.height);
  45412. this.topLeftPaddingBox =
  45413. tlh > 0 || tlv > 0
  45414. ? getCurvePoints(bounds.left + borderLeftWidth, bounds.top + borderTopWidth, Math.max(0, tlh - borderLeftWidth), Math.max(0, tlv - borderTopWidth), CORNER.TOP_LEFT)
  45415. : new Vector(bounds.left + borderLeftWidth, bounds.top + borderTopWidth);
  45416. this.topRightPaddingBox =
  45417. trh > 0 || trv > 0
  45418. ? getCurvePoints(bounds.left + Math.min(topWidth, bounds.width - borderRightWidth), bounds.top + borderTopWidth, topWidth > bounds.width + borderRightWidth ? 0 : Math.max(0, trh - borderRightWidth), Math.max(0, trv - borderTopWidth), CORNER.TOP_RIGHT)
  45419. : new Vector(bounds.left + bounds.width - borderRightWidth, bounds.top + borderTopWidth);
  45420. this.bottomRightPaddingBox =
  45421. brh > 0 || brv > 0
  45422. ? getCurvePoints(bounds.left + Math.min(bottomWidth, bounds.width - borderLeftWidth), bounds.top + Math.min(rightHeight, bounds.height - borderBottomWidth), Math.max(0, brh - borderRightWidth), Math.max(0, brv - borderBottomWidth), CORNER.BOTTOM_RIGHT)
  45423. : new Vector(bounds.left + bounds.width - borderRightWidth, bounds.top + bounds.height - borderBottomWidth);
  45424. this.bottomLeftPaddingBox =
  45425. blh > 0 || blv > 0
  45426. ? getCurvePoints(bounds.left + borderLeftWidth, bounds.top + Math.min(leftHeight, bounds.height - borderBottomWidth), Math.max(0, blh - borderLeftWidth), Math.max(0, blv - borderBottomWidth), CORNER.BOTTOM_LEFT)
  45427. : new Vector(bounds.left + borderLeftWidth, bounds.top + bounds.height - borderBottomWidth);
  45428. this.topLeftContentBox =
  45429. tlh > 0 || tlv > 0
  45430. ? getCurvePoints(bounds.left + borderLeftWidth + paddingLeft, bounds.top + borderTopWidth + paddingTop, Math.max(0, tlh - (borderLeftWidth + paddingLeft)), Math.max(0, tlv - (borderTopWidth + paddingTop)), CORNER.TOP_LEFT)
  45431. : new Vector(bounds.left + borderLeftWidth + paddingLeft, bounds.top + borderTopWidth + paddingTop);
  45432. this.topRightContentBox =
  45433. trh > 0 || trv > 0
  45434. ? getCurvePoints(bounds.left + Math.min(topWidth, bounds.width + borderLeftWidth + paddingLeft), bounds.top + borderTopWidth + paddingTop, topWidth > bounds.width + borderLeftWidth + paddingLeft ? 0 : trh - borderLeftWidth + paddingLeft, trv - (borderTopWidth + paddingTop), CORNER.TOP_RIGHT)
  45435. : new Vector(bounds.left + bounds.width - (borderRightWidth + paddingRight), bounds.top + borderTopWidth + paddingTop);
  45436. this.bottomRightContentBox =
  45437. brh > 0 || brv > 0
  45438. ? getCurvePoints(bounds.left + Math.min(bottomWidth, bounds.width - (borderLeftWidth + paddingLeft)), bounds.top + Math.min(rightHeight, bounds.height + borderTopWidth + paddingTop), Math.max(0, brh - (borderRightWidth + paddingRight)), brv - (borderBottomWidth + paddingBottom), CORNER.BOTTOM_RIGHT)
  45439. : new Vector(bounds.left + bounds.width - (borderRightWidth + paddingRight), bounds.top + bounds.height - (borderBottomWidth + paddingBottom));
  45440. this.bottomLeftContentBox =
  45441. blh > 0 || blv > 0
  45442. ? getCurvePoints(bounds.left + borderLeftWidth + paddingLeft, bounds.top + leftHeight, Math.max(0, blh - (borderLeftWidth + paddingLeft)), blv - (borderBottomWidth + paddingBottom), CORNER.BOTTOM_LEFT)
  45443. : new Vector(bounds.left + borderLeftWidth + paddingLeft, bounds.top + bounds.height - (borderBottomWidth + paddingBottom));
  45444. }
  45445. return BoundCurves;
  45446. }());
  45447. var CORNER;
  45448. (function (CORNER) {
  45449. CORNER[CORNER["TOP_LEFT"] = 0] = "TOP_LEFT";
  45450. CORNER[CORNER["TOP_RIGHT"] = 1] = "TOP_RIGHT";
  45451. CORNER[CORNER["BOTTOM_RIGHT"] = 2] = "BOTTOM_RIGHT";
  45452. CORNER[CORNER["BOTTOM_LEFT"] = 3] = "BOTTOM_LEFT";
  45453. })(CORNER || (CORNER = {}));
  45454. var getCurvePoints = function (x, y, r1, r2, position) {
  45455. var kappa = 4 * ((Math.sqrt(2) - 1) / 3);
  45456. var ox = r1 * kappa; // control point offset horizontal
  45457. var oy = r2 * kappa; // control point offset vertical
  45458. var xm = x + r1; // x-middle
  45459. var ym = y + r2; // y-middle
  45460. switch (position) {
  45461. case CORNER.TOP_LEFT:
  45462. return new BezierCurve(new Vector(x, ym), new Vector(x, ym - oy), new Vector(xm - ox, y), new Vector(xm, y));
  45463. case CORNER.TOP_RIGHT:
  45464. return new BezierCurve(new Vector(x, y), new Vector(x + ox, y), new Vector(xm, ym - oy), new Vector(xm, ym));
  45465. case CORNER.BOTTOM_RIGHT:
  45466. return new BezierCurve(new Vector(xm, y), new Vector(xm, y + oy), new Vector(x + ox, ym), new Vector(x, ym));
  45467. case CORNER.BOTTOM_LEFT:
  45468. default:
  45469. return new BezierCurve(new Vector(xm, ym), new Vector(xm - ox, ym), new Vector(x, y + oy), new Vector(x, y));
  45470. }
  45471. };
  45472. var calculateBorderBoxPath = function (curves) {
  45473. return [curves.topLeftBorderBox, curves.topRightBorderBox, curves.bottomRightBorderBox, curves.bottomLeftBorderBox];
  45474. };
  45475. var calculateContentBoxPath = function (curves) {
  45476. return [
  45477. curves.topLeftContentBox,
  45478. curves.topRightContentBox,
  45479. curves.bottomRightContentBox,
  45480. curves.bottomLeftContentBox
  45481. ];
  45482. };
  45483. var calculatePaddingBoxPath = function (curves) {
  45484. return [
  45485. curves.topLeftPaddingBox,
  45486. curves.topRightPaddingBox,
  45487. curves.bottomRightPaddingBox,
  45488. curves.bottomLeftPaddingBox
  45489. ];
  45490. };
  45491. var TransformEffect = /** @class */ (function () {
  45492. function TransformEffect(offsetX, offsetY, matrix) {
  45493. this.offsetX = offsetX;
  45494. this.offsetY = offsetY;
  45495. this.matrix = matrix;
  45496. this.type = 0 /* TRANSFORM */;
  45497. this.target = 2 /* BACKGROUND_BORDERS */ | 4 /* CONTENT */;
  45498. }
  45499. return TransformEffect;
  45500. }());
  45501. var ClipEffect = /** @class */ (function () {
  45502. function ClipEffect(path, target) {
  45503. this.path = path;
  45504. this.target = target;
  45505. this.type = 1 /* CLIP */;
  45506. }
  45507. return ClipEffect;
  45508. }());
  45509. var OpacityEffect = /** @class */ (function () {
  45510. function OpacityEffect(opacity) {
  45511. this.opacity = opacity;
  45512. this.type = 2 /* OPACITY */;
  45513. this.target = 2 /* BACKGROUND_BORDERS */ | 4 /* CONTENT */;
  45514. }
  45515. return OpacityEffect;
  45516. }());
  45517. var isTransformEffect = function (effect) {
  45518. return effect.type === 0 /* TRANSFORM */;
  45519. };
  45520. var isClipEffect = function (effect) { return effect.type === 1 /* CLIP */; };
  45521. var isOpacityEffect = function (effect) { return effect.type === 2 /* OPACITY */; };
  45522. var equalPath = function (a, b) {
  45523. if (a.length === b.length) {
  45524. return a.some(function (v, i) { return v === b[i]; });
  45525. }
  45526. return false;
  45527. };
  45528. var transformPath = function (path, deltaX, deltaY, deltaW, deltaH) {
  45529. return path.map(function (point, index) {
  45530. switch (index) {
  45531. case 0:
  45532. return point.add(deltaX, deltaY);
  45533. case 1:
  45534. return point.add(deltaX + deltaW, deltaY);
  45535. case 2:
  45536. return point.add(deltaX + deltaW, deltaY + deltaH);
  45537. case 3:
  45538. return point.add(deltaX, deltaY + deltaH);
  45539. }
  45540. return point;
  45541. });
  45542. };
  45543. var StackingContext = /** @class */ (function () {
  45544. function StackingContext(container) {
  45545. this.element = container;
  45546. this.inlineLevel = [];
  45547. this.nonInlineLevel = [];
  45548. this.negativeZIndex = [];
  45549. this.zeroOrAutoZIndexOrTransformedOrOpacity = [];
  45550. this.positiveZIndex = [];
  45551. this.nonPositionedFloats = [];
  45552. this.nonPositionedInlineLevel = [];
  45553. }
  45554. return StackingContext;
  45555. }());
  45556. var ElementPaint = /** @class */ (function () {
  45557. function ElementPaint(container, parent) {
  45558. this.container = container;
  45559. this.parent = parent;
  45560. this.effects = [];
  45561. this.curves = new BoundCurves(this.container);
  45562. if (this.container.styles.opacity < 1) {
  45563. this.effects.push(new OpacityEffect(this.container.styles.opacity));
  45564. }
  45565. if (this.container.styles.transform !== null) {
  45566. var offsetX = this.container.bounds.left + this.container.styles.transformOrigin[0].number;
  45567. var offsetY = this.container.bounds.top + this.container.styles.transformOrigin[1].number;
  45568. var matrix = this.container.styles.transform;
  45569. this.effects.push(new TransformEffect(offsetX, offsetY, matrix));
  45570. }
  45571. if (this.container.styles.overflowX !== 0 /* VISIBLE */) {
  45572. var borderBox = calculateBorderBoxPath(this.curves);
  45573. var paddingBox = calculatePaddingBoxPath(this.curves);
  45574. if (equalPath(borderBox, paddingBox)) {
  45575. this.effects.push(new ClipEffect(borderBox, 2 /* BACKGROUND_BORDERS */ | 4 /* CONTENT */));
  45576. }
  45577. else {
  45578. this.effects.push(new ClipEffect(borderBox, 2 /* BACKGROUND_BORDERS */));
  45579. this.effects.push(new ClipEffect(paddingBox, 4 /* CONTENT */));
  45580. }
  45581. }
  45582. }
  45583. ElementPaint.prototype.getEffects = function (target) {
  45584. var inFlow = [2 /* ABSOLUTE */, 3 /* FIXED */].indexOf(this.container.styles.position) === -1;
  45585. var parent = this.parent;
  45586. var effects = this.effects.slice(0);
  45587. while (parent) {
  45588. var croplessEffects = parent.effects.filter(function (effect) { return !isClipEffect(effect); });
  45589. if (inFlow || parent.container.styles.position !== 0 /* STATIC */ || !parent.parent) {
  45590. effects.unshift.apply(effects, croplessEffects);
  45591. inFlow = [2 /* ABSOLUTE */, 3 /* FIXED */].indexOf(parent.container.styles.position) === -1;
  45592. if (parent.container.styles.overflowX !== 0 /* VISIBLE */) {
  45593. var borderBox = calculateBorderBoxPath(parent.curves);
  45594. var paddingBox = calculatePaddingBoxPath(parent.curves);
  45595. if (!equalPath(borderBox, paddingBox)) {
  45596. effects.unshift(new ClipEffect(paddingBox, 2 /* BACKGROUND_BORDERS */ | 4 /* CONTENT */));
  45597. }
  45598. }
  45599. }
  45600. else {
  45601. effects.unshift.apply(effects, croplessEffects);
  45602. }
  45603. parent = parent.parent;
  45604. }
  45605. return effects.filter(function (effect) { return contains(effect.target, target); });
  45606. };
  45607. return ElementPaint;
  45608. }());
  45609. var parseStackTree = function (parent, stackingContext, realStackingContext, listItems) {
  45610. parent.container.elements.forEach(function (child) {
  45611. var treatAsRealStackingContext = contains(child.flags, 4 /* CREATES_REAL_STACKING_CONTEXT */);
  45612. var createsStackingContext = contains(child.flags, 2 /* CREATES_STACKING_CONTEXT */);
  45613. var paintContainer = new ElementPaint(child, parent);
  45614. if (contains(child.styles.display, 2048 /* LIST_ITEM */)) {
  45615. listItems.push(paintContainer);
  45616. }
  45617. var listOwnerItems = contains(child.flags, 8 /* IS_LIST_OWNER */) ? [] : listItems;
  45618. if (treatAsRealStackingContext || createsStackingContext) {
  45619. var parentStack = treatAsRealStackingContext || child.styles.isPositioned() ? realStackingContext : stackingContext;
  45620. var stack = new StackingContext(paintContainer);
  45621. if (child.styles.isPositioned() || child.styles.opacity < 1 || child.styles.isTransformed()) {
  45622. var order_1 = child.styles.zIndex.order;
  45623. if (order_1 < 0) {
  45624. var index_1 = 0;
  45625. parentStack.negativeZIndex.some(function (current, i) {
  45626. if (order_1 > current.element.container.styles.zIndex.order) {
  45627. index_1 = i;
  45628. return false;
  45629. }
  45630. else if (index_1 > 0) {
  45631. return true;
  45632. }
  45633. return false;
  45634. });
  45635. parentStack.negativeZIndex.splice(index_1, 0, stack);
  45636. }
  45637. else if (order_1 > 0) {
  45638. var index_2 = 0;
  45639. parentStack.positiveZIndex.some(function (current, i) {
  45640. if (order_1 >= current.element.container.styles.zIndex.order) {
  45641. index_2 = i + 1;
  45642. return false;
  45643. }
  45644. else if (index_2 > 0) {
  45645. return true;
  45646. }
  45647. return false;
  45648. });
  45649. parentStack.positiveZIndex.splice(index_2, 0, stack);
  45650. }
  45651. else {
  45652. parentStack.zeroOrAutoZIndexOrTransformedOrOpacity.push(stack);
  45653. }
  45654. }
  45655. else {
  45656. if (child.styles.isFloating()) {
  45657. parentStack.nonPositionedFloats.push(stack);
  45658. }
  45659. else {
  45660. parentStack.nonPositionedInlineLevel.push(stack);
  45661. }
  45662. }
  45663. parseStackTree(paintContainer, stack, treatAsRealStackingContext ? stack : realStackingContext, listOwnerItems);
  45664. }
  45665. else {
  45666. if (child.styles.isInlineLevel()) {
  45667. stackingContext.inlineLevel.push(paintContainer);
  45668. }
  45669. else {
  45670. stackingContext.nonInlineLevel.push(paintContainer);
  45671. }
  45672. parseStackTree(paintContainer, stackingContext, realStackingContext, listOwnerItems);
  45673. }
  45674. if (contains(child.flags, 8 /* IS_LIST_OWNER */)) {
  45675. processListItems(child, listOwnerItems);
  45676. }
  45677. });
  45678. };
  45679. var processListItems = function (owner, elements) {
  45680. var numbering = owner instanceof OLElementContainer ? owner.start : 1;
  45681. var reversed = owner instanceof OLElementContainer ? owner.reversed : false;
  45682. for (var i = 0; i < elements.length; i++) {
  45683. var item = elements[i];
  45684. if (item.container instanceof LIElementContainer &&
  45685. typeof item.container.value === 'number' &&
  45686. item.container.value !== 0) {
  45687. numbering = item.container.value;
  45688. }
  45689. item.listValue = createCounterText(numbering, item.container.styles.listStyleType, true);
  45690. numbering += reversed ? -1 : 1;
  45691. }
  45692. };
  45693. var parseStackingContexts = function (container) {
  45694. var paintContainer = new ElementPaint(container, null);
  45695. var root = new StackingContext(paintContainer);
  45696. var listItems = [];
  45697. parseStackTree(paintContainer, root, root, listItems);
  45698. processListItems(paintContainer.container, listItems);
  45699. return root;
  45700. };
  45701. var parsePathForBorder = function (curves, borderSide) {
  45702. switch (borderSide) {
  45703. case 0:
  45704. return createPathFromCurves(curves.topLeftBorderBox, curves.topLeftPaddingBox, curves.topRightBorderBox, curves.topRightPaddingBox);
  45705. case 1:
  45706. return createPathFromCurves(curves.topRightBorderBox, curves.topRightPaddingBox, curves.bottomRightBorderBox, curves.bottomRightPaddingBox);
  45707. case 2:
  45708. return createPathFromCurves(curves.bottomRightBorderBox, curves.bottomRightPaddingBox, curves.bottomLeftBorderBox, curves.bottomLeftPaddingBox);
  45709. case 3:
  45710. default:
  45711. return createPathFromCurves(curves.bottomLeftBorderBox, curves.bottomLeftPaddingBox, curves.topLeftBorderBox, curves.topLeftPaddingBox);
  45712. }
  45713. };
  45714. var parsePathForBorderDoubleOuter = function (curves, borderSide) {
  45715. switch (borderSide) {
  45716. case 0:
  45717. return createPathFromCurves(curves.topLeftBorderBox, curves.topLeftBorderDoubleOuterBox, curves.topRightBorderBox, curves.topRightBorderDoubleOuterBox);
  45718. case 1:
  45719. return createPathFromCurves(curves.topRightBorderBox, curves.topRightBorderDoubleOuterBox, curves.bottomRightBorderBox, curves.bottomRightBorderDoubleOuterBox);
  45720. case 2:
  45721. return createPathFromCurves(curves.bottomRightBorderBox, curves.bottomRightBorderDoubleOuterBox, curves.bottomLeftBorderBox, curves.bottomLeftBorderDoubleOuterBox);
  45722. case 3:
  45723. default:
  45724. return createPathFromCurves(curves.bottomLeftBorderBox, curves.bottomLeftBorderDoubleOuterBox, curves.topLeftBorderBox, curves.topLeftBorderDoubleOuterBox);
  45725. }
  45726. };
  45727. var parsePathForBorderDoubleInner = function (curves, borderSide) {
  45728. switch (borderSide) {
  45729. case 0:
  45730. return createPathFromCurves(curves.topLeftBorderDoubleInnerBox, curves.topLeftPaddingBox, curves.topRightBorderDoubleInnerBox, curves.topRightPaddingBox);
  45731. case 1:
  45732. return createPathFromCurves(curves.topRightBorderDoubleInnerBox, curves.topRightPaddingBox, curves.bottomRightBorderDoubleInnerBox, curves.bottomRightPaddingBox);
  45733. case 2:
  45734. return createPathFromCurves(curves.bottomRightBorderDoubleInnerBox, curves.bottomRightPaddingBox, curves.bottomLeftBorderDoubleInnerBox, curves.bottomLeftPaddingBox);
  45735. case 3:
  45736. default:
  45737. return createPathFromCurves(curves.bottomLeftBorderDoubleInnerBox, curves.bottomLeftPaddingBox, curves.topLeftBorderDoubleInnerBox, curves.topLeftPaddingBox);
  45738. }
  45739. };
  45740. var parsePathForBorderStroke = function (curves, borderSide) {
  45741. switch (borderSide) {
  45742. case 0:
  45743. return createStrokePathFromCurves(curves.topLeftBorderStroke, curves.topRightBorderStroke);
  45744. case 1:
  45745. return createStrokePathFromCurves(curves.topRightBorderStroke, curves.bottomRightBorderStroke);
  45746. case 2:
  45747. return createStrokePathFromCurves(curves.bottomRightBorderStroke, curves.bottomLeftBorderStroke);
  45748. case 3:
  45749. default:
  45750. return createStrokePathFromCurves(curves.bottomLeftBorderStroke, curves.topLeftBorderStroke);
  45751. }
  45752. };
  45753. var createStrokePathFromCurves = function (outer1, outer2) {
  45754. var path = [];
  45755. if (isBezierCurve(outer1)) {
  45756. path.push(outer1.subdivide(0.5, false));
  45757. }
  45758. else {
  45759. path.push(outer1);
  45760. }
  45761. if (isBezierCurve(outer2)) {
  45762. path.push(outer2.subdivide(0.5, true));
  45763. }
  45764. else {
  45765. path.push(outer2);
  45766. }
  45767. return path;
  45768. };
  45769. var createPathFromCurves = function (outer1, inner1, outer2, inner2) {
  45770. var path = [];
  45771. if (isBezierCurve(outer1)) {
  45772. path.push(outer1.subdivide(0.5, false));
  45773. }
  45774. else {
  45775. path.push(outer1);
  45776. }
  45777. if (isBezierCurve(outer2)) {
  45778. path.push(outer2.subdivide(0.5, true));
  45779. }
  45780. else {
  45781. path.push(outer2);
  45782. }
  45783. if (isBezierCurve(inner2)) {
  45784. path.push(inner2.subdivide(0.5, true).reverse());
  45785. }
  45786. else {
  45787. path.push(inner2);
  45788. }
  45789. if (isBezierCurve(inner1)) {
  45790. path.push(inner1.subdivide(0.5, false).reverse());
  45791. }
  45792. else {
  45793. path.push(inner1);
  45794. }
  45795. return path;
  45796. };
  45797. var paddingBox = function (element) {
  45798. var bounds = element.bounds;
  45799. var styles = element.styles;
  45800. return bounds.add(styles.borderLeftWidth, styles.borderTopWidth, -(styles.borderRightWidth + styles.borderLeftWidth), -(styles.borderTopWidth + styles.borderBottomWidth));
  45801. };
  45802. var contentBox = function (element) {
  45803. var styles = element.styles;
  45804. var bounds = element.bounds;
  45805. var paddingLeft = getAbsoluteValue(styles.paddingLeft, bounds.width);
  45806. var paddingRight = getAbsoluteValue(styles.paddingRight, bounds.width);
  45807. var paddingTop = getAbsoluteValue(styles.paddingTop, bounds.width);
  45808. var paddingBottom = getAbsoluteValue(styles.paddingBottom, bounds.width);
  45809. return bounds.add(paddingLeft + styles.borderLeftWidth, paddingTop + styles.borderTopWidth, -(styles.borderRightWidth + styles.borderLeftWidth + paddingLeft + paddingRight), -(styles.borderTopWidth + styles.borderBottomWidth + paddingTop + paddingBottom));
  45810. };
  45811. var calculateBackgroundPositioningArea = function (backgroundOrigin, element) {
  45812. if (backgroundOrigin === 0 /* BORDER_BOX */) {
  45813. return element.bounds;
  45814. }
  45815. if (backgroundOrigin === 2 /* CONTENT_BOX */) {
  45816. return contentBox(element);
  45817. }
  45818. return paddingBox(element);
  45819. };
  45820. var calculateBackgroundPaintingArea = function (backgroundClip, element) {
  45821. if (backgroundClip === 0 /* BORDER_BOX */) {
  45822. return element.bounds;
  45823. }
  45824. if (backgroundClip === 2 /* CONTENT_BOX */) {
  45825. return contentBox(element);
  45826. }
  45827. return paddingBox(element);
  45828. };
  45829. var calculateBackgroundRendering = function (container, index, intrinsicSize) {
  45830. var backgroundPositioningArea = calculateBackgroundPositioningArea(getBackgroundValueForIndex(container.styles.backgroundOrigin, index), container);
  45831. var backgroundPaintingArea = calculateBackgroundPaintingArea(getBackgroundValueForIndex(container.styles.backgroundClip, index), container);
  45832. var backgroundImageSize = calculateBackgroundSize(getBackgroundValueForIndex(container.styles.backgroundSize, index), intrinsicSize, backgroundPositioningArea);
  45833. var sizeWidth = backgroundImageSize[0], sizeHeight = backgroundImageSize[1];
  45834. var position = getAbsoluteValueForTuple(getBackgroundValueForIndex(container.styles.backgroundPosition, index), backgroundPositioningArea.width - sizeWidth, backgroundPositioningArea.height - sizeHeight);
  45835. var path = calculateBackgroundRepeatPath(getBackgroundValueForIndex(container.styles.backgroundRepeat, index), position, backgroundImageSize, backgroundPositioningArea, backgroundPaintingArea);
  45836. var offsetX = Math.round(backgroundPositioningArea.left + position[0]);
  45837. var offsetY = Math.round(backgroundPositioningArea.top + position[1]);
  45838. return [path, offsetX, offsetY, sizeWidth, sizeHeight];
  45839. };
  45840. var isAuto = function (token) { return isIdentToken(token) && token.value === BACKGROUND_SIZE.AUTO; };
  45841. var hasIntrinsicValue = function (value) { return typeof value === 'number'; };
  45842. var calculateBackgroundSize = function (size, _a, bounds) {
  45843. var intrinsicWidth = _a[0], intrinsicHeight = _a[1], intrinsicProportion = _a[2];
  45844. var first = size[0], second = size[1];
  45845. if (!first) {
  45846. return [0, 0];
  45847. }
  45848. if (isLengthPercentage(first) && second && isLengthPercentage(second)) {
  45849. return [getAbsoluteValue(first, bounds.width), getAbsoluteValue(second, bounds.height)];
  45850. }
  45851. var hasIntrinsicProportion = hasIntrinsicValue(intrinsicProportion);
  45852. if (isIdentToken(first) && (first.value === BACKGROUND_SIZE.CONTAIN || first.value === BACKGROUND_SIZE.COVER)) {
  45853. if (hasIntrinsicValue(intrinsicProportion)) {
  45854. var targetRatio = bounds.width / bounds.height;
  45855. return targetRatio < intrinsicProportion !== (first.value === BACKGROUND_SIZE.COVER)
  45856. ? [bounds.width, bounds.width / intrinsicProportion]
  45857. : [bounds.height * intrinsicProportion, bounds.height];
  45858. }
  45859. return [bounds.width, bounds.height];
  45860. }
  45861. var hasIntrinsicWidth = hasIntrinsicValue(intrinsicWidth);
  45862. var hasIntrinsicHeight = hasIntrinsicValue(intrinsicHeight);
  45863. var hasIntrinsicDimensions = hasIntrinsicWidth || hasIntrinsicHeight;
  45864. // If the background-size is auto or auto auto:
  45865. if (isAuto(first) && (!second || isAuto(second))) {
  45866. // If the image has both horizontal and vertical intrinsic dimensions, it's rendered at that size.
  45867. if (hasIntrinsicWidth && hasIntrinsicHeight) {
  45868. return [intrinsicWidth, intrinsicHeight];
  45869. }
  45870. // If the image has no intrinsic dimensions and has no intrinsic proportions,
  45871. // it's rendered at the size of the background positioning area.
  45872. if (!hasIntrinsicProportion && !hasIntrinsicDimensions) {
  45873. return [bounds.width, bounds.height];
  45874. }
  45875. // TODO If the image has no intrinsic dimensions but has intrinsic proportions, it's rendered as if contain had been specified instead.
  45876. // If the image has only one intrinsic dimension and has intrinsic proportions, it's rendered at the size corresponding to that one dimension.
  45877. // The other dimension is computed using the specified dimension and the intrinsic proportions.
  45878. if (hasIntrinsicDimensions && hasIntrinsicProportion) {
  45879. var width_1 = hasIntrinsicWidth
  45880. ? intrinsicWidth
  45881. : intrinsicHeight * intrinsicProportion;
  45882. var height_1 = hasIntrinsicHeight
  45883. ? intrinsicHeight
  45884. : intrinsicWidth / intrinsicProportion;
  45885. return [width_1, height_1];
  45886. }
  45887. // If the image has only one intrinsic dimension but has no intrinsic proportions,
  45888. // it's rendered using the specified dimension and the other dimension of the background positioning area.
  45889. var width_2 = hasIntrinsicWidth ? intrinsicWidth : bounds.width;
  45890. var height_2 = hasIntrinsicHeight ? intrinsicHeight : bounds.height;
  45891. return [width_2, height_2];
  45892. }
  45893. // If the image has intrinsic proportions, it's stretched to the specified dimension.
  45894. // The unspecified dimension is computed using the specified dimension and the intrinsic proportions.
  45895. if (hasIntrinsicProportion) {
  45896. var width_3 = 0;
  45897. var height_3 = 0;
  45898. if (isLengthPercentage(first)) {
  45899. width_3 = getAbsoluteValue(first, bounds.width);
  45900. }
  45901. else if (isLengthPercentage(second)) {
  45902. height_3 = getAbsoluteValue(second, bounds.height);
  45903. }
  45904. if (isAuto(first)) {
  45905. width_3 = height_3 * intrinsicProportion;
  45906. }
  45907. else if (!second || isAuto(second)) {
  45908. height_3 = width_3 / intrinsicProportion;
  45909. }
  45910. return [width_3, height_3];
  45911. }
  45912. // If the image has no intrinsic proportions, it's stretched to the specified dimension.
  45913. // The unspecified dimension is computed using the image's corresponding intrinsic dimension,
  45914. // if there is one. If there is no such intrinsic dimension,
  45915. // it becomes the corresponding dimension of the background positioning area.
  45916. var width = null;
  45917. var height = null;
  45918. if (isLengthPercentage(first)) {
  45919. width = getAbsoluteValue(first, bounds.width);
  45920. }
  45921. else if (second && isLengthPercentage(second)) {
  45922. height = getAbsoluteValue(second, bounds.height);
  45923. }
  45924. if (width !== null && (!second || isAuto(second))) {
  45925. height =
  45926. hasIntrinsicWidth && hasIntrinsicHeight
  45927. ? (width / intrinsicWidth) * intrinsicHeight
  45928. : bounds.height;
  45929. }
  45930. if (height !== null && isAuto(first)) {
  45931. width =
  45932. hasIntrinsicWidth && hasIntrinsicHeight
  45933. ? (height / intrinsicHeight) * intrinsicWidth
  45934. : bounds.width;
  45935. }
  45936. if (width !== null && height !== null) {
  45937. return [width, height];
  45938. }
  45939. throw new Error("Unable to calculate background-size for element");
  45940. };
  45941. var getBackgroundValueForIndex = function (values, index) {
  45942. var value = values[index];
  45943. if (typeof value === 'undefined') {
  45944. return values[0];
  45945. }
  45946. return value;
  45947. };
  45948. var calculateBackgroundRepeatPath = function (repeat, _a, _b, backgroundPositioningArea, backgroundPaintingArea) {
  45949. var x = _a[0], y = _a[1];
  45950. var width = _b[0], height = _b[1];
  45951. switch (repeat) {
  45952. case 2 /* REPEAT_X */:
  45953. return [
  45954. new Vector(Math.round(backgroundPositioningArea.left), Math.round(backgroundPositioningArea.top + y)),
  45955. new Vector(Math.round(backgroundPositioningArea.left + backgroundPositioningArea.width), Math.round(backgroundPositioningArea.top + y)),
  45956. new Vector(Math.round(backgroundPositioningArea.left + backgroundPositioningArea.width), Math.round(height + backgroundPositioningArea.top + y)),
  45957. new Vector(Math.round(backgroundPositioningArea.left), Math.round(height + backgroundPositioningArea.top + y))
  45958. ];
  45959. case 3 /* REPEAT_Y */:
  45960. return [
  45961. new Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.top)),
  45962. new Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.top)),
  45963. new Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.height + backgroundPositioningArea.top)),
  45964. new Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.height + backgroundPositioningArea.top))
  45965. ];
  45966. case 1 /* NO_REPEAT */:
  45967. return [
  45968. new Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.top + y)),
  45969. new Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.top + y)),
  45970. new Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.top + y + height)),
  45971. new Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.top + y + height))
  45972. ];
  45973. default:
  45974. return [
  45975. new Vector(Math.round(backgroundPaintingArea.left), Math.round(backgroundPaintingArea.top)),
  45976. new Vector(Math.round(backgroundPaintingArea.left + backgroundPaintingArea.width), Math.round(backgroundPaintingArea.top)),
  45977. new Vector(Math.round(backgroundPaintingArea.left + backgroundPaintingArea.width), Math.round(backgroundPaintingArea.height + backgroundPaintingArea.top)),
  45978. new Vector(Math.round(backgroundPaintingArea.left), Math.round(backgroundPaintingArea.height + backgroundPaintingArea.top))
  45979. ];
  45980. }
  45981. };
  45982. var SMALL_IMAGE = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
  45983. var SAMPLE_TEXT = 'Hidden Text';
  45984. var FontMetrics = /** @class */ (function () {
  45985. function FontMetrics(document) {
  45986. this._data = {};
  45987. this._document = document;
  45988. }
  45989. FontMetrics.prototype.parseMetrics = function (fontFamily, fontSize) {
  45990. var container = this._document.createElement('div');
  45991. var img = this._document.createElement('img');
  45992. var span = this._document.createElement('span');
  45993. var body = this._document.body;
  45994. container.style.visibility = 'hidden';
  45995. container.style.fontFamily = fontFamily;
  45996. container.style.fontSize = fontSize;
  45997. container.style.margin = '0';
  45998. container.style.padding = '0';
  45999. container.style.whiteSpace = 'nowrap';
  46000. body.appendChild(container);
  46001. img.src = SMALL_IMAGE;
  46002. img.width = 1;
  46003. img.height = 1;
  46004. img.style.margin = '0';
  46005. img.style.padding = '0';
  46006. img.style.verticalAlign = 'baseline';
  46007. span.style.fontFamily = fontFamily;
  46008. span.style.fontSize = fontSize;
  46009. span.style.margin = '0';
  46010. span.style.padding = '0';
  46011. span.appendChild(this._document.createTextNode(SAMPLE_TEXT));
  46012. container.appendChild(span);
  46013. container.appendChild(img);
  46014. var baseline = img.offsetTop - span.offsetTop + 2;
  46015. container.removeChild(span);
  46016. container.appendChild(this._document.createTextNode(SAMPLE_TEXT));
  46017. container.style.lineHeight = 'normal';
  46018. img.style.verticalAlign = 'super';
  46019. var middle = img.offsetTop - container.offsetTop + 2;
  46020. body.removeChild(container);
  46021. return { baseline: baseline, middle: middle };
  46022. };
  46023. FontMetrics.prototype.getMetrics = function (fontFamily, fontSize) {
  46024. var key = fontFamily + " " + fontSize;
  46025. if (typeof this._data[key] === 'undefined') {
  46026. this._data[key] = this.parseMetrics(fontFamily, fontSize);
  46027. }
  46028. return this._data[key];
  46029. };
  46030. return FontMetrics;
  46031. }());
  46032. var Renderer = /** @class */ (function () {
  46033. function Renderer(context, options) {
  46034. this.context = context;
  46035. this.options = options;
  46036. }
  46037. return Renderer;
  46038. }());
  46039. var MASK_OFFSET = 10000;
  46040. var CanvasRenderer = /** @class */ (function (_super) {
  46041. __extends(CanvasRenderer, _super);
  46042. function CanvasRenderer(context, options) {
  46043. var _this = _super.call(this, context, options) || this;
  46044. _this._activeEffects = [];
  46045. _this.canvas = options.canvas ? options.canvas : document.createElement('canvas');
  46046. _this.ctx = _this.canvas.getContext('2d');
  46047. if (!options.canvas) {
  46048. _this.canvas.width = Math.floor(options.width * options.scale);
  46049. _this.canvas.height = Math.floor(options.height * options.scale);
  46050. _this.canvas.style.width = options.width + "px";
  46051. _this.canvas.style.height = options.height + "px";
  46052. }
  46053. _this.fontMetrics = new FontMetrics(document);
  46054. _this.ctx.scale(_this.options.scale, _this.options.scale);
  46055. _this.ctx.translate(-options.x, -options.y);
  46056. _this.ctx.textBaseline = 'bottom';
  46057. _this._activeEffects = [];
  46058. _this.context.logger.debug("Canvas renderer initialized (" + options.width + "x" + options.height + ") with scale " + options.scale);
  46059. return _this;
  46060. }
  46061. CanvasRenderer.prototype.applyEffects = function (effects) {
  46062. var _this = this;
  46063. while (this._activeEffects.length) {
  46064. this.popEffect();
  46065. }
  46066. effects.forEach(function (effect) { return _this.applyEffect(effect); });
  46067. };
  46068. CanvasRenderer.prototype.applyEffect = function (effect) {
  46069. this.ctx.save();
  46070. if (isOpacityEffect(effect)) {
  46071. this.ctx.globalAlpha = effect.opacity;
  46072. }
  46073. if (isTransformEffect(effect)) {
  46074. this.ctx.translate(effect.offsetX, effect.offsetY);
  46075. this.ctx.transform(effect.matrix[0], effect.matrix[1], effect.matrix[2], effect.matrix[3], effect.matrix[4], effect.matrix[5]);
  46076. this.ctx.translate(-effect.offsetX, -effect.offsetY);
  46077. }
  46078. if (isClipEffect(effect)) {
  46079. this.path(effect.path);
  46080. this.ctx.clip();
  46081. }
  46082. this._activeEffects.push(effect);
  46083. };
  46084. CanvasRenderer.prototype.popEffect = function () {
  46085. this._activeEffects.pop();
  46086. this.ctx.restore();
  46087. };
  46088. CanvasRenderer.prototype.renderStack = function (stack) {
  46089. return __awaiter(this, void 0, void 0, function () {
  46090. var styles;
  46091. return __generator(this, function (_a) {
  46092. switch (_a.label) {
  46093. case 0:
  46094. styles = stack.element.container.styles;
  46095. if (!styles.isVisible()) return [3 /*break*/, 2];
  46096. return [4 /*yield*/, this.renderStackContent(stack)];
  46097. case 1:
  46098. _a.sent();
  46099. _a.label = 2;
  46100. case 2: return [2 /*return*/];
  46101. }
  46102. });
  46103. });
  46104. };
  46105. CanvasRenderer.prototype.renderNode = function (paint) {
  46106. return __awaiter(this, void 0, void 0, function () {
  46107. return __generator(this, function (_a) {
  46108. switch (_a.label) {
  46109. case 0:
  46110. if (contains(paint.container.flags, 16 /* DEBUG_RENDER */)) {
  46111. debugger;
  46112. }
  46113. if (!paint.container.styles.isVisible()) return [3 /*break*/, 3];
  46114. return [4 /*yield*/, this.renderNodeBackgroundAndBorders(paint)];
  46115. case 1:
  46116. _a.sent();
  46117. return [4 /*yield*/, this.renderNodeContent(paint)];
  46118. case 2:
  46119. _a.sent();
  46120. _a.label = 3;
  46121. case 3: return [2 /*return*/];
  46122. }
  46123. });
  46124. });
  46125. };
  46126. CanvasRenderer.prototype.renderTextWithLetterSpacing = function (text, letterSpacing, baseline) {
  46127. var _this = this;
  46128. if (letterSpacing === 0) {
  46129. this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + baseline);
  46130. }
  46131. else {
  46132. var letters = segmentGraphemes(text.text);
  46133. letters.reduce(function (left, letter) {
  46134. _this.ctx.fillText(letter, left, text.bounds.top + baseline);
  46135. return left + _this.ctx.measureText(letter).width;
  46136. }, text.bounds.left);
  46137. }
  46138. };
  46139. CanvasRenderer.prototype.createFontStyle = function (styles) {
  46140. var fontVariant = styles.fontVariant
  46141. .filter(function (variant) { return variant === 'normal' || variant === 'small-caps'; })
  46142. .join('');
  46143. var fontFamily = fixIOSSystemFonts(styles.fontFamily).join(', ');
  46144. var fontSize = isDimensionToken(styles.fontSize)
  46145. ? "" + styles.fontSize.number + styles.fontSize.unit
  46146. : styles.fontSize.number + "px";
  46147. return [
  46148. [styles.fontStyle, fontVariant, styles.fontWeight, fontSize, fontFamily].join(' '),
  46149. fontFamily,
  46150. fontSize
  46151. ];
  46152. };
  46153. CanvasRenderer.prototype.renderTextNode = function (text, styles) {
  46154. return __awaiter(this, void 0, void 0, function () {
  46155. var _a, font, fontFamily, fontSize, _b, baseline, middle, paintOrder;
  46156. var _this = this;
  46157. return __generator(this, function (_c) {
  46158. _a = this.createFontStyle(styles), font = _a[0], fontFamily = _a[1], fontSize = _a[2];
  46159. this.ctx.font = font;
  46160. this.ctx.direction = styles.direction === 1 /* RTL */ ? 'rtl' : 'ltr';
  46161. this.ctx.textAlign = 'left';
  46162. this.ctx.textBaseline = 'alphabetic';
  46163. _b = this.fontMetrics.getMetrics(fontFamily, fontSize), baseline = _b.baseline, middle = _b.middle;
  46164. paintOrder = styles.paintOrder;
  46165. text.textBounds.forEach(function (text) {
  46166. paintOrder.forEach(function (paintOrderLayer) {
  46167. switch (paintOrderLayer) {
  46168. case 0 /* FILL */:
  46169. _this.ctx.fillStyle = asString(styles.color);
  46170. _this.renderTextWithLetterSpacing(text, styles.letterSpacing, baseline);
  46171. var textShadows = styles.textShadow;
  46172. if (textShadows.length && text.text.trim().length) {
  46173. textShadows
  46174. .slice(0)
  46175. .reverse()
  46176. .forEach(function (textShadow) {
  46177. _this.ctx.shadowColor = asString(textShadow.color);
  46178. _this.ctx.shadowOffsetX = textShadow.offsetX.number * _this.options.scale;
  46179. _this.ctx.shadowOffsetY = textShadow.offsetY.number * _this.options.scale;
  46180. _this.ctx.shadowBlur = textShadow.blur.number;
  46181. _this.renderTextWithLetterSpacing(text, styles.letterSpacing, baseline);
  46182. });
  46183. _this.ctx.shadowColor = '';
  46184. _this.ctx.shadowOffsetX = 0;
  46185. _this.ctx.shadowOffsetY = 0;
  46186. _this.ctx.shadowBlur = 0;
  46187. }
  46188. if (styles.textDecorationLine.length) {
  46189. _this.ctx.fillStyle = asString(styles.textDecorationColor || styles.color);
  46190. styles.textDecorationLine.forEach(function (textDecorationLine) {
  46191. switch (textDecorationLine) {
  46192. case 1 /* UNDERLINE */:
  46193. // Draws a line at the baseline of the font
  46194. // TODO As some browsers display the line as more than 1px if the font-size is big,
  46195. // need to take that into account both in position and size
  46196. _this.ctx.fillRect(text.bounds.left, Math.round(text.bounds.top + baseline), text.bounds.width, 1);
  46197. break;
  46198. case 2 /* OVERLINE */:
  46199. _this.ctx.fillRect(text.bounds.left, Math.round(text.bounds.top), text.bounds.width, 1);
  46200. break;
  46201. case 3 /* LINE_THROUGH */:
  46202. // TODO try and find exact position for line-through
  46203. _this.ctx.fillRect(text.bounds.left, Math.ceil(text.bounds.top + middle), text.bounds.width, 1);
  46204. break;
  46205. }
  46206. });
  46207. }
  46208. break;
  46209. case 1 /* STROKE */:
  46210. if (styles.webkitTextStrokeWidth && text.text.trim().length) {
  46211. _this.ctx.strokeStyle = asString(styles.webkitTextStrokeColor);
  46212. _this.ctx.lineWidth = styles.webkitTextStrokeWidth;
  46213. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  46214. _this.ctx.lineJoin = !!window.chrome ? 'miter' : 'round';
  46215. _this.ctx.strokeText(text.text, text.bounds.left, text.bounds.top + baseline);
  46216. }
  46217. _this.ctx.strokeStyle = '';
  46218. _this.ctx.lineWidth = 0;
  46219. _this.ctx.lineJoin = 'miter';
  46220. break;
  46221. }
  46222. });
  46223. });
  46224. return [2 /*return*/];
  46225. });
  46226. });
  46227. };
  46228. CanvasRenderer.prototype.renderReplacedElement = function (container, curves, image) {
  46229. if (image && container.intrinsicWidth > 0 && container.intrinsicHeight > 0) {
  46230. var box = contentBox(container);
  46231. var path = calculatePaddingBoxPath(curves);
  46232. this.path(path);
  46233. this.ctx.save();
  46234. this.ctx.clip();
  46235. this.ctx.drawImage(image, 0, 0, container.intrinsicWidth, container.intrinsicHeight, box.left, box.top, box.width, box.height);
  46236. this.ctx.restore();
  46237. }
  46238. };
  46239. CanvasRenderer.prototype.renderNodeContent = function (paint) {
  46240. return __awaiter(this, void 0, void 0, function () {
  46241. var container, curves, styles, _i, _a, child, image, image, iframeRenderer, canvas, size, _b, fontFamily, fontSize, baseline, bounds, x, textBounds, img, image, url, fontFamily, bounds;
  46242. return __generator(this, function (_c) {
  46243. switch (_c.label) {
  46244. case 0:
  46245. this.applyEffects(paint.getEffects(4 /* CONTENT */));
  46246. container = paint.container;
  46247. curves = paint.curves;
  46248. styles = container.styles;
  46249. _i = 0, _a = container.textNodes;
  46250. _c.label = 1;
  46251. case 1:
  46252. if (!(_i < _a.length)) return [3 /*break*/, 4];
  46253. child = _a[_i];
  46254. return [4 /*yield*/, this.renderTextNode(child, styles)];
  46255. case 2:
  46256. _c.sent();
  46257. _c.label = 3;
  46258. case 3:
  46259. _i++;
  46260. return [3 /*break*/, 1];
  46261. case 4:
  46262. if (!(container instanceof ImageElementContainer)) return [3 /*break*/, 8];
  46263. _c.label = 5;
  46264. case 5:
  46265. _c.trys.push([5, 7, , 8]);
  46266. return [4 /*yield*/, this.context.cache.match(container.src)];
  46267. case 6:
  46268. image = _c.sent();
  46269. this.renderReplacedElement(container, curves, image);
  46270. return [3 /*break*/, 8];
  46271. case 7:
  46272. _c.sent();
  46273. this.context.logger.error("Error loading image " + container.src);
  46274. return [3 /*break*/, 8];
  46275. case 8:
  46276. if (container instanceof CanvasElementContainer) {
  46277. this.renderReplacedElement(container, curves, container.canvas);
  46278. }
  46279. if (!(container instanceof SVGElementContainer)) return [3 /*break*/, 12];
  46280. _c.label = 9;
  46281. case 9:
  46282. _c.trys.push([9, 11, , 12]);
  46283. return [4 /*yield*/, this.context.cache.match(container.svg)];
  46284. case 10:
  46285. image = _c.sent();
  46286. this.renderReplacedElement(container, curves, image);
  46287. return [3 /*break*/, 12];
  46288. case 11:
  46289. _c.sent();
  46290. this.context.logger.error("Error loading svg " + container.svg.substring(0, 255));
  46291. return [3 /*break*/, 12];
  46292. case 12:
  46293. if (!(container instanceof IFrameElementContainer && container.tree)) return [3 /*break*/, 14];
  46294. iframeRenderer = new CanvasRenderer(this.context, {
  46295. scale: this.options.scale,
  46296. backgroundColor: container.backgroundColor,
  46297. x: 0,
  46298. y: 0,
  46299. width: container.width,
  46300. height: container.height
  46301. });
  46302. return [4 /*yield*/, iframeRenderer.render(container.tree)];
  46303. case 13:
  46304. canvas = _c.sent();
  46305. if (container.width && container.height) {
  46306. this.ctx.drawImage(canvas, 0, 0, container.width, container.height, container.bounds.left, container.bounds.top, container.bounds.width, container.bounds.height);
  46307. }
  46308. _c.label = 14;
  46309. case 14:
  46310. if (container instanceof InputElementContainer) {
  46311. size = Math.min(container.bounds.width, container.bounds.height);
  46312. if (container.type === CHECKBOX) {
  46313. if (container.checked) {
  46314. this.ctx.save();
  46315. this.path([
  46316. new Vector(container.bounds.left + size * 0.39363, container.bounds.top + size * 0.79),
  46317. new Vector(container.bounds.left + size * 0.16, container.bounds.top + size * 0.5549),
  46318. new Vector(container.bounds.left + size * 0.27347, container.bounds.top + size * 0.44071),
  46319. new Vector(container.bounds.left + size * 0.39694, container.bounds.top + size * 0.5649),
  46320. new Vector(container.bounds.left + size * 0.72983, container.bounds.top + size * 0.23),
  46321. new Vector(container.bounds.left + size * 0.84, container.bounds.top + size * 0.34085),
  46322. new Vector(container.bounds.left + size * 0.39363, container.bounds.top + size * 0.79)
  46323. ]);
  46324. this.ctx.fillStyle = asString(INPUT_COLOR);
  46325. this.ctx.fill();
  46326. this.ctx.restore();
  46327. }
  46328. }
  46329. else if (container.type === RADIO) {
  46330. if (container.checked) {
  46331. this.ctx.save();
  46332. this.ctx.beginPath();
  46333. this.ctx.arc(container.bounds.left + size / 2, container.bounds.top + size / 2, size / 4, 0, Math.PI * 2, true);
  46334. this.ctx.fillStyle = asString(INPUT_COLOR);
  46335. this.ctx.fill();
  46336. this.ctx.restore();
  46337. }
  46338. }
  46339. }
  46340. if (isTextInputElement(container) && container.value.length) {
  46341. _b = this.createFontStyle(styles), fontFamily = _b[0], fontSize = _b[1];
  46342. baseline = this.fontMetrics.getMetrics(fontFamily, fontSize).baseline;
  46343. this.ctx.font = fontFamily;
  46344. this.ctx.fillStyle = asString(styles.color);
  46345. this.ctx.textBaseline = 'alphabetic';
  46346. this.ctx.textAlign = canvasTextAlign(container.styles.textAlign);
  46347. bounds = contentBox(container);
  46348. x = 0;
  46349. switch (container.styles.textAlign) {
  46350. case 1 /* CENTER */:
  46351. x += bounds.width / 2;
  46352. break;
  46353. case 2 /* RIGHT */:
  46354. x += bounds.width;
  46355. break;
  46356. }
  46357. textBounds = bounds.add(x, 0, 0, -bounds.height / 2 + 1);
  46358. this.ctx.save();
  46359. this.path([
  46360. new Vector(bounds.left, bounds.top),
  46361. new Vector(bounds.left + bounds.width, bounds.top),
  46362. new Vector(bounds.left + bounds.width, bounds.top + bounds.height),
  46363. new Vector(bounds.left, bounds.top + bounds.height)
  46364. ]);
  46365. this.ctx.clip();
  46366. this.renderTextWithLetterSpacing(new TextBounds(container.value, textBounds), styles.letterSpacing, baseline);
  46367. this.ctx.restore();
  46368. this.ctx.textBaseline = 'alphabetic';
  46369. this.ctx.textAlign = 'left';
  46370. }
  46371. if (!contains(container.styles.display, 2048 /* LIST_ITEM */)) return [3 /*break*/, 20];
  46372. if (!(container.styles.listStyleImage !== null)) return [3 /*break*/, 19];
  46373. img = container.styles.listStyleImage;
  46374. if (!(img.type === 0 /* URL */)) return [3 /*break*/, 18];
  46375. image = void 0;
  46376. url = img.url;
  46377. _c.label = 15;
  46378. case 15:
  46379. _c.trys.push([15, 17, , 18]);
  46380. return [4 /*yield*/, this.context.cache.match(url)];
  46381. case 16:
  46382. image = _c.sent();
  46383. this.ctx.drawImage(image, container.bounds.left - (image.width + 10), container.bounds.top);
  46384. return [3 /*break*/, 18];
  46385. case 17:
  46386. _c.sent();
  46387. this.context.logger.error("Error loading list-style-image " + url);
  46388. return [3 /*break*/, 18];
  46389. case 18: return [3 /*break*/, 20];
  46390. case 19:
  46391. if (paint.listValue && container.styles.listStyleType !== -1 /* NONE */) {
  46392. fontFamily = this.createFontStyle(styles)[0];
  46393. this.ctx.font = fontFamily;
  46394. this.ctx.fillStyle = asString(styles.color);
  46395. this.ctx.textBaseline = 'middle';
  46396. this.ctx.textAlign = 'right';
  46397. bounds = new Bounds(container.bounds.left, container.bounds.top + getAbsoluteValue(container.styles.paddingTop, container.bounds.width), container.bounds.width, computeLineHeight(styles.lineHeight, styles.fontSize.number) / 2 + 1);
  46398. this.renderTextWithLetterSpacing(new TextBounds(paint.listValue, bounds), styles.letterSpacing, computeLineHeight(styles.lineHeight, styles.fontSize.number) / 2 + 2);
  46399. this.ctx.textBaseline = 'bottom';
  46400. this.ctx.textAlign = 'left';
  46401. }
  46402. _c.label = 20;
  46403. case 20: return [2 /*return*/];
  46404. }
  46405. });
  46406. });
  46407. };
  46408. CanvasRenderer.prototype.renderStackContent = function (stack) {
  46409. return __awaiter(this, void 0, void 0, function () {
  46410. var _i, _a, child, _b, _c, child, _d, _e, child, _f, _g, child, _h, _j, child, _k, _l, child, _m, _o, child;
  46411. return __generator(this, function (_p) {
  46412. switch (_p.label) {
  46413. case 0:
  46414. if (contains(stack.element.container.flags, 16 /* DEBUG_RENDER */)) {
  46415. debugger;
  46416. }
  46417. // https://www.w3.org/TR/css-position-3/#painting-order
  46418. // 1. the background and borders of the element forming the stacking context.
  46419. return [4 /*yield*/, this.renderNodeBackgroundAndBorders(stack.element)];
  46420. case 1:
  46421. // https://www.w3.org/TR/css-position-3/#painting-order
  46422. // 1. the background and borders of the element forming the stacking context.
  46423. _p.sent();
  46424. _i = 0, _a = stack.negativeZIndex;
  46425. _p.label = 2;
  46426. case 2:
  46427. if (!(_i < _a.length)) return [3 /*break*/, 5];
  46428. child = _a[_i];
  46429. return [4 /*yield*/, this.renderStack(child)];
  46430. case 3:
  46431. _p.sent();
  46432. _p.label = 4;
  46433. case 4:
  46434. _i++;
  46435. return [3 /*break*/, 2];
  46436. case 5:
  46437. // 3. For all its in-flow, non-positioned, block-level descendants in tree order:
  46438. return [4 /*yield*/, this.renderNodeContent(stack.element)];
  46439. case 6:
  46440. // 3. For all its in-flow, non-positioned, block-level descendants in tree order:
  46441. _p.sent();
  46442. _b = 0, _c = stack.nonInlineLevel;
  46443. _p.label = 7;
  46444. case 7:
  46445. if (!(_b < _c.length)) return [3 /*break*/, 10];
  46446. child = _c[_b];
  46447. return [4 /*yield*/, this.renderNode(child)];
  46448. case 8:
  46449. _p.sent();
  46450. _p.label = 9;
  46451. case 9:
  46452. _b++;
  46453. return [3 /*break*/, 7];
  46454. case 10:
  46455. _d = 0, _e = stack.nonPositionedFloats;
  46456. _p.label = 11;
  46457. case 11:
  46458. if (!(_d < _e.length)) return [3 /*break*/, 14];
  46459. child = _e[_d];
  46460. return [4 /*yield*/, this.renderStack(child)];
  46461. case 12:
  46462. _p.sent();
  46463. _p.label = 13;
  46464. case 13:
  46465. _d++;
  46466. return [3 /*break*/, 11];
  46467. case 14:
  46468. _f = 0, _g = stack.nonPositionedInlineLevel;
  46469. _p.label = 15;
  46470. case 15:
  46471. if (!(_f < _g.length)) return [3 /*break*/, 18];
  46472. child = _g[_f];
  46473. return [4 /*yield*/, this.renderStack(child)];
  46474. case 16:
  46475. _p.sent();
  46476. _p.label = 17;
  46477. case 17:
  46478. _f++;
  46479. return [3 /*break*/, 15];
  46480. case 18:
  46481. _h = 0, _j = stack.inlineLevel;
  46482. _p.label = 19;
  46483. case 19:
  46484. if (!(_h < _j.length)) return [3 /*break*/, 22];
  46485. child = _j[_h];
  46486. return [4 /*yield*/, this.renderNode(child)];
  46487. case 20:
  46488. _p.sent();
  46489. _p.label = 21;
  46490. case 21:
  46491. _h++;
  46492. return [3 /*break*/, 19];
  46493. case 22:
  46494. _k = 0, _l = stack.zeroOrAutoZIndexOrTransformedOrOpacity;
  46495. _p.label = 23;
  46496. case 23:
  46497. if (!(_k < _l.length)) return [3 /*break*/, 26];
  46498. child = _l[_k];
  46499. return [4 /*yield*/, this.renderStack(child)];
  46500. case 24:
  46501. _p.sent();
  46502. _p.label = 25;
  46503. case 25:
  46504. _k++;
  46505. return [3 /*break*/, 23];
  46506. case 26:
  46507. _m = 0, _o = stack.positiveZIndex;
  46508. _p.label = 27;
  46509. case 27:
  46510. if (!(_m < _o.length)) return [3 /*break*/, 30];
  46511. child = _o[_m];
  46512. return [4 /*yield*/, this.renderStack(child)];
  46513. case 28:
  46514. _p.sent();
  46515. _p.label = 29;
  46516. case 29:
  46517. _m++;
  46518. return [3 /*break*/, 27];
  46519. case 30: return [2 /*return*/];
  46520. }
  46521. });
  46522. });
  46523. };
  46524. CanvasRenderer.prototype.mask = function (paths) {
  46525. this.ctx.beginPath();
  46526. this.ctx.moveTo(0, 0);
  46527. this.ctx.lineTo(this.canvas.width, 0);
  46528. this.ctx.lineTo(this.canvas.width, this.canvas.height);
  46529. this.ctx.lineTo(0, this.canvas.height);
  46530. this.ctx.lineTo(0, 0);
  46531. this.formatPath(paths.slice(0).reverse());
  46532. this.ctx.closePath();
  46533. };
  46534. CanvasRenderer.prototype.path = function (paths) {
  46535. this.ctx.beginPath();
  46536. this.formatPath(paths);
  46537. this.ctx.closePath();
  46538. };
  46539. CanvasRenderer.prototype.formatPath = function (paths) {
  46540. var _this = this;
  46541. paths.forEach(function (point, index) {
  46542. var start = isBezierCurve(point) ? point.start : point;
  46543. if (index === 0) {
  46544. _this.ctx.moveTo(start.x, start.y);
  46545. }
  46546. else {
  46547. _this.ctx.lineTo(start.x, start.y);
  46548. }
  46549. if (isBezierCurve(point)) {
  46550. _this.ctx.bezierCurveTo(point.startControl.x, point.startControl.y, point.endControl.x, point.endControl.y, point.end.x, point.end.y);
  46551. }
  46552. });
  46553. };
  46554. CanvasRenderer.prototype.renderRepeat = function (path, pattern, offsetX, offsetY) {
  46555. this.path(path);
  46556. this.ctx.fillStyle = pattern;
  46557. this.ctx.translate(offsetX, offsetY);
  46558. this.ctx.fill();
  46559. this.ctx.translate(-offsetX, -offsetY);
  46560. };
  46561. CanvasRenderer.prototype.resizeImage = function (image, width, height) {
  46562. var _a;
  46563. if (image.width === width && image.height === height) {
  46564. return image;
  46565. }
  46566. var ownerDocument = (_a = this.canvas.ownerDocument) !== null && _a !== void 0 ? _a : document;
  46567. var canvas = ownerDocument.createElement('canvas');
  46568. canvas.width = Math.max(1, width);
  46569. canvas.height = Math.max(1, height);
  46570. var ctx = canvas.getContext('2d');
  46571. ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, width, height);
  46572. return canvas;
  46573. };
  46574. CanvasRenderer.prototype.renderBackgroundImage = function (container) {
  46575. return __awaiter(this, void 0, void 0, function () {
  46576. var index, _loop_1, this_1, _i, _a, backgroundImage;
  46577. return __generator(this, function (_b) {
  46578. switch (_b.label) {
  46579. case 0:
  46580. index = container.styles.backgroundImage.length - 1;
  46581. _loop_1 = function (backgroundImage) {
  46582. var image, url, _c, path, x, y, width, height, pattern, _d, path, x, y, width, height, _e, lineLength, x0, x1, y0, y1, canvas, ctx, gradient_1, pattern, _f, path, left, top_1, width, height, position, x, y, _g, rx, ry, radialGradient_1, midX, midY, f, invF;
  46583. return __generator(this, function (_h) {
  46584. switch (_h.label) {
  46585. case 0:
  46586. if (!(backgroundImage.type === 0 /* URL */)) return [3 /*break*/, 5];
  46587. image = void 0;
  46588. url = backgroundImage.url;
  46589. _h.label = 1;
  46590. case 1:
  46591. _h.trys.push([1, 3, , 4]);
  46592. return [4 /*yield*/, this_1.context.cache.match(url)];
  46593. case 2:
  46594. image = _h.sent();
  46595. return [3 /*break*/, 4];
  46596. case 3:
  46597. _h.sent();
  46598. this_1.context.logger.error("Error loading background-image " + url);
  46599. return [3 /*break*/, 4];
  46600. case 4:
  46601. if (image) {
  46602. _c = calculateBackgroundRendering(container, index, [
  46603. image.width,
  46604. image.height,
  46605. image.width / image.height
  46606. ]), path = _c[0], x = _c[1], y = _c[2], width = _c[3], height = _c[4];
  46607. pattern = this_1.ctx.createPattern(this_1.resizeImage(image, width, height), 'repeat');
  46608. this_1.renderRepeat(path, pattern, x, y);
  46609. }
  46610. return [3 /*break*/, 6];
  46611. case 5:
  46612. if (isLinearGradient(backgroundImage)) {
  46613. _d = calculateBackgroundRendering(container, index, [null, null, null]), path = _d[0], x = _d[1], y = _d[2], width = _d[3], height = _d[4];
  46614. _e = calculateGradientDirection(backgroundImage.angle, width, height), lineLength = _e[0], x0 = _e[1], x1 = _e[2], y0 = _e[3], y1 = _e[4];
  46615. canvas = document.createElement('canvas');
  46616. canvas.width = width;
  46617. canvas.height = height;
  46618. ctx = canvas.getContext('2d');
  46619. gradient_1 = ctx.createLinearGradient(x0, y0, x1, y1);
  46620. processColorStops(backgroundImage.stops, lineLength).forEach(function (colorStop) {
  46621. return gradient_1.addColorStop(colorStop.stop, asString(colorStop.color));
  46622. });
  46623. ctx.fillStyle = gradient_1;
  46624. ctx.fillRect(0, 0, width, height);
  46625. if (width > 0 && height > 0) {
  46626. pattern = this_1.ctx.createPattern(canvas, 'repeat');
  46627. this_1.renderRepeat(path, pattern, x, y);
  46628. }
  46629. }
  46630. else if (isRadialGradient(backgroundImage)) {
  46631. _f = calculateBackgroundRendering(container, index, [
  46632. null,
  46633. null,
  46634. null
  46635. ]), path = _f[0], left = _f[1], top_1 = _f[2], width = _f[3], height = _f[4];
  46636. position = backgroundImage.position.length === 0 ? [FIFTY_PERCENT] : backgroundImage.position;
  46637. x = getAbsoluteValue(position[0], width);
  46638. y = getAbsoluteValue(position[position.length - 1], height);
  46639. _g = calculateRadius(backgroundImage, x, y, width, height), rx = _g[0], ry = _g[1];
  46640. if (rx > 0 && ry > 0) {
  46641. radialGradient_1 = this_1.ctx.createRadialGradient(left + x, top_1 + y, 0, left + x, top_1 + y, rx);
  46642. processColorStops(backgroundImage.stops, rx * 2).forEach(function (colorStop) {
  46643. return radialGradient_1.addColorStop(colorStop.stop, asString(colorStop.color));
  46644. });
  46645. this_1.path(path);
  46646. this_1.ctx.fillStyle = radialGradient_1;
  46647. if (rx !== ry) {
  46648. midX = container.bounds.left + 0.5 * container.bounds.width;
  46649. midY = container.bounds.top + 0.5 * container.bounds.height;
  46650. f = ry / rx;
  46651. invF = 1 / f;
  46652. this_1.ctx.save();
  46653. this_1.ctx.translate(midX, midY);
  46654. this_1.ctx.transform(1, 0, 0, f, 0, 0);
  46655. this_1.ctx.translate(-midX, -midY);
  46656. this_1.ctx.fillRect(left, invF * (top_1 - midY) + midY, width, height * invF);
  46657. this_1.ctx.restore();
  46658. }
  46659. else {
  46660. this_1.ctx.fill();
  46661. }
  46662. }
  46663. }
  46664. _h.label = 6;
  46665. case 6:
  46666. index--;
  46667. return [2 /*return*/];
  46668. }
  46669. });
  46670. };
  46671. this_1 = this;
  46672. _i = 0, _a = container.styles.backgroundImage.slice(0).reverse();
  46673. _b.label = 1;
  46674. case 1:
  46675. if (!(_i < _a.length)) return [3 /*break*/, 4];
  46676. backgroundImage = _a[_i];
  46677. return [5 /*yield**/, _loop_1(backgroundImage)];
  46678. case 2:
  46679. _b.sent();
  46680. _b.label = 3;
  46681. case 3:
  46682. _i++;
  46683. return [3 /*break*/, 1];
  46684. case 4: return [2 /*return*/];
  46685. }
  46686. });
  46687. });
  46688. };
  46689. CanvasRenderer.prototype.renderSolidBorder = function (color, side, curvePoints) {
  46690. return __awaiter(this, void 0, void 0, function () {
  46691. return __generator(this, function (_a) {
  46692. this.path(parsePathForBorder(curvePoints, side));
  46693. this.ctx.fillStyle = asString(color);
  46694. this.ctx.fill();
  46695. return [2 /*return*/];
  46696. });
  46697. });
  46698. };
  46699. CanvasRenderer.prototype.renderDoubleBorder = function (color, width, side, curvePoints) {
  46700. return __awaiter(this, void 0, void 0, function () {
  46701. var outerPaths, innerPaths;
  46702. return __generator(this, function (_a) {
  46703. switch (_a.label) {
  46704. case 0:
  46705. if (!(width < 3)) return [3 /*break*/, 2];
  46706. return [4 /*yield*/, this.renderSolidBorder(color, side, curvePoints)];
  46707. case 1:
  46708. _a.sent();
  46709. return [2 /*return*/];
  46710. case 2:
  46711. outerPaths = parsePathForBorderDoubleOuter(curvePoints, side);
  46712. this.path(outerPaths);
  46713. this.ctx.fillStyle = asString(color);
  46714. this.ctx.fill();
  46715. innerPaths = parsePathForBorderDoubleInner(curvePoints, side);
  46716. this.path(innerPaths);
  46717. this.ctx.fill();
  46718. return [2 /*return*/];
  46719. }
  46720. });
  46721. });
  46722. };
  46723. CanvasRenderer.prototype.renderNodeBackgroundAndBorders = function (paint) {
  46724. return __awaiter(this, void 0, void 0, function () {
  46725. var styles, hasBackground, borders, backgroundPaintingArea, side, _i, borders_1, border;
  46726. var _this = this;
  46727. return __generator(this, function (_a) {
  46728. switch (_a.label) {
  46729. case 0:
  46730. this.applyEffects(paint.getEffects(2 /* BACKGROUND_BORDERS */));
  46731. styles = paint.container.styles;
  46732. hasBackground = !isTransparent(styles.backgroundColor) || styles.backgroundImage.length;
  46733. borders = [
  46734. { style: styles.borderTopStyle, color: styles.borderTopColor, width: styles.borderTopWidth },
  46735. { style: styles.borderRightStyle, color: styles.borderRightColor, width: styles.borderRightWidth },
  46736. { style: styles.borderBottomStyle, color: styles.borderBottomColor, width: styles.borderBottomWidth },
  46737. { style: styles.borderLeftStyle, color: styles.borderLeftColor, width: styles.borderLeftWidth }
  46738. ];
  46739. backgroundPaintingArea = calculateBackgroundCurvedPaintingArea(getBackgroundValueForIndex(styles.backgroundClip, 0), paint.curves);
  46740. if (!(hasBackground || styles.boxShadow.length)) return [3 /*break*/, 2];
  46741. this.ctx.save();
  46742. this.path(backgroundPaintingArea);
  46743. this.ctx.clip();
  46744. if (!isTransparent(styles.backgroundColor)) {
  46745. this.ctx.fillStyle = asString(styles.backgroundColor);
  46746. this.ctx.fill();
  46747. }
  46748. return [4 /*yield*/, this.renderBackgroundImage(paint.container)];
  46749. case 1:
  46750. _a.sent();
  46751. this.ctx.restore();
  46752. styles.boxShadow
  46753. .slice(0)
  46754. .reverse()
  46755. .forEach(function (shadow) {
  46756. _this.ctx.save();
  46757. var borderBoxArea = calculateBorderBoxPath(paint.curves);
  46758. var maskOffset = shadow.inset ? 0 : MASK_OFFSET;
  46759. var shadowPaintingArea = transformPath(borderBoxArea, -maskOffset + (shadow.inset ? 1 : -1) * shadow.spread.number, (shadow.inset ? 1 : -1) * shadow.spread.number, shadow.spread.number * (shadow.inset ? -2 : 2), shadow.spread.number * (shadow.inset ? -2 : 2));
  46760. if (shadow.inset) {
  46761. _this.path(borderBoxArea);
  46762. _this.ctx.clip();
  46763. _this.mask(shadowPaintingArea);
  46764. }
  46765. else {
  46766. _this.mask(borderBoxArea);
  46767. _this.ctx.clip();
  46768. _this.path(shadowPaintingArea);
  46769. }
  46770. _this.ctx.shadowOffsetX = shadow.offsetX.number + maskOffset;
  46771. _this.ctx.shadowOffsetY = shadow.offsetY.number;
  46772. _this.ctx.shadowColor = asString(shadow.color);
  46773. _this.ctx.shadowBlur = shadow.blur.number;
  46774. _this.ctx.fillStyle = shadow.inset ? asString(shadow.color) : 'rgba(0,0,0,1)';
  46775. _this.ctx.fill();
  46776. _this.ctx.restore();
  46777. });
  46778. _a.label = 2;
  46779. case 2:
  46780. side = 0;
  46781. _i = 0, borders_1 = borders;
  46782. _a.label = 3;
  46783. case 3:
  46784. if (!(_i < borders_1.length)) return [3 /*break*/, 13];
  46785. border = borders_1[_i];
  46786. if (!(border.style !== 0 /* NONE */ && !isTransparent(border.color) && border.width > 0)) return [3 /*break*/, 11];
  46787. if (!(border.style === 2 /* DASHED */)) return [3 /*break*/, 5];
  46788. return [4 /*yield*/, this.renderDashedDottedBorder(border.color, border.width, side, paint.curves, 2 /* DASHED */)];
  46789. case 4:
  46790. _a.sent();
  46791. return [3 /*break*/, 11];
  46792. case 5:
  46793. if (!(border.style === 3 /* DOTTED */)) return [3 /*break*/, 7];
  46794. return [4 /*yield*/, this.renderDashedDottedBorder(border.color, border.width, side, paint.curves, 3 /* DOTTED */)];
  46795. case 6:
  46796. _a.sent();
  46797. return [3 /*break*/, 11];
  46798. case 7:
  46799. if (!(border.style === 4 /* DOUBLE */)) return [3 /*break*/, 9];
  46800. return [4 /*yield*/, this.renderDoubleBorder(border.color, border.width, side, paint.curves)];
  46801. case 8:
  46802. _a.sent();
  46803. return [3 /*break*/, 11];
  46804. case 9: return [4 /*yield*/, this.renderSolidBorder(border.color, side, paint.curves)];
  46805. case 10:
  46806. _a.sent();
  46807. _a.label = 11;
  46808. case 11:
  46809. side++;
  46810. _a.label = 12;
  46811. case 12:
  46812. _i++;
  46813. return [3 /*break*/, 3];
  46814. case 13: return [2 /*return*/];
  46815. }
  46816. });
  46817. });
  46818. };
  46819. CanvasRenderer.prototype.renderDashedDottedBorder = function (color, width, side, curvePoints, style) {
  46820. return __awaiter(this, void 0, void 0, function () {
  46821. var strokePaths, boxPaths, startX, startY, endX, endY, length, dashLength, spaceLength, useLineDash, multiplier, numberOfDashes, minSpace, maxSpace, path1, path2, path1, path2;
  46822. return __generator(this, function (_a) {
  46823. this.ctx.save();
  46824. strokePaths = parsePathForBorderStroke(curvePoints, side);
  46825. boxPaths = parsePathForBorder(curvePoints, side);
  46826. if (style === 2 /* DASHED */) {
  46827. this.path(boxPaths);
  46828. this.ctx.clip();
  46829. }
  46830. if (isBezierCurve(boxPaths[0])) {
  46831. startX = boxPaths[0].start.x;
  46832. startY = boxPaths[0].start.y;
  46833. }
  46834. else {
  46835. startX = boxPaths[0].x;
  46836. startY = boxPaths[0].y;
  46837. }
  46838. if (isBezierCurve(boxPaths[1])) {
  46839. endX = boxPaths[1].end.x;
  46840. endY = boxPaths[1].end.y;
  46841. }
  46842. else {
  46843. endX = boxPaths[1].x;
  46844. endY = boxPaths[1].y;
  46845. }
  46846. if (side === 0 || side === 2) {
  46847. length = Math.abs(startX - endX);
  46848. }
  46849. else {
  46850. length = Math.abs(startY - endY);
  46851. }
  46852. this.ctx.beginPath();
  46853. if (style === 3 /* DOTTED */) {
  46854. this.formatPath(strokePaths);
  46855. }
  46856. else {
  46857. this.formatPath(boxPaths.slice(0, 2));
  46858. }
  46859. dashLength = width < 3 ? width * 3 : width * 2;
  46860. spaceLength = width < 3 ? width * 2 : width;
  46861. if (style === 3 /* DOTTED */) {
  46862. dashLength = width;
  46863. spaceLength = width;
  46864. }
  46865. useLineDash = true;
  46866. if (length <= dashLength * 2) {
  46867. useLineDash = false;
  46868. }
  46869. else if (length <= dashLength * 2 + spaceLength) {
  46870. multiplier = length / (2 * dashLength + spaceLength);
  46871. dashLength *= multiplier;
  46872. spaceLength *= multiplier;
  46873. }
  46874. else {
  46875. numberOfDashes = Math.floor((length + spaceLength) / (dashLength + spaceLength));
  46876. minSpace = (length - numberOfDashes * dashLength) / (numberOfDashes - 1);
  46877. maxSpace = (length - (numberOfDashes + 1) * dashLength) / numberOfDashes;
  46878. spaceLength =
  46879. maxSpace <= 0 || Math.abs(spaceLength - minSpace) < Math.abs(spaceLength - maxSpace)
  46880. ? minSpace
  46881. : maxSpace;
  46882. }
  46883. if (useLineDash) {
  46884. if (style === 3 /* DOTTED */) {
  46885. this.ctx.setLineDash([0, dashLength + spaceLength]);
  46886. }
  46887. else {
  46888. this.ctx.setLineDash([dashLength, spaceLength]);
  46889. }
  46890. }
  46891. if (style === 3 /* DOTTED */) {
  46892. this.ctx.lineCap = 'round';
  46893. this.ctx.lineWidth = width;
  46894. }
  46895. else {
  46896. this.ctx.lineWidth = width * 2 + 1.1;
  46897. }
  46898. this.ctx.strokeStyle = asString(color);
  46899. this.ctx.stroke();
  46900. this.ctx.setLineDash([]);
  46901. // dashed round edge gap
  46902. if (style === 2 /* DASHED */) {
  46903. if (isBezierCurve(boxPaths[0])) {
  46904. path1 = boxPaths[3];
  46905. path2 = boxPaths[0];
  46906. this.ctx.beginPath();
  46907. this.formatPath([new Vector(path1.end.x, path1.end.y), new Vector(path2.start.x, path2.start.y)]);
  46908. this.ctx.stroke();
  46909. }
  46910. if (isBezierCurve(boxPaths[1])) {
  46911. path1 = boxPaths[1];
  46912. path2 = boxPaths[2];
  46913. this.ctx.beginPath();
  46914. this.formatPath([new Vector(path1.end.x, path1.end.y), new Vector(path2.start.x, path2.start.y)]);
  46915. this.ctx.stroke();
  46916. }
  46917. }
  46918. this.ctx.restore();
  46919. return [2 /*return*/];
  46920. });
  46921. });
  46922. };
  46923. CanvasRenderer.prototype.render = function (element) {
  46924. return __awaiter(this, void 0, void 0, function () {
  46925. var stack;
  46926. return __generator(this, function (_a) {
  46927. switch (_a.label) {
  46928. case 0:
  46929. if (this.options.backgroundColor) {
  46930. this.ctx.fillStyle = asString(this.options.backgroundColor);
  46931. this.ctx.fillRect(this.options.x, this.options.y, this.options.width, this.options.height);
  46932. }
  46933. stack = parseStackingContexts(element);
  46934. return [4 /*yield*/, this.renderStack(stack)];
  46935. case 1:
  46936. _a.sent();
  46937. this.applyEffects([]);
  46938. return [2 /*return*/, this.canvas];
  46939. }
  46940. });
  46941. });
  46942. };
  46943. return CanvasRenderer;
  46944. }(Renderer));
  46945. var isTextInputElement = function (container) {
  46946. if (container instanceof TextareaElementContainer) {
  46947. return true;
  46948. }
  46949. else if (container instanceof SelectElementContainer) {
  46950. return true;
  46951. }
  46952. else if (container instanceof InputElementContainer && container.type !== RADIO && container.type !== CHECKBOX) {
  46953. return true;
  46954. }
  46955. return false;
  46956. };
  46957. var calculateBackgroundCurvedPaintingArea = function (clip, curves) {
  46958. switch (clip) {
  46959. case 0 /* BORDER_BOX */:
  46960. return calculateBorderBoxPath(curves);
  46961. case 2 /* CONTENT_BOX */:
  46962. return calculateContentBoxPath(curves);
  46963. case 1 /* PADDING_BOX */:
  46964. default:
  46965. return calculatePaddingBoxPath(curves);
  46966. }
  46967. };
  46968. var canvasTextAlign = function (textAlign) {
  46969. switch (textAlign) {
  46970. case 1 /* CENTER */:
  46971. return 'center';
  46972. case 2 /* RIGHT */:
  46973. return 'right';
  46974. case 0 /* LEFT */:
  46975. default:
  46976. return 'left';
  46977. }
  46978. };
  46979. // see https://github.com/niklasvh/html2canvas/pull/2645
  46980. var iOSBrokenFonts = ['-apple-system', 'system-ui'];
  46981. var fixIOSSystemFonts = function (fontFamilies) {
  46982. return /iPhone OS 15_(0|1)/.test(window.navigator.userAgent)
  46983. ? fontFamilies.filter(function (fontFamily) { return iOSBrokenFonts.indexOf(fontFamily) === -1; })
  46984. : fontFamilies;
  46985. };
  46986. var ForeignObjectRenderer = /** @class */ (function (_super) {
  46987. __extends(ForeignObjectRenderer, _super);
  46988. function ForeignObjectRenderer(context, options) {
  46989. var _this = _super.call(this, context, options) || this;
  46990. _this.canvas = options.canvas ? options.canvas : document.createElement('canvas');
  46991. _this.ctx = _this.canvas.getContext('2d');
  46992. _this.options = options;
  46993. _this.canvas.width = Math.floor(options.width * options.scale);
  46994. _this.canvas.height = Math.floor(options.height * options.scale);
  46995. _this.canvas.style.width = options.width + "px";
  46996. _this.canvas.style.height = options.height + "px";
  46997. _this.ctx.scale(_this.options.scale, _this.options.scale);
  46998. _this.ctx.translate(-options.x, -options.y);
  46999. _this.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized (" + options.width + "x" + options.height + " at " + options.x + "," + options.y + ") with scale " + options.scale);
  47000. return _this;
  47001. }
  47002. ForeignObjectRenderer.prototype.render = function (element) {
  47003. return __awaiter(this, void 0, void 0, function () {
  47004. var svg, img;
  47005. return __generator(this, function (_a) {
  47006. switch (_a.label) {
  47007. case 0:
  47008. svg = createForeignObjectSVG(this.options.width * this.options.scale, this.options.height * this.options.scale, this.options.scale, this.options.scale, element);
  47009. return [4 /*yield*/, loadSerializedSVG(svg)];
  47010. case 1:
  47011. img = _a.sent();
  47012. if (this.options.backgroundColor) {
  47013. this.ctx.fillStyle = asString(this.options.backgroundColor);
  47014. this.ctx.fillRect(0, 0, this.options.width * this.options.scale, this.options.height * this.options.scale);
  47015. }
  47016. this.ctx.drawImage(img, -this.options.x * this.options.scale, -this.options.y * this.options.scale);
  47017. return [2 /*return*/, this.canvas];
  47018. }
  47019. });
  47020. });
  47021. };
  47022. return ForeignObjectRenderer;
  47023. }(Renderer));
  47024. var loadSerializedSVG = function (svg) {
  47025. return new Promise(function (resolve, reject) {
  47026. var img = new Image();
  47027. img.onload = function () {
  47028. resolve(img);
  47029. };
  47030. img.onerror = reject;
  47031. img.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(svg));
  47032. });
  47033. };
  47034. var Logger = /** @class */ (function () {
  47035. function Logger(_a) {
  47036. var id = _a.id, enabled = _a.enabled;
  47037. this.id = id;
  47038. this.enabled = enabled;
  47039. this.start = Date.now();
  47040. }
  47041. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  47042. Logger.prototype.debug = function () {
  47043. var args = [];
  47044. for (var _i = 0; _i < arguments.length; _i++) {
  47045. args[_i] = arguments[_i];
  47046. }
  47047. if (this.enabled) {
  47048. // eslint-disable-next-line no-console
  47049. if (typeof window !== 'undefined' && window.console && typeof console.debug === 'function') {
  47050. // eslint-disable-next-line no-console
  47051. console.debug.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args));
  47052. }
  47053. else {
  47054. this.info.apply(this, args);
  47055. }
  47056. }
  47057. };
  47058. Logger.prototype.getTime = function () {
  47059. return Date.now() - this.start;
  47060. };
  47061. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  47062. Logger.prototype.info = function () {
  47063. var args = [];
  47064. for (var _i = 0; _i < arguments.length; _i++) {
  47065. args[_i] = arguments[_i];
  47066. }
  47067. if (this.enabled) {
  47068. // eslint-disable-next-line no-console
  47069. if (typeof window !== 'undefined' && window.console && typeof console.info === 'function') {
  47070. // eslint-disable-next-line no-console
  47071. console.info.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args));
  47072. }
  47073. }
  47074. };
  47075. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  47076. Logger.prototype.warn = function () {
  47077. var args = [];
  47078. for (var _i = 0; _i < arguments.length; _i++) {
  47079. args[_i] = arguments[_i];
  47080. }
  47081. if (this.enabled) {
  47082. // eslint-disable-next-line no-console
  47083. if (typeof window !== 'undefined' && window.console && typeof console.warn === 'function') {
  47084. // eslint-disable-next-line no-console
  47085. console.warn.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args));
  47086. }
  47087. else {
  47088. this.info.apply(this, args);
  47089. }
  47090. }
  47091. };
  47092. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  47093. Logger.prototype.error = function () {
  47094. var args = [];
  47095. for (var _i = 0; _i < arguments.length; _i++) {
  47096. args[_i] = arguments[_i];
  47097. }
  47098. if (this.enabled) {
  47099. // eslint-disable-next-line no-console
  47100. if (typeof window !== 'undefined' && window.console && typeof console.error === 'function') {
  47101. // eslint-disable-next-line no-console
  47102. console.error.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args));
  47103. }
  47104. else {
  47105. this.info.apply(this, args);
  47106. }
  47107. }
  47108. };
  47109. Logger.instances = {};
  47110. return Logger;
  47111. }());
  47112. var Context = /** @class */ (function () {
  47113. function Context(options, windowBounds) {
  47114. var _a;
  47115. this.windowBounds = windowBounds;
  47116. this.instanceName = "#" + Context.instanceCount++;
  47117. this.logger = new Logger({ id: this.instanceName, enabled: options.logging });
  47118. this.cache = (_a = options.cache) !== null && _a !== void 0 ? _a : new Cache(this, options);
  47119. }
  47120. Context.instanceCount = 1;
  47121. return Context;
  47122. }());
  47123. var html2canvas = function (element, options) {
  47124. if (options === void 0) { options = {}; }
  47125. return renderElement(element, options);
  47126. };
  47127. if (typeof window !== 'undefined') {
  47128. CacheStorage.setContext(window);
  47129. }
  47130. var renderElement = function (element, opts) { return __awaiter(void 0, void 0, void 0, function () {
  47131. var ownerDocument, defaultView, resourceOptions, contextOptions, windowOptions, windowBounds, context, foreignObjectRendering, cloneOptions, documentCloner, clonedElement, container, _a, width, height, left, top, backgroundColor, renderOptions, canvas, renderer, root, renderer;
  47132. var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
  47133. return __generator(this, function (_u) {
  47134. switch (_u.label) {
  47135. case 0:
  47136. if (!element || typeof element !== 'object') {
  47137. return [2 /*return*/, Promise.reject('Invalid element provided as first argument')];
  47138. }
  47139. ownerDocument = element.ownerDocument;
  47140. if (!ownerDocument) {
  47141. throw new Error("Element is not attached to a Document");
  47142. }
  47143. defaultView = ownerDocument.defaultView;
  47144. if (!defaultView) {
  47145. throw new Error("Document is not attached to a Window");
  47146. }
  47147. resourceOptions = {
  47148. allowTaint: (_b = opts.allowTaint) !== null && _b !== void 0 ? _b : false,
  47149. imageTimeout: (_c = opts.imageTimeout) !== null && _c !== void 0 ? _c : 15000,
  47150. proxy: opts.proxy,
  47151. useCORS: (_d = opts.useCORS) !== null && _d !== void 0 ? _d : false
  47152. };
  47153. contextOptions = __assign({ logging: (_e = opts.logging) !== null && _e !== void 0 ? _e : true, cache: opts.cache }, resourceOptions);
  47154. windowOptions = {
  47155. windowWidth: (_f = opts.windowWidth) !== null && _f !== void 0 ? _f : defaultView.innerWidth,
  47156. windowHeight: (_g = opts.windowHeight) !== null && _g !== void 0 ? _g : defaultView.innerHeight,
  47157. scrollX: (_h = opts.scrollX) !== null && _h !== void 0 ? _h : defaultView.pageXOffset,
  47158. scrollY: (_j = opts.scrollY) !== null && _j !== void 0 ? _j : defaultView.pageYOffset
  47159. };
  47160. windowBounds = new Bounds(windowOptions.scrollX, windowOptions.scrollY, windowOptions.windowWidth, windowOptions.windowHeight);
  47161. context = new Context(contextOptions, windowBounds);
  47162. foreignObjectRendering = (_k = opts.foreignObjectRendering) !== null && _k !== void 0 ? _k : false;
  47163. cloneOptions = {
  47164. allowTaint: (_l = opts.allowTaint) !== null && _l !== void 0 ? _l : false,
  47165. onclone: opts.onclone,
  47166. ignoreElements: opts.ignoreElements,
  47167. inlineImages: foreignObjectRendering,
  47168. copyStyles: foreignObjectRendering
  47169. };
  47170. context.logger.debug("Starting document clone with size " + windowBounds.width + "x" + windowBounds.height + " scrolled to " + -windowBounds.left + "," + -windowBounds.top);
  47171. documentCloner = new DocumentCloner(context, element, cloneOptions);
  47172. clonedElement = documentCloner.clonedReferenceElement;
  47173. if (!clonedElement) {
  47174. return [2 /*return*/, Promise.reject("Unable to find element in cloned iframe")];
  47175. }
  47176. return [4 /*yield*/, documentCloner.toIFrame(ownerDocument, windowBounds)];
  47177. case 1:
  47178. container = _u.sent();
  47179. _a = isBodyElement(clonedElement) || isHTMLElement(clonedElement)
  47180. ? parseDocumentSize(clonedElement.ownerDocument)
  47181. : parseBounds(context, clonedElement), width = _a.width, height = _a.height, left = _a.left, top = _a.top;
  47182. backgroundColor = parseBackgroundColor(context, clonedElement, opts.backgroundColor);
  47183. renderOptions = {
  47184. canvas: opts.canvas,
  47185. backgroundColor: backgroundColor,
  47186. scale: (_o = (_m = opts.scale) !== null && _m !== void 0 ? _m : defaultView.devicePixelRatio) !== null && _o !== void 0 ? _o : 1,
  47187. x: ((_p = opts.x) !== null && _p !== void 0 ? _p : 0) + left,
  47188. y: ((_q = opts.y) !== null && _q !== void 0 ? _q : 0) + top,
  47189. width: (_r = opts.width) !== null && _r !== void 0 ? _r : Math.ceil(width),
  47190. height: (_s = opts.height) !== null && _s !== void 0 ? _s : Math.ceil(height)
  47191. };
  47192. if (!foreignObjectRendering) return [3 /*break*/, 3];
  47193. context.logger.debug("Document cloned, using foreign object rendering");
  47194. renderer = new ForeignObjectRenderer(context, renderOptions);
  47195. return [4 /*yield*/, renderer.render(clonedElement)];
  47196. case 2:
  47197. canvas = _u.sent();
  47198. return [3 /*break*/, 5];
  47199. case 3:
  47200. context.logger.debug("Document cloned, element located at " + left + "," + top + " with size " + width + "x" + height + " using computed rendering");
  47201. context.logger.debug("Starting DOM parsing");
  47202. root = parseTree(context, clonedElement);
  47203. if (backgroundColor === root.styles.backgroundColor) {
  47204. root.styles.backgroundColor = COLORS.TRANSPARENT;
  47205. }
  47206. context.logger.debug("Starting renderer for element at " + renderOptions.x + "," + renderOptions.y + " with size " + renderOptions.width + "x" + renderOptions.height);
  47207. renderer = new CanvasRenderer(context, renderOptions);
  47208. return [4 /*yield*/, renderer.render(root)];
  47209. case 4:
  47210. canvas = _u.sent();
  47211. _u.label = 5;
  47212. case 5:
  47213. if ((_t = opts.removeContainer) !== null && _t !== void 0 ? _t : true) {
  47214. if (!DocumentCloner.destroy(container)) {
  47215. context.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore");
  47216. }
  47217. }
  47218. context.logger.debug("Finished rendering");
  47219. return [2 /*return*/, canvas];
  47220. }
  47221. });
  47222. }); };
  47223. var parseBackgroundColor = function (context, element, backgroundColorOverride) {
  47224. var ownerDocument = element.ownerDocument;
  47225. // http://www.w3.org/TR/css3-background/#special-backgrounds
  47226. var documentBackgroundColor = ownerDocument.documentElement
  47227. ? parseColor(context, getComputedStyle(ownerDocument.documentElement).backgroundColor)
  47228. : COLORS.TRANSPARENT;
  47229. var bodyBackgroundColor = ownerDocument.body
  47230. ? parseColor(context, getComputedStyle(ownerDocument.body).backgroundColor)
  47231. : COLORS.TRANSPARENT;
  47232. var defaultBackgroundColor = typeof backgroundColorOverride === 'string'
  47233. ? parseColor(context, backgroundColorOverride)
  47234. : backgroundColorOverride === null
  47235. ? COLORS.TRANSPARENT
  47236. : 0xffffffff;
  47237. return element === ownerDocument.documentElement
  47238. ? isTransparent(documentBackgroundColor)
  47239. ? isTransparent(bodyBackgroundColor)
  47240. ? defaultBackgroundColor
  47241. : bodyBackgroundColor
  47242. : documentBackgroundColor
  47243. : defaultBackgroundColor;
  47244. };
  47245. return html2canvas;
  47246. })));
  47247. });
  47248. /**
  47249. * 先把body上的内容隐藏起来
  47250. * @returns {Array} displayList 记录body子元素原始的显隐信息
  47251. */
  47252. var hideBodyChildren = function hideBodyChildren() {
  47253. var _context;
  47254. var displayList = [];
  47255. /** @type {HTMLElement[]}*/
  47256. forEach$3(_context = from_1$2(document.body.children)).call(_context, function (dom, index) {
  47257. displayList[index] = dom.style.display;
  47258. dom.style.display = 'none';
  47259. });
  47260. return displayList;
  47261. };
  47262. /**
  47263. * 复原body上被隐藏的内容
  47264. * @param {Array} displayList 记录body子元素原始的显隐信息
  47265. */
  47266. var undoHideBodyChildren = function undoHideBodyChildren() {
  47267. var _context2;
  47268. var displayList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  47269. /** @type {HTMLElement[]}*/
  47270. forEach$3(_context2 = from_1$2(document.body.children)).call(_context2, function (dom, index) {
  47271. if (typeof displayList[index] !== 'undefined') {
  47272. dom.style.display = displayList[index];
  47273. }
  47274. });
  47275. };
  47276. /**
  47277. * 将预览区域的内容放在body上准备后续导出操作
  47278. * @param {HTMLElement} previeweDom 预览区域的dom
  47279. * @param {function} cb 准备好导出后开始执行导出操作
  47280. */
  47281. var getReadyToExport = function getReadyToExport(previeweDom, cb) {
  47282. var cherryPreviewer =
  47283. /** @type {HTMLElement}*/
  47284. previeweDom.cloneNode(true); // 强制去掉预览区的隐藏class
  47285. cherryPreviewer.className = cherryPreviewer.className.replace('cherry-previewer--hidden', '');
  47286. cherryPreviewer.style.width = '100%';
  47287. var mmls = cherryPreviewer.querySelectorAll('mjx-assistive-mml'); // a fix for html2canvas
  47288. forEach$3(mmls).call(mmls, function (e) {
  47289. if (e instanceof HTMLElement) e.style.setProperty('visibility', 'hidden');
  47290. });
  47291. var cherryWrapper = document.createElement('div');
  47292. cherryWrapper.appendChild(cherryPreviewer);
  47293. var displayList = hideBodyChildren();
  47294. document.body.appendChild(cherryWrapper);
  47295. var bodyOverflow = document.body.style.overflow;
  47296. document.body.style.overflow = 'visible';
  47297. cb(cherryPreviewer, function () {
  47298. cherryWrapper.remove();
  47299. undoHideBodyChildren(displayList);
  47300. document.body.style.overflow = bodyOverflow;
  47301. });
  47302. };
  47303. /**
  47304. * 下载文件
  47305. * @param {String} downloadUrl 图片本地地址
  47306. * @param {String} fileName 导出图片文件名
  47307. */
  47308. var fileDownload = function fileDownload(downloadUrl, fileName) {
  47309. var aLink = document.createElement('a');
  47310. aLink.style.display = 'none';
  47311. aLink.href = downloadUrl;
  47312. aLink.download = "".concat(fileName, ".png");
  47313. document.body.appendChild(aLink);
  47314. aLink.click();
  47315. document.body.removeChild(aLink);
  47316. };
  47317. /**
  47318. * 利用window.print导出成PDF
  47319. * @param {HTMLElement} previeweDom 预览区域的dom
  47320. * @param {String} fileName 导出PDF文件名
  47321. */
  47322. function exportPDF(previeweDom, fileName) {
  47323. var oldTitle = document.title;
  47324. document.title = fileName;
  47325. getReadyToExport(previeweDom, function (
  47326. /** @type {HTMLElement}*/
  47327. cherryPreviewer,
  47328. /** @type {function}*/
  47329. thenFinish) {
  47330. window.print();
  47331. thenFinish();
  47332. document.title = oldTitle;
  47333. });
  47334. }
  47335. /**
  47336. * 利用canvas将html内容导出成图片
  47337. * @param {HTMLElement} previeweDom 预览区域的dom
  47338. * @param {String} fileName 导出图片文件名
  47339. */
  47340. function exportScreenShot(previeweDom, fileName) {
  47341. getReadyToExport(previeweDom, function (
  47342. /** @type {HTMLElement}*/
  47343. cherryPreviewer,
  47344. /** @type {function}*/
  47345. thenFinish) {
  47346. window.scrollTo(0, 0);
  47347. html2canvas(cherryPreviewer, {
  47348. allowTaint: true,
  47349. height: cherryPreviewer.clientHeight,
  47350. width: cherryPreviewer.clientWidth,
  47351. scrollY: 0,
  47352. scrollX: 0
  47353. }).then(function (canvas) {
  47354. var imgData = canvas.toDataURL('image/jpeg');
  47355. fileDownload(imgData, fileName);
  47356. thenFinish();
  47357. });
  47358. });
  47359. }
  47360. /**
  47361. * 导出 markdown 文件
  47362. * @param {String} markdownText markdown文本
  47363. * @param {String} fileName 导出markdown文件名
  47364. */
  47365. function exportMarkdownFile(markdownText, fileName) {
  47366. var blob = new Blob([markdownText], {
  47367. type: 'text/markdown;charset=utf-8'
  47368. });
  47369. var aLink = document.createElement('a');
  47370. aLink.style.display = 'none';
  47371. aLink.href = url$2.createObjectURL(blob);
  47372. aLink.download = "".concat(fileName, ".md");
  47373. document.body.appendChild(aLink);
  47374. aLink.click();
  47375. document.body.removeChild(aLink);
  47376. }
  47377. /**
  47378. * 导出预览区 HTML 文件
  47379. * @param {String} HTMLText HTML文本
  47380. * @param {String} fileName 导出HTML文件名
  47381. */
  47382. function exportHTMLFile(HTMLText, fileName) {
  47383. var blob = new Blob([HTMLText], {
  47384. type: 'text/markdown;charset=utf-8'
  47385. });
  47386. var aLink = document.createElement('a');
  47387. aLink.style.display = 'none';
  47388. aLink.href = url$2.createObjectURL(blob);
  47389. aLink.download = "".concat(fileName, ".html");
  47390. document.body.appendChild(aLink);
  47391. aLink.click();
  47392. document.body.removeChild(aLink);
  47393. }
  47394. var $propertyIsEnumerable$2 = objectPropertyIsEnumerable.f;
  47395. var propertyIsEnumerable$1 = functionUncurryThis($propertyIsEnumerable$2);
  47396. var push$9 = functionUncurryThis([].push);
  47397. // `Object.{ entries, values }` methods implementation
  47398. var createMethod$5 = function (TO_ENTRIES) {
  47399. return function (it) {
  47400. var O = toIndexedObject(it);
  47401. var keys = objectKeys(O);
  47402. var length = keys.length;
  47403. var i = 0;
  47404. var result = [];
  47405. var key;
  47406. while (length > i) {
  47407. key = keys[i++];
  47408. if (!descriptors || propertyIsEnumerable$1(O, key)) {
  47409. push$9(result, TO_ENTRIES ? [key, O[key]] : O[key]);
  47410. }
  47411. }
  47412. return result;
  47413. };
  47414. };
  47415. var objectToArray = {
  47416. // `Object.entries` method
  47417. // https://tc39.es/ecma262/#sec-object.entries
  47418. entries: createMethod$5(true),
  47419. // `Object.values` method
  47420. // https://tc39.es/ecma262/#sec-object.values
  47421. values: createMethod$5(false)
  47422. };
  47423. var $values = objectToArray.values;
  47424. // `Object.values` method
  47425. // https://tc39.es/ecma262/#sec-object.values
  47426. _export({ target: 'Object', stat: true }, {
  47427. values: function values(O) {
  47428. return $values(O);
  47429. }
  47430. });
  47431. var values$1 = path.Object.values;
  47432. var values$2 = values$1;
  47433. var values$3 = values$2;
  47434. var $entries = objectToArray.entries;
  47435. // `Object.entries` method
  47436. // https://tc39.es/ecma262/#sec-object.entries
  47437. _export({ target: 'Object', stat: true }, {
  47438. entries: function entries(O) {
  47439. return $entries(O);
  47440. }
  47441. });
  47442. var entries = path.Object.entries;
  47443. var entries$1 = entries;
  47444. var entries$2 = entries$1;
  47445. /**
  47446. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  47447. *
  47448. * Licensed under the Apache License, Version 2.0 (the "License");
  47449. * you may not use this file except in compliance with the License.
  47450. * You may obtain a copy of the License at
  47451. *
  47452. * http://www.apache.org/licenses/LICENSE-2.0
  47453. *
  47454. * Unless required by applicable law or agreed to in writing, software
  47455. * distributed under the License is distributed on an "AS IS" BASIS,
  47456. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  47457. * See the License for the specific language governing permissions and
  47458. * limitations under the License.
  47459. */
  47460. /**
  47461. * 用于在图片四周画出调整图片尺寸的边框
  47462. */
  47463. var imgSizeHander = {
  47464. mouseResize: {},
  47465. getImgPosition: function getImgPosition() {
  47466. var position = this.img.getBoundingClientRect();
  47467. var editorPosition = this.previewerDom.parentNode.getBoundingClientRect();
  47468. var padding = _parseFloat$2(this.img.style.padding) || 0;
  47469. return {
  47470. bottom: position.bottom - editorPosition.bottom,
  47471. top: position.top - editorPosition.top + padding * 1.5,
  47472. height: position.height,
  47473. width: position.width,
  47474. right: position.right - editorPosition.right,
  47475. left: position.left - editorPosition.left + padding * 1.5,
  47476. x: position.x - editorPosition.x,
  47477. y: position.y - editorPosition.y
  47478. };
  47479. },
  47480. initBubbleButtons: function initBubbleButtons() {
  47481. var position = this.getImgPosition();
  47482. return {
  47483. points: {
  47484. arr: ['leftTop', 'leftBottom', 'rightTop', 'rightBottom', 'leftMiddle', 'middleBottom', 'middleTop', 'rightMiddle'],
  47485. arrInfo: {
  47486. leftTop: {
  47487. name: '20',
  47488. left: 0,
  47489. top: 0
  47490. },
  47491. leftBottom: {
  47492. name: '00',
  47493. left: 0,
  47494. top: 0
  47495. },
  47496. rightTop: {
  47497. name: '22',
  47498. left: 0,
  47499. top: 0
  47500. },
  47501. rightBottom: {
  47502. name: '02',
  47503. left: 0,
  47504. top: 0
  47505. },
  47506. leftMiddle: {
  47507. name: '10',
  47508. left: 0,
  47509. top: 0
  47510. },
  47511. middleBottom: {
  47512. name: '01',
  47513. left: 0,
  47514. top: 0
  47515. },
  47516. middleTop: {
  47517. name: '21',
  47518. left: 0,
  47519. top: 0
  47520. },
  47521. rightMiddle: {
  47522. name: '12',
  47523. left: 0,
  47524. top: 0
  47525. }
  47526. }
  47527. },
  47528. imgSrc: this.img.src,
  47529. style: {
  47530. width: this.img.width,
  47531. height: this.img.height,
  47532. left: position.left - 1,
  47533. top: position.top - 1,
  47534. marginTop: 0,
  47535. marginLeft: 0
  47536. },
  47537. scrollTop: this.previewerDom.scrollTop,
  47538. position: position
  47539. };
  47540. },
  47541. showBubble: function showBubble(img, container, previewerDom) {
  47542. if (this.$isResizing()) {
  47543. return;
  47544. }
  47545. this.img = img;
  47546. this.previewerDom = previewerDom;
  47547. this.container = container;
  47548. this.buts = this.initBubbleButtons();
  47549. this.drawBubbleButs();
  47550. },
  47551. emit: function emit(type) {
  47552. var event = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  47553. switch (type) {
  47554. case 'mousedown':
  47555. return this.resizeBegin(event);
  47556. case 'mouseup':
  47557. return this.resizeStop(event);
  47558. case 'mousemove':
  47559. return this.resizeWorking(event);
  47560. case 'scroll':
  47561. return this.dealScroll(event);
  47562. case 'remove':
  47563. return this.remove();
  47564. case 'previewUpdate':
  47565. return this.previewUpdate(event);
  47566. }
  47567. },
  47568. previewUpdate: function previewUpdate(callback) {
  47569. if (this.$isResizing()) {
  47570. return;
  47571. }
  47572. this.remove();
  47573. callback();
  47574. },
  47575. drawBubbleButs: function drawBubbleButs() {
  47576. var _context,
  47577. _this = this;
  47578. if (this.butsLayout) {
  47579. return this.updateBubbleButs();
  47580. }
  47581. this.butsLayout = this.container;
  47582. this.butsImg = document.createElement('div');
  47583. this.butsImg.className = 'cherry-previewer-img-size-hander__background';
  47584. this.butsImg.style.backgroundImage = "url(".concat(this.buts.imgSrc, ")");
  47585. this.butsLayout.appendChild(this.butsImg);
  47586. this.butsPoints = {};
  47587. forEach$3(_context = keys$3(this.buts.points.arr)).call(_context, function (index) {
  47588. var name = _this.buts.points.arr[index];
  47589. var tmp = document.createElement('div');
  47590. tmp.className = ['cherry-previewer-img-size-hander__points', "cherry-previewer-img-size-hander__points-".concat(name)].join(' ');
  47591. tmp.dataset.name = name;
  47592. _this.butsLayout.appendChild(tmp);
  47593. _this.butsPoints["pints-".concat(name)] = tmp;
  47594. });
  47595. return this.updateBubbleButs();
  47596. },
  47597. remove: function remove() {
  47598. this.butsLayout = false;
  47599. },
  47600. updateBubbleButs: function updateBubbleButs() {
  47601. var _context2,
  47602. _this2 = this,
  47603. _context3;
  47604. this.$updatePointsInfo();
  47605. forEach$3(_context2 = keys$3(this.buts.style)).call(_context2, function (name) {
  47606. _this2.butsLayout.style[name] = "".concat(_this2.buts.style[name], "px");
  47607. });
  47608. forEach$3(_context3 = keys$3(this.buts.points.arr)).call(_context3, function (index) {
  47609. var name = _this2.buts.points.arr[index];
  47610. _this2.butsPoints["pints-".concat(name)].style.top = "".concat(_this2.buts.points.arrInfo[name].top, "px");
  47611. _this2.butsPoints["pints-".concat(name)].style.left = "".concat(_this2.buts.points.arrInfo[name].left, "px");
  47612. });
  47613. },
  47614. $updatePointsInfo: function $updatePointsInfo() {
  47615. var _context4,
  47616. _this3 = this;
  47617. var pointLeft = this.buts.style.width;
  47618. var pointTop = this.buts.style.height;
  47619. var newPointsInfo = this.$getPointsInfo(pointLeft, pointTop);
  47620. forEach$3(_context4 = keys$3(this.buts.points.arr)).call(_context4, function (index) {
  47621. var name = _this3.buts.points.arr[index];
  47622. if (_this3.buts.points.arrInfo[name].left !== newPointsInfo[name].left) {
  47623. _this3.buts.points.arrInfo[name].left = newPointsInfo[name].left;
  47624. }
  47625. if (_this3.buts.points.arrInfo[name].top !== newPointsInfo[name].top) {
  47626. _this3.buts.points.arrInfo[name].top = newPointsInfo[name].top;
  47627. }
  47628. });
  47629. },
  47630. $getPointsInfo: function $getPointsInfo(left, top) {
  47631. return {
  47632. leftTop: {
  47633. left: 0,
  47634. top: 0
  47635. },
  47636. leftBottom: {
  47637. left: 0,
  47638. top: top
  47639. },
  47640. rightTop: {
  47641. left: left,
  47642. top: 0
  47643. },
  47644. rightBottom: {
  47645. left: left,
  47646. top: top
  47647. },
  47648. leftMiddle: {
  47649. left: 0,
  47650. top: top / 2
  47651. },
  47652. middleBottom: {
  47653. left: left / 2,
  47654. top: top
  47655. },
  47656. middleTop: {
  47657. left: left / 2,
  47658. top: 0
  47659. },
  47660. rightMiddle: {
  47661. left: left,
  47662. top: top / 2
  47663. }
  47664. };
  47665. },
  47666. $isResizing: function $isResizing() {
  47667. return this.mouseResize.resize;
  47668. },
  47669. dealScroll: function dealScroll(event) {
  47670. var position = this.getImgPosition();
  47671. if (this.butsLayout.style.marginTop !== position.top - this.buts.position.top) {
  47672. this.butsLayout.style.marginTop = "".concat(position.top - this.buts.position.top, "px");
  47673. this.buts.style.marginTop = "".concat(position.top - this.buts.position.top, "px");
  47674. }
  47675. if (this.butsLayout.style.marginLeft !== position.left - this.buts.position.left) {
  47676. this.butsLayout.style.marginLeft = "".concat(position.left - this.buts.position.left, "px");
  47677. this.buts.style.marginLeft = "".concat(position.left - this.buts.position.left, "px");
  47678. }
  47679. },
  47680. initMouse: function initMouse() {
  47681. return {
  47682. left: 0,
  47683. top: 0,
  47684. resize: false,
  47685. name: ''
  47686. };
  47687. },
  47688. resizeBegin: function resizeBegin(event) {
  47689. var point = event.target;
  47690. if (!point.classList.contains('cherry-previewer-img-size-hander__points')) {
  47691. return false;
  47692. }
  47693. this.mouseResize.left = event.clientX;
  47694. this.mouseResize.top = event.clientY;
  47695. this.mouseResize.resize = true;
  47696. this.mouseResize.name = point.getAttribute('data-name');
  47697. this.previewerDom.classList.add('doing-resize-img');
  47698. },
  47699. resizeStop: function resizeStop(event, buts, editor, menu) {
  47700. if (!this.$isResizing()) {
  47701. return false;
  47702. }
  47703. this.img.style.width = "".concat(this.buts.style.width, "px");
  47704. this.img.style.height = "".concat(this.buts.style.height, "px");
  47705. this.buts.style.marginTop = 0;
  47706. this.buts.style.marginLeft = 0;
  47707. this.updateBubbleButs();
  47708. this.mouseResize.resize = false;
  47709. this.previewerDom.classList.remove('doing-resize-img');
  47710. this.change();
  47711. },
  47712. resizeWorking: function resizeWorking(event, buts) {
  47713. if (!this.$isResizing()) {
  47714. return;
  47715. }
  47716. var changeX = event.clientX - this.mouseResize.left;
  47717. var changeY = event.clientY - this.mouseResize.top;
  47718. var change = {};
  47719. switch (this.mouseResize.name) {
  47720. case 'leftTop':
  47721. case 'leftBottom':
  47722. case 'leftMiddle':
  47723. change = this.$getChange(changeX, changeY, 'x');
  47724. this.buts.style.width = this.buts.position.width - change.changeX;
  47725. if (this.mouseResize.name !== 'leftMiddle') {
  47726. this.buts.style.height = this.buts.position.height - change.changeY;
  47727. }
  47728. break;
  47729. case 'rightTop':
  47730. case 'rightBottom':
  47731. case 'rightMiddle':
  47732. change = this.$getChange(changeX, changeY, 'x');
  47733. this.buts.style.width = this.buts.position.width + change.changeX;
  47734. if (this.mouseResize.name !== 'rightMiddle') {
  47735. this.buts.style.height = this.buts.position.height + change.changeY;
  47736. }
  47737. break;
  47738. case 'middleTop':
  47739. change = this.$getChange(changeX, changeY, 'y');
  47740. this.buts.style.height = this.buts.position.height - change.changeY;
  47741. break;
  47742. case 'middleBottom':
  47743. change = this.$getChange(changeX, changeY, 'y');
  47744. this.buts.style.height = this.buts.position.height + change.changeY;
  47745. break;
  47746. }
  47747. this.updateBubbleButs();
  47748. this.change();
  47749. },
  47750. change: function change() {
  47751. this.emitChange(this.img, {
  47752. width: this.buts.style.width,
  47753. height: this.buts.style.height
  47754. });
  47755. },
  47756. bindChange: function bindChange(func) {
  47757. this.emitChange = func;
  47758. },
  47759. /**
  47760. * 根据宽(x)或高(y)来进行等比例缩放
  47761. * @param {number} x 宽度
  47762. * @param {number} y 高度
  47763. * @param {string} type 类型,以宽/高为基准做等比例缩放
  47764. * @returns
  47765. */
  47766. $getChange: function $getChange(x, y, type) {
  47767. var ret = {
  47768. changeX: 0,
  47769. changeY: 0
  47770. };
  47771. switch (type) {
  47772. case 'y':
  47773. ret.changeY = y;
  47774. ret.changeX = y * this.buts.position.width / this.buts.position.height;
  47775. break;
  47776. default:
  47777. ret.changeX = x;
  47778. ret.changeY = x * this.buts.position.height / this.buts.position.width;
  47779. break;
  47780. }
  47781. return ret;
  47782. }
  47783. };
  47784. var $every = arrayIteration.every;
  47785. var STRICT_METHOD$4 = arrayMethodIsStrict('every');
  47786. // `Array.prototype.every` method
  47787. // https://tc39.es/ecma262/#sec-array.prototype.every
  47788. _export({ target: 'Array', proto: true, forced: !STRICT_METHOD$4 }, {
  47789. every: function every(callbackfn /* , thisArg */) {
  47790. return $every(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  47791. }
  47792. });
  47793. var every = entryVirtual('Array').every;
  47794. var ArrayPrototype$e = Array.prototype;
  47795. var every$1 = function (it) {
  47796. var own = it.every;
  47797. return it === ArrayPrototype$e || (objectIsPrototypeOf(ArrayPrototype$e, it) && own === ArrayPrototype$e.every) ? every : own;
  47798. };
  47799. var every$2 = every$1;
  47800. var every$3 = every$2;
  47801. var TypeError$o = global_1.TypeError;
  47802. // `FlattenIntoArray` abstract operation
  47803. // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
  47804. var flattenIntoArray = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {
  47805. var targetIndex = start;
  47806. var sourceIndex = 0;
  47807. var mapFn = mapper ? functionBindContext(mapper, thisArg) : false;
  47808. var element, elementLen;
  47809. while (sourceIndex < sourceLen) {
  47810. if (sourceIndex in source) {
  47811. element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
  47812. if (depth > 0 && isArray(element)) {
  47813. elementLen = lengthOfArrayLike(element);
  47814. targetIndex = flattenIntoArray(target, original, element, elementLen, targetIndex, depth - 1) - 1;
  47815. } else {
  47816. if (targetIndex >= 0x1FFFFFFFFFFFFF) throw TypeError$o('Exceed the acceptable array length');
  47817. target[targetIndex] = element;
  47818. }
  47819. targetIndex++;
  47820. }
  47821. sourceIndex++;
  47822. }
  47823. return targetIndex;
  47824. };
  47825. var flattenIntoArray_1 = flattenIntoArray;
  47826. // `Array.prototype.flat` method
  47827. // https://tc39.es/ecma262/#sec-array.prototype.flat
  47828. _export({ target: 'Array', proto: true }, {
  47829. flat: function flat(/* depthArg = 1 */) {
  47830. var depthArg = arguments.length ? arguments[0] : undefined;
  47831. var O = toObject(this);
  47832. var sourceLen = lengthOfArrayLike(O);
  47833. var A = arraySpeciesCreate(O, 0);
  47834. A.length = flattenIntoArray_1(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toIntegerOrInfinity(depthArg));
  47835. return A;
  47836. }
  47837. });
  47838. var flat = entryVirtual('Array').flat;
  47839. var ArrayPrototype$f = Array.prototype;
  47840. var flat$1 = function (it) {
  47841. var own = it.flat;
  47842. return it === ArrayPrototype$f || (objectIsPrototypeOf(ArrayPrototype$f, it) && own === ArrayPrototype$f.flat) ? flat : own;
  47843. };
  47844. var flat$2 = flat$1;
  47845. var flat$3 = flat$2;
  47846. /**
  47847. * 用于在表格上出现编辑区,并提供拖拽行列的功能
  47848. */
  47849. var TableHandler = /*#__PURE__*/function () {
  47850. /**
  47851. * 用来存放所有的数据
  47852. */
  47853. function TableHandler(trigger, target, container, previewerDom, codeMirror) {
  47854. _classCallCheck(this, TableHandler);
  47855. _defineProperty(this, "tableEditor", {
  47856. info: {},
  47857. // 当前点击的预览区域table的相关信息
  47858. tableCodes: [],
  47859. // 编辑器内所有的表格语法
  47860. editorDom: {} // 编辑器容器
  47861. });
  47862. // 触发方式 click / hover
  47863. this.trigger = trigger;
  47864. this.target = target;
  47865. this.previewerDom = previewerDom;
  47866. this.container = container;
  47867. this.codeMirror = codeMirror;
  47868. this.$initReg();
  47869. this.$findTableInEditor();
  47870. }
  47871. _createClass(TableHandler, [{
  47872. key: "emit",
  47873. value: function emit(type) {
  47874. var event = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  47875. var callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
  47876. switch (type) {
  47877. case 'keyup':
  47878. return this.trigger === 'click' && this.$onInputChange(event);
  47879. case 'remove':
  47880. return this.$remove();
  47881. case 'scroll':
  47882. return this.$refreshPosition();
  47883. case 'previewUpdate':
  47884. return this.$refreshPosition();
  47885. case 'mouseup':
  47886. return this.trigger === 'click' && this.$tryRemoveMe(event, callback);
  47887. }
  47888. }
  47889. }, {
  47890. key: "$tryRemoveMe",
  47891. value: function $tryRemoveMe(event, callback) {
  47892. if (!/textarea/i.test(event.target.tagName)) {
  47893. this.$remove();
  47894. callback();
  47895. }
  47896. }
  47897. /**
  47898. * 获取目标dom的位置信息和尺寸信息
  47899. */
  47900. }, {
  47901. key: "$getPosition",
  47902. value: function $getPosition() {
  47903. var node = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.tableEditor.info.tdNode;
  47904. var position = node.getBoundingClientRect();
  47905. var editorPosition = this.previewerDom.parentNode.getBoundingClientRect();
  47906. return {
  47907. top: position.top - editorPosition.top,
  47908. height: position.height,
  47909. width: position.width,
  47910. left: position.left - editorPosition.left,
  47911. maxHeight: editorPosition.height
  47912. };
  47913. }
  47914. }, {
  47915. key: "setStyle",
  47916. value: function setStyle(element, property, value) {
  47917. var info = element.getBoundingClientRect();
  47918. if (info[property] !== value) {
  47919. element.style[property] = value;
  47920. }
  47921. }
  47922. /**
  47923. * TODO: 这里是分别对文本框、操作符号和选项设置偏移,应该作为一个整体来设置
  47924. */
  47925. }, {
  47926. key: "$setInputOffset",
  47927. value: function $setInputOffset() {
  47928. var tdInfo = this.$getPosition();
  47929. var inputDiv = this.tableEditor.editorDom.inputDiv; // 设置文本框的偏移及大小
  47930. this.setStyle(inputDiv, 'width', "".concat(tdInfo.width, "px"));
  47931. this.setStyle(inputDiv, 'height', "".concat(tdInfo.height, "px"));
  47932. this.setStyle(inputDiv, 'top', "".concat(tdInfo.top, "px"));
  47933. this.setStyle(inputDiv, 'left', "".concat(tdInfo.left, "px")); // 根据是否超出边界来显示或者隐藏元素
  47934. var isWithinBounds = tdInfo.top >= 0 && tdInfo.top + tdInfo.height <= tdInfo.maxHeight;
  47935. this.setStyle(inputDiv, 'display', isWithinBounds ? '' : 'none');
  47936. }
  47937. /**
  47938. * 刷新操作符位置
  47939. */
  47940. }, {
  47941. key: "$setSymbolOffset",
  47942. value: function $setSymbolOffset() {
  47943. var _context2,
  47944. _this = this;
  47945. var container = this.tableEditor.editorDom.symbolContainer;
  47946. var _this$tableEditor$inf = this.tableEditor.info,
  47947. tableNode = _this$tableEditor$inf.tableNode,
  47948. trNode = _this$tableEditor$inf.trNode,
  47949. isTHead = _this$tableEditor$inf.isTHead;
  47950. var tableInfo = this.$getPosition(tableNode);
  47951. var trInfo = this.$getPosition(trNode);
  47952. var tdInfo = this.$getPosition();
  47953. var previewerRect = this.previewerDom.getBoundingClientRect(); // 设置容器宽高
  47954. this.setStyle(this.container, 'width', "".concat(tableInfo.width, "px"));
  47955. this.setStyle(this.container, 'height', "".concat(tableInfo.height, "px"));
  47956. this.setStyle(this.container, 'top', "".concat(tableInfo.top, "px"));
  47957. this.setStyle(this.container, 'left', "".concat(tableInfo.left, "px")); // 判断是否在预览区内
  47958. var isWithinBounds = function isWithinBounds(symbol) {
  47959. var _context;
  47960. var symbolRect = symbol.getBoundingClientRect();
  47961. var boundMap = {
  47962. top: [previewerRect.top, previewerRect.top + previewerRect.height - symbolRect.height],
  47963. left: [previewerRect.left, previewerRect.left + previewerRect.width - symbolRect.width]
  47964. };
  47965. return every$3(_context = entries$2(boundMap)).call(_context, function (_ref) {
  47966. var _ref2 = _slicedToArray(_ref, 2),
  47967. key = _ref2[0],
  47968. _ref2$ = _slicedToArray(_ref2[1], 2),
  47969. min = _ref2$[0],
  47970. max = _ref2$[1];
  47971. return symbolRect[key] >= min && symbolRect[key] <= max;
  47972. });
  47973. }; // 设置操作符位置与控制显隐
  47974. forEach$3(_context2 = container.childNodes).call(_context2, function (node) {
  47975. var _context3;
  47976. var _node$dataset = node.dataset,
  47977. index = _node$dataset.index,
  47978. type = _node$dataset.type,
  47979. dir = _node$dataset.dir;
  47980. var propDict = {
  47981. Row: ['left', 'right'],
  47982. Col: ['top', 'bottom']
  47983. };
  47984. var offset = {
  47985. outer: 20,
  47986. radius: 7
  47987. };
  47988. _this.setStyle(node, propDict[dir][index], "-".concat(offset.outer, "px"));
  47989. _this.setStyle(node, 'display', '');
  47990. var refreshMap = {
  47991. LastRow: function LastRow() {
  47992. return _this.setStyle(node, 'top', "".concat(trInfo.top - tableInfo.top - offset.radius, "px"));
  47993. },
  47994. NextRow: function NextRow() {
  47995. return _this.setStyle(node, 'top', "".concat(trInfo.top - tableInfo.top + trInfo.height - offset.radius, "px"));
  47996. },
  47997. LastCol: function LastCol() {
  47998. return _this.setStyle(node, 'left', "".concat(tdInfo.left - tableInfo.left - offset.radius, "px"));
  47999. },
  48000. NextCol: function NextCol() {
  48001. return _this.setStyle(node, 'left', "".concat(tdInfo.left - tableInfo.left + tdInfo.width - offset.radius, "px"));
  48002. }
  48003. };
  48004. var oper = concat$5(_context3 = "".concat(type)).call(_context3, dir);
  48005. refreshMap[oper]();
  48006. _this.setStyle(node, 'display', isWithinBounds(node) ? '' : 'none');
  48007. if (isTHead && oper === 'LastRow') {
  48008. _this.setStyle(node, 'display', 'none');
  48009. }
  48010. });
  48011. }
  48012. /**
  48013. * 刷新定位
  48014. */
  48015. }, {
  48016. key: "$refreshPosition",
  48017. value: function $refreshPosition() {
  48018. if (this.trigger === 'click') {
  48019. this.$setInputOffset();
  48020. return;
  48021. }
  48022. this.$setSymbolOffset();
  48023. }
  48024. }, {
  48025. key: "$remove",
  48026. value: function $remove() {
  48027. this.tableEditor = {
  48028. info: {},
  48029. tableCodes: [],
  48030. editorDom: {}
  48031. };
  48032. }
  48033. /**
  48034. * 收集编辑器中的表格语法,并记录表格语法的开始的offset
  48035. */
  48036. }, {
  48037. key: "$collectTableCode",
  48038. value: function $collectTableCode() {
  48039. var tableCodes = [];
  48040. this.codeMirror.getValue().replace(this.codeBlockReg, function (whole) {
  48041. // 先把代码块里的表格语法关键字干掉
  48042. return whole.replace(/\|/g, '.');
  48043. }).replace(this.tableReg, function (whole) {
  48044. var _ref3;
  48045. var match = whole.replace(/^\n*/, '');
  48046. var offsetBegin = (_ref3 = (arguments.length <= 1 ? 0 : arguments.length - 1) - 2 + 1, _ref3 < 1 || arguments.length <= _ref3 ? undefined : arguments[_ref3]) + whole.match(/^\n*/)[0].length;
  48047. tableCodes.push({
  48048. code: match,
  48049. offset: offsetBegin
  48050. });
  48051. });
  48052. this.tableEditor.tableCodes = tableCodes;
  48053. }
  48054. /**
  48055. * 获取预览区域被点击的table对象,并记录table的顺位
  48056. */
  48057. }, {
  48058. key: "$collectTableDom",
  48059. value: function $collectTableDom() {
  48060. var _context4, _context5, _context6;
  48061. var list = from_1$2(this.previewerDom.querySelectorAll('table.cherry-table'));
  48062. var tableNode = this.$getClosestNode(this.target, 'TABLE');
  48063. if (tableNode === false) {
  48064. return false;
  48065. }
  48066. var columns = filter$3(_context4 = from_1$2(this.target.parentElement.childNodes)).call(_context4, function (child) {
  48067. // 计算列数
  48068. return child.tagName.toLowerCase() === 'td';
  48069. }).length;
  48070. this.tableEditor.info = {
  48071. tableNode: tableNode,
  48072. tdNode: this.target,
  48073. trNode: this.target.parentElement,
  48074. tdIndex: indexOf$8(_context5 = from_1$2(this.target.parentElement.childNodes)).call(_context5, this.target),
  48075. trIndex: indexOf$8(_context6 = from_1$2(this.target.parentElement.parentElement.childNodes)).call(_context6, this.target.parentElement),
  48076. isTHead: this.target.parentElement.parentElement.tagName !== 'TBODY',
  48077. totalTables: list.length,
  48078. tableIndex: indexOf$8(list).call(list, tableNode),
  48079. tableText: tableNode.textContent.replace(/[\s]/g, ''),
  48080. columns: columns
  48081. };
  48082. }
  48083. /**
  48084. * 选中对应单元格、所在行、所在列的内容
  48085. * @param {Number} index
  48086. * @param {String} type 'td': 当前单元格, 'table': 当前表格
  48087. * @param {Boolean} select 是否选中编辑器中的代码
  48088. */
  48089. }, {
  48090. key: "$setSelection",
  48091. value: function $setSelection(index) {
  48092. var _whole$slice$match$le, _whole$slice$match, _this$codeMirror;
  48093. var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'table';
  48094. var select = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  48095. var tableCode = this.tableEditor.tableCodes[index];
  48096. var whole = this.codeMirror.getValue();
  48097. var selectTdInfo = this.tableEditor.info;
  48098. var beginLine = (_whole$slice$match$le = (_whole$slice$match = slice$7(whole).call(whole, 0, tableCode.offset).match(/\n/g)) === null || _whole$slice$match === void 0 ? void 0 : _whole$slice$match.length) !== null && _whole$slice$match$le !== void 0 ? _whole$slice$match$le : 0;
  48099. var _this$$getTdOffset = this.$getTdOffset(tableCode.code, selectTdInfo.isTHead, selectTdInfo.trIndex, selectTdInfo.tdIndex),
  48100. preLine = _this$$getTdOffset.preLine,
  48101. preCh = _this$$getTdOffset.preCh,
  48102. plusCh = _this$$getTdOffset.plusCh,
  48103. currentTd = _this$$getTdOffset.currentTd;
  48104. if (type === 'table') {
  48105. var endLine = beginLine + tableCode.code.match(/\n/g).length;
  48106. var endCh = tableCode.code.match(/[^\n]+\n*$/)[0].length;
  48107. this.tableEditor.info.selection = [{
  48108. line: beginLine,
  48109. ch: 0
  48110. }, {
  48111. line: endLine,
  48112. ch: endCh
  48113. }];
  48114. } else {
  48115. this.tableEditor.info.selection = [{
  48116. line: beginLine + preLine,
  48117. ch: preCh
  48118. }, {
  48119. line: beginLine + preLine,
  48120. ch: preCh + plusCh
  48121. }];
  48122. }
  48123. select && (_this$codeMirror = this.codeMirror).setSelection.apply(_this$codeMirror, _toConsumableArray(this.tableEditor.info.selection));
  48124. this.tableEditor.info.code = currentTd;
  48125. }
  48126. /**
  48127. * 获取对应单元格的偏移量
  48128. * @param {String} tableCode
  48129. * @param {Boolean} isTHead
  48130. * @param {Number} trIndex
  48131. * @param {Number} tdIndex
  48132. */
  48133. }, {
  48134. key: "$getTdOffset",
  48135. value: function $getTdOffset(tableCode, isTHead, trIndex, tdIndex) {
  48136. var codes = tableCode.split(/\n/);
  48137. var targetTr = isTHead ? 0 : trIndex + 2;
  48138. var tds = codes[targetTr].split(/\|/);
  48139. var needPlus1 = /^\s*$/.test(tds[0]);
  48140. var targetTd = needPlus1 ? tdIndex + 1 : tdIndex;
  48141. var current = tds[targetTd];
  48142. var pre = [];
  48143. for (var i = 0; i < targetTd; i++) {
  48144. pre.push(tds[i]);
  48145. }
  48146. return {
  48147. preLine: targetTr,
  48148. preCh: needPlus1 ? pre.join('|').length + 1 : pre.join('|').length,
  48149. plusCh: current.length,
  48150. currentTd: current
  48151. };
  48152. }
  48153. /**
  48154. * 在编辑器里找到对应的表格源码,并让编辑器选中
  48155. */
  48156. }, {
  48157. key: "$findTableInEditor",
  48158. value: function $findTableInEditor() {
  48159. this.$collectTableDom();
  48160. this.$collectTableCode(); // 暂时不考虑代码块中包含表格、人为输入表格html语法、tapd特色表格语法的情况
  48161. // 也就是说,出现上述情况时,表格的所见即所得编辑功能失效
  48162. if (this.tableEditor.info.totalTables !== this.tableEditor.tableCodes.length) {
  48163. return false;
  48164. }
  48165. this.$setSelection(this.tableEditor.info.tableIndex, 'td', this.trigger === 'click');
  48166. }
  48167. }, {
  48168. key: "$initReg",
  48169. value: function $initReg() {
  48170. this.tableReg = this.tableReg ? this.tableReg : getTableRule(true);
  48171. this.codeBlockReg = this.codeBlockReg ? this.codeBlockReg : getCodeBlockRule().reg;
  48172. }
  48173. }, {
  48174. key: "showBubble",
  48175. value: function showBubble() {
  48176. if (this.trigger === 'click') {
  48177. this.$drawEditor();
  48178. return;
  48179. }
  48180. this.$drawSymbol();
  48181. }
  48182. /**
  48183. * 判断是否处于编辑状态
  48184. * @returns {boolean}
  48185. */
  48186. }, {
  48187. key: "$isEditing",
  48188. value: function $isEditing() {
  48189. return this.tableEditor.editing;
  48190. }
  48191. /**
  48192. * 把表格上的input单行文本框和操作符号画出来
  48193. */
  48194. }, {
  48195. key: "$drawEditor",
  48196. value: function $drawEditor() {
  48197. var dom = document.createElement('div');
  48198. dom.className = 'cherry-previewer-table-content-hander__input';
  48199. var input = document.createElement('textarea');
  48200. dom.appendChild(input);
  48201. this.tableEditor.editorDom.inputDiv = dom;
  48202. this.tableEditor.editorDom.inputDom = input;
  48203. this.$updateEditorPosition();
  48204. this.container.appendChild(this.tableEditor.editorDom.inputDiv);
  48205. this.tableEditor.editorDom.inputDom.value = this.tableEditor.info.code.replace(/<br>/g, '\n');
  48206. this.tableEditor.editorDom.inputDom.focus();
  48207. }
  48208. }, {
  48209. key: "$onInputChange",
  48210. value: function $onInputChange(e) {
  48211. if (e.target.tagName !== 'TEXTAREA') {
  48212. return;
  48213. }
  48214. this.codeMirror.replaceSelection(e.target.value.replace(/\n/g, '<br>'), 'around');
  48215. }
  48216. /**
  48217. * 更新编辑器的位置(尺寸和位置)
  48218. */
  48219. }, {
  48220. key: "$updateEditorPosition",
  48221. value: function $updateEditorPosition() {
  48222. this.$setInputOffset();
  48223. var tdStyle = getComputedStyle(this.tableEditor.info.tdNode);
  48224. this.tableEditor.editorDom.inputDom.style.textAlign = tdStyle.textAlign || 'left';
  48225. this.tableEditor.editorDom.inputDom.style.fontSize = tdStyle.fontSize || '16px';
  48226. this.tableEditor.editorDom.inputDom.style.fontFamily = tdStyle.fontFamily;
  48227. this.tableEditor.editorDom.inputDom.style.lineHeight = tdStyle.lineHeight;
  48228. this.tableEditor.editorDom.inputDom.style.padding = tdStyle.padding; // 左对齐的时候,paddingRight设置成0,反之paddingLeft设置成0
  48229. if (/left/.test(tdStyle.textAlign)) {
  48230. this.tableEditor.editorDom.inputDom.style.paddingRight = '0px';
  48231. }
  48232. if (/right/.test(tdStyle.textAlign)) {
  48233. this.tableEditor.editorDom.inputDom.style.paddingLeft = '0px';
  48234. }
  48235. if (/center/.test(tdStyle.textAlign)) {
  48236. this.tableEditor.editorDom.inputDom.style.paddingLeft = '0px';
  48237. this.tableEditor.editorDom.inputDom.style.paddingRight = '0px';
  48238. }
  48239. this.tableEditor.editorDom.inputDom.style.paddingBottom = '0px';
  48240. }
  48241. }, {
  48242. key: "$getClosestNode",
  48243. value: function $getClosestNode(node, targetNodeName) {
  48244. if (node.tagName === targetNodeName) {
  48245. return node;
  48246. }
  48247. if (node.parentNode.tagName === 'BODY') {
  48248. return false;
  48249. }
  48250. return this.$getClosestNode(node.parentNode, targetNodeName);
  48251. }
  48252. /**
  48253. * 绘制操作符号
  48254. */
  48255. }, {
  48256. key: "$drawSymbol",
  48257. value: function $drawSymbol() {
  48258. var _context7,
  48259. _this2 = this;
  48260. var types = ['Last', 'Next'];
  48261. var dirs = ['Row', 'Col'];
  48262. var textDict = {
  48263. Row: '行',
  48264. Col: '列'
  48265. };
  48266. var symbols = flat$3(_context7 = map$3(dirs).call(dirs, function (_, index) {
  48267. return map$3(types).call(types, function (type) {
  48268. return map$3(dirs).call(dirs, function (dir) {
  48269. return ["".concat(index), type, dir];
  48270. });
  48271. });
  48272. })).call(_context7, 2);
  48273. var container = document.createElement('ul');
  48274. container.className = 'cherry-previewer-table-hover-handler-container';
  48275. forEach$3(symbols).call(symbols, function (_ref4) {
  48276. var _ref5 = _slicedToArray(_ref4, 3),
  48277. index = _ref5[0],
  48278. type = _ref5[1],
  48279. dir = _ref5[2];
  48280. var li = document.createElement('li');
  48281. li.setAttribute('data-index', index);
  48282. li.setAttribute('data-type', type);
  48283. li.setAttribute('data-dir', dir);
  48284. li.className = 'cherry-previewer-table-hover-handler__symbol';
  48285. li.title = "\u6DFB\u52A0".concat(textDict[dir]);
  48286. li.innerHTML = '+';
  48287. li.addEventListener('click', function (e) {
  48288. var _context8;
  48289. var target = e.target;
  48290. if (!(target instanceof HTMLElement)) {
  48291. return;
  48292. }
  48293. var _target$dataset = target.dataset,
  48294. type = _target$dataset.type,
  48295. dir = _target$dataset.dir;
  48296. _this2[concat$5(_context8 = "$add".concat(type)).call(_context8, dir)]();
  48297. });
  48298. container.appendChild(li);
  48299. }, true);
  48300. this.tableEditor.editorDom.symbolContainer = container;
  48301. this.container.appendChild(this.tableEditor.editorDom.symbolContainer);
  48302. this.$setSymbolOffset();
  48303. }
  48304. /**
  48305. * 添加上一行
  48306. */
  48307. }, {
  48308. key: "$addLastRow",
  48309. value: function $addLastRow() {
  48310. var _context9;
  48311. var _this$tableEditor$inf2 = _slicedToArray(this.tableEditor.info.selection, 1),
  48312. line = _this$tableEditor$inf2[0].line;
  48313. var newRow = "".concat(repeat$3(_context9 = '|').call(_context9, this.tableEditor.info.columns), "\n");
  48314. this.codeMirror.replaceRange(newRow, {
  48315. line: line,
  48316. ch: 0
  48317. });
  48318. this.$findTableInEditor();
  48319. this.$setSelection(this.tableEditor.info.tableIndex, 'td');
  48320. }
  48321. /**
  48322. * 添加下一行
  48323. */
  48324. }, {
  48325. key: "$addNextRow",
  48326. value: function $addNextRow() {
  48327. var _context10;
  48328. var _this$tableEditor$inf3 = _slicedToArray(this.tableEditor.info.selection, 2),
  48329. line = _this$tableEditor$inf3[1].line;
  48330. var newRow = "".concat(repeat$3(_context10 = '|').call(_context10, this.tableEditor.info.columns), "\n");
  48331. this.codeMirror.replaceRange(newRow, {
  48332. line: line + 1,
  48333. ch: 0
  48334. });
  48335. this.$findTableInEditor();
  48336. this.$setSelection(this.tableEditor.info.tableIndex, 'td');
  48337. }
  48338. /**
  48339. * 添加上一列
  48340. */
  48341. }, {
  48342. key: "$addLastCol",
  48343. value: function $addLastCol() {
  48344. var _this3 = this;
  48345. this.$setSelection(this.tableEditor.info.tableIndex, 'table');
  48346. var selection = this.codeMirror.getSelection();
  48347. var lines = selection.split('\n');
  48348. var newLines = map$3(lines).call(lines, function (line, index) {
  48349. var cells = line.split('|');
  48350. var replaceItem = 1 === index ? ':-:' : '';
  48351. splice$4(cells).call(cells, _this3.tableEditor.info.tdIndex + 1, 0, replaceItem);
  48352. return cells.join('|');
  48353. });
  48354. var newText = newLines.join('\n');
  48355. this.codeMirror.replaceSelection(newText);
  48356. this.$findTableInEditor();
  48357. this.$setSelection(this.tableEditor.info.tableIndex, 'table');
  48358. }
  48359. /**
  48360. * 添加下一列
  48361. */
  48362. }, {
  48363. key: "$addNextCol",
  48364. value: function $addNextCol() {
  48365. var _this4 = this;
  48366. this.$setSelection(this.tableEditor.info.tableIndex, 'table');
  48367. var selection = this.codeMirror.getSelection();
  48368. var lines = selection.split('\n');
  48369. var newLines = map$3(lines).call(lines, function (line, index) {
  48370. var cells = line.split('|');
  48371. var replaceItem = 1 === index ? ':-:' : '';
  48372. splice$4(cells).call(cells, _this4.tableEditor.info.tdIndex + 2, 0, replaceItem);
  48373. return cells.join('|');
  48374. });
  48375. var newText = newLines.join('\n');
  48376. this.codeMirror.replaceSelection(newText);
  48377. this.$findTableInEditor();
  48378. this.$setSelection(this.tableEditor.info.tableIndex, 'table');
  48379. }
  48380. }]);
  48381. return TableHandler;
  48382. }();
  48383. /**
  48384. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  48385. *
  48386. * Licensed under the Apache License, Version 2.0 (the "License");
  48387. * you may not use this file except in compliance with the License.
  48388. * You may obtain a copy of the License at
  48389. *
  48390. * http://www.apache.org/licenses/LICENSE-2.0
  48391. *
  48392. * Unless required by applicable law or agreed to in writing, software
  48393. * distributed under the License is distributed on an "AS IS" BASIS,
  48394. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  48395. * See the License for the specific language governing permissions and
  48396. * limitations under the License.
  48397. */
  48398. /**
  48399. * 对话框基操集合
  48400. */
  48401. var dialog = {
  48402. open: function open() {
  48403. this.dom.style.display = 'block';
  48404. this.postMessage('ready?');
  48405. },
  48406. close: function close() {
  48407. this.dom.style.display = 'none';
  48408. },
  48409. postMessage: function postMessage(messageName) {
  48410. var _this$iframeDom, _this$iframeDom$conte;
  48411. var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  48412. (_this$iframeDom = this.iframeDom) === null || _this$iframeDom === void 0 ? void 0 : (_this$iframeDom$conte = _this$iframeDom.contentWindow) === null || _this$iframeDom$conte === void 0 ? void 0 : _this$iframeDom$conte.postMessage({
  48413. eventName: messageName,
  48414. value: value
  48415. }, '*');
  48416. },
  48417. draw: function draw(params, onReady, onSubmit) {
  48418. var _this = this;
  48419. var iframeSrc = params.iframeSrc,
  48420. title = params.title;
  48421. this.onSubmit = onSubmit;
  48422. this.onReady = onReady;
  48423. if (this.dom) {
  48424. var test = new RegExp("".concat(iframeSrc, "$"), 'i');
  48425. if (!test.test(this.iframeDom.src)) {
  48426. this.iframeDom.src = iframeSrc;
  48427. }
  48428. this.open();
  48429. return;
  48430. } // 添加通信事件
  48431. window.addEventListener('message', function (event) {
  48432. // @ts-ignore
  48433. if (!event.data || !event.data.eventName) {
  48434. return;
  48435. } // @ts-ignore
  48436. switch (event.data.eventName) {
  48437. case 'getData:success':
  48438. // @ts-ignore
  48439. _this.onSubmit(event.data.value);
  48440. _this.close();
  48441. case 'ready':
  48442. _this.onReady();
  48443. }
  48444. }); // 构造页面元素
  48445. this.iframeDom = createElement('iframe', 'cherry-dialog-iframe', {
  48446. src: iframeSrc,
  48447. style: 'border: none;'
  48448. });
  48449. this.dom = createElement('div', 'cherry-dialog', {
  48450. style: ['z-index:9999', 'display: block', 'position: absolute', 'top: 10%;left: 10%;bottom: 10%;right: 10%', 'background-color: #FFF', 'box-shadow: 0px 50px 100px -12px rgba(0,0,0,.05),0px 30px 60px -30px rgba(0,0,0,.1)', 'border-radius: 6px', 'border: 1px solid #ddd;'].join(';')
  48451. });
  48452. this.head = createElement('div', 'cherry-dialog--head', {
  48453. style: ['height: 30px', 'line-height: 30px', 'padding-left: 10px', 'padding-right: 10px'].join(';')
  48454. });
  48455. this.body = createElement('div', 'cherry-dialog--body', {
  48456. style: ['position: absolute', 'bottom: 30px', 'top: 30px', 'left: 0', 'right: 0', 'overflow: hidden'].join(';')
  48457. });
  48458. this.foot = createElement('div', 'cherry-dialog--foot', {
  48459. style: ['height: 30px', 'line-height: 18px', 'padding-left: 10px', 'padding-right: 10px', 'position: absolute', 'bottom: 0', 'left: 0', 'right: 0'].join(';')
  48460. });
  48461. this.headTitle = createElement('span', 'cherry-dialog--title', {
  48462. style: 'user-select:none;'
  48463. });
  48464. this.headCloseButton = createElement('i', 'cherry-dialog--close ch-icon ch-icon-close', {
  48465. style: 'float: right;font-size: 12px;cursor: pointer;'
  48466. });
  48467. this.footSureButton = createElement('button', 'cherry-dialog--sure', {
  48468. style: ['float: right', 'cursor: pointer', 'margin: 3px', 'background-color: #4d90fe', 'color: #FFF', 'border: 1px solid #4d90fe', 'border-radius: 2px', 'padding: 2px 15px', 'user-select:none'].join(';')
  48469. });
  48470. this.headCloseButton.title = '关闭';
  48471. this.footSureButton.textContent = '确定';
  48472. this.headTitle.textContent = title;
  48473. this.head.appendChild(this.headTitle);
  48474. this.head.appendChild(this.headCloseButton);
  48475. this.foot.appendChild(this.footSureButton);
  48476. this.body.appendChild(this.iframeDom);
  48477. this.dom.appendChild(this.head);
  48478. this.dom.appendChild(this.body);
  48479. this.dom.appendChild(this.foot);
  48480. this.headCloseButton.addEventListener('click', function () {
  48481. _this.close();
  48482. });
  48483. this.footSureButton.addEventListener('click', function () {
  48484. _this.postMessage('getData');
  48485. });
  48486. document.body.appendChild(this.dom);
  48487. }
  48488. };
  48489. /**
  48490. * draw.io的对话框
  48491. * @param {string} xml draw.io的xml格式的字符串数据
  48492. * @param {*} callback 回调
  48493. */
  48494. function drawioDialog() {
  48495. var iframeSrc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  48496. var xml = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  48497. var callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  48498. var dialogParam = {
  48499. iframeSrc: iframeSrc,
  48500. title: 'draw.io'
  48501. };
  48502. dialog.draw(dialogParam, function () {
  48503. dialog.postMessage('setData', xml);
  48504. }, function (data) {
  48505. callback(data);
  48506. });
  48507. }
  48508. /**
  48509. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  48510. *
  48511. * Licensed under the Apache License, Version 2.0 (the "License");
  48512. * you may not use this file except in compliance with the License.
  48513. * You may obtain a copy of the License at
  48514. *
  48515. * http://www.apache.org/licenses/LICENSE-2.0
  48516. *
  48517. * Unless required by applicable law or agreed to in writing, software
  48518. * distributed under the License is distributed on an "AS IS" BASIS,
  48519. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  48520. * See the License for the specific language governing permissions and
  48521. * limitations under the License.
  48522. */
  48523. /**
  48524. * 复制内容到剪贴板
  48525. * @returns null
  48526. */
  48527. function copyToClip(str) {
  48528. function listener(e) {
  48529. e.clipboardData.setData('text/html', str);
  48530. e.clipboardData.setData('text/plain', str);
  48531. e.preventDefault();
  48532. }
  48533. document.addEventListener('copy', listener);
  48534. document.execCommand('copy');
  48535. document.removeEventListener('copy', listener);
  48536. }
  48537. /**
  48538. * Gets the timestamp of the number of milliseconds that have elapsed since
  48539. * the Unix epoch (1 January 1970 00:00:00 UTC).
  48540. *
  48541. * @static
  48542. * @memberOf _
  48543. * @since 2.4.0
  48544. * @category Date
  48545. * @returns {number} Returns the timestamp.
  48546. * @example
  48547. *
  48548. * _.defer(function(stamp) {
  48549. * console.log(_.now() - stamp);
  48550. * }, _.now());
  48551. * // => Logs the number of milliseconds it took for the deferred invocation.
  48552. */
  48553. var now = function() {
  48554. return _root.Date.now();
  48555. };
  48556. var now_1 = now;
  48557. /** Used to match a single whitespace character. */
  48558. var reWhitespace = /\s/;
  48559. /**
  48560. * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
  48561. * character of `string`.
  48562. *
  48563. * @private
  48564. * @param {string} string The string to inspect.
  48565. * @returns {number} Returns the index of the last non-whitespace character.
  48566. */
  48567. function trimmedEndIndex(string) {
  48568. var index = string.length;
  48569. while (index-- && reWhitespace.test(string.charAt(index))) {}
  48570. return index;
  48571. }
  48572. var _trimmedEndIndex = trimmedEndIndex;
  48573. /** Used to match leading whitespace. */
  48574. var reTrimStart = /^\s+/;
  48575. /**
  48576. * The base implementation of `_.trim`.
  48577. *
  48578. * @private
  48579. * @param {string} string The string to trim.
  48580. * @returns {string} Returns the trimmed string.
  48581. */
  48582. function baseTrim(string) {
  48583. return string
  48584. ? string.slice(0, _trimmedEndIndex(string) + 1).replace(reTrimStart, '')
  48585. : string;
  48586. }
  48587. var _baseTrim = baseTrim;
  48588. /** Used as references for various `Number` constants. */
  48589. var NAN = 0 / 0;
  48590. /** Used to detect bad signed hexadecimal string values. */
  48591. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  48592. /** Used to detect binary string values. */
  48593. var reIsBinary = /^0b[01]+$/i;
  48594. /** Used to detect octal string values. */
  48595. var reIsOctal = /^0o[0-7]+$/i;
  48596. /** Built-in method references without a dependency on `root`. */
  48597. var freeParseInt = parseInt;
  48598. /**
  48599. * Converts `value` to a number.
  48600. *
  48601. * @static
  48602. * @memberOf _
  48603. * @since 4.0.0
  48604. * @category Lang
  48605. * @param {*} value The value to process.
  48606. * @returns {number} Returns the number.
  48607. * @example
  48608. *
  48609. * _.toNumber(3.2);
  48610. * // => 3.2
  48611. *
  48612. * _.toNumber(Number.MIN_VALUE);
  48613. * // => 5e-324
  48614. *
  48615. * _.toNumber(Infinity);
  48616. * // => Infinity
  48617. *
  48618. * _.toNumber('3.2');
  48619. * // => 3.2
  48620. */
  48621. function toNumber(value) {
  48622. if (typeof value == 'number') {
  48623. return value;
  48624. }
  48625. if (isSymbol_1(value)) {
  48626. return NAN;
  48627. }
  48628. if (isObject_1(value)) {
  48629. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  48630. value = isObject_1(other) ? (other + '') : other;
  48631. }
  48632. if (typeof value != 'string') {
  48633. return value === 0 ? value : +value;
  48634. }
  48635. value = _baseTrim(value);
  48636. var isBinary = reIsBinary.test(value);
  48637. return (isBinary || reIsOctal.test(value))
  48638. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  48639. : (reIsBadHex.test(value) ? NAN : +value);
  48640. }
  48641. var toNumber_1 = toNumber;
  48642. /** Error message constants. */
  48643. var FUNC_ERROR_TEXT = 'Expected a function';
  48644. /* Built-in method references for those with the same name as other `lodash` methods. */
  48645. var nativeMax$1 = Math.max,
  48646. nativeMin = Math.min;
  48647. /**
  48648. * Creates a debounced function that delays invoking `func` until after `wait`
  48649. * milliseconds have elapsed since the last time the debounced function was
  48650. * invoked. The debounced function comes with a `cancel` method to cancel
  48651. * delayed `func` invocations and a `flush` method to immediately invoke them.
  48652. * Provide `options` to indicate whether `func` should be invoked on the
  48653. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  48654. * with the last arguments provided to the debounced function. Subsequent
  48655. * calls to the debounced function return the result of the last `func`
  48656. * invocation.
  48657. *
  48658. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  48659. * invoked on the trailing edge of the timeout only if the debounced function
  48660. * is invoked more than once during the `wait` timeout.
  48661. *
  48662. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  48663. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  48664. *
  48665. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  48666. * for details over the differences between `_.debounce` and `_.throttle`.
  48667. *
  48668. * @static
  48669. * @memberOf _
  48670. * @since 0.1.0
  48671. * @category Function
  48672. * @param {Function} func The function to debounce.
  48673. * @param {number} [wait=0] The number of milliseconds to delay.
  48674. * @param {Object} [options={}] The options object.
  48675. * @param {boolean} [options.leading=false]
  48676. * Specify invoking on the leading edge of the timeout.
  48677. * @param {number} [options.maxWait]
  48678. * The maximum time `func` is allowed to be delayed before it's invoked.
  48679. * @param {boolean} [options.trailing=true]
  48680. * Specify invoking on the trailing edge of the timeout.
  48681. * @returns {Function} Returns the new debounced function.
  48682. * @example
  48683. *
  48684. * // Avoid costly calculations while the window size is in flux.
  48685. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  48686. *
  48687. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  48688. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  48689. * 'leading': true,
  48690. * 'trailing': false
  48691. * }));
  48692. *
  48693. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  48694. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  48695. * var source = new EventSource('/stream');
  48696. * jQuery(source).on('message', debounced);
  48697. *
  48698. * // Cancel the trailing debounced invocation.
  48699. * jQuery(window).on('popstate', debounced.cancel);
  48700. */
  48701. function debounce(func, wait, options) {
  48702. var lastArgs,
  48703. lastThis,
  48704. maxWait,
  48705. result,
  48706. timerId,
  48707. lastCallTime,
  48708. lastInvokeTime = 0,
  48709. leading = false,
  48710. maxing = false,
  48711. trailing = true;
  48712. if (typeof func != 'function') {
  48713. throw new TypeError(FUNC_ERROR_TEXT);
  48714. }
  48715. wait = toNumber_1(wait) || 0;
  48716. if (isObject_1(options)) {
  48717. leading = !!options.leading;
  48718. maxing = 'maxWait' in options;
  48719. maxWait = maxing ? nativeMax$1(toNumber_1(options.maxWait) || 0, wait) : maxWait;
  48720. trailing = 'trailing' in options ? !!options.trailing : trailing;
  48721. }
  48722. function invokeFunc(time) {
  48723. var args = lastArgs,
  48724. thisArg = lastThis;
  48725. lastArgs = lastThis = undefined;
  48726. lastInvokeTime = time;
  48727. result = func.apply(thisArg, args);
  48728. return result;
  48729. }
  48730. function leadingEdge(time) {
  48731. // Reset any `maxWait` timer.
  48732. lastInvokeTime = time;
  48733. // Start the timer for the trailing edge.
  48734. timerId = setTimeout(timerExpired, wait);
  48735. // Invoke the leading edge.
  48736. return leading ? invokeFunc(time) : result;
  48737. }
  48738. function remainingWait(time) {
  48739. var timeSinceLastCall = time - lastCallTime,
  48740. timeSinceLastInvoke = time - lastInvokeTime,
  48741. timeWaiting = wait - timeSinceLastCall;
  48742. return maxing
  48743. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  48744. : timeWaiting;
  48745. }
  48746. function shouldInvoke(time) {
  48747. var timeSinceLastCall = time - lastCallTime,
  48748. timeSinceLastInvoke = time - lastInvokeTime;
  48749. // Either this is the first call, activity has stopped and we're at the
  48750. // trailing edge, the system time has gone backwards and we're treating
  48751. // it as the trailing edge, or we've hit the `maxWait` limit.
  48752. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  48753. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  48754. }
  48755. function timerExpired() {
  48756. var time = now_1();
  48757. if (shouldInvoke(time)) {
  48758. return trailingEdge(time);
  48759. }
  48760. // Restart the timer.
  48761. timerId = setTimeout(timerExpired, remainingWait(time));
  48762. }
  48763. function trailingEdge(time) {
  48764. timerId = undefined;
  48765. // Only invoke if we have `lastArgs` which means `func` has been
  48766. // debounced at least once.
  48767. if (trailing && lastArgs) {
  48768. return invokeFunc(time);
  48769. }
  48770. lastArgs = lastThis = undefined;
  48771. return result;
  48772. }
  48773. function cancel() {
  48774. if (timerId !== undefined) {
  48775. clearTimeout(timerId);
  48776. }
  48777. lastInvokeTime = 0;
  48778. lastArgs = lastCallTime = lastThis = timerId = undefined;
  48779. }
  48780. function flush() {
  48781. return timerId === undefined ? result : trailingEdge(now_1());
  48782. }
  48783. function debounced() {
  48784. var time = now_1(),
  48785. isInvoking = shouldInvoke(time);
  48786. lastArgs = arguments;
  48787. lastThis = this;
  48788. lastCallTime = time;
  48789. if (isInvoking) {
  48790. if (timerId === undefined) {
  48791. return leadingEdge(lastCallTime);
  48792. }
  48793. if (maxing) {
  48794. // Handle invocations in a tight loop.
  48795. clearTimeout(timerId);
  48796. timerId = setTimeout(timerExpired, wait);
  48797. return invokeFunc(lastCallTime);
  48798. }
  48799. }
  48800. if (timerId === undefined) {
  48801. timerId = setTimeout(timerExpired, wait);
  48802. }
  48803. return result;
  48804. }
  48805. debounced.cancel = cancel;
  48806. debounced.flush = flush;
  48807. return debounced;
  48808. }
  48809. var debounce_1 = debounce;
  48810. /**
  48811. * 预览区域的响应式工具栏
  48812. */
  48813. var PreviewerBubble = /*#__PURE__*/function () {
  48814. /**
  48815. *
  48816. * @param {import('../Previewer').default} previewer
  48817. */
  48818. function PreviewerBubble(previewer) {
  48819. _classCallCheck(this, PreviewerBubble);
  48820. /**
  48821. * @property
  48822. * @type {import('../Previewer').default}
  48823. */
  48824. this.previewer = previewer;
  48825. /**
  48826. * @property
  48827. * @type {import('../Editor').default}
  48828. */
  48829. this.editor = previewer.editor;
  48830. this.previewerDom = this.previewer.getDom();
  48831. this.enablePreviewerBubble = this.previewer.options.enablePreviewerBubble;
  48832. /**
  48833. * @property
  48834. * @type {{ [key: string]: HTMLDivElement}}
  48835. */
  48836. this.bubble = {};
  48837. /**
  48838. * @property
  48839. * @type {{ [key: string]: { emit: (...args: any[]) => any, [key:string]: any }}}
  48840. */
  48841. this.bubbleHandler = {};
  48842. this.init();
  48843. }
  48844. _createClass(PreviewerBubble, [{
  48845. key: "init",
  48846. value: function init() {
  48847. var _context,
  48848. _context2,
  48849. _context3,
  48850. _this = this,
  48851. _context10;
  48852. this.previewerDom.addEventListener('click', bind$5(_context = this.$onClick).call(_context, this));
  48853. this.previewerDom.addEventListener('mouseover', bind$5(_context2 = this.$onMouseOver).call(_context2, this));
  48854. this.previewerDom.addEventListener('mouseout', bind$5(_context3 = this.$onMouseOut).call(_context3, this));
  48855. document.addEventListener('mousedown', function (event) {
  48856. var _context4;
  48857. forEach$3(_context4 = values$3(_this.bubbleHandler)).call(_context4, function (handler) {
  48858. return handler.emit('mousedown', event);
  48859. });
  48860. });
  48861. document.addEventListener('mouseup', function (event) {
  48862. var _context5;
  48863. forEach$3(_context5 = values$3(_this.bubbleHandler)).call(_context5, function (handler) {
  48864. return handler.emit('mouseup', event, function () {
  48865. return _this.$removeAllPreviewerBubbles('click');
  48866. });
  48867. });
  48868. });
  48869. document.addEventListener('mousemove', function (event) {
  48870. var _context6;
  48871. forEach$3(_context6 = values$3(_this.bubbleHandler)).call(_context6, function (handler) {
  48872. return handler.emit('mousemove', event);
  48873. });
  48874. });
  48875. document.addEventListener('keyup', function (event) {
  48876. var _context7;
  48877. forEach$3(_context7 = values$3(_this.bubbleHandler)).call(_context7, function (handler) {
  48878. return handler.emit('keyup', event);
  48879. });
  48880. });
  48881. this.previewerDom.addEventListener('scroll', function (event) {
  48882. var _context8;
  48883. forEach$3(_context8 = values$3(_this.bubbleHandler)).call(_context8, function (handler) {
  48884. return handler.emit('scroll', event);
  48885. });
  48886. }, true);
  48887. Event$1.on(this.previewer.instanceId, Event$1.Events.previewerClose, function () {
  48888. return _this.$removeAllPreviewerBubbles();
  48889. });
  48890. this.previewer.options.afterUpdateCallBack.push(function () {
  48891. var _context9;
  48892. forEach$3(_context9 = values$3(_this.bubbleHandler)).call(_context9, function (handler) {
  48893. return handler.emit('previewUpdate', function () {
  48894. return _this.$removeAllPreviewerBubbles();
  48895. });
  48896. });
  48897. });
  48898. this.previewerDom.addEventListener('change', bind$5(_context10 = this.$onChange).call(_context10, this));
  48899. this.removeHoverBubble = debounce_1(function () {
  48900. return _this.$removeAllPreviewerBubbles('hover');
  48901. }, 400);
  48902. }
  48903. /**
  48904. * 是否为由cherry生成的表格,且不是简单表格
  48905. * @param {HTMLElement} element
  48906. * @returns {boolean}
  48907. */
  48908. }, {
  48909. key: "isCherryTable",
  48910. value: function isCherryTable(element) {
  48911. var container = this.$getClosestNode(element, 'DIV');
  48912. if (container === false) {
  48913. return false;
  48914. }
  48915. if (/simple-table/.test(container.className) || !/cherry-table-container/.test(container.className)) {
  48916. return false;
  48917. }
  48918. return true;
  48919. }
  48920. }, {
  48921. key: "$onMouseOver",
  48922. value: function $onMouseOver(e) {
  48923. if (!this.enablePreviewerBubble) {
  48924. return;
  48925. }
  48926. var cherryStatus = this.previewer.$cherry.getStatus(); // 左侧编辑器被隐藏时不再提供后续功能
  48927. if (cherryStatus.editor === 'hide') {
  48928. return;
  48929. }
  48930. var target = e.target;
  48931. if (typeof target.tagName === 'undefined') {
  48932. return;
  48933. }
  48934. switch (target.tagName) {
  48935. case 'TD':
  48936. case 'TH':
  48937. if (!this.isCherryTable(e.target)) {
  48938. return;
  48939. }
  48940. this.removeHoverBubble.cancel();
  48941. this.$removeAllPreviewerBubbles('hover');
  48942. this.$showTablePreviewerBubbles('hover', e.target);
  48943. return;
  48944. }
  48945. }
  48946. }, {
  48947. key: "$onMouseOut",
  48948. value: function $onMouseOut() {
  48949. if (!this.enablePreviewerBubble) {
  48950. return;
  48951. }
  48952. var cherryStatus = this.previewer.$cherry.getStatus(); // 左侧编辑器被隐藏时不再提供后续功能
  48953. if (cherryStatus.editor === 'hide') {
  48954. return;
  48955. }
  48956. this.removeHoverBubble();
  48957. }
  48958. }, {
  48959. key: "$dealCheckboxClick",
  48960. value: function $dealCheckboxClick(e) {
  48961. var _this2 = this;
  48962. var target = e.target; // 先计算是previewer中第几个checkbox
  48963. var list = from_1$2(this.previewerDom.querySelectorAll('.ch-icon-square, .ch-icon-check'));
  48964. this.checkboxIdx = indexOf$8(list).call(list, target); // 然后找到Editor中对应的`- []`或者`- [ ]`进行修改
  48965. var contents = this.getValueWithoutCode().split('\n');
  48966. var editorCheckboxCount = 0; // [ ]中的空格,或者[x]中的x的位置
  48967. var targetLine = -1;
  48968. var targetCh = -1;
  48969. forEach$3(contents).call(contents, function (lineContent, lineIdx) {
  48970. var tmp = trim$3(lineContent).call(lineContent); // 去掉句首的空格和制表符
  48971. if (startsWith$3(tmp).call(tmp, '- [ ]') || startsWith$3(tmp).call(tmp, '- [x]')) {
  48972. // 如果是个checkbox
  48973. if (editorCheckboxCount === _this2.checkboxIdx) {
  48974. targetLine = lineIdx;
  48975. targetCh = indexOf$8(lineContent).call(lineContent, '- [') + 3;
  48976. }
  48977. editorCheckboxCount += 1;
  48978. }
  48979. });
  48980. if (targetLine === -1) {
  48981. // 无法找到对应的checkbox
  48982. return;
  48983. }
  48984. this.editor.editor.setSelection({
  48985. line: targetLine,
  48986. ch: targetCh
  48987. }, {
  48988. line: targetLine,
  48989. ch: targetCh + 1
  48990. });
  48991. this.editor.editor.replaceSelection(this.editor.editor.getSelection() === ' ' ? 'x' : ' ', 'around');
  48992. }
  48993. }, {
  48994. key: "$onClick",
  48995. value: function $onClick(e) {
  48996. var _this3 = this;
  48997. var target = e.target; // 复制代码块操作不关心编辑器的状态
  48998. this.$dealCopyCodeBlock(e);
  48999. var cherryStatus = this.previewer.$cherry.getStatus(); // 纯预览模式下,支持点击放大图片功能(以回调的形式实现,需要业务侧实现图片放大功能)
  49000. if (cherryStatus.editor === 'hide') {
  49001. if (cherryStatus.previewer === 'show') {
  49002. this.previewer.$cherry.options.callback.onClickPreview && this.previewer.$cherry.options.callback.onClickPreview(e);
  49003. }
  49004. return;
  49005. } // 编辑draw.io不受enablePreviewerBubble配置的影响
  49006. if (target.tagName === 'IMG' && target.getAttribute('data-type') === 'drawio') {
  49007. if (!this.beginChangeDrawioImg(target)) {
  49008. return;
  49009. }
  49010. var xmlData = decodeURI(target.getAttribute('data-xml'));
  49011. drawioDialog(this.previewer.$cherry.options.drawioIframeUrl, xmlData, function (newData) {
  49012. var _context11;
  49013. var xmlData = newData.xmlData,
  49014. base64 = newData.base64;
  49015. _this3.editor.editor.replaceSelection(concat$5(_context11 = "(".concat(base64, "){data-type=drawio data-xml=")).call(_context11, encodeURI(xmlData), "}"), 'around');
  49016. });
  49017. return;
  49018. }
  49019. if (!this.enablePreviewerBubble) {
  49020. return;
  49021. } // 只有双栏编辑模式才出现下面的功能
  49022. // checkbox所见即所得编辑操作
  49023. if (target.className === 'ch-icon ch-icon-square' || target.className === 'ch-icon ch-icon-check') {
  49024. this.$dealCheckboxClick(e);
  49025. }
  49026. this.$removeAllPreviewerBubbles();
  49027. if (typeof target.tagName === 'undefined') {
  49028. return;
  49029. }
  49030. switch (target.tagName) {
  49031. case 'IMG':
  49032. this.$showImgPreviewerBubbles(target);
  49033. break;
  49034. case 'TD':
  49035. case 'TH':
  49036. if (!this.isCherryTable(e.target)) {
  49037. return;
  49038. }
  49039. this.$showTablePreviewerBubbles('click', e.target);
  49040. break;
  49041. }
  49042. }
  49043. }, {
  49044. key: "$onChange",
  49045. value: function $onChange(e) {
  49046. var target = e.target; // code预览区域,修改语言设置项事件处理
  49047. if (target.className === CODE_PREVIEWER_LANG_SELECT_CLASS_NAME) {
  49048. this.$codePreviewLangSelectEventHandler(e);
  49049. }
  49050. }
  49051. }, {
  49052. key: "$getClosestNode",
  49053. value: function $getClosestNode(node, targetNodeName) {
  49054. if (node.tagName === targetNodeName) {
  49055. return node;
  49056. }
  49057. if (node.parentNode.tagName === 'BODY') {
  49058. return false;
  49059. }
  49060. return this.$getClosestNode(node.parentNode, targetNodeName);
  49061. }
  49062. /**
  49063. * 处理复制代码块的操作
  49064. */
  49065. }, {
  49066. key: "$dealCopyCodeBlock",
  49067. value: function $dealCopyCodeBlock(e) {
  49068. var _target$parentNode;
  49069. var target = e.target;
  49070. if (target.className === 'cherry-copy-code-block' || ((_target$parentNode = target.parentNode) === null || _target$parentNode === void 0 ? void 0 : _target$parentNode.className) === 'cherry-copy-code-block') {
  49071. var parentNode = target.className === 'cherry-copy-code-block' ? target.parentNode : target.parentNode.parentNode;
  49072. var codeContent = parentNode.innerText;
  49073. var _final = this.previewer.$cherry.options.callback.onCopyCode(e, codeContent);
  49074. if (_final === false) {
  49075. return false;
  49076. }
  49077. var iconNode = parentNode.querySelector('i.ch-icon-copy');
  49078. if (iconNode) {
  49079. iconNode.className = iconNode.className.replace('copy', 'ok');
  49080. setTimeout$3(function () {
  49081. iconNode.className = iconNode.className.replace('ok', 'copy');
  49082. }, 1500);
  49083. }
  49084. copyToClip(_final);
  49085. }
  49086. }
  49087. /**
  49088. * 隐藏预览区域已经激活的工具栏
  49089. * @param {string} trigger 移除指定的触发方式,不传默认全部移除
  49090. */
  49091. }, {
  49092. key: "$removeAllPreviewerBubbles",
  49093. value: function $removeAllPreviewerBubbles() {
  49094. var _context12,
  49095. _context13,
  49096. _this4 = this,
  49097. _context14,
  49098. _context15;
  49099. var trigger = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  49100. forEach$3(_context12 = filter$3(_context13 = entries$2(this.bubble)).call(_context13, function (_ref) {
  49101. var _ref2 = _slicedToArray(_ref, 1),
  49102. key = _ref2[0];
  49103. return !trigger || trigger === key;
  49104. })).call(_context12, function (_ref3) {
  49105. var _ref4 = _slicedToArray(_ref3, 2),
  49106. key = _ref4[0],
  49107. value = _ref4[1];
  49108. value.remove();
  49109. delete _this4.bubble[key];
  49110. });
  49111. forEach$3(_context14 = filter$3(_context15 = entries$2(this.bubbleHandler)).call(_context15, function (_ref5) {
  49112. var _ref6 = _slicedToArray(_ref5, 1),
  49113. key = _ref6[0];
  49114. return !trigger || trigger === key;
  49115. })).call(_context14, function (_ref7) {
  49116. var _ref8 = _slicedToArray(_ref7, 2),
  49117. key = _ref8[0],
  49118. value = _ref8[1];
  49119. value.emit('remove');
  49120. delete _this4.bubbleHandler[key];
  49121. });
  49122. }
  49123. /**
  49124. * 为触发的table增加操作工具栏
  49125. * @param {string} trigger 触发方式
  49126. * @param {HTMLElement} htmlElement 用户触发的table dom
  49127. */
  49128. }, {
  49129. key: "$showTablePreviewerBubbles",
  49130. value: function $showTablePreviewerBubbles(trigger, htmlElement) {
  49131. this.$createPreviewerBubbles(trigger, trigger === 'click' ? 'table-content-hander' : 'table-hover-handler');
  49132. var handler = new TableHandler(trigger, htmlElement, this.bubble[trigger], this.previewerDom, this.editor.editor);
  49133. handler.showBubble();
  49134. this.bubbleHandler[trigger] = handler;
  49135. }
  49136. /**
  49137. * 为选中的图片增加操作工具栏
  49138. * @param {HTMLImageElement} htmlElement 用户点击的图片dom
  49139. */
  49140. }, {
  49141. key: "$showImgPreviewerBubbles",
  49142. value: function $showImgPreviewerBubbles(htmlElement) {
  49143. var _context16;
  49144. this.$createPreviewerBubbles();
  49145. var list = from_1$2(this.previewerDom.querySelectorAll('img'));
  49146. this.totalImgs = list.length;
  49147. this.imgIndex = indexOf$8(list).call(list, htmlElement);
  49148. if (!this.beginChangeImgValue(htmlElement)) {
  49149. return {
  49150. emit: function emit() {}
  49151. };
  49152. }
  49153. imgSizeHander.showBubble(htmlElement, this.bubble.click, this.previewerDom);
  49154. imgSizeHander.bindChange(bind$5(_context16 = this.changeImgValue).call(_context16, this));
  49155. this.bubbleHandler.click = imgSizeHander;
  49156. }
  49157. }, {
  49158. key: "getValueWithoutCode",
  49159. value: function getValueWithoutCode() {
  49160. return this.editor.editor.getValue().replace(getCodeBlockRule().reg, function (whole) {
  49161. // 把代码块里的内容干掉
  49162. return whole.replace(/^.*$/gm, '/n');
  49163. }).replace(/(`+)(.+?(?:\n.+?)*?)\1/g, function (whole) {
  49164. // 把行内代码的符号去掉
  49165. return whole.replace(/[![\]()]/g, '.');
  49166. });
  49167. }
  49168. /**
  49169. * TODO: beginChangeDrawioImg 和 beginChangeImgValue 代码高度重合,后面有时间重构下,抽成一个可以复用的,可以避开代码块、行内代码影响的通用方法
  49170. * 修改draw.io图片时选中编辑区域的对应文本
  49171. * @param {*} htmlElement 图片node
  49172. */
  49173. }, {
  49174. key: "beginChangeDrawioImg",
  49175. value: function beginChangeDrawioImg(htmlElement) {
  49176. var _context17;
  49177. var allDrawioImgs = from_1$2(this.previewerDom.querySelectorAll('img[data-type="drawio"]'));
  49178. var totalDrawioImgs = allDrawioImgs.length;
  49179. var drawioImgIndex = indexOf$8(allDrawioImgs).call(allDrawioImgs, htmlElement);
  49180. var content = this.getValueWithoutCode();
  49181. var drawioImgsCode = content.match(imgDrawioReg);
  49182. var testSrc = drawioImgsCode[drawioImgIndex] ? trim$3(_context17 = drawioImgsCode[drawioImgIndex].replace(/^!\[.*?\]\((.*?)\)/, '$1')).call(_context17) : '';
  49183. if (drawioImgsCode.length === totalDrawioImgs || htmlElement.getAttribute('src') === testSrc) {
  49184. // 如果drawio语法数量和预览区域的一样多
  49185. var totalValue = content.split(imgDrawioReg);
  49186. var line = 0;
  49187. var beginCh = 0;
  49188. var endCh = 0;
  49189. var testIndex = 0;
  49190. for (var i = 0; i < totalValue.length; i++) {
  49191. var targetString = totalValue[i];
  49192. if (targetString === drawioImgsCode[testIndex]) {
  49193. // 如果找到目标代码
  49194. if (testIndex === drawioImgIndex) {
  49195. endCh = beginCh + targetString.length;
  49196. beginCh += targetString.replace(/^(!\[[^\]]*])[^\n]*$/, '$1').length;
  49197. this.editor.editor.setSelection({
  49198. line: line,
  49199. ch: beginCh
  49200. }, {
  49201. line: line,
  49202. ch: endCh
  49203. }); // 更新后需要再调用一次markText机制
  49204. this.editor.dealBigData();
  49205. return true;
  49206. }
  49207. testIndex += 1;
  49208. } else {
  49209. var _targetString$match$l, _targetString$match;
  49210. line += (_targetString$match$l = (_targetString$match = targetString.match(/\n/g)) === null || _targetString$match === void 0 ? void 0 : _targetString$match.length) !== null && _targetString$match$l !== void 0 ? _targetString$match$l : 0;
  49211. if (/\n/.test(targetString)) {
  49212. // 如果有换行,则开始位置的字符计数从最后一个换行开始计数
  49213. beginCh = targetString.replace(/^[\w\W]*\n([^\n]*)$/, '$1').length;
  49214. } else {
  49215. // 如果没有换行,则继续按上次的beginCh为起始开始计数
  49216. beginCh += targetString.length;
  49217. }
  49218. }
  49219. }
  49220. }
  49221. return false;
  49222. }
  49223. /**
  49224. * 选中图片对应的MD语法
  49225. * @param {*} htmlElement 图片node
  49226. * @returns {boolean}
  49227. */
  49228. }, {
  49229. key: "beginChangeImgValue",
  49230. value: function beginChangeImgValue(htmlElement) {
  49231. var _context18;
  49232. var content = this.getValueWithoutCode();
  49233. var src = htmlElement.getAttribute('src');
  49234. var imgReg = /(!\[[^\n]*?\]\([^)]+\))/g;
  49235. var contentImgs = content.match(imgReg);
  49236. var testSrc = contentImgs[this.imgIndex] ? trim$3(_context18 = contentImgs[this.imgIndex].replace(/^!\[.*?\]\((.*?)\)/, '$1')).call(_context18) : '';
  49237. if (contentImgs.length === this.totalImgs || src === testSrc) {
  49238. // 如果图片语法数量和预览区域的一样多
  49239. // 暂时不需要考虑手动输入img标签的场景 和 引用图片的场景
  49240. var totalValue = content.split(imgReg);
  49241. var imgAppendReg = /^!\[.*?((?:#center|#right|#left|#float-right|#float-left|#border|#B|#shadow|#S|#radius|#R)+).*?\].*$/;
  49242. var line = 0;
  49243. var beginCh = 0;
  49244. var endCh = 0;
  49245. var testIndex = 0;
  49246. for (var i = 0; i < totalValue.length; i++) {
  49247. var _targetString$match$l2, _targetString$match2;
  49248. var targetString = totalValue[i];
  49249. if (targetString === contentImgs[testIndex]) {
  49250. // 如果找到目标代码
  49251. if (testIndex === this.imgIndex) {
  49252. this.imgAppend = imgAppendReg.test(targetString) ? targetString.replace(imgAppendReg, '$1') : false;
  49253. beginCh += targetString.replace(/^(!\[[^#\]]*).*$/, '$1').length;
  49254. endCh = beginCh + targetString.replace(/^(!\[[^#\]]*)([^\]]*?)\].*$/, '$2').length;
  49255. this.editor.editor.setSelection({
  49256. line: line,
  49257. ch: beginCh
  49258. }, {
  49259. line: line,
  49260. ch: endCh
  49261. });
  49262. return true;
  49263. }
  49264. testIndex += 1;
  49265. }
  49266. line += (_targetString$match$l2 = (_targetString$match2 = targetString.match(/\n/g)) === null || _targetString$match2 === void 0 ? void 0 : _targetString$match2.length) !== null && _targetString$match$l2 !== void 0 ? _targetString$match$l2 : 0;
  49267. if (/\n/.test(targetString)) {
  49268. // 如果有换行,则开始位置的字符计数从最后一个换行开始计数
  49269. beginCh = targetString.replace(/^[\w\W]*\n([^\n]*)$/, '$1').length;
  49270. } else {
  49271. // 如果没有换行,则继续按上次的beginCh为起始开始计数
  49272. beginCh += targetString.length;
  49273. }
  49274. }
  49275. }
  49276. return false;
  49277. }
  49278. /**
  49279. * 修改图片尺寸时的回调
  49280. * @param {HTMLElement} htmlElement 被拖拽的图片标签
  49281. * @param {Object} style 图片的属性(宽高、对齐方式)
  49282. */
  49283. }, {
  49284. key: "changeImgValue",
  49285. value: function changeImgValue(htmlElement, style) {
  49286. var _context19, _context20;
  49287. var append = this.imgAppend ? " ".concat(this.imgAppend) : '';
  49288. this.editor.editor.replaceSelection(concat$5(_context19 = concat$5(_context20 = "#".concat(Math.round(style.width), "px #")).call(_context20, Math.round(style.height), "px")).call(_context19, append), 'around');
  49289. }
  49290. /**
  49291. * 预览区域编辑器的容器
  49292. * @param {string} trigger 触发方式
  49293. * @param {string} type 容器类型(用作样式名:cherry-previewer-{type})
  49294. */
  49295. }, {
  49296. key: "$createPreviewerBubbles",
  49297. value: function $createPreviewerBubbles() {
  49298. var trigger = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'click';
  49299. var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'img-size-hander';
  49300. if (!this.bubble[trigger]) {
  49301. this.bubble[trigger] = document.createElement('div');
  49302. this.bubble[trigger].className = "cherry-previewer-".concat(type);
  49303. this.previewerDom.after(this.bubble[trigger]);
  49304. if (trigger === 'hover') {
  49305. this.bubble[trigger].addEventListener('mouseover', this.removeHoverBubble.cancel);
  49306. this.bubble[trigger].addEventListener('mouseout', this.removeHoverBubble);
  49307. }
  49308. }
  49309. }
  49310. }, {
  49311. key: "$showBorderBubbles",
  49312. value: function $showBorderBubbles() {}
  49313. }, {
  49314. key: "$showBtnBubbles",
  49315. value: function $showBtnBubbles() {}
  49316. /**
  49317. * 修改预览区域代码语言设置的回调
  49318. */
  49319. }, {
  49320. key: "$codePreviewLangSelectEventHandler",
  49321. value: function $codePreviewLangSelectEventHandler(event) {
  49322. var list = from_1$2(this.previewerDom.querySelectorAll(".".concat(CODE_PREVIEWER_LANG_SELECT_CLASS_NAME)));
  49323. var codePreviewIndex = indexOf$8(list).call(list, event.target);
  49324. var contentList = this.editor.editor.getValue().split('\n');
  49325. var targetCodePreviewSelectLine = -1;
  49326. var findCodeArea = -1; // 相互匹配的`的数量
  49327. var matchedSignalNum = 0; // 查找选择设置的代码块在哪一行:
  49328. var left = 0;
  49329. while (left < contentList.length) {
  49330. if (findCodeArea >= codePreviewIndex) {
  49331. break;
  49332. }
  49333. var right = left + 1;
  49334. if (/^`{3,}[\s\S]*$/.test(contentList[left])) {
  49335. var _contentList$left$mat, _contentList$left$mat2;
  49336. // 起始的`的数量
  49337. var topSignalNum = (_contentList$left$mat = (_contentList$left$mat2 = contentList[left].match(/^(`*)/g)) === null || _contentList$left$mat2 === void 0 ? void 0 : _contentList$left$mat2[0].length) !== null && _contentList$left$mat !== void 0 ? _contentList$left$mat : 0;
  49338. while (right < contentList.length) {
  49339. var _contentList$right$ma, _contentList$right$ma2;
  49340. var isMatched = false;
  49341. var bottomSignalNum = (_contentList$right$ma = (_contentList$right$ma2 = contentList[right].match(/^(`*)/g)) === null || _contentList$right$ma2 === void 0 ? void 0 : _contentList$right$ma2[0].length) !== null && _contentList$right$ma !== void 0 ? _contentList$right$ma : 0; // 支持: 3个及以上的`的相互匹配
  49342. if (/^`{3,}$/.test(contentList[right]) && bottomSignalNum === topSignalNum) {
  49343. isMatched = true;
  49344. findCodeArea = findCodeArea + 1;
  49345. if (findCodeArea === codePreviewIndex) {
  49346. targetCodePreviewSelectLine = left;
  49347. matchedSignalNum = topSignalNum;
  49348. }
  49349. }
  49350. right = right + 1;
  49351. if (isMatched) {
  49352. break;
  49353. }
  49354. }
  49355. }
  49356. left = right;
  49357. } // 只有匹配了代码块才进行替换
  49358. if (matchedSignalNum) {
  49359. this.editor.editor.setSelection({
  49360. line: targetCodePreviewSelectLine,
  49361. ch: matchedSignalNum
  49362. }, {
  49363. line: targetCodePreviewSelectLine,
  49364. ch: contentList[targetCodePreviewSelectLine].length
  49365. });
  49366. this.editor.editor.replaceSelection(event.target.value || '');
  49367. }
  49368. }
  49369. }]);
  49370. return PreviewerBubble;
  49371. }();
  49372. var setInterval$2 = path.setInterval;
  49373. var setInterval$3 = setInterval$2;
  49374. /**
  49375. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  49376. *
  49377. * Licensed under the Apache License, Version 2.0 (the "License");
  49378. * you may not use this file except in compliance with the License.
  49379. * You may obtain a copy of the License at
  49380. *
  49381. * http://www.apache.org/licenses/LICENSE-2.0
  49382. *
  49383. * Unless required by applicable law or agreed to in writing, software
  49384. * distributed under the License is distributed on an "AS IS" BASIS,
  49385. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  49386. * See the License for the specific language governing permissions and
  49387. * limitations under the License.
  49388. */
  49389. /**
  49390. * 懒加载图片
  49391. *
  49392. * - 只缓存图片的src的原因
  49393. * - 1、因为浏览器的图片缓存机制,相同的src第二次请求时,会浏览器会直接返回缓存的图片
  49394. * - 2、编辑状态时预览区域dom结构不稳定,并不能准确的缓存到img dom对象
  49395. *
  49396. * - 当浏览器**禁用**了图片缓存时,本机制效果有限
  49397. * - 依然还是可以实现懒加载的效果
  49398. * - 但是会把图片请求次数翻倍
  49399. */
  49400. var LazyLoadImg = /*#__PURE__*/function () {
  49401. function LazyLoadImg(options, previewer) {
  49402. _classCallCheck(this, LazyLoadImg);
  49403. _defineProperty(this, "options", {
  49404. // 加载图片时如果需要展示loading图,则配置loading图的地址
  49405. loadingImgPath: '',
  49406. // 同一时间最多有几个图片请求,最大同时加载6张图片
  49407. maxNumPerTime: 2,
  49408. // 不进行懒加载处理的图片数量,如果为0,即所有图片都进行懒加载处理, 如果设置为-1,则所有图片都不进行懒加载处理
  49409. noLoadImgNum: 5,
  49410. // 首次自动加载几张图片(不论图片是否滚动到视野内),autoLoadImgNum = -1 表示会自动加载完所有图片
  49411. autoLoadImgNum: 5,
  49412. // 针对加载失败的图片 或 beforeLoadOneImgCallback 返回false 的图片,最多尝试加载几次,为了防止死循环,最多5次。以图片的src为纬度统计重试次数
  49413. maxTryTimesPerSrc: 2,
  49414. // 加载一张图片之前的回调函数,函数return false 会终止加载操作
  49415. beforeLoadOneImgCallback: function beforeLoadOneImgCallback(img) {},
  49416. // 加载一张图片失败之后的回调函数
  49417. failLoadOneImgCallback: function failLoadOneImgCallback(img) {},
  49418. // 加载一张图片之后的回调函数,如果图片加载失败,则不会回调该函数
  49419. afterLoadOneImgCallback: function afterLoadOneImgCallback(img) {},
  49420. // 加载完所有图片后调用的回调函数,只表示某一个时刻所有图片都加在完时的回调,如果预览区域又有了新图片,当新图片加载完后还会产生这个回调
  49421. afterLoadAllImgCallback: function afterLoadAllImgCallback() {}
  49422. });
  49423. assign$2(this.options, options);
  49424. this.previewer = previewer; // 记录已经加载过的图片src
  49425. this.srcLoadedList = []; // 记录加载失败的图片src,key是src,value是失败次数
  49426. this.srcFailLoadedList = {}; // 记录正在加载的图片src
  49427. this.srcLoadingList = []; // 记录所有懒加载的图片src
  49428. this.srcList = []; // 记录当前时刻有多少图片正在加载
  49429. this.loadingImgNum = 0; // 记录上次加载完所有图片的个数
  49430. this.lastLoadAllNum = 0;
  49431. this.previewerDom = this.previewer.getDomContainer();
  49432. }
  49433. /**
  49434. * 判断图片的src是否加载过
  49435. * @param {String} src
  49436. * @return {Boolean}
  49437. */
  49438. _createClass(LazyLoadImg, [{
  49439. key: "isLoaded",
  49440. value: function isLoaded(src) {
  49441. var _context;
  49442. return includes$4(_context = this.srcLoadedList).call(_context, src);
  49443. }
  49444. /**
  49445. * 判断图片是否正在加载
  49446. * @param {String} src
  49447. * @return {Boolean}
  49448. */
  49449. }, {
  49450. key: "isLoading",
  49451. value: function isLoading(src) {
  49452. var _context2;
  49453. return includes$4(_context2 = this.srcLoadingList).call(_context2, src);
  49454. }
  49455. /**
  49456. * 加载失败时,把src加入到失败队列中,并记录失败次数
  49457. * @param {*} src
  49458. */
  49459. }, {
  49460. key: "loadFailed",
  49461. value: function loadFailed(src) {
  49462. this.srcFailLoadedList[src] = this.srcFailLoadedList[src] ? this.srcFailLoadedList[src] + 1 : 1;
  49463. }
  49464. /**
  49465. * 判断图片失败次数是否超过最大次数
  49466. * @param {*} src
  49467. * @return {Boolean}
  49468. */
  49469. }, {
  49470. key: "isFailLoadedMax",
  49471. value: function isFailLoadedMax(src) {
  49472. return this.srcFailLoadedList[src] && this.srcFailLoadedList[src] > this.options.maxTryTimesPerSrc;
  49473. }
  49474. /**
  49475. * 判断当前时刻所有图片是否都完成过加载
  49476. * 当出现新图片后,完成加载后,当前函数还是会再次触发加载完的回调函数(afterLoadAllImgCallback)
  49477. * 该函数并不是实时返回的,最大有1s的延时
  49478. */
  49479. }, {
  49480. key: "isLoadedAllDone",
  49481. value: function isLoadedAllDone() {
  49482. var imgs = this.previewerDom.querySelectorAll('img[data-src]');
  49483. var allLoadedNum = this.srcLoadedList.length; // const dataSrcRemain = allLoadNum - this.srcLoadedList.length;
  49484. if (imgs.length <= 0 && this.lastLoadAllNum < allLoadedNum) {
  49485. this.lastLoadAllNum = allLoadedNum;
  49486. this.options.afterLoadAllImgCallback();
  49487. return true;
  49488. }
  49489. return false;
  49490. }
  49491. /**
  49492. * 当向下滚动时,提前100px加载图片
  49493. * 当向上滚动时,不提前加载图片,一定要图片完全进入可视区域(top > 0)再加载图片,否则当锚点定位时,会由于上面的图片加载出现定位不准的情况
  49494. *
  49495. */
  49496. }, {
  49497. key: "loadOneImg",
  49498. value: function loadOneImg() {
  49499. var _window$innerHeight,
  49500. _window,
  49501. _this = this;
  49502. var imgs = this.previewerDom.querySelectorAll('img[data-src]');
  49503. var _this$previewerDom$ge = this.previewerDom.getBoundingClientRect(),
  49504. height = _this$previewerDom$ge.height,
  49505. top = _this$previewerDom$ge.top;
  49506. var previewerHeight = height + top + 100; // 冗余一定高度用于提前加载
  49507. var windowsHeight = (_window$innerHeight = (_window = window) === null || _window === void 0 ? void 0 : _window.innerHeight) !== null && _window$innerHeight !== void 0 ? _window$innerHeight : 0 + 100; // 浏览器的视口高度
  49508. var maxHeight = Math.min(previewerHeight, windowsHeight); // 目标视区高度一定是小于浏览器视口高度的,也一定是小于预览区高度的
  49509. var minHeight = top - 30; // 计算顶部高度时,需要预加载一行高
  49510. var autoLoadImgNum = this.options.autoLoadImgNum;
  49511. var _loop = function _loop(i) {
  49512. var img = imgs[i];
  49513. var position = img.getBoundingClientRect(); // 判断是否在视区内
  49514. var testPosition = position.top >= minHeight && position.top <= maxHeight; // 判断是否需要自动加载
  49515. var testAutoLoad = _this.srcList.length < autoLoadImgNum;
  49516. if (!testPosition && !testAutoLoad) {
  49517. return "continue";
  49518. }
  49519. var originSrc = img.getAttribute('data-src');
  49520. if (!originSrc) {
  49521. return "continue";
  49522. }
  49523. if (_this.isLoaded(originSrc) || _this.isFailLoadedMax(originSrc)) {
  49524. // 如果已经加载过相同的图片,或者已经超过失败最大重试次数,则直接加载
  49525. img.setAttribute('src', originSrc);
  49526. img.removeAttribute('data-src');
  49527. } // 如果当前src正在加载,则忽略这个src,继续找下个符合条件的src
  49528. if (_this.isLoading(originSrc)) {
  49529. return "continue";
  49530. } // 超过最大并发量时停止加载
  49531. if (_this.loadingImgNum >= _this.options.maxNumPerTime) {
  49532. return {
  49533. v: false
  49534. };
  49535. }
  49536. var test = _this.options.beforeLoadOneImgCallback(img);
  49537. if (typeof test === 'undefined' || test) {
  49538. var _img$getAttribute;
  49539. originSrc = (_img$getAttribute = img.getAttribute('data-src')) !== null && _img$getAttribute !== void 0 ? _img$getAttribute : originSrc;
  49540. } else {
  49541. _this.loadFailed(originSrc);
  49542. return "continue";
  49543. }
  49544. _this.loadingImgNum += 1;
  49545. _this.srcList.push(originSrc);
  49546. _this.srcLoadingList.push(originSrc);
  49547. _this.tryLoadOneImg(originSrc, function () {
  49548. var _context3, _context4;
  49549. img.setAttribute('src', originSrc);
  49550. img.removeAttribute('data-src');
  49551. _this.srcLoadedList.push(originSrc);
  49552. _this.loadingImgNum -= 1;
  49553. splice$4(_context3 = _this.srcLoadingList).call(_context3, indexOf$8(_context4 = _this.srcLoadingList).call(_context4, originSrc), 1);
  49554. _this.options.afterLoadOneImgCallback(img);
  49555. _this.loadOneImg();
  49556. }, function () {
  49557. var _context5, _context6;
  49558. _this.loadFailed(originSrc);
  49559. _this.loadingImgNum -= 1;
  49560. splice$4(_context5 = _this.srcLoadingList).call(_context5, indexOf$8(_context6 = _this.srcLoadingList).call(_context6, originSrc), 1);
  49561. _this.options.failLoadOneImgCallback(img);
  49562. _this.loadOneImg();
  49563. });
  49564. };
  49565. for (var i = 0; i < imgs.length; i++) {
  49566. var _ret = _loop(i);
  49567. if (_ret === "continue") continue;
  49568. if (_typeof(_ret) === "object") return _ret.v;
  49569. }
  49570. return false;
  49571. }
  49572. /**
  49573. * 尝试加载src
  49574. * @param {String} src
  49575. */
  49576. }, {
  49577. key: "tryLoadOneImg",
  49578. value: function tryLoadOneImg(src, successCallback, failCallback) {
  49579. var img = document.createElement('img');
  49580. img.onload = function () {
  49581. successCallback();
  49582. img.remove();
  49583. };
  49584. img.onerror = function () {
  49585. failCallback();
  49586. img.remove();
  49587. };
  49588. img.setAttribute('src', src);
  49589. }
  49590. /**
  49591. * 开始进行懒加载
  49592. *
  49593. * **关于实现方式的思考**
  49594. * 实现图片懒加载一般有三种方式:
  49595. * 1、监听滚动事件,滚动到视野内的图片开始加载
  49596. * 2、定时检测当前视窗内是否有图片需要加载
  49597. * 3、当前一张图片加载完成后,自动加载下一张图片
  49598. *
  49599. * 方式1监听滚动事件的弊端:
  49600. * 1、需要限频率
  49601. * 2、不能实现自动加载所有图片的功能(autoLoadImgNum = -1)
  49602. * 3、如果业务方对预览区域做了个性化加工,有可能导致监听不到滚动事件
  49603. * 4、在自动滚动到锚点的场景,会在页面滚动时加载图片,图片的加载会导致锚点上方的元素高度发生变化,最终导致锚点定位失败
  49604. * (所以在这个场景下,需要特殊处理图片加载的时机,但并不好判断是否锚点引发的滚动)
  49605. * 5、浏览器尺寸发生变化或者浏览器缩放比例发生变化的场景(当然还有横屏竖屏切换、系统分辨率改变等)不好监听和响应
  49606. *
  49607. * 方式2轮询的弊端:
  49608. * 1、需要额外的逻辑来控制并发
  49609. * 2、消耗计算资源,所以需要尽量优化单次计算量,并尽量避免在轮询里进行大范围dom操作
  49610. * 3、两次图片加载中间可能有最大轮询间隔的空闲时间浪费
  49611. *
  49612. * 方式3依次加载的弊端:
  49613. * 1、没办法实现滚动到视野内再加载图片
  49614. *
  49615. * 综合考虑决定用方式2(轮询)+方式3(依次加载)的组合方式,并且每次只做一次dom写操作
  49616. * 轮询带来的性能开销就让受摩尔定律加持的硬件和每月都会更新版本的浏览器们愁去吧
  49617. */
  49618. }, {
  49619. key: "doLazyLoad",
  49620. value: function doLazyLoad() {
  49621. var _this2 = this;
  49622. // 防止重复调用
  49623. if (this.isRunning) {
  49624. return;
  49625. }
  49626. this.isRunning = true;
  49627. var maxNumPerTime = this.options.maxNumPerTime;
  49628. var polling = function polling() {
  49629. // 保证至少有一次自动加载
  49630. _this2.loadOneImg();
  49631. for (var i = 1; i < maxNumPerTime; i++) {
  49632. _this2.loadOneImg();
  49633. }
  49634. setTimeout$3(polling, 200);
  49635. };
  49636. polling(); // setTimeout(polling, 200);
  49637. setInterval$3(function () {
  49638. _this2.isLoadedAllDone();
  49639. }, 1000);
  49640. }
  49641. /**
  49642. * 把图片里的data-src替换为src
  49643. * @param {*} content
  49644. * @returns {String}
  49645. */
  49646. }, {
  49647. key: "changeDataSrc2Src",
  49648. value: function changeDataSrc2Src(content) {
  49649. var _this3 = this;
  49650. return content.replace(/<img ([^>]*?)data-src="([^"]+)"([^>]*?)>/g, function (match, m1, src, m3) {
  49651. var _context7, _context8;
  49652. return concat$5(_context7 = concat$5(_context8 = "<img ".concat(_this3.$removeSrc(m1), " src=\"")).call(_context8, src, "\" ")).call(_context7, _this3.$removeSrc(m3), ">").replace(/ {2,}/g, ' ');
  49653. });
  49654. }
  49655. /**
  49656. * 把已经加载的图片里的data-src替换为src
  49657. * @param {*} content
  49658. * @returns {String}
  49659. */
  49660. }, {
  49661. key: "changeLoadedDataSrc2Src",
  49662. value: function changeLoadedDataSrc2Src(content) {
  49663. var _this4 = this;
  49664. return content.replace(/<img ([^>]*?)data-src="([^"]+)"([^>]*?)>/g, function (match, m1, src, m3) {
  49665. var _context9, _context10;
  49666. if (!_this4.isLoaded(src)) {
  49667. return match;
  49668. }
  49669. return concat$5(_context9 = concat$5(_context10 = "<img ".concat(_this4.$removeSrc(m1), " src=\"")).call(_context10, src, "\" ")).call(_context9, _this4.$removeSrc(m3), ">").replace(/ {2,}/g, ' ');
  49670. });
  49671. }
  49672. /**
  49673. * 移除图片的src属性
  49674. * @param {String} img
  49675. * @returns {String}
  49676. */
  49677. }, {
  49678. key: "$removeSrc",
  49679. value: function $removeSrc(img) {
  49680. return " ".concat(img).replace(/^(.*?) src=".*?"(.*?$)/, '$1$2');
  49681. }
  49682. /**
  49683. * 把图片里的src替换为data-src,如果src已经加载过,则不替换
  49684. * @param {String} content
  49685. * @param {Boolean} focus 强制替换
  49686. * @returns {String}
  49687. */
  49688. }, {
  49689. key: "changeSrc2DataSrc",
  49690. value: function changeSrc2DataSrc(content) {
  49691. var _this5 = this;
  49692. var focus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  49693. var loadingImgPath = this.options.loadingImgPath;
  49694. var noLoadImgNum = this.options.noLoadImgNum;
  49695. var currentNoLoadImgNum = 0;
  49696. return content.replace(/<img ([^>]*?)src="([^"]+)"([^>]*?)>/g, function (match, m1, src, m3) {
  49697. var _context14, _context15;
  49698. // 如果已经替换过data-src了,或者没有src属性,或者关闭了懒加载功能,则不替换
  49699. if (/data-src="/.test(match) || !/ src="/.test(match) || noLoadImgNum < 0) {
  49700. return match;
  49701. }
  49702. if (focus === false) {
  49703. // 前noLoadImgNum张图片不替换
  49704. if (currentNoLoadImgNum < noLoadImgNum) {
  49705. currentNoLoadImgNum += 1;
  49706. return match;
  49707. } // 如果src已经加载过,则不替换
  49708. if (_this5.isLoaded(src)) {
  49709. return match;
  49710. }
  49711. } // 如果配置了loadingImgPath,则替换src为loadingImgPath
  49712. if (loadingImgPath) {
  49713. var _context11, _context12, _context13;
  49714. return concat$5(_context11 = concat$5(_context12 = concat$5(_context13 = "<img ".concat(m1, "src=\"")).call(_context13, loadingImgPath, "\" data-src=\"")).call(_context12, src, "\"")).call(_context11, m3, ">");
  49715. }
  49716. return concat$5(_context14 = concat$5(_context15 = "<img ".concat(m1, "data-src=\"")).call(_context15, src, "\"")).call(_context14, m3, ">");
  49717. });
  49718. }
  49719. }]);
  49720. return LazyLoadImg;
  49721. }();
  49722. var onScroll = function onScroll() {}; // store in memory for remove event
  49723. /**
  49724. * 解析第一个节点
  49725. * @param {Node} node 经过DOMParser转换的HTML
  49726. * @returns {String | null}
  49727. */
  49728. var findNonEmptyNode = function findNonEmptyNode(node) {
  49729. var _context;
  49730. // 如果节点是文本节点且内容不为空,则返回该节点
  49731. if (node.nodeType === Node.TEXT_NODE && trim$3(_context = node.textContent).call(_context) !== '') {
  49732. var _context2;
  49733. return trim$3(_context2 = node.textContent).call(_context2);
  49734. }
  49735. for (var i = 0; i < node.childNodes.length; i++) {
  49736. var childNode = node.childNodes[i];
  49737. var result = findNonEmptyNode(childNode);
  49738. if (result) {
  49739. return result;
  49740. }
  49741. }
  49742. return null;
  49743. };
  49744. /**
  49745. * 作用:
  49746. * dom更新
  49747. * 局部加载(分片)
  49748. * 与左侧输入区域滚动同步
  49749. */
  49750. var Previewer = /*#__PURE__*/function () {
  49751. /**
  49752. * @property
  49753. * @private
  49754. * @type {boolean} 等待预览区域更新。预览区域更新时,预览区的滚动不会引起编辑器滚动,避免因插入的元素高度变化导致编辑区域跳动
  49755. */
  49756. /**
  49757. * @property
  49758. * @private
  49759. * @type {number} 释放同步滚动锁定的定时器ID
  49760. */
  49761. /**
  49762. * @property
  49763. * @public
  49764. * @type {boolean} 是否为移动端预览模式
  49765. */
  49766. /**
  49767. *
  49768. * @param {Partial<import('~types/previewer').PreviewerOptions>} options 预览区域设置
  49769. */
  49770. function Previewer(options) {
  49771. _classCallCheck(this, Previewer);
  49772. _defineProperty(this, "applyingDomChanges", false);
  49773. _defineProperty(this, "syncScrollLockTimer", 0);
  49774. _defineProperty(this, "isMobilePreview", false);
  49775. /**
  49776. * @property
  49777. * @type {import('~types/previewer').PreviewerOptions}
  49778. */
  49779. this.options = {
  49780. previewerDom: document.createElement('div'),
  49781. virtualDragLineDom: document.createElement('div'),
  49782. editorMaskDom: document.createElement('div'),
  49783. previewerMaskDom: document.createElement('div'),
  49784. minBlockPercentage: 0.2,
  49785. // editor或previewer所占宽度比例的最小值
  49786. value: '',
  49787. enablePreviewerBubble: true,
  49788. afterUpdateCallBack: [],
  49789. isPreviewOnly: false,
  49790. previewerCache: {
  49791. // 关闭/开启预览区时缓存的previewer数据
  49792. html: '',
  49793. htmlChanged: false,
  49794. layout: {}
  49795. },
  49796. /**
  49797. * 配置图片懒加载的逻辑
  49798. * 如果不希望图片懒加载,可配置成 lazyLoadImg = {maxNumPerTime: 6, autoLoadImgNum: -1}
  49799. */
  49800. lazyLoadImg: {
  49801. // 加载图片时如果需要展示loading图,则配置loading图的地址
  49802. loadingImgPath: '',
  49803. // 同一时间最多有几个图片请求,最大同时加载6张图片
  49804. maxNumPerTime: 2,
  49805. // 不进行懒加载处理的图片数量,如果为0,即所有图片都进行懒加载处理, 如果设置为-1,则所有图片都不进行懒加载处理
  49806. noLoadImgNum: 5,
  49807. // 首次自动加载几张图片(不论图片是否滚动到视野内),autoLoadImgNum = -1 表示会自动加载完所有图片
  49808. autoLoadImgNum: 5,
  49809. // 针对加载失败的图片 或 beforeLoadOneImgCallback 返回false 的图片,最多尝试加载几次,为了防止死循环,最多5次。以图片的src为纬度统计重试次数
  49810. maxTryTimesPerSrc: 2,
  49811. // 加载一张图片之前的回调函数,函数return false 会终止加载操作
  49812. beforeLoadOneImgCallback: function beforeLoadOneImgCallback(img) {},
  49813. // 加载一张图片失败之后的回调函数
  49814. failLoadOneImgCallback: function failLoadOneImgCallback(img) {},
  49815. // 加载一张图片之后的回调函数,如果图片加载失败,则不会回调该函数
  49816. afterLoadOneImgCallback: function afterLoadOneImgCallback(img) {},
  49817. // 加载完所有图片后调用的回调函数
  49818. afterLoadAllImgCallback: function afterLoadAllImgCallback() {}
  49819. }
  49820. };
  49821. assign$2(this.options, options);
  49822. this.$cherry = this.options.$cherry;
  49823. this.instanceId = this.$cherry.getInstanceId();
  49824. /**
  49825. * @property
  49826. * @private
  49827. * @type {{ timer?: number; destinationTop?: number }}
  49828. */
  49829. this.animation = {};
  49830. }
  49831. _createClass(Previewer, [{
  49832. key: "init",
  49833. value: function init(editor) {
  49834. /**
  49835. * @property
  49836. * @private
  49837. * @type {boolean} 禁用滚动事件监听
  49838. */
  49839. this.disableScrollListener = false;
  49840. this.bindScroll();
  49841. this.editor = editor;
  49842. this.bindDrag();
  49843. this.$initPreviewerBubble();
  49844. this.lazyLoadImg = new LazyLoadImg(this.options.lazyLoadImg, this);
  49845. this.lazyLoadImg.doLazyLoad();
  49846. this.onMouseDown();
  49847. }
  49848. }, {
  49849. key: "$initPreviewerBubble",
  49850. value: function $initPreviewerBubble() {
  49851. this.previewerBubble = new PreviewerBubble(this);
  49852. }
  49853. /**
  49854. * @returns {HTMLElement}
  49855. */
  49856. }, {
  49857. key: "getDomContainer",
  49858. value: function getDomContainer() {
  49859. return this.isMobilePreview ? this.options.previewerDom.querySelector('.cherry-mobile-previewer-content') : this.options.previewerDom;
  49860. }
  49861. }, {
  49862. key: "getDom",
  49863. value: function getDom() {
  49864. return this.options.previewerDom;
  49865. }
  49866. /**
  49867. * 获取预览区内的html内容
  49868. * @param {boolean} wrapTheme 是否在外层包裹主题class
  49869. * @returns html内容
  49870. */
  49871. }, {
  49872. key: "getValue",
  49873. value: function getValue() {
  49874. var _context3, _context4;
  49875. var wrapTheme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  49876. var html = '';
  49877. if (this.isPreviewerHidden()) {
  49878. html = this.options.previewerCache.html;
  49879. } else {
  49880. html = this.getDomContainer().innerHTML;
  49881. } // 需要未加载的图片替换成原始图片
  49882. html = this.lazyLoadImg.changeDataSrc2Src(html);
  49883. if (!wrapTheme || !this.$cherry.wrapperDom) {
  49884. return html;
  49885. }
  49886. var inlineCodeTheme = this.$cherry.wrapperDom.getAttribute('data-inline-code-theme');
  49887. var codeBlockTheme = this.$cherry.wrapperDom.getAttribute('data-code-block-theme');
  49888. return concat$5(_context3 = concat$5(_context4 = "<div data-inline-code-theme=\"".concat(inlineCodeTheme, "\" data-code-block-theme=\"")).call(_context4, codeBlockTheme, "\">")).call(_context3, html, "</div>");
  49889. }
  49890. }, {
  49891. key: "isPreviewerHidden",
  49892. value: function isPreviewerHidden() {
  49893. return this.options.previewerDom.classList.contains('cherry-previewer--hidden');
  49894. }
  49895. }, {
  49896. key: "calculateRealLayout",
  49897. value: function calculateRealLayout(editorWidth) {
  49898. // 根据editor的绝对宽度计算editor和previewer的百分比宽度
  49899. var editorDomWidth = this.editor.options.editorDom.getBoundingClientRect().width;
  49900. var previewerDomWidth = this.options.previewerDom.getBoundingClientRect().width;
  49901. var totalWidth = editorDomWidth + previewerDomWidth;
  49902. var editorPercentage = +(editorWidth / totalWidth).toFixed(3);
  49903. if (editorPercentage < this.options.minBlockPercentage) {
  49904. editorPercentage = +this.options.minBlockPercentage.toFixed(3);
  49905. } else if (editorPercentage > 1 - this.options.minBlockPercentage) {
  49906. editorPercentage = +(1 - this.options.minBlockPercentage).toFixed(3);
  49907. }
  49908. var previewerPercentage = +(1 - editorPercentage).toFixed(3);
  49909. var res = {
  49910. editorPercentage: "".concat(editorPercentage * 100, "%"),
  49911. previewerPercentage: "".concat(previewerPercentage * 100, "%")
  49912. };
  49913. return res;
  49914. }
  49915. }, {
  49916. key: "setRealLayout",
  49917. value: function setRealLayout(editorPercentage, previewerPercentage) {
  49918. // 主动设置editor,previewer宽度,按百分比计算
  49919. var $editorPercentage = editorPercentage;
  49920. var $previewerPercentage = previewerPercentage;
  49921. if (!$editorPercentage || !$previewerPercentage) {
  49922. $editorPercentage = '50%';
  49923. $previewerPercentage = '50%';
  49924. }
  49925. this.editor.options.editorDom.style.width = $editorPercentage;
  49926. this.options.previewerDom.style.width = $previewerPercentage;
  49927. this.syncVirtualLayoutFromReal();
  49928. }
  49929. }, {
  49930. key: "syncVirtualLayoutFromReal",
  49931. value: function syncVirtualLayoutFromReal() {
  49932. // 通过editor和previewer的百分比宽度,同步更新mask和dragLine的px宽度及位置
  49933. var editorPos = this.editor.options.editorDom.getBoundingClientRect();
  49934. var previewerPos = this.options.previewerDom.getBoundingClientRect();
  49935. var editorHeight = editorPos.height;
  49936. var editorTop = this.editor.options.editorDom.offsetTop;
  49937. var editorLeft = editorPos.left;
  49938. var editorWidth = editorPos.width;
  49939. var previewerLeft = previewerPos.left ? previewerPos.left - editorLeft : 0;
  49940. var previewerWidth = previewerPos.width || 0;
  49941. var _this$options = this.options,
  49942. editorMaskDom = _this$options.editorMaskDom,
  49943. previewerMaskDom = _this$options.previewerMaskDom,
  49944. virtualLineDom = _this$options.virtualDragLineDom;
  49945. virtualLineDom.style.top = "".concat(editorTop, "px");
  49946. virtualLineDom.style.left = "".concat(previewerLeft, "px");
  49947. virtualLineDom.style.bottom = '0px';
  49948. editorMaskDom.style.height = "".concat(editorHeight, "px");
  49949. editorMaskDom.style.top = "".concat(editorTop, "px");
  49950. editorMaskDom.style.left = '0px';
  49951. editorMaskDom.style.width = "".concat(editorWidth, "px");
  49952. previewerMaskDom.style.height = "".concat(editorHeight, "px");
  49953. previewerMaskDom.style.top = "".concat(editorTop, "px");
  49954. previewerMaskDom.style.left = "".concat(previewerLeft, "px");
  49955. previewerMaskDom.style.width = "".concat(previewerWidth, "px");
  49956. }
  49957. }, {
  49958. key: "calculateVirtualLayout",
  49959. value: function calculateVirtualLayout(editorLeft, editorRight) {
  49960. // 计算mask和dragline应处在的位置,按px计算
  49961. var editorDomWidth = this.editor.options.editorDom.getBoundingClientRect().width;
  49962. var previewerDomWidth = this.options.previewerDom.getBoundingClientRect().width;
  49963. var totalWidth = editorDomWidth + previewerDomWidth;
  49964. var startWidth = editorLeft.toFixed(0);
  49965. var leftWidth = editorRight - editorLeft;
  49966. if (leftWidth < totalWidth * this.options.minBlockPercentage) {
  49967. leftWidth = +(totalWidth * this.options.minBlockPercentage).toFixed(0);
  49968. } else if (leftWidth > totalWidth * (1 - this.options.minBlockPercentage)) {
  49969. leftWidth = +(totalWidth * (1 - this.options.minBlockPercentage)).toFixed(0);
  49970. }
  49971. var rightWidth = totalWidth - leftWidth;
  49972. var ret = {
  49973. startWidth: _parseInt$2(startWidth, 10),
  49974. // 起始位置(左侧留白)
  49975. leftWidth: leftWidth,
  49976. // 左侧mask宽度
  49977. rightWidth: rightWidth // 右侧mask宽度
  49978. };
  49979. return ret;
  49980. }
  49981. }, {
  49982. key: "setVirtualLayout",
  49983. value: function setVirtualLayout(startWidth, leftWidth, rightWidth) {
  49984. // 主动设置mask和dragLine位置,按px计算
  49985. var _this$options2 = this.options,
  49986. editorMaskDom = _this$options2.editorMaskDom,
  49987. previewerMaskDom = _this$options2.previewerMaskDom,
  49988. virtualLineDom = _this$options2.virtualDragLineDom;
  49989. var $startWidth = 0; // =startWidth
  49990. editorMaskDom.style.left = "".concat($startWidth, "px");
  49991. editorMaskDom.style.width = "".concat(leftWidth, "px");
  49992. virtualLineDom.style.left = "".concat($startWidth + leftWidth, "px");
  49993. previewerMaskDom.style.left = "".concat($startWidth + leftWidth, "px");
  49994. previewerMaskDom.style.width = "".concat(rightWidth, "px");
  49995. }
  49996. }, {
  49997. key: "bindDrag",
  49998. value: function bindDrag() {
  49999. var _this = this,
  50000. _context5;
  50001. var dragLineMouseMove = function dragLineMouseMove(mouseMoveEvent) {
  50002. // 阻止事件冒泡
  50003. if (mouseMoveEvent && mouseMoveEvent.stopPropagation) {
  50004. mouseMoveEvent.stopPropagation();
  50005. } else {
  50006. mouseMoveEvent.cancelBubble = true;
  50007. } // 取消默认事件
  50008. if (mouseMoveEvent.preventDefault) {
  50009. mouseMoveEvent.preventDefault();
  50010. } else {
  50011. window.event.returnValue = false;
  50012. }
  50013. var editorLeft = _this.editor.options.editorDom.getBoundingClientRect().left;
  50014. var editorRight = mouseMoveEvent.clientX;
  50015. var virtualLayout = _this.calculateVirtualLayout(editorLeft, editorRight);
  50016. _this.setVirtualLayout(virtualLayout.startWidth, virtualLayout.leftWidth, virtualLayout.rightWidth);
  50017. return false;
  50018. };
  50019. var dragLineMouseUp = function dragLineMouseUp(mouseUpEvent) {
  50020. // 阻止事件冒泡
  50021. if (mouseUpEvent && mouseUpEvent.stopPropagation) {
  50022. mouseUpEvent.stopPropagation();
  50023. } else {
  50024. mouseUpEvent.cancelBubble = true;
  50025. } // 取消默认事件
  50026. if (mouseUpEvent.preventDefault) {
  50027. mouseUpEvent.preventDefault();
  50028. } else {
  50029. window.event.returnValue = false;
  50030. } // 重新设置editor和previewer宽度占比
  50031. var editorLeft = _this.editor.options.editorDom.getBoundingClientRect().left;
  50032. var editorRight = mouseUpEvent.clientX;
  50033. var layout = _this.calculateRealLayout(editorRight - editorLeft);
  50034. _this.setRealLayout(layout.editorPercentage, layout.previewerPercentage); // 去掉蒙层和虚拟拖动条
  50035. _this.editor.options.editorDom.classList.remove('no-select');
  50036. _this.options.previewerDom.classList.remove('no-select');
  50037. _this.options.editorMaskDom.classList.remove('cherry-editor-mask--show');
  50038. _this.options.previewerMaskDom.classList.remove('cherry-previewer-mask--show');
  50039. _this.options.virtualDragLineDom.classList.remove('cherry-drag--show'); // 刷新codemirror宽度
  50040. _this.editor.editor.refresh(); // 取消事件绑定
  50041. removeEvent(document, 'mousemove', dragLineMouseMove, false);
  50042. removeEvent(document, 'mouseup', dragLineMouseUp, false);
  50043. return false;
  50044. };
  50045. var dragLineMouseDown = function dragLineMouseDown(mouseDownEvent) {
  50046. // 阻止事件冒泡
  50047. if (mouseDownEvent && mouseDownEvent.stopPropagation) {
  50048. mouseDownEvent.stopPropagation();
  50049. } else {
  50050. mouseDownEvent.cancelBubble = true;
  50051. } // 取消默认事件
  50052. if (mouseDownEvent.preventDefault) {
  50053. mouseDownEvent.preventDefault();
  50054. } else {
  50055. window.event.returnValue = false;
  50056. }
  50057. _this.syncVirtualLayoutFromReal();
  50058. var editorLeft = _this.editor.options.editorDom.getBoundingClientRect().left;
  50059. var editorRight = mouseDownEvent.clientX;
  50060. var virtualLayout = _this.calculateVirtualLayout(editorLeft, editorRight);
  50061. _this.setVirtualLayout(virtualLayout.startWidth, virtualLayout.leftWidth, virtualLayout.rightWidth);
  50062. if (!_this.options.virtualDragLineDom.classList.contains('cherry-drag--show')) {
  50063. // 增加蒙层防止选中editor或previewer内容
  50064. _this.options.virtualDragLineDom.classList.add('cherry-drag--show');
  50065. _this.options.editorMaskDom.classList.add('cherry-editor-mask--show');
  50066. _this.options.previewerMaskDom.classList.add('cherry-previewer-mask--show');
  50067. _this.options.previewerDom.classList.add('no-select');
  50068. _this.editor.options.editorDom.classList.add('no-select'); // 绑定事件
  50069. addEvent(document, 'mousemove', dragLineMouseMove, false);
  50070. addEvent(document, 'mouseup', dragLineMouseUp, false);
  50071. }
  50072. return false;
  50073. };
  50074. addEvent(this.options.virtualDragLineDom, 'mousedown', dragLineMouseDown, false);
  50075. addEvent(window, 'resize', bind$5(_context5 = this.syncVirtualLayoutFromReal).call(_context5, this), false);
  50076. this.setRealLayout();
  50077. }
  50078. }, {
  50079. key: "bindScroll",
  50080. value: function bindScroll() {
  50081. var _this2 = this;
  50082. var domContainer = this.getDomContainer();
  50083. onScroll = function onScroll() {
  50084. if (_this2.applyingDomChanges) {
  50085. // Logger.log(new Date(), 'sync scroll locked');
  50086. return;
  50087. }
  50088. if (_this2.disableScrollListener) {
  50089. _this2.disableScrollListener = false;
  50090. return;
  50091. }
  50092. if (domContainer.scrollTop <= 0) {
  50093. _this2.editor.scrollToLineNum(0, 0, 1);
  50094. return;
  50095. } // 判定预览区域是否滚动到底部的逻辑,增加10px的冗余
  50096. if (domContainer.scrollTop + domContainer.offsetHeight + 10 > domContainer.scrollHeight) {
  50097. _this2.editor.scrollToLineNum(null);
  50098. return;
  50099. } // 获取预览容器基准坐标
  50100. var basePoint = domContainer.getBoundingClientRect(); // 观察点坐标,取容器中轴线
  50101. var watchPoint = {
  50102. x: basePoint.left + basePoint.width / 2,
  50103. y: basePoint.top + 1
  50104. }; // 获取观察点处的DOM
  50105. var targetElements = elementsFromPoint(watchPoint.x, watchPoint.y);
  50106. var targetElement;
  50107. for (var i = 0; i < targetElements.length; i++) {
  50108. if (domContainer.contains(targetElements[i])) {
  50109. targetElement = targetElements[i];
  50110. break;
  50111. }
  50112. }
  50113. if (!targetElement || targetElement === domContainer) {
  50114. return;
  50115. } // 获取观察点处最近的markdown元素
  50116. var mdElement = targetElement.closest('[data-sign]'); // 由于新增脚注,内部容器也有可能存在data-sign,所以需要循环往父级找
  50117. while (mdElement && mdElement.parentElement && mdElement.parentElement !== domContainer) {
  50118. mdElement = mdElement.parentElement.closest('[data-sign]');
  50119. }
  50120. if (!mdElement) {
  50121. return;
  50122. } // 计算当前焦点容器的所在行数
  50123. var lines = 0;
  50124. var element = mdElement;
  50125. while (element) {
  50126. lines += +element.getAttribute('data-lines');
  50127. element = element.previousElementSibling; // 取上一个兄弟节点,直到为null
  50128. } // markdown元素存在margin,getBoundingRect不能获取到margin
  50129. var mdElementStyle = getComputedStyle(mdElement);
  50130. var marginTop = _parseFloat$2(mdElementStyle.marginTop);
  50131. var marginBottom = _parseFloat$2(mdElementStyle.marginBottom); // markdown元素基于当前页面的矩形模型
  50132. var mdRect = mdElement.getBoundingClientRect();
  50133. var mdActualHeight = mdRect.height + marginTop + marginBottom; // (mdRect.y - marginTop)为顶部触达区域,basePoint.y为预览区域的顶部,故可视范围应减去预览区域的偏移
  50134. var mdOffsetTop = mdRect.y - marginTop - basePoint.y;
  50135. var lineNum = +mdElement.getAttribute('data-lines'); // 当前markdown元素所占行数
  50136. var percent = 100 * Math.abs(mdOffsetTop) / mdActualHeight / 100; // console.log('destLine:', lines, percent,
  50137. // mdRect.height + marginTop + marginBottom, mdOffsetTop, mdElement);
  50138. // if(mdOffsetTop < 0) {
  50139. return _this2.editor.scrollToLineNum(lines - lineNum, lineNum, percent); // }
  50140. // return this.editor.scrollToLineNum(lines - lineNum, 0, 0);
  50141. };
  50142. addEvent(domContainer, 'scroll', onScroll, false);
  50143. addEvent(domContainer, 'wheel', function () {
  50144. // 鼠标滚轮滚动时,强制监听滚动事件
  50145. _this2.disableScrollListener = false; // 打断滚动动画
  50146. cancelAnimationFrame(_this2.animation.timer);
  50147. _this2.animation.timer = 0;
  50148. }, false);
  50149. }
  50150. }, {
  50151. key: "removeScroll",
  50152. value: function removeScroll() {
  50153. var domContainer = this.getDomContainer();
  50154. removeEvent(domContainer, 'scroll', onScroll, false);
  50155. }
  50156. }, {
  50157. key: "$html2H",
  50158. value: function $html2H(dom) {
  50159. if (typeof dom === 'undefined') {
  50160. return h_1('span', {}, []);
  50161. }
  50162. if (!dom.tagName) {
  50163. return dom.textContent;
  50164. }
  50165. var tagName = dom.tagName; // skip all children if data-cm-atomic attribute is set
  50166. var isAtomic = 'true' === dom.getAttribute('data-cm-atomic');
  50167. var myAttrs = this.$getAttrsForH(dom.attributes);
  50168. var children = [];
  50169. if (!isAtomic && dom.childNodes && dom.childNodes.length > 0) {
  50170. for (var i = 0; i < dom.childNodes.length; i++) {
  50171. children.push(this.$html2H(dom.childNodes[i]));
  50172. }
  50173. }
  50174. return h_1(tagName, myAttrs, children);
  50175. }
  50176. }, {
  50177. key: "$getAttrsForH",
  50178. value: function $getAttrsForH(obj) {
  50179. if (!obj) {
  50180. return {};
  50181. }
  50182. var ret = {
  50183. dataset: {}
  50184. };
  50185. for (var i = 0; i < obj.length; i++) {
  50186. var name = obj[i].name;
  50187. var value = obj[i].value;
  50188. if (/^(width|height)$/i.test(name)) {
  50189. if (isNaN(value)) {
  50190. var _context6;
  50191. ret.style = ret.style ? ret.style : [];
  50192. ret.style.push(concat$5(_context6 = "".concat(name, ":")).call(_context6, value));
  50193. continue;
  50194. }
  50195. }
  50196. if (/^(class|id|href|rel|target|src|title|controls|align|width|height|style|open)$/i.test(name)) {
  50197. name = name === 'class' ? 'className' : name;
  50198. if (name === 'style') {
  50199. ret.style = ret.style ? ret.style : [];
  50200. ret.style.push(value);
  50201. } else if (name === 'open') {
  50202. // 只要有open这个属性,就一定是true
  50203. ret[name] = true;
  50204. } else {
  50205. ret[name] = value;
  50206. }
  50207. } else {
  50208. // jsDom属性里面rowspan的S要大写,否则应用到html的dom节点会变成data-rowspan
  50209. // https://stackoverflow.com/q/29774686
  50210. if ('colspan' === name) {
  50211. name = 'colSpan';
  50212. } else if ('rowspan' === name) {
  50213. name = 'rowSpan';
  50214. }
  50215. if (/^data-/i.test(name)) {
  50216. name = name.replace(/^data-/i, '');
  50217. } else {
  50218. ret[name] = value;
  50219. }
  50220. ret.dataset[name] = value;
  50221. }
  50222. }
  50223. if (ret.style) {
  50224. ret.style = {
  50225. cssText: ret.style.join(';')
  50226. }; // see virtual-dom implementation
  50227. }
  50228. return ret;
  50229. }
  50230. }, {
  50231. key: "$updateDom",
  50232. value: function $updateDom(newDom, oldDom) {
  50233. var diff = diff_1$1(this.$html2H(oldDom), this.$html2H(newDom));
  50234. return patch_1$1(oldDom, diff);
  50235. }
  50236. }, {
  50237. key: "$testChild",
  50238. value: function $testChild(dom) {
  50239. if (!dom.parentNode) {
  50240. return true;
  50241. }
  50242. if (dom.parentNode.classList.contains('cherry-previewer')) {
  50243. return true;
  50244. }
  50245. if (dom.parentNode.getAttribute('data-sign')) {
  50246. return false;
  50247. }
  50248. return this.$testChild(dom.parentNode);
  50249. }
  50250. }, {
  50251. key: "_testMaxIndex",
  50252. value: function _testMaxIndex(index, arr) {
  50253. if (!arr) {
  50254. return false;
  50255. }
  50256. for (var i = 0; i < arr.length; i++) {
  50257. if (index <= arr[i]) {
  50258. return true;
  50259. }
  50260. }
  50261. return false;
  50262. }
  50263. }, {
  50264. key: "$getSignData",
  50265. value: function $getSignData(dom) {
  50266. var list = dom.querySelectorAll('[data-sign]');
  50267. var ret = {
  50268. list: [],
  50269. signs: {}
  50270. };
  50271. for (var i = 0; i < list.length; i++) {
  50272. if (!this.$testChild(list[i])) {
  50273. continue;
  50274. }
  50275. var sign = list[i].getAttribute('data-sign');
  50276. ret.list.push({
  50277. sign: sign,
  50278. dom: list[i]
  50279. });
  50280. if (!ret.signs[sign]) {
  50281. ret.signs[sign] = [];
  50282. }
  50283. ret.signs[sign].push(i);
  50284. }
  50285. return ret;
  50286. }
  50287. }, {
  50288. key: "_hasNewSign",
  50289. value: function _hasNewSign(list, sign, signIndex) {
  50290. if (list.length > 0) {
  50291. var resSign;
  50292. forEach$3(list).call(list, function (listItem, i) {
  50293. var _context7;
  50294. // hash精度校准
  50295. if (slice$7(_context7 = listItem.sign).call(_context7, 0, 12) === slice$7(sign).call(sign, 0, 12) && i > signIndex) {
  50296. resSign = {
  50297. index: i > signIndex ? i : signIndex,
  50298. sign: sign
  50299. };
  50300. }
  50301. });
  50302. return resSign;
  50303. }
  50304. return false;
  50305. }
  50306. }, {
  50307. key: "$dealWithMyersDiffResult",
  50308. value: function $dealWithMyersDiffResult(result, oldContent, newContent, domContainer) {
  50309. var _this3 = this;
  50310. forEach$3(result).call(result, function (change) {
  50311. if (newContent[change.newIndex].dom) {
  50312. // 把已经加载过的图片的data-src变成src
  50313. newContent[change.newIndex].dom.innerHTML = _this3.lazyLoadImg.changeLoadedDataSrc2Src(newContent[change.newIndex].dom.innerHTML);
  50314. }
  50315. switch (change.type) {
  50316. case 'delete':
  50317. domContainer.removeChild(oldContent[change.oldIndex].dom);
  50318. break;
  50319. case 'insert':
  50320. if (oldContent[change.oldIndex]) {
  50321. domContainer.insertBefore(newContent[change.newIndex].dom, oldContent[change.oldIndex].dom);
  50322. } else {
  50323. domContainer.appendChild(newContent[change.newIndex].dom);
  50324. }
  50325. break;
  50326. case 'update':
  50327. try {
  50328. if (newContent[change.newIndex].dom.querySelector('svg')) {
  50329. throw new Error(); // SVG暂不使用patch更新
  50330. }
  50331. _this3.$updateDom(newContent[change.newIndex].dom, oldContent[change.oldIndex].dom);
  50332. } catch (e) {
  50333. domContainer.insertBefore(newContent[change.newIndex].dom, oldContent[change.oldIndex].dom);
  50334. domContainer.removeChild(oldContent[change.oldIndex].dom);
  50335. }
  50336. }
  50337. });
  50338. }
  50339. }, {
  50340. key: "$dealUpdate",
  50341. value: function $dealUpdate(domContainer, oldHtmlList, newHtmlList) {
  50342. if (newHtmlList.list !== oldHtmlList.list) {
  50343. if (newHtmlList.list.length && oldHtmlList.list.length) {
  50344. var myersDiff = new MyersDiff(newHtmlList.list, oldHtmlList.list, function (obj, index) {
  50345. return obj[index].sign;
  50346. });
  50347. var res = myersDiff.doDiff();
  50348. // Logger.log(res);
  50349. this.$dealWithMyersDiffResult(res, oldHtmlList.list, newHtmlList.list, domContainer);
  50350. } else if (newHtmlList.list.length && !oldHtmlList.list.length) {
  50351. var _context8;
  50352. // 全新增
  50353. // Logger.log('add all');
  50354. forEach$3(_context8 = newHtmlList.list).call(_context8, function (piece) {
  50355. domContainer.appendChild(piece.dom);
  50356. });
  50357. } else if (!newHtmlList.list.length && oldHtmlList.list.length) {
  50358. var _context9;
  50359. // 全删除
  50360. // Logger.log('delete all');
  50361. forEach$3(_context9 = oldHtmlList.list).call(_context9, function (piece) {
  50362. domContainer.removeChild(piece.dom);
  50363. });
  50364. }
  50365. }
  50366. }
  50367. /**
  50368. * 强制重新渲染预览区域
  50369. */
  50370. }, {
  50371. key: "refresh",
  50372. value: function refresh(html) {
  50373. var domContainer = this.getDomContainer();
  50374. domContainer.innerHTML = html;
  50375. }
  50376. }, {
  50377. key: "update",
  50378. value: function update(html) {
  50379. var _this4 = this;
  50380. // 更新时保留图片懒加载逻辑
  50381. var newHtml = this.lazyLoadImg.changeSrc2DataSrc(html);
  50382. if (!this.isPreviewerHidden()) {
  50383. // 标记当前正在更新预览区域,锁定同步滚动功能
  50384. window.clearTimeout(this.syncScrollLockTimer);
  50385. this.applyingDomChanges = true; // 预览区未隐藏时,直接更新
  50386. var tmpDiv = document.createElement('div');
  50387. var domContainer = this.getDomContainer();
  50388. tmpDiv.innerHTML = newHtml;
  50389. var newHtmlList = this.$getSignData(tmpDiv);
  50390. var oldHtmlList = this.$getSignData(domContainer);
  50391. try {
  50392. this.$dealUpdate(domContainer, oldHtmlList, newHtmlList);
  50393. this.afterUpdate();
  50394. } finally {
  50395. // 延时释放同步滚动功能,在DOM更新完成后执行
  50396. this.syncScrollLockTimer = setTimeout$3(function () {
  50397. _this4.applyingDomChanges = false;
  50398. }, 50);
  50399. }
  50400. } else {
  50401. // 预览区隐藏时,先缓存起来,等到预览区打开再一次性更新
  50402. this.doHtmlCache(newHtml);
  50403. }
  50404. }
  50405. }, {
  50406. key: "$dealEditAndPreviewOnly",
  50407. value: function $dealEditAndPreviewOnly() {
  50408. var _this5 = this;
  50409. var isEditOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  50410. var fullEditorLayout = {
  50411. editorPercentage: '0%',
  50412. previewerPercentage: '100%'
  50413. };
  50414. if (isEditOnly) {
  50415. fullEditorLayout = {
  50416. editorPercentage: '100%',
  50417. previewerPercentage: '0%'
  50418. };
  50419. }
  50420. var editorWidth = this.editor.options.editorDom.getBoundingClientRect().width;
  50421. var layout = this.calculateRealLayout(editorWidth);
  50422. this.options.previewerCache.layout = layout;
  50423. this.setRealLayout(fullEditorLayout.editorPercentage, fullEditorLayout.previewerPercentage);
  50424. this.options.virtualDragLineDom.classList.add('cherry-drag--hidden');
  50425. var previewerDom = this.options.previewerDom;
  50426. var editorDom = this.editor.options.editorDom;
  50427. if (isEditOnly) {
  50428. previewerDom.classList.add('cherry-previewer--hidden');
  50429. editorDom.classList.add('cherry-editor--full');
  50430. previewerDom.classList.remove('cherry-preview--full');
  50431. editorDom.classList.remove('cherry-editor--hidden');
  50432. } else {
  50433. previewerDom.classList.add('cherry-preview--full');
  50434. editorDom.classList.add('cherry-editor--hidden');
  50435. previewerDom.classList.remove('cherry-previewer--hidden');
  50436. editorDom.classList.remove('cherry-editor--full');
  50437. }
  50438. setTimeout$3(function () {
  50439. return _this5.editor.editor.refresh();
  50440. }, 0);
  50441. }
  50442. }, {
  50443. key: "previewOnly",
  50444. value: function previewOnly() {
  50445. this.$dealEditAndPreviewOnly(false);
  50446. if (this.options.previewerCache.htmlChanged) {
  50447. this.update(this.options.previewerCache.html);
  50448. }
  50449. this.cleanHtmlCache();
  50450. Event$1.emit(this.instanceId, Event$1.Events.previewerOpen);
  50451. Event$1.emit(this.instanceId, Event$1.Events.editorClose);
  50452. }
  50453. }, {
  50454. key: "editOnly",
  50455. value: function editOnly() {
  50456. this.$dealEditAndPreviewOnly(true);
  50457. this.cleanHtmlCache();
  50458. Event$1.emit(this.instanceId, Event$1.Events.previewerClose);
  50459. Event$1.emit(this.instanceId, Event$1.Events.editorOpen);
  50460. }
  50461. }, {
  50462. key: "recoverPreviewer",
  50463. value: function recoverPreviewer() {
  50464. var _this6 = this;
  50465. this.options.previewerDom.classList.remove('cherry-previewer--hidden');
  50466. this.options.virtualDragLineDom.classList.remove('cherry-drag--hidden');
  50467. this.editor.options.editorDom.classList.remove('cherry-editor--full'); // 恢复现场
  50468. if (this.options.previewerCache.layout !== {}) {
  50469. var layout = this.options.previewerCache.layout;
  50470. this.setRealLayout(layout.editorPercentage, layout.previewerPercentage);
  50471. }
  50472. if (this.options.previewerCache.htmlChanged) {
  50473. this.update(this.options.previewerCache.html);
  50474. }
  50475. this.cleanHtmlCache();
  50476. Event$1.emit(this.instanceId, Event$1.Events.previewerOpen);
  50477. Event$1.emit(this.instanceId, Event$1.Events.editorOpen);
  50478. setTimeout$3(function () {
  50479. return _this6.editor.editor.refresh();
  50480. }, 0);
  50481. }
  50482. }, {
  50483. key: "doHtmlCache",
  50484. value: function doHtmlCache(html) {
  50485. this.options.previewerCache.html = html;
  50486. this.options.previewerCache.htmlChanged = true;
  50487. }
  50488. }, {
  50489. key: "cleanHtmlCache",
  50490. value: function cleanHtmlCache() {
  50491. this.options.previewerCache.html = '';
  50492. this.options.previewerCache.htmlChanged = false;
  50493. this.options.previewerCache.layout = {};
  50494. }
  50495. }, {
  50496. key: "afterUpdate",
  50497. value: function afterUpdate() {
  50498. var _context10;
  50499. map$3(_context10 = this.options.afterUpdateCallBack).call(_context10, function (fn) {
  50500. return fn();
  50501. });
  50502. if (this.highlightLineNum === undefined) {
  50503. this.highlightLineNum = 0;
  50504. }
  50505. this.highlightLine(this.highlightLineNum);
  50506. }
  50507. }, {
  50508. key: "registerAfterUpdate",
  50509. value: function registerAfterUpdate(fn) {
  50510. if (isArray$8(fn)) {
  50511. var _context11;
  50512. this.options.afterUpdateCallBack = concat$5(_context11 = this.options.afterUpdateCallBack).call(_context11, fn);
  50513. } else if (!fn) {
  50514. throw new Error('[markdown error]: Previewer registerAfterUpdate params are undefined');
  50515. } else {
  50516. this.options.afterUpdateCallBack.push(fn);
  50517. }
  50518. }
  50519. /**
  50520. * 根据行号计算出top值
  50521. * @param {Number} lineNum
  50522. * @param {Number} linePercent
  50523. * @return {Number} top
  50524. */
  50525. }, {
  50526. key: "$getTopByLineNum",
  50527. value: function $getTopByLineNum(lineNum) {
  50528. var linePercent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  50529. var domContainer = this.getDomContainer();
  50530. if (lineNum === null) {
  50531. return domContainer.scrollHeight;
  50532. }
  50533. var $lineNum = typeof lineNum === 'number' ? lineNum : _parseInt$2(lineNum, 10);
  50534. var doms =
  50535. /** @type {NodeListOf<HTMLElement>}*/
  50536. domContainer.querySelectorAll('[data-sign]');
  50537. var lines = 0;
  50538. var containerY = domContainer.offsetTop;
  50539. for (var index = 0; index < doms.length; index++) {
  50540. if (doms[index].parentNode !== domContainer) {
  50541. continue;
  50542. }
  50543. var blockLines = _parseInt$2(doms[index].getAttribute('data-lines'), 10);
  50544. if (lines + blockLines < $lineNum) {
  50545. lines += blockLines;
  50546. continue;
  50547. } else {
  50548. // 基础定位,区块高度及offsetTop会受到block margin合并的影响
  50549. var _getBlockTopAndHeight = getBlockTopAndHeightWithMargin(doms[index]),
  50550. blockHeight = _getBlockTopAndHeight.height,
  50551. offsetTop = _getBlockTopAndHeight.offsetTop;
  50552. var blockY = offsetTop - containerY;
  50553. var scrollTo = blockY + blockHeight * linePercent; // 区块多于1行
  50554. if (blockLines > 1) {
  50555. // 高度百分比计算
  50556. // 该区块已经滚动过的行,不包括当前行,减一
  50557. var overScrolledLines = blockLines - Math.abs($lineNum - (lines + blockLines)) - 1;
  50558. var overScrolledHeight = overScrolledLines / blockLines * blockHeight; // 已经滚过的高度
  50559. var blockLineHeight = blockHeight / blockLines; // 该区块每一行的高度
  50560. // 应该滚动到的位置
  50561. scrollTo = blockY + overScrolledHeight + blockLineHeight * linePercent; // console.log('overscrolled:', overScrolledHeight, blockLineHeight, linePercent);
  50562. } // console.log('滚动编辑区域,左侧应scroll to ', lineNum, '::',scrollTo);
  50563. return scrollTo;
  50564. }
  50565. } // 如果计算完预览区域所有的行号依然<左侧光标所在的行号,则预览区域直接滚到最低部
  50566. return domContainer.scrollHeight;
  50567. }
  50568. /**
  50569. * 高亮预览区域对应的行
  50570. * @param {Number} lineNum
  50571. */
  50572. }, {
  50573. key: "highlightLine",
  50574. value: function highlightLine(lineNum) {
  50575. var _context12, _this$$cherry, _this$$cherry$status, _this$$cherry2, _this$$cherry2$status;
  50576. var domContainer = this.getDomContainer(); // 先取消所有行的高亮效果
  50577. forEach$3(_context12 = domContainer.querySelectorAll('.cherry-highlight-line')).call(_context12, function (element) {
  50578. element.classList.remove('cherry-highlight-line');
  50579. }); // 只有双栏模式下才需要高亮光标对应的预览区域
  50580. if (((_this$$cherry = this.$cherry) === null || _this$$cherry === void 0 ? void 0 : (_this$$cherry$status = _this$$cherry.status) === null || _this$$cherry$status === void 0 ? void 0 : _this$$cherry$status.previewer) !== 'show' || ((_this$$cherry2 = this.$cherry) === null || _this$$cherry2 === void 0 ? void 0 : (_this$$cherry2$status = _this$$cherry2.status) === null || _this$$cherry2$status === void 0 ? void 0 : _this$$cherry2$status.editor) !== 'show') {
  50581. return;
  50582. }
  50583. var doms =
  50584. /** @type {NodeListOf<HTMLElement>}*/
  50585. domContainer.querySelectorAll('[data-sign]');
  50586. var lines = 0;
  50587. for (var index = 0; index < doms.length; index++) {
  50588. if (doms[index].parentNode !== domContainer) {
  50589. continue;
  50590. }
  50591. var blockLines = _parseInt$2(doms[index].getAttribute('data-lines'), 10);
  50592. if (lines + blockLines < lineNum) {
  50593. lines += blockLines;
  50594. continue;
  50595. } else {
  50596. this.highlightLineNum = lineNum;
  50597. doms[index].classList.add('cherry-highlight-line');
  50598. return;
  50599. }
  50600. }
  50601. }
  50602. /**
  50603. * 滚动到对应行号位置并加上偏移量
  50604. * @param {Number} lineNum
  50605. * @param {Number} offset
  50606. */
  50607. }, {
  50608. key: "scrollToLineNumWithOffset",
  50609. value: function scrollToLineNumWithOffset(lineNum, offset) {
  50610. var top = this.$getTopByLineNum(lineNum) - offset;
  50611. this.$scrollAnimation(top);
  50612. this.highlightLine(lineNum);
  50613. }
  50614. /**
  50615. * 实现滚动动画
  50616. * @param { Number } targetY 目标位置
  50617. */
  50618. }, {
  50619. key: "$scrollAnimation",
  50620. value: function $scrollAnimation(targetY) {
  50621. var _this7 = this;
  50622. this.animation.destinationTop = targetY;
  50623. if (this.animation.timer) {
  50624. return;
  50625. }
  50626. var animationHandler = function animationHandler() {
  50627. var dom = _this7.getDomContainer();
  50628. var currentTop = dom.scrollTop;
  50629. var delta = _this7.animation.destinationTop - currentTop; // 100毫秒内完成动画
  50630. var move = Math.ceil(Math.min(Math.abs(delta), Math.max(1, Math.abs(delta) / (100 / 16.7))));
  50631. if (delta === 0 || currentTop >= dom.scrollHeight || move > Math.abs(delta)) {
  50632. cancelAnimationFrame(_this7.animation.timer);
  50633. _this7.animation.timer = 0;
  50634. return;
  50635. }
  50636. _this7.disableScrollListener = true;
  50637. _this7.getDomContainer().scrollTo(null, currentTop + delta / Math.abs(delta) * move);
  50638. _this7.animation.timer = requestAnimationFrame(animationHandler);
  50639. };
  50640. this.animation.timer = requestAnimationFrame(animationHandler);
  50641. }
  50642. }, {
  50643. key: "scrollToLineNum",
  50644. value: function scrollToLineNum(lineNum, linePercent) {
  50645. var top = this.$getTopByLineNum(lineNum, linePercent);
  50646. this.$scrollAnimation(top);
  50647. }
  50648. }, {
  50649. key: "onMouseDown",
  50650. value: function onMouseDown() {
  50651. var _this8 = this;
  50652. addEvent(this.getDomContainer(), 'mousedown', function () {
  50653. setTimeout$3(function () {
  50654. Event$1.emit(_this8.instanceId, Event$1.Events.cleanAllSubMenus);
  50655. });
  50656. });
  50657. }
  50658. /**
  50659. * 导出预览区域内容
  50660. * @public
  50661. * @param {String} type 'pdf':导出成pdf文件; 'img':导出成图片
  50662. * @param {String |Function} fileName 导出文件名
  50663. */
  50664. }, {
  50665. key: "export",
  50666. value: function _export() {
  50667. var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'pdf';
  50668. var fileName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  50669. // console.log(this.options);
  50670. var name;
  50671. if (!fileName) {
  50672. var parser = new DOMParser();
  50673. var domTree = parser.parseFromString(this.getValue(), 'text/html');
  50674. var firstNodeText = findNonEmptyNode(domTree);
  50675. firstNodeText ? name = firstNodeText : name = 'cherry';
  50676. } // if (typeof fileName === 'function') {
  50677. // name = fileName();
  50678. // } else {
  50679. // name = fileName;
  50680. // }
  50681. if (type === 'pdf') {
  50682. exportPDF(this.getDomContainer(), name);
  50683. } else if (type === 'screenShot') {
  50684. exportScreenShot(this.getDomContainer(), name);
  50685. } else if (type === 'markdown') {
  50686. exportMarkdownFile(this.$cherry.getMarkdown(), name);
  50687. } else if (type === 'html') {
  50688. exportHTMLFile(this.getValue(), name);
  50689. }
  50690. }
  50691. }]);
  50692. return Previewer;
  50693. }();
  50694. // Kludges for bugs and behavior differences that can't be feature
  50695. // detected are enabled based on userAgent etc sniffing.
  50696. var userAgent = navigator.userAgent;
  50697. var platform = navigator.platform;
  50698. var gecko = /gecko\/\d/i.test(userAgent);
  50699. var ie_upto10 = /MSIE \d/.test(userAgent);
  50700. var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
  50701. var edge = /Edge\/(\d+)/.exec(userAgent);
  50702. var ie = ie_upto10 || ie_11up || edge;
  50703. var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]);
  50704. var webkit = !edge && /WebKit\//.test(userAgent);
  50705. var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
  50706. var chrome = !edge && /Chrome\//.test(userAgent);
  50707. var presto = /Opera\//.test(userAgent);
  50708. var safari = /Apple Computer/.test(navigator.vendor);
  50709. var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
  50710. var phantom = /PhantomJS/.test(userAgent);
  50711. var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent);
  50712. var android = /Android/.test(userAgent); // This is woefully incomplete. Suggestions for alternative methods welcome.
  50713. var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
  50714. var mac = ios || /Mac/.test(platform);
  50715. var chromeOS = /\bCrOS\b/.test(userAgent);
  50716. var windows = /win/i.test(platform);
  50717. var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/);
  50718. if (presto_version) presto_version = Number(presto_version[1]);
  50719. if (presto_version && presto_version >= 15) {
  50720. presto = false;
  50721. webkit = true;
  50722. } // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
  50723. /**
  50724. * @typedef {Object} SubMenuConfigItem
  50725. * @property {string} name - 子菜单项名称
  50726. * @property {string=} iconName - 子菜单项图标名称
  50727. * @property {function} onclick - 子菜单项点击事件
  50728. */
  50729. /**
  50730. *
  50731. * @param {HTMLElement} targetDom
  50732. * @param {'absolute' | 'fixed' | 'sidebar'} [positionModel = 'absolute']
  50733. * @returns {Pick<DOMRect, 'left' | 'top' | 'width' | 'height'>}
  50734. */
  50735. function getPosition(targetDom) {
  50736. var positionModel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'absolute';
  50737. var pos = targetDom.getBoundingClientRect();
  50738. if (positionModel === 'fixed') {
  50739. return pos;
  50740. } // 侧边栏按钮做个特殊处理
  50741. if (positionModel === 'sidebar') {
  50742. var parent = MenuBase.getTargetParentByButton(targetDom);
  50743. return {
  50744. left: parent.offsetLeft - 130 + pos.width,
  50745. top: targetDom.offsetTop + pos.height / 2,
  50746. width: pos.width,
  50747. height: pos.height
  50748. };
  50749. }
  50750. return {
  50751. left: targetDom.offsetLeft,
  50752. top: targetDom.offsetTop,
  50753. width: pos.width,
  50754. height: pos.height
  50755. };
  50756. }
  50757. /**
  50758. * @typedef {import('@/Editor').default} Editor
  50759. */
  50760. /**
  50761. * @class MenuBase
  50762. */
  50763. var MenuBase = /*#__PURE__*/function () {
  50764. /**
  50765. * @deprecated
  50766. * @type {MenuBase['fire']}
  50767. */
  50768. /**
  50769. *
  50770. * @param {*} $cherry
  50771. */
  50772. function MenuBase($cherry) {
  50773. _classCallCheck(this, MenuBase);
  50774. _defineProperty(this, "_onClick", void 0);
  50775. this.$cherry = $cherry;
  50776. this.bubbleMenu = false;
  50777. this.subMenu = null; // 子菜单实例
  50778. this.name = ''; // 菜单项Name
  50779. this.editor = $cherry.editor; // markdown实例
  50780. this.locale = $cherry.locale;
  50781. this.dom = null;
  50782. this.updateMarkdown = true; // 是否更新markdown原文
  50783. /** @type {SubMenuConfigItem[]} */
  50784. this.subMenuConfig = []; // 子菜单配置
  50785. this.noIcon = false; // 是否不显示图标
  50786. this.cacheOnce = false; // 是否保存一次点击事件生成的内容
  50787. /**
  50788. * 子菜单的定位方式
  50789. * @property
  50790. * @type {'absolute' | 'fixed' | 'sidebar'}
  50791. */
  50792. this.positionModel = 'absolute'; // eslint-disable-next-line no-underscore-dangle
  50793. if (typeof this._onClick === 'function') {
  50794. Logger.warn('`MenuBase._onClick` is deprecated. Override `fire` instead'); // eslint-disable-next-line no-underscore-dangle
  50795. this.fire = this._onClick;
  50796. }
  50797. }
  50798. _createClass(MenuBase, [{
  50799. key: "getSubMenuConfig",
  50800. value: function getSubMenuConfig() {
  50801. return this.subMenuConfig;
  50802. }
  50803. /**
  50804. * 设置菜单
  50805. * @param {string} name 菜单名称
  50806. * @param {string} [iconName] 菜单图标名
  50807. */
  50808. }, {
  50809. key: "setName",
  50810. value: function setName(name, iconName) {
  50811. this.name = name;
  50812. this.iconName = iconName;
  50813. }
  50814. }, {
  50815. key: "setId",
  50816. value: function setId(id) {
  50817. this.id = id;
  50818. }
  50819. /**
  50820. * 设置一个一次性缓存
  50821. * 使用场景:
  50822. * 当需要异步操作是,比如上传视频、选择字体颜色、通过棋盘插入表格等
  50823. * 实现原理:
  50824. * 1、第一次点击按钮时触发fire()方法,触发选择文件、选择颜色、选择棋盘格的操作。此时onClick()不返回任何数据。
  50825. * 2、当异步操作完成后(如提交了文件、选择了颜色等),调用本方法(setCacheOnce)实现缓存,最后调用fire()方法
  50826. * 3、当fire()方法再次调用onClick()方法时,onClick()方法会返回缓存的数据(getAndCleanCacheOnce)
  50827. *
  50828. * 这么设计的原因:
  50829. * 1、可以复用MenuBase的相关方法
  50830. * 2、避免异步操作直接与codemirror交互
  50831. * @param {*} info
  50832. */
  50833. }, {
  50834. key: "setCacheOnce",
  50835. value: function setCacheOnce(info) {
  50836. this.cacheOnce = info;
  50837. }
  50838. }, {
  50839. key: "getAndCleanCacheOnce",
  50840. value: function getAndCleanCacheOnce() {
  50841. this.updateMarkdown = true;
  50842. var ret = this.cacheOnce;
  50843. this.cacheOnce = false;
  50844. return ret;
  50845. }
  50846. }, {
  50847. key: "hasCacheOnce",
  50848. value: function hasCacheOnce() {
  50849. return this.cacheOnce !== false;
  50850. }
  50851. /**
  50852. * 创建一个一级菜单
  50853. * @param {boolean} asSubMenu 是否以子菜单的形式创建
  50854. */
  50855. }, {
  50856. key: "createBtn",
  50857. value: function createBtn() {
  50858. var asSubMenu = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  50859. var classNames = asSubMenu ? 'cherry-dropdown-item' : "cherry-toolbar-button cherry-toolbar-".concat(this.iconName ? this.iconName : this.name);
  50860. var span = createElement('span', classNames, {
  50861. title: this.locale[this.name] || escapeHTMLSpecialCharOnce(this.name)
  50862. }); // 如果有图标,则添加图标
  50863. if (this.iconName && !this.noIcon) {
  50864. var icon = createElement('i', "ch-icon ch-icon-".concat(this.iconName));
  50865. span.appendChild(icon);
  50866. } // 二级菜单强制显示文字,没有图标的按钮也显示文字
  50867. if (this.id) {
  50868. span.id = this.id;
  50869. }
  50870. if (asSubMenu || this.noIcon) {
  50871. span.innerHTML += this.locale[this.name] || escapeHTMLSpecialCharOnce(this.name);
  50872. } // 只有一级菜单才保存dom,且只保存一次
  50873. if (!asSubMenu && !this.dom) {
  50874. this.dom = span;
  50875. }
  50876. return span;
  50877. }
  50878. }, {
  50879. key: "createSubBtnByConfig",
  50880. value: function createSubBtnByConfig(config) {
  50881. var name = config.name,
  50882. iconName = config.iconName,
  50883. id = config.id,
  50884. onclick = config.onclick;
  50885. var span = createElement('span', 'cherry-dropdown-item', {
  50886. title: this.locale[name] || escapeHTMLSpecialCharOnce(name)
  50887. });
  50888. if (iconName) {
  50889. var icon = createElement('i', "ch-icon ch-icon-".concat(iconName));
  50890. span.appendChild(icon);
  50891. }
  50892. if (id) {
  50893. span.id = id;
  50894. }
  50895. span.innerHTML += this.locale[name] || escapeHTMLSpecialCharOnce(name);
  50896. span.addEventListener('click', onclick, false);
  50897. return span;
  50898. }
  50899. /**
  50900. * 处理菜单项点击事件
  50901. * @param {MouseEvent | KeyboardEvent | undefined} [event] 点击事件
  50902. * @returns {void}
  50903. */
  50904. }, {
  50905. key: "fire",
  50906. value: function fire(event) {
  50907. var _this = this;
  50908. var shortKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  50909. event === null || event === void 0 ? void 0 : event.stopPropagation();
  50910. if (typeof this.onClick === 'function') {
  50911. var selections = this.editor.editor.getSelections(); // 判断是不是多选
  50912. this.isSelections = selections.length > 1; // 当onClick返回null、undefined、false时,维持原样
  50913. var ret = map$3(selections).call(selections, function (selection, index, srcArray) {
  50914. return _this.onClick(selection, shortKey, event) || srcArray[index];
  50915. });
  50916. if (!this.bubbleMenu && this.updateMarkdown) {
  50917. // 非下拉菜单按钮保留selection
  50918. this.editor.editor.replaceSelections(ret, 'around');
  50919. this.editor.editor.focus();
  50920. this.$afterClick();
  50921. }
  50922. }
  50923. }
  50924. /**
  50925. * 获取当前选择区域的range
  50926. */
  50927. }, {
  50928. key: "$getSelectionRange",
  50929. value: function $getSelectionRange() {
  50930. var _this$editor$editor$l = this.editor.editor.listSelections()[0],
  50931. anchor = _this$editor$editor$l.anchor,
  50932. head = _this$editor$editor$l.head; // 如果begin在end的后面
  50933. if (anchor.line === head.line && anchor.ch > head.ch || anchor.line > head.line) {
  50934. return {
  50935. begin: head,
  50936. end: anchor
  50937. };
  50938. }
  50939. return {
  50940. begin: anchor,
  50941. end: head
  50942. };
  50943. }
  50944. /**
  50945. * 注册点击事件渲染后的回调函数
  50946. * @param {function} cb
  50947. */
  50948. }, {
  50949. key: "registerAfterClickCb",
  50950. value: function registerAfterClickCb(cb) {
  50951. this.afterClickCb = cb;
  50952. }
  50953. /**
  50954. * 点击事件渲染后的回调函数
  50955. */
  50956. }, {
  50957. key: "$afterClick",
  50958. value: function $afterClick() {
  50959. if (typeof this.afterClickCb === 'function' && !this.isSelections) {
  50960. this.afterClickCb();
  50961. this.afterClickCb = null;
  50962. }
  50963. }
  50964. /**
  50965. * 选中除了前后语法后的内容
  50966. * @param {String} lessBefore
  50967. * @param {String} lessAfter
  50968. */
  50969. }, {
  50970. key: "setLessSelection",
  50971. value: function setLessSelection(lessBefore, lessAfter) {
  50972. var _lessBefore$match, _lessBefore$match2, _lessAfter$match, _lessAfter$match2;
  50973. var cm = this.editor.editor;
  50974. var _this$$getSelectionRa = this.$getSelectionRange(),
  50975. begin = _this$$getSelectionRa.begin,
  50976. end = _this$$getSelectionRa.end;
  50977. var newBeginLine = ((_lessBefore$match = lessBefore.match(/\n/g)) === null || _lessBefore$match === void 0 ? void 0 : _lessBefore$match.length) > 0 ? begin.line + lessBefore.match(/\n/g).length : begin.line;
  50978. var newBeginCh = ((_lessBefore$match2 = lessBefore.match(/\n/g)) === null || _lessBefore$match2 === void 0 ? void 0 : _lessBefore$match2.length) > 0 ? lessBefore.replace(/^[\s\S]*?\n([^\n]*)$/, '$1').length : begin.ch + lessBefore.length;
  50979. var newBegin = {
  50980. line: newBeginLine,
  50981. ch: newBeginCh
  50982. };
  50983. var newEndLine = ((_lessAfter$match = lessAfter.match(/\n/g)) === null || _lessAfter$match === void 0 ? void 0 : _lessAfter$match.length) > 0 ? end.line - lessAfter.match(/\n/g).length : end.line;
  50984. var newEndCh = ((_lessAfter$match2 = lessAfter.match(/\n/g)) === null || _lessAfter$match2 === void 0 ? void 0 : _lessAfter$match2.length) > 0 ? cm.getLine(newEndLine).length : end.ch - lessAfter.length;
  50985. var newEnd = {
  50986. line: newEndLine,
  50987. ch: newEndCh
  50988. };
  50989. cm.setSelection(newBegin, newEnd);
  50990. }
  50991. /**
  50992. * 基于当前已选择区域,获取更多的选择区
  50993. * @param {string} [appendBefore] 选择区前面追加的内容
  50994. * @param {string} [appendAfter] 选择区后面追加的内容
  50995. * @param {function} [cb] 回调函数,如果返回false,则恢复原来的选取
  50996. */
  50997. }, {
  50998. key: "getMoreSelection",
  50999. value: function getMoreSelection(appendBefore, appendAfter, cb) {
  51000. var cm = this.editor.editor;
  51001. var _this$$getSelectionRa2 = this.$getSelectionRange(),
  51002. begin = _this$$getSelectionRa2.begin,
  51003. end = _this$$getSelectionRa2.end;
  51004. var newBeginCh = // 如果只包含换行,则起始位置一定是0
  51005. /\n/.test(appendBefore) ? 0 : begin.ch - appendBefore.length;
  51006. newBeginCh = newBeginCh < 0 ? 0 : newBeginCh;
  51007. var newBeginLine = /\n/.test(appendBefore) ? begin.line - appendBefore.match(/\n/g).length : begin.line;
  51008. newBeginLine = newBeginLine < 0 ? 0 : newBeginLine;
  51009. var newBegin = {
  51010. line: newBeginLine,
  51011. ch: newBeginCh
  51012. };
  51013. var newEndLine = end.line;
  51014. var newEndCh = end.ch;
  51015. if (/\n/.test(appendAfter)) {
  51016. var _cm$getLine;
  51017. newEndLine = end.line + appendAfter.match(/\n/g).length;
  51018. newEndCh = (_cm$getLine = cm.getLine(newEndLine)) === null || _cm$getLine === void 0 ? void 0 : _cm$getLine.length;
  51019. } else {
  51020. newEndCh = cm.getLine(end.line).length < end.ch + appendAfter.length ? cm.getLine(end.line).length : end.ch + appendAfter.length;
  51021. }
  51022. var newEnd = {
  51023. line: newEndLine,
  51024. ch: newEndCh
  51025. };
  51026. cm.setSelection(newBegin, newEnd);
  51027. if (cb() === false) {
  51028. cm.setSelection(begin, end);
  51029. }
  51030. }
  51031. /**
  51032. * 获取用户选中的文本内容,如果没有选中文本,则返回光标所在的位置的内容
  51033. * @param {string} selection 当前选中的文本内容
  51034. * @param {string} type 'line': 当没有选择文本时,获取光标所在行的内容; 'word': 当没有选择文本时,获取光标所在单词的内容
  51035. * @param {boolean} focus true;强行选中光标处的内容,否则只获取选中的内容
  51036. * @returns {string}
  51037. */
  51038. }, {
  51039. key: "getSelection",
  51040. value: function getSelection(selection) {
  51041. var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'word';
  51042. var focus = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  51043. var cm = this.editor.editor; // 多光标模式下不做处理
  51044. if (this.isSelections) {
  51045. return selection;
  51046. }
  51047. if (selection && !focus) {
  51048. return selection;
  51049. } // 获取光标所在行的内容,同时选中所在行
  51050. if (type === 'line') {
  51051. var _this$$getSelectionRa3 = this.$getSelectionRange(),
  51052. begin = _this$$getSelectionRa3.begin,
  51053. end = _this$$getSelectionRa3.end;
  51054. cm.setSelection({
  51055. line: begin.line,
  51056. ch: 0
  51057. }, {
  51058. line: end.line,
  51059. ch: cm.getLine(end.line).length
  51060. });
  51061. return cm.getSelection();
  51062. } // 获取光标所在单词的内容,同时选中所在单词
  51063. if (type === 'word') {
  51064. var _cm$findWordAt = cm.findWordAt(cm.getCursor()),
  51065. _begin = _cm$findWordAt.anchor,
  51066. _end = _cm$findWordAt.head;
  51067. cm.setSelection(_begin, _end);
  51068. return cm.getSelection();
  51069. }
  51070. }
  51071. /**
  51072. * 反转子菜单点击事件参数顺序
  51073. * @deprecated
  51074. */
  51075. }, {
  51076. key: "bindSubClick",
  51077. value: function bindSubClick(shortcut, selection) {
  51078. return this.fire(null, shortcut);
  51079. }
  51080. }, {
  51081. key: "onClick",
  51082. value: function onClick(selection, shortcut, callback) {
  51083. return selection;
  51084. }
  51085. }, {
  51086. key: "shortcutKeys",
  51087. get: function get() {
  51088. return [];
  51089. }
  51090. /**
  51091. * 获取当前菜单的位置
  51092. */
  51093. }, {
  51094. key: "getMenuPosition",
  51095. value: function getMenuPosition() {
  51096. var parent = MenuBase.getTargetParentByButton(this.dom);
  51097. var isFromSidebar = /cherry-sidebar/.test(parent.className);
  51098. if (/cherry-bubble/.test(parent.className) || /cherry-floatmenu/.test(parent.className)) {
  51099. this.positionModel = 'fixed';
  51100. } else if (isFromSidebar) {
  51101. this.positionModel = 'sidebar';
  51102. } else {
  51103. this.positionModel = 'absolute';
  51104. }
  51105. return getPosition(this.dom, this.positionModel);
  51106. }
  51107. /**
  51108. * 根据按钮获取按钮的父元素,这里父元素要绕过toolbar-(left|right)那一层
  51109. * @param {HTMLElement} dom 按钮元素
  51110. * @returns {HTMLElement} 父元素
  51111. */
  51112. }], [{
  51113. key: "getTargetParentByButton",
  51114. value: function getTargetParentByButton(dom) {
  51115. var parent = dom.parentElement;
  51116. if (/toolbar-(left|right)/.test(parent.className)) {
  51117. parent = parent.parentElement;
  51118. }
  51119. return parent;
  51120. }
  51121. }]);
  51122. return MenuBase;
  51123. }();
  51124. function _createSuper$z(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$z(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  51125. function _isNativeReflectConstruct$z() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  51126. /**
  51127. * 加粗按钮
  51128. */
  51129. var Bold = /*#__PURE__*/function (_MenuBase) {
  51130. _inherits(Bold, _MenuBase);
  51131. var _super = _createSuper$z(Bold);
  51132. function Bold($cherry) {
  51133. var _this;
  51134. _classCallCheck(this, Bold);
  51135. _this = _super.call(this, $cherry);
  51136. _this.setName('bold', 'bold');
  51137. return _this;
  51138. }
  51139. /**
  51140. * 是不是包含加粗语法
  51141. * @param {String} selection
  51142. * @returns {Boolean}
  51143. */
  51144. _createClass(Bold, [{
  51145. key: "$testIsBold",
  51146. value: function $testIsBold(selection) {
  51147. return /^\s*(\*\*|__)[\s\S]+(\1)/.test(selection);
  51148. }
  51149. /**
  51150. * 响应点击事件
  51151. * @param {string} selection 被用户选中的文本内容
  51152. * @param {string} shortKey 快捷键参数,本函数不处理这个参数
  51153. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  51154. */
  51155. }, {
  51156. key: "onClick",
  51157. value: function onClick(selection) {
  51158. var _this2 = this;
  51159. var $selection = this.getSelection(selection) || this.locale.bold; // 如果是单选,并且选中内容的开始结束内没有加粗语法,则扩大选中范围
  51160. if (!this.isSelections && !this.$testIsBold($selection)) {
  51161. this.getMoreSelection('**', '**', function () {
  51162. var newSelection = _this2.editor.editor.getSelection();
  51163. var isBold = _this2.$testIsBold(newSelection);
  51164. if (isBold) {
  51165. $selection = newSelection;
  51166. }
  51167. return isBold;
  51168. });
  51169. } // 如果选中的文本中已经有加粗语法了,则去掉加粗语法
  51170. if (this.$testIsBold($selection)) {
  51171. return $selection.replace(/(^)(\s*)(\*\*|__)([^\n]+)(\3)(\s*)($)/gm, '$1$4$7');
  51172. }
  51173. this.registerAfterClickCb(function () {
  51174. _this2.setLessSelection('**', '**');
  51175. });
  51176. return $selection.replace(/(^)([^\n]+)($)/gm, '$1**$2**$3');
  51177. }
  51178. /**
  51179. * 声明绑定的快捷键,快捷键触发onClick
  51180. */
  51181. }, {
  51182. key: "shortcutKeys",
  51183. get: function get() {
  51184. return ['Ctrl-b'];
  51185. }
  51186. }]);
  51187. return Bold;
  51188. }(MenuBase);
  51189. function _createSuper$A(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$A(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  51190. function _isNativeReflectConstruct$A() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  51191. /**
  51192. * 插入斜体的按钮
  51193. */
  51194. var Italic = /*#__PURE__*/function (_MenuBase) {
  51195. _inherits(Italic, _MenuBase);
  51196. var _super = _createSuper$A(Italic);
  51197. function Italic($cherry) {
  51198. var _this;
  51199. _classCallCheck(this, Italic);
  51200. _this = _super.call(this, $cherry);
  51201. _this.setName('italic', 'italic');
  51202. return _this;
  51203. }
  51204. /**
  51205. * 是不是包含加粗语法
  51206. * @param {String} selection
  51207. * @returns {Boolean}
  51208. */
  51209. _createClass(Italic, [{
  51210. key: "$testIsItalic",
  51211. value: function $testIsItalic(selection) {
  51212. return /^\s*(\*|_)[\s\S]+(\1)/.test(selection);
  51213. }
  51214. /**
  51215. * 响应点击事件
  51216. * @param {string} selection 被用户选中的文本内容
  51217. * @param {string} shortKey 快捷键参数,本函数不处理这个参数
  51218. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  51219. */
  51220. }, {
  51221. key: "onClick",
  51222. value: function onClick(selection) {
  51223. var _this2 = this;
  51224. var $selection = this.getSelection(selection) || this.locale.italic; // 如果是单选,并且选中内容的开始结束内没有加粗语法,则扩大选中范围
  51225. if (!this.isSelections && !this.$testIsItalic($selection)) {
  51226. this.getMoreSelection('*', '*', function () {
  51227. var newSelection = _this2.editor.editor.getSelection();
  51228. var isItalic = _this2.$testIsItalic(newSelection);
  51229. if (isItalic) {
  51230. $selection = newSelection;
  51231. }
  51232. return isItalic;
  51233. });
  51234. }
  51235. if (this.$testIsItalic($selection)) {
  51236. return $selection.replace(/(^)(\s*)(\*|_)([^\n]+)(\3)(\s*)($)/gm, '$1$4$7');
  51237. }
  51238. this.registerAfterClickCb(function () {
  51239. _this2.setLessSelection('*', '*');
  51240. });
  51241. return $selection.replace(/(^)([^\n]+)($)/gm, '$1*$2*$3');
  51242. }
  51243. /**
  51244. * 获得监听的快捷键
  51245. * 在windows下是Ctrl+i,在mac下是cmd+i
  51246. */
  51247. }, {
  51248. key: "shortcutKeys",
  51249. get: function get() {
  51250. return ['Ctrl-i'];
  51251. }
  51252. }]);
  51253. return Italic;
  51254. }(MenuBase);
  51255. function _createSuper$B(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$B(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  51256. function _isNativeReflectConstruct$B() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  51257. /**
  51258. * 工具栏里的分割线,用来切分不同类型按钮的区域
  51259. * 一个实例中可以配置多个分割线
  51260. */
  51261. var Split = /*#__PURE__*/function (_MenuBase) {
  51262. _inherits(Split, _MenuBase);
  51263. var _super = _createSuper$B(Split);
  51264. function Split($cherry) {
  51265. var _this;
  51266. _classCallCheck(this, Split);
  51267. _this = _super.call(this, $cherry);
  51268. _this.setName('split', '|');
  51269. return _this;
  51270. }
  51271. /**
  51272. * 重载创建按钮逻辑
  51273. * @returns {HTMLElement} 分割线标签
  51274. */
  51275. _createClass(Split, [{
  51276. key: "createBtn",
  51277. value: function createBtn() {
  51278. var className = 'cherry-toolbar-button cherry-toolbar-split';
  51279. var i = document.createElement('i');
  51280. i.className = className;
  51281. return i;
  51282. }
  51283. }]);
  51284. return Split;
  51285. }(MenuBase);
  51286. /**
  51287. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  51288. *
  51289. * Licensed under the Apache License, Version 2.0 (the "License");
  51290. * you may not use this file except in compliance with the License.
  51291. * You may obtain a copy of the License at
  51292. *
  51293. * http://www.apache.org/licenses/LICENSE-2.0
  51294. *
  51295. * Unless required by applicable law or agreed to in writing, software
  51296. * distributed under the License is distributed on an "AS IS" BASIS,
  51297. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  51298. * See the License for the specific language governing permissions and
  51299. * limitations under the License.
  51300. */
  51301. /**
  51302. * 获取用户选中的文本内容,如果没有选中文本,则返回光标所在的位置的内容
  51303. * @param {Object} cm Codemirror实例
  51304. * @param {string} selection 当前选中的文本内容
  51305. * @param {string} type 'line': 当没有选择文本时,获取光标所在行的内容; 'word': 当没有选择文本时,获取光标所在单词的内容
  51306. * @param {boolean} focus true;强行选中光标处的内容,否则只获取选中的内容
  51307. * @returns {string}
  51308. */
  51309. function getSelection(cm, selection) {
  51310. var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'word';
  51311. var focus = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  51312. // 多光标模式下不做处理
  51313. if (cm.getSelections().length > 1) {
  51314. return selection;
  51315. }
  51316. if (selection && !focus) {
  51317. return selection;
  51318. } // 获取光标所在行的内容,同时选中所在行
  51319. if (type === 'line') {
  51320. var _cm$listSelections$ = cm.listSelections()[0],
  51321. anchor = _cm$listSelections$.anchor,
  51322. head = _cm$listSelections$.head; // 如果begin在end的后面
  51323. if (anchor.line === head.line && anchor.ch > head.ch || anchor.line > head.line) {
  51324. cm.setSelection({
  51325. line: head.line,
  51326. ch: 0
  51327. }, {
  51328. line: anchor.line,
  51329. ch: cm.getLine(anchor.line).length
  51330. });
  51331. } else {
  51332. cm.setSelection({
  51333. line: anchor.line,
  51334. ch: 0
  51335. }, {
  51336. line: head.line,
  51337. ch: cm.getLine(head.line).length
  51338. });
  51339. }
  51340. return cm.getSelection();
  51341. } // 获取光标所在单词的内容,同时选中所在单词
  51342. if (type === 'word') {
  51343. var _cm$findWordAt = cm.findWordAt(cm.getCursor()),
  51344. begin = _cm$findWordAt.anchor,
  51345. end = _cm$findWordAt.head;
  51346. cm.setSelection(begin, end);
  51347. return cm.getSelection();
  51348. }
  51349. }
  51350. function _createSuper$C(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$C(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  51351. function _isNativeReflectConstruct$C() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  51352. /**
  51353. * 删除线的按钮
  51354. */
  51355. var Strikethrough$1 = /*#__PURE__*/function (_MenuBase) {
  51356. _inherits(Strikethrough, _MenuBase);
  51357. var _super = _createSuper$C(Strikethrough);
  51358. function Strikethrough($cherry) {
  51359. var _this;
  51360. _classCallCheck(this, Strikethrough);
  51361. _this = _super.call(this, $cherry);
  51362. _this.setName('strikethrough', 'strike');
  51363. return _this;
  51364. }
  51365. _createClass(Strikethrough, [{
  51366. key: "$testIsStrike",
  51367. value: function $testIsStrike(selection) {
  51368. return /(~~)[\s\S]+(\1)/.test(selection);
  51369. }
  51370. /**
  51371. *
  51372. * @param {string} selection 被用户选中的文本内容
  51373. * @param {string} shortKey 快捷键参数,本函数不处理这个参数
  51374. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  51375. */
  51376. }, {
  51377. key: "onClick",
  51378. value: function onClick(selection) {
  51379. var _this$$cherry,
  51380. _this$$cherry$options,
  51381. _this$$cherry$options2,
  51382. _this$$cherry$options3,
  51383. _this$$cherry$options4,
  51384. _this2 = this,
  51385. _context;
  51386. var $selection = getSelection(this.editor.editor, selection) || this.locale.strikethrough; // @ts-ignore
  51387. var needWhitespace = (_this$$cherry = this.$cherry) === null || _this$$cherry === void 0 ? void 0 : (_this$$cherry$options = _this$$cherry.options) === null || _this$$cherry$options === void 0 ? void 0 : (_this$$cherry$options2 = _this$$cherry$options.engine) === null || _this$$cherry$options2 === void 0 ? void 0 : (_this$$cherry$options3 = _this$$cherry$options2.syntax) === null || _this$$cherry$options3 === void 0 ? void 0 : (_this$$cherry$options4 = _this$$cherry$options3.strikethrough) === null || _this$$cherry$options4 === void 0 ? void 0 : _this$$cherry$options4.needWhitespace;
  51388. var space = needWhitespace ? ' ' : ''; // 如果被选中的文本中包含删除线语法,则去掉删除线语法
  51389. if (!this.isSelections && !this.$testIsStrike($selection)) {
  51390. this.getMoreSelection("".concat(space, "~~"), "~~".concat(space), function () {
  51391. var newSelection = _this2.editor.editor.getSelection();
  51392. var isStrike = _this2.$testIsStrike(newSelection);
  51393. if (isStrike) {
  51394. $selection = newSelection;
  51395. }
  51396. return isStrike;
  51397. });
  51398. }
  51399. if (this.$testIsStrike($selection)) {
  51400. return selection.replace(/[\s]*(~~)([\s\S]+)(\1)[\s]*/g, '$2');
  51401. }
  51402. this.registerAfterClickCb(function () {
  51403. _this2.setLessSelection("".concat(space, "~~"), "~~".concat(space));
  51404. });
  51405. return $selection.replace(/(^)[\s]*([\s\S]+?)[\s]*($)/g, concat$5(_context = "$1".concat(space, "~~$2~~")).call(_context, space, "$3"));
  51406. }
  51407. }, {
  51408. key: "shortcutKeys",
  51409. get: function get() {
  51410. return ['Ctrl-d'];
  51411. }
  51412. }]);
  51413. return Strikethrough;
  51414. }(MenuBase);
  51415. function _createSuper$D(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$D(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  51416. function _isNativeReflectConstruct$D() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  51417. /**
  51418. * 下标的按钮
  51419. **/
  51420. var Sub$1 = /*#__PURE__*/function (_MenuBase) {
  51421. _inherits(Sub, _MenuBase);
  51422. var _super = _createSuper$D(Sub);
  51423. function Sub($cherry) {
  51424. var _this;
  51425. _classCallCheck(this, Sub);
  51426. _this = _super.call(this, $cherry);
  51427. _this.setName('sub', 'sub');
  51428. return _this;
  51429. }
  51430. _createClass(Sub, [{
  51431. key: "$testIsSub",
  51432. value: function $testIsSub(selection) {
  51433. return /^\s*(\^\^)[\s\S]+(\1)/.test(selection);
  51434. }
  51435. /**
  51436. *
  51437. * @param {string} selection 被用户选中的文本内容
  51438. * @param {string} shortKey 快捷键参数,本函数不处理这个参数
  51439. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  51440. */
  51441. }, {
  51442. key: "onClick",
  51443. value: function onClick(selection) {
  51444. var _this2 = this;
  51445. var $selection = getSelection(this.editor.editor, selection) || this.locale.sub; // 如果选中的内容里有下标的语法,则认为是要去掉下标语法
  51446. if (!this.isSelections && !this.$testIsSub($selection)) {
  51447. this.getMoreSelection('^^', '^^', function () {
  51448. var newSelection = _this2.editor.editor.getSelection();
  51449. var isSub = _this2.$testIsSub(newSelection);
  51450. if (isSub) {
  51451. $selection = newSelection;
  51452. }
  51453. return isSub;
  51454. });
  51455. }
  51456. if (this.$testIsSub($selection)) {
  51457. return $selection.replace(/(^)(\s*)(\^\^)([^\n]+)(\3)(\s*)($)/gm, '$1$4$7');
  51458. }
  51459. this.registerAfterClickCb(function () {
  51460. _this2.setLessSelection('^^', '^^');
  51461. });
  51462. return $selection.replace(/(^)([^\n]+)($)/gm, '$1^^$2^^$3');
  51463. }
  51464. }]);
  51465. return Sub;
  51466. }(MenuBase);
  51467. function _createSuper$E(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$E(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  51468. function _isNativeReflectConstruct$E() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  51469. /**
  51470. * 上标的按钮
  51471. **/
  51472. var Sup$1 = /*#__PURE__*/function (_MenuBase) {
  51473. _inherits(Sup, _MenuBase);
  51474. var _super = _createSuper$E(Sup);
  51475. function Sup($cherry) {
  51476. var _this;
  51477. _classCallCheck(this, Sup);
  51478. _this = _super.call(this, $cherry);
  51479. _this.setName('sup', 'sup');
  51480. return _this;
  51481. }
  51482. _createClass(Sup, [{
  51483. key: "$testIsSup",
  51484. value: function $testIsSup(selection) {
  51485. return /^\s*(\^)[\s\S]+(\1)/.test(selection);
  51486. }
  51487. /**
  51488. *
  51489. * @param {string} selection 被用户选中的文本内容
  51490. * @param {string} shortKey 快捷键参数,本函数不处理这个参数
  51491. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  51492. */
  51493. }, {
  51494. key: "onClick",
  51495. value: function onClick(selection) {
  51496. var _this2 = this;
  51497. var $selection = getSelection(this.editor.editor, selection) || this.locale.sup; // 如果选中的内容里有上标的语法,则认为是要去掉上标语法
  51498. if (!this.isSelections && !this.$testIsSup($selection)) {
  51499. this.getMoreSelection('^', '^', function () {
  51500. var newSelection = _this2.editor.editor.getSelection();
  51501. var isSup = _this2.$testIsSup(newSelection);
  51502. if (isSup) {
  51503. $selection = newSelection;
  51504. }
  51505. return isSup;
  51506. });
  51507. }
  51508. if (this.$testIsSup($selection)) {
  51509. return selection.replace(/(^)(\s*)(\^)([^\n]+)(\3)(\s*)($)/gm, '$1$4$7');
  51510. }
  51511. this.registerAfterClickCb(function () {
  51512. _this2.setLessSelection('^', '^');
  51513. });
  51514. return $selection.replace(/(^)([^\n]+)($)/gm, '$1^$2^$3');
  51515. }
  51516. }]);
  51517. return Sup;
  51518. }(MenuBase);
  51519. function _createSuper$F(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$F(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  51520. function _isNativeReflectConstruct$F() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  51521. /**
  51522. * 插入字体颜色或者字体背景颜色的按钮
  51523. */
  51524. var Color$1 = /*#__PURE__*/function (_MenuBase) {
  51525. _inherits(Color, _MenuBase);
  51526. var _super = _createSuper$F(Color);
  51527. function Color($cherry) {
  51528. var _this;
  51529. _classCallCheck(this, Color);
  51530. _this = _super.call(this, $cherry);
  51531. _this.setName('color', 'color'); // this.bubbleMenu = true;
  51532. _this.bubbleColor = new BubbleColor($cherry);
  51533. return _this;
  51534. }
  51535. _createClass(Color, [{
  51536. key: "$testIsColor",
  51537. value: function $testIsColor(type, selection) {
  51538. var textReg = /^\s*!![^\s]+ [\s\S]+!!\s*$/;
  51539. var bgReg = /^\s*!!![^\s]+ [\s\S]+!!!\s*$/;
  51540. if (type === 'text') {
  51541. return textReg.test(selection) && !bgReg.test(selection);
  51542. }
  51543. return bgReg.test(selection);
  51544. }
  51545. /**
  51546. * 响应点击事件
  51547. * @param {string} selection 被用户选中的文本内容
  51548. * @param {string} shortKey 快捷键参数,本函数不处理这个参数
  51549. * @param {Event & {target:HTMLElement}} event 点击事件,用来从被点击的调色盘中获得对应的颜色
  51550. * @returns 回填到编辑器光标位置/选中文本区域的内容
  51551. */
  51552. }, {
  51553. key: "onClick",
  51554. value: function onClick(selection) {
  51555. var _this2 = this;
  51556. var event = arguments.length > 2 ? arguments[2] : undefined;
  51557. var $selection = getSelection(this.editor.editor, selection) || this.locale.color;
  51558. if (this.hasCacheOnce()) {
  51559. var _context4, _context5;
  51560. // @ts-ignore
  51561. var _this$getAndCleanCach = this.getAndCleanCacheOnce(),
  51562. type = _this$getAndCleanCach.type,
  51563. color = _this$getAndCleanCach.color;
  51564. var begin = type === 'text' ? "!!".concat(color, " ") : "!!!".concat(color, " ");
  51565. var end = type === 'text' ? '!!' : '!!!';
  51566. if (!this.isSelections && !this.$testIsColor(type, $selection)) {
  51567. this.getMoreSelection(begin, end, function () {
  51568. var newSelection = _this2.editor.editor.getSelection();
  51569. if (_this2.$testIsColor(type, newSelection)) {
  51570. $selection = newSelection;
  51571. return true;
  51572. }
  51573. return false;
  51574. });
  51575. }
  51576. if (this.$testIsColor(type, $selection)) {
  51577. var _context;
  51578. var reg = new RegExp(concat$5(_context = "(^\\s*".concat(end, ")([^\\s]+) ([\\s\\S]+")).call(_context, end, "\\s*$)"), 'gm');
  51579. var needClean = true;
  51580. var tmp = $selection.replace(reg, function (w, m1, m2, m3) {
  51581. var _context2, _context3;
  51582. needClean = needClean ? m2 === color : false;
  51583. return concat$5(_context2 = concat$5(_context3 = "".concat(m1)).call(_context3, color, " ")).call(_context2, m3);
  51584. });
  51585. if (needClean) {
  51586. return $selection.replace(reg, '$3').replace(/!+\s*$/gm, '');
  51587. }
  51588. this.registerAfterClickCb(function () {
  51589. _this2.setLessSelection(begin, end);
  51590. });
  51591. return tmp;
  51592. }
  51593. this.registerAfterClickCb(function () {
  51594. _this2.setLessSelection(begin, end);
  51595. });
  51596. return concat$5(_context4 = concat$5(_context5 = "".concat(begin)).call(_context5, $selection)).call(_context4, end);
  51597. } // 定位调色盘应该出现的位置
  51598. // 该按钮可能出现在顶部工具栏,
  51599. // 也可能出现在选中文字时出现的bubble工具栏,
  51600. // 也可能出现在新行出现的float工具栏
  51601. var top = 0;
  51602. var left = 0;
  51603. if (event.target.closest('.cherry-bubble')) {
  51604. var $colorDom =
  51605. /** @type {HTMLElement}*/
  51606. event.target.closest('.cherry-bubble');
  51607. var clientRect = $colorDom.getBoundingClientRect();
  51608. top = clientRect.top + $colorDom.offsetHeight;
  51609. left =
  51610. /** @type {HTMLElement}*/
  51611. event.target.closest('.cherry-toolbar-color').offsetLeft + clientRect.left;
  51612. } else {
  51613. var _$colorDom =
  51614. /** @type {HTMLElement}*/
  51615. event.target.closest('.cherry-toolbar-color');
  51616. var _clientRect = _$colorDom.getBoundingClientRect();
  51617. top = _clientRect.top + _$colorDom.offsetHeight;
  51618. left = _clientRect.left;
  51619. }
  51620. this.updateMarkdown = false; // 【TODO】需要增加getMoreSelection的逻辑
  51621. this.bubbleColor.show({
  51622. left: left,
  51623. top: top,
  51624. $color: this
  51625. });
  51626. }
  51627. }]);
  51628. return Color;
  51629. }(MenuBase);
  51630. var BubbleColor = /*#__PURE__*/function () {
  51631. function BubbleColor($cherry) {
  51632. _classCallCheck(this, BubbleColor);
  51633. _defineProperty(this, "colorStack", ['#000000', '#444444', '#666666', '#999999', '#cccccc', '#eeeeee', '#f3f3f3', '#ffffff', '#ff0000', '#ff9900', '#ffff00', '#00ff00', '#00ffff', '#0000ff', '#9900ff', '#ff00ff', '#f4cccc', '#fce5cd', '#fff2cc', '#d9ead3', '#d0e0e3', '#cfe2f3', '#d9d2e9', '#ead1dc', '#ea9999', '#f9cb9c', '#ffe599', '#b6d7a8', '#a2c4c9', '#9fc5e8', '#b4a7d6', '#d5a6bd', '#e06666', '#f6b26b', '#ffd966', '#93c47d', '#76a5af', '#6fa8dc', '#8e7cc3', '#c27ba0', '#cc0000', '#e69138', '#f1c232', '#6aa84f', '#45818e', '#3d85c6', '#674ea7', '#a64d79', '#990000', '#b45f06', '#bf9000', '#38761d', '#134f5c', '#0b5394', '#351c75', '#741b47', '#660000', '#783f04', '#7f6000', '#274e13', '#0c343d', '#073763', '#20124d', '#4c1130']);
  51634. this.editor = $cherry.editor;
  51635. this.init();
  51636. this.initAction();
  51637. }
  51638. /**
  51639. * 定义调色盘每个色块的颜色值
  51640. */
  51641. _createClass(BubbleColor, [{
  51642. key: "setSelection",
  51643. value:
  51644. /**
  51645. * 用来暂存选中的内容
  51646. * @param {string} selection 编辑区选中的文本内容
  51647. */
  51648. function setSelection(selection) {
  51649. this.selection = selection;
  51650. }
  51651. }, {
  51652. key: "getFontColorDom",
  51653. value: function getFontColorDom(title) {
  51654. var _context6, _context9;
  51655. var colorStackDOM = map$3(_context6 = this.colorStack).call(_context6, function (color) {
  51656. var _context7, _context8;
  51657. return concat$5(_context7 = concat$5(_context8 = "<span class=\"cherry-color-item cherry-color-item__".concat(color.replace('#', ''), "\" unselectable=\"on\" data-val=\"")).call(_context8, color, "\"\n style=\"background-color:")).call(_context7, color, "\"></span>");
  51658. }).join('');
  51659. return concat$5(_context9 = "<h3>".concat(title, "</h3>")).call(_context9, colorStackDOM);
  51660. }
  51661. }, {
  51662. key: "getDom",
  51663. value: function getDom() {
  51664. var $colorWrap = document.createElement('div');
  51665. $colorWrap.classList.add('cherry-color-wrap');
  51666. $colorWrap.classList.add('cherry-dropdown');
  51667. var $textWrap = document.createElement('div');
  51668. $textWrap.classList.add('cherry-color-text');
  51669. $textWrap.innerHTML = this.getFontColorDom('文本颜色');
  51670. $colorWrap.appendChild($textWrap);
  51671. var $bgWrap = document.createElement('div');
  51672. $bgWrap.classList.add('cherry-color-bg');
  51673. $bgWrap.innerHTML = this.getFontColorDom('背景颜色');
  51674. $colorWrap.appendChild($bgWrap);
  51675. return $colorWrap;
  51676. }
  51677. }, {
  51678. key: "init",
  51679. value: function init() {
  51680. this.dom = this.getDom();
  51681. this.editor.options.wrapperDom.appendChild(this.dom);
  51682. }
  51683. }, {
  51684. key: "onClick",
  51685. value: function onClick() {
  51686. var _context11;
  51687. if (this.type === 'text') {
  51688. var _context10;
  51689. if (/^!!#\S+ [\s\S]+?!!/.test(this.selection)) {
  51690. return this.selection.replace(/^!!#\S+ ([\s\S]+?)!!/, "!!".concat(this.colorValue, " $1!!"));
  51691. }
  51692. return concat$5(_context10 = "!!".concat(this.colorValue, " ")).call(_context10, this.selection, "!!");
  51693. }
  51694. if (/^!!!#\S+ [\s\S]+?!!!/.test(this.selection)) {
  51695. return this.selection.replace(/^!!!#\S+ ([\s\S]+?)!!!/, "!!!".concat(this.colorValue, " $1!!!"));
  51696. }
  51697. return concat$5(_context11 = "!!!".concat(this.colorValue, " ")).call(_context11, this.selection, "!!!");
  51698. }
  51699. }, {
  51700. key: "initAction",
  51701. value: function initAction() {
  51702. var _this3 = this;
  51703. // const self = this;
  51704. this.dom.addEventListener('click', function (evt) {
  51705. var target =
  51706. /** @type {MouseEvent & {target:HTMLElement}}*/
  51707. evt.target;
  51708. _this3.colorValue = target.getAttribute('data-val');
  51709. if (!_this3.colorValue) {
  51710. return false;
  51711. }
  51712. _this3.type = target.closest('.cherry-color-text') ? 'text' : 'bg';
  51713. _this3.$color.setCacheOnce({
  51714. type: _this3.type,
  51715. color: _this3.colorValue
  51716. });
  51717. _this3.$color.fire(null);
  51718. }, false);
  51719. this.dom.addEventListener('EditorHideToolbarSubMenu', function () {
  51720. if (_this3.dom.style.display !== 'none') {
  51721. _this3.dom.style.display = 'none';
  51722. }
  51723. });
  51724. }
  51725. /**
  51726. * 在对应的坐标展示调色盘
  51727. * @param {Object} 坐标
  51728. */
  51729. }, {
  51730. key: "show",
  51731. value: function show(_ref) {
  51732. var left = _ref.left,
  51733. top = _ref.top,
  51734. $color = _ref.$color;
  51735. this.dom.style.left = "".concat(left, "px");
  51736. this.dom.style.top = "".concat(top, "px");
  51737. this.dom.style.display = 'block';
  51738. this.$color = $color;
  51739. }
  51740. }]);
  51741. return BubbleColor;
  51742. }();
  51743. function _createSuper$G(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$G(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  51744. function _isNativeReflectConstruct$G() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  51745. /**
  51746. * 插入1级~5级标题
  51747. */
  51748. var Header$1 = /*#__PURE__*/function (_MenuBase) {
  51749. _inherits(Header, _MenuBase);
  51750. var _super = _createSuper$G(Header);
  51751. function Header($cherry) {
  51752. var _context, _context2, _context3, _context4, _context5;
  51753. var _this;
  51754. _classCallCheck(this, Header);
  51755. _this = _super.call(this, $cherry);
  51756. _this.setName('header', 'header');
  51757. _this.subMenuConfig = [{
  51758. iconName: 'h1',
  51759. name: 'h1',
  51760. onclick: bind$5(_context = _this.bindSubClick).call(_context, _assertThisInitialized(_this), '1')
  51761. }, {
  51762. iconName: 'h2',
  51763. name: 'h2',
  51764. onclick: bind$5(_context2 = _this.bindSubClick).call(_context2, _assertThisInitialized(_this), '2')
  51765. }, {
  51766. iconName: 'h3',
  51767. name: 'h3',
  51768. onclick: bind$5(_context3 = _this.bindSubClick).call(_context3, _assertThisInitialized(_this), '3')
  51769. }, {
  51770. iconName: 'h4',
  51771. name: 'h4',
  51772. onclick: bind$5(_context4 = _this.bindSubClick).call(_context4, _assertThisInitialized(_this), '4')
  51773. }, {
  51774. iconName: 'h5',
  51775. name: 'h5',
  51776. onclick: bind$5(_context5 = _this.bindSubClick).call(_context5, _assertThisInitialized(_this), '5')
  51777. }];
  51778. return _this;
  51779. }
  51780. _createClass(Header, [{
  51781. key: "getSubMenuConfig",
  51782. value: function getSubMenuConfig() {
  51783. return this.subMenuConfig;
  51784. }
  51785. /**
  51786. * 解析快捷键,判断插入的标题级别
  51787. * @param {string} shortKey 快捷键
  51788. * @returns
  51789. */
  51790. }, {
  51791. key: "$getFlagStr",
  51792. value: function $getFlagStr(shortKey) {
  51793. var _context6;
  51794. var test = +(typeof shortKey === 'string' ? shortKey.replace(/[^0-9]+([0-9])/g, '$1') : shortKey);
  51795. return repeat$3(_context6 = '#').call(_context6, test ? test : 1);
  51796. }
  51797. }, {
  51798. key: "$testIsHead",
  51799. value: function $testIsHead(selection) {
  51800. return /^\s*(#+)\s*.+/.test(selection);
  51801. }
  51802. /**
  51803. * 响应点击事件
  51804. * @param {string} selection 被用户选中的文本内容
  51805. * @param {string} shortKey 快捷键参数
  51806. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  51807. */
  51808. }, {
  51809. key: "onClick",
  51810. value: function onClick(selection) {
  51811. var _this2 = this;
  51812. var shortKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  51813. var $selection = getSelection(this.editor.editor, selection, 'line', true) || this.locale.header;
  51814. var header = this.$getFlagStr(shortKey);
  51815. if (!this.isSelections && !this.$testIsHead($selection)) {
  51816. this.getMoreSelection('\n', '', function () {
  51817. var newSelection = _this2.editor.editor.getSelection();
  51818. var isHead = _this2.$testIsHead(newSelection);
  51819. if (isHead) {
  51820. $selection = newSelection;
  51821. }
  51822. return isHead;
  51823. });
  51824. }
  51825. if (this.$testIsHead($selection)) {
  51826. // 如果选中的内容里有标题语法,并且标记级别与目标一致,则去掉标题语法
  51827. // 反之,修改标题级别与目标一致
  51828. var needClean = true;
  51829. var tmp = $selection.replace(/(^\s*)(#+)(\s*)(.+$)/gm, function (w, m1, m2, m3, m4) {
  51830. var _context7, _context8, _context9;
  51831. needClean = needClean ? m2.length === header.length : false;
  51832. return concat$5(_context7 = concat$5(_context8 = concat$5(_context9 = "".concat(m1)).call(_context9, header)).call(_context8, m3)).call(_context7, m4);
  51833. });
  51834. if (needClean) {
  51835. return $selection.replace(/(^\s*)(#+)(\s*)(.+$)/gm, '$1$4');
  51836. }
  51837. this.registerAfterClickCb(function () {
  51838. _this2.setLessSelection("".concat(header, " "), '');
  51839. });
  51840. return tmp;
  51841. }
  51842. this.registerAfterClickCb(function () {
  51843. _this2.setLessSelection("".concat(header, " "), '');
  51844. });
  51845. return $selection.replace(/(^)([\s]*)([^\n]+)($)/gm, "$1".concat(header, " $3$4"));
  51846. }
  51847. /**
  51848. * 获得监听的快捷键
  51849. * 在windows下是Ctrl+1,在mac下是cmd+1
  51850. */
  51851. }, {
  51852. key: "shortcutKeys",
  51853. get: function get() {
  51854. return ['Ctrl-1', 'Ctrl-2', 'Ctrl-3', 'Ctrl-4', 'Ctrl-5', 'Ctrl-6'];
  51855. }
  51856. }]);
  51857. return Header;
  51858. }(MenuBase);
  51859. /**
  51860. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  51861. *
  51862. * Licensed under the Apache License, Version 2.0 (the "License");
  51863. * you may not use this file except in compliance with the License.
  51864. * You may obtain a copy of the License at
  51865. *
  51866. * http://www.apache.org/licenses/LICENSE-2.0
  51867. *
  51868. * Unless required by applicable law or agreed to in writing, software
  51869. * distributed under the License is distributed on an "AS IS" BASIS,
  51870. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  51871. * See the License for the specific language governing permissions and
  51872. * limitations under the License.
  51873. */
  51874. var createTableItem = function createTableItem(dataset, className) {
  51875. var _context;
  51876. var dom = document.createElement('td');
  51877. dom.className = className || 'table-item';
  51878. forEach$3(_context = keys$3(dataset)).call(_context, function (prop) {
  51879. dom.dataset[prop] = dataset[prop];
  51880. });
  51881. return dom;
  51882. };
  51883. /**
  51884. * 插入表格的辅助面板
  51885. */
  51886. var BubbleTableMenu = /*#__PURE__*/function () {
  51887. function BubbleTableMenu(_ref, className) {
  51888. var row = _ref.row,
  51889. col = _ref.col;
  51890. _classCallCheck(this, BubbleTableMenu);
  51891. this.init(row, col, className);
  51892. this.initEventListeners();
  51893. this.afterClick = function () {};
  51894. }
  51895. _createClass(BubbleTableMenu, [{
  51896. key: "init",
  51897. value: function init(row, col, className) {
  51898. var _this = this;
  51899. var container = document.createElement('table');
  51900. var cellArr = [];
  51901. var classNames = ['cherry-insert-table-menu', 'cherry-dropdown'];
  51902. container.className = classNames.join(' ');
  51903. for (var r = 1; r <= row; r++) {
  51904. var rowContainer = document.createElement('tr');
  51905. rowContainer.className = 'cherry-insert-table-menu-row';
  51906. cellArr[r - 1] = [];
  51907. for (var c = 1; c <= col; c++) {
  51908. var cell = createTableItem({
  51909. row: r,
  51910. col: c
  51911. }, 'cherry-insert-table-menu-item');
  51912. rowContainer.appendChild(cell);
  51913. cellArr[r - 1][c - 1] = cell;
  51914. }
  51915. container.appendChild(rowContainer);
  51916. }
  51917. container.style.display = 'none';
  51918. container.addEventListener('EditorHideToolbarSubMenu', function () {
  51919. _this.hide();
  51920. });
  51921. this.dom = container;
  51922. this.cell = cellArr;
  51923. this.maxRow = row;
  51924. this.maxCol = col;
  51925. this.activeRow = 0;
  51926. this.activeCol = 0;
  51927. return this.dom;
  51928. }
  51929. }, {
  51930. key: "initEventListeners",
  51931. value: function initEventListeners() {
  51932. var _context2, _context3;
  51933. this.dom.addEventListener('mousemove', bind$5(_context2 = this.handleMouseMove).call(_context2, this), false); // 不能用click
  51934. this.dom.addEventListener('mouseup', bind$5(_context3 = this.handleMouseUp).call(_context3, this));
  51935. }
  51936. }, {
  51937. key: "setActiveCell",
  51938. value: function setActiveCell(row, col) {
  51939. if (this.activeRow === row && this.activeCol === col) {
  51940. return;
  51941. }
  51942. var minRow = Math.min(this.activeRow, row);
  51943. var maxRow = Math.max(this.activeRow, row);
  51944. if (minRow !== maxRow) {
  51945. // 先清空或按照历史列数增减active类
  51946. for (var r = maxRow; r > minRow; r--) {
  51947. for (var c = 1; c <= this.activeCol; c++) {
  51948. this.cell[r - 1][c - 1].classList.toggle('active');
  51949. }
  51950. }
  51951. }
  51952. var minCol = Math.min(this.activeCol, col);
  51953. var maxCol = Math.max(this.activeCol, col);
  51954. if (minCol !== maxCol) {
  51955. for (var _c = maxCol; _c > minCol; _c--) {
  51956. for (var _r = 1; _r <= row; _r++) {
  51957. this.cell[_r - 1][_c - 1].classList.toggle('active');
  51958. }
  51959. }
  51960. }
  51961. this.activeRow = row;
  51962. this.activeCol = col;
  51963. }
  51964. }, {
  51965. key: "handleMouseMove",
  51966. value: function handleMouseMove(event) {
  51967. var target = event.target;
  51968. if (target === this.dom) {
  51969. return;
  51970. }
  51971. if (!target.classList.contains('cherry-insert-table-menu-item')) {
  51972. target = target.querySelector('.cherry-insert-table-menu-item');
  51973. }
  51974. if (!target) {
  51975. return;
  51976. }
  51977. this.setActiveCell(target.dataset.row, target.dataset.col);
  51978. }
  51979. }, {
  51980. key: "handleMouseUp",
  51981. value: function handleMouseUp(event) {
  51982. var target = event.target;
  51983. if (target === this.dom) {
  51984. this.afterClick(this.activeRow, this.activeCol);
  51985. this.hide();
  51986. return;
  51987. }
  51988. if (!target.classList.contains('cherry-insert-table-menu-item')) {
  51989. target = target.querySelector('.cherry-insert-table-menu-item');
  51990. }
  51991. if (!target) {
  51992. this.afterClick(this.activeRow, this.activeCol);
  51993. this.hide();
  51994. return;
  51995. } // 正中单元格时才使用target的dataset
  51996. this.afterClick(this.activeRow, this.activeCol);
  51997. this.hide();
  51998. }
  51999. }, {
  52000. key: "show",
  52001. value: function show(callback) {
  52002. this.dom.style.display = 'block';
  52003. this.afterClick = callback;
  52004. }
  52005. }, {
  52006. key: "hide",
  52007. value: function hide() {
  52008. this.dom.style.display = 'none'; // reset active status
  52009. for (var r = 0; r < this.maxRow; r++) {
  52010. for (var c = 0; c < this.maxCol; c++) {
  52011. this.cell[r][c].classList.remove('active');
  52012. }
  52013. }
  52014. this.activeRow = 0;
  52015. this.activeCol = 0;
  52016. }
  52017. }]);
  52018. return BubbleTableMenu;
  52019. }();
  52020. function _createSuper$H(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$H(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  52021. function _isNativeReflectConstruct$H() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  52022. /**
  52023. * "插入"按钮
  52024. */
  52025. var Insert = /*#__PURE__*/function (_MenuBase) {
  52026. _inherits(Insert, _MenuBase);
  52027. var _super = _createSuper$H(Insert);
  52028. // TODO: 需要优化参数传入方式
  52029. function Insert($cherry) {
  52030. var _this;
  52031. _classCallCheck(this, Insert);
  52032. _this = _super.call(this, $cherry);
  52033. _this.setName('insert', 'insert');
  52034. _this.noIcon = true;
  52035. _this.subBubbleTableMenu = new BubbleTableMenu({
  52036. row: 9,
  52037. col: 9
  52038. });
  52039. $cherry.editor.options.wrapperDom.appendChild(_this.subBubbleTableMenu.dom);
  52040. return _this;
  52041. }
  52042. /**
  52043. * 上传文件的逻辑
  52044. * @param {string} type 上传文件的类型
  52045. */
  52046. _createClass(Insert, [{
  52047. key: "handleUpload",
  52048. value: function handleUpload() {
  52049. var _this2 = this;
  52050. var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'image';
  52051. // type为上传文件类型 image|video|audio|pdf|word
  52052. var input = document.createElement('input');
  52053. input.type = 'file';
  52054. input.id = 'fileUpload';
  52055. input.value = '';
  52056. input.style.display = 'none'; // document.body.appendChild(input);
  52057. input.addEventListener('change', function (event) {
  52058. // @ts-ignore
  52059. var _event$target$files = _slicedToArray(event.target.files, 1),
  52060. file = _event$target$files[0]; // 文件上传后的回调函数可以由调用方自己实现
  52061. _this2.$cherry.options.fileUpload(file, function (url) {
  52062. // 文件上传的默认回调行数,调用方可以完全不使用该函数
  52063. if (typeof url !== 'string' || !url) {
  52064. return;
  52065. }
  52066. var code = '';
  52067. if (type === 'image') {
  52068. var _context;
  52069. // 如果是图片,则返回固定的图片markdown源码
  52070. code = concat$5(_context = "![".concat(file.name, "](")).call(_context, url, ")");
  52071. } else if (type === 'video') {
  52072. var _context2;
  52073. // 如果是视频,则返回固定的视频markdown源码
  52074. code = concat$5(_context2 = "!video[".concat(file.name, "](")).call(_context2, url, ")");
  52075. } else if (type === 'audio') {
  52076. var _context3;
  52077. // 如果是音频,则返回固定的音频markdown源码
  52078. code = concat$5(_context3 = "!audio[".concat(file.name, "](")).call(_context3, url, ")");
  52079. } else {
  52080. var _context4;
  52081. // 默认返回超链接
  52082. code = concat$5(_context4 = "[".concat(file.name, "](")).call(_context4, url, ")");
  52083. } // 替换选中区域
  52084. // @ts-ignore
  52085. _this2.$cherry.$cherry.doc.replaceSelection(code);
  52086. });
  52087. });
  52088. input.click();
  52089. }
  52090. /**
  52091. * 响应点击事件
  52092. * @param {string} selection 被用户选中的文本内容
  52093. * @param {string} shortKey 快捷键参数
  52094. * @param {Function} [callback] 回调函数
  52095. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  52096. */
  52097. }, {
  52098. key: "onClick",
  52099. value: function onClick(selection) {
  52100. var _context11, _context18, _context19, _context25, _context26;
  52101. var shortKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  52102. var callback = arguments.length > 2 ? arguments[2] : undefined;
  52103. if (/normal-table/.test(shortKey)) {
  52104. var _context5, _context6, _context7, _context8, _context9, _context10;
  52105. // 如果是插入markdown标准表格
  52106. // 根据shortKey获取想插入表格的行号和列号
  52107. // shortKey形如:`normal-table-2*4`,表示插入2行(包含表头是3行)4列的表格
  52108. var rowAndCol = shortKey.match(/([0-9]+)[^0-9]([0-9]+)/);
  52109. var row = rowAndCol ? +rowAndCol[1] : 3;
  52110. var col = rowAndCol ? +rowAndCol[2] : 5;
  52111. var headerText = repeat$3(_context5 = ' Header |').call(_context5, col);
  52112. var controlText = repeat$3(_context6 = ' ------ |').call(_context6, col);
  52113. var rowText = "\n|".concat(repeat$3(_context7 = ' Sample |').call(_context7, col));
  52114. var text = concat$5(_context8 = concat$5(_context9 = concat$5(_context10 = "".concat(selection, "\n\n|")).call(_context10, headerText, "\n|")).call(_context9, controlText)).call(_context8, repeat$3(rowText).call(rowText, row), "\n\n");
  52115. return text;
  52116. }
  52117. var $selection = getSelection(this.editor.editor, selection);
  52118. switch (shortKey) {
  52119. case 'hr':
  52120. // 插入分割线
  52121. return "".concat(selection, "\n\n---\n");
  52122. case 'br':
  52123. // 插入换行,在cherry里约定一个回车是一个换行,两个连续回车是一个空行,三个及以上连续回车是两个空行
  52124. return "".concat(selection, "<br>");
  52125. case 'code':
  52126. // 插入代码块
  52127. return "\n``` \n".concat(selection ? selection : 'code...', "\n```\n");
  52128. case 'formula':
  52129. // 插入行内公式
  52130. return "".concat(selection, "\n\n$ e=mc^2 $\n\n");
  52131. case 'checklist':
  52132. // 插入检查项
  52133. return "".concat(selection, "\n\n- [x] Item 1\n- [ ] Item 2\n- [ ] Item 3\n");
  52134. case 'toc':
  52135. // 插入目录
  52136. return "".concat(selection, "\n\n[[toc]]\n");
  52137. case 'link':
  52138. // 插入超链接
  52139. return concat$5(_context11 = "".concat(selection, "[")).call(_context11, this.locale.link, "](http://url.com) ");
  52140. case 'image':
  52141. // 插入图片,调用上传文件逻辑
  52142. this.handleUpload('image');
  52143. return selection;
  52144. case 'video':
  52145. // 插入视频,调用上传文件逻辑
  52146. this.handleUpload('video');
  52147. return selection;
  52148. case 'audio':
  52149. // 插入音频,调用上传文件逻辑
  52150. this.handleUpload('audio');
  52151. return selection;
  52152. case 'table':
  52153. // 插入表格,会出现一个二维面板,用户可以通过点击决定插入表格的行号和列号
  52154. // TODO: 菜单定位方式调整,空行判断
  52155. this.subBubbleTableMenu.dom.style.left = this.subMenu.dom.style.left;
  52156. this.subBubbleTableMenu.dom.style.top = this.subMenu.dom.style.top;
  52157. this.subBubbleTableMenu.show(function (row, col) {
  52158. var _context12, _context13, _context14, _context15, _context16, _context17;
  52159. var headerText = repeat$3(_context12 = ' Header |').call(_context12, col);
  52160. var controlText = repeat$3(_context13 = ' ------ |').call(_context13, col);
  52161. var rowText = "\n|".concat(repeat$3(_context14 = ' Sample |').call(_context14, col));
  52162. var text = concat$5(_context15 = concat$5(_context16 = concat$5(_context17 = "".concat(selection, "\n\n|")).call(_context17, headerText, "\n|")).call(_context16, controlText)).call(_context15, repeat$3(rowText).call(rowText, row), "\n\n");
  52163. callback(text);
  52164. });
  52165. return;
  52166. case 'line-table':
  52167. // 插入带折线图的表格
  52168. return concat$5(_context18 = "".concat(selection, "\n\n")).call(_context18, ['| :line: {x,y} | a | b | c |', '| :-: | :-: | :-: | :-: |', '| x | 1 | 2 | 3 |', '| y | 2 | 4 | 6 |', '| z | 7 | 5 | 3 |'].join('\n'), "\n\n");
  52169. case 'bar-table':
  52170. // 插入带柱状图的表格
  52171. return concat$5(_context19 = "".concat(selection, "\n\n")).call(_context19, ['| :bar: {x,y} | a | b | c |', '| :-: | :-: | :-: | :-: |', '| x | 1 | 2 | 3 |', '| y | 2 | 4 | 6 |', '| z | 7 | 5 | 3 |'].join('\n'), "\n\n");
  52172. case 'headlessTable':
  52173. // 插入没有表头的表格
  52174. // 该表格语法是源于[TAPD](https://tapd.cn) wiki应用里的一种表格语法
  52175. // 该表格语法不是markdown通用语法,请慎用
  52176. // TODO: 菜单定位方式调整, 空行判断
  52177. this.subBubbleTableMenu.dom.style.left = this.subMenu.dom.style.left;
  52178. this.subBubbleTableMenu.dom.style.top = this.subMenu.dom.style.top;
  52179. this.subBubbleTableMenu.show(function (row, col) {
  52180. var _context20, _context21, _context22, _context23, _context24;
  52181. var text = concat$5(_context20 = concat$5(_context21 = "".concat(selection, "\n\n||")).call(_context21, repeat$3(_context22 = ' ~Header ||').call(_context22, col))).call(_context20, repeat$3(_context23 = "\n||".concat(repeat$3(_context24 = ' SampleT ||').call(_context24, col))).call(_context23, row - 1), "\n\n");
  52182. callback(text);
  52183. });
  52184. return;
  52185. case 'pdf':
  52186. // 插入pdf文件,调用上传文件逻辑
  52187. this.handleUpload('pdf');
  52188. return selection;
  52189. case 'word':
  52190. // 插入word,调用上传文件逻辑
  52191. // 可以在文件上传逻辑里做处理,word上传后通过后台服务转成html再返回,前端接受后进行处理并回填
  52192. this.handleUpload('word');
  52193. return selection;
  52194. case 'ruby':
  52195. // 如果选中的文本中已经有ruby语法了,则去掉该语法
  52196. if (/^\s*\{[\s\S]+\|[\s\S]+\}/.test($selection)) {
  52197. return $selection.replace(/^\s*\{\s*([\s\S]+?)\s*\|[\s\S]+\}\s*/gm, '$1');
  52198. }
  52199. return concat$5(_context25 = " { ".concat($selection, " | ")).call(_context25, trim$3(_context26 = this.editor.$cherry.options.callback.changeString2Pinyin($selection)).call(_context26), " } ");
  52200. }
  52201. }
  52202. }]);
  52203. return Insert;
  52204. }(MenuBase);
  52205. function _createSuper$I(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$I(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  52206. function _isNativeReflectConstruct$I() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  52207. /**
  52208. * 插入有序/无序/checklist列表的按钮
  52209. */
  52210. var List$1 = /*#__PURE__*/function (_MenuBase) {
  52211. _inherits(List, _MenuBase);
  52212. var _super = _createSuper$I(List);
  52213. function List($cherry) {
  52214. var _context, _context2, _context3;
  52215. var _this;
  52216. _classCallCheck(this, List);
  52217. _this = _super.call(this, $cherry);
  52218. _this.setName('list', 'list');
  52219. _this.subMenuConfig = [{
  52220. iconName: 'ol',
  52221. name: 'ol',
  52222. onclick: bind$5(_context = _this.bindSubClick).call(_context, _assertThisInitialized(_this), '1')
  52223. }, {
  52224. iconName: 'ul',
  52225. name: 'ul',
  52226. onclick: bind$5(_context2 = _this.bindSubClick).call(_context2, _assertThisInitialized(_this), '2')
  52227. }, {
  52228. iconName: 'checklist',
  52229. name: 'checklist',
  52230. onclick: bind$5(_context3 = _this.bindSubClick).call(_context3, _assertThisInitialized(_this), '3')
  52231. }];
  52232. return _this;
  52233. }
  52234. _createClass(List, [{
  52235. key: "getSubMenuConfig",
  52236. value: function getSubMenuConfig() {
  52237. return this.subMenuConfig;
  52238. }
  52239. /**
  52240. * 响应点击事件
  52241. * @param {string} selection 编辑区选中的文本内容
  52242. * @param {string} shortKey 快捷键:ol 有序列表,ul 无序列表,checklist 检查项
  52243. * @returns 对应markdown的源码
  52244. */
  52245. }, {
  52246. key: "onClick",
  52247. value: function onClick(selection) {
  52248. var shortKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  52249. var listType = [null, 'ol', 'ul', 'checklist']; // 下标1, 2, 3生效
  52250. var $selection = getSelection(this.editor.editor, selection, 'line', true);
  52251. var _$selection$match = $selection.match(/^\n*/),
  52252. _$selection$match2 = _slicedToArray(_$selection$match, 1),
  52253. before = _$selection$match2[0];
  52254. var _$selection$match3 = $selection.match(/\n*$/),
  52255. _$selection$match4 = _slicedToArray(_$selection$match3, 1),
  52256. after = _$selection$match4[0];
  52257. if (listType[shortKey] !== null) {
  52258. var _context4, _context5;
  52259. return concat$5(_context4 = concat$5(_context5 = "".concat(before)).call(_context5, getListFromStr($selection, listType[shortKey]))).call(_context4, after);
  52260. }
  52261. return $selection;
  52262. }
  52263. }]);
  52264. return List;
  52265. }(MenuBase);
  52266. function _createSuper$J(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$J(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  52267. function _isNativeReflectConstruct$J() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  52268. /**
  52269. * 下标的按钮
  52270. **/
  52271. var Ol = /*#__PURE__*/function (_MenuBase) {
  52272. _inherits(Ol, _MenuBase);
  52273. var _super = _createSuper$J(Ol);
  52274. function Ol($cherry) {
  52275. var _this;
  52276. _classCallCheck(this, Ol);
  52277. _this = _super.call(this, $cherry);
  52278. _this.setName('ol', 'ol');
  52279. return _this;
  52280. }
  52281. /**
  52282. *
  52283. * @param {string} selection 被用户选中的文本内容
  52284. * @param {string} shortKey 快捷键参数,本函数不处理这个参数
  52285. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  52286. */
  52287. _createClass(Ol, [{
  52288. key: "onClick",
  52289. value: function onClick(selection) {
  52290. var _context, _context2;
  52291. var $selection = getSelection(this.editor.editor, selection, 'line', true) || 'Item 1\n Item 1.1\nItem 2';
  52292. var _$selection$match = $selection.match(/^\n*/),
  52293. _$selection$match2 = _slicedToArray(_$selection$match, 1),
  52294. before = _$selection$match2[0];
  52295. var _$selection$match3 = $selection.match(/\n*$/),
  52296. _$selection$match4 = _slicedToArray(_$selection$match3, 1),
  52297. after = _$selection$match4[0];
  52298. return concat$5(_context = concat$5(_context2 = "".concat(before)).call(_context2, getListFromStr($selection, 'ol'))).call(_context, after);
  52299. }
  52300. }]);
  52301. return Ol;
  52302. }(MenuBase);
  52303. function _createSuper$K(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$K(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  52304. function _isNativeReflectConstruct$K() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  52305. /**
  52306. * 下标的按钮
  52307. **/
  52308. var Ul = /*#__PURE__*/function (_MenuBase) {
  52309. _inherits(Ul, _MenuBase);
  52310. var _super = _createSuper$K(Ul);
  52311. function Ul($cherry) {
  52312. var _this;
  52313. _classCallCheck(this, Ul);
  52314. _this = _super.call(this, $cherry);
  52315. _this.setName('ul', 'ul');
  52316. return _this;
  52317. }
  52318. /**
  52319. *
  52320. * @param {string} selection 被用户选中的文本内容
  52321. * @param {string} shortKey 快捷键参数,本函数不处理这个参数
  52322. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  52323. */
  52324. _createClass(Ul, [{
  52325. key: "onClick",
  52326. value: function onClick(selection) {
  52327. var _context, _context2;
  52328. var $selection = getSelection(this.editor.editor, selection, 'line', true) || 'Item 1\n Item 1.1\nItem 2';
  52329. var _$selection$match = $selection.match(/^\n*/),
  52330. _$selection$match2 = _slicedToArray(_$selection$match, 1),
  52331. before = _$selection$match2[0];
  52332. var _$selection$match3 = $selection.match(/\n*$/),
  52333. _$selection$match4 = _slicedToArray(_$selection$match3, 1),
  52334. after = _$selection$match4[0];
  52335. return concat$5(_context = concat$5(_context2 = "".concat(before)).call(_context2, getListFromStr($selection, 'ul'))).call(_context, after);
  52336. }
  52337. }]);
  52338. return Ul;
  52339. }(MenuBase);
  52340. function _createSuper$L(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$L(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  52341. function _isNativeReflectConstruct$L() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  52342. /**
  52343. * 下标的按钮
  52344. **/
  52345. var Checklist = /*#__PURE__*/function (_MenuBase) {
  52346. _inherits(Checklist, _MenuBase);
  52347. var _super = _createSuper$L(Checklist);
  52348. function Checklist($cherry) {
  52349. var _this;
  52350. _classCallCheck(this, Checklist);
  52351. _this = _super.call(this, $cherry);
  52352. _this.setName('checklist', 'checklist');
  52353. return _this;
  52354. }
  52355. /**
  52356. *
  52357. * @param {string} selection 被用户选中的文本内容
  52358. * @param {string} shortKey 快捷键参数,本函数不处理这个参数
  52359. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  52360. */
  52361. _createClass(Checklist, [{
  52362. key: "onClick",
  52363. value: function onClick(selection) {
  52364. var _context, _context2;
  52365. var $selection = getSelection(this.editor.editor, selection, 'line', true) || 'Item 1\n Item 1.1\nItem 2';
  52366. var _$selection$match = $selection.match(/^\n*/),
  52367. _$selection$match2 = _slicedToArray(_$selection$match, 1),
  52368. before = _$selection$match2[0];
  52369. var _$selection$match3 = $selection.match(/\n*$/),
  52370. _$selection$match4 = _slicedToArray(_$selection$match3, 1),
  52371. after = _$selection$match4[0];
  52372. return concat$5(_context = concat$5(_context2 = "".concat(before)).call(_context2, getListFromStr($selection, 'checklist'))).call(_context, after);
  52373. }
  52374. }]);
  52375. return Checklist;
  52376. }(MenuBase);
  52377. function _createSuper$M(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$M(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  52378. function _isNativeReflectConstruct$M() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  52379. function generateExample(title, mermaidCode) {
  52380. return [title, '```mermaid', mermaidCode, '```'].join('\n');
  52381. }
  52382. var flowChartContent = ['\tA[公司] -->| 下 班 | B(菜市场)', '\tB --> C{看见<br>卖西瓜的}', '\tC -->|Yes| D[买一个包子]', '\tC -->|No| E[买一斤包子]'].join('\n');
  52383. var sample = {
  52384. flow: ['FlowChart', generateExample('左右结构', "graph LR\n".concat(flowChartContent)), generateExample('上下结构', "graph TD\n".concat(flowChartContent))].join('\n'),
  52385. sequence: generateExample('SequenceDiagram', ['sequenceDiagram', 'autonumber', 'A-->A: 文本1', 'A->>B: 文本2', 'loop 循环1', 'loop 循环2', 'A->B: 文本3', 'end', 'loop 循环3', 'B -->>A: 文本4', 'end', 'B -->> B: 文本5', 'end'].join('\n')),
  52386. state: generateExample('StateDiagram', ['stateDiagram-v2', '[*] --> A', 'A --> B', 'A --> C', 'state A {', ' \t[*] --> D', ' \tD --> [*]', '}', 'B --> [*]', 'C --> [*]'].join('\n')),
  52387. "class": generateExample('ClassDiagram', ['classDiagram', 'Base <|-- One', 'Base <|-- Two', 'Base : +String name', 'Base: +getName()', 'Base: +setName(String name)', 'class One{', ' \t+String newName', ' \t+getNewName()', '}', 'class Two{', ' \t-int id', ' \t-getId()', '}'].join('\n')),
  52388. pie: generateExample('PieChart', ['pie', 'title 饼图', '"A" : 100', '"B" : 80', '"C" : 40', '"D" : 30'].join('\n')),
  52389. gantt: generateExample('GanttChart', ['gantt', '\ttitle 敏捷研发流程', '\tsection 迭代前', '\t\t交互设计 :a1, 2020-03-01, 4d', '\t\tUI设计 :after a1, 5d', '\t\t需求评审 : 1d', '\tsection 迭代中', '\t\t详细设计 :a2, 2020-03-11, 2d', '\t\t开发 :2020-03-15, 7d', '\t\t测试 :2020-03-22, 5d', '\tsection 迭代后', '\t\t发布: 1d', '\t\t验收: 2d', '\t\t回顾: 1d'].join('\n'))
  52390. };
  52391. /**
  52392. * 插入“画图”的按钮
  52393. * 本功能依赖[Mermaid.js](https://mermaid-js.github.io)组件,请保证调用CherryMarkdown前已加载mermaid.js组件
  52394. */
  52395. var Graph = /*#__PURE__*/function (_MenuBase) {
  52396. _inherits(Graph, _MenuBase);
  52397. var _super = _createSuper$M(Graph);
  52398. function Graph($cherry) {
  52399. var _context, _context2, _context3, _context4, _context5, _context6;
  52400. var _this;
  52401. _classCallCheck(this, Graph);
  52402. _this = _super.call(this, $cherry);
  52403. _this.setName('graph', 'insertChart');
  52404. _this.noIcon = true;
  52405. _this.subMenuConfig = [// 流程图
  52406. // 访问[Mermaid 流程图](https://mermaid-js.github.io/mermaid/#/flowchart)参考具体使用方法。
  52407. {
  52408. iconName: 'insertFlow',
  52409. name: 'insertFlow',
  52410. onclick: bind$5(_context = _this.bindSubClick).call(_context, _assertThisInitialized(_this), '1')
  52411. }, // 时序图
  52412. // 访问[Mermaid 时序图](https://mermaid-js.github.io/mermaid/#/sequenceDiagram)参考具体使用方法
  52413. {
  52414. iconName: 'insertSeq',
  52415. name: 'insertSeq',
  52416. onclick: bind$5(_context2 = _this.bindSubClick).call(_context2, _assertThisInitialized(_this), '2')
  52417. }, // 状态图
  52418. // 访问[Mermaid 状态图](https://mermaid-js.github.io/mermaid/#/stateDiagram)参考具体使用方法
  52419. {
  52420. iconName: 'insertState',
  52421. name: 'insertState',
  52422. onclick: bind$5(_context3 = _this.bindSubClick).call(_context3, _assertThisInitialized(_this), '3')
  52423. }, // 类图
  52424. // 访问[Mermaid UML图](https://mermaid-js.github.io/mermaid/#/classDiagram)参考具体使用方法
  52425. {
  52426. iconName: 'insertClass',
  52427. name: 'insertClass',
  52428. onclick: bind$5(_context4 = _this.bindSubClick).call(_context4, _assertThisInitialized(_this), '4')
  52429. }, // 饼图
  52430. // 访问[Mermaid 饼图](https://mermaid-js.github.io/mermaid/#/pie)参考具体使用方法
  52431. {
  52432. iconName: 'insertPie',
  52433. name: 'insertPie',
  52434. onclick: bind$5(_context5 = _this.bindSubClick).call(_context5, _assertThisInitialized(_this), '5')
  52435. }, // 甘特图
  52436. {
  52437. iconName: 'insertGantt',
  52438. name: 'insertGantt',
  52439. onclick: bind$5(_context6 = _this.bindSubClick).call(_context6, _assertThisInitialized(_this), '6')
  52440. }];
  52441. return _this;
  52442. }
  52443. _createClass(Graph, [{
  52444. key: "getSubMenuConfig",
  52445. value: function getSubMenuConfig() {
  52446. return this.subMenuConfig;
  52447. }
  52448. /**
  52449. * 响应点击事件
  52450. * @param {string} selection 被用户选中的文本内容,本函数不处理选中的内容,会直接清空用户选中的内容
  52451. * @param {string} shortKey 快捷键参数
  52452. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  52453. */
  52454. }, {
  52455. key: "onClick",
  52456. value: function onClick(selection) {
  52457. var _this2 = this;
  52458. var shortKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  52459. var shortcut = "".concat(shortKey);
  52460. var shortcutKeyMap = [, 'flow', 'sequence', 'state', 'class', 'pie', 'gantt'];
  52461. var selectedExample = shortcutKeyMap[+shortcut];
  52462. if (!shortcutKeyMap[+shortcut]) {
  52463. return;
  52464. }
  52465. this.registerAfterClickCb(function () {
  52466. _this2.setLessSelection('\n\n\n\n\n', '\n\n');
  52467. });
  52468. return "\n\n".concat(this.$getSampleCode(selectedExample), "\n");
  52469. }
  52470. /**
  52471. * 画图的markdown源码模版
  52472. * @param {string} type 画图的类型
  52473. * @returns
  52474. */
  52475. }, {
  52476. key: "$getSampleCode",
  52477. value: function $getSampleCode(type) {
  52478. return sample[type].replace(/\t/g, ' ');
  52479. }
  52480. }]);
  52481. return Graph;
  52482. }(MenuBase);
  52483. function _createSuper$N(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$N(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  52484. function _isNativeReflectConstruct$N() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  52485. var Size$1 = /*#__PURE__*/function (_MenuBase) {
  52486. _inherits(Size, _MenuBase);
  52487. var _super = _createSuper$N(Size);
  52488. function Size($cherry) {
  52489. var _context, _context2, _context3, _context4;
  52490. var _this;
  52491. _classCallCheck(this, Size);
  52492. _this = _super.call(this, $cherry);
  52493. _this.setName('size', 'size');
  52494. _this.subMenuConfig = [{
  52495. name: '小',
  52496. noIcon: true,
  52497. onclick: bind$5(_context = _this.bindSubClick).call(_context, _assertThisInitialized(_this), '12')
  52498. }, {
  52499. name: '中',
  52500. noIcon: true,
  52501. onclick: bind$5(_context2 = _this.bindSubClick).call(_context2, _assertThisInitialized(_this), '17')
  52502. }, {
  52503. name: '大',
  52504. noIcon: true,
  52505. onclick: bind$5(_context3 = _this.bindSubClick).call(_context3, _assertThisInitialized(_this), '24')
  52506. }, {
  52507. name: '特大',
  52508. noIcon: true,
  52509. onclick: bind$5(_context4 = _this.bindSubClick).call(_context4, _assertThisInitialized(_this), '32')
  52510. }];
  52511. _this.shortKeyMap = {
  52512. 'Alt-1': '12',
  52513. 'Alt-2': '17',
  52514. 'Alt-3': '24',
  52515. 'Alt-4': '32'
  52516. };
  52517. return _this;
  52518. }
  52519. _createClass(Size, [{
  52520. key: "getSubMenuConfig",
  52521. value: function getSubMenuConfig() {
  52522. return this.subMenuConfig;
  52523. }
  52524. }, {
  52525. key: "_getFlagStr",
  52526. value: function _getFlagStr(shortKey) {
  52527. var test = shortKey.replace(/[^0-9]+([0-9])/g, '$1');
  52528. var header = '#';
  52529. for (var i = 1; i < test; i++) {
  52530. header += '#';
  52531. }
  52532. return header;
  52533. }
  52534. }, {
  52535. key: "$testIsSize",
  52536. value: function $testIsSize(selection) {
  52537. return /^\s*(![0-9]+) [\s\S]+!/.test(selection);
  52538. }
  52539. }, {
  52540. key: "$getSizeByShortKey",
  52541. value: function $getSizeByShortKey(shortKey) {
  52542. if (/^[0-9]+$/.test(shortKey)) {
  52543. return shortKey;
  52544. }
  52545. return this.shortKeyMap[shortKey] || '17';
  52546. }
  52547. }, {
  52548. key: "onClick",
  52549. value: function onClick(selection) {
  52550. var _this2 = this;
  52551. var shortKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '17';
  52552. var size = this.$getSizeByShortKey(shortKey);
  52553. var $selection = getSelection(this.editor.editor, selection) || '字号'; // 如果选中的内容里有字号语法,则直接去掉该语法
  52554. if (!this.isSelections && !this.$testIsSize($selection)) {
  52555. this.getMoreSelection('!32 ', '!', function () {
  52556. var newSelection = _this2.editor.editor.getSelection();
  52557. if (_this2.$testIsSize(newSelection)) {
  52558. $selection = newSelection;
  52559. return true;
  52560. }
  52561. return false;
  52562. });
  52563. }
  52564. if (this.$testIsSize($selection)) {
  52565. // 如果选中的内容里有字号语法,并且字号与目标一致,则去掉字号语法
  52566. // 反之,修改字号与目标一致
  52567. var needClean = true;
  52568. var tmp = $selection.replace(/(^)(\s*)(![0-9]+)([^\n]+)(!)(\s*)($)/gm, function (w, m1, m2, m3, m4, m5, m6, m7) {
  52569. var _context5, _context6, _context7, _context8, _context9, _context10;
  52570. needClean = needClean ? m3 === "!".concat(size) : false;
  52571. return concat$5(_context5 = concat$5(_context6 = concat$5(_context7 = concat$5(_context8 = concat$5(_context9 = concat$5(_context10 = "".concat(m1)).call(_context10, m2, "!")).call(_context9, size)).call(_context8, m4)).call(_context7, m5)).call(_context6, m6)).call(_context5, m7);
  52572. });
  52573. if (needClean) {
  52574. return $selection.replace(/(^)(\s*)(![0-9]+\s*)([^\n]+)(!)(\s*)($)/gm, '$1$4$7');
  52575. }
  52576. this.registerAfterClickCb(function () {
  52577. _this2.setLessSelection("!".concat(size, " "), '!');
  52578. });
  52579. return tmp;
  52580. }
  52581. this.registerAfterClickCb(function () {
  52582. _this2.setLessSelection("!".concat(size, " "), '!');
  52583. });
  52584. return $selection.replace(/(^)([^\n]+)($)/gm, "$1!".concat(size, " $2!$3"));
  52585. }
  52586. }, {
  52587. key: "shortcutKeys",
  52588. get: function get() {
  52589. return ['Alt-1', 'Alt-2', 'Alt-3', 'Alt-4'];
  52590. }
  52591. }]);
  52592. return Size;
  52593. }(MenuBase);
  52594. function _createSuper$O(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$O(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  52595. function _isNativeReflectConstruct$O() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  52596. /**
  52597. * 插入1级标题
  52598. */
  52599. var H1 = /*#__PURE__*/function (_MenuBase) {
  52600. _inherits(H1, _MenuBase);
  52601. var _super = _createSuper$O(H1);
  52602. function H1($cherry) {
  52603. var _this;
  52604. _classCallCheck(this, H1);
  52605. _this = _super.call(this, $cherry);
  52606. _this.setName('h1', 'h1');
  52607. return _this;
  52608. }
  52609. _createClass(H1, [{
  52610. key: "$testIsHead",
  52611. value: function $testIsHead(selection) {
  52612. return /^\s*(#+)\s*.+/.test(selection);
  52613. }
  52614. /**
  52615. * 响应点击事件
  52616. * @param {string} selection 被用户选中的文本内容
  52617. * @param {string} shortKey 快捷键参数,本函数不处理这个参数
  52618. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  52619. */
  52620. }, {
  52621. key: "onClick",
  52622. value: function onClick(selection) {
  52623. var _this2 = this;
  52624. var $selection = getSelection(this.editor.editor, selection, 'line', true) || this.locale.h1;
  52625. var header = '#';
  52626. if (!this.isSelections && !this.$testIsHead($selection)) {
  52627. this.getMoreSelection('\n', '', function () {
  52628. var newSelection = _this2.editor.editor.getSelection();
  52629. var isHead = _this2.$testIsHead(newSelection);
  52630. if (isHead) {
  52631. $selection = newSelection;
  52632. }
  52633. return isHead;
  52634. });
  52635. }
  52636. if (this.$testIsHead($selection)) {
  52637. // 如果选中的内容里有标题语法,并且标记级别与目标一致,则去掉标题语法
  52638. // 反之,修改标题级别与目标一致
  52639. var needClean = true;
  52640. var tmp = $selection.replace(/(^\s*)(#+)(\s*)(.+$)/gm, function (w, m1, m2, m3, m4) {
  52641. var _context, _context2, _context3;
  52642. needClean = needClean ? m2.length === header.length : false;
  52643. return concat$5(_context = concat$5(_context2 = concat$5(_context3 = "".concat(m1)).call(_context3, header)).call(_context2, m3)).call(_context, m4);
  52644. });
  52645. if (needClean) {
  52646. return $selection.replace(/(^\s*)(#+)(\s*)(.+$)/gm, '$1$4');
  52647. }
  52648. this.registerAfterClickCb(function () {
  52649. _this2.setLessSelection("".concat(header, " "), '');
  52650. });
  52651. return tmp;
  52652. }
  52653. this.registerAfterClickCb(function () {
  52654. _this2.setLessSelection("".concat(header, " "), '');
  52655. });
  52656. return $selection.replace(/(^)([\s]*)([^\n]+)($)/gm, "$1".concat(header, " $3$4"));
  52657. }
  52658. }]);
  52659. return H1;
  52660. }(MenuBase);
  52661. function _createSuper$P(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$P(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  52662. function _isNativeReflectConstruct$P() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  52663. /**
  52664. * 插入2级标题
  52665. */
  52666. var H2 = /*#__PURE__*/function (_MenuBase) {
  52667. _inherits(H2, _MenuBase);
  52668. var _super = _createSuper$P(H2);
  52669. function H2($cherry) {
  52670. var _this;
  52671. _classCallCheck(this, H2);
  52672. _this = _super.call(this, $cherry);
  52673. _this.setName('h2', 'h2');
  52674. return _this;
  52675. }
  52676. _createClass(H2, [{
  52677. key: "$testIsHead",
  52678. value: function $testIsHead(selection) {
  52679. return /^\s*(#+)\s*.+/.test(selection);
  52680. }
  52681. /**
  52682. * 响应点击事件
  52683. * @param {string} selection 被用户选中的文本内容
  52684. * @param {string} shortKey 快捷键参数,本函数不处理这个参数
  52685. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  52686. */
  52687. }, {
  52688. key: "onClick",
  52689. value: function onClick(selection) {
  52690. var _this2 = this;
  52691. var $selection = getSelection(this.editor.editor, selection, 'line', true) || this.locale.h2;
  52692. var header = '##';
  52693. if (!this.isSelections && !this.$testIsHead($selection)) {
  52694. this.getMoreSelection('\n', '', function () {
  52695. var newSelection = _this2.editor.editor.getSelection();
  52696. var isHead = _this2.$testIsHead(newSelection);
  52697. if (isHead) {
  52698. $selection = newSelection;
  52699. }
  52700. return isHead;
  52701. });
  52702. }
  52703. if (this.$testIsHead($selection)) {
  52704. // 如果选中的内容里有标题语法,并且标记级别与目标一致,则去掉标题语法
  52705. // 反之,修改标题级别与目标一致
  52706. var needClean = true;
  52707. var tmp = $selection.replace(/(^\s*)(#+)(\s*)(.+$)/gm, function (w, m1, m2, m3, m4) {
  52708. var _context, _context2, _context3;
  52709. needClean = needClean ? m2.length === header.length : false;
  52710. return concat$5(_context = concat$5(_context2 = concat$5(_context3 = "".concat(m1)).call(_context3, header)).call(_context2, m3)).call(_context, m4);
  52711. });
  52712. if (needClean) {
  52713. return $selection.replace(/(^\s*)(#+)(\s*)(.+$)/gm, '$1$4');
  52714. }
  52715. this.registerAfterClickCb(function () {
  52716. _this2.setLessSelection("".concat(header, " "), '');
  52717. });
  52718. return tmp;
  52719. }
  52720. this.registerAfterClickCb(function () {
  52721. _this2.setLessSelection("".concat(header, " "), '');
  52722. });
  52723. return $selection.replace(/(^)([\s]*)([^\n]+)($)/gm, "$1".concat(header, " $3$4"));
  52724. }
  52725. }]);
  52726. return H2;
  52727. }(MenuBase);
  52728. function _createSuper$Q(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$Q(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  52729. function _isNativeReflectConstruct$Q() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  52730. /**
  52731. * 插入3级标题
  52732. */
  52733. var H3 = /*#__PURE__*/function (_MenuBase) {
  52734. _inherits(H3, _MenuBase);
  52735. var _super = _createSuper$Q(H3);
  52736. function H3($cherry) {
  52737. var _this;
  52738. _classCallCheck(this, H3);
  52739. _this = _super.call(this, $cherry);
  52740. _this.setName('h3', 'h3');
  52741. return _this;
  52742. }
  52743. _createClass(H3, [{
  52744. key: "$testIsHead",
  52745. value: function $testIsHead(selection) {
  52746. return /^\s*(#+)\s*.+/.test(selection);
  52747. }
  52748. /**
  52749. * 响应点击事件
  52750. * @param {string} selection 被用户选中的文本内容
  52751. * @param {string} shortKey 快捷键参数,本函数不处理这个参数
  52752. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  52753. */
  52754. }, {
  52755. key: "onClick",
  52756. value: function onClick(selection) {
  52757. var _this2 = this;
  52758. var $selection = getSelection(this.editor.editor, selection, 'line', true) || this.locale.h3;
  52759. var header = '###';
  52760. if (!this.isSelections && !this.$testIsHead($selection)) {
  52761. this.getMoreSelection('\n', '', function () {
  52762. var newSelection = _this2.editor.editor.getSelection();
  52763. var isHead = _this2.$testIsHead(newSelection);
  52764. if (isHead) {
  52765. $selection = newSelection;
  52766. }
  52767. return isHead;
  52768. });
  52769. }
  52770. if (this.$testIsHead($selection)) {
  52771. // 如果选中的内容里有标题语法,并且标记级别与目标一致,则去掉标题语法
  52772. // 反之,修改标题级别与目标一致
  52773. var needClean = true;
  52774. var tmp = $selection.replace(/(^\s*)(#+)(\s*)(.+$)/gm, function (w, m1, m2, m3, m4) {
  52775. var _context, _context2, _context3;
  52776. needClean = needClean ? m2.length === header.length : false;
  52777. return concat$5(_context = concat$5(_context2 = concat$5(_context3 = "".concat(m1)).call(_context3, header)).call(_context2, m3)).call(_context, m4);
  52778. });
  52779. if (needClean) {
  52780. return $selection.replace(/(^\s*)(#+)(\s*)(.+$)/gm, '$1$4');
  52781. }
  52782. this.registerAfterClickCb(function () {
  52783. _this2.setLessSelection("".concat(header, " "), '');
  52784. });
  52785. return tmp;
  52786. }
  52787. this.registerAfterClickCb(function () {
  52788. _this2.setLessSelection("".concat(header, " "), '');
  52789. });
  52790. return $selection.replace(/(^)([\s]*)([^\n]+)($)/gm, "$1".concat(header, " $3$4"));
  52791. }
  52792. }]);
  52793. return H3;
  52794. }(MenuBase);
  52795. function _createSuper$R(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$R(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  52796. function _isNativeReflectConstruct$R() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  52797. /**
  52798. * 插入“引用”的按钮
  52799. */
  52800. var Quote = /*#__PURE__*/function (_MenuBase) {
  52801. _inherits(Quote, _MenuBase);
  52802. var _super = _createSuper$R(Quote);
  52803. function Quote($cherry) {
  52804. var _this;
  52805. _classCallCheck(this, Quote);
  52806. _this = _super.call(this, $cherry);
  52807. _this.setName('quote', 'blockquote');
  52808. return _this;
  52809. }
  52810. /**
  52811. * click handler
  52812. * @param {string} selection selection in editor
  52813. * @returns
  52814. */
  52815. _createClass(Quote, [{
  52816. key: "onClick",
  52817. value: function onClick(selection) {
  52818. var _context,
  52819. _this2 = this;
  52820. var $selection = getSelection(this.editor.editor, selection, 'line', true) || this.locale.quote;
  52821. var isWrapped = every$3(_context = $selection.split('\n')).call(_context, function (text) {
  52822. return /^\s*>[^\n]+$/.exec(text);
  52823. });
  52824. if (isWrapped) {
  52825. // 去掉>号
  52826. return $selection.replace(/(^\s*)>\s*([^\n]+)($)/gm, '$1$2$3').replace(/\n+$/, '\n\n');
  52827. }
  52828. this.registerAfterClickCb(function () {
  52829. _this2.setLessSelection('> ', '');
  52830. }); // 给每一行增加>号
  52831. return $selection.replace(/(^)([^\n]+)($)/gm, '$1> $2$3').replace(/\n+$/, '\n\n');
  52832. }
  52833. }]);
  52834. return Quote;
  52835. }(MenuBase);
  52836. function _createSuper$S(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$S(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  52837. function _isNativeReflectConstruct$S() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  52838. /**
  52839. * 插入“简单表格”的按钮
  52840. * 所谓简单表格,是源于[TAPD](https://tapd.cn) wiki应用里的一种表格语法
  52841. * 该表格语法不是markdown通用语法,请慎用
  52842. */
  52843. var QuickTable = /*#__PURE__*/function (_MenuBase) {
  52844. _inherits(QuickTable, _MenuBase);
  52845. var _super = _createSuper$S(QuickTable);
  52846. function QuickTable($cherry) {
  52847. var _this;
  52848. _classCallCheck(this, QuickTable);
  52849. _this = _super.call(this, $cherry);
  52850. _this.setName('quickTable', 'table');
  52851. return _this;
  52852. }
  52853. /**
  52854. * 响应点击事件
  52855. * @param {string} selection 编辑器里选中的内容
  52856. * @param {string} shortKey 本函数不处理快捷键
  52857. * @returns
  52858. */
  52859. _createClass(QuickTable, [{
  52860. key: "onClick",
  52861. value: function onClick(selection) {
  52862. // TODO:可以尝试解析下selection里的内容,按\s、\t区分列,按\n区分行
  52863. return "".concat(selection, "| LeftAlignedCol | CenterAlignedCol | RightAlignedCol |\n") + '| :--- | :---: | ---: |\n' + '| sampleText | sampleText | sampleText |\n' + '| **left**Text | centered Text | *right*Text |\n';
  52864. }
  52865. }]);
  52866. return QuickTable;
  52867. }(MenuBase);
  52868. function _createSuper$T(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$T(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  52869. function _isNativeReflectConstruct$T() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  52870. /**
  52871. * 关闭/展示预览区域的按钮
  52872. */
  52873. var TogglePreview = /*#__PURE__*/function (_MenuBase) {
  52874. _inherits(TogglePreview, _MenuBase);
  52875. var _super = _createSuper$T(TogglePreview);
  52876. /** @type {boolean} 当前预览状态 */
  52877. function TogglePreview($cherry) {
  52878. var _this;
  52879. _classCallCheck(this, TogglePreview);
  52880. _this = _super.call(this, $cherry);
  52881. _defineProperty(_assertThisInitialized(_this), "$previewerHidden", false);
  52882. _this.setName('previewClose', 'previewClose');
  52883. _this.instanceId = $cherry.instanceId;
  52884. _this.updateMarkdown = false;
  52885. _this.attachEventListeners();
  52886. return _this;
  52887. }
  52888. /**
  52889. * 绑定预览事件
  52890. */
  52891. _createClass(TogglePreview, [{
  52892. key: "attachEventListeners",
  52893. value: function attachEventListeners() {
  52894. var _this2 = this;
  52895. Event$1.on(this.instanceId, Event$1.Events.previewerClose, function () {
  52896. _this2.isHidden = true;
  52897. });
  52898. Event$1.on(this.instanceId, Event$1.Events.previewerOpen, function () {
  52899. _this2.isHidden = false;
  52900. });
  52901. }
  52902. }, {
  52903. key: "isHidden",
  52904. get: function get() {
  52905. return this.$previewerHidden;
  52906. },
  52907. set: function set(state) {
  52908. // 节流
  52909. if (state === this.$previewerHidden) {
  52910. return;
  52911. }
  52912. var icon = this.dom.querySelector('i'); // 隐藏预览,按钮状态为打开预览
  52913. if (state) {
  52914. icon.classList.toggle('ch-icon-previewClose', false);
  52915. icon.classList.toggle('ch-icon-preview', true);
  52916. icon.title = this.locale.togglePreview;
  52917. } else {
  52918. icon.classList.toggle('ch-icon-previewClose', true);
  52919. icon.classList.toggle('ch-icon-preview', false);
  52920. icon.title = this.locale.previewClose;
  52921. }
  52922. this.$previewerHidden = state;
  52923. }
  52924. /**
  52925. * 响应点击事件
  52926. */
  52927. }, {
  52928. key: "onClick",
  52929. value: function onClick() {
  52930. if (this.editor.previewer.isPreviewerHidden()) {
  52931. this.editor.previewer.recoverPreviewer(true);
  52932. this.isHidden = false;
  52933. } else {
  52934. this.editor.previewer.editOnly(true);
  52935. this.isHidden = true;
  52936. }
  52937. }
  52938. }]);
  52939. return TogglePreview;
  52940. }(MenuBase);
  52941. function _createSuper$U(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$U(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  52942. function _isNativeReflectConstruct$U() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  52943. /**
  52944. * 全屏按钮
  52945. */
  52946. var FullScreen = /*#__PURE__*/function (_MenuBase) {
  52947. _inherits(FullScreen, _MenuBase);
  52948. var _super = _createSuper$U(FullScreen);
  52949. function FullScreen($cherry) {
  52950. var _this;
  52951. _classCallCheck(this, FullScreen);
  52952. _this = _super.call(this, $cherry);
  52953. _this.updateMarkdown = false;
  52954. _this.setName('fullScreen', 'fullscreen');
  52955. return _this;
  52956. }
  52957. /**
  52958. * 响应点击事件
  52959. */
  52960. _createClass(FullScreen, [{
  52961. key: "onClick",
  52962. value: function onClick() {
  52963. var cherryClass = this.editor.options.editorDom.parentElement.classList;
  52964. var cherryToolbarFullscreen = document.querySelector('.cherry-toolbar-fullscreen');
  52965. while (cherryToolbarFullscreen.firstChild) {
  52966. // 循环删除父元素下的第一个子元素,直到父元素下没有子元素
  52967. cherryToolbarFullscreen.removeChild(cherryToolbarFullscreen.firstChild);
  52968. }
  52969. if (cherryClass.contains('fullscreen')) {
  52970. var fullScreen = createElement('i', 'ch-icon ch-icon-fullscreen');
  52971. cherryToolbarFullscreen.appendChild(fullScreen);
  52972. cherryClass.remove('fullscreen');
  52973. } else {
  52974. var minScreen = createElement('i', 'ch-icon ch-icon-minscreen');
  52975. cherryToolbarFullscreen.appendChild(minScreen);
  52976. cherryClass.add('fullscreen');
  52977. }
  52978. this.editor.editor.refresh();
  52979. }
  52980. }]);
  52981. return FullScreen;
  52982. }(MenuBase);
  52983. function _createSuper$V(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$V(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  52984. function _isNativeReflectConstruct$V() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  52985. /**
  52986. * 撤销回退按钮,点击后触发编辑器的undo操作
  52987. * 依赖codemirror的undo接口
  52988. **/
  52989. var Undo = /*#__PURE__*/function (_MenuBase) {
  52990. _inherits(Undo, _MenuBase);
  52991. var _super = _createSuper$V(Undo);
  52992. function Undo($cherry) {
  52993. var _this;
  52994. _classCallCheck(this, Undo);
  52995. _this = _super.call(this, $cherry);
  52996. _this.setName('undo', 'undo');
  52997. return _this;
  52998. }
  52999. _createClass(Undo, [{
  53000. key: "onClick",
  53001. value: function onClick() {
  53002. this.editor.editor.undo();
  53003. }
  53004. }]);
  53005. return Undo;
  53006. }(MenuBase);
  53007. function _createSuper$W(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$W(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53008. function _isNativeReflectConstruct$W() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53009. /**
  53010. * 撤销/重做 里的“重做”按键
  53011. * 依赖codemirror的undo接口
  53012. */
  53013. var Redo = /*#__PURE__*/function (_MenuBase) {
  53014. _inherits(Redo, _MenuBase);
  53015. var _super = _createSuper$W(Redo);
  53016. function Redo($cherry) {
  53017. var _this;
  53018. _classCallCheck(this, Redo);
  53019. _this = _super.call(this, $cherry);
  53020. _this.setName('redo', 'redo');
  53021. return _this;
  53022. }
  53023. /**
  53024. * 直接调用codemirror的redo方法就好了
  53025. */
  53026. _createClass(Redo, [{
  53027. key: "onClick",
  53028. value: function onClick() {
  53029. this.editor.editor.redo();
  53030. }
  53031. }]);
  53032. return Redo;
  53033. }(MenuBase);
  53034. function _createSuper$X(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$X(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53035. function _isNativeReflectConstruct$X() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53036. /**
  53037. * 插入代码块的按钮
  53038. */
  53039. var Code = /*#__PURE__*/function (_MenuBase) {
  53040. _inherits(Code, _MenuBase);
  53041. var _super = _createSuper$X(Code);
  53042. function Code($cherry) {
  53043. var _this;
  53044. _classCallCheck(this, Code);
  53045. _this = _super.call(this, $cherry);
  53046. _this.setName('code', 'code');
  53047. return _this;
  53048. }
  53049. /**
  53050. * 响应点击事件
  53051. * @param {string} selection 被用户选中的文本内容
  53052. * @param {string} shortKey 快捷键参数,本函数不处理这个参数
  53053. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  53054. */
  53055. _createClass(Code, [{
  53056. key: "onClick",
  53057. value: function onClick(selection) {
  53058. var _this2 = this;
  53059. var code = selection ? selection : 'code...';
  53060. this.registerAfterClickCb(function () {
  53061. _this2.setLessSelection("\n``` \n", "\n```\n");
  53062. });
  53063. return "\n``` \n".concat(code, "\n```\n");
  53064. }
  53065. /**
  53066. * 声明绑定的快捷键,快捷键触发onClick
  53067. */
  53068. }, {
  53069. key: "shortcutKeys",
  53070. get: function get() {
  53071. return ['Ctrl-k'];
  53072. }
  53073. }]);
  53074. return Code;
  53075. }(MenuBase);
  53076. function _createSuper$Y(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$Y(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53077. function _isNativeReflectConstruct$Y() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53078. /**
  53079. * 设置代码块的主题
  53080. * 本功能依赖[prism组件](https://github.com/PrismJS/prism)
  53081. */
  53082. var CodeTheme = /*#__PURE__*/function (_MenuBase) {
  53083. _inherits(CodeTheme, _MenuBase);
  53084. var _super = _createSuper$Y(CodeTheme);
  53085. function CodeTheme($cherry) {
  53086. var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8;
  53087. var _this;
  53088. _classCallCheck(this, CodeTheme);
  53089. _this = _super.call(this, $cherry);
  53090. _this.setName('codeTheme');
  53091. _this.iconName = "code-theme";
  53092. _this.updateMarkdown = false;
  53093. _this.subMenuConfig = [{
  53094. noIcon: true,
  53095. name: 'default',
  53096. onclick: bind$5(_context = _this.bindSubClick).call(_context, _assertThisInitialized(_this), 'default')
  53097. }, {
  53098. noIcon: true,
  53099. name: 'dark',
  53100. onclick: bind$5(_context2 = _this.bindSubClick).call(_context2, _assertThisInitialized(_this), 'dark')
  53101. }, {
  53102. noIcon: true,
  53103. name: 'funky',
  53104. onclick: bind$5(_context3 = _this.bindSubClick).call(_context3, _assertThisInitialized(_this), 'funky')
  53105. }, {
  53106. noIcon: true,
  53107. name: 'okaidia',
  53108. onclick: bind$5(_context4 = _this.bindSubClick).call(_context4, _assertThisInitialized(_this), 'okaidia')
  53109. }, {
  53110. noIcon: true,
  53111. name: 'twilight',
  53112. onclick: bind$5(_context5 = _this.bindSubClick).call(_context5, _assertThisInitialized(_this), 'twilight')
  53113. }, {
  53114. noIcon: true,
  53115. name: 'coy',
  53116. onclick: bind$5(_context6 = _this.bindSubClick).call(_context6, _assertThisInitialized(_this), 'coy')
  53117. }, {
  53118. noIcon: true,
  53119. name: 'solarized light',
  53120. onclick: bind$5(_context7 = _this.bindSubClick).call(_context7, _assertThisInitialized(_this), 'solarized-light')
  53121. }, {
  53122. noIcon: true,
  53123. name: 'tomorrow night',
  53124. onclick: bind$5(_context8 = _this.bindSubClick).call(_context8, _assertThisInitialized(_this), 'tomorrow-night')
  53125. }];
  53126. return _this;
  53127. }
  53128. /**
  53129. * 响应点击事件
  53130. * @param {string} shortKey 快捷键参数,本函数不处理这个参数
  53131. * @param {string} theme 具体的代码块主题
  53132. * @returns 回填到编辑器光标位置/选中文本区域的内容
  53133. */
  53134. _createClass(CodeTheme, [{
  53135. key: "onClick",
  53136. value: function onClick() {
  53137. var theme = arguments.length > 1 ? arguments[1] : undefined;
  53138. document.querySelector('.cherry').setAttribute('data-code-block-theme', theme);
  53139. }
  53140. }]);
  53141. return CodeTheme;
  53142. }(MenuBase);
  53143. function _createSuper$Z(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$Z(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53144. function _isNativeReflectConstruct$Z() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53145. var Export = /*#__PURE__*/function (_MenuBase) {
  53146. _inherits(Export, _MenuBase);
  53147. var _super = _createSuper$Z(Export);
  53148. function Export($cherry) {
  53149. var _context, _context2, _context3, _context4;
  53150. var _this;
  53151. _classCallCheck(this, Export);
  53152. _this = _super.call(this, $cherry);
  53153. _this.setName('export');
  53154. _this.iconName = "export";
  53155. _this.updateMarkdown = false;
  53156. _this.subMenuConfig = [{
  53157. noIcon: true,
  53158. name: 'exportToPdf',
  53159. onclick: bind$5(_context = _this.bindSubClick).call(_context, _assertThisInitialized(_this), 'pdf')
  53160. }, {
  53161. noIcon: true,
  53162. name: 'exportScreenshot',
  53163. onclick: bind$5(_context2 = _this.bindSubClick).call(_context2, _assertThisInitialized(_this), 'screenShot')
  53164. }, {
  53165. noIcon: true,
  53166. name: 'exportMarkdownFile',
  53167. onclick: bind$5(_context3 = _this.bindSubClick).call(_context3, _assertThisInitialized(_this), 'markdown')
  53168. }, {
  53169. noIcon: true,
  53170. name: 'exportHTMLFile',
  53171. onclick: bind$5(_context4 = _this.bindSubClick).call(_context4, _assertThisInitialized(_this), 'html')
  53172. }];
  53173. return _this;
  53174. }
  53175. _createClass(Export, [{
  53176. key: "onClick",
  53177. value: function onClick() {
  53178. var type = arguments.length > 1 ? arguments[1] : undefined;
  53179. if (document.querySelector('.cherry-dropdown[name=export]')) {
  53180. /** @type {HTMLElement}*/
  53181. document.querySelector('.cherry-dropdown[name=export]').style.display = 'none';
  53182. } // 强制刷新一下预览区域的内容
  53183. var previewer = this.$cherry.previewer;
  53184. var html = '';
  53185. if (previewer.isPreviewerHidden()) {
  53186. html = previewer.options.previewerCache.html;
  53187. } else {
  53188. html = previewer.getDomContainer().innerHTML;
  53189. } // 需要未加载的图片替换成原始图片
  53190. html = previewer.lazyLoadImg.changeDataSrc2Src(html);
  53191. previewer.refresh(html);
  53192. previewer["export"](type);
  53193. }
  53194. }]);
  53195. return Export;
  53196. }(MenuBase);
  53197. function _createSuper$_(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$_(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53198. function _isNativeReflectConstruct$_() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53199. /**
  53200. * 设置按钮
  53201. */
  53202. var Settings = /*#__PURE__*/function (_MenuBase) {
  53203. _inherits(Settings, _MenuBase);
  53204. var _super = _createSuper$_(Settings);
  53205. /**
  53206. * TODO: 需要优化参数传入方式
  53207. */
  53208. function Settings($cherry) {
  53209. var _this$engine$$cherry$, _context, _context2, _context3;
  53210. var _this;
  53211. _classCallCheck(this, Settings);
  53212. _this = _super.call(this, $cherry);
  53213. _this.setName('settings', 'settings');
  53214. _this.updateMarkdown = false;
  53215. _this.engine = $cherry.engine;
  53216. var classicBr = testKeyInLocal('classicBr') ? getIsClassicBrFromLocal() : (_this$engine$$cherry$ = _this.engine.$cherry.options.engine.global) === null || _this$engine$$cherry$ === void 0 ? void 0 : _this$engine$$cherry$.classicBr;
  53217. var defaultModel = $cherry.editor.options.defaultModel;
  53218. var classicBrIconName = classicBr ? 'br' : 'normal';
  53219. var classicBrName = classicBr ? 'classicBr' : 'normalBr';
  53220. var previewIcon = defaultModel === 'editOnly' ? 'preview' : 'previewClose';
  53221. var previewName = defaultModel === 'editOnly' ? 'togglePreview' : 'previewClose';
  53222. _this.instanceId = $cherry.instanceId;
  53223. _this.subMenuConfig = [{
  53224. iconName: classicBrIconName,
  53225. name: classicBrName,
  53226. onclick: bind$5(_context = _this.bindSubClick).call(_context, _assertThisInitialized(_this), 'classicBr')
  53227. }, {
  53228. iconName: previewIcon,
  53229. name: previewName,
  53230. onclick: bind$5(_context2 = _this.bindSubClick).call(_context2, _assertThisInitialized(_this), 'previewClose')
  53231. }, {
  53232. iconName: '',
  53233. name: 'hide',
  53234. onclick: bind$5(_context3 = _this.bindSubClick).call(_context3, _assertThisInitialized(_this), 'toggleToolbar')
  53235. }];
  53236. _this.attachEventListeners();
  53237. _this.shortcutKeyMaps = [{
  53238. shortKey: 'toggleToolbar',
  53239. shortcutKey: 'Ctrl-0'
  53240. }];
  53241. return _this;
  53242. }
  53243. /**
  53244. * 获取子菜单数组
  53245. * @returns {Array} 返回子菜单
  53246. */
  53247. _createClass(Settings, [{
  53248. key: "getSubMenuConfig",
  53249. value: function getSubMenuConfig() {
  53250. return this.subMenuConfig;
  53251. }
  53252. /**
  53253. * 监听快捷键,并触发回调
  53254. * @param {string} shortCut 快捷键
  53255. * @param {string} selection 编辑区选中的内容
  53256. * @param {boolean} [async] 是否异步
  53257. * @param {Function} [callback] 回调函数
  53258. * @returns
  53259. */
  53260. }, {
  53261. key: "bindSubClick",
  53262. value: function bindSubClick(shortCut, selection, async, callback) {
  53263. if (async) {
  53264. return this.onClick(selection, shortCut, callback);
  53265. }
  53266. return this.onClick(selection, shortCut);
  53267. }
  53268. /**
  53269. * 切换预览按钮
  53270. * @param {boolean} isOpen 预览模式是否打开
  53271. */
  53272. }, {
  53273. key: "togglePreviewBtn",
  53274. value: function togglePreviewBtn(isOpen) {
  53275. var _this2 = this;
  53276. var previewIcon = isOpen ? 'previewClose' : 'preview';
  53277. var previewName = isOpen ? 'previewClose' : 'togglePreview';
  53278. if (this.subMenu) {
  53279. var dropdown = document.querySelector('.cherry-dropdown[name="settings"]');
  53280. if (dropdown) {
  53281. var icon =
  53282. /** @type {HTMLElement} */
  53283. dropdown.querySelector('.ch-icon-previewClose,.ch-icon-preview');
  53284. icon.classList.toggle('ch-icon-previewClose');
  53285. icon.classList.toggle('ch-icon-preview');
  53286. icon.title = this.locale[previewName];
  53287. icon.parentElement.innerHTML = icon.parentElement.innerHTML.replace(/<\/i>.+$/, "</i>".concat(this.locale[previewName]));
  53288. }
  53289. } else {
  53290. var _context4;
  53291. this.subMenuConfig = map$3(_context4 = this.subMenuConfig).call(_context4, function (item) {
  53292. if (item.iconName === 'previewClose' || item.iconName === 'preview') {
  53293. var _context5;
  53294. return {
  53295. iconName: previewIcon,
  53296. name: previewName,
  53297. onclick: bind$5(_context5 = _this2.bindSubClick).call(_context5, _this2, 'previewClose')
  53298. };
  53299. }
  53300. return item;
  53301. });
  53302. }
  53303. }
  53304. /**
  53305. * 绑定预览事件
  53306. */
  53307. }, {
  53308. key: "attachEventListeners",
  53309. value: function attachEventListeners() {
  53310. var _this3 = this;
  53311. Event$1.on(this.instanceId, Event$1.Events.previewerClose, function () {
  53312. _this3.togglePreviewBtn(false);
  53313. });
  53314. Event$1.on(this.instanceId, Event$1.Events.previewerOpen, function () {
  53315. _this3.togglePreviewBtn(true);
  53316. });
  53317. }
  53318. /**
  53319. * 响应点击事件
  53320. * @param {string} selection 编辑区选中的内容
  53321. * @param {string} shortKey 快捷键
  53322. * @param {Function} [callback] 回调函数
  53323. * @returns
  53324. */
  53325. }, {
  53326. key: "onClick",
  53327. value: function onClick(selection) {
  53328. var shortKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  53329. // eslint-disable-next-line no-param-reassign
  53330. shortKey = this.matchShortcutKey(shortKey);
  53331. if (shortKey === 'classicBr') {
  53332. var _context6;
  53333. var targetIsClassicBr = !getIsClassicBrFromLocal();
  53334. saveIsClassicBrToLocal(targetIsClassicBr);
  53335. this.engine.$cherry.options.engine.global.classicBr = targetIsClassicBr;
  53336. forEach$3(_context6 = this.engine.hookCenter.hookList.paragraph).call(_context6, function (item) {
  53337. item.classicBr = targetIsClassicBr;
  53338. });
  53339. var i = this.$cherry.wrapperDom.querySelector('.cherry-dropdown .ch-icon-normal');
  53340. i = i ? i : this.$cherry.wrapperDom.querySelector('.cherry-dropdown .ch-icon-br');
  53341. if (targetIsClassicBr) {
  53342. i.classList.replace('ch-icon-normal', 'ch-icon-br');
  53343. i.parentElement.childNodes[1].textContent = this.locale.classicBr;
  53344. } else {
  53345. i.classList.replace('ch-icon-br', 'ch-icon-normal');
  53346. i.parentElement.childNodes[1].textContent = this.locale.normalBr;
  53347. }
  53348. this.engine.$cherry.previewer.update('');
  53349. this.engine.$cherry.initText(this.engine.$cherry.editor.editor);
  53350. } else if (shortKey === 'previewClose') {
  53351. if (this.editor.previewer.isPreviewerHidden()) {
  53352. this.editor.previewer.recoverPreviewer(true);
  53353. } else {
  53354. this.editor.previewer.editOnly(true);
  53355. }
  53356. } else if (shortKey === 'toggleToolbar') {
  53357. this.toggleToolbar();
  53358. }
  53359. return selection;
  53360. }
  53361. /**
  53362. * 解析快捷键
  53363. * @param {string} shortcutKey 快捷键
  53364. * @returns
  53365. */
  53366. }, {
  53367. key: "matchShortcutKey",
  53368. value: function matchShortcutKey(shortcutKey) {
  53369. var _context7;
  53370. var shortcutKeyMap = find$3(_context7 = this.shortcutKeyMaps).call(_context7, function (item) {
  53371. return item.shortcutKey === shortcutKey;
  53372. });
  53373. return shortcutKeyMap !== undefined ? shortcutKeyMap.shortKey : shortcutKey;
  53374. }
  53375. /**
  53376. * 切换Toolbar显示状态
  53377. */
  53378. }, {
  53379. key: "toggleToolbar",
  53380. value: function toggleToolbar() {
  53381. var wrapperDom = this.engine.$cherry.wrapperDom;
  53382. if (wrapperDom instanceof HTMLDivElement) {
  53383. var _context8;
  53384. var toolbarInstanceId = this.engine.$cherry.toolbar.instanceId;
  53385. if (indexOf$8(_context8 = wrapperDom.className).call(_context8, 'cherry--no-toolbar') > -1) {
  53386. wrapperDom.classList.remove('cherry--no-toolbar');
  53387. Event$1.emit(toolbarInstanceId, Event$1.Events.toolbarShow);
  53388. } else {
  53389. wrapperDom.classList.add('cherry--no-toolbar');
  53390. Event$1.emit(toolbarInstanceId, Event$1.Events.toolbarHide);
  53391. }
  53392. }
  53393. }
  53394. }, {
  53395. key: "shortcutKeys",
  53396. get: function get() {
  53397. var _context9;
  53398. return map$3(_context9 = this.shortcutKeyMaps).call(_context9, function (item) {
  53399. return item.shortcutKey;
  53400. });
  53401. }
  53402. }]);
  53403. return Settings;
  53404. }(MenuBase);
  53405. function _createSuper$$(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$$(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53406. function _isNativeReflectConstruct$$() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53407. /**
  53408. * 下划线按钮
  53409. **/
  53410. var Underline$1 = /*#__PURE__*/function (_MenuBase) {
  53411. _inherits(Underline, _MenuBase);
  53412. var _super = _createSuper$$(Underline);
  53413. function Underline($cherry) {
  53414. var _this;
  53415. _classCallCheck(this, Underline);
  53416. _this = _super.call(this, $cherry);
  53417. _this.setName('underline', 'underline');
  53418. return _this;
  53419. }
  53420. _createClass(Underline, [{
  53421. key: "$testIsUnderline",
  53422. value: function $testIsUnderline(selection) {
  53423. return /^\s*(\/)[\s\S]+(\1)/.test(selection);
  53424. }
  53425. /**
  53426. *
  53427. * @param {string} selection 被用户选中的文本内容
  53428. * @param {string} shortKey 快捷键参数,本函数不处理这个参数
  53429. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  53430. */
  53431. }, {
  53432. key: "onClick",
  53433. value: function onClick(selection) {
  53434. var _this2 = this;
  53435. var $selection = selection ? selection : this.locale.underline; // 如果选中的内容里有下划线语法,则认为是要去掉下划线语法
  53436. if (!this.isSelections && !this.$testIsUnderline($selection)) {
  53437. this.getMoreSelection(' /', '/ ', function () {
  53438. var newSelection = _this2.editor.editor.getSelection();
  53439. var isUnderline = _this2.$testIsUnderline(newSelection);
  53440. if (isUnderline) {
  53441. $selection = newSelection;
  53442. }
  53443. return isUnderline;
  53444. });
  53445. }
  53446. if (this.$testIsUnderline($selection)) {
  53447. return $selection.replace(/(^)(\s*)(\/)([^\n]+)(\3)(\s*)($)/gm, '$1$4$7');
  53448. }
  53449. this.registerAfterClickCb(function () {
  53450. _this2.setLessSelection(' /', '/ ');
  53451. }); // 如果选中的内容里没有下划线语法,则加上下划线
  53452. return $selection.replace(/(^)([^\n]+)($)/gm, '$1 /$2/ $3');
  53453. }
  53454. /**
  53455. * 声明绑定的快捷键,快捷键触发onClick
  53456. */
  53457. }, {
  53458. key: "shortcutKeys",
  53459. get: function get() {
  53460. return ['Ctrl-u'];
  53461. }
  53462. }]);
  53463. return Underline;
  53464. }(MenuBase);
  53465. function _createSuper$10(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$10(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53466. function _isNativeReflectConstruct$10() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53467. /**
  53468. * 切换预览/编辑模式的按钮
  53469. * 该按钮不支持切换到双栏编辑模式
  53470. * 只能切换成纯编辑模式和纯预览模式
  53471. **/
  53472. var SwitchModel = /*#__PURE__*/function (_MenuBase) {
  53473. _inherits(SwitchModel, _MenuBase);
  53474. var _super = _createSuper$10(SwitchModel);
  53475. function SwitchModel($cherry) {
  53476. var _this;
  53477. _classCallCheck(this, SwitchModel);
  53478. _this = _super.call(this, $cherry);
  53479. _this.setName('switchPreview');
  53480. _this.instanceId = $cherry.instanceId;
  53481. _this.attachEventListeners();
  53482. return _this;
  53483. }
  53484. _createClass(SwitchModel, [{
  53485. key: "attachEventListeners",
  53486. value: function attachEventListeners() {
  53487. var _this2 = this;
  53488. Event$1.on(this.instanceId, Event$1.Events.toolbarHide, function () {
  53489. // 当收到工具栏隐藏事件后,修改工具栏的内容为切换到编辑模式的内容
  53490. _this2.dom.textContent = _this2.locale.switchEdit;
  53491. });
  53492. Event$1.on(this.instanceId, Event$1.Events.toolbarShow, function () {
  53493. // 当收到工具栏显示事件后,修改工具栏的内容为切换到预览模式的内容
  53494. _this2.dom.textContent = _this2.locale.switchPreview;
  53495. });
  53496. }
  53497. }, {
  53498. key: "onClick",
  53499. value: function onClick() {
  53500. if (this.editor.previewer.isPreviewerHidden()) {
  53501. // 从编辑模式切换到预览模式
  53502. this.editor.previewer.previewOnly();
  53503. var toolbar = this.dom.parentElement.parentElement;
  53504. toolbar.classList.add('preview-only');
  53505. this.dom.textContent = this.locale.switchEdit;
  53506. } else {
  53507. // 从预览模式切换到编辑模式
  53508. this.editor.previewer.editOnly(true);
  53509. var _toolbar = this.dom.parentElement.parentElement;
  53510. _toolbar.classList.remove('preview-only');
  53511. this.dom.textContent = this.locale.switchPreview;
  53512. }
  53513. }
  53514. }]);
  53515. return SwitchModel;
  53516. }(MenuBase);
  53517. function _createSuper$11(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$11(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53518. function _isNativeReflectConstruct$11() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53519. /**
  53520. * 插入图片
  53521. */
  53522. var Image$2 = /*#__PURE__*/function (_MenuBase) {
  53523. _inherits(Image, _MenuBase);
  53524. var _super = _createSuper$11(Image);
  53525. function Image($cherry) {
  53526. var _this;
  53527. _classCallCheck(this, Image);
  53528. _this = _super.call(this, $cherry);
  53529. _this.setName('image', 'image');
  53530. return _this;
  53531. }
  53532. /**
  53533. * 响应点击事件
  53534. * @param {string} selection 被用户选中的文本内容
  53535. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  53536. */
  53537. _createClass(Image, [{
  53538. key: "onClick",
  53539. value: function onClick(selection) {
  53540. var _this2 = this,
  53541. _this$$cherry$options,
  53542. _this$$cherry$options2,
  53543. _this$$cherry$options3;
  53544. if (this.hasCacheOnce()) {
  53545. var _context, _context2;
  53546. // @ts-ignore
  53547. var _this$getAndCleanCach = this.getAndCleanCacheOnce(),
  53548. name = _this$getAndCleanCach.name,
  53549. url = _this$getAndCleanCach.url,
  53550. params = _this$getAndCleanCach.params;
  53551. var begin = '![';
  53552. var end = "](".concat(url, ")");
  53553. this.registerAfterClickCb(function () {
  53554. _this2.setLessSelection(begin, end);
  53555. });
  53556. var finalName = params.name ? params.name : name;
  53557. return concat$5(_context = concat$5(_context2 = "".concat(begin).concat(finalName)).call(_context2, handelParams(params))).call(_context, end);
  53558. }
  53559. var accept = (_this$$cherry$options = (_this$$cherry$options2 = this.$cherry.options) === null || _this$$cherry$options2 === void 0 ? void 0 : (_this$$cherry$options3 = _this$$cherry$options2.fileTypeLimitMap) === null || _this$$cherry$options3 === void 0 ? void 0 : _this$$cherry$options3.image) !== null && _this$$cherry$options !== void 0 ? _this$$cherry$options : '*'; // 插入图片,调用上传文件逻辑
  53560. handleUpload(this.editor, 'image', accept, function (name, url, params) {
  53561. _this2.setCacheOnce({
  53562. name: name,
  53563. url: url,
  53564. params: params
  53565. });
  53566. _this2.fire(null);
  53567. });
  53568. this.updateMarkdown = false;
  53569. return selection;
  53570. }
  53571. /**
  53572. * 声明绑定的快捷键,快捷键触发onClick
  53573. */
  53574. }, {
  53575. key: "shortcutKeys",
  53576. get: function get() {
  53577. return ['Ctrl-g'];
  53578. }
  53579. }]);
  53580. return Image;
  53581. }(MenuBase);
  53582. function _createSuper$12(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$12(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53583. function _isNativeReflectConstruct$12() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53584. /**
  53585. * 插入音频
  53586. */
  53587. var Audio = /*#__PURE__*/function (_MenuBase) {
  53588. _inherits(Audio, _MenuBase);
  53589. var _super = _createSuper$12(Audio);
  53590. function Audio($cherry) {
  53591. var _this;
  53592. _classCallCheck(this, Audio);
  53593. _this = _super.call(this, $cherry);
  53594. _this.setName('audio', 'video');
  53595. return _this;
  53596. }
  53597. /**
  53598. * 响应点击事件
  53599. * @param {string} selection 被用户选中的文本内容
  53600. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  53601. */
  53602. _createClass(Audio, [{
  53603. key: "onClick",
  53604. value: function onClick(selection) {
  53605. var _this2 = this,
  53606. _this$$cherry$options,
  53607. _this$$cherry$options2,
  53608. _this$$cherry$options3;
  53609. if (this.hasCacheOnce()) {
  53610. var _context, _context2;
  53611. // @ts-ignore
  53612. var _this$getAndCleanCach = this.getAndCleanCacheOnce(),
  53613. name = _this$getAndCleanCach.name,
  53614. url = _this$getAndCleanCach.url,
  53615. params = _this$getAndCleanCach.params;
  53616. var begin = '!audio[';
  53617. var end = "](".concat(url, ")");
  53618. this.registerAfterClickCb(function () {
  53619. _this2.setLessSelection(begin, end);
  53620. });
  53621. var finalName = params.name ? params.name : name;
  53622. return concat$5(_context = concat$5(_context2 = "".concat(begin).concat(finalName)).call(_context2, handelParams(params))).call(_context, end);
  53623. }
  53624. var accept = (_this$$cherry$options = (_this$$cherry$options2 = this.$cherry.options) === null || _this$$cherry$options2 === void 0 ? void 0 : (_this$$cherry$options3 = _this$$cherry$options2.fileTypeLimitMap) === null || _this$$cherry$options3 === void 0 ? void 0 : _this$$cherry$options3.audio) !== null && _this$$cherry$options !== void 0 ? _this$$cherry$options : '*'; // 插入图片,调用上传文件逻辑
  53625. handleUpload(this.editor, 'audio', accept, function (name, url, params) {
  53626. _this2.setCacheOnce({
  53627. name: name,
  53628. url: url,
  53629. params: params
  53630. });
  53631. _this2.fire(null);
  53632. });
  53633. this.updateMarkdown = false;
  53634. return selection;
  53635. }
  53636. }]);
  53637. return Audio;
  53638. }(MenuBase);
  53639. function _createSuper$13(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$13(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53640. function _isNativeReflectConstruct$13() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53641. /**
  53642. * 插入视频
  53643. */
  53644. var Video = /*#__PURE__*/function (_MenuBase) {
  53645. _inherits(Video, _MenuBase);
  53646. var _super = _createSuper$13(Video);
  53647. function Video($cherry) {
  53648. var _this;
  53649. _classCallCheck(this, Video);
  53650. _this = _super.call(this, $cherry);
  53651. _this.setName('video', 'video');
  53652. return _this;
  53653. }
  53654. /**
  53655. * 响应点击事件
  53656. * @param {string} selection 被用户选中的文本内容
  53657. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  53658. */
  53659. _createClass(Video, [{
  53660. key: "onClick",
  53661. value: function onClick(selection) {
  53662. var _this2 = this,
  53663. _this$$cherry$options,
  53664. _this$$cherry$options2,
  53665. _this$$cherry$options3;
  53666. if (this.hasCacheOnce()) {
  53667. var _context, _context2, _context3;
  53668. // @ts-ignore
  53669. var _this$getAndCleanCach = this.getAndCleanCacheOnce(),
  53670. name = _this$getAndCleanCach.name,
  53671. url = _this$getAndCleanCach.url,
  53672. params = _this$getAndCleanCach.params;
  53673. var begin = '!video[';
  53674. var end = params.poster ? concat$5(_context = "](".concat(url, "){poster=")).call(_context, params.poster, "}") : "](".concat(url, ")");
  53675. this.registerAfterClickCb(function () {
  53676. _this2.setLessSelection(begin, end);
  53677. });
  53678. var finalName = params.name ? params.name : name;
  53679. return concat$5(_context2 = concat$5(_context3 = "".concat(begin).concat(finalName)).call(_context3, handelParams(params))).call(_context2, end);
  53680. }
  53681. var accept = (_this$$cherry$options = (_this$$cherry$options2 = this.$cherry.options) === null || _this$$cherry$options2 === void 0 ? void 0 : (_this$$cherry$options3 = _this$$cherry$options2.fileTypeLimitMap) === null || _this$$cherry$options3 === void 0 ? void 0 : _this$$cherry$options3.video) !== null && _this$$cherry$options !== void 0 ? _this$$cherry$options : '*'; // 插入图片,调用上传文件逻辑
  53682. handleUpload(this.editor, 'video', accept, function (name, url, params) {
  53683. _this2.setCacheOnce({
  53684. name: name,
  53685. url: url,
  53686. params: params
  53687. });
  53688. _this2.fire(null);
  53689. });
  53690. this.updateMarkdown = false;
  53691. return selection;
  53692. }
  53693. }]);
  53694. return Video;
  53695. }(MenuBase);
  53696. function _createSuper$14(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$14(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53697. function _isNativeReflectConstruct$14() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53698. /**
  53699. * 插入换行
  53700. */
  53701. var Br$1 = /*#__PURE__*/function (_MenuBase) {
  53702. _inherits(Br, _MenuBase);
  53703. var _super = _createSuper$14(Br);
  53704. function Br($cherry) {
  53705. var _this;
  53706. _classCallCheck(this, Br);
  53707. _this = _super.call(this, $cherry);
  53708. _this.setName('br', 'br');
  53709. return _this;
  53710. }
  53711. /**
  53712. * 响应点击事件
  53713. * @param {string} selection 被用户选中的文本内容
  53714. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  53715. */
  53716. _createClass(Br, [{
  53717. key: "onClick",
  53718. value: function onClick(selection) {
  53719. return "".concat(selection, "<br>");
  53720. }
  53721. }]);
  53722. return Br;
  53723. }(MenuBase);
  53724. function _createSuper$15(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$15(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53725. function _isNativeReflectConstruct$15() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53726. /**
  53727. * 插入分割线
  53728. */
  53729. var Hr$1 = /*#__PURE__*/function (_MenuBase) {
  53730. _inherits(Hr, _MenuBase);
  53731. var _super = _createSuper$15(Hr);
  53732. function Hr($cherry) {
  53733. var _this;
  53734. _classCallCheck(this, Hr);
  53735. _this = _super.call(this, $cherry);
  53736. _this.setName('hr', 'line');
  53737. return _this;
  53738. }
  53739. /**
  53740. * 响应点击事件
  53741. * @param {string} selection 被用户选中的文本内容
  53742. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  53743. */
  53744. _createClass(Hr, [{
  53745. key: "onClick",
  53746. value: function onClick(selection) {
  53747. // 插入分割线
  53748. return "".concat(selection, "\n\n---\n");
  53749. }
  53750. }]);
  53751. return Hr;
  53752. }(MenuBase);
  53753. function _createSuper$16(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$16(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53754. function _isNativeReflectConstruct$16() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53755. /**
  53756. * 插入行内公式
  53757. */
  53758. var Formula = /*#__PURE__*/function (_MenuBase) {
  53759. _inherits(Formula, _MenuBase);
  53760. var _super = _createSuper$16(Formula);
  53761. function Formula($cherry) {
  53762. var _this;
  53763. _classCallCheck(this, Formula);
  53764. _this = _super.call(this, $cherry);
  53765. _this.setName('formula', 'insertFormula');
  53766. return _this;
  53767. }
  53768. /**
  53769. * 响应点击事件
  53770. * @param {string} selection 被用户选中的文本内容
  53771. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  53772. */
  53773. _createClass(Formula, [{
  53774. key: "onClick",
  53775. value: function onClick(selection) {
  53776. var _this2 = this,
  53777. _context;
  53778. var before = "".concat(selection, " $ ");
  53779. var after = ' $ ';
  53780. this.registerAfterClickCb(function () {
  53781. _this2.setLessSelection(before, after);
  53782. }); // 插入行内公式
  53783. return concat$5(_context = "".concat(before, "e=mc^2")).call(_context, after);
  53784. }
  53785. /**
  53786. * 声明绑定的快捷键,快捷键触发onClick
  53787. */
  53788. }, {
  53789. key: "shortcutKeys",
  53790. get: function get() {
  53791. return ['Ctrl-m'];
  53792. }
  53793. }]);
  53794. return Formula;
  53795. }(MenuBase);
  53796. function _createSuper$17(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$17(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53797. function _isNativeReflectConstruct$17() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53798. /**
  53799. * 插入超链接
  53800. */
  53801. var Link$1 = /*#__PURE__*/function (_MenuBase) {
  53802. _inherits(Link, _MenuBase);
  53803. var _super = _createSuper$17(Link);
  53804. function Link($cherry) {
  53805. var _this;
  53806. _classCallCheck(this, Link);
  53807. _this = _super.call(this, $cherry);
  53808. _this.setName('link', 'link');
  53809. return _this;
  53810. }
  53811. /**
  53812. * 响应点击事件
  53813. * @param {string} selection 被用户选中的文本内容
  53814. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  53815. */
  53816. _createClass(Link, [{
  53817. key: "onClick",
  53818. value: function onClick(selection) {
  53819. // 插入图片,调用上传文件逻辑
  53820. if (/^http/.test(selection)) {
  53821. var _context;
  53822. return concat$5(_context = "[".concat(this.locale.link, "](")).call(_context, selection, ")");
  53823. }
  53824. var title = selection ? selection : this.locale.link;
  53825. return "[".concat(title, "](http://url.com) ");
  53826. }
  53827. /**
  53828. * 声明绑定的快捷键,快捷键触发onClick
  53829. */
  53830. }, {
  53831. key: "shortcutKeys",
  53832. get: function get() {
  53833. return ['Ctrl-l'];
  53834. }
  53835. }]);
  53836. return Link;
  53837. }(MenuBase);
  53838. function _createSuper$18(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$18(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53839. function _isNativeReflectConstruct$18() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53840. /**
  53841. * 插入普通表格
  53842. */
  53843. var Table$1 = /*#__PURE__*/function (_MenuBase) {
  53844. _inherits(Table, _MenuBase);
  53845. var _super = _createSuper$18(Table);
  53846. function Table($cherry) {
  53847. var _this;
  53848. _classCallCheck(this, Table);
  53849. _this = _super.call(this, $cherry);
  53850. _this.setName('table', 'table');
  53851. _this.subBubbleTableMenu = new BubbleTableMenu({
  53852. row: 9,
  53853. col: 9
  53854. });
  53855. $cherry.editor.options.wrapperDom.appendChild(_this.subBubbleTableMenu.dom);
  53856. _this.catchOnce = '';
  53857. return _this;
  53858. }
  53859. /**
  53860. * 响应点击事件
  53861. * @param {string} selection 被用户选中的文本内容
  53862. * @returns {*} 回填到编辑器光标位置/选中文本区域的内容
  53863. */
  53864. _createClass(Table, [{
  53865. key: "onClick",
  53866. value: function onClick(selection) {
  53867. var _this2 = this;
  53868. // 如果二维面板处于隐藏状态,说明是第一次点击
  53869. if (this.subBubbleTableMenu.dom.style.display === 'none' || !this.hasCacheOnce()) {
  53870. // 插入表格,会出现一个二维面板,用户可以通过点击决定插入表格的行号和列号
  53871. var pos = this.dom.getBoundingClientRect();
  53872. this.subBubbleTableMenu.dom.style.left = "".concat(pos.left + pos.width, "px");
  53873. this.subBubbleTableMenu.dom.style.top = "".concat(pos.top + pos.height, "px");
  53874. this.subBubbleTableMenu.show(function (row, col) {
  53875. var _context, _context2, _context3, _context4, _context5, _context6;
  53876. var headerText = repeat$3(_context = ' Header |').call(_context, col);
  53877. var controlText = repeat$3(_context2 = ' ------ |').call(_context2, col);
  53878. var rowText = "\n|".concat(repeat$3(_context3 = ' Sample |').call(_context3, col));
  53879. var _final = concat$5(_context4 = concat$5(_context5 = concat$5(_context6 = "".concat(selection, "\n\n|")).call(_context6, headerText, "\n|")).call(_context5, controlText)).call(_context4, repeat$3(rowText).call(rowText, row), "\n\n");
  53880. _this2.setCacheOnce(_final);
  53881. _this2.fire(null);
  53882. });
  53883. this.updateMarkdown = false;
  53884. return false;
  53885. }
  53886. return this.getAndCleanCacheOnce();
  53887. }
  53888. }]);
  53889. return Table;
  53890. }(MenuBase);
  53891. function _createSuper$19(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$19(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53892. function _isNativeReflectConstruct$19() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53893. /**
  53894. * 插入目录
  53895. */
  53896. var Toc$1 = /*#__PURE__*/function (_MenuBase) {
  53897. _inherits(Toc, _MenuBase);
  53898. var _super = _createSuper$19(Toc);
  53899. function Toc($cherry) {
  53900. var _this;
  53901. _classCallCheck(this, Toc);
  53902. _this = _super.call(this, $cherry);
  53903. _this.setName('toc', 'toc');
  53904. return _this;
  53905. }
  53906. /**
  53907. * 响应点击事件
  53908. * @param {string} selection 被用户选中的文本内容
  53909. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  53910. */
  53911. _createClass(Toc, [{
  53912. key: "onClick",
  53913. value: function onClick(selection) {
  53914. // 插入目录
  53915. return "".concat(selection, "\n\n[[toc]]\n");
  53916. }
  53917. }]);
  53918. return Toc;
  53919. }(MenuBase);
  53920. function _createSuper$1a(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1a(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53921. function _isNativeReflectConstruct$1a() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53922. /**
  53923. * 插入折线图+表格
  53924. */
  53925. var LineTable = /*#__PURE__*/function (_MenuBase) {
  53926. _inherits(LineTable, _MenuBase);
  53927. var _super = _createSuper$1a(LineTable);
  53928. function LineTable($cherry) {
  53929. var _this;
  53930. _classCallCheck(this, LineTable);
  53931. _this = _super.call(this, $cherry);
  53932. _this.setName('lineTable', 'table');
  53933. return _this;
  53934. }
  53935. /**
  53936. * 响应点击事件
  53937. * @param {string} selection 被用户选中的文本内容
  53938. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  53939. */
  53940. _createClass(LineTable, [{
  53941. key: "onClick",
  53942. value: function onClick(selection) {
  53943. var _context;
  53944. // 插入带折线图的表格
  53945. return concat$5(_context = "".concat(selection, "\n\n")).call(_context, ['| :line: {x,y} | a | b | c |', '| :-: | :-: | :-: | :-: |', '| x | 1 | 2 | 3 |', '| y | 2 | 4 | 6 |', '| z | 7 | 5 | 3 |'].join('\n'), "\n\n");
  53946. }
  53947. }]);
  53948. return LineTable;
  53949. }(MenuBase);
  53950. function _createSuper$1b(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1b(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53951. function _isNativeReflectConstruct$1b() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53952. /**
  53953. * 插入柱状图图+表格
  53954. */
  53955. var BrTable = /*#__PURE__*/function (_MenuBase) {
  53956. _inherits(BrTable, _MenuBase);
  53957. var _super = _createSuper$1b(BrTable);
  53958. function BrTable($cherry) {
  53959. var _this;
  53960. _classCallCheck(this, BrTable);
  53961. _this = _super.call(this, $cherry);
  53962. _this.setName('brTable', 'table');
  53963. return _this;
  53964. }
  53965. /**
  53966. * 响应点击事件
  53967. * @param {string} selection 被用户选中的文本内容
  53968. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  53969. */
  53970. _createClass(BrTable, [{
  53971. key: "onClick",
  53972. value: function onClick(selection) {
  53973. var _context;
  53974. // 插入带折线图的表格
  53975. return concat$5(_context = "".concat(selection, "\n\n")).call(_context, ['| :bar: {x,y} | a | b | c |', '| :-: | :-: | :-: | :-: |', '| x | 1 | 2 | 3 |', '| y | 2 | 4 | 6 |', '| z | 7 | 5 | 3 |'].join('\n'), "\n\n");
  53976. }
  53977. }]);
  53978. return BrTable;
  53979. }(MenuBase);
  53980. function _createSuper$1c(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1c(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  53981. function _isNativeReflectConstruct$1c() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  53982. /**
  53983. * 插入pdf
  53984. */
  53985. var Pdf = /*#__PURE__*/function (_MenuBase) {
  53986. _inherits(Pdf, _MenuBase);
  53987. var _super = _createSuper$1c(Pdf);
  53988. function Pdf($cherry) {
  53989. var _this;
  53990. _classCallCheck(this, Pdf);
  53991. _this = _super.call(this, $cherry);
  53992. _this.setName('pdf', 'pdf');
  53993. return _this;
  53994. }
  53995. /**
  53996. * 响应点击事件
  53997. * @param {string} selection 被用户选中的文本内容
  53998. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  53999. */
  54000. _createClass(Pdf, [{
  54001. key: "onClick",
  54002. value: function onClick(selection) {
  54003. var _this2 = this,
  54004. _this$$cherry$options,
  54005. _this$$cherry$options2,
  54006. _this$$cherry$options3;
  54007. if (this.hasCacheOnce()) {
  54008. var _context;
  54009. // @ts-ignore
  54010. var _this$getAndCleanCach = this.getAndCleanCacheOnce(),
  54011. name = _this$getAndCleanCach.name,
  54012. url = _this$getAndCleanCach.url,
  54013. params = _this$getAndCleanCach.params;
  54014. var begin = '[';
  54015. var end = "](".concat(url, ")");
  54016. this.registerAfterClickCb(function () {
  54017. _this2.setLessSelection(begin, end);
  54018. });
  54019. var finalName = params.name ? params.name : name;
  54020. return concat$5(_context = "".concat(begin).concat(finalName)).call(_context, end);
  54021. }
  54022. var accept = (_this$$cherry$options = (_this$$cherry$options2 = this.$cherry.options) === null || _this$$cherry$options2 === void 0 ? void 0 : (_this$$cherry$options3 = _this$$cherry$options2.fileTypeLimitMap) === null || _this$$cherry$options3 === void 0 ? void 0 : _this$$cherry$options3.pdf) !== null && _this$$cherry$options !== void 0 ? _this$$cherry$options : '*'; // 插入图片,调用上传文件逻辑
  54023. handleUpload(this.editor, 'pdf', accept, function (name, url, params) {
  54024. _this2.setCacheOnce({
  54025. name: name,
  54026. url: url,
  54027. params: params
  54028. });
  54029. _this2.fire(null);
  54030. });
  54031. this.updateMarkdown = false;
  54032. return selection;
  54033. }
  54034. }]);
  54035. return Pdf;
  54036. }(MenuBase);
  54037. function _createSuper$1d(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1d(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  54038. function _isNativeReflectConstruct$1d() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  54039. /**
  54040. * 插入pdf
  54041. */
  54042. var File = /*#__PURE__*/function (_MenuBase) {
  54043. _inherits(File, _MenuBase);
  54044. var _super = _createSuper$1d(File);
  54045. function File($cherry) {
  54046. var _this;
  54047. _classCallCheck(this, File);
  54048. _this = _super.call(this, $cherry);
  54049. _this.setName('file', 'phone');
  54050. return _this;
  54051. }
  54052. /**
  54053. * 响应点击事件
  54054. * @param {string} selection 被用户选中的文本内容
  54055. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  54056. */
  54057. _createClass(File, [{
  54058. key: "onClick",
  54059. value: function onClick(selection) {
  54060. var _this2 = this,
  54061. _this$$cherry$options,
  54062. _this$$cherry$options2,
  54063. _this$$cherry$options3;
  54064. if (this.hasCacheOnce()) {
  54065. var _context;
  54066. // @ts-ignore
  54067. var _this$getAndCleanCach = this.getAndCleanCacheOnce(),
  54068. name = _this$getAndCleanCach.name,
  54069. url = _this$getAndCleanCach.url,
  54070. params = _this$getAndCleanCach.params;
  54071. var begin = '[';
  54072. var end = "](".concat(url, ")");
  54073. this.registerAfterClickCb(function () {
  54074. _this2.setLessSelection(begin, end);
  54075. });
  54076. var finalName = params.name ? params.name : name;
  54077. return concat$5(_context = "".concat(begin).concat(finalName)).call(_context, end);
  54078. }
  54079. var accept = (_this$$cherry$options = (_this$$cherry$options2 = this.$cherry.options) === null || _this$$cherry$options2 === void 0 ? void 0 : (_this$$cherry$options3 = _this$$cherry$options2.fileTypeLimitMap) === null || _this$$cherry$options3 === void 0 ? void 0 : _this$$cherry$options3.file) !== null && _this$$cherry$options !== void 0 ? _this$$cherry$options : '*'; // 插入图片,调用上传文件逻辑
  54080. handleUpload(this.editor, 'file', accept, function (name, url, params) {
  54081. _this2.setCacheOnce({
  54082. name: name,
  54083. url: url,
  54084. params: params
  54085. });
  54086. _this2.fire(null);
  54087. });
  54088. this.updateMarkdown = false;
  54089. return selection;
  54090. }
  54091. }]);
  54092. return File;
  54093. }(MenuBase);
  54094. function _createSuper$1e(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1e(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  54095. function _isNativeReflectConstruct$1e() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  54096. /**
  54097. * 插入word
  54098. */
  54099. var Word = /*#__PURE__*/function (_MenuBase) {
  54100. _inherits(Word, _MenuBase);
  54101. var _super = _createSuper$1e(Word);
  54102. function Word($cherry) {
  54103. var _this;
  54104. _classCallCheck(this, Word);
  54105. _this = _super.call(this, $cherry);
  54106. _this.setName('word', 'word');
  54107. return _this;
  54108. }
  54109. /**
  54110. * 响应点击事件
  54111. * @param {string} selection 被用户选中的文本内容
  54112. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  54113. */
  54114. _createClass(Word, [{
  54115. key: "onClick",
  54116. value: function onClick(selection) {
  54117. var _this2 = this,
  54118. _this$$cherry$options,
  54119. _this$$cherry$options2,
  54120. _this$$cherry$options3;
  54121. if (this.hasCacheOnce()) {
  54122. var _context;
  54123. // @ts-ignore
  54124. var _this$getAndCleanCach = this.getAndCleanCacheOnce(),
  54125. name = _this$getAndCleanCach.name,
  54126. url = _this$getAndCleanCach.url,
  54127. params = _this$getAndCleanCach.params;
  54128. var begin = '[';
  54129. var end = "](".concat(url, ")");
  54130. this.registerAfterClickCb(function () {
  54131. _this2.setLessSelection(begin, end);
  54132. });
  54133. var finalName = params.name ? params.name : name;
  54134. return concat$5(_context = "".concat(begin).concat(finalName)).call(_context, end);
  54135. }
  54136. var accept = (_this$$cherry$options = (_this$$cherry$options2 = this.$cherry.options) === null || _this$$cherry$options2 === void 0 ? void 0 : (_this$$cherry$options3 = _this$$cherry$options2.fileTypeLimitMap) === null || _this$$cherry$options3 === void 0 ? void 0 : _this$$cherry$options3.word) !== null && _this$$cherry$options !== void 0 ? _this$$cherry$options : '*'; // 插入图片,调用上传文件逻辑
  54137. handleUpload(this.editor, 'word', accept, function (name, url, params) {
  54138. _this2.setCacheOnce({
  54139. name: name,
  54140. url: url,
  54141. params: params
  54142. });
  54143. _this2.fire(null);
  54144. });
  54145. this.updateMarkdown = false;
  54146. return selection;
  54147. }
  54148. }]);
  54149. return Word;
  54150. }(MenuBase);
  54151. function _createSuper$1f(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1f(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  54152. function _isNativeReflectConstruct$1f() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  54153. /**
  54154. * 生成ruby,使用场景:给中文增加拼音、给中文增加英文、给英文增加中文等等
  54155. */
  54156. var Ruby$1 = /*#__PURE__*/function (_MenuBase) {
  54157. _inherits(Ruby, _MenuBase);
  54158. var _super = _createSuper$1f(Ruby);
  54159. function Ruby($cherry) {
  54160. var _this;
  54161. _classCallCheck(this, Ruby);
  54162. _this = _super.call(this, $cherry);
  54163. _this.setName('pinyin', 'pinyin');
  54164. return _this;
  54165. }
  54166. _createClass(Ruby, [{
  54167. key: "$testIsRuby",
  54168. value: function $testIsRuby(selection) {
  54169. return /^\s*\{[\s\S]+\|[\s\S]+\}/.test(selection);
  54170. }
  54171. /**
  54172. * 响应点击事件
  54173. * @param {string} selection 被用户选中的文本内容
  54174. * @param {string} shortKey 快捷键参数,本函数不处理这个参数
  54175. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  54176. */
  54177. }, {
  54178. key: "onClick",
  54179. value: function onClick(selection) {
  54180. var _this2 = this,
  54181. _context,
  54182. _context2;
  54183. var $selection = getSelection(this.editor.editor, selection) || '拼音'; // 如果选中的文本中已经有ruby语法了,则去掉该语法
  54184. if (!this.isSelections && !this.$testIsRuby($selection)) {
  54185. this.getMoreSelection(' { ', ' } ', function () {
  54186. var newSelection = _this2.editor.editor.getSelection();
  54187. var isRuby = _this2.$testIsRuby(newSelection);
  54188. if (isRuby) {
  54189. $selection = newSelection;
  54190. }
  54191. return isRuby;
  54192. });
  54193. }
  54194. if (this.$testIsRuby($selection)) {
  54195. return $selection.replace(/^\s*\{\s*([\s\S]+?)\s*\|[\s\S]+\}\s*/gm, '$1');
  54196. }
  54197. var pinyin = trim$3(_context = this.editor.$cherry.options.callback.changeString2Pinyin($selection) || 'pin yin').call(_context);
  54198. this.registerAfterClickCb(function () {
  54199. _this2.setLessSelection(' { ', ' } ');
  54200. });
  54201. return concat$5(_context2 = " { ".concat($selection, " | ")).call(_context2, pinyin, " } ");
  54202. }
  54203. }]);
  54204. return Ruby;
  54205. }(MenuBase);
  54206. function _createSuper$1g(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1g(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  54207. function _isNativeReflectConstruct$1g() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  54208. /**
  54209. * 修改主题
  54210. */
  54211. var Theme = /*#__PURE__*/function (_MenuBase) {
  54212. _inherits(Theme, _MenuBase);
  54213. var _super = _createSuper$1g(Theme);
  54214. function Theme($cherry) {
  54215. var _context;
  54216. var _this;
  54217. _classCallCheck(this, Theme);
  54218. _this = _super.call(this, $cherry);
  54219. _this.setName('theme', 'insertChart');
  54220. _this.subMenuConfig = [];
  54221. var self = _assertThisInitialized(_this);
  54222. forEach$3(_context = $cherry.options.theme).call(_context, function (one) {
  54223. var _context2;
  54224. self.subMenuConfig.push({
  54225. iconName: one.className,
  54226. name: one.label,
  54227. onclick: bind$5(_context2 = self.bindSubClick).call(_context2, self, one.className)
  54228. });
  54229. });
  54230. return _this;
  54231. }
  54232. /**
  54233. * 响应点击事件
  54234. * @param {string} selection 被用户选中的文本内容
  54235. * @param {string} shortKey 快捷键参数
  54236. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  54237. */
  54238. _createClass(Theme, [{
  54239. key: "onClick",
  54240. value: function onClick(selection) {
  54241. var shortKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  54242. changeTheme(this.$cherry, shortKey);
  54243. this.updateMarkdown = false;
  54244. return '';
  54245. }
  54246. }]);
  54247. return Theme;
  54248. }(MenuBase);
  54249. var bind$a = function bind(fn, thisArg) {
  54250. return function wrap() {
  54251. var args = new Array(arguments.length);
  54252. for (var i = 0; i < args.length; i++) {
  54253. args[i] = arguments[i];
  54254. }
  54255. return fn.apply(thisArg, args);
  54256. };
  54257. };
  54258. // utils is a library of generic helper functions non-specific to axios
  54259. var toString$4 = Object.prototype.toString;
  54260. /**
  54261. * Determine if a value is an Array
  54262. *
  54263. * @param {Object} val The value to test
  54264. * @returns {boolean} True if value is an Array, otherwise false
  54265. */
  54266. function isArray$a(val) {
  54267. return Array.isArray(val);
  54268. }
  54269. /**
  54270. * Determine if a value is undefined
  54271. *
  54272. * @param {Object} val The value to test
  54273. * @returns {boolean} True if the value is undefined, otherwise false
  54274. */
  54275. function isUndefined(val) {
  54276. return typeof val === 'undefined';
  54277. }
  54278. /**
  54279. * Determine if a value is a Buffer
  54280. *
  54281. * @param {Object} val The value to test
  54282. * @returns {boolean} True if value is a Buffer, otherwise false
  54283. */
  54284. function isBuffer$1(val) {
  54285. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  54286. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  54287. }
  54288. /**
  54289. * Determine if a value is an ArrayBuffer
  54290. *
  54291. * @param {Object} val The value to test
  54292. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  54293. */
  54294. function isArrayBuffer(val) {
  54295. return toString$4.call(val) === '[object ArrayBuffer]';
  54296. }
  54297. /**
  54298. * Determine if a value is a FormData
  54299. *
  54300. * @param {Object} val The value to test
  54301. * @returns {boolean} True if value is an FormData, otherwise false
  54302. */
  54303. function isFormData(val) {
  54304. return toString$4.call(val) === '[object FormData]';
  54305. }
  54306. /**
  54307. * Determine if a value is a view on an ArrayBuffer
  54308. *
  54309. * @param {Object} val The value to test
  54310. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  54311. */
  54312. function isArrayBufferView(val) {
  54313. var result;
  54314. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  54315. result = ArrayBuffer.isView(val);
  54316. } else {
  54317. result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
  54318. }
  54319. return result;
  54320. }
  54321. /**
  54322. * Determine if a value is a String
  54323. *
  54324. * @param {Object} val The value to test
  54325. * @returns {boolean} True if value is a String, otherwise false
  54326. */
  54327. function isString(val) {
  54328. return typeof val === 'string';
  54329. }
  54330. /**
  54331. * Determine if a value is a Number
  54332. *
  54333. * @param {Object} val The value to test
  54334. * @returns {boolean} True if value is a Number, otherwise false
  54335. */
  54336. function isNumber(val) {
  54337. return typeof val === 'number';
  54338. }
  54339. /**
  54340. * Determine if a value is an Object
  54341. *
  54342. * @param {Object} val The value to test
  54343. * @returns {boolean} True if value is an Object, otherwise false
  54344. */
  54345. function isObject$3(val) {
  54346. return val !== null && typeof val === 'object';
  54347. }
  54348. /**
  54349. * Determine if a value is a plain Object
  54350. *
  54351. * @param {Object} val The value to test
  54352. * @return {boolean} True if value is a plain Object, otherwise false
  54353. */
  54354. function isPlainObject$1(val) {
  54355. if (toString$4.call(val) !== '[object Object]') {
  54356. return false;
  54357. }
  54358. var prototype = Object.getPrototypeOf(val);
  54359. return prototype === null || prototype === Object.prototype;
  54360. }
  54361. /**
  54362. * Determine if a value is a Date
  54363. *
  54364. * @param {Object} val The value to test
  54365. * @returns {boolean} True if value is a Date, otherwise false
  54366. */
  54367. function isDate(val) {
  54368. return toString$4.call(val) === '[object Date]';
  54369. }
  54370. /**
  54371. * Determine if a value is a File
  54372. *
  54373. * @param {Object} val The value to test
  54374. * @returns {boolean} True if value is a File, otherwise false
  54375. */
  54376. function isFile(val) {
  54377. return toString$4.call(val) === '[object File]';
  54378. }
  54379. /**
  54380. * Determine if a value is a Blob
  54381. *
  54382. * @param {Object} val The value to test
  54383. * @returns {boolean} True if value is a Blob, otherwise false
  54384. */
  54385. function isBlob(val) {
  54386. return toString$4.call(val) === '[object Blob]';
  54387. }
  54388. /**
  54389. * Determine if a value is a Function
  54390. *
  54391. * @param {Object} val The value to test
  54392. * @returns {boolean} True if value is a Function, otherwise false
  54393. */
  54394. function isFunction$1(val) {
  54395. return toString$4.call(val) === '[object Function]';
  54396. }
  54397. /**
  54398. * Determine if a value is a Stream
  54399. *
  54400. * @param {Object} val The value to test
  54401. * @returns {boolean} True if value is a Stream, otherwise false
  54402. */
  54403. function isStream(val) {
  54404. return isObject$3(val) && isFunction$1(val.pipe);
  54405. }
  54406. /**
  54407. * Determine if a value is a URLSearchParams object
  54408. *
  54409. * @param {Object} val The value to test
  54410. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  54411. */
  54412. function isURLSearchParams(val) {
  54413. return toString$4.call(val) === '[object URLSearchParams]';
  54414. }
  54415. /**
  54416. * Trim excess whitespace off the beginning and end of a string
  54417. *
  54418. * @param {String} str The String to trim
  54419. * @returns {String} The String freed of excess whitespace
  54420. */
  54421. function trim$6(str) {
  54422. return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
  54423. }
  54424. /**
  54425. * Determine if we're running in a standard browser environment
  54426. *
  54427. * This allows axios to run in a web worker, and react-native.
  54428. * Both environments support XMLHttpRequest, but not fully standard globals.
  54429. *
  54430. * web workers:
  54431. * typeof window -> undefined
  54432. * typeof document -> undefined
  54433. *
  54434. * react-native:
  54435. * navigator.product -> 'ReactNative'
  54436. * nativescript
  54437. * navigator.product -> 'NativeScript' or 'NS'
  54438. */
  54439. function isStandardBrowserEnv() {
  54440. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  54441. navigator.product === 'NativeScript' ||
  54442. navigator.product === 'NS')) {
  54443. return false;
  54444. }
  54445. return (
  54446. typeof window !== 'undefined' &&
  54447. typeof document !== 'undefined'
  54448. );
  54449. }
  54450. /**
  54451. * Iterate over an Array or an Object invoking a function for each item.
  54452. *
  54453. * If `obj` is an Array callback will be called passing
  54454. * the value, index, and complete array for each item.
  54455. *
  54456. * If 'obj' is an Object callback will be called passing
  54457. * the value, key, and complete object for each property.
  54458. *
  54459. * @param {Object|Array} obj The object to iterate
  54460. * @param {Function} fn The callback to invoke for each item
  54461. */
  54462. function forEach$5(obj, fn) {
  54463. // Don't bother if no value provided
  54464. if (obj === null || typeof obj === 'undefined') {
  54465. return;
  54466. }
  54467. // Force an array if not already something iterable
  54468. if (typeof obj !== 'object') {
  54469. /*eslint no-param-reassign:0*/
  54470. obj = [obj];
  54471. }
  54472. if (isArray$a(obj)) {
  54473. // Iterate over array values
  54474. for (var i = 0, l = obj.length; i < l; i++) {
  54475. fn.call(null, obj[i], i, obj);
  54476. }
  54477. } else {
  54478. // Iterate over object keys
  54479. for (var key in obj) {
  54480. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  54481. fn.call(null, obj[key], key, obj);
  54482. }
  54483. }
  54484. }
  54485. }
  54486. /**
  54487. * Accepts varargs expecting each argument to be an object, then
  54488. * immutably merges the properties of each object and returns result.
  54489. *
  54490. * When multiple objects contain the same key the later object in
  54491. * the arguments list will take precedence.
  54492. *
  54493. * Example:
  54494. *
  54495. * ```js
  54496. * var result = merge({foo: 123}, {foo: 456});
  54497. * console.log(result.foo); // outputs 456
  54498. * ```
  54499. *
  54500. * @param {Object} obj1 Object to merge
  54501. * @returns {Object} Result of all merge properties
  54502. */
  54503. function merge$1(/* obj1, obj2, obj3, ... */) {
  54504. var result = {};
  54505. function assignValue(val, key) {
  54506. if (isPlainObject$1(result[key]) && isPlainObject$1(val)) {
  54507. result[key] = merge$1(result[key], val);
  54508. } else if (isPlainObject$1(val)) {
  54509. result[key] = merge$1({}, val);
  54510. } else if (isArray$a(val)) {
  54511. result[key] = val.slice();
  54512. } else {
  54513. result[key] = val;
  54514. }
  54515. }
  54516. for (var i = 0, l = arguments.length; i < l; i++) {
  54517. forEach$5(arguments[i], assignValue);
  54518. }
  54519. return result;
  54520. }
  54521. /**
  54522. * Extends object a by mutably adding to it the properties of object b.
  54523. *
  54524. * @param {Object} a The object to be extended
  54525. * @param {Object} b The object to copy properties from
  54526. * @param {Object} thisArg The object to bind function to
  54527. * @return {Object} The resulting value of object a
  54528. */
  54529. function extend(a, b, thisArg) {
  54530. forEach$5(b, function assignValue(val, key) {
  54531. if (thisArg && typeof val === 'function') {
  54532. a[key] = bind$a(val, thisArg);
  54533. } else {
  54534. a[key] = val;
  54535. }
  54536. });
  54537. return a;
  54538. }
  54539. /**
  54540. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  54541. *
  54542. * @param {string} content with BOM
  54543. * @return {string} content value without BOM
  54544. */
  54545. function stripBOM(content) {
  54546. if (content.charCodeAt(0) === 0xFEFF) {
  54547. content = content.slice(1);
  54548. }
  54549. return content;
  54550. }
  54551. var utils = {
  54552. isArray: isArray$a,
  54553. isArrayBuffer: isArrayBuffer,
  54554. isBuffer: isBuffer$1,
  54555. isFormData: isFormData,
  54556. isArrayBufferView: isArrayBufferView,
  54557. isString: isString,
  54558. isNumber: isNumber,
  54559. isObject: isObject$3,
  54560. isPlainObject: isPlainObject$1,
  54561. isUndefined: isUndefined,
  54562. isDate: isDate,
  54563. isFile: isFile,
  54564. isBlob: isBlob,
  54565. isFunction: isFunction$1,
  54566. isStream: isStream,
  54567. isURLSearchParams: isURLSearchParams,
  54568. isStandardBrowserEnv: isStandardBrowserEnv,
  54569. forEach: forEach$5,
  54570. merge: merge$1,
  54571. extend: extend,
  54572. trim: trim$6,
  54573. stripBOM: stripBOM
  54574. };
  54575. function encode$1(val) {
  54576. return encodeURIComponent(val).
  54577. replace(/%3A/gi, ':').
  54578. replace(/%24/g, '$').
  54579. replace(/%2C/gi, ',').
  54580. replace(/%20/g, '+').
  54581. replace(/%5B/gi, '[').
  54582. replace(/%5D/gi, ']');
  54583. }
  54584. /**
  54585. * Build a URL by appending params to the end
  54586. *
  54587. * @param {string} url The base of the url (e.g., http://www.google.com)
  54588. * @param {object} [params] The params to be appended
  54589. * @returns {string} The formatted url
  54590. */
  54591. var buildURL = function buildURL(url, params, paramsSerializer) {
  54592. /*eslint no-param-reassign:0*/
  54593. if (!params) {
  54594. return url;
  54595. }
  54596. var serializedParams;
  54597. if (paramsSerializer) {
  54598. serializedParams = paramsSerializer(params);
  54599. } else if (utils.isURLSearchParams(params)) {
  54600. serializedParams = params.toString();
  54601. } else {
  54602. var parts = [];
  54603. utils.forEach(params, function serialize(val, key) {
  54604. if (val === null || typeof val === 'undefined') {
  54605. return;
  54606. }
  54607. if (utils.isArray(val)) {
  54608. key = key + '[]';
  54609. } else {
  54610. val = [val];
  54611. }
  54612. utils.forEach(val, function parseValue(v) {
  54613. if (utils.isDate(v)) {
  54614. v = v.toISOString();
  54615. } else if (utils.isObject(v)) {
  54616. v = JSON.stringify(v);
  54617. }
  54618. parts.push(encode$1(key) + '=' + encode$1(v));
  54619. });
  54620. });
  54621. serializedParams = parts.join('&');
  54622. }
  54623. if (serializedParams) {
  54624. var hashmarkIndex = url.indexOf('#');
  54625. if (hashmarkIndex !== -1) {
  54626. url = url.slice(0, hashmarkIndex);
  54627. }
  54628. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  54629. }
  54630. return url;
  54631. };
  54632. function InterceptorManager() {
  54633. this.handlers = [];
  54634. }
  54635. /**
  54636. * Add a new interceptor to the stack
  54637. *
  54638. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  54639. * @param {Function} rejected The function to handle `reject` for a `Promise`
  54640. *
  54641. * @return {Number} An ID used to remove interceptor later
  54642. */
  54643. InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
  54644. this.handlers.push({
  54645. fulfilled: fulfilled,
  54646. rejected: rejected,
  54647. synchronous: options ? options.synchronous : false,
  54648. runWhen: options ? options.runWhen : null
  54649. });
  54650. return this.handlers.length - 1;
  54651. };
  54652. /**
  54653. * Remove an interceptor from the stack
  54654. *
  54655. * @param {Number} id The ID that was returned by `use`
  54656. */
  54657. InterceptorManager.prototype.eject = function eject(id) {
  54658. if (this.handlers[id]) {
  54659. this.handlers[id] = null;
  54660. }
  54661. };
  54662. /**
  54663. * Iterate over all the registered interceptors
  54664. *
  54665. * This method is particularly useful for skipping over any
  54666. * interceptors that may have become `null` calling `eject`.
  54667. *
  54668. * @param {Function} fn The function to call for each interceptor
  54669. */
  54670. InterceptorManager.prototype.forEach = function forEach(fn) {
  54671. utils.forEach(this.handlers, function forEachHandler(h) {
  54672. if (h !== null) {
  54673. fn(h);
  54674. }
  54675. });
  54676. };
  54677. var InterceptorManager_1 = InterceptorManager;
  54678. var normalizeHeaderName = function normalizeHeaderName(headers, normalizedName) {
  54679. utils.forEach(headers, function processHeader(value, name) {
  54680. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  54681. headers[normalizedName] = value;
  54682. delete headers[name];
  54683. }
  54684. });
  54685. };
  54686. /**
  54687. * Update an Error with the specified config, error code, and response.
  54688. *
  54689. * @param {Error} error The error to update.
  54690. * @param {Object} config The config.
  54691. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  54692. * @param {Object} [request] The request.
  54693. * @param {Object} [response] The response.
  54694. * @returns {Error} The error.
  54695. */
  54696. var enhanceError = function enhanceError(error, config, code, request, response) {
  54697. error.config = config;
  54698. if (code) {
  54699. error.code = code;
  54700. }
  54701. error.request = request;
  54702. error.response = response;
  54703. error.isAxiosError = true;
  54704. error.toJSON = function toJSON() {
  54705. return {
  54706. // Standard
  54707. message: this.message,
  54708. name: this.name,
  54709. // Microsoft
  54710. description: this.description,
  54711. number: this.number,
  54712. // Mozilla
  54713. fileName: this.fileName,
  54714. lineNumber: this.lineNumber,
  54715. columnNumber: this.columnNumber,
  54716. stack: this.stack,
  54717. // Axios
  54718. config: this.config,
  54719. code: this.code,
  54720. status: this.response && this.response.status ? this.response.status : null
  54721. };
  54722. };
  54723. return error;
  54724. };
  54725. var transitional = {
  54726. silentJSONParsing: true,
  54727. forcedJSONParsing: true,
  54728. clarifyTimeoutError: false
  54729. };
  54730. /**
  54731. * Create an Error with the specified message, config, error code, request and response.
  54732. *
  54733. * @param {string} message The error message.
  54734. * @param {Object} config The config.
  54735. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  54736. * @param {Object} [request] The request.
  54737. * @param {Object} [response] The response.
  54738. * @returns {Error} The created error.
  54739. */
  54740. var createError = function createError(message, config, code, request, response) {
  54741. var error = new Error(message);
  54742. return enhanceError(error, config, code, request, response);
  54743. };
  54744. /**
  54745. * Resolve or reject a Promise based on response status.
  54746. *
  54747. * @param {Function} resolve A function that resolves the promise.
  54748. * @param {Function} reject A function that rejects the promise.
  54749. * @param {object} response The response.
  54750. */
  54751. var settle = function settle(resolve, reject, response) {
  54752. var validateStatus = response.config.validateStatus;
  54753. if (!response.status || !validateStatus || validateStatus(response.status)) {
  54754. resolve(response);
  54755. } else {
  54756. reject(createError(
  54757. 'Request failed with status code ' + response.status,
  54758. response.config,
  54759. null,
  54760. response.request,
  54761. response
  54762. ));
  54763. }
  54764. };
  54765. var cookies = (
  54766. utils.isStandardBrowserEnv() ?
  54767. // Standard browser envs support document.cookie
  54768. (function standardBrowserEnv() {
  54769. return {
  54770. write: function write(name, value, expires, path, domain, secure) {
  54771. var cookie = [];
  54772. cookie.push(name + '=' + encodeURIComponent(value));
  54773. if (utils.isNumber(expires)) {
  54774. cookie.push('expires=' + new Date(expires).toGMTString());
  54775. }
  54776. if (utils.isString(path)) {
  54777. cookie.push('path=' + path);
  54778. }
  54779. if (utils.isString(domain)) {
  54780. cookie.push('domain=' + domain);
  54781. }
  54782. if (secure === true) {
  54783. cookie.push('secure');
  54784. }
  54785. document.cookie = cookie.join('; ');
  54786. },
  54787. read: function read(name) {
  54788. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  54789. return (match ? decodeURIComponent(match[3]) : null);
  54790. },
  54791. remove: function remove(name) {
  54792. this.write(name, '', Date.now() - 86400000);
  54793. }
  54794. };
  54795. })() :
  54796. // Non standard browser env (web workers, react-native) lack needed support.
  54797. (function nonStandardBrowserEnv() {
  54798. return {
  54799. write: function write() {},
  54800. read: function read() { return null; },
  54801. remove: function remove() {}
  54802. };
  54803. })()
  54804. );
  54805. /**
  54806. * Determines whether the specified URL is absolute
  54807. *
  54808. * @param {string} url The URL to test
  54809. * @returns {boolean} True if the specified URL is absolute, otherwise false
  54810. */
  54811. var isAbsoluteURL = function isAbsoluteURL(url) {
  54812. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  54813. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  54814. // by any combination of letters, digits, plus, period, or hyphen.
  54815. return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
  54816. };
  54817. /**
  54818. * Creates a new URL by combining the specified URLs
  54819. *
  54820. * @param {string} baseURL The base URL
  54821. * @param {string} relativeURL The relative URL
  54822. * @returns {string} The combined URL
  54823. */
  54824. var combineURLs = function combineURLs(baseURL, relativeURL) {
  54825. return relativeURL
  54826. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  54827. : baseURL;
  54828. };
  54829. /**
  54830. * Creates a new URL by combining the baseURL with the requestedURL,
  54831. * only when the requestedURL is not already an absolute URL.
  54832. * If the requestURL is absolute, this function returns the requestedURL untouched.
  54833. *
  54834. * @param {string} baseURL The base URL
  54835. * @param {string} requestedURL Absolute or relative URL to combine
  54836. * @returns {string} The combined full path
  54837. */
  54838. var buildFullPath = function buildFullPath(baseURL, requestedURL) {
  54839. if (baseURL && !isAbsoluteURL(requestedURL)) {
  54840. return combineURLs(baseURL, requestedURL);
  54841. }
  54842. return requestedURL;
  54843. };
  54844. // Headers whose duplicates are ignored by node
  54845. // c.f. https://nodejs.org/api/http.html#http_message_headers
  54846. var ignoreDuplicateOf = [
  54847. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  54848. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  54849. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  54850. 'referer', 'retry-after', 'user-agent'
  54851. ];
  54852. /**
  54853. * Parse headers into an object
  54854. *
  54855. * ```
  54856. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  54857. * Content-Type: application/json
  54858. * Connection: keep-alive
  54859. * Transfer-Encoding: chunked
  54860. * ```
  54861. *
  54862. * @param {String} headers Headers needing to be parsed
  54863. * @returns {Object} Headers parsed into an object
  54864. */
  54865. var parseHeaders = function parseHeaders(headers) {
  54866. var parsed = {};
  54867. var key;
  54868. var val;
  54869. var i;
  54870. if (!headers) { return parsed; }
  54871. utils.forEach(headers.split('\n'), function parser(line) {
  54872. i = line.indexOf(':');
  54873. key = utils.trim(line.substr(0, i)).toLowerCase();
  54874. val = utils.trim(line.substr(i + 1));
  54875. if (key) {
  54876. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  54877. return;
  54878. }
  54879. if (key === 'set-cookie') {
  54880. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  54881. } else {
  54882. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  54883. }
  54884. }
  54885. });
  54886. return parsed;
  54887. };
  54888. var isURLSameOrigin = (
  54889. utils.isStandardBrowserEnv() ?
  54890. // Standard browser envs have full support of the APIs needed to test
  54891. // whether the request URL is of the same origin as current location.
  54892. (function standardBrowserEnv() {
  54893. var msie = /(msie|trident)/i.test(navigator.userAgent);
  54894. var urlParsingNode = document.createElement('a');
  54895. var originURL;
  54896. /**
  54897. * Parse a URL to discover it's components
  54898. *
  54899. * @param {String} url The URL to be parsed
  54900. * @returns {Object}
  54901. */
  54902. function resolveURL(url) {
  54903. var href = url;
  54904. if (msie) {
  54905. // IE needs attribute set twice to normalize properties
  54906. urlParsingNode.setAttribute('href', href);
  54907. href = urlParsingNode.href;
  54908. }
  54909. urlParsingNode.setAttribute('href', href);
  54910. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  54911. return {
  54912. href: urlParsingNode.href,
  54913. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  54914. host: urlParsingNode.host,
  54915. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  54916. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  54917. hostname: urlParsingNode.hostname,
  54918. port: urlParsingNode.port,
  54919. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  54920. urlParsingNode.pathname :
  54921. '/' + urlParsingNode.pathname
  54922. };
  54923. }
  54924. originURL = resolveURL(window.location.href);
  54925. /**
  54926. * Determine if a URL shares the same origin as the current location
  54927. *
  54928. * @param {String} requestURL The URL to test
  54929. * @returns {boolean} True if URL shares the same origin, otherwise false
  54930. */
  54931. return function isURLSameOrigin(requestURL) {
  54932. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  54933. return (parsed.protocol === originURL.protocol &&
  54934. parsed.host === originURL.host);
  54935. };
  54936. })() :
  54937. // Non standard browser envs (web workers, react-native) lack needed support.
  54938. (function nonStandardBrowserEnv() {
  54939. return function isURLSameOrigin() {
  54940. return true;
  54941. };
  54942. })()
  54943. );
  54944. /**
  54945. * A `Cancel` is an object that is thrown when an operation is canceled.
  54946. *
  54947. * @class
  54948. * @param {string=} message The message.
  54949. */
  54950. function Cancel(message) {
  54951. this.message = message;
  54952. }
  54953. Cancel.prototype.toString = function toString() {
  54954. return 'Cancel' + (this.message ? ': ' + this.message : '');
  54955. };
  54956. Cancel.prototype.__CANCEL__ = true;
  54957. var Cancel_1 = Cancel;
  54958. var xhr = function xhrAdapter(config) {
  54959. return new Promise(function dispatchXhrRequest(resolve, reject) {
  54960. var requestData = config.data;
  54961. var requestHeaders = config.headers;
  54962. var responseType = config.responseType;
  54963. var onCanceled;
  54964. function done() {
  54965. if (config.cancelToken) {
  54966. config.cancelToken.unsubscribe(onCanceled);
  54967. }
  54968. if (config.signal) {
  54969. config.signal.removeEventListener('abort', onCanceled);
  54970. }
  54971. }
  54972. if (utils.isFormData(requestData)) {
  54973. delete requestHeaders['Content-Type']; // Let the browser set it
  54974. }
  54975. var request = new XMLHttpRequest();
  54976. // HTTP basic authentication
  54977. if (config.auth) {
  54978. var username = config.auth.username || '';
  54979. var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
  54980. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  54981. }
  54982. var fullPath = buildFullPath(config.baseURL, config.url);
  54983. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  54984. // Set the request timeout in MS
  54985. request.timeout = config.timeout;
  54986. function onloadend() {
  54987. if (!request) {
  54988. return;
  54989. }
  54990. // Prepare the response
  54991. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  54992. var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
  54993. request.responseText : request.response;
  54994. var response = {
  54995. data: responseData,
  54996. status: request.status,
  54997. statusText: request.statusText,
  54998. headers: responseHeaders,
  54999. config: config,
  55000. request: request
  55001. };
  55002. settle(function _resolve(value) {
  55003. resolve(value);
  55004. done();
  55005. }, function _reject(err) {
  55006. reject(err);
  55007. done();
  55008. }, response);
  55009. // Clean up request
  55010. request = null;
  55011. }
  55012. if ('onloadend' in request) {
  55013. // Use onloadend if available
  55014. request.onloadend = onloadend;
  55015. } else {
  55016. // Listen for ready state to emulate onloadend
  55017. request.onreadystatechange = function handleLoad() {
  55018. if (!request || request.readyState !== 4) {
  55019. return;
  55020. }
  55021. // The request errored out and we didn't get a response, this will be
  55022. // handled by onerror instead
  55023. // With one exception: request that using file: protocol, most browsers
  55024. // will return status as 0 even though it's a successful request
  55025. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  55026. return;
  55027. }
  55028. // readystate handler is calling before onerror or ontimeout handlers,
  55029. // so we should call onloadend on the next 'tick'
  55030. setTimeout(onloadend);
  55031. };
  55032. }
  55033. // Handle browser request cancellation (as opposed to a manual cancellation)
  55034. request.onabort = function handleAbort() {
  55035. if (!request) {
  55036. return;
  55037. }
  55038. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  55039. // Clean up request
  55040. request = null;
  55041. };
  55042. // Handle low level network errors
  55043. request.onerror = function handleError() {
  55044. // Real errors are hidden from us by the browser
  55045. // onerror should only fire if it's a network error
  55046. reject(createError('Network Error', config, null, request));
  55047. // Clean up request
  55048. request = null;
  55049. };
  55050. // Handle timeout
  55051. request.ontimeout = function handleTimeout() {
  55052. var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
  55053. var transitional$1 = config.transitional || transitional;
  55054. if (config.timeoutErrorMessage) {
  55055. timeoutErrorMessage = config.timeoutErrorMessage;
  55056. }
  55057. reject(createError(
  55058. timeoutErrorMessage,
  55059. config,
  55060. transitional$1.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
  55061. request));
  55062. // Clean up request
  55063. request = null;
  55064. };
  55065. // Add xsrf header
  55066. // This is only done if running in a standard browser environment.
  55067. // Specifically not if we're in a web worker, or react-native.
  55068. if (utils.isStandardBrowserEnv()) {
  55069. // Add xsrf header
  55070. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  55071. cookies.read(config.xsrfCookieName) :
  55072. undefined;
  55073. if (xsrfValue) {
  55074. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  55075. }
  55076. }
  55077. // Add headers to the request
  55078. if ('setRequestHeader' in request) {
  55079. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  55080. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  55081. // Remove Content-Type if data is undefined
  55082. delete requestHeaders[key];
  55083. } else {
  55084. // Otherwise add header to the request
  55085. request.setRequestHeader(key, val);
  55086. }
  55087. });
  55088. }
  55089. // Add withCredentials to request if needed
  55090. if (!utils.isUndefined(config.withCredentials)) {
  55091. request.withCredentials = !!config.withCredentials;
  55092. }
  55093. // Add responseType to request if needed
  55094. if (responseType && responseType !== 'json') {
  55095. request.responseType = config.responseType;
  55096. }
  55097. // Handle progress if needed
  55098. if (typeof config.onDownloadProgress === 'function') {
  55099. request.addEventListener('progress', config.onDownloadProgress);
  55100. }
  55101. // Not all browsers support upload events
  55102. if (typeof config.onUploadProgress === 'function' && request.upload) {
  55103. request.upload.addEventListener('progress', config.onUploadProgress);
  55104. }
  55105. if (config.cancelToken || config.signal) {
  55106. // Handle cancellation
  55107. // eslint-disable-next-line func-names
  55108. onCanceled = function(cancel) {
  55109. if (!request) {
  55110. return;
  55111. }
  55112. reject(!cancel || (cancel && cancel.type) ? new Cancel_1('canceled') : cancel);
  55113. request.abort();
  55114. request = null;
  55115. };
  55116. config.cancelToken && config.cancelToken.subscribe(onCanceled);
  55117. if (config.signal) {
  55118. config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
  55119. }
  55120. }
  55121. if (!requestData) {
  55122. requestData = null;
  55123. }
  55124. // Send the request
  55125. request.send(requestData);
  55126. });
  55127. };
  55128. var DEFAULT_CONTENT_TYPE = {
  55129. 'Content-Type': 'application/x-www-form-urlencoded'
  55130. };
  55131. function setContentTypeIfUnset(headers, value) {
  55132. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  55133. headers['Content-Type'] = value;
  55134. }
  55135. }
  55136. function getDefaultAdapter() {
  55137. var adapter;
  55138. if (typeof XMLHttpRequest !== 'undefined') {
  55139. // For browsers use XHR adapter
  55140. adapter = xhr;
  55141. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  55142. // For node use HTTP adapter
  55143. adapter = xhr;
  55144. }
  55145. return adapter;
  55146. }
  55147. function stringifySafely(rawValue, parser, encoder) {
  55148. if (utils.isString(rawValue)) {
  55149. try {
  55150. (parser || JSON.parse)(rawValue);
  55151. return utils.trim(rawValue);
  55152. } catch (e) {
  55153. if (e.name !== 'SyntaxError') {
  55154. throw e;
  55155. }
  55156. }
  55157. }
  55158. return (encoder || JSON.stringify)(rawValue);
  55159. }
  55160. var defaults = {
  55161. transitional: transitional,
  55162. adapter: getDefaultAdapter(),
  55163. transformRequest: [function transformRequest(data, headers) {
  55164. normalizeHeaderName(headers, 'Accept');
  55165. normalizeHeaderName(headers, 'Content-Type');
  55166. if (utils.isFormData(data) ||
  55167. utils.isArrayBuffer(data) ||
  55168. utils.isBuffer(data) ||
  55169. utils.isStream(data) ||
  55170. utils.isFile(data) ||
  55171. utils.isBlob(data)
  55172. ) {
  55173. return data;
  55174. }
  55175. if (utils.isArrayBufferView(data)) {
  55176. return data.buffer;
  55177. }
  55178. if (utils.isURLSearchParams(data)) {
  55179. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  55180. return data.toString();
  55181. }
  55182. if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
  55183. setContentTypeIfUnset(headers, 'application/json');
  55184. return stringifySafely(data);
  55185. }
  55186. return data;
  55187. }],
  55188. transformResponse: [function transformResponse(data) {
  55189. var transitional = this.transitional || defaults.transitional;
  55190. var silentJSONParsing = transitional && transitional.silentJSONParsing;
  55191. var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
  55192. var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
  55193. if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
  55194. try {
  55195. return JSON.parse(data);
  55196. } catch (e) {
  55197. if (strictJSONParsing) {
  55198. if (e.name === 'SyntaxError') {
  55199. throw enhanceError(e, this, 'E_JSON_PARSE');
  55200. }
  55201. throw e;
  55202. }
  55203. }
  55204. }
  55205. return data;
  55206. }],
  55207. /**
  55208. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  55209. * timeout is not created.
  55210. */
  55211. timeout: 0,
  55212. xsrfCookieName: 'XSRF-TOKEN',
  55213. xsrfHeaderName: 'X-XSRF-TOKEN',
  55214. maxContentLength: -1,
  55215. maxBodyLength: -1,
  55216. validateStatus: function validateStatus(status) {
  55217. return status >= 200 && status < 300;
  55218. },
  55219. headers: {
  55220. common: {
  55221. 'Accept': 'application/json, text/plain, */*'
  55222. }
  55223. }
  55224. };
  55225. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  55226. defaults.headers[method] = {};
  55227. });
  55228. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  55229. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  55230. });
  55231. var defaults_1 = defaults;
  55232. /**
  55233. * Transform the data for a request or a response
  55234. *
  55235. * @param {Object|String} data The data to be transformed
  55236. * @param {Array} headers The headers for the request or response
  55237. * @param {Array|Function} fns A single function or Array of functions
  55238. * @returns {*} The resulting transformed data
  55239. */
  55240. var transformData = function transformData(data, headers, fns) {
  55241. var context = this || defaults_1;
  55242. /*eslint no-param-reassign:0*/
  55243. utils.forEach(fns, function transform(fn) {
  55244. data = fn.call(context, data, headers);
  55245. });
  55246. return data;
  55247. };
  55248. var isCancel = function isCancel(value) {
  55249. return !!(value && value.__CANCEL__);
  55250. };
  55251. /**
  55252. * Throws a `Cancel` if cancellation has been requested.
  55253. */
  55254. function throwIfCancellationRequested(config) {
  55255. if (config.cancelToken) {
  55256. config.cancelToken.throwIfRequested();
  55257. }
  55258. if (config.signal && config.signal.aborted) {
  55259. throw new Cancel_1('canceled');
  55260. }
  55261. }
  55262. /**
  55263. * Dispatch a request to the server using the configured adapter.
  55264. *
  55265. * @param {object} config The config that is to be used for the request
  55266. * @returns {Promise} The Promise to be fulfilled
  55267. */
  55268. var dispatchRequest = function dispatchRequest(config) {
  55269. throwIfCancellationRequested(config);
  55270. // Ensure headers exist
  55271. config.headers = config.headers || {};
  55272. // Transform request data
  55273. config.data = transformData.call(
  55274. config,
  55275. config.data,
  55276. config.headers,
  55277. config.transformRequest
  55278. );
  55279. // Flatten headers
  55280. config.headers = utils.merge(
  55281. config.headers.common || {},
  55282. config.headers[config.method] || {},
  55283. config.headers
  55284. );
  55285. utils.forEach(
  55286. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  55287. function cleanHeaderConfig(method) {
  55288. delete config.headers[method];
  55289. }
  55290. );
  55291. var adapter = config.adapter || defaults_1.adapter;
  55292. return adapter(config).then(function onAdapterResolution(response) {
  55293. throwIfCancellationRequested(config);
  55294. // Transform response data
  55295. response.data = transformData.call(
  55296. config,
  55297. response.data,
  55298. response.headers,
  55299. config.transformResponse
  55300. );
  55301. return response;
  55302. }, function onAdapterRejection(reason) {
  55303. if (!isCancel(reason)) {
  55304. throwIfCancellationRequested(config);
  55305. // Transform response data
  55306. if (reason && reason.response) {
  55307. reason.response.data = transformData.call(
  55308. config,
  55309. reason.response.data,
  55310. reason.response.headers,
  55311. config.transformResponse
  55312. );
  55313. }
  55314. }
  55315. return Promise.reject(reason);
  55316. });
  55317. };
  55318. /**
  55319. * Config-specific merge-function which creates a new config-object
  55320. * by merging two configuration objects together.
  55321. *
  55322. * @param {Object} config1
  55323. * @param {Object} config2
  55324. * @returns {Object} New object resulting from merging config2 to config1
  55325. */
  55326. var mergeConfig = function mergeConfig(config1, config2) {
  55327. // eslint-disable-next-line no-param-reassign
  55328. config2 = config2 || {};
  55329. var config = {};
  55330. function getMergedValue(target, source) {
  55331. if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
  55332. return utils.merge(target, source);
  55333. } else if (utils.isPlainObject(source)) {
  55334. return utils.merge({}, source);
  55335. } else if (utils.isArray(source)) {
  55336. return source.slice();
  55337. }
  55338. return source;
  55339. }
  55340. // eslint-disable-next-line consistent-return
  55341. function mergeDeepProperties(prop) {
  55342. if (!utils.isUndefined(config2[prop])) {
  55343. return getMergedValue(config1[prop], config2[prop]);
  55344. } else if (!utils.isUndefined(config1[prop])) {
  55345. return getMergedValue(undefined, config1[prop]);
  55346. }
  55347. }
  55348. // eslint-disable-next-line consistent-return
  55349. function valueFromConfig2(prop) {
  55350. if (!utils.isUndefined(config2[prop])) {
  55351. return getMergedValue(undefined, config2[prop]);
  55352. }
  55353. }
  55354. // eslint-disable-next-line consistent-return
  55355. function defaultToConfig2(prop) {
  55356. if (!utils.isUndefined(config2[prop])) {
  55357. return getMergedValue(undefined, config2[prop]);
  55358. } else if (!utils.isUndefined(config1[prop])) {
  55359. return getMergedValue(undefined, config1[prop]);
  55360. }
  55361. }
  55362. // eslint-disable-next-line consistent-return
  55363. function mergeDirectKeys(prop) {
  55364. if (prop in config2) {
  55365. return getMergedValue(config1[prop], config2[prop]);
  55366. } else if (prop in config1) {
  55367. return getMergedValue(undefined, config1[prop]);
  55368. }
  55369. }
  55370. var mergeMap = {
  55371. 'url': valueFromConfig2,
  55372. 'method': valueFromConfig2,
  55373. 'data': valueFromConfig2,
  55374. 'baseURL': defaultToConfig2,
  55375. 'transformRequest': defaultToConfig2,
  55376. 'transformResponse': defaultToConfig2,
  55377. 'paramsSerializer': defaultToConfig2,
  55378. 'timeout': defaultToConfig2,
  55379. 'timeoutMessage': defaultToConfig2,
  55380. 'withCredentials': defaultToConfig2,
  55381. 'adapter': defaultToConfig2,
  55382. 'responseType': defaultToConfig2,
  55383. 'xsrfCookieName': defaultToConfig2,
  55384. 'xsrfHeaderName': defaultToConfig2,
  55385. 'onUploadProgress': defaultToConfig2,
  55386. 'onDownloadProgress': defaultToConfig2,
  55387. 'decompress': defaultToConfig2,
  55388. 'maxContentLength': defaultToConfig2,
  55389. 'maxBodyLength': defaultToConfig2,
  55390. 'transport': defaultToConfig2,
  55391. 'httpAgent': defaultToConfig2,
  55392. 'httpsAgent': defaultToConfig2,
  55393. 'cancelToken': defaultToConfig2,
  55394. 'socketPath': defaultToConfig2,
  55395. 'responseEncoding': defaultToConfig2,
  55396. 'validateStatus': mergeDirectKeys
  55397. };
  55398. utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
  55399. var merge = mergeMap[prop] || mergeDeepProperties;
  55400. var configValue = merge(prop);
  55401. (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
  55402. });
  55403. return config;
  55404. };
  55405. var data$1 = {
  55406. "version": "0.26.1"
  55407. };
  55408. var VERSION = data$1.version;
  55409. var validators = {};
  55410. // eslint-disable-next-line func-names
  55411. ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
  55412. validators[type] = function validator(thing) {
  55413. return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
  55414. };
  55415. });
  55416. var deprecatedWarnings = {};
  55417. /**
  55418. * Transitional option validator
  55419. * @param {function|boolean?} validator - set to false if the transitional option has been removed
  55420. * @param {string?} version - deprecated version / removed since version
  55421. * @param {string?} message - some message with additional info
  55422. * @returns {function}
  55423. */
  55424. validators.transitional = function transitional(validator, version, message) {
  55425. function formatMessage(opt, desc) {
  55426. return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
  55427. }
  55428. // eslint-disable-next-line func-names
  55429. return function(value, opt, opts) {
  55430. if (validator === false) {
  55431. throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
  55432. }
  55433. if (version && !deprecatedWarnings[opt]) {
  55434. deprecatedWarnings[opt] = true;
  55435. // eslint-disable-next-line no-console
  55436. console.warn(
  55437. formatMessage(
  55438. opt,
  55439. ' has been deprecated since v' + version + ' and will be removed in the near future'
  55440. )
  55441. );
  55442. }
  55443. return validator ? validator(value, opt, opts) : true;
  55444. };
  55445. };
  55446. /**
  55447. * Assert object's properties type
  55448. * @param {object} options
  55449. * @param {object} schema
  55450. * @param {boolean?} allowUnknown
  55451. */
  55452. function assertOptions(options, schema, allowUnknown) {
  55453. if (typeof options !== 'object') {
  55454. throw new TypeError('options must be an object');
  55455. }
  55456. var keys = Object.keys(options);
  55457. var i = keys.length;
  55458. while (i-- > 0) {
  55459. var opt = keys[i];
  55460. var validator = schema[opt];
  55461. if (validator) {
  55462. var value = options[opt];
  55463. var result = value === undefined || validator(value, opt, options);
  55464. if (result !== true) {
  55465. throw new TypeError('option ' + opt + ' must be ' + result);
  55466. }
  55467. continue;
  55468. }
  55469. if (allowUnknown !== true) {
  55470. throw Error('Unknown option ' + opt);
  55471. }
  55472. }
  55473. }
  55474. var validator = {
  55475. assertOptions: assertOptions,
  55476. validators: validators
  55477. };
  55478. var validators$1 = validator.validators;
  55479. /**
  55480. * Create a new instance of Axios
  55481. *
  55482. * @param {Object} instanceConfig The default config for the instance
  55483. */
  55484. function Axios(instanceConfig) {
  55485. this.defaults = instanceConfig;
  55486. this.interceptors = {
  55487. request: new InterceptorManager_1(),
  55488. response: new InterceptorManager_1()
  55489. };
  55490. }
  55491. /**
  55492. * Dispatch a request
  55493. *
  55494. * @param {Object} config The config specific for this request (merged with this.defaults)
  55495. */
  55496. Axios.prototype.request = function request(configOrUrl, config) {
  55497. /*eslint no-param-reassign:0*/
  55498. // Allow for axios('example/url'[, config]) a la fetch API
  55499. if (typeof configOrUrl === 'string') {
  55500. config = config || {};
  55501. config.url = configOrUrl;
  55502. } else {
  55503. config = configOrUrl || {};
  55504. }
  55505. config = mergeConfig(this.defaults, config);
  55506. // Set config.method
  55507. if (config.method) {
  55508. config.method = config.method.toLowerCase();
  55509. } else if (this.defaults.method) {
  55510. config.method = this.defaults.method.toLowerCase();
  55511. } else {
  55512. config.method = 'get';
  55513. }
  55514. var transitional = config.transitional;
  55515. if (transitional !== undefined) {
  55516. validator.assertOptions(transitional, {
  55517. silentJSONParsing: validators$1.transitional(validators$1.boolean),
  55518. forcedJSONParsing: validators$1.transitional(validators$1.boolean),
  55519. clarifyTimeoutError: validators$1.transitional(validators$1.boolean)
  55520. }, false);
  55521. }
  55522. // filter out skipped interceptors
  55523. var requestInterceptorChain = [];
  55524. var synchronousRequestInterceptors = true;
  55525. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  55526. if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
  55527. return;
  55528. }
  55529. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  55530. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  55531. });
  55532. var responseInterceptorChain = [];
  55533. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  55534. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  55535. });
  55536. var promise;
  55537. if (!synchronousRequestInterceptors) {
  55538. var chain = [dispatchRequest, undefined];
  55539. Array.prototype.unshift.apply(chain, requestInterceptorChain);
  55540. chain = chain.concat(responseInterceptorChain);
  55541. promise = Promise.resolve(config);
  55542. while (chain.length) {
  55543. promise = promise.then(chain.shift(), chain.shift());
  55544. }
  55545. return promise;
  55546. }
  55547. var newConfig = config;
  55548. while (requestInterceptorChain.length) {
  55549. var onFulfilled = requestInterceptorChain.shift();
  55550. var onRejected = requestInterceptorChain.shift();
  55551. try {
  55552. newConfig = onFulfilled(newConfig);
  55553. } catch (error) {
  55554. onRejected(error);
  55555. break;
  55556. }
  55557. }
  55558. try {
  55559. promise = dispatchRequest(newConfig);
  55560. } catch (error) {
  55561. return Promise.reject(error);
  55562. }
  55563. while (responseInterceptorChain.length) {
  55564. promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
  55565. }
  55566. return promise;
  55567. };
  55568. Axios.prototype.getUri = function getUri(config) {
  55569. config = mergeConfig(this.defaults, config);
  55570. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  55571. };
  55572. // Provide aliases for supported request methods
  55573. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  55574. /*eslint func-names:0*/
  55575. Axios.prototype[method] = function(url, config) {
  55576. return this.request(mergeConfig(config || {}, {
  55577. method: method,
  55578. url: url,
  55579. data: (config || {}).data
  55580. }));
  55581. };
  55582. });
  55583. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  55584. /*eslint func-names:0*/
  55585. Axios.prototype[method] = function(url, data, config) {
  55586. return this.request(mergeConfig(config || {}, {
  55587. method: method,
  55588. url: url,
  55589. data: data
  55590. }));
  55591. };
  55592. });
  55593. var Axios_1 = Axios;
  55594. /**
  55595. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  55596. *
  55597. * @class
  55598. * @param {Function} executor The executor function.
  55599. */
  55600. function CancelToken(executor) {
  55601. if (typeof executor !== 'function') {
  55602. throw new TypeError('executor must be a function.');
  55603. }
  55604. var resolvePromise;
  55605. this.promise = new Promise(function promiseExecutor(resolve) {
  55606. resolvePromise = resolve;
  55607. });
  55608. var token = this;
  55609. // eslint-disable-next-line func-names
  55610. this.promise.then(function(cancel) {
  55611. if (!token._listeners) return;
  55612. var i;
  55613. var l = token._listeners.length;
  55614. for (i = 0; i < l; i++) {
  55615. token._listeners[i](cancel);
  55616. }
  55617. token._listeners = null;
  55618. });
  55619. // eslint-disable-next-line func-names
  55620. this.promise.then = function(onfulfilled) {
  55621. var _resolve;
  55622. // eslint-disable-next-line func-names
  55623. var promise = new Promise(function(resolve) {
  55624. token.subscribe(resolve);
  55625. _resolve = resolve;
  55626. }).then(onfulfilled);
  55627. promise.cancel = function reject() {
  55628. token.unsubscribe(_resolve);
  55629. };
  55630. return promise;
  55631. };
  55632. executor(function cancel(message) {
  55633. if (token.reason) {
  55634. // Cancellation has already been requested
  55635. return;
  55636. }
  55637. token.reason = new Cancel_1(message);
  55638. resolvePromise(token.reason);
  55639. });
  55640. }
  55641. /**
  55642. * Throws a `Cancel` if cancellation has been requested.
  55643. */
  55644. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  55645. if (this.reason) {
  55646. throw this.reason;
  55647. }
  55648. };
  55649. /**
  55650. * Subscribe to the cancel signal
  55651. */
  55652. CancelToken.prototype.subscribe = function subscribe(listener) {
  55653. if (this.reason) {
  55654. listener(this.reason);
  55655. return;
  55656. }
  55657. if (this._listeners) {
  55658. this._listeners.push(listener);
  55659. } else {
  55660. this._listeners = [listener];
  55661. }
  55662. };
  55663. /**
  55664. * Unsubscribe from the cancel signal
  55665. */
  55666. CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
  55667. if (!this._listeners) {
  55668. return;
  55669. }
  55670. var index = this._listeners.indexOf(listener);
  55671. if (index !== -1) {
  55672. this._listeners.splice(index, 1);
  55673. }
  55674. };
  55675. /**
  55676. * Returns an object that contains a new `CancelToken` and a function that, when called,
  55677. * cancels the `CancelToken`.
  55678. */
  55679. CancelToken.source = function source() {
  55680. var cancel;
  55681. var token = new CancelToken(function executor(c) {
  55682. cancel = c;
  55683. });
  55684. return {
  55685. token: token,
  55686. cancel: cancel
  55687. };
  55688. };
  55689. var CancelToken_1 = CancelToken;
  55690. /**
  55691. * Syntactic sugar for invoking a function and expanding an array for arguments.
  55692. *
  55693. * Common use case would be to use `Function.prototype.apply`.
  55694. *
  55695. * ```js
  55696. * function f(x, y, z) {}
  55697. * var args = [1, 2, 3];
  55698. * f.apply(null, args);
  55699. * ```
  55700. *
  55701. * With `spread` this example can be re-written.
  55702. *
  55703. * ```js
  55704. * spread(function(x, y, z) {})([1, 2, 3]);
  55705. * ```
  55706. *
  55707. * @param {Function} callback
  55708. * @returns {Function}
  55709. */
  55710. var spread = function spread(callback) {
  55711. return function wrap(arr) {
  55712. return callback.apply(null, arr);
  55713. };
  55714. };
  55715. /**
  55716. * Determines whether the payload is an error thrown by Axios
  55717. *
  55718. * @param {*} payload The value to test
  55719. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  55720. */
  55721. var isAxiosError = function isAxiosError(payload) {
  55722. return utils.isObject(payload) && (payload.isAxiosError === true);
  55723. };
  55724. /**
  55725. * Create an instance of Axios
  55726. *
  55727. * @param {Object} defaultConfig The default config for the instance
  55728. * @return {Axios} A new instance of Axios
  55729. */
  55730. function createInstance(defaultConfig) {
  55731. var context = new Axios_1(defaultConfig);
  55732. var instance = bind$a(Axios_1.prototype.request, context);
  55733. // Copy axios.prototype to instance
  55734. utils.extend(instance, Axios_1.prototype, context);
  55735. // Copy context to instance
  55736. utils.extend(instance, context);
  55737. // Factory for creating new instances
  55738. instance.create = function create(instanceConfig) {
  55739. return createInstance(mergeConfig(defaultConfig, instanceConfig));
  55740. };
  55741. return instance;
  55742. }
  55743. // Create the default instance to be exported
  55744. var axios = createInstance(defaults_1);
  55745. // Expose Axios class to allow class inheritance
  55746. axios.Axios = Axios_1;
  55747. // Expose Cancel & CancelToken
  55748. axios.Cancel = Cancel_1;
  55749. axios.CancelToken = CancelToken_1;
  55750. axios.isCancel = isCancel;
  55751. axios.VERSION = data$1.version;
  55752. // Expose all/spread
  55753. axios.all = function all(promises) {
  55754. return Promise.all(promises);
  55755. };
  55756. axios.spread = spread;
  55757. // Expose isAxiosError
  55758. axios.isAxiosError = isAxiosError;
  55759. var axios_1 = axios;
  55760. // Allow use of default import syntax in TypeScript
  55761. var _default = axios;
  55762. axios_1.default = _default;
  55763. var axios$1 = axios_1;
  55764. var base$1 = createCommonjsModule(function (module, exports) {
  55765. /* tslint:disable */
  55766. /* eslint-disable */
  55767. /**
  55768. * OpenAI API
  55769. * APIs for sampling from and fine-tuning language models
  55770. *
  55771. * The version of the OpenAPI document: 1.3.0
  55772. *
  55773. *
  55774. * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
  55775. * https://openapi-generator.tech
  55776. * Do not edit the class manually.
  55777. */
  55778. Object.defineProperty(exports, "__esModule", { value: true });
  55779. exports.RequiredError = exports.BaseAPI = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
  55780. exports.BASE_PATH = "https://api.openai.com/v1".replace(/\/+$/, "");
  55781. /**
  55782. *
  55783. * @export
  55784. */
  55785. exports.COLLECTION_FORMATS = {
  55786. csv: ",",
  55787. ssv: " ",
  55788. tsv: "\t",
  55789. pipes: "|",
  55790. };
  55791. /**
  55792. *
  55793. * @export
  55794. * @class BaseAPI
  55795. */
  55796. class BaseAPI {
  55797. constructor(configuration, basePath = exports.BASE_PATH, axios = axios$1.default) {
  55798. this.basePath = basePath;
  55799. this.axios = axios;
  55800. if (configuration) {
  55801. this.configuration = configuration;
  55802. this.basePath = configuration.basePath || this.basePath;
  55803. }
  55804. }
  55805. }
  55806. exports.BaseAPI = BaseAPI;
  55807. /**
  55808. *
  55809. * @export
  55810. * @class RequiredError
  55811. * @extends {Error}
  55812. */
  55813. class RequiredError extends Error {
  55814. constructor(field, msg) {
  55815. super(msg);
  55816. this.field = field;
  55817. this.name = "RequiredError";
  55818. }
  55819. }
  55820. exports.RequiredError = RequiredError;
  55821. });
  55822. unwrapExports(base$1);
  55823. var base_1 = base$1.RequiredError;
  55824. var base_2 = base$1.BaseAPI;
  55825. var base_3 = base$1.COLLECTION_FORMATS;
  55826. var base_4 = base$1.BASE_PATH;
  55827. var common = createCommonjsModule(function (module, exports) {
  55828. /* tslint:disable */
  55829. /* eslint-disable */
  55830. /**
  55831. * OpenAI API
  55832. * APIs for sampling from and fine-tuning language models
  55833. *
  55834. * The version of the OpenAPI document: 1.3.0
  55835. *
  55836. *
  55837. * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
  55838. * https://openapi-generator.tech
  55839. * Do not edit the class manually.
  55840. */
  55841. var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
  55842. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  55843. return new (P || (P = Promise))(function (resolve, reject) {
  55844. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  55845. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  55846. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  55847. step((generator = generator.apply(thisArg, _arguments || [])).next());
  55848. });
  55849. };
  55850. Object.defineProperty(exports, "__esModule", { value: true });
  55851. exports.createRequestFunction = exports.toPathString = exports.serializeDataIfNeeded = exports.setSearchParams = exports.setOAuthToObject = exports.setBearerAuthToObject = exports.setBasicAuthToObject = exports.setApiKeyToObject = exports.assertParamExists = exports.DUMMY_BASE_URL = void 0;
  55852. /**
  55853. *
  55854. * @export
  55855. */
  55856. exports.DUMMY_BASE_URL = 'https://example.com';
  55857. /**
  55858. *
  55859. * @throws {RequiredError}
  55860. * @export
  55861. */
  55862. exports.assertParamExists = function (functionName, paramName, paramValue) {
  55863. if (paramValue === null || paramValue === undefined) {
  55864. throw new base$1.RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
  55865. }
  55866. };
  55867. /**
  55868. *
  55869. * @export
  55870. */
  55871. exports.setApiKeyToObject = function (object, keyParamName, configuration) {
  55872. return __awaiter(this, void 0, void 0, function* () {
  55873. if (configuration && configuration.apiKey) {
  55874. const localVarApiKeyValue = typeof configuration.apiKey === 'function'
  55875. ? yield configuration.apiKey(keyParamName)
  55876. : yield configuration.apiKey;
  55877. object[keyParamName] = localVarApiKeyValue;
  55878. }
  55879. });
  55880. };
  55881. /**
  55882. *
  55883. * @export
  55884. */
  55885. exports.setBasicAuthToObject = function (object, configuration) {
  55886. if (configuration && (configuration.username || configuration.password)) {
  55887. object["auth"] = { username: configuration.username, password: configuration.password };
  55888. }
  55889. };
  55890. /**
  55891. *
  55892. * @export
  55893. */
  55894. exports.setBearerAuthToObject = function (object, configuration) {
  55895. return __awaiter(this, void 0, void 0, function* () {
  55896. if (configuration && configuration.accessToken) {
  55897. const accessToken = typeof configuration.accessToken === 'function'
  55898. ? yield configuration.accessToken()
  55899. : yield configuration.accessToken;
  55900. object["Authorization"] = "Bearer " + accessToken;
  55901. }
  55902. });
  55903. };
  55904. /**
  55905. *
  55906. * @export
  55907. */
  55908. exports.setOAuthToObject = function (object, name, scopes, configuration) {
  55909. return __awaiter(this, void 0, void 0, function* () {
  55910. if (configuration && configuration.accessToken) {
  55911. const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
  55912. ? yield configuration.accessToken(name, scopes)
  55913. : yield configuration.accessToken;
  55914. object["Authorization"] = "Bearer " + localVarAccessTokenValue;
  55915. }
  55916. });
  55917. };
  55918. function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
  55919. if (parameter == null)
  55920. return;
  55921. if (typeof parameter === "object") {
  55922. if (Array.isArray(parameter)) {
  55923. parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
  55924. }
  55925. else {
  55926. Object.keys(parameter).forEach(currentKey => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`));
  55927. }
  55928. }
  55929. else {
  55930. if (urlSearchParams.has(key)) {
  55931. urlSearchParams.append(key, parameter);
  55932. }
  55933. else {
  55934. urlSearchParams.set(key, parameter);
  55935. }
  55936. }
  55937. }
  55938. /**
  55939. *
  55940. * @export
  55941. */
  55942. exports.setSearchParams = function (url, ...objects) {
  55943. const searchParams = new URLSearchParams(url.search);
  55944. setFlattenedQueryParams(searchParams, objects);
  55945. url.search = searchParams.toString();
  55946. };
  55947. /**
  55948. *
  55949. * @export
  55950. */
  55951. exports.serializeDataIfNeeded = function (value, requestOptions, configuration) {
  55952. const nonString = typeof value !== 'string';
  55953. const needsSerialization = nonString && configuration && configuration.isJsonMime
  55954. ? configuration.isJsonMime(requestOptions.headers['Content-Type'])
  55955. : nonString;
  55956. return needsSerialization
  55957. ? JSON.stringify(value !== undefined ? value : {})
  55958. : (value || "");
  55959. };
  55960. /**
  55961. *
  55962. * @export
  55963. */
  55964. exports.toPathString = function (url) {
  55965. return url.pathname + url.search + url.hash;
  55966. };
  55967. /**
  55968. *
  55969. * @export
  55970. */
  55971. exports.createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) {
  55972. return (axios = globalAxios, basePath = BASE_PATH) => {
  55973. const axiosRequestArgs = Object.assign(Object.assign({}, axiosArgs.options), { url: ((configuration === null || configuration === void 0 ? void 0 : configuration.basePath) || basePath) + axiosArgs.url });
  55974. return axios.request(axiosRequestArgs);
  55975. };
  55976. };
  55977. });
  55978. unwrapExports(common);
  55979. var common_1 = common.createRequestFunction;
  55980. var common_2 = common.toPathString;
  55981. var common_3 = common.serializeDataIfNeeded;
  55982. var common_4 = common.setSearchParams;
  55983. var common_5 = common.setOAuthToObject;
  55984. var common_6 = common.setBearerAuthToObject;
  55985. var common_7 = common.setBasicAuthToObject;
  55986. var common_8 = common.setApiKeyToObject;
  55987. var common_9 = common.assertParamExists;
  55988. var common_10 = common.DUMMY_BASE_URL;
  55989. var api = createCommonjsModule(function (module, exports) {
  55990. /* tslint:disable */
  55991. /* eslint-disable */
  55992. /**
  55993. * OpenAI API
  55994. * APIs for sampling from and fine-tuning language models
  55995. *
  55996. * The version of the OpenAPI document: 1.3.0
  55997. *
  55998. *
  55999. * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
  56000. * https://openapi-generator.tech
  56001. * Do not edit the class manually.
  56002. */
  56003. var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
  56004. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  56005. return new (P || (P = Promise))(function (resolve, reject) {
  56006. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  56007. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  56008. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  56009. step((generator = generator.apply(thisArg, _arguments || [])).next());
  56010. });
  56011. };
  56012. Object.defineProperty(exports, "__esModule", { value: true });
  56013. exports.OpenAIApi = exports.OpenAIApiFactory = exports.OpenAIApiFp = exports.OpenAIApiAxiosParamCreator = exports.CreateImageRequestResponseFormatEnum = exports.CreateImageRequestSizeEnum = exports.ChatCompletionResponseMessageRoleEnum = exports.ChatCompletionRequestMessageRoleEnum = void 0;
  56014. // Some imports not used depending on template conditions
  56015. // @ts-ignore
  56016. // @ts-ignore
  56017. exports.ChatCompletionRequestMessageRoleEnum = {
  56018. System: 'system',
  56019. User: 'user',
  56020. Assistant: 'assistant',
  56021. Function: 'function'
  56022. };
  56023. exports.ChatCompletionResponseMessageRoleEnum = {
  56024. System: 'system',
  56025. User: 'user',
  56026. Assistant: 'assistant',
  56027. Function: 'function'
  56028. };
  56029. exports.CreateImageRequestSizeEnum = {
  56030. _256x256: '256x256',
  56031. _512x512: '512x512',
  56032. _1024x1024: '1024x1024'
  56033. };
  56034. exports.CreateImageRequestResponseFormatEnum = {
  56035. Url: 'url',
  56036. B64Json: 'b64_json'
  56037. };
  56038. /**
  56039. * OpenAIApi - axios parameter creator
  56040. * @export
  56041. */
  56042. exports.OpenAIApiAxiosParamCreator = function (configuration) {
  56043. return {
  56044. /**
  56045. *
  56046. * @summary Immediately cancel a fine-tune job.
  56047. * @param {string} fineTuneId The ID of the fine-tune job to cancel
  56048. * @param {*} [options] Override http request option.
  56049. * @throws {RequiredError}
  56050. */
  56051. cancelFineTune: (fineTuneId, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56052. // verify required parameter 'fineTuneId' is not null or undefined
  56053. common.assertParamExists('cancelFineTune', 'fineTuneId', fineTuneId);
  56054. const localVarPath = `/fine-tunes/{fine_tune_id}/cancel`
  56055. .replace(`{${"fine_tune_id"}}`, encodeURIComponent(String(fineTuneId)));
  56056. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56057. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56058. let baseOptions;
  56059. if (configuration) {
  56060. baseOptions = configuration.baseOptions;
  56061. }
  56062. const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
  56063. const localVarHeaderParameter = {};
  56064. const localVarQueryParameter = {};
  56065. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56066. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56067. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56068. return {
  56069. url: common.toPathString(localVarUrlObj),
  56070. options: localVarRequestOptions,
  56071. };
  56072. }),
  56073. /**
  56074. *
  56075. * @summary Answers the specified question using the provided documents and examples. The endpoint first [searches](/docs/api-reference/searches) over provided documents or files to find relevant context. The relevant context is combined with the provided examples and question to create the prompt for [completion](/docs/api-reference/completions).
  56076. * @param {CreateAnswerRequest} createAnswerRequest
  56077. * @param {*} [options] Override http request option.
  56078. * @deprecated
  56079. * @throws {RequiredError}
  56080. */
  56081. createAnswer: (createAnswerRequest, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56082. // verify required parameter 'createAnswerRequest' is not null or undefined
  56083. common.assertParamExists('createAnswer', 'createAnswerRequest', createAnswerRequest);
  56084. const localVarPath = `/answers`;
  56085. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56086. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56087. let baseOptions;
  56088. if (configuration) {
  56089. baseOptions = configuration.baseOptions;
  56090. }
  56091. const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
  56092. const localVarHeaderParameter = {};
  56093. const localVarQueryParameter = {};
  56094. localVarHeaderParameter['Content-Type'] = 'application/json';
  56095. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56096. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56097. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56098. localVarRequestOptions.data = common.serializeDataIfNeeded(createAnswerRequest, localVarRequestOptions, configuration);
  56099. return {
  56100. url: common.toPathString(localVarUrlObj),
  56101. options: localVarRequestOptions,
  56102. };
  56103. }),
  56104. /**
  56105. *
  56106. * @summary Creates a model response for the given chat conversation.
  56107. * @param {CreateChatCompletionRequest} createChatCompletionRequest
  56108. * @param {*} [options] Override http request option.
  56109. * @throws {RequiredError}
  56110. */
  56111. createChatCompletion: (createChatCompletionRequest, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56112. // verify required parameter 'createChatCompletionRequest' is not null or undefined
  56113. common.assertParamExists('createChatCompletion', 'createChatCompletionRequest', createChatCompletionRequest);
  56114. const localVarPath = `/chat/completions`;
  56115. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56116. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56117. let baseOptions;
  56118. if (configuration) {
  56119. baseOptions = configuration.baseOptions;
  56120. }
  56121. const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
  56122. const localVarHeaderParameter = {};
  56123. const localVarQueryParameter = {};
  56124. localVarHeaderParameter['Content-Type'] = 'application/json';
  56125. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56126. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56127. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56128. localVarRequestOptions.data = common.serializeDataIfNeeded(createChatCompletionRequest, localVarRequestOptions, configuration);
  56129. return {
  56130. url: common.toPathString(localVarUrlObj),
  56131. options: localVarRequestOptions,
  56132. };
  56133. }),
  56134. /**
  56135. *
  56136. * @summary Classifies the specified `query` using provided examples. The endpoint first [searches](/docs/api-reference/searches) over the labeled examples to select the ones most relevant for the particular query. Then, the relevant examples are combined with the query to construct a prompt to produce the final label via the [completions](/docs/api-reference/completions) endpoint. Labeled examples can be provided via an uploaded `file`, or explicitly listed in the request using the `examples` parameter for quick tests and small scale use cases.
  56137. * @param {CreateClassificationRequest} createClassificationRequest
  56138. * @param {*} [options] Override http request option.
  56139. * @deprecated
  56140. * @throws {RequiredError}
  56141. */
  56142. createClassification: (createClassificationRequest, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56143. // verify required parameter 'createClassificationRequest' is not null or undefined
  56144. common.assertParamExists('createClassification', 'createClassificationRequest', createClassificationRequest);
  56145. const localVarPath = `/classifications`;
  56146. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56147. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56148. let baseOptions;
  56149. if (configuration) {
  56150. baseOptions = configuration.baseOptions;
  56151. }
  56152. const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
  56153. const localVarHeaderParameter = {};
  56154. const localVarQueryParameter = {};
  56155. localVarHeaderParameter['Content-Type'] = 'application/json';
  56156. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56157. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56158. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56159. localVarRequestOptions.data = common.serializeDataIfNeeded(createClassificationRequest, localVarRequestOptions, configuration);
  56160. return {
  56161. url: common.toPathString(localVarUrlObj),
  56162. options: localVarRequestOptions,
  56163. };
  56164. }),
  56165. /**
  56166. *
  56167. * @summary Creates a completion for the provided prompt and parameters.
  56168. * @param {CreateCompletionRequest} createCompletionRequest
  56169. * @param {*} [options] Override http request option.
  56170. * @throws {RequiredError}
  56171. */
  56172. createCompletion: (createCompletionRequest, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56173. // verify required parameter 'createCompletionRequest' is not null or undefined
  56174. common.assertParamExists('createCompletion', 'createCompletionRequest', createCompletionRequest);
  56175. const localVarPath = `/completions`;
  56176. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56177. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56178. let baseOptions;
  56179. if (configuration) {
  56180. baseOptions = configuration.baseOptions;
  56181. }
  56182. const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
  56183. const localVarHeaderParameter = {};
  56184. const localVarQueryParameter = {};
  56185. localVarHeaderParameter['Content-Type'] = 'application/json';
  56186. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56187. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56188. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56189. localVarRequestOptions.data = common.serializeDataIfNeeded(createCompletionRequest, localVarRequestOptions, configuration);
  56190. return {
  56191. url: common.toPathString(localVarUrlObj),
  56192. options: localVarRequestOptions,
  56193. };
  56194. }),
  56195. /**
  56196. *
  56197. * @summary Creates a new edit for the provided input, instruction, and parameters.
  56198. * @param {CreateEditRequest} createEditRequest
  56199. * @param {*} [options] Override http request option.
  56200. * @throws {RequiredError}
  56201. */
  56202. createEdit: (createEditRequest, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56203. // verify required parameter 'createEditRequest' is not null or undefined
  56204. common.assertParamExists('createEdit', 'createEditRequest', createEditRequest);
  56205. const localVarPath = `/edits`;
  56206. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56207. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56208. let baseOptions;
  56209. if (configuration) {
  56210. baseOptions = configuration.baseOptions;
  56211. }
  56212. const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
  56213. const localVarHeaderParameter = {};
  56214. const localVarQueryParameter = {};
  56215. localVarHeaderParameter['Content-Type'] = 'application/json';
  56216. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56217. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56218. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56219. localVarRequestOptions.data = common.serializeDataIfNeeded(createEditRequest, localVarRequestOptions, configuration);
  56220. return {
  56221. url: common.toPathString(localVarUrlObj),
  56222. options: localVarRequestOptions,
  56223. };
  56224. }),
  56225. /**
  56226. *
  56227. * @summary Creates an embedding vector representing the input text.
  56228. * @param {CreateEmbeddingRequest} createEmbeddingRequest
  56229. * @param {*} [options] Override http request option.
  56230. * @throws {RequiredError}
  56231. */
  56232. createEmbedding: (createEmbeddingRequest, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56233. // verify required parameter 'createEmbeddingRequest' is not null or undefined
  56234. common.assertParamExists('createEmbedding', 'createEmbeddingRequest', createEmbeddingRequest);
  56235. const localVarPath = `/embeddings`;
  56236. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56237. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56238. let baseOptions;
  56239. if (configuration) {
  56240. baseOptions = configuration.baseOptions;
  56241. }
  56242. const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
  56243. const localVarHeaderParameter = {};
  56244. const localVarQueryParameter = {};
  56245. localVarHeaderParameter['Content-Type'] = 'application/json';
  56246. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56247. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56248. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56249. localVarRequestOptions.data = common.serializeDataIfNeeded(createEmbeddingRequest, localVarRequestOptions, configuration);
  56250. return {
  56251. url: common.toPathString(localVarUrlObj),
  56252. options: localVarRequestOptions,
  56253. };
  56254. }),
  56255. /**
  56256. *
  56257. * @summary Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.
  56258. * @param {File} file Name of the [JSON Lines](https://jsonlines.readthedocs.io/en/latest/) file to be uploaded. If the &#x60;purpose&#x60; is set to \\\&quot;fine-tune\\\&quot;, each line is a JSON record with \\\&quot;prompt\\\&quot; and \\\&quot;completion\\\&quot; fields representing your [training examples](/docs/guides/fine-tuning/prepare-training-data).
  56259. * @param {string} purpose The intended purpose of the uploaded documents. Use \\\&quot;fine-tune\\\&quot; for [Fine-tuning](/docs/api-reference/fine-tunes). This allows us to validate the format of the uploaded file.
  56260. * @param {*} [options] Override http request option.
  56261. * @throws {RequiredError}
  56262. */
  56263. createFile: (file, purpose, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56264. // verify required parameter 'file' is not null or undefined
  56265. common.assertParamExists('createFile', 'file', file);
  56266. // verify required parameter 'purpose' is not null or undefined
  56267. common.assertParamExists('createFile', 'purpose', purpose);
  56268. const localVarPath = `/files`;
  56269. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56270. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56271. let baseOptions;
  56272. if (configuration) {
  56273. baseOptions = configuration.baseOptions;
  56274. }
  56275. const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
  56276. const localVarHeaderParameter = {};
  56277. const localVarQueryParameter = {};
  56278. const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)();
  56279. if (file !== undefined) {
  56280. localVarFormParams.append('file', file);
  56281. }
  56282. if (purpose !== undefined) {
  56283. localVarFormParams.append('purpose', purpose);
  56284. }
  56285. localVarHeaderParameter['Content-Type'] = 'multipart/form-data';
  56286. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56287. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56288. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), localVarFormParams.getHeaders()), headersFromBaseOptions), options.headers);
  56289. localVarRequestOptions.data = localVarFormParams;
  56290. return {
  56291. url: common.toPathString(localVarUrlObj),
  56292. options: localVarRequestOptions,
  56293. };
  56294. }),
  56295. /**
  56296. *
  56297. * @summary Creates a job that fine-tunes a specified model from a given dataset. Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. [Learn more about Fine-tuning](/docs/guides/fine-tuning)
  56298. * @param {CreateFineTuneRequest} createFineTuneRequest
  56299. * @param {*} [options] Override http request option.
  56300. * @throws {RequiredError}
  56301. */
  56302. createFineTune: (createFineTuneRequest, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56303. // verify required parameter 'createFineTuneRequest' is not null or undefined
  56304. common.assertParamExists('createFineTune', 'createFineTuneRequest', createFineTuneRequest);
  56305. const localVarPath = `/fine-tunes`;
  56306. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56307. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56308. let baseOptions;
  56309. if (configuration) {
  56310. baseOptions = configuration.baseOptions;
  56311. }
  56312. const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
  56313. const localVarHeaderParameter = {};
  56314. const localVarQueryParameter = {};
  56315. localVarHeaderParameter['Content-Type'] = 'application/json';
  56316. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56317. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56318. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56319. localVarRequestOptions.data = common.serializeDataIfNeeded(createFineTuneRequest, localVarRequestOptions, configuration);
  56320. return {
  56321. url: common.toPathString(localVarUrlObj),
  56322. options: localVarRequestOptions,
  56323. };
  56324. }),
  56325. /**
  56326. *
  56327. * @summary Creates an image given a prompt.
  56328. * @param {CreateImageRequest} createImageRequest
  56329. * @param {*} [options] Override http request option.
  56330. * @throws {RequiredError}
  56331. */
  56332. createImage: (createImageRequest, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56333. // verify required parameter 'createImageRequest' is not null or undefined
  56334. common.assertParamExists('createImage', 'createImageRequest', createImageRequest);
  56335. const localVarPath = `/images/generations`;
  56336. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56337. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56338. let baseOptions;
  56339. if (configuration) {
  56340. baseOptions = configuration.baseOptions;
  56341. }
  56342. const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
  56343. const localVarHeaderParameter = {};
  56344. const localVarQueryParameter = {};
  56345. localVarHeaderParameter['Content-Type'] = 'application/json';
  56346. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56347. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56348. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56349. localVarRequestOptions.data = common.serializeDataIfNeeded(createImageRequest, localVarRequestOptions, configuration);
  56350. return {
  56351. url: common.toPathString(localVarUrlObj),
  56352. options: localVarRequestOptions,
  56353. };
  56354. }),
  56355. /**
  56356. *
  56357. * @summary Creates an edited or extended image given an original image and a prompt.
  56358. * @param {File} image The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.
  56359. * @param {string} prompt A text description of the desired image(s). The maximum length is 1000 characters.
  56360. * @param {File} [mask] An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where &#x60;image&#x60; should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as &#x60;image&#x60;.
  56361. * @param {number} [n] The number of images to generate. Must be between 1 and 10.
  56362. * @param {string} [size] The size of the generated images. Must be one of &#x60;256x256&#x60;, &#x60;512x512&#x60;, or &#x60;1024x1024&#x60;.
  56363. * @param {string} [responseFormat] The format in which the generated images are returned. Must be one of &#x60;url&#x60; or &#x60;b64_json&#x60;.
  56364. * @param {string} [user] A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
  56365. * @param {*} [options] Override http request option.
  56366. * @throws {RequiredError}
  56367. */
  56368. createImageEdit: (image, prompt, mask, n, size, responseFormat, user, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56369. // verify required parameter 'image' is not null or undefined
  56370. common.assertParamExists('createImageEdit', 'image', image);
  56371. // verify required parameter 'prompt' is not null or undefined
  56372. common.assertParamExists('createImageEdit', 'prompt', prompt);
  56373. const localVarPath = `/images/edits`;
  56374. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56375. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56376. let baseOptions;
  56377. if (configuration) {
  56378. baseOptions = configuration.baseOptions;
  56379. }
  56380. const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
  56381. const localVarHeaderParameter = {};
  56382. const localVarQueryParameter = {};
  56383. const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)();
  56384. if (image !== undefined) {
  56385. localVarFormParams.append('image', image);
  56386. }
  56387. if (mask !== undefined) {
  56388. localVarFormParams.append('mask', mask);
  56389. }
  56390. if (prompt !== undefined) {
  56391. localVarFormParams.append('prompt', prompt);
  56392. }
  56393. if (n !== undefined) {
  56394. localVarFormParams.append('n', n);
  56395. }
  56396. if (size !== undefined) {
  56397. localVarFormParams.append('size', size);
  56398. }
  56399. if (responseFormat !== undefined) {
  56400. localVarFormParams.append('response_format', responseFormat);
  56401. }
  56402. if (user !== undefined) {
  56403. localVarFormParams.append('user', user);
  56404. }
  56405. localVarHeaderParameter['Content-Type'] = 'multipart/form-data';
  56406. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56407. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56408. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), localVarFormParams.getHeaders()), headersFromBaseOptions), options.headers);
  56409. localVarRequestOptions.data = localVarFormParams;
  56410. return {
  56411. url: common.toPathString(localVarUrlObj),
  56412. options: localVarRequestOptions,
  56413. };
  56414. }),
  56415. /**
  56416. *
  56417. * @summary Creates a variation of a given image.
  56418. * @param {File} image The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
  56419. * @param {number} [n] The number of images to generate. Must be between 1 and 10.
  56420. * @param {string} [size] The size of the generated images. Must be one of &#x60;256x256&#x60;, &#x60;512x512&#x60;, or &#x60;1024x1024&#x60;.
  56421. * @param {string} [responseFormat] The format in which the generated images are returned. Must be one of &#x60;url&#x60; or &#x60;b64_json&#x60;.
  56422. * @param {string} [user] A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
  56423. * @param {*} [options] Override http request option.
  56424. * @throws {RequiredError}
  56425. */
  56426. createImageVariation: (image, n, size, responseFormat, user, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56427. // verify required parameter 'image' is not null or undefined
  56428. common.assertParamExists('createImageVariation', 'image', image);
  56429. const localVarPath = `/images/variations`;
  56430. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56431. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56432. let baseOptions;
  56433. if (configuration) {
  56434. baseOptions = configuration.baseOptions;
  56435. }
  56436. const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
  56437. const localVarHeaderParameter = {};
  56438. const localVarQueryParameter = {};
  56439. const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)();
  56440. if (image !== undefined) {
  56441. localVarFormParams.append('image', image);
  56442. }
  56443. if (n !== undefined) {
  56444. localVarFormParams.append('n', n);
  56445. }
  56446. if (size !== undefined) {
  56447. localVarFormParams.append('size', size);
  56448. }
  56449. if (responseFormat !== undefined) {
  56450. localVarFormParams.append('response_format', responseFormat);
  56451. }
  56452. if (user !== undefined) {
  56453. localVarFormParams.append('user', user);
  56454. }
  56455. localVarHeaderParameter['Content-Type'] = 'multipart/form-data';
  56456. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56457. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56458. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), localVarFormParams.getHeaders()), headersFromBaseOptions), options.headers);
  56459. localVarRequestOptions.data = localVarFormParams;
  56460. return {
  56461. url: common.toPathString(localVarUrlObj),
  56462. options: localVarRequestOptions,
  56463. };
  56464. }),
  56465. /**
  56466. *
  56467. * @summary Classifies if text violates OpenAI\'s Content Policy
  56468. * @param {CreateModerationRequest} createModerationRequest
  56469. * @param {*} [options] Override http request option.
  56470. * @throws {RequiredError}
  56471. */
  56472. createModeration: (createModerationRequest, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56473. // verify required parameter 'createModerationRequest' is not null or undefined
  56474. common.assertParamExists('createModeration', 'createModerationRequest', createModerationRequest);
  56475. const localVarPath = `/moderations`;
  56476. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56477. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56478. let baseOptions;
  56479. if (configuration) {
  56480. baseOptions = configuration.baseOptions;
  56481. }
  56482. const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
  56483. const localVarHeaderParameter = {};
  56484. const localVarQueryParameter = {};
  56485. localVarHeaderParameter['Content-Type'] = 'application/json';
  56486. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56487. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56488. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56489. localVarRequestOptions.data = common.serializeDataIfNeeded(createModerationRequest, localVarRequestOptions, configuration);
  56490. return {
  56491. url: common.toPathString(localVarUrlObj),
  56492. options: localVarRequestOptions,
  56493. };
  56494. }),
  56495. /**
  56496. *
  56497. * @summary The search endpoint computes similarity scores between provided query and documents. Documents can be passed directly to the API if there are no more than 200 of them. To go beyond the 200 document limit, documents can be processed offline and then used for efficient retrieval at query time. When `file` is set, the search endpoint searches over all the documents in the given file and returns up to the `max_rerank` number of documents. These documents will be returned along with their search scores. The similarity score is a positive score that usually ranges from 0 to 300 (but can sometimes go higher), where a score above 200 usually means the document is semantically similar to the query.
  56498. * @param {string} engineId The ID of the engine to use for this request. You can select one of &#x60;ada&#x60;, &#x60;babbage&#x60;, &#x60;curie&#x60;, or &#x60;davinci&#x60;.
  56499. * @param {CreateSearchRequest} createSearchRequest
  56500. * @param {*} [options] Override http request option.
  56501. * @deprecated
  56502. * @throws {RequiredError}
  56503. */
  56504. createSearch: (engineId, createSearchRequest, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56505. // verify required parameter 'engineId' is not null or undefined
  56506. common.assertParamExists('createSearch', 'engineId', engineId);
  56507. // verify required parameter 'createSearchRequest' is not null or undefined
  56508. common.assertParamExists('createSearch', 'createSearchRequest', createSearchRequest);
  56509. const localVarPath = `/engines/{engine_id}/search`
  56510. .replace(`{${"engine_id"}}`, encodeURIComponent(String(engineId)));
  56511. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56512. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56513. let baseOptions;
  56514. if (configuration) {
  56515. baseOptions = configuration.baseOptions;
  56516. }
  56517. const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
  56518. const localVarHeaderParameter = {};
  56519. const localVarQueryParameter = {};
  56520. localVarHeaderParameter['Content-Type'] = 'application/json';
  56521. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56522. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56523. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56524. localVarRequestOptions.data = common.serializeDataIfNeeded(createSearchRequest, localVarRequestOptions, configuration);
  56525. return {
  56526. url: common.toPathString(localVarUrlObj),
  56527. options: localVarRequestOptions,
  56528. };
  56529. }),
  56530. /**
  56531. *
  56532. * @summary Transcribes audio into the input language.
  56533. * @param {File} file The audio file object (not file name) to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.
  56534. * @param {string} model ID of the model to use. Only &#x60;whisper-1&#x60; is currently available.
  56535. * @param {string} [prompt] An optional text to guide the model\\\&#39;s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language.
  56536. * @param {string} [responseFormat] The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt.
  56537. * @param {number} [temperature] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
  56538. * @param {string} [language] The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency.
  56539. * @param {*} [options] Override http request option.
  56540. * @throws {RequiredError}
  56541. */
  56542. createTranscription: (file, model, prompt, responseFormat, temperature, language, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56543. // verify required parameter 'file' is not null or undefined
  56544. common.assertParamExists('createTranscription', 'file', file);
  56545. // verify required parameter 'model' is not null or undefined
  56546. common.assertParamExists('createTranscription', 'model', model);
  56547. const localVarPath = `/audio/transcriptions`;
  56548. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56549. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56550. let baseOptions;
  56551. if (configuration) {
  56552. baseOptions = configuration.baseOptions;
  56553. }
  56554. const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
  56555. const localVarHeaderParameter = {};
  56556. const localVarQueryParameter = {};
  56557. const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)();
  56558. if (file !== undefined) {
  56559. localVarFormParams.append('file', file);
  56560. }
  56561. if (model !== undefined) {
  56562. localVarFormParams.append('model', model);
  56563. }
  56564. if (prompt !== undefined) {
  56565. localVarFormParams.append('prompt', prompt);
  56566. }
  56567. if (responseFormat !== undefined) {
  56568. localVarFormParams.append('response_format', responseFormat);
  56569. }
  56570. if (temperature !== undefined) {
  56571. localVarFormParams.append('temperature', temperature);
  56572. }
  56573. if (language !== undefined) {
  56574. localVarFormParams.append('language', language);
  56575. }
  56576. localVarHeaderParameter['Content-Type'] = 'multipart/form-data';
  56577. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56578. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56579. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), localVarFormParams.getHeaders()), headersFromBaseOptions), options.headers);
  56580. localVarRequestOptions.data = localVarFormParams;
  56581. return {
  56582. url: common.toPathString(localVarUrlObj),
  56583. options: localVarRequestOptions,
  56584. };
  56585. }),
  56586. /**
  56587. *
  56588. * @summary Translates audio into into English.
  56589. * @param {File} file The audio file object (not file name) translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.
  56590. * @param {string} model ID of the model to use. Only &#x60;whisper-1&#x60; is currently available.
  56591. * @param {string} [prompt] An optional text to guide the model\\\&#39;s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English.
  56592. * @param {string} [responseFormat] The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt.
  56593. * @param {number} [temperature] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
  56594. * @param {*} [options] Override http request option.
  56595. * @throws {RequiredError}
  56596. */
  56597. createTranslation: (file, model, prompt, responseFormat, temperature, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56598. // verify required parameter 'file' is not null or undefined
  56599. common.assertParamExists('createTranslation', 'file', file);
  56600. // verify required parameter 'model' is not null or undefined
  56601. common.assertParamExists('createTranslation', 'model', model);
  56602. const localVarPath = `/audio/translations`;
  56603. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56604. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56605. let baseOptions;
  56606. if (configuration) {
  56607. baseOptions = configuration.baseOptions;
  56608. }
  56609. const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
  56610. const localVarHeaderParameter = {};
  56611. const localVarQueryParameter = {};
  56612. const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)();
  56613. if (file !== undefined) {
  56614. localVarFormParams.append('file', file);
  56615. }
  56616. if (model !== undefined) {
  56617. localVarFormParams.append('model', model);
  56618. }
  56619. if (prompt !== undefined) {
  56620. localVarFormParams.append('prompt', prompt);
  56621. }
  56622. if (responseFormat !== undefined) {
  56623. localVarFormParams.append('response_format', responseFormat);
  56624. }
  56625. if (temperature !== undefined) {
  56626. localVarFormParams.append('temperature', temperature);
  56627. }
  56628. localVarHeaderParameter['Content-Type'] = 'multipart/form-data';
  56629. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56630. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56631. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), localVarFormParams.getHeaders()), headersFromBaseOptions), options.headers);
  56632. localVarRequestOptions.data = localVarFormParams;
  56633. return {
  56634. url: common.toPathString(localVarUrlObj),
  56635. options: localVarRequestOptions,
  56636. };
  56637. }),
  56638. /**
  56639. *
  56640. * @summary Delete a file.
  56641. * @param {string} fileId The ID of the file to use for this request
  56642. * @param {*} [options] Override http request option.
  56643. * @throws {RequiredError}
  56644. */
  56645. deleteFile: (fileId, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56646. // verify required parameter 'fileId' is not null or undefined
  56647. common.assertParamExists('deleteFile', 'fileId', fileId);
  56648. const localVarPath = `/files/{file_id}`
  56649. .replace(`{${"file_id"}}`, encodeURIComponent(String(fileId)));
  56650. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56651. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56652. let baseOptions;
  56653. if (configuration) {
  56654. baseOptions = configuration.baseOptions;
  56655. }
  56656. const localVarRequestOptions = Object.assign(Object.assign({ method: 'DELETE' }, baseOptions), options);
  56657. const localVarHeaderParameter = {};
  56658. const localVarQueryParameter = {};
  56659. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56660. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56661. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56662. return {
  56663. url: common.toPathString(localVarUrlObj),
  56664. options: localVarRequestOptions,
  56665. };
  56666. }),
  56667. /**
  56668. *
  56669. * @summary Delete a fine-tuned model. You must have the Owner role in your organization.
  56670. * @param {string} model The model to delete
  56671. * @param {*} [options] Override http request option.
  56672. * @throws {RequiredError}
  56673. */
  56674. deleteModel: (model, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56675. // verify required parameter 'model' is not null or undefined
  56676. common.assertParamExists('deleteModel', 'model', model);
  56677. const localVarPath = `/models/{model}`
  56678. .replace(`{${"model"}}`, encodeURIComponent(String(model)));
  56679. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56680. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56681. let baseOptions;
  56682. if (configuration) {
  56683. baseOptions = configuration.baseOptions;
  56684. }
  56685. const localVarRequestOptions = Object.assign(Object.assign({ method: 'DELETE' }, baseOptions), options);
  56686. const localVarHeaderParameter = {};
  56687. const localVarQueryParameter = {};
  56688. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56689. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56690. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56691. return {
  56692. url: common.toPathString(localVarUrlObj),
  56693. options: localVarRequestOptions,
  56694. };
  56695. }),
  56696. /**
  56697. *
  56698. * @summary Returns the contents of the specified file
  56699. * @param {string} fileId The ID of the file to use for this request
  56700. * @param {*} [options] Override http request option.
  56701. * @throws {RequiredError}
  56702. */
  56703. downloadFile: (fileId, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56704. // verify required parameter 'fileId' is not null or undefined
  56705. common.assertParamExists('downloadFile', 'fileId', fileId);
  56706. const localVarPath = `/files/{file_id}/content`
  56707. .replace(`{${"file_id"}}`, encodeURIComponent(String(fileId)));
  56708. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56709. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56710. let baseOptions;
  56711. if (configuration) {
  56712. baseOptions = configuration.baseOptions;
  56713. }
  56714. const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
  56715. const localVarHeaderParameter = {};
  56716. const localVarQueryParameter = {};
  56717. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56718. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56719. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56720. return {
  56721. url: common.toPathString(localVarUrlObj),
  56722. options: localVarRequestOptions,
  56723. };
  56724. }),
  56725. /**
  56726. *
  56727. * @summary Lists the currently available (non-finetuned) models, and provides basic information about each one such as the owner and availability.
  56728. * @param {*} [options] Override http request option.
  56729. * @deprecated
  56730. * @throws {RequiredError}
  56731. */
  56732. listEngines: (options = {}) => __awaiter(this, void 0, void 0, function* () {
  56733. const localVarPath = `/engines`;
  56734. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56735. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56736. let baseOptions;
  56737. if (configuration) {
  56738. baseOptions = configuration.baseOptions;
  56739. }
  56740. const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
  56741. const localVarHeaderParameter = {};
  56742. const localVarQueryParameter = {};
  56743. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56744. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56745. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56746. return {
  56747. url: common.toPathString(localVarUrlObj),
  56748. options: localVarRequestOptions,
  56749. };
  56750. }),
  56751. /**
  56752. *
  56753. * @summary Returns a list of files that belong to the user\'s organization.
  56754. * @param {*} [options] Override http request option.
  56755. * @throws {RequiredError}
  56756. */
  56757. listFiles: (options = {}) => __awaiter(this, void 0, void 0, function* () {
  56758. const localVarPath = `/files`;
  56759. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56760. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56761. let baseOptions;
  56762. if (configuration) {
  56763. baseOptions = configuration.baseOptions;
  56764. }
  56765. const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
  56766. const localVarHeaderParameter = {};
  56767. const localVarQueryParameter = {};
  56768. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56769. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56770. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56771. return {
  56772. url: common.toPathString(localVarUrlObj),
  56773. options: localVarRequestOptions,
  56774. };
  56775. }),
  56776. /**
  56777. *
  56778. * @summary Get fine-grained status updates for a fine-tune job.
  56779. * @param {string} fineTuneId The ID of the fine-tune job to get events for.
  56780. * @param {boolean} [stream] Whether to stream events for the fine-tune job. If set to true, events will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available. The stream will terminate with a &#x60;data: [DONE]&#x60; message when the job is finished (succeeded, cancelled, or failed). If set to false, only events generated so far will be returned.
  56781. * @param {*} [options] Override http request option.
  56782. * @throws {RequiredError}
  56783. */
  56784. listFineTuneEvents: (fineTuneId, stream, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56785. // verify required parameter 'fineTuneId' is not null or undefined
  56786. common.assertParamExists('listFineTuneEvents', 'fineTuneId', fineTuneId);
  56787. const localVarPath = `/fine-tunes/{fine_tune_id}/events`
  56788. .replace(`{${"fine_tune_id"}}`, encodeURIComponent(String(fineTuneId)));
  56789. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56790. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56791. let baseOptions;
  56792. if (configuration) {
  56793. baseOptions = configuration.baseOptions;
  56794. }
  56795. const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
  56796. const localVarHeaderParameter = {};
  56797. const localVarQueryParameter = {};
  56798. if (stream !== undefined) {
  56799. localVarQueryParameter['stream'] = stream;
  56800. }
  56801. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56802. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56803. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56804. return {
  56805. url: common.toPathString(localVarUrlObj),
  56806. options: localVarRequestOptions,
  56807. };
  56808. }),
  56809. /**
  56810. *
  56811. * @summary List your organization\'s fine-tuning jobs
  56812. * @param {*} [options] Override http request option.
  56813. * @throws {RequiredError}
  56814. */
  56815. listFineTunes: (options = {}) => __awaiter(this, void 0, void 0, function* () {
  56816. const localVarPath = `/fine-tunes`;
  56817. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56818. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56819. let baseOptions;
  56820. if (configuration) {
  56821. baseOptions = configuration.baseOptions;
  56822. }
  56823. const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
  56824. const localVarHeaderParameter = {};
  56825. const localVarQueryParameter = {};
  56826. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56827. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56828. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56829. return {
  56830. url: common.toPathString(localVarUrlObj),
  56831. options: localVarRequestOptions,
  56832. };
  56833. }),
  56834. /**
  56835. *
  56836. * @summary Lists the currently available models, and provides basic information about each one such as the owner and availability.
  56837. * @param {*} [options] Override http request option.
  56838. * @throws {RequiredError}
  56839. */
  56840. listModels: (options = {}) => __awaiter(this, void 0, void 0, function* () {
  56841. const localVarPath = `/models`;
  56842. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56843. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56844. let baseOptions;
  56845. if (configuration) {
  56846. baseOptions = configuration.baseOptions;
  56847. }
  56848. const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
  56849. const localVarHeaderParameter = {};
  56850. const localVarQueryParameter = {};
  56851. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56852. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56853. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56854. return {
  56855. url: common.toPathString(localVarUrlObj),
  56856. options: localVarRequestOptions,
  56857. };
  56858. }),
  56859. /**
  56860. *
  56861. * @summary Retrieves a model instance, providing basic information about it such as the owner and availability.
  56862. * @param {string} engineId The ID of the engine to use for this request
  56863. * @param {*} [options] Override http request option.
  56864. * @deprecated
  56865. * @throws {RequiredError}
  56866. */
  56867. retrieveEngine: (engineId, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56868. // verify required parameter 'engineId' is not null or undefined
  56869. common.assertParamExists('retrieveEngine', 'engineId', engineId);
  56870. const localVarPath = `/engines/{engine_id}`
  56871. .replace(`{${"engine_id"}}`, encodeURIComponent(String(engineId)));
  56872. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56873. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56874. let baseOptions;
  56875. if (configuration) {
  56876. baseOptions = configuration.baseOptions;
  56877. }
  56878. const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
  56879. const localVarHeaderParameter = {};
  56880. const localVarQueryParameter = {};
  56881. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56882. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56883. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56884. return {
  56885. url: common.toPathString(localVarUrlObj),
  56886. options: localVarRequestOptions,
  56887. };
  56888. }),
  56889. /**
  56890. *
  56891. * @summary Returns information about a specific file.
  56892. * @param {string} fileId The ID of the file to use for this request
  56893. * @param {*} [options] Override http request option.
  56894. * @throws {RequiredError}
  56895. */
  56896. retrieveFile: (fileId, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56897. // verify required parameter 'fileId' is not null or undefined
  56898. common.assertParamExists('retrieveFile', 'fileId', fileId);
  56899. const localVarPath = `/files/{file_id}`
  56900. .replace(`{${"file_id"}}`, encodeURIComponent(String(fileId)));
  56901. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56902. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56903. let baseOptions;
  56904. if (configuration) {
  56905. baseOptions = configuration.baseOptions;
  56906. }
  56907. const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
  56908. const localVarHeaderParameter = {};
  56909. const localVarQueryParameter = {};
  56910. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56911. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56912. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56913. return {
  56914. url: common.toPathString(localVarUrlObj),
  56915. options: localVarRequestOptions,
  56916. };
  56917. }),
  56918. /**
  56919. *
  56920. * @summary Gets info about the fine-tune job. [Learn more about Fine-tuning](/docs/guides/fine-tuning)
  56921. * @param {string} fineTuneId The ID of the fine-tune job
  56922. * @param {*} [options] Override http request option.
  56923. * @throws {RequiredError}
  56924. */
  56925. retrieveFineTune: (fineTuneId, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56926. // verify required parameter 'fineTuneId' is not null or undefined
  56927. common.assertParamExists('retrieveFineTune', 'fineTuneId', fineTuneId);
  56928. const localVarPath = `/fine-tunes/{fine_tune_id}`
  56929. .replace(`{${"fine_tune_id"}}`, encodeURIComponent(String(fineTuneId)));
  56930. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56931. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56932. let baseOptions;
  56933. if (configuration) {
  56934. baseOptions = configuration.baseOptions;
  56935. }
  56936. const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
  56937. const localVarHeaderParameter = {};
  56938. const localVarQueryParameter = {};
  56939. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56940. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56941. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56942. return {
  56943. url: common.toPathString(localVarUrlObj),
  56944. options: localVarRequestOptions,
  56945. };
  56946. }),
  56947. /**
  56948. *
  56949. * @summary Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
  56950. * @param {string} model The ID of the model to use for this request
  56951. * @param {*} [options] Override http request option.
  56952. * @throws {RequiredError}
  56953. */
  56954. retrieveModel: (model, options = {}) => __awaiter(this, void 0, void 0, function* () {
  56955. // verify required parameter 'model' is not null or undefined
  56956. common.assertParamExists('retrieveModel', 'model', model);
  56957. const localVarPath = `/models/{model}`
  56958. .replace(`{${"model"}}`, encodeURIComponent(String(model)));
  56959. // use dummy base URL string because the URL constructor only accepts absolute URLs.
  56960. const localVarUrlObj = new URL(localVarPath, common.DUMMY_BASE_URL);
  56961. let baseOptions;
  56962. if (configuration) {
  56963. baseOptions = configuration.baseOptions;
  56964. }
  56965. const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
  56966. const localVarHeaderParameter = {};
  56967. const localVarQueryParameter = {};
  56968. common.setSearchParams(localVarUrlObj, localVarQueryParameter);
  56969. let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
  56970. localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
  56971. return {
  56972. url: common.toPathString(localVarUrlObj),
  56973. options: localVarRequestOptions,
  56974. };
  56975. }),
  56976. };
  56977. };
  56978. /**
  56979. * OpenAIApi - functional programming interface
  56980. * @export
  56981. */
  56982. exports.OpenAIApiFp = function (configuration) {
  56983. const localVarAxiosParamCreator = exports.OpenAIApiAxiosParamCreator(configuration);
  56984. return {
  56985. /**
  56986. *
  56987. * @summary Immediately cancel a fine-tune job.
  56988. * @param {string} fineTuneId The ID of the fine-tune job to cancel
  56989. * @param {*} [options] Override http request option.
  56990. * @throws {RequiredError}
  56991. */
  56992. cancelFineTune(fineTuneId, options) {
  56993. return __awaiter(this, void 0, void 0, function* () {
  56994. const localVarAxiosArgs = yield localVarAxiosParamCreator.cancelFineTune(fineTuneId, options);
  56995. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  56996. });
  56997. },
  56998. /**
  56999. *
  57000. * @summary Answers the specified question using the provided documents and examples. The endpoint first [searches](/docs/api-reference/searches) over provided documents or files to find relevant context. The relevant context is combined with the provided examples and question to create the prompt for [completion](/docs/api-reference/completions).
  57001. * @param {CreateAnswerRequest} createAnswerRequest
  57002. * @param {*} [options] Override http request option.
  57003. * @deprecated
  57004. * @throws {RequiredError}
  57005. */
  57006. createAnswer(createAnswerRequest, options) {
  57007. return __awaiter(this, void 0, void 0, function* () {
  57008. const localVarAxiosArgs = yield localVarAxiosParamCreator.createAnswer(createAnswerRequest, options);
  57009. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57010. });
  57011. },
  57012. /**
  57013. *
  57014. * @summary Creates a model response for the given chat conversation.
  57015. * @param {CreateChatCompletionRequest} createChatCompletionRequest
  57016. * @param {*} [options] Override http request option.
  57017. * @throws {RequiredError}
  57018. */
  57019. createChatCompletion(createChatCompletionRequest, options) {
  57020. return __awaiter(this, void 0, void 0, function* () {
  57021. const localVarAxiosArgs = yield localVarAxiosParamCreator.createChatCompletion(createChatCompletionRequest, options);
  57022. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57023. });
  57024. },
  57025. /**
  57026. *
  57027. * @summary Classifies the specified `query` using provided examples. The endpoint first [searches](/docs/api-reference/searches) over the labeled examples to select the ones most relevant for the particular query. Then, the relevant examples are combined with the query to construct a prompt to produce the final label via the [completions](/docs/api-reference/completions) endpoint. Labeled examples can be provided via an uploaded `file`, or explicitly listed in the request using the `examples` parameter for quick tests and small scale use cases.
  57028. * @param {CreateClassificationRequest} createClassificationRequest
  57029. * @param {*} [options] Override http request option.
  57030. * @deprecated
  57031. * @throws {RequiredError}
  57032. */
  57033. createClassification(createClassificationRequest, options) {
  57034. return __awaiter(this, void 0, void 0, function* () {
  57035. const localVarAxiosArgs = yield localVarAxiosParamCreator.createClassification(createClassificationRequest, options);
  57036. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57037. });
  57038. },
  57039. /**
  57040. *
  57041. * @summary Creates a completion for the provided prompt and parameters.
  57042. * @param {CreateCompletionRequest} createCompletionRequest
  57043. * @param {*} [options] Override http request option.
  57044. * @throws {RequiredError}
  57045. */
  57046. createCompletion(createCompletionRequest, options) {
  57047. return __awaiter(this, void 0, void 0, function* () {
  57048. const localVarAxiosArgs = yield localVarAxiosParamCreator.createCompletion(createCompletionRequest, options);
  57049. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57050. });
  57051. },
  57052. /**
  57053. *
  57054. * @summary Creates a new edit for the provided input, instruction, and parameters.
  57055. * @param {CreateEditRequest} createEditRequest
  57056. * @param {*} [options] Override http request option.
  57057. * @throws {RequiredError}
  57058. */
  57059. createEdit(createEditRequest, options) {
  57060. return __awaiter(this, void 0, void 0, function* () {
  57061. const localVarAxiosArgs = yield localVarAxiosParamCreator.createEdit(createEditRequest, options);
  57062. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57063. });
  57064. },
  57065. /**
  57066. *
  57067. * @summary Creates an embedding vector representing the input text.
  57068. * @param {CreateEmbeddingRequest} createEmbeddingRequest
  57069. * @param {*} [options] Override http request option.
  57070. * @throws {RequiredError}
  57071. */
  57072. createEmbedding(createEmbeddingRequest, options) {
  57073. return __awaiter(this, void 0, void 0, function* () {
  57074. const localVarAxiosArgs = yield localVarAxiosParamCreator.createEmbedding(createEmbeddingRequest, options);
  57075. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57076. });
  57077. },
  57078. /**
  57079. *
  57080. * @summary Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.
  57081. * @param {File} file Name of the [JSON Lines](https://jsonlines.readthedocs.io/en/latest/) file to be uploaded. If the &#x60;purpose&#x60; is set to \\\&quot;fine-tune\\\&quot;, each line is a JSON record with \\\&quot;prompt\\\&quot; and \\\&quot;completion\\\&quot; fields representing your [training examples](/docs/guides/fine-tuning/prepare-training-data).
  57082. * @param {string} purpose The intended purpose of the uploaded documents. Use \\\&quot;fine-tune\\\&quot; for [Fine-tuning](/docs/api-reference/fine-tunes). This allows us to validate the format of the uploaded file.
  57083. * @param {*} [options] Override http request option.
  57084. * @throws {RequiredError}
  57085. */
  57086. createFile(file, purpose, options) {
  57087. return __awaiter(this, void 0, void 0, function* () {
  57088. const localVarAxiosArgs = yield localVarAxiosParamCreator.createFile(file, purpose, options);
  57089. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57090. });
  57091. },
  57092. /**
  57093. *
  57094. * @summary Creates a job that fine-tunes a specified model from a given dataset. Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. [Learn more about Fine-tuning](/docs/guides/fine-tuning)
  57095. * @param {CreateFineTuneRequest} createFineTuneRequest
  57096. * @param {*} [options] Override http request option.
  57097. * @throws {RequiredError}
  57098. */
  57099. createFineTune(createFineTuneRequest, options) {
  57100. return __awaiter(this, void 0, void 0, function* () {
  57101. const localVarAxiosArgs = yield localVarAxiosParamCreator.createFineTune(createFineTuneRequest, options);
  57102. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57103. });
  57104. },
  57105. /**
  57106. *
  57107. * @summary Creates an image given a prompt.
  57108. * @param {CreateImageRequest} createImageRequest
  57109. * @param {*} [options] Override http request option.
  57110. * @throws {RequiredError}
  57111. */
  57112. createImage(createImageRequest, options) {
  57113. return __awaiter(this, void 0, void 0, function* () {
  57114. const localVarAxiosArgs = yield localVarAxiosParamCreator.createImage(createImageRequest, options);
  57115. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57116. });
  57117. },
  57118. /**
  57119. *
  57120. * @summary Creates an edited or extended image given an original image and a prompt.
  57121. * @param {File} image The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.
  57122. * @param {string} prompt A text description of the desired image(s). The maximum length is 1000 characters.
  57123. * @param {File} [mask] An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where &#x60;image&#x60; should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as &#x60;image&#x60;.
  57124. * @param {number} [n] The number of images to generate. Must be between 1 and 10.
  57125. * @param {string} [size] The size of the generated images. Must be one of &#x60;256x256&#x60;, &#x60;512x512&#x60;, or &#x60;1024x1024&#x60;.
  57126. * @param {string} [responseFormat] The format in which the generated images are returned. Must be one of &#x60;url&#x60; or &#x60;b64_json&#x60;.
  57127. * @param {string} [user] A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
  57128. * @param {*} [options] Override http request option.
  57129. * @throws {RequiredError}
  57130. */
  57131. createImageEdit(image, prompt, mask, n, size, responseFormat, user, options) {
  57132. return __awaiter(this, void 0, void 0, function* () {
  57133. const localVarAxiosArgs = yield localVarAxiosParamCreator.createImageEdit(image, prompt, mask, n, size, responseFormat, user, options);
  57134. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57135. });
  57136. },
  57137. /**
  57138. *
  57139. * @summary Creates a variation of a given image.
  57140. * @param {File} image The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
  57141. * @param {number} [n] The number of images to generate. Must be between 1 and 10.
  57142. * @param {string} [size] The size of the generated images. Must be one of &#x60;256x256&#x60;, &#x60;512x512&#x60;, or &#x60;1024x1024&#x60;.
  57143. * @param {string} [responseFormat] The format in which the generated images are returned. Must be one of &#x60;url&#x60; or &#x60;b64_json&#x60;.
  57144. * @param {string} [user] A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
  57145. * @param {*} [options] Override http request option.
  57146. * @throws {RequiredError}
  57147. */
  57148. createImageVariation(image, n, size, responseFormat, user, options) {
  57149. return __awaiter(this, void 0, void 0, function* () {
  57150. const localVarAxiosArgs = yield localVarAxiosParamCreator.createImageVariation(image, n, size, responseFormat, user, options);
  57151. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57152. });
  57153. },
  57154. /**
  57155. *
  57156. * @summary Classifies if text violates OpenAI\'s Content Policy
  57157. * @param {CreateModerationRequest} createModerationRequest
  57158. * @param {*} [options] Override http request option.
  57159. * @throws {RequiredError}
  57160. */
  57161. createModeration(createModerationRequest, options) {
  57162. return __awaiter(this, void 0, void 0, function* () {
  57163. const localVarAxiosArgs = yield localVarAxiosParamCreator.createModeration(createModerationRequest, options);
  57164. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57165. });
  57166. },
  57167. /**
  57168. *
  57169. * @summary The search endpoint computes similarity scores between provided query and documents. Documents can be passed directly to the API if there are no more than 200 of them. To go beyond the 200 document limit, documents can be processed offline and then used for efficient retrieval at query time. When `file` is set, the search endpoint searches over all the documents in the given file and returns up to the `max_rerank` number of documents. These documents will be returned along with their search scores. The similarity score is a positive score that usually ranges from 0 to 300 (but can sometimes go higher), where a score above 200 usually means the document is semantically similar to the query.
  57170. * @param {string} engineId The ID of the engine to use for this request. You can select one of &#x60;ada&#x60;, &#x60;babbage&#x60;, &#x60;curie&#x60;, or &#x60;davinci&#x60;.
  57171. * @param {CreateSearchRequest} createSearchRequest
  57172. * @param {*} [options] Override http request option.
  57173. * @deprecated
  57174. * @throws {RequiredError}
  57175. */
  57176. createSearch(engineId, createSearchRequest, options) {
  57177. return __awaiter(this, void 0, void 0, function* () {
  57178. const localVarAxiosArgs = yield localVarAxiosParamCreator.createSearch(engineId, createSearchRequest, options);
  57179. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57180. });
  57181. },
  57182. /**
  57183. *
  57184. * @summary Transcribes audio into the input language.
  57185. * @param {File} file The audio file object (not file name) to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.
  57186. * @param {string} model ID of the model to use. Only &#x60;whisper-1&#x60; is currently available.
  57187. * @param {string} [prompt] An optional text to guide the model\\\&#39;s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language.
  57188. * @param {string} [responseFormat] The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt.
  57189. * @param {number} [temperature] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
  57190. * @param {string} [language] The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency.
  57191. * @param {*} [options] Override http request option.
  57192. * @throws {RequiredError}
  57193. */
  57194. createTranscription(file, model, prompt, responseFormat, temperature, language, options) {
  57195. return __awaiter(this, void 0, void 0, function* () {
  57196. const localVarAxiosArgs = yield localVarAxiosParamCreator.createTranscription(file, model, prompt, responseFormat, temperature, language, options);
  57197. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57198. });
  57199. },
  57200. /**
  57201. *
  57202. * @summary Translates audio into into English.
  57203. * @param {File} file The audio file object (not file name) translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.
  57204. * @param {string} model ID of the model to use. Only &#x60;whisper-1&#x60; is currently available.
  57205. * @param {string} [prompt] An optional text to guide the model\\\&#39;s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English.
  57206. * @param {string} [responseFormat] The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt.
  57207. * @param {number} [temperature] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
  57208. * @param {*} [options] Override http request option.
  57209. * @throws {RequiredError}
  57210. */
  57211. createTranslation(file, model, prompt, responseFormat, temperature, options) {
  57212. return __awaiter(this, void 0, void 0, function* () {
  57213. const localVarAxiosArgs = yield localVarAxiosParamCreator.createTranslation(file, model, prompt, responseFormat, temperature, options);
  57214. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57215. });
  57216. },
  57217. /**
  57218. *
  57219. * @summary Delete a file.
  57220. * @param {string} fileId The ID of the file to use for this request
  57221. * @param {*} [options] Override http request option.
  57222. * @throws {RequiredError}
  57223. */
  57224. deleteFile(fileId, options) {
  57225. return __awaiter(this, void 0, void 0, function* () {
  57226. const localVarAxiosArgs = yield localVarAxiosParamCreator.deleteFile(fileId, options);
  57227. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57228. });
  57229. },
  57230. /**
  57231. *
  57232. * @summary Delete a fine-tuned model. You must have the Owner role in your organization.
  57233. * @param {string} model The model to delete
  57234. * @param {*} [options] Override http request option.
  57235. * @throws {RequiredError}
  57236. */
  57237. deleteModel(model, options) {
  57238. return __awaiter(this, void 0, void 0, function* () {
  57239. const localVarAxiosArgs = yield localVarAxiosParamCreator.deleteModel(model, options);
  57240. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57241. });
  57242. },
  57243. /**
  57244. *
  57245. * @summary Returns the contents of the specified file
  57246. * @param {string} fileId The ID of the file to use for this request
  57247. * @param {*} [options] Override http request option.
  57248. * @throws {RequiredError}
  57249. */
  57250. downloadFile(fileId, options) {
  57251. return __awaiter(this, void 0, void 0, function* () {
  57252. const localVarAxiosArgs = yield localVarAxiosParamCreator.downloadFile(fileId, options);
  57253. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57254. });
  57255. },
  57256. /**
  57257. *
  57258. * @summary Lists the currently available (non-finetuned) models, and provides basic information about each one such as the owner and availability.
  57259. * @param {*} [options] Override http request option.
  57260. * @deprecated
  57261. * @throws {RequiredError}
  57262. */
  57263. listEngines(options) {
  57264. return __awaiter(this, void 0, void 0, function* () {
  57265. const localVarAxiosArgs = yield localVarAxiosParamCreator.listEngines(options);
  57266. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57267. });
  57268. },
  57269. /**
  57270. *
  57271. * @summary Returns a list of files that belong to the user\'s organization.
  57272. * @param {*} [options] Override http request option.
  57273. * @throws {RequiredError}
  57274. */
  57275. listFiles(options) {
  57276. return __awaiter(this, void 0, void 0, function* () {
  57277. const localVarAxiosArgs = yield localVarAxiosParamCreator.listFiles(options);
  57278. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57279. });
  57280. },
  57281. /**
  57282. *
  57283. * @summary Get fine-grained status updates for a fine-tune job.
  57284. * @param {string} fineTuneId The ID of the fine-tune job to get events for.
  57285. * @param {boolean} [stream] Whether to stream events for the fine-tune job. If set to true, events will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available. The stream will terminate with a &#x60;data: [DONE]&#x60; message when the job is finished (succeeded, cancelled, or failed). If set to false, only events generated so far will be returned.
  57286. * @param {*} [options] Override http request option.
  57287. * @throws {RequiredError}
  57288. */
  57289. listFineTuneEvents(fineTuneId, stream, options) {
  57290. return __awaiter(this, void 0, void 0, function* () {
  57291. const localVarAxiosArgs = yield localVarAxiosParamCreator.listFineTuneEvents(fineTuneId, stream, options);
  57292. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57293. });
  57294. },
  57295. /**
  57296. *
  57297. * @summary List your organization\'s fine-tuning jobs
  57298. * @param {*} [options] Override http request option.
  57299. * @throws {RequiredError}
  57300. */
  57301. listFineTunes(options) {
  57302. return __awaiter(this, void 0, void 0, function* () {
  57303. const localVarAxiosArgs = yield localVarAxiosParamCreator.listFineTunes(options);
  57304. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57305. });
  57306. },
  57307. /**
  57308. *
  57309. * @summary Lists the currently available models, and provides basic information about each one such as the owner and availability.
  57310. * @param {*} [options] Override http request option.
  57311. * @throws {RequiredError}
  57312. */
  57313. listModels(options) {
  57314. return __awaiter(this, void 0, void 0, function* () {
  57315. const localVarAxiosArgs = yield localVarAxiosParamCreator.listModels(options);
  57316. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57317. });
  57318. },
  57319. /**
  57320. *
  57321. * @summary Retrieves a model instance, providing basic information about it such as the owner and availability.
  57322. * @param {string} engineId The ID of the engine to use for this request
  57323. * @param {*} [options] Override http request option.
  57324. * @deprecated
  57325. * @throws {RequiredError}
  57326. */
  57327. retrieveEngine(engineId, options) {
  57328. return __awaiter(this, void 0, void 0, function* () {
  57329. const localVarAxiosArgs = yield localVarAxiosParamCreator.retrieveEngine(engineId, options);
  57330. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57331. });
  57332. },
  57333. /**
  57334. *
  57335. * @summary Returns information about a specific file.
  57336. * @param {string} fileId The ID of the file to use for this request
  57337. * @param {*} [options] Override http request option.
  57338. * @throws {RequiredError}
  57339. */
  57340. retrieveFile(fileId, options) {
  57341. return __awaiter(this, void 0, void 0, function* () {
  57342. const localVarAxiosArgs = yield localVarAxiosParamCreator.retrieveFile(fileId, options);
  57343. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57344. });
  57345. },
  57346. /**
  57347. *
  57348. * @summary Gets info about the fine-tune job. [Learn more about Fine-tuning](/docs/guides/fine-tuning)
  57349. * @param {string} fineTuneId The ID of the fine-tune job
  57350. * @param {*} [options] Override http request option.
  57351. * @throws {RequiredError}
  57352. */
  57353. retrieveFineTune(fineTuneId, options) {
  57354. return __awaiter(this, void 0, void 0, function* () {
  57355. const localVarAxiosArgs = yield localVarAxiosParamCreator.retrieveFineTune(fineTuneId, options);
  57356. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57357. });
  57358. },
  57359. /**
  57360. *
  57361. * @summary Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
  57362. * @param {string} model The ID of the model to use for this request
  57363. * @param {*} [options] Override http request option.
  57364. * @throws {RequiredError}
  57365. */
  57366. retrieveModel(model, options) {
  57367. return __awaiter(this, void 0, void 0, function* () {
  57368. const localVarAxiosArgs = yield localVarAxiosParamCreator.retrieveModel(model, options);
  57369. return common.createRequestFunction(localVarAxiosArgs, axios$1.default, base$1.BASE_PATH, configuration);
  57370. });
  57371. },
  57372. };
  57373. };
  57374. /**
  57375. * OpenAIApi - factory interface
  57376. * @export
  57377. */
  57378. exports.OpenAIApiFactory = function (configuration, basePath, axios) {
  57379. const localVarFp = exports.OpenAIApiFp(configuration);
  57380. return {
  57381. /**
  57382. *
  57383. * @summary Immediately cancel a fine-tune job.
  57384. * @param {string} fineTuneId The ID of the fine-tune job to cancel
  57385. * @param {*} [options] Override http request option.
  57386. * @throws {RequiredError}
  57387. */
  57388. cancelFineTune(fineTuneId, options) {
  57389. return localVarFp.cancelFineTune(fineTuneId, options).then((request) => request(axios, basePath));
  57390. },
  57391. /**
  57392. *
  57393. * @summary Answers the specified question using the provided documents and examples. The endpoint first [searches](/docs/api-reference/searches) over provided documents or files to find relevant context. The relevant context is combined with the provided examples and question to create the prompt for [completion](/docs/api-reference/completions).
  57394. * @param {CreateAnswerRequest} createAnswerRequest
  57395. * @param {*} [options] Override http request option.
  57396. * @deprecated
  57397. * @throws {RequiredError}
  57398. */
  57399. createAnswer(createAnswerRequest, options) {
  57400. return localVarFp.createAnswer(createAnswerRequest, options).then((request) => request(axios, basePath));
  57401. },
  57402. /**
  57403. *
  57404. * @summary Creates a model response for the given chat conversation.
  57405. * @param {CreateChatCompletionRequest} createChatCompletionRequest
  57406. * @param {*} [options] Override http request option.
  57407. * @throws {RequiredError}
  57408. */
  57409. createChatCompletion(createChatCompletionRequest, options) {
  57410. return localVarFp.createChatCompletion(createChatCompletionRequest, options).then((request) => request(axios, basePath));
  57411. },
  57412. /**
  57413. *
  57414. * @summary Classifies the specified `query` using provided examples. The endpoint first [searches](/docs/api-reference/searches) over the labeled examples to select the ones most relevant for the particular query. Then, the relevant examples are combined with the query to construct a prompt to produce the final label via the [completions](/docs/api-reference/completions) endpoint. Labeled examples can be provided via an uploaded `file`, or explicitly listed in the request using the `examples` parameter for quick tests and small scale use cases.
  57415. * @param {CreateClassificationRequest} createClassificationRequest
  57416. * @param {*} [options] Override http request option.
  57417. * @deprecated
  57418. * @throws {RequiredError}
  57419. */
  57420. createClassification(createClassificationRequest, options) {
  57421. return localVarFp.createClassification(createClassificationRequest, options).then((request) => request(axios, basePath));
  57422. },
  57423. /**
  57424. *
  57425. * @summary Creates a completion for the provided prompt and parameters.
  57426. * @param {CreateCompletionRequest} createCompletionRequest
  57427. * @param {*} [options] Override http request option.
  57428. * @throws {RequiredError}
  57429. */
  57430. createCompletion(createCompletionRequest, options) {
  57431. return localVarFp.createCompletion(createCompletionRequest, options).then((request) => request(axios, basePath));
  57432. },
  57433. /**
  57434. *
  57435. * @summary Creates a new edit for the provided input, instruction, and parameters.
  57436. * @param {CreateEditRequest} createEditRequest
  57437. * @param {*} [options] Override http request option.
  57438. * @throws {RequiredError}
  57439. */
  57440. createEdit(createEditRequest, options) {
  57441. return localVarFp.createEdit(createEditRequest, options).then((request) => request(axios, basePath));
  57442. },
  57443. /**
  57444. *
  57445. * @summary Creates an embedding vector representing the input text.
  57446. * @param {CreateEmbeddingRequest} createEmbeddingRequest
  57447. * @param {*} [options] Override http request option.
  57448. * @throws {RequiredError}
  57449. */
  57450. createEmbedding(createEmbeddingRequest, options) {
  57451. return localVarFp.createEmbedding(createEmbeddingRequest, options).then((request) => request(axios, basePath));
  57452. },
  57453. /**
  57454. *
  57455. * @summary Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.
  57456. * @param {File} file Name of the [JSON Lines](https://jsonlines.readthedocs.io/en/latest/) file to be uploaded. If the &#x60;purpose&#x60; is set to \\\&quot;fine-tune\\\&quot;, each line is a JSON record with \\\&quot;prompt\\\&quot; and \\\&quot;completion\\\&quot; fields representing your [training examples](/docs/guides/fine-tuning/prepare-training-data).
  57457. * @param {string} purpose The intended purpose of the uploaded documents. Use \\\&quot;fine-tune\\\&quot; for [Fine-tuning](/docs/api-reference/fine-tunes). This allows us to validate the format of the uploaded file.
  57458. * @param {*} [options] Override http request option.
  57459. * @throws {RequiredError}
  57460. */
  57461. createFile(file, purpose, options) {
  57462. return localVarFp.createFile(file, purpose, options).then((request) => request(axios, basePath));
  57463. },
  57464. /**
  57465. *
  57466. * @summary Creates a job that fine-tunes a specified model from a given dataset. Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. [Learn more about Fine-tuning](/docs/guides/fine-tuning)
  57467. * @param {CreateFineTuneRequest} createFineTuneRequest
  57468. * @param {*} [options] Override http request option.
  57469. * @throws {RequiredError}
  57470. */
  57471. createFineTune(createFineTuneRequest, options) {
  57472. return localVarFp.createFineTune(createFineTuneRequest, options).then((request) => request(axios, basePath));
  57473. },
  57474. /**
  57475. *
  57476. * @summary Creates an image given a prompt.
  57477. * @param {CreateImageRequest} createImageRequest
  57478. * @param {*} [options] Override http request option.
  57479. * @throws {RequiredError}
  57480. */
  57481. createImage(createImageRequest, options) {
  57482. return localVarFp.createImage(createImageRequest, options).then((request) => request(axios, basePath));
  57483. },
  57484. /**
  57485. *
  57486. * @summary Creates an edited or extended image given an original image and a prompt.
  57487. * @param {File} image The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.
  57488. * @param {string} prompt A text description of the desired image(s). The maximum length is 1000 characters.
  57489. * @param {File} [mask] An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where &#x60;image&#x60; should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as &#x60;image&#x60;.
  57490. * @param {number} [n] The number of images to generate. Must be between 1 and 10.
  57491. * @param {string} [size] The size of the generated images. Must be one of &#x60;256x256&#x60;, &#x60;512x512&#x60;, or &#x60;1024x1024&#x60;.
  57492. * @param {string} [responseFormat] The format in which the generated images are returned. Must be one of &#x60;url&#x60; or &#x60;b64_json&#x60;.
  57493. * @param {string} [user] A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
  57494. * @param {*} [options] Override http request option.
  57495. * @throws {RequiredError}
  57496. */
  57497. createImageEdit(image, prompt, mask, n, size, responseFormat, user, options) {
  57498. return localVarFp.createImageEdit(image, prompt, mask, n, size, responseFormat, user, options).then((request) => request(axios, basePath));
  57499. },
  57500. /**
  57501. *
  57502. * @summary Creates a variation of a given image.
  57503. * @param {File} image The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
  57504. * @param {number} [n] The number of images to generate. Must be between 1 and 10.
  57505. * @param {string} [size] The size of the generated images. Must be one of &#x60;256x256&#x60;, &#x60;512x512&#x60;, or &#x60;1024x1024&#x60;.
  57506. * @param {string} [responseFormat] The format in which the generated images are returned. Must be one of &#x60;url&#x60; or &#x60;b64_json&#x60;.
  57507. * @param {string} [user] A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
  57508. * @param {*} [options] Override http request option.
  57509. * @throws {RequiredError}
  57510. */
  57511. createImageVariation(image, n, size, responseFormat, user, options) {
  57512. return localVarFp.createImageVariation(image, n, size, responseFormat, user, options).then((request) => request(axios, basePath));
  57513. },
  57514. /**
  57515. *
  57516. * @summary Classifies if text violates OpenAI\'s Content Policy
  57517. * @param {CreateModerationRequest} createModerationRequest
  57518. * @param {*} [options] Override http request option.
  57519. * @throws {RequiredError}
  57520. */
  57521. createModeration(createModerationRequest, options) {
  57522. return localVarFp.createModeration(createModerationRequest, options).then((request) => request(axios, basePath));
  57523. },
  57524. /**
  57525. *
  57526. * @summary The search endpoint computes similarity scores between provided query and documents. Documents can be passed directly to the API if there are no more than 200 of them. To go beyond the 200 document limit, documents can be processed offline and then used for efficient retrieval at query time. When `file` is set, the search endpoint searches over all the documents in the given file and returns up to the `max_rerank` number of documents. These documents will be returned along with their search scores. The similarity score is a positive score that usually ranges from 0 to 300 (but can sometimes go higher), where a score above 200 usually means the document is semantically similar to the query.
  57527. * @param {string} engineId The ID of the engine to use for this request. You can select one of &#x60;ada&#x60;, &#x60;babbage&#x60;, &#x60;curie&#x60;, or &#x60;davinci&#x60;.
  57528. * @param {CreateSearchRequest} createSearchRequest
  57529. * @param {*} [options] Override http request option.
  57530. * @deprecated
  57531. * @throws {RequiredError}
  57532. */
  57533. createSearch(engineId, createSearchRequest, options) {
  57534. return localVarFp.createSearch(engineId, createSearchRequest, options).then((request) => request(axios, basePath));
  57535. },
  57536. /**
  57537. *
  57538. * @summary Transcribes audio into the input language.
  57539. * @param {File} file The audio file object (not file name) to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.
  57540. * @param {string} model ID of the model to use. Only &#x60;whisper-1&#x60; is currently available.
  57541. * @param {string} [prompt] An optional text to guide the model\\\&#39;s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language.
  57542. * @param {string} [responseFormat] The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt.
  57543. * @param {number} [temperature] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
  57544. * @param {string} [language] The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency.
  57545. * @param {*} [options] Override http request option.
  57546. * @throws {RequiredError}
  57547. */
  57548. createTranscription(file, model, prompt, responseFormat, temperature, language, options) {
  57549. return localVarFp.createTranscription(file, model, prompt, responseFormat, temperature, language, options).then((request) => request(axios, basePath));
  57550. },
  57551. /**
  57552. *
  57553. * @summary Translates audio into into English.
  57554. * @param {File} file The audio file object (not file name) translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.
  57555. * @param {string} model ID of the model to use. Only &#x60;whisper-1&#x60; is currently available.
  57556. * @param {string} [prompt] An optional text to guide the model\\\&#39;s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English.
  57557. * @param {string} [responseFormat] The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt.
  57558. * @param {number} [temperature] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
  57559. * @param {*} [options] Override http request option.
  57560. * @throws {RequiredError}
  57561. */
  57562. createTranslation(file, model, prompt, responseFormat, temperature, options) {
  57563. return localVarFp.createTranslation(file, model, prompt, responseFormat, temperature, options).then((request) => request(axios, basePath));
  57564. },
  57565. /**
  57566. *
  57567. * @summary Delete a file.
  57568. * @param {string} fileId The ID of the file to use for this request
  57569. * @param {*} [options] Override http request option.
  57570. * @throws {RequiredError}
  57571. */
  57572. deleteFile(fileId, options) {
  57573. return localVarFp.deleteFile(fileId, options).then((request) => request(axios, basePath));
  57574. },
  57575. /**
  57576. *
  57577. * @summary Delete a fine-tuned model. You must have the Owner role in your organization.
  57578. * @param {string} model The model to delete
  57579. * @param {*} [options] Override http request option.
  57580. * @throws {RequiredError}
  57581. */
  57582. deleteModel(model, options) {
  57583. return localVarFp.deleteModel(model, options).then((request) => request(axios, basePath));
  57584. },
  57585. /**
  57586. *
  57587. * @summary Returns the contents of the specified file
  57588. * @param {string} fileId The ID of the file to use for this request
  57589. * @param {*} [options] Override http request option.
  57590. * @throws {RequiredError}
  57591. */
  57592. downloadFile(fileId, options) {
  57593. return localVarFp.downloadFile(fileId, options).then((request) => request(axios, basePath));
  57594. },
  57595. /**
  57596. *
  57597. * @summary Lists the currently available (non-finetuned) models, and provides basic information about each one such as the owner and availability.
  57598. * @param {*} [options] Override http request option.
  57599. * @deprecated
  57600. * @throws {RequiredError}
  57601. */
  57602. listEngines(options) {
  57603. return localVarFp.listEngines(options).then((request) => request(axios, basePath));
  57604. },
  57605. /**
  57606. *
  57607. * @summary Returns a list of files that belong to the user\'s organization.
  57608. * @param {*} [options] Override http request option.
  57609. * @throws {RequiredError}
  57610. */
  57611. listFiles(options) {
  57612. return localVarFp.listFiles(options).then((request) => request(axios, basePath));
  57613. },
  57614. /**
  57615. *
  57616. * @summary Get fine-grained status updates for a fine-tune job.
  57617. * @param {string} fineTuneId The ID of the fine-tune job to get events for.
  57618. * @param {boolean} [stream] Whether to stream events for the fine-tune job. If set to true, events will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available. The stream will terminate with a &#x60;data: [DONE]&#x60; message when the job is finished (succeeded, cancelled, or failed). If set to false, only events generated so far will be returned.
  57619. * @param {*} [options] Override http request option.
  57620. * @throws {RequiredError}
  57621. */
  57622. listFineTuneEvents(fineTuneId, stream, options) {
  57623. return localVarFp.listFineTuneEvents(fineTuneId, stream, options).then((request) => request(axios, basePath));
  57624. },
  57625. /**
  57626. *
  57627. * @summary List your organization\'s fine-tuning jobs
  57628. * @param {*} [options] Override http request option.
  57629. * @throws {RequiredError}
  57630. */
  57631. listFineTunes(options) {
  57632. return localVarFp.listFineTunes(options).then((request) => request(axios, basePath));
  57633. },
  57634. /**
  57635. *
  57636. * @summary Lists the currently available models, and provides basic information about each one such as the owner and availability.
  57637. * @param {*} [options] Override http request option.
  57638. * @throws {RequiredError}
  57639. */
  57640. listModels(options) {
  57641. return localVarFp.listModels(options).then((request) => request(axios, basePath));
  57642. },
  57643. /**
  57644. *
  57645. * @summary Retrieves a model instance, providing basic information about it such as the owner and availability.
  57646. * @param {string} engineId The ID of the engine to use for this request
  57647. * @param {*} [options] Override http request option.
  57648. * @deprecated
  57649. * @throws {RequiredError}
  57650. */
  57651. retrieveEngine(engineId, options) {
  57652. return localVarFp.retrieveEngine(engineId, options).then((request) => request(axios, basePath));
  57653. },
  57654. /**
  57655. *
  57656. * @summary Returns information about a specific file.
  57657. * @param {string} fileId The ID of the file to use for this request
  57658. * @param {*} [options] Override http request option.
  57659. * @throws {RequiredError}
  57660. */
  57661. retrieveFile(fileId, options) {
  57662. return localVarFp.retrieveFile(fileId, options).then((request) => request(axios, basePath));
  57663. },
  57664. /**
  57665. *
  57666. * @summary Gets info about the fine-tune job. [Learn more about Fine-tuning](/docs/guides/fine-tuning)
  57667. * @param {string} fineTuneId The ID of the fine-tune job
  57668. * @param {*} [options] Override http request option.
  57669. * @throws {RequiredError}
  57670. */
  57671. retrieveFineTune(fineTuneId, options) {
  57672. return localVarFp.retrieveFineTune(fineTuneId, options).then((request) => request(axios, basePath));
  57673. },
  57674. /**
  57675. *
  57676. * @summary Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
  57677. * @param {string} model The ID of the model to use for this request
  57678. * @param {*} [options] Override http request option.
  57679. * @throws {RequiredError}
  57680. */
  57681. retrieveModel(model, options) {
  57682. return localVarFp.retrieveModel(model, options).then((request) => request(axios, basePath));
  57683. },
  57684. };
  57685. };
  57686. /**
  57687. * OpenAIApi - object-oriented interface
  57688. * @export
  57689. * @class OpenAIApi
  57690. * @extends {BaseAPI}
  57691. */
  57692. class OpenAIApi extends base$1.BaseAPI {
  57693. /**
  57694. *
  57695. * @summary Immediately cancel a fine-tune job.
  57696. * @param {string} fineTuneId The ID of the fine-tune job to cancel
  57697. * @param {*} [options] Override http request option.
  57698. * @throws {RequiredError}
  57699. * @memberof OpenAIApi
  57700. */
  57701. cancelFineTune(fineTuneId, options) {
  57702. return exports.OpenAIApiFp(this.configuration).cancelFineTune(fineTuneId, options).then((request) => request(this.axios, this.basePath));
  57703. }
  57704. /**
  57705. *
  57706. * @summary Answers the specified question using the provided documents and examples. The endpoint first [searches](/docs/api-reference/searches) over provided documents or files to find relevant context. The relevant context is combined with the provided examples and question to create the prompt for [completion](/docs/api-reference/completions).
  57707. * @param {CreateAnswerRequest} createAnswerRequest
  57708. * @param {*} [options] Override http request option.
  57709. * @deprecated
  57710. * @throws {RequiredError}
  57711. * @memberof OpenAIApi
  57712. */
  57713. createAnswer(createAnswerRequest, options) {
  57714. return exports.OpenAIApiFp(this.configuration).createAnswer(createAnswerRequest, options).then((request) => request(this.axios, this.basePath));
  57715. }
  57716. /**
  57717. *
  57718. * @summary Creates a model response for the given chat conversation.
  57719. * @param {CreateChatCompletionRequest} createChatCompletionRequest
  57720. * @param {*} [options] Override http request option.
  57721. * @throws {RequiredError}
  57722. * @memberof OpenAIApi
  57723. */
  57724. createChatCompletion(createChatCompletionRequest, options) {
  57725. return exports.OpenAIApiFp(this.configuration).createChatCompletion(createChatCompletionRequest, options).then((request) => request(this.axios, this.basePath));
  57726. }
  57727. /**
  57728. *
  57729. * @summary Classifies the specified `query` using provided examples. The endpoint first [searches](/docs/api-reference/searches) over the labeled examples to select the ones most relevant for the particular query. Then, the relevant examples are combined with the query to construct a prompt to produce the final label via the [completions](/docs/api-reference/completions) endpoint. Labeled examples can be provided via an uploaded `file`, or explicitly listed in the request using the `examples` parameter for quick tests and small scale use cases.
  57730. * @param {CreateClassificationRequest} createClassificationRequest
  57731. * @param {*} [options] Override http request option.
  57732. * @deprecated
  57733. * @throws {RequiredError}
  57734. * @memberof OpenAIApi
  57735. */
  57736. createClassification(createClassificationRequest, options) {
  57737. return exports.OpenAIApiFp(this.configuration).createClassification(createClassificationRequest, options).then((request) => request(this.axios, this.basePath));
  57738. }
  57739. /**
  57740. *
  57741. * @summary Creates a completion for the provided prompt and parameters.
  57742. * @param {CreateCompletionRequest} createCompletionRequest
  57743. * @param {*} [options] Override http request option.
  57744. * @throws {RequiredError}
  57745. * @memberof OpenAIApi
  57746. */
  57747. createCompletion(createCompletionRequest, options) {
  57748. return exports.OpenAIApiFp(this.configuration).createCompletion(createCompletionRequest, options).then((request) => request(this.axios, this.basePath));
  57749. }
  57750. /**
  57751. *
  57752. * @summary Creates a new edit for the provided input, instruction, and parameters.
  57753. * @param {CreateEditRequest} createEditRequest
  57754. * @param {*} [options] Override http request option.
  57755. * @throws {RequiredError}
  57756. * @memberof OpenAIApi
  57757. */
  57758. createEdit(createEditRequest, options) {
  57759. return exports.OpenAIApiFp(this.configuration).createEdit(createEditRequest, options).then((request) => request(this.axios, this.basePath));
  57760. }
  57761. /**
  57762. *
  57763. * @summary Creates an embedding vector representing the input text.
  57764. * @param {CreateEmbeddingRequest} createEmbeddingRequest
  57765. * @param {*} [options] Override http request option.
  57766. * @throws {RequiredError}
  57767. * @memberof OpenAIApi
  57768. */
  57769. createEmbedding(createEmbeddingRequest, options) {
  57770. return exports.OpenAIApiFp(this.configuration).createEmbedding(createEmbeddingRequest, options).then((request) => request(this.axios, this.basePath));
  57771. }
  57772. /**
  57773. *
  57774. * @summary Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.
  57775. * @param {File} file Name of the [JSON Lines](https://jsonlines.readthedocs.io/en/latest/) file to be uploaded. If the &#x60;purpose&#x60; is set to \\\&quot;fine-tune\\\&quot;, each line is a JSON record with \\\&quot;prompt\\\&quot; and \\\&quot;completion\\\&quot; fields representing your [training examples](/docs/guides/fine-tuning/prepare-training-data).
  57776. * @param {string} purpose The intended purpose of the uploaded documents. Use \\\&quot;fine-tune\\\&quot; for [Fine-tuning](/docs/api-reference/fine-tunes). This allows us to validate the format of the uploaded file.
  57777. * @param {*} [options] Override http request option.
  57778. * @throws {RequiredError}
  57779. * @memberof OpenAIApi
  57780. */
  57781. createFile(file, purpose, options) {
  57782. return exports.OpenAIApiFp(this.configuration).createFile(file, purpose, options).then((request) => request(this.axios, this.basePath));
  57783. }
  57784. /**
  57785. *
  57786. * @summary Creates a job that fine-tunes a specified model from a given dataset. Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. [Learn more about Fine-tuning](/docs/guides/fine-tuning)
  57787. * @param {CreateFineTuneRequest} createFineTuneRequest
  57788. * @param {*} [options] Override http request option.
  57789. * @throws {RequiredError}
  57790. * @memberof OpenAIApi
  57791. */
  57792. createFineTune(createFineTuneRequest, options) {
  57793. return exports.OpenAIApiFp(this.configuration).createFineTune(createFineTuneRequest, options).then((request) => request(this.axios, this.basePath));
  57794. }
  57795. /**
  57796. *
  57797. * @summary Creates an image given a prompt.
  57798. * @param {CreateImageRequest} createImageRequest
  57799. * @param {*} [options] Override http request option.
  57800. * @throws {RequiredError}
  57801. * @memberof OpenAIApi
  57802. */
  57803. createImage(createImageRequest, options) {
  57804. return exports.OpenAIApiFp(this.configuration).createImage(createImageRequest, options).then((request) => request(this.axios, this.basePath));
  57805. }
  57806. /**
  57807. *
  57808. * @summary Creates an edited or extended image given an original image and a prompt.
  57809. * @param {File} image The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.
  57810. * @param {string} prompt A text description of the desired image(s). The maximum length is 1000 characters.
  57811. * @param {File} [mask] An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where &#x60;image&#x60; should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as &#x60;image&#x60;.
  57812. * @param {number} [n] The number of images to generate. Must be between 1 and 10.
  57813. * @param {string} [size] The size of the generated images. Must be one of &#x60;256x256&#x60;, &#x60;512x512&#x60;, or &#x60;1024x1024&#x60;.
  57814. * @param {string} [responseFormat] The format in which the generated images are returned. Must be one of &#x60;url&#x60; or &#x60;b64_json&#x60;.
  57815. * @param {string} [user] A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
  57816. * @param {*} [options] Override http request option.
  57817. * @throws {RequiredError}
  57818. * @memberof OpenAIApi
  57819. */
  57820. createImageEdit(image, prompt, mask, n, size, responseFormat, user, options) {
  57821. return exports.OpenAIApiFp(this.configuration).createImageEdit(image, prompt, mask, n, size, responseFormat, user, options).then((request) => request(this.axios, this.basePath));
  57822. }
  57823. /**
  57824. *
  57825. * @summary Creates a variation of a given image.
  57826. * @param {File} image The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
  57827. * @param {number} [n] The number of images to generate. Must be between 1 and 10.
  57828. * @param {string} [size] The size of the generated images. Must be one of &#x60;256x256&#x60;, &#x60;512x512&#x60;, or &#x60;1024x1024&#x60;.
  57829. * @param {string} [responseFormat] The format in which the generated images are returned. Must be one of &#x60;url&#x60; or &#x60;b64_json&#x60;.
  57830. * @param {string} [user] A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
  57831. * @param {*} [options] Override http request option.
  57832. * @throws {RequiredError}
  57833. * @memberof OpenAIApi
  57834. */
  57835. createImageVariation(image, n, size, responseFormat, user, options) {
  57836. return exports.OpenAIApiFp(this.configuration).createImageVariation(image, n, size, responseFormat, user, options).then((request) => request(this.axios, this.basePath));
  57837. }
  57838. /**
  57839. *
  57840. * @summary Classifies if text violates OpenAI\'s Content Policy
  57841. * @param {CreateModerationRequest} createModerationRequest
  57842. * @param {*} [options] Override http request option.
  57843. * @throws {RequiredError}
  57844. * @memberof OpenAIApi
  57845. */
  57846. createModeration(createModerationRequest, options) {
  57847. return exports.OpenAIApiFp(this.configuration).createModeration(createModerationRequest, options).then((request) => request(this.axios, this.basePath));
  57848. }
  57849. /**
  57850. *
  57851. * @summary The search endpoint computes similarity scores between provided query and documents. Documents can be passed directly to the API if there are no more than 200 of them. To go beyond the 200 document limit, documents can be processed offline and then used for efficient retrieval at query time. When `file` is set, the search endpoint searches over all the documents in the given file and returns up to the `max_rerank` number of documents. These documents will be returned along with their search scores. The similarity score is a positive score that usually ranges from 0 to 300 (but can sometimes go higher), where a score above 200 usually means the document is semantically similar to the query.
  57852. * @param {string} engineId The ID of the engine to use for this request. You can select one of &#x60;ada&#x60;, &#x60;babbage&#x60;, &#x60;curie&#x60;, or &#x60;davinci&#x60;.
  57853. * @param {CreateSearchRequest} createSearchRequest
  57854. * @param {*} [options] Override http request option.
  57855. * @deprecated
  57856. * @throws {RequiredError}
  57857. * @memberof OpenAIApi
  57858. */
  57859. createSearch(engineId, createSearchRequest, options) {
  57860. return exports.OpenAIApiFp(this.configuration).createSearch(engineId, createSearchRequest, options).then((request) => request(this.axios, this.basePath));
  57861. }
  57862. /**
  57863. *
  57864. * @summary Transcribes audio into the input language.
  57865. * @param {File} file The audio file object (not file name) to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.
  57866. * @param {string} model ID of the model to use. Only &#x60;whisper-1&#x60; is currently available.
  57867. * @param {string} [prompt] An optional text to guide the model\\\&#39;s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language.
  57868. * @param {string} [responseFormat] The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt.
  57869. * @param {number} [temperature] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
  57870. * @param {string} [language] The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency.
  57871. * @param {*} [options] Override http request option.
  57872. * @throws {RequiredError}
  57873. * @memberof OpenAIApi
  57874. */
  57875. createTranscription(file, model, prompt, responseFormat, temperature, language, options) {
  57876. return exports.OpenAIApiFp(this.configuration).createTranscription(file, model, prompt, responseFormat, temperature, language, options).then((request) => request(this.axios, this.basePath));
  57877. }
  57878. /**
  57879. *
  57880. * @summary Translates audio into into English.
  57881. * @param {File} file The audio file object (not file name) translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.
  57882. * @param {string} model ID of the model to use. Only &#x60;whisper-1&#x60; is currently available.
  57883. * @param {string} [prompt] An optional text to guide the model\\\&#39;s style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English.
  57884. * @param {string} [responseFormat] The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt.
  57885. * @param {number} [temperature] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
  57886. * @param {*} [options] Override http request option.
  57887. * @throws {RequiredError}
  57888. * @memberof OpenAIApi
  57889. */
  57890. createTranslation(file, model, prompt, responseFormat, temperature, options) {
  57891. return exports.OpenAIApiFp(this.configuration).createTranslation(file, model, prompt, responseFormat, temperature, options).then((request) => request(this.axios, this.basePath));
  57892. }
  57893. /**
  57894. *
  57895. * @summary Delete a file.
  57896. * @param {string} fileId The ID of the file to use for this request
  57897. * @param {*} [options] Override http request option.
  57898. * @throws {RequiredError}
  57899. * @memberof OpenAIApi
  57900. */
  57901. deleteFile(fileId, options) {
  57902. return exports.OpenAIApiFp(this.configuration).deleteFile(fileId, options).then((request) => request(this.axios, this.basePath));
  57903. }
  57904. /**
  57905. *
  57906. * @summary Delete a fine-tuned model. You must have the Owner role in your organization.
  57907. * @param {string} model The model to delete
  57908. * @param {*} [options] Override http request option.
  57909. * @throws {RequiredError}
  57910. * @memberof OpenAIApi
  57911. */
  57912. deleteModel(model, options) {
  57913. return exports.OpenAIApiFp(this.configuration).deleteModel(model, options).then((request) => request(this.axios, this.basePath));
  57914. }
  57915. /**
  57916. *
  57917. * @summary Returns the contents of the specified file
  57918. * @param {string} fileId The ID of the file to use for this request
  57919. * @param {*} [options] Override http request option.
  57920. * @throws {RequiredError}
  57921. * @memberof OpenAIApi
  57922. */
  57923. downloadFile(fileId, options) {
  57924. return exports.OpenAIApiFp(this.configuration).downloadFile(fileId, options).then((request) => request(this.axios, this.basePath));
  57925. }
  57926. /**
  57927. *
  57928. * @summary Lists the currently available (non-finetuned) models, and provides basic information about each one such as the owner and availability.
  57929. * @param {*} [options] Override http request option.
  57930. * @deprecated
  57931. * @throws {RequiredError}
  57932. * @memberof OpenAIApi
  57933. */
  57934. listEngines(options) {
  57935. return exports.OpenAIApiFp(this.configuration).listEngines(options).then((request) => request(this.axios, this.basePath));
  57936. }
  57937. /**
  57938. *
  57939. * @summary Returns a list of files that belong to the user\'s organization.
  57940. * @param {*} [options] Override http request option.
  57941. * @throws {RequiredError}
  57942. * @memberof OpenAIApi
  57943. */
  57944. listFiles(options) {
  57945. return exports.OpenAIApiFp(this.configuration).listFiles(options).then((request) => request(this.axios, this.basePath));
  57946. }
  57947. /**
  57948. *
  57949. * @summary Get fine-grained status updates for a fine-tune job.
  57950. * @param {string} fineTuneId The ID of the fine-tune job to get events for.
  57951. * @param {boolean} [stream] Whether to stream events for the fine-tune job. If set to true, events will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available. The stream will terminate with a &#x60;data: [DONE]&#x60; message when the job is finished (succeeded, cancelled, or failed). If set to false, only events generated so far will be returned.
  57952. * @param {*} [options] Override http request option.
  57953. * @throws {RequiredError}
  57954. * @memberof OpenAIApi
  57955. */
  57956. listFineTuneEvents(fineTuneId, stream, options) {
  57957. return exports.OpenAIApiFp(this.configuration).listFineTuneEvents(fineTuneId, stream, options).then((request) => request(this.axios, this.basePath));
  57958. }
  57959. /**
  57960. *
  57961. * @summary List your organization\'s fine-tuning jobs
  57962. * @param {*} [options] Override http request option.
  57963. * @throws {RequiredError}
  57964. * @memberof OpenAIApi
  57965. */
  57966. listFineTunes(options) {
  57967. return exports.OpenAIApiFp(this.configuration).listFineTunes(options).then((request) => request(this.axios, this.basePath));
  57968. }
  57969. /**
  57970. *
  57971. * @summary Lists the currently available models, and provides basic information about each one such as the owner and availability.
  57972. * @param {*} [options] Override http request option.
  57973. * @throws {RequiredError}
  57974. * @memberof OpenAIApi
  57975. */
  57976. listModels(options) {
  57977. return exports.OpenAIApiFp(this.configuration).listModels(options).then((request) => request(this.axios, this.basePath));
  57978. }
  57979. /**
  57980. *
  57981. * @summary Retrieves a model instance, providing basic information about it such as the owner and availability.
  57982. * @param {string} engineId The ID of the engine to use for this request
  57983. * @param {*} [options] Override http request option.
  57984. * @deprecated
  57985. * @throws {RequiredError}
  57986. * @memberof OpenAIApi
  57987. */
  57988. retrieveEngine(engineId, options) {
  57989. return exports.OpenAIApiFp(this.configuration).retrieveEngine(engineId, options).then((request) => request(this.axios, this.basePath));
  57990. }
  57991. /**
  57992. *
  57993. * @summary Returns information about a specific file.
  57994. * @param {string} fileId The ID of the file to use for this request
  57995. * @param {*} [options] Override http request option.
  57996. * @throws {RequiredError}
  57997. * @memberof OpenAIApi
  57998. */
  57999. retrieveFile(fileId, options) {
  58000. return exports.OpenAIApiFp(this.configuration).retrieveFile(fileId, options).then((request) => request(this.axios, this.basePath));
  58001. }
  58002. /**
  58003. *
  58004. * @summary Gets info about the fine-tune job. [Learn more about Fine-tuning](/docs/guides/fine-tuning)
  58005. * @param {string} fineTuneId The ID of the fine-tune job
  58006. * @param {*} [options] Override http request option.
  58007. * @throws {RequiredError}
  58008. * @memberof OpenAIApi
  58009. */
  58010. retrieveFineTune(fineTuneId, options) {
  58011. return exports.OpenAIApiFp(this.configuration).retrieveFineTune(fineTuneId, options).then((request) => request(this.axios, this.basePath));
  58012. }
  58013. /**
  58014. *
  58015. * @summary Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
  58016. * @param {string} model The ID of the model to use for this request
  58017. * @param {*} [options] Override http request option.
  58018. * @throws {RequiredError}
  58019. * @memberof OpenAIApi
  58020. */
  58021. retrieveModel(model, options) {
  58022. return exports.OpenAIApiFp(this.configuration).retrieveModel(model, options).then((request) => request(this.axios, this.basePath));
  58023. }
  58024. }
  58025. exports.OpenAIApi = OpenAIApi;
  58026. });
  58027. unwrapExports(api);
  58028. var api_1 = api.OpenAIApi;
  58029. var api_2 = api.OpenAIApiFactory;
  58030. var api_3 = api.OpenAIApiFp;
  58031. var api_4 = api.OpenAIApiAxiosParamCreator;
  58032. var api_5 = api.CreateImageRequestResponseFormatEnum;
  58033. var api_6 = api.CreateImageRequestSizeEnum;
  58034. var api_7 = api.ChatCompletionResponseMessageRoleEnum;
  58035. var api_8 = api.ChatCompletionRequestMessageRoleEnum;
  58036. var name = "openai";
  58037. var version$2 = "3.3.0";
  58038. var description = "Node.js library for the OpenAI API";
  58039. var repository = {
  58040. type: "git",
  58041. url: "[email protected]:openai/openai-node.git"
  58042. };
  58043. var keywords = [
  58044. "openai",
  58045. "open",
  58046. "ai",
  58047. "gpt-3",
  58048. "gpt3"
  58049. ];
  58050. var author = "OpenAI";
  58051. var license = "MIT";
  58052. var main = "./dist/index.js";
  58053. var types = "./dist/index.d.ts";
  58054. var scripts = {
  58055. build: "tsc --outDir dist/"
  58056. };
  58057. var dependencies = {
  58058. axios: "^0.26.0",
  58059. "form-data": "^4.0.0"
  58060. };
  58061. var devDependencies = {
  58062. "@types/node": "^12.11.5",
  58063. typescript: "^3.6.4"
  58064. };
  58065. var _package = {
  58066. name: name,
  58067. version: version$2,
  58068. description: description,
  58069. repository: repository,
  58070. keywords: keywords,
  58071. author: author,
  58072. license: license,
  58073. main: main,
  58074. types: types,
  58075. scripts: scripts,
  58076. dependencies: dependencies,
  58077. devDependencies: devDependencies
  58078. };
  58079. var _package$1 = /*#__PURE__*/Object.freeze({
  58080. __proto__: null,
  58081. name: name,
  58082. version: version$2,
  58083. description: description,
  58084. repository: repository,
  58085. keywords: keywords,
  58086. author: author,
  58087. license: license,
  58088. main: main,
  58089. types: types,
  58090. scripts: scripts,
  58091. dependencies: dependencies,
  58092. devDependencies: devDependencies,
  58093. 'default': _package
  58094. });
  58095. /* eslint-env browser */
  58096. var browser = typeof self == 'object' ? self.FormData : window.FormData;
  58097. var packageJson = getCjsExportFromNamespace(_package$1);
  58098. var configuration = createCommonjsModule(function (module, exports) {
  58099. /* tslint:disable */
  58100. /* eslint-disable */
  58101. /**
  58102. * OpenAI API
  58103. * APIs for sampling from and fine-tuning language models
  58104. *
  58105. * The version of the OpenAPI document: 1.3.0
  58106. *
  58107. *
  58108. * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
  58109. * https://openapi-generator.tech
  58110. * Do not edit the class manually.
  58111. */
  58112. Object.defineProperty(exports, "__esModule", { value: true });
  58113. exports.Configuration = void 0;
  58114. class Configuration {
  58115. constructor(param = {}) {
  58116. this.apiKey = param.apiKey;
  58117. this.organization = param.organization;
  58118. this.username = param.username;
  58119. this.password = param.password;
  58120. this.accessToken = param.accessToken;
  58121. this.basePath = param.basePath;
  58122. this.baseOptions = param.baseOptions;
  58123. this.formDataCtor = param.formDataCtor;
  58124. if (!this.baseOptions) {
  58125. this.baseOptions = {};
  58126. }
  58127. this.baseOptions.headers = Object.assign({ 'User-Agent': `OpenAI/NodeJS/${packageJson.version}`, 'Authorization': `Bearer ${this.apiKey}` }, this.baseOptions.headers);
  58128. if (this.organization) {
  58129. this.baseOptions.headers['OpenAI-Organization'] = this.organization;
  58130. }
  58131. if (!this.formDataCtor) {
  58132. this.formDataCtor = browser;
  58133. }
  58134. }
  58135. /**
  58136. * Check if the given MIME is a JSON MIME.
  58137. * JSON MIME examples:
  58138. * application/json
  58139. * application/json; charset=UTF8
  58140. * APPLICATION/JSON
  58141. * application/vnd.company+json
  58142. * @param mime - MIME (Multipurpose Internet Mail Extensions)
  58143. * @return True if the given MIME is JSON, false otherwise.
  58144. */
  58145. isJsonMime(mime) {
  58146. const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
  58147. return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
  58148. }
  58149. }
  58150. exports.Configuration = Configuration;
  58151. });
  58152. unwrapExports(configuration);
  58153. var configuration_1 = configuration.Configuration;
  58154. var dist = createCommonjsModule(function (module, exports) {
  58155. /* tslint:disable */
  58156. /* eslint-disable */
  58157. /**
  58158. * OpenAI API
  58159. * APIs for sampling from and fine-tuning language models
  58160. *
  58161. * The version of the OpenAPI document: 1.3.0
  58162. *
  58163. *
  58164. * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
  58165. * https://openapi-generator.tech
  58166. * Do not edit the class manually.
  58167. */
  58168. var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  58169. if (k2 === undefined) k2 = k;
  58170. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  58171. }) : (function(o, m, k, k2) {
  58172. if (k2 === undefined) k2 = k;
  58173. o[k2] = m[k];
  58174. }));
  58175. var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
  58176. for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
  58177. };
  58178. Object.defineProperty(exports, "__esModule", { value: true });
  58179. __exportStar(api, exports);
  58180. __exportStar(configuration, exports);
  58181. });
  58182. var openAI = unwrapExports(dist);
  58183. var _generatePromptMap, _queryMap;
  58184. function _createSuper$1h(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1h(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  58185. function _isNativeReflectConstruct$1h() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  58186. var FUNC_MAP = {
  58187. COMPLEMENT: 'complement',
  58188. SUMMARY: 'summary'
  58189. };
  58190. /**
  58191. * 插入“画图”的按钮
  58192. * 本功能依赖[Mermaid.js](https://mermaid-js.github.io)组件,请保证调用CherryMarkdown前已加载mermaid.js组件
  58193. */
  58194. var ChatGpt = /*#__PURE__*/function (_MenuBase) {
  58195. _inherits(ChatGpt, _MenuBase);
  58196. var _super = _createSuper$1h(ChatGpt);
  58197. function ChatGpt($cherry) {
  58198. var _context, _context2;
  58199. var _this;
  58200. _classCallCheck(this, ChatGpt);
  58201. _this = _super.call(this, $cherry);
  58202. _this.setName('chatgpt', 'chatgpt');
  58203. _this.noIcon = true;
  58204. _this.subMenuConfig = [// 续写
  58205. {
  58206. iconName: _this.locale.complement,
  58207. name: FUNC_MAP.COMPLEMENT,
  58208. onclick: bind$5(_context = _this.bindSubClick).call(_context, _assertThisInitialized(_this), FUNC_MAP.COMPLEMENT)
  58209. }, // 总结
  58210. {
  58211. iconName: _this.locale.summary,
  58212. name: FUNC_MAP.SUMMARY,
  58213. onclick: bind$5(_context2 = _this.bindSubClick).call(_context2, _assertThisInitialized(_this), FUNC_MAP.SUMMARY)
  58214. }];
  58215. var _ref = _this.$cherry.options.openai || {},
  58216. _ref$apiKey = _ref.apiKey,
  58217. apiKey = _ref$apiKey === void 0 ? '' : _ref$apiKey,
  58218. _ref$proxy = _ref.proxy;
  58219. _ref$proxy = _ref$proxy === void 0 ? {} : _ref$proxy;
  58220. var _ref$proxy$host = _ref$proxy.host,
  58221. host = _ref$proxy$host === void 0 ? '' : _ref$proxy$host,
  58222. _ref$proxy$port = _ref$proxy.port,
  58223. port = _ref$proxy$port === void 0 ? '' : _ref$proxy$port,
  58224. ignoreError = _ref.ignoreError; // 设置apiKey
  58225. if (apiKey) {
  58226. var openai = new openAI.OpenAIApi(new openAI.Configuration({
  58227. apiKey: apiKey
  58228. }));
  58229. _this.openai = openai;
  58230. } // 设置http proxy
  58231. if (host && port) {
  58232. _this.proxy = {
  58233. host: host,
  58234. port: port
  58235. };
  58236. }
  58237. _this.ignoreError = ignoreError;
  58238. return _this;
  58239. }
  58240. _createClass(ChatGpt, [{
  58241. key: "getSubMenuConfig",
  58242. value: function getSubMenuConfig() {
  58243. return this.subMenuConfig;
  58244. }
  58245. /**
  58246. * 响应点击事件
  58247. * @param {string} selection 被用户选中的文本内容,本函数不处理选中的内容,会直接清空用户选中的内容
  58248. * @param {string} shortKey 快捷键参数
  58249. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  58250. */
  58251. }, {
  58252. key: "onClick",
  58253. value: function onClick(selection) {
  58254. var shortKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  58255. if (!shortKey) {
  58256. return;
  58257. }
  58258. switch (shortKey) {
  58259. case FUNC_MAP.COMPLEMENT:
  58260. if (!this.openai) {
  58261. // 触发一个事件表示没有apiKey?
  58262. return;
  58263. }
  58264. this.queryOpenAIApi(FUNC_MAP.COMPLEMENT, selection);
  58265. break;
  58266. case FUNC_MAP.SUMMARY:
  58267. this.queryOpenAIApi(FUNC_MAP.SUMMARY, selection);
  58268. break;
  58269. default:
  58270. return;
  58271. }
  58272. }
  58273. /**
  58274. * 在编辑器中添加文字
  58275. */
  58276. }, {
  58277. key: "concatText",
  58278. value: function concatText(selection, text) {
  58279. var _this$editor, _this$editor$editor, _context3, _this$editor2, _this$editor2$editor;
  58280. this.button.className = this.button.className.replace('icon-loading loading', '');
  58281. this.button.innerText = this.button.title;
  58282. (_this$editor = this.editor) === null || _this$editor === void 0 ? void 0 : (_this$editor$editor = _this$editor.editor) === null || _this$editor$editor === void 0 ? void 0 : _this$editor$editor.replaceSelection(concat$5(_context3 = "".concat(selection || '', " \n")).call(_context3, text));
  58283. (_this$editor2 = this.editor) === null || _this$editor2 === void 0 ? void 0 : (_this$editor2$editor = _this$editor2.editor) === null || _this$editor2$editor === void 0 ? void 0 : _this$editor2$editor.focus();
  58284. }
  58285. /**
  58286. * 请求openai api,成功回调&失败回调
  58287. * @param {string} name
  58288. * @param {string} selection
  58289. */
  58290. }, {
  58291. key: "queryOpenAIApi",
  58292. value: function queryOpenAIApi(name, selection) {
  58293. var _this2 = this;
  58294. if (!this.openai) {
  58295. return;
  58296. } // 增加loading
  58297. // eslint-disable-next-line prefer-destructuring
  58298. this.button = this.$cherry.wrapperDom.getElementsByClassName('cherry-toolbar-chatgpt')[0];
  58299. if (/icon-loading loading/.test(this.button.className)) {
  58300. return;
  58301. }
  58302. this.button.className += ' icon-loading loading';
  58303. this.button.innerText = ''; // const that = this;
  58304. var inputText = selection || this.$cherry.editor.editor.getValue();
  58305. queryMap[name].apply(this, [inputText]).then(function (res) {
  58306. var _res$data, _res$data$choices, _res$data$choices$, _res$data$choices$$me;
  58307. return _this2.concatText(selection, ((_res$data = res.data) === null || _res$data === void 0 ? void 0 : (_res$data$choices = _res$data.choices) === null || _res$data$choices === void 0 ? void 0 : (_res$data$choices$ = _res$data$choices[0]) === null || _res$data$choices$ === void 0 ? void 0 : (_res$data$choices$$me = _res$data$choices$.message) === null || _res$data$choices$$me === void 0 ? void 0 : _res$data$choices$$me.content) || '');
  58308. })["catch"](function (res) {
  58309. var _res$response, _res$response$data, _res$response$data$er;
  58310. // 请求失败处理,两种方案
  58311. // 1. 抛出一个事件给第三方使用者,在cherry里怎么实现?
  58312. // 2. cherry处理并在编辑器中提示用户,目前采取这种方式
  58313. var errMsg = (res === null || res === void 0 ? void 0 : (_res$response = res.response) === null || _res$response === void 0 ? void 0 : (_res$response$data = _res$response.data) === null || _res$response$data === void 0 ? void 0 : (_res$response$data$er = _res$response$data.error) === null || _res$response$data$er === void 0 ? void 0 : _res$response$data$er.message) || '';
  58314. if (errMsg && _this2.ignoreError === false) {
  58315. _this2.concatText(selection, errMsg);
  58316. }
  58317. });
  58318. }
  58319. }]);
  58320. return ChatGpt;
  58321. }(MenuBase);
  58322. var generatePromptMap = (_generatePromptMap = {}, _defineProperty(_generatePromptMap, FUNC_MAP.COMPLEMENT, function (text, language) {
  58323. if (language === 'zh_CN') {
  58324. return "\u8BF7\u7EED\u5199\u4EE5\u4E0B\u6587\u5B57: ".concat(text);
  58325. }
  58326. return "continue writing with the following text: ".concat(text);
  58327. }), _defineProperty(_generatePromptMap, FUNC_MAP.SUMMARY, function (text, language) {
  58328. if (language === 'zh_CN') {
  58329. return "\u8BF7\u603B\u7ED3\u4EE5\u4E0B\u6587\u5B57: ".concat(text);
  58330. }
  58331. return "summary the following text: ".concat(text);
  58332. }), _generatePromptMap);
  58333. function queryCompletion(type, input) {
  58334. return this.openai.createChatCompletion({
  58335. model: 'gpt-3.5-turbo',
  58336. messages: [{
  58337. role: 'user',
  58338. content: generatePromptMap[type](input, this.$cherry.options.locale || '')
  58339. }] // temperature: 0.6,
  58340. // max_tokens: 500,
  58341. }, {
  58342. proxy: this.proxy
  58343. });
  58344. }
  58345. var queryMap = (_queryMap = {}, _defineProperty(_queryMap, FUNC_MAP.COMPLEMENT, function (input) {
  58346. return queryCompletion.apply(this, [FUNC_MAP.COMPLEMENT, input]);
  58347. }), _defineProperty(_queryMap, FUNC_MAP.SUMMARY, function (input) {
  58348. return queryCompletion.apply(this, [FUNC_MAP.SUMMARY, input]);
  58349. }), _queryMap);
  58350. function _createSuper$1i(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1i(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  58351. function _isNativeReflectConstruct$1i() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  58352. /**
  58353. * 预览区域切换到“移动端视图”的按钮
  58354. */
  58355. var MobilePreview = /*#__PURE__*/function (_MenuBase) {
  58356. _inherits(MobilePreview, _MenuBase);
  58357. var _super = _createSuper$1i(MobilePreview);
  58358. function MobilePreview($cherry) {
  58359. var _this;
  58360. _classCallCheck(this, MobilePreview);
  58361. _this = _super.call(this, $cherry);
  58362. _this.previewer = $cherry.previewer;
  58363. _this.updateMarkdown = false;
  58364. _this.setName('mobilePreview', 'phone');
  58365. return _this;
  58366. }
  58367. /**
  58368. * 响应点击事件
  58369. * 因为是预览区域的按钮,所以不用关注编辑区的选中内容
  58370. */
  58371. _createClass(MobilePreview, [{
  58372. key: "onClick",
  58373. value: function onClick() {
  58374. this.previewer.removeScroll(); // TODO:是否可以只通过修改外层class的方式来实现移动端预览效果的展示,而不是增加删除dom结构的方式
  58375. var previewerDom = this.previewer.getDomContainer();
  58376. if (this.previewer.isMobilePreview) {
  58377. previewerDom.parentNode.innerHTML = previewerDom.innerHTML;
  58378. } else {
  58379. previewerDom.innerHTML = "<div class='cherry-mobile-previewer-content'>".concat(previewerDom.innerHTML, "</div>");
  58380. }
  58381. this.previewer.isMobilePreview = !this.previewer.isMobilePreview;
  58382. this.previewer.bindScroll();
  58383. }
  58384. }]);
  58385. return MobilePreview;
  58386. }(MenuBase);
  58387. var copyConstructorProperties = function (target, source, exceptions) {
  58388. var keys = ownKeys(source);
  58389. var defineProperty = objectDefineProperty.f;
  58390. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  58391. for (var i = 0; i < keys.length; i++) {
  58392. var key = keys[i];
  58393. if (!hasOwnProperty_1(target, key) && !(exceptions && hasOwnProperty_1(exceptions, key))) {
  58394. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  58395. }
  58396. }
  58397. };
  58398. var $Error = Error;
  58399. var replace$5 = functionUncurryThis(''.replace);
  58400. var TEST = (function (arg) { return String($Error(arg).stack); })('zxcasd');
  58401. var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/;
  58402. var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST);
  58403. var clearErrorStack = function (stack, dropEntries) {
  58404. if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) {
  58405. while (dropEntries--) stack = replace$5(stack, V8_OR_CHAKRA_STACK_ENTRY, '');
  58406. } return stack;
  58407. };
  58408. // `InstallErrorCause` abstract operation
  58409. // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause
  58410. var installErrorCause = function (O, options) {
  58411. if (isObject(options) && 'cause' in options) {
  58412. createNonEnumerableProperty(O, 'cause', options.cause);
  58413. }
  58414. };
  58415. var normalizeStringArgument = function (argument, $default) {
  58416. return argument === undefined ? arguments.length < 2 ? '' : $default : toString_1(argument);
  58417. };
  58418. var errorStackInstallable = !fails(function () {
  58419. var error = Error('a');
  58420. if (!('stack' in error)) return true;
  58421. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  58422. Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7));
  58423. return error.stack !== 7;
  58424. });
  58425. var TO_STRING_TAG$4 = wellKnownSymbol('toStringTag');
  58426. var Error$1 = global_1.Error;
  58427. var push$a = [].push;
  58428. var $AggregateError = function AggregateError(errors, message /* , options */) {
  58429. var options = arguments.length > 2 ? arguments[2] : undefined;
  58430. var isInstance = objectIsPrototypeOf(AggregateErrorPrototype, this);
  58431. var that;
  58432. if (objectSetPrototypeOf) {
  58433. that = objectSetPrototypeOf(new Error$1(), isInstance ? objectGetPrototypeOf(this) : AggregateErrorPrototype);
  58434. } else {
  58435. that = isInstance ? this : objectCreate(AggregateErrorPrototype);
  58436. createNonEnumerableProperty(that, TO_STRING_TAG$4, 'Error');
  58437. }
  58438. if (message !== undefined) createNonEnumerableProperty(that, 'message', normalizeStringArgument(message));
  58439. if (errorStackInstallable) createNonEnumerableProperty(that, 'stack', clearErrorStack(that.stack, 1));
  58440. installErrorCause(that, options);
  58441. var errorsArray = [];
  58442. iterate(errors, push$a, { that: errorsArray });
  58443. createNonEnumerableProperty(that, 'errors', errorsArray);
  58444. return that;
  58445. };
  58446. if (objectSetPrototypeOf) objectSetPrototypeOf($AggregateError, Error$1);
  58447. else copyConstructorProperties($AggregateError, Error$1, { name: true });
  58448. var AggregateErrorPrototype = $AggregateError.prototype = objectCreate(Error$1.prototype, {
  58449. constructor: createPropertyDescriptor(1, $AggregateError),
  58450. message: createPropertyDescriptor(1, ''),
  58451. name: createPropertyDescriptor(1, 'AggregateError')
  58452. });
  58453. // `AggregateError` constructor
  58454. // https://tc39.es/ecma262/#sec-aggregate-error-constructor
  58455. _export({ global: true, constructor: true, arity: 2 }, {
  58456. AggregateError: $AggregateError
  58457. });
  58458. var engineIsIos = /(?:ipad|iphone|ipod).*applewebkit/i.test(engineUserAgent);
  58459. var set$1 = global_1.setImmediate;
  58460. var clear = global_1.clearImmediate;
  58461. var process$2 = global_1.process;
  58462. var Dispatch = global_1.Dispatch;
  58463. var Function$3 = global_1.Function;
  58464. var MessageChannel = global_1.MessageChannel;
  58465. var String$5 = global_1.String;
  58466. var counter = 0;
  58467. var queue = {};
  58468. var ONREADYSTATECHANGE = 'onreadystatechange';
  58469. var location$1, defer, channel, port;
  58470. try {
  58471. // Deno throws a ReferenceError on `location` access without `--location` flag
  58472. location$1 = global_1.location;
  58473. } catch (error) { /* empty */ }
  58474. var run = function (id) {
  58475. if (hasOwnProperty_1(queue, id)) {
  58476. var fn = queue[id];
  58477. delete queue[id];
  58478. fn();
  58479. }
  58480. };
  58481. var runner = function (id) {
  58482. return function () {
  58483. run(id);
  58484. };
  58485. };
  58486. var listener = function (event) {
  58487. run(event.data);
  58488. };
  58489. var post = function (id) {
  58490. // old engines have not location.origin
  58491. global_1.postMessage(String$5(id), location$1.protocol + '//' + location$1.host);
  58492. };
  58493. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  58494. if (!set$1 || !clear) {
  58495. set$1 = function setImmediate(handler) {
  58496. validateArgumentsLength(arguments.length, 1);
  58497. var fn = isCallable(handler) ? handler : Function$3(handler);
  58498. var args = arraySlice(arguments, 1);
  58499. queue[++counter] = function () {
  58500. functionApply(fn, undefined, args);
  58501. };
  58502. defer(counter);
  58503. return counter;
  58504. };
  58505. clear = function clearImmediate(id) {
  58506. delete queue[id];
  58507. };
  58508. // Node.js 0.8-
  58509. if (engineIsNode) {
  58510. defer = function (id) {
  58511. process$2.nextTick(runner(id));
  58512. };
  58513. // Sphere (JS game engine) Dispatch API
  58514. } else if (Dispatch && Dispatch.now) {
  58515. defer = function (id) {
  58516. Dispatch.now(runner(id));
  58517. };
  58518. // Browsers with MessageChannel, includes WebWorkers
  58519. // except iOS - https://github.com/zloirock/core-js/issues/624
  58520. } else if (MessageChannel && !engineIsIos) {
  58521. channel = new MessageChannel();
  58522. port = channel.port2;
  58523. channel.port1.onmessage = listener;
  58524. defer = functionBindContext(port.postMessage, port);
  58525. // Browsers with postMessage, skip WebWorkers
  58526. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  58527. } else if (
  58528. global_1.addEventListener &&
  58529. isCallable(global_1.postMessage) &&
  58530. !global_1.importScripts &&
  58531. location$1 && location$1.protocol !== 'file:' &&
  58532. !fails(post)
  58533. ) {
  58534. defer = post;
  58535. global_1.addEventListener('message', listener, false);
  58536. // IE8-
  58537. } else if (ONREADYSTATECHANGE in documentCreateElement('script')) {
  58538. defer = function (id) {
  58539. html.appendChild(documentCreateElement('script'))[ONREADYSTATECHANGE] = function () {
  58540. html.removeChild(this);
  58541. run(id);
  58542. };
  58543. };
  58544. // Rest old browsers
  58545. } else {
  58546. defer = function (id) {
  58547. setTimeout(runner(id), 0);
  58548. };
  58549. }
  58550. }
  58551. var task = {
  58552. set: set$1,
  58553. clear: clear
  58554. };
  58555. var engineIsIosPebble = /ipad|iphone|ipod/i.test(engineUserAgent) && global_1.Pebble !== undefined;
  58556. var engineIsWebosWebkit = /web0s(?!.*chrome)/i.test(engineUserAgent);
  58557. var getOwnPropertyDescriptor$9 = objectGetOwnPropertyDescriptor.f;
  58558. var macrotask = task.set;
  58559. var MutationObserver = global_1.MutationObserver || global_1.WebKitMutationObserver;
  58560. var document$2 = global_1.document;
  58561. var process$3 = global_1.process;
  58562. var Promise$1 = global_1.Promise;
  58563. // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
  58564. var queueMicrotaskDescriptor = getOwnPropertyDescriptor$9(global_1, 'queueMicrotask');
  58565. var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
  58566. var flush, head, last, notify, toggle, node, promise, then;
  58567. // modern engines have queueMicrotask method
  58568. if (!queueMicrotask) {
  58569. flush = function () {
  58570. var parent, fn;
  58571. if (engineIsNode && (parent = process$3.domain)) parent.exit();
  58572. while (head) {
  58573. fn = head.fn;
  58574. head = head.next;
  58575. try {
  58576. fn();
  58577. } catch (error) {
  58578. if (head) notify();
  58579. else last = undefined;
  58580. throw error;
  58581. }
  58582. } last = undefined;
  58583. if (parent) parent.enter();
  58584. };
  58585. // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
  58586. // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898
  58587. if (!engineIsIos && !engineIsNode && !engineIsWebosWebkit && MutationObserver && document$2) {
  58588. toggle = true;
  58589. node = document$2.createTextNode('');
  58590. new MutationObserver(flush).observe(node, { characterData: true });
  58591. notify = function () {
  58592. node.data = toggle = !toggle;
  58593. };
  58594. // environments with maybe non-completely correct, but existent Promise
  58595. } else if (!engineIsIosPebble && Promise$1 && Promise$1.resolve) {
  58596. // Promise.resolve without an argument throws an error in LG WebOS 2
  58597. promise = Promise$1.resolve(undefined);
  58598. // workaround of WebKit ~ iOS Safari 10.1 bug
  58599. promise.constructor = Promise$1;
  58600. then = functionBindContext(promise.then, promise);
  58601. notify = function () {
  58602. then(flush);
  58603. };
  58604. // Node.js without promises
  58605. } else if (engineIsNode) {
  58606. notify = function () {
  58607. process$3.nextTick(flush);
  58608. };
  58609. // for other environments - macrotask based on:
  58610. // - setImmediate
  58611. // - MessageChannel
  58612. // - window.postMessage
  58613. // - onreadystatechange
  58614. // - setTimeout
  58615. } else {
  58616. // strange IE + webpack dev server bug - use .bind(global)
  58617. macrotask = functionBindContext(macrotask, global_1);
  58618. notify = function () {
  58619. macrotask(flush);
  58620. };
  58621. }
  58622. }
  58623. var microtask = queueMicrotask || function (fn) {
  58624. var task = { fn: fn, next: undefined };
  58625. if (last) last.next = task;
  58626. if (!head) {
  58627. head = task;
  58628. notify();
  58629. } last = task;
  58630. };
  58631. var hostReportErrors = function (a, b) {
  58632. var console = global_1.console;
  58633. if (console && console.error) {
  58634. arguments.length == 1 ? console.error(a) : console.error(a, b);
  58635. }
  58636. };
  58637. var perform = function (exec) {
  58638. try {
  58639. return { error: false, value: exec() };
  58640. } catch (error) {
  58641. return { error: true, value: error };
  58642. }
  58643. };
  58644. var Queue = function () {
  58645. this.head = null;
  58646. this.tail = null;
  58647. };
  58648. Queue.prototype = {
  58649. add: function (item) {
  58650. var entry = { item: item, next: null };
  58651. if (this.head) this.tail.next = entry;
  58652. else this.head = entry;
  58653. this.tail = entry;
  58654. },
  58655. get: function () {
  58656. var entry = this.head;
  58657. if (entry) {
  58658. this.head = entry.next;
  58659. if (this.tail === entry) this.tail = null;
  58660. return entry.item;
  58661. }
  58662. }
  58663. };
  58664. var queue$1 = Queue;
  58665. var promiseNativeConstructor = global_1.Promise;
  58666. var engineIsBrowser = typeof window == 'object' && typeof Deno != 'object';
  58667. var NativePromisePrototype = promiseNativeConstructor && promiseNativeConstructor.prototype;
  58668. var SPECIES$5 = wellKnownSymbol('species');
  58669. var SUBCLASSING = false;
  58670. var NATIVE_PROMISE_REJECTION_EVENT = isCallable(global_1.PromiseRejectionEvent);
  58671. var FORCED_PROMISE_CONSTRUCTOR = isForced_1('Promise', function () {
  58672. var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(promiseNativeConstructor);
  58673. var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(promiseNativeConstructor);
  58674. // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
  58675. // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
  58676. // We can't detect it synchronously, so just check versions
  58677. if (!GLOBAL_CORE_JS_PROMISE && engineV8Version === 66) return true;
  58678. // We need Promise#{ catch, finally } in the pure version for preventing prototype pollution
  58679. if ( !(NativePromisePrototype['catch'] && NativePromisePrototype['finally'])) return true;
  58680. // We can't use @@species feature detection in V8 since it causes
  58681. // deoptimization and performance degradation
  58682. // https://github.com/zloirock/core-js/issues/679
  58683. if (engineV8Version >= 51 && /native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) return false;
  58684. // Detect correctness of subclassing with @@species support
  58685. var promise = new promiseNativeConstructor(function (resolve) { resolve(1); });
  58686. var FakePromise = function (exec) {
  58687. exec(function () { /* empty */ }, function () { /* empty */ });
  58688. };
  58689. var constructor = promise.constructor = {};
  58690. constructor[SPECIES$5] = FakePromise;
  58691. SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise;
  58692. if (!SUBCLASSING) return true;
  58693. // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  58694. return !GLOBAL_CORE_JS_PROMISE && engineIsBrowser && !NATIVE_PROMISE_REJECTION_EVENT;
  58695. });
  58696. var promiseConstructorDetection = {
  58697. CONSTRUCTOR: FORCED_PROMISE_CONSTRUCTOR,
  58698. REJECTION_EVENT: NATIVE_PROMISE_REJECTION_EVENT,
  58699. SUBCLASSING: SUBCLASSING
  58700. };
  58701. var PromiseCapability = function (C) {
  58702. var resolve, reject;
  58703. this.promise = new C(function ($$resolve, $$reject) {
  58704. if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
  58705. resolve = $$resolve;
  58706. reject = $$reject;
  58707. });
  58708. this.resolve = aCallable(resolve);
  58709. this.reject = aCallable(reject);
  58710. };
  58711. // `NewPromiseCapability` abstract operation
  58712. // https://tc39.es/ecma262/#sec-newpromisecapability
  58713. var f$8 = function (C) {
  58714. return new PromiseCapability(C);
  58715. };
  58716. var newPromiseCapability = {
  58717. f: f$8
  58718. };
  58719. var task$1 = task.set;
  58720. var PROMISE = 'Promise';
  58721. var FORCED_PROMISE_CONSTRUCTOR$1 = promiseConstructorDetection.CONSTRUCTOR;
  58722. var NATIVE_PROMISE_REJECTION_EVENT$1 = promiseConstructorDetection.REJECTION_EVENT;
  58723. var getInternalPromiseState = internalState.getterFor(PROMISE);
  58724. var setInternalState$7 = internalState.set;
  58725. var NativePromisePrototype$1 = promiseNativeConstructor && promiseNativeConstructor.prototype;
  58726. var PromiseConstructor = promiseNativeConstructor;
  58727. var PromisePrototype = NativePromisePrototype$1;
  58728. var TypeError$p = global_1.TypeError;
  58729. var document$3 = global_1.document;
  58730. var process$4 = global_1.process;
  58731. var newPromiseCapability$1 = newPromiseCapability.f;
  58732. var newGenericPromiseCapability = newPromiseCapability$1;
  58733. var DISPATCH_EVENT = !!(document$3 && document$3.createEvent && global_1.dispatchEvent);
  58734. var UNHANDLED_REJECTION = 'unhandledrejection';
  58735. var REJECTION_HANDLED = 'rejectionhandled';
  58736. var PENDING = 0;
  58737. var FULFILLED = 1;
  58738. var REJECTED = 2;
  58739. var HANDLED = 1;
  58740. var UNHANDLED = 2;
  58741. var Internal, OwnPromiseCapability, PromiseWrapper;
  58742. // helpers
  58743. var isThenable = function (it) {
  58744. var then;
  58745. return isObject(it) && isCallable(then = it.then) ? then : false;
  58746. };
  58747. var callReaction = function (reaction, state) {
  58748. var value = state.value;
  58749. var ok = state.state == FULFILLED;
  58750. var handler = ok ? reaction.ok : reaction.fail;
  58751. var resolve = reaction.resolve;
  58752. var reject = reaction.reject;
  58753. var domain = reaction.domain;
  58754. var result, then, exited;
  58755. try {
  58756. if (handler) {
  58757. if (!ok) {
  58758. if (state.rejection === UNHANDLED) onHandleUnhandled(state);
  58759. state.rejection = HANDLED;
  58760. }
  58761. if (handler === true) result = value;
  58762. else {
  58763. if (domain) domain.enter();
  58764. result = handler(value); // can throw
  58765. if (domain) {
  58766. domain.exit();
  58767. exited = true;
  58768. }
  58769. }
  58770. if (result === reaction.promise) {
  58771. reject(TypeError$p('Promise-chain cycle'));
  58772. } else if (then = isThenable(result)) {
  58773. functionCall(then, result, resolve, reject);
  58774. } else resolve(result);
  58775. } else reject(value);
  58776. } catch (error) {
  58777. if (domain && !exited) domain.exit();
  58778. reject(error);
  58779. }
  58780. };
  58781. var notify$1 = function (state, isReject) {
  58782. if (state.notified) return;
  58783. state.notified = true;
  58784. microtask(function () {
  58785. var reactions = state.reactions;
  58786. var reaction;
  58787. while (reaction = reactions.get()) {
  58788. callReaction(reaction, state);
  58789. }
  58790. state.notified = false;
  58791. if (isReject && !state.rejection) onUnhandled(state);
  58792. });
  58793. };
  58794. var dispatchEvent = function (name, promise, reason) {
  58795. var event, handler;
  58796. if (DISPATCH_EVENT) {
  58797. event = document$3.createEvent('Event');
  58798. event.promise = promise;
  58799. event.reason = reason;
  58800. event.initEvent(name, false, true);
  58801. global_1.dispatchEvent(event);
  58802. } else event = { promise: promise, reason: reason };
  58803. if (!NATIVE_PROMISE_REJECTION_EVENT$1 && (handler = global_1['on' + name])) handler(event);
  58804. else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
  58805. };
  58806. var onUnhandled = function (state) {
  58807. functionCall(task$1, global_1, function () {
  58808. var promise = state.facade;
  58809. var value = state.value;
  58810. var IS_UNHANDLED = isUnhandled(state);
  58811. var result;
  58812. if (IS_UNHANDLED) {
  58813. result = perform(function () {
  58814. if (engineIsNode) {
  58815. process$4.emit('unhandledRejection', value, promise);
  58816. } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
  58817. });
  58818. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  58819. state.rejection = engineIsNode || isUnhandled(state) ? UNHANDLED : HANDLED;
  58820. if (result.error) throw result.value;
  58821. }
  58822. });
  58823. };
  58824. var isUnhandled = function (state) {
  58825. return state.rejection !== HANDLED && !state.parent;
  58826. };
  58827. var onHandleUnhandled = function (state) {
  58828. functionCall(task$1, global_1, function () {
  58829. var promise = state.facade;
  58830. if (engineIsNode) {
  58831. process$4.emit('rejectionHandled', promise);
  58832. } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
  58833. });
  58834. };
  58835. var bind$b = function (fn, state, unwrap) {
  58836. return function (value) {
  58837. fn(state, value, unwrap);
  58838. };
  58839. };
  58840. var internalReject = function (state, value, unwrap) {
  58841. if (state.done) return;
  58842. state.done = true;
  58843. if (unwrap) state = unwrap;
  58844. state.value = value;
  58845. state.state = REJECTED;
  58846. notify$1(state, true);
  58847. };
  58848. var internalResolve = function (state, value, unwrap) {
  58849. if (state.done) return;
  58850. state.done = true;
  58851. if (unwrap) state = unwrap;
  58852. try {
  58853. if (state.facade === value) throw TypeError$p("Promise can't be resolved itself");
  58854. var then = isThenable(value);
  58855. if (then) {
  58856. microtask(function () {
  58857. var wrapper = { done: false };
  58858. try {
  58859. functionCall(then, value,
  58860. bind$b(internalResolve, wrapper, state),
  58861. bind$b(internalReject, wrapper, state)
  58862. );
  58863. } catch (error) {
  58864. internalReject(wrapper, error, state);
  58865. }
  58866. });
  58867. } else {
  58868. state.value = value;
  58869. state.state = FULFILLED;
  58870. notify$1(state, false);
  58871. }
  58872. } catch (error) {
  58873. internalReject({ done: false }, error, state);
  58874. }
  58875. };
  58876. // constructor polyfill
  58877. if (FORCED_PROMISE_CONSTRUCTOR$1) {
  58878. // 25.4.3.1 Promise(executor)
  58879. PromiseConstructor = function Promise(executor) {
  58880. anInstance(this, PromisePrototype);
  58881. aCallable(executor);
  58882. functionCall(Internal, this);
  58883. var state = getInternalPromiseState(this);
  58884. try {
  58885. executor(bind$b(internalResolve, state), bind$b(internalReject, state));
  58886. } catch (error) {
  58887. internalReject(state, error);
  58888. }
  58889. };
  58890. PromisePrototype = PromiseConstructor.prototype;
  58891. // eslint-disable-next-line no-unused-vars -- required for `.length`
  58892. Internal = function Promise(executor) {
  58893. setInternalState$7(this, {
  58894. type: PROMISE,
  58895. done: false,
  58896. notified: false,
  58897. parent: false,
  58898. reactions: new queue$1(),
  58899. rejection: false,
  58900. state: PENDING,
  58901. value: undefined
  58902. });
  58903. };
  58904. // `Promise.prototype.then` method
  58905. // https://tc39.es/ecma262/#sec-promise.prototype.then
  58906. Internal.prototype = defineBuiltIn(PromisePrototype, 'then', function then(onFulfilled, onRejected) {
  58907. var state = getInternalPromiseState(this);
  58908. var reaction = newPromiseCapability$1(speciesConstructor(this, PromiseConstructor));
  58909. state.parent = true;
  58910. reaction.ok = isCallable(onFulfilled) ? onFulfilled : true;
  58911. reaction.fail = isCallable(onRejected) && onRejected;
  58912. reaction.domain = engineIsNode ? process$4.domain : undefined;
  58913. if (state.state == PENDING) state.reactions.add(reaction);
  58914. else microtask(function () {
  58915. callReaction(reaction, state);
  58916. });
  58917. return reaction.promise;
  58918. });
  58919. OwnPromiseCapability = function () {
  58920. var promise = new Internal();
  58921. var state = getInternalPromiseState(promise);
  58922. this.promise = promise;
  58923. this.resolve = bind$b(internalResolve, state);
  58924. this.reject = bind$b(internalReject, state);
  58925. };
  58926. newPromiseCapability.f = newPromiseCapability$1 = function (C) {
  58927. return C === PromiseConstructor || C === PromiseWrapper
  58928. ? new OwnPromiseCapability(C)
  58929. : newGenericPromiseCapability(C);
  58930. };
  58931. }
  58932. _export({ global: true, constructor: true, wrap: true, forced: FORCED_PROMISE_CONSTRUCTOR$1 }, {
  58933. Promise: PromiseConstructor
  58934. });
  58935. setToStringTag(PromiseConstructor, PROMISE, false, true);
  58936. setSpecies(PROMISE);
  58937. var FORCED_PROMISE_CONSTRUCTOR$2 = promiseConstructorDetection.CONSTRUCTOR;
  58938. var promiseStaticsIncorrectIteration = FORCED_PROMISE_CONSTRUCTOR$2 || !checkCorrectnessOfIteration(function (iterable) {
  58939. promiseNativeConstructor.all(iterable).then(undefined, function () { /* empty */ });
  58940. });
  58941. // `Promise.all` method
  58942. // https://tc39.es/ecma262/#sec-promise.all
  58943. _export({ target: 'Promise', stat: true, forced: promiseStaticsIncorrectIteration }, {
  58944. all: function all(iterable) {
  58945. var C = this;
  58946. var capability = newPromiseCapability.f(C);
  58947. var resolve = capability.resolve;
  58948. var reject = capability.reject;
  58949. var result = perform(function () {
  58950. var $promiseResolve = aCallable(C.resolve);
  58951. var values = [];
  58952. var counter = 0;
  58953. var remaining = 1;
  58954. iterate(iterable, function (promise) {
  58955. var index = counter++;
  58956. var alreadyCalled = false;
  58957. remaining++;
  58958. functionCall($promiseResolve, C, promise).then(function (value) {
  58959. if (alreadyCalled) return;
  58960. alreadyCalled = true;
  58961. values[index] = value;
  58962. --remaining || resolve(values);
  58963. }, reject);
  58964. });
  58965. --remaining || resolve(values);
  58966. });
  58967. if (result.error) reject(result.value);
  58968. return capability.promise;
  58969. }
  58970. });
  58971. var FORCED_PROMISE_CONSTRUCTOR$3 = promiseConstructorDetection.CONSTRUCTOR;
  58972. var NativePromisePrototype$2 = promiseNativeConstructor && promiseNativeConstructor.prototype;
  58973. // `Promise.prototype.catch` method
  58974. // https://tc39.es/ecma262/#sec-promise.prototype.catch
  58975. _export({ target: 'Promise', proto: true, forced: FORCED_PROMISE_CONSTRUCTOR$3, real: true }, {
  58976. 'catch': function (onRejected) {
  58977. return this.then(undefined, onRejected);
  58978. }
  58979. });
  58980. // `Promise.race` method
  58981. // https://tc39.es/ecma262/#sec-promise.race
  58982. _export({ target: 'Promise', stat: true, forced: promiseStaticsIncorrectIteration }, {
  58983. race: function race(iterable) {
  58984. var C = this;
  58985. var capability = newPromiseCapability.f(C);
  58986. var reject = capability.reject;
  58987. var result = perform(function () {
  58988. var $promiseResolve = aCallable(C.resolve);
  58989. iterate(iterable, function (promise) {
  58990. functionCall($promiseResolve, C, promise).then(capability.resolve, reject);
  58991. });
  58992. });
  58993. if (result.error) reject(result.value);
  58994. return capability.promise;
  58995. }
  58996. });
  58997. var FORCED_PROMISE_CONSTRUCTOR$4 = promiseConstructorDetection.CONSTRUCTOR;
  58998. // `Promise.reject` method
  58999. // https://tc39.es/ecma262/#sec-promise.reject
  59000. _export({ target: 'Promise', stat: true, forced: FORCED_PROMISE_CONSTRUCTOR$4 }, {
  59001. reject: function reject(r) {
  59002. var capability = newPromiseCapability.f(this);
  59003. functionCall(capability.reject, undefined, r);
  59004. return capability.promise;
  59005. }
  59006. });
  59007. var promiseResolve = function (C, x) {
  59008. anObject(C);
  59009. if (isObject(x) && x.constructor === C) return x;
  59010. var promiseCapability = newPromiseCapability.f(C);
  59011. var resolve = promiseCapability.resolve;
  59012. resolve(x);
  59013. return promiseCapability.promise;
  59014. };
  59015. var FORCED_PROMISE_CONSTRUCTOR$5 = promiseConstructorDetection.CONSTRUCTOR;
  59016. var PromiseConstructorWrapper = getBuiltIn('Promise');
  59017. var CHECK_WRAPPER = !FORCED_PROMISE_CONSTRUCTOR$5;
  59018. // `Promise.resolve` method
  59019. // https://tc39.es/ecma262/#sec-promise.resolve
  59020. _export({ target: 'Promise', stat: true, forced: isPure }, {
  59021. resolve: function resolve(x) {
  59022. return promiseResolve(CHECK_WRAPPER && this === PromiseConstructorWrapper ? promiseNativeConstructor : this, x);
  59023. }
  59024. });
  59025. // `Promise.allSettled` method
  59026. // https://tc39.es/ecma262/#sec-promise.allsettled
  59027. _export({ target: 'Promise', stat: true }, {
  59028. allSettled: function allSettled(iterable) {
  59029. var C = this;
  59030. var capability = newPromiseCapability.f(C);
  59031. var resolve = capability.resolve;
  59032. var reject = capability.reject;
  59033. var result = perform(function () {
  59034. var promiseResolve = aCallable(C.resolve);
  59035. var values = [];
  59036. var counter = 0;
  59037. var remaining = 1;
  59038. iterate(iterable, function (promise) {
  59039. var index = counter++;
  59040. var alreadyCalled = false;
  59041. remaining++;
  59042. functionCall(promiseResolve, C, promise).then(function (value) {
  59043. if (alreadyCalled) return;
  59044. alreadyCalled = true;
  59045. values[index] = { status: 'fulfilled', value: value };
  59046. --remaining || resolve(values);
  59047. }, function (error) {
  59048. if (alreadyCalled) return;
  59049. alreadyCalled = true;
  59050. values[index] = { status: 'rejected', reason: error };
  59051. --remaining || resolve(values);
  59052. });
  59053. });
  59054. --remaining || resolve(values);
  59055. });
  59056. if (result.error) reject(result.value);
  59057. return capability.promise;
  59058. }
  59059. });
  59060. var PROMISE_ANY_ERROR = 'No one promise resolved';
  59061. // `Promise.any` method
  59062. // https://tc39.es/ecma262/#sec-promise.any
  59063. _export({ target: 'Promise', stat: true }, {
  59064. any: function any(iterable) {
  59065. var C = this;
  59066. var AggregateError = getBuiltIn('AggregateError');
  59067. var capability = newPromiseCapability.f(C);
  59068. var resolve = capability.resolve;
  59069. var reject = capability.reject;
  59070. var result = perform(function () {
  59071. var promiseResolve = aCallable(C.resolve);
  59072. var errors = [];
  59073. var counter = 0;
  59074. var remaining = 1;
  59075. var alreadyResolved = false;
  59076. iterate(iterable, function (promise) {
  59077. var index = counter++;
  59078. var alreadyRejected = false;
  59079. remaining++;
  59080. functionCall(promiseResolve, C, promise).then(function (value) {
  59081. if (alreadyRejected || alreadyResolved) return;
  59082. alreadyResolved = true;
  59083. resolve(value);
  59084. }, function (error) {
  59085. if (alreadyRejected || alreadyResolved) return;
  59086. alreadyRejected = true;
  59087. errors[index] = error;
  59088. --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR));
  59089. });
  59090. });
  59091. --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR));
  59092. });
  59093. if (result.error) reject(result.value);
  59094. return capability.promise;
  59095. }
  59096. });
  59097. var NativePromisePrototype$3 = promiseNativeConstructor && promiseNativeConstructor.prototype;
  59098. // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
  59099. var NON_GENERIC = !!promiseNativeConstructor && fails(function () {
  59100. // eslint-disable-next-line unicorn/no-thenable -- required for testing
  59101. NativePromisePrototype$3['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });
  59102. });
  59103. // `Promise.prototype.finally` method
  59104. // https://tc39.es/ecma262/#sec-promise.prototype.finally
  59105. _export({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
  59106. 'finally': function (onFinally) {
  59107. var C = speciesConstructor(this, getBuiltIn('Promise'));
  59108. var isFunction = isCallable(onFinally);
  59109. return this.then(
  59110. isFunction ? function (x) {
  59111. return promiseResolve(C, onFinally()).then(function () { return x; });
  59112. } : onFinally,
  59113. isFunction ? function (e) {
  59114. return promiseResolve(C, onFinally()).then(function () { throw e; });
  59115. } : onFinally
  59116. );
  59117. }
  59118. });
  59119. var promise$1 = path.Promise;
  59120. var promise$2 = promise$1;
  59121. var promise$3 = promise$2;
  59122. // TODO: Remove from `core-js@4`
  59123. // `Promise.try` method
  59124. // https://github.com/tc39/proposal-promise-try
  59125. _export({ target: 'Promise', stat: true, forced: true }, {
  59126. 'try': function (callbackfn) {
  59127. var promiseCapability = newPromiseCapability.f(this);
  59128. var result = perform(callbackfn);
  59129. (result.error ? promiseCapability.reject : promiseCapability.resolve)(result.value);
  59130. return promiseCapability.promise;
  59131. }
  59132. });
  59133. // TODO: Remove from `core-js@4`
  59134. var promise$4 = promise$3;
  59135. var promise$5 = promise$4;
  59136. var promise$6 = promise$5;
  59137. var asyncToGenerator = createCommonjsModule(function (module) {
  59138. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  59139. try {
  59140. var info = gen[key](arg);
  59141. var value = info.value;
  59142. } catch (error) {
  59143. reject(error);
  59144. return;
  59145. }
  59146. if (info.done) {
  59147. resolve(value);
  59148. } else {
  59149. promise$6.resolve(value).then(_next, _throw);
  59150. }
  59151. }
  59152. function _asyncToGenerator(fn) {
  59153. return function () {
  59154. var self = this,
  59155. args = arguments;
  59156. return new promise$6(function (resolve, reject) {
  59157. var gen = fn.apply(self, args);
  59158. function _next(value) {
  59159. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  59160. }
  59161. function _throw(err) {
  59162. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  59163. }
  59164. _next(undefined);
  59165. });
  59166. };
  59167. }
  59168. module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
  59169. });
  59170. var _asyncToGenerator = unwrapExports(asyncToGenerator);
  59171. var forEach$6 = forEach$2;
  59172. var forEach$7 = forEach$6;
  59173. var forEach$8 = forEach$7;
  59174. var forEach$9 = forEach$8;
  59175. var un$Reverse = functionUncurryThis([].reverse);
  59176. var test$1 = [1, 2];
  59177. // `Array.prototype.reverse` method
  59178. // https://tc39.es/ecma262/#sec-array.prototype.reverse
  59179. // fix for Safari 12.0 bug
  59180. // https://bugs.webkit.org/show_bug.cgi?id=188794
  59181. _export({ target: 'Array', proto: true, forced: String(test$1) === String(test$1.reverse()) }, {
  59182. reverse: function reverse() {
  59183. // eslint-disable-next-line no-self-assign -- dirty hack
  59184. if (isArray(this)) this.length = this.length;
  59185. return un$Reverse(this);
  59186. }
  59187. });
  59188. var reverse = entryVirtual('Array').reverse;
  59189. var ArrayPrototype$g = Array.prototype;
  59190. var reverse$1 = function (it) {
  59191. var own = it.reverse;
  59192. return it === ArrayPrototype$g || (objectIsPrototypeOf(ArrayPrototype$g, it) && own === ArrayPrototype$g.reverse) ? reverse : own;
  59193. };
  59194. var reverse$2 = reverse$1;
  59195. var reverse$3 = reverse$2;
  59196. var reverse$4 = reverse$3;
  59197. var reverse$5 = reverse$4;
  59198. var reverse$6 = reverse$5;
  59199. var regeneratorRuntime = createCommonjsModule(function (module) {
  59200. var _typeof = _typeof_1["default"];
  59201. function _regeneratorRuntime() {
  59202. /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
  59203. module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
  59204. return exports;
  59205. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  59206. var exports = {},
  59207. Op = Object.prototype,
  59208. hasOwn = Op.hasOwnProperty,
  59209. $Symbol = "function" == typeof symbol$5 ? symbol$5 : {},
  59210. iteratorSymbol = $Symbol.iterator || "@@iterator",
  59211. asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
  59212. toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  59213. function define(obj, key, value) {
  59214. return defineProperty$9(obj, key, {
  59215. value: value,
  59216. enumerable: !0,
  59217. configurable: !0,
  59218. writable: !0
  59219. }), obj[key];
  59220. }
  59221. try {
  59222. define({}, "");
  59223. } catch (err) {
  59224. define = function define(obj, key, value) {
  59225. return obj[key] = value;
  59226. };
  59227. }
  59228. function wrap(innerFn, outerFn, self, tryLocsList) {
  59229. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
  59230. generator = create$5(protoGenerator.prototype),
  59231. context = new Context(tryLocsList || []);
  59232. return generator._invoke = function (innerFn, self, context) {
  59233. var state = "suspendedStart";
  59234. return function (method, arg) {
  59235. if ("executing" === state) throw new Error("Generator is already running");
  59236. if ("completed" === state) {
  59237. if ("throw" === method) throw arg;
  59238. return doneResult();
  59239. }
  59240. for (context.method = method, context.arg = arg;;) {
  59241. var delegate = context.delegate;
  59242. if (delegate) {
  59243. var delegateResult = maybeInvokeDelegate(delegate, context);
  59244. if (delegateResult) {
  59245. if (delegateResult === ContinueSentinel) continue;
  59246. return delegateResult;
  59247. }
  59248. }
  59249. if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
  59250. if ("suspendedStart" === state) throw state = "completed", context.arg;
  59251. context.dispatchException(context.arg);
  59252. } else "return" === context.method && context.abrupt("return", context.arg);
  59253. state = "executing";
  59254. var record = tryCatch(innerFn, self, context);
  59255. if ("normal" === record.type) {
  59256. if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
  59257. return {
  59258. value: record.arg,
  59259. done: context.done
  59260. };
  59261. }
  59262. "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
  59263. }
  59264. };
  59265. }(innerFn, self, context), generator;
  59266. }
  59267. function tryCatch(fn, obj, arg) {
  59268. try {
  59269. return {
  59270. type: "normal",
  59271. arg: fn.call(obj, arg)
  59272. };
  59273. } catch (err) {
  59274. return {
  59275. type: "throw",
  59276. arg: err
  59277. };
  59278. }
  59279. }
  59280. exports.wrap = wrap;
  59281. var ContinueSentinel = {};
  59282. function Generator() {}
  59283. function GeneratorFunction() {}
  59284. function GeneratorFunctionPrototype() {}
  59285. var IteratorPrototype = {};
  59286. define(IteratorPrototype, iteratorSymbol, function () {
  59287. return this;
  59288. });
  59289. var getProto = getPrototypeOf$5,
  59290. NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  59291. NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
  59292. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = create$5(IteratorPrototype);
  59293. function defineIteratorMethods(prototype) {
  59294. var _context;
  59295. forEach$9(_context = ["next", "throw", "return"]).call(_context, function (method) {
  59296. define(prototype, method, function (arg) {
  59297. return this._invoke(method, arg);
  59298. });
  59299. });
  59300. }
  59301. function AsyncIterator(generator, PromiseImpl) {
  59302. function invoke(method, arg, resolve, reject) {
  59303. var record = tryCatch(generator[method], generator, arg);
  59304. if ("throw" !== record.type) {
  59305. var result = record.arg,
  59306. value = result.value;
  59307. return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
  59308. invoke("next", value, resolve, reject);
  59309. }, function (err) {
  59310. invoke("throw", err, resolve, reject);
  59311. }) : PromiseImpl.resolve(value).then(function (unwrapped) {
  59312. result.value = unwrapped, resolve(result);
  59313. }, function (error) {
  59314. return invoke("throw", error, resolve, reject);
  59315. });
  59316. }
  59317. reject(record.arg);
  59318. }
  59319. var previousPromise;
  59320. this._invoke = function (method, arg) {
  59321. function callInvokeWithMethodAndArg() {
  59322. return new PromiseImpl(function (resolve, reject) {
  59323. invoke(method, arg, resolve, reject);
  59324. });
  59325. }
  59326. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  59327. };
  59328. }
  59329. function maybeInvokeDelegate(delegate, context) {
  59330. var method = delegate.iterator[context.method];
  59331. if (undefined === method) {
  59332. if (context.delegate = null, "throw" === context.method) {
  59333. if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
  59334. context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
  59335. }
  59336. return ContinueSentinel;
  59337. }
  59338. var record = tryCatch(method, delegate.iterator, context.arg);
  59339. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
  59340. var info = record.arg;
  59341. return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
  59342. }
  59343. function pushTryEntry(locs) {
  59344. var entry = {
  59345. tryLoc: locs[0]
  59346. };
  59347. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  59348. }
  59349. function resetTryEntry(entry) {
  59350. var record = entry.completion || {};
  59351. record.type = "normal", delete record.arg, entry.completion = record;
  59352. }
  59353. function Context(tryLocsList) {
  59354. this.tryEntries = [{
  59355. tryLoc: "root"
  59356. }], forEach$9(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0);
  59357. }
  59358. function values(iterable) {
  59359. if (iterable) {
  59360. var iteratorMethod = iterable[iteratorSymbol];
  59361. if (iteratorMethod) return iteratorMethod.call(iterable);
  59362. if ("function" == typeof iterable.next) return iterable;
  59363. if (!isNaN(iterable.length)) {
  59364. var i = -1,
  59365. next = function next() {
  59366. for (; ++i < iterable.length;) {
  59367. if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
  59368. }
  59369. return next.value = undefined, next.done = !0, next;
  59370. };
  59371. return next.next = next;
  59372. }
  59373. }
  59374. return {
  59375. next: doneResult
  59376. };
  59377. }
  59378. function doneResult() {
  59379. return {
  59380. value: undefined,
  59381. done: !0
  59382. };
  59383. }
  59384. return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
  59385. var ctor = "function" == typeof genFun && genFun.constructor;
  59386. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  59387. }, exports.mark = function (genFun) {
  59388. return setPrototypeOf$5 ? setPrototypeOf$5(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = create$5(Gp), genFun;
  59389. }, exports.awrap = function (arg) {
  59390. return {
  59391. __await: arg
  59392. };
  59393. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  59394. return this;
  59395. }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  59396. void 0 === PromiseImpl && (PromiseImpl = promise$6);
  59397. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  59398. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  59399. return result.done ? result.value : iter.next();
  59400. });
  59401. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
  59402. return this;
  59403. }), define(Gp, "toString", function () {
  59404. return "[object Generator]";
  59405. }), exports.keys = function (object) {
  59406. var keys = [];
  59407. for (var key in object) {
  59408. keys.push(key);
  59409. }
  59410. return reverse$6(keys).call(keys), function next() {
  59411. for (; keys.length;) {
  59412. var key = keys.pop();
  59413. if (key in object) return next.value = key, next.done = !1, next;
  59414. }
  59415. return next.done = !0, next;
  59416. };
  59417. }, exports.values = values, Context.prototype = {
  59418. constructor: Context,
  59419. reset: function reset(skipTempReset) {
  59420. var _context2;
  59421. if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, forEach$9(_context2 = this.tryEntries).call(_context2, resetTryEntry), !skipTempReset) for (var name in this) {
  59422. "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+slice$6(name).call(name, 1)) && (this[name] = undefined);
  59423. }
  59424. },
  59425. stop: function stop() {
  59426. this.done = !0;
  59427. var rootRecord = this.tryEntries[0].completion;
  59428. if ("throw" === rootRecord.type) throw rootRecord.arg;
  59429. return this.rval;
  59430. },
  59431. dispatchException: function dispatchException(exception) {
  59432. if (this.done) throw exception;
  59433. var context = this;
  59434. function handle(loc, caught) {
  59435. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
  59436. }
  59437. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  59438. var entry = this.tryEntries[i],
  59439. record = entry.completion;
  59440. if ("root" === entry.tryLoc) return handle("end");
  59441. if (entry.tryLoc <= this.prev) {
  59442. var hasCatch = hasOwn.call(entry, "catchLoc"),
  59443. hasFinally = hasOwn.call(entry, "finallyLoc");
  59444. if (hasCatch && hasFinally) {
  59445. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  59446. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  59447. } else if (hasCatch) {
  59448. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  59449. } else {
  59450. if (!hasFinally) throw new Error("try statement without catch or finally");
  59451. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  59452. }
  59453. }
  59454. }
  59455. },
  59456. abrupt: function abrupt(type, arg) {
  59457. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  59458. var entry = this.tryEntries[i];
  59459. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  59460. var finallyEntry = entry;
  59461. break;
  59462. }
  59463. }
  59464. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  59465. var record = finallyEntry ? finallyEntry.completion : {};
  59466. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  59467. },
  59468. complete: function complete(record, afterLoc) {
  59469. if ("throw" === record.type) throw record.arg;
  59470. return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
  59471. },
  59472. finish: function finish(finallyLoc) {
  59473. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  59474. var entry = this.tryEntries[i];
  59475. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
  59476. }
  59477. },
  59478. "catch": function _catch(tryLoc) {
  59479. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  59480. var entry = this.tryEntries[i];
  59481. if (entry.tryLoc === tryLoc) {
  59482. var record = entry.completion;
  59483. if ("throw" === record.type) {
  59484. var thrown = record.arg;
  59485. resetTryEntry(entry);
  59486. }
  59487. return thrown;
  59488. }
  59489. }
  59490. throw new Error("illegal catch attempt");
  59491. },
  59492. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  59493. return this.delegate = {
  59494. iterator: values(iterable),
  59495. resultName: resultName,
  59496. nextLoc: nextLoc
  59497. }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
  59498. }
  59499. }, exports;
  59500. }
  59501. module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
  59502. });
  59503. unwrapExports(regeneratorRuntime);
  59504. var regenerator = regeneratorRuntime();
  59505. var promise$7 = promise$2;
  59506. const defaultOpts = {
  59507. xml: false,
  59508. decodeEntities: true,
  59509. };
  59510. const xmlModeDefault = {
  59511. _useHtmlParser2: true,
  59512. xmlMode: true,
  59513. };
  59514. /**
  59515. * Flatten the options for Cheerio.
  59516. *
  59517. * This will set `_useHtmlParser2` to true if `xml` is set to true.
  59518. *
  59519. * @param options - The options to flatten.
  59520. * @returns The flattened options.
  59521. */
  59522. function flatten(options) {
  59523. return (options === null || options === void 0 ? void 0 : options.xml)
  59524. ? typeof options.xml === 'boolean'
  59525. ? xmlModeDefault
  59526. : { ...xmlModeDefault, ...options.xml }
  59527. : options !== null && options !== void 0 ? options : undefined;
  59528. }
  59529. /** Types of elements found in htmlparser2's DOM */
  59530. var ElementType;
  59531. (function (ElementType) {
  59532. /** Type for the root element of a document */
  59533. ElementType["Root"] = "root";
  59534. /** Type for Text */
  59535. ElementType["Text"] = "text";
  59536. /** Type for <? ... ?> */
  59537. ElementType["Directive"] = "directive";
  59538. /** Type for <!-- ... --> */
  59539. ElementType["Comment"] = "comment";
  59540. /** Type for <script> tags */
  59541. ElementType["Script"] = "script";
  59542. /** Type for <style> tags */
  59543. ElementType["Style"] = "style";
  59544. /** Type for Any tag */
  59545. ElementType["Tag"] = "tag";
  59546. /** Type for <![CDATA[ ... ]]> */
  59547. ElementType["CDATA"] = "cdata";
  59548. /** Type for <!doctype ...> */
  59549. ElementType["Doctype"] = "doctype";
  59550. })(ElementType || (ElementType = {}));
  59551. /**
  59552. * Tests whether an element is a tag or not.
  59553. *
  59554. * @param elem Element to test
  59555. */
  59556. function isTag(elem) {
  59557. return (elem.type === ElementType.Tag ||
  59558. elem.type === ElementType.Script ||
  59559. elem.type === ElementType.Style);
  59560. }
  59561. // Exports for backwards compatibility
  59562. /** Type for the root element of a document */
  59563. const Root = ElementType.Root;
  59564. /** Type for Text */
  59565. const Text = ElementType.Text;
  59566. /** Type for <? ... ?> */
  59567. const Directive = ElementType.Directive;
  59568. /** Type for <!-- ... --> */
  59569. const Comment = ElementType.Comment;
  59570. /** Type for <script> tags */
  59571. const Script = ElementType.Script;
  59572. /** Type for <style> tags */
  59573. const Style = ElementType.Style;
  59574. /** Type for Any tag */
  59575. const Tag = ElementType.Tag;
  59576. /** Type for <![CDATA[ ... ]]> */
  59577. const CDATA = ElementType.CDATA;
  59578. /** Type for <!doctype ...> */
  59579. const Doctype = ElementType.Doctype;
  59580. /**
  59581. * This object will be used as the prototype for Nodes when creating a
  59582. * DOM-Level-1-compliant structure.
  59583. */
  59584. class Node$2 {
  59585. constructor() {
  59586. /** Parent of the node */
  59587. this.parent = null;
  59588. /** Previous sibling */
  59589. this.prev = null;
  59590. /** Next sibling */
  59591. this.next = null;
  59592. /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
  59593. this.startIndex = null;
  59594. /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
  59595. this.endIndex = null;
  59596. }
  59597. // Read-write aliases for properties
  59598. /**
  59599. * Same as {@link parent}.
  59600. * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
  59601. */
  59602. get parentNode() {
  59603. return this.parent;
  59604. }
  59605. set parentNode(parent) {
  59606. this.parent = parent;
  59607. }
  59608. /**
  59609. * Same as {@link prev}.
  59610. * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
  59611. */
  59612. get previousSibling() {
  59613. return this.prev;
  59614. }
  59615. set previousSibling(prev) {
  59616. this.prev = prev;
  59617. }
  59618. /**
  59619. * Same as {@link next}.
  59620. * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
  59621. */
  59622. get nextSibling() {
  59623. return this.next;
  59624. }
  59625. set nextSibling(next) {
  59626. this.next = next;
  59627. }
  59628. /**
  59629. * Clone this node, and optionally its children.
  59630. *
  59631. * @param recursive Clone child nodes as well.
  59632. * @returns A clone of the node.
  59633. */
  59634. cloneNode(recursive = false) {
  59635. return cloneNode(this, recursive);
  59636. }
  59637. }
  59638. /**
  59639. * A node that contains some data.
  59640. */
  59641. class DataNode extends Node$2 {
  59642. /**
  59643. * @param data The content of the data node
  59644. */
  59645. constructor(data) {
  59646. super();
  59647. this.data = data;
  59648. }
  59649. /**
  59650. * Same as {@link data}.
  59651. * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
  59652. */
  59653. get nodeValue() {
  59654. return this.data;
  59655. }
  59656. set nodeValue(data) {
  59657. this.data = data;
  59658. }
  59659. }
  59660. /**
  59661. * Text within the document.
  59662. */
  59663. class Text$1 extends DataNode {
  59664. constructor() {
  59665. super(...arguments);
  59666. this.type = ElementType.Text;
  59667. }
  59668. get nodeType() {
  59669. return 3;
  59670. }
  59671. }
  59672. /**
  59673. * Comments within the document.
  59674. */
  59675. class Comment$1 extends DataNode {
  59676. constructor() {
  59677. super(...arguments);
  59678. this.type = ElementType.Comment;
  59679. }
  59680. get nodeType() {
  59681. return 8;
  59682. }
  59683. }
  59684. /**
  59685. * Processing instructions, including doc types.
  59686. */
  59687. class ProcessingInstruction extends DataNode {
  59688. constructor(name, data) {
  59689. super(data);
  59690. this.name = name;
  59691. this.type = ElementType.Directive;
  59692. }
  59693. get nodeType() {
  59694. return 1;
  59695. }
  59696. }
  59697. /**
  59698. * A `Node` that can have children.
  59699. */
  59700. class NodeWithChildren extends Node$2 {
  59701. /**
  59702. * @param children Children of the node. Only certain node types can have children.
  59703. */
  59704. constructor(children) {
  59705. super();
  59706. this.children = children;
  59707. }
  59708. // Aliases
  59709. /** First child of the node. */
  59710. get firstChild() {
  59711. var _a;
  59712. return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
  59713. }
  59714. /** Last child of the node. */
  59715. get lastChild() {
  59716. return this.children.length > 0
  59717. ? this.children[this.children.length - 1]
  59718. : null;
  59719. }
  59720. /**
  59721. * Same as {@link children}.
  59722. * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
  59723. */
  59724. get childNodes() {
  59725. return this.children;
  59726. }
  59727. set childNodes(children) {
  59728. this.children = children;
  59729. }
  59730. }
  59731. class CDATA$1 extends NodeWithChildren {
  59732. constructor() {
  59733. super(...arguments);
  59734. this.type = ElementType.CDATA;
  59735. }
  59736. get nodeType() {
  59737. return 4;
  59738. }
  59739. }
  59740. /**
  59741. * The root node of the document.
  59742. */
  59743. class Document extends NodeWithChildren {
  59744. constructor() {
  59745. super(...arguments);
  59746. this.type = ElementType.Root;
  59747. }
  59748. get nodeType() {
  59749. return 9;
  59750. }
  59751. }
  59752. /**
  59753. * An element within the DOM.
  59754. */
  59755. class Element extends NodeWithChildren {
  59756. /**
  59757. * @param name Name of the tag, eg. `div`, `span`.
  59758. * @param attribs Object mapping attribute names to attribute values.
  59759. * @param children Children of the node.
  59760. */
  59761. constructor(name, attribs, children = [], type = name === "script"
  59762. ? ElementType.Script
  59763. : name === "style"
  59764. ? ElementType.Style
  59765. : ElementType.Tag) {
  59766. super(children);
  59767. this.name = name;
  59768. this.attribs = attribs;
  59769. this.type = type;
  59770. }
  59771. get nodeType() {
  59772. return 1;
  59773. }
  59774. // DOM Level 1 aliases
  59775. /**
  59776. * Same as {@link name}.
  59777. * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
  59778. */
  59779. get tagName() {
  59780. return this.name;
  59781. }
  59782. set tagName(name) {
  59783. this.name = name;
  59784. }
  59785. get attributes() {
  59786. return Object.keys(this.attribs).map((name) => {
  59787. var _a, _b;
  59788. return ({
  59789. name,
  59790. value: this.attribs[name],
  59791. namespace: (_a = this["x-attribsNamespace"]) === null || _a === void 0 ? void 0 : _a[name],
  59792. prefix: (_b = this["x-attribsPrefix"]) === null || _b === void 0 ? void 0 : _b[name],
  59793. });
  59794. });
  59795. }
  59796. }
  59797. /**
  59798. * @param node Node to check.
  59799. * @returns `true` if the node is a `Element`, `false` otherwise.
  59800. */
  59801. function isTag$1(node) {
  59802. return isTag(node);
  59803. }
  59804. /**
  59805. * @param node Node to check.
  59806. * @returns `true` if the node has the type `CDATA`, `false` otherwise.
  59807. */
  59808. function isCDATA(node) {
  59809. return node.type === ElementType.CDATA;
  59810. }
  59811. /**
  59812. * @param node Node to check.
  59813. * @returns `true` if the node has the type `Text`, `false` otherwise.
  59814. */
  59815. function isText(node) {
  59816. return node.type === ElementType.Text;
  59817. }
  59818. /**
  59819. * @param node Node to check.
  59820. * @returns `true` if the node has the type `Comment`, `false` otherwise.
  59821. */
  59822. function isComment(node) {
  59823. return node.type === ElementType.Comment;
  59824. }
  59825. /**
  59826. * @param node Node to check.
  59827. * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
  59828. */
  59829. function isDirective(node) {
  59830. return node.type === ElementType.Directive;
  59831. }
  59832. /**
  59833. * @param node Node to check.
  59834. * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
  59835. */
  59836. function isDocument(node) {
  59837. return node.type === ElementType.Root;
  59838. }
  59839. /**
  59840. * @param node Node to check.
  59841. * @returns `true` if the node has children, `false` otherwise.
  59842. */
  59843. function hasChildren(node) {
  59844. return Object.prototype.hasOwnProperty.call(node, "children");
  59845. }
  59846. /**
  59847. * Clone a node, and optionally its children.
  59848. *
  59849. * @param recursive Clone child nodes as well.
  59850. * @returns A clone of the node.
  59851. */
  59852. function cloneNode(node, recursive = false) {
  59853. let result;
  59854. if (isText(node)) {
  59855. result = new Text$1(node.data);
  59856. }
  59857. else if (isComment(node)) {
  59858. result = new Comment$1(node.data);
  59859. }
  59860. else if (isTag$1(node)) {
  59861. const children = recursive ? cloneChildren(node.children) : [];
  59862. const clone = new Element(node.name, { ...node.attribs }, children);
  59863. children.forEach((child) => (child.parent = clone));
  59864. if (node.namespace != null) {
  59865. clone.namespace = node.namespace;
  59866. }
  59867. if (node["x-attribsNamespace"]) {
  59868. clone["x-attribsNamespace"] = { ...node["x-attribsNamespace"] };
  59869. }
  59870. if (node["x-attribsPrefix"]) {
  59871. clone["x-attribsPrefix"] = { ...node["x-attribsPrefix"] };
  59872. }
  59873. result = clone;
  59874. }
  59875. else if (isCDATA(node)) {
  59876. const children = recursive ? cloneChildren(node.children) : [];
  59877. const clone = new CDATA$1(children);
  59878. children.forEach((child) => (child.parent = clone));
  59879. result = clone;
  59880. }
  59881. else if (isDocument(node)) {
  59882. const children = recursive ? cloneChildren(node.children) : [];
  59883. const clone = new Document(children);
  59884. children.forEach((child) => (child.parent = clone));
  59885. if (node["x-mode"]) {
  59886. clone["x-mode"] = node["x-mode"];
  59887. }
  59888. result = clone;
  59889. }
  59890. else if (isDirective(node)) {
  59891. const instruction = new ProcessingInstruction(node.name, node.data);
  59892. if (node["x-name"] != null) {
  59893. instruction["x-name"] = node["x-name"];
  59894. instruction["x-publicId"] = node["x-publicId"];
  59895. instruction["x-systemId"] = node["x-systemId"];
  59896. }
  59897. result = instruction;
  59898. }
  59899. else {
  59900. throw new Error(`Not implemented yet: ${node.type}`);
  59901. }
  59902. result.startIndex = node.startIndex;
  59903. result.endIndex = node.endIndex;
  59904. if (node.sourceCodeLocation != null) {
  59905. result.sourceCodeLocation = node.sourceCodeLocation;
  59906. }
  59907. return result;
  59908. }
  59909. function cloneChildren(childs) {
  59910. const children = childs.map((child) => cloneNode(child, true));
  59911. for (let i = 1; i < children.length; i++) {
  59912. children[i].prev = children[i - 1];
  59913. children[i - 1].next = children[i];
  59914. }
  59915. return children;
  59916. }
  59917. // Default options
  59918. const defaultOpts$1 = {
  59919. withStartIndices: false,
  59920. withEndIndices: false,
  59921. xmlMode: false,
  59922. };
  59923. class DomHandler {
  59924. /**
  59925. * @param callback Called once parsing has completed.
  59926. * @param options Settings for the handler.
  59927. * @param elementCB Callback whenever a tag is closed.
  59928. */
  59929. constructor(callback, options, elementCB) {
  59930. /** The elements of the DOM */
  59931. this.dom = [];
  59932. /** The root element for the DOM */
  59933. this.root = new Document(this.dom);
  59934. /** Indicated whether parsing has been completed. */
  59935. this.done = false;
  59936. /** Stack of open tags. */
  59937. this.tagStack = [this.root];
  59938. /** A data node that is still being written to. */
  59939. this.lastNode = null;
  59940. /** Reference to the parser instance. Used for location information. */
  59941. this.parser = null;
  59942. // Make it possible to skip arguments, for backwards-compatibility
  59943. if (typeof options === "function") {
  59944. elementCB = options;
  59945. options = defaultOpts$1;
  59946. }
  59947. if (typeof callback === "object") {
  59948. options = callback;
  59949. callback = undefined;
  59950. }
  59951. this.callback = callback !== null && callback !== void 0 ? callback : null;
  59952. this.options = options !== null && options !== void 0 ? options : defaultOpts$1;
  59953. this.elementCB = elementCB !== null && elementCB !== void 0 ? elementCB : null;
  59954. }
  59955. onparserinit(parser) {
  59956. this.parser = parser;
  59957. }
  59958. // Resets the handler back to starting state
  59959. onreset() {
  59960. this.dom = [];
  59961. this.root = new Document(this.dom);
  59962. this.done = false;
  59963. this.tagStack = [this.root];
  59964. this.lastNode = null;
  59965. this.parser = null;
  59966. }
  59967. // Signals the handler that parsing is done
  59968. onend() {
  59969. if (this.done)
  59970. return;
  59971. this.done = true;
  59972. this.parser = null;
  59973. this.handleCallback(null);
  59974. }
  59975. onerror(error) {
  59976. this.handleCallback(error);
  59977. }
  59978. onclosetag() {
  59979. this.lastNode = null;
  59980. const elem = this.tagStack.pop();
  59981. if (this.options.withEndIndices) {
  59982. elem.endIndex = this.parser.endIndex;
  59983. }
  59984. if (this.elementCB)
  59985. this.elementCB(elem);
  59986. }
  59987. onopentag(name, attribs) {
  59988. const type = this.options.xmlMode ? ElementType.Tag : undefined;
  59989. const element = new Element(name, attribs, undefined, type);
  59990. this.addNode(element);
  59991. this.tagStack.push(element);
  59992. }
  59993. ontext(data) {
  59994. const { lastNode } = this;
  59995. if (lastNode && lastNode.type === ElementType.Text) {
  59996. lastNode.data += data;
  59997. if (this.options.withEndIndices) {
  59998. lastNode.endIndex = this.parser.endIndex;
  59999. }
  60000. }
  60001. else {
  60002. const node = new Text$1(data);
  60003. this.addNode(node);
  60004. this.lastNode = node;
  60005. }
  60006. }
  60007. oncomment(data) {
  60008. if (this.lastNode && this.lastNode.type === ElementType.Comment) {
  60009. this.lastNode.data += data;
  60010. return;
  60011. }
  60012. const node = new Comment$1(data);
  60013. this.addNode(node);
  60014. this.lastNode = node;
  60015. }
  60016. oncommentend() {
  60017. this.lastNode = null;
  60018. }
  60019. oncdatastart() {
  60020. const text = new Text$1("");
  60021. const node = new CDATA$1([text]);
  60022. this.addNode(node);
  60023. text.parent = node;
  60024. this.lastNode = text;
  60025. }
  60026. oncdataend() {
  60027. this.lastNode = null;
  60028. }
  60029. onprocessinginstruction(name, data) {
  60030. const node = new ProcessingInstruction(name, data);
  60031. this.addNode(node);
  60032. }
  60033. handleCallback(error) {
  60034. if (typeof this.callback === "function") {
  60035. this.callback(error, this.dom);
  60036. }
  60037. else if (error) {
  60038. throw error;
  60039. }
  60040. }
  60041. addNode(node) {
  60042. const parent = this.tagStack[this.tagStack.length - 1];
  60043. const previousSibling = parent.children[parent.children.length - 1];
  60044. if (this.options.withStartIndices) {
  60045. node.startIndex = this.parser.startIndex;
  60046. }
  60047. if (this.options.withEndIndices) {
  60048. node.endIndex = this.parser.endIndex;
  60049. }
  60050. parent.children.push(node);
  60051. if (previousSibling) {
  60052. node.prev = previousSibling;
  60053. previousSibling.next = node;
  60054. }
  60055. node.parent = parent;
  60056. this.lastNode = null;
  60057. }
  60058. }
  60059. const xmlReplacer = /["&'<>$\x80-\uFFFF]/g;
  60060. const xmlCodeMap = new Map([
  60061. [34, "&quot;"],
  60062. [38, "&amp;"],
  60063. [39, "&apos;"],
  60064. [60, "&lt;"],
  60065. [62, "&gt;"],
  60066. ]);
  60067. // For compatibility with node < 4, we wrap `codePointAt`
  60068. const getCodePoint =
  60069. // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
  60070. String.prototype.codePointAt != null
  60071. ? (str, index) => str.codePointAt(index)
  60072. : // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  60073. (c, index) => (c.charCodeAt(index) & 0xfc00) === 0xd800
  60074. ? (c.charCodeAt(index) - 0xd800) * 0x400 +
  60075. c.charCodeAt(index + 1) -
  60076. 0xdc00 +
  60077. 0x10000
  60078. : c.charCodeAt(index);
  60079. /**
  60080. * Encodes all non-ASCII characters, as well as characters not valid in XML
  60081. * documents using XML entities.
  60082. *
  60083. * If a character has no equivalent entity, a
  60084. * numeric hexadecimal reference (eg. `&#xfc;`) will be used.
  60085. */
  60086. function encodeXML(str) {
  60087. let ret = "";
  60088. let lastIdx = 0;
  60089. let match;
  60090. while ((match = xmlReplacer.exec(str)) !== null) {
  60091. const i = match.index;
  60092. const char = str.charCodeAt(i);
  60093. const next = xmlCodeMap.get(char);
  60094. if (next !== undefined) {
  60095. ret += str.substring(lastIdx, i) + next;
  60096. lastIdx = i + 1;
  60097. }
  60098. else {
  60099. ret += `${str.substring(lastIdx, i)}&#x${getCodePoint(str, i).toString(16)};`;
  60100. // Increase by 1 if we have a surrogate pair
  60101. lastIdx = xmlReplacer.lastIndex += Number((char & 0xfc00) === 0xd800);
  60102. }
  60103. }
  60104. return ret + str.substr(lastIdx);
  60105. }
  60106. function getEscaper(regex, map) {
  60107. return function escape(data) {
  60108. let match;
  60109. let lastIdx = 0;
  60110. let result = "";
  60111. while ((match = regex.exec(data))) {
  60112. if (lastIdx !== match.index) {
  60113. result += data.substring(lastIdx, match.index);
  60114. }
  60115. // We know that this chararcter will be in the map.
  60116. result += map.get(match[0].charCodeAt(0));
  60117. // Every match will be of length 1
  60118. lastIdx = match.index + 1;
  60119. }
  60120. return result + data.substring(lastIdx);
  60121. };
  60122. }
  60123. /**
  60124. * Encodes all characters that have to be escaped in HTML attributes,
  60125. * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
  60126. *
  60127. * @param data String to escape.
  60128. */
  60129. const escapeAttribute = getEscaper(/["&\u00A0]/g, new Map([
  60130. [34, "&quot;"],
  60131. [38, "&amp;"],
  60132. [160, "&nbsp;"],
  60133. ]));
  60134. /**
  60135. * Encodes all characters that have to be escaped in HTML text,
  60136. * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
  60137. *
  60138. * @param data String to escape.
  60139. */
  60140. const escapeText = getEscaper(/[&<>\u00A0]/g, new Map([
  60141. [38, "&amp;"],
  60142. [60, "&lt;"],
  60143. [62, "&gt;"],
  60144. [160, "&nbsp;"],
  60145. ]));
  60146. const elementNames = new Map([
  60147. "altGlyph",
  60148. "altGlyphDef",
  60149. "altGlyphItem",
  60150. "animateColor",
  60151. "animateMotion",
  60152. "animateTransform",
  60153. "clipPath",
  60154. "feBlend",
  60155. "feColorMatrix",
  60156. "feComponentTransfer",
  60157. "feComposite",
  60158. "feConvolveMatrix",
  60159. "feDiffuseLighting",
  60160. "feDisplacementMap",
  60161. "feDistantLight",
  60162. "feDropShadow",
  60163. "feFlood",
  60164. "feFuncA",
  60165. "feFuncB",
  60166. "feFuncG",
  60167. "feFuncR",
  60168. "feGaussianBlur",
  60169. "feImage",
  60170. "feMerge",
  60171. "feMergeNode",
  60172. "feMorphology",
  60173. "feOffset",
  60174. "fePointLight",
  60175. "feSpecularLighting",
  60176. "feSpotLight",
  60177. "feTile",
  60178. "feTurbulence",
  60179. "foreignObject",
  60180. "glyphRef",
  60181. "linearGradient",
  60182. "radialGradient",
  60183. "textPath",
  60184. ].map((val) => [val.toLowerCase(), val]));
  60185. const attributeNames = new Map([
  60186. "definitionURL",
  60187. "attributeName",
  60188. "attributeType",
  60189. "baseFrequency",
  60190. "baseProfile",
  60191. "calcMode",
  60192. "clipPathUnits",
  60193. "diffuseConstant",
  60194. "edgeMode",
  60195. "filterUnits",
  60196. "glyphRef",
  60197. "gradientTransform",
  60198. "gradientUnits",
  60199. "kernelMatrix",
  60200. "kernelUnitLength",
  60201. "keyPoints",
  60202. "keySplines",
  60203. "keyTimes",
  60204. "lengthAdjust",
  60205. "limitingConeAngle",
  60206. "markerHeight",
  60207. "markerUnits",
  60208. "markerWidth",
  60209. "maskContentUnits",
  60210. "maskUnits",
  60211. "numOctaves",
  60212. "pathLength",
  60213. "patternContentUnits",
  60214. "patternTransform",
  60215. "patternUnits",
  60216. "pointsAtX",
  60217. "pointsAtY",
  60218. "pointsAtZ",
  60219. "preserveAlpha",
  60220. "preserveAspectRatio",
  60221. "primitiveUnits",
  60222. "refX",
  60223. "refY",
  60224. "repeatCount",
  60225. "repeatDur",
  60226. "requiredExtensions",
  60227. "requiredFeatures",
  60228. "specularConstant",
  60229. "specularExponent",
  60230. "spreadMethod",
  60231. "startOffset",
  60232. "stdDeviation",
  60233. "stitchTiles",
  60234. "surfaceScale",
  60235. "systemLanguage",
  60236. "tableValues",
  60237. "targetX",
  60238. "targetY",
  60239. "textLength",
  60240. "viewBox",
  60241. "viewTarget",
  60242. "xChannelSelector",
  60243. "yChannelSelector",
  60244. "zoomAndPan",
  60245. ].map((val) => [val.toLowerCase(), val]));
  60246. /*
  60247. * Module dependencies
  60248. */
  60249. const unencodedElements = new Set([
  60250. "style",
  60251. "script",
  60252. "xmp",
  60253. "iframe",
  60254. "noembed",
  60255. "noframes",
  60256. "plaintext",
  60257. "noscript",
  60258. ]);
  60259. function replaceQuotes(value) {
  60260. return value.replace(/"/g, "&quot;");
  60261. }
  60262. /**
  60263. * Format attributes
  60264. */
  60265. function formatAttributes(attributes, opts) {
  60266. var _a;
  60267. if (!attributes)
  60268. return;
  60269. const encode = ((_a = opts.encodeEntities) !== null && _a !== void 0 ? _a : opts.decodeEntities) === false
  60270. ? replaceQuotes
  60271. : opts.xmlMode || opts.encodeEntities !== "utf8"
  60272. ? encodeXML
  60273. : escapeAttribute;
  60274. return Object.keys(attributes)
  60275. .map((key) => {
  60276. var _a, _b;
  60277. const value = (_a = attributes[key]) !== null && _a !== void 0 ? _a : "";
  60278. if (opts.xmlMode === "foreign") {
  60279. /* Fix up mixed-case attribute names */
  60280. key = (_b = attributeNames.get(key)) !== null && _b !== void 0 ? _b : key;
  60281. }
  60282. if (!opts.emptyAttrs && !opts.xmlMode && value === "") {
  60283. return key;
  60284. }
  60285. return `${key}="${encode(value)}"`;
  60286. })
  60287. .join(" ");
  60288. }
  60289. /**
  60290. * Self-enclosing tags
  60291. */
  60292. const singleTag = new Set([
  60293. "area",
  60294. "base",
  60295. "basefont",
  60296. "br",
  60297. "col",
  60298. "command",
  60299. "embed",
  60300. "frame",
  60301. "hr",
  60302. "img",
  60303. "input",
  60304. "isindex",
  60305. "keygen",
  60306. "link",
  60307. "meta",
  60308. "param",
  60309. "source",
  60310. "track",
  60311. "wbr",
  60312. ]);
  60313. /**
  60314. * Renders a DOM node or an array of DOM nodes to a string.
  60315. *
  60316. * Can be thought of as the equivalent of the `outerHTML` of the passed node(s).
  60317. *
  60318. * @param node Node to be rendered.
  60319. * @param options Changes serialization behavior
  60320. */
  60321. function render(node, options = {}) {
  60322. const nodes = "length" in node ? node : [node];
  60323. let output = "";
  60324. for (let i = 0; i < nodes.length; i++) {
  60325. output += renderNode(nodes[i], options);
  60326. }
  60327. return output;
  60328. }
  60329. function renderNode(node, options) {
  60330. switch (node.type) {
  60331. case Root:
  60332. return render(node.children, options);
  60333. // @ts-expect-error We don't use `Doctype` yet
  60334. case Doctype:
  60335. case Directive:
  60336. return renderDirective(node);
  60337. case Comment:
  60338. return renderComment(node);
  60339. case CDATA:
  60340. return renderCdata(node);
  60341. case Script:
  60342. case Style:
  60343. case Tag:
  60344. return renderTag(node, options);
  60345. case Text:
  60346. return renderText(node, options);
  60347. }
  60348. }
  60349. const foreignModeIntegrationPoints = new Set([
  60350. "mi",
  60351. "mo",
  60352. "mn",
  60353. "ms",
  60354. "mtext",
  60355. "annotation-xml",
  60356. "foreignObject",
  60357. "desc",
  60358. "title",
  60359. ]);
  60360. const foreignElements = new Set(["svg", "math"]);
  60361. function renderTag(elem, opts) {
  60362. var _a;
  60363. // Handle SVG / MathML in HTML
  60364. if (opts.xmlMode === "foreign") {
  60365. /* Fix up mixed-case element names */
  60366. elem.name = (_a = elementNames.get(elem.name)) !== null && _a !== void 0 ? _a : elem.name;
  60367. /* Exit foreign mode at integration points */
  60368. if (elem.parent &&
  60369. foreignModeIntegrationPoints.has(elem.parent.name)) {
  60370. opts = { ...opts, xmlMode: false };
  60371. }
  60372. }
  60373. if (!opts.xmlMode && foreignElements.has(elem.name)) {
  60374. opts = { ...opts, xmlMode: "foreign" };
  60375. }
  60376. let tag = `<${elem.name}`;
  60377. const attribs = formatAttributes(elem.attribs, opts);
  60378. if (attribs) {
  60379. tag += ` ${attribs}`;
  60380. }
  60381. if (elem.children.length === 0 &&
  60382. (opts.xmlMode
  60383. ? // In XML mode or foreign mode, and user hasn't explicitly turned off self-closing tags
  60384. opts.selfClosingTags !== false
  60385. : // User explicitly asked for self-closing tags, even in HTML mode
  60386. opts.selfClosingTags && singleTag.has(elem.name))) {
  60387. if (!opts.xmlMode)
  60388. tag += " ";
  60389. tag += "/>";
  60390. }
  60391. else {
  60392. tag += ">";
  60393. if (elem.children.length > 0) {
  60394. tag += render(elem.children, opts);
  60395. }
  60396. if (opts.xmlMode || !singleTag.has(elem.name)) {
  60397. tag += `</${elem.name}>`;
  60398. }
  60399. }
  60400. return tag;
  60401. }
  60402. function renderDirective(elem) {
  60403. return `<${elem.data}>`;
  60404. }
  60405. function renderText(elem, opts) {
  60406. var _a;
  60407. let data = elem.data || "";
  60408. // If entities weren't decoded, no need to encode them back
  60409. if (((_a = opts.encodeEntities) !== null && _a !== void 0 ? _a : opts.decodeEntities) !== false &&
  60410. !(!opts.xmlMode &&
  60411. elem.parent &&
  60412. unencodedElements.has(elem.parent.name))) {
  60413. data =
  60414. opts.xmlMode || opts.encodeEntities !== "utf8"
  60415. ? encodeXML(data)
  60416. : escapeText(data);
  60417. }
  60418. return data;
  60419. }
  60420. function renderCdata(elem) {
  60421. return `<![CDATA[${elem.children[0].data}]]>`;
  60422. }
  60423. function renderComment(elem) {
  60424. return `<!--${elem.data}-->`;
  60425. }
  60426. /**
  60427. * @category Stringify
  60428. * @deprecated Use the `dom-serializer` module directly.
  60429. * @param node Node to get the outer HTML of.
  60430. * @param options Options for serialization.
  60431. * @returns `node`'s outer HTML.
  60432. */
  60433. function getOuterHTML(node, options) {
  60434. return render(node, options);
  60435. }
  60436. /**
  60437. * @category Stringify
  60438. * @deprecated Use the `dom-serializer` module directly.
  60439. * @param node Node to get the inner HTML of.
  60440. * @param options Options for serialization.
  60441. * @returns `node`'s inner HTML.
  60442. */
  60443. function getInnerHTML(node, options) {
  60444. return hasChildren(node)
  60445. ? node.children.map((node) => getOuterHTML(node, options)).join("")
  60446. : "";
  60447. }
  60448. /**
  60449. * Get a node's inner text. Same as `textContent`, but inserts newlines for `<br>` tags.
  60450. *
  60451. * @category Stringify
  60452. * @deprecated Use `textContent` instead.
  60453. * @param node Node to get the inner text of.
  60454. * @returns `node`'s inner text.
  60455. */
  60456. function getText(node) {
  60457. if (Array.isArray(node))
  60458. return node.map(getText).join("");
  60459. if (isTag$1(node))
  60460. return node.name === "br" ? "\n" : getText(node.children);
  60461. if (isCDATA(node))
  60462. return getText(node.children);
  60463. if (isText(node))
  60464. return node.data;
  60465. return "";
  60466. }
  60467. /**
  60468. * Get a node's text content.
  60469. *
  60470. * @category Stringify
  60471. * @param node Node to get the text content of.
  60472. * @returns `node`'s text content.
  60473. * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent}
  60474. */
  60475. function textContent(node) {
  60476. if (Array.isArray(node))
  60477. return node.map(textContent).join("");
  60478. if (hasChildren(node) && !isComment(node)) {
  60479. return textContent(node.children);
  60480. }
  60481. if (isText(node))
  60482. return node.data;
  60483. return "";
  60484. }
  60485. /**
  60486. * Get a node's inner text.
  60487. *
  60488. * @category Stringify
  60489. * @param node Node to get the inner text of.
  60490. * @returns `node`'s inner text.
  60491. * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/innerText}
  60492. */
  60493. function innerText(node) {
  60494. if (Array.isArray(node))
  60495. return node.map(innerText).join("");
  60496. if (hasChildren(node) && (node.type === ElementType.Tag || isCDATA(node))) {
  60497. return innerText(node.children);
  60498. }
  60499. if (isText(node))
  60500. return node.data;
  60501. return "";
  60502. }
  60503. /**
  60504. * Get a node's children.
  60505. *
  60506. * @category Traversal
  60507. * @param elem Node to get the children of.
  60508. * @returns `elem`'s children, or an empty array.
  60509. */
  60510. function getChildren(elem) {
  60511. return hasChildren(elem) ? elem.children : [];
  60512. }
  60513. /**
  60514. * Get a node's parent.
  60515. *
  60516. * @category Traversal
  60517. * @param elem Node to get the parent of.
  60518. * @returns `elem`'s parent node.
  60519. */
  60520. function getParent(elem) {
  60521. return elem.parent || null;
  60522. }
  60523. /**
  60524. * Gets an elements siblings, including the element itself.
  60525. *
  60526. * Attempts to get the children through the element's parent first. If we don't
  60527. * have a parent (the element is a root node), we walk the element's `prev` &
  60528. * `next` to get all remaining nodes.
  60529. *
  60530. * @category Traversal
  60531. * @param elem Element to get the siblings of.
  60532. * @returns `elem`'s siblings.
  60533. */
  60534. function getSiblings(elem) {
  60535. const parent = getParent(elem);
  60536. if (parent != null)
  60537. return getChildren(parent);
  60538. const siblings = [elem];
  60539. let { prev, next } = elem;
  60540. while (prev != null) {
  60541. siblings.unshift(prev);
  60542. ({ prev } = prev);
  60543. }
  60544. while (next != null) {
  60545. siblings.push(next);
  60546. ({ next } = next);
  60547. }
  60548. return siblings;
  60549. }
  60550. /**
  60551. * Gets an attribute from an element.
  60552. *
  60553. * @category Traversal
  60554. * @param elem Element to check.
  60555. * @param name Attribute name to retrieve.
  60556. * @returns The element's attribute value, or `undefined`.
  60557. */
  60558. function getAttributeValue(elem, name) {
  60559. var _a;
  60560. return (_a = elem.attribs) === null || _a === void 0 ? void 0 : _a[name];
  60561. }
  60562. /**
  60563. * Checks whether an element has an attribute.
  60564. *
  60565. * @category Traversal
  60566. * @param elem Element to check.
  60567. * @param name Attribute name to look for.
  60568. * @returns Returns whether `elem` has the attribute `name`.
  60569. */
  60570. function hasAttrib(elem, name) {
  60571. return (elem.attribs != null &&
  60572. Object.prototype.hasOwnProperty.call(elem.attribs, name) &&
  60573. elem.attribs[name] != null);
  60574. }
  60575. /**
  60576. * Get the tag name of an element.
  60577. *
  60578. * @category Traversal
  60579. * @param elem The element to get the name for.
  60580. * @returns The tag name of `elem`.
  60581. */
  60582. function getName(elem) {
  60583. return elem.name;
  60584. }
  60585. /**
  60586. * Returns the next element sibling of a node.
  60587. *
  60588. * @category Traversal
  60589. * @param elem The element to get the next sibling of.
  60590. * @returns `elem`'s next sibling that is a tag.
  60591. */
  60592. function nextElementSibling(elem) {
  60593. let { next } = elem;
  60594. while (next !== null && !isTag$1(next))
  60595. ({ next } = next);
  60596. return next;
  60597. }
  60598. /**
  60599. * Returns the previous element sibling of a node.
  60600. *
  60601. * @category Traversal
  60602. * @param elem The element to get the previous sibling of.
  60603. * @returns `elem`'s previous sibling that is a tag.
  60604. */
  60605. function prevElementSibling(elem) {
  60606. let { prev } = elem;
  60607. while (prev !== null && !isTag$1(prev))
  60608. ({ prev } = prev);
  60609. return prev;
  60610. }
  60611. /**
  60612. * Remove an element from the dom
  60613. *
  60614. * @category Manipulation
  60615. * @param elem The element to be removed
  60616. */
  60617. function removeElement(elem) {
  60618. if (elem.prev)
  60619. elem.prev.next = elem.next;
  60620. if (elem.next)
  60621. elem.next.prev = elem.prev;
  60622. if (elem.parent) {
  60623. const childs = elem.parent.children;
  60624. childs.splice(childs.lastIndexOf(elem), 1);
  60625. }
  60626. }
  60627. /**
  60628. * Replace an element in the dom
  60629. *
  60630. * @category Manipulation
  60631. * @param elem The element to be replaced
  60632. * @param replacement The element to be added
  60633. */
  60634. function replaceElement(elem, replacement) {
  60635. const prev = (replacement.prev = elem.prev);
  60636. if (prev) {
  60637. prev.next = replacement;
  60638. }
  60639. const next = (replacement.next = elem.next);
  60640. if (next) {
  60641. next.prev = replacement;
  60642. }
  60643. const parent = (replacement.parent = elem.parent);
  60644. if (parent) {
  60645. const childs = parent.children;
  60646. childs[childs.lastIndexOf(elem)] = replacement;
  60647. elem.parent = null;
  60648. }
  60649. }
  60650. /**
  60651. * Append a child to an element.
  60652. *
  60653. * @category Manipulation
  60654. * @param elem The element to append to.
  60655. * @param child The element to be added as a child.
  60656. */
  60657. function appendChild(elem, child) {
  60658. removeElement(child);
  60659. child.next = null;
  60660. child.parent = elem;
  60661. if (elem.children.push(child) > 1) {
  60662. const sibling = elem.children[elem.children.length - 2];
  60663. sibling.next = child;
  60664. child.prev = sibling;
  60665. }
  60666. else {
  60667. child.prev = null;
  60668. }
  60669. }
  60670. /**
  60671. * Append an element after another.
  60672. *
  60673. * @category Manipulation
  60674. * @param elem The element to append after.
  60675. * @param next The element be added.
  60676. */
  60677. function append(elem, next) {
  60678. removeElement(next);
  60679. const { parent } = elem;
  60680. const currNext = elem.next;
  60681. next.next = currNext;
  60682. next.prev = elem;
  60683. elem.next = next;
  60684. next.parent = parent;
  60685. if (currNext) {
  60686. currNext.prev = next;
  60687. if (parent) {
  60688. const childs = parent.children;
  60689. childs.splice(childs.lastIndexOf(currNext), 0, next);
  60690. }
  60691. }
  60692. else if (parent) {
  60693. parent.children.push(next);
  60694. }
  60695. }
  60696. /**
  60697. * Prepend a child to an element.
  60698. *
  60699. * @category Manipulation
  60700. * @param elem The element to prepend before.
  60701. * @param child The element to be added as a child.
  60702. */
  60703. function prependChild(elem, child) {
  60704. removeElement(child);
  60705. child.parent = elem;
  60706. child.prev = null;
  60707. if (elem.children.unshift(child) !== 1) {
  60708. const sibling = elem.children[1];
  60709. sibling.prev = child;
  60710. child.next = sibling;
  60711. }
  60712. else {
  60713. child.next = null;
  60714. }
  60715. }
  60716. /**
  60717. * Prepend an element before another.
  60718. *
  60719. * @category Manipulation
  60720. * @param elem The element to prepend before.
  60721. * @param prev The element be added.
  60722. */
  60723. function prepend(elem, prev) {
  60724. removeElement(prev);
  60725. const { parent } = elem;
  60726. if (parent) {
  60727. const childs = parent.children;
  60728. childs.splice(childs.indexOf(elem), 0, prev);
  60729. }
  60730. if (elem.prev) {
  60731. elem.prev.next = prev;
  60732. }
  60733. prev.parent = parent;
  60734. prev.prev = elem.prev;
  60735. prev.next = elem;
  60736. elem.prev = prev;
  60737. }
  60738. /**
  60739. * Search a node and its children for nodes passing a test function.
  60740. *
  60741. * @category Querying
  60742. * @param test Function to test nodes on.
  60743. * @param node Node to search. Will be included in the result set if it matches.
  60744. * @param recurse Also consider child nodes.
  60745. * @param limit Maximum number of nodes to return.
  60746. * @returns All nodes passing `test`.
  60747. */
  60748. function filter$4(test, node, recurse = true, limit = Infinity) {
  60749. if (!Array.isArray(node))
  60750. node = [node];
  60751. return find$5(test, node, recurse, limit);
  60752. }
  60753. /**
  60754. * Search an array of node and its children for nodes passing a test function.
  60755. *
  60756. * @category Querying
  60757. * @param test Function to test nodes on.
  60758. * @param nodes Array of nodes to search.
  60759. * @param recurse Also consider child nodes.
  60760. * @param limit Maximum number of nodes to return.
  60761. * @returns All nodes passing `test`.
  60762. */
  60763. function find$5(test, nodes, recurse, limit) {
  60764. const result = [];
  60765. for (const elem of nodes) {
  60766. if (test(elem)) {
  60767. result.push(elem);
  60768. if (--limit <= 0)
  60769. break;
  60770. }
  60771. if (recurse && hasChildren(elem) && elem.children.length > 0) {
  60772. const children = find$5(test, elem.children, recurse, limit);
  60773. result.push(...children);
  60774. limit -= children.length;
  60775. if (limit <= 0)
  60776. break;
  60777. }
  60778. }
  60779. return result;
  60780. }
  60781. /**
  60782. * Finds the first element inside of an array that matches a test function.
  60783. *
  60784. * @category Querying
  60785. * @param test Function to test nodes on.
  60786. * @param nodes Array of nodes to search.
  60787. * @returns The first node in the array that passes `test`.
  60788. * @deprecated Use `Array.prototype.find` directly.
  60789. */
  60790. function findOneChild(test, nodes) {
  60791. return nodes.find(test);
  60792. }
  60793. /**
  60794. * Finds one element in a tree that passes a test.
  60795. *
  60796. * @category Querying
  60797. * @param test Function to test nodes on.
  60798. * @param nodes Array of nodes to search.
  60799. * @param recurse Also consider child nodes.
  60800. * @returns The first child node that passes `test`.
  60801. */
  60802. function findOne(test, nodes, recurse = true) {
  60803. let elem = null;
  60804. for (let i = 0; i < nodes.length && !elem; i++) {
  60805. const checked = nodes[i];
  60806. if (!isTag$1(checked)) {
  60807. continue;
  60808. }
  60809. else if (test(checked)) {
  60810. elem = checked;
  60811. }
  60812. else if (recurse && checked.children.length > 0) {
  60813. elem = findOne(test, checked.children, true);
  60814. }
  60815. }
  60816. return elem;
  60817. }
  60818. /**
  60819. * @category Querying
  60820. * @param test Function to test nodes on.
  60821. * @param nodes Array of nodes to search.
  60822. * @returns Whether a tree of nodes contains at least one node passing the test.
  60823. */
  60824. function existsOne(test, nodes) {
  60825. return nodes.some((checked) => isTag$1(checked) &&
  60826. (test(checked) ||
  60827. (checked.children.length > 0 &&
  60828. existsOne(test, checked.children))));
  60829. }
  60830. /**
  60831. * Search and array of nodes and its children for elements passing a test function.
  60832. *
  60833. * Same as `find`, but limited to elements and with less options, leading to reduced complexity.
  60834. *
  60835. * @category Querying
  60836. * @param test Function to test nodes on.
  60837. * @param nodes Array of nodes to search.
  60838. * @returns All nodes passing `test`.
  60839. */
  60840. function findAll(test, nodes) {
  60841. var _a;
  60842. const result = [];
  60843. const stack = nodes.filter(isTag$1);
  60844. let elem;
  60845. while ((elem = stack.shift())) {
  60846. const children = (_a = elem.children) === null || _a === void 0 ? void 0 : _a.filter(isTag$1);
  60847. if (children && children.length > 0) {
  60848. stack.unshift(...children);
  60849. }
  60850. if (test(elem))
  60851. result.push(elem);
  60852. }
  60853. return result;
  60854. }
  60855. const Checks = {
  60856. tag_name(name) {
  60857. if (typeof name === "function") {
  60858. return (elem) => isTag$1(elem) && name(elem.name);
  60859. }
  60860. else if (name === "*") {
  60861. return isTag$1;
  60862. }
  60863. return (elem) => isTag$1(elem) && elem.name === name;
  60864. },
  60865. tag_type(type) {
  60866. if (typeof type === "function") {
  60867. return (elem) => type(elem.type);
  60868. }
  60869. return (elem) => elem.type === type;
  60870. },
  60871. tag_contains(data) {
  60872. if (typeof data === "function") {
  60873. return (elem) => isText(elem) && data(elem.data);
  60874. }
  60875. return (elem) => isText(elem) && elem.data === data;
  60876. },
  60877. };
  60878. /**
  60879. * @param attrib Attribute to check.
  60880. * @param value Attribute value to look for.
  60881. * @returns A function to check whether the a node has an attribute with a
  60882. * particular value.
  60883. */
  60884. function getAttribCheck(attrib, value) {
  60885. if (typeof value === "function") {
  60886. return (elem) => isTag$1(elem) && value(elem.attribs[attrib]);
  60887. }
  60888. return (elem) => isTag$1(elem) && elem.attribs[attrib] === value;
  60889. }
  60890. /**
  60891. * @param a First function to combine.
  60892. * @param b Second function to combine.
  60893. * @returns A function taking a node and returning `true` if either of the input
  60894. * functions returns `true` for the node.
  60895. */
  60896. function combineFuncs(a, b) {
  60897. return (elem) => a(elem) || b(elem);
  60898. }
  60899. /**
  60900. * @param options An object describing nodes to look for.
  60901. * @returns A function executing all checks in `options` and returning `true` if
  60902. * any of them match a node.
  60903. */
  60904. function compileTest(options) {
  60905. const funcs = Object.keys(options).map((key) => {
  60906. const value = options[key];
  60907. return Object.prototype.hasOwnProperty.call(Checks, key)
  60908. ? Checks[key](value)
  60909. : getAttribCheck(key, value);
  60910. });
  60911. return funcs.length === 0 ? null : funcs.reduce(combineFuncs);
  60912. }
  60913. /**
  60914. * @category Legacy Query Functions
  60915. * @param options An object describing nodes to look for.
  60916. * @param node The element to test.
  60917. * @returns Whether the element matches the description in `options`.
  60918. */
  60919. function testElement(options, node) {
  60920. const test = compileTest(options);
  60921. return test ? test(node) : true;
  60922. }
  60923. /**
  60924. * @category Legacy Query Functions
  60925. * @param options An object describing nodes to look for.
  60926. * @param nodes Nodes to search through.
  60927. * @param recurse Also consider child nodes.
  60928. * @param limit Maximum number of nodes to return.
  60929. * @returns All nodes that match `options`.
  60930. */
  60931. function getElements(options, nodes, recurse, limit = Infinity) {
  60932. const test = compileTest(options);
  60933. return test ? filter$4(test, nodes, recurse, limit) : [];
  60934. }
  60935. /**
  60936. * @category Legacy Query Functions
  60937. * @param id The unique ID attribute value to look for.
  60938. * @param nodes Nodes to search through.
  60939. * @param recurse Also consider child nodes.
  60940. * @returns The node with the supplied ID.
  60941. */
  60942. function getElementById(id, nodes, recurse = true) {
  60943. if (!Array.isArray(nodes))
  60944. nodes = [nodes];
  60945. return findOne(getAttribCheck("id", id), nodes, recurse);
  60946. }
  60947. /**
  60948. * @category Legacy Query Functions
  60949. * @param tagName Tag name to search for.
  60950. * @param nodes Nodes to search through.
  60951. * @param recurse Also consider child nodes.
  60952. * @param limit Maximum number of nodes to return.
  60953. * @returns All nodes with the supplied `tagName`.
  60954. */
  60955. function getElementsByTagName(tagName, nodes, recurse = true, limit = Infinity) {
  60956. return filter$4(Checks["tag_name"](tagName), nodes, recurse, limit);
  60957. }
  60958. /**
  60959. * @category Legacy Query Functions
  60960. * @param type Element type to look for.
  60961. * @param nodes Nodes to search through.
  60962. * @param recurse Also consider child nodes.
  60963. * @param limit Maximum number of nodes to return.
  60964. * @returns All nodes with the supplied `type`.
  60965. */
  60966. function getElementsByTagType(type, nodes, recurse = true, limit = Infinity) {
  60967. return filter$4(Checks["tag_type"](type), nodes, recurse, limit);
  60968. }
  60969. /**
  60970. * Given an array of nodes, remove any member that is contained by another.
  60971. *
  60972. * @category Helpers
  60973. * @param nodes Nodes to filter.
  60974. * @returns Remaining nodes that aren't subtrees of each other.
  60975. */
  60976. function removeSubsets(nodes) {
  60977. let idx = nodes.length;
  60978. /*
  60979. * Check if each node (or one of its ancestors) is already contained in the
  60980. * array.
  60981. */
  60982. while (--idx >= 0) {
  60983. const node = nodes[idx];
  60984. /*
  60985. * Remove the node if it is not unique.
  60986. * We are going through the array from the end, so we only
  60987. * have to check nodes that preceed the node under consideration in the array.
  60988. */
  60989. if (idx > 0 && nodes.lastIndexOf(node, idx - 1) >= 0) {
  60990. nodes.splice(idx, 1);
  60991. continue;
  60992. }
  60993. for (let ancestor = node.parent; ancestor; ancestor = ancestor.parent) {
  60994. if (nodes.includes(ancestor)) {
  60995. nodes.splice(idx, 1);
  60996. break;
  60997. }
  60998. }
  60999. }
  61000. return nodes;
  61001. }
  61002. /**
  61003. * @category Helpers
  61004. * @see {@link http://dom.spec.whatwg.org/#dom-node-comparedocumentposition}
  61005. */
  61006. var DocumentPosition;
  61007. (function (DocumentPosition) {
  61008. DocumentPosition[DocumentPosition["DISCONNECTED"] = 1] = "DISCONNECTED";
  61009. DocumentPosition[DocumentPosition["PRECEDING"] = 2] = "PRECEDING";
  61010. DocumentPosition[DocumentPosition["FOLLOWING"] = 4] = "FOLLOWING";
  61011. DocumentPosition[DocumentPosition["CONTAINS"] = 8] = "CONTAINS";
  61012. DocumentPosition[DocumentPosition["CONTAINED_BY"] = 16] = "CONTAINED_BY";
  61013. })(DocumentPosition || (DocumentPosition = {}));
  61014. /**
  61015. * Compare the position of one node against another node in any other document.
  61016. * The return value is a bitmask with the values from {@link DocumentPosition}.
  61017. *
  61018. * Document order:
  61019. * > There is an ordering, document order, defined on all the nodes in the
  61020. * > document corresponding to the order in which the first character of the
  61021. * > XML representation of each node occurs in the XML representation of the
  61022. * > document after expansion of general entities. Thus, the document element
  61023. * > node will be the first node. Element nodes occur before their children.
  61024. * > Thus, document order orders element nodes in order of the occurrence of
  61025. * > their start-tag in the XML (after expansion of entities). The attribute
  61026. * > nodes of an element occur after the element and before its children. The
  61027. * > relative order of attribute nodes is implementation-dependent.
  61028. *
  61029. * Source:
  61030. * http://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-document-order
  61031. *
  61032. * @category Helpers
  61033. * @param nodeA The first node to use in the comparison
  61034. * @param nodeB The second node to use in the comparison
  61035. * @returns A bitmask describing the input nodes' relative position.
  61036. *
  61037. * See http://dom.spec.whatwg.org/#dom-node-comparedocumentposition for
  61038. * a description of these values.
  61039. */
  61040. function compareDocumentPosition(nodeA, nodeB) {
  61041. const aParents = [];
  61042. const bParents = [];
  61043. if (nodeA === nodeB) {
  61044. return 0;
  61045. }
  61046. let current = hasChildren(nodeA) ? nodeA : nodeA.parent;
  61047. while (current) {
  61048. aParents.unshift(current);
  61049. current = current.parent;
  61050. }
  61051. current = hasChildren(nodeB) ? nodeB : nodeB.parent;
  61052. while (current) {
  61053. bParents.unshift(current);
  61054. current = current.parent;
  61055. }
  61056. const maxIdx = Math.min(aParents.length, bParents.length);
  61057. let idx = 0;
  61058. while (idx < maxIdx && aParents[idx] === bParents[idx]) {
  61059. idx++;
  61060. }
  61061. if (idx === 0) {
  61062. return DocumentPosition.DISCONNECTED;
  61063. }
  61064. const sharedParent = aParents[idx - 1];
  61065. const siblings = sharedParent.children;
  61066. const aSibling = aParents[idx];
  61067. const bSibling = bParents[idx];
  61068. if (siblings.indexOf(aSibling) > siblings.indexOf(bSibling)) {
  61069. if (sharedParent === nodeB) {
  61070. return DocumentPosition.FOLLOWING | DocumentPosition.CONTAINED_BY;
  61071. }
  61072. return DocumentPosition.FOLLOWING;
  61073. }
  61074. if (sharedParent === nodeA) {
  61075. return DocumentPosition.PRECEDING | DocumentPosition.CONTAINS;
  61076. }
  61077. return DocumentPosition.PRECEDING;
  61078. }
  61079. /**
  61080. * Sort an array of nodes based on their relative position in the document and
  61081. * remove any duplicate nodes. If the array contains nodes that do not belong to
  61082. * the same document, sort order is unspecified.
  61083. *
  61084. * @category Helpers
  61085. * @param nodes Array of DOM nodes.
  61086. * @returns Collection of unique nodes, sorted in document order.
  61087. */
  61088. function uniqueSort(nodes) {
  61089. nodes = nodes.filter((node, i, arr) => !arr.includes(node, i + 1));
  61090. nodes.sort((a, b) => {
  61091. const relative = compareDocumentPosition(a, b);
  61092. if (relative & DocumentPosition.PRECEDING) {
  61093. return -1;
  61094. }
  61095. else if (relative & DocumentPosition.FOLLOWING) {
  61096. return 1;
  61097. }
  61098. return 0;
  61099. });
  61100. return nodes;
  61101. }
  61102. /**
  61103. * Get the feed object from the root of a DOM tree.
  61104. *
  61105. * @category Feeds
  61106. * @param doc - The DOM to to extract the feed from.
  61107. * @returns The feed.
  61108. */
  61109. function getFeed(doc) {
  61110. const feedRoot = getOneElement(isValidFeed, doc);
  61111. return !feedRoot
  61112. ? null
  61113. : feedRoot.name === "feed"
  61114. ? getAtomFeed(feedRoot)
  61115. : getRssFeed(feedRoot);
  61116. }
  61117. /**
  61118. * Parse an Atom feed.
  61119. *
  61120. * @param feedRoot The root of the feed.
  61121. * @returns The parsed feed.
  61122. */
  61123. function getAtomFeed(feedRoot) {
  61124. var _a;
  61125. const childs = feedRoot.children;
  61126. const feed = {
  61127. type: "atom",
  61128. items: getElementsByTagName("entry", childs).map((item) => {
  61129. var _a;
  61130. const { children } = item;
  61131. const entry = { media: getMediaElements(children) };
  61132. addConditionally(entry, "id", "id", children);
  61133. addConditionally(entry, "title", "title", children);
  61134. const href = (_a = getOneElement("link", children)) === null || _a === void 0 ? void 0 : _a.attribs["href"];
  61135. if (href) {
  61136. entry.link = href;
  61137. }
  61138. const description = fetch$1("summary", children) || fetch$1("content", children);
  61139. if (description) {
  61140. entry.description = description;
  61141. }
  61142. const pubDate = fetch$1("updated", children);
  61143. if (pubDate) {
  61144. entry.pubDate = new Date(pubDate);
  61145. }
  61146. return entry;
  61147. }),
  61148. };
  61149. addConditionally(feed, "id", "id", childs);
  61150. addConditionally(feed, "title", "title", childs);
  61151. const href = (_a = getOneElement("link", childs)) === null || _a === void 0 ? void 0 : _a.attribs["href"];
  61152. if (href) {
  61153. feed.link = href;
  61154. }
  61155. addConditionally(feed, "description", "subtitle", childs);
  61156. const updated = fetch$1("updated", childs);
  61157. if (updated) {
  61158. feed.updated = new Date(updated);
  61159. }
  61160. addConditionally(feed, "author", "email", childs, true);
  61161. return feed;
  61162. }
  61163. /**
  61164. * Parse a RSS feed.
  61165. *
  61166. * @param feedRoot The root of the feed.
  61167. * @returns The parsed feed.
  61168. */
  61169. function getRssFeed(feedRoot) {
  61170. var _a, _b;
  61171. const childs = (_b = (_a = getOneElement("channel", feedRoot.children)) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : [];
  61172. const feed = {
  61173. type: feedRoot.name.substr(0, 3),
  61174. id: "",
  61175. items: getElementsByTagName("item", feedRoot.children).map((item) => {
  61176. const { children } = item;
  61177. const entry = { media: getMediaElements(children) };
  61178. addConditionally(entry, "id", "guid", children);
  61179. addConditionally(entry, "title", "title", children);
  61180. addConditionally(entry, "link", "link", children);
  61181. addConditionally(entry, "description", "description", children);
  61182. const pubDate = fetch$1("pubDate", children);
  61183. if (pubDate)
  61184. entry.pubDate = new Date(pubDate);
  61185. return entry;
  61186. }),
  61187. };
  61188. addConditionally(feed, "title", "title", childs);
  61189. addConditionally(feed, "link", "link", childs);
  61190. addConditionally(feed, "description", "description", childs);
  61191. const updated = fetch$1("lastBuildDate", childs);
  61192. if (updated) {
  61193. feed.updated = new Date(updated);
  61194. }
  61195. addConditionally(feed, "author", "managingEditor", childs, true);
  61196. return feed;
  61197. }
  61198. const MEDIA_KEYS_STRING = ["url", "type", "lang"];
  61199. const MEDIA_KEYS_INT = [
  61200. "fileSize",
  61201. "bitrate",
  61202. "framerate",
  61203. "samplingrate",
  61204. "channels",
  61205. "duration",
  61206. "height",
  61207. "width",
  61208. ];
  61209. /**
  61210. * Get all media elements of a feed item.
  61211. *
  61212. * @param where Nodes to search in.
  61213. * @returns Media elements.
  61214. */
  61215. function getMediaElements(where) {
  61216. return getElementsByTagName("media:content", where).map((elem) => {
  61217. const { attribs } = elem;
  61218. const media = {
  61219. medium: attribs["medium"],
  61220. isDefault: !!attribs["isDefault"],
  61221. };
  61222. for (const attrib of MEDIA_KEYS_STRING) {
  61223. if (attribs[attrib]) {
  61224. media[attrib] = attribs[attrib];
  61225. }
  61226. }
  61227. for (const attrib of MEDIA_KEYS_INT) {
  61228. if (attribs[attrib]) {
  61229. media[attrib] = parseInt(attribs[attrib], 10);
  61230. }
  61231. }
  61232. if (attribs["expression"]) {
  61233. media.expression = attribs["expression"];
  61234. }
  61235. return media;
  61236. });
  61237. }
  61238. /**
  61239. * Get one element by tag name.
  61240. *
  61241. * @param tagName Tag name to look for
  61242. * @param node Node to search in
  61243. * @returns The element or null
  61244. */
  61245. function getOneElement(tagName, node) {
  61246. return getElementsByTagName(tagName, node, true, 1)[0];
  61247. }
  61248. /**
  61249. * Get the text content of an element with a certain tag name.
  61250. *
  61251. * @param tagName Tag name to look for.
  61252. * @param where Node to search in.
  61253. * @param recurse Whether to recurse into child nodes.
  61254. * @returns The text content of the element.
  61255. */
  61256. function fetch$1(tagName, where, recurse = false) {
  61257. return textContent(getElementsByTagName(tagName, where, recurse, 1)).trim();
  61258. }
  61259. /**
  61260. * Adds a property to an object if it has a value.
  61261. *
  61262. * @param obj Object to be extended
  61263. * @param prop Property name
  61264. * @param tagName Tag name that contains the conditionally added property
  61265. * @param where Element to search for the property
  61266. * @param recurse Whether to recurse into child nodes.
  61267. */
  61268. function addConditionally(obj, prop, tagName, where, recurse = false) {
  61269. const val = fetch$1(tagName, where, recurse);
  61270. if (val)
  61271. obj[prop] = val;
  61272. }
  61273. /**
  61274. * Checks if an element is a feed root node.
  61275. *
  61276. * @param value The name of the element to check.
  61277. * @returns Whether an element is a feed root node.
  61278. */
  61279. function isValidFeed(value) {
  61280. return value === "rss" || value === "feed" || value === "rdf:RDF";
  61281. }
  61282. var DomUtils = /*#__PURE__*/Object.freeze({
  61283. __proto__: null,
  61284. isTag: isTag$1,
  61285. isCDATA: isCDATA,
  61286. isText: isText,
  61287. isComment: isComment,
  61288. isDocument: isDocument,
  61289. hasChildren: hasChildren,
  61290. getOuterHTML: getOuterHTML,
  61291. getInnerHTML: getInnerHTML,
  61292. getText: getText,
  61293. textContent: textContent,
  61294. innerText: innerText,
  61295. getChildren: getChildren,
  61296. getParent: getParent,
  61297. getSiblings: getSiblings,
  61298. getAttributeValue: getAttributeValue,
  61299. hasAttrib: hasAttrib,
  61300. getName: getName,
  61301. nextElementSibling: nextElementSibling,
  61302. prevElementSibling: prevElementSibling,
  61303. removeElement: removeElement,
  61304. replaceElement: replaceElement,
  61305. appendChild: appendChild,
  61306. append: append,
  61307. prependChild: prependChild,
  61308. prepend: prepend,
  61309. filter: filter$4,
  61310. find: find$5,
  61311. findOneChild: findOneChild,
  61312. findOne: findOne,
  61313. existsOne: existsOne,
  61314. findAll: findAll,
  61315. testElement: testElement,
  61316. getElements: getElements,
  61317. getElementById: getElementById,
  61318. getElementsByTagName: getElementsByTagName,
  61319. getElementsByTagType: getElementsByTagType,
  61320. removeSubsets: removeSubsets,
  61321. get DocumentPosition () { return DocumentPosition; },
  61322. compareDocumentPosition: compareDocumentPosition,
  61323. uniqueSort: uniqueSort,
  61324. getFeed: getFeed
  61325. });
  61326. /**
  61327. * Helper function to render a DOM.
  61328. *
  61329. * @param that - Cheerio instance to render.
  61330. * @param dom - The DOM to render. Defaults to `that`'s root.
  61331. * @param options - Options for rendering.
  61332. * @returns The rendered document.
  61333. */
  61334. function render$1(that, dom, options) {
  61335. if (!that)
  61336. return '';
  61337. return that(dom !== null && dom !== void 0 ? dom : that._root.children, null, undefined, options).toString();
  61338. }
  61339. /**
  61340. * Checks if a passed object is an options object.
  61341. *
  61342. * @param dom - Object to check if it is an options object.
  61343. * @returns Whether the object is an options object.
  61344. */
  61345. function isOptions(dom, options) {
  61346. return (!options &&
  61347. typeof dom === 'object' &&
  61348. dom != null &&
  61349. !('length' in dom) &&
  61350. !('type' in dom));
  61351. }
  61352. function html$1(dom, options) {
  61353. /*
  61354. * Be flexible about parameters, sometimes we call html(),
  61355. * with options as only parameter
  61356. * check dom argument for dom element specific properties
  61357. * assume there is no 'length' or 'type' properties in the options object
  61358. */
  61359. const toRender = isOptions(dom) ? ((options = dom), undefined) : dom;
  61360. /*
  61361. * Sometimes `$.html()` is used without preloading html,
  61362. * so fallback non-existing options to the default ones.
  61363. */
  61364. const opts = {
  61365. ...defaultOpts,
  61366. ...this === null || this === void 0 ? void 0 : this._options,
  61367. ...flatten(options !== null && options !== void 0 ? options : {}),
  61368. };
  61369. return render$1(this, toRender, opts);
  61370. }
  61371. /**
  61372. * Render the document as XML.
  61373. *
  61374. * @param dom - Element to render.
  61375. * @returns THe rendered document.
  61376. */
  61377. function xml$1(dom) {
  61378. const options = { ...this._options, xmlMode: true };
  61379. return render$1(this, dom, options);
  61380. }
  61381. /**
  61382. * Render the document as text.
  61383. *
  61384. * This returns the `textContent` of the passed elements. The result will
  61385. * include the contents of `script` and `stype` elements. To avoid this, use
  61386. * `.prop('innerText')` instead.
  61387. *
  61388. * @param elements - Elements to render.
  61389. * @returns The rendered document.
  61390. */
  61391. function text(elements) {
  61392. const elems = elements ? elements : this ? this.root() : [];
  61393. let ret = '';
  61394. for (let i = 0; i < elems.length; i++) {
  61395. ret += textContent(elems[i]);
  61396. }
  61397. return ret;
  61398. }
  61399. function parseHTML(data, context, keepScripts = typeof context === 'boolean' ? context : false) {
  61400. if (!data || typeof data !== 'string') {
  61401. return null;
  61402. }
  61403. if (typeof context === 'boolean') {
  61404. keepScripts = context;
  61405. }
  61406. const parsed = this.load(data, defaultOpts, false);
  61407. if (!keepScripts) {
  61408. parsed('script').remove();
  61409. }
  61410. /*
  61411. * The `children` array is used by Cheerio internally to group elements that
  61412. * share the same parents. When nodes created through `parseHTML` are
  61413. * inserted into previously-existing DOM structures, they will be removed
  61414. * from the `children` array. The results of `parseHTML` should remain
  61415. * constant across these operations, so a shallow copy should be returned.
  61416. */
  61417. return parsed.root()[0].children.slice();
  61418. }
  61419. /**
  61420. * Sometimes you need to work with the top-level root element. To query it, you
  61421. * can use `$.root()`.
  61422. *
  61423. * @example
  61424. *
  61425. * ```js
  61426. * $.root().append('<ul id="vegetables"></ul>').html();
  61427. * //=> <ul id="fruits">...</ul><ul id="vegetables"></ul>
  61428. * ```
  61429. *
  61430. * @returns Cheerio instance wrapping the root node.
  61431. * @alias Cheerio.root
  61432. */
  61433. function root$2() {
  61434. return this(this._root);
  61435. }
  61436. /**
  61437. * Checks to see if the `contained` DOM element is a descendant of the
  61438. * `container` DOM element.
  61439. *
  61440. * @param container - Potential parent node.
  61441. * @param contained - Potential child node.
  61442. * @returns Indicates if the nodes contain one another.
  61443. * @alias Cheerio.contains
  61444. * @see {@link https://api.jquery.com/jQuery.contains/}
  61445. */
  61446. function contains(container, contained) {
  61447. // According to the jQuery API, an element does not "contain" itself
  61448. if (contained === container) {
  61449. return false;
  61450. }
  61451. /*
  61452. * Step up the descendants, stopping when the root element is reached
  61453. * (signaled by `.parent` returning a reference to the same object)
  61454. */
  61455. let next = contained;
  61456. while (next && next !== next.parent) {
  61457. next = next.parent;
  61458. if (next === container) {
  61459. return true;
  61460. }
  61461. }
  61462. return false;
  61463. }
  61464. /**
  61465. * $.merge().
  61466. *
  61467. * @param arr1 - First array.
  61468. * @param arr2 - Second array.
  61469. * @returns `arr1`, with elements of `arr2` inserted.
  61470. * @alias Cheerio.merge
  61471. * @see {@link https://api.jquery.com/jQuery.merge/}
  61472. */
  61473. function merge$2(arr1, arr2) {
  61474. if (!isArrayLike$1(arr1) || !isArrayLike$1(arr2)) {
  61475. return;
  61476. }
  61477. let newLength = arr1.length;
  61478. const len = +arr2.length;
  61479. for (let i = 0; i < len; i++) {
  61480. arr1[newLength++] = arr2[i];
  61481. }
  61482. arr1.length = newLength;
  61483. return arr1;
  61484. }
  61485. /**
  61486. * Checks if an object is array-like.
  61487. *
  61488. * @param item - Item to check.
  61489. * @returns Indicates if the item is array-like.
  61490. */
  61491. function isArrayLike$1(item) {
  61492. if (Array.isArray(item)) {
  61493. return true;
  61494. }
  61495. if (typeof item !== 'object' ||
  61496. !Object.prototype.hasOwnProperty.call(item, 'length') ||
  61497. typeof item.length !== 'number' ||
  61498. item.length < 0) {
  61499. return false;
  61500. }
  61501. for (let i = 0; i < item.length; i++) {
  61502. if (!(i in item)) {
  61503. return false;
  61504. }
  61505. }
  61506. return true;
  61507. }
  61508. var staticMethods = /*#__PURE__*/Object.freeze({
  61509. __proto__: null,
  61510. html: html$1,
  61511. xml: xml$1,
  61512. text: text,
  61513. parseHTML: parseHTML,
  61514. root: root$2,
  61515. contains: contains,
  61516. merge: merge$2
  61517. });
  61518. /**
  61519. * Checks if an object is a Cheerio instance.
  61520. *
  61521. * @category Utils
  61522. * @param maybeCheerio - The object to check.
  61523. * @returns Whether the object is a Cheerio instance.
  61524. */
  61525. function isCheerio(maybeCheerio) {
  61526. return maybeCheerio.cheerio != null;
  61527. }
  61528. /**
  61529. * Convert a string to camel case notation.
  61530. *
  61531. * @private
  61532. * @category Utils
  61533. * @param str - The string to be converted.
  61534. * @returns String in camel case notation.
  61535. */
  61536. function camelCase(str) {
  61537. return str.replace(/[_.-](\w|$)/g, (_, x) => x.toUpperCase());
  61538. }
  61539. /**
  61540. * Convert a string from camel case to "CSS case", where word boundaries are
  61541. * described by hyphens ("-") and all characters are lower-case.
  61542. *
  61543. * @private
  61544. * @category Utils
  61545. * @param str - The string to be converted.
  61546. * @returns String in "CSS case".
  61547. */
  61548. function cssCase(str) {
  61549. return str.replace(/[A-Z]/g, '-$&').toLowerCase();
  61550. }
  61551. /**
  61552. * Iterate over each DOM element without creating intermediary Cheerio instances.
  61553. *
  61554. * This is indented for use internally to avoid otherwise unnecessary memory
  61555. * pressure introduced by _make.
  61556. *
  61557. * @category Utils
  61558. * @param array - The array to iterate over.
  61559. * @param fn - Function to call.
  61560. * @returns The original instance.
  61561. */
  61562. function domEach(array, fn) {
  61563. const len = array.length;
  61564. for (let i = 0; i < len; i++)
  61565. fn(array[i], i);
  61566. return array;
  61567. }
  61568. /**
  61569. * Create a deep copy of the given DOM structure. Sets the parents of the copies
  61570. * of the passed nodes to `null`.
  61571. *
  61572. * @private
  61573. * @category Utils
  61574. * @param dom - The domhandler-compliant DOM structure.
  61575. * @returns - The cloned DOM.
  61576. */
  61577. function cloneDom(dom) {
  61578. const clone = 'length' in dom
  61579. ? Array.prototype.map.call(dom, (el) => cloneNode(el, true))
  61580. : [cloneNode(dom, true)];
  61581. // Add a root node around the cloned nodes
  61582. const root = new Document(clone);
  61583. clone.forEach((node) => {
  61584. node.parent = root;
  61585. });
  61586. return clone;
  61587. }
  61588. var CharacterCodes;
  61589. (function (CharacterCodes) {
  61590. CharacterCodes[CharacterCodes["LowerA"] = 97] = "LowerA";
  61591. CharacterCodes[CharacterCodes["LowerZ"] = 122] = "LowerZ";
  61592. CharacterCodes[CharacterCodes["UpperA"] = 65] = "UpperA";
  61593. CharacterCodes[CharacterCodes["UpperZ"] = 90] = "UpperZ";
  61594. CharacterCodes[CharacterCodes["Exclamation"] = 33] = "Exclamation";
  61595. })(CharacterCodes || (CharacterCodes = {}));
  61596. /**
  61597. * Check if string is HTML.
  61598. *
  61599. * Tests for a `<` within a string, immediate followed by a letter and
  61600. * eventually followed by a `>`.
  61601. *
  61602. * @private
  61603. * @category Utils
  61604. * @param str - The string to check.
  61605. * @returns Indicates if `str` is HTML.
  61606. */
  61607. function isHtml(str) {
  61608. const tagStart = str.indexOf('<');
  61609. if (tagStart < 0 || tagStart > str.length - 3)
  61610. return false;
  61611. const tagChar = str.charCodeAt(tagStart + 1);
  61612. return (((tagChar >= CharacterCodes.LowerA && tagChar <= CharacterCodes.LowerZ) ||
  61613. (tagChar >= CharacterCodes.UpperA && tagChar <= CharacterCodes.UpperZ) ||
  61614. tagChar === CharacterCodes.Exclamation) &&
  61615. str.includes('>', tagStart + 2));
  61616. }
  61617. /**
  61618. * Methods for getting and modifying attributes.
  61619. *
  61620. * @module cheerio/attributes
  61621. */
  61622. const hasOwn = Object.prototype.hasOwnProperty;
  61623. const rspace = /\s+/;
  61624. const dataAttrPrefix = 'data-';
  61625. /*
  61626. * Lookup table for coercing string data-* attributes to their corresponding
  61627. * JavaScript primitives
  61628. */
  61629. const primitives = {
  61630. null: null,
  61631. true: true,
  61632. false: false,
  61633. };
  61634. // Attributes that are booleans
  61635. const rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i;
  61636. // Matches strings that look like JSON objects or arrays
  61637. const rbrace = /^{[^]*}$|^\[[^]*]$/;
  61638. function getAttr(elem, name, xmlMode) {
  61639. var _a;
  61640. if (!elem || !isTag$1(elem))
  61641. return undefined;
  61642. (_a = elem.attribs) !== null && _a !== void 0 ? _a : (elem.attribs = {});
  61643. // Return the entire attribs object if no attribute specified
  61644. if (!name) {
  61645. return elem.attribs;
  61646. }
  61647. if (hasOwn.call(elem.attribs, name)) {
  61648. // Get the (decoded) attribute
  61649. return !xmlMode && rboolean.test(name) ? name : elem.attribs[name];
  61650. }
  61651. // Mimic the DOM and return text content as value for `option's`
  61652. if (elem.name === 'option' && name === 'value') {
  61653. return text(elem.children);
  61654. }
  61655. // Mimic DOM with default value for radios/checkboxes
  61656. if (elem.name === 'input' &&
  61657. (elem.attribs['type'] === 'radio' || elem.attribs['type'] === 'checkbox') &&
  61658. name === 'value') {
  61659. return 'on';
  61660. }
  61661. return undefined;
  61662. }
  61663. /**
  61664. * Sets the value of an attribute. The attribute will be deleted if the value is `null`.
  61665. *
  61666. * @private
  61667. * @param el - The element to set the attribute on.
  61668. * @param name - The attribute's name.
  61669. * @param value - The attribute's value.
  61670. */
  61671. function setAttr(el, name, value) {
  61672. if (value === null) {
  61673. removeAttribute(el, name);
  61674. }
  61675. else {
  61676. el.attribs[name] = `${value}`;
  61677. }
  61678. }
  61679. function attr(name, value) {
  61680. // Set the value (with attr map support)
  61681. if (typeof name === 'object' || value !== undefined) {
  61682. if (typeof value === 'function') {
  61683. if (typeof name !== 'string') {
  61684. {
  61685. throw new Error('Bad combination of arguments.');
  61686. }
  61687. }
  61688. return domEach(this, (el, i) => {
  61689. if (isTag$1(el))
  61690. setAttr(el, name, value.call(el, i, el.attribs[name]));
  61691. });
  61692. }
  61693. return domEach(this, (el) => {
  61694. if (!isTag$1(el))
  61695. return;
  61696. if (typeof name === 'object') {
  61697. Object.keys(name).forEach((objName) => {
  61698. const objValue = name[objName];
  61699. setAttr(el, objName, objValue);
  61700. });
  61701. }
  61702. else {
  61703. setAttr(el, name, value);
  61704. }
  61705. });
  61706. }
  61707. return arguments.length > 1
  61708. ? this
  61709. : getAttr(this[0], name, this.options.xmlMode);
  61710. }
  61711. /**
  61712. * Gets a node's prop.
  61713. *
  61714. * @private
  61715. * @category Attributes
  61716. * @param el - Element to get the prop of.
  61717. * @param name - Name of the prop.
  61718. * @returns The prop's value.
  61719. */
  61720. function getProp(el, name, xmlMode) {
  61721. if (!el || !isTag$1(el))
  61722. return;
  61723. return name in el
  61724. ? // @ts-expect-error TS doesn't like us accessing the value directly here.
  61725. el[name]
  61726. : !xmlMode && rboolean.test(name)
  61727. ? getAttr(el, name, false) !== undefined
  61728. : getAttr(el, name, xmlMode);
  61729. }
  61730. /**
  61731. * Sets the value of a prop.
  61732. *
  61733. * @private
  61734. * @param el - The element to set the prop on.
  61735. * @param name - The prop's name.
  61736. * @param value - The prop's value.
  61737. */
  61738. function setProp(el, name, value, xmlMode) {
  61739. if (name in el) {
  61740. // @ts-expect-error Overriding value
  61741. el[name] = value;
  61742. }
  61743. else {
  61744. setAttr(el, name, !xmlMode && rboolean.test(name) ? (value ? '' : null) : `${value}`);
  61745. }
  61746. }
  61747. function prop(name, value) {
  61748. var _a;
  61749. if (typeof name === 'string' && value === undefined) {
  61750. switch (name) {
  61751. case 'style': {
  61752. const property = this.css();
  61753. const keys = Object.keys(property);
  61754. keys.forEach((p, i) => {
  61755. property[i] = p;
  61756. });
  61757. property.length = keys.length;
  61758. return property;
  61759. }
  61760. case 'tagName':
  61761. case 'nodeName': {
  61762. const el = this[0];
  61763. return isTag$1(el) ? el.name.toUpperCase() : undefined;
  61764. }
  61765. case 'href':
  61766. case 'src': {
  61767. const el = this[0];
  61768. if (!isTag$1(el)) {
  61769. return undefined;
  61770. }
  61771. const prop = (_a = el.attribs) === null || _a === void 0 ? void 0 : _a[name];
  61772. /* eslint-disable node/no-unsupported-features/node-builtins */
  61773. if (typeof URL !== 'undefined' &&
  61774. ((name === 'href' && (el.tagName === 'a' || el.name === 'link')) ||
  61775. (name === 'src' &&
  61776. (el.tagName === 'img' ||
  61777. el.tagName === 'iframe' ||
  61778. el.tagName === 'audio' ||
  61779. el.tagName === 'video' ||
  61780. el.tagName === 'source'))) &&
  61781. prop !== undefined &&
  61782. this.options.baseURI) {
  61783. return new URL(prop, this.options.baseURI).href;
  61784. }
  61785. /* eslint-enable node/no-unsupported-features/node-builtins */
  61786. return prop;
  61787. }
  61788. case 'innerText':
  61789. return innerText(this[0]);
  61790. case 'textContent':
  61791. return textContent(this[0]);
  61792. case 'outerHTML':
  61793. return this.clone().wrap('<container />').parent().html();
  61794. case 'innerHTML':
  61795. return this.html();
  61796. default:
  61797. return getProp(this[0], name, this.options.xmlMode);
  61798. }
  61799. }
  61800. if (typeof name === 'object' || value !== undefined) {
  61801. if (typeof value === 'function') {
  61802. if (typeof name === 'object') {
  61803. throw new Error('Bad combination of arguments.');
  61804. }
  61805. return domEach(this, (el, i) => {
  61806. if (isTag$1(el)) {
  61807. setProp(el, name, value.call(el, i, getProp(el, name, this.options.xmlMode)), this.options.xmlMode);
  61808. }
  61809. });
  61810. }
  61811. return domEach(this, (el) => {
  61812. if (!isTag$1(el))
  61813. return;
  61814. if (typeof name === 'object') {
  61815. Object.keys(name).forEach((key) => {
  61816. const val = name[key];
  61817. setProp(el, key, val, this.options.xmlMode);
  61818. });
  61819. }
  61820. else {
  61821. setProp(el, name, value, this.options.xmlMode);
  61822. }
  61823. });
  61824. }
  61825. return undefined;
  61826. }
  61827. /**
  61828. * Sets the value of a data attribute.
  61829. *
  61830. * @private
  61831. * @param el - The element to set the data attribute on.
  61832. * @param name - The data attribute's name.
  61833. * @param value - The data attribute's value.
  61834. */
  61835. function setData(el, name, value) {
  61836. var _a;
  61837. const elem = el;
  61838. (_a = elem.data) !== null && _a !== void 0 ? _a : (elem.data = {});
  61839. if (typeof name === 'object')
  61840. Object.assign(elem.data, name);
  61841. else if (typeof name === 'string' && value !== undefined) {
  61842. elem.data[name] = value;
  61843. }
  61844. }
  61845. /**
  61846. * Read the specified attribute from the equivalent HTML5 `data-*` attribute,
  61847. * and (if present) cache the value in the node's internal data store. If no
  61848. * attribute name is specified, read _all_ HTML5 `data-*` attributes in this manner.
  61849. *
  61850. * @private
  61851. * @category Attributes
  61852. * @param el - Element to get the data attribute of.
  61853. * @param name - Name of the data attribute.
  61854. * @returns The data attribute's value, or a map with all of the data attributes.
  61855. */
  61856. function readData(el, name) {
  61857. let domNames;
  61858. let jsNames;
  61859. let value;
  61860. if (name == null) {
  61861. domNames = Object.keys(el.attribs).filter((attrName) => attrName.startsWith(dataAttrPrefix));
  61862. jsNames = domNames.map((domName) => camelCase(domName.slice(dataAttrPrefix.length)));
  61863. }
  61864. else {
  61865. domNames = [dataAttrPrefix + cssCase(name)];
  61866. jsNames = [name];
  61867. }
  61868. for (let idx = 0; idx < domNames.length; ++idx) {
  61869. const domName = domNames[idx];
  61870. const jsName = jsNames[idx];
  61871. if (hasOwn.call(el.attribs, domName) &&
  61872. !hasOwn.call(el.data, jsName)) {
  61873. value = el.attribs[domName];
  61874. if (hasOwn.call(primitives, value)) {
  61875. value = primitives[value];
  61876. }
  61877. else if (value === String(Number(value))) {
  61878. value = Number(value);
  61879. }
  61880. else if (rbrace.test(value)) {
  61881. try {
  61882. value = JSON.parse(value);
  61883. }
  61884. catch (e) {
  61885. /* Ignore */
  61886. }
  61887. }
  61888. el.data[jsName] = value;
  61889. }
  61890. }
  61891. return name == null ? el.data : value;
  61892. }
  61893. function data$2(name, value) {
  61894. var _a;
  61895. const elem = this[0];
  61896. if (!elem || !isTag$1(elem))
  61897. return;
  61898. const dataEl = elem;
  61899. (_a = dataEl.data) !== null && _a !== void 0 ? _a : (dataEl.data = {});
  61900. // Return the entire data object if no data specified
  61901. if (!name) {
  61902. return readData(dataEl);
  61903. }
  61904. // Set the value (with attr map support)
  61905. if (typeof name === 'object' || value !== undefined) {
  61906. domEach(this, (el) => {
  61907. if (isTag$1(el)) {
  61908. if (typeof name === 'object')
  61909. setData(el, name);
  61910. else
  61911. setData(el, name, value);
  61912. }
  61913. });
  61914. return this;
  61915. }
  61916. if (hasOwn.call(dataEl.data, name)) {
  61917. return dataEl.data[name];
  61918. }
  61919. return readData(dataEl, name);
  61920. }
  61921. function val(value) {
  61922. const querying = arguments.length === 0;
  61923. const element = this[0];
  61924. if (!element || !isTag$1(element))
  61925. return querying ? undefined : this;
  61926. switch (element.name) {
  61927. case 'textarea':
  61928. return this.text(value);
  61929. case 'select': {
  61930. const option = this.find('option:selected');
  61931. if (!querying) {
  61932. if (this.attr('multiple') == null && typeof value === 'object') {
  61933. return this;
  61934. }
  61935. this.find('option').removeAttr('selected');
  61936. const values = typeof value !== 'object' ? [value] : value;
  61937. for (let i = 0; i < values.length; i++) {
  61938. this.find(`option[value="${values[i]}"]`).attr('selected', '');
  61939. }
  61940. return this;
  61941. }
  61942. return this.attr('multiple')
  61943. ? option.toArray().map((el) => text(el.children))
  61944. : option.attr('value');
  61945. }
  61946. case 'input':
  61947. case 'option':
  61948. return querying
  61949. ? this.attr('value')
  61950. : this.attr('value', value);
  61951. }
  61952. return undefined;
  61953. }
  61954. /**
  61955. * Remove an attribute.
  61956. *
  61957. * @private
  61958. * @param elem - Node to remove attribute from.
  61959. * @param name - Name of the attribute to remove.
  61960. */
  61961. function removeAttribute(elem, name) {
  61962. if (!elem.attribs || !hasOwn.call(elem.attribs, name))
  61963. return;
  61964. delete elem.attribs[name];
  61965. }
  61966. /**
  61967. * Splits a space-separated list of names to individual names.
  61968. *
  61969. * @category Attributes
  61970. * @param names - Names to split.
  61971. * @returns - Split names.
  61972. */
  61973. function splitNames(names) {
  61974. return names ? names.trim().split(rspace) : [];
  61975. }
  61976. /**
  61977. * Method for removing attributes by `name`.
  61978. *
  61979. * @category Attributes
  61980. * @example
  61981. *
  61982. * ```js
  61983. * $('.pear').removeAttr('class').html();
  61984. * //=> <li>Pear</li>
  61985. *
  61986. * $('.apple').attr('id', 'favorite');
  61987. * $('.apple').removeAttr('id class').html();
  61988. * //=> <li>Apple</li>
  61989. * ```
  61990. *
  61991. * @param name - Name of the attribute.
  61992. * @returns The instance itself.
  61993. * @see {@link https://api.jquery.com/removeAttr/}
  61994. */
  61995. function removeAttr(name) {
  61996. const attrNames = splitNames(name);
  61997. for (let i = 0; i < attrNames.length; i++) {
  61998. domEach(this, (elem) => {
  61999. if (isTag$1(elem))
  62000. removeAttribute(elem, attrNames[i]);
  62001. });
  62002. }
  62003. return this;
  62004. }
  62005. /**
  62006. * Check to see if _any_ of the matched elements have the given `className`.
  62007. *
  62008. * @category Attributes
  62009. * @example
  62010. *
  62011. * ```js
  62012. * $('.pear').hasClass('pear');
  62013. * //=> true
  62014. *
  62015. * $('apple').hasClass('fruit');
  62016. * //=> false
  62017. *
  62018. * $('li').hasClass('pear');
  62019. * //=> true
  62020. * ```
  62021. *
  62022. * @param className - Name of the class.
  62023. * @returns Indicates if an element has the given `className`.
  62024. * @see {@link https://api.jquery.com/hasClass/}
  62025. */
  62026. function hasClass(className) {
  62027. return this.toArray().some((elem) => {
  62028. const clazz = isTag$1(elem) && elem.attribs['class'];
  62029. let idx = -1;
  62030. if (clazz && className.length) {
  62031. while ((idx = clazz.indexOf(className, idx + 1)) > -1) {
  62032. const end = idx + className.length;
  62033. if ((idx === 0 || rspace.test(clazz[idx - 1])) &&
  62034. (end === clazz.length || rspace.test(clazz[end]))) {
  62035. return true;
  62036. }
  62037. }
  62038. }
  62039. return false;
  62040. });
  62041. }
  62042. /**
  62043. * Adds class(es) to all of the matched elements. Also accepts a `function`.
  62044. *
  62045. * @category Attributes
  62046. * @example
  62047. *
  62048. * ```js
  62049. * $('.pear').addClass('fruit').html();
  62050. * //=> <li class="pear fruit">Pear</li>
  62051. *
  62052. * $('.apple').addClass('fruit red').html();
  62053. * //=> <li class="apple fruit red">Apple</li>
  62054. * ```
  62055. *
  62056. * @param value - Name of new class.
  62057. * @returns The instance itself.
  62058. * @see {@link https://api.jquery.com/addClass/}
  62059. */
  62060. function addClass(value) {
  62061. // Support functions
  62062. if (typeof value === 'function') {
  62063. return domEach(this, (el, i) => {
  62064. if (isTag$1(el)) {
  62065. const className = el.attribs['class'] || '';
  62066. addClass.call([el], value.call(el, i, className));
  62067. }
  62068. });
  62069. }
  62070. // Return if no value or not a string or function
  62071. if (!value || typeof value !== 'string')
  62072. return this;
  62073. const classNames = value.split(rspace);
  62074. const numElements = this.length;
  62075. for (let i = 0; i < numElements; i++) {
  62076. const el = this[i];
  62077. // If selected element isn't a tag, move on
  62078. if (!isTag$1(el))
  62079. continue;
  62080. // If we don't already have classes — always set xmlMode to false here, as it doesn't matter for classes
  62081. const className = getAttr(el, 'class', false);
  62082. if (!className) {
  62083. setAttr(el, 'class', classNames.join(' ').trim());
  62084. }
  62085. else {
  62086. let setClass = ` ${className} `;
  62087. // Check if class already exists
  62088. for (let j = 0; j < classNames.length; j++) {
  62089. const appendClass = `${classNames[j]} `;
  62090. if (!setClass.includes(` ${appendClass}`))
  62091. setClass += appendClass;
  62092. }
  62093. setAttr(el, 'class', setClass.trim());
  62094. }
  62095. }
  62096. return this;
  62097. }
  62098. /**
  62099. * Removes one or more space-separated classes from the selected elements. If no
  62100. * `className` is defined, all classes will be removed. Also accepts a `function`.
  62101. *
  62102. * @category Attributes
  62103. * @example
  62104. *
  62105. * ```js
  62106. * $('.pear').removeClass('pear').html();
  62107. * //=> <li class="">Pear</li>
  62108. *
  62109. * $('.apple').addClass('red').removeClass().html();
  62110. * //=> <li class="">Apple</li>
  62111. * ```
  62112. *
  62113. * @param name - Name of the class. If not specified, removes all elements.
  62114. * @returns The instance itself.
  62115. * @see {@link https://api.jquery.com/removeClass/}
  62116. */
  62117. function removeClass(name) {
  62118. // Handle if value is a function
  62119. if (typeof name === 'function') {
  62120. return domEach(this, (el, i) => {
  62121. if (isTag$1(el)) {
  62122. removeClass.call([el], name.call(el, i, el.attribs['class'] || ''));
  62123. }
  62124. });
  62125. }
  62126. const classes = splitNames(name);
  62127. const numClasses = classes.length;
  62128. const removeAll = arguments.length === 0;
  62129. return domEach(this, (el) => {
  62130. if (!isTag$1(el))
  62131. return;
  62132. if (removeAll) {
  62133. // Short circuit the remove all case as this is the nice one
  62134. el.attribs['class'] = '';
  62135. }
  62136. else {
  62137. const elClasses = splitNames(el.attribs['class']);
  62138. let changed = false;
  62139. for (let j = 0; j < numClasses; j++) {
  62140. const index = elClasses.indexOf(classes[j]);
  62141. if (index >= 0) {
  62142. elClasses.splice(index, 1);
  62143. changed = true;
  62144. /*
  62145. * We have to do another pass to ensure that there are not duplicate
  62146. * classes listed
  62147. */
  62148. j--;
  62149. }
  62150. }
  62151. if (changed) {
  62152. el.attribs['class'] = elClasses.join(' ');
  62153. }
  62154. }
  62155. });
  62156. }
  62157. /**
  62158. * Add or remove class(es) from the matched elements, depending on either the
  62159. * class's presence or the value of the switch argument. Also accepts a `function`.
  62160. *
  62161. * @category Attributes
  62162. * @example
  62163. *
  62164. * ```js
  62165. * $('.apple.green').toggleClass('fruit green red').html();
  62166. * //=> <li class="apple fruit red">Apple</li>
  62167. *
  62168. * $('.apple.green').toggleClass('fruit green red', true).html();
  62169. * //=> <li class="apple green fruit red">Apple</li>
  62170. * ```
  62171. *
  62172. * @param value - Name of the class. Can also be a function.
  62173. * @param stateVal - If specified the state of the class.
  62174. * @returns The instance itself.
  62175. * @see {@link https://api.jquery.com/toggleClass/}
  62176. */
  62177. function toggleClass(value, stateVal) {
  62178. // Support functions
  62179. if (typeof value === 'function') {
  62180. return domEach(this, (el, i) => {
  62181. if (isTag$1(el)) {
  62182. toggleClass.call([el], value.call(el, i, el.attribs['class'] || '', stateVal), stateVal);
  62183. }
  62184. });
  62185. }
  62186. // Return if no value or not a string or function
  62187. if (!value || typeof value !== 'string')
  62188. return this;
  62189. const classNames = value.split(rspace);
  62190. const numClasses = classNames.length;
  62191. const state = typeof stateVal === 'boolean' ? (stateVal ? 1 : -1) : 0;
  62192. const numElements = this.length;
  62193. for (let i = 0; i < numElements; i++) {
  62194. const el = this[i];
  62195. // If selected element isn't a tag, move on
  62196. if (!isTag$1(el))
  62197. continue;
  62198. const elementClasses = splitNames(el.attribs['class']);
  62199. // Check if class already exists
  62200. for (let j = 0; j < numClasses; j++) {
  62201. // Check if the class name is currently defined
  62202. const index = elementClasses.indexOf(classNames[j]);
  62203. // Add if stateValue === true or we are toggling and there is no value
  62204. if (state >= 0 && index < 0) {
  62205. elementClasses.push(classNames[j]);
  62206. }
  62207. else if (state <= 0 && index >= 0) {
  62208. // Otherwise remove but only if the item exists
  62209. elementClasses.splice(index, 1);
  62210. }
  62211. }
  62212. el.attribs['class'] = elementClasses.join(' ');
  62213. }
  62214. return this;
  62215. }
  62216. var Attributes = /*#__PURE__*/Object.freeze({
  62217. __proto__: null,
  62218. attr: attr,
  62219. prop: prop,
  62220. data: data$2,
  62221. val: val,
  62222. removeAttr: removeAttr,
  62223. hasClass: hasClass,
  62224. addClass: addClass,
  62225. removeClass: removeClass,
  62226. toggleClass: toggleClass
  62227. });
  62228. var SelectorType;
  62229. (function (SelectorType) {
  62230. SelectorType["Attribute"] = "attribute";
  62231. SelectorType["Pseudo"] = "pseudo";
  62232. SelectorType["PseudoElement"] = "pseudo-element";
  62233. SelectorType["Tag"] = "tag";
  62234. SelectorType["Universal"] = "universal";
  62235. // Traversals
  62236. SelectorType["Adjacent"] = "adjacent";
  62237. SelectorType["Child"] = "child";
  62238. SelectorType["Descendant"] = "descendant";
  62239. SelectorType["Parent"] = "parent";
  62240. SelectorType["Sibling"] = "sibling";
  62241. SelectorType["ColumnCombinator"] = "column-combinator";
  62242. })(SelectorType || (SelectorType = {}));
  62243. var AttributeAction;
  62244. (function (AttributeAction) {
  62245. AttributeAction["Any"] = "any";
  62246. AttributeAction["Element"] = "element";
  62247. AttributeAction["End"] = "end";
  62248. AttributeAction["Equals"] = "equals";
  62249. AttributeAction["Exists"] = "exists";
  62250. AttributeAction["Hyphen"] = "hyphen";
  62251. AttributeAction["Not"] = "not";
  62252. AttributeAction["Start"] = "start";
  62253. })(AttributeAction || (AttributeAction = {}));
  62254. const reName = /^[^\\#]?(?:\\(?:[\da-f]{1,6}\s?|.)|[\w\-\u00b0-\uFFFF])+/;
  62255. const reEscape = /\\([\da-f]{1,6}\s?|(\s)|.)/gi;
  62256. const actionTypes = new Map([
  62257. [126 /* Tilde */, AttributeAction.Element],
  62258. [94 /* Circumflex */, AttributeAction.Start],
  62259. [36 /* Dollar */, AttributeAction.End],
  62260. [42 /* Asterisk */, AttributeAction.Any],
  62261. [33 /* ExclamationMark */, AttributeAction.Not],
  62262. [124 /* Pipe */, AttributeAction.Hyphen],
  62263. ]);
  62264. // Pseudos, whose data property is parsed as well.
  62265. const unpackPseudos = new Set([
  62266. "has",
  62267. "not",
  62268. "matches",
  62269. "is",
  62270. "where",
  62271. "host",
  62272. "host-context",
  62273. ]);
  62274. /**
  62275. * Checks whether a specific selector is a traversal.
  62276. * This is useful eg. in swapping the order of elements that
  62277. * are not traversals.
  62278. *
  62279. * @param selector Selector to check.
  62280. */
  62281. function isTraversal(selector) {
  62282. switch (selector.type) {
  62283. case SelectorType.Adjacent:
  62284. case SelectorType.Child:
  62285. case SelectorType.Descendant:
  62286. case SelectorType.Parent:
  62287. case SelectorType.Sibling:
  62288. case SelectorType.ColumnCombinator:
  62289. return true;
  62290. default:
  62291. return false;
  62292. }
  62293. }
  62294. const stripQuotesFromPseudos = new Set(["contains", "icontains"]);
  62295. // Unescape function taken from https://github.com/jquery/sizzle/blob/master/src/sizzle.js#L152
  62296. function funescape(_, escaped, escapedWhitespace) {
  62297. const high = parseInt(escaped, 16) - 0x10000;
  62298. // NaN means non-codepoint
  62299. return high !== high || escapedWhitespace
  62300. ? escaped
  62301. : high < 0
  62302. ? // BMP codepoint
  62303. String.fromCharCode(high + 0x10000)
  62304. : // Supplemental Plane codepoint (surrogate pair)
  62305. String.fromCharCode((high >> 10) | 0xd800, (high & 0x3ff) | 0xdc00);
  62306. }
  62307. function unescapeCSS(str) {
  62308. return str.replace(reEscape, funescape);
  62309. }
  62310. function isQuote(c) {
  62311. return c === 39 /* SingleQuote */ || c === 34 /* DoubleQuote */;
  62312. }
  62313. function isWhitespace(c) {
  62314. return (c === 32 /* Space */ ||
  62315. c === 9 /* Tab */ ||
  62316. c === 10 /* NewLine */ ||
  62317. c === 12 /* FormFeed */ ||
  62318. c === 13 /* CarriageReturn */);
  62319. }
  62320. /**
  62321. * Parses `selector`, optionally with the passed `options`.
  62322. *
  62323. * @param selector Selector to parse.
  62324. * @param options Options for parsing.
  62325. * @returns Returns a two-dimensional array.
  62326. * The first dimension represents selectors separated by commas (eg. `sub1, sub2`),
  62327. * the second contains the relevant tokens for that selector.
  62328. */
  62329. function parse(selector) {
  62330. const subselects = [];
  62331. const endIndex = parseSelector(subselects, `${selector}`, 0);
  62332. if (endIndex < selector.length) {
  62333. throw new Error(`Unmatched selector: ${selector.slice(endIndex)}`);
  62334. }
  62335. return subselects;
  62336. }
  62337. function parseSelector(subselects, selector, selectorIndex) {
  62338. let tokens = [];
  62339. function getName(offset) {
  62340. const match = selector.slice(selectorIndex + offset).match(reName);
  62341. if (!match) {
  62342. throw new Error(`Expected name, found ${selector.slice(selectorIndex)}`);
  62343. }
  62344. const [name] = match;
  62345. selectorIndex += offset + name.length;
  62346. return unescapeCSS(name);
  62347. }
  62348. function stripWhitespace(offset) {
  62349. selectorIndex += offset;
  62350. while (selectorIndex < selector.length &&
  62351. isWhitespace(selector.charCodeAt(selectorIndex))) {
  62352. selectorIndex++;
  62353. }
  62354. }
  62355. function readValueWithParenthesis() {
  62356. selectorIndex += 1;
  62357. const start = selectorIndex;
  62358. let counter = 1;
  62359. for (; counter > 0 && selectorIndex < selector.length; selectorIndex++) {
  62360. if (selector.charCodeAt(selectorIndex) ===
  62361. 40 /* LeftParenthesis */ &&
  62362. !isEscaped(selectorIndex)) {
  62363. counter++;
  62364. }
  62365. else if (selector.charCodeAt(selectorIndex) ===
  62366. 41 /* RightParenthesis */ &&
  62367. !isEscaped(selectorIndex)) {
  62368. counter--;
  62369. }
  62370. }
  62371. if (counter) {
  62372. throw new Error("Parenthesis not matched");
  62373. }
  62374. return unescapeCSS(selector.slice(start, selectorIndex - 1));
  62375. }
  62376. function isEscaped(pos) {
  62377. let slashCount = 0;
  62378. while (selector.charCodeAt(--pos) === 92 /* BackSlash */)
  62379. slashCount++;
  62380. return (slashCount & 1) === 1;
  62381. }
  62382. function ensureNotTraversal() {
  62383. if (tokens.length > 0 && isTraversal(tokens[tokens.length - 1])) {
  62384. throw new Error("Did not expect successive traversals.");
  62385. }
  62386. }
  62387. function addTraversal(type) {
  62388. if (tokens.length > 0 &&
  62389. tokens[tokens.length - 1].type === SelectorType.Descendant) {
  62390. tokens[tokens.length - 1].type = type;
  62391. return;
  62392. }
  62393. ensureNotTraversal();
  62394. tokens.push({ type });
  62395. }
  62396. function addSpecialAttribute(name, action) {
  62397. tokens.push({
  62398. type: SelectorType.Attribute,
  62399. name,
  62400. action,
  62401. value: getName(1),
  62402. namespace: null,
  62403. ignoreCase: "quirks",
  62404. });
  62405. }
  62406. /**
  62407. * We have finished parsing the current part of the selector.
  62408. *
  62409. * Remove descendant tokens at the end if they exist,
  62410. * and return the last index, so that parsing can be
  62411. * picked up from here.
  62412. */
  62413. function finalizeSubselector() {
  62414. if (tokens.length &&
  62415. tokens[tokens.length - 1].type === SelectorType.Descendant) {
  62416. tokens.pop();
  62417. }
  62418. if (tokens.length === 0) {
  62419. throw new Error("Empty sub-selector");
  62420. }
  62421. subselects.push(tokens);
  62422. }
  62423. stripWhitespace(0);
  62424. if (selector.length === selectorIndex) {
  62425. return selectorIndex;
  62426. }
  62427. loop: while (selectorIndex < selector.length) {
  62428. const firstChar = selector.charCodeAt(selectorIndex);
  62429. switch (firstChar) {
  62430. // Whitespace
  62431. case 32 /* Space */:
  62432. case 9 /* Tab */:
  62433. case 10 /* NewLine */:
  62434. case 12 /* FormFeed */:
  62435. case 13 /* CarriageReturn */: {
  62436. if (tokens.length === 0 ||
  62437. tokens[0].type !== SelectorType.Descendant) {
  62438. ensureNotTraversal();
  62439. tokens.push({ type: SelectorType.Descendant });
  62440. }
  62441. stripWhitespace(1);
  62442. break;
  62443. }
  62444. // Traversals
  62445. case 62 /* GreaterThan */: {
  62446. addTraversal(SelectorType.Child);
  62447. stripWhitespace(1);
  62448. break;
  62449. }
  62450. case 60 /* LessThan */: {
  62451. addTraversal(SelectorType.Parent);
  62452. stripWhitespace(1);
  62453. break;
  62454. }
  62455. case 126 /* Tilde */: {
  62456. addTraversal(SelectorType.Sibling);
  62457. stripWhitespace(1);
  62458. break;
  62459. }
  62460. case 43 /* Plus */: {
  62461. addTraversal(SelectorType.Adjacent);
  62462. stripWhitespace(1);
  62463. break;
  62464. }
  62465. // Special attribute selectors: .class, #id
  62466. case 46 /* Period */: {
  62467. addSpecialAttribute("class", AttributeAction.Element);
  62468. break;
  62469. }
  62470. case 35 /* Hash */: {
  62471. addSpecialAttribute("id", AttributeAction.Equals);
  62472. break;
  62473. }
  62474. case 91 /* LeftSquareBracket */: {
  62475. stripWhitespace(1);
  62476. // Determine attribute name and namespace
  62477. let name;
  62478. let namespace = null;
  62479. if (selector.charCodeAt(selectorIndex) === 124 /* Pipe */) {
  62480. // Equivalent to no namespace
  62481. name = getName(1);
  62482. }
  62483. else if (selector.startsWith("*|", selectorIndex)) {
  62484. namespace = "*";
  62485. name = getName(2);
  62486. }
  62487. else {
  62488. name = getName(0);
  62489. if (selector.charCodeAt(selectorIndex) === 124 /* Pipe */ &&
  62490. selector.charCodeAt(selectorIndex + 1) !==
  62491. 61 /* Equal */) {
  62492. namespace = name;
  62493. name = getName(1);
  62494. }
  62495. }
  62496. stripWhitespace(0);
  62497. // Determine comparison operation
  62498. let action = AttributeAction.Exists;
  62499. const possibleAction = actionTypes.get(selector.charCodeAt(selectorIndex));
  62500. if (possibleAction) {
  62501. action = possibleAction;
  62502. if (selector.charCodeAt(selectorIndex + 1) !==
  62503. 61 /* Equal */) {
  62504. throw new Error("Expected `=`");
  62505. }
  62506. stripWhitespace(2);
  62507. }
  62508. else if (selector.charCodeAt(selectorIndex) === 61 /* Equal */) {
  62509. action = AttributeAction.Equals;
  62510. stripWhitespace(1);
  62511. }
  62512. // Determine value
  62513. let value = "";
  62514. let ignoreCase = null;
  62515. if (action !== "exists") {
  62516. if (isQuote(selector.charCodeAt(selectorIndex))) {
  62517. const quote = selector.charCodeAt(selectorIndex);
  62518. let sectionEnd = selectorIndex + 1;
  62519. while (sectionEnd < selector.length &&
  62520. (selector.charCodeAt(sectionEnd) !== quote ||
  62521. isEscaped(sectionEnd))) {
  62522. sectionEnd += 1;
  62523. }
  62524. if (selector.charCodeAt(sectionEnd) !== quote) {
  62525. throw new Error("Attribute value didn't end");
  62526. }
  62527. value = unescapeCSS(selector.slice(selectorIndex + 1, sectionEnd));
  62528. selectorIndex = sectionEnd + 1;
  62529. }
  62530. else {
  62531. const valueStart = selectorIndex;
  62532. while (selectorIndex < selector.length &&
  62533. ((!isWhitespace(selector.charCodeAt(selectorIndex)) &&
  62534. selector.charCodeAt(selectorIndex) !==
  62535. 93 /* RightSquareBracket */) ||
  62536. isEscaped(selectorIndex))) {
  62537. selectorIndex += 1;
  62538. }
  62539. value = unescapeCSS(selector.slice(valueStart, selectorIndex));
  62540. }
  62541. stripWhitespace(0);
  62542. // See if we have a force ignore flag
  62543. const forceIgnore = selector.charCodeAt(selectorIndex) | 0x20;
  62544. // If the forceIgnore flag is set (either `i` or `s`), use that value
  62545. if (forceIgnore === 115 /* LowerS */) {
  62546. ignoreCase = false;
  62547. stripWhitespace(1);
  62548. }
  62549. else if (forceIgnore === 105 /* LowerI */) {
  62550. ignoreCase = true;
  62551. stripWhitespace(1);
  62552. }
  62553. }
  62554. if (selector.charCodeAt(selectorIndex) !==
  62555. 93 /* RightSquareBracket */) {
  62556. throw new Error("Attribute selector didn't terminate");
  62557. }
  62558. selectorIndex += 1;
  62559. const attributeSelector = {
  62560. type: SelectorType.Attribute,
  62561. name,
  62562. action,
  62563. value,
  62564. namespace,
  62565. ignoreCase,
  62566. };
  62567. tokens.push(attributeSelector);
  62568. break;
  62569. }
  62570. case 58 /* Colon */: {
  62571. if (selector.charCodeAt(selectorIndex + 1) === 58 /* Colon */) {
  62572. tokens.push({
  62573. type: SelectorType.PseudoElement,
  62574. name: getName(2).toLowerCase(),
  62575. data: selector.charCodeAt(selectorIndex) ===
  62576. 40 /* LeftParenthesis */
  62577. ? readValueWithParenthesis()
  62578. : null,
  62579. });
  62580. continue;
  62581. }
  62582. const name = getName(1).toLowerCase();
  62583. let data = null;
  62584. if (selector.charCodeAt(selectorIndex) ===
  62585. 40 /* LeftParenthesis */) {
  62586. if (unpackPseudos.has(name)) {
  62587. if (isQuote(selector.charCodeAt(selectorIndex + 1))) {
  62588. throw new Error(`Pseudo-selector ${name} cannot be quoted`);
  62589. }
  62590. data = [];
  62591. selectorIndex = parseSelector(data, selector, selectorIndex + 1);
  62592. if (selector.charCodeAt(selectorIndex) !==
  62593. 41 /* RightParenthesis */) {
  62594. throw new Error(`Missing closing parenthesis in :${name} (${selector})`);
  62595. }
  62596. selectorIndex += 1;
  62597. }
  62598. else {
  62599. data = readValueWithParenthesis();
  62600. if (stripQuotesFromPseudos.has(name)) {
  62601. const quot = data.charCodeAt(0);
  62602. if (quot === data.charCodeAt(data.length - 1) &&
  62603. isQuote(quot)) {
  62604. data = data.slice(1, -1);
  62605. }
  62606. }
  62607. data = unescapeCSS(data);
  62608. }
  62609. }
  62610. tokens.push({ type: SelectorType.Pseudo, name, data });
  62611. break;
  62612. }
  62613. case 44 /* Comma */: {
  62614. finalizeSubselector();
  62615. tokens = [];
  62616. stripWhitespace(1);
  62617. break;
  62618. }
  62619. default: {
  62620. if (selector.startsWith("/*", selectorIndex)) {
  62621. const endIndex = selector.indexOf("*/", selectorIndex + 2);
  62622. if (endIndex < 0) {
  62623. throw new Error("Comment was not terminated");
  62624. }
  62625. selectorIndex = endIndex + 2;
  62626. // Remove leading whitespace
  62627. if (tokens.length === 0) {
  62628. stripWhitespace(0);
  62629. }
  62630. break;
  62631. }
  62632. let namespace = null;
  62633. let name;
  62634. if (firstChar === 42 /* Asterisk */) {
  62635. selectorIndex += 1;
  62636. name = "*";
  62637. }
  62638. else if (firstChar === 124 /* Pipe */) {
  62639. name = "";
  62640. if (selector.charCodeAt(selectorIndex + 1) === 124 /* Pipe */) {
  62641. addTraversal(SelectorType.ColumnCombinator);
  62642. stripWhitespace(2);
  62643. break;
  62644. }
  62645. }
  62646. else if (reName.test(selector.slice(selectorIndex))) {
  62647. name = getName(0);
  62648. }
  62649. else {
  62650. break loop;
  62651. }
  62652. if (selector.charCodeAt(selectorIndex) === 124 /* Pipe */ &&
  62653. selector.charCodeAt(selectorIndex + 1) !== 124 /* Pipe */) {
  62654. namespace = name;
  62655. if (selector.charCodeAt(selectorIndex + 1) ===
  62656. 42 /* Asterisk */) {
  62657. name = "*";
  62658. selectorIndex += 2;
  62659. }
  62660. else {
  62661. name = getName(1);
  62662. }
  62663. }
  62664. tokens.push(name === "*"
  62665. ? { type: SelectorType.Universal, namespace }
  62666. : { type: SelectorType.Tag, name, namespace });
  62667. }
  62668. }
  62669. }
  62670. finalizeSubselector();
  62671. return selectorIndex;
  62672. }
  62673. var boolbase = {
  62674. trueFunc: function trueFunc(){
  62675. return true;
  62676. },
  62677. falseFunc: function falseFunc(){
  62678. return false;
  62679. }
  62680. };
  62681. var boolbase_1 = boolbase.trueFunc;
  62682. var boolbase_2 = boolbase.falseFunc;
  62683. const procedure = new Map([
  62684. [SelectorType.Universal, 50],
  62685. [SelectorType.Tag, 30],
  62686. [SelectorType.Attribute, 1],
  62687. [SelectorType.Pseudo, 0],
  62688. ]);
  62689. function isTraversal$1(token) {
  62690. return !procedure.has(token.type);
  62691. }
  62692. const attributes = new Map([
  62693. [AttributeAction.Exists, 10],
  62694. [AttributeAction.Equals, 8],
  62695. [AttributeAction.Not, 7],
  62696. [AttributeAction.Start, 6],
  62697. [AttributeAction.End, 6],
  62698. [AttributeAction.Any, 5],
  62699. ]);
  62700. /**
  62701. * Sort the parts of the passed selector,
  62702. * as there is potential for optimization
  62703. * (some types of selectors are faster than others)
  62704. *
  62705. * @param arr Selector to sort
  62706. */
  62707. function sortByProcedure(arr) {
  62708. const procs = arr.map(getProcedure);
  62709. for (let i = 1; i < arr.length; i++) {
  62710. const procNew = procs[i];
  62711. if (procNew < 0)
  62712. continue;
  62713. for (let j = i - 1; j >= 0 && procNew < procs[j]; j--) {
  62714. const token = arr[j + 1];
  62715. arr[j + 1] = arr[j];
  62716. arr[j] = token;
  62717. procs[j + 1] = procs[j];
  62718. procs[j] = procNew;
  62719. }
  62720. }
  62721. }
  62722. function getProcedure(token) {
  62723. var _a, _b;
  62724. let proc = (_a = procedure.get(token.type)) !== null && _a !== void 0 ? _a : -1;
  62725. if (token.type === SelectorType.Attribute) {
  62726. proc = (_b = attributes.get(token.action)) !== null && _b !== void 0 ? _b : 4;
  62727. if (token.action === AttributeAction.Equals && token.name === "id") {
  62728. // Prefer ID selectors (eg. #ID)
  62729. proc = 9;
  62730. }
  62731. if (token.ignoreCase) {
  62732. /*
  62733. * IgnoreCase adds some overhead, prefer "normal" token
  62734. * this is a binary operation, to ensure it's still an int
  62735. */
  62736. proc >>= 1;
  62737. }
  62738. }
  62739. else if (token.type === SelectorType.Pseudo) {
  62740. if (!token.data) {
  62741. proc = 3;
  62742. }
  62743. else if (token.name === "has" || token.name === "contains") {
  62744. proc = 0; // Expensive in any case
  62745. }
  62746. else if (Array.isArray(token.data)) {
  62747. // Eg. :matches, :not
  62748. proc = Math.min(...token.data.map((d) => Math.min(...d.map(getProcedure))));
  62749. // If we have traversals, try to avoid executing this selector
  62750. if (proc < 0) {
  62751. proc = 0;
  62752. }
  62753. }
  62754. else {
  62755. proc = 2;
  62756. }
  62757. }
  62758. return proc;
  62759. }
  62760. /**
  62761. * All reserved characters in a regex, used for escaping.
  62762. *
  62763. * Taken from XRegExp, (c) 2007-2020 Steven Levithan under the MIT license
  62764. * https://github.com/slevithan/xregexp/blob/95eeebeb8fac8754d54eafe2b4743661ac1cf028/src/xregexp.js#L794
  62765. */
  62766. const reChars = /[-[\]{}()*+?.,\\^$|#\s]/g;
  62767. function escapeRegex(value) {
  62768. return value.replace(reChars, "\\$&");
  62769. }
  62770. /**
  62771. * Attributes that are case-insensitive in HTML.
  62772. *
  62773. * @private
  62774. * @see https://html.spec.whatwg.org/multipage/semantics-other.html#case-sensitivity-of-selectors
  62775. */
  62776. const caseInsensitiveAttributes = new Set([
  62777. "accept",
  62778. "accept-charset",
  62779. "align",
  62780. "alink",
  62781. "axis",
  62782. "bgcolor",
  62783. "charset",
  62784. "checked",
  62785. "clear",
  62786. "codetype",
  62787. "color",
  62788. "compact",
  62789. "declare",
  62790. "defer",
  62791. "dir",
  62792. "direction",
  62793. "disabled",
  62794. "enctype",
  62795. "face",
  62796. "frame",
  62797. "hreflang",
  62798. "http-equiv",
  62799. "lang",
  62800. "language",
  62801. "link",
  62802. "media",
  62803. "method",
  62804. "multiple",
  62805. "nohref",
  62806. "noresize",
  62807. "noshade",
  62808. "nowrap",
  62809. "readonly",
  62810. "rel",
  62811. "rev",
  62812. "rules",
  62813. "scope",
  62814. "scrolling",
  62815. "selected",
  62816. "shape",
  62817. "target",
  62818. "text",
  62819. "type",
  62820. "valign",
  62821. "valuetype",
  62822. "vlink",
  62823. ]);
  62824. function shouldIgnoreCase(selector, options) {
  62825. return typeof selector.ignoreCase === "boolean"
  62826. ? selector.ignoreCase
  62827. : selector.ignoreCase === "quirks"
  62828. ? !!options.quirksMode
  62829. : !options.xmlMode && caseInsensitiveAttributes.has(selector.name);
  62830. }
  62831. /**
  62832. * Attribute selectors
  62833. */
  62834. const attributeRules = {
  62835. equals(next, data, options) {
  62836. const { adapter } = options;
  62837. const { name } = data;
  62838. let { value } = data;
  62839. if (shouldIgnoreCase(data, options)) {
  62840. value = value.toLowerCase();
  62841. return (elem) => {
  62842. const attr = adapter.getAttributeValue(elem, name);
  62843. return (attr != null &&
  62844. attr.length === value.length &&
  62845. attr.toLowerCase() === value &&
  62846. next(elem));
  62847. };
  62848. }
  62849. return (elem) => adapter.getAttributeValue(elem, name) === value && next(elem);
  62850. },
  62851. hyphen(next, data, options) {
  62852. const { adapter } = options;
  62853. const { name } = data;
  62854. let { value } = data;
  62855. const len = value.length;
  62856. if (shouldIgnoreCase(data, options)) {
  62857. value = value.toLowerCase();
  62858. return function hyphenIC(elem) {
  62859. const attr = adapter.getAttributeValue(elem, name);
  62860. return (attr != null &&
  62861. (attr.length === len || attr.charAt(len) === "-") &&
  62862. attr.substr(0, len).toLowerCase() === value &&
  62863. next(elem));
  62864. };
  62865. }
  62866. return function hyphen(elem) {
  62867. const attr = adapter.getAttributeValue(elem, name);
  62868. return (attr != null &&
  62869. (attr.length === len || attr.charAt(len) === "-") &&
  62870. attr.substr(0, len) === value &&
  62871. next(elem));
  62872. };
  62873. },
  62874. element(next, data, options) {
  62875. const { adapter } = options;
  62876. const { name, value } = data;
  62877. if (/\s/.test(value)) {
  62878. return boolbase.falseFunc;
  62879. }
  62880. const regex = new RegExp(`(?:^|\\s)${escapeRegex(value)}(?:$|\\s)`, shouldIgnoreCase(data, options) ? "i" : "");
  62881. return function element(elem) {
  62882. const attr = adapter.getAttributeValue(elem, name);
  62883. return (attr != null &&
  62884. attr.length >= value.length &&
  62885. regex.test(attr) &&
  62886. next(elem));
  62887. };
  62888. },
  62889. exists(next, { name }, { adapter }) {
  62890. return (elem) => adapter.hasAttrib(elem, name) && next(elem);
  62891. },
  62892. start(next, data, options) {
  62893. const { adapter } = options;
  62894. const { name } = data;
  62895. let { value } = data;
  62896. const len = value.length;
  62897. if (len === 0) {
  62898. return boolbase.falseFunc;
  62899. }
  62900. if (shouldIgnoreCase(data, options)) {
  62901. value = value.toLowerCase();
  62902. return (elem) => {
  62903. const attr = adapter.getAttributeValue(elem, name);
  62904. return (attr != null &&
  62905. attr.length >= len &&
  62906. attr.substr(0, len).toLowerCase() === value &&
  62907. next(elem));
  62908. };
  62909. }
  62910. return (elem) => {
  62911. var _a;
  62912. return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.startsWith(value)) &&
  62913. next(elem);
  62914. };
  62915. },
  62916. end(next, data, options) {
  62917. const { adapter } = options;
  62918. const { name } = data;
  62919. let { value } = data;
  62920. const len = -value.length;
  62921. if (len === 0) {
  62922. return boolbase.falseFunc;
  62923. }
  62924. if (shouldIgnoreCase(data, options)) {
  62925. value = value.toLowerCase();
  62926. return (elem) => {
  62927. var _a;
  62928. return ((_a = adapter
  62929. .getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.substr(len).toLowerCase()) === value && next(elem);
  62930. };
  62931. }
  62932. return (elem) => {
  62933. var _a;
  62934. return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.endsWith(value)) &&
  62935. next(elem);
  62936. };
  62937. },
  62938. any(next, data, options) {
  62939. const { adapter } = options;
  62940. const { name, value } = data;
  62941. if (value === "") {
  62942. return boolbase.falseFunc;
  62943. }
  62944. if (shouldIgnoreCase(data, options)) {
  62945. const regex = new RegExp(escapeRegex(value), "i");
  62946. return function anyIC(elem) {
  62947. const attr = adapter.getAttributeValue(elem, name);
  62948. return (attr != null &&
  62949. attr.length >= value.length &&
  62950. regex.test(attr) &&
  62951. next(elem));
  62952. };
  62953. }
  62954. return (elem) => {
  62955. var _a;
  62956. return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.includes(value)) &&
  62957. next(elem);
  62958. };
  62959. },
  62960. not(next, data, options) {
  62961. const { adapter } = options;
  62962. const { name } = data;
  62963. let { value } = data;
  62964. if (value === "") {
  62965. return (elem) => !!adapter.getAttributeValue(elem, name) && next(elem);
  62966. }
  62967. else if (shouldIgnoreCase(data, options)) {
  62968. value = value.toLowerCase();
  62969. return (elem) => {
  62970. const attr = adapter.getAttributeValue(elem, name);
  62971. return ((attr == null ||
  62972. attr.length !== value.length ||
  62973. attr.toLowerCase() !== value) &&
  62974. next(elem));
  62975. };
  62976. }
  62977. return (elem) => adapter.getAttributeValue(elem, name) !== value && next(elem);
  62978. },
  62979. };
  62980. // Following http://www.w3.org/TR/css3-selectors/#nth-child-pseudo
  62981. // Whitespace as per https://www.w3.org/TR/selectors-3/#lex is " \t\r\n\f"
  62982. const whitespace$1 = new Set([9, 10, 12, 13, 32]);
  62983. const ZERO = "0".charCodeAt(0);
  62984. const NINE = "9".charCodeAt(0);
  62985. /**
  62986. * Parses an expression.
  62987. *
  62988. * @throws An `Error` if parsing fails.
  62989. * @returns An array containing the integer step size and the integer offset of the nth rule.
  62990. * @example nthCheck.parse("2n+3"); // returns [2, 3]
  62991. */
  62992. function parse$1(formula) {
  62993. formula = formula.trim().toLowerCase();
  62994. if (formula === "even") {
  62995. return [2, 0];
  62996. }
  62997. else if (formula === "odd") {
  62998. return [2, 1];
  62999. }
  63000. // Parse [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]?
  63001. let idx = 0;
  63002. let a = 0;
  63003. let sign = readSign();
  63004. let number = readNumber();
  63005. if (idx < formula.length && formula.charAt(idx) === "n") {
  63006. idx++;
  63007. a = sign * (number !== null && number !== void 0 ? number : 1);
  63008. skipWhitespace();
  63009. if (idx < formula.length) {
  63010. sign = readSign();
  63011. skipWhitespace();
  63012. number = readNumber();
  63013. }
  63014. else {
  63015. sign = number = 0;
  63016. }
  63017. }
  63018. // Throw if there is anything else
  63019. if (number === null || idx < formula.length) {
  63020. throw new Error(`n-th rule couldn't be parsed ('${formula}')`);
  63021. }
  63022. return [a, sign * number];
  63023. function readSign() {
  63024. if (formula.charAt(idx) === "-") {
  63025. idx++;
  63026. return -1;
  63027. }
  63028. if (formula.charAt(idx) === "+") {
  63029. idx++;
  63030. }
  63031. return 1;
  63032. }
  63033. function readNumber() {
  63034. const start = idx;
  63035. let value = 0;
  63036. while (idx < formula.length &&
  63037. formula.charCodeAt(idx) >= ZERO &&
  63038. formula.charCodeAt(idx) <= NINE) {
  63039. value = value * 10 + (formula.charCodeAt(idx) - ZERO);
  63040. idx++;
  63041. }
  63042. // Return `null` if we didn't read anything.
  63043. return idx === start ? null : value;
  63044. }
  63045. function skipWhitespace() {
  63046. while (idx < formula.length &&
  63047. whitespace$1.has(formula.charCodeAt(idx))) {
  63048. idx++;
  63049. }
  63050. }
  63051. }
  63052. /**
  63053. * Returns a function that checks if an elements index matches the given rule
  63054. * highly optimized to return the fastest solution.
  63055. *
  63056. * @param parsed A tuple [a, b], as returned by `parse`.
  63057. * @returns A highly optimized function that returns whether an index matches the nth-check.
  63058. * @example
  63059. *
  63060. * ```js
  63061. * const check = nthCheck.compile([2, 3]);
  63062. *
  63063. * check(0); // `false`
  63064. * check(1); // `false`
  63065. * check(2); // `true`
  63066. * check(3); // `false`
  63067. * check(4); // `true`
  63068. * check(5); // `false`
  63069. * check(6); // `true`
  63070. * ```
  63071. */
  63072. function compile(parsed) {
  63073. const a = parsed[0];
  63074. // Subtract 1 from `b`, to convert from one- to zero-indexed.
  63075. const b = parsed[1] - 1;
  63076. /*
  63077. * When `b <= 0`, `a * n` won't be lead to any matches for `a < 0`.
  63078. * Besides, the specification states that no elements are
  63079. * matched when `a` and `b` are 0.
  63080. *
  63081. * `b < 0` here as we subtracted 1 from `b` above.
  63082. */
  63083. if (b < 0 && a <= 0)
  63084. return boolbase_2;
  63085. // When `a` is in the range -1..1, it matches any element (so only `b` is checked).
  63086. if (a === -1)
  63087. return (index) => index <= b;
  63088. if (a === 0)
  63089. return (index) => index === b;
  63090. // When `b <= 0` and `a === 1`, they match any element.
  63091. if (a === 1)
  63092. return b < 0 ? boolbase_1 : (index) => index >= b;
  63093. /*
  63094. * Otherwise, modulo can be used to check if there is a match.
  63095. *
  63096. * Modulo doesn't care about the sign, so let's use `a`s absolute value.
  63097. */
  63098. const absA = Math.abs(a);
  63099. // Get `b mod a`, + a if this is negative.
  63100. const bMod = ((b % absA) + absA) % absA;
  63101. return a > 1
  63102. ? (index) => index >= b && index % absA === bMod
  63103. : (index) => index <= b && index % absA === bMod;
  63104. }
  63105. /**
  63106. * Parses and compiles a formula to a highly optimized function.
  63107. * Combination of {@link parse} and {@link compile}.
  63108. *
  63109. * If the formula doesn't match any elements,
  63110. * it returns [`boolbase`](https://github.com/fb55/boolbase)'s `falseFunc`.
  63111. * Otherwise, a function accepting an _index_ is returned, which returns
  63112. * whether or not the passed _index_ matches the formula.
  63113. *
  63114. * Note: The nth-rule starts counting at `1`, the returned function at `0`.
  63115. *
  63116. * @param formula The formula to compile.
  63117. * @example
  63118. * const check = nthCheck("2n+3");
  63119. *
  63120. * check(0); // `false`
  63121. * check(1); // `false`
  63122. * check(2); // `true`
  63123. * check(3); // `false`
  63124. * check(4); // `true`
  63125. * check(5); // `false`
  63126. * check(6); // `true`
  63127. */
  63128. function nthCheck(formula) {
  63129. return compile(parse$1(formula));
  63130. }
  63131. function getChildFunc(next, adapter) {
  63132. return (elem) => {
  63133. const parent = adapter.getParent(elem);
  63134. return parent != null && adapter.isTag(parent) && next(elem);
  63135. };
  63136. }
  63137. const filters = {
  63138. contains(next, text, { adapter }) {
  63139. return function contains(elem) {
  63140. return next(elem) && adapter.getText(elem).includes(text);
  63141. };
  63142. },
  63143. icontains(next, text, { adapter }) {
  63144. const itext = text.toLowerCase();
  63145. return function icontains(elem) {
  63146. return (next(elem) &&
  63147. adapter.getText(elem).toLowerCase().includes(itext));
  63148. };
  63149. },
  63150. // Location specific methods
  63151. "nth-child"(next, rule, { adapter, equals }) {
  63152. const func = nthCheck(rule);
  63153. if (func === boolbase.falseFunc)
  63154. return boolbase.falseFunc;
  63155. if (func === boolbase.trueFunc)
  63156. return getChildFunc(next, adapter);
  63157. return function nthChild(elem) {
  63158. const siblings = adapter.getSiblings(elem);
  63159. let pos = 0;
  63160. for (let i = 0; i < siblings.length; i++) {
  63161. if (equals(elem, siblings[i]))
  63162. break;
  63163. if (adapter.isTag(siblings[i])) {
  63164. pos++;
  63165. }
  63166. }
  63167. return func(pos) && next(elem);
  63168. };
  63169. },
  63170. "nth-last-child"(next, rule, { adapter, equals }) {
  63171. const func = nthCheck(rule);
  63172. if (func === boolbase.falseFunc)
  63173. return boolbase.falseFunc;
  63174. if (func === boolbase.trueFunc)
  63175. return getChildFunc(next, adapter);
  63176. return function nthLastChild(elem) {
  63177. const siblings = adapter.getSiblings(elem);
  63178. let pos = 0;
  63179. for (let i = siblings.length - 1; i >= 0; i--) {
  63180. if (equals(elem, siblings[i]))
  63181. break;
  63182. if (adapter.isTag(siblings[i])) {
  63183. pos++;
  63184. }
  63185. }
  63186. return func(pos) && next(elem);
  63187. };
  63188. },
  63189. "nth-of-type"(next, rule, { adapter, equals }) {
  63190. const func = nthCheck(rule);
  63191. if (func === boolbase.falseFunc)
  63192. return boolbase.falseFunc;
  63193. if (func === boolbase.trueFunc)
  63194. return getChildFunc(next, adapter);
  63195. return function nthOfType(elem) {
  63196. const siblings = adapter.getSiblings(elem);
  63197. let pos = 0;
  63198. for (let i = 0; i < siblings.length; i++) {
  63199. const currentSibling = siblings[i];
  63200. if (equals(elem, currentSibling))
  63201. break;
  63202. if (adapter.isTag(currentSibling) &&
  63203. adapter.getName(currentSibling) === adapter.getName(elem)) {
  63204. pos++;
  63205. }
  63206. }
  63207. return func(pos) && next(elem);
  63208. };
  63209. },
  63210. "nth-last-of-type"(next, rule, { adapter, equals }) {
  63211. const func = nthCheck(rule);
  63212. if (func === boolbase.falseFunc)
  63213. return boolbase.falseFunc;
  63214. if (func === boolbase.trueFunc)
  63215. return getChildFunc(next, adapter);
  63216. return function nthLastOfType(elem) {
  63217. const siblings = adapter.getSiblings(elem);
  63218. let pos = 0;
  63219. for (let i = siblings.length - 1; i >= 0; i--) {
  63220. const currentSibling = siblings[i];
  63221. if (equals(elem, currentSibling))
  63222. break;
  63223. if (adapter.isTag(currentSibling) &&
  63224. adapter.getName(currentSibling) === adapter.getName(elem)) {
  63225. pos++;
  63226. }
  63227. }
  63228. return func(pos) && next(elem);
  63229. };
  63230. },
  63231. // TODO determine the actual root element
  63232. root(next, _rule, { adapter }) {
  63233. return (elem) => {
  63234. const parent = adapter.getParent(elem);
  63235. return (parent == null || !adapter.isTag(parent)) && next(elem);
  63236. };
  63237. },
  63238. scope(next, rule, options, context) {
  63239. const { equals } = options;
  63240. if (!context || context.length === 0) {
  63241. // Equivalent to :root
  63242. return filters["root"](next, rule, options);
  63243. }
  63244. if (context.length === 1) {
  63245. // NOTE: can't be unpacked, as :has uses this for side-effects
  63246. return (elem) => equals(context[0], elem) && next(elem);
  63247. }
  63248. return (elem) => context.includes(elem) && next(elem);
  63249. },
  63250. hover: dynamicStatePseudo("isHovered"),
  63251. visited: dynamicStatePseudo("isVisited"),
  63252. active: dynamicStatePseudo("isActive"),
  63253. };
  63254. /**
  63255. * Dynamic state pseudos. These depend on optional Adapter methods.
  63256. *
  63257. * @param name The name of the adapter method to call.
  63258. * @returns Pseudo for the `filters` object.
  63259. */
  63260. function dynamicStatePseudo(name) {
  63261. return function dynamicPseudo(next, _rule, { adapter }) {
  63262. const func = adapter[name];
  63263. if (typeof func !== "function") {
  63264. return boolbase.falseFunc;
  63265. }
  63266. return function active(elem) {
  63267. return func(elem) && next(elem);
  63268. };
  63269. };
  63270. }
  63271. // While filters are precompiled, pseudos get called when they are needed
  63272. const pseudos = {
  63273. empty(elem, { adapter }) {
  63274. return !adapter.getChildren(elem).some((elem) =>
  63275. // FIXME: `getText` call is potentially expensive.
  63276. adapter.isTag(elem) || adapter.getText(elem) !== "");
  63277. },
  63278. "first-child"(elem, { adapter, equals }) {
  63279. if (adapter.prevElementSibling) {
  63280. return adapter.prevElementSibling(elem) == null;
  63281. }
  63282. const firstChild = adapter
  63283. .getSiblings(elem)
  63284. .find((elem) => adapter.isTag(elem));
  63285. return firstChild != null && equals(elem, firstChild);
  63286. },
  63287. "last-child"(elem, { adapter, equals }) {
  63288. const siblings = adapter.getSiblings(elem);
  63289. for (let i = siblings.length - 1; i >= 0; i--) {
  63290. if (equals(elem, siblings[i]))
  63291. return true;
  63292. if (adapter.isTag(siblings[i]))
  63293. break;
  63294. }
  63295. return false;
  63296. },
  63297. "first-of-type"(elem, { adapter, equals }) {
  63298. const siblings = adapter.getSiblings(elem);
  63299. const elemName = adapter.getName(elem);
  63300. for (let i = 0; i < siblings.length; i++) {
  63301. const currentSibling = siblings[i];
  63302. if (equals(elem, currentSibling))
  63303. return true;
  63304. if (adapter.isTag(currentSibling) &&
  63305. adapter.getName(currentSibling) === elemName) {
  63306. break;
  63307. }
  63308. }
  63309. return false;
  63310. },
  63311. "last-of-type"(elem, { adapter, equals }) {
  63312. const siblings = adapter.getSiblings(elem);
  63313. const elemName = adapter.getName(elem);
  63314. for (let i = siblings.length - 1; i >= 0; i--) {
  63315. const currentSibling = siblings[i];
  63316. if (equals(elem, currentSibling))
  63317. return true;
  63318. if (adapter.isTag(currentSibling) &&
  63319. adapter.getName(currentSibling) === elemName) {
  63320. break;
  63321. }
  63322. }
  63323. return false;
  63324. },
  63325. "only-of-type"(elem, { adapter, equals }) {
  63326. const elemName = adapter.getName(elem);
  63327. return adapter
  63328. .getSiblings(elem)
  63329. .every((sibling) => equals(elem, sibling) ||
  63330. !adapter.isTag(sibling) ||
  63331. adapter.getName(sibling) !== elemName);
  63332. },
  63333. "only-child"(elem, { adapter, equals }) {
  63334. return adapter
  63335. .getSiblings(elem)
  63336. .every((sibling) => equals(elem, sibling) || !adapter.isTag(sibling));
  63337. },
  63338. };
  63339. function verifyPseudoArgs(func, name, subselect, argIndex) {
  63340. if (subselect === null) {
  63341. if (func.length > argIndex) {
  63342. throw new Error(`Pseudo-class :${name} requires an argument`);
  63343. }
  63344. }
  63345. else if (func.length === argIndex) {
  63346. throw new Error(`Pseudo-class :${name} doesn't have any arguments`);
  63347. }
  63348. }
  63349. /**
  63350. * Aliases are pseudos that are expressed as selectors.
  63351. */
  63352. const aliases = {
  63353. // Links
  63354. "any-link": ":is(a, area, link)[href]",
  63355. link: ":any-link:not(:visited)",
  63356. // Forms
  63357. // https://html.spec.whatwg.org/multipage/scripting.html#disabled-elements
  63358. disabled: `:is(
  63359. :is(button, input, select, textarea, optgroup, option)[disabled],
  63360. optgroup[disabled] > option,
  63361. fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *)
  63362. )`,
  63363. enabled: ":not(:disabled)",
  63364. checked: ":is(:is(input[type=radio], input[type=checkbox])[checked], option:selected)",
  63365. required: ":is(input, select, textarea)[required]",
  63366. optional: ":is(input, select, textarea):not([required])",
  63367. // JQuery extensions
  63368. // https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-selectedness
  63369. selected: "option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)",
  63370. checkbox: "[type=checkbox]",
  63371. file: "[type=file]",
  63372. password: "[type=password]",
  63373. radio: "[type=radio]",
  63374. reset: "[type=reset]",
  63375. image: "[type=image]",
  63376. submit: "[type=submit]",
  63377. parent: ":not(:empty)",
  63378. header: ":is(h1, h2, h3, h4, h5, h6)",
  63379. button: ":is(button, input[type=button])",
  63380. input: ":is(input, textarea, select, button)",
  63381. text: "input:is(:not([type!='']), [type=text])",
  63382. };
  63383. /** Used as a placeholder for :has. Will be replaced with the actual element. */
  63384. const PLACEHOLDER_ELEMENT = {};
  63385. function ensureIsTag(next, adapter) {
  63386. if (next === boolbase.falseFunc)
  63387. return boolbase.falseFunc;
  63388. return (elem) => adapter.isTag(elem) && next(elem);
  63389. }
  63390. function getNextSiblings(elem, adapter) {
  63391. const siblings = adapter.getSiblings(elem);
  63392. if (siblings.length <= 1)
  63393. return [];
  63394. const elemIndex = siblings.indexOf(elem);
  63395. if (elemIndex < 0 || elemIndex === siblings.length - 1)
  63396. return [];
  63397. return siblings.slice(elemIndex + 1).filter(adapter.isTag);
  63398. }
  63399. function copyOptions(options) {
  63400. // Not copied: context, rootFunc
  63401. return {
  63402. xmlMode: !!options.xmlMode,
  63403. lowerCaseAttributeNames: !!options.lowerCaseAttributeNames,
  63404. lowerCaseTags: !!options.lowerCaseTags,
  63405. quirksMode: !!options.quirksMode,
  63406. cacheResults: !!options.cacheResults,
  63407. pseudos: options.pseudos,
  63408. adapter: options.adapter,
  63409. equals: options.equals,
  63410. };
  63411. }
  63412. const is = (next, token, options, context, compileToken) => {
  63413. const func = compileToken(token, copyOptions(options), context);
  63414. return func === boolbase.trueFunc
  63415. ? next
  63416. : func === boolbase.falseFunc
  63417. ? boolbase.falseFunc
  63418. : (elem) => func(elem) && next(elem);
  63419. };
  63420. /*
  63421. * :not, :has, :is, :matches and :where have to compile selectors
  63422. * doing this in src/pseudos.ts would lead to circular dependencies,
  63423. * so we add them here
  63424. */
  63425. const subselects = {
  63426. is,
  63427. /**
  63428. * `:matches` and `:where` are aliases for `:is`.
  63429. */
  63430. matches: is,
  63431. where: is,
  63432. not(next, token, options, context, compileToken) {
  63433. const func = compileToken(token, copyOptions(options), context);
  63434. return func === boolbase.falseFunc
  63435. ? next
  63436. : func === boolbase.trueFunc
  63437. ? boolbase.falseFunc
  63438. : (elem) => !func(elem) && next(elem);
  63439. },
  63440. has(next, subselect, options, _context, compileToken) {
  63441. const { adapter } = options;
  63442. const opts = copyOptions(options);
  63443. opts.relativeSelector = true;
  63444. const context = subselect.some((s) => s.some(isTraversal$1))
  63445. ? // Used as a placeholder. Will be replaced with the actual element.
  63446. [PLACEHOLDER_ELEMENT]
  63447. : undefined;
  63448. const compiled = compileToken(subselect, opts, context);
  63449. if (compiled === boolbase.falseFunc)
  63450. return boolbase.falseFunc;
  63451. const hasElement = ensureIsTag(compiled, adapter);
  63452. // If `compiled` is `trueFunc`, we can skip this.
  63453. if (context && compiled !== boolbase.trueFunc) {
  63454. /*
  63455. * `shouldTestNextSiblings` will only be true if the query starts with
  63456. * a traversal (sibling or adjacent). That means we will always have a context.
  63457. */
  63458. const { shouldTestNextSiblings = false } = compiled;
  63459. return (elem) => {
  63460. if (!next(elem))
  63461. return false;
  63462. context[0] = elem;
  63463. const childs = adapter.getChildren(elem);
  63464. const nextElements = shouldTestNextSiblings
  63465. ? [...childs, ...getNextSiblings(elem, adapter)]
  63466. : childs;
  63467. return adapter.existsOne(hasElement, nextElements);
  63468. };
  63469. }
  63470. return (elem) => next(elem) &&
  63471. adapter.existsOne(hasElement, adapter.getChildren(elem));
  63472. },
  63473. };
  63474. function compilePseudoSelector(next, selector, options, context, compileToken) {
  63475. var _a;
  63476. const { name, data } = selector;
  63477. if (Array.isArray(data)) {
  63478. if (!(name in subselects)) {
  63479. throw new Error(`Unknown pseudo-class :${name}(${data})`);
  63480. }
  63481. return subselects[name](next, data, options, context, compileToken);
  63482. }
  63483. const userPseudo = (_a = options.pseudos) === null || _a === void 0 ? void 0 : _a[name];
  63484. const stringPseudo = typeof userPseudo === "string" ? userPseudo : aliases[name];
  63485. if (typeof stringPseudo === "string") {
  63486. if (data != null) {
  63487. throw new Error(`Pseudo ${name} doesn't have any arguments`);
  63488. }
  63489. // The alias has to be parsed here, to make sure options are respected.
  63490. const alias = parse(stringPseudo);
  63491. return subselects["is"](next, alias, options, context, compileToken);
  63492. }
  63493. if (typeof userPseudo === "function") {
  63494. verifyPseudoArgs(userPseudo, name, data, 1);
  63495. return (elem) => userPseudo(elem, data) && next(elem);
  63496. }
  63497. if (name in filters) {
  63498. return filters[name](next, data, options, context);
  63499. }
  63500. if (name in pseudos) {
  63501. const pseudo = pseudos[name];
  63502. verifyPseudoArgs(pseudo, name, data, 2);
  63503. return (elem) => pseudo(elem, options, data) && next(elem);
  63504. }
  63505. throw new Error(`Unknown pseudo-class :${name}`);
  63506. }
  63507. function getElementParent(node, adapter) {
  63508. const parent = adapter.getParent(node);
  63509. if (parent && adapter.isTag(parent)) {
  63510. return parent;
  63511. }
  63512. return null;
  63513. }
  63514. /*
  63515. * All available rules
  63516. */
  63517. function compileGeneralSelector(next, selector, options, context, compileToken) {
  63518. const { adapter, equals } = options;
  63519. switch (selector.type) {
  63520. case SelectorType.PseudoElement: {
  63521. throw new Error("Pseudo-elements are not supported by css-select");
  63522. }
  63523. case SelectorType.ColumnCombinator: {
  63524. throw new Error("Column combinators are not yet supported by css-select");
  63525. }
  63526. case SelectorType.Attribute: {
  63527. if (selector.namespace != null) {
  63528. throw new Error("Namespaced attributes are not yet supported by css-select");
  63529. }
  63530. if (!options.xmlMode || options.lowerCaseAttributeNames) {
  63531. selector.name = selector.name.toLowerCase();
  63532. }
  63533. return attributeRules[selector.action](next, selector, options);
  63534. }
  63535. case SelectorType.Pseudo: {
  63536. return compilePseudoSelector(next, selector, options, context, compileToken);
  63537. }
  63538. // Tags
  63539. case SelectorType.Tag: {
  63540. if (selector.namespace != null) {
  63541. throw new Error("Namespaced tag names are not yet supported by css-select");
  63542. }
  63543. let { name } = selector;
  63544. if (!options.xmlMode || options.lowerCaseTags) {
  63545. name = name.toLowerCase();
  63546. }
  63547. return function tag(elem) {
  63548. return adapter.getName(elem) === name && next(elem);
  63549. };
  63550. }
  63551. // Traversal
  63552. case SelectorType.Descendant: {
  63553. if (options.cacheResults === false ||
  63554. typeof WeakSet === "undefined") {
  63555. return function descendant(elem) {
  63556. let current = elem;
  63557. while ((current = getElementParent(current, adapter))) {
  63558. if (next(current)) {
  63559. return true;
  63560. }
  63561. }
  63562. return false;
  63563. };
  63564. }
  63565. // @ts-expect-error `ElementNode` is not extending object
  63566. const isFalseCache = new WeakSet();
  63567. return function cachedDescendant(elem) {
  63568. let current = elem;
  63569. while ((current = getElementParent(current, adapter))) {
  63570. if (!isFalseCache.has(current)) {
  63571. if (adapter.isTag(current) && next(current)) {
  63572. return true;
  63573. }
  63574. isFalseCache.add(current);
  63575. }
  63576. }
  63577. return false;
  63578. };
  63579. }
  63580. case "_flexibleDescendant": {
  63581. // Include element itself, only used while querying an array
  63582. return function flexibleDescendant(elem) {
  63583. let current = elem;
  63584. do {
  63585. if (next(current))
  63586. return true;
  63587. } while ((current = getElementParent(current, adapter)));
  63588. return false;
  63589. };
  63590. }
  63591. case SelectorType.Parent: {
  63592. return function parent(elem) {
  63593. return adapter
  63594. .getChildren(elem)
  63595. .some((elem) => adapter.isTag(elem) && next(elem));
  63596. };
  63597. }
  63598. case SelectorType.Child: {
  63599. return function child(elem) {
  63600. const parent = adapter.getParent(elem);
  63601. return parent != null && adapter.isTag(parent) && next(parent);
  63602. };
  63603. }
  63604. case SelectorType.Sibling: {
  63605. return function sibling(elem) {
  63606. const siblings = adapter.getSiblings(elem);
  63607. for (let i = 0; i < siblings.length; i++) {
  63608. const currentSibling = siblings[i];
  63609. if (equals(elem, currentSibling))
  63610. break;
  63611. if (adapter.isTag(currentSibling) && next(currentSibling)) {
  63612. return true;
  63613. }
  63614. }
  63615. return false;
  63616. };
  63617. }
  63618. case SelectorType.Adjacent: {
  63619. if (adapter.prevElementSibling) {
  63620. return function adjacent(elem) {
  63621. const previous = adapter.prevElementSibling(elem);
  63622. return previous != null && next(previous);
  63623. };
  63624. }
  63625. return function adjacent(elem) {
  63626. const siblings = adapter.getSiblings(elem);
  63627. let lastElement;
  63628. for (let i = 0; i < siblings.length; i++) {
  63629. const currentSibling = siblings[i];
  63630. if (equals(elem, currentSibling))
  63631. break;
  63632. if (adapter.isTag(currentSibling)) {
  63633. lastElement = currentSibling;
  63634. }
  63635. }
  63636. return !!lastElement && next(lastElement);
  63637. };
  63638. }
  63639. case SelectorType.Universal: {
  63640. if (selector.namespace != null && selector.namespace !== "*") {
  63641. throw new Error("Namespaced universal selectors are not yet supported by css-select");
  63642. }
  63643. return next;
  63644. }
  63645. }
  63646. }
  63647. function includesScopePseudo(t) {
  63648. return (t.type === SelectorType.Pseudo &&
  63649. (t.name === "scope" ||
  63650. (Array.isArray(t.data) &&
  63651. t.data.some((data) => data.some(includesScopePseudo)))));
  63652. }
  63653. const DESCENDANT_TOKEN = { type: SelectorType.Descendant };
  63654. const FLEXIBLE_DESCENDANT_TOKEN = {
  63655. type: "_flexibleDescendant",
  63656. };
  63657. const SCOPE_TOKEN = {
  63658. type: SelectorType.Pseudo,
  63659. name: "scope",
  63660. data: null,
  63661. };
  63662. /*
  63663. * CSS 4 Spec (Draft): 3.4.1. Absolutizing a Relative Selector
  63664. * http://www.w3.org/TR/selectors4/#absolutizing
  63665. */
  63666. function absolutize(token, { adapter }, context) {
  63667. // TODO Use better check if the context is a document
  63668. const hasContext = !!(context === null || context === void 0 ? void 0 : context.every((e) => {
  63669. const parent = adapter.isTag(e) && adapter.getParent(e);
  63670. return e === PLACEHOLDER_ELEMENT || (parent && adapter.isTag(parent));
  63671. }));
  63672. for (const t of token) {
  63673. if (t.length > 0 &&
  63674. isTraversal$1(t[0]) &&
  63675. t[0].type !== SelectorType.Descendant) ;
  63676. else if (hasContext && !t.some(includesScopePseudo)) {
  63677. t.unshift(DESCENDANT_TOKEN);
  63678. }
  63679. else {
  63680. continue;
  63681. }
  63682. t.unshift(SCOPE_TOKEN);
  63683. }
  63684. }
  63685. function compileToken(token, options, context) {
  63686. var _a;
  63687. token.forEach(sortByProcedure);
  63688. context = (_a = options.context) !== null && _a !== void 0 ? _a : context;
  63689. const isArrayContext = Array.isArray(context);
  63690. const finalContext = context && (Array.isArray(context) ? context : [context]);
  63691. // Check if the selector is relative
  63692. if (options.relativeSelector !== false) {
  63693. absolutize(token, options, finalContext);
  63694. }
  63695. else if (token.some((t) => t.length > 0 && isTraversal$1(t[0]))) {
  63696. throw new Error("Relative selectors are not allowed when the `relativeSelector` option is disabled");
  63697. }
  63698. let shouldTestNextSiblings = false;
  63699. const query = token
  63700. .map((rules) => {
  63701. if (rules.length >= 2) {
  63702. const [first, second] = rules;
  63703. if (first.type !== SelectorType.Pseudo ||
  63704. first.name !== "scope") ;
  63705. else if (isArrayContext &&
  63706. second.type === SelectorType.Descendant) {
  63707. rules[1] = FLEXIBLE_DESCENDANT_TOKEN;
  63708. }
  63709. else if (second.type === SelectorType.Adjacent ||
  63710. second.type === SelectorType.Sibling) {
  63711. shouldTestNextSiblings = true;
  63712. }
  63713. }
  63714. return compileRules(rules, options, finalContext);
  63715. })
  63716. .reduce(reduceRules, boolbase.falseFunc);
  63717. query.shouldTestNextSiblings = shouldTestNextSiblings;
  63718. return query;
  63719. }
  63720. function compileRules(rules, options, context) {
  63721. var _a;
  63722. return rules.reduce((previous, rule) => previous === boolbase.falseFunc
  63723. ? boolbase.falseFunc
  63724. : compileGeneralSelector(previous, rule, options, context, compileToken), (_a = options.rootFunc) !== null && _a !== void 0 ? _a : boolbase.trueFunc);
  63725. }
  63726. function reduceRules(a, b) {
  63727. if (b === boolbase.falseFunc || a === boolbase.trueFunc) {
  63728. return a;
  63729. }
  63730. if (a === boolbase.falseFunc || b === boolbase.trueFunc) {
  63731. return b;
  63732. }
  63733. return function combine(elem) {
  63734. return a(elem) || b(elem);
  63735. };
  63736. }
  63737. const defaultEquals = (a, b) => a === b;
  63738. const defaultOptions$1 = {
  63739. adapter: DomUtils,
  63740. equals: defaultEquals,
  63741. };
  63742. function convertOptionFormats(options) {
  63743. var _a, _b, _c, _d;
  63744. /*
  63745. * We force one format of options to the other one.
  63746. */
  63747. // @ts-expect-error Default options may have incompatible `Node` / `ElementNode`.
  63748. const opts = options !== null && options !== void 0 ? options : defaultOptions$1;
  63749. // @ts-expect-error Same as above.
  63750. (_a = opts.adapter) !== null && _a !== void 0 ? _a : (opts.adapter = DomUtils);
  63751. // @ts-expect-error `equals` does not exist on `Options`
  63752. (_b = opts.equals) !== null && _b !== void 0 ? _b : (opts.equals = (_d = (_c = opts.adapter) === null || _c === void 0 ? void 0 : _c.equals) !== null && _d !== void 0 ? _d : defaultEquals);
  63753. return opts;
  63754. }
  63755. function wrapCompile(func) {
  63756. return function addAdapter(selector, options, context) {
  63757. const opts = convertOptionFormats(options);
  63758. return func(selector, opts, context);
  63759. };
  63760. }
  63761. const _compileToken = wrapCompile(compileToken);
  63762. function prepareContext(elems, adapter, shouldTestNextSiblings = false) {
  63763. /*
  63764. * Add siblings if the query requires them.
  63765. * See https://github.com/fb55/css-select/pull/43#issuecomment-225414692
  63766. */
  63767. if (shouldTestNextSiblings) {
  63768. elems = appendNextSiblings(elems, adapter);
  63769. }
  63770. return Array.isArray(elems)
  63771. ? adapter.removeSubsets(elems)
  63772. : adapter.getChildren(elems);
  63773. }
  63774. function appendNextSiblings(elem, adapter) {
  63775. // Order matters because jQuery seems to check the children before the siblings
  63776. const elems = Array.isArray(elem) ? elem.slice(0) : [elem];
  63777. const elemsLength = elems.length;
  63778. for (let i = 0; i < elemsLength; i++) {
  63779. const nextSiblings = getNextSiblings(elems[i], adapter);
  63780. elems.push(...nextSiblings);
  63781. }
  63782. return elems;
  63783. }
  63784. const filterNames = new Set([
  63785. "first",
  63786. "last",
  63787. "eq",
  63788. "gt",
  63789. "nth",
  63790. "lt",
  63791. "even",
  63792. "odd",
  63793. ]);
  63794. function isFilter(s) {
  63795. if (s.type !== "pseudo")
  63796. return false;
  63797. if (filterNames.has(s.name))
  63798. return true;
  63799. if (s.name === "not" && Array.isArray(s.data)) {
  63800. // Only consider `:not` with embedded filters
  63801. return s.data.some((s) => s.some(isFilter));
  63802. }
  63803. return false;
  63804. }
  63805. function getLimit(filter, data, partLimit) {
  63806. const num = data != null ? parseInt(data, 10) : NaN;
  63807. switch (filter) {
  63808. case "first":
  63809. return 1;
  63810. case "nth":
  63811. case "eq":
  63812. return isFinite(num) ? (num >= 0 ? num + 1 : Infinity) : 0;
  63813. case "lt":
  63814. return isFinite(num)
  63815. ? num >= 0
  63816. ? Math.min(num, partLimit)
  63817. : Infinity
  63818. : 0;
  63819. case "gt":
  63820. return isFinite(num) ? Infinity : 0;
  63821. case "odd":
  63822. return 2 * partLimit;
  63823. case "even":
  63824. return 2 * partLimit - 1;
  63825. case "last":
  63826. case "not":
  63827. return Infinity;
  63828. }
  63829. }
  63830. function getDocumentRoot(node) {
  63831. while (node.parent)
  63832. node = node.parent;
  63833. return node;
  63834. }
  63835. function groupSelectors(selectors) {
  63836. const filteredSelectors = [];
  63837. const plainSelectors = [];
  63838. for (const selector of selectors) {
  63839. if (selector.some(isFilter)) {
  63840. filteredSelectors.push(selector);
  63841. }
  63842. else {
  63843. plainSelectors.push(selector);
  63844. }
  63845. }
  63846. return [plainSelectors, filteredSelectors];
  63847. }
  63848. const UNIVERSAL_SELECTOR = {
  63849. type: SelectorType.Universal,
  63850. namespace: null,
  63851. };
  63852. const SCOPE_PSEUDO = {
  63853. type: SelectorType.Pseudo,
  63854. name: "scope",
  63855. data: null,
  63856. };
  63857. function is$1(element, selector, options = {}) {
  63858. return some$4([element], selector, options);
  63859. }
  63860. function some$4(elements, selector, options = {}) {
  63861. if (typeof selector === "function")
  63862. return elements.some(selector);
  63863. const [plain, filtered] = groupSelectors(parse(selector));
  63864. return ((plain.length > 0 && elements.some(_compileToken(plain, options))) ||
  63865. filtered.some((sel) => filterBySelector(sel, elements, options).length > 0));
  63866. }
  63867. function filterByPosition(filter, elems, data, options) {
  63868. const num = typeof data === "string" ? parseInt(data, 10) : NaN;
  63869. switch (filter) {
  63870. case "first":
  63871. case "lt":
  63872. // Already done in `getLimit`
  63873. return elems;
  63874. case "last":
  63875. return elems.length > 0 ? [elems[elems.length - 1]] : elems;
  63876. case "nth":
  63877. case "eq":
  63878. return isFinite(num) && Math.abs(num) < elems.length
  63879. ? [num < 0 ? elems[elems.length + num] : elems[num]]
  63880. : [];
  63881. case "gt":
  63882. return isFinite(num) ? elems.slice(num + 1) : [];
  63883. case "even":
  63884. return elems.filter((_, i) => i % 2 === 0);
  63885. case "odd":
  63886. return elems.filter((_, i) => i % 2 === 1);
  63887. case "not": {
  63888. const filtered = new Set(filterParsed(data, elems, options));
  63889. return elems.filter((e) => !filtered.has(e));
  63890. }
  63891. }
  63892. }
  63893. function filter$5(selector, elements, options = {}) {
  63894. return filterParsed(parse(selector), elements, options);
  63895. }
  63896. /**
  63897. * Filter a set of elements by a selector.
  63898. *
  63899. * Will return elements in the original order.
  63900. *
  63901. * @param selector Selector to filter by.
  63902. * @param elements Elements to filter.
  63903. * @param options Options for selector.
  63904. */
  63905. function filterParsed(selector, elements, options) {
  63906. if (elements.length === 0)
  63907. return [];
  63908. const [plainSelectors, filteredSelectors] = groupSelectors(selector);
  63909. let found;
  63910. if (plainSelectors.length) {
  63911. const filtered = filterElements(elements, plainSelectors, options);
  63912. // If there are no filters, just return
  63913. if (filteredSelectors.length === 0) {
  63914. return filtered;
  63915. }
  63916. // Otherwise, we have to do some filtering
  63917. if (filtered.length) {
  63918. found = new Set(filtered);
  63919. }
  63920. }
  63921. for (let i = 0; i < filteredSelectors.length && (found === null || found === void 0 ? void 0 : found.size) !== elements.length; i++) {
  63922. const filteredSelector = filteredSelectors[i];
  63923. const missing = found
  63924. ? elements.filter((e) => isTag$1(e) && !found.has(e))
  63925. : elements;
  63926. if (missing.length === 0)
  63927. break;
  63928. const filtered = filterBySelector(filteredSelector, elements, options);
  63929. if (filtered.length) {
  63930. if (!found) {
  63931. /*
  63932. * If we haven't found anything before the last selector,
  63933. * just return what we found now.
  63934. */
  63935. if (i === filteredSelectors.length - 1) {
  63936. return filtered;
  63937. }
  63938. found = new Set(filtered);
  63939. }
  63940. else {
  63941. filtered.forEach((el) => found.add(el));
  63942. }
  63943. }
  63944. }
  63945. return typeof found !== "undefined"
  63946. ? (found.size === elements.length
  63947. ? elements
  63948. : // Filter elements to preserve order
  63949. elements.filter((el) => found.has(el)))
  63950. : [];
  63951. }
  63952. function filterBySelector(selector, elements, options) {
  63953. var _a;
  63954. if (selector.some(isTraversal)) {
  63955. /*
  63956. * Get root node, run selector with the scope
  63957. * set to all of our nodes.
  63958. */
  63959. const root = (_a = options.root) !== null && _a !== void 0 ? _a : getDocumentRoot(elements[0]);
  63960. const opts = { ...options, context: elements, relativeSelector: false };
  63961. selector.push(SCOPE_PSEUDO);
  63962. return findFilterElements(root, selector, opts, true, elements.length);
  63963. }
  63964. // Performance optimization: If we don't have to traverse, just filter set.
  63965. return findFilterElements(elements, selector, options, false, elements.length);
  63966. }
  63967. function select(selector, root, options = {}, limit = Infinity) {
  63968. if (typeof selector === "function") {
  63969. return find$6(root, selector);
  63970. }
  63971. const [plain, filtered] = groupSelectors(parse(selector));
  63972. const results = filtered.map((sel) => findFilterElements(root, sel, options, true, limit));
  63973. // Plain selectors can be queried in a single go
  63974. if (plain.length) {
  63975. results.push(findElements(root, plain, options, limit));
  63976. }
  63977. if (results.length === 0) {
  63978. return [];
  63979. }
  63980. // If there was only a single selector, just return the result
  63981. if (results.length === 1) {
  63982. return results[0];
  63983. }
  63984. // Sort results, filtering for duplicates
  63985. return uniqueSort(results.reduce((a, b) => [...a, ...b]));
  63986. }
  63987. /**
  63988. *
  63989. * @param root Element(s) to search from.
  63990. * @param selector Selector to look for.
  63991. * @param options Options for querying.
  63992. * @param queryForSelector Query multiple levels deep for the initial selector, even if it doesn't contain a traversal.
  63993. */
  63994. function findFilterElements(root, selector, options, queryForSelector, totalLimit) {
  63995. const filterIndex = selector.findIndex(isFilter);
  63996. const sub = selector.slice(0, filterIndex);
  63997. const filter = selector[filterIndex];
  63998. // If we are at the end of the selector, we can limit the number of elements to retrieve.
  63999. const partLimit = selector.length - 1 === filterIndex ? totalLimit : Infinity;
  64000. /*
  64001. * Set the number of elements to retrieve.
  64002. * Eg. for :first, we only have to get a single element.
  64003. */
  64004. const limit = getLimit(filter.name, filter.data, partLimit);
  64005. if (limit === 0)
  64006. return [];
  64007. /*
  64008. * Skip `findElements` call if our selector starts with a positional
  64009. * pseudo.
  64010. */
  64011. const elemsNoLimit = sub.length === 0 && !Array.isArray(root)
  64012. ? getChildren(root).filter(isTag$1)
  64013. : sub.length === 0
  64014. ? (Array.isArray(root) ? root : [root]).filter(isTag$1)
  64015. : queryForSelector || sub.some(isTraversal)
  64016. ? findElements(root, [sub], options, limit)
  64017. : filterElements(root, [sub], options);
  64018. const elems = elemsNoLimit.slice(0, limit);
  64019. let result = filterByPosition(filter.name, elems, filter.data, options);
  64020. if (result.length === 0 || selector.length === filterIndex + 1) {
  64021. return result;
  64022. }
  64023. const remainingSelector = selector.slice(filterIndex + 1);
  64024. const remainingHasTraversal = remainingSelector.some(isTraversal);
  64025. if (remainingHasTraversal) {
  64026. if (isTraversal(remainingSelector[0])) {
  64027. const { type } = remainingSelector[0];
  64028. if (type === SelectorType.Sibling ||
  64029. type === SelectorType.Adjacent) {
  64030. // If we have a sibling traversal, we need to also look at the siblings.
  64031. result = prepareContext(result, DomUtils, true);
  64032. }
  64033. // Avoid a traversal-first selector error.
  64034. remainingSelector.unshift(UNIVERSAL_SELECTOR);
  64035. }
  64036. options = {
  64037. ...options,
  64038. // Avoid absolutizing the selector
  64039. relativeSelector: false,
  64040. /*
  64041. * Add a custom root func, to make sure traversals don't match elements
  64042. * that aren't a part of the considered tree.
  64043. */
  64044. rootFunc: (el) => result.includes(el),
  64045. };
  64046. }
  64047. else if (options.rootFunc && options.rootFunc !== boolbase_1) {
  64048. options = { ...options, rootFunc: boolbase_1 };
  64049. }
  64050. /*
  64051. * If we have another filter, recursively call `findFilterElements`,
  64052. * with the `recursive` flag disabled. We only have to look for more
  64053. * elements when we see a traversal.
  64054. *
  64055. * Otherwise,
  64056. */
  64057. return remainingSelector.some(isFilter)
  64058. ? findFilterElements(result, remainingSelector, options, false, totalLimit)
  64059. : remainingHasTraversal
  64060. ? // Query existing elements to resolve traversal.
  64061. findElements(result, [remainingSelector], options, totalLimit)
  64062. : // If we don't have any more traversals, simply filter elements.
  64063. filterElements(result, [remainingSelector], options);
  64064. }
  64065. function findElements(root, sel, options, limit) {
  64066. const query = _compileToken(sel, options, root);
  64067. return find$6(root, query, limit);
  64068. }
  64069. function find$6(root, query, limit = Infinity) {
  64070. const elems = prepareContext(root, DomUtils, query.shouldTestNextSiblings);
  64071. return find$5((node) => isTag$1(node) && query(node), elems, true, limit);
  64072. }
  64073. function filterElements(elements, sel, options) {
  64074. const els = (Array.isArray(elements) ? elements : [elements]).filter(isTag$1);
  64075. if (els.length === 0)
  64076. return els;
  64077. const query = _compileToken(sel, options);
  64078. return query === boolbase_1 ? els : els.filter(query);
  64079. }
  64080. /**
  64081. * Methods for traversing the DOM structure.
  64082. *
  64083. * @module cheerio/traversing
  64084. */
  64085. const reSiblingSelector = /^\s*[~+]/;
  64086. /**
  64087. * Get the descendants of each element in the current set of matched elements,
  64088. * filtered by a selector, jQuery object, or element.
  64089. *
  64090. * @category Traversing
  64091. * @example
  64092. *
  64093. * ```js
  64094. * $('#fruits').find('li').length;
  64095. * //=> 3
  64096. * $('#fruits').find($('.apple')).length;
  64097. * //=> 1
  64098. * ```
  64099. *
  64100. * @param selectorOrHaystack - Element to look for.
  64101. * @returns The found elements.
  64102. * @see {@link https://api.jquery.com/find/}
  64103. */
  64104. function find$7(selectorOrHaystack) {
  64105. var _a;
  64106. if (!selectorOrHaystack) {
  64107. return this._make([]);
  64108. }
  64109. const context = this.toArray();
  64110. if (typeof selectorOrHaystack !== 'string') {
  64111. const haystack = isCheerio(selectorOrHaystack)
  64112. ? selectorOrHaystack.toArray()
  64113. : [selectorOrHaystack];
  64114. return this._make(haystack.filter((elem) => context.some((node) => contains(node, elem))));
  64115. }
  64116. const elems = reSiblingSelector.test(selectorOrHaystack)
  64117. ? context
  64118. : this.children().toArray();
  64119. const options = {
  64120. context,
  64121. root: (_a = this._root) === null || _a === void 0 ? void 0 : _a[0],
  64122. // Pass options that are recognized by `cheerio-select`
  64123. xmlMode: this.options.xmlMode,
  64124. lowerCaseTags: this.options.lowerCaseTags,
  64125. lowerCaseAttributeNames: this.options.lowerCaseAttributeNames,
  64126. pseudos: this.options.pseudos,
  64127. quirksMode: this.options.quirksMode,
  64128. };
  64129. return this._make(select(selectorOrHaystack, elems, options));
  64130. }
  64131. /**
  64132. * Creates a matcher, using a particular mapping function. Matchers provide a
  64133. * function that finds elements using a generating function, supporting filtering.
  64134. *
  64135. * @private
  64136. * @param matchMap - Mapping function.
  64137. * @returns - Function for wrapping generating functions.
  64138. */
  64139. function _getMatcher(matchMap) {
  64140. return function (fn, ...postFns) {
  64141. return function (selector) {
  64142. var _a;
  64143. let matched = matchMap(fn, this);
  64144. if (selector) {
  64145. matched = filterArray(matched, selector, this.options.xmlMode, (_a = this._root) === null || _a === void 0 ? void 0 : _a[0]);
  64146. }
  64147. return this._make(
  64148. // Post processing is only necessary if there is more than one element.
  64149. this.length > 1 && matched.length > 1
  64150. ? postFns.reduce((elems, fn) => fn(elems), matched)
  64151. : matched);
  64152. };
  64153. };
  64154. }
  64155. /** Matcher that adds multiple elements for each entry in the input. */
  64156. const _matcher = _getMatcher((fn, elems) => {
  64157. const ret = [];
  64158. for (let i = 0; i < elems.length; i++) {
  64159. const value = fn(elems[i]);
  64160. ret.push(value);
  64161. }
  64162. return new Array().concat(...ret);
  64163. });
  64164. /** Matcher that adds at most one element for each entry in the input. */
  64165. const _singleMatcher = _getMatcher((fn, elems) => {
  64166. const ret = [];
  64167. for (let i = 0; i < elems.length; i++) {
  64168. const value = fn(elems[i]);
  64169. if (value !== null) {
  64170. ret.push(value);
  64171. }
  64172. }
  64173. return ret;
  64174. });
  64175. /**
  64176. * Matcher that supports traversing until a condition is met.
  64177. *
  64178. * @returns A function usable for `*Until` methods.
  64179. */
  64180. function _matchUntil(nextElem, ...postFns) {
  64181. // We use a variable here that is used from within the matcher.
  64182. let matches = null;
  64183. const innerMatcher = _getMatcher((nextElem, elems) => {
  64184. const matched = [];
  64185. domEach(elems, (elem) => {
  64186. for (let next; (next = nextElem(elem)); elem = next) {
  64187. // FIXME: `matched` might contain duplicates here and the index is too large.
  64188. if (matches === null || matches === void 0 ? void 0 : matches(next, matched.length))
  64189. break;
  64190. matched.push(next);
  64191. }
  64192. });
  64193. return matched;
  64194. })(nextElem, ...postFns);
  64195. return function (selector, filterSelector) {
  64196. // Override `matches` variable with the new target.
  64197. matches =
  64198. typeof selector === 'string'
  64199. ? (elem) => is$1(elem, selector, this.options)
  64200. : selector
  64201. ? getFilterFn(selector)
  64202. : null;
  64203. const ret = innerMatcher.call(this, filterSelector);
  64204. // Set `matches` to `null`, so we don't waste memory.
  64205. matches = null;
  64206. return ret;
  64207. };
  64208. }
  64209. function _removeDuplicates(elems) {
  64210. return Array.from(new Set(elems));
  64211. }
  64212. /**
  64213. * Get the parent of each element in the current set of matched elements,
  64214. * optionally filtered by a selector.
  64215. *
  64216. * @category Traversing
  64217. * @example
  64218. *
  64219. * ```js
  64220. * $('.pear').parent().attr('id');
  64221. * //=> fruits
  64222. * ```
  64223. *
  64224. * @param selector - If specified filter for parent.
  64225. * @returns The parents.
  64226. * @see {@link https://api.jquery.com/parent/}
  64227. */
  64228. const parent = _singleMatcher(({ parent }) => (parent && !isDocument(parent) ? parent : null), _removeDuplicates);
  64229. /**
  64230. * Get a set of parents filtered by `selector` of each element in the current
  64231. * set of match elements.
  64232. *
  64233. * @category Traversing
  64234. * @example
  64235. *
  64236. * ```js
  64237. * $('.orange').parents().length;
  64238. * //=> 2
  64239. * $('.orange').parents('#fruits').length;
  64240. * //=> 1
  64241. * ```
  64242. *
  64243. * @param selector - If specified filter for parents.
  64244. * @returns The parents.
  64245. * @see {@link https://api.jquery.com/parents/}
  64246. */
  64247. const parents = _matcher((elem) => {
  64248. const matched = [];
  64249. while (elem.parent && !isDocument(elem.parent)) {
  64250. matched.push(elem.parent);
  64251. elem = elem.parent;
  64252. }
  64253. return matched;
  64254. }, uniqueSort, (elems) => elems.reverse());
  64255. /**
  64256. * Get the ancestors of each element in the current set of matched elements, up
  64257. * to but not including the element matched by the selector, DOM node, or cheerio object.
  64258. *
  64259. * @category Traversing
  64260. * @example
  64261. *
  64262. * ```js
  64263. * $('.orange').parentsUntil('#food').length;
  64264. * //=> 1
  64265. * ```
  64266. *
  64267. * @param selector - Selector for element to stop at.
  64268. * @param filterSelector - Optional filter for parents.
  64269. * @returns The parents.
  64270. * @see {@link https://api.jquery.com/parentsUntil/}
  64271. */
  64272. const parentsUntil = _matchUntil(({ parent }) => (parent && !isDocument(parent) ? parent : null), uniqueSort, (elems) => elems.reverse());
  64273. /**
  64274. * For each element in the set, get the first element that matches the selector
  64275. * by testing the element itself and traversing up through its ancestors in the DOM tree.
  64276. *
  64277. * @category Traversing
  64278. * @example
  64279. *
  64280. * ```js
  64281. * $('.orange').closest();
  64282. * //=> []
  64283. *
  64284. * $('.orange').closest('.apple');
  64285. * // => []
  64286. *
  64287. * $('.orange').closest('li');
  64288. * //=> [<li class="orange">Orange</li>]
  64289. *
  64290. * $('.orange').closest('#fruits');
  64291. * //=> [<ul id="fruits"> ... </ul>]
  64292. * ```
  64293. *
  64294. * @param selector - Selector for the element to find.
  64295. * @returns The closest nodes.
  64296. * @see {@link https://api.jquery.com/closest/}
  64297. */
  64298. function closest(selector) {
  64299. var _a;
  64300. const set = [];
  64301. if (!selector) {
  64302. return this._make(set);
  64303. }
  64304. const selectOpts = {
  64305. xmlMode: this.options.xmlMode,
  64306. root: (_a = this._root) === null || _a === void 0 ? void 0 : _a[0],
  64307. };
  64308. const selectFn = typeof selector === 'string'
  64309. ? (elem) => is$1(elem, selector, selectOpts)
  64310. : getFilterFn(selector);
  64311. domEach(this, (elem) => {
  64312. while (elem && isTag$1(elem)) {
  64313. if (selectFn(elem, 0)) {
  64314. // Do not add duplicate elements to the set
  64315. if (!set.includes(elem)) {
  64316. set.push(elem);
  64317. }
  64318. break;
  64319. }
  64320. elem = elem.parent;
  64321. }
  64322. });
  64323. return this._make(set);
  64324. }
  64325. /**
  64326. * Gets the next sibling of the first selected element, optionally filtered by a selector.
  64327. *
  64328. * @category Traversing
  64329. * @example
  64330. *
  64331. * ```js
  64332. * $('.apple').next().hasClass('orange');
  64333. * //=> true
  64334. * ```
  64335. *
  64336. * @param selector - If specified filter for sibling.
  64337. * @returns The next nodes.
  64338. * @see {@link https://api.jquery.com/next/}
  64339. */
  64340. const next = _singleMatcher((elem) => nextElementSibling(elem));
  64341. /**
  64342. * Gets all the following siblings of the first selected element, optionally
  64343. * filtered by a selector.
  64344. *
  64345. * @category Traversing
  64346. * @example
  64347. *
  64348. * ```js
  64349. * $('.apple').nextAll();
  64350. * //=> [<li class="orange">Orange</li>, <li class="pear">Pear</li>]
  64351. * $('.apple').nextAll('.orange');
  64352. * //=> [<li class="orange">Orange</li>]
  64353. * ```
  64354. *
  64355. * @param selector - If specified filter for siblings.
  64356. * @returns The next nodes.
  64357. * @see {@link https://api.jquery.com/nextAll/}
  64358. */
  64359. const nextAll = _matcher((elem) => {
  64360. const matched = [];
  64361. while (elem.next) {
  64362. elem = elem.next;
  64363. if (isTag$1(elem))
  64364. matched.push(elem);
  64365. }
  64366. return matched;
  64367. }, _removeDuplicates);
  64368. /**
  64369. * Gets all the following siblings up to but not including the element matched
  64370. * by the selector, optionally filtered by another selector.
  64371. *
  64372. * @category Traversing
  64373. * @example
  64374. *
  64375. * ```js
  64376. * $('.apple').nextUntil('.pear');
  64377. * //=> [<li class="orange">Orange</li>]
  64378. * ```
  64379. *
  64380. * @param selector - Selector for element to stop at.
  64381. * @param filterSelector - If specified filter for siblings.
  64382. * @returns The next nodes.
  64383. * @see {@link https://api.jquery.com/nextUntil/}
  64384. */
  64385. const nextUntil = _matchUntil((el) => nextElementSibling(el), _removeDuplicates);
  64386. /**
  64387. * Gets the previous sibling of the first selected element optionally filtered
  64388. * by a selector.
  64389. *
  64390. * @category Traversing
  64391. * @example
  64392. *
  64393. * ```js
  64394. * $('.orange').prev().hasClass('apple');
  64395. * //=> true
  64396. * ```
  64397. *
  64398. * @param selector - If specified filter for siblings.
  64399. * @returns The previous nodes.
  64400. * @see {@link https://api.jquery.com/prev/}
  64401. */
  64402. const prev = _singleMatcher((elem) => prevElementSibling(elem));
  64403. /**
  64404. * Gets all the preceding siblings of the first selected element, optionally
  64405. * filtered by a selector.
  64406. *
  64407. * @category Traversing
  64408. * @example
  64409. *
  64410. * ```js
  64411. * $('.pear').prevAll();
  64412. * //=> [<li class="orange">Orange</li>, <li class="apple">Apple</li>]
  64413. *
  64414. * $('.pear').prevAll('.orange');
  64415. * //=> [<li class="orange">Orange</li>]
  64416. * ```
  64417. *
  64418. * @param selector - If specified filter for siblings.
  64419. * @returns The previous nodes.
  64420. * @see {@link https://api.jquery.com/prevAll/}
  64421. */
  64422. const prevAll = _matcher((elem) => {
  64423. const matched = [];
  64424. while (elem.prev) {
  64425. elem = elem.prev;
  64426. if (isTag$1(elem))
  64427. matched.push(elem);
  64428. }
  64429. return matched;
  64430. }, _removeDuplicates);
  64431. /**
  64432. * Gets all the preceding siblings up to but not including the element matched
  64433. * by the selector, optionally filtered by another selector.
  64434. *
  64435. * @category Traversing
  64436. * @example
  64437. *
  64438. * ```js
  64439. * $('.pear').prevUntil('.apple');
  64440. * //=> [<li class="orange">Orange</li>]
  64441. * ```
  64442. *
  64443. * @param selector - Selector for element to stop at.
  64444. * @param filterSelector - If specified filter for siblings.
  64445. * @returns The previous nodes.
  64446. * @see {@link https://api.jquery.com/prevUntil/}
  64447. */
  64448. const prevUntil = _matchUntil((el) => prevElementSibling(el), _removeDuplicates);
  64449. /**
  64450. * Get the siblings of each element (excluding the element) in the set of
  64451. * matched elements, optionally filtered by a selector.
  64452. *
  64453. * @category Traversing
  64454. * @example
  64455. *
  64456. * ```js
  64457. * $('.pear').siblings().length;
  64458. * //=> 2
  64459. *
  64460. * $('.pear').siblings('.orange').length;
  64461. * //=> 1
  64462. * ```
  64463. *
  64464. * @param selector - If specified filter for siblings.
  64465. * @returns The siblings.
  64466. * @see {@link https://api.jquery.com/siblings/}
  64467. */
  64468. const siblings = _matcher((elem) => getSiblings(elem).filter((el) => isTag$1(el) && el !== elem), uniqueSort);
  64469. /**
  64470. * Gets the element children of each element in the set of matched elements.
  64471. *
  64472. * @category Traversing
  64473. * @example
  64474. *
  64475. * ```js
  64476. * $('#fruits').children().length;
  64477. * //=> 3
  64478. *
  64479. * $('#fruits').children('.pear').text();
  64480. * //=> Pear
  64481. * ```
  64482. *
  64483. * @param selector - If specified filter for children.
  64484. * @returns The children.
  64485. * @see {@link https://api.jquery.com/children/}
  64486. */
  64487. const children = _matcher((elem) => getChildren(elem).filter(isTag$1), _removeDuplicates);
  64488. /**
  64489. * Gets the children of each element in the set of matched elements, including
  64490. * text and comment nodes.
  64491. *
  64492. * @category Traversing
  64493. * @example
  64494. *
  64495. * ```js
  64496. * $('#fruits').contents().length;
  64497. * //=> 3
  64498. * ```
  64499. *
  64500. * @returns The children.
  64501. * @see {@link https://api.jquery.com/contents/}
  64502. */
  64503. function contents() {
  64504. const elems = this.toArray().reduce((newElems, elem) => hasChildren(elem) ? newElems.concat(elem.children) : newElems, []);
  64505. return this._make(elems);
  64506. }
  64507. /**
  64508. * Iterates over a cheerio object, executing a function for each matched
  64509. * element. When the callback is fired, the function is fired in the context of
  64510. * the DOM element, so `this` refers to the current element, which is equivalent
  64511. * to the function parameter `element`. To break out of the `each` loop early,
  64512. * return with `false`.
  64513. *
  64514. * @category Traversing
  64515. * @example
  64516. *
  64517. * ```js
  64518. * const fruits = [];
  64519. *
  64520. * $('li').each(function (i, elem) {
  64521. * fruits[i] = $(this).text();
  64522. * });
  64523. *
  64524. * fruits.join(', ');
  64525. * //=> Apple, Orange, Pear
  64526. * ```
  64527. *
  64528. * @param fn - Function to execute.
  64529. * @returns The instance itself, useful for chaining.
  64530. * @see {@link https://api.jquery.com/each/}
  64531. */
  64532. function each(fn) {
  64533. let i = 0;
  64534. const len = this.length;
  64535. while (i < len && fn.call(this[i], i, this[i]) !== false)
  64536. ++i;
  64537. return this;
  64538. }
  64539. /**
  64540. * Pass each element in the current matched set through a function, producing a
  64541. * new Cheerio object containing the return values. The function can return an
  64542. * individual data item or an array of data items to be inserted into the
  64543. * resulting set. If an array is returned, the elements inside the array are
  64544. * inserted into the set. If the function returns null or undefined, no element
  64545. * will be inserted.
  64546. *
  64547. * @category Traversing
  64548. * @example
  64549. *
  64550. * ```js
  64551. * $('li')
  64552. * .map(function (i, el) {
  64553. * // this === el
  64554. * return $(this).text();
  64555. * })
  64556. * .toArray()
  64557. * .join(' ');
  64558. * //=> "apple orange pear"
  64559. * ```
  64560. *
  64561. * @param fn - Function to execute.
  64562. * @returns The mapped elements, wrapped in a Cheerio collection.
  64563. * @see {@link https://api.jquery.com/map/}
  64564. */
  64565. function map$a(fn) {
  64566. let elems = [];
  64567. for (let i = 0; i < this.length; i++) {
  64568. const el = this[i];
  64569. const val = fn.call(el, i, el);
  64570. if (val != null) {
  64571. elems = elems.concat(val);
  64572. }
  64573. }
  64574. return this._make(elems);
  64575. }
  64576. /**
  64577. * Creates a function to test if a filter is matched.
  64578. *
  64579. * @param match - A filter.
  64580. * @returns A function that determines if a filter has been matched.
  64581. */
  64582. function getFilterFn(match) {
  64583. if (typeof match === 'function') {
  64584. return (el, i) => match.call(el, i, el);
  64585. }
  64586. if (isCheerio(match)) {
  64587. return (el) => Array.prototype.includes.call(match, el);
  64588. }
  64589. return function (el) {
  64590. return match === el;
  64591. };
  64592. }
  64593. function filter$6(match) {
  64594. var _a;
  64595. return this._make(filterArray(this.toArray(), match, this.options.xmlMode, (_a = this._root) === null || _a === void 0 ? void 0 : _a[0]));
  64596. }
  64597. function filterArray(nodes, match, xmlMode, root) {
  64598. return typeof match === 'string'
  64599. ? filter$5(match, nodes, { xmlMode, root })
  64600. : nodes.filter(getFilterFn(match));
  64601. }
  64602. /**
  64603. * Checks the current list of elements and returns `true` if _any_ of the
  64604. * elements match the selector. If using an element or Cheerio selection,
  64605. * returns `true` if _any_ of the elements match. If using a predicate function,
  64606. * the function is executed in the context of the selected element, so `this`
  64607. * refers to the current element.
  64608. *
  64609. * @category Attributes
  64610. * @param selector - Selector for the selection.
  64611. * @returns Whether or not the selector matches an element of the instance.
  64612. * @see {@link https://api.jquery.com/is/}
  64613. */
  64614. function is$2(selector) {
  64615. const nodes = this.toArray();
  64616. return typeof selector === 'string'
  64617. ? some$4(nodes.filter(isTag$1), selector, this.options)
  64618. : selector
  64619. ? nodes.some(getFilterFn(selector))
  64620. : false;
  64621. }
  64622. /**
  64623. * Remove elements from the set of matched elements. Given a Cheerio object that
  64624. * represents a set of DOM elements, the `.not()` method constructs a new
  64625. * Cheerio object from a subset of the matching elements. The supplied selector
  64626. * is tested against each element; the elements that don't match the selector
  64627. * will be included in the result.
  64628. *
  64629. * The `.not()` method can take a function as its argument in the same way that
  64630. * `.filter()` does. Elements for which the function returns `true` are excluded
  64631. * from the filtered set; all other elements are included.
  64632. *
  64633. * @category Traversing
  64634. * @example <caption>Selector</caption>
  64635. *
  64636. * ```js
  64637. * $('li').not('.apple').length;
  64638. * //=> 2
  64639. * ```
  64640. *
  64641. * @example <caption>Function</caption>
  64642. *
  64643. * ```js
  64644. * $('li').not(function (i, el) {
  64645. * // this === el
  64646. * return $(this).attr('class') === 'orange';
  64647. * }).length; //=> 2
  64648. * ```
  64649. *
  64650. * @param match - Value to look for, following the rules above.
  64651. * @param container - Optional node to filter instead.
  64652. * @returns The filtered collection.
  64653. * @see {@link https://api.jquery.com/not/}
  64654. */
  64655. function not(match) {
  64656. let nodes = this.toArray();
  64657. if (typeof match === 'string') {
  64658. const matches = new Set(filter$5(match, nodes, this.options));
  64659. nodes = nodes.filter((el) => !matches.has(el));
  64660. }
  64661. else {
  64662. const filterFn = getFilterFn(match);
  64663. nodes = nodes.filter((el, i) => !filterFn(el, i));
  64664. }
  64665. return this._make(nodes);
  64666. }
  64667. /**
  64668. * Filters the set of matched elements to only those which have the given DOM
  64669. * element as a descendant or which have a descendant that matches the given
  64670. * selector. Equivalent to `.filter(':has(selector)')`.
  64671. *
  64672. * @category Traversing
  64673. * @example <caption>Selector</caption>
  64674. *
  64675. * ```js
  64676. * $('ul').has('.pear').attr('id');
  64677. * //=> fruits
  64678. * ```
  64679. *
  64680. * @example <caption>Element</caption>
  64681. *
  64682. * ```js
  64683. * $('ul').has($('.pear')[0]).attr('id');
  64684. * //=> fruits
  64685. * ```
  64686. *
  64687. * @param selectorOrHaystack - Element to look for.
  64688. * @returns The filtered collection.
  64689. * @see {@link https://api.jquery.com/has/}
  64690. */
  64691. function has$1(selectorOrHaystack) {
  64692. return this.filter(typeof selectorOrHaystack === 'string'
  64693. ? // Using the `:has` selector here short-circuits searches.
  64694. `:has(${selectorOrHaystack})`
  64695. : (_, el) => this._make(el).find(selectorOrHaystack).length > 0);
  64696. }
  64697. /**
  64698. * Will select the first element of a cheerio object.
  64699. *
  64700. * @category Traversing
  64701. * @example
  64702. *
  64703. * ```js
  64704. * $('#fruits').children().first().text();
  64705. * //=> Apple
  64706. * ```
  64707. *
  64708. * @returns The first element.
  64709. * @see {@link https://api.jquery.com/first/}
  64710. */
  64711. function first() {
  64712. return this.length > 1 ? this._make(this[0]) : this;
  64713. }
  64714. /**
  64715. * Will select the last element of a cheerio object.
  64716. *
  64717. * @category Traversing
  64718. * @example
  64719. *
  64720. * ```js
  64721. * $('#fruits').children().last().text();
  64722. * //=> Pear
  64723. * ```
  64724. *
  64725. * @returns The last element.
  64726. * @see {@link https://api.jquery.com/last/}
  64727. */
  64728. function last$1() {
  64729. return this.length > 0 ? this._make(this[this.length - 1]) : this;
  64730. }
  64731. /**
  64732. * Reduce the set of matched elements to the one at the specified index. Use
  64733. * `.eq(-i)` to count backwards from the last selected element.
  64734. *
  64735. * @category Traversing
  64736. * @example
  64737. *
  64738. * ```js
  64739. * $('li').eq(0).text();
  64740. * //=> Apple
  64741. *
  64742. * $('li').eq(-1).text();
  64743. * //=> Pear
  64744. * ```
  64745. *
  64746. * @param i - Index of the element to select.
  64747. * @returns The element at the `i`th position.
  64748. * @see {@link https://api.jquery.com/eq/}
  64749. */
  64750. function eq$1(i) {
  64751. var _a;
  64752. i = +i;
  64753. // Use the first identity optimization if possible
  64754. if (i === 0 && this.length <= 1)
  64755. return this;
  64756. if (i < 0)
  64757. i = this.length + i;
  64758. return this._make((_a = this[i]) !== null && _a !== void 0 ? _a : []);
  64759. }
  64760. function get$9(i) {
  64761. if (i == null) {
  64762. return this.toArray();
  64763. }
  64764. return this[i < 0 ? this.length + i : i];
  64765. }
  64766. /**
  64767. * Retrieve all the DOM elements contained in the jQuery set as an array.
  64768. *
  64769. * @example
  64770. *
  64771. * ```js
  64772. * $('li').toArray();
  64773. * //=> [ {...}, {...}, {...} ]
  64774. * ```
  64775. *
  64776. * @returns The contained items.
  64777. */
  64778. function toArray$1() {
  64779. return Array.prototype.slice.call(this);
  64780. }
  64781. /**
  64782. * Search for a given element from among the matched elements.
  64783. *
  64784. * @category Traversing
  64785. * @example
  64786. *
  64787. * ```js
  64788. * $('.pear').index();
  64789. * //=> 2 $('.orange').index('li');
  64790. * //=> 1
  64791. * $('.apple').index($('#fruit, li'));
  64792. * //=> 1
  64793. * ```
  64794. *
  64795. * @param selectorOrNeedle - Element to look for.
  64796. * @returns The index of the element.
  64797. * @see {@link https://api.jquery.com/index/}
  64798. */
  64799. function index(selectorOrNeedle) {
  64800. let $haystack;
  64801. let needle;
  64802. if (selectorOrNeedle == null) {
  64803. $haystack = this.parent().children();
  64804. needle = this[0];
  64805. }
  64806. else if (typeof selectorOrNeedle === 'string') {
  64807. $haystack = this._make(selectorOrNeedle);
  64808. needle = this[0];
  64809. }
  64810. else {
  64811. // eslint-disable-next-line @typescript-eslint/no-this-alias
  64812. $haystack = this;
  64813. needle = isCheerio(selectorOrNeedle)
  64814. ? selectorOrNeedle[0]
  64815. : selectorOrNeedle;
  64816. }
  64817. return Array.prototype.indexOf.call($haystack, needle);
  64818. }
  64819. /**
  64820. * Gets the elements matching the specified range (0-based position).
  64821. *
  64822. * @category Traversing
  64823. * @example
  64824. *
  64825. * ```js
  64826. * $('li').slice(1).eq(0).text();
  64827. * //=> 'Orange'
  64828. *
  64829. * $('li').slice(1, 2).length;
  64830. * //=> 1
  64831. * ```
  64832. *
  64833. * @param start - An position at which the elements begin to be selected. If
  64834. * negative, it indicates an offset from the end of the set.
  64835. * @param end - An position at which the elements stop being selected. If
  64836. * negative, it indicates an offset from the end of the set. If omitted, the
  64837. * range continues until the end of the set.
  64838. * @returns The elements matching the specified range.
  64839. * @see {@link https://api.jquery.com/slice/}
  64840. */
  64841. function slice$8(start, end) {
  64842. return this._make(Array.prototype.slice.call(this, start, end));
  64843. }
  64844. /**
  64845. * End the most recent filtering operation in the current chain and return the
  64846. * set of matched elements to its previous state.
  64847. *
  64848. * @category Traversing
  64849. * @example
  64850. *
  64851. * ```js
  64852. * $('li').eq(0).end().length;
  64853. * //=> 3
  64854. * ```
  64855. *
  64856. * @returns The previous state of the set of matched elements.
  64857. * @see {@link https://api.jquery.com/end/}
  64858. */
  64859. function end() {
  64860. var _a;
  64861. return (_a = this.prevObject) !== null && _a !== void 0 ? _a : this._make([]);
  64862. }
  64863. /**
  64864. * Add elements to the set of matched elements.
  64865. *
  64866. * @category Traversing
  64867. * @example
  64868. *
  64869. * ```js
  64870. * $('.apple').add('.orange').length;
  64871. * //=> 2
  64872. * ```
  64873. *
  64874. * @param other - Elements to add.
  64875. * @param context - Optionally the context of the new selection.
  64876. * @returns The combined set.
  64877. * @see {@link https://api.jquery.com/add/}
  64878. */
  64879. function add(other, context) {
  64880. const selection = this._make(other, context);
  64881. const contents = uniqueSort([...this.get(), ...selection.get()]);
  64882. return this._make(contents);
  64883. }
  64884. /**
  64885. * Add the previous set of elements on the stack to the current set, optionally
  64886. * filtered by a selector.
  64887. *
  64888. * @category Traversing
  64889. * @example
  64890. *
  64891. * ```js
  64892. * $('li').eq(0).addBack('.orange').length;
  64893. * //=> 2
  64894. * ```
  64895. *
  64896. * @param selector - Selector for the elements to add.
  64897. * @returns The combined set.
  64898. * @see {@link https://api.jquery.com/addBack/}
  64899. */
  64900. function addBack(selector) {
  64901. return this.prevObject
  64902. ? this.add(selector ? this.prevObject.filter(selector) : this.prevObject)
  64903. : this;
  64904. }
  64905. var Traversing = /*#__PURE__*/Object.freeze({
  64906. __proto__: null,
  64907. find: find$7,
  64908. parent: parent,
  64909. parents: parents,
  64910. parentsUntil: parentsUntil,
  64911. closest: closest,
  64912. next: next,
  64913. nextAll: nextAll,
  64914. nextUntil: nextUntil,
  64915. prev: prev,
  64916. prevAll: prevAll,
  64917. prevUntil: prevUntil,
  64918. siblings: siblings,
  64919. children: children,
  64920. contents: contents,
  64921. each: each,
  64922. map: map$a,
  64923. filter: filter$6,
  64924. filterArray: filterArray,
  64925. is: is$2,
  64926. not: not,
  64927. has: has$1,
  64928. first: first,
  64929. last: last$1,
  64930. eq: eq$1,
  64931. get: get$9,
  64932. toArray: toArray$1,
  64933. index: index,
  64934. slice: slice$8,
  64935. end: end,
  64936. add: add,
  64937. addBack: addBack
  64938. });
  64939. /**
  64940. * Get the parse function with options.
  64941. *
  64942. * @param parser - The parser function.
  64943. * @returns The parse function with options.
  64944. */
  64945. function getParse(parser) {
  64946. /**
  64947. * Parse a HTML string or a node.
  64948. *
  64949. * @param content - The HTML string or node.
  64950. * @param options - The parser options.
  64951. * @param isDocument - If `content` is a document.
  64952. * @param context - The context node in the DOM tree.
  64953. * @returns The parsed document node.
  64954. */
  64955. return function parse(content, options, isDocument$1, context) {
  64956. if (typeof Buffer !== 'undefined' && Buffer.isBuffer(content)) {
  64957. content = content.toString();
  64958. }
  64959. if (typeof content === 'string') {
  64960. return parser(content, options, isDocument$1, context);
  64961. }
  64962. const doc = content;
  64963. if (!Array.isArray(doc) && isDocument(doc)) {
  64964. // If `doc` is already a root, just return it
  64965. return doc;
  64966. }
  64967. // Add conent to new root element
  64968. const root = new Document([]);
  64969. // Update the DOM using the root
  64970. update(doc, root);
  64971. return root;
  64972. };
  64973. }
  64974. /**
  64975. * Update the dom structure, for one changed layer.
  64976. *
  64977. * @param newChilds - The new children.
  64978. * @param parent - The new parent.
  64979. * @returns The parent node.
  64980. */
  64981. function update(newChilds, parent) {
  64982. // Normalize
  64983. const arr = Array.isArray(newChilds) ? newChilds : [newChilds];
  64984. // Update parent
  64985. if (parent) {
  64986. parent.children = arr;
  64987. }
  64988. else {
  64989. parent = null;
  64990. }
  64991. // Update neighbors
  64992. for (let i = 0; i < arr.length; i++) {
  64993. const node = arr[i];
  64994. // Cleanly remove existing nodes from their previous structures.
  64995. if (node.parent && node.parent.children !== arr) {
  64996. removeElement(node);
  64997. }
  64998. if (parent) {
  64999. node.prev = arr[i - 1] || null;
  65000. node.next = arr[i + 1] || null;
  65001. }
  65002. else {
  65003. node.prev = node.next = null;
  65004. }
  65005. node.parent = parent;
  65006. }
  65007. return parent;
  65008. }
  65009. /**
  65010. * Methods for modifying the DOM structure.
  65011. *
  65012. * @module cheerio/manipulation
  65013. */
  65014. /**
  65015. * Create an array of nodes, recursing into arrays and parsing strings if necessary.
  65016. *
  65017. * @private
  65018. * @category Manipulation
  65019. * @param elem - Elements to make an array of.
  65020. * @param clone - Optionally clone nodes.
  65021. * @returns The array of nodes.
  65022. */
  65023. function _makeDomArray(elem, clone) {
  65024. if (elem == null) {
  65025. return [];
  65026. }
  65027. if (isCheerio(elem)) {
  65028. return clone ? cloneDom(elem.get()) : elem.get();
  65029. }
  65030. if (Array.isArray(elem)) {
  65031. return elem.reduce((newElems, el) => newElems.concat(this._makeDomArray(el, clone)), []);
  65032. }
  65033. if (typeof elem === 'string') {
  65034. return this._parse(elem, this.options, false, null).children;
  65035. }
  65036. return clone ? cloneDom([elem]) : [elem];
  65037. }
  65038. function _insert(concatenator) {
  65039. return function (...elems) {
  65040. const lastIdx = this.length - 1;
  65041. return domEach(this, (el, i) => {
  65042. if (!hasChildren(el))
  65043. return;
  65044. const domSrc = typeof elems[0] === 'function'
  65045. ? elems[0].call(el, i, this._render(el.children))
  65046. : elems;
  65047. const dom = this._makeDomArray(domSrc, i < lastIdx);
  65048. concatenator(dom, el.children, el);
  65049. });
  65050. };
  65051. }
  65052. /**
  65053. * Modify an array in-place, removing some number of elements and adding new
  65054. * elements directly following them.
  65055. *
  65056. * @private
  65057. * @category Manipulation
  65058. * @param array - Target array to splice.
  65059. * @param spliceIdx - Index at which to begin changing the array.
  65060. * @param spliceCount - Number of elements to remove from the array.
  65061. * @param newElems - Elements to insert into the array.
  65062. * @param parent - The parent of the node.
  65063. * @returns The spliced array.
  65064. */
  65065. function uniqueSplice(array, spliceIdx, spliceCount, newElems, parent) {
  65066. var _a, _b;
  65067. const spliceArgs = [
  65068. spliceIdx,
  65069. spliceCount,
  65070. ...newElems,
  65071. ];
  65072. const prev = spliceIdx === 0 ? null : array[spliceIdx - 1];
  65073. const next = spliceIdx + spliceCount >= array.length
  65074. ? null
  65075. : array[spliceIdx + spliceCount];
  65076. /*
  65077. * Before splicing in new elements, ensure they do not already appear in the
  65078. * current array.
  65079. */
  65080. for (let idx = 0; idx < newElems.length; ++idx) {
  65081. const node = newElems[idx];
  65082. const oldParent = node.parent;
  65083. if (oldParent) {
  65084. const oldSiblings = oldParent.children;
  65085. const prevIdx = oldSiblings.indexOf(node);
  65086. if (prevIdx > -1) {
  65087. oldParent.children.splice(prevIdx, 1);
  65088. if (parent === oldParent && spliceIdx > prevIdx) {
  65089. spliceArgs[0]--;
  65090. }
  65091. }
  65092. }
  65093. node.parent = parent;
  65094. if (node.prev) {
  65095. node.prev.next = (_a = node.next) !== null && _a !== void 0 ? _a : null;
  65096. }
  65097. if (node.next) {
  65098. node.next.prev = (_b = node.prev) !== null && _b !== void 0 ? _b : null;
  65099. }
  65100. node.prev = idx === 0 ? prev : newElems[idx - 1];
  65101. node.next = idx === newElems.length - 1 ? next : newElems[idx + 1];
  65102. }
  65103. if (prev) {
  65104. prev.next = newElems[0];
  65105. }
  65106. if (next) {
  65107. next.prev = newElems[newElems.length - 1];
  65108. }
  65109. return array.splice(...spliceArgs);
  65110. }
  65111. /**
  65112. * Insert every element in the set of matched elements to the end of the target.
  65113. *
  65114. * @category Manipulation
  65115. * @example
  65116. *
  65117. * ```js
  65118. * $('<li class="plum">Plum</li>').appendTo('#fruits');
  65119. * $.html();
  65120. * //=> <ul id="fruits">
  65121. * // <li class="apple">Apple</li>
  65122. * // <li class="orange">Orange</li>
  65123. * // <li class="pear">Pear</li>
  65124. * // <li class="plum">Plum</li>
  65125. * // </ul>
  65126. * ```
  65127. *
  65128. * @param target - Element to append elements to.
  65129. * @returns The instance itself.
  65130. * @see {@link https://api.jquery.com/appendTo/}
  65131. */
  65132. function appendTo(target) {
  65133. const appendTarget = isCheerio(target) ? target : this._make(target);
  65134. appendTarget.append(this);
  65135. return this;
  65136. }
  65137. /**
  65138. * Insert every element in the set of matched elements to the beginning of the target.
  65139. *
  65140. * @category Manipulation
  65141. * @example
  65142. *
  65143. * ```js
  65144. * $('<li class="plum">Plum</li>').prependTo('#fruits');
  65145. * $.html();
  65146. * //=> <ul id="fruits">
  65147. * // <li class="plum">Plum</li>
  65148. * // <li class="apple">Apple</li>
  65149. * // <li class="orange">Orange</li>
  65150. * // <li class="pear">Pear</li>
  65151. * // </ul>
  65152. * ```
  65153. *
  65154. * @param target - Element to prepend elements to.
  65155. * @returns The instance itself.
  65156. * @see {@link https://api.jquery.com/prependTo/}
  65157. */
  65158. function prependTo(target) {
  65159. const prependTarget = isCheerio(target) ? target : this._make(target);
  65160. prependTarget.prepend(this);
  65161. return this;
  65162. }
  65163. /**
  65164. * Inserts content as the _last_ child of each of the selected elements.
  65165. *
  65166. * @category Manipulation
  65167. * @example
  65168. *
  65169. * ```js
  65170. * $('ul').append('<li class="plum">Plum</li>');
  65171. * $.html();
  65172. * //=> <ul id="fruits">
  65173. * // <li class="apple">Apple</li>
  65174. * // <li class="orange">Orange</li>
  65175. * // <li class="pear">Pear</li>
  65176. * // <li class="plum">Plum</li>
  65177. * // </ul>
  65178. * ```
  65179. *
  65180. * @see {@link https://api.jquery.com/append/}
  65181. */
  65182. const append$1 = _insert((dom, children, parent) => {
  65183. uniqueSplice(children, children.length, 0, dom, parent);
  65184. });
  65185. /**
  65186. * Inserts content as the _first_ child of each of the selected elements.
  65187. *
  65188. * @category Manipulation
  65189. * @example
  65190. *
  65191. * ```js
  65192. * $('ul').prepend('<li class="plum">Plum</li>');
  65193. * $.html();
  65194. * //=> <ul id="fruits">
  65195. * // <li class="plum">Plum</li>
  65196. * // <li class="apple">Apple</li>
  65197. * // <li class="orange">Orange</li>
  65198. * // <li class="pear">Pear</li>
  65199. * // </ul>
  65200. * ```
  65201. *
  65202. * @see {@link https://api.jquery.com/prepend/}
  65203. */
  65204. const prepend$1 = _insert((dom, children, parent) => {
  65205. uniqueSplice(children, 0, 0, dom, parent);
  65206. });
  65207. function _wrap(insert) {
  65208. return function (wrapper) {
  65209. const lastIdx = this.length - 1;
  65210. const lastParent = this.parents().last();
  65211. for (let i = 0; i < this.length; i++) {
  65212. const el = this[i];
  65213. const wrap = typeof wrapper === 'function'
  65214. ? wrapper.call(el, i, el)
  65215. : typeof wrapper === 'string' && !isHtml(wrapper)
  65216. ? lastParent.find(wrapper).clone()
  65217. : wrapper;
  65218. const [wrapperDom] = this._makeDomArray(wrap, i < lastIdx);
  65219. if (!wrapperDom || !hasChildren(wrapperDom))
  65220. continue;
  65221. let elInsertLocation = wrapperDom;
  65222. /*
  65223. * Find the deepest child. Only consider the first tag child of each node
  65224. * (ignore text); stop if no children are found.
  65225. */
  65226. let j = 0;
  65227. while (j < elInsertLocation.children.length) {
  65228. const child = elInsertLocation.children[j];
  65229. if (isTag$1(child)) {
  65230. elInsertLocation = child;
  65231. j = 0;
  65232. }
  65233. else {
  65234. j++;
  65235. }
  65236. }
  65237. insert(el, elInsertLocation, [wrapperDom]);
  65238. }
  65239. return this;
  65240. };
  65241. }
  65242. /**
  65243. * The .wrap() function can take any string or object that could be passed to
  65244. * the $() factory function to specify a DOM structure. This structure may be
  65245. * nested several levels deep, but should contain only one inmost element. A
  65246. * copy of this structure will be wrapped around each of the elements in the set
  65247. * of matched elements. This method returns the original set of elements for
  65248. * chaining purposes.
  65249. *
  65250. * @category Manipulation
  65251. * @example
  65252. *
  65253. * ```js
  65254. * const redFruit = $('<div class="red-fruit"></div>');
  65255. * $('.apple').wrap(redFruit);
  65256. *
  65257. * //=> <ul id="fruits">
  65258. * // <div class="red-fruit">
  65259. * // <li class="apple">Apple</li>
  65260. * // </div>
  65261. * // <li class="orange">Orange</li>
  65262. * // <li class="plum">Plum</li>
  65263. * // </ul>
  65264. *
  65265. * const healthy = $('<div class="healthy"></div>');
  65266. * $('li').wrap(healthy);
  65267. *
  65268. * //=> <ul id="fruits">
  65269. * // <div class="healthy">
  65270. * // <li class="apple">Apple</li>
  65271. * // </div>
  65272. * // <div class="healthy">
  65273. * // <li class="orange">Orange</li>
  65274. * // </div>
  65275. * // <div class="healthy">
  65276. * // <li class="plum">Plum</li>
  65277. * // </div>
  65278. * // </ul>
  65279. * ```
  65280. *
  65281. * @param wrapper - The DOM structure to wrap around each element in the selection.
  65282. * @see {@link https://api.jquery.com/wrap/}
  65283. */
  65284. const wrap$2 = _wrap((el, elInsertLocation, wrapperDom) => {
  65285. const { parent } = el;
  65286. if (!parent)
  65287. return;
  65288. const siblings = parent.children;
  65289. const index = siblings.indexOf(el);
  65290. update([el], elInsertLocation);
  65291. /*
  65292. * The previous operation removed the current element from the `siblings`
  65293. * array, so the `dom` array can be inserted without removing any
  65294. * additional elements.
  65295. */
  65296. uniqueSplice(siblings, index, 0, wrapperDom, parent);
  65297. });
  65298. /**
  65299. * The .wrapInner() function can take any string or object that could be passed
  65300. * to the $() factory function to specify a DOM structure. This structure may be
  65301. * nested several levels deep, but should contain only one inmost element. The
  65302. * structure will be wrapped around the content of each of the elements in the
  65303. * set of matched elements.
  65304. *
  65305. * @category Manipulation
  65306. * @example
  65307. *
  65308. * ```js
  65309. * const redFruit = $('<div class="red-fruit"></div>');
  65310. * $('.apple').wrapInner(redFruit);
  65311. *
  65312. * //=> <ul id="fruits">
  65313. * // <li class="apple">
  65314. * // <div class="red-fruit">Apple</div>
  65315. * // </li>
  65316. * // <li class="orange">Orange</li>
  65317. * // <li class="pear">Pear</li>
  65318. * // </ul>
  65319. *
  65320. * const healthy = $('<div class="healthy"></div>');
  65321. * $('li').wrapInner(healthy);
  65322. *
  65323. * //=> <ul id="fruits">
  65324. * // <li class="apple">
  65325. * // <div class="healthy">Apple</div>
  65326. * // </li>
  65327. * // <li class="orange">
  65328. * // <div class="healthy">Orange</div>
  65329. * // </li>
  65330. * // <li class="pear">
  65331. * // <div class="healthy">Pear</div>
  65332. * // </li>
  65333. * // </ul>
  65334. * ```
  65335. *
  65336. * @param wrapper - The DOM structure to wrap around the content of each element
  65337. * in the selection.
  65338. * @returns The instance itself, for chaining.
  65339. * @see {@link https://api.jquery.com/wrapInner/}
  65340. */
  65341. const wrapInner = _wrap((el, elInsertLocation, wrapperDom) => {
  65342. if (!hasChildren(el))
  65343. return;
  65344. update(el.children, elInsertLocation);
  65345. update(wrapperDom, el);
  65346. });
  65347. /**
  65348. * The .unwrap() function, removes the parents of the set of matched elements
  65349. * from the DOM, leaving the matched elements in their place.
  65350. *
  65351. * @category Manipulation
  65352. * @example <caption>without selector</caption>
  65353. *
  65354. * ```js
  65355. * const $ = cheerio.load(
  65356. * '<div id=test>\n <div><p>Hello</p></div>\n <div><p>World</p></div>\n</div>'
  65357. * );
  65358. * $('#test p').unwrap();
  65359. *
  65360. * //=> <div id=test>
  65361. * // <p>Hello</p>
  65362. * // <p>World</p>
  65363. * // </div>
  65364. * ```
  65365. *
  65366. * @example <caption>with selector</caption>
  65367. *
  65368. * ```js
  65369. * const $ = cheerio.load(
  65370. * '<div id=test>\n <p>Hello</p>\n <b><p>World</p></b>\n</div>'
  65371. * );
  65372. * $('#test p').unwrap('b');
  65373. *
  65374. * //=> <div id=test>
  65375. * // <p>Hello</p>
  65376. * // <p>World</p>
  65377. * // </div>
  65378. * ```
  65379. *
  65380. * @param selector - A selector to check the parent element against. If an
  65381. * element's parent does not match the selector, the element won't be unwrapped.
  65382. * @returns The instance itself, for chaining.
  65383. * @see {@link https://api.jquery.com/unwrap/}
  65384. */
  65385. function unwrap(selector) {
  65386. this.parent(selector)
  65387. .not('body')
  65388. .each((_, el) => {
  65389. this._make(el).replaceWith(el.children);
  65390. });
  65391. return this;
  65392. }
  65393. /**
  65394. * The .wrapAll() function can take any string or object that could be passed to
  65395. * the $() function to specify a DOM structure. This structure may be nested
  65396. * several levels deep, but should contain only one inmost element. The
  65397. * structure will be wrapped around all of the elements in the set of matched
  65398. * elements, as a single group.
  65399. *
  65400. * @category Manipulation
  65401. * @example <caption>With markup passed to `wrapAll`</caption>
  65402. *
  65403. * ```js
  65404. * const $ = cheerio.load(
  65405. * '<div class="container"><div class="inner">First</div><div class="inner">Second</div></div>'
  65406. * );
  65407. * $('.inner').wrapAll("<div class='new'></div>");
  65408. *
  65409. * //=> <div class="container">
  65410. * // <div class='new'>
  65411. * // <div class="inner">First</div>
  65412. * // <div class="inner">Second</div>
  65413. * // </div>
  65414. * // </div>
  65415. * ```
  65416. *
  65417. * @example <caption>With an existing cheerio instance</caption>
  65418. *
  65419. * ```js
  65420. * const $ = cheerio.load(
  65421. * '<span>Span 1</span><strong>Strong</strong><span>Span 2</span>'
  65422. * );
  65423. * const wrap = $('<div><p><em><b></b></em></p></div>');
  65424. * $('span').wrapAll(wrap);
  65425. *
  65426. * //=> <div>
  65427. * // <p>
  65428. * // <em>
  65429. * // <b>
  65430. * // <span>Span 1</span>
  65431. * // <span>Span 2</span>
  65432. * // </b>
  65433. * // </em>
  65434. * // </p>
  65435. * // </div>
  65436. * // <strong>Strong</strong>
  65437. * ```
  65438. *
  65439. * @param wrapper - The DOM structure to wrap around all matched elements in the
  65440. * selection.
  65441. * @returns The instance itself.
  65442. * @see {@link https://api.jquery.com/wrapAll/}
  65443. */
  65444. function wrapAll(wrapper) {
  65445. const el = this[0];
  65446. if (el) {
  65447. const wrap = this._make(typeof wrapper === 'function' ? wrapper.call(el, 0, el) : wrapper).insertBefore(el);
  65448. // If html is given as wrapper, wrap may contain text elements
  65449. let elInsertLocation;
  65450. for (let i = 0; i < wrap.length; i++) {
  65451. if (wrap[i].type === 'tag')
  65452. elInsertLocation = wrap[i];
  65453. }
  65454. let j = 0;
  65455. /*
  65456. * Find the deepest child. Only consider the first tag child of each node
  65457. * (ignore text); stop if no children are found.
  65458. */
  65459. while (elInsertLocation && j < elInsertLocation.children.length) {
  65460. const child = elInsertLocation.children[j];
  65461. if (child.type === 'tag') {
  65462. elInsertLocation = child;
  65463. j = 0;
  65464. }
  65465. else {
  65466. j++;
  65467. }
  65468. }
  65469. if (elInsertLocation)
  65470. this._make(elInsertLocation).append(this);
  65471. }
  65472. return this;
  65473. }
  65474. /* eslint-disable jsdoc/check-param-names*/
  65475. /**
  65476. * Insert content next to each element in the set of matched elements.
  65477. *
  65478. * @category Manipulation
  65479. * @example
  65480. *
  65481. * ```js
  65482. * $('.apple').after('<li class="plum">Plum</li>');
  65483. * $.html();
  65484. * //=> <ul id="fruits">
  65485. * // <li class="apple">Apple</li>
  65486. * // <li class="plum">Plum</li>
  65487. * // <li class="orange">Orange</li>
  65488. * // <li class="pear">Pear</li>
  65489. * // </ul>
  65490. * ```
  65491. *
  65492. * @param content - HTML string, DOM element, array of DOM elements or Cheerio
  65493. * to insert after each element in the set of matched elements.
  65494. * @returns The instance itself.
  65495. * @see {@link https://api.jquery.com/after/}
  65496. */
  65497. function after(...elems) {
  65498. const lastIdx = this.length - 1;
  65499. return domEach(this, (el, i) => {
  65500. const { parent } = el;
  65501. if (!hasChildren(el) || !parent) {
  65502. return;
  65503. }
  65504. const siblings = parent.children;
  65505. const index = siblings.indexOf(el);
  65506. // If not found, move on
  65507. /* istanbul ignore next */
  65508. if (index < 0)
  65509. return;
  65510. const domSrc = typeof elems[0] === 'function'
  65511. ? elems[0].call(el, i, this._render(el.children))
  65512. : elems;
  65513. const dom = this._makeDomArray(domSrc, i < lastIdx);
  65514. // Add element after `this` element
  65515. uniqueSplice(siblings, index + 1, 0, dom, parent);
  65516. });
  65517. }
  65518. /* eslint-enable jsdoc/check-param-names*/
  65519. /**
  65520. * Insert every element in the set of matched elements after the target.
  65521. *
  65522. * @category Manipulation
  65523. * @example
  65524. *
  65525. * ```js
  65526. * $('<li class="plum">Plum</li>').insertAfter('.apple');
  65527. * $.html();
  65528. * //=> <ul id="fruits">
  65529. * // <li class="apple">Apple</li>
  65530. * // <li class="plum">Plum</li>
  65531. * // <li class="orange">Orange</li>
  65532. * // <li class="pear">Pear</li>
  65533. * // </ul>
  65534. * ```
  65535. *
  65536. * @param target - Element to insert elements after.
  65537. * @returns The set of newly inserted elements.
  65538. * @see {@link https://api.jquery.com/insertAfter/}
  65539. */
  65540. function insertAfter(target) {
  65541. if (typeof target === 'string') {
  65542. target = this._make(target);
  65543. }
  65544. this.remove();
  65545. const clones = [];
  65546. this._makeDomArray(target).forEach((el) => {
  65547. const clonedSelf = this.clone().toArray();
  65548. const { parent } = el;
  65549. if (!parent) {
  65550. return;
  65551. }
  65552. const siblings = parent.children;
  65553. const index = siblings.indexOf(el);
  65554. // If not found, move on
  65555. /* istanbul ignore next */
  65556. if (index < 0)
  65557. return;
  65558. // Add cloned `this` element(s) after target element
  65559. uniqueSplice(siblings, index + 1, 0, clonedSelf, parent);
  65560. clones.push(...clonedSelf);
  65561. });
  65562. return this._make(clones);
  65563. }
  65564. /* eslint-disable jsdoc/check-param-names*/
  65565. /**
  65566. * Insert content previous to each element in the set of matched elements.
  65567. *
  65568. * @category Manipulation
  65569. * @example
  65570. *
  65571. * ```js
  65572. * $('.apple').before('<li class="plum">Plum</li>');
  65573. * $.html();
  65574. * //=> <ul id="fruits">
  65575. * // <li class="plum">Plum</li>
  65576. * // <li class="apple">Apple</li>
  65577. * // <li class="orange">Orange</li>
  65578. * // <li class="pear">Pear</li>
  65579. * // </ul>
  65580. * ```
  65581. *
  65582. * @param content - HTML string, DOM element, array of DOM elements or Cheerio
  65583. * to insert before each element in the set of matched elements.
  65584. * @returns The instance itself.
  65585. * @see {@link https://api.jquery.com/before/}
  65586. */
  65587. function before(...elems) {
  65588. const lastIdx = this.length - 1;
  65589. return domEach(this, (el, i) => {
  65590. const { parent } = el;
  65591. if (!hasChildren(el) || !parent) {
  65592. return;
  65593. }
  65594. const siblings = parent.children;
  65595. const index = siblings.indexOf(el);
  65596. // If not found, move on
  65597. /* istanbul ignore next */
  65598. if (index < 0)
  65599. return;
  65600. const domSrc = typeof elems[0] === 'function'
  65601. ? elems[0].call(el, i, this._render(el.children))
  65602. : elems;
  65603. const dom = this._makeDomArray(domSrc, i < lastIdx);
  65604. // Add element before `el` element
  65605. uniqueSplice(siblings, index, 0, dom, parent);
  65606. });
  65607. }
  65608. /* eslint-enable jsdoc/check-param-names*/
  65609. /**
  65610. * Insert every element in the set of matched elements before the target.
  65611. *
  65612. * @category Manipulation
  65613. * @example
  65614. *
  65615. * ```js
  65616. * $('<li class="plum">Plum</li>').insertBefore('.apple');
  65617. * $.html();
  65618. * //=> <ul id="fruits">
  65619. * // <li class="plum">Plum</li>
  65620. * // <li class="apple">Apple</li>
  65621. * // <li class="orange">Orange</li>
  65622. * // <li class="pear">Pear</li>
  65623. * // </ul>
  65624. * ```
  65625. *
  65626. * @param target - Element to insert elements before.
  65627. * @returns The set of newly inserted elements.
  65628. * @see {@link https://api.jquery.com/insertBefore/}
  65629. */
  65630. function insertBefore(target) {
  65631. const targetArr = this._make(target);
  65632. this.remove();
  65633. const clones = [];
  65634. domEach(targetArr, (el) => {
  65635. const clonedSelf = this.clone().toArray();
  65636. const { parent } = el;
  65637. if (!parent) {
  65638. return;
  65639. }
  65640. const siblings = parent.children;
  65641. const index = siblings.indexOf(el);
  65642. // If not found, move on
  65643. /* istanbul ignore next */
  65644. if (index < 0)
  65645. return;
  65646. // Add cloned `this` element(s) after target element
  65647. uniqueSplice(siblings, index, 0, clonedSelf, parent);
  65648. clones.push(...clonedSelf);
  65649. });
  65650. return this._make(clones);
  65651. }
  65652. /**
  65653. * Removes the set of matched elements from the DOM and all their children.
  65654. * `selector` filters the set of matched elements to be removed.
  65655. *
  65656. * @category Manipulation
  65657. * @example
  65658. *
  65659. * ```js
  65660. * $('.pear').remove();
  65661. * $.html();
  65662. * //=> <ul id="fruits">
  65663. * // <li class="apple">Apple</li>
  65664. * // <li class="orange">Orange</li>
  65665. * // </ul>
  65666. * ```
  65667. *
  65668. * @param selector - Optional selector for elements to remove.
  65669. * @returns The instance itself.
  65670. * @see {@link https://api.jquery.com/remove/}
  65671. */
  65672. function remove$1(selector) {
  65673. // Filter if we have selector
  65674. const elems = selector ? this.filter(selector) : this;
  65675. domEach(elems, (el) => {
  65676. removeElement(el);
  65677. el.prev = el.next = el.parent = null;
  65678. });
  65679. return this;
  65680. }
  65681. /**
  65682. * Replaces matched elements with `content`.
  65683. *
  65684. * @category Manipulation
  65685. * @example
  65686. *
  65687. * ```js
  65688. * const plum = $('<li class="plum">Plum</li>');
  65689. * $('.pear').replaceWith(plum);
  65690. * $.html();
  65691. * //=> <ul id="fruits">
  65692. * // <li class="apple">Apple</li>
  65693. * // <li class="orange">Orange</li>
  65694. * // <li class="plum">Plum</li>
  65695. * // </ul>
  65696. * ```
  65697. *
  65698. * @param content - Replacement for matched elements.
  65699. * @returns The instance itself.
  65700. * @see {@link https://api.jquery.com/replaceWith/}
  65701. */
  65702. function replaceWith(content) {
  65703. return domEach(this, (el, i) => {
  65704. const { parent } = el;
  65705. if (!parent) {
  65706. return;
  65707. }
  65708. const siblings = parent.children;
  65709. const cont = typeof content === 'function' ? content.call(el, i, el) : content;
  65710. const dom = this._makeDomArray(cont);
  65711. /*
  65712. * In the case that `dom` contains nodes that already exist in other
  65713. * structures, ensure those nodes are properly removed.
  65714. */
  65715. update(dom, null);
  65716. const index = siblings.indexOf(el);
  65717. // Completely remove old element
  65718. uniqueSplice(siblings, index, 1, dom, parent);
  65719. if (!dom.includes(el)) {
  65720. el.parent = el.prev = el.next = null;
  65721. }
  65722. });
  65723. }
  65724. /**
  65725. * Empties an element, removing all its children.
  65726. *
  65727. * @category Manipulation
  65728. * @example
  65729. *
  65730. * ```js
  65731. * $('ul').empty();
  65732. * $.html();
  65733. * //=> <ul id="fruits"></ul>
  65734. * ```
  65735. *
  65736. * @returns The instance itself.
  65737. * @see {@link https://api.jquery.com/empty/}
  65738. */
  65739. function empty$1() {
  65740. return domEach(this, (el) => {
  65741. if (!hasChildren(el))
  65742. return;
  65743. el.children.forEach((child) => {
  65744. child.next = child.prev = child.parent = null;
  65745. });
  65746. el.children.length = 0;
  65747. });
  65748. }
  65749. function html$2(str) {
  65750. if (str === undefined) {
  65751. const el = this[0];
  65752. if (!el || !hasChildren(el))
  65753. return null;
  65754. return this._render(el.children);
  65755. }
  65756. return domEach(this, (el) => {
  65757. if (!hasChildren(el))
  65758. return;
  65759. el.children.forEach((child) => {
  65760. child.next = child.prev = child.parent = null;
  65761. });
  65762. const content = isCheerio(str)
  65763. ? str.toArray()
  65764. : this._parse(`${str}`, this.options, false, el).children;
  65765. update(content, el);
  65766. });
  65767. }
  65768. /**
  65769. * Turns the collection to a string. Alias for `.html()`.
  65770. *
  65771. * @category Manipulation
  65772. * @returns The rendered document.
  65773. */
  65774. function toString$5() {
  65775. return this._render(this);
  65776. }
  65777. function text$1(str) {
  65778. // If `str` is undefined, act as a "getter"
  65779. if (str === undefined) {
  65780. return text(this);
  65781. }
  65782. if (typeof str === 'function') {
  65783. // Function support
  65784. return domEach(this, (el, i) => this._make(el).text(str.call(el, i, text([el]))));
  65785. }
  65786. // Append text node to each selected elements
  65787. return domEach(this, (el) => {
  65788. if (!hasChildren(el))
  65789. return;
  65790. el.children.forEach((child) => {
  65791. child.next = child.prev = child.parent = null;
  65792. });
  65793. const textNode = new Text$1(`${str}`);
  65794. update(textNode, el);
  65795. });
  65796. }
  65797. /**
  65798. * Clone the cheerio object.
  65799. *
  65800. * @category Manipulation
  65801. * @example
  65802. *
  65803. * ```js
  65804. * const moreFruit = $('#fruits').clone();
  65805. * ```
  65806. *
  65807. * @returns The cloned object.
  65808. * @see {@link https://api.jquery.com/clone/}
  65809. */
  65810. function clone() {
  65811. return this._make(cloneDom(this.get()));
  65812. }
  65813. var Manipulation = /*#__PURE__*/Object.freeze({
  65814. __proto__: null,
  65815. _makeDomArray: _makeDomArray,
  65816. appendTo: appendTo,
  65817. prependTo: prependTo,
  65818. append: append$1,
  65819. prepend: prepend$1,
  65820. wrap: wrap$2,
  65821. wrapInner: wrapInner,
  65822. unwrap: unwrap,
  65823. wrapAll: wrapAll,
  65824. after: after,
  65825. insertAfter: insertAfter,
  65826. before: before,
  65827. insertBefore: insertBefore,
  65828. remove: remove$1,
  65829. replaceWith: replaceWith,
  65830. empty: empty$1,
  65831. html: html$2,
  65832. toString: toString$5,
  65833. text: text$1,
  65834. clone: clone
  65835. });
  65836. /**
  65837. * Set multiple CSS properties for every matched element.
  65838. *
  65839. * @category CSS
  65840. * @param prop - The names of the properties.
  65841. * @param val - The new values.
  65842. * @returns The instance itself.
  65843. * @see {@link https://api.jquery.com/css/}
  65844. */
  65845. function css(prop, val) {
  65846. if ((prop != null && val != null) ||
  65847. // When `prop` is a "plain" object
  65848. (typeof prop === 'object' && !Array.isArray(prop))) {
  65849. return domEach(this, (el, i) => {
  65850. if (isTag$1(el)) {
  65851. // `prop` can't be an array here anymore.
  65852. setCss(el, prop, val, i);
  65853. }
  65854. });
  65855. }
  65856. if (this.length === 0) {
  65857. return undefined;
  65858. }
  65859. return getCss(this[0], prop);
  65860. }
  65861. /**
  65862. * Set styles of all elements.
  65863. *
  65864. * @private
  65865. * @param el - Element to set style of.
  65866. * @param prop - Name of property.
  65867. * @param value - Value to set property to.
  65868. * @param idx - Optional index within the selection.
  65869. */
  65870. function setCss(el, prop, value, idx) {
  65871. if (typeof prop === 'string') {
  65872. const styles = getCss(el);
  65873. const val = typeof value === 'function' ? value.call(el, idx, styles[prop]) : value;
  65874. if (val === '') {
  65875. delete styles[prop];
  65876. }
  65877. else if (val != null) {
  65878. styles[prop] = val;
  65879. }
  65880. el.attribs['style'] = stringify$3(styles);
  65881. }
  65882. else if (typeof prop === 'object') {
  65883. Object.keys(prop).forEach((k, i) => {
  65884. setCss(el, k, prop[k], i);
  65885. });
  65886. }
  65887. }
  65888. function getCss(el, prop) {
  65889. if (!el || !isTag$1(el))
  65890. return;
  65891. const styles = parse$2(el.attribs['style']);
  65892. if (typeof prop === 'string') {
  65893. return styles[prop];
  65894. }
  65895. if (Array.isArray(prop)) {
  65896. const newStyles = {};
  65897. prop.forEach((item) => {
  65898. if (styles[item] != null) {
  65899. newStyles[item] = styles[item];
  65900. }
  65901. });
  65902. return newStyles;
  65903. }
  65904. return styles;
  65905. }
  65906. /**
  65907. * Stringify `obj` to styles.
  65908. *
  65909. * @private
  65910. * @category CSS
  65911. * @param obj - Object to stringify.
  65912. * @returns The serialized styles.
  65913. */
  65914. function stringify$3(obj) {
  65915. return Object.keys(obj).reduce((str, prop) => `${str}${str ? ' ' : ''}${prop}: ${obj[prop]};`, '');
  65916. }
  65917. /**
  65918. * Parse `styles`.
  65919. *
  65920. * @private
  65921. * @category CSS
  65922. * @param styles - Styles to be parsed.
  65923. * @returns The parsed styles.
  65924. */
  65925. function parse$2(styles) {
  65926. styles = (styles || '').trim();
  65927. if (!styles)
  65928. return {};
  65929. const obj = {};
  65930. let key;
  65931. for (const str of styles.split(';')) {
  65932. const n = str.indexOf(':');
  65933. // If there is no :, or if it is the first/last character, add to the previous item's value
  65934. if (n < 1 || n === str.length - 1) {
  65935. const trimmed = str.trimEnd();
  65936. if (trimmed.length > 0 && key !== undefined) {
  65937. obj[key] += `;${trimmed}`;
  65938. }
  65939. }
  65940. else {
  65941. key = str.slice(0, n).trim();
  65942. obj[key] = str.slice(n + 1).trim();
  65943. }
  65944. }
  65945. return obj;
  65946. }
  65947. var Css = /*#__PURE__*/Object.freeze({
  65948. __proto__: null,
  65949. css: css
  65950. });
  65951. /*
  65952. * https://github.com/jquery/jquery/blob/2.1.3/src/manipulation/var/rcheckableType.js
  65953. * https://github.com/jquery/jquery/blob/2.1.3/src/serialize.js
  65954. */
  65955. const submittableSelector = 'input,select,textarea,keygen';
  65956. const r20 = /%20/g;
  65957. const rCRLF = /\r?\n/g;
  65958. /**
  65959. * Encode a set of form elements as a string for submission.
  65960. *
  65961. * @category Forms
  65962. * @example
  65963. *
  65964. * ```js
  65965. * $('<form><input name="foo" value="bar" /></form>').serialize();
  65966. * //=> 'foo=bar'
  65967. * ```
  65968. *
  65969. * @returns The serialized form.
  65970. * @see {@link https://api.jquery.com/serialize/}
  65971. */
  65972. function serialize$1() {
  65973. // Convert form elements into name/value objects
  65974. const arr = this.serializeArray();
  65975. // Serialize each element into a key/value string
  65976. const retArr = arr.map((data) => `${encodeURIComponent(data.name)}=${encodeURIComponent(data.value)}`);
  65977. // Return the resulting serialization
  65978. return retArr.join('&').replace(r20, '+');
  65979. }
  65980. /**
  65981. * Encode a set of form elements as an array of names and values.
  65982. *
  65983. * @category Forms
  65984. * @example
  65985. *
  65986. * ```js
  65987. * $('<form><input name="foo" value="bar" /></form>').serializeArray();
  65988. * //=> [ { name: 'foo', value: 'bar' } ]
  65989. * ```
  65990. *
  65991. * @returns The serialized form.
  65992. * @see {@link https://api.jquery.com/serializeArray/}
  65993. */
  65994. function serializeArray() {
  65995. // Resolve all form elements from either forms or collections of form elements
  65996. return this.map((_, elem) => {
  65997. const $elem = this._make(elem);
  65998. if (isTag$1(elem) && elem.name === 'form') {
  65999. return $elem.find(submittableSelector).toArray();
  66000. }
  66001. return $elem.filter(submittableSelector).toArray();
  66002. })
  66003. .filter(
  66004. // Verify elements have a name (`attr.name`) and are not disabled (`:enabled`)
  66005. '[name!=""]:enabled' +
  66006. // And cannot be clicked (`[type=submit]`) or are used in `x-www-form-urlencoded` (`[type=file]`)
  66007. ':not(:submit, :button, :image, :reset, :file)' +
  66008. // And are either checked/don't have a checkable state
  66009. ':matches([checked], :not(:checkbox, :radio))'
  66010. // Convert each of the elements to its value(s)
  66011. )
  66012. .map((_, elem) => {
  66013. var _a;
  66014. const $elem = this._make(elem);
  66015. const name = $elem.attr('name'); // We have filtered for elements with a name before.
  66016. // If there is no value set (e.g. `undefined`, `null`), then default value to empty
  66017. const value = (_a = $elem.val()) !== null && _a !== void 0 ? _a : '';
  66018. // If we have an array of values (e.g. `<select multiple>`), return an array of key/value pairs
  66019. if (Array.isArray(value)) {
  66020. return value.map((val) =>
  66021. /*
  66022. * We trim replace any line endings (e.g. `\r` or `\r\n` with `\r\n`) to guarantee consistency across platforms
  66023. * These can occur inside of `<textarea>'s`
  66024. */
  66025. ({ name, value: val.replace(rCRLF, '\r\n') }));
  66026. }
  66027. // Otherwise (e.g. `<input type="text">`, return only one key/value pair
  66028. return { name, value: value.replace(rCRLF, '\r\n') };
  66029. })
  66030. .toArray();
  66031. }
  66032. var Forms = /*#__PURE__*/Object.freeze({
  66033. __proto__: null,
  66034. serialize: serialize$1,
  66035. serializeArray: serializeArray
  66036. });
  66037. class Cheerio {
  66038. /**
  66039. * Instance of cheerio. Methods are specified in the modules. Usage of this
  66040. * constructor is not recommended. Please use `$.load` instead.
  66041. *
  66042. * @private
  66043. * @param elements - The new selection.
  66044. * @param root - Sets the root node.
  66045. * @param options - Options for the instance.
  66046. */
  66047. constructor(elements, root, options) {
  66048. this.length = 0;
  66049. this.options = options;
  66050. this._root = root;
  66051. if (elements) {
  66052. for (let idx = 0; idx < elements.length; idx++) {
  66053. this[idx] = elements[idx];
  66054. }
  66055. this.length = elements.length;
  66056. }
  66057. }
  66058. }
  66059. /** Set a signature of the object. */
  66060. Cheerio.prototype.cheerio = '[cheerio object]';
  66061. /*
  66062. * Make cheerio an array-like object
  66063. */
  66064. Cheerio.prototype.splice = Array.prototype.splice;
  66065. // Support for (const element of $(...)) iteration:
  66066. Cheerio.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
  66067. // Plug in the API
  66068. Object.assign(Cheerio.prototype, Attributes, Traversing, Manipulation, Css, Forms);
  66069. function getLoad(parse, render) {
  66070. /**
  66071. * Create a querying function, bound to a document created from the provided markup.
  66072. *
  66073. * Note that similar to web browser contexts, this operation may introduce
  66074. * `<html>`, `<head>`, and `<body>` elements; set `isDocument` to `false` to
  66075. * switch to fragment mode and disable this.
  66076. *
  66077. * @param content - Markup to be loaded.
  66078. * @param options - Options for the created instance.
  66079. * @param isDocument - Allows parser to be switched to fragment mode.
  66080. * @returns The loaded document.
  66081. * @see {@link https://cheerio.js.org#loading} for additional usage information.
  66082. */
  66083. return function load(content, options, isDocument = true) {
  66084. if (content == null) {
  66085. throw new Error('cheerio.load() expects a string');
  66086. }
  66087. const internalOpts = { ...defaultOpts, ...flatten(options) };
  66088. const initialRoot = parse(content, internalOpts, isDocument, null);
  66089. /** Create an extended class here, so that extensions only live on one instance. */
  66090. class LoadedCheerio extends Cheerio {
  66091. _make(selector, context) {
  66092. const cheerio = initialize(selector, context);
  66093. cheerio.prevObject = this;
  66094. return cheerio;
  66095. }
  66096. _parse(content, options, isDocument, context) {
  66097. return parse(content, options, isDocument, context);
  66098. }
  66099. _render(dom) {
  66100. return render(dom, this.options);
  66101. }
  66102. }
  66103. function initialize(selector, context, root = initialRoot, opts) {
  66104. // $($)
  66105. if (selector && isCheerio(selector))
  66106. return selector;
  66107. const options = {
  66108. ...internalOpts,
  66109. ...flatten(opts),
  66110. };
  66111. const r = typeof root === 'string'
  66112. ? [parse(root, options, false, null)]
  66113. : 'length' in root
  66114. ? root
  66115. : [root];
  66116. const rootInstance = isCheerio(r)
  66117. ? r
  66118. : new LoadedCheerio(r, null, options);
  66119. // Add a cyclic reference, so that calling methods on `_root` never fails.
  66120. rootInstance._root = rootInstance;
  66121. // $(), $(null), $(undefined), $(false)
  66122. if (!selector) {
  66123. return new LoadedCheerio(undefined, rootInstance, options);
  66124. }
  66125. const elements = typeof selector === 'string' && isHtml(selector)
  66126. ? // $(<html>)
  66127. parse(selector, options, false, null).children
  66128. : isNode(selector)
  66129. ? // $(dom)
  66130. [selector]
  66131. : Array.isArray(selector)
  66132. ? // $([dom])
  66133. selector
  66134. : undefined;
  66135. const instance = new LoadedCheerio(elements, rootInstance, options);
  66136. if (elements) {
  66137. return instance;
  66138. }
  66139. if (typeof selector !== 'string') {
  66140. throw new Error('Unexpected type of selector');
  66141. }
  66142. // We know that our selector is a string now.
  66143. let search = selector;
  66144. const searchContext = !context
  66145. ? // If we don't have a context, maybe we have a root, from loading
  66146. rootInstance
  66147. : typeof context === 'string'
  66148. ? isHtml(context)
  66149. ? // $('li', '<ul>...</ul>')
  66150. new LoadedCheerio([parse(context, options, false, null)], rootInstance, options)
  66151. : // $('li', 'ul')
  66152. ((search = `${context} ${search}`), rootInstance)
  66153. : isCheerio(context)
  66154. ? // $('li', $)
  66155. context
  66156. : // $('li', node), $('li', [nodes])
  66157. new LoadedCheerio(Array.isArray(context) ? context : [context], rootInstance, options);
  66158. // If we still don't have a context, return
  66159. if (!searchContext)
  66160. return instance;
  66161. /*
  66162. * #id, .class, tag
  66163. */
  66164. return searchContext.find(search);
  66165. }
  66166. // Add in static methods & properties
  66167. Object.assign(initialize, staticMethods, {
  66168. load,
  66169. // `_root` and `_options` are used in static methods.
  66170. _root: initialRoot,
  66171. _options: internalOpts,
  66172. // Add `fn` for plugins
  66173. fn: LoadedCheerio.prototype,
  66174. // Add the prototype here to maintain `instanceof` behavior.
  66175. prototype: LoadedCheerio.prototype,
  66176. });
  66177. return initialize;
  66178. };
  66179. }
  66180. function isNode(obj) {
  66181. return (!!obj.name ||
  66182. obj.type === 'root' ||
  66183. obj.type === 'text' ||
  66184. obj.type === 'comment');
  66185. }
  66186. const UNDEFINED_CODE_POINTS = new Set([
  66187. 65534, 65535, 131070, 131071, 196606, 196607, 262142, 262143, 327678, 327679, 393214,
  66188. 393215, 458750, 458751, 524286, 524287, 589822, 589823, 655358, 655359, 720894,
  66189. 720895, 786430, 786431, 851966, 851967, 917502, 917503, 983038, 983039, 1048574,
  66190. 1048575, 1114110, 1114111,
  66191. ]);
  66192. const REPLACEMENT_CHARACTER = '\uFFFD';
  66193. var CODE_POINTS;
  66194. (function (CODE_POINTS) {
  66195. CODE_POINTS[CODE_POINTS["EOF"] = -1] = "EOF";
  66196. CODE_POINTS[CODE_POINTS["NULL"] = 0] = "NULL";
  66197. CODE_POINTS[CODE_POINTS["TABULATION"] = 9] = "TABULATION";
  66198. CODE_POINTS[CODE_POINTS["CARRIAGE_RETURN"] = 13] = "CARRIAGE_RETURN";
  66199. CODE_POINTS[CODE_POINTS["LINE_FEED"] = 10] = "LINE_FEED";
  66200. CODE_POINTS[CODE_POINTS["FORM_FEED"] = 12] = "FORM_FEED";
  66201. CODE_POINTS[CODE_POINTS["SPACE"] = 32] = "SPACE";
  66202. CODE_POINTS[CODE_POINTS["EXCLAMATION_MARK"] = 33] = "EXCLAMATION_MARK";
  66203. CODE_POINTS[CODE_POINTS["QUOTATION_MARK"] = 34] = "QUOTATION_MARK";
  66204. CODE_POINTS[CODE_POINTS["NUMBER_SIGN"] = 35] = "NUMBER_SIGN";
  66205. CODE_POINTS[CODE_POINTS["AMPERSAND"] = 38] = "AMPERSAND";
  66206. CODE_POINTS[CODE_POINTS["APOSTROPHE"] = 39] = "APOSTROPHE";
  66207. CODE_POINTS[CODE_POINTS["HYPHEN_MINUS"] = 45] = "HYPHEN_MINUS";
  66208. CODE_POINTS[CODE_POINTS["SOLIDUS"] = 47] = "SOLIDUS";
  66209. CODE_POINTS[CODE_POINTS["DIGIT_0"] = 48] = "DIGIT_0";
  66210. CODE_POINTS[CODE_POINTS["DIGIT_9"] = 57] = "DIGIT_9";
  66211. CODE_POINTS[CODE_POINTS["SEMICOLON"] = 59] = "SEMICOLON";
  66212. CODE_POINTS[CODE_POINTS["LESS_THAN_SIGN"] = 60] = "LESS_THAN_SIGN";
  66213. CODE_POINTS[CODE_POINTS["EQUALS_SIGN"] = 61] = "EQUALS_SIGN";
  66214. CODE_POINTS[CODE_POINTS["GREATER_THAN_SIGN"] = 62] = "GREATER_THAN_SIGN";
  66215. CODE_POINTS[CODE_POINTS["QUESTION_MARK"] = 63] = "QUESTION_MARK";
  66216. CODE_POINTS[CODE_POINTS["LATIN_CAPITAL_A"] = 65] = "LATIN_CAPITAL_A";
  66217. CODE_POINTS[CODE_POINTS["LATIN_CAPITAL_F"] = 70] = "LATIN_CAPITAL_F";
  66218. CODE_POINTS[CODE_POINTS["LATIN_CAPITAL_X"] = 88] = "LATIN_CAPITAL_X";
  66219. CODE_POINTS[CODE_POINTS["LATIN_CAPITAL_Z"] = 90] = "LATIN_CAPITAL_Z";
  66220. CODE_POINTS[CODE_POINTS["RIGHT_SQUARE_BRACKET"] = 93] = "RIGHT_SQUARE_BRACKET";
  66221. CODE_POINTS[CODE_POINTS["GRAVE_ACCENT"] = 96] = "GRAVE_ACCENT";
  66222. CODE_POINTS[CODE_POINTS["LATIN_SMALL_A"] = 97] = "LATIN_SMALL_A";
  66223. CODE_POINTS[CODE_POINTS["LATIN_SMALL_F"] = 102] = "LATIN_SMALL_F";
  66224. CODE_POINTS[CODE_POINTS["LATIN_SMALL_X"] = 120] = "LATIN_SMALL_X";
  66225. CODE_POINTS[CODE_POINTS["LATIN_SMALL_Z"] = 122] = "LATIN_SMALL_Z";
  66226. CODE_POINTS[CODE_POINTS["REPLACEMENT_CHARACTER"] = 65533] = "REPLACEMENT_CHARACTER";
  66227. })(CODE_POINTS || (CODE_POINTS = {}));
  66228. const SEQUENCES = {
  66229. DASH_DASH: '--',
  66230. CDATA_START: '[CDATA[',
  66231. DOCTYPE: 'doctype',
  66232. SCRIPT: 'script',
  66233. PUBLIC: 'public',
  66234. SYSTEM: 'system',
  66235. };
  66236. //Surrogates
  66237. function isSurrogate(cp) {
  66238. return cp >= 55296 && cp <= 57343;
  66239. }
  66240. function isSurrogatePair(cp) {
  66241. return cp >= 56320 && cp <= 57343;
  66242. }
  66243. function getSurrogatePairCodePoint(cp1, cp2) {
  66244. return (cp1 - 55296) * 1024 + 9216 + cp2;
  66245. }
  66246. //NOTE: excluding NULL and ASCII whitespace
  66247. function isControlCodePoint(cp) {
  66248. return ((cp !== 0x20 && cp !== 0x0a && cp !== 0x0d && cp !== 0x09 && cp !== 0x0c && cp >= 0x01 && cp <= 0x1f) ||
  66249. (cp >= 0x7f && cp <= 0x9f));
  66250. }
  66251. function isUndefinedCodePoint(cp) {
  66252. return (cp >= 64976 && cp <= 65007) || UNDEFINED_CODE_POINTS.has(cp);
  66253. }
  66254. var ERR;
  66255. (function (ERR) {
  66256. ERR["controlCharacterInInputStream"] = "control-character-in-input-stream";
  66257. ERR["noncharacterInInputStream"] = "noncharacter-in-input-stream";
  66258. ERR["surrogateInInputStream"] = "surrogate-in-input-stream";
  66259. ERR["nonVoidHtmlElementStartTagWithTrailingSolidus"] = "non-void-html-element-start-tag-with-trailing-solidus";
  66260. ERR["endTagWithAttributes"] = "end-tag-with-attributes";
  66261. ERR["endTagWithTrailingSolidus"] = "end-tag-with-trailing-solidus";
  66262. ERR["unexpectedSolidusInTag"] = "unexpected-solidus-in-tag";
  66263. ERR["unexpectedNullCharacter"] = "unexpected-null-character";
  66264. ERR["unexpectedQuestionMarkInsteadOfTagName"] = "unexpected-question-mark-instead-of-tag-name";
  66265. ERR["invalidFirstCharacterOfTagName"] = "invalid-first-character-of-tag-name";
  66266. ERR["unexpectedEqualsSignBeforeAttributeName"] = "unexpected-equals-sign-before-attribute-name";
  66267. ERR["missingEndTagName"] = "missing-end-tag-name";
  66268. ERR["unexpectedCharacterInAttributeName"] = "unexpected-character-in-attribute-name";
  66269. ERR["unknownNamedCharacterReference"] = "unknown-named-character-reference";
  66270. ERR["missingSemicolonAfterCharacterReference"] = "missing-semicolon-after-character-reference";
  66271. ERR["unexpectedCharacterAfterDoctypeSystemIdentifier"] = "unexpected-character-after-doctype-system-identifier";
  66272. ERR["unexpectedCharacterInUnquotedAttributeValue"] = "unexpected-character-in-unquoted-attribute-value";
  66273. ERR["eofBeforeTagName"] = "eof-before-tag-name";
  66274. ERR["eofInTag"] = "eof-in-tag";
  66275. ERR["missingAttributeValue"] = "missing-attribute-value";
  66276. ERR["missingWhitespaceBetweenAttributes"] = "missing-whitespace-between-attributes";
  66277. ERR["missingWhitespaceAfterDoctypePublicKeyword"] = "missing-whitespace-after-doctype-public-keyword";
  66278. ERR["missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers"] = "missing-whitespace-between-doctype-public-and-system-identifiers";
  66279. ERR["missingWhitespaceAfterDoctypeSystemKeyword"] = "missing-whitespace-after-doctype-system-keyword";
  66280. ERR["missingQuoteBeforeDoctypePublicIdentifier"] = "missing-quote-before-doctype-public-identifier";
  66281. ERR["missingQuoteBeforeDoctypeSystemIdentifier"] = "missing-quote-before-doctype-system-identifier";
  66282. ERR["missingDoctypePublicIdentifier"] = "missing-doctype-public-identifier";
  66283. ERR["missingDoctypeSystemIdentifier"] = "missing-doctype-system-identifier";
  66284. ERR["abruptDoctypePublicIdentifier"] = "abrupt-doctype-public-identifier";
  66285. ERR["abruptDoctypeSystemIdentifier"] = "abrupt-doctype-system-identifier";
  66286. ERR["cdataInHtmlContent"] = "cdata-in-html-content";
  66287. ERR["incorrectlyOpenedComment"] = "incorrectly-opened-comment";
  66288. ERR["eofInScriptHtmlCommentLikeText"] = "eof-in-script-html-comment-like-text";
  66289. ERR["eofInDoctype"] = "eof-in-doctype";
  66290. ERR["nestedComment"] = "nested-comment";
  66291. ERR["abruptClosingOfEmptyComment"] = "abrupt-closing-of-empty-comment";
  66292. ERR["eofInComment"] = "eof-in-comment";
  66293. ERR["incorrectlyClosedComment"] = "incorrectly-closed-comment";
  66294. ERR["eofInCdata"] = "eof-in-cdata";
  66295. ERR["absenceOfDigitsInNumericCharacterReference"] = "absence-of-digits-in-numeric-character-reference";
  66296. ERR["nullCharacterReference"] = "null-character-reference";
  66297. ERR["surrogateCharacterReference"] = "surrogate-character-reference";
  66298. ERR["characterReferenceOutsideUnicodeRange"] = "character-reference-outside-unicode-range";
  66299. ERR["controlCharacterReference"] = "control-character-reference";
  66300. ERR["noncharacterCharacterReference"] = "noncharacter-character-reference";
  66301. ERR["missingWhitespaceBeforeDoctypeName"] = "missing-whitespace-before-doctype-name";
  66302. ERR["missingDoctypeName"] = "missing-doctype-name";
  66303. ERR["invalidCharacterSequenceAfterDoctypeName"] = "invalid-character-sequence-after-doctype-name";
  66304. ERR["duplicateAttribute"] = "duplicate-attribute";
  66305. ERR["nonConformingDoctype"] = "non-conforming-doctype";
  66306. ERR["missingDoctype"] = "missing-doctype";
  66307. ERR["misplacedDoctype"] = "misplaced-doctype";
  66308. ERR["endTagWithoutMatchingOpenElement"] = "end-tag-without-matching-open-element";
  66309. ERR["closingOfElementWithOpenChildElements"] = "closing-of-element-with-open-child-elements";
  66310. ERR["disallowedContentInNoscriptInHead"] = "disallowed-content-in-noscript-in-head";
  66311. ERR["openElementsLeftAfterEof"] = "open-elements-left-after-eof";
  66312. ERR["abandonedHeadElementChild"] = "abandoned-head-element-child";
  66313. ERR["misplacedStartTagForHeadElement"] = "misplaced-start-tag-for-head-element";
  66314. ERR["nestedNoscriptInHead"] = "nested-noscript-in-head";
  66315. ERR["eofInElementThatCanContainOnlyText"] = "eof-in-element-that-can-contain-only-text";
  66316. })(ERR || (ERR = {}));
  66317. //Const
  66318. const DEFAULT_BUFFER_WATERLINE = 1 << 16;
  66319. //Preprocessor
  66320. //NOTE: HTML input preprocessing
  66321. //(see: http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#preprocessing-the-input-stream)
  66322. class Preprocessor {
  66323. constructor(handler) {
  66324. this.handler = handler;
  66325. this.html = '';
  66326. this.pos = -1;
  66327. // NOTE: Initial `lastGapPos` is -2, to ensure `col` on initialisation is 0
  66328. this.lastGapPos = -2;
  66329. this.gapStack = [];
  66330. this.skipNextNewLine = false;
  66331. this.lastChunkWritten = false;
  66332. this.endOfChunkHit = false;
  66333. this.bufferWaterline = DEFAULT_BUFFER_WATERLINE;
  66334. this.isEol = false;
  66335. this.lineStartPos = 0;
  66336. this.droppedBufferSize = 0;
  66337. this.line = 1;
  66338. //NOTE: avoid reporting errors twice on advance/retreat
  66339. this.lastErrOffset = -1;
  66340. }
  66341. /** The column on the current line. If we just saw a gap (eg. a surrogate pair), return the index before. */
  66342. get col() {
  66343. return this.pos - this.lineStartPos + Number(this.lastGapPos !== this.pos);
  66344. }
  66345. get offset() {
  66346. return this.droppedBufferSize + this.pos;
  66347. }
  66348. getError(code) {
  66349. const { line, col, offset } = this;
  66350. return {
  66351. code,
  66352. startLine: line,
  66353. endLine: line,
  66354. startCol: col,
  66355. endCol: col,
  66356. startOffset: offset,
  66357. endOffset: offset,
  66358. };
  66359. }
  66360. _err(code) {
  66361. if (this.handler.onParseError && this.lastErrOffset !== this.offset) {
  66362. this.lastErrOffset = this.offset;
  66363. this.handler.onParseError(this.getError(code));
  66364. }
  66365. }
  66366. _addGap() {
  66367. this.gapStack.push(this.lastGapPos);
  66368. this.lastGapPos = this.pos;
  66369. }
  66370. _processSurrogate(cp) {
  66371. //NOTE: try to peek a surrogate pair
  66372. if (this.pos !== this.html.length - 1) {
  66373. const nextCp = this.html.charCodeAt(this.pos + 1);
  66374. if (isSurrogatePair(nextCp)) {
  66375. //NOTE: we have a surrogate pair. Peek pair character and recalculate code point.
  66376. this.pos++;
  66377. //NOTE: add a gap that should be avoided during retreat
  66378. this._addGap();
  66379. return getSurrogatePairCodePoint(cp, nextCp);
  66380. }
  66381. }
  66382. //NOTE: we are at the end of a chunk, therefore we can't infer the surrogate pair yet.
  66383. else if (!this.lastChunkWritten) {
  66384. this.endOfChunkHit = true;
  66385. return CODE_POINTS.EOF;
  66386. }
  66387. //NOTE: isolated surrogate
  66388. this._err(ERR.surrogateInInputStream);
  66389. return cp;
  66390. }
  66391. willDropParsedChunk() {
  66392. return this.pos > this.bufferWaterline;
  66393. }
  66394. dropParsedChunk() {
  66395. if (this.willDropParsedChunk()) {
  66396. this.html = this.html.substring(this.pos);
  66397. this.lineStartPos -= this.pos;
  66398. this.droppedBufferSize += this.pos;
  66399. this.pos = 0;
  66400. this.lastGapPos = -2;
  66401. this.gapStack.length = 0;
  66402. }
  66403. }
  66404. write(chunk, isLastChunk) {
  66405. if (this.html.length > 0) {
  66406. this.html += chunk;
  66407. }
  66408. else {
  66409. this.html = chunk;
  66410. }
  66411. this.endOfChunkHit = false;
  66412. this.lastChunkWritten = isLastChunk;
  66413. }
  66414. insertHtmlAtCurrentPos(chunk) {
  66415. this.html = this.html.substring(0, this.pos + 1) + chunk + this.html.substring(this.pos + 1);
  66416. this.endOfChunkHit = false;
  66417. }
  66418. startsWith(pattern, caseSensitive) {
  66419. // Check if our buffer has enough characters
  66420. if (this.pos + pattern.length > this.html.length) {
  66421. this.endOfChunkHit = !this.lastChunkWritten;
  66422. return false;
  66423. }
  66424. if (caseSensitive) {
  66425. return this.html.startsWith(pattern, this.pos);
  66426. }
  66427. for (let i = 0; i < pattern.length; i++) {
  66428. const cp = this.html.charCodeAt(this.pos + i) | 0x20;
  66429. if (cp !== pattern.charCodeAt(i)) {
  66430. return false;
  66431. }
  66432. }
  66433. return true;
  66434. }
  66435. peek(offset) {
  66436. const pos = this.pos + offset;
  66437. if (pos >= this.html.length) {
  66438. this.endOfChunkHit = !this.lastChunkWritten;
  66439. return CODE_POINTS.EOF;
  66440. }
  66441. return this.html.charCodeAt(pos);
  66442. }
  66443. advance() {
  66444. this.pos++;
  66445. //NOTE: LF should be in the last column of the line
  66446. if (this.isEol) {
  66447. this.isEol = false;
  66448. this.line++;
  66449. this.lineStartPos = this.pos;
  66450. }
  66451. if (this.pos >= this.html.length) {
  66452. this.endOfChunkHit = !this.lastChunkWritten;
  66453. return CODE_POINTS.EOF;
  66454. }
  66455. let cp = this.html.charCodeAt(this.pos);
  66456. //NOTE: all U+000D CARRIAGE RETURN (CR) characters must be converted to U+000A LINE FEED (LF) characters
  66457. if (cp === CODE_POINTS.CARRIAGE_RETURN) {
  66458. this.isEol = true;
  66459. this.skipNextNewLine = true;
  66460. return CODE_POINTS.LINE_FEED;
  66461. }
  66462. //NOTE: any U+000A LINE FEED (LF) characters that immediately follow a U+000D CARRIAGE RETURN (CR) character
  66463. //must be ignored.
  66464. if (cp === CODE_POINTS.LINE_FEED) {
  66465. this.isEol = true;
  66466. if (this.skipNextNewLine) {
  66467. // `line` will be bumped again in the recursive call.
  66468. this.line--;
  66469. this.skipNextNewLine = false;
  66470. this._addGap();
  66471. return this.advance();
  66472. }
  66473. }
  66474. this.skipNextNewLine = false;
  66475. if (isSurrogate(cp)) {
  66476. cp = this._processSurrogate(cp);
  66477. }
  66478. //OPTIMIZATION: first check if code point is in the common allowed
  66479. //range (ASCII alphanumeric, whitespaces, big chunk of BMP)
  66480. //before going into detailed performance cost validation.
  66481. const isCommonValidRange = this.handler.onParseError === null ||
  66482. (cp > 0x1f && cp < 0x7f) ||
  66483. cp === CODE_POINTS.LINE_FEED ||
  66484. cp === CODE_POINTS.CARRIAGE_RETURN ||
  66485. (cp > 0x9f && cp < 64976);
  66486. if (!isCommonValidRange) {
  66487. this._checkForProblematicCharacters(cp);
  66488. }
  66489. return cp;
  66490. }
  66491. _checkForProblematicCharacters(cp) {
  66492. if (isControlCodePoint(cp)) {
  66493. this._err(ERR.controlCharacterInInputStream);
  66494. }
  66495. else if (isUndefinedCodePoint(cp)) {
  66496. this._err(ERR.noncharacterInInputStream);
  66497. }
  66498. }
  66499. retreat(count) {
  66500. this.pos -= count;
  66501. while (this.pos < this.lastGapPos) {
  66502. this.lastGapPos = this.gapStack.pop();
  66503. this.pos--;
  66504. }
  66505. this.isEol = false;
  66506. }
  66507. }
  66508. var TokenType;
  66509. (function (TokenType) {
  66510. TokenType[TokenType["CHARACTER"] = 0] = "CHARACTER";
  66511. TokenType[TokenType["NULL_CHARACTER"] = 1] = "NULL_CHARACTER";
  66512. TokenType[TokenType["WHITESPACE_CHARACTER"] = 2] = "WHITESPACE_CHARACTER";
  66513. TokenType[TokenType["START_TAG"] = 3] = "START_TAG";
  66514. TokenType[TokenType["END_TAG"] = 4] = "END_TAG";
  66515. TokenType[TokenType["COMMENT"] = 5] = "COMMENT";
  66516. TokenType[TokenType["DOCTYPE"] = 6] = "DOCTYPE";
  66517. TokenType[TokenType["EOF"] = 7] = "EOF";
  66518. TokenType[TokenType["HIBERNATION"] = 8] = "HIBERNATION";
  66519. })(TokenType || (TokenType = {}));
  66520. function getTokenAttr(token, attrName) {
  66521. for (let i = token.attrs.length - 1; i >= 0; i--) {
  66522. if (token.attrs[i].name === attrName) {
  66523. return token.attrs[i].value;
  66524. }
  66525. }
  66526. return null;
  66527. }
  66528. var decodeDataHtml = createCommonjsModule(function (module, exports) {
  66529. Object.defineProperty(exports, "__esModule", { value: true });
  66530. // Generated using scripts/write-decode-map.ts
  66531. // prettier-ignore
  66532. exports.default = new Uint16Array([7489, 60, 213, 305, 650, 1181, 1403, 1488, 1653, 1758, 1954, 2006, 2063, 2634, 2705, 3489, 3693, 3849, 3878, 4298, 4648, 4833, 5141, 5277, 5315, 5343, 5413, 0, 0, 0, 0, 0, 0, 5483, 5837, 6541, 7186, 7645, 8062, 8288, 8624, 8845, 9152, 9211, 9282, 10276, 10514, 11528, 11848, 12238, 12310, 12986, 13881, 14252, 14590, 14888, 14961, 15072, 15150, 2048, 69, 77, 97, 98, 99, 102, 103, 108, 109, 110, 111, 112, 114, 115, 116, 117, 92, 98, 102, 109, 115, 127, 132, 139, 144, 149, 152, 166, 179, 185, 200, 207, 108, 105, 103, 32827, 198, 16582, 80, 32827, 38, 16422, 99, 117, 116, 101, 32827, 193, 16577, 114, 101, 118, 101, 59, 16642, 256, 105, 121, 120, 125, 114, 99, 32827, 194, 16578, 59, 17424, 114, 59, 49152, 55349, 56580, 114, 97, 118, 101, 32827, 192, 16576, 112, 104, 97, 59, 17297, 97, 99, 114, 59, 16640, 100, 59, 27219, 256, 103, 112, 157, 161, 111, 110, 59, 16644, 102, 59, 49152, 55349, 56632, 112, 108, 121, 70, 117, 110, 99, 116, 105, 111, 110, 59, 24673, 105, 110, 103, 32827, 197, 16581, 256, 99, 115, 190, 195, 114, 59, 49152, 55349, 56476, 105, 103, 110, 59, 25172, 105, 108, 100, 101, 32827, 195, 16579, 109, 108, 32827, 196, 16580, 1024, 97, 99, 101, 102, 111, 114, 115, 117, 229, 251, 254, 279, 284, 290, 295, 298, 256, 99, 114, 234, 242, 107, 115, 108, 97, 115, 104, 59, 25110, 374, 246, 248, 59, 27367, 101, 100, 59, 25350, 121, 59, 17425, 384, 99, 114, 116, 261, 267, 276, 97, 117, 115, 101, 59, 25141, 110, 111, 117, 108, 108, 105, 115, 59, 24876, 97, 59, 17298, 114, 59, 49152, 55349, 56581, 112, 102, 59, 49152, 55349, 56633, 101, 118, 101, 59, 17112, 99, 242, 275, 109, 112, 101, 113, 59, 25166, 1792, 72, 79, 97, 99, 100, 101, 102, 104, 105, 108, 111, 114, 115, 117, 333, 337, 342, 384, 414, 418, 437, 439, 442, 476, 533, 627, 632, 638, 99, 121, 59, 17447, 80, 89, 32827, 169, 16553, 384, 99, 112, 121, 349, 354, 378, 117, 116, 101, 59, 16646, 256, 59, 105, 359, 360, 25298, 116, 97, 108, 68, 105, 102, 102, 101, 114, 101, 110, 116, 105, 97, 108, 68, 59, 24901, 108, 101, 121, 115, 59, 24877, 512, 97, 101, 105, 111, 393, 398, 404, 408, 114, 111, 110, 59, 16652, 100, 105, 108, 32827, 199, 16583, 114, 99, 59, 16648, 110, 105, 110, 116, 59, 25136, 111, 116, 59, 16650, 256, 100, 110, 423, 429, 105, 108, 108, 97, 59, 16568, 116, 101, 114, 68, 111, 116, 59, 16567, 242, 383, 105, 59, 17319, 114, 99, 108, 101, 512, 68, 77, 80, 84, 455, 459, 465, 470, 111, 116, 59, 25241, 105, 110, 117, 115, 59, 25238, 108, 117, 115, 59, 25237, 105, 109, 101, 115, 59, 25239, 111, 256, 99, 115, 482, 504, 107, 119, 105, 115, 101, 67, 111, 110, 116, 111, 117, 114, 73, 110, 116, 101, 103, 114, 97, 108, 59, 25138, 101, 67, 117, 114, 108, 121, 256, 68, 81, 515, 527, 111, 117, 98, 108, 101, 81, 117, 111, 116, 101, 59, 24605, 117, 111, 116, 101, 59, 24601, 512, 108, 110, 112, 117, 542, 552, 583, 597, 111, 110, 256, 59, 101, 549, 550, 25143, 59, 27252, 384, 103, 105, 116, 559, 566, 570, 114, 117, 101, 110, 116, 59, 25185, 110, 116, 59, 25135, 111, 117, 114, 73, 110, 116, 101, 103, 114, 97, 108, 59, 25134, 256, 102, 114, 588, 590, 59, 24834, 111, 100, 117, 99, 116, 59, 25104, 110, 116, 101, 114, 67, 108, 111, 99, 107, 119, 105, 115, 101, 67, 111, 110, 116, 111, 117, 114, 73, 110, 116, 101, 103, 114, 97, 108, 59, 25139, 111, 115, 115, 59, 27183, 99, 114, 59, 49152, 55349, 56478, 112, 256, 59, 67, 644, 645, 25299, 97, 112, 59, 25165, 1408, 68, 74, 83, 90, 97, 99, 101, 102, 105, 111, 115, 672, 684, 688, 692, 696, 715, 727, 737, 742, 819, 1165, 256, 59, 111, 377, 677, 116, 114, 97, 104, 100, 59, 26897, 99, 121, 59, 17410, 99, 121, 59, 17413, 99, 121, 59, 17423, 384, 103, 114, 115, 703, 708, 711, 103, 101, 114, 59, 24609, 114, 59, 24993, 104, 118, 59, 27364, 256, 97, 121, 720, 725, 114, 111, 110, 59, 16654, 59, 17428, 108, 256, 59, 116, 733, 734, 25095, 97, 59, 17300, 114, 59, 49152, 55349, 56583, 256, 97, 102, 747, 807, 256, 99, 109, 752, 802, 114, 105, 116, 105, 99, 97, 108, 512, 65, 68, 71, 84, 768, 774, 790, 796, 99, 117, 116, 101, 59, 16564, 111, 372, 779, 781, 59, 17113, 98, 108, 101, 65, 99, 117, 116, 101, 59, 17117, 114, 97, 118, 101, 59, 16480, 105, 108, 100, 101, 59, 17116, 111, 110, 100, 59, 25284, 102, 101, 114, 101, 110, 116, 105, 97, 108, 68, 59, 24902, 1136, 829, 0, 0, 0, 834, 852, 0, 1029, 102, 59, 49152, 55349, 56635, 384, 59, 68, 69, 840, 841, 845, 16552, 111, 116, 59, 24796, 113, 117, 97, 108, 59, 25168, 98, 108, 101, 768, 67, 68, 76, 82, 85, 86, 867, 882, 898, 975, 994, 1016, 111, 110, 116, 111, 117, 114, 73, 110, 116, 101, 103, 114, 97, 236, 569, 111, 628, 889, 0, 0, 891, 187, 841, 110, 65, 114, 114, 111, 119, 59, 25043, 256, 101, 111, 903, 932, 102, 116, 384, 65, 82, 84, 912, 918, 929, 114, 114, 111, 119, 59, 25040, 105, 103, 104, 116, 65, 114, 114, 111, 119, 59, 25044, 101, 229, 714, 110, 103, 256, 76, 82, 939, 964, 101, 102, 116, 256, 65, 82, 947, 953, 114, 114, 111, 119, 59, 26616, 105, 103, 104, 116, 65, 114, 114, 111, 119, 59, 26618, 105, 103, 104, 116, 65, 114, 114, 111, 119, 59, 26617, 105, 103, 104, 116, 256, 65, 84, 984, 990, 114, 114, 111, 119, 59, 25042, 101, 101, 59, 25256, 112, 577, 1001, 0, 0, 1007, 114, 114, 111, 119, 59, 25041, 111, 119, 110, 65, 114, 114, 111, 119, 59, 25045, 101, 114, 116, 105, 99, 97, 108, 66, 97, 114, 59, 25125, 110, 768, 65, 66, 76, 82, 84, 97, 1042, 1066, 1072, 1118, 1151, 892, 114, 114, 111, 119, 384, 59, 66, 85, 1053, 1054, 1058, 24979, 97, 114, 59, 26899, 112, 65, 114, 114, 111, 119, 59, 25077, 114, 101, 118, 101, 59, 17169, 101, 102, 116, 722, 1082, 0, 1094, 0, 1104, 105, 103, 104, 116, 86, 101, 99, 116, 111, 114, 59, 26960, 101, 101, 86, 101, 99, 116, 111, 114, 59, 26974, 101, 99, 116, 111, 114, 256, 59, 66, 1113, 1114, 25021, 97, 114, 59, 26966, 105, 103, 104, 116, 468, 1127, 0, 1137, 101, 101, 86, 101, 99, 116, 111, 114, 59, 26975, 101, 99, 116, 111, 114, 256, 59, 66, 1146, 1147, 25025, 97, 114, 59, 26967, 101, 101, 256, 59, 65, 1158, 1159, 25252, 114, 114, 111, 119, 59, 24999, 256, 99, 116, 1170, 1175, 114, 59, 49152, 55349, 56479, 114, 111, 107, 59, 16656, 2048, 78, 84, 97, 99, 100, 102, 103, 108, 109, 111, 112, 113, 115, 116, 117, 120, 1213, 1216, 1220, 1227, 1246, 1250, 1255, 1262, 1269, 1313, 1327, 1334, 1362, 1373, 1376, 1381, 71, 59, 16714, 72, 32827, 208, 16592, 99, 117, 116, 101, 32827, 201, 16585, 384, 97, 105, 121, 1234, 1239, 1244, 114, 111, 110, 59, 16666, 114, 99, 32827, 202, 16586, 59, 17453, 111, 116, 59, 16662, 114, 59, 49152, 55349, 56584, 114, 97, 118, 101, 32827, 200, 16584, 101, 109, 101, 110, 116, 59, 25096, 256, 97, 112, 1274, 1278, 99, 114, 59, 16658, 116, 121, 595, 1286, 0, 0, 1298, 109, 97, 108, 108, 83, 113, 117, 97, 114, 101, 59, 26107, 101, 114, 121, 83, 109, 97, 108, 108, 83, 113, 117, 97, 114, 101, 59, 26027, 256, 103, 112, 1318, 1322, 111, 110, 59, 16664, 102, 59, 49152, 55349, 56636, 115, 105, 108, 111, 110, 59, 17301, 117, 256, 97, 105, 1340, 1353, 108, 256, 59, 84, 1346, 1347, 27253, 105, 108, 100, 101, 59, 25154, 108, 105, 98, 114, 105, 117, 109, 59, 25036, 256, 99, 105, 1367, 1370, 114, 59, 24880, 109, 59, 27251, 97, 59, 17303, 109, 108, 32827, 203, 16587, 256, 105, 112, 1386, 1391, 115, 116, 115, 59, 25091, 111, 110, 101, 110, 116, 105, 97, 108, 69, 59, 24903, 640, 99, 102, 105, 111, 115, 1413, 1416, 1421, 1458, 1484, 121, 59, 17444, 114, 59, 49152, 55349, 56585, 108, 108, 101, 100, 595, 1431, 0, 0, 1443, 109, 97, 108, 108, 83, 113, 117, 97, 114, 101, 59, 26108, 101, 114, 121, 83, 109, 97, 108, 108, 83, 113, 117, 97, 114, 101, 59, 26026, 880, 1466, 0, 1471, 0, 0, 1476, 102, 59, 49152, 55349, 56637, 65, 108, 108, 59, 25088, 114, 105, 101, 114, 116, 114, 102, 59, 24881, 99, 242, 1483, 1536, 74, 84, 97, 98, 99, 100, 102, 103, 111, 114, 115, 116, 1512, 1516, 1519, 1530, 1536, 1554, 1558, 1563, 1565, 1571, 1644, 1650, 99, 121, 59, 17411, 32827, 62, 16446, 109, 109, 97, 256, 59, 100, 1527, 1528, 17299, 59, 17372, 114, 101, 118, 101, 59, 16670, 384, 101, 105, 121, 1543, 1548, 1552, 100, 105, 108, 59, 16674, 114, 99, 59, 16668, 59, 17427, 111, 116, 59, 16672, 114, 59, 49152, 55349, 56586, 59, 25305, 112, 102, 59, 49152, 55349, 56638, 101, 97, 116, 101, 114, 768, 69, 70, 71, 76, 83, 84, 1589, 1604, 1614, 1622, 1627, 1638, 113, 117, 97, 108, 256, 59, 76, 1598, 1599, 25189, 101, 115, 115, 59, 25307, 117, 108, 108, 69, 113, 117, 97, 108, 59, 25191, 114, 101, 97, 116, 101, 114, 59, 27298, 101, 115, 115, 59, 25207, 108, 97, 110, 116, 69, 113, 117, 97, 108, 59, 27262, 105, 108, 100, 101, 59, 25203, 99, 114, 59, 49152, 55349, 56482, 59, 25195, 1024, 65, 97, 99, 102, 105, 111, 115, 117, 1669, 1675, 1686, 1691, 1694, 1706, 1726, 1738, 82, 68, 99, 121, 59, 17450, 256, 99, 116, 1680, 1684, 101, 107, 59, 17095, 59, 16478, 105, 114, 99, 59, 16676, 114, 59, 24844, 108, 98, 101, 114, 116, 83, 112, 97, 99, 101, 59, 24843, 496, 1711, 0, 1714, 102, 59, 24845, 105, 122, 111, 110, 116, 97, 108, 76, 105, 110, 101, 59, 25856, 256, 99, 116, 1731, 1733, 242, 1705, 114, 111, 107, 59, 16678, 109, 112, 324, 1744, 1752, 111, 119, 110, 72, 117, 109, 240, 303, 113, 117, 97, 108, 59, 25167, 1792, 69, 74, 79, 97, 99, 100, 102, 103, 109, 110, 111, 115, 116, 117, 1786, 1790, 1795, 1799, 1806, 1818, 1822, 1825, 1832, 1860, 1912, 1931, 1935, 1941, 99, 121, 59, 17429, 108, 105, 103, 59, 16690, 99, 121, 59, 17409, 99, 117, 116, 101, 32827, 205, 16589, 256, 105, 121, 1811, 1816, 114, 99, 32827, 206, 16590, 59, 17432, 111, 116, 59, 16688, 114, 59, 24849, 114, 97, 118, 101, 32827, 204, 16588, 384, 59, 97, 112, 1824, 1839, 1855, 256, 99, 103, 1844, 1847, 114, 59, 16682, 105, 110, 97, 114, 121, 73, 59, 24904, 108, 105, 101, 243, 989, 500, 1865, 0, 1890, 256, 59, 101, 1869, 1870, 25132, 256, 103, 114, 1875, 1880, 114, 97, 108, 59, 25131, 115, 101, 99, 116, 105, 111, 110, 59, 25282, 105, 115, 105, 98, 108, 101, 256, 67, 84, 1900, 1906, 111, 109, 109, 97, 59, 24675, 105, 109, 101, 115, 59, 24674, 384, 103, 112, 116, 1919, 1923, 1928, 111, 110, 59, 16686, 102, 59, 49152, 55349, 56640, 97, 59, 17305, 99, 114, 59, 24848, 105, 108, 100, 101, 59, 16680, 491, 1946, 0, 1950, 99, 121, 59, 17414, 108, 32827, 207, 16591, 640, 99, 102, 111, 115, 117, 1964, 1975, 1980, 1986, 2000, 256, 105, 121, 1969, 1973, 114, 99, 59, 16692, 59, 17433, 114, 59, 49152, 55349, 56589, 112, 102, 59, 49152, 55349, 56641, 483, 1991, 0, 1996, 114, 59, 49152, 55349, 56485, 114, 99, 121, 59, 17416, 107, 99, 121, 59, 17412, 896, 72, 74, 97, 99, 102, 111, 115, 2020, 2024, 2028, 2033, 2045, 2050, 2056, 99, 121, 59, 17445, 99, 121, 59, 17420, 112, 112, 97, 59, 17306, 256, 101, 121, 2038, 2043, 100, 105, 108, 59, 16694, 59, 17434, 114, 59, 49152, 55349, 56590, 112, 102, 59, 49152, 55349, 56642, 99, 114, 59, 49152, 55349, 56486, 1408, 74, 84, 97, 99, 101, 102, 108, 109, 111, 115, 116, 2085, 2089, 2092, 2128, 2147, 2483, 2488, 2503, 2509, 2615, 2631, 99, 121, 59, 17417, 32827, 60, 16444, 640, 99, 109, 110, 112, 114, 2103, 2108, 2113, 2116, 2125, 117, 116, 101, 59, 16697, 98, 100, 97, 59, 17307, 103, 59, 26602, 108, 97, 99, 101, 116, 114, 102, 59, 24850, 114, 59, 24990, 384, 97, 101, 121, 2135, 2140, 2145, 114, 111, 110, 59, 16701, 100, 105, 108, 59, 16699, 59, 17435, 256, 102, 115, 2152, 2416, 116, 1280, 65, 67, 68, 70, 82, 84, 85, 86, 97, 114, 2174, 2217, 2225, 2272, 2278, 2300, 2351, 2395, 912, 2410, 256, 110, 114, 2179, 2191, 103, 108, 101, 66, 114, 97, 99, 107, 101, 116, 59, 26600, 114, 111, 119, 384, 59, 66, 82, 2201, 2202, 2206, 24976, 97, 114, 59, 25060, 105, 103, 104, 116, 65, 114, 114, 111, 119, 59, 25030, 101, 105, 108, 105, 110, 103, 59, 25352, 111, 501, 2231, 0, 2243, 98, 108, 101, 66, 114, 97, 99, 107, 101, 116, 59, 26598, 110, 468, 2248, 0, 2258, 101, 101, 86, 101, 99, 116, 111, 114, 59, 26977, 101, 99, 116, 111, 114, 256, 59, 66, 2267, 2268, 25027, 97, 114, 59, 26969, 108, 111, 111, 114, 59, 25354, 105, 103, 104, 116, 256, 65, 86, 2287, 2293, 114, 114, 111, 119, 59, 24980, 101, 99, 116, 111, 114, 59, 26958, 256, 101, 114, 2305, 2327, 101, 384, 59, 65, 86, 2313, 2314, 2320, 25251, 114, 114, 111, 119, 59, 24996, 101, 99, 116, 111, 114, 59, 26970, 105, 97, 110, 103, 108, 101, 384, 59, 66, 69, 2340, 2341, 2345, 25266, 97, 114, 59, 27087, 113, 117, 97, 108, 59, 25268, 112, 384, 68, 84, 86, 2359, 2370, 2380, 111, 119, 110, 86, 101, 99, 116, 111, 114, 59, 26961, 101, 101, 86, 101, 99, 116, 111, 114, 59, 26976, 101, 99, 116, 111, 114, 256, 59, 66, 2390, 2391, 25023, 97, 114, 59, 26968, 101, 99, 116, 111, 114, 256, 59, 66, 2405, 2406, 25020, 97, 114, 59, 26962, 105, 103, 104, 116, 225, 924, 115, 768, 69, 70, 71, 76, 83, 84, 2430, 2443, 2453, 2461, 2466, 2477, 113, 117, 97, 108, 71, 114, 101, 97, 116, 101, 114, 59, 25306, 117, 108, 108, 69, 113, 117, 97, 108, 59, 25190, 114, 101, 97, 116, 101, 114, 59, 25206, 101, 115, 115, 59, 27297, 108, 97, 110, 116, 69, 113, 117, 97, 108, 59, 27261, 105, 108, 100, 101, 59, 25202, 114, 59, 49152, 55349, 56591, 256, 59, 101, 2493, 2494, 25304, 102, 116, 97, 114, 114, 111, 119, 59, 25050, 105, 100, 111, 116, 59, 16703, 384, 110, 112, 119, 2516, 2582, 2587, 103, 512, 76, 82, 108, 114, 2526, 2551, 2562, 2576, 101, 102, 116, 256, 65, 82, 2534, 2540, 114, 114, 111, 119, 59, 26613, 105, 103, 104, 116, 65, 114, 114, 111, 119, 59, 26615, 105, 103, 104, 116, 65, 114, 114, 111, 119, 59, 26614, 101, 102, 116, 256, 97, 114, 947, 2570, 105, 103, 104, 116, 225, 959, 105, 103, 104, 116, 225, 970, 102, 59, 49152, 55349, 56643, 101, 114, 256, 76, 82, 2594, 2604, 101, 102, 116, 65, 114, 114, 111, 119, 59, 24985, 105, 103, 104, 116, 65, 114, 114, 111, 119, 59, 24984, 384, 99, 104, 116, 2622, 2624, 2626, 242, 2124, 59, 25008, 114, 111, 107, 59, 16705, 59, 25194, 1024, 97, 99, 101, 102, 105, 111, 115, 117, 2650, 2653, 2656, 2679, 2684, 2693, 2699, 2702, 112, 59, 26885, 121, 59, 17436, 256, 100, 108, 2661, 2671, 105, 117, 109, 83, 112, 97, 99, 101, 59, 24671, 108, 105, 110, 116, 114, 102, 59, 24883, 114, 59, 49152, 55349, 56592, 110, 117, 115, 80, 108, 117, 115, 59, 25107, 112, 102, 59, 49152, 55349, 56644, 99, 242, 2678, 59, 17308, 1152, 74, 97, 99, 101, 102, 111, 115, 116, 117, 2723, 2727, 2733, 2752, 2836, 2841, 3473, 3479, 3486, 99, 121, 59, 17418, 99, 117, 116, 101, 59, 16707, 384, 97, 101, 121, 2740, 2745, 2750, 114, 111, 110, 59, 16711, 100, 105, 108, 59, 16709, 59, 17437, 384, 103, 115, 119, 2759, 2800, 2830, 97, 116, 105, 118, 101, 384, 77, 84, 86, 2771, 2783, 2792, 101, 100, 105, 117, 109, 83, 112, 97, 99, 101, 59, 24587, 104, 105, 256, 99, 110, 2790, 2776, 235, 2777, 101, 114, 121, 84, 104, 105, 238, 2777, 116, 101, 100, 256, 71, 76, 2808, 2822, 114, 101, 97, 116, 101, 114, 71, 114, 101, 97, 116, 101, 242, 1651, 101, 115, 115, 76, 101, 115, 243, 2632, 76, 105, 110, 101, 59, 16394, 114, 59, 49152, 55349, 56593, 512, 66, 110, 112, 116, 2850, 2856, 2871, 2874, 114, 101, 97, 107, 59, 24672, 66, 114, 101, 97, 107, 105, 110, 103, 83, 112, 97, 99, 101, 59, 16544, 102, 59, 24853, 1664, 59, 67, 68, 69, 71, 72, 76, 78, 80, 82, 83, 84, 86, 2901, 2902, 2922, 2940, 2977, 3051, 3076, 3166, 3204, 3238, 3288, 3425, 3461, 27372, 256, 111, 117, 2907, 2916, 110, 103, 114, 117, 101, 110, 116, 59, 25186, 112, 67, 97, 112, 59, 25197, 111, 117, 98, 108, 101, 86, 101, 114, 116, 105, 99, 97, 108, 66, 97, 114, 59, 25126, 384, 108, 113, 120, 2947, 2954, 2971, 101, 109, 101, 110, 116, 59, 25097, 117, 97, 108, 256, 59, 84, 2962, 2963, 25184, 105, 108, 100, 101, 59, 49152, 8770, 824, 105, 115, 116, 115, 59, 25092, 114, 101, 97, 116, 101, 114, 896, 59, 69, 70, 71, 76, 83, 84, 2998, 2999, 3005, 3017, 3027, 3032, 3045, 25199, 113, 117, 97, 108, 59, 25201, 117, 108, 108, 69, 113, 117, 97, 108, 59, 49152, 8807, 824, 114, 101, 97, 116, 101, 114, 59, 49152, 8811, 824, 101, 115, 115, 59, 25209, 108, 97, 110, 116, 69, 113, 117, 97, 108, 59, 49152, 10878, 824, 105, 108, 100, 101, 59, 25205, 117, 109, 112, 324, 3058, 3069, 111, 119, 110, 72, 117, 109, 112, 59, 49152, 8782, 824, 113, 117, 97, 108, 59, 49152, 8783, 824, 101, 256, 102, 115, 3082, 3111, 116, 84, 114, 105, 97, 110, 103, 108, 101, 384, 59, 66, 69, 3098, 3099, 3105, 25322, 97, 114, 59, 49152, 10703, 824, 113, 117, 97, 108, 59, 25324, 115, 768, 59, 69, 71, 76, 83, 84, 3125, 3126, 3132, 3140, 3147, 3160, 25198, 113, 117, 97, 108, 59, 25200, 114, 101, 97, 116, 101, 114, 59, 25208, 101, 115, 115, 59, 49152, 8810, 824, 108, 97, 110, 116, 69, 113, 117, 97, 108, 59, 49152, 10877, 824, 105, 108, 100, 101, 59, 25204, 101, 115, 116, 101, 100, 256, 71, 76, 3176, 3193, 114, 101, 97, 116, 101, 114, 71, 114, 101, 97, 116, 101, 114, 59, 49152, 10914, 824, 101, 115, 115, 76, 101, 115, 115, 59, 49152, 10913, 824, 114, 101, 99, 101, 100, 101, 115, 384, 59, 69, 83, 3218, 3219, 3227, 25216, 113, 117, 97, 108, 59, 49152, 10927, 824, 108, 97, 110, 116, 69, 113, 117, 97, 108, 59, 25312, 256, 101, 105, 3243, 3257, 118, 101, 114, 115, 101, 69, 108, 101, 109, 101, 110, 116, 59, 25100, 103, 104, 116, 84, 114, 105, 97, 110, 103, 108, 101, 384, 59, 66, 69, 3275, 3276, 3282, 25323, 97, 114, 59, 49152, 10704, 824, 113, 117, 97, 108, 59, 25325, 256, 113, 117, 3293, 3340, 117, 97, 114, 101, 83, 117, 256, 98, 112, 3304, 3321, 115, 101, 116, 256, 59, 69, 3312, 3315, 49152, 8847, 824, 113, 117, 97, 108, 59, 25314, 101, 114, 115, 101, 116, 256, 59, 69, 3331, 3334, 49152, 8848, 824, 113, 117, 97, 108, 59, 25315, 384, 98, 99, 112, 3347, 3364, 3406, 115, 101, 116, 256, 59, 69, 3355, 3358, 49152, 8834, 8402, 113, 117, 97, 108, 59, 25224, 99, 101, 101, 100, 115, 512, 59, 69, 83, 84, 3378, 3379, 3387, 3398, 25217, 113, 117, 97, 108, 59, 49152, 10928, 824, 108, 97, 110, 116, 69, 113, 117, 97, 108, 59, 25313, 105, 108, 100, 101, 59, 49152, 8831, 824, 101, 114, 115, 101, 116, 256, 59, 69, 3416, 3419, 49152, 8835, 8402, 113, 117, 97, 108, 59, 25225, 105, 108, 100, 101, 512, 59, 69, 70, 84, 3438, 3439, 3445, 3455, 25153, 113, 117, 97, 108, 59, 25156, 117, 108, 108, 69, 113, 117, 97, 108, 59, 25159, 105, 108, 100, 101, 59, 25161, 101, 114, 116, 105, 99, 97, 108, 66, 97, 114, 59, 25124, 99, 114, 59, 49152, 55349, 56489, 105, 108, 100, 101, 32827, 209, 16593, 59, 17309, 1792, 69, 97, 99, 100, 102, 103, 109, 111, 112, 114, 115, 116, 117, 118, 3517, 3522, 3529, 3541, 3547, 3552, 3559, 3580, 3586, 3616, 3618, 3634, 3647, 3652, 108, 105, 103, 59, 16722, 99, 117, 116, 101, 32827, 211, 16595, 256, 105, 121, 3534, 3539, 114, 99, 32827, 212, 16596, 59, 17438, 98, 108, 97, 99, 59, 16720, 114, 59, 49152, 55349, 56594, 114, 97, 118, 101, 32827, 210, 16594, 384, 97, 101, 105, 3566, 3570, 3574, 99, 114, 59, 16716, 103, 97, 59, 17321, 99, 114, 111, 110, 59, 17311, 112, 102, 59, 49152, 55349, 56646, 101, 110, 67, 117, 114, 108, 121, 256, 68, 81, 3598, 3610, 111, 117, 98, 108, 101, 81, 117, 111, 116, 101, 59, 24604, 117, 111, 116, 101, 59, 24600, 59, 27220, 256, 99, 108, 3623, 3628, 114, 59, 49152, 55349, 56490, 97, 115, 104, 32827, 216, 16600, 105, 364, 3639, 3644, 100, 101, 32827, 213, 16597, 101, 115, 59, 27191, 109, 108, 32827, 214, 16598, 101, 114, 256, 66, 80, 3659, 3680, 256, 97, 114, 3664, 3667, 114, 59, 24638, 97, 99, 256, 101, 107, 3674, 3676, 59, 25566, 101, 116, 59, 25524, 97, 114, 101, 110, 116, 104, 101, 115, 105, 115, 59, 25564, 1152, 97, 99, 102, 104, 105, 108, 111, 114, 115, 3711, 3719, 3722, 3727, 3730, 3732, 3741, 3760, 3836, 114, 116, 105, 97, 108, 68, 59, 25090, 121, 59, 17439, 114, 59, 49152, 55349, 56595, 105, 59, 17318, 59, 17312, 117, 115, 77, 105, 110, 117, 115, 59, 16561, 256, 105, 112, 3746, 3757, 110, 99, 97, 114, 101, 112, 108, 97, 110, 229, 1693, 102, 59, 24857, 512, 59, 101, 105, 111, 3769, 3770, 3808, 3812, 27323, 99, 101, 100, 101, 115, 512, 59, 69, 83, 84, 3784, 3785, 3791, 3802, 25210, 113, 117, 97, 108, 59, 27311, 108, 97, 110, 116, 69, 113, 117, 97, 108, 59, 25212, 105, 108, 100, 101, 59, 25214, 109, 101, 59, 24627, 256, 100, 112, 3817, 3822, 117, 99, 116, 59, 25103, 111, 114, 116, 105, 111, 110, 256, 59, 97, 549, 3833, 108, 59, 25117, 256, 99, 105, 3841, 3846, 114, 59, 49152, 55349, 56491, 59, 17320, 512, 85, 102, 111, 115, 3857, 3862, 3867, 3871, 79, 84, 32827, 34, 16418, 114, 59, 49152, 55349, 56596, 112, 102, 59, 24858, 99, 114, 59, 49152, 55349, 56492, 1536, 66, 69, 97, 99, 101, 102, 104, 105, 111, 114, 115, 117, 3902, 3907, 3911, 3936, 3955, 4007, 4010, 4013, 4246, 4265, 4276, 4286, 97, 114, 114, 59, 26896, 71, 32827, 174, 16558, 384, 99, 110, 114, 3918, 3923, 3926, 117, 116, 101, 59, 16724, 103, 59, 26603, 114, 256, 59, 116, 3932, 3933, 24992, 108, 59, 26902, 384, 97, 101, 121, 3943, 3948, 3953, 114, 111, 110, 59, 16728, 100, 105, 108, 59, 16726, 59, 17440, 256, 59, 118, 3960, 3961, 24860, 101, 114, 115, 101, 256, 69, 85, 3970, 3993, 256, 108, 113, 3975, 3982, 101, 109, 101, 110, 116, 59, 25099, 117, 105, 108, 105, 98, 114, 105, 117, 109, 59, 25035, 112, 69, 113, 117, 105, 108, 105, 98, 114, 105, 117, 109, 59, 26991, 114, 187, 3961, 111, 59, 17313, 103, 104, 116, 1024, 65, 67, 68, 70, 84, 85, 86, 97, 4033, 4075, 4083, 4130, 4136, 4187, 4231, 984, 256, 110, 114, 4038, 4050, 103, 108, 101, 66, 114, 97, 99, 107, 101, 116, 59, 26601, 114, 111, 119, 384, 59, 66, 76, 4060, 4061, 4065, 24978, 97, 114, 59, 25061, 101, 102, 116, 65, 114, 114, 111, 119, 59, 25028, 101, 105, 108, 105, 110, 103, 59, 25353, 111, 501, 4089, 0, 4101, 98, 108, 101, 66, 114, 97, 99, 107, 101, 116, 59, 26599, 110, 468, 4106, 0, 4116, 101, 101, 86, 101, 99, 116, 111, 114, 59, 26973, 101, 99, 116, 111, 114, 256, 59, 66, 4125, 4126, 25026, 97, 114, 59, 26965, 108, 111, 111, 114, 59, 25355, 256, 101, 114, 4141, 4163, 101, 384, 59, 65, 86, 4149, 4150, 4156, 25250, 114, 114, 111, 119, 59, 24998, 101, 99, 116, 111, 114, 59, 26971, 105, 97, 110, 103, 108, 101, 384, 59, 66, 69, 4176, 4177, 4181, 25267, 97, 114, 59, 27088, 113, 117, 97, 108, 59, 25269, 112, 384, 68, 84, 86, 4195, 4206, 4216, 111, 119, 110, 86, 101, 99, 116, 111, 114, 59, 26959, 101, 101, 86, 101, 99, 116, 111, 114, 59, 26972, 101, 99, 116, 111, 114, 256, 59, 66, 4226, 4227, 25022, 97, 114, 59, 26964, 101, 99, 116, 111, 114, 256, 59, 66, 4241, 4242, 25024, 97, 114, 59, 26963, 256, 112, 117, 4251, 4254, 102, 59, 24861, 110, 100, 73, 109, 112, 108, 105, 101, 115, 59, 26992, 105, 103, 104, 116, 97, 114, 114, 111, 119, 59, 25051, 256, 99, 104, 4281, 4284, 114, 59, 24859, 59, 25009, 108, 101, 68, 101, 108, 97, 121, 101, 100, 59, 27124, 1664, 72, 79, 97, 99, 102, 104, 105, 109, 111, 113, 115, 116, 117, 4324, 4337, 4343, 4349, 4377, 4382, 4433, 4438, 4449, 4455, 4533, 4539, 4543, 256, 67, 99, 4329, 4334, 72, 99, 121, 59, 17449, 121, 59, 17448, 70, 84, 99, 121, 59, 17452, 99, 117, 116, 101, 59, 16730, 640, 59, 97, 101, 105, 121, 4360, 4361, 4366, 4371, 4375, 27324, 114, 111, 110, 59, 16736, 100, 105, 108, 59, 16734, 114, 99, 59, 16732, 59, 17441, 114, 59, 49152, 55349, 56598, 111, 114, 116, 512, 68, 76, 82, 85, 4394, 4404, 4414, 4425, 111, 119, 110, 65, 114, 114, 111, 119, 187, 1054, 101, 102, 116, 65, 114, 114, 111, 119, 187, 2202, 105, 103, 104, 116, 65, 114, 114, 111, 119, 187, 4061, 112, 65, 114, 114, 111, 119, 59, 24977, 103, 109, 97, 59, 17315, 97, 108, 108, 67, 105, 114, 99, 108, 101, 59, 25112, 112, 102, 59, 49152, 55349, 56650, 626, 4461, 0, 0, 4464, 116, 59, 25114, 97, 114, 101, 512, 59, 73, 83, 85, 4475, 4476, 4489, 4527, 26017, 110, 116, 101, 114, 115, 101, 99, 116, 105, 111, 110, 59, 25235, 117, 256, 98, 112, 4495, 4510, 115, 101, 116, 256, 59, 69, 4503, 4504, 25231, 113, 117, 97, 108, 59, 25233, 101, 114, 115, 101, 116, 256, 59, 69, 4520, 4521, 25232, 113, 117, 97, 108, 59, 25234, 110, 105, 111, 110, 59, 25236, 99, 114, 59, 49152, 55349, 56494, 97, 114, 59, 25286, 512, 98, 99, 109, 112, 4552, 4571, 4617, 4619, 256, 59, 115, 4557, 4558, 25296, 101, 116, 256, 59, 69, 4557, 4565, 113, 117, 97, 108, 59, 25222, 256, 99, 104, 4576, 4613, 101, 101, 100, 115, 512, 59, 69, 83, 84, 4589, 4590, 4596, 4607, 25211, 113, 117, 97, 108, 59, 27312, 108, 97, 110, 116, 69, 113, 117, 97, 108, 59, 25213, 105, 108, 100, 101, 59, 25215, 84, 104, 225, 3980, 59, 25105, 384, 59, 101, 115, 4626, 4627, 4643, 25297, 114, 115, 101, 116, 256, 59, 69, 4636, 4637, 25219, 113, 117, 97, 108, 59, 25223, 101, 116, 187, 4627, 1408, 72, 82, 83, 97, 99, 102, 104, 105, 111, 114, 115, 4670, 4676, 4681, 4693, 4702, 4721, 4726, 4767, 4802, 4808, 4817, 79, 82, 78, 32827, 222, 16606, 65, 68, 69, 59, 24866, 256, 72, 99, 4686, 4690, 99, 121, 59, 17419, 121, 59, 17446, 256, 98, 117, 4698, 4700, 59, 16393, 59, 17316, 384, 97, 101, 121, 4709, 4714, 4719, 114, 111, 110, 59, 16740, 100, 105, 108, 59, 16738, 59, 17442, 114, 59, 49152, 55349, 56599, 256, 101, 105, 4731, 4745, 498, 4736, 0, 4743, 101, 102, 111, 114, 101, 59, 25140, 97, 59, 17304, 256, 99, 110, 4750, 4760, 107, 83, 112, 97, 99, 101, 59, 49152, 8287, 8202, 83, 112, 97, 99, 101, 59, 24585, 108, 100, 101, 512, 59, 69, 70, 84, 4779, 4780, 4786, 4796, 25148, 113, 117, 97, 108, 59, 25155, 117, 108, 108, 69, 113, 117, 97, 108, 59, 25157, 105, 108, 100, 101, 59, 25160, 112, 102, 59, 49152, 55349, 56651, 105, 112, 108, 101, 68, 111, 116, 59, 24795, 256, 99, 116, 4822, 4827, 114, 59, 49152, 55349, 56495, 114, 111, 107, 59, 16742, 2785, 4855, 4878, 4890, 4902, 0, 4908, 4913, 0, 0, 0, 0, 0, 4920, 4925, 4983, 4997, 0, 5119, 5124, 5130, 5136, 256, 99, 114, 4859, 4865, 117, 116, 101, 32827, 218, 16602, 114, 256, 59, 111, 4871, 4872, 24991, 99, 105, 114, 59, 26953, 114, 483, 4883, 0, 4886, 121, 59, 17422, 118, 101, 59, 16748, 256, 105, 121, 4894, 4899, 114, 99, 32827, 219, 16603, 59, 17443, 98, 108, 97, 99, 59, 16752, 114, 59, 49152, 55349, 56600, 114, 97, 118, 101, 32827, 217, 16601, 97, 99, 114, 59, 16746, 256, 100, 105, 4929, 4969, 101, 114, 256, 66, 80, 4936, 4957, 256, 97, 114, 4941, 4944, 114, 59, 16479, 97, 99, 256, 101, 107, 4951, 4953, 59, 25567, 101, 116, 59, 25525, 97, 114, 101, 110, 116, 104, 101, 115, 105, 115, 59, 25565, 111, 110, 256, 59, 80, 4976, 4977, 25283, 108, 117, 115, 59, 25230, 256, 103, 112, 4987, 4991, 111, 110, 59, 16754, 102, 59, 49152, 55349, 56652, 1024, 65, 68, 69, 84, 97, 100, 112, 115, 5013, 5038, 5048, 5060, 1000, 5074, 5079, 5107, 114, 114, 111, 119, 384, 59, 66, 68, 4432, 5024, 5028, 97, 114, 59, 26898, 111, 119, 110, 65, 114, 114, 111, 119, 59, 25029, 111, 119, 110, 65, 114, 114, 111, 119, 59, 24981, 113, 117, 105, 108, 105, 98, 114, 105, 117, 109, 59, 26990, 101, 101, 256, 59, 65, 5067, 5068, 25253, 114, 114, 111, 119, 59, 24997, 111, 119, 110, 225, 1011, 101, 114, 256, 76, 82, 5086, 5096, 101, 102, 116, 65, 114, 114, 111, 119, 59, 24982, 105, 103, 104, 116, 65, 114, 114, 111, 119, 59, 24983, 105, 256, 59, 108, 5113, 5114, 17362, 111, 110, 59, 17317, 105, 110, 103, 59, 16750, 99, 114, 59, 49152, 55349, 56496, 105, 108, 100, 101, 59, 16744, 109, 108, 32827, 220, 16604, 1152, 68, 98, 99, 100, 101, 102, 111, 115, 118, 5159, 5164, 5168, 5171, 5182, 5253, 5258, 5264, 5270, 97, 115, 104, 59, 25259, 97, 114, 59, 27371, 121, 59, 17426, 97, 115, 104, 256, 59, 108, 5179, 5180, 25257, 59, 27366, 256, 101, 114, 5187, 5189, 59, 25281, 384, 98, 116, 121, 5196, 5200, 5242, 97, 114, 59, 24598, 256, 59, 105, 5199, 5205, 99, 97, 108, 512, 66, 76, 83, 84, 5217, 5221, 5226, 5236, 97, 114, 59, 25123, 105, 110, 101, 59, 16508, 101, 112, 97, 114, 97, 116, 111, 114, 59, 26456, 105, 108, 100, 101, 59, 25152, 84, 104, 105, 110, 83, 112, 97, 99, 101, 59, 24586, 114, 59, 49152, 55349, 56601, 112, 102, 59, 49152, 55349, 56653, 99, 114, 59, 49152, 55349, 56497, 100, 97, 115, 104, 59, 25258, 640, 99, 101, 102, 111, 115, 5287, 5292, 5297, 5302, 5308, 105, 114, 99, 59, 16756, 100, 103, 101, 59, 25280, 114, 59, 49152, 55349, 56602, 112, 102, 59, 49152, 55349, 56654, 99, 114, 59, 49152, 55349, 56498, 512, 102, 105, 111, 115, 5323, 5328, 5330, 5336, 114, 59, 49152, 55349, 56603, 59, 17310, 112, 102, 59, 49152, 55349, 56655, 99, 114, 59, 49152, 55349, 56499, 1152, 65, 73, 85, 97, 99, 102, 111, 115, 117, 5361, 5365, 5369, 5373, 5380, 5391, 5396, 5402, 5408, 99, 121, 59, 17455, 99, 121, 59, 17415, 99, 121, 59, 17454, 99, 117, 116, 101, 32827, 221, 16605, 256, 105, 121, 5385, 5389, 114, 99, 59, 16758, 59, 17451, 114, 59, 49152, 55349, 56604, 112, 102, 59, 49152, 55349, 56656, 99, 114, 59, 49152, 55349, 56500, 109, 108, 59, 16760, 1024, 72, 97, 99, 100, 101, 102, 111, 115, 5429, 5433, 5439, 5451, 5455, 5469, 5472, 5476, 99, 121, 59, 17430, 99, 117, 116, 101, 59, 16761, 256, 97, 121, 5444, 5449, 114, 111, 110, 59, 16765, 59, 17431, 111, 116, 59, 16763, 498, 5460, 0, 5467, 111, 87, 105, 100, 116, 232, 2777, 97, 59, 17302, 114, 59, 24872, 112, 102, 59, 24868, 99, 114, 59, 49152, 55349, 56501, 3041, 5507, 5514, 5520, 0, 5552, 5558, 5567, 0, 0, 0, 0, 5574, 5595, 5611, 5727, 5741, 0, 5781, 5787, 5810, 5817, 0, 5822, 99, 117, 116, 101, 32827, 225, 16609, 114, 101, 118, 101, 59, 16643, 768, 59, 69, 100, 105, 117, 121, 5532, 5533, 5537, 5539, 5544, 5549, 25150, 59, 49152, 8766, 819, 59, 25151, 114, 99, 32827, 226, 16610, 116, 101, 32955, 180, 774, 59, 17456, 108, 105, 103, 32827, 230, 16614, 256, 59, 114, 178, 5562, 59, 49152, 55349, 56606, 114, 97, 118, 101, 32827, 224, 16608, 256, 101, 112, 5578, 5590, 256, 102, 112, 5583, 5588, 115, 121, 109, 59, 24885, 232, 5587, 104, 97, 59, 17329, 256, 97, 112, 5599, 99, 256, 99, 108, 5604, 5607, 114, 59, 16641, 103, 59, 27199, 612, 5616, 0, 0, 5642, 640, 59, 97, 100, 115, 118, 5626, 5627, 5631, 5633, 5639, 25127, 110, 100, 59, 27221, 59, 27228, 108, 111, 112, 101, 59, 27224, 59, 27226, 896, 59, 101, 108, 109, 114, 115, 122, 5656, 5657, 5659, 5662, 5695, 5711, 5721, 25120, 59, 27044, 101, 187, 5657, 115, 100, 256, 59, 97, 5669, 5670, 25121, 1121, 5680, 5682, 5684, 5686, 5688, 5690, 5692, 5694, 59, 27048, 59, 27049, 59, 27050, 59, 27051, 59, 27052, 59, 27053, 59, 27054, 59, 27055, 116, 256, 59, 118, 5701, 5702, 25119, 98, 256, 59, 100, 5708, 5709, 25278, 59, 27037, 256, 112, 116, 5716, 5719, 104, 59, 25122, 187, 185, 97, 114, 114, 59, 25468, 256, 103, 112, 5731, 5735, 111, 110, 59, 16645, 102, 59, 49152, 55349, 56658, 896, 59, 69, 97, 101, 105, 111, 112, 4801, 5755, 5757, 5762, 5764, 5767, 5770, 59, 27248, 99, 105, 114, 59, 27247, 59, 25162, 100, 59, 25163, 115, 59, 16423, 114, 111, 120, 256, 59, 101, 4801, 5778, 241, 5763, 105, 110, 103, 32827, 229, 16613, 384, 99, 116, 121, 5793, 5798, 5800, 114, 59, 49152, 55349, 56502, 59, 16426, 109, 112, 256, 59, 101, 4801, 5807, 241, 648, 105, 108, 100, 101, 32827, 227, 16611, 109, 108, 32827, 228, 16612, 256, 99, 105, 5826, 5832, 111, 110, 105, 110, 244, 626, 110, 116, 59, 27153, 2048, 78, 97, 98, 99, 100, 101, 102, 105, 107, 108, 110, 111, 112, 114, 115, 117, 5869, 5873, 5936, 5948, 5955, 5960, 6008, 6013, 6112, 6118, 6201, 6224, 5901, 6461, 6472, 6512, 111, 116, 59, 27373, 256, 99, 114, 5878, 5918, 107, 512, 99, 101, 112, 115, 5888, 5893, 5901, 5907, 111, 110, 103, 59, 25164, 112, 115, 105, 108, 111, 110, 59, 17398, 114, 105, 109, 101, 59, 24629, 105, 109, 256, 59, 101, 5914, 5915, 25149, 113, 59, 25293, 374, 5922, 5926, 101, 101, 59, 25277, 101, 100, 256, 59, 103, 5932, 5933, 25349, 101, 187, 5933, 114, 107, 256, 59, 116, 4956, 5943, 98, 114, 107, 59, 25526, 256, 111, 121, 5889, 5953, 59, 17457, 113, 117, 111, 59, 24606, 640, 99, 109, 112, 114, 116, 5971, 5979, 5985, 5988, 5992, 97, 117, 115, 256, 59, 101, 266, 265, 112, 116, 121, 118, 59, 27056, 115, 233, 5900, 110, 111, 245, 275, 384, 97, 104, 119, 5999, 6001, 6003, 59, 17330, 59, 24886, 101, 101, 110, 59, 25196, 114, 59, 49152, 55349, 56607, 103, 896, 99, 111, 115, 116, 117, 118, 119, 6029, 6045, 6067, 6081, 6101, 6107, 6110, 384, 97, 105, 117, 6036, 6038, 6042, 240, 1888, 114, 99, 59, 26095, 112, 187, 4977, 384, 100, 112, 116, 6052, 6056, 6061, 111, 116, 59, 27136, 108, 117, 115, 59, 27137, 105, 109, 101, 115, 59, 27138, 625, 6073, 0, 0, 6078, 99, 117, 112, 59, 27142, 97, 114, 59, 26117, 114, 105, 97, 110, 103, 108, 101, 256, 100, 117, 6093, 6098, 111, 119, 110, 59, 26045, 112, 59, 26035, 112, 108, 117, 115, 59, 27140, 101, 229, 5188, 229, 5293, 97, 114, 111, 119, 59, 26893, 384, 97, 107, 111, 6125, 6182, 6197, 256, 99, 110, 6130, 6179, 107, 384, 108, 115, 116, 6138, 1451, 6146, 111, 122, 101, 110, 103, 101, 59, 27115, 114, 105, 97, 110, 103, 108, 101, 512, 59, 100, 108, 114, 6162, 6163, 6168, 6173, 26036, 111, 119, 110, 59, 26046, 101, 102, 116, 59, 26050, 105, 103, 104, 116, 59, 26040, 107, 59, 25635, 433, 6187, 0, 6195, 434, 6191, 0, 6193, 59, 26002, 59, 26001, 52, 59, 26003, 99, 107, 59, 25992, 256, 101, 111, 6206, 6221, 256, 59, 113, 6211, 6214, 49152, 61, 8421, 117, 105, 118, 59, 49152, 8801, 8421, 116, 59, 25360, 512, 112, 116, 119, 120, 6233, 6238, 6247, 6252, 102, 59, 49152, 55349, 56659, 256, 59, 116, 5067, 6243, 111, 109, 187, 5068, 116, 105, 101, 59, 25288, 1536, 68, 72, 85, 86, 98, 100, 104, 109, 112, 116, 117, 118, 6277, 6294, 6314, 6331, 6359, 6363, 6380, 6399, 6405, 6410, 6416, 6433, 512, 76, 82, 108, 114, 6286, 6288, 6290, 6292, 59, 25943, 59, 25940, 59, 25942, 59, 25939, 640, 59, 68, 85, 100, 117, 6305, 6306, 6308, 6310, 6312, 25936, 59, 25958, 59, 25961, 59, 25956, 59, 25959, 512, 76, 82, 108, 114, 6323, 6325, 6327, 6329, 59, 25949, 59, 25946, 59, 25948, 59, 25945, 896, 59, 72, 76, 82, 104, 108, 114, 6346, 6347, 6349, 6351, 6353, 6355, 6357, 25937, 59, 25964, 59, 25955, 59, 25952, 59, 25963, 59, 25954, 59, 25951, 111, 120, 59, 27081, 512, 76, 82, 108, 114, 6372, 6374, 6376, 6378, 59, 25941, 59, 25938, 59, 25872, 59, 25868, 640, 59, 68, 85, 100, 117, 1725, 6391, 6393, 6395, 6397, 59, 25957, 59, 25960, 59, 25900, 59, 25908, 105, 110, 117, 115, 59, 25247, 108, 117, 115, 59, 25246, 105, 109, 101, 115, 59, 25248, 512, 76, 82, 108, 114, 6425, 6427, 6429, 6431, 59, 25947, 59, 25944, 59, 25880, 59, 25876, 896, 59, 72, 76, 82, 104, 108, 114, 6448, 6449, 6451, 6453, 6455, 6457, 6459, 25858, 59, 25962, 59, 25953, 59, 25950, 59, 25916, 59, 25892, 59, 25884, 256, 101, 118, 291, 6466, 98, 97, 114, 32827, 166, 16550, 512, 99, 101, 105, 111, 6481, 6486, 6490, 6496, 114, 59, 49152, 55349, 56503, 109, 105, 59, 24655, 109, 256, 59, 101, 5914, 5916, 108, 384, 59, 98, 104, 6504, 6505, 6507, 16476, 59, 27077, 115, 117, 98, 59, 26568, 364, 6516, 6526, 108, 256, 59, 101, 6521, 6522, 24610, 116, 187, 6522, 112, 384, 59, 69, 101, 303, 6533, 6535, 59, 27310, 256, 59, 113, 1756, 1755, 3297, 6567, 0, 6632, 6673, 6677, 6706, 0, 6711, 6736, 0, 0, 6836, 0, 0, 6849, 0, 0, 6945, 6958, 6989, 6994, 0, 7165, 0, 7180, 384, 99, 112, 114, 6573, 6578, 6621, 117, 116, 101, 59, 16647, 768, 59, 97, 98, 99, 100, 115, 6591, 6592, 6596, 6602, 6613, 6617, 25129, 110, 100, 59, 27204, 114, 99, 117, 112, 59, 27209, 256, 97, 117, 6607, 6610, 112, 59, 27211, 112, 59, 27207, 111, 116, 59, 27200, 59, 49152, 8745, 65024, 256, 101, 111, 6626, 6629, 116, 59, 24641, 238, 1683, 512, 97, 101, 105, 117, 6640, 6651, 6657, 6661, 496, 6645, 0, 6648, 115, 59, 27213, 111, 110, 59, 16653, 100, 105, 108, 32827, 231, 16615, 114, 99, 59, 16649, 112, 115, 256, 59, 115, 6668, 6669, 27212, 109, 59, 27216, 111, 116, 59, 16651, 384, 100, 109, 110, 6683, 6688, 6694, 105, 108, 32955, 184, 429, 112, 116, 121, 118, 59, 27058, 116, 33024, 162, 59, 101, 6701, 6702, 16546, 114, 228, 434, 114, 59, 49152, 55349, 56608, 384, 99, 101, 105, 6717, 6720, 6733, 121, 59, 17479, 99, 107, 256, 59, 109, 6727, 6728, 26387, 97, 114, 107, 187, 6728, 59, 17351, 114, 896, 59, 69, 99, 101, 102, 109, 115, 6751, 6752, 6754, 6763, 6820, 6826, 6830, 26059, 59, 27075, 384, 59, 101, 108, 6761, 6762, 6765, 17094, 113, 59, 25175, 101, 609, 6772, 0, 0, 6792, 114, 114, 111, 119, 256, 108, 114, 6780, 6785, 101, 102, 116, 59, 25018, 105, 103, 104, 116, 59, 25019, 640, 82, 83, 97, 99, 100, 6802, 6804, 6806, 6810, 6815, 187, 3911, 59, 25800, 115, 116, 59, 25243, 105, 114, 99, 59, 25242, 97, 115, 104, 59, 25245, 110, 105, 110, 116, 59, 27152, 105, 100, 59, 27375, 99, 105, 114, 59, 27074, 117, 98, 115, 256, 59, 117, 6843, 6844, 26211, 105, 116, 187, 6844, 748, 6855, 6868, 6906, 0, 6922, 111, 110, 256, 59, 101, 6861, 6862, 16442, 256, 59, 113, 199, 198, 621, 6873, 0, 0, 6882, 97, 256, 59, 116, 6878, 6879, 16428, 59, 16448, 384, 59, 102, 108, 6888, 6889, 6891, 25089, 238, 4448, 101, 256, 109, 120, 6897, 6902, 101, 110, 116, 187, 6889, 101, 243, 589, 487, 6910, 0, 6919, 256, 59, 100, 4795, 6914, 111, 116, 59, 27245, 110, 244, 582, 384, 102, 114, 121, 6928, 6932, 6935, 59, 49152, 55349, 56660, 111, 228, 596, 33024, 169, 59, 115, 341, 6941, 114, 59, 24855, 256, 97, 111, 6949, 6953, 114, 114, 59, 25013, 115, 115, 59, 26391, 256, 99, 117, 6962, 6967, 114, 59, 49152, 55349, 56504, 256, 98, 112, 6972, 6980, 256, 59, 101, 6977, 6978, 27343, 59, 27345, 256, 59, 101, 6985, 6986, 27344, 59, 27346, 100, 111, 116, 59, 25327, 896, 100, 101, 108, 112, 114, 118, 119, 7008, 7020, 7031, 7042, 7084, 7124, 7161, 97, 114, 114, 256, 108, 114, 7016, 7018, 59, 26936, 59, 26933, 624, 7026, 0, 0, 7029, 114, 59, 25310, 99, 59, 25311, 97, 114, 114, 256, 59, 112, 7039, 7040, 25014, 59, 26941, 768, 59, 98, 99, 100, 111, 115, 7055, 7056, 7062, 7073, 7077, 7080, 25130, 114, 99, 97, 112, 59, 27208, 256, 97, 117, 7067, 7070, 112, 59, 27206, 112, 59, 27210, 111, 116, 59, 25229, 114, 59, 27205, 59, 49152, 8746, 65024, 512, 97, 108, 114, 118, 7093, 7103, 7134, 7139, 114, 114, 256, 59, 109, 7100, 7101, 25015, 59, 26940, 121, 384, 101, 118, 119, 7111, 7124, 7128, 113, 624, 7118, 0, 0, 7122, 114, 101, 227, 7027, 117, 227, 7029, 101, 101, 59, 25294, 101, 100, 103, 101, 59, 25295, 101, 110, 32827, 164, 16548, 101, 97, 114, 114, 111, 119, 256, 108, 114, 7150, 7155, 101, 102, 116, 187, 7040, 105, 103, 104, 116, 187, 7101, 101, 228, 7133, 256, 99, 105, 7169, 7175, 111, 110, 105, 110, 244, 503, 110, 116, 59, 25137, 108, 99, 116, 121, 59, 25389, 2432, 65, 72, 97, 98, 99, 100, 101, 102, 104, 105, 106, 108, 111, 114, 115, 116, 117, 119, 122, 7224, 7227, 7231, 7261, 7273, 7285, 7306, 7326, 7340, 7351, 7419, 7423, 7437, 7547, 7569, 7595, 7611, 7622, 7629, 114, 242, 897, 97, 114, 59, 26981, 512, 103, 108, 114, 115, 7240, 7245, 7250, 7252, 103, 101, 114, 59, 24608, 101, 116, 104, 59, 24888, 242, 4403, 104, 256, 59, 118, 7258, 7259, 24592, 187, 2314, 363, 7265, 7271, 97, 114, 111, 119, 59, 26895, 97, 227, 789, 256, 97, 121, 7278, 7283, 114, 111, 110, 59, 16655, 59, 17460, 384, 59, 97, 111, 818, 7292, 7300, 256, 103, 114, 703, 7297, 114, 59, 25034, 116, 115, 101, 113, 59, 27255, 384, 103, 108, 109, 7313, 7316, 7320, 32827, 176, 16560, 116, 97, 59, 17332, 112, 116, 121, 118, 59, 27057, 256, 105, 114, 7331, 7336, 115, 104, 116, 59, 27007, 59, 49152, 55349, 56609, 97, 114, 256, 108, 114, 7347, 7349, 187, 2268, 187, 4126, 640, 97, 101, 103, 115, 118, 7362, 888, 7382, 7388, 7392, 109, 384, 59, 111, 115, 806, 7370, 7380, 110, 100, 256, 59, 115, 806, 7377, 117, 105, 116, 59, 26214, 97, 109, 109, 97, 59, 17373, 105, 110, 59, 25330, 384, 59, 105, 111, 7399, 7400, 7416, 16631, 100, 101, 33024, 247, 59, 111, 7399, 7408, 110, 116, 105, 109, 101, 115, 59, 25287, 110, 248, 7415, 99, 121, 59, 17490, 99, 623, 7430, 0, 0, 7434, 114, 110, 59, 25374, 111, 112, 59, 25357, 640, 108, 112, 116, 117, 119, 7448, 7453, 7458, 7497, 7509, 108, 97, 114, 59, 16420, 102, 59, 49152, 55349, 56661, 640, 59, 101, 109, 112, 115, 779, 7469, 7479, 7485, 7490, 113, 256, 59, 100, 850, 7475, 111, 116, 59, 25169, 105, 110, 117, 115, 59, 25144, 108, 117, 115, 59, 25108, 113, 117, 97, 114, 101, 59, 25249, 98, 108, 101, 98, 97, 114, 119, 101, 100, 103, 229, 250, 110, 384, 97, 100, 104, 4398, 7517, 7527, 111, 119, 110, 97, 114, 114, 111, 119, 243, 7299, 97, 114, 112, 111, 111, 110, 256, 108, 114, 7538, 7542, 101, 102, 244, 7348, 105, 103, 104, 244, 7350, 354, 7551, 7557, 107, 97, 114, 111, 247, 3906, 623, 7562, 0, 0, 7566, 114, 110, 59, 25375, 111, 112, 59, 25356, 384, 99, 111, 116, 7576, 7587, 7590, 256, 114, 121, 7581, 7585, 59, 49152, 55349, 56505, 59, 17493, 108, 59, 27126, 114, 111, 107, 59, 16657, 256, 100, 114, 7600, 7604, 111, 116, 59, 25329, 105, 256, 59, 102, 7610, 6166, 26047, 256, 97, 104, 7616, 7619, 114, 242, 1065, 97, 242, 4006, 97, 110, 103, 108, 101, 59, 27046, 256, 99, 105, 7634, 7637, 121, 59, 17503, 103, 114, 97, 114, 114, 59, 26623, 2304, 68, 97, 99, 100, 101, 102, 103, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 120, 7681, 7689, 7705, 7736, 1400, 7740, 7753, 7777, 7806, 7845, 7855, 7869, 7905, 7978, 7991, 8004, 8014, 8026, 256, 68, 111, 7686, 7476, 111, 244, 7305, 256, 99, 115, 7694, 7700, 117, 116, 101, 32827, 233, 16617, 116, 101, 114, 59, 27246, 512, 97, 105, 111, 121, 7714, 7719, 7729, 7734, 114, 111, 110, 59, 16667, 114, 256, 59, 99, 7725, 7726, 25174, 32827, 234, 16618, 108, 111, 110, 59, 25173, 59, 17485, 111, 116, 59, 16663, 256, 68, 114, 7745, 7749, 111, 116, 59, 25170, 59, 49152, 55349, 56610, 384, 59, 114, 115, 7760, 7761, 7767, 27290, 97, 118, 101, 32827, 232, 16616, 256, 59, 100, 7772, 7773, 27286, 111, 116, 59, 27288, 512, 59, 105, 108, 115, 7786, 7787, 7794, 7796, 27289, 110, 116, 101, 114, 115, 59, 25575, 59, 24851, 256, 59, 100, 7801, 7802, 27285, 111, 116, 59, 27287, 384, 97, 112, 115, 7813, 7817, 7831, 99, 114, 59, 16659, 116, 121, 384, 59, 115, 118, 7826, 7827, 7829, 25093, 101, 116, 187, 7827, 112, 256, 49, 59, 7837, 7844, 307, 7841, 7843, 59, 24580, 59, 24581, 24579, 256, 103, 115, 7850, 7852, 59, 16715, 112, 59, 24578, 256, 103, 112, 7860, 7864, 111, 110, 59, 16665, 102, 59, 49152, 55349, 56662, 384, 97, 108, 115, 7876, 7886, 7890, 114, 256, 59, 115, 7882, 7883, 25301, 108, 59, 27107, 117, 115, 59, 27249, 105, 384, 59, 108, 118, 7898, 7899, 7903, 17333, 111, 110, 187, 7899, 59, 17397, 512, 99, 115, 117, 118, 7914, 7923, 7947, 7971, 256, 105, 111, 7919, 7729, 114, 99, 187, 7726, 617, 7929, 0, 0, 7931, 237, 1352, 97, 110, 116, 256, 103, 108, 7938, 7942, 116, 114, 187, 7773, 101, 115, 115, 187, 7802, 384, 97, 101, 105, 7954, 7958, 7962, 108, 115, 59, 16445, 115, 116, 59, 25183, 118, 256, 59, 68, 565, 7968, 68, 59, 27256, 112, 97, 114, 115, 108, 59, 27109, 256, 68, 97, 7983, 7987, 111, 116, 59, 25171, 114, 114, 59, 26993, 384, 99, 100, 105, 7998, 8001, 7928, 114, 59, 24879, 111, 244, 850, 256, 97, 104, 8009, 8011, 59, 17335, 32827, 240, 16624, 256, 109, 114, 8019, 8023, 108, 32827, 235, 16619, 111, 59, 24748, 384, 99, 105, 112, 8033, 8036, 8039, 108, 59, 16417, 115, 244, 1390, 256, 101, 111, 8044, 8052, 99, 116, 97, 116, 105, 111, 238, 1369, 110, 101, 110, 116, 105, 97, 108, 229, 1401, 2529, 8082, 0, 8094, 0, 8097, 8103, 0, 0, 8134, 8140, 0, 8147, 0, 8166, 8170, 8192, 0, 8200, 8282, 108, 108, 105, 110, 103, 100, 111, 116, 115, 101, 241, 7748, 121, 59, 17476, 109, 97, 108, 101, 59, 26176, 384, 105, 108, 114, 8109, 8115, 8129, 108, 105, 103, 59, 32768, 64259, 617, 8121, 0, 0, 8125, 103, 59, 32768, 64256, 105, 103, 59, 32768, 64260, 59, 49152, 55349, 56611, 108, 105, 103, 59, 32768, 64257, 108, 105, 103, 59, 49152, 102, 106, 384, 97, 108, 116, 8153, 8156, 8161, 116, 59, 26221, 105, 103, 59, 32768, 64258, 110, 115, 59, 26033, 111, 102, 59, 16786, 496, 8174, 0, 8179, 102, 59, 49152, 55349, 56663, 256, 97, 107, 1471, 8183, 256, 59, 118, 8188, 8189, 25300, 59, 27353, 97, 114, 116, 105, 110, 116, 59, 27149, 256, 97, 111, 8204, 8277, 256, 99, 115, 8209, 8274, 945, 8218, 8240, 8248, 8261, 8264, 0, 8272, 946, 8226, 8229, 8231, 8234, 8236, 0, 8238, 32827, 189, 16573, 59, 24915, 32827, 188, 16572, 59, 24917, 59, 24921, 59, 24923, 435, 8244, 0, 8246, 59, 24916, 59, 24918, 692, 8254, 8257, 0, 0, 8259, 32827, 190, 16574, 59, 24919, 59, 24924, 53, 59, 24920, 438, 8268, 0, 8270, 59, 24922, 59, 24925, 56, 59, 24926, 108, 59, 24644, 119, 110, 59, 25378, 99, 114, 59, 49152, 55349, 56507, 2176, 69, 97, 98, 99, 100, 101, 102, 103, 105, 106, 108, 110, 111, 114, 115, 116, 118, 8322, 8329, 8351, 8357, 8368, 8372, 8432, 8437, 8442, 8447, 8451, 8466, 8504, 791, 8510, 8530, 8606, 256, 59, 108, 1613, 8327, 59, 27276, 384, 99, 109, 112, 8336, 8341, 8349, 117, 116, 101, 59, 16885, 109, 97, 256, 59, 100, 8348, 7386, 17331, 59, 27270, 114, 101, 118, 101, 59, 16671, 256, 105, 121, 8362, 8366, 114, 99, 59, 16669, 59, 17459, 111, 116, 59, 16673, 512, 59, 108, 113, 115, 1598, 1602, 8381, 8393, 384, 59, 113, 115, 1598, 1612, 8388, 108, 97, 110, 244, 1637, 512, 59, 99, 100, 108, 1637, 8402, 8405, 8421, 99, 59, 27305, 111, 116, 256, 59, 111, 8412, 8413, 27264, 256, 59, 108, 8418, 8419, 27266, 59, 27268, 256, 59, 101, 8426, 8429, 49152, 8923, 65024, 115, 59, 27284, 114, 59, 49152, 55349, 56612, 256, 59, 103, 1651, 1563, 109, 101, 108, 59, 24887, 99, 121, 59, 17491, 512, 59, 69, 97, 106, 1626, 8460, 8462, 8464, 59, 27282, 59, 27301, 59, 27300, 512, 69, 97, 101, 115, 8475, 8477, 8489, 8500, 59, 25193, 112, 256, 59, 112, 8483, 8484, 27274, 114, 111, 120, 187, 8484, 256, 59, 113, 8494, 8495, 27272, 256, 59, 113, 8494, 8475, 105, 109, 59, 25319, 112, 102, 59, 49152, 55349, 56664, 256, 99, 105, 8515, 8518, 114, 59, 24842, 109, 384, 59, 101, 108, 1643, 8526, 8528, 59, 27278, 59, 27280, 33536, 62, 59, 99, 100, 108, 113, 114, 1518, 8544, 8554, 8558, 8563, 8569, 256, 99, 105, 8549, 8551, 59, 27303, 114, 59, 27258, 111, 116, 59, 25303, 80, 97, 114, 59, 27029, 117, 101, 115, 116, 59, 27260, 640, 97, 100, 101, 108, 115, 8580, 8554, 8592, 1622, 8603, 496, 8585, 0, 8590, 112, 114, 111, 248, 8350, 114, 59, 27000, 113, 256, 108, 113, 1599, 8598, 108, 101, 115, 243, 8328, 105, 237, 1643, 256, 101, 110, 8611, 8621, 114, 116, 110, 101, 113, 113, 59, 49152, 8809, 65024, 197, 8618, 1280, 65, 97, 98, 99, 101, 102, 107, 111, 115, 121, 8644, 8647, 8689, 8693, 8698, 8728, 8733, 8751, 8808, 8829, 114, 242, 928, 512, 105, 108, 109, 114, 8656, 8660, 8663, 8667, 114, 115, 240, 5252, 102, 187, 8228, 105, 108, 244, 1705, 256, 100, 114, 8672, 8676, 99, 121, 59, 17482, 384, 59, 99, 119, 2292, 8683, 8687, 105, 114, 59, 26952, 59, 25005, 97, 114, 59, 24847, 105, 114, 99, 59, 16677, 384, 97, 108, 114, 8705, 8718, 8723, 114, 116, 115, 256, 59, 117, 8713, 8714, 26213, 105, 116, 187, 8714, 108, 105, 112, 59, 24614, 99, 111, 110, 59, 25273, 114, 59, 49152, 55349, 56613, 115, 256, 101, 119, 8739, 8745, 97, 114, 111, 119, 59, 26917, 97, 114, 111, 119, 59, 26918, 640, 97, 109, 111, 112, 114, 8762, 8766, 8771, 8798, 8803, 114, 114, 59, 25087, 116, 104, 116, 59, 25147, 107, 256, 108, 114, 8777, 8787, 101, 102, 116, 97, 114, 114, 111, 119, 59, 25001, 105, 103, 104, 116, 97, 114, 114, 111, 119, 59, 25002, 102, 59, 49152, 55349, 56665, 98, 97, 114, 59, 24597, 384, 99, 108, 116, 8815, 8820, 8824, 114, 59, 49152, 55349, 56509, 97, 115, 232, 8692, 114, 111, 107, 59, 16679, 256, 98, 112, 8834, 8839, 117, 108, 108, 59, 24643, 104, 101, 110, 187, 7259, 2785, 8867, 0, 8874, 0, 8888, 8901, 8910, 0, 8917, 8947, 0, 0, 8952, 8994, 9063, 9058, 9087, 0, 9094, 9130, 9140, 99, 117, 116, 101, 32827, 237, 16621, 384, 59, 105, 121, 1905, 8880, 8885, 114, 99, 32827, 238, 16622, 59, 17464, 256, 99, 120, 8892, 8895, 121, 59, 17461, 99, 108, 32827, 161, 16545, 256, 102, 114, 927, 8905, 59, 49152, 55349, 56614, 114, 97, 118, 101, 32827, 236, 16620, 512, 59, 105, 110, 111, 1854, 8925, 8937, 8942, 256, 105, 110, 8930, 8934, 110, 116, 59, 27148, 116, 59, 25133, 102, 105, 110, 59, 27100, 116, 97, 59, 24873, 108, 105, 103, 59, 16691, 384, 97, 111, 112, 8958, 8986, 8989, 384, 99, 103, 116, 8965, 8968, 8983, 114, 59, 16683, 384, 101, 108, 112, 1823, 8975, 8979, 105, 110, 229, 1934, 97, 114, 244, 1824, 104, 59, 16689, 102, 59, 25271, 101, 100, 59, 16821, 640, 59, 99, 102, 111, 116, 1268, 9004, 9009, 9021, 9025, 97, 114, 101, 59, 24837, 105, 110, 256, 59, 116, 9016, 9017, 25118, 105, 101, 59, 27101, 100, 111, 244, 8985, 640, 59, 99, 101, 108, 112, 1879, 9036, 9040, 9051, 9057, 97, 108, 59, 25274, 256, 103, 114, 9045, 9049, 101, 114, 243, 5475, 227, 9037, 97, 114, 104, 107, 59, 27159, 114, 111, 100, 59, 27196, 512, 99, 103, 112, 116, 9071, 9074, 9078, 9083, 121, 59, 17489, 111, 110, 59, 16687, 102, 59, 49152, 55349, 56666, 97, 59, 17337, 117, 101, 115, 116, 32827, 191, 16575, 256, 99, 105, 9098, 9103, 114, 59, 49152, 55349, 56510, 110, 640, 59, 69, 100, 115, 118, 1268, 9115, 9117, 9121, 1267, 59, 25337, 111, 116, 59, 25333, 256, 59, 118, 9126, 9127, 25332, 59, 25331, 256, 59, 105, 1911, 9134, 108, 100, 101, 59, 16681, 491, 9144, 0, 9148, 99, 121, 59, 17494, 108, 32827, 239, 16623, 768, 99, 102, 109, 111, 115, 117, 9164, 9175, 9180, 9185, 9191, 9205, 256, 105, 121, 9169, 9173, 114, 99, 59, 16693, 59, 17465, 114, 59, 49152, 55349, 56615, 97, 116, 104, 59, 16951, 112, 102, 59, 49152, 55349, 56667, 483, 9196, 0, 9201, 114, 59, 49152, 55349, 56511, 114, 99, 121, 59, 17496, 107, 99, 121, 59, 17492, 1024, 97, 99, 102, 103, 104, 106, 111, 115, 9227, 9238, 9250, 9255, 9261, 9265, 9269, 9275, 112, 112, 97, 256, 59, 118, 9235, 9236, 17338, 59, 17392, 256, 101, 121, 9243, 9248, 100, 105, 108, 59, 16695, 59, 17466, 114, 59, 49152, 55349, 56616, 114, 101, 101, 110, 59, 16696, 99, 121, 59, 17477, 99, 121, 59, 17500, 112, 102, 59, 49152, 55349, 56668, 99, 114, 59, 49152, 55349, 56512, 2944, 65, 66, 69, 72, 97, 98, 99, 100, 101, 102, 103, 104, 106, 108, 109, 110, 111, 112, 114, 115, 116, 117, 118, 9328, 9345, 9350, 9357, 9361, 9486, 9533, 9562, 9600, 9806, 9822, 9829, 9849, 9853, 9882, 9906, 9944, 10077, 10088, 10123, 10176, 10241, 10258, 384, 97, 114, 116, 9335, 9338, 9340, 114, 242, 2502, 242, 917, 97, 105, 108, 59, 26907, 97, 114, 114, 59, 26894, 256, 59, 103, 2452, 9355, 59, 27275, 97, 114, 59, 26978, 2403, 9381, 0, 9386, 0, 9393, 0, 0, 0, 0, 0, 9397, 9402, 0, 9414, 9416, 9421, 0, 9465, 117, 116, 101, 59, 16698, 109, 112, 116, 121, 118, 59, 27060, 114, 97, 238, 2124, 98, 100, 97, 59, 17339, 103, 384, 59, 100, 108, 2190, 9409, 9411, 59, 27025, 229, 2190, 59, 27269, 117, 111, 32827, 171, 16555, 114, 1024, 59, 98, 102, 104, 108, 112, 115, 116, 2201, 9438, 9446, 9449, 9451, 9454, 9457, 9461, 256, 59, 102, 2205, 9443, 115, 59, 26911, 115, 59, 26909, 235, 8786, 112, 59, 25003, 108, 59, 26937, 105, 109, 59, 26995, 108, 59, 24994, 384, 59, 97, 101, 9471, 9472, 9476, 27307, 105, 108, 59, 26905, 256, 59, 115, 9481, 9482, 27309, 59, 49152, 10925, 65024, 384, 97, 98, 114, 9493, 9497, 9501, 114, 114, 59, 26892, 114, 107, 59, 26482, 256, 97, 107, 9506, 9516, 99, 256, 101, 107, 9512, 9514, 59, 16507, 59, 16475, 256, 101, 115, 9521, 9523, 59, 27019, 108, 256, 100, 117, 9529, 9531, 59, 27023, 59, 27021, 512, 97, 101, 117, 121, 9542, 9547, 9558, 9560, 114, 111, 110, 59, 16702, 256, 100, 105, 9552, 9556, 105, 108, 59, 16700, 236, 2224, 226, 9513, 59, 17467, 512, 99, 113, 114, 115, 9571, 9574, 9581, 9597, 97, 59, 26934, 117, 111, 256, 59, 114, 3609, 5958, 256, 100, 117, 9586, 9591, 104, 97, 114, 59, 26983, 115, 104, 97, 114, 59, 26955, 104, 59, 25010, 640, 59, 102, 103, 113, 115, 9611, 9612, 2441, 9715, 9727, 25188, 116, 640, 97, 104, 108, 114, 116, 9624, 9636, 9655, 9666, 9704, 114, 114, 111, 119, 256, 59, 116, 2201, 9633, 97, 233, 9462, 97, 114, 112, 111, 111, 110, 256, 100, 117, 9647, 9652, 111, 119, 110, 187, 1114, 112, 187, 2406, 101, 102, 116, 97, 114, 114, 111, 119, 115, 59, 25031, 105, 103, 104, 116, 384, 97, 104, 115, 9677, 9686, 9694, 114, 114, 111, 119, 256, 59, 115, 2292, 2215, 97, 114, 112, 111, 111, 110, 243, 3992, 113, 117, 105, 103, 97, 114, 114, 111, 247, 8688, 104, 114, 101, 101, 116, 105, 109, 101, 115, 59, 25291, 384, 59, 113, 115, 9611, 2451, 9722, 108, 97, 110, 244, 2476, 640, 59, 99, 100, 103, 115, 2476, 9738, 9741, 9757, 9768, 99, 59, 27304, 111, 116, 256, 59, 111, 9748, 9749, 27263, 256, 59, 114, 9754, 9755, 27265, 59, 27267, 256, 59, 101, 9762, 9765, 49152, 8922, 65024, 115, 59, 27283, 640, 97, 100, 101, 103, 115, 9779, 9785, 9789, 9801, 9803, 112, 112, 114, 111, 248, 9414, 111, 116, 59, 25302, 113, 256, 103, 113, 9795, 9797, 244, 2441, 103, 116, 242, 9356, 244, 2459, 105, 237, 2482, 384, 105, 108, 114, 9813, 2273, 9818, 115, 104, 116, 59, 27004, 59, 49152, 55349, 56617, 256, 59, 69, 2460, 9827, 59, 27281, 353, 9833, 9846, 114, 256, 100, 117, 9650, 9838, 256, 59, 108, 2405, 9843, 59, 26986, 108, 107, 59, 25988, 99, 121, 59, 17497, 640, 59, 97, 99, 104, 116, 2632, 9864, 9867, 9873, 9878, 114, 242, 9665, 111, 114, 110, 101, 242, 7432, 97, 114, 100, 59, 26987, 114, 105, 59, 26106, 256, 105, 111, 9887, 9892, 100, 111, 116, 59, 16704, 117, 115, 116, 256, 59, 97, 9900, 9901, 25520, 99, 104, 101, 187, 9901, 512, 69, 97, 101, 115, 9915, 9917, 9929, 9940, 59, 25192, 112, 256, 59, 112, 9923, 9924, 27273, 114, 111, 120, 187, 9924, 256, 59, 113, 9934, 9935, 27271, 256, 59, 113, 9934, 9915, 105, 109, 59, 25318, 1024, 97, 98, 110, 111, 112, 116, 119, 122, 9961, 9972, 9975, 10010, 10031, 10049, 10055, 10064, 256, 110, 114, 9966, 9969, 103, 59, 26604, 114, 59, 25085, 114, 235, 2241, 103, 384, 108, 109, 114, 9983, 9997, 10004, 101, 102, 116, 256, 97, 114, 2534, 9991, 105, 103, 104, 116, 225, 2546, 97, 112, 115, 116, 111, 59, 26620, 105, 103, 104, 116, 225, 2557, 112, 97, 114, 114, 111, 119, 256, 108, 114, 10021, 10025, 101, 102, 244, 9453, 105, 103, 104, 116, 59, 25004, 384, 97, 102, 108, 10038, 10041, 10045, 114, 59, 27013, 59, 49152, 55349, 56669, 117, 115, 59, 27181, 105, 109, 101, 115, 59, 27188, 353, 10059, 10063, 115, 116, 59, 25111, 225, 4942, 384, 59, 101, 102, 10071, 10072, 6144, 26058, 110, 103, 101, 187, 10072, 97, 114, 256, 59, 108, 10084, 10085, 16424, 116, 59, 27027, 640, 97, 99, 104, 109, 116, 10099, 10102, 10108, 10117, 10119, 114, 242, 2216, 111, 114, 110, 101, 242, 7564, 97, 114, 256, 59, 100, 3992, 10115, 59, 26989, 59, 24590, 114, 105, 59, 25279, 768, 97, 99, 104, 105, 113, 116, 10136, 10141, 2624, 10146, 10158, 10171, 113, 117, 111, 59, 24633, 114, 59, 49152, 55349, 56513, 109, 384, 59, 101, 103, 2482, 10154, 10156, 59, 27277, 59, 27279, 256, 98, 117, 9514, 10163, 111, 256, 59, 114, 3615, 10169, 59, 24602, 114, 111, 107, 59, 16706, 33792, 60, 59, 99, 100, 104, 105, 108, 113, 114, 2091, 10194, 9785, 10204, 10208, 10213, 10218, 10224, 256, 99, 105, 10199, 10201, 59, 27302, 114, 59, 27257, 114, 101, 229, 9714, 109, 101, 115, 59, 25289, 97, 114, 114, 59, 26998, 117, 101, 115, 116, 59, 27259, 256, 80, 105, 10229, 10233, 97, 114, 59, 27030, 384, 59, 101, 102, 10240, 2349, 6171, 26051, 114, 256, 100, 117, 10247, 10253, 115, 104, 97, 114, 59, 26954, 104, 97, 114, 59, 26982, 256, 101, 110, 10263, 10273, 114, 116, 110, 101, 113, 113, 59, 49152, 8808, 65024, 197, 10270, 1792, 68, 97, 99, 100, 101, 102, 104, 105, 108, 110, 111, 112, 115, 117, 10304, 10309, 10370, 10382, 10387, 10400, 10405, 10408, 10458, 10466, 10468, 2691, 10483, 10498, 68, 111, 116, 59, 25146, 512, 99, 108, 112, 114, 10318, 10322, 10339, 10365, 114, 32827, 175, 16559, 256, 101, 116, 10327, 10329, 59, 26178, 256, 59, 101, 10334, 10335, 26400, 115, 101, 187, 10335, 256, 59, 115, 4155, 10344, 116, 111, 512, 59, 100, 108, 117, 4155, 10355, 10359, 10363, 111, 119, 238, 1164, 101, 102, 244, 2319, 240, 5073, 107, 101, 114, 59, 26030, 256, 111, 121, 10375, 10380, 109, 109, 97, 59, 27177, 59, 17468, 97, 115, 104, 59, 24596, 97, 115, 117, 114, 101, 100, 97, 110, 103, 108, 101, 187, 5670, 114, 59, 49152, 55349, 56618, 111, 59, 24871, 384, 99, 100, 110, 10415, 10420, 10441, 114, 111, 32827, 181, 16565, 512, 59, 97, 99, 100, 5220, 10429, 10432, 10436, 115, 244, 5799, 105, 114, 59, 27376, 111, 116, 32955, 183, 437, 117, 115, 384, 59, 98, 100, 10450, 6403, 10451, 25106, 256, 59, 117, 7484, 10456, 59, 27178, 355, 10462, 10465, 112, 59, 27355, 242, 8722, 240, 2689, 256, 100, 112, 10473, 10478, 101, 108, 115, 59, 25255, 102, 59, 49152, 55349, 56670, 256, 99, 116, 10488, 10493, 114, 59, 49152, 55349, 56514, 112, 111, 115, 187, 5533, 384, 59, 108, 109, 10505, 10506, 10509, 17340, 116, 105, 109, 97, 112, 59, 25272, 3072, 71, 76, 82, 86, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 108, 109, 111, 112, 114, 115, 116, 117, 118, 119, 10562, 10579, 10622, 10633, 10648, 10714, 10729, 10773, 10778, 10840, 10845, 10883, 10901, 10916, 10920, 11012, 11015, 11076, 11135, 11182, 11316, 11367, 11388, 11497, 256, 103, 116, 10567, 10571, 59, 49152, 8921, 824, 256, 59, 118, 10576, 3023, 49152, 8811, 8402, 384, 101, 108, 116, 10586, 10610, 10614, 102, 116, 256, 97, 114, 10593, 10599, 114, 114, 111, 119, 59, 25037, 105, 103, 104, 116, 97, 114, 114, 111, 119, 59, 25038, 59, 49152, 8920, 824, 256, 59, 118, 10619, 3143, 49152, 8810, 8402, 105, 103, 104, 116, 97, 114, 114, 111, 119, 59, 25039, 256, 68, 100, 10638, 10643, 97, 115, 104, 59, 25263, 97, 115, 104, 59, 25262, 640, 98, 99, 110, 112, 116, 10659, 10663, 10668, 10673, 10700, 108, 97, 187, 734, 117, 116, 101, 59, 16708, 103, 59, 49152, 8736, 8402, 640, 59, 69, 105, 111, 112, 3460, 10684, 10688, 10693, 10696, 59, 49152, 10864, 824, 100, 59, 49152, 8779, 824, 115, 59, 16713, 114, 111, 248, 3460, 117, 114, 256, 59, 97, 10707, 10708, 26222, 108, 256, 59, 115, 10707, 2872, 499, 10719, 0, 10723, 112, 32955, 160, 2871, 109, 112, 256, 59, 101, 3065, 3072, 640, 97, 101, 111, 117, 121, 10740, 10750, 10755, 10768, 10771, 496, 10745, 0, 10747, 59, 27203, 111, 110, 59, 16712, 100, 105, 108, 59, 16710, 110, 103, 256, 59, 100, 3454, 10762, 111, 116, 59, 49152, 10861, 824, 112, 59, 27202, 59, 17469, 97, 115, 104, 59, 24595, 896, 59, 65, 97, 100, 113, 115, 120, 2962, 10793, 10797, 10811, 10817, 10821, 10832, 114, 114, 59, 25047, 114, 256, 104, 114, 10803, 10806, 107, 59, 26916, 256, 59, 111, 5106, 5104, 111, 116, 59, 49152, 8784, 824, 117, 105, 246, 2915, 256, 101, 105, 10826, 10830, 97, 114, 59, 26920, 237, 2968, 105, 115, 116, 256, 59, 115, 2976, 2975, 114, 59, 49152, 55349, 56619, 512, 69, 101, 115, 116, 3013, 10854, 10873, 10876, 384, 59, 113, 115, 3004, 10861, 3041, 384, 59, 113, 115, 3004, 3013, 10868, 108, 97, 110, 244, 3042, 105, 237, 3050, 256, 59, 114, 2998, 10881, 187, 2999, 384, 65, 97, 112, 10890, 10893, 10897, 114, 242, 10609, 114, 114, 59, 25006, 97, 114, 59, 27378, 384, 59, 115, 118, 3981, 10908, 3980, 256, 59, 100, 10913, 10914, 25340, 59, 25338, 99, 121, 59, 17498, 896, 65, 69, 97, 100, 101, 115, 116, 10935, 10938, 10942, 10946, 10949, 10998, 11001, 114, 242, 10598, 59, 49152, 8806, 824, 114, 114, 59, 24986, 114, 59, 24613, 512, 59, 102, 113, 115, 3131, 10958, 10979, 10991, 116, 256, 97, 114, 10964, 10969, 114, 114, 111, 247, 10945, 105, 103, 104, 116, 97, 114, 114, 111, 247, 10896, 384, 59, 113, 115, 3131, 10938, 10986, 108, 97, 110, 244, 3157, 256, 59, 115, 3157, 10996, 187, 3126, 105, 237, 3165, 256, 59, 114, 3125, 11006, 105, 256, 59, 101, 3098, 3109, 105, 228, 3472, 256, 112, 116, 11020, 11025, 102, 59, 49152, 55349, 56671, 33152, 172, 59, 105, 110, 11033, 11034, 11062, 16556, 110, 512, 59, 69, 100, 118, 2953, 11044, 11048, 11054, 59, 49152, 8953, 824, 111, 116, 59, 49152, 8949, 824, 481, 2953, 11059, 11061, 59, 25335, 59, 25334, 105, 256, 59, 118, 3256, 11068, 481, 3256, 11073, 11075, 59, 25342, 59, 25341, 384, 97, 111, 114, 11083, 11107, 11113, 114, 512, 59, 97, 115, 116, 2939, 11093, 11098, 11103, 108, 108, 101, 236, 2939, 108, 59, 49152, 11005, 8421, 59, 49152, 8706, 824, 108, 105, 110, 116, 59, 27156, 384, 59, 99, 101, 3218, 11120, 11123, 117, 229, 3237, 256, 59, 99, 3224, 11128, 256, 59, 101, 3218, 11133, 241, 3224, 512, 65, 97, 105, 116, 11144, 11147, 11165, 11175, 114, 242, 10632, 114, 114, 384, 59, 99, 119, 11156, 11157, 11161, 24987, 59, 49152, 10547, 824, 59, 49152, 8605, 824, 103, 104, 116, 97, 114, 114, 111, 119, 187, 11157, 114, 105, 256, 59, 101, 3275, 3286, 896, 99, 104, 105, 109, 112, 113, 117, 11197, 11213, 11225, 11012, 2936, 11236, 11247, 512, 59, 99, 101, 114, 3378, 11206, 3383, 11209, 117, 229, 3397, 59, 49152, 55349, 56515, 111, 114, 116, 621, 11013, 0, 0, 11222, 97, 114, 225, 11094, 109, 256, 59, 101, 3438, 11231, 256, 59, 113, 3444, 3443, 115, 117, 256, 98, 112, 11243, 11245, 229, 3320, 229, 3339, 384, 98, 99, 112, 11254, 11281, 11289, 512, 59, 69, 101, 115, 11263, 11264, 3362, 11268, 25220, 59, 49152, 10949, 824, 101, 116, 256, 59, 101, 3355, 11275, 113, 256, 59, 113, 3363, 11264, 99, 256, 59, 101, 3378, 11287, 241, 3384, 512, 59, 69, 101, 115, 11298, 11299, 3423, 11303, 25221, 59, 49152, 10950, 824, 101, 116, 256, 59, 101, 3416, 11310, 113, 256, 59, 113, 3424, 11299, 512, 103, 105, 108, 114, 11325, 11327, 11333, 11335, 236, 3031, 108, 100, 101, 32827, 241, 16625, 231, 3139, 105, 97, 110, 103, 108, 101, 256, 108, 114, 11346, 11356, 101, 102, 116, 256, 59, 101, 3098, 11354, 241, 3110, 105, 103, 104, 116, 256, 59, 101, 3275, 11365, 241, 3287, 256, 59, 109, 11372, 11373, 17341, 384, 59, 101, 115, 11380, 11381, 11385, 16419, 114, 111, 59, 24854, 112, 59, 24583, 1152, 68, 72, 97, 100, 103, 105, 108, 114, 115, 11407, 11412, 11417, 11422, 11427, 11440, 11446, 11475, 11491, 97, 115, 104, 59, 25261, 97, 114, 114, 59, 26884, 112, 59, 49152, 8781, 8402, 97, 115, 104, 59, 25260, 256, 101, 116, 11432, 11436, 59, 49152, 8805, 8402, 59, 49152, 62, 8402, 110, 102, 105, 110, 59, 27102, 384, 65, 101, 116, 11453, 11457, 11461, 114, 114, 59, 26882, 59, 49152, 8804, 8402, 256, 59, 114, 11466, 11469, 49152, 60, 8402, 105, 101, 59, 49152, 8884, 8402, 256, 65, 116, 11480, 11484, 114, 114, 59, 26883, 114, 105, 101, 59, 49152, 8885, 8402, 105, 109, 59, 49152, 8764, 8402, 384, 65, 97, 110, 11504, 11508, 11522, 114, 114, 59, 25046, 114, 256, 104, 114, 11514, 11517, 107, 59, 26915, 256, 59, 111, 5095, 5093, 101, 97, 114, 59, 26919, 4691, 6805, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11565, 0, 11576, 11592, 11616, 11621, 11634, 11652, 6919, 0, 0, 11661, 11691, 0, 11720, 11726, 0, 11740, 11801, 11819, 11838, 11843, 256, 99, 115, 11569, 6807, 117, 116, 101, 32827, 243, 16627, 256, 105, 121, 11580, 11589, 114, 256, 59, 99, 6814, 11586, 32827, 244, 16628, 59, 17470, 640, 97, 98, 105, 111, 115, 6816, 11602, 11607, 456, 11610, 108, 97, 99, 59, 16721, 118, 59, 27192, 111, 108, 100, 59, 27068, 108, 105, 103, 59, 16723, 256, 99, 114, 11625, 11629, 105, 114, 59, 27071, 59, 49152, 55349, 56620, 879, 11641, 0, 0, 11644, 0, 11650, 110, 59, 17115, 97, 118, 101, 32827, 242, 16626, 59, 27073, 256, 98, 109, 11656, 3572, 97, 114, 59, 27061, 512, 97, 99, 105, 116, 11669, 11672, 11685, 11688, 114, 242, 6784, 256, 105, 114, 11677, 11680, 114, 59, 27070, 111, 115, 115, 59, 27067, 110, 229, 3666, 59, 27072, 384, 97, 101, 105, 11697, 11701, 11705, 99, 114, 59, 16717, 103, 97, 59, 17353, 384, 99, 100, 110, 11712, 11717, 461, 114, 111, 110, 59, 17343, 59, 27062, 112, 102, 59, 49152, 55349, 56672, 384, 97, 101, 108, 11732, 11735, 466, 114, 59, 27063, 114, 112, 59, 27065, 896, 59, 97, 100, 105, 111, 115, 118, 11754, 11755, 11758, 11784, 11789, 11792, 11798, 25128, 114, 242, 6790, 512, 59, 101, 102, 109, 11767, 11768, 11778, 11781, 27229, 114, 256, 59, 111, 11774, 11775, 24884, 102, 187, 11775, 32827, 170, 16554, 32827, 186, 16570, 103, 111, 102, 59, 25270, 114, 59, 27222, 108, 111, 112, 101, 59, 27223, 59, 27227, 384, 99, 108, 111, 11807, 11809, 11815, 242, 11777, 97, 115, 104, 32827, 248, 16632, 108, 59, 25240, 105, 364, 11823, 11828, 100, 101, 32827, 245, 16629, 101, 115, 256, 59, 97, 475, 11834, 115, 59, 27190, 109, 108, 32827, 246, 16630, 98, 97, 114, 59, 25405, 2785, 11870, 0, 11901, 0, 11904, 11933, 0, 11938, 11961, 0, 0, 11979, 3740, 0, 12051, 0, 0, 12075, 12220, 0, 12232, 114, 512, 59, 97, 115, 116, 1027, 11879, 11890, 3717, 33024, 182, 59, 108, 11885, 11886, 16566, 108, 101, 236, 1027, 617, 11896, 0, 0, 11899, 109, 59, 27379, 59, 27389, 121, 59, 17471, 114, 640, 99, 105, 109, 112, 116, 11915, 11919, 11923, 6245, 11927, 110, 116, 59, 16421, 111, 100, 59, 16430, 105, 108, 59, 24624, 101, 110, 107, 59, 24625, 114, 59, 49152, 55349, 56621, 384, 105, 109, 111, 11944, 11952, 11956, 256, 59, 118, 11949, 11950, 17350, 59, 17365, 109, 97, 244, 2678, 110, 101, 59, 26126, 384, 59, 116, 118, 11967, 11968, 11976, 17344, 99, 104, 102, 111, 114, 107, 187, 8189, 59, 17366, 256, 97, 117, 11983, 11999, 110, 256, 99, 107, 11989, 11997, 107, 256, 59, 104, 8692, 11995, 59, 24846, 246, 8692, 115, 1152, 59, 97, 98, 99, 100, 101, 109, 115, 116, 12019, 12020, 6408, 12025, 12029, 12036, 12038, 12042, 12046, 16427, 99, 105, 114, 59, 27171, 105, 114, 59, 27170, 256, 111, 117, 7488, 12034, 59, 27173, 59, 27250, 110, 32955, 177, 3741, 105, 109, 59, 27174, 119, 111, 59, 27175, 384, 105, 112, 117, 12057, 12064, 12069, 110, 116, 105, 110, 116, 59, 27157, 102, 59, 49152, 55349, 56673, 110, 100, 32827, 163, 16547, 1280, 59, 69, 97, 99, 101, 105, 110, 111, 115, 117, 3784, 12095, 12097, 12100, 12103, 12161, 12169, 12178, 12158, 12214, 59, 27315, 112, 59, 27319, 117, 229, 3801, 256, 59, 99, 3790, 12108, 768, 59, 97, 99, 101, 110, 115, 3784, 12121, 12127, 12134, 12136, 12158, 112, 112, 114, 111, 248, 12099, 117, 114, 108, 121, 101, 241, 3801, 241, 3790, 384, 97, 101, 115, 12143, 12150, 12154, 112, 112, 114, 111, 120, 59, 27321, 113, 113, 59, 27317, 105, 109, 59, 25320, 105, 237, 3807, 109, 101, 256, 59, 115, 12168, 3758, 24626, 384, 69, 97, 115, 12152, 12176, 12154, 240, 12149, 384, 100, 102, 112, 3820, 12185, 12207, 384, 97, 108, 115, 12192, 12197, 12202, 108, 97, 114, 59, 25390, 105, 110, 101, 59, 25362, 117, 114, 102, 59, 25363, 256, 59, 116, 3835, 12212, 239, 3835, 114, 101, 108, 59, 25264, 256, 99, 105, 12224, 12229, 114, 59, 49152, 55349, 56517, 59, 17352, 110, 99, 115, 112, 59, 24584, 768, 102, 105, 111, 112, 115, 117, 12250, 8930, 12255, 12261, 12267, 12273, 114, 59, 49152, 55349, 56622, 112, 102, 59, 49152, 55349, 56674, 114, 105, 109, 101, 59, 24663, 99, 114, 59, 49152, 55349, 56518, 384, 97, 101, 111, 12280, 12297, 12307, 116, 256, 101, 105, 12286, 12293, 114, 110, 105, 111, 110, 243, 1712, 110, 116, 59, 27158, 115, 116, 256, 59, 101, 12304, 12305, 16447, 241, 7961, 244, 3860, 2688, 65, 66, 72, 97, 98, 99, 100, 101, 102, 104, 105, 108, 109, 110, 111, 112, 114, 115, 116, 117, 120, 12352, 12369, 12373, 12377, 12512, 12558, 12587, 12615, 12642, 12658, 12686, 12806, 12821, 12836, 12841, 12888, 12910, 12914, 12944, 12976, 12983, 384, 97, 114, 116, 12359, 12362, 12364, 114, 242, 4275, 242, 989, 97, 105, 108, 59, 26908, 97, 114, 242, 7269, 97, 114, 59, 26980, 896, 99, 100, 101, 110, 113, 114, 116, 12392, 12405, 12408, 12415, 12431, 12436, 12492, 256, 101, 117, 12397, 12401, 59, 49152, 8765, 817, 116, 101, 59, 16725, 105, 227, 4462, 109, 112, 116, 121, 118, 59, 27059, 103, 512, 59, 100, 101, 108, 4049, 12425, 12427, 12429, 59, 27026, 59, 27045, 229, 4049, 117, 111, 32827, 187, 16571, 114, 1408, 59, 97, 98, 99, 102, 104, 108, 112, 115, 116, 119, 4060, 12460, 12463, 12471, 12473, 12476, 12478, 12480, 12483, 12487, 12490, 112, 59, 26997, 256, 59, 102, 4064, 12468, 115, 59, 26912, 59, 26931, 115, 59, 26910, 235, 8797, 240, 10030, 108, 59, 26949, 105, 109, 59, 26996, 108, 59, 24995, 59, 24989, 256, 97, 105, 12497, 12501, 105, 108, 59, 26906, 111, 256, 59, 110, 12507, 12508, 25142, 97, 108, 243, 3870, 384, 97, 98, 114, 12519, 12522, 12526, 114, 242, 6117, 114, 107, 59, 26483, 256, 97, 107, 12531, 12541, 99, 256, 101, 107, 12537, 12539, 59, 16509, 59, 16477, 256, 101, 115, 12546, 12548, 59, 27020, 108, 256, 100, 117, 12554, 12556, 59, 27022, 59, 27024, 512, 97, 101, 117, 121, 12567, 12572, 12583, 12585, 114, 111, 110, 59, 16729, 256, 100, 105, 12577, 12581, 105, 108, 59, 16727, 236, 4082, 226, 12538, 59, 17472, 512, 99, 108, 113, 115, 12596, 12599, 12605, 12612, 97, 59, 26935, 100, 104, 97, 114, 59, 26985, 117, 111, 256, 59, 114, 526, 525, 104, 59, 25011, 384, 97, 99, 103, 12622, 12639, 3908, 108, 512, 59, 105, 112, 115, 3960, 12632, 12635, 4252, 110, 229, 4283, 97, 114, 244, 4009, 116, 59, 26029, 384, 105, 108, 114, 12649, 4131, 12654, 115, 104, 116, 59, 27005, 59, 49152, 55349, 56623, 256, 97, 111, 12663, 12678, 114, 256, 100, 117, 12669, 12671, 187, 1147, 256, 59, 108, 4241, 12676, 59, 26988, 256, 59, 118, 12683, 12684, 17345, 59, 17393, 384, 103, 110, 115, 12693, 12793, 12796, 104, 116, 768, 97, 104, 108, 114, 115, 116, 12708, 12720, 12738, 12760, 12772, 12782, 114, 114, 111, 119, 256, 59, 116, 4060, 12717, 97, 233, 12488, 97, 114, 112, 111, 111, 110, 256, 100, 117, 12731, 12735, 111, 119, 238, 12670, 112, 187, 4242, 101, 102, 116, 256, 97, 104, 12746, 12752, 114, 114, 111, 119, 243, 4074, 97, 114, 112, 111, 111, 110, 243, 1361, 105, 103, 104, 116, 97, 114, 114, 111, 119, 115, 59, 25033, 113, 117, 105, 103, 97, 114, 114, 111, 247, 12491, 104, 114, 101, 101, 116, 105, 109, 101, 115, 59, 25292, 103, 59, 17114, 105, 110, 103, 100, 111, 116, 115, 101, 241, 7986, 384, 97, 104, 109, 12813, 12816, 12819, 114, 242, 4074, 97, 242, 1361, 59, 24591, 111, 117, 115, 116, 256, 59, 97, 12830, 12831, 25521, 99, 104, 101, 187, 12831, 109, 105, 100, 59, 27374, 512, 97, 98, 112, 116, 12850, 12861, 12864, 12882, 256, 110, 114, 12855, 12858, 103, 59, 26605, 114, 59, 25086, 114, 235, 4099, 384, 97, 102, 108, 12871, 12874, 12878, 114, 59, 27014, 59, 49152, 55349, 56675, 117, 115, 59, 27182, 105, 109, 101, 115, 59, 27189, 256, 97, 112, 12893, 12903, 114, 256, 59, 103, 12899, 12900, 16425, 116, 59, 27028, 111, 108, 105, 110, 116, 59, 27154, 97, 114, 242, 12771, 512, 97, 99, 104, 113, 12923, 12928, 4284, 12933, 113, 117, 111, 59, 24634, 114, 59, 49152, 55349, 56519, 256, 98, 117, 12539, 12938, 111, 256, 59, 114, 532, 531, 384, 104, 105, 114, 12951, 12955, 12960, 114, 101, 229, 12792, 109, 101, 115, 59, 25290, 105, 512, 59, 101, 102, 108, 12970, 4185, 6177, 12971, 26041, 116, 114, 105, 59, 27086, 108, 117, 104, 97, 114, 59, 26984, 59, 24862, 3425, 13013, 13019, 13023, 13100, 13112, 13169, 0, 13178, 13220, 0, 0, 13292, 13296, 0, 13352, 13384, 13402, 13485, 13489, 13514, 13553, 0, 13846, 0, 0, 13875, 99, 117, 116, 101, 59, 16731, 113, 117, 239, 10170, 1280, 59, 69, 97, 99, 101, 105, 110, 112, 115, 121, 4589, 13043, 13045, 13055, 13058, 13067, 13071, 13087, 13094, 13097, 59, 27316, 496, 13050, 0, 13052, 59, 27320, 111, 110, 59, 16737, 117, 229, 4606, 256, 59, 100, 4595, 13063, 105, 108, 59, 16735, 114, 99, 59, 16733, 384, 69, 97, 115, 13078, 13080, 13083, 59, 27318, 112, 59, 27322, 105, 109, 59, 25321, 111, 108, 105, 110, 116, 59, 27155, 105, 237, 4612, 59, 17473, 111, 116, 384, 59, 98, 101, 13108, 7495, 13109, 25285, 59, 27238, 896, 65, 97, 99, 109, 115, 116, 120, 13126, 13130, 13143, 13147, 13150, 13155, 13165, 114, 114, 59, 25048, 114, 256, 104, 114, 13136, 13138, 235, 8744, 256, 59, 111, 2614, 2612, 116, 32827, 167, 16551, 105, 59, 16443, 119, 97, 114, 59, 26921, 109, 256, 105, 110, 13161, 240, 110, 117, 243, 241, 116, 59, 26422, 114, 256, 59, 111, 13174, 8277, 49152, 55349, 56624, 512, 97, 99, 111, 121, 13186, 13190, 13201, 13216, 114, 112, 59, 26223, 256, 104, 121, 13195, 13199, 99, 121, 59, 17481, 59, 17480, 114, 116, 621, 13209, 0, 0, 13212, 105, 228, 5220, 97, 114, 97, 236, 11887, 32827, 173, 16557, 256, 103, 109, 13224, 13236, 109, 97, 384, 59, 102, 118, 13233, 13234, 13234, 17347, 59, 17346, 1024, 59, 100, 101, 103, 108, 110, 112, 114, 4779, 13253, 13257, 13262, 13270, 13278, 13281, 13286, 111, 116, 59, 27242, 256, 59, 113, 4785, 4784, 256, 59, 69, 13267, 13268, 27294, 59, 27296, 256, 59, 69, 13275, 13276, 27293, 59, 27295, 101, 59, 25158, 108, 117, 115, 59, 27172, 97, 114, 114, 59, 26994, 97, 114, 242, 4413, 512, 97, 101, 105, 116, 13304, 13320, 13327, 13335, 256, 108, 115, 13309, 13316, 108, 115, 101, 116, 109, 233, 13162, 104, 112, 59, 27187, 112, 97, 114, 115, 108, 59, 27108, 256, 100, 108, 5219, 13332, 101, 59, 25379, 256, 59, 101, 13340, 13341, 27306, 256, 59, 115, 13346, 13347, 27308, 59, 49152, 10924, 65024, 384, 102, 108, 112, 13358, 13363, 13378, 116, 99, 121, 59, 17484, 256, 59, 98, 13368, 13369, 16431, 256, 59, 97, 13374, 13375, 27076, 114, 59, 25407, 102, 59, 49152, 55349, 56676, 97, 256, 100, 114, 13389, 1026, 101, 115, 256, 59, 117, 13396, 13397, 26208, 105, 116, 187, 13397, 384, 99, 115, 117, 13408, 13433, 13471, 256, 97, 117, 13413, 13423, 112, 256, 59, 115, 4488, 13419, 59, 49152, 8851, 65024, 112, 256, 59, 115, 4532, 13429, 59, 49152, 8852, 65024, 117, 256, 98, 112, 13439, 13455, 384, 59, 101, 115, 4503, 4508, 13446, 101, 116, 256, 59, 101, 4503, 13453, 241, 4509, 384, 59, 101, 115, 4520, 4525, 13462, 101, 116, 256, 59, 101, 4520, 13469, 241, 4526, 384, 59, 97, 102, 4475, 13478, 1456, 114, 357, 13483, 1457, 187, 4476, 97, 114, 242, 4424, 512, 99, 101, 109, 116, 13497, 13502, 13506, 13509, 114, 59, 49152, 55349, 56520, 116, 109, 238, 241, 105, 236, 13333, 97, 114, 230, 4542, 256, 97, 114, 13518, 13525, 114, 256, 59, 102, 13524, 6079, 26118, 256, 97, 110, 13530, 13549, 105, 103, 104, 116, 256, 101, 112, 13539, 13546, 112, 115, 105, 108, 111, 238, 7904, 104, 233, 11951, 115, 187, 10322, 640, 98, 99, 109, 110, 112, 13563, 13662, 4617, 13707, 13710, 1152, 59, 69, 100, 101, 109, 110, 112, 114, 115, 13582, 13583, 13585, 13589, 13598, 13603, 13612, 13617, 13622, 25218, 59, 27333, 111, 116, 59, 27325, 256, 59, 100, 4570, 13594, 111, 116, 59, 27331, 117, 108, 116, 59, 27329, 256, 69, 101, 13608, 13610, 59, 27339, 59, 25226, 108, 117, 115, 59, 27327, 97, 114, 114, 59, 27001, 384, 101, 105, 117, 13629, 13650, 13653, 116, 384, 59, 101, 110, 13582, 13637, 13643, 113, 256, 59, 113, 4570, 13583, 101, 113, 256, 59, 113, 13611, 13608, 109, 59, 27335, 256, 98, 112, 13658, 13660, 59, 27349, 59, 27347, 99, 768, 59, 97, 99, 101, 110, 115, 4589, 13676, 13682, 13689, 13691, 13094, 112, 112, 114, 111, 248, 13050, 117, 114, 108, 121, 101, 241, 4606, 241, 4595, 384, 97, 101, 115, 13698, 13704, 13083, 112, 112, 114, 111, 248, 13082, 113, 241, 13079, 103, 59, 26218, 1664, 49, 50, 51, 59, 69, 100, 101, 104, 108, 109, 110, 112, 115, 13737, 13740, 13743, 4636, 13746, 13748, 13760, 13769, 13781, 13786, 13791, 13800, 13805, 32827, 185, 16569, 32827, 178, 16562, 32827, 179, 16563, 59, 27334, 256, 111, 115, 13753, 13756, 116, 59, 27326, 117, 98, 59, 27352, 256, 59, 100, 4642, 13765, 111, 116, 59, 27332, 115, 256, 111, 117, 13775, 13778, 108, 59, 26569, 98, 59, 27351, 97, 114, 114, 59, 27003, 117, 108, 116, 59, 27330, 256, 69, 101, 13796, 13798, 59, 27340, 59, 25227, 108, 117, 115, 59, 27328, 384, 101, 105, 117, 13812, 13833, 13836, 116, 384, 59, 101, 110, 4636, 13820, 13826, 113, 256, 59, 113, 4642, 13746, 101, 113, 256, 59, 113, 13799, 13796, 109, 59, 27336, 256, 98, 112, 13841, 13843, 59, 27348, 59, 27350, 384, 65, 97, 110, 13852, 13856, 13869, 114, 114, 59, 25049, 114, 256, 104, 114, 13862, 13864, 235, 8750, 256, 59, 111, 2603, 2601, 119, 97, 114, 59, 26922, 108, 105, 103, 32827, 223, 16607, 3041, 13905, 13917, 13920, 4814, 13939, 13945, 0, 13950, 14018, 0, 0, 0, 0, 0, 14043, 14083, 0, 14089, 14188, 0, 0, 0, 14215, 626, 13910, 0, 0, 13915, 103, 101, 116, 59, 25366, 59, 17348, 114, 235, 3679, 384, 97, 101, 121, 13926, 13931, 13936, 114, 111, 110, 59, 16741, 100, 105, 108, 59, 16739, 59, 17474, 108, 114, 101, 99, 59, 25365, 114, 59, 49152, 55349, 56625, 512, 101, 105, 107, 111, 13958, 13981, 14005, 14012, 498, 13963, 0, 13969, 101, 256, 52, 102, 4740, 4737, 97, 384, 59, 115, 118, 13976, 13977, 13979, 17336, 121, 109, 59, 17361, 256, 99, 110, 13986, 14002, 107, 256, 97, 115, 13992, 13998, 112, 112, 114, 111, 248, 4801, 105, 109, 187, 4780, 115, 240, 4766, 256, 97, 115, 14010, 13998, 240, 4801, 114, 110, 32827, 254, 16638, 492, 799, 14022, 8935, 101, 115, 33152, 215, 59, 98, 100, 14031, 14032, 14040, 16599, 256, 59, 97, 6415, 14037, 114, 59, 27185, 59, 27184, 384, 101, 112, 115, 14049, 14051, 14080, 225, 10829, 512, 59, 98, 99, 102, 1158, 14060, 14064, 14068, 111, 116, 59, 25398, 105, 114, 59, 27377, 256, 59, 111, 14073, 14076, 49152, 55349, 56677, 114, 107, 59, 27354, 225, 13154, 114, 105, 109, 101, 59, 24628, 384, 97, 105, 112, 14095, 14098, 14180, 100, 229, 4680, 896, 97, 100, 101, 109, 112, 115, 116, 14113, 14157, 14144, 14161, 14167, 14172, 14175, 110, 103, 108, 101, 640, 59, 100, 108, 113, 114, 14128, 14129, 14134, 14144, 14146, 26037, 111, 119, 110, 187, 7611, 101, 102, 116, 256, 59, 101, 10240, 14142, 241, 2350, 59, 25180, 105, 103, 104, 116, 256, 59, 101, 12970, 14155, 241, 4186, 111, 116, 59, 26092, 105, 110, 117, 115, 59, 27194, 108, 117, 115, 59, 27193, 98, 59, 27085, 105, 109, 101, 59, 27195, 101, 122, 105, 117, 109, 59, 25570, 384, 99, 104, 116, 14194, 14205, 14209, 256, 114, 121, 14199, 14203, 59, 49152, 55349, 56521, 59, 17478, 99, 121, 59, 17499, 114, 111, 107, 59, 16743, 256, 105, 111, 14219, 14222, 120, 244, 6007, 104, 101, 97, 100, 256, 108, 114, 14231, 14240, 101, 102, 116, 97, 114, 114, 111, 247, 2127, 105, 103, 104, 116, 97, 114, 114, 111, 119, 187, 3933, 2304, 65, 72, 97, 98, 99, 100, 102, 103, 104, 108, 109, 111, 112, 114, 115, 116, 117, 119, 14288, 14291, 14295, 14308, 14320, 14332, 14350, 14364, 14371, 14388, 14417, 14429, 14443, 14505, 14540, 14546, 14570, 14582, 114, 242, 1005, 97, 114, 59, 26979, 256, 99, 114, 14300, 14306, 117, 116, 101, 32827, 250, 16634, 242, 4432, 114, 483, 14314, 0, 14317, 121, 59, 17502, 118, 101, 59, 16749, 256, 105, 121, 14325, 14330, 114, 99, 32827, 251, 16635, 59, 17475, 384, 97, 98, 104, 14339, 14342, 14347, 114, 242, 5037, 108, 97, 99, 59, 16753, 97, 242, 5059, 256, 105, 114, 14355, 14360, 115, 104, 116, 59, 27006, 59, 49152, 55349, 56626, 114, 97, 118, 101, 32827, 249, 16633, 353, 14375, 14385, 114, 256, 108, 114, 14380, 14382, 187, 2391, 187, 4227, 108, 107, 59, 25984, 256, 99, 116, 14393, 14413, 623, 14399, 0, 0, 14410, 114, 110, 256, 59, 101, 14405, 14406, 25372, 114, 187, 14406, 111, 112, 59, 25359, 114, 105, 59, 26104, 256, 97, 108, 14422, 14426, 99, 114, 59, 16747, 32955, 168, 841, 256, 103, 112, 14434, 14438, 111, 110, 59, 16755, 102, 59, 49152, 55349, 56678, 768, 97, 100, 104, 108, 115, 117, 4427, 14456, 14461, 4978, 14481, 14496, 111, 119, 110, 225, 5043, 97, 114, 112, 111, 111, 110, 256, 108, 114, 14472, 14476, 101, 102, 244, 14381, 105, 103, 104, 244, 14383, 105, 384, 59, 104, 108, 14489, 14490, 14492, 17349, 187, 5114, 111, 110, 187, 14490, 112, 97, 114, 114, 111, 119, 115, 59, 25032, 384, 99, 105, 116, 14512, 14532, 14536, 623, 14518, 0, 0, 14529, 114, 110, 256, 59, 101, 14524, 14525, 25373, 114, 187, 14525, 111, 112, 59, 25358, 110, 103, 59, 16751, 114, 105, 59, 26105, 99, 114, 59, 49152, 55349, 56522, 384, 100, 105, 114, 14553, 14557, 14562, 111, 116, 59, 25328, 108, 100, 101, 59, 16745, 105, 256, 59, 102, 14128, 14568, 187, 6163, 256, 97, 109, 14575, 14578, 114, 242, 14504, 108, 32827, 252, 16636, 97, 110, 103, 108, 101, 59, 27047, 1920, 65, 66, 68, 97, 99, 100, 101, 102, 108, 110, 111, 112, 114, 115, 122, 14620, 14623, 14633, 14637, 14773, 14776, 14781, 14815, 14820, 14824, 14835, 14841, 14845, 14849, 14880, 114, 242, 1015, 97, 114, 256, 59, 118, 14630, 14631, 27368, 59, 27369, 97, 115, 232, 993, 256, 110, 114, 14642, 14647, 103, 114, 116, 59, 27036, 896, 101, 107, 110, 112, 114, 115, 116, 13539, 14662, 14667, 14674, 14685, 14692, 14742, 97, 112, 112, 225, 9237, 111, 116, 104, 105, 110, 231, 7830, 384, 104, 105, 114, 13547, 11976, 14681, 111, 112, 244, 12213, 256, 59, 104, 5047, 14690, 239, 12685, 256, 105, 117, 14697, 14701, 103, 109, 225, 13235, 256, 98, 112, 14706, 14724, 115, 101, 116, 110, 101, 113, 256, 59, 113, 14717, 14720, 49152, 8842, 65024, 59, 49152, 10955, 65024, 115, 101, 116, 110, 101, 113, 256, 59, 113, 14735, 14738, 49152, 8843, 65024, 59, 49152, 10956, 65024, 256, 104, 114, 14747, 14751, 101, 116, 225, 13980, 105, 97, 110, 103, 108, 101, 256, 108, 114, 14762, 14767, 101, 102, 116, 187, 2341, 105, 103, 104, 116, 187, 4177, 121, 59, 17458, 97, 115, 104, 187, 4150, 384, 101, 108, 114, 14788, 14802, 14807, 384, 59, 98, 101, 11754, 14795, 14799, 97, 114, 59, 25275, 113, 59, 25178, 108, 105, 112, 59, 25326, 256, 98, 116, 14812, 5224, 97, 242, 5225, 114, 59, 49152, 55349, 56627, 116, 114, 233, 14766, 115, 117, 256, 98, 112, 14831, 14833, 187, 3356, 187, 3417, 112, 102, 59, 49152, 55349, 56679, 114, 111, 240, 3835, 116, 114, 233, 14772, 256, 99, 117, 14854, 14859, 114, 59, 49152, 55349, 56523, 256, 98, 112, 14864, 14872, 110, 256, 69, 101, 14720, 14870, 187, 14718, 110, 256, 69, 101, 14738, 14878, 187, 14736, 105, 103, 122, 97, 103, 59, 27034, 896, 99, 101, 102, 111, 112, 114, 115, 14902, 14907, 14934, 14939, 14932, 14945, 14954, 105, 114, 99, 59, 16757, 256, 100, 105, 14912, 14929, 256, 98, 103, 14917, 14921, 97, 114, 59, 27231, 101, 256, 59, 113, 5626, 14927, 59, 25177, 101, 114, 112, 59, 24856, 114, 59, 49152, 55349, 56628, 112, 102, 59, 49152, 55349, 56680, 256, 59, 101, 5241, 14950, 97, 116, 232, 5241, 99, 114, 59, 49152, 55349, 56524, 2787, 6030, 14983, 0, 14987, 0, 14992, 15003, 0, 0, 15005, 15016, 15019, 15023, 0, 0, 15043, 15054, 0, 15064, 6108, 6111, 116, 114, 233, 6097, 114, 59, 49152, 55349, 56629, 256, 65, 97, 14996, 14999, 114, 242, 963, 114, 242, 2550, 59, 17342, 256, 65, 97, 15009, 15012, 114, 242, 952, 114, 242, 2539, 97, 240, 10003, 105, 115, 59, 25339, 384, 100, 112, 116, 6052, 15029, 15038, 256, 102, 108, 15034, 6057, 59, 49152, 55349, 56681, 105, 109, 229, 6066, 256, 65, 97, 15047, 15050, 114, 242, 974, 114, 242, 2561, 256, 99, 113, 15058, 6072, 114, 59, 49152, 55349, 56525, 256, 112, 116, 6102, 15068, 114, 233, 6100, 1024, 97, 99, 101, 102, 105, 111, 115, 117, 15088, 15101, 15112, 15116, 15121, 15125, 15131, 15137, 99, 256, 117, 121, 15094, 15099, 116, 101, 32827, 253, 16637, 59, 17487, 256, 105, 121, 15106, 15110, 114, 99, 59, 16759, 59, 17483, 110, 32827, 165, 16549, 114, 59, 49152, 55349, 56630, 99, 121, 59, 17495, 112, 102, 59, 49152, 55349, 56682, 99, 114, 59, 49152, 55349, 56526, 256, 99, 109, 15142, 15145, 121, 59, 17486, 108, 32827, 255, 16639, 1280, 97, 99, 100, 101, 102, 104, 105, 111, 115, 119, 15170, 15176, 15188, 15192, 15204, 15209, 15213, 15220, 15226, 15232, 99, 117, 116, 101, 59, 16762, 256, 97, 121, 15181, 15186, 114, 111, 110, 59, 16766, 59, 17463, 111, 116, 59, 16764, 256, 101, 116, 15197, 15201, 116, 114, 230, 5471, 97, 59, 17334, 114, 59, 49152, 55349, 56631, 99, 121, 59, 17462, 103, 114, 97, 114, 114, 59, 25053, 112, 102, 59, 49152, 55349, 56683, 99, 114, 59, 49152, 55349, 56527, 256, 106, 110, 15237, 15239, 59, 24589, 106, 59, 24588]);
  66533. });
  66534. unwrapExports(decodeDataHtml);
  66535. var decodeDataXml = createCommonjsModule(function (module, exports) {
  66536. Object.defineProperty(exports, "__esModule", { value: true });
  66537. // Generated using scripts/write-decode-map.ts
  66538. // prettier-ignore
  66539. exports.default = new Uint16Array([512, 97, 103, 108, 113, 9, 21, 24, 27, 621, 15, 0, 0, 18, 112, 59, 16422, 111, 115, 59, 16423, 116, 59, 16446, 116, 59, 16444, 117, 111, 116, 59, 16418]);
  66540. });
  66541. unwrapExports(decodeDataXml);
  66542. var decode_codepoint = createCommonjsModule(function (module, exports) {
  66543. // Adapted from https://github.com/mathiasbynens/he/blob/36afe179392226cf1b6ccdb16ebbb7a5a844d93a/src/he.js#L106-L134
  66544. var _a;
  66545. Object.defineProperty(exports, "__esModule", { value: true });
  66546. exports.replaceCodePoint = exports.fromCodePoint = void 0;
  66547. var decodeMap = new Map([
  66548. [0, 65533],
  66549. [128, 8364],
  66550. [130, 8218],
  66551. [131, 402],
  66552. [132, 8222],
  66553. [133, 8230],
  66554. [134, 8224],
  66555. [135, 8225],
  66556. [136, 710],
  66557. [137, 8240],
  66558. [138, 352],
  66559. [139, 8249],
  66560. [140, 338],
  66561. [142, 381],
  66562. [145, 8216],
  66563. [146, 8217],
  66564. [147, 8220],
  66565. [148, 8221],
  66566. [149, 8226],
  66567. [150, 8211],
  66568. [151, 8212],
  66569. [152, 732],
  66570. [153, 8482],
  66571. [154, 353],
  66572. [155, 8250],
  66573. [156, 339],
  66574. [158, 382],
  66575. [159, 376],
  66576. ]);
  66577. exports.fromCodePoint =
  66578. // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, node/no-unsupported-features/es-builtins
  66579. (_a = String.fromCodePoint) !== null && _a !== void 0 ? _a : function (codePoint) {
  66580. var output = "";
  66581. if (codePoint > 0xffff) {
  66582. codePoint -= 0x10000;
  66583. output += String.fromCharCode(((codePoint >>> 10) & 0x3ff) | 0xd800);
  66584. codePoint = 0xdc00 | (codePoint & 0x3ff);
  66585. }
  66586. output += String.fromCharCode(codePoint);
  66587. return output;
  66588. };
  66589. function replaceCodePoint(codePoint) {
  66590. var _a;
  66591. if ((codePoint >= 0xd800 && codePoint <= 0xdfff) || codePoint > 0x10ffff) {
  66592. return 0xfffd;
  66593. }
  66594. return (_a = decodeMap.get(codePoint)) !== null && _a !== void 0 ? _a : codePoint;
  66595. }
  66596. exports.replaceCodePoint = replaceCodePoint;
  66597. function decodeCodePoint(codePoint) {
  66598. return (0, exports.fromCodePoint)(replaceCodePoint(codePoint));
  66599. }
  66600. exports.default = decodeCodePoint;
  66601. });
  66602. unwrapExports(decode_codepoint);
  66603. var decode_codepoint_1 = decode_codepoint.replaceCodePoint;
  66604. var decode_codepoint_2 = decode_codepoint.fromCodePoint;
  66605. var decode = createCommonjsModule(function (module, exports) {
  66606. var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
  66607. return (mod && mod.__esModule) ? mod : { "default": mod };
  66608. };
  66609. Object.defineProperty(exports, "__esModule", { value: true });
  66610. exports.decodeXML = exports.decodeHTMLStrict = exports.decodeHTML = exports.determineBranch = exports.BinTrieFlags = exports.fromCodePoint = exports.replaceCodePoint = exports.decodeCodePoint = exports.xmlDecodeTree = exports.htmlDecodeTree = void 0;
  66611. var decode_data_html_js_1 = __importDefault(decodeDataHtml);
  66612. exports.htmlDecodeTree = decode_data_html_js_1.default;
  66613. var decode_data_xml_js_1 = __importDefault(decodeDataXml);
  66614. exports.xmlDecodeTree = decode_data_xml_js_1.default;
  66615. var decode_codepoint_js_1 = __importDefault(decode_codepoint);
  66616. exports.decodeCodePoint = decode_codepoint_js_1.default;
  66617. var decode_codepoint_js_2 = decode_codepoint;
  66618. Object.defineProperty(exports, "replaceCodePoint", { enumerable: true, get: function () { return decode_codepoint_js_2.replaceCodePoint; } });
  66619. Object.defineProperty(exports, "fromCodePoint", { enumerable: true, get: function () { return decode_codepoint_js_2.fromCodePoint; } });
  66620. var CharCodes;
  66621. (function (CharCodes) {
  66622. CharCodes[CharCodes["NUM"] = 35] = "NUM";
  66623. CharCodes[CharCodes["SEMI"] = 59] = "SEMI";
  66624. CharCodes[CharCodes["ZERO"] = 48] = "ZERO";
  66625. CharCodes[CharCodes["NINE"] = 57] = "NINE";
  66626. CharCodes[CharCodes["LOWER_A"] = 97] = "LOWER_A";
  66627. CharCodes[CharCodes["LOWER_F"] = 102] = "LOWER_F";
  66628. CharCodes[CharCodes["LOWER_X"] = 120] = "LOWER_X";
  66629. /** Bit that needs to be set to convert an upper case ASCII character to lower case */
  66630. CharCodes[CharCodes["To_LOWER_BIT"] = 32] = "To_LOWER_BIT";
  66631. })(CharCodes || (CharCodes = {}));
  66632. var BinTrieFlags;
  66633. (function (BinTrieFlags) {
  66634. BinTrieFlags[BinTrieFlags["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
  66635. BinTrieFlags[BinTrieFlags["BRANCH_LENGTH"] = 16256] = "BRANCH_LENGTH";
  66636. BinTrieFlags[BinTrieFlags["JUMP_TABLE"] = 127] = "JUMP_TABLE";
  66637. })(BinTrieFlags = exports.BinTrieFlags || (exports.BinTrieFlags = {}));
  66638. function getDecoder(decodeTree) {
  66639. return function decodeHTMLBinary(str, strict) {
  66640. var ret = "";
  66641. var lastIdx = 0;
  66642. var strIdx = 0;
  66643. while ((strIdx = str.indexOf("&", strIdx)) >= 0) {
  66644. ret += str.slice(lastIdx, strIdx);
  66645. lastIdx = strIdx;
  66646. // Skip the "&"
  66647. strIdx += 1;
  66648. // If we have a numeric entity, handle this separately.
  66649. if (str.charCodeAt(strIdx) === CharCodes.NUM) {
  66650. // Skip the leading "&#". For hex entities, also skip the leading "x".
  66651. var start = strIdx + 1;
  66652. var base = 10;
  66653. var cp = str.charCodeAt(start);
  66654. if ((cp | CharCodes.To_LOWER_BIT) === CharCodes.LOWER_X) {
  66655. base = 16;
  66656. strIdx += 1;
  66657. start += 1;
  66658. }
  66659. do
  66660. cp = str.charCodeAt(++strIdx);
  66661. while ((cp >= CharCodes.ZERO && cp <= CharCodes.NINE) ||
  66662. (base === 16 &&
  66663. (cp | CharCodes.To_LOWER_BIT) >= CharCodes.LOWER_A &&
  66664. (cp | CharCodes.To_LOWER_BIT) <= CharCodes.LOWER_F));
  66665. if (start !== strIdx) {
  66666. var entity = str.substring(start, strIdx);
  66667. var parsed = parseInt(entity, base);
  66668. if (str.charCodeAt(strIdx) === CharCodes.SEMI) {
  66669. strIdx += 1;
  66670. }
  66671. else if (strict) {
  66672. continue;
  66673. }
  66674. ret += (0, decode_codepoint_js_1.default)(parsed);
  66675. lastIdx = strIdx;
  66676. }
  66677. continue;
  66678. }
  66679. var resultIdx = 0;
  66680. var excess = 1;
  66681. var treeIdx = 0;
  66682. var current = decodeTree[treeIdx];
  66683. for (; strIdx < str.length; strIdx++, excess++) {
  66684. treeIdx = determineBranch(decodeTree, current, treeIdx + 1, str.charCodeAt(strIdx));
  66685. if (treeIdx < 0)
  66686. break;
  66687. current = decodeTree[treeIdx];
  66688. var masked = current & BinTrieFlags.VALUE_LENGTH;
  66689. // If the branch is a value, store it and continue
  66690. if (masked) {
  66691. // If we have a legacy entity while parsing strictly, just skip the number of bytes
  66692. if (!strict || str.charCodeAt(strIdx) === CharCodes.SEMI) {
  66693. resultIdx = treeIdx;
  66694. excess = 0;
  66695. }
  66696. // The mask is the number of bytes of the value, including the current byte.
  66697. var valueLength = (masked >> 14) - 1;
  66698. if (valueLength === 0)
  66699. break;
  66700. treeIdx += valueLength;
  66701. }
  66702. }
  66703. if (resultIdx !== 0) {
  66704. var valueLength = (decodeTree[resultIdx] & BinTrieFlags.VALUE_LENGTH) >> 14;
  66705. ret +=
  66706. valueLength === 1
  66707. ? String.fromCharCode(decodeTree[resultIdx] & ~BinTrieFlags.VALUE_LENGTH)
  66708. : valueLength === 2
  66709. ? String.fromCharCode(decodeTree[resultIdx + 1])
  66710. : String.fromCharCode(decodeTree[resultIdx + 1], decodeTree[resultIdx + 2]);
  66711. lastIdx = strIdx - excess + 1;
  66712. }
  66713. }
  66714. return ret + str.slice(lastIdx);
  66715. };
  66716. }
  66717. function determineBranch(decodeTree, current, nodeIdx, char) {
  66718. var branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
  66719. var jumpOffset = current & BinTrieFlags.JUMP_TABLE;
  66720. // Case 1: Single branch encoded in jump offset
  66721. if (branchCount === 0) {
  66722. return jumpOffset !== 0 && char === jumpOffset ? nodeIdx : -1;
  66723. }
  66724. // Case 2: Multiple branches encoded in jump table
  66725. if (jumpOffset) {
  66726. var value = char - jumpOffset;
  66727. return value < 0 || value > branchCount
  66728. ? -1
  66729. : decodeTree[nodeIdx + value] - 1;
  66730. }
  66731. // Case 3: Multiple branches encoded in dictionary
  66732. // Binary search for the character.
  66733. var lo = nodeIdx;
  66734. var hi = lo + branchCount - 1;
  66735. while (lo <= hi) {
  66736. var mid = (lo + hi) >>> 1;
  66737. var midVal = decodeTree[mid];
  66738. if (midVal < char) {
  66739. lo = mid + 1;
  66740. }
  66741. else if (midVal > char) {
  66742. hi = mid - 1;
  66743. }
  66744. else {
  66745. return decodeTree[mid + branchCount];
  66746. }
  66747. }
  66748. return -1;
  66749. }
  66750. exports.determineBranch = determineBranch;
  66751. var htmlDecoder = getDecoder(decode_data_html_js_1.default);
  66752. var xmlDecoder = getDecoder(decode_data_xml_js_1.default);
  66753. function decodeHTML(str) {
  66754. return htmlDecoder(str, false);
  66755. }
  66756. exports.decodeHTML = decodeHTML;
  66757. function decodeHTMLStrict(str) {
  66758. return htmlDecoder(str, true);
  66759. }
  66760. exports.decodeHTMLStrict = decodeHTMLStrict;
  66761. function decodeXML(str) {
  66762. return xmlDecoder(str, true);
  66763. }
  66764. exports.decodeXML = decodeXML;
  66765. });
  66766. unwrapExports(decode);
  66767. var decode_1 = decode.decodeXML;
  66768. var decode_2 = decode.decodeHTMLStrict;
  66769. var decode_3 = decode.decodeHTML;
  66770. var decode_4 = decode.determineBranch;
  66771. var decode_5 = decode.BinTrieFlags;
  66772. var decode_6 = decode.fromCodePoint;
  66773. var decode_7 = decode.replaceCodePoint;
  66774. var decode_8 = decode.decodeCodePoint;
  66775. var decode_9 = decode.xmlDecodeTree;
  66776. var decode_10 = decode.htmlDecodeTree;
  66777. /** All valid namespaces in HTML. */
  66778. var NS;
  66779. (function (NS) {
  66780. NS["HTML"] = "http://www.w3.org/1999/xhtml";
  66781. NS["MATHML"] = "http://www.w3.org/1998/Math/MathML";
  66782. NS["SVG"] = "http://www.w3.org/2000/svg";
  66783. NS["XLINK"] = "http://www.w3.org/1999/xlink";
  66784. NS["XML"] = "http://www.w3.org/XML/1998/namespace";
  66785. NS["XMLNS"] = "http://www.w3.org/2000/xmlns/";
  66786. })(NS || (NS = {}));
  66787. var ATTRS;
  66788. (function (ATTRS) {
  66789. ATTRS["TYPE"] = "type";
  66790. ATTRS["ACTION"] = "action";
  66791. ATTRS["ENCODING"] = "encoding";
  66792. ATTRS["PROMPT"] = "prompt";
  66793. ATTRS["NAME"] = "name";
  66794. ATTRS["COLOR"] = "color";
  66795. ATTRS["FACE"] = "face";
  66796. ATTRS["SIZE"] = "size";
  66797. })(ATTRS || (ATTRS = {}));
  66798. /**
  66799. * The mode of the document.
  66800. *
  66801. * @see {@link https://dom.spec.whatwg.org/#concept-document-limited-quirks}
  66802. */
  66803. var DOCUMENT_MODE;
  66804. (function (DOCUMENT_MODE) {
  66805. DOCUMENT_MODE["NO_QUIRKS"] = "no-quirks";
  66806. DOCUMENT_MODE["QUIRKS"] = "quirks";
  66807. DOCUMENT_MODE["LIMITED_QUIRKS"] = "limited-quirks";
  66808. })(DOCUMENT_MODE || (DOCUMENT_MODE = {}));
  66809. var TAG_NAMES;
  66810. (function (TAG_NAMES) {
  66811. TAG_NAMES["A"] = "a";
  66812. TAG_NAMES["ADDRESS"] = "address";
  66813. TAG_NAMES["ANNOTATION_XML"] = "annotation-xml";
  66814. TAG_NAMES["APPLET"] = "applet";
  66815. TAG_NAMES["AREA"] = "area";
  66816. TAG_NAMES["ARTICLE"] = "article";
  66817. TAG_NAMES["ASIDE"] = "aside";
  66818. TAG_NAMES["B"] = "b";
  66819. TAG_NAMES["BASE"] = "base";
  66820. TAG_NAMES["BASEFONT"] = "basefont";
  66821. TAG_NAMES["BGSOUND"] = "bgsound";
  66822. TAG_NAMES["BIG"] = "big";
  66823. TAG_NAMES["BLOCKQUOTE"] = "blockquote";
  66824. TAG_NAMES["BODY"] = "body";
  66825. TAG_NAMES["BR"] = "br";
  66826. TAG_NAMES["BUTTON"] = "button";
  66827. TAG_NAMES["CAPTION"] = "caption";
  66828. TAG_NAMES["CENTER"] = "center";
  66829. TAG_NAMES["CODE"] = "code";
  66830. TAG_NAMES["COL"] = "col";
  66831. TAG_NAMES["COLGROUP"] = "colgroup";
  66832. TAG_NAMES["DD"] = "dd";
  66833. TAG_NAMES["DESC"] = "desc";
  66834. TAG_NAMES["DETAILS"] = "details";
  66835. TAG_NAMES["DIALOG"] = "dialog";
  66836. TAG_NAMES["DIR"] = "dir";
  66837. TAG_NAMES["DIV"] = "div";
  66838. TAG_NAMES["DL"] = "dl";
  66839. TAG_NAMES["DT"] = "dt";
  66840. TAG_NAMES["EM"] = "em";
  66841. TAG_NAMES["EMBED"] = "embed";
  66842. TAG_NAMES["FIELDSET"] = "fieldset";
  66843. TAG_NAMES["FIGCAPTION"] = "figcaption";
  66844. TAG_NAMES["FIGURE"] = "figure";
  66845. TAG_NAMES["FONT"] = "font";
  66846. TAG_NAMES["FOOTER"] = "footer";
  66847. TAG_NAMES["FOREIGN_OBJECT"] = "foreignObject";
  66848. TAG_NAMES["FORM"] = "form";
  66849. TAG_NAMES["FRAME"] = "frame";
  66850. TAG_NAMES["FRAMESET"] = "frameset";
  66851. TAG_NAMES["H1"] = "h1";
  66852. TAG_NAMES["H2"] = "h2";
  66853. TAG_NAMES["H3"] = "h3";
  66854. TAG_NAMES["H4"] = "h4";
  66855. TAG_NAMES["H5"] = "h5";
  66856. TAG_NAMES["H6"] = "h6";
  66857. TAG_NAMES["HEAD"] = "head";
  66858. TAG_NAMES["HEADER"] = "header";
  66859. TAG_NAMES["HGROUP"] = "hgroup";
  66860. TAG_NAMES["HR"] = "hr";
  66861. TAG_NAMES["HTML"] = "html";
  66862. TAG_NAMES["I"] = "i";
  66863. TAG_NAMES["IMG"] = "img";
  66864. TAG_NAMES["IMAGE"] = "image";
  66865. TAG_NAMES["INPUT"] = "input";
  66866. TAG_NAMES["IFRAME"] = "iframe";
  66867. TAG_NAMES["KEYGEN"] = "keygen";
  66868. TAG_NAMES["LABEL"] = "label";
  66869. TAG_NAMES["LI"] = "li";
  66870. TAG_NAMES["LINK"] = "link";
  66871. TAG_NAMES["LISTING"] = "listing";
  66872. TAG_NAMES["MAIN"] = "main";
  66873. TAG_NAMES["MALIGNMARK"] = "malignmark";
  66874. TAG_NAMES["MARQUEE"] = "marquee";
  66875. TAG_NAMES["MATH"] = "math";
  66876. TAG_NAMES["MENU"] = "menu";
  66877. TAG_NAMES["META"] = "meta";
  66878. TAG_NAMES["MGLYPH"] = "mglyph";
  66879. TAG_NAMES["MI"] = "mi";
  66880. TAG_NAMES["MO"] = "mo";
  66881. TAG_NAMES["MN"] = "mn";
  66882. TAG_NAMES["MS"] = "ms";
  66883. TAG_NAMES["MTEXT"] = "mtext";
  66884. TAG_NAMES["NAV"] = "nav";
  66885. TAG_NAMES["NOBR"] = "nobr";
  66886. TAG_NAMES["NOFRAMES"] = "noframes";
  66887. TAG_NAMES["NOEMBED"] = "noembed";
  66888. TAG_NAMES["NOSCRIPT"] = "noscript";
  66889. TAG_NAMES["OBJECT"] = "object";
  66890. TAG_NAMES["OL"] = "ol";
  66891. TAG_NAMES["OPTGROUP"] = "optgroup";
  66892. TAG_NAMES["OPTION"] = "option";
  66893. TAG_NAMES["P"] = "p";
  66894. TAG_NAMES["PARAM"] = "param";
  66895. TAG_NAMES["PLAINTEXT"] = "plaintext";
  66896. TAG_NAMES["PRE"] = "pre";
  66897. TAG_NAMES["RB"] = "rb";
  66898. TAG_NAMES["RP"] = "rp";
  66899. TAG_NAMES["RT"] = "rt";
  66900. TAG_NAMES["RTC"] = "rtc";
  66901. TAG_NAMES["RUBY"] = "ruby";
  66902. TAG_NAMES["S"] = "s";
  66903. TAG_NAMES["SCRIPT"] = "script";
  66904. TAG_NAMES["SECTION"] = "section";
  66905. TAG_NAMES["SELECT"] = "select";
  66906. TAG_NAMES["SOURCE"] = "source";
  66907. TAG_NAMES["SMALL"] = "small";
  66908. TAG_NAMES["SPAN"] = "span";
  66909. TAG_NAMES["STRIKE"] = "strike";
  66910. TAG_NAMES["STRONG"] = "strong";
  66911. TAG_NAMES["STYLE"] = "style";
  66912. TAG_NAMES["SUB"] = "sub";
  66913. TAG_NAMES["SUMMARY"] = "summary";
  66914. TAG_NAMES["SUP"] = "sup";
  66915. TAG_NAMES["TABLE"] = "table";
  66916. TAG_NAMES["TBODY"] = "tbody";
  66917. TAG_NAMES["TEMPLATE"] = "template";
  66918. TAG_NAMES["TEXTAREA"] = "textarea";
  66919. TAG_NAMES["TFOOT"] = "tfoot";
  66920. TAG_NAMES["TD"] = "td";
  66921. TAG_NAMES["TH"] = "th";
  66922. TAG_NAMES["THEAD"] = "thead";
  66923. TAG_NAMES["TITLE"] = "title";
  66924. TAG_NAMES["TR"] = "tr";
  66925. TAG_NAMES["TRACK"] = "track";
  66926. TAG_NAMES["TT"] = "tt";
  66927. TAG_NAMES["U"] = "u";
  66928. TAG_NAMES["UL"] = "ul";
  66929. TAG_NAMES["SVG"] = "svg";
  66930. TAG_NAMES["VAR"] = "var";
  66931. TAG_NAMES["WBR"] = "wbr";
  66932. TAG_NAMES["XMP"] = "xmp";
  66933. })(TAG_NAMES || (TAG_NAMES = {}));
  66934. /**
  66935. * Tag IDs are numeric IDs for known tag names.
  66936. *
  66937. * We use tag IDs to improve the performance of tag name comparisons.
  66938. */
  66939. var TAG_ID;
  66940. (function (TAG_ID) {
  66941. TAG_ID[TAG_ID["UNKNOWN"] = 0] = "UNKNOWN";
  66942. TAG_ID[TAG_ID["A"] = 1] = "A";
  66943. TAG_ID[TAG_ID["ADDRESS"] = 2] = "ADDRESS";
  66944. TAG_ID[TAG_ID["ANNOTATION_XML"] = 3] = "ANNOTATION_XML";
  66945. TAG_ID[TAG_ID["APPLET"] = 4] = "APPLET";
  66946. TAG_ID[TAG_ID["AREA"] = 5] = "AREA";
  66947. TAG_ID[TAG_ID["ARTICLE"] = 6] = "ARTICLE";
  66948. TAG_ID[TAG_ID["ASIDE"] = 7] = "ASIDE";
  66949. TAG_ID[TAG_ID["B"] = 8] = "B";
  66950. TAG_ID[TAG_ID["BASE"] = 9] = "BASE";
  66951. TAG_ID[TAG_ID["BASEFONT"] = 10] = "BASEFONT";
  66952. TAG_ID[TAG_ID["BGSOUND"] = 11] = "BGSOUND";
  66953. TAG_ID[TAG_ID["BIG"] = 12] = "BIG";
  66954. TAG_ID[TAG_ID["BLOCKQUOTE"] = 13] = "BLOCKQUOTE";
  66955. TAG_ID[TAG_ID["BODY"] = 14] = "BODY";
  66956. TAG_ID[TAG_ID["BR"] = 15] = "BR";
  66957. TAG_ID[TAG_ID["BUTTON"] = 16] = "BUTTON";
  66958. TAG_ID[TAG_ID["CAPTION"] = 17] = "CAPTION";
  66959. TAG_ID[TAG_ID["CENTER"] = 18] = "CENTER";
  66960. TAG_ID[TAG_ID["CODE"] = 19] = "CODE";
  66961. TAG_ID[TAG_ID["COL"] = 20] = "COL";
  66962. TAG_ID[TAG_ID["COLGROUP"] = 21] = "COLGROUP";
  66963. TAG_ID[TAG_ID["DD"] = 22] = "DD";
  66964. TAG_ID[TAG_ID["DESC"] = 23] = "DESC";
  66965. TAG_ID[TAG_ID["DETAILS"] = 24] = "DETAILS";
  66966. TAG_ID[TAG_ID["DIALOG"] = 25] = "DIALOG";
  66967. TAG_ID[TAG_ID["DIR"] = 26] = "DIR";
  66968. TAG_ID[TAG_ID["DIV"] = 27] = "DIV";
  66969. TAG_ID[TAG_ID["DL"] = 28] = "DL";
  66970. TAG_ID[TAG_ID["DT"] = 29] = "DT";
  66971. TAG_ID[TAG_ID["EM"] = 30] = "EM";
  66972. TAG_ID[TAG_ID["EMBED"] = 31] = "EMBED";
  66973. TAG_ID[TAG_ID["FIELDSET"] = 32] = "FIELDSET";
  66974. TAG_ID[TAG_ID["FIGCAPTION"] = 33] = "FIGCAPTION";
  66975. TAG_ID[TAG_ID["FIGURE"] = 34] = "FIGURE";
  66976. TAG_ID[TAG_ID["FONT"] = 35] = "FONT";
  66977. TAG_ID[TAG_ID["FOOTER"] = 36] = "FOOTER";
  66978. TAG_ID[TAG_ID["FOREIGN_OBJECT"] = 37] = "FOREIGN_OBJECT";
  66979. TAG_ID[TAG_ID["FORM"] = 38] = "FORM";
  66980. TAG_ID[TAG_ID["FRAME"] = 39] = "FRAME";
  66981. TAG_ID[TAG_ID["FRAMESET"] = 40] = "FRAMESET";
  66982. TAG_ID[TAG_ID["H1"] = 41] = "H1";
  66983. TAG_ID[TAG_ID["H2"] = 42] = "H2";
  66984. TAG_ID[TAG_ID["H3"] = 43] = "H3";
  66985. TAG_ID[TAG_ID["H4"] = 44] = "H4";
  66986. TAG_ID[TAG_ID["H5"] = 45] = "H5";
  66987. TAG_ID[TAG_ID["H6"] = 46] = "H6";
  66988. TAG_ID[TAG_ID["HEAD"] = 47] = "HEAD";
  66989. TAG_ID[TAG_ID["HEADER"] = 48] = "HEADER";
  66990. TAG_ID[TAG_ID["HGROUP"] = 49] = "HGROUP";
  66991. TAG_ID[TAG_ID["HR"] = 50] = "HR";
  66992. TAG_ID[TAG_ID["HTML"] = 51] = "HTML";
  66993. TAG_ID[TAG_ID["I"] = 52] = "I";
  66994. TAG_ID[TAG_ID["IMG"] = 53] = "IMG";
  66995. TAG_ID[TAG_ID["IMAGE"] = 54] = "IMAGE";
  66996. TAG_ID[TAG_ID["INPUT"] = 55] = "INPUT";
  66997. TAG_ID[TAG_ID["IFRAME"] = 56] = "IFRAME";
  66998. TAG_ID[TAG_ID["KEYGEN"] = 57] = "KEYGEN";
  66999. TAG_ID[TAG_ID["LABEL"] = 58] = "LABEL";
  67000. TAG_ID[TAG_ID["LI"] = 59] = "LI";
  67001. TAG_ID[TAG_ID["LINK"] = 60] = "LINK";
  67002. TAG_ID[TAG_ID["LISTING"] = 61] = "LISTING";
  67003. TAG_ID[TAG_ID["MAIN"] = 62] = "MAIN";
  67004. TAG_ID[TAG_ID["MALIGNMARK"] = 63] = "MALIGNMARK";
  67005. TAG_ID[TAG_ID["MARQUEE"] = 64] = "MARQUEE";
  67006. TAG_ID[TAG_ID["MATH"] = 65] = "MATH";
  67007. TAG_ID[TAG_ID["MENU"] = 66] = "MENU";
  67008. TAG_ID[TAG_ID["META"] = 67] = "META";
  67009. TAG_ID[TAG_ID["MGLYPH"] = 68] = "MGLYPH";
  67010. TAG_ID[TAG_ID["MI"] = 69] = "MI";
  67011. TAG_ID[TAG_ID["MO"] = 70] = "MO";
  67012. TAG_ID[TAG_ID["MN"] = 71] = "MN";
  67013. TAG_ID[TAG_ID["MS"] = 72] = "MS";
  67014. TAG_ID[TAG_ID["MTEXT"] = 73] = "MTEXT";
  67015. TAG_ID[TAG_ID["NAV"] = 74] = "NAV";
  67016. TAG_ID[TAG_ID["NOBR"] = 75] = "NOBR";
  67017. TAG_ID[TAG_ID["NOFRAMES"] = 76] = "NOFRAMES";
  67018. TAG_ID[TAG_ID["NOEMBED"] = 77] = "NOEMBED";
  67019. TAG_ID[TAG_ID["NOSCRIPT"] = 78] = "NOSCRIPT";
  67020. TAG_ID[TAG_ID["OBJECT"] = 79] = "OBJECT";
  67021. TAG_ID[TAG_ID["OL"] = 80] = "OL";
  67022. TAG_ID[TAG_ID["OPTGROUP"] = 81] = "OPTGROUP";
  67023. TAG_ID[TAG_ID["OPTION"] = 82] = "OPTION";
  67024. TAG_ID[TAG_ID["P"] = 83] = "P";
  67025. TAG_ID[TAG_ID["PARAM"] = 84] = "PARAM";
  67026. TAG_ID[TAG_ID["PLAINTEXT"] = 85] = "PLAINTEXT";
  67027. TAG_ID[TAG_ID["PRE"] = 86] = "PRE";
  67028. TAG_ID[TAG_ID["RB"] = 87] = "RB";
  67029. TAG_ID[TAG_ID["RP"] = 88] = "RP";
  67030. TAG_ID[TAG_ID["RT"] = 89] = "RT";
  67031. TAG_ID[TAG_ID["RTC"] = 90] = "RTC";
  67032. TAG_ID[TAG_ID["RUBY"] = 91] = "RUBY";
  67033. TAG_ID[TAG_ID["S"] = 92] = "S";
  67034. TAG_ID[TAG_ID["SCRIPT"] = 93] = "SCRIPT";
  67035. TAG_ID[TAG_ID["SECTION"] = 94] = "SECTION";
  67036. TAG_ID[TAG_ID["SELECT"] = 95] = "SELECT";
  67037. TAG_ID[TAG_ID["SOURCE"] = 96] = "SOURCE";
  67038. TAG_ID[TAG_ID["SMALL"] = 97] = "SMALL";
  67039. TAG_ID[TAG_ID["SPAN"] = 98] = "SPAN";
  67040. TAG_ID[TAG_ID["STRIKE"] = 99] = "STRIKE";
  67041. TAG_ID[TAG_ID["STRONG"] = 100] = "STRONG";
  67042. TAG_ID[TAG_ID["STYLE"] = 101] = "STYLE";
  67043. TAG_ID[TAG_ID["SUB"] = 102] = "SUB";
  67044. TAG_ID[TAG_ID["SUMMARY"] = 103] = "SUMMARY";
  67045. TAG_ID[TAG_ID["SUP"] = 104] = "SUP";
  67046. TAG_ID[TAG_ID["TABLE"] = 105] = "TABLE";
  67047. TAG_ID[TAG_ID["TBODY"] = 106] = "TBODY";
  67048. TAG_ID[TAG_ID["TEMPLATE"] = 107] = "TEMPLATE";
  67049. TAG_ID[TAG_ID["TEXTAREA"] = 108] = "TEXTAREA";
  67050. TAG_ID[TAG_ID["TFOOT"] = 109] = "TFOOT";
  67051. TAG_ID[TAG_ID["TD"] = 110] = "TD";
  67052. TAG_ID[TAG_ID["TH"] = 111] = "TH";
  67053. TAG_ID[TAG_ID["THEAD"] = 112] = "THEAD";
  67054. TAG_ID[TAG_ID["TITLE"] = 113] = "TITLE";
  67055. TAG_ID[TAG_ID["TR"] = 114] = "TR";
  67056. TAG_ID[TAG_ID["TRACK"] = 115] = "TRACK";
  67057. TAG_ID[TAG_ID["TT"] = 116] = "TT";
  67058. TAG_ID[TAG_ID["U"] = 117] = "U";
  67059. TAG_ID[TAG_ID["UL"] = 118] = "UL";
  67060. TAG_ID[TAG_ID["SVG"] = 119] = "SVG";
  67061. TAG_ID[TAG_ID["VAR"] = 120] = "VAR";
  67062. TAG_ID[TAG_ID["WBR"] = 121] = "WBR";
  67063. TAG_ID[TAG_ID["XMP"] = 122] = "XMP";
  67064. })(TAG_ID || (TAG_ID = {}));
  67065. const TAG_NAME_TO_ID = new Map([
  67066. [TAG_NAMES.A, TAG_ID.A],
  67067. [TAG_NAMES.ADDRESS, TAG_ID.ADDRESS],
  67068. [TAG_NAMES.ANNOTATION_XML, TAG_ID.ANNOTATION_XML],
  67069. [TAG_NAMES.APPLET, TAG_ID.APPLET],
  67070. [TAG_NAMES.AREA, TAG_ID.AREA],
  67071. [TAG_NAMES.ARTICLE, TAG_ID.ARTICLE],
  67072. [TAG_NAMES.ASIDE, TAG_ID.ASIDE],
  67073. [TAG_NAMES.B, TAG_ID.B],
  67074. [TAG_NAMES.BASE, TAG_ID.BASE],
  67075. [TAG_NAMES.BASEFONT, TAG_ID.BASEFONT],
  67076. [TAG_NAMES.BGSOUND, TAG_ID.BGSOUND],
  67077. [TAG_NAMES.BIG, TAG_ID.BIG],
  67078. [TAG_NAMES.BLOCKQUOTE, TAG_ID.BLOCKQUOTE],
  67079. [TAG_NAMES.BODY, TAG_ID.BODY],
  67080. [TAG_NAMES.BR, TAG_ID.BR],
  67081. [TAG_NAMES.BUTTON, TAG_ID.BUTTON],
  67082. [TAG_NAMES.CAPTION, TAG_ID.CAPTION],
  67083. [TAG_NAMES.CENTER, TAG_ID.CENTER],
  67084. [TAG_NAMES.CODE, TAG_ID.CODE],
  67085. [TAG_NAMES.COL, TAG_ID.COL],
  67086. [TAG_NAMES.COLGROUP, TAG_ID.COLGROUP],
  67087. [TAG_NAMES.DD, TAG_ID.DD],
  67088. [TAG_NAMES.DESC, TAG_ID.DESC],
  67089. [TAG_NAMES.DETAILS, TAG_ID.DETAILS],
  67090. [TAG_NAMES.DIALOG, TAG_ID.DIALOG],
  67091. [TAG_NAMES.DIR, TAG_ID.DIR],
  67092. [TAG_NAMES.DIV, TAG_ID.DIV],
  67093. [TAG_NAMES.DL, TAG_ID.DL],
  67094. [TAG_NAMES.DT, TAG_ID.DT],
  67095. [TAG_NAMES.EM, TAG_ID.EM],
  67096. [TAG_NAMES.EMBED, TAG_ID.EMBED],
  67097. [TAG_NAMES.FIELDSET, TAG_ID.FIELDSET],
  67098. [TAG_NAMES.FIGCAPTION, TAG_ID.FIGCAPTION],
  67099. [TAG_NAMES.FIGURE, TAG_ID.FIGURE],
  67100. [TAG_NAMES.FONT, TAG_ID.FONT],
  67101. [TAG_NAMES.FOOTER, TAG_ID.FOOTER],
  67102. [TAG_NAMES.FOREIGN_OBJECT, TAG_ID.FOREIGN_OBJECT],
  67103. [TAG_NAMES.FORM, TAG_ID.FORM],
  67104. [TAG_NAMES.FRAME, TAG_ID.FRAME],
  67105. [TAG_NAMES.FRAMESET, TAG_ID.FRAMESET],
  67106. [TAG_NAMES.H1, TAG_ID.H1],
  67107. [TAG_NAMES.H2, TAG_ID.H2],
  67108. [TAG_NAMES.H3, TAG_ID.H3],
  67109. [TAG_NAMES.H4, TAG_ID.H4],
  67110. [TAG_NAMES.H5, TAG_ID.H5],
  67111. [TAG_NAMES.H6, TAG_ID.H6],
  67112. [TAG_NAMES.HEAD, TAG_ID.HEAD],
  67113. [TAG_NAMES.HEADER, TAG_ID.HEADER],
  67114. [TAG_NAMES.HGROUP, TAG_ID.HGROUP],
  67115. [TAG_NAMES.HR, TAG_ID.HR],
  67116. [TAG_NAMES.HTML, TAG_ID.HTML],
  67117. [TAG_NAMES.I, TAG_ID.I],
  67118. [TAG_NAMES.IMG, TAG_ID.IMG],
  67119. [TAG_NAMES.IMAGE, TAG_ID.IMAGE],
  67120. [TAG_NAMES.INPUT, TAG_ID.INPUT],
  67121. [TAG_NAMES.IFRAME, TAG_ID.IFRAME],
  67122. [TAG_NAMES.KEYGEN, TAG_ID.KEYGEN],
  67123. [TAG_NAMES.LABEL, TAG_ID.LABEL],
  67124. [TAG_NAMES.LI, TAG_ID.LI],
  67125. [TAG_NAMES.LINK, TAG_ID.LINK],
  67126. [TAG_NAMES.LISTING, TAG_ID.LISTING],
  67127. [TAG_NAMES.MAIN, TAG_ID.MAIN],
  67128. [TAG_NAMES.MALIGNMARK, TAG_ID.MALIGNMARK],
  67129. [TAG_NAMES.MARQUEE, TAG_ID.MARQUEE],
  67130. [TAG_NAMES.MATH, TAG_ID.MATH],
  67131. [TAG_NAMES.MENU, TAG_ID.MENU],
  67132. [TAG_NAMES.META, TAG_ID.META],
  67133. [TAG_NAMES.MGLYPH, TAG_ID.MGLYPH],
  67134. [TAG_NAMES.MI, TAG_ID.MI],
  67135. [TAG_NAMES.MO, TAG_ID.MO],
  67136. [TAG_NAMES.MN, TAG_ID.MN],
  67137. [TAG_NAMES.MS, TAG_ID.MS],
  67138. [TAG_NAMES.MTEXT, TAG_ID.MTEXT],
  67139. [TAG_NAMES.NAV, TAG_ID.NAV],
  67140. [TAG_NAMES.NOBR, TAG_ID.NOBR],
  67141. [TAG_NAMES.NOFRAMES, TAG_ID.NOFRAMES],
  67142. [TAG_NAMES.NOEMBED, TAG_ID.NOEMBED],
  67143. [TAG_NAMES.NOSCRIPT, TAG_ID.NOSCRIPT],
  67144. [TAG_NAMES.OBJECT, TAG_ID.OBJECT],
  67145. [TAG_NAMES.OL, TAG_ID.OL],
  67146. [TAG_NAMES.OPTGROUP, TAG_ID.OPTGROUP],
  67147. [TAG_NAMES.OPTION, TAG_ID.OPTION],
  67148. [TAG_NAMES.P, TAG_ID.P],
  67149. [TAG_NAMES.PARAM, TAG_ID.PARAM],
  67150. [TAG_NAMES.PLAINTEXT, TAG_ID.PLAINTEXT],
  67151. [TAG_NAMES.PRE, TAG_ID.PRE],
  67152. [TAG_NAMES.RB, TAG_ID.RB],
  67153. [TAG_NAMES.RP, TAG_ID.RP],
  67154. [TAG_NAMES.RT, TAG_ID.RT],
  67155. [TAG_NAMES.RTC, TAG_ID.RTC],
  67156. [TAG_NAMES.RUBY, TAG_ID.RUBY],
  67157. [TAG_NAMES.S, TAG_ID.S],
  67158. [TAG_NAMES.SCRIPT, TAG_ID.SCRIPT],
  67159. [TAG_NAMES.SECTION, TAG_ID.SECTION],
  67160. [TAG_NAMES.SELECT, TAG_ID.SELECT],
  67161. [TAG_NAMES.SOURCE, TAG_ID.SOURCE],
  67162. [TAG_NAMES.SMALL, TAG_ID.SMALL],
  67163. [TAG_NAMES.SPAN, TAG_ID.SPAN],
  67164. [TAG_NAMES.STRIKE, TAG_ID.STRIKE],
  67165. [TAG_NAMES.STRONG, TAG_ID.STRONG],
  67166. [TAG_NAMES.STYLE, TAG_ID.STYLE],
  67167. [TAG_NAMES.SUB, TAG_ID.SUB],
  67168. [TAG_NAMES.SUMMARY, TAG_ID.SUMMARY],
  67169. [TAG_NAMES.SUP, TAG_ID.SUP],
  67170. [TAG_NAMES.TABLE, TAG_ID.TABLE],
  67171. [TAG_NAMES.TBODY, TAG_ID.TBODY],
  67172. [TAG_NAMES.TEMPLATE, TAG_ID.TEMPLATE],
  67173. [TAG_NAMES.TEXTAREA, TAG_ID.TEXTAREA],
  67174. [TAG_NAMES.TFOOT, TAG_ID.TFOOT],
  67175. [TAG_NAMES.TD, TAG_ID.TD],
  67176. [TAG_NAMES.TH, TAG_ID.TH],
  67177. [TAG_NAMES.THEAD, TAG_ID.THEAD],
  67178. [TAG_NAMES.TITLE, TAG_ID.TITLE],
  67179. [TAG_NAMES.TR, TAG_ID.TR],
  67180. [TAG_NAMES.TRACK, TAG_ID.TRACK],
  67181. [TAG_NAMES.TT, TAG_ID.TT],
  67182. [TAG_NAMES.U, TAG_ID.U],
  67183. [TAG_NAMES.UL, TAG_ID.UL],
  67184. [TAG_NAMES.SVG, TAG_ID.SVG],
  67185. [TAG_NAMES.VAR, TAG_ID.VAR],
  67186. [TAG_NAMES.WBR, TAG_ID.WBR],
  67187. [TAG_NAMES.XMP, TAG_ID.XMP],
  67188. ]);
  67189. function getTagID(tagName) {
  67190. var _a;
  67191. return (_a = TAG_NAME_TO_ID.get(tagName)) !== null && _a !== void 0 ? _a : TAG_ID.UNKNOWN;
  67192. }
  67193. const $ = TAG_ID;
  67194. const SPECIAL_ELEMENTS = {
  67195. [NS.HTML]: new Set([
  67196. $.ADDRESS,
  67197. $.APPLET,
  67198. $.AREA,
  67199. $.ARTICLE,
  67200. $.ASIDE,
  67201. $.BASE,
  67202. $.BASEFONT,
  67203. $.BGSOUND,
  67204. $.BLOCKQUOTE,
  67205. $.BODY,
  67206. $.BR,
  67207. $.BUTTON,
  67208. $.CAPTION,
  67209. $.CENTER,
  67210. $.COL,
  67211. $.COLGROUP,
  67212. $.DD,
  67213. $.DETAILS,
  67214. $.DIR,
  67215. $.DIV,
  67216. $.DL,
  67217. $.DT,
  67218. $.EMBED,
  67219. $.FIELDSET,
  67220. $.FIGCAPTION,
  67221. $.FIGURE,
  67222. $.FOOTER,
  67223. $.FORM,
  67224. $.FRAME,
  67225. $.FRAMESET,
  67226. $.H1,
  67227. $.H2,
  67228. $.H3,
  67229. $.H4,
  67230. $.H5,
  67231. $.H6,
  67232. $.HEAD,
  67233. $.HEADER,
  67234. $.HGROUP,
  67235. $.HR,
  67236. $.HTML,
  67237. $.IFRAME,
  67238. $.IMG,
  67239. $.INPUT,
  67240. $.LI,
  67241. $.LINK,
  67242. $.LISTING,
  67243. $.MAIN,
  67244. $.MARQUEE,
  67245. $.MENU,
  67246. $.META,
  67247. $.NAV,
  67248. $.NOEMBED,
  67249. $.NOFRAMES,
  67250. $.NOSCRIPT,
  67251. $.OBJECT,
  67252. $.OL,
  67253. $.P,
  67254. $.PARAM,
  67255. $.PLAINTEXT,
  67256. $.PRE,
  67257. $.SCRIPT,
  67258. $.SECTION,
  67259. $.SELECT,
  67260. $.SOURCE,
  67261. $.STYLE,
  67262. $.SUMMARY,
  67263. $.TABLE,
  67264. $.TBODY,
  67265. $.TD,
  67266. $.TEMPLATE,
  67267. $.TEXTAREA,
  67268. $.TFOOT,
  67269. $.TH,
  67270. $.THEAD,
  67271. $.TITLE,
  67272. $.TR,
  67273. $.TRACK,
  67274. $.UL,
  67275. $.WBR,
  67276. $.XMP,
  67277. ]),
  67278. [NS.MATHML]: new Set([$.MI, $.MO, $.MN, $.MS, $.MTEXT, $.ANNOTATION_XML]),
  67279. [NS.SVG]: new Set([$.TITLE, $.FOREIGN_OBJECT, $.DESC]),
  67280. [NS.XLINK]: new Set(),
  67281. [NS.XML]: new Set(),
  67282. [NS.XMLNS]: new Set(),
  67283. };
  67284. function isNumberedHeader(tn) {
  67285. return tn === $.H1 || tn === $.H2 || tn === $.H3 || tn === $.H4 || tn === $.H5 || tn === $.H6;
  67286. }
  67287. const UNESCAPED_TEXT = new Set([
  67288. TAG_NAMES.STYLE,
  67289. TAG_NAMES.SCRIPT,
  67290. TAG_NAMES.XMP,
  67291. TAG_NAMES.IFRAME,
  67292. TAG_NAMES.NOEMBED,
  67293. TAG_NAMES.NOFRAMES,
  67294. TAG_NAMES.PLAINTEXT,
  67295. ]);
  67296. function hasUnescapedText(tn, scriptingEnabled) {
  67297. return UNESCAPED_TEXT.has(tn) || (scriptingEnabled && tn === TAG_NAMES.NOSCRIPT);
  67298. }
  67299. //C1 Unicode control character reference replacements
  67300. const C1_CONTROLS_REFERENCE_REPLACEMENTS = new Map([
  67301. [0x80, 8364],
  67302. [0x82, 8218],
  67303. [0x83, 402],
  67304. [0x84, 8222],
  67305. [0x85, 8230],
  67306. [0x86, 8224],
  67307. [0x87, 8225],
  67308. [0x88, 710],
  67309. [0x89, 8240],
  67310. [0x8a, 352],
  67311. [0x8b, 8249],
  67312. [0x8c, 338],
  67313. [0x8e, 381],
  67314. [0x91, 8216],
  67315. [0x92, 8217],
  67316. [0x93, 8220],
  67317. [0x94, 8221],
  67318. [0x95, 8226],
  67319. [0x96, 8211],
  67320. [0x97, 8212],
  67321. [0x98, 732],
  67322. [0x99, 8482],
  67323. [0x9a, 353],
  67324. [0x9b, 8250],
  67325. [0x9c, 339],
  67326. [0x9e, 382],
  67327. [0x9f, 376],
  67328. ]);
  67329. //States
  67330. var State;
  67331. (function (State) {
  67332. State[State["DATA"] = 0] = "DATA";
  67333. State[State["RCDATA"] = 1] = "RCDATA";
  67334. State[State["RAWTEXT"] = 2] = "RAWTEXT";
  67335. State[State["SCRIPT_DATA"] = 3] = "SCRIPT_DATA";
  67336. State[State["PLAINTEXT"] = 4] = "PLAINTEXT";
  67337. State[State["TAG_OPEN"] = 5] = "TAG_OPEN";
  67338. State[State["END_TAG_OPEN"] = 6] = "END_TAG_OPEN";
  67339. State[State["TAG_NAME"] = 7] = "TAG_NAME";
  67340. State[State["RCDATA_LESS_THAN_SIGN"] = 8] = "RCDATA_LESS_THAN_SIGN";
  67341. State[State["RCDATA_END_TAG_OPEN"] = 9] = "RCDATA_END_TAG_OPEN";
  67342. State[State["RCDATA_END_TAG_NAME"] = 10] = "RCDATA_END_TAG_NAME";
  67343. State[State["RAWTEXT_LESS_THAN_SIGN"] = 11] = "RAWTEXT_LESS_THAN_SIGN";
  67344. State[State["RAWTEXT_END_TAG_OPEN"] = 12] = "RAWTEXT_END_TAG_OPEN";
  67345. State[State["RAWTEXT_END_TAG_NAME"] = 13] = "RAWTEXT_END_TAG_NAME";
  67346. State[State["SCRIPT_DATA_LESS_THAN_SIGN"] = 14] = "SCRIPT_DATA_LESS_THAN_SIGN";
  67347. State[State["SCRIPT_DATA_END_TAG_OPEN"] = 15] = "SCRIPT_DATA_END_TAG_OPEN";
  67348. State[State["SCRIPT_DATA_END_TAG_NAME"] = 16] = "SCRIPT_DATA_END_TAG_NAME";
  67349. State[State["SCRIPT_DATA_ESCAPE_START"] = 17] = "SCRIPT_DATA_ESCAPE_START";
  67350. State[State["SCRIPT_DATA_ESCAPE_START_DASH"] = 18] = "SCRIPT_DATA_ESCAPE_START_DASH";
  67351. State[State["SCRIPT_DATA_ESCAPED"] = 19] = "SCRIPT_DATA_ESCAPED";
  67352. State[State["SCRIPT_DATA_ESCAPED_DASH"] = 20] = "SCRIPT_DATA_ESCAPED_DASH";
  67353. State[State["SCRIPT_DATA_ESCAPED_DASH_DASH"] = 21] = "SCRIPT_DATA_ESCAPED_DASH_DASH";
  67354. State[State["SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN"] = 22] = "SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN";
  67355. State[State["SCRIPT_DATA_ESCAPED_END_TAG_OPEN"] = 23] = "SCRIPT_DATA_ESCAPED_END_TAG_OPEN";
  67356. State[State["SCRIPT_DATA_ESCAPED_END_TAG_NAME"] = 24] = "SCRIPT_DATA_ESCAPED_END_TAG_NAME";
  67357. State[State["SCRIPT_DATA_DOUBLE_ESCAPE_START"] = 25] = "SCRIPT_DATA_DOUBLE_ESCAPE_START";
  67358. State[State["SCRIPT_DATA_DOUBLE_ESCAPED"] = 26] = "SCRIPT_DATA_DOUBLE_ESCAPED";
  67359. State[State["SCRIPT_DATA_DOUBLE_ESCAPED_DASH"] = 27] = "SCRIPT_DATA_DOUBLE_ESCAPED_DASH";
  67360. State[State["SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH"] = 28] = "SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH";
  67361. State[State["SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN"] = 29] = "SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN";
  67362. State[State["SCRIPT_DATA_DOUBLE_ESCAPE_END"] = 30] = "SCRIPT_DATA_DOUBLE_ESCAPE_END";
  67363. State[State["BEFORE_ATTRIBUTE_NAME"] = 31] = "BEFORE_ATTRIBUTE_NAME";
  67364. State[State["ATTRIBUTE_NAME"] = 32] = "ATTRIBUTE_NAME";
  67365. State[State["AFTER_ATTRIBUTE_NAME"] = 33] = "AFTER_ATTRIBUTE_NAME";
  67366. State[State["BEFORE_ATTRIBUTE_VALUE"] = 34] = "BEFORE_ATTRIBUTE_VALUE";
  67367. State[State["ATTRIBUTE_VALUE_DOUBLE_QUOTED"] = 35] = "ATTRIBUTE_VALUE_DOUBLE_QUOTED";
  67368. State[State["ATTRIBUTE_VALUE_SINGLE_QUOTED"] = 36] = "ATTRIBUTE_VALUE_SINGLE_QUOTED";
  67369. State[State["ATTRIBUTE_VALUE_UNQUOTED"] = 37] = "ATTRIBUTE_VALUE_UNQUOTED";
  67370. State[State["AFTER_ATTRIBUTE_VALUE_QUOTED"] = 38] = "AFTER_ATTRIBUTE_VALUE_QUOTED";
  67371. State[State["SELF_CLOSING_START_TAG"] = 39] = "SELF_CLOSING_START_TAG";
  67372. State[State["BOGUS_COMMENT"] = 40] = "BOGUS_COMMENT";
  67373. State[State["MARKUP_DECLARATION_OPEN"] = 41] = "MARKUP_DECLARATION_OPEN";
  67374. State[State["COMMENT_START"] = 42] = "COMMENT_START";
  67375. State[State["COMMENT_START_DASH"] = 43] = "COMMENT_START_DASH";
  67376. State[State["COMMENT"] = 44] = "COMMENT";
  67377. State[State["COMMENT_LESS_THAN_SIGN"] = 45] = "COMMENT_LESS_THAN_SIGN";
  67378. State[State["COMMENT_LESS_THAN_SIGN_BANG"] = 46] = "COMMENT_LESS_THAN_SIGN_BANG";
  67379. State[State["COMMENT_LESS_THAN_SIGN_BANG_DASH"] = 47] = "COMMENT_LESS_THAN_SIGN_BANG_DASH";
  67380. State[State["COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH"] = 48] = "COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH";
  67381. State[State["COMMENT_END_DASH"] = 49] = "COMMENT_END_DASH";
  67382. State[State["COMMENT_END"] = 50] = "COMMENT_END";
  67383. State[State["COMMENT_END_BANG"] = 51] = "COMMENT_END_BANG";
  67384. State[State["DOCTYPE"] = 52] = "DOCTYPE";
  67385. State[State["BEFORE_DOCTYPE_NAME"] = 53] = "BEFORE_DOCTYPE_NAME";
  67386. State[State["DOCTYPE_NAME"] = 54] = "DOCTYPE_NAME";
  67387. State[State["AFTER_DOCTYPE_NAME"] = 55] = "AFTER_DOCTYPE_NAME";
  67388. State[State["AFTER_DOCTYPE_PUBLIC_KEYWORD"] = 56] = "AFTER_DOCTYPE_PUBLIC_KEYWORD";
  67389. State[State["BEFORE_DOCTYPE_PUBLIC_IDENTIFIER"] = 57] = "BEFORE_DOCTYPE_PUBLIC_IDENTIFIER";
  67390. State[State["DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED"] = 58] = "DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED";
  67391. State[State["DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED"] = 59] = "DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED";
  67392. State[State["AFTER_DOCTYPE_PUBLIC_IDENTIFIER"] = 60] = "AFTER_DOCTYPE_PUBLIC_IDENTIFIER";
  67393. State[State["BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS"] = 61] = "BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS";
  67394. State[State["AFTER_DOCTYPE_SYSTEM_KEYWORD"] = 62] = "AFTER_DOCTYPE_SYSTEM_KEYWORD";
  67395. State[State["BEFORE_DOCTYPE_SYSTEM_IDENTIFIER"] = 63] = "BEFORE_DOCTYPE_SYSTEM_IDENTIFIER";
  67396. State[State["DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED"] = 64] = "DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED";
  67397. State[State["DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED"] = 65] = "DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED";
  67398. State[State["AFTER_DOCTYPE_SYSTEM_IDENTIFIER"] = 66] = "AFTER_DOCTYPE_SYSTEM_IDENTIFIER";
  67399. State[State["BOGUS_DOCTYPE"] = 67] = "BOGUS_DOCTYPE";
  67400. State[State["CDATA_SECTION"] = 68] = "CDATA_SECTION";
  67401. State[State["CDATA_SECTION_BRACKET"] = 69] = "CDATA_SECTION_BRACKET";
  67402. State[State["CDATA_SECTION_END"] = 70] = "CDATA_SECTION_END";
  67403. State[State["CHARACTER_REFERENCE"] = 71] = "CHARACTER_REFERENCE";
  67404. State[State["NAMED_CHARACTER_REFERENCE"] = 72] = "NAMED_CHARACTER_REFERENCE";
  67405. State[State["AMBIGUOUS_AMPERSAND"] = 73] = "AMBIGUOUS_AMPERSAND";
  67406. State[State["NUMERIC_CHARACTER_REFERENCE"] = 74] = "NUMERIC_CHARACTER_REFERENCE";
  67407. State[State["HEXADEMICAL_CHARACTER_REFERENCE_START"] = 75] = "HEXADEMICAL_CHARACTER_REFERENCE_START";
  67408. State[State["DECIMAL_CHARACTER_REFERENCE_START"] = 76] = "DECIMAL_CHARACTER_REFERENCE_START";
  67409. State[State["HEXADEMICAL_CHARACTER_REFERENCE"] = 77] = "HEXADEMICAL_CHARACTER_REFERENCE";
  67410. State[State["DECIMAL_CHARACTER_REFERENCE"] = 78] = "DECIMAL_CHARACTER_REFERENCE";
  67411. State[State["NUMERIC_CHARACTER_REFERENCE_END"] = 79] = "NUMERIC_CHARACTER_REFERENCE_END";
  67412. })(State || (State = {}));
  67413. //Tokenizer initial states for different modes
  67414. const TokenizerMode = {
  67415. DATA: State.DATA,
  67416. RCDATA: State.RCDATA,
  67417. RAWTEXT: State.RAWTEXT,
  67418. SCRIPT_DATA: State.SCRIPT_DATA,
  67419. PLAINTEXT: State.PLAINTEXT,
  67420. CDATA_SECTION: State.CDATA_SECTION,
  67421. };
  67422. //Utils
  67423. //OPTIMIZATION: these utility functions should not be moved out of this module. V8 Crankshaft will not inline
  67424. //this functions if they will be situated in another module due to context switch.
  67425. //Always perform inlining check before modifying this functions ('node --trace-inlining').
  67426. function isAsciiDigit(cp) {
  67427. return cp >= CODE_POINTS.DIGIT_0 && cp <= CODE_POINTS.DIGIT_9;
  67428. }
  67429. function isAsciiUpper(cp) {
  67430. return cp >= CODE_POINTS.LATIN_CAPITAL_A && cp <= CODE_POINTS.LATIN_CAPITAL_Z;
  67431. }
  67432. function isAsciiLower(cp) {
  67433. return cp >= CODE_POINTS.LATIN_SMALL_A && cp <= CODE_POINTS.LATIN_SMALL_Z;
  67434. }
  67435. function isAsciiLetter(cp) {
  67436. return isAsciiLower(cp) || isAsciiUpper(cp);
  67437. }
  67438. function isAsciiAlphaNumeric(cp) {
  67439. return isAsciiLetter(cp) || isAsciiDigit(cp);
  67440. }
  67441. function isAsciiUpperHexDigit(cp) {
  67442. return cp >= CODE_POINTS.LATIN_CAPITAL_A && cp <= CODE_POINTS.LATIN_CAPITAL_F;
  67443. }
  67444. function isAsciiLowerHexDigit(cp) {
  67445. return cp >= CODE_POINTS.LATIN_SMALL_A && cp <= CODE_POINTS.LATIN_SMALL_F;
  67446. }
  67447. function isAsciiHexDigit(cp) {
  67448. return isAsciiDigit(cp) || isAsciiUpperHexDigit(cp) || isAsciiLowerHexDigit(cp);
  67449. }
  67450. function toAsciiLower(cp) {
  67451. return cp + 32;
  67452. }
  67453. function isWhitespace$1(cp) {
  67454. return cp === CODE_POINTS.SPACE || cp === CODE_POINTS.LINE_FEED || cp === CODE_POINTS.TABULATION || cp === CODE_POINTS.FORM_FEED;
  67455. }
  67456. function isEntityInAttributeInvalidEnd(nextCp) {
  67457. return nextCp === CODE_POINTS.EQUALS_SIGN || isAsciiAlphaNumeric(nextCp);
  67458. }
  67459. function isScriptDataDoubleEscapeSequenceEnd(cp) {
  67460. return isWhitespace$1(cp) || cp === CODE_POINTS.SOLIDUS || cp === CODE_POINTS.GREATER_THAN_SIGN;
  67461. }
  67462. //Tokenizer
  67463. class Tokenizer {
  67464. constructor(options, handler) {
  67465. this.options = options;
  67466. this.handler = handler;
  67467. this.paused = false;
  67468. /** Ensures that the parsing loop isn't run multiple times at once. */
  67469. this.inLoop = false;
  67470. /**
  67471. * Indicates that the current adjusted node exists, is not an element in the HTML namespace,
  67472. * and that it is not an integration point for either MathML or HTML.
  67473. *
  67474. * @see {@link https://html.spec.whatwg.org/multipage/parsing.html#tree-construction}
  67475. */
  67476. this.inForeignNode = false;
  67477. this.lastStartTagName = '';
  67478. this.active = false;
  67479. this.state = State.DATA;
  67480. this.returnState = State.DATA;
  67481. this.charRefCode = -1;
  67482. this.consumedAfterSnapshot = -1;
  67483. this.currentCharacterToken = null;
  67484. this.currentToken = null;
  67485. this.currentAttr = { name: '', value: '' };
  67486. this.preprocessor = new Preprocessor(handler);
  67487. this.currentLocation = this.getCurrentLocation(-1);
  67488. }
  67489. //Errors
  67490. _err(code) {
  67491. var _a, _b;
  67492. (_b = (_a = this.handler).onParseError) === null || _b === void 0 ? void 0 : _b.call(_a, this.preprocessor.getError(code));
  67493. }
  67494. // NOTE: `offset` may never run across line boundaries.
  67495. getCurrentLocation(offset) {
  67496. if (!this.options.sourceCodeLocationInfo) {
  67497. return null;
  67498. }
  67499. return {
  67500. startLine: this.preprocessor.line,
  67501. startCol: this.preprocessor.col - offset,
  67502. startOffset: this.preprocessor.offset - offset,
  67503. endLine: -1,
  67504. endCol: -1,
  67505. endOffset: -1,
  67506. };
  67507. }
  67508. _runParsingLoop() {
  67509. if (this.inLoop)
  67510. return;
  67511. this.inLoop = true;
  67512. while (this.active && !this.paused) {
  67513. this.consumedAfterSnapshot = 0;
  67514. const cp = this._consume();
  67515. if (!this._ensureHibernation()) {
  67516. this._callState(cp);
  67517. }
  67518. }
  67519. this.inLoop = false;
  67520. }
  67521. //API
  67522. pause() {
  67523. this.paused = true;
  67524. }
  67525. resume(writeCallback) {
  67526. if (!this.paused) {
  67527. throw new Error('Parser was already resumed');
  67528. }
  67529. this.paused = false;
  67530. // Necessary for synchronous resume.
  67531. if (this.inLoop)
  67532. return;
  67533. this._runParsingLoop();
  67534. if (!this.paused) {
  67535. writeCallback === null || writeCallback === void 0 ? void 0 : writeCallback();
  67536. }
  67537. }
  67538. write(chunk, isLastChunk, writeCallback) {
  67539. this.active = true;
  67540. this.preprocessor.write(chunk, isLastChunk);
  67541. this._runParsingLoop();
  67542. if (!this.paused) {
  67543. writeCallback === null || writeCallback === void 0 ? void 0 : writeCallback();
  67544. }
  67545. }
  67546. insertHtmlAtCurrentPos(chunk) {
  67547. this.active = true;
  67548. this.preprocessor.insertHtmlAtCurrentPos(chunk);
  67549. this._runParsingLoop();
  67550. }
  67551. //Hibernation
  67552. _ensureHibernation() {
  67553. if (this.preprocessor.endOfChunkHit) {
  67554. this._unconsume(this.consumedAfterSnapshot);
  67555. this.active = false;
  67556. return true;
  67557. }
  67558. return false;
  67559. }
  67560. //Consumption
  67561. _consume() {
  67562. this.consumedAfterSnapshot++;
  67563. return this.preprocessor.advance();
  67564. }
  67565. _unconsume(count) {
  67566. this.consumedAfterSnapshot -= count;
  67567. this.preprocessor.retreat(count);
  67568. }
  67569. _reconsumeInState(state) {
  67570. this.state = state;
  67571. this._unconsume(1);
  67572. }
  67573. _advanceBy(count) {
  67574. this.consumedAfterSnapshot += count;
  67575. for (let i = 0; i < count; i++) {
  67576. this.preprocessor.advance();
  67577. }
  67578. }
  67579. _consumeSequenceIfMatch(pattern, caseSensitive) {
  67580. if (this.preprocessor.startsWith(pattern, caseSensitive)) {
  67581. // We will already have consumed one character before calling this method.
  67582. this._advanceBy(pattern.length - 1);
  67583. return true;
  67584. }
  67585. return false;
  67586. }
  67587. //Token creation
  67588. _createStartTagToken() {
  67589. this.currentToken = {
  67590. type: TokenType.START_TAG,
  67591. tagName: '',
  67592. tagID: TAG_ID.UNKNOWN,
  67593. selfClosing: false,
  67594. ackSelfClosing: false,
  67595. attrs: [],
  67596. location: this.getCurrentLocation(1),
  67597. };
  67598. }
  67599. _createEndTagToken() {
  67600. this.currentToken = {
  67601. type: TokenType.END_TAG,
  67602. tagName: '',
  67603. tagID: TAG_ID.UNKNOWN,
  67604. selfClosing: false,
  67605. ackSelfClosing: false,
  67606. attrs: [],
  67607. location: this.getCurrentLocation(2),
  67608. };
  67609. }
  67610. _createCommentToken(offset) {
  67611. this.currentToken = {
  67612. type: TokenType.COMMENT,
  67613. data: '',
  67614. location: this.getCurrentLocation(offset),
  67615. };
  67616. }
  67617. _createDoctypeToken(initialName) {
  67618. this.currentToken = {
  67619. type: TokenType.DOCTYPE,
  67620. name: initialName,
  67621. forceQuirks: false,
  67622. publicId: null,
  67623. systemId: null,
  67624. location: this.currentLocation,
  67625. };
  67626. }
  67627. _createCharacterToken(type, chars) {
  67628. this.currentCharacterToken = {
  67629. type,
  67630. chars,
  67631. location: this.currentLocation,
  67632. };
  67633. }
  67634. //Tag attributes
  67635. _createAttr(attrNameFirstCh) {
  67636. this.currentAttr = {
  67637. name: attrNameFirstCh,
  67638. value: '',
  67639. };
  67640. this.currentLocation = this.getCurrentLocation(0);
  67641. }
  67642. _leaveAttrName() {
  67643. var _a;
  67644. var _b;
  67645. const token = this.currentToken;
  67646. if (getTokenAttr(token, this.currentAttr.name) === null) {
  67647. token.attrs.push(this.currentAttr);
  67648. if (token.location && this.currentLocation) {
  67649. const attrLocations = ((_a = (_b = token.location).attrs) !== null && _a !== void 0 ? _a : (_b.attrs = Object.create(null)));
  67650. attrLocations[this.currentAttr.name] = this.currentLocation;
  67651. // Set end location
  67652. this._leaveAttrValue();
  67653. }
  67654. }
  67655. else {
  67656. this._err(ERR.duplicateAttribute);
  67657. }
  67658. }
  67659. _leaveAttrValue() {
  67660. if (this.currentLocation) {
  67661. this.currentLocation.endLine = this.preprocessor.line;
  67662. this.currentLocation.endCol = this.preprocessor.col;
  67663. this.currentLocation.endOffset = this.preprocessor.offset;
  67664. }
  67665. }
  67666. //Token emission
  67667. prepareToken(ct) {
  67668. this._emitCurrentCharacterToken(ct.location);
  67669. this.currentToken = null;
  67670. if (ct.location) {
  67671. ct.location.endLine = this.preprocessor.line;
  67672. ct.location.endCol = this.preprocessor.col + 1;
  67673. ct.location.endOffset = this.preprocessor.offset + 1;
  67674. }
  67675. this.currentLocation = this.getCurrentLocation(-1);
  67676. }
  67677. emitCurrentTagToken() {
  67678. const ct = this.currentToken;
  67679. this.prepareToken(ct);
  67680. ct.tagID = getTagID(ct.tagName);
  67681. if (ct.type === TokenType.START_TAG) {
  67682. this.lastStartTagName = ct.tagName;
  67683. this.handler.onStartTag(ct);
  67684. }
  67685. else {
  67686. if (ct.attrs.length > 0) {
  67687. this._err(ERR.endTagWithAttributes);
  67688. }
  67689. if (ct.selfClosing) {
  67690. this._err(ERR.endTagWithTrailingSolidus);
  67691. }
  67692. this.handler.onEndTag(ct);
  67693. }
  67694. this.preprocessor.dropParsedChunk();
  67695. }
  67696. emitCurrentComment(ct) {
  67697. this.prepareToken(ct);
  67698. this.handler.onComment(ct);
  67699. this.preprocessor.dropParsedChunk();
  67700. }
  67701. emitCurrentDoctype(ct) {
  67702. this.prepareToken(ct);
  67703. this.handler.onDoctype(ct);
  67704. this.preprocessor.dropParsedChunk();
  67705. }
  67706. _emitCurrentCharacterToken(nextLocation) {
  67707. if (this.currentCharacterToken) {
  67708. //NOTE: if we have a pending character token, make it's end location equal to the
  67709. //current token's start location.
  67710. if (nextLocation && this.currentCharacterToken.location) {
  67711. this.currentCharacterToken.location.endLine = nextLocation.startLine;
  67712. this.currentCharacterToken.location.endCol = nextLocation.startCol;
  67713. this.currentCharacterToken.location.endOffset = nextLocation.startOffset;
  67714. }
  67715. switch (this.currentCharacterToken.type) {
  67716. case TokenType.CHARACTER: {
  67717. this.handler.onCharacter(this.currentCharacterToken);
  67718. break;
  67719. }
  67720. case TokenType.NULL_CHARACTER: {
  67721. this.handler.onNullCharacter(this.currentCharacterToken);
  67722. break;
  67723. }
  67724. case TokenType.WHITESPACE_CHARACTER: {
  67725. this.handler.onWhitespaceCharacter(this.currentCharacterToken);
  67726. break;
  67727. }
  67728. }
  67729. this.currentCharacterToken = null;
  67730. }
  67731. }
  67732. _emitEOFToken() {
  67733. const location = this.getCurrentLocation(0);
  67734. if (location) {
  67735. location.endLine = location.startLine;
  67736. location.endCol = location.startCol;
  67737. location.endOffset = location.startOffset;
  67738. }
  67739. this._emitCurrentCharacterToken(location);
  67740. this.handler.onEof({ type: TokenType.EOF, location });
  67741. this.active = false;
  67742. }
  67743. //Characters emission
  67744. //OPTIMIZATION: specification uses only one type of character tokens (one token per character).
  67745. //This causes a huge memory overhead and a lot of unnecessary parser loops. parse5 uses 3 groups of characters.
  67746. //If we have a sequence of characters that belong to the same group, the parser can process it
  67747. //as a single solid character token.
  67748. //So, there are 3 types of character tokens in parse5:
  67749. //1)TokenType.NULL_CHARACTER - \u0000-character sequences (e.g. '\u0000\u0000\u0000')
  67750. //2)TokenType.WHITESPACE_CHARACTER - any whitespace/new-line character sequences (e.g. '\n \r\t \f')
  67751. //3)TokenType.CHARACTER - any character sequence which don't belong to groups 1 and 2 (e.g. 'abcdef1234@@#$%^')
  67752. _appendCharToCurrentCharacterToken(type, ch) {
  67753. if (this.currentCharacterToken) {
  67754. if (this.currentCharacterToken.type !== type) {
  67755. this.currentLocation = this.getCurrentLocation(0);
  67756. this._emitCurrentCharacterToken(this.currentLocation);
  67757. this.preprocessor.dropParsedChunk();
  67758. }
  67759. else {
  67760. this.currentCharacterToken.chars += ch;
  67761. return;
  67762. }
  67763. }
  67764. this._createCharacterToken(type, ch);
  67765. }
  67766. _emitCodePoint(cp) {
  67767. let type = TokenType.CHARACTER;
  67768. if (isWhitespace$1(cp)) {
  67769. type = TokenType.WHITESPACE_CHARACTER;
  67770. }
  67771. else if (cp === CODE_POINTS.NULL) {
  67772. type = TokenType.NULL_CHARACTER;
  67773. }
  67774. this._appendCharToCurrentCharacterToken(type, String.fromCodePoint(cp));
  67775. }
  67776. //NOTE: used when we emit characters explicitly.
  67777. //This is always for non-whitespace and non-null characters, which allows us to avoid additional checks.
  67778. _emitChars(ch) {
  67779. this._appendCharToCurrentCharacterToken(TokenType.CHARACTER, ch);
  67780. }
  67781. // Character reference helpers
  67782. _matchNamedCharacterReference(cp) {
  67783. let result = null;
  67784. let excess = 0;
  67785. let withoutSemicolon = false;
  67786. for (let i = 0, current = decode_10[0]; i >= 0; cp = this._consume()) {
  67787. i = decode_4(decode_10, current, i + 1, cp);
  67788. if (i < 0)
  67789. break;
  67790. excess += 1;
  67791. current = decode_10[i];
  67792. const masked = current & decode_5.VALUE_LENGTH;
  67793. // If the branch is a value, store it and continue
  67794. if (masked) {
  67795. // The mask is the number of bytes of the value, including the current byte.
  67796. const valueLength = (masked >> 14) - 1;
  67797. // Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
  67798. // See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
  67799. if (cp !== CODE_POINTS.SEMICOLON &&
  67800. this._isCharacterReferenceInAttribute() &&
  67801. isEntityInAttributeInvalidEnd(this.preprocessor.peek(1))) {
  67802. //NOTE: we don't flush all consumed code points here, and instead switch back to the original state after
  67803. //emitting an ampersand. This is fine, as alphanumeric characters won't be parsed differently in attributes.
  67804. result = [CODE_POINTS.AMPERSAND];
  67805. // Skip over the value.
  67806. i += valueLength;
  67807. }
  67808. else {
  67809. // If this is a surrogate pair, consume the next two bytes.
  67810. result =
  67811. valueLength === 0
  67812. ? [decode_10[i] & ~decode_5.VALUE_LENGTH]
  67813. : valueLength === 1
  67814. ? [decode_10[++i]]
  67815. : [decode_10[++i], decode_10[++i]];
  67816. excess = 0;
  67817. withoutSemicolon = cp !== CODE_POINTS.SEMICOLON;
  67818. }
  67819. if (valueLength === 0) {
  67820. // If the value is zero-length, we're done.
  67821. this._consume();
  67822. break;
  67823. }
  67824. }
  67825. }
  67826. this._unconsume(excess);
  67827. if (withoutSemicolon && !this.preprocessor.endOfChunkHit) {
  67828. this._err(ERR.missingSemicolonAfterCharacterReference);
  67829. }
  67830. // We want to emit the error above on the code point after the entity.
  67831. // We always consume one code point too many in the loop, and we wait to
  67832. // unconsume it until after the error is emitted.
  67833. this._unconsume(1);
  67834. return result;
  67835. }
  67836. _isCharacterReferenceInAttribute() {
  67837. return (this.returnState === State.ATTRIBUTE_VALUE_DOUBLE_QUOTED ||
  67838. this.returnState === State.ATTRIBUTE_VALUE_SINGLE_QUOTED ||
  67839. this.returnState === State.ATTRIBUTE_VALUE_UNQUOTED);
  67840. }
  67841. _flushCodePointConsumedAsCharacterReference(cp) {
  67842. if (this._isCharacterReferenceInAttribute()) {
  67843. this.currentAttr.value += String.fromCodePoint(cp);
  67844. }
  67845. else {
  67846. this._emitCodePoint(cp);
  67847. }
  67848. }
  67849. // Calling states this way turns out to be much faster than any other approach.
  67850. _callState(cp) {
  67851. switch (this.state) {
  67852. case State.DATA: {
  67853. this._stateData(cp);
  67854. break;
  67855. }
  67856. case State.RCDATA: {
  67857. this._stateRcdata(cp);
  67858. break;
  67859. }
  67860. case State.RAWTEXT: {
  67861. this._stateRawtext(cp);
  67862. break;
  67863. }
  67864. case State.SCRIPT_DATA: {
  67865. this._stateScriptData(cp);
  67866. break;
  67867. }
  67868. case State.PLAINTEXT: {
  67869. this._statePlaintext(cp);
  67870. break;
  67871. }
  67872. case State.TAG_OPEN: {
  67873. this._stateTagOpen(cp);
  67874. break;
  67875. }
  67876. case State.END_TAG_OPEN: {
  67877. this._stateEndTagOpen(cp);
  67878. break;
  67879. }
  67880. case State.TAG_NAME: {
  67881. this._stateTagName(cp);
  67882. break;
  67883. }
  67884. case State.RCDATA_LESS_THAN_SIGN: {
  67885. this._stateRcdataLessThanSign(cp);
  67886. break;
  67887. }
  67888. case State.RCDATA_END_TAG_OPEN: {
  67889. this._stateRcdataEndTagOpen(cp);
  67890. break;
  67891. }
  67892. case State.RCDATA_END_TAG_NAME: {
  67893. this._stateRcdataEndTagName(cp);
  67894. break;
  67895. }
  67896. case State.RAWTEXT_LESS_THAN_SIGN: {
  67897. this._stateRawtextLessThanSign(cp);
  67898. break;
  67899. }
  67900. case State.RAWTEXT_END_TAG_OPEN: {
  67901. this._stateRawtextEndTagOpen(cp);
  67902. break;
  67903. }
  67904. case State.RAWTEXT_END_TAG_NAME: {
  67905. this._stateRawtextEndTagName(cp);
  67906. break;
  67907. }
  67908. case State.SCRIPT_DATA_LESS_THAN_SIGN: {
  67909. this._stateScriptDataLessThanSign(cp);
  67910. break;
  67911. }
  67912. case State.SCRIPT_DATA_END_TAG_OPEN: {
  67913. this._stateScriptDataEndTagOpen(cp);
  67914. break;
  67915. }
  67916. case State.SCRIPT_DATA_END_TAG_NAME: {
  67917. this._stateScriptDataEndTagName(cp);
  67918. break;
  67919. }
  67920. case State.SCRIPT_DATA_ESCAPE_START: {
  67921. this._stateScriptDataEscapeStart(cp);
  67922. break;
  67923. }
  67924. case State.SCRIPT_DATA_ESCAPE_START_DASH: {
  67925. this._stateScriptDataEscapeStartDash(cp);
  67926. break;
  67927. }
  67928. case State.SCRIPT_DATA_ESCAPED: {
  67929. this._stateScriptDataEscaped(cp);
  67930. break;
  67931. }
  67932. case State.SCRIPT_DATA_ESCAPED_DASH: {
  67933. this._stateScriptDataEscapedDash(cp);
  67934. break;
  67935. }
  67936. case State.SCRIPT_DATA_ESCAPED_DASH_DASH: {
  67937. this._stateScriptDataEscapedDashDash(cp);
  67938. break;
  67939. }
  67940. case State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN: {
  67941. this._stateScriptDataEscapedLessThanSign(cp);
  67942. break;
  67943. }
  67944. case State.SCRIPT_DATA_ESCAPED_END_TAG_OPEN: {
  67945. this._stateScriptDataEscapedEndTagOpen(cp);
  67946. break;
  67947. }
  67948. case State.SCRIPT_DATA_ESCAPED_END_TAG_NAME: {
  67949. this._stateScriptDataEscapedEndTagName(cp);
  67950. break;
  67951. }
  67952. case State.SCRIPT_DATA_DOUBLE_ESCAPE_START: {
  67953. this._stateScriptDataDoubleEscapeStart(cp);
  67954. break;
  67955. }
  67956. case State.SCRIPT_DATA_DOUBLE_ESCAPED: {
  67957. this._stateScriptDataDoubleEscaped(cp);
  67958. break;
  67959. }
  67960. case State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH: {
  67961. this._stateScriptDataDoubleEscapedDash(cp);
  67962. break;
  67963. }
  67964. case State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH: {
  67965. this._stateScriptDataDoubleEscapedDashDash(cp);
  67966. break;
  67967. }
  67968. case State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN: {
  67969. this._stateScriptDataDoubleEscapedLessThanSign(cp);
  67970. break;
  67971. }
  67972. case State.SCRIPT_DATA_DOUBLE_ESCAPE_END: {
  67973. this._stateScriptDataDoubleEscapeEnd(cp);
  67974. break;
  67975. }
  67976. case State.BEFORE_ATTRIBUTE_NAME: {
  67977. this._stateBeforeAttributeName(cp);
  67978. break;
  67979. }
  67980. case State.ATTRIBUTE_NAME: {
  67981. this._stateAttributeName(cp);
  67982. break;
  67983. }
  67984. case State.AFTER_ATTRIBUTE_NAME: {
  67985. this._stateAfterAttributeName(cp);
  67986. break;
  67987. }
  67988. case State.BEFORE_ATTRIBUTE_VALUE: {
  67989. this._stateBeforeAttributeValue(cp);
  67990. break;
  67991. }
  67992. case State.ATTRIBUTE_VALUE_DOUBLE_QUOTED: {
  67993. this._stateAttributeValueDoubleQuoted(cp);
  67994. break;
  67995. }
  67996. case State.ATTRIBUTE_VALUE_SINGLE_QUOTED: {
  67997. this._stateAttributeValueSingleQuoted(cp);
  67998. break;
  67999. }
  68000. case State.ATTRIBUTE_VALUE_UNQUOTED: {
  68001. this._stateAttributeValueUnquoted(cp);
  68002. break;
  68003. }
  68004. case State.AFTER_ATTRIBUTE_VALUE_QUOTED: {
  68005. this._stateAfterAttributeValueQuoted(cp);
  68006. break;
  68007. }
  68008. case State.SELF_CLOSING_START_TAG: {
  68009. this._stateSelfClosingStartTag(cp);
  68010. break;
  68011. }
  68012. case State.BOGUS_COMMENT: {
  68013. this._stateBogusComment(cp);
  68014. break;
  68015. }
  68016. case State.MARKUP_DECLARATION_OPEN: {
  68017. this._stateMarkupDeclarationOpen(cp);
  68018. break;
  68019. }
  68020. case State.COMMENT_START: {
  68021. this._stateCommentStart(cp);
  68022. break;
  68023. }
  68024. case State.COMMENT_START_DASH: {
  68025. this._stateCommentStartDash(cp);
  68026. break;
  68027. }
  68028. case State.COMMENT: {
  68029. this._stateComment(cp);
  68030. break;
  68031. }
  68032. case State.COMMENT_LESS_THAN_SIGN: {
  68033. this._stateCommentLessThanSign(cp);
  68034. break;
  68035. }
  68036. case State.COMMENT_LESS_THAN_SIGN_BANG: {
  68037. this._stateCommentLessThanSignBang(cp);
  68038. break;
  68039. }
  68040. case State.COMMENT_LESS_THAN_SIGN_BANG_DASH: {
  68041. this._stateCommentLessThanSignBangDash(cp);
  68042. break;
  68043. }
  68044. case State.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH: {
  68045. this._stateCommentLessThanSignBangDashDash(cp);
  68046. break;
  68047. }
  68048. case State.COMMENT_END_DASH: {
  68049. this._stateCommentEndDash(cp);
  68050. break;
  68051. }
  68052. case State.COMMENT_END: {
  68053. this._stateCommentEnd(cp);
  68054. break;
  68055. }
  68056. case State.COMMENT_END_BANG: {
  68057. this._stateCommentEndBang(cp);
  68058. break;
  68059. }
  68060. case State.DOCTYPE: {
  68061. this._stateDoctype(cp);
  68062. break;
  68063. }
  68064. case State.BEFORE_DOCTYPE_NAME: {
  68065. this._stateBeforeDoctypeName(cp);
  68066. break;
  68067. }
  68068. case State.DOCTYPE_NAME: {
  68069. this._stateDoctypeName(cp);
  68070. break;
  68071. }
  68072. case State.AFTER_DOCTYPE_NAME: {
  68073. this._stateAfterDoctypeName(cp);
  68074. break;
  68075. }
  68076. case State.AFTER_DOCTYPE_PUBLIC_KEYWORD: {
  68077. this._stateAfterDoctypePublicKeyword(cp);
  68078. break;
  68079. }
  68080. case State.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER: {
  68081. this._stateBeforeDoctypePublicIdentifier(cp);
  68082. break;
  68083. }
  68084. case State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED: {
  68085. this._stateDoctypePublicIdentifierDoubleQuoted(cp);
  68086. break;
  68087. }
  68088. case State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED: {
  68089. this._stateDoctypePublicIdentifierSingleQuoted(cp);
  68090. break;
  68091. }
  68092. case State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER: {
  68093. this._stateAfterDoctypePublicIdentifier(cp);
  68094. break;
  68095. }
  68096. case State.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS: {
  68097. this._stateBetweenDoctypePublicAndSystemIdentifiers(cp);
  68098. break;
  68099. }
  68100. case State.AFTER_DOCTYPE_SYSTEM_KEYWORD: {
  68101. this._stateAfterDoctypeSystemKeyword(cp);
  68102. break;
  68103. }
  68104. case State.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER: {
  68105. this._stateBeforeDoctypeSystemIdentifier(cp);
  68106. break;
  68107. }
  68108. case State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED: {
  68109. this._stateDoctypeSystemIdentifierDoubleQuoted(cp);
  68110. break;
  68111. }
  68112. case State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED: {
  68113. this._stateDoctypeSystemIdentifierSingleQuoted(cp);
  68114. break;
  68115. }
  68116. case State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER: {
  68117. this._stateAfterDoctypeSystemIdentifier(cp);
  68118. break;
  68119. }
  68120. case State.BOGUS_DOCTYPE: {
  68121. this._stateBogusDoctype(cp);
  68122. break;
  68123. }
  68124. case State.CDATA_SECTION: {
  68125. this._stateCdataSection(cp);
  68126. break;
  68127. }
  68128. case State.CDATA_SECTION_BRACKET: {
  68129. this._stateCdataSectionBracket(cp);
  68130. break;
  68131. }
  68132. case State.CDATA_SECTION_END: {
  68133. this._stateCdataSectionEnd(cp);
  68134. break;
  68135. }
  68136. case State.CHARACTER_REFERENCE: {
  68137. this._stateCharacterReference(cp);
  68138. break;
  68139. }
  68140. case State.NAMED_CHARACTER_REFERENCE: {
  68141. this._stateNamedCharacterReference(cp);
  68142. break;
  68143. }
  68144. case State.AMBIGUOUS_AMPERSAND: {
  68145. this._stateAmbiguousAmpersand(cp);
  68146. break;
  68147. }
  68148. case State.NUMERIC_CHARACTER_REFERENCE: {
  68149. this._stateNumericCharacterReference(cp);
  68150. break;
  68151. }
  68152. case State.HEXADEMICAL_CHARACTER_REFERENCE_START: {
  68153. this._stateHexademicalCharacterReferenceStart(cp);
  68154. break;
  68155. }
  68156. case State.DECIMAL_CHARACTER_REFERENCE_START: {
  68157. this._stateDecimalCharacterReferenceStart(cp);
  68158. break;
  68159. }
  68160. case State.HEXADEMICAL_CHARACTER_REFERENCE: {
  68161. this._stateHexademicalCharacterReference(cp);
  68162. break;
  68163. }
  68164. case State.DECIMAL_CHARACTER_REFERENCE: {
  68165. this._stateDecimalCharacterReference(cp);
  68166. break;
  68167. }
  68168. case State.NUMERIC_CHARACTER_REFERENCE_END: {
  68169. this._stateNumericCharacterReferenceEnd();
  68170. break;
  68171. }
  68172. default: {
  68173. throw new Error('Unknown state');
  68174. }
  68175. }
  68176. }
  68177. // State machine
  68178. // Data state
  68179. //------------------------------------------------------------------
  68180. _stateData(cp) {
  68181. switch (cp) {
  68182. case CODE_POINTS.LESS_THAN_SIGN: {
  68183. this.state = State.TAG_OPEN;
  68184. break;
  68185. }
  68186. case CODE_POINTS.AMPERSAND: {
  68187. this.returnState = State.DATA;
  68188. this.state = State.CHARACTER_REFERENCE;
  68189. break;
  68190. }
  68191. case CODE_POINTS.NULL: {
  68192. this._err(ERR.unexpectedNullCharacter);
  68193. this._emitCodePoint(cp);
  68194. break;
  68195. }
  68196. case CODE_POINTS.EOF: {
  68197. this._emitEOFToken();
  68198. break;
  68199. }
  68200. default: {
  68201. this._emitCodePoint(cp);
  68202. }
  68203. }
  68204. }
  68205. // RCDATA state
  68206. //------------------------------------------------------------------
  68207. _stateRcdata(cp) {
  68208. switch (cp) {
  68209. case CODE_POINTS.AMPERSAND: {
  68210. this.returnState = State.RCDATA;
  68211. this.state = State.CHARACTER_REFERENCE;
  68212. break;
  68213. }
  68214. case CODE_POINTS.LESS_THAN_SIGN: {
  68215. this.state = State.RCDATA_LESS_THAN_SIGN;
  68216. break;
  68217. }
  68218. case CODE_POINTS.NULL: {
  68219. this._err(ERR.unexpectedNullCharacter);
  68220. this._emitChars(REPLACEMENT_CHARACTER);
  68221. break;
  68222. }
  68223. case CODE_POINTS.EOF: {
  68224. this._emitEOFToken();
  68225. break;
  68226. }
  68227. default: {
  68228. this._emitCodePoint(cp);
  68229. }
  68230. }
  68231. }
  68232. // RAWTEXT state
  68233. //------------------------------------------------------------------
  68234. _stateRawtext(cp) {
  68235. switch (cp) {
  68236. case CODE_POINTS.LESS_THAN_SIGN: {
  68237. this.state = State.RAWTEXT_LESS_THAN_SIGN;
  68238. break;
  68239. }
  68240. case CODE_POINTS.NULL: {
  68241. this._err(ERR.unexpectedNullCharacter);
  68242. this._emitChars(REPLACEMENT_CHARACTER);
  68243. break;
  68244. }
  68245. case CODE_POINTS.EOF: {
  68246. this._emitEOFToken();
  68247. break;
  68248. }
  68249. default: {
  68250. this._emitCodePoint(cp);
  68251. }
  68252. }
  68253. }
  68254. // Script data state
  68255. //------------------------------------------------------------------
  68256. _stateScriptData(cp) {
  68257. switch (cp) {
  68258. case CODE_POINTS.LESS_THAN_SIGN: {
  68259. this.state = State.SCRIPT_DATA_LESS_THAN_SIGN;
  68260. break;
  68261. }
  68262. case CODE_POINTS.NULL: {
  68263. this._err(ERR.unexpectedNullCharacter);
  68264. this._emitChars(REPLACEMENT_CHARACTER);
  68265. break;
  68266. }
  68267. case CODE_POINTS.EOF: {
  68268. this._emitEOFToken();
  68269. break;
  68270. }
  68271. default: {
  68272. this._emitCodePoint(cp);
  68273. }
  68274. }
  68275. }
  68276. // PLAINTEXT state
  68277. //------------------------------------------------------------------
  68278. _statePlaintext(cp) {
  68279. switch (cp) {
  68280. case CODE_POINTS.NULL: {
  68281. this._err(ERR.unexpectedNullCharacter);
  68282. this._emitChars(REPLACEMENT_CHARACTER);
  68283. break;
  68284. }
  68285. case CODE_POINTS.EOF: {
  68286. this._emitEOFToken();
  68287. break;
  68288. }
  68289. default: {
  68290. this._emitCodePoint(cp);
  68291. }
  68292. }
  68293. }
  68294. // Tag open state
  68295. //------------------------------------------------------------------
  68296. _stateTagOpen(cp) {
  68297. if (isAsciiLetter(cp)) {
  68298. this._createStartTagToken();
  68299. this.state = State.TAG_NAME;
  68300. this._stateTagName(cp);
  68301. }
  68302. else
  68303. switch (cp) {
  68304. case CODE_POINTS.EXCLAMATION_MARK: {
  68305. this.state = State.MARKUP_DECLARATION_OPEN;
  68306. break;
  68307. }
  68308. case CODE_POINTS.SOLIDUS: {
  68309. this.state = State.END_TAG_OPEN;
  68310. break;
  68311. }
  68312. case CODE_POINTS.QUESTION_MARK: {
  68313. this._err(ERR.unexpectedQuestionMarkInsteadOfTagName);
  68314. this._createCommentToken(1);
  68315. this.state = State.BOGUS_COMMENT;
  68316. this._stateBogusComment(cp);
  68317. break;
  68318. }
  68319. case CODE_POINTS.EOF: {
  68320. this._err(ERR.eofBeforeTagName);
  68321. this._emitChars('<');
  68322. this._emitEOFToken();
  68323. break;
  68324. }
  68325. default: {
  68326. this._err(ERR.invalidFirstCharacterOfTagName);
  68327. this._emitChars('<');
  68328. this.state = State.DATA;
  68329. this._stateData(cp);
  68330. }
  68331. }
  68332. }
  68333. // End tag open state
  68334. //------------------------------------------------------------------
  68335. _stateEndTagOpen(cp) {
  68336. if (isAsciiLetter(cp)) {
  68337. this._createEndTagToken();
  68338. this.state = State.TAG_NAME;
  68339. this._stateTagName(cp);
  68340. }
  68341. else
  68342. switch (cp) {
  68343. case CODE_POINTS.GREATER_THAN_SIGN: {
  68344. this._err(ERR.missingEndTagName);
  68345. this.state = State.DATA;
  68346. break;
  68347. }
  68348. case CODE_POINTS.EOF: {
  68349. this._err(ERR.eofBeforeTagName);
  68350. this._emitChars('</');
  68351. this._emitEOFToken();
  68352. break;
  68353. }
  68354. default: {
  68355. this._err(ERR.invalidFirstCharacterOfTagName);
  68356. this._createCommentToken(2);
  68357. this.state = State.BOGUS_COMMENT;
  68358. this._stateBogusComment(cp);
  68359. }
  68360. }
  68361. }
  68362. // Tag name state
  68363. //------------------------------------------------------------------
  68364. _stateTagName(cp) {
  68365. const token = this.currentToken;
  68366. switch (cp) {
  68367. case CODE_POINTS.SPACE:
  68368. case CODE_POINTS.LINE_FEED:
  68369. case CODE_POINTS.TABULATION:
  68370. case CODE_POINTS.FORM_FEED: {
  68371. this.state = State.BEFORE_ATTRIBUTE_NAME;
  68372. break;
  68373. }
  68374. case CODE_POINTS.SOLIDUS: {
  68375. this.state = State.SELF_CLOSING_START_TAG;
  68376. break;
  68377. }
  68378. case CODE_POINTS.GREATER_THAN_SIGN: {
  68379. this.state = State.DATA;
  68380. this.emitCurrentTagToken();
  68381. break;
  68382. }
  68383. case CODE_POINTS.NULL: {
  68384. this._err(ERR.unexpectedNullCharacter);
  68385. token.tagName += REPLACEMENT_CHARACTER;
  68386. break;
  68387. }
  68388. case CODE_POINTS.EOF: {
  68389. this._err(ERR.eofInTag);
  68390. this._emitEOFToken();
  68391. break;
  68392. }
  68393. default: {
  68394. token.tagName += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);
  68395. }
  68396. }
  68397. }
  68398. // RCDATA less-than sign state
  68399. //------------------------------------------------------------------
  68400. _stateRcdataLessThanSign(cp) {
  68401. if (cp === CODE_POINTS.SOLIDUS) {
  68402. this.state = State.RCDATA_END_TAG_OPEN;
  68403. }
  68404. else {
  68405. this._emitChars('<');
  68406. this.state = State.RCDATA;
  68407. this._stateRcdata(cp);
  68408. }
  68409. }
  68410. // RCDATA end tag open state
  68411. //------------------------------------------------------------------
  68412. _stateRcdataEndTagOpen(cp) {
  68413. if (isAsciiLetter(cp)) {
  68414. this.state = State.RCDATA_END_TAG_NAME;
  68415. this._stateRcdataEndTagName(cp);
  68416. }
  68417. else {
  68418. this._emitChars('</');
  68419. this.state = State.RCDATA;
  68420. this._stateRcdata(cp);
  68421. }
  68422. }
  68423. handleSpecialEndTag(_cp) {
  68424. if (!this.preprocessor.startsWith(this.lastStartTagName, false)) {
  68425. return !this._ensureHibernation();
  68426. }
  68427. this._createEndTagToken();
  68428. const token = this.currentToken;
  68429. token.tagName = this.lastStartTagName;
  68430. const cp = this.preprocessor.peek(this.lastStartTagName.length);
  68431. switch (cp) {
  68432. case CODE_POINTS.SPACE:
  68433. case CODE_POINTS.LINE_FEED:
  68434. case CODE_POINTS.TABULATION:
  68435. case CODE_POINTS.FORM_FEED: {
  68436. this._advanceBy(this.lastStartTagName.length);
  68437. this.state = State.BEFORE_ATTRIBUTE_NAME;
  68438. return false;
  68439. }
  68440. case CODE_POINTS.SOLIDUS: {
  68441. this._advanceBy(this.lastStartTagName.length);
  68442. this.state = State.SELF_CLOSING_START_TAG;
  68443. return false;
  68444. }
  68445. case CODE_POINTS.GREATER_THAN_SIGN: {
  68446. this._advanceBy(this.lastStartTagName.length);
  68447. this.emitCurrentTagToken();
  68448. this.state = State.DATA;
  68449. return false;
  68450. }
  68451. default: {
  68452. return !this._ensureHibernation();
  68453. }
  68454. }
  68455. }
  68456. // RCDATA end tag name state
  68457. //------------------------------------------------------------------
  68458. _stateRcdataEndTagName(cp) {
  68459. if (this.handleSpecialEndTag(cp)) {
  68460. this._emitChars('</');
  68461. this.state = State.RCDATA;
  68462. this._stateRcdata(cp);
  68463. }
  68464. }
  68465. // RAWTEXT less-than sign state
  68466. //------------------------------------------------------------------
  68467. _stateRawtextLessThanSign(cp) {
  68468. if (cp === CODE_POINTS.SOLIDUS) {
  68469. this.state = State.RAWTEXT_END_TAG_OPEN;
  68470. }
  68471. else {
  68472. this._emitChars('<');
  68473. this.state = State.RAWTEXT;
  68474. this._stateRawtext(cp);
  68475. }
  68476. }
  68477. // RAWTEXT end tag open state
  68478. //------------------------------------------------------------------
  68479. _stateRawtextEndTagOpen(cp) {
  68480. if (isAsciiLetter(cp)) {
  68481. this.state = State.RAWTEXT_END_TAG_NAME;
  68482. this._stateRawtextEndTagName(cp);
  68483. }
  68484. else {
  68485. this._emitChars('</');
  68486. this.state = State.RAWTEXT;
  68487. this._stateRawtext(cp);
  68488. }
  68489. }
  68490. // RAWTEXT end tag name state
  68491. //------------------------------------------------------------------
  68492. _stateRawtextEndTagName(cp) {
  68493. if (this.handleSpecialEndTag(cp)) {
  68494. this._emitChars('</');
  68495. this.state = State.RAWTEXT;
  68496. this._stateRawtext(cp);
  68497. }
  68498. }
  68499. // Script data less-than sign state
  68500. //------------------------------------------------------------------
  68501. _stateScriptDataLessThanSign(cp) {
  68502. switch (cp) {
  68503. case CODE_POINTS.SOLIDUS: {
  68504. this.state = State.SCRIPT_DATA_END_TAG_OPEN;
  68505. break;
  68506. }
  68507. case CODE_POINTS.EXCLAMATION_MARK: {
  68508. this.state = State.SCRIPT_DATA_ESCAPE_START;
  68509. this._emitChars('<!');
  68510. break;
  68511. }
  68512. default: {
  68513. this._emitChars('<');
  68514. this.state = State.SCRIPT_DATA;
  68515. this._stateScriptData(cp);
  68516. }
  68517. }
  68518. }
  68519. // Script data end tag open state
  68520. //------------------------------------------------------------------
  68521. _stateScriptDataEndTagOpen(cp) {
  68522. if (isAsciiLetter(cp)) {
  68523. this.state = State.SCRIPT_DATA_END_TAG_NAME;
  68524. this._stateScriptDataEndTagName(cp);
  68525. }
  68526. else {
  68527. this._emitChars('</');
  68528. this.state = State.SCRIPT_DATA;
  68529. this._stateScriptData(cp);
  68530. }
  68531. }
  68532. // Script data end tag name state
  68533. //------------------------------------------------------------------
  68534. _stateScriptDataEndTagName(cp) {
  68535. if (this.handleSpecialEndTag(cp)) {
  68536. this._emitChars('</');
  68537. this.state = State.SCRIPT_DATA;
  68538. this._stateScriptData(cp);
  68539. }
  68540. }
  68541. // Script data escape start state
  68542. //------------------------------------------------------------------
  68543. _stateScriptDataEscapeStart(cp) {
  68544. if (cp === CODE_POINTS.HYPHEN_MINUS) {
  68545. this.state = State.SCRIPT_DATA_ESCAPE_START_DASH;
  68546. this._emitChars('-');
  68547. }
  68548. else {
  68549. this.state = State.SCRIPT_DATA;
  68550. this._stateScriptData(cp);
  68551. }
  68552. }
  68553. // Script data escape start dash state
  68554. //------------------------------------------------------------------
  68555. _stateScriptDataEscapeStartDash(cp) {
  68556. if (cp === CODE_POINTS.HYPHEN_MINUS) {
  68557. this.state = State.SCRIPT_DATA_ESCAPED_DASH_DASH;
  68558. this._emitChars('-');
  68559. }
  68560. else {
  68561. this.state = State.SCRIPT_DATA;
  68562. this._stateScriptData(cp);
  68563. }
  68564. }
  68565. // Script data escaped state
  68566. //------------------------------------------------------------------
  68567. _stateScriptDataEscaped(cp) {
  68568. switch (cp) {
  68569. case CODE_POINTS.HYPHEN_MINUS: {
  68570. this.state = State.SCRIPT_DATA_ESCAPED_DASH;
  68571. this._emitChars('-');
  68572. break;
  68573. }
  68574. case CODE_POINTS.LESS_THAN_SIGN: {
  68575. this.state = State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;
  68576. break;
  68577. }
  68578. case CODE_POINTS.NULL: {
  68579. this._err(ERR.unexpectedNullCharacter);
  68580. this._emitChars(REPLACEMENT_CHARACTER);
  68581. break;
  68582. }
  68583. case CODE_POINTS.EOF: {
  68584. this._err(ERR.eofInScriptHtmlCommentLikeText);
  68585. this._emitEOFToken();
  68586. break;
  68587. }
  68588. default: {
  68589. this._emitCodePoint(cp);
  68590. }
  68591. }
  68592. }
  68593. // Script data escaped dash state
  68594. //------------------------------------------------------------------
  68595. _stateScriptDataEscapedDash(cp) {
  68596. switch (cp) {
  68597. case CODE_POINTS.HYPHEN_MINUS: {
  68598. this.state = State.SCRIPT_DATA_ESCAPED_DASH_DASH;
  68599. this._emitChars('-');
  68600. break;
  68601. }
  68602. case CODE_POINTS.LESS_THAN_SIGN: {
  68603. this.state = State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;
  68604. break;
  68605. }
  68606. case CODE_POINTS.NULL: {
  68607. this._err(ERR.unexpectedNullCharacter);
  68608. this.state = State.SCRIPT_DATA_ESCAPED;
  68609. this._emitChars(REPLACEMENT_CHARACTER);
  68610. break;
  68611. }
  68612. case CODE_POINTS.EOF: {
  68613. this._err(ERR.eofInScriptHtmlCommentLikeText);
  68614. this._emitEOFToken();
  68615. break;
  68616. }
  68617. default: {
  68618. this.state = State.SCRIPT_DATA_ESCAPED;
  68619. this._emitCodePoint(cp);
  68620. }
  68621. }
  68622. }
  68623. // Script data escaped dash dash state
  68624. //------------------------------------------------------------------
  68625. _stateScriptDataEscapedDashDash(cp) {
  68626. switch (cp) {
  68627. case CODE_POINTS.HYPHEN_MINUS: {
  68628. this._emitChars('-');
  68629. break;
  68630. }
  68631. case CODE_POINTS.LESS_THAN_SIGN: {
  68632. this.state = State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;
  68633. break;
  68634. }
  68635. case CODE_POINTS.GREATER_THAN_SIGN: {
  68636. this.state = State.SCRIPT_DATA;
  68637. this._emitChars('>');
  68638. break;
  68639. }
  68640. case CODE_POINTS.NULL: {
  68641. this._err(ERR.unexpectedNullCharacter);
  68642. this.state = State.SCRIPT_DATA_ESCAPED;
  68643. this._emitChars(REPLACEMENT_CHARACTER);
  68644. break;
  68645. }
  68646. case CODE_POINTS.EOF: {
  68647. this._err(ERR.eofInScriptHtmlCommentLikeText);
  68648. this._emitEOFToken();
  68649. break;
  68650. }
  68651. default: {
  68652. this.state = State.SCRIPT_DATA_ESCAPED;
  68653. this._emitCodePoint(cp);
  68654. }
  68655. }
  68656. }
  68657. // Script data escaped less-than sign state
  68658. //------------------------------------------------------------------
  68659. _stateScriptDataEscapedLessThanSign(cp) {
  68660. if (cp === CODE_POINTS.SOLIDUS) {
  68661. this.state = State.SCRIPT_DATA_ESCAPED_END_TAG_OPEN;
  68662. }
  68663. else if (isAsciiLetter(cp)) {
  68664. this._emitChars('<');
  68665. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPE_START;
  68666. this._stateScriptDataDoubleEscapeStart(cp);
  68667. }
  68668. else {
  68669. this._emitChars('<');
  68670. this.state = State.SCRIPT_DATA_ESCAPED;
  68671. this._stateScriptDataEscaped(cp);
  68672. }
  68673. }
  68674. // Script data escaped end tag open state
  68675. //------------------------------------------------------------------
  68676. _stateScriptDataEscapedEndTagOpen(cp) {
  68677. if (isAsciiLetter(cp)) {
  68678. this.state = State.SCRIPT_DATA_ESCAPED_END_TAG_NAME;
  68679. this._stateScriptDataEscapedEndTagName(cp);
  68680. }
  68681. else {
  68682. this._emitChars('</');
  68683. this.state = State.SCRIPT_DATA_ESCAPED;
  68684. this._stateScriptDataEscaped(cp);
  68685. }
  68686. }
  68687. // Script data escaped end tag name state
  68688. //------------------------------------------------------------------
  68689. _stateScriptDataEscapedEndTagName(cp) {
  68690. if (this.handleSpecialEndTag(cp)) {
  68691. this._emitChars('</');
  68692. this.state = State.SCRIPT_DATA_ESCAPED;
  68693. this._stateScriptDataEscaped(cp);
  68694. }
  68695. }
  68696. // Script data double escape start state
  68697. //------------------------------------------------------------------
  68698. _stateScriptDataDoubleEscapeStart(cp) {
  68699. if (this.preprocessor.startsWith(SEQUENCES.SCRIPT, false) &&
  68700. isScriptDataDoubleEscapeSequenceEnd(this.preprocessor.peek(SEQUENCES.SCRIPT.length))) {
  68701. this._emitCodePoint(cp);
  68702. for (let i = 0; i < SEQUENCES.SCRIPT.length; i++) {
  68703. this._emitCodePoint(this._consume());
  68704. }
  68705. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
  68706. }
  68707. else if (!this._ensureHibernation()) {
  68708. this.state = State.SCRIPT_DATA_ESCAPED;
  68709. this._stateScriptDataEscaped(cp);
  68710. }
  68711. }
  68712. // Script data double escaped state
  68713. //------------------------------------------------------------------
  68714. _stateScriptDataDoubleEscaped(cp) {
  68715. switch (cp) {
  68716. case CODE_POINTS.HYPHEN_MINUS: {
  68717. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH;
  68718. this._emitChars('-');
  68719. break;
  68720. }
  68721. case CODE_POINTS.LESS_THAN_SIGN: {
  68722. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN;
  68723. this._emitChars('<');
  68724. break;
  68725. }
  68726. case CODE_POINTS.NULL: {
  68727. this._err(ERR.unexpectedNullCharacter);
  68728. this._emitChars(REPLACEMENT_CHARACTER);
  68729. break;
  68730. }
  68731. case CODE_POINTS.EOF: {
  68732. this._err(ERR.eofInScriptHtmlCommentLikeText);
  68733. this._emitEOFToken();
  68734. break;
  68735. }
  68736. default: {
  68737. this._emitCodePoint(cp);
  68738. }
  68739. }
  68740. }
  68741. // Script data double escaped dash state
  68742. //------------------------------------------------------------------
  68743. _stateScriptDataDoubleEscapedDash(cp) {
  68744. switch (cp) {
  68745. case CODE_POINTS.HYPHEN_MINUS: {
  68746. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH;
  68747. this._emitChars('-');
  68748. break;
  68749. }
  68750. case CODE_POINTS.LESS_THAN_SIGN: {
  68751. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN;
  68752. this._emitChars('<');
  68753. break;
  68754. }
  68755. case CODE_POINTS.NULL: {
  68756. this._err(ERR.unexpectedNullCharacter);
  68757. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
  68758. this._emitChars(REPLACEMENT_CHARACTER);
  68759. break;
  68760. }
  68761. case CODE_POINTS.EOF: {
  68762. this._err(ERR.eofInScriptHtmlCommentLikeText);
  68763. this._emitEOFToken();
  68764. break;
  68765. }
  68766. default: {
  68767. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
  68768. this._emitCodePoint(cp);
  68769. }
  68770. }
  68771. }
  68772. // Script data double escaped dash dash state
  68773. //------------------------------------------------------------------
  68774. _stateScriptDataDoubleEscapedDashDash(cp) {
  68775. switch (cp) {
  68776. case CODE_POINTS.HYPHEN_MINUS: {
  68777. this._emitChars('-');
  68778. break;
  68779. }
  68780. case CODE_POINTS.LESS_THAN_SIGN: {
  68781. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN;
  68782. this._emitChars('<');
  68783. break;
  68784. }
  68785. case CODE_POINTS.GREATER_THAN_SIGN: {
  68786. this.state = State.SCRIPT_DATA;
  68787. this._emitChars('>');
  68788. break;
  68789. }
  68790. case CODE_POINTS.NULL: {
  68791. this._err(ERR.unexpectedNullCharacter);
  68792. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
  68793. this._emitChars(REPLACEMENT_CHARACTER);
  68794. break;
  68795. }
  68796. case CODE_POINTS.EOF: {
  68797. this._err(ERR.eofInScriptHtmlCommentLikeText);
  68798. this._emitEOFToken();
  68799. break;
  68800. }
  68801. default: {
  68802. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
  68803. this._emitCodePoint(cp);
  68804. }
  68805. }
  68806. }
  68807. // Script data double escaped less-than sign state
  68808. //------------------------------------------------------------------
  68809. _stateScriptDataDoubleEscapedLessThanSign(cp) {
  68810. if (cp === CODE_POINTS.SOLIDUS) {
  68811. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPE_END;
  68812. this._emitChars('/');
  68813. }
  68814. else {
  68815. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
  68816. this._stateScriptDataDoubleEscaped(cp);
  68817. }
  68818. }
  68819. // Script data double escape end state
  68820. //------------------------------------------------------------------
  68821. _stateScriptDataDoubleEscapeEnd(cp) {
  68822. if (this.preprocessor.startsWith(SEQUENCES.SCRIPT, false) &&
  68823. isScriptDataDoubleEscapeSequenceEnd(this.preprocessor.peek(SEQUENCES.SCRIPT.length))) {
  68824. this._emitCodePoint(cp);
  68825. for (let i = 0; i < SEQUENCES.SCRIPT.length; i++) {
  68826. this._emitCodePoint(this._consume());
  68827. }
  68828. this.state = State.SCRIPT_DATA_ESCAPED;
  68829. }
  68830. else if (!this._ensureHibernation()) {
  68831. this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
  68832. this._stateScriptDataDoubleEscaped(cp);
  68833. }
  68834. }
  68835. // Before attribute name state
  68836. //------------------------------------------------------------------
  68837. _stateBeforeAttributeName(cp) {
  68838. switch (cp) {
  68839. case CODE_POINTS.SPACE:
  68840. case CODE_POINTS.LINE_FEED:
  68841. case CODE_POINTS.TABULATION:
  68842. case CODE_POINTS.FORM_FEED: {
  68843. // Ignore whitespace
  68844. break;
  68845. }
  68846. case CODE_POINTS.SOLIDUS:
  68847. case CODE_POINTS.GREATER_THAN_SIGN:
  68848. case CODE_POINTS.EOF: {
  68849. this.state = State.AFTER_ATTRIBUTE_NAME;
  68850. this._stateAfterAttributeName(cp);
  68851. break;
  68852. }
  68853. case CODE_POINTS.EQUALS_SIGN: {
  68854. this._err(ERR.unexpectedEqualsSignBeforeAttributeName);
  68855. this._createAttr('=');
  68856. this.state = State.ATTRIBUTE_NAME;
  68857. break;
  68858. }
  68859. default: {
  68860. this._createAttr('');
  68861. this.state = State.ATTRIBUTE_NAME;
  68862. this._stateAttributeName(cp);
  68863. }
  68864. }
  68865. }
  68866. // Attribute name state
  68867. //------------------------------------------------------------------
  68868. _stateAttributeName(cp) {
  68869. switch (cp) {
  68870. case CODE_POINTS.SPACE:
  68871. case CODE_POINTS.LINE_FEED:
  68872. case CODE_POINTS.TABULATION:
  68873. case CODE_POINTS.FORM_FEED:
  68874. case CODE_POINTS.SOLIDUS:
  68875. case CODE_POINTS.GREATER_THAN_SIGN:
  68876. case CODE_POINTS.EOF: {
  68877. this._leaveAttrName();
  68878. this.state = State.AFTER_ATTRIBUTE_NAME;
  68879. this._stateAfterAttributeName(cp);
  68880. break;
  68881. }
  68882. case CODE_POINTS.EQUALS_SIGN: {
  68883. this._leaveAttrName();
  68884. this.state = State.BEFORE_ATTRIBUTE_VALUE;
  68885. break;
  68886. }
  68887. case CODE_POINTS.QUOTATION_MARK:
  68888. case CODE_POINTS.APOSTROPHE:
  68889. case CODE_POINTS.LESS_THAN_SIGN: {
  68890. this._err(ERR.unexpectedCharacterInAttributeName);
  68891. this.currentAttr.name += String.fromCodePoint(cp);
  68892. break;
  68893. }
  68894. case CODE_POINTS.NULL: {
  68895. this._err(ERR.unexpectedNullCharacter);
  68896. this.currentAttr.name += REPLACEMENT_CHARACTER;
  68897. break;
  68898. }
  68899. default: {
  68900. this.currentAttr.name += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);
  68901. }
  68902. }
  68903. }
  68904. // After attribute name state
  68905. //------------------------------------------------------------------
  68906. _stateAfterAttributeName(cp) {
  68907. switch (cp) {
  68908. case CODE_POINTS.SPACE:
  68909. case CODE_POINTS.LINE_FEED:
  68910. case CODE_POINTS.TABULATION:
  68911. case CODE_POINTS.FORM_FEED: {
  68912. // Ignore whitespace
  68913. break;
  68914. }
  68915. case CODE_POINTS.SOLIDUS: {
  68916. this.state = State.SELF_CLOSING_START_TAG;
  68917. break;
  68918. }
  68919. case CODE_POINTS.EQUALS_SIGN: {
  68920. this.state = State.BEFORE_ATTRIBUTE_VALUE;
  68921. break;
  68922. }
  68923. case CODE_POINTS.GREATER_THAN_SIGN: {
  68924. this.state = State.DATA;
  68925. this.emitCurrentTagToken();
  68926. break;
  68927. }
  68928. case CODE_POINTS.EOF: {
  68929. this._err(ERR.eofInTag);
  68930. this._emitEOFToken();
  68931. break;
  68932. }
  68933. default: {
  68934. this._createAttr('');
  68935. this.state = State.ATTRIBUTE_NAME;
  68936. this._stateAttributeName(cp);
  68937. }
  68938. }
  68939. }
  68940. // Before attribute value state
  68941. //------------------------------------------------------------------
  68942. _stateBeforeAttributeValue(cp) {
  68943. switch (cp) {
  68944. case CODE_POINTS.SPACE:
  68945. case CODE_POINTS.LINE_FEED:
  68946. case CODE_POINTS.TABULATION:
  68947. case CODE_POINTS.FORM_FEED: {
  68948. // Ignore whitespace
  68949. break;
  68950. }
  68951. case CODE_POINTS.QUOTATION_MARK: {
  68952. this.state = State.ATTRIBUTE_VALUE_DOUBLE_QUOTED;
  68953. break;
  68954. }
  68955. case CODE_POINTS.APOSTROPHE: {
  68956. this.state = State.ATTRIBUTE_VALUE_SINGLE_QUOTED;
  68957. break;
  68958. }
  68959. case CODE_POINTS.GREATER_THAN_SIGN: {
  68960. this._err(ERR.missingAttributeValue);
  68961. this.state = State.DATA;
  68962. this.emitCurrentTagToken();
  68963. break;
  68964. }
  68965. default: {
  68966. this.state = State.ATTRIBUTE_VALUE_UNQUOTED;
  68967. this._stateAttributeValueUnquoted(cp);
  68968. }
  68969. }
  68970. }
  68971. // Attribute value (double-quoted) state
  68972. //------------------------------------------------------------------
  68973. _stateAttributeValueDoubleQuoted(cp) {
  68974. switch (cp) {
  68975. case CODE_POINTS.QUOTATION_MARK: {
  68976. this.state = State.AFTER_ATTRIBUTE_VALUE_QUOTED;
  68977. break;
  68978. }
  68979. case CODE_POINTS.AMPERSAND: {
  68980. this.returnState = State.ATTRIBUTE_VALUE_DOUBLE_QUOTED;
  68981. this.state = State.CHARACTER_REFERENCE;
  68982. break;
  68983. }
  68984. case CODE_POINTS.NULL: {
  68985. this._err(ERR.unexpectedNullCharacter);
  68986. this.currentAttr.value += REPLACEMENT_CHARACTER;
  68987. break;
  68988. }
  68989. case CODE_POINTS.EOF: {
  68990. this._err(ERR.eofInTag);
  68991. this._emitEOFToken();
  68992. break;
  68993. }
  68994. default: {
  68995. this.currentAttr.value += String.fromCodePoint(cp);
  68996. }
  68997. }
  68998. }
  68999. // Attribute value (single-quoted) state
  69000. //------------------------------------------------------------------
  69001. _stateAttributeValueSingleQuoted(cp) {
  69002. switch (cp) {
  69003. case CODE_POINTS.APOSTROPHE: {
  69004. this.state = State.AFTER_ATTRIBUTE_VALUE_QUOTED;
  69005. break;
  69006. }
  69007. case CODE_POINTS.AMPERSAND: {
  69008. this.returnState = State.ATTRIBUTE_VALUE_SINGLE_QUOTED;
  69009. this.state = State.CHARACTER_REFERENCE;
  69010. break;
  69011. }
  69012. case CODE_POINTS.NULL: {
  69013. this._err(ERR.unexpectedNullCharacter);
  69014. this.currentAttr.value += REPLACEMENT_CHARACTER;
  69015. break;
  69016. }
  69017. case CODE_POINTS.EOF: {
  69018. this._err(ERR.eofInTag);
  69019. this._emitEOFToken();
  69020. break;
  69021. }
  69022. default: {
  69023. this.currentAttr.value += String.fromCodePoint(cp);
  69024. }
  69025. }
  69026. }
  69027. // Attribute value (unquoted) state
  69028. //------------------------------------------------------------------
  69029. _stateAttributeValueUnquoted(cp) {
  69030. switch (cp) {
  69031. case CODE_POINTS.SPACE:
  69032. case CODE_POINTS.LINE_FEED:
  69033. case CODE_POINTS.TABULATION:
  69034. case CODE_POINTS.FORM_FEED: {
  69035. this._leaveAttrValue();
  69036. this.state = State.BEFORE_ATTRIBUTE_NAME;
  69037. break;
  69038. }
  69039. case CODE_POINTS.AMPERSAND: {
  69040. this.returnState = State.ATTRIBUTE_VALUE_UNQUOTED;
  69041. this.state = State.CHARACTER_REFERENCE;
  69042. break;
  69043. }
  69044. case CODE_POINTS.GREATER_THAN_SIGN: {
  69045. this._leaveAttrValue();
  69046. this.state = State.DATA;
  69047. this.emitCurrentTagToken();
  69048. break;
  69049. }
  69050. case CODE_POINTS.NULL: {
  69051. this._err(ERR.unexpectedNullCharacter);
  69052. this.currentAttr.value += REPLACEMENT_CHARACTER;
  69053. break;
  69054. }
  69055. case CODE_POINTS.QUOTATION_MARK:
  69056. case CODE_POINTS.APOSTROPHE:
  69057. case CODE_POINTS.LESS_THAN_SIGN:
  69058. case CODE_POINTS.EQUALS_SIGN:
  69059. case CODE_POINTS.GRAVE_ACCENT: {
  69060. this._err(ERR.unexpectedCharacterInUnquotedAttributeValue);
  69061. this.currentAttr.value += String.fromCodePoint(cp);
  69062. break;
  69063. }
  69064. case CODE_POINTS.EOF: {
  69065. this._err(ERR.eofInTag);
  69066. this._emitEOFToken();
  69067. break;
  69068. }
  69069. default: {
  69070. this.currentAttr.value += String.fromCodePoint(cp);
  69071. }
  69072. }
  69073. }
  69074. // After attribute value (quoted) state
  69075. //------------------------------------------------------------------
  69076. _stateAfterAttributeValueQuoted(cp) {
  69077. switch (cp) {
  69078. case CODE_POINTS.SPACE:
  69079. case CODE_POINTS.LINE_FEED:
  69080. case CODE_POINTS.TABULATION:
  69081. case CODE_POINTS.FORM_FEED: {
  69082. this._leaveAttrValue();
  69083. this.state = State.BEFORE_ATTRIBUTE_NAME;
  69084. break;
  69085. }
  69086. case CODE_POINTS.SOLIDUS: {
  69087. this._leaveAttrValue();
  69088. this.state = State.SELF_CLOSING_START_TAG;
  69089. break;
  69090. }
  69091. case CODE_POINTS.GREATER_THAN_SIGN: {
  69092. this._leaveAttrValue();
  69093. this.state = State.DATA;
  69094. this.emitCurrentTagToken();
  69095. break;
  69096. }
  69097. case CODE_POINTS.EOF: {
  69098. this._err(ERR.eofInTag);
  69099. this._emitEOFToken();
  69100. break;
  69101. }
  69102. default: {
  69103. this._err(ERR.missingWhitespaceBetweenAttributes);
  69104. this.state = State.BEFORE_ATTRIBUTE_NAME;
  69105. this._stateBeforeAttributeName(cp);
  69106. }
  69107. }
  69108. }
  69109. // Self-closing start tag state
  69110. //------------------------------------------------------------------
  69111. _stateSelfClosingStartTag(cp) {
  69112. switch (cp) {
  69113. case CODE_POINTS.GREATER_THAN_SIGN: {
  69114. const token = this.currentToken;
  69115. token.selfClosing = true;
  69116. this.state = State.DATA;
  69117. this.emitCurrentTagToken();
  69118. break;
  69119. }
  69120. case CODE_POINTS.EOF: {
  69121. this._err(ERR.eofInTag);
  69122. this._emitEOFToken();
  69123. break;
  69124. }
  69125. default: {
  69126. this._err(ERR.unexpectedSolidusInTag);
  69127. this.state = State.BEFORE_ATTRIBUTE_NAME;
  69128. this._stateBeforeAttributeName(cp);
  69129. }
  69130. }
  69131. }
  69132. // Bogus comment state
  69133. //------------------------------------------------------------------
  69134. _stateBogusComment(cp) {
  69135. const token = this.currentToken;
  69136. switch (cp) {
  69137. case CODE_POINTS.GREATER_THAN_SIGN: {
  69138. this.state = State.DATA;
  69139. this.emitCurrentComment(token);
  69140. break;
  69141. }
  69142. case CODE_POINTS.EOF: {
  69143. this.emitCurrentComment(token);
  69144. this._emitEOFToken();
  69145. break;
  69146. }
  69147. case CODE_POINTS.NULL: {
  69148. this._err(ERR.unexpectedNullCharacter);
  69149. token.data += REPLACEMENT_CHARACTER;
  69150. break;
  69151. }
  69152. default: {
  69153. token.data += String.fromCodePoint(cp);
  69154. }
  69155. }
  69156. }
  69157. // Markup declaration open state
  69158. //------------------------------------------------------------------
  69159. _stateMarkupDeclarationOpen(cp) {
  69160. if (this._consumeSequenceIfMatch(SEQUENCES.DASH_DASH, true)) {
  69161. this._createCommentToken(SEQUENCES.DASH_DASH.length + 1);
  69162. this.state = State.COMMENT_START;
  69163. }
  69164. else if (this._consumeSequenceIfMatch(SEQUENCES.DOCTYPE, false)) {
  69165. // NOTE: Doctypes tokens are created without fixed offsets. We keep track of the moment a doctype *might* start here.
  69166. this.currentLocation = this.getCurrentLocation(SEQUENCES.DOCTYPE.length + 1);
  69167. this.state = State.DOCTYPE;
  69168. }
  69169. else if (this._consumeSequenceIfMatch(SEQUENCES.CDATA_START, true)) {
  69170. if (this.inForeignNode) {
  69171. this.state = State.CDATA_SECTION;
  69172. }
  69173. else {
  69174. this._err(ERR.cdataInHtmlContent);
  69175. this._createCommentToken(SEQUENCES.CDATA_START.length + 1);
  69176. this.currentToken.data = '[CDATA[';
  69177. this.state = State.BOGUS_COMMENT;
  69178. }
  69179. }
  69180. //NOTE: Sequence lookups can be abrupted by hibernation. In that case, lookup
  69181. //results are no longer valid and we will need to start over.
  69182. else if (!this._ensureHibernation()) {
  69183. this._err(ERR.incorrectlyOpenedComment);
  69184. this._createCommentToken(2);
  69185. this.state = State.BOGUS_COMMENT;
  69186. this._stateBogusComment(cp);
  69187. }
  69188. }
  69189. // Comment start state
  69190. //------------------------------------------------------------------
  69191. _stateCommentStart(cp) {
  69192. switch (cp) {
  69193. case CODE_POINTS.HYPHEN_MINUS: {
  69194. this.state = State.COMMENT_START_DASH;
  69195. break;
  69196. }
  69197. case CODE_POINTS.GREATER_THAN_SIGN: {
  69198. this._err(ERR.abruptClosingOfEmptyComment);
  69199. this.state = State.DATA;
  69200. const token = this.currentToken;
  69201. this.emitCurrentComment(token);
  69202. break;
  69203. }
  69204. default: {
  69205. this.state = State.COMMENT;
  69206. this._stateComment(cp);
  69207. }
  69208. }
  69209. }
  69210. // Comment start dash state
  69211. //------------------------------------------------------------------
  69212. _stateCommentStartDash(cp) {
  69213. const token = this.currentToken;
  69214. switch (cp) {
  69215. case CODE_POINTS.HYPHEN_MINUS: {
  69216. this.state = State.COMMENT_END;
  69217. break;
  69218. }
  69219. case CODE_POINTS.GREATER_THAN_SIGN: {
  69220. this._err(ERR.abruptClosingOfEmptyComment);
  69221. this.state = State.DATA;
  69222. this.emitCurrentComment(token);
  69223. break;
  69224. }
  69225. case CODE_POINTS.EOF: {
  69226. this._err(ERR.eofInComment);
  69227. this.emitCurrentComment(token);
  69228. this._emitEOFToken();
  69229. break;
  69230. }
  69231. default: {
  69232. token.data += '-';
  69233. this.state = State.COMMENT;
  69234. this._stateComment(cp);
  69235. }
  69236. }
  69237. }
  69238. // Comment state
  69239. //------------------------------------------------------------------
  69240. _stateComment(cp) {
  69241. const token = this.currentToken;
  69242. switch (cp) {
  69243. case CODE_POINTS.HYPHEN_MINUS: {
  69244. this.state = State.COMMENT_END_DASH;
  69245. break;
  69246. }
  69247. case CODE_POINTS.LESS_THAN_SIGN: {
  69248. token.data += '<';
  69249. this.state = State.COMMENT_LESS_THAN_SIGN;
  69250. break;
  69251. }
  69252. case CODE_POINTS.NULL: {
  69253. this._err(ERR.unexpectedNullCharacter);
  69254. token.data += REPLACEMENT_CHARACTER;
  69255. break;
  69256. }
  69257. case CODE_POINTS.EOF: {
  69258. this._err(ERR.eofInComment);
  69259. this.emitCurrentComment(token);
  69260. this._emitEOFToken();
  69261. break;
  69262. }
  69263. default: {
  69264. token.data += String.fromCodePoint(cp);
  69265. }
  69266. }
  69267. }
  69268. // Comment less-than sign state
  69269. //------------------------------------------------------------------
  69270. _stateCommentLessThanSign(cp) {
  69271. const token = this.currentToken;
  69272. switch (cp) {
  69273. case CODE_POINTS.EXCLAMATION_MARK: {
  69274. token.data += '!';
  69275. this.state = State.COMMENT_LESS_THAN_SIGN_BANG;
  69276. break;
  69277. }
  69278. case CODE_POINTS.LESS_THAN_SIGN: {
  69279. token.data += '<';
  69280. break;
  69281. }
  69282. default: {
  69283. this.state = State.COMMENT;
  69284. this._stateComment(cp);
  69285. }
  69286. }
  69287. }
  69288. // Comment less-than sign bang state
  69289. //------------------------------------------------------------------
  69290. _stateCommentLessThanSignBang(cp) {
  69291. if (cp === CODE_POINTS.HYPHEN_MINUS) {
  69292. this.state = State.COMMENT_LESS_THAN_SIGN_BANG_DASH;
  69293. }
  69294. else {
  69295. this.state = State.COMMENT;
  69296. this._stateComment(cp);
  69297. }
  69298. }
  69299. // Comment less-than sign bang dash state
  69300. //------------------------------------------------------------------
  69301. _stateCommentLessThanSignBangDash(cp) {
  69302. if (cp === CODE_POINTS.HYPHEN_MINUS) {
  69303. this.state = State.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH;
  69304. }
  69305. else {
  69306. this.state = State.COMMENT_END_DASH;
  69307. this._stateCommentEndDash(cp);
  69308. }
  69309. }
  69310. // Comment less-than sign bang dash dash state
  69311. //------------------------------------------------------------------
  69312. _stateCommentLessThanSignBangDashDash(cp) {
  69313. if (cp !== CODE_POINTS.GREATER_THAN_SIGN && cp !== CODE_POINTS.EOF) {
  69314. this._err(ERR.nestedComment);
  69315. }
  69316. this.state = State.COMMENT_END;
  69317. this._stateCommentEnd(cp);
  69318. }
  69319. // Comment end dash state
  69320. //------------------------------------------------------------------
  69321. _stateCommentEndDash(cp) {
  69322. const token = this.currentToken;
  69323. switch (cp) {
  69324. case CODE_POINTS.HYPHEN_MINUS: {
  69325. this.state = State.COMMENT_END;
  69326. break;
  69327. }
  69328. case CODE_POINTS.EOF: {
  69329. this._err(ERR.eofInComment);
  69330. this.emitCurrentComment(token);
  69331. this._emitEOFToken();
  69332. break;
  69333. }
  69334. default: {
  69335. token.data += '-';
  69336. this.state = State.COMMENT;
  69337. this._stateComment(cp);
  69338. }
  69339. }
  69340. }
  69341. // Comment end state
  69342. //------------------------------------------------------------------
  69343. _stateCommentEnd(cp) {
  69344. const token = this.currentToken;
  69345. switch (cp) {
  69346. case CODE_POINTS.GREATER_THAN_SIGN: {
  69347. this.state = State.DATA;
  69348. this.emitCurrentComment(token);
  69349. break;
  69350. }
  69351. case CODE_POINTS.EXCLAMATION_MARK: {
  69352. this.state = State.COMMENT_END_BANG;
  69353. break;
  69354. }
  69355. case CODE_POINTS.HYPHEN_MINUS: {
  69356. token.data += '-';
  69357. break;
  69358. }
  69359. case CODE_POINTS.EOF: {
  69360. this._err(ERR.eofInComment);
  69361. this.emitCurrentComment(token);
  69362. this._emitEOFToken();
  69363. break;
  69364. }
  69365. default: {
  69366. token.data += '--';
  69367. this.state = State.COMMENT;
  69368. this._stateComment(cp);
  69369. }
  69370. }
  69371. }
  69372. // Comment end bang state
  69373. //------------------------------------------------------------------
  69374. _stateCommentEndBang(cp) {
  69375. const token = this.currentToken;
  69376. switch (cp) {
  69377. case CODE_POINTS.HYPHEN_MINUS: {
  69378. token.data += '--!';
  69379. this.state = State.COMMENT_END_DASH;
  69380. break;
  69381. }
  69382. case CODE_POINTS.GREATER_THAN_SIGN: {
  69383. this._err(ERR.incorrectlyClosedComment);
  69384. this.state = State.DATA;
  69385. this.emitCurrentComment(token);
  69386. break;
  69387. }
  69388. case CODE_POINTS.EOF: {
  69389. this._err(ERR.eofInComment);
  69390. this.emitCurrentComment(token);
  69391. this._emitEOFToken();
  69392. break;
  69393. }
  69394. default: {
  69395. token.data += '--!';
  69396. this.state = State.COMMENT;
  69397. this._stateComment(cp);
  69398. }
  69399. }
  69400. }
  69401. // DOCTYPE state
  69402. //------------------------------------------------------------------
  69403. _stateDoctype(cp) {
  69404. switch (cp) {
  69405. case CODE_POINTS.SPACE:
  69406. case CODE_POINTS.LINE_FEED:
  69407. case CODE_POINTS.TABULATION:
  69408. case CODE_POINTS.FORM_FEED: {
  69409. this.state = State.BEFORE_DOCTYPE_NAME;
  69410. break;
  69411. }
  69412. case CODE_POINTS.GREATER_THAN_SIGN: {
  69413. this.state = State.BEFORE_DOCTYPE_NAME;
  69414. this._stateBeforeDoctypeName(cp);
  69415. break;
  69416. }
  69417. case CODE_POINTS.EOF: {
  69418. this._err(ERR.eofInDoctype);
  69419. this._createDoctypeToken(null);
  69420. const token = this.currentToken;
  69421. token.forceQuirks = true;
  69422. this.emitCurrentDoctype(token);
  69423. this._emitEOFToken();
  69424. break;
  69425. }
  69426. default: {
  69427. this._err(ERR.missingWhitespaceBeforeDoctypeName);
  69428. this.state = State.BEFORE_DOCTYPE_NAME;
  69429. this._stateBeforeDoctypeName(cp);
  69430. }
  69431. }
  69432. }
  69433. // Before DOCTYPE name state
  69434. //------------------------------------------------------------------
  69435. _stateBeforeDoctypeName(cp) {
  69436. if (isAsciiUpper(cp)) {
  69437. this._createDoctypeToken(String.fromCharCode(toAsciiLower(cp)));
  69438. this.state = State.DOCTYPE_NAME;
  69439. }
  69440. else
  69441. switch (cp) {
  69442. case CODE_POINTS.SPACE:
  69443. case CODE_POINTS.LINE_FEED:
  69444. case CODE_POINTS.TABULATION:
  69445. case CODE_POINTS.FORM_FEED: {
  69446. // Ignore whitespace
  69447. break;
  69448. }
  69449. case CODE_POINTS.NULL: {
  69450. this._err(ERR.unexpectedNullCharacter);
  69451. this._createDoctypeToken(REPLACEMENT_CHARACTER);
  69452. this.state = State.DOCTYPE_NAME;
  69453. break;
  69454. }
  69455. case CODE_POINTS.GREATER_THAN_SIGN: {
  69456. this._err(ERR.missingDoctypeName);
  69457. this._createDoctypeToken(null);
  69458. const token = this.currentToken;
  69459. token.forceQuirks = true;
  69460. this.emitCurrentDoctype(token);
  69461. this.state = State.DATA;
  69462. break;
  69463. }
  69464. case CODE_POINTS.EOF: {
  69465. this._err(ERR.eofInDoctype);
  69466. this._createDoctypeToken(null);
  69467. const token = this.currentToken;
  69468. token.forceQuirks = true;
  69469. this.emitCurrentDoctype(token);
  69470. this._emitEOFToken();
  69471. break;
  69472. }
  69473. default: {
  69474. this._createDoctypeToken(String.fromCodePoint(cp));
  69475. this.state = State.DOCTYPE_NAME;
  69476. }
  69477. }
  69478. }
  69479. // DOCTYPE name state
  69480. //------------------------------------------------------------------
  69481. _stateDoctypeName(cp) {
  69482. const token = this.currentToken;
  69483. switch (cp) {
  69484. case CODE_POINTS.SPACE:
  69485. case CODE_POINTS.LINE_FEED:
  69486. case CODE_POINTS.TABULATION:
  69487. case CODE_POINTS.FORM_FEED: {
  69488. this.state = State.AFTER_DOCTYPE_NAME;
  69489. break;
  69490. }
  69491. case CODE_POINTS.GREATER_THAN_SIGN: {
  69492. this.state = State.DATA;
  69493. this.emitCurrentDoctype(token);
  69494. break;
  69495. }
  69496. case CODE_POINTS.NULL: {
  69497. this._err(ERR.unexpectedNullCharacter);
  69498. token.name += REPLACEMENT_CHARACTER;
  69499. break;
  69500. }
  69501. case CODE_POINTS.EOF: {
  69502. this._err(ERR.eofInDoctype);
  69503. token.forceQuirks = true;
  69504. this.emitCurrentDoctype(token);
  69505. this._emitEOFToken();
  69506. break;
  69507. }
  69508. default: {
  69509. token.name += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);
  69510. }
  69511. }
  69512. }
  69513. // After DOCTYPE name state
  69514. //------------------------------------------------------------------
  69515. _stateAfterDoctypeName(cp) {
  69516. const token = this.currentToken;
  69517. switch (cp) {
  69518. case CODE_POINTS.SPACE:
  69519. case CODE_POINTS.LINE_FEED:
  69520. case CODE_POINTS.TABULATION:
  69521. case CODE_POINTS.FORM_FEED: {
  69522. // Ignore whitespace
  69523. break;
  69524. }
  69525. case CODE_POINTS.GREATER_THAN_SIGN: {
  69526. this.state = State.DATA;
  69527. this.emitCurrentDoctype(token);
  69528. break;
  69529. }
  69530. case CODE_POINTS.EOF: {
  69531. this._err(ERR.eofInDoctype);
  69532. token.forceQuirks = true;
  69533. this.emitCurrentDoctype(token);
  69534. this._emitEOFToken();
  69535. break;
  69536. }
  69537. default:
  69538. if (this._consumeSequenceIfMatch(SEQUENCES.PUBLIC, false)) {
  69539. this.state = State.AFTER_DOCTYPE_PUBLIC_KEYWORD;
  69540. }
  69541. else if (this._consumeSequenceIfMatch(SEQUENCES.SYSTEM, false)) {
  69542. this.state = State.AFTER_DOCTYPE_SYSTEM_KEYWORD;
  69543. }
  69544. //NOTE: sequence lookup can be abrupted by hibernation. In that case lookup
  69545. //results are no longer valid and we will need to start over.
  69546. else if (!this._ensureHibernation()) {
  69547. this._err(ERR.invalidCharacterSequenceAfterDoctypeName);
  69548. token.forceQuirks = true;
  69549. this.state = State.BOGUS_DOCTYPE;
  69550. this._stateBogusDoctype(cp);
  69551. }
  69552. }
  69553. }
  69554. // After DOCTYPE public keyword state
  69555. //------------------------------------------------------------------
  69556. _stateAfterDoctypePublicKeyword(cp) {
  69557. const token = this.currentToken;
  69558. switch (cp) {
  69559. case CODE_POINTS.SPACE:
  69560. case CODE_POINTS.LINE_FEED:
  69561. case CODE_POINTS.TABULATION:
  69562. case CODE_POINTS.FORM_FEED: {
  69563. this.state = State.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;
  69564. break;
  69565. }
  69566. case CODE_POINTS.QUOTATION_MARK: {
  69567. this._err(ERR.missingWhitespaceAfterDoctypePublicKeyword);
  69568. token.publicId = '';
  69569. this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;
  69570. break;
  69571. }
  69572. case CODE_POINTS.APOSTROPHE: {
  69573. this._err(ERR.missingWhitespaceAfterDoctypePublicKeyword);
  69574. token.publicId = '';
  69575. this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;
  69576. break;
  69577. }
  69578. case CODE_POINTS.GREATER_THAN_SIGN: {
  69579. this._err(ERR.missingDoctypePublicIdentifier);
  69580. token.forceQuirks = true;
  69581. this.state = State.DATA;
  69582. this.emitCurrentDoctype(token);
  69583. break;
  69584. }
  69585. case CODE_POINTS.EOF: {
  69586. this._err(ERR.eofInDoctype);
  69587. token.forceQuirks = true;
  69588. this.emitCurrentDoctype(token);
  69589. this._emitEOFToken();
  69590. break;
  69591. }
  69592. default: {
  69593. this._err(ERR.missingQuoteBeforeDoctypePublicIdentifier);
  69594. token.forceQuirks = true;
  69595. this.state = State.BOGUS_DOCTYPE;
  69596. this._stateBogusDoctype(cp);
  69597. }
  69598. }
  69599. }
  69600. // Before DOCTYPE public identifier state
  69601. //------------------------------------------------------------------
  69602. _stateBeforeDoctypePublicIdentifier(cp) {
  69603. const token = this.currentToken;
  69604. switch (cp) {
  69605. case CODE_POINTS.SPACE:
  69606. case CODE_POINTS.LINE_FEED:
  69607. case CODE_POINTS.TABULATION:
  69608. case CODE_POINTS.FORM_FEED: {
  69609. // Ignore whitespace
  69610. break;
  69611. }
  69612. case CODE_POINTS.QUOTATION_MARK: {
  69613. token.publicId = '';
  69614. this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;
  69615. break;
  69616. }
  69617. case CODE_POINTS.APOSTROPHE: {
  69618. token.publicId = '';
  69619. this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;
  69620. break;
  69621. }
  69622. case CODE_POINTS.GREATER_THAN_SIGN: {
  69623. this._err(ERR.missingDoctypePublicIdentifier);
  69624. token.forceQuirks = true;
  69625. this.state = State.DATA;
  69626. this.emitCurrentDoctype(token);
  69627. break;
  69628. }
  69629. case CODE_POINTS.EOF: {
  69630. this._err(ERR.eofInDoctype);
  69631. token.forceQuirks = true;
  69632. this.emitCurrentDoctype(token);
  69633. this._emitEOFToken();
  69634. break;
  69635. }
  69636. default: {
  69637. this._err(ERR.missingQuoteBeforeDoctypePublicIdentifier);
  69638. token.forceQuirks = true;
  69639. this.state = State.BOGUS_DOCTYPE;
  69640. this._stateBogusDoctype(cp);
  69641. }
  69642. }
  69643. }
  69644. // DOCTYPE public identifier (double-quoted) state
  69645. //------------------------------------------------------------------
  69646. _stateDoctypePublicIdentifierDoubleQuoted(cp) {
  69647. const token = this.currentToken;
  69648. switch (cp) {
  69649. case CODE_POINTS.QUOTATION_MARK: {
  69650. this.state = State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;
  69651. break;
  69652. }
  69653. case CODE_POINTS.NULL: {
  69654. this._err(ERR.unexpectedNullCharacter);
  69655. token.publicId += REPLACEMENT_CHARACTER;
  69656. break;
  69657. }
  69658. case CODE_POINTS.GREATER_THAN_SIGN: {
  69659. this._err(ERR.abruptDoctypePublicIdentifier);
  69660. token.forceQuirks = true;
  69661. this.emitCurrentDoctype(token);
  69662. this.state = State.DATA;
  69663. break;
  69664. }
  69665. case CODE_POINTS.EOF: {
  69666. this._err(ERR.eofInDoctype);
  69667. token.forceQuirks = true;
  69668. this.emitCurrentDoctype(token);
  69669. this._emitEOFToken();
  69670. break;
  69671. }
  69672. default: {
  69673. token.publicId += String.fromCodePoint(cp);
  69674. }
  69675. }
  69676. }
  69677. // DOCTYPE public identifier (single-quoted) state
  69678. //------------------------------------------------------------------
  69679. _stateDoctypePublicIdentifierSingleQuoted(cp) {
  69680. const token = this.currentToken;
  69681. switch (cp) {
  69682. case CODE_POINTS.APOSTROPHE: {
  69683. this.state = State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;
  69684. break;
  69685. }
  69686. case CODE_POINTS.NULL: {
  69687. this._err(ERR.unexpectedNullCharacter);
  69688. token.publicId += REPLACEMENT_CHARACTER;
  69689. break;
  69690. }
  69691. case CODE_POINTS.GREATER_THAN_SIGN: {
  69692. this._err(ERR.abruptDoctypePublicIdentifier);
  69693. token.forceQuirks = true;
  69694. this.emitCurrentDoctype(token);
  69695. this.state = State.DATA;
  69696. break;
  69697. }
  69698. case CODE_POINTS.EOF: {
  69699. this._err(ERR.eofInDoctype);
  69700. token.forceQuirks = true;
  69701. this.emitCurrentDoctype(token);
  69702. this._emitEOFToken();
  69703. break;
  69704. }
  69705. default: {
  69706. token.publicId += String.fromCodePoint(cp);
  69707. }
  69708. }
  69709. }
  69710. // After DOCTYPE public identifier state
  69711. //------------------------------------------------------------------
  69712. _stateAfterDoctypePublicIdentifier(cp) {
  69713. const token = this.currentToken;
  69714. switch (cp) {
  69715. case CODE_POINTS.SPACE:
  69716. case CODE_POINTS.LINE_FEED:
  69717. case CODE_POINTS.TABULATION:
  69718. case CODE_POINTS.FORM_FEED: {
  69719. this.state = State.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;
  69720. break;
  69721. }
  69722. case CODE_POINTS.GREATER_THAN_SIGN: {
  69723. this.state = State.DATA;
  69724. this.emitCurrentDoctype(token);
  69725. break;
  69726. }
  69727. case CODE_POINTS.QUOTATION_MARK: {
  69728. this._err(ERR.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers);
  69729. token.systemId = '';
  69730. this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
  69731. break;
  69732. }
  69733. case CODE_POINTS.APOSTROPHE: {
  69734. this._err(ERR.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers);
  69735. token.systemId = '';
  69736. this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
  69737. break;
  69738. }
  69739. case CODE_POINTS.EOF: {
  69740. this._err(ERR.eofInDoctype);
  69741. token.forceQuirks = true;
  69742. this.emitCurrentDoctype(token);
  69743. this._emitEOFToken();
  69744. break;
  69745. }
  69746. default: {
  69747. this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
  69748. token.forceQuirks = true;
  69749. this.state = State.BOGUS_DOCTYPE;
  69750. this._stateBogusDoctype(cp);
  69751. }
  69752. }
  69753. }
  69754. // Between DOCTYPE public and system identifiers state
  69755. //------------------------------------------------------------------
  69756. _stateBetweenDoctypePublicAndSystemIdentifiers(cp) {
  69757. const token = this.currentToken;
  69758. switch (cp) {
  69759. case CODE_POINTS.SPACE:
  69760. case CODE_POINTS.LINE_FEED:
  69761. case CODE_POINTS.TABULATION:
  69762. case CODE_POINTS.FORM_FEED: {
  69763. // Ignore whitespace
  69764. break;
  69765. }
  69766. case CODE_POINTS.GREATER_THAN_SIGN: {
  69767. this.emitCurrentDoctype(token);
  69768. this.state = State.DATA;
  69769. break;
  69770. }
  69771. case CODE_POINTS.QUOTATION_MARK: {
  69772. token.systemId = '';
  69773. this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
  69774. break;
  69775. }
  69776. case CODE_POINTS.APOSTROPHE: {
  69777. token.systemId = '';
  69778. this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
  69779. break;
  69780. }
  69781. case CODE_POINTS.EOF: {
  69782. this._err(ERR.eofInDoctype);
  69783. token.forceQuirks = true;
  69784. this.emitCurrentDoctype(token);
  69785. this._emitEOFToken();
  69786. break;
  69787. }
  69788. default: {
  69789. this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
  69790. token.forceQuirks = true;
  69791. this.state = State.BOGUS_DOCTYPE;
  69792. this._stateBogusDoctype(cp);
  69793. }
  69794. }
  69795. }
  69796. // After DOCTYPE system keyword state
  69797. //------------------------------------------------------------------
  69798. _stateAfterDoctypeSystemKeyword(cp) {
  69799. const token = this.currentToken;
  69800. switch (cp) {
  69801. case CODE_POINTS.SPACE:
  69802. case CODE_POINTS.LINE_FEED:
  69803. case CODE_POINTS.TABULATION:
  69804. case CODE_POINTS.FORM_FEED: {
  69805. this.state = State.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;
  69806. break;
  69807. }
  69808. case CODE_POINTS.QUOTATION_MARK: {
  69809. this._err(ERR.missingWhitespaceAfterDoctypeSystemKeyword);
  69810. token.systemId = '';
  69811. this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
  69812. break;
  69813. }
  69814. case CODE_POINTS.APOSTROPHE: {
  69815. this._err(ERR.missingWhitespaceAfterDoctypeSystemKeyword);
  69816. token.systemId = '';
  69817. this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
  69818. break;
  69819. }
  69820. case CODE_POINTS.GREATER_THAN_SIGN: {
  69821. this._err(ERR.missingDoctypeSystemIdentifier);
  69822. token.forceQuirks = true;
  69823. this.state = State.DATA;
  69824. this.emitCurrentDoctype(token);
  69825. break;
  69826. }
  69827. case CODE_POINTS.EOF: {
  69828. this._err(ERR.eofInDoctype);
  69829. token.forceQuirks = true;
  69830. this.emitCurrentDoctype(token);
  69831. this._emitEOFToken();
  69832. break;
  69833. }
  69834. default: {
  69835. this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
  69836. token.forceQuirks = true;
  69837. this.state = State.BOGUS_DOCTYPE;
  69838. this._stateBogusDoctype(cp);
  69839. }
  69840. }
  69841. }
  69842. // Before DOCTYPE system identifier state
  69843. //------------------------------------------------------------------
  69844. _stateBeforeDoctypeSystemIdentifier(cp) {
  69845. const token = this.currentToken;
  69846. switch (cp) {
  69847. case CODE_POINTS.SPACE:
  69848. case CODE_POINTS.LINE_FEED:
  69849. case CODE_POINTS.TABULATION:
  69850. case CODE_POINTS.FORM_FEED: {
  69851. // Ignore whitespace
  69852. break;
  69853. }
  69854. case CODE_POINTS.QUOTATION_MARK: {
  69855. token.systemId = '';
  69856. this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
  69857. break;
  69858. }
  69859. case CODE_POINTS.APOSTROPHE: {
  69860. token.systemId = '';
  69861. this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
  69862. break;
  69863. }
  69864. case CODE_POINTS.GREATER_THAN_SIGN: {
  69865. this._err(ERR.missingDoctypeSystemIdentifier);
  69866. token.forceQuirks = true;
  69867. this.state = State.DATA;
  69868. this.emitCurrentDoctype(token);
  69869. break;
  69870. }
  69871. case CODE_POINTS.EOF: {
  69872. this._err(ERR.eofInDoctype);
  69873. token.forceQuirks = true;
  69874. this.emitCurrentDoctype(token);
  69875. this._emitEOFToken();
  69876. break;
  69877. }
  69878. default: {
  69879. this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
  69880. token.forceQuirks = true;
  69881. this.state = State.BOGUS_DOCTYPE;
  69882. this._stateBogusDoctype(cp);
  69883. }
  69884. }
  69885. }
  69886. // DOCTYPE system identifier (double-quoted) state
  69887. //------------------------------------------------------------------
  69888. _stateDoctypeSystemIdentifierDoubleQuoted(cp) {
  69889. const token = this.currentToken;
  69890. switch (cp) {
  69891. case CODE_POINTS.QUOTATION_MARK: {
  69892. this.state = State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;
  69893. break;
  69894. }
  69895. case CODE_POINTS.NULL: {
  69896. this._err(ERR.unexpectedNullCharacter);
  69897. token.systemId += REPLACEMENT_CHARACTER;
  69898. break;
  69899. }
  69900. case CODE_POINTS.GREATER_THAN_SIGN: {
  69901. this._err(ERR.abruptDoctypeSystemIdentifier);
  69902. token.forceQuirks = true;
  69903. this.emitCurrentDoctype(token);
  69904. this.state = State.DATA;
  69905. break;
  69906. }
  69907. case CODE_POINTS.EOF: {
  69908. this._err(ERR.eofInDoctype);
  69909. token.forceQuirks = true;
  69910. this.emitCurrentDoctype(token);
  69911. this._emitEOFToken();
  69912. break;
  69913. }
  69914. default: {
  69915. token.systemId += String.fromCodePoint(cp);
  69916. }
  69917. }
  69918. }
  69919. // DOCTYPE system identifier (single-quoted) state
  69920. //------------------------------------------------------------------
  69921. _stateDoctypeSystemIdentifierSingleQuoted(cp) {
  69922. const token = this.currentToken;
  69923. switch (cp) {
  69924. case CODE_POINTS.APOSTROPHE: {
  69925. this.state = State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;
  69926. break;
  69927. }
  69928. case CODE_POINTS.NULL: {
  69929. this._err(ERR.unexpectedNullCharacter);
  69930. token.systemId += REPLACEMENT_CHARACTER;
  69931. break;
  69932. }
  69933. case CODE_POINTS.GREATER_THAN_SIGN: {
  69934. this._err(ERR.abruptDoctypeSystemIdentifier);
  69935. token.forceQuirks = true;
  69936. this.emitCurrentDoctype(token);
  69937. this.state = State.DATA;
  69938. break;
  69939. }
  69940. case CODE_POINTS.EOF: {
  69941. this._err(ERR.eofInDoctype);
  69942. token.forceQuirks = true;
  69943. this.emitCurrentDoctype(token);
  69944. this._emitEOFToken();
  69945. break;
  69946. }
  69947. default: {
  69948. token.systemId += String.fromCodePoint(cp);
  69949. }
  69950. }
  69951. }
  69952. // After DOCTYPE system identifier state
  69953. //------------------------------------------------------------------
  69954. _stateAfterDoctypeSystemIdentifier(cp) {
  69955. const token = this.currentToken;
  69956. switch (cp) {
  69957. case CODE_POINTS.SPACE:
  69958. case CODE_POINTS.LINE_FEED:
  69959. case CODE_POINTS.TABULATION:
  69960. case CODE_POINTS.FORM_FEED: {
  69961. // Ignore whitespace
  69962. break;
  69963. }
  69964. case CODE_POINTS.GREATER_THAN_SIGN: {
  69965. this.emitCurrentDoctype(token);
  69966. this.state = State.DATA;
  69967. break;
  69968. }
  69969. case CODE_POINTS.EOF: {
  69970. this._err(ERR.eofInDoctype);
  69971. token.forceQuirks = true;
  69972. this.emitCurrentDoctype(token);
  69973. this._emitEOFToken();
  69974. break;
  69975. }
  69976. default: {
  69977. this._err(ERR.unexpectedCharacterAfterDoctypeSystemIdentifier);
  69978. this.state = State.BOGUS_DOCTYPE;
  69979. this._stateBogusDoctype(cp);
  69980. }
  69981. }
  69982. }
  69983. // Bogus DOCTYPE state
  69984. //------------------------------------------------------------------
  69985. _stateBogusDoctype(cp) {
  69986. const token = this.currentToken;
  69987. switch (cp) {
  69988. case CODE_POINTS.GREATER_THAN_SIGN: {
  69989. this.emitCurrentDoctype(token);
  69990. this.state = State.DATA;
  69991. break;
  69992. }
  69993. case CODE_POINTS.NULL: {
  69994. this._err(ERR.unexpectedNullCharacter);
  69995. break;
  69996. }
  69997. case CODE_POINTS.EOF: {
  69998. this.emitCurrentDoctype(token);
  69999. this._emitEOFToken();
  70000. break;
  70001. }
  70002. // Do nothing
  70003. }
  70004. }
  70005. // CDATA section state
  70006. //------------------------------------------------------------------
  70007. _stateCdataSection(cp) {
  70008. switch (cp) {
  70009. case CODE_POINTS.RIGHT_SQUARE_BRACKET: {
  70010. this.state = State.CDATA_SECTION_BRACKET;
  70011. break;
  70012. }
  70013. case CODE_POINTS.EOF: {
  70014. this._err(ERR.eofInCdata);
  70015. this._emitEOFToken();
  70016. break;
  70017. }
  70018. default: {
  70019. this._emitCodePoint(cp);
  70020. }
  70021. }
  70022. }
  70023. // CDATA section bracket state
  70024. //------------------------------------------------------------------
  70025. _stateCdataSectionBracket(cp) {
  70026. if (cp === CODE_POINTS.RIGHT_SQUARE_BRACKET) {
  70027. this.state = State.CDATA_SECTION_END;
  70028. }
  70029. else {
  70030. this._emitChars(']');
  70031. this.state = State.CDATA_SECTION;
  70032. this._stateCdataSection(cp);
  70033. }
  70034. }
  70035. // CDATA section end state
  70036. //------------------------------------------------------------------
  70037. _stateCdataSectionEnd(cp) {
  70038. switch (cp) {
  70039. case CODE_POINTS.GREATER_THAN_SIGN: {
  70040. this.state = State.DATA;
  70041. break;
  70042. }
  70043. case CODE_POINTS.RIGHT_SQUARE_BRACKET: {
  70044. this._emitChars(']');
  70045. break;
  70046. }
  70047. default: {
  70048. this._emitChars(']]');
  70049. this.state = State.CDATA_SECTION;
  70050. this._stateCdataSection(cp);
  70051. }
  70052. }
  70053. }
  70054. // Character reference state
  70055. //------------------------------------------------------------------
  70056. _stateCharacterReference(cp) {
  70057. if (cp === CODE_POINTS.NUMBER_SIGN) {
  70058. this.state = State.NUMERIC_CHARACTER_REFERENCE;
  70059. }
  70060. else if (isAsciiAlphaNumeric(cp)) {
  70061. this.state = State.NAMED_CHARACTER_REFERENCE;
  70062. this._stateNamedCharacterReference(cp);
  70063. }
  70064. else {
  70065. this._flushCodePointConsumedAsCharacterReference(CODE_POINTS.AMPERSAND);
  70066. this._reconsumeInState(this.returnState);
  70067. }
  70068. }
  70069. // Named character reference state
  70070. //------------------------------------------------------------------
  70071. _stateNamedCharacterReference(cp) {
  70072. const matchResult = this._matchNamedCharacterReference(cp);
  70073. //NOTE: Matching can be abrupted by hibernation. In that case, match
  70074. //results are no longer valid and we will need to start over.
  70075. if (this._ensureHibernation()) ;
  70076. else if (matchResult) {
  70077. for (let i = 0; i < matchResult.length; i++) {
  70078. this._flushCodePointConsumedAsCharacterReference(matchResult[i]);
  70079. }
  70080. this.state = this.returnState;
  70081. }
  70082. else {
  70083. this._flushCodePointConsumedAsCharacterReference(CODE_POINTS.AMPERSAND);
  70084. this.state = State.AMBIGUOUS_AMPERSAND;
  70085. }
  70086. }
  70087. // Ambiguos ampersand state
  70088. //------------------------------------------------------------------
  70089. _stateAmbiguousAmpersand(cp) {
  70090. if (isAsciiAlphaNumeric(cp)) {
  70091. this._flushCodePointConsumedAsCharacterReference(cp);
  70092. }
  70093. else {
  70094. if (cp === CODE_POINTS.SEMICOLON) {
  70095. this._err(ERR.unknownNamedCharacterReference);
  70096. }
  70097. this._reconsumeInState(this.returnState);
  70098. }
  70099. }
  70100. // Numeric character reference state
  70101. //------------------------------------------------------------------
  70102. _stateNumericCharacterReference(cp) {
  70103. this.charRefCode = 0;
  70104. if (cp === CODE_POINTS.LATIN_SMALL_X || cp === CODE_POINTS.LATIN_CAPITAL_X) {
  70105. this.state = State.HEXADEMICAL_CHARACTER_REFERENCE_START;
  70106. }
  70107. else {
  70108. this.state = State.DECIMAL_CHARACTER_REFERENCE_START;
  70109. this._stateDecimalCharacterReferenceStart(cp);
  70110. }
  70111. }
  70112. // Hexademical character reference start state
  70113. //------------------------------------------------------------------
  70114. _stateHexademicalCharacterReferenceStart(cp) {
  70115. if (isAsciiHexDigit(cp)) {
  70116. this.state = State.HEXADEMICAL_CHARACTER_REFERENCE;
  70117. this._stateHexademicalCharacterReference(cp);
  70118. }
  70119. else {
  70120. this._err(ERR.absenceOfDigitsInNumericCharacterReference);
  70121. this._flushCodePointConsumedAsCharacterReference(CODE_POINTS.AMPERSAND);
  70122. this._flushCodePointConsumedAsCharacterReference(CODE_POINTS.NUMBER_SIGN);
  70123. this._unconsume(2);
  70124. this.state = this.returnState;
  70125. }
  70126. }
  70127. // Decimal character reference start state
  70128. //------------------------------------------------------------------
  70129. _stateDecimalCharacterReferenceStart(cp) {
  70130. if (isAsciiDigit(cp)) {
  70131. this.state = State.DECIMAL_CHARACTER_REFERENCE;
  70132. this._stateDecimalCharacterReference(cp);
  70133. }
  70134. else {
  70135. this._err(ERR.absenceOfDigitsInNumericCharacterReference);
  70136. this._flushCodePointConsumedAsCharacterReference(CODE_POINTS.AMPERSAND);
  70137. this._flushCodePointConsumedAsCharacterReference(CODE_POINTS.NUMBER_SIGN);
  70138. this._reconsumeInState(this.returnState);
  70139. }
  70140. }
  70141. // Hexademical character reference state
  70142. //------------------------------------------------------------------
  70143. _stateHexademicalCharacterReference(cp) {
  70144. if (isAsciiUpperHexDigit(cp)) {
  70145. this.charRefCode = this.charRefCode * 16 + cp - 0x37;
  70146. }
  70147. else if (isAsciiLowerHexDigit(cp)) {
  70148. this.charRefCode = this.charRefCode * 16 + cp - 0x57;
  70149. }
  70150. else if (isAsciiDigit(cp)) {
  70151. this.charRefCode = this.charRefCode * 16 + cp - 0x30;
  70152. }
  70153. else if (cp === CODE_POINTS.SEMICOLON) {
  70154. this.state = State.NUMERIC_CHARACTER_REFERENCE_END;
  70155. }
  70156. else {
  70157. this._err(ERR.missingSemicolonAfterCharacterReference);
  70158. this.state = State.NUMERIC_CHARACTER_REFERENCE_END;
  70159. this._stateNumericCharacterReferenceEnd();
  70160. }
  70161. }
  70162. // Decimal character reference state
  70163. //------------------------------------------------------------------
  70164. _stateDecimalCharacterReference(cp) {
  70165. if (isAsciiDigit(cp)) {
  70166. this.charRefCode = this.charRefCode * 10 + cp - 0x30;
  70167. }
  70168. else if (cp === CODE_POINTS.SEMICOLON) {
  70169. this.state = State.NUMERIC_CHARACTER_REFERENCE_END;
  70170. }
  70171. else {
  70172. this._err(ERR.missingSemicolonAfterCharacterReference);
  70173. this.state = State.NUMERIC_CHARACTER_REFERENCE_END;
  70174. this._stateNumericCharacterReferenceEnd();
  70175. }
  70176. }
  70177. // Numeric character reference end state
  70178. //------------------------------------------------------------------
  70179. _stateNumericCharacterReferenceEnd() {
  70180. if (this.charRefCode === CODE_POINTS.NULL) {
  70181. this._err(ERR.nullCharacterReference);
  70182. this.charRefCode = CODE_POINTS.REPLACEMENT_CHARACTER;
  70183. }
  70184. else if (this.charRefCode > 1114111) {
  70185. this._err(ERR.characterReferenceOutsideUnicodeRange);
  70186. this.charRefCode = CODE_POINTS.REPLACEMENT_CHARACTER;
  70187. }
  70188. else if (isSurrogate(this.charRefCode)) {
  70189. this._err(ERR.surrogateCharacterReference);
  70190. this.charRefCode = CODE_POINTS.REPLACEMENT_CHARACTER;
  70191. }
  70192. else if (isUndefinedCodePoint(this.charRefCode)) {
  70193. this._err(ERR.noncharacterCharacterReference);
  70194. }
  70195. else if (isControlCodePoint(this.charRefCode) || this.charRefCode === CODE_POINTS.CARRIAGE_RETURN) {
  70196. this._err(ERR.controlCharacterReference);
  70197. const replacement = C1_CONTROLS_REFERENCE_REPLACEMENTS.get(this.charRefCode);
  70198. if (replacement !== undefined) {
  70199. this.charRefCode = replacement;
  70200. }
  70201. }
  70202. this._flushCodePointConsumedAsCharacterReference(this.charRefCode);
  70203. this._reconsumeInState(this.returnState);
  70204. }
  70205. }
  70206. //Element utils
  70207. const IMPLICIT_END_TAG_REQUIRED = new Set([TAG_ID.DD, TAG_ID.DT, TAG_ID.LI, TAG_ID.OPTGROUP, TAG_ID.OPTION, TAG_ID.P, TAG_ID.RB, TAG_ID.RP, TAG_ID.RT, TAG_ID.RTC]);
  70208. const IMPLICIT_END_TAG_REQUIRED_THOROUGHLY = new Set([
  70209. ...IMPLICIT_END_TAG_REQUIRED,
  70210. TAG_ID.CAPTION,
  70211. TAG_ID.COLGROUP,
  70212. TAG_ID.TBODY,
  70213. TAG_ID.TD,
  70214. TAG_ID.TFOOT,
  70215. TAG_ID.TH,
  70216. TAG_ID.THEAD,
  70217. TAG_ID.TR,
  70218. ]);
  70219. const SCOPING_ELEMENT_NS = new Map([
  70220. [TAG_ID.APPLET, NS.HTML],
  70221. [TAG_ID.CAPTION, NS.HTML],
  70222. [TAG_ID.HTML, NS.HTML],
  70223. [TAG_ID.MARQUEE, NS.HTML],
  70224. [TAG_ID.OBJECT, NS.HTML],
  70225. [TAG_ID.TABLE, NS.HTML],
  70226. [TAG_ID.TD, NS.HTML],
  70227. [TAG_ID.TEMPLATE, NS.HTML],
  70228. [TAG_ID.TH, NS.HTML],
  70229. [TAG_ID.ANNOTATION_XML, NS.MATHML],
  70230. [TAG_ID.MI, NS.MATHML],
  70231. [TAG_ID.MN, NS.MATHML],
  70232. [TAG_ID.MO, NS.MATHML],
  70233. [TAG_ID.MS, NS.MATHML],
  70234. [TAG_ID.MTEXT, NS.MATHML],
  70235. [TAG_ID.DESC, NS.SVG],
  70236. [TAG_ID.FOREIGN_OBJECT, NS.SVG],
  70237. [TAG_ID.TITLE, NS.SVG],
  70238. ]);
  70239. const NAMED_HEADERS = [TAG_ID.H1, TAG_ID.H2, TAG_ID.H3, TAG_ID.H4, TAG_ID.H5, TAG_ID.H6];
  70240. const TABLE_ROW_CONTEXT = [TAG_ID.TR, TAG_ID.TEMPLATE, TAG_ID.HTML];
  70241. const TABLE_BODY_CONTEXT = [TAG_ID.TBODY, TAG_ID.TFOOT, TAG_ID.THEAD, TAG_ID.TEMPLATE, TAG_ID.HTML];
  70242. const TABLE_CONTEXT = [TAG_ID.TABLE, TAG_ID.TEMPLATE, TAG_ID.HTML];
  70243. const TABLE_CELLS = [TAG_ID.TD, TAG_ID.TH];
  70244. //Stack of open elements
  70245. class OpenElementStack {
  70246. constructor(document, treeAdapter, handler) {
  70247. this.treeAdapter = treeAdapter;
  70248. this.handler = handler;
  70249. this.items = [];
  70250. this.tagIDs = [];
  70251. this.stackTop = -1;
  70252. this.tmplCount = 0;
  70253. this.currentTagId = TAG_ID.UNKNOWN;
  70254. this.current = document;
  70255. }
  70256. get currentTmplContentOrNode() {
  70257. return this._isInTemplate() ? this.treeAdapter.getTemplateContent(this.current) : this.current;
  70258. }
  70259. //Index of element
  70260. _indexOf(element) {
  70261. return this.items.lastIndexOf(element, this.stackTop);
  70262. }
  70263. //Update current element
  70264. _isInTemplate() {
  70265. return this.currentTagId === TAG_ID.TEMPLATE && this.treeAdapter.getNamespaceURI(this.current) === NS.HTML;
  70266. }
  70267. _updateCurrentElement() {
  70268. this.current = this.items[this.stackTop];
  70269. this.currentTagId = this.tagIDs[this.stackTop];
  70270. }
  70271. //Mutations
  70272. push(element, tagID) {
  70273. this.stackTop++;
  70274. this.items[this.stackTop] = element;
  70275. this.current = element;
  70276. this.tagIDs[this.stackTop] = tagID;
  70277. this.currentTagId = tagID;
  70278. if (this._isInTemplate()) {
  70279. this.tmplCount++;
  70280. }
  70281. this.handler.onItemPush(element, tagID, true);
  70282. }
  70283. pop() {
  70284. const popped = this.current;
  70285. if (this.tmplCount > 0 && this._isInTemplate()) {
  70286. this.tmplCount--;
  70287. }
  70288. this.stackTop--;
  70289. this._updateCurrentElement();
  70290. this.handler.onItemPop(popped, true);
  70291. }
  70292. replace(oldElement, newElement) {
  70293. const idx = this._indexOf(oldElement);
  70294. this.items[idx] = newElement;
  70295. if (idx === this.stackTop) {
  70296. this.current = newElement;
  70297. }
  70298. }
  70299. insertAfter(referenceElement, newElement, newElementID) {
  70300. const insertionIdx = this._indexOf(referenceElement) + 1;
  70301. this.items.splice(insertionIdx, 0, newElement);
  70302. this.tagIDs.splice(insertionIdx, 0, newElementID);
  70303. this.stackTop++;
  70304. if (insertionIdx === this.stackTop) {
  70305. this._updateCurrentElement();
  70306. }
  70307. this.handler.onItemPush(this.current, this.currentTagId, insertionIdx === this.stackTop);
  70308. }
  70309. popUntilTagNamePopped(tagName) {
  70310. let targetIdx = this.stackTop + 1;
  70311. do {
  70312. targetIdx = this.tagIDs.lastIndexOf(tagName, targetIdx - 1);
  70313. } while (targetIdx > 0 && this.treeAdapter.getNamespaceURI(this.items[targetIdx]) !== NS.HTML);
  70314. this.shortenToLength(targetIdx < 0 ? 0 : targetIdx);
  70315. }
  70316. shortenToLength(idx) {
  70317. while (this.stackTop >= idx) {
  70318. const popped = this.current;
  70319. if (this.tmplCount > 0 && this._isInTemplate()) {
  70320. this.tmplCount -= 1;
  70321. }
  70322. this.stackTop--;
  70323. this._updateCurrentElement();
  70324. this.handler.onItemPop(popped, this.stackTop < idx);
  70325. }
  70326. }
  70327. popUntilElementPopped(element) {
  70328. const idx = this._indexOf(element);
  70329. this.shortenToLength(idx < 0 ? 0 : idx);
  70330. }
  70331. popUntilPopped(tagNames, targetNS) {
  70332. const idx = this._indexOfTagNames(tagNames, targetNS);
  70333. this.shortenToLength(idx < 0 ? 0 : idx);
  70334. }
  70335. popUntilNumberedHeaderPopped() {
  70336. this.popUntilPopped(NAMED_HEADERS, NS.HTML);
  70337. }
  70338. popUntilTableCellPopped() {
  70339. this.popUntilPopped(TABLE_CELLS, NS.HTML);
  70340. }
  70341. popAllUpToHtmlElement() {
  70342. //NOTE: here we assume that the root <html> element is always first in the open element stack, so
  70343. //we perform this fast stack clean up.
  70344. this.tmplCount = 0;
  70345. this.shortenToLength(1);
  70346. }
  70347. _indexOfTagNames(tagNames, namespace) {
  70348. for (let i = this.stackTop; i >= 0; i--) {
  70349. if (tagNames.includes(this.tagIDs[i]) && this.treeAdapter.getNamespaceURI(this.items[i]) === namespace) {
  70350. return i;
  70351. }
  70352. }
  70353. return -1;
  70354. }
  70355. clearBackTo(tagNames, targetNS) {
  70356. const idx = this._indexOfTagNames(tagNames, targetNS);
  70357. this.shortenToLength(idx + 1);
  70358. }
  70359. clearBackToTableContext() {
  70360. this.clearBackTo(TABLE_CONTEXT, NS.HTML);
  70361. }
  70362. clearBackToTableBodyContext() {
  70363. this.clearBackTo(TABLE_BODY_CONTEXT, NS.HTML);
  70364. }
  70365. clearBackToTableRowContext() {
  70366. this.clearBackTo(TABLE_ROW_CONTEXT, NS.HTML);
  70367. }
  70368. remove(element) {
  70369. const idx = this._indexOf(element);
  70370. if (idx >= 0) {
  70371. if (idx === this.stackTop) {
  70372. this.pop();
  70373. }
  70374. else {
  70375. this.items.splice(idx, 1);
  70376. this.tagIDs.splice(idx, 1);
  70377. this.stackTop--;
  70378. this._updateCurrentElement();
  70379. this.handler.onItemPop(element, false);
  70380. }
  70381. }
  70382. }
  70383. //Search
  70384. tryPeekProperlyNestedBodyElement() {
  70385. //Properly nested <body> element (should be second element in stack).
  70386. return this.stackTop >= 1 && this.tagIDs[1] === TAG_ID.BODY ? this.items[1] : null;
  70387. }
  70388. contains(element) {
  70389. return this._indexOf(element) > -1;
  70390. }
  70391. getCommonAncestor(element) {
  70392. const elementIdx = this._indexOf(element) - 1;
  70393. return elementIdx >= 0 ? this.items[elementIdx] : null;
  70394. }
  70395. isRootHtmlElementCurrent() {
  70396. return this.stackTop === 0 && this.tagIDs[0] === TAG_ID.HTML;
  70397. }
  70398. //Element in scope
  70399. hasInScope(tagName) {
  70400. for (let i = this.stackTop; i >= 0; i--) {
  70401. const tn = this.tagIDs[i];
  70402. const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
  70403. if (tn === tagName && ns === NS.HTML) {
  70404. return true;
  70405. }
  70406. if (SCOPING_ELEMENT_NS.get(tn) === ns) {
  70407. return false;
  70408. }
  70409. }
  70410. return true;
  70411. }
  70412. hasNumberedHeaderInScope() {
  70413. for (let i = this.stackTop; i >= 0; i--) {
  70414. const tn = this.tagIDs[i];
  70415. const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
  70416. if (isNumberedHeader(tn) && ns === NS.HTML) {
  70417. return true;
  70418. }
  70419. if (SCOPING_ELEMENT_NS.get(tn) === ns) {
  70420. return false;
  70421. }
  70422. }
  70423. return true;
  70424. }
  70425. hasInListItemScope(tagName) {
  70426. for (let i = this.stackTop; i >= 0; i--) {
  70427. const tn = this.tagIDs[i];
  70428. const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
  70429. if (tn === tagName && ns === NS.HTML) {
  70430. return true;
  70431. }
  70432. if (((tn === TAG_ID.UL || tn === TAG_ID.OL) && ns === NS.HTML) || SCOPING_ELEMENT_NS.get(tn) === ns) {
  70433. return false;
  70434. }
  70435. }
  70436. return true;
  70437. }
  70438. hasInButtonScope(tagName) {
  70439. for (let i = this.stackTop; i >= 0; i--) {
  70440. const tn = this.tagIDs[i];
  70441. const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
  70442. if (tn === tagName && ns === NS.HTML) {
  70443. return true;
  70444. }
  70445. if ((tn === TAG_ID.BUTTON && ns === NS.HTML) || SCOPING_ELEMENT_NS.get(tn) === ns) {
  70446. return false;
  70447. }
  70448. }
  70449. return true;
  70450. }
  70451. hasInTableScope(tagName) {
  70452. for (let i = this.stackTop; i >= 0; i--) {
  70453. const tn = this.tagIDs[i];
  70454. const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
  70455. if (ns !== NS.HTML) {
  70456. continue;
  70457. }
  70458. if (tn === tagName) {
  70459. return true;
  70460. }
  70461. if (tn === TAG_ID.TABLE || tn === TAG_ID.TEMPLATE || tn === TAG_ID.HTML) {
  70462. return false;
  70463. }
  70464. }
  70465. return true;
  70466. }
  70467. hasTableBodyContextInTableScope() {
  70468. for (let i = this.stackTop; i >= 0; i--) {
  70469. const tn = this.tagIDs[i];
  70470. const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
  70471. if (ns !== NS.HTML) {
  70472. continue;
  70473. }
  70474. if (tn === TAG_ID.TBODY || tn === TAG_ID.THEAD || tn === TAG_ID.TFOOT) {
  70475. return true;
  70476. }
  70477. if (tn === TAG_ID.TABLE || tn === TAG_ID.HTML) {
  70478. return false;
  70479. }
  70480. }
  70481. return true;
  70482. }
  70483. hasInSelectScope(tagName) {
  70484. for (let i = this.stackTop; i >= 0; i--) {
  70485. const tn = this.tagIDs[i];
  70486. const ns = this.treeAdapter.getNamespaceURI(this.items[i]);
  70487. if (ns !== NS.HTML) {
  70488. continue;
  70489. }
  70490. if (tn === tagName) {
  70491. return true;
  70492. }
  70493. if (tn !== TAG_ID.OPTION && tn !== TAG_ID.OPTGROUP) {
  70494. return false;
  70495. }
  70496. }
  70497. return true;
  70498. }
  70499. //Implied end tags
  70500. generateImpliedEndTags() {
  70501. while (IMPLICIT_END_TAG_REQUIRED.has(this.currentTagId)) {
  70502. this.pop();
  70503. }
  70504. }
  70505. generateImpliedEndTagsThoroughly() {
  70506. while (IMPLICIT_END_TAG_REQUIRED_THOROUGHLY.has(this.currentTagId)) {
  70507. this.pop();
  70508. }
  70509. }
  70510. generateImpliedEndTagsWithExclusion(exclusionId) {
  70511. while (this.currentTagId !== exclusionId && IMPLICIT_END_TAG_REQUIRED_THOROUGHLY.has(this.currentTagId)) {
  70512. this.pop();
  70513. }
  70514. }
  70515. }
  70516. //Const
  70517. const NOAH_ARK_CAPACITY = 3;
  70518. var EntryType;
  70519. (function (EntryType) {
  70520. EntryType[EntryType["Marker"] = 0] = "Marker";
  70521. EntryType[EntryType["Element"] = 1] = "Element";
  70522. })(EntryType || (EntryType = {}));
  70523. const MARKER = { type: EntryType.Marker };
  70524. //List of formatting elements
  70525. class FormattingElementList {
  70526. constructor(treeAdapter) {
  70527. this.treeAdapter = treeAdapter;
  70528. this.entries = [];
  70529. this.bookmark = null;
  70530. }
  70531. //Noah Ark's condition
  70532. //OPTIMIZATION: at first we try to find possible candidates for exclusion using
  70533. //lightweight heuristics without thorough attributes check.
  70534. _getNoahArkConditionCandidates(newElement, neAttrs) {
  70535. const candidates = [];
  70536. const neAttrsLength = neAttrs.length;
  70537. const neTagName = this.treeAdapter.getTagName(newElement);
  70538. const neNamespaceURI = this.treeAdapter.getNamespaceURI(newElement);
  70539. for (let i = 0; i < this.entries.length; i++) {
  70540. const entry = this.entries[i];
  70541. if (entry.type === EntryType.Marker) {
  70542. break;
  70543. }
  70544. const { element } = entry;
  70545. if (this.treeAdapter.getTagName(element) === neTagName &&
  70546. this.treeAdapter.getNamespaceURI(element) === neNamespaceURI) {
  70547. const elementAttrs = this.treeAdapter.getAttrList(element);
  70548. if (elementAttrs.length === neAttrsLength) {
  70549. candidates.push({ idx: i, attrs: elementAttrs });
  70550. }
  70551. }
  70552. }
  70553. return candidates;
  70554. }
  70555. _ensureNoahArkCondition(newElement) {
  70556. if (this.entries.length < NOAH_ARK_CAPACITY)
  70557. return;
  70558. const neAttrs = this.treeAdapter.getAttrList(newElement);
  70559. const candidates = this._getNoahArkConditionCandidates(newElement, neAttrs);
  70560. if (candidates.length < NOAH_ARK_CAPACITY)
  70561. return;
  70562. //NOTE: build attrs map for the new element, so we can perform fast lookups
  70563. const neAttrsMap = new Map(neAttrs.map((neAttr) => [neAttr.name, neAttr.value]));
  70564. let validCandidates = 0;
  70565. //NOTE: remove bottommost candidates, until Noah's Ark condition will not be met
  70566. for (let i = 0; i < candidates.length; i++) {
  70567. const candidate = candidates[i];
  70568. // We know that `candidate.attrs.length === neAttrs.length`
  70569. if (candidate.attrs.every((cAttr) => neAttrsMap.get(cAttr.name) === cAttr.value)) {
  70570. validCandidates += 1;
  70571. if (validCandidates >= NOAH_ARK_CAPACITY) {
  70572. this.entries.splice(candidate.idx, 1);
  70573. }
  70574. }
  70575. }
  70576. }
  70577. //Mutations
  70578. insertMarker() {
  70579. this.entries.unshift(MARKER);
  70580. }
  70581. pushElement(element, token) {
  70582. this._ensureNoahArkCondition(element);
  70583. this.entries.unshift({
  70584. type: EntryType.Element,
  70585. element,
  70586. token,
  70587. });
  70588. }
  70589. insertElementAfterBookmark(element, token) {
  70590. const bookmarkIdx = this.entries.indexOf(this.bookmark);
  70591. this.entries.splice(bookmarkIdx, 0, {
  70592. type: EntryType.Element,
  70593. element,
  70594. token,
  70595. });
  70596. }
  70597. removeEntry(entry) {
  70598. const entryIndex = this.entries.indexOf(entry);
  70599. if (entryIndex >= 0) {
  70600. this.entries.splice(entryIndex, 1);
  70601. }
  70602. }
  70603. clearToLastMarker() {
  70604. const markerIdx = this.entries.indexOf(MARKER);
  70605. if (markerIdx >= 0) {
  70606. this.entries.splice(0, markerIdx + 1);
  70607. }
  70608. else {
  70609. this.entries.length = 0;
  70610. }
  70611. }
  70612. //Search
  70613. getElementEntryInScopeWithTagName(tagName) {
  70614. const entry = this.entries.find((entry) => entry.type === EntryType.Marker || this.treeAdapter.getTagName(entry.element) === tagName);
  70615. return entry && entry.type === EntryType.Element ? entry : null;
  70616. }
  70617. getElementEntry(element) {
  70618. return this.entries.find((entry) => entry.type === EntryType.Element && entry.element === element);
  70619. }
  70620. }
  70621. var NodeType;
  70622. (function (NodeType) {
  70623. NodeType["Document"] = "#document";
  70624. NodeType["DocumentFragment"] = "#document-fragment";
  70625. NodeType["Comment"] = "#comment";
  70626. NodeType["Text"] = "#text";
  70627. NodeType["DocumentType"] = "#documentType";
  70628. })(NodeType || (NodeType = {}));
  70629. function createTextNode(value) {
  70630. return {
  70631. nodeName: NodeType.Text,
  70632. value,
  70633. parentNode: null,
  70634. };
  70635. }
  70636. const defaultTreeAdapter = {
  70637. //Node construction
  70638. createDocument() {
  70639. return {
  70640. nodeName: NodeType.Document,
  70641. mode: DOCUMENT_MODE.NO_QUIRKS,
  70642. childNodes: [],
  70643. };
  70644. },
  70645. createDocumentFragment() {
  70646. return {
  70647. nodeName: NodeType.DocumentFragment,
  70648. childNodes: [],
  70649. };
  70650. },
  70651. createElement(tagName, namespaceURI, attrs) {
  70652. return {
  70653. nodeName: tagName,
  70654. tagName,
  70655. attrs,
  70656. namespaceURI,
  70657. childNodes: [],
  70658. parentNode: null,
  70659. };
  70660. },
  70661. createCommentNode(data) {
  70662. return {
  70663. nodeName: NodeType.Comment,
  70664. data,
  70665. parentNode: null,
  70666. };
  70667. },
  70668. //Tree mutation
  70669. appendChild(parentNode, newNode) {
  70670. parentNode.childNodes.push(newNode);
  70671. newNode.parentNode = parentNode;
  70672. },
  70673. insertBefore(parentNode, newNode, referenceNode) {
  70674. const insertionIdx = parentNode.childNodes.indexOf(referenceNode);
  70675. parentNode.childNodes.splice(insertionIdx, 0, newNode);
  70676. newNode.parentNode = parentNode;
  70677. },
  70678. setTemplateContent(templateElement, contentElement) {
  70679. templateElement.content = contentElement;
  70680. },
  70681. getTemplateContent(templateElement) {
  70682. return templateElement.content;
  70683. },
  70684. setDocumentType(document, name, publicId, systemId) {
  70685. const doctypeNode = document.childNodes.find((node) => node.nodeName === NodeType.DocumentType);
  70686. if (doctypeNode) {
  70687. doctypeNode.name = name;
  70688. doctypeNode.publicId = publicId;
  70689. doctypeNode.systemId = systemId;
  70690. }
  70691. else {
  70692. const node = {
  70693. nodeName: NodeType.DocumentType,
  70694. name,
  70695. publicId,
  70696. systemId,
  70697. parentNode: null,
  70698. };
  70699. defaultTreeAdapter.appendChild(document, node);
  70700. }
  70701. },
  70702. setDocumentMode(document, mode) {
  70703. document.mode = mode;
  70704. },
  70705. getDocumentMode(document) {
  70706. return document.mode;
  70707. },
  70708. detachNode(node) {
  70709. if (node.parentNode) {
  70710. const idx = node.parentNode.childNodes.indexOf(node);
  70711. node.parentNode.childNodes.splice(idx, 1);
  70712. node.parentNode = null;
  70713. }
  70714. },
  70715. insertText(parentNode, text) {
  70716. if (parentNode.childNodes.length > 0) {
  70717. const prevNode = parentNode.childNodes[parentNode.childNodes.length - 1];
  70718. if (defaultTreeAdapter.isTextNode(prevNode)) {
  70719. prevNode.value += text;
  70720. return;
  70721. }
  70722. }
  70723. defaultTreeAdapter.appendChild(parentNode, createTextNode(text));
  70724. },
  70725. insertTextBefore(parentNode, text, referenceNode) {
  70726. const prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1];
  70727. if (prevNode && defaultTreeAdapter.isTextNode(prevNode)) {
  70728. prevNode.value += text;
  70729. }
  70730. else {
  70731. defaultTreeAdapter.insertBefore(parentNode, createTextNode(text), referenceNode);
  70732. }
  70733. },
  70734. adoptAttributes(recipient, attrs) {
  70735. const recipientAttrsMap = new Set(recipient.attrs.map((attr) => attr.name));
  70736. for (let j = 0; j < attrs.length; j++) {
  70737. if (!recipientAttrsMap.has(attrs[j].name)) {
  70738. recipient.attrs.push(attrs[j]);
  70739. }
  70740. }
  70741. },
  70742. //Tree traversing
  70743. getFirstChild(node) {
  70744. return node.childNodes[0];
  70745. },
  70746. getChildNodes(node) {
  70747. return node.childNodes;
  70748. },
  70749. getParentNode(node) {
  70750. return node.parentNode;
  70751. },
  70752. getAttrList(element) {
  70753. return element.attrs;
  70754. },
  70755. //Node data
  70756. getTagName(element) {
  70757. return element.tagName;
  70758. },
  70759. getNamespaceURI(element) {
  70760. return element.namespaceURI;
  70761. },
  70762. getTextNodeContent(textNode) {
  70763. return textNode.value;
  70764. },
  70765. getCommentNodeContent(commentNode) {
  70766. return commentNode.data;
  70767. },
  70768. getDocumentTypeNodeName(doctypeNode) {
  70769. return doctypeNode.name;
  70770. },
  70771. getDocumentTypeNodePublicId(doctypeNode) {
  70772. return doctypeNode.publicId;
  70773. },
  70774. getDocumentTypeNodeSystemId(doctypeNode) {
  70775. return doctypeNode.systemId;
  70776. },
  70777. //Node types
  70778. isTextNode(node) {
  70779. return node.nodeName === '#text';
  70780. },
  70781. isCommentNode(node) {
  70782. return node.nodeName === '#comment';
  70783. },
  70784. isDocumentTypeNode(node) {
  70785. return node.nodeName === NodeType.DocumentType;
  70786. },
  70787. isElementNode(node) {
  70788. return Object.prototype.hasOwnProperty.call(node, 'tagName');
  70789. },
  70790. // Source code location
  70791. setNodeSourceCodeLocation(node, location) {
  70792. node.sourceCodeLocation = location;
  70793. },
  70794. getNodeSourceCodeLocation(node) {
  70795. return node.sourceCodeLocation;
  70796. },
  70797. updateNodeSourceCodeLocation(node, endLocation) {
  70798. node.sourceCodeLocation = { ...node.sourceCodeLocation, ...endLocation };
  70799. },
  70800. };
  70801. //Const
  70802. const VALID_DOCTYPE_NAME = 'html';
  70803. const VALID_SYSTEM_ID = 'about:legacy-compat';
  70804. const QUIRKS_MODE_SYSTEM_ID = 'http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd';
  70805. const QUIRKS_MODE_PUBLIC_ID_PREFIXES = [
  70806. '+//silmaril//dtd html pro v0r11 19970101//',
  70807. '-//as//dtd html 3.0 aswedit + extensions//',
  70808. '-//advasoft ltd//dtd html 3.0 aswedit + extensions//',
  70809. '-//ietf//dtd html 2.0 level 1//',
  70810. '-//ietf//dtd html 2.0 level 2//',
  70811. '-//ietf//dtd html 2.0 strict level 1//',
  70812. '-//ietf//dtd html 2.0 strict level 2//',
  70813. '-//ietf//dtd html 2.0 strict//',
  70814. '-//ietf//dtd html 2.0//',
  70815. '-//ietf//dtd html 2.1e//',
  70816. '-//ietf//dtd html 3.0//',
  70817. '-//ietf//dtd html 3.2 final//',
  70818. '-//ietf//dtd html 3.2//',
  70819. '-//ietf//dtd html 3//',
  70820. '-//ietf//dtd html level 0//',
  70821. '-//ietf//dtd html level 1//',
  70822. '-//ietf//dtd html level 2//',
  70823. '-//ietf//dtd html level 3//',
  70824. '-//ietf//dtd html strict level 0//',
  70825. '-//ietf//dtd html strict level 1//',
  70826. '-//ietf//dtd html strict level 2//',
  70827. '-//ietf//dtd html strict level 3//',
  70828. '-//ietf//dtd html strict//',
  70829. '-//ietf//dtd html//',
  70830. '-//metrius//dtd metrius presentational//',
  70831. '-//microsoft//dtd internet explorer 2.0 html strict//',
  70832. '-//microsoft//dtd internet explorer 2.0 html//',
  70833. '-//microsoft//dtd internet explorer 2.0 tables//',
  70834. '-//microsoft//dtd internet explorer 3.0 html strict//',
  70835. '-//microsoft//dtd internet explorer 3.0 html//',
  70836. '-//microsoft//dtd internet explorer 3.0 tables//',
  70837. '-//netscape comm. corp.//dtd html//',
  70838. '-//netscape comm. corp.//dtd strict html//',
  70839. "-//o'reilly and associates//dtd html 2.0//",
  70840. "-//o'reilly and associates//dtd html extended 1.0//",
  70841. "-//o'reilly and associates//dtd html extended relaxed 1.0//",
  70842. '-//sq//dtd html 2.0 hotmetal + extensions//',
  70843. '-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//',
  70844. '-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//',
  70845. '-//spyglass//dtd html 2.0 extended//',
  70846. '-//sun microsystems corp.//dtd hotjava html//',
  70847. '-//sun microsystems corp.//dtd hotjava strict html//',
  70848. '-//w3c//dtd html 3 1995-03-24//',
  70849. '-//w3c//dtd html 3.2 draft//',
  70850. '-//w3c//dtd html 3.2 final//',
  70851. '-//w3c//dtd html 3.2//',
  70852. '-//w3c//dtd html 3.2s draft//',
  70853. '-//w3c//dtd html 4.0 frameset//',
  70854. '-//w3c//dtd html 4.0 transitional//',
  70855. '-//w3c//dtd html experimental 19960712//',
  70856. '-//w3c//dtd html experimental 970421//',
  70857. '-//w3c//dtd w3 html//',
  70858. '-//w3o//dtd w3 html 3.0//',
  70859. '-//webtechs//dtd mozilla html 2.0//',
  70860. '-//webtechs//dtd mozilla html//',
  70861. ];
  70862. const QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES = [
  70863. ...QUIRKS_MODE_PUBLIC_ID_PREFIXES,
  70864. '-//w3c//dtd html 4.01 frameset//',
  70865. '-//w3c//dtd html 4.01 transitional//',
  70866. ];
  70867. const QUIRKS_MODE_PUBLIC_IDS = new Set([
  70868. '-//w3o//dtd w3 html strict 3.0//en//',
  70869. '-/w3c/dtd html 4.0 transitional/en',
  70870. 'html',
  70871. ]);
  70872. const LIMITED_QUIRKS_PUBLIC_ID_PREFIXES = ['-//w3c//dtd xhtml 1.0 frameset//', '-//w3c//dtd xhtml 1.0 transitional//'];
  70873. const LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES = [
  70874. ...LIMITED_QUIRKS_PUBLIC_ID_PREFIXES,
  70875. '-//w3c//dtd html 4.01 frameset//',
  70876. '-//w3c//dtd html 4.01 transitional//',
  70877. ];
  70878. //Utils
  70879. function hasPrefix(publicId, prefixes) {
  70880. return prefixes.some((prefix) => publicId.startsWith(prefix));
  70881. }
  70882. //API
  70883. function isConforming(token) {
  70884. return (token.name === VALID_DOCTYPE_NAME &&
  70885. token.publicId === null &&
  70886. (token.systemId === null || token.systemId === VALID_SYSTEM_ID));
  70887. }
  70888. function getDocumentMode(token) {
  70889. if (token.name !== VALID_DOCTYPE_NAME) {
  70890. return DOCUMENT_MODE.QUIRKS;
  70891. }
  70892. const { systemId } = token;
  70893. if (systemId && systemId.toLowerCase() === QUIRKS_MODE_SYSTEM_ID) {
  70894. return DOCUMENT_MODE.QUIRKS;
  70895. }
  70896. let { publicId } = token;
  70897. if (publicId !== null) {
  70898. publicId = publicId.toLowerCase();
  70899. if (QUIRKS_MODE_PUBLIC_IDS.has(publicId)) {
  70900. return DOCUMENT_MODE.QUIRKS;
  70901. }
  70902. let prefixes = systemId === null ? QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES : QUIRKS_MODE_PUBLIC_ID_PREFIXES;
  70903. if (hasPrefix(publicId, prefixes)) {
  70904. return DOCUMENT_MODE.QUIRKS;
  70905. }
  70906. prefixes =
  70907. systemId === null ? LIMITED_QUIRKS_PUBLIC_ID_PREFIXES : LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES;
  70908. if (hasPrefix(publicId, prefixes)) {
  70909. return DOCUMENT_MODE.LIMITED_QUIRKS;
  70910. }
  70911. }
  70912. return DOCUMENT_MODE.NO_QUIRKS;
  70913. }
  70914. //MIME types
  70915. const MIME_TYPES = {
  70916. TEXT_HTML: 'text/html',
  70917. APPLICATION_XML: 'application/xhtml+xml',
  70918. };
  70919. //Attributes
  70920. const DEFINITION_URL_ATTR = 'definitionurl';
  70921. const ADJUSTED_DEFINITION_URL_ATTR = 'definitionURL';
  70922. const SVG_ATTRS_ADJUSTMENT_MAP = new Map([
  70923. 'attributeName',
  70924. 'attributeType',
  70925. 'baseFrequency',
  70926. 'baseProfile',
  70927. 'calcMode',
  70928. 'clipPathUnits',
  70929. 'diffuseConstant',
  70930. 'edgeMode',
  70931. 'filterUnits',
  70932. 'glyphRef',
  70933. 'gradientTransform',
  70934. 'gradientUnits',
  70935. 'kernelMatrix',
  70936. 'kernelUnitLength',
  70937. 'keyPoints',
  70938. 'keySplines',
  70939. 'keyTimes',
  70940. 'lengthAdjust',
  70941. 'limitingConeAngle',
  70942. 'markerHeight',
  70943. 'markerUnits',
  70944. 'markerWidth',
  70945. 'maskContentUnits',
  70946. 'maskUnits',
  70947. 'numOctaves',
  70948. 'pathLength',
  70949. 'patternContentUnits',
  70950. 'patternTransform',
  70951. 'patternUnits',
  70952. 'pointsAtX',
  70953. 'pointsAtY',
  70954. 'pointsAtZ',
  70955. 'preserveAlpha',
  70956. 'preserveAspectRatio',
  70957. 'primitiveUnits',
  70958. 'refX',
  70959. 'refY',
  70960. 'repeatCount',
  70961. 'repeatDur',
  70962. 'requiredExtensions',
  70963. 'requiredFeatures',
  70964. 'specularConstant',
  70965. 'specularExponent',
  70966. 'spreadMethod',
  70967. 'startOffset',
  70968. 'stdDeviation',
  70969. 'stitchTiles',
  70970. 'surfaceScale',
  70971. 'systemLanguage',
  70972. 'tableValues',
  70973. 'targetX',
  70974. 'targetY',
  70975. 'textLength',
  70976. 'viewBox',
  70977. 'viewTarget',
  70978. 'xChannelSelector',
  70979. 'yChannelSelector',
  70980. 'zoomAndPan',
  70981. ].map((attr) => [attr.toLowerCase(), attr]));
  70982. const XML_ATTRS_ADJUSTMENT_MAP = new Map([
  70983. ['xlink:actuate', { prefix: 'xlink', name: 'actuate', namespace: NS.XLINK }],
  70984. ['xlink:arcrole', { prefix: 'xlink', name: 'arcrole', namespace: NS.XLINK }],
  70985. ['xlink:href', { prefix: 'xlink', name: 'href', namespace: NS.XLINK }],
  70986. ['xlink:role', { prefix: 'xlink', name: 'role', namespace: NS.XLINK }],
  70987. ['xlink:show', { prefix: 'xlink', name: 'show', namespace: NS.XLINK }],
  70988. ['xlink:title', { prefix: 'xlink', name: 'title', namespace: NS.XLINK }],
  70989. ['xlink:type', { prefix: 'xlink', name: 'type', namespace: NS.XLINK }],
  70990. ['xml:base', { prefix: 'xml', name: 'base', namespace: NS.XML }],
  70991. ['xml:lang', { prefix: 'xml', name: 'lang', namespace: NS.XML }],
  70992. ['xml:space', { prefix: 'xml', name: 'space', namespace: NS.XML }],
  70993. ['xmlns', { prefix: '', name: 'xmlns', namespace: NS.XMLNS }],
  70994. ['xmlns:xlink', { prefix: 'xmlns', name: 'xlink', namespace: NS.XMLNS }],
  70995. ]);
  70996. //SVG tag names adjustment map
  70997. const SVG_TAG_NAMES_ADJUSTMENT_MAP = new Map([
  70998. 'altGlyph',
  70999. 'altGlyphDef',
  71000. 'altGlyphItem',
  71001. 'animateColor',
  71002. 'animateMotion',
  71003. 'animateTransform',
  71004. 'clipPath',
  71005. 'feBlend',
  71006. 'feColorMatrix',
  71007. 'feComponentTransfer',
  71008. 'feComposite',
  71009. 'feConvolveMatrix',
  71010. 'feDiffuseLighting',
  71011. 'feDisplacementMap',
  71012. 'feDistantLight',
  71013. 'feFlood',
  71014. 'feFuncA',
  71015. 'feFuncB',
  71016. 'feFuncG',
  71017. 'feFuncR',
  71018. 'feGaussianBlur',
  71019. 'feImage',
  71020. 'feMerge',
  71021. 'feMergeNode',
  71022. 'feMorphology',
  71023. 'feOffset',
  71024. 'fePointLight',
  71025. 'feSpecularLighting',
  71026. 'feSpotLight',
  71027. 'feTile',
  71028. 'feTurbulence',
  71029. 'foreignObject',
  71030. 'glyphRef',
  71031. 'linearGradient',
  71032. 'radialGradient',
  71033. 'textPath',
  71034. ].map((tn) => [tn.toLowerCase(), tn]));
  71035. //Tags that causes exit from foreign content
  71036. const EXITS_FOREIGN_CONTENT = new Set([
  71037. TAG_ID.B,
  71038. TAG_ID.BIG,
  71039. TAG_ID.BLOCKQUOTE,
  71040. TAG_ID.BODY,
  71041. TAG_ID.BR,
  71042. TAG_ID.CENTER,
  71043. TAG_ID.CODE,
  71044. TAG_ID.DD,
  71045. TAG_ID.DIV,
  71046. TAG_ID.DL,
  71047. TAG_ID.DT,
  71048. TAG_ID.EM,
  71049. TAG_ID.EMBED,
  71050. TAG_ID.H1,
  71051. TAG_ID.H2,
  71052. TAG_ID.H3,
  71053. TAG_ID.H4,
  71054. TAG_ID.H5,
  71055. TAG_ID.H6,
  71056. TAG_ID.HEAD,
  71057. TAG_ID.HR,
  71058. TAG_ID.I,
  71059. TAG_ID.IMG,
  71060. TAG_ID.LI,
  71061. TAG_ID.LISTING,
  71062. TAG_ID.MENU,
  71063. TAG_ID.META,
  71064. TAG_ID.NOBR,
  71065. TAG_ID.OL,
  71066. TAG_ID.P,
  71067. TAG_ID.PRE,
  71068. TAG_ID.RUBY,
  71069. TAG_ID.S,
  71070. TAG_ID.SMALL,
  71071. TAG_ID.SPAN,
  71072. TAG_ID.STRONG,
  71073. TAG_ID.STRIKE,
  71074. TAG_ID.SUB,
  71075. TAG_ID.SUP,
  71076. TAG_ID.TABLE,
  71077. TAG_ID.TT,
  71078. TAG_ID.U,
  71079. TAG_ID.UL,
  71080. TAG_ID.VAR,
  71081. ]);
  71082. //Check exit from foreign content
  71083. function causesExit(startTagToken) {
  71084. const tn = startTagToken.tagID;
  71085. const isFontWithAttrs = tn === TAG_ID.FONT &&
  71086. startTagToken.attrs.some(({ name }) => name === ATTRS.COLOR || name === ATTRS.SIZE || name === ATTRS.FACE);
  71087. return isFontWithAttrs || EXITS_FOREIGN_CONTENT.has(tn);
  71088. }
  71089. //Token adjustments
  71090. function adjustTokenMathMLAttrs(token) {
  71091. for (let i = 0; i < token.attrs.length; i++) {
  71092. if (token.attrs[i].name === DEFINITION_URL_ATTR) {
  71093. token.attrs[i].name = ADJUSTED_DEFINITION_URL_ATTR;
  71094. break;
  71095. }
  71096. }
  71097. }
  71098. function adjustTokenSVGAttrs(token) {
  71099. for (let i = 0; i < token.attrs.length; i++) {
  71100. const adjustedAttrName = SVG_ATTRS_ADJUSTMENT_MAP.get(token.attrs[i].name);
  71101. if (adjustedAttrName != null) {
  71102. token.attrs[i].name = adjustedAttrName;
  71103. }
  71104. }
  71105. }
  71106. function adjustTokenXMLAttrs(token) {
  71107. for (let i = 0; i < token.attrs.length; i++) {
  71108. const adjustedAttrEntry = XML_ATTRS_ADJUSTMENT_MAP.get(token.attrs[i].name);
  71109. if (adjustedAttrEntry) {
  71110. token.attrs[i].prefix = adjustedAttrEntry.prefix;
  71111. token.attrs[i].name = adjustedAttrEntry.name;
  71112. token.attrs[i].namespace = adjustedAttrEntry.namespace;
  71113. }
  71114. }
  71115. }
  71116. function adjustTokenSVGTagName(token) {
  71117. const adjustedTagName = SVG_TAG_NAMES_ADJUSTMENT_MAP.get(token.tagName);
  71118. if (adjustedTagName != null) {
  71119. token.tagName = adjustedTagName;
  71120. token.tagID = getTagID(token.tagName);
  71121. }
  71122. }
  71123. //Integration points
  71124. function isMathMLTextIntegrationPoint(tn, ns) {
  71125. return ns === NS.MATHML && (tn === TAG_ID.MI || tn === TAG_ID.MO || tn === TAG_ID.MN || tn === TAG_ID.MS || tn === TAG_ID.MTEXT);
  71126. }
  71127. function isHtmlIntegrationPoint(tn, ns, attrs) {
  71128. if (ns === NS.MATHML && tn === TAG_ID.ANNOTATION_XML) {
  71129. for (let i = 0; i < attrs.length; i++) {
  71130. if (attrs[i].name === ATTRS.ENCODING) {
  71131. const value = attrs[i].value.toLowerCase();
  71132. return value === MIME_TYPES.TEXT_HTML || value === MIME_TYPES.APPLICATION_XML;
  71133. }
  71134. }
  71135. }
  71136. return ns === NS.SVG && (tn === TAG_ID.FOREIGN_OBJECT || tn === TAG_ID.DESC || tn === TAG_ID.TITLE);
  71137. }
  71138. function isIntegrationPoint(tn, ns, attrs, foreignNS) {
  71139. return (((!foreignNS || foreignNS === NS.HTML) && isHtmlIntegrationPoint(tn, ns, attrs)) ||
  71140. ((!foreignNS || foreignNS === NS.MATHML) && isMathMLTextIntegrationPoint(tn, ns)));
  71141. }
  71142. //Misc constants
  71143. const HIDDEN_INPUT_TYPE = 'hidden';
  71144. //Adoption agency loops iteration count
  71145. const AA_OUTER_LOOP_ITER = 8;
  71146. const AA_INNER_LOOP_ITER = 3;
  71147. //Insertion modes
  71148. var InsertionMode;
  71149. (function (InsertionMode) {
  71150. InsertionMode[InsertionMode["INITIAL"] = 0] = "INITIAL";
  71151. InsertionMode[InsertionMode["BEFORE_HTML"] = 1] = "BEFORE_HTML";
  71152. InsertionMode[InsertionMode["BEFORE_HEAD"] = 2] = "BEFORE_HEAD";
  71153. InsertionMode[InsertionMode["IN_HEAD"] = 3] = "IN_HEAD";
  71154. InsertionMode[InsertionMode["IN_HEAD_NO_SCRIPT"] = 4] = "IN_HEAD_NO_SCRIPT";
  71155. InsertionMode[InsertionMode["AFTER_HEAD"] = 5] = "AFTER_HEAD";
  71156. InsertionMode[InsertionMode["IN_BODY"] = 6] = "IN_BODY";
  71157. InsertionMode[InsertionMode["TEXT"] = 7] = "TEXT";
  71158. InsertionMode[InsertionMode["IN_TABLE"] = 8] = "IN_TABLE";
  71159. InsertionMode[InsertionMode["IN_TABLE_TEXT"] = 9] = "IN_TABLE_TEXT";
  71160. InsertionMode[InsertionMode["IN_CAPTION"] = 10] = "IN_CAPTION";
  71161. InsertionMode[InsertionMode["IN_COLUMN_GROUP"] = 11] = "IN_COLUMN_GROUP";
  71162. InsertionMode[InsertionMode["IN_TABLE_BODY"] = 12] = "IN_TABLE_BODY";
  71163. InsertionMode[InsertionMode["IN_ROW"] = 13] = "IN_ROW";
  71164. InsertionMode[InsertionMode["IN_CELL"] = 14] = "IN_CELL";
  71165. InsertionMode[InsertionMode["IN_SELECT"] = 15] = "IN_SELECT";
  71166. InsertionMode[InsertionMode["IN_SELECT_IN_TABLE"] = 16] = "IN_SELECT_IN_TABLE";
  71167. InsertionMode[InsertionMode["IN_TEMPLATE"] = 17] = "IN_TEMPLATE";
  71168. InsertionMode[InsertionMode["AFTER_BODY"] = 18] = "AFTER_BODY";
  71169. InsertionMode[InsertionMode["IN_FRAMESET"] = 19] = "IN_FRAMESET";
  71170. InsertionMode[InsertionMode["AFTER_FRAMESET"] = 20] = "AFTER_FRAMESET";
  71171. InsertionMode[InsertionMode["AFTER_AFTER_BODY"] = 21] = "AFTER_AFTER_BODY";
  71172. InsertionMode[InsertionMode["AFTER_AFTER_FRAMESET"] = 22] = "AFTER_AFTER_FRAMESET";
  71173. })(InsertionMode || (InsertionMode = {}));
  71174. const BASE_LOC = {
  71175. startLine: -1,
  71176. startCol: -1,
  71177. startOffset: -1,
  71178. endLine: -1,
  71179. endCol: -1,
  71180. endOffset: -1,
  71181. };
  71182. const TABLE_STRUCTURE_TAGS = new Set([TAG_ID.TABLE, TAG_ID.TBODY, TAG_ID.TFOOT, TAG_ID.THEAD, TAG_ID.TR]);
  71183. const defaultParserOptions = {
  71184. scriptingEnabled: true,
  71185. sourceCodeLocationInfo: false,
  71186. treeAdapter: defaultTreeAdapter,
  71187. onParseError: null,
  71188. };
  71189. //Parser
  71190. class Parser {
  71191. constructor(options, document, fragmentContext = null, scriptHandler = null) {
  71192. this.fragmentContext = fragmentContext;
  71193. this.scriptHandler = scriptHandler;
  71194. this.currentToken = null;
  71195. this.stopped = false;
  71196. this.insertionMode = InsertionMode.INITIAL;
  71197. this.originalInsertionMode = InsertionMode.INITIAL;
  71198. this.headElement = null;
  71199. this.formElement = null;
  71200. /** Indicates that the current node is not an element in the HTML namespace */
  71201. this.currentNotInHTML = false;
  71202. /**
  71203. * The template insertion mode stack is maintained from the left.
  71204. * Ie. the topmost element will always have index 0.
  71205. */
  71206. this.tmplInsertionModeStack = [];
  71207. this.pendingCharacterTokens = [];
  71208. this.hasNonWhitespacePendingCharacterToken = false;
  71209. this.framesetOk = true;
  71210. this.skipNextNewLine = false;
  71211. this.fosterParentingEnabled = false;
  71212. this.options = {
  71213. ...defaultParserOptions,
  71214. ...options,
  71215. };
  71216. this.treeAdapter = this.options.treeAdapter;
  71217. this.onParseError = this.options.onParseError;
  71218. // Always enable location info if we report parse errors.
  71219. if (this.onParseError) {
  71220. this.options.sourceCodeLocationInfo = true;
  71221. }
  71222. this.document = document !== null && document !== void 0 ? document : this.treeAdapter.createDocument();
  71223. this.tokenizer = new Tokenizer(this.options, this);
  71224. this.activeFormattingElements = new FormattingElementList(this.treeAdapter);
  71225. this.fragmentContextID = fragmentContext ? getTagID(this.treeAdapter.getTagName(fragmentContext)) : TAG_ID.UNKNOWN;
  71226. this._setContextModes(fragmentContext !== null && fragmentContext !== void 0 ? fragmentContext : this.document, this.fragmentContextID);
  71227. this.openElements = new OpenElementStack(this.document, this.treeAdapter, this);
  71228. }
  71229. // API
  71230. static parse(html, options) {
  71231. const parser = new this(options);
  71232. parser.tokenizer.write(html, true);
  71233. return parser.document;
  71234. }
  71235. static getFragmentParser(fragmentContext, options) {
  71236. const opts = {
  71237. ...defaultParserOptions,
  71238. ...options,
  71239. };
  71240. //NOTE: use a <template> element as the fragment context if no context element was provided,
  71241. //so we will parse in a "forgiving" manner
  71242. fragmentContext !== null && fragmentContext !== void 0 ? fragmentContext : (fragmentContext = opts.treeAdapter.createElement(TAG_NAMES.TEMPLATE, NS.HTML, []));
  71243. //NOTE: create a fake element which will be used as the `document` for fragment parsing.
  71244. //This is important for jsdom, where a new `document` cannot be created. This led to
  71245. //fragment parsing messing with the main `document`.
  71246. const documentMock = opts.treeAdapter.createElement('documentmock', NS.HTML, []);
  71247. const parser = new this(opts, documentMock, fragmentContext);
  71248. if (parser.fragmentContextID === TAG_ID.TEMPLATE) {
  71249. parser.tmplInsertionModeStack.unshift(InsertionMode.IN_TEMPLATE);
  71250. }
  71251. parser._initTokenizerForFragmentParsing();
  71252. parser._insertFakeRootElement();
  71253. parser._resetInsertionMode();
  71254. parser._findFormInFragmentContext();
  71255. return parser;
  71256. }
  71257. getFragment() {
  71258. const rootElement = this.treeAdapter.getFirstChild(this.document);
  71259. const fragment = this.treeAdapter.createDocumentFragment();
  71260. this._adoptNodes(rootElement, fragment);
  71261. return fragment;
  71262. }
  71263. //Errors
  71264. _err(token, code, beforeToken) {
  71265. var _a;
  71266. if (!this.onParseError)
  71267. return;
  71268. const loc = (_a = token.location) !== null && _a !== void 0 ? _a : BASE_LOC;
  71269. const err = {
  71270. code,
  71271. startLine: loc.startLine,
  71272. startCol: loc.startCol,
  71273. startOffset: loc.startOffset,
  71274. endLine: beforeToken ? loc.startLine : loc.endLine,
  71275. endCol: beforeToken ? loc.startCol : loc.endCol,
  71276. endOffset: beforeToken ? loc.startOffset : loc.endOffset,
  71277. };
  71278. this.onParseError(err);
  71279. }
  71280. //Stack events
  71281. onItemPush(node, tid, isTop) {
  71282. var _a, _b;
  71283. (_b = (_a = this.treeAdapter).onItemPush) === null || _b === void 0 ? void 0 : _b.call(_a, node);
  71284. if (isTop && this.openElements.stackTop > 0)
  71285. this._setContextModes(node, tid);
  71286. }
  71287. onItemPop(node, isTop) {
  71288. var _a, _b;
  71289. if (this.options.sourceCodeLocationInfo) {
  71290. this._setEndLocation(node, this.currentToken);
  71291. }
  71292. (_b = (_a = this.treeAdapter).onItemPop) === null || _b === void 0 ? void 0 : _b.call(_a, node, this.openElements.current);
  71293. if (isTop) {
  71294. let current;
  71295. let currentTagId;
  71296. if (this.openElements.stackTop === 0 && this.fragmentContext) {
  71297. current = this.fragmentContext;
  71298. currentTagId = this.fragmentContextID;
  71299. }
  71300. else {
  71301. ({ current, currentTagId } = this.openElements);
  71302. }
  71303. this._setContextModes(current, currentTagId);
  71304. }
  71305. }
  71306. _setContextModes(current, tid) {
  71307. const isHTML = current === this.document || this.treeAdapter.getNamespaceURI(current) === NS.HTML;
  71308. this.currentNotInHTML = !isHTML;
  71309. this.tokenizer.inForeignNode = !isHTML && !this._isIntegrationPoint(tid, current);
  71310. }
  71311. _switchToTextParsing(currentToken, nextTokenizerState) {
  71312. this._insertElement(currentToken, NS.HTML);
  71313. this.tokenizer.state = nextTokenizerState;
  71314. this.originalInsertionMode = this.insertionMode;
  71315. this.insertionMode = InsertionMode.TEXT;
  71316. }
  71317. switchToPlaintextParsing() {
  71318. this.insertionMode = InsertionMode.TEXT;
  71319. this.originalInsertionMode = InsertionMode.IN_BODY;
  71320. this.tokenizer.state = TokenizerMode.PLAINTEXT;
  71321. }
  71322. //Fragment parsing
  71323. _getAdjustedCurrentElement() {
  71324. return this.openElements.stackTop === 0 && this.fragmentContext
  71325. ? this.fragmentContext
  71326. : this.openElements.current;
  71327. }
  71328. _findFormInFragmentContext() {
  71329. let node = this.fragmentContext;
  71330. while (node) {
  71331. if (this.treeAdapter.getTagName(node) === TAG_NAMES.FORM) {
  71332. this.formElement = node;
  71333. break;
  71334. }
  71335. node = this.treeAdapter.getParentNode(node);
  71336. }
  71337. }
  71338. _initTokenizerForFragmentParsing() {
  71339. if (!this.fragmentContext || this.treeAdapter.getNamespaceURI(this.fragmentContext) !== NS.HTML) {
  71340. return;
  71341. }
  71342. switch (this.fragmentContextID) {
  71343. case TAG_ID.TITLE:
  71344. case TAG_ID.TEXTAREA: {
  71345. this.tokenizer.state = TokenizerMode.RCDATA;
  71346. break;
  71347. }
  71348. case TAG_ID.STYLE:
  71349. case TAG_ID.XMP:
  71350. case TAG_ID.IFRAME:
  71351. case TAG_ID.NOEMBED:
  71352. case TAG_ID.NOFRAMES:
  71353. case TAG_ID.NOSCRIPT: {
  71354. this.tokenizer.state = TokenizerMode.RAWTEXT;
  71355. break;
  71356. }
  71357. case TAG_ID.SCRIPT: {
  71358. this.tokenizer.state = TokenizerMode.SCRIPT_DATA;
  71359. break;
  71360. }
  71361. case TAG_ID.PLAINTEXT: {
  71362. this.tokenizer.state = TokenizerMode.PLAINTEXT;
  71363. break;
  71364. }
  71365. // Do nothing
  71366. }
  71367. }
  71368. //Tree mutation
  71369. _setDocumentType(token) {
  71370. const name = token.name || '';
  71371. const publicId = token.publicId || '';
  71372. const systemId = token.systemId || '';
  71373. this.treeAdapter.setDocumentType(this.document, name, publicId, systemId);
  71374. if (token.location) {
  71375. const documentChildren = this.treeAdapter.getChildNodes(this.document);
  71376. const docTypeNode = documentChildren.find((node) => this.treeAdapter.isDocumentTypeNode(node));
  71377. if (docTypeNode) {
  71378. this.treeAdapter.setNodeSourceCodeLocation(docTypeNode, token.location);
  71379. }
  71380. }
  71381. }
  71382. _attachElementToTree(element, location) {
  71383. if (this.options.sourceCodeLocationInfo) {
  71384. const loc = location && {
  71385. ...location,
  71386. startTag: location,
  71387. };
  71388. this.treeAdapter.setNodeSourceCodeLocation(element, loc);
  71389. }
  71390. if (this._shouldFosterParentOnInsertion()) {
  71391. this._fosterParentElement(element);
  71392. }
  71393. else {
  71394. const parent = this.openElements.currentTmplContentOrNode;
  71395. this.treeAdapter.appendChild(parent, element);
  71396. }
  71397. }
  71398. _appendElement(token, namespaceURI) {
  71399. const element = this.treeAdapter.createElement(token.tagName, namespaceURI, token.attrs);
  71400. this._attachElementToTree(element, token.location);
  71401. }
  71402. _insertElement(token, namespaceURI) {
  71403. const element = this.treeAdapter.createElement(token.tagName, namespaceURI, token.attrs);
  71404. this._attachElementToTree(element, token.location);
  71405. this.openElements.push(element, token.tagID);
  71406. }
  71407. _insertFakeElement(tagName, tagID) {
  71408. const element = this.treeAdapter.createElement(tagName, NS.HTML, []);
  71409. this._attachElementToTree(element, null);
  71410. this.openElements.push(element, tagID);
  71411. }
  71412. _insertTemplate(token) {
  71413. const tmpl = this.treeAdapter.createElement(token.tagName, NS.HTML, token.attrs);
  71414. const content = this.treeAdapter.createDocumentFragment();
  71415. this.treeAdapter.setTemplateContent(tmpl, content);
  71416. this._attachElementToTree(tmpl, token.location);
  71417. this.openElements.push(tmpl, token.tagID);
  71418. if (this.options.sourceCodeLocationInfo)
  71419. this.treeAdapter.setNodeSourceCodeLocation(content, null);
  71420. }
  71421. _insertFakeRootElement() {
  71422. const element = this.treeAdapter.createElement(TAG_NAMES.HTML, NS.HTML, []);
  71423. if (this.options.sourceCodeLocationInfo)
  71424. this.treeAdapter.setNodeSourceCodeLocation(element, null);
  71425. this.treeAdapter.appendChild(this.openElements.current, element);
  71426. this.openElements.push(element, TAG_ID.HTML);
  71427. }
  71428. _appendCommentNode(token, parent) {
  71429. const commentNode = this.treeAdapter.createCommentNode(token.data);
  71430. this.treeAdapter.appendChild(parent, commentNode);
  71431. if (this.options.sourceCodeLocationInfo) {
  71432. this.treeAdapter.setNodeSourceCodeLocation(commentNode, token.location);
  71433. }
  71434. }
  71435. _insertCharacters(token) {
  71436. let parent;
  71437. let beforeElement;
  71438. if (this._shouldFosterParentOnInsertion()) {
  71439. ({ parent, beforeElement } = this._findFosterParentingLocation());
  71440. if (beforeElement) {
  71441. this.treeAdapter.insertTextBefore(parent, token.chars, beforeElement);
  71442. }
  71443. else {
  71444. this.treeAdapter.insertText(parent, token.chars);
  71445. }
  71446. }
  71447. else {
  71448. parent = this.openElements.currentTmplContentOrNode;
  71449. this.treeAdapter.insertText(parent, token.chars);
  71450. }
  71451. if (!token.location)
  71452. return;
  71453. const siblings = this.treeAdapter.getChildNodes(parent);
  71454. const textNodeIdx = beforeElement ? siblings.lastIndexOf(beforeElement) : siblings.length;
  71455. const textNode = siblings[textNodeIdx - 1];
  71456. //NOTE: if we have a location assigned by another token, then just update the end position
  71457. const tnLoc = this.treeAdapter.getNodeSourceCodeLocation(textNode);
  71458. if (tnLoc) {
  71459. const { endLine, endCol, endOffset } = token.location;
  71460. this.treeAdapter.updateNodeSourceCodeLocation(textNode, { endLine, endCol, endOffset });
  71461. }
  71462. else if (this.options.sourceCodeLocationInfo) {
  71463. this.treeAdapter.setNodeSourceCodeLocation(textNode, token.location);
  71464. }
  71465. }
  71466. _adoptNodes(donor, recipient) {
  71467. for (let child = this.treeAdapter.getFirstChild(donor); child; child = this.treeAdapter.getFirstChild(donor)) {
  71468. this.treeAdapter.detachNode(child);
  71469. this.treeAdapter.appendChild(recipient, child);
  71470. }
  71471. }
  71472. _setEndLocation(element, closingToken) {
  71473. if (this.treeAdapter.getNodeSourceCodeLocation(element) && closingToken.location) {
  71474. const ctLoc = closingToken.location;
  71475. const tn = this.treeAdapter.getTagName(element);
  71476. const endLoc =
  71477. // NOTE: For cases like <p> <p> </p> - First 'p' closes without a closing
  71478. // tag and for cases like <td> <p> </td> - 'p' closes without a closing tag.
  71479. closingToken.type === TokenType.END_TAG && tn === closingToken.tagName
  71480. ? {
  71481. endTag: { ...ctLoc },
  71482. endLine: ctLoc.endLine,
  71483. endCol: ctLoc.endCol,
  71484. endOffset: ctLoc.endOffset,
  71485. }
  71486. : {
  71487. endLine: ctLoc.startLine,
  71488. endCol: ctLoc.startCol,
  71489. endOffset: ctLoc.startOffset,
  71490. };
  71491. this.treeAdapter.updateNodeSourceCodeLocation(element, endLoc);
  71492. }
  71493. }
  71494. //Token processing
  71495. shouldProcessStartTagTokenInForeignContent(token) {
  71496. // Check that neither current === document, or ns === NS.HTML
  71497. if (!this.currentNotInHTML)
  71498. return false;
  71499. let current;
  71500. let currentTagId;
  71501. if (this.openElements.stackTop === 0 && this.fragmentContext) {
  71502. current = this.fragmentContext;
  71503. currentTagId = this.fragmentContextID;
  71504. }
  71505. else {
  71506. ({ current, currentTagId } = this.openElements);
  71507. }
  71508. if (token.tagID === TAG_ID.SVG &&
  71509. this.treeAdapter.getTagName(current) === TAG_NAMES.ANNOTATION_XML &&
  71510. this.treeAdapter.getNamespaceURI(current) === NS.MATHML) {
  71511. return false;
  71512. }
  71513. return (
  71514. // Check that `current` is not an integration point for HTML or MathML elements.
  71515. this.tokenizer.inForeignNode ||
  71516. // If it _is_ an integration point, then we might have to check that it is not an HTML
  71517. // integration point.
  71518. ((token.tagID === TAG_ID.MGLYPH || token.tagID === TAG_ID.MALIGNMARK) &&
  71519. !this._isIntegrationPoint(currentTagId, current, NS.HTML)));
  71520. }
  71521. _processToken(token) {
  71522. switch (token.type) {
  71523. case TokenType.CHARACTER: {
  71524. this.onCharacter(token);
  71525. break;
  71526. }
  71527. case TokenType.NULL_CHARACTER: {
  71528. this.onNullCharacter(token);
  71529. break;
  71530. }
  71531. case TokenType.COMMENT: {
  71532. this.onComment(token);
  71533. break;
  71534. }
  71535. case TokenType.DOCTYPE: {
  71536. this.onDoctype(token);
  71537. break;
  71538. }
  71539. case TokenType.START_TAG: {
  71540. this._processStartTag(token);
  71541. break;
  71542. }
  71543. case TokenType.END_TAG: {
  71544. this.onEndTag(token);
  71545. break;
  71546. }
  71547. case TokenType.EOF: {
  71548. this.onEof(token);
  71549. break;
  71550. }
  71551. case TokenType.WHITESPACE_CHARACTER: {
  71552. this.onWhitespaceCharacter(token);
  71553. break;
  71554. }
  71555. }
  71556. }
  71557. //Integration points
  71558. _isIntegrationPoint(tid, element, foreignNS) {
  71559. const ns = this.treeAdapter.getNamespaceURI(element);
  71560. const attrs = this.treeAdapter.getAttrList(element);
  71561. return isIntegrationPoint(tid, ns, attrs, foreignNS);
  71562. }
  71563. //Active formatting elements reconstruction
  71564. _reconstructActiveFormattingElements() {
  71565. const listLength = this.activeFormattingElements.entries.length;
  71566. if (listLength) {
  71567. const endIndex = this.activeFormattingElements.entries.findIndex((entry) => entry.type === EntryType.Marker || this.openElements.contains(entry.element));
  71568. const unopenIdx = endIndex < 0 ? listLength - 1 : endIndex - 1;
  71569. for (let i = unopenIdx; i >= 0; i--) {
  71570. const entry = this.activeFormattingElements.entries[i];
  71571. this._insertElement(entry.token, this.treeAdapter.getNamespaceURI(entry.element));
  71572. entry.element = this.openElements.current;
  71573. }
  71574. }
  71575. }
  71576. //Close elements
  71577. _closeTableCell() {
  71578. this.openElements.generateImpliedEndTags();
  71579. this.openElements.popUntilTableCellPopped();
  71580. this.activeFormattingElements.clearToLastMarker();
  71581. this.insertionMode = InsertionMode.IN_ROW;
  71582. }
  71583. _closePElement() {
  71584. this.openElements.generateImpliedEndTagsWithExclusion(TAG_ID.P);
  71585. this.openElements.popUntilTagNamePopped(TAG_ID.P);
  71586. }
  71587. //Insertion modes
  71588. _resetInsertionMode() {
  71589. for (let i = this.openElements.stackTop; i >= 0; i--) {
  71590. //Insertion mode reset map
  71591. switch (i === 0 && this.fragmentContext ? this.fragmentContextID : this.openElements.tagIDs[i]) {
  71592. case TAG_ID.TR:
  71593. this.insertionMode = InsertionMode.IN_ROW;
  71594. return;
  71595. case TAG_ID.TBODY:
  71596. case TAG_ID.THEAD:
  71597. case TAG_ID.TFOOT:
  71598. this.insertionMode = InsertionMode.IN_TABLE_BODY;
  71599. return;
  71600. case TAG_ID.CAPTION:
  71601. this.insertionMode = InsertionMode.IN_CAPTION;
  71602. return;
  71603. case TAG_ID.COLGROUP:
  71604. this.insertionMode = InsertionMode.IN_COLUMN_GROUP;
  71605. return;
  71606. case TAG_ID.TABLE:
  71607. this.insertionMode = InsertionMode.IN_TABLE;
  71608. return;
  71609. case TAG_ID.BODY:
  71610. this.insertionMode = InsertionMode.IN_BODY;
  71611. return;
  71612. case TAG_ID.FRAMESET:
  71613. this.insertionMode = InsertionMode.IN_FRAMESET;
  71614. return;
  71615. case TAG_ID.SELECT:
  71616. this._resetInsertionModeForSelect(i);
  71617. return;
  71618. case TAG_ID.TEMPLATE:
  71619. this.insertionMode = this.tmplInsertionModeStack[0];
  71620. return;
  71621. case TAG_ID.HTML:
  71622. this.insertionMode = this.headElement ? InsertionMode.AFTER_HEAD : InsertionMode.BEFORE_HEAD;
  71623. return;
  71624. case TAG_ID.TD:
  71625. case TAG_ID.TH:
  71626. if (i > 0) {
  71627. this.insertionMode = InsertionMode.IN_CELL;
  71628. return;
  71629. }
  71630. break;
  71631. case TAG_ID.HEAD:
  71632. if (i > 0) {
  71633. this.insertionMode = InsertionMode.IN_HEAD;
  71634. return;
  71635. }
  71636. break;
  71637. }
  71638. }
  71639. this.insertionMode = InsertionMode.IN_BODY;
  71640. }
  71641. _resetInsertionModeForSelect(selectIdx) {
  71642. if (selectIdx > 0) {
  71643. for (let i = selectIdx - 1; i > 0; i--) {
  71644. const tn = this.openElements.tagIDs[i];
  71645. if (tn === TAG_ID.TEMPLATE) {
  71646. break;
  71647. }
  71648. else if (tn === TAG_ID.TABLE) {
  71649. this.insertionMode = InsertionMode.IN_SELECT_IN_TABLE;
  71650. return;
  71651. }
  71652. }
  71653. }
  71654. this.insertionMode = InsertionMode.IN_SELECT;
  71655. }
  71656. //Foster parenting
  71657. _isElementCausesFosterParenting(tn) {
  71658. return TABLE_STRUCTURE_TAGS.has(tn);
  71659. }
  71660. _shouldFosterParentOnInsertion() {
  71661. return this.fosterParentingEnabled && this._isElementCausesFosterParenting(this.openElements.currentTagId);
  71662. }
  71663. _findFosterParentingLocation() {
  71664. for (let i = this.openElements.stackTop; i >= 0; i--) {
  71665. const openElement = this.openElements.items[i];
  71666. switch (this.openElements.tagIDs[i]) {
  71667. case TAG_ID.TEMPLATE:
  71668. if (this.treeAdapter.getNamespaceURI(openElement) === NS.HTML) {
  71669. return { parent: this.treeAdapter.getTemplateContent(openElement), beforeElement: null };
  71670. }
  71671. break;
  71672. case TAG_ID.TABLE: {
  71673. const parent = this.treeAdapter.getParentNode(openElement);
  71674. if (parent) {
  71675. return { parent, beforeElement: openElement };
  71676. }
  71677. return { parent: this.openElements.items[i - 1], beforeElement: null };
  71678. }
  71679. // Do nothing
  71680. }
  71681. }
  71682. return { parent: this.openElements.items[0], beforeElement: null };
  71683. }
  71684. _fosterParentElement(element) {
  71685. const location = this._findFosterParentingLocation();
  71686. if (location.beforeElement) {
  71687. this.treeAdapter.insertBefore(location.parent, element, location.beforeElement);
  71688. }
  71689. else {
  71690. this.treeAdapter.appendChild(location.parent, element);
  71691. }
  71692. }
  71693. //Special elements
  71694. _isSpecialElement(element, id) {
  71695. const ns = this.treeAdapter.getNamespaceURI(element);
  71696. return SPECIAL_ELEMENTS[ns].has(id);
  71697. }
  71698. onCharacter(token) {
  71699. this.skipNextNewLine = false;
  71700. if (this.tokenizer.inForeignNode) {
  71701. characterInForeignContent(this, token);
  71702. return;
  71703. }
  71704. switch (this.insertionMode) {
  71705. case InsertionMode.INITIAL:
  71706. tokenInInitialMode(this, token);
  71707. break;
  71708. case InsertionMode.BEFORE_HTML:
  71709. tokenBeforeHtml(this, token);
  71710. break;
  71711. case InsertionMode.BEFORE_HEAD:
  71712. tokenBeforeHead(this, token);
  71713. break;
  71714. case InsertionMode.IN_HEAD:
  71715. tokenInHead(this, token);
  71716. break;
  71717. case InsertionMode.IN_HEAD_NO_SCRIPT:
  71718. tokenInHeadNoScript(this, token);
  71719. break;
  71720. case InsertionMode.AFTER_HEAD:
  71721. tokenAfterHead(this, token);
  71722. break;
  71723. case InsertionMode.IN_BODY:
  71724. case InsertionMode.IN_CAPTION:
  71725. case InsertionMode.IN_CELL:
  71726. case InsertionMode.IN_TEMPLATE:
  71727. characterInBody(this, token);
  71728. break;
  71729. case InsertionMode.TEXT:
  71730. case InsertionMode.IN_SELECT:
  71731. case InsertionMode.IN_SELECT_IN_TABLE:
  71732. this._insertCharacters(token);
  71733. break;
  71734. case InsertionMode.IN_TABLE:
  71735. case InsertionMode.IN_TABLE_BODY:
  71736. case InsertionMode.IN_ROW:
  71737. characterInTable(this, token);
  71738. break;
  71739. case InsertionMode.IN_TABLE_TEXT:
  71740. characterInTableText(this, token);
  71741. break;
  71742. case InsertionMode.IN_COLUMN_GROUP:
  71743. tokenInColumnGroup(this, token);
  71744. break;
  71745. case InsertionMode.AFTER_BODY:
  71746. tokenAfterBody(this, token);
  71747. break;
  71748. case InsertionMode.AFTER_AFTER_BODY:
  71749. tokenAfterAfterBody(this, token);
  71750. break;
  71751. // Do nothing
  71752. }
  71753. }
  71754. onNullCharacter(token) {
  71755. this.skipNextNewLine = false;
  71756. if (this.tokenizer.inForeignNode) {
  71757. nullCharacterInForeignContent(this, token);
  71758. return;
  71759. }
  71760. switch (this.insertionMode) {
  71761. case InsertionMode.INITIAL:
  71762. tokenInInitialMode(this, token);
  71763. break;
  71764. case InsertionMode.BEFORE_HTML:
  71765. tokenBeforeHtml(this, token);
  71766. break;
  71767. case InsertionMode.BEFORE_HEAD:
  71768. tokenBeforeHead(this, token);
  71769. break;
  71770. case InsertionMode.IN_HEAD:
  71771. tokenInHead(this, token);
  71772. break;
  71773. case InsertionMode.IN_HEAD_NO_SCRIPT:
  71774. tokenInHeadNoScript(this, token);
  71775. break;
  71776. case InsertionMode.AFTER_HEAD:
  71777. tokenAfterHead(this, token);
  71778. break;
  71779. case InsertionMode.TEXT:
  71780. this._insertCharacters(token);
  71781. break;
  71782. case InsertionMode.IN_TABLE:
  71783. case InsertionMode.IN_TABLE_BODY:
  71784. case InsertionMode.IN_ROW:
  71785. characterInTable(this, token);
  71786. break;
  71787. case InsertionMode.IN_COLUMN_GROUP:
  71788. tokenInColumnGroup(this, token);
  71789. break;
  71790. case InsertionMode.AFTER_BODY:
  71791. tokenAfterBody(this, token);
  71792. break;
  71793. case InsertionMode.AFTER_AFTER_BODY:
  71794. tokenAfterAfterBody(this, token);
  71795. break;
  71796. // Do nothing
  71797. }
  71798. }
  71799. onComment(token) {
  71800. this.skipNextNewLine = false;
  71801. if (this.currentNotInHTML) {
  71802. appendComment(this, token);
  71803. return;
  71804. }
  71805. switch (this.insertionMode) {
  71806. case InsertionMode.INITIAL:
  71807. case InsertionMode.BEFORE_HTML:
  71808. case InsertionMode.BEFORE_HEAD:
  71809. case InsertionMode.IN_HEAD:
  71810. case InsertionMode.IN_HEAD_NO_SCRIPT:
  71811. case InsertionMode.AFTER_HEAD:
  71812. case InsertionMode.IN_BODY:
  71813. case InsertionMode.IN_TABLE:
  71814. case InsertionMode.IN_CAPTION:
  71815. case InsertionMode.IN_COLUMN_GROUP:
  71816. case InsertionMode.IN_TABLE_BODY:
  71817. case InsertionMode.IN_ROW:
  71818. case InsertionMode.IN_CELL:
  71819. case InsertionMode.IN_SELECT:
  71820. case InsertionMode.IN_SELECT_IN_TABLE:
  71821. case InsertionMode.IN_TEMPLATE:
  71822. case InsertionMode.IN_FRAMESET:
  71823. case InsertionMode.AFTER_FRAMESET:
  71824. appendComment(this, token);
  71825. break;
  71826. case InsertionMode.IN_TABLE_TEXT:
  71827. tokenInTableText(this, token);
  71828. break;
  71829. case InsertionMode.AFTER_BODY:
  71830. appendCommentToRootHtmlElement(this, token);
  71831. break;
  71832. case InsertionMode.AFTER_AFTER_BODY:
  71833. case InsertionMode.AFTER_AFTER_FRAMESET:
  71834. appendCommentToDocument(this, token);
  71835. break;
  71836. // Do nothing
  71837. }
  71838. }
  71839. onDoctype(token) {
  71840. this.skipNextNewLine = false;
  71841. switch (this.insertionMode) {
  71842. case InsertionMode.INITIAL:
  71843. doctypeInInitialMode(this, token);
  71844. break;
  71845. case InsertionMode.BEFORE_HEAD:
  71846. case InsertionMode.IN_HEAD:
  71847. case InsertionMode.IN_HEAD_NO_SCRIPT:
  71848. case InsertionMode.AFTER_HEAD:
  71849. this._err(token, ERR.misplacedDoctype);
  71850. break;
  71851. case InsertionMode.IN_TABLE_TEXT:
  71852. tokenInTableText(this, token);
  71853. break;
  71854. // Do nothing
  71855. }
  71856. }
  71857. onStartTag(token) {
  71858. this.skipNextNewLine = false;
  71859. this.currentToken = token;
  71860. this._processStartTag(token);
  71861. if (token.selfClosing && !token.ackSelfClosing) {
  71862. this._err(token, ERR.nonVoidHtmlElementStartTagWithTrailingSolidus);
  71863. }
  71864. }
  71865. /**
  71866. * Processes a given start tag.
  71867. *
  71868. * `onStartTag` checks if a self-closing tag was recognized. When a token
  71869. * is moved inbetween multiple insertion modes, this check for self-closing
  71870. * could lead to false positives. To avoid this, `_processStartTag` is used
  71871. * for nested calls.
  71872. *
  71873. * @param token The token to process.
  71874. */
  71875. _processStartTag(token) {
  71876. if (this.shouldProcessStartTagTokenInForeignContent(token)) {
  71877. startTagInForeignContent(this, token);
  71878. }
  71879. else {
  71880. this._startTagOutsideForeignContent(token);
  71881. }
  71882. }
  71883. _startTagOutsideForeignContent(token) {
  71884. switch (this.insertionMode) {
  71885. case InsertionMode.INITIAL:
  71886. tokenInInitialMode(this, token);
  71887. break;
  71888. case InsertionMode.BEFORE_HTML:
  71889. startTagBeforeHtml(this, token);
  71890. break;
  71891. case InsertionMode.BEFORE_HEAD:
  71892. startTagBeforeHead(this, token);
  71893. break;
  71894. case InsertionMode.IN_HEAD:
  71895. startTagInHead(this, token);
  71896. break;
  71897. case InsertionMode.IN_HEAD_NO_SCRIPT:
  71898. startTagInHeadNoScript(this, token);
  71899. break;
  71900. case InsertionMode.AFTER_HEAD:
  71901. startTagAfterHead(this, token);
  71902. break;
  71903. case InsertionMode.IN_BODY:
  71904. startTagInBody(this, token);
  71905. break;
  71906. case InsertionMode.IN_TABLE:
  71907. startTagInTable(this, token);
  71908. break;
  71909. case InsertionMode.IN_TABLE_TEXT:
  71910. tokenInTableText(this, token);
  71911. break;
  71912. case InsertionMode.IN_CAPTION:
  71913. startTagInCaption(this, token);
  71914. break;
  71915. case InsertionMode.IN_COLUMN_GROUP:
  71916. startTagInColumnGroup(this, token);
  71917. break;
  71918. case InsertionMode.IN_TABLE_BODY:
  71919. startTagInTableBody(this, token);
  71920. break;
  71921. case InsertionMode.IN_ROW:
  71922. startTagInRow(this, token);
  71923. break;
  71924. case InsertionMode.IN_CELL:
  71925. startTagInCell(this, token);
  71926. break;
  71927. case InsertionMode.IN_SELECT:
  71928. startTagInSelect(this, token);
  71929. break;
  71930. case InsertionMode.IN_SELECT_IN_TABLE:
  71931. startTagInSelectInTable(this, token);
  71932. break;
  71933. case InsertionMode.IN_TEMPLATE:
  71934. startTagInTemplate(this, token);
  71935. break;
  71936. case InsertionMode.AFTER_BODY:
  71937. startTagAfterBody(this, token);
  71938. break;
  71939. case InsertionMode.IN_FRAMESET:
  71940. startTagInFrameset(this, token);
  71941. break;
  71942. case InsertionMode.AFTER_FRAMESET:
  71943. startTagAfterFrameset(this, token);
  71944. break;
  71945. case InsertionMode.AFTER_AFTER_BODY:
  71946. startTagAfterAfterBody(this, token);
  71947. break;
  71948. case InsertionMode.AFTER_AFTER_FRAMESET:
  71949. startTagAfterAfterFrameset(this, token);
  71950. break;
  71951. // Do nothing
  71952. }
  71953. }
  71954. onEndTag(token) {
  71955. this.skipNextNewLine = false;
  71956. this.currentToken = token;
  71957. if (this.currentNotInHTML) {
  71958. endTagInForeignContent(this, token);
  71959. }
  71960. else {
  71961. this._endTagOutsideForeignContent(token);
  71962. }
  71963. }
  71964. _endTagOutsideForeignContent(token) {
  71965. switch (this.insertionMode) {
  71966. case InsertionMode.INITIAL:
  71967. tokenInInitialMode(this, token);
  71968. break;
  71969. case InsertionMode.BEFORE_HTML:
  71970. endTagBeforeHtml(this, token);
  71971. break;
  71972. case InsertionMode.BEFORE_HEAD:
  71973. endTagBeforeHead(this, token);
  71974. break;
  71975. case InsertionMode.IN_HEAD:
  71976. endTagInHead(this, token);
  71977. break;
  71978. case InsertionMode.IN_HEAD_NO_SCRIPT:
  71979. endTagInHeadNoScript(this, token);
  71980. break;
  71981. case InsertionMode.AFTER_HEAD:
  71982. endTagAfterHead(this, token);
  71983. break;
  71984. case InsertionMode.IN_BODY:
  71985. endTagInBody(this, token);
  71986. break;
  71987. case InsertionMode.TEXT:
  71988. endTagInText(this, token);
  71989. break;
  71990. case InsertionMode.IN_TABLE:
  71991. endTagInTable(this, token);
  71992. break;
  71993. case InsertionMode.IN_TABLE_TEXT:
  71994. tokenInTableText(this, token);
  71995. break;
  71996. case InsertionMode.IN_CAPTION:
  71997. endTagInCaption(this, token);
  71998. break;
  71999. case InsertionMode.IN_COLUMN_GROUP:
  72000. endTagInColumnGroup(this, token);
  72001. break;
  72002. case InsertionMode.IN_TABLE_BODY:
  72003. endTagInTableBody(this, token);
  72004. break;
  72005. case InsertionMode.IN_ROW:
  72006. endTagInRow(this, token);
  72007. break;
  72008. case InsertionMode.IN_CELL:
  72009. endTagInCell(this, token);
  72010. break;
  72011. case InsertionMode.IN_SELECT:
  72012. endTagInSelect(this, token);
  72013. break;
  72014. case InsertionMode.IN_SELECT_IN_TABLE:
  72015. endTagInSelectInTable(this, token);
  72016. break;
  72017. case InsertionMode.IN_TEMPLATE:
  72018. endTagInTemplate(this, token);
  72019. break;
  72020. case InsertionMode.AFTER_BODY:
  72021. endTagAfterBody(this, token);
  72022. break;
  72023. case InsertionMode.IN_FRAMESET:
  72024. endTagInFrameset(this, token);
  72025. break;
  72026. case InsertionMode.AFTER_FRAMESET:
  72027. endTagAfterFrameset(this, token);
  72028. break;
  72029. case InsertionMode.AFTER_AFTER_BODY:
  72030. tokenAfterAfterBody(this, token);
  72031. break;
  72032. // Do nothing
  72033. }
  72034. }
  72035. onEof(token) {
  72036. switch (this.insertionMode) {
  72037. case InsertionMode.INITIAL:
  72038. tokenInInitialMode(this, token);
  72039. break;
  72040. case InsertionMode.BEFORE_HTML:
  72041. tokenBeforeHtml(this, token);
  72042. break;
  72043. case InsertionMode.BEFORE_HEAD:
  72044. tokenBeforeHead(this, token);
  72045. break;
  72046. case InsertionMode.IN_HEAD:
  72047. tokenInHead(this, token);
  72048. break;
  72049. case InsertionMode.IN_HEAD_NO_SCRIPT:
  72050. tokenInHeadNoScript(this, token);
  72051. break;
  72052. case InsertionMode.AFTER_HEAD:
  72053. tokenAfterHead(this, token);
  72054. break;
  72055. case InsertionMode.IN_BODY:
  72056. case InsertionMode.IN_TABLE:
  72057. case InsertionMode.IN_CAPTION:
  72058. case InsertionMode.IN_COLUMN_GROUP:
  72059. case InsertionMode.IN_TABLE_BODY:
  72060. case InsertionMode.IN_ROW:
  72061. case InsertionMode.IN_CELL:
  72062. case InsertionMode.IN_SELECT:
  72063. case InsertionMode.IN_SELECT_IN_TABLE:
  72064. eofInBody(this, token);
  72065. break;
  72066. case InsertionMode.TEXT:
  72067. eofInText(this, token);
  72068. break;
  72069. case InsertionMode.IN_TABLE_TEXT:
  72070. tokenInTableText(this, token);
  72071. break;
  72072. case InsertionMode.IN_TEMPLATE:
  72073. eofInTemplate(this, token);
  72074. break;
  72075. case InsertionMode.AFTER_BODY:
  72076. case InsertionMode.IN_FRAMESET:
  72077. case InsertionMode.AFTER_FRAMESET:
  72078. case InsertionMode.AFTER_AFTER_BODY:
  72079. case InsertionMode.AFTER_AFTER_FRAMESET:
  72080. stopParsing(this, token);
  72081. break;
  72082. // Do nothing
  72083. }
  72084. }
  72085. onWhitespaceCharacter(token) {
  72086. if (this.skipNextNewLine) {
  72087. this.skipNextNewLine = false;
  72088. if (token.chars.charCodeAt(0) === CODE_POINTS.LINE_FEED) {
  72089. if (token.chars.length === 1) {
  72090. return;
  72091. }
  72092. token.chars = token.chars.substr(1);
  72093. }
  72094. }
  72095. if (this.tokenizer.inForeignNode) {
  72096. this._insertCharacters(token);
  72097. return;
  72098. }
  72099. switch (this.insertionMode) {
  72100. case InsertionMode.IN_HEAD:
  72101. case InsertionMode.IN_HEAD_NO_SCRIPT:
  72102. case InsertionMode.AFTER_HEAD:
  72103. case InsertionMode.TEXT:
  72104. case InsertionMode.IN_COLUMN_GROUP:
  72105. case InsertionMode.IN_SELECT:
  72106. case InsertionMode.IN_SELECT_IN_TABLE:
  72107. case InsertionMode.IN_FRAMESET:
  72108. case InsertionMode.AFTER_FRAMESET:
  72109. this._insertCharacters(token);
  72110. break;
  72111. case InsertionMode.IN_BODY:
  72112. case InsertionMode.IN_CAPTION:
  72113. case InsertionMode.IN_CELL:
  72114. case InsertionMode.IN_TEMPLATE:
  72115. case InsertionMode.AFTER_BODY:
  72116. case InsertionMode.AFTER_AFTER_BODY:
  72117. case InsertionMode.AFTER_AFTER_FRAMESET:
  72118. whitespaceCharacterInBody(this, token);
  72119. break;
  72120. case InsertionMode.IN_TABLE:
  72121. case InsertionMode.IN_TABLE_BODY:
  72122. case InsertionMode.IN_ROW:
  72123. characterInTable(this, token);
  72124. break;
  72125. case InsertionMode.IN_TABLE_TEXT:
  72126. whitespaceCharacterInTableText(this, token);
  72127. break;
  72128. // Do nothing
  72129. }
  72130. }
  72131. }
  72132. //Adoption agency algorithm
  72133. //(see: http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#adoptionAgency)
  72134. //------------------------------------------------------------------
  72135. //Steps 5-8 of the algorithm
  72136. function aaObtainFormattingElementEntry(p, token) {
  72137. let formattingElementEntry = p.activeFormattingElements.getElementEntryInScopeWithTagName(token.tagName);
  72138. if (formattingElementEntry) {
  72139. if (!p.openElements.contains(formattingElementEntry.element)) {
  72140. p.activeFormattingElements.removeEntry(formattingElementEntry);
  72141. formattingElementEntry = null;
  72142. }
  72143. else if (!p.openElements.hasInScope(token.tagID)) {
  72144. formattingElementEntry = null;
  72145. }
  72146. }
  72147. else {
  72148. genericEndTagInBody(p, token);
  72149. }
  72150. return formattingElementEntry;
  72151. }
  72152. //Steps 9 and 10 of the algorithm
  72153. function aaObtainFurthestBlock(p, formattingElementEntry) {
  72154. let furthestBlock = null;
  72155. let idx = p.openElements.stackTop;
  72156. for (; idx >= 0; idx--) {
  72157. const element = p.openElements.items[idx];
  72158. if (element === formattingElementEntry.element) {
  72159. break;
  72160. }
  72161. if (p._isSpecialElement(element, p.openElements.tagIDs[idx])) {
  72162. furthestBlock = element;
  72163. }
  72164. }
  72165. if (!furthestBlock) {
  72166. p.openElements.shortenToLength(idx < 0 ? 0 : idx);
  72167. p.activeFormattingElements.removeEntry(formattingElementEntry);
  72168. }
  72169. return furthestBlock;
  72170. }
  72171. //Step 13 of the algorithm
  72172. function aaInnerLoop(p, furthestBlock, formattingElement) {
  72173. let lastElement = furthestBlock;
  72174. let nextElement = p.openElements.getCommonAncestor(furthestBlock);
  72175. for (let i = 0, element = nextElement; element !== formattingElement; i++, element = nextElement) {
  72176. //NOTE: store the next element for the next loop iteration (it may be deleted from the stack by step 9.5)
  72177. nextElement = p.openElements.getCommonAncestor(element);
  72178. const elementEntry = p.activeFormattingElements.getElementEntry(element);
  72179. const counterOverflow = elementEntry && i >= AA_INNER_LOOP_ITER;
  72180. const shouldRemoveFromOpenElements = !elementEntry || counterOverflow;
  72181. if (shouldRemoveFromOpenElements) {
  72182. if (counterOverflow) {
  72183. p.activeFormattingElements.removeEntry(elementEntry);
  72184. }
  72185. p.openElements.remove(element);
  72186. }
  72187. else {
  72188. element = aaRecreateElementFromEntry(p, elementEntry);
  72189. if (lastElement === furthestBlock) {
  72190. p.activeFormattingElements.bookmark = elementEntry;
  72191. }
  72192. p.treeAdapter.detachNode(lastElement);
  72193. p.treeAdapter.appendChild(element, lastElement);
  72194. lastElement = element;
  72195. }
  72196. }
  72197. return lastElement;
  72198. }
  72199. //Step 13.7 of the algorithm
  72200. function aaRecreateElementFromEntry(p, elementEntry) {
  72201. const ns = p.treeAdapter.getNamespaceURI(elementEntry.element);
  72202. const newElement = p.treeAdapter.createElement(elementEntry.token.tagName, ns, elementEntry.token.attrs);
  72203. p.openElements.replace(elementEntry.element, newElement);
  72204. elementEntry.element = newElement;
  72205. return newElement;
  72206. }
  72207. //Step 14 of the algorithm
  72208. function aaInsertLastNodeInCommonAncestor(p, commonAncestor, lastElement) {
  72209. const tn = p.treeAdapter.getTagName(commonAncestor);
  72210. const tid = getTagID(tn);
  72211. if (p._isElementCausesFosterParenting(tid)) {
  72212. p._fosterParentElement(lastElement);
  72213. }
  72214. else {
  72215. const ns = p.treeAdapter.getNamespaceURI(commonAncestor);
  72216. if (tid === TAG_ID.TEMPLATE && ns === NS.HTML) {
  72217. commonAncestor = p.treeAdapter.getTemplateContent(commonAncestor);
  72218. }
  72219. p.treeAdapter.appendChild(commonAncestor, lastElement);
  72220. }
  72221. }
  72222. //Steps 15-19 of the algorithm
  72223. function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {
  72224. const ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element);
  72225. const { token } = formattingElementEntry;
  72226. const newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);
  72227. p._adoptNodes(furthestBlock, newElement);
  72228. p.treeAdapter.appendChild(furthestBlock, newElement);
  72229. p.activeFormattingElements.insertElementAfterBookmark(newElement, token);
  72230. p.activeFormattingElements.removeEntry(formattingElementEntry);
  72231. p.openElements.remove(formattingElementEntry.element);
  72232. p.openElements.insertAfter(furthestBlock, newElement, token.tagID);
  72233. }
  72234. //Algorithm entry point
  72235. function callAdoptionAgency(p, token) {
  72236. for (let i = 0; i < AA_OUTER_LOOP_ITER; i++) {
  72237. const formattingElementEntry = aaObtainFormattingElementEntry(p, token);
  72238. if (!formattingElementEntry) {
  72239. break;
  72240. }
  72241. const furthestBlock = aaObtainFurthestBlock(p, formattingElementEntry);
  72242. if (!furthestBlock) {
  72243. break;
  72244. }
  72245. p.activeFormattingElements.bookmark = formattingElementEntry;
  72246. const lastElement = aaInnerLoop(p, furthestBlock, formattingElementEntry.element);
  72247. const commonAncestor = p.openElements.getCommonAncestor(formattingElementEntry.element);
  72248. p.treeAdapter.detachNode(lastElement);
  72249. if (commonAncestor)
  72250. aaInsertLastNodeInCommonAncestor(p, commonAncestor, lastElement);
  72251. aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry);
  72252. }
  72253. }
  72254. //Generic token handlers
  72255. //------------------------------------------------------------------
  72256. function appendComment(p, token) {
  72257. p._appendCommentNode(token, p.openElements.currentTmplContentOrNode);
  72258. }
  72259. function appendCommentToRootHtmlElement(p, token) {
  72260. p._appendCommentNode(token, p.openElements.items[0]);
  72261. }
  72262. function appendCommentToDocument(p, token) {
  72263. p._appendCommentNode(token, p.document);
  72264. }
  72265. function stopParsing(p, token) {
  72266. p.stopped = true;
  72267. // NOTE: Set end locations for elements that remain on the open element stack.
  72268. if (token.location) {
  72269. // NOTE: If we are not in a fragment, `html` and `body` will stay on the stack.
  72270. // This is a problem, as we might overwrite their end position here.
  72271. const target = p.fragmentContext ? 0 : 2;
  72272. for (let i = p.openElements.stackTop; i >= target; i--) {
  72273. p._setEndLocation(p.openElements.items[i], token);
  72274. }
  72275. // Handle `html` and `body`
  72276. if (!p.fragmentContext && p.openElements.stackTop >= 0) {
  72277. const htmlElement = p.openElements.items[0];
  72278. const htmlLocation = p.treeAdapter.getNodeSourceCodeLocation(htmlElement);
  72279. if (htmlLocation && !htmlLocation.endTag) {
  72280. p._setEndLocation(htmlElement, token);
  72281. if (p.openElements.stackTop >= 1) {
  72282. const bodyElement = p.openElements.items[1];
  72283. const bodyLocation = p.treeAdapter.getNodeSourceCodeLocation(bodyElement);
  72284. if (bodyLocation && !bodyLocation.endTag) {
  72285. p._setEndLocation(bodyElement, token);
  72286. }
  72287. }
  72288. }
  72289. }
  72290. }
  72291. }
  72292. // The "initial" insertion mode
  72293. //------------------------------------------------------------------
  72294. function doctypeInInitialMode(p, token) {
  72295. p._setDocumentType(token);
  72296. const mode = token.forceQuirks ? DOCUMENT_MODE.QUIRKS : getDocumentMode(token);
  72297. if (!isConforming(token)) {
  72298. p._err(token, ERR.nonConformingDoctype);
  72299. }
  72300. p.treeAdapter.setDocumentMode(p.document, mode);
  72301. p.insertionMode = InsertionMode.BEFORE_HTML;
  72302. }
  72303. function tokenInInitialMode(p, token) {
  72304. p._err(token, ERR.missingDoctype, true);
  72305. p.treeAdapter.setDocumentMode(p.document, DOCUMENT_MODE.QUIRKS);
  72306. p.insertionMode = InsertionMode.BEFORE_HTML;
  72307. p._processToken(token);
  72308. }
  72309. // The "before html" insertion mode
  72310. //------------------------------------------------------------------
  72311. function startTagBeforeHtml(p, token) {
  72312. if (token.tagID === TAG_ID.HTML) {
  72313. p._insertElement(token, NS.HTML);
  72314. p.insertionMode = InsertionMode.BEFORE_HEAD;
  72315. }
  72316. else {
  72317. tokenBeforeHtml(p, token);
  72318. }
  72319. }
  72320. function endTagBeforeHtml(p, token) {
  72321. const tn = token.tagID;
  72322. if (tn === TAG_ID.HTML || tn === TAG_ID.HEAD || tn === TAG_ID.BODY || tn === TAG_ID.BR) {
  72323. tokenBeforeHtml(p, token);
  72324. }
  72325. }
  72326. function tokenBeforeHtml(p, token) {
  72327. p._insertFakeRootElement();
  72328. p.insertionMode = InsertionMode.BEFORE_HEAD;
  72329. p._processToken(token);
  72330. }
  72331. // The "before head" insertion mode
  72332. //------------------------------------------------------------------
  72333. function startTagBeforeHead(p, token) {
  72334. switch (token.tagID) {
  72335. case TAG_ID.HTML: {
  72336. startTagInBody(p, token);
  72337. break;
  72338. }
  72339. case TAG_ID.HEAD: {
  72340. p._insertElement(token, NS.HTML);
  72341. p.headElement = p.openElements.current;
  72342. p.insertionMode = InsertionMode.IN_HEAD;
  72343. break;
  72344. }
  72345. default: {
  72346. tokenBeforeHead(p, token);
  72347. }
  72348. }
  72349. }
  72350. function endTagBeforeHead(p, token) {
  72351. const tn = token.tagID;
  72352. if (tn === TAG_ID.HEAD || tn === TAG_ID.BODY || tn === TAG_ID.HTML || tn === TAG_ID.BR) {
  72353. tokenBeforeHead(p, token);
  72354. }
  72355. else {
  72356. p._err(token, ERR.endTagWithoutMatchingOpenElement);
  72357. }
  72358. }
  72359. function tokenBeforeHead(p, token) {
  72360. p._insertFakeElement(TAG_NAMES.HEAD, TAG_ID.HEAD);
  72361. p.headElement = p.openElements.current;
  72362. p.insertionMode = InsertionMode.IN_HEAD;
  72363. p._processToken(token);
  72364. }
  72365. // The "in head" insertion mode
  72366. //------------------------------------------------------------------
  72367. function startTagInHead(p, token) {
  72368. switch (token.tagID) {
  72369. case TAG_ID.HTML: {
  72370. startTagInBody(p, token);
  72371. break;
  72372. }
  72373. case TAG_ID.BASE:
  72374. case TAG_ID.BASEFONT:
  72375. case TAG_ID.BGSOUND:
  72376. case TAG_ID.LINK:
  72377. case TAG_ID.META: {
  72378. p._appendElement(token, NS.HTML);
  72379. token.ackSelfClosing = true;
  72380. break;
  72381. }
  72382. case TAG_ID.TITLE: {
  72383. p._switchToTextParsing(token, TokenizerMode.RCDATA);
  72384. break;
  72385. }
  72386. case TAG_ID.NOSCRIPT: {
  72387. if (p.options.scriptingEnabled) {
  72388. p._switchToTextParsing(token, TokenizerMode.RAWTEXT);
  72389. }
  72390. else {
  72391. p._insertElement(token, NS.HTML);
  72392. p.insertionMode = InsertionMode.IN_HEAD_NO_SCRIPT;
  72393. }
  72394. break;
  72395. }
  72396. case TAG_ID.NOFRAMES:
  72397. case TAG_ID.STYLE: {
  72398. p._switchToTextParsing(token, TokenizerMode.RAWTEXT);
  72399. break;
  72400. }
  72401. case TAG_ID.SCRIPT: {
  72402. p._switchToTextParsing(token, TokenizerMode.SCRIPT_DATA);
  72403. break;
  72404. }
  72405. case TAG_ID.TEMPLATE: {
  72406. p._insertTemplate(token);
  72407. p.activeFormattingElements.insertMarker();
  72408. p.framesetOk = false;
  72409. p.insertionMode = InsertionMode.IN_TEMPLATE;
  72410. p.tmplInsertionModeStack.unshift(InsertionMode.IN_TEMPLATE);
  72411. break;
  72412. }
  72413. case TAG_ID.HEAD: {
  72414. p._err(token, ERR.misplacedStartTagForHeadElement);
  72415. break;
  72416. }
  72417. default: {
  72418. tokenInHead(p, token);
  72419. }
  72420. }
  72421. }
  72422. function endTagInHead(p, token) {
  72423. switch (token.tagID) {
  72424. case TAG_ID.HEAD: {
  72425. p.openElements.pop();
  72426. p.insertionMode = InsertionMode.AFTER_HEAD;
  72427. break;
  72428. }
  72429. case TAG_ID.BODY:
  72430. case TAG_ID.BR:
  72431. case TAG_ID.HTML: {
  72432. tokenInHead(p, token);
  72433. break;
  72434. }
  72435. case TAG_ID.TEMPLATE: {
  72436. if (p.openElements.tmplCount > 0) {
  72437. p.openElements.generateImpliedEndTagsThoroughly();
  72438. if (p.openElements.currentTagId !== TAG_ID.TEMPLATE) {
  72439. p._err(token, ERR.closingOfElementWithOpenChildElements);
  72440. }
  72441. p.openElements.popUntilTagNamePopped(TAG_ID.TEMPLATE);
  72442. p.activeFormattingElements.clearToLastMarker();
  72443. p.tmplInsertionModeStack.shift();
  72444. p._resetInsertionMode();
  72445. }
  72446. else {
  72447. p._err(token, ERR.endTagWithoutMatchingOpenElement);
  72448. }
  72449. break;
  72450. }
  72451. default: {
  72452. p._err(token, ERR.endTagWithoutMatchingOpenElement);
  72453. }
  72454. }
  72455. }
  72456. function tokenInHead(p, token) {
  72457. p.openElements.pop();
  72458. p.insertionMode = InsertionMode.AFTER_HEAD;
  72459. p._processToken(token);
  72460. }
  72461. // The "in head no script" insertion mode
  72462. //------------------------------------------------------------------
  72463. function startTagInHeadNoScript(p, token) {
  72464. switch (token.tagID) {
  72465. case TAG_ID.HTML: {
  72466. startTagInBody(p, token);
  72467. break;
  72468. }
  72469. case TAG_ID.BASEFONT:
  72470. case TAG_ID.BGSOUND:
  72471. case TAG_ID.HEAD:
  72472. case TAG_ID.LINK:
  72473. case TAG_ID.META:
  72474. case TAG_ID.NOFRAMES:
  72475. case TAG_ID.STYLE: {
  72476. startTagInHead(p, token);
  72477. break;
  72478. }
  72479. case TAG_ID.NOSCRIPT: {
  72480. p._err(token, ERR.nestedNoscriptInHead);
  72481. break;
  72482. }
  72483. default: {
  72484. tokenInHeadNoScript(p, token);
  72485. }
  72486. }
  72487. }
  72488. function endTagInHeadNoScript(p, token) {
  72489. switch (token.tagID) {
  72490. case TAG_ID.NOSCRIPT: {
  72491. p.openElements.pop();
  72492. p.insertionMode = InsertionMode.IN_HEAD;
  72493. break;
  72494. }
  72495. case TAG_ID.BR: {
  72496. tokenInHeadNoScript(p, token);
  72497. break;
  72498. }
  72499. default: {
  72500. p._err(token, ERR.endTagWithoutMatchingOpenElement);
  72501. }
  72502. }
  72503. }
  72504. function tokenInHeadNoScript(p, token) {
  72505. const errCode = token.type === TokenType.EOF ? ERR.openElementsLeftAfterEof : ERR.disallowedContentInNoscriptInHead;
  72506. p._err(token, errCode);
  72507. p.openElements.pop();
  72508. p.insertionMode = InsertionMode.IN_HEAD;
  72509. p._processToken(token);
  72510. }
  72511. // The "after head" insertion mode
  72512. //------------------------------------------------------------------
  72513. function startTagAfterHead(p, token) {
  72514. switch (token.tagID) {
  72515. case TAG_ID.HTML: {
  72516. startTagInBody(p, token);
  72517. break;
  72518. }
  72519. case TAG_ID.BODY: {
  72520. p._insertElement(token, NS.HTML);
  72521. p.framesetOk = false;
  72522. p.insertionMode = InsertionMode.IN_BODY;
  72523. break;
  72524. }
  72525. case TAG_ID.FRAMESET: {
  72526. p._insertElement(token, NS.HTML);
  72527. p.insertionMode = InsertionMode.IN_FRAMESET;
  72528. break;
  72529. }
  72530. case TAG_ID.BASE:
  72531. case TAG_ID.BASEFONT:
  72532. case TAG_ID.BGSOUND:
  72533. case TAG_ID.LINK:
  72534. case TAG_ID.META:
  72535. case TAG_ID.NOFRAMES:
  72536. case TAG_ID.SCRIPT:
  72537. case TAG_ID.STYLE:
  72538. case TAG_ID.TEMPLATE:
  72539. case TAG_ID.TITLE: {
  72540. p._err(token, ERR.abandonedHeadElementChild);
  72541. p.openElements.push(p.headElement, TAG_ID.HEAD);
  72542. startTagInHead(p, token);
  72543. p.openElements.remove(p.headElement);
  72544. break;
  72545. }
  72546. case TAG_ID.HEAD: {
  72547. p._err(token, ERR.misplacedStartTagForHeadElement);
  72548. break;
  72549. }
  72550. default: {
  72551. tokenAfterHead(p, token);
  72552. }
  72553. }
  72554. }
  72555. function endTagAfterHead(p, token) {
  72556. switch (token.tagID) {
  72557. case TAG_ID.BODY:
  72558. case TAG_ID.HTML:
  72559. case TAG_ID.BR: {
  72560. tokenAfterHead(p, token);
  72561. break;
  72562. }
  72563. case TAG_ID.TEMPLATE: {
  72564. endTagInHead(p, token);
  72565. break;
  72566. }
  72567. default: {
  72568. p._err(token, ERR.endTagWithoutMatchingOpenElement);
  72569. }
  72570. }
  72571. }
  72572. function tokenAfterHead(p, token) {
  72573. p._insertFakeElement(TAG_NAMES.BODY, TAG_ID.BODY);
  72574. p.insertionMode = InsertionMode.IN_BODY;
  72575. modeInBody(p, token);
  72576. }
  72577. // The "in body" insertion mode
  72578. //------------------------------------------------------------------
  72579. function modeInBody(p, token) {
  72580. switch (token.type) {
  72581. case TokenType.CHARACTER: {
  72582. characterInBody(p, token);
  72583. break;
  72584. }
  72585. case TokenType.WHITESPACE_CHARACTER: {
  72586. whitespaceCharacterInBody(p, token);
  72587. break;
  72588. }
  72589. case TokenType.COMMENT: {
  72590. appendComment(p, token);
  72591. break;
  72592. }
  72593. case TokenType.START_TAG: {
  72594. startTagInBody(p, token);
  72595. break;
  72596. }
  72597. case TokenType.END_TAG: {
  72598. endTagInBody(p, token);
  72599. break;
  72600. }
  72601. case TokenType.EOF: {
  72602. eofInBody(p, token);
  72603. break;
  72604. }
  72605. // Do nothing
  72606. }
  72607. }
  72608. function whitespaceCharacterInBody(p, token) {
  72609. p._reconstructActiveFormattingElements();
  72610. p._insertCharacters(token);
  72611. }
  72612. function characterInBody(p, token) {
  72613. p._reconstructActiveFormattingElements();
  72614. p._insertCharacters(token);
  72615. p.framesetOk = false;
  72616. }
  72617. function htmlStartTagInBody(p, token) {
  72618. if (p.openElements.tmplCount === 0) {
  72619. p.treeAdapter.adoptAttributes(p.openElements.items[0], token.attrs);
  72620. }
  72621. }
  72622. function bodyStartTagInBody(p, token) {
  72623. const bodyElement = p.openElements.tryPeekProperlyNestedBodyElement();
  72624. if (bodyElement && p.openElements.tmplCount === 0) {
  72625. p.framesetOk = false;
  72626. p.treeAdapter.adoptAttributes(bodyElement, token.attrs);
  72627. }
  72628. }
  72629. function framesetStartTagInBody(p, token) {
  72630. const bodyElement = p.openElements.tryPeekProperlyNestedBodyElement();
  72631. if (p.framesetOk && bodyElement) {
  72632. p.treeAdapter.detachNode(bodyElement);
  72633. p.openElements.popAllUpToHtmlElement();
  72634. p._insertElement(token, NS.HTML);
  72635. p.insertionMode = InsertionMode.IN_FRAMESET;
  72636. }
  72637. }
  72638. function addressStartTagInBody(p, token) {
  72639. if (p.openElements.hasInButtonScope(TAG_ID.P)) {
  72640. p._closePElement();
  72641. }
  72642. p._insertElement(token, NS.HTML);
  72643. }
  72644. function numberedHeaderStartTagInBody(p, token) {
  72645. if (p.openElements.hasInButtonScope(TAG_ID.P)) {
  72646. p._closePElement();
  72647. }
  72648. if (isNumberedHeader(p.openElements.currentTagId)) {
  72649. p.openElements.pop();
  72650. }
  72651. p._insertElement(token, NS.HTML);
  72652. }
  72653. function preStartTagInBody(p, token) {
  72654. if (p.openElements.hasInButtonScope(TAG_ID.P)) {
  72655. p._closePElement();
  72656. }
  72657. p._insertElement(token, NS.HTML);
  72658. //NOTE: If the next token is a U+000A LINE FEED (LF) character token, then ignore that token and move
  72659. //on to the next one. (Newlines at the start of pre blocks are ignored as an authoring convenience.)
  72660. p.skipNextNewLine = true;
  72661. p.framesetOk = false;
  72662. }
  72663. function formStartTagInBody(p, token) {
  72664. const inTemplate = p.openElements.tmplCount > 0;
  72665. if (!p.formElement || inTemplate) {
  72666. if (p.openElements.hasInButtonScope(TAG_ID.P)) {
  72667. p._closePElement();
  72668. }
  72669. p._insertElement(token, NS.HTML);
  72670. if (!inTemplate) {
  72671. p.formElement = p.openElements.current;
  72672. }
  72673. }
  72674. }
  72675. function listItemStartTagInBody(p, token) {
  72676. p.framesetOk = false;
  72677. const tn = token.tagID;
  72678. for (let i = p.openElements.stackTop; i >= 0; i--) {
  72679. const elementId = p.openElements.tagIDs[i];
  72680. if ((tn === TAG_ID.LI && elementId === TAG_ID.LI) ||
  72681. ((tn === TAG_ID.DD || tn === TAG_ID.DT) && (elementId === TAG_ID.DD || elementId === TAG_ID.DT))) {
  72682. p.openElements.generateImpliedEndTagsWithExclusion(elementId);
  72683. p.openElements.popUntilTagNamePopped(elementId);
  72684. break;
  72685. }
  72686. if (elementId !== TAG_ID.ADDRESS &&
  72687. elementId !== TAG_ID.DIV &&
  72688. elementId !== TAG_ID.P &&
  72689. p._isSpecialElement(p.openElements.items[i], elementId)) {
  72690. break;
  72691. }
  72692. }
  72693. if (p.openElements.hasInButtonScope(TAG_ID.P)) {
  72694. p._closePElement();
  72695. }
  72696. p._insertElement(token, NS.HTML);
  72697. }
  72698. function plaintextStartTagInBody(p, token) {
  72699. if (p.openElements.hasInButtonScope(TAG_ID.P)) {
  72700. p._closePElement();
  72701. }
  72702. p._insertElement(token, NS.HTML);
  72703. p.tokenizer.state = TokenizerMode.PLAINTEXT;
  72704. }
  72705. function buttonStartTagInBody(p, token) {
  72706. if (p.openElements.hasInScope(TAG_ID.BUTTON)) {
  72707. p.openElements.generateImpliedEndTags();
  72708. p.openElements.popUntilTagNamePopped(TAG_ID.BUTTON);
  72709. }
  72710. p._reconstructActiveFormattingElements();
  72711. p._insertElement(token, NS.HTML);
  72712. p.framesetOk = false;
  72713. }
  72714. function aStartTagInBody(p, token) {
  72715. const activeElementEntry = p.activeFormattingElements.getElementEntryInScopeWithTagName(TAG_NAMES.A);
  72716. if (activeElementEntry) {
  72717. callAdoptionAgency(p, token);
  72718. p.openElements.remove(activeElementEntry.element);
  72719. p.activeFormattingElements.removeEntry(activeElementEntry);
  72720. }
  72721. p._reconstructActiveFormattingElements();
  72722. p._insertElement(token, NS.HTML);
  72723. p.activeFormattingElements.pushElement(p.openElements.current, token);
  72724. }
  72725. function bStartTagInBody(p, token) {
  72726. p._reconstructActiveFormattingElements();
  72727. p._insertElement(token, NS.HTML);
  72728. p.activeFormattingElements.pushElement(p.openElements.current, token);
  72729. }
  72730. function nobrStartTagInBody(p, token) {
  72731. p._reconstructActiveFormattingElements();
  72732. if (p.openElements.hasInScope(TAG_ID.NOBR)) {
  72733. callAdoptionAgency(p, token);
  72734. p._reconstructActiveFormattingElements();
  72735. }
  72736. p._insertElement(token, NS.HTML);
  72737. p.activeFormattingElements.pushElement(p.openElements.current, token);
  72738. }
  72739. function appletStartTagInBody(p, token) {
  72740. p._reconstructActiveFormattingElements();
  72741. p._insertElement(token, NS.HTML);
  72742. p.activeFormattingElements.insertMarker();
  72743. p.framesetOk = false;
  72744. }
  72745. function tableStartTagInBody(p, token) {
  72746. if (p.treeAdapter.getDocumentMode(p.document) !== DOCUMENT_MODE.QUIRKS && p.openElements.hasInButtonScope(TAG_ID.P)) {
  72747. p._closePElement();
  72748. }
  72749. p._insertElement(token, NS.HTML);
  72750. p.framesetOk = false;
  72751. p.insertionMode = InsertionMode.IN_TABLE;
  72752. }
  72753. function areaStartTagInBody(p, token) {
  72754. p._reconstructActiveFormattingElements();
  72755. p._appendElement(token, NS.HTML);
  72756. p.framesetOk = false;
  72757. token.ackSelfClosing = true;
  72758. }
  72759. function isHiddenInput(token) {
  72760. const inputType = getTokenAttr(token, ATTRS.TYPE);
  72761. return inputType != null && inputType.toLowerCase() === HIDDEN_INPUT_TYPE;
  72762. }
  72763. function inputStartTagInBody(p, token) {
  72764. p._reconstructActiveFormattingElements();
  72765. p._appendElement(token, NS.HTML);
  72766. if (!isHiddenInput(token)) {
  72767. p.framesetOk = false;
  72768. }
  72769. token.ackSelfClosing = true;
  72770. }
  72771. function paramStartTagInBody(p, token) {
  72772. p._appendElement(token, NS.HTML);
  72773. token.ackSelfClosing = true;
  72774. }
  72775. function hrStartTagInBody(p, token) {
  72776. if (p.openElements.hasInButtonScope(TAG_ID.P)) {
  72777. p._closePElement();
  72778. }
  72779. p._appendElement(token, NS.HTML);
  72780. p.framesetOk = false;
  72781. token.ackSelfClosing = true;
  72782. }
  72783. function imageStartTagInBody(p, token) {
  72784. token.tagName = TAG_NAMES.IMG;
  72785. token.tagID = TAG_ID.IMG;
  72786. areaStartTagInBody(p, token);
  72787. }
  72788. function textareaStartTagInBody(p, token) {
  72789. p._insertElement(token, NS.HTML);
  72790. //NOTE: If the next token is a U+000A LINE FEED (LF) character token, then ignore that token and move
  72791. //on to the next one. (Newlines at the start of textarea elements are ignored as an authoring convenience.)
  72792. p.skipNextNewLine = true;
  72793. p.tokenizer.state = TokenizerMode.RCDATA;
  72794. p.originalInsertionMode = p.insertionMode;
  72795. p.framesetOk = false;
  72796. p.insertionMode = InsertionMode.TEXT;
  72797. }
  72798. function xmpStartTagInBody(p, token) {
  72799. if (p.openElements.hasInButtonScope(TAG_ID.P)) {
  72800. p._closePElement();
  72801. }
  72802. p._reconstructActiveFormattingElements();
  72803. p.framesetOk = false;
  72804. p._switchToTextParsing(token, TokenizerMode.RAWTEXT);
  72805. }
  72806. function iframeStartTagInBody(p, token) {
  72807. p.framesetOk = false;
  72808. p._switchToTextParsing(token, TokenizerMode.RAWTEXT);
  72809. }
  72810. //NOTE: here we assume that we always act as an user agent with enabled plugins, so we parse
  72811. //<noembed> as rawtext.
  72812. function noembedStartTagInBody(p, token) {
  72813. p._switchToTextParsing(token, TokenizerMode.RAWTEXT);
  72814. }
  72815. function selectStartTagInBody(p, token) {
  72816. p._reconstructActiveFormattingElements();
  72817. p._insertElement(token, NS.HTML);
  72818. p.framesetOk = false;
  72819. p.insertionMode =
  72820. p.insertionMode === InsertionMode.IN_TABLE ||
  72821. p.insertionMode === InsertionMode.IN_CAPTION ||
  72822. p.insertionMode === InsertionMode.IN_TABLE_BODY ||
  72823. p.insertionMode === InsertionMode.IN_ROW ||
  72824. p.insertionMode === InsertionMode.IN_CELL
  72825. ? InsertionMode.IN_SELECT_IN_TABLE
  72826. : InsertionMode.IN_SELECT;
  72827. }
  72828. function optgroupStartTagInBody(p, token) {
  72829. if (p.openElements.currentTagId === TAG_ID.OPTION) {
  72830. p.openElements.pop();
  72831. }
  72832. p._reconstructActiveFormattingElements();
  72833. p._insertElement(token, NS.HTML);
  72834. }
  72835. function rbStartTagInBody(p, token) {
  72836. if (p.openElements.hasInScope(TAG_ID.RUBY)) {
  72837. p.openElements.generateImpliedEndTags();
  72838. }
  72839. p._insertElement(token, NS.HTML);
  72840. }
  72841. function rtStartTagInBody(p, token) {
  72842. if (p.openElements.hasInScope(TAG_ID.RUBY)) {
  72843. p.openElements.generateImpliedEndTagsWithExclusion(TAG_ID.RTC);
  72844. }
  72845. p._insertElement(token, NS.HTML);
  72846. }
  72847. function mathStartTagInBody(p, token) {
  72848. p._reconstructActiveFormattingElements();
  72849. adjustTokenMathMLAttrs(token);
  72850. adjustTokenXMLAttrs(token);
  72851. if (token.selfClosing) {
  72852. p._appendElement(token, NS.MATHML);
  72853. }
  72854. else {
  72855. p._insertElement(token, NS.MATHML);
  72856. }
  72857. token.ackSelfClosing = true;
  72858. }
  72859. function svgStartTagInBody(p, token) {
  72860. p._reconstructActiveFormattingElements();
  72861. adjustTokenSVGAttrs(token);
  72862. adjustTokenXMLAttrs(token);
  72863. if (token.selfClosing) {
  72864. p._appendElement(token, NS.SVG);
  72865. }
  72866. else {
  72867. p._insertElement(token, NS.SVG);
  72868. }
  72869. token.ackSelfClosing = true;
  72870. }
  72871. function genericStartTagInBody(p, token) {
  72872. p._reconstructActiveFormattingElements();
  72873. p._insertElement(token, NS.HTML);
  72874. }
  72875. function startTagInBody(p, token) {
  72876. switch (token.tagID) {
  72877. case TAG_ID.I:
  72878. case TAG_ID.S:
  72879. case TAG_ID.B:
  72880. case TAG_ID.U:
  72881. case TAG_ID.EM:
  72882. case TAG_ID.TT:
  72883. case TAG_ID.BIG:
  72884. case TAG_ID.CODE:
  72885. case TAG_ID.FONT:
  72886. case TAG_ID.SMALL:
  72887. case TAG_ID.STRIKE:
  72888. case TAG_ID.STRONG: {
  72889. bStartTagInBody(p, token);
  72890. break;
  72891. }
  72892. case TAG_ID.A: {
  72893. aStartTagInBody(p, token);
  72894. break;
  72895. }
  72896. case TAG_ID.H1:
  72897. case TAG_ID.H2:
  72898. case TAG_ID.H3:
  72899. case TAG_ID.H4:
  72900. case TAG_ID.H5:
  72901. case TAG_ID.H6: {
  72902. numberedHeaderStartTagInBody(p, token);
  72903. break;
  72904. }
  72905. case TAG_ID.P:
  72906. case TAG_ID.DL:
  72907. case TAG_ID.OL:
  72908. case TAG_ID.UL:
  72909. case TAG_ID.DIV:
  72910. case TAG_ID.DIR:
  72911. case TAG_ID.NAV:
  72912. case TAG_ID.MAIN:
  72913. case TAG_ID.MENU:
  72914. case TAG_ID.ASIDE:
  72915. case TAG_ID.CENTER:
  72916. case TAG_ID.FIGURE:
  72917. case TAG_ID.FOOTER:
  72918. case TAG_ID.HEADER:
  72919. case TAG_ID.HGROUP:
  72920. case TAG_ID.DIALOG:
  72921. case TAG_ID.DETAILS:
  72922. case TAG_ID.ADDRESS:
  72923. case TAG_ID.ARTICLE:
  72924. case TAG_ID.SECTION:
  72925. case TAG_ID.SUMMARY:
  72926. case TAG_ID.FIELDSET:
  72927. case TAG_ID.BLOCKQUOTE:
  72928. case TAG_ID.FIGCAPTION: {
  72929. addressStartTagInBody(p, token);
  72930. break;
  72931. }
  72932. case TAG_ID.LI:
  72933. case TAG_ID.DD:
  72934. case TAG_ID.DT: {
  72935. listItemStartTagInBody(p, token);
  72936. break;
  72937. }
  72938. case TAG_ID.BR:
  72939. case TAG_ID.IMG:
  72940. case TAG_ID.WBR:
  72941. case TAG_ID.AREA:
  72942. case TAG_ID.EMBED:
  72943. case TAG_ID.KEYGEN: {
  72944. areaStartTagInBody(p, token);
  72945. break;
  72946. }
  72947. case TAG_ID.HR: {
  72948. hrStartTagInBody(p, token);
  72949. break;
  72950. }
  72951. case TAG_ID.RB:
  72952. case TAG_ID.RTC: {
  72953. rbStartTagInBody(p, token);
  72954. break;
  72955. }
  72956. case TAG_ID.RT:
  72957. case TAG_ID.RP: {
  72958. rtStartTagInBody(p, token);
  72959. break;
  72960. }
  72961. case TAG_ID.PRE:
  72962. case TAG_ID.LISTING: {
  72963. preStartTagInBody(p, token);
  72964. break;
  72965. }
  72966. case TAG_ID.XMP: {
  72967. xmpStartTagInBody(p, token);
  72968. break;
  72969. }
  72970. case TAG_ID.SVG: {
  72971. svgStartTagInBody(p, token);
  72972. break;
  72973. }
  72974. case TAG_ID.HTML: {
  72975. htmlStartTagInBody(p, token);
  72976. break;
  72977. }
  72978. case TAG_ID.BASE:
  72979. case TAG_ID.LINK:
  72980. case TAG_ID.META:
  72981. case TAG_ID.STYLE:
  72982. case TAG_ID.TITLE:
  72983. case TAG_ID.SCRIPT:
  72984. case TAG_ID.BGSOUND:
  72985. case TAG_ID.BASEFONT:
  72986. case TAG_ID.TEMPLATE: {
  72987. startTagInHead(p, token);
  72988. break;
  72989. }
  72990. case TAG_ID.BODY: {
  72991. bodyStartTagInBody(p, token);
  72992. break;
  72993. }
  72994. case TAG_ID.FORM: {
  72995. formStartTagInBody(p, token);
  72996. break;
  72997. }
  72998. case TAG_ID.NOBR: {
  72999. nobrStartTagInBody(p, token);
  73000. break;
  73001. }
  73002. case TAG_ID.MATH: {
  73003. mathStartTagInBody(p, token);
  73004. break;
  73005. }
  73006. case TAG_ID.TABLE: {
  73007. tableStartTagInBody(p, token);
  73008. break;
  73009. }
  73010. case TAG_ID.INPUT: {
  73011. inputStartTagInBody(p, token);
  73012. break;
  73013. }
  73014. case TAG_ID.PARAM:
  73015. case TAG_ID.TRACK:
  73016. case TAG_ID.SOURCE: {
  73017. paramStartTagInBody(p, token);
  73018. break;
  73019. }
  73020. case TAG_ID.IMAGE: {
  73021. imageStartTagInBody(p, token);
  73022. break;
  73023. }
  73024. case TAG_ID.BUTTON: {
  73025. buttonStartTagInBody(p, token);
  73026. break;
  73027. }
  73028. case TAG_ID.APPLET:
  73029. case TAG_ID.OBJECT:
  73030. case TAG_ID.MARQUEE: {
  73031. appletStartTagInBody(p, token);
  73032. break;
  73033. }
  73034. case TAG_ID.IFRAME: {
  73035. iframeStartTagInBody(p, token);
  73036. break;
  73037. }
  73038. case TAG_ID.SELECT: {
  73039. selectStartTagInBody(p, token);
  73040. break;
  73041. }
  73042. case TAG_ID.OPTION:
  73043. case TAG_ID.OPTGROUP: {
  73044. optgroupStartTagInBody(p, token);
  73045. break;
  73046. }
  73047. case TAG_ID.NOEMBED: {
  73048. noembedStartTagInBody(p, token);
  73049. break;
  73050. }
  73051. case TAG_ID.FRAMESET: {
  73052. framesetStartTagInBody(p, token);
  73053. break;
  73054. }
  73055. case TAG_ID.TEXTAREA: {
  73056. textareaStartTagInBody(p, token);
  73057. break;
  73058. }
  73059. case TAG_ID.NOSCRIPT: {
  73060. if (p.options.scriptingEnabled) {
  73061. noembedStartTagInBody(p, token);
  73062. }
  73063. else {
  73064. genericStartTagInBody(p, token);
  73065. }
  73066. break;
  73067. }
  73068. case TAG_ID.PLAINTEXT: {
  73069. plaintextStartTagInBody(p, token);
  73070. break;
  73071. }
  73072. case TAG_ID.COL:
  73073. case TAG_ID.TH:
  73074. case TAG_ID.TD:
  73075. case TAG_ID.TR:
  73076. case TAG_ID.HEAD:
  73077. case TAG_ID.FRAME:
  73078. case TAG_ID.TBODY:
  73079. case TAG_ID.TFOOT:
  73080. case TAG_ID.THEAD:
  73081. case TAG_ID.CAPTION:
  73082. case TAG_ID.COLGROUP: {
  73083. // Ignore token
  73084. break;
  73085. }
  73086. default: {
  73087. genericStartTagInBody(p, token);
  73088. }
  73089. }
  73090. }
  73091. function bodyEndTagInBody(p, token) {
  73092. if (p.openElements.hasInScope(TAG_ID.BODY)) {
  73093. p.insertionMode = InsertionMode.AFTER_BODY;
  73094. //NOTE: <body> is never popped from the stack, so we need to updated
  73095. //the end location explicitly.
  73096. if (p.options.sourceCodeLocationInfo) {
  73097. const bodyElement = p.openElements.tryPeekProperlyNestedBodyElement();
  73098. if (bodyElement) {
  73099. p._setEndLocation(bodyElement, token);
  73100. }
  73101. }
  73102. }
  73103. }
  73104. function htmlEndTagInBody(p, token) {
  73105. if (p.openElements.hasInScope(TAG_ID.BODY)) {
  73106. p.insertionMode = InsertionMode.AFTER_BODY;
  73107. endTagAfterBody(p, token);
  73108. }
  73109. }
  73110. function addressEndTagInBody(p, token) {
  73111. const tn = token.tagID;
  73112. if (p.openElements.hasInScope(tn)) {
  73113. p.openElements.generateImpliedEndTags();
  73114. p.openElements.popUntilTagNamePopped(tn);
  73115. }
  73116. }
  73117. function formEndTagInBody(p) {
  73118. const inTemplate = p.openElements.tmplCount > 0;
  73119. const { formElement } = p;
  73120. if (!inTemplate) {
  73121. p.formElement = null;
  73122. }
  73123. if ((formElement || inTemplate) && p.openElements.hasInScope(TAG_ID.FORM)) {
  73124. p.openElements.generateImpliedEndTags();
  73125. if (inTemplate) {
  73126. p.openElements.popUntilTagNamePopped(TAG_ID.FORM);
  73127. }
  73128. else if (formElement) {
  73129. p.openElements.remove(formElement);
  73130. }
  73131. }
  73132. }
  73133. function pEndTagInBody(p) {
  73134. if (!p.openElements.hasInButtonScope(TAG_ID.P)) {
  73135. p._insertFakeElement(TAG_NAMES.P, TAG_ID.P);
  73136. }
  73137. p._closePElement();
  73138. }
  73139. function liEndTagInBody(p) {
  73140. if (p.openElements.hasInListItemScope(TAG_ID.LI)) {
  73141. p.openElements.generateImpliedEndTagsWithExclusion(TAG_ID.LI);
  73142. p.openElements.popUntilTagNamePopped(TAG_ID.LI);
  73143. }
  73144. }
  73145. function ddEndTagInBody(p, token) {
  73146. const tn = token.tagID;
  73147. if (p.openElements.hasInScope(tn)) {
  73148. p.openElements.generateImpliedEndTagsWithExclusion(tn);
  73149. p.openElements.popUntilTagNamePopped(tn);
  73150. }
  73151. }
  73152. function numberedHeaderEndTagInBody(p) {
  73153. if (p.openElements.hasNumberedHeaderInScope()) {
  73154. p.openElements.generateImpliedEndTags();
  73155. p.openElements.popUntilNumberedHeaderPopped();
  73156. }
  73157. }
  73158. function appletEndTagInBody(p, token) {
  73159. const tn = token.tagID;
  73160. if (p.openElements.hasInScope(tn)) {
  73161. p.openElements.generateImpliedEndTags();
  73162. p.openElements.popUntilTagNamePopped(tn);
  73163. p.activeFormattingElements.clearToLastMarker();
  73164. }
  73165. }
  73166. function brEndTagInBody(p) {
  73167. p._reconstructActiveFormattingElements();
  73168. p._insertFakeElement(TAG_NAMES.BR, TAG_ID.BR);
  73169. p.openElements.pop();
  73170. p.framesetOk = false;
  73171. }
  73172. function genericEndTagInBody(p, token) {
  73173. const tn = token.tagName;
  73174. const tid = token.tagID;
  73175. for (let i = p.openElements.stackTop; i > 0; i--) {
  73176. const element = p.openElements.items[i];
  73177. const elementId = p.openElements.tagIDs[i];
  73178. // Compare the tag name here, as the tag might not be a known tag with an ID.
  73179. if (tid === elementId && (tid !== TAG_ID.UNKNOWN || p.treeAdapter.getTagName(element) === tn)) {
  73180. p.openElements.generateImpliedEndTagsWithExclusion(tid);
  73181. if (p.openElements.stackTop >= i)
  73182. p.openElements.shortenToLength(i);
  73183. break;
  73184. }
  73185. if (p._isSpecialElement(element, elementId)) {
  73186. break;
  73187. }
  73188. }
  73189. }
  73190. function endTagInBody(p, token) {
  73191. switch (token.tagID) {
  73192. case TAG_ID.A:
  73193. case TAG_ID.B:
  73194. case TAG_ID.I:
  73195. case TAG_ID.S:
  73196. case TAG_ID.U:
  73197. case TAG_ID.EM:
  73198. case TAG_ID.TT:
  73199. case TAG_ID.BIG:
  73200. case TAG_ID.CODE:
  73201. case TAG_ID.FONT:
  73202. case TAG_ID.NOBR:
  73203. case TAG_ID.SMALL:
  73204. case TAG_ID.STRIKE:
  73205. case TAG_ID.STRONG: {
  73206. callAdoptionAgency(p, token);
  73207. break;
  73208. }
  73209. case TAG_ID.P: {
  73210. pEndTagInBody(p);
  73211. break;
  73212. }
  73213. case TAG_ID.DL:
  73214. case TAG_ID.UL:
  73215. case TAG_ID.OL:
  73216. case TAG_ID.DIR:
  73217. case TAG_ID.DIV:
  73218. case TAG_ID.NAV:
  73219. case TAG_ID.PRE:
  73220. case TAG_ID.MAIN:
  73221. case TAG_ID.MENU:
  73222. case TAG_ID.ASIDE:
  73223. case TAG_ID.CENTER:
  73224. case TAG_ID.FIGURE:
  73225. case TAG_ID.FOOTER:
  73226. case TAG_ID.HEADER:
  73227. case TAG_ID.HGROUP:
  73228. case TAG_ID.DIALOG:
  73229. case TAG_ID.ADDRESS:
  73230. case TAG_ID.ARTICLE:
  73231. case TAG_ID.DETAILS:
  73232. case TAG_ID.SECTION:
  73233. case TAG_ID.SUMMARY:
  73234. case TAG_ID.LISTING:
  73235. case TAG_ID.FIELDSET:
  73236. case TAG_ID.BLOCKQUOTE:
  73237. case TAG_ID.FIGCAPTION: {
  73238. addressEndTagInBody(p, token);
  73239. break;
  73240. }
  73241. case TAG_ID.LI: {
  73242. liEndTagInBody(p);
  73243. break;
  73244. }
  73245. case TAG_ID.DD:
  73246. case TAG_ID.DT: {
  73247. ddEndTagInBody(p, token);
  73248. break;
  73249. }
  73250. case TAG_ID.H1:
  73251. case TAG_ID.H2:
  73252. case TAG_ID.H3:
  73253. case TAG_ID.H4:
  73254. case TAG_ID.H5:
  73255. case TAG_ID.H6: {
  73256. numberedHeaderEndTagInBody(p);
  73257. break;
  73258. }
  73259. case TAG_ID.BR: {
  73260. brEndTagInBody(p);
  73261. break;
  73262. }
  73263. case TAG_ID.BODY: {
  73264. bodyEndTagInBody(p, token);
  73265. break;
  73266. }
  73267. case TAG_ID.HTML: {
  73268. htmlEndTagInBody(p, token);
  73269. break;
  73270. }
  73271. case TAG_ID.FORM: {
  73272. formEndTagInBody(p);
  73273. break;
  73274. }
  73275. case TAG_ID.APPLET:
  73276. case TAG_ID.OBJECT:
  73277. case TAG_ID.MARQUEE: {
  73278. appletEndTagInBody(p, token);
  73279. break;
  73280. }
  73281. case TAG_ID.TEMPLATE: {
  73282. endTagInHead(p, token);
  73283. break;
  73284. }
  73285. default: {
  73286. genericEndTagInBody(p, token);
  73287. }
  73288. }
  73289. }
  73290. function eofInBody(p, token) {
  73291. if (p.tmplInsertionModeStack.length > 0) {
  73292. eofInTemplate(p, token);
  73293. }
  73294. else {
  73295. stopParsing(p, token);
  73296. }
  73297. }
  73298. // The "text" insertion mode
  73299. //------------------------------------------------------------------
  73300. function endTagInText(p, token) {
  73301. var _a;
  73302. if (token.tagID === TAG_ID.SCRIPT) {
  73303. (_a = p.scriptHandler) === null || _a === void 0 ? void 0 : _a.call(p, p.openElements.current);
  73304. }
  73305. p.openElements.pop();
  73306. p.insertionMode = p.originalInsertionMode;
  73307. }
  73308. function eofInText(p, token) {
  73309. p._err(token, ERR.eofInElementThatCanContainOnlyText);
  73310. p.openElements.pop();
  73311. p.insertionMode = p.originalInsertionMode;
  73312. p.onEof(token);
  73313. }
  73314. // The "in table" insertion mode
  73315. //------------------------------------------------------------------
  73316. function characterInTable(p, token) {
  73317. if (TABLE_STRUCTURE_TAGS.has(p.openElements.currentTagId)) {
  73318. p.pendingCharacterTokens.length = 0;
  73319. p.hasNonWhitespacePendingCharacterToken = false;
  73320. p.originalInsertionMode = p.insertionMode;
  73321. p.insertionMode = InsertionMode.IN_TABLE_TEXT;
  73322. switch (token.type) {
  73323. case TokenType.CHARACTER: {
  73324. characterInTableText(p, token);
  73325. break;
  73326. }
  73327. case TokenType.WHITESPACE_CHARACTER: {
  73328. whitespaceCharacterInTableText(p, token);
  73329. break;
  73330. }
  73331. // Ignore null
  73332. }
  73333. }
  73334. else {
  73335. tokenInTable(p, token);
  73336. }
  73337. }
  73338. function captionStartTagInTable(p, token) {
  73339. p.openElements.clearBackToTableContext();
  73340. p.activeFormattingElements.insertMarker();
  73341. p._insertElement(token, NS.HTML);
  73342. p.insertionMode = InsertionMode.IN_CAPTION;
  73343. }
  73344. function colgroupStartTagInTable(p, token) {
  73345. p.openElements.clearBackToTableContext();
  73346. p._insertElement(token, NS.HTML);
  73347. p.insertionMode = InsertionMode.IN_COLUMN_GROUP;
  73348. }
  73349. function colStartTagInTable(p, token) {
  73350. p.openElements.clearBackToTableContext();
  73351. p._insertFakeElement(TAG_NAMES.COLGROUP, TAG_ID.COLGROUP);
  73352. p.insertionMode = InsertionMode.IN_COLUMN_GROUP;
  73353. startTagInColumnGroup(p, token);
  73354. }
  73355. function tbodyStartTagInTable(p, token) {
  73356. p.openElements.clearBackToTableContext();
  73357. p._insertElement(token, NS.HTML);
  73358. p.insertionMode = InsertionMode.IN_TABLE_BODY;
  73359. }
  73360. function tdStartTagInTable(p, token) {
  73361. p.openElements.clearBackToTableContext();
  73362. p._insertFakeElement(TAG_NAMES.TBODY, TAG_ID.TBODY);
  73363. p.insertionMode = InsertionMode.IN_TABLE_BODY;
  73364. startTagInTableBody(p, token);
  73365. }
  73366. function tableStartTagInTable(p, token) {
  73367. if (p.openElements.hasInTableScope(TAG_ID.TABLE)) {
  73368. p.openElements.popUntilTagNamePopped(TAG_ID.TABLE);
  73369. p._resetInsertionMode();
  73370. p._processStartTag(token);
  73371. }
  73372. }
  73373. function inputStartTagInTable(p, token) {
  73374. if (isHiddenInput(token)) {
  73375. p._appendElement(token, NS.HTML);
  73376. }
  73377. else {
  73378. tokenInTable(p, token);
  73379. }
  73380. token.ackSelfClosing = true;
  73381. }
  73382. function formStartTagInTable(p, token) {
  73383. if (!p.formElement && p.openElements.tmplCount === 0) {
  73384. p._insertElement(token, NS.HTML);
  73385. p.formElement = p.openElements.current;
  73386. p.openElements.pop();
  73387. }
  73388. }
  73389. function startTagInTable(p, token) {
  73390. switch (token.tagID) {
  73391. case TAG_ID.TD:
  73392. case TAG_ID.TH:
  73393. case TAG_ID.TR: {
  73394. tdStartTagInTable(p, token);
  73395. break;
  73396. }
  73397. case TAG_ID.STYLE:
  73398. case TAG_ID.SCRIPT:
  73399. case TAG_ID.TEMPLATE: {
  73400. startTagInHead(p, token);
  73401. break;
  73402. }
  73403. case TAG_ID.COL: {
  73404. colStartTagInTable(p, token);
  73405. break;
  73406. }
  73407. case TAG_ID.FORM: {
  73408. formStartTagInTable(p, token);
  73409. break;
  73410. }
  73411. case TAG_ID.TABLE: {
  73412. tableStartTagInTable(p, token);
  73413. break;
  73414. }
  73415. case TAG_ID.TBODY:
  73416. case TAG_ID.TFOOT:
  73417. case TAG_ID.THEAD: {
  73418. tbodyStartTagInTable(p, token);
  73419. break;
  73420. }
  73421. case TAG_ID.INPUT: {
  73422. inputStartTagInTable(p, token);
  73423. break;
  73424. }
  73425. case TAG_ID.CAPTION: {
  73426. captionStartTagInTable(p, token);
  73427. break;
  73428. }
  73429. case TAG_ID.COLGROUP: {
  73430. colgroupStartTagInTable(p, token);
  73431. break;
  73432. }
  73433. default: {
  73434. tokenInTable(p, token);
  73435. }
  73436. }
  73437. }
  73438. function endTagInTable(p, token) {
  73439. switch (token.tagID) {
  73440. case TAG_ID.TABLE: {
  73441. if (p.openElements.hasInTableScope(TAG_ID.TABLE)) {
  73442. p.openElements.popUntilTagNamePopped(TAG_ID.TABLE);
  73443. p._resetInsertionMode();
  73444. }
  73445. break;
  73446. }
  73447. case TAG_ID.TEMPLATE: {
  73448. endTagInHead(p, token);
  73449. break;
  73450. }
  73451. case TAG_ID.BODY:
  73452. case TAG_ID.CAPTION:
  73453. case TAG_ID.COL:
  73454. case TAG_ID.COLGROUP:
  73455. case TAG_ID.HTML:
  73456. case TAG_ID.TBODY:
  73457. case TAG_ID.TD:
  73458. case TAG_ID.TFOOT:
  73459. case TAG_ID.TH:
  73460. case TAG_ID.THEAD:
  73461. case TAG_ID.TR: {
  73462. // Ignore token
  73463. break;
  73464. }
  73465. default: {
  73466. tokenInTable(p, token);
  73467. }
  73468. }
  73469. }
  73470. function tokenInTable(p, token) {
  73471. const savedFosterParentingState = p.fosterParentingEnabled;
  73472. p.fosterParentingEnabled = true;
  73473. // Process token in `In Body` mode
  73474. modeInBody(p, token);
  73475. p.fosterParentingEnabled = savedFosterParentingState;
  73476. }
  73477. // The "in table text" insertion mode
  73478. //------------------------------------------------------------------
  73479. function whitespaceCharacterInTableText(p, token) {
  73480. p.pendingCharacterTokens.push(token);
  73481. }
  73482. function characterInTableText(p, token) {
  73483. p.pendingCharacterTokens.push(token);
  73484. p.hasNonWhitespacePendingCharacterToken = true;
  73485. }
  73486. function tokenInTableText(p, token) {
  73487. let i = 0;
  73488. if (p.hasNonWhitespacePendingCharacterToken) {
  73489. for (; i < p.pendingCharacterTokens.length; i++) {
  73490. tokenInTable(p, p.pendingCharacterTokens[i]);
  73491. }
  73492. }
  73493. else {
  73494. for (; i < p.pendingCharacterTokens.length; i++) {
  73495. p._insertCharacters(p.pendingCharacterTokens[i]);
  73496. }
  73497. }
  73498. p.insertionMode = p.originalInsertionMode;
  73499. p._processToken(token);
  73500. }
  73501. // The "in caption" insertion mode
  73502. //------------------------------------------------------------------
  73503. const TABLE_VOID_ELEMENTS = new Set([TAG_ID.CAPTION, TAG_ID.COL, TAG_ID.COLGROUP, TAG_ID.TBODY, TAG_ID.TD, TAG_ID.TFOOT, TAG_ID.TH, TAG_ID.THEAD, TAG_ID.TR]);
  73504. function startTagInCaption(p, token) {
  73505. const tn = token.tagID;
  73506. if (TABLE_VOID_ELEMENTS.has(tn)) {
  73507. if (p.openElements.hasInTableScope(TAG_ID.CAPTION)) {
  73508. p.openElements.generateImpliedEndTags();
  73509. p.openElements.popUntilTagNamePopped(TAG_ID.CAPTION);
  73510. p.activeFormattingElements.clearToLastMarker();
  73511. p.insertionMode = InsertionMode.IN_TABLE;
  73512. startTagInTable(p, token);
  73513. }
  73514. }
  73515. else {
  73516. startTagInBody(p, token);
  73517. }
  73518. }
  73519. function endTagInCaption(p, token) {
  73520. const tn = token.tagID;
  73521. switch (tn) {
  73522. case TAG_ID.CAPTION:
  73523. case TAG_ID.TABLE: {
  73524. if (p.openElements.hasInTableScope(TAG_ID.CAPTION)) {
  73525. p.openElements.generateImpliedEndTags();
  73526. p.openElements.popUntilTagNamePopped(TAG_ID.CAPTION);
  73527. p.activeFormattingElements.clearToLastMarker();
  73528. p.insertionMode = InsertionMode.IN_TABLE;
  73529. if (tn === TAG_ID.TABLE) {
  73530. endTagInTable(p, token);
  73531. }
  73532. }
  73533. break;
  73534. }
  73535. case TAG_ID.BODY:
  73536. case TAG_ID.COL:
  73537. case TAG_ID.COLGROUP:
  73538. case TAG_ID.HTML:
  73539. case TAG_ID.TBODY:
  73540. case TAG_ID.TD:
  73541. case TAG_ID.TFOOT:
  73542. case TAG_ID.TH:
  73543. case TAG_ID.THEAD:
  73544. case TAG_ID.TR: {
  73545. // Ignore token
  73546. break;
  73547. }
  73548. default: {
  73549. endTagInBody(p, token);
  73550. }
  73551. }
  73552. }
  73553. // The "in column group" insertion mode
  73554. //------------------------------------------------------------------
  73555. function startTagInColumnGroup(p, token) {
  73556. switch (token.tagID) {
  73557. case TAG_ID.HTML: {
  73558. startTagInBody(p, token);
  73559. break;
  73560. }
  73561. case TAG_ID.COL: {
  73562. p._appendElement(token, NS.HTML);
  73563. token.ackSelfClosing = true;
  73564. break;
  73565. }
  73566. case TAG_ID.TEMPLATE: {
  73567. startTagInHead(p, token);
  73568. break;
  73569. }
  73570. default: {
  73571. tokenInColumnGroup(p, token);
  73572. }
  73573. }
  73574. }
  73575. function endTagInColumnGroup(p, token) {
  73576. switch (token.tagID) {
  73577. case TAG_ID.COLGROUP: {
  73578. if (p.openElements.currentTagId === TAG_ID.COLGROUP) {
  73579. p.openElements.pop();
  73580. p.insertionMode = InsertionMode.IN_TABLE;
  73581. }
  73582. break;
  73583. }
  73584. case TAG_ID.TEMPLATE: {
  73585. endTagInHead(p, token);
  73586. break;
  73587. }
  73588. case TAG_ID.COL: {
  73589. // Ignore token
  73590. break;
  73591. }
  73592. default: {
  73593. tokenInColumnGroup(p, token);
  73594. }
  73595. }
  73596. }
  73597. function tokenInColumnGroup(p, token) {
  73598. if (p.openElements.currentTagId === TAG_ID.COLGROUP) {
  73599. p.openElements.pop();
  73600. p.insertionMode = InsertionMode.IN_TABLE;
  73601. p._processToken(token);
  73602. }
  73603. }
  73604. // The "in table body" insertion mode
  73605. //------------------------------------------------------------------
  73606. function startTagInTableBody(p, token) {
  73607. switch (token.tagID) {
  73608. case TAG_ID.TR: {
  73609. p.openElements.clearBackToTableBodyContext();
  73610. p._insertElement(token, NS.HTML);
  73611. p.insertionMode = InsertionMode.IN_ROW;
  73612. break;
  73613. }
  73614. case TAG_ID.TH:
  73615. case TAG_ID.TD: {
  73616. p.openElements.clearBackToTableBodyContext();
  73617. p._insertFakeElement(TAG_NAMES.TR, TAG_ID.TR);
  73618. p.insertionMode = InsertionMode.IN_ROW;
  73619. startTagInRow(p, token);
  73620. break;
  73621. }
  73622. case TAG_ID.CAPTION:
  73623. case TAG_ID.COL:
  73624. case TAG_ID.COLGROUP:
  73625. case TAG_ID.TBODY:
  73626. case TAG_ID.TFOOT:
  73627. case TAG_ID.THEAD: {
  73628. if (p.openElements.hasTableBodyContextInTableScope()) {
  73629. p.openElements.clearBackToTableBodyContext();
  73630. p.openElements.pop();
  73631. p.insertionMode = InsertionMode.IN_TABLE;
  73632. startTagInTable(p, token);
  73633. }
  73634. break;
  73635. }
  73636. default: {
  73637. startTagInTable(p, token);
  73638. }
  73639. }
  73640. }
  73641. function endTagInTableBody(p, token) {
  73642. const tn = token.tagID;
  73643. switch (token.tagID) {
  73644. case TAG_ID.TBODY:
  73645. case TAG_ID.TFOOT:
  73646. case TAG_ID.THEAD: {
  73647. if (p.openElements.hasInTableScope(tn)) {
  73648. p.openElements.clearBackToTableBodyContext();
  73649. p.openElements.pop();
  73650. p.insertionMode = InsertionMode.IN_TABLE;
  73651. }
  73652. break;
  73653. }
  73654. case TAG_ID.TABLE: {
  73655. if (p.openElements.hasTableBodyContextInTableScope()) {
  73656. p.openElements.clearBackToTableBodyContext();
  73657. p.openElements.pop();
  73658. p.insertionMode = InsertionMode.IN_TABLE;
  73659. endTagInTable(p, token);
  73660. }
  73661. break;
  73662. }
  73663. case TAG_ID.BODY:
  73664. case TAG_ID.CAPTION:
  73665. case TAG_ID.COL:
  73666. case TAG_ID.COLGROUP:
  73667. case TAG_ID.HTML:
  73668. case TAG_ID.TD:
  73669. case TAG_ID.TH:
  73670. case TAG_ID.TR: {
  73671. // Ignore token
  73672. break;
  73673. }
  73674. default: {
  73675. endTagInTable(p, token);
  73676. }
  73677. }
  73678. }
  73679. // The "in row" insertion mode
  73680. //------------------------------------------------------------------
  73681. function startTagInRow(p, token) {
  73682. switch (token.tagID) {
  73683. case TAG_ID.TH:
  73684. case TAG_ID.TD: {
  73685. p.openElements.clearBackToTableRowContext();
  73686. p._insertElement(token, NS.HTML);
  73687. p.insertionMode = InsertionMode.IN_CELL;
  73688. p.activeFormattingElements.insertMarker();
  73689. break;
  73690. }
  73691. case TAG_ID.CAPTION:
  73692. case TAG_ID.COL:
  73693. case TAG_ID.COLGROUP:
  73694. case TAG_ID.TBODY:
  73695. case TAG_ID.TFOOT:
  73696. case TAG_ID.THEAD:
  73697. case TAG_ID.TR: {
  73698. if (p.openElements.hasInTableScope(TAG_ID.TR)) {
  73699. p.openElements.clearBackToTableRowContext();
  73700. p.openElements.pop();
  73701. p.insertionMode = InsertionMode.IN_TABLE_BODY;
  73702. startTagInTableBody(p, token);
  73703. }
  73704. break;
  73705. }
  73706. default: {
  73707. startTagInTable(p, token);
  73708. }
  73709. }
  73710. }
  73711. function endTagInRow(p, token) {
  73712. switch (token.tagID) {
  73713. case TAG_ID.TR: {
  73714. if (p.openElements.hasInTableScope(TAG_ID.TR)) {
  73715. p.openElements.clearBackToTableRowContext();
  73716. p.openElements.pop();
  73717. p.insertionMode = InsertionMode.IN_TABLE_BODY;
  73718. }
  73719. break;
  73720. }
  73721. case TAG_ID.TABLE: {
  73722. if (p.openElements.hasInTableScope(TAG_ID.TR)) {
  73723. p.openElements.clearBackToTableRowContext();
  73724. p.openElements.pop();
  73725. p.insertionMode = InsertionMode.IN_TABLE_BODY;
  73726. endTagInTableBody(p, token);
  73727. }
  73728. break;
  73729. }
  73730. case TAG_ID.TBODY:
  73731. case TAG_ID.TFOOT:
  73732. case TAG_ID.THEAD: {
  73733. if (p.openElements.hasInTableScope(token.tagID) || p.openElements.hasInTableScope(TAG_ID.TR)) {
  73734. p.openElements.clearBackToTableRowContext();
  73735. p.openElements.pop();
  73736. p.insertionMode = InsertionMode.IN_TABLE_BODY;
  73737. endTagInTableBody(p, token);
  73738. }
  73739. break;
  73740. }
  73741. case TAG_ID.BODY:
  73742. case TAG_ID.CAPTION:
  73743. case TAG_ID.COL:
  73744. case TAG_ID.COLGROUP:
  73745. case TAG_ID.HTML:
  73746. case TAG_ID.TD:
  73747. case TAG_ID.TH: {
  73748. // Ignore end tag
  73749. break;
  73750. }
  73751. default:
  73752. endTagInTable(p, token);
  73753. }
  73754. }
  73755. // The "in cell" insertion mode
  73756. //------------------------------------------------------------------
  73757. function startTagInCell(p, token) {
  73758. const tn = token.tagID;
  73759. if (TABLE_VOID_ELEMENTS.has(tn)) {
  73760. if (p.openElements.hasInTableScope(TAG_ID.TD) || p.openElements.hasInTableScope(TAG_ID.TH)) {
  73761. p._closeTableCell();
  73762. startTagInRow(p, token);
  73763. }
  73764. }
  73765. else {
  73766. startTagInBody(p, token);
  73767. }
  73768. }
  73769. function endTagInCell(p, token) {
  73770. const tn = token.tagID;
  73771. switch (tn) {
  73772. case TAG_ID.TD:
  73773. case TAG_ID.TH: {
  73774. if (p.openElements.hasInTableScope(tn)) {
  73775. p.openElements.generateImpliedEndTags();
  73776. p.openElements.popUntilTagNamePopped(tn);
  73777. p.activeFormattingElements.clearToLastMarker();
  73778. p.insertionMode = InsertionMode.IN_ROW;
  73779. }
  73780. break;
  73781. }
  73782. case TAG_ID.TABLE:
  73783. case TAG_ID.TBODY:
  73784. case TAG_ID.TFOOT:
  73785. case TAG_ID.THEAD:
  73786. case TAG_ID.TR: {
  73787. if (p.openElements.hasInTableScope(tn)) {
  73788. p._closeTableCell();
  73789. endTagInRow(p, token);
  73790. }
  73791. break;
  73792. }
  73793. case TAG_ID.BODY:
  73794. case TAG_ID.CAPTION:
  73795. case TAG_ID.COL:
  73796. case TAG_ID.COLGROUP:
  73797. case TAG_ID.HTML: {
  73798. // Ignore token
  73799. break;
  73800. }
  73801. default: {
  73802. endTagInBody(p, token);
  73803. }
  73804. }
  73805. }
  73806. // The "in select" insertion mode
  73807. //------------------------------------------------------------------
  73808. function startTagInSelect(p, token) {
  73809. switch (token.tagID) {
  73810. case TAG_ID.HTML: {
  73811. startTagInBody(p, token);
  73812. break;
  73813. }
  73814. case TAG_ID.OPTION: {
  73815. if (p.openElements.currentTagId === TAG_ID.OPTION) {
  73816. p.openElements.pop();
  73817. }
  73818. p._insertElement(token, NS.HTML);
  73819. break;
  73820. }
  73821. case TAG_ID.OPTGROUP: {
  73822. if (p.openElements.currentTagId === TAG_ID.OPTION) {
  73823. p.openElements.pop();
  73824. }
  73825. if (p.openElements.currentTagId === TAG_ID.OPTGROUP) {
  73826. p.openElements.pop();
  73827. }
  73828. p._insertElement(token, NS.HTML);
  73829. break;
  73830. }
  73831. case TAG_ID.INPUT:
  73832. case TAG_ID.KEYGEN:
  73833. case TAG_ID.TEXTAREA:
  73834. case TAG_ID.SELECT: {
  73835. if (p.openElements.hasInSelectScope(TAG_ID.SELECT)) {
  73836. p.openElements.popUntilTagNamePopped(TAG_ID.SELECT);
  73837. p._resetInsertionMode();
  73838. if (token.tagID !== TAG_ID.SELECT) {
  73839. p._processStartTag(token);
  73840. }
  73841. }
  73842. break;
  73843. }
  73844. case TAG_ID.SCRIPT:
  73845. case TAG_ID.TEMPLATE: {
  73846. startTagInHead(p, token);
  73847. break;
  73848. }
  73849. // Do nothing
  73850. }
  73851. }
  73852. function endTagInSelect(p, token) {
  73853. switch (token.tagID) {
  73854. case TAG_ID.OPTGROUP: {
  73855. if (p.openElements.stackTop > 0 &&
  73856. p.openElements.currentTagId === TAG_ID.OPTION &&
  73857. p.openElements.tagIDs[p.openElements.stackTop - 1] === TAG_ID.OPTGROUP) {
  73858. p.openElements.pop();
  73859. }
  73860. if (p.openElements.currentTagId === TAG_ID.OPTGROUP) {
  73861. p.openElements.pop();
  73862. }
  73863. break;
  73864. }
  73865. case TAG_ID.OPTION: {
  73866. if (p.openElements.currentTagId === TAG_ID.OPTION) {
  73867. p.openElements.pop();
  73868. }
  73869. break;
  73870. }
  73871. case TAG_ID.SELECT: {
  73872. if (p.openElements.hasInSelectScope(TAG_ID.SELECT)) {
  73873. p.openElements.popUntilTagNamePopped(TAG_ID.SELECT);
  73874. p._resetInsertionMode();
  73875. }
  73876. break;
  73877. }
  73878. case TAG_ID.TEMPLATE: {
  73879. endTagInHead(p, token);
  73880. break;
  73881. }
  73882. // Do nothing
  73883. }
  73884. }
  73885. // The "in select in table" insertion mode
  73886. //------------------------------------------------------------------
  73887. function startTagInSelectInTable(p, token) {
  73888. const tn = token.tagID;
  73889. if (tn === TAG_ID.CAPTION ||
  73890. tn === TAG_ID.TABLE ||
  73891. tn === TAG_ID.TBODY ||
  73892. tn === TAG_ID.TFOOT ||
  73893. tn === TAG_ID.THEAD ||
  73894. tn === TAG_ID.TR ||
  73895. tn === TAG_ID.TD ||
  73896. tn === TAG_ID.TH) {
  73897. p.openElements.popUntilTagNamePopped(TAG_ID.SELECT);
  73898. p._resetInsertionMode();
  73899. p._processStartTag(token);
  73900. }
  73901. else {
  73902. startTagInSelect(p, token);
  73903. }
  73904. }
  73905. function endTagInSelectInTable(p, token) {
  73906. const tn = token.tagID;
  73907. if (tn === TAG_ID.CAPTION ||
  73908. tn === TAG_ID.TABLE ||
  73909. tn === TAG_ID.TBODY ||
  73910. tn === TAG_ID.TFOOT ||
  73911. tn === TAG_ID.THEAD ||
  73912. tn === TAG_ID.TR ||
  73913. tn === TAG_ID.TD ||
  73914. tn === TAG_ID.TH) {
  73915. if (p.openElements.hasInTableScope(tn)) {
  73916. p.openElements.popUntilTagNamePopped(TAG_ID.SELECT);
  73917. p._resetInsertionMode();
  73918. p.onEndTag(token);
  73919. }
  73920. }
  73921. else {
  73922. endTagInSelect(p, token);
  73923. }
  73924. }
  73925. // The "in template" insertion mode
  73926. //------------------------------------------------------------------
  73927. function startTagInTemplate(p, token) {
  73928. switch (token.tagID) {
  73929. // First, handle tags that can start without a mode change
  73930. case TAG_ID.BASE:
  73931. case TAG_ID.BASEFONT:
  73932. case TAG_ID.BGSOUND:
  73933. case TAG_ID.LINK:
  73934. case TAG_ID.META:
  73935. case TAG_ID.NOFRAMES:
  73936. case TAG_ID.SCRIPT:
  73937. case TAG_ID.STYLE:
  73938. case TAG_ID.TEMPLATE:
  73939. case TAG_ID.TITLE:
  73940. startTagInHead(p, token);
  73941. break;
  73942. // Re-process the token in the appropriate mode
  73943. case TAG_ID.CAPTION:
  73944. case TAG_ID.COLGROUP:
  73945. case TAG_ID.TBODY:
  73946. case TAG_ID.TFOOT:
  73947. case TAG_ID.THEAD:
  73948. p.tmplInsertionModeStack[0] = InsertionMode.IN_TABLE;
  73949. p.insertionMode = InsertionMode.IN_TABLE;
  73950. startTagInTable(p, token);
  73951. break;
  73952. case TAG_ID.COL:
  73953. p.tmplInsertionModeStack[0] = InsertionMode.IN_COLUMN_GROUP;
  73954. p.insertionMode = InsertionMode.IN_COLUMN_GROUP;
  73955. startTagInColumnGroup(p, token);
  73956. break;
  73957. case TAG_ID.TR:
  73958. p.tmplInsertionModeStack[0] = InsertionMode.IN_TABLE_BODY;
  73959. p.insertionMode = InsertionMode.IN_TABLE_BODY;
  73960. startTagInTableBody(p, token);
  73961. break;
  73962. case TAG_ID.TD:
  73963. case TAG_ID.TH:
  73964. p.tmplInsertionModeStack[0] = InsertionMode.IN_ROW;
  73965. p.insertionMode = InsertionMode.IN_ROW;
  73966. startTagInRow(p, token);
  73967. break;
  73968. default:
  73969. p.tmplInsertionModeStack[0] = InsertionMode.IN_BODY;
  73970. p.insertionMode = InsertionMode.IN_BODY;
  73971. startTagInBody(p, token);
  73972. }
  73973. }
  73974. function endTagInTemplate(p, token) {
  73975. if (token.tagID === TAG_ID.TEMPLATE) {
  73976. endTagInHead(p, token);
  73977. }
  73978. }
  73979. function eofInTemplate(p, token) {
  73980. if (p.openElements.tmplCount > 0) {
  73981. p.openElements.popUntilTagNamePopped(TAG_ID.TEMPLATE);
  73982. p.activeFormattingElements.clearToLastMarker();
  73983. p.tmplInsertionModeStack.shift();
  73984. p._resetInsertionMode();
  73985. p.onEof(token);
  73986. }
  73987. else {
  73988. stopParsing(p, token);
  73989. }
  73990. }
  73991. // The "after body" insertion mode
  73992. //------------------------------------------------------------------
  73993. function startTagAfterBody(p, token) {
  73994. if (token.tagID === TAG_ID.HTML) {
  73995. startTagInBody(p, token);
  73996. }
  73997. else {
  73998. tokenAfterBody(p, token);
  73999. }
  74000. }
  74001. function endTagAfterBody(p, token) {
  74002. var _a;
  74003. if (token.tagID === TAG_ID.HTML) {
  74004. if (!p.fragmentContext) {
  74005. p.insertionMode = InsertionMode.AFTER_AFTER_BODY;
  74006. }
  74007. //NOTE: <html> is never popped from the stack, so we need to updated
  74008. //the end location explicitly.
  74009. if (p.options.sourceCodeLocationInfo && p.openElements.tagIDs[0] === TAG_ID.HTML) {
  74010. p._setEndLocation(p.openElements.items[0], token);
  74011. // Update the body element, if it doesn't have an end tag
  74012. const bodyElement = p.openElements.items[1];
  74013. if (bodyElement && !((_a = p.treeAdapter.getNodeSourceCodeLocation(bodyElement)) === null || _a === void 0 ? void 0 : _a.endTag)) {
  74014. p._setEndLocation(bodyElement, token);
  74015. }
  74016. }
  74017. }
  74018. else {
  74019. tokenAfterBody(p, token);
  74020. }
  74021. }
  74022. function tokenAfterBody(p, token) {
  74023. p.insertionMode = InsertionMode.IN_BODY;
  74024. modeInBody(p, token);
  74025. }
  74026. // The "in frameset" insertion mode
  74027. //------------------------------------------------------------------
  74028. function startTagInFrameset(p, token) {
  74029. switch (token.tagID) {
  74030. case TAG_ID.HTML: {
  74031. startTagInBody(p, token);
  74032. break;
  74033. }
  74034. case TAG_ID.FRAMESET: {
  74035. p._insertElement(token, NS.HTML);
  74036. break;
  74037. }
  74038. case TAG_ID.FRAME: {
  74039. p._appendElement(token, NS.HTML);
  74040. token.ackSelfClosing = true;
  74041. break;
  74042. }
  74043. case TAG_ID.NOFRAMES: {
  74044. startTagInHead(p, token);
  74045. break;
  74046. }
  74047. // Do nothing
  74048. }
  74049. }
  74050. function endTagInFrameset(p, token) {
  74051. if (token.tagID === TAG_ID.FRAMESET && !p.openElements.isRootHtmlElementCurrent()) {
  74052. p.openElements.pop();
  74053. if (!p.fragmentContext && p.openElements.currentTagId !== TAG_ID.FRAMESET) {
  74054. p.insertionMode = InsertionMode.AFTER_FRAMESET;
  74055. }
  74056. }
  74057. }
  74058. // The "after frameset" insertion mode
  74059. //------------------------------------------------------------------
  74060. function startTagAfterFrameset(p, token) {
  74061. switch (token.tagID) {
  74062. case TAG_ID.HTML: {
  74063. startTagInBody(p, token);
  74064. break;
  74065. }
  74066. case TAG_ID.NOFRAMES: {
  74067. startTagInHead(p, token);
  74068. break;
  74069. }
  74070. // Do nothing
  74071. }
  74072. }
  74073. function endTagAfterFrameset(p, token) {
  74074. if (token.tagID === TAG_ID.HTML) {
  74075. p.insertionMode = InsertionMode.AFTER_AFTER_FRAMESET;
  74076. }
  74077. }
  74078. // The "after after body" insertion mode
  74079. //------------------------------------------------------------------
  74080. function startTagAfterAfterBody(p, token) {
  74081. if (token.tagID === TAG_ID.HTML) {
  74082. startTagInBody(p, token);
  74083. }
  74084. else {
  74085. tokenAfterAfterBody(p, token);
  74086. }
  74087. }
  74088. function tokenAfterAfterBody(p, token) {
  74089. p.insertionMode = InsertionMode.IN_BODY;
  74090. modeInBody(p, token);
  74091. }
  74092. // The "after after frameset" insertion mode
  74093. //------------------------------------------------------------------
  74094. function startTagAfterAfterFrameset(p, token) {
  74095. switch (token.tagID) {
  74096. case TAG_ID.HTML: {
  74097. startTagInBody(p, token);
  74098. break;
  74099. }
  74100. case TAG_ID.NOFRAMES: {
  74101. startTagInHead(p, token);
  74102. break;
  74103. }
  74104. // Do nothing
  74105. }
  74106. }
  74107. // The rules for parsing tokens in foreign content
  74108. //------------------------------------------------------------------
  74109. function nullCharacterInForeignContent(p, token) {
  74110. token.chars = REPLACEMENT_CHARACTER;
  74111. p._insertCharacters(token);
  74112. }
  74113. function characterInForeignContent(p, token) {
  74114. p._insertCharacters(token);
  74115. p.framesetOk = false;
  74116. }
  74117. function popUntilHtmlOrIntegrationPoint(p) {
  74118. while (p.treeAdapter.getNamespaceURI(p.openElements.current) !== NS.HTML &&
  74119. !p._isIntegrationPoint(p.openElements.currentTagId, p.openElements.current)) {
  74120. p.openElements.pop();
  74121. }
  74122. }
  74123. function startTagInForeignContent(p, token) {
  74124. if (causesExit(token)) {
  74125. popUntilHtmlOrIntegrationPoint(p);
  74126. p._startTagOutsideForeignContent(token);
  74127. }
  74128. else {
  74129. const current = p._getAdjustedCurrentElement();
  74130. const currentNs = p.treeAdapter.getNamespaceURI(current);
  74131. if (currentNs === NS.MATHML) {
  74132. adjustTokenMathMLAttrs(token);
  74133. }
  74134. else if (currentNs === NS.SVG) {
  74135. adjustTokenSVGTagName(token);
  74136. adjustTokenSVGAttrs(token);
  74137. }
  74138. adjustTokenXMLAttrs(token);
  74139. if (token.selfClosing) {
  74140. p._appendElement(token, currentNs);
  74141. }
  74142. else {
  74143. p._insertElement(token, currentNs);
  74144. }
  74145. token.ackSelfClosing = true;
  74146. }
  74147. }
  74148. function endTagInForeignContent(p, token) {
  74149. if (token.tagID === TAG_ID.P || token.tagID === TAG_ID.BR) {
  74150. popUntilHtmlOrIntegrationPoint(p);
  74151. p._endTagOutsideForeignContent(token);
  74152. return;
  74153. }
  74154. for (let i = p.openElements.stackTop; i > 0; i--) {
  74155. const element = p.openElements.items[i];
  74156. if (p.treeAdapter.getNamespaceURI(element) === NS.HTML) {
  74157. p._endTagOutsideForeignContent(token);
  74158. break;
  74159. }
  74160. const tagName = p.treeAdapter.getTagName(element);
  74161. if (tagName.toLowerCase() === token.tagName) {
  74162. //NOTE: update the token tag name for `_setEndLocation`.
  74163. token.tagName = tagName;
  74164. p.openElements.shortenToLength(i);
  74165. break;
  74166. }
  74167. }
  74168. }
  74169. var _escape = createCommonjsModule(function (module, exports) {
  74170. Object.defineProperty(exports, "__esModule", { value: true });
  74171. exports.escapeText = exports.escapeAttribute = exports.escapeUTF8 = exports.escape = exports.encodeXML = exports.getCodePoint = exports.xmlReplacer = void 0;
  74172. exports.xmlReplacer = /["&'<>$\x80-\uFFFF]/g;
  74173. var xmlCodeMap = new Map([
  74174. [34, "&quot;"],
  74175. [38, "&amp;"],
  74176. [39, "&apos;"],
  74177. [60, "&lt;"],
  74178. [62, "&gt;"],
  74179. ]);
  74180. // For compatibility with node < 4, we wrap `codePointAt`
  74181. exports.getCodePoint =
  74182. // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
  74183. String.prototype.codePointAt != null
  74184. ? function (str, index) { return str.codePointAt(index); }
  74185. : // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  74186. function (c, index) {
  74187. return (c.charCodeAt(index) & 0xfc00) === 0xd800
  74188. ? (c.charCodeAt(index) - 0xd800) * 0x400 +
  74189. c.charCodeAt(index + 1) -
  74190. 0xdc00 +
  74191. 0x10000
  74192. : c.charCodeAt(index);
  74193. };
  74194. /**
  74195. * Encodes all non-ASCII characters, as well as characters not valid in XML
  74196. * documents using XML entities.
  74197. *
  74198. * If a character has no equivalent entity, a
  74199. * numeric hexadecimal reference (eg. `&#xfc;`) will be used.
  74200. */
  74201. function encodeXML(str) {
  74202. var ret = "";
  74203. var lastIdx = 0;
  74204. var match;
  74205. while ((match = exports.xmlReplacer.exec(str)) !== null) {
  74206. var i = match.index;
  74207. var char = str.charCodeAt(i);
  74208. var next = xmlCodeMap.get(char);
  74209. if (next !== undefined) {
  74210. ret += str.substring(lastIdx, i) + next;
  74211. lastIdx = i + 1;
  74212. }
  74213. else {
  74214. ret += "".concat(str.substring(lastIdx, i), "&#x").concat((0, exports.getCodePoint)(str, i).toString(16), ";");
  74215. // Increase by 1 if we have a surrogate pair
  74216. lastIdx = exports.xmlReplacer.lastIndex += Number((char & 0xfc00) === 0xd800);
  74217. }
  74218. }
  74219. return ret + str.substr(lastIdx);
  74220. }
  74221. exports.encodeXML = encodeXML;
  74222. /**
  74223. * Encodes all non-ASCII characters, as well as characters not valid in XML
  74224. * documents using numeric hexadecimal reference (eg. `&#xfc;`).
  74225. *
  74226. * Have a look at `escapeUTF8` if you want a more concise output at the expense
  74227. * of reduced transportability.
  74228. *
  74229. * @param data String to escape.
  74230. */
  74231. exports.escape = encodeXML;
  74232. function getEscaper(regex, map) {
  74233. return function escape(data) {
  74234. var match;
  74235. var lastIdx = 0;
  74236. var result = "";
  74237. while ((match = regex.exec(data))) {
  74238. if (lastIdx !== match.index) {
  74239. result += data.substring(lastIdx, match.index);
  74240. }
  74241. // We know that this chararcter will be in the map.
  74242. result += map.get(match[0].charCodeAt(0));
  74243. // Every match will be of length 1
  74244. lastIdx = match.index + 1;
  74245. }
  74246. return result + data.substring(lastIdx);
  74247. };
  74248. }
  74249. /**
  74250. * Encodes all characters not valid in XML documents using XML entities.
  74251. *
  74252. * Note that the output will be character-set dependent.
  74253. *
  74254. * @param data String to escape.
  74255. */
  74256. exports.escapeUTF8 = getEscaper(/[&<>'"]/g, xmlCodeMap);
  74257. /**
  74258. * Encodes all characters that have to be escaped in HTML attributes,
  74259. * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
  74260. *
  74261. * @param data String to escape.
  74262. */
  74263. exports.escapeAttribute = getEscaper(/["&\u00A0]/g, new Map([
  74264. [34, "&quot;"],
  74265. [38, "&amp;"],
  74266. [160, "&nbsp;"],
  74267. ]));
  74268. /**
  74269. * Encodes all characters that have to be escaped in HTML text,
  74270. * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
  74271. *
  74272. * @param data String to escape.
  74273. */
  74274. exports.escapeText = getEscaper(/[&<>\u00A0]/g, new Map([
  74275. [38, "&amp;"],
  74276. [60, "&lt;"],
  74277. [62, "&gt;"],
  74278. [160, "&nbsp;"],
  74279. ]));
  74280. });
  74281. unwrapExports(_escape);
  74282. var _escape_1 = _escape.escapeText;
  74283. var _escape_2 = _escape.escapeAttribute;
  74284. var _escape_3 = _escape.escapeUTF8;
  74285. var _escape_4 = _escape.escape;
  74286. var _escape_5 = _escape.encodeXML;
  74287. var _escape_6 = _escape.getCodePoint;
  74288. var _escape_7 = _escape.xmlReplacer;
  74289. // Sets
  74290. const VOID_ELEMENTS = new Set([
  74291. TAG_NAMES.AREA,
  74292. TAG_NAMES.BASE,
  74293. TAG_NAMES.BASEFONT,
  74294. TAG_NAMES.BGSOUND,
  74295. TAG_NAMES.BR,
  74296. TAG_NAMES.COL,
  74297. TAG_NAMES.EMBED,
  74298. TAG_NAMES.FRAME,
  74299. TAG_NAMES.HR,
  74300. TAG_NAMES.IMG,
  74301. TAG_NAMES.INPUT,
  74302. TAG_NAMES.KEYGEN,
  74303. TAG_NAMES.LINK,
  74304. TAG_NAMES.META,
  74305. TAG_NAMES.PARAM,
  74306. TAG_NAMES.SOURCE,
  74307. TAG_NAMES.TRACK,
  74308. TAG_NAMES.WBR,
  74309. ]);
  74310. function isVoidElement(node, options) {
  74311. return (options.treeAdapter.isElementNode(node) &&
  74312. options.treeAdapter.getNamespaceURI(node) === NS.HTML &&
  74313. VOID_ELEMENTS.has(options.treeAdapter.getTagName(node)));
  74314. }
  74315. const defaultOpts$2 = { treeAdapter: defaultTreeAdapter, scriptingEnabled: true };
  74316. /**
  74317. * Serializes an AST element node to an HTML string, including the element node.
  74318. *
  74319. * @example
  74320. *
  74321. * ```js
  74322. * const parse5 = require('parse5');
  74323. *
  74324. * const document = parse5.parseFragment('<div>Hello, <b>world</b>!</div>');
  74325. *
  74326. * // Serializes the <div> element.
  74327. * const html = parse5.serializeOuter(document.childNodes[0]);
  74328. *
  74329. * console.log(str); //> '<div>Hello, <b>world</b>!</div>'
  74330. * ```
  74331. *
  74332. * @param node Node to serialize.
  74333. * @param options Serialization options.
  74334. */
  74335. function serializeOuter(node, options) {
  74336. const opts = { ...defaultOpts$2, ...options };
  74337. return serializeNode(node, opts);
  74338. }
  74339. function serializeChildNodes(parentNode, options) {
  74340. let html = '';
  74341. // Get container of the child nodes
  74342. const container = options.treeAdapter.isElementNode(parentNode) &&
  74343. options.treeAdapter.getTagName(parentNode) === TAG_NAMES.TEMPLATE &&
  74344. options.treeAdapter.getNamespaceURI(parentNode) === NS.HTML
  74345. ? options.treeAdapter.getTemplateContent(parentNode)
  74346. : parentNode;
  74347. const childNodes = options.treeAdapter.getChildNodes(container);
  74348. if (childNodes) {
  74349. for (const currentNode of childNodes) {
  74350. html += serializeNode(currentNode, options);
  74351. }
  74352. }
  74353. return html;
  74354. }
  74355. function serializeNode(node, options) {
  74356. if (options.treeAdapter.isElementNode(node)) {
  74357. return serializeElement(node, options);
  74358. }
  74359. if (options.treeAdapter.isTextNode(node)) {
  74360. return serializeTextNode(node, options);
  74361. }
  74362. if (options.treeAdapter.isCommentNode(node)) {
  74363. return serializeCommentNode(node, options);
  74364. }
  74365. if (options.treeAdapter.isDocumentTypeNode(node)) {
  74366. return serializeDocumentTypeNode(node, options);
  74367. }
  74368. // Return an empty string for unknown nodes
  74369. return '';
  74370. }
  74371. function serializeElement(node, options) {
  74372. const tn = options.treeAdapter.getTagName(node);
  74373. return `<${tn}${serializeAttributes(node, options)}>${isVoidElement(node, options) ? '' : `${serializeChildNodes(node, options)}</${tn}>`}`;
  74374. }
  74375. function serializeAttributes(node, { treeAdapter }) {
  74376. let html = '';
  74377. for (const attr of treeAdapter.getAttrList(node)) {
  74378. html += ' ';
  74379. if (!attr.namespace) {
  74380. html += attr.name;
  74381. }
  74382. else
  74383. switch (attr.namespace) {
  74384. case NS.XML: {
  74385. html += `xml:${attr.name}`;
  74386. break;
  74387. }
  74388. case NS.XMLNS: {
  74389. if (attr.name !== 'xmlns') {
  74390. html += 'xmlns:';
  74391. }
  74392. html += attr.name;
  74393. break;
  74394. }
  74395. case NS.XLINK: {
  74396. html += `xlink:${attr.name}`;
  74397. break;
  74398. }
  74399. default: {
  74400. html += `${attr.prefix}:${attr.name}`;
  74401. }
  74402. }
  74403. html += `="${_escape_2(attr.value)}"`;
  74404. }
  74405. return html;
  74406. }
  74407. function serializeTextNode(node, options) {
  74408. const { treeAdapter } = options;
  74409. const content = treeAdapter.getTextNodeContent(node);
  74410. const parent = treeAdapter.getParentNode(node);
  74411. const parentTn = parent && treeAdapter.isElementNode(parent) && treeAdapter.getTagName(parent);
  74412. return parentTn &&
  74413. treeAdapter.getNamespaceURI(parent) === NS.HTML &&
  74414. hasUnescapedText(parentTn, options.scriptingEnabled)
  74415. ? content
  74416. : _escape_1(content);
  74417. }
  74418. function serializeCommentNode(node, { treeAdapter }) {
  74419. return `<!--${treeAdapter.getCommentNodeContent(node)}-->`;
  74420. }
  74421. function serializeDocumentTypeNode(node, { treeAdapter }) {
  74422. return `<!DOCTYPE ${treeAdapter.getDocumentTypeNodeName(node)}>`;
  74423. }
  74424. // Shorthands
  74425. /**
  74426. * Parses an HTML string.
  74427. *
  74428. * @param html Input HTML string.
  74429. * @param options Parsing options.
  74430. * @returns Document
  74431. *
  74432. * @example
  74433. *
  74434. * ```js
  74435. * const parse5 = require('parse5');
  74436. *
  74437. * const document = parse5.parse('<!DOCTYPE html><html><head></head><body>Hi there!</body></html>');
  74438. *
  74439. * console.log(document.childNodes[1].tagName); //> 'html'
  74440. *```
  74441. */
  74442. function parse$3(html, options) {
  74443. return Parser.parse(html, options);
  74444. }
  74445. function parseFragment(fragmentContext, html, options) {
  74446. if (typeof fragmentContext === 'string') {
  74447. options = html;
  74448. html = fragmentContext;
  74449. fragmentContext = null;
  74450. }
  74451. const parser = Parser.getFragmentParser(fragmentContext, options);
  74452. parser.tokenizer.write(html, true);
  74453. return parser.getFragment();
  74454. }
  74455. // `Set` constructor
  74456. // https://tc39.es/ecma262/#sec-set-objects
  74457. collection('Set', function (init) {
  74458. return function Set() { return init(this, arguments.length ? arguments[0] : undefined); };
  74459. }, collectionStrong);
  74460. var set$2 = path.Set;
  74461. var set$3 = set$2;
  74462. var set$4 = set$3;
  74463. /* eslint-disable es-x/no-array-prototype-lastindexof -- safe */
  74464. var min$4 = Math.min;
  74465. var $lastIndexOf = [].lastIndexOf;
  74466. var NEGATIVE_ZERO$1 = !!$lastIndexOf && 1 / [1].lastIndexOf(1, -0) < 0;
  74467. var STRICT_METHOD$5 = arrayMethodIsStrict('lastIndexOf');
  74468. var FORCED$6 = NEGATIVE_ZERO$1 || !STRICT_METHOD$5;
  74469. // `Array.prototype.lastIndexOf` method implementation
  74470. // https://tc39.es/ecma262/#sec-array.prototype.lastindexof
  74471. var arrayLastIndexOf = FORCED$6 ? function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) {
  74472. // convert -0 to +0
  74473. if (NEGATIVE_ZERO$1) return functionApply($lastIndexOf, this, arguments) || 0;
  74474. var O = toIndexedObject(this);
  74475. var length = lengthOfArrayLike(O);
  74476. var index = length - 1;
  74477. if (arguments.length > 1) index = min$4(index, toIntegerOrInfinity(arguments[1]));
  74478. if (index < 0) index = length + index;
  74479. for (;index >= 0; index--) if (index in O && O[index] === searchElement) return index || 0;
  74480. return -1;
  74481. } : $lastIndexOf;
  74482. // `Array.prototype.lastIndexOf` method
  74483. // https://tc39.es/ecma262/#sec-array.prototype.lastindexof
  74484. // eslint-disable-next-line es-x/no-array-prototype-lastindexof -- required for testing
  74485. _export({ target: 'Array', proto: true, forced: arrayLastIndexOf !== [].lastIndexOf }, {
  74486. lastIndexOf: arrayLastIndexOf
  74487. });
  74488. var lastIndexOf = entryVirtual('Array').lastIndexOf;
  74489. var entries$3 = entryVirtual('Array').entries;
  74490. var map$b = map$5;
  74491. var UNDEFINED_CODE_POINTS$1 = new set$4([65534, 65535, 131070, 131071, 196606, 196607, 262142, 262143, 327678, 327679, 393214, 393215, 458750, 458751, 524286, 524287, 589822, 589823, 655358, 655359, 720894, 720895, 786430, 786431, 851966, 851967, 917502, 917503, 983038, 983039, 1048574, 1048575, 1114110, 1114111]);
  74492. var CODE_POINTS$1;
  74493. (function (CODE_POINTS) {
  74494. CODE_POINTS[CODE_POINTS["EOF"] = -1] = "EOF";
  74495. CODE_POINTS[CODE_POINTS["NULL"] = 0] = "NULL";
  74496. CODE_POINTS[CODE_POINTS["TABULATION"] = 9] = "TABULATION";
  74497. CODE_POINTS[CODE_POINTS["CARRIAGE_RETURN"] = 13] = "CARRIAGE_RETURN";
  74498. CODE_POINTS[CODE_POINTS["LINE_FEED"] = 10] = "LINE_FEED";
  74499. CODE_POINTS[CODE_POINTS["FORM_FEED"] = 12] = "FORM_FEED";
  74500. CODE_POINTS[CODE_POINTS["SPACE"] = 32] = "SPACE";
  74501. CODE_POINTS[CODE_POINTS["EXCLAMATION_MARK"] = 33] = "EXCLAMATION_MARK";
  74502. CODE_POINTS[CODE_POINTS["QUOTATION_MARK"] = 34] = "QUOTATION_MARK";
  74503. CODE_POINTS[CODE_POINTS["NUMBER_SIGN"] = 35] = "NUMBER_SIGN";
  74504. CODE_POINTS[CODE_POINTS["AMPERSAND"] = 38] = "AMPERSAND";
  74505. CODE_POINTS[CODE_POINTS["APOSTROPHE"] = 39] = "APOSTROPHE";
  74506. CODE_POINTS[CODE_POINTS["HYPHEN_MINUS"] = 45] = "HYPHEN_MINUS";
  74507. CODE_POINTS[CODE_POINTS["SOLIDUS"] = 47] = "SOLIDUS";
  74508. CODE_POINTS[CODE_POINTS["DIGIT_0"] = 48] = "DIGIT_0";
  74509. CODE_POINTS[CODE_POINTS["DIGIT_9"] = 57] = "DIGIT_9";
  74510. CODE_POINTS[CODE_POINTS["SEMICOLON"] = 59] = "SEMICOLON";
  74511. CODE_POINTS[CODE_POINTS["LESS_THAN_SIGN"] = 60] = "LESS_THAN_SIGN";
  74512. CODE_POINTS[CODE_POINTS["EQUALS_SIGN"] = 61] = "EQUALS_SIGN";
  74513. CODE_POINTS[CODE_POINTS["GREATER_THAN_SIGN"] = 62] = "GREATER_THAN_SIGN";
  74514. CODE_POINTS[CODE_POINTS["QUESTION_MARK"] = 63] = "QUESTION_MARK";
  74515. CODE_POINTS[CODE_POINTS["LATIN_CAPITAL_A"] = 65] = "LATIN_CAPITAL_A";
  74516. CODE_POINTS[CODE_POINTS["LATIN_CAPITAL_F"] = 70] = "LATIN_CAPITAL_F";
  74517. CODE_POINTS[CODE_POINTS["LATIN_CAPITAL_X"] = 88] = "LATIN_CAPITAL_X";
  74518. CODE_POINTS[CODE_POINTS["LATIN_CAPITAL_Z"] = 90] = "LATIN_CAPITAL_Z";
  74519. CODE_POINTS[CODE_POINTS["RIGHT_SQUARE_BRACKET"] = 93] = "RIGHT_SQUARE_BRACKET";
  74520. CODE_POINTS[CODE_POINTS["GRAVE_ACCENT"] = 96] = "GRAVE_ACCENT";
  74521. CODE_POINTS[CODE_POINTS["LATIN_SMALL_A"] = 97] = "LATIN_SMALL_A";
  74522. CODE_POINTS[CODE_POINTS["LATIN_SMALL_F"] = 102] = "LATIN_SMALL_F";
  74523. CODE_POINTS[CODE_POINTS["LATIN_SMALL_X"] = 120] = "LATIN_SMALL_X";
  74524. CODE_POINTS[CODE_POINTS["LATIN_SMALL_Z"] = 122] = "LATIN_SMALL_Z";
  74525. CODE_POINTS[CODE_POINTS["REPLACEMENT_CHARACTER"] = 65533] = "REPLACEMENT_CHARACTER";
  74526. })(CODE_POINTS$1 || (CODE_POINTS$1 = {}));
  74527. var ERR$1;
  74528. (function (ERR) {
  74529. ERR["controlCharacterInInputStream"] = "control-character-in-input-stream";
  74530. ERR["noncharacterInInputStream"] = "noncharacter-in-input-stream";
  74531. ERR["surrogateInInputStream"] = "surrogate-in-input-stream";
  74532. ERR["nonVoidHtmlElementStartTagWithTrailingSolidus"] = "non-void-html-element-start-tag-with-trailing-solidus";
  74533. ERR["endTagWithAttributes"] = "end-tag-with-attributes";
  74534. ERR["endTagWithTrailingSolidus"] = "end-tag-with-trailing-solidus";
  74535. ERR["unexpectedSolidusInTag"] = "unexpected-solidus-in-tag";
  74536. ERR["unexpectedNullCharacter"] = "unexpected-null-character";
  74537. ERR["unexpectedQuestionMarkInsteadOfTagName"] = "unexpected-question-mark-instead-of-tag-name";
  74538. ERR["invalidFirstCharacterOfTagName"] = "invalid-first-character-of-tag-name";
  74539. ERR["unexpectedEqualsSignBeforeAttributeName"] = "unexpected-equals-sign-before-attribute-name";
  74540. ERR["missingEndTagName"] = "missing-end-tag-name";
  74541. ERR["unexpectedCharacterInAttributeName"] = "unexpected-character-in-attribute-name";
  74542. ERR["unknownNamedCharacterReference"] = "unknown-named-character-reference";
  74543. ERR["missingSemicolonAfterCharacterReference"] = "missing-semicolon-after-character-reference";
  74544. ERR["unexpectedCharacterAfterDoctypeSystemIdentifier"] = "unexpected-character-after-doctype-system-identifier";
  74545. ERR["unexpectedCharacterInUnquotedAttributeValue"] = "unexpected-character-in-unquoted-attribute-value";
  74546. ERR["eofBeforeTagName"] = "eof-before-tag-name";
  74547. ERR["eofInTag"] = "eof-in-tag";
  74548. ERR["missingAttributeValue"] = "missing-attribute-value";
  74549. ERR["missingWhitespaceBetweenAttributes"] = "missing-whitespace-between-attributes";
  74550. ERR["missingWhitespaceAfterDoctypePublicKeyword"] = "missing-whitespace-after-doctype-public-keyword";
  74551. ERR["missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers"] = "missing-whitespace-between-doctype-public-and-system-identifiers";
  74552. ERR["missingWhitespaceAfterDoctypeSystemKeyword"] = "missing-whitespace-after-doctype-system-keyword";
  74553. ERR["missingQuoteBeforeDoctypePublicIdentifier"] = "missing-quote-before-doctype-public-identifier";
  74554. ERR["missingQuoteBeforeDoctypeSystemIdentifier"] = "missing-quote-before-doctype-system-identifier";
  74555. ERR["missingDoctypePublicIdentifier"] = "missing-doctype-public-identifier";
  74556. ERR["missingDoctypeSystemIdentifier"] = "missing-doctype-system-identifier";
  74557. ERR["abruptDoctypePublicIdentifier"] = "abrupt-doctype-public-identifier";
  74558. ERR["abruptDoctypeSystemIdentifier"] = "abrupt-doctype-system-identifier";
  74559. ERR["cdataInHtmlContent"] = "cdata-in-html-content";
  74560. ERR["incorrectlyOpenedComment"] = "incorrectly-opened-comment";
  74561. ERR["eofInScriptHtmlCommentLikeText"] = "eof-in-script-html-comment-like-text";
  74562. ERR["eofInDoctype"] = "eof-in-doctype";
  74563. ERR["nestedComment"] = "nested-comment";
  74564. ERR["abruptClosingOfEmptyComment"] = "abrupt-closing-of-empty-comment";
  74565. ERR["eofInComment"] = "eof-in-comment";
  74566. ERR["incorrectlyClosedComment"] = "incorrectly-closed-comment";
  74567. ERR["eofInCdata"] = "eof-in-cdata";
  74568. ERR["absenceOfDigitsInNumericCharacterReference"] = "absence-of-digits-in-numeric-character-reference";
  74569. ERR["nullCharacterReference"] = "null-character-reference";
  74570. ERR["surrogateCharacterReference"] = "surrogate-character-reference";
  74571. ERR["characterReferenceOutsideUnicodeRange"] = "character-reference-outside-unicode-range";
  74572. ERR["controlCharacterReference"] = "control-character-reference";
  74573. ERR["noncharacterCharacterReference"] = "noncharacter-character-reference";
  74574. ERR["missingWhitespaceBeforeDoctypeName"] = "missing-whitespace-before-doctype-name";
  74575. ERR["missingDoctypeName"] = "missing-doctype-name";
  74576. ERR["invalidCharacterSequenceAfterDoctypeName"] = "invalid-character-sequence-after-doctype-name";
  74577. ERR["duplicateAttribute"] = "duplicate-attribute";
  74578. ERR["nonConformingDoctype"] = "non-conforming-doctype";
  74579. ERR["missingDoctype"] = "missing-doctype";
  74580. ERR["misplacedDoctype"] = "misplaced-doctype";
  74581. ERR["endTagWithoutMatchingOpenElement"] = "end-tag-without-matching-open-element";
  74582. ERR["closingOfElementWithOpenChildElements"] = "closing-of-element-with-open-child-elements";
  74583. ERR["disallowedContentInNoscriptInHead"] = "disallowed-content-in-noscript-in-head";
  74584. ERR["openElementsLeftAfterEof"] = "open-elements-left-after-eof";
  74585. ERR["abandonedHeadElementChild"] = "abandoned-head-element-child";
  74586. ERR["misplacedStartTagForHeadElement"] = "misplaced-start-tag-for-head-element";
  74587. ERR["nestedNoscriptInHead"] = "nested-noscript-in-head";
  74588. ERR["eofInElementThatCanContainOnlyText"] = "eof-in-element-that-can-contain-only-text";
  74589. })(ERR$1 || (ERR$1 = {}));
  74590. var TokenType$1;
  74591. (function (TokenType) {
  74592. TokenType[TokenType["CHARACTER"] = 0] = "CHARACTER";
  74593. TokenType[TokenType["NULL_CHARACTER"] = 1] = "NULL_CHARACTER";
  74594. TokenType[TokenType["WHITESPACE_CHARACTER"] = 2] = "WHITESPACE_CHARACTER";
  74595. TokenType[TokenType["START_TAG"] = 3] = "START_TAG";
  74596. TokenType[TokenType["END_TAG"] = 4] = "END_TAG";
  74597. TokenType[TokenType["COMMENT"] = 5] = "COMMENT";
  74598. TokenType[TokenType["DOCTYPE"] = 6] = "DOCTYPE";
  74599. TokenType[TokenType["EOF"] = 7] = "EOF";
  74600. TokenType[TokenType["HIBERNATION"] = 8] = "HIBERNATION";
  74601. })(TokenType$1 || (TokenType$1 = {}));
  74602. var _SPECIAL_ELEMENTS;
  74603. /** All valid namespaces in HTML. */
  74604. var NS$1;
  74605. (function (NS) {
  74606. NS["HTML"] = "http://www.w3.org/1999/xhtml";
  74607. NS["MATHML"] = "http://www.w3.org/1998/Math/MathML";
  74608. NS["SVG"] = "http://www.w3.org/2000/svg";
  74609. NS["XLINK"] = "http://www.w3.org/1999/xlink";
  74610. NS["XML"] = "http://www.w3.org/XML/1998/namespace";
  74611. NS["XMLNS"] = "http://www.w3.org/2000/xmlns/";
  74612. })(NS$1 || (NS$1 = {}));
  74613. var ATTRS$1;
  74614. (function (ATTRS) {
  74615. ATTRS["TYPE"] = "type";
  74616. ATTRS["ACTION"] = "action";
  74617. ATTRS["ENCODING"] = "encoding";
  74618. ATTRS["PROMPT"] = "prompt";
  74619. ATTRS["NAME"] = "name";
  74620. ATTRS["COLOR"] = "color";
  74621. ATTRS["FACE"] = "face";
  74622. ATTRS["SIZE"] = "size";
  74623. })(ATTRS$1 || (ATTRS$1 = {}));
  74624. /**
  74625. * The mode of the document.
  74626. *
  74627. * @see {@link https://dom.spec.whatwg.org/#concept-document-limited-quirks}
  74628. */
  74629. var DOCUMENT_MODE$1;
  74630. (function (DOCUMENT_MODE) {
  74631. DOCUMENT_MODE["NO_QUIRKS"] = "no-quirks";
  74632. DOCUMENT_MODE["QUIRKS"] = "quirks";
  74633. DOCUMENT_MODE["LIMITED_QUIRKS"] = "limited-quirks";
  74634. })(DOCUMENT_MODE$1 || (DOCUMENT_MODE$1 = {}));
  74635. var TAG_NAMES$1;
  74636. (function (TAG_NAMES) {
  74637. TAG_NAMES["A"] = "a";
  74638. TAG_NAMES["ADDRESS"] = "address";
  74639. TAG_NAMES["ANNOTATION_XML"] = "annotation-xml";
  74640. TAG_NAMES["APPLET"] = "applet";
  74641. TAG_NAMES["AREA"] = "area";
  74642. TAG_NAMES["ARTICLE"] = "article";
  74643. TAG_NAMES["ASIDE"] = "aside";
  74644. TAG_NAMES["B"] = "b";
  74645. TAG_NAMES["BASE"] = "base";
  74646. TAG_NAMES["BASEFONT"] = "basefont";
  74647. TAG_NAMES["BGSOUND"] = "bgsound";
  74648. TAG_NAMES["BIG"] = "big";
  74649. TAG_NAMES["BLOCKQUOTE"] = "blockquote";
  74650. TAG_NAMES["BODY"] = "body";
  74651. TAG_NAMES["BR"] = "br";
  74652. TAG_NAMES["BUTTON"] = "button";
  74653. TAG_NAMES["CAPTION"] = "caption";
  74654. TAG_NAMES["CENTER"] = "center";
  74655. TAG_NAMES["CODE"] = "code";
  74656. TAG_NAMES["COL"] = "col";
  74657. TAG_NAMES["COLGROUP"] = "colgroup";
  74658. TAG_NAMES["DD"] = "dd";
  74659. TAG_NAMES["DESC"] = "desc";
  74660. TAG_NAMES["DETAILS"] = "details";
  74661. TAG_NAMES["DIALOG"] = "dialog";
  74662. TAG_NAMES["DIR"] = "dir";
  74663. TAG_NAMES["DIV"] = "div";
  74664. TAG_NAMES["DL"] = "dl";
  74665. TAG_NAMES["DT"] = "dt";
  74666. TAG_NAMES["EM"] = "em";
  74667. TAG_NAMES["EMBED"] = "embed";
  74668. TAG_NAMES["FIELDSET"] = "fieldset";
  74669. TAG_NAMES["FIGCAPTION"] = "figcaption";
  74670. TAG_NAMES["FIGURE"] = "figure";
  74671. TAG_NAMES["FONT"] = "font";
  74672. TAG_NAMES["FOOTER"] = "footer";
  74673. TAG_NAMES["FOREIGN_OBJECT"] = "foreignObject";
  74674. TAG_NAMES["FORM"] = "form";
  74675. TAG_NAMES["FRAME"] = "frame";
  74676. TAG_NAMES["FRAMESET"] = "frameset";
  74677. TAG_NAMES["H1"] = "h1";
  74678. TAG_NAMES["H2"] = "h2";
  74679. TAG_NAMES["H3"] = "h3";
  74680. TAG_NAMES["H4"] = "h4";
  74681. TAG_NAMES["H5"] = "h5";
  74682. TAG_NAMES["H6"] = "h6";
  74683. TAG_NAMES["HEAD"] = "head";
  74684. TAG_NAMES["HEADER"] = "header";
  74685. TAG_NAMES["HGROUP"] = "hgroup";
  74686. TAG_NAMES["HR"] = "hr";
  74687. TAG_NAMES["HTML"] = "html";
  74688. TAG_NAMES["I"] = "i";
  74689. TAG_NAMES["IMG"] = "img";
  74690. TAG_NAMES["IMAGE"] = "image";
  74691. TAG_NAMES["INPUT"] = "input";
  74692. TAG_NAMES["IFRAME"] = "iframe";
  74693. TAG_NAMES["KEYGEN"] = "keygen";
  74694. TAG_NAMES["LABEL"] = "label";
  74695. TAG_NAMES["LI"] = "li";
  74696. TAG_NAMES["LINK"] = "link";
  74697. TAG_NAMES["LISTING"] = "listing";
  74698. TAG_NAMES["MAIN"] = "main";
  74699. TAG_NAMES["MALIGNMARK"] = "malignmark";
  74700. TAG_NAMES["MARQUEE"] = "marquee";
  74701. TAG_NAMES["MATH"] = "math";
  74702. TAG_NAMES["MENU"] = "menu";
  74703. TAG_NAMES["META"] = "meta";
  74704. TAG_NAMES["MGLYPH"] = "mglyph";
  74705. TAG_NAMES["MI"] = "mi";
  74706. TAG_NAMES["MO"] = "mo";
  74707. TAG_NAMES["MN"] = "mn";
  74708. TAG_NAMES["MS"] = "ms";
  74709. TAG_NAMES["MTEXT"] = "mtext";
  74710. TAG_NAMES["NAV"] = "nav";
  74711. TAG_NAMES["NOBR"] = "nobr";
  74712. TAG_NAMES["NOFRAMES"] = "noframes";
  74713. TAG_NAMES["NOEMBED"] = "noembed";
  74714. TAG_NAMES["NOSCRIPT"] = "noscript";
  74715. TAG_NAMES["OBJECT"] = "object";
  74716. TAG_NAMES["OL"] = "ol";
  74717. TAG_NAMES["OPTGROUP"] = "optgroup";
  74718. TAG_NAMES["OPTION"] = "option";
  74719. TAG_NAMES["P"] = "p";
  74720. TAG_NAMES["PARAM"] = "param";
  74721. TAG_NAMES["PLAINTEXT"] = "plaintext";
  74722. TAG_NAMES["PRE"] = "pre";
  74723. TAG_NAMES["RB"] = "rb";
  74724. TAG_NAMES["RP"] = "rp";
  74725. TAG_NAMES["RT"] = "rt";
  74726. TAG_NAMES["RTC"] = "rtc";
  74727. TAG_NAMES["RUBY"] = "ruby";
  74728. TAG_NAMES["S"] = "s";
  74729. TAG_NAMES["SCRIPT"] = "script";
  74730. TAG_NAMES["SECTION"] = "section";
  74731. TAG_NAMES["SELECT"] = "select";
  74732. TAG_NAMES["SOURCE"] = "source";
  74733. TAG_NAMES["SMALL"] = "small";
  74734. TAG_NAMES["SPAN"] = "span";
  74735. TAG_NAMES["STRIKE"] = "strike";
  74736. TAG_NAMES["STRONG"] = "strong";
  74737. TAG_NAMES["STYLE"] = "style";
  74738. TAG_NAMES["SUB"] = "sub";
  74739. TAG_NAMES["SUMMARY"] = "summary";
  74740. TAG_NAMES["SUP"] = "sup";
  74741. TAG_NAMES["TABLE"] = "table";
  74742. TAG_NAMES["TBODY"] = "tbody";
  74743. TAG_NAMES["TEMPLATE"] = "template";
  74744. TAG_NAMES["TEXTAREA"] = "textarea";
  74745. TAG_NAMES["TFOOT"] = "tfoot";
  74746. TAG_NAMES["TD"] = "td";
  74747. TAG_NAMES["TH"] = "th";
  74748. TAG_NAMES["THEAD"] = "thead";
  74749. TAG_NAMES["TITLE"] = "title";
  74750. TAG_NAMES["TR"] = "tr";
  74751. TAG_NAMES["TRACK"] = "track";
  74752. TAG_NAMES["TT"] = "tt";
  74753. TAG_NAMES["U"] = "u";
  74754. TAG_NAMES["UL"] = "ul";
  74755. TAG_NAMES["SVG"] = "svg";
  74756. TAG_NAMES["VAR"] = "var";
  74757. TAG_NAMES["WBR"] = "wbr";
  74758. TAG_NAMES["XMP"] = "xmp";
  74759. })(TAG_NAMES$1 || (TAG_NAMES$1 = {}));
  74760. /**
  74761. * Tag IDs are numeric IDs for known tag names.
  74762. *
  74763. * We use tag IDs to improve the performance of tag name comparisons.
  74764. */
  74765. var TAG_ID$1;
  74766. (function (TAG_ID) {
  74767. TAG_ID[TAG_ID["UNKNOWN"] = 0] = "UNKNOWN";
  74768. TAG_ID[TAG_ID["A"] = 1] = "A";
  74769. TAG_ID[TAG_ID["ADDRESS"] = 2] = "ADDRESS";
  74770. TAG_ID[TAG_ID["ANNOTATION_XML"] = 3] = "ANNOTATION_XML";
  74771. TAG_ID[TAG_ID["APPLET"] = 4] = "APPLET";
  74772. TAG_ID[TAG_ID["AREA"] = 5] = "AREA";
  74773. TAG_ID[TAG_ID["ARTICLE"] = 6] = "ARTICLE";
  74774. TAG_ID[TAG_ID["ASIDE"] = 7] = "ASIDE";
  74775. TAG_ID[TAG_ID["B"] = 8] = "B";
  74776. TAG_ID[TAG_ID["BASE"] = 9] = "BASE";
  74777. TAG_ID[TAG_ID["BASEFONT"] = 10] = "BASEFONT";
  74778. TAG_ID[TAG_ID["BGSOUND"] = 11] = "BGSOUND";
  74779. TAG_ID[TAG_ID["BIG"] = 12] = "BIG";
  74780. TAG_ID[TAG_ID["BLOCKQUOTE"] = 13] = "BLOCKQUOTE";
  74781. TAG_ID[TAG_ID["BODY"] = 14] = "BODY";
  74782. TAG_ID[TAG_ID["BR"] = 15] = "BR";
  74783. TAG_ID[TAG_ID["BUTTON"] = 16] = "BUTTON";
  74784. TAG_ID[TAG_ID["CAPTION"] = 17] = "CAPTION";
  74785. TAG_ID[TAG_ID["CENTER"] = 18] = "CENTER";
  74786. TAG_ID[TAG_ID["CODE"] = 19] = "CODE";
  74787. TAG_ID[TAG_ID["COL"] = 20] = "COL";
  74788. TAG_ID[TAG_ID["COLGROUP"] = 21] = "COLGROUP";
  74789. TAG_ID[TAG_ID["DD"] = 22] = "DD";
  74790. TAG_ID[TAG_ID["DESC"] = 23] = "DESC";
  74791. TAG_ID[TAG_ID["DETAILS"] = 24] = "DETAILS";
  74792. TAG_ID[TAG_ID["DIALOG"] = 25] = "DIALOG";
  74793. TAG_ID[TAG_ID["DIR"] = 26] = "DIR";
  74794. TAG_ID[TAG_ID["DIV"] = 27] = "DIV";
  74795. TAG_ID[TAG_ID["DL"] = 28] = "DL";
  74796. TAG_ID[TAG_ID["DT"] = 29] = "DT";
  74797. TAG_ID[TAG_ID["EM"] = 30] = "EM";
  74798. TAG_ID[TAG_ID["EMBED"] = 31] = "EMBED";
  74799. TAG_ID[TAG_ID["FIELDSET"] = 32] = "FIELDSET";
  74800. TAG_ID[TAG_ID["FIGCAPTION"] = 33] = "FIGCAPTION";
  74801. TAG_ID[TAG_ID["FIGURE"] = 34] = "FIGURE";
  74802. TAG_ID[TAG_ID["FONT"] = 35] = "FONT";
  74803. TAG_ID[TAG_ID["FOOTER"] = 36] = "FOOTER";
  74804. TAG_ID[TAG_ID["FOREIGN_OBJECT"] = 37] = "FOREIGN_OBJECT";
  74805. TAG_ID[TAG_ID["FORM"] = 38] = "FORM";
  74806. TAG_ID[TAG_ID["FRAME"] = 39] = "FRAME";
  74807. TAG_ID[TAG_ID["FRAMESET"] = 40] = "FRAMESET";
  74808. TAG_ID[TAG_ID["H1"] = 41] = "H1";
  74809. TAG_ID[TAG_ID["H2"] = 42] = "H2";
  74810. TAG_ID[TAG_ID["H3"] = 43] = "H3";
  74811. TAG_ID[TAG_ID["H4"] = 44] = "H4";
  74812. TAG_ID[TAG_ID["H5"] = 45] = "H5";
  74813. TAG_ID[TAG_ID["H6"] = 46] = "H6";
  74814. TAG_ID[TAG_ID["HEAD"] = 47] = "HEAD";
  74815. TAG_ID[TAG_ID["HEADER"] = 48] = "HEADER";
  74816. TAG_ID[TAG_ID["HGROUP"] = 49] = "HGROUP";
  74817. TAG_ID[TAG_ID["HR"] = 50] = "HR";
  74818. TAG_ID[TAG_ID["HTML"] = 51] = "HTML";
  74819. TAG_ID[TAG_ID["I"] = 52] = "I";
  74820. TAG_ID[TAG_ID["IMG"] = 53] = "IMG";
  74821. TAG_ID[TAG_ID["IMAGE"] = 54] = "IMAGE";
  74822. TAG_ID[TAG_ID["INPUT"] = 55] = "INPUT";
  74823. TAG_ID[TAG_ID["IFRAME"] = 56] = "IFRAME";
  74824. TAG_ID[TAG_ID["KEYGEN"] = 57] = "KEYGEN";
  74825. TAG_ID[TAG_ID["LABEL"] = 58] = "LABEL";
  74826. TAG_ID[TAG_ID["LI"] = 59] = "LI";
  74827. TAG_ID[TAG_ID["LINK"] = 60] = "LINK";
  74828. TAG_ID[TAG_ID["LISTING"] = 61] = "LISTING";
  74829. TAG_ID[TAG_ID["MAIN"] = 62] = "MAIN";
  74830. TAG_ID[TAG_ID["MALIGNMARK"] = 63] = "MALIGNMARK";
  74831. TAG_ID[TAG_ID["MARQUEE"] = 64] = "MARQUEE";
  74832. TAG_ID[TAG_ID["MATH"] = 65] = "MATH";
  74833. TAG_ID[TAG_ID["MENU"] = 66] = "MENU";
  74834. TAG_ID[TAG_ID["META"] = 67] = "META";
  74835. TAG_ID[TAG_ID["MGLYPH"] = 68] = "MGLYPH";
  74836. TAG_ID[TAG_ID["MI"] = 69] = "MI";
  74837. TAG_ID[TAG_ID["MO"] = 70] = "MO";
  74838. TAG_ID[TAG_ID["MN"] = 71] = "MN";
  74839. TAG_ID[TAG_ID["MS"] = 72] = "MS";
  74840. TAG_ID[TAG_ID["MTEXT"] = 73] = "MTEXT";
  74841. TAG_ID[TAG_ID["NAV"] = 74] = "NAV";
  74842. TAG_ID[TAG_ID["NOBR"] = 75] = "NOBR";
  74843. TAG_ID[TAG_ID["NOFRAMES"] = 76] = "NOFRAMES";
  74844. TAG_ID[TAG_ID["NOEMBED"] = 77] = "NOEMBED";
  74845. TAG_ID[TAG_ID["NOSCRIPT"] = 78] = "NOSCRIPT";
  74846. TAG_ID[TAG_ID["OBJECT"] = 79] = "OBJECT";
  74847. TAG_ID[TAG_ID["OL"] = 80] = "OL";
  74848. TAG_ID[TAG_ID["OPTGROUP"] = 81] = "OPTGROUP";
  74849. TAG_ID[TAG_ID["OPTION"] = 82] = "OPTION";
  74850. TAG_ID[TAG_ID["P"] = 83] = "P";
  74851. TAG_ID[TAG_ID["PARAM"] = 84] = "PARAM";
  74852. TAG_ID[TAG_ID["PLAINTEXT"] = 85] = "PLAINTEXT";
  74853. TAG_ID[TAG_ID["PRE"] = 86] = "PRE";
  74854. TAG_ID[TAG_ID["RB"] = 87] = "RB";
  74855. TAG_ID[TAG_ID["RP"] = 88] = "RP";
  74856. TAG_ID[TAG_ID["RT"] = 89] = "RT";
  74857. TAG_ID[TAG_ID["RTC"] = 90] = "RTC";
  74858. TAG_ID[TAG_ID["RUBY"] = 91] = "RUBY";
  74859. TAG_ID[TAG_ID["S"] = 92] = "S";
  74860. TAG_ID[TAG_ID["SCRIPT"] = 93] = "SCRIPT";
  74861. TAG_ID[TAG_ID["SECTION"] = 94] = "SECTION";
  74862. TAG_ID[TAG_ID["SELECT"] = 95] = "SELECT";
  74863. TAG_ID[TAG_ID["SOURCE"] = 96] = "SOURCE";
  74864. TAG_ID[TAG_ID["SMALL"] = 97] = "SMALL";
  74865. TAG_ID[TAG_ID["SPAN"] = 98] = "SPAN";
  74866. TAG_ID[TAG_ID["STRIKE"] = 99] = "STRIKE";
  74867. TAG_ID[TAG_ID["STRONG"] = 100] = "STRONG";
  74868. TAG_ID[TAG_ID["STYLE"] = 101] = "STYLE";
  74869. TAG_ID[TAG_ID["SUB"] = 102] = "SUB";
  74870. TAG_ID[TAG_ID["SUMMARY"] = 103] = "SUMMARY";
  74871. TAG_ID[TAG_ID["SUP"] = 104] = "SUP";
  74872. TAG_ID[TAG_ID["TABLE"] = 105] = "TABLE";
  74873. TAG_ID[TAG_ID["TBODY"] = 106] = "TBODY";
  74874. TAG_ID[TAG_ID["TEMPLATE"] = 107] = "TEMPLATE";
  74875. TAG_ID[TAG_ID["TEXTAREA"] = 108] = "TEXTAREA";
  74876. TAG_ID[TAG_ID["TFOOT"] = 109] = "TFOOT";
  74877. TAG_ID[TAG_ID["TD"] = 110] = "TD";
  74878. TAG_ID[TAG_ID["TH"] = 111] = "TH";
  74879. TAG_ID[TAG_ID["THEAD"] = 112] = "THEAD";
  74880. TAG_ID[TAG_ID["TITLE"] = 113] = "TITLE";
  74881. TAG_ID[TAG_ID["TR"] = 114] = "TR";
  74882. TAG_ID[TAG_ID["TRACK"] = 115] = "TRACK";
  74883. TAG_ID[TAG_ID["TT"] = 116] = "TT";
  74884. TAG_ID[TAG_ID["U"] = 117] = "U";
  74885. TAG_ID[TAG_ID["UL"] = 118] = "UL";
  74886. TAG_ID[TAG_ID["SVG"] = 119] = "SVG";
  74887. TAG_ID[TAG_ID["VAR"] = 120] = "VAR";
  74888. TAG_ID[TAG_ID["WBR"] = 121] = "WBR";
  74889. TAG_ID[TAG_ID["XMP"] = 122] = "XMP";
  74890. })(TAG_ID$1 || (TAG_ID$1 = {}));
  74891. var TAG_NAME_TO_ID$1 = new map$b([[TAG_NAMES$1.A, TAG_ID$1.A], [TAG_NAMES$1.ADDRESS, TAG_ID$1.ADDRESS], [TAG_NAMES$1.ANNOTATION_XML, TAG_ID$1.ANNOTATION_XML], [TAG_NAMES$1.APPLET, TAG_ID$1.APPLET], [TAG_NAMES$1.AREA, TAG_ID$1.AREA], [TAG_NAMES$1.ARTICLE, TAG_ID$1.ARTICLE], [TAG_NAMES$1.ASIDE, TAG_ID$1.ASIDE], [TAG_NAMES$1.B, TAG_ID$1.B], [TAG_NAMES$1.BASE, TAG_ID$1.BASE], [TAG_NAMES$1.BASEFONT, TAG_ID$1.BASEFONT], [TAG_NAMES$1.BGSOUND, TAG_ID$1.BGSOUND], [TAG_NAMES$1.BIG, TAG_ID$1.BIG], [TAG_NAMES$1.BLOCKQUOTE, TAG_ID$1.BLOCKQUOTE], [TAG_NAMES$1.BODY, TAG_ID$1.BODY], [TAG_NAMES$1.BR, TAG_ID$1.BR], [TAG_NAMES$1.BUTTON, TAG_ID$1.BUTTON], [TAG_NAMES$1.CAPTION, TAG_ID$1.CAPTION], [TAG_NAMES$1.CENTER, TAG_ID$1.CENTER], [TAG_NAMES$1.CODE, TAG_ID$1.CODE], [TAG_NAMES$1.COL, TAG_ID$1.COL], [TAG_NAMES$1.COLGROUP, TAG_ID$1.COLGROUP], [TAG_NAMES$1.DD, TAG_ID$1.DD], [TAG_NAMES$1.DESC, TAG_ID$1.DESC], [TAG_NAMES$1.DETAILS, TAG_ID$1.DETAILS], [TAG_NAMES$1.DIALOG, TAG_ID$1.DIALOG], [TAG_NAMES$1.DIR, TAG_ID$1.DIR], [TAG_NAMES$1.DIV, TAG_ID$1.DIV], [TAG_NAMES$1.DL, TAG_ID$1.DL], [TAG_NAMES$1.DT, TAG_ID$1.DT], [TAG_NAMES$1.EM, TAG_ID$1.EM], [TAG_NAMES$1.EMBED, TAG_ID$1.EMBED], [TAG_NAMES$1.FIELDSET, TAG_ID$1.FIELDSET], [TAG_NAMES$1.FIGCAPTION, TAG_ID$1.FIGCAPTION], [TAG_NAMES$1.FIGURE, TAG_ID$1.FIGURE], [TAG_NAMES$1.FONT, TAG_ID$1.FONT], [TAG_NAMES$1.FOOTER, TAG_ID$1.FOOTER], [TAG_NAMES$1.FOREIGN_OBJECT, TAG_ID$1.FOREIGN_OBJECT], [TAG_NAMES$1.FORM, TAG_ID$1.FORM], [TAG_NAMES$1.FRAME, TAG_ID$1.FRAME], [TAG_NAMES$1.FRAMESET, TAG_ID$1.FRAMESET], [TAG_NAMES$1.H1, TAG_ID$1.H1], [TAG_NAMES$1.H2, TAG_ID$1.H2], [TAG_NAMES$1.H3, TAG_ID$1.H3], [TAG_NAMES$1.H4, TAG_ID$1.H4], [TAG_NAMES$1.H5, TAG_ID$1.H5], [TAG_NAMES$1.H6, TAG_ID$1.H6], [TAG_NAMES$1.HEAD, TAG_ID$1.HEAD], [TAG_NAMES$1.HEADER, TAG_ID$1.HEADER], [TAG_NAMES$1.HGROUP, TAG_ID$1.HGROUP], [TAG_NAMES$1.HR, TAG_ID$1.HR], [TAG_NAMES$1.HTML, TAG_ID$1.HTML], [TAG_NAMES$1.I, TAG_ID$1.I], [TAG_NAMES$1.IMG, TAG_ID$1.IMG], [TAG_NAMES$1.IMAGE, TAG_ID$1.IMAGE], [TAG_NAMES$1.INPUT, TAG_ID$1.INPUT], [TAG_NAMES$1.IFRAME, TAG_ID$1.IFRAME], [TAG_NAMES$1.KEYGEN, TAG_ID$1.KEYGEN], [TAG_NAMES$1.LABEL, TAG_ID$1.LABEL], [TAG_NAMES$1.LI, TAG_ID$1.LI], [TAG_NAMES$1.LINK, TAG_ID$1.LINK], [TAG_NAMES$1.LISTING, TAG_ID$1.LISTING], [TAG_NAMES$1.MAIN, TAG_ID$1.MAIN], [TAG_NAMES$1.MALIGNMARK, TAG_ID$1.MALIGNMARK], [TAG_NAMES$1.MARQUEE, TAG_ID$1.MARQUEE], [TAG_NAMES$1.MATH, TAG_ID$1.MATH], [TAG_NAMES$1.MENU, TAG_ID$1.MENU], [TAG_NAMES$1.META, TAG_ID$1.META], [TAG_NAMES$1.MGLYPH, TAG_ID$1.MGLYPH], [TAG_NAMES$1.MI, TAG_ID$1.MI], [TAG_NAMES$1.MO, TAG_ID$1.MO], [TAG_NAMES$1.MN, TAG_ID$1.MN], [TAG_NAMES$1.MS, TAG_ID$1.MS], [TAG_NAMES$1.MTEXT, TAG_ID$1.MTEXT], [TAG_NAMES$1.NAV, TAG_ID$1.NAV], [TAG_NAMES$1.NOBR, TAG_ID$1.NOBR], [TAG_NAMES$1.NOFRAMES, TAG_ID$1.NOFRAMES], [TAG_NAMES$1.NOEMBED, TAG_ID$1.NOEMBED], [TAG_NAMES$1.NOSCRIPT, TAG_ID$1.NOSCRIPT], [TAG_NAMES$1.OBJECT, TAG_ID$1.OBJECT], [TAG_NAMES$1.OL, TAG_ID$1.OL], [TAG_NAMES$1.OPTGROUP, TAG_ID$1.OPTGROUP], [TAG_NAMES$1.OPTION, TAG_ID$1.OPTION], [TAG_NAMES$1.P, TAG_ID$1.P], [TAG_NAMES$1.PARAM, TAG_ID$1.PARAM], [TAG_NAMES$1.PLAINTEXT, TAG_ID$1.PLAINTEXT], [TAG_NAMES$1.PRE, TAG_ID$1.PRE], [TAG_NAMES$1.RB, TAG_ID$1.RB], [TAG_NAMES$1.RP, TAG_ID$1.RP], [TAG_NAMES$1.RT, TAG_ID$1.RT], [TAG_NAMES$1.RTC, TAG_ID$1.RTC], [TAG_NAMES$1.RUBY, TAG_ID$1.RUBY], [TAG_NAMES$1.S, TAG_ID$1.S], [TAG_NAMES$1.SCRIPT, TAG_ID$1.SCRIPT], [TAG_NAMES$1.SECTION, TAG_ID$1.SECTION], [TAG_NAMES$1.SELECT, TAG_ID$1.SELECT], [TAG_NAMES$1.SOURCE, TAG_ID$1.SOURCE], [TAG_NAMES$1.SMALL, TAG_ID$1.SMALL], [TAG_NAMES$1.SPAN, TAG_ID$1.SPAN], [TAG_NAMES$1.STRIKE, TAG_ID$1.STRIKE], [TAG_NAMES$1.STRONG, TAG_ID$1.STRONG], [TAG_NAMES$1.STYLE, TAG_ID$1.STYLE], [TAG_NAMES$1.SUB, TAG_ID$1.SUB], [TAG_NAMES$1.SUMMARY, TAG_ID$1.SUMMARY], [TAG_NAMES$1.SUP, TAG_ID$1.SUP], [TAG_NAMES$1.TABLE, TAG_ID$1.TABLE], [TAG_NAMES$1.TBODY, TAG_ID$1.TBODY], [TAG_NAMES$1.TEMPLATE, TAG_ID$1.TEMPLATE], [TAG_NAMES$1.TEXTAREA, TAG_ID$1.TEXTAREA], [TAG_NAMES$1.TFOOT, TAG_ID$1.TFOOT], [TAG_NAMES$1.TD, TAG_ID$1.TD], [TAG_NAMES$1.TH, TAG_ID$1.TH], [TAG_NAMES$1.THEAD, TAG_ID$1.THEAD], [TAG_NAMES$1.TITLE, TAG_ID$1.TITLE], [TAG_NAMES$1.TR, TAG_ID$1.TR], [TAG_NAMES$1.TRACK, TAG_ID$1.TRACK], [TAG_NAMES$1.TT, TAG_ID$1.TT], [TAG_NAMES$1.U, TAG_ID$1.U], [TAG_NAMES$1.UL, TAG_ID$1.UL], [TAG_NAMES$1.SVG, TAG_ID$1.SVG], [TAG_NAMES$1.VAR, TAG_ID$1.VAR], [TAG_NAMES$1.WBR, TAG_ID$1.WBR], [TAG_NAMES$1.XMP, TAG_ID$1.XMP]]);
  74892. var $$1 = TAG_ID$1;
  74893. var SPECIAL_ELEMENTS$1 = (_SPECIAL_ELEMENTS = {}, _defineProperty(_SPECIAL_ELEMENTS, NS$1.HTML, new set$4([$$1.ADDRESS, $$1.APPLET, $$1.AREA, $$1.ARTICLE, $$1.ASIDE, $$1.BASE, $$1.BASEFONT, $$1.BGSOUND, $$1.BLOCKQUOTE, $$1.BODY, $$1.BR, $$1.BUTTON, $$1.CAPTION, $$1.CENTER, $$1.COL, $$1.COLGROUP, $$1.DD, $$1.DETAILS, $$1.DIR, $$1.DIV, $$1.DL, $$1.DT, $$1.EMBED, $$1.FIELDSET, $$1.FIGCAPTION, $$1.FIGURE, $$1.FOOTER, $$1.FORM, $$1.FRAME, $$1.FRAMESET, $$1.H1, $$1.H2, $$1.H3, $$1.H4, $$1.H5, $$1.H6, $$1.HEAD, $$1.HEADER, $$1.HGROUP, $$1.HR, $$1.HTML, $$1.IFRAME, $$1.IMG, $$1.INPUT, $$1.LI, $$1.LINK, $$1.LISTING, $$1.MAIN, $$1.MARQUEE, $$1.MENU, $$1.META, $$1.NAV, $$1.NOEMBED, $$1.NOFRAMES, $$1.NOSCRIPT, $$1.OBJECT, $$1.OL, $$1.P, $$1.PARAM, $$1.PLAINTEXT, $$1.PRE, $$1.SCRIPT, $$1.SECTION, $$1.SELECT, $$1.SOURCE, $$1.STYLE, $$1.SUMMARY, $$1.TABLE, $$1.TBODY, $$1.TD, $$1.TEMPLATE, $$1.TEXTAREA, $$1.TFOOT, $$1.TH, $$1.THEAD, $$1.TITLE, $$1.TR, $$1.TRACK, $$1.UL, $$1.WBR, $$1.XMP])), _defineProperty(_SPECIAL_ELEMENTS, NS$1.MATHML, new set$4([$$1.MI, $$1.MO, $$1.MN, $$1.MS, $$1.MTEXT, $$1.ANNOTATION_XML])), _defineProperty(_SPECIAL_ELEMENTS, NS$1.SVG, new set$4([$$1.TITLE, $$1.FOREIGN_OBJECT, $$1.DESC])), _defineProperty(_SPECIAL_ELEMENTS, NS$1.XLINK, new set$4()), _defineProperty(_SPECIAL_ELEMENTS, NS$1.XML, new set$4()), _defineProperty(_SPECIAL_ELEMENTS, NS$1.XMLNS, new set$4()), _SPECIAL_ELEMENTS);
  74894. var UNESCAPED_TEXT$1 = new set$4([TAG_NAMES$1.STYLE, TAG_NAMES$1.SCRIPT, TAG_NAMES$1.XMP, TAG_NAMES$1.IFRAME, TAG_NAMES$1.NOEMBED, TAG_NAMES$1.NOFRAMES, TAG_NAMES$1.PLAINTEXT]);
  74895. var C1_CONTROLS_REFERENCE_REPLACEMENTS$1 = new map$b([[0x80, 8364], [0x82, 8218], [0x83, 402], [0x84, 8222], [0x85, 8230], [0x86, 8224], [0x87, 8225], [0x88, 710], [0x89, 8240], [0x8a, 352], [0x8b, 8249], [0x8c, 338], [0x8e, 381], [0x91, 8216], [0x92, 8217], [0x93, 8220], [0x94, 8221], [0x95, 8226], [0x96, 8211], [0x97, 8212], [0x98, 732], [0x99, 8482], [0x9a, 353], [0x9b, 8250], [0x9c, 339], [0x9e, 382], [0x9f, 376]]); //States
  74896. var State$1;
  74897. (function (State) {
  74898. State[State["DATA"] = 0] = "DATA";
  74899. State[State["RCDATA"] = 1] = "RCDATA";
  74900. State[State["RAWTEXT"] = 2] = "RAWTEXT";
  74901. State[State["SCRIPT_DATA"] = 3] = "SCRIPT_DATA";
  74902. State[State["PLAINTEXT"] = 4] = "PLAINTEXT";
  74903. State[State["TAG_OPEN"] = 5] = "TAG_OPEN";
  74904. State[State["END_TAG_OPEN"] = 6] = "END_TAG_OPEN";
  74905. State[State["TAG_NAME"] = 7] = "TAG_NAME";
  74906. State[State["RCDATA_LESS_THAN_SIGN"] = 8] = "RCDATA_LESS_THAN_SIGN";
  74907. State[State["RCDATA_END_TAG_OPEN"] = 9] = "RCDATA_END_TAG_OPEN";
  74908. State[State["RCDATA_END_TAG_NAME"] = 10] = "RCDATA_END_TAG_NAME";
  74909. State[State["RAWTEXT_LESS_THAN_SIGN"] = 11] = "RAWTEXT_LESS_THAN_SIGN";
  74910. State[State["RAWTEXT_END_TAG_OPEN"] = 12] = "RAWTEXT_END_TAG_OPEN";
  74911. State[State["RAWTEXT_END_TAG_NAME"] = 13] = "RAWTEXT_END_TAG_NAME";
  74912. State[State["SCRIPT_DATA_LESS_THAN_SIGN"] = 14] = "SCRIPT_DATA_LESS_THAN_SIGN";
  74913. State[State["SCRIPT_DATA_END_TAG_OPEN"] = 15] = "SCRIPT_DATA_END_TAG_OPEN";
  74914. State[State["SCRIPT_DATA_END_TAG_NAME"] = 16] = "SCRIPT_DATA_END_TAG_NAME";
  74915. State[State["SCRIPT_DATA_ESCAPE_START"] = 17] = "SCRIPT_DATA_ESCAPE_START";
  74916. State[State["SCRIPT_DATA_ESCAPE_START_DASH"] = 18] = "SCRIPT_DATA_ESCAPE_START_DASH";
  74917. State[State["SCRIPT_DATA_ESCAPED"] = 19] = "SCRIPT_DATA_ESCAPED";
  74918. State[State["SCRIPT_DATA_ESCAPED_DASH"] = 20] = "SCRIPT_DATA_ESCAPED_DASH";
  74919. State[State["SCRIPT_DATA_ESCAPED_DASH_DASH"] = 21] = "SCRIPT_DATA_ESCAPED_DASH_DASH";
  74920. State[State["SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN"] = 22] = "SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN";
  74921. State[State["SCRIPT_DATA_ESCAPED_END_TAG_OPEN"] = 23] = "SCRIPT_DATA_ESCAPED_END_TAG_OPEN";
  74922. State[State["SCRIPT_DATA_ESCAPED_END_TAG_NAME"] = 24] = "SCRIPT_DATA_ESCAPED_END_TAG_NAME";
  74923. State[State["SCRIPT_DATA_DOUBLE_ESCAPE_START"] = 25] = "SCRIPT_DATA_DOUBLE_ESCAPE_START";
  74924. State[State["SCRIPT_DATA_DOUBLE_ESCAPED"] = 26] = "SCRIPT_DATA_DOUBLE_ESCAPED";
  74925. State[State["SCRIPT_DATA_DOUBLE_ESCAPED_DASH"] = 27] = "SCRIPT_DATA_DOUBLE_ESCAPED_DASH";
  74926. State[State["SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH"] = 28] = "SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH";
  74927. State[State["SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN"] = 29] = "SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN";
  74928. State[State["SCRIPT_DATA_DOUBLE_ESCAPE_END"] = 30] = "SCRIPT_DATA_DOUBLE_ESCAPE_END";
  74929. State[State["BEFORE_ATTRIBUTE_NAME"] = 31] = "BEFORE_ATTRIBUTE_NAME";
  74930. State[State["ATTRIBUTE_NAME"] = 32] = "ATTRIBUTE_NAME";
  74931. State[State["AFTER_ATTRIBUTE_NAME"] = 33] = "AFTER_ATTRIBUTE_NAME";
  74932. State[State["BEFORE_ATTRIBUTE_VALUE"] = 34] = "BEFORE_ATTRIBUTE_VALUE";
  74933. State[State["ATTRIBUTE_VALUE_DOUBLE_QUOTED"] = 35] = "ATTRIBUTE_VALUE_DOUBLE_QUOTED";
  74934. State[State["ATTRIBUTE_VALUE_SINGLE_QUOTED"] = 36] = "ATTRIBUTE_VALUE_SINGLE_QUOTED";
  74935. State[State["ATTRIBUTE_VALUE_UNQUOTED"] = 37] = "ATTRIBUTE_VALUE_UNQUOTED";
  74936. State[State["AFTER_ATTRIBUTE_VALUE_QUOTED"] = 38] = "AFTER_ATTRIBUTE_VALUE_QUOTED";
  74937. State[State["SELF_CLOSING_START_TAG"] = 39] = "SELF_CLOSING_START_TAG";
  74938. State[State["BOGUS_COMMENT"] = 40] = "BOGUS_COMMENT";
  74939. State[State["MARKUP_DECLARATION_OPEN"] = 41] = "MARKUP_DECLARATION_OPEN";
  74940. State[State["COMMENT_START"] = 42] = "COMMENT_START";
  74941. State[State["COMMENT_START_DASH"] = 43] = "COMMENT_START_DASH";
  74942. State[State["COMMENT"] = 44] = "COMMENT";
  74943. State[State["COMMENT_LESS_THAN_SIGN"] = 45] = "COMMENT_LESS_THAN_SIGN";
  74944. State[State["COMMENT_LESS_THAN_SIGN_BANG"] = 46] = "COMMENT_LESS_THAN_SIGN_BANG";
  74945. State[State["COMMENT_LESS_THAN_SIGN_BANG_DASH"] = 47] = "COMMENT_LESS_THAN_SIGN_BANG_DASH";
  74946. State[State["COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH"] = 48] = "COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH";
  74947. State[State["COMMENT_END_DASH"] = 49] = "COMMENT_END_DASH";
  74948. State[State["COMMENT_END"] = 50] = "COMMENT_END";
  74949. State[State["COMMENT_END_BANG"] = 51] = "COMMENT_END_BANG";
  74950. State[State["DOCTYPE"] = 52] = "DOCTYPE";
  74951. State[State["BEFORE_DOCTYPE_NAME"] = 53] = "BEFORE_DOCTYPE_NAME";
  74952. State[State["DOCTYPE_NAME"] = 54] = "DOCTYPE_NAME";
  74953. State[State["AFTER_DOCTYPE_NAME"] = 55] = "AFTER_DOCTYPE_NAME";
  74954. State[State["AFTER_DOCTYPE_PUBLIC_KEYWORD"] = 56] = "AFTER_DOCTYPE_PUBLIC_KEYWORD";
  74955. State[State["BEFORE_DOCTYPE_PUBLIC_IDENTIFIER"] = 57] = "BEFORE_DOCTYPE_PUBLIC_IDENTIFIER";
  74956. State[State["DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED"] = 58] = "DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED";
  74957. State[State["DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED"] = 59] = "DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED";
  74958. State[State["AFTER_DOCTYPE_PUBLIC_IDENTIFIER"] = 60] = "AFTER_DOCTYPE_PUBLIC_IDENTIFIER";
  74959. State[State["BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS"] = 61] = "BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS";
  74960. State[State["AFTER_DOCTYPE_SYSTEM_KEYWORD"] = 62] = "AFTER_DOCTYPE_SYSTEM_KEYWORD";
  74961. State[State["BEFORE_DOCTYPE_SYSTEM_IDENTIFIER"] = 63] = "BEFORE_DOCTYPE_SYSTEM_IDENTIFIER";
  74962. State[State["DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED"] = 64] = "DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED";
  74963. State[State["DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED"] = 65] = "DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED";
  74964. State[State["AFTER_DOCTYPE_SYSTEM_IDENTIFIER"] = 66] = "AFTER_DOCTYPE_SYSTEM_IDENTIFIER";
  74965. State[State["BOGUS_DOCTYPE"] = 67] = "BOGUS_DOCTYPE";
  74966. State[State["CDATA_SECTION"] = 68] = "CDATA_SECTION";
  74967. State[State["CDATA_SECTION_BRACKET"] = 69] = "CDATA_SECTION_BRACKET";
  74968. State[State["CDATA_SECTION_END"] = 70] = "CDATA_SECTION_END";
  74969. State[State["CHARACTER_REFERENCE"] = 71] = "CHARACTER_REFERENCE";
  74970. State[State["NAMED_CHARACTER_REFERENCE"] = 72] = "NAMED_CHARACTER_REFERENCE";
  74971. State[State["AMBIGUOUS_AMPERSAND"] = 73] = "AMBIGUOUS_AMPERSAND";
  74972. State[State["NUMERIC_CHARACTER_REFERENCE"] = 74] = "NUMERIC_CHARACTER_REFERENCE";
  74973. State[State["HEXADEMICAL_CHARACTER_REFERENCE_START"] = 75] = "HEXADEMICAL_CHARACTER_REFERENCE_START";
  74974. State[State["DECIMAL_CHARACTER_REFERENCE_START"] = 76] = "DECIMAL_CHARACTER_REFERENCE_START";
  74975. State[State["HEXADEMICAL_CHARACTER_REFERENCE"] = 77] = "HEXADEMICAL_CHARACTER_REFERENCE";
  74976. State[State["DECIMAL_CHARACTER_REFERENCE"] = 78] = "DECIMAL_CHARACTER_REFERENCE";
  74977. State[State["NUMERIC_CHARACTER_REFERENCE_END"] = 79] = "NUMERIC_CHARACTER_REFERENCE_END";
  74978. })(State$1 || (State$1 = {})); //Tokenizer initial states for different modes
  74979. var TokenizerMode$1 = {
  74980. DATA: State$1.DATA,
  74981. RCDATA: State$1.RCDATA,
  74982. RAWTEXT: State$1.RAWTEXT,
  74983. SCRIPT_DATA: State$1.SCRIPT_DATA,
  74984. PLAINTEXT: State$1.PLAINTEXT,
  74985. CDATA_SECTION: State$1.CDATA_SECTION
  74986. }; //Utils
  74987. var _context$1;
  74988. var IMPLICIT_END_TAG_REQUIRED$1 = new set$4([TAG_ID$1.DD, TAG_ID$1.DT, TAG_ID$1.LI, TAG_ID$1.OPTGROUP, TAG_ID$1.OPTION, TAG_ID$1.P, TAG_ID$1.RB, TAG_ID$1.RP, TAG_ID$1.RT, TAG_ID$1.RTC]);
  74989. var IMPLICIT_END_TAG_REQUIRED_THOROUGHLY$1 = new set$4(concat$5(_context$1 = []).call(_context$1, _toConsumableArray(IMPLICIT_END_TAG_REQUIRED$1), [TAG_ID$1.CAPTION, TAG_ID$1.COLGROUP, TAG_ID$1.TBODY, TAG_ID$1.TD, TAG_ID$1.TFOOT, TAG_ID$1.TH, TAG_ID$1.THEAD, TAG_ID$1.TR]));
  74990. var SCOPING_ELEMENT_NS$1 = new map$b([[TAG_ID$1.APPLET, NS$1.HTML], [TAG_ID$1.CAPTION, NS$1.HTML], [TAG_ID$1.HTML, NS$1.HTML], [TAG_ID$1.MARQUEE, NS$1.HTML], [TAG_ID$1.OBJECT, NS$1.HTML], [TAG_ID$1.TABLE, NS$1.HTML], [TAG_ID$1.TD, NS$1.HTML], [TAG_ID$1.TEMPLATE, NS$1.HTML], [TAG_ID$1.TH, NS$1.HTML], [TAG_ID$1.ANNOTATION_XML, NS$1.MATHML], [TAG_ID$1.MI, NS$1.MATHML], [TAG_ID$1.MN, NS$1.MATHML], [TAG_ID$1.MO, NS$1.MATHML], [TAG_ID$1.MS, NS$1.MATHML], [TAG_ID$1.MTEXT, NS$1.MATHML], [TAG_ID$1.DESC, NS$1.SVG], [TAG_ID$1.FOREIGN_OBJECT, NS$1.SVG], [TAG_ID$1.TITLE, NS$1.SVG]]);
  74991. var NAMED_HEADERS$1 = [TAG_ID$1.H1, TAG_ID$1.H2, TAG_ID$1.H3, TAG_ID$1.H4, TAG_ID$1.H5, TAG_ID$1.H6];
  74992. var TABLE_ROW_CONTEXT$1 = [TAG_ID$1.TR, TAG_ID$1.TEMPLATE, TAG_ID$1.HTML];
  74993. var TABLE_BODY_CONTEXT$1 = [TAG_ID$1.TBODY, TAG_ID$1.TFOOT, TAG_ID$1.THEAD, TAG_ID$1.TEMPLATE, TAG_ID$1.HTML];
  74994. var TABLE_CONTEXT$1 = [TAG_ID$1.TABLE, TAG_ID$1.TEMPLATE, TAG_ID$1.HTML];
  74995. var TABLE_CELLS$1 = [TAG_ID$1.TD, TAG_ID$1.TH]; //Stack of open elements
  74996. var EntryType$1;
  74997. (function (EntryType) {
  74998. EntryType[EntryType["Marker"] = 0] = "Marker";
  74999. EntryType[EntryType["Element"] = 1] = "Element";
  75000. })(EntryType$1 || (EntryType$1 = {}));
  75001. var MARKER$1 = {
  75002. type: EntryType$1.Marker
  75003. }; //List of formatting elements
  75004. var NodeType$1;
  75005. (function (NodeType) {
  75006. NodeType["Document"] = "#document";
  75007. NodeType["DocumentFragment"] = "#document-fragment";
  75008. NodeType["Comment"] = "#comment";
  75009. NodeType["Text"] = "#text";
  75010. NodeType["DocumentType"] = "#documentType";
  75011. })(NodeType$1 || (NodeType$1 = {}));
  75012. var _context$2, _context2$1;
  75013. var QUIRKS_MODE_PUBLIC_ID_PREFIXES$1 = ['+//silmaril//dtd html pro v0r11 19970101//', '-//as//dtd html 3.0 aswedit + extensions//', '-//advasoft ltd//dtd html 3.0 aswedit + extensions//', '-//ietf//dtd html 2.0 level 1//', '-//ietf//dtd html 2.0 level 2//', '-//ietf//dtd html 2.0 strict level 1//', '-//ietf//dtd html 2.0 strict level 2//', '-//ietf//dtd html 2.0 strict//', '-//ietf//dtd html 2.0//', '-//ietf//dtd html 2.1e//', '-//ietf//dtd html 3.0//', '-//ietf//dtd html 3.2 final//', '-//ietf//dtd html 3.2//', '-//ietf//dtd html 3//', '-//ietf//dtd html level 0//', '-//ietf//dtd html level 1//', '-//ietf//dtd html level 2//', '-//ietf//dtd html level 3//', '-//ietf//dtd html strict level 0//', '-//ietf//dtd html strict level 1//', '-//ietf//dtd html strict level 2//', '-//ietf//dtd html strict level 3//', '-//ietf//dtd html strict//', '-//ietf//dtd html//', '-//metrius//dtd metrius presentational//', '-//microsoft//dtd internet explorer 2.0 html strict//', '-//microsoft//dtd internet explorer 2.0 html//', '-//microsoft//dtd internet explorer 2.0 tables//', '-//microsoft//dtd internet explorer 3.0 html strict//', '-//microsoft//dtd internet explorer 3.0 html//', '-//microsoft//dtd internet explorer 3.0 tables//', '-//netscape comm. corp.//dtd html//', '-//netscape comm. corp.//dtd strict html//', "-//o'reilly and associates//dtd html 2.0//", "-//o'reilly and associates//dtd html extended 1.0//", "-//o'reilly and associates//dtd html extended relaxed 1.0//", '-//sq//dtd html 2.0 hotmetal + extensions//', '-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//', '-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//', '-//spyglass//dtd html 2.0 extended//', '-//sun microsystems corp.//dtd hotjava html//', '-//sun microsystems corp.//dtd hotjava strict html//', '-//w3c//dtd html 3 1995-03-24//', '-//w3c//dtd html 3.2 draft//', '-//w3c//dtd html 3.2 final//', '-//w3c//dtd html 3.2//', '-//w3c//dtd html 3.2s draft//', '-//w3c//dtd html 4.0 frameset//', '-//w3c//dtd html 4.0 transitional//', '-//w3c//dtd html experimental 19960712//', '-//w3c//dtd html experimental 970421//', '-//w3c//dtd w3 html//', '-//w3o//dtd w3 html 3.0//', '-//webtechs//dtd mozilla html 2.0//', '-//webtechs//dtd mozilla html//'];
  75014. var QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES$1 = concat$5(_context$2 = []).call(_context$2, QUIRKS_MODE_PUBLIC_ID_PREFIXES$1, ['-//w3c//dtd html 4.01 frameset//', '-//w3c//dtd html 4.01 transitional//']);
  75015. var QUIRKS_MODE_PUBLIC_IDS$1 = new set$4(['-//w3o//dtd w3 html strict 3.0//en//', '-/w3c/dtd html 4.0 transitional/en', 'html']);
  75016. var LIMITED_QUIRKS_PUBLIC_ID_PREFIXES$1 = ['-//w3c//dtd xhtml 1.0 frameset//', '-//w3c//dtd xhtml 1.0 transitional//'];
  75017. var LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES$1 = concat$5(_context2$1 = []).call(_context2$1, LIMITED_QUIRKS_PUBLIC_ID_PREFIXES$1, ['-//w3c//dtd html 4.01 frameset//', '-//w3c//dtd html 4.01 transitional//']); //Utils
  75018. var _context$3, _context2$2;
  75019. var SVG_ATTRS_ADJUSTMENT_MAP$1 = new map$b(map$3(_context$3 = ['attributeName', 'attributeType', 'baseFrequency', 'baseProfile', 'calcMode', 'clipPathUnits', 'diffuseConstant', 'edgeMode', 'filterUnits', 'glyphRef', 'gradientTransform', 'gradientUnits', 'kernelMatrix', 'kernelUnitLength', 'keyPoints', 'keySplines', 'keyTimes', 'lengthAdjust', 'limitingConeAngle', 'markerHeight', 'markerUnits', 'markerWidth', 'maskContentUnits', 'maskUnits', 'numOctaves', 'pathLength', 'patternContentUnits', 'patternTransform', 'patternUnits', 'pointsAtX', 'pointsAtY', 'pointsAtZ', 'preserveAlpha', 'preserveAspectRatio', 'primitiveUnits', 'refX', 'refY', 'repeatCount', 'repeatDur', 'requiredExtensions', 'requiredFeatures', 'specularConstant', 'specularExponent', 'spreadMethod', 'startOffset', 'stdDeviation', 'stitchTiles', 'surfaceScale', 'systemLanguage', 'tableValues', 'targetX', 'targetY', 'textLength', 'viewBox', 'viewTarget', 'xChannelSelector', 'yChannelSelector', 'zoomAndPan']).call(_context$3, function (attr) {
  75020. return [attr.toLowerCase(), attr];
  75021. }));
  75022. var XML_ATTRS_ADJUSTMENT_MAP$1 = new map$b([['xlink:actuate', {
  75023. prefix: 'xlink',
  75024. name: 'actuate',
  75025. namespace: NS$1.XLINK
  75026. }], ['xlink:arcrole', {
  75027. prefix: 'xlink',
  75028. name: 'arcrole',
  75029. namespace: NS$1.XLINK
  75030. }], ['xlink:href', {
  75031. prefix: 'xlink',
  75032. name: 'href',
  75033. namespace: NS$1.XLINK
  75034. }], ['xlink:role', {
  75035. prefix: 'xlink',
  75036. name: 'role',
  75037. namespace: NS$1.XLINK
  75038. }], ['xlink:show', {
  75039. prefix: 'xlink',
  75040. name: 'show',
  75041. namespace: NS$1.XLINK
  75042. }], ['xlink:title', {
  75043. prefix: 'xlink',
  75044. name: 'title',
  75045. namespace: NS$1.XLINK
  75046. }], ['xlink:type', {
  75047. prefix: 'xlink',
  75048. name: 'type',
  75049. namespace: NS$1.XLINK
  75050. }], ['xml:base', {
  75051. prefix: 'xml',
  75052. name: 'base',
  75053. namespace: NS$1.XML
  75054. }], ['xml:lang', {
  75055. prefix: 'xml',
  75056. name: 'lang',
  75057. namespace: NS$1.XML
  75058. }], ['xml:space', {
  75059. prefix: 'xml',
  75060. name: 'space',
  75061. namespace: NS$1.XML
  75062. }], ['xmlns', {
  75063. prefix: '',
  75064. name: 'xmlns',
  75065. namespace: NS$1.XMLNS
  75066. }], ['xmlns:xlink', {
  75067. prefix: 'xmlns',
  75068. name: 'xlink',
  75069. namespace: NS$1.XMLNS
  75070. }]]); //SVG tag names adjustment map
  75071. var SVG_TAG_NAMES_ADJUSTMENT_MAP$1 = new map$b(map$3(_context2$2 = ['altGlyph', 'altGlyphDef', 'altGlyphItem', 'animateColor', 'animateMotion', 'animateTransform', 'clipPath', 'feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'foreignObject', 'glyphRef', 'linearGradient', 'radialGradient', 'textPath']).call(_context2$2, function (tn) {
  75072. return [tn.toLowerCase(), tn];
  75073. })); //Tags that causes exit from foreign content
  75074. var EXITS_FOREIGN_CONTENT$1 = new set$4([TAG_ID$1.B, TAG_ID$1.BIG, TAG_ID$1.BLOCKQUOTE, TAG_ID$1.BODY, TAG_ID$1.BR, TAG_ID$1.CENTER, TAG_ID$1.CODE, TAG_ID$1.DD, TAG_ID$1.DIV, TAG_ID$1.DL, TAG_ID$1.DT, TAG_ID$1.EM, TAG_ID$1.EMBED, TAG_ID$1.H1, TAG_ID$1.H2, TAG_ID$1.H3, TAG_ID$1.H4, TAG_ID$1.H5, TAG_ID$1.H6, TAG_ID$1.HEAD, TAG_ID$1.HR, TAG_ID$1.I, TAG_ID$1.IMG, TAG_ID$1.LI, TAG_ID$1.LISTING, TAG_ID$1.MENU, TAG_ID$1.META, TAG_ID$1.NOBR, TAG_ID$1.OL, TAG_ID$1.P, TAG_ID$1.PRE, TAG_ID$1.RUBY, TAG_ID$1.S, TAG_ID$1.SMALL, TAG_ID$1.SPAN, TAG_ID$1.STRONG, TAG_ID$1.STRIKE, TAG_ID$1.SUB, TAG_ID$1.SUP, TAG_ID$1.TABLE, TAG_ID$1.TT, TAG_ID$1.U, TAG_ID$1.UL, TAG_ID$1.VAR]); //Check exit from foreign content
  75075. var InsertionMode$1;
  75076. (function (InsertionMode) {
  75077. InsertionMode[InsertionMode["INITIAL"] = 0] = "INITIAL";
  75078. InsertionMode[InsertionMode["BEFORE_HTML"] = 1] = "BEFORE_HTML";
  75079. InsertionMode[InsertionMode["BEFORE_HEAD"] = 2] = "BEFORE_HEAD";
  75080. InsertionMode[InsertionMode["IN_HEAD"] = 3] = "IN_HEAD";
  75081. InsertionMode[InsertionMode["IN_HEAD_NO_SCRIPT"] = 4] = "IN_HEAD_NO_SCRIPT";
  75082. InsertionMode[InsertionMode["AFTER_HEAD"] = 5] = "AFTER_HEAD";
  75083. InsertionMode[InsertionMode["IN_BODY"] = 6] = "IN_BODY";
  75084. InsertionMode[InsertionMode["TEXT"] = 7] = "TEXT";
  75085. InsertionMode[InsertionMode["IN_TABLE"] = 8] = "IN_TABLE";
  75086. InsertionMode[InsertionMode["IN_TABLE_TEXT"] = 9] = "IN_TABLE_TEXT";
  75087. InsertionMode[InsertionMode["IN_CAPTION"] = 10] = "IN_CAPTION";
  75088. InsertionMode[InsertionMode["IN_COLUMN_GROUP"] = 11] = "IN_COLUMN_GROUP";
  75089. InsertionMode[InsertionMode["IN_TABLE_BODY"] = 12] = "IN_TABLE_BODY";
  75090. InsertionMode[InsertionMode["IN_ROW"] = 13] = "IN_ROW";
  75091. InsertionMode[InsertionMode["IN_CELL"] = 14] = "IN_CELL";
  75092. InsertionMode[InsertionMode["IN_SELECT"] = 15] = "IN_SELECT";
  75093. InsertionMode[InsertionMode["IN_SELECT_IN_TABLE"] = 16] = "IN_SELECT_IN_TABLE";
  75094. InsertionMode[InsertionMode["IN_TEMPLATE"] = 17] = "IN_TEMPLATE";
  75095. InsertionMode[InsertionMode["AFTER_BODY"] = 18] = "AFTER_BODY";
  75096. InsertionMode[InsertionMode["IN_FRAMESET"] = 19] = "IN_FRAMESET";
  75097. InsertionMode[InsertionMode["AFTER_FRAMESET"] = 20] = "AFTER_FRAMESET";
  75098. InsertionMode[InsertionMode["AFTER_AFTER_BODY"] = 21] = "AFTER_AFTER_BODY";
  75099. InsertionMode[InsertionMode["AFTER_AFTER_FRAMESET"] = 22] = "AFTER_AFTER_FRAMESET";
  75100. })(InsertionMode$1 || (InsertionMode$1 = {}));
  75101. var TABLE_STRUCTURE_TAGS$1 = new set$4([TAG_ID$1.TABLE, TAG_ID$1.TBODY, TAG_ID$1.TFOOT, TAG_ID$1.THEAD, TAG_ID$1.TR]);
  75102. //------------------------------------------------------------------
  75103. var TABLE_VOID_ELEMENTS$1 = new set$4([TAG_ID$1.CAPTION, TAG_ID$1.COL, TAG_ID$1.COLGROUP, TAG_ID$1.TBODY, TAG_ID$1.TD, TAG_ID$1.TFOOT, TAG_ID$1.TH, TAG_ID$1.THEAD, TAG_ID$1.TR]);
  75104. var VOID_ELEMENTS$1 = new set$4([TAG_NAMES$1.AREA, TAG_NAMES$1.BASE, TAG_NAMES$1.BASEFONT, TAG_NAMES$1.BGSOUND, TAG_NAMES$1.BR, TAG_NAMES$1.COL, TAG_NAMES$1.EMBED, TAG_NAMES$1.FRAME, TAG_NAMES$1.HR, TAG_NAMES$1.IMG, TAG_NAMES$1.INPUT, TAG_NAMES$1.KEYGEN, TAG_NAMES$1.LINK, TAG_NAMES$1.META, TAG_NAMES$1.PARAM, TAG_NAMES$1.SOURCE, TAG_NAMES$1.TRACK, TAG_NAMES$1.WBR]);
  75105. function ownKeys$8(object, enumerableOnly) { var keys = keys$3(object); if (getOwnPropertySymbols$2) { var symbols = getOwnPropertySymbols$2(object); enumerableOnly && (symbols = filter$3(symbols).call(symbols, function (sym) { return getOwnPropertyDescriptor$3(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  75106. function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var _context7, _context8; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? forEach$3(_context7 = ownKeys$8(Object(source), !0)).call(_context7, function (key) { _defineProperty(target, key, source[key]); }) : getOwnPropertyDescriptors$2 ? defineProperties$2(target, getOwnPropertyDescriptors$2(source)) : forEach$3(_context8 = ownKeys$8(Object(source))).call(_context8, function (key) { defineProperty$5(target, key, getOwnPropertyDescriptor$3(source, key)); }); } return target; }
  75107. function createTextNode$1(value) {
  75108. return new Text$1(value);
  75109. }
  75110. function enquoteDoctypeId(id) {
  75111. var quote = includes$4(id).call(id, '"') ? "'" : '"';
  75112. return quote + id + quote;
  75113. }
  75114. /** @internal */
  75115. function serializeDoctypeContent(name, publicId, systemId) {
  75116. var str = '!DOCTYPE ';
  75117. if (name) {
  75118. str += name;
  75119. }
  75120. if (publicId) {
  75121. str += " PUBLIC ".concat(enquoteDoctypeId(publicId));
  75122. } else if (systemId) {
  75123. str += ' SYSTEM';
  75124. }
  75125. if (systemId) {
  75126. str += " ".concat(enquoteDoctypeId(systemId));
  75127. }
  75128. return str;
  75129. }
  75130. var adapter = {
  75131. // Re-exports from domhandler
  75132. isCommentNode: isComment,
  75133. isElementNode: isTag$1,
  75134. isTextNode: isText,
  75135. //Node construction
  75136. createDocument: function createDocument() {
  75137. var node = new Document([]);
  75138. node['x-mode'] = DOCUMENT_MODE$1.NO_QUIRKS;
  75139. return node;
  75140. },
  75141. createDocumentFragment: function createDocumentFragment() {
  75142. return new Document([]);
  75143. },
  75144. createElement: function createElement(tagName, namespaceURI, attrs) {
  75145. var attribs = create$6(null);
  75146. var attribsNamespace = create$6(null);
  75147. var attribsPrefix = create$6(null);
  75148. for (var i = 0; i < attrs.length; i++) {
  75149. var attrName = attrs[i].name;
  75150. attribs[attrName] = attrs[i].value;
  75151. attribsNamespace[attrName] = attrs[i].namespace;
  75152. attribsPrefix[attrName] = attrs[i].prefix;
  75153. }
  75154. var node = new Element(tagName, attribs, []);
  75155. node.namespace = namespaceURI;
  75156. node['x-attribsNamespace'] = attribsNamespace;
  75157. node['x-attribsPrefix'] = attribsPrefix;
  75158. return node;
  75159. },
  75160. createCommentNode: function createCommentNode(data) {
  75161. return new Comment$1(data);
  75162. },
  75163. //Tree mutation
  75164. appendChild: function appendChild(parentNode, newNode) {
  75165. var prev = parentNode.children[parentNode.children.length - 1];
  75166. if (prev) {
  75167. prev.next = newNode;
  75168. newNode.prev = prev;
  75169. }
  75170. parentNode.children.push(newNode);
  75171. newNode.parent = parentNode;
  75172. },
  75173. insertBefore: function insertBefore(parentNode, newNode, referenceNode) {
  75174. var _context, _context2;
  75175. var insertionIdx = indexOf$8(_context = parentNode.children).call(_context, referenceNode);
  75176. var prev = referenceNode.prev;
  75177. if (prev) {
  75178. prev.next = newNode;
  75179. newNode.prev = prev;
  75180. }
  75181. referenceNode.prev = newNode;
  75182. newNode.next = referenceNode;
  75183. splice$4(_context2 = parentNode.children).call(_context2, insertionIdx, 0, newNode);
  75184. newNode.parent = parentNode;
  75185. },
  75186. setTemplateContent: function setTemplateContent(templateElement, contentElement) {
  75187. adapter.appendChild(templateElement, contentElement);
  75188. },
  75189. getTemplateContent: function getTemplateContent(templateElement) {
  75190. return templateElement.children[0];
  75191. },
  75192. setDocumentType: function setDocumentType(document, name, publicId, systemId) {
  75193. var _context3;
  75194. var data = serializeDoctypeContent(name, publicId, systemId);
  75195. var doctypeNode = find$3(_context3 = document.children).call(_context3, function (node) {
  75196. return isDirective(node) && node.name === '!doctype';
  75197. });
  75198. if (doctypeNode) {
  75199. doctypeNode.data = data !== null && data !== void 0 ? data : null;
  75200. } else {
  75201. doctypeNode = new ProcessingInstruction('!doctype', data);
  75202. adapter.appendChild(document, doctypeNode);
  75203. }
  75204. doctypeNode['x-name'] = name !== null && name !== void 0 ? name : undefined;
  75205. doctypeNode['x-publicId'] = publicId !== null && publicId !== void 0 ? publicId : undefined;
  75206. doctypeNode['x-systemId'] = systemId !== null && systemId !== void 0 ? systemId : undefined;
  75207. },
  75208. setDocumentMode: function setDocumentMode(document, mode) {
  75209. document['x-mode'] = mode;
  75210. },
  75211. getDocumentMode: function getDocumentMode(document) {
  75212. return document['x-mode'];
  75213. },
  75214. detachNode: function detachNode(node) {
  75215. if (node.parent) {
  75216. var _context4, _context5;
  75217. var idx = indexOf$8(_context4 = node.parent.children).call(_context4, node);
  75218. var prev = node.prev,
  75219. next = node.next;
  75220. node.prev = null;
  75221. node.next = null;
  75222. if (prev) {
  75223. prev.next = next;
  75224. }
  75225. if (next) {
  75226. next.prev = prev;
  75227. }
  75228. splice$4(_context5 = node.parent.children).call(_context5, idx, 1);
  75229. node.parent = null;
  75230. }
  75231. },
  75232. insertText: function insertText(parentNode, text) {
  75233. var lastChild = parentNode.children[parentNode.children.length - 1];
  75234. if (lastChild && isText(lastChild)) {
  75235. lastChild.data += text;
  75236. } else {
  75237. adapter.appendChild(parentNode, createTextNode$1(text));
  75238. }
  75239. },
  75240. insertTextBefore: function insertTextBefore(parentNode, text, referenceNode) {
  75241. var _context6;
  75242. var prevNode = parentNode.children[indexOf$8(_context6 = parentNode.children).call(_context6, referenceNode) - 1];
  75243. if (prevNode && isText(prevNode)) {
  75244. prevNode.data += text;
  75245. } else {
  75246. adapter.insertBefore(parentNode, createTextNode$1(text), referenceNode);
  75247. }
  75248. },
  75249. adoptAttributes: function adoptAttributes(recipient, attrs) {
  75250. for (var i = 0; i < attrs.length; i++) {
  75251. var attrName = attrs[i].name;
  75252. if (typeof recipient.attribs[attrName] === 'undefined') {
  75253. recipient.attribs[attrName] = attrs[i].value;
  75254. recipient['x-attribsNamespace'][attrName] = attrs[i].namespace;
  75255. recipient['x-attribsPrefix'][attrName] = attrs[i].prefix;
  75256. }
  75257. }
  75258. },
  75259. //Tree traversing
  75260. getFirstChild: function getFirstChild(node) {
  75261. return node.children[0];
  75262. },
  75263. getChildNodes: function getChildNodes(node) {
  75264. return node.children;
  75265. },
  75266. getParentNode: function getParentNode(node) {
  75267. return node.parent;
  75268. },
  75269. getAttrList: function getAttrList(element) {
  75270. return element.attributes;
  75271. },
  75272. //Node data
  75273. getTagName: function getTagName(element) {
  75274. return element.name;
  75275. },
  75276. getNamespaceURI: function getNamespaceURI(element) {
  75277. return element.namespace;
  75278. },
  75279. getTextNodeContent: function getTextNodeContent(textNode) {
  75280. return textNode.data;
  75281. },
  75282. getCommentNodeContent: function getCommentNodeContent(commentNode) {
  75283. return commentNode.data;
  75284. },
  75285. getDocumentTypeNodeName: function getDocumentTypeNodeName(doctypeNode) {
  75286. var _a;
  75287. return (_a = doctypeNode['x-name']) !== null && _a !== void 0 ? _a : '';
  75288. },
  75289. getDocumentTypeNodePublicId: function getDocumentTypeNodePublicId(doctypeNode) {
  75290. var _a;
  75291. return (_a = doctypeNode['x-publicId']) !== null && _a !== void 0 ? _a : '';
  75292. },
  75293. getDocumentTypeNodeSystemId: function getDocumentTypeNodeSystemId(doctypeNode) {
  75294. var _a;
  75295. return (_a = doctypeNode['x-systemId']) !== null && _a !== void 0 ? _a : '';
  75296. },
  75297. //Node types
  75298. isDocumentTypeNode: function isDocumentTypeNode(node) {
  75299. return isDirective(node) && node.name === '!doctype';
  75300. },
  75301. // Source code location
  75302. setNodeSourceCodeLocation: function setNodeSourceCodeLocation(node, location) {
  75303. if (location) {
  75304. node.startIndex = location.startOffset;
  75305. node.endIndex = location.endOffset;
  75306. }
  75307. node.sourceCodeLocation = location;
  75308. },
  75309. getNodeSourceCodeLocation: function getNodeSourceCodeLocation(node) {
  75310. return node.sourceCodeLocation;
  75311. },
  75312. updateNodeSourceCodeLocation: function updateNodeSourceCodeLocation(node, endLocation) {
  75313. if (endLocation.endOffset != null) node.endIndex = endLocation.endOffset;
  75314. node.sourceCodeLocation = _objectSpread$7(_objectSpread$7({}, node.sourceCodeLocation), endLocation);
  75315. }
  75316. };
  75317. /**
  75318. * Parse the content with `parse5` in the context of the given `ParentNode`.
  75319. *
  75320. * @param content - The content to parse.
  75321. * @param options - A set of options to use to parse.
  75322. * @param isDocument - Whether to parse the content as a full HTML document.
  75323. * @param context - The context in which to parse the content.
  75324. * @returns The parsed content.
  75325. */
  75326. function parseWithParse5(content, options, isDocument, context) {
  75327. const opts = {
  75328. scriptingEnabled: typeof options.scriptingEnabled === 'boolean'
  75329. ? options.scriptingEnabled
  75330. : true,
  75331. treeAdapter: adapter,
  75332. sourceCodeLocationInfo: options.sourceCodeLocationInfo,
  75333. };
  75334. return isDocument
  75335. ? parse$3(content, opts)
  75336. : parseFragment(context, content, opts);
  75337. }
  75338. const renderOpts = { treeAdapter: adapter };
  75339. /**
  75340. * Renders the given DOM tree with `parse5` and returns the result as a string.
  75341. *
  75342. * @param dom - The DOM tree to render.
  75343. * @returns The rendered document.
  75344. */
  75345. function renderWithParse5(dom) {
  75346. /*
  75347. * `dom-serializer` passes over the special "root" node and renders the
  75348. * node's children in its place. To mimic this behavior with `parse5`, an
  75349. * equivalent operation must be applied to the input array.
  75350. */
  75351. const nodes = 'length' in dom ? dom : [dom];
  75352. for (let index = 0; index < nodes.length; index += 1) {
  75353. const node = nodes[index];
  75354. if (isDocument(node)) {
  75355. Array.prototype.splice.call(nodes, index, 1, ...node.children);
  75356. }
  75357. }
  75358. let result = '';
  75359. for (let index = 0; index < nodes.length; index += 1) {
  75360. const node = nodes[index];
  75361. result += serializeOuter(node, renderOpts);
  75362. }
  75363. return result;
  75364. }
  75365. var CharCodes;
  75366. (function (CharCodes) {
  75367. CharCodes[CharCodes["Tab"] = 9] = "Tab";
  75368. CharCodes[CharCodes["NewLine"] = 10] = "NewLine";
  75369. CharCodes[CharCodes["FormFeed"] = 12] = "FormFeed";
  75370. CharCodes[CharCodes["CarriageReturn"] = 13] = "CarriageReturn";
  75371. CharCodes[CharCodes["Space"] = 32] = "Space";
  75372. CharCodes[CharCodes["ExclamationMark"] = 33] = "ExclamationMark";
  75373. CharCodes[CharCodes["Num"] = 35] = "Num";
  75374. CharCodes[CharCodes["Amp"] = 38] = "Amp";
  75375. CharCodes[CharCodes["SingleQuote"] = 39] = "SingleQuote";
  75376. CharCodes[CharCodes["DoubleQuote"] = 34] = "DoubleQuote";
  75377. CharCodes[CharCodes["Dash"] = 45] = "Dash";
  75378. CharCodes[CharCodes["Slash"] = 47] = "Slash";
  75379. CharCodes[CharCodes["Zero"] = 48] = "Zero";
  75380. CharCodes[CharCodes["Nine"] = 57] = "Nine";
  75381. CharCodes[CharCodes["Semi"] = 59] = "Semi";
  75382. CharCodes[CharCodes["Lt"] = 60] = "Lt";
  75383. CharCodes[CharCodes["Eq"] = 61] = "Eq";
  75384. CharCodes[CharCodes["Gt"] = 62] = "Gt";
  75385. CharCodes[CharCodes["Questionmark"] = 63] = "Questionmark";
  75386. CharCodes[CharCodes["UpperA"] = 65] = "UpperA";
  75387. CharCodes[CharCodes["LowerA"] = 97] = "LowerA";
  75388. CharCodes[CharCodes["UpperF"] = 70] = "UpperF";
  75389. CharCodes[CharCodes["LowerF"] = 102] = "LowerF";
  75390. CharCodes[CharCodes["UpperZ"] = 90] = "UpperZ";
  75391. CharCodes[CharCodes["LowerZ"] = 122] = "LowerZ";
  75392. CharCodes[CharCodes["LowerX"] = 120] = "LowerX";
  75393. CharCodes[CharCodes["OpeningSquareBracket"] = 91] = "OpeningSquareBracket";
  75394. })(CharCodes || (CharCodes = {}));
  75395. /** All the states the tokenizer can be in. */
  75396. var State$2;
  75397. (function (State) {
  75398. State[State["Text"] = 1] = "Text";
  75399. State[State["BeforeTagName"] = 2] = "BeforeTagName";
  75400. State[State["InTagName"] = 3] = "InTagName";
  75401. State[State["InSelfClosingTag"] = 4] = "InSelfClosingTag";
  75402. State[State["BeforeClosingTagName"] = 5] = "BeforeClosingTagName";
  75403. State[State["InClosingTagName"] = 6] = "InClosingTagName";
  75404. State[State["AfterClosingTagName"] = 7] = "AfterClosingTagName";
  75405. // Attributes
  75406. State[State["BeforeAttributeName"] = 8] = "BeforeAttributeName";
  75407. State[State["InAttributeName"] = 9] = "InAttributeName";
  75408. State[State["AfterAttributeName"] = 10] = "AfterAttributeName";
  75409. State[State["BeforeAttributeValue"] = 11] = "BeforeAttributeValue";
  75410. State[State["InAttributeValueDq"] = 12] = "InAttributeValueDq";
  75411. State[State["InAttributeValueSq"] = 13] = "InAttributeValueSq";
  75412. State[State["InAttributeValueNq"] = 14] = "InAttributeValueNq";
  75413. // Declarations
  75414. State[State["BeforeDeclaration"] = 15] = "BeforeDeclaration";
  75415. State[State["InDeclaration"] = 16] = "InDeclaration";
  75416. // Processing instructions
  75417. State[State["InProcessingInstruction"] = 17] = "InProcessingInstruction";
  75418. // Comments & CDATA
  75419. State[State["BeforeComment"] = 18] = "BeforeComment";
  75420. State[State["CDATASequence"] = 19] = "CDATASequence";
  75421. State[State["InSpecialComment"] = 20] = "InSpecialComment";
  75422. State[State["InCommentLike"] = 21] = "InCommentLike";
  75423. // Special tags
  75424. State[State["BeforeSpecialS"] = 22] = "BeforeSpecialS";
  75425. State[State["SpecialStartSequence"] = 23] = "SpecialStartSequence";
  75426. State[State["InSpecialTag"] = 24] = "InSpecialTag";
  75427. State[State["BeforeEntity"] = 25] = "BeforeEntity";
  75428. State[State["BeforeNumericEntity"] = 26] = "BeforeNumericEntity";
  75429. State[State["InNamedEntity"] = 27] = "InNamedEntity";
  75430. State[State["InNumericEntity"] = 28] = "InNumericEntity";
  75431. State[State["InHexEntity"] = 29] = "InHexEntity";
  75432. })(State$2 || (State$2 = {}));
  75433. function isWhitespace$2(c) {
  75434. return (c === CharCodes.Space ||
  75435. c === CharCodes.NewLine ||
  75436. c === CharCodes.Tab ||
  75437. c === CharCodes.FormFeed ||
  75438. c === CharCodes.CarriageReturn);
  75439. }
  75440. function isEndOfTagSection(c) {
  75441. return c === CharCodes.Slash || c === CharCodes.Gt || isWhitespace$2(c);
  75442. }
  75443. function isNumber$1(c) {
  75444. return c >= CharCodes.Zero && c <= CharCodes.Nine;
  75445. }
  75446. function isASCIIAlpha(c) {
  75447. return ((c >= CharCodes.LowerA && c <= CharCodes.LowerZ) ||
  75448. (c >= CharCodes.UpperA && c <= CharCodes.UpperZ));
  75449. }
  75450. function isHexDigit(c) {
  75451. return ((c >= CharCodes.UpperA && c <= CharCodes.UpperF) ||
  75452. (c >= CharCodes.LowerA && c <= CharCodes.LowerF));
  75453. }
  75454. var QuoteType;
  75455. (function (QuoteType) {
  75456. QuoteType[QuoteType["NoValue"] = 0] = "NoValue";
  75457. QuoteType[QuoteType["Unquoted"] = 1] = "Unquoted";
  75458. QuoteType[QuoteType["Single"] = 2] = "Single";
  75459. QuoteType[QuoteType["Double"] = 3] = "Double";
  75460. })(QuoteType || (QuoteType = {}));
  75461. /**
  75462. * Sequences used to match longer strings.
  75463. *
  75464. * We don't have `Script`, `Style`, or `Title` here. Instead, we re-use the *End
  75465. * sequences with an increased offset.
  75466. */
  75467. const Sequences = {
  75468. Cdata: new Uint8Array([0x43, 0x44, 0x41, 0x54, 0x41, 0x5b]),
  75469. CdataEnd: new Uint8Array([0x5d, 0x5d, 0x3e]),
  75470. CommentEnd: new Uint8Array([0x2d, 0x2d, 0x3e]),
  75471. ScriptEnd: new Uint8Array([0x3c, 0x2f, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74]),
  75472. StyleEnd: new Uint8Array([0x3c, 0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65]),
  75473. TitleEnd: new Uint8Array([0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65]), // `</title`
  75474. };
  75475. class Tokenizer$1 {
  75476. constructor({ xmlMode = false, decodeEntities = true, }, cbs) {
  75477. this.cbs = cbs;
  75478. /** The current state the tokenizer is in. */
  75479. this.state = State$2.Text;
  75480. /** The read buffer. */
  75481. this.buffer = "";
  75482. /** The beginning of the section that is currently being read. */
  75483. this.sectionStart = 0;
  75484. /** The index within the buffer that we are currently looking at. */
  75485. this.index = 0;
  75486. /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
  75487. this.baseState = State$2.Text;
  75488. /** For special parsing behavior inside of script and style tags. */
  75489. this.isSpecial = false;
  75490. /** Indicates whether the tokenizer has been paused. */
  75491. this.running = true;
  75492. /** The offset of the current buffer. */
  75493. this.offset = 0;
  75494. this.sequenceIndex = 0;
  75495. this.trieIndex = 0;
  75496. this.trieCurrent = 0;
  75497. /** For named entities, the index of the value. For numeric entities, the code point. */
  75498. this.entityResult = 0;
  75499. this.entityExcess = 0;
  75500. this.xmlMode = xmlMode;
  75501. this.decodeEntities = decodeEntities;
  75502. this.entityTrie = xmlMode ? decode_9 : decode_10;
  75503. }
  75504. reset() {
  75505. this.state = State$2.Text;
  75506. this.buffer = "";
  75507. this.sectionStart = 0;
  75508. this.index = 0;
  75509. this.baseState = State$2.Text;
  75510. this.currentSequence = undefined;
  75511. this.running = true;
  75512. this.offset = 0;
  75513. }
  75514. write(chunk) {
  75515. this.offset += this.buffer.length;
  75516. this.buffer = chunk;
  75517. this.parse();
  75518. }
  75519. end() {
  75520. if (this.running)
  75521. this.finish();
  75522. }
  75523. pause() {
  75524. this.running = false;
  75525. }
  75526. resume() {
  75527. this.running = true;
  75528. if (this.index < this.buffer.length + this.offset) {
  75529. this.parse();
  75530. }
  75531. }
  75532. /**
  75533. * The current index within all of the written data.
  75534. */
  75535. getIndex() {
  75536. return this.index;
  75537. }
  75538. /**
  75539. * The start of the current section.
  75540. */
  75541. getSectionStart() {
  75542. return this.sectionStart;
  75543. }
  75544. stateText(c) {
  75545. if (c === CharCodes.Lt ||
  75546. (!this.decodeEntities && this.fastForwardTo(CharCodes.Lt))) {
  75547. if (this.index > this.sectionStart) {
  75548. this.cbs.ontext(this.sectionStart, this.index);
  75549. }
  75550. this.state = State$2.BeforeTagName;
  75551. this.sectionStart = this.index;
  75552. }
  75553. else if (this.decodeEntities && c === CharCodes.Amp) {
  75554. this.state = State$2.BeforeEntity;
  75555. }
  75556. }
  75557. stateSpecialStartSequence(c) {
  75558. const isEnd = this.sequenceIndex === this.currentSequence.length;
  75559. const isMatch = isEnd
  75560. ? // If we are at the end of the sequence, make sure the tag name has ended
  75561. isEndOfTagSection(c)
  75562. : // Otherwise, do a case-insensitive comparison
  75563. (c | 0x20) === this.currentSequence[this.sequenceIndex];
  75564. if (!isMatch) {
  75565. this.isSpecial = false;
  75566. }
  75567. else if (!isEnd) {
  75568. this.sequenceIndex++;
  75569. return;
  75570. }
  75571. this.sequenceIndex = 0;
  75572. this.state = State$2.InTagName;
  75573. this.stateInTagName(c);
  75574. }
  75575. /** Look for an end tag. For <title> tags, also decode entities. */
  75576. stateInSpecialTag(c) {
  75577. if (this.sequenceIndex === this.currentSequence.length) {
  75578. if (c === CharCodes.Gt || isWhitespace$2(c)) {
  75579. const endOfText = this.index - this.currentSequence.length;
  75580. if (this.sectionStart < endOfText) {
  75581. // Spoof the index so that reported locations match up.
  75582. const actualIndex = this.index;
  75583. this.index = endOfText;
  75584. this.cbs.ontext(this.sectionStart, endOfText);
  75585. this.index = actualIndex;
  75586. }
  75587. this.isSpecial = false;
  75588. this.sectionStart = endOfText + 2; // Skip over the `</`
  75589. this.stateInClosingTagName(c);
  75590. return; // We are done; skip the rest of the function.
  75591. }
  75592. this.sequenceIndex = 0;
  75593. }
  75594. if ((c | 0x20) === this.currentSequence[this.sequenceIndex]) {
  75595. this.sequenceIndex += 1;
  75596. }
  75597. else if (this.sequenceIndex === 0) {
  75598. if (this.currentSequence === Sequences.TitleEnd) {
  75599. // We have to parse entities in <title> tags.
  75600. if (this.decodeEntities && c === CharCodes.Amp) {
  75601. this.state = State$2.BeforeEntity;
  75602. }
  75603. }
  75604. else if (this.fastForwardTo(CharCodes.Lt)) {
  75605. // Outside of <title> tags, we can fast-forward.
  75606. this.sequenceIndex = 1;
  75607. }
  75608. }
  75609. else {
  75610. // If we see a `<`, set the sequence index to 1; useful for eg. `<</script>`.
  75611. this.sequenceIndex = Number(c === CharCodes.Lt);
  75612. }
  75613. }
  75614. stateCDATASequence(c) {
  75615. if (c === Sequences.Cdata[this.sequenceIndex]) {
  75616. if (++this.sequenceIndex === Sequences.Cdata.length) {
  75617. this.state = State$2.InCommentLike;
  75618. this.currentSequence = Sequences.CdataEnd;
  75619. this.sequenceIndex = 0;
  75620. this.sectionStart = this.index + 1;
  75621. }
  75622. }
  75623. else {
  75624. this.sequenceIndex = 0;
  75625. this.state = State$2.InDeclaration;
  75626. this.stateInDeclaration(c); // Reconsume the character
  75627. }
  75628. }
  75629. /**
  75630. * When we wait for one specific character, we can speed things up
  75631. * by skipping through the buffer until we find it.
  75632. *
  75633. * @returns Whether the character was found.
  75634. */
  75635. fastForwardTo(c) {
  75636. while (++this.index < this.buffer.length + this.offset) {
  75637. if (this.buffer.charCodeAt(this.index - this.offset) === c) {
  75638. return true;
  75639. }
  75640. }
  75641. /*
  75642. * We increment the index at the end of the `parse` loop,
  75643. * so set it to `buffer.length - 1` here.
  75644. *
  75645. * TODO: Refactor `parse` to increment index before calling states.
  75646. */
  75647. this.index = this.buffer.length + this.offset - 1;
  75648. return false;
  75649. }
  75650. /**
  75651. * Comments and CDATA end with `-->` and `]]>`.
  75652. *
  75653. * Their common qualities are:
  75654. * - Their end sequences have a distinct character they start with.
  75655. * - That character is then repeated, so we have to check multiple repeats.
  75656. * - All characters but the start character of the sequence can be skipped.
  75657. */
  75658. stateInCommentLike(c) {
  75659. if (c === this.currentSequence[this.sequenceIndex]) {
  75660. if (++this.sequenceIndex === this.currentSequence.length) {
  75661. if (this.currentSequence === Sequences.CdataEnd) {
  75662. this.cbs.oncdata(this.sectionStart, this.index, 2);
  75663. }
  75664. else {
  75665. this.cbs.oncomment(this.sectionStart, this.index, 2);
  75666. }
  75667. this.sequenceIndex = 0;
  75668. this.sectionStart = this.index + 1;
  75669. this.state = State$2.Text;
  75670. }
  75671. }
  75672. else if (this.sequenceIndex === 0) {
  75673. // Fast-forward to the first character of the sequence
  75674. if (this.fastForwardTo(this.currentSequence[0])) {
  75675. this.sequenceIndex = 1;
  75676. }
  75677. }
  75678. else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
  75679. // Allow long sequences, eg. --->, ]]]>
  75680. this.sequenceIndex = 0;
  75681. }
  75682. }
  75683. /**
  75684. * HTML only allows ASCII alpha characters (a-z and A-Z) at the beginning of a tag name.
  75685. *
  75686. * XML allows a lot more characters here (@see https://www.w3.org/TR/REC-xml/#NT-NameStartChar).
  75687. * We allow anything that wouldn't end the tag.
  75688. */
  75689. isTagStartChar(c) {
  75690. return this.xmlMode ? !isEndOfTagSection(c) : isASCIIAlpha(c);
  75691. }
  75692. startSpecial(sequence, offset) {
  75693. this.isSpecial = true;
  75694. this.currentSequence = sequence;
  75695. this.sequenceIndex = offset;
  75696. this.state = State$2.SpecialStartSequence;
  75697. }
  75698. stateBeforeTagName(c) {
  75699. if (c === CharCodes.ExclamationMark) {
  75700. this.state = State$2.BeforeDeclaration;
  75701. this.sectionStart = this.index + 1;
  75702. }
  75703. else if (c === CharCodes.Questionmark) {
  75704. this.state = State$2.InProcessingInstruction;
  75705. this.sectionStart = this.index + 1;
  75706. }
  75707. else if (this.isTagStartChar(c)) {
  75708. const lower = c | 0x20;
  75709. this.sectionStart = this.index;
  75710. if (!this.xmlMode && lower === Sequences.TitleEnd[2]) {
  75711. this.startSpecial(Sequences.TitleEnd, 3);
  75712. }
  75713. else {
  75714. this.state =
  75715. !this.xmlMode && lower === Sequences.ScriptEnd[2]
  75716. ? State$2.BeforeSpecialS
  75717. : State$2.InTagName;
  75718. }
  75719. }
  75720. else if (c === CharCodes.Slash) {
  75721. this.state = State$2.BeforeClosingTagName;
  75722. }
  75723. else {
  75724. this.state = State$2.Text;
  75725. this.stateText(c);
  75726. }
  75727. }
  75728. stateInTagName(c) {
  75729. if (isEndOfTagSection(c)) {
  75730. this.cbs.onopentagname(this.sectionStart, this.index);
  75731. this.sectionStart = -1;
  75732. this.state = State$2.BeforeAttributeName;
  75733. this.stateBeforeAttributeName(c);
  75734. }
  75735. }
  75736. stateBeforeClosingTagName(c) {
  75737. if (isWhitespace$2(c)) ;
  75738. else if (c === CharCodes.Gt) {
  75739. this.state = State$2.Text;
  75740. }
  75741. else {
  75742. this.state = this.isTagStartChar(c)
  75743. ? State$2.InClosingTagName
  75744. : State$2.InSpecialComment;
  75745. this.sectionStart = this.index;
  75746. }
  75747. }
  75748. stateInClosingTagName(c) {
  75749. if (c === CharCodes.Gt || isWhitespace$2(c)) {
  75750. this.cbs.onclosetag(this.sectionStart, this.index);
  75751. this.sectionStart = -1;
  75752. this.state = State$2.AfterClosingTagName;
  75753. this.stateAfterClosingTagName(c);
  75754. }
  75755. }
  75756. stateAfterClosingTagName(c) {
  75757. // Skip everything until ">"
  75758. if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {
  75759. this.state = State$2.Text;
  75760. this.sectionStart = this.index + 1;
  75761. }
  75762. }
  75763. stateBeforeAttributeName(c) {
  75764. if (c === CharCodes.Gt) {
  75765. this.cbs.onopentagend(this.index);
  75766. if (this.isSpecial) {
  75767. this.state = State$2.InSpecialTag;
  75768. this.sequenceIndex = 0;
  75769. }
  75770. else {
  75771. this.state = State$2.Text;
  75772. }
  75773. this.baseState = this.state;
  75774. this.sectionStart = this.index + 1;
  75775. }
  75776. else if (c === CharCodes.Slash) {
  75777. this.state = State$2.InSelfClosingTag;
  75778. }
  75779. else if (!isWhitespace$2(c)) {
  75780. this.state = State$2.InAttributeName;
  75781. this.sectionStart = this.index;
  75782. }
  75783. }
  75784. stateInSelfClosingTag(c) {
  75785. if (c === CharCodes.Gt) {
  75786. this.cbs.onselfclosingtag(this.index);
  75787. this.state = State$2.Text;
  75788. this.baseState = State$2.Text;
  75789. this.sectionStart = this.index + 1;
  75790. this.isSpecial = false; // Reset special state, in case of self-closing special tags
  75791. }
  75792. else if (!isWhitespace$2(c)) {
  75793. this.state = State$2.BeforeAttributeName;
  75794. this.stateBeforeAttributeName(c);
  75795. }
  75796. }
  75797. stateInAttributeName(c) {
  75798. if (c === CharCodes.Eq || isEndOfTagSection(c)) {
  75799. this.cbs.onattribname(this.sectionStart, this.index);
  75800. this.sectionStart = -1;
  75801. this.state = State$2.AfterAttributeName;
  75802. this.stateAfterAttributeName(c);
  75803. }
  75804. }
  75805. stateAfterAttributeName(c) {
  75806. if (c === CharCodes.Eq) {
  75807. this.state = State$2.BeforeAttributeValue;
  75808. }
  75809. else if (c === CharCodes.Slash || c === CharCodes.Gt) {
  75810. this.cbs.onattribend(QuoteType.NoValue, this.index);
  75811. this.state = State$2.BeforeAttributeName;
  75812. this.stateBeforeAttributeName(c);
  75813. }
  75814. else if (!isWhitespace$2(c)) {
  75815. this.cbs.onattribend(QuoteType.NoValue, this.index);
  75816. this.state = State$2.InAttributeName;
  75817. this.sectionStart = this.index;
  75818. }
  75819. }
  75820. stateBeforeAttributeValue(c) {
  75821. if (c === CharCodes.DoubleQuote) {
  75822. this.state = State$2.InAttributeValueDq;
  75823. this.sectionStart = this.index + 1;
  75824. }
  75825. else if (c === CharCodes.SingleQuote) {
  75826. this.state = State$2.InAttributeValueSq;
  75827. this.sectionStart = this.index + 1;
  75828. }
  75829. else if (!isWhitespace$2(c)) {
  75830. this.sectionStart = this.index;
  75831. this.state = State$2.InAttributeValueNq;
  75832. this.stateInAttributeValueNoQuotes(c); // Reconsume token
  75833. }
  75834. }
  75835. handleInAttributeValue(c, quote) {
  75836. if (c === quote ||
  75837. (!this.decodeEntities && this.fastForwardTo(quote))) {
  75838. this.cbs.onattribdata(this.sectionStart, this.index);
  75839. this.sectionStart = -1;
  75840. this.cbs.onattribend(quote === CharCodes.DoubleQuote
  75841. ? QuoteType.Double
  75842. : QuoteType.Single, this.index);
  75843. this.state = State$2.BeforeAttributeName;
  75844. }
  75845. else if (this.decodeEntities && c === CharCodes.Amp) {
  75846. this.baseState = this.state;
  75847. this.state = State$2.BeforeEntity;
  75848. }
  75849. }
  75850. stateInAttributeValueDoubleQuotes(c) {
  75851. this.handleInAttributeValue(c, CharCodes.DoubleQuote);
  75852. }
  75853. stateInAttributeValueSingleQuotes(c) {
  75854. this.handleInAttributeValue(c, CharCodes.SingleQuote);
  75855. }
  75856. stateInAttributeValueNoQuotes(c) {
  75857. if (isWhitespace$2(c) || c === CharCodes.Gt) {
  75858. this.cbs.onattribdata(this.sectionStart, this.index);
  75859. this.sectionStart = -1;
  75860. this.cbs.onattribend(QuoteType.Unquoted, this.index);
  75861. this.state = State$2.BeforeAttributeName;
  75862. this.stateBeforeAttributeName(c);
  75863. }
  75864. else if (this.decodeEntities && c === CharCodes.Amp) {
  75865. this.baseState = this.state;
  75866. this.state = State$2.BeforeEntity;
  75867. }
  75868. }
  75869. stateBeforeDeclaration(c) {
  75870. if (c === CharCodes.OpeningSquareBracket) {
  75871. this.state = State$2.CDATASequence;
  75872. this.sequenceIndex = 0;
  75873. }
  75874. else {
  75875. this.state =
  75876. c === CharCodes.Dash
  75877. ? State$2.BeforeComment
  75878. : State$2.InDeclaration;
  75879. }
  75880. }
  75881. stateInDeclaration(c) {
  75882. if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {
  75883. this.cbs.ondeclaration(this.sectionStart, this.index);
  75884. this.state = State$2.Text;
  75885. this.sectionStart = this.index + 1;
  75886. }
  75887. }
  75888. stateInProcessingInstruction(c) {
  75889. if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {
  75890. this.cbs.onprocessinginstruction(this.sectionStart, this.index);
  75891. this.state = State$2.Text;
  75892. this.sectionStart = this.index + 1;
  75893. }
  75894. }
  75895. stateBeforeComment(c) {
  75896. if (c === CharCodes.Dash) {
  75897. this.state = State$2.InCommentLike;
  75898. this.currentSequence = Sequences.CommentEnd;
  75899. // Allow short comments (eg. <!-->)
  75900. this.sequenceIndex = 2;
  75901. this.sectionStart = this.index + 1;
  75902. }
  75903. else {
  75904. this.state = State$2.InDeclaration;
  75905. }
  75906. }
  75907. stateInSpecialComment(c) {
  75908. if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {
  75909. this.cbs.oncomment(this.sectionStart, this.index, 0);
  75910. this.state = State$2.Text;
  75911. this.sectionStart = this.index + 1;
  75912. }
  75913. }
  75914. stateBeforeSpecialS(c) {
  75915. const lower = c | 0x20;
  75916. if (lower === Sequences.ScriptEnd[3]) {
  75917. this.startSpecial(Sequences.ScriptEnd, 4);
  75918. }
  75919. else if (lower === Sequences.StyleEnd[3]) {
  75920. this.startSpecial(Sequences.StyleEnd, 4);
  75921. }
  75922. else {
  75923. this.state = State$2.InTagName;
  75924. this.stateInTagName(c); // Consume the token again
  75925. }
  75926. }
  75927. stateBeforeEntity(c) {
  75928. // Start excess with 1 to include the '&'
  75929. this.entityExcess = 1;
  75930. this.entityResult = 0;
  75931. if (c === CharCodes.Num) {
  75932. this.state = State$2.BeforeNumericEntity;
  75933. }
  75934. else if (c === CharCodes.Amp) ;
  75935. else {
  75936. this.trieIndex = 0;
  75937. this.trieCurrent = this.entityTrie[0];
  75938. this.state = State$2.InNamedEntity;
  75939. this.stateInNamedEntity(c);
  75940. }
  75941. }
  75942. stateInNamedEntity(c) {
  75943. this.entityExcess += 1;
  75944. this.trieIndex = decode_4(this.entityTrie, this.trieCurrent, this.trieIndex + 1, c);
  75945. if (this.trieIndex < 0) {
  75946. this.emitNamedEntity();
  75947. this.index--;
  75948. return;
  75949. }
  75950. this.trieCurrent = this.entityTrie[this.trieIndex];
  75951. const masked = this.trieCurrent & decode_5.VALUE_LENGTH;
  75952. // If the branch is a value, store it and continue
  75953. if (masked) {
  75954. // The mask is the number of bytes of the value, including the current byte.
  75955. const valueLength = (masked >> 14) - 1;
  75956. // If we have a legacy entity while parsing strictly, just skip the number of bytes
  75957. if (!this.allowLegacyEntity() && c !== CharCodes.Semi) {
  75958. this.trieIndex += valueLength;
  75959. }
  75960. else {
  75961. // Add 1 as we have already incremented the excess
  75962. const entityStart = this.index - this.entityExcess + 1;
  75963. if (entityStart > this.sectionStart) {
  75964. this.emitPartial(this.sectionStart, entityStart);
  75965. }
  75966. // If this is a surrogate pair, consume the next two bytes
  75967. this.entityResult = this.trieIndex;
  75968. this.trieIndex += valueLength;
  75969. this.entityExcess = 0;
  75970. this.sectionStart = this.index + 1;
  75971. if (valueLength === 0) {
  75972. this.emitNamedEntity();
  75973. }
  75974. }
  75975. }
  75976. }
  75977. emitNamedEntity() {
  75978. this.state = this.baseState;
  75979. if (this.entityResult === 0) {
  75980. return;
  75981. }
  75982. const valueLength = (this.entityTrie[this.entityResult] & decode_5.VALUE_LENGTH) >>
  75983. 14;
  75984. switch (valueLength) {
  75985. case 1:
  75986. this.emitCodePoint(this.entityTrie[this.entityResult] &
  75987. ~decode_5.VALUE_LENGTH);
  75988. break;
  75989. case 2:
  75990. this.emitCodePoint(this.entityTrie[this.entityResult + 1]);
  75991. break;
  75992. case 3: {
  75993. this.emitCodePoint(this.entityTrie[this.entityResult + 1]);
  75994. this.emitCodePoint(this.entityTrie[this.entityResult + 2]);
  75995. }
  75996. }
  75997. }
  75998. stateBeforeNumericEntity(c) {
  75999. if ((c | 0x20) === CharCodes.LowerX) {
  76000. this.entityExcess++;
  76001. this.state = State$2.InHexEntity;
  76002. }
  76003. else {
  76004. this.state = State$2.InNumericEntity;
  76005. this.stateInNumericEntity(c);
  76006. }
  76007. }
  76008. emitNumericEntity(strict) {
  76009. const entityStart = this.index - this.entityExcess - 1;
  76010. const numberStart = entityStart + 2 + Number(this.state === State$2.InHexEntity);
  76011. if (numberStart !== this.index) {
  76012. // Emit leading data if any
  76013. if (entityStart > this.sectionStart) {
  76014. this.emitPartial(this.sectionStart, entityStart);
  76015. }
  76016. this.sectionStart = this.index + Number(strict);
  76017. this.emitCodePoint(decode_7(this.entityResult));
  76018. }
  76019. this.state = this.baseState;
  76020. }
  76021. stateInNumericEntity(c) {
  76022. if (c === CharCodes.Semi) {
  76023. this.emitNumericEntity(true);
  76024. }
  76025. else if (isNumber$1(c)) {
  76026. this.entityResult = this.entityResult * 10 + (c - CharCodes.Zero);
  76027. this.entityExcess++;
  76028. }
  76029. else {
  76030. if (this.allowLegacyEntity()) {
  76031. this.emitNumericEntity(false);
  76032. }
  76033. else {
  76034. this.state = this.baseState;
  76035. }
  76036. this.index--;
  76037. }
  76038. }
  76039. stateInHexEntity(c) {
  76040. if (c === CharCodes.Semi) {
  76041. this.emitNumericEntity(true);
  76042. }
  76043. else if (isNumber$1(c)) {
  76044. this.entityResult = this.entityResult * 16 + (c - CharCodes.Zero);
  76045. this.entityExcess++;
  76046. }
  76047. else if (isHexDigit(c)) {
  76048. this.entityResult =
  76049. this.entityResult * 16 + ((c | 0x20) - CharCodes.LowerA + 10);
  76050. this.entityExcess++;
  76051. }
  76052. else {
  76053. if (this.allowLegacyEntity()) {
  76054. this.emitNumericEntity(false);
  76055. }
  76056. else {
  76057. this.state = this.baseState;
  76058. }
  76059. this.index--;
  76060. }
  76061. }
  76062. allowLegacyEntity() {
  76063. return (!this.xmlMode &&
  76064. (this.baseState === State$2.Text ||
  76065. this.baseState === State$2.InSpecialTag));
  76066. }
  76067. /**
  76068. * Remove data that has already been consumed from the buffer.
  76069. */
  76070. cleanup() {
  76071. // If we are inside of text or attributes, emit what we already have.
  76072. if (this.running && this.sectionStart !== this.index) {
  76073. if (this.state === State$2.Text ||
  76074. (this.state === State$2.InSpecialTag && this.sequenceIndex === 0)) {
  76075. this.cbs.ontext(this.sectionStart, this.index);
  76076. this.sectionStart = this.index;
  76077. }
  76078. else if (this.state === State$2.InAttributeValueDq ||
  76079. this.state === State$2.InAttributeValueSq ||
  76080. this.state === State$2.InAttributeValueNq) {
  76081. this.cbs.onattribdata(this.sectionStart, this.index);
  76082. this.sectionStart = this.index;
  76083. }
  76084. }
  76085. }
  76086. shouldContinue() {
  76087. return this.index < this.buffer.length + this.offset && this.running;
  76088. }
  76089. /**
  76090. * Iterates through the buffer, calling the function corresponding to the current state.
  76091. *
  76092. * States that are more likely to be hit are higher up, as a performance improvement.
  76093. */
  76094. parse() {
  76095. while (this.shouldContinue()) {
  76096. const c = this.buffer.charCodeAt(this.index - this.offset);
  76097. if (this.state === State$2.Text) {
  76098. this.stateText(c);
  76099. }
  76100. else if (this.state === State$2.SpecialStartSequence) {
  76101. this.stateSpecialStartSequence(c);
  76102. }
  76103. else if (this.state === State$2.InSpecialTag) {
  76104. this.stateInSpecialTag(c);
  76105. }
  76106. else if (this.state === State$2.CDATASequence) {
  76107. this.stateCDATASequence(c);
  76108. }
  76109. else if (this.state === State$2.InAttributeValueDq) {
  76110. this.stateInAttributeValueDoubleQuotes(c);
  76111. }
  76112. else if (this.state === State$2.InAttributeName) {
  76113. this.stateInAttributeName(c);
  76114. }
  76115. else if (this.state === State$2.InCommentLike) {
  76116. this.stateInCommentLike(c);
  76117. }
  76118. else if (this.state === State$2.InSpecialComment) {
  76119. this.stateInSpecialComment(c);
  76120. }
  76121. else if (this.state === State$2.BeforeAttributeName) {
  76122. this.stateBeforeAttributeName(c);
  76123. }
  76124. else if (this.state === State$2.InTagName) {
  76125. this.stateInTagName(c);
  76126. }
  76127. else if (this.state === State$2.InClosingTagName) {
  76128. this.stateInClosingTagName(c);
  76129. }
  76130. else if (this.state === State$2.BeforeTagName) {
  76131. this.stateBeforeTagName(c);
  76132. }
  76133. else if (this.state === State$2.AfterAttributeName) {
  76134. this.stateAfterAttributeName(c);
  76135. }
  76136. else if (this.state === State$2.InAttributeValueSq) {
  76137. this.stateInAttributeValueSingleQuotes(c);
  76138. }
  76139. else if (this.state === State$2.BeforeAttributeValue) {
  76140. this.stateBeforeAttributeValue(c);
  76141. }
  76142. else if (this.state === State$2.BeforeClosingTagName) {
  76143. this.stateBeforeClosingTagName(c);
  76144. }
  76145. else if (this.state === State$2.AfterClosingTagName) {
  76146. this.stateAfterClosingTagName(c);
  76147. }
  76148. else if (this.state === State$2.BeforeSpecialS) {
  76149. this.stateBeforeSpecialS(c);
  76150. }
  76151. else if (this.state === State$2.InAttributeValueNq) {
  76152. this.stateInAttributeValueNoQuotes(c);
  76153. }
  76154. else if (this.state === State$2.InSelfClosingTag) {
  76155. this.stateInSelfClosingTag(c);
  76156. }
  76157. else if (this.state === State$2.InDeclaration) {
  76158. this.stateInDeclaration(c);
  76159. }
  76160. else if (this.state === State$2.BeforeDeclaration) {
  76161. this.stateBeforeDeclaration(c);
  76162. }
  76163. else if (this.state === State$2.BeforeComment) {
  76164. this.stateBeforeComment(c);
  76165. }
  76166. else if (this.state === State$2.InProcessingInstruction) {
  76167. this.stateInProcessingInstruction(c);
  76168. }
  76169. else if (this.state === State$2.InNamedEntity) {
  76170. this.stateInNamedEntity(c);
  76171. }
  76172. else if (this.state === State$2.BeforeEntity) {
  76173. this.stateBeforeEntity(c);
  76174. }
  76175. else if (this.state === State$2.InHexEntity) {
  76176. this.stateInHexEntity(c);
  76177. }
  76178. else if (this.state === State$2.InNumericEntity) {
  76179. this.stateInNumericEntity(c);
  76180. }
  76181. else {
  76182. // `this._state === State.BeforeNumericEntity`
  76183. this.stateBeforeNumericEntity(c);
  76184. }
  76185. this.index++;
  76186. }
  76187. this.cleanup();
  76188. }
  76189. finish() {
  76190. if (this.state === State$2.InNamedEntity) {
  76191. this.emitNamedEntity();
  76192. }
  76193. // If there is remaining data, emit it in a reasonable way
  76194. if (this.sectionStart < this.index) {
  76195. this.handleTrailingData();
  76196. }
  76197. this.cbs.onend();
  76198. }
  76199. /** Handle any trailing data. */
  76200. handleTrailingData() {
  76201. const endIndex = this.buffer.length + this.offset;
  76202. if (this.state === State$2.InCommentLike) {
  76203. if (this.currentSequence === Sequences.CdataEnd) {
  76204. this.cbs.oncdata(this.sectionStart, endIndex, 0);
  76205. }
  76206. else {
  76207. this.cbs.oncomment(this.sectionStart, endIndex, 0);
  76208. }
  76209. }
  76210. else if (this.state === State$2.InNumericEntity &&
  76211. this.allowLegacyEntity()) {
  76212. this.emitNumericEntity(false);
  76213. // All trailing data will have been consumed
  76214. }
  76215. else if (this.state === State$2.InHexEntity &&
  76216. this.allowLegacyEntity()) {
  76217. this.emitNumericEntity(false);
  76218. // All trailing data will have been consumed
  76219. }
  76220. else if (this.state === State$2.InTagName ||
  76221. this.state === State$2.BeforeAttributeName ||
  76222. this.state === State$2.BeforeAttributeValue ||
  76223. this.state === State$2.AfterAttributeName ||
  76224. this.state === State$2.InAttributeName ||
  76225. this.state === State$2.InAttributeValueSq ||
  76226. this.state === State$2.InAttributeValueDq ||
  76227. this.state === State$2.InAttributeValueNq ||
  76228. this.state === State$2.InClosingTagName) ;
  76229. else {
  76230. this.cbs.ontext(this.sectionStart, endIndex);
  76231. }
  76232. }
  76233. emitPartial(start, endIndex) {
  76234. if (this.baseState !== State$2.Text &&
  76235. this.baseState !== State$2.InSpecialTag) {
  76236. this.cbs.onattribdata(start, endIndex);
  76237. }
  76238. else {
  76239. this.cbs.ontext(start, endIndex);
  76240. }
  76241. }
  76242. emitCodePoint(cp) {
  76243. if (this.baseState !== State$2.Text &&
  76244. this.baseState !== State$2.InSpecialTag) {
  76245. this.cbs.onattribentity(cp);
  76246. }
  76247. else {
  76248. this.cbs.ontextentity(cp);
  76249. }
  76250. }
  76251. }
  76252. const formTags = new Set([
  76253. "input",
  76254. "option",
  76255. "optgroup",
  76256. "select",
  76257. "button",
  76258. "datalist",
  76259. "textarea",
  76260. ]);
  76261. const pTag = new Set(["p"]);
  76262. const tableSectionTags = new Set(["thead", "tbody"]);
  76263. const ddtTags = new Set(["dd", "dt"]);
  76264. const rtpTags = new Set(["rt", "rp"]);
  76265. const openImpliesClose = new Map([
  76266. ["tr", new Set(["tr", "th", "td"])],
  76267. ["th", new Set(["th"])],
  76268. ["td", new Set(["thead", "th", "td"])],
  76269. ["body", new Set(["head", "link", "script"])],
  76270. ["li", new Set(["li"])],
  76271. ["p", pTag],
  76272. ["h1", pTag],
  76273. ["h2", pTag],
  76274. ["h3", pTag],
  76275. ["h4", pTag],
  76276. ["h5", pTag],
  76277. ["h6", pTag],
  76278. ["select", formTags],
  76279. ["input", formTags],
  76280. ["output", formTags],
  76281. ["button", formTags],
  76282. ["datalist", formTags],
  76283. ["textarea", formTags],
  76284. ["option", new Set(["option"])],
  76285. ["optgroup", new Set(["optgroup", "option"])],
  76286. ["dd", ddtTags],
  76287. ["dt", ddtTags],
  76288. ["address", pTag],
  76289. ["article", pTag],
  76290. ["aside", pTag],
  76291. ["blockquote", pTag],
  76292. ["details", pTag],
  76293. ["div", pTag],
  76294. ["dl", pTag],
  76295. ["fieldset", pTag],
  76296. ["figcaption", pTag],
  76297. ["figure", pTag],
  76298. ["footer", pTag],
  76299. ["form", pTag],
  76300. ["header", pTag],
  76301. ["hr", pTag],
  76302. ["main", pTag],
  76303. ["nav", pTag],
  76304. ["ol", pTag],
  76305. ["pre", pTag],
  76306. ["section", pTag],
  76307. ["table", pTag],
  76308. ["ul", pTag],
  76309. ["rt", rtpTags],
  76310. ["rp", rtpTags],
  76311. ["tbody", tableSectionTags],
  76312. ["tfoot", tableSectionTags],
  76313. ]);
  76314. const voidElements = new Set([
  76315. "area",
  76316. "base",
  76317. "basefont",
  76318. "br",
  76319. "col",
  76320. "command",
  76321. "embed",
  76322. "frame",
  76323. "hr",
  76324. "img",
  76325. "input",
  76326. "isindex",
  76327. "keygen",
  76328. "link",
  76329. "meta",
  76330. "param",
  76331. "source",
  76332. "track",
  76333. "wbr",
  76334. ]);
  76335. const foreignContextElements = new Set(["math", "svg"]);
  76336. const htmlIntegrationElements = new Set([
  76337. "mi",
  76338. "mo",
  76339. "mn",
  76340. "ms",
  76341. "mtext",
  76342. "annotation-xml",
  76343. "foreignobject",
  76344. "desc",
  76345. "title",
  76346. ]);
  76347. const reNameEnd = /\s|\//;
  76348. class Parser$1 {
  76349. constructor(cbs, options = {}) {
  76350. var _a, _b, _c, _d, _e;
  76351. this.options = options;
  76352. /** The start index of the last event. */
  76353. this.startIndex = 0;
  76354. /** The end index of the last event. */
  76355. this.endIndex = 0;
  76356. /**
  76357. * Store the start index of the current open tag,
  76358. * so we can update the start index for attributes.
  76359. */
  76360. this.openTagStart = 0;
  76361. this.tagname = "";
  76362. this.attribname = "";
  76363. this.attribvalue = "";
  76364. this.attribs = null;
  76365. this.stack = [];
  76366. this.foreignContext = [];
  76367. this.buffers = [];
  76368. this.bufferOffset = 0;
  76369. /** The index of the last written buffer. Used when resuming after a `pause()`. */
  76370. this.writeIndex = 0;
  76371. /** Indicates whether the parser has finished running / `.end` has been called. */
  76372. this.ended = false;
  76373. this.cbs = cbs !== null && cbs !== void 0 ? cbs : {};
  76374. this.lowerCaseTagNames = (_a = options.lowerCaseTags) !== null && _a !== void 0 ? _a : !options.xmlMode;
  76375. this.lowerCaseAttributeNames =
  76376. (_b = options.lowerCaseAttributeNames) !== null && _b !== void 0 ? _b : !options.xmlMode;
  76377. this.tokenizer = new ((_c = options.Tokenizer) !== null && _c !== void 0 ? _c : Tokenizer$1)(this.options, this);
  76378. (_e = (_d = this.cbs).onparserinit) === null || _e === void 0 ? void 0 : _e.call(_d, this);
  76379. }
  76380. // Tokenizer event handlers
  76381. /** @internal */
  76382. ontext(start, endIndex) {
  76383. var _a, _b;
  76384. const data = this.getSlice(start, endIndex);
  76385. this.endIndex = endIndex - 1;
  76386. (_b = (_a = this.cbs).ontext) === null || _b === void 0 ? void 0 : _b.call(_a, data);
  76387. this.startIndex = endIndex;
  76388. }
  76389. /** @internal */
  76390. ontextentity(cp) {
  76391. var _a, _b;
  76392. /*
  76393. * Entities can be emitted on the character, or directly after.
  76394. * We use the section start here to get accurate indices.
  76395. */
  76396. const idx = this.tokenizer.getSectionStart();
  76397. this.endIndex = idx - 1;
  76398. (_b = (_a = this.cbs).ontext) === null || _b === void 0 ? void 0 : _b.call(_a, decode_6(cp));
  76399. this.startIndex = idx;
  76400. }
  76401. isVoidElement(name) {
  76402. return !this.options.xmlMode && voidElements.has(name);
  76403. }
  76404. /** @internal */
  76405. onopentagname(start, endIndex) {
  76406. this.endIndex = endIndex;
  76407. let name = this.getSlice(start, endIndex);
  76408. if (this.lowerCaseTagNames) {
  76409. name = name.toLowerCase();
  76410. }
  76411. this.emitOpenTag(name);
  76412. }
  76413. emitOpenTag(name) {
  76414. var _a, _b, _c, _d;
  76415. this.openTagStart = this.startIndex;
  76416. this.tagname = name;
  76417. const impliesClose = !this.options.xmlMode && openImpliesClose.get(name);
  76418. if (impliesClose) {
  76419. while (this.stack.length > 0 &&
  76420. impliesClose.has(this.stack[this.stack.length - 1])) {
  76421. const el = this.stack.pop();
  76422. (_b = (_a = this.cbs).onclosetag) === null || _b === void 0 ? void 0 : _b.call(_a, el, true);
  76423. }
  76424. }
  76425. if (!this.isVoidElement(name)) {
  76426. this.stack.push(name);
  76427. if (foreignContextElements.has(name)) {
  76428. this.foreignContext.push(true);
  76429. }
  76430. else if (htmlIntegrationElements.has(name)) {
  76431. this.foreignContext.push(false);
  76432. }
  76433. }
  76434. (_d = (_c = this.cbs).onopentagname) === null || _d === void 0 ? void 0 : _d.call(_c, name);
  76435. if (this.cbs.onopentag)
  76436. this.attribs = {};
  76437. }
  76438. endOpenTag(isImplied) {
  76439. var _a, _b;
  76440. this.startIndex = this.openTagStart;
  76441. if (this.attribs) {
  76442. (_b = (_a = this.cbs).onopentag) === null || _b === void 0 ? void 0 : _b.call(_a, this.tagname, this.attribs, isImplied);
  76443. this.attribs = null;
  76444. }
  76445. if (this.cbs.onclosetag && this.isVoidElement(this.tagname)) {
  76446. this.cbs.onclosetag(this.tagname, true);
  76447. }
  76448. this.tagname = "";
  76449. }
  76450. /** @internal */
  76451. onopentagend(endIndex) {
  76452. this.endIndex = endIndex;
  76453. this.endOpenTag(false);
  76454. // Set `startIndex` for next node
  76455. this.startIndex = endIndex + 1;
  76456. }
  76457. /** @internal */
  76458. onclosetag(start, endIndex) {
  76459. var _a, _b, _c, _d, _e, _f;
  76460. this.endIndex = endIndex;
  76461. let name = this.getSlice(start, endIndex);
  76462. if (this.lowerCaseTagNames) {
  76463. name = name.toLowerCase();
  76464. }
  76465. if (foreignContextElements.has(name) ||
  76466. htmlIntegrationElements.has(name)) {
  76467. this.foreignContext.pop();
  76468. }
  76469. if (!this.isVoidElement(name)) {
  76470. const pos = this.stack.lastIndexOf(name);
  76471. if (pos !== -1) {
  76472. if (this.cbs.onclosetag) {
  76473. let count = this.stack.length - pos;
  76474. while (count--) {
  76475. // We know the stack has sufficient elements.
  76476. this.cbs.onclosetag(this.stack.pop(), count !== 0);
  76477. }
  76478. }
  76479. else
  76480. this.stack.length = pos;
  76481. }
  76482. else if (!this.options.xmlMode && name === "p") {
  76483. // Implicit open before close
  76484. this.emitOpenTag("p");
  76485. this.closeCurrentTag(true);
  76486. }
  76487. }
  76488. else if (!this.options.xmlMode && name === "br") {
  76489. // We can't use `emitOpenTag` for implicit open, as `br` would be implicitly closed.
  76490. (_b = (_a = this.cbs).onopentagname) === null || _b === void 0 ? void 0 : _b.call(_a, "br");
  76491. (_d = (_c = this.cbs).onopentag) === null || _d === void 0 ? void 0 : _d.call(_c, "br", {}, true);
  76492. (_f = (_e = this.cbs).onclosetag) === null || _f === void 0 ? void 0 : _f.call(_e, "br", false);
  76493. }
  76494. // Set `startIndex` for next node
  76495. this.startIndex = endIndex + 1;
  76496. }
  76497. /** @internal */
  76498. onselfclosingtag(endIndex) {
  76499. this.endIndex = endIndex;
  76500. if (this.options.xmlMode ||
  76501. this.options.recognizeSelfClosing ||
  76502. this.foreignContext[this.foreignContext.length - 1]) {
  76503. this.closeCurrentTag(false);
  76504. // Set `startIndex` for next node
  76505. this.startIndex = endIndex + 1;
  76506. }
  76507. else {
  76508. // Ignore the fact that the tag is self-closing.
  76509. this.onopentagend(endIndex);
  76510. }
  76511. }
  76512. closeCurrentTag(isOpenImplied) {
  76513. var _a, _b;
  76514. const name = this.tagname;
  76515. this.endOpenTag(isOpenImplied);
  76516. // Self-closing tags will be on the top of the stack
  76517. if (this.stack[this.stack.length - 1] === name) {
  76518. // If the opening tag isn't implied, the closing tag has to be implied.
  76519. (_b = (_a = this.cbs).onclosetag) === null || _b === void 0 ? void 0 : _b.call(_a, name, !isOpenImplied);
  76520. this.stack.pop();
  76521. }
  76522. }
  76523. /** @internal */
  76524. onattribname(start, endIndex) {
  76525. this.startIndex = start;
  76526. const name = this.getSlice(start, endIndex);
  76527. this.attribname = this.lowerCaseAttributeNames
  76528. ? name.toLowerCase()
  76529. : name;
  76530. }
  76531. /** @internal */
  76532. onattribdata(start, endIndex) {
  76533. this.attribvalue += this.getSlice(start, endIndex);
  76534. }
  76535. /** @internal */
  76536. onattribentity(cp) {
  76537. this.attribvalue += decode_6(cp);
  76538. }
  76539. /** @internal */
  76540. onattribend(quote, endIndex) {
  76541. var _a, _b;
  76542. this.endIndex = endIndex;
  76543. (_b = (_a = this.cbs).onattribute) === null || _b === void 0 ? void 0 : _b.call(_a, this.attribname, this.attribvalue, quote === QuoteType.Double
  76544. ? '"'
  76545. : quote === QuoteType.Single
  76546. ? "'"
  76547. : quote === QuoteType.NoValue
  76548. ? undefined
  76549. : null);
  76550. if (this.attribs &&
  76551. !Object.prototype.hasOwnProperty.call(this.attribs, this.attribname)) {
  76552. this.attribs[this.attribname] = this.attribvalue;
  76553. }
  76554. this.attribvalue = "";
  76555. }
  76556. getInstructionName(value) {
  76557. const idx = value.search(reNameEnd);
  76558. let name = idx < 0 ? value : value.substr(0, idx);
  76559. if (this.lowerCaseTagNames) {
  76560. name = name.toLowerCase();
  76561. }
  76562. return name;
  76563. }
  76564. /** @internal */
  76565. ondeclaration(start, endIndex) {
  76566. this.endIndex = endIndex;
  76567. const value = this.getSlice(start, endIndex);
  76568. if (this.cbs.onprocessinginstruction) {
  76569. const name = this.getInstructionName(value);
  76570. this.cbs.onprocessinginstruction(`!${name}`, `!${value}`);
  76571. }
  76572. // Set `startIndex` for next node
  76573. this.startIndex = endIndex + 1;
  76574. }
  76575. /** @internal */
  76576. onprocessinginstruction(start, endIndex) {
  76577. this.endIndex = endIndex;
  76578. const value = this.getSlice(start, endIndex);
  76579. if (this.cbs.onprocessinginstruction) {
  76580. const name = this.getInstructionName(value);
  76581. this.cbs.onprocessinginstruction(`?${name}`, `?${value}`);
  76582. }
  76583. // Set `startIndex` for next node
  76584. this.startIndex = endIndex + 1;
  76585. }
  76586. /** @internal */
  76587. oncomment(start, endIndex, offset) {
  76588. var _a, _b, _c, _d;
  76589. this.endIndex = endIndex;
  76590. (_b = (_a = this.cbs).oncomment) === null || _b === void 0 ? void 0 : _b.call(_a, this.getSlice(start, endIndex - offset));
  76591. (_d = (_c = this.cbs).oncommentend) === null || _d === void 0 ? void 0 : _d.call(_c);
  76592. // Set `startIndex` for next node
  76593. this.startIndex = endIndex + 1;
  76594. }
  76595. /** @internal */
  76596. oncdata(start, endIndex, offset) {
  76597. var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
  76598. this.endIndex = endIndex;
  76599. const value = this.getSlice(start, endIndex - offset);
  76600. if (this.options.xmlMode || this.options.recognizeCDATA) {
  76601. (_b = (_a = this.cbs).oncdatastart) === null || _b === void 0 ? void 0 : _b.call(_a);
  76602. (_d = (_c = this.cbs).ontext) === null || _d === void 0 ? void 0 : _d.call(_c, value);
  76603. (_f = (_e = this.cbs).oncdataend) === null || _f === void 0 ? void 0 : _f.call(_e);
  76604. }
  76605. else {
  76606. (_h = (_g = this.cbs).oncomment) === null || _h === void 0 ? void 0 : _h.call(_g, `[CDATA[${value}]]`);
  76607. (_k = (_j = this.cbs).oncommentend) === null || _k === void 0 ? void 0 : _k.call(_j);
  76608. }
  76609. // Set `startIndex` for next node
  76610. this.startIndex = endIndex + 1;
  76611. }
  76612. /** @internal */
  76613. onend() {
  76614. var _a, _b;
  76615. if (this.cbs.onclosetag) {
  76616. // Set the end index for all remaining tags
  76617. this.endIndex = this.startIndex;
  76618. for (let i = this.stack.length; i > 0; this.cbs.onclosetag(this.stack[--i], true))
  76619. ;
  76620. }
  76621. (_b = (_a = this.cbs).onend) === null || _b === void 0 ? void 0 : _b.call(_a);
  76622. }
  76623. /**
  76624. * Resets the parser to a blank state, ready to parse a new HTML document
  76625. */
  76626. reset() {
  76627. var _a, _b, _c, _d;
  76628. (_b = (_a = this.cbs).onreset) === null || _b === void 0 ? void 0 : _b.call(_a);
  76629. this.tokenizer.reset();
  76630. this.tagname = "";
  76631. this.attribname = "";
  76632. this.attribs = null;
  76633. this.stack.length = 0;
  76634. this.startIndex = 0;
  76635. this.endIndex = 0;
  76636. (_d = (_c = this.cbs).onparserinit) === null || _d === void 0 ? void 0 : _d.call(_c, this);
  76637. this.buffers.length = 0;
  76638. this.bufferOffset = 0;
  76639. this.writeIndex = 0;
  76640. this.ended = false;
  76641. }
  76642. /**
  76643. * Resets the parser, then parses a complete document and
  76644. * pushes it to the handler.
  76645. *
  76646. * @param data Document to parse.
  76647. */
  76648. parseComplete(data) {
  76649. this.reset();
  76650. this.end(data);
  76651. }
  76652. getSlice(start, end) {
  76653. while (start - this.bufferOffset >= this.buffers[0].length) {
  76654. this.shiftBuffer();
  76655. }
  76656. let str = this.buffers[0].slice(start - this.bufferOffset, end - this.bufferOffset);
  76657. while (end - this.bufferOffset > this.buffers[0].length) {
  76658. this.shiftBuffer();
  76659. str += this.buffers[0].slice(0, end - this.bufferOffset);
  76660. }
  76661. return str;
  76662. }
  76663. shiftBuffer() {
  76664. this.bufferOffset += this.buffers[0].length;
  76665. this.writeIndex--;
  76666. this.buffers.shift();
  76667. }
  76668. /**
  76669. * Parses a chunk of data and calls the corresponding callbacks.
  76670. *
  76671. * @param chunk Chunk to parse.
  76672. */
  76673. write(chunk) {
  76674. var _a, _b;
  76675. if (this.ended) {
  76676. (_b = (_a = this.cbs).onerror) === null || _b === void 0 ? void 0 : _b.call(_a, new Error(".write() after done!"));
  76677. return;
  76678. }
  76679. this.buffers.push(chunk);
  76680. if (this.tokenizer.running) {
  76681. this.tokenizer.write(chunk);
  76682. this.writeIndex++;
  76683. }
  76684. }
  76685. /**
  76686. * Parses the end of the buffer and clears the stack, calls onend.
  76687. *
  76688. * @param chunk Optional final chunk to parse.
  76689. */
  76690. end(chunk) {
  76691. var _a, _b;
  76692. if (this.ended) {
  76693. (_b = (_a = this.cbs).onerror) === null || _b === void 0 ? void 0 : _b.call(_a, Error(".end() after done!"));
  76694. return;
  76695. }
  76696. if (chunk)
  76697. this.write(chunk);
  76698. this.ended = true;
  76699. this.tokenizer.end();
  76700. }
  76701. /**
  76702. * Pauses parsing. The parser won't emit events until `resume` is called.
  76703. */
  76704. pause() {
  76705. this.tokenizer.pause();
  76706. }
  76707. /**
  76708. * Resumes parsing after `pause` was called.
  76709. */
  76710. resume() {
  76711. this.tokenizer.resume();
  76712. while (this.tokenizer.running &&
  76713. this.writeIndex < this.buffers.length) {
  76714. this.tokenizer.write(this.buffers[this.writeIndex++]);
  76715. }
  76716. if (this.ended)
  76717. this.tokenizer.end();
  76718. }
  76719. /**
  76720. * Alias of `write`, for backwards compatibility.
  76721. *
  76722. * @param chunk Chunk to parse.
  76723. * @deprecated
  76724. */
  76725. parseChunk(chunk) {
  76726. this.write(chunk);
  76727. }
  76728. /**
  76729. * Alias of `end`, for backwards compatibility.
  76730. *
  76731. * @param chunk Optional final chunk to parse.
  76732. * @deprecated
  76733. */
  76734. done(chunk) {
  76735. this.end(chunk);
  76736. }
  76737. }
  76738. // Helper methods
  76739. /**
  76740. * Parses the data, returns the resulting document.
  76741. *
  76742. * @param data The data that should be parsed.
  76743. * @param options Optional options for the parser and DOM builder.
  76744. */
  76745. function parseDocument(data, options) {
  76746. const handler = new DomHandler(undefined, options);
  76747. new Parser$1(handler, options).end(data);
  76748. return handler.root;
  76749. }
  76750. /**
  76751. * Types used in signatures of Cheerio methods.
  76752. *
  76753. * @category Cheerio
  76754. */
  76755. const parse$4 = getParse((content, options, isDocument, context) => options.xmlMode || options._useHtmlParser2
  76756. ? parseDocument(content, options)
  76757. : parseWithParse5(content, options, isDocument, context));
  76758. // Duplicate docs due to https://github.com/TypeStrong/typedoc/issues/1616
  76759. /**
  76760. * Create a querying function, bound to a document created from the provided markup.
  76761. *
  76762. * Note that similar to web browser contexts, this operation may introduce
  76763. * `<html>`, `<head>`, and `<body>` elements; set `isDocument` to `false` to
  76764. * switch to fragment mode and disable this.
  76765. *
  76766. * @param content - Markup to be loaded.
  76767. * @param options - Options for the created instance.
  76768. * @param isDocument - Allows parser to be switched to fragment mode.
  76769. * @returns The loaded document.
  76770. * @see {@link https://cheerio.js.org#loading} for additional usage information.
  76771. */
  76772. const load = getLoad(parse$4, (dom, options) => options.xmlMode || options._useHtmlParser2
  76773. ? render(dom, options)
  76774. : renderWithParse5(dom));
  76775. /**
  76776. * The default cheerio instance.
  76777. *
  76778. * @deprecated Use the function returned by `load` instead.
  76779. */
  76780. var cheerio = load([]);
  76781. var debug_1 = createCommonjsModule(function (module, exports) {
  76782. exports = module.exports = debug;
  76783. function debug(label) {
  76784. return _debug.bind(null, label);
  76785. }
  76786. function _debug(label) {
  76787. var args = [].slice.call(arguments, 1);
  76788. args.unshift('[' + label + ']');
  76789. process.stderr.write(args.join(' ') + '\n');
  76790. }
  76791. });
  76792. var lexer = createCommonjsModule(function (module, exports) {
  76793. var debug = debug_1('lex');
  76794. exports = module.exports = lex;
  76795. /**
  76796. * Convert a CSS string into an array of lexical tokens.
  76797. *
  76798. * @param {String} css CSS
  76799. * @returns {Array} lexical tokens
  76800. */
  76801. function lex(css) {
  76802. var buffer = ''; // Character accumulator
  76803. var ch; // Current character
  76804. var column = 0; // Current source column number
  76805. var cursor = -1; // Current source cursor position
  76806. var depth = 0; // Current nesting depth
  76807. var line = 1; // Current source line number
  76808. var state = 'before-selector'; // Current state
  76809. var stack = [state]; // State stack
  76810. var token = {}; // Current token
  76811. var tokens = []; // Token accumulator
  76812. // Supported @-rules, in roughly descending order of usage probability.
  76813. var atRules = [
  76814. 'media',
  76815. 'keyframes',
  76816. { name: '-webkit-keyframes', type: 'keyframes', prefix: '-webkit-' },
  76817. { name: '-moz-keyframes', type: 'keyframes', prefix: '-moz-' },
  76818. { name: '-ms-keyframes', type: 'keyframes', prefix: '-ms-' },
  76819. { name: '-o-keyframes', type: 'keyframes', prefix: '-o-' },
  76820. 'font-face',
  76821. { name: 'import', state: 'before-at-value' },
  76822. { name: 'charset', state: 'before-at-value' },
  76823. 'supports',
  76824. 'viewport',
  76825. { name: 'namespace', state: 'before-at-value' },
  76826. 'document',
  76827. { name: '-moz-document', type: 'document', prefix: '-moz-' },
  76828. 'page'
  76829. ];
  76830. // -- Functions ------------------------------------------------------------
  76831. /**
  76832. * Advance the character cursor and return the next character.
  76833. *
  76834. * @returns {String} The next character.
  76835. */
  76836. function getCh() {
  76837. skip();
  76838. return css[cursor];
  76839. }
  76840. /**
  76841. * Return the state at the given index in the stack.
  76842. * The stack is LIFO so indexing is from the right.
  76843. *
  76844. * @param {Number} [index=0] Index to return.
  76845. * @returns {String} state
  76846. */
  76847. function getState(index) {
  76848. return index ? stack[stack.length - 1 - index] : state;
  76849. }
  76850. /**
  76851. * Look ahead for a string beginning from the next position. The string
  76852. * being looked for must start at the next position.
  76853. *
  76854. * @param {String} str The string to look for.
  76855. * @returns {Boolean} Whether the string was found.
  76856. */
  76857. function isNextString(str) {
  76858. var start = cursor + 1;
  76859. return (str === css.slice(start, start + str.length));
  76860. }
  76861. /**
  76862. * Find the start position of a substring beginning from the next
  76863. * position. The string being looked for may begin anywhere.
  76864. *
  76865. * @param {String} str The substring to look for.
  76866. * @returns {Number|false} The position, or `false` if not found.
  76867. */
  76868. function find(str) {
  76869. var pos = css.slice(cursor).indexOf(str);
  76870. return pos > 0 ? pos : false;
  76871. }
  76872. /**
  76873. * Determine whether a character is next.
  76874. *
  76875. * @param {String} ch Character.
  76876. * @returns {Boolean} Whether the character is next.
  76877. */
  76878. function isNextChar(ch) {
  76879. return ch === peek(1);
  76880. }
  76881. /**
  76882. * Return the character at the given cursor offset. The offset is relative
  76883. * to the cursor, so negative values move backwards.
  76884. *
  76885. * @param {Number} [offset=1] Cursor offset.
  76886. * @returns {String} Character.
  76887. */
  76888. function peek(offset) {
  76889. return css[cursor + (offset || 1)];
  76890. }
  76891. /**
  76892. * Remove the current state from the stack and set the new current state.
  76893. *
  76894. * @returns {String} The removed state.
  76895. */
  76896. function popState() {
  76897. var removed = stack.pop();
  76898. state = stack[stack.length - 1];
  76899. return removed;
  76900. }
  76901. /**
  76902. * Set the current state and add it to the stack.
  76903. *
  76904. * @param {String} newState The new state.
  76905. * @returns {Number} The new stack length.
  76906. */
  76907. function pushState(newState) {
  76908. state = newState;
  76909. stack.push(state);
  76910. return stack.length;
  76911. }
  76912. /**
  76913. * Replace the current state with a new state.
  76914. *
  76915. * @param {String} newState The new state.
  76916. * @returns {String} The replaced state.
  76917. */
  76918. function replaceState(newState) {
  76919. var previousState = state;
  76920. stack[stack.length - 1] = state = newState;
  76921. return previousState;
  76922. }
  76923. /**
  76924. * Move the character cursor. Positive numbers move the cursor forward.
  76925. * Negative numbers are not supported!
  76926. *
  76927. * @param {Number} [n=1] Number of characters to skip.
  76928. */
  76929. function skip(n) {
  76930. if ((n || 1) == 1) {
  76931. if (css[cursor] == '\n') {
  76932. line++;
  76933. column = 1;
  76934. } else {
  76935. column++;
  76936. }
  76937. cursor++;
  76938. } else {
  76939. var skipStr = css.slice(cursor, cursor + n).split('\n');
  76940. if (skipStr.length > 1) {
  76941. line += skipStr.length - 1;
  76942. column = 1;
  76943. }
  76944. column += skipStr[skipStr.length - 1].length;
  76945. cursor = cursor + n;
  76946. }
  76947. }
  76948. /**
  76949. * Add the current token to the pile and reset the buffer.
  76950. */
  76951. function addToken() {
  76952. token.end = {
  76953. line: line,
  76954. col: column
  76955. };
  76956. tokens.push(token);
  76957. buffer = '';
  76958. token = {};
  76959. }
  76960. /**
  76961. * Set the current token.
  76962. *
  76963. * @param {String} type Token type.
  76964. */
  76965. function initializeToken(type) {
  76966. token = {
  76967. type: type,
  76968. start: {
  76969. line: line,
  76970. col : column
  76971. }
  76972. };
  76973. }
  76974. while (ch = getCh()) {
  76975. // column += 1;
  76976. switch (ch) {
  76977. // Space
  76978. case ' ':
  76979. switch (getState()) {
  76980. case 'selector':
  76981. case 'value':
  76982. case 'value-paren':
  76983. case 'at-group':
  76984. case 'at-value':
  76985. case 'comment':
  76986. case 'double-string':
  76987. case 'single-string':
  76988. buffer += ch;
  76989. break;
  76990. }
  76991. break;
  76992. // Newline or tab
  76993. case '\n':
  76994. case '\t':
  76995. case '\r':
  76996. case '\f':
  76997. switch (getState()) {
  76998. case 'value':
  76999. case 'value-paren':
  77000. case 'at-group':
  77001. case 'comment':
  77002. case 'single-string':
  77003. case 'double-string':
  77004. case 'selector':
  77005. buffer += ch;
  77006. break;
  77007. case 'at-value':
  77008. // Tokenize an @-rule if a semi-colon was omitted.
  77009. if ('\n' === ch) {
  77010. token.value = buffer.trim();
  77011. addToken();
  77012. popState();
  77013. }
  77014. break;
  77015. }
  77016. // if ('\n' === ch) {
  77017. // column = 0;
  77018. // line += 1;
  77019. // }
  77020. break;
  77021. case ':':
  77022. switch (getState()) {
  77023. case 'name':
  77024. token.name = buffer.trim();
  77025. buffer = '';
  77026. replaceState('before-value');
  77027. break;
  77028. case 'before-selector':
  77029. buffer += ch;
  77030. initializeToken('selector');
  77031. pushState('selector');
  77032. break;
  77033. case 'before-value':
  77034. replaceState('value');
  77035. buffer += ch;
  77036. break;
  77037. default:
  77038. buffer += ch;
  77039. break;
  77040. }
  77041. break;
  77042. case ';':
  77043. switch (getState()) {
  77044. case 'name':
  77045. case 'before-value':
  77046. case 'value':
  77047. // Tokenize a declaration
  77048. // if value is empty skip the declaration
  77049. if (buffer.trim().length > 0) {
  77050. token.value = buffer.trim(),
  77051. addToken();
  77052. }
  77053. replaceState('before-name');
  77054. break;
  77055. case 'value-paren':
  77056. // Insignificant semi-colon
  77057. buffer += ch;
  77058. break;
  77059. case 'at-value':
  77060. // Tokenize an @-rule
  77061. token.value = buffer.trim();
  77062. addToken();
  77063. popState();
  77064. break;
  77065. case 'before-name':
  77066. // Extraneous semi-colon
  77067. break;
  77068. default:
  77069. buffer += ch;
  77070. break;
  77071. }
  77072. break;
  77073. case '{':
  77074. switch (getState()) {
  77075. case 'selector':
  77076. // If the sequence is `\{` then assume that the brace should be escaped.
  77077. if (peek(-1) === '\\') {
  77078. buffer += ch;
  77079. break;
  77080. }
  77081. // Tokenize a selector
  77082. token.text = buffer.trim();
  77083. addToken();
  77084. replaceState('before-name');
  77085. depth = depth + 1;
  77086. break;
  77087. case 'at-group':
  77088. // Tokenize an @-group
  77089. token.name = buffer.trim();
  77090. // XXX: @-rules are starting to get hairy
  77091. switch (token.type) {
  77092. case 'font-face':
  77093. case 'viewport' :
  77094. case 'page' :
  77095. pushState('before-name');
  77096. break;
  77097. default:
  77098. pushState('before-selector');
  77099. }
  77100. addToken();
  77101. depth = depth + 1;
  77102. break;
  77103. case 'name':
  77104. case 'at-rule':
  77105. // Tokenize a declaration or an @-rule
  77106. token.name = buffer.trim();
  77107. addToken();
  77108. pushState('before-name');
  77109. depth = depth + 1;
  77110. break;
  77111. case 'comment':
  77112. case 'double-string':
  77113. case 'single-string':
  77114. // Ignore braces in comments and strings
  77115. buffer += ch;
  77116. break;
  77117. case 'before-value':
  77118. replaceState('value');
  77119. buffer += ch;
  77120. break;
  77121. }
  77122. break;
  77123. case '}':
  77124. switch (getState()) {
  77125. case 'before-name':
  77126. case 'name':
  77127. case 'before-value':
  77128. case 'value':
  77129. // If the buffer contains anything, it is a value
  77130. if (buffer) {
  77131. token.value = buffer.trim();
  77132. }
  77133. // If the current token has a name and a value it should be tokenized.
  77134. if (token.name && token.value) {
  77135. addToken();
  77136. }
  77137. // Leave the block
  77138. initializeToken('end');
  77139. addToken();
  77140. popState();
  77141. // We might need to leave again.
  77142. // XXX: What about 3 levels deep?
  77143. if ('at-group' === getState()) {
  77144. initializeToken('at-group-end');
  77145. addToken();
  77146. popState();
  77147. }
  77148. if (depth > 0) {
  77149. depth = depth - 1;
  77150. }
  77151. break;
  77152. case 'at-group':
  77153. case 'before-selector':
  77154. case 'selector':
  77155. // If the sequence is `\}` then assume that the brace should be escaped.
  77156. if (peek(-1) === '\\') {
  77157. buffer += ch;
  77158. break;
  77159. }
  77160. if (depth > 0) {
  77161. // Leave block if in an at-group
  77162. if ('at-group' === getState(1)) {
  77163. initializeToken('at-group-end');
  77164. addToken();
  77165. }
  77166. }
  77167. if (depth > 1) {
  77168. popState();
  77169. }
  77170. if (depth > 0) {
  77171. depth = depth - 1;
  77172. }
  77173. break;
  77174. case 'double-string':
  77175. case 'single-string':
  77176. case 'comment':
  77177. // Ignore braces in comments and strings.
  77178. buffer += ch;
  77179. break;
  77180. }
  77181. break;
  77182. // Strings
  77183. case '"':
  77184. case "'":
  77185. switch (getState()) {
  77186. case 'double-string':
  77187. if ('"' === ch && '\\' !== peek(-1)) {
  77188. popState();
  77189. }
  77190. break;
  77191. case 'single-string':
  77192. if ("'" === ch && '\\' !== peek(-1)) {
  77193. popState();
  77194. }
  77195. break;
  77196. case 'before-at-value':
  77197. replaceState('at-value');
  77198. pushState('"' === ch ? 'double-string' : 'single-string');
  77199. break;
  77200. case 'before-value':
  77201. replaceState('value');
  77202. pushState('"' === ch ? 'double-string' : 'single-string');
  77203. break;
  77204. case 'comment':
  77205. // Ignore strings within comments.
  77206. break;
  77207. default:
  77208. if ('\\' !== peek(-1)) {
  77209. pushState('"' === ch ? 'double-string' : 'single-string');
  77210. }
  77211. }
  77212. buffer += ch;
  77213. break;
  77214. // Comments
  77215. case '/':
  77216. switch (getState()) {
  77217. case 'comment':
  77218. case 'double-string':
  77219. case 'single-string':
  77220. // Ignore
  77221. buffer += ch;
  77222. break;
  77223. case 'before-value':
  77224. case 'selector':
  77225. case 'name':
  77226. case 'value':
  77227. if (isNextChar('*')) {
  77228. // Ignore comments in selectors, properties and values. They are
  77229. // difficult to represent in the AST.
  77230. var pos = find('*/');
  77231. if (pos) {
  77232. skip(pos + 1);
  77233. }
  77234. } else {
  77235. if (getState() == 'before-value') replaceState('value');
  77236. buffer += ch;
  77237. }
  77238. break;
  77239. default:
  77240. if (isNextChar('*')) {
  77241. // Create a comment token
  77242. initializeToken('comment');
  77243. pushState('comment');
  77244. skip();
  77245. }
  77246. else {
  77247. buffer += ch;
  77248. }
  77249. break;
  77250. }
  77251. break;
  77252. // Comment end or universal selector
  77253. case '*':
  77254. switch (getState()) {
  77255. case 'comment':
  77256. if (isNextChar('/')) {
  77257. // Tokenize a comment
  77258. token.text = buffer; // Don't trim()!
  77259. skip();
  77260. addToken();
  77261. popState();
  77262. }
  77263. else {
  77264. buffer += ch;
  77265. }
  77266. break;
  77267. case 'before-selector':
  77268. buffer += ch;
  77269. initializeToken('selector');
  77270. pushState('selector');
  77271. break;
  77272. case 'before-value':
  77273. replaceState('value');
  77274. buffer += ch;
  77275. break;
  77276. default:
  77277. buffer += ch;
  77278. }
  77279. break;
  77280. // @-rules
  77281. case '@':
  77282. switch (getState()) {
  77283. case 'comment':
  77284. case 'double-string':
  77285. case 'single-string':
  77286. buffer += ch;
  77287. break;
  77288. case 'before-value':
  77289. replaceState('value');
  77290. buffer += ch;
  77291. break;
  77292. default:
  77293. // Iterate over the supported @-rules and attempt to tokenize one.
  77294. var tokenized = false;
  77295. var name;
  77296. var rule;
  77297. for (var j = 0, len = atRules.length; !tokenized && j < len; ++j) {
  77298. rule = atRules[j];
  77299. name = rule.name || rule;
  77300. if (!isNextString(name)) { continue; }
  77301. tokenized = true;
  77302. initializeToken(name);
  77303. pushState(rule.state || 'at-group');
  77304. skip(name.length);
  77305. if (rule.prefix) {
  77306. token.prefix = rule.prefix;
  77307. }
  77308. if (rule.type) {
  77309. token.type = rule.type;
  77310. }
  77311. }
  77312. if (!tokenized) {
  77313. // Keep on truckin' America!
  77314. buffer += ch;
  77315. }
  77316. break;
  77317. }
  77318. break;
  77319. // Parentheses are tracked to disambiguate semi-colons, such as within a
  77320. // data URI.
  77321. case '(':
  77322. switch (getState()) {
  77323. case 'value':
  77324. pushState('value-paren');
  77325. break;
  77326. case 'before-value':
  77327. replaceState('value');
  77328. break;
  77329. }
  77330. buffer += ch;
  77331. break;
  77332. case ')':
  77333. switch (getState()) {
  77334. case 'value-paren':
  77335. popState();
  77336. break;
  77337. case 'before-value':
  77338. replaceState('value');
  77339. break;
  77340. }
  77341. buffer += ch;
  77342. break;
  77343. default:
  77344. switch (getState()) {
  77345. case 'before-selector':
  77346. initializeToken('selector');
  77347. pushState('selector');
  77348. break;
  77349. case 'before-name':
  77350. initializeToken('property');
  77351. replaceState('name');
  77352. break;
  77353. case 'before-value':
  77354. replaceState('value');
  77355. break;
  77356. case 'before-at-value':
  77357. replaceState('at-value');
  77358. break;
  77359. }
  77360. buffer += ch;
  77361. break;
  77362. }
  77363. }
  77364. return tokens;
  77365. }
  77366. });
  77367. var parser = createCommonjsModule(function (module, exports) {
  77368. var debug = debug_1('parse');
  77369. exports = module.exports = parse;
  77370. var _comments; // Whether comments are allowed.
  77371. var _depth; // Current block nesting depth.
  77372. var _position; // Whether to include line/column position.
  77373. var _tokens; // Array of lexical tokens.
  77374. /**
  77375. * Convert a CSS string or array of lexical tokens into a `stringify`-able AST.
  77376. *
  77377. * @param {String} css CSS string or array of lexical token
  77378. * @param {Object} [options]
  77379. * @param {Boolean} [options.comments=false] allow comment nodes in the AST
  77380. * @returns {Object} `stringify`-able AST
  77381. */
  77382. function parse(css, options) {
  77383. options || (options = {});
  77384. _comments = !!options.comments;
  77385. _position = !!options.position;
  77386. _depth = 0;
  77387. // Operate on a copy of the given tokens, or the lex()'d CSS string.
  77388. _tokens = Array.isArray(css) ? css.slice() : lexer(css);
  77389. var rule;
  77390. var rules = [];
  77391. var token;
  77392. while ((token = next())) {
  77393. rule = parseToken(token);
  77394. rule && rules.push(rule);
  77395. }
  77396. return {
  77397. type: "stylesheet",
  77398. stylesheet: {
  77399. rules: rules
  77400. }
  77401. };
  77402. }
  77403. // -- Functions --------------------------------------------------------------
  77404. /**
  77405. * Build an AST node from a lexical token.
  77406. *
  77407. * @param {Object} token lexical token
  77408. * @param {Object} [override] object hash of properties that override those
  77409. * already in the token, or that will be added to the token.
  77410. * @returns {Object} AST node
  77411. */
  77412. function astNode(token, override) {
  77413. override || (override = {});
  77414. var key;
  77415. var keys = ['type', 'name', 'value'];
  77416. var node = {};
  77417. // Avoiding [].forEach for performance reasons.
  77418. for (var i = 0; i < keys.length; ++i) {
  77419. key = keys[i];
  77420. if (token[key]) {
  77421. node[key] = override[key] || token[key];
  77422. }
  77423. }
  77424. keys = Object.keys(override);
  77425. for (i = 0; i < keys.length; ++i) {
  77426. key = keys[i];
  77427. if (!node[key]) {
  77428. node[key] = override[key];
  77429. }
  77430. }
  77431. if (_position) {
  77432. node.position = {
  77433. start: token.start,
  77434. end: token.end
  77435. };
  77436. }
  77437. return node;
  77438. }
  77439. /**
  77440. * Remove a lexical token from the stack and return the removed token.
  77441. *
  77442. * @returns {Object} lexical token
  77443. */
  77444. function next() {
  77445. var token = _tokens.shift();
  77446. return token;
  77447. }
  77448. // -- Parse* Functions ---------------------------------------------------------
  77449. /**
  77450. * Convert an @-group lexical token to an AST node.
  77451. *
  77452. * @param {Object} token @-group lexical token
  77453. * @returns {Object} @-group AST node
  77454. */
  77455. function parseAtGroup(token) {
  77456. _depth = _depth + 1;
  77457. // As the @-group token is assembled, relevant token values are captured here
  77458. // temporarily. They will later be used as `tokenize()` overrides.
  77459. var overrides = {};
  77460. switch (token.type) {
  77461. case 'font-face':
  77462. case 'viewport' :
  77463. overrides.declarations = parseDeclarations();
  77464. break;
  77465. case 'page':
  77466. overrides.prefix = token.prefix;
  77467. overrides.declarations = parseDeclarations();
  77468. break;
  77469. default:
  77470. overrides.prefix = token.prefix;
  77471. overrides.rules = parseRules();
  77472. }
  77473. return astNode(token, overrides);
  77474. }
  77475. /**
  77476. * Convert an @import lexical token to an AST node.
  77477. *
  77478. * @param {Object} token @import lexical token
  77479. * @returns {Object} @import AST node
  77480. */
  77481. function parseAtImport(token) {
  77482. return astNode(token);
  77483. }
  77484. /**
  77485. * Convert an @charset token to an AST node.
  77486. *
  77487. * @param {Object} token @charset lexical token
  77488. * @returns {Object} @charset node
  77489. */
  77490. function parseCharset(token) {
  77491. return astNode(token);
  77492. }
  77493. /**
  77494. * Convert a comment token to an AST Node.
  77495. *
  77496. * @param {Object} token comment lexical token
  77497. * @returns {Object} comment node
  77498. */
  77499. function parseComment(token) {
  77500. return astNode(token, {text: token.text});
  77501. }
  77502. function parseNamespace(token) {
  77503. return astNode(token);
  77504. }
  77505. /**
  77506. * Convert a property lexical token to a property AST node.
  77507. *
  77508. * @returns {Object} property node
  77509. */
  77510. function parseProperty(token) {
  77511. return astNode(token);
  77512. }
  77513. /**
  77514. * Convert a selector lexical token to a selector AST node.
  77515. *
  77516. * @param {Object} token selector lexical token
  77517. * @returns {Object} selector node
  77518. */
  77519. function parseSelector(token) {
  77520. function trim(str) {
  77521. return str.trim();
  77522. }
  77523. return astNode(token, {
  77524. type: 'rule',
  77525. selectors: token.text.split(',').map(trim),
  77526. declarations: parseDeclarations()
  77527. });
  77528. }
  77529. /**
  77530. * Convert a lexical token to an AST node.
  77531. *
  77532. * @returns {Object|undefined} AST node
  77533. */
  77534. function parseToken(token) {
  77535. switch (token.type) {
  77536. // Cases are listed in roughly descending order of probability.
  77537. case 'property': return parseProperty(token);
  77538. case 'selector': return parseSelector(token);
  77539. case 'at-group-end': _depth = _depth - 1; return;
  77540. case 'media' :
  77541. case 'keyframes' :return parseAtGroup(token);
  77542. case 'comment': if (_comments) { return parseComment(token); } break;
  77543. case 'charset': return parseCharset(token);
  77544. case 'import': return parseAtImport(token);
  77545. case 'namespace': return parseNamespace(token);
  77546. case 'font-face':
  77547. case 'supports' :
  77548. case 'viewport' :
  77549. case 'document' :
  77550. case 'page' : return parseAtGroup(token);
  77551. }
  77552. }
  77553. // -- Parse Helper Functions ---------------------------------------------------
  77554. /**
  77555. * Iteratively parses lexical tokens from the stack into AST nodes until a
  77556. * conditional function returns `false`, at which point iteration terminates
  77557. * and any AST nodes collected are returned.
  77558. *
  77559. * @param {Function} conditionFn
  77560. * @param {Object} token the lexical token being parsed
  77561. * @returns {Boolean} `true` if the token should be parsed, `false` otherwise
  77562. * @return {Array} AST nodes
  77563. */
  77564. function parseTokensWhile(conditionFn) {
  77565. var node;
  77566. var nodes = [];
  77567. var token;
  77568. while ((token = next()) && (conditionFn && conditionFn(token))) {
  77569. node = parseToken(token);
  77570. node && nodes.push(node);
  77571. }
  77572. // Place an unused non-`end` lexical token back onto the stack.
  77573. if (token && token.type !== 'end') {
  77574. _tokens.unshift(token);
  77575. }
  77576. return nodes;
  77577. }
  77578. /**
  77579. * Convert a series of tokens into a sequence of declaration AST nodes.
  77580. *
  77581. * @returns {Array} declaration nodes
  77582. */
  77583. function parseDeclarations() {
  77584. return parseTokensWhile(function (token) {
  77585. return (token.type === 'property' || token.type === 'comment');
  77586. });
  77587. }
  77588. /**
  77589. * Convert a series of tokens into a sequence of rule nodes.
  77590. *
  77591. * @returns {Array} rule nodes
  77592. */
  77593. function parseRules() {
  77594. return parseTokensWhile(function () { return _depth; });
  77595. }
  77596. });
  77597. var stringify_1 = createCommonjsModule(function (module, exports) {
  77598. var debug = debug_1('stringify');
  77599. var _comments; // Whether comments are allowed in the stringified CSS.
  77600. var _compress; // Whether the stringified CSS should be compressed.
  77601. var _indentation; // Indentation option value.
  77602. var _level; // Current indentation level.
  77603. var _n; // Compression-aware newline character.
  77604. var _s; // Compression-aware space character.
  77605. exports = module.exports = stringify;
  77606. /**
  77607. * Convert a `stringify`-able AST into a CSS string.
  77608. *
  77609. * @param {Object} `stringify`-able AST
  77610. * @param {Object} [options]
  77611. * @param {Boolean} [options.comments=false] allow comments in the CSS
  77612. * @param {Boolean} [options.compress=false] compress whitespace
  77613. * @param {String} [options.indentation=''] indentation sequence
  77614. * @returns {String} CSS
  77615. */
  77616. function stringify(ast, options) {
  77617. options || (options = {});
  77618. _indentation = options.indentation || '';
  77619. _compress = !!options.compress;
  77620. _comments = !!options.comments;
  77621. _level = 1;
  77622. if (_compress) {
  77623. _n = _s = '';
  77624. } else {
  77625. _n = '\n';
  77626. _s = ' ';
  77627. }
  77628. var css = reduce(ast.stylesheet.rules, stringifyNode).join('\n').trim();
  77629. return css;
  77630. }
  77631. // -- Functions --------------------------------------------------------------
  77632. /**
  77633. * Modify the indentation level, or return a compression-aware sequence of
  77634. * spaces equal to the current indentation level.
  77635. *
  77636. * @param {Number} [level=undefined] indentation level modifier
  77637. * @returns {String} sequence of spaces
  77638. */
  77639. function indent(level) {
  77640. if (level) {
  77641. _level += level;
  77642. return;
  77643. }
  77644. if (_compress) { return ''; }
  77645. return Array(_level).join(_indentation || '');
  77646. }
  77647. // -- Stringify Functions ------------------------------------------------------
  77648. /**
  77649. * Stringify an @-rule AST node.
  77650. *
  77651. * Use `stringifyAtGroup()` when dealing with @-groups that may contain blocks
  77652. * such as @media.
  77653. *
  77654. * @param {String} type @-rule type. E.g., import, charset
  77655. * @returns {String} Stringified @-rule
  77656. */
  77657. function stringifyAtRule(node) {
  77658. return '@' + node.type + ' ' + node.value + ';' + _n;
  77659. }
  77660. /**
  77661. * Stringify an @-group AST node.
  77662. *
  77663. * Use `stringifyAtRule()` when dealing with @-rules that may not contain blocks
  77664. * such as @import.
  77665. *
  77666. * @param {Object} node @-group AST node
  77667. * @returns {String}
  77668. */
  77669. function stringifyAtGroup(node) {
  77670. var label = '';
  77671. var prefix = node.prefix || '';
  77672. if (node.name) {
  77673. label = ' ' + node.name;
  77674. }
  77675. // FIXME: @-rule conditional logic is leaking everywhere.
  77676. var chomp = node.type !== 'page';
  77677. return '@' + prefix + node.type + label + _s + stringifyBlock(node, chomp) + _n;
  77678. }
  77679. /**
  77680. * Stringify a comment AST node.
  77681. *
  77682. * @param {Object} node comment AST node
  77683. * @returns {String}
  77684. */
  77685. function stringifyComment(node) {
  77686. if (!_comments) { return ''; }
  77687. return '/*' + (node.text || '') + '*/' + _n;
  77688. }
  77689. /**
  77690. * Stringify a rule AST node.
  77691. *
  77692. * @param {Object} node rule AST node
  77693. * @returns {String}
  77694. */
  77695. function stringifyRule(node) {
  77696. var label;
  77697. if (node.selectors) {
  77698. label = node.selectors.join(',' + _n);
  77699. } else {
  77700. label = '@' + node.type;
  77701. label += node.name ? ' ' + node.name : '';
  77702. }
  77703. return indent() + label + _s + stringifyBlock(node) + _n;
  77704. }
  77705. // -- Stringify Helper Functions -----------------------------------------------
  77706. /**
  77707. * Reduce an array by applying a function to each item and retaining the truthy
  77708. * results.
  77709. *
  77710. * When `item.type` is `'comment'` `stringifyComment` will be applied instead.
  77711. *
  77712. * @param {Array} items array to reduce
  77713. * @param {Function} fn function to call for each item in the array
  77714. * @returns {Mixed} Truthy values will be retained, falsy values omitted
  77715. * @returns {Array} retained results
  77716. */
  77717. function reduce(items, fn) {
  77718. return items.reduce(function (results, item) {
  77719. var result = (item.type === 'comment') ? stringifyComment(item) : fn(item);
  77720. result && results.push(result);
  77721. return results;
  77722. }, []);
  77723. }
  77724. /**
  77725. * Stringify an AST node with the assumption that it represents a block of
  77726. * declarations or other @-group contents.
  77727. *
  77728. * @param {Object} node AST node
  77729. * @returns {String}
  77730. */
  77731. // FIXME: chomp should not be a magic boolean parameter
  77732. function stringifyBlock(node, chomp) {
  77733. var children = node.declarations;
  77734. var fn = stringifyDeclaration;
  77735. if (node.rules) {
  77736. children = node.rules;
  77737. fn = stringifyRule;
  77738. }
  77739. children = stringifyChildren(children, fn);
  77740. children && (children = _n + children + (chomp ? '' : _n));
  77741. return '{' + children + indent() + '}';
  77742. }
  77743. /**
  77744. * Stringify an array of child AST nodes by calling the given stringify function
  77745. * once for each child, and concatenating the results.
  77746. *
  77747. * @param {Array} children `node.rules` or `node.declarations`
  77748. * @param {Function} fn stringify function
  77749. * @returns {String}
  77750. */
  77751. function stringifyChildren(children, fn) {
  77752. if (!children) { return ''; }
  77753. indent(1);
  77754. var results = reduce(children, fn);
  77755. indent(-1);
  77756. if (!results.length) { return ''; }
  77757. return results.join(_n);
  77758. }
  77759. /**
  77760. * Stringify a declaration AST node.
  77761. *
  77762. * @param {Object} node declaration AST node
  77763. * @returns {String}
  77764. */
  77765. function stringifyDeclaration(node) {
  77766. if (node.type === 'property') {
  77767. return stringifyProperty(node);
  77768. }
  77769. }
  77770. /**
  77771. * Stringify an AST node.
  77772. *
  77773. * @param {Object} node AST node
  77774. * @returns {String}
  77775. */
  77776. function stringifyNode(node) {
  77777. switch (node.type) {
  77778. // Cases are listed in roughly descending order of probability.
  77779. case 'rule': return stringifyRule(node);
  77780. case 'media' :
  77781. case 'keyframes': return stringifyAtGroup(node);
  77782. case 'comment': return stringifyComment(node);
  77783. case 'import' :
  77784. case 'charset' :
  77785. case 'namespace': return stringifyAtRule(node);
  77786. case 'font-face':
  77787. case 'supports' :
  77788. case 'viewport' :
  77789. case 'document' :
  77790. case 'page' : return stringifyAtGroup(node);
  77791. }
  77792. }
  77793. /**
  77794. * Stringify an AST property node.
  77795. *
  77796. * @param {Object} node AST property node
  77797. * @returns {String}
  77798. */
  77799. function stringifyProperty(node) {
  77800. var name = node.name ? node.name + ':' + _s : '';
  77801. return indent() + name + node.value + ';';
  77802. }
  77803. });
  77804. var mensch = {
  77805. lex : lexer,
  77806. parse: parser,
  77807. stringify: stringify_1
  77808. };
  77809. // Notable changes from Slick.Parser 1.0.x
  77810. // The parser now uses 2 classes: Expressions and Expression
  77811. // `new Expressions` produces an array-like object containing a list of Expression objects
  77812. // - Expressions::toString() produces a cleaned up expressions string
  77813. // `new Expression` produces an array-like object
  77814. // - Expression::toString() produces a cleaned up expression string
  77815. // The only exposed method is parse, which produces a (cached) `new Expressions` instance
  77816. // parsed.raw is no longer present, use .toString()
  77817. // parsed.expression is now useless, just use the indices
  77818. // parsed.reverse() has been removed for now, due to its apparent uselessness
  77819. // Other changes in the Expressions object:
  77820. // - classNames are now unique, and save both escaped and unescaped values
  77821. // - attributes now save both escaped and unescaped values
  77822. // - pseudos now save both escaped and unescaped values
  77823. var escapeRe = /([-.*+?^${}()|[\]\/\\])/g,
  77824. unescapeRe = /\\/g;
  77825. var escape$1 = function(string){
  77826. // XRegExp v2.0.0-beta-3
  77827. // « https://github.com/slevithan/XRegExp/blob/master/src/xregexp.js
  77828. return (string + "").replace(escapeRe, '\\$1')
  77829. };
  77830. var unescape$1 = function(string){
  77831. return (string + "").replace(unescapeRe, '')
  77832. };
  77833. var slickRe = RegExp(
  77834. /*
  77835. #!/usr/bin/env ruby
  77836. puts "\t\t" + DATA.read.gsub(/\(\?x\)|\s+#.*$|\s+|\\$|\\n/,'')
  77837. __END__
  77838. "(?x)^(?:\
  77839. \\s* ( , ) \\s* # Separator \n\
  77840. | \\s* ( <combinator>+ ) \\s* # Combinator \n\
  77841. | ( \\s+ ) # CombinatorChildren \n\
  77842. | ( <unicode>+ | \\* ) # Tag \n\
  77843. | \\# ( <unicode>+ ) # ID \n\
  77844. | \\. ( <unicode>+ ) # ClassName \n\
  77845. | # Attribute \n\
  77846. \\[ \
  77847. \\s* (<unicode1>+) (?: \
  77848. \\s* ([*^$!~|]?=) (?: \
  77849. \\s* (?:\
  77850. ([\"']?)(.*?)\\9 \
  77851. )\
  77852. ) \
  77853. )? \\s* \
  77854. \\](?!\\]) \n\
  77855. | :+ ( <unicode>+ )(?:\
  77856. \\( (?:\
  77857. (?:([\"'])([^\\12]*)\\12)|((?:\\([^)]+\\)|[^()]*)+)\
  77858. ) \\)\
  77859. )?\
  77860. )"
  77861. */
  77862. "^(?:\\s*(,)\\s*|\\s*(<combinator>+)\\s*|(\\s+)|(<unicode>+|\\*)|\\#(<unicode>+)|\\.(<unicode>+)|\\[\\s*(<unicode1>+)(?:\\s*([*^$!~|]?=)(?:\\s*(?:([\"']?)(.*?)\\9)))?\\s*\\](?!\\])|(:+)(<unicode>+)(?:\\((?:(?:([\"'])([^\\13]*)\\13)|((?:\\([^)]+\\)|[^()]*)+))\\))?)"
  77863. .replace(/<combinator>/, '[' + escape$1(">+~`!@$%^&={}\\;</") + ']')
  77864. .replace(/<unicode>/g, '(?:[\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])')
  77865. .replace(/<unicode1>/g, '(?:[:\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])')
  77866. );
  77867. // Part
  77868. var Part = function Part(combinator){
  77869. this.combinator = combinator || " ";
  77870. this.tag = "*";
  77871. };
  77872. Part.prototype.toString = function(){
  77873. if (!this.raw){
  77874. var xpr = "", k, part;
  77875. xpr += this.tag || "*";
  77876. if (this.id) xpr += "#" + this.id;
  77877. if (this.classes) xpr += "." + this.classList.join(".");
  77878. if (this.attributes) for (k = 0; part = this.attributes[k++];){
  77879. xpr += "[" + part.name + (part.operator ? part.operator + '"' + part.value + '"' : '') + "]";
  77880. }
  77881. if (this.pseudos) for (k = 0; part = this.pseudos[k++];){
  77882. xpr += ":" + part.name;
  77883. if (part.value) xpr += "(" + part.value + ")";
  77884. }
  77885. this.raw = xpr;
  77886. }
  77887. return this.raw
  77888. };
  77889. // Expression
  77890. var Expression = function Expression(){
  77891. this.length = 0;
  77892. };
  77893. Expression.prototype.toString = function(){
  77894. if (!this.raw){
  77895. var xpr = "";
  77896. for (var j = 0, bit; bit = this[j++];){
  77897. if (j !== 1) xpr += " ";
  77898. if (bit.combinator !== " ") xpr += bit.combinator + " ";
  77899. xpr += bit;
  77900. }
  77901. this.raw = xpr;
  77902. }
  77903. return this.raw
  77904. };
  77905. var replacer$1 = function(
  77906. rawMatch,
  77907. separator,
  77908. combinator,
  77909. combinatorChildren,
  77910. tagName,
  77911. id,
  77912. className,
  77913. attributeKey,
  77914. attributeOperator,
  77915. attributeQuote,
  77916. attributeValue,
  77917. pseudoMarker,
  77918. pseudoClass,
  77919. pseudoQuote,
  77920. pseudoClassQuotedValue,
  77921. pseudoClassValue
  77922. ){
  77923. var expression, current;
  77924. if (separator || !this.length){
  77925. expression = this[this.length++] = new Expression;
  77926. if (separator) return ''
  77927. }
  77928. if (!expression) expression = this[this.length - 1];
  77929. if (combinator || combinatorChildren || !expression.length){
  77930. current = expression[expression.length++] = new Part(combinator);
  77931. }
  77932. if (!current) current = expression[expression.length - 1];
  77933. if (tagName){
  77934. current.tag = unescape$1(tagName);
  77935. } else if (id){
  77936. current.id = unescape$1(id);
  77937. } else if (className){
  77938. var unescaped = unescape$1(className);
  77939. var classes = current.classes || (current.classes = {});
  77940. if (!classes[unescaped]){
  77941. classes[unescaped] = escape$1(className);
  77942. var classList = current.classList || (current.classList = []);
  77943. classList.push(unescaped);
  77944. classList.sort();
  77945. }
  77946. } else if (pseudoClass){
  77947. pseudoClassValue = pseudoClassValue || pseudoClassQuotedValue
  77948. ;(current.pseudos || (current.pseudos = [])).push({
  77949. type : pseudoMarker.length == 1 ? 'class' : 'element',
  77950. name : unescape$1(pseudoClass),
  77951. escapedName : escape$1(pseudoClass),
  77952. value : pseudoClassValue ? unescape$1(pseudoClassValue) : null,
  77953. escapedValue : pseudoClassValue ? escape$1(pseudoClassValue) : null
  77954. });
  77955. } else if (attributeKey){
  77956. attributeValue = attributeValue ? escape$1(attributeValue) : null
  77957. ;(current.attributes || (current.attributes = [])).push({
  77958. operator : attributeOperator,
  77959. name : unescape$1(attributeKey),
  77960. escapedName : escape$1(attributeKey),
  77961. value : attributeValue ? unescape$1(attributeValue) : null,
  77962. escapedValue : attributeValue ? escape$1(attributeValue) : null
  77963. });
  77964. }
  77965. return ''
  77966. };
  77967. // Expressions
  77968. var Expressions = function Expressions(expression){
  77969. this.length = 0;
  77970. var self = this;
  77971. var original = expression, replaced;
  77972. while (expression){
  77973. replaced = expression.replace(slickRe, function(){
  77974. return replacer$1.apply(self, arguments)
  77975. });
  77976. if (replaced === expression) throw new Error(original + ' is an invalid expression')
  77977. expression = replaced;
  77978. }
  77979. };
  77980. Expressions.prototype.toString = function(){
  77981. if (!this.raw){
  77982. var expressions = [];
  77983. for (var i = 0, expression; expression = this[i++];) expressions.push(expression);
  77984. this.raw = expressions.join(", ");
  77985. }
  77986. return this.raw
  77987. };
  77988. var cache = {};
  77989. var parse$5 = function(expression){
  77990. if (expression == null) return null
  77991. expression = ('' + expression).replace(/^\s+|\s+$/g, '');
  77992. return cache[expression] || (cache[expression] = new Expressions(expression))
  77993. };
  77994. var parser$1 = parse$5;
  77995. var selector = createCommonjsModule(function (module, exports) {
  77996. module.exports = exports = Selector;
  77997. /**
  77998. * CSS selector constructor.
  77999. *
  78000. * @param {String} selector text
  78001. * @param {Array} optionally, precalculated specificity
  78002. * @api public
  78003. */
  78004. function Selector(text, styleAttribute) {
  78005. this.text = text;
  78006. this.spec = undefined;
  78007. this.styleAttribute = styleAttribute || false;
  78008. }
  78009. /**
  78010. * Get parsed selector.
  78011. *
  78012. * @api public
  78013. */
  78014. Selector.prototype.parsed = function() {
  78015. if (!this.tokens) { this.tokens = parse(this.text); }
  78016. return this.tokens;
  78017. };
  78018. /**
  78019. * Lazy specificity getter
  78020. *
  78021. * @api public
  78022. */
  78023. Selector.prototype.specificity = function() {
  78024. var styleAttribute = this.styleAttribute;
  78025. if (!this.spec) { this.spec = specificity(this.text, this.parsed()); }
  78026. return this.spec;
  78027. function specificity(text, parsed) {
  78028. var expressions = parsed || parse(text);
  78029. var spec = [styleAttribute ? 1 : 0, 0, 0, 0];
  78030. var nots = [];
  78031. for (var i = 0; i < expressions.length; i++) {
  78032. var expression = expressions[i];
  78033. var pseudos = expression.pseudos;
  78034. // id awards a point in the second column
  78035. if (expression.id) { spec[1]++; }
  78036. // classes and attributes award a point each in the third column
  78037. if (expression.attributes) { spec[2] += expression.attributes.length; }
  78038. if (expression.classList) { spec[2] += expression.classList.length; }
  78039. // tag awards a point in the fourth column
  78040. if (expression.tag && expression.tag !== '*') { spec[3]++; }
  78041. // pseudos award a point each in the fourth column
  78042. if (pseudos) {
  78043. spec[3] += pseudos.length;
  78044. for (var p = 0; p < pseudos.length; p++) {
  78045. if (pseudos[p].name === 'not') {
  78046. nots.push(pseudos[p].value);
  78047. spec[3]--;
  78048. }
  78049. }
  78050. }
  78051. }
  78052. for (var ii = nots.length; ii--;) {
  78053. var not = specificity(nots[ii]);
  78054. for (var jj = 4; jj--;) { spec[jj] += not[jj]; }
  78055. }
  78056. return spec;
  78057. }
  78058. };
  78059. /**
  78060. * Parses a selector and returns the tokens.
  78061. *
  78062. * @param {String} selector
  78063. * @api private.
  78064. */
  78065. function parse(text) {
  78066. try {
  78067. return parser$1(text)[0];
  78068. } catch (e) {
  78069. return [];
  78070. }
  78071. }
  78072. });
  78073. var property = createCommonjsModule(function (module, exports) {
  78074. module.exports = exports = Property;
  78075. /**
  78076. * Module dependencies.
  78077. */
  78078. /**
  78079. * CSS property constructor.
  78080. *
  78081. * @param {String} property
  78082. * @param {String} value
  78083. * @param {Selector} selector the property originates from
  78084. * @param {Integer} priority 0 for normal properties, 2 for !important properties.
  78085. * @param {Array} additional array of integers representing more detailed priorities (sorting)
  78086. * @api public
  78087. */
  78088. function Property(prop, value, selector, priority, additionalPriority) {
  78089. this.prop = prop;
  78090. this.value = value;
  78091. this.selector = selector;
  78092. this.priority = priority || 0;
  78093. this.additionalPriority = additionalPriority || [];
  78094. }
  78095. /**
  78096. * Compares with another Property based on Selector#specificity.
  78097. *
  78098. * @api public
  78099. */
  78100. Property.prototype.compareFunc = function(property) {
  78101. var a = [];
  78102. a.push.apply(a, this.selector.specificity());
  78103. a.push.apply(a, this.additionalPriority);
  78104. a[0] += this.priority;
  78105. var b = [];
  78106. b.push.apply(b, property.selector.specificity());
  78107. b.push.apply(b, property.additionalPriority);
  78108. b[0] += property.priority;
  78109. return utils$1.compareFunc(a, b);
  78110. };
  78111. Property.prototype.compare = function(property) {
  78112. var winner = this.compareFunc(property);
  78113. if (winner === 1) {
  78114. return this;
  78115. }
  78116. return property;
  78117. };
  78118. /**
  78119. * Returns CSS property
  78120. *
  78121. * @api public
  78122. */
  78123. Property.prototype.toString = function() {
  78124. return this.prop + ': ' + this.value.replace(/['"]+/g, '') + ';';
  78125. };
  78126. });
  78127. var utils$1 = createCommonjsModule(function (module, exports) {
  78128. /**
  78129. * Module dependencies.
  78130. */
  78131. exports.Selector = selector;
  78132. exports.Property = property;
  78133. /**
  78134. * Returns an array of the selectors.
  78135. *
  78136. * @license Sizzle CSS Selector Engine - MIT
  78137. * @param {String} selectorText from mensch
  78138. * @api public
  78139. */
  78140. exports.extract = function extract(selectorText) {
  78141. var attr = 0;
  78142. var sels = [];
  78143. var sel = '';
  78144. for (var i = 0, l = selectorText.length; i < l; i++) {
  78145. var c = selectorText.charAt(i);
  78146. if (attr) {
  78147. if (']' === c || ')' === c) { attr--; }
  78148. sel += c;
  78149. } else {
  78150. if (',' === c) {
  78151. sels.push(sel);
  78152. sel = '';
  78153. } else {
  78154. if ('[' === c || '(' === c) { attr++; }
  78155. if (sel.length || (c !== ',' && c !== '\n' && c !== ' ')) { sel += c; }
  78156. }
  78157. }
  78158. }
  78159. if (sel.length) {
  78160. sels.push(sel);
  78161. }
  78162. return sels;
  78163. };
  78164. /**
  78165. * Returns a parse tree for a CSS source.
  78166. * If it encounters multiple selectors separated by a comma, it splits the
  78167. * tree.
  78168. *
  78169. * @param {String} css source
  78170. * @api public
  78171. */
  78172. exports.parseCSS = function(css) {
  78173. var parsed = mensch.parse(css, {position: true, comments: true});
  78174. var rules = typeof parsed.stylesheet != 'undefined' && parsed.stylesheet.rules ? parsed.stylesheet.rules : [];
  78175. var ret = [];
  78176. for (var i = 0, l = rules.length; i < l; i++) {
  78177. if (rules[i].type == 'rule') {
  78178. var rule = rules[i];
  78179. var selectors = rule.selectors;
  78180. for (var ii = 0, ll = selectors.length; ii < ll; ii++) {
  78181. ret.push([selectors[ii], rule.declarations]);
  78182. }
  78183. }
  78184. }
  78185. return ret;
  78186. };
  78187. /**
  78188. * Returns preserved text for a CSS source.
  78189. *
  78190. * @param {String} css source
  78191. * @param {Object} options
  78192. * @api public
  78193. */
  78194. exports.getPreservedText = function(css, options, ignoredPseudos) {
  78195. var parsed = mensch.parse(css, {position: true, comments: true});
  78196. var rules = typeof parsed.stylesheet != 'undefined' && parsed.stylesheet.rules ? parsed.stylesheet.rules : [];
  78197. var preserved = [];
  78198. var lastStart = null;
  78199. for (var i = rules.length - 1; i >= 0; i--) {
  78200. if ((options.fontFaces && rules[i].type === 'font-face') ||
  78201. (options.mediaQueries && rules[i].type === 'media') ||
  78202. (options.keyFrames && rules[i].type === 'keyframes') ||
  78203. (options.pseudos && rules[i].selectors && this.matchesPseudo(rules[i].selectors[0], ignoredPseudos))) {
  78204. preserved.unshift(
  78205. mensch.stringify(
  78206. { stylesheet: { rules: [ rules[i] ] }},
  78207. { comments: false, indentation: ' ' }
  78208. )
  78209. );
  78210. }
  78211. lastStart = rules[i].position.start;
  78212. }
  78213. if (preserved.length === 0) {
  78214. return false;
  78215. }
  78216. return '\n' + preserved.join('\n') + '\n';
  78217. };
  78218. exports.normalizeLineEndings = function(text) {
  78219. return text.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n');
  78220. };
  78221. exports.matchesPseudo = function(needle, haystack) {
  78222. return haystack.find(function (element) {
  78223. return needle.indexOf(element) > -1;
  78224. })
  78225. };
  78226. /**
  78227. * Compares two specificity vectors, returning the winning one.
  78228. *
  78229. * @param {Array} vector a
  78230. * @param {Array} vector b
  78231. * @return {Array}
  78232. * @api public
  78233. */
  78234. exports.compareFunc = function(a, b) {
  78235. var min = Math.min(a.length, b.length);
  78236. for (var i = 0; i < min; i++) {
  78237. if (a[i] === b[i]) { continue; }
  78238. if (a[i] > b[i]) { return 1; }
  78239. return -1;
  78240. }
  78241. return a.length - b.length;
  78242. };
  78243. exports.compare = function(a, b) {
  78244. return exports.compareFunc(a, b) == 1 ? a : b;
  78245. };
  78246. exports.getDefaultOptions = function(options) {
  78247. var result = Object.assign({
  78248. extraCss: '',
  78249. insertPreservedExtraCss: true,
  78250. applyStyleTags: true,
  78251. removeStyleTags: true,
  78252. preserveMediaQueries: true,
  78253. preserveFontFaces: true,
  78254. preserveKeyFrames: true,
  78255. preservePseudos: true,
  78256. applyWidthAttributes: true,
  78257. applyHeightAttributes: true,
  78258. applyAttributesTableElements: true,
  78259. url: ''
  78260. }, options);
  78261. result.webResources = result.webResources || {};
  78262. return result;
  78263. };
  78264. });
  78265. var utils_1 = utils$1.Selector;
  78266. var utils_2 = utils$1.Property;
  78267. var utils_3 = utils$1.extract;
  78268. var utils_4 = utils$1.parseCSS;
  78269. var utils_5 = utils$1.getPreservedText;
  78270. var utils_6 = utils$1.normalizeLineEndings;
  78271. var utils_7 = utils$1.matchesPseudo;
  78272. var utils_8 = utils$1.compareFunc;
  78273. var utils_9 = utils$1.compare;
  78274. var utils_10 = utils$1.getDefaultOptions;
  78275. var cheerio_1 = createCommonjsModule(function (module) {
  78276. /**
  78277. * Module dependencies.
  78278. */
  78279. var cheerioLoad = function(html, options, encodeEntities) {
  78280. options = Object.assign({decodeEntities: false, _useHtmlParser2:true}, options);
  78281. html = encodeEntities(html);
  78282. return cheerio.load(html, options);
  78283. };
  78284. var createEntityConverters = function () {
  78285. var codeBlockLookup = [];
  78286. var encodeCodeBlocks = function(html) {
  78287. var blocks = module.exports.codeBlocks;
  78288. Object.keys(blocks).forEach(function(key) {
  78289. var re = new RegExp(blocks[key].start + '([\\S\\s]*?)' + blocks[key].end, 'g');
  78290. html = html.replace(re, function(match, subMatch) {
  78291. codeBlockLookup.push(match);
  78292. return 'JUICE_CODE_BLOCK_' + (codeBlockLookup.length - 1) + '_';
  78293. });
  78294. });
  78295. return html;
  78296. };
  78297. var decodeCodeBlocks = function(html) {
  78298. for(var index = 0; index < codeBlockLookup.length; index++) {
  78299. var re = new RegExp('JUICE_CODE_BLOCK_' + index + '_(="")?', 'gi');
  78300. html = html.replace(re, function() {
  78301. return codeBlockLookup[index];
  78302. });
  78303. }
  78304. return html;
  78305. };
  78306. return {
  78307. encodeEntities: encodeCodeBlocks,
  78308. decodeEntities: decodeCodeBlocks,
  78309. };
  78310. };
  78311. /**
  78312. * Parses the input, calls the callback on the parsed DOM, and generates the output
  78313. *
  78314. * @param {String} html input html to be processed
  78315. * @param {Object} options for the parser
  78316. * @param {Function} callback to be invoked on the DOM
  78317. * @param {Array} callbackExtraArguments to be passed to the callback
  78318. * @return {String} resulting html
  78319. */
  78320. module.exports = function(html, options, callback, callbackExtraArguments) {
  78321. var entityConverters = createEntityConverters();
  78322. var $ = cheerioLoad(html, options, entityConverters.encodeEntities);
  78323. var args = [ $ ];
  78324. args.push.apply(args, callbackExtraArguments);
  78325. var doc = callback.apply(undefined, args) || $;
  78326. if (options && options.xmlMode) {
  78327. return entityConverters.decodeEntities(doc.xml());
  78328. }
  78329. return entityConverters.decodeEntities(doc.html());
  78330. };
  78331. module.exports.codeBlocks = {
  78332. EJS: { start: '<%', end: '%>' },
  78333. HBS: { start: '{{', end: '}}' }
  78334. };
  78335. });
  78336. var cheerio_2 = cheerio_1.codeBlocks;
  78337. /**
  78338. * Converts a decimal number to roman numeral.
  78339. * https://stackoverflow.com/questions/9083037/convert-a-number-into-a-roman-numeral-in-javascript
  78340. *
  78341. * @param {Number} number
  78342. * @api private.
  78343. */
  78344. var romanize = function(num) {
  78345. if (isNaN(num))
  78346. return NaN;
  78347. var digits = String(+num).split(""),
  78348. key = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM",
  78349. "","X","XX","XXX","XL","L","LX","LXX","LXXX","XC",
  78350. "","I","II","III","IV","V","VI","VII","VIII","IX"],
  78351. roman = "",
  78352. i = 3;
  78353. while (i--)
  78354. roman = (key[+digits.pop() + (i * 10)] || "") + roman;
  78355. return Array(+digits.join("") + 1).join("M") + roman;
  78356. };
  78357. /**
  78358. * Converts a decimal number to alphanumeric numeral.
  78359. * https://stackoverflow.com/questions/45787459/convert-number-to-alphabet-string-javascript
  78360. *
  78361. * @param {Number} number
  78362. * @api private.
  78363. */
  78364. var alphanumeric = function(num) {
  78365. var s = '', t;
  78366. while (num > 0) {
  78367. t = (num - 1) % 26;
  78368. s = String.fromCharCode(65 + t) + s;
  78369. num = (num - t)/26 | 0;
  78370. }
  78371. return s || undefined;
  78372. };
  78373. var numbers = {
  78374. romanize: romanize,
  78375. alphanumeric: alphanumeric
  78376. };
  78377. var inline = function makeJuiceClient(juiceClient) {
  78378. juiceClient.ignoredPseudos = ['hover', 'active', 'focus', 'visited', 'link'];
  78379. juiceClient.widthElements = ['TABLE', 'TD', 'TH', 'IMG'];
  78380. juiceClient.heightElements = ['TABLE', 'TD', 'TH', 'IMG'];
  78381. juiceClient.tableElements = ['TABLE', 'TH', 'TR', 'TD', 'CAPTION', 'COLGROUP', 'COL', 'THEAD', 'TBODY', 'TFOOT'];
  78382. juiceClient.nonVisualElements = [ 'HEAD', 'TITLE', 'BASE', 'LINK', 'STYLE', 'META', 'SCRIPT', 'NOSCRIPT' ];
  78383. juiceClient.styleToAttribute = {
  78384. 'background-color': 'bgcolor',
  78385. 'background-image': 'background',
  78386. 'text-align': 'align',
  78387. 'vertical-align': 'valign'
  78388. };
  78389. juiceClient.excludedProperties = [];
  78390. juiceClient.juiceDocument = juiceDocument;
  78391. juiceClient.inlineDocument = inlineDocument;
  78392. function inlineDocument($, css, options) {
  78393. options = options || {};
  78394. var rules = utils$1.parseCSS(css);
  78395. var editedElements = [];
  78396. var styleAttributeName = 'style';
  78397. var counters = {};
  78398. if (options.styleAttributeName) {
  78399. styleAttributeName = options.styleAttributeName;
  78400. }
  78401. rules.forEach(handleRule);
  78402. editedElements.forEach(setStyleAttrs);
  78403. if (options.inlinePseudoElements) {
  78404. editedElements.forEach(inlinePseudoElements);
  78405. }
  78406. if (options.applyWidthAttributes) {
  78407. editedElements.forEach(function(el) {
  78408. setDimensionAttrs(el, 'width');
  78409. });
  78410. }
  78411. if (options.applyHeightAttributes) {
  78412. editedElements.forEach(function(el) {
  78413. setDimensionAttrs(el, 'height');
  78414. });
  78415. }
  78416. if (options.applyAttributesTableElements) {
  78417. editedElements.forEach(setAttributesOnTableElements);
  78418. }
  78419. if (options.insertPreservedExtraCss && options.extraCss) {
  78420. var preservedText = utils$1.getPreservedText(options.extraCss, {
  78421. mediaQueries: options.preserveMediaQueries,
  78422. fontFaces: options.preserveFontFaces,
  78423. keyFrames: options.preserveKeyFrames
  78424. });
  78425. if (preservedText) {
  78426. var $appendTo = null;
  78427. if (options.insertPreservedExtraCss !== true) {
  78428. $appendTo = $(options.insertPreservedExtraCss);
  78429. } else {
  78430. $appendTo = $('head');
  78431. if (!$appendTo.length) { $appendTo = $('body'); }
  78432. if (!$appendTo.length) { $appendTo = $.root(); }
  78433. }
  78434. $appendTo.first().append('<style>' + preservedText + '</style>');
  78435. }
  78436. }
  78437. function handleRule(rule) {
  78438. var sel = rule[0];
  78439. var style = rule[1];
  78440. var selector = new utils$1.Selector(sel);
  78441. var parsedSelector = selector.parsed();
  78442. if (!parsedSelector) {
  78443. return;
  78444. }
  78445. var pseudoElementType = getPseudoElementType(parsedSelector);
  78446. // skip rule if the selector has any pseudos which are ignored
  78447. for (var i = 0; i < parsedSelector.length; ++i) {
  78448. var subSel = parsedSelector[i];
  78449. if (subSel.pseudos) {
  78450. for (var j = 0; j < subSel.pseudos.length; ++j) {
  78451. var subSelPseudo = subSel.pseudos[j];
  78452. if (juiceClient.ignoredPseudos.indexOf(subSelPseudo.name) >= 0) {
  78453. return;
  78454. }
  78455. }
  78456. }
  78457. }
  78458. if (pseudoElementType) {
  78459. var last = parsedSelector[parsedSelector.length - 1];
  78460. var pseudos = last.pseudos;
  78461. last.pseudos = filterElementPseudos(last.pseudos);
  78462. sel = parsedSelector.toString();
  78463. last.pseudos = pseudos;
  78464. }
  78465. var els;
  78466. try {
  78467. els = $(sel);
  78468. } catch (err) {
  78469. // skip invalid selector
  78470. return;
  78471. }
  78472. els.each(function() {
  78473. var el = this;
  78474. if (el.name && juiceClient.nonVisualElements.indexOf(el.name.toUpperCase()) >= 0) {
  78475. return;
  78476. }
  78477. if (pseudoElementType) {
  78478. var pseudoElPropName = 'pseudo' + pseudoElementType;
  78479. var pseudoEl = el[pseudoElPropName];
  78480. if (!pseudoEl) {
  78481. pseudoEl = el[pseudoElPropName] = $('<span />').get(0);
  78482. pseudoEl.pseudoElementType = pseudoElementType;
  78483. pseudoEl.pseudoElementParent = el;
  78484. pseudoEl.counterProps = el.counterProps;
  78485. el[pseudoElPropName] = pseudoEl;
  78486. }
  78487. el = pseudoEl;
  78488. }
  78489. if (!el.styleProps) {
  78490. el.styleProps = {};
  78491. // if the element has inline styles, fake selector with topmost specificity
  78492. if ($(el).attr(styleAttributeName)) {
  78493. var cssText = '* { ' + $(el).attr(styleAttributeName) + ' } ';
  78494. addProps(utils$1.parseCSS(cssText)[0][1], new utils$1.Selector('<style>', true));
  78495. }
  78496. // store reference to an element we need to compile style="" attr for
  78497. editedElements.push(el);
  78498. }
  78499. if (!el.counterProps) {
  78500. el.counterProps = el.parent && el.parent.counterProps
  78501. ? Object.create(el.parent.counterProps)
  78502. : {};
  78503. }
  78504. function resetCounter(el, value) {
  78505. var tokens = value.split(/\s+/);
  78506. for (var j = 0; j < tokens.length; j++) {
  78507. var counter = tokens[j];
  78508. var resetval = parseInt(tokens[j+1], 10);
  78509. isNaN(resetval)
  78510. ? el.counterProps[counter] = counters[counter] = 0
  78511. : el.counterProps[counter] = counters[tokens[j++]] = resetval;
  78512. }
  78513. }
  78514. function incrementCounter(el, value) {
  78515. var tokens = value.split(/\s+/);
  78516. for (var j = 0; j < tokens.length; j++) {
  78517. var counter = tokens[j];
  78518. if (el.counterProps[counter] === undefined) {
  78519. continue;
  78520. }
  78521. var incrval = parseInt(tokens[j+1], 10);
  78522. isNaN(incrval)
  78523. ? el.counterProps[counter] = counters[counter] += 1
  78524. : el.counterProps[counter] = counters[tokens[j++]] += incrval;
  78525. }
  78526. }
  78527. // go through the properties
  78528. function addProps(style, selector) {
  78529. for (var i = 0, l = style.length; i < l; i++) {
  78530. if (style[i].type == 'property') {
  78531. var name = style[i].name;
  78532. var value = style[i].value;
  78533. if (name === 'counter-reset') {
  78534. resetCounter(el, value);
  78535. }
  78536. if (name === 'counter-increment') {
  78537. incrementCounter(el, value);
  78538. }
  78539. var important = value.match(/!important$/) !== null;
  78540. if (important && !options.preserveImportant) value = removeImportant(value);
  78541. // adds line number and column number for the properties as "additionalPriority" to the
  78542. // properties because in CSS the position directly affect the priority.
  78543. var additionalPriority = [style[i].position.start.line, style[i].position.start.col];
  78544. var prop = new utils$1.Property(name, value, selector, important ? 2 : 0, additionalPriority);
  78545. var existing = el.styleProps[name];
  78546. // if property name is not in the excluded properties array
  78547. if (juiceClient.excludedProperties.indexOf(name) < 0) {
  78548. if (existing && existing.compare(prop) === prop || !existing) {
  78549. // deleting a property let us change the order (move it to the end in the setStyleAttrs loop)
  78550. if (existing && existing.selector !== selector) {
  78551. delete el.styleProps[name];
  78552. } else if (existing) {
  78553. // make "prop" a special composed property.
  78554. prop.nextProp = existing;
  78555. }
  78556. el.styleProps[name] = prop;
  78557. }
  78558. }
  78559. }
  78560. }
  78561. }
  78562. addProps(style, selector);
  78563. });
  78564. }
  78565. function setStyleAttrs(el) {
  78566. var l = Object.keys(el.styleProps).length;
  78567. var props = [];
  78568. // Here we loop each property and make sure to "expand"
  78569. // linked "nextProp" properties happening when the same property
  78570. // is declared multiple times in the same selector.
  78571. Object.keys(el.styleProps).forEach(function(key) {
  78572. var np = el.styleProps[key];
  78573. while (typeof np !== 'undefined') {
  78574. props.push(np);
  78575. np = np.nextProp;
  78576. }
  78577. });
  78578. // sort properties by their originating selector's specificity so that
  78579. // props like "padding" and "padding-bottom" are resolved as expected.
  78580. props.sort(function(a, b) {
  78581. return a.compareFunc(b);
  78582. });
  78583. var string = props
  78584. .filter(function(prop) {
  78585. // Content becomes the innerHTML of pseudo elements, not used as a
  78586. // style property
  78587. return prop.prop !== 'content';
  78588. })
  78589. .map(function(prop) {
  78590. return prop.prop + ': ' + prop.value.replace(/["]/g, '\'') + ';';
  78591. })
  78592. .join(' ');
  78593. if (string) {
  78594. $(el).attr(styleAttributeName, string);
  78595. }
  78596. }
  78597. function inlinePseudoElements(el) {
  78598. if (el.pseudoElementType && el.styleProps.content) {
  78599. var parsed = parseContent(el);
  78600. if (parsed.img) {
  78601. el.name = 'img';
  78602. $(el).attr('src', parsed.img);
  78603. } else {
  78604. $(el).text(parsed);
  78605. }
  78606. var parent = el.pseudoElementParent;
  78607. if (el.pseudoElementType === 'before') {
  78608. $(parent).prepend(el);
  78609. } else {
  78610. $(parent).append(el);
  78611. }
  78612. }
  78613. }
  78614. function setDimensionAttrs(el, dimension) {
  78615. if (!el.name) { return; }
  78616. var elName = el.name.toUpperCase();
  78617. if (juiceClient[dimension + 'Elements'].indexOf(elName) > -1) {
  78618. for (var i in el.styleProps) {
  78619. if (el.styleProps[i].prop === dimension) {
  78620. var value = el.styleProps[i].value;
  78621. if (options.preserveImportant) {
  78622. value = removeImportant(value);
  78623. }
  78624. if (value.match(/px/)) {
  78625. var pxSize = value.replace('px', '');
  78626. $(el).attr(dimension, pxSize);
  78627. return;
  78628. }
  78629. if (juiceClient.tableElements.indexOf(elName) > -1 && value.match(/\%/)) {
  78630. $(el).attr(dimension, value);
  78631. return;
  78632. }
  78633. }
  78634. }
  78635. }
  78636. }
  78637. function extractBackgroundUrl(value) {
  78638. return value.indexOf('url(') !== 0
  78639. ? value
  78640. : value.replace(/^url\((["'])?([^"']+)\1\)$/, '$2');
  78641. }
  78642. function setAttributesOnTableElements(el) {
  78643. if (!el.name) { return; }
  78644. var elName = el.name.toUpperCase();
  78645. var styleProps = Object.keys(juiceClient.styleToAttribute);
  78646. if (juiceClient.tableElements.indexOf(elName) > -1) {
  78647. for (var i in el.styleProps) {
  78648. if (styleProps.indexOf(el.styleProps[i].prop) > -1) {
  78649. var prop = juiceClient.styleToAttribute[el.styleProps[i].prop];
  78650. var value = el.styleProps[i].value;
  78651. if (options.preserveImportant) {
  78652. value = removeImportant(value);
  78653. }
  78654. if (prop === 'background') {
  78655. value = extractBackgroundUrl(value);
  78656. }
  78657. if (/(linear|radial)-gradient\(/i.test(value)) {
  78658. continue;
  78659. }
  78660. $(el).attr(prop, value);
  78661. }
  78662. }
  78663. }
  78664. }
  78665. }
  78666. function removeImportant(value) {
  78667. return value.replace(/\s*!important$/, '')
  78668. }
  78669. function findVariableValue(el, variable) {
  78670. while (el) {
  78671. if (variable in el.styleProps) {
  78672. return el.styleProps[variable].value;
  78673. }
  78674. var el = el.parent || el.pseudoElementParent;
  78675. }
  78676. }
  78677. function applyCounterStyle(counter, style) {
  78678. switch (style) {
  78679. case 'lower-roman':
  78680. return numbers.romanize(counter).toLowerCase();
  78681. case 'upper-roman':
  78682. return numbers.romanize(counter);
  78683. case 'lower-latin':
  78684. case 'lower-alpha':
  78685. return numbers.alphanumeric(counter).toLowerCase();
  78686. case 'upper-latin':
  78687. case 'upper-alpha':
  78688. return numbers.alphanumeric(counter);
  78689. // TODO support more counter styles
  78690. default:
  78691. return counter.toString();
  78692. }
  78693. }
  78694. function parseContent(el) {
  78695. var content = el.styleProps.content.value;
  78696. if (content === 'none' || content === 'normal') {
  78697. return '';
  78698. }
  78699. var imageUrlMatch = content.match(/^\s*url\s*\(\s*(.*?)\s*\)\s*$/i);
  78700. if (imageUrlMatch) {
  78701. var url = imageUrlMatch[1].replace(/^['"]|['"]$/g, '');
  78702. return { img: url };
  78703. }
  78704. var parsed = [];
  78705. var tokens = content.split(/['"]/);
  78706. for (var i = 0; i < tokens.length; i++) {
  78707. if (tokens[i] === '') continue;
  78708. var varMatch = tokens[i].match(/var\s*\(\s*(.*?)\s*(,\s*(.*?)\s*)?\s*\)/i);
  78709. if (varMatch) {
  78710. var variable = findVariableValue(el, varMatch[1]) || varMatch[2];
  78711. parsed.push(variable.replace(/^['"]|['"]$/g, ''));
  78712. continue;
  78713. }
  78714. var counterMatch = tokens[i].match(/counter\s*\(\s*(.*?)\s*(,\s*(.*?)\s*)?\s*\)/i);
  78715. if (counterMatch && counterMatch[1] in el.counterProps) {
  78716. var counter = el.counterProps[counterMatch[1]];
  78717. parsed.push(applyCounterStyle(counter, counterMatch[3]));
  78718. continue;
  78719. }
  78720. var attrMatch = tokens[i].match(/attr\s*\(\s*(.*?)\s*\)/i);
  78721. if (attrMatch) {
  78722. var attr = attrMatch[1];
  78723. parsed.push(el.pseudoElementParent
  78724. ? el.pseudoElementParent.attribs[attr]
  78725. : el.attribs[attr]
  78726. );
  78727. continue;
  78728. }
  78729. parsed.push(tokens[i]);
  78730. }
  78731. content = parsed.join('');
  78732. // Naive unescape, assume no unicode char codes
  78733. content = content.replace(/\\/g, '');
  78734. return content;
  78735. }
  78736. // Return "before" or "after" if the given selector is a pseudo element (e.g.,
  78737. // a::after).
  78738. function getPseudoElementType(selector) {
  78739. if (selector.length === 0) {
  78740. return;
  78741. }
  78742. var pseudos = selector[selector.length - 1].pseudos;
  78743. if (!pseudos) {
  78744. return;
  78745. }
  78746. for (var i = 0; i < pseudos.length; i++) {
  78747. if (isPseudoElementName(pseudos[i])) {
  78748. return pseudos[i].name;
  78749. }
  78750. }
  78751. }
  78752. function isPseudoElementName(pseudo) {
  78753. return pseudo.name === 'before' || pseudo.name === 'after';
  78754. }
  78755. function filterElementPseudos(pseudos) {
  78756. return pseudos.filter(function(pseudo) {
  78757. return !isPseudoElementName(pseudo);
  78758. });
  78759. }
  78760. function juiceDocument($, options) {
  78761. options = utils$1.getDefaultOptions(options);
  78762. var css = extractCssFromDocument($, options);
  78763. css += '\n' + options.extraCss;
  78764. inlineDocument($, css, options);
  78765. return $;
  78766. }
  78767. function getStylesData($, options) {
  78768. var results = [];
  78769. var stylesList = $('style');
  78770. var styleDataList, styleData, styleElement;
  78771. stylesList.each(function() {
  78772. styleElement = this;
  78773. // the API for Cheerio using parse5 (default) and htmlparser2 are slightly different
  78774. // detect this by checking if .childNodes exist (as opposed to .children)
  78775. var usingParse5 = !!styleElement.childNodes;
  78776. styleDataList = usingParse5 ? styleElement.childNodes : styleElement.children;
  78777. if (styleDataList.length !== 1) {
  78778. if (options.removeStyleTags) {
  78779. $(styleElement).remove();
  78780. }
  78781. return;
  78782. }
  78783. styleData = styleDataList[0].data;
  78784. if (options.applyStyleTags && $(styleElement).attr('data-embed') === undefined) {
  78785. results.push(styleData);
  78786. }
  78787. if (options.removeStyleTags && $(styleElement).attr('data-embed') === undefined) {
  78788. var text = usingParse5 ? styleElement.childNodes[0].nodeValue : styleElement.children[0].data;
  78789. var preservedText = utils$1.getPreservedText(text, {
  78790. mediaQueries: options.preserveMediaQueries,
  78791. fontFaces: options.preserveFontFaces,
  78792. keyFrames: options.preserveKeyFrames,
  78793. pseudos: options.preservePseudos
  78794. }, juiceClient.ignoredPseudos);
  78795. if (preservedText) {
  78796. if (usingParse5) {
  78797. styleElement.childNodes[0].nodeValue = preservedText;
  78798. } else {
  78799. styleElement.children[0].data = preservedText;
  78800. }
  78801. } else {
  78802. $(styleElement).remove();
  78803. }
  78804. }
  78805. $(styleElement).removeAttr('data-embed');
  78806. });
  78807. return results;
  78808. }
  78809. function extractCssFromDocument($, options) {
  78810. var results = getStylesData($, options);
  78811. var css = results.join('\n');
  78812. return css;
  78813. }
  78814. return juiceClient;
  78815. };
  78816. /**
  78817. * Note that makeJuiceClient will take a base object (in this case a function) and enhance it
  78818. * with a lot of useful properties and functions.
  78819. *
  78820. * This client adopts cheerio as a DOM parser and adds an "inlineContent" function that let
  78821. * users to specify the CSS to be inlined instead of extracting it from the html.
  78822. *
  78823. * The weird "makeJuiceClient" behaviour is there in order to keep backward API compatibility.
  78824. */
  78825. var juiceClient = inline(function(html,options) {
  78826. return cheerio_1(html, { xmlMode: options && options.xmlMode}, juiceDocument, [options]);
  78827. });
  78828. var juiceDocument = function(html, options) {
  78829. return juiceClient.juiceDocument(html, options);
  78830. };
  78831. juiceClient.inlineContent = function(html, css, options) {
  78832. return cheerio_1(html, { xmlMode: options && options.xmlMode}, juiceClient.inlineDocument, [css, options]);
  78833. };
  78834. var client = juiceClient;
  78835. function _createSuper$1j(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1j(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  78836. function _isNativeReflectConstruct$1j() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  78837. /**
  78838. * 复制按钮,用来复制预览区的html内容
  78839. * 该操作会将预览区的css样式以行内样式的形式插入到html内容里,从而保证粘贴时样式一致
  78840. */
  78841. var Copy = /*#__PURE__*/function (_MenuBase) {
  78842. _inherits(Copy, _MenuBase);
  78843. var _super = _createSuper$1j(Copy);
  78844. function Copy($cherry) {
  78845. var _this;
  78846. _classCallCheck(this, Copy);
  78847. _this = _super.call(this, $cherry);
  78848. _this.previewer = $cherry.previewer;
  78849. _this.isLoading = false;
  78850. _this.updateMarkdown = false;
  78851. _this.setName('copy', 'copy');
  78852. return _this;
  78853. }
  78854. _createClass(Copy, [{
  78855. key: "adaptWechat",
  78856. value: function () {
  78857. var _adaptWechat = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(rawHtml) {
  78858. var figureRegex, html, imgRegex, promises, urls;
  78859. return regenerator.wrap(function _callee$(_context3) {
  78860. while (1) {
  78861. switch (_context3.prev = _context3.next) {
  78862. case 0:
  78863. // 转化链接
  78864. // Array.from(document.querySelectorAll('a')).forEach((item) => {
  78865. // item.removeAttribute('href');
  78866. // });
  78867. // 防止echarts标签被转成p时丢失样式
  78868. figureRegex = /(<figure data-lines=.+?<)div(.+?<\/)div(>.*?<\/figure>)/g;
  78869. html = rawHtml.replace(figureRegex, function (match, prefix, content, suffix) {
  78870. var _context, _context2;
  78871. return concat$5(_context = concat$5(_context2 = "".concat(prefix, "p")).call(_context2, content, "p")).call(_context, suffix);
  78872. }); // 图片转base64,防止无法自动上传
  78873. imgRegex = /(<img.+?src=")(.+?)(".*?>)/g;
  78874. /** @type {(Promise<string>)[]} */
  78875. promises = [];
  78876. html.replace(imgRegex, function (match, prefix, src) {
  78877. promises.push(convertImgToBase64(src));
  78878. });
  78879. _context3.next = 7;
  78880. return promise$7.all(promises);
  78881. case 7:
  78882. urls = _context3.sent;
  78883. return _context3.abrupt("return", html.replace(imgRegex, function (match, prefix, src, suffix) {
  78884. return prefix + urls.shift() + suffix;
  78885. }));
  78886. case 9:
  78887. case "end":
  78888. return _context3.stop();
  78889. }
  78890. }
  78891. }, _callee);
  78892. }));
  78893. function adaptWechat(_x) {
  78894. return _adaptWechat.apply(this, arguments);
  78895. }
  78896. return adaptWechat;
  78897. }()
  78898. }, {
  78899. key: "getStyleFromSheets",
  78900. value: function getStyleFromSheets(keyword) {
  78901. var _context4;
  78902. var sheets = filter$3(_context4 = from_1$2(document.styleSheets)).call(_context4, function (item) {
  78903. var _context5;
  78904. return indexOf$8(_context5 = item.cssRules[0].cssText).call(_context5, keyword) > -1;
  78905. });
  78906. return "<style>".concat(reduce$3(sheets).call(sheets, function (html, sheet) {
  78907. var _context6;
  78908. return html + reduce$3(_context6 = from_1$2(sheet.cssRules)).call(_context6, function (html, rule) {
  78909. return html + rule.cssText;
  78910. }, '');
  78911. }, ''), "</style>");
  78912. }
  78913. }, {
  78914. key: "computeStyle",
  78915. value: function computeStyle() {
  78916. // 计算需要append进富文本的style
  78917. var mathStyle = this.getStyleFromSheets('mjx-container');
  78918. var cherryStyle = this.getStyleFromSheets('cherry');
  78919. var echartStyle = '<style>figure>p{overflow:hidden;position:relative;width:500px;height:300px;background:transparent;}</style>';
  78920. return {
  78921. mathStyle: mathStyle,
  78922. echartStyle: echartStyle,
  78923. cherryStyle: cherryStyle
  78924. };
  78925. }
  78926. /**
  78927. * 由于复制操作会随着预览区域的内容增加而耗时变长,所以需要增加“正在复制”的状态回显
  78928. * 同时该状态也用于限频
  78929. */
  78930. }, {
  78931. key: "toggleLoading",
  78932. value: function toggleLoading() {
  78933. // 切换loading状态
  78934. if (this.isLoading) {
  78935. var loadingButton = document.querySelector('.icon-loading');
  78936. loadingButton.outerHTML = "<i class=\"ch-icon ch-icon-copy\" title=\"".concat(this.locale.copy, "\"></i>");
  78937. } else {
  78938. var copyButton = document.querySelector('.ch-icon-copy');
  78939. copyButton.outerHTML = '<div class="icon-loading loading"></div>';
  78940. }
  78941. this.isLoading = !this.isLoading;
  78942. }
  78943. /**
  78944. * 响应点击事件
  78945. * 该按钮不会引发编辑区域的内容改动,所以不用处理用户在编辑区域的选中内容
  78946. * @param {Event} e 点击事件
  78947. */
  78948. }, {
  78949. key: "onClick",
  78950. value: function onClick(e) {
  78951. var _this2 = this;
  78952. this.toggleLoading();
  78953. var inlineCodeTheme = document.querySelector('.cherry').getAttribute('data-inline-code-theme');
  78954. var codeBlockTheme = document.querySelector('.cherry').getAttribute('data-code-block-theme');
  78955. var _this$computeStyle = this.computeStyle(),
  78956. mathStyle = _this$computeStyle.mathStyle,
  78957. echartStyle = _this$computeStyle.echartStyle,
  78958. cherryStyle = _this$computeStyle.cherryStyle;
  78959. var html = this.previewer.isPreviewerHidden() ? this.previewer.options.previewerCache.html : this.previewer.getValue(); // 将css样式以行内样式的形式插入到html内容里
  78960. this.adaptWechat(html).then(function (html) {
  78961. var _context7, _context8, _context9;
  78962. copyToClip(client(concat$5(_context7 = concat$5(_context8 = concat$5(_context9 = "<div data-inline-code-theme=\"".concat(inlineCodeTheme, "\" data-code-block-theme=\"")).call(_context9, codeBlockTheme, "\">\n <div class=\"cherry-markdown\">")).call(_context8, html, "</div>\n </div>")).call(_context7, mathStyle + echartStyle + cherryStyle)));
  78963. _this2.toggleLoading();
  78964. });
  78965. }
  78966. }]);
  78967. return Copy;
  78968. }(MenuBase);
  78969. function convertImgToBase64(url, callback, outputFormat) {
  78970. return new promise$7(function (resolve) {
  78971. var canvas =
  78972. /** @type {HTMLCanvasElement}*/
  78973. document.createElement('CANVAS');
  78974. var ctx = canvas.getContext('2d');
  78975. var img = new Image();
  78976. img.crossOrigin = 'Anonymous';
  78977. img.onload = function () {
  78978. canvas.height = img.height;
  78979. canvas.width = img.width;
  78980. ctx.drawImage(img, 0, 0);
  78981. var dataURL = canvas.toDataURL(outputFormat || 'image/png');
  78982. resolve(dataURL);
  78983. canvas = null;
  78984. };
  78985. img.src = url;
  78986. });
  78987. }
  78988. function _createSuper$1k(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1k(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  78989. function _isNativeReflectConstruct$1k() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  78990. /**
  78991. * 插入面板
  78992. */
  78993. var Panel$1 = /*#__PURE__*/function (_MenuBase) {
  78994. _inherits(Panel, _MenuBase);
  78995. var _super = _createSuper$1k(Panel);
  78996. function Panel($cherry) {
  78997. var _context, _context2, _context3, _context4, _context5;
  78998. var _this;
  78999. _classCallCheck(this, Panel);
  79000. _this = _super.call(this, $cherry);
  79001. _this.setName('panel', 'tips');
  79002. _this.panelRule = getPanelRule().reg;
  79003. _this.subMenuConfig = [{
  79004. iconName: 'tips',
  79005. name: 'tips',
  79006. onclick: bind$5(_context = _this.bindSubClick).call(_context, _assertThisInitialized(_this), 'primary')
  79007. }, {
  79008. iconName: 'info',
  79009. name: 'info',
  79010. onclick: bind$5(_context2 = _this.bindSubClick).call(_context2, _assertThisInitialized(_this), 'info')
  79011. }, {
  79012. iconName: 'warning',
  79013. name: 'warning',
  79014. onclick: bind$5(_context3 = _this.bindSubClick).call(_context3, _assertThisInitialized(_this), 'warning')
  79015. }, {
  79016. iconName: 'danger',
  79017. name: 'danger',
  79018. onclick: bind$5(_context4 = _this.bindSubClick).call(_context4, _assertThisInitialized(_this), 'danger')
  79019. }, {
  79020. iconName: 'success',
  79021. name: 'success',
  79022. onclick: bind$5(_context5 = _this.bindSubClick).call(_context5, _assertThisInitialized(_this), 'success')
  79023. }];
  79024. return _this;
  79025. }
  79026. /**
  79027. * 从字符串中找打面板的name
  79028. * @param {string} str
  79029. * @returns {string | false}
  79030. */
  79031. _createClass(Panel, [{
  79032. key: "$getNameFromStr",
  79033. value: function $getNameFromStr(str) {
  79034. var ret = false;
  79035. this.panelRule.lastIndex = 0;
  79036. str.replace(this.panelRule, function (match, preLines, name, content) {
  79037. var $name = /\s/.test(trim$3(name).call(name)) ? trim$3(name).call(name).replace(/\s.*$/, '') : name;
  79038. ret = $name ? trim$3($name).call($name).toLowerCase() : '';
  79039. return match;
  79040. });
  79041. return ret;
  79042. }
  79043. }, {
  79044. key: "$getTitle",
  79045. value: function $getTitle(str) {
  79046. this.panelRule.lastIndex = 0;
  79047. str.replace(this.panelRule, function (match, preLines, name, content) {
  79048. var $name = trim$3(name).call(name);
  79049. return /\s/.test($name) ? $name.replace(/[^\s]+\s/, '') : '';
  79050. });
  79051. return '';
  79052. }
  79053. /**
  79054. * 响应点击事件
  79055. * @param {string} selection 被用户选中的文本内容
  79056. * @param {string} shortKey 快捷键参数
  79057. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  79058. */
  79059. }, {
  79060. key: "onClick",
  79061. value: function onClick(selection) {
  79062. var _this2 = this,
  79063. _context9,
  79064. _context10;
  79065. var shortKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  79066. var $selection = getSelection(this.editor.editor, selection, 'line', true) || '内容';
  79067. var currentName = this.$getNameFromStr($selection);
  79068. var title = this.$getTitle($selection);
  79069. if (currentName === false) {
  79070. // 如果没有命中面板语法,则尝试扩大选区
  79071. this.getMoreSelection('::: ', '\n', function () {
  79072. var newSelection = _this2.editor.editor.getSelection();
  79073. var isMatch = _this2.$getNameFromStr(newSelection);
  79074. if (isMatch !== false) {
  79075. $selection = newSelection;
  79076. currentName = isMatch;
  79077. title = _this2.$getTitle(newSelection);
  79078. }
  79079. return isMatch !== false;
  79080. });
  79081. }
  79082. if (currentName !== false) {
  79083. // 如果命中了面板语法,则尝试去掉语法或者变更语法
  79084. if (currentName === shortKey) {
  79085. // 去掉面板语法
  79086. this.panelRule.lastIndex = 0;
  79087. return $selection.replace(this.panelRule, function (match, preLines, name, content) {
  79088. var _context6;
  79089. var $name = trim$3(name).call(name);
  79090. var $title = /\s/.test($name) ? $name.replace(/[^\s]+\s/, '') : '';
  79091. return concat$5(_context6 = "".concat($title, "\n")).call(_context6, content);
  79092. });
  79093. } // 修改name
  79094. this.registerAfterClickCb(function () {
  79095. _this2.setLessSelection('::: ', '\n');
  79096. });
  79097. this.panelRule.lastIndex = 0;
  79098. return $selection.replace(this.panelRule, function (match, preLines, name, content) {
  79099. var _context7, _context8;
  79100. var $name = trim$3(name).call(name);
  79101. var $title = /\s/.test($name) ? $name.replace(/[^\s]+\s/, '') : '';
  79102. return concat$5(_context7 = concat$5(_context8 = "::: ".concat(shortKey, " ")).call(_context8, $title, "\n")).call(_context7, content.replace(/\n+$/, ''), "\n:::");
  79103. });
  79104. }
  79105. this.registerAfterClickCb(function () {
  79106. _this2.setLessSelection('::: ', '\n');
  79107. });
  79108. $selection = $selection.replace(/^\n+/, '');
  79109. if (/\n/.test($selection)) {
  79110. if (!title) {
  79111. title = $selection.replace(/\n[\w\W]+$/, '');
  79112. $selection = $selection.replace(/^[^\n]+\n/, '');
  79113. }
  79114. } else {
  79115. title = title ? title : '标题';
  79116. }
  79117. return concat$5(_context9 = concat$5(_context10 = "::: ".concat(shortKey, " ")).call(_context10, title, "\n")).call(_context9, $selection, "\n:::").replace(/\n{2,}:::/g, '\n:::');
  79118. }
  79119. }]);
  79120. return Panel;
  79121. }(MenuBase);
  79122. function _createSuper$1l(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1l(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  79123. function _isNativeReflectConstruct$1l() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  79124. /**
  79125. * 插入对齐方式
  79126. */
  79127. var Justify = /*#__PURE__*/function (_Panel) {
  79128. _inherits(Justify, _Panel);
  79129. var _super = _createSuper$1l(Justify);
  79130. function Justify($cherry) {
  79131. var _context, _context2, _context3;
  79132. var _this;
  79133. _classCallCheck(this, Justify);
  79134. _this = _super.call(this, $cherry);
  79135. _this.setName('justify', 'justify');
  79136. _this.panelRule = getPanelRule().reg;
  79137. _this.subMenuConfig = [{
  79138. iconName: 'justifyLeft',
  79139. name: '左对齐',
  79140. onclick: bind$5(_context = _this.bindSubClick).call(_context, _assertThisInitialized(_this), 'left')
  79141. }, {
  79142. iconName: 'justifyCenter',
  79143. name: '居中',
  79144. onclick: bind$5(_context2 = _this.bindSubClick).call(_context2, _assertThisInitialized(_this), 'center')
  79145. }, {
  79146. iconName: 'justifyRight',
  79147. name: '右对齐',
  79148. onclick: bind$5(_context3 = _this.bindSubClick).call(_context3, _assertThisInitialized(_this), 'right')
  79149. }];
  79150. return _this;
  79151. }
  79152. _createClass(Justify, [{
  79153. key: "$getTitle",
  79154. value: function $getTitle() {
  79155. return ' ';
  79156. }
  79157. }]);
  79158. return Justify;
  79159. }(Panel$1);
  79160. function _createSuper$1m(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1m(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  79161. function _isNativeReflectConstruct$1m() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  79162. /**
  79163. * 插入手风琴
  79164. */
  79165. var Detail$1 = /*#__PURE__*/function (_MenuBase) {
  79166. _inherits(Detail, _MenuBase);
  79167. var _super = _createSuper$1m(Detail);
  79168. function Detail($cherry) {
  79169. var _this;
  79170. _classCallCheck(this, Detail);
  79171. _this = _super.call(this, $cherry);
  79172. _this.setName('detail', 'insertFlow');
  79173. _this.detailRule = getDetailRule().reg;
  79174. return _this;
  79175. }
  79176. /**
  79177. * 响应点击事件
  79178. * @param {string} selection 被用户选中的文本内容
  79179. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  79180. */
  79181. _createClass(Detail, [{
  79182. key: "onClick",
  79183. value: function onClick(selection) {
  79184. var _this2 = this;
  79185. var $selection = getSelection(this.editor.editor, selection, 'line', true) || '点击展开更多\n内容\n++- 默认展开\n内容\n++ 默认收起\n内容';
  79186. this.detailRule.lastIndex = 0;
  79187. if (!this.detailRule.test($selection)) {
  79188. // 如果没有命中手风琴语法,则尝试扩大选区
  79189. this.getMoreSelection('+++ ', '\n', function () {
  79190. var newSelection = _this2.editor.editor.getSelection();
  79191. _this2.detailRule.lastIndex = 0;
  79192. var isMatch = _this2.detailRule.test(newSelection);
  79193. if (isMatch !== false) {
  79194. $selection = newSelection;
  79195. }
  79196. return isMatch !== false;
  79197. });
  79198. }
  79199. this.detailRule.lastIndex = 0;
  79200. if (this.detailRule.test($selection)) {
  79201. // 如果命中了手风琴语法,则去掉手风琴语法
  79202. this.detailRule.lastIndex = 0;
  79203. return $selection.replace(this.detailRule, function (match, preLines, isOpen, title, content) {
  79204. var _context;
  79205. return concat$5(_context = "".concat(title, "\n")).call(_context, content);
  79206. });
  79207. } // 去掉开头的空格
  79208. $selection = $selection.replace(/^\s+/, ''); // 如果选中的内容不包含换行,则强制增加一个换行
  79209. if (!/\n/.test($selection)) {
  79210. var _context2;
  79211. $selection = concat$5(_context2 = "".concat($selection, "\n")).call(_context2, $selection);
  79212. }
  79213. this.registerAfterClickCb(function () {
  79214. _this2.setLessSelection('+++ ', '\n');
  79215. });
  79216. return "+++ ".concat($selection, "\n+++").replace(/\n{2,}\+\+\+/g, '\n+++');
  79217. }
  79218. }]);
  79219. return Detail;
  79220. }(MenuBase);
  79221. function _createSuper$1n(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1n(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  79222. function _isNativeReflectConstruct$1n() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  79223. /**
  79224. * 打开draw.io画图对话框,点击确定后向编辑器插入图片语法
  79225. */
  79226. var DrawIo = /*#__PURE__*/function (_MenuBase) {
  79227. _inherits(DrawIo, _MenuBase);
  79228. var _super = _createSuper$1n(DrawIo);
  79229. function DrawIo($cherry) {
  79230. var _this;
  79231. _classCallCheck(this, DrawIo);
  79232. _this = _super.call(this, $cherry);
  79233. _this.setName('draw.io', 'draw.io');
  79234. _this.noIcon = true;
  79235. _this.drawioIframeUrl = $cherry.options.drawioIframeUrl;
  79236. return _this;
  79237. }
  79238. /**
  79239. * 响应点击事件
  79240. * @param {string} selection 被用户选中的文本内容
  79241. * @param {string} shortKey 快捷键参数,本函数不处理这个参数
  79242. * @returns {string} 回填到编辑器光标位置/选中文本区域的内容
  79243. */
  79244. _createClass(DrawIo, [{
  79245. key: "onClick",
  79246. value: function onClick(selection) {
  79247. var _this2 = this;
  79248. if (!this.drawioIframeUrl) {
  79249. // 如果没有配置drawio的编辑页URL,则直接失效
  79250. return selection;
  79251. }
  79252. if (this.hasCacheOnce()) {
  79253. var _context;
  79254. // @ts-ignore
  79255. var _this$getAndCleanCach = this.getAndCleanCacheOnce(),
  79256. xmlData = _this$getAndCleanCach.xmlData,
  79257. base64 = _this$getAndCleanCach.base64;
  79258. var begin = '![';
  79259. var end = concat$5(_context = "](".concat(base64, "){data-type=drawio data-xml=")).call(_context, encodeURI(xmlData), "}");
  79260. this.registerAfterClickCb(function () {
  79261. _this2.setLessSelection(begin, end);
  79262. });
  79263. return "".concat(begin, "\u5728\u9884\u89C8\u533A\u70B9\u51FB\u56FE\u7247\u91CD\u65B0\u7F16\u8F91draw.io").concat(end);
  79264. } // 插入图片,调用上传文件逻辑
  79265. drawioDialog(this.drawioIframeUrl, '', function (data) {
  79266. _this2.setCacheOnce(data);
  79267. _this2.fire(null);
  79268. });
  79269. this.updateMarkdown = false;
  79270. return selection;
  79271. }
  79272. }]);
  79273. return DrawIo;
  79274. }(MenuBase);
  79275. // 目前不支持按需动态加载
  79276. // 如果对CherryMarkdown构建后的文件大小有比较严格的要求,可以根据实际情况删减hook
  79277. var HookList = {
  79278. bold: Bold,
  79279. italic: Italic,
  79280. '|': Split,
  79281. strikethrough: Strikethrough$1,
  79282. sub: Sub$1,
  79283. sup: Sup$1,
  79284. header: Header$1,
  79285. insert: Insert,
  79286. list: List$1,
  79287. ol: Ol,
  79288. ul: Ul,
  79289. checklist: Checklist,
  79290. graph: Graph,
  79291. size: Size$1,
  79292. h1: H1,
  79293. h2: H2,
  79294. h3: H3,
  79295. color: Color$1,
  79296. quote: Quote,
  79297. quickTable: QuickTable,
  79298. togglePreview: TogglePreview,
  79299. code: Code,
  79300. codeTheme: CodeTheme,
  79301. "export": Export,
  79302. settings: Settings,
  79303. fullScreen: FullScreen,
  79304. mobilePreview: MobilePreview,
  79305. copy: Copy,
  79306. undo: Undo,
  79307. redo: Redo,
  79308. underline: Underline$1,
  79309. switchModel: SwitchModel,
  79310. image: Image$2,
  79311. audio: Audio,
  79312. video: Video,
  79313. br: Br$1,
  79314. hr: Hr$1,
  79315. formula: Formula,
  79316. link: Link$1,
  79317. table: Table$1,
  79318. toc: Toc$1,
  79319. lineTable: LineTable,
  79320. barTable: BrTable,
  79321. pdf: Pdf,
  79322. word: Word,
  79323. ruby: Ruby$1,
  79324. theme: Theme,
  79325. file: File,
  79326. panel: Panel$1,
  79327. justify: Justify,
  79328. detail: Detail$1,
  79329. drawIo: DrawIo,
  79330. chatgpt: ChatGpt
  79331. };
  79332. var HookCenter$1 = /*#__PURE__*/function () {
  79333. function HookCenter(toolbar) {
  79334. _classCallCheck(this, HookCenter);
  79335. this.toolbar = toolbar;
  79336. /**
  79337. * @type {{[key: string]: import('@/toolbars/MenuBase').default}} 保存所有菜单实例
  79338. */
  79339. this.hooks = {};
  79340. /**
  79341. * @type {string[]} 所有注册的菜单名称
  79342. */
  79343. this.allMenusName = [];
  79344. /**
  79345. * @type {string[]} 一级菜单的名称
  79346. */
  79347. this.level1MenusName = [];
  79348. /**
  79349. * @type {{ [parentName: string]: string[]}} 二级菜单的名称, e.g. {一级菜单名称: [二级菜单名称1, 二级菜单名称2]}
  79350. */
  79351. this.level2MenusName = {};
  79352. this.init();
  79353. }
  79354. _createClass(HookCenter, [{
  79355. key: "$newMenu",
  79356. value: function $newMenu(name) {
  79357. if (this.hooks[name]) {
  79358. return;
  79359. }
  79360. var _this$toolbar$options = this.toolbar.options,
  79361. $cherry = _this$toolbar$options.$cherry,
  79362. customMenu = _this$toolbar$options.customMenu;
  79363. if (HookList[name]) {
  79364. this.allMenusName.push(name);
  79365. this.hooks[name] = new HookList[name]($cherry);
  79366. } else if (customMenu !== undefined && customMenu !== null && customMenu[name]) {
  79367. this.allMenusName.push(name); // 如果是自定义菜单,传参兼容旧版
  79368. this.hooks[name] = new customMenu[name]($cherry);
  79369. }
  79370. }
  79371. /**
  79372. * 根据配置动态渲染、绑定工具栏
  79373. * @returns
  79374. */
  79375. }, {
  79376. key: "init",
  79377. value: function init() {
  79378. var _this = this;
  79379. var buttonConfig = this.toolbar.options.buttonConfig;
  79380. forEach$3(buttonConfig).call(buttonConfig, function (item) {
  79381. if (typeof item === 'string') {
  79382. _this.level1MenusName.push(item);
  79383. _this.$newMenu(item);
  79384. } else if (_typeof(item) === 'object') {
  79385. var keys = keys$3(item);
  79386. if (keys.length === 1) {
  79387. var _context;
  79388. // 只接受形如{ name: [ subMenu ] }的参数
  79389. var _keys = _slicedToArray(keys, 1),
  79390. name = _keys[0];
  79391. _this.level1MenusName.push(name);
  79392. _this.$newMenu(name);
  79393. _this.level2MenusName[name] = item[name];
  79394. forEach$3(_context = item[name]).call(_context, function (subItem) {
  79395. _this.$newMenu(subItem);
  79396. });
  79397. }
  79398. }
  79399. });
  79400. }
  79401. }]);
  79402. return HookCenter;
  79403. }();
  79404. var Toolbar = /*#__PURE__*/function () {
  79405. /**
  79406. * @type {Record<string, any>} 外部获取 toolbarHandler
  79407. */
  79408. function Toolbar(options) {
  79409. _classCallCheck(this, Toolbar);
  79410. _defineProperty(this, "toolbarHandlers", {});
  79411. // 存储所有菜单的实例
  79412. this.menus = {}; // 存储所有快捷键的影射 {快捷键: 菜单名称}
  79413. this.shortcutKeyMap = {}; // 存储所有二级菜单面板
  79414. this.subMenus = {}; // 默认的菜单配置
  79415. this.options = {
  79416. dom: document.createElement('div'),
  79417. buttonConfig: ['bold'],
  79418. customMenu: [],
  79419. buttonRightConfig: []
  79420. };
  79421. assign$2(this.options, options);
  79422. this.$cherry = this.options.$cherry;
  79423. this.instanceId = this.$cherry.instanceId;
  79424. this.menus = new HookCenter$1(this);
  79425. this.drawMenus();
  79426. this.init();
  79427. }
  79428. _createClass(Toolbar, [{
  79429. key: "init",
  79430. value: function init() {
  79431. var _this = this;
  79432. this.collectShortcutKey();
  79433. this.collectToolbarHandler();
  79434. Event$1.on(this.instanceId, Event$1.Events.cleanAllSubMenus, function () {
  79435. return _this.hideAllSubMenu();
  79436. });
  79437. }
  79438. }, {
  79439. key: "previewOnly",
  79440. value: function previewOnly() {
  79441. this.options.dom.classList.add('preview-only');
  79442. Event$1.emit(this.instanceId, Event$1.Events.toolbarHide);
  79443. }
  79444. }, {
  79445. key: "showToolbar",
  79446. value: function showToolbar() {
  79447. this.options.dom.classList.remove('preview-only');
  79448. Event$1.emit(this.instanceId, Event$1.Events.toolbarShow);
  79449. }
  79450. }, {
  79451. key: "isHasLevel2Menu",
  79452. value: function isHasLevel2Menu(name) {
  79453. // FIXME: return boolean
  79454. return this.menus.level2MenusName[name];
  79455. }
  79456. }, {
  79457. key: "isHasConfigMenu",
  79458. value: function isHasConfigMenu(name) {
  79459. // FIXME: return boolean
  79460. return this.menus.hooks[name].subMenuConfig || [];
  79461. }
  79462. /**
  79463. * 判断是否有子菜单,目前有两种子菜单配置方式:1、通过`subMenuConfig`属性 2、通过`buttonConfig`配置属性
  79464. * @param {string} name
  79465. * @returns {boolean} 是否有子菜单
  79466. */
  79467. }, {
  79468. key: "isHasSubMenu",
  79469. value: function isHasSubMenu(name) {
  79470. return Boolean(this.isHasLevel2Menu(name) || this.isHasConfigMenu(name).length > 0);
  79471. }
  79472. /**
  79473. * 根据配置画出来一级工具栏
  79474. */
  79475. }, {
  79476. key: "drawMenus",
  79477. value: function drawMenus() {
  79478. var _context,
  79479. _this2 = this,
  79480. _this$options$buttonR;
  79481. var fragLeft = document.createDocumentFragment();
  79482. var toolbarLeft = createElement('div', 'toolbar-left');
  79483. forEach$3(_context = this.menus.level1MenusName).call(_context, function (name) {
  79484. var btn = _this2.menus.hooks[name].createBtn();
  79485. btn.addEventListener('click', function (event) {
  79486. _this2.onClick(event, name);
  79487. }, false);
  79488. if (_this2.isHasSubMenu(name)) {
  79489. btn.classList.add('cherry-toolbar-dropdown');
  79490. }
  79491. fragLeft.appendChild(btn);
  79492. });
  79493. toolbarLeft.appendChild(fragLeft);
  79494. this.options.dom.appendChild(toolbarLeft);
  79495. (_this$options$buttonR = this.options.buttonRightConfig) !== null && _this$options$buttonR !== void 0 && _this$options$buttonR.length ? this.drawRightMenus(this.options.buttonRightConfig) : null;
  79496. }
  79497. /**
  79498. * 根据配置画出来右侧一级工具栏
  79499. */
  79500. }, {
  79501. key: "drawRightMenus",
  79502. value: function drawRightMenus(buttonRightConfig) {
  79503. var _context2;
  79504. var toolbarRight = createElement('div', 'toolbar-right');
  79505. var fragRight = document.createDocumentFragment();
  79506. var rightOptions = {
  79507. options: {
  79508. $cherry: this.$cherry,
  79509. buttonConfig: buttonRightConfig,
  79510. customMenu: []
  79511. }
  79512. };
  79513. var rightMenus = new HookCenter$1(rightOptions);
  79514. forEach$3(_context2 = rightMenus.level1MenusName).call(_context2, function (name) {
  79515. var btn = rightMenus.hooks[name].createBtn();
  79516. btn.addEventListener('click', function (event) {
  79517. console.log('第一次点击');
  79518. rightMenus.hooks[name].fire(event, name);
  79519. }, false);
  79520. fragRight.appendChild(btn);
  79521. });
  79522. toolbarRight.appendChild(fragRight);
  79523. this.options.dom.appendChild(toolbarRight);
  79524. }
  79525. }, {
  79526. key: "setSubMenuPosition",
  79527. value: function setSubMenuPosition(menuObj, subMenuObj) {
  79528. var pos = menuObj.getMenuPosition();
  79529. subMenuObj.style.left = "".concat(pos.left + pos.width / 2, "px");
  79530. subMenuObj.style.top = "".concat(pos.top + pos.height, "px");
  79531. subMenuObj.style.position = menuObj.positionModel;
  79532. }
  79533. }, {
  79534. key: "drawSubMenus",
  79535. value: function drawSubMenus(name) {
  79536. var _this3 = this;
  79537. this.subMenus[name] = createElement('div', 'cherry-dropdown', {
  79538. name: name
  79539. });
  79540. this.setSubMenuPosition(this.menus.hooks[name], this.subMenus[name]); // 如果有配置的二级菜单
  79541. var level2MenusName = this.isHasLevel2Menu(name);
  79542. if (level2MenusName) {
  79543. forEach$3(level2MenusName).call(level2MenusName, function (level2Name) {
  79544. var subMenu = _this3.menus.hooks[level2Name];
  79545. if (subMenu !== undefined && typeof subMenu.createBtn === 'function') {
  79546. var btn = subMenu.createBtn(true); // 二级菜单的dom认定为一级菜单的
  79547. subMenu.dom = subMenu.dom ? subMenu.dom : _this3.menus.hooks[name].dom;
  79548. btn.addEventListener('click', function (event) {
  79549. return _this3.onClick(event, level2Name, true);
  79550. }, false);
  79551. _this3.subMenus[name].appendChild(btn);
  79552. }
  79553. });
  79554. } // 兼容旧版本配置的二级菜单
  79555. var subMenuConfig = this.isHasConfigMenu(name);
  79556. if (subMenuConfig.length > 0) {
  79557. forEach$3(subMenuConfig).call(subMenuConfig, function (config) {
  79558. var btn = _this3.menus.hooks[name].createSubBtnByConfig(config);
  79559. btn.addEventListener('click', function () {
  79560. return _this3.hideAllSubMenu();
  79561. }, false);
  79562. _this3.subMenus[name].appendChild(btn);
  79563. });
  79564. }
  79565. this.$cherry.wrapperDom.appendChild(this.subMenus[name]);
  79566. }
  79567. /**
  79568. * 处理点击事件
  79569. */
  79570. }, {
  79571. key: "onClick",
  79572. value: function onClick(event, name) {
  79573. var focusEvent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  79574. var menu = this.menus.hooks[name];
  79575. if (!menu) {
  79576. return;
  79577. }
  79578. if (this.isHasSubMenu(name) && !focusEvent) {
  79579. this.toggleSubMenu(name);
  79580. } else {
  79581. this.hideAllSubMenu();
  79582. menu.fire(event, name);
  79583. }
  79584. }
  79585. /**
  79586. * 展开/收起二级菜单
  79587. */
  79588. }, {
  79589. key: "toggleSubMenu",
  79590. value: function toggleSubMenu(name) {
  79591. if (!this.subMenus[name]) {
  79592. // 如果没有二级菜单,则先画出来,然后再显示
  79593. this.hideAllSubMenu();
  79594. this.drawSubMenus(name);
  79595. this.subMenus[name].style.display = 'block';
  79596. return;
  79597. }
  79598. if (this.subMenus[name].style.display === 'none') {
  79599. // 如果是隐藏的,则先隐藏所有二级菜单,再显示当前二级菜单
  79600. this.hideAllSubMenu();
  79601. this.subMenus[name].style.display = 'block';
  79602. this.setSubMenuPosition(this.menus.hooks[name], this.subMenus[name]);
  79603. } else {
  79604. // 如果是显示的,则隐藏当前二级菜单
  79605. this.subMenus[name].style.display = 'none';
  79606. }
  79607. }
  79608. /**
  79609. * 隐藏所有的二级菜单
  79610. */
  79611. }, {
  79612. key: "hideAllSubMenu",
  79613. value: function hideAllSubMenu() {
  79614. var _context3;
  79615. forEach$3(_context3 = this.$cherry.wrapperDom.querySelectorAll('.cherry-dropdown')).call(_context3, function (dom) {
  79616. dom.style.display = 'none';
  79617. });
  79618. }
  79619. /**
  79620. * 收集快捷键
  79621. */
  79622. }, {
  79623. key: "collectShortcutKey",
  79624. value: function collectShortcutKey() {
  79625. var _context4,
  79626. _this4 = this;
  79627. forEach$3(_context4 = this.menus.allMenusName).call(_context4, function (name) {
  79628. var _this4$menus$hooks$na;
  79629. (_this4$menus$hooks$na = _this4.menus.hooks[name].shortcutKeys) === null || _this4$menus$hooks$na === void 0 ? void 0 : forEach$3(_this4$menus$hooks$na).call(_this4$menus$hooks$na, function (key) {
  79630. _this4.shortcutKeyMap[key] = name;
  79631. });
  79632. });
  79633. }
  79634. }, {
  79635. key: "collectToolbarHandler",
  79636. value: function collectToolbarHandler() {
  79637. var _context5,
  79638. _this5 = this;
  79639. this.toolbarHandlers = reduce$3(_context5 = this.menus.allMenusName).call(_context5, function (handlerMap, name) {
  79640. var menuHook = _this5.menus.hooks[name];
  79641. if (!menuHook) {
  79642. return handlerMap;
  79643. }
  79644. handlerMap[name] = function (shortcut, _callback) {
  79645. if (typeof _callback === 'function') {
  79646. Logger.warn('MenuBase#onClick param callback is no longer supported. Please register the callback via MenuBase#registerAfterClickCb instead.');
  79647. }
  79648. menuHook.fire.call(menuHook, undefined, shortcut);
  79649. };
  79650. return handlerMap;
  79651. }, {});
  79652. }
  79653. /**
  79654. * 监测是否有对应的快捷键
  79655. * @param {KeyboardEvent} evt keydown 事件
  79656. * @returns {boolean} 是否有对应的快捷键
  79657. */
  79658. }, {
  79659. key: "matchShortcutKey",
  79660. value: function matchShortcutKey(evt) {
  79661. return !!this.shortcutKeyMap[this.getCurrentKey(evt)];
  79662. }
  79663. /**
  79664. * 触发对应快捷键的事件
  79665. * @param {KeyboardEvent} evt
  79666. */
  79667. }, {
  79668. key: "fireShortcutKey",
  79669. value: function fireShortcutKey(evt) {
  79670. var _this$menus$hooks$thi;
  79671. var currentKey = this.getCurrentKey(evt);
  79672. (_this$menus$hooks$thi = this.menus.hooks[this.shortcutKeyMap[currentKey]]) === null || _this$menus$hooks$thi === void 0 ? void 0 : _this$menus$hooks$thi.fire(evt, currentKey);
  79673. }
  79674. /**
  79675. * 格式化当前按键,mac下的command按键转换为ctrl
  79676. * @param {KeyboardEvent} event
  79677. * @returns
  79678. */
  79679. }, {
  79680. key: "getCurrentKey",
  79681. value: function getCurrentKey(event) {
  79682. var key = '';
  79683. if (event.ctrlKey) {
  79684. key += 'Ctrl-';
  79685. }
  79686. if (event.altKey) {
  79687. key += 'Alt-';
  79688. }
  79689. if (event.metaKey && mac) {
  79690. key += 'Ctrl-';
  79691. } // 如果存在shift键
  79692. if (event.shiftKey) {
  79693. key += "Shift-";
  79694. } // 如果还有第三个键 且不是 shift键
  79695. if (event.key && event.key.toLowerCase() !== 'shift') {
  79696. key += event.key.toLowerCase();
  79697. }
  79698. return key;
  79699. }
  79700. }]);
  79701. return Toolbar;
  79702. }();
  79703. function _createSuper$1o(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1o(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  79704. function _isNativeReflectConstruct$1o() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  79705. /**
  79706. * 在编辑区域选中文本时浮现的bubble工具栏
  79707. */
  79708. var Bubble = /*#__PURE__*/function (_Toolbar) {
  79709. _inherits(Bubble, _Toolbar);
  79710. var _super = _createSuper$1o(Bubble);
  79711. function Bubble() {
  79712. _classCallCheck(this, Bubble);
  79713. return _super.apply(this, arguments);
  79714. }
  79715. _createClass(Bubble, [{
  79716. key: "visible",
  79717. get: function get() {
  79718. var bubbleStyle = window.getComputedStyle(this.bubbleDom);
  79719. return bubbleStyle.display !== 'none' && bubbleStyle.visibility !== 'hidden';
  79720. },
  79721. set:
  79722. /**
  79723. * @type {'flex' | 'block'}
  79724. */
  79725. // constructor(options) {
  79726. // super(options);
  79727. // }
  79728. function set(visible) {
  79729. var bubbleStyle = window.getComputedStyle(this.bubbleDom);
  79730. if (visible) {
  79731. bubbleStyle.display === 'none' && (this.bubbleDom.style.display = Bubble.displayType); // bubbleStyle.visibility !== 'visible' && (this.bubbleBottom.style.visibility = 'visible');
  79732. } else {
  79733. bubbleStyle.display !== 'none' && (this.bubbleDom.style.display = 'none'); // bubbleStyle.visibility !== 'hidden' && (this.bubbleBottom.style.visibility = 'hidden');
  79734. }
  79735. }
  79736. }, {
  79737. key: "init",
  79738. value: function init() {
  79739. this.options.editor = this.$cherry.editor;
  79740. this.addSelectionChangeListener();
  79741. this.bubbleDom = this.options.dom;
  79742. this.editorDom = this.options.editor.getEditorDom();
  79743. this.initBubbleDom();
  79744. this.editorDom.querySelector('.CodeMirror').appendChild(this.bubbleDom);
  79745. }
  79746. /**
  79747. * 计算编辑区域的偏移量
  79748. * @returns {number} 编辑区域的滚动区域
  79749. */
  79750. }, {
  79751. key: "getScrollTop",
  79752. value: function getScrollTop() {
  79753. return this.options.editor.editor.getScrollInfo().top;
  79754. }
  79755. /**
  79756. * 当编辑区域滚动的时候自动隐藏bubble工具栏和子工具栏
  79757. */
  79758. }, {
  79759. key: "updatePositionWhenScroll",
  79760. value: function updatePositionWhenScroll() {
  79761. if (this.bubbleDom.style.display === Bubble.displayType) {
  79762. this.bubbleDom.style.marginTop = "".concat(_parseFloat$2(this.bubbleDom.dataset.scrollTop) - this.getScrollTop(), "px");
  79763. }
  79764. }
  79765. /**
  79766. * 根据高度计算bubble工具栏出现的位置的高度
  79767. * 根据宽度计算bubble工具栏出现的位置的left值,以及bubble工具栏三角箭头的left值
  79768. * @param {number} top 高度
  79769. * @param {number} width 选中文本内容的宽度
  79770. */
  79771. }, {
  79772. key: "showBubble",
  79773. value: function showBubble(top, width) {
  79774. if (!this.visible) {
  79775. this.visible = true;
  79776. this.bubbleDom.style.marginTop = '0';
  79777. this.bubbleDom.dataset.scrollTop = String(this.getScrollTop());
  79778. }
  79779. var positionLimit = this.editorDom.querySelector('.CodeMirror-lines').firstChild.getBoundingClientRect();
  79780. var editorPosition = this.editorDom.getBoundingClientRect();
  79781. var minLeft = positionLimit.left - editorPosition.left;
  79782. var maxLeft = positionLimit.width + minLeft;
  79783. var minTop = this.bubbleDom.offsetHeight * 2;
  79784. var $top = top;
  79785. if ($top < minTop) {
  79786. // 如果高度小于编辑器的顶部,则让bubble工具栏出现在选中文本的下放
  79787. $top += this.bubbleDom.offsetHeight - this.bubbleTop.getBoundingClientRect().height;
  79788. this.bubbleTop.style.display = 'block';
  79789. this.bubbleBottom.style.display = 'none';
  79790. } else {
  79791. // 反之出现在选中文本内容的上方
  79792. $top -= this.bubbleDom.offsetHeight + 2 * this.bubbleBottom.getBoundingClientRect().height;
  79793. this.bubbleTop.style.display = 'none';
  79794. this.bubbleBottom.style.display = 'block';
  79795. }
  79796. this.bubbleDom.style.top = "".concat($top, "px");
  79797. var left = width - this.bubbleDom.offsetWidth / 2;
  79798. if (left < minLeft) {
  79799. // 如果位置超过了编辑器的最左边,则控制bubble工具栏不超出编辑器最左边
  79800. // 同时bubble工具栏上的箭头尽量指向选中文本内容的中间位置
  79801. left = minLeft;
  79802. this.$setBubbleCursorPosition("".concat(width - minLeft, "px"));
  79803. } else if (left + this.bubbleDom.offsetWidth > maxLeft) {
  79804. // 如果位置超过了编辑器的最右边,则控制bubble工具栏不超出编辑器最右边
  79805. // 同时bubble工具栏上的箭头尽量指向选中文本内容的中间位置
  79806. left = maxLeft - this.bubbleDom.offsetWidth;
  79807. this.$setBubbleCursorPosition("".concat(width - left, "px"));
  79808. } else {
  79809. // 让bubble工具栏的箭头处于工具栏的中间位置
  79810. this.$setBubbleCursorPosition('50%');
  79811. } // 安全边距 20px
  79812. this.bubbleDom.style.left = "".concat(Math.max(20, left), "px");
  79813. }
  79814. }, {
  79815. key: "hideBubble",
  79816. value: function hideBubble() {
  79817. this.visible = false;
  79818. }
  79819. /**
  79820. * 控制bubble工具栏的箭头的位置
  79821. * @param {string} left 左偏移量
  79822. */
  79823. }, {
  79824. key: "$setBubbleCursorPosition",
  79825. value: function $setBubbleCursorPosition() {
  79826. var left = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '50%';
  79827. if (left === '50%') {
  79828. this.bubbleTop.style.left = '50%';
  79829. this.bubbleBottom.style.left = '50%';
  79830. } else {
  79831. var $left = _parseFloat$2(left) < 10 ? '10px' : left;
  79832. this.bubbleTop.style.left = $left;
  79833. this.bubbleBottom.style.left = $left;
  79834. }
  79835. }
  79836. }, {
  79837. key: "initBubbleDom",
  79838. value: function initBubbleDom() {
  79839. var top = document.createElement('div');
  79840. top.className = 'cherry-bubble-top';
  79841. var bottom = document.createElement('div');
  79842. bottom.className = 'cherry-bubble-bottom';
  79843. this.bubbleTop = top;
  79844. this.bubbleBottom = bottom;
  79845. this.bubbleDom.appendChild(top);
  79846. this.bubbleDom.appendChild(bottom); // 默认不可见
  79847. this.visible = false;
  79848. }
  79849. }, {
  79850. key: "getBubbleDom",
  79851. value: function getBubbleDom() {
  79852. return this.bubbleDom;
  79853. }
  79854. }, {
  79855. key: "addSelectionChangeListener",
  79856. value: function addSelectionChangeListener() {
  79857. var _this = this;
  79858. this.options.editor.addListener('change', function (codemirror) {
  79859. // 当编辑区内容变更时自动隐藏bubble工具栏
  79860. _this.hideBubble();
  79861. });
  79862. this.options.editor.addListener('refresh', function (codemirror) {
  79863. // 当编辑区内容刷新时自动隐藏bubble工具栏
  79864. _this.hideBubble();
  79865. });
  79866. this.options.editor.addListener('scroll', function (codemirror) {
  79867. // 当编辑区滚动时,需要实时同步bubble工具栏的位置
  79868. _this.updatePositionWhenScroll();
  79869. });
  79870. this.options.editor.addListener('beforeSelectionChange', function (codemirror, info) {
  79871. // 当编辑区选中内容改变时,需要展示/隐藏bubble工具栏,并计算工具栏位置
  79872. if (info.origin !== '*mouse' && (info.origin !== null || typeof info.origin === 'undefined')) {
  79873. return true;
  79874. }
  79875. if (!info.ranges[0]) {
  79876. return true;
  79877. }
  79878. var anchor = info.ranges[0].anchor.line * 1000000 + info.ranges[0].anchor.ch;
  79879. var head = info.ranges[0].head.line * 1000000 + info.ranges[0].head.ch;
  79880. var direction = 'asc';
  79881. if (anchor > head) {
  79882. direction = 'desc';
  79883. }
  79884. setTimeout$3(function () {
  79885. var selections = codemirror.getSelections();
  79886. if (selections.join('').length <= 0) {
  79887. _this.hideBubble();
  79888. return;
  79889. }
  79890. var selectedObjs = codemirror.getWrapperElement().getElementsByClassName('CodeMirror-selected');
  79891. var editorPosition = _this.editorDom.getBoundingClientRect();
  79892. var width = 0;
  79893. var top = 0;
  79894. if (_typeof(selectedObjs) !== 'object' || selectedObjs.length <= 0) {
  79895. _this.hideBubble();
  79896. return;
  79897. }
  79898. for (var key = 0; key < selectedObjs.length; key++) {
  79899. var one = selectedObjs[key];
  79900. var position = one.getBoundingClientRect();
  79901. var targetTop = position.top - editorPosition.top;
  79902. if (direction === 'asc') {
  79903. if (targetTop >= top) {
  79904. top = targetTop;
  79905. width = position.left - editorPosition.left + position.width / 2;
  79906. }
  79907. } else {
  79908. if (targetTop <= top || top <= 0) {
  79909. top = targetTop;
  79910. width = position.left - editorPosition.left + position.width / 2;
  79911. }
  79912. }
  79913. }
  79914. _this.showBubble(top, width);
  79915. }, 10);
  79916. });
  79917. }
  79918. }]);
  79919. return Bubble;
  79920. }(Toolbar);
  79921. _defineProperty(Bubble, "displayType", 'flex');
  79922. function _createSuper$1p(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1p(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  79923. function _isNativeReflectConstruct$1p() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  79924. /**
  79925. * 当光标处于编辑器新行起始位置时出现的浮动工具栏
  79926. */
  79927. var FloatMenu = /*#__PURE__*/function (_Toolbar) {
  79928. _inherits(FloatMenu, _Toolbar);
  79929. var _super = _createSuper$1p(FloatMenu);
  79930. function FloatMenu() {
  79931. _classCallCheck(this, FloatMenu);
  79932. return _super.apply(this, arguments);
  79933. }
  79934. _createClass(FloatMenu, [{
  79935. key: "init",
  79936. value: // constructor(options) {
  79937. // super(options);
  79938. // }
  79939. function init() {
  79940. this.editor = this.$cherry.editor;
  79941. this.editorDom = this.editor.getEditorDom();
  79942. this.editorDom.querySelector('.CodeMirror-scroll').appendChild(this.options.dom);
  79943. this.initAction();
  79944. }
  79945. }, {
  79946. key: "initAction",
  79947. value: function initAction() {
  79948. var self = this;
  79949. this.editor.addListener('cursorActivity', function (codemirror, evt) {
  79950. // 当编辑区光标位置改变时触发
  79951. self.cursorActivity(evt, codemirror);
  79952. });
  79953. this.editor.addListener('update', function (codemirror, evt) {
  79954. // 当编辑区内容改变时触发
  79955. self.cursorActivity(evt, codemirror);
  79956. });
  79957. this.editor.addListener('refresh', function (codemirror, evt) {
  79958. // 当编辑器刷新时触发
  79959. setTimeout$3(function () {
  79960. self.cursorActivity(evt, codemirror);
  79961. }, 0);
  79962. });
  79963. }
  79964. }, {
  79965. key: "update",
  79966. value: function update(evt, codeMirror) {
  79967. var pos = codeMirror.getCursor();
  79968. if (this.isHidden(pos.line, codeMirror)) {
  79969. this.options.dom.style.display = 'none';
  79970. return false;
  79971. }
  79972. this.options.dom.style.display = 'inline-block';
  79973. }
  79974. /**
  79975. * 当光标激活时触发,当光标处于行起始位置时展示float工具栏;反之隐藏
  79976. * @param {Event} evt
  79977. * @param {CodeMirror.Editor} codeMirror
  79978. * @returns
  79979. */
  79980. }, {
  79981. key: "cursorActivity",
  79982. value: function cursorActivity(evt, codeMirror) {
  79983. var pos = codeMirror.getCursor();
  79984. var codeMirrorLines = document.querySelector('.cherry-editor .CodeMirror-lines');
  79985. if (!codeMirrorLines) {
  79986. return false;
  79987. }
  79988. var computedLinesStyle = getComputedStyle(codeMirrorLines);
  79989. var codeWrapPaddingLeft = _parseFloat$2(computedLinesStyle.paddingLeft);
  79990. var codeWrapPaddingTop = _parseFloat$2(computedLinesStyle.paddingTop); // const cursorHandle = codeMirror.getLineHandle(pos.line);
  79991. // const verticalMiddle = cursorHandle.height * 1 / 2;
  79992. if (this.isHidden(pos.line, codeMirror)) {
  79993. this.options.dom.style.display = 'none';
  79994. return false;
  79995. }
  79996. this.options.dom.style.display = 'inline-block';
  79997. this.options.dom.style.left = "".concat(codeWrapPaddingLeft, "px");
  79998. this.options.dom.style.top = "".concat(this.getLineHeight(pos.line, codeMirror) + codeWrapPaddingTop, "px");
  79999. }
  80000. /**
  80001. * 判断是否需要隐藏Float工具栏
  80002. * 有选中内容,或者光标所在行有内容时隐藏float 工具栏
  80003. * @param {number} line
  80004. * @param {CodeMirror.Editor} codeMirror
  80005. * @returns {boolean} 是否需要隐藏float工具栏,true:需要隐藏
  80006. */
  80007. }, {
  80008. key: "isHidden",
  80009. value: function isHidden(line, codeMirror) {
  80010. var selections = codeMirror.getSelections();
  80011. if (selections.length > 1) {
  80012. return true;
  80013. }
  80014. var selection = codeMirror.getSelection();
  80015. if (selection.length > 0) {
  80016. return true;
  80017. }
  80018. if (codeMirror.getLine(line)) {
  80019. return true;
  80020. }
  80021. return false;
  80022. }
  80023. /**
  80024. * 获取对应行的行高度,用来让float 工具栏在该行保持垂直居中
  80025. * @param {number} line
  80026. * @param {CodeMirror.Editor} codeMirror
  80027. * @returns
  80028. */
  80029. }, {
  80030. key: "getLineHeight",
  80031. value: function getLineHeight(line, codeMirror) {
  80032. var height = 0;
  80033. codeMirror.getDoc().eachLine(0, line, function (line) {
  80034. height += line.height;
  80035. });
  80036. return height;
  80037. }
  80038. }]);
  80039. return FloatMenu;
  80040. }(Toolbar);
  80041. function _createSuper$1q(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1q(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  80042. function _isNativeReflectConstruct$1q() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  80043. /**
  80044. * 预览区域右侧悬浮的工具栏
  80045. * 推荐放置跟编辑区域完全无关的工具栏
  80046. * 比如复制预览区域内容、修改预览区域主题等
  80047. */
  80048. var Sidebar = /*#__PURE__*/function (_Toolbar) {
  80049. _inherits(Sidebar, _Toolbar);
  80050. var _super = _createSuper$1q(Sidebar);
  80051. function Sidebar() {
  80052. _classCallCheck(this, Sidebar);
  80053. return _super.apply(this, arguments);
  80054. }
  80055. return _createClass(Sidebar);
  80056. }(Toolbar);
  80057. /**
  80058. * This library modifies the diff-patch-match library by Neil Fraser
  80059. * by removing the patch and match functionality and certain advanced
  80060. * options in the diff function. The original license is as follows:
  80061. *
  80062. * ===
  80063. *
  80064. * Diff Match and Patch
  80065. *
  80066. * Copyright 2006 Google Inc.
  80067. * http://code.google.com/p/google-diff-match-patch/
  80068. *
  80069. * Licensed under the Apache License, Version 2.0 (the "License");
  80070. * you may not use this file except in compliance with the License.
  80071. * You may obtain a copy of the License at
  80072. *
  80073. * http://www.apache.org/licenses/LICENSE-2.0
  80074. *
  80075. * Unless required by applicable law or agreed to in writing, software
  80076. * distributed under the License is distributed on an "AS IS" BASIS,
  80077. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  80078. * See the License for the specific language governing permissions and
  80079. * limitations under the License.
  80080. */
  80081. /**
  80082. * The data structure representing a diff is an array of tuples:
  80083. * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
  80084. * which means: delete 'Hello', add 'Goodbye' and keep ' world.'
  80085. */
  80086. var DIFF_DELETE = -1;
  80087. var DIFF_INSERT = 1;
  80088. var DIFF_EQUAL = 0;
  80089. /**
  80090. * Find the differences between two texts. Simplifies the problem by stripping
  80091. * any common prefix or suffix off the texts before diffing.
  80092. * @param {string} text1 Old string to be diffed.
  80093. * @param {string} text2 New string to be diffed.
  80094. * @param {Int|Object} [cursor_pos] Edit position in text1 or object with more info
  80095. * @return {Array} Array of diff tuples.
  80096. */
  80097. function diff_main(text1, text2, cursor_pos, _fix_unicode) {
  80098. // Check for equality
  80099. if (text1 === text2) {
  80100. if (text1) {
  80101. return [[DIFF_EQUAL, text1]];
  80102. }
  80103. return [];
  80104. }
  80105. if (cursor_pos != null) {
  80106. var editdiff = find_cursor_edit_diff(text1, text2, cursor_pos);
  80107. if (editdiff) {
  80108. return editdiff;
  80109. }
  80110. }
  80111. // Trim off common prefix (speedup).
  80112. var commonlength = diff_commonPrefix(text1, text2);
  80113. var commonprefix = text1.substring(0, commonlength);
  80114. text1 = text1.substring(commonlength);
  80115. text2 = text2.substring(commonlength);
  80116. // Trim off common suffix (speedup).
  80117. commonlength = diff_commonSuffix(text1, text2);
  80118. var commonsuffix = text1.substring(text1.length - commonlength);
  80119. text1 = text1.substring(0, text1.length - commonlength);
  80120. text2 = text2.substring(0, text2.length - commonlength);
  80121. // Compute the diff on the middle block.
  80122. var diffs = diff_compute_(text1, text2);
  80123. // Restore the prefix and suffix.
  80124. if (commonprefix) {
  80125. diffs.unshift([DIFF_EQUAL, commonprefix]);
  80126. }
  80127. if (commonsuffix) {
  80128. diffs.push([DIFF_EQUAL, commonsuffix]);
  80129. }
  80130. diff_cleanupMerge(diffs, _fix_unicode);
  80131. return diffs;
  80132. }
  80133. /**
  80134. * Find the differences between two texts. Assumes that the texts do not
  80135. * have any common prefix or suffix.
  80136. * @param {string} text1 Old string to be diffed.
  80137. * @param {string} text2 New string to be diffed.
  80138. * @return {Array} Array of diff tuples.
  80139. */
  80140. function diff_compute_(text1, text2) {
  80141. var diffs;
  80142. if (!text1) {
  80143. // Just add some text (speedup).
  80144. return [[DIFF_INSERT, text2]];
  80145. }
  80146. if (!text2) {
  80147. // Just delete some text (speedup).
  80148. return [[DIFF_DELETE, text1]];
  80149. }
  80150. var longtext = text1.length > text2.length ? text1 : text2;
  80151. var shorttext = text1.length > text2.length ? text2 : text1;
  80152. var i = longtext.indexOf(shorttext);
  80153. if (i !== -1) {
  80154. // Shorter text is inside the longer text (speedup).
  80155. diffs = [
  80156. [DIFF_INSERT, longtext.substring(0, i)],
  80157. [DIFF_EQUAL, shorttext],
  80158. [DIFF_INSERT, longtext.substring(i + shorttext.length)]
  80159. ];
  80160. // Swap insertions for deletions if diff is reversed.
  80161. if (text1.length > text2.length) {
  80162. diffs[0][0] = diffs[2][0] = DIFF_DELETE;
  80163. }
  80164. return diffs;
  80165. }
  80166. if (shorttext.length === 1) {
  80167. // Single character string.
  80168. // After the previous speedup, the character can't be an equality.
  80169. return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
  80170. }
  80171. // Check to see if the problem can be split in two.
  80172. var hm = diff_halfMatch_(text1, text2);
  80173. if (hm) {
  80174. // A half-match was found, sort out the return data.
  80175. var text1_a = hm[0];
  80176. var text1_b = hm[1];
  80177. var text2_a = hm[2];
  80178. var text2_b = hm[3];
  80179. var mid_common = hm[4];
  80180. // Send both pairs off for separate processing.
  80181. var diffs_a = diff_main(text1_a, text2_a);
  80182. var diffs_b = diff_main(text1_b, text2_b);
  80183. // Merge the results.
  80184. return diffs_a.concat([[DIFF_EQUAL, mid_common]], diffs_b);
  80185. }
  80186. return diff_bisect_(text1, text2);
  80187. }
  80188. /**
  80189. * Find the 'middle snake' of a diff, split the problem in two
  80190. * and return the recursively constructed diff.
  80191. * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
  80192. * @param {string} text1 Old string to be diffed.
  80193. * @param {string} text2 New string to be diffed.
  80194. * @return {Array} Array of diff tuples.
  80195. * @private
  80196. */
  80197. function diff_bisect_(text1, text2) {
  80198. // Cache the text lengths to prevent multiple calls.
  80199. var text1_length = text1.length;
  80200. var text2_length = text2.length;
  80201. var max_d = Math.ceil((text1_length + text2_length) / 2);
  80202. var v_offset = max_d;
  80203. var v_length = 2 * max_d;
  80204. var v1 = new Array(v_length);
  80205. var v2 = new Array(v_length);
  80206. // Setting all elements to -1 is faster in Chrome & Firefox than mixing
  80207. // integers and undefined.
  80208. for (var x = 0; x < v_length; x++) {
  80209. v1[x] = -1;
  80210. v2[x] = -1;
  80211. }
  80212. v1[v_offset + 1] = 0;
  80213. v2[v_offset + 1] = 0;
  80214. var delta = text1_length - text2_length;
  80215. // If the total number of characters is odd, then the front path will collide
  80216. // with the reverse path.
  80217. var front = (delta % 2 !== 0);
  80218. // Offsets for start and end of k loop.
  80219. // Prevents mapping of space beyond the grid.
  80220. var k1start = 0;
  80221. var k1end = 0;
  80222. var k2start = 0;
  80223. var k2end = 0;
  80224. for (var d = 0; d < max_d; d++) {
  80225. // Walk the front path one step.
  80226. for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
  80227. var k1_offset = v_offset + k1;
  80228. var x1;
  80229. if (k1 === -d || (k1 !== d && v1[k1_offset - 1] < v1[k1_offset + 1])) {
  80230. x1 = v1[k1_offset + 1];
  80231. } else {
  80232. x1 = v1[k1_offset - 1] + 1;
  80233. }
  80234. var y1 = x1 - k1;
  80235. while (
  80236. x1 < text1_length && y1 < text2_length &&
  80237. text1.charAt(x1) === text2.charAt(y1)
  80238. ) {
  80239. x1++;
  80240. y1++;
  80241. }
  80242. v1[k1_offset] = x1;
  80243. if (x1 > text1_length) {
  80244. // Ran off the right of the graph.
  80245. k1end += 2;
  80246. } else if (y1 > text2_length) {
  80247. // Ran off the bottom of the graph.
  80248. k1start += 2;
  80249. } else if (front) {
  80250. var k2_offset = v_offset + delta - k1;
  80251. if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] !== -1) {
  80252. // Mirror x2 onto top-left coordinate system.
  80253. var x2 = text1_length - v2[k2_offset];
  80254. if (x1 >= x2) {
  80255. // Overlap detected.
  80256. return diff_bisectSplit_(text1, text2, x1, y1);
  80257. }
  80258. }
  80259. }
  80260. }
  80261. // Walk the reverse path one step.
  80262. for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
  80263. var k2_offset = v_offset + k2;
  80264. var x2;
  80265. if (k2 === -d || (k2 !== d && v2[k2_offset - 1] < v2[k2_offset + 1])) {
  80266. x2 = v2[k2_offset + 1];
  80267. } else {
  80268. x2 = v2[k2_offset - 1] + 1;
  80269. }
  80270. var y2 = x2 - k2;
  80271. while (
  80272. x2 < text1_length && y2 < text2_length &&
  80273. text1.charAt(text1_length - x2 - 1) === text2.charAt(text2_length - y2 - 1)
  80274. ) {
  80275. x2++;
  80276. y2++;
  80277. }
  80278. v2[k2_offset] = x2;
  80279. if (x2 > text1_length) {
  80280. // Ran off the left of the graph.
  80281. k2end += 2;
  80282. } else if (y2 > text2_length) {
  80283. // Ran off the top of the graph.
  80284. k2start += 2;
  80285. } else if (!front) {
  80286. var k1_offset = v_offset + delta - k2;
  80287. if (k1_offset >= 0 && k1_offset < v_length && v1[k1_offset] !== -1) {
  80288. var x1 = v1[k1_offset];
  80289. var y1 = v_offset + x1 - k1_offset;
  80290. // Mirror x2 onto top-left coordinate system.
  80291. x2 = text1_length - x2;
  80292. if (x1 >= x2) {
  80293. // Overlap detected.
  80294. return diff_bisectSplit_(text1, text2, x1, y1);
  80295. }
  80296. }
  80297. }
  80298. }
  80299. }
  80300. // Diff took too long and hit the deadline or
  80301. // number of diffs equals number of characters, no commonality at all.
  80302. return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
  80303. }
  80304. /**
  80305. * Given the location of the 'middle snake', split the diff in two parts
  80306. * and recurse.
  80307. * @param {string} text1 Old string to be diffed.
  80308. * @param {string} text2 New string to be diffed.
  80309. * @param {number} x Index of split point in text1.
  80310. * @param {number} y Index of split point in text2.
  80311. * @return {Array} Array of diff tuples.
  80312. */
  80313. function diff_bisectSplit_(text1, text2, x, y) {
  80314. var text1a = text1.substring(0, x);
  80315. var text2a = text2.substring(0, y);
  80316. var text1b = text1.substring(x);
  80317. var text2b = text2.substring(y);
  80318. // Compute both diffs serially.
  80319. var diffs = diff_main(text1a, text2a);
  80320. var diffsb = diff_main(text1b, text2b);
  80321. return diffs.concat(diffsb);
  80322. }
  80323. /**
  80324. * Determine the common prefix of two strings.
  80325. * @param {string} text1 First string.
  80326. * @param {string} text2 Second string.
  80327. * @return {number} The number of characters common to the start of each
  80328. * string.
  80329. */
  80330. function diff_commonPrefix(text1, text2) {
  80331. // Quick check for common null cases.
  80332. if (!text1 || !text2 || text1.charAt(0) !== text2.charAt(0)) {
  80333. return 0;
  80334. }
  80335. // Binary search.
  80336. // Performance analysis: http://neil.fraser.name/news/2007/10/09/
  80337. var pointermin = 0;
  80338. var pointermax = Math.min(text1.length, text2.length);
  80339. var pointermid = pointermax;
  80340. var pointerstart = 0;
  80341. while (pointermin < pointermid) {
  80342. if (
  80343. text1.substring(pointerstart, pointermid) ==
  80344. text2.substring(pointerstart, pointermid)
  80345. ) {
  80346. pointermin = pointermid;
  80347. pointerstart = pointermin;
  80348. } else {
  80349. pointermax = pointermid;
  80350. }
  80351. pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
  80352. }
  80353. if (is_surrogate_pair_start(text1.charCodeAt(pointermid - 1))) {
  80354. pointermid--;
  80355. }
  80356. return pointermid;
  80357. }
  80358. /**
  80359. * Determine the common suffix of two strings.
  80360. * @param {string} text1 First string.
  80361. * @param {string} text2 Second string.
  80362. * @return {number} The number of characters common to the end of each string.
  80363. */
  80364. function diff_commonSuffix(text1, text2) {
  80365. // Quick check for common null cases.
  80366. if (!text1 || !text2 || text1.slice(-1) !== text2.slice(-1)) {
  80367. return 0;
  80368. }
  80369. // Binary search.
  80370. // Performance analysis: http://neil.fraser.name/news/2007/10/09/
  80371. var pointermin = 0;
  80372. var pointermax = Math.min(text1.length, text2.length);
  80373. var pointermid = pointermax;
  80374. var pointerend = 0;
  80375. while (pointermin < pointermid) {
  80376. if (
  80377. text1.substring(text1.length - pointermid, text1.length - pointerend) ==
  80378. text2.substring(text2.length - pointermid, text2.length - pointerend)
  80379. ) {
  80380. pointermin = pointermid;
  80381. pointerend = pointermin;
  80382. } else {
  80383. pointermax = pointermid;
  80384. }
  80385. pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
  80386. }
  80387. if (is_surrogate_pair_end(text1.charCodeAt(text1.length - pointermid))) {
  80388. pointermid--;
  80389. }
  80390. return pointermid;
  80391. }
  80392. /**
  80393. * Do the two texts share a substring which is at least half the length of the
  80394. * longer text?
  80395. * This speedup can produce non-minimal diffs.
  80396. * @param {string} text1 First string.
  80397. * @param {string} text2 Second string.
  80398. * @return {Array.<string>} Five element Array, containing the prefix of
  80399. * text1, the suffix of text1, the prefix of text2, the suffix of
  80400. * text2 and the common middle. Or null if there was no match.
  80401. */
  80402. function diff_halfMatch_(text1, text2) {
  80403. var longtext = text1.length > text2.length ? text1 : text2;
  80404. var shorttext = text1.length > text2.length ? text2 : text1;
  80405. if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
  80406. return null; // Pointless.
  80407. }
  80408. /**
  80409. * Does a substring of shorttext exist within longtext such that the substring
  80410. * is at least half the length of longtext?
  80411. * Closure, but does not reference any external variables.
  80412. * @param {string} longtext Longer string.
  80413. * @param {string} shorttext Shorter string.
  80414. * @param {number} i Start index of quarter length substring within longtext.
  80415. * @return {Array.<string>} Five element Array, containing the prefix of
  80416. * longtext, the suffix of longtext, the prefix of shorttext, the suffix
  80417. * of shorttext and the common middle. Or null if there was no match.
  80418. * @private
  80419. */
  80420. function diff_halfMatchI_(longtext, shorttext, i) {
  80421. // Start with a 1/4 length substring at position i as a seed.
  80422. var seed = longtext.substring(i, i + Math.floor(longtext.length / 4));
  80423. var j = -1;
  80424. var best_common = '';
  80425. var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b;
  80426. while ((j = shorttext.indexOf(seed, j + 1)) !== -1) {
  80427. var prefixLength = diff_commonPrefix(
  80428. longtext.substring(i), shorttext.substring(j));
  80429. var suffixLength = diff_commonSuffix(
  80430. longtext.substring(0, i), shorttext.substring(0, j));
  80431. if (best_common.length < suffixLength + prefixLength) {
  80432. best_common = shorttext.substring(
  80433. j - suffixLength, j) + shorttext.substring(j, j + prefixLength);
  80434. best_longtext_a = longtext.substring(0, i - suffixLength);
  80435. best_longtext_b = longtext.substring(i + prefixLength);
  80436. best_shorttext_a = shorttext.substring(0, j - suffixLength);
  80437. best_shorttext_b = shorttext.substring(j + prefixLength);
  80438. }
  80439. }
  80440. if (best_common.length * 2 >= longtext.length) {
  80441. return [
  80442. best_longtext_a, best_longtext_b,
  80443. best_shorttext_a, best_shorttext_b, best_common
  80444. ];
  80445. } else {
  80446. return null;
  80447. }
  80448. }
  80449. // First check if the second quarter is the seed for a half-match.
  80450. var hm1 = diff_halfMatchI_(longtext, shorttext, Math.ceil(longtext.length / 4));
  80451. // Check again based on the third quarter.
  80452. var hm2 = diff_halfMatchI_(longtext, shorttext, Math.ceil(longtext.length / 2));
  80453. var hm;
  80454. if (!hm1 && !hm2) {
  80455. return null;
  80456. } else if (!hm2) {
  80457. hm = hm1;
  80458. } else if (!hm1) {
  80459. hm = hm2;
  80460. } else {
  80461. // Both matched. Select the longest.
  80462. hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
  80463. }
  80464. // A half-match was found, sort out the return data.
  80465. var text1_a, text1_b, text2_a, text2_b;
  80466. if (text1.length > text2.length) {
  80467. text1_a = hm[0];
  80468. text1_b = hm[1];
  80469. text2_a = hm[2];
  80470. text2_b = hm[3];
  80471. } else {
  80472. text2_a = hm[0];
  80473. text2_b = hm[1];
  80474. text1_a = hm[2];
  80475. text1_b = hm[3];
  80476. }
  80477. var mid_common = hm[4];
  80478. return [text1_a, text1_b, text2_a, text2_b, mid_common];
  80479. }
  80480. /**
  80481. * Reorder and merge like edit sections. Merge equalities.
  80482. * Any edit section can move as long as it doesn't cross an equality.
  80483. * @param {Array} diffs Array of diff tuples.
  80484. * @param {boolean} fix_unicode Whether to normalize to a unicode-correct diff
  80485. */
  80486. function diff_cleanupMerge(diffs, fix_unicode) {
  80487. diffs.push([DIFF_EQUAL, '']); // Add a dummy entry at the end.
  80488. var pointer = 0;
  80489. var count_delete = 0;
  80490. var count_insert = 0;
  80491. var text_delete = '';
  80492. var text_insert = '';
  80493. var commonlength;
  80494. while (pointer < diffs.length) {
  80495. if (pointer < diffs.length - 1 && !diffs[pointer][1]) {
  80496. diffs.splice(pointer, 1);
  80497. continue;
  80498. }
  80499. switch (diffs[pointer][0]) {
  80500. case DIFF_INSERT:
  80501. count_insert++;
  80502. text_insert += diffs[pointer][1];
  80503. pointer++;
  80504. break;
  80505. case DIFF_DELETE:
  80506. count_delete++;
  80507. text_delete += diffs[pointer][1];
  80508. pointer++;
  80509. break;
  80510. case DIFF_EQUAL:
  80511. var previous_equality = pointer - count_insert - count_delete - 1;
  80512. if (fix_unicode) {
  80513. // prevent splitting of unicode surrogate pairs. when fix_unicode is true,
  80514. // we assume that the old and new text in the diff are complete and correct
  80515. // unicode-encoded JS strings, but the tuple boundaries may fall between
  80516. // surrogate pairs. we fix this by shaving off stray surrogates from the end
  80517. // of the previous equality and the beginning of this equality. this may create
  80518. // empty equalities or a common prefix or suffix. for example, if AB and AC are
  80519. // emojis, `[[0, 'A'], [-1, 'BA'], [0, 'C']]` would turn into deleting 'ABAC' and
  80520. // inserting 'AC', and then the common suffix 'AC' will be eliminated. in this
  80521. // particular case, both equalities go away, we absorb any previous inequalities,
  80522. // and we keep scanning for the next equality before rewriting the tuples.
  80523. if (previous_equality >= 0 && ends_with_pair_start(diffs[previous_equality][1])) {
  80524. var stray = diffs[previous_equality][1].slice(-1);
  80525. diffs[previous_equality][1] = diffs[previous_equality][1].slice(0, -1);
  80526. text_delete = stray + text_delete;
  80527. text_insert = stray + text_insert;
  80528. if (!diffs[previous_equality][1]) {
  80529. // emptied out previous equality, so delete it and include previous delete/insert
  80530. diffs.splice(previous_equality, 1);
  80531. pointer--;
  80532. var k = previous_equality - 1;
  80533. if (diffs[k] && diffs[k][0] === DIFF_INSERT) {
  80534. count_insert++;
  80535. text_insert = diffs[k][1] + text_insert;
  80536. k--;
  80537. }
  80538. if (diffs[k] && diffs[k][0] === DIFF_DELETE) {
  80539. count_delete++;
  80540. text_delete = diffs[k][1] + text_delete;
  80541. k--;
  80542. }
  80543. previous_equality = k;
  80544. }
  80545. }
  80546. if (starts_with_pair_end(diffs[pointer][1])) {
  80547. var stray = diffs[pointer][1].charAt(0);
  80548. diffs[pointer][1] = diffs[pointer][1].slice(1);
  80549. text_delete += stray;
  80550. text_insert += stray;
  80551. }
  80552. }
  80553. if (pointer < diffs.length - 1 && !diffs[pointer][1]) {
  80554. // for empty equality not at end, wait for next equality
  80555. diffs.splice(pointer, 1);
  80556. break;
  80557. }
  80558. if (text_delete.length > 0 || text_insert.length > 0) {
  80559. // note that diff_commonPrefix and diff_commonSuffix are unicode-aware
  80560. if (text_delete.length > 0 && text_insert.length > 0) {
  80561. // Factor out any common prefixes.
  80562. commonlength = diff_commonPrefix(text_insert, text_delete);
  80563. if (commonlength !== 0) {
  80564. if (previous_equality >= 0) {
  80565. diffs[previous_equality][1] += text_insert.substring(0, commonlength);
  80566. } else {
  80567. diffs.splice(0, 0, [DIFF_EQUAL, text_insert.substring(0, commonlength)]);
  80568. pointer++;
  80569. }
  80570. text_insert = text_insert.substring(commonlength);
  80571. text_delete = text_delete.substring(commonlength);
  80572. }
  80573. // Factor out any common suffixes.
  80574. commonlength = diff_commonSuffix(text_insert, text_delete);
  80575. if (commonlength !== 0) {
  80576. diffs[pointer][1] =
  80577. text_insert.substring(text_insert.length - commonlength) + diffs[pointer][1];
  80578. text_insert = text_insert.substring(0, text_insert.length - commonlength);
  80579. text_delete = text_delete.substring(0, text_delete.length - commonlength);
  80580. }
  80581. }
  80582. // Delete the offending records and add the merged ones.
  80583. var n = count_insert + count_delete;
  80584. if (text_delete.length === 0 && text_insert.length === 0) {
  80585. diffs.splice(pointer - n, n);
  80586. pointer = pointer - n;
  80587. } else if (text_delete.length === 0) {
  80588. diffs.splice(pointer - n, n, [DIFF_INSERT, text_insert]);
  80589. pointer = pointer - n + 1;
  80590. } else if (text_insert.length === 0) {
  80591. diffs.splice(pointer - n, n, [DIFF_DELETE, text_delete]);
  80592. pointer = pointer - n + 1;
  80593. } else {
  80594. diffs.splice(pointer - n, n, [DIFF_DELETE, text_delete], [DIFF_INSERT, text_insert]);
  80595. pointer = pointer - n + 2;
  80596. }
  80597. }
  80598. if (pointer !== 0 && diffs[pointer - 1][0] === DIFF_EQUAL) {
  80599. // Merge this equality with the previous one.
  80600. diffs[pointer - 1][1] += diffs[pointer][1];
  80601. diffs.splice(pointer, 1);
  80602. } else {
  80603. pointer++;
  80604. }
  80605. count_insert = 0;
  80606. count_delete = 0;
  80607. text_delete = '';
  80608. text_insert = '';
  80609. break;
  80610. }
  80611. }
  80612. if (diffs[diffs.length - 1][1] === '') {
  80613. diffs.pop(); // Remove the dummy entry at the end.
  80614. }
  80615. // Second pass: look for single edits surrounded on both sides by equalities
  80616. // which can be shifted sideways to eliminate an equality.
  80617. // e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
  80618. var changes = false;
  80619. pointer = 1;
  80620. // Intentionally ignore the first and last element (don't need checking).
  80621. while (pointer < diffs.length - 1) {
  80622. if (diffs[pointer - 1][0] === DIFF_EQUAL &&
  80623. diffs[pointer + 1][0] === DIFF_EQUAL) {
  80624. // This is a single edit surrounded by equalities.
  80625. if (diffs[pointer][1].substring(diffs[pointer][1].length -
  80626. diffs[pointer - 1][1].length) === diffs[pointer - 1][1]) {
  80627. // Shift the edit over the previous equality.
  80628. diffs[pointer][1] = diffs[pointer - 1][1] +
  80629. diffs[pointer][1].substring(0, diffs[pointer][1].length -
  80630. diffs[pointer - 1][1].length);
  80631. diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
  80632. diffs.splice(pointer - 1, 1);
  80633. changes = true;
  80634. } else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) ==
  80635. diffs[pointer + 1][1]) {
  80636. // Shift the edit over the next equality.
  80637. diffs[pointer - 1][1] += diffs[pointer + 1][1];
  80638. diffs[pointer][1] =
  80639. diffs[pointer][1].substring(diffs[pointer + 1][1].length) +
  80640. diffs[pointer + 1][1];
  80641. diffs.splice(pointer + 1, 1);
  80642. changes = true;
  80643. }
  80644. }
  80645. pointer++;
  80646. }
  80647. // If shifts were made, the diff needs reordering and another shift sweep.
  80648. if (changes) {
  80649. diff_cleanupMerge(diffs, fix_unicode);
  80650. }
  80651. }
  80652. function is_surrogate_pair_start(charCode) {
  80653. return charCode >= 0xD800 && charCode <= 0xDBFF;
  80654. }
  80655. function is_surrogate_pair_end(charCode) {
  80656. return charCode >= 0xDC00 && charCode <= 0xDFFF;
  80657. }
  80658. function starts_with_pair_end(str) {
  80659. return is_surrogate_pair_end(str.charCodeAt(0));
  80660. }
  80661. function ends_with_pair_start(str) {
  80662. return is_surrogate_pair_start(str.charCodeAt(str.length - 1));
  80663. }
  80664. function remove_empty_tuples(tuples) {
  80665. var ret = [];
  80666. for (var i = 0; i < tuples.length; i++) {
  80667. if (tuples[i][1].length > 0) {
  80668. ret.push(tuples[i]);
  80669. }
  80670. }
  80671. return ret;
  80672. }
  80673. function make_edit_splice(before, oldMiddle, newMiddle, after) {
  80674. if (ends_with_pair_start(before) || starts_with_pair_end(after)) {
  80675. return null;
  80676. }
  80677. return remove_empty_tuples([
  80678. [DIFF_EQUAL, before],
  80679. [DIFF_DELETE, oldMiddle],
  80680. [DIFF_INSERT, newMiddle],
  80681. [DIFF_EQUAL, after]
  80682. ]);
  80683. }
  80684. function find_cursor_edit_diff(oldText, newText, cursor_pos) {
  80685. // note: this runs after equality check has ruled out exact equality
  80686. var oldRange = typeof cursor_pos === 'number' ?
  80687. { index: cursor_pos, length: 0 } : cursor_pos.oldRange;
  80688. var newRange = typeof cursor_pos === 'number' ?
  80689. null : cursor_pos.newRange;
  80690. // take into account the old and new selection to generate the best diff
  80691. // possible for a text edit. for example, a text change from "xxx" to "xx"
  80692. // could be a delete or forwards-delete of any one of the x's, or the
  80693. // result of selecting two of the x's and typing "x".
  80694. var oldLength = oldText.length;
  80695. var newLength = newText.length;
  80696. if (oldRange.length === 0 && (newRange === null || newRange.length === 0)) {
  80697. // see if we have an insert or delete before or after cursor
  80698. var oldCursor = oldRange.index;
  80699. var oldBefore = oldText.slice(0, oldCursor);
  80700. var oldAfter = oldText.slice(oldCursor);
  80701. var maybeNewCursor = newRange ? newRange.index : null;
  80702. editBefore: {
  80703. // is this an insert or delete right before oldCursor?
  80704. var newCursor = oldCursor + newLength - oldLength;
  80705. if (maybeNewCursor !== null && maybeNewCursor !== newCursor) {
  80706. break editBefore;
  80707. }
  80708. if (newCursor < 0 || newCursor > newLength) {
  80709. break editBefore;
  80710. }
  80711. var newBefore = newText.slice(0, newCursor);
  80712. var newAfter = newText.slice(newCursor);
  80713. if (newAfter !== oldAfter) {
  80714. break editBefore;
  80715. }
  80716. var prefixLength = Math.min(oldCursor, newCursor);
  80717. var oldPrefix = oldBefore.slice(0, prefixLength);
  80718. var newPrefix = newBefore.slice(0, prefixLength);
  80719. if (oldPrefix !== newPrefix) {
  80720. break editBefore;
  80721. }
  80722. var oldMiddle = oldBefore.slice(prefixLength);
  80723. var newMiddle = newBefore.slice(prefixLength);
  80724. return make_edit_splice(oldPrefix, oldMiddle, newMiddle, oldAfter);
  80725. }
  80726. editAfter: {
  80727. // is this an insert or delete right after oldCursor?
  80728. if (maybeNewCursor !== null && maybeNewCursor !== oldCursor) {
  80729. break editAfter;
  80730. }
  80731. var cursor = oldCursor;
  80732. var newBefore = newText.slice(0, cursor);
  80733. var newAfter = newText.slice(cursor);
  80734. if (newBefore !== oldBefore) {
  80735. break editAfter;
  80736. }
  80737. var suffixLength = Math.min(oldLength - cursor, newLength - cursor);
  80738. var oldSuffix = oldAfter.slice(oldAfter.length - suffixLength);
  80739. var newSuffix = newAfter.slice(newAfter.length - suffixLength);
  80740. if (oldSuffix !== newSuffix) {
  80741. break editAfter;
  80742. }
  80743. var oldMiddle = oldAfter.slice(0, oldAfter.length - suffixLength);
  80744. var newMiddle = newAfter.slice(0, newAfter.length - suffixLength);
  80745. return make_edit_splice(oldBefore, oldMiddle, newMiddle, oldSuffix);
  80746. }
  80747. }
  80748. if (oldRange.length > 0 && newRange && newRange.length === 0) {
  80749. replaceRange: {
  80750. // see if diff could be a splice of the old selection range
  80751. var oldPrefix = oldText.slice(0, oldRange.index);
  80752. var oldSuffix = oldText.slice(oldRange.index + oldRange.length);
  80753. var prefixLength = oldPrefix.length;
  80754. var suffixLength = oldSuffix.length;
  80755. if (newLength < prefixLength + suffixLength) {
  80756. break replaceRange;
  80757. }
  80758. var newPrefix = newText.slice(0, prefixLength);
  80759. var newSuffix = newText.slice(newLength - suffixLength);
  80760. if (oldPrefix !== newPrefix || oldSuffix !== newSuffix) {
  80761. break replaceRange;
  80762. }
  80763. var oldMiddle = oldText.slice(prefixLength, oldLength - suffixLength);
  80764. var newMiddle = newText.slice(prefixLength, newLength - suffixLength);
  80765. return make_edit_splice(oldPrefix, oldMiddle, newMiddle, oldSuffix);
  80766. }
  80767. }
  80768. return null;
  80769. }
  80770. function diff$1(text1, text2, cursor_pos) {
  80771. // only pass fix_unicode=true at the top level, not when diff_main is
  80772. // recursively invoked
  80773. return diff_main(text1, text2, cursor_pos, true);
  80774. }
  80775. diff$1.INSERT = DIFF_INSERT;
  80776. diff$1.DELETE = DIFF_DELETE;
  80777. diff$1.EQUAL = DIFF_EQUAL;
  80778. var diff_1$2 = diff$1;
  80779. /**
  80780. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  80781. *
  80782. * Licensed under the Apache License, Version 2.0 (the "License");
  80783. * you may not use this file except in compliance with the License.
  80784. * You may obtain a copy of the License at
  80785. *
  80786. * http://www.apache.org/licenses/LICENSE-2.0
  80787. *
  80788. * Unless required by applicable law or agreed to in writing, software
  80789. * distributed under the License is distributed on an "AS IS" BASIS,
  80790. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  80791. * See the License for the specific language governing permissions and
  80792. * limitations under the License.
  80793. */
  80794. /**
  80795. * 更新内容时保持光标不变
  80796. * @param {Number} pos 光标相对文档开头的偏移量
  80797. * @param {String} oldContent 变更前的内容
  80798. * @param {String} newContent 变更后的内容
  80799. * @returns {Number} newPos 新的光标偏移量
  80800. */
  80801. function getPosBydiffs(pos, oldContent, newContent) {
  80802. var diffs = diff_1$2(oldContent, newContent);
  80803. var newPos = pos;
  80804. var tmpPos = pos;
  80805. for (var i = 0; i < diffs.length; i++) {
  80806. var val = diffs[i];
  80807. if (tmpPos <= 0) {
  80808. return newPos;
  80809. }
  80810. var opType = val[0];
  80811. var opLength = val[1].length;
  80812. switch (opType) {
  80813. // 没有改变的内容
  80814. case diff_1$2.EQUAL:
  80815. if (tmpPos <= opLength) {
  80816. return newPos;
  80817. }
  80818. tmpPos -= opLength;
  80819. break;
  80820. // 删除的内容
  80821. case diff_1$2.DELETE:
  80822. if (tmpPos <= opLength) {
  80823. return newPos - opLength + tmpPos;
  80824. }
  80825. tmpPos -= opLength;
  80826. newPos -= opLength;
  80827. break;
  80828. // 新增的内容
  80829. case diff_1$2.INSERT:
  80830. newPos += opLength;
  80831. break;
  80832. }
  80833. }
  80834. return newPos;
  80835. }
  80836. /**
  80837. * A specialized version of `_.forEach` for arrays without support for
  80838. * iteratee shorthands.
  80839. *
  80840. * @private
  80841. * @param {Array} [array] The array to iterate over.
  80842. * @param {Function} iteratee The function invoked per iteration.
  80843. * @returns {Array} Returns `array`.
  80844. */
  80845. function arrayEach(array, iteratee) {
  80846. var index = -1,
  80847. length = array == null ? 0 : array.length;
  80848. while (++index < length) {
  80849. if (iteratee(array[index], index, array) === false) {
  80850. break;
  80851. }
  80852. }
  80853. return array;
  80854. }
  80855. var _arrayEach = arrayEach;
  80856. /* Built-in method references for those with the same name as other `lodash` methods. */
  80857. var nativeKeys = _overArg(Object.keys, Object);
  80858. var _nativeKeys = nativeKeys;
  80859. /** Used for built-in method references. */
  80860. var objectProto$b = Object.prototype;
  80861. /** Used to check objects for own properties. */
  80862. var hasOwnProperty$a = objectProto$b.hasOwnProperty;
  80863. /**
  80864. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  80865. *
  80866. * @private
  80867. * @param {Object} object The object to query.
  80868. * @returns {Array} Returns the array of property names.
  80869. */
  80870. function baseKeys(object) {
  80871. if (!_isPrototype(object)) {
  80872. return _nativeKeys(object);
  80873. }
  80874. var result = [];
  80875. for (var key in Object(object)) {
  80876. if (hasOwnProperty$a.call(object, key) && key != 'constructor') {
  80877. result.push(key);
  80878. }
  80879. }
  80880. return result;
  80881. }
  80882. var _baseKeys = baseKeys;
  80883. /**
  80884. * Creates an array of the own enumerable property names of `object`.
  80885. *
  80886. * **Note:** Non-object values are coerced to objects. See the
  80887. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  80888. * for more details.
  80889. *
  80890. * @static
  80891. * @since 0.1.0
  80892. * @memberOf _
  80893. * @category Object
  80894. * @param {Object} object The object to query.
  80895. * @returns {Array} Returns the array of property names.
  80896. * @example
  80897. *
  80898. * function Foo() {
  80899. * this.a = 1;
  80900. * this.b = 2;
  80901. * }
  80902. *
  80903. * Foo.prototype.c = 3;
  80904. *
  80905. * _.keys(new Foo);
  80906. * // => ['a', 'b'] (iteration order is not guaranteed)
  80907. *
  80908. * _.keys('hi');
  80909. * // => ['0', '1']
  80910. */
  80911. function keys$8(object) {
  80912. return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
  80913. }
  80914. var keys_1 = keys$8;
  80915. /**
  80916. * The base implementation of `_.assign` without support for multiple sources
  80917. * or `customizer` functions.
  80918. *
  80919. * @private
  80920. * @param {Object} object The destination object.
  80921. * @param {Object} source The source object.
  80922. * @returns {Object} Returns `object`.
  80923. */
  80924. function baseAssign(object, source) {
  80925. return object && _copyObject(source, keys_1(source), object);
  80926. }
  80927. var _baseAssign = baseAssign;
  80928. /**
  80929. * The base implementation of `_.assignIn` without support for multiple sources
  80930. * or `customizer` functions.
  80931. *
  80932. * @private
  80933. * @param {Object} object The destination object.
  80934. * @param {Object} source The source object.
  80935. * @returns {Object} Returns `object`.
  80936. */
  80937. function baseAssignIn(object, source) {
  80938. return object && _copyObject(source, keysIn_1(source), object);
  80939. }
  80940. var _baseAssignIn = baseAssignIn;
  80941. /**
  80942. * A specialized version of `_.filter` for arrays without support for
  80943. * iteratee shorthands.
  80944. *
  80945. * @private
  80946. * @param {Array} [array] The array to iterate over.
  80947. * @param {Function} predicate The function invoked per iteration.
  80948. * @returns {Array} Returns the new filtered array.
  80949. */
  80950. function arrayFilter(array, predicate) {
  80951. var index = -1,
  80952. length = array == null ? 0 : array.length,
  80953. resIndex = 0,
  80954. result = [];
  80955. while (++index < length) {
  80956. var value = array[index];
  80957. if (predicate(value, index, array)) {
  80958. result[resIndex++] = value;
  80959. }
  80960. }
  80961. return result;
  80962. }
  80963. var _arrayFilter = arrayFilter;
  80964. /**
  80965. * This method returns a new empty array.
  80966. *
  80967. * @static
  80968. * @memberOf _
  80969. * @since 4.13.0
  80970. * @category Util
  80971. * @returns {Array} Returns the new empty array.
  80972. * @example
  80973. *
  80974. * var arrays = _.times(2, _.stubArray);
  80975. *
  80976. * console.log(arrays);
  80977. * // => [[], []]
  80978. *
  80979. * console.log(arrays[0] === arrays[1]);
  80980. * // => false
  80981. */
  80982. function stubArray() {
  80983. return [];
  80984. }
  80985. var stubArray_1 = stubArray;
  80986. /** Used for built-in method references. */
  80987. var objectProto$c = Object.prototype;
  80988. /** Built-in value references. */
  80989. var propertyIsEnumerable$2 = objectProto$c.propertyIsEnumerable;
  80990. /* Built-in method references for those with the same name as other `lodash` methods. */
  80991. var nativeGetSymbols = Object.getOwnPropertySymbols;
  80992. /**
  80993. * Creates an array of the own enumerable symbols of `object`.
  80994. *
  80995. * @private
  80996. * @param {Object} object The object to query.
  80997. * @returns {Array} Returns the array of symbols.
  80998. */
  80999. var getSymbols = !nativeGetSymbols ? stubArray_1 : function(object) {
  81000. if (object == null) {
  81001. return [];
  81002. }
  81003. object = Object(object);
  81004. return _arrayFilter(nativeGetSymbols(object), function(symbol) {
  81005. return propertyIsEnumerable$2.call(object, symbol);
  81006. });
  81007. };
  81008. var _getSymbols = getSymbols;
  81009. /**
  81010. * Copies own symbols of `source` to `object`.
  81011. *
  81012. * @private
  81013. * @param {Object} source The object to copy symbols from.
  81014. * @param {Object} [object={}] The object to copy symbols to.
  81015. * @returns {Object} Returns `object`.
  81016. */
  81017. function copySymbols(source, object) {
  81018. return _copyObject(source, _getSymbols(source), object);
  81019. }
  81020. var _copySymbols = copySymbols;
  81021. /**
  81022. * Appends the elements of `values` to `array`.
  81023. *
  81024. * @private
  81025. * @param {Array} array The array to modify.
  81026. * @param {Array} values The values to append.
  81027. * @returns {Array} Returns `array`.
  81028. */
  81029. function arrayPush(array, values) {
  81030. var index = -1,
  81031. length = values.length,
  81032. offset = array.length;
  81033. while (++index < length) {
  81034. array[offset + index] = values[index];
  81035. }
  81036. return array;
  81037. }
  81038. var _arrayPush = arrayPush;
  81039. /* Built-in method references for those with the same name as other `lodash` methods. */
  81040. var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
  81041. /**
  81042. * Creates an array of the own and inherited enumerable symbols of `object`.
  81043. *
  81044. * @private
  81045. * @param {Object} object The object to query.
  81046. * @returns {Array} Returns the array of symbols.
  81047. */
  81048. var getSymbolsIn = !nativeGetSymbols$1 ? stubArray_1 : function(object) {
  81049. var result = [];
  81050. while (object) {
  81051. _arrayPush(result, _getSymbols(object));
  81052. object = _getPrototype(object);
  81053. }
  81054. return result;
  81055. };
  81056. var _getSymbolsIn = getSymbolsIn;
  81057. /**
  81058. * Copies own and inherited symbols of `source` to `object`.
  81059. *
  81060. * @private
  81061. * @param {Object} source The object to copy symbols from.
  81062. * @param {Object} [object={}] The object to copy symbols to.
  81063. * @returns {Object} Returns `object`.
  81064. */
  81065. function copySymbolsIn(source, object) {
  81066. return _copyObject(source, _getSymbolsIn(source), object);
  81067. }
  81068. var _copySymbolsIn = copySymbolsIn;
  81069. /**
  81070. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  81071. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  81072. * symbols of `object`.
  81073. *
  81074. * @private
  81075. * @param {Object} object The object to query.
  81076. * @param {Function} keysFunc The function to get the keys of `object`.
  81077. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  81078. * @returns {Array} Returns the array of property names and symbols.
  81079. */
  81080. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  81081. var result = keysFunc(object);
  81082. return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
  81083. }
  81084. var _baseGetAllKeys = baseGetAllKeys;
  81085. /**
  81086. * Creates an array of own enumerable property names and symbols of `object`.
  81087. *
  81088. * @private
  81089. * @param {Object} object The object to query.
  81090. * @returns {Array} Returns the array of property names and symbols.
  81091. */
  81092. function getAllKeys(object) {
  81093. return _baseGetAllKeys(object, keys_1, _getSymbols);
  81094. }
  81095. var _getAllKeys = getAllKeys;
  81096. /**
  81097. * Creates an array of own and inherited enumerable property names and
  81098. * symbols of `object`.
  81099. *
  81100. * @private
  81101. * @param {Object} object The object to query.
  81102. * @returns {Array} Returns the array of property names and symbols.
  81103. */
  81104. function getAllKeysIn(object) {
  81105. return _baseGetAllKeys(object, keysIn_1, _getSymbolsIn);
  81106. }
  81107. var _getAllKeysIn = getAllKeysIn;
  81108. /* Built-in method references that are verified to be native. */
  81109. var DataView$1 = _getNative(_root, 'DataView');
  81110. var _DataView = DataView$1;
  81111. /* Built-in method references that are verified to be native. */
  81112. var Promise$2 = _getNative(_root, 'Promise');
  81113. var _Promise = Promise$2;
  81114. /* Built-in method references that are verified to be native. */
  81115. var Set$1 = _getNative(_root, 'Set');
  81116. var _Set = Set$1;
  81117. /* Built-in method references that are verified to be native. */
  81118. var WeakMap$2 = _getNative(_root, 'WeakMap');
  81119. var _WeakMap = WeakMap$2;
  81120. /** `Object#toString` result references. */
  81121. var mapTag$1 = '[object Map]',
  81122. objectTag$2 = '[object Object]',
  81123. promiseTag = '[object Promise]',
  81124. setTag$1 = '[object Set]',
  81125. weakMapTag$1 = '[object WeakMap]';
  81126. var dataViewTag$1 = '[object DataView]';
  81127. /** Used to detect maps, sets, and weakmaps. */
  81128. var dataViewCtorString = _toSource(_DataView),
  81129. mapCtorString = _toSource(_Map),
  81130. promiseCtorString = _toSource(_Promise),
  81131. setCtorString = _toSource(_Set),
  81132. weakMapCtorString = _toSource(_WeakMap);
  81133. /**
  81134. * Gets the `toStringTag` of `value`.
  81135. *
  81136. * @private
  81137. * @param {*} value The value to query.
  81138. * @returns {string} Returns the `toStringTag`.
  81139. */
  81140. var getTag = _baseGetTag;
  81141. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  81142. if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
  81143. (_Map && getTag(new _Map) != mapTag$1) ||
  81144. (_Promise && getTag(_Promise.resolve()) != promiseTag) ||
  81145. (_Set && getTag(new _Set) != setTag$1) ||
  81146. (_WeakMap && getTag(new _WeakMap) != weakMapTag$1)) {
  81147. getTag = function(value) {
  81148. var result = _baseGetTag(value),
  81149. Ctor = result == objectTag$2 ? value.constructor : undefined,
  81150. ctorString = Ctor ? _toSource(Ctor) : '';
  81151. if (ctorString) {
  81152. switch (ctorString) {
  81153. case dataViewCtorString: return dataViewTag$1;
  81154. case mapCtorString: return mapTag$1;
  81155. case promiseCtorString: return promiseTag;
  81156. case setCtorString: return setTag$1;
  81157. case weakMapCtorString: return weakMapTag$1;
  81158. }
  81159. }
  81160. return result;
  81161. };
  81162. }
  81163. var _getTag = getTag;
  81164. /** Used for built-in method references. */
  81165. var objectProto$d = Object.prototype;
  81166. /** Used to check objects for own properties. */
  81167. var hasOwnProperty$b = objectProto$d.hasOwnProperty;
  81168. /**
  81169. * Initializes an array clone.
  81170. *
  81171. * @private
  81172. * @param {Array} array The array to clone.
  81173. * @returns {Array} Returns the initialized clone.
  81174. */
  81175. function initCloneArray(array) {
  81176. var length = array.length,
  81177. result = new array.constructor(length);
  81178. // Add properties assigned by `RegExp#exec`.
  81179. if (length && typeof array[0] == 'string' && hasOwnProperty$b.call(array, 'index')) {
  81180. result.index = array.index;
  81181. result.input = array.input;
  81182. }
  81183. return result;
  81184. }
  81185. var _initCloneArray = initCloneArray;
  81186. /**
  81187. * Creates a clone of `dataView`.
  81188. *
  81189. * @private
  81190. * @param {Object} dataView The data view to clone.
  81191. * @param {boolean} [isDeep] Specify a deep clone.
  81192. * @returns {Object} Returns the cloned data view.
  81193. */
  81194. function cloneDataView(dataView, isDeep) {
  81195. var buffer = isDeep ? _cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  81196. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  81197. }
  81198. var _cloneDataView = cloneDataView;
  81199. /** Used to match `RegExp` flags from their coerced string values. */
  81200. var reFlags = /\w*$/;
  81201. /**
  81202. * Creates a clone of `regexp`.
  81203. *
  81204. * @private
  81205. * @param {Object} regexp The regexp to clone.
  81206. * @returns {Object} Returns the cloned regexp.
  81207. */
  81208. function cloneRegExp(regexp) {
  81209. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  81210. result.lastIndex = regexp.lastIndex;
  81211. return result;
  81212. }
  81213. var _cloneRegExp = cloneRegExp;
  81214. /** Used to convert symbols to primitives and strings. */
  81215. var symbolProto$1 = _Symbol ? _Symbol.prototype : undefined,
  81216. symbolValueOf = symbolProto$1 ? symbolProto$1.valueOf : undefined;
  81217. /**
  81218. * Creates a clone of the `symbol` object.
  81219. *
  81220. * @private
  81221. * @param {Object} symbol The symbol object to clone.
  81222. * @returns {Object} Returns the cloned symbol object.
  81223. */
  81224. function cloneSymbol(symbol) {
  81225. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  81226. }
  81227. var _cloneSymbol = cloneSymbol;
  81228. /** `Object#toString` result references. */
  81229. var boolTag$1 = '[object Boolean]',
  81230. dateTag$1 = '[object Date]',
  81231. mapTag$2 = '[object Map]',
  81232. numberTag$1 = '[object Number]',
  81233. regexpTag$1 = '[object RegExp]',
  81234. setTag$2 = '[object Set]',
  81235. stringTag$1 = '[object String]',
  81236. symbolTag$1 = '[object Symbol]';
  81237. var arrayBufferTag$1 = '[object ArrayBuffer]',
  81238. dataViewTag$2 = '[object DataView]',
  81239. float32Tag$1 = '[object Float32Array]',
  81240. float64Tag$1 = '[object Float64Array]',
  81241. int8Tag$1 = '[object Int8Array]',
  81242. int16Tag$1 = '[object Int16Array]',
  81243. int32Tag$1 = '[object Int32Array]',
  81244. uint8Tag$1 = '[object Uint8Array]',
  81245. uint8ClampedTag$1 = '[object Uint8ClampedArray]',
  81246. uint16Tag$1 = '[object Uint16Array]',
  81247. uint32Tag$1 = '[object Uint32Array]';
  81248. /**
  81249. * Initializes an object clone based on its `toStringTag`.
  81250. *
  81251. * **Note:** This function only supports cloning values with tags of
  81252. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  81253. *
  81254. * @private
  81255. * @param {Object} object The object to clone.
  81256. * @param {string} tag The `toStringTag` of the object to clone.
  81257. * @param {boolean} [isDeep] Specify a deep clone.
  81258. * @returns {Object} Returns the initialized clone.
  81259. */
  81260. function initCloneByTag(object, tag, isDeep) {
  81261. var Ctor = object.constructor;
  81262. switch (tag) {
  81263. case arrayBufferTag$1:
  81264. return _cloneArrayBuffer(object);
  81265. case boolTag$1:
  81266. case dateTag$1:
  81267. return new Ctor(+object);
  81268. case dataViewTag$2:
  81269. return _cloneDataView(object, isDeep);
  81270. case float32Tag$1: case float64Tag$1:
  81271. case int8Tag$1: case int16Tag$1: case int32Tag$1:
  81272. case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
  81273. return _cloneTypedArray(object, isDeep);
  81274. case mapTag$2:
  81275. return new Ctor;
  81276. case numberTag$1:
  81277. case stringTag$1:
  81278. return new Ctor(object);
  81279. case regexpTag$1:
  81280. return _cloneRegExp(object);
  81281. case setTag$2:
  81282. return new Ctor;
  81283. case symbolTag$1:
  81284. return _cloneSymbol(object);
  81285. }
  81286. }
  81287. var _initCloneByTag = initCloneByTag;
  81288. /** `Object#toString` result references. */
  81289. var mapTag$3 = '[object Map]';
  81290. /**
  81291. * The base implementation of `_.isMap` without Node.js optimizations.
  81292. *
  81293. * @private
  81294. * @param {*} value The value to check.
  81295. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  81296. */
  81297. function baseIsMap(value) {
  81298. return isObjectLike_1(value) && _getTag(value) == mapTag$3;
  81299. }
  81300. var _baseIsMap = baseIsMap;
  81301. /* Node.js helper references. */
  81302. var nodeIsMap = _nodeUtil && _nodeUtil.isMap;
  81303. /**
  81304. * Checks if `value` is classified as a `Map` object.
  81305. *
  81306. * @static
  81307. * @memberOf _
  81308. * @since 4.3.0
  81309. * @category Lang
  81310. * @param {*} value The value to check.
  81311. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  81312. * @example
  81313. *
  81314. * _.isMap(new Map);
  81315. * // => true
  81316. *
  81317. * _.isMap(new WeakMap);
  81318. * // => false
  81319. */
  81320. var isMap = nodeIsMap ? _baseUnary(nodeIsMap) : _baseIsMap;
  81321. var isMap_1 = isMap;
  81322. /** `Object#toString` result references. */
  81323. var setTag$3 = '[object Set]';
  81324. /**
  81325. * The base implementation of `_.isSet` without Node.js optimizations.
  81326. *
  81327. * @private
  81328. * @param {*} value The value to check.
  81329. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  81330. */
  81331. function baseIsSet(value) {
  81332. return isObjectLike_1(value) && _getTag(value) == setTag$3;
  81333. }
  81334. var _baseIsSet = baseIsSet;
  81335. /* Node.js helper references. */
  81336. var nodeIsSet = _nodeUtil && _nodeUtil.isSet;
  81337. /**
  81338. * Checks if `value` is classified as a `Set` object.
  81339. *
  81340. * @static
  81341. * @memberOf _
  81342. * @since 4.3.0
  81343. * @category Lang
  81344. * @param {*} value The value to check.
  81345. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  81346. * @example
  81347. *
  81348. * _.isSet(new Set);
  81349. * // => true
  81350. *
  81351. * _.isSet(new WeakSet);
  81352. * // => false
  81353. */
  81354. var isSet = nodeIsSet ? _baseUnary(nodeIsSet) : _baseIsSet;
  81355. var isSet_1 = isSet;
  81356. /** Used to compose bitmasks for cloning. */
  81357. var CLONE_DEEP_FLAG = 1,
  81358. CLONE_FLAT_FLAG = 2,
  81359. CLONE_SYMBOLS_FLAG = 4;
  81360. /** `Object#toString` result references. */
  81361. var argsTag$2 = '[object Arguments]',
  81362. arrayTag$1 = '[object Array]',
  81363. boolTag$2 = '[object Boolean]',
  81364. dateTag$2 = '[object Date]',
  81365. errorTag$1 = '[object Error]',
  81366. funcTag$2 = '[object Function]',
  81367. genTag$1 = '[object GeneratorFunction]',
  81368. mapTag$4 = '[object Map]',
  81369. numberTag$2 = '[object Number]',
  81370. objectTag$3 = '[object Object]',
  81371. regexpTag$2 = '[object RegExp]',
  81372. setTag$4 = '[object Set]',
  81373. stringTag$2 = '[object String]',
  81374. symbolTag$2 = '[object Symbol]',
  81375. weakMapTag$2 = '[object WeakMap]';
  81376. var arrayBufferTag$2 = '[object ArrayBuffer]',
  81377. dataViewTag$3 = '[object DataView]',
  81378. float32Tag$2 = '[object Float32Array]',
  81379. float64Tag$2 = '[object Float64Array]',
  81380. int8Tag$2 = '[object Int8Array]',
  81381. int16Tag$2 = '[object Int16Array]',
  81382. int32Tag$2 = '[object Int32Array]',
  81383. uint8Tag$2 = '[object Uint8Array]',
  81384. uint8ClampedTag$2 = '[object Uint8ClampedArray]',
  81385. uint16Tag$2 = '[object Uint16Array]',
  81386. uint32Tag$2 = '[object Uint32Array]';
  81387. /** Used to identify `toStringTag` values supported by `_.clone`. */
  81388. var cloneableTags = {};
  81389. cloneableTags[argsTag$2] = cloneableTags[arrayTag$1] =
  81390. cloneableTags[arrayBufferTag$2] = cloneableTags[dataViewTag$3] =
  81391. cloneableTags[boolTag$2] = cloneableTags[dateTag$2] =
  81392. cloneableTags[float32Tag$2] = cloneableTags[float64Tag$2] =
  81393. cloneableTags[int8Tag$2] = cloneableTags[int16Tag$2] =
  81394. cloneableTags[int32Tag$2] = cloneableTags[mapTag$4] =
  81395. cloneableTags[numberTag$2] = cloneableTags[objectTag$3] =
  81396. cloneableTags[regexpTag$2] = cloneableTags[setTag$4] =
  81397. cloneableTags[stringTag$2] = cloneableTags[symbolTag$2] =
  81398. cloneableTags[uint8Tag$2] = cloneableTags[uint8ClampedTag$2] =
  81399. cloneableTags[uint16Tag$2] = cloneableTags[uint32Tag$2] = true;
  81400. cloneableTags[errorTag$1] = cloneableTags[funcTag$2] =
  81401. cloneableTags[weakMapTag$2] = false;
  81402. /**
  81403. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  81404. * traversed objects.
  81405. *
  81406. * @private
  81407. * @param {*} value The value to clone.
  81408. * @param {boolean} bitmask The bitmask flags.
  81409. * 1 - Deep clone
  81410. * 2 - Flatten inherited properties
  81411. * 4 - Clone symbols
  81412. * @param {Function} [customizer] The function to customize cloning.
  81413. * @param {string} [key] The key of `value`.
  81414. * @param {Object} [object] The parent object of `value`.
  81415. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  81416. * @returns {*} Returns the cloned value.
  81417. */
  81418. function baseClone(value, bitmask, customizer, key, object, stack) {
  81419. var result,
  81420. isDeep = bitmask & CLONE_DEEP_FLAG,
  81421. isFlat = bitmask & CLONE_FLAT_FLAG,
  81422. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  81423. if (customizer) {
  81424. result = object ? customizer(value, key, object, stack) : customizer(value);
  81425. }
  81426. if (result !== undefined) {
  81427. return result;
  81428. }
  81429. if (!isObject_1(value)) {
  81430. return value;
  81431. }
  81432. var isArr = isArray_1(value);
  81433. if (isArr) {
  81434. result = _initCloneArray(value);
  81435. if (!isDeep) {
  81436. return _copyArray(value, result);
  81437. }
  81438. } else {
  81439. var tag = _getTag(value),
  81440. isFunc = tag == funcTag$2 || tag == genTag$1;
  81441. if (isBuffer_1(value)) {
  81442. return _cloneBuffer(value, isDeep);
  81443. }
  81444. if (tag == objectTag$3 || tag == argsTag$2 || (isFunc && !object)) {
  81445. result = (isFlat || isFunc) ? {} : _initCloneObject(value);
  81446. if (!isDeep) {
  81447. return isFlat
  81448. ? _copySymbolsIn(value, _baseAssignIn(result, value))
  81449. : _copySymbols(value, _baseAssign(result, value));
  81450. }
  81451. } else {
  81452. if (!cloneableTags[tag]) {
  81453. return object ? value : {};
  81454. }
  81455. result = _initCloneByTag(value, tag, isDeep);
  81456. }
  81457. }
  81458. // Check for circular references and return its corresponding clone.
  81459. stack || (stack = new _Stack);
  81460. var stacked = stack.get(value);
  81461. if (stacked) {
  81462. return stacked;
  81463. }
  81464. stack.set(value, result);
  81465. if (isSet_1(value)) {
  81466. value.forEach(function(subValue) {
  81467. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  81468. });
  81469. } else if (isMap_1(value)) {
  81470. value.forEach(function(subValue, key) {
  81471. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  81472. });
  81473. }
  81474. var keysFunc = isFull
  81475. ? (isFlat ? _getAllKeysIn : _getAllKeys)
  81476. : (isFlat ? keysIn_1 : keys_1);
  81477. var props = isArr ? undefined : keysFunc(value);
  81478. _arrayEach(props || value, function(subValue, key) {
  81479. if (props) {
  81480. key = subValue;
  81481. subValue = value[key];
  81482. }
  81483. // Recursively populate clone (susceptible to call stack limits).
  81484. _assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  81485. });
  81486. return result;
  81487. }
  81488. var _baseClone = baseClone;
  81489. /** Used to compose bitmasks for cloning. */
  81490. var CLONE_DEEP_FLAG$1 = 1,
  81491. CLONE_SYMBOLS_FLAG$1 = 4;
  81492. /**
  81493. * This method is like `_.clone` except that it recursively clones `value`.
  81494. *
  81495. * @static
  81496. * @memberOf _
  81497. * @since 1.0.0
  81498. * @category Lang
  81499. * @param {*} value The value to recursively clone.
  81500. * @returns {*} Returns the deep cloned value.
  81501. * @see _.clone
  81502. * @example
  81503. *
  81504. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  81505. *
  81506. * var deep = _.cloneDeep(objects);
  81507. * console.log(deep[0] === objects[0]);
  81508. * // => false
  81509. */
  81510. function cloneDeep(value) {
  81511. return _baseClone(value, CLONE_DEEP_FLAG$1 | CLONE_SYMBOLS_FLAG$1);
  81512. }
  81513. var cloneDeep_1 = cloneDeep;
  81514. /**
  81515. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  81516. *
  81517. * Licensed under the Apache License, Version 2.0 (the "License");
  81518. * you may not use this file except in compliance with the License.
  81519. * You may obtain a copy of the License at
  81520. *
  81521. * http://www.apache.org/licenses/LICENSE-2.0
  81522. *
  81523. * Unless required by applicable law or agreed to in writing, software
  81524. * distributed under the License is distributed on an "AS IS" BASIS,
  81525. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  81526. * See the License for the specific language governing permissions and
  81527. * limitations under the License.
  81528. */
  81529. var callbacks = {
  81530. /**
  81531. * 全局的URL处理器
  81532. * @param {string} url 来源url
  81533. * @param {'image'|'audio'|'video'|'autolink'|'link'} srcType 来源类型
  81534. * @returns
  81535. */
  81536. urlProcessor: function urlProcessor(url, srcType) {
  81537. return url;
  81538. },
  81539. fileUpload: function fileUpload(file, callback) {
  81540. if (/video/i.test(file.type)) {
  81541. callback('images/demo-dog.png', {
  81542. name: "".concat(file.name.replace(/\.[^.]+$/, '')),
  81543. poster: 'images/demo-dog.png?poster=true',
  81544. isBorder: true,
  81545. isShadow: true,
  81546. isRadius: true
  81547. });
  81548. } else {
  81549. callback('images/demo-dog.png', {
  81550. name: "".concat(file.name.replace(/\.[^.]+$/, '')),
  81551. isShadow: true
  81552. });
  81553. }
  81554. },
  81555. afterChange: function afterChange(text, html) {},
  81556. afterInit: function afterInit(text, html) {},
  81557. beforeImageMounted: function beforeImageMounted(srcProp, src) {
  81558. return {
  81559. srcProp: srcProp,
  81560. src: src
  81561. };
  81562. },
  81563. onClickPreview: function onClickPreview(event) {},
  81564. onCopyCode: function onCopyCode(event, code) {
  81565. // 阻止默认的粘贴事件
  81566. // return false;
  81567. // 对复制内容进行额外处理
  81568. return code;
  81569. },
  81570. // 获取中文的拼音
  81571. changeString2Pinyin: function changeString2Pinyin(string) {
  81572. /**
  81573. * 推荐使用这个组件:https://github.com/liu11hao11/pinyin_js
  81574. *
  81575. * 可以在 ../scripts/pinyin/pinyin_dist.js 里直接引用
  81576. */
  81577. return string;
  81578. }
  81579. };
  81580. /** @type {Partial<import('~types/cherry').CherryOptions>} */
  81581. var defaultConfig = {
  81582. // 第三方包
  81583. externals: {// externals
  81584. },
  81585. // chatGpt的openai配置
  81586. openai: {
  81587. apiKey: '',
  81588. // apiKey
  81589. // proxy: {
  81590. // host: '127.0.0.1',
  81591. // port: '7890',
  81592. // }, // http & https代理配置
  81593. ignoreError: false // 是否忽略请求失败,默认忽略
  81594. },
  81595. // 解析引擎配置
  81596. engine: {
  81597. // 全局配置
  81598. global: {
  81599. // 是否启用经典换行逻辑
  81600. // true:一个换行会被忽略,两个以上连续换行会分割成段落,
  81601. // false: 一个换行会转成<br>,两个连续换行会分割成段落,三个以上连续换行会转成<br>并分割段落
  81602. classicBr: false,
  81603. /**
  81604. * 全局的URL处理器
  81605. * @param {string} url 来源url
  81606. * @param {'image'|'audio'|'video'|'autolink'|'link'} srcType 来源类型
  81607. * @returns
  81608. */
  81609. urlProcessor: callbacks.urlProcessor,
  81610. /**
  81611. * 额外允许渲染的html标签
  81612. * 标签以英文竖线分隔,如:htmlWhiteList: 'iframe|script|style'
  81613. * 默认为空,默认允许渲染的html见src/utils/sanitize.js whiteList 属性
  81614. * 需要注意:
  81615. * - 启用iframe、script等标签后,会产生xss注入,请根据实际场景判断是否需要启用
  81616. * - 一般编辑权限可控的场景(如api文档系统)可以允许iframe、script等标签
  81617. */
  81618. htmlWhiteList: ''
  81619. },
  81620. // 内置语法配置
  81621. syntax: {
  81622. // 语法开关
  81623. // 'hookName': false,
  81624. // 语法配置
  81625. // 'hookName': {
  81626. //
  81627. // }
  81628. link: {
  81629. /** 生成的<a>标签追加target属性的默认值 空:在<a>标签里不会追加target属性, _blank:在<a>标签里追加target="_blank"属性 */
  81630. target: '',
  81631. /** 生成的<a>标签追加rel属性的默认值 空:在<a>标签里不会追加rel属性, nofollow:在<a>标签里追加rel="nofollow:在"属性*/
  81632. rel: ''
  81633. },
  81634. autoLink: {
  81635. /** 生成的<a>标签追加target属性的默认值 空:在<a>标签里不会追加target属性, _blank:在<a>标签里追加target="_blank"属性 */
  81636. target: '',
  81637. /** 生成的<a>标签追加rel属性的默认值 空:在<a>标签里不会追加rel属性, nofollow:在<a>标签里追加rel="nofollow:在"属性*/
  81638. rel: '',
  81639. /** 是否开启短链接 */
  81640. enableShortLink: true,
  81641. /** 短链接长度 */
  81642. shortLinkLength: 20
  81643. },
  81644. list: {
  81645. listNested: false,
  81646. // 同级列表类型转换后变为子级
  81647. indentSpace: 2 // 默认2个空格缩进
  81648. },
  81649. table: {
  81650. enableChart: false // chartRenderEngine: EChartsTableEngine,
  81651. // externals: ['echarts'],
  81652. },
  81653. inlineCode: {
  81654. theme: 'red'
  81655. },
  81656. codeBlock: {
  81657. theme: 'dark',
  81658. // 默认为深色主题
  81659. wrap: true,
  81660. // 超出长度是否换行,false则显示滚动条
  81661. lineNumber: true,
  81662. // 默认显示行号
  81663. copyCode: true,
  81664. // 是否显示“复制”按钮
  81665. customRenderer: {// 自定义语法渲染器
  81666. },
  81667. mermaid: {
  81668. svg2img: false // 是否将mermaid生成的画图变成img格式
  81669. },
  81670. /**
  81671. * indentedCodeBlock是缩进代码块是否启用的开关
  81672. *
  81673. * 在6.X之前的版本中默认不支持该语法。
  81674. * 因为cherry的开发团队认为该语法太丑了(容易误触)
  81675. * 开发团队希望用```代码块语法来彻底取代该语法
  81676. * 但在后续的沟通中,开发团队发现在某些场景下该语法有更好的显示效果
  81677. * 因此开发团队在6.X版本中才引入了该语法
  81678. * 已经引用6.x以下版本的业务如果想做到用户无感知升级,可以去掉该语法:
  81679. * indentedCodeBlock:false
  81680. */
  81681. indentedCodeBlock: true
  81682. },
  81683. emoji: {
  81684. useUnicode: true // 是否使用unicode进行渲染
  81685. },
  81686. fontEmphasis: {
  81687. /**
  81688. * 是否允许首尾空格
  81689. * 首尾、前后的定义: 语法前**语法首+内容+语法尾**语法后
  81690. * 例:
  81691. * true:
  81692. * __ hello __ ====> <strong> hello </strong>
  81693. * __hello__ ====> <strong>hello</strong>
  81694. * false:
  81695. * __ hello __ ====> <em>_ hello _</em>
  81696. * __hello__ ====> <strong>hello</strong>
  81697. */
  81698. allowWhitespace: false
  81699. },
  81700. strikethrough: {
  81701. /**
  81702. * 是否必须有前后空格
  81703. * 首尾、前后的定义: 语法前**语法首+内容+语法尾**语法后
  81704. * 例:
  81705. * true:
  81706. * hello wor~~l~~d ====> hello wor~~l~~d
  81707. * hello wor ~~l~~ d ====> hello wor <del>l</del> d
  81708. * false:
  81709. * hello wor~~l~~d ====> hello wor<del>l</del>d
  81710. * hello wor ~~l~~ d ====> hello wor <del>l</del> d
  81711. */
  81712. needWhitespace: false
  81713. },
  81714. mathBlock: {
  81715. engine: 'MathJax',
  81716. // katex或MathJax
  81717. src: '',
  81718. plugins: true // 默认加载插件
  81719. },
  81720. inlineMath: {
  81721. engine: 'MathJax',
  81722. // katex或MathJax
  81723. src: ''
  81724. },
  81725. toc: {
  81726. /** 默认只渲染一个目录 */
  81727. allowMultiToc: false
  81728. },
  81729. header: {
  81730. /**
  81731. * 标题的样式:
  81732. * - default 默认样式,标题前面有锚点
  81733. * - autonumber 标题前面有自增序号锚点
  81734. * - none 标题没有锚点
  81735. */
  81736. anchorStyle: 'default'
  81737. }
  81738. }
  81739. },
  81740. editor: {
  81741. id: 'code',
  81742. // textarea 的id属性值
  81743. name: 'code',
  81744. // textarea 的name属性值
  81745. autoSave2Textarea: false,
  81746. // 是否自动将编辑区的内容回写到textarea里
  81747. theme: 'default',
  81748. // depend on codemirror theme name: https://codemirror.net/demo/theme.htm
  81749. // 编辑器的高度,默认100%,如果挂载点存在内联设置的height则以内联样式为主
  81750. height: '100%',
  81751. // defaultModel 编辑器初始化后的默认模式,一共有三种模式:1、双栏编辑预览模式;2、纯编辑模式;3、预览模式
  81752. // edit&preview: 双栏编辑预览模式
  81753. // editOnly: 纯编辑模式(没有预览,可通过toolbar切换成双栏或预览模式)
  81754. // previewOnly: 预览模式(没有编辑框,toolbar只显示“返回编辑”按钮,可通过toolbar切换成编辑模式)
  81755. defaultModel: 'edit&preview',
  81756. // 粘贴时是否自动将html转成markdown
  81757. convertWhenPaste: true,
  81758. codemirror: {
  81759. // 是否自动focus 默认为true
  81760. autofocus: true
  81761. },
  81762. writingStyle: 'normal' // 书写风格,normal 普通 | typewriter 打字机 | focus 专注,默认normal
  81763. },
  81764. toolbars: {
  81765. theme: 'dark',
  81766. // light or dark
  81767. showToolbar: true,
  81768. // false:不展示顶部工具栏; true:展示工具栏; toolbars.showToolbar=false 与 toolbars.toolbar=false 等效
  81769. toolbar: ['bold', 'italic', 'strikethrough', '|', 'color', 'header', 'ruby', '|', 'list', 'panel', // 'justify', // 对齐方式,默认不推荐这么“复杂”的样式要求
  81770. 'detail', {
  81771. insert: ['image', 'audio', 'video', 'link', 'hr', 'br', 'code', 'formula', 'toc', 'table', 'line-table', 'bar-table', 'pdf', 'word']
  81772. }, 'graph', 'settings'],
  81773. toolbarRight: [],
  81774. sidebar: [],
  81775. bubble: ['bold', 'italic', 'underline', 'strikethrough', 'sub', 'sup', 'quote', '|', 'size', 'color'],
  81776. // array or false
  81777. "float": ['h1', 'h2', 'h3', '|', 'checklist', 'quote', 'table', 'code'] // array or false
  81778. },
  81779. // 打开draw.io编辑页的url,如果为空则drawio按钮失效
  81780. drawioIframeUrl: '',
  81781. // 上传文件的回调
  81782. fileUpload: callbacks.fileUpload,
  81783. /**
  81784. * 上传文件的时候用来指定文件类型
  81785. */
  81786. fileTypeLimitMap: {
  81787. video: 'video/*',
  81788. audio: 'audio/*',
  81789. image: 'image/*',
  81790. word: '.doc,.docx',
  81791. pdf: '.pdf',
  81792. file: '*'
  81793. },
  81794. callback: {
  81795. afterChange: callbacks.afterChange,
  81796. afterInit: callbacks.afterInit,
  81797. beforeImageMounted: callbacks.beforeImageMounted,
  81798. // 预览区域点击事件,previewer.enablePreviewerBubble = true 时生效
  81799. onClickPreview: callbacks.onClickPreview,
  81800. // 复制代码块代码时的回调
  81801. onCopyCode: callbacks.onCopyCode,
  81802. // 把中文变成拼音的回调,当然也可以把中文变成英文、英文变成中文
  81803. changeString2Pinyin: callbacks.changeString2Pinyin
  81804. },
  81805. previewer: {
  81806. dom: false,
  81807. className: 'cherry-markdown',
  81808. // 是否启用预览区域编辑能力(目前支持编辑图片尺寸、编辑表格内容)
  81809. enablePreviewerBubble: true,
  81810. /**
  81811. * 配置图片懒加载的逻辑
  81812. * - 如果不希望图片懒加载,可配置成 lazyLoadImg = {noLoadImgNum: -1}
  81813. * - 如果希望所有图片都无脑懒加载,可配置成 lazyLoadImg = {noLoadImgNum: 0, autoLoadImgNum: -1}
  81814. * - 如果一共有15张图片,希望:
  81815. * 1、前5张图片(1~5)直接加载;
  81816. * 2、后5张图片(6~10)不论在不在视区内,都无脑懒加载;
  81817. * 3、其他图片(11~15)在视区内时,进行懒加载;
  81818. * 则配置应该为:lazyLoadImg = {noLoadImgNum: 5, autoLoadImgNum: 5}
  81819. */
  81820. lazyLoadImg: {
  81821. // 加载图片时如果需要展示loading图,则配置loading图的地址
  81822. loadingImgPath: '',
  81823. // 同一时间最多有几个图片请求,最大同时加载6张图片
  81824. maxNumPerTime: 2,
  81825. // 不进行懒加载处理的图片数量,如果为0,即所有图片都进行懒加载处理, 如果设置为-1,则所有图片都不进行懒加载处理
  81826. noLoadImgNum: 5,
  81827. // 首次自动加载几张图片(不论图片是否滚动到视野内),autoLoadImgNum = -1 表示会自动加载完所有图片
  81828. autoLoadImgNum: 5,
  81829. // 针对加载失败的图片 或 beforeLoadOneImgCallback 返回false 的图片,最多尝试加载几次,为了防止死循环,最多5次。以图片的src为纬度统计重试次数
  81830. maxTryTimesPerSrc: 2,
  81831. // 加载一张图片之前的回调函数,函数return false 会终止加载操作
  81832. beforeLoadOneImgCallback: function beforeLoadOneImgCallback(img) {
  81833. return true;
  81834. },
  81835. // 加载一张图片失败之后的回调函数
  81836. failLoadOneImgCallback: function failLoadOneImgCallback(img) {},
  81837. // 加载一张图片之后的回调函数,如果图片加载失败,则不会回调该函数
  81838. afterLoadOneImgCallback: function afterLoadOneImgCallback(img) {},
  81839. // 加载完所有图片后调用的回调函数
  81840. afterLoadAllImgCallback: function afterLoadAllImgCallback() {}
  81841. }
  81842. },
  81843. /**
  81844. * 配置主题,第三方可以自行扩展主题
  81845. */
  81846. theme: [{
  81847. className: 'default',
  81848. label: '默认'
  81849. }, {
  81850. className: 'dark',
  81851. label: '暗黑'
  81852. }, {
  81853. className: 'light',
  81854. label: '明亮'
  81855. }, {
  81856. className: 'green',
  81857. label: '清新'
  81858. }, {
  81859. className: 'red',
  81860. label: '热情'
  81861. }, {
  81862. className: 'violet',
  81863. label: '淡雅'
  81864. }, {
  81865. className: 'blue',
  81866. label: '清幽'
  81867. }],
  81868. // 预览页面不需要绑定事件
  81869. isPreviewOnly: false,
  81870. // 预览区域跟随编辑器光标自动滚动
  81871. autoScrollByCursor: true,
  81872. // 外层容器不存在时,是否强制输出到body上
  81873. forceAppend: true,
  81874. // The locale Cherry is going to use. Locales live in /src/locales/
  81875. locale: 'zh_CN'
  81876. };
  81877. var defaultConfig$1 = cloneDeep_1(defaultConfig);
  81878. /**
  81879. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  81880. *
  81881. * Licensed under the Apache License, Version 2.0 (the "License");
  81882. * you may not use this file except in compliance with the License.
  81883. * You may obtain a copy of the License at
  81884. *
  81885. * http://www.apache.org/licenses/LICENSE-2.0
  81886. *
  81887. * Unless required by applicable law or agreed to in writing, software
  81888. * distributed under the License is distributed on an "AS IS" BASIS,
  81889. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  81890. * See the License for the specific language governing permissions and
  81891. * limitations under the License.
  81892. */
  81893. var zhCn = {
  81894. bold: '加粗',
  81895. // 加粗
  81896. code: '代码',
  81897. // 代码
  81898. graph: '画图',
  81899. // 画图
  81900. h1: '一级标题',
  81901. // 一级标题
  81902. h2: '二级标题',
  81903. // 二级标题
  81904. h3: '三级标题',
  81905. // 三级标题
  81906. h4: '四级标题',
  81907. // 四级标题
  81908. h5: '五级标题',
  81909. // 五级标题
  81910. header: '标题',
  81911. // 标题
  81912. insert: '插入',
  81913. // 插入
  81914. italic: '斜体',
  81915. // 斜体
  81916. list: '列表',
  81917. // 列表
  81918. quickTable: '表格',
  81919. // 表格
  81920. quote: '引用',
  81921. // 引用
  81922. size: '大小',
  81923. // 大小
  81924. color: '文字颜色&背景',
  81925. // 文字颜色&背景
  81926. strikethrough: '删除线',
  81927. // 删除线
  81928. sub: '下标',
  81929. // 下标
  81930. sup: '上标',
  81931. // 上标
  81932. togglePreview: '预览',
  81933. // 预览
  81934. fullScreen: '全屏',
  81935. // 全屏
  81936. image: '图片',
  81937. // 图片
  81938. audio: '音频',
  81939. // 音频
  81940. video: '视频',
  81941. // 视频
  81942. link: '超链接',
  81943. // 超链接
  81944. hr: '分隔线',
  81945. // 分隔线
  81946. br: '换行',
  81947. // 换行
  81948. toc: '目录',
  81949. // 目录
  81950. pdf: 'pdf',
  81951. // pdf
  81952. word: 'word',
  81953. // word
  81954. table: '表格',
  81955. // 表格
  81956. 'line-table': '折线表格',
  81957. // 折线表格
  81958. 'bar-table': '柱状表格',
  81959. // 柱状表格
  81960. formula: '公式',
  81961. // 公式
  81962. insertFormula: '公式',
  81963. // 公式
  81964. insertFlow: '流程图',
  81965. // 流程图
  81966. insertSeq: '时序图',
  81967. // 时序图
  81968. insertState: '状态图',
  81969. // 状态图
  81970. insertClass: '类图',
  81971. // 类图
  81972. insertPie: '饼图',
  81973. // 饼图
  81974. insertGantt: '甘特图',
  81975. // 甘特图
  81976. checklist: '清单',
  81977. // 清单
  81978. ol: '有序列表',
  81979. // 有序列表
  81980. ul: '无序列表',
  81981. // 无序列表
  81982. undo: '撤销',
  81983. // 撤销
  81984. redo: '恢复',
  81985. // 恢复
  81986. previewClose: '关闭预览',
  81987. // 关闭预览
  81988. codeTheme: '代码主题',
  81989. // 代码主题
  81990. switchModel: '模式切换',
  81991. // 模式切换
  81992. switchPreview: '预览',
  81993. // 预览
  81994. switchEdit: '返回编辑',
  81995. // 返回编辑
  81996. classicBr: '经典换行',
  81997. // 经典换行
  81998. normalBr: '常规换行',
  81999. // 常规换行
  82000. settings: '设置',
  82001. // 设置
  82002. mobilePreview: '移动端预览',
  82003. // 移动端预览
  82004. copy: '复制内容',
  82005. // 复制内容
  82006. "export": '导出',
  82007. // 导出PDF、长图
  82008. underline: '下划线',
  82009. // 下划线
  82010. pinyin: '拼音',
  82011. // 拼音
  82012. file: '文件',
  82013. pastePlain: '粘贴为纯文本格式',
  82014. // 粘贴为纯文本格式
  82015. pasteMarkdown: '粘贴为markdown格式',
  82016. // 粘贴为markdown格式
  82017. hide: '隐藏(ctrl+0)',
  82018. // 隐藏(ctrl+0)
  82019. exportToPdf: '导出PDF',
  82020. // 导出PDF
  82021. exportScreenshot: '导出长图',
  82022. // 导出长图
  82023. exportMarkdownFile: '导出markdown',
  82024. // 导出markdown文件
  82025. exportHTMLFile: '导出html',
  82026. // 导出预览区html文件
  82027. theme: '主题',
  82028. // 导出长图
  82029. panel: '面板',
  82030. // 导出长图
  82031. detail: '手风琴',
  82032. // 手风琴
  82033. 'H1 Heading': 'H1 一级标题',
  82034. 'H2 Heading': 'H2 二级标题',
  82035. 'H3 Heading': 'H3 三级标题',
  82036. complement: '续写',
  82037. summary: '总结',
  82038. save: '保存',
  82039. release: '发布',
  82040. back: '返回',
  82041. };
  82042. /**
  82043. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  82044. *
  82045. * Licensed under the Apache License, Version 2.0 (the "License");
  82046. * you may not use this file except in compliance with the License.
  82047. * You may obtain a copy of the License at
  82048. *
  82049. * http://www.apache.org/licenses/LICENSE-2.0
  82050. *
  82051. * Unless required by applicable law or agreed to in writing, software
  82052. * distributed under the License is distributed on an "AS IS" BASIS,
  82053. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  82054. * See the License for the specific language governing permissions and
  82055. * limitations under the License.
  82056. */
  82057. var enUs = {
  82058. bold: 'Bold',
  82059. code: 'Code',
  82060. graph: 'Graph',
  82061. h1: 'Heading 1',
  82062. h2: 'Heading 2',
  82063. h3: 'Heading 3',
  82064. h4: 'Heading 4',
  82065. h5: 'Heading 5',
  82066. header: 'Header',
  82067. insert: 'Insert',
  82068. italic: 'Italic',
  82069. list: 'List',
  82070. quickTable: 'Quick Table',
  82071. quote: 'Quote',
  82072. size: 'Size',
  82073. color: 'Text Color & Background',
  82074. strikethrough: 'Strikethrough',
  82075. sub: 'Sub',
  82076. sup: 'Sup',
  82077. togglePreview: 'Toggle Preview',
  82078. fullScreen: 'Full Screen',
  82079. image: 'Image',
  82080. audio: 'Audio',
  82081. video: 'Video',
  82082. link: 'Link',
  82083. hr: 'Horizontal Rule',
  82084. br: 'New Line',
  82085. toc: 'Table Of Content',
  82086. pdf: 'PDF',
  82087. word: 'Word',
  82088. table: 'Table',
  82089. 'line-table': 'Line Table',
  82090. 'bar-table': 'Bar Table',
  82091. formula: 'Formula',
  82092. insertFormula: 'Insert Formula',
  82093. insertFlow: 'Insert Flow',
  82094. insertSeq: 'Insert Seq',
  82095. insertState: 'Insert State',
  82096. insertClass: 'Insert Class',
  82097. insertPie: 'Insert Pie',
  82098. insertGantt: 'Insert Gantt',
  82099. checklist: 'Checklist',
  82100. ol: 'Ordered List',
  82101. ul: 'Unordered List',
  82102. undo: 'Undo',
  82103. redo: 'Redo',
  82104. previewClose: 'Preview Close',
  82105. codeTheme: 'Code Theme',
  82106. switchModel: 'Switch Model',
  82107. switchPreview: 'Switch Preview',
  82108. switchEdit: 'Switch Edit',
  82109. classicBr: 'Classic New Line',
  82110. normalBr: 'Normal New Line',
  82111. settings: 'Settings',
  82112. mobilePreview: 'Mobile Preview',
  82113. copy: 'Copy',
  82114. "export": 'Export',
  82115. underline: 'Underline',
  82116. pinyin: 'Pinyin',
  82117. pastePlain: 'Paste as Plain Text',
  82118. pasteMarkdown: 'Paste as Markdown',
  82119. hide: 'Hide (ctrl+0)',
  82120. exportToPdf: 'Export to PDF',
  82121. exportScreenshot: 'Screenshot',
  82122. exportMarkdownFile: 'Export Markdown File',
  82123. exportHTMLFile: 'Export preview HTML File',
  82124. 'H1 Heading': 'H1 Heading',
  82125. 'H2 Heading': 'H1 Heading',
  82126. 'H3 Heading': 'H1 Heading',
  82127. complement: 'Complement',
  82128. summary: 'Summary',
  82129. save: 'Save',
  82130. release: 'Release',
  82131. back: 'Back',
  82132. };
  82133. /**
  82134. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  82135. *
  82136. * Licensed under the Apache License, Version 2.0 (the "License");
  82137. * you may not use this file except in compliance with the License.
  82138. * You may obtain a copy of the License at
  82139. *
  82140. * http://www.apache.org/licenses/LICENSE-2.0
  82141. *
  82142. * Unless required by applicable law or agreed to in writing, software
  82143. * distributed under the License is distributed on an "AS IS" BASIS,
  82144. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  82145. * See the License for the specific language governing permissions and
  82146. * limitations under the License.
  82147. */
  82148. var locales = {
  82149. zh_CN: zhCn,
  82150. en_US: enUs
  82151. };
  82152. function _createSuper$1r(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1r(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  82153. function _isNativeReflectConstruct$1r() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  82154. function filterOptions(options, whiteList, propTypes) {
  82155. var _context;
  82156. var filteredOptions = {};
  82157. forEach$3(_context = keys$3(options)).call(_context, function (key) {
  82158. if (indexOf$8(whiteList).call(whiteList, key) === -1) {
  82159. return;
  82160. }
  82161. if (_typeof(propTypes) === 'object') {
  82162. if (typeof propTypes[key] === 'string') {
  82163. if (_typeof(options[key]) === propTypes[key]) {
  82164. filteredOptions[key] = options[key];
  82165. }
  82166. } else {
  82167. if (options[key] instanceof propTypes[key]) {
  82168. filteredOptions[key] = options[key];
  82169. }
  82170. }
  82171. } else if (typeof propTypes === 'string') {
  82172. if (_typeof(options[key]) === propTypes) {
  82173. filteredOptions[key] = options[key];
  82174. }
  82175. }
  82176. });
  82177. return filteredOptions;
  82178. }
  82179. function createSyntaxHook(name, type, options) {
  82180. var _class;
  82181. var BaseClass = type === HOOKS_TYPE_LIST.PAR ? ParagraphBase : SyntaxBase;
  82182. var optionsWhiteList = ['beforeMakeHtml', 'makeHtml', 'afterMakeHtml', 'rule', 'test'];
  82183. var filteredOptions = filterOptions(options, optionsWhiteList, 'function');
  82184. var paragraphConfig = {
  82185. needCache: options.needCache,
  82186. defaultCache: options.defaultCache
  82187. };
  82188. return _class = /*#__PURE__*/function (_BaseClass) {
  82189. _inherits(CustomSyntax, _BaseClass);
  82190. var _super = _createSuper$1r(CustomSyntax);
  82191. function CustomSyntax() {
  82192. var _this;
  82193. var editorConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  82194. _classCallCheck(this, CustomSyntax);
  82195. if (type === HOOKS_TYPE_LIST.PAR) {
  82196. _this = _super.call(this, {
  82197. needCache: !!paragraphConfig.needCache,
  82198. defaultCache: paragraphConfig.defaultCache
  82199. });
  82200. } else {
  82201. _this = _super.call(this);
  82202. }
  82203. _this.config = editorConfig.config;
  82204. return _possibleConstructorReturn(_this);
  82205. }
  82206. _createClass(CustomSyntax, [{
  82207. key: "beforeMakeHtml",
  82208. value: function beforeMakeHtml() {
  82209. var _get2, _context2;
  82210. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  82211. args[_key] = arguments[_key];
  82212. }
  82213. if (filteredOptions.beforeMakeHtml) {
  82214. return filteredOptions.beforeMakeHtml.apply(this, args);
  82215. }
  82216. return (_get2 = _get(_getPrototypeOf(CustomSyntax.prototype), "beforeMakeHtml", this)).call.apply(_get2, concat$5(_context2 = [this]).call(_context2, args));
  82217. }
  82218. }, {
  82219. key: "makeHtml",
  82220. value: function makeHtml() {
  82221. var _get3, _context3;
  82222. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  82223. args[_key2] = arguments[_key2];
  82224. }
  82225. if (filteredOptions.makeHtml) {
  82226. return filteredOptions.makeHtml.apply(this, args);
  82227. }
  82228. return (_get3 = _get(_getPrototypeOf(CustomSyntax.prototype), "makeHtml", this)).call.apply(_get3, concat$5(_context3 = [this]).call(_context3, args));
  82229. }
  82230. }, {
  82231. key: "afterMakeHtml",
  82232. value: function afterMakeHtml() {
  82233. var _get4, _context4;
  82234. for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  82235. args[_key3] = arguments[_key3];
  82236. }
  82237. if (filteredOptions.afterMakeHtml) {
  82238. return filteredOptions.afterMakeHtml.apply(this, args);
  82239. }
  82240. return (_get4 = _get(_getPrototypeOf(CustomSyntax.prototype), "afterMakeHtml", this)).call.apply(_get4, concat$5(_context4 = [this]).call(_context4, args));
  82241. }
  82242. }, {
  82243. key: "test",
  82244. value: function test() {
  82245. var _get5, _context5;
  82246. for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  82247. args[_key4] = arguments[_key4];
  82248. }
  82249. if (filteredOptions.test) {
  82250. return filteredOptions.test.apply(this, args);
  82251. }
  82252. return (_get5 = _get(_getPrototypeOf(CustomSyntax.prototype), "test", this)).call.apply(_get5, concat$5(_context5 = [this]).call(_context5, args));
  82253. }
  82254. }, {
  82255. key: "rule",
  82256. value: function rule() {
  82257. var _get6, _context6;
  82258. for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
  82259. args[_key5] = arguments[_key5];
  82260. }
  82261. if (filteredOptions.rule) {
  82262. return filteredOptions.rule.apply(this, args);
  82263. }
  82264. return (_get6 = _get(_getPrototypeOf(CustomSyntax.prototype), "rule", this)).call.apply(_get6, concat$5(_context6 = [this]).call(_context6, args));
  82265. }
  82266. }]);
  82267. return CustomSyntax;
  82268. }(BaseClass), _defineProperty(_class, "HOOK_NAME", name), _class;
  82269. }
  82270. function createMenuHook(name, options) {
  82271. var optionsWhiteList = ['subMenuConfig', 'id', 'onClick', 'shortcutKeys', 'iconName'];
  82272. var propTypes = {
  82273. subMenuConfig: Array,
  82274. onClick: 'function',
  82275. shortcutKeys: Array,
  82276. id: 'string',
  82277. iconName: 'string'
  82278. };
  82279. var filteredOptions = filterOptions(options, optionsWhiteList, propTypes);
  82280. return /*#__PURE__*/function (_MenuBase) {
  82281. _inherits(CustomMenu, _MenuBase);
  82282. var _super2 = _createSuper$1r(CustomMenu);
  82283. function CustomMenu(editorInstance) {
  82284. var _this2;
  82285. _classCallCheck(this, CustomMenu);
  82286. _this2 = _super2.call(this, editorInstance);
  82287. if (!filteredOptions.iconName) {
  82288. _this2.noIcon = true;
  82289. }
  82290. _this2.setName(name, filteredOptions.iconName);
  82291. _this2.setId(filteredOptions.id);
  82292. _this2.subMenuConfig = filteredOptions.subMenuConfig || [];
  82293. return _this2;
  82294. }
  82295. _createClass(CustomMenu, [{
  82296. key: "onClick",
  82297. value: function onClick() {
  82298. var _get7, _context7;
  82299. for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
  82300. args[_key6] = arguments[_key6];
  82301. }
  82302. if (filteredOptions.onClick) {
  82303. return filteredOptions.onClick.apply(this, args);
  82304. }
  82305. return (_get7 = _get(_getPrototypeOf(CustomMenu.prototype), "onClick", this)).call.apply(_get7, concat$5(_context7 = [this]).call(_context7, args));
  82306. }
  82307. }, {
  82308. key: "shortcutKeys",
  82309. get: function get() {
  82310. if (filteredOptions.shortcutKeys) {
  82311. return filteredOptions.shortcutKeys;
  82312. }
  82313. return [];
  82314. }
  82315. }]);
  82316. return CustomMenu;
  82317. }(MenuBase);
  82318. }
  82319. var constants = {
  82320. HOOKS_TYPE_LIST: HOOKS_TYPE_LIST
  82321. };
  82322. var nodeIgnorePlugin = [];
  82323. if (!isBrowser()) {
  82324. forEach$3(nodeIgnorePlugin).call(nodeIgnorePlugin, function (key) {
  82325. });
  82326. }
  82327. var VERSION$1 = "0.8.21-4b60dd76";
  82328. var CherryStatic = /*#__PURE__*/function () {
  82329. function CherryStatic() {
  82330. _classCallCheck(this, CherryStatic);
  82331. }
  82332. _createClass(CherryStatic, null, [{
  82333. key: "usePlugin",
  82334. value:
  82335. /**
  82336. * @this {typeof import('./Cherry').default | typeof CherryStatic}
  82337. * @param {{ install: (defaultConfig: any, ...args: any[]) => void }} PluginClass 插件Class
  82338. * @param {...any} args 初始化插件的参数
  82339. * @returns
  82340. */
  82341. function usePlugin(PluginClass) {
  82342. var _context;
  82343. if (this === CherryStatic) {
  82344. throw new Error('`usePlugin` is not allowed to called through CherryStatic class.');
  82345. } // @ts-ignore
  82346. if (this.initialized) {
  82347. throw new Error('The function `usePlugin` should be called before Cherry is instantiated.');
  82348. } // @ts-ignore
  82349. if (PluginClass.$cherry$mounted === true) {
  82350. return;
  82351. } // @ts-ignore
  82352. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  82353. args[_key - 1] = arguments[_key];
  82354. }
  82355. PluginClass.install.apply(PluginClass, concat$5(_context = [this.config.defaults]).call(_context, args)); // @ts-ignore
  82356. PluginClass.$cherry$mounted = true;
  82357. }
  82358. }]);
  82359. return CherryStatic;
  82360. }();
  82361. _defineProperty(CherryStatic, "createSyntaxHook", createSyntaxHook);
  82362. _defineProperty(CherryStatic, "createMenuHook", createMenuHook);
  82363. _defineProperty(CherryStatic, "constants", constants);
  82364. _defineProperty(CherryStatic, "VERSION", VERSION$1);
  82365. function ownKeys$9(object, enumerableOnly) { var keys = keys$3(object); if (getOwnPropertySymbols$2) { var symbols = getOwnPropertySymbols$2(object); enumerableOnly && (symbols = filter$3(symbols).call(symbols, function (sym) { return getOwnPropertyDescriptor$3(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  82366. function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? forEach$3(_context5 = ownKeys$9(Object(source), !0)).call(_context5, function (key) { _defineProperty(target, key, source[key]); }) : getOwnPropertyDescriptors$2 ? defineProperties$2(target, getOwnPropertyDescriptors$2(source)) : forEach$3(_context6 = ownKeys$9(Object(source))).call(_context6, function (key) { defineProperty$5(target, key, getOwnPropertyDescriptor$3(source, key)); }); } return target; }
  82367. function _createSuper$1s(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1s(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct$4(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  82368. function _isNativeReflectConstruct$1s() { if (typeof Reflect === "undefined" || !construct$4) return false; if (construct$4.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct$4(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  82369. /** @typedef {import('~types/cherry').CherryOptions} CherryOptions */
  82370. var Cherry = /*#__PURE__*/function (_CherryStatic) {
  82371. _inherits(Cherry, _CherryStatic);
  82372. var _super = _createSuper$1s(Cherry);
  82373. /**
  82374. * @protected
  82375. */
  82376. /**
  82377. * @readonly
  82378. */
  82379. /**
  82380. * @param {Partial<CherryOptions>} options
  82381. */
  82382. function Cherry(options) {
  82383. var _context;
  82384. var _this;
  82385. _classCallCheck(this, Cherry);
  82386. _this = _super.call(this);
  82387. Cherry.initialized = true;
  82388. var defaultConfigCopy = cloneDeep_1(Cherry.config.defaults);
  82389. _this.defaultToolbar = defaultConfigCopy.toolbars.toolbar;
  82390. $expectTarget(options, Object);
  82391. /**
  82392. * @property
  82393. * @type {Partial<CherryOptions>}
  82394. */
  82395. _this.options = mergeWith_1({}, defaultConfigCopy, options, customizer); // loading the locale
  82396. _this.locale = locales[_this.options.locale];
  82397. if (typeof _this.options.engine.global.urlProcessor === 'function') {
  82398. _this.options.engine.global.urlProcessor = urlProcessorProxy(_this.options.engine.global.urlProcessor);
  82399. }
  82400. _this.status = {
  82401. toolbar: 'show',
  82402. previewer: 'show',
  82403. editor: 'show'
  82404. };
  82405. if (_this.options.isPreviewOnly || _this.options.editor.defaultModel === 'previewOnly') {
  82406. _this.options.toolbars.showToolbar = false;
  82407. _this.options.editor.defaultModel = 'previewOnly';
  82408. _this.status.editor = 'hide';
  82409. _this.status.toolbar = 'hide';
  82410. }
  82411. /**
  82412. * @property
  82413. * @type {string} 实例ID
  82414. */
  82415. _this.instanceId = concat$5(_context = "cherry-".concat(new Date().getTime())).call(_context, Math.random());
  82416. _this.options.instanceId = _this.instanceId;
  82417. /**
  82418. * @private
  82419. * @type {Engine}
  82420. */
  82421. _this.engine = new Engine(_this.options, _assertThisInitialized(_this));
  82422. _this.init();
  82423. return _this;
  82424. }
  82425. /**
  82426. * 初始化工具栏、编辑区、预览区等
  82427. * @private
  82428. */
  82429. _createClass(Cherry, [{
  82430. key: "init",
  82431. value: function init() {
  82432. var _context2,
  82433. _this2 = this;
  82434. var mountEl = this.options.id ? document.getElementById(this.options.id) : this.options.el;
  82435. if (!mountEl) {
  82436. if (!this.options.forceAppend) {
  82437. return false;
  82438. }
  82439. mountEl = document.createElement('div');
  82440. mountEl.id = this.options.id || 'cherry-markdown';
  82441. document.body.appendChild(mountEl);
  82442. }
  82443. if (!mountEl.style.height) {
  82444. mountEl.style.height = this.options.editor.height;
  82445. }
  82446. this.cherryDom = mountEl; // 蒙层dom,用来拖拽编辑区&预览区宽度时展示蒙层
  82447. var wrapperDom = this.createWrapper(); // 创建编辑区
  82448. var editor = this.createEditor(); // 创建预览区
  82449. var previewer = this.createPreviewer();
  82450. if (this.options.toolbars.showToolbar === false || this.options.toolbars.toolbar === false) {
  82451. // 即便配置了不展示工具栏,也要让工具栏加载对应的语法hook
  82452. wrapperDom.classList.add('cherry--no-toolbar');
  82453. this.options.toolbars.toolbar = this.defaultToolbar;
  82454. }
  82455. $expectTarget(this.options.toolbars.toolbar, Array); // 创建顶部工具栏
  82456. this.toolbar = this.createToolbar();
  82457. var wrapperFragment = document.createDocumentFragment();
  82458. wrapperFragment.appendChild(this.toolbar.options.dom);
  82459. wrapperFragment.appendChild(editor.options.editorDom); // 创建预览区域的侧边工具栏
  82460. this.createSidebar(wrapperFragment);
  82461. if (!this.options.previewer.dom) {
  82462. wrapperFragment.appendChild(previewer.options.previewerDom);
  82463. }
  82464. wrapperFragment.appendChild(previewer.options.virtualDragLineDom);
  82465. wrapperFragment.appendChild(previewer.options.editorMaskDom);
  82466. wrapperFragment.appendChild(previewer.options.previewerMaskDom);
  82467. wrapperDom.appendChild(wrapperFragment);
  82468. mountEl.appendChild(wrapperDom);
  82469. editor.init(previewer); // 创建bubble工具栏,所谓bubble工具栏,是指在编辑区选中文本时悬浮出现的工具栏
  82470. this.createBubble(); // 创建float工具栏,所谓float工具栏,是指当编辑区光标处于新行时,在行内联想出的工具栏
  82471. this.createFloatMenu();
  82472. previewer.init(editor);
  82473. previewer.registerAfterUpdate(bind$5(_context2 = this.engine.mounted).call(_context2, this.engine)); // default value init
  82474. this.initText(editor.editor); // 切换模式,有纯预览模式、纯编辑模式、双栏编辑模式
  82475. this.switchModel(this.options.editor.defaultModel);
  82476. Event$1.on(this.instanceId, Event$1.Events.toolbarHide, function () {
  82477. _this2.status.toolbar = 'hide';
  82478. });
  82479. Event$1.on(this.instanceId, Event$1.Events.toolbarShow, function () {
  82480. _this2.status.toolbar = 'show';
  82481. });
  82482. Event$1.on(this.instanceId, Event$1.Events.previewerClose, function () {
  82483. _this2.status.previewer = 'hide';
  82484. });
  82485. Event$1.on(this.instanceId, Event$1.Events.previewerOpen, function () {
  82486. _this2.status.previewer = 'show';
  82487. });
  82488. Event$1.on(this.instanceId, Event$1.Events.editorClose, function () {
  82489. _this2.status.editor = 'hide'; // 关闭编辑区时,需要清除所有高亮
  82490. _this2.previewer.highlightLine(0);
  82491. });
  82492. Event$1.on(this.instanceId, Event$1.Events.editorOpen, function () {
  82493. _this2.status.editor = 'show';
  82494. });
  82495. }
  82496. /**
  82497. * 切换编辑模式
  82498. * @param {'edit&preview'|'editOnly'|'previewOnly'} model 模式类型
  82499. * 一般纯预览模式和纯编辑模式适合在屏幕较小的终端使用,比如手机移动端
  82500. *
  82501. * @returns
  82502. */
  82503. }, {
  82504. key: "switchModel",
  82505. value: function switchModel() {
  82506. var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'edit&preview';
  82507. switch (model) {
  82508. case 'edit&preview':
  82509. if (this.previewer) {
  82510. this.previewer.editOnly(true);
  82511. this.previewer.recoverPreviewer();
  82512. }
  82513. if (this.toolbar) {
  82514. this.toolbar.showToolbar();
  82515. }
  82516. break;
  82517. case 'editOnly':
  82518. if (!this.previewer.isPreviewerHidden()) {
  82519. this.previewer.editOnly(true);
  82520. }
  82521. if (this.toolbar) {
  82522. this.toolbar.showToolbar();
  82523. }
  82524. break;
  82525. case 'previewOnly':
  82526. this.previewer.previewOnly();
  82527. this.toolbar && this.toolbar.previewOnly();
  82528. break;
  82529. }
  82530. }
  82531. /**
  82532. * 获取实例id
  82533. * @returns {string}
  82534. * @public
  82535. */
  82536. }, {
  82537. key: "getInstanceId",
  82538. value: function getInstanceId() {
  82539. return this.instanceId;
  82540. }
  82541. /**
  82542. * 获取编辑器状态
  82543. * @returns {Object}
  82544. */
  82545. }, {
  82546. key: "getStatus",
  82547. value: function getStatus() {
  82548. return this.status;
  82549. }
  82550. /**
  82551. * 获取编辑区内的markdown源码内容
  82552. * @returns markdown源码内容
  82553. */
  82554. }, {
  82555. key: "getValue",
  82556. value: function getValue() {
  82557. return this.editor.editor.getValue();
  82558. }
  82559. /**
  82560. * 获取编辑区内的markdown源码内容
  82561. * @returns markdown源码内容
  82562. */
  82563. }, {
  82564. key: "getMarkdown",
  82565. value: function getMarkdown() {
  82566. return this.getValue();
  82567. }
  82568. /**
  82569. * 获取CodeMirror实例
  82570. * @returns CodeMirror实例
  82571. */
  82572. }, {
  82573. key: "getCodeMirror",
  82574. value: function getCodeMirror() {
  82575. return this.editor.editor;
  82576. }
  82577. /**
  82578. * 获取预览区内的html内容
  82579. * @param {boolean} wrapTheme 是否在外层包裹主题class
  82580. * @returns html内容
  82581. */
  82582. }, {
  82583. key: "getHtml",
  82584. value: function getHtml() {
  82585. var wrapTheme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  82586. return this.previewer.getValue(wrapTheme);
  82587. }
  82588. }, {
  82589. key: "getPreviewer",
  82590. value: function getPreviewer() {
  82591. return this.previewer;
  82592. }
  82593. /**
  82594. * 获取目录,目录由head1~6组成
  82595. * @returns 标题head数组
  82596. */
  82597. }, {
  82598. key: "getTheme",
  82599. value: function getTheme() {
  82600. return getThemeFromLocal(true)
  82601. }
  82602. }, {
  82603. key: "setTheme",
  82604. value: function setTheme(theme) {
  82605. changeTheme(this, theme)
  82606. }
  82607. }, {
  82608. key: "getToc",
  82609. value: function getToc() {
  82610. var str = this.getHtml();
  82611. /** @type {({level: number;id: string;text: string})[]} */
  82612. var headerList = [];
  82613. var headerRegex = /<h([1-6]).*?id="([^"]+?)".*?>(.+?)<\/h[0-6]>/g;
  82614. str.replace(headerRegex, function (match, level, id, text) {
  82615. headerList.push({
  82616. level: +level,
  82617. id: id,
  82618. text: text
  82619. });
  82620. return match;
  82621. });
  82622. return headerList;
  82623. }
  82624. /**
  82625. * 覆盖编辑区的内容
  82626. * @param {string} content markdown内容
  82627. * @param {boolean} keepCursor 是否保持光标位置
  82628. * @returns
  82629. */
  82630. }, {
  82631. key: "setValue",
  82632. value: function setValue(content) {
  82633. var keepCursor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  82634. if (keepCursor === false) {
  82635. return this.editor.editor.setValue(content);
  82636. }
  82637. var codemirror = this.editor.editor;
  82638. var old = this.getValue();
  82639. var pos = codemirror.getDoc().indexFromPos(codemirror.getCursor());
  82640. var newPos = getPosBydiffs(pos, old, content);
  82641. var ret = codemirror.setValue(content);
  82642. var cursor = codemirror.getDoc().posFromIndex(newPos);
  82643. codemirror.setCursor(cursor);
  82644. return ret;
  82645. }
  82646. /**
  82647. * 在光标处或者指定行+偏移量插入内容
  82648. * @param {string} content 被插入的文本
  82649. * @param {boolean} [isSelect=false] 是否选中刚插入的内容
  82650. * @param {[number, number]|false} [anchor=false] [x,y] 代表x+1行,y+1字符偏移量,默认false 会从光标处插入
  82651. * @param {boolean} [focus=true] 保持编辑器处于focus状态
  82652. * @returns
  82653. */
  82654. }, {
  82655. key: "insert",
  82656. value: function insert(content) {
  82657. var isSelect = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  82658. var anchor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  82659. var focus = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  82660. if (anchor) {
  82661. this.editor.editor.setSelection({
  82662. line: anchor[0],
  82663. ch: anchor[1]
  82664. }, {
  82665. line: anchor[0],
  82666. ch: anchor[1]
  82667. });
  82668. }
  82669. var ret = this.editor.editor.replaceSelection(content, isSelect ? 'around' : 'end');
  82670. focus && this.editor.editor.focus();
  82671. return ret;
  82672. }
  82673. /**
  82674. * 在光标处或者指定行+偏移量插入内容
  82675. * @param {string} content 被插入的文本
  82676. * @param {boolean} [isSelect=false] 是否选中刚插入的内容
  82677. * @param {[number, number]|false} [anchor=false] [x,y] 代表x+1行,y+1字符偏移量,默认false 会从光标处插入
  82678. * @param {boolean} [focus=true] 保持编辑器处于focus状态
  82679. * @returns
  82680. */
  82681. }, {
  82682. key: "insertValue",
  82683. value: function insertValue(content) {
  82684. var isSelect = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  82685. var anchor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  82686. var focus = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  82687. return this.insert(content, isSelect, anchor, focus);
  82688. }
  82689. /**
  82690. * 强制重新渲染预览区域
  82691. */
  82692. }, {
  82693. key: "refreshPreviewer",
  82694. value: function refreshPreviewer() {
  82695. try {
  82696. var markdownText = this.getValue();
  82697. var html = this.engine.makeHtml(markdownText);
  82698. this.previewer.refresh(html);
  82699. } catch (e) {
  82700. throw new NestedError(e);
  82701. }
  82702. }
  82703. /**
  82704. * 覆盖编辑区的内容
  82705. * @param {string} content markdown内容
  82706. * @param {boolean} keepCursor 是否保持光标位置
  82707. * @returns
  82708. */
  82709. }, {
  82710. key: "setMarkdown",
  82711. value: function setMarkdown(content) {
  82712. var keepCursor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  82713. return this.setValue(content, keepCursor);
  82714. }
  82715. /**
  82716. * @private
  82717. * @returns
  82718. */
  82719. }, {
  82720. key: "createWrapper",
  82721. value: function createWrapper() {
  82722. var toolbarTheme = this.options.toolbars.theme === 'dark' ? 'dark' : ''; // TODO: 完善类型
  82723. var inlineCodeTheme =
  82724. /** @type {{theme?: string;}} */
  82725. this.options.engine.syntax.inlineCode.theme;
  82726. var codeBlockTheme =
  82727. /** @type {{theme?: string;}} */
  82728. this.options.engine.syntax.codeBlock.theme;
  82729. if (codeBlockTheme === 'dark') codeBlockTheme = 'tomorrow-night';else if (codeBlockTheme === 'light') codeBlockTheme = 'solarized-light';
  82730. var wrapperDom = createElement('div', ['cherry', 'clearfix', getThemeFromLocal(true)].join(' '), {
  82731. 'data-toolbarTheme': toolbarTheme,
  82732. 'data-inlineCodeTheme': inlineCodeTheme,
  82733. 'data-codeBlockTheme': codeBlockTheme
  82734. });
  82735. this.wrapperDom = wrapperDom;
  82736. return wrapperDom;
  82737. }
  82738. /**
  82739. * @private
  82740. * @returns {Toolbar}
  82741. */
  82742. }, {
  82743. key: "createToolbar",
  82744. value: function createToolbar() {
  82745. var dom = createElement('div', 'cherry-toolbar');
  82746. this.toolbar = new Toolbar({
  82747. dom: dom,
  82748. $cherry: this,
  82749. buttonRightConfig: this.options.toolbars.toolbarRight,
  82750. buttonConfig: this.options.toolbars.toolbar,
  82751. customMenu: this.options.toolbars.customMenu
  82752. });
  82753. return this.toolbar;
  82754. }
  82755. /**
  82756. * @private
  82757. * @returns
  82758. */
  82759. }, {
  82760. key: "createSidebar",
  82761. value: function createSidebar(wrapperFragment) {
  82762. if (this.options.toolbars.sidebar) {
  82763. $expectTarget(this.options.toolbars.sidebar, Array);
  82764. var externalClass = this.options.toolbars.theme === 'dark' ? 'dark' : '';
  82765. var dom = createElement('div', "cherry-sidebar ".concat(externalClass));
  82766. this.sidebar = new Sidebar({
  82767. dom: dom,
  82768. $cherry: this,
  82769. buttonConfig: this.options.toolbars.sidebar,
  82770. customMenu: this.options.toolbars.customMenu
  82771. });
  82772. wrapperFragment.appendChild(this.sidebar.options.dom);
  82773. }
  82774. }
  82775. /**
  82776. * @private
  82777. * @returns
  82778. */
  82779. }, {
  82780. key: "createFloatMenu",
  82781. value: function createFloatMenu() {
  82782. if (this.options.toolbars["float"]) {
  82783. var dom = createElement('div', 'cherry-floatmenu');
  82784. $expectTarget(this.options.toolbars["float"], Array);
  82785. this.floatMenu = new FloatMenu({
  82786. dom: dom,
  82787. $cherry: this,
  82788. buttonConfig: this.options.toolbars["float"],
  82789. customMenu: this.options.toolbars.customMenu
  82790. });
  82791. }
  82792. }
  82793. /**
  82794. * @private
  82795. * @returns
  82796. */
  82797. }, {
  82798. key: "createBubble",
  82799. value: function createBubble() {
  82800. if (this.options.toolbars.bubble) {
  82801. var dom = createElement('div', 'cherry-bubble');
  82802. $expectTarget(this.options.toolbars.bubble, Array);
  82803. this.bubble = new Bubble({
  82804. dom: dom,
  82805. $cherry: this,
  82806. buttonConfig: this.options.toolbars.bubble,
  82807. customMenu: this.options.toolbars.customMenu,
  82808. engine: this.engine
  82809. });
  82810. }
  82811. }
  82812. /**
  82813. * @private
  82814. * @returns {import('@/Editor').default}
  82815. */
  82816. }, {
  82817. key: "createEditor",
  82818. value: function createEditor() {
  82819. var _this$options$editor$, _this$options$editor$2, _context3, _context4;
  82820. var textArea = createElement('textarea', '', {
  82821. id: (_this$options$editor$ = this.options.editor.id) !== null && _this$options$editor$ !== void 0 ? _this$options$editor$ : 'code',
  82822. name: (_this$options$editor$2 = this.options.editor.name) !== null && _this$options$editor$2 !== void 0 ? _this$options$editor$2 : 'code'
  82823. });
  82824. textArea.textContent = this.options.value;
  82825. var editor = createElement('div', 'cherry-editor');
  82826. editor.appendChild(textArea);
  82827. this.editor = new Editor(_objectSpread$8({
  82828. $cherry: this,
  82829. editorDom: editor,
  82830. wrapperDom: this.wrapperDom,
  82831. value: this.options.value,
  82832. onKeydown: bind$5(_context3 = this.fireShortcutKey).call(_context3, this),
  82833. onChange: bind$5(_context4 = this.editText).call(_context4, this),
  82834. toolbars: this.options.toolbars,
  82835. fileUpload: this.options.fileUpload,
  82836. autoScrollByCursor: this.options.autoScrollByCursor
  82837. }, this.options.editor));
  82838. return this.editor;
  82839. }
  82840. /**
  82841. * @private
  82842. * @returns {import('@/Previewer').default}
  82843. */
  82844. }, {
  82845. key: "createPreviewer",
  82846. value: function createPreviewer() {
  82847. /** @type {HTMLDivElement} */
  82848. var previewer;
  82849. var anchorStyle = this.options.engine.syntax.header && this.options.engine.syntax.header.anchorStyle || 'default';
  82850. var autonumberClass = anchorStyle === 'autonumber' ? ' head-num' : '';
  82851. var _this$options$preview = this.options.previewer,
  82852. className = _this$options$preview.className,
  82853. dom = _this$options$preview.dom,
  82854. enablePreviewerBubble = _this$options$preview.enablePreviewerBubble;
  82855. var previewerClassName = ['cherry-previewer cherry-markdown', className || '', autonumberClass, getThemeFromLocal(true)].join(' ');
  82856. if (dom) {
  82857. previewer = dom;
  82858. previewer.className += " ".concat(previewerClassName);
  82859. } else {
  82860. previewer = createElement('div', previewerClassName);
  82861. }
  82862. var virtualDragLine = createElement('div', 'cherry-drag');
  82863. var editorMask = createElement('div', 'cherry-editor-mask');
  82864. var previewerMask = createElement('div', 'cherry-previewer-mask');
  82865. this.previewer = new Previewer({
  82866. $cherry: this,
  82867. virtualDragLineDom: virtualDragLine,
  82868. editorMaskDom: editorMask,
  82869. previewerMaskDom: previewerMask,
  82870. previewerDom: previewer,
  82871. value: this.options.value,
  82872. isPreviewOnly: this.options.isPreviewOnly,
  82873. enablePreviewerBubble: enablePreviewerBubble,
  82874. lazyLoadImg: this.options.previewer.lazyLoadImg
  82875. });
  82876. return this.previewer;
  82877. }
  82878. /**
  82879. * @private
  82880. * @param {import('codemirror').Editor} codemirror
  82881. */
  82882. }, {
  82883. key: "initText",
  82884. value: function initText(codemirror) {
  82885. try {
  82886. var markdownText = codemirror.getValue();
  82887. var html = this.engine.makeHtml(markdownText);
  82888. this.previewer.update(html);
  82889. if (this.options.callback.afterInit) {
  82890. this.options.callback.afterInit(markdownText, html);
  82891. }
  82892. } catch (e) {
  82893. throw new NestedError(e);
  82894. }
  82895. }
  82896. /**
  82897. * @private
  82898. * @param {Event} _evt
  82899. * @param {import('codemirror').Editor} codemirror
  82900. */
  82901. }, {
  82902. key: "editText",
  82903. value: function editText(_evt, codemirror) {
  82904. var _this3 = this;
  82905. try {
  82906. if (this.timer) {
  82907. clearTimeout(this.timer);
  82908. this.timer = null;
  82909. }
  82910. this.timer = setTimeout$3(function () {
  82911. var markdownText = codemirror.getValue();
  82912. var html = _this3.engine.makeHtml(markdownText);
  82913. _this3.previewer.update(html);
  82914. if (_this3.options.callback.afterChange) {
  82915. _this3.options.callback.afterChange(markdownText, html);
  82916. } // 强制每次编辑(包括undo、redo)编辑器都会自动滚动到光标位置
  82917. codemirror.scrollIntoView(null);
  82918. }, 50);
  82919. } catch (e) {
  82920. throw new NestedError(e);
  82921. }
  82922. }
  82923. /**
  82924. * @private
  82925. * @param {any} cb
  82926. */
  82927. }, {
  82928. key: "onChange",
  82929. value: function onChange(cb) {
  82930. this.editor.editor.on('change', function (codeMirror) {
  82931. cb({
  82932. markdown: codeMirror.getValue() // 后续可以按需增加html或其他状态
  82933. });
  82934. });
  82935. }
  82936. /**
  82937. * @private
  82938. * @param {*} evt
  82939. */
  82940. }, {
  82941. key: "fireShortcutKey",
  82942. value: function fireShortcutKey(evt) {
  82943. if (this.toolbar.matchShortcutKey(evt)) {
  82944. // 快捷键
  82945. evt.preventDefault();
  82946. this.toolbar.fireShortcutKey(evt);
  82947. }
  82948. }
  82949. /**
  82950. * 导出预览区域内容
  82951. * @public
  82952. * @param {String} type 'pdf':导出成pdf文件; 'img':导出成图片
  82953. * @param {String} fileName 导出文件名
  82954. */
  82955. }, {
  82956. key: "export",
  82957. value: function _export() {
  82958. var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'pdf';
  82959. var fileName = arguments.length > 1 ? arguments[1] : undefined;
  82960. this.previewer["export"](type, fileName);
  82961. }
  82962. /**
  82963. * 修改主题
  82964. * @param {string} theme option.theme里的className
  82965. */
  82966. }, {
  82967. key: "setTheme",
  82968. value: function setTheme() {
  82969. var theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
  82970. changeTheme(this, theme);
  82971. }
  82972. /**
  82973. * 修改书写风格
  82974. * @param {string} writingStyle normal 普通 | typewriter 打字机 | focus 专注
  82975. */
  82976. }, {
  82977. key: "setWritingStyle",
  82978. value: function setWritingStyle(writingStyle) {
  82979. this.editor.setWritingStyle(writingStyle);
  82980. }
  82981. }]);
  82982. return Cherry;
  82983. }(CherryStatic);
  82984. _defineProperty(Cherry, "initialized", false);
  82985. _defineProperty(Cherry, "config", {
  82986. /** @type {Partial<CherryOptions>} */
  82987. defaults: defaultConfig$1
  82988. });
  82989. /**
  82990. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  82991. *
  82992. * Licensed under the Apache License, Version 2.0 (the "License");
  82993. * you may not use this file except in compliance with the License.
  82994. * You may obtain a copy of the License at
  82995. *
  82996. * http://www.apache.org/licenses/LICENSE-2.0
  82997. *
  82998. * Unless required by applicable law or agreed to in writing, software
  82999. * distributed under the License is distributed on an "AS IS" BASIS,
  83000. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  83001. * See the License for the specific language governing permissions and
  83002. * limitations under the License.
  83003. */
  83004. if (window) {
  83005. // @ts-ignore
  83006. window.Cherry = Cherry;
  83007. }
  83008. function ownKeys$a(object, enumerableOnly) { var keys = keys$3(object); if (getOwnPropertySymbols$2) { var symbols = getOwnPropertySymbols$2(object); enumerableOnly && (symbols = filter$3(symbols).call(symbols, function (sym) { return getOwnPropertyDescriptor$3(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  83009. function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var _context4, _context5; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? forEach$3(_context4 = ownKeys$a(Object(source), !0)).call(_context4, function (key) { _defineProperty(target, key, source[key]); }) : getOwnPropertyDescriptors$2 ? defineProperties$2(target, getOwnPropertyDescriptors$2(source)) : forEach$3(_context5 = ownKeys$a(Object(source))).call(_context5, function (key) { defineProperty$5(target, key, getOwnPropertyDescriptor$3(source, key)); }); } return target; }
  83010. var DEFAULT_OPTIONS = {
  83011. // TODO: themes
  83012. theme: 'default',
  83013. altFontFamily: 'sans-serif',
  83014. fontFamily: 'sans-serif',
  83015. themeCSS: '.label foreignObject { font-size: 90%; overflow: visible; } .label { font-family: sans-serif; }',
  83016. flowchart: {
  83017. useMaxWidth: false
  83018. },
  83019. sequence: {
  83020. useMaxWidth: false
  83021. },
  83022. startOnLoad: false,
  83023. logLevel: 5 // fontFamily: 'Arial, monospace'
  83024. };
  83025. var MermaidCodeEngine = /*#__PURE__*/function () {
  83026. function MermaidCodeEngine() {
  83027. var mermaidOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  83028. _classCallCheck(this, MermaidCodeEngine);
  83029. _defineProperty(this, "mermaidAPIRefs", null);
  83030. _defineProperty(this, "options", DEFAULT_OPTIONS);
  83031. _defineProperty(this, "dom", null);
  83032. _defineProperty(this, "mermaidCanvas", null);
  83033. var mermaid = mermaidOptions.mermaid,
  83034. mermaidAPI = mermaidOptions.mermaidAPI;
  83035. if (!mermaidAPI && !window.mermaidAPI && (!mermaid || !mermaid.mermaidAPI) && (!window.mermaid || !window.mermaid.mermaidAPI)) {
  83036. throw new Error('code-block-mermaid-plugin[init]: Package mermaid or mermaidAPI not found.');
  83037. }
  83038. this.options = _objectSpread$9(_objectSpread$9({}, DEFAULT_OPTIONS), mermaidOptions || {});
  83039. this.mermaidAPIRefs = mermaidAPI || window.mermaidAPI || mermaid.mermaidAPI || window.mermaid.mermaidAPI;
  83040. delete this.options.mermaid;
  83041. delete this.options.mermaidAPI;
  83042. this.mermaidAPIRefs.initialize(this.options);
  83043. }
  83044. _createClass(MermaidCodeEngine, [{
  83045. key: "mountMermaidCanvas",
  83046. value: function mountMermaidCanvas($engine) {
  83047. if (this.mermaidCanvas && document.body.contains(this.mermaidCanvas)) {
  83048. return;
  83049. }
  83050. this.mermaidCanvas = document.createElement('div');
  83051. this.mermaidCanvas.style = 'width:1024px;opacity:0;position:fixed;top:100%;';
  83052. var container = $engine.$cherry.wrapperDom || document.body;
  83053. container.appendChild(this.mermaidCanvas);
  83054. }
  83055. /**
  83056. * 转换svg为img,如果出错则直出svg
  83057. * @param {string} svgCode
  83058. * @param {string} graphId
  83059. * @returns {string}
  83060. */
  83061. }, {
  83062. key: "convertMermaidSvgToImg",
  83063. value: function convertMermaidSvgToImg(svgCode, graphId) {
  83064. var domParser = new DOMParser();
  83065. var svgHtml;
  83066. var injectSvgFallback = function injectSvgFallback(svg) {
  83067. return svg.replace('<svg ', '<svg style="max-width:100%;height:auto;font-family:sans-serif;" ');
  83068. };
  83069. try {
  83070. var svgDoc =
  83071. /** @type {XMLDocument} */
  83072. domParser.parseFromString(svgCode, 'image/svg+xml');
  83073. var svgDom =
  83074. /** @type {SVGSVGElement} */
  83075. /** @type {any} */
  83076. svgDoc.documentElement; // tagName不是svg时,说明存在parse error
  83077. if (svgDom.tagName.toLowerCase() === 'svg') {
  83078. svgDom.style.maxWidth = '100%';
  83079. svgDom.style.height = 'auto';
  83080. svgDom.style.fontFamily = 'sans-serif';
  83081. var shadowSvg =
  83082. /** @type {SVGSVGElement} */
  83083. /** @type {any} */
  83084. document.getElementById(graphId);
  83085. var svgBox = shadowSvg.getBBox();
  83086. if (!svgDom.hasAttribute('viewBox')) {
  83087. var _context;
  83088. svgDom.setAttribute('viewBox', concat$5(_context = "0 0 ".concat(svgBox.width, " ")).call(_context, svgBox.height));
  83089. } else {
  83090. svgBox = svgDom.viewBox.baseVal;
  83091. }
  83092. svgDom.getAttribute('width') === '100%' && svgDom.setAttribute('width', "".concat(svgBox.width));
  83093. svgDom.getAttribute('height') === '100%' && svgDom.setAttribute('height', "".concat(svgBox.height)); // fix end
  83094. svgHtml = svgDoc.documentElement.outerHTML; // 屏蔽转img标签功能,如需要转换为img解除屏蔽即可
  83095. if (this.svg2img) {
  83096. var _context2;
  83097. var dataUrl = "data:image/svg+xml,".concat(encodeURIComponent(svgDoc.documentElement.outerHTML));
  83098. svgHtml = concat$5(_context2 = "<img class=\"svg-img\" src=\"".concat(dataUrl, "\" alt=\"")).call(_context2, graphId, "\" />");
  83099. }
  83100. } else {
  83101. svgHtml = injectSvgFallback(svgCode);
  83102. }
  83103. } catch (e) {
  83104. svgHtml = injectSvgFallback(svgCode);
  83105. }
  83106. return svgHtml;
  83107. }
  83108. }, {
  83109. key: "render",
  83110. value: function render(src, sign, $engine) {
  83111. var _context3,
  83112. _config$svg2img,
  83113. _this = this;
  83114. var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  83115. var $sign = sign;
  83116. if (!$sign) {
  83117. $sign = Math.round(Math.random() * 100000000);
  83118. }
  83119. this.mountMermaidCanvas($engine);
  83120. var html; // 多实例的情况下相同的内容ID相同会导致mermaid渲染异常
  83121. // 需要通过添加时间戳使得多次渲染相同内容的图像ID唯一
  83122. // 图像渲染节流在CodeBlock Hook内部控制
  83123. var graphId = concat$5(_context3 = "mermaid-".concat($sign, "-")).call(_context3, new Date().getTime());
  83124. this.svg2img = (_config$svg2img = config === null || config === void 0 ? void 0 : config.svg2img) !== null && _config$svg2img !== void 0 ? _config$svg2img : false;
  83125. try {
  83126. this.mermaidAPIRefs.render(graphId, src, function (svgCode) {
  83127. var fixedSvg = svgCode.replace(/\s*markerUnits="0"/g, '').replace(/\s*x="NaN"/g, '').replace(/<br>/g, '<br/>');
  83128. html = _this.convertMermaidSvgToImg(fixedSvg, graphId);
  83129. }, this.mermaidCanvas);
  83130. } catch (e) {
  83131. return e === null || e === void 0 ? void 0 : e.str;
  83132. }
  83133. return html;
  83134. }
  83135. }], [{
  83136. key: "install",
  83137. value: function install(cherryOptions) {
  83138. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  83139. args[_key - 1] = arguments[_key];
  83140. }
  83141. mergeWith_1(cherryOptions, {
  83142. engine: {
  83143. syntax: {
  83144. codeBlock: {
  83145. customRenderer: {
  83146. mermaid: _construct(MermaidCodeEngine, args)
  83147. }
  83148. }
  83149. }
  83150. }
  83151. });
  83152. }
  83153. }]);
  83154. return MermaidCodeEngine;
  83155. }();
  83156. _defineProperty(MermaidCodeEngine, "TYPE", 'figure');
  83157. // @ts-nocheck
  83158. /*
  83159. * $Id: rawdeflate.js,v 0.3 2009/03/01 19:05:05 dankogai Exp dankogai $
  83160. *
  83161. * Original:
  83162. * http://www.onicos.com/staff/iz/amuse/javascript/expert/deflate.txt
  83163. */
  83164. // if run as a web worker, respond to messages by deflating them
  83165. var deflate = function () {
  83166. /* Copyright (C) 1999 Masanao Izumo <[email protected]>
  83167. * Version: 1.0.1
  83168. * LastModified: Dec 25 1999
  83169. */
  83170. /* Interface:
  83171. * data = deflate(src);
  83172. */
  83173. /* constant parameters */
  83174. var zip_WSIZE = 32768; // Sliding Window size
  83175. var zip_STORED_BLOCK = 0;
  83176. var zip_STATIC_TREES = 1;
  83177. var zip_DYN_TREES = 2;
  83178. /* for deflate */
  83179. var zip_DEFAULT_LEVEL = 6;
  83180. var zip_INBUFSIZ = 32768; // Input buffer size
  83181. var zip_INBUF_EXTRA = 64; // Extra buffer
  83182. var zip_OUTBUFSIZ = 1024 * 8;
  83183. var zip_window_size = 2 * zip_WSIZE;
  83184. var zip_MIN_MATCH = 3;
  83185. var zip_MAX_MATCH = 258;
  83186. var zip_BITS = 16; // for SMALL_MEM
  83187. var zip_LIT_BUFSIZE = 0x2000;
  83188. var zip_HASH_BITS = 13; // for MEDIUM_MEM
  83189. // var zip_LIT_BUFSIZE = 0x4000;
  83190. // var zip_HASH_BITS = 14;
  83191. // for BIG_MEM
  83192. // var zip_LIT_BUFSIZE = 0x8000;
  83193. // var zip_HASH_BITS = 15;
  83194. // if(zip_LIT_BUFSIZE > zip_INBUFSIZ)
  83195. // alert("error: zip_INBUFSIZ is too small");
  83196. // if((zip_WSIZE<<1) > (1<<zip_BITS))
  83197. // alert("error: zip_WSIZE is too large");
  83198. // if(zip_HASH_BITS > zip_BITS-1)
  83199. // alert("error: zip_HASH_BITS is too large");
  83200. // if(zip_HASH_BITS < 8 || zip_MAX_MATCH != 258)
  83201. // alert("error: Code too clever");
  83202. var zip_DIST_BUFSIZE = zip_LIT_BUFSIZE;
  83203. var zip_HASH_SIZE = 1 << zip_HASH_BITS;
  83204. var zip_HASH_MASK = zip_HASH_SIZE - 1;
  83205. var zip_WMASK = zip_WSIZE - 1;
  83206. var zip_NIL = 0; // Tail of hash chains
  83207. var zip_TOO_FAR = 4096;
  83208. var zip_MIN_LOOKAHEAD = zip_MAX_MATCH + zip_MIN_MATCH + 1;
  83209. var zip_MAX_DIST = zip_WSIZE - zip_MIN_LOOKAHEAD;
  83210. var zip_SMALLEST = 1;
  83211. var zip_MAX_BITS = 15;
  83212. var zip_MAX_BL_BITS = 7;
  83213. var zip_LENGTH_CODES = 29;
  83214. var zip_LITERALS = 256;
  83215. var zip_END_BLOCK = 256;
  83216. var zip_L_CODES = zip_LITERALS + 1 + zip_LENGTH_CODES;
  83217. var zip_D_CODES = 30;
  83218. var zip_BL_CODES = 19;
  83219. var zip_REP_3_6 = 16;
  83220. var zip_REPZ_3_10 = 17;
  83221. var zip_REPZ_11_138 = 18;
  83222. var zip_HEAP_SIZE = 2 * zip_L_CODES + 1;
  83223. var zip_H_SHIFT = _parseInt$2((zip_HASH_BITS + zip_MIN_MATCH - 1) / zip_MIN_MATCH);
  83224. /* variables */
  83225. var zip_free_queue;
  83226. var zip_qhead;
  83227. var zip_qtail;
  83228. var zip_initflag;
  83229. var zip_outbuf = null;
  83230. var zip_outcnt;
  83231. var zip_outoff;
  83232. var zip_complete;
  83233. var zip_window;
  83234. var zip_d_buf;
  83235. var zip_l_buf;
  83236. var zip_prev;
  83237. var zip_bi_buf;
  83238. var zip_bi_valid;
  83239. var zip_block_start;
  83240. var zip_ins_h;
  83241. var zip_hash_head;
  83242. var zip_prev_match;
  83243. var zip_match_available;
  83244. var zip_match_length;
  83245. var zip_prev_length;
  83246. var zip_strstart;
  83247. var zip_match_start;
  83248. var zip_eofile;
  83249. var zip_lookahead;
  83250. var zip_max_chain_length;
  83251. var zip_max_lazy_match;
  83252. var zip_compr_level;
  83253. var zip_good_match;
  83254. var zip_dyn_ltree;
  83255. var zip_dyn_dtree;
  83256. var zip_static_ltree;
  83257. var zip_static_dtree;
  83258. var zip_bl_tree;
  83259. var zip_l_desc;
  83260. var zip_d_desc;
  83261. var zip_bl_desc;
  83262. var zip_bl_count;
  83263. var zip_heap;
  83264. var zip_heap_len;
  83265. var zip_heap_max;
  83266. var zip_depth;
  83267. var zip_length_code;
  83268. var zip_dist_code;
  83269. var zip_base_length;
  83270. var zip_base_dist;
  83271. var zip_flag_buf;
  83272. var zip_last_lit;
  83273. var zip_last_dist;
  83274. var zip_last_flags;
  83275. var zip_flags;
  83276. var zip_flag_bit;
  83277. var zip_opt_len;
  83278. var zip_static_len;
  83279. var zip_deflate_data;
  83280. var zip_deflate_pos;
  83281. /* objects (deflate) */
  83282. function zip_DeflateCT() {
  83283. this.fc = 0; // frequency count or bit string
  83284. this.dl = 0; // father node in Huffman tree or length of bit string
  83285. }
  83286. function zip_DeflateTreeDesc() {
  83287. this.dyn_tree = null; // the dynamic tree
  83288. this.static_tree = null; // corresponding static tree or NULL
  83289. this.extra_bits = null; // extra bits for each code or NULL
  83290. this.extra_base = 0; // base index for extra_bits
  83291. this.elems = 0; // max number of elements in the tree
  83292. this.max_length = 0; // max bit length for the codes
  83293. this.max_code = 0; // largest code with non zero frequency
  83294. }
  83295. /* Values for max_lazy_match, good_match and max_chain_length, depending on
  83296. * the desired pack level (0..9). The values given below have been tuned to
  83297. * exclude worst case performance for pathological files. Better values may be
  83298. * found for specific files.
  83299. */
  83300. function zip_DeflateConfiguration(a, b, c, d) {
  83301. this.good_length = a; // reduce lazy search above this match length
  83302. this.max_lazy = b; // do not perform lazy search above this match length
  83303. this.nice_length = c; // quit search above this match length
  83304. this.max_chain = d;
  83305. }
  83306. function zip_DeflateBuffer() {
  83307. this.next = null;
  83308. this.len = 0;
  83309. this.ptr = new Array(zip_OUTBUFSIZ);
  83310. this.off = 0;
  83311. }
  83312. /* constant tables */
  83313. var zip_extra_lbits = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0];
  83314. var zip_extra_dbits = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13];
  83315. var zip_extra_blbits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7];
  83316. var zip_bl_order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
  83317. var zip_configuration_table = [new zip_DeflateConfiguration(0, 0, 0, 0), new zip_DeflateConfiguration(4, 4, 8, 4), new zip_DeflateConfiguration(4, 5, 16, 8), new zip_DeflateConfiguration(4, 6, 32, 32), new zip_DeflateConfiguration(4, 4, 16, 16), new zip_DeflateConfiguration(8, 16, 32, 32), new zip_DeflateConfiguration(8, 16, 128, 128), new zip_DeflateConfiguration(8, 32, 128, 256), new zip_DeflateConfiguration(32, 128, 258, 1024), new zip_DeflateConfiguration(32, 258, 258, 4096)];
  83318. /* routines (deflate) */
  83319. function zip_deflate_start(level) {
  83320. var i;
  83321. if (!level) level = zip_DEFAULT_LEVEL;else if (level < 1) level = 1;else if (level > 9) level = 9;
  83322. zip_compr_level = level;
  83323. zip_initflag = false;
  83324. zip_eofile = false;
  83325. if (zip_outbuf != null) return;
  83326. zip_free_queue = zip_qhead = zip_qtail = null;
  83327. zip_outbuf = new Array(zip_OUTBUFSIZ);
  83328. zip_window = new Array(zip_window_size);
  83329. zip_d_buf = new Array(zip_DIST_BUFSIZE);
  83330. zip_l_buf = new Array(zip_INBUFSIZ + zip_INBUF_EXTRA);
  83331. zip_prev = new Array(1 << zip_BITS);
  83332. zip_dyn_ltree = new Array(zip_HEAP_SIZE);
  83333. for (i = 0; i < zip_HEAP_SIZE; i++) {
  83334. zip_dyn_ltree[i] = new zip_DeflateCT();
  83335. }
  83336. zip_dyn_dtree = new Array(2 * zip_D_CODES + 1);
  83337. for (i = 0; i < 2 * zip_D_CODES + 1; i++) {
  83338. zip_dyn_dtree[i] = new zip_DeflateCT();
  83339. }
  83340. zip_static_ltree = new Array(zip_L_CODES + 2);
  83341. for (i = 0; i < zip_L_CODES + 2; i++) {
  83342. zip_static_ltree[i] = new zip_DeflateCT();
  83343. }
  83344. zip_static_dtree = new Array(zip_D_CODES);
  83345. for (i = 0; i < zip_D_CODES; i++) {
  83346. zip_static_dtree[i] = new zip_DeflateCT();
  83347. }
  83348. zip_bl_tree = new Array(2 * zip_BL_CODES + 1);
  83349. for (i = 0; i < 2 * zip_BL_CODES + 1; i++) {
  83350. zip_bl_tree[i] = new zip_DeflateCT();
  83351. }
  83352. zip_l_desc = new zip_DeflateTreeDesc();
  83353. zip_d_desc = new zip_DeflateTreeDesc();
  83354. zip_bl_desc = new zip_DeflateTreeDesc();
  83355. zip_bl_count = new Array(zip_MAX_BITS + 1);
  83356. zip_heap = new Array(2 * zip_L_CODES + 1);
  83357. zip_depth = new Array(2 * zip_L_CODES + 1);
  83358. zip_length_code = new Array(zip_MAX_MATCH - zip_MIN_MATCH + 1);
  83359. zip_dist_code = new Array(512);
  83360. zip_base_length = new Array(zip_LENGTH_CODES);
  83361. zip_base_dist = new Array(zip_D_CODES);
  83362. zip_flag_buf = new Array(_parseInt$2(zip_LIT_BUFSIZE / 8));
  83363. }
  83364. function zip_reuse_queue(p) {
  83365. p.next = zip_free_queue;
  83366. zip_free_queue = p;
  83367. }
  83368. function zip_new_queue() {
  83369. var p;
  83370. if (zip_free_queue != null) {
  83371. p = zip_free_queue;
  83372. zip_free_queue = zip_free_queue.next;
  83373. } else p = new zip_DeflateBuffer();
  83374. p.next = null;
  83375. p.len = p.off = 0;
  83376. return p;
  83377. }
  83378. function zip_head1(i) {
  83379. return zip_prev[zip_WSIZE + i];
  83380. }
  83381. function zip_head2(i, val) {
  83382. return zip_prev[zip_WSIZE + i] = val;
  83383. }
  83384. /* put_byte is used for the compressed output, put_ubyte for the
  83385. * uncompressed output. However unlzw() uses window for its
  83386. * suffix table instead of its output buffer, so it does not use put_ubyte
  83387. * (to be cleaned up).
  83388. */
  83389. function zip_put_byte(c) {
  83390. zip_outbuf[zip_outoff + zip_outcnt++] = c;
  83391. if (zip_outoff + zip_outcnt == zip_OUTBUFSIZ) zip_qoutbuf();
  83392. }
  83393. /* Output a 16 bit value, lsb first */
  83394. function zip_put_short(w) {
  83395. w &= 0xffff;
  83396. if (zip_outoff + zip_outcnt < zip_OUTBUFSIZ - 2) {
  83397. zip_outbuf[zip_outoff + zip_outcnt++] = w & 0xff;
  83398. zip_outbuf[zip_outoff + zip_outcnt++] = w >>> 8;
  83399. } else {
  83400. zip_put_byte(w & 0xff);
  83401. zip_put_byte(w >>> 8);
  83402. }
  83403. }
  83404. /* ==========================================================================
  83405. * Insert string s in the dictionary and set match_head to the previous head
  83406. * of the hash chain (the most recent string with same hash key). Return
  83407. * the previous length of the hash chain.
  83408. * IN assertion: all calls to to INSERT_STRING are made with consecutive
  83409. * input characters and the first MIN_MATCH bytes of s are valid
  83410. * (except for the last MIN_MATCH-1 bytes of the input file).
  83411. */
  83412. function zip_INSERT_STRING() {
  83413. zip_ins_h = (zip_ins_h << zip_H_SHIFT ^ zip_window[zip_strstart + zip_MIN_MATCH - 1] & 0xff) & zip_HASH_MASK;
  83414. zip_hash_head = zip_head1(zip_ins_h);
  83415. zip_prev[zip_strstart & zip_WMASK] = zip_hash_head;
  83416. zip_head2(zip_ins_h, zip_strstart);
  83417. }
  83418. /* Send a code of the given tree. c and tree must not have side effects */
  83419. function zip_SEND_CODE(c, tree) {
  83420. zip_send_bits(tree[c].fc, tree[c].dl);
  83421. }
  83422. /* Mapping from a distance to a distance code. dist is the distance - 1 and
  83423. * must not have side effects. dist_code[256] and dist_code[257] are never
  83424. * used.
  83425. */
  83426. function zip_D_CODE(dist) {
  83427. return (dist < 256 ? zip_dist_code[dist] : zip_dist_code[256 + (dist >> 7)]) & 0xff;
  83428. }
  83429. /* ==========================================================================
  83430. * Compares to subtrees, using the tree depth as tie breaker when
  83431. * the subtrees have equal frequency. This minimizes the worst case length.
  83432. */
  83433. function zip_SMALLER(tree, n, m) {
  83434. return tree[n].fc < tree[m].fc || tree[n].fc == tree[m].fc && zip_depth[n] <= zip_depth[m];
  83435. }
  83436. /* ==========================================================================
  83437. * read string data
  83438. */
  83439. function zip_read_buff(buff, offset, n) {
  83440. var i;
  83441. for (i = 0; i < n && zip_deflate_pos < zip_deflate_data.length; i++) {
  83442. buff[offset + i] = zip_deflate_data.charCodeAt(zip_deflate_pos++) & 0xff;
  83443. }
  83444. return i;
  83445. }
  83446. /* ==========================================================================
  83447. * Initialize the "longest match" routines for a new file
  83448. */
  83449. function zip_lm_init() {
  83450. var j;
  83451. /* Initialize the hash table. */
  83452. for (j = 0; j < zip_HASH_SIZE; j++) {
  83453. // zip_head2(j, zip_NIL);
  83454. zip_prev[zip_WSIZE + j] = 0;
  83455. }
  83456. /* prev will be initialized on the fly */
  83457. /* Set the default configuration parameters:
  83458. */
  83459. zip_max_lazy_match = zip_configuration_table[zip_compr_level].max_lazy;
  83460. zip_good_match = zip_configuration_table[zip_compr_level].good_length;
  83461. zip_max_chain_length = zip_configuration_table[zip_compr_level].max_chain;
  83462. zip_strstart = 0;
  83463. zip_block_start = 0;
  83464. zip_lookahead = zip_read_buff(zip_window, 0, 2 * zip_WSIZE);
  83465. if (zip_lookahead <= 0) {
  83466. zip_eofile = true;
  83467. zip_lookahead = 0;
  83468. return;
  83469. }
  83470. zip_eofile = false;
  83471. /* Make sure that we always have enough lookahead. This is important
  83472. * if input comes from a device such as a tty.
  83473. */
  83474. while (zip_lookahead < zip_MIN_LOOKAHEAD && !zip_eofile) {
  83475. zip_fill_window();
  83476. }
  83477. /* If lookahead < MIN_MATCH, ins_h is garbage, but this is
  83478. * not important since only literal bytes will be emitted.
  83479. */
  83480. zip_ins_h = 0;
  83481. for (j = 0; j < zip_MIN_MATCH - 1; j++) {
  83482. // UPDATE_HASH(ins_h, window[j]);
  83483. zip_ins_h = (zip_ins_h << zip_H_SHIFT ^ zip_window[j] & 0xff) & zip_HASH_MASK;
  83484. }
  83485. }
  83486. /* ==========================================================================
  83487. * Set match_start to the longest match starting at the given string and
  83488. * return its length. Matches shorter or equal to prev_length are discarded,
  83489. * in which case the result is equal to prev_length and match_start is
  83490. * garbage.
  83491. * IN assertions: cur_match is the head of the hash chain for the current
  83492. * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
  83493. */
  83494. function zip_longest_match(cur_match) {
  83495. var chain_length = zip_max_chain_length; // max hash chain length
  83496. var scanp = zip_strstart; // current string
  83497. var matchp; // matched string
  83498. var len; // length of current match
  83499. var best_len = zip_prev_length; // best match length so far
  83500. /* Stop when cur_match becomes <= limit. To simplify the code,
  83501. * we prevent matches with the string of window index 0.
  83502. */
  83503. var limit = zip_strstart > zip_MAX_DIST ? zip_strstart - zip_MAX_DIST : zip_NIL;
  83504. var strendp = zip_strstart + zip_MAX_MATCH;
  83505. var scan_end1 = zip_window[scanp + best_len - 1];
  83506. var scan_end = zip_window[scanp + best_len];
  83507. /* Do not waste too much time if we already have a good match: */
  83508. if (zip_prev_length >= zip_good_match) chain_length >>= 2; // Assert(encoder->strstart <= window_size-MIN_LOOKAHEAD, "insufficient lookahead");
  83509. do {
  83510. // Assert(cur_match < encoder->strstart, "no future");
  83511. matchp = cur_match;
  83512. /* Skip to next match if the match length cannot increase
  83513. * or if the match length is less than 2:
  83514. */
  83515. if (zip_window[matchp + best_len] != scan_end || zip_window[matchp + best_len - 1] != scan_end1 || zip_window[matchp] != zip_window[scanp] || zip_window[++matchp] != zip_window[scanp + 1]) {
  83516. continue;
  83517. }
  83518. /* The check at best_len-1 can be removed because it will be made
  83519. * again later. (This heuristic is not always a win.)
  83520. * It is not necessary to compare scan[2] and match[2] since they
  83521. * are always equal when the other bytes match, given that
  83522. * the hash keys are equal and that HASH_BITS >= 8.
  83523. */
  83524. scanp += 2;
  83525. matchp++;
  83526. /* We check for insufficient lookahead only every 8th comparison;
  83527. * the 256th check will be made at strstart+258.
  83528. */
  83529. do {} while (zip_window[++scanp] == zip_window[++matchp] && zip_window[++scanp] == zip_window[++matchp] && zip_window[++scanp] == zip_window[++matchp] && zip_window[++scanp] == zip_window[++matchp] && zip_window[++scanp] == zip_window[++matchp] && zip_window[++scanp] == zip_window[++matchp] && zip_window[++scanp] == zip_window[++matchp] && zip_window[++scanp] == zip_window[++matchp] && scanp < strendp);
  83530. len = zip_MAX_MATCH - (strendp - scanp);
  83531. scanp = strendp - zip_MAX_MATCH;
  83532. if (len > best_len) {
  83533. zip_match_start = cur_match;
  83534. best_len = len;
  83535. {
  83536. if (len >= zip_MAX_MATCH) break;
  83537. }
  83538. scan_end1 = zip_window[scanp + best_len - 1];
  83539. scan_end = zip_window[scanp + best_len];
  83540. }
  83541. } while ((cur_match = zip_prev[cur_match & zip_WMASK]) > limit && --chain_length != 0);
  83542. return best_len;
  83543. }
  83544. /* ==========================================================================
  83545. * Fill the window when the lookahead becomes insufficient.
  83546. * Updates strstart and lookahead, and sets eofile if end of input file.
  83547. * IN assertion: lookahead < MIN_LOOKAHEAD && strstart + lookahead > 0
  83548. * OUT assertions: at least one byte has been read, or eofile is set;
  83549. * file reads are performed for at least two bytes (required for the
  83550. * translate_eol option).
  83551. */
  83552. function zip_fill_window() {
  83553. var n;
  83554. var m; // Amount of free space at the end of the window.
  83555. var more = zip_window_size - zip_lookahead - zip_strstart;
  83556. /* If the window is almost full and there is insufficient lookahead,
  83557. * move the upper half to the lower one to make room in the upper half.
  83558. */
  83559. if (more == -1) {
  83560. /* Very unlikely, but possible on 16 bit machine if strstart == 0
  83561. * and lookahead == 1 (input done one byte at time)
  83562. */
  83563. more--;
  83564. } else if (zip_strstart >= zip_WSIZE + zip_MAX_DIST) {
  83565. /* By the IN assertion, the window is not empty so we can't confuse
  83566. * more == 0 with more == 64K on a 16 bit machine.
  83567. */
  83568. // Assert(window_size == (ulg)2*WSIZE, "no sliding with BIG_MEM");
  83569. // System.arraycopy(window, WSIZE, window, 0, WSIZE);
  83570. for (n = 0; n < zip_WSIZE; n++) {
  83571. zip_window[n] = zip_window[n + zip_WSIZE];
  83572. }
  83573. zip_match_start -= zip_WSIZE;
  83574. zip_strstart -= zip_WSIZE;
  83575. /* we now have strstart >= MAX_DIST: */
  83576. zip_block_start -= zip_WSIZE;
  83577. for (n = 0; n < zip_HASH_SIZE; n++) {
  83578. m = zip_head1(n);
  83579. zip_head2(n, m >= zip_WSIZE ? m - zip_WSIZE : zip_NIL);
  83580. }
  83581. for (n = 0; n < zip_WSIZE; n++) {
  83582. /* If n is not on any hash chain, prev[n] is garbage but
  83583. * its value will never be used.
  83584. */
  83585. m = zip_prev[n];
  83586. zip_prev[n] = m >= zip_WSIZE ? m - zip_WSIZE : zip_NIL;
  83587. }
  83588. more += zip_WSIZE;
  83589. } // At this point, more >= 2
  83590. if (!zip_eofile) {
  83591. n = zip_read_buff(zip_window, zip_strstart + zip_lookahead, more);
  83592. if (n <= 0) zip_eofile = true;else zip_lookahead += n;
  83593. }
  83594. }
  83595. /* ==========================================================================
  83596. * Processes a new input file and return its compressed length. This
  83597. * function does not perform lazy evaluationof matches and inserts
  83598. * new strings in the dictionary only for unmatched strings or for short
  83599. * matches. It is used only for the fast compression options.
  83600. */
  83601. function zip_deflate_fast() {
  83602. while (zip_lookahead != 0 && zip_qhead == null) {
  83603. var flush; // set if current block must be flushed
  83604. /* Insert the string window[strstart .. strstart+2] in the
  83605. * dictionary, and set hash_head to the head of the hash chain:
  83606. */
  83607. zip_INSERT_STRING();
  83608. /* Find the longest match, discarding those <= prev_length.
  83609. * At this point we have always match_length < MIN_MATCH
  83610. */
  83611. if (zip_hash_head != zip_NIL && zip_strstart - zip_hash_head <= zip_MAX_DIST) {
  83612. /* To simplify the code, we prevent matches with the string
  83613. * of window index 0 (in particular we have to avoid a match
  83614. * of the string with itself at the start of the input file).
  83615. */
  83616. zip_match_length = zip_longest_match(zip_hash_head);
  83617. /* longest_match() sets match_start */
  83618. if (zip_match_length > zip_lookahead) zip_match_length = zip_lookahead;
  83619. }
  83620. if (zip_match_length >= zip_MIN_MATCH) {
  83621. // check_match(strstart, match_start, match_length);
  83622. flush = zip_ct_tally(zip_strstart - zip_match_start, zip_match_length - zip_MIN_MATCH);
  83623. zip_lookahead -= zip_match_length;
  83624. /* Insert new strings in the hash table only if the match length
  83625. * is not too large. This saves time but degrades compression.
  83626. */
  83627. if (zip_match_length <= zip_max_lazy_match) {
  83628. zip_match_length--; // string at strstart already in hash table
  83629. do {
  83630. zip_strstart++;
  83631. zip_INSERT_STRING();
  83632. /* strstart never exceeds WSIZE-MAX_MATCH, so there are
  83633. * always MIN_MATCH bytes ahead. If lookahead < MIN_MATCH
  83634. * these bytes are garbage, but it does not matter since
  83635. * the next lookahead bytes will be emitted as literals.
  83636. */
  83637. } while (--zip_match_length != 0);
  83638. zip_strstart++;
  83639. } else {
  83640. zip_strstart += zip_match_length;
  83641. zip_match_length = 0;
  83642. zip_ins_h = zip_window[zip_strstart] & 0xff; // UPDATE_HASH(ins_h, window[strstart + 1]);
  83643. zip_ins_h = (zip_ins_h << zip_H_SHIFT ^ zip_window[zip_strstart + 1] & 0xff) & zip_HASH_MASK; // #if MIN_MATCH != 3
  83644. // Call UPDATE_HASH() MIN_MATCH-3 more times
  83645. // #endif
  83646. }
  83647. } else {
  83648. /* No match, output a literal byte */
  83649. flush = zip_ct_tally(0, zip_window[zip_strstart] & 0xff);
  83650. zip_lookahead--;
  83651. zip_strstart++;
  83652. }
  83653. if (flush) {
  83654. zip_flush_block(0);
  83655. zip_block_start = zip_strstart;
  83656. }
  83657. /* Make sure that we always have enough lookahead, except
  83658. * at the end of the input file. We need MAX_MATCH bytes
  83659. * for the next match, plus MIN_MATCH bytes to insert the
  83660. * string following the next match.
  83661. */
  83662. while (zip_lookahead < zip_MIN_LOOKAHEAD && !zip_eofile) {
  83663. zip_fill_window();
  83664. }
  83665. }
  83666. }
  83667. function zip_deflate_better() {
  83668. /* Process the input block. */
  83669. while (zip_lookahead != 0 && zip_qhead == null) {
  83670. /* Insert the string window[strstart .. strstart+2] in the
  83671. * dictionary, and set hash_head to the head of the hash chain:
  83672. */
  83673. zip_INSERT_STRING();
  83674. /* Find the longest match, discarding those <= prev_length.
  83675. */
  83676. zip_prev_length = zip_match_length;
  83677. zip_prev_match = zip_match_start;
  83678. zip_match_length = zip_MIN_MATCH - 1;
  83679. if (zip_hash_head != zip_NIL && zip_prev_length < zip_max_lazy_match && zip_strstart - zip_hash_head <= zip_MAX_DIST) {
  83680. /* To simplify the code, we prevent matches with the string
  83681. * of window index 0 (in particular we have to avoid a match
  83682. * of the string with itself at the start of the input file).
  83683. */
  83684. zip_match_length = zip_longest_match(zip_hash_head);
  83685. /* longest_match() sets match_start */
  83686. if (zip_match_length > zip_lookahead) zip_match_length = zip_lookahead;
  83687. /* Ignore a length 3 match if it is too distant: */
  83688. if (zip_match_length == zip_MIN_MATCH && zip_strstart - zip_match_start > zip_TOO_FAR) {
  83689. /* If prev_match is also MIN_MATCH, match_start is garbage
  83690. * but we will ignore the current match anyway.
  83691. */
  83692. zip_match_length--;
  83693. }
  83694. }
  83695. /* If there was a match at the previous step and the current
  83696. * match is not better, output the previous match:
  83697. */
  83698. if (zip_prev_length >= zip_MIN_MATCH && zip_match_length <= zip_prev_length) {
  83699. var flush; // set if current block must be flushed
  83700. // check_match(strstart - 1, prev_match, prev_length);
  83701. flush = zip_ct_tally(zip_strstart - 1 - zip_prev_match, zip_prev_length - zip_MIN_MATCH);
  83702. /* Insert in hash table all strings up to the end of the match.
  83703. * strstart-1 and strstart are already inserted.
  83704. */
  83705. zip_lookahead -= zip_prev_length - 1;
  83706. zip_prev_length -= 2;
  83707. do {
  83708. zip_strstart++;
  83709. zip_INSERT_STRING();
  83710. /* strstart never exceeds WSIZE-MAX_MATCH, so there are
  83711. * always MIN_MATCH bytes ahead. If lookahead < MIN_MATCH
  83712. * these bytes are garbage, but it does not matter since the
  83713. * next lookahead bytes will always be emitted as literals.
  83714. */
  83715. } while (--zip_prev_length != 0);
  83716. zip_match_available = 0;
  83717. zip_match_length = zip_MIN_MATCH - 1;
  83718. zip_strstart++;
  83719. if (flush) {
  83720. zip_flush_block(0);
  83721. zip_block_start = zip_strstart;
  83722. }
  83723. } else if (zip_match_available != 0) {
  83724. /* If there was no match at the previous position, output a
  83725. * single literal. If there was a match but the current match
  83726. * is longer, truncate the previous match to a single literal.
  83727. */
  83728. if (zip_ct_tally(0, zip_window[zip_strstart - 1] & 0xff)) {
  83729. zip_flush_block(0);
  83730. zip_block_start = zip_strstart;
  83731. }
  83732. zip_strstart++;
  83733. zip_lookahead--;
  83734. } else {
  83735. /* There is no previous match to compare with, wait for
  83736. * the next step to decide.
  83737. */
  83738. zip_match_available = 1;
  83739. zip_strstart++;
  83740. zip_lookahead--;
  83741. }
  83742. /* Make sure that we always have enough lookahead, except
  83743. * at the end of the input file. We need MAX_MATCH bytes
  83744. * for the next match, plus MIN_MATCH bytes to insert the
  83745. * string following the next match.
  83746. */
  83747. while (zip_lookahead < zip_MIN_LOOKAHEAD && !zip_eofile) {
  83748. zip_fill_window();
  83749. }
  83750. }
  83751. }
  83752. function zip_init_deflate() {
  83753. if (zip_eofile) return;
  83754. zip_bi_buf = 0;
  83755. zip_bi_valid = 0;
  83756. zip_ct_init();
  83757. zip_lm_init();
  83758. zip_qhead = null;
  83759. zip_outcnt = 0;
  83760. zip_outoff = 0;
  83761. if (zip_compr_level <= 3) {
  83762. zip_prev_length = zip_MIN_MATCH - 1;
  83763. zip_match_length = 0;
  83764. } else {
  83765. zip_match_length = zip_MIN_MATCH - 1;
  83766. zip_match_available = 0;
  83767. }
  83768. zip_complete = false;
  83769. }
  83770. /* ==========================================================================
  83771. * Same as above, but achieves better compression. We use a lazy
  83772. * evaluation for matches: a match is finally adopted only if there is
  83773. * no better match at the next window position.
  83774. */
  83775. function zip_deflate_internal(buff, off, buff_size) {
  83776. var n;
  83777. if (!zip_initflag) {
  83778. zip_init_deflate();
  83779. zip_initflag = true;
  83780. if (zip_lookahead == 0) {
  83781. // empty
  83782. zip_complete = true;
  83783. return 0;
  83784. }
  83785. }
  83786. if ((n = zip_qcopy(buff, off, buff_size)) == buff_size) return buff_size;
  83787. if (zip_complete) return n;
  83788. if (zip_compr_level <= 3) // optimized for speed
  83789. zip_deflate_fast();else zip_deflate_better();
  83790. if (zip_lookahead == 0) {
  83791. if (zip_match_available != 0) zip_ct_tally(0, zip_window[zip_strstart - 1] & 0xff);
  83792. zip_flush_block(1);
  83793. zip_complete = true;
  83794. }
  83795. return n + zip_qcopy(buff, n + off, buff_size - n);
  83796. }
  83797. function zip_qcopy(buff, off, buff_size) {
  83798. var n;
  83799. var i;
  83800. var j;
  83801. n = 0;
  83802. while (zip_qhead != null && n < buff_size) {
  83803. i = buff_size - n;
  83804. if (i > zip_qhead.len) i = zip_qhead.len; // System.arraycopy(qhead.ptr, qhead.off, buff, off + n, i);
  83805. for (j = 0; j < i; j++) {
  83806. buff[off + n + j] = zip_qhead.ptr[zip_qhead.off + j];
  83807. }
  83808. zip_qhead.off += i;
  83809. zip_qhead.len -= i;
  83810. n += i;
  83811. if (zip_qhead.len == 0) {
  83812. var p;
  83813. p = zip_qhead;
  83814. zip_qhead = zip_qhead.next;
  83815. zip_reuse_queue(p);
  83816. }
  83817. }
  83818. if (n == buff_size) return n;
  83819. if (zip_outoff < zip_outcnt) {
  83820. i = buff_size - n;
  83821. if (i > zip_outcnt - zip_outoff) i = zip_outcnt - zip_outoff; // System.arraycopy(outbuf, outoff, buff, off + n, i);
  83822. for (j = 0; j < i; j++) {
  83823. buff[off + n + j] = zip_outbuf[zip_outoff + j];
  83824. }
  83825. zip_outoff += i;
  83826. n += i;
  83827. if (zip_outcnt == zip_outoff) zip_outcnt = zip_outoff = 0;
  83828. }
  83829. return n;
  83830. }
  83831. /* ==========================================================================
  83832. * Allocate the match buffer, initialize the various tables and save the
  83833. * location of the internal file attribute (ascii/binary) and method
  83834. * (DEFLATE/STORE).
  83835. */
  83836. function zip_ct_init() {
  83837. var n; // iterates over tree elements
  83838. var bits; // bit counter
  83839. var length; // length value
  83840. var code; // code value
  83841. var dist; // distance index
  83842. if (zip_static_dtree[0].dl != 0) return; // ct_init already called
  83843. zip_l_desc.dyn_tree = zip_dyn_ltree;
  83844. zip_l_desc.static_tree = zip_static_ltree;
  83845. zip_l_desc.extra_bits = zip_extra_lbits;
  83846. zip_l_desc.extra_base = zip_LITERALS + 1;
  83847. zip_l_desc.elems = zip_L_CODES;
  83848. zip_l_desc.max_length = zip_MAX_BITS;
  83849. zip_l_desc.max_code = 0;
  83850. zip_d_desc.dyn_tree = zip_dyn_dtree;
  83851. zip_d_desc.static_tree = zip_static_dtree;
  83852. zip_d_desc.extra_bits = zip_extra_dbits;
  83853. zip_d_desc.extra_base = 0;
  83854. zip_d_desc.elems = zip_D_CODES;
  83855. zip_d_desc.max_length = zip_MAX_BITS;
  83856. zip_d_desc.max_code = 0;
  83857. zip_bl_desc.dyn_tree = zip_bl_tree;
  83858. zip_bl_desc.static_tree = null;
  83859. zip_bl_desc.extra_bits = zip_extra_blbits;
  83860. zip_bl_desc.extra_base = 0;
  83861. zip_bl_desc.elems = zip_BL_CODES;
  83862. zip_bl_desc.max_length = zip_MAX_BL_BITS;
  83863. zip_bl_desc.max_code = 0; // Initialize the mapping length (0..255) -> length code (0..28)
  83864. length = 0;
  83865. for (code = 0; code < zip_LENGTH_CODES - 1; code++) {
  83866. zip_base_length[code] = length;
  83867. for (n = 0; n < 1 << zip_extra_lbits[code]; n++) {
  83868. zip_length_code[length++] = code;
  83869. }
  83870. } // Assert (length == 256, "ct_init: length != 256");
  83871. /* Note that the length 255 (match length 258) can be represented
  83872. * in two different ways: code 284 + 5 bits or code 285, so we
  83873. * overwrite length_code[255] to use the best encoding:
  83874. */
  83875. zip_length_code[length - 1] = code;
  83876. /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
  83877. dist = 0;
  83878. for (code = 0; code < 16; code++) {
  83879. zip_base_dist[code] = dist;
  83880. for (n = 0; n < 1 << zip_extra_dbits[code]; n++) {
  83881. zip_dist_code[dist++] = code;
  83882. }
  83883. } // Assert (dist == 256, "ct_init: dist != 256");
  83884. dist >>= 7; // from now on, all distances are divided by 128
  83885. for (; code < zip_D_CODES; code++) {
  83886. zip_base_dist[code] = dist << 7;
  83887. for (n = 0; n < 1 << zip_extra_dbits[code] - 7; n++) {
  83888. zip_dist_code[256 + dist++] = code;
  83889. }
  83890. } // Assert (dist == 256, "ct_init: 256+dist != 512");
  83891. // Construct the codes of the static literal tree
  83892. for (bits = 0; bits <= zip_MAX_BITS; bits++) {
  83893. zip_bl_count[bits] = 0;
  83894. }
  83895. n = 0;
  83896. while (n <= 143) {
  83897. zip_static_ltree[n++].dl = 8;
  83898. zip_bl_count[8]++;
  83899. }
  83900. while (n <= 255) {
  83901. zip_static_ltree[n++].dl = 9;
  83902. zip_bl_count[9]++;
  83903. }
  83904. while (n <= 279) {
  83905. zip_static_ltree[n++].dl = 7;
  83906. zip_bl_count[7]++;
  83907. }
  83908. while (n <= 287) {
  83909. zip_static_ltree[n++].dl = 8;
  83910. zip_bl_count[8]++;
  83911. }
  83912. /* Codes 286 and 287 do not exist, but we must include them in the
  83913. * tree construction to get a canonical Huffman tree (longest code
  83914. * all ones)
  83915. */
  83916. zip_gen_codes(zip_static_ltree, zip_L_CODES + 1);
  83917. /* The static distance tree is trivial: */
  83918. for (n = 0; n < zip_D_CODES; n++) {
  83919. zip_static_dtree[n].dl = 5;
  83920. zip_static_dtree[n].fc = zip_bi_reverse(n, 5);
  83921. } // Initialize the first block of the first file:
  83922. zip_init_block();
  83923. }
  83924. /* ==========================================================================
  83925. * Initialize a new block.
  83926. */
  83927. function zip_init_block() {
  83928. var n; // iterates over tree elements
  83929. // Initialize the trees.
  83930. for (n = 0; n < zip_L_CODES; n++) {
  83931. zip_dyn_ltree[n].fc = 0;
  83932. }
  83933. for (n = 0; n < zip_D_CODES; n++) {
  83934. zip_dyn_dtree[n].fc = 0;
  83935. }
  83936. for (n = 0; n < zip_BL_CODES; n++) {
  83937. zip_bl_tree[n].fc = 0;
  83938. }
  83939. zip_dyn_ltree[zip_END_BLOCK].fc = 1;
  83940. zip_opt_len = zip_static_len = 0;
  83941. zip_last_lit = zip_last_dist = zip_last_flags = 0;
  83942. zip_flags = 0;
  83943. zip_flag_bit = 1;
  83944. }
  83945. /* ==========================================================================
  83946. * Restore the heap property by moving down the tree starting at node k,
  83947. * exchanging a node with the smallest of its two sons if necessary, stopping
  83948. * when the heap property is re-established (each father smaller than its
  83949. * two sons).
  83950. */
  83951. function zip_pqdownheap(tree, // the tree to restore
  83952. k) {
  83953. // node to move down
  83954. var v = zip_heap[k];
  83955. var j = k << 1; // left son of k
  83956. while (j <= zip_heap_len) {
  83957. // Set j to the smallest of the two sons:
  83958. if (j < zip_heap_len && zip_SMALLER(tree, zip_heap[j + 1], zip_heap[j])) j++; // Exit if v is smaller than both sons
  83959. if (zip_SMALLER(tree, v, zip_heap[j])) break; // Exchange v with the smallest son
  83960. zip_heap[k] = zip_heap[j];
  83961. k = j; // And continue down the tree, setting j to the left son of k
  83962. j <<= 1;
  83963. }
  83964. zip_heap[k] = v;
  83965. }
  83966. /* ==========================================================================
  83967. * Compute the optimal bit lengths for a tree and update the total bit length
  83968. * for the current block.
  83969. * IN assertion: the fields freq and dad are set, heap[heap_max] and
  83970. * above are the tree nodes sorted by increasing frequency.
  83971. * OUT assertions: the field len is set to the optimal bit length, the
  83972. * array bl_count contains the frequencies for each bit length.
  83973. * The length opt_len is updated; static_len is also updated if stree is
  83974. * not null.
  83975. */
  83976. function zip_gen_bitlen(desc) {
  83977. // the tree descriptor
  83978. var tree = desc.dyn_tree;
  83979. var extra = desc.extra_bits;
  83980. var base = desc.extra_base;
  83981. var max_code = desc.max_code;
  83982. var max_length = desc.max_length;
  83983. var stree = desc.static_tree;
  83984. var h; // heap index
  83985. var n;
  83986. var m; // iterate over the tree elements
  83987. var bits; // bit length
  83988. var xbits; // extra bits
  83989. var f; // frequency
  83990. var overflow = 0; // number of elements with bit length too large
  83991. for (bits = 0; bits <= zip_MAX_BITS; bits++) {
  83992. zip_bl_count[bits] = 0;
  83993. }
  83994. /* In a first pass, compute the optimal bit lengths (which may
  83995. * overflow in the case of the bit length tree).
  83996. */
  83997. tree[zip_heap[zip_heap_max]].dl = 0; // root of the heap
  83998. for (h = zip_heap_max + 1; h < zip_HEAP_SIZE; h++) {
  83999. n = zip_heap[h];
  84000. bits = tree[tree[n].dl].dl + 1;
  84001. if (bits > max_length) {
  84002. bits = max_length;
  84003. overflow++;
  84004. }
  84005. tree[n].dl = bits; // We overwrite tree[n].dl which is no longer needed
  84006. if (n > max_code) continue; // not a leaf node
  84007. zip_bl_count[bits]++;
  84008. xbits = 0;
  84009. if (n >= base) xbits = extra[n - base];
  84010. f = tree[n].fc;
  84011. zip_opt_len += f * (bits + xbits);
  84012. if (stree != null) zip_static_len += f * (stree[n].dl + xbits);
  84013. }
  84014. if (overflow == 0) return; // This happens for example on obj2 and pic of the Calgary corpus
  84015. // Find the first bit length which could increase:
  84016. do {
  84017. bits = max_length - 1;
  84018. while (zip_bl_count[bits] == 0) {
  84019. bits--;
  84020. }
  84021. zip_bl_count[bits]--; // move one leaf down the tree
  84022. zip_bl_count[bits + 1] += 2; // move one overflow item as its brother
  84023. zip_bl_count[max_length]--;
  84024. /* The brother of the overflow item also moves one step up,
  84025. * but this does not affect bl_count[max_length]
  84026. */
  84027. overflow -= 2;
  84028. } while (overflow > 0);
  84029. /* Now recompute all bit lengths, scanning in increasing frequency.
  84030. * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
  84031. * lengths instead of fixing only the wrong ones. This idea is taken
  84032. * from 'ar' written by Haruhiko Okumura.)
  84033. */
  84034. for (bits = max_length; bits != 0; bits--) {
  84035. n = zip_bl_count[bits];
  84036. while (n != 0) {
  84037. m = zip_heap[--h];
  84038. if (m > max_code) continue;
  84039. if (tree[m].dl != bits) {
  84040. zip_opt_len += (bits - tree[m].dl) * tree[m].fc;
  84041. tree[m].fc = bits;
  84042. }
  84043. n--;
  84044. }
  84045. }
  84046. }
  84047. /* ==========================================================================
  84048. * Generate the codes for a given tree and bit counts (which need not be
  84049. * optimal).
  84050. * IN assertion: the array bl_count contains the bit length statistics for
  84051. * the given tree and the field len is set for all tree elements.
  84052. * OUT assertion: the field code is set for all tree elements of non
  84053. * zero code length.
  84054. */
  84055. function zip_gen_codes(tree, // the tree to decorate
  84056. max_code) {
  84057. // largest code with non zero frequency
  84058. var next_code = new Array(zip_MAX_BITS + 1); // next code value for each bit length
  84059. var code = 0; // running code value
  84060. var bits; // bit index
  84061. var n; // code index
  84062. /* The distribution counts are first used to generate the code values
  84063. * without bit reversal.
  84064. */
  84065. for (bits = 1; bits <= zip_MAX_BITS; bits++) {
  84066. code = code + zip_bl_count[bits - 1] << 1;
  84067. next_code[bits] = code;
  84068. }
  84069. /* Check that the bit counts in bl_count are consistent. The last code
  84070. * must be all ones.
  84071. */
  84072. // Assert (code + encoder->bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
  84073. // "inconsistent bit counts");
  84074. // Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
  84075. for (n = 0; n <= max_code; n++) {
  84076. var len = tree[n].dl;
  84077. if (len == 0) continue; // Now reverse the bits
  84078. tree[n].fc = zip_bi_reverse(next_code[len]++, len); // Tracec(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
  84079. // n, (isgraph(n) ? n : ' '), len, tree[n].fc, next_code[len]-1));
  84080. }
  84081. }
  84082. /* ==========================================================================
  84083. * Construct one Huffman tree and assigns the code bit strings and lengths.
  84084. * Update the total bit length for the current block.
  84085. * IN assertion: the field freq is set for all tree elements.
  84086. * OUT assertions: the fields len and code are set to the optimal bit length
  84087. * and corresponding code. The length opt_len is updated; static_len is
  84088. * also updated if stree is not null. The field max_code is set.
  84089. */
  84090. function zip_build_tree(desc) {
  84091. // the tree descriptor
  84092. var tree = desc.dyn_tree;
  84093. var stree = desc.static_tree;
  84094. var elems = desc.elems;
  84095. var n;
  84096. var m; // iterate over heap elements
  84097. var max_code = -1; // largest code with non zero frequency
  84098. var node = elems; // next internal node of the tree
  84099. /* Construct the initial heap, with least frequent element in
  84100. * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
  84101. * heap[0] is not used.
  84102. */
  84103. zip_heap_len = 0;
  84104. zip_heap_max = zip_HEAP_SIZE;
  84105. for (n = 0; n < elems; n++) {
  84106. if (tree[n].fc != 0) {
  84107. zip_heap[++zip_heap_len] = max_code = n;
  84108. zip_depth[n] = 0;
  84109. } else tree[n].dl = 0;
  84110. }
  84111. /* The pkzip format requires that at least one distance code exists,
  84112. * and that at least one bit should be sent even if there is only one
  84113. * possible code. So to avoid special checks later on we force at least
  84114. * two codes of non zero frequency.
  84115. */
  84116. while (zip_heap_len < 2) {
  84117. var xnew = zip_heap[++zip_heap_len] = max_code < 2 ? ++max_code : 0;
  84118. tree[xnew].fc = 1;
  84119. zip_depth[xnew] = 0;
  84120. zip_opt_len--;
  84121. if (stree != null) zip_static_len -= stree[xnew].dl; // new is 0 or 1 so it does not have extra bits
  84122. }
  84123. desc.max_code = max_code;
  84124. /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
  84125. * establish sub-heaps of increasing lengths:
  84126. */
  84127. for (n = zip_heap_len >> 1; n >= 1; n--) {
  84128. zip_pqdownheap(tree, n);
  84129. }
  84130. /* Construct the Huffman tree by repeatedly combining the least two
  84131. * frequent nodes.
  84132. */
  84133. do {
  84134. n = zip_heap[zip_SMALLEST];
  84135. zip_heap[zip_SMALLEST] = zip_heap[zip_heap_len--];
  84136. zip_pqdownheap(tree, zip_SMALLEST);
  84137. m = zip_heap[zip_SMALLEST]; // m = node of next least frequency
  84138. // keep the nodes sorted by frequency
  84139. zip_heap[--zip_heap_max] = n;
  84140. zip_heap[--zip_heap_max] = m; // Create a new node father of n and m
  84141. tree[node].fc = tree[n].fc + tree[m].fc; // depth[node] = (char)(MAX(depth[n], depth[m]) + 1);
  84142. if (zip_depth[n] > zip_depth[m] + 1) zip_depth[node] = zip_depth[n];else zip_depth[node] = zip_depth[m] + 1;
  84143. tree[n].dl = tree[m].dl = node; // and insert the new node in the heap
  84144. zip_heap[zip_SMALLEST] = node++;
  84145. zip_pqdownheap(tree, zip_SMALLEST);
  84146. } while (zip_heap_len >= 2);
  84147. zip_heap[--zip_heap_max] = zip_heap[zip_SMALLEST];
  84148. /* At this point, the fields freq and dad are set. We can now
  84149. * generate the bit lengths.
  84150. */
  84151. zip_gen_bitlen(desc); // The field len is now set, we can generate the bit codes
  84152. zip_gen_codes(tree, max_code);
  84153. }
  84154. /* ==========================================================================
  84155. * Scan a literal or distance tree to determine the frequencies of the codes
  84156. * in the bit length tree. Updates opt_len to take into account the repeat
  84157. * counts. (The contribution of the bit length codes will be added later
  84158. * during the construction of bl_tree.)
  84159. */
  84160. function zip_scan_tree(tree, // the tree to be scanned
  84161. max_code) {
  84162. // and its largest code of non zero frequency
  84163. var n; // iterates over all tree elements
  84164. var prevlen = -1; // last emitted length
  84165. var curlen; // length of current code
  84166. var nextlen = tree[0].dl; // length of next code
  84167. var count = 0; // repeat count of the current code
  84168. var max_count = 7; // max repeat count
  84169. var min_count = 4; // min repeat count
  84170. if (nextlen == 0) {
  84171. max_count = 138;
  84172. min_count = 3;
  84173. }
  84174. tree[max_code + 1].dl = 0xffff; // guard
  84175. for (n = 0; n <= max_code; n++) {
  84176. curlen = nextlen;
  84177. nextlen = tree[n + 1].dl;
  84178. if (++count < max_count && curlen == nextlen) continue;else if (count < min_count) zip_bl_tree[curlen].fc += count;else if (curlen != 0) {
  84179. if (curlen != prevlen) zip_bl_tree[curlen].fc++;
  84180. zip_bl_tree[zip_REP_3_6].fc++;
  84181. } else if (count <= 10) zip_bl_tree[zip_REPZ_3_10].fc++;else zip_bl_tree[zip_REPZ_11_138].fc++;
  84182. count = 0;
  84183. prevlen = curlen;
  84184. if (nextlen == 0) {
  84185. max_count = 138;
  84186. min_count = 3;
  84187. } else if (curlen == nextlen) {
  84188. max_count = 6;
  84189. min_count = 3;
  84190. } else {
  84191. max_count = 7;
  84192. min_count = 4;
  84193. }
  84194. }
  84195. }
  84196. /* ==========================================================================
  84197. * Send a literal or distance tree in compressed form, using the codes in
  84198. * bl_tree.
  84199. */
  84200. function zip_send_tree(tree, // the tree to be scanned
  84201. max_code) {
  84202. // and its largest code of non zero frequency
  84203. var n; // iterates over all tree elements
  84204. var prevlen = -1; // last emitted length
  84205. var curlen; // length of current code
  84206. var nextlen = tree[0].dl; // length of next code
  84207. var count = 0; // repeat count of the current code
  84208. var max_count = 7; // max repeat count
  84209. var min_count = 4;
  84210. /* guard already set */
  84211. // min repeat count
  84212. /* tree[max_code+1].dl = -1; */
  84213. if (nextlen == 0) {
  84214. max_count = 138;
  84215. min_count = 3;
  84216. }
  84217. for (n = 0; n <= max_code; n++) {
  84218. curlen = nextlen;
  84219. nextlen = tree[n + 1].dl;
  84220. if (++count < max_count && curlen == nextlen) {
  84221. continue;
  84222. } else if (count < min_count) {
  84223. do {
  84224. zip_SEND_CODE(curlen, zip_bl_tree);
  84225. } while (--count != 0);
  84226. } else if (curlen != 0) {
  84227. if (curlen != prevlen) {
  84228. zip_SEND_CODE(curlen, zip_bl_tree);
  84229. count--;
  84230. } // Assert(count >= 3 && count <= 6, " 3_6?");
  84231. zip_SEND_CODE(zip_REP_3_6, zip_bl_tree);
  84232. zip_send_bits(count - 3, 2);
  84233. } else if (count <= 10) {
  84234. zip_SEND_CODE(zip_REPZ_3_10, zip_bl_tree);
  84235. zip_send_bits(count - 3, 3);
  84236. } else {
  84237. zip_SEND_CODE(zip_REPZ_11_138, zip_bl_tree);
  84238. zip_send_bits(count - 11, 7);
  84239. }
  84240. count = 0;
  84241. prevlen = curlen;
  84242. if (nextlen == 0) {
  84243. max_count = 138;
  84244. min_count = 3;
  84245. } else if (curlen == nextlen) {
  84246. max_count = 6;
  84247. min_count = 3;
  84248. } else {
  84249. max_count = 7;
  84250. min_count = 4;
  84251. }
  84252. }
  84253. }
  84254. /* ==========================================================================
  84255. * Construct the Huffman tree for the bit lengths and return the index in
  84256. * bl_order of the last bit length code to send.
  84257. */
  84258. function zip_build_bl_tree() {
  84259. var max_blindex; // index of last bit length code of non zero freq
  84260. // Determine the bit length frequencies for literal and distance trees
  84261. zip_scan_tree(zip_dyn_ltree, zip_l_desc.max_code);
  84262. zip_scan_tree(zip_dyn_dtree, zip_d_desc.max_code); // Build the bit length tree:
  84263. zip_build_tree(zip_bl_desc);
  84264. /* opt_len now includes the length of the tree representations, except
  84265. * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
  84266. */
  84267. /* Determine the number of bit length codes to send. The pkzip format
  84268. * requires that at least 4 bit length codes be sent. (appnote.txt says
  84269. * 3 but the actual value used is 4.)
  84270. */
  84271. for (max_blindex = zip_BL_CODES - 1; max_blindex >= 3; max_blindex--) {
  84272. if (zip_bl_tree[zip_bl_order[max_blindex]].dl != 0) break;
  84273. }
  84274. /* Update opt_len to include the bit length tree and counts */
  84275. zip_opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; // Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
  84276. // encoder->opt_len, encoder->static_len));
  84277. return max_blindex;
  84278. }
  84279. /* ==========================================================================
  84280. * Send the header for a block using dynamic Huffman trees: the counts, the
  84281. * lengths of the bit length codes, the literal tree and the distance tree.
  84282. * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
  84283. */
  84284. function zip_send_all_trees(lcodes, dcodes, blcodes) {
  84285. // number of codes for each tree
  84286. var rank; // index in bl_order
  84287. // Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
  84288. // Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
  84289. // "too many codes");
  84290. // Tracev((stderr, "\nbl counts: "));
  84291. zip_send_bits(lcodes - 257, 5); // not +255 as stated in appnote.txt
  84292. zip_send_bits(dcodes - 1, 5);
  84293. zip_send_bits(blcodes - 4, 4); // not -3 as stated in appnote.txt
  84294. for (rank = 0; rank < blcodes; rank++) {
  84295. // Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
  84296. zip_send_bits(zip_bl_tree[zip_bl_order[rank]].dl, 3);
  84297. } // send the literal tree
  84298. zip_send_tree(zip_dyn_ltree, lcodes - 1); // send the distance tree
  84299. zip_send_tree(zip_dyn_dtree, dcodes - 1);
  84300. }
  84301. /* ==========================================================================
  84302. * Determine the best encoding for the current block: dynamic trees, static
  84303. * trees or store, and output the encoded block to the zip file.
  84304. */
  84305. function zip_flush_block(eof) {
  84306. // true if this is the last block for a file
  84307. var opt_lenb;
  84308. var static_lenb; // opt_len and static_len in bytes
  84309. var max_blindex; // index of last bit length code of non zero freq
  84310. var stored_len; // length of input block
  84311. stored_len = zip_strstart - zip_block_start;
  84312. zip_flag_buf[zip_last_flags] = zip_flags; // Save the flags for the last 8 items
  84313. // Construct the literal and distance trees
  84314. zip_build_tree(zip_l_desc); // Tracev((stderr, "\nlit data: dyn %ld, stat %ld",
  84315. // encoder->opt_len, encoder->static_len));
  84316. zip_build_tree(zip_d_desc); // Tracev((stderr, "\ndist data: dyn %ld, stat %ld",
  84317. // encoder->opt_len, encoder->static_len));
  84318. /* At this point, opt_len and static_len are the total bit lengths of
  84319. * the compressed block data, excluding the tree representations.
  84320. */
  84321. /* Build the bit length tree for the above two trees, and get the index
  84322. * in bl_order of the last bit length code to send.
  84323. */
  84324. max_blindex = zip_build_bl_tree(); // Determine the best encoding. Compute first the block length in bytes
  84325. opt_lenb = zip_opt_len + 3 + 7 >> 3;
  84326. static_lenb = zip_static_len + 3 + 7 >> 3; // Trace((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ",
  84327. // opt_lenb, encoder->opt_len,
  84328. // static_lenb, encoder->static_len, stored_len,
  84329. // encoder->last_lit, encoder->last_dist));
  84330. if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
  84331. if (stored_len + 4 <= opt_lenb && // 4: two words for the lengths
  84332. zip_block_start >= 0) {
  84333. var i;
  84334. /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
  84335. * Otherwise we can't have processed more than WSIZE input bytes since
  84336. * the last block flush, because compression would have been
  84337. * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
  84338. * transform a block into a stored block.
  84339. */
  84340. zip_send_bits((zip_STORED_BLOCK << 1) + eof, 3);
  84341. /* send block type */
  84342. zip_bi_windup();
  84343. /* align on byte boundary */
  84344. zip_put_short(stored_len);
  84345. zip_put_short(~stored_len); // copy block
  84346. /*
  84347. p = &window[block_start];
  84348. for(i = 0; i < stored_len; i++)
  84349. put_byte(p[i]);
  84350. */
  84351. for (i = 0; i < stored_len; i++) {
  84352. zip_put_byte(zip_window[zip_block_start + i]);
  84353. }
  84354. } else if (static_lenb == opt_lenb) {
  84355. zip_send_bits((zip_STATIC_TREES << 1) + eof, 3);
  84356. zip_compress_block(zip_static_ltree, zip_static_dtree);
  84357. } else {
  84358. zip_send_bits((zip_DYN_TREES << 1) + eof, 3);
  84359. zip_send_all_trees(zip_l_desc.max_code + 1, zip_d_desc.max_code + 1, max_blindex + 1);
  84360. zip_compress_block(zip_dyn_ltree, zip_dyn_dtree);
  84361. }
  84362. zip_init_block();
  84363. if (eof != 0) zip_bi_windup();
  84364. }
  84365. /* ==========================================================================
  84366. * Save the match info and tally the frequency counts. Return true if
  84367. * the current block must be flushed.
  84368. */
  84369. function zip_ct_tally(dist, // distance of matched string
  84370. lc) {
  84371. // match length-MIN_MATCH or unmatched char (if dist==0)
  84372. zip_l_buf[zip_last_lit++] = lc;
  84373. if (dist == 0) {
  84374. // lc is the unmatched char
  84375. zip_dyn_ltree[lc].fc++;
  84376. } else {
  84377. // Here, lc is the match length - MIN_MATCH
  84378. dist--; // dist = match distance - 1
  84379. // Assert((ush)dist < (ush)MAX_DIST &&
  84380. // (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
  84381. // (ush)D_CODE(dist) < (ush)D_CODES, "ct_tally: bad match");
  84382. zip_dyn_ltree[zip_length_code[lc] + zip_LITERALS + 1].fc++;
  84383. zip_dyn_dtree[zip_D_CODE(dist)].fc++;
  84384. zip_d_buf[zip_last_dist++] = dist;
  84385. zip_flags |= zip_flag_bit;
  84386. }
  84387. zip_flag_bit <<= 1; // Output the flags if they fill a byte
  84388. if ((zip_last_lit & 7) == 0) {
  84389. zip_flag_buf[zip_last_flags++] = zip_flags;
  84390. zip_flags = 0;
  84391. zip_flag_bit = 1;
  84392. } // Try to guess if it is profitable to stop the current block here
  84393. if (zip_compr_level > 2 && (zip_last_lit & 0xfff) == 0) {
  84394. // Compute an upper bound for the compressed length
  84395. var out_length = zip_last_lit * 8;
  84396. var in_length = zip_strstart - zip_block_start;
  84397. var dcode;
  84398. for (dcode = 0; dcode < zip_D_CODES; dcode++) {
  84399. out_length += zip_dyn_dtree[dcode].fc * (5 + zip_extra_dbits[dcode]);
  84400. }
  84401. out_length >>= 3; // Trace((stderr,"\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ",
  84402. // encoder->last_lit, encoder->last_dist, in_length, out_length,
  84403. // 100L - out_length*100L/in_length));
  84404. if (zip_last_dist < _parseInt$2(zip_last_lit / 2) && out_length < _parseInt$2(in_length / 2)) return true;
  84405. }
  84406. return zip_last_lit == zip_LIT_BUFSIZE - 1 || zip_last_dist == zip_DIST_BUFSIZE;
  84407. /* We avoid equality with LIT_BUFSIZE because of wraparound at 64K
  84408. * on 16 bit machines and because stored blocks are restricted to
  84409. * 64K-1 bytes.
  84410. */
  84411. }
  84412. /* ==========================================================================
  84413. * Send the block data compressed using the given Huffman trees
  84414. */
  84415. function zip_compress_block(ltree, // literal tree
  84416. dtree) {
  84417. // distance tree
  84418. var dist; // distance of matched string
  84419. var lc; // match length or unmatched char (if dist == 0)
  84420. var lx = 0; // running index in l_buf
  84421. var dx = 0; // running index in d_buf
  84422. var fx = 0; // running index in flag_buf
  84423. var flag = 0; // current flags
  84424. var code; // the code to send
  84425. var extra; // number of extra bits to send
  84426. if (zip_last_lit != 0) do {
  84427. if ((lx & 7) == 0) flag = zip_flag_buf[fx++];
  84428. lc = zip_l_buf[lx++] & 0xff;
  84429. if ((flag & 1) == 0) {
  84430. zip_SEND_CODE(lc, ltree);
  84431. /* send a literal byte */
  84432. // Tracecv(isgraph(lc), (stderr," '%c' ", lc));
  84433. } else {
  84434. // Here, lc is the match length - MIN_MATCH
  84435. code = zip_length_code[lc];
  84436. zip_SEND_CODE(code + zip_LITERALS + 1, ltree); // send the length code
  84437. extra = zip_extra_lbits[code];
  84438. if (extra != 0) {
  84439. lc -= zip_base_length[code];
  84440. zip_send_bits(lc, extra); // send the extra length bits
  84441. }
  84442. dist = zip_d_buf[dx++]; // Here, dist is the match distance - 1
  84443. code = zip_D_CODE(dist); // Assert (code < D_CODES, "bad d_code");
  84444. zip_SEND_CODE(code, dtree); // send the distance code
  84445. extra = zip_extra_dbits[code];
  84446. if (extra != 0) {
  84447. dist -= zip_base_dist[code];
  84448. zip_send_bits(dist, extra); // send the extra distance bits
  84449. }
  84450. } // literal or match pair ?
  84451. flag >>= 1;
  84452. } while (lx < zip_last_lit);
  84453. zip_SEND_CODE(zip_END_BLOCK, ltree);
  84454. }
  84455. /* ==========================================================================
  84456. * Send a value on a given number of bits.
  84457. * IN assertion: length <= 16 and value fits in length bits.
  84458. */
  84459. var zip_Buf_size = 16; // bit size of bi_buf
  84460. function zip_send_bits(value, // value to send
  84461. length) {
  84462. // number of bits
  84463. /* If not enough room in bi_buf, use (valid) bits from bi_buf and
  84464. * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
  84465. * unused bits in value.
  84466. */
  84467. if (zip_bi_valid > zip_Buf_size - length) {
  84468. zip_bi_buf |= value << zip_bi_valid;
  84469. zip_put_short(zip_bi_buf);
  84470. zip_bi_buf = value >> zip_Buf_size - zip_bi_valid;
  84471. zip_bi_valid += length - zip_Buf_size;
  84472. } else {
  84473. zip_bi_buf |= value << zip_bi_valid;
  84474. zip_bi_valid += length;
  84475. }
  84476. }
  84477. /* ==========================================================================
  84478. * Reverse the first len bits of a code, using straightforward code (a faster
  84479. * method would use a table)
  84480. * IN assertion: 1 <= len <= 15
  84481. */
  84482. function zip_bi_reverse(code, // the value to invert
  84483. len) {
  84484. // its bit length
  84485. var res = 0;
  84486. do {
  84487. res |= code & 1;
  84488. code >>= 1;
  84489. res <<= 1;
  84490. } while (--len > 0);
  84491. return res >> 1;
  84492. }
  84493. /* ==========================================================================
  84494. * Write out any remaining bits in an incomplete byte.
  84495. */
  84496. function zip_bi_windup() {
  84497. if (zip_bi_valid > 8) {
  84498. zip_put_short(zip_bi_buf);
  84499. } else if (zip_bi_valid > 0) {
  84500. zip_put_byte(zip_bi_buf);
  84501. }
  84502. zip_bi_buf = 0;
  84503. zip_bi_valid = 0;
  84504. }
  84505. function zip_qoutbuf() {
  84506. if (zip_outcnt != 0) {
  84507. var q;
  84508. var i;
  84509. q = zip_new_queue();
  84510. if (zip_qhead == null) zip_qhead = zip_qtail = q;else zip_qtail = zip_qtail.next = q;
  84511. q.len = zip_outcnt - zip_outoff; // System.arraycopy(zip_outbuf, zip_outoff, q.ptr, 0, q.len);
  84512. for (i = 0; i < q.len; i++) {
  84513. q.ptr[i] = zip_outbuf[zip_outoff + i];
  84514. }
  84515. zip_outcnt = zip_outoff = 0;
  84516. }
  84517. }
  84518. return function deflate(str, level) {
  84519. var i;
  84520. var j;
  84521. zip_deflate_data = str;
  84522. zip_deflate_pos = 0;
  84523. if (typeof level === 'undefined') level = zip_DEFAULT_LEVEL;
  84524. zip_deflate_start(level);
  84525. var buff = new Array(1024);
  84526. var aout = [];
  84527. while ((i = zip_deflate_internal(buff, 0, buff.length)) > 0) {
  84528. var cbuf = new Array(i);
  84529. for (j = 0; j < i; j++) {
  84530. cbuf[j] = String.fromCharCode(buff[j]);
  84531. }
  84532. aout[aout.length] = cbuf.join('');
  84533. }
  84534. zip_deflate_data = null; // G.C.
  84535. return aout.join('');
  84536. };
  84537. }();
  84538. function ownKeys$b(object, enumerableOnly) { var keys = keys$3(object); if (getOwnPropertySymbols$2) { var symbols = getOwnPropertySymbols$2(object); enumerableOnly && (symbols = filter$3(symbols).call(symbols, function (sym) { return getOwnPropertyDescriptor$3(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  84539. function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var _context4, _context5; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? forEach$3(_context4 = ownKeys$b(Object(source), !0)).call(_context4, function (key) { _defineProperty(target, key, source[key]); }) : getOwnPropertyDescriptors$2 ? defineProperties$2(target, getOwnPropertyDescriptors$2(source)) : forEach$3(_context5 = ownKeys$b(Object(source))).call(_context5, function (key) { defineProperty$5(target, key, getOwnPropertyDescriptor$3(source, key)); }); } return target; }
  84540. function encode64(data) {
  84541. var r = '';
  84542. for (var i = 0; i < data.length; i += 3) {
  84543. if (i + 2 === data.length) {
  84544. r += append3bytes(data.charCodeAt(i), data.charCodeAt(i + 1), 0);
  84545. } else if (i + 1 === data.length) {
  84546. r += append3bytes(data.charCodeAt(i), 0, 0);
  84547. } else {
  84548. r += append3bytes(data.charCodeAt(i), data.charCodeAt(i + 1), data.charCodeAt(i + 2));
  84549. }
  84550. }
  84551. return r;
  84552. }
  84553. function append3bytes(b1, b2, b3) {
  84554. var c1 = b1 >> 2;
  84555. var c2 = (b1 & 0x3) << 4 | b2 >> 4;
  84556. var c3 = (b2 & 0xf) << 2 | b3 >> 6;
  84557. var c4 = b3 & 0x3f;
  84558. var r = '';
  84559. r += encode6bit(c1 & 0x3f);
  84560. r += encode6bit(c2 & 0x3f);
  84561. r += encode6bit(c3 & 0x3f);
  84562. r += encode6bit(c4 & 0x3f);
  84563. return r;
  84564. }
  84565. function encode6bit(b1) {
  84566. var b = b1;
  84567. if (b < 10) {
  84568. return String.fromCharCode(48 + b);
  84569. }
  84570. b -= 10;
  84571. if (b < 26) {
  84572. return String.fromCharCode(65 + b);
  84573. }
  84574. b -= 26;
  84575. if (b < 26) {
  84576. return String.fromCharCode(97 + b);
  84577. }
  84578. b -= 26;
  84579. if (b === 0) {
  84580. return '-';
  84581. }
  84582. if (b === 1) {
  84583. return '_';
  84584. }
  84585. return '?';
  84586. }
  84587. function compress(s1, url) {
  84588. var _context;
  84589. var s = unescape(encodeURIComponent(s1));
  84590. return concat$5(_context = "".concat(url, "/svg/")).call(_context, encode64(deflate(s, 9)));
  84591. }
  84592. var PlantUMLCodeEngine = /*#__PURE__*/function () {
  84593. function PlantUMLCodeEngine() {
  84594. var _plantUMLOptions$base;
  84595. var plantUMLOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  84596. _classCallCheck(this, PlantUMLCodeEngine);
  84597. var defaultUrl = 'http://www.plantuml.com/plantuml';
  84598. this.baseUrl = (_plantUMLOptions$base = plantUMLOptions.baseUrl) !== null && _plantUMLOptions$base !== void 0 ? _plantUMLOptions$base : defaultUrl;
  84599. }
  84600. _createClass(PlantUMLCodeEngine, [{
  84601. key: "render",
  84602. value: function render(src, sign) {
  84603. var _context2, _context3;
  84604. var $sign = sign;
  84605. if (!$sign) {
  84606. $sign = Math.round(Math.random() * 100000000);
  84607. }
  84608. var graphId = concat$5(_context2 = "plantuml-".concat($sign, "-")).call(_context2, new Date().getTime());
  84609. return concat$5(_context3 = "<img id=\"".concat(graphId, "\" src=\"")).call(_context3, compress(src, this.baseUrl), "\" />");
  84610. }
  84611. }], [{
  84612. key: "install",
  84613. value: function install(cherryOptions, args) {
  84614. var _cherryOptions$engine;
  84615. mergeWith_1(cherryOptions, {
  84616. engine: {
  84617. syntax: {
  84618. codeBlock: {
  84619. customRenderer: {
  84620. plantuml: new PlantUMLCodeEngine(_objectSpread$a(_objectSpread$a({}, args), (_cherryOptions$engine = cherryOptions.engine.syntax.plantuml) !== null && _cherryOptions$engine !== void 0 ? _cherryOptions$engine : {}))
  84621. }
  84622. }
  84623. }
  84624. }
  84625. });
  84626. }
  84627. }]);
  84628. return PlantUMLCodeEngine;
  84629. }();
  84630. /*! For license information please see mermaid.esm.min.mjs.LICENSE.txt */
  84631. var t={2536:(t,e,n)=>{t=n.nmd(t);var r=function(){var t=function(t,e,n,r){for(n=n||{},r=t.length;r--;n[t[r]]=e);return n},e=[1,6],n=[1,7],r=[1,8],i=[1,9],a=[1,16],o=[1,11],s=[1,12],l=[1,13],u=[1,14],h=[1,15],f=[1,27],d=[1,33],p=[1,34],g=[1,35],y=[1,36],m=[1,37],b=[1,72],v=[1,73],_=[1,74],x=[1,75],k=[1,76],w=[1,77],T=[1,78],E=[1,38],C=[1,39],S=[1,40],A=[1,41],M=[1,42],N=[1,43],O=[1,44],D=[1,45],B=[1,46],L=[1,47],I=[1,48],F=[1,49],R=[1,50],P=[1,51],j=[1,52],z=[1,53],Y=[1,54],U=[1,55],$=[1,56],W=[1,57],q=[1,59],H=[1,60],V=[1,61],G=[1,62],X=[1,63],Z=[1,64],Q=[1,65],K=[1,66],J=[1,67],tt=[1,68],et=[1,69],nt=[24,52],rt=[24,44,46,47,48,49,50,51,52,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84],it=[15,24,44,46,47,48,49,50,51,52,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84],at=[1,94],ot=[1,95],st=[1,96],ct=[1,97],lt=[15,24,52],ut=[7,8,9,10,18,22,25,26,27,28],ht=[15,24,43,52],ft=[15,24,43,52,86,87,89,90],dt=[15,43],pt=[44,46,47,48,49,50,51,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84],gt={trace:function(){},yy:{},symbols_:{error:2,start:3,mermaidDoc:4,direction:5,directive:6,direction_tb:7,direction_bt:8,direction_rl:9,direction_lr:10,graphConfig:11,openDirective:12,typeDirective:13,closeDirective:14,NEWLINE:15,":":16,argDirective:17,open_directive:18,type_directive:19,arg_directive:20,close_directive:21,C4_CONTEXT:22,statements:23,EOF:24,C4_CONTAINER:25,C4_COMPONENT:26,C4_DYNAMIC:27,C4_DEPLOYMENT:28,otherStatements:29,diagramStatements:30,otherStatement:31,title:32,accDescription:33,acc_title:34,acc_title_value:35,acc_descr:36,acc_descr_value:37,acc_descr_multiline_value:38,boundaryStatement:39,boundaryStartStatement:40,boundaryStopStatement:41,boundaryStart:42,LBRACE:43,ENTERPRISE_BOUNDARY:44,attributes:45,SYSTEM_BOUNDARY:46,BOUNDARY:47,CONTAINER_BOUNDARY:48,NODE:49,NODE_L:50,NODE_R:51,RBRACE:52,diagramStatement:53,PERSON:54,PERSON_EXT:55,SYSTEM:56,SYSTEM_DB:57,SYSTEM_QUEUE:58,SYSTEM_EXT:59,SYSTEM_EXT_DB:60,SYSTEM_EXT_QUEUE:61,CONTAINER:62,CONTAINER_DB:63,CONTAINER_QUEUE:64,CONTAINER_EXT:65,CONTAINER_EXT_DB:66,CONTAINER_EXT_QUEUE:67,COMPONENT:68,COMPONENT_DB:69,COMPONENT_QUEUE:70,COMPONENT_EXT:71,COMPONENT_EXT_DB:72,COMPONENT_EXT_QUEUE:73,REL:74,BIREL:75,REL_U:76,REL_D:77,REL_L:78,REL_R:79,REL_B:80,REL_INDEX:81,UPDATE_EL_STYLE:82,UPDATE_REL_STYLE:83,UPDATE_LAYOUT_CONFIG:84,attribute:85,STR:86,STR_KEY:87,STR_VALUE:88,ATTRIBUTE:89,ATTRIBUTE_EMPTY:90,$accept:0,$end:1},terminals_:{2:"error",7:"direction_tb",8:"direction_bt",9:"direction_rl",10:"direction_lr",15:"NEWLINE",16:":",18:"open_directive",19:"type_directive",20:"arg_directive",21:"close_directive",22:"C4_CONTEXT",24:"EOF",25:"C4_CONTAINER",26:"C4_COMPONENT",27:"C4_DYNAMIC",28:"C4_DEPLOYMENT",32:"title",33:"accDescription",34:"acc_title",35:"acc_title_value",36:"acc_descr",37:"acc_descr_value",38:"acc_descr_multiline_value",43:"LBRACE",44:"ENTERPRISE_BOUNDARY",46:"SYSTEM_BOUNDARY",47:"BOUNDARY",48:"CONTAINER_BOUNDARY",49:"NODE",50:"NODE_L",51:"NODE_R",52:"RBRACE",54:"PERSON",55:"PERSON_EXT",56:"SYSTEM",57:"SYSTEM_DB",58:"SYSTEM_QUEUE",59:"SYSTEM_EXT",60:"SYSTEM_EXT_DB",61:"SYSTEM_EXT_QUEUE",62:"CONTAINER",63:"CONTAINER_DB",64:"CONTAINER_QUEUE",65:"CONTAINER_EXT",66:"CONTAINER_EXT_DB",67:"CONTAINER_EXT_QUEUE",68:"COMPONENT",69:"COMPONENT_DB",70:"COMPONENT_QUEUE",71:"COMPONENT_EXT",72:"COMPONENT_EXT_DB",73:"COMPONENT_EXT_QUEUE",74:"REL",75:"BIREL",76:"REL_U",77:"REL_D",78:"REL_L",79:"REL_R",80:"REL_B",81:"REL_INDEX",82:"UPDATE_EL_STYLE",83:"UPDATE_REL_STYLE",84:"UPDATE_LAYOUT_CONFIG",86:"STR",87:"STR_KEY",88:"STR_VALUE",89:"ATTRIBUTE",90:"ATTRIBUTE_EMPTY"},productions_:[0,[3,1],[3,1],[3,2],[5,1],[5,1],[5,1],[5,1],[4,1],[6,4],[6,6],[12,1],[13,1],[17,1],[14,1],[11,4],[11,4],[11,4],[11,4],[11,4],[23,1],[23,1],[23,2],[29,1],[29,2],[29,3],[31,1],[31,1],[31,2],[31,2],[31,1],[39,3],[40,3],[40,3],[40,4],[42,2],[42,2],[42,2],[42,2],[42,2],[42,2],[42,2],[41,1],[30,1],[30,2],[30,3],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,1],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[53,2],[45,1],[45,2],[85,1],[85,2],[85,1],[85,1]],performAction:function(t,e,n,r,i,a,o){var s=a.length-1;switch(i){case 4:r.setDirection("TB");break;case 5:r.setDirection("BT");break;case 6:r.setDirection("RL");break;case 7:r.setDirection("LR");break;case 11:console.log("open_directive: ",a[s]),r.parseDirective("%%{","open_directive");break;case 12:break;case 13:a[s]=a[s].trim().replace(/'/g,'"'),console.log("arg_directive: ",a[s]),r.parseDirective(a[s],"arg_directive");break;case 14:console.log("close_directive: ",a[s]),r.parseDirective("}%%","close_directive","c4Context");break;case 15:case 16:case 17:case 18:case 19:r.setC4Type(a[s-3]);break;case 26:r.setTitle(a[s].substring(6)),this.$=a[s].substring(6);break;case 27:r.setAccDescription(a[s].substring(15)),this.$=a[s].substring(15);break;case 28:this.$=a[s].trim(),r.setTitle(this.$);break;case 29:case 30:this.$=a[s].trim(),r.setAccDescription(this.$);break;case 35:case 36:console.log(a[s-1],JSON.stringify(a[s])),a[s].splice(2,0,"ENTERPRISE"),r.addPersonOrSystemBoundary(...a[s]),this.$=a[s];break;case 37:console.log(a[s-1],JSON.stringify(a[s])),r.addPersonOrSystemBoundary(...a[s]),this.$=a[s];break;case 38:console.log(a[s-1],JSON.stringify(a[s])),a[s].splice(2,0,"CONTAINER"),r.addContainerBoundary(...a[s]),this.$=a[s];break;case 39:console.log(a[s-1],JSON.stringify(a[s])),r.addDeploymentNode("node",...a[s]),this.$=a[s];break;case 40:console.log(a[s-1],JSON.stringify(a[s])),r.addDeploymentNode("nodeL",...a[s]),this.$=a[s];break;case 41:console.log(a[s-1],JSON.stringify(a[s])),r.addDeploymentNode("nodeR",...a[s]),this.$=a[s];break;case 42:r.popBoundaryParseStack();break;case 46:console.log(a[s-1],JSON.stringify(a[s])),r.addPersonOrSystem("person",...a[s]),this.$=a[s];break;case 47:console.log(a[s-1],JSON.stringify(a[s])),r.addPersonOrSystem("external_person",...a[s]),this.$=a[s];break;case 48:console.log(a[s-1],JSON.stringify(a[s])),r.addPersonOrSystem("system",...a[s]),this.$=a[s];break;case 49:console.log(a[s-1],JSON.stringify(a[s])),r.addPersonOrSystem("system_db",...a[s]),this.$=a[s];break;case 50:console.log(a[s-1],JSON.stringify(a[s])),r.addPersonOrSystem("system_queue",...a[s]),this.$=a[s];break;case 51:console.log(a[s-1],JSON.stringify(a[s])),r.addPersonOrSystem("external_system",...a[s]),this.$=a[s];break;case 52:console.log(a[s-1],JSON.stringify(a[s])),r.addPersonOrSystem("external_system_db",...a[s]),this.$=a[s];break;case 53:console.log(a[s-1],JSON.stringify(a[s])),r.addPersonOrSystem("external_system_queue",...a[s]),this.$=a[s];break;case 54:console.log(a[s-1],JSON.stringify(a[s])),r.addContainer("container",...a[s]),this.$=a[s];break;case 55:console.log(a[s-1],JSON.stringify(a[s])),r.addContainer("container_db",...a[s]),this.$=a[s];break;case 56:console.log(a[s-1],JSON.stringify(a[s])),r.addContainer("container_queue",...a[s]),this.$=a[s];break;case 57:console.log(a[s-1],JSON.stringify(a[s])),r.addContainer("external_container",...a[s]),this.$=a[s];break;case 58:console.log(a[s-1],JSON.stringify(a[s])),r.addContainer("external_container_db",...a[s]),this.$=a[s];break;case 59:console.log(a[s-1],JSON.stringify(a[s])),r.addContainer("external_container_queue",...a[s]),this.$=a[s];break;case 60:console.log(a[s-1],JSON.stringify(a[s])),r.addComponent("component",...a[s]),this.$=a[s];break;case 61:console.log(a[s-1],JSON.stringify(a[s])),r.addComponent("component_db",...a[s]),this.$=a[s];break;case 62:console.log(a[s-1],JSON.stringify(a[s])),r.addComponent("component_queue",...a[s]),this.$=a[s];break;case 63:console.log(a[s-1],JSON.stringify(a[s])),r.addComponent("external_component",...a[s]),this.$=a[s];break;case 64:console.log(a[s-1],JSON.stringify(a[s])),r.addComponent("external_component_db",...a[s]),this.$=a[s];break;case 65:console.log(a[s-1],JSON.stringify(a[s])),r.addComponent("external_component_queue",...a[s]),this.$=a[s];break;case 67:console.log(a[s-1],JSON.stringify(a[s])),r.addRel("rel",...a[s]),this.$=a[s];break;case 68:console.log(a[s-1],JSON.stringify(a[s])),r.addRel("birel",...a[s]),this.$=a[s];break;case 69:console.log(a[s-1],JSON.stringify(a[s])),r.addRel("rel_u",...a[s]),this.$=a[s];break;case 70:console.log(a[s-1],JSON.stringify(a[s])),r.addRel("rel_d",...a[s]),this.$=a[s];break;case 71:console.log(a[s-1],JSON.stringify(a[s])),r.addRel("rel_l",...a[s]),this.$=a[s];break;case 72:console.log(a[s-1],JSON.stringify(a[s])),r.addRel("rel_r",...a[s]),this.$=a[s];break;case 73:console.log(a[s-1],JSON.stringify(a[s])),r.addRel("rel_b",...a[s]),this.$=a[s];break;case 74:console.log(a[s-1],JSON.stringify(a[s])),a[s].splice(0,1),r.addRel("rel",...a[s]),this.$=a[s];break;case 75:console.log(a[s-1],JSON.stringify(a[s])),r.updateElStyle("update_el_style",...a[s]),this.$=a[s];break;case 76:console.log(a[s-1],JSON.stringify(a[s])),r.updateRelStyle("update_rel_style",...a[s]),this.$=a[s];break;case 77:console.log(a[s-1],JSON.stringify(a[s])),r.updateLayoutConfig("update_layout_config",...a[s]),this.$=a[s];break;case 78:console.log("PUSH ATTRIBUTE: ",a[s]),this.$=[a[s]];break;case 79:console.log("PUSH ATTRIBUTE: ",a[s-1]),a[s].unshift(a[s-1]),this.$=a[s];break;case 80:case 82:this.$=a[s].trim();break;case 81:console.log("kv: ",a[s-1],a[s]);let t={};t[a[s-1].trim()]=a[s].trim(),this.$=t;break;case 83:this.$="";}},table:[{3:1,4:2,5:3,6:4,7:e,8:n,9:r,10:i,11:5,12:10,18:a,22:o,25:s,26:l,27:u,28:h},{1:[3]},{1:[2,1]},{1:[2,2]},{3:17,4:2,5:3,6:4,7:e,8:n,9:r,10:i,11:5,12:10,18:a,22:o,25:s,26:l,27:u,28:h},{1:[2,8]},{1:[2,4]},{1:[2,5]},{1:[2,6]},{1:[2,7]},{13:18,19:[1,19]},{15:[1,20]},{15:[1,21]},{15:[1,22]},{15:[1,23]},{15:[1,24]},{19:[2,11]},{1:[2,3]},{14:25,16:[1,26],21:f},t([16,21],[2,12]),{23:28,29:29,30:30,31:31,32:d,33:p,34:g,36:y,38:m,39:58,40:70,42:71,44:b,46:v,47:_,48:x,49:k,50:w,51:T,53:32,54:E,55:C,56:S,57:A,58:M,59:N,60:O,61:D,62:B,63:L,64:I,65:F,66:R,67:P,68:j,69:z,70:Y,71:U,72:$,73:W,74:q,75:H,76:V,77:G,78:X,79:Z,80:Q,81:K,82:J,83:tt,84:et},{23:79,29:29,30:30,31:31,32:d,33:p,34:g,36:y,38:m,39:58,40:70,42:71,44:b,46:v,47:_,48:x,49:k,50:w,51:T,53:32,54:E,55:C,56:S,57:A,58:M,59:N,60:O,61:D,62:B,63:L,64:I,65:F,66:R,67:P,68:j,69:z,70:Y,71:U,72:$,73:W,74:q,75:H,76:V,77:G,78:X,79:Z,80:Q,81:K,82:J,83:tt,84:et},{23:80,29:29,30:30,31:31,32:d,33:p,34:g,36:y,38:m,39:58,40:70,42:71,44:b,46:v,47:_,48:x,49:k,50:w,51:T,53:32,54:E,55:C,56:S,57:A,58:M,59:N,60:O,61:D,62:B,63:L,64:I,65:F,66:R,67:P,68:j,69:z,70:Y,71:U,72:$,73:W,74:q,75:H,76:V,77:G,78:X,79:Z,80:Q,81:K,82:J,83:tt,84:et},{23:81,29:29,30:30,31:31,32:d,33:p,34:g,36:y,38:m,39:58,40:70,42:71,44:b,46:v,47:_,48:x,49:k,50:w,51:T,53:32,54:E,55:C,56:S,57:A,58:M,59:N,60:O,61:D,62:B,63:L,64:I,65:F,66:R,67:P,68:j,69:z,70:Y,71:U,72:$,73:W,74:q,75:H,76:V,77:G,78:X,79:Z,80:Q,81:K,82:J,83:tt,84:et},{23:82,29:29,30:30,31:31,32:d,33:p,34:g,36:y,38:m,39:58,40:70,42:71,44:b,46:v,47:_,48:x,49:k,50:w,51:T,53:32,54:E,55:C,56:S,57:A,58:M,59:N,60:O,61:D,62:B,63:L,64:I,65:F,66:R,67:P,68:j,69:z,70:Y,71:U,72:$,73:W,74:q,75:H,76:V,77:G,78:X,79:Z,80:Q,81:K,82:J,83:tt,84:et},{15:[1,83]},{17:84,20:[1,85]},{15:[2,14]},{24:[1,86]},t(nt,[2,20],{53:32,39:58,40:70,42:71,30:87,44:b,46:v,47:_,48:x,49:k,50:w,51:T,54:E,55:C,56:S,57:A,58:M,59:N,60:O,61:D,62:B,63:L,64:I,65:F,66:R,67:P,68:j,69:z,70:Y,71:U,72:$,73:W,74:q,75:H,76:V,77:G,78:X,79:Z,80:Q,81:K,82:J,83:tt,84:et}),t(nt,[2,21]),t(rt,[2,23],{15:[1,88]}),t(nt,[2,43],{15:[1,89]}),t(it,[2,26]),t(it,[2,27]),{35:[1,90]},{37:[1,91]},t(it,[2,30]),{45:92,85:93,86:at,87:ot,89:st,90:ct},{45:98,85:93,86:at,87:ot,89:st,90:ct},{45:99,85:93,86:at,87:ot,89:st,90:ct},{45:100,85:93,86:at,87:ot,89:st,90:ct},{45:101,85:93,86:at,87:ot,89:st,90:ct},{45:102,85:93,86:at,87:ot,89:st,90:ct},{45:103,85:93,86:at,87:ot,89:st,90:ct},{45:104,85:93,86:at,87:ot,89:st,90:ct},{45:105,85:93,86:at,87:ot,89:st,90:ct},{45:106,85:93,86:at,87:ot,89:st,90:ct},{45:107,85:93,86:at,87:ot,89:st,90:ct},{45:108,85:93,86:at,87:ot,89:st,90:ct},{45:109,85:93,86:at,87:ot,89:st,90:ct},{45:110,85:93,86:at,87:ot,89:st,90:ct},{45:111,85:93,86:at,87:ot,89:st,90:ct},{45:112,85:93,86:at,87:ot,89:st,90:ct},{45:113,85:93,86:at,87:ot,89:st,90:ct},{45:114,85:93,86:at,87:ot,89:st,90:ct},{45:115,85:93,86:at,87:ot,89:st,90:ct},{45:116,85:93,86:at,87:ot,89:st,90:ct},t(lt,[2,66]),{45:117,85:93,86:at,87:ot,89:st,90:ct},{45:118,85:93,86:at,87:ot,89:st,90:ct},{45:119,85:93,86:at,87:ot,89:st,90:ct},{45:120,85:93,86:at,87:ot,89:st,90:ct},{45:121,85:93,86:at,87:ot,89:st,90:ct},{45:122,85:93,86:at,87:ot,89:st,90:ct},{45:123,85:93,86:at,87:ot,89:st,90:ct},{45:124,85:93,86:at,87:ot,89:st,90:ct},{45:125,85:93,86:at,87:ot,89:st,90:ct},{45:126,85:93,86:at,87:ot,89:st,90:ct},{45:127,85:93,86:at,87:ot,89:st,90:ct},{30:128,39:58,40:70,42:71,44:b,46:v,47:_,48:x,49:k,50:w,51:T,53:32,54:E,55:C,56:S,57:A,58:M,59:N,60:O,61:D,62:B,63:L,64:I,65:F,66:R,67:P,68:j,69:z,70:Y,71:U,72:$,73:W,74:q,75:H,76:V,77:G,78:X,79:Z,80:Q,81:K,82:J,83:tt,84:et},{15:[1,130],43:[1,129]},{45:131,85:93,86:at,87:ot,89:st,90:ct},{45:132,85:93,86:at,87:ot,89:st,90:ct},{45:133,85:93,86:at,87:ot,89:st,90:ct},{45:134,85:93,86:at,87:ot,89:st,90:ct},{45:135,85:93,86:at,87:ot,89:st,90:ct},{45:136,85:93,86:at,87:ot,89:st,90:ct},{45:137,85:93,86:at,87:ot,89:st,90:ct},{24:[1,138]},{24:[1,139]},{24:[1,140]},{24:[1,141]},t(ut,[2,9]),{14:142,21:f},{21:[2,13]},{1:[2,15]},t(nt,[2,22]),t(rt,[2,24],{31:31,29:143,32:d,33:p,34:g,36:y,38:m}),t(nt,[2,44],{29:29,30:30,31:31,53:32,39:58,40:70,42:71,23:144,32:d,33:p,34:g,36:y,38:m,44:b,46:v,47:_,48:x,49:k,50:w,51:T,54:E,55:C,56:S,57:A,58:M,59:N,60:O,61:D,62:B,63:L,64:I,65:F,66:R,67:P,68:j,69:z,70:Y,71:U,72:$,73:W,74:q,75:H,76:V,77:G,78:X,79:Z,80:Q,81:K,82:J,83:tt,84:et}),t(it,[2,28]),t(it,[2,29]),t(lt,[2,46]),t(ht,[2,78],{85:93,45:145,86:at,87:ot,89:st,90:ct}),t(ft,[2,80]),{88:[1,146]},t(ft,[2,82]),t(ft,[2,83]),t(lt,[2,47]),t(lt,[2,48]),t(lt,[2,49]),t(lt,[2,50]),t(lt,[2,51]),t(lt,[2,52]),t(lt,[2,53]),t(lt,[2,54]),t(lt,[2,55]),t(lt,[2,56]),t(lt,[2,57]),t(lt,[2,58]),t(lt,[2,59]),t(lt,[2,60]),t(lt,[2,61]),t(lt,[2,62]),t(lt,[2,63]),t(lt,[2,64]),t(lt,[2,65]),t(lt,[2,67]),t(lt,[2,68]),t(lt,[2,69]),t(lt,[2,70]),t(lt,[2,71]),t(lt,[2,72]),t(lt,[2,73]),t(lt,[2,74]),t(lt,[2,75]),t(lt,[2,76]),t(lt,[2,77]),{41:147,52:[1,148]},{15:[1,149]},{43:[1,150]},t(dt,[2,35]),t(dt,[2,36]),t(dt,[2,37]),t(dt,[2,38]),t(dt,[2,39]),t(dt,[2,40]),t(dt,[2,41]),{1:[2,16]},{1:[2,17]},{1:[2,18]},{1:[2,19]},{15:[1,151]},t(rt,[2,25]),t(nt,[2,45]),t(ht,[2,79]),t(ft,[2,81]),t(lt,[2,31]),t(lt,[2,42]),t(pt,[2,32]),t(pt,[2,33],{15:[1,152]}),t(ut,[2,10]),t(pt,[2,34])],defaultActions:{2:[2,1],3:[2,2],5:[2,8],6:[2,4],7:[2,5],8:[2,6],9:[2,7],16:[2,11],17:[2,3],27:[2,14],85:[2,13],86:[2,15],138:[2,16],139:[2,17],140:[2,18],141:[2,19]},parseError:function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t);},parse:function(t){var e=this,n=[0],r=[],i=[null],a=[],o=this.table,s="",c=0,l=0,u=0,h=2,f=1,d=a.slice.call(arguments,1),p=Object.create(this.lexer),g={yy:{}};for(var y in this.yy)Object.prototype.hasOwnProperty.call(this.yy,y)&&(g.yy[y]=this.yy[y]);p.setInput(t,g.yy),g.yy.lexer=p,g.yy.parser=this,void 0===p.yylloc&&(p.yylloc={});var m=p.yylloc;a.push(m);var b=p.options&&p.options.ranges;function v(){var t;return "number"!=typeof(t=r.pop()||p.lex()||f)&&(t instanceof Array&&(t=(r=t).pop()),t=e.symbols_[t]||t),t}"function"==typeof g.yy.parseError?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var _,x,k,w,T,E,C,S,A,M={};;){if(k=n[n.length-1],this.defaultActions[k]?w=this.defaultActions[k]:(null==_&&(_=v()),w=o[k]&&o[k][_]),void 0===w||!w.length||!w[0]){var N="";for(E in A=[],o[k])this.terminals_[E]&&E>h&&A.push("'"+this.terminals_[E]+"'");N=p.showPosition?"Parse error on line "+(c+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[_]||_)+"'":"Parse error on line "+(c+1)+": Unexpected "+(_==f?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(N,{text:p.match,token:this.terminals_[_]||_,line:p.yylineno,loc:m,expected:A});}if(w[0]instanceof Array&&w.length>1)throw new Error("Parse Error: multiple actions possible at state: "+k+", token: "+_);switch(w[0]){case 1:n.push(_),i.push(p.yytext),a.push(p.yylloc),n.push(w[1]),_=null,x?(_=x,x=null):(l=p.yyleng,s=p.yytext,c=p.yylineno,m=p.yylloc,u>0&&u--);break;case 2:if(C=this.productions_[w[1]][1],M.$=i[i.length-C],M._$={first_line:a[a.length-(C||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(C||1)].first_column,last_column:a[a.length-1].last_column},b&&(M._$.range=[a[a.length-(C||1)].range[0],a[a.length-1].range[1]]),void 0!==(T=this.performAction.apply(M,[s,l,c,g.yy,w[1],i,a].concat(d))))return T;C&&(n=n.slice(0,-1*C*2),i=i.slice(0,-1*C),a=a.slice(0,-1*C)),n.push(this.productions_[w[1]][0]),i.push(M.$),a.push(M._$),S=o[n[n.length-2]][n[n.length-1]],n.push(S);break;case 3:return !0}}return !0}},yt={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e);},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t));},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return (t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var n,r,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(r=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in i)this[a]=i[a];return !1}return !1},next:function(){if(this.done)return this.EOF;var t,e,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),a=0;a<i.length;a++)if((n=this._input.match(this.rules[i[a]]))&&(!e||n[0].length>e[0].length)){if(e=n,r=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,i[a])))return t;if(this._backtrack){e=!1;continue}return !1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[r]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(t){this.conditionStack.push(t);},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return (t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t);},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(t,e,n,r){switch(n){case 0:return this.begin("open_directive"),18;case 1:return 7;case 2:return 8;case 3:return 9;case 4:return 10;case 5:return this.begin("type_directive"),19;case 6:return this.popState(),this.begin("arg_directive"),16;case 7:return this.popState(),this.popState(),21;case 8:return 20;case 9:return 32;case 10:return 33;case 11:return this.begin("acc_title"),34;case 12:return this.popState(),"acc_title_value";case 13:return this.begin("acc_descr"),36;case 14:return this.popState(),"acc_descr_value";case 15:this.begin("acc_descr_multiline");break;case 16:this.popState();break;case 17:return "acc_descr_multiline_value";case 18:case 21:break;case 19:c;break;case 20:return 15;case 22:return 22;case 23:return 25;case 24:return 26;case 25:return 27;case 26:return 28;case 27:return this.begin("person_ext"),console.log("begin person_ext"),55;case 28:return this.begin("person"),console.log("begin person"),54;case 29:return this.begin("system_ext_queue"),console.log("begin system_ext_queue"),61;case 30:return this.begin("system_ext_db"),console.log("begin system_ext_db"),60;case 31:return this.begin("system_ext"),console.log("begin system_ext"),59;case 32:return this.begin("system_queue"),console.log("begin system_queue"),58;case 33:return this.begin("system_db"),console.log("begin system_db"),57;case 34:return this.begin("system"),console.log("begin system"),56;case 35:return this.begin("boundary"),console.log("begin boundary"),47;case 36:return this.begin("enterprise_boundary"),console.log("begin enterprise_boundary"),44;case 37:return this.begin("system_boundary"),console.log("begin system_boundary"),46;case 38:return this.begin("container_ext_queue"),console.log("begin container_ext_queue"),67;case 39:return this.begin("container_ext_db"),console.log("begin container_ext_db"),66;case 40:return this.begin("container_ext"),console.log("begin container_ext"),65;case 41:return this.begin("container_queue"),console.log("begin container_queue"),64;case 42:return this.begin("container_db"),console.log("begin container_db"),63;case 43:return this.begin("container"),console.log("begin container"),62;case 44:return this.begin("container_boundary"),console.log("begin container_boundary"),48;case 45:return this.begin("component_ext_queue"),console.log("begin component_ext_queue"),73;case 46:return this.begin("component_ext_db"),console.log("begin component_ext_db"),72;case 47:return this.begin("component_ext"),console.log("begin component_ext"),71;case 48:return this.begin("component_queue"),console.log("begin component_queue"),70;case 49:return this.begin("component_db"),console.log("begin component_db"),69;case 50:return this.begin("component"),console.log("begin component"),68;case 51:case 52:return this.begin("node"),console.log("begin node"),49;case 53:return this.begin("node_l"),console.log("begin node_l"),50;case 54:return this.begin("node_r"),console.log("begin node_r"),51;case 55:return this.begin("rel"),console.log("begin rel"),74;case 56:return this.begin("birel"),console.log("begin birel"),75;case 57:case 58:return this.begin("rel_u"),console.log("begin rel_u"),76;case 59:case 60:return this.begin("rel_d"),console.log("begin rel_d"),77;case 61:case 62:return this.begin("rel_l"),console.log("begin rel_l"),78;case 63:case 64:return this.begin("rel_r"),console.log("begin rel_r"),79;case 65:return this.begin("rel_b"),console.log("begin rel_b"),80;case 66:return this.begin("rel_index"),console.log("begin rel_index"),81;case 67:return this.begin("update_el_style"),console.log("begin update_el_style"),82;case 68:return this.begin("update_rel_style"),console.log("begin update_rel_style"),83;case 69:return this.begin("update_layout_config"),console.log("begin update_layout_config"),84;case 70:return "EOF_IN_STRUCT";case 71:return console.log("begin attribute with ATTRIBUTE_EMPTY"),this.begin("attribute"),"ATTRIBUTE_EMPTY";case 72:console.log("begin attribute"),this.begin("attribute");break;case 73:console.log("STOP attribute"),this.popState(),console.log("STOP diagram"),this.popState();break;case 74:return console.log(",,"),90;case 75:console.log(",");break;case 76:return console.log("ATTRIBUTE_EMPTY"),90;case 77:console.log("begin string"),this.begin("string");break;case 78:console.log("STOP string"),this.popState();break;case 79:return console.log("STR"),"STR";case 80:console.log("begin string_kv"),this.begin("string_kv");break;case 81:return console.log("STR_KEY"),this.begin("string_kv_key"),"STR_KEY";case 82:console.log("begin string_kv_value"),this.popState(),this.begin("string_kv_value");break;case 83:return console.log("STR_VALUE"),"STR_VALUE";case 84:console.log("STOP string_kv_value"),this.popState(),this.popState();break;case 85:return console.log("not STR"),"STR";case 86:return console.log("begin boundary block"),"LBRACE";case 87:return console.log("STOP boundary block"),"RBRACE";case 88:return "SPACE";case 89:return "EOL";case 90:return 24}},rules:[/^(?:%%\{)/,/^(?:.*direction\s+TB[^\n]*)/,/^(?:.*direction\s+BT[^\n]*)/,/^(?:.*direction\s+RL[^\n]*)/,/^(?:.*direction\s+LR[^\n]*)/,/^(?:((?:(?!\}%%)[^:.])*))/,/^(?::)/,/^(?:\}%%)/,/^(?:((?:(?!\}%%).|\n)*))/,/^(?:title\s[^#\n;]+)/,/^(?:accDescription\s[^#\n;]+)/,/^(?:accTitle\s*:\s*)/,/^(?:(?!\n||)*[^\n]*)/,/^(?:accDescr\s*:\s*)/,/^(?:(?!\n||)*[^\n]*)/,/^(?:accDescr\s*\{\s*)/,/^(?:[\}])/,/^(?:[^\}]*)/,/^(?:%%(?!\{)*[^\n]*(\r?\n?)+)/,/^(?:%%[^\n]*(\r?\n)*)/,/^(?:\s*(\r?\n)+)/,/^(?:\s+)/,/^(?:C4Context\b)/,/^(?:C4Container\b)/,/^(?:C4Component\b)/,/^(?:C4Dynamic\b)/,/^(?:C4Deployment\b)/,/^(?:Person_Ext\b)/,/^(?:Person\b)/,/^(?:SystemQueue_Ext\b)/,/^(?:SystemDb_Ext\b)/,/^(?:System_Ext\b)/,/^(?:SystemQueue\b)/,/^(?:SystemDb\b)/,/^(?:System\b)/,/^(?:Boundary\b)/,/^(?:Enterprise_Boundary\b)/,/^(?:System_Boundary\b)/,/^(?:ContainerQueue_Ext\b)/,/^(?:ContainerDb_Ext\b)/,/^(?:Container_Ext\b)/,/^(?:ContainerQueue\b)/,/^(?:ContainerDb\b)/,/^(?:Container\b)/,/^(?:Container_Boundary\b)/,/^(?:ComponentQueue_Ext\b)/,/^(?:ComponentDb_Ext\b)/,/^(?:Component_Ext\b)/,/^(?:ComponentQueue\b)/,/^(?:ComponentDb\b)/,/^(?:Component\b)/,/^(?:Deployment_Node\b)/,/^(?:Node\b)/,/^(?:Node_L\b)/,/^(?:Node_R\b)/,/^(?:Rel\b)/,/^(?:BiRel\b)/,/^(?:Rel_Up\b)/,/^(?:Rel_U\b)/,/^(?:Rel_Down\b)/,/^(?:Rel_D\b)/,/^(?:Rel_Left\b)/,/^(?:Rel_L\b)/,/^(?:Rel_Right\b)/,/^(?:Rel_R\b)/,/^(?:Rel_Back\b)/,/^(?:RelIndex\b)/,/^(?:UpdateElementStyle\b)/,/^(?:UpdateRelStyle\b)/,/^(?:UpdateLayoutConfig\b)/,/^(?:$)/,/^(?:[(][ ]*[,])/,/^(?:[(])/,/^(?:[)])/,/^(?:,,)/,/^(?:,)/,/^(?:[ ]*["]["])/,/^(?:[ ]*["])/,/^(?:["])/,/^(?:[^"]*)/,/^(?:[ ]*[\$])/,/^(?:[^=]*)/,/^(?:[=][ ]*["])/,/^(?:[^"]+)/,/^(?:["])/,/^(?:[^,]+)/,/^(?:\{)/,/^(?:\})/,/^(?:[\s]+)/,/^(?:[\n\r]+)/,/^(?:$)/],conditions:{acc_descr_multiline:{rules:[16,17],inclusive:!1},acc_descr:{rules:[14],inclusive:!1},acc_title:{rules:[12],inclusive:!1},close_directive:{rules:[],inclusive:!1},arg_directive:{rules:[7,8],inclusive:!1},type_directive:{rules:[6,7],inclusive:!1},open_directive:{rules:[5],inclusive:!1},string_kv_value:{rules:[83,84],inclusive:!1},string_kv_key:{rules:[82],inclusive:!1},string_kv:{rules:[81],inclusive:!1},string:{rules:[78,79],inclusive:!1},attribute:{rules:[73,74,75,76,77,80,85],inclusive:!1},update_layout_config:{rules:[70,71,72,73],inclusive:!1},update_rel_style:{rules:[70,71,72,73],inclusive:!1},update_el_style:{rules:[70,71,72,73],inclusive:!1},rel_b:{rules:[70,71,72,73],inclusive:!1},rel_r:{rules:[70,71,72,73],inclusive:!1},rel_l:{rules:[70,71,72,73],inclusive:!1},rel_d:{rules:[70,71,72,73],inclusive:!1},rel_u:{rules:[70,71,72,73],inclusive:!1},rel_bi:{rules:[],inclusive:!1},rel:{rules:[70,71,72,73],inclusive:!1},node_r:{rules:[70,71,72,73],inclusive:!1},node_l:{rules:[70,71,72,73],inclusive:!1},node:{rules:[70,71,72,73],inclusive:!1},index:{rules:[],inclusive:!1},rel_index:{rules:[70,71,72,73],inclusive:!1},component_ext_queue:{rules:[],inclusive:!1},component_ext_db:{rules:[70,71,72,73],inclusive:!1},component_ext:{rules:[70,71,72,73],inclusive:!1},component_queue:{rules:[70,71,72,73],inclusive:!1},component_db:{rules:[70,71,72,73],inclusive:!1},component:{rules:[70,71,72,73],inclusive:!1},container_boundary:{rules:[70,71,72,73],inclusive:!1},container_ext_queue:{rules:[],inclusive:!1},container_ext_db:{rules:[70,71,72,73],inclusive:!1},container_ext:{rules:[70,71,72,73],inclusive:!1},container_queue:{rules:[70,71,72,73],inclusive:!1},container_db:{rules:[70,71,72,73],inclusive:!1},container:{rules:[70,71,72,73],inclusive:!1},birel:{rules:[70,71,72,73],inclusive:!1},system_boundary:{rules:[70,71,72,73],inclusive:!1},enterprise_boundary:{rules:[70,71,72,73],inclusive:!1},boundary:{rules:[70,71,72,73],inclusive:!1},system_ext_queue:{rules:[70,71,72,73],inclusive:!1},system_ext_db:{rules:[70,71,72,73],inclusive:!1},system_ext:{rules:[70,71,72,73],inclusive:!1},system_queue:{rules:[70,71,72,73],inclusive:!1},system_db:{rules:[70,71,72,73],inclusive:!1},system:{rules:[70,71,72,73],inclusive:!1},person_ext:{rules:[70,71,72,73],inclusive:!1},person:{rules:[70,71,72,73],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,9,10,11,13,15,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,86,87,88,89,90],inclusive:!0}}};function mt(){this.yy={};}return gt.lexer=yt,mt.prototype=gt,gt.Parser=mt,new mt}();e.parser=r,e.Parser=r.Parser,e.parse=function(){return r.parse.apply(r,arguments)},e.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var r=n(555).readFileSync(n(6470).normalize(t[1]),"utf8");return e.parser.parse(r)},n.c[n.s]===t&&e.main(process.argv.slice(1));},1362:(t,e,n)=>{t=n.nmd(t);var r=function(){var t=function(t,e,n,r){for(n=n||{},r=t.length;r--;n[t[r]]=e);return n},e=[1,3],n=[1,7],r=[1,8],i=[1,9],a=[1,10],o=[1,13],s=[1,12],c=[1,16,25],l=[1,20],u=[1,31],h=[1,32],f=[1,33],d=[1,35],p=[1,38],g=[1,36],y=[1,37],m=[1,39],b=[1,40],v=[1,41],_=[1,42],x=[1,45],k=[1,46],w=[1,47],T=[1,48],E=[16,25],C=[1,62],S=[1,63],A=[1,64],M=[1,65],N=[1,66],O=[1,67],D=[1,68],B=[16,25,32,44,45,53,56,57,58,59,60,61,62,67,69],L=[16,25,30,32,44,45,49,53,56,57,58,59,60,61,62,67,69,84,85,86,87],I=[5,8,9,10,11,16,19,23,25],F=[53,84,85,86,87],R=[53,61,62,84,85,86,87],P=[53,56,57,58,59,60,84,85,86,87],j=[16,25,32],z=[1,100],Y={trace:function(){},yy:{},symbols_:{error:2,start:3,mermaidDoc:4,statments:5,direction:6,directive:7,direction_tb:8,direction_bt:9,direction_rl:10,direction_lr:11,graphConfig:12,openDirective:13,typeDirective:14,closeDirective:15,NEWLINE:16,":":17,argDirective:18,open_directive:19,type_directive:20,arg_directive:21,close_directive:22,CLASS_DIAGRAM:23,statements:24,EOF:25,statement:26,className:27,alphaNumToken:28,classLiteralName:29,GENERICTYPE:30,relationStatement:31,LABEL:32,classStatement:33,methodStatement:34,annotationStatement:35,clickStatement:36,cssClassStatement:37,acc_title:38,acc_title_value:39,acc_descr:40,acc_descr_value:41,acc_descr_multiline_value:42,CLASS:43,STYLE_SEPARATOR:44,STRUCT_START:45,members:46,STRUCT_STOP:47,ANNOTATION_START:48,ANNOTATION_END:49,MEMBER:50,SEPARATOR:51,relation:52,STR:53,relationType:54,lineType:55,AGGREGATION:56,EXTENSION:57,COMPOSITION:58,DEPENDENCY:59,LOLLIPOP:60,LINE:61,DOTTED_LINE:62,CALLBACK:63,LINK:64,LINK_TARGET:65,CLICK:66,CALLBACK_NAME:67,CALLBACK_ARGS:68,HREF:69,CSSCLASS:70,commentToken:71,textToken:72,graphCodeTokens:73,textNoTagsToken:74,TAGSTART:75,TAGEND:76,"==":77,"--":78,PCT:79,DEFAULT:80,SPACE:81,MINUS:82,keywords:83,UNICODE_TEXT:84,NUM:85,ALPHA:86,BQUOTE_STR:87,$accept:0,$end:1},terminals_:{2:"error",5:"statments",8:"direction_tb",9:"direction_bt",10:"direction_rl",11:"direction_lr",16:"NEWLINE",17:":",19:"open_directive",20:"type_directive",21:"arg_directive",22:"close_directive",23:"CLASS_DIAGRAM",25:"EOF",30:"GENERICTYPE",32:"LABEL",38:"acc_title",39:"acc_title_value",40:"acc_descr",41:"acc_descr_value",42:"acc_descr_multiline_value",43:"CLASS",44:"STYLE_SEPARATOR",45:"STRUCT_START",47:"STRUCT_STOP",48:"ANNOTATION_START",49:"ANNOTATION_END",50:"MEMBER",51:"SEPARATOR",53:"STR",56:"AGGREGATION",57:"EXTENSION",58:"COMPOSITION",59:"DEPENDENCY",60:"LOLLIPOP",61:"LINE",62:"DOTTED_LINE",63:"CALLBACK",64:"LINK",65:"LINK_TARGET",66:"CLICK",67:"CALLBACK_NAME",68:"CALLBACK_ARGS",69:"HREF",70:"CSSCLASS",73:"graphCodeTokens",75:"TAGSTART",76:"TAGEND",77:"==",78:"--",79:"PCT",80:"DEFAULT",81:"SPACE",82:"MINUS",83:"keywords",84:"UNICODE_TEXT",85:"NUM",86:"ALPHA",87:"BQUOTE_STR"},productions_:[0,[3,1],[3,1],[3,1],[3,2],[6,1],[6,1],[6,1],[6,1],[4,1],[7,4],[7,6],[13,1],[14,1],[18,1],[15,1],[12,4],[24,1],[24,2],[24,3],[27,1],[27,1],[27,2],[27,2],[27,2],[26,1],[26,2],[26,1],[26,1],[26,1],[26,1],[26,1],[26,1],[26,1],[26,2],[26,2],[26,1],[33,2],[33,4],[33,5],[33,7],[35,4],[46,1],[46,2],[34,1],[34,2],[34,1],[34,1],[31,3],[31,4],[31,4],[31,5],[52,3],[52,2],[52,2],[52,1],[54,1],[54,1],[54,1],[54,1],[54,1],[55,1],[55,1],[36,3],[36,4],[36,3],[36,4],[36,4],[36,5],[36,3],[36,4],[36,4],[36,5],[36,3],[36,4],[36,4],[36,5],[37,3],[71,1],[71,1],[72,1],[72,1],[72,1],[72,1],[72,1],[72,1],[72,1],[74,1],[74,1],[74,1],[74,1],[28,1],[28,1],[28,1],[29,1]],performAction:function(t,e,n,r,i,a,o){var s=a.length-1;switch(i){case 5:r.setDirection("TB");break;case 6:r.setDirection("BT");break;case 7:r.setDirection("RL");break;case 8:r.setDirection("LR");break;case 12:r.parseDirective("%%{","open_directive");break;case 13:r.parseDirective(a[s],"type_directive");break;case 14:a[s]=a[s].trim().replace(/'/g,'"'),r.parseDirective(a[s],"arg_directive");break;case 15:r.parseDirective("}%%","close_directive","class");break;case 20:case 21:this.$=a[s];break;case 22:this.$=a[s-1]+a[s];break;case 23:case 24:this.$=a[s-1]+"~"+a[s];break;case 25:r.addRelation(a[s]);break;case 26:a[s-1].title=r.cleanupLabel(a[s]),r.addRelation(a[s-1]);break;case 34:this.$=a[s].trim(),r.setAccTitle(this.$);break;case 35:case 36:this.$=a[s].trim(),r.setAccDescription(this.$);break;case 37:r.addClass(a[s]);break;case 38:r.addClass(a[s-2]),r.setCssClass(a[s-2],a[s]);break;case 39:r.addClass(a[s-3]),r.addMembers(a[s-3],a[s-1]);break;case 40:r.addClass(a[s-5]),r.setCssClass(a[s-5],a[s-3]),r.addMembers(a[s-5],a[s-1]);break;case 41:r.addAnnotation(a[s],a[s-2]);break;case 42:this.$=[a[s]];break;case 43:a[s].push(a[s-1]),this.$=a[s];break;case 44:case 46:case 47:break;case 45:r.addMember(a[s-1],r.cleanupLabel(a[s]));break;case 48:this.$={id1:a[s-2],id2:a[s],relation:a[s-1],relationTitle1:"none",relationTitle2:"none"};break;case 49:this.$={id1:a[s-3],id2:a[s],relation:a[s-1],relationTitle1:a[s-2],relationTitle2:"none"};break;case 50:this.$={id1:a[s-3],id2:a[s],relation:a[s-2],relationTitle1:"none",relationTitle2:a[s-1]};break;case 51:this.$={id1:a[s-4],id2:a[s],relation:a[s-2],relationTitle1:a[s-3],relationTitle2:a[s-1]};break;case 52:this.$={type1:a[s-2],type2:a[s],lineType:a[s-1]};break;case 53:this.$={type1:"none",type2:a[s],lineType:a[s-1]};break;case 54:this.$={type1:a[s-1],type2:"none",lineType:a[s]};break;case 55:this.$={type1:"none",type2:"none",lineType:a[s]};break;case 56:this.$=r.relationType.AGGREGATION;break;case 57:this.$=r.relationType.EXTENSION;break;case 58:this.$=r.relationType.COMPOSITION;break;case 59:this.$=r.relationType.DEPENDENCY;break;case 60:this.$=r.relationType.LOLLIPOP;break;case 61:this.$=r.lineType.LINE;break;case 62:this.$=r.lineType.DOTTED_LINE;break;case 63:case 69:this.$=a[s-2],r.setClickEvent(a[s-1],a[s]);break;case 64:case 70:this.$=a[s-3],r.setClickEvent(a[s-2],a[s-1]),r.setTooltip(a[s-2],a[s]);break;case 65:case 73:this.$=a[s-2],r.setLink(a[s-1],a[s]);break;case 66:case 74:this.$=a[s-3],r.setLink(a[s-2],a[s-1],a[s]);break;case 67:case 75:this.$=a[s-3],r.setLink(a[s-2],a[s-1]),r.setTooltip(a[s-2],a[s]);break;case 68:case 76:this.$=a[s-4],r.setLink(a[s-3],a[s-2],a[s]),r.setTooltip(a[s-3],a[s-1]);break;case 71:this.$=a[s-3],r.setClickEvent(a[s-2],a[s-1],a[s]);break;case 72:this.$=a[s-4],r.setClickEvent(a[s-3],a[s-2],a[s-1]),r.setTooltip(a[s-3],a[s]);break;case 77:r.setCssClass(a[s-1],a[s]);}},table:[{3:1,4:2,5:e,6:4,7:5,8:n,9:r,10:i,11:a,12:6,13:11,19:o,23:s},{1:[3]},{1:[2,1]},{1:[2,2]},{1:[2,3]},{3:14,4:2,5:e,6:4,7:5,8:n,9:r,10:i,11:a,12:6,13:11,19:o,23:s},{1:[2,9]},t(c,[2,5]),t(c,[2,6]),t(c,[2,7]),t(c,[2,8]),{14:15,20:[1,16]},{16:[1,17]},{20:[2,12]},{1:[2,4]},{15:18,17:[1,19],22:l},t([17,22],[2,13]),{6:30,7:29,8:n,9:r,10:i,11:a,13:11,19:o,24:21,26:22,27:34,28:43,29:44,31:23,33:24,34:25,35:26,36:27,37:28,38:u,40:h,42:f,43:d,48:p,50:g,51:y,63:m,64:b,66:v,70:_,84:x,85:k,86:w,87:T},{16:[1,49]},{18:50,21:[1,51]},{16:[2,15]},{25:[1,52]},{16:[1,53],25:[2,17]},t(E,[2,25],{32:[1,54]}),t(E,[2,27]),t(E,[2,28]),t(E,[2,29]),t(E,[2,30]),t(E,[2,31]),t(E,[2,32]),t(E,[2,33]),{39:[1,55]},{41:[1,56]},t(E,[2,36]),t(E,[2,44],{52:57,54:60,55:61,32:[1,59],53:[1,58],56:C,57:S,58:A,59:M,60:N,61:O,62:D}),{27:69,28:43,29:44,84:x,85:k,86:w,87:T},t(E,[2,46]),t(E,[2,47]),{28:70,84:x,85:k,86:w},{27:71,28:43,29:44,84:x,85:k,86:w,87:T},{27:72,28:43,29:44,84:x,85:k,86:w,87:T},{27:73,28:43,29:44,84:x,85:k,86:w,87:T},{53:[1,74]},t(B,[2,20],{28:43,29:44,27:75,30:[1,76],84:x,85:k,86:w,87:T}),t(B,[2,21],{30:[1,77]}),t(L,[2,91]),t(L,[2,92]),t(L,[2,93]),t([16,25,30,32,44,45,53,56,57,58,59,60,61,62,67,69],[2,94]),t(I,[2,10]),{15:78,22:l},{22:[2,14]},{1:[2,16]},{6:30,7:29,8:n,9:r,10:i,11:a,13:11,19:o,24:79,25:[2,18],26:22,27:34,28:43,29:44,31:23,33:24,34:25,35:26,36:27,37:28,38:u,40:h,42:f,43:d,48:p,50:g,51:y,63:m,64:b,66:v,70:_,84:x,85:k,86:w,87:T},t(E,[2,26]),t(E,[2,34]),t(E,[2,35]),{27:80,28:43,29:44,53:[1,81],84:x,85:k,86:w,87:T},{52:82,54:60,55:61,56:C,57:S,58:A,59:M,60:N,61:O,62:D},t(E,[2,45]),{55:83,61:O,62:D},t(F,[2,55],{54:84,56:C,57:S,58:A,59:M,60:N}),t(R,[2,56]),t(R,[2,57]),t(R,[2,58]),t(R,[2,59]),t(R,[2,60]),t(P,[2,61]),t(P,[2,62]),t(E,[2,37],{44:[1,85],45:[1,86]}),{49:[1,87]},{53:[1,88]},{53:[1,89]},{67:[1,90],69:[1,91]},{28:92,84:x,85:k,86:w},t(B,[2,22]),t(B,[2,23]),t(B,[2,24]),{16:[1,93]},{25:[2,19]},t(j,[2,48]),{27:94,28:43,29:44,84:x,85:k,86:w,87:T},{27:95,28:43,29:44,53:[1,96],84:x,85:k,86:w,87:T},t(F,[2,54],{54:97,56:C,57:S,58:A,59:M,60:N}),t(F,[2,53]),{28:98,84:x,85:k,86:w},{46:99,50:z},{27:101,28:43,29:44,84:x,85:k,86:w,87:T},t(E,[2,63],{53:[1,102]}),t(E,[2,65],{53:[1,104],65:[1,103]}),t(E,[2,69],{53:[1,105],68:[1,106]}),t(E,[2,73],{53:[1,108],65:[1,107]}),t(E,[2,77]),t(I,[2,11]),t(j,[2,50]),t(j,[2,49]),{27:109,28:43,29:44,84:x,85:k,86:w,87:T},t(F,[2,52]),t(E,[2,38],{45:[1,110]}),{47:[1,111]},{46:112,47:[2,42],50:z},t(E,[2,41]),t(E,[2,64]),t(E,[2,66]),t(E,[2,67],{65:[1,113]}),t(E,[2,70]),t(E,[2,71],{53:[1,114]}),t(E,[2,74]),t(E,[2,75],{65:[1,115]}),t(j,[2,51]),{46:116,50:z},t(E,[2,39]),{47:[2,43]},t(E,[2,68]),t(E,[2,72]),t(E,[2,76]),{47:[1,117]},t(E,[2,40])],defaultActions:{2:[2,1],3:[2,2],4:[2,3],6:[2,9],13:[2,12],14:[2,4],20:[2,15],51:[2,14],52:[2,16],79:[2,19],112:[2,43]},parseError:function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t);},parse:function(t){var e=this,n=[0],r=[],i=[null],a=[],o=this.table,s="",c=0,l=0,u=0,h=2,f=1,d=a.slice.call(arguments,1),p=Object.create(this.lexer),g={yy:{}};for(var y in this.yy)Object.prototype.hasOwnProperty.call(this.yy,y)&&(g.yy[y]=this.yy[y]);p.setInput(t,g.yy),g.yy.lexer=p,g.yy.parser=this,void 0===p.yylloc&&(p.yylloc={});var m=p.yylloc;a.push(m);var b=p.options&&p.options.ranges;function v(){var t;return "number"!=typeof(t=r.pop()||p.lex()||f)&&(t instanceof Array&&(t=(r=t).pop()),t=e.symbols_[t]||t),t}"function"==typeof g.yy.parseError?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var _,x,k,w,T,E,C,S,A,M={};;){if(k=n[n.length-1],this.defaultActions[k]?w=this.defaultActions[k]:(null==_&&(_=v()),w=o[k]&&o[k][_]),void 0===w||!w.length||!w[0]){var N="";for(E in A=[],o[k])this.terminals_[E]&&E>h&&A.push("'"+this.terminals_[E]+"'");N=p.showPosition?"Parse error on line "+(c+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[_]||_)+"'":"Parse error on line "+(c+1)+": Unexpected "+(_==f?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(N,{text:p.match,token:this.terminals_[_]||_,line:p.yylineno,loc:m,expected:A});}if(w[0]instanceof Array&&w.length>1)throw new Error("Parse Error: multiple actions possible at state: "+k+", token: "+_);switch(w[0]){case 1:n.push(_),i.push(p.yytext),a.push(p.yylloc),n.push(w[1]),_=null,x?(_=x,x=null):(l=p.yyleng,s=p.yytext,c=p.yylineno,m=p.yylloc,u>0&&u--);break;case 2:if(C=this.productions_[w[1]][1],M.$=i[i.length-C],M._$={first_line:a[a.length-(C||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(C||1)].first_column,last_column:a[a.length-1].last_column},b&&(M._$.range=[a[a.length-(C||1)].range[0],a[a.length-1].range[1]]),void 0!==(T=this.performAction.apply(M,[s,l,c,g.yy,w[1],i,a].concat(d))))return T;C&&(n=n.slice(0,-1*C*2),i=i.slice(0,-1*C),a=a.slice(0,-1*C)),n.push(this.productions_[w[1]][0]),i.push(M.$),a.push(M._$),S=o[n[n.length-2]][n[n.length-1]],n.push(S);break;case 3:return !0}}return !0}},U={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e);},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t));},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return (t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var n,r,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(r=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in i)this[a]=i[a];return !1}return !1},next:function(){if(this.done)return this.EOF;var t,e,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),a=0;a<i.length;a++)if((n=this._input.match(this.rules[i[a]]))&&(!e||n[0].length>e[0].length)){if(e=n,r=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,i[a])))return t;if(this._backtrack){e=!1;continue}return !1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[r]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(t){this.conditionStack.push(t);},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return (t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t);},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(t,e,n,r){switch(n){case 0:return this.begin("open_directive"),19;case 1:return 8;case 2:return 9;case 3:return 10;case 4:return 11;case 5:return this.begin("type_directive"),20;case 6:return this.popState(),this.begin("arg_directive"),17;case 7:return this.popState(),this.popState(),22;case 8:return 21;case 9:case 10:case 19:case 27:break;case 11:return this.begin("acc_title"),38;case 12:return this.popState(),"acc_title_value";case 13:return this.begin("acc_descr"),40;case 14:return this.popState(),"acc_descr_value";case 15:this.begin("acc_descr_multiline");break;case 16:case 37:case 40:case 43:case 46:case 49:case 52:this.popState();break;case 17:return "acc_descr_multiline_value";case 18:return 16;case 20:case 21:return 23;case 22:return this.begin("struct"),45;case 23:return "EDGE_STATE";case 24:return "EOF_IN_STRUCT";case 25:return "OPEN_IN_STRUCT";case 26:return this.popState(),47;case 28:return "MEMBER";case 29:return 43;case 30:return 70;case 31:return 63;case 32:return 64;case 33:return 66;case 34:return 48;case 35:return 49;case 36:this.begin("generic");break;case 38:return "GENERICTYPE";case 39:this.begin("string");break;case 41:return "STR";case 42:this.begin("bqstring");break;case 44:return "BQUOTE_STR";case 45:this.begin("href");break;case 47:return 69;case 48:this.begin("callback_name");break;case 50:this.popState(),this.begin("callback_args");break;case 51:return 67;case 53:return 68;case 54:case 55:case 56:case 57:return 65;case 58:case 59:return 57;case 60:case 61:return 59;case 62:return 58;case 63:return 56;case 64:return 60;case 65:return 61;case 66:return 62;case 67:return 32;case 68:return 44;case 69:return 82;case 70:return "DOT";case 71:return "PLUS";case 72:return 79;case 73:case 74:return "EQUALS";case 75:return 86;case 76:return "PUNCTUATION";case 77:return 85;case 78:return 84;case 79:return 81;case 80:return 25}},rules:[/^(?:%%\{)/,/^(?:.*direction\s+TB[^\n]*)/,/^(?:.*direction\s+BT[^\n]*)/,/^(?:.*direction\s+RL[^\n]*)/,/^(?:.*direction\s+LR[^\n]*)/,/^(?:((?:(?!\}%%)[^:.])*))/,/^(?::)/,/^(?:\}%%)/,/^(?:((?:(?!\}%%).|\n)*))/,/^(?:%%(?!\{)*[^\n]*(\r?\n?)+)/,/^(?:%%[^\n]*(\r?\n)*)/,/^(?:accTitle\s*:\s*)/,/^(?:(?!\n||)*[^\n]*)/,/^(?:accDescr\s*:\s*)/,/^(?:(?!\n||)*[^\n]*)/,/^(?:accDescr\s*\{\s*)/,/^(?:[\}])/,/^(?:[^\}]*)/,/^(?:\s*(\r?\n)+)/,/^(?:\s+)/,/^(?:classDiagram-v2\b)/,/^(?:classDiagram\b)/,/^(?:[{])/,/^(?:\[\*\])/,/^(?:$)/,/^(?:[{])/,/^(?:[}])/,/^(?:[\n])/,/^(?:[^{}\n]*)/,/^(?:class\b)/,/^(?:cssClass\b)/,/^(?:callback\b)/,/^(?:link\b)/,/^(?:click\b)/,/^(?:<<)/,/^(?:>>)/,/^(?:[~])/,/^(?:[~])/,/^(?:[^~]*)/,/^(?:["])/,/^(?:["])/,/^(?:[^"]*)/,/^(?:[`])/,/^(?:[`])/,/^(?:[^`]+)/,/^(?:href[\s]+["])/,/^(?:["])/,/^(?:[^"]*)/,/^(?:call[\s]+)/,/^(?:\([\s]*\))/,/^(?:\()/,/^(?:[^(]*)/,/^(?:\))/,/^(?:[^)]*)/,/^(?:_self\b)/,/^(?:_blank\b)/,/^(?:_parent\b)/,/^(?:_top\b)/,/^(?:\s*<\|)/,/^(?:\s*\|>)/,/^(?:\s*>)/,/^(?:\s*<)/,/^(?:\s*\*)/,/^(?:\s*o\b)/,/^(?:\s*\(\))/,/^(?:--)/,/^(?:\.\.)/,/^(?::{1}[^:\n;]+)/,/^(?::{3})/,/^(?:-)/,/^(?:\.)/,/^(?:\+)/,/^(?:%)/,/^(?:=)/,/^(?:=)/,/^(?:\w+)/,/^(?:[!"#$%&'*+,-.`?\\/])/,/^(?:[0-9]+)/,/^(?:[\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|[\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|[\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|[\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE]|[\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA]|[\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0]|[\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977]|[\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2]|[\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A]|[\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39]|[\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8]|[\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C]|[\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C]|[\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99]|[\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0]|[\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D]|[\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3]|[\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10]|[\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1]|[\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81]|[\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3]|[\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6]|[\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A]|[\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081]|[\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D]|[\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0]|[\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310]|[\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C]|[\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711]|[\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7]|[\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C]|[\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16]|[\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF]|[\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC]|[\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D]|[\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D]|[\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3]|[\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F]|[\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128]|[\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184]|[\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3]|[\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6]|[\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE]|[\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C]|[\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D]|[\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC]|[\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B]|[\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788]|[\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805]|[\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB]|[\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28]|[\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5]|[\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4]|[\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E]|[\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D]|[\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36]|[\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D]|[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|[\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|[\uFFD2-\uFFD7\uFFDA-\uFFDC])/,/^(?:\s)/,/^(?:$)/],conditions:{acc_descr_multiline:{rules:[16,17],inclusive:!1},acc_descr:{rules:[14],inclusive:!1},acc_title:{rules:[12],inclusive:!1},arg_directive:{rules:[7,8],inclusive:!1},type_directive:{rules:[6,7],inclusive:!1},open_directive:{rules:[5],inclusive:!1},callback_args:{rules:[52,53],inclusive:!1},callback_name:{rules:[49,50,51],inclusive:!1},href:{rules:[46,47],inclusive:!1},struct:{rules:[23,24,25,26,27,28],inclusive:!1},generic:{rules:[37,38],inclusive:!1},bqstring:{rules:[43,44],inclusive:!1},string:{rules:[40,41],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,9,10,11,13,15,18,19,20,21,22,23,29,30,31,32,33,34,35,36,39,42,45,48,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80],inclusive:!0}}};function $(){this.yy={};}return Y.lexer=U,$.prototype=Y,Y.Parser=$,new $}();e.parser=r,e.Parser=r.Parser,e.parse=function(){return r.parse.apply(r,arguments)},e.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var r=n(8218).readFileSync(n(6470).normalize(t[1]),"utf8");return e.parser.parse(r)},n.c[n.s]===t&&e.main(process.argv.slice(1));},5890:(t,e,n)=>{t=n.nmd(t);var r=function(){var t=function(t,e,n,r){for(n=n||{},r=t.length;r--;n[t[r]]=e);return n},e=[1,2],n=[1,5],r=[6,9,11,23,25,27,29,30,49],i=[1,17],a=[1,18],o=[1,19],s=[1,20],c=[1,21],l=[1,24],u=[1,29],h=[1,30],f=[1,31],d=[1,32],p=[6,9,11,15,20,23,25,27,29,30,42,43,44,45,49],g=[1,45],y=[30,46,47],m=[4,6,9,11,23,25,27,29,30,49],b=[42,43,44,45],v=[22,37],_=[1,64],x={trace:function(){},yy:{},symbols_:{error:2,start:3,ER_DIAGRAM:4,document:5,EOF:6,directive:7,line:8,SPACE:9,statement:10,NEWLINE:11,openDirective:12,typeDirective:13,closeDirective:14,":":15,argDirective:16,entityName:17,relSpec:18,role:19,BLOCK_START:20,attributes:21,BLOCK_STOP:22,title:23,title_value:24,acc_title:25,acc_title_value:26,acc_descr:27,acc_descr_value:28,acc_descr_multiline_value:29,ALPHANUM:30,".":31,attribute:32,attributeType:33,attributeName:34,attributeKeyType:35,attributeComment:36,ATTRIBUTE_WORD:37,ATTRIBUTE_KEY:38,COMMENT:39,cardinality:40,relType:41,ZERO_OR_ONE:42,ZERO_OR_MORE:43,ONE_OR_MORE:44,ONLY_ONE:45,NON_IDENTIFYING:46,IDENTIFYING:47,WORD:48,open_directive:49,type_directive:50,arg_directive:51,close_directive:52,$accept:0,$end:1},terminals_:{2:"error",4:"ER_DIAGRAM",6:"EOF",9:"SPACE",11:"NEWLINE",15:":",20:"BLOCK_START",22:"BLOCK_STOP",23:"title",24:"title_value",25:"acc_title",26:"acc_title_value",27:"acc_descr",28:"acc_descr_value",29:"acc_descr_multiline_value",30:"ALPHANUM",31:".",37:"ATTRIBUTE_WORD",38:"ATTRIBUTE_KEY",39:"COMMENT",42:"ZERO_OR_ONE",43:"ZERO_OR_MORE",44:"ONE_OR_MORE",45:"ONLY_ONE",46:"NON_IDENTIFYING",47:"IDENTIFYING",48:"WORD",49:"open_directive",50:"type_directive",51:"arg_directive",52:"close_directive"},productions_:[0,[3,3],[3,2],[5,0],[5,2],[8,2],[8,1],[8,1],[8,1],[7,4],[7,6],[10,1],[10,5],[10,4],[10,3],[10,1],[10,2],[10,2],[10,2],[10,1],[17,1],[17,3],[21,1],[21,2],[32,2],[32,3],[32,3],[32,4],[33,1],[34,1],[35,1],[36,1],[18,3],[40,1],[40,1],[40,1],[40,1],[41,1],[41,1],[19,1],[19,1],[12,1],[13,1],[16,1],[14,1]],performAction:function(t,e,n,r,i,a,o){var s=a.length-1;switch(i){case 1:break;case 3:case 7:case 8:this.$=[];break;case 4:a[s-1].push(a[s]),this.$=a[s-1];break;case 5:case 6:case 20:case 28:case 29:case 30:case 40:this.$=a[s];break;case 12:r.addEntity(a[s-4]),r.addEntity(a[s-2]),r.addRelationship(a[s-4],a[s],a[s-2],a[s-3]);break;case 13:r.addEntity(a[s-3]),r.addAttributes(a[s-3],a[s-1]);break;case 14:r.addEntity(a[s-2]);break;case 15:r.addEntity(a[s]);break;case 16:case 17:this.$=a[s].trim(),r.setAccTitle(this.$);break;case 18:case 19:this.$=a[s].trim(),r.setAccDescription(this.$);break;case 21:this.$=a[s-2]+a[s-1]+a[s];break;case 22:this.$=[a[s]];break;case 23:a[s].push(a[s-1]),this.$=a[s];break;case 24:this.$={attributeType:a[s-1],attributeName:a[s]};break;case 25:this.$={attributeType:a[s-2],attributeName:a[s-1],attributeKeyType:a[s]};break;case 26:this.$={attributeType:a[s-2],attributeName:a[s-1],attributeComment:a[s]};break;case 27:this.$={attributeType:a[s-3],attributeName:a[s-2],attributeKeyType:a[s-1],attributeComment:a[s]};break;case 31:case 39:this.$=a[s].replace(/"/g,"");break;case 32:this.$={cardA:a[s],relType:a[s-1],cardB:a[s-2]};break;case 33:this.$=r.Cardinality.ZERO_OR_ONE;break;case 34:this.$=r.Cardinality.ZERO_OR_MORE;break;case 35:this.$=r.Cardinality.ONE_OR_MORE;break;case 36:this.$=r.Cardinality.ONLY_ONE;break;case 37:this.$=r.Identification.NON_IDENTIFYING;break;case 38:this.$=r.Identification.IDENTIFYING;break;case 41:r.parseDirective("%%{","open_directive");break;case 42:r.parseDirective(a[s],"type_directive");break;case 43:a[s]=a[s].trim().replace(/'/g,'"'),r.parseDirective(a[s],"arg_directive");break;case 44:r.parseDirective("}%%","close_directive","er");}},table:[{3:1,4:e,7:3,12:4,49:n},{1:[3]},t(r,[2,3],{5:6}),{3:7,4:e,7:3,12:4,49:n},{13:8,50:[1,9]},{50:[2,41]},{6:[1,10],7:15,8:11,9:[1,12],10:13,11:[1,14],12:4,17:16,23:i,25:a,27:o,29:s,30:c,49:n},{1:[2,2]},{14:22,15:[1,23],52:l},t([15,52],[2,42]),t(r,[2,8],{1:[2,1]}),t(r,[2,4]),{7:15,10:25,12:4,17:16,23:i,25:a,27:o,29:s,30:c,49:n},t(r,[2,6]),t(r,[2,7]),t(r,[2,11]),t(r,[2,15],{18:26,40:28,20:[1,27],42:u,43:h,44:f,45:d}),{24:[1,33]},{26:[1,34]},{28:[1,35]},t(r,[2,19]),t(p,[2,20],{31:[1,36]}),{11:[1,37]},{16:38,51:[1,39]},{11:[2,44]},t(r,[2,5]),{17:40,30:c},{21:41,22:[1,42],32:43,33:44,37:g},{41:46,46:[1,47],47:[1,48]},t(y,[2,33]),t(y,[2,34]),t(y,[2,35]),t(y,[2,36]),t(r,[2,16]),t(r,[2,17]),t(r,[2,18]),{17:49,30:c},t(m,[2,9]),{14:50,52:l},{52:[2,43]},{15:[1,51]},{22:[1,52]},t(r,[2,14]),{21:53,22:[2,22],32:43,33:44,37:g},{34:54,37:[1,55]},{37:[2,28]},{40:56,42:u,43:h,44:f,45:d},t(b,[2,37]),t(b,[2,38]),t(p,[2,21]),{11:[1,57]},{19:58,30:[1,60],48:[1,59]},t(r,[2,13]),{22:[2,23]},t(v,[2,24],{35:61,36:62,38:[1,63],39:_}),t([22,37,38,39],[2,29]),{30:[2,32]},t(m,[2,10]),t(r,[2,12]),t(r,[2,39]),t(r,[2,40]),t(v,[2,25],{36:65,39:_}),t(v,[2,26]),t([22,37,39],[2,30]),t(v,[2,31]),t(v,[2,27])],defaultActions:{5:[2,41],7:[2,2],24:[2,44],39:[2,43],45:[2,28],53:[2,23],56:[2,32]},parseError:function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t);},parse:function(t){var e=this,n=[0],r=[],i=[null],a=[],o=this.table,s="",c=0,l=0,u=0,h=2,f=1,d=a.slice.call(arguments,1),p=Object.create(this.lexer),g={yy:{}};for(var y in this.yy)Object.prototype.hasOwnProperty.call(this.yy,y)&&(g.yy[y]=this.yy[y]);p.setInput(t,g.yy),g.yy.lexer=p,g.yy.parser=this,void 0===p.yylloc&&(p.yylloc={});var m=p.yylloc;a.push(m);var b=p.options&&p.options.ranges;function v(){var t;return "number"!=typeof(t=r.pop()||p.lex()||f)&&(t instanceof Array&&(t=(r=t).pop()),t=e.symbols_[t]||t),t}"function"==typeof g.yy.parseError?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var _,x,k,w,T,E,C,S,A,M={};;){if(k=n[n.length-1],this.defaultActions[k]?w=this.defaultActions[k]:(null==_&&(_=v()),w=o[k]&&o[k][_]),void 0===w||!w.length||!w[0]){var N="";for(E in A=[],o[k])this.terminals_[E]&&E>h&&A.push("'"+this.terminals_[E]+"'");N=p.showPosition?"Parse error on line "+(c+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[_]||_)+"'":"Parse error on line "+(c+1)+": Unexpected "+(_==f?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(N,{text:p.match,token:this.terminals_[_]||_,line:p.yylineno,loc:m,expected:A});}if(w[0]instanceof Array&&w.length>1)throw new Error("Parse Error: multiple actions possible at state: "+k+", token: "+_);switch(w[0]){case 1:n.push(_),i.push(p.yytext),a.push(p.yylloc),n.push(w[1]),_=null,x?(_=x,x=null):(l=p.yyleng,s=p.yytext,c=p.yylineno,m=p.yylloc,u>0&&u--);break;case 2:if(C=this.productions_[w[1]][1],M.$=i[i.length-C],M._$={first_line:a[a.length-(C||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(C||1)].first_column,last_column:a[a.length-1].last_column},b&&(M._$.range=[a[a.length-(C||1)].range[0],a[a.length-1].range[1]]),void 0!==(T=this.performAction.apply(M,[s,l,c,g.yy,w[1],i,a].concat(d))))return T;C&&(n=n.slice(0,-1*C*2),i=i.slice(0,-1*C),a=a.slice(0,-1*C)),n.push(this.productions_[w[1]][0]),i.push(M.$),a.push(M._$),S=o[n[n.length-2]][n[n.length-1]],n.push(S);break;case 3:return !0}}return !0}},k={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e);},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t));},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return (t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var n,r,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(r=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in i)this[a]=i[a];return !1}return !1},next:function(){if(this.done)return this.EOF;var t,e,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),a=0;a<i.length;a++)if((n=this._input.match(this.rules[i[a]]))&&(!e||n[0].length>e[0].length)){if(e=n,r=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,i[a])))return t;if(this._backtrack){e=!1;continue}return !1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[r]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(t){this.conditionStack.push(t);},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return (t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t);},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,n,r){switch(n){case 0:return this.begin("acc_title"),25;case 1:return this.popState(),"acc_title_value";case 2:return this.begin("acc_descr"),27;case 3:return this.popState(),"acc_descr_value";case 4:this.begin("acc_descr_multiline");break;case 5:this.popState();break;case 6:return "acc_descr_multiline_value";case 7:return this.begin("open_directive"),49;case 8:return this.begin("type_directive"),50;case 9:return this.popState(),this.begin("arg_directive"),15;case 10:return this.popState(),this.popState(),52;case 11:return 51;case 12:case 13:case 15:case 20:case 25:break;case 14:return 11;case 16:return 9;case 17:return 48;case 18:return 4;case 19:return this.begin("block"),20;case 21:return 38;case 22:case 23:return 37;case 24:return 39;case 26:return this.popState(),22;case 27:case 40:return e.yytext[0];case 28:case 32:return 42;case 29:case 33:return 43;case 30:case 34:return 44;case 31:return 45;case 35:case 37:case 38:return 46;case 36:return 47;case 39:return 30;case 41:return 6}},rules:[/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:%%\{)/i,/^(?:((?:(?!\}%%)[^:.])*))/i,/^(?::)/i,/^(?:\}%%)/i,/^(?:((?:(?!\}%%).|\n)*))/i,/^(?:%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:[\s]+)/i,/^(?:"[^"]*")/i,/^(?:erDiagram\b)/i,/^(?:\{)/i,/^(?:\s+)/i,/^(?:\b((?:PK)|(?:FK))\b)/i,/^(?:(.*?)[~](.*?)*[~])/i,/^(?:[A-Za-z][A-Za-z0-9\-_\[\]]*)/i,/^(?:"[^"]*")/i,/^(?:[\n]+)/i,/^(?:\})/i,/^(?:.)/i,/^(?:\|o\b)/i,/^(?:\}o\b)/i,/^(?:\}\|)/i,/^(?:\|\|)/i,/^(?:o\|)/i,/^(?:o\{)/i,/^(?:\|\{)/i,/^(?:\.\.)/i,/^(?:--)/i,/^(?:\.-)/i,/^(?:-\.)/i,/^(?:[A-Za-z][A-Za-z0-9\-_]*)/i,/^(?:.)/i,/^(?:$)/i],conditions:{acc_descr_multiline:{rules:[5,6],inclusive:!1},acc_descr:{rules:[3],inclusive:!1},acc_title:{rules:[1],inclusive:!1},open_directive:{rules:[8],inclusive:!1},type_directive:{rules:[9,10],inclusive:!1},arg_directive:{rules:[10,11],inclusive:!1},block:{rules:[20,21,22,23,24,25,26,27],inclusive:!1},INITIAL:{rules:[0,2,4,7,12,13,14,15,16,17,18,19,28,29,30,31,32,33,34,35,36,37,38,39,40,41],inclusive:!0}}};function w(){this.yy={};}return x.lexer=k,w.prototype=x,x.Parser=w,new w}();e.parser=r,e.Parser=r.Parser,e.parse=function(){return r.parse.apply(r,arguments)},e.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var r=n(8009).readFileSync(n(6470).normalize(t[1]),"utf8");return e.parser.parse(r)},n.c[n.s]===t&&e.main(process.argv.slice(1));},3602:(t,e,n)=>{t=n.nmd(t);var r=function(){var t=function(t,e,n,r){for(n=n||{},r=t.length;r--;n[t[r]]=e);return n},e=[1,9],n=[1,7],r=[1,6],i=[1,8],a=[1,20,21,22,23,38,44,46,48,52,66,67,86,87,88,89,90,91,95,105,106,109,111,112,118,119,120,121,122,123,124,125,126,127],o=[2,10],s=[1,20],c=[1,21],l=[1,22],u=[1,23],h=[1,30],f=[1,32],d=[1,33],p=[1,34],g=[1,62],y=[1,48],m=[1,52],b=[1,36],v=[1,37],_=[1,38],x=[1,39],k=[1,40],w=[1,56],T=[1,63],E=[1,51],C=[1,53],S=[1,55],A=[1,59],M=[1,60],N=[1,41],O=[1,42],D=[1,43],B=[1,44],L=[1,61],I=[1,50],F=[1,54],R=[1,57],P=[1,58],j=[1,49],z=[1,66],Y=[1,71],U=[1,20,21,22,23,38,42,44,46,48,52,66,67,86,87,88,89,90,91,95,105,106,109,111,112,118,119,120,121,122,123,124,125,126,127],$=[1,75],W=[1,74],q=[1,76],H=[20,21,23,81,82],V=[1,99],G=[1,104],X=[1,107],Z=[1,108],Q=[1,101],K=[1,106],J=[1,109],tt=[1,102],et=[1,114],nt=[1,113],rt=[1,103],it=[1,105],at=[1,110],ot=[1,111],st=[1,112],ct=[1,115],lt=[20,21,22,23,81,82],ut=[20,21,22,23,53,81,82],ht=[20,21,22,23,40,52,53,55,57,59,61,63,65,66,67,69,71,73,74,76,81,82,91,95,105,106,109,111,112,122,123,124,125,126,127],ft=[20,21,23],dt=[20,21,23,52,66,67,81,82,91,95,105,106,109,111,112,122,123,124,125,126,127],pt=[1,12,20,21,22,23,24,38,42,44,46,48,52,66,67,86,87,88,89,90,91,95,105,106,109,111,112,118,119,120,121,122,123,124,125,126,127],gt=[52,66,67,91,95,105,106,109,111,112,122,123,124,125,126,127],yt=[1,149],mt=[1,157],bt=[1,158],vt=[1,159],_t=[1,160],xt=[1,144],kt=[1,145],wt=[1,141],Tt=[1,152],Et=[1,153],Ct=[1,154],St=[1,155],At=[1,156],Mt=[1,161],Nt=[1,162],Ot=[1,147],Dt=[1,150],Bt=[1,146],Lt=[1,143],It=[20,21,22,23,38,42,44,46,48,52,66,67,86,87,88,89,90,91,95,105,106,109,111,112,118,119,120,121,122,123,124,125,126,127],Ft=[1,165],Rt=[20,21,22,23,26,52,66,67,91,105,106,109,111,112,122,123,124,125,126,127],Pt=[20,21,22,23,24,26,38,40,41,42,52,56,58,60,62,64,66,67,68,70,72,73,75,77,81,82,86,87,88,89,90,91,92,95,105,106,109,111,112,113,114,122,123,124,125,126,127],jt=[12,21,22,24],zt=[22,106],Yt=[1,250],Ut=[1,245],$t=[1,246],Wt=[1,254],qt=[1,251],Ht=[1,248],Vt=[1,247],Gt=[1,249],Xt=[1,252],Zt=[1,253],Qt=[1,255],Kt=[1,273],Jt=[20,21,23,106],te=[20,21,22,23,66,67,86,102,105,106,109,110,111,112,113],ee={trace:function(){},yy:{},symbols_:{error:2,start:3,mermaidDoc:4,directive:5,openDirective:6,typeDirective:7,closeDirective:8,separator:9,":":10,argDirective:11,open_directive:12,type_directive:13,arg_directive:14,close_directive:15,graphConfig:16,document:17,line:18,statement:19,SEMI:20,NEWLINE:21,SPACE:22,EOF:23,GRAPH:24,NODIR:25,DIR:26,FirstStmtSeperator:27,ending:28,endToken:29,spaceList:30,spaceListNewline:31,verticeStatement:32,styleStatement:33,linkStyleStatement:34,classDefStatement:35,classStatement:36,clickStatement:37,subgraph:38,text:39,SQS:40,SQE:41,end:42,direction:43,acc_title:44,acc_title_value:45,acc_descr:46,acc_descr_value:47,acc_descr_multiline_value:48,link:49,node:50,vertex:51,AMP:52,STYLE_SEPARATOR:53,idString:54,DOUBLECIRCLESTART:55,DOUBLECIRCLEEND:56,PS:57,PE:58,"(-":59,"-)":60,STADIUMSTART:61,STADIUMEND:62,SUBROUTINESTART:63,SUBROUTINEEND:64,VERTEX_WITH_PROPS_START:65,ALPHA:66,COLON:67,PIPE:68,CYLINDERSTART:69,CYLINDEREND:70,DIAMOND_START:71,DIAMOND_STOP:72,TAGEND:73,TRAPSTART:74,TRAPEND:75,INVTRAPSTART:76,INVTRAPEND:77,linkStatement:78,arrowText:79,TESTSTR:80,START_LINK:81,LINK:82,textToken:83,STR:84,keywords:85,STYLE:86,LINKSTYLE:87,CLASSDEF:88,CLASS:89,CLICK:90,DOWN:91,UP:92,textNoTags:93,textNoTagsToken:94,DEFAULT:95,stylesOpt:96,alphaNum:97,CALLBACKNAME:98,CALLBACKARGS:99,HREF:100,LINK_TARGET:101,HEX:102,numList:103,INTERPOLATE:104,NUM:105,COMMA:106,style:107,styleComponent:108,MINUS:109,UNIT:110,BRKT:111,DOT:112,PCT:113,TAGSTART:114,alphaNumToken:115,idStringToken:116,alphaNumStatement:117,direction_tb:118,direction_bt:119,direction_rl:120,direction_lr:121,PUNCTUATION:122,UNICODE_TEXT:123,PLUS:124,EQUALS:125,MULT:126,UNDERSCORE:127,graphCodeTokens:128,ARROW_CROSS:129,ARROW_POINT:130,ARROW_CIRCLE:131,ARROW_OPEN:132,QUOTE:133,$accept:0,$end:1},terminals_:{2:"error",10:":",12:"open_directive",13:"type_directive",14:"arg_directive",15:"close_directive",20:"SEMI",21:"NEWLINE",22:"SPACE",23:"EOF",24:"GRAPH",25:"NODIR",26:"DIR",38:"subgraph",40:"SQS",41:"SQE",42:"end",44:"acc_title",45:"acc_title_value",46:"acc_descr",47:"acc_descr_value",48:"acc_descr_multiline_value",52:"AMP",53:"STYLE_SEPARATOR",55:"DOUBLECIRCLESTART",56:"DOUBLECIRCLEEND",57:"PS",58:"PE",59:"(-",60:"-)",61:"STADIUMSTART",62:"STADIUMEND",63:"SUBROUTINESTART",64:"SUBROUTINEEND",65:"VERTEX_WITH_PROPS_START",66:"ALPHA",67:"COLON",68:"PIPE",69:"CYLINDERSTART",70:"CYLINDEREND",71:"DIAMOND_START",72:"DIAMOND_STOP",73:"TAGEND",74:"TRAPSTART",75:"TRAPEND",76:"INVTRAPSTART",77:"INVTRAPEND",80:"TESTSTR",81:"START_LINK",82:"LINK",84:"STR",86:"STYLE",87:"LINKSTYLE",88:"CLASSDEF",89:"CLASS",90:"CLICK",91:"DOWN",92:"UP",95:"DEFAULT",98:"CALLBACKNAME",99:"CALLBACKARGS",100:"HREF",101:"LINK_TARGET",102:"HEX",104:"INTERPOLATE",105:"NUM",106:"COMMA",109:"MINUS",110:"UNIT",111:"BRKT",112:"DOT",113:"PCT",114:"TAGSTART",118:"direction_tb",119:"direction_bt",120:"direction_rl",121:"direction_lr",122:"PUNCTUATION",123:"UNICODE_TEXT",124:"PLUS",125:"EQUALS",126:"MULT",127:"UNDERSCORE",129:"ARROW_CROSS",130:"ARROW_POINT",131:"ARROW_CIRCLE",132:"ARROW_OPEN",133:"QUOTE"},productions_:[0,[3,1],[3,2],[5,4],[5,6],[6,1],[7,1],[11,1],[8,1],[4,2],[17,0],[17,2],[18,1],[18,1],[18,1],[18,1],[18,1],[16,2],[16,2],[16,2],[16,3],[28,2],[28,1],[29,1],[29,1],[29,1],[27,1],[27,1],[27,2],[31,2],[31,2],[31,1],[31,1],[30,2],[30,1],[19,2],[19,2],[19,2],[19,2],[19,2],[19,2],[19,9],[19,6],[19,4],[19,1],[19,2],[19,2],[19,1],[9,1],[9,1],[9,1],[32,3],[32,4],[32,2],[32,1],[50,1],[50,5],[50,3],[51,4],[51,4],[51,6],[51,4],[51,4],[51,4],[51,8],[51,4],[51,4],[51,4],[51,6],[51,4],[51,4],[51,4],[51,4],[51,4],[51,1],[49,2],[49,3],[49,3],[49,1],[49,3],[78,1],[79,3],[39,1],[39,2],[39,1],[85,1],[85,1],[85,1],[85,1],[85,1],[85,1],[85,1],[85,1],[85,1],[85,1],[85,1],[93,1],[93,2],[35,5],[35,5],[36,5],[37,2],[37,4],[37,3],[37,5],[37,2],[37,4],[37,4],[37,6],[37,2],[37,4],[37,2],[37,4],[37,4],[37,6],[33,5],[33,5],[34,5],[34,5],[34,9],[34,9],[34,7],[34,7],[103,1],[103,3],[96,1],[96,3],[107,1],[107,2],[108,1],[108,1],[108,1],[108,1],[108,1],[108,1],[108,1],[108,1],[108,1],[108,1],[108,1],[83,1],[83,1],[83,1],[83,1],[83,1],[83,1],[94,1],[94,1],[94,1],[94,1],[54,1],[54,2],[97,1],[97,2],[117,1],[117,1],[117,1],[117,1],[43,1],[43,1],[43,1],[43,1],[115,1],[115,1],[115,1],[115,1],[115,1],[115,1],[115,1],[115,1],[115,1],[115,1],[115,1],[115,1],[115,1],[116,1],[116,1],[116,1],[116,1],[116,1],[116,1],[116,1],[116,1],[116,1],[116,1],[116,1],[116,1],[116,1],[116,1],[116,1],[116,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1],[128,1]],performAction:function(t,e,n,r,i,a,o){var s=a.length-1;switch(i){case 5:r.parseDirective("%%{","open_directive");break;case 6:r.parseDirective(a[s],"type_directive");break;case 7:a[s]=a[s].trim().replace(/'/g,'"'),r.parseDirective(a[s],"arg_directive");break;case 8:r.parseDirective("}%%","close_directive","flowchart");break;case 10:case 36:case 37:case 38:case 39:case 40:this.$=[];break;case 11:a[s]!==[]&&a[s-1].push(a[s]),this.$=a[s-1];break;case 12:case 82:case 84:case 96:case 152:case 154:case 155:case 78:case 150:this.$=a[s];break;case 19:r.setDirection("TB"),this.$="TB";break;case 20:r.setDirection(a[s-1]),this.$=a[s-1];break;case 35:this.$=a[s-1].nodes;break;case 41:this.$=r.addSubGraph(a[s-6],a[s-1],a[s-4]);break;case 42:this.$=r.addSubGraph(a[s-3],a[s-1],a[s-3]);break;case 43:this.$=r.addSubGraph(void 0,a[s-1],void 0);break;case 45:this.$=a[s].trim(),r.setAccTitle(this.$);break;case 46:case 47:this.$=a[s].trim(),r.setAccDescription(this.$);break;case 51:r.addLink(a[s-2].stmt,a[s],a[s-1]),this.$={stmt:a[s],nodes:a[s].concat(a[s-2].nodes)};break;case 52:r.addLink(a[s-3].stmt,a[s-1],a[s-2]),this.$={stmt:a[s-1],nodes:a[s-1].concat(a[s-3].nodes)};break;case 53:this.$={stmt:a[s-1],nodes:a[s-1]};break;case 54:this.$={stmt:a[s],nodes:a[s]};break;case 55:case 123:case 125:this.$=[a[s]];break;case 56:this.$=a[s-4].concat(a[s]);break;case 57:this.$=[a[s-2]],r.setClass(a[s-2],a[s]);break;case 58:this.$=a[s-3],r.addVertex(a[s-3],a[s-1],"square");break;case 59:this.$=a[s-3],r.addVertex(a[s-3],a[s-1],"doublecircle");break;case 60:this.$=a[s-5],r.addVertex(a[s-5],a[s-2],"circle");break;case 61:this.$=a[s-3],r.addVertex(a[s-3],a[s-1],"ellipse");break;case 62:this.$=a[s-3],r.addVertex(a[s-3],a[s-1],"stadium");break;case 63:this.$=a[s-3],r.addVertex(a[s-3],a[s-1],"subroutine");break;case 64:this.$=a[s-7],r.addVertex(a[s-7],a[s-1],"rect",void 0,void 0,void 0,Object.fromEntries([[a[s-5],a[s-3]]]));break;case 65:this.$=a[s-3],r.addVertex(a[s-3],a[s-1],"cylinder");break;case 66:this.$=a[s-3],r.addVertex(a[s-3],a[s-1],"round");break;case 67:this.$=a[s-3],r.addVertex(a[s-3],a[s-1],"diamond");break;case 68:this.$=a[s-5],r.addVertex(a[s-5],a[s-2],"hexagon");break;case 69:this.$=a[s-3],r.addVertex(a[s-3],a[s-1],"odd");break;case 70:this.$=a[s-3],r.addVertex(a[s-3],a[s-1],"trapezoid");break;case 71:this.$=a[s-3],r.addVertex(a[s-3],a[s-1],"inv_trapezoid");break;case 72:this.$=a[s-3],r.addVertex(a[s-3],a[s-1],"lean_right");break;case 73:this.$=a[s-3],r.addVertex(a[s-3],a[s-1],"lean_left");break;case 74:this.$=a[s],r.addVertex(a[s]);break;case 75:a[s-1].text=a[s],this.$=a[s-1];break;case 76:case 77:a[s-2].text=a[s-1],this.$=a[s-2];break;case 79:var c=r.destructLink(a[s],a[s-2]);this.$={type:c.type,stroke:c.stroke,length:c.length,text:a[s-1]};break;case 80:c=r.destructLink(a[s]),this.$={type:c.type,stroke:c.stroke,length:c.length};break;case 81:this.$=a[s-1];break;case 83:case 97:case 153:case 151:this.$=a[s-1]+""+a[s];break;case 98:case 99:this.$=a[s-4],r.addClass(a[s-2],a[s]);break;case 100:this.$=a[s-4],r.setClass(a[s-2],a[s]);break;case 101:case 109:this.$=a[s-1],r.setClickEvent(a[s-1],a[s]);break;case 102:case 110:this.$=a[s-3],r.setClickEvent(a[s-3],a[s-2]),r.setTooltip(a[s-3],a[s]);break;case 103:this.$=a[s-2],r.setClickEvent(a[s-2],a[s-1],a[s]);break;case 104:this.$=a[s-4],r.setClickEvent(a[s-4],a[s-3],a[s-2]),r.setTooltip(a[s-4],a[s]);break;case 105:case 111:this.$=a[s-1],r.setLink(a[s-1],a[s]);break;case 106:case 112:this.$=a[s-3],r.setLink(a[s-3],a[s-2]),r.setTooltip(a[s-3],a[s]);break;case 107:case 113:this.$=a[s-3],r.setLink(a[s-3],a[s-2],a[s]);break;case 108:case 114:this.$=a[s-5],r.setLink(a[s-5],a[s-4],a[s]),r.setTooltip(a[s-5],a[s-2]);break;case 115:this.$=a[s-4],r.addVertex(a[s-2],void 0,void 0,a[s]);break;case 116:case 118:this.$=a[s-4],r.updateLink(a[s-2],a[s]);break;case 117:this.$=a[s-4],r.updateLink([a[s-2]],a[s]);break;case 119:this.$=a[s-8],r.updateLinkInterpolate([a[s-6]],a[s-2]),r.updateLink([a[s-6]],a[s]);break;case 120:this.$=a[s-8],r.updateLinkInterpolate(a[s-6],a[s-2]),r.updateLink(a[s-6],a[s]);break;case 121:this.$=a[s-6],r.updateLinkInterpolate([a[s-4]],a[s]);break;case 122:this.$=a[s-6],r.updateLinkInterpolate(a[s-4],a[s]);break;case 124:case 126:a[s-2].push(a[s]),this.$=a[s-2];break;case 128:this.$=a[s-1]+a[s];break;case 156:this.$="v";break;case 157:this.$="-";break;case 158:this.$={stmt:"dir",value:"TB"};break;case 159:this.$={stmt:"dir",value:"BT"};break;case 160:this.$={stmt:"dir",value:"RL"};break;case 161:this.$={stmt:"dir",value:"LR"};}},table:[{3:1,4:2,5:3,6:5,12:e,16:4,21:n,22:r,24:i},{1:[3]},{1:[2,1]},{3:10,4:2,5:3,6:5,12:e,16:4,21:n,22:r,24:i},t(a,o,{17:11}),{7:12,13:[1,13]},{16:14,21:n,22:r,24:i},{16:15,21:n,22:r,24:i},{25:[1,16],26:[1,17]},{13:[2,5]},{1:[2,2]},{1:[2,9],18:18,19:19,20:s,21:c,22:l,23:u,32:24,33:25,34:26,35:27,36:28,37:29,38:h,43:31,44:f,46:d,48:p,50:35,51:45,52:g,54:46,66:y,67:m,86:b,87:v,88:_,89:x,90:k,91:w,95:T,105:E,106:C,109:S,111:A,112:M,116:47,118:N,119:O,120:D,121:B,122:L,123:I,124:F,125:R,126:P,127:j},{8:64,10:[1,65],15:z},t([10,15],[2,6]),t(a,[2,17]),t(a,[2,18]),t(a,[2,19]),{20:[1,68],21:[1,69],22:Y,27:67,30:70},t(U,[2,11]),t(U,[2,12]),t(U,[2,13]),t(U,[2,14]),t(U,[2,15]),t(U,[2,16]),{9:72,20:$,21:W,23:q,49:73,78:77,81:[1,78],82:[1,79]},{9:80,20:$,21:W,23:q},{9:81,20:$,21:W,23:q},{9:82,20:$,21:W,23:q},{9:83,20:$,21:W,23:q},{9:84,20:$,21:W,23:q},{9:86,20:$,21:W,22:[1,85],23:q},t(U,[2,44]),{45:[1,87]},{47:[1,88]},t(U,[2,47]),t(H,[2,54],{30:89,22:Y}),{22:[1,90]},{22:[1,91]},{22:[1,92]},{22:[1,93]},{26:V,52:G,66:X,67:Z,84:[1,97],91:Q,97:96,98:[1,94],100:[1,95],105:K,106:J,109:tt,111:et,112:nt,115:100,117:98,122:rt,123:it,124:at,125:ot,126:st,127:ct},t(U,[2,158]),t(U,[2,159]),t(U,[2,160]),t(U,[2,161]),t(lt,[2,55],{53:[1,116]}),t(ut,[2,74],{116:129,40:[1,117],52:g,55:[1,118],57:[1,119],59:[1,120],61:[1,121],63:[1,122],65:[1,123],66:y,67:m,69:[1,124],71:[1,125],73:[1,126],74:[1,127],76:[1,128],91:w,95:T,105:E,106:C,109:S,111:A,112:M,122:L,123:I,124:F,125:R,126:P,127:j}),t(ht,[2,150]),t(ht,[2,175]),t(ht,[2,176]),t(ht,[2,177]),t(ht,[2,178]),t(ht,[2,179]),t(ht,[2,180]),t(ht,[2,181]),t(ht,[2,182]),t(ht,[2,183]),t(ht,[2,184]),t(ht,[2,185]),t(ht,[2,186]),t(ht,[2,187]),t(ht,[2,188]),t(ht,[2,189]),t(ht,[2,190]),{9:130,20:$,21:W,23:q},{11:131,14:[1,132]},t(ft,[2,8]),t(a,[2,20]),t(a,[2,26]),t(a,[2,27]),{21:[1,133]},t(dt,[2,34],{30:134,22:Y}),t(U,[2,35]),{50:135,51:45,52:g,54:46,66:y,67:m,91:w,95:T,105:E,106:C,109:S,111:A,112:M,116:47,122:L,123:I,124:F,125:R,126:P,127:j},t(pt,[2,48]),t(pt,[2,49]),t(pt,[2,50]),t(gt,[2,78],{79:136,68:[1,138],80:[1,137]}),{22:yt,24:mt,26:bt,38:vt,39:139,42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:140,84:wt,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},t([52,66,67,68,80,91,95,105,106,109,111,112,122,123,124,125,126,127],[2,80]),t(U,[2,36]),t(U,[2,37]),t(U,[2,38]),t(U,[2,39]),t(U,[2,40]),{22:yt,24:mt,26:bt,38:vt,39:163,42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:140,84:wt,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},t(It,o,{17:164}),t(U,[2,45]),t(U,[2,46]),t(H,[2,53],{52:Ft}),{26:V,52:G,66:X,67:Z,91:Q,97:166,102:[1,167],105:K,106:J,109:tt,111:et,112:nt,115:100,117:98,122:rt,123:it,124:at,125:ot,126:st,127:ct},{95:[1,168],103:169,105:[1,170]},{26:V,52:G,66:X,67:Z,91:Q,95:[1,171],97:172,105:K,106:J,109:tt,111:et,112:nt,115:100,117:98,122:rt,123:it,124:at,125:ot,126:st,127:ct},{26:V,52:G,66:X,67:Z,91:Q,97:173,105:K,106:J,109:tt,111:et,112:nt,115:100,117:98,122:rt,123:it,124:at,125:ot,126:st,127:ct},t(ft,[2,101],{22:[1,174],99:[1,175]}),t(ft,[2,105],{22:[1,176]}),t(ft,[2,109],{115:100,117:178,22:[1,177],26:V,52:G,66:X,67:Z,91:Q,105:K,106:J,109:tt,111:et,112:nt,122:rt,123:it,124:at,125:ot,126:st,127:ct}),t(ft,[2,111],{22:[1,179]}),t(Rt,[2,152]),t(Rt,[2,154]),t(Rt,[2,155]),t(Rt,[2,156]),t(Rt,[2,157]),t(Pt,[2,162]),t(Pt,[2,163]),t(Pt,[2,164]),t(Pt,[2,165]),t(Pt,[2,166]),t(Pt,[2,167]),t(Pt,[2,168]),t(Pt,[2,169]),t(Pt,[2,170]),t(Pt,[2,171]),t(Pt,[2,172]),t(Pt,[2,173]),t(Pt,[2,174]),{52:g,54:180,66:y,67:m,91:w,95:T,105:E,106:C,109:S,111:A,112:M,116:47,122:L,123:I,124:F,125:R,126:P,127:j},{22:yt,24:mt,26:bt,38:vt,39:181,42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:140,84:wt,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,39:182,42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:140,84:wt,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,39:184,42:_t,52:G,57:[1,183],66:X,67:Z,73:xt,81:kt,83:140,84:wt,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,39:185,42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:140,84:wt,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,39:186,42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:140,84:wt,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,39:187,42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:140,84:wt,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{66:[1,188]},{22:yt,24:mt,26:bt,38:vt,39:189,42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:140,84:wt,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,39:190,42:_t,52:G,66:X,67:Z,71:[1,191],73:xt,81:kt,83:140,84:wt,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,39:192,42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:140,84:wt,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,39:193,42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:140,84:wt,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,39:194,42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:140,84:wt,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},t(ht,[2,151]),t(jt,[2,3]),{8:195,15:z},{15:[2,7]},t(a,[2,28]),t(dt,[2,33]),t(H,[2,51],{30:196,22:Y}),t(gt,[2,75],{22:[1,197]}),{22:[1,198]},{22:yt,24:mt,26:bt,38:vt,39:199,42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:140,84:wt,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,42:_t,52:G,66:X,67:Z,73:xt,81:kt,82:[1,200],83:201,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},t(Pt,[2,82]),t(Pt,[2,84]),t(Pt,[2,140]),t(Pt,[2,141]),t(Pt,[2,142]),t(Pt,[2,143]),t(Pt,[2,144]),t(Pt,[2,145]),t(Pt,[2,146]),t(Pt,[2,147]),t(Pt,[2,148]),t(Pt,[2,149]),t(Pt,[2,85]),t(Pt,[2,86]),t(Pt,[2,87]),t(Pt,[2,88]),t(Pt,[2,89]),t(Pt,[2,90]),t(Pt,[2,91]),t(Pt,[2,92]),t(Pt,[2,93]),t(Pt,[2,94]),t(Pt,[2,95]),{9:203,20:$,21:W,22:yt,23:q,24:mt,26:bt,38:vt,40:[1,202],42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:201,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{18:18,19:19,20:s,21:c,22:l,23:u,32:24,33:25,34:26,35:27,36:28,37:29,38:h,42:[1,204],43:31,44:f,46:d,48:p,50:35,51:45,52:g,54:46,66:y,67:m,86:b,87:v,88:_,89:x,90:k,91:w,95:T,105:E,106:C,109:S,111:A,112:M,116:47,118:N,119:O,120:D,121:B,122:L,123:I,124:F,125:R,126:P,127:j},{22:Y,30:205},{22:[1,206],26:V,52:G,66:X,67:Z,91:Q,105:K,106:J,109:tt,111:et,112:nt,115:100,117:178,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:[1,207]},{22:[1,208]},{22:[1,209],106:[1,210]},t(zt,[2,123]),{22:[1,211]},{22:[1,212],26:V,52:G,66:X,67:Z,91:Q,105:K,106:J,109:tt,111:et,112:nt,115:100,117:178,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:[1,213],26:V,52:G,66:X,67:Z,91:Q,105:K,106:J,109:tt,111:et,112:nt,115:100,117:178,122:rt,123:it,124:at,125:ot,126:st,127:ct},{84:[1,214]},t(ft,[2,103],{22:[1,215]}),{84:[1,216],101:[1,217]},{84:[1,218]},t(Rt,[2,153]),{84:[1,219],101:[1,220]},t(lt,[2,57],{116:129,52:g,66:y,67:m,91:w,95:T,105:E,106:C,109:S,111:A,112:M,122:L,123:I,124:F,125:R,126:P,127:j}),{22:yt,24:mt,26:bt,38:vt,41:[1,221],42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:201,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,42:_t,52:G,56:[1,222],66:X,67:Z,73:xt,81:kt,83:201,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,39:223,42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:140,84:wt,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,42:_t,52:G,58:[1,224],66:X,67:Z,73:xt,81:kt,83:201,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,42:_t,52:G,60:[1,225],66:X,67:Z,73:xt,81:kt,83:201,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,42:_t,52:G,62:[1,226],66:X,67:Z,73:xt,81:kt,83:201,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,42:_t,52:G,64:[1,227],66:X,67:Z,73:xt,81:kt,83:201,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{67:[1,228]},{22:yt,24:mt,26:bt,38:vt,42:_t,52:G,66:X,67:Z,70:[1,229],73:xt,81:kt,83:201,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,42:_t,52:G,66:X,67:Z,72:[1,230],73:xt,81:kt,83:201,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,39:231,42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:140,84:wt,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,41:[1,232],42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:201,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,42:_t,52:G,66:X,67:Z,73:xt,75:[1,233],77:[1,234],81:kt,83:201,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{22:yt,24:mt,26:bt,38:vt,42:_t,52:G,66:X,67:Z,73:xt,75:[1,236],77:[1,235],81:kt,83:201,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{9:237,20:$,21:W,23:q},t(H,[2,52],{52:Ft}),t(gt,[2,77]),t(gt,[2,76]),{22:yt,24:mt,26:bt,38:vt,42:_t,52:G,66:X,67:Z,68:[1,238],73:xt,81:kt,83:201,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},t(gt,[2,79]),t(Pt,[2,83]),{22:yt,24:mt,26:bt,38:vt,39:239,42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:140,84:wt,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},t(It,o,{17:240}),t(U,[2,43]),{51:241,52:g,54:46,66:y,67:m,91:w,95:T,105:E,106:C,109:S,111:A,112:M,116:47,122:L,123:I,124:F,125:R,126:P,127:j},{22:Yt,66:Ut,67:$t,86:Wt,96:242,102:qt,105:Ht,107:243,108:244,109:Vt,110:Gt,111:Xt,112:Zt,113:Qt},{22:Yt,66:Ut,67:$t,86:Wt,96:256,102:qt,105:Ht,107:243,108:244,109:Vt,110:Gt,111:Xt,112:Zt,113:Qt},{22:Yt,66:Ut,67:$t,86:Wt,96:257,102:qt,104:[1,258],105:Ht,107:243,108:244,109:Vt,110:Gt,111:Xt,112:Zt,113:Qt},{22:Yt,66:Ut,67:$t,86:Wt,96:259,102:qt,104:[1,260],105:Ht,107:243,108:244,109:Vt,110:Gt,111:Xt,112:Zt,113:Qt},{105:[1,261]},{22:Yt,66:Ut,67:$t,86:Wt,96:262,102:qt,105:Ht,107:243,108:244,109:Vt,110:Gt,111:Xt,112:Zt,113:Qt},{22:Yt,66:Ut,67:$t,86:Wt,96:263,102:qt,105:Ht,107:243,108:244,109:Vt,110:Gt,111:Xt,112:Zt,113:Qt},{26:V,52:G,66:X,67:Z,91:Q,97:264,105:K,106:J,109:tt,111:et,112:nt,115:100,117:98,122:rt,123:it,124:at,125:ot,126:st,127:ct},t(ft,[2,102]),{84:[1,265]},t(ft,[2,106],{22:[1,266]}),t(ft,[2,107]),t(ft,[2,110]),t(ft,[2,112],{22:[1,267]}),t(ft,[2,113]),t(ut,[2,58]),t(ut,[2,59]),{22:yt,24:mt,26:bt,38:vt,42:_t,52:G,58:[1,268],66:X,67:Z,73:xt,81:kt,83:201,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},t(ut,[2,66]),t(ut,[2,61]),t(ut,[2,62]),t(ut,[2,63]),{66:[1,269]},t(ut,[2,65]),t(ut,[2,67]),{22:yt,24:mt,26:bt,38:vt,42:_t,52:G,66:X,67:Z,72:[1,270],73:xt,81:kt,83:201,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},t(ut,[2,69]),t(ut,[2,70]),t(ut,[2,72]),t(ut,[2,71]),t(ut,[2,73]),t(jt,[2,4]),t([22,52,66,67,91,95,105,106,109,111,112,122,123,124,125,126,127],[2,81]),{22:yt,24:mt,26:bt,38:vt,41:[1,271],42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:201,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{18:18,19:19,20:s,21:c,22:l,23:u,32:24,33:25,34:26,35:27,36:28,37:29,38:h,42:[1,272],43:31,44:f,46:d,48:p,50:35,51:45,52:g,54:46,66:y,67:m,86:b,87:v,88:_,89:x,90:k,91:w,95:T,105:E,106:C,109:S,111:A,112:M,116:47,118:N,119:O,120:D,121:B,122:L,123:I,124:F,125:R,126:P,127:j},t(lt,[2,56]),t(ft,[2,115],{106:Kt}),t(Jt,[2,125],{108:274,22:Yt,66:Ut,67:$t,86:Wt,102:qt,105:Ht,109:Vt,110:Gt,111:Xt,112:Zt,113:Qt}),t(te,[2,127]),t(te,[2,129]),t(te,[2,130]),t(te,[2,131]),t(te,[2,132]),t(te,[2,133]),t(te,[2,134]),t(te,[2,135]),t(te,[2,136]),t(te,[2,137]),t(te,[2,138]),t(te,[2,139]),t(ft,[2,116],{106:Kt}),t(ft,[2,117],{106:Kt}),{22:[1,275]},t(ft,[2,118],{106:Kt}),{22:[1,276]},t(zt,[2,124]),t(ft,[2,98],{106:Kt}),t(ft,[2,99],{106:Kt}),t(ft,[2,100],{115:100,117:178,26:V,52:G,66:X,67:Z,91:Q,105:K,106:J,109:tt,111:et,112:nt,122:rt,123:it,124:at,125:ot,126:st,127:ct}),t(ft,[2,104]),{101:[1,277]},{101:[1,278]},{58:[1,279]},{68:[1,280]},{72:[1,281]},{9:282,20:$,21:W,23:q},t(U,[2,42]),{22:Yt,66:Ut,67:$t,86:Wt,102:qt,105:Ht,107:283,108:244,109:Vt,110:Gt,111:Xt,112:Zt,113:Qt},t(te,[2,128]),{26:V,52:G,66:X,67:Z,91:Q,97:284,105:K,106:J,109:tt,111:et,112:nt,115:100,117:98,122:rt,123:it,124:at,125:ot,126:st,127:ct},{26:V,52:G,66:X,67:Z,91:Q,97:285,105:K,106:J,109:tt,111:et,112:nt,115:100,117:98,122:rt,123:it,124:at,125:ot,126:st,127:ct},t(ft,[2,108]),t(ft,[2,114]),t(ut,[2,60]),{22:yt,24:mt,26:bt,38:vt,39:286,42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:140,84:wt,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},t(ut,[2,68]),t(It,o,{17:287}),t(Jt,[2,126],{108:274,22:Yt,66:Ut,67:$t,86:Wt,102:qt,105:Ht,109:Vt,110:Gt,111:Xt,112:Zt,113:Qt}),t(ft,[2,121],{115:100,117:178,22:[1,288],26:V,52:G,66:X,67:Z,91:Q,105:K,106:J,109:tt,111:et,112:nt,122:rt,123:it,124:at,125:ot,126:st,127:ct}),t(ft,[2,122],{115:100,117:178,22:[1,289],26:V,52:G,66:X,67:Z,91:Q,105:K,106:J,109:tt,111:et,112:nt,122:rt,123:it,124:at,125:ot,126:st,127:ct}),{22:yt,24:mt,26:bt,38:vt,41:[1,290],42:_t,52:G,66:X,67:Z,73:xt,81:kt,83:201,85:151,86:Tt,87:Et,88:Ct,89:St,90:At,91:Mt,92:Nt,94:142,95:Ot,105:K,106:J,109:Dt,111:et,112:nt,113:Bt,114:Lt,115:148,122:rt,123:it,124:at,125:ot,126:st,127:ct},{18:18,19:19,20:s,21:c,22:l,23:u,32:24,33:25,34:26,35:27,36:28,37:29,38:h,42:[1,291],43:31,44:f,46:d,48:p,50:35,51:45,52:g,54:46,66:y,67:m,86:b,87:v,88:_,89:x,90:k,91:w,95:T,105:E,106:C,109:S,111:A,112:M,116:47,118:N,119:O,120:D,121:B,122:L,123:I,124:F,125:R,126:P,127:j},{22:Yt,66:Ut,67:$t,86:Wt,96:292,102:qt,105:Ht,107:243,108:244,109:Vt,110:Gt,111:Xt,112:Zt,113:Qt},{22:Yt,66:Ut,67:$t,86:Wt,96:293,102:qt,105:Ht,107:243,108:244,109:Vt,110:Gt,111:Xt,112:Zt,113:Qt},t(ut,[2,64]),t(U,[2,41]),t(ft,[2,119],{106:Kt}),t(ft,[2,120],{106:Kt})],defaultActions:{2:[2,1],9:[2,5],10:[2,2],132:[2,7]},parseError:function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t);},parse:function(t){var e=this,n=[0],r=[],i=[null],a=[],o=this.table,s="",c=0,l=0,u=0,h=2,f=1,d=a.slice.call(arguments,1),p=Object.create(this.lexer),g={yy:{}};for(var y in this.yy)Object.prototype.hasOwnProperty.call(this.yy,y)&&(g.yy[y]=this.yy[y]);p.setInput(t,g.yy),g.yy.lexer=p,g.yy.parser=this,void 0===p.yylloc&&(p.yylloc={});var m=p.yylloc;a.push(m);var b=p.options&&p.options.ranges;function v(){var t;return "number"!=typeof(t=r.pop()||p.lex()||f)&&(t instanceof Array&&(t=(r=t).pop()),t=e.symbols_[t]||t),t}"function"==typeof g.yy.parseError?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var _,x,k,w,T,E,C,S,A,M={};;){if(k=n[n.length-1],this.defaultActions[k]?w=this.defaultActions[k]:(null==_&&(_=v()),w=o[k]&&o[k][_]),void 0===w||!w.length||!w[0]){var N="";for(E in A=[],o[k])this.terminals_[E]&&E>h&&A.push("'"+this.terminals_[E]+"'");N=p.showPosition?"Parse error on line "+(c+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[_]||_)+"'":"Parse error on line "+(c+1)+": Unexpected "+(_==f?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(N,{text:p.match,token:this.terminals_[_]||_,line:p.yylineno,loc:m,expected:A});}if(w[0]instanceof Array&&w.length>1)throw new Error("Parse Error: multiple actions possible at state: "+k+", token: "+_);switch(w[0]){case 1:n.push(_),i.push(p.yytext),a.push(p.yylloc),n.push(w[1]),_=null,x?(_=x,x=null):(l=p.yyleng,s=p.yytext,c=p.yylineno,m=p.yylloc,u>0&&u--);break;case 2:if(C=this.productions_[w[1]][1],M.$=i[i.length-C],M._$={first_line:a[a.length-(C||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(C||1)].first_column,last_column:a[a.length-1].last_column},b&&(M._$.range=[a[a.length-(C||1)].range[0],a[a.length-1].range[1]]),void 0!==(T=this.performAction.apply(M,[s,l,c,g.yy,w[1],i,a].concat(d))))return T;C&&(n=n.slice(0,-1*C*2),i=i.slice(0,-1*C),a=a.slice(0,-1*C)),n.push(this.productions_[w[1]][0]),i.push(M.$),a.push(M._$),S=o[n[n.length-2]][n[n.length-1]],n.push(S);break;case 3:return !0}}return !0}},ne={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e);},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t));},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return (t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var n,r,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(r=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in i)this[a]=i[a];return !1}return !1},next:function(){if(this.done)return this.EOF;var t,e,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),a=0;a<i.length;a++)if((n=this._input.match(this.rules[i[a]]))&&(!e||n[0].length>e[0].length)){if(e=n,r=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,i[a])))return t;if(this._backtrack){e=!1;continue}return !1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[r]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(t){this.conditionStack.push(t);},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return (t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t);},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(t,e,n,r){switch(n){case 0:return this.begin("open_directive"),12;case 1:return this.begin("type_directive"),13;case 2:return this.popState(),this.begin("arg_directive"),10;case 3:return this.popState(),this.popState(),15;case 4:return 14;case 5:case 6:break;case 7:return this.begin("acc_title"),44;case 8:return this.popState(),"acc_title_value";case 9:return this.begin("acc_descr"),46;case 10:return this.popState(),"acc_descr_value";case 11:this.begin("acc_descr_multiline");break;case 12:case 15:case 24:case 27:case 30:case 33:this.popState();break;case 13:return "acc_descr_multiline_value";case 14:this.begin("string");break;case 16:return "STR";case 17:return 86;case 18:return 95;case 19:return 87;case 20:return 104;case 21:return 88;case 22:return 89;case 23:this.begin("href");break;case 25:return 100;case 26:this.begin("callbackname");break;case 28:this.popState(),this.begin("callbackargs");break;case 29:return 98;case 31:return 99;case 32:this.begin("click");break;case 34:return 90;case 35:case 36:return t.lex.firstGraph()&&this.begin("dir"),24;case 37:return 38;case 38:return 42;case 39:case 40:case 41:case 42:return 101;case 43:return this.popState(),25;case 44:case 45:case 46:case 47:case 48:case 49:case 50:case 51:case 52:case 53:return this.popState(),26;case 54:return 118;case 55:return 119;case 56:return 120;case 57:return 121;case 58:return 105;case 59:return 111;case 60:return 53;case 61:return 67;case 62:return 52;case 63:return 20;case 64:return 106;case 65:return 126;case 66:case 67:case 68:return 82;case 69:case 70:case 71:return 81;case 72:return 59;case 73:return 60;case 74:return 61;case 75:return 62;case 76:return 63;case 77:return 64;case 78:return 65;case 79:return 69;case 80:return 70;case 81:return 55;case 82:return 56;case 83:return 109;case 84:return 112;case 85:return 127;case 86:return 124;case 87:return 113;case 88:case 89:return 125;case 90:return 114;case 91:return 73;case 92:return 92;case 93:return "SEP";case 94:return 91;case 95:return 66;case 96:return 75;case 97:return 74;case 98:return 77;case 99:return 76;case 100:return 122;case 101:return 123;case 102:return 68;case 103:return 57;case 104:return 58;case 105:return 40;case 106:return 41;case 107:return 71;case 108:return 72;case 109:return 133;case 110:return 21;case 111:return 22;case 112:return 23}},rules:[/^(?:%%\{)/,/^(?:((?:(?!\}%%)[^:.])*))/,/^(?::)/,/^(?:\}%%)/,/^(?:((?:(?!\}%%).|\n)*))/,/^(?:%%(?!\{)[^\n]*)/,/^(?:[^\}]%%[^\n]*)/,/^(?:accTitle\s*:\s*)/,/^(?:(?!\n||)*[^\n]*)/,/^(?:accDescr\s*:\s*)/,/^(?:(?!\n||)*[^\n]*)/,/^(?:accDescr\s*\{\s*)/,/^(?:[\}])/,/^(?:[^\}]*)/,/^(?:["])/,/^(?:["])/,/^(?:[^"]*)/,/^(?:style\b)/,/^(?:default\b)/,/^(?:linkStyle\b)/,/^(?:interpolate\b)/,/^(?:classDef\b)/,/^(?:class\b)/,/^(?:href[\s]+["])/,/^(?:["])/,/^(?:[^"]*)/,/^(?:call[\s]+)/,/^(?:\([\s]*\))/,/^(?:\()/,/^(?:[^(]*)/,/^(?:\))/,/^(?:[^)]*)/,/^(?:click[\s]+)/,/^(?:[\s\n])/,/^(?:[^\s\n]*)/,/^(?:graph\b)/,/^(?:flowchart\b)/,/^(?:subgraph\b)/,/^(?:end\b\s*)/,/^(?:_self\b)/,/^(?:_blank\b)/,/^(?:_parent\b)/,/^(?:_top\b)/,/^(?:(\r?\n)*\s*\n)/,/^(?:\s*LR\b)/,/^(?:\s*RL\b)/,/^(?:\s*TB\b)/,/^(?:\s*BT\b)/,/^(?:\s*TD\b)/,/^(?:\s*BR\b)/,/^(?:\s*<)/,/^(?:\s*>)/,/^(?:\s*\^)/,/^(?:\s*v\b)/,/^(?:.*direction\s+TB[^\n]*)/,/^(?:.*direction\s+BT[^\n]*)/,/^(?:.*direction\s+RL[^\n]*)/,/^(?:.*direction\s+LR[^\n]*)/,/^(?:[0-9]+)/,/^(?:#)/,/^(?::::)/,/^(?::)/,/^(?:&)/,/^(?:;)/,/^(?:,)/,/^(?:\*)/,/^(?:\s*[xo<]?--+[-xo>]\s*)/,/^(?:\s*[xo<]?==+[=xo>]\s*)/,/^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/,/^(?:\s*[xo<]?--\s*)/,/^(?:\s*[xo<]?==\s*)/,/^(?:\s*[xo<]?-\.\s*)/,/^(?:\(-)/,/^(?:-\))/,/^(?:\(\[)/,/^(?:\]\))/,/^(?:\[\[)/,/^(?:\]\])/,/^(?:\[\|)/,/^(?:\[\()/,/^(?:\)\])/,/^(?:\(\(\()/,/^(?:\)\)\))/,/^(?:-)/,/^(?:\.)/,/^(?:[\_])/,/^(?:\+)/,/^(?:%)/,/^(?:=)/,/^(?:=)/,/^(?:<)/,/^(?:>)/,/^(?:\^)/,/^(?:\\\|)/,/^(?:v\b)/,/^(?:[A-Za-z]+)/,/^(?:\\\])/,/^(?:\[\/)/,/^(?:\/\])/,/^(?:\[\\)/,/^(?:[!"#$%&'*+,-.`?\\_/])/,/^(?:[\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|[\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|[\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|[\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE]|[\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA]|[\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0]|[\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977]|[\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2]|[\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A]|[\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39]|[\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8]|[\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C]|[\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C]|[\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99]|[\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0]|[\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D]|[\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3]|[\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10]|[\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1]|[\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81]|[\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3]|[\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6]|[\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A]|[\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081]|[\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D]|[\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0]|[\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310]|[\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C]|[\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711]|[\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7]|[\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C]|[\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16]|[\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF]|[\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC]|[\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D]|[\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D]|[\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3]|[\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F]|[\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128]|[\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184]|[\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3]|[\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6]|[\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE]|[\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C]|[\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D]|[\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC]|[\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B]|[\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788]|[\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805]|[\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB]|[\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28]|[\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5]|[\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4]|[\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E]|[\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D]|[\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36]|[\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D]|[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|[\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|[\uFFD2-\uFFD7\uFFDA-\uFFDC])/,/^(?:\|)/,/^(?:\()/,/^(?:\))/,/^(?:\[)/,/^(?:\])/,/^(?:\{)/,/^(?:\})/,/^(?:")/,/^(?:(\r?\n)+)/,/^(?:\s)/,/^(?:$)/],conditions:{close_directive:{rules:[],inclusive:!1},arg_directive:{rules:[3,4],inclusive:!1},type_directive:{rules:[2,3],inclusive:!1},open_directive:{rules:[1],inclusive:!1},callbackargs:{rules:[30,31],inclusive:!1},callbackname:{rules:[27,28,29],inclusive:!1},href:{rules:[24,25],inclusive:!1},click:{rules:[33,34],inclusive:!1},vertex:{rules:[],inclusive:!1},dir:{rules:[43,44,45,46,47,48,49,50,51,52,53],inclusive:!1},acc_descr_multiline:{rules:[12,13],inclusive:!1},acc_descr:{rules:[10],inclusive:!1},acc_title:{rules:[8],inclusive:!1},string:{rules:[15,16],inclusive:!1},INITIAL:{rules:[0,5,6,7,9,11,14,17,18,19,20,21,22,23,26,32,35,36,37,38,39,40,41,42,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112],inclusive:!0}}};function re(){this.yy={};}return ee.lexer=ne,re.prototype=ee,ee.Parser=re,new re}();e.parser=r,e.Parser=r.Parser,e.parse=function(){return r.parse.apply(r,arguments)},e.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var r=n(5354).readFileSync(n(6470).normalize(t[1]),"utf8");return e.parser.parse(r)},n.c[n.s]===t&&e.main(process.argv.slice(1));},9959:(t,e,n)=>{t=n.nmd(t);var r=function(){var t=function(t,e,n,r){for(n=n||{},r=t.length;r--;n[t[r]]=e);return n},e=[1,3],n=[1,5],r=[7,9,11,12,13,14,15,16,17,18,19,20,22,24,25,27,34,39],i=[1,15],a=[1,16],o=[1,17],s=[1,18],c=[1,19],l=[1,20],u=[1,21],h=[1,22],f=[1,23],d=[1,24],p=[1,25],g=[1,26],y=[1,28],m=[1,30],b=[1,33],v=[5,7,9,11,12,13,14,15,16,17,18,19,20,22,24,25,27,34,39],_={trace:function(){},yy:{},symbols_:{error:2,start:3,directive:4,gantt:5,document:6,EOF:7,line:8,SPACE:9,statement:10,NL:11,dateFormat:12,inclusiveEndDates:13,topAxis:14,axisFormat:15,excludes:16,includes:17,todayMarker:18,title:19,acc_title:20,acc_title_value:21,acc_descr:22,acc_descr_value:23,acc_descr_multiline_value:24,section:25,clickStatement:26,taskTxt:27,taskData:28,openDirective:29,typeDirective:30,closeDirective:31,":":32,argDirective:33,click:34,callbackname:35,callbackargs:36,href:37,clickStatementDebug:38,open_directive:39,type_directive:40,arg_directive:41,close_directive:42,$accept:0,$end:1},terminals_:{2:"error",5:"gantt",7:"EOF",9:"SPACE",11:"NL",12:"dateFormat",13:"inclusiveEndDates",14:"topAxis",15:"axisFormat",16:"excludes",17:"includes",18:"todayMarker",19:"title",20:"acc_title",21:"acc_title_value",22:"acc_descr",23:"acc_descr_value",24:"acc_descr_multiline_value",25:"section",27:"taskTxt",28:"taskData",32:":",34:"click",35:"callbackname",36:"callbackargs",37:"href",39:"open_directive",40:"type_directive",41:"arg_directive",42:"close_directive"},productions_:[0,[3,2],[3,3],[6,0],[6,2],[8,2],[8,1],[8,1],[8,1],[10,1],[10,1],[10,1],[10,1],[10,1],[10,1],[10,1],[10,1],[10,2],[10,2],[10,1],[10,1],[10,1],[10,2],[10,1],[4,4],[4,6],[26,2],[26,3],[26,3],[26,4],[26,3],[26,4],[26,2],[38,2],[38,3],[38,3],[38,4],[38,3],[38,4],[38,2],[29,1],[30,1],[33,1],[31,1]],performAction:function(t,e,n,r,i,a,o){var s=a.length-1;switch(i){case 2:return a[s-1];case 3:case 7:case 8:this.$=[];break;case 4:a[s-1].push(a[s]),this.$=a[s-1];break;case 5:case 6:this.$=a[s];break;case 9:r.setDateFormat(a[s].substr(11)),this.$=a[s].substr(11);break;case 10:r.enableInclusiveEndDates(),this.$=a[s].substr(18);break;case 11:r.TopAxis(),this.$=a[s].substr(8);break;case 12:r.setAxisFormat(a[s].substr(11)),this.$=a[s].substr(11);break;case 13:r.setExcludes(a[s].substr(9)),this.$=a[s].substr(9);break;case 14:r.setIncludes(a[s].substr(9)),this.$=a[s].substr(9);break;case 15:r.setTodayMarker(a[s].substr(12)),this.$=a[s].substr(12);break;case 16:r.setDiagramTitle(a[s].substr(6)),this.$=a[s].substr(6);break;case 17:this.$=a[s].trim(),r.setAccTitle(this.$);break;case 18:case 19:this.$=a[s].trim(),r.setAccDescription(this.$);break;case 20:r.addSection(a[s].substr(8)),this.$=a[s].substr(8);break;case 22:r.addTask(a[s-1],a[s]),this.$="task";break;case 26:this.$=a[s-1],r.setClickEvent(a[s-1],a[s],null);break;case 27:this.$=a[s-2],r.setClickEvent(a[s-2],a[s-1],a[s]);break;case 28:this.$=a[s-2],r.setClickEvent(a[s-2],a[s-1],null),r.setLink(a[s-2],a[s]);break;case 29:this.$=a[s-3],r.setClickEvent(a[s-3],a[s-2],a[s-1]),r.setLink(a[s-3],a[s]);break;case 30:this.$=a[s-2],r.setClickEvent(a[s-2],a[s],null),r.setLink(a[s-2],a[s-1]);break;case 31:this.$=a[s-3],r.setClickEvent(a[s-3],a[s-1],a[s]),r.setLink(a[s-3],a[s-2]);break;case 32:this.$=a[s-1],r.setLink(a[s-1],a[s]);break;case 33:case 39:this.$=a[s-1]+" "+a[s];break;case 34:case 35:case 37:this.$=a[s-2]+" "+a[s-1]+" "+a[s];break;case 36:case 38:this.$=a[s-3]+" "+a[s-2]+" "+a[s-1]+" "+a[s];break;case 40:r.parseDirective("%%{","open_directive");break;case 41:r.parseDirective(a[s],"type_directive");break;case 42:a[s]=a[s].trim().replace(/'/g,'"'),r.parseDirective(a[s],"arg_directive");break;case 43:r.parseDirective("}%%","close_directive","gantt");}},table:[{3:1,4:2,5:e,29:4,39:n},{1:[3]},{3:6,4:2,5:e,29:4,39:n},t(r,[2,3],{6:7}),{30:8,40:[1,9]},{40:[2,40]},{1:[2,1]},{4:29,7:[1,10],8:11,9:[1,12],10:13,11:[1,14],12:i,13:a,14:o,15:s,16:c,17:l,18:u,19:h,20:f,22:d,24:p,25:g,26:27,27:y,29:4,34:m,39:n},{31:31,32:[1,32],42:b},t([32,42],[2,41]),t(r,[2,8],{1:[2,2]}),t(r,[2,4]),{4:29,10:34,12:i,13:a,14:o,15:s,16:c,17:l,18:u,19:h,20:f,22:d,24:p,25:g,26:27,27:y,29:4,34:m,39:n},t(r,[2,6]),t(r,[2,7]),t(r,[2,9]),t(r,[2,10]),t(r,[2,11]),t(r,[2,12]),t(r,[2,13]),t(r,[2,14]),t(r,[2,15]),t(r,[2,16]),{21:[1,35]},{23:[1,36]},t(r,[2,19]),t(r,[2,20]),t(r,[2,21]),{28:[1,37]},t(r,[2,23]),{35:[1,38],37:[1,39]},{11:[1,40]},{33:41,41:[1,42]},{11:[2,43]},t(r,[2,5]),t(r,[2,17]),t(r,[2,18]),t(r,[2,22]),t(r,[2,26],{36:[1,43],37:[1,44]}),t(r,[2,32],{35:[1,45]}),t(v,[2,24]),{31:46,42:b},{42:[2,42]},t(r,[2,27],{37:[1,47]}),t(r,[2,28]),t(r,[2,30],{36:[1,48]}),{11:[1,49]},t(r,[2,29]),t(r,[2,31]),t(v,[2,25])],defaultActions:{5:[2,40],6:[2,1],33:[2,43],42:[2,42]},parseError:function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t);},parse:function(t){var e=this,n=[0],r=[],i=[null],a=[],o=this.table,s="",c=0,l=0,u=0,h=2,f=1,d=a.slice.call(arguments,1),p=Object.create(this.lexer),g={yy:{}};for(var y in this.yy)Object.prototype.hasOwnProperty.call(this.yy,y)&&(g.yy[y]=this.yy[y]);p.setInput(t,g.yy),g.yy.lexer=p,g.yy.parser=this,void 0===p.yylloc&&(p.yylloc={});var m=p.yylloc;a.push(m);var b=p.options&&p.options.ranges;function v(){var t;return "number"!=typeof(t=r.pop()||p.lex()||f)&&(t instanceof Array&&(t=(r=t).pop()),t=e.symbols_[t]||t),t}"function"==typeof g.yy.parseError?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var _,x,k,w,T,E,C,S,A,M={};;){if(k=n[n.length-1],this.defaultActions[k]?w=this.defaultActions[k]:(null==_&&(_=v()),w=o[k]&&o[k][_]),void 0===w||!w.length||!w[0]){var N="";for(E in A=[],o[k])this.terminals_[E]&&E>h&&A.push("'"+this.terminals_[E]+"'");N=p.showPosition?"Parse error on line "+(c+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[_]||_)+"'":"Parse error on line "+(c+1)+": Unexpected "+(_==f?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(N,{text:p.match,token:this.terminals_[_]||_,line:p.yylineno,loc:m,expected:A});}if(w[0]instanceof Array&&w.length>1)throw new Error("Parse Error: multiple actions possible at state: "+k+", token: "+_);switch(w[0]){case 1:n.push(_),i.push(p.yytext),a.push(p.yylloc),n.push(w[1]),_=null,x?(_=x,x=null):(l=p.yyleng,s=p.yytext,c=p.yylineno,m=p.yylloc,u>0&&u--);break;case 2:if(C=this.productions_[w[1]][1],M.$=i[i.length-C],M._$={first_line:a[a.length-(C||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(C||1)].first_column,last_column:a[a.length-1].last_column},b&&(M._$.range=[a[a.length-(C||1)].range[0],a[a.length-1].range[1]]),void 0!==(T=this.performAction.apply(M,[s,l,c,g.yy,w[1],i,a].concat(d))))return T;C&&(n=n.slice(0,-1*C*2),i=i.slice(0,-1*C),a=a.slice(0,-1*C)),n.push(this.productions_[w[1]][0]),i.push(M.$),a.push(M._$),S=o[n[n.length-2]][n[n.length-1]],n.push(S);break;case 3:return !0}}return !0}},x={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e);},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t));},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return (t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var n,r,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(r=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in i)this[a]=i[a];return !1}return !1},next:function(){if(this.done)return this.EOF;var t,e,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),a=0;a<i.length;a++)if((n=this._input.match(this.rules[i[a]]))&&(!e||n[0].length>e[0].length)){if(e=n,r=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,i[a])))return t;if(this._backtrack){e=!1;continue}return !1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[r]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(t){this.conditionStack.push(t);},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return (t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t);},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,n,r){switch(n){case 0:return this.begin("open_directive"),39;case 1:return this.begin("type_directive"),40;case 2:return this.popState(),this.begin("arg_directive"),32;case 3:return this.popState(),this.popState(),42;case 4:return 41;case 5:return this.begin("acc_title"),20;case 6:return this.popState(),"acc_title_value";case 7:return this.begin("acc_descr"),22;case 8:return this.popState(),"acc_descr_value";case 9:this.begin("acc_descr_multiline");break;case 10:case 20:case 23:case 26:case 29:this.popState();break;case 11:return "acc_descr_multiline_value";case 12:case 13:case 14:case 16:case 17:case 18:break;case 15:return 11;case 19:this.begin("href");break;case 21:return 37;case 22:this.begin("callbackname");break;case 24:this.popState(),this.begin("callbackargs");break;case 25:return 35;case 27:return 36;case 28:this.begin("click");break;case 30:return 34;case 31:return 5;case 32:return 12;case 33:return 13;case 34:return 14;case 35:return 15;case 36:return 17;case 37:return 16;case 38:return 18;case 39:return "date";case 40:return 19;case 41:return "accDescription";case 42:return 25;case 43:return 27;case 44:return 28;case 45:return 32;case 46:return 7;case 47:return "INVALID"}},rules:[/^(?:%%\{)/i,/^(?:((?:(?!\}%%)[^:.])*))/i,/^(?::)/i,/^(?:\}%%)/i,/^(?:((?:(?!\}%%).|\n)*))/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:%%(?!\{)*[^\n]*)/i,/^(?:[^\}]%%*[^\n]*)/i,/^(?:%%*[^\n]*[\n]*)/i,/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:%[^\n]*)/i,/^(?:href[\s]+["])/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:call[\s]+)/i,/^(?:\([\s]*\))/i,/^(?:\()/i,/^(?:[^(]*)/i,/^(?:\))/i,/^(?:[^)]*)/i,/^(?:click[\s]+)/i,/^(?:[\s\n])/i,/^(?:[^\s\n]*)/i,/^(?:gantt\b)/i,/^(?:dateFormat\s[^#\n;]+)/i,/^(?:inclusiveEndDates\b)/i,/^(?:topAxis\b)/i,/^(?:axisFormat\s[^#\n;]+)/i,/^(?:includes\s[^#\n;]+)/i,/^(?:excludes\s[^#\n;]+)/i,/^(?:todayMarker\s[^\n;]+)/i,/^(?:\d\d\d\d-\d\d-\d\d\b)/i,/^(?:title\s[^#\n;]+)/i,/^(?:accDescription\s[^#\n;]+)/i,/^(?:section\s[^#:\n;]+)/i,/^(?:[^#:\n;]+)/i,/^(?::[^#\n;]+)/i,/^(?::)/i,/^(?:$)/i,/^(?:.)/i],conditions:{acc_descr_multiline:{rules:[10,11],inclusive:!1},acc_descr:{rules:[8],inclusive:!1},acc_title:{rules:[6],inclusive:!1},close_directive:{rules:[],inclusive:!1},arg_directive:{rules:[3,4],inclusive:!1},type_directive:{rules:[2,3],inclusive:!1},open_directive:{rules:[1],inclusive:!1},callbackargs:{rules:[26,27],inclusive:!1},callbackname:{rules:[23,24,25],inclusive:!1},href:{rules:[20,21],inclusive:!1},click:{rules:[29,30],inclusive:!1},INITIAL:{rules:[0,5,7,9,12,13,14,15,16,17,18,19,22,28,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47],inclusive:!0}}};function k(){this.yy={};}return _.lexer=x,k.prototype=_,_.Parser=k,new k}();e.parser=r,e.Parser=r.Parser,e.parse=function(){return r.parse.apply(r,arguments)},e.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var r=n(6878).readFileSync(n(6470).normalize(t[1]),"utf8");return e.parser.parse(r)},n.c[n.s]===t&&e.main(process.argv.slice(1));},2553:(t,e,n)=>{t=n.nmd(t);var r=function(){var t=function(t,e,n,r){for(n=n||{},r=t.length;r--;n[t[r]]=e);return n},e=[1,4],n=[1,7],r=[1,5],i=[1,9],a=[1,6],o=[2,6],s=[1,16],c=[6,8,14,20,22,24,25,27,29,32,35,39,49,53],l=[8,14,20,22,24,25,27,29,32,35,39],u=[8,13,14,20,22,24,25,27,29,32,35,39],h=[1,26],f=[6,8,14,49,53],d=[8,14,53],p=[1,64],g=[1,65],y=[1,66],m=[8,14,33,38,41,53],b={trace:function(){},yy:{},symbols_:{error:2,start:3,eol:4,directive:5,GG:6,document:7,EOF:8,":":9,DIR:10,options:11,body:12,OPT:13,NL:14,line:15,statement:16,commitStatement:17,mergeStatement:18,cherryPickStatement:19,acc_title:20,acc_title_value:21,acc_descr:22,acc_descr_value:23,acc_descr_multiline_value:24,section:25,branchStatement:26,CHECKOUT:27,ID:28,BRANCH:29,ORDER:30,NUM:31,CHERRY_PICK:32,COMMIT_ID:33,STR:34,MERGE:35,COMMIT_TYPE:36,commitType:37,COMMIT_TAG:38,COMMIT:39,commit_arg:40,COMMIT_MSG:41,NORMAL:42,REVERSE:43,HIGHLIGHT:44,openDirective:45,typeDirective:46,closeDirective:47,argDirective:48,open_directive:49,type_directive:50,arg_directive:51,close_directive:52,";":53,$accept:0,$end:1},terminals_:{2:"error",6:"GG",8:"EOF",9:":",10:"DIR",13:"OPT",14:"NL",20:"acc_title",21:"acc_title_value",22:"acc_descr",23:"acc_descr_value",24:"acc_descr_multiline_value",25:"section",27:"CHECKOUT",28:"ID",29:"BRANCH",30:"ORDER",31:"NUM",32:"CHERRY_PICK",33:"COMMIT_ID",34:"STR",35:"MERGE",36:"COMMIT_TYPE",38:"COMMIT_TAG",39:"COMMIT",41:"COMMIT_MSG",42:"NORMAL",43:"REVERSE",44:"HIGHLIGHT",49:"open_directive",50:"type_directive",51:"arg_directive",52:"close_directive",53:";"},productions_:[0,[3,2],[3,2],[3,3],[3,4],[3,5],[7,0],[7,2],[11,2],[11,1],[12,0],[12,2],[15,2],[15,1],[16,1],[16,1],[16,1],[16,2],[16,2],[16,1],[16,1],[16,1],[16,2],[26,2],[26,4],[19,3],[18,2],[18,4],[18,4],[18,4],[18,6],[18,6],[18,6],[18,6],[18,6],[18,6],[18,8],[18,8],[18,8],[18,8],[18,8],[18,8],[17,2],[17,3],[17,3],[17,5],[17,5],[17,3],[17,5],[17,5],[17,5],[17,5],[17,7],[17,7],[17,7],[17,7],[17,7],[17,7],[17,3],[17,5],[17,5],[17,5],[17,5],[17,5],[17,5],[17,7],[17,7],[17,7],[17,7],[17,7],[17,7],[17,7],[17,7],[17,7],[17,7],[17,7],[17,7],[17,7],[17,7],[17,7],[17,7],[17,7],[17,7],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[17,9],[40,0],[40,1],[37,1],[37,1],[37,1],[5,3],[5,5],[45,1],[46,1],[48,1],[47,1],[4,1],[4,1],[4,1]],performAction:function(t,e,n,r,i,a,o){var s=a.length-1;switch(i){case 3:return a[s];case 4:return a[s-1];case 5:return r.setDirection(a[s-3]),a[s-1];case 7:r.setOptions(a[s-1]),this.$=a[s];break;case 8:a[s-1]+=a[s],this.$=a[s-1];break;case 10:this.$=[];break;case 11:a[s-1].push(a[s]),this.$=a[s-1];break;case 12:this.$=a[s-1];break;case 17:this.$=a[s].trim(),r.setAccTitle(this.$);break;case 18:case 19:this.$=a[s].trim(),r.setAccDescription(this.$);break;case 20:r.addSection(a[s].substr(8)),this.$=a[s].substr(8);break;case 22:r.checkout(a[s]);break;case 23:r.branch(a[s]);break;case 24:r.branch(a[s-2],a[s]);break;case 25:r.cherryPick(a[s]);break;case 26:r.merge(a[s],"","","");break;case 27:r.merge(a[s-2],a[s],"","");break;case 28:r.merge(a[s-2],"",a[s],"");break;case 29:r.merge(a[s-2],"","",a[s]);break;case 30:r.merge(a[s-4],a[s],"",a[s-2]);break;case 31:r.merge(a[s-4],"",a[s],a[s-2]);break;case 32:r.merge(a[s-4],"",a[s-2],a[s]);break;case 33:r.merge(a[s-4],a[s-2],a[s],"");break;case 34:r.merge(a[s-4],a[s-2],"",a[s]);break;case 35:r.merge(a[s-4],a[s],a[s-2],"");break;case 36:r.merge(a[s-6],a[s-4],a[s-2],a[s]);break;case 37:r.merge(a[s-6],a[s],a[s-4],a[s-2]);break;case 38:r.merge(a[s-6],a[s-4],a[s],a[s-2]);break;case 39:r.merge(a[s-6],a[s-2],a[s-4],a[s]);break;case 40:r.merge(a[s-6],a[s],a[s-2],a[s-4]);break;case 41:r.merge(a[s-6],a[s-2],a[s],a[s-4]);break;case 42:r.commit(a[s]);break;case 43:r.commit("","",r.commitType.NORMAL,a[s]);break;case 44:r.commit("","",a[s],"");break;case 45:r.commit("","",a[s],a[s-2]);break;case 46:r.commit("","",a[s-2],a[s]);break;case 47:r.commit("",a[s],r.commitType.NORMAL,"");break;case 48:r.commit("",a[s-2],r.commitType.NORMAL,a[s]);break;case 49:r.commit("",a[s],r.commitType.NORMAL,a[s-2]);break;case 50:r.commit("",a[s-2],a[s],"");break;case 51:r.commit("",a[s],a[s-2],"");break;case 52:r.commit("",a[s-4],a[s-2],a[s]);break;case 53:r.commit("",a[s-4],a[s],a[s-2]);break;case 54:r.commit("",a[s-2],a[s-4],a[s]);break;case 55:r.commit("",a[s],a[s-4],a[s-2]);break;case 56:r.commit("",a[s],a[s-2],a[s-4]);break;case 57:r.commit("",a[s-2],a[s],a[s-4]);break;case 58:r.commit(a[s],"",r.commitType.NORMAL,"");break;case 59:r.commit(a[s],"",r.commitType.NORMAL,a[s-2]);break;case 60:r.commit(a[s-2],"",r.commitType.NORMAL,a[s]);break;case 61:r.commit(a[s-2],"",a[s],"");break;case 62:r.commit(a[s],"",a[s-2],"");break;case 63:r.commit(a[s],a[s-2],r.commitType.NORMAL,"");break;case 64:r.commit(a[s-2],a[s],r.commitType.NORMAL,"");break;case 65:r.commit(a[s-4],"",a[s-2],a[s]);break;case 66:r.commit(a[s-4],"",a[s],a[s-2]);break;case 67:r.commit(a[s-2],"",a[s-4],a[s]);break;case 68:r.commit(a[s],"",a[s-4],a[s-2]);break;case 69:r.commit(a[s],"",a[s-2],a[s-4]);break;case 70:r.commit(a[s-2],"",a[s],a[s-4]);break;case 71:r.commit(a[s-4],a[s],a[s-2],"");break;case 72:r.commit(a[s-4],a[s-2],a[s],"");break;case 73:r.commit(a[s-2],a[s],a[s-4],"");break;case 74:r.commit(a[s],a[s-2],a[s-4],"");break;case 75:r.commit(a[s],a[s-4],a[s-2],"");break;case 76:r.commit(a[s-2],a[s-4],a[s],"");break;case 77:r.commit(a[s-4],a[s],r.commitType.NORMAL,a[s-2]);break;case 78:r.commit(a[s-4],a[s-2],r.commitType.NORMAL,a[s]);break;case 79:r.commit(a[s-2],a[s],r.commitType.NORMAL,a[s-4]);break;case 80:r.commit(a[s],a[s-2],r.commitType.NORMAL,a[s-4]);break;case 81:r.commit(a[s],a[s-4],r.commitType.NORMAL,a[s-2]);break;case 82:r.commit(a[s-2],a[s-4],r.commitType.NORMAL,a[s]);break;case 83:r.commit(a[s-6],a[s-4],a[s-2],a[s]);break;case 84:r.commit(a[s-6],a[s-4],a[s],a[s-2]);break;case 85:r.commit(a[s-6],a[s-2],a[s-4],a[s]);break;case 86:r.commit(a[s-6],a[s],a[s-4],a[s-2]);break;case 87:r.commit(a[s-6],a[s-2],a[s],a[s-4]);break;case 88:r.commit(a[s-6],a[s],a[s-2],a[s-4]);break;case 89:r.commit(a[s-4],a[s-6],a[s-2],a[s]);break;case 90:r.commit(a[s-4],a[s-6],a[s],a[s-2]);break;case 91:r.commit(a[s-2],a[s-6],a[s-4],a[s]);break;case 92:r.commit(a[s],a[s-6],a[s-4],a[s-2]);break;case 93:r.commit(a[s-2],a[s-6],a[s],a[s-4]);break;case 94:r.commit(a[s],a[s-6],a[s-2],a[s-4]);break;case 95:r.commit(a[s],a[s-4],a[s-2],a[s-6]);break;case 96:r.commit(a[s-2],a[s-4],a[s],a[s-6]);break;case 97:r.commit(a[s],a[s-2],a[s-4],a[s-6]);break;case 98:r.commit(a[s-2],a[s],a[s-4],a[s-6]);break;case 99:r.commit(a[s-4],a[s-2],a[s],a[s-6]);break;case 100:r.commit(a[s-4],a[s],a[s-2],a[s-6]);break;case 101:r.commit(a[s-2],a[s-4],a[s-6],a[s]);break;case 102:r.commit(a[s],a[s-4],a[s-6],a[s-2]);break;case 103:r.commit(a[s-2],a[s],a[s-6],a[s-4]);break;case 104:r.commit(a[s],a[s-2],a[s-6],a[s-4]);break;case 105:r.commit(a[s-4],a[s-2],a[s-6],a[s]);break;case 106:r.commit(a[s-4],a[s],a[s-6],a[s-2]);break;case 107:this.$="";break;case 108:this.$=a[s];break;case 109:this.$=r.commitType.NORMAL;break;case 110:this.$=r.commitType.REVERSE;break;case 111:this.$=r.commitType.HIGHLIGHT;break;case 114:r.parseDirective("%%{","open_directive");break;case 115:r.parseDirective(a[s],"type_directive");break;case 116:a[s]=a[s].trim().replace(/'/g,'"'),r.parseDirective(a[s],"arg_directive");break;case 117:r.parseDirective("}%%","close_directive","gitGraph");}},table:[{3:1,4:2,5:3,6:e,8:n,14:r,45:8,49:i,53:a},{1:[3]},{3:10,4:2,5:3,6:e,8:n,14:r,45:8,49:i,53:a},{3:11,4:2,5:3,6:e,8:n,14:r,45:8,49:i,53:a},{7:12,8:o,9:[1,13],10:[1,14],11:15,14:s},t(c,[2,118]),t(c,[2,119]),t(c,[2,120]),{46:17,50:[1,18]},{50:[2,114]},{1:[2,1]},{1:[2,2]},{8:[1,19]},{7:20,8:o,11:15,14:s},{9:[1,21]},t(l,[2,10],{12:22,13:[1,23]}),t(u,[2,9]),{9:[1,25],47:24,52:h},t([9,52],[2,115]),{1:[2,3]},{8:[1,27]},{7:28,8:o,11:15,14:s},{8:[2,7],14:[1,31],15:29,16:30,17:32,18:33,19:34,20:[1,35],22:[1,36],24:[1,37],25:[1,38],26:39,27:[1,40],29:[1,44],32:[1,43],35:[1,42],39:[1,41]},t(u,[2,8]),t(f,[2,112]),{48:45,51:[1,46]},t(f,[2,117]),{1:[2,4]},{8:[1,47]},t(l,[2,11]),{4:48,8:n,14:r,53:a},t(l,[2,13]),t(d,[2,14]),t(d,[2,15]),t(d,[2,16]),{21:[1,49]},{23:[1,50]},t(d,[2,19]),t(d,[2,20]),t(d,[2,21]),{28:[1,51]},t(d,[2,107],{40:52,33:[1,55],34:[1,57],36:[1,54],38:[1,53],41:[1,56]}),{28:[1,58]},{33:[1,59]},{28:[1,60]},{47:61,52:h},{52:[2,116]},{1:[2,5]},t(l,[2,12]),t(d,[2,17]),t(d,[2,18]),t(d,[2,22]),t(d,[2,42]),{34:[1,62]},{37:63,42:p,43:g,44:y},{34:[1,67]},{34:[1,68]},t(d,[2,108]),t(d,[2,26],{33:[1,69],36:[1,70],38:[1,71]}),{34:[1,72]},t(d,[2,23],{30:[1,73]}),t(f,[2,113]),t(d,[2,43],{33:[1,75],36:[1,74],41:[1,76]}),t(d,[2,44],{33:[1,78],38:[1,77],41:[1,79]}),t(m,[2,109]),t(m,[2,110]),t(m,[2,111]),t(d,[2,47],{36:[1,81],38:[1,80],41:[1,82]}),t(d,[2,58],{33:[1,85],36:[1,84],38:[1,83]}),{34:[1,86]},{37:87,42:p,43:g,44:y},{34:[1,88]},t(d,[2,25]),{31:[1,89]},{37:90,42:p,43:g,44:y},{34:[1,91]},{34:[1,92]},{34:[1,93]},{34:[1,94]},{34:[1,95]},{34:[1,96]},{37:97,42:p,43:g,44:y},{34:[1,98]},{34:[1,99]},{37:100,42:p,43:g,44:y},{34:[1,101]},t(d,[2,27],{36:[1,102],38:[1,103]}),t(d,[2,28],{33:[1,105],38:[1,104]}),t(d,[2,29],{33:[1,106],36:[1,107]}),t(d,[2,24]),t(d,[2,45],{33:[1,108],41:[1,109]}),t(d,[2,49],{36:[1,110],41:[1,111]}),t(d,[2,59],{33:[1,113],36:[1,112]}),t(d,[2,46],{33:[1,114],41:[1,115]}),t(d,[2,51],{38:[1,116],41:[1,117]}),t(d,[2,62],{33:[1,119],38:[1,118]}),t(d,[2,48],{36:[1,120],41:[1,121]}),t(d,[2,50],{38:[1,122],41:[1,123]}),t(d,[2,63],{36:[1,124],38:[1,125]}),t(d,[2,60],{33:[1,127],36:[1,126]}),t(d,[2,61],{33:[1,129],38:[1,128]}),t(d,[2,64],{36:[1,130],38:[1,131]}),{37:132,42:p,43:g,44:y},{34:[1,133]},{34:[1,134]},{34:[1,135]},{34:[1,136]},{37:137,42:p,43:g,44:y},{34:[1,138]},{34:[1,139]},{37:140,42:p,43:g,44:y},{34:[1,141]},{37:142,42:p,43:g,44:y},{34:[1,143]},{34:[1,144]},{34:[1,145]},{34:[1,146]},{34:[1,147]},{34:[1,148]},{34:[1,149]},{37:150,42:p,43:g,44:y},{34:[1,151]},{34:[1,152]},{34:[1,153]},{37:154,42:p,43:g,44:y},{34:[1,155]},{37:156,42:p,43:g,44:y},{34:[1,157]},{34:[1,158]},{34:[1,159]},{37:160,42:p,43:g,44:y},{34:[1,161]},t(d,[2,33],{38:[1,162]}),t(d,[2,34],{36:[1,163]}),t(d,[2,32],{33:[1,164]}),t(d,[2,35],{38:[1,165]}),t(d,[2,30],{36:[1,166]}),t(d,[2,31],{33:[1,167]}),t(d,[2,56],{41:[1,168]}),t(d,[2,69],{33:[1,169]}),t(d,[2,57],{41:[1,170]}),t(d,[2,80],{36:[1,171]}),t(d,[2,70],{33:[1,172]}),t(d,[2,79],{36:[1,173]}),t(d,[2,55],{41:[1,174]}),t(d,[2,68],{33:[1,175]}),t(d,[2,54],{41:[1,176]}),t(d,[2,74],{38:[1,177]}),t(d,[2,67],{33:[1,178]}),t(d,[2,73],{38:[1,179]}),t(d,[2,53],{41:[1,180]}),t(d,[2,81],{36:[1,181]}),t(d,[2,52],{41:[1,182]}),t(d,[2,75],{38:[1,183]}),t(d,[2,76],{38:[1,184]}),t(d,[2,82],{36:[1,185]}),t(d,[2,66],{33:[1,186]}),t(d,[2,77],{36:[1,187]}),t(d,[2,65],{33:[1,188]}),t(d,[2,71],{38:[1,189]}),t(d,[2,72],{38:[1,190]}),t(d,[2,78],{36:[1,191]}),{34:[1,192]},{37:193,42:p,43:g,44:y},{34:[1,194]},{34:[1,195]},{37:196,42:p,43:g,44:y},{34:[1,197]},{34:[1,198]},{34:[1,199]},{34:[1,200]},{37:201,42:p,43:g,44:y},{34:[1,202]},{37:203,42:p,43:g,44:y},{34:[1,204]},{34:[1,205]},{34:[1,206]},{34:[1,207]},{34:[1,208]},{34:[1,209]},{34:[1,210]},{37:211,42:p,43:g,44:y},{34:[1,212]},{34:[1,213]},{34:[1,214]},{37:215,42:p,43:g,44:y},{34:[1,216]},{37:217,42:p,43:g,44:y},{34:[1,218]},{34:[1,219]},{34:[1,220]},{37:221,42:p,43:g,44:y},t(d,[2,36]),t(d,[2,38]),t(d,[2,37]),t(d,[2,39]),t(d,[2,41]),t(d,[2,40]),t(d,[2,97]),t(d,[2,98]),t(d,[2,95]),t(d,[2,96]),t(d,[2,100]),t(d,[2,99]),t(d,[2,104]),t(d,[2,103]),t(d,[2,102]),t(d,[2,101]),t(d,[2,106]),t(d,[2,105]),t(d,[2,94]),t(d,[2,93]),t(d,[2,92]),t(d,[2,91]),t(d,[2,89]),t(d,[2,90]),t(d,[2,88]),t(d,[2,87]),t(d,[2,86]),t(d,[2,85]),t(d,[2,83]),t(d,[2,84])],defaultActions:{9:[2,114],10:[2,1],11:[2,2],19:[2,3],27:[2,4],46:[2,116],47:[2,5]},parseError:function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t);},parse:function(t){var e=this,n=[0],r=[],i=[null],a=[],o=this.table,s="",c=0,l=0,u=0,h=2,f=1,d=a.slice.call(arguments,1),p=Object.create(this.lexer),g={yy:{}};for(var y in this.yy)Object.prototype.hasOwnProperty.call(this.yy,y)&&(g.yy[y]=this.yy[y]);p.setInput(t,g.yy),g.yy.lexer=p,g.yy.parser=this,void 0===p.yylloc&&(p.yylloc={});var m=p.yylloc;a.push(m);var b=p.options&&p.options.ranges;function v(){var t;return "number"!=typeof(t=r.pop()||p.lex()||f)&&(t instanceof Array&&(t=(r=t).pop()),t=e.symbols_[t]||t),t}"function"==typeof g.yy.parseError?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var _,x,k,w,T,E,C,S,A,M={};;){if(k=n[n.length-1],this.defaultActions[k]?w=this.defaultActions[k]:(null==_&&(_=v()),w=o[k]&&o[k][_]),void 0===w||!w.length||!w[0]){var N="";for(E in A=[],o[k])this.terminals_[E]&&E>h&&A.push("'"+this.terminals_[E]+"'");N=p.showPosition?"Parse error on line "+(c+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[_]||_)+"'":"Parse error on line "+(c+1)+": Unexpected "+(_==f?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(N,{text:p.match,token:this.terminals_[_]||_,line:p.yylineno,loc:m,expected:A});}if(w[0]instanceof Array&&w.length>1)throw new Error("Parse Error: multiple actions possible at state: "+k+", token: "+_);switch(w[0]){case 1:n.push(_),i.push(p.yytext),a.push(p.yylloc),n.push(w[1]),_=null,x?(_=x,x=null):(l=p.yyleng,s=p.yytext,c=p.yylineno,m=p.yylloc,u>0&&u--);break;case 2:if(C=this.productions_[w[1]][1],M.$=i[i.length-C],M._$={first_line:a[a.length-(C||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(C||1)].first_column,last_column:a[a.length-1].last_column},b&&(M._$.range=[a[a.length-(C||1)].range[0],a[a.length-1].range[1]]),void 0!==(T=this.performAction.apply(M,[s,l,c,g.yy,w[1],i,a].concat(d))))return T;C&&(n=n.slice(0,-1*C*2),i=i.slice(0,-1*C),a=a.slice(0,-1*C)),n.push(this.productions_[w[1]][0]),i.push(M.$),a.push(M._$),S=o[n[n.length-2]][n[n.length-1]],n.push(S);break;case 3:return !0}}return !0}},v={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e);},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t));},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return (t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var n,r,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(r=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in i)this[a]=i[a];return !1}return !1},next:function(){if(this.done)return this.EOF;var t,e,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),a=0;a<i.length;a++)if((n=this._input.match(this.rules[i[a]]))&&(!e||n[0].length>e[0].length)){if(e=n,r=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,i[a])))return t;if(this._backtrack){e=!1;continue}return !1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[r]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(t){this.conditionStack.push(t);},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return (t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t);},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,n,r){switch(n){case 0:return this.begin("open_directive"),49;case 1:return this.begin("type_directive"),50;case 2:return this.popState(),this.begin("arg_directive"),9;case 3:return this.popState(),this.popState(),52;case 4:return 51;case 5:return this.begin("acc_title"),20;case 6:return this.popState(),"acc_title_value";case 7:return this.begin("acc_descr"),22;case 8:return this.popState(),"acc_descr_value";case 9:this.begin("acc_descr_multiline");break;case 10:case 35:case 38:this.popState();break;case 11:return "acc_descr_multiline_value";case 12:return 14;case 13:case 14:case 15:break;case 16:return 6;case 17:return 39;case 18:return 33;case 19:return 36;case 20:return 41;case 21:return 42;case 22:return 43;case 23:return 44;case 24:return 38;case 25:return 29;case 26:return 30;case 27:return 35;case 28:return 32;case 29:return 27;case 30:case 31:return 10;case 32:return 9;case 33:return "CARET";case 34:this.begin("options");break;case 36:return 13;case 37:this.begin("string");break;case 39:return 34;case 40:return 31;case 41:return 28;case 42:return 8}},rules:[/^(?:%%\{)/i,/^(?:((?:(?!\}%%)[^:.])*))/i,/^(?::)/i,/^(?:\}%%)/i,/^(?:((?:(?!\}%%).|\n)*))/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:(\r?\n)+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:%[^\n]*)/i,/^(?:gitGraph\b)/i,/^(?:commit\b)/i,/^(?:id:)/i,/^(?:type:)/i,/^(?:msg:)/i,/^(?:NORMAL\b)/i,/^(?:REVERSE\b)/i,/^(?:HIGHLIGHT\b)/i,/^(?:tag:)/i,/^(?:branch\b)/i,/^(?:order:)/i,/^(?:merge\b)/i,/^(?:cherry-pick\b)/i,/^(?:checkout\b)/i,/^(?:LR\b)/i,/^(?:BT\b)/i,/^(?::)/i,/^(?:\^)/i,/^(?:options\r?\n)/i,/^(?:[ \r\n\t]+end\b)/i,/^(?:[\s\S]+(?=[ \r\n\t]+end))/i,/^(?:["])/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:[0-9]+)/i,/^(?:[a-zA-Z][-_\./a-zA-Z0-9]*[-_a-zA-Z0-9])/i,/^(?:$)/i],conditions:{acc_descr_multiline:{rules:[10,11],inclusive:!1},acc_descr:{rules:[8],inclusive:!1},acc_title:{rules:[6],inclusive:!1},close_directive:{rules:[],inclusive:!1},arg_directive:{rules:[3,4],inclusive:!1},type_directive:{rules:[2,3],inclusive:!1},open_directive:{rules:[1],inclusive:!1},options:{rules:[35,36],inclusive:!1},string:{rules:[38,39],inclusive:!1},INITIAL:{rules:[0,5,7,9,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,37,40,41,42],inclusive:!0}}};function _(){this.yy={};}return b.lexer=v,_.prototype=b,b.Parser=_,new _}();e.parser=r,e.Parser=r.Parser,e.parse=function(){return r.parse.apply(r,arguments)},e.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var r=n(8183).readFileSync(n(6470).normalize(t[1]),"utf8");return e.parser.parse(r)},n.c[n.s]===t&&e.main(process.argv.slice(1));},6765:(t,e,n)=>{t=n.nmd(t);var r=function(){var t=function(t,e,n,r){for(n=n||{},r=t.length;r--;n[t[r]]=e);return n},e=[6,9,10],n={trace:function(){},yy:{},symbols_:{error:2,start:3,info:4,document:5,EOF:6,line:7,statement:8,NL:9,showInfo:10,$accept:0,$end:1},terminals_:{2:"error",4:"info",6:"EOF",9:"NL",10:"showInfo"},productions_:[0,[3,3],[5,0],[5,2],[7,1],[7,1],[8,1]],performAction:function(t,e,n,r,i,a,o){switch(a.length,i){case 1:return r;case 4:break;case 6:r.setInfo(!0);}},table:[{3:1,4:[1,2]},{1:[3]},t(e,[2,2],{5:3}),{6:[1,4],7:5,8:6,9:[1,7],10:[1,8]},{1:[2,1]},t(e,[2,3]),t(e,[2,4]),t(e,[2,5]),t(e,[2,6])],defaultActions:{4:[2,1]},parseError:function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t);},parse:function(t){var e=this,n=[0],r=[],i=[null],a=[],o=this.table,s="",c=0,l=0,u=0,h=2,f=1,d=a.slice.call(arguments,1),p=Object.create(this.lexer),g={yy:{}};for(var y in this.yy)Object.prototype.hasOwnProperty.call(this.yy,y)&&(g.yy[y]=this.yy[y]);p.setInput(t,g.yy),g.yy.lexer=p,g.yy.parser=this,void 0===p.yylloc&&(p.yylloc={});var m=p.yylloc;a.push(m);var b=p.options&&p.options.ranges;function v(){var t;return "number"!=typeof(t=r.pop()||p.lex()||f)&&(t instanceof Array&&(t=(r=t).pop()),t=e.symbols_[t]||t),t}"function"==typeof g.yy.parseError?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var _,x,k,w,T,E,C,S,A,M={};;){if(k=n[n.length-1],this.defaultActions[k]?w=this.defaultActions[k]:(null==_&&(_=v()),w=o[k]&&o[k][_]),void 0===w||!w.length||!w[0]){var N="";for(E in A=[],o[k])this.terminals_[E]&&E>h&&A.push("'"+this.terminals_[E]+"'");N=p.showPosition?"Parse error on line "+(c+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[_]||_)+"'":"Parse error on line "+(c+1)+": Unexpected "+(_==f?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(N,{text:p.match,token:this.terminals_[_]||_,line:p.yylineno,loc:m,expected:A});}if(w[0]instanceof Array&&w.length>1)throw new Error("Parse Error: multiple actions possible at state: "+k+", token: "+_);switch(w[0]){case 1:n.push(_),i.push(p.yytext),a.push(p.yylloc),n.push(w[1]),_=null,x?(_=x,x=null):(l=p.yyleng,s=p.yytext,c=p.yylineno,m=p.yylloc,u>0&&u--);break;case 2:if(C=this.productions_[w[1]][1],M.$=i[i.length-C],M._$={first_line:a[a.length-(C||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(C||1)].first_column,last_column:a[a.length-1].last_column},b&&(M._$.range=[a[a.length-(C||1)].range[0],a[a.length-1].range[1]]),void 0!==(T=this.performAction.apply(M,[s,l,c,g.yy,w[1],i,a].concat(d))))return T;C&&(n=n.slice(0,-1*C*2),i=i.slice(0,-1*C),a=a.slice(0,-1*C)),n.push(this.productions_[w[1]][0]),i.push(M.$),a.push(M._$),S=o[n[n.length-2]][n[n.length-1]],n.push(S);break;case 3:return !0}}return !0}},r={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e);},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t));},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return (t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var n,r,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(r=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in i)this[a]=i[a];return !1}return !1},next:function(){if(this.done)return this.EOF;var t,e,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),a=0;a<i.length;a++)if((n=this._input.match(this.rules[i[a]]))&&(!e||n[0].length>e[0].length)){if(e=n,r=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,i[a])))return t;if(this._backtrack){e=!1;continue}return !1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[r]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(t){this.conditionStack.push(t);},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return (t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t);},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,n,r){switch(n){case 0:return 4;case 1:return 9;case 2:return "space";case 3:return 10;case 4:return 6;case 5:return "TXT"}},rules:[/^(?:info\b)/i,/^(?:[\s\n\r]+)/i,/^(?:[\s]+)/i,/^(?:showInfo\b)/i,/^(?:$)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5],inclusive:!0}}};function i(){this.yy={};}return n.lexer=r,i.prototype=n,n.Parser=i,new i}();e.parser=r,e.Parser=r.Parser,e.parse=function(){return r.parse.apply(r,arguments)},e.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var r=n(1428).readFileSync(n(6470).normalize(t[1]),"utf8");return e.parser.parse(r)},n.c[n.s]===t&&e.main(process.argv.slice(1));},7062:(t,e,n)=>{t=n.nmd(t);var r=function(){var t=function(t,e,n,r){for(n=n||{},r=t.length;r--;n[t[r]]=e);return n},e=[1,4],n=[1,5],r=[1,6],i=[1,7],a=[1,9],o=[1,11,13,15,17,19,20,26,27,28,29],s=[2,5],c=[1,6,11,13,15,17,19,20,26,27,28,29],l=[26,27,28],u=[2,8],h=[1,18],f=[1,19],d=[1,20],p=[1,21],g=[1,22],y=[1,23],m=[1,28],b=[6,26,27,28,29],v={trace:function(){},yy:{},symbols_:{error:2,start:3,eol:4,directive:5,PIE:6,document:7,showData:8,line:9,statement:10,txt:11,value:12,title:13,title_value:14,acc_title:15,acc_title_value:16,acc_descr:17,acc_descr_value:18,acc_descr_multiline_value:19,section:20,openDirective:21,typeDirective:22,closeDirective:23,":":24,argDirective:25,NEWLINE:26,";":27,EOF:28,open_directive:29,type_directive:30,arg_directive:31,close_directive:32,$accept:0,$end:1},terminals_:{2:"error",6:"PIE",8:"showData",11:"txt",12:"value",13:"title",14:"title_value",15:"acc_title",16:"acc_title_value",17:"acc_descr",18:"acc_descr_value",19:"acc_descr_multiline_value",20:"section",24:":",26:"NEWLINE",27:";",28:"EOF",29:"open_directive",30:"type_directive",31:"arg_directive",32:"close_directive"},productions_:[0,[3,2],[3,2],[3,2],[3,3],[7,0],[7,2],[9,2],[10,0],[10,2],[10,2],[10,2],[10,2],[10,1],[10,1],[10,1],[5,3],[5,5],[4,1],[4,1],[4,1],[21,1],[22,1],[25,1],[23,1]],performAction:function(t,e,n,r,i,a,o){var s=a.length-1;switch(i){case 4:r.setShowData(!0);break;case 7:this.$=a[s-1];break;case 9:r.addSection(a[s-1],r.cleanupValue(a[s]));break;case 10:this.$=a[s].trim(),r.setDiagramTitle(this.$);break;case 11:this.$=a[s].trim(),r.setAccTitle(this.$);break;case 12:case 13:this.$=a[s].trim(),r.setAccDescription(this.$);break;case 14:r.addSection(a[s].substr(8)),this.$=a[s].substr(8);break;case 21:r.parseDirective("%%{","open_directive");break;case 22:r.parseDirective(a[s],"type_directive");break;case 23:a[s]=a[s].trim().replace(/'/g,'"'),r.parseDirective(a[s],"arg_directive");break;case 24:r.parseDirective("}%%","close_directive","pie");}},table:[{3:1,4:2,5:3,6:e,21:8,26:n,27:r,28:i,29:a},{1:[3]},{3:10,4:2,5:3,6:e,21:8,26:n,27:r,28:i,29:a},{3:11,4:2,5:3,6:e,21:8,26:n,27:r,28:i,29:a},t(o,s,{7:12,8:[1,13]}),t(c,[2,18]),t(c,[2,19]),t(c,[2,20]),{22:14,30:[1,15]},{30:[2,21]},{1:[2,1]},{1:[2,2]},t(l,u,{21:8,9:16,10:17,5:24,1:[2,3],11:h,13:f,15:d,17:p,19:g,20:y,29:a}),t(o,s,{7:25}),{23:26,24:[1,27],32:m},t([24,32],[2,22]),t(o,[2,6]),{4:29,26:n,27:r,28:i},{12:[1,30]},{14:[1,31]},{16:[1,32]},{18:[1,33]},t(l,[2,13]),t(l,[2,14]),t(l,[2,15]),t(l,u,{21:8,9:16,10:17,5:24,1:[2,4],11:h,13:f,15:d,17:p,19:g,20:y,29:a}),t(b,[2,16]),{25:34,31:[1,35]},t(b,[2,24]),t(o,[2,7]),t(l,[2,9]),t(l,[2,10]),t(l,[2,11]),t(l,[2,12]),{23:36,32:m},{32:[2,23]},t(b,[2,17])],defaultActions:{9:[2,21],10:[2,1],11:[2,2],35:[2,23]},parseError:function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t);},parse:function(t){var e=this,n=[0],r=[],i=[null],a=[],o=this.table,s="",c=0,l=0,u=0,h=2,f=1,d=a.slice.call(arguments,1),p=Object.create(this.lexer),g={yy:{}};for(var y in this.yy)Object.prototype.hasOwnProperty.call(this.yy,y)&&(g.yy[y]=this.yy[y]);p.setInput(t,g.yy),g.yy.lexer=p,g.yy.parser=this,void 0===p.yylloc&&(p.yylloc={});var m=p.yylloc;a.push(m);var b=p.options&&p.options.ranges;function v(){var t;return "number"!=typeof(t=r.pop()||p.lex()||f)&&(t instanceof Array&&(t=(r=t).pop()),t=e.symbols_[t]||t),t}"function"==typeof g.yy.parseError?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var _,x,k,w,T,E,C,S,A,M={};;){if(k=n[n.length-1],this.defaultActions[k]?w=this.defaultActions[k]:(null==_&&(_=v()),w=o[k]&&o[k][_]),void 0===w||!w.length||!w[0]){var N="";for(E in A=[],o[k])this.terminals_[E]&&E>h&&A.push("'"+this.terminals_[E]+"'");N=p.showPosition?"Parse error on line "+(c+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[_]||_)+"'":"Parse error on line "+(c+1)+": Unexpected "+(_==f?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(N,{text:p.match,token:this.terminals_[_]||_,line:p.yylineno,loc:m,expected:A});}if(w[0]instanceof Array&&w.length>1)throw new Error("Parse Error: multiple actions possible at state: "+k+", token: "+_);switch(w[0]){case 1:n.push(_),i.push(p.yytext),a.push(p.yylloc),n.push(w[1]),_=null,x?(_=x,x=null):(l=p.yyleng,s=p.yytext,c=p.yylineno,m=p.yylloc,u>0&&u--);break;case 2:if(C=this.productions_[w[1]][1],M.$=i[i.length-C],M._$={first_line:a[a.length-(C||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(C||1)].first_column,last_column:a[a.length-1].last_column},b&&(M._$.range=[a[a.length-(C||1)].range[0],a[a.length-1].range[1]]),void 0!==(T=this.performAction.apply(M,[s,l,c,g.yy,w[1],i,a].concat(d))))return T;C&&(n=n.slice(0,-1*C*2),i=i.slice(0,-1*C),a=a.slice(0,-1*C)),n.push(this.productions_[w[1]][0]),i.push(M.$),a.push(M._$),S=o[n[n.length-2]][n[n.length-1]],n.push(S);break;case 3:return !0}}return !0}},_={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e);},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t));},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return (t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var n,r,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(r=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in i)this[a]=i[a];return !1}return !1},next:function(){if(this.done)return this.EOF;var t,e,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),a=0;a<i.length;a++)if((n=this._input.match(this.rules[i[a]]))&&(!e||n[0].length>e[0].length)){if(e=n,r=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,i[a])))return t;if(this._backtrack){e=!1;continue}return !1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[r]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(t){this.conditionStack.push(t);},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return (t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t);},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,n,r){switch(n){case 0:return this.begin("open_directive"),29;case 1:return this.begin("type_directive"),30;case 2:return this.popState(),this.begin("arg_directive"),24;case 3:return this.popState(),this.popState(),32;case 4:return 31;case 5:case 6:case 8:case 9:break;case 7:return 26;case 10:return this.begin("title"),13;case 11:return this.popState(),"title_value";case 12:return this.begin("acc_title"),15;case 13:return this.popState(),"acc_title_value";case 14:return this.begin("acc_descr"),17;case 15:return this.popState(),"acc_descr_value";case 16:this.begin("acc_descr_multiline");break;case 17:case 20:this.popState();break;case 18:return "acc_descr_multiline_value";case 19:this.begin("string");break;case 21:return "txt";case 22:return 6;case 23:return 8;case 24:return "value";case 25:return 28}},rules:[/^(?:%%\{)/i,/^(?:((?:(?!\}%%)[^:.])*))/i,/^(?::)/i,/^(?:\}%%)/i,/^(?:((?:(?!\}%%).|\n)*))/i,/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[\n\r]+)/i,/^(?:%%[^\n]*)/i,/^(?:[\s]+)/i,/^(?:title\b)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:["])/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:pie\b)/i,/^(?:showData\b)/i,/^(?::[\s]*[\d]+(?:\.[\d]+)?)/i,/^(?:$)/i],conditions:{acc_descr_multiline:{rules:[17,18],inclusive:!1},acc_descr:{rules:[15],inclusive:!1},acc_title:{rules:[13],inclusive:!1},close_directive:{rules:[],inclusive:!1},arg_directive:{rules:[3,4],inclusive:!1},type_directive:{rules:[2,3],inclusive:!1},open_directive:{rules:[1],inclusive:!1},title:{rules:[11],inclusive:!1},string:{rules:[20,21],inclusive:!1},INITIAL:{rules:[0,5,6,7,8,9,10,12,14,16,19,22,23,24,25],inclusive:!0}}};function x(){this.yy={};}return v.lexer=_,x.prototype=v,v.Parser=x,new x}();e.parser=r,e.Parser=r.Parser,e.parse=function(){return r.parse.apply(r,arguments)},e.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var r=n(4551).readFileSync(n(6470).normalize(t[1]),"utf8");return e.parser.parse(r)},n.c[n.s]===t&&e.main(process.argv.slice(1));},3176:(t,e,n)=>{t=n.nmd(t);var r=function(){var t=function(t,e,n,r){for(n=n||{},r=t.length;r--;n[t[r]]=e);return n},e=[1,3],n=[1,5],r=[1,6],i=[1,7],a=[1,8],o=[5,6,8,14,16,18,19,40,41,42,43,44,45,53,71,72],s=[1,22],c=[2,13],l=[1,26],u=[1,27],h=[1,28],f=[1,29],d=[1,30],p=[1,31],g=[1,24],y=[1,32],m=[1,33],b=[1,36],v=[71,72],_=[5,8,14,16,18,19,40,41,42,43,44,45,53,60,62,71,72],x=[1,56],k=[1,57],w=[1,58],T=[1,59],E=[1,60],C=[1,61],S=[1,62],A=[62,63],M=[1,74],N=[1,70],O=[1,71],D=[1,72],B=[1,73],L=[1,75],I=[1,79],F=[1,80],R=[1,77],P=[1,78],j=[5,8,14,16,18,19,40,41,42,43,44,45,53,71,72],z={trace:function(){},yy:{},symbols_:{error:2,start:3,directive:4,NEWLINE:5,RD:6,diagram:7,EOF:8,openDirective:9,typeDirective:10,closeDirective:11,":":12,argDirective:13,acc_title:14,acc_title_value:15,acc_descr:16,acc_descr_value:17,acc_descr_multiline_value:18,open_directive:19,type_directive:20,arg_directive:21,close_directive:22,requirementDef:23,elementDef:24,relationshipDef:25,requirementType:26,requirementName:27,STRUCT_START:28,requirementBody:29,ID:30,COLONSEP:31,id:32,TEXT:33,text:34,RISK:35,riskLevel:36,VERIFYMTHD:37,verifyType:38,STRUCT_STOP:39,REQUIREMENT:40,FUNCTIONAL_REQUIREMENT:41,INTERFACE_REQUIREMENT:42,PERFORMANCE_REQUIREMENT:43,PHYSICAL_REQUIREMENT:44,DESIGN_CONSTRAINT:45,LOW_RISK:46,MED_RISK:47,HIGH_RISK:48,VERIFY_ANALYSIS:49,VERIFY_DEMONSTRATION:50,VERIFY_INSPECTION:51,VERIFY_TEST:52,ELEMENT:53,elementName:54,elementBody:55,TYPE:56,type:57,DOCREF:58,ref:59,END_ARROW_L:60,relationship:61,LINE:62,END_ARROW_R:63,CONTAINS:64,COPIES:65,DERIVES:66,SATISFIES:67,VERIFIES:68,REFINES:69,TRACES:70,unqString:71,qString:72,$accept:0,$end:1},terminals_:{2:"error",5:"NEWLINE",6:"RD",8:"EOF",12:":",14:"acc_title",15:"acc_title_value",16:"acc_descr",17:"acc_descr_value",18:"acc_descr_multiline_value",19:"open_directive",20:"type_directive",21:"arg_directive",22:"close_directive",28:"STRUCT_START",30:"ID",31:"COLONSEP",33:"TEXT",35:"RISK",37:"VERIFYMTHD",39:"STRUCT_STOP",40:"REQUIREMENT",41:"FUNCTIONAL_REQUIREMENT",42:"INTERFACE_REQUIREMENT",43:"PERFORMANCE_REQUIREMENT",44:"PHYSICAL_REQUIREMENT",45:"DESIGN_CONSTRAINT",46:"LOW_RISK",47:"MED_RISK",48:"HIGH_RISK",49:"VERIFY_ANALYSIS",50:"VERIFY_DEMONSTRATION",51:"VERIFY_INSPECTION",52:"VERIFY_TEST",53:"ELEMENT",56:"TYPE",58:"DOCREF",60:"END_ARROW_L",62:"LINE",63:"END_ARROW_R",64:"CONTAINS",65:"COPIES",66:"DERIVES",67:"SATISFIES",68:"VERIFIES",69:"REFINES",70:"TRACES",71:"unqString",72:"qString"},productions_:[0,[3,3],[3,2],[3,4],[4,3],[4,5],[4,2],[4,2],[4,1],[9,1],[10,1],[13,1],[11,1],[7,0],[7,2],[7,2],[7,2],[7,2],[7,2],[23,5],[29,5],[29,5],[29,5],[29,5],[29,2],[29,1],[26,1],[26,1],[26,1],[26,1],[26,1],[26,1],[36,1],[36,1],[36,1],[38,1],[38,1],[38,1],[38,1],[24,5],[55,5],[55,5],[55,2],[55,1],[25,5],[25,5],[61,1],[61,1],[61,1],[61,1],[61,1],[61,1],[61,1],[27,1],[27,1],[32,1],[32,1],[34,1],[34,1],[54,1],[54,1],[57,1],[57,1],[59,1],[59,1]],performAction:function(t,e,n,r,i,a,o){var s=a.length-1;switch(i){case 6:this.$=a[s].trim(),r.setAccTitle(this.$);break;case 7:case 8:this.$=a[s].trim(),r.setAccDescription(this.$);break;case 9:r.parseDirective("%%{","open_directive");break;case 10:r.parseDirective(a[s],"type_directive");break;case 11:a[s]=a[s].trim().replace(/'/g,'"'),r.parseDirective(a[s],"arg_directive");break;case 12:r.parseDirective("}%%","close_directive","pie");break;case 13:this.$=[];break;case 19:r.addRequirement(a[s-3],a[s-4]);break;case 20:r.setNewReqId(a[s-2]);break;case 21:r.setNewReqText(a[s-2]);break;case 22:r.setNewReqRisk(a[s-2]);break;case 23:r.setNewReqVerifyMethod(a[s-2]);break;case 26:this.$=r.RequirementType.REQUIREMENT;break;case 27:this.$=r.RequirementType.FUNCTIONAL_REQUIREMENT;break;case 28:this.$=r.RequirementType.INTERFACE_REQUIREMENT;break;case 29:this.$=r.RequirementType.PERFORMANCE_REQUIREMENT;break;case 30:this.$=r.RequirementType.PHYSICAL_REQUIREMENT;break;case 31:this.$=r.RequirementType.DESIGN_CONSTRAINT;break;case 32:this.$=r.RiskLevel.LOW_RISK;break;case 33:this.$=r.RiskLevel.MED_RISK;break;case 34:this.$=r.RiskLevel.HIGH_RISK;break;case 35:this.$=r.VerifyType.VERIFY_ANALYSIS;break;case 36:this.$=r.VerifyType.VERIFY_DEMONSTRATION;break;case 37:this.$=r.VerifyType.VERIFY_INSPECTION;break;case 38:this.$=r.VerifyType.VERIFY_TEST;break;case 39:r.addElement(a[s-3]);break;case 40:r.setNewElementType(a[s-2]);break;case 41:r.setNewElementDocRef(a[s-2]);break;case 44:r.addRelationship(a[s-2],a[s],a[s-4]);break;case 45:r.addRelationship(a[s-2],a[s-4],a[s]);break;case 46:this.$=r.Relationships.CONTAINS;break;case 47:this.$=r.Relationships.COPIES;break;case 48:this.$=r.Relationships.DERIVES;break;case 49:this.$=r.Relationships.SATISFIES;break;case 50:this.$=r.Relationships.VERIFIES;break;case 51:this.$=r.Relationships.REFINES;break;case 52:this.$=r.Relationships.TRACES;}},table:[{3:1,4:2,6:e,9:4,14:n,16:r,18:i,19:a},{1:[3]},{3:10,4:2,5:[1,9],6:e,9:4,14:n,16:r,18:i,19:a},{5:[1,11]},{10:12,20:[1,13]},{15:[1,14]},{17:[1,15]},t(o,[2,8]),{20:[2,9]},{3:16,4:2,6:e,9:4,14:n,16:r,18:i,19:a},{1:[2,2]},{4:21,5:s,7:17,8:c,9:4,14:n,16:r,18:i,19:a,23:18,24:19,25:20,26:23,32:25,40:l,41:u,42:h,43:f,44:d,45:p,53:g,71:y,72:m},{11:34,12:[1,35],22:b},t([12,22],[2,10]),t(o,[2,6]),t(o,[2,7]),{1:[2,1]},{8:[1,37]},{4:21,5:s,7:38,8:c,9:4,14:n,16:r,18:i,19:a,23:18,24:19,25:20,26:23,32:25,40:l,41:u,42:h,43:f,44:d,45:p,53:g,71:y,72:m},{4:21,5:s,7:39,8:c,9:4,14:n,16:r,18:i,19:a,23:18,24:19,25:20,26:23,32:25,40:l,41:u,42:h,43:f,44:d,45:p,53:g,71:y,72:m},{4:21,5:s,7:40,8:c,9:4,14:n,16:r,18:i,19:a,23:18,24:19,25:20,26:23,32:25,40:l,41:u,42:h,43:f,44:d,45:p,53:g,71:y,72:m},{4:21,5:s,7:41,8:c,9:4,14:n,16:r,18:i,19:a,23:18,24:19,25:20,26:23,32:25,40:l,41:u,42:h,43:f,44:d,45:p,53:g,71:y,72:m},{4:21,5:s,7:42,8:c,9:4,14:n,16:r,18:i,19:a,23:18,24:19,25:20,26:23,32:25,40:l,41:u,42:h,43:f,44:d,45:p,53:g,71:y,72:m},{27:43,71:[1,44],72:[1,45]},{54:46,71:[1,47],72:[1,48]},{60:[1,49],62:[1,50]},t(v,[2,26]),t(v,[2,27]),t(v,[2,28]),t(v,[2,29]),t(v,[2,30]),t(v,[2,31]),t(_,[2,55]),t(_,[2,56]),t(o,[2,4]),{13:51,21:[1,52]},t(o,[2,12]),{1:[2,3]},{8:[2,14]},{8:[2,15]},{8:[2,16]},{8:[2,17]},{8:[2,18]},{28:[1,53]},{28:[2,53]},{28:[2,54]},{28:[1,54]},{28:[2,59]},{28:[2,60]},{61:55,64:x,65:k,66:w,67:T,68:E,69:C,70:S},{61:63,64:x,65:k,66:w,67:T,68:E,69:C,70:S},{11:64,22:b},{22:[2,11]},{5:[1,65]},{5:[1,66]},{62:[1,67]},t(A,[2,46]),t(A,[2,47]),t(A,[2,48]),t(A,[2,49]),t(A,[2,50]),t(A,[2,51]),t(A,[2,52]),{63:[1,68]},t(o,[2,5]),{5:M,29:69,30:N,33:O,35:D,37:B,39:L},{5:I,39:F,55:76,56:R,58:P},{32:81,71:y,72:m},{32:82,71:y,72:m},t(j,[2,19]),{31:[1,83]},{31:[1,84]},{31:[1,85]},{31:[1,86]},{5:M,29:87,30:N,33:O,35:D,37:B,39:L},t(j,[2,25]),t(j,[2,39]),{31:[1,88]},{31:[1,89]},{5:I,39:F,55:90,56:R,58:P},t(j,[2,43]),t(j,[2,44]),t(j,[2,45]),{32:91,71:y,72:m},{34:92,71:[1,93],72:[1,94]},{36:95,46:[1,96],47:[1,97],48:[1,98]},{38:99,49:[1,100],50:[1,101],51:[1,102],52:[1,103]},t(j,[2,24]),{57:104,71:[1,105],72:[1,106]},{59:107,71:[1,108],72:[1,109]},t(j,[2,42]),{5:[1,110]},{5:[1,111]},{5:[2,57]},{5:[2,58]},{5:[1,112]},{5:[2,32]},{5:[2,33]},{5:[2,34]},{5:[1,113]},{5:[2,35]},{5:[2,36]},{5:[2,37]},{5:[2,38]},{5:[1,114]},{5:[2,61]},{5:[2,62]},{5:[1,115]},{5:[2,63]},{5:[2,64]},{5:M,29:116,30:N,33:O,35:D,37:B,39:L},{5:M,29:117,30:N,33:O,35:D,37:B,39:L},{5:M,29:118,30:N,33:O,35:D,37:B,39:L},{5:M,29:119,30:N,33:O,35:D,37:B,39:L},{5:I,39:F,55:120,56:R,58:P},{5:I,39:F,55:121,56:R,58:P},t(j,[2,20]),t(j,[2,21]),t(j,[2,22]),t(j,[2,23]),t(j,[2,40]),t(j,[2,41])],defaultActions:{8:[2,9],10:[2,2],16:[2,1],37:[2,3],38:[2,14],39:[2,15],40:[2,16],41:[2,17],42:[2,18],44:[2,53],45:[2,54],47:[2,59],48:[2,60],52:[2,11],93:[2,57],94:[2,58],96:[2,32],97:[2,33],98:[2,34],100:[2,35],101:[2,36],102:[2,37],103:[2,38],105:[2,61],106:[2,62],108:[2,63],109:[2,64]},parseError:function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t);},parse:function(t){var e=this,n=[0],r=[],i=[null],a=[],o=this.table,s="",c=0,l=0,u=0,h=2,f=1,d=a.slice.call(arguments,1),p=Object.create(this.lexer),g={yy:{}};for(var y in this.yy)Object.prototype.hasOwnProperty.call(this.yy,y)&&(g.yy[y]=this.yy[y]);p.setInput(t,g.yy),g.yy.lexer=p,g.yy.parser=this,void 0===p.yylloc&&(p.yylloc={});var m=p.yylloc;a.push(m);var b=p.options&&p.options.ranges;function v(){var t;return "number"!=typeof(t=r.pop()||p.lex()||f)&&(t instanceof Array&&(t=(r=t).pop()),t=e.symbols_[t]||t),t}"function"==typeof g.yy.parseError?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var _,x,k,w,T,E,C,S,A,M={};;){if(k=n[n.length-1],this.defaultActions[k]?w=this.defaultActions[k]:(null==_&&(_=v()),w=o[k]&&o[k][_]),void 0===w||!w.length||!w[0]){var N="";for(E in A=[],o[k])this.terminals_[E]&&E>h&&A.push("'"+this.terminals_[E]+"'");N=p.showPosition?"Parse error on line "+(c+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[_]||_)+"'":"Parse error on line "+(c+1)+": Unexpected "+(_==f?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(N,{text:p.match,token:this.terminals_[_]||_,line:p.yylineno,loc:m,expected:A});}if(w[0]instanceof Array&&w.length>1)throw new Error("Parse Error: multiple actions possible at state: "+k+", token: "+_);switch(w[0]){case 1:n.push(_),i.push(p.yytext),a.push(p.yylloc),n.push(w[1]),_=null,x?(_=x,x=null):(l=p.yyleng,s=p.yytext,c=p.yylineno,m=p.yylloc,u>0&&u--);break;case 2:if(C=this.productions_[w[1]][1],M.$=i[i.length-C],M._$={first_line:a[a.length-(C||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(C||1)].first_column,last_column:a[a.length-1].last_column},b&&(M._$.range=[a[a.length-(C||1)].range[0],a[a.length-1].range[1]]),void 0!==(T=this.performAction.apply(M,[s,l,c,g.yy,w[1],i,a].concat(d))))return T;C&&(n=n.slice(0,-1*C*2),i=i.slice(0,-1*C),a=a.slice(0,-1*C)),n.push(this.productions_[w[1]][0]),i.push(M.$),a.push(M._$),S=o[n[n.length-2]][n[n.length-1]],n.push(S);break;case 3:return !0}}return !0}},Y={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e);},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t));},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return (t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var n,r,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(r=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in i)this[a]=i[a];return !1}return !1},next:function(){if(this.done)return this.EOF;var t,e,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),a=0;a<i.length;a++)if((n=this._input.match(this.rules[i[a]]))&&(!e||n[0].length>e[0].length)){if(e=n,r=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,i[a])))return t;if(this._backtrack){e=!1;continue}return !1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[r]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(t){this.conditionStack.push(t);},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return (t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t);},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,n,r){switch(n){case 0:return this.begin("open_directive"),19;case 1:return this.begin("type_directive"),20;case 2:return this.popState(),this.begin("arg_directive"),12;case 3:return this.popState(),this.popState(),22;case 4:return 21;case 5:return "title";case 6:return this.begin("acc_title"),14;case 7:return this.popState(),"acc_title_value";case 8:return this.begin("acc_descr"),16;case 9:return this.popState(),"acc_descr_value";case 10:this.begin("acc_descr_multiline");break;case 11:case 53:this.popState();break;case 12:return "acc_descr_multiline_value";case 13:return 5;case 14:case 15:case 16:break;case 17:return 8;case 18:return 6;case 19:return 28;case 20:return 39;case 21:return 31;case 22:return 30;case 23:return 33;case 24:return 35;case 25:return 37;case 26:return 40;case 27:return 41;case 28:return 42;case 29:return 43;case 30:return 44;case 31:return 45;case 32:return 46;case 33:return 47;case 34:return 48;case 35:return 49;case 36:return 50;case 37:return 51;case 38:return 52;case 39:return 53;case 40:return 64;case 41:return 65;case 42:return 66;case 43:return 67;case 44:return 68;case 45:return 69;case 46:return 70;case 47:return 56;case 48:return 58;case 49:return 60;case 50:return 63;case 51:return 62;case 52:this.begin("string");break;case 54:return "qString";case 55:return e.yytext=e.yytext.trim(),71}},rules:[/^(?:%%\{)/i,/^(?:((?:(?!\}%%)[^:.])*))/i,/^(?::)/i,/^(?:\}%%)/i,/^(?:((?:(?!\}%%).|\n)*))/i,/^(?:title\s[^#\n;]+)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:(\r?\n)+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:%[^\n]*)/i,/^(?:$)/i,/^(?:requirementDiagram\b)/i,/^(?:\{)/i,/^(?:\})/i,/^(?::)/i,/^(?:id\b)/i,/^(?:text\b)/i,/^(?:risk\b)/i,/^(?:verifyMethod\b)/i,/^(?:requirement\b)/i,/^(?:functionalRequirement\b)/i,/^(?:interfaceRequirement\b)/i,/^(?:performanceRequirement\b)/i,/^(?:physicalRequirement\b)/i,/^(?:designConstraint\b)/i,/^(?:low\b)/i,/^(?:medium\b)/i,/^(?:high\b)/i,/^(?:analysis\b)/i,/^(?:demonstration\b)/i,/^(?:inspection\b)/i,/^(?:test\b)/i,/^(?:element\b)/i,/^(?:contains\b)/i,/^(?:copies\b)/i,/^(?:derives\b)/i,/^(?:satisfies\b)/i,/^(?:verifies\b)/i,/^(?:refines\b)/i,/^(?:traces\b)/i,/^(?:type\b)/i,/^(?:docref\b)/i,/^(?:<-)/i,/^(?:->)/i,/^(?:-)/i,/^(?:["])/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:[\w][^\r\n\{\<\>\-\=]*)/i],conditions:{acc_descr_multiline:{rules:[11,12],inclusive:!1},acc_descr:{rules:[9],inclusive:!1},acc_title:{rules:[7],inclusive:!1},close_directive:{rules:[],inclusive:!1},arg_directive:{rules:[3,4],inclusive:!1},type_directive:{rules:[2,3],inclusive:!1},open_directive:{rules:[1],inclusive:!1},unqString:{rules:[],inclusive:!1},token:{rules:[],inclusive:!1},string:{rules:[53,54],inclusive:!1},INITIAL:{rules:[0,5,6,8,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,55],inclusive:!0}}};function U(){this.yy={};}return z.lexer=Y,U.prototype=z,z.Parser=U,new U}();e.parser=r,e.Parser=r.Parser,e.parse=function(){return r.parse.apply(r,arguments)},e.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var r=n(8800).readFileSync(n(6470).normalize(t[1]),"utf8");return e.parser.parse(r)},n.c[n.s]===t&&e.main(process.argv.slice(1));},6876:(t,e,n)=>{t=n.nmd(t);var r=function(){var t=function(t,e,n,r){for(n=n||{},r=t.length;r--;n[t[r]]=e);return n},e=[1,2],n=[1,3],r=[1,5],i=[1,7],a=[2,5],o=[1,15],s=[1,17],c=[1,18],l=[1,19],u=[1,21],h=[1,22],f=[1,23],d=[1,29],p=[1,30],g=[1,31],y=[1,32],m=[1,33],b=[1,34],v=[1,35],_=[1,36],x=[1,37],k=[1,38],w=[1,39],T=[1,40],E=[1,43],C=[1,44],S=[1,45],A=[1,46],M=[1,47],N=[1,48],O=[1,51],D=[1,4,5,16,20,22,25,26,32,33,34,36,38,39,40,41,42,43,45,47,49,50,51,52,53,58,59,60,61,69,79],B=[4,5,16,20,22,25,26,32,33,34,36,38,39,40,41,42,43,45,47,49,53,58,59,60,61,69,79],L=[4,5,16,20,22,25,26,32,33,34,36,38,39,40,41,42,43,45,47,49,52,53,58,59,60,61,69,79],I=[4,5,16,20,22,25,26,32,33,34,36,38,39,40,41,42,43,45,47,49,51,53,58,59,60,61,69,79],F=[4,5,16,20,22,25,26,32,33,34,36,38,39,40,41,42,43,45,47,49,50,53,58,59,60,61,69,79],R=[67,68,69],P=[1,121],j=[1,4,5,7,16,20,22,25,26,32,33,34,36,38,39,40,41,42,43,45,47,49,50,51,52,53,58,59,60,61,69,79],z={trace:function(){},yy:{},symbols_:{error:2,start:3,SPACE:4,NEWLINE:5,directive:6,SD:7,document:8,line:9,statement:10,openDirective:11,typeDirective:12,closeDirective:13,":":14,argDirective:15,participant:16,actor:17,AS:18,restOfLine:19,participant_actor:20,signal:21,autonumber:22,NUM:23,off:24,activate:25,deactivate:26,note_statement:27,links_statement:28,link_statement:29,properties_statement:30,details_statement:31,title:32,legacy_title:33,acc_title:34,acc_title_value:35,acc_descr:36,acc_descr_value:37,acc_descr_multiline_value:38,loop:39,end:40,rect:41,opt:42,alt:43,else_sections:44,par:45,par_sections:46,critical:47,option_sections:48,break:49,option:50,and:51,else:52,note:53,placement:54,text2:55,over:56,actor_pair:57,links:58,link:59,properties:60,details:61,spaceList:62,",":63,left_of:64,right_of:65,signaltype:66,"+":67,"-":68,ACTOR:69,SOLID_OPEN_ARROW:70,DOTTED_OPEN_ARROW:71,SOLID_ARROW:72,DOTTED_ARROW:73,SOLID_CROSS:74,DOTTED_CROSS:75,SOLID_POINT:76,DOTTED_POINT:77,TXT:78,open_directive:79,type_directive:80,arg_directive:81,close_directive:82,$accept:0,$end:1},terminals_:{2:"error",4:"SPACE",5:"NEWLINE",7:"SD",14:":",16:"participant",18:"AS",19:"restOfLine",20:"participant_actor",22:"autonumber",23:"NUM",24:"off",25:"activate",26:"deactivate",32:"title",33:"legacy_title",34:"acc_title",35:"acc_title_value",36:"acc_descr",37:"acc_descr_value",38:"acc_descr_multiline_value",39:"loop",40:"end",41:"rect",42:"opt",43:"alt",45:"par",47:"critical",49:"break",50:"option",51:"and",52:"else",53:"note",56:"over",58:"links",59:"link",60:"properties",61:"details",63:",",64:"left_of",65:"right_of",67:"+",68:"-",69:"ACTOR",70:"SOLID_OPEN_ARROW",71:"DOTTED_OPEN_ARROW",72:"SOLID_ARROW",73:"DOTTED_ARROW",74:"SOLID_CROSS",75:"DOTTED_CROSS",76:"SOLID_POINT",77:"DOTTED_POINT",78:"TXT",79:"open_directive",80:"type_directive",81:"arg_directive",82:"close_directive"},productions_:[0,[3,2],[3,2],[3,2],[3,2],[8,0],[8,2],[9,2],[9,1],[9,1],[6,4],[6,6],[10,5],[10,3],[10,5],[10,3],[10,2],[10,4],[10,3],[10,3],[10,2],[10,3],[10,3],[10,2],[10,2],[10,2],[10,2],[10,2],[10,1],[10,1],[10,2],[10,2],[10,1],[10,4],[10,4],[10,4],[10,4],[10,4],[10,4],[10,4],[10,1],[48,1],[48,4],[46,1],[46,4],[44,1],[44,4],[27,4],[27,4],[28,3],[29,3],[30,3],[31,3],[62,2],[62,1],[57,3],[57,1],[54,1],[54,1],[21,5],[21,5],[21,4],[17,1],[66,1],[66,1],[66,1],[66,1],[66,1],[66,1],[66,1],[66,1],[55,1],[11,1],[12,1],[15,1],[13,1]],performAction:function(t,e,n,r,i,a,o){var s=a.length-1;switch(i){case 4:return r.apply(a[s]),a[s];case 5:case 9:this.$=[];break;case 6:a[s-1].push(a[s]),this.$=a[s-1];break;case 7:case 8:case 56:this.$=a[s];break;case 12:a[s-3].type="addParticipant",a[s-3].description=r.parseMessage(a[s-1]),this.$=a[s-3];break;case 13:a[s-1].type="addParticipant",this.$=a[s-1];break;case 14:a[s-3].type="addActor",a[s-3].description=r.parseMessage(a[s-1]),this.$=a[s-3];break;case 15:a[s-1].type="addActor",this.$=a[s-1];break;case 17:this.$={type:"sequenceIndex",sequenceIndex:Number(a[s-2]),sequenceIndexStep:Number(a[s-1]),sequenceVisible:!0,signalType:r.LINETYPE.AUTONUMBER};break;case 18:this.$={type:"sequenceIndex",sequenceIndex:Number(a[s-1]),sequenceIndexStep:1,sequenceVisible:!0,signalType:r.LINETYPE.AUTONUMBER};break;case 19:this.$={type:"sequenceIndex",sequenceVisible:!1,signalType:r.LINETYPE.AUTONUMBER};break;case 20:this.$={type:"sequenceIndex",sequenceVisible:!0,signalType:r.LINETYPE.AUTONUMBER};break;case 21:this.$={type:"activeStart",signalType:r.LINETYPE.ACTIVE_START,actor:a[s-1]};break;case 22:this.$={type:"activeEnd",signalType:r.LINETYPE.ACTIVE_END,actor:a[s-1]};break;case 28:r.setDiagramTitle(a[s].substring(6)),this.$=a[s].substring(6);break;case 29:r.setDiagramTitle(a[s].substring(7)),this.$=a[s].substring(7);break;case 30:this.$=a[s].trim(),r.setAccTitle(this.$);break;case 31:case 32:this.$=a[s].trim(),r.setAccDescription(this.$);break;case 33:a[s-1].unshift({type:"loopStart",loopText:r.parseMessage(a[s-2]),signalType:r.LINETYPE.LOOP_START}),a[s-1].push({type:"loopEnd",loopText:a[s-2],signalType:r.LINETYPE.LOOP_END}),this.$=a[s-1];break;case 34:a[s-1].unshift({type:"rectStart",color:r.parseMessage(a[s-2]),signalType:r.LINETYPE.RECT_START}),a[s-1].push({type:"rectEnd",color:r.parseMessage(a[s-2]),signalType:r.LINETYPE.RECT_END}),this.$=a[s-1];break;case 35:a[s-1].unshift({type:"optStart",optText:r.parseMessage(a[s-2]),signalType:r.LINETYPE.OPT_START}),a[s-1].push({type:"optEnd",optText:r.parseMessage(a[s-2]),signalType:r.LINETYPE.OPT_END}),this.$=a[s-1];break;case 36:a[s-1].unshift({type:"altStart",altText:r.parseMessage(a[s-2]),signalType:r.LINETYPE.ALT_START}),a[s-1].push({type:"altEnd",signalType:r.LINETYPE.ALT_END}),this.$=a[s-1];break;case 37:a[s-1].unshift({type:"parStart",parText:r.parseMessage(a[s-2]),signalType:r.LINETYPE.PAR_START}),a[s-1].push({type:"parEnd",signalType:r.LINETYPE.PAR_END}),this.$=a[s-1];break;case 38:a[s-1].unshift({type:"criticalStart",criticalText:r.parseMessage(a[s-2]),signalType:r.LINETYPE.CRITICAL_START}),a[s-1].push({type:"criticalEnd",signalType:r.LINETYPE.CRITICAL_END}),this.$=a[s-1];break;case 39:a[s-1].unshift({type:"breakStart",breakText:r.parseMessage(a[s-2]),signalType:r.LINETYPE.BREAK_START}),a[s-1].push({type:"breakEnd",optText:r.parseMessage(a[s-2]),signalType:r.LINETYPE.BREAK_END}),this.$=a[s-1];break;case 42:this.$=a[s-3].concat([{type:"option",optionText:r.parseMessage(a[s-1]),signalType:r.LINETYPE.CRITICAL_OPTION},a[s]]);break;case 44:this.$=a[s-3].concat([{type:"and",parText:r.parseMessage(a[s-1]),signalType:r.LINETYPE.PAR_AND},a[s]]);break;case 46:this.$=a[s-3].concat([{type:"else",altText:r.parseMessage(a[s-1]),signalType:r.LINETYPE.ALT_ELSE},a[s]]);break;case 47:this.$=[a[s-1],{type:"addNote",placement:a[s-2],actor:a[s-1].actor,text:a[s]}];break;case 48:a[s-2]=[].concat(a[s-1],a[s-1]).slice(0,2),a[s-2][0]=a[s-2][0].actor,a[s-2][1]=a[s-2][1].actor,this.$=[a[s-1],{type:"addNote",placement:r.PLACEMENT.OVER,actor:a[s-2].slice(0,2),text:a[s]}];break;case 49:this.$=[a[s-1],{type:"addLinks",actor:a[s-1].actor,text:a[s]}];break;case 50:this.$=[a[s-1],{type:"addALink",actor:a[s-1].actor,text:a[s]}];break;case 51:this.$=[a[s-1],{type:"addProperties",actor:a[s-1].actor,text:a[s]}];break;case 52:this.$=[a[s-1],{type:"addDetails",actor:a[s-1].actor,text:a[s]}];break;case 55:this.$=[a[s-2],a[s]];break;case 57:this.$=r.PLACEMENT.LEFTOF;break;case 58:this.$=r.PLACEMENT.RIGHTOF;break;case 59:this.$=[a[s-4],a[s-1],{type:"addMessage",from:a[s-4].actor,to:a[s-1].actor,signalType:a[s-3],msg:a[s]},{type:"activeStart",signalType:r.LINETYPE.ACTIVE_START,actor:a[s-1]}];break;case 60:this.$=[a[s-4],a[s-1],{type:"addMessage",from:a[s-4].actor,to:a[s-1].actor,signalType:a[s-3],msg:a[s]},{type:"activeEnd",signalType:r.LINETYPE.ACTIVE_END,actor:a[s-4]}];break;case 61:this.$=[a[s-3],a[s-1],{type:"addMessage",from:a[s-3].actor,to:a[s-1].actor,signalType:a[s-2],msg:a[s]}];break;case 62:this.$={type:"addParticipant",actor:a[s]};break;case 63:this.$=r.LINETYPE.SOLID_OPEN;break;case 64:this.$=r.LINETYPE.DOTTED_OPEN;break;case 65:this.$=r.LINETYPE.SOLID;break;case 66:this.$=r.LINETYPE.DOTTED;break;case 67:this.$=r.LINETYPE.SOLID_CROSS;break;case 68:this.$=r.LINETYPE.DOTTED_CROSS;break;case 69:this.$=r.LINETYPE.SOLID_POINT;break;case 70:this.$=r.LINETYPE.DOTTED_POINT;break;case 71:this.$=r.parseMessage(a[s].trim().substring(1));break;case 72:r.parseDirective("%%{","open_directive");break;case 73:r.parseDirective(a[s],"type_directive");break;case 74:a[s]=a[s].trim().replace(/'/g,'"'),r.parseDirective(a[s],"arg_directive");break;case 75:r.parseDirective("}%%","close_directive","sequence");}},table:[{3:1,4:e,5:n,6:4,7:r,11:6,79:i},{1:[3]},{3:8,4:e,5:n,6:4,7:r,11:6,79:i},{3:9,4:e,5:n,6:4,7:r,11:6,79:i},{3:10,4:e,5:n,6:4,7:r,11:6,79:i},t([1,4,5,16,20,22,25,26,32,33,34,36,38,39,41,42,43,45,47,49,53,58,59,60,61,69,79],a,{8:11}),{12:12,80:[1,13]},{80:[2,72]},{1:[2,1]},{1:[2,2]},{1:[2,3]},{1:[2,4],4:o,5:s,6:41,9:14,10:16,11:6,16:c,17:42,20:l,21:20,22:u,25:h,26:f,27:24,28:25,29:26,30:27,31:28,32:d,33:p,34:g,36:y,38:m,39:b,41:v,42:_,43:x,45:k,47:w,49:T,53:E,58:C,59:S,60:A,61:M,69:N,79:i},{13:49,14:[1,50],82:O},t([14,82],[2,73]),t(D,[2,6]),{6:41,10:52,11:6,16:c,17:42,20:l,21:20,22:u,25:h,26:f,27:24,28:25,29:26,30:27,31:28,32:d,33:p,34:g,36:y,38:m,39:b,41:v,42:_,43:x,45:k,47:w,49:T,53:E,58:C,59:S,60:A,61:M,69:N,79:i},t(D,[2,8]),t(D,[2,9]),{17:53,69:N},{17:54,69:N},{5:[1,55]},{5:[1,58],23:[1,56],24:[1,57]},{17:59,69:N},{17:60,69:N},{5:[1,61]},{5:[1,62]},{5:[1,63]},{5:[1,64]},{5:[1,65]},t(D,[2,28]),t(D,[2,29]),{35:[1,66]},{37:[1,67]},t(D,[2,32]),{19:[1,68]},{19:[1,69]},{19:[1,70]},{19:[1,71]},{19:[1,72]},{19:[1,73]},{19:[1,74]},t(D,[2,40]),{66:75,70:[1,76],71:[1,77],72:[1,78],73:[1,79],74:[1,80],75:[1,81],76:[1,82],77:[1,83]},{54:84,56:[1,85],64:[1,86],65:[1,87]},{17:88,69:N},{17:89,69:N},{17:90,69:N},{17:91,69:N},t([5,18,63,70,71,72,73,74,75,76,77,78],[2,62]),{5:[1,92]},{15:93,81:[1,94]},{5:[2,75]},t(D,[2,7]),{5:[1,96],18:[1,95]},{5:[1,98],18:[1,97]},t(D,[2,16]),{5:[1,100],23:[1,99]},{5:[1,101]},t(D,[2,20]),{5:[1,102]},{5:[1,103]},t(D,[2,23]),t(D,[2,24]),t(D,[2,25]),t(D,[2,26]),t(D,[2,27]),t(D,[2,30]),t(D,[2,31]),t(B,a,{8:104}),t(B,a,{8:105}),t(B,a,{8:106}),t(L,a,{44:107,8:108}),t(I,a,{46:109,8:110}),t(F,a,{48:111,8:112}),t(B,a,{8:113}),{17:116,67:[1,114],68:[1,115],69:N},t(R,[2,63]),t(R,[2,64]),t(R,[2,65]),t(R,[2,66]),t(R,[2,67]),t(R,[2,68]),t(R,[2,69]),t(R,[2,70]),{17:117,69:N},{17:119,57:118,69:N},{69:[2,57]},{69:[2,58]},{55:120,78:P},{55:122,78:P},{55:123,78:P},{55:124,78:P},t(j,[2,10]),{13:125,82:O},{82:[2,74]},{19:[1,126]},t(D,[2,13]),{19:[1,127]},t(D,[2,15]),{5:[1,128]},t(D,[2,18]),t(D,[2,19]),t(D,[2,21]),t(D,[2,22]),{4:o,5:s,6:41,9:14,10:16,11:6,16:c,17:42,20:l,21:20,22:u,25:h,26:f,27:24,28:25,29:26,30:27,31:28,32:d,33:p,34:g,36:y,38:m,39:b,40:[1,129],41:v,42:_,43:x,45:k,47:w,49:T,53:E,58:C,59:S,60:A,61:M,69:N,79:i},{4:o,5:s,6:41,9:14,10:16,11:6,16:c,17:42,20:l,21:20,22:u,25:h,26:f,27:24,28:25,29:26,30:27,31:28,32:d,33:p,34:g,36:y,38:m,39:b,40:[1,130],41:v,42:_,43:x,45:k,47:w,49:T,53:E,58:C,59:S,60:A,61:M,69:N,79:i},{4:o,5:s,6:41,9:14,10:16,11:6,16:c,17:42,20:l,21:20,22:u,25:h,26:f,27:24,28:25,29:26,30:27,31:28,32:d,33:p,34:g,36:y,38:m,39:b,40:[1,131],41:v,42:_,43:x,45:k,47:w,49:T,53:E,58:C,59:S,60:A,61:M,69:N,79:i},{40:[1,132]},{4:o,5:s,6:41,9:14,10:16,11:6,16:c,17:42,20:l,21:20,22:u,25:h,26:f,27:24,28:25,29:26,30:27,31:28,32:d,33:p,34:g,36:y,38:m,39:b,40:[2,45],41:v,42:_,43:x,45:k,47:w,49:T,52:[1,133],53:E,58:C,59:S,60:A,61:M,69:N,79:i},{40:[1,134]},{4:o,5:s,6:41,9:14,10:16,11:6,16:c,17:42,20:l,21:20,22:u,25:h,26:f,27:24,28:25,29:26,30:27,31:28,32:d,33:p,34:g,36:y,38:m,39:b,40:[2,43],41:v,42:_,43:x,45:k,47:w,49:T,51:[1,135],53:E,58:C,59:S,60:A,61:M,69:N,79:i},{40:[1,136]},{4:o,5:s,6:41,9:14,10:16,11:6,16:c,17:42,20:l,21:20,22:u,25:h,26:f,27:24,28:25,29:26,30:27,31:28,32:d,33:p,34:g,36:y,38:m,39:b,40:[2,41],41:v,42:_,43:x,45:k,47:w,49:T,50:[1,137],53:E,58:C,59:S,60:A,61:M,69:N,79:i},{4:o,5:s,6:41,9:14,10:16,11:6,16:c,17:42,20:l,21:20,22:u,25:h,26:f,27:24,28:25,29:26,30:27,31:28,32:d,33:p,34:g,36:y,38:m,39:b,40:[1,138],41:v,42:_,43:x,45:k,47:w,49:T,53:E,58:C,59:S,60:A,61:M,69:N,79:i},{17:139,69:N},{17:140,69:N},{55:141,78:P},{55:142,78:P},{55:143,78:P},{63:[1,144],78:[2,56]},{5:[2,49]},{5:[2,71]},{5:[2,50]},{5:[2,51]},{5:[2,52]},{5:[1,145]},{5:[1,146]},{5:[1,147]},t(D,[2,17]),t(D,[2,33]),t(D,[2,34]),t(D,[2,35]),t(D,[2,36]),{19:[1,148]},t(D,[2,37]),{19:[1,149]},t(D,[2,38]),{19:[1,150]},t(D,[2,39]),{55:151,78:P},{55:152,78:P},{5:[2,61]},{5:[2,47]},{5:[2,48]},{17:153,69:N},t(j,[2,11]),t(D,[2,12]),t(D,[2,14]),t(L,a,{8:108,44:154}),t(I,a,{8:110,46:155}),t(F,a,{8:112,48:156}),{5:[2,59]},{5:[2,60]},{78:[2,55]},{40:[2,46]},{40:[2,44]},{40:[2,42]}],defaultActions:{7:[2,72],8:[2,1],9:[2,2],10:[2,3],51:[2,75],86:[2,57],87:[2,58],94:[2,74],120:[2,49],121:[2,71],122:[2,50],123:[2,51],124:[2,52],141:[2,61],142:[2,47],143:[2,48],151:[2,59],152:[2,60],153:[2,55],154:[2,46],155:[2,44],156:[2,42]},parseError:function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t);},parse:function(t){var e=this,n=[0],r=[],i=[null],a=[],o=this.table,s="",c=0,l=0,u=0,h=2,f=1,d=a.slice.call(arguments,1),p=Object.create(this.lexer),g={yy:{}};for(var y in this.yy)Object.prototype.hasOwnProperty.call(this.yy,y)&&(g.yy[y]=this.yy[y]);p.setInput(t,g.yy),g.yy.lexer=p,g.yy.parser=this,void 0===p.yylloc&&(p.yylloc={});var m=p.yylloc;a.push(m);var b=p.options&&p.options.ranges;function v(){var t;return "number"!=typeof(t=r.pop()||p.lex()||f)&&(t instanceof Array&&(t=(r=t).pop()),t=e.symbols_[t]||t),t}"function"==typeof g.yy.parseError?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var _,x,k,w,T,E,C,S,A,M={};;){if(k=n[n.length-1],this.defaultActions[k]?w=this.defaultActions[k]:(null==_&&(_=v()),w=o[k]&&o[k][_]),void 0===w||!w.length||!w[0]){var N="";for(E in A=[],o[k])this.terminals_[E]&&E>h&&A.push("'"+this.terminals_[E]+"'");N=p.showPosition?"Parse error on line "+(c+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[_]||_)+"'":"Parse error on line "+(c+1)+": Unexpected "+(_==f?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(N,{text:p.match,token:this.terminals_[_]||_,line:p.yylineno,loc:m,expected:A});}if(w[0]instanceof Array&&w.length>1)throw new Error("Parse Error: multiple actions possible at state: "+k+", token: "+_);switch(w[0]){case 1:n.push(_),i.push(p.yytext),a.push(p.yylloc),n.push(w[1]),_=null,x?(_=x,x=null):(l=p.yyleng,s=p.yytext,c=p.yylineno,m=p.yylloc,u>0&&u--);break;case 2:if(C=this.productions_[w[1]][1],M.$=i[i.length-C],M._$={first_line:a[a.length-(C||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(C||1)].first_column,last_column:a[a.length-1].last_column},b&&(M._$.range=[a[a.length-(C||1)].range[0],a[a.length-1].range[1]]),void 0!==(T=this.performAction.apply(M,[s,l,c,g.yy,w[1],i,a].concat(d))))return T;C&&(n=n.slice(0,-1*C*2),i=i.slice(0,-1*C),a=a.slice(0,-1*C)),n.push(this.productions_[w[1]][0]),i.push(M.$),a.push(M._$),S=o[n[n.length-2]][n[n.length-1]],n.push(S);break;case 3:return !0}}return !0}},Y={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e);},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t));},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return (t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var n,r,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(r=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in i)this[a]=i[a];return !1}return !1},next:function(){if(this.done)return this.EOF;var t,e,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),a=0;a<i.length;a++)if((n=this._input.match(this.rules[i[a]]))&&(!e||n[0].length>e[0].length)){if(e=n,r=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,i[a])))return t;if(this._backtrack){e=!1;continue}return !1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[r]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(t){this.conditionStack.push(t);},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return (t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t);},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,n,r){switch(n){case 0:return this.begin("open_directive"),79;case 1:return this.begin("type_directive"),80;case 2:return this.popState(),this.begin("arg_directive"),14;case 3:return this.popState(),this.popState(),82;case 4:return 81;case 5:case 52:case 65:return 5;case 6:case 7:case 8:case 9:case 10:break;case 11:return 23;case 12:return this.begin("ID"),16;case 13:return this.begin("ID"),20;case 14:return e.yytext=e.yytext.trim(),this.begin("ALIAS"),69;case 15:return this.popState(),this.popState(),this.begin("LINE"),18;case 16:return this.popState(),this.popState(),5;case 17:return this.begin("LINE"),39;case 18:return this.begin("LINE"),41;case 19:return this.begin("LINE"),42;case 20:return this.begin("LINE"),43;case 21:return this.begin("LINE"),52;case 22:return this.begin("LINE"),45;case 23:return this.begin("LINE"),51;case 24:return this.begin("LINE"),47;case 25:return this.begin("LINE"),50;case 26:return this.begin("LINE"),49;case 27:return this.popState(),19;case 28:return 40;case 29:return 64;case 30:return 65;case 31:return 58;case 32:return 59;case 33:return 60;case 34:return 61;case 35:return 56;case 36:return 53;case 37:return this.begin("ID"),25;case 38:return this.begin("ID"),26;case 39:return 32;case 40:return 33;case 41:return this.begin("acc_title"),34;case 42:return this.popState(),"acc_title_value";case 43:return this.begin("acc_descr"),36;case 44:return this.popState(),"acc_descr_value";case 45:this.begin("acc_descr_multiline");break;case 46:this.popState();break;case 47:return "acc_descr_multiline_value";case 48:return 7;case 49:return 22;case 50:return 24;case 51:return 63;case 53:return e.yytext=e.yytext.trim(),69;case 54:return 72;case 55:return 73;case 56:return 70;case 57:return 71;case 58:return 74;case 59:return 75;case 60:return 76;case 61:return 77;case 62:return 78;case 63:return 67;case 64:return 68;case 66:return "INVALID"}},rules:[/^(?:%%\{)/i,/^(?:((?:(?!\}%%)[^:.])*))/i,/^(?::)/i,/^(?:\}%%)/i,/^(?:((?:(?!\}%%).|\n)*))/i,/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:((?!\n)\s)+)/i,/^(?:#[^\n]*)/i,/^(?:%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[0-9]+(?=[ \n]+))/i,/^(?:participant\b)/i,/^(?:actor\b)/i,/^(?:[^\->:\n,;]+?(?=((?!\n)\s)+as(?!\n)\s|[#\n;]|$))/i,/^(?:as\b)/i,/^(?:(?:))/i,/^(?:loop\b)/i,/^(?:rect\b)/i,/^(?:opt\b)/i,/^(?:alt\b)/i,/^(?:else\b)/i,/^(?:par\b)/i,/^(?:and\b)/i,/^(?:critical\b)/i,/^(?:option\b)/i,/^(?:break\b)/i,/^(?:(?:[:]?(?:no)?wrap)?[^#\n;]*)/i,/^(?:end\b)/i,/^(?:left of\b)/i,/^(?:right of\b)/i,/^(?:links\b)/i,/^(?:link\b)/i,/^(?:properties\b)/i,/^(?:details\b)/i,/^(?:over\b)/i,/^(?:note\b)/i,/^(?:activate\b)/i,/^(?:deactivate\b)/i,/^(?:title\s[^#\n;]+)/i,/^(?:title:\s[^#\n;]+)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:sequenceDiagram\b)/i,/^(?:autonumber\b)/i,/^(?:off\b)/i,/^(?:,)/i,/^(?:;)/i,/^(?:[^\+\->:\n,;]+((?!(-x|--x|-\)|--\)))[\-]*[^\+\->:\n,;]+)*)/i,/^(?:->>)/i,/^(?:-->>)/i,/^(?:->)/i,/^(?:-->)/i,/^(?:-[x])/i,/^(?:--[x])/i,/^(?:-[\)])/i,/^(?:--[\)])/i,/^(?::(?:(?:no)?wrap)?[^#\n;]+)/i,/^(?:\+)/i,/^(?:-)/i,/^(?:$)/i,/^(?:.)/i],conditions:{acc_descr_multiline:{rules:[46,47],inclusive:!1},acc_descr:{rules:[44],inclusive:!1},acc_title:{rules:[42],inclusive:!1},open_directive:{rules:[1,8],inclusive:!1},type_directive:{rules:[2,3,8],inclusive:!1},arg_directive:{rules:[3,4,8],inclusive:!1},ID:{rules:[7,8,14],inclusive:!1},ALIAS:{rules:[7,8,15,16],inclusive:!1},LINE:{rules:[7,8,27],inclusive:!1},INITIAL:{rules:[0,5,6,8,9,10,11,12,13,17,18,19,20,21,22,23,24,25,26,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,45,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66],inclusive:!0}}};function U(){this.yy={};}return z.lexer=Y,U.prototype=z,z.Parser=U,new U}();e.parser=r,e.Parser=r.Parser,e.parse=function(){return r.parse.apply(r,arguments)},e.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var r=n(1993).readFileSync(n(6470).normalize(t[1]),"utf8");return e.parser.parse(r)},n.c[n.s]===t&&e.main(process.argv.slice(1));},3584:(t,e,n)=>{t=n.nmd(t);var r=function(){var t=function(t,e,n,r){for(n=n||{},r=t.length;r--;n[t[r]]=e);return n},e=[1,2],n=[1,3],r=[1,5],i=[1,7],a=[2,5],o=[1,15],s=[1,17],c=[1,19],l=[1,20],u=[1,21],h=[1,22],f=[1,33],d=[1,23],p=[1,24],g=[1,25],y=[1,26],m=[1,27],b=[1,30],v=[1,31],_=[1,32],x=[1,35],k=[1,36],w=[1,37],T=[1,38],E=[1,34],C=[1,41],S=[1,4,5,14,15,17,19,20,22,23,24,25,26,27,31,33,35,41,42,43,44,47,50],A=[1,4,5,12,13,14,15,17,19,20,22,23,24,25,26,27,31,33,35,41,42,43,44,47,50],M=[1,4,5,7,14,15,17,19,20,22,23,24,25,26,27,31,33,35,41,42,43,44,47,50],N=[4,5,14,15,17,19,20,22,23,24,25,26,27,31,33,35,41,42,43,44,47,50],O={trace:function(){},yy:{},symbols_:{error:2,start:3,SPACE:4,NL:5,directive:6,SD:7,document:8,line:9,statement:10,idStatement:11,DESCR:12,"--\x3e":13,HIDE_EMPTY:14,scale:15,WIDTH:16,COMPOSIT_STATE:17,STRUCT_START:18,STRUCT_STOP:19,STATE_DESCR:20,AS:21,ID:22,FORK:23,JOIN:24,CHOICE:25,CONCURRENT:26,note:27,notePosition:28,NOTE_TEXT:29,direction:30,acc_title:31,acc_title_value:32,acc_descr:33,acc_descr_value:34,acc_descr_multiline_value:35,openDirective:36,typeDirective:37,closeDirective:38,":":39,argDirective:40,direction_tb:41,direction_bt:42,direction_rl:43,direction_lr:44,eol:45,";":46,EDGE_STATE:47,left_of:48,right_of:49,open_directive:50,type_directive:51,arg_directive:52,close_directive:53,$accept:0,$end:1},terminals_:{2:"error",4:"SPACE",5:"NL",7:"SD",12:"DESCR",13:"--\x3e",14:"HIDE_EMPTY",15:"scale",16:"WIDTH",17:"COMPOSIT_STATE",18:"STRUCT_START",19:"STRUCT_STOP",20:"STATE_DESCR",21:"AS",22:"ID",23:"FORK",24:"JOIN",25:"CHOICE",26:"CONCURRENT",27:"note",29:"NOTE_TEXT",31:"acc_title",32:"acc_title_value",33:"acc_descr",34:"acc_descr_value",35:"acc_descr_multiline_value",39:":",41:"direction_tb",42:"direction_bt",43:"direction_rl",44:"direction_lr",46:";",47:"EDGE_STATE",48:"left_of",49:"right_of",50:"open_directive",51:"type_directive",52:"arg_directive",53:"close_directive"},productions_:[0,[3,2],[3,2],[3,2],[3,2],[8,0],[8,2],[9,2],[9,1],[9,1],[10,1],[10,2],[10,3],[10,4],[10,1],[10,2],[10,1],[10,4],[10,3],[10,6],[10,1],[10,1],[10,1],[10,1],[10,4],[10,4],[10,1],[10,1],[10,2],[10,2],[10,1],[6,3],[6,5],[30,1],[30,1],[30,1],[30,1],[45,1],[45,1],[11,1],[11,1],[28,1],[28,1],[36,1],[37,1],[40,1],[38,1]],performAction:function(t,e,n,r,i,a,o){var s=a.length-1;switch(i){case 4:return r.setRootDoc(a[s]),a[s];case 5:this.$=[];break;case 6:"nl"!=a[s]&&(a[s-1].push(a[s]),this.$=a[s-1]);break;case 7:case 8:case 39:case 40:this.$=a[s];break;case 9:this.$="nl";break;case 10:this.$={stmt:"state",id:a[s],type:"default",description:""};break;case 11:this.$={stmt:"state",id:a[s-1],type:"default",description:r.trimColon(a[s])};break;case 12:this.$={stmt:"relation",state1:{stmt:"state",id:a[s-2],type:"default",description:""},state2:{stmt:"state",id:a[s],type:"default",description:""}};break;case 13:this.$={stmt:"relation",state1:{stmt:"state",id:a[s-3],type:"default",description:""},state2:{stmt:"state",id:a[s-1],type:"default",description:""},description:a[s].substr(1).trim()};break;case 17:this.$={stmt:"state",id:a[s-3],type:"default",description:"",doc:a[s-1]};break;case 18:var c=a[s],l=a[s-2].trim();if(a[s].match(":")){var u=a[s].split(":");c=u[0],l=[l,u[1]];}this.$={stmt:"state",id:c,type:"default",description:l};break;case 19:this.$={stmt:"state",id:a[s-3],type:"default",description:a[s-5],doc:a[s-1]};break;case 20:this.$={stmt:"state",id:a[s],type:"fork"};break;case 21:this.$={stmt:"state",id:a[s],type:"join"};break;case 22:this.$={stmt:"state",id:a[s],type:"choice"};break;case 23:this.$={stmt:"state",id:r.getDividerId(),type:"divider"};break;case 24:this.$={stmt:"state",id:a[s-1].trim(),note:{position:a[s-2].trim(),text:a[s].trim()}};break;case 28:this.$=a[s].trim(),r.setAccTitle(this.$);break;case 29:case 30:this.$=a[s].trim(),r.setAccDescription(this.$);break;case 33:r.setDirection("TB"),this.$={stmt:"dir",value:"TB"};break;case 34:r.setDirection("BT"),this.$={stmt:"dir",value:"BT"};break;case 35:r.setDirection("RL"),this.$={stmt:"dir",value:"RL"};break;case 36:r.setDirection("LR"),this.$={stmt:"dir",value:"LR"};break;case 43:r.parseDirective("%%{","open_directive");break;case 44:r.parseDirective(a[s],"type_directive");break;case 45:a[s]=a[s].trim().replace(/'/g,'"'),r.parseDirective(a[s],"arg_directive");break;case 46:r.parseDirective("}%%","close_directive","state");}},table:[{3:1,4:e,5:n,6:4,7:r,36:6,50:i},{1:[3]},{3:8,4:e,5:n,6:4,7:r,36:6,50:i},{3:9,4:e,5:n,6:4,7:r,36:6,50:i},{3:10,4:e,5:n,6:4,7:r,36:6,50:i},t([1,4,5,14,15,17,20,22,23,24,25,26,27,31,33,35,41,42,43,44,47,50],a,{8:11}),{37:12,51:[1,13]},{51:[2,43]},{1:[2,1]},{1:[2,2]},{1:[2,3]},{1:[2,4],4:o,5:s,6:28,9:14,10:16,11:18,14:c,15:l,17:u,20:h,22:f,23:d,24:p,25:g,26:y,27:m,30:29,31:b,33:v,35:_,36:6,41:x,42:k,43:w,44:T,47:E,50:i},{38:39,39:[1,40],53:C},t([39,53],[2,44]),t(S,[2,6]),{6:28,10:42,11:18,14:c,15:l,17:u,20:h,22:f,23:d,24:p,25:g,26:y,27:m,30:29,31:b,33:v,35:_,36:6,41:x,42:k,43:w,44:T,47:E,50:i},t(S,[2,8]),t(S,[2,9]),t(S,[2,10],{12:[1,43],13:[1,44]}),t(S,[2,14]),{16:[1,45]},t(S,[2,16],{18:[1,46]}),{21:[1,47]},t(S,[2,20]),t(S,[2,21]),t(S,[2,22]),t(S,[2,23]),{28:48,29:[1,49],48:[1,50],49:[1,51]},t(S,[2,26]),t(S,[2,27]),{32:[1,52]},{34:[1,53]},t(S,[2,30]),t(A,[2,39]),t(A,[2,40]),t(S,[2,33]),t(S,[2,34]),t(S,[2,35]),t(S,[2,36]),t(M,[2,31]),{40:54,52:[1,55]},t(M,[2,46]),t(S,[2,7]),t(S,[2,11]),{11:56,22:f,47:E},t(S,[2,15]),t(N,a,{8:57}),{22:[1,58]},{22:[1,59]},{21:[1,60]},{22:[2,41]},{22:[2,42]},t(S,[2,28]),t(S,[2,29]),{38:61,53:C},{53:[2,45]},t(S,[2,12],{12:[1,62]}),{4:o,5:s,6:28,9:14,10:16,11:18,14:c,15:l,17:u,19:[1,63],20:h,22:f,23:d,24:p,25:g,26:y,27:m,30:29,31:b,33:v,35:_,36:6,41:x,42:k,43:w,44:T,47:E,50:i},t(S,[2,18],{18:[1,64]}),{29:[1,65]},{22:[1,66]},t(M,[2,32]),t(S,[2,13]),t(S,[2,17]),t(N,a,{8:67}),t(S,[2,24]),t(S,[2,25]),{4:o,5:s,6:28,9:14,10:16,11:18,14:c,15:l,17:u,19:[1,68],20:h,22:f,23:d,24:p,25:g,26:y,27:m,30:29,31:b,33:v,35:_,36:6,41:x,42:k,43:w,44:T,47:E,50:i},t(S,[2,19])],defaultActions:{7:[2,43],8:[2,1],9:[2,2],10:[2,3],50:[2,41],51:[2,42],55:[2,45]},parseError:function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t);},parse:function(t){var e=this,n=[0],r=[],i=[null],a=[],o=this.table,s="",c=0,l=0,u=0,h=2,f=1,d=a.slice.call(arguments,1),p=Object.create(this.lexer),g={yy:{}};for(var y in this.yy)Object.prototype.hasOwnProperty.call(this.yy,y)&&(g.yy[y]=this.yy[y]);p.setInput(t,g.yy),g.yy.lexer=p,g.yy.parser=this,void 0===p.yylloc&&(p.yylloc={});var m=p.yylloc;a.push(m);var b=p.options&&p.options.ranges;function v(){var t;return "number"!=typeof(t=r.pop()||p.lex()||f)&&(t instanceof Array&&(t=(r=t).pop()),t=e.symbols_[t]||t),t}"function"==typeof g.yy.parseError?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var _,x,k,w,T,E,C,S,A,M={};;){if(k=n[n.length-1],this.defaultActions[k]?w=this.defaultActions[k]:(null==_&&(_=v()),w=o[k]&&o[k][_]),void 0===w||!w.length||!w[0]){var N="";for(E in A=[],o[k])this.terminals_[E]&&E>h&&A.push("'"+this.terminals_[E]+"'");N=p.showPosition?"Parse error on line "+(c+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[_]||_)+"'":"Parse error on line "+(c+1)+": Unexpected "+(_==f?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(N,{text:p.match,token:this.terminals_[_]||_,line:p.yylineno,loc:m,expected:A});}if(w[0]instanceof Array&&w.length>1)throw new Error("Parse Error: multiple actions possible at state: "+k+", token: "+_);switch(w[0]){case 1:n.push(_),i.push(p.yytext),a.push(p.yylloc),n.push(w[1]),_=null,x?(_=x,x=null):(l=p.yyleng,s=p.yytext,c=p.yylineno,m=p.yylloc,u>0&&u--);break;case 2:if(C=this.productions_[w[1]][1],M.$=i[i.length-C],M._$={first_line:a[a.length-(C||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(C||1)].first_column,last_column:a[a.length-1].last_column},b&&(M._$.range=[a[a.length-(C||1)].range[0],a[a.length-1].range[1]]),void 0!==(T=this.performAction.apply(M,[s,l,c,g.yy,w[1],i,a].concat(d))))return T;C&&(n=n.slice(0,-1*C*2),i=i.slice(0,-1*C),a=a.slice(0,-1*C)),n.push(this.productions_[w[1]][0]),i.push(M.$),a.push(M._$),S=o[n[n.length-2]][n[n.length-1]],n.push(S);break;case 3:return !0}}return !0}},D={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e);},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t));},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return (t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var n,r,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(r=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in i)this[a]=i[a];return !1}return !1},next:function(){if(this.done)return this.EOF;var t,e,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),a=0;a<i.length;a++)if((n=this._input.match(this.rules[i[a]]))&&(!e||n[0].length>e[0].length)){if(e=n,r=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,i[a])))return t;if(this._backtrack){e=!1;continue}return !1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[r]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(t){this.conditionStack.push(t);},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return (t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t);},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,n,r){switch(n){case 0:case 33:return 41;case 1:case 34:return 42;case 2:case 35:return 43;case 3:case 36:return 44;case 4:return this.begin("open_directive"),50;case 5:return this.begin("type_directive"),51;case 6:return this.popState(),this.begin("arg_directive"),39;case 7:return this.popState(),this.popState(),53;case 8:return 52;case 9:case 10:case 12:case 13:case 14:case 15:case 46:case 52:break;case 11:case 66:return 5;case 16:return this.pushState("SCALE"),15;case 17:return 16;case 18:case 24:case 40:case 43:this.popState();break;case 19:return this.begin("acc_title"),31;case 20:return this.popState(),"acc_title_value";case 21:return this.begin("acc_descr"),33;case 22:return this.popState(),"acc_descr_value";case 23:this.begin("acc_descr_multiline");break;case 25:return "acc_descr_multiline_value";case 26:this.pushState("STATE");break;case 27:case 30:return this.popState(),e.yytext=e.yytext.slice(0,-8).trim(),23;case 28:case 31:return this.popState(),e.yytext=e.yytext.slice(0,-8).trim(),24;case 29:case 32:return this.popState(),e.yytext=e.yytext.slice(0,-10).trim(),25;case 37:this.begin("STATE_STRING");break;case 38:return this.popState(),this.pushState("STATE_ID"),"AS";case 39:case 54:return this.popState(),"ID";case 41:return "STATE_DESCR";case 42:return 17;case 44:return this.popState(),this.pushState("struct"),18;case 45:return this.popState(),19;case 47:return this.begin("NOTE"),27;case 48:return this.popState(),this.pushState("NOTE_ID"),48;case 49:return this.popState(),this.pushState("NOTE_ID"),49;case 50:this.popState(),this.pushState("FLOATING_NOTE");break;case 51:return this.popState(),this.pushState("FLOATING_NOTE_ID"),"AS";case 53:return "NOTE_TEXT";case 55:return this.popState(),this.pushState("NOTE_TEXT"),22;case 56:return this.popState(),e.yytext=e.yytext.substr(2).trim(),29;case 57:return this.popState(),e.yytext=e.yytext.slice(0,-8).trim(),29;case 58:case 59:return 7;case 60:return 14;case 61:return 47;case 62:return 22;case 63:return e.yytext=e.yytext.trim(),12;case 64:return 13;case 65:return 26;case 67:return "INVALID"}},rules:[/^(?:.*direction\s+TB[^\n]*)/i,/^(?:.*direction\s+BT[^\n]*)/i,/^(?:.*direction\s+RL[^\n]*)/i,/^(?:.*direction\s+LR[^\n]*)/i,/^(?:%%\{)/i,/^(?:((?:(?!\}%%)[^:.])*))/i,/^(?::)/i,/^(?:\}%%)/i,/^(?:((?:(?!\}%%).|\n)*))/i,/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[\n]+)/i,/^(?:[\s]+)/i,/^(?:((?!\n)\s)+)/i,/^(?:#[^\n]*)/i,/^(?:%[^\n]*)/i,/^(?:scale\s+)/i,/^(?:\d+)/i,/^(?:\s+width\b)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:state\s+)/i,/^(?:.*<<fork>>)/i,/^(?:.*<<join>>)/i,/^(?:.*<<choice>>)/i,/^(?:.*\[\[fork\]\])/i,/^(?:.*\[\[join\]\])/i,/^(?:.*\[\[choice\]\])/i,/^(?:.*direction\s+TB[^\n]*)/i,/^(?:.*direction\s+BT[^\n]*)/i,/^(?:.*direction\s+RL[^\n]*)/i,/^(?:.*direction\s+LR[^\n]*)/i,/^(?:["])/i,/^(?:\s*as\s+)/i,/^(?:[^\n\{]*)/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:[^\n\s\{]+)/i,/^(?:\n)/i,/^(?:\{)/i,/^(?:\})/i,/^(?:[\n])/i,/^(?:note\s+)/i,/^(?:left of\b)/i,/^(?:right of\b)/i,/^(?:")/i,/^(?:\s*as\s*)/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:[^\n]*)/i,/^(?:\s*[^:\n\s\-]+)/i,/^(?:\s*:[^:\n;]+)/i,/^(?:[\s\S]*?end note\b)/i,/^(?:stateDiagram\s+)/i,/^(?:stateDiagram-v2\s+)/i,/^(?:hide empty description\b)/i,/^(?:\[\*\])/i,/^(?:[^:\n\s\-\{]+)/i,/^(?:\s*:[^:\n;]+)/i,/^(?:-->)/i,/^(?:--)/i,/^(?:$)/i,/^(?:.)/i],conditions:{LINE:{rules:[13,14],inclusive:!1},close_directive:{rules:[13,14],inclusive:!1},arg_directive:{rules:[7,8,13,14],inclusive:!1},type_directive:{rules:[6,7,13,14],inclusive:!1},open_directive:{rules:[5,13,14],inclusive:!1},struct:{rules:[13,14,26,33,34,35,36,45,46,47,61,62,63,64,65],inclusive:!1},FLOATING_NOTE_ID:{rules:[54],inclusive:!1},FLOATING_NOTE:{rules:[51,52,53],inclusive:!1},NOTE_TEXT:{rules:[56,57],inclusive:!1},NOTE_ID:{rules:[55],inclusive:!1},NOTE:{rules:[48,49,50],inclusive:!1},acc_descr_multiline:{rules:[24,25],inclusive:!1},acc_descr:{rules:[22],inclusive:!1},acc_title:{rules:[20],inclusive:!1},SCALE:{rules:[17,18],inclusive:!1},ALIAS:{rules:[],inclusive:!1},STATE_ID:{rules:[39],inclusive:!1},STATE_STRING:{rules:[40,41],inclusive:!1},FORK_STATE:{rules:[],inclusive:!1},STATE:{rules:[13,14,27,28,29,30,31,32,37,38,42,43,44],inclusive:!1},ID:{rules:[13,14],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,9,10,11,12,14,15,16,19,21,23,26,44,47,58,59,60,61,62,63,64,66,67],inclusive:!0}}};function B(){this.yy={};}return O.lexer=D,B.prototype=O,O.Parser=B,new B}();e.parser=r,e.Parser=r.Parser,e.parse=function(){return r.parse.apply(r,arguments)},e.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var r=n(3069).readFileSync(n(6470).normalize(t[1]),"utf8");return e.parser.parse(r)},n.c[n.s]===t&&e.main(process.argv.slice(1));},9763:(t,e,n)=>{t=n.nmd(t);var r=function(){var t=function(t,e,n,r){for(n=n||{},r=t.length;r--;n[t[r]]=e);return n},e=[1,2],n=[1,5],r=[6,9,11,17,18,20,22,23,24,26],i=[1,15],a=[1,16],o=[1,17],s=[1,18],c=[1,19],l=[1,20],u=[1,24],h=[4,6,9,11,17,18,20,22,23,24,26],f={trace:function(){},yy:{},symbols_:{error:2,start:3,journey:4,document:5,EOF:6,directive:7,line:8,SPACE:9,statement:10,NEWLINE:11,openDirective:12,typeDirective:13,closeDirective:14,":":15,argDirective:16,title:17,acc_title:18,acc_title_value:19,acc_descr:20,acc_descr_value:21,acc_descr_multiline_value:22,section:23,taskName:24,taskData:25,open_directive:26,type_directive:27,arg_directive:28,close_directive:29,$accept:0,$end:1},terminals_:{2:"error",4:"journey",6:"EOF",9:"SPACE",11:"NEWLINE",15:":",17:"title",18:"acc_title",19:"acc_title_value",20:"acc_descr",21:"acc_descr_value",22:"acc_descr_multiline_value",23:"section",24:"taskName",25:"taskData",26:"open_directive",27:"type_directive",28:"arg_directive",29:"close_directive"},productions_:[0,[3,3],[3,2],[5,0],[5,2],[8,2],[8,1],[8,1],[8,1],[7,4],[7,6],[10,1],[10,2],[10,2],[10,1],[10,1],[10,2],[10,1],[12,1],[13,1],[16,1],[14,1]],performAction:function(t,e,n,r,i,a,o){var s=a.length-1;switch(i){case 1:return a[s-1];case 3:case 7:case 8:this.$=[];break;case 4:a[s-1].push(a[s]),this.$=a[s-1];break;case 5:case 6:this.$=a[s];break;case 11:r.setDiagramTitle(a[s].substr(6)),this.$=a[s].substr(6);break;case 12:this.$=a[s].trim(),r.setAccTitle(this.$);break;case 13:case 14:this.$=a[s].trim(),r.setAccDescription(this.$);break;case 15:r.addSection(a[s].substr(8)),this.$=a[s].substr(8);break;case 16:r.addTask(a[s-1],a[s]),this.$="task";break;case 18:r.parseDirective("%%{","open_directive");break;case 19:r.parseDirective(a[s],"type_directive");break;case 20:a[s]=a[s].trim().replace(/'/g,'"'),r.parseDirective(a[s],"arg_directive");break;case 21:r.parseDirective("}%%","close_directive","journey");}},table:[{3:1,4:e,7:3,12:4,26:n},{1:[3]},t(r,[2,3],{5:6}),{3:7,4:e,7:3,12:4,26:n},{13:8,27:[1,9]},{27:[2,18]},{6:[1,10],7:21,8:11,9:[1,12],10:13,11:[1,14],12:4,17:i,18:a,20:o,22:s,23:c,24:l,26:n},{1:[2,2]},{14:22,15:[1,23],29:u},t([15,29],[2,19]),t(r,[2,8],{1:[2,1]}),t(r,[2,4]),{7:21,10:25,12:4,17:i,18:a,20:o,22:s,23:c,24:l,26:n},t(r,[2,6]),t(r,[2,7]),t(r,[2,11]),{19:[1,26]},{21:[1,27]},t(r,[2,14]),t(r,[2,15]),{25:[1,28]},t(r,[2,17]),{11:[1,29]},{16:30,28:[1,31]},{11:[2,21]},t(r,[2,5]),t(r,[2,12]),t(r,[2,13]),t(r,[2,16]),t(h,[2,9]),{14:32,29:u},{29:[2,20]},{11:[1,33]},t(h,[2,10])],defaultActions:{5:[2,18],7:[2,2],24:[2,21],31:[2,20]},parseError:function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t);},parse:function(t){var e=this,n=[0],r=[],i=[null],a=[],o=this.table,s="",c=0,l=0,u=0,h=2,f=1,d=a.slice.call(arguments,1),p=Object.create(this.lexer),g={yy:{}};for(var y in this.yy)Object.prototype.hasOwnProperty.call(this.yy,y)&&(g.yy[y]=this.yy[y]);p.setInput(t,g.yy),g.yy.lexer=p,g.yy.parser=this,void 0===p.yylloc&&(p.yylloc={});var m=p.yylloc;a.push(m);var b=p.options&&p.options.ranges;function v(){var t;return "number"!=typeof(t=r.pop()||p.lex()||f)&&(t instanceof Array&&(t=(r=t).pop()),t=e.symbols_[t]||t),t}"function"==typeof g.yy.parseError?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var _,x,k,w,T,E,C,S,A,M={};;){if(k=n[n.length-1],this.defaultActions[k]?w=this.defaultActions[k]:(null==_&&(_=v()),w=o[k]&&o[k][_]),void 0===w||!w.length||!w[0]){var N="";for(E in A=[],o[k])this.terminals_[E]&&E>h&&A.push("'"+this.terminals_[E]+"'");N=p.showPosition?"Parse error on line "+(c+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[_]||_)+"'":"Parse error on line "+(c+1)+": Unexpected "+(_==f?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(N,{text:p.match,token:this.terminals_[_]||_,line:p.yylineno,loc:m,expected:A});}if(w[0]instanceof Array&&w.length>1)throw new Error("Parse Error: multiple actions possible at state: "+k+", token: "+_);switch(w[0]){case 1:n.push(_),i.push(p.yytext),a.push(p.yylloc),n.push(w[1]),_=null,x?(_=x,x=null):(l=p.yyleng,s=p.yytext,c=p.yylineno,m=p.yylloc,u>0&&u--);break;case 2:if(C=this.productions_[w[1]][1],M.$=i[i.length-C],M._$={first_line:a[a.length-(C||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(C||1)].first_column,last_column:a[a.length-1].last_column},b&&(M._$.range=[a[a.length-(C||1)].range[0],a[a.length-1].range[1]]),void 0!==(T=this.performAction.apply(M,[s,l,c,g.yy,w[1],i,a].concat(d))))return T;C&&(n=n.slice(0,-1*C*2),i=i.slice(0,-1*C),a=a.slice(0,-1*C)),n.push(this.productions_[w[1]][0]),i.push(M.$),a.push(M._$),S=o[n[n.length-2]][n[n.length-1]],n.push(S);break;case 3:return !0}}return !0}},d={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e);},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t));},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return (t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var n,r,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(r=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in i)this[a]=i[a];return !1}return !1},next:function(){if(this.done)return this.EOF;var t,e,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),a=0;a<i.length;a++)if((n=this._input.match(this.rules[i[a]]))&&(!e||n[0].length>e[0].length)){if(e=n,r=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,i[a])))return t;if(this._backtrack){e=!1;continue}return !1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[r]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(t){this.conditionStack.push(t);},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return (t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t);},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,n,r){switch(n){case 0:return this.begin("open_directive"),26;case 1:return this.begin("type_directive"),27;case 2:return this.popState(),this.begin("arg_directive"),15;case 3:return this.popState(),this.popState(),29;case 4:return 28;case 5:case 6:case 8:case 9:break;case 7:return 11;case 10:return 4;case 11:return 17;case 12:return this.begin("acc_title"),18;case 13:return this.popState(),"acc_title_value";case 14:return this.begin("acc_descr"),20;case 15:return this.popState(),"acc_descr_value";case 16:this.begin("acc_descr_multiline");break;case 17:this.popState();break;case 18:return "acc_descr_multiline_value";case 19:return 23;case 20:return 24;case 21:return 25;case 22:return 15;case 23:return 6;case 24:return "INVALID"}},rules:[/^(?:%%\{)/i,/^(?:((?:(?!\}%%)[^:.])*))/i,/^(?::)/i,/^(?:\}%%)/i,/^(?:((?:(?!\}%%).|\n)*))/i,/^(?:%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:journey\b)/i,/^(?:title\s[^#\n;]+)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:section\s[^#:\n;]+)/i,/^(?:[^#:\n;]+)/i,/^(?::[^#\n;]+)/i,/^(?::)/i,/^(?:$)/i,/^(?:.)/i],conditions:{open_directive:{rules:[1],inclusive:!1},type_directive:{rules:[2,3],inclusive:!1},arg_directive:{rules:[3,4],inclusive:!1},acc_descr_multiline:{rules:[17,18],inclusive:!1},acc_descr:{rules:[15],inclusive:!1},acc_title:{rules:[13],inclusive:!1},INITIAL:{rules:[0,5,6,7,8,9,10,11,12,14,16,19,20,21,22,23,24],inclusive:!0}}};function p(){this.yy={};}return f.lexer=d,p.prototype=f,f.Parser=p,new p}();e.parser=r,e.Parser=r.Parser,e.parse=function(){return r.parse.apply(r,arguments)},e.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var r=n(9143).readFileSync(n(6470).normalize(t[1]),"utf8");return e.parser.parse(r)},n.c[n.s]===t&&e.main(process.argv.slice(1));},7967:(t,e)=>{e.N=void 0;var n=/^([^\w]*)(javascript|data|vbscript)/im,r=/&#(\w+)(^\w|;)?/g,i=/[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim,a=/^([^:]+):/gm,o=[".","/"];e.N=function(t){var e,s=(e=t||"",e.replace(r,(function(t,e){return String.fromCharCode(e)}))).replace(i,"").trim();if(!s)return "about:blank";if(function(t){return o.indexOf(t[0])>-1}(s))return s;var c=s.match(a);if(!c)return s;var l=c[0];return n.test(l)?"about:blank":s};},3841:t=>{t.exports=function(t,e){return t.intersect(e)};},6187:(t,e,n)=>{n.d(e,{Z:()=>fu});var r=n(1941),i=n.n(r),a={debug:1,info:2,warn:3,error:4,fatal:5},o={debug:function(){},info:function(){},warn:function(){},error:function(){},fatal:function(){}},s=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"fatal";isNaN(t)&&(t=t.toLowerCase(),void 0!==a[t]&&(t=a[t])),o.trace=function(){},o.debug=function(){},o.info=function(){},o.warn=function(){},o.error=function(){},o.fatal=function(){},t<=a.fatal&&(o.fatal=console.error?console.error.bind(console,c("FATAL"),"color: orange"):console.log.bind(console,"",c("FATAL"))),t<=a.error&&(o.error=console.error?console.error.bind(console,c("ERROR"),"color: orange"):console.log.bind(console,"",c("ERROR"))),t<=a.warn&&(o.warn=console.warn?console.warn.bind(console,c("WARN"),"color: orange"):console.log.bind(console,"",c("WARN"))),t<=a.info&&(o.info=console.info?console.info.bind(console,c("INFO"),"color: lightblue"):console.log.bind(console,"",c("INFO"))),t<=a.debug&&(o.debug=console.debug?console.debug.bind(console,c("DEBUG"),"color: lightgreen"):console.log.bind(console,"",c("DEBUG")));},c=function(t){var e=i()().format("ss.SSS");return "%c".concat(e," : ").concat(t," : ")},l=n(7543),u="comm",h="rule",f="decl",d=Math.abs,p=String.fromCharCode;function g(t){return t.trim()}function y(t,e,n){return t.replace(e,n)}function m(t,e){return t.indexOf(e)}function b(t,e){return 0|t.charCodeAt(e)}function v(t,e,n){return t.slice(e,n)}function _(t){return t.length}function x(t){return t.length}function k(t,e){return e.push(t),t}function w(t,e){for(var n="",r=x(t),i=0;i<r;i++)n+=e(t[i],i,t,e)||"";return n}function T(t,e,n,r){switch(t.type){case"@import":case f:return t.return=t.return||t.value;case u:return "";case"@keyframes":return t.return=t.value+"{"+w(t.children,r)+"}";case h:t.value=t.props.join(",");}return _(n=w(t.children,r))?t.return=t.value+"{"+n+"}":""}var E=1,C=1,S=0,A=0,M=0,N="";function O(t,e,n,r,i,a,o){return {value:t,root:e,parent:n,type:r,props:i,children:a,line:E,column:C,length:o,return:""}}function D(){return M=A>0?b(N,--A):0,C--,10===M&&(C=1,E--),M}function B(){return M=A<S?b(N,A++):0,C++,10===M&&(C=1,E++),M}function L(){return b(N,A)}function I(){return A}function F(t,e){return v(N,t,e)}function R(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function P(t){return g(F(A-1,Y(91===t?t+2:40===t?t+1:t)))}function j(t){for(;(M=L())&&M<33;)B();return R(t)>2||R(M)>3?"":" "}function z(t,e){for(;--e&&B()&&!(M<48||M>102||M>57&&M<65||M>70&&M<97););return F(t,I()+(e<6&&32==L()&&32==B()))}function Y(t){for(;B();)switch(M){case t:return A;case 34:case 39:34!==t&&39!==t&&Y(M);break;case 40:41===t&&Y(t);break;case 92:B();}return A}function U(t,e){for(;B()&&t+M!==57&&(t+M!==84||47!==L()););return "/*"+F(e,A-1)+"*"+p(47===t?t:B())}function $(t){for(;!R(L());)B();return F(t,A)}function W(t){return function(t){return N="",t}(q("",null,null,null,[""],t=function(t){return E=C=1,S=_(N=t),A=0,[]}(t),0,[0],t))}function q(t,e,n,r,i,a,o,s,c){for(var l=0,u=0,h=o,f=0,d=0,g=0,b=1,v=1,x=1,w=0,T="",E=i,C=a,S=r,A=T;v;)switch(g=w,w=B()){case 40:if(108!=g&&58==A.charCodeAt(h-1)){-1!=m(A+=y(P(w),"&","&\f"),"&\f")&&(x=-1);break}case 34:case 39:case 91:A+=P(w);break;case 9:case 10:case 13:case 32:A+=j(g);break;case 92:A+=z(I()-1,7);continue;case 47:switch(L()){case 42:case 47:k(V(U(B(),I()),e,n),c);break;default:A+="/";}break;case 123*b:s[l++]=_(A)*x;case 125*b:case 59:case 0:switch(w){case 0:case 125:v=0;case 59+u:d>0&&_(A)-h&&k(d>32?G(A+";",r,n,h-1):G(y(A," ","")+";",r,n,h-2),c);break;case 59:A+=";";default:if(k(S=H(A,e,n,l,u,i,s,T,E=[],C=[],h),a),123===w)if(0===u)q(A,e,S,S,E,a,h,s,C);else switch(f){case 100:case 109:case 115:q(t,S,S,r&&k(H(t,S,S,0,0,i,s,T,i,E=[],h),C),i,C,h,s,r?E:C);break;default:q(A,S,S,S,[""],C,0,s,C);}}l=u=d=0,b=x=1,T=A="",h=o;break;case 58:h=1+_(A),d=g;default:if(b<1)if(123==w)--b;else if(125==w&&0==b++&&125==D())continue;switch(A+=p(w),w*b){case 38:x=u>0?1:(A+="\f",-1);break;case 44:s[l++]=(_(A)-1)*x,x=1;break;case 64:45===L()&&(A+=P(B())),f=L(),u=h=_(T=A+=$(I())),w++;break;case 45:45===g&&2==_(A)&&(b=0);}}return a}function H(t,e,n,r,i,a,o,s,c,l,u){for(var f=i-1,p=0===i?a:[""],m=x(p),b=0,_=0,k=0;b<r;++b)for(var w=0,T=v(t,f+1,f=d(_=o[b])),E=t;w<m;++w)(E=g(_>0?p[w]+" "+T:y(T,/&\f/g,p[w])))&&(c[k++]=E);return O(t,e,n,0===i?h:s,c,l,u)}function V(t,e,n){return O(t,e,n,u,p(M),v(t,2,-2),0)}function G(t,e,n,r){return O(t,e,n,f,v(t,0,r),v(t,r+1,-1),r)}const X="9.1.7";function Z(t){return Z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z(t)}const Q=function t(e,n,r){var i=Object.assign({depth:2,clobber:!1},r),a=i.depth,o=i.clobber;return Array.isArray(n)&&!Array.isArray(e)?(n.forEach((function(n){return t(e,n,r)})),e):Array.isArray(n)&&Array.isArray(e)?(n.forEach((function(t){-1===e.indexOf(t)&&e.push(t);})),e):void 0===e||a<=0?null!=e&&"object"===Z(e)&&"object"===Z(n)?Object.assign(e,n):n:(void 0!==n&&"object"===Z(e)&&"object"===Z(n)&&Object.keys(n).forEach((function(r){"object"!==Z(n[r])||void 0!==e[r]&&"object"!==Z(e[r])?(o||"object"!==Z(e[r])&&"object"!==Z(n[r]))&&(e[r]=n[r]):(void 0===e[r]&&(e[r]=Array.isArray(n[r])?[]:{}),e[r]=t(e[r],n[r],{depth:a-1,clobber:o}));})),e)},K={min:{r:0,g:0,b:0,s:0,l:0,a:0},max:{r:255,g:255,b:255,h:360,s:100,l:100,a:1},clamp:{r:t=>t>=255?255:t<0?0:t,g:t=>t>=255?255:t<0?0:t,b:t=>t>=255?255:t<0?0:t,h:t=>t%360,s:t=>t>=100?100:t<0?0:t,l:t=>t>=100?100:t<0?0:t,a:t=>t>=1?1:t<0?0:t},toLinear:t=>{const e=t/255;return t>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92},hue2rgb:(t,e,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t),hsl2rgb:({h:t,s:e,l:n},r)=>{if(!e)return 2.55*n;t/=360,e/=100;const i=(n/=100)<.5?n*(1+e):n+e-n*e,a=2*n-i;switch(r){case"r":return 255*K.hue2rgb(a,i,t+1/3);case"g":return 255*K.hue2rgb(a,i,t);case"b":return 255*K.hue2rgb(a,i,t-1/3)}},rgb2hsl:({r:t,g:e,b:n},r)=>{t/=255,e/=255,n/=255;const i=Math.max(t,e,n),a=Math.min(t,e,n),o=(i+a)/2;if("l"===r)return 100*o;if(i===a)return 0;const s=i-a;if("s"===r)return 100*(o>.5?s/(2-i-a):s/(i+a));switch(i){case t:return 60*((e-n)/s+(e<n?6:0));case e:return 60*((n-t)/s+2);case n:return 60*((t-e)/s+4);default:return -1}}},J={channel:K,lang:{clamp:(t,e,n)=>e>n?Math.min(e,Math.max(n,t)):Math.min(n,Math.max(e,t)),round:t=>Math.round(1e10*t)/1e10},unit:{dec2hex:t=>{const e=Math.round(t).toString(16);return e.length>1?e:`0${e}`}}},tt={};for(let t=0;t<=255;t++)tt[t]=J.unit.dec2hex(t);const et=new class{constructor(t,e){this.color=e,this.changed=!1,this.data=t,this.type=new class{constructor(){this.type=0;}get(){return this.type}set(t){if(this.type&&this.type!==t)throw new Error("Cannot change both RGB and HSL channels at the same time");this.type=t;}reset(){this.type=0;}is(t){return this.type===t}};}set(t,e){return this.color=e,this.changed=!1,this.data=t,this.type.type=0,this}_ensureHSL(){const t=this.data,{h:e,s:n,l:r}=t;void 0===e&&(t.h=J.channel.rgb2hsl(t,"h")),void 0===n&&(t.s=J.channel.rgb2hsl(t,"s")),void 0===r&&(t.l=J.channel.rgb2hsl(t,"l"));}_ensureRGB(){const t=this.data,{r:e,g:n,b:r}=t;void 0===e&&(t.r=J.channel.hsl2rgb(t,"r")),void 0===n&&(t.g=J.channel.hsl2rgb(t,"g")),void 0===r&&(t.b=J.channel.hsl2rgb(t,"b"));}get r(){const t=this.data,e=t.r;return this.type.is(2)||void 0===e?(this._ensureHSL(),J.channel.hsl2rgb(t,"r")):e}get g(){const t=this.data,e=t.g;return this.type.is(2)||void 0===e?(this._ensureHSL(),J.channel.hsl2rgb(t,"g")):e}get b(){const t=this.data,e=t.b;return this.type.is(2)||void 0===e?(this._ensureHSL(),J.channel.hsl2rgb(t,"b")):e}get h(){const t=this.data,e=t.h;return this.type.is(1)||void 0===e?(this._ensureRGB(),J.channel.rgb2hsl(t,"h")):e}get s(){const t=this.data,e=t.s;return this.type.is(1)||void 0===e?(this._ensureRGB(),J.channel.rgb2hsl(t,"s")):e}get l(){const t=this.data,e=t.l;return this.type.is(1)||void 0===e?(this._ensureRGB(),J.channel.rgb2hsl(t,"l")):e}get a(){return this.data.a}set r(t){this.type.set(1),this.changed=!0,this.data.r=t;}set g(t){this.type.set(1),this.changed=!0,this.data.g=t;}set b(t){this.type.set(1),this.changed=!0,this.data.b=t;}set h(t){this.type.set(2),this.changed=!0,this.data.h=t;}set s(t){this.type.set(2),this.changed=!0,this.data.s=t;}set l(t){this.type.set(2),this.changed=!0,this.data.l=t;}set a(t){this.changed=!0,this.data.a=t;}}({r:0,g:0,b:0,a:0},"transparent"),nt={re:/^#((?:[a-f0-9]{2}){2,4}|[a-f0-9]{3})$/i,parse:t=>{if(35!==t.charCodeAt(0))return;const e=t.match(nt.re);if(!e)return;const n=e[1],r=parseInt(n,16),i=n.length,a=i%4==0,o=i>4,s=o?1:17,c=o?8:4,l=a?0:-1,u=o?255:15;return et.set({r:(r>>c*(l+3)&u)*s,g:(r>>c*(l+2)&u)*s,b:(r>>c*(l+1)&u)*s,a:a?(r&u)*s/255:1},t)},stringify:t=>{const{r:e,g:n,b:r,a:i}=t;return i<1?`#${tt[Math.round(e)]}${tt[Math.round(n)]}${tt[Math.round(r)]}${tt[Math.round(255*i)]}`:`#${tt[Math.round(e)]}${tt[Math.round(n)]}${tt[Math.round(r)]}`}},rt=nt,it={re:/^hsla?\(\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?(?:deg|grad|rad|turn)?)\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?%)\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?%)(?:\s*?(?:,|\/)\s*?\+?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?(%)?))?\s*?\)$/i,hueRe:/^(.+?)(deg|grad|rad|turn)$/i,_hue2deg:t=>{const e=t.match(it.hueRe);if(e){const[,t,n]=e;switch(n){case"grad":return J.channel.clamp.h(.9*parseFloat(t));case"rad":return J.channel.clamp.h(180*parseFloat(t)/Math.PI);case"turn":return J.channel.clamp.h(360*parseFloat(t))}}return J.channel.clamp.h(parseFloat(t))},parse:t=>{const e=t.charCodeAt(0);if(104!==e&&72!==e)return;const n=t.match(it.re);if(!n)return;const[,r,i,a,o,s]=n;return et.set({h:it._hue2deg(r),s:J.channel.clamp.s(parseFloat(i)),l:J.channel.clamp.l(parseFloat(a)),a:o?J.channel.clamp.a(s?parseFloat(o)/100:parseFloat(o)):1},t)},stringify:t=>{const{h:e,s:n,l:r,a:i}=t;return i<1?`hsla(${J.lang.round(e)}, ${J.lang.round(n)}%, ${J.lang.round(r)}%, ${i})`:`hsl(${J.lang.round(e)}, ${J.lang.round(n)}%, ${J.lang.round(r)}%)`}},at=it,ot={colors:{aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyanaqua:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",transparent:"#00000000",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},parse:t=>{t=t.toLowerCase();const e=ot.colors[t];if(e)return rt.parse(e)},stringify:t=>{const e=rt.stringify(t);for(const t in ot.colors)if(ot.colors[t]===e)return t}},st=ot,ct={re:/^rgba?\(\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))(?:\s*?(?:,|\/)\s*?\+?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?)))?\s*?\)$/i,parse:t=>{const e=t.charCodeAt(0);if(114!==e&&82!==e)return;const n=t.match(ct.re);if(!n)return;const[,r,i,a,o,s,c,l,u]=n;return et.set({r:J.channel.clamp.r(i?2.55*parseFloat(r):parseFloat(r)),g:J.channel.clamp.g(o?2.55*parseFloat(a):parseFloat(a)),b:J.channel.clamp.b(c?2.55*parseFloat(s):parseFloat(s)),a:l?J.channel.clamp.a(u?parseFloat(l)/100:parseFloat(l)):1},t)},stringify:t=>{const{r:e,g:n,b:r,a:i}=t;return i<1?`rgba(${J.lang.round(e)}, ${J.lang.round(n)}, ${J.lang.round(r)}, ${J.lang.round(i)})`:`rgb(${J.lang.round(e)}, ${J.lang.round(n)}, ${J.lang.round(r)})`}},lt=ct,ut={format:{keyword:st,hex:rt,rgb:lt,rgba:lt,hsl:at,hsla:at},parse:t=>{if("string"!=typeof t)return t;const e=rt.parse(t)||lt.parse(t)||at.parse(t)||st.parse(t);if(e)return e;throw new Error(`Unsupported color format: "${t}"`)},stringify:t=>!t.changed&&t.color?t.color:t.type.is(2)||void 0===t.data.r?at.stringify(t):t.a<1||!Number.isInteger(t.r)||!Number.isInteger(t.g)||!Number.isInteger(t.b)?lt.stringify(t):rt.stringify(t)},ht=(t,e)=>{const n=ut.parse(t);for(const t in e)n[t]=J.channel.clamp[t](e[t]);return ut.stringify(n)},ft=(t,e)=>{const n=ut.parse(t),r={};for(const t in e)e[t]&&(r[t]=n[t]+e[t]);return ht(t,r)},dt=(t,e,n=0,r=1)=>{if("number"!=typeof t)return ht(t,{a:e});const i=et.set({r:J.channel.clamp.r(t),g:J.channel.clamp.g(e),b:J.channel.clamp.b(n),a:J.channel.clamp.a(r)});return ut.stringify(i)},pt=(t,e=100)=>{const n=ut.parse(t);return n.r=255-n.r,n.g=255-n.g,n.b=255-n.b,((t,e,n=50)=>{const{r,g:i,b:a,a:o}=ut.parse(t),{r:s,g:c,b:l,a:u}=ut.parse(e),h=n/100,f=2*h-1,d=o-u,p=((f*d==-1?f:(f+d)/(1+f*d))+1)/2,g=1-p;return dt(r*p+s*g,i*p+c*g,a*p+l*g,o*h+u*(1-h))})(n,t,e)},gt=(t,e,n)=>{const r=ut.parse(t),i=r[e],a=J.channel.clamp[e](i+n);return i!==a&&(r[e]=a),ut.stringify(r)},yt=(t,e)=>gt(t,"l",-e),mt=(t,e)=>gt(t,"l",e);var bt=function(t,e){return ft(t,e?{s:-40,l:10}:{s:-40,l:-10})};function vt(t){return vt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vt(t)}function _t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r);}}var xt=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.background="#f4f4f4",this.darkMode=!1,this.primaryColor="#fff4dd",this.noteBkgColor="#fff5ad",this.noteTextColor="#333",this.fontFamily='"trebuchet ms", verdana, arial, sans-serif',this.fontSize="16px";}var e,n;return e=t,n=[{key:"updateColors",value:function(){this.primaryTextColor=this.primaryTextColor||(this.darkMode?"#eee":"#333"),this.secondaryColor=this.secondaryColor||ft(this.primaryColor,{h:-120}),this.tertiaryColor=this.tertiaryColor||ft(this.primaryColor,{h:180,l:5}),this.primaryBorderColor=this.primaryBorderColor||bt(this.primaryColor,this.darkMode),this.secondaryBorderColor=this.secondaryBorderColor||bt(this.secondaryColor,this.darkMode),this.tertiaryBorderColor=this.tertiaryBorderColor||bt(this.tertiaryColor,this.darkMode),this.noteBorderColor=this.noteBorderColor||bt(this.noteBkgColor,this.darkMode),this.noteBkgColor=this.noteBkgColor||"#fff5ad",this.noteTextColor=this.noteTextColor||"#333",this.secondaryTextColor=this.secondaryTextColor||pt(this.secondaryColor),this.tertiaryTextColor=this.tertiaryTextColor||pt(this.tertiaryColor),this.lineColor=this.lineColor||pt(this.background),this.textColor=this.textColor||this.primaryTextColor,this.nodeBkg=this.nodeBkg||this.primaryColor,this.mainBkg=this.mainBkg||this.primaryColor,this.nodeBorder=this.nodeBorder||this.primaryBorderColor,this.clusterBkg=this.clusterBkg||this.tertiaryColor,this.clusterBorder=this.clusterBorder||this.tertiaryBorderColor,this.defaultLinkColor=this.defaultLinkColor||this.lineColor,this.titleColor=this.titleColor||this.tertiaryTextColor,this.edgeLabelBackground=this.edgeLabelBackground||(this.darkMode?yt(this.secondaryColor,30):this.secondaryColor),this.nodeTextColor=this.nodeTextColor||this.primaryTextColor,this.actorBorder=this.actorBorder||this.primaryBorderColor,this.actorBkg=this.actorBkg||this.mainBkg,this.actorTextColor=this.actorTextColor||this.primaryTextColor,this.actorLineColor=this.actorLineColor||"grey",this.labelBoxBkgColor=this.labelBoxBkgColor||this.actorBkg,this.signalColor=this.signalColor||this.textColor,this.signalTextColor=this.signalTextColor||this.textColor,this.labelBoxBorderColor=this.labelBoxBorderColor||this.actorBorder,this.labelTextColor=this.labelTextColor||this.actorTextColor,this.loopTextColor=this.loopTextColor||this.actorTextColor,this.activationBorderColor=this.activationBorderColor||yt(this.secondaryColor,10),this.activationBkgColor=this.activationBkgColor||this.secondaryColor,this.sequenceNumberColor=this.sequenceNumberColor||pt(this.lineColor),this.sectionBkgColor=this.sectionBkgColor||this.tertiaryColor,this.altSectionBkgColor=this.altSectionBkgColor||"white",this.sectionBkgColor=this.sectionBkgColor||this.secondaryColor,this.sectionBkgColor2=this.sectionBkgColor2||this.primaryColor,this.excludeBkgColor=this.excludeBkgColor||"#eeeeee",this.taskBorderColor=this.taskBorderColor||this.primaryBorderColor,this.taskBkgColor=this.taskBkgColor||this.primaryColor,this.activeTaskBorderColor=this.activeTaskBorderColor||this.primaryColor,this.activeTaskBkgColor=this.activeTaskBkgColor||mt(this.primaryColor,23),this.gridColor=this.gridColor||"lightgrey",this.doneTaskBkgColor=this.doneTaskBkgColor||"lightgrey",this.doneTaskBorderColor=this.doneTaskBorderColor||"grey",this.critBorderColor=this.critBorderColor||"#ff8888",this.critBkgColor=this.critBkgColor||"red",this.todayLineColor=this.todayLineColor||"red",this.taskTextColor=this.taskTextColor||this.textColor,this.taskTextOutsideColor=this.taskTextOutsideColor||this.textColor,this.taskTextLightColor=this.taskTextLightColor||this.textColor,this.taskTextColor=this.taskTextColor||this.primaryTextColor,this.taskTextDarkColor=this.taskTextDarkColor||this.textColor,this.taskTextClickableColor=this.taskTextClickableColor||"#003163",this.personBorder=this.personBorder||this.primaryBorderColor,this.personBkg=this.personBkg||this.mainBkg,this.transitionColor=this.transitionColor||this.lineColor,this.transitionLabelColor=this.transitionLabelColor||this.textColor,this.stateLabelColor=this.stateLabelColor||this.stateBkg||this.primaryTextColor,this.stateBkg=this.stateBkg||this.mainBkg,this.labelBackgroundColor=this.labelBackgroundColor||this.stateBkg,this.compositeBackground=this.compositeBackground||this.background||this.tertiaryColor,this.altBackground=this.altBackground||this.tertiaryColor,this.compositeTitleBackground=this.compositeTitleBackground||this.mainBkg,this.compositeBorder=this.compositeBorder||this.nodeBorder,this.innerEndBackground=this.nodeBorder,this.errorBkgColor=this.errorBkgColor||this.tertiaryColor,this.errorTextColor=this.errorTextColor||this.tertiaryTextColor,this.transitionColor=this.transitionColor||this.lineColor,this.specialStateColor=this.lineColor,this.classText=this.classText||this.textColor,this.fillType0=this.fillType0||this.primaryColor,this.fillType1=this.fillType1||this.secondaryColor,this.fillType2=this.fillType2||ft(this.primaryColor,{h:64}),this.fillType3=this.fillType3||ft(this.secondaryColor,{h:64}),this.fillType4=this.fillType4||ft(this.primaryColor,{h:-64}),this.fillType5=this.fillType5||ft(this.secondaryColor,{h:-64}),this.fillType6=this.fillType6||ft(this.primaryColor,{h:128}),this.fillType7=this.fillType7||ft(this.secondaryColor,{h:128}),this.pie1=this.pie1||this.primaryColor,this.pie2=this.pie2||this.secondaryColor,this.pie3=this.pie3||this.tertiaryColor,this.pie4=this.pie4||ft(this.primaryColor,{l:-10}),this.pie5=this.pie5||ft(this.secondaryColor,{l:-10}),this.pie6=this.pie6||ft(this.tertiaryColor,{l:-10}),this.pie7=this.pie7||ft(this.primaryColor,{h:60,l:-10}),this.pie8=this.pie8||ft(this.primaryColor,{h:-60,l:-10}),this.pie9=this.pie9||ft(this.primaryColor,{h:120,l:0}),this.pie10=this.pie10||ft(this.primaryColor,{h:60,l:-20}),this.pie11=this.pie11||ft(this.primaryColor,{h:-60,l:-20}),this.pie12=this.pie12||ft(this.primaryColor,{h:120,l:-10}),this.pieTitleTextSize=this.pieTitleTextSize||"25px",this.pieTitleTextColor=this.pieTitleTextColor||this.taskTextDarkColor,this.pieSectionTextSize=this.pieSectionTextSize||"17px",this.pieSectionTextColor=this.pieSectionTextColor||this.textColor,this.pieLegendTextSize=this.pieLegendTextSize||"17px",this.pieLegendTextColor=this.pieLegendTextColor||this.taskTextDarkColor,this.pieStrokeColor=this.pieStrokeColor||"black",this.pieStrokeWidth=this.pieStrokeWidth||"2px",this.pieOpacity=this.pieOpacity||"0.7",this.requirementBackground=this.requirementBackground||this.primaryColor,this.requirementBorderColor=this.requirementBorderColor||this.primaryBorderColor,this.requirementBorderSize=this.requirementBorderSize||this.primaryBorderColor,this.requirementTextColor=this.requirementTextColor||this.primaryTextColor,this.relationColor=this.relationColor||this.lineColor,this.relationLabelBackground=this.relationLabelBackground||(this.darkMode?yt(this.secondaryColor,30):this.secondaryColor),this.relationLabelColor=this.relationLabelColor||this.actorTextColor,this.git0=this.git0||this.primaryColor,this.git1=this.git1||this.secondaryColor,this.git2=this.git2||this.tertiaryColor,this.git3=this.git3||ft(this.primaryColor,{h:-30}),this.git4=this.git4||ft(this.primaryColor,{h:-60}),this.git5=this.git5||ft(this.primaryColor,{h:-90}),this.git6=this.git6||ft(this.primaryColor,{h:60}),this.git7=this.git7||ft(this.primaryColor,{h:120}),this.darkMode?(this.git0=mt(this.git0,25),this.git1=mt(this.git1,25),this.git2=mt(this.git2,25),this.git3=mt(this.git3,25),this.git4=mt(this.git4,25),this.git5=mt(this.git5,25),this.git6=mt(this.git6,25),this.git7=mt(this.git7,25)):(this.git0=yt(this.git0,25),this.git1=yt(this.git1,25),this.git2=yt(this.git2,25),this.git3=yt(this.git3,25),this.git4=yt(this.git4,25),this.git5=yt(this.git5,25),this.git6=yt(this.git6,25),this.git7=yt(this.git7,25)),this.gitInv0=this.gitInv0||pt(this.git0),this.gitInv1=this.gitInv1||pt(this.git1),this.gitInv2=this.gitInv2||pt(this.git2),this.gitInv3=this.gitInv3||pt(this.git3),this.gitInv4=this.gitInv4||pt(this.git4),this.gitInv5=this.gitInv5||pt(this.git5),this.gitInv6=this.gitInv6||pt(this.git6),this.gitInv7=this.gitInv7||pt(this.git7),this.branchLabelColor=this.branchLabelColor||(this.darkMode?"black":this.labelTextColor),this.gitBranchLabel0=this.gitBranchLabel0||this.branchLabelColor,this.gitBranchLabel1=this.gitBranchLabel1||this.branchLabelColor,this.gitBranchLabel2=this.gitBranchLabel2||this.branchLabelColor,this.gitBranchLabel3=this.gitBranchLabel3||this.branchLabelColor,this.gitBranchLabel4=this.gitBranchLabel4||this.branchLabelColor,this.gitBranchLabel5=this.gitBranchLabel5||this.branchLabelColor,this.gitBranchLabel6=this.gitBranchLabel6||this.branchLabelColor,this.gitBranchLabel7=this.gitBranchLabel7||this.branchLabelColor,this.tagLabelColor=this.tagLabelColor||this.primaryTextColor,this.tagLabelBackground=this.tagLabelBackground||this.primaryColor,this.tagLabelBorder=this.tagBorder||this.primaryBorderColor,this.tagLabelFontSize=this.tagLabelFontSize||"10px",this.commitLabelColor=this.commitLabelColor||this.secondaryTextColor,this.commitLabelBackground=this.commitLabelBackground||this.secondaryColor,this.commitLabelFontSize=this.commitLabelFontSize||"10px";}},{key:"calculate",value:function(t){var e=this;if("object"===vt(t)){var n=Object.keys(t);n.forEach((function(n){e[n]=t[n];})),this.updateColors(),n.forEach((function(n){e[n]=t[n];}));}else this.updateColors();}}],n&&_t(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function kt(t){return kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},kt(t)}function wt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r);}}var Tt=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.background="#333",this.primaryColor="#1f2020",this.secondaryColor=mt(this.primaryColor,16),this.tertiaryColor=ft(this.primaryColor,{h:-160}),this.primaryBorderColor=pt(this.background),this.secondaryBorderColor=bt(this.secondaryColor,this.darkMode),this.tertiaryBorderColor=bt(this.tertiaryColor,this.darkMode),this.primaryTextColor=pt(this.primaryColor),this.secondaryTextColor=pt(this.secondaryColor),this.tertiaryTextColor=pt(this.tertiaryColor),this.lineColor=pt(this.background),this.textColor=pt(this.background),this.mainBkg="#1f2020",this.secondBkg="calculated",this.mainContrastColor="lightgrey",this.darkTextColor=mt(pt("#323D47"),10),this.lineColor="calculated",this.border1="#81B1DB",this.border2=dt(255,255,255,.25),this.arrowheadColor="calculated",this.fontFamily='"trebuchet ms", verdana, arial, sans-serif',this.fontSize="16px",this.labelBackground="#181818",this.textColor="#ccc",this.nodeBkg="calculated",this.nodeBorder="calculated",this.clusterBkg="calculated",this.clusterBorder="calculated",this.defaultLinkColor="calculated",this.titleColor="#F9FFFE",this.edgeLabelBackground="calculated",this.actorBorder="calculated",this.actorBkg="calculated",this.actorTextColor="calculated",this.actorLineColor="calculated",this.signalColor="calculated",this.signalTextColor="calculated",this.labelBoxBkgColor="calculated",this.labelBoxBorderColor="calculated",this.labelTextColor="calculated",this.loopTextColor="calculated",this.noteBorderColor="calculated",this.noteBkgColor="#fff5ad",this.noteTextColor="calculated",this.activationBorderColor="calculated",this.activationBkgColor="calculated",this.sequenceNumberColor="black",this.sectionBkgColor=yt("#EAE8D9",30),this.altSectionBkgColor="calculated",this.sectionBkgColor2="#EAE8D9",this.taskBorderColor=dt(255,255,255,70),this.taskBkgColor="calculated",this.taskTextColor="calculated",this.taskTextLightColor="calculated",this.taskTextOutsideColor="calculated",this.taskTextClickableColor="#003163",this.activeTaskBorderColor=dt(255,255,255,50),this.activeTaskBkgColor="#81B1DB",this.gridColor="calculated",this.doneTaskBkgColor="calculated",this.doneTaskBorderColor="grey",this.critBorderColor="#E83737",this.critBkgColor="#E83737",this.taskTextDarkColor="calculated",this.todayLineColor="#DB5757",this.personBorder="calculated",this.personBkg="calculated",this.labelColor="calculated",this.errorBkgColor="#a44141",this.errorTextColor="#ddd";}var e,n;return e=t,n=[{key:"updateColors",value:function(){this.secondBkg=mt(this.mainBkg,16),this.lineColor=this.mainContrastColor,this.arrowheadColor=this.mainContrastColor,this.nodeBkg=this.mainBkg,this.nodeBorder=this.border1,this.clusterBkg=this.secondBkg,this.clusterBorder=this.border2,this.defaultLinkColor=this.lineColor,this.edgeLabelBackground=mt(this.labelBackground,25),this.actorBorder=this.border1,this.actorBkg=this.mainBkg,this.actorTextColor=this.mainContrastColor,this.actorLineColor=this.mainContrastColor,this.signalColor=this.mainContrastColor,this.signalTextColor=this.mainContrastColor,this.labelBoxBkgColor=this.actorBkg,this.labelBoxBorderColor=this.actorBorder,this.labelTextColor=this.mainContrastColor,this.loopTextColor=this.mainContrastColor,this.noteBorderColor=this.secondaryBorderColor,this.noteBkgColor=this.secondBkg,this.noteTextColor=this.secondaryTextColor,this.activationBorderColor=this.border1,this.activationBkgColor=this.secondBkg,this.altSectionBkgColor=this.background,this.taskBkgColor=mt(this.mainBkg,23),this.taskTextColor=this.darkTextColor,this.taskTextLightColor=this.mainContrastColor,this.taskTextOutsideColor=this.taskTextLightColor,this.gridColor=this.mainContrastColor,this.doneTaskBkgColor=this.mainContrastColor,this.taskTextDarkColor=this.darkTextColor,this.transitionColor=this.transitionColor||this.lineColor,this.transitionLabelColor=this.transitionLabelColor||this.textColor,this.stateLabelColor=this.stateLabelColor||this.stateBkg||this.primaryTextColor,this.stateBkg=this.stateBkg||this.mainBkg,this.labelBackgroundColor=this.labelBackgroundColor||this.stateBkg,this.compositeBackground=this.compositeBackground||this.background||this.tertiaryColor,this.altBackground=this.altBackground||"#555",this.compositeTitleBackground=this.compositeTitleBackground||this.mainBkg,this.compositeBorder=this.compositeBorder||this.nodeBorder,this.innerEndBackground=this.primaryBorderColor,this.specialStateColor="#f4f4f4",this.errorBkgColor=this.errorBkgColor||this.tertiaryColor,this.errorTextColor=this.errorTextColor||this.tertiaryTextColor,this.fillType0=this.primaryColor,this.fillType1=this.secondaryColor,this.fillType2=ft(this.primaryColor,{h:64}),this.fillType3=ft(this.secondaryColor,{h:64}),this.fillType4=ft(this.primaryColor,{h:-64}),this.fillType5=ft(this.secondaryColor,{h:-64}),this.fillType6=ft(this.primaryColor,{h:128}),this.fillType7=ft(this.secondaryColor,{h:128}),this.pie1=this.pie1||"#0b0000",this.pie2=this.pie2||"#4d1037",this.pie3=this.pie3||"#3f5258",this.pie4=this.pie4||"#4f2f1b",this.pie5=this.pie5||"#6e0a0a",this.pie6=this.pie6||"#3b0048",this.pie7=this.pie7||"#995a01",this.pie8=this.pie8||"#154706",this.pie9=this.pie9||"#161722",this.pie10=this.pie10||"#00296f",this.pie11=this.pie11||"#01629c",this.pie12=this.pie12||"#010029",this.pieTitleTextSize=this.pieTitleTextSize||"25px",this.pieTitleTextColor=this.pieTitleTextColor||this.taskTextDarkColor,this.pieSectionTextSize=this.pieSectionTextSize||"17px",this.pieSectionTextColor=this.pieSectionTextColor||this.textColor,this.pieLegendTextSize=this.pieLegendTextSize||"17px",this.pieLegendTextColor=this.pieLegendTextColor||this.taskTextDarkColor,this.pieStrokeColor=this.pieStrokeColor||"black",this.pieStrokeWidth=this.pieStrokeWidth||"2px",this.pieOpacity=this.pieOpacity||"0.7",this.classText=this.primaryTextColor,this.requirementBackground=this.requirementBackground||this.primaryColor,this.requirementBorderColor=this.requirementBorderColor||this.primaryBorderColor,this.requirementBorderSize=this.requirementBorderSize||this.primaryBorderColor,this.requirementTextColor=this.requirementTextColor||this.primaryTextColor,this.relationColor=this.relationColor||this.lineColor,this.relationLabelBackground=this.relationLabelBackground||(this.darkMode?yt(this.secondaryColor,30):this.secondaryColor),this.relationLabelColor=this.relationLabelColor||this.actorTextColor,this.git0=mt(this.secondaryColor,20),this.git1=mt(this.pie2||this.secondaryColor,20),this.git2=mt(this.pie3||this.tertiaryColor,20),this.git3=mt(this.pie4||ft(this.primaryColor,{h:-30}),20),this.git4=mt(this.pie5||ft(this.primaryColor,{h:-60}),20),this.git5=mt(this.pie6||ft(this.primaryColor,{h:-90}),10),this.git6=mt(this.pie7||ft(this.primaryColor,{h:60}),10),this.git7=mt(this.pie8||ft(this.primaryColor,{h:120}),20),this.gitInv0=this.gitInv0||pt(this.git0),this.gitInv1=this.gitInv1||pt(this.git1),this.gitInv2=this.gitInv2||pt(this.git2),this.gitInv3=this.gitInv3||pt(this.git3),this.gitInv4=this.gitInv4||pt(this.git4),this.gitInv5=this.gitInv5||pt(this.git5),this.gitInv6=this.gitInv6||pt(this.git6),this.gitInv7=this.gitInv7||pt(this.git7),this.tagLabelColor=this.tagLabelColor||this.primaryTextColor,this.tagLabelBackground=this.tagLabelBackground||this.primaryColor,this.tagLabelBorder=this.tagBorder||this.primaryBorderColor,this.tagLabelFontSize=this.tagLabelFontSize||"10px",this.commitLabelColor=this.commitLabelColor||this.secondaryTextColor,this.commitLabelBackground=this.commitLabelBackground||this.secondaryColor,this.commitLabelFontSize=this.commitLabelFontSize||"10px";}},{key:"calculate",value:function(t){var e=this;if("object"===kt(t)){var n=Object.keys(t);n.forEach((function(n){e[n]=t[n];})),this.updateColors(),n.forEach((function(n){e[n]=t[n];}));}else this.updateColors();}}],n&&wt(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function Et(t){return Et="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Et(t)}function Ct(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r);}}var St=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.background="#f4f4f4",this.primaryColor="#ECECFF",this.secondaryColor=ft(this.primaryColor,{h:120}),this.secondaryColor="#ffffde",this.tertiaryColor=ft(this.primaryColor,{h:-160}),this.primaryBorderColor=bt(this.primaryColor,this.darkMode),this.secondaryBorderColor=bt(this.secondaryColor,this.darkMode),this.tertiaryBorderColor=bt(this.tertiaryColor,this.darkMode),this.primaryTextColor=pt(this.primaryColor),this.secondaryTextColor=pt(this.secondaryColor),this.tertiaryTextColor=pt(this.tertiaryColor),this.lineColor=pt(this.background),this.textColor=pt(this.background),this.background="white",this.mainBkg="#ECECFF",this.secondBkg="#ffffde",this.lineColor="#333333",this.border1="#9370DB",this.border2="#aaaa33",this.arrowheadColor="#333333",this.fontFamily='"trebuchet ms", verdana, arial, sans-serif',this.fontSize="16px",this.labelBackground="#e8e8e8",this.textColor="#333",this.nodeBkg="calculated",this.nodeBorder="calculated",this.clusterBkg="calculated",this.clusterBorder="calculated",this.defaultLinkColor="calculated",this.titleColor="calculated",this.edgeLabelBackground="calculated",this.actorBorder="calculated",this.actorBkg="calculated",this.actorTextColor="black",this.actorLineColor="grey",this.signalColor="calculated",this.signalTextColor="calculated",this.labelBoxBkgColor="calculated",this.labelBoxBorderColor="calculated",this.labelTextColor="calculated",this.loopTextColor="calculated",this.noteBorderColor="calculated",this.noteBkgColor="#fff5ad",this.noteTextColor="calculated",this.activationBorderColor="#666",this.activationBkgColor="#f4f4f4",this.sequenceNumberColor="white",this.sectionBkgColor="calculated",this.altSectionBkgColor="calculated",this.sectionBkgColor2="calculated",this.excludeBkgColor="#eeeeee",this.taskBorderColor="calculated",this.taskBkgColor="calculated",this.taskTextLightColor="calculated",this.taskTextColor=this.taskTextLightColor,this.taskTextDarkColor="calculated",this.taskTextOutsideColor=this.taskTextDarkColor,this.taskTextClickableColor="calculated",this.activeTaskBorderColor="calculated",this.activeTaskBkgColor="calculated",this.gridColor="calculated",this.doneTaskBkgColor="calculated",this.doneTaskBorderColor="calculated",this.critBorderColor="calculated",this.critBkgColor="calculated",this.todayLineColor="calculated",this.sectionBkgColor=dt(102,102,255,.49),this.altSectionBkgColor="white",this.sectionBkgColor2="#fff400",this.taskBorderColor="#534fbc",this.taskBkgColor="#8a90dd",this.taskTextLightColor="white",this.taskTextColor="calculated",this.taskTextDarkColor="black",this.taskTextOutsideColor="calculated",this.taskTextClickableColor="#003163",this.activeTaskBorderColor="#534fbc",this.activeTaskBkgColor="#bfc7ff",this.gridColor="lightgrey",this.doneTaskBkgColor="lightgrey",this.doneTaskBorderColor="grey",this.critBorderColor="#ff8888",this.critBkgColor="red",this.todayLineColor="red",this.personBorder="calculated",this.personBkg="calculated",this.labelColor="black",this.errorBkgColor="#552222",this.errorTextColor="#552222",this.updateColors();}var e,n;return e=t,n=[{key:"updateColors",value:function(){this.nodeBkg=this.mainBkg,this.nodeBorder=this.border1,this.clusterBkg=this.secondBkg,this.clusterBorder=this.border2,this.defaultLinkColor=this.lineColor,this.titleColor=this.textColor,this.edgeLabelBackground=this.labelBackground,this.actorBorder=mt(this.border1,23),this.actorBkg=this.mainBkg,this.labelBoxBkgColor=this.actorBkg,this.signalColor=this.textColor,this.signalTextColor=this.textColor,this.labelBoxBorderColor=this.actorBorder,this.labelTextColor=this.actorTextColor,this.loopTextColor=this.actorTextColor,this.noteBorderColor=this.border2,this.noteTextColor=this.actorTextColor,this.taskTextColor=this.taskTextLightColor,this.taskTextOutsideColor=this.taskTextDarkColor,this.transitionColor=this.transitionColor||this.lineColor,this.transitionLabelColor=this.transitionLabelColor||this.textColor,this.stateLabelColor=this.stateLabelColor||this.stateBkg||this.primaryTextColor,this.stateBkg=this.stateBkg||this.mainBkg,this.labelBackgroundColor=this.labelBackgroundColor||this.stateBkg,this.compositeBackground=this.compositeBackground||this.background||this.tertiaryColor,this.altBackground=this.altBackground||"#f0f0f0",this.compositeTitleBackground=this.compositeTitleBackground||this.mainBkg,this.compositeBorder=this.compositeBorder||this.nodeBorder,this.innerEndBackground=this.nodeBorder,this.specialStateColor=this.lineColor,this.errorBkgColor=this.errorBkgColor||this.tertiaryColor,this.errorTextColor=this.errorTextColor||this.tertiaryTextColor,this.transitionColor=this.transitionColor||this.lineColor,this.classText=this.primaryTextColor,this.fillType0=this.primaryColor,this.fillType1=this.secondaryColor,this.fillType2=ft(this.primaryColor,{h:64}),this.fillType3=ft(this.secondaryColor,{h:64}),this.fillType4=ft(this.primaryColor,{h:-64}),this.fillType5=ft(this.secondaryColor,{h:-64}),this.fillType6=ft(this.primaryColor,{h:128}),this.fillType7=ft(this.secondaryColor,{h:128}),this.pie1=this.pie1||this.primaryColor,this.pie2=this.pie2||this.secondaryColor,this.pie3=this.pie3||ft(this.tertiaryColor,{l:-40}),this.pie4=this.pie4||ft(this.primaryColor,{l:-10}),this.pie5=this.pie5||ft(this.secondaryColor,{l:-30}),this.pie6=this.pie6||ft(this.tertiaryColor,{l:-20}),this.pie7=this.pie7||ft(this.primaryColor,{h:60,l:-20}),this.pie8=this.pie8||ft(this.primaryColor,{h:-60,l:-40}),this.pie9=this.pie9||ft(this.primaryColor,{h:120,l:-40}),this.pie10=this.pie10||ft(this.primaryColor,{h:60,l:-40}),this.pie11=this.pie11||ft(this.primaryColor,{h:-90,l:-40}),this.pie12=this.pie12||ft(this.primaryColor,{h:120,l:-30}),this.pieTitleTextSize=this.pieTitleTextSize||"25px",this.pieTitleTextColor=this.pieTitleTextColor||this.taskTextDarkColor,this.pieSectionTextSize=this.pieSectionTextSize||"17px",this.pieSectionTextColor=this.pieSectionTextColor||this.textColor,this.pieLegendTextSize=this.pieLegendTextSize||"17px",this.pieLegendTextColor=this.pieLegendTextColor||this.taskTextDarkColor,this.pieStrokeColor=this.pieStrokeColor||"black",this.pieStrokeWidth=this.pieStrokeWidth||"2px",this.pieOpacity=this.pieOpacity||"0.7",this.requirementBackground=this.requirementBackground||this.primaryColor,this.requirementBorderColor=this.requirementBorderColor||this.primaryBorderColor,this.requirementBorderSize=this.requirementBorderSize||this.primaryBorderColor,this.requirementTextColor=this.requirementTextColor||this.primaryTextColor,this.relationColor=this.relationColor||this.lineColor,this.relationLabelBackground=this.relationLabelBackground||this.labelBackground,this.relationLabelColor=this.relationLabelColor||this.actorTextColor,this.git0=this.git0||this.primaryColor,this.git1=this.git1||this.secondaryColor,this.git2=this.git2||this.tertiaryColor,this.git3=this.git3||ft(this.primaryColor,{h:-30}),this.git4=this.git4||ft(this.primaryColor,{h:-60}),this.git5=this.git5||ft(this.primaryColor,{h:-90}),this.git6=this.git6||ft(this.primaryColor,{h:60}),this.git7=this.git7||ft(this.primaryColor,{h:120}),this.darkMode?(this.git0=mt(this.git0,25),this.git1=mt(this.git1,25),this.git2=mt(this.git2,25),this.git3=mt(this.git3,25),this.git4=mt(this.git4,25),this.git5=mt(this.git5,25),this.git6=mt(this.git6,25),this.git7=mt(this.git7,25)):(this.git0=yt(this.git0,25),this.git1=yt(this.git1,25),this.git2=yt(this.git2,25),this.git3=yt(this.git3,25),this.git4=yt(this.git4,25),this.git5=yt(this.git5,25),this.git6=yt(this.git6,25),this.git7=yt(this.git7,25)),this.gitInv0=this.gitInv0||yt(pt(this.git0),25),this.gitInv1=this.gitInv1||pt(this.git1),this.gitInv2=this.gitInv2||pt(this.git2),this.gitInv3=this.gitInv3||pt(this.git3),this.gitInv4=this.gitInv4||pt(this.git4),this.gitInv5=this.gitInv5||pt(this.git5),this.gitInv6=this.gitInv6||pt(this.git6),this.gitInv7=this.gitInv7||pt(this.git7),this.gitBranchLabel0=this.gitBranchLabel0||pt(this.labelTextColor),this.gitBranchLabel1=this.gitBranchLabel1||this.labelTextColor,this.gitBranchLabel2=this.gitBranchLabel2||this.labelTextColor,this.gitBranchLabel3=this.gitBranchLabel3||pt(this.labelTextColor),this.gitBranchLabel4=this.gitBranchLabel4||this.labelTextColor,this.gitBranchLabel5=this.gitBranchLabel5||this.labelTextColor,this.gitBranchLabel6=this.gitBranchLabel6||this.labelTextColor,this.gitBranchLabel7=this.gitBranchLabel7||this.labelTextColor,this.tagLabelColor=this.tagLabelColor||this.primaryTextColor,this.tagLabelBackground=this.tagLabelBackground||this.primaryColor,this.tagLabelBorder=this.tagBorder||this.primaryBorderColor,this.tagLabelFontSize=this.tagLabelFontSize||"10px",this.commitLabelColor=this.commitLabelColor||this.secondaryTextColor,this.commitLabelBackground=this.commitLabelBackground||this.secondaryColor,this.commitLabelFontSize=this.commitLabelFontSize||"10px";}},{key:"calculate",value:function(t){var e=this;if("object"===Et(t)){var n=Object.keys(t);n.forEach((function(n){e[n]=t[n];})),this.updateColors(),n.forEach((function(n){e[n]=t[n];}));}else this.updateColors();}}],n&&Ct(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function At(t){return At="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},At(t)}function Mt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r);}}var Nt=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.background="#f4f4f4",this.primaryColor="#cde498",this.secondaryColor="#cdffb2",this.background="white",this.mainBkg="#cde498",this.secondBkg="#cdffb2",this.lineColor="green",this.border1="#13540c",this.border2="#6eaa49",this.arrowheadColor="green",this.fontFamily='"trebuchet ms", verdana, arial, sans-serif',this.fontSize="16px",this.tertiaryColor=mt("#cde498",10),this.primaryBorderColor=bt(this.primaryColor,this.darkMode),this.secondaryBorderColor=bt(this.secondaryColor,this.darkMode),this.tertiaryBorderColor=bt(this.tertiaryColor,this.darkMode),this.primaryTextColor=pt(this.primaryColor),this.secondaryTextColor=pt(this.secondaryColor),this.tertiaryTextColor=pt(this.primaryColor),this.lineColor=pt(this.background),this.textColor=pt(this.background),this.nodeBkg="calculated",this.nodeBorder="calculated",this.clusterBkg="calculated",this.clusterBorder="calculated",this.defaultLinkColor="calculated",this.titleColor="#333",this.edgeLabelBackground="#e8e8e8",this.actorBorder="calculated",this.actorBkg="calculated",this.actorTextColor="black",this.actorLineColor="grey",this.signalColor="#333",this.signalTextColor="#333",this.labelBoxBkgColor="calculated",this.labelBoxBorderColor="#326932",this.labelTextColor="calculated",this.loopTextColor="calculated",this.noteBorderColor="calculated",this.noteBkgColor="#fff5ad",this.noteTextColor="calculated",this.activationBorderColor="#666",this.activationBkgColor="#f4f4f4",this.sequenceNumberColor="white",this.sectionBkgColor="#6eaa49",this.altSectionBkgColor="white",this.sectionBkgColor2="#6eaa49",this.excludeBkgColor="#eeeeee",this.taskBorderColor="calculated",this.taskBkgColor="#487e3a",this.taskTextLightColor="white",this.taskTextColor="calculated",this.taskTextDarkColor="black",this.taskTextOutsideColor="calculated",this.taskTextClickableColor="#003163",this.activeTaskBorderColor="calculated",this.activeTaskBkgColor="calculated",this.gridColor="lightgrey",this.doneTaskBkgColor="lightgrey",this.doneTaskBorderColor="grey",this.critBorderColor="#ff8888",this.critBkgColor="red",this.todayLineColor="red",this.personBorder="calculated",this.personBkg="calculated",this.labelColor="black",this.errorBkgColor="#552222",this.errorTextColor="#552222";}var e,n;return e=t,n=[{key:"updateColors",value:function(){this.nodeBkg=this.mainBkg,this.nodeBorder=this.border1,this.clusterBkg=this.secondBkg,this.clusterBorder=this.border2,this.defaultLinkColor=this.lineColor,this.actorBorder=yt(this.mainBkg,20),this.actorBkg=this.mainBkg,this.labelBoxBkgColor=this.actorBkg,this.labelTextColor=this.actorTextColor,this.loopTextColor=this.actorTextColor,this.noteBorderColor=this.border2,this.noteTextColor=this.actorTextColor,this.taskBorderColor=this.border1,this.taskTextColor=this.taskTextLightColor,this.taskTextOutsideColor=this.taskTextDarkColor,this.activeTaskBorderColor=this.taskBorderColor,this.activeTaskBkgColor=this.mainBkg,this.transitionColor=this.transitionColor||this.lineColor,this.transitionLabelColor=this.transitionLabelColor||this.textColor,this.stateLabelColor=this.stateLabelColor||this.stateBkg||this.primaryTextColor,this.stateBkg=this.stateBkg||this.mainBkg,this.labelBackgroundColor=this.labelBackgroundColor||this.stateBkg,this.compositeBackground=this.compositeBackground||this.background||this.tertiaryColor,this.altBackground=this.altBackground||"#f0f0f0",this.compositeTitleBackground=this.compositeTitleBackground||this.mainBkg,this.compositeBorder=this.compositeBorder||this.nodeBorder,this.innerEndBackground=this.primaryBorderColor,this.specialStateColor=this.lineColor,this.errorBkgColor=this.errorBkgColor||this.tertiaryColor,this.errorTextColor=this.errorTextColor||this.tertiaryTextColor,this.transitionColor=this.transitionColor||this.lineColor,this.classText=this.primaryTextColor,this.fillType0=this.primaryColor,this.fillType1=this.secondaryColor,this.fillType2=ft(this.primaryColor,{h:64}),this.fillType3=ft(this.secondaryColor,{h:64}),this.fillType4=ft(this.primaryColor,{h:-64}),this.fillType5=ft(this.secondaryColor,{h:-64}),this.fillType6=ft(this.primaryColor,{h:128}),this.fillType7=ft(this.secondaryColor,{h:128}),this.pie1=this.pie1||this.primaryColor,this.pie2=this.pie2||this.secondaryColor,this.pie3=this.pie3||this.tertiaryColor,this.pie4=this.pie4||ft(this.primaryColor,{l:-30}),this.pie5=this.pie5||ft(this.secondaryColor,{l:-30}),this.pie6=this.pie6||ft(this.tertiaryColor,{h:40,l:-40}),this.pie7=this.pie7||ft(this.primaryColor,{h:60,l:-10}),this.pie8=this.pie8||ft(this.primaryColor,{h:-60,l:-10}),this.pie9=this.pie9||ft(this.primaryColor,{h:120,l:0}),this.pie10=this.pie10||ft(this.primaryColor,{h:60,l:-50}),this.pie11=this.pie11||ft(this.primaryColor,{h:-60,l:-50}),this.pie12=this.pie12||ft(this.primaryColor,{h:120,l:-50}),this.pieTitleTextSize=this.pieTitleTextSize||"25px",this.pieTitleTextColor=this.pieTitleTextColor||this.taskTextDarkColor,this.pieSectionTextSize=this.pieSectionTextSize||"17px",this.pieSectionTextColor=this.pieSectionTextColor||this.textColor,this.pieLegendTextSize=this.pieLegendTextSize||"17px",this.pieLegendTextColor=this.pieLegendTextColor||this.taskTextDarkColor,this.pieStrokeColor=this.pieStrokeColor||"black",this.pieStrokeWidth=this.pieStrokeWidth||"2px",this.pieOpacity=this.pieOpacity||"0.7",this.requirementBackground=this.requirementBackground||this.primaryColor,this.requirementBorderColor=this.requirementBorderColor||this.primaryBorderColor,this.requirementBorderSize=this.requirementBorderSize||this.primaryBorderColor,this.requirementTextColor=this.requirementTextColor||this.primaryTextColor,this.relationColor=this.relationColor||this.lineColor,this.relationLabelBackground=this.relationLabelBackground||this.edgeLabelBackground,this.relationLabelColor=this.relationLabelColor||this.actorTextColor,this.git0=this.git0||this.primaryColor,this.git1=this.git1||this.secondaryColor,this.git2=this.git2||this.tertiaryColor,this.git3=this.git3||ft(this.primaryColor,{h:-30}),this.git4=this.git4||ft(this.primaryColor,{h:-60}),this.git5=this.git5||ft(this.primaryColor,{h:-90}),this.git6=this.git6||ft(this.primaryColor,{h:60}),this.git7=this.git7||ft(this.primaryColor,{h:120}),this.darkMode?(this.git0=mt(this.git0,25),this.git1=mt(this.git1,25),this.git2=mt(this.git2,25),this.git3=mt(this.git3,25),this.git4=mt(this.git4,25),this.git5=mt(this.git5,25),this.git6=mt(this.git6,25),this.git7=mt(this.git7,25)):(this.git0=yt(this.git0,25),this.git1=yt(this.git1,25),this.git2=yt(this.git2,25),this.git3=yt(this.git3,25),this.git4=yt(this.git4,25),this.git5=yt(this.git5,25),this.git6=yt(this.git6,25),this.git7=yt(this.git7,25)),this.gitInv0=this.gitInv0||pt(this.git0),this.gitInv1=this.gitInv1||pt(this.git1),this.gitInv2=this.gitInv2||pt(this.git2),this.gitInv3=this.gitInv3||pt(this.git3),this.gitInv4=this.gitInv4||pt(this.git4),this.gitInv5=this.gitInv5||pt(this.git5),this.gitInv6=this.gitInv6||pt(this.git6),this.gitInv7=this.gitInv7||pt(this.git7),this.tagLabelColor=this.tagLabelColor||this.primaryTextColor,this.tagLabelBackground=this.tagLabelBackground||this.primaryColor,this.tagLabelBorder=this.tagBorder||this.primaryBorderColor,this.tagLabelFontSize=this.tagLabelFontSize||"10px",this.commitLabelColor=this.commitLabelColor||this.secondaryTextColor,this.commitLabelBackground=this.commitLabelBackground||this.secondaryColor,this.commitLabelFontSize=this.commitLabelFontSize||"10px";}},{key:"calculate",value:function(t){var e=this;if("object"===At(t)){var n=Object.keys(t);n.forEach((function(n){e[n]=t[n];})),this.updateColors(),n.forEach((function(n){e[n]=t[n];}));}else this.updateColors();}}],n&&Mt(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function Ot(t){return Ot="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ot(t)}function Dt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r);}}var Bt=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.primaryColor="#eee",this.contrast="#707070",this.secondaryColor=mt(this.contrast,55),this.background="#ffffff",this.tertiaryColor=ft(this.primaryColor,{h:-160}),this.primaryBorderColor=bt(this.primaryColor,this.darkMode),this.secondaryBorderColor=bt(this.secondaryColor,this.darkMode),this.tertiaryBorderColor=bt(this.tertiaryColor,this.darkMode),this.primaryTextColor=pt(this.primaryColor),this.secondaryTextColor=pt(this.secondaryColor),this.tertiaryTextColor=pt(this.tertiaryColor),this.lineColor=pt(this.background),this.textColor=pt(this.background),this.mainBkg="#eee",this.secondBkg="calculated",this.lineColor="#666",this.border1="#999",this.border2="calculated",this.note="#ffa",this.text="#333",this.critical="#d42",this.done="#bbb",this.arrowheadColor="#333333",this.fontFamily='"trebuchet ms", verdana, arial, sans-serif',this.fontSize="16px",this.nodeBkg="calculated",this.nodeBorder="calculated",this.clusterBkg="calculated",this.clusterBorder="calculated",this.defaultLinkColor="calculated",this.titleColor="calculated",this.edgeLabelBackground="white",this.actorBorder="calculated",this.actorBkg="calculated",this.actorTextColor="calculated",this.actorLineColor="calculated",this.signalColor="calculated",this.signalTextColor="calculated",this.labelBoxBkgColor="calculated",this.labelBoxBorderColor="calculated",this.labelTextColor="calculated",this.loopTextColor="calculated",this.noteBorderColor="calculated",this.noteBkgColor="calculated",this.noteTextColor="calculated",this.activationBorderColor="#666",this.activationBkgColor="#f4f4f4",this.sequenceNumberColor="white",this.sectionBkgColor="calculated",this.altSectionBkgColor="white",this.sectionBkgColor2="calculated",this.excludeBkgColor="#eeeeee",this.taskBorderColor="calculated",this.taskBkgColor="calculated",this.taskTextLightColor="white",this.taskTextColor="calculated",this.taskTextDarkColor="calculated",this.taskTextOutsideColor="calculated",this.taskTextClickableColor="#003163",this.activeTaskBorderColor="calculated",this.activeTaskBkgColor="calculated",this.gridColor="calculated",this.doneTaskBkgColor="calculated",this.doneTaskBorderColor="calculated",this.critBkgColor="calculated",this.critBorderColor="calculated",this.todayLineColor="calculated",this.personBorder="calculated",this.personBkg="calculated",this.labelColor="black",this.errorBkgColor="#552222",this.errorTextColor="#552222";}var e,n;return e=t,n=[{key:"updateColors",value:function(){this.secondBkg=mt(this.contrast,55),this.border2=this.contrast,this.nodeBkg=this.mainBkg,this.nodeBorder=this.border1,this.clusterBkg=this.secondBkg,this.clusterBorder=this.border2,this.defaultLinkColor=this.lineColor,this.titleColor=this.text,this.actorBorder=mt(this.border1,23),this.actorBkg=this.mainBkg,this.actorTextColor=this.text,this.actorLineColor=this.lineColor,this.signalColor=this.text,this.signalTextColor=this.text,this.labelBoxBkgColor=this.actorBkg,this.labelBoxBorderColor=this.actorBorder,this.labelTextColor=this.text,this.loopTextColor=this.text,this.noteBorderColor="#999",this.noteBkgColor="#666",this.noteTextColor="#fff",this.sectionBkgColor=mt(this.contrast,30),this.sectionBkgColor2=mt(this.contrast,30),this.taskBorderColor=yt(this.contrast,10),this.taskBkgColor=this.contrast,this.taskTextColor=this.taskTextLightColor,this.taskTextDarkColor=this.text,this.taskTextOutsideColor=this.taskTextDarkColor,this.activeTaskBorderColor=this.taskBorderColor,this.activeTaskBkgColor=this.mainBkg,this.gridColor=mt(this.border1,30),this.doneTaskBkgColor=this.done,this.doneTaskBorderColor=this.lineColor,this.critBkgColor=this.critical,this.critBorderColor=yt(this.critBkgColor,10),this.todayLineColor=this.critBkgColor,this.transitionColor=this.transitionColor||"#000",this.transitionLabelColor=this.transitionLabelColor||this.textColor,this.stateLabelColor=this.stateLabelColor||this.stateBkg||this.primaryTextColor,this.stateBkg=this.stateBkg||this.mainBkg,this.labelBackgroundColor=this.labelBackgroundColor||this.stateBkg,this.compositeBackground=this.compositeBackground||this.background||this.tertiaryColor,this.altBackground=this.altBackground||"#f4f4f4",this.compositeTitleBackground=this.compositeTitleBackground||this.mainBkg,this.stateBorder=this.stateBorder||"#000",this.innerEndBackground=this.primaryBorderColor,this.specialStateColor="#222",this.errorBkgColor=this.errorBkgColor||this.tertiaryColor,this.errorTextColor=this.errorTextColor||this.tertiaryTextColor,this.classText=this.primaryTextColor,this.fillType0=this.primaryColor,this.fillType1=this.secondaryColor,this.fillType2=ft(this.primaryColor,{h:64}),this.fillType3=ft(this.secondaryColor,{h:64}),this.fillType4=ft(this.primaryColor,{h:-64}),this.fillType5=ft(this.secondaryColor,{h:-64}),this.fillType6=ft(this.primaryColor,{h:128}),this.fillType7=ft(this.secondaryColor,{h:128}),this.pie1=this.pie1||"#F4F4F4",this.pie2=this.pie2||"#555",this.pie3=this.pie3||"#BBB",this.pie4=this.pie4||"#777",this.pie5=this.pie5||"#999",this.pie6=this.pie6||"#DDD",this.pie7=this.pie7||"#FFF",this.pie8=this.pie8||"#DDD",this.pie9=this.pie9||"#BBB",this.pie10=this.pie10||"#999",this.pie11=this.pie11||"#777",this.pie12=this.pie12||"#555",this.pieTitleTextSize=this.pieTitleTextSize||"25px",this.pieTitleTextColor=this.pieTitleTextColor||this.taskTextDarkColor,this.pieSectionTextSize=this.pieSectionTextSize||"17px",this.pieSectionTextColor=this.pieSectionTextColor||this.textColor,this.pieLegendTextSize=this.pieLegendTextSize||"17px",this.pieLegendTextColor=this.pieLegendTextColor||this.taskTextDarkColor,this.pieStrokeColor=this.pieStrokeColor||"black",this.pieStrokeWidth=this.pieStrokeWidth||"2px",this.pieOpacity=this.pieOpacity||"0.7",this.requirementBackground=this.requirementBackground||this.primaryColor,this.requirementBorderColor=this.requirementBorderColor||this.primaryBorderColor,this.requirementBorderSize=this.requirementBorderSize||this.primaryBorderColor,this.requirementTextColor=this.requirementTextColor||this.primaryTextColor,this.relationColor=this.relationColor||this.lineColor,this.relationLabelBackground=this.relationLabelBackground||this.edgeLabelBackground,this.relationLabelColor=this.relationLabelColor||this.actorTextColor,this.git0=yt(this.pie1,25)||this.primaryColor,this.git1=this.pie2||this.secondaryColor,this.git2=this.pie3||this.tertiaryColor,this.git3=this.pie4||ft(this.primaryColor,{h:-30}),this.git4=this.pie5||ft(this.primaryColor,{h:-60}),this.git5=this.pie6||ft(this.primaryColor,{h:-90}),this.git6=this.pie7||ft(this.primaryColor,{h:60}),this.git7=this.pie8||ft(this.primaryColor,{h:120}),this.gitInv0=this.gitInv0||pt(this.git0),this.gitInv1=this.gitInv1||pt(this.git1),this.gitInv2=this.gitInv2||pt(this.git2),this.gitInv3=this.gitInv3||pt(this.git3),this.gitInv4=this.gitInv4||pt(this.git4),this.gitInv5=this.gitInv5||pt(this.git5),this.gitInv6=this.gitInv6||pt(this.git6),this.gitInv7=this.gitInv7||pt(this.git7),this.branchLabelColor=this.branchLabelColor||this.labelTextColor,this.gitBranchLabel0=this.branchLabelColor,this.gitBranchLabel1="white",this.gitBranchLabel2=this.branchLabelColor,this.gitBranchLabel3="white",this.gitBranchLabel4=this.branchLabelColor,this.gitBranchLabel5=this.branchLabelColor,this.gitBranchLabel6=this.branchLabelColor,this.gitBranchLabel7=this.branchLabelColor,this.tagLabelColor=this.tagLabelColor||this.primaryTextColor,this.tagLabelBackground=this.tagLabelBackground||this.primaryColor,this.tagLabelBorder=this.tagBorder||this.primaryBorderColor,this.tagLabelFontSize=this.tagLabelFontSize||"10px",this.commitLabelColor=this.commitLabelColor||this.secondaryTextColor,this.commitLabelBackground=this.commitLabelBackground||this.secondaryColor,this.commitLabelFontSize=this.commitLabelFontSize||"10px";}},{key:"calculate",value:function(t){var e=this;if("object"===Ot(t)){var n=Object.keys(t);n.forEach((function(n){e[n]=t[n];})),this.updateColors(),n.forEach((function(n){e[n]=t[n];}));}else this.updateColors();}}],n&&Dt(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();const Lt={base:{getThemeVariables:function(t){var e=new xt;return e.calculate(t),e}},dark:{getThemeVariables:function(t){var e=new Tt;return e.calculate(t),e}},default:{getThemeVariables:function(t){var e=new St;return e.calculate(t),e}},forest:{getThemeVariables:function(t){var e=new Nt;return e.calculate(t),e}},neutral:{getThemeVariables:function(t){var e=new Bt;return e.calculate(t),e}}};function It(t){return function(t){if(Array.isArray(t))return Ft(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ft(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return "Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ft(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ft(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Rt(t){return Rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Rt(t)}var Pt={theme:"default",themeVariables:Lt.default.getThemeVariables(),themeCSS:void 0,maxTextSize:5e4,darkMode:!1,fontFamily:'"trebuchet ms", verdana, arial, sans-serif;',logLevel:5,securityLevel:"strict",startOnLoad:!0,arrowMarkerAbsolute:!1,secure:["secure","securityLevel","startOnLoad","maxTextSize"],deterministicIds:!1,deterministicIDSeed:void 0,flowchart:{diagramPadding:8,htmlLabels:!0,nodeSpacing:50,rankSpacing:50,curve:"basis",padding:15,useMaxWidth:!0,defaultRenderer:"dagre-d3"},sequence:{hideUnusedParticipants:!1,activationWidth:10,diagramMarginX:50,diagramMarginY:10,actorMargin:50,width:150,height:65,boxMargin:10,boxTextMargin:5,noteMargin:10,messageMargin:35,messageAlign:"center",mirrorActors:!0,forceMenus:!1,bottomMarginAdj:1,useMaxWidth:!0,rightAngles:!1,showSequenceNumbers:!1,actorFontSize:14,actorFontFamily:'"Open Sans", sans-serif',actorFontWeight:400,noteFontSize:14,noteFontFamily:'"trebuchet ms", verdana, arial, sans-serif',noteFontWeight:400,noteAlign:"center",messageFontSize:16,messageFontFamily:'"trebuchet ms", verdana, arial, sans-serif',messageFontWeight:400,wrap:!1,wrapPadding:10,labelBoxWidth:50,labelBoxHeight:20,messageFont:function(){return {fontFamily:this.messageFontFamily,fontSize:this.messageFontSize,fontWeight:this.messageFontWeight}},noteFont:function(){return {fontFamily:this.noteFontFamily,fontSize:this.noteFontSize,fontWeight:this.noteFontWeight}},actorFont:function(){return {fontFamily:this.actorFontFamily,fontSize:this.actorFontSize,fontWeight:this.actorFontWeight}}},gantt:{titleTopMargin:25,barHeight:20,barGap:4,topPadding:50,rightPadding:75,leftPadding:75,gridLineStartPadding:35,fontSize:11,sectionFontSize:11,numberSectionStyles:4,axisFormat:"%Y-%m-%d",useMaxWidth:!0,topAxis:!1,useWidth:void 0},journey:{diagramMarginX:50,diagramMarginY:10,leftMargin:150,width:150,height:50,boxMargin:10,boxTextMargin:5,noteMargin:10,messageMargin:35,messageAlign:"center",bottomMarginAdj:1,useMaxWidth:!0,rightAngles:!1,taskFontSize:14,taskFontFamily:'"Open Sans", sans-serif',taskMargin:50,activationWidth:10,textPlacement:"fo",actorColours:["#8FBC8F","#7CFC00","#00FFFF","#20B2AA","#B0E0E6","#FFFFE0"],sectionFills:["#191970","#8B008B","#4B0082","#2F4F4F","#800000","#8B4513","#00008B"],sectionColours:["#fff"]},class:{arrowMarkerAbsolute:!1,dividerMargin:10,padding:5,textHeight:10,useMaxWidth:!0,defaultRenderer:"dagre-wrapper"},state:{dividerMargin:10,sizeUnit:5,padding:8,textHeight:10,titleShift:-15,noteMargin:10,forkWidth:70,forkHeight:7,miniPadding:2,fontSizeFactor:5.02,fontSize:24,labelHeight:16,edgeLengthFactor:"20",compositTitleSize:35,radius:5,useMaxWidth:!0,defaultRenderer:"dagre-wrapper"},er:{diagramPadding:20,layoutDirection:"TB",minEntityWidth:100,minEntityHeight:75,entityPadding:15,stroke:"gray",fill:"honeydew",fontSize:12,useMaxWidth:!0},pie:{useWidth:void 0,useMaxWidth:!0},requirement:{useWidth:void 0,useMaxWidth:!0,rect_fill:"#f9f9f9",text_color:"#333",rect_border_size:"0.5px",rect_border_color:"#bbb",rect_min_width:200,rect_min_height:200,fontSize:14,rect_padding:10,line_height:20},gitGraph:{diagramPadding:8,nodeLabel:{width:75,height:100,x:-25,y:0},mainBranchName:"main",mainBranchOrder:0,showCommitLabel:!0,showBranches:!0,rotateCommitLabel:!0},c4:{useWidth:void 0,diagramMarginX:50,diagramMarginY:10,c4ShapeMargin:50,c4ShapePadding:20,width:216,height:60,boxMargin:10,useMaxWidth:!0,c4ShapeInRow:4,nextLinePaddingX:0,c4BoundaryInRow:2,personFontSize:14,personFontFamily:'"Open Sans", sans-serif',personFontWeight:"normal",external_personFontSize:14,external_personFontFamily:'"Open Sans", sans-serif',external_personFontWeight:"normal",systemFontSize:14,systemFontFamily:'"Open Sans", sans-serif',systemFontWeight:"normal",external_systemFontSize:14,external_systemFontFamily:'"Open Sans", sans-serif',external_systemFontWeight:"normal",system_dbFontSize:14,system_dbFontFamily:'"Open Sans", sans-serif',system_dbFontWeight:"normal",external_system_dbFontSize:14,external_system_dbFontFamily:'"Open Sans", sans-serif',external_system_dbFontWeight:"normal",system_queueFontSize:14,system_queueFontFamily:'"Open Sans", sans-serif',system_queueFontWeight:"normal",external_system_queueFontSize:14,external_system_queueFontFamily:'"Open Sans", sans-serif',external_system_queueFontWeight:"normal",boundaryFontSize:14,boundaryFontFamily:'"Open Sans", sans-serif',boundaryFontWeight:"normal",messageFontSize:12,messageFontFamily:'"Open Sans", sans-serif',messageFontWeight:"normal",containerFontSize:14,containerFontFamily:'"Open Sans", sans-serif',containerFontWeight:"normal",external_containerFontSize:14,external_containerFontFamily:'"Open Sans", sans-serif',external_containerFontWeight:"normal",container_dbFontSize:14,container_dbFontFamily:'"Open Sans", sans-serif',container_dbFontWeight:"normal",external_container_dbFontSize:14,external_container_dbFontFamily:'"Open Sans", sans-serif',external_container_dbFontWeight:"normal",container_queueFontSize:14,container_queueFontFamily:'"Open Sans", sans-serif',container_queueFontWeight:"normal",external_container_queueFontSize:14,external_container_queueFontFamily:'"Open Sans", sans-serif',external_container_queueFontWeight:"normal",componentFontSize:14,componentFontFamily:'"Open Sans", sans-serif',componentFontWeight:"normal",external_componentFontSize:14,external_componentFontFamily:'"Open Sans", sans-serif',external_componentFontWeight:"normal",component_dbFontSize:14,component_dbFontFamily:'"Open Sans", sans-serif',component_dbFontWeight:"normal",external_component_dbFontSize:14,external_component_dbFontFamily:'"Open Sans", sans-serif',external_component_dbFontWeight:"normal",component_queueFontSize:14,component_queueFontFamily:'"Open Sans", sans-serif',component_queueFontWeight:"normal",external_component_queueFontSize:14,external_component_queueFontFamily:'"Open Sans", sans-serif',external_component_queueFontWeight:"normal",wrap:!0,wrapPadding:10,personFont:function(){return {fontFamily:this.personFontFamily,fontSize:this.personFontSize,fontWeight:this.personFontWeight}},external_personFont:function(){return {fontFamily:this.external_personFontFamily,fontSize:this.external_personFontSize,fontWeight:this.external_personFontWeight}},systemFont:function(){return {fontFamily:this.systemFontFamily,fontSize:this.systemFontSize,fontWeight:this.systemFontWeight}},external_systemFont:function(){return {fontFamily:this.external_systemFontFamily,fontSize:this.external_systemFontSize,fontWeight:this.external_systemFontWeight}},system_dbFont:function(){return {fontFamily:this.system_dbFontFamily,fontSize:this.system_dbFontSize,fontWeight:this.system_dbFontWeight}},external_system_dbFont:function(){return {fontFamily:this.external_system_dbFontFamily,fontSize:this.external_system_dbFontSize,fontWeight:this.external_system_dbFontWeight}},system_queueFont:function(){return {fontFamily:this.system_queueFontFamily,fontSize:this.system_queueFontSize,fontWeight:this.system_queueFontWeight}},external_system_queueFont:function(){return {fontFamily:this.external_system_queueFontFamily,fontSize:this.external_system_queueFontSize,fontWeight:this.external_system_queueFontWeight}},containerFont:function(){return {fontFamily:this.containerFontFamily,fontSize:this.containerFontSize,fontWeight:this.containerFontWeight}},external_containerFont:function(){return {fontFamily:this.external_containerFontFamily,fontSize:this.external_containerFontSize,fontWeight:this.external_containerFontWeight}},container_dbFont:function(){return {fontFamily:this.container_dbFontFamily,fontSize:this.container_dbFontSize,fontWeight:this.container_dbFontWeight}},external_container_dbFont:function(){return {fontFamily:this.external_container_dbFontFamily,fontSize:this.external_container_dbFontSize,fontWeight:this.external_container_dbFontWeight}},container_queueFont:function(){return {fontFamily:this.container_queueFontFamily,fontSize:this.container_queueFontSize,fontWeight:this.container_queueFontWeight}},external_container_queueFont:function(){return {fontFamily:this.external_container_queueFontFamily,fontSize:this.external_container_queueFontSize,fontWeight:this.external_container_queueFontWeight}},componentFont:function(){return {fontFamily:this.componentFontFamily,fontSize:this.componentFontSize,fontWeight:this.componentFontWeight}},external_componentFont:function(){return {fontFamily:this.external_componentFontFamily,fontSize:this.external_componentFontSize,fontWeight:this.external_componentFontWeight}},component_dbFont:function(){return {fontFamily:this.component_dbFontFamily,fontSize:this.component_dbFontSize,fontWeight:this.component_dbFontWeight}},external_component_dbFont:function(){return {fontFamily:this.external_component_dbFontFamily,fontSize:this.external_component_dbFontSize,fontWeight:this.external_component_dbFontWeight}},component_queueFont:function(){return {fontFamily:this.component_queueFontFamily,fontSize:this.component_queueFontSize,fontWeight:this.component_queueFontWeight}},external_component_queueFont:function(){return {fontFamily:this.external_component_queueFontFamily,fontSize:this.external_component_queueFontSize,fontWeight:this.external_component_queueFontWeight}},boundaryFont:function(){return {fontFamily:this.boundaryFontFamily,fontSize:this.boundaryFontSize,fontWeight:this.boundaryFontWeight}},messageFont:function(){return {fontFamily:this.messageFontFamily,fontSize:this.messageFontSize,fontWeight:this.messageFontWeight}},person_bg_color:"#08427B",person_border_color:"#073B6F",external_person_bg_color:"#686868",external_person_border_color:"#8A8A8A",system_bg_color:"#1168BD",system_border_color:"#3C7FC0",system_db_bg_color:"#1168BD",system_db_border_color:"#3C7FC0",system_queue_bg_color:"#1168BD",system_queue_border_color:"#3C7FC0",external_system_bg_color:"#999999",external_system_border_color:"#8A8A8A",external_system_db_bg_color:"#999999",external_system_db_border_color:"#8A8A8A",external_system_queue_bg_color:"#999999",external_system_queue_border_color:"#8A8A8A",container_bg_color:"#438DD5",container_border_color:"#3C7FC0",container_db_bg_color:"#438DD5",container_db_border_color:"#3C7FC0",container_queue_bg_color:"#438DD5",container_queue_border_color:"#3C7FC0",external_container_bg_color:"#B3B3B3",external_container_border_color:"#A6A6A6",external_container_db_bg_color:"#B3B3B3",external_container_db_border_color:"#A6A6A6",external_container_queue_bg_color:"#B3B3B3",external_container_queue_border_color:"#A6A6A6",component_bg_color:"#85BBF0",component_border_color:"#78A8D8",component_db_bg_color:"#85BBF0",component_db_border_color:"#78A8D8",component_queue_bg_color:"#85BBF0",component_queue_border_color:"#78A8D8",external_component_bg_color:"#CCCCCC",external_component_border_color:"#BFBFBF",external_component_db_bg_color:"#CCCCCC",external_component_db_border_color:"#BFBFBF",external_component_queue_bg_color:"#CCCCCC",external_component_queue_border_color:"#BFBFBF"}};Pt.class.arrowMarkerAbsolute=Pt.arrowMarkerAbsolute,Pt.gitGraph.arrowMarkerAbsolute=Pt.arrowMarkerAbsolute;var jt=function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Object.keys(e).reduce((function(r,i){return Array.isArray(e[i])?r:"object"===Rt(e[i])&&null!==e[i]?[].concat(It(r),[n+i],It(t(e[i],""))):[].concat(It(r),[n+i])}),[])}(Pt,"");const zt=Pt;function Yt(t){return Yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yt(t)}var Ut,$t=Object.freeze(zt),Wt=Q({},$t),qt=[],Ht=Q({},$t),Vt=function(t,e){for(var n=Q({},t),r={},i=0;i<e.length;i++){var a=e[i];Zt(a),r=Q(r,a);}if(n=Q(n,r),r.theme&&Lt[r.theme]){var o=Q({},Ut),s=Q(o.themeVariables||{},r.themeVariables);n.themeVariables=Lt[n.theme].getThemeVariables(s);}return Ht=n,n},Gt=function(){return Q({},Wt)},Xt=function(){return Q({},Ht)},Zt=function t(e){Object.keys(Wt.secure).forEach((function(t){void 0!==e[Wt.secure[t]]&&(o.debug("Denied attempt to modify a secure key ".concat(Wt.secure[t]),e[Wt.secure[t]]),delete e[Wt.secure[t]]);})),Object.keys(e).forEach((function(t){0===t.indexOf("__")&&delete e[t];})),Object.keys(e).forEach((function(n){"string"==typeof e[n]&&(e[n].indexOf("<")>-1||e[n].indexOf(">")>-1||e[n].indexOf("url(data:")>-1)&&delete e[n],"object"===Yt(e[n])&&t(e[n]);}));},Qt=function(t){t.fontFamily&&(t.themeVariables&&t.themeVariables.fontFamily||(t.themeVariables={fontFamily:t.fontFamily})),qt.push(t),Vt(Wt,qt);},Kt=function(){Vt(Wt,qt=[]);},Jt=n(7856),te=n.n(Jt),ee=function(t){var e=t.replace(/\\u[\dA-F]{4}/gi,(function(t){return String.fromCharCode(parseInt(t.replace(/\\u/g,""),16))}));return e=(e=(e=e.replace(/\\x([0-9a-f]{2})/gi,(function(t,e){return String.fromCharCode(parseInt(e,16))}))).replace(/\\[\d\d\d]{3}/gi,(function(t){return String.fromCharCode(parseInt(t.replace(/\\/g,""),8))}))).replace(/\\[\d\d\d]{2}/gi,(function(t){return String.fromCharCode(parseInt(t.replace(/\\/g,""),8))}))},ne=function(t){for(var e="",n=0;n>=0;){if(!((n=t.indexOf("<script"))>=0)){e+=t,n=-1;break}e+=t.substr(0,n),(n=(t=t.substr(n+1)).indexOf("<\/script>"))>=0&&(n+=9,t=t.substr(n));}var r=ee(e);return (r=(r=(r=(r=r.replace(/script>/gi,"#")).replace(/javascript:/gi,"#")).replace(/javascript&colon/gi,"#")).replace(/onerror=/gi,"onerror:")).replace(/<iframe/gi,"")},re=function(t,e){var n=t,r=!0;if(!e.flowchart||!1!==e.flowchart.htmlLabels&&"false"!==e.flowchart.htmlLabels||(r=!1),r){var i=e.securityLevel;"antiscript"===i||"strict"===i?n=ne(n):"loose"!==i&&(n=(n=(n=se(n)).replace(/</g,"&lt;").replace(/>/g,"&gt;")).replace(/=/g,"&equals;"),n=oe(n));}return n},ie=function(t,e){return t?e.dompurifyConfig?te().sanitize(re(t,e),e.dompurifyConfig):te().sanitize(re(t,e)):t},ae=/<br\s*\/?>/gi,oe=function(t){return t.replace(/#br#/g,"<br/>")},se=function(t){return t.replace(ae,"#br#")},ce=function(t){return "false"!==t&&!1!==t},le=function t(e){var n=e;return -1!=e.indexOf("~")?t(n=(n=n.replace("~","<")).replace("~",">")):n};const ue={getRows:function(t){if(!t)return 1;var e=se(t);return (e=e.replace(/\\n/g,"#br#")).split("#br#")},sanitizeText:ie,sanitizeTextOrArray:function(t,e){return "string"==typeof t?ie(t,e):t.flat().map((function(t){return ie(t,e)}))},hasBreaks:function(t){return ae.test(t)},splitBreaks:function(t){return t.split(ae)},lineBreakRegex:ae,removeScript:ne,getUrl:function(t){var e="";return t&&(e=(e=(e=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search).replace(/\(/g,"\\(")).replace(/\)/g,"\\)")),e},evaluate:ce,removeEscapes:ee};var he="",fe="",de="",pe=function(t){return ie(t,Xt())},ge=function(){he="",de="",fe="";},ye=function(t){he=pe(t).replace(/^\s+/g,"");},me=function(){return he||fe},be=function(t){de=pe(t).replace(/\n\s+/g,"\n");},ve=function(){return de},_e=function(t){fe=pe(t);},xe=function(){return fe};function ke(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,a=[],o=!0,s=!1;try{for(n=n.call(t);!(o=(r=n.next()).done)&&(a.push(r.value),!e||a.length!==e);o=!0);}catch(t){s=!0,i=t;}finally{try{o||null==n.return||n.return();}finally{if(s)throw i}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return we(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return "Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?we(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function we(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Te(t){return Te="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Te(t)}var Ee,Ce=[],Se=[""],Ae="global",Me="",Ne=[{alias:"global",label:{text:"global"},type:{text:"global"},tags:null,link:null,parentBoundary:""}],Oe=[],De="",Be=!1,Le=4,Ie=2,Fe=function(t){return null==t?Ce:Ce.filter((function(e){return e.parentBoundary===t}))},Re=function(){return Be};const Pe={addPersonOrSystem:function(t,e,n,r,i,a,o){if(null!==e&&null!==n){var s={},c=Ce.find((function(t){return t.alias===e}));if(c&&e===c.alias?s=c:(s.alias=e,Ce.push(s)),s.label=null==n?{text:""}:{text:n},null==r)s.descr={text:""};else if("object"===Te(r)){var l=ke(Object.entries(r)[0],2),u=l[0],h=l[1];s[u]={text:h};}else s.descr={text:r};if("object"===Te(i)){var f=ke(Object.entries(i)[0],2),d=f[0],p=f[1];s[d]=p;}else s.sprite=i;if("object"===Te(a)){var g=ke(Object.entries(a)[0],2),y=g[0],m=g[1];s[y]=m;}else s.tags=a;if("object"===Te(o)){var b=ke(Object.entries(o)[0],2),v=b[0],_=b[1];s[v]=_;}else s.link=o;s.typeC4Shape={text:t},s.parentBoundary=Ae,s.wrap=Re();}},addPersonOrSystemBoundary:function(t,e,n,r,i){if(null!==t&&null!==e){var a={},o=Ne.find((function(e){return e.alias===t}));if(o&&t===o.alias?a=o:(a.alias=t,Ne.push(a)),a.label=null==e?{text:""}:{text:e},null==n)a.type={text:"system"};else if("object"===Te(n)){var s=ke(Object.entries(n)[0],2),c=s[0],l=s[1];a[c]={text:l};}else a.type={text:n};if("object"===Te(r)){var u=ke(Object.entries(r)[0],2),h=u[0],f=u[1];a[h]=f;}else a.tags=r;if("object"===Te(i)){var d=ke(Object.entries(i)[0],2),p=d[0],g=d[1];a[p]=g;}else a.link=i;a.parentBoundary=Ae,a.wrap=Re(),Me=Ae,Ae=t,Se.push(Me);}},addContainer:function(t,e,n,r,i,a,o,s){if(null!==e&&null!==n){var c={},l=Ce.find((function(t){return t.alias===e}));if(l&&e===l.alias?c=l:(c.alias=e,Ce.push(c)),c.label=null==n?{text:""}:{text:n},null==r)c.techn={text:""};else if("object"===Te(r)){var u=ke(Object.entries(r)[0],2),h=u[0],f=u[1];c[h]={text:f};}else c.techn={text:r};if(null==i)c.descr={text:""};else if("object"===Te(i)){var d=ke(Object.entries(i)[0],2),p=d[0],g=d[1];c[p]={text:g};}else c.descr={text:i};if("object"===Te(a)){var y=ke(Object.entries(a)[0],2),m=y[0],b=y[1];c[m]=b;}else c.sprite=a;if("object"===Te(o)){var v=ke(Object.entries(o)[0],2),_=v[0],x=v[1];c[_]=x;}else c.tags=o;if("object"===Te(s)){var k=ke(Object.entries(s)[0],2),w=k[0],T=k[1];c[w]=T;}else c.link=s;c.wrap=Re(),c.typeC4Shape={text:t},c.parentBoundary=Ae;}},addContainerBoundary:function(t,e,n,r,i){if(null!==t&&null!==e){var a={},o=Ne.find((function(e){return e.alias===t}));if(o&&t===o.alias?a=o:(a.alias=t,Ne.push(a)),a.label=null==e?{text:""}:{text:e},null==n)a.type={text:"container"};else if("object"===Te(n)){var s=ke(Object.entries(n)[0],2),c=s[0],l=s[1];a[c]={text:l};}else a.type={text:n};if("object"===Te(r)){var u=ke(Object.entries(r)[0],2),h=u[0],f=u[1];a[h]=f;}else a.tags=r;if("object"===Te(i)){var d=ke(Object.entries(i)[0],2),p=d[0],g=d[1];a[p]=g;}else a.link=i;a.parentBoundary=Ae,a.wrap=Re(),Me=Ae,Ae=t,Se.push(Me);}},addComponent:function(t,e,n,r,i,a,o,s){if(null!==e&&null!==n){var c={},l=Ce.find((function(t){return t.alias===e}));if(l&&e===l.alias?c=l:(c.alias=e,Ce.push(c)),c.label=null==n?{text:""}:{text:n},null==r)c.techn={text:""};else if("object"===Te(r)){var u=ke(Object.entries(r)[0],2),h=u[0],f=u[1];c[h]={text:f};}else c.techn={text:r};if(null==i)c.descr={text:""};else if("object"===Te(i)){var d=ke(Object.entries(i)[0],2),p=d[0],g=d[1];c[p]={text:g};}else c.descr={text:i};if("object"===Te(a)){var y=ke(Object.entries(a)[0],2),m=y[0],b=y[1];c[m]=b;}else c.sprite=a;if("object"===Te(o)){var v=ke(Object.entries(o)[0],2),_=v[0],x=v[1];c[_]=x;}else c.tags=o;if("object"===Te(s)){var k=ke(Object.entries(s)[0],2),w=k[0],T=k[1];c[w]=T;}else c.link=s;c.wrap=Re(),c.typeC4Shape={text:t},c.parentBoundary=Ae;}},addDeploymentNode:function(t,e,n,r,i,a,o,s){if(null!==e&&null!==n){var c={},l=Ne.find((function(t){return t.alias===e}));if(l&&e===l.alias?c=l:(c.alias=e,Ne.push(c)),c.label=null==n?{text:""}:{text:n},null==r)c.type={text:"node"};else if("object"===Te(r)){var u=ke(Object.entries(r)[0],2),h=u[0],f=u[1];c[h]={text:f};}else c.type={text:r};if(null==i)c.descr={text:""};else if("object"===Te(i)){var d=ke(Object.entries(i)[0],2),p=d[0],g=d[1];c[p]={text:g};}else c.descr={text:i};if("object"===Te(o)){var y=ke(Object.entries(o)[0],2),m=y[0],b=y[1];c[m]=b;}else c.tags=o;if("object"===Te(s)){var v=ke(Object.entries(s)[0],2),_=v[0],x=v[1];c[_]=x;}else c.link=s;c.nodeType=t,c.parentBoundary=Ae,c.wrap=Re(),Me=Ae,Ae=e,Se.push(Me);}},popBoundaryParseStack:function(){Ae=Me,Se.pop(),Me=Se.pop(),Se.push(Me);},addRel:function(t,e,n,r,i,a,o,s,c){if(null!=t&&null!=e&&null!=n&&null!=r){var l={},u=Oe.find((function(t){return t.from===e&&t.to===n}));if(u?l=u:Oe.push(l),l.type=t,l.from=e,l.to=n,l.label={text:r},null==i)l.techn={text:""};else if("object"===Te(i)){var h=ke(Object.entries(i)[0],2),f=h[0],d=h[1];l[f]={text:d};}else l.techn={text:i};if(null==a)l.descr={text:""};else if("object"===Te(a)){var p=ke(Object.entries(a)[0],2),g=p[0],y=p[1];l[g]={text:y};}else l.descr={text:a};if("object"===Te(o)){var m=ke(Object.entries(o)[0],2),b=m[0],v=m[1];l[b]=v;}else l.sprite=o;if("object"===Te(s)){var _=ke(Object.entries(s)[0],2),x=_[0],k=_[1];l[x]=k;}else l.tags=s;if("object"===Te(c)){var w=ke(Object.entries(c)[0],2),T=w[0],E=w[1];l[T]=E;}else l.link=c;l.wrap=Re();}},updateElStyle:function(t,e,n,r,i,a,o,s,c,l,u){var h=Ce.find((function(t){return t.alias===e}));if(void 0!==h||void 0!==(h=Ne.find((function(t){return t.alias===e})))){if(null!=n)if("object"===Te(n)){var f=ke(Object.entries(n)[0],2),d=f[0],p=f[1];h[d]=p;}else h.bgColor=n;if(null!=r)if("object"===Te(r)){var g=ke(Object.entries(r)[0],2),y=g[0],m=g[1];h[y]=m;}else h.fontColor=r;if(null!=i)if("object"===Te(i)){var b=ke(Object.entries(i)[0],2),v=b[0],_=b[1];h[v]=_;}else h.borderColor=i;if(null!=a)if("object"===Te(a)){var x=ke(Object.entries(a)[0],2),k=x[0],w=x[1];h[k]=w;}else h.shadowing=a;if(null!=o)if("object"===Te(o)){var T=ke(Object.entries(o)[0],2),E=T[0],C=T[1];h[E]=C;}else h.shape=o;if(null!=s)if("object"===Te(s)){var S=ke(Object.entries(s)[0],2),A=S[0],M=S[1];h[A]=M;}else h.sprite=s;if(null!=c)if("object"===Te(c)){var N=ke(Object.entries(c)[0],2),O=N[0],D=N[1];h[O]=D;}else h.techn=c;if(null!=l)if("object"===Te(l)){var B=ke(Object.entries(l)[0],2),L=B[0],I=B[1];h[L]=I;}else h.legendText=l;if(null!=u)if("object"===Te(u)){var F=ke(Object.entries(u)[0],2),R=F[0],P=F[1];h[R]=P;}else h.legendSprite=u;}},updateRelStyle:function(t,e,n,r,i,a,o){var s=Oe.find((function(t){return t.from===e&&t.to===n}));if(void 0!==s){if(null!=r)if("object"===Te(r)){var c=ke(Object.entries(r)[0],2),l=c[0],u=c[1];s[l]=u;}else s.textColor=r;if(null!=i)if("object"===Te(i)){var h=ke(Object.entries(i)[0],2),f=h[0],d=h[1];s[f]=d;}else s.lineColor=i;if(null!=a)if("object"===Te(a)){var p=ke(Object.entries(a)[0],2),g=p[0],y=p[1];s[g]=parseInt(y);}else s.offsetX=parseInt(a);if(null!=o)if("object"===Te(o)){var m=ke(Object.entries(o)[0],2),b=m[0],v=m[1];s[b]=parseInt(v);}else s.offsetY=parseInt(o);}},updateLayoutConfig:function(t,e,n){var r=Le,i=Ie;if("object"===Te(e)){var a=ke(Object.entries(e)[0],2),o=(a[0],a[1]);r=parseInt(o);}else r=parseInt(e);if("object"===Te(n)){var s=ke(Object.entries(n)[0],2),c=(s[0],s[1]);i=parseInt(c);}else i=parseInt(n);r>=1&&(Le=r),i>=1&&(Ie=i);},autoWrap:Re,setWrap:function(t){Be=t;},getC4ShapeArray:Fe,getC4Shape:function(t){return Ce.find((function(e){return e.alias===t}))},getC4ShapeKeys:function(t){return Object.keys(Fe(t))},getBoundarys:function(t){return null==t?Ne:Ne.filter((function(e){return e.parentBoundary===t}))},getCurrentBoundaryParse:function(){return Ae},getParentBoundaryParse:function(){return Me},getRels:function(){return Oe},getTitle:function(){return De},getC4Type:function(){return Ee},getC4ShapeInRow:function(){return Le},getC4BoundaryInRow:function(){return Ie},setAccTitle:ye,getAccTitle:me,getAccDescription:ve,setAccDescription:be,parseDirective:function(t,e,n){cu.parseDirective(this,t,e,n);},getConfig:function(){return Xt().c4},clear:function(){Ce=[],Ne=[{alias:"global",label:{text:"global"},type:{text:"global"},tags:null,link:null,parentBoundary:""}],Me="",Ae="global",Se=[""],Oe=[],Se=[""],De="",Be=!1,Le=4,Ie=2;},LINETYPE:{SOLID:0,DOTTED:1,NOTE:2,SOLID_CROSS:3,DOTTED_CROSS:4,SOLID_OPEN:5,DOTTED_OPEN:6,LOOP_START:10,LOOP_END:11,ALT_START:12,ALT_ELSE:13,ALT_END:14,OPT_START:15,OPT_END:16,ACTIVE_START:17,ACTIVE_END:18,PAR_START:19,PAR_AND:20,PAR_END:21,RECT_START:22,RECT_END:23,SOLID_POINT:24,DOTTED_POINT:25},ARROWTYPE:{FILLED:0,OPEN:1},PLACEMENT:{LEFTOF:0,RIGHTOF:1,OVER:2},setTitle:function(t){var e=ie(t,Xt());De=e;},setC4Type:function(t){var e=ie(t,Xt());Ee=e;}};var je=n(7967);function ze(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var Ye=function(t,e){var n=t.append("rect");if(n.attr("x",e.x),n.attr("y",e.y),n.attr("fill",e.fill),n.attr("stroke",e.stroke),n.attr("width",e.width),n.attr("height",e.height),n.attr("rx",e.rx),n.attr("ry",e.ry),"undefined"!==e.attrs&&null!==e.attrs)for(var r in e.attrs)n.attr(r,e.attrs[r]);return "undefined"!==e.class&&n.attr("class",e.class),n},Ue=function(){function t(t,e,n,i,a,o,s){r(e.append("text").attr("x",n+a/2).attr("y",i+o/2+5).style("text-anchor","middle").text(t),s);}function e(t,e,n,i,a,o,s,c){for(var l=c.fontSize,u=c.fontFamily,h=c.fontWeight,f=t.split(ue.lineBreakRegex),d=0;d<f.length;d++){var p=d*l-l*(f.length-1)/2,g=e.append("text").attr("x",n+a/2).attr("y",i).style("text-anchor","middle").attr("dominant-baseline","middle").style("font-size",l).style("font-weight",h).style("font-family",u);g.append("tspan").attr("dy",p).text(f[d]).attr("alignment-baseline","mathematical"),r(g,s);}}function n(t,n,i,a,o,s,c,l){var u=n.append("switch"),h=u.append("foreignObject").attr("x",i).attr("y",a).attr("width",o).attr("height",s).append("xhtml:div").style("display","table").style("height","100%").style("width","100%");h.append("div").style("display","table-cell").style("text-align","center").style("vertical-align","middle").text(t),e(t,u,i,a,o,0,c,l),r(h,c);}function r(t,e){for(var n in e)e.hasOwnProperty(n)&&t.attr(n,e[n]);}return function(r){return "fo"===r.textPlacement?n:"old"===r.textPlacement?t:e}}();const $e=function(t,e,n){var r=e.bgColor?e.bgColor:n[e.typeC4Shape.text+"_bg_color"],i=e.borderColor?e.borderColor:n[e.typeC4Shape.text+"_border_color"],a=e.fontColor?e.fontColor:"#FFFFFF",o="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACD0lEQVR4Xu2YoU4EMRCGT+4j8Ai8AhaH4QHgAUjQuFMECUgMIUgwJAgMhgQsAYUiJCiQIBBY+EITsjfTdme6V24v4c8vyGbb+ZjOtN0bNcvjQXmkH83WvYBWto6PLm6v7p7uH1/w2fXD+PBycX1Pv2l3IdDm/vn7x+dXQiAubRzoURa7gRZWd0iGRIiJbOnhnfYBQZNJjNbuyY2eJG8fkDE3bbG4ep6MHUAsgYxmE3nVs6VsBWJSGccsOlFPmLIViMzLOB7pCVO2AtHJMohH7Fh6zqitQK7m0rJvAVYgGcEpe//PLdDz65sM4pF9N7ICcXDKIB5Nv6j7tD0NoSdM2QrU9Gg0ewE1LqBhHR3BBdvj2vapnidjHxD/q6vd7Pvhr31AwcY8eXMTXAKECZZJFXuEq27aLgQK5uLMohCenGGuGewOxSjBvYBqeG6B+Nqiblggdjnc+ZXDy+FNFpFzw76O3UBAROuXh6FoiAcf5g9eTvUgzy0nWg6I8cXHRUpg5bOVBCo+KDpFajOf23GgPme7RSQ+lacIENUgJ6gg1k6HjgOlqnLqip4tEuhv0hNEMXUD0clyXE3p6pZA0S2nnvTlXwLJEZWlb7cTQH1+USgTN4VhAenm/wea1OCAOmqo6fE1WCb9WSKBah+rbUWPWAmE2Rvk0ApiB45eOyNAzU8xcTvj8KvkKEoOaIYeHNA3ZuygAvFMUO0AAAAASUVORK5CYII=";switch(e.typeC4Shape.text){case"person":o="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACD0lEQVR4Xu2YoU4EMRCGT+4j8Ai8AhaH4QHgAUjQuFMECUgMIUgwJAgMhgQsAYUiJCiQIBBY+EITsjfTdme6V24v4c8vyGbb+ZjOtN0bNcvjQXmkH83WvYBWto6PLm6v7p7uH1/w2fXD+PBycX1Pv2l3IdDm/vn7x+dXQiAubRzoURa7gRZWd0iGRIiJbOnhnfYBQZNJjNbuyY2eJG8fkDE3bbG4ep6MHUAsgYxmE3nVs6VsBWJSGccsOlFPmLIViMzLOB7pCVO2AtHJMohH7Fh6zqitQK7m0rJvAVYgGcEpe//PLdDz65sM4pF9N7ICcXDKIB5Nv6j7tD0NoSdM2QrU9Gg0ewE1LqBhHR3BBdvj2vapnidjHxD/q6vd7Pvhr31AwcY8eXMTXAKECZZJFXuEq27aLgQK5uLMohCenGGuGewOxSjBvYBqeG6B+Nqiblggdjnc+ZXDy+FNFpFzw76O3UBAROuXh6FoiAcf5g9eTvUgzy0nWg6I8cXHRUpg5bOVBCo+KDpFajOf23GgPme7RSQ+lacIENUgJ6gg1k6HjgOlqnLqip4tEuhv0hNEMXUD0clyXE3p6pZA0S2nnvTlXwLJEZWlb7cTQH1+USgTN4VhAenm/wea1OCAOmqo6fE1WCb9WSKBah+rbUWPWAmE2Rvk0ApiB45eOyNAzU8xcTvj8KvkKEoOaIYeHNA3ZuygAvFMUO0AAAAASUVORK5CYII=";break;case"external_person":o="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAAB6ElEQVR4Xu2YLY+EMBCG9+dWr0aj0Wg0Go1Go0+j8Xdv2uTCvv1gpt0ebHKPuhDaeW4605Z9mJvx4AdXUyTUdd08z+u6flmWZRnHsWkafk9DptAwDPu+f0eAYtu2PEaGWuj5fCIZrBAC2eLBAnRCsEkkxmeaJp7iDJ2QMDdHsLg8SxKFEJaAo8lAXnmuOFIhTMpxxKATebo4UiFknuNo4OniSIXQyRxEA3YsnjGCVEjVXD7yLUAqxBGUyPv/Y4W2beMgGuS7kVQIBycH0fD+oi5pezQETxdHKmQKGk1eQEYldK+jw5GxPfZ9z7Mk0Qnhf1W1m3w//EUn5BDmSZsbR44QQLBEqrBHqOrmSKaQAxdnLArCrxZcM7A7ZKs4ioRq8LFC+NpC3WCBJsvpVw5edm9iEXFuyNfxXAgSwfrFQ1c0iNda8AdejvUgnktOtJQQxmcfFzGglc5WVCj7oDgFqU18boeFSs52CUh8LE8BIVQDT1ABrB0HtgSEYlX5doJnCwv9TXocKCaKbnwhdDKPq4lf3SwU3HLq4V/+WYhHVMa/3b4IlfyikAduCkcBc7mQ3/z/Qq/cTuikhkzB12Ae/mcJC9U+Vo8Ej1gWAtgbeGgFsAMHr50BIWOLCbezvhpBFUdY6EJuJ/QDW0XoMX60zZ0AAAAASUVORK5CYII=";}var s=t.append("g");s.attr("class","person-man");var c={x:0,y:0,fill:"#EDF2AE",stroke:"#666",width:100,anchor:"start",height:100,rx:0,ry:0};switch(e.typeC4Shape.text){case"person":case"external_person":case"system":case"external_system":case"container":case"external_container":case"component":case"external_component":c.x=e.x,c.y=e.y,c.fill=r,c.width=e.width,c.height=e.height,c.style="stroke:"+i+";stroke-width:0.5;",c.rx=2.5,c.ry=2.5,Ye(s,c);break;case"system_db":case"external_system_db":case"container_db":case"external_container_db":case"component_db":case"external_component_db":s.append("path").attr("fill",r).attr("stroke-width","0.5").attr("stroke",i).attr("d","Mstartx,startyc0,-10 half,-10 half,-10c0,0 half,0 half,10l0,heightc0,10 -half,10 -half,10c0,0 -half,0 -half,-10l0,-height".replaceAll("startx",e.x).replaceAll("starty",e.y).replaceAll("half",e.width/2).replaceAll("height",e.height)),s.append("path").attr("fill","none").attr("stroke-width","0.5").attr("stroke",i).attr("d","Mstartx,startyc0,10 half,10 half,10c0,0 half,0 half,-10".replaceAll("startx",e.x).replaceAll("starty",e.y).replaceAll("half",e.width/2));break;case"system_queue":case"external_system_queue":case"container_queue":case"external_container_queue":case"component_queue":case"external_component_queue":s.append("path").attr("fill",r).attr("stroke-width","0.5").attr("stroke",i).attr("d","Mstartx,startylwidth,0c5,0 5,half 5,halfc0,0 0,half -5,halfl-width,0c-5,0 -5,-half -5,-halfc0,0 0,-half 5,-half".replaceAll("startx",e.x).replaceAll("starty",e.y).replaceAll("width",e.width).replaceAll("half",e.height/2)),s.append("path").attr("fill","none").attr("stroke-width","0.5").attr("stroke",i).attr("d","Mstartx,startyc-5,0 -5,half -5,halfc0,half 5,half 5,half".replaceAll("startx",e.x+e.width).replaceAll("starty",e.y).replaceAll("half",e.height/2));}var l,u,h=(l=n,u=e.typeC4Shape.text,{fontFamily:l[u+"FontFamily"],fontSize:l[u+"FontSize"],fontWeight:l[u+"FontWeight"]});switch(s.append("text").attr("fill",a).attr("font-family",h.fontFamily).attr("font-size",h.fontSize-2).attr("font-style","italic").attr("lengthAdjust","spacing").attr("textLength",e.typeC4Shape.width).attr("x",e.x+e.width/2-e.typeC4Shape.width/2).attr("y",e.y+e.typeC4Shape.Y).text("<<"+e.typeC4Shape.text+">>"),e.typeC4Shape.text){case"person":case"external_person":!function(t,e,n,r,i,a){var o=t.append("image");o.attr("width",e),o.attr("height",n),o.attr("x",r),o.attr("y",i);var s=a.startsWith("data:image/png;base64")?a:(0, je.N)(a);o.attr("xlink:href",s);}(s,48,48,e.x+e.width/2-24,e.y+e.image.Y,o);}var f=n[e.typeC4Shape.text+"Font"]();return f.fontWeight="bold",f.fontSize=f.fontSize+2,f.fontColor=a,Ue(n)(e.label.text,s,e.x,e.y+e.label.Y,e.width,e.height,{fill:a},f),(f=n[e.typeC4Shape.text+"Font"]()).fontColor=a,e.thchn&&""!==e.thchn.text?Ue(n)(e.thchn.text,s,e.x,e.y+e.thchn.Y,e.width,e.height,{fill:a,"font-style":"italic"},f):e.type&&""!==e.type.text&&Ue(n)(e.type.text,s,e.x,e.y+e.type.Y,e.width,e.height,{fill:a,"font-style":"italic"},f),e.descr&&""!==e.descr.text&&((f=n.personFont()).fontColor=a,Ue(n)(e.descr.text,s,e.x,e.y+e.descr.Y,e.width,e.height,{fill:a},f)),e.height},We=function(t,e,n){var r,i=t.append("g"),a=0,o=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return ze(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return "Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ze(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return {s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return {s:function(){n=n.call(t);},n:function(){var t=n.next();return o=t.done,t},e:function(t){s=!0,a=t;},f:function(){try{o||null==n.return||n.return();}finally{if(s)throw a}}}}(e);try{for(o.s();!(r=o.n()).done;){var s=r.value,c=s.textColor?s.textColor:"#444444",l=s.lineColor?s.lineColor:"#444444",u=s.offsetX?parseInt(s.offsetX):0,h=s.offsetY?parseInt(s.offsetY):0;if(0===a){var f=i.append("line");f.attr("x1",s.startPoint.x),f.attr("y1",s.startPoint.y),f.attr("x2",s.endPoint.x),f.attr("y2",s.endPoint.y),f.attr("stroke-width","1"),f.attr("stroke",l),f.style("fill","none"),"rel_b"!==s.type&&f.attr("marker-end","url(#arrowhead)"),"birel"!==s.type&&"rel_b"!==s.type||f.attr("marker-start","url(#arrowend)"),a=-1;}else {var d=i.append("path");d.attr("fill","none").attr("stroke-width","1").attr("stroke",l).attr("d","Mstartx,starty Qcontrolx,controly stopx,stopy ".replaceAll("startx",s.startPoint.x).replaceAll("starty",s.startPoint.y).replaceAll("controlx",s.startPoint.x+(s.endPoint.x-s.startPoint.x)/2-(s.endPoint.x-s.startPoint.x)/4).replaceAll("controly",s.startPoint.y+(s.endPoint.y-s.startPoint.y)/2).replaceAll("stopx",s.endPoint.x).replaceAll("stopy",s.endPoint.y)),"rel_b"!==s.type&&d.attr("marker-end","url(#arrowhead)"),"birel"!==s.type&&"rel_b"!==s.type||d.attr("marker-start","url(#arrowend)");}var p=n.messageFont();Ue(n)(s.label.text,i,Math.min(s.startPoint.x,s.endPoint.x)+Math.abs(s.endPoint.x-s.startPoint.x)/2+u,Math.min(s.startPoint.y,s.endPoint.y)+Math.abs(s.endPoint.y-s.startPoint.y)/2+h,s.label.width,s.label.height,{fill:c},p),s.techn&&""!==s.techn.text&&(p=n.messageFont(),Ue(n)("["+s.techn.text+"]",i,Math.min(s.startPoint.x,s.endPoint.x)+Math.abs(s.endPoint.x-s.startPoint.x)/2+u,Math.min(s.startPoint.y,s.endPoint.y)+Math.abs(s.endPoint.y-s.startPoint.y)/2+n.messageFontSize+5+h,Math.max(s.label.width,s.techn.width),s.techn.height,{fill:c,"font-style":"italic"},p));}}catch(t){o.e(t);}finally{o.f();}};je.N;var qe=n(2536),He=n.n(qe),Ve=/[%]{2}[{]\s*(?:(?:(\w+)\s*:|(\w+))\s*(?:(?:(\w+))|((?:(?![}][%]{2}).|\r?\n)*))?\s*)(?:[}][%]{2})?/gi,Ge=/\s*%%.*\n/gm,Xe={};const Ze=function(t,e){if((t=t.replace(Ve,"").replace(Ge,"\n")).match(/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/))return "c4";if("error"===t)return "error";if(t.match(/^\s*sequenceDiagram/))return "sequence";if(t.match(/^\s*gantt/))return "gantt";if(t.match(/^\s*classDiagram-v2/))return "classDiagram";if(t.match(/^\s*classDiagram/))return e&&e.class&&"dagre-wrapper"===e.class.defaultRenderer?"classDiagram":"class";if(t.match(/^\s*stateDiagram-v2/))return "stateDiagram";if(t.match(/^\s*stateDiagram/))return e&&e.class&&"dagre-wrapper"===e.state.defaultRenderer?"stateDiagram":"state";if(t.match(/^\s*flowchart/))return "flowchart-v2";if(t.match(/^\s*info/))return "info";if(t.match(/^\s*pie/))return "pie";if(t.match(/^\s*erDiagram/))return "er";if(t.match(/^\s*journey/))return "journey";if(t.match(/^\s*requirement/)||t.match(/^\s*requirementDiagram/))return "requirement";if(e&&e.flowchart&&"dagre-wrapper"===e.flowchart.defaultRenderer)return "flowchart-v2";for(var n=Object.keys(Xe),r=0;r<n.length;r++){var i=n[r],a=Xe[i];if(a&&a.detector(t))return i}return "flowchart"};var Qe=void 0;function Ke(t){return Ke="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ke(t)}function Je(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r);}}function tn(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=nn(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return {s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return {s:function(){n=n.call(t);},n:function(){var t=n.next();return o=t.done,t},e:function(t){s=!0,a=t;},f:function(){try{o||null==n.return||n.return();}finally{if(s)throw a}}}}function en(t){return function(t){if(Array.isArray(t))return rn(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||nn(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function nn(t,e){if(t){if("string"==typeof t)return rn(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return "Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?rn(t,e):void 0}}function rn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var an,on={curveBasis:l.curveBasis,curveBasisClosed:l.curveBasisClosed,curveBasisOpen:l.curveBasisOpen,curveLinear:l.curveLinear,curveLinearClosed:l.curveLinearClosed,curveMonotoneX:l.curveMonotoneX,curveMonotoneY:l.curveMonotoneY,curveNatural:l.curveNatural,curveStep:l.curveStep,curveStepAfter:l.curveStepAfter,curveStepBefore:l.curveStepBefore},sn=/[%]{2}[{]\s*(?:(?:(\w+)\s*:|(\w+))\s*(?:(?:(\w+))|((?:(?![}][%]{2}).|\r?\n)*))?\s*)(?:[}][%]{2})?/gi,cn=/\s*(?:(?:(\w+)(?=:):|(\w+))\s*(?:(?:(\w+))|((?:(?![}][%]{2}).|\r?\n)*))?\s*)(?:[}][%]{2})?/gi,ln=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;try{var n=new RegExp("[%]{2}(?![{]".concat(cn.source,")(?=[}][%]{2}).*\n"),"ig");t=t.trim().replace(n,"").replace(/'/gm,'"'),o.debug("Detecting diagram directive".concat(null!==e?" type:"+e:""," based on the text:").concat(t));for(var r,i=[];null!==(r=sn.exec(t));)if(r.index===sn.lastIndex&&sn.lastIndex++,r&&!e||e&&r[1]&&r[1].match(e)||e&&r[2]&&r[2].match(e)){var a=r[1]?r[1]:r[2],s=r[3]?r[3].trim():r[4]?JSON.parse(r[4].trim()):null;i.push({type:a,args:s});}return 0===i.length&&i.push({type:t,args:null}),1===i.length?i[0]:i}catch(n){return o.error("ERROR: ".concat(n.message," - Unable to parse directive\n ").concat(null!==e?" type:"+e:""," based on the text:").concat(t)),{type:null,args:null}}},un=function(t,e){var n={};return function(){for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];var o=e?e.apply(Qe,i):i[0];if(o in n)return n[o];var s=t.apply(void 0,i);return n[o]=s,s}},hn=function(t,e){if(!t)return e;var n="curve".concat(t.charAt(0).toUpperCase()+t.slice(1));return on[n]||e},fn=function(t,e){return t&&e?Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)):0},dn=function(t){for(var e="",n="",r=0;r<t.length;r++)void 0!==t[r]&&(t[r].startsWith("color:")||t[r].startsWith("text-align:")?n=n+t[r]+";":e=e+t[r]+";");return {style:e,labelStyle:n}},pn=0,gn=function(){return pn++,"id-"+Math.random().toString(36).substr(2,12)+"-"+pn},yn=function(t){return function(t){for(var e="",n="0123456789abcdef",r=n.length,i=0;i<t;i++)e+=n.charAt(Math.floor(Math.random()*r));return e}(t.length)},mn=function(t,e){var n=e.text.replace(ue.lineBreakRegex," "),r=t.append("text");r.attr("x",e.x),r.attr("y",e.y),r.style("text-anchor",e.anchor),r.style("font-family",e.fontFamily),r.style("font-size",e.fontSize),r.style("font-weight",e.fontWeight),r.attr("fill",e.fill),void 0!==e.class&&r.attr("class",e.class);var i=r.append("tspan");return i.attr("x",e.x+2*e.textMargin),i.attr("fill",e.fill),i.text(n),r},bn=un((function(t,e,n){if(!t)return t;if(n=Object.assign({fontSize:12,fontWeight:400,fontFamily:"Arial",joinWith:"<br/>"},n),ue.lineBreakRegex.test(t))return t;var r=t.split(" "),i=[],a="";return r.forEach((function(t,o){var s=xn("".concat(t," "),n),c=xn(a,n);if(s>e){var l=vn(t,e,"-",n),u=l.hyphenatedStrings,h=l.remainingWord;i.push.apply(i,[a].concat(en(u))),a=h;}else c+s>=e?(i.push(a),a=t):a=[a,t].filter(Boolean).join(" ");o+1===r.length&&i.push(a);})),i.filter((function(t){return ""!==t})).join(n.joinWith)}),(function(t,e,n){return "".concat(t,"-").concat(e,"-").concat(n.fontSize,"-").concat(n.fontWeight,"-").concat(n.fontFamily,"-").concat(n.joinWith)})),vn=un((function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"-",r=arguments.length>3?arguments[3]:void 0;r=Object.assign({fontSize:12,fontWeight:400,fontFamily:"Arial",margin:0},r);var i=t.split(""),a=[],o="";return i.forEach((function(t,s){var c="".concat(o).concat(t);if(xn(c,r)>=e){var l=s+1,u=i.length===l,h="".concat(c).concat(n);a.push(u?c:h),o="";}else o=c;})),{hyphenatedStrings:a,remainingWord:o}}),(function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"-",r=arguments.length>3?arguments[3]:void 0;return "".concat(t,"-").concat(e,"-").concat(n,"-").concat(r.fontSize,"-").concat(r.fontWeight,"-").concat(r.fontFamily)})),_n=function(t,e){return e=Object.assign({fontSize:12,fontWeight:400,fontFamily:"Arial",margin:15},e),kn(t,e).height},xn=function(t,e){return e=Object.assign({fontSize:12,fontWeight:400,fontFamily:"Arial"},e),kn(t,e).width},kn=un((function(t,e){var n=e=Object.assign({fontSize:12,fontWeight:400,fontFamily:"Arial"},e),r=n.fontSize,i=n.fontFamily,a=n.fontWeight;if(!t)return {width:0,height:0};var o=["sans-serif",i],s=t.split(ue.lineBreakRegex),c=[],u=(0, l.select)("body");if(!u.remove)return {width:0,height:0,lineHeight:0};for(var h=u.append("svg"),f=0,d=o;f<d.length;f++){var p,g=d[f],y=0,m={width:0,height:0,lineHeight:0},b=tn(s);try{for(b.s();!(p=b.n()).done;){var v=p.value,_={x:0,y:0,fill:void 0,anchor:"start",style:"#666",width:100,height:100,textMargin:0,rx:0,ry:0,valign:void 0};_.text=v;var x=mn(h,_).style("font-size",r).style("font-weight",a).style("font-family",g),k=(x._groups||x)[0][0].getBBox();m.width=Math.round(Math.max(m.width,k.width)),y=Math.round(k.height),m.height+=y,m.lineHeight=Math.round(Math.max(m.lineHeight,y));}}catch(t){b.e(t);}finally{b.f();}c.push(m);}return h.remove(),c[isNaN(c[1].height)||isNaN(c[1].width)||isNaN(c[1].lineHeight)||c[0].height>c[1].height&&c[0].width>c[1].width&&c[0].lineHeight>c[1].lineHeight?0:1]}),(function(t,e){return "".concat(t,"-").concat(e.fontSize,"-").concat(e.fontWeight,"-").concat(e.fontFamily)})),wn=function(t,e,n){var r=new Map;return n?(r.set("width","100%"),r.set("style","max-width: ".concat(e,"px;"))):r.set("width",e),r},Tn=function(t,e,n,r){!function(t,e){var n,r=tn(e);try{for(r.s();!(n=r.n()).done;){var i=n.value;t.attr(i[0],i[1]);}}catch(t){r.e(t);}finally{r.f();}}(t,wn(0,1*n,r));},En=function(t,e,n,r){var i=e.node().getBBox(),a=i.width,s=i.height;o.info("SVG bounds: ".concat(a,"x").concat(s),i);var c=t._label.width,l=t._label.height;o.info("Graph bounds: ".concat(c,"x").concat(l),t),c=a+2*n,l=s+2*n,o.info("Calculated bounds: ".concat(c,"x").concat(l)),Tn(e,0,c,r);var u="".concat(i.x-n," ").concat(i.y-n," ").concat(i.width+2*n," ").concat(i.height+2*n);o.info("Graph.label",t._label,"swidth",a,"sheight",s,"width",c,"height",l,"vBox",u),e.attr("viewBox",u);},Cn=function t(e){if(o.debug("directiveSanitizer called with",e),"object"===Ke(e)&&(e.length?e.forEach((function(e){return t(e)})):Object.keys(e).forEach((function(n){o.debug("Checking key",n),0===n.indexOf("__")&&(o.debug("sanitize deleting __ option",n),delete e[n]),n.indexOf("proto")>=0&&(o.debug("sanitize deleting proto option",n),delete e[n]),n.indexOf("constr")>=0&&(o.debug("sanitize deleting constr option",n),delete e[n]),n.indexOf("themeCSS")>=0&&(o.debug("sanitizing themeCss option"),e[n]=Sn(e[n])),n.indexOf("fontFamily")>=0&&(o.debug("sanitizing fontFamily option"),e[n]=Sn(e[n])),n.indexOf("altFontFamily")>=0&&(o.debug("sanitizing altFontFamily option"),e[n]=Sn(e[n])),jt.indexOf(n)<0?(o.debug("sanitize deleting option",n),delete e[n]):"object"===Ke(e[n])&&(o.debug("sanitize deleting object",n),t(e[n]));}))),e.themeVariables)for(var n=Object.keys(e.themeVariables),r=0;r<n.length;r++){var i=n[r],a=e.themeVariables[i];a&&a.match&&!a.match(/^[a-zA-Z0-9#,";()%. ]+$/)&&(e.themeVariables[i]="");}o.debug("After sanitization",e);},Sn=function(t){for(var e=0,n=0,r=0;r<t.length;r++){if(e<n)return "{ /* ERROR: Unbalanced CSS */ }";"{"===t[r]?e++:"}"===t[r]&&n++;}return e!==n?"{ /* ERROR: Unbalanced CSS */ }":t};const An={assignWithDepth:Q,wrapLabel:bn,calculateTextHeight:_n,calculateTextWidth:xn,calculateTextDimensions:kn,calculateSvgSizeAttrs:wn,configureSvgSize:Tn,setupGraphViewbox:En,detectInit:function(t,e){var n=ln(t,/(?:init\b)|(?:initialize\b)/),r={};if(Array.isArray(n)){var i=n.map((function(t){return t.args}));Cn(i),r=Q(r,en(i));}else r=n.args;if(r){var a=Ze(t,e);["config"].forEach((function(t){void 0!==r[t]&&("flowchart-v2"===a&&(a="flowchart"),r[a]=r[t],delete r[t]);}));}return r},detectDirective:ln,isSubstringInArray:function(t,e){for(var n=0;n<e.length;n++)if(e[n].match(t))return n;return -1},interpolateToCurve:hn,calcLabelPosition:function(t){return 1===t.length?t[0]:function(t){var e,n=0;t.forEach((function(t){n+=fn(t,e),e=t;}));var r=n/2,i=void 0;return e=void 0,t.forEach((function(t){if(e&&!i){var n=fn(t,e);if(n<r)r-=n;else {var a=r/n;a<=0&&(i=e),a>=1&&(i={x:t.x,y:t.y}),a>0&&a<1&&(i={x:(1-a)*e.x+a*t.x,y:(1-a)*e.y+a*t.y});}}e=t;})),i}(t)},calcCardinalityPosition:function(t,e,n){var r;o.info("our points",e),e[0]!==n&&(e=e.reverse()),e.forEach((function(t){fn(t,r),r=t;}));var i,a=25;r=void 0,e.forEach((function(t){if(r&&!i){var e=fn(t,r);if(e<a)a-=e;else {var n=a/e;n<=0&&(i=r),n>=1&&(i={x:t.x,y:t.y}),n>0&&n<1&&(i={x:(1-n)*r.x+n*t.x,y:(1-n)*r.y+n*t.y});}}r=t;}));var s=t?10:5,c=Math.atan2(e[0].y-i.y,e[0].x-i.x),l={x:0,y:0};return l.x=Math.sin(c)*s+(e[0].x+i.x)/2,l.y=-Math.cos(c)*s+(e[0].y+i.y)/2,l},calcTerminalLabelPosition:function(t,e,n){var r,i=JSON.parse(JSON.stringify(n));o.info("our points",i),"start_left"!==e&&"start_right"!==e&&(i=i.reverse()),i.forEach((function(t){fn(t,r),r=t;}));var a,s=25+t;r=void 0,i.forEach((function(t){if(r&&!a){var e=fn(t,r);if(e<s)s-=e;else {var n=s/e;n<=0&&(a=r),n>=1&&(a={x:t.x,y:t.y}),n>0&&n<1&&(a={x:(1-n)*r.x+n*t.x,y:(1-n)*r.y+n*t.y});}}r=t;}));var c=10+.5*t,l=Math.atan2(i[0].y-a.y,i[0].x-a.x),u={x:0,y:0};return u.x=Math.sin(l)*c+(i[0].x+a.x)/2,u.y=-Math.cos(l)*c+(i[0].y+a.y)/2,"start_left"===e&&(u.x=Math.sin(l+Math.PI)*c+(i[0].x+a.x)/2,u.y=-Math.cos(l+Math.PI)*c+(i[0].y+a.y)/2),"end_right"===e&&(u.x=Math.sin(l-Math.PI)*c+(i[0].x+a.x)/2-5,u.y=-Math.cos(l-Math.PI)*c+(i[0].y+a.y)/2-5),"end_left"===e&&(u.x=Math.sin(l)*c+(i[0].x+a.x)/2-5,u.y=-Math.cos(l)*c+(i[0].y+a.y)/2-5),u},formatUrl:function(t,e){var n=t.trim();if(n)return "loose"!==e.securityLevel?(0, je.N)(n):n},getStylesFromArray:dn,generateId:gn,random:yn,memoize:un,runFunc:function(t){for(var e,n=t.split("."),r=n.length-1,i=n[r],a=window,o=0;o<r;o++)if(!(a=a[n[o]]))return;for(var s=arguments.length,c=new Array(s>1?s-1:0),l=1;l<s;l++)c[l-1]=arguments[l];(e=a)[i].apply(e,c);},entityDecode:function(t){return an=an||document.createElement("div"),t=escape(t).replace(/%26/g,"&").replace(/%23/g,"#").replace(/%3B/g,";"),an.innerHTML=t,unescape(an.textContent)},initIdGenerator:function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.deterministic=e,this.seed=n,this.count=n?n.length:0;}var e,n;return e=t,(n=[{key:"next",value:function(){return this.deterministic?this.count++:Date.now()}}])&&Je(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}(),directiveSanitizer:Cn,sanitizeCss:Sn};function Mn(t,e,n){if(void 0!==e.insert){var r=t.getAccTitle(),i=t.getAccDescription();e.attr("role","img").attr("aria-labelledby","chart-title-"+n+" chart-desc-"+n),e.insert("desc",":first-child").attr("id","chart-desc-"+n).text(i),e.insert("title",":first-child").attr("id","chart-title-"+n).text(r);}}function Nn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function On(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Dn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r);}}function Bn(t,e,n){return e&&Dn(t.prototype,e),n&&Dn(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}var Ln=0,In=0,Fn=4,Rn=2;qe.parser.yy=Pe;var Pn={},jn=function(){function t(e){On(this,t),this.name="",this.data={},this.data.startx=void 0,this.data.stopx=void 0,this.data.starty=void 0,this.data.stopy=void 0,this.data.widthLimit=void 0,this.nextData={},this.nextData.startx=void 0,this.nextData.stopx=void 0,this.nextData.starty=void 0,this.nextData.stopy=void 0,this.nextData.cnt=0,zn(e.db.getConfig());}return Bn(t,[{key:"setData",value:function(t,e,n,r){this.nextData.startx=this.data.startx=t,this.nextData.stopx=this.data.stopx=e,this.nextData.starty=this.data.starty=n,this.nextData.stopy=this.data.stopy=r;}},{key:"updateVal",value:function(t,e,n,r){void 0===t[e]?t[e]=n:t[e]=r(n,t[e]);}},{key:"insert",value:function(t){this.nextData.cnt=this.nextData.cnt+1;var e=this.nextData.startx===this.nextData.stopx?this.nextData.stopx+t.margin:this.nextData.stopx+2*t.margin,n=e+t.width,r=this.nextData.starty+2*t.margin,i=r+t.height;(e>=this.data.widthLimit||n>=this.data.widthLimit||this.nextData.cnt>Fn)&&(e=this.nextData.startx+t.margin+Pn.nextLinePaddingX,r=this.nextData.stopy+2*t.margin,this.nextData.stopx=n=e+t.width,this.nextData.starty=this.nextData.stopy,this.nextData.stopy=i=r+t.height,this.nextData.cnt=1),t.x=e,t.y=r,this.updateVal(this.data,"startx",e,Math.min),this.updateVal(this.data,"starty",r,Math.min),this.updateVal(this.data,"stopx",n,Math.max),this.updateVal(this.data,"stopy",i,Math.max),this.updateVal(this.nextData,"startx",e,Math.min),this.updateVal(this.nextData,"starty",r,Math.min),this.updateVal(this.nextData,"stopx",n,Math.max),this.updateVal(this.nextData,"stopy",i,Math.max);}},{key:"init",value:function(t){this.name="",this.data={startx:void 0,stopx:void 0,starty:void 0,stopy:void 0,widthLimit:void 0},this.nextData={startx:void 0,stopx:void 0,starty:void 0,stopy:void 0,cnt:0},zn(t.db.getConfig());}},{key:"bumpLastMargin",value:function(t){this.data.stopx+=t,this.data.stopy+=t;}}]),t}(),zn=function(t){Q(Pn,t),t.fontFamily&&(Pn.personFontFamily=Pn.systemFontFamily=Pn.messageFontFamily=t.fontFamily),t.fontSize&&(Pn.personFontSize=Pn.systemFontSize=Pn.messageFontSize=t.fontSize),t.fontWeight&&(Pn.personFontWeight=Pn.systemFontWeight=Pn.messageFontWeight=t.fontWeight);},Yn=function(t,e){return {fontFamily:t[e+"FontFamily"],fontSize:t[e+"FontSize"],fontWeight:t[e+"FontWeight"]}},Un=function(t){return {fontFamily:t.boundaryFontFamily,fontSize:t.boundaryFontSize,fontWeight:t.boundaryFontWeight}};function $n(t,e,n,r,i){if(!e[t].width)if(n)e[t].text=bn(e[t].text,i,r),e[t].textLines=e[t].text.split(ue.lineBreakRegex).length,e[t].width=i,e[t].height=_n(e[t].text,r);else {var a=e[t].text.split(ue.lineBreakRegex);e[t].textLines=a.length;var o=0;e[t].height=0,e[t].width=0;for(var s=0;s<a.length;s++)e[t].width=Math.max(xn(a[s],r),e[t].width),o=_n(a[s],r),e[t].height=e[t].height+o;}}var Wn=function(t,e,n){e.x=n.data.startx,e.y=n.data.starty,e.width=n.data.stopx-n.data.startx,e.height=n.data.stopy-n.data.starty,e.label.y=Pn.c4ShapeMargin-35;var r=e.wrap&&Pn.wrap,i=Un(Pn);i.fontSize=i.fontSize+2,i.fontWeight="bold",$n("label",e,r,i,xn(e.label.text,i)),function(t,e,n){var r=t.append("g"),i=e.bgColor?e.bgColor:"none",a=e.borderColor?e.borderColor:"#444444",o=e.fontColor?e.fontColor:"black",s={"stroke-width":1,"stroke-dasharray":"7.0,7.0"};e.nodeType&&(s={"stroke-width":1});var c={x:e.x,y:e.y,fill:i,stroke:a,width:e.width,height:e.height,rx:2.5,ry:2.5,attrs:s};Ye(r,c);var l=n.boundaryFont();l.fontWeight="bold",l.fontSize=l.fontSize+2,l.fontColor=o,Ue(n)(e.label.text,r,e.x,e.y+e.label.Y,e.width,e.height,{fill:"#444444"},l),e.type&&""!==e.type.text&&((l=n.boundaryFont()).fontColor=o,Ue(n)(e.type.text,r,e.x,e.y+e.type.Y,e.width,e.height,{fill:"#444444"},l)),e.descr&&""!==e.descr.text&&((l=n.boundaryFont()).fontSize=l.fontSize-2,l.fontColor=o,Ue(n)(e.descr.text,r,e.x,e.y+e.descr.Y,e.width,e.height,{fill:"#444444"},l));}(t,e,Pn);},qn=function(t,e,n,r){for(var i=0,a=0;a<r.length;a++){i=0;var o=n[r[a]],s=Yn(Pn,o.typeC4Shape.text);switch(s.fontSize=s.fontSize-2,o.typeC4Shape.width=xn("<<"+o.typeC4Shape.text+">>",s),o.typeC4Shape.height=s.fontSize+2,o.typeC4Shape.Y=Pn.c4ShapePadding,i=o.typeC4Shape.Y+o.typeC4Shape.height-4,o.image={width:0,height:0,Y:0},o.typeC4Shape.text){case"person":case"external_person":o.image.width=48,o.image.height=48,o.image.Y=i,i=o.image.Y+o.image.height;}o.sprite&&(o.image.width=48,o.image.height=48,o.image.Y=i,i=o.image.Y+o.image.height);var c=o.wrap&&Pn.wrap,l=Pn.width-2*Pn.c4ShapePadding,u=Yn(Pn,o.typeC4Shape.text);u.fontSize=u.fontSize+2,u.fontWeight="bold",$n("label",o,c,u,l),o.label.Y=i+8,i=o.label.Y+o.label.height,o.type&&""!==o.type.text?(o.type.text="["+o.type.text+"]",$n("type",o,c,Yn(Pn,o.typeC4Shape.text),l),o.type.Y=i+5,i=o.type.Y+o.type.height):o.techn&&""!==o.techn.text&&(o.techn.text="["+o.techn.text+"]",$n("techn",o,c,Yn(Pn,o.techn.text),l),o.techn.Y=i+5,i=o.techn.Y+o.techn.height);var h=i,f=o.label.width;o.descr&&""!==o.descr.text&&($n("descr",o,c,Yn(Pn,o.typeC4Shape.text),l),o.descr.Y=i+20,i=o.descr.Y+o.descr.height,f=Math.max(o.label.width,o.descr.width),h=i-5*o.descr.textLines),f+=Pn.c4ShapePadding,o.width=Math.max(o.width||Pn.width,f,Pn.width),o.height=Math.max(o.height||Pn.height,h,Pn.height),o.margin=o.margin||Pn.c4ShapeMargin,t.insert(o),$e(e,o,Pn);}t.bumpLastMargin(Pn.c4ShapeMargin);},Hn=Bn((function t(e,n){On(this,t),this.x=e,this.y=n;})),Vn=function(t,e){var n=t.x,r=t.y,i=e.x,a=e.y,o=n+t.width/2,s=r+t.height/2,c=Math.abs(n-i),l=Math.abs(r-a),u=l/c,h=t.height/t.width,f=null;return r==a&&n<i?f=new Hn(n+t.width,s):r==a&&n>i?f=new Hn(n,s):n==i&&r<a?f=new Hn(o,r+t.height):n==i&&r>a&&(f=new Hn(o,r)),n>i&&r<a?f=h>=u?new Hn(n,s+u*t.width/2):new Hn(o-c/l*t.height/2,r+t.height):n<i&&r<a?f=h>=u?new Hn(n+t.width,s+u*t.width/2):new Hn(o+c/l*t.height/2,r+t.height):n<i&&r>a?f=h>=u?new Hn(n+t.width,s-u*t.width/2):new Hn(o+t.height/2*c/l,r):n>i&&r>a&&(f=h>=u?new Hn(n,s-t.width/2*u):new Hn(o-t.height/2*c/l,r)),f},Gn=function(t,e){var n={x:0,y:0};n.x=e.x+e.width/2,n.y=e.y+e.height/2;var r=Vn(t,n);return n.x=t.x+t.width/2,n.y=t.y+t.height/2,{startPoint:r,endPoint:Vn(e,n)}};function Xn(t,e,n,r,i){var a=new jn(i);a.data.widthLimit=n.data.widthLimit/Math.min(Rn,r.length);for(var o=0;o<r.length;o++){var s=r[o],c=0;s.image={width:0,height:0,Y:0},s.sprite&&(s.image.width=48,s.image.height=48,s.image.Y=c,c=s.image.Y+s.image.height);var l=s.wrap&&Pn.wrap,u=Un(Pn);if(u.fontSize=u.fontSize+2,u.fontWeight="bold",$n("label",s,l,u,a.data.widthLimit),s.label.Y=c+8,c=s.label.Y+s.label.height,s.type&&""!==s.type.text&&(s.type.text="["+s.type.text+"]",$n("type",s,l,Un(Pn),a.data.widthLimit),s.type.Y=c+5,c=s.type.Y+s.type.height),s.descr&&""!==s.descr.text){var h=Un(Pn);h.fontSize=h.fontSize-2,$n("descr",s,l,h,a.data.widthLimit),s.descr.Y=c+20,c=s.descr.Y+s.descr.height;}if(0==o||o%Rn==0){var f=n.data.startx+Pn.diagramMarginX,d=n.data.stopy+Pn.diagramMarginY+c;a.setData(f,f,d,d);}else {var p=a.data.stopx!==a.data.startx?a.data.stopx+Pn.diagramMarginX:a.data.startx,g=a.data.starty;a.setData(p,p,g,g);}a.name=s.alias;var y=i.db.getC4ShapeArray(s.alias),m=i.db.getC4ShapeKeys(s.alias);m.length>0&&qn(a,t,y,m),e=s.alias;var b=i.db.getBoundarys(e);b.length>0&&Xn(t,e,a,b,i),"global"!==s.alias&&Wn(t,s,a),n.data.stopy=Math.max(a.data.stopy+Pn.c4ShapeMargin,n.data.stopy),n.data.stopx=Math.max(a.data.stopx+Pn.c4ShapeMargin,n.data.stopx),Ln=Math.max(Ln,n.data.stopx),In=Math.max(In,n.data.stopy);}}const Zn={drawPersonOrSystemArray:qn,drawBoundary:Wn,setConf:zn,draw:function(t,e,n,r){Pn=Xt().c4;var i,a=Xt().securityLevel;"sandbox"===a&&(i=(0, l.select)("#i"+e));var s="sandbox"===a?(0, l.select)(i.nodes()[0].contentDocument.body):(0, l.select)("body"),c=r.db;r.db.setWrap(Pn.wrap),Fn=c.getC4ShapeInRow(),Rn=c.getC4BoundaryInRow(),o.debug("C:".concat(JSON.stringify(Pn,null,2)));var u="sandbox"===a?s.select('[id="'.concat(e,'"]')):(0, l.select)('[id="'.concat(e,'"]'));u.append("defs").append("symbol").attr("id","computer").attr("width","24").attr("height","24").append("path").attr("transform","scale(.5)").attr("d","M2 2v13h20v-13h-20zm18 11h-16v-9h16v9zm-10.228 6l.466-1h3.524l.467 1h-4.457zm14.228 3h-24l2-6h2.104l-1.33 4h18.45l-1.297-4h2.073l2 6zm-5-10h-14v-7h14v7z"),function(t){t.append("defs").append("symbol").attr("id","database").attr("fill-rule","evenodd").attr("clip-rule","evenodd").append("path").attr("transform","scale(.5)").attr("d","M12.258.001l.256.004.255.005.253.008.251.01.249.012.247.015.246.016.242.019.241.02.239.023.236.024.233.027.231.028.229.031.225.032.223.034.22.036.217.038.214.04.211.041.208.043.205.045.201.046.198.048.194.05.191.051.187.053.183.054.18.056.175.057.172.059.168.06.163.061.16.063.155.064.15.066.074.033.073.033.071.034.07.034.069.035.068.035.067.035.066.035.064.036.064.036.062.036.06.036.06.037.058.037.058.037.055.038.055.038.053.038.052.038.051.039.05.039.048.039.047.039.045.04.044.04.043.04.041.04.04.041.039.041.037.041.036.041.034.041.033.042.032.042.03.042.029.042.027.042.026.043.024.043.023.043.021.043.02.043.018.044.017.043.015.044.013.044.012.044.011.045.009.044.007.045.006.045.004.045.002.045.001.045v17l-.001.045-.002.045-.004.045-.006.045-.007.045-.009.044-.011.045-.012.044-.013.044-.015.044-.017.043-.018.044-.02.043-.021.043-.023.043-.024.043-.026.043-.027.042-.029.042-.03.042-.032.042-.033.042-.034.041-.036.041-.037.041-.039.041-.04.041-.041.04-.043.04-.044.04-.045.04-.047.039-.048.039-.05.039-.051.039-.052.038-.053.038-.055.038-.055.038-.058.037-.058.037-.06.037-.06.036-.062.036-.064.036-.064.036-.066.035-.067.035-.068.035-.069.035-.07.034-.071.034-.073.033-.074.033-.15.066-.155.064-.16.063-.163.061-.168.06-.172.059-.175.057-.18.056-.183.054-.187.053-.191.051-.194.05-.198.048-.201.046-.205.045-.208.043-.211.041-.214.04-.217.038-.22.036-.223.034-.225.032-.229.031-.231.028-.233.027-.236.024-.239.023-.241.02-.242.019-.246.016-.247.015-.249.012-.251.01-.253.008-.255.005-.256.004-.258.001-.258-.001-.256-.004-.255-.005-.253-.008-.251-.01-.249-.012-.247-.015-.245-.016-.243-.019-.241-.02-.238-.023-.236-.024-.234-.027-.231-.028-.228-.031-.226-.032-.223-.034-.22-.036-.217-.038-.214-.04-.211-.041-.208-.043-.204-.045-.201-.046-.198-.048-.195-.05-.19-.051-.187-.053-.184-.054-.179-.056-.176-.057-.172-.059-.167-.06-.164-.061-.159-.063-.155-.064-.151-.066-.074-.033-.072-.033-.072-.034-.07-.034-.069-.035-.068-.035-.067-.035-.066-.035-.064-.036-.063-.036-.062-.036-.061-.036-.06-.037-.058-.037-.057-.037-.056-.038-.055-.038-.053-.038-.052-.038-.051-.039-.049-.039-.049-.039-.046-.039-.046-.04-.044-.04-.043-.04-.041-.04-.04-.041-.039-.041-.037-.041-.036-.041-.034-.041-.033-.042-.032-.042-.03-.042-.029-.042-.027-.042-.026-.043-.024-.043-.023-.043-.021-.043-.02-.043-.018-.044-.017-.043-.015-.044-.013-.044-.012-.044-.011-.045-.009-.044-.007-.045-.006-.045-.004-.045-.002-.045-.001-.045v-17l.001-.045.002-.045.004-.045.006-.045.007-.045.009-.044.011-.045.012-.044.013-.044.015-.044.017-.043.018-.044.02-.043.021-.043.023-.043.024-.043.026-.043.027-.042.029-.042.03-.042.032-.042.033-.042.034-.041.036-.041.037-.041.039-.041.04-.041.041-.04.043-.04.044-.04.046-.04.046-.039.049-.039.049-.039.051-.039.052-.038.053-.038.055-.038.056-.038.057-.037.058-.037.06-.037.061-.036.062-.036.063-.036.064-.036.066-.035.067-.035.068-.035.069-.035.07-.034.072-.034.072-.033.074-.033.151-.066.155-.064.159-.063.164-.061.167-.06.172-.059.176-.057.179-.056.184-.054.187-.053.19-.051.195-.05.198-.048.201-.046.204-.045.208-.043.211-.041.214-.04.217-.038.22-.036.223-.034.226-.032.228-.031.231-.028.234-.027.236-.024.238-.023.241-.02.243-.019.245-.016.247-.015.249-.012.251-.01.253-.008.255-.005.256-.004.258-.001.258.001zm-9.258 20.499v.01l.001.021.003.021.004.022.005.021.006.022.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.023.018.024.019.024.021.024.022.025.023.024.024.025.052.049.056.05.061.051.066.051.07.051.075.051.079.052.084.052.088.052.092.052.097.052.102.051.105.052.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.048.144.049.147.047.152.047.155.047.16.045.163.045.167.043.171.043.176.041.178.041.183.039.187.039.19.037.194.035.197.035.202.033.204.031.209.03.212.029.216.027.219.025.222.024.226.021.23.02.233.018.236.016.24.015.243.012.246.01.249.008.253.005.256.004.259.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.021.224-.024.22-.026.216-.027.212-.028.21-.031.205-.031.202-.034.198-.034.194-.036.191-.037.187-.039.183-.04.179-.04.175-.042.172-.043.168-.044.163-.045.16-.046.155-.046.152-.047.148-.048.143-.049.139-.049.136-.05.131-.05.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.053.083-.051.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.05.023-.024.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.023.01-.022.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.127l-.077.055-.08.053-.083.054-.085.053-.087.052-.09.052-.093.051-.095.05-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.045-.118.044-.12.043-.122.042-.124.042-.126.041-.128.04-.13.04-.132.038-.134.038-.135.037-.138.037-.139.035-.142.035-.143.034-.144.033-.147.032-.148.031-.15.03-.151.03-.153.029-.154.027-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.01-.179.008-.179.008-.181.006-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.006-.179-.008-.179-.008-.178-.01-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.027-.153-.029-.151-.03-.15-.03-.148-.031-.146-.032-.145-.033-.143-.034-.141-.035-.14-.035-.137-.037-.136-.037-.134-.038-.132-.038-.13-.04-.128-.04-.126-.041-.124-.042-.122-.042-.12-.044-.117-.043-.116-.045-.113-.045-.112-.046-.109-.047-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.05-.093-.052-.09-.051-.087-.052-.085-.053-.083-.054-.08-.054-.077-.054v4.127zm0-5.654v.011l.001.021.003.021.004.021.005.022.006.022.007.022.009.022.01.022.011.023.012.023.013.023.015.024.016.023.017.024.018.024.019.024.021.024.022.024.023.025.024.024.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.052.11.051.114.051.119.052.123.05.127.051.131.05.135.049.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.044.171.042.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.022.23.02.233.018.236.016.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.012.241-.015.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.048.139-.05.136-.049.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.051.051-.049.023-.025.023-.024.021-.025.02-.024.019-.024.018-.024.017-.024.015-.023.014-.023.013-.024.012-.022.01-.023.01-.023.008-.022.006-.022.006-.022.004-.021.004-.022.001-.021.001-.021v-4.139l-.077.054-.08.054-.083.054-.085.052-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.044-.118.044-.12.044-.122.042-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.035-.143.033-.144.033-.147.033-.148.031-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.009-.179.009-.179.007-.181.007-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.007-.179-.007-.179-.009-.178-.009-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.031-.146-.033-.145-.033-.143-.033-.141-.035-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.04-.126-.041-.124-.042-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.051-.093-.051-.09-.051-.087-.053-.085-.052-.083-.054-.08-.054-.077-.054v4.139zm0-5.666v.011l.001.02.003.022.004.021.005.022.006.021.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.024.018.023.019.024.021.025.022.024.023.024.024.025.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.051.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.043.171.043.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.021.23.02.233.018.236.017.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.013.241-.014.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.049.139-.049.136-.049.131-.051.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.049.023-.025.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.022.01-.023.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.153l-.077.054-.08.054-.083.053-.085.053-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.048-.105.048-.106.048-.109.046-.111.046-.114.046-.115.044-.118.044-.12.043-.122.043-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.034-.143.034-.144.033-.147.032-.148.032-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.024-.161.024-.162.023-.163.023-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.01-.178.01-.179.009-.179.007-.181.006-.182.006-.182.004-.184.003-.184.001-.185.001-.185-.001-.184-.001-.184-.003-.182-.004-.182-.006-.181-.006-.179-.007-.179-.009-.178-.01-.176-.01-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.023-.162-.023-.161-.024-.159-.024-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.032-.146-.032-.145-.033-.143-.034-.141-.034-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.041-.126-.041-.124-.041-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.048-.105-.048-.102-.048-.1-.05-.097-.049-.095-.051-.093-.051-.09-.052-.087-.052-.085-.053-.083-.053-.08-.054-.077-.054v4.153zm8.74-8.179l-.257.004-.254.005-.25.008-.247.011-.244.012-.241.014-.237.016-.233.018-.231.021-.226.022-.224.023-.22.026-.216.027-.212.028-.21.031-.205.032-.202.033-.198.034-.194.036-.191.038-.187.038-.183.04-.179.041-.175.042-.172.043-.168.043-.163.045-.16.046-.155.046-.152.048-.148.048-.143.048-.139.049-.136.05-.131.05-.126.051-.123.051-.118.051-.114.052-.11.052-.106.052-.101.052-.096.052-.092.052-.088.052-.083.052-.079.052-.074.051-.07.052-.065.051-.06.05-.056.05-.051.05-.023.025-.023.024-.021.024-.02.025-.019.024-.018.024-.017.023-.015.024-.014.023-.013.023-.012.023-.01.023-.01.022-.008.022-.006.023-.006.021-.004.022-.004.021-.001.021-.001.021.001.021.001.021.004.021.004.022.006.021.006.023.008.022.01.022.01.023.012.023.013.023.014.023.015.024.017.023.018.024.019.024.02.025.021.024.023.024.023.025.051.05.056.05.06.05.065.051.07.052.074.051.079.052.083.052.088.052.092.052.096.052.101.052.106.052.11.052.114.052.118.051.123.051.126.051.131.05.136.05.139.049.143.048.148.048.152.048.155.046.16.046.163.045.168.043.172.043.175.042.179.041.183.04.187.038.191.038.194.036.198.034.202.033.205.032.21.031.212.028.216.027.22.026.224.023.226.022.231.021.233.018.237.016.241.014.244.012.247.011.25.008.254.005.257.004.26.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.022.224-.023.22-.026.216-.027.212-.028.21-.031.205-.032.202-.033.198-.034.194-.036.191-.038.187-.038.183-.04.179-.041.175-.042.172-.043.168-.043.163-.045.16-.046.155-.046.152-.048.148-.048.143-.048.139-.049.136-.05.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.05.051-.05.023-.025.023-.024.021-.024.02-.025.019-.024.018-.024.017-.023.015-.024.014-.023.013-.023.012-.023.01-.023.01-.022.008-.022.006-.023.006-.021.004-.022.004-.021.001-.021.001-.021-.001-.021-.001-.021-.004-.021-.004-.022-.006-.021-.006-.023-.008-.022-.01-.022-.01-.023-.012-.023-.013-.023-.014-.023-.015-.024-.017-.023-.018-.024-.019-.024-.02-.025-.021-.024-.023-.024-.023-.025-.051-.05-.056-.05-.06-.05-.065-.051-.07-.052-.074-.051-.079-.052-.083-.052-.088-.052-.092-.052-.096-.052-.101-.052-.106-.052-.11-.052-.114-.052-.118-.051-.123-.051-.126-.051-.131-.05-.136-.05-.139-.049-.143-.048-.148-.048-.152-.048-.155-.046-.16-.046-.163-.045-.168-.043-.172-.043-.175-.042-.179-.041-.183-.04-.187-.038-.191-.038-.194-.036-.198-.034-.202-.033-.205-.032-.21-.031-.212-.028-.216-.027-.22-.026-.224-.023-.226-.022-.231-.021-.233-.018-.237-.016-.241-.014-.244-.012-.247-.011-.25-.008-.254-.005-.257-.004-.26-.001-.26.001z");}(u),function(t){t.append("defs").append("symbol").attr("id","clock").attr("width","24").attr("height","24").append("path").attr("transform","scale(.5)").attr("d","M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm5.848 12.459c.202.038.202.333.001.372-1.907.361-6.045 1.111-6.547 1.111-.719 0-1.301-.582-1.301-1.301 0-.512.77-5.447 1.125-7.445.034-.192.312-.181.343.014l.985 6.238 5.394 1.011z");}(u);var h=new jn(r);h.setData(Pn.diagramMarginX,Pn.diagramMarginX,Pn.diagramMarginY,Pn.diagramMarginY),h.data.widthLimit=screen.availWidth,Ln=Pn.diagramMarginX,In=Pn.diagramMarginY;var f=r.db.getTitle();r.db.getC4Type(),Xn(u,"",h,r.db.getBoundarys(""),r),function(t){t.append("defs").append("marker").attr("id","arrowhead").attr("refX",9).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",12).attr("markerHeight",12).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z");}(u),function(t){t.append("defs").append("marker").attr("id","arrowend").attr("refX",1).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",12).attr("markerHeight",12).attr("orient","auto").append("path").attr("d","M 10 0 L 0 5 L 10 10 z");}(u),function(t){var e=t.append("defs").append("marker").attr("id","crosshead").attr("markerWidth",15).attr("markerHeight",8).attr("orient","auto").attr("refX",16).attr("refY",4);e.append("path").attr("fill","black").attr("stroke","#000000").style("stroke-dasharray","0, 0").attr("stroke-width","1px").attr("d","M 9,2 V 6 L16,4 Z"),e.append("path").attr("fill","none").attr("stroke","#000000").style("stroke-dasharray","0, 0").attr("stroke-width","1px").attr("d","M 0,1 L 6,7 M 6,1 L 0,7");}(u),function(t){t.append("defs").append("marker").attr("id","filled-head").attr("refX",18).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L14,7 L9,1 Z");}(u),function(t,e,n,r){var i,a,o=0,s=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Nn(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return "Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Nn(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return {s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return {s:function(){n=n.call(t);},n:function(){var t=n.next();return o=t.done,t},e:function(t){s=!0,a=t;},f:function(){try{o||null==n.return||n.return();}finally{if(s)throw a}}}}(e);try{for(s.s();!(i=s.n()).done;){var c=i.value;o+=1;var l=c.wrap&&Pn.wrap,u={fontFamily:(a=Pn).messageFontFamily,fontSize:a.messageFontSize,fontWeight:a.messageFontWeight};"C4Dynamic"===r.db.getC4Type()&&(c.label.text=o+": "+c.label.text);var h=xn(c.label.text,u);$n("label",c,l,u,h),c.techn&&""!==c.techn.text&&$n("techn",c,l,u,h=xn(c.techn.text,u)),c.descr&&""!==c.descr.text&&$n("descr",c,l,u,h=xn(c.descr.text,u));var f=n(c.from),d=n(c.to),p=Gn(f,d);c.startPoint=p.startPoint,c.endPoint=p.endPoint;}}catch(t){s.e(t);}finally{s.f();}We(t,e,Pn);}(u,r.db.getRels(),r.db.getC4Shape,r),h.data.stopx=Ln,h.data.stopy=In;var d=h.data,p=d.stopy-d.starty+2*Pn.diagramMarginY,g=d.stopx-d.startx+2*Pn.diagramMarginX;f&&u.append("text").text(f).attr("x",(d.stopx-d.startx)/2-4*Pn.diagramMarginX).attr("y",d.starty+Pn.diagramMarginY),Tn(u,0,g,Pn.useMaxWidth);var y=f?60:0;u.attr("viewBox",d.startx-Pn.diagramMarginX+" -"+(Pn.diagramMarginY+y)+" "+g+" "+(p+y)),Mn(qe.parser.yy,u,e),o.debug("models:",d);}};function Qn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var Kn="classid-",Jn=[],tr={},er=0,nr=[],rr=function(t){return ue.sanitizeText(t,Xt())},ir=function(t){var e="",n=t;if(t.indexOf("~")>0){var r=t.split("~");n=r[0],e=ue.sanitizeText(r[1],Xt());}return {className:n,type:e}},ar=function(t){var e=ir(t);void 0===tr[e.className]&&(tr[e.className]={id:e.className,type:e.type,cssClasses:[],methods:[],members:[],annotations:[],domId:Kn+e.className+"-"+er},er++);},or=function(t){for(var e=Object.keys(tr),n=0;n<e.length;n++)if(tr[e[n]].id===t)return tr[e[n]].domId},sr=function(t,e){var n=ir(t).className,r=tr[n];if("string"==typeof e){var i=e.trim();i.startsWith("<<")&&i.endsWith(">>")?r.annotations.push(rr(i.substring(2,i.length-2))):i.indexOf(")")>0?r.methods.push(rr(i)):i&&r.members.push(rr(i));}},cr=function(t,e){t.split(",").forEach((function(t){var n=t;t[0].match(/\d/)&&(n=Kn+n),void 0!==tr[n]&&tr[n].cssClasses.push(e);}));},lr=function(t,e,n){var r=Xt(),i=t,a=or(i);if("loose"===r.securityLevel&&void 0!==e&&void 0!==tr[i]){var o=[];if("string"==typeof n){o=n.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/);for(var s=0;s<o.length;s++){var c=o[s].trim();'"'===c.charAt(0)&&'"'===c.charAt(c.length-1)&&(c=c.substr(1,c.length-2)),o[s]=c;}}0===o.length&&o.push(a),nr.push((function(){var t=document.querySelector('[id="'.concat(a,'"]'));null!==t&&t.addEventListener("click",(function(){var t;An.runFunc.apply(An,[e].concat(function(t){if(Array.isArray(t))return Qn(t)}(t=o)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Qn(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return "Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Qn(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()));}),!1);}));}},ur=function(t){var e=(0, l.select)(".mermaidTooltip");null===(e._groups||e)[0][0]&&(e=(0, l.select)("body").append("div").attr("class","mermaidTooltip").style("opacity",0)),(0, l.select)(t).select("svg").selectAll("g.node").on("mouseover",(function(){var t=(0, l.select)(this);if(null!==t.attr("title")){var n=this.getBoundingClientRect();e.transition().duration(200).style("opacity",".9"),e.text(t.attr("title")).style("left",window.scrollX+n.left+(n.right-n.left)/2+"px").style("top",window.scrollY+n.top-14+document.body.scrollTop+"px"),e.html(e.html().replace(/&lt;br\/&gt;/g,"<br/>")),t.classed("hover",!0);}})).on("mouseout",(function(){e.transition().duration(500).style("opacity",0),(0, l.select)(this).classed("hover",!1);}));};nr.push(ur);var hr="TB";const fr={parseDirective:function(t,e,n){cu.parseDirective(this,t,e,n);},setAccTitle:ye,getAccTitle:me,getAccDescription:ve,setAccDescription:be,getConfig:function(){return Xt().class},addClass:ar,bindFunctions:function(t){nr.forEach((function(e){e(t);}));},clear:function(){Jn=[],tr={},(nr=[]).push(ur),ge();},getClass:function(t){return tr[t]},getClasses:function(){return tr},addAnnotation:function(t,e){var n=ir(t).className;tr[n].annotations.push(e);},getRelations:function(){return Jn},addRelation:function(t){o.debug("Adding relation: "+JSON.stringify(t)),ar(t.id1),ar(t.id2),t.id1=ir(t.id1).className,t.id2=ir(t.id2).className,t.relationTitle1=ue.sanitizeText(t.relationTitle1.trim(),Xt()),t.relationTitle2=ue.sanitizeText(t.relationTitle2.trim(),Xt()),Jn.push(t);},getDirection:function(){return hr},setDirection:function(t){hr=t;},addMember:sr,addMembers:function(t,e){Array.isArray(e)&&(e.reverse(),e.forEach((function(e){return sr(t,e)})));},cleanupLabel:function(t){return ":"===t.substring(0,1)?ue.sanitizeText(t.substr(1).trim(),Xt()):rr(t.trim())},lineType:{LINE:0,DOTTED_LINE:1},relationType:{AGGREGATION:0,EXTENSION:1,COMPOSITION:2,DEPENDENCY:3,LOLLIPOP:4},setClickEvent:function(t,e,n){t.split(",").forEach((function(t){lr(t,e,n),tr[t].haveCallback=!0;})),cr(t,"clickable");},setCssClass:cr,setLink:function(t,e,n){var r=Xt();t.split(",").forEach((function(t){var i=t;t[0].match(/\d/)&&(i=Kn+i),void 0!==tr[i]&&(tr[i].link=An.formatUrl(e,r),"sandbox"===r.securityLevel?tr[i].linkTarget="_top":tr[i].linkTarget="string"==typeof n?rr(n):"_blank");})),cr(t,"clickable");},getTooltip:function(t){return tr[t].tooltip},setTooltip:function(t,e){var n=Xt();t.split(",").forEach((function(t){void 0!==e&&(tr[t].tooltip=ue.sanitizeText(e,n));}));},lookUpDomId:or};var dr=n(681),pr=n.n(dr),gr=n(8282),yr=n.n(gr),mr=0,br=function(t){var e=t.match(/^(\+|-|~|#)?(\w+)(~\w+~|\[\])?\s+(\w+) *(\*|\$)?$/),n=t.match(/^([+|\-|~|#])?(\w+) *\( *(.*)\) *(\*|\$)? *(\w*[~|[\]]*\s*\w*~?)$/);return e&&!n?vr(e):n?_r(n):xr(t)},vr=function(t){var e="",n="";try{var r=t[1]?t[1].trim():"",i=t[2]?t[2].trim():"",a=t[3]?le(t[3].trim()):"",o=t[4]?t[4].trim():"",s=t[5]?t[5].trim():"";n=r+i+a+" "+o,e=wr(s);}catch(e){n=t;}return {displayText:n,cssStyle:e}},_r=function(t){var e="",n="";try{var r=t[1]?t[1].trim():"",i=t[2]?t[2].trim():"",a=t[3]?le(t[3].trim()):"",o=t[4]?t[4].trim():"";n=r+i+"("+a+")"+(t[5]?" : "+le(t[5]).trim():""),e=wr(o);}catch(e){n=t;}return {displayText:n,cssStyle:e}},xr=function(t){var e="",n="",r="",i=t.indexOf("("),a=t.indexOf(")");if(i>1&&a>i&&a<=t.length){var o="",s="",c=t.substring(0,1);c.match(/\w/)?s=t.substring(0,i).trim():(c.match(/\+|-|~|#/)&&(o=c),s=t.substring(1,i).trim());var l=t.substring(i+1,a),u=t.substring(a+1,1);n=wr(u),e=o+s+"("+le(l.trim())+")",a<"".length&&""!==(r=t.substring(a+2).trim())&&(r=" : "+le(r));}else e=le(t);return {displayText:e,cssStyle:n}},kr=function(t,e,n,r){var i=br(e),a=t.append("tspan").attr("x",r.padding).text(i.displayText);""!==i.cssStyle&&a.attr("style",i.cssStyle),n||a.attr("dy",r.textHeight);},wr=function(t){switch(t){case"*":return "font-style:italic;";case"$":return "text-decoration:underline;";default:return ""}};const Tr=function(t,e,n,r){o.debug("Rendering class ",e,n);var i,a=e.id,s={id:a,label:e.id,width:0,height:0},c=t.append("g").attr("id",r.db.lookUpDomId(a)).attr("class","classGroup");i=e.link?c.append("svg:a").attr("xlink:href",e.link).attr("target",e.linkTarget).append("text").attr("y",n.textHeight+n.padding).attr("x",0):c.append("text").attr("y",n.textHeight+n.padding).attr("x",0);var l=!0;e.annotations.forEach((function(t){var e=i.append("tspan").text("«"+t+"»");l||e.attr("dy",n.textHeight),l=!1;}));var u=e.id;void 0!==e.type&&""!==e.type&&(u+="<"+e.type+">");var h=i.append("tspan").text(u).attr("class","title");l||h.attr("dy",n.textHeight);var f=i.node().getBBox().height,d=c.append("line").attr("x1",0).attr("y1",n.padding+f+n.dividerMargin/2).attr("y2",n.padding+f+n.dividerMargin/2),p=c.append("text").attr("x",n.padding).attr("y",f+n.dividerMargin+n.textHeight).attr("fill","white").attr("class","classText");l=!0,e.members.forEach((function(t){kr(p,t,l,n),l=!1;}));var g=p.node().getBBox(),y=c.append("line").attr("x1",0).attr("y1",n.padding+f+n.dividerMargin+g.height).attr("y2",n.padding+f+n.dividerMargin+g.height),m=c.append("text").attr("x",n.padding).attr("y",f+2*n.dividerMargin+g.height+n.textHeight).attr("fill","white").attr("class","classText");l=!0,e.methods.forEach((function(t){kr(m,t,l,n),l=!1;}));var b=c.node().getBBox(),v=" ";e.cssClasses.length>0&&(v+=e.cssClasses.join(" "));var _=c.insert("rect",":first-child").attr("x",0).attr("y",0).attr("width",b.width+2*n.padding).attr("height",b.height+n.padding+.5*n.dividerMargin).attr("class",v).node().getBBox().width;return i.node().childNodes.forEach((function(t){t.setAttribute("x",(_-t.getBBox().width)/2);})),e.tooltip&&i.insert("title").text(e.tooltip),d.attr("x2",_),y.attr("x2",_),s.width=_,s.height=b.height+n.padding+.5*n.dividerMargin,s};var Er={},Cr=function(t){var e=Object.entries(Er).find((function(e){return e[1].label===t}));if(e)return e[0]};const Sr={draw:function(t,e,n,r){var i=Xt().class;Er={},o.info("Rendering diagram "+t);var a,s=Xt().securityLevel;"sandbox"===s&&(a=(0, l.select)("#i"+e));var c,u="sandbox"===s?(0, l.select)(a.nodes()[0].contentDocument.body):(0, l.select)("body"),h=("sandbox"===s?a.nodes()[0].contentDocument:document,u.select("[id='".concat(e,"']")));(c=h).append("defs").append("marker").attr("id","extensionStart").attr("class","extension").attr("refX",0).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 1,7 L18,13 V 1 Z"),c.append("defs").append("marker").attr("id","extensionEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 1,1 V 13 L18,7 Z"),c.append("defs").append("marker").attr("id","compositionStart").attr("class","extension").attr("refX",0).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),c.append("defs").append("marker").attr("id","compositionEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),c.append("defs").append("marker").attr("id","aggregationStart").attr("class","extension").attr("refX",0).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),c.append("defs").append("marker").attr("id","aggregationEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),c.append("defs").append("marker").attr("id","dependencyStart").attr("class","extension").attr("refX",0).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 5,7 L9,13 L1,7 L9,1 Z"),c.append("defs").append("marker").attr("id","dependencyEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L14,7 L9,1 Z");var f=new(yr().Graph)({multigraph:!0});f.setGraph({isMultiGraph:!0}),f.setDefaultEdgeLabel((function(){return {}}));for(var d=r.db.getClasses(),p=Object.keys(d),g=0;g<p.length;g++){var y=d[p[g]],m=Tr(h,y,i,r);Er[m.id]=m,f.setNode(m.id,m),o.info("Org height: "+m.height);}r.db.getRelations().forEach((function(t){o.info("tjoho"+Cr(t.id1)+Cr(t.id2)+JSON.stringify(t)),f.setEdge(Cr(t.id1),Cr(t.id2),{relation:t},t.title||"DEFAULT");})),pr().layout(f),f.nodes().forEach((function(t){void 0!==t&&void 0!==f.node(t)&&(o.debug("Node "+t+": "+JSON.stringify(f.node(t))),u.select("#"+r.db.lookUpDomId(t)).attr("transform","translate("+(f.node(t).x-f.node(t).width/2)+","+(f.node(t).y-f.node(t).height/2)+" )"));})),f.edges().forEach((function(t){void 0!==t&&void 0!==f.edge(t)&&(o.debug("Edge "+t.v+" -> "+t.w+": "+JSON.stringify(f.edge(t))),function(t,e,n,r,i){var a=function(t){switch(t){case i.db.relationType.AGGREGATION:return "aggregation";case i.db.EXTENSION:return "extension";case i.db.COMPOSITION:return "composition";case i.db.DEPENDENCY:return "dependency";case i.db.LOLLIPOP:return "lollipop"}};e.points=e.points.filter((function(t){return !Number.isNaN(t.y)}));var s,c,u=e.points,h=(0, l.line)().x((function(t){return t.x})).y((function(t){return t.y})).curve(l.curveBasis),f=t.append("path").attr("d",h(u)).attr("id","edge"+mr).attr("class","relation"),d="";r.arrowMarkerAbsolute&&(d=(d=(d=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search).replace(/\(/g,"\\(")).replace(/\)/g,"\\)")),1==n.relation.lineType&&f.attr("class","relation dashed-line"),"none"!==n.relation.type1&&f.attr("marker-start","url("+d+"#"+a(n.relation.type1)+"Start)"),"none"!==n.relation.type2&&f.attr("marker-end","url("+d+"#"+a(n.relation.type2)+"End)");var p,g,y,m,b=e.points.length,v=An.calcLabelPosition(e.points);if(s=v.x,c=v.y,b%2!=0&&b>1){var _=An.calcCardinalityPosition("none"!==n.relation.type1,e.points,e.points[0]),x=An.calcCardinalityPosition("none"!==n.relation.type2,e.points,e.points[b-1]);o.debug("cardinality_1_point "+JSON.stringify(_)),o.debug("cardinality_2_point "+JSON.stringify(x)),p=_.x,g=_.y,y=x.x,m=x.y;}if(void 0!==n.title){var k=t.append("g").attr("class","classLabel"),w=k.append("text").attr("class","label").attr("x",s).attr("y",c).attr("fill","red").attr("text-anchor","middle").text(n.title);window.label=w;var T=w.node().getBBox();k.insert("rect",":first-child").attr("class","box").attr("x",T.x-r.padding/2).attr("y",T.y-r.padding/2).attr("width",T.width+r.padding).attr("height",T.height+r.padding);}o.info("Rendering relation "+JSON.stringify(n)),void 0!==n.relationTitle1&&"none"!==n.relationTitle1&&t.append("g").attr("class","cardinality").append("text").attr("class","type1").attr("x",p).attr("y",g).attr("fill","black").attr("font-size","6").text(n.relationTitle1),void 0!==n.relationTitle2&&"none"!==n.relationTitle2&&t.append("g").attr("class","cardinality").append("text").attr("class","type2").attr("x",y).attr("y",m).attr("fill","black").attr("font-size","6").text(n.relationTitle2),mr++;}(h,f.edge(t),f.edge(t).relation,i,r));}));var b=h.node().getBBox(),v=b.width+40,_=b.height+40;Tn(h,0,v,i.useMaxWidth);var x="".concat(b.x-20," ").concat(b.y-20," ").concat(v," ").concat(_);o.debug("viewBox ".concat(x)),h.attr("viewBox",x),Mn(r.db,h,e);}};var Ar={extension:function(t,e,n){o.trace("Making markers for ",n),t.append("defs").append("marker").attr("id",e+"-extensionStart").attr("class","marker extension "+e).attr("refX",0).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 1,7 L18,13 V 1 Z"),t.append("defs").append("marker").attr("id",e+"-extensionEnd").attr("class","marker extension "+e).attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 1,1 V 13 L18,7 Z");},composition:function(t,e){t.append("defs").append("marker").attr("id",e+"-compositionStart").attr("class","marker composition "+e).attr("refX",0).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),t.append("defs").append("marker").attr("id",e+"-compositionEnd").attr("class","marker composition "+e).attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z");},aggregation:function(t,e){t.append("defs").append("marker").attr("id",e+"-aggregationStart").attr("class","marker aggregation "+e).attr("refX",0).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),t.append("defs").append("marker").attr("id",e+"-aggregationEnd").attr("class","marker aggregation "+e).attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z");},dependency:function(t,e){t.append("defs").append("marker").attr("id",e+"-dependencyStart").attr("class","marker dependency "+e).attr("refX",0).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 5,7 L9,13 L1,7 L9,1 Z"),t.append("defs").append("marker").attr("id",e+"-dependencyEnd").attr("class","marker dependency "+e).attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L14,7 L9,1 Z");},lollipop:function(t,e,n){t.append("defs").append("marker").attr("id",e+"-lollipopStart").attr("class","marker lollipop "+e).attr("refX",0).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("circle").attr("stroke","black").attr("fill","white").attr("cx",6).attr("cy",7).attr("r",6);},point:function(t,e){t.append("marker").attr("id",e+"-pointEnd").attr("class","marker "+e).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",12).attr("markerHeight",12).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0"),t.append("marker").attr("id",e+"-pointStart").attr("class","marker "+e).attr("viewBox","0 0 10 10").attr("refX",0).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",12).attr("markerHeight",12).attr("orient","auto").append("path").attr("d","M 0 5 L 10 10 L 10 0 z").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0");},circle:function(t,e){t.append("marker").attr("id",e+"-circleEnd").attr("class","marker "+e).attr("viewBox","0 0 10 10").attr("refX",11).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("circle").attr("cx","5").attr("cy","5").attr("r","5").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0"),t.append("marker").attr("id",e+"-circleStart").attr("class","marker "+e).attr("viewBox","0 0 10 10").attr("refX",-1).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("circle").attr("cx","5").attr("cy","5").attr("r","5").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0");},cross:function(t,e){t.append("marker").attr("id",e+"-crossEnd").attr("class","marker cross "+e).attr("viewBox","0 0 11 11").attr("refX",12).attr("refY",5.2).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("path").attr("d","M 1,1 l 9,9 M 10,1 l -9,9").attr("class","arrowMarkerPath").style("stroke-width",2).style("stroke-dasharray","1,0"),t.append("marker").attr("id",e+"-crossStart").attr("class","marker cross "+e).attr("viewBox","0 0 11 11").attr("refX",-1).attr("refY",5.2).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("path").attr("d","M 1,1 l 9,9 M 10,1 l -9,9").attr("class","arrowMarkerPath").style("stroke-width",2).style("stroke-dasharray","1,0");},barb:function(t,e){t.append("defs").append("marker").attr("id",e+"-barbEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",14).attr("markerUnits","strokeWidth").attr("orient","auto").append("path").attr("d","M 19,7 L9,13 L14,7 L9,1 Z");}};const Mr=function(t,e,n,r){e.forEach((function(e){Ar[e](t,n,r);}));};function Nr(t){return Nr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Nr(t)}const Or=function(t,e,n,r){var i=t||"";if("object"===Nr(i)&&(i=i[0]),ce(Xt().flowchart.htmlLabels)){i=i.replace(/\\n|\n/g,"<br />"),o.info("vertexText"+i);var a=function(t){var e,n=(0, l.select)(document.createElementNS("http://www.w3.org/2000/svg","foreignObject")),r=n.append("xhtml:div"),i=t.label,a=t.isNode?"nodeLabel":"edgeLabel";return r.html('<span class="'+a+'" '+(t.labelStyle?'style="'+t.labelStyle+'"':"")+">"+i+"</span>"),(e=t.labelStyle)&&r.attr("style",e),r.style("display","inline-block"),r.style("white-space","nowrap"),r.attr("xmlns","http://www.w3.org/1999/xhtml"),n.node()}({isNode:r,label:iu(i).replace(/fa[lrsb]?:fa-[\w-]+/g,(function(t){return "<i class='".concat(t.replace(":"," "),"'></i>")})),labelStyle:e.replace("fill:","color:")});return a}var s=document.createElementNS("http://www.w3.org/2000/svg","text");s.setAttribute("style",e.replace("color:","fill:"));var c=[];c="string"==typeof i?i.split(/\\n|\n|<br\s*\/?>/gi):Array.isArray(i)?i:[];for(var u=0;u<c.length;u++){var h=document.createElementNS("http://www.w3.org/2000/svg","tspan");h.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),h.setAttribute("dy","1em"),h.setAttribute("x","0"),n?h.setAttribute("class","title-row"):h.setAttribute("class","row"),h.textContent=c[u].trim(),s.appendChild(h);}return s};var Dr=function(t,e,n,r){var i;i=n||"node default";var a=t.insert("g").attr("class",i).attr("id",e.domId||e.id),o=a.insert("g").attr("class","label").attr("style",e.labelStyle),s="string"==typeof e.labelText?e.labelText:e.labelText[0],c=o.node().appendChild(Or(ie(iu(s),Xt()),e.labelStyle,!1,r)),u=c.getBBox();if(ce(Xt().flowchart.htmlLabels)){var h=c.children[0],f=(0, l.select)(c);u=h.getBoundingClientRect(),f.attr("width",u.width),f.attr("height",u.height);}var d=e.padding/2;return o.attr("transform","translate("+-u.width/2+", "+-u.height/2+")"),{shapeSvg:a,bbox:u,halfPadding:d,label:o}},Br=function(t,e){var n=e.node().getBBox();t.width=n.width,t.height=n.height;};function Lr(t,e,n,r){return t.insert("polygon",":first-child").attr("points",r.map((function(t){return t.x+","+t.y})).join(" ")).attr("class","label-container").attr("transform","translate("+-e/2+","+n/2+")")}var Ir={},Fr={},Rr={},Pr=function(t,e){return o.trace("In isDecendant",e," ",t," = ",Fr[e].indexOf(t)>=0),Fr[e].indexOf(t)>=0},jr=function t(e,n,r,i){o.warn("Copying children of ",e,"root",i,"data",n.node(e),i);var a=n.children(e)||[];e!==i&&a.push(e),o.warn("Copying (nodes) clusterId",e,"nodes",a),a.forEach((function(a){if(n.children(a).length>0)t(a,n,r,i);else {var s=n.node(a);o.info("cp ",a," to ",i," with parent ",e),r.setNode(a,s),i!==n.parent(a)&&(o.warn("Setting parent",a,n.parent(a)),r.setParent(a,n.parent(a))),e!==i&&a!==e?(o.debug("Setting parent",a,e),r.setParent(a,e)):(o.info("In copy ",e,"root",i,"data",n.node(e),i),o.debug("Not Setting parent for node=",a,"cluster!==rootId",e!==i,"node!==clusterId",a!==e));var c=n.edges(a);o.debug("Copying Edges",c),c.forEach((function(t){o.info("Edge",t);var a=n.edge(t.v,t.w,t.name);o.info("Edge data",a,i);try{!function(t,e){return o.info("Decendants of ",e," is ",Fr[e]),o.info("Edge is ",t),t.v!==e&&t.w!==e&&(Fr[e]?(o.info("Here "),Fr[e].indexOf(t.v)>=0||!!Pr(t.v,e)||!!Pr(t.w,e)||Fr[e].indexOf(t.w)>=0):(o.debug("Tilt, ",e,",not in decendants"),!1))}(t,i)?o.info("Skipping copy of edge ",t.v,"--\x3e",t.w," rootId: ",i," clusterId:",e):(o.info("Copying as ",t.v,t.w,a,t.name),r.setEdge(t.v,t.w,a,t.name),o.info("newGraph edges ",r.edges(),r.edge(r.edges()[0])));}catch(t){o.error(t);}}));}o.debug("Removing node",a),n.removeNode(a);}));},zr=function t(e,n){for(var r=n.children(e),i=[].concat(r),a=0;a<r.length;a++)Rr[r[a]]=e,i=i.concat(t(r[a],n));return i},Yr=function t(e,n){o.trace("Searching",e);var r=n.children(e);if(o.trace("Searching children of id ",e,r),r.length<1)return o.trace("This is a valid node",e),e;for(var i=0;i<r.length;i++){var a=t(r[i],n);if(a)return o.trace("Found replacement for",e," => ",a),a}},Ur=function(t){return Ir[t]&&Ir[t].externalConnections&&Ir[t]?Ir[t].id:t},$r=function(t,e){!t||e>10?o.debug("Opting out, no graph "):(o.debug("Opting in, graph "),t.nodes().forEach((function(e){t.children(e).length>0&&(o.warn("Cluster identified",e," Replacement id in edges: ",Yr(e,t)),Fr[e]=zr(e,t),Ir[e]={id:Yr(e,t),clusterData:t.node(e)});})),t.nodes().forEach((function(e){var n=t.children(e),r=t.edges();n.length>0?(o.debug("Cluster identified",e,Fr),r.forEach((function(t){t.v!==e&&t.w!==e&&Pr(t.v,e)^Pr(t.w,e)&&(o.warn("Edge: ",t," leaves cluster ",e),o.warn("Decendants of XXX ",e,": ",Fr[e]),Ir[e].externalConnections=!0);}))):o.debug("Not a cluster ",e,Fr);})),t.edges().forEach((function(e){var n=t.edge(e);o.warn("Edge "+e.v+" -> "+e.w+": "+JSON.stringify(e)),o.warn("Edge "+e.v+" -> "+e.w+": "+JSON.stringify(t.edge(e)));var r=e.v,i=e.w;if(o.warn("Fix XXX",Ir,"ids:",e.v,e.w,"Translateing: ",Ir[e.v]," --- ",Ir[e.w]),Ir[e.v]&&Ir[e.w]&&Ir[e.v]===Ir[e.w]){o.warn("Fixing and trixing link to self - removing XXX",e.v,e.w,e.name),o.warn("Fixing and trixing - removing XXX",e.v,e.w,e.name),r=Ur(e.v),i=Ur(e.w),t.removeEdge(e.v,e.w,e.name);var a=e.w+"---"+e.v;t.setNode(a,{domId:a,id:a,labelStyle:"",labelText:n.label,padding:0,shape:"labelRect",style:""});var s=JSON.parse(JSON.stringify(n)),c=JSON.parse(JSON.stringify(n));s.label="",s.arrowTypeEnd="none",c.label="",s.fromCluster=e.v,c.toCluster=e.v,t.setEdge(r,a,s,e.name+"-cyclic-special"),t.setEdge(a,i,c,e.name+"-cyclic-special");}else (Ir[e.v]||Ir[e.w])&&(o.warn("Fixing and trixing - removing XXX",e.v,e.w,e.name),r=Ur(e.v),i=Ur(e.w),t.removeEdge(e.v,e.w,e.name),r!==e.v&&(n.fromCluster=e.v),i!==e.w&&(n.toCluster=e.w),o.warn("Fix Replacing with XXX",r,i,e.name),t.setEdge(r,i,n,e.name));})),o.warn("Adjusted Graph",yr().json.write(t)),Wr(t,0),o.trace(Ir));},Wr=function t(e,n){if(o.warn("extractor - ",n,yr().json.write(e),e.children("D")),n>10)o.error("Bailing out");else {for(var r=e.nodes(),i=!1,a=0;a<r.length;a++){var s=r[a],c=e.children(s);i=i||c.length>0;}if(i){o.debug("Nodes = ",r,n);for(var l=0;l<r.length;l++){var u=r[l];if(o.debug("Extracting node",u,Ir,Ir[u]&&!Ir[u].externalConnections,!e.parent(u),e.node(u),e.children("D")," Depth ",n),Ir[u])if(!Ir[u].externalConnections&&e.children(u)&&e.children(u).length>0){o.warn("Cluster without external connections, without a parent and with children",u,n);var h="TB"===e.graph().rankdir?"LR":"TB";Ir[u]&&Ir[u].clusterData&&Ir[u].clusterData.dir&&(h=Ir[u].clusterData.dir,o.warn("Fixing dir",Ir[u].clusterData.dir,h));var f=new(yr().Graph)({multigraph:!0,compound:!0}).setGraph({rankdir:h,nodesep:50,ranksep:50,marginx:8,marginy:8}).setDefaultEdgeLabel((function(){return {}}));o.warn("Old graph before copy",yr().json.write(e)),jr(u,e,f,u),e.setNode(u,{clusterNode:!0,id:u,clusterData:Ir[u].clusterData,labelText:Ir[u].labelText,graph:f}),o.warn("New graph after copy node: (",u,")",yr().json.write(f)),o.debug("Old graph after copy",yr().json.write(e));}else o.warn("Cluster ** ",u," **not meeting the criteria !externalConnections:",!Ir[u].externalConnections," no parent: ",!e.parent(u)," children ",e.children(u)&&e.children(u).length>0,e.children("D"),n),o.debug(Ir);else o.debug("Not a cluster",u,n);}r=e.nodes(),o.warn("New list of nodes",r);for(var d=0;d<r.length;d++){var p=r[d],g=e.node(p);o.warn(" Now next level",p,g),g.clusterNode&&t(g.graph,n+1);}}else o.debug("Done, no node has children",e.nodes());}},qr=function t(e,n){if(0===n.length)return [];var r=Object.assign(n);return n.forEach((function(n){var i=e.children(n),a=t(e,i);r=r.concat(a);})),r},Hr=function(t){return qr(t,t.children())},Vr=n(3841);const Gr=function(t,e,n,r){var i=t.x,a=t.y,o=i-r.x,s=a-r.y,c=Math.sqrt(e*e*s*s+n*n*o*o),l=Math.abs(e*n*o/c);r.x<i&&(l=-l);var u=Math.abs(e*n*s/c);return r.y<a&&(u=-u),{x:i+l,y:a+u}};function Xr(t,e){return t*e>0}const Zr=function(t,e,n,r){var i,a,o,s,c,l,u,h,f,d,p,g,y;if(i=e.y-t.y,o=t.x-e.x,c=e.x*t.y-t.x*e.y,f=i*n.x+o*n.y+c,d=i*r.x+o*r.y+c,!(0!==f&&0!==d&&Xr(f,d)||(a=r.y-n.y,s=n.x-r.x,l=r.x*n.y-n.x*r.y,u=a*t.x+s*t.y+l,h=a*e.x+s*e.y+l,0!==u&&0!==h&&Xr(u,h)||0==(p=i*s-a*o))))return g=Math.abs(p/2),{x:(y=o*l-s*c)<0?(y-g)/p:(y+g)/p,y:(y=a*c-i*l)<0?(y-g)/p:(y+g)/p}},Qr=function(t,e){var n,r,i=t.x,a=t.y,o=e.x-i,s=e.y-a,c=t.width/2,l=t.height/2;return Math.abs(s)*c>Math.abs(o)*l?(s<0&&(l=-l),n=0===s?0:l*o/s,r=l):(o<0&&(c=-c),n=c,r=0===o?0:c*s/o),{x:i+n,y:a+r}},Kr=(n.n(Vr)(),function(t,e,n){return Gr(t,e,e,n)}),Jr=function(t,e,n){var r=t.x,i=t.y,a=[],o=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY;"function"==typeof e.forEach?e.forEach((function(t){o=Math.min(o,t.x),s=Math.min(s,t.y);})):(o=Math.min(o,e.x),s=Math.min(s,e.y));for(var c=r-t.width/2-o,l=i-t.height/2-s,u=0;u<e.length;u++){var h=e[u],f=e[u<e.length-1?u+1:0],d=Zr(t,n,{x:c+h.x,y:l+h.y},{x:c+f.x,y:l+f.y});d&&a.push(d);}return a.length?(a.length>1&&a.sort((function(t,e){var r=t.x-n.x,i=t.y-n.y,a=Math.sqrt(r*r+i*i),o=e.x-n.x,s=e.y-n.y,c=Math.sqrt(o*o+s*s);return a<c?-1:a===c?0:1})),a[0]):t},ti=Qr;function ei(t){return ei="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ei(t)}function ni(t,e,n,r){var i=[],a=function(t){i.push(t),i.push(0);},s=function(t){i.push(0),i.push(t);};e.includes("t")?(o.debug("add top border"),a(n)):s(n),e.includes("r")?(o.debug("add right border"),a(r)):s(r),e.includes("b")?(o.debug("add bottom border"),a(n)):s(n),e.includes("l")?(o.debug("add left border"),a(r)):s(r),t.attr("stroke-dasharray",i.join(" "));}var ri=function(t,e,n){var r=t.insert("g").attr("class","node default").attr("id",e.domId||e.id),i=70,a=10;"LR"===n&&(i=10,a=70);var o=r.append("rect").attr("x",-1*i/2).attr("y",-1*a/2).attr("width",i).attr("height",a).attr("class","fork-join");return Br(e,o),e.height=e.height+e.padding/2,e.width=e.width+e.padding/2,e.intersect=function(t){return ti(e,t)},r},ii={question:function(t,e){var n=Dr(t,e,void 0,!0),r=n.shapeSvg,i=n.bbox,a=i.width+e.padding+(i.height+e.padding),s=[{x:a/2,y:0},{x:a,y:-a/2},{x:a/2,y:-a},{x:0,y:-a/2}];o.info("Question main (Circle)");var c=Lr(r,a,a,s);return c.attr("style",e.style),Br(e,c),e.intersect=function(t){return o.warn("Intersect called"),Jr(e,s,t)},r},rect:function(t,e){var n=Dr(t,e,"node "+e.classes,!0),r=n.shapeSvg,i=n.bbox,a=n.halfPadding;o.trace("Classes = ",e.classes);var s=r.insert("rect",":first-child"),c=i.width+e.padding,l=i.height+e.padding;if(s.attr("class","basic label-container").attr("style",e.style).attr("rx",e.rx).attr("ry",e.ry).attr("x",-i.width/2-a).attr("y",-i.height/2-a).attr("width",c).attr("height",l),e.props){var u=new Set(Object.keys(e.props));e.props.borders&&(ni(s,e.props.borders,c,l),u.delete("borders")),u.forEach((function(t){o.warn("Unknown node property ".concat(t));}));}return Br(e,s),e.intersect=function(t){return ti(e,t)},r},labelRect:function(t,e){var n=Dr(t,e,"label",!0),r=n.shapeSvg;o.trace("Classes = ",e.classes);var i=r.insert("rect",":first-child");if(i.attr("width",0).attr("height",0),r.attr("class","label edgeLabel"),e.props){var a=new Set(Object.keys(e.props));e.props.borders&&(ni(i,e.props.borders,0,0),a.delete("borders")),a.forEach((function(t){o.warn("Unknown node property ".concat(t));}));}return Br(e,i),e.intersect=function(t){return ti(e,t)},r},rectWithTitle:function(t,e){var n;n=e.classes?"node "+e.classes:"node default";var r,i=t.insert("g").attr("class",n).attr("id",e.domId||e.id),a=i.insert("rect",":first-child"),s=i.insert("line"),c=i.insert("g").attr("class","label"),u=e.labelText.flat?e.labelText.flat():e.labelText;r="object"===ei(u)?u[0]:u,o.info("Label text abc79",r,u,"object"===ei(u));var h=c.node().appendChild(Or(r,e.labelStyle,!0,!0)),f={width:0,height:0};if(ce(Xt().flowchart.htmlLabels)){var d=h.children[0],p=(0, l.select)(h);f=d.getBoundingClientRect(),p.attr("width",f.width),p.attr("height",f.height);}o.info("Text 2",u);var g=u.slice(1,u.length),y=h.getBBox(),m=c.node().appendChild(Or(g.join?g.join("<br/>"):g,e.labelStyle,!0,!0));if(ce(Xt().flowchart.htmlLabels)){var b=m.children[0],v=(0, l.select)(m);f=b.getBoundingClientRect(),v.attr("width",f.width),v.attr("height",f.height);}var _=e.padding/2;return (0, l.select)(m).attr("transform","translate( "+(f.width>y.width?0:(y.width-f.width)/2)+", "+(y.height+_+5)+")"),(0, l.select)(h).attr("transform","translate( "+(f.width<y.width?0:-(y.width-f.width)/2)+", 0)"),f=c.node().getBBox(),c.attr("transform","translate("+-f.width/2+", "+(-f.height/2-_+3)+")"),a.attr("class","outer title-state").attr("x",-f.width/2-_).attr("y",-f.height/2-_).attr("width",f.width+e.padding).attr("height",f.height+e.padding),s.attr("class","divider").attr("x1",-f.width/2-_).attr("x2",f.width/2+_).attr("y1",-f.height/2-_+y.height+_).attr("y2",-f.height/2-_+y.height+_),Br(e,a),e.intersect=function(t){return ti(e,t)},i},choice:function(t,e){var n=t.insert("g").attr("class","node default").attr("id",e.domId||e.id);return n.insert("polygon",":first-child").attr("points",[{x:0,y:14},{x:14,y:0},{x:0,y:-14},{x:-14,y:0}].map((function(t){return t.x+","+t.y})).join(" ")).attr("class","state-start").attr("r",7).attr("width",28).attr("height",28),e.width=28,e.height=28,e.intersect=function(t){return Kr(e,14,t)},n},circle:function(t,e){var n=Dr(t,e,void 0,!0),r=n.shapeSvg,i=n.bbox,a=n.halfPadding,s=r.insert("circle",":first-child");return s.attr("style",e.style).attr("rx",e.rx).attr("ry",e.ry).attr("r",i.width/2+a).attr("width",i.width+e.padding).attr("height",i.height+e.padding),o.info("Circle main"),Br(e,s),e.intersect=function(t){return o.info("Circle intersect",e,i.width/2+a,t),Kr(e,i.width/2+a,t)},r},doublecircle:function(t,e){var n=Dr(t,e,void 0,!0),r=n.shapeSvg,i=n.bbox,a=n.halfPadding,s=r.insert("g",":first-child"),c=s.insert("circle"),l=s.insert("circle");return c.attr("style",e.style).attr("rx",e.rx).attr("ry",e.ry).attr("r",i.width/2+a+5).attr("width",i.width+e.padding+10).attr("height",i.height+e.padding+10),l.attr("style",e.style).attr("rx",e.rx).attr("ry",e.ry).attr("r",i.width/2+a).attr("width",i.width+e.padding).attr("height",i.height+e.padding),o.info("DoubleCircle main"),Br(e,c),e.intersect=function(t){return o.info("DoubleCircle intersect",e,i.width/2+a+5,t),Kr(e,i.width/2+a+5,t)},r},stadium:function(t,e){var n=Dr(t,e,void 0,!0),r=n.shapeSvg,i=n.bbox,a=i.height+e.padding,o=i.width+a/4+e.padding,s=r.insert("rect",":first-child").attr("style",e.style).attr("rx",a/2).attr("ry",a/2).attr("x",-o/2).attr("y",-a/2).attr("width",o).attr("height",a);return Br(e,s),e.intersect=function(t){return ti(e,t)},r},hexagon:function(t,e){var n=Dr(t,e,void 0,!0),r=n.shapeSvg,i=n.bbox,a=i.height+e.padding,o=a/4,s=i.width+2*o+e.padding,c=[{x:o,y:0},{x:s-o,y:0},{x:s,y:-a/2},{x:s-o,y:-a},{x:o,y:-a},{x:0,y:-a/2}],l=Lr(r,s,a,c);return l.attr("style",e.style),Br(e,l),e.intersect=function(t){return Jr(e,c,t)},r},rect_left_inv_arrow:function(t,e){var n=Dr(t,e,void 0,!0),r=n.shapeSvg,i=n.bbox,a=i.width+e.padding,o=i.height+e.padding,s=[{x:-o/2,y:0},{x:a,y:0},{x:a,y:-o},{x:-o/2,y:-o},{x:0,y:-o/2}];return Lr(r,a,o,s).attr("style",e.style),e.width=a+o,e.height=o,e.intersect=function(t){return Jr(e,s,t)},r},lean_right:function(t,e){var n=Dr(t,e,void 0,!0),r=n.shapeSvg,i=n.bbox,a=i.width+e.padding,o=i.height+e.padding,s=[{x:-2*o/6,y:0},{x:a-o/6,y:0},{x:a+2*o/6,y:-o},{x:o/6,y:-o}],c=Lr(r,a,o,s);return c.attr("style",e.style),Br(e,c),e.intersect=function(t){return Jr(e,s,t)},r},lean_left:function(t,e){var n=Dr(t,e,void 0,!0),r=n.shapeSvg,i=n.bbox,a=i.width+e.padding,o=i.height+e.padding,s=[{x:2*o/6,y:0},{x:a+o/6,y:0},{x:a-2*o/6,y:-o},{x:-o/6,y:-o}],c=Lr(r,a,o,s);return c.attr("style",e.style),Br(e,c),e.intersect=function(t){return Jr(e,s,t)},r},trapezoid:function(t,e){var n=Dr(t,e,void 0,!0),r=n.shapeSvg,i=n.bbox,a=i.width+e.padding,o=i.height+e.padding,s=[{x:-2*o/6,y:0},{x:a+2*o/6,y:0},{x:a-o/6,y:-o},{x:o/6,y:-o}],c=Lr(r,a,o,s);return c.attr("style",e.style),Br(e,c),e.intersect=function(t){return Jr(e,s,t)},r},inv_trapezoid:function(t,e){var n=Dr(t,e,void 0,!0),r=n.shapeSvg,i=n.bbox,a=i.width+e.padding,o=i.height+e.padding,s=[{x:o/6,y:0},{x:a-o/6,y:0},{x:a+2*o/6,y:-o},{x:-2*o/6,y:-o}],c=Lr(r,a,o,s);return c.attr("style",e.style),Br(e,c),e.intersect=function(t){return Jr(e,s,t)},r},rect_right_inv_arrow:function(t,e){var n=Dr(t,e,void 0,!0),r=n.shapeSvg,i=n.bbox,a=i.width+e.padding,o=i.height+e.padding,s=[{x:0,y:0},{x:a+o/2,y:0},{x:a,y:-o/2},{x:a+o/2,y:-o},{x:0,y:-o}],c=Lr(r,a,o,s);return c.attr("style",e.style),Br(e,c),e.intersect=function(t){return Jr(e,s,t)},r},cylinder:function(t,e){var n=Dr(t,e,void 0,!0),r=n.shapeSvg,i=n.bbox,a=i.width+e.padding,o=a/2,s=o/(2.5+a/50),c=i.height+s+e.padding,l="M 0,"+s+" a "+o+","+s+" 0,0,0 "+a+" 0 a "+o+","+s+" 0,0,0 "+-a+" 0 l 0,"+c+" a "+o+","+s+" 0,0,0 "+a+" 0 l 0,"+-c,u=r.attr("label-offset-y",s).insert("path",":first-child").attr("style",e.style).attr("d",l).attr("transform","translate("+-a/2+","+-(c/2+s)+")");return Br(e,u),e.intersect=function(t){var n=ti(e,t),r=n.x-e.x;if(0!=o&&(Math.abs(r)<e.width/2||Math.abs(r)==e.width/2&&Math.abs(n.y-e.y)>e.height/2-s)){var i=s*s*(1-r*r/(o*o));0!=i&&(i=Math.sqrt(i)),i=s-i,t.y-e.y>0&&(i=-i),n.y+=i;}return n},r},start:function(t,e){var n=t.insert("g").attr("class","node default").attr("id",e.domId||e.id),r=n.insert("circle",":first-child");return r.attr("class","state-start").attr("r",7).attr("width",14).attr("height",14),Br(e,r),e.intersect=function(t){return Kr(e,7,t)},n},end:function(t,e){var n=t.insert("g").attr("class","node default").attr("id",e.domId||e.id),r=n.insert("circle",":first-child"),i=n.insert("circle",":first-child");return i.attr("class","state-start").attr("r",7).attr("width",14).attr("height",14),r.attr("class","state-end").attr("r",5).attr("width",10).attr("height",10),Br(e,i),e.intersect=function(t){return Kr(e,7,t)},n},note:function(t,e){var n=Dr(t,e,"node "+e.classes,!0),r=n.shapeSvg,i=n.bbox,a=n.halfPadding;o.info("Classes = ",e.classes);var s=r.insert("rect",":first-child");return s.attr("rx",e.rx).attr("ry",e.ry).attr("x",-i.width/2-a).attr("y",-i.height/2-a).attr("width",i.width+e.padding).attr("height",i.height+e.padding),Br(e,s),e.intersect=function(t){return ti(e,t)},r},subroutine:function(t,e){var n=Dr(t,e,void 0,!0),r=n.shapeSvg,i=n.bbox,a=i.width+e.padding,o=i.height+e.padding,s=[{x:0,y:0},{x:a,y:0},{x:a,y:-o},{x:0,y:-o},{x:0,y:0},{x:-8,y:0},{x:a+8,y:0},{x:a+8,y:-o},{x:-8,y:-o},{x:-8,y:0}],c=Lr(r,a,o,s);return c.attr("style",e.style),Br(e,c),e.intersect=function(t){return Jr(e,s,t)},r},fork:ri,join:ri,class_box:function(t,e){var n,r=e.padding/2;n=e.classes?"node "+e.classes:"node default";var i=t.insert("g").attr("class",n).attr("id",e.domId||e.id),a=i.insert("rect",":first-child"),o=i.insert("line"),s=i.insert("line"),c=0,u=4,h=i.insert("g").attr("class","label"),f=0,d=e.classData.annotations&&e.classData.annotations[0],p=e.classData.annotations[0]?"«"+e.classData.annotations[0]+"»":"",g=h.node().appendChild(Or(p,e.labelStyle,!0,!0)),y=g.getBBox();if(ce(Xt().flowchart.htmlLabels)){var m=g.children[0],b=(0, l.select)(g);y=m.getBoundingClientRect(),b.attr("width",y.width),b.attr("height",y.height);}e.classData.annotations[0]&&(u+=y.height+4,c+=y.width);var v=e.classData.id;void 0!==e.classData.type&&""!==e.classData.type&&(Xt().flowchart.htmlLabels?v+="&lt;"+e.classData.type+"&gt;":v+="<"+e.classData.type+">");var _=h.node().appendChild(Or(v,e.labelStyle,!0,!0));(0, l.select)(_).attr("class","classTitle");var x=_.getBBox();if(ce(Xt().flowchart.htmlLabels)){var k=_.children[0],w=(0, l.select)(_);x=k.getBoundingClientRect(),w.attr("width",x.width),w.attr("height",x.height);}u+=x.height+4,x.width>c&&(c=x.width);var T=[];e.classData.members.forEach((function(t){var n=br(t),r=n.displayText;Xt().flowchart.htmlLabels&&(r=r.replace(/</g,"&lt;").replace(/>/g,"&gt;"));var i=h.node().appendChild(Or(r,n.cssStyle?n.cssStyle:e.labelStyle,!0,!0)),a=i.getBBox();if(ce(Xt().flowchart.htmlLabels)){var o=i.children[0],s=(0, l.select)(i);a=o.getBoundingClientRect(),s.attr("width",a.width),s.attr("height",a.height);}a.width>c&&(c=a.width),u+=a.height+4,T.push(i);})),u+=8;var E=[];if(e.classData.methods.forEach((function(t){var n=br(t),r=n.displayText;Xt().flowchart.htmlLabels&&(r=r.replace(/</g,"&lt;").replace(/>/g,"&gt;"));var i=h.node().appendChild(Or(r,n.cssStyle?n.cssStyle:e.labelStyle,!0,!0)),a=i.getBBox();if(ce(Xt().flowchart.htmlLabels)){var o=i.children[0],s=(0, l.select)(i);a=o.getBoundingClientRect(),s.attr("width",a.width),s.attr("height",a.height);}a.width>c&&(c=a.width),u+=a.height+4,E.push(i);})),u+=8,d){var C=(c-y.width)/2;(0, l.select)(g).attr("transform","translate( "+(-1*c/2+C)+", "+-1*u/2+")"),f=y.height+4;}var S=(c-x.width)/2;return (0, l.select)(_).attr("transform","translate( "+(-1*c/2+S)+", "+(-1*u/2+f)+")"),f+=x.height+4,o.attr("class","divider").attr("x1",-c/2-r).attr("x2",c/2+r).attr("y1",-u/2-r+8+f).attr("y2",-u/2-r+8+f),f+=8,T.forEach((function(t){(0, l.select)(t).attr("transform","translate( "+-c/2+", "+(-1*u/2+f+4)+")"),f+=x.height+4;})),f+=8,s.attr("class","divider").attr("x1",-c/2-r).attr("x2",c/2+r).attr("y1",-u/2-r+8+f).attr("y2",-u/2-r+8+f),f+=8,E.forEach((function(t){(0, l.select)(t).attr("transform","translate( "+-c/2+", "+(-1*u/2+f)+")"),f+=x.height+4;})),a.attr("class","outer title-state").attr("x",-c/2-r).attr("y",-u/2-r).attr("width",c+e.padding).attr("height",u+e.padding),Br(e,a),e.intersect=function(t){return ti(e,t)},i}},ai={},oi=function(t){var e=ai[t.id];o.trace("Transforming node",t.diff,t,"translate("+(t.x-t.width/2-5)+", "+t.width/2+")");var n=t.diff||0;return t.clusterNode?e.attr("transform","translate("+(t.x+n-t.width/2)+", "+(t.y-t.height/2-8)+")"):e.attr("transform","translate("+t.x+", "+t.y+")"),n},si={rect:function(t,e){o.trace("Creating subgraph rect for ",e.id,e);var n=t.insert("g").attr("class","cluster"+(e.class?" "+e.class:"")).attr("id",e.id),r=n.insert("rect",":first-child"),i=n.insert("g").attr("class","cluster-label"),a=i.node().appendChild(Or(e.labelText,e.labelStyle,void 0,!0)),s=a.getBBox();if(ce(Xt().flowchart.htmlLabels)){var c=a.children[0],u=(0, l.select)(a);s=c.getBoundingClientRect(),u.attr("width",s.width),u.attr("height",s.height);}var h=0*e.padding,f=h/2,d=e.width<=s.width+h?s.width+h:e.width;e.width<=s.width+h?e.diff=(s.width-e.width)/2-e.padding/2:e.diff=-e.padding/2,o.trace("Data ",e,JSON.stringify(e)),r.attr("style",e.style).attr("rx",e.rx).attr("ry",e.ry).attr("x",e.x-d/2).attr("y",e.y-e.height/2-f).attr("width",d).attr("height",e.height+h),i.attr("transform","translate("+(e.x-s.width/2)+", "+(e.y-e.height/2+e.padding/3)+")");var p=r.node().getBBox();return e.width=p.width,e.height=p.height,e.intersect=function(t){return Qr(e,t)},n},roundedWithTitle:function(t,e){var n=t.insert("g").attr("class",e.classes).attr("id",e.id),r=n.insert("rect",":first-child"),i=n.insert("g").attr("class","cluster-label"),a=n.append("rect"),o=i.node().appendChild(Or(e.labelText,e.labelStyle,void 0,!0)),s=o.getBBox();if(ce(Xt().flowchart.htmlLabels)){var c=o.children[0],u=(0, l.select)(o);s=c.getBoundingClientRect(),u.attr("width",s.width),u.attr("height",s.height);}s=o.getBBox();var h=0*e.padding,f=h/2,d=e.width<=s.width+e.padding?s.width+e.padding:e.width;e.width<=s.width+e.padding?e.diff=(s.width+0*e.padding-e.width)/2:e.diff=-e.padding/2,r.attr("class","outer").attr("x",e.x-d/2-f).attr("y",e.y-e.height/2-f).attr("width",d+h).attr("height",e.height+h),a.attr("class","inner").attr("x",e.x-d/2-f).attr("y",e.y-e.height/2-f+s.height-1).attr("width",d+h).attr("height",e.height+h-s.height-3),i.attr("transform","translate("+(e.x-s.width/2)+", "+(e.y-e.height/2-e.padding/3+(ce(Xt().flowchart.htmlLabels)?5:3))+")");var p=r.node().getBBox();return e.height=p.height,e.intersect=function(t){return Qr(e,t)},n},noteGroup:function(t,e){var n=t.insert("g").attr("class","note-cluster").attr("id",e.id),r=n.insert("rect",":first-child"),i=0*e.padding,a=i/2;r.attr("rx",e.rx).attr("ry",e.ry).attr("x",e.x-e.width/2-a).attr("y",e.y-e.height/2-a).attr("width",e.width+i).attr("height",e.height+i).attr("fill","none");var o=r.node().getBBox();return e.width=o.width,e.height=o.height,e.intersect=function(t){return Qr(e,t)},n},divider:function(t,e){var n=t.insert("g").attr("class",e.classes).attr("id",e.id),r=n.insert("rect",":first-child"),i=0*e.padding,a=i/2;r.attr("class","divider").attr("x",e.x-e.width/2-a).attr("y",e.y-e.height/2).attr("width",e.width+i).attr("height",e.height+i);var o=r.node().getBBox();return e.width=o.width,e.height=o.height,e.diff=-e.padding/2,e.intersect=function(t){return Qr(e,t)},n}},ci={},li={},ui={},hi=function(t,e){var n=Or(e.label,e.labelStyle),r=t.insert("g").attr("class","edgeLabel"),i=r.insert("g").attr("class","label");i.node().appendChild(n);var a,o=n.getBBox();if(ce(Xt().flowchart.htmlLabels)){var s=n.children[0],c=(0, l.select)(n);o=s.getBoundingClientRect(),c.attr("width",o.width),c.attr("height",o.height);}if(i.attr("transform","translate("+-o.width/2+", "+-o.height/2+")"),li[e.id]=r,e.width=o.width,e.height=o.height,e.startLabelLeft){var u=Or(e.startLabelLeft,e.labelStyle),h=t.insert("g").attr("class","edgeTerminals"),f=h.insert("g").attr("class","inner");a=f.node().appendChild(u);var d=u.getBBox();f.attr("transform","translate("+-d.width/2+", "+-d.height/2+")"),ui[e.id]||(ui[e.id]={}),ui[e.id].startLeft=h,fi(a,e.startLabelLeft);}if(e.startLabelRight){var p=Or(e.startLabelRight,e.labelStyle),g=t.insert("g").attr("class","edgeTerminals"),y=g.insert("g").attr("class","inner");a=g.node().appendChild(p),y.node().appendChild(p);var m=p.getBBox();y.attr("transform","translate("+-m.width/2+", "+-m.height/2+")"),ui[e.id]||(ui[e.id]={}),ui[e.id].startRight=g,fi(a,e.startLabelRight);}if(e.endLabelLeft){var b=Or(e.endLabelLeft,e.labelStyle),v=t.insert("g").attr("class","edgeTerminals"),_=v.insert("g").attr("class","inner");a=_.node().appendChild(b);var x=b.getBBox();_.attr("transform","translate("+-x.width/2+", "+-x.height/2+")"),v.node().appendChild(b),ui[e.id]||(ui[e.id]={}),ui[e.id].endLeft=v,fi(a,e.endLabelLeft);}if(e.endLabelRight){var k=Or(e.endLabelRight,e.labelStyle),w=t.insert("g").attr("class","edgeTerminals"),T=w.insert("g").attr("class","inner");a=T.node().appendChild(k);var E=k.getBBox();T.attr("transform","translate("+-E.width/2+", "+-E.height/2+")"),w.node().appendChild(k),ui[e.id]||(ui[e.id]={}),ui[e.id].endRight=w,fi(a,e.endLabelRight);}};function fi(t,e){Xt().flowchart.htmlLabels&&t&&(t.style.width=9*e.length+"px",t.style.height="12px");}var di=function(t,e){o.info("Moving label abc78 ",t.id,t.label,li[t.id]);var n=e.updatedPath?e.updatedPath:e.originalPath;if(t.label){var r=li[t.id],i=t.x,a=t.y;if(n){var s=An.calcLabelPosition(n);o.info("Moving label from (",i,",",a,") to (",s.x,",",s.y,") abc78");}r.attr("transform","translate("+i+", "+a+")");}if(t.startLabelLeft){var c=ui[t.id].startLeft,l=t.x,u=t.y;if(n){var h=An.calcTerminalLabelPosition(t.arrowTypeStart?10:0,"start_left",n);l=h.x,u=h.y;}c.attr("transform","translate("+l+", "+u+")");}if(t.startLabelRight){var f=ui[t.id].startRight,d=t.x,p=t.y;if(n){var g=An.calcTerminalLabelPosition(t.arrowTypeStart?10:0,"start_right",n);d=g.x,p=g.y;}f.attr("transform","translate("+d+", "+p+")");}if(t.endLabelLeft){var y=ui[t.id].endLeft,m=t.x,b=t.y;if(n){var v=An.calcTerminalLabelPosition(t.arrowTypeEnd?10:0,"end_left",n);m=v.x,b=v.y;}y.attr("transform","translate("+m+", "+b+")");}if(t.endLabelRight){var _=ui[t.id].endRight,x=t.x,k=t.y;if(n){var w=An.calcTerminalLabelPosition(t.arrowTypeEnd?10:0,"end_right",n);x=w.x,k=w.y;}_.attr("transform","translate("+x+", "+k+")");}},pi=function(t,e){o.warn("abc88 cutPathAtIntersect",t,e);var n=[],r=t[0],i=!1;return t.forEach((function(t){if(o.info("abc88 checking point",t,e),function(t,e){var n=t.x,r=t.y,i=Math.abs(e.x-n),a=Math.abs(e.y-r),o=t.width/2,s=t.height/2;return i>=o||a>=s}(e,t)||i)o.warn("abc88 outside",t,r),r=t,i||n.push(t);else {var a=function(t,e,n){o.warn("intersection calc abc89:\n outsidePoint: ".concat(JSON.stringify(e),"\n insidePoint : ").concat(JSON.stringify(n),"\n node : x:").concat(t.x," y:").concat(t.y," w:").concat(t.width," h:").concat(t.height));var r=t.x,i=t.y,a=Math.abs(r-n.x),s=t.width/2,c=n.x<e.x?s-a:s+a,l=t.height/2,u=Math.abs(e.y-n.y),h=Math.abs(e.x-n.x);if(Math.abs(i-e.y)*s>Math.abs(r-e.x)*l){var f=n.y<e.y?e.y-l-i:i-l-e.y;c=h*f/u;var d={x:n.x<e.x?n.x+c:n.x-h+c,y:n.y<e.y?n.y+u-f:n.y-u+f};return 0===c&&(d.x=e.x,d.y=e.y),0===h&&(d.x=e.x),0===u&&(d.y=e.y),o.warn("abc89 topp/bott calc, Q ".concat(u,", q ").concat(f,", R ").concat(h,", r ").concat(c),d),d}var p=u*(c=n.x<e.x?e.x-s-r:r-s-e.x)/h,g=n.x<e.x?n.x+h-c:n.x-h+c,y=n.y<e.y?n.y+p:n.y-p;return o.warn("sides calc abc89, Q ".concat(u,", q ").concat(p,", R ").concat(h,", r ").concat(c),{_x:g,_y:y}),0===c&&(g=e.x,y=e.y),0===h&&(g=e.x),0===u&&(y=e.y),{x:g,y}}(e,r,t);o.warn("abc88 inside",t,r,a),o.warn("abc88 intersection",a);var s=!1;n.forEach((function(t){s=s||t.x===a.x&&t.y===a.y;})),n.find((function(t){return t.x===a.x&&t.y===a.y}))?o.warn("abc88 no intersect",a,n):n.push(a),i=!0;}})),o.warn("abc88 returning points",n),n},gi=function t(e,n,r,i){o.info("Graph in recursive render: XXX",yr().json.write(n),i);var a=n.graph().rankdir;o.trace("Dir in recursive render - dir:",a);var s=e.insert("g").attr("class","root");n.nodes()?o.info("Recursive render XXX",n.nodes()):o.info("No nodes found for",n),n.edges().length>0&&o.trace("Recursive edges",n.edge(n.edges()[0]));var c=s.insert("g").attr("class","clusters"),u=s.insert("g").attr("class","edgePaths"),h=s.insert("g").attr("class","edgeLabels"),f=s.insert("g").attr("class","nodes");n.nodes().forEach((function(e){var s=n.node(e);if(void 0!==i){var c=JSON.parse(JSON.stringify(i.clusterData));o.info("Setting data for cluster XXX (",e,") ",c,i),n.setNode(i.id,c),n.parent(e)||(o.trace("Setting parent",e,i.id),n.setParent(e,i.id,c));}if(o.info("(Insert) Node XXX"+e+": "+JSON.stringify(n.node(e))),s&&s.clusterNode){o.info("Cluster identified",e,s.width,n.node(e));var l=t(f,s.graph,r,n.node(e)),u=l.elem;Br(s,u),s.diff=l.diff||0,o.info("Node bounds (abc123)",e,s,s.width,s.x,s.y),function(t,e){ai[e.id]=t;}(u,s),o.warn("Recursive render complete ",u,s);}else n.children(e).length>0?(o.info("Cluster - the non recursive path XXX",e,s.id,s,n),o.info(Yr(s.id,n)),Ir[s.id]={id:Yr(s.id,n),node:s}):(o.info("Node - the non recursive path",e,s.id,s),function(t,e,n){var r,i,a;e.link?("sandbox"===Xt().securityLevel?a="_top":e.linkTarget&&(a=e.linkTarget||"_blank"),r=t.insert("svg:a").attr("xlink:href",e.link).attr("target",a),i=ii[e.shape](r,e,n)):r=i=ii[e.shape](t,e,n),e.tooltip&&i.attr("title",e.tooltip),e.class&&i.attr("class","node default "+e.class),ai[e.id]=r,e.haveCallback&&ai[e.id].attr("class",ai[e.id].attr("class")+" clickable");}(f,n.node(e),a));})),n.edges().forEach((function(t){var e=n.edge(t.v,t.w,t.name);o.info("Edge "+t.v+" -> "+t.w+": "+JSON.stringify(t)),o.info("Edge "+t.v+" -> "+t.w+": ",t," ",JSON.stringify(n.edge(t))),o.info("Fix",Ir,"ids:",t.v,t.w,"Translateing: ",Ir[t.v],Ir[t.w]),hi(h,e);})),n.edges().forEach((function(t){o.info("Edge "+t.v+" -> "+t.w+": "+JSON.stringify(t));})),o.info("#############################################"),o.info("### Layout ###"),o.info("#############################################"),o.info(n),pr().layout(n),o.info("Graph after layout:",yr().json.write(n));var d=0;return Hr(n).forEach((function(t){var e=n.node(t);o.info("Position "+t+": "+JSON.stringify(n.node(t))),o.info("Position "+t+": ("+e.x,","+e.y,") width: ",e.width," height: ",e.height),e&&e.clusterNode?oi(e):n.children(t).length>0?(function(t,e){o.trace("Inserting cluster");var n=e.shape||"rect";ci[e.id]=si[n](t,e);}(c,e),Ir[e.id].node=e):oi(e);})),n.edges().forEach((function(t){var e=n.edge(t);o.info("Edge "+t.v+" -> "+t.w+": "+JSON.stringify(e),e);var i=function(t,e,n,r,i,a){var s=n.points,c=!1,u=a.node(e.v),h=a.node(e.w);o.info("abc88 InsertEdge: ",n),h.intersect&&u.intersect&&((s=s.slice(1,n.points.length-1)).unshift(u.intersect(s[0])),o.info("Last point",s[s.length-1],h,h.intersect(s[s.length-1])),s.push(h.intersect(s[s.length-1]))),n.toCluster&&(o.info("to cluster abc88",r[n.toCluster]),s=pi(n.points,r[n.toCluster].node),c=!0),n.fromCluster&&(o.info("from cluster abc88",r[n.fromCluster]),s=pi(s.reverse(),r[n.fromCluster].node).reverse(),c=!0);var f,d=s.filter((function(t){return !Number.isNaN(t.y)}));f=("graph"===i||"flowchart"===i)&&n.curve||l.curveBasis;var p,g=(0, l.line)().x((function(t){return t.x})).y((function(t){return t.y})).curve(f);switch(n.thickness){case"normal":p="edge-thickness-normal";break;case"thick":p="edge-thickness-thick";break;default:p="";}switch(n.pattern){case"solid":p+=" edge-pattern-solid";break;case"dotted":p+=" edge-pattern-dotted";break;case"dashed":p+=" edge-pattern-dashed";}var y=t.append("path").attr("d",g(d)).attr("id",n.id).attr("class"," "+p+(n.classes?" "+n.classes:"")).attr("style",n.style),m="";switch(Xt().state.arrowMarkerAbsolute&&(m=(m=(m=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search).replace(/\(/g,"\\(")).replace(/\)/g,"\\)")),o.info("arrowTypeStart",n.arrowTypeStart),o.info("arrowTypeEnd",n.arrowTypeEnd),n.arrowTypeStart){case"arrow_cross":y.attr("marker-start","url("+m+"#"+i+"-crossStart)");break;case"arrow_point":y.attr("marker-start","url("+m+"#"+i+"-pointStart)");break;case"arrow_barb":y.attr("marker-start","url("+m+"#"+i+"-barbStart)");break;case"arrow_circle":y.attr("marker-start","url("+m+"#"+i+"-circleStart)");break;case"aggregation":y.attr("marker-start","url("+m+"#"+i+"-aggregationStart)");break;case"extension":y.attr("marker-start","url("+m+"#"+i+"-extensionStart)");break;case"composition":y.attr("marker-start","url("+m+"#"+i+"-compositionStart)");break;case"dependency":y.attr("marker-start","url("+m+"#"+i+"-dependencyStart)");break;case"lollipop":y.attr("marker-start","url("+m+"#"+i+"-lollipopStart)");}switch(n.arrowTypeEnd){case"arrow_cross":y.attr("marker-end","url("+m+"#"+i+"-crossEnd)");break;case"arrow_point":y.attr("marker-end","url("+m+"#"+i+"-pointEnd)");break;case"arrow_barb":y.attr("marker-end","url("+m+"#"+i+"-barbEnd)");break;case"arrow_circle":y.attr("marker-end","url("+m+"#"+i+"-circleEnd)");break;case"aggregation":y.attr("marker-end","url("+m+"#"+i+"-aggregationEnd)");break;case"extension":y.attr("marker-end","url("+m+"#"+i+"-extensionEnd)");break;case"composition":y.attr("marker-end","url("+m+"#"+i+"-compositionEnd)");break;case"dependency":y.attr("marker-end","url("+m+"#"+i+"-dependencyEnd)");break;case"lollipop":y.attr("marker-end","url("+m+"#"+i+"-lollipopEnd)");}var b={};return c&&(b.updatedPath=s),b.originalPath=n.points,b}(u,t,e,Ir,r,n);di(e,i);})),n.nodes().forEach((function(t){var e=n.node(t);o.info(t,e.type,e.diff),"group"===e.type&&(d=e.diff);})),{elem:s,diff:d}},yi=function(t,e,n,r,i){Mr(t,n,r,i),ai={},li={},ui={},ci={},Fr={},Rr={},Ir={},o.warn("Graph at first:",yr().json.write(e)),$r(e),o.warn("Graph after:",yr().json.write(e)),gi(t,e,r);},mi={dividerMargin:10,padding:5,textHeight:10};function bi(t){var e;switch(t){case 0:e="aggregation";break;case 1:e="extension";break;case 2:e="composition";break;case 3:e="dependency";break;case 4:e="lollipop";break;default:e="none";}return e}const vi={setConf:function(t){Object.keys(t).forEach((function(e){mi[e]=t[e];}));},draw:function(t,e,n,r){o.info("Drawing class - ",e);var i=Xt().flowchart,a=Xt().securityLevel;o.info("config:",i);var s,c=i.nodeSpacing||50,u=i.rankSpacing||50,h=new(yr().Graph)({multigraph:!0,compound:!0}).setGraph({rankdir:r.db.getDirection(),nodesep:c,ranksep:u,marginx:8,marginy:8}).setDefaultEdgeLabel((function(){return {}})),f=r.db.getClasses(),d=r.db.getRelations();o.info(d),function(t,e,n,r){var i=Object.keys(t);o.info("keys:",i),o.info(t),i.forEach((function(n){var i=t[n],a="";i.cssClasses.length>0&&(a=a+" "+i.cssClasses.join(" "));var s,c,l={labelStyle:""},u=void 0!==i.text?i.text:i.id;i.type,c="class_box",e.setNode(i.id,{labelStyle:l.labelStyle,shape:c,labelText:(s=u,ue.sanitizeText(s,Xt())),classData:i,rx:0,ry:0,class:a,style:l.style,id:i.id,domId:i.domId,tooltip:r.db.getTooltip(i.id)||"",haveCallback:i.haveCallback,link:i.link,width:"group"===i.type?500:void 0,type:i.type,padding:Xt().flowchart.padding}),o.info("setNode",{labelStyle:l.labelStyle,shape:c,labelText:u,rx:0,ry:0,class:a,style:l.style,id:i.id,width:"group"===i.type?500:void 0,type:i.type,padding:Xt().flowchart.padding});}));}(f,h,0,r),function(t,e){var n=Xt().flowchart,r=0;t.forEach((function(i){r++;var a={classes:"relation"};a.pattern=1==i.relation.lineType?"dashed":"solid",a.id="id"+r,"arrow_open"===i.type?a.arrowhead="none":a.arrowhead="normal",o.info(a,i),a.startLabelRight="none"===i.relationTitle1?"":i.relationTitle1,a.endLabelLeft="none"===i.relationTitle2?"":i.relationTitle2,a.arrowTypeStart=bi(i.relation.type1),a.arrowTypeEnd=bi(i.relation.type2);var s="",c="";if(void 0!==i.style){var u=dn(i.style);s=u.style,c=u.labelStyle;}else s="fill:none";a.style=s,a.labelStyle=c,void 0!==i.interpolate?a.curve=hn(i.interpolate,l.curveLinear):void 0!==t.defaultInterpolate?a.curve=hn(t.defaultInterpolate,l.curveLinear):a.curve=hn(n.curve,l.curveLinear),i.text=i.title,void 0===i.text?void 0!==i.style&&(a.arrowheadStyle="fill: #333"):(a.arrowheadStyle="fill: #333",a.labelpos="c",Xt().flowchart.htmlLabels?(a.labelType="html",a.label='<span class="edgeLabel">'+i.text+"</span>"):(a.labelType="text",a.label=i.text.replace(ue.lineBreakRegex,"\n"),void 0===i.style&&(a.style=a.style||"stroke: #333; stroke-width: 1.5px;fill:none"),a.labelStyle=a.labelStyle.replace("color:","fill:"))),e.setEdge(i.id1,i.id2,a,r);}));}(d,h),"sandbox"===a&&(s=(0, l.select)("#i"+e));var p="sandbox"===a?(0, l.select)(s.nodes()[0].contentDocument.body):(0, l.select)("body"),g=p.select('[id="'.concat(e,'"]')),y=p.select("#"+e+" g");if(yi(y,h,["aggregation","extension","composition","dependency","lollipop"],"classDiagram",e),En(h,g,i.diagramPadding,i.useMaxWidth),!i.htmlLabels)for(var m="sandbox"===a?s.nodes()[0].contentDocument:document,b=m.querySelectorAll('[id="'+e+'"] .edgeLabel .label'),v=0;v<b.length;v++){var _=b[v],x=_.getBBox(),k=m.createElementNS("http://www.w3.org/2000/svg","rect");k.setAttribute("rx",0),k.setAttribute("ry",0),k.setAttribute("width",x.width),k.setAttribute("height",x.height),_.insertBefore(k,_.firstChild);}Mn(r.db,g,e);}};var _i=n(1362),xi=n.n(_i),ki={},wi=[],Ti=function(t){return void 0===ki[t]&&(ki[t]={attributes:[]},o.info("Added new entity :",t)),ki[t]};const Ei={Cardinality:{ZERO_OR_ONE:"ZERO_OR_ONE",ZERO_OR_MORE:"ZERO_OR_MORE",ONE_OR_MORE:"ONE_OR_MORE",ONLY_ONE:"ONLY_ONE"},Identification:{NON_IDENTIFYING:"NON_IDENTIFYING",IDENTIFYING:"IDENTIFYING"},parseDirective:function(t,e,n){cu.parseDirective(this,t,e,n);},getConfig:function(){return Xt().er},addEntity:Ti,addAttributes:function(t,e){var n,r=Ti(t);for(n=e.length-1;n>=0;n--)r.attributes.push(e[n]),o.debug("Added attribute ",e[n].attributeName);},getEntities:function(){return ki},addRelationship:function(t,e,n,r){var i={entityA:t,roleA:e,entityB:n,relSpec:r};wi.push(i),o.debug("Added new relationship :",i);},getRelationships:function(){return wi},clear:function(){ki={},wi=[],ge();},setAccTitle:ye,getAccTitle:me,setAccDescription:be,getAccDescription:ve};var Ci={ONLY_ONE_START:"ONLY_ONE_START",ONLY_ONE_END:"ONLY_ONE_END",ZERO_OR_ONE_START:"ZERO_OR_ONE_START",ZERO_OR_ONE_END:"ZERO_OR_ONE_END",ONE_OR_MORE_START:"ONE_OR_MORE_START",ONE_OR_MORE_END:"ONE_OR_MORE_END",ZERO_OR_MORE_START:"ZERO_OR_MORE_START",ZERO_OR_MORE_END:"ZERO_OR_MORE_END"};const Si=Ci;var Ai={},Mi=function(t){return (t.entityA+t.roleA+t.entityB).replace(/\s/g,"")},Ni=0;const Oi={setConf:function(t){for(var e=Object.keys(t),n=0;n<e.length;n++)Ai[e[n]]=t[e[n]];},draw:function(t,e,n,r){Ai=Xt().er,o.info("Drawing ER diagram");var i,a=Xt().securityLevel;"sandbox"===a&&(i=(0, l.select)("#i"+e));var s,c=("sandbox"===a?(0, l.select)(i.nodes()[0].contentDocument.body):(0, l.select)("body")).select("[id='".concat(e,"']"));(function(t,e){var n;t.append("defs").append("marker").attr("id",Ci.ONLY_ONE_START).attr("refX",0).attr("refY",9).attr("markerWidth",18).attr("markerHeight",18).attr("orient","auto").append("path").attr("stroke",e.stroke).attr("fill","none").attr("d","M9,0 L9,18 M15,0 L15,18"),t.append("defs").append("marker").attr("id",Ci.ONLY_ONE_END).attr("refX",18).attr("refY",9).attr("markerWidth",18).attr("markerHeight",18).attr("orient","auto").append("path").attr("stroke",e.stroke).attr("fill","none").attr("d","M3,0 L3,18 M9,0 L9,18"),(n=t.append("defs").append("marker").attr("id",Ci.ZERO_OR_ONE_START).attr("refX",0).attr("refY",9).attr("markerWidth",30).attr("markerHeight",18).attr("orient","auto")).append("circle").attr("stroke",e.stroke).attr("fill","white").attr("cx",21).attr("cy",9).attr("r",6),n.append("path").attr("stroke",e.stroke).attr("fill","none").attr("d","M9,0 L9,18"),(n=t.append("defs").append("marker").attr("id",Ci.ZERO_OR_ONE_END).attr("refX",30).attr("refY",9).attr("markerWidth",30).attr("markerHeight",18).attr("orient","auto")).append("circle").attr("stroke",e.stroke).attr("fill","white").attr("cx",9).attr("cy",9).attr("r",6),n.append("path").attr("stroke",e.stroke).attr("fill","none").attr("d","M21,0 L21,18"),t.append("defs").append("marker").attr("id",Ci.ONE_OR_MORE_START).attr("refX",18).attr("refY",18).attr("markerWidth",45).attr("markerHeight",36).attr("orient","auto").append("path").attr("stroke",e.stroke).attr("fill","none").attr("d","M0,18 Q 18,0 36,18 Q 18,36 0,18 M42,9 L42,27"),t.append("defs").append("marker").attr("id",Ci.ONE_OR_MORE_END).attr("refX",27).attr("refY",18).attr("markerWidth",45).attr("markerHeight",36).attr("orient","auto").append("path").attr("stroke",e.stroke).attr("fill","none").attr("d","M3,9 L3,27 M9,18 Q27,0 45,18 Q27,36 9,18"),(n=t.append("defs").append("marker").attr("id",Ci.ZERO_OR_MORE_START).attr("refX",18).attr("refY",18).attr("markerWidth",57).attr("markerHeight",36).attr("orient","auto")).append("circle").attr("stroke",e.stroke).attr("fill","white").attr("cx",48).attr("cy",18).attr("r",6),n.append("path").attr("stroke",e.stroke).attr("fill","none").attr("d","M0,18 Q18,0 36,18 Q18,36 0,18"),(n=t.append("defs").append("marker").attr("id",Ci.ZERO_OR_MORE_END).attr("refX",39).attr("refY",18).attr("markerWidth",57).attr("markerHeight",36).attr("orient","auto")).append("circle").attr("stroke",e.stroke).attr("fill","white").attr("cx",9).attr("cy",18).attr("r",6),n.append("path").attr("stroke",e.stroke).attr("fill","none").attr("d","M21,18 Q39,0 57,18 Q39,36 21,18");})(c,Ai),s=new(yr().Graph)({multigraph:!0,directed:!0,compound:!1}).setGraph({rankdir:Ai.layoutDirection,marginx:20,marginy:20,nodesep:100,edgesep:100,ranksep:100}).setDefaultEdgeLabel((function(){return {}}));var u,h,f=function(t,e,n){var r;return Object.keys(e).forEach((function(i){var a=t.append("g").attr("id",i);r=void 0===r?i:r;var o="entity-"+i,s=a.append("text").attr("class","er entityLabel").attr("id",o).attr("x",0).attr("y",0).attr("dominant-baseline","middle").attr("text-anchor","middle").attr("style","font-family: "+Xt().fontFamily+"; font-size: "+Ai.fontSize+"px").text(i),c=function(t,e,n){var r=Ai.entityPadding/3,i=Ai.entityPadding/3,a=.85*Ai.fontSize,o=e.node().getBBox(),s=[],c=!1,l=!1,u=0,h=0,f=0,d=0,p=o.height+2*r,g=1;n.forEach((function(t){void 0!==t.attributeKeyType&&(c=!0),void 0!==t.attributeComment&&(l=!0);})),n.forEach((function(n){var i="".concat(e.node().id,"-attr-").concat(g),o=0,y=le(n.attributeType),m=t.append("text").attr("class","er entityLabel").attr("id","".concat(i,"-type")).attr("x",0).attr("y",0).attr("dominant-baseline","middle").attr("text-anchor","left").attr("style","font-family: "+Xt().fontFamily+"; font-size: "+a+"px").text(y),b=t.append("text").attr("class","er entityLabel").attr("id","".concat(i,"-name")).attr("x",0).attr("y",0).attr("dominant-baseline","middle").attr("text-anchor","left").attr("style","font-family: "+Xt().fontFamily+"; font-size: "+a+"px").text(n.attributeName),v={};v.tn=m,v.nn=b;var _=m.node().getBBox(),x=b.node().getBBox();if(u=Math.max(u,_.width),h=Math.max(h,x.width),o=Math.max(_.height,x.height),c){var k=t.append("text").attr("class","er entityLabel").attr("id","".concat(i,"-key")).attr("x",0).attr("y",0).attr("dominant-baseline","middle").attr("text-anchor","left").attr("style","font-family: "+Xt().fontFamily+"; font-size: "+a+"px").text(n.attributeKeyType||"");v.kn=k;var w=k.node().getBBox();f=Math.max(f,w.width),o=Math.max(o,w.height);}if(l){var T=t.append("text").attr("class","er entityLabel").attr("id","".concat(i,"-comment")).attr("x",0).attr("y",0).attr("dominant-baseline","middle").attr("text-anchor","left").attr("style","font-family: "+Xt().fontFamily+"; font-size: "+a+"px").text(n.attributeComment||"");v.cn=T;var E=T.node().getBBox();d=Math.max(d,E.width),o=Math.max(o,E.height);}v.height=o,s.push(v),p+=o+2*r,g+=1;}));var y=4;c&&(y+=2),l&&(y+=2);var m=u+h+f+d,b={width:Math.max(Ai.minEntityWidth,Math.max(o.width+2*Ai.entityPadding,m+i*y)),height:n.length>0?p:Math.max(Ai.minEntityHeight,o.height+2*Ai.entityPadding)};if(n.length>0){var v=Math.max(0,(b.width-m-i*y)/(y/2));e.attr("transform","translate("+b.width/2+","+(r+o.height/2)+")");var _=o.height+2*r,x="attributeBoxOdd";s.forEach((function(e){var n=_+r+e.height/2;e.tn.attr("transform","translate("+i+","+n+")");var a=t.insert("rect","#"+e.tn.node().id).attr("class","er ".concat(x)).attr("fill",Ai.fill).attr("fill-opacity","100%").attr("stroke",Ai.stroke).attr("x",0).attr("y",_).attr("width",u+2*i+v).attr("height",e.height+2*r),o=parseFloat(a.attr("x"))+parseFloat(a.attr("width"));e.nn.attr("transform","translate("+(o+i)+","+n+")");var s=t.insert("rect","#"+e.nn.node().id).attr("class","er ".concat(x)).attr("fill",Ai.fill).attr("fill-opacity","100%").attr("stroke",Ai.stroke).attr("x",o).attr("y",_).attr("width",h+2*i+v).attr("height",e.height+2*r),p=parseFloat(s.attr("x"))+parseFloat(s.attr("width"));if(c){e.kn.attr("transform","translate("+(p+i)+","+n+")");var g=t.insert("rect","#"+e.kn.node().id).attr("class","er ".concat(x)).attr("fill",Ai.fill).attr("fill-opacity","100%").attr("stroke",Ai.stroke).attr("x",p).attr("y",_).attr("width",f+2*i+v).attr("height",e.height+2*r);p=parseFloat(g.attr("x"))+parseFloat(g.attr("width"));}l&&(e.cn.attr("transform","translate("+(p+i)+","+n+")"),t.insert("rect","#"+e.cn.node().id).attr("class","er ".concat(x)).attr("fill",Ai.fill).attr("fill-opacity","100%").attr("stroke",Ai.stroke).attr("x",p).attr("y",_).attr("width",d+2*i+v).attr("height",e.height+2*r)),_+=e.height+2*r,x="attributeBoxOdd"==x?"attributeBoxEven":"attributeBoxOdd";}));}else b.height=Math.max(Ai.minEntityHeight,p),e.attr("transform","translate("+b.width/2+","+b.height/2+")");return b}(a,s,e[i].attributes),l=c.width,u=c.height,h=a.insert("rect","#"+o).attr("class","er entityBox").attr("fill",Ai.fill).attr("fill-opacity","100%").attr("stroke",Ai.stroke).attr("x",0).attr("y",0).attr("width",l).attr("height",u).node().getBBox();n.setNode(i,{width:h.width,height:h.height,shape:"rect",id:i});})),r}(c,r.db.getEntities(),s),d=function(t,e){return t.forEach((function(t){e.setEdge(t.entityA,t.entityB,{relationship:t},Mi(t));})),t}(r.db.getRelationships(),s);pr().layout(s),u=c,(h=s).nodes().forEach((function(t){void 0!==t&&void 0!==h.node(t)&&u.select("#"+t).attr("transform","translate("+(h.node(t).x-h.node(t).width/2)+","+(h.node(t).y-h.node(t).height/2)+" )");})),d.forEach((function(t){!function(t,e,n,r,i){Ni++;var a=n.edge(e.entityA,e.entityB,Mi(e)),o=(0, l.line)().x((function(t){return t.x})).y((function(t){return t.y})).curve(l.curveBasis),s=t.insert("path","#"+r).attr("class","er relationshipLine").attr("d",o(a.points)).attr("stroke",Ai.stroke).attr("fill","none");e.relSpec.relType===i.db.Identification.NON_IDENTIFYING&&s.attr("stroke-dasharray","8,8");var c="";switch(Ai.arrowMarkerAbsolute&&(c=(c=(c=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search).replace(/\(/g,"\\(")).replace(/\)/g,"\\)")),e.relSpec.cardA){case i.db.Cardinality.ZERO_OR_ONE:s.attr("marker-end","url("+c+"#"+Si.ZERO_OR_ONE_END+")");break;case i.db.Cardinality.ZERO_OR_MORE:s.attr("marker-end","url("+c+"#"+Si.ZERO_OR_MORE_END+")");break;case i.db.Cardinality.ONE_OR_MORE:s.attr("marker-end","url("+c+"#"+Si.ONE_OR_MORE_END+")");break;case i.db.Cardinality.ONLY_ONE:s.attr("marker-end","url("+c+"#"+Si.ONLY_ONE_END+")");}switch(e.relSpec.cardB){case i.db.Cardinality.ZERO_OR_ONE:s.attr("marker-start","url("+c+"#"+Si.ZERO_OR_ONE_START+")");break;case i.db.Cardinality.ZERO_OR_MORE:s.attr("marker-start","url("+c+"#"+Si.ZERO_OR_MORE_START+")");break;case i.db.Cardinality.ONE_OR_MORE:s.attr("marker-start","url("+c+"#"+Si.ONE_OR_MORE_START+")");break;case i.db.Cardinality.ONLY_ONE:s.attr("marker-start","url("+c+"#"+Si.ONLY_ONE_START+")");}var u=s.node().getTotalLength(),h=s.node().getPointAtLength(.5*u),f="rel"+Ni,d=t.append("text").attr("class","er relationshipLabel").attr("id",f).attr("x",h.x).attr("y",h.y).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("style","font-family: "+Xt().fontFamily+"; font-size: "+Ai.fontSize+"px").text(e.roleA).node().getBBox();t.insert("rect","#"+f).attr("class","er relationshipLabelBox").attr("x",h.x-d.width/2).attr("y",h.y-d.height/2).attr("width",d.width).attr("height",d.height).attr("fill","white").attr("fill-opacity","85%");}(c,t,s,f,r);}));var p=Ai.diagramPadding,g=c.node().getBBox(),y=g.width+2*p,m=g.height+2*p;Tn(c,0,y,Ai.useMaxWidth),c.attr("viewBox","".concat(g.x-p," ").concat(g.y-p," ").concat(y," ").concat(m)),Mn(r.db,c,e);}};var Di={};const Bi={setConf:function(t){Object.keys(t).forEach((function(e){Di[e]=t[e];}));},draw:function(t,e,n){try{o.debug("Renering svg for syntax error\n");var r=(0,l.select)("#"+e),i=r.append("g");i.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),i.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),i.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),i.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),i.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),i.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),i.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in graph"),i.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text("mermaid version "+n),r.attr("height",100),r.attr("width",500),r.attr("viewBox","768 0 912 512");}catch(t){o.error("Error while rendering info diagram"),o.error(t.message);}}};var Li=n(5890),Ii=n.n(Li);function Fi(t){return Fi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fi(t)}function Ri(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var Pi,ji,zi="flowchart-",Yi=0,Ui=Xt(),$i={},Wi=[],qi=[],Hi=[],Vi={},Gi={},Xi=0,Zi=!0,Qi=[],Ki=function(t){return ue.sanitizeText(t,Ui)},Ji=function(t){for(var e=Object.keys($i),n=0;n<e.length;n++)if($i[e[n]].id===t)return $i[e[n]].domId;return t},ta=function(t,e,n,r){var i={start:t,end:e,type:void 0,text:""};void 0!==(r=n.text)&&(i.text=Ki(r.trim()),'"'===i.text[0]&&'"'===i.text[i.text.length-1]&&(i.text=i.text.substring(1,i.text.length-1))),void 0!==n&&(i.type=n.type,i.stroke=n.stroke,i.length=n.length),Wi.push(i);},ea=function(t,e){t.split(",").forEach((function(t){var n=t;void 0!==$i[n]&&$i[n].classes.push(e),void 0!==Vi[n]&&Vi[n].classes.push(e);}));},na=function(t){var e=(0, l.select)(".mermaidTooltip");null===(e._groups||e)[0][0]&&(e=(0, l.select)("body").append("div").attr("class","mermaidTooltip").style("opacity",0)),(0, l.select)(t).select("svg").selectAll("g.node").on("mouseover",(function(){var t=(0, l.select)(this);if(null!==t.attr("title")){var n=this.getBoundingClientRect();e.transition().duration(200).style("opacity",".9"),e.text(t.attr("title")).style("left",window.scrollX+n.left+(n.right-n.left)/2+"px").style("top",window.scrollY+n.top-14+document.body.scrollTop+"px"),e.html(e.html().replace(/&lt;br\/&gt;/g,"<br/>")),t.classed("hover",!0);}})).on("mouseout",(function(){e.transition().duration(500).style("opacity",0),(0, l.select)(this).classed("hover",!1);}));};Qi.push(na);var ra=function(t){for(var e=0;e<Hi.length;e++)if(Hi[e].id===t)return e;return -1},ia=-1,aa=[],oa=function t(e,n){var r=Hi[n].nodes;if(!((ia+=1)>2e3)){if(aa[ia]=n,Hi[n].id===e)return {result:!0,count:0};for(var i=0,a=1;i<r.length;){var o=ra(r[i]);if(o>=0){var s=t(e,o);if(s.result)return {result:!0,count:a+s.count};a+=s.count;}i+=1;}return {result:!1,count:a}}},sa=function(t,e){var n=!1;return t.forEach((function(t){t.nodes.indexOf(e)>=0&&(n=!0);})),n},ca=function(t,e){var n=[];return t.nodes.forEach((function(r,i){sa(e,r)||n.push(t.nodes[i]);})),{nodes:n}};const la={parseDirective:function(t,e,n){cu.parseDirective(this,t,e,n);},defaultConfig:function(){return $t.flowchart},setAccTitle:ye,getAccTitle:me,getAccDescription:ve,setAccDescription:be,addVertex:function(t,e,n,r,i,a){var o,s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},c=t;void 0!==c&&0!==c.trim().length&&(void 0===$i[c]&&($i[c]={id:c,domId:zi+c+"-"+Yi,styles:[],classes:[]}),Yi++,void 0!==e?(Ui=Xt(),'"'===(o=Ki(e.trim()))[0]&&'"'===o[o.length-1]&&(o=o.substring(1,o.length-1)),$i[c].text=o):void 0===$i[c].text&&($i[c].text=t),void 0!==n&&($i[c].type=n),null!=r&&r.forEach((function(t){$i[c].styles.push(t);})),null!=i&&i.forEach((function(t){$i[c].classes.push(t);})),void 0!==a&&($i[c].dir=a),$i[c].props=s);},lookUpDomId:Ji,addLink:function(t,e,n,r){var i,a;for(i=0;i<t.length;i++)for(a=0;a<e.length;a++)ta(t[i],e[a],n,r);},updateLinkInterpolate:function(t,e){t.forEach((function(t){"default"===t?Wi.defaultInterpolate=e:Wi[t].interpolate=e;}));},updateLink:function(t,e){t.forEach((function(t){"default"===t?Wi.defaultStyle=e:(-1===An.isSubstringInArray("fill",e)&&e.push("fill:none"),Wi[t].style=e);}));},addClass:function(t,e){void 0===qi[t]&&(qi[t]={id:t,styles:[],textStyles:[]}),null!=e&&e.forEach((function(e){if(e.match("color")){var n=e.replace("fill","bgFill").replace("color","fill");qi[t].textStyles.push(n);}qi[t].styles.push(e);}));},setDirection:function(t){(Pi=t).match(/.*</)&&(Pi="RL"),Pi.match(/.*\^/)&&(Pi="BT"),Pi.match(/.*>/)&&(Pi="LR"),Pi.match(/.*v/)&&(Pi="TB");},setClass:ea,setTooltip:function(t,e){t.split(",").forEach((function(t){void 0!==e&&(Gi["gen-1"===ji?Ji(t):t]=Ki(e));}));},getTooltip:function(t){return Gi[t]},setClickEvent:function(t,e,n){t.split(",").forEach((function(t){!function(t,e,n){var r=Ji(t);if("loose"===Xt().securityLevel&&void 0!==e){var i=[];if("string"==typeof n){i=n.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/);for(var a=0;a<i.length;a++){var o=i[a].trim();'"'===o.charAt(0)&&'"'===o.charAt(o.length-1)&&(o=o.substr(1,o.length-2)),i[a]=o;}}0===i.length&&i.push(t),void 0!==$i[t]&&($i[t].haveCallback=!0,Qi.push((function(){var t=document.querySelector('[id="'.concat(r,'"]'));null!==t&&t.addEventListener("click",(function(){var t;An.runFunc.apply(An,[e].concat(function(t){if(Array.isArray(t))return Ri(t)}(t=i)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ri(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return "Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ri(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()));}),!1);})));}}(t,e,n);})),ea(t,"clickable");},setLink:function(t,e,n){t.split(",").forEach((function(t){void 0!==$i[t]&&($i[t].link=An.formatUrl(e,Ui),$i[t].linkTarget=n);})),ea(t,"clickable");},bindFunctions:function(t){Qi.forEach((function(e){e(t);}));},getDirection:function(){return Pi.trim()},getVertices:function(){return $i},getEdges:function(){return Wi},getClasses:function(){return qi},clear:function(t){$i={},qi={},Wi=[],(Qi=[]).push(na),Hi=[],Vi={},Xi=0,Gi=[],Zi=!0,ji=t||"gen-1",ge();},setGen:function(t){ji=t||"gen-1";},defaultStyle:function(){return "fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;"},addSubGraph:function(t,e,n){var r=t.trim(),i=n;t===n&&n.match(/\s/)&&(r=void 0);var a=[],s=function(t){var e,n={boolean:{},number:{},string:{}},r=[],i=t.filter((function(t){var i=Fi(t);return t.stmt&&"dir"===t.stmt?(e=t.value,!1):""!==t.trim()&&(i in n?!n[i].hasOwnProperty(t)&&(n[i][t]=!0):!(r.indexOf(t)>=0)&&r.push(t))}));return {nodeList:i,dir:e}}(a.concat.apply(a,e)),c=s.nodeList,l=s.dir;if(a=c,"gen-1"===ji)for(var u=0;u<a.length;u++)a[u]=Ji(a[u]);r=r||"subGraph"+Xi,i=Ki(i=i||""),Xi+=1;var h={id:r,nodes:a,title:i.trim(),classes:[],dir:l};return o.info("Adding",h.id,h.nodes,h.dir),h.nodes=ca(h,Hi).nodes,Hi.push(h),Vi[r]=h,r},getDepthFirstPos:function(t){return aa[t]},indexNodes:function(){ia=-1,Hi.length>0&&oa("none",Hi.length-1);},getSubGraphs:function(){return Hi},destructLink:function(t,e){var n,r=function(t){var e=t.trim(),n=e.slice(0,-1),r="arrow_open";switch(e.slice(-1)){case"x":r="arrow_cross","x"===e[0]&&(r="double_"+r,n=n.slice(1));break;case">":r="arrow_point","<"===e[0]&&(r="double_"+r,n=n.slice(1));break;case"o":r="arrow_circle","o"===e[0]&&(r="double_"+r,n=n.slice(1));}var i="normal",a=n.length-1;"="===n[0]&&(i="thick");var o=function(t,e){for(var n=e.length,r=0,i=0;i<n;++i)"."===e[i]&&++r;return r}(0,n);return o&&(i="dotted",a=o),{type:r,stroke:i,length:a}}(t);if(e){if(n=function(t){var e=t.trim(),n="arrow_open";switch(e[0]){case"<":n="arrow_point",e=e.slice(1);break;case"x":n="arrow_cross",e=e.slice(1);break;case"o":n="arrow_circle",e=e.slice(1);}var r="normal";return -1!==e.indexOf("=")&&(r="thick"),-1!==e.indexOf(".")&&(r="dotted"),{type:n,stroke:r}}(e),n.stroke!==r.stroke)return {type:"INVALID",stroke:"INVALID"};if("arrow_open"===n.type)n.type=r.type;else {if(n.type!==r.type)return {type:"INVALID",stroke:"INVALID"};n.type="double_"+n.type;}return "double_arrow"===n.type&&(n.type="double_arrow_point"),n.length=r.length,n}return r},lex:{firstGraph:function(){return !!Zi&&(Zi=!1,!0)}},exists:sa,makeUniq:ca};var ua=n(4949),ha=n.n(ua),fa=n(8284),da=n.n(fa);function pa(t,e,n){var r=.9*(e.width+e.height),i=[{x:r/2,y:0},{x:r,y:-r/2},{x:r/2,y:-r},{x:0,y:-r/2}],a=Ea(t,r,r,i);return n.intersect=function(t){return ha().intersect.polygon(n,i,t)},a}function ga(t,e,n){var r=e.height,i=r/4,a=e.width+2*i,o=[{x:i,y:0},{x:a-i,y:0},{x:a,y:-r/2},{x:a-i,y:-r},{x:i,y:-r},{x:0,y:-r/2}],s=Ea(t,a,r,o);return n.intersect=function(t){return ha().intersect.polygon(n,o,t)},s}function ya(t,e,n){var r=e.width,i=e.height,a=[{x:-i/2,y:0},{x:r,y:0},{x:r,y:-i},{x:-i/2,y:-i},{x:0,y:-i/2}],o=Ea(t,r,i,a);return n.intersect=function(t){return ha().intersect.polygon(n,a,t)},o}function ma(t,e,n){var r=e.width,i=e.height,a=[{x:-2*i/6,y:0},{x:r-i/6,y:0},{x:r+2*i/6,y:-i},{x:i/6,y:-i}],o=Ea(t,r,i,a);return n.intersect=function(t){return ha().intersect.polygon(n,a,t)},o}function ba(t,e,n){var r=e.width,i=e.height,a=[{x:2*i/6,y:0},{x:r+i/6,y:0},{x:r-2*i/6,y:-i},{x:-i/6,y:-i}],o=Ea(t,r,i,a);return n.intersect=function(t){return ha().intersect.polygon(n,a,t)},o}function va(t,e,n){var r=e.width,i=e.height,a=[{x:-2*i/6,y:0},{x:r+2*i/6,y:0},{x:r-i/6,y:-i},{x:i/6,y:-i}],o=Ea(t,r,i,a);return n.intersect=function(t){return ha().intersect.polygon(n,a,t)},o}function _a(t,e,n){var r=e.width,i=e.height,a=[{x:i/6,y:0},{x:r-i/6,y:0},{x:r+2*i/6,y:-i},{x:-2*i/6,y:-i}],o=Ea(t,r,i,a);return n.intersect=function(t){return ha().intersect.polygon(n,a,t)},o}function xa(t,e,n){var r=e.width,i=e.height,a=[{x:0,y:0},{x:r+i/2,y:0},{x:r,y:-i/2},{x:r+i/2,y:-i},{x:0,y:-i}],o=Ea(t,r,i,a);return n.intersect=function(t){return ha().intersect.polygon(n,a,t)},o}function ka(t,e,n){var r=e.height,i=e.width+r/4,a=t.insert("rect",":first-child").attr("rx",r/2).attr("ry",r/2).attr("x",-i/2).attr("y",-r/2).attr("width",i).attr("height",r);return n.intersect=function(t){return ha().intersect.rect(n,t)},a}function wa(t,e,n){var r=e.width,i=e.height,a=[{x:0,y:0},{x:r,y:0},{x:r,y:-i},{x:0,y:-i},{x:0,y:0},{x:-8,y:0},{x:r+8,y:0},{x:r+8,y:-i},{x:-8,y:-i},{x:-8,y:0}],o=Ea(t,r,i,a);return n.intersect=function(t){return ha().intersect.polygon(n,a,t)},o}function Ta(t,e,n){var r=e.width,i=r/2,a=i/(2.5+r/50),o=e.height+a,s="M 0,"+a+" a "+i+","+a+" 0,0,0 "+r+" 0 a "+i+","+a+" 0,0,0 "+-r+" 0 l 0,"+o+" a "+i+","+a+" 0,0,0 "+r+" 0 l 0,"+-o,c=t.attr("label-offset-y",a).insert("path",":first-child").attr("d",s).attr("transform","translate("+-r/2+","+-(o/2+a)+")");return n.intersect=function(t){var e=ha().intersect.rect(n,t),r=e.x-n.x;if(0!=i&&(Math.abs(r)<n.width/2||Math.abs(r)==n.width/2&&Math.abs(e.y-n.y)>n.height/2-a)){var o=a*a*(1-r*r/(i*i));0!=o&&(o=Math.sqrt(o)),o=a-o,t.y-n.y>0&&(o=-o),e.y+=o;}return e},c}function Ea(t,e,n,r){return t.insert("polygon",":first-child").attr("points",r.map((function(t){return t.x+","+t.y})).join(" ")).attr("transform","translate("+-e/2+","+n/2+")")}const Ca=function(t){t.shapes().question=pa,t.shapes().hexagon=ga,t.shapes().stadium=ka,t.shapes().subroutine=wa,t.shapes().cylinder=Ta,t.shapes().rect_left_inv_arrow=ya,t.shapes().lean_right=ma,t.shapes().lean_left=ba,t.shapes().trapezoid=va,t.shapes().inv_trapezoid=_a,t.shapes().rect_right_inv_arrow=xa;};var Sa={},Aa=function(t,e,n,r,i,a){Xt().securityLevel;var s=r?r.select('[id="'.concat(n,'"]')):(0, l.select)('[id="'.concat(n,'"]')),c=i||document;Object.keys(t).forEach((function(n){var r=t[n],i="default";r.classes.length>0&&(i=r.classes.join(" "));var l,u=dn(r.styles),h=void 0!==r.text?r.text:r.id;if(ce(Xt().flowchart.htmlLabels)){var f={label:h.replace(/fa[lrsb]?:fa-[\w-]+/g,(function(t){return "<i class='".concat(t.replace(":"," "),"'></i>")}))};(l=da()(s,f).node()).parentNode.removeChild(l);}else {var d=c.createElementNS("http://www.w3.org/2000/svg","text");d.setAttribute("style",u.labelStyle.replace("color:","fill:"));for(var p=h.split(ue.lineBreakRegex),g=0;g<p.length;g++){var y=c.createElementNS("http://www.w3.org/2000/svg","tspan");y.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),y.setAttribute("dy","1em"),y.setAttribute("x","1"),y.textContent=p[g],d.appendChild(y);}l=d;}var m=0,b="";switch(r.type){case"round":m=5,b="rect";break;case"square":case"group":default:b="rect";break;case"diamond":b="question";break;case"hexagon":b="hexagon";break;case"odd":case"odd_right":b="rect_left_inv_arrow";break;case"lean_right":b="lean_right";break;case"lean_left":b="lean_left";break;case"trapezoid":b="trapezoid";break;case"inv_trapezoid":b="inv_trapezoid";break;case"circle":b="circle";break;case"ellipse":b="ellipse";break;case"stadium":b="stadium";break;case"subroutine":b="subroutine";break;case"cylinder":b="cylinder";}o.warn("Adding node",r.id,r.domId),e.setNode(a.db.lookUpDomId(r.id),{labelType:"svg",labelStyle:u.labelStyle,shape:b,label:l,rx:m,ry:m,class:i,style:u.style,id:a.db.lookUpDomId(r.id)});}));},Ma=function(t,e,n){var r,i,a=0;if(void 0!==t.defaultStyle){var o=dn(t.defaultStyle);r=o.style,i=o.labelStyle;}t.forEach((function(o){a++;var s="L-"+o.start+"-"+o.end,c="LS-"+o.start,u="LE-"+o.end,h={};"arrow_open"===o.type?h.arrowhead="none":h.arrowhead="normal";var f="",d="";if(void 0!==o.style){var p=dn(o.style);f=p.style,d=p.labelStyle;}else switch(o.stroke){case"normal":f="fill:none",void 0!==r&&(f=r),void 0!==i&&(d=i);break;case"dotted":f="fill:none;stroke-width:2px;stroke-dasharray:3;";break;case"thick":f=" stroke-width: 3.5px;fill:none";}h.style=f,h.labelStyle=d,void 0!==o.interpolate?h.curve=hn(o.interpolate,l.curveLinear):void 0!==t.defaultInterpolate?h.curve=hn(t.defaultInterpolate,l.curveLinear):h.curve=hn(Sa.curve,l.curveLinear),void 0===o.text?void 0!==o.style&&(h.arrowheadStyle="fill: #333"):(h.arrowheadStyle="fill: #333",h.labelpos="c",ce(Xt().flowchart.htmlLabels)?(h.labelType="html",h.label='<span id="L-'.concat(s,'" class="edgeLabel L-').concat(c,"' L-").concat(u,'" style="').concat(h.labelStyle,'">').concat(o.text.replace(/fa[lrsb]?:fa-[\w-]+/g,(function(t){return "<i class='".concat(t.replace(":"," "),"'></i>")})),"</span>")):(h.labelType="text",h.label=o.text.replace(ue.lineBreakRegex,"\n"),void 0===o.style&&(h.style=h.style||"stroke: #333; stroke-width: 1.5px;fill:none"),h.labelStyle=h.labelStyle.replace("color:","fill:"))),h.id=s,h.class=c+" "+u,h.minlen=o.length||1,e.setEdge(n.db.lookUpDomId(o.start),n.db.lookUpDomId(o.end),h,a);}));};const Na={setConf:function(t){for(var e=Object.keys(t),n=0;n<e.length;n++)Sa[e[n]]=t[e[n]];},addVertices:Aa,addEdges:Ma,getClasses:function(t,e){o.info("Extracting classes"),e.db.clear();try{return e.parse(t),e.db.getClasses()}catch(t){return}},draw:function(t,e,n,r){o.info("Drawing flowchart"),r.db.clear();var i,a=Xt().securityLevel;"sandbox"===a&&(i=(0, l.select)("#i"+e));var s="sandbox"===a?(0, l.select)(i.nodes()[0].contentDocument.body):(0, l.select)("body"),c="sandbox"===a?i.nodes()[0].contentDocument:document;try{r.parser.parse(t);}catch(t){o.debug("Parsing failed");}var u=r.db.getDirection();void 0===u&&(u="TD");for(var h,f=Xt().flowchart,d=f.nodeSpacing||50,p=f.rankSpacing||50,g=new(yr().Graph)({multigraph:!0,compound:!0}).setGraph({rankdir:u,nodesep:d,ranksep:p,marginx:8,marginy:8}).setDefaultEdgeLabel((function(){return {}})),y=r.db.getSubGraphs(),m=y.length-1;m>=0;m--)h=y[m],r.db.addVertex(h.id,h.title,"group",void 0,h.classes);var b=r.db.getVertices();o.warn("Get vertices",b);var v=r.db.getEdges(),_=0;for(_=y.length-1;_>=0;_--){h=y[_],(0, l.selectAll)("cluster").append("text");for(var x=0;x<h.nodes.length;x++)o.warn("Setting subgraph",h.nodes[x],r.db.lookUpDomId(h.nodes[x]),r.db.lookUpDomId(h.id)),g.setParent(r.db.lookUpDomId(h.nodes[x]),r.db.lookUpDomId(h.id));}Aa(b,g,e,s,c,r),Ma(v,g,r);var k=new(ha().render);Ca(k),k.arrows().none=function(t,e,n,r){var i=t.append("marker").attr("id",e).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerUnits","strokeWidth").attr("markerWidth",8).attr("markerHeight",6).attr("orient","auto").append("path").attr("d","M 0 0 L 0 0 L 0 0 z");ha().util.applyStyle(i,n[r+"Style"]);},k.arrows().normal=function(t,e){t.append("marker").attr("id",e).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerUnits","strokeWidth").attr("markerWidth",8).attr("markerHeight",6).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("class","arrowheadPath").style("stroke-width",1).style("stroke-dasharray","1,0");};var w=s.select('[id="'.concat(e,'"]'));Mn(r.db,w,e);var T=s.select("#"+e+" g");for(k(T,g),T.selectAll("g.node").attr("title",(function(){return r.db.getTooltip(this.id)})),r.db.indexNodes("subGraph"+_),_=0;_<y.length;_++)if("undefined"!==(h=y[_]).title){var E=c.querySelectorAll("#"+e+' [id="'+r.db.lookUpDomId(h.id)+'"] rect'),C=c.querySelectorAll("#"+e+' [id="'+r.db.lookUpDomId(h.id)+'"]'),S=E[0].x.baseVal.value,A=E[0].y.baseVal.value,M=E[0].width.baseVal.value,N=(0, l.select)(C[0]).select(".label");N.attr("transform","translate(".concat(S+M/2,", ").concat(A+14,")")),N.attr("id",e+"Text");for(var O=0;O<h.classes.length;O++)C[0].classList.add(h.classes[O]);}ce(f.htmlLabels);for(var D=c.querySelectorAll('[id="'+e+'"] .edgeLabel .label'),B=0;B<D.length;B++){var L=D[B],I=L.getBBox(),F=c.createElementNS("http://www.w3.org/2000/svg","rect");F.setAttribute("rx",0),F.setAttribute("ry",0),F.setAttribute("width",I.width),F.setAttribute("height",I.height),L.insertBefore(F,L.firstChild);}En(g,w,f.diagramPadding,f.useMaxWidth),Object.keys(b).forEach((function(t){var n=b[t];if(n.link){var i=s.select("#"+e+' [id="'+r.db.lookUpDomId(t)+'"]');if(i){var o=c.createElementNS("http://www.w3.org/2000/svg","a");o.setAttributeNS("http://www.w3.org/2000/svg","class",n.classes.join(" ")),o.setAttributeNS("http://www.w3.org/2000/svg","href",n.link),o.setAttributeNS("http://www.w3.org/2000/svg","rel","noopener"),"sandbox"===a?o.setAttributeNS("http://www.w3.org/2000/svg","target","_top"):n.linkTarget&&o.setAttributeNS("http://www.w3.org/2000/svg","target",n.linkTarget);var l=i.insert((function(){return o}),":first-child"),u=i.select(".label-container");u&&l.append((function(){return u.node()}));var h=i.select(".label");h&&l.append((function(){return h.node()}));}}}));}};var Oa={},Da=function(t,e,n,r,i,a){var s=r.select('[id="'.concat(n,'"]'));Object.keys(t).forEach((function(n){var r=t[n],c="default";r.classes.length>0&&(c=r.classes.join(" "));var l,u=dn(r.styles),h=void 0!==r.text?r.text:r.id;if(ce(Xt().flowchart.htmlLabels)){var f={label:h.replace(/fa[lrsb]?:fa-[\w-]+/g,(function(t){return "<i class='".concat(t.replace(":"," "),"'></i>")}))};(l=da()(s,f).node()).parentNode.removeChild(l);}else {var d=i.createElementNS("http://www.w3.org/2000/svg","text");d.setAttribute("style",u.labelStyle.replace("color:","fill:"));for(var p=h.split(ue.lineBreakRegex),g=0;g<p.length;g++){var y=i.createElementNS("http://www.w3.org/2000/svg","tspan");y.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),y.setAttribute("dy","1em"),y.setAttribute("x","1"),y.textContent=p[g],d.appendChild(y);}l=d;}var m=0,b="";switch(r.type){case"round":m=5,b="rect";break;case"square":case"group":default:b="rect";break;case"diamond":b="question";break;case"hexagon":b="hexagon";break;case"odd":case"odd_right":b="rect_left_inv_arrow";break;case"lean_right":b="lean_right";break;case"lean_left":b="lean_left";break;case"trapezoid":b="trapezoid";break;case"inv_trapezoid":b="inv_trapezoid";break;case"circle":b="circle";break;case"ellipse":b="ellipse";break;case"stadium":b="stadium";break;case"subroutine":b="subroutine";break;case"cylinder":b="cylinder";break;case"doublecircle":b="doublecircle";}e.setNode(r.id,{labelStyle:u.labelStyle,shape:b,labelText:h,rx:m,ry:m,class:c,style:u.style,id:r.id,link:r.link,linkTarget:r.linkTarget,tooltip:a.db.getTooltip(r.id)||"",domId:a.db.lookUpDomId(r.id),haveCallback:r.haveCallback,width:"group"===r.type?500:void 0,dir:r.dir,type:r.type,props:r.props,padding:Xt().flowchart.padding}),o.info("setNode",{labelStyle:u.labelStyle,shape:b,labelText:h,rx:m,ry:m,class:c,style:u.style,id:r.id,domId:a.db.lookUpDomId(r.id),width:"group"===r.type?500:void 0,type:r.type,dir:r.dir,props:r.props,padding:Xt().flowchart.padding});}));},Ba=function(t,e,n){o.info("abc78 edges = ",t);var r,i,a=0,s={};if(void 0!==t.defaultStyle){var c=dn(t.defaultStyle);r=c.style,i=c.labelStyle;}t.forEach((function(n){a++;var c="L-"+n.start+"-"+n.end;void 0===s[c]?(s[c]=0,o.info("abc78 new entry",c,s[c])):(s[c]++,o.info("abc78 new entry",c,s[c]));var u=c+"-"+s[c];o.info("abc78 new link id to be used is",c,u,s[c]);var h="LS-"+n.start,f="LE-"+n.end,d={style:"",labelStyle:""};switch(d.minlen=n.length||1,"arrow_open"===n.type?d.arrowhead="none":d.arrowhead="normal",d.arrowTypeStart="arrow_open",d.arrowTypeEnd="arrow_open",n.type){case"double_arrow_cross":d.arrowTypeStart="arrow_cross";case"arrow_cross":d.arrowTypeEnd="arrow_cross";break;case"double_arrow_point":d.arrowTypeStart="arrow_point";case"arrow_point":d.arrowTypeEnd="arrow_point";break;case"double_arrow_circle":d.arrowTypeStart="arrow_circle";case"arrow_circle":d.arrowTypeEnd="arrow_circle";}var p="",g="";switch(n.stroke){case"normal":p="fill:none;",void 0!==r&&(p=r),void 0!==i&&(g=i),d.thickness="normal",d.pattern="solid";break;case"dotted":d.thickness="normal",d.pattern="dotted",d.style="fill:none;stroke-width:2px;stroke-dasharray:3;";break;case"thick":d.thickness="thick",d.pattern="solid",d.style="stroke-width: 3.5px;fill:none;";}if(void 0!==n.style){var y=dn(n.style);p=y.style,g=y.labelStyle;}d.style=d.style+=p,d.labelStyle=d.labelStyle+=g,void 0!==n.interpolate?d.curve=hn(n.interpolate,l.curveLinear):void 0!==t.defaultInterpolate?d.curve=hn(t.defaultInterpolate,l.curveLinear):d.curve=hn(Oa.curve,l.curveLinear),void 0===n.text?void 0!==n.style&&(d.arrowheadStyle="fill: #333"):(d.arrowheadStyle="fill: #333",d.labelpos="c"),d.labelType="text",d.label=n.text.replace(ue.lineBreakRegex,"\n"),void 0===n.style&&(d.style=d.style||"stroke: #333; stroke-width: 1.5px;fill:none;"),d.labelStyle=d.labelStyle.replace("color:","fill:"),d.id=u,d.classes="flowchart-link "+h+" "+f,e.setEdge(n.start,n.end,d,a);}));};const La={setConf:function(t){for(var e=Object.keys(t),n=0;n<e.length;n++)Oa[e[n]]=t[e[n]];},addVertices:Da,addEdges:Ba,getClasses:function(t,e){o.info("Extracting classes"),e.db.clear();try{return e.parse(t),e.db.getClasses()}catch(t){return}},draw:function(t,e,n,r){o.info("Drawing flowchart"),r.db.clear(),la.setGen("gen-2"),r.parser.parse(t);var i=r.db.getDirection();void 0===i&&(i="TD");var a,s=Xt().flowchart,c=s.nodeSpacing||50,u=s.rankSpacing||50,h=Xt().securityLevel;"sandbox"===h&&(a=(0, l.select)("#i"+e));var f,d="sandbox"===h?(0, l.select)(a.nodes()[0].contentDocument.body):(0, l.select)("body"),p="sandbox"===h?a.nodes()[0].contentDocument:document,g=new(yr().Graph)({multigraph:!0,compound:!0}).setGraph({rankdir:i,nodesep:c,ranksep:u,marginx:0,marginy:0}).setDefaultEdgeLabel((function(){return {}})),y=r.db.getSubGraphs();o.info("Subgraphs - ",y);for(var m=y.length-1;m>=0;m--)f=y[m],o.info("Subgraph - ",f),r.db.addVertex(f.id,f.title,"group",void 0,f.classes,f.dir);var b=r.db.getVertices(),v=r.db.getEdges();o.info(v);var _=0;for(_=y.length-1;_>=0;_--){f=y[_],(0, l.selectAll)("cluster").append("text");for(var x=0;x<f.nodes.length;x++)o.info("Setting up subgraphs",f.nodes[x],f.id),g.setParent(f.nodes[x],f.id);}Da(b,g,e,d,p,r),Ba(v,g);var k=d.select('[id="'.concat(e,'"]'));Mn(r.db,k,e);var w=d.select("#"+e+" g");if(yi(w,g,["point","circle","cross"],"flowchart",e),En(g,k,s.diagramPadding,s.useMaxWidth),r.db.indexNodes("subGraph"+_),!s.htmlLabels)for(var T=p.querySelectorAll('[id="'+e+'"] .edgeLabel .label'),E=0;E<T.length;E++){var C=T[E],S=C.getBBox(),A=p.createElementNS("http://www.w3.org/2000/svg","rect");A.setAttribute("rx",0),A.setAttribute("ry",0),A.setAttribute("width",S.width),A.setAttribute("height",S.height),C.insertBefore(A,C.firstChild);}Object.keys(b).forEach((function(t){var n=b[t];if(n.link){var r=(0, l.select)("#"+e+' [id="'+t+'"]');if(r){var i=p.createElementNS("http://www.w3.org/2000/svg","a");i.setAttributeNS("http://www.w3.org/2000/svg","class",n.classes.join(" ")),i.setAttributeNS("http://www.w3.org/2000/svg","href",n.link),i.setAttributeNS("http://www.w3.org/2000/svg","rel","noopener"),"sandbox"===h?i.setAttributeNS("http://www.w3.org/2000/svg","target","_top"):n.linkTarget&&i.setAttributeNS("http://www.w3.org/2000/svg","target",n.linkTarget);var a=r.insert((function(){return i}),":first-child"),o=r.select(".label-container");o&&a.append((function(){return o.node()}));var s=r.select(".label");s&&a.append((function(){return s.node()}));}}}));}};var Ia=n(3602),Fa=n.n(Ia);function Ra(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var Pa,ja,za="",Ya="",Ua="",$a=[],Wa=[],qa={},Ha=[],Va=[],Ga="",Xa=["active","done","crit","milestone"],Za=[],Qa=!1,Ka=!1,Ja=0,to=function(t,e,n,r){return !(r.indexOf(t.format(e.trim()))>=0)&&(t.isoWeekday()>=6&&n.indexOf("weekends")>=0||n.indexOf(t.format("dddd").toLowerCase())>=0||n.indexOf(t.format(e.trim()))>=0)},eo=function(t,e,n,r){if(n.length&&!t.manualEndTime){var a=i()(t.startTime,e,!0);a.add(1,"d");var o=i()(t.endTime,e,!0),s=no(a,o,e,n,r);t.endTime=o.toDate(),t.renderEndTime=s;}},no=function(t,e,n,r,i){for(var a=!1,o=null;t<=e;)a||(o=e.toDate()),(a=to(t,n,r,i))&&e.add(1,"d"),t.add(1,"d");return o},ro=function(t,e,n){n=n.trim();var r=/^after\s+([\d\w- ]+)/.exec(n.trim());if(null!==r){var a=null;if(r[1].split(" ").forEach((function(t){var e=uo(t);void 0!==e&&(a?e.endTime>a.endTime&&(a=e):a=e);})),a)return a.endTime;var s=new Date;return s.setHours(0,0,0,0),s}var c=i()(n,e.trim(),!0);return c.isValid()?c.toDate():(o.debug("Invalid date:"+n),o.debug("With date format:"+e.trim()),new Date)},io=function(t,e){if(null!==t)switch(t[2]){case"ms":e.add(t[1],"milliseconds");break;case"s":e.add(t[1],"seconds");break;case"m":e.add(t[1],"minutes");break;case"h":e.add(t[1],"hours");break;case"d":e.add(t[1],"days");break;case"w":e.add(t[1],"weeks");}return e.toDate()},ao=function(t,e,n,r){r=r||!1,n=n.trim();var a=i()(n,e.trim(),!0);return a.isValid()?(r&&a.add(1,"d"),a.toDate()):io(/^([\d]+)([wdhms]|ms)$/.exec(n.trim()),i()(t))},oo=0,so=function(t){return void 0===t?"task"+(oo+=1):t},co=[],lo={},uo=function(t){var e=lo[t];return co[e]},ho=function(){for(var t=function(t){var e=co[t],n="";switch(co[t].raw.startTime.type){case"prevTaskEnd":var r=uo(e.prevTaskId);e.startTime=r.endTime;break;case"getStartDate":(n=ro(0,za,co[t].raw.startTime.startData))&&(co[t].startTime=n);}return co[t].startTime&&(co[t].endTime=ao(co[t].startTime,za,co[t].raw.endTime.data,Qa),co[t].endTime&&(co[t].processed=!0,co[t].manualEndTime=i()(co[t].raw.endTime.data,"YYYY-MM-DD",!0).isValid(),eo(co[t],za,Wa,$a))),co[t].processed},e=!0,n=0;n<co.length;n++)t(n),e=e&&co[n].processed;return e},fo=function(t,e){t.split(",").forEach((function(t){var n=uo(t);void 0!==n&&n.classes.push(e);}));},po=function(t,e){Za.push((function(){var n=document.querySelector('[id="'.concat(t,'"]'));null!==n&&n.addEventListener("click",(function(){e();}));})),Za.push((function(){var n=document.querySelector('[id="'.concat(t,'-text"]'));null!==n&&n.addEventListener("click",(function(){e();}));}));};const go={parseDirective:function(t,e,n){cu.parseDirective(this,t,e,n);},getConfig:function(){return Xt().gantt},clear:function(){Ha=[],Va=[],Ga="",Za=[],oo=0,Pa=void 0,ja=void 0,co=[],za="",Ya="",Ua="",$a=[],Wa=[],Qa=!1,Ka=!1,Ja=0,qa={},ge();},setDateFormat:function(t){za=t;},getDateFormat:function(){return za},enableInclusiveEndDates:function(){Qa=!0;},endDatesAreInclusive:function(){return Qa},enableTopAxis:function(){Ka=!0;},topAxisEnabled:function(){return Ka},setAxisFormat:function(t){Ya=t;},getAxisFormat:function(){return Ya},setTodayMarker:function(t){Ua=t;},getTodayMarker:function(){return Ua},setAccTitle:ye,getAccTitle:me,setDiagramTitle:_e,getDiagramTitle:xe,setAccDescription:be,getAccDescription:ve,addSection:function(t){Ga=t,Ha.push(t);},getSections:function(){return Ha},getTasks:function(){for(var t=ho(),e=0;!t&&e<10;)t=ho(),e++;return Va=co},addTask:function(t,e){var n={section:Ga,type:Ga,processed:!1,manualEndTime:!1,renderEndTime:null,raw:{data:e},task:t,classes:[]},r=function(t,e){var n=(":"===e.substr(0,1)?e.substr(1,e.length):e).split(","),r={};yo(n,r,Xa);for(var i=0;i<n.length;i++)n[i]=n[i].trim();switch(n.length){case 1:r.id=so(),r.startTime={type:"prevTaskEnd",id:t},r.endTime={data:n[0]};break;case 2:r.id=so(),r.startTime={type:"getStartDate",startData:n[0]},r.endTime={data:n[1]};break;case 3:r.id=so(n[0]),r.startTime={type:"getStartDate",startData:n[1]},r.endTime={data:n[2]};}return r}(ja,e);n.raw.startTime=r.startTime,n.raw.endTime=r.endTime,n.id=r.id,n.prevTaskId=ja,n.active=r.active,n.done=r.done,n.crit=r.crit,n.milestone=r.milestone,n.order=Ja,Ja++;var i=co.push(n);ja=n.id,lo[n.id]=i-1;},findTaskById:uo,addTaskOrg:function(t,e){var n={section:Ga,type:Ga,description:t,task:t,classes:[]},r=function(t,e){var n=(":"===e.substr(0,1)?e.substr(1,e.length):e).split(","),r={};yo(n,r,Xa);for(var a=0;a<n.length;a++)n[a]=n[a].trim();var o="";switch(n.length){case 1:r.id=so(),r.startTime=t.endTime,o=n[0];break;case 2:r.id=so(),r.startTime=ro(0,za,n[0]),o=n[1];break;case 3:r.id=so(n[0]),r.startTime=ro(0,za,n[1]),o=n[2];}return o&&(r.endTime=ao(r.startTime,za,o,Qa),r.manualEndTime=i()(o,"YYYY-MM-DD",!0).isValid(),eo(r,za,Wa,$a)),r}(Pa,e);n.startTime=r.startTime,n.endTime=r.endTime,n.id=r.id,n.active=r.active,n.done=r.done,n.crit=r.crit,n.milestone=r.milestone,Pa=n,Va.push(n);},setIncludes:function(t){$a=t.toLowerCase().split(/[\s,]+/);},getIncludes:function(){return $a},setExcludes:function(t){Wa=t.toLowerCase().split(/[\s,]+/);},getExcludes:function(){return Wa},setClickEvent:function(t,e,n){t.split(",").forEach((function(t){!function(t,e,n){if("loose"===Xt().securityLevel&&void 0!==e){var r=[];if("string"==typeof n){r=n.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/);for(var i=0;i<r.length;i++){var a=r[i].trim();'"'===a.charAt(0)&&'"'===a.charAt(a.length-1)&&(a=a.substr(1,a.length-2)),r[i]=a;}}0===r.length&&r.push(t),void 0!==uo(t)&&po(t,(function(){var t;An.runFunc.apply(An,[e].concat(function(t){if(Array.isArray(t))return Ra(t)}(t=r)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ra(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return "Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ra(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()));}));}}(t,e,n);})),fo(t,"clickable");},setLink:function(t,e){var n=e;"loose"!==Xt().securityLevel&&(n=(0, je.N)(e)),t.split(",").forEach((function(t){void 0!==uo(t)&&(po(t,(function(){window.open(n,"_self");})),qa[t]=n);})),fo(t,"clickable");},getLinks:function(){return qa},bindFunctions:function(t){Za.forEach((function(e){e(t);}));},durationToDate:io,isInvalidDate:to};function yo(t,e,n){for(var r=!0;r;)r=!1,n.forEach((function(n){var i=new RegExp("^\\s*"+n+"\\s*$");t[0].match(i)&&(e[n]=!0,t.shift(1),r=!0);}));}var mo;const bo={setConf:function(){o.debug("Something is calling, setConf, remove the call");},draw:function(t,e,n,r){var a,o=Xt().gantt,s=Xt().securityLevel;"sandbox"===s&&(a=(0, l.select)("#i"+e));var c="sandbox"===s?(0, l.select)(a.nodes()[0].contentDocument.body):(0, l.select)("body"),u="sandbox"===s?a.nodes()[0].contentDocument:document,h=u.getElementById(e);void 0===(mo=h.parentElement.offsetWidth)&&(mo=1200),void 0!==o.useWidth&&(mo=o.useWidth);var f=r.db.getTasks(),d=f.length*(o.barHeight+o.barGap)+2*o.topPadding;h.setAttribute("viewBox","0 0 "+mo+" "+d);for(var p=c.select('[id="'.concat(e,'"]')),g=(0, l.scaleTime)().domain([(0, l.min)(f,(function(t){return t.startTime})),(0, l.max)(f,(function(t){return t.endTime}))]).rangeRound([0,mo-o.leftPadding-o.rightPadding]),y=[],m=0;m<f.length;m++)y.push(f[m].type);var b=y;y=function(t){for(var e={},n=[],r=0,i=t.length;r<i;++r)Object.prototype.hasOwnProperty.call(e,t[r])||(e[t[r]]=!0,n.push(t[r]));return n}(y),f.sort((function(t,e){var n=t.startTime,r=e.startTime,i=0;return n>r?i=1:n<r&&(i=-1),i})),function(t,n,a){var s=o.barHeight,c=s+o.barGap,h=o.topPadding,f=o.leftPadding;(0, l.scaleLinear)().domain([0,y.length]).range(["#00B9FA","#F95002"]).interpolate(l.interpolateHcl),function(t,e,n,a,s,c,l,u){var h=c.reduce((function(t,e){var n=e.startTime;return t?Math.min(t,n):n}),0),f=c.reduce((function(t,e){var n=e.endTime;return t?Math.max(t,n):n}),0),d=r.db.getDateFormat();if(h&&f){for(var y=[],m=null,b=i()(h);b.valueOf()<=f;)r.db.isInvalidDate(b,d,l,u)?m?m.end=b.clone():m={start:b.clone(),end:b.clone()}:m&&(y.push(m),m=null),b.add(1,"d");p.append("g").selectAll("rect").data(y).enter().append("rect").attr("id",(function(t){return "exclude-"+t.start.format("YYYY-MM-DD")})).attr("x",(function(t){return g(t.start)+n})).attr("y",o.gridLineStartPadding).attr("width",(function(t){var e=t.end.clone().add(1,"day");return g(e)-g(t.start)})).attr("height",s-e-o.gridLineStartPadding).attr("transform-origin",(function(e,r){return (g(e.start)+n+.5*(g(e.end)-g(e.start))).toString()+"px "+(r*t+.5*s).toString()+"px"})).attr("class","exclude-range");}}(c,h,f,0,a,t,r.db.getExcludes(),r.db.getIncludes()),function(t,e,n,i){var a=(0, l.axisBottom)(g).tickSize(-i+e+o.gridLineStartPadding).tickFormat((0, l.timeFormat)(r.db.getAxisFormat()||o.axisFormat||"%Y-%m-%d"));if(p.append("g").attr("class","grid").attr("transform","translate("+t+", "+(i-50)+")").call(a).selectAll("text").style("text-anchor","middle").attr("fill","#000").attr("stroke","none").attr("font-size",10).attr("dy","1em"),r.db.topAxisEnabled()||o.topAxis){var s=(0, l.axisTop)(g).tickSize(-i+e+o.gridLineStartPadding).tickFormat((0, l.timeFormat)(r.db.getAxisFormat()||o.axisFormat||"%Y-%m-%d"));p.append("g").attr("class","grid").attr("transform","translate("+t+", "+e+")").call(s).selectAll("text").style("text-anchor","middle").attr("fill","#000").attr("stroke","none").attr("font-size",10);}}(f,h,0,a),function(t,n,i,a,s,c,u){p.append("g").selectAll("rect").data(t).enter().append("rect").attr("x",0).attr("y",(function(t,e){return t.order*n+i-2})).attr("width",(function(){return u-o.rightPadding/2})).attr("height",n).attr("class",(function(t){for(var e=0;e<y.length;e++)if(t.type===y[e])return "section section"+e%o.numberSectionStyles;return "section section0"}));var h=p.append("g").selectAll("rect").data(t).enter(),f=r.db.getLinks();if(h.append("rect").attr("id",(function(t){return t.id})).attr("rx",3).attr("ry",3).attr("x",(function(t){return t.milestone?g(t.startTime)+a+.5*(g(t.endTime)-g(t.startTime))-.5*s:g(t.startTime)+a})).attr("y",(function(t,e){return t.order*n+i})).attr("width",(function(t){return t.milestone?s:g(t.renderEndTime||t.endTime)-g(t.startTime)})).attr("height",s).attr("transform-origin",(function(t,e){return e=t.order,(g(t.startTime)+a+.5*(g(t.endTime)-g(t.startTime))).toString()+"px "+(e*n+i+.5*s).toString()+"px"})).attr("class",(function(t){var e="";t.classes.length>0&&(e=t.classes.join(" "));for(var n=0,r=0;r<y.length;r++)t.type===y[r]&&(n=r%o.numberSectionStyles);var i="";return t.active?t.crit?i+=" activeCrit":i=" active":t.done?i=t.crit?" doneCrit":" done":t.crit&&(i+=" crit"),0===i.length&&(i=" task"),t.milestone&&(i=" milestone "+i),"task"+(i+=n)+" "+e})),h.append("text").attr("id",(function(t){return t.id+"-text"})).text((function(t){return t.task})).attr("font-size",o.fontSize).attr("x",(function(t){var e=g(t.startTime),n=g(t.renderEndTime||t.endTime);t.milestone&&(e+=.5*(g(t.endTime)-g(t.startTime))-.5*s),t.milestone&&(n=e+s);var r=this.getBBox().width;return r>n-e?n+r+1.5*o.leftPadding>u?e+a-5:n+a+5:(n-e)/2+e+a})).attr("y",(function(t,e){return t.order*n+o.barHeight/2+(o.fontSize/2-2)+i})).attr("text-height",s).attr("class",(function(t){var e=g(t.startTime),n=g(t.endTime);t.milestone&&(n=e+s);var r=this.getBBox().width,i="";t.classes.length>0&&(i=t.classes.join(" "));for(var a=0,c=0;c<y.length;c++)t.type===y[c]&&(a=c%o.numberSectionStyles);var l="";return t.active&&(l=t.crit?"activeCritText"+a:"activeText"+a),t.done?l=t.crit?l+" doneCritText"+a:l+" doneText"+a:t.crit&&(l=l+" critText"+a),t.milestone&&(l+=" milestoneText"),r>n-e?n+r+1.5*o.leftPadding>u?i+" taskTextOutsideLeft taskTextOutside"+a+" "+l:i+" taskTextOutsideRight taskTextOutside"+a+" "+l+" width-"+r:i+" taskText taskText"+a+" "+l+" width-"+r})),"sandbox"===Xt().securityLevel){var d;d=(0, l.select)("#i"+e),(0, l.select)(d.nodes()[0].contentDocument.body);var m=d.nodes()[0].contentDocument;h.filter((function(t){return void 0!==f[t.id]})).each((function(t){var e=m.querySelector("#"+t.id),n=m.querySelector("#"+t.id+"-text"),r=e.parentNode,i=m.createElement("a");i.setAttribute("xlink:href",f[t.id]),i.setAttribute("target","_top"),r.appendChild(i),i.appendChild(e),i.appendChild(n);}));}}(t,c,h,f,s,0,n),function(t,e){for(var n=[],r=0,i=0;i<y.length;i++)n[i]=[y[i],(a=y[i],s=b,function(t){for(var e=t.length,n={};e;)n[t[--e]]=(n[t[e]]||0)+1;return n}(s)[a]||0)];var a,s;p.append("g").selectAll("text").data(n).enter().append((function(t){var e=t[0].split(ue.lineBreakRegex),n=-(e.length-1)/2,r=u.createElementNS("http://www.w3.org/2000/svg","text");r.setAttribute("dy",n+"em");for(var i=0;i<e.length;i++){var a=u.createElementNS("http://www.w3.org/2000/svg","tspan");a.setAttribute("alignment-baseline","central"),a.setAttribute("x","10"),i>0&&a.setAttribute("dy","1em"),a.textContent=e[i],r.appendChild(a);}return r})).attr("x",10).attr("y",(function(i,a){if(!(a>0))return i[1]*t/2+e;for(var o=0;o<a;o++)return r+=n[a-1][1],i[1]*t/2+r*t+e})).attr("font-size",o.sectionFontSize).attr("font-size",o.sectionFontSize).attr("class",(function(t){for(var e=0;e<y.length;e++)if(t[0]===y[e])return "sectionTitle sectionTitle"+e%o.numberSectionStyles;return "sectionTitle"}));}(c,h),function(t,e,n,i){var a=r.db.getTodayMarker();if("off"!==a){var s=p.append("g").attr("class","today"),c=new Date,l=s.append("line");l.attr("x1",g(c)+t).attr("x2",g(c)+t).attr("y1",o.titleTopMargin).attr("y2",i-o.titleTopMargin).attr("class","today"),""!==a&&l.attr("style",a.replace(/,/g,";"));}}(f,0,0,a);}(f,mo,d),Tn(p,0,mo,o.useMaxWidth),p.append("text").text(r.db.getDiagramTitle()).attr("x",mo/2).attr("y",o.titleTopMargin).attr("class","titleText"),Mn(r.db,p,e);}};var vo=n(9959),_o=n.n(vo),xo="",ko=!1;const wo={setMessage:function(t){o.debug("Setting message to: "+t),xo=t;},getMessage:function(){return xo},setInfo:function(t){ko=t;},getInfo:function(){return ko}},To={draw:function(t,e,n,r){try{o.debug("Renering info diagram\n"+t);var i,a=Xt().securityLevel;"sandbox"===a&&(i=(0,l.select)("#i"+e));var s="sandbox"===a?(0,l.select)(i.nodes()[0].contentDocument.body):(0,l.select)("body"),c=("sandbox"===a?i.nodes()[0].contentDocument:document,s.select("#"+e));c.append("g").append("text").attr("x",100).attr("y",40).attr("class","version").attr("font-size","32px").style("text-anchor","middle").text("v "+n),c.attr("height",100),c.attr("width",400);}catch(t){o.error("Error while rendering info diagram"),o.error(t.message);}}};var Eo=n(6765),Co=n.n(Eo),So=n(7062),Ao=n.n(So),Mo={},No=!1;const Oo={parseDirective:function(t,e,n){cu.parseDirective(this,t,e,n);},getConfig:function(){return Xt().pie},addSection:function(t,e){t=ue.sanitizeText(t,Xt()),void 0===Mo[t]&&(Mo[t]=e,o.debug("Added new section :",t));},getSections:function(){return Mo},cleanupValue:function(t){return ":"===t.substring(0,1)?(t=t.substring(1).trim(),Number(t.trim())):Number(t.trim())},clear:function(){Mo={},No=!1,ge();},setAccTitle:ye,getAccTitle:me,setDiagramTitle:_e,getDiagramTitle:xe,setShowData:function(t){No=t;},getShowData:function(){return No},getAccDescription:ve,setAccDescription:be};var Do,Bo=Xt();const Lo={draw:function(t,e,n,r){try{Bo=Xt(),o.debug("Rendering info diagram\n"+t);var i,a=Xt().securityLevel;"sandbox"===a&&(i=(0,l.select)("#i"+e));var s="sandbox"===a?(0,l.select)(i.nodes()[0].contentDocument.body):(0,l.select)("body"),c="sandbox"===a?i.nodes()[0].contentDocument:document;r.db.clear(),r.parser.parse(t),o.debug("Parsed info diagram");var u=c.getElementById(e);void 0===(Do=u.parentElement.offsetWidth)&&(Do=1200),void 0!==Bo.useWidth&&(Do=Bo.useWidth),void 0!==Bo.pie.useWidth&&(Do=Bo.pie.useWidth);var h=s.select("#"+e);Tn(h,0,Do,Bo.pie.useMaxWidth),Mn(r.db,h,e),u.setAttribute("viewBox","0 0 "+Do+" 450");var f=Math.min(Do,450)/2-40,d=h.append("g").attr("transform","translate("+Do/2+",225)"),p=r.db.getSections(),g=0;Object.keys(p).forEach((function(t){g+=p[t];}));var y=Bo.themeVariables,m=[y.pie1,y.pie2,y.pie3,y.pie4,y.pie5,y.pie6,y.pie7,y.pie8,y.pie9,y.pie10,y.pie11,y.pie12],b=(0,l.scaleOrdinal)().range(m),v=(0,l.pie)().value((function(t){return t[1]}))(Object.entries(p)),_=(0,l.arc)().innerRadius(0).outerRadius(f);d.selectAll("mySlices").data(v).enter().append("path").attr("d",_).attr("fill",(function(t){return b(t.data[0])})).attr("class","pieCircle"),d.selectAll("mySlices").data(v).enter().append("text").text((function(t){return (t.data[1]/g*100).toFixed(0)+"%"})).attr("transform",(function(t){return "translate("+_.centroid(t)+")"})).style("text-anchor","middle").attr("class","slice"),d.append("text").text(r.db.getDiagramTitle()).attr("x",0).attr("y",-200).attr("class","pieTitleText");var x=d.selectAll(".legend").data(b.domain()).enter().append("g").attr("class","legend").attr("transform",(function(t,e){return "translate(216,"+(22*e-22*b.domain().length/2)+")"}));x.append("rect").attr("width",18).attr("height",18).style("fill",b).style("stroke",b),x.data(v).append("text").attr("x",22).attr("y",14).text((function(t){return r.db.getShowData()||Bo.showData||Bo.pie.showData?t.data[0]+" ["+t.data[1]+"]":t.data[0]}));}catch(t){o.error("Error while rendering info diagram"),o.error(t);}}};var Io=n(3176),Fo=n.n(Io),Ro=[],Po={},jo={},zo={},Yo={};const Uo={RequirementType:{REQUIREMENT:"Requirement",FUNCTIONAL_REQUIREMENT:"Functional Requirement",INTERFACE_REQUIREMENT:"Interface Requirement",PERFORMANCE_REQUIREMENT:"Performance Requirement",PHYSICAL_REQUIREMENT:"Physical Requirement",DESIGN_CONSTRAINT:"Design Constraint"},RiskLevel:{LOW_RISK:"Low",MED_RISK:"Medium",HIGH_RISK:"High"},VerifyType:{VERIFY_ANALYSIS:"Analysis",VERIFY_DEMONSTRATION:"Demonstration",VERIFY_INSPECTION:"Inspection",VERIFY_TEST:"Test"},Relationships:{CONTAINS:"contains",COPIES:"copies",DERIVES:"derives",SATISFIES:"satisfies",VERIFIES:"verifies",REFINES:"refines",TRACES:"traces"},parseDirective:function(t,e,n){cu.parseDirective(this,t,e,n);},getConfig:function(){return Xt().req},addRequirement:function(t,e){return void 0===jo[t]&&(jo[t]={name:t,type:e,id:Po.id,text:Po.text,risk:Po.risk,verifyMethod:Po.verifyMethod}),Po={},jo[t]},getRequirements:function(){return jo},setNewReqId:function(t){void 0!==Po&&(Po.id=t);},setNewReqText:function(t){void 0!==Po&&(Po.text=t);},setNewReqRisk:function(t){void 0!==Po&&(Po.risk=t);},setNewReqVerifyMethod:function(t){void 0!==Po&&(Po.verifyMethod=t);},setAccTitle:ye,getAccTitle:me,setAccDescription:be,getAccDescription:ve,addElement:function(t){return void 0===Yo[t]&&(Yo[t]={name:t,type:zo.type,docRef:zo.docRef},o.info("Added new requirement: ",t)),zo={},Yo[t]},getElements:function(){return Yo},setNewElementType:function(t){void 0!==zo&&(zo.type=t);},setNewElementDocRef:function(t){void 0!==zo&&(zo.docRef=t);},addRelationship:function(t,e,n){Ro.push({type:t,src:e,dst:n});},getRelationships:function(){return Ro},clear:function(){Ro=[],Po={},jo={},zo={},Yo={},ge();}};var $o={CONTAINS:"contains",ARROW:"arrow"};const Wo=$o;var qo={},Ho=0,Vo=function(t,e){return t.insert("rect","#"+e).attr("class","req reqBox").attr("x",0).attr("y",0).attr("width",qo.rect_min_width+"px").attr("height",qo.rect_min_height+"px")},Go=function(t,e,n){var r=qo.rect_min_width/2,i=t.append("text").attr("class","req reqLabel reqTitle").attr("id",e).attr("x",r).attr("y",qo.rect_padding).attr("dominant-baseline","hanging"),a=0;n.forEach((function(t){0==a?i.append("tspan").attr("text-anchor","middle").attr("x",qo.rect_min_width/2).attr("dy",0).text(t):i.append("tspan").attr("text-anchor","middle").attr("x",qo.rect_min_width/2).attr("dy",.75*qo.line_height).text(t),a++;}));var o=1.5*qo.rect_padding+a*qo.line_height*.75;return t.append("line").attr("class","req-title-line").attr("x1","0").attr("x2",qo.rect_min_width).attr("y1",o).attr("y2",o),{titleNode:i,y:o}},Xo=function(t,e,n,r){var i=t.append("text").attr("class","req reqLabel").attr("id",e).attr("x",qo.rect_padding).attr("y",r).attr("dominant-baseline","hanging"),a=0,o=[];return n.forEach((function(t){for(var e=t.length;e>30&&a<3;){var n=t.substring(0,30);e=(t=t.substring(30,t.length)).length,o[o.length]=n,a++;}if(3==a){var r=o[o.length-1];o[o.length-1]=r.substring(0,r.length-4)+"...";}else o[o.length]=t;a=0;})),o.forEach((function(t){i.append("tspan").attr("x",qo.rect_padding).attr("dy",qo.line_height).text(t);})),i},Zo=function(t){return t.replace(/\s/g,"").replace(/\./g,"_")};const Qo={draw:function(t,e,n,r){qo=Xt().requirement,r.db.clear(),r.parser.parse(t);var i,a=qo.securityLevel;"sandbox"===a&&(i=(0, l.select)("#i"+e));var s="sandbox"===a?(0, l.select)(i.nodes()[0].contentDocument.body):(0, l.select)("body"),c=("sandbox"===a?i.nodes()[0].contentDocument:document,s.select("[id='".concat(e,"']")));!function(t,e){var n=t.append("defs").append("marker").attr("id",$o.CONTAINS+"_line_ending").attr("refX",0).attr("refY",e.line_height/2).attr("markerWidth",e.line_height).attr("markerHeight",e.line_height).attr("orient","auto").append("g");n.append("circle").attr("cx",e.line_height/2).attr("cy",e.line_height/2).attr("r",e.line_height/2).attr("fill","none"),n.append("line").attr("x1",0).attr("x2",e.line_height).attr("y1",e.line_height/2).attr("y2",e.line_height/2).attr("stroke-width",1),n.append("line").attr("y1",0).attr("y2",e.line_height).attr("x1",e.line_height/2).attr("x2",e.line_height/2).attr("stroke-width",1),t.append("defs").append("marker").attr("id",$o.ARROW+"_line_ending").attr("refX",e.line_height).attr("refY",.5*e.line_height).attr("markerWidth",e.line_height).attr("markerHeight",e.line_height).attr("orient","auto").append("path").attr("d","M0,0\n L".concat(e.line_height,",").concat(e.line_height/2,"\n M").concat(e.line_height,",").concat(e.line_height/2,"\n L0,").concat(e.line_height)).attr("stroke-width",1);}(c,qo);var u,h,f,d=new(yr().Graph)({multigraph:!1,compound:!1,directed:!0}).setGraph({rankdir:qo.layoutDirection,marginx:20,marginy:20,nodesep:100,edgesep:100,ranksep:100}).setDefaultEdgeLabel((function(){return {}})),p=r.db.getRequirements(),g=r.db.getElements(),y=r.db.getRelationships();u=p,h=d,f=c,Object.keys(u).forEach((function(t){var e=u[t];t=Zo(t),o.info("Added new requirement: ",t);var n=f.append("g").attr("id",t),r=Vo(n,"req-"+t),a=Go(n,t+"_title",["<<".concat(e.type,">>"),"".concat(e.name)]);var s=Xo(n,t+"_body",["Id: ".concat(e.id),"Text: ".concat(e.text),"Risk: ".concat(e.risk),"Verification: ".concat(e.verifyMethod)],a.y);var c=r.node().getBBox();h.setNode(t,{width:c.width,height:c.height,shape:"rect",id:t});})),function(t,e,n){Object.keys(t).forEach((function(r){var i=t[r],a=Zo(r),o=n.append("g").attr("id",a),s="element-"+a,c=Vo(o,s),u=Go(o,s+"_title",["<<Element>>","".concat(r)]);var h=Xo(o,s+"_body",["Type: ".concat(i.type||"Not Specified"),"Doc Ref: ".concat(i.docRef||"None")],u.y);var f=c.node().getBBox();e.setNode(a,{width:f.width,height:f.height,shape:"rect",id:a});}));}(g,d,c),function(t,e){t.forEach((function(t){var n=Zo(t.src),r=Zo(t.dst);e.setEdge(n,r,{relationship:t});}));}(y,d),pr().layout(d),function(t,e){e.nodes().forEach((function(n){void 0!==n&&void 0!==e.node(n)&&(t.select("#"+n),t.select("#"+n).attr("transform","translate("+(e.node(n).x-e.node(n).width/2)+","+(e.node(n).y-e.node(n).height/2)+" )"));}));}(c,d),y.forEach((function(t){!function(t,e,n,r,i){var a=n.edge(Zo(e.src),Zo(e.dst)),o=(0, l.line)().x((function(t){return t.x})).y((function(t){return t.y})),s=t.insert("path","#"+r).attr("class","er relationshipLine").attr("d",o(a.points)).attr("fill","none");e.type==i.db.Relationships.CONTAINS?s.attr("marker-start","url("+ue.getUrl(qo.arrowMarkerAbsolute)+"#"+e.type+"_line_ending)"):(s.attr("stroke-dasharray","10,7"),s.attr("marker-end","url("+ue.getUrl(qo.arrowMarkerAbsolute)+"#"+Wo.ARROW+"_line_ending)")),function(t,e,n,r){var i=e.node().getTotalLength(),a=e.node().getPointAtLength(.5*i),o="rel"+Ho;Ho++;var s=t.append("text").attr("class","req relationshipLabel").attr("id",o).attr("x",a.x).attr("y",a.y).attr("text-anchor","middle").attr("dominant-baseline","middle").text(r).node().getBBox();t.insert("rect","#"+o).attr("class","req reqLabelBox").attr("x",a.x-s.width/2).attr("y",a.y-s.height/2).attr("width",s.width).attr("height",s.height).attr("fill","white").attr("fill-opacity","85%");}(t,s,0,"<<".concat(e.type,">>"));}(c,t,d,e,r);}));var m=qo.rect_padding,b=c.node().getBBox(),v=b.width+2*m,_=b.height+2*m;Tn(c,0,v,qo.useMaxWidth),c.attr("viewBox","".concat(b.x-m," ").concat(b.y-m," ").concat(v," ").concat(_)),Mn(r.db,c,e);}};var Ko,Jo=n(6876),ts=n.n(Jo),es=void 0,ns={},rs=[],as=!1,os=function(t,e,n,r){var i=ns[t];i&&e===i.name&&null==n||(null!=n&&null!=n.text||(n={text:e,wrap:null,type:r}),null!=r&&null!=n.text||(n={text:e,wrap:null,type:r}),ns[t]={name:e,description:n.text,wrap:void 0===n.wrap&&us()||!!n.wrap,prevActor:es,links:{},properties:{},actorCnt:null,rectData:null,type:r||"participant"},es&&ns[es]&&(ns[es].nextActor=t),es=t);},ss=function(t){var e,n=0;for(e=0;e<rs.length;e++)rs[e].type===hs.ACTIVE_START&&rs[e].from.actor===t&&n++,rs[e].type===hs.ACTIVE_END&&rs[e].from.actor===t&&n--;return n},cs=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{text:void 0,wrap:void 0},r=arguments.length>3?arguments[3]:void 0;if(r===hs.ACTIVE_END){var i=ss(t.actor);if(i<1){var a=new Error("Trying to inactivate an inactive participant ("+t.actor+")");throw a.hash={text:"->>-",token:"->>-",line:"1",loc:{first_line:1,last_line:1,first_column:1,last_column:1},expected:["'ACTIVE_PARTICIPANT'"]},a}}return rs.push({from:t,to:e,message:n.text,wrap:void 0===n.wrap&&us()||!!n.wrap,type:r}),!0},ls=function(t){return ns[t]},us=function(){return void 0!==Ko?Ko:Xt().sequence.wrap},hs={SOLID:0,DOTTED:1,NOTE:2,SOLID_CROSS:3,DOTTED_CROSS:4,SOLID_OPEN:5,DOTTED_OPEN:6,LOOP_START:10,LOOP_END:11,ALT_START:12,ALT_ELSE:13,ALT_END:14,OPT_START:15,OPT_END:16,ACTIVE_START:17,ACTIVE_END:18,PAR_START:19,PAR_AND:20,PAR_END:21,RECT_START:22,RECT_END:23,SOLID_POINT:24,DOTTED_POINT:25,AUTONUMBER:26,CRITICAL_START:27,CRITICAL_OPTION:28,CRITICAL_END:29,BREAK_START:30,BREAK_END:31},fs=function(t,e,n){var r={actor:t,placement:e,message:n.text,wrap:void 0===n.wrap&&us()||!!n.wrap},i=[].concat(t,t);rs.push({from:i[0],to:i[1],message:n.text,wrap:void 0===n.wrap&&us()||!!n.wrap,type:hs.NOTE,placement:e});},ds=function(t,e){var n=ls(t);try{var r=ie(e.text,Xt());r=(r=r.replace(/&amp;/g,"&")).replace(/&equals;/g,"="),ps(n,JSON.parse(r));}catch(t){o.error("error while parsing actor link text",t);}};function ps(t,e){if(null==t.links)t.links=e;else for(var n in e)t.links[n]=e[n];}var gs=function(t,e){var n=ls(t);try{var r=ie(e.text,Xt());ys(n,JSON.parse(r));}catch(t){o.error("error while parsing actor properties text",t);}};function ys(t,e){if(null==t.properties)t.properties=e;else for(var n in e)t.properties[n]=e[n];}var ms=function(t,e){var n=ls(t),r=document.getElementById(e.text);try{var i=r.innerHTML,a=JSON.parse(i);a.properties&&ys(n,a.properties),a.links&&ps(n,a.links);}catch(t){o.error("error while parsing actor details text",t);}};const bs={addActor:os,addMessage:function(t,e,n,r){rs.push({from:t,to:e,message:n.text,wrap:void 0===n.wrap&&us()||!!n.wrap,answer:r});},addSignal:cs,addLinks:ds,addDetails:ms,addProperties:gs,autoWrap:us,setWrap:function(t){Ko=t;},enableSequenceNumbers:function(){as=!0;},disableSequenceNumbers:function(){as=!1;},showSequenceNumbers:function(){return as},getMessages:function(){return rs},getActors:function(){return ns},getActor:ls,getActorKeys:function(){return Object.keys(ns)},getActorProperty:function(t,e){if(void 0!==t&&void 0!==t.properties)return t.properties[e]},getAccTitle:me,getDiagramTitle:xe,setDiagramTitle:_e,parseDirective:function(t,e,n){cu.parseDirective(this,t,e,n);},getConfig:function(){return Xt().sequence},clear:function(){ns={},rs=[],as=!1,ge();},parseMessage:function(t){var e=t.trim(),n={text:e.replace(/^[:]?(?:no)?wrap:/,"").trim(),wrap:null!==e.match(/^[:]?wrap:/)||null===e.match(/^[:]?nowrap:/)&&void 0};return o.debug("parseMessage:",n),n},LINETYPE:hs,ARROWTYPE:{FILLED:0,OPEN:1},PLACEMENT:{LEFTOF:0,RIGHTOF:1,OVER:2},addNote:fs,setAccTitle:ye,apply:function t(e){if(e instanceof Array)e.forEach((function(e){t(e);}));else switch(e.type){case"sequenceIndex":rs.push({from:void 0,to:void 0,message:{start:e.sequenceIndex,step:e.sequenceIndexStep,visible:e.sequenceVisible},wrap:!1,type:e.signalType});break;case"addParticipant":os(e.actor,e.actor,e.description,"participant");break;case"addActor":os(e.actor,e.actor,e.description,"actor");break;case"activeStart":case"activeEnd":cs(e.actor,void 0,void 0,e.signalType);break;case"addNote":fs(e.actor,e.placement,e.text);break;case"addLinks":ds(e.actor,e.text);break;case"addALink":!function(t,e){var n=ls(t);try{var r={},i=ie(e.text,Xt()),a=i.indexOf("@"),s=(i=(i=i.replace(/&amp;/g,"&")).replace(/&equals;/g,"=")).slice(0,a-1).trim(),c=i.slice(a+1).trim();r[s]=c,ps(n,r);}catch(t){o.error("error while parsing actor link text",t);}}(e.actor,e.text);break;case"addProperties":gs(e.actor,e.text);break;case"addDetails":ms(e.actor,e.text);break;case"addMessage":cs(e.from,e.to,e.msg,e.signalType);break;case"loopStart":cs(void 0,void 0,e.loopText,e.signalType);break;case"loopEnd":case"rectEnd":case"optEnd":case"altEnd":case"parEnd":case"criticalEnd":case"breakEnd":cs(void 0,void 0,void 0,e.signalType);break;case"rectStart":cs(void 0,void 0,e.color,e.signalType);break;case"optStart":cs(void 0,void 0,e.optText,e.signalType);break;case"altStart":case"else":cs(void 0,void 0,e.altText,e.signalType);break;case"setAccTitle":ye(e.text);break;case"parStart":case"and":cs(void 0,void 0,e.parText,e.signalType);break;case"criticalStart":cs(void 0,void 0,e.criticalText,e.signalType);break;case"option":cs(void 0,void 0,e.optionText,e.signalType);break;case"breakStart":cs(void 0,void 0,e.breakText,e.signalType);}},setAccDescription:be,getAccDescription:ve};var vs=[],_s=function(t,e){var n=t.append("rect");return n.attr("x",e.x),n.attr("y",e.y),n.attr("fill",e.fill),n.attr("stroke",e.stroke),n.attr("width",e.width),n.attr("height",e.height),n.attr("rx",e.rx),n.attr("ry",e.ry),void 0!==e.class&&n.attr("class",e.class),n},xs=function(t,e){var n;n=function(){var n=document.querySelectorAll(t);0!==n.length&&(n[0].addEventListener("mouseover",(function(){Ts("actor"+e+"_popup");})),n[0].addEventListener("mouseout",(function(){Es("actor"+e+"_popup");})));},vs.push(n);},ks=function(t,e,n,r){var i=t.append("image");i.attr("x",e),i.attr("y",n);var a=(0, je.N)(r);i.attr("xlink:href",a);},ws=function(t,e,n,r){var i=t.append("use");i.attr("x",e),i.attr("y",n);var a=(0, je.N)(r);i.attr("xlink:href","#"+a);},Ts=function(t){var e=document.getElementById(t);null!=e&&(e.style.display="block");},Es=function(t){var e=document.getElementById(t);null!=e&&(e.style.display="none");},Cs=function(t,e){var n=0,r=0,i=e.text.split(ue.lineBreakRegex),a=[],o=0,s=function(){return e.y};if(void 0!==e.valign&&void 0!==e.textMargin&&e.textMargin>0)switch(e.valign){case"top":case"start":s=function(){return Math.round(e.y+e.textMargin)};break;case"middle":case"center":s=function(){return Math.round(e.y+(n+r+e.textMargin)/2)};break;case"bottom":case"end":s=function(){return Math.round(e.y+(n+r+2*e.textMargin)-e.textMargin)};}if(void 0!==e.anchor&&void 0!==e.textMargin&&void 0!==e.width)switch(e.anchor){case"left":case"start":e.x=Math.round(e.x+e.textMargin),e.anchor="start",e.dominantBaseline="middle",e.alignmentBaseline="middle";break;case"middle":case"center":e.x=Math.round(e.x+e.width/2),e.anchor="middle",e.dominantBaseline="middle",e.alignmentBaseline="middle";break;case"right":case"end":e.x=Math.round(e.x+e.width-e.textMargin),e.anchor="end",e.dominantBaseline="middle",e.alignmentBaseline="middle";}for(var c=0;c<i.length;c++){var l=i[c];void 0!==e.textMargin&&0===e.textMargin&&void 0!==e.fontSize&&(o=c*e.fontSize);var u=t.append("text");if(u.attr("x",e.x),u.attr("y",s()),void 0!==e.anchor&&u.attr("text-anchor",e.anchor).attr("dominant-baseline",e.dominantBaseline).attr("alignment-baseline",e.alignmentBaseline),void 0!==e.fontFamily&&u.style("font-family",e.fontFamily),void 0!==e.fontSize&&u.style("font-size",e.fontSize),void 0!==e.fontWeight&&u.style("font-weight",e.fontWeight),void 0!==e.fill&&u.attr("fill",e.fill),void 0!==e.class&&u.attr("class",e.class),void 0!==e.dy?u.attr("dy",e.dy):0!==o&&u.attr("dy",o),e.tspan){var h=u.append("tspan");h.attr("x",e.x),void 0!==e.fill&&h.attr("fill",e.fill),h.text(l);}else u.text(l);void 0!==e.valign&&void 0!==e.textMargin&&e.textMargin>0&&(r+=(u._groups||u)[0][0].getBBox().height,n=r),a.push(u);}return a},Ss=function(t,e){var n=t.append("polygon");return n.attr("points",function(t,e,n,r,i){return t+","+e+" "+(t+n)+","+e+" "+(t+n)+","+(e+r-7)+" "+(t+n-8.4)+","+(e+r)+" "+t+","+(e+r)}(e.x,e.y,e.width,e.height)),n.attr("class","labelBox"),e.y=e.y+e.height/2,Cs(t,e),n},As=-1,Ms=function(t,e){t.selectAll&&t.selectAll(".actor-line").attr("class","200").attr("y2",e-55);},Ns=function(){return {x:0,y:0,fill:void 0,anchor:void 0,style:"#666",width:void 0,height:void 0,textMargin:0,rx:0,ry:0,tspan:!0,valign:void 0}},Os=function(){return {x:0,y:0,fill:"#EDF2AE",stroke:"#666",width:100,anchor:"start",height:100,rx:0,ry:0}},Ds=function(){function t(t,e,n,i,a,o,s){r(e.append("text").attr("x",n+a/2).attr("y",i+o/2+5).style("text-anchor","middle").text(t),s);}function e(t,e,n,i,a,o,s,c){for(var l=c.actorFontSize,u=c.actorFontFamily,h=c.actorFontWeight,f=l&&l.replace?l.replace("px",""):l,d=t.split(ue.lineBreakRegex),p=0;p<d.length;p++){var g=p*f-f*(d.length-1)/2,y=e.append("text").attr("x",n+a/2).attr("y",i).style("text-anchor","middle").style("font-size",l).style("font-weight",h).style("font-family",u);y.append("tspan").attr("x",n+a/2).attr("dy",g).text(d[p]),y.attr("y",i+o/2).attr("dominant-baseline","central").attr("alignment-baseline","central"),r(y,s);}}function n(t,n,i,a,o,s,c,l){var u=n.append("switch"),h=u.append("foreignObject").attr("x",i).attr("y",a).attr("width",o).attr("height",s).append("xhtml:div").style("display","table").style("height","100%").style("width","100%");h.append("div").style("display","table-cell").style("text-align","center").style("vertical-align","middle").text(t),e(t,u,i,a,o,s,c,l),r(h,c);}function r(t,e){for(var n in e)e.hasOwnProperty(n)&&t.attr(n,e[n]);}return function(r){return "fo"===r.textPlacement?n:"old"===r.textPlacement?t:e}}(),Bs=function(){function t(t,e,n,i,a,o,s){r(e.append("text").attr("x",n).attr("y",i).style("text-anchor","start").text(t),s);}function e(t,e,n,i,a,o,s,c){for(var l=c.actorFontSize,u=c.actorFontFamily,h=c.actorFontWeight,f=t.split(ue.lineBreakRegex),d=0;d<f.length;d++){var p=d*l-l*(f.length-1)/2,g=e.append("text").attr("x",n).attr("y",i).style("text-anchor","start").style("font-size",l).style("font-weight",h).style("font-family",u);g.append("tspan").attr("x",n).attr("dy",p).text(f[d]),g.attr("y",i+o/2).attr("dominant-baseline","central").attr("alignment-baseline","central"),r(g,s);}}function n(t,n,i,a,o,s,c,l){var u=n.append("switch"),h=u.append("foreignObject").attr("x",i).attr("y",a).attr("width",o).attr("height",s).append("xhtml:div").style("display","table").style("height","100%").style("width","100%");h.append("div").style("display","table-cell").style("text-align","center").style("vertical-align","middle").text(t),e(t,u,i,a,0,s,c,l),r(h,c);}function r(t,e){for(var n in e)e.hasOwnProperty(n)&&t.attr(n,e[n]);}return function(r){return "fo"===r.textPlacement?n:"old"===r.textPlacement?t:e}}();const Ls=_s,Is=function(t,e,n){switch(e.type){case"actor":return function(t,e,n){var r=e.x+e.width/2;0===e.y&&(As++,t.append("line").attr("id","actor"+As).attr("x1",r).attr("y1",80).attr("x2",r).attr("y2",2e3).attr("class","actor-line").attr("stroke-width","0.5px").attr("stroke","#999"));var i=t.append("g");i.attr("class","actor-man");var a={x:0,y:0,fill:"#EDF2AE",stroke:"#666",width:100,anchor:"start",height:100,rx:0,ry:0};a.x=e.x,a.y=e.y,a.fill="#eaeaea",a.width=e.width,a.height=e.height,a.class="actor",a.rx=3,a.ry=3,i.append("line").attr("id","actor-man-torso"+As).attr("x1",r).attr("y1",e.y+25).attr("x2",r).attr("y2",e.y+45),i.append("line").attr("id","actor-man-arms"+As).attr("x1",r-18).attr("y1",e.y+33).attr("x2",r+18).attr("y2",e.y+33),i.append("line").attr("x1",r-18).attr("y1",e.y+60).attr("x2",r).attr("y2",e.y+45),i.append("line").attr("x1",r).attr("y1",e.y+45).attr("x2",r+16).attr("y2",e.y+60);var o=i.append("circle");o.attr("cx",e.x+e.width/2),o.attr("cy",e.y+10),o.attr("r",15),o.attr("width",e.width),o.attr("height",e.height);var s=i.node().getBBox();return e.height=s.height,Ds(n)(e.description,i,a.x,a.y+35,a.width,a.height,{class:"actor"},n),e.height}(t,e,n);case"participant":return function(t,e,n){var r=e.x+e.width/2,i=t.append("g"),a=i;0===e.y&&(As++,a.append("line").attr("id","actor"+As).attr("x1",r).attr("y1",5).attr("x2",r).attr("y2",2e3).attr("class","actor-line").attr("stroke-width","0.5px").attr("stroke","#999"),a=i.append("g"),e.actorCnt=As,null!=e.links&&(a.attr("id","root-"+As),xs("#root-"+As,As)));var o={x:0,y:0,fill:"#EDF2AE",stroke:"#666",width:100,anchor:"start",height:100,rx:0,ry:0},s="actor";null!=e.properties&&e.properties.class?s=e.properties.class:o.fill="#eaeaea",o.x=e.x,o.y=e.y,o.width=e.width,o.height=e.height,o.class=s,o.rx=3,o.ry=3;var c=_s(a,o);if(e.rectData=o,null!=e.properties&&e.properties.icon){var l=e.properties.icon.trim();"@"===l.charAt(0)?ws(a,o.x+o.width-20,o.y+10,l.substr(1)):ks(a,o.x+o.width-20,o.y+10,l);}Ds(n)(e.description,a,o.x,o.y,o.width,o.height,{class:"actor"},n);var u=e.height;if(c.node){var h=c.node().getBBox();e.height=h.height,u=h.height;}return u}(t,e,n)}},Fs=function(t,e,n,r,i){if(void 0===e.links||null===e.links||0===Object.keys(e.links).length)return {height:0,width:0};var a=e.links,o=e.actorCnt,s=e.rectData,c="none";i&&(c="block !important");var l=t.append("g");l.attr("id","actor"+o+"_popup"),l.attr("class","actorPopupMenu"),l.attr("display",c),xs("#actor"+o+"_popup",o);var u="";void 0!==s.class&&(u=" "+s.class);var h=s.width>n?s.width:n,f=l.append("rect");if(f.attr("class","actorPopupMenuPanel"+u),f.attr("x",s.x),f.attr("y",s.height),f.attr("fill",s.fill),f.attr("stroke",s.stroke),f.attr("width",h),f.attr("height",s.height),f.attr("rx",s.rx),f.attr("ry",s.ry),null!=a){var d=20;for(var p in a){var g=l.append("a"),y=(0, je.N)(a[p]);g.attr("xlink:href",y),g.attr("target","_blank"),Bs(r)(p,g,s.x+10,s.height+d,h,20,{class:"actor"},r),d+=30;}}return f.attr("height",d),{height:s.height+d,width:h}},Rs=function(t){return t.append("g")},Ps=function(t,e,n,r,i){var a={x:0,y:0,fill:"#EDF2AE",stroke:"#666",width:100,anchor:"start",height:100,rx:0,ry:0},o=e.anchored;a.x=e.startx,a.y=e.starty,a.class="activation"+i%3,a.width=e.stopx-e.startx,a.height=n-e.starty,_s(o,a);},js=function(t,e,n,r){var i=r.boxMargin,a=r.boxTextMargin,o=r.labelBoxHeight,s=r.labelBoxWidth,c=r.messageFontFamily,l=r.messageFontSize,u=r.messageFontWeight,h=t.append("g"),f=function(t,e,n,r){return h.append("line").attr("x1",t).attr("y1",e).attr("x2",n).attr("y2",r).attr("class","loopLine")};f(e.startx,e.starty,e.stopx,e.starty),f(e.stopx,e.starty,e.stopx,e.stopy),f(e.startx,e.stopy,e.stopx,e.stopy),f(e.startx,e.starty,e.startx,e.stopy),void 0!==e.sections&&e.sections.forEach((function(t){f(e.startx,t.y,e.stopx,t.y).style("stroke-dasharray","3, 3");}));var d={x:0,y:0,fill:void 0,anchor:void 0,style:"#666",width:void 0,height:void 0,textMargin:0,rx:0,ry:0,tspan:!0,valign:void 0};d.text=n,d.x=e.startx,d.y=e.starty,d.fontFamily=c,d.fontSize=l,d.fontWeight=u,d.anchor="middle",d.valign="middle",d.tspan=!1,d.width=s||50,d.height=o||20,d.textMargin=a,d.class="labelText",Ss(h,d),(d={x:0,y:0,fill:void 0,anchor:void 0,style:"#666",width:void 0,height:void 0,textMargin:0,rx:0,ry:0,tspan:!0,valign:void 0}).text=e.title,d.x=e.startx+s/2+(e.stopx-e.startx)/2,d.y=e.starty+i+a,d.anchor="middle",d.valign="middle",d.textMargin=a,d.class="loopText",d.fontFamily=c,d.fontSize=l,d.fontWeight=u,d.wrap=!0;var p=Cs(h,d);return void 0!==e.sectionTitles&&e.sectionTitles.forEach((function(t,n){if(t.message){d.text=t.message,d.x=e.startx+(e.stopx-e.startx)/2,d.y=e.sections[n].y+i+a,d.class="loopText",d.anchor="middle",d.valign="middle",d.tspan=!1,d.fontFamily=c,d.fontSize=l,d.fontWeight=u,d.wrap=e.wrap,p=Cs(h,d);var r=Math.round(p.map((function(t){return (t._groups||t)[0][0].getBBox().height})).reduce((function(t,e){return t+e})));e.sections[n].height+=r-(i+a);}})),e.height=Math.round(e.stopy-e.starty),h},zs=function(t,e){_s(t,{x:e.startx,y:e.starty,width:e.stopx-e.startx,height:e.stopy-e.starty,fill:e.fill,class:"rect"}).lower();},Ys=function(t){t.append("defs").append("marker").attr("id","arrowhead").attr("refX",9).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",12).attr("markerHeight",12).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z");},Us=function(t){t.append("defs").append("marker").attr("id","filled-head").attr("refX",18).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L14,7 L9,1 Z");},$s=function(t){t.append("defs").append("marker").attr("id","sequencenumber").attr("refX",15).attr("refY",15).attr("markerWidth",60).attr("markerHeight",40).attr("orient","auto").append("circle").attr("cx",15).attr("cy",15).attr("r",6);},Ws=function(t){var e=t.append("defs").append("marker").attr("id","crosshead").attr("markerWidth",15).attr("markerHeight",8).attr("orient","auto").attr("refX",16).attr("refY",4);e.append("path").attr("fill","black").attr("stroke","#000000").style("stroke-dasharray","0, 0").attr("stroke-width","1px").attr("d","M 9,2 V 6 L16,4 Z"),e.append("path").attr("fill","none").attr("stroke","#000000").style("stroke-dasharray","0, 0").attr("stroke-width","1px").attr("d","M 0,1 L 6,7 M 6,1 L 0,7");},qs=function(t){t.append("defs").append("symbol").attr("id","database").attr("fill-rule","evenodd").attr("clip-rule","evenodd").append("path").attr("transform","scale(.5)").attr("d","M12.258.001l.256.004.255.005.253.008.251.01.249.012.247.015.246.016.242.019.241.02.239.023.236.024.233.027.231.028.229.031.225.032.223.034.22.036.217.038.214.04.211.041.208.043.205.045.201.046.198.048.194.05.191.051.187.053.183.054.18.056.175.057.172.059.168.06.163.061.16.063.155.064.15.066.074.033.073.033.071.034.07.034.069.035.068.035.067.035.066.035.064.036.064.036.062.036.06.036.06.037.058.037.058.037.055.038.055.038.053.038.052.038.051.039.05.039.048.039.047.039.045.04.044.04.043.04.041.04.04.041.039.041.037.041.036.041.034.041.033.042.032.042.03.042.029.042.027.042.026.043.024.043.023.043.021.043.02.043.018.044.017.043.015.044.013.044.012.044.011.045.009.044.007.045.006.045.004.045.002.045.001.045v17l-.001.045-.002.045-.004.045-.006.045-.007.045-.009.044-.011.045-.012.044-.013.044-.015.044-.017.043-.018.044-.02.043-.021.043-.023.043-.024.043-.026.043-.027.042-.029.042-.03.042-.032.042-.033.042-.034.041-.036.041-.037.041-.039.041-.04.041-.041.04-.043.04-.044.04-.045.04-.047.039-.048.039-.05.039-.051.039-.052.038-.053.038-.055.038-.055.038-.058.037-.058.037-.06.037-.06.036-.062.036-.064.036-.064.036-.066.035-.067.035-.068.035-.069.035-.07.034-.071.034-.073.033-.074.033-.15.066-.155.064-.16.063-.163.061-.168.06-.172.059-.175.057-.18.056-.183.054-.187.053-.191.051-.194.05-.198.048-.201.046-.205.045-.208.043-.211.041-.214.04-.217.038-.22.036-.223.034-.225.032-.229.031-.231.028-.233.027-.236.024-.239.023-.241.02-.242.019-.246.016-.247.015-.249.012-.251.01-.253.008-.255.005-.256.004-.258.001-.258-.001-.256-.004-.255-.005-.253-.008-.251-.01-.249-.012-.247-.015-.245-.016-.243-.019-.241-.02-.238-.023-.236-.024-.234-.027-.231-.028-.228-.031-.226-.032-.223-.034-.22-.036-.217-.038-.214-.04-.211-.041-.208-.043-.204-.045-.201-.046-.198-.048-.195-.05-.19-.051-.187-.053-.184-.054-.179-.056-.176-.057-.172-.059-.167-.06-.164-.061-.159-.063-.155-.064-.151-.066-.074-.033-.072-.033-.072-.034-.07-.034-.069-.035-.068-.035-.067-.035-.066-.035-.064-.036-.063-.036-.062-.036-.061-.036-.06-.037-.058-.037-.057-.037-.056-.038-.055-.038-.053-.038-.052-.038-.051-.039-.049-.039-.049-.039-.046-.039-.046-.04-.044-.04-.043-.04-.041-.04-.04-.041-.039-.041-.037-.041-.036-.041-.034-.041-.033-.042-.032-.042-.03-.042-.029-.042-.027-.042-.026-.043-.024-.043-.023-.043-.021-.043-.02-.043-.018-.044-.017-.043-.015-.044-.013-.044-.012-.044-.011-.045-.009-.044-.007-.045-.006-.045-.004-.045-.002-.045-.001-.045v-17l.001-.045.002-.045.004-.045.006-.045.007-.045.009-.044.011-.045.012-.044.013-.044.015-.044.017-.043.018-.044.02-.043.021-.043.023-.043.024-.043.026-.043.027-.042.029-.042.03-.042.032-.042.033-.042.034-.041.036-.041.037-.041.039-.041.04-.041.041-.04.043-.04.044-.04.046-.04.046-.039.049-.039.049-.039.051-.039.052-.038.053-.038.055-.038.056-.038.057-.037.058-.037.06-.037.061-.036.062-.036.063-.036.064-.036.066-.035.067-.035.068-.035.069-.035.07-.034.072-.034.072-.033.074-.033.151-.066.155-.064.159-.063.164-.061.167-.06.172-.059.176-.057.179-.056.184-.054.187-.053.19-.051.195-.05.198-.048.201-.046.204-.045.208-.043.211-.041.214-.04.217-.038.22-.036.223-.034.226-.032.228-.031.231-.028.234-.027.236-.024.238-.023.241-.02.243-.019.245-.016.247-.015.249-.012.251-.01.253-.008.255-.005.256-.004.258-.001.258.001zm-9.258 20.499v.01l.001.021.003.021.004.022.005.021.006.022.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.023.018.024.019.024.021.024.022.025.023.024.024.025.052.049.056.05.061.051.066.051.07.051.075.051.079.052.084.052.088.052.092.052.097.052.102.051.105.052.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.048.144.049.147.047.152.047.155.047.16.045.163.045.167.043.171.043.176.041.178.041.183.039.187.039.19.037.194.035.197.035.202.033.204.031.209.03.212.029.216.027.219.025.222.024.226.021.23.02.233.018.236.016.24.015.243.012.246.01.249.008.253.005.256.004.259.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.021.224-.024.22-.026.216-.027.212-.028.21-.031.205-.031.202-.034.198-.034.194-.036.191-.037.187-.039.183-.04.179-.04.175-.042.172-.043.168-.044.163-.045.16-.046.155-.046.152-.047.148-.048.143-.049.139-.049.136-.05.131-.05.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.053.083-.051.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.05.023-.024.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.023.01-.022.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.127l-.077.055-.08.053-.083.054-.085.053-.087.052-.09.052-.093.051-.095.05-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.045-.118.044-.12.043-.122.042-.124.042-.126.041-.128.04-.13.04-.132.038-.134.038-.135.037-.138.037-.139.035-.142.035-.143.034-.144.033-.147.032-.148.031-.15.03-.151.03-.153.029-.154.027-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.01-.179.008-.179.008-.181.006-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.006-.179-.008-.179-.008-.178-.01-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.027-.153-.029-.151-.03-.15-.03-.148-.031-.146-.032-.145-.033-.143-.034-.141-.035-.14-.035-.137-.037-.136-.037-.134-.038-.132-.038-.13-.04-.128-.04-.126-.041-.124-.042-.122-.042-.12-.044-.117-.043-.116-.045-.113-.045-.112-.046-.109-.047-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.05-.093-.052-.09-.051-.087-.052-.085-.053-.083-.054-.08-.054-.077-.054v4.127zm0-5.654v.011l.001.021.003.021.004.021.005.022.006.022.007.022.009.022.01.022.011.023.012.023.013.023.015.024.016.023.017.024.018.024.019.024.021.024.022.024.023.025.024.024.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.052.11.051.114.051.119.052.123.05.127.051.131.05.135.049.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.044.171.042.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.022.23.02.233.018.236.016.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.012.241-.015.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.048.139-.05.136-.049.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.051.051-.049.023-.025.023-.024.021-.025.02-.024.019-.024.018-.024.017-.024.015-.023.014-.023.013-.024.012-.022.01-.023.01-.023.008-.022.006-.022.006-.022.004-.021.004-.022.001-.021.001-.021v-4.139l-.077.054-.08.054-.083.054-.085.052-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.044-.118.044-.12.044-.122.042-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.035-.143.033-.144.033-.147.033-.148.031-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.009-.179.009-.179.007-.181.007-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.007-.179-.007-.179-.009-.178-.009-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.031-.146-.033-.145-.033-.143-.033-.141-.035-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.04-.126-.041-.124-.042-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.051-.093-.051-.09-.051-.087-.053-.085-.052-.083-.054-.08-.054-.077-.054v4.139zm0-5.666v.011l.001.02.003.022.004.021.005.022.006.021.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.024.018.023.019.024.021.025.022.024.023.024.024.025.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.051.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.043.171.043.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.021.23.02.233.018.236.017.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.013.241-.014.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.049.139-.049.136-.049.131-.051.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.049.023-.025.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.022.01-.023.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.153l-.077.054-.08.054-.083.053-.085.053-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.048-.105.048-.106.048-.109.046-.111.046-.114.046-.115.044-.118.044-.12.043-.122.043-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.034-.143.034-.144.033-.147.032-.148.032-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.024-.161.024-.162.023-.163.023-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.01-.178.01-.179.009-.179.007-.181.006-.182.006-.182.004-.184.003-.184.001-.185.001-.185-.001-.184-.001-.184-.003-.182-.004-.182-.006-.181-.006-.179-.007-.179-.009-.178-.01-.176-.01-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.023-.162-.023-.161-.024-.159-.024-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.032-.146-.032-.145-.033-.143-.034-.141-.034-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.041-.126-.041-.124-.041-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.048-.105-.048-.102-.048-.1-.05-.097-.049-.095-.051-.093-.051-.09-.052-.087-.052-.085-.053-.083-.053-.08-.054-.077-.054v4.153zm8.74-8.179l-.257.004-.254.005-.25.008-.247.011-.244.012-.241.014-.237.016-.233.018-.231.021-.226.022-.224.023-.22.026-.216.027-.212.028-.21.031-.205.032-.202.033-.198.034-.194.036-.191.038-.187.038-.183.04-.179.041-.175.042-.172.043-.168.043-.163.045-.16.046-.155.046-.152.048-.148.048-.143.048-.139.049-.136.05-.131.05-.126.051-.123.051-.118.051-.114.052-.11.052-.106.052-.101.052-.096.052-.092.052-.088.052-.083.052-.079.052-.074.051-.07.052-.065.051-.06.05-.056.05-.051.05-.023.025-.023.024-.021.024-.02.025-.019.024-.018.024-.017.023-.015.024-.014.023-.013.023-.012.023-.01.023-.01.022-.008.022-.006.023-.006.021-.004.022-.004.021-.001.021-.001.021.001.021.001.021.004.021.004.022.006.021.006.023.008.022.01.022.01.023.012.023.013.023.014.023.015.024.017.023.018.024.019.024.02.025.021.024.023.024.023.025.051.05.056.05.06.05.065.051.07.052.074.051.079.052.083.052.088.052.092.052.096.052.101.052.106.052.11.052.114.052.118.051.123.051.126.051.131.05.136.05.139.049.143.048.148.048.152.048.155.046.16.046.163.045.168.043.172.043.175.042.179.041.183.04.187.038.191.038.194.036.198.034.202.033.205.032.21.031.212.028.216.027.22.026.224.023.226.022.231.021.233.018.237.016.241.014.244.012.247.011.25.008.254.005.257.004.26.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.022.224-.023.22-.026.216-.027.212-.028.21-.031.205-.032.202-.033.198-.034.194-.036.191-.038.187-.038.183-.04.179-.041.175-.042.172-.043.168-.043.163-.045.16-.046.155-.046.152-.048.148-.048.143-.048.139-.049.136-.05.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.05.051-.05.023-.025.023-.024.021-.024.02-.025.019-.024.018-.024.017-.023.015-.024.014-.023.013-.023.012-.023.01-.023.01-.022.008-.022.006-.023.006-.021.004-.022.004-.021.001-.021.001-.021-.001-.021-.001-.021-.004-.021-.004-.022-.006-.021-.006-.023-.008-.022-.01-.022-.01-.023-.012-.023-.013-.023-.014-.023-.015-.024-.017-.023-.018-.024-.019-.024-.02-.025-.021-.024-.023-.024-.023-.025-.051-.05-.056-.05-.06-.05-.065-.051-.07-.052-.074-.051-.079-.052-.083-.052-.088-.052-.092-.052-.096-.052-.101-.052-.106-.052-.11-.052-.114-.052-.118-.051-.123-.051-.126-.051-.131-.05-.136-.05-.139-.049-.143-.048-.148-.048-.152-.048-.155-.046-.16-.046-.163-.045-.168-.043-.172-.043-.175-.042-.179-.041-.183-.04-.187-.038-.191-.038-.194-.036-.198-.034-.202-.033-.205-.032-.21-.031-.212-.028-.216-.027-.22-.026-.224-.023-.226-.022-.231-.021-.233-.018-.237-.016-.241-.014-.244-.012-.247-.011-.25-.008-.254-.005-.257-.004-.26-.001-.26.001z");},Hs=function(t){t.append("defs").append("symbol").attr("id","computer").attr("width","24").attr("height","24").append("path").attr("transform","scale(.5)").attr("d","M2 2v13h20v-13h-20zm18 11h-16v-9h16v9zm-10.228 6l.466-1h3.524l.467 1h-4.457zm14.228 3h-24l2-6h2.104l-1.33 4h18.45l-1.297-4h2.073l2 6zm-5-10h-14v-7h14v7z");},Vs=function(t){t.append("defs").append("symbol").attr("id","clock").attr("width","24").attr("height","24").append("path").attr("transform","scale(.5)").attr("d","M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm5.848 12.459c.202.038.202.333.001.372-1.907.361-6.045 1.111-6.547 1.111-.719 0-1.301-.582-1.301-1.301 0-.512.77-5.447 1.125-7.445.034-.192.312-.181.343.014l.985 6.238 5.394 1.011z");},Gs=Ns,Xs=Os;je.N;var Zs={},Qs={data:{startx:void 0,stopx:void 0,starty:void 0,stopy:void 0},verticalPos:0,sequenceItems:[],activations:[],models:{getHeight:function(){return Math.max.apply(null,0===this.actors.length?[0]:this.actors.map((function(t){return t.height||0})))+(0===this.loops.length?0:this.loops.map((function(t){return t.height||0})).reduce((function(t,e){return t+e})))+(0===this.messages.length?0:this.messages.map((function(t){return t.height||0})).reduce((function(t,e){return t+e})))+(0===this.notes.length?0:this.notes.map((function(t){return t.height||0})).reduce((function(t,e){return t+e})))},clear:function(){this.actors=[],this.loops=[],this.messages=[],this.notes=[];},addActor:function(t){this.actors.push(t);},addLoop:function(t){this.loops.push(t);},addMessage:function(t){this.messages.push(t);},addNote:function(t){this.notes.push(t);},lastActor:function(){return this.actors[this.actors.length-1]},lastLoop:function(){return this.loops[this.loops.length-1]},lastMessage:function(){return this.messages[this.messages.length-1]},lastNote:function(){return this.notes[this.notes.length-1]},actors:[],loops:[],messages:[],notes:[]},init:function(){this.sequenceItems=[],this.activations=[],this.models.clear(),this.data={startx:void 0,stopx:void 0,starty:void 0,stopy:void 0},this.verticalPos=0,rc(Xt());},updateVal:function(t,e,n,r){void 0===t[e]?t[e]=n:t[e]=r(n,t[e]);},updateBounds:function(t,e,n,r){var i=this,a=0;function o(o){return function(s){a++;var c=i.sequenceItems.length-a+1;i.updateVal(s,"starty",e-c*Zs.boxMargin,Math.min),i.updateVal(s,"stopy",r+c*Zs.boxMargin,Math.max),i.updateVal(Qs.data,"startx",t-c*Zs.boxMargin,Math.min),i.updateVal(Qs.data,"stopx",n+c*Zs.boxMargin,Math.max),"activation"!==o&&(i.updateVal(s,"startx",t-c*Zs.boxMargin,Math.min),i.updateVal(s,"stopx",n+c*Zs.boxMargin,Math.max),i.updateVal(Qs.data,"starty",e-c*Zs.boxMargin,Math.min),i.updateVal(Qs.data,"stopy",r+c*Zs.boxMargin,Math.max));}}this.sequenceItems.forEach(o()),this.activations.forEach(o("activation"));},insert:function(t,e,n,r){var i=Math.min(t,n),a=Math.max(t,n),o=Math.min(e,r),s=Math.max(e,r);this.updateVal(Qs.data,"startx",i,Math.min),this.updateVal(Qs.data,"starty",o,Math.min),this.updateVal(Qs.data,"stopx",a,Math.max),this.updateVal(Qs.data,"stopy",s,Math.max),this.updateBounds(i,o,a,s);},newActivation:function(t,e,n){var r=n[t.from.actor],i=ic(t.from.actor).length||0,a=r.x+r.width/2+(i-1)*Zs.activationWidth/2;this.activations.push({startx:a,starty:this.verticalPos+2,stopx:a+Zs.activationWidth,stopy:void 0,actor:t.from.actor,anchored:Rs(e)});},endActivation:function(t){var e=this.activations.map((function(t){return t.actor})).lastIndexOf(t.from.actor);return this.activations.splice(e,1)[0]},createLoop:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{message:void 0,wrap:!1,width:void 0},e=arguments.length>1?arguments[1]:void 0;return {startx:void 0,starty:this.verticalPos,stopx:void 0,stopy:void 0,title:t.message,wrap:t.wrap,width:t.width,height:0,fill:e}},newLoop:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{message:void 0,wrap:!1,width:void 0},e=arguments.length>1?arguments[1]:void 0;this.sequenceItems.push(this.createLoop(t,e));},endLoop:function(){return this.sequenceItems.pop()},addSectionToLoop:function(t){var e=this.sequenceItems.pop();e.sections=e.sections||[],e.sectionTitles=e.sectionTitles||[],e.sections.push({y:Qs.getVerticalPos(),height:0}),e.sectionTitles.push(t),this.sequenceItems.push(e);},bumpVerticalPos:function(t){this.verticalPos=this.verticalPos+t,this.data.stopy=this.verticalPos;},getVerticalPos:function(){return this.verticalPos},getBounds:function(){return {bounds:this.data,models:this.models}}},Ks=function(t){return {fontFamily:t.messageFontFamily,fontSize:t.messageFontSize,fontWeight:t.messageFontWeight}},Js=function(t){return {fontFamily:t.noteFontFamily,fontSize:t.noteFontSize,fontWeight:t.noteFontWeight}},tc=function(t){return {fontFamily:t.actorFontFamily,fontSize:t.actorFontSize,fontWeight:t.actorFontWeight}},ec=function(t,e,n,r,i,a){if(!0===i.hideUnusedParticipants){var o=new Set;a.forEach((function(t){o.add(t.from),o.add(t.to);})),n=n.filter((function(t){return o.has(t)}));}for(var s=0,c=0,l=0,u=0;u<n.length;u++){var h=e[n[u]];h.width=h.width||Zs.width,h.height=Math.max(h.height||Zs.height,Zs.height),h.margin=h.margin||Zs.actorMargin,h.x=s+c,h.y=r;var f=Is(t,h,Zs);l=Math.max(l,f),Qs.insert(h.x,r,h.x+h.width,h.height),s+=h.width,c+=h.margin,Qs.models.addActor(h);}Qs.bumpVerticalPos(l);},nc=function(t,e,n,r){for(var i=0,a=0,o=0;o<n.length;o++){var s=e[n[o]],c=sc(s),l=Fs(t,s,c,Zs,Zs.forceMenus);l.height>i&&(i=l.height),l.width+s.x>a&&(a=l.width+s.x);}return {maxHeight:i,maxWidth:a}},rc=function(t){Q(Zs,t),t.fontFamily&&(Zs.actorFontFamily=Zs.noteFontFamily=Zs.messageFontFamily=t.fontFamily),t.fontSize&&(Zs.actorFontSize=Zs.noteFontSize=Zs.messageFontSize=t.fontSize),t.fontWeight&&(Zs.actorFontWeight=Zs.noteFontWeight=Zs.messageFontWeight=t.fontWeight);},ic=function(t){return Qs.activations.filter((function(e){return e.actor===t}))},ac=function(t,e){var n=e[t],r=ic(t);return [r.reduce((function(t,e){return Math.min(t,e.startx)}),n.x+n.width/2),r.reduce((function(t,e){return Math.max(t,e.stopx)}),n.x+n.width/2)]};function oc(t,e,n,r,i){Qs.bumpVerticalPos(n);var a=r;if(e.id&&e.message&&t[e.id]){var s=t[e.id].width,c=Ks(Zs);e.message=An.wrapLabel("[".concat(e.message,"]"),s-2*Zs.wrapPadding,c),e.width=s,e.wrap=!0;var l=An.calculateTextDimensions(e.message,c),u=Math.max(l.height,Zs.labelBoxHeight);a=r+u,o.debug("".concat(u," - ").concat(e.message));}i(e),Qs.bumpVerticalPos(a);}var sc=function(t){var e=0,n=tc(Zs);for(var r in t.links){var i=An.calculateTextDimensions(r,n).width+2*Zs.wrapPadding+2*Zs.boxMargin;e<i&&(e=i);}return e};const cc={bounds:Qs,drawActors:ec,drawActorsPopup:nc,setConf:rc,draw:function(t,e,n,r){Zs=Xt().sequence;var i,a=Xt().securityLevel;"sandbox"===a&&(i=(0, l.select)("#i"+e));var s="sandbox"===a?(0, l.select)(i.nodes()[0].contentDocument.body):(0, l.select)("body"),c="sandbox"===a?i.nodes()[0].contentDocument:document;Qs.init(),o.debug(r.db);var u="sandbox"===a?s.select('[id="'.concat(e,'"]')):(0, l.select)('[id="'.concat(e,'"]')),h=r.db.getActors(),f=r.db.getActorKeys(),d=r.db.getMessages(),p=r.db.getDiagramTitle(),g=function(t,e,n){var r={};return e.forEach((function(e){if(t[e.to]&&t[e.from]){var i=t[e.to];if(e.placement===n.db.PLACEMENT.LEFTOF&&!i.prevActor)return;if(e.placement===n.db.PLACEMENT.RIGHTOF&&!i.nextActor)return;var a=void 0!==e.placement,o=!a,s=a?Js(Zs):Ks(Zs),c=e.wrap?An.wrapLabel(e.message,Zs.width-2*Zs.wrapPadding,s):e.message,l=An.calculateTextDimensions(c,s).width+2*Zs.wrapPadding;o&&e.from===i.nextActor?r[e.to]=Math.max(r[e.to]||0,l):o&&e.from===i.prevActor?r[e.from]=Math.max(r[e.from]||0,l):o&&e.from===e.to?(r[e.from]=Math.max(r[e.from]||0,l/2),r[e.to]=Math.max(r[e.to]||0,l/2)):e.placement===n.db.PLACEMENT.RIGHTOF?r[e.from]=Math.max(r[e.from]||0,l):e.placement===n.db.PLACEMENT.LEFTOF?r[i.prevActor]=Math.max(r[i.prevActor]||0,l):e.placement===n.db.PLACEMENT.OVER&&(i.prevActor&&(r[i.prevActor]=Math.max(r[i.prevActor]||0,l/2)),i.nextActor&&(r[e.from]=Math.max(r[e.from]||0,l/2)));}})),o.debug("maxMessageWidthPerActor:",r),r}(h,d,r);Zs.height=function(t,e){var n=0;for(var r in Object.keys(t).forEach((function(e){var r=t[e];r.wrap&&(r.description=An.wrapLabel(r.description,Zs.width-2*Zs.wrapPadding,tc(Zs)));var i=An.calculateTextDimensions(r.description,tc(Zs));r.width=r.wrap?Zs.width:Math.max(Zs.width,i.width+2*Zs.wrapPadding),r.height=r.wrap?Math.max(i.height,Zs.height):Zs.height,n=Math.max(n,r.height);})),e){var i=t[r];if(i){var a=t[i.nextActor];if(a){var o=e[r]+Zs.actorMargin-i.width/2-a.width/2;i.margin=Math.max(o,Zs.actorMargin);}}}return Math.max(n,Zs.height)}(h,g),Hs(u),qs(u),Vs(u),ec(u,h,f,0,Zs,d);var y=function(t,e,n,r){var i,a,s,c={},l=[];return t.forEach((function(t){switch(t.id=An.random({length:10}),t.type){case r.db.LINETYPE.LOOP_START:case r.db.LINETYPE.ALT_START:case r.db.LINETYPE.OPT_START:case r.db.LINETYPE.PAR_START:case r.db.LINETYPE.CRITICAL_START:case r.db.LINETYPE.BREAK_START:l.push({id:t.id,msg:t.message,from:Number.MAX_SAFE_INTEGER,to:Number.MIN_SAFE_INTEGER,width:0});break;case r.db.LINETYPE.ALT_ELSE:case r.db.LINETYPE.PAR_AND:case r.db.LINETYPE.CRITICAL_OPTION:t.message&&(i=l.pop(),c[i.id]=i,c[t.id]=i,l.push(i));break;case r.db.LINETYPE.LOOP_END:case r.db.LINETYPE.ALT_END:case r.db.LINETYPE.OPT_END:case r.db.LINETYPE.PAR_END:case r.db.LINETYPE.CRITICAL_END:case r.db.LINETYPE.BREAK_END:i=l.pop(),c[i.id]=i;break;case r.db.LINETYPE.ACTIVE_START:var n=e[t.from?t.from.actor:t.to.actor],u=ic(t.from?t.from.actor:t.to.actor).length,h=n.x+n.width/2+(u-1)*Zs.activationWidth/2,f={startx:h,stopx:h+Zs.activationWidth,actor:t.from.actor,enabled:!0};Qs.activations.push(f);break;case r.db.LINETYPE.ACTIVE_END:var d=Qs.activations.map((function(t){return t.actor})).lastIndexOf(t.from.actor);delete Qs.activations.splice(d,1)[0];}void 0!==t.placement?(a=function(t,e,n){var r=e[t.from].x,i=e[t.to].x,a=t.wrap&&t.message,s=An.calculateTextDimensions(a?An.wrapLabel(t.message,Zs.width,Js(Zs)):t.message,Js(Zs)),c={width:a?Zs.width:Math.max(Zs.width,s.width+2*Zs.noteMargin),height:0,startx:e[t.from].x,stopx:0,starty:0,stopy:0,message:t.message};return t.placement===n.db.PLACEMENT.RIGHTOF?(c.width=a?Math.max(Zs.width,s.width):Math.max(e[t.from].width/2+e[t.to].width/2,s.width+2*Zs.noteMargin),c.startx=r+(e[t.from].width+Zs.actorMargin)/2):t.placement===n.db.PLACEMENT.LEFTOF?(c.width=a?Math.max(Zs.width,s.width+2*Zs.noteMargin):Math.max(e[t.from].width/2+e[t.to].width/2,s.width+2*Zs.noteMargin),c.startx=r-c.width+(e[t.from].width-Zs.actorMargin)/2):t.to===t.from?(s=An.calculateTextDimensions(a?An.wrapLabel(t.message,Math.max(Zs.width,e[t.from].width),Js(Zs)):t.message,Js(Zs)),c.width=a?Math.max(Zs.width,e[t.from].width):Math.max(e[t.from].width,Zs.width,s.width+2*Zs.noteMargin),c.startx=r+(e[t.from].width-c.width)/2):(c.width=Math.abs(r+e[t.from].width/2-(i+e[t.to].width/2))+Zs.actorMargin,c.startx=r<i?r+e[t.from].width/2-Zs.actorMargin/2:i+e[t.to].width/2-Zs.actorMargin/2),a&&(c.message=An.wrapLabel(t.message,c.width-2*Zs.wrapPadding,Js(Zs))),o.debug("NM:[".concat(c.startx,",").concat(c.stopx,",").concat(c.starty,",").concat(c.stopy,":").concat(c.width,",").concat(c.height,"=").concat(t.message,"]")),c}(t,e,r),t.noteModel=a,l.forEach((function(t){(i=t).from=Math.min(i.from,a.startx),i.to=Math.max(i.to,a.startx+a.width),i.width=Math.max(i.width,Math.abs(i.from-i.to))-Zs.labelBoxWidth;}))):(s=function(t,e,n){var r=!1;if([n.db.LINETYPE.SOLID_OPEN,n.db.LINETYPE.DOTTED_OPEN,n.db.LINETYPE.SOLID,n.db.LINETYPE.DOTTED,n.db.LINETYPE.SOLID_CROSS,n.db.LINETYPE.DOTTED_CROSS,n.db.LINETYPE.SOLID_POINT,n.db.LINETYPE.DOTTED_POINT].includes(t.type)&&(r=!0),!r)return {};var i=ac(t.from,e),a=ac(t.to,e),o=i[0]<=a[0]?1:0,s=i[0]<a[0]?0:1,c=i.concat(a),l=Math.abs(a[s]-i[o]);t.wrap&&t.message&&(t.message=An.wrapLabel(t.message,Math.max(l+2*Zs.wrapPadding,Zs.width),Ks(Zs)));var u=An.calculateTextDimensions(t.message,Ks(Zs));return {width:Math.max(t.wrap?0:u.width+2*Zs.wrapPadding,l+2*Zs.wrapPadding,Zs.width),height:0,startx:i[o],stopx:a[s],starty:0,stopy:0,message:t.message,type:t.type,wrap:t.wrap,fromBounds:Math.min.apply(null,c),toBounds:Math.max.apply(null,c)}}(t,e,r),t.msgModel=s,s.startx&&s.stopx&&l.length>0&&l.forEach((function(n){if(i=n,s.startx===s.stopx){var r=e[t.from],a=e[t.to];i.from=Math.min(r.x-s.width/2,r.x-r.width/2,i.from),i.to=Math.max(a.x+s.width/2,a.x+r.width/2,i.to),i.width=Math.max(i.width,Math.abs(i.to-i.from))-Zs.labelBoxWidth;}else i.from=Math.min(s.startx,i.from),i.to=Math.max(s.stopx,i.to),i.width=Math.max(i.width,s.width)-Zs.labelBoxWidth;})));})),Qs.activations=[],o.debug("Loop type widths:",c),c}(d,h,0,r);Ys(u),Ws(u),Us(u),$s(u);var m=1,b=1,v=Array();d.forEach((function(t){var e,n,i;switch(t.type){case r.db.LINETYPE.NOTE:n=t.noteModel,function(t,e){Qs.bumpVerticalPos(Zs.boxMargin),e.height=Zs.boxMargin,e.starty=Qs.getVerticalPos();var n=Xs();n.x=e.startx,n.y=e.starty,n.width=e.width||Zs.width,n.class="note";var r=t.append("g"),i=Ls(r,n),a=Gs();a.x=e.startx,a.y=e.starty,a.width=n.width,a.dy="1em",a.text=e.message,a.class="noteText",a.fontFamily=Zs.noteFontFamily,a.fontSize=Zs.noteFontSize,a.fontWeight=Zs.noteFontWeight,a.anchor=Zs.noteAlign,a.textMargin=Zs.noteMargin,a.valign="center";var o=Cs(r,a),s=Math.round(o.map((function(t){return (t._groups||t)[0][0].getBBox().height})).reduce((function(t,e){return t+e})));i.attr("height",s+2*Zs.noteMargin),e.height+=s+2*Zs.noteMargin,Qs.bumpVerticalPos(s+2*Zs.noteMargin),e.stopy=e.starty+s+2*Zs.noteMargin,e.stopx=e.startx+n.width,Qs.insert(e.startx,e.starty,e.stopx,e.stopy),Qs.models.addNote(e);}(u,n);break;case r.db.LINETYPE.ACTIVE_START:Qs.newActivation(t,u,h);break;case r.db.LINETYPE.ACTIVE_END:!function(t,e){var n=Qs.endActivation(t);n.starty+18>e&&(n.starty=e-6,e+=12),Ps(u,n,e,Zs,ic(t.from.actor).length),Qs.insert(n.startx,e-10,n.stopx,e);}(t,Qs.getVerticalPos());break;case r.db.LINETYPE.LOOP_START:oc(y,t,Zs.boxMargin,Zs.boxMargin+Zs.boxTextMargin,(function(t){return Qs.newLoop(t)}));break;case r.db.LINETYPE.LOOP_END:e=Qs.endLoop(),js(u,e,"loop",Zs),Qs.bumpVerticalPos(e.stopy-Qs.getVerticalPos()),Qs.models.addLoop(e);break;case r.db.LINETYPE.RECT_START:oc(y,t,Zs.boxMargin,Zs.boxMargin,(function(t){return Qs.newLoop(void 0,t.message)}));break;case r.db.LINETYPE.RECT_END:e=Qs.endLoop(),zs(u,e),Qs.models.addLoop(e),Qs.bumpVerticalPos(e.stopy-Qs.getVerticalPos());break;case r.db.LINETYPE.OPT_START:oc(y,t,Zs.boxMargin,Zs.boxMargin+Zs.boxTextMargin,(function(t){return Qs.newLoop(t)}));break;case r.db.LINETYPE.OPT_END:e=Qs.endLoop(),js(u,e,"opt",Zs),Qs.bumpVerticalPos(e.stopy-Qs.getVerticalPos()),Qs.models.addLoop(e);break;case r.db.LINETYPE.ALT_START:oc(y,t,Zs.boxMargin,Zs.boxMargin+Zs.boxTextMargin,(function(t){return Qs.newLoop(t)}));break;case r.db.LINETYPE.ALT_ELSE:oc(y,t,Zs.boxMargin+Zs.boxTextMargin,Zs.boxMargin,(function(t){return Qs.addSectionToLoop(t)}));break;case r.db.LINETYPE.ALT_END:e=Qs.endLoop(),js(u,e,"alt",Zs),Qs.bumpVerticalPos(e.stopy-Qs.getVerticalPos()),Qs.models.addLoop(e);break;case r.db.LINETYPE.PAR_START:oc(y,t,Zs.boxMargin,Zs.boxMargin+Zs.boxTextMargin,(function(t){return Qs.newLoop(t)}));break;case r.db.LINETYPE.PAR_AND:oc(y,t,Zs.boxMargin+Zs.boxTextMargin,Zs.boxMargin,(function(t){return Qs.addSectionToLoop(t)}));break;case r.db.LINETYPE.PAR_END:e=Qs.endLoop(),js(u,e,"par",Zs),Qs.bumpVerticalPos(e.stopy-Qs.getVerticalPos()),Qs.models.addLoop(e);break;case r.db.LINETYPE.AUTONUMBER:m=t.message.start||m,b=t.message.step||b,t.message.visible?r.db.enableSequenceNumbers():r.db.disableSequenceNumbers();break;case r.db.LINETYPE.CRITICAL_START:oc(y,t,Zs.boxMargin,Zs.boxMargin+Zs.boxTextMargin,(function(t){return Qs.newLoop(t)}));break;case r.db.LINETYPE.CRITICAL_OPTION:oc(y,t,Zs.boxMargin+Zs.boxTextMargin,Zs.boxMargin,(function(t){return Qs.addSectionToLoop(t)}));break;case r.db.LINETYPE.CRITICAL_END:e=Qs.endLoop(),js(u,e,"critical",Zs),Qs.bumpVerticalPos(e.stopy-Qs.getVerticalPos()),Qs.models.addLoop(e);break;case r.db.LINETYPE.BREAK_START:oc(y,t,Zs.boxMargin,Zs.boxMargin+Zs.boxTextMargin,(function(t){return Qs.newLoop(t)}));break;case r.db.LINETYPE.BREAK_END:e=Qs.endLoop(),js(u,e,"break",Zs),Qs.bumpVerticalPos(e.stopy-Qs.getVerticalPos()),Qs.models.addLoop(e);break;default:try{(i=t.msgModel).starty=Qs.getVerticalPos(),i.sequenceIndex=m,i.sequenceVisible=r.db.showSequenceNumbers();var a=function(t,e){Qs.bumpVerticalPos(10);var n,r=e.startx,i=e.stopx,a=e.message,o=ue.splitBreaks(a).length,s=An.calculateTextDimensions(a,Ks(Zs)),c=s.height/o;e.height+=c,Qs.bumpVerticalPos(c);var l=s.height-10,u=s.width;if(r===i){n=Qs.getVerticalPos()+l,Zs.rightAngles||(l+=Zs.boxMargin,n=Qs.getVerticalPos()+l),l+=30;var h=Math.max(u/2,Zs.width/2);Qs.insert(r-h,Qs.getVerticalPos()-10+l,i+h,Qs.getVerticalPos()+30+l);}else l+=Zs.boxMargin,n=Qs.getVerticalPos()+l,Qs.insert(r,n-10,i,n);return Qs.bumpVerticalPos(l),e.height+=l,e.stopy=e.starty+e.height,Qs.insert(e.fromBounds,e.starty,e.toBounds,e.stopy),n}(0,i);v.push({messageModel:i,lineStarty:a}),Qs.models.addMessage(i);}catch(t){o.error("error while drawing message",t);}}[r.db.LINETYPE.SOLID_OPEN,r.db.LINETYPE.DOTTED_OPEN,r.db.LINETYPE.SOLID,r.db.LINETYPE.DOTTED,r.db.LINETYPE.SOLID_CROSS,r.db.LINETYPE.DOTTED_CROSS,r.db.LINETYPE.SOLID_POINT,r.db.LINETYPE.DOTTED_POINT].includes(t.type)&&(m+=b);})),v.forEach((function(t){return function(t,e,n,r){var i=e.startx,a=e.stopx,o=e.starty,s=e.message,c=e.type,l=e.sequenceIndex,u=e.sequenceVisible,h=An.calculateTextDimensions(s,Ks(Zs)),f=Gs();f.x=i,f.y=o+10,f.width=a-i,f.class="messageText",f.dy="1em",f.text=s,f.fontFamily=Zs.messageFontFamily,f.fontSize=Zs.messageFontSize,f.fontWeight=Zs.messageFontWeight,f.anchor=Zs.messageAlign,f.valign="center",f.textMargin=Zs.wrapPadding,f.tspan=!1,Cs(t,f);var d,p=h.width;i===a?d=Zs.rightAngles?t.append("path").attr("d","M ".concat(i,",").concat(n," H ").concat(i+Math.max(Zs.width/2,p/2)," V ").concat(n+25," H ").concat(i)):t.append("path").attr("d","M "+i+","+n+" C "+(i+60)+","+(n-10)+" "+(i+60)+","+(n+30)+" "+i+","+(n+20)):((d=t.append("line")).attr("x1",i),d.attr("y1",n),d.attr("x2",a),d.attr("y2",n)),c===r.db.LINETYPE.DOTTED||c===r.db.LINETYPE.DOTTED_CROSS||c===r.db.LINETYPE.DOTTED_POINT||c===r.db.LINETYPE.DOTTED_OPEN?(d.style("stroke-dasharray","3, 3"),d.attr("class","messageLine1")):d.attr("class","messageLine0");var g="";Zs.arrowMarkerAbsolute&&(g=(g=(g=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search).replace(/\(/g,"\\(")).replace(/\)/g,"\\)")),d.attr("stroke-width",2),d.attr("stroke","none"),d.style("fill","none"),c!==r.db.LINETYPE.SOLID&&c!==r.db.LINETYPE.DOTTED||d.attr("marker-end","url("+g+"#arrowhead)"),c!==r.db.LINETYPE.SOLID_POINT&&c!==r.db.LINETYPE.DOTTED_POINT||d.attr("marker-end","url("+g+"#filled-head)"),c!==r.db.LINETYPE.SOLID_CROSS&&c!==r.db.LINETYPE.DOTTED_CROSS||d.attr("marker-end","url("+g+"#crosshead)"),(u||Zs.showSequenceNumbers)&&(d.attr("marker-start","url("+g+"#sequencenumber)"),t.append("text").attr("x",i).attr("y",n+4).attr("font-family","sans-serif").attr("font-size","12px").attr("text-anchor","middle").attr("class","sequenceNumber").text(l));}(u,t.messageModel,t.lineStarty,r)})),Zs.mirrorActors&&(Qs.bumpVerticalPos(2*Zs.boxMargin),ec(u,h,f,Qs.getVerticalPos(),Zs,d),Qs.bumpVerticalPos(Zs.boxMargin),Ms(u,Qs.getVerticalPos()));var _=nc(u,h,f),x=Qs.getBounds().bounds;o.debug("For line height fix Querying: #"+e+" .actor-line"),(0, l.selectAll)("#"+e+" .actor-line").attr("y2",x.stopy);var k=x.stopy-x.starty;k<_.maxHeight&&(k=_.maxHeight);var w=k+2*Zs.diagramMarginY;Zs.mirrorActors&&(w=w-Zs.boxMargin+Zs.bottomMarginAdj);var T=x.stopx-x.startx;T<_.maxWidth&&(T=_.maxWidth);var E=T+2*Zs.diagramMarginX;p&&u.append("text").text(p).attr("x",(x.stopx-x.startx)/2-2*Zs.diagramMarginX).attr("y",-25),Tn(u,0,E,Zs.useMaxWidth);var C=p?40:0;u.attr("viewBox",x.startx-Zs.diagramMarginX+" -"+(Zs.diagramMarginY+C)+" "+E+" "+(w+C)),Mn(r.db,u,e),o.debug("models:",Qs.models);}};var lc=n(3584),uc=n.n(lc);function hc(t){return hc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hc(t)}var fc=function(t){return JSON.parse(JSON.stringify(t))},dc=[],pc=function t(e,n,r){if("relation"===n.stmt)t(e,n.state1,!0),t(e,n.state2,!1);else if("state"===n.stmt&&"[*]"===n.id&&(n.id=r?e.id+"_start":e.id+"_end",n.start=r),n.doc){var i=[],a=0,o=[];for(a=0;a<n.doc.length;a++)if("divider"===n.doc[a].type){var s=fc(n.doc[a]);s.doc=fc(o),i.push(s),o=[];}else o.push(n.doc[a]);if(i.length>0&&o.length>0){var c={stmt:"state",id:gn(),type:"divider",doc:fc(o)};i.push(fc(c)),n.doc=i;}n.doc.forEach((function(e){return t(n,e,!0)}));}},gc={root:{relations:[],states:{},documents:{}}},yc=gc.root,mc=0,bc=function(t,e,n,r,i){void 0===yc.states[t]?yc.states[t]={id:t,descriptions:[],type:e,doc:n,note:i}:(yc.states[t].doc||(yc.states[t].doc=n),yc.states[t].type||(yc.states[t].type=e)),r&&(o.info("Adding state ",t,r),"string"==typeof r&&xc(t,r.trim()),"object"===hc(r)&&r.forEach((function(e){return xc(t,e.trim())}))),i&&(yc.states[t].note=i,yc.states[t].note.text=ue.sanitizeText(yc.states[t].note.text,Xt()));},vc=function(t){yc=(gc={root:{relations:[],states:{},documents:{}}}).root,yc=gc.root,mc=0,wc=[],t||ge();},_c=function(t,e,n){var r=t,i=e,a="default",o="default";"[*]"===t&&(r="start"+ ++mc,a="start"),"[*]"===e&&(i="end"+mc,o="end"),bc(r,a),bc(i,o),yc.relations.push({id1:r,id2:i,title:ue.sanitizeText(n,Xt())});},xc=function(t,e){var n=yc.states[t],r=e;":"===r[0]&&(r=r.substr(1).trim()),n.descriptions.push(ue.sanitizeText(r,Xt()));},kc=0,wc=[],Tc="TB";const Ec={parseDirective:function(t,e,n){cu.parseDirective(this,t,e,n);},getConfig:function(){return Xt().state},addState:bc,clear:vc,getState:function(t){return yc.states[t]},getStates:function(){return yc.states},getRelations:function(){return yc.relations},getClasses:function(){return wc},getDirection:function(){return Tc},addRelation:_c,getDividerId:function(){return "divider-id-"+ ++kc},setDirection:function(t){Tc=t;},cleanupLabel:function(t){return ":"===t.substring(0,1)?t.substr(2).trim():t.trim()},lineType:{LINE:0,DOTTED_LINE:1},relationType:{AGGREGATION:0,EXTENSION:1,COMPOSITION:2,DEPENDENCY:3},logDocuments:function(){o.info("Documents = ",gc);},getRootDoc:function(){return dc},setRootDoc:function(t){o.info("Setting root doc",t),dc=t;},getRootDocV2:function(){return pc({id:"root"},{id:"root",doc:dc},!0),{id:"root",doc:dc}},extract:function(t){var e;e=t.doc?t.doc:t,o.info(e),vc(!0),o.info("Extract",e),e.forEach((function(t){"state"===t.stmt&&bc(t.id,t.type,t.doc,t.description,t.note),"relation"===t.stmt&&_c(t.state1.id,t.state2.id,t.description);}));},trimColon:function(t){return t&&":"===t[0]?t.substr(1).trim():t.trim()},getAccTitle:me,setAccTitle:ye,getAccDescription:ve,setAccDescription:be};function Sc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var Ac,Mc=function(t,e,n){var r,i=Xt().state.padding,a=2*Xt().state.padding,o=t.node().getBBox(),s=o.width,c=o.x,l=t.append("text").attr("x",0).attr("y",Xt().state.titleShift).attr("font-size",Xt().state.fontSize).attr("class","state-title").text(e.id),u=l.node().getBBox().width+a,h=Math.max(u,s);h===s&&(h+=a);var f=t.node().getBBox();e.doc,r=c-i,u>s&&(r=(s-h)/2+i),Math.abs(c-f.x)<i&&u>s&&(r=c-(u-s)/2);var d=1-Xt().state.textHeight;return t.insert("rect",":first-child").attr("x",r).attr("y",d).attr("class",n?"alt-composit":"composit").attr("width",h).attr("height",f.height+Xt().state.textHeight+Xt().state.titleShift+1).attr("rx","0"),l.attr("x",r+i),u<=s&&l.attr("x",c+(h-a)/2-u/2+i),t.insert("rect",":first-child").attr("x",r).attr("y",Xt().state.titleShift-Xt().state.textHeight-Xt().state.padding).attr("width",h).attr("height",3*Xt().state.textHeight).attr("rx",Xt().state.radius),t.insert("rect",":first-child").attr("x",r).attr("y",Xt().state.titleShift-Xt().state.textHeight-Xt().state.padding).attr("width",h).attr("height",f.height+3+2*Xt().state.textHeight).attr("rx",Xt().state.radius),t},Nc=function(t,e){e.attr("class","state-note");var n=e.append("rect").attr("x",0).attr("y",Xt().state.padding),r=function(t,e,n,r){var i=0,a=r.append("text");a.style("text-anchor","start"),a.attr("class","noteText");var o,s=t.replace(/\r\n/g,"<br/>"),c=(s=s.replace(/\n/g,"<br/>")).split(ue.lineBreakRegex),l=1.25*Xt().state.noteMargin,u=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Sc(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return "Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Sc(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return {s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return {s:function(){n=n.call(t);},n:function(){var t=n.next();return o=t.done,t},e:function(t){s=!0,a=t;},f:function(){try{o||null==n.return||n.return();}finally{if(s)throw a}}}}(c);try{for(u.s();!(o=u.n()).done;){var h=o.value.trim();if(h.length>0){var f=a.append("tspan");f.text(h),0===l&&(l+=f.node().getBBox().height),i+=l,f.attr("x",0+Xt().state.noteMargin),f.attr("y",0+i+1.25*Xt().state.noteMargin);}}}catch(t){u.e(t);}finally{u.f();}return {textWidth:a.node().getBBox().width,textHeight:i}}(t,0,0,e.append("g")),i=r.textWidth,a=r.textHeight;return n.attr("height",a+2*Xt().state.noteMargin),n.attr("width",i+2*Xt().state.noteMargin),n},Oc=function(t,e){var n=e.id,r={id:n,label:e.id,width:0,height:0},i=t.append("g").attr("id",n).attr("class","stateGroup");"start"===e.type&&function(t){t.append("circle").attr("class","start-state").attr("r",Xt().state.sizeUnit).attr("cx",Xt().state.padding+Xt().state.sizeUnit).attr("cy",Xt().state.padding+Xt().state.sizeUnit);}(i),"end"===e.type&&function(t){t.append("circle").attr("class","end-state-outer").attr("r",Xt().state.sizeUnit+Xt().state.miniPadding).attr("cx",Xt().state.padding+Xt().state.sizeUnit+Xt().state.miniPadding).attr("cy",Xt().state.padding+Xt().state.sizeUnit+Xt().state.miniPadding),t.append("circle").attr("class","end-state-inner").attr("r",Xt().state.sizeUnit).attr("cx",Xt().state.padding+Xt().state.sizeUnit+2).attr("cy",Xt().state.padding+Xt().state.sizeUnit+2);}(i),"fork"!==e.type&&"join"!==e.type||function(t,e){var n=Xt().state.forkWidth,r=Xt().state.forkHeight;if(e.parentId){var i=n;n=r,r=i;}t.append("rect").style("stroke","black").style("fill","black").attr("width",n).attr("height",r).attr("x",Xt().state.padding).attr("y",Xt().state.padding);}(i,e),"note"===e.type&&Nc(e.note.text,i),"divider"===e.type&&function(t){t.append("line").style("stroke","grey").style("stroke-dasharray","3").attr("x1",Xt().state.textHeight).attr("class","divider").attr("x2",2*Xt().state.textHeight).attr("y1",0).attr("y2",0);}(i),"default"===e.type&&0===e.descriptions.length&&function(t,e){var n=t.append("text").attr("x",2*Xt().state.padding).attr("y",Xt().state.textHeight+2*Xt().state.padding).attr("font-size",Xt().state.fontSize).attr("class","state-title").text(e.id).node().getBBox();t.insert("rect",":first-child").attr("x",Xt().state.padding).attr("y",Xt().state.padding).attr("width",n.width+2*Xt().state.padding).attr("height",n.height+2*Xt().state.padding).attr("rx",Xt().state.radius);}(i,e),"default"===e.type&&e.descriptions.length>0&&function(t,e){var n=t.append("text").attr("x",2*Xt().state.padding).attr("y",Xt().state.textHeight+1.3*Xt().state.padding).attr("font-size",Xt().state.fontSize).attr("class","state-title").text(e.descriptions[0]).node().getBBox(),r=n.height,i=t.append("text").attr("x",Xt().state.padding).attr("y",r+.4*Xt().state.padding+Xt().state.dividerMargin+Xt().state.textHeight).attr("class","state-description"),a=!0,o=!0;e.descriptions.forEach((function(t){a||(function(t,e,n){var r=t.append("tspan").attr("x",2*Xt().state.padding).text(e);n||r.attr("dy",Xt().state.textHeight);}(i,t,o),o=!1),a=!1;}));var s=t.append("line").attr("x1",Xt().state.padding).attr("y1",Xt().state.padding+r+Xt().state.dividerMargin/2).attr("y2",Xt().state.padding+r+Xt().state.dividerMargin/2).attr("class","descr-divider"),c=i.node().getBBox(),l=Math.max(c.width,n.width);s.attr("x2",l+3*Xt().state.padding),t.insert("rect",":first-child").attr("x",Xt().state.padding).attr("y",Xt().state.padding).attr("width",l+2*Xt().state.padding).attr("height",c.height+r+2*Xt().state.padding).attr("rx",Xt().state.radius);}(i,e);var o=i.node().getBBox();return r.width=o.width+2*Xt().state.padding,r.height=o.height+2*Xt().state.padding,r},Dc=0,Bc={},Lc=function t(e,n,r,i,a,s,c){var u,h=new(yr().Graph)({compound:!0,multigraph:!0}),f=!0;for(u=0;u<e.length;u++)if("relation"===e[u].stmt){f=!1;break}r?h.setGraph({rankdir:"LR",multigraph:!0,compound:!0,ranker:"tight-tree",ranksep:f?1:Ac.edgeLengthFactor,nodeSep:f?1:50,isMultiGraph:!0}):h.setGraph({rankdir:"TB",multigraph:!0,compound:!0,ranksep:f?1:Ac.edgeLengthFactor,nodeSep:f?1:50,ranker:"tight-tree",isMultiGraph:!0}),h.setDefaultEdgeLabel((function(){return {}})),c.db.extract(e);for(var d=c.db.getStates(),p=c.db.getRelations(),g=Object.keys(d),y=0;y<g.length;y++){var m=d[g[y]];r&&(m.parentId=r);var b=void 0;if(m.doc){var v=n.append("g").attr("id",m.id).attr("class","stateGroup");b=t(m.doc,v,m.id,!i,a,s,c);var _=(v=Mc(v,m,i)).node().getBBox();b.width=_.width,b.height=_.height+Ac.padding/2,Bc[m.id]={y:Ac.compositTitleSize};}else b=Oc(n,m);if(m.note){var x={descriptions:[],id:m.id+"-note",note:m.note,type:"note"},k=Oc(n,x);"left of"===m.note.position?(h.setNode(b.id+"-note",k),h.setNode(b.id,b)):(h.setNode(b.id,b),h.setNode(b.id+"-note",k)),h.setParent(b.id,b.id+"-group"),h.setParent(b.id+"-note",b.id+"-group");}else h.setNode(b.id,b);}o.debug("Count=",h.nodeCount(),h);var w=0;p.forEach((function(t){var e;w++,o.debug("Setting edge",t),h.setEdge(t.id1,t.id2,{relation:t,width:(e=t.title,e?e.length*Ac.fontSizeFactor:1),height:Ac.labelHeight*ue.getRows(t.title).length,labelpos:"c"},"id"+w);})),pr().layout(h),o.debug("Graph after layout",h.nodes());var T=n.node();h.nodes().forEach((function(t){void 0!==t&&void 0!==h.node(t)?(o.warn("Node "+t+": "+JSON.stringify(h.node(t))),a.select("#"+T.id+" #"+t).attr("transform","translate("+(h.node(t).x-h.node(t).width/2)+","+(h.node(t).y+(Bc[t]?Bc[t].y:0)-h.node(t).height/2)+" )"),a.select("#"+T.id+" #"+t).attr("data-x-shift",h.node(t).x-h.node(t).width/2),s.querySelectorAll("#"+T.id+" #"+t+" .divider").forEach((function(t){var e=t.parentElement,n=0,r=0;e&&(e.parentElement&&(n=e.parentElement.getBBox().width),r=parseInt(e.getAttribute("data-x-shift"),10),Number.isNaN(r)&&(r=0)),t.setAttribute("x1",0-r+8),t.setAttribute("x2",n-r-8);}))):o.debug("No Node "+t+": "+JSON.stringify(h.node(t)));}));var E=T.getBBox();h.edges().forEach((function(t){void 0!==t&&void 0!==h.edge(t)&&(o.debug("Edge "+t.v+" -> "+t.w+": "+JSON.stringify(h.edge(t))),function(t,e,n){e.points=e.points.filter((function(t){return !Number.isNaN(t.y)}));var r=e.points,i=(0, l.line)().x((function(t){return t.x})).y((function(t){return t.y})).curve(l.curveBasis),a=t.append("path").attr("d",i(r)).attr("id","edge"+Dc).attr("class","transition"),s="";if(Xt().state.arrowMarkerAbsolute&&(s=(s=(s=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search).replace(/\(/g,"\\(")).replace(/\)/g,"\\)")),a.attr("marker-end","url("+s+"#"+function(t){switch(t){case Ec.relationType.AGGREGATION:return "aggregation";case Ec.relationType.EXTENSION:return "extension";case Ec.relationType.COMPOSITION:return "composition";case Ec.relationType.DEPENDENCY:return "dependency"}}(Ec.relationType.DEPENDENCY)+"End)"),void 0!==n.title){for(var c=t.append("g").attr("class","stateLabel"),u=An.calcLabelPosition(e.points),h=u.x,f=u.y,d=ue.getRows(n.title),p=0,g=[],y=0,m=0,b=0;b<=d.length;b++){var v=c.append("text").attr("text-anchor","middle").text(d[b]).attr("x",h).attr("y",f+p),_=v.node().getBBox();if(y=Math.max(y,_.width),m=Math.min(m,_.x),o.info(_.x,h,f+p),0===p){var x=v.node().getBBox();p=x.height,o.info("Title height",p,f);}g.push(v);}var k=p*d.length;if(d.length>1){var w=(d.length-1)*p*.5;g.forEach((function(t,e){return t.attr("y",f+e*p-w)})),k=p*d.length;}var T=c.node().getBBox();c.insert("rect",":first-child").attr("class","box").attr("x",h-y/2-Xt().state.padding/2).attr("y",f-k/2-Xt().state.padding/2-3.5).attr("width",y+Xt().state.padding).attr("height",k+Xt().state.padding),o.info(T);}Dc++;}(n,h.edge(t),h.edge(t).relation));})),E=T.getBBox();var C={id:r||"root",label:r||"root",width:0,height:0};return C.width=E.width+2*Ac.padding,C.height=E.height+2*Ac.padding,o.debug("Doc rendered",C,h),C};const Ic={setConf:function(){},draw:function(t,e,n,r){Ac=Xt().state;var i,a=Xt().securityLevel;"sandbox"===a&&(i=(0, l.select)("#i"+e));var s="sandbox"===a?(0, l.select)(i.nodes()[0].contentDocument.body):(0, l.select)("body"),c="sandbox"===a?i.nodes()[0].contentDocument:document;o.debug("Rendering diagram "+t);var u=s.select("[id='".concat(e,"']"));u.append("defs").append("marker").attr("id","dependencyEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 19,7 L9,13 L14,7 L9,1 Z"),new(yr().Graph)({multigraph:!0,compound:!0,rankdir:"RL"}).setDefaultEdgeLabel((function(){return {}}));var h=r.db.getRootDoc();Lc(h,u,void 0,!1,s,c,r);var f=Ac.padding,d=u.node().getBBox(),p=d.width+2*f,g=d.height+2*f;Tn(u,0,1.75*p,Ac.useMaxWidth),u.attr("viewBox","".concat(d.x-Ac.padding," ").concat(d.y-Ac.padding," ")+p+" "+g),Mn(r.db,u,e);}};var Fc={},Rc={},Pc=function(t,e,n,r){if("root"!==n.id){var i="rect";!0===n.start&&(i="start"),!1===n.start&&(i="end"),"default"!==n.type&&(i=n.type),Rc[n.id]||(Rc[n.id]={id:n.id,shape:i,description:ue.sanitizeText(n.id,Xt()),classes:"statediagram-state"}),n.description&&(Array.isArray(Rc[n.id].description)?(Rc[n.id].shape="rectWithTitle",Rc[n.id].description.push(n.description)):Rc[n.id].description.length>0?(Rc[n.id].shape="rectWithTitle",Rc[n.id].description===n.id?Rc[n.id].description=[n.description]:Rc[n.id].description=[Rc[n.id].description,n.description]):(Rc[n.id].shape="rect",Rc[n.id].description=n.description),Rc[n.id].description=ue.sanitizeTextOrArray(Rc[n.id].description,Xt())),1===Rc[n.id].description.length&&"rectWithTitle"===Rc[n.id].shape&&(Rc[n.id].shape="rect"),!Rc[n.id].type&&n.doc&&(o.info("Setting cluster for ",n.id,Yc(n)),Rc[n.id].type="group",Rc[n.id].dir=Yc(n),Rc[n.id].shape="divider"===n.type?"divider":"roundedWithTitle",Rc[n.id].classes=Rc[n.id].classes+" "+(r?"statediagram-cluster statediagram-cluster-alt":"statediagram-cluster"));var a={labelStyle:"",shape:Rc[n.id].shape,labelText:Rc[n.id].description,classes:Rc[n.id].classes,style:"",id:n.id,dir:Rc[n.id].dir,domId:"state-"+n.id+"-"+jc,type:Rc[n.id].type,padding:15};if(n.note){var s={labelStyle:"",shape:"note",labelText:n.note.text,classes:"statediagram-note",style:"",id:n.id+"----note-"+jc,domId:"state-"+n.id+"----note-"+jc,type:Rc[n.id].type,padding:15},c={labelStyle:"",shape:"noteGroup",labelText:n.note.text,classes:Rc[n.id].classes,style:"",id:n.id+"----parent",domId:"state-"+n.id+"----parent-"+jc,type:"group",padding:0};jc++,t.setNode(n.id+"----parent",c),t.setNode(s.id,s),t.setNode(n.id,a),t.setParent(n.id,n.id+"----parent"),t.setParent(s.id,n.id+"----parent");var l=n.id,u=s.id;"left of"===n.note.position&&(l=s.id,u=n.id),t.setEdge(l,u,{arrowhead:"none",arrowType:"",style:"fill:none",labelStyle:"",classes:"transition note-edge",arrowheadStyle:"fill: #333",labelpos:"c",labelType:"text",thickness:"normal"});}else t.setNode(n.id,a);}e&&"root"!==e.id&&(o.trace("Setting node ",n.id," to be child of its parent ",e.id),t.setParent(n.id,e.id)),n.doc&&(o.trace("Adding nodes children "),zc(t,n,n.doc,!r));},jc=0,zc=function(t,e,n,r){o.trace("items",n),n.forEach((function(n){if("state"===n.stmt||"default"===n.stmt)Pc(t,e,n,r);else if("relation"===n.stmt){Pc(t,e,n.state1,r),Pc(t,e,n.state2,r);var i={id:"edge"+jc,arrowhead:"normal",arrowTypeEnd:"arrow_barb",style:"fill:none",labelStyle:"",label:ue.sanitizeText(n.description,Xt()),arrowheadStyle:"fill: #333",labelpos:"c",labelType:"text",thickness:"normal",classes:"transition"},a=n.state1.id,o=n.state2.id;t.setEdge(a,o,i,jc),jc++;}}));},Yc=function(t,e){var n=e||"TB";if(t.doc)for(var r=0;r<t.doc.length;r++){var i=t.doc[r];"dir"===i.stmt&&(n=i.value);}return n};const Uc={setConf:function(t){for(var e=Object.keys(t),n=0;n<e.length;n++)Fc[e[n]]=t[e[n]];},getClasses:function(t,e){return o.trace("Extracting classes"),e.sb.clear(),e.parser.parse(t),e.sb.getClasses()},draw:function(t,e,n,r){o.info("Drawing state diagram (v2)",e),Rc={};var i=r.db.getDirection();void 0===i&&(i="LR");var a=Xt().state,s=a.nodeSpacing||50,c=a.rankSpacing||50,u=Xt().securityLevel;o.info(r.db.getRootDocV2()),r.db.extract(r.db.getRootDocV2()),o.info(r.db.getRootDocV2());var h,f=new(yr().Graph)({multigraph:!0,compound:!0}).setGraph({rankdir:Yc(r.db.getRootDocV2()),nodesep:s,ranksep:c,marginx:8,marginy:8}).setDefaultEdgeLabel((function(){return {}}));Pc(f,void 0,r.db.getRootDocV2(),!0),"sandbox"===u&&(h=(0, l.select)("#i"+e));var d="sandbox"===u?(0, l.select)(h.nodes()[0].contentDocument.body):(0, l.select)("body"),p=("sandbox"===u?h.nodes()[0].contentDocument:document,d.select('[id="'.concat(e,'"]'))),g=d.select("#"+e+" g");yi(g,f,["barb"],"statediagram",e);var y=p.node().getBBox(),m=y.width+16,b=y.height+16;p.attr("class","statediagram");var v=p.node().getBBox();Tn(p,0,m,a.useMaxWidth);var _="".concat(v.x-8," ").concat(v.y-8," ").concat(m," ").concat(b);o.debug("viewBox ".concat(_)),p.attr("viewBox",_);for(var x=document.querySelectorAll('[id="'+e+'"] .edgeLabel .label'),k=0;k<x.length;k++){var w=x[k],T=w.getBBox(),E=document.createElementNS("http://www.w3.org/2000/svg","rect");E.setAttribute("rx",0),E.setAttribute("ry",0),E.setAttribute("width",T.width),E.setAttribute("height",T.height),w.insertBefore(E,w.firstChild);}Mn(r.db,p,e);}};function $c(t){return function(t){if(Array.isArray(t))return Wc(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Wc(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return "Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Wc(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Wc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var qc="",Hc=[],Vc=[],Gc=[],Xc=function(){for(var t=!0,e=0;e<Gc.length;e++)Gc[e].processed,t=t&&Gc[e].processed;return t};const Zc={parseDirective:function(t,e,n){cu.parseDirective(this,t,e,n);},getConfig:function(){return Xt().journey},clear:function(){Hc.length=0,Vc.length=0,qc="",Gc.length=0,ge();},setDiagramTitle:_e,getDiagramTitle:xe,setAccTitle:ye,getAccTitle:me,setAccDescription:be,getAccDescription:ve,addSection:function(t){qc=t,Hc.push(t);},getSections:function(){return Hc},getTasks:function(){for(var t=Xc(),e=0;!t&&e<100;)t=Xc(),e++;return Vc.push.apply(Vc,Gc),Vc},addTask:function(t,e){var n=e.substr(1).split(":"),r=0,i=[];1===n.length?(r=Number(n[0]),i=[]):(r=Number(n[0]),i=n[1].split(","));var a=i.map((function(t){return t.trim()})),o={section:qc,type:qc,people:a,task:t,score:r};Gc.push(o);},addTaskOrg:function(t){var e={section:qc,type:qc,description:t,task:t,classes:[]};Vc.push(e);},getActors:function(){return t=[],Vc.forEach((function(e){e.people&&t.push.apply(t,$c(e.people));})),$c(new Set(t)).sort();var t;}};var Qc=function(t,e){var n=t.append("rect");return n.attr("x",e.x),n.attr("y",e.y),n.attr("fill",e.fill),n.attr("stroke",e.stroke),n.attr("width",e.width),n.attr("height",e.height),n.attr("rx",e.rx),n.attr("ry",e.ry),void 0!==e.class&&n.attr("class",e.class),n},Kc=function(t,e){var n=t.append("circle");return n.attr("cx",e.cx),n.attr("cy",e.cy),n.attr("class","actor-"+e.pos),n.attr("fill",e.fill),n.attr("stroke",e.stroke),n.attr("r",e.r),void 0!==n.class&&n.attr("class",n.class),void 0!==e.title&&n.append("title").text(e.title),n},Jc=-1,tl=function(){function t(t,e,n,i,a,o,s,c){r(e.append("text").attr("x",n+a/2).attr("y",i+o/2+5).style("font-color",c).style("text-anchor","middle").text(t),s);}function e(t,e,n,i,a,o,s,c,l){for(var u=c.taskFontSize,h=c.taskFontFamily,f=t.split(/<br\s*\/?>/gi),d=0;d<f.length;d++){var p=d*u-u*(f.length-1)/2,g=e.append("text").attr("x",n+a/2).attr("y",i).attr("fill",l).style("text-anchor","middle").style("font-size",u).style("font-family",h);g.append("tspan").attr("x",n+a/2).attr("dy",p).text(f[d]),g.attr("y",i+o/2).attr("dominant-baseline","central").attr("alignment-baseline","central"),r(g,s);}}function n(t,n,i,a,o,s,c,l){var u=n.append("switch"),h=u.append("foreignObject").attr("x",i).attr("y",a).attr("width",o).attr("height",s).attr("position","fixed").append("xhtml:div").style("display","table").style("height","100%").style("width","100%");h.append("div").attr("class","label").style("display","table-cell").style("text-align","center").style("vertical-align","middle").text(t),e(t,u,i,a,o,s,c,l),r(h,c);}function r(t,e){for(var n in e)n in e&&t.attr(n,e[n]);}return function(r){return "fo"===r.textPlacement?n:"old"===r.textPlacement?t:e}}();const el=Kc,nl=function(t,e,n){var r=t.append("g"),i={x:0,y:0,width:100,anchor:"start",height:100,rx:0,ry:0};i.x=e.x,i.y=e.y,i.fill=e.fill,i.width=n.width,i.height=n.height,i.class="journey-section section-type-"+e.num,i.rx=3,i.ry=3,Qc(r,i),tl(n)(e.text,r,i.x,i.y,i.width,i.height,{class:"journey-section section-type-"+e.num},n,e.colour);},rl=function(t,e){var n=e.text.replace(/<br\s*\/?>/gi," "),r=t.append("text");r.attr("x",e.x),r.attr("y",e.y),r.attr("class","legend"),r.style("text-anchor",e.anchor),void 0!==e.class&&r.attr("class",e.class);var i=r.append("tspan");return i.attr("x",e.x+2*e.textMargin),i.text(n),r},il=function(t,e,n){var r,i,a,o=e.x+n.width/2,s=t.append("g");Jc++,s.append("line").attr("id","task"+Jc).attr("x1",o).attr("y1",e.y).attr("x2",o).attr("y2",450).attr("class","task-line").attr("stroke-width","1px").attr("stroke-dasharray","4 2").attr("stroke","#666"),r=s,i={cx:o,cy:300+30*(5-e.score),score:e.score},r.append("circle").attr("cx",i.cx).attr("cy",i.cy).attr("class","face").attr("r",15).attr("stroke-width",2).attr("overflow","visible"),(a=r.append("g")).append("circle").attr("cx",i.cx-5).attr("cy",i.cy-5).attr("r",1.5).attr("stroke-width",2).attr("fill","#666").attr("stroke","#666"),a.append("circle").attr("cx",i.cx+5).attr("cy",i.cy-5).attr("r",1.5).attr("stroke-width",2).attr("fill","#666").attr("stroke","#666"),i.score>3?function(t){var e=(0, l.arc)().startAngle(Math.PI/2).endAngle(Math.PI/2*3).innerRadius(7.5).outerRadius(15/2.2);t.append("path").attr("class","mouth").attr("d",e).attr("transform","translate("+i.cx+","+(i.cy+2)+")");}(a):i.score<3?function(t){var e=(0, l.arc)().startAngle(3*Math.PI/2).endAngle(Math.PI/2*5).innerRadius(7.5).outerRadius(15/2.2);t.append("path").attr("class","mouth").attr("d",e).attr("transform","translate("+i.cx+","+(i.cy+7)+")");}(a):function(t){t.append("line").attr("class","mouth").attr("stroke",2).attr("x1",i.cx-5).attr("y1",i.cy+7).attr("x2",i.cx+5).attr("y2",i.cy+7).attr("class","mouth").attr("stroke-width","1px").attr("stroke","#666");}(a);var c={x:0,y:0,width:100,anchor:"start",height:100,rx:0,ry:0};c.x=e.x,c.y=e.y,c.fill=e.fill,c.width=n.width,c.height=n.height,c.class="task task-type-"+e.num,c.rx=3,c.ry=3,Qc(s,c);var u=e.x+14;e.people.forEach((function(t){var n=e.actors[t].color,r={cx:u,cy:e.y,r:7,fill:n,stroke:"#000",title:t,pos:e.actors[t].position};Kc(s,r),u+=10;})),tl(n)(e.task,s,c.x,c.y,c.width,c.height,{class:"task"},n,e.colour);};var al={},ol=Xt().journey,sl=Xt().journey.leftMargin,cl={data:{startx:void 0,stopx:void 0,starty:void 0,stopy:void 0},verticalPos:0,sequenceItems:[],init:function(){this.sequenceItems=[],this.data={startx:void 0,stopx:void 0,starty:void 0,stopy:void 0},this.verticalPos=0;},updateVal:function(t,e,n,r){void 0===t[e]?t[e]=n:t[e]=r(n,t[e]);},updateBounds:function(t,e,n,r){var i=Xt().journey,a=this,o=0;this.sequenceItems.forEach((function(s){o++;var c=a.sequenceItems.length-o+1;a.updateVal(s,"starty",e-c*i.boxMargin,Math.min),a.updateVal(s,"stopy",r+c*i.boxMargin,Math.max),a.updateVal(cl.data,"startx",t-c*i.boxMargin,Math.min),a.updateVal(cl.data,"stopx",n+c*i.boxMargin,Math.max),a.updateVal(s,"startx",t-c*i.boxMargin,Math.min),a.updateVal(s,"stopx",n+c*i.boxMargin,Math.max),a.updateVal(cl.data,"starty",e-c*i.boxMargin,Math.min),a.updateVal(cl.data,"stopy",r+c*i.boxMargin,Math.max);}));},insert:function(t,e,n,r){var i=Math.min(t,n),a=Math.max(t,n),o=Math.min(e,r),s=Math.max(e,r);this.updateVal(cl.data,"startx",i,Math.min),this.updateVal(cl.data,"starty",o,Math.min),this.updateVal(cl.data,"stopx",a,Math.max),this.updateVal(cl.data,"stopy",s,Math.max),this.updateBounds(i,o,a,s);},bumpVerticalPos:function(t){this.verticalPos=this.verticalPos+t,this.data.stopy=this.verticalPos;},getVerticalPos:function(){return this.verticalPos},getBounds:function(){return this.data}},ll=ol.sectionFills,ul=ol.sectionColours;const hl={setConf:function(t){Object.keys(t).forEach((function(e){ol[e]=t[e];}));},draw:function(t,e,n,r){var i=Xt().journey;r.db.clear(),r.parser.parse(t+"\n");var a,o=Xt().securityLevel;"sandbox"===o&&(a=(0, l.select)("#i"+e));var s="sandbox"===o?(0, l.select)(a.nodes()[0].contentDocument.body):(0, l.select)("body");cl.init();var c=s.select("#"+e);c.append("defs").append("marker").attr("id","arrowhead").attr("refX",5).attr("refY",2).attr("markerWidth",6).attr("markerHeight",4).attr("orient","auto").append("path").attr("d","M 0,0 V 4 L6,2 Z");var u=r.db.getTasks(),h=r.db.getDiagramTitle(),f=r.db.getActors();for(var d in al)delete al[d];var p=0;f.forEach((function(t){al[t]={color:i.actorColours[p%i.actorColours.length],position:p},p++;})),function(t){var e=Xt().journey,n=60;Object.keys(al).forEach((function(r){var i=al[r].color,a={cx:20,cy:n,r:7,fill:i,stroke:"#000",pos:al[r].position};el(t,a);var o={x:40,y:n+7,fill:"#666",text:r,textMargin:5|e.boxTextMargin};rl(t,o),n+=20;}));}(c),cl.insert(0,0,sl,50*Object.keys(al).length),function(t,e,n){for(var r=Xt().journey,i="",a=n+(2*r.height+r.diagramMarginY),o=0,s="#CCC",c="black",l=0,u=0;u<e.length;u++){var h=e[u];if(i!==h.section){s=ll[o%ll.length],l=o%ll.length,c=ul[o%ul.length];var f={x:u*r.taskMargin+u*r.width+sl,y:50,text:h.section,fill:s,num:l,colour:c};nl(t,f,r),i=h.section,o++;}var d=h.people.reduce((function(t,e){return al[e]&&(t[e]=al[e]),t}),{});h.x=u*r.taskMargin+u*r.width+sl,h.y=a,h.width=r.diagramMarginX,h.height=r.diagramMarginY,h.colour=c,h.fill=s,h.num=l,h.actors=d,il(t,h,r),cl.insert(h.x,h.y,h.x+h.width+r.taskMargin,450);}}(c,u,0);var g=cl.getBounds();h&&c.append("text").text(h).attr("x",sl).attr("font-size","4ex").attr("font-weight","bold").attr("y",25);var y=g.stopy-g.starty+2*i.diagramMarginY,m=sl+g.stopx+2*i.diagramMarginX;Tn(c,0,m,i.useMaxWidth),c.append("line").attr("x1",sl).attr("y1",4*i.height).attr("x2",m-sl-4).attr("y2",4*i.height).attr("stroke-width",4).attr("stroke","black").attr("marker-end","url(#arrowhead)");var b=h?70:0;c.attr("viewBox","".concat(g.startx," -25 ").concat(m," ").concat(y+b)),c.attr("preserveAspectRatio","xMinYMin meet"),c.attr("height",y+b+25),Mn(r.db,c,e);}};var fl=n(9763),dl=n.n(fl),pl={c4:{db:Pe,renderer:Zn,parser:He(),init:function(t){Zn.setConf(t.c4);}},class:{db:fr,renderer:Sr,parser:xi(),init:function(t){t.class.arrowMarkerAbsolute=t.arrowMarkerAbsolute,fr.clear();}},error:{db:{},renderer:Bi,parser:{parser:{yy:{}},parse:function(){}},init:function(){}},classDiagram:{db:fr,renderer:vi,parser:xi(),init:function(t){t.class.arrowMarkerAbsolute=t.arrowMarkerAbsolute,fr.clear();}},er:{db:Ei,renderer:Oi,parser:Ii()},flowchart:{db:la,renderer:Na,parser:Fa(),init:function(t){Na.setConf(t.flowchart),t.flowchart.arrowMarkerAbsolute=t.arrowMarkerAbsolute,la.clear(),la.setGen("gen-1");}},"flowchart-v2":{db:la,renderer:La,parser:Fa(),init:function(t){La.setConf(t.flowchart),t.flowchart.arrowMarkerAbsolute=t.arrowMarkerAbsolute,la.clear(),la.setGen("gen-2");}},gantt:{db:go,renderer:bo,parser:_o(),init:function(t){bo.setConf(t.gantt);}},info:{db:wo,renderer:To,parser:Co()},pie:{db:Oo,renderer:Lo,parser:Ao()},requirement:{db:Uo,renderer:Qo,parser:Fo()},sequence:{db:bs,renderer:cc,parser:ts(),init:function(t){t.sequence.arrowMarkerAbsolute=t.arrowMarkerAbsolute,t.sequenceDiagram&&(cc.setConf(Object.assign(t.sequence,t.sequenceDiagram)),console.error("`mermaid config.sequenceDiagram` has been renamed to `config.sequence`. Please update your mermaid config.")),bs.setWrap(t.wrap),cc.setConf(t.sequence);}},state:{db:Ec,renderer:Ic,parser:uc(),init:function(t){t.class.arrowMarkerAbsolute=t.arrowMarkerAbsolute,Ec.clear();}},stateDiagram:{db:Ec,renderer:Uc,parser:uc(),init:function(t){t.class.arrowMarkerAbsolute=t.arrowMarkerAbsolute,Ec.clear();}},journey:{db:Zc,renderer:hl,parser:dl(),init:function(t){hl.setConf(t.journey),Zc.clear();}}},gl=function(){return pl};function yl(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r);}return n}function ml(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?yl(Object(n),!0).forEach((function(e){bl(t,e,n[e]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yl(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e));}));}return t}function bl(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var vl=Xt().gitGraph.mainBranchName,_l=Xt().gitGraph.mainBranchOrder,xl={},kl=null,wl={};wl[vl]={name:vl,order:_l};var Tl={};Tl[vl]=kl;var El=vl,Cl="LR",Sl=0;function Al(){return yn({length:7})}var Ml={},Nl=function(t){if(t=ue.sanitizeText(t,Xt()),void 0===Tl[t]){var e=new Error('Trying to checkout branch which is not yet created. (Help try using "branch '+t+'")');throw e.hash={text:"checkout "+t,token:"checkout "+t,line:"1",loc:{first_line:1,last_line:1,first_column:1,last_column:1},expected:['"branch '+t+'"']},e}var n=Tl[El=t];kl=xl[n];};function Ol(t,e,n){var r=t.indexOf(e);-1===r?t.push(n):t.splice(r,1,n);}function Dl(t){var e=t.reduce((function(t,e){return t.seq>e.seq?t:e}),t[0]),n="";t.forEach((function(t){n+=t===e?"\t*":"\t|";}));var r,i,a,s=[n,e.id,e.seq];for(var c in Tl)Tl[c]===e.id&&s.push(c);if(o.debug(s.join(" ")),e.parents&&2==e.parents.length){var l=xl[e.parents[0]];Ol(t,e,l),t.push(xl[e.parents[1]]);}else {if(0==e.parents.length)return;var u=xl[e.parents];Ol(t,e,u);}r=t,i=function(t){return t.id},a=Object.create(null),Dl(t=r.reduce((function(t,e){var n=i(e);return a[n]||(a[n]=!0,t.push(e)),t}),[]));}var Bl=function(){var t=Object.keys(xl).map((function(t){return xl[t]}));return t.forEach((function(t){o.debug(t.id);})),t.sort((function(t,e){return t.seq-e.seq})),t},Ll={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4};const Il={parseDirective:function(t,e,n){cu.parseDirective(this,t,e,n);},getConfig:function(){return Xt().gitGraph},setDirection:function(t){Cl=t;},setOptions:function(t){o.debug("options str",t),t=(t=t&&t.trim())||"{}";try{Ml=JSON.parse(t);}catch(t){o.error("error while parsing gitGraph options",t.message);}},getOptions:function(){return Ml},commit:function(t,e,n,r){o.debug("Entering commit:",t,e,n,r),e=ue.sanitizeText(e,Xt()),t=ue.sanitizeText(t,Xt()),r=ue.sanitizeText(r,Xt());var i={id:e||Sl+"-"+Al(),message:t,seq:Sl++,type:n||Ll.NORMAL,tag:r||"",parents:null==kl?[]:[kl.id],branch:El};kl=i,xl[i.id]=i,Tl[El]=i.id,o.debug("in pushCommit "+i.id);},branch:function(t,e){if(t=ue.sanitizeText(t,Xt()),void 0!==Tl[t]){var n=new Error('Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout '+t+'")');throw n.hash={text:"branch "+t,token:"branch "+t,line:"1",loc:{first_line:1,last_line:1,first_column:1,last_column:1},expected:['"checkout '+t+'"']},n}Tl[t]=null!=kl?kl.id:null,wl[t]={name:t,order:e?parseInt(e,10):null},Nl(t),o.debug("in createBranch");},merge:function(t,e,n,r){t=ue.sanitizeText(t,Xt()),e=ue.sanitizeText(e,Xt());var i=xl[Tl[El]],a=xl[Tl[t]];if(El===t){var s=new Error('Incorrect usage of "merge". Cannot merge a branch to itself');throw s.hash={text:"merge "+t,token:"merge "+t,line:"1",loc:{first_line:1,last_line:1,first_column:1,last_column:1},expected:["branch abc"]},s}if(void 0===i||!i){var c=new Error('Incorrect usage of "merge". Current branch ('+El+")has no commits");throw c.hash={text:"merge "+t,token:"merge "+t,line:"1",loc:{first_line:1,last_line:1,first_column:1,last_column:1},expected:["commit"]},c}if(void 0===Tl[t]){var l=new Error('Incorrect usage of "merge". Branch to be merged ('+t+") does not exist");throw l.hash={text:"merge "+t,token:"merge "+t,line:"1",loc:{first_line:1,last_line:1,first_column:1,last_column:1},expected:["branch "+t]},l}if(void 0===a||!a){var u=new Error('Incorrect usage of "merge". Branch to be merged ('+t+") has no commits");throw u.hash={text:"merge "+t,token:"merge "+t,line:"1",loc:{first_line:1,last_line:1,first_column:1,last_column:1},expected:['"commit"']},u}if(i===a){var h=new Error('Incorrect usage of "merge". Both branches have same head');throw h.hash={text:"merge "+t,token:"merge "+t,line:"1",loc:{first_line:1,last_line:1,first_column:1,last_column:1},expected:["branch abc"]},h}if(e&&void 0!==xl[e]){var f=new Error('Incorrect usage of "merge". Commit with id:'+e+" already exists, use different custom Id");throw f.hash={text:"merge "+t+e+n+r,token:"merge "+t+e+n+r,line:"1",loc:{first_line:1,last_line:1,first_column:1,last_column:1},expected:["merge "+t+" "+e+"_UNIQUE "+n+" "+r]},f}var d={id:e||Sl+"-"+Al(),message:"merged branch "+t+" into "+El,seq:Sl++,parents:[null==kl?null:kl.id,Tl[t]],branch:El,type:Ll.MERGE,customType:n,customId:!!e,tag:r||""};kl=d,xl[d.id]=d,Tl[El]=d.id,o.debug(Tl),o.debug("in mergeBranch");},cherryPick:function(t,e){if(t=ue.sanitizeText(t,Xt()),e=ue.sanitizeText(e,Xt()),!t||void 0===xl[t]){var n=new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');throw n.hash={text:"cherryPick "+t+" "+e,token:"cherryPick "+t+" "+e,line:"1",loc:{first_line:1,last_line:1,first_column:1,last_column:1},expected:["cherry-pick abc"]},n}var r=xl[t],i=r.branch;if(r.type===Ll.MERGE){var a=new Error('Incorrect usage of "cherryPick". Source commit should not be a merge commit');throw a.hash={text:"cherryPick "+t+" "+e,token:"cherryPick "+t+" "+e,line:"1",loc:{first_line:1,last_line:1,first_column:1,last_column:1},expected:["cherry-pick abc"]},a}if(!e||void 0===xl[e]){if(i===El){var s=new Error('Incorrect usage of "cherryPick". Source commit is already on current branch');throw s.hash={text:"cherryPick "+t+" "+e,token:"cherryPick "+t+" "+e,line:"1",loc:{first_line:1,last_line:1,first_column:1,last_column:1},expected:["cherry-pick abc"]},s}var c=xl[Tl[El]];if(void 0===c||!c){var l=new Error('Incorrect usage of "cherry-pick". Current branch ('+El+")has no commits");throw l.hash={text:"cherryPick "+t+" "+e,token:"cherryPick "+t+" "+e,line:"1",loc:{first_line:1,last_line:1,first_column:1,last_column:1},expected:["cherry-pick abc"]},l}var u={id:Sl+"-"+Al(),message:"cherry-picked "+r+" into "+El,seq:Sl++,parents:[null==kl?null:kl.id,r.id],branch:El,type:Ll.CHERRY_PICK,tag:"cherry-pick:"+r.id};kl=u,xl[u.id]=u,Tl[El]=u.id,o.debug(Tl),o.debug("in cheeryPick");}},checkout:Nl,prettyPrint:function(){o.debug(xl),Dl([Bl()[0]]);},clear:function(){xl={},kl=null;var t=Xt().gitGraph.mainBranchName,e=Xt().gitGraph.mainBranchOrder;(Tl={})[t]=null,(wl={})[t]={name:t,order:e},El=t,Sl=0,ge();},getBranchesAsObjArray:function(){return Object.values(wl).map((function(t,e){return null!==t.order?t:ml(ml({},t),{},{order:parseFloat("0.".concat(e),10)})})).sort((function(t,e){return t.order-e.order})).map((function(t){return {name:t.name}}))},getBranches:function(){return Tl},getCommits:function(){return xl},getCommitsArray:Bl,getCurrentBranch:function(){return El},getDirection:function(){return Cl},getHead:function(){return kl},setAccTitle:ye,getAccTitle:me,getAccDescription:ve,setAccDescription:be,commitType:Ll};var Fl={},Rl={},Pl={},jl=[],zl=0,Yl=function(t,e,n){var r=Xt().gitGraph,i=t.append("g").attr("class","commit-bullets"),a=t.append("g").attr("class","commit-labels"),o=0;Object.keys(e).sort((function(t,n){return e[t].seq-e[n].seq})).forEach((function(t,s){var c=e[t],l=Rl[c.branch].pos,u=o+10;if(n){var h,f=void 0!==c.customType&&""!==c.customType?c.customType:c.type;switch(f){case 0:default:h="commit-normal";break;case 1:h="commit-reverse";break;case 2:h="commit-highlight";break;case 3:h="commit-merge";break;case 4:h="commit-cherry-pick";}if(2===f){var d=i.append("rect");d.attr("x",u-10),d.attr("y",l-10),d.attr("height",20),d.attr("width",20),d.attr("class","commit ".concat(c.id," commit-highlight").concat(Rl[c.branch].index%8," ").concat(h,"-outer")),i.append("rect").attr("x",u-6).attr("y",l-6).attr("height",12).attr("width",12).attr("class","commit ".concat(c.id," commit").concat(Rl[c.branch].index%8," ").concat(h,"-inner"));}else if(4===f)i.append("circle").attr("cx",u).attr("cy",l).attr("r",10).attr("class","commit ".concat(c.id," ").concat(h)),i.append("circle").attr("cx",u-3).attr("cy",l+2).attr("r",2.75).attr("fill","#fff").attr("class","commit ".concat(c.id," ").concat(h)),i.append("circle").attr("cx",u+3).attr("cy",l+2).attr("r",2.75).attr("fill","#fff").attr("class","commit ".concat(c.id," ").concat(h)),i.append("line").attr("x1",u+3).attr("y1",l+1).attr("x2",u).attr("y2",l-5).attr("stroke","#fff").attr("class","commit ".concat(c.id," ").concat(h)),i.append("line").attr("x1",u-3).attr("y1",l+1).attr("x2",u).attr("y2",l-5).attr("stroke","#fff").attr("class","commit ".concat(c.id," ").concat(h));else {var p=i.append("circle");if(p.attr("cx",u),p.attr("cy",l),p.attr("r",3===c.type?9:10),p.attr("class","commit ".concat(c.id," commit").concat(Rl[c.branch].index%8)),3===f){var g=i.append("circle");g.attr("cx",u),g.attr("cy",l),g.attr("r",6),g.attr("class","commit ".concat(h," ").concat(c.id," commit").concat(Rl[c.branch].index%8));}1===f&&i.append("path").attr("d","M ".concat(u-5,",").concat(l-5,"L").concat(u+5,",").concat(l+5,"M").concat(u-5,",").concat(l+5,"L").concat(u+5,",").concat(l-5)).attr("class","commit ".concat(h," ").concat(c.id," commit").concat(Rl[c.branch].index%8));}}if(Pl[c.id]={x:o+10,y:l},n){if(4!==c.type&&(c.customId&&3===c.type||3!==c.type)&&r.showCommitLabel){var y=a.append("g"),m=y.insert("rect").attr("class","commit-label-bkg"),b=y.append("text").attr("x",o).attr("y",l+25).attr("class","commit-label").text(c.id),v=b.node().getBBox();if(m.attr("x",o+10-v.width/2-2).attr("y",l+13.5).attr("width",v.width+4).attr("height",v.height+4),b.attr("x",o+10-v.width/2),r.rotateCommitLabel){var _=-7.5-(v.width+10)/25*9.5,x=10+v.width/25*8.5;y.attr("transform","translate("+_+", "+x+") rotate(-45, "+o+", "+l+")");}}if(c.tag){var k=a.insert("polygon"),w=a.append("circle"),T=a.append("text").attr("y",l-16).attr("class","tag-label").text(c.tag),E=T.node().getBBox();T.attr("x",o+10-E.width/2);var C=E.height/2,S=l-19.2;k.attr("class","tag-label-bkg").attr("points","\n ".concat(o-E.width/2-2,",").concat(S+2,"\n ").concat(o-E.width/2-2,",").concat(S-2,"\n ").concat(o+10-E.width/2-4,",").concat(S-C-2,"\n ").concat(o+10+E.width/2+4,",").concat(S-C-2,"\n ").concat(o+10+E.width/2+4,",").concat(S+C+2,"\n ").concat(o+10-E.width/2-4,",").concat(S+C+2)),w.attr("cx",o-E.width/2+2).attr("cy",S).attr("r",1.5).attr("class","tag-hole");}}(o+=50)>zl&&(zl=o);}));},Ul=function t(e,n,r){var i=r||0,a=e+Math.abs(e-n)/2;if(i>5)return a;for(var o=!0,s=0;s<jl.length;s++)Math.abs(jl[s]-a)<10&&(o=!1);return o?(jl.push(a),a):t(e,n-Math.abs(e-n)/5,i+1)};const $l={draw:function(t,e,n,r){Rl={},Pl={},Fl={},zl=0,jl=[];var i=Xt(),a=Xt().gitGraph;o.debug("in gitgraph renderer",t+"\n","id:",e,n),Fl=r.db.getCommits();var s=r.db.getBranchesAsObjArray(),c=0;s.forEach((function(t,e){Rl[t.name]={pos:c,index:e},c+=50+(a.rotateCommitLabel?40:0);}));var u=(0, l.select)('[id="'.concat(e,'"]'));Mn(r.db,u,e),Yl(u,Fl,!1),a.showBranches&&function(t,e){var n=Xt().gitGraph,r=t.append("g");e.forEach((function(t,e){var i=e%8,a=Rl[t.name].pos,o=r.append("line");o.attr("x1",0),o.attr("y1",a),o.attr("x2",zl),o.attr("y2",a),o.attr("class","branch branch"+i),jl.push(a);var s=function(t){var e=document.createElementNS("http://www.w3.org/2000/svg","text"),n=[];n="string"==typeof t?t.split(/\\n|\n|<br\s*\/?>/gi):Array.isArray(t)?t:[];for(var r=0;r<n.length;r++){var i=document.createElementNS("http://www.w3.org/2000/svg","tspan");i.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),i.setAttribute("dy","1em"),i.setAttribute("x","0"),i.setAttribute("class","row"),i.textContent=n[r].trim(),e.appendChild(i);}return e}(t.name),c=r.insert("rect"),l=r.insert("g").attr("class","branchLabel").insert("g").attr("class","label branch-label"+i);l.node().appendChild(s);var u=s.getBBox();c.attr("class","branchLabelBkg label"+i).attr("rx",4).attr("ry",4).attr("x",-u.width-4-(!0===n.rotateCommitLabel?30:0)).attr("y",-u.height/2+8).attr("width",u.width+18).attr("height",u.height+4),l.attr("transform","translate("+(-u.width-14-(!0===n.rotateCommitLabel?30:0))+", "+(a-u.height/2-1)+")"),c.attr("transform","translate(-19, "+(a-u.height/2)+")");}));}(u,s),function(t,e){var n=t.append("g").attr("class","commit-arrows");Object.keys(e).forEach((function(t,r){var i=e[t];i.parents&&i.parents.length>0&&i.parents.forEach((function(t){!function(t,e,n,r){var i=Xt(),a=Pl[e.id],o=Pl[n.id],s=function(t,e,n){return Pl[e.id],Pl[t.id],Object.keys(n).filter((function(r){return n[r].branch===e.branch&&n[r].seq>t.seq&&n[r].seq<e.seq})).length>0}(e,n,r);i.arrowMarkerAbsolute&&(window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search).replace(/\(/g,"\\(").replace(/\)/g,"\\)");var c,l="",u="",h=0,f=0,d=Rl[n.branch].index;if(s){l="A 10 10, 0, 0, 0,",u="A 10 10, 0, 0, 1,",h=10,f=10,d=Rl[n.branch].index;var p=a.y<o.y?Ul(a.y,o.y):Ul(o.y,a.y);c=a.y<o.y?"M ".concat(a.x," ").concat(a.y," L ").concat(a.x," ").concat(p-h," ").concat(l," ").concat(a.x+f," ").concat(p," L ").concat(o.x-h," ").concat(p," ").concat(u," ").concat(o.x," ").concat(p+f," L ").concat(o.x," ").concat(o.y):"M ".concat(a.x," ").concat(a.y," L ").concat(a.x," ").concat(p+h," ").concat(u," ").concat(a.x+f," ").concat(p," L ").concat(o.x-h," ").concat(p," ").concat(l," ").concat(o.x," ").concat(p-f," L ").concat(o.x," ").concat(o.y);}else a.y<o.y&&(l="A 20 20, 0, 0, 0,",h=20,f=20,d=Rl[n.branch].index,c="M ".concat(a.x," ").concat(a.y," L ").concat(a.x," ").concat(o.y-h," ").concat(l," ").concat(a.x+f," ").concat(o.y," L ").concat(o.x," ").concat(o.y)),a.y>o.y&&(l="A 20 20, 0, 0, 0,",h=20,f=20,d=Rl[e.branch].index,c="M ".concat(a.x," ").concat(a.y," L ").concat(o.x-h," ").concat(a.y," ").concat(l," ").concat(o.x," ").concat(a.y-f," L ").concat(o.x," ").concat(o.y)),a.y===o.y&&(d=Rl[e.branch].index,c="M ".concat(a.x," ").concat(a.y," L ").concat(a.x," ").concat(o.y-h," ").concat(l," ").concat(a.x+f," ").concat(o.y," L ").concat(o.x," ").concat(o.y));t.append("path").attr("d",c).attr("class","arrow arrow"+d%8);}(n,e[t],i,e);}));}));}(u,Fl),Yl(u,Fl,!0);var h=a.diagramPadding,f=u.node().getBBox(),d=f.width+2*h,p=f.height+2*h;Tn(u,0,d,i.useMaxWidth);var g="".concat(f.x-h-(a.showBranches&&!0===a.rotateCommitLabel?30:0)," ").concat(f.y-h," ").concat(d," ").concat(p);u.attr("viewBox",g);}};var Wl=n(2553),ql=n.n(Wl);const Hl=function(t){return t.match(/^\s*gitGraph/)?"gitGraph":null},Vl=function(){var t,e,n,r,i,a;t="gitGraph",e=ql(),n=Il,r=$l,i=void 0,a=Hl,pl[t]={parser:e,db:n,renderer:r,init:i},function(t,e){Xe[t]={detector:e};}(t,a);};function Gl(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r);}}function Xl(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Zl=function(){function t(e){var n,r;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Xl(this,"type","graph"),Xl(this,"parser",void 0),Xl(this,"renderer",void 0),Xl(this,"db",void 0);var i=gl(),a=Xt();this.txt=e,this.type=Ze(e,a),o.debug("Type "+this.type),this.db=i[this.type].db,null===(n=(r=this.db).clear)||void 0===n||n.call(r),this.renderer=i[this.type].renderer,this.parser=i[this.type].parser,this.parser.parser.yy=this.db,"function"==typeof i[this.type].init&&(i[this.type].init(a),o.debug("Initialized diagram "+this.type,a)),this.txt=this.txt+"\n",this.parser.parser.yy.graphType=this.type,this.parser.parser.yy.parseError=function(t,e){throw {str:t,hash:e}},this.parser.parse(this.txt);}var e,r;return e=t,(r=[{key:"parse",value:function(t){var e=!1;try{t+="\n",this.db.clear(),this.parser.parse(t);}catch(t){if(e=!0,!n.g.mermaid.parseError)throw t;null!=t.str?n.g.mermaid.parseError(t.str,t.hash):n.g.mermaid.parseError(t);}return !e}},{key:"getParser",value:function(){return this.parser}},{key:"getType",value:function(){return this.type}}])&&Gl(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const Ql=Zl,Kl=function(t){return "g.classGroup text {\n fill: ".concat(t.nodeBorder,";\n fill: ").concat(t.classText,";\n stroke: none;\n font-family: ").concat(t.fontFamily,";\n font-size: 10px;\n\n .title {\n font-weight: bolder;\n }\n\n}\n\n.nodeLabel, .edgeLabel {\n color: ").concat(t.classText,";\n}\n.edgeLabel .label rect {\n fill: ").concat(t.mainBkg,";\n}\n.label text {\n fill: ").concat(t.classText,";\n}\n.edgeLabel .label span {\n background: ").concat(t.mainBkg,";\n}\n\n.classTitle {\n font-weight: bolder;\n}\n.node rect,\n .node circle,\n .node ellipse,\n .node polygon,\n .node path {\n fill: ").concat(t.mainBkg,";\n stroke: ").concat(t.nodeBorder,";\n stroke-width: 1px;\n }\n\n\n.divider {\n stroke: ").concat(t.nodeBorder,";\n stroke: 1;\n}\n\ng.clickable {\n cursor: pointer;\n}\n\ng.classGroup rect {\n fill: ").concat(t.mainBkg,";\n stroke: ").concat(t.nodeBorder,";\n}\n\ng.classGroup line {\n stroke: ").concat(t.nodeBorder,";\n stroke-width: 1;\n}\n\n.classLabel .box {\n stroke: none;\n stroke-width: 0;\n fill: ").concat(t.mainBkg,";\n opacity: 0.5;\n}\n\n.classLabel .label {\n fill: ").concat(t.nodeBorder,";\n font-size: 10px;\n}\n\n.relation {\n stroke: ").concat(t.lineColor,";\n stroke-width: 1;\n fill: none;\n}\n\n.dashed-line{\n stroke-dasharray: 3;\n}\n\n#compositionStart, .composition {\n fill: ").concat(t.lineColor," !important;\n stroke: ").concat(t.lineColor," !important;\n stroke-width: 1;\n}\n\n#compositionEnd, .composition {\n fill: ").concat(t.lineColor," !important;\n stroke: ").concat(t.lineColor," !important;\n stroke-width: 1;\n}\n\n#dependencyStart, .dependency {\n fill: ").concat(t.lineColor," !important;\n stroke: ").concat(t.lineColor," !important;\n stroke-width: 1;\n}\n\n#dependencyStart, .dependency {\n fill: ").concat(t.lineColor," !important;\n stroke: ").concat(t.lineColor," !important;\n stroke-width: 1;\n}\n\n#extensionStart, .extension {\n fill: ").concat(t.lineColor," !important;\n stroke: ").concat(t.lineColor," !important;\n stroke-width: 1;\n}\n\n#extensionEnd, .extension {\n fill: ").concat(t.lineColor," !important;\n stroke: ").concat(t.lineColor," !important;\n stroke-width: 1;\n}\n\n#aggregationStart, .aggregation {\n fill: ").concat(t.mainBkg," !important;\n stroke: ").concat(t.lineColor," !important;\n stroke-width: 1;\n}\n\n#aggregationEnd, .aggregation {\n fill: ").concat(t.mainBkg," !important;\n stroke: ").concat(t.lineColor," !important;\n stroke-width: 1;\n}\n\n#lollipopStart, .lollipop {\n fill: ").concat(t.mainBkg," !important;\n stroke: ").concat(t.lineColor," !important;\n stroke-width: 1;\n}\n\n#lollipopEnd, .lollipop {\n fill: ").concat(t.mainBkg," !important;\n stroke: ").concat(t.lineColor," !important;\n stroke-width: 1;\n}\n\n.edgeTerminals {\n font-size: 11px;\n}\n\n")},Jl=function(t){return ".label {\n font-family: ".concat(t.fontFamily,";\n color: ").concat(t.nodeTextColor||t.textColor,";\n }\n .cluster-label text {\n fill: ").concat(t.titleColor,";\n }\n .cluster-label span {\n color: ").concat(t.titleColor,";\n }\n\n .label text,span {\n fill: ").concat(t.nodeTextColor||t.textColor,";\n color: ").concat(t.nodeTextColor||t.textColor,";\n }\n\n .node rect,\n .node circle,\n .node ellipse,\n .node polygon,\n .node path {\n fill: ").concat(t.mainBkg,";\n stroke: ").concat(t.nodeBorder,";\n stroke-width: 1px;\n }\n\n .node .label {\n text-align: center;\n }\n .node.clickable {\n cursor: pointer;\n }\n\n .arrowheadPath {\n fill: ").concat(t.arrowheadColor,";\n }\n\n .edgePath .path {\n stroke: ").concat(t.lineColor,";\n stroke-width: 2.0px;\n }\n\n .flowchart-link {\n stroke: ").concat(t.lineColor,";\n fill: none;\n }\n\n .edgeLabel {\n background-color: ").concat(t.edgeLabelBackground,";\n rect {\n opacity: 0.5;\n background-color: ").concat(t.edgeLabelBackground,";\n fill: ").concat(t.edgeLabelBackground,";\n }\n text-align: center;\n }\n\n .cluster rect {\n fill: ").concat(t.clusterBkg,";\n stroke: ").concat(t.clusterBorder,";\n stroke-width: 1px;\n }\n\n .cluster text {\n fill: ").concat(t.titleColor,";\n }\n\n .cluster span {\n color: ").concat(t.titleColor,";\n }\n /* .cluster div {\n color: ").concat(t.titleColor,";\n } */\n\n div.mermaidTooltip {\n position: absolute;\n text-align: center;\n max-width: 200px;\n padding: 2px;\n font-family: ").concat(t.fontFamily,";\n font-size: 12px;\n background: ").concat(t.tertiaryColor,";\n border: 1px solid ").concat(t.border2,";\n border-radius: 2px;\n pointer-events: none;\n z-index: 100;\n }\n")},tu=function(t){return "\ndefs #statediagram-barbEnd {\n fill: ".concat(t.transitionColor,";\n stroke: ").concat(t.transitionColor,";\n }\ng.stateGroup text {\n fill: ").concat(t.nodeBorder,";\n stroke: none;\n font-size: 10px;\n}\ng.stateGroup text {\n fill: ").concat(t.textColor,";\n stroke: none;\n font-size: 10px;\n\n}\ng.stateGroup .state-title {\n font-weight: bolder;\n fill: ").concat(t.stateLabelColor,";\n}\n\ng.stateGroup rect {\n fill: ").concat(t.mainBkg,";\n stroke: ").concat(t.nodeBorder,";\n}\n\ng.stateGroup line {\n stroke: ").concat(t.lineColor,";\n stroke-width: 1;\n}\n\n.transition {\n stroke: ").concat(t.transitionColor,";\n stroke-width: 1;\n fill: none;\n}\n\n.stateGroup .composit {\n fill: ").concat(t.background,";\n border-bottom: 1px\n}\n\n.stateGroup .alt-composit {\n fill: #e0e0e0;\n border-bottom: 1px\n}\n\n.state-note {\n stroke: ").concat(t.noteBorderColor,";\n fill: ").concat(t.noteBkgColor,";\n\n text {\n fill: ").concat(t.noteTextColor,";\n stroke: none;\n font-size: 10px;\n }\n}\n\n.stateLabel .box {\n stroke: none;\n stroke-width: 0;\n fill: ").concat(t.mainBkg,";\n opacity: 0.5;\n}\n\n.edgeLabel .label rect {\n fill: ").concat(t.labelBackgroundColor,";\n opacity: 0.5;\n}\n.edgeLabel .label text {\n fill: ").concat(t.transitionLabelColor||t.tertiaryTextColor,";\n}\n.label div .edgeLabel {\n color: ").concat(t.transitionLabelColor||t.tertiaryTextColor,";\n}\n\n.stateLabel text {\n fill: ").concat(t.stateLabelColor,";\n font-size: 10px;\n font-weight: bold;\n}\n\n.node circle.state-start {\n fill: ").concat(t.specialStateColor,";\n stroke: ").concat(t.specialStateColor,";\n}\n\n.node .fork-join {\n fill: ").concat(t.specialStateColor,";\n stroke: ").concat(t.specialStateColor,";\n}\n\n.node circle.state-end {\n fill: ").concat(t.innerEndBackground,";\n stroke: ").concat(t.background,";\n stroke-width: 1.5\n}\n.end-state-inner {\n fill: ").concat(t.compositeBackground||t.background,";\n // stroke: ").concat(t.background,";\n stroke-width: 1.5\n}\n\n.node rect {\n fill: ").concat(t.stateBkg||t.mainBkg,";\n stroke: ").concat(t.stateBorder||t.nodeBorder,";\n stroke-width: 1px;\n}\n.node polygon {\n fill: ").concat(t.mainBkg,";\n stroke: ").concat(t.stateBorder||t.nodeBorder,";;\n stroke-width: 1px;\n}\n#statediagram-barbEnd {\n fill: ").concat(t.lineColor,";\n}\n\n.statediagram-cluster rect {\n fill: ").concat(t.compositeTitleBackground,";\n stroke: ").concat(t.stateBorder||t.nodeBorder,";\n stroke-width: 1px;\n}\n\n.cluster-label, .nodeLabel {\n color: ").concat(t.stateLabelColor,";\n}\n\n.statediagram-cluster rect.outer {\n rx: 5px;\n ry: 5px;\n}\n.statediagram-state .divider {\n stroke: ").concat(t.stateBorder||t.nodeBorder,";\n}\n\n.statediagram-state .title-state {\n rx: 5px;\n ry: 5px;\n}\n.statediagram-cluster.statediagram-cluster .inner {\n fill: ").concat(t.compositeBackground||t.background,";\n}\n.statediagram-cluster.statediagram-cluster-alt .inner {\n fill: ").concat(t.altBackground?t.altBackground:"#efefef",";\n}\n\n.statediagram-cluster .inner {\n rx:0;\n ry:0;\n}\n\n.statediagram-state rect.basic {\n rx: 5px;\n ry: 5px;\n}\n.statediagram-state rect.divider {\n stroke-dasharray: 10,10;\n fill: ").concat(t.altBackground?t.altBackground:"#efefef",";\n}\n\n.note-edge {\n stroke-dasharray: 5;\n}\n\n.statediagram-note rect {\n fill: ").concat(t.noteBkgColor,";\n stroke: ").concat(t.noteBorderColor,";\n stroke-width: 1px;\n rx: 0;\n ry: 0;\n}\n.statediagram-note rect {\n fill: ").concat(t.noteBkgColor,";\n stroke: ").concat(t.noteBorderColor,";\n stroke-width: 1px;\n rx: 0;\n ry: 0;\n}\n\n.statediagram-note text {\n fill: ").concat(t.noteTextColor,";\n}\n\n.statediagram-note .nodeLabel {\n color: ").concat(t.noteTextColor,";\n}\n.statediagram .edgeLabel {\n color: red; // ").concat(t.noteTextColor,";\n}\n\n#dependencyStart, #dependencyEnd {\n fill: ").concat(t.lineColor,";\n stroke: ").concat(t.lineColor,";\n stroke-width: 1;\n}\n")};var eu={flowchart:Jl,"flowchart-v2":Jl,sequence:function(t){return ".actor {\n stroke: ".concat(t.actorBorder,";\n fill: ").concat(t.actorBkg,";\n }\n\n text.actor > tspan {\n fill: ").concat(t.actorTextColor,";\n stroke: none;\n }\n\n .actor-line {\n stroke: ").concat(t.actorLineColor,";\n }\n\n .messageLine0 {\n stroke-width: 1.5;\n stroke-dasharray: none;\n stroke: ").concat(t.signalColor,";\n }\n\n .messageLine1 {\n stroke-width: 1.5;\n stroke-dasharray: 2, 2;\n stroke: ").concat(t.signalColor,";\n }\n\n #arrowhead path {\n fill: ").concat(t.signalColor,";\n stroke: ").concat(t.signalColor,";\n }\n\n .sequenceNumber {\n fill: ").concat(t.sequenceNumberColor,";\n }\n\n #sequencenumber {\n fill: ").concat(t.signalColor,";\n }\n\n #crosshead path {\n fill: ").concat(t.signalColor,";\n stroke: ").concat(t.signalColor,";\n }\n\n .messageText {\n fill: ").concat(t.signalTextColor,";\n stroke: none;\n }\n\n .labelBox {\n stroke: ").concat(t.labelBoxBorderColor,";\n fill: ").concat(t.labelBoxBkgColor,";\n }\n\n .labelText, .labelText > tspan {\n fill: ").concat(t.labelTextColor,";\n stroke: none;\n }\n\n .loopText, .loopText > tspan {\n fill: ").concat(t.loopTextColor,";\n stroke: none;\n }\n\n .loopLine {\n stroke-width: 2px;\n stroke-dasharray: 2, 2;\n stroke: ").concat(t.labelBoxBorderColor,";\n fill: ").concat(t.labelBoxBorderColor,";\n }\n\n .note {\n //stroke: #decc93;\n stroke: ").concat(t.noteBorderColor,";\n fill: ").concat(t.noteBkgColor,";\n }\n\n .noteText, .noteText > tspan {\n fill: ").concat(t.noteTextColor,";\n stroke: none;\n }\n\n .activation0 {\n fill: ").concat(t.activationBkgColor,";\n stroke: ").concat(t.activationBorderColor,";\n }\n\n .activation1 {\n fill: ").concat(t.activationBkgColor,";\n stroke: ").concat(t.activationBorderColor,";\n }\n\n .activation2 {\n fill: ").concat(t.activationBkgColor,";\n stroke: ").concat(t.activationBorderColor,";\n }\n\n .actorPopupMenu {\n position: absolute;\n }\n\n .actorPopupMenuPanel {\n position: absolute;\n fill: ").concat(t.actorBkg,";\n box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);\n filter: drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));\n}\n .actor-man line {\n stroke: ").concat(t.actorBorder,";\n fill: ").concat(t.actorBkg,";\n }\n .actor-man circle, line {\n stroke: ").concat(t.actorBorder,";\n fill: ").concat(t.actorBkg,";\n stroke-width: 2px;\n }\n")},gantt:function(t){return '\n .mermaid-main-font {\n font-family: "trebuchet ms", verdana, arial, sans-serif;\n font-family: var(--mermaid-font-family);\n }\n .exclude-range {\n fill: '.concat(t.excludeBkgColor,";\n }\n\n .section {\n stroke: none;\n opacity: 0.2;\n }\n\n .section0 {\n fill: ").concat(t.sectionBkgColor,";\n }\n\n .section2 {\n fill: ").concat(t.sectionBkgColor2,";\n }\n\n .section1,\n .section3 {\n fill: ").concat(t.altSectionBkgColor,";\n opacity: 0.2;\n }\n\n .sectionTitle0 {\n fill: ").concat(t.titleColor,";\n }\n\n .sectionTitle1 {\n fill: ").concat(t.titleColor,";\n }\n\n .sectionTitle2 {\n fill: ").concat(t.titleColor,";\n }\n\n .sectionTitle3 {\n fill: ").concat(t.titleColor,";\n }\n\n .sectionTitle {\n text-anchor: start;\n // font-size: ").concat(t.ganttFontSize,";\n // text-height: 14px;\n font-family: 'trebuchet ms', verdana, arial, sans-serif;\n font-family: var(--mermaid-font-family);\n\n }\n\n\n /* Grid and axis */\n\n .grid .tick {\n stroke: ").concat(t.gridColor,";\n opacity: 0.8;\n shape-rendering: crispEdges;\n text {\n font-family: ").concat(t.fontFamily,";\n fill: ").concat(t.textColor,";\n }\n }\n\n .grid path {\n stroke-width: 0;\n }\n\n\n /* Today line */\n\n .today {\n fill: none;\n stroke: ").concat(t.todayLineColor,";\n stroke-width: 2px;\n }\n\n\n /* Task styling */\n\n /* Default task */\n\n .task {\n stroke-width: 2;\n }\n\n .taskText {\n text-anchor: middle;\n font-family: 'trebuchet ms', verdana, arial, sans-serif;\n font-family: var(--mermaid-font-family);\n }\n\n // .taskText:not([font-size]) {\n // font-size: ").concat(t.ganttFontSize,";\n // }\n\n .taskTextOutsideRight {\n fill: ").concat(t.taskTextDarkColor,";\n text-anchor: start;\n // font-size: ").concat(t.ganttFontSize,";\n font-family: 'trebuchet ms', verdana, arial, sans-serif;\n font-family: var(--mermaid-font-family);\n\n }\n\n .taskTextOutsideLeft {\n fill: ").concat(t.taskTextDarkColor,";\n text-anchor: end;\n // font-size: ").concat(t.ganttFontSize,";\n }\n\n /* Special case clickable */\n .task.clickable {\n cursor: pointer;\n }\n .taskText.clickable {\n cursor: pointer;\n fill: ").concat(t.taskTextClickableColor," !important;\n font-weight: bold;\n }\n\n .taskTextOutsideLeft.clickable {\n cursor: pointer;\n fill: ").concat(t.taskTextClickableColor," !important;\n font-weight: bold;\n }\n\n .taskTextOutsideRight.clickable {\n cursor: pointer;\n fill: ").concat(t.taskTextClickableColor," !important;\n font-weight: bold;\n }\n\n /* Specific task settings for the sections*/\n\n .taskText0,\n .taskText1,\n .taskText2,\n .taskText3 {\n fill: ").concat(t.taskTextColor,";\n }\n\n .task0,\n .task1,\n .task2,\n .task3 {\n fill: ").concat(t.taskBkgColor,";\n stroke: ").concat(t.taskBorderColor,";\n }\n\n .taskTextOutside0,\n .taskTextOutside2\n {\n fill: ").concat(t.taskTextOutsideColor,";\n }\n\n .taskTextOutside1,\n .taskTextOutside3 {\n fill: ").concat(t.taskTextOutsideColor,";\n }\n\n\n /* Active task */\n\n .active0,\n .active1,\n .active2,\n .active3 {\n fill: ").concat(t.activeTaskBkgColor,";\n stroke: ").concat(t.activeTaskBorderColor,";\n }\n\n .activeText0,\n .activeText1,\n .activeText2,\n .activeText3 {\n fill: ").concat(t.taskTextDarkColor," !important;\n }\n\n\n /* Completed task */\n\n .done0,\n .done1,\n .done2,\n .done3 {\n stroke: ").concat(t.doneTaskBorderColor,";\n fill: ").concat(t.doneTaskBkgColor,";\n stroke-width: 2;\n }\n\n .doneText0,\n .doneText1,\n .doneText2,\n .doneText3 {\n fill: ").concat(t.taskTextDarkColor," !important;\n }\n\n\n /* Tasks on the critical line */\n\n .crit0,\n .crit1,\n .crit2,\n .crit3 {\n stroke: ").concat(t.critBorderColor,";\n fill: ").concat(t.critBkgColor,";\n stroke-width: 2;\n }\n\n .activeCrit0,\n .activeCrit1,\n .activeCrit2,\n .activeCrit3 {\n stroke: ").concat(t.critBorderColor,";\n fill: ").concat(t.activeTaskBkgColor,";\n stroke-width: 2;\n }\n\n .doneCrit0,\n .doneCrit1,\n .doneCrit2,\n .doneCrit3 {\n stroke: ").concat(t.critBorderColor,";\n fill: ").concat(t.doneTaskBkgColor,";\n stroke-width: 2;\n cursor: pointer;\n shape-rendering: crispEdges;\n }\n\n .milestone {\n transform: rotate(45deg) scale(0.8,0.8);\n }\n\n .milestoneText {\n font-style: italic;\n }\n .doneCritText0,\n .doneCritText1,\n .doneCritText2,\n .doneCritText3 {\n fill: ").concat(t.taskTextDarkColor," !important;\n }\n\n .activeCritText0,\n .activeCritText1,\n .activeCritText2,\n .activeCritText3 {\n fill: ").concat(t.taskTextDarkColor," !important;\n }\n\n .titleText {\n text-anchor: middle;\n font-size: 18px;\n fill: ").concat(t.textColor," ;\n font-family: 'trebuchet ms', verdana, arial, sans-serif;\n font-family: var(--mermaid-font-family);\n }\n")},classDiagram:Kl,"classDiagram-v2":Kl,class:Kl,stateDiagram:tu,state:tu,gitGraph:function(t){return "\n .commit-id,\n .commit-msg,\n .branch-label {\n fill: lightgrey;\n color: lightgrey;\n font-family: 'trebuchet ms', verdana, arial, sans-serif;\n font-family: var(--mermaid-font-family);\n }\n ".concat([0,1,2,3,4,5,6,7].map((function(e){return "\n .branch-label".concat(e," { fill: ").concat(t["gitBranchLabel"+e],"; }\n .commit").concat(e," { stroke: ").concat(t["git"+e],"; fill: ").concat(t["git"+e],"; }\n .commit-highlight").concat(e," { stroke: ").concat(t["gitInv"+e],"; fill: ").concat(t["gitInv"+e],"; }\n .label").concat(e," { fill: ").concat(t["git"+e],"; }\n .arrow").concat(e," { stroke: ").concat(t["git"+e],"; }\n ")})).join("\n"),"\n\n .branch {\n stroke-width: 1;\n stroke: ").concat(t.lineColor,";\n stroke-dasharray: 2;\n }\n .commit-label { font-size: ").concat(t.commitLabelFontSize,"; fill: ").concat(t.commitLabelColor,";}\n .commit-label-bkg { font-size: ").concat(t.commitLabelFontSize,"; fill: ").concat(t.commitLabelBackground,"; opacity: 0.5; }\n .tag-label { font-size: ").concat(t.tagLabelFontSize,"; fill: ").concat(t.tagLabelColor,";}\n .tag-label-bkg { fill: ").concat(t.tagLabelBackground,"; stroke: ").concat(t.tagLabelBorder,"; }\n .tag-hole { fill: ").concat(t.textColor,"; }\n\n .commit-merge {\n stroke: ").concat(t.primaryColor,";\n fill: ").concat(t.primaryColor,";\n }\n .commit-reverse {\n stroke: ").concat(t.primaryColor,";\n fill: ").concat(t.primaryColor,";\n stroke-width: 3;\n }\n .commit-highlight-outer {\n }\n .commit-highlight-inner {\n stroke: ").concat(t.primaryColor,";\n fill: ").concat(t.primaryColor,";\n }\n\n .arrow { stroke-width: 8; stroke-linecap: round; fill: none}\n }\n")},info:function(){return ""},pie:function(t){return "\n .pieCircle{\n stroke: ".concat(t.pieStrokeColor,";\n stroke-width : ").concat(t.pieStrokeWidth,";\n opacity : ").concat(t.pieOpacity,";\n }\n .pieTitleText {\n text-anchor: middle;\n font-size: ").concat(t.pieTitleTextSize,";\n fill: ").concat(t.pieTitleTextColor,";\n font-family: ").concat(t.fontFamily,";\n }\n .slice {\n font-family: ").concat(t.fontFamily,";\n fill: ").concat(t.pieSectionTextColor,";\n font-size:").concat(t.pieSectionTextSize,";\n // fill: white;\n }\n .legend text {\n fill: ").concat(t.pieLegendTextColor,";\n font-family: ").concat(t.fontFamily,";\n font-size: ").concat(t.pieLegendTextSize,";\n }\n")},er:function(t){return "\n .entityBox {\n fill: ".concat(t.mainBkg,";\n stroke: ").concat(t.nodeBorder,";\n }\n\n .attributeBoxOdd {\n fill: #ffffff;\n stroke: ").concat(t.nodeBorder,";\n }\n\n .attributeBoxEven {\n fill: #f2f2f2;\n stroke: ").concat(t.nodeBorder,";\n }\n\n .relationshipLabelBox {\n fill: ").concat(t.tertiaryColor,";\n opacity: 0.7;\n background-color: ").concat(t.tertiaryColor,";\n rect {\n opacity: 0.5;\n }\n }\n\n .relationshipLine {\n stroke: ").concat(t.lineColor,";\n }\n")},error:function(){return ""},journey:function(t){return ".label {\n font-family: 'trebuchet ms', verdana, arial, sans-serif;\n font-family: var(--mermaid-font-family);\n color: ".concat(t.textColor,";\n }\n .mouth {\n stroke: #666;\n }\n\n line {\n stroke: ").concat(t.textColor,"\n }\n\n .legend {\n fill: ").concat(t.textColor,";\n }\n\n .label text {\n fill: #333;\n }\n .label {\n color: ").concat(t.textColor,"\n }\n\n .face {\n ").concat(t.faceColor?"fill: ".concat(t.faceColor):"fill: #FFF8DC",";\n stroke: #999;\n }\n\n .node rect,\n .node circle,\n .node ellipse,\n .node polygon,\n .node path {\n fill: ").concat(t.mainBkg,";\n stroke: ").concat(t.nodeBorder,";\n stroke-width: 1px;\n }\n\n .node .label {\n text-align: center;\n }\n .node.clickable {\n cursor: pointer;\n }\n\n .arrowheadPath {\n fill: ").concat(t.arrowheadColor,";\n }\n\n .edgePath .path {\n stroke: ").concat(t.lineColor,";\n stroke-width: 1.5px;\n }\n\n .flowchart-link {\n stroke: ").concat(t.lineColor,";\n fill: none;\n }\n\n .edgeLabel {\n background-color: ").concat(t.edgeLabelBackground,";\n rect {\n opacity: 0.5;\n }\n text-align: center;\n }\n\n .cluster rect {\n }\n\n .cluster text {\n fill: ").concat(t.titleColor,";\n }\n\n div.mermaidTooltip {\n position: absolute;\n text-align: center;\n max-width: 200px;\n padding: 2px;\n font-family: 'trebuchet ms', verdana, arial, sans-serif;\n font-family: var(--mermaid-font-family);\n font-size: 12px;\n background: ").concat(t.tertiaryColor,";\n border: 1px solid ").concat(t.border2,";\n border-radius: 2px;\n pointer-events: none;\n z-index: 100;\n }\n\n .task-type-0, .section-type-0 {\n ").concat(t.fillType0?"fill: ".concat(t.fillType0):"",";\n }\n .task-type-1, .section-type-1 {\n ").concat(t.fillType0?"fill: ".concat(t.fillType1):"",";\n }\n .task-type-2, .section-type-2 {\n ").concat(t.fillType0?"fill: ".concat(t.fillType2):"",";\n }\n .task-type-3, .section-type-3 {\n ").concat(t.fillType0?"fill: ".concat(t.fillType3):"",";\n }\n .task-type-4, .section-type-4 {\n ").concat(t.fillType0?"fill: ".concat(t.fillType4):"",";\n }\n .task-type-5, .section-type-5 {\n ").concat(t.fillType0?"fill: ".concat(t.fillType5):"",";\n }\n .task-type-6, .section-type-6 {\n ").concat(t.fillType0?"fill: ".concat(t.fillType6):"",";\n }\n .task-type-7, .section-type-7 {\n ").concat(t.fillType0?"fill: ".concat(t.fillType7):"",";\n }\n\n .actor-0 {\n ").concat(t.actor0?"fill: ".concat(t.actor0):"",";\n }\n .actor-1 {\n ").concat(t.actor1?"fill: ".concat(t.actor1):"",";\n }\n .actor-2 {\n ").concat(t.actor2?"fill: ".concat(t.actor2):"",";\n }\n .actor-3 {\n ").concat(t.actor3?"fill: ".concat(t.actor3):"",";\n }\n .actor-4 {\n ").concat(t.actor4?"fill: ".concat(t.actor4):"",";\n }\n .actor-5 {\n ").concat(t.actor5?"fill: ".concat(t.actor5):"",";\n }\n\n }\n")},requirement:function(t){return "\n\n marker {\n fill: ".concat(t.relationColor,";\n stroke: ").concat(t.relationColor,";\n }\n\n marker.cross {\n stroke: ").concat(t.lineColor,";\n }\n\n svg {\n font-family: ").concat(t.fontFamily,";\n font-size: ").concat(t.fontSize,";\n }\n\n .reqBox {\n fill: ").concat(t.requirementBackground,";\n fill-opacity: 100%;\n stroke: ").concat(t.requirementBorderColor,";\n stroke-width: ").concat(t.requirementBorderSize,";\n }\n \n .reqTitle, .reqLabel{\n fill: ").concat(t.requirementTextColor,";\n }\n .reqLabelBox {\n fill: ").concat(t.relationLabelBackground,";\n fill-opacity: 100%;\n }\n\n .req-title-line {\n stroke: ").concat(t.requirementBorderColor,";\n stroke-width: ").concat(t.requirementBorderSize,";\n }\n .relationshipLine {\n stroke: ").concat(t.relationColor,";\n stroke-width: 1;\n }\n .relationshipLabel {\n fill: ").concat(t.relationLabelColor,";\n }\n\n")},c4:function(t){return ".person {\n stroke: ".concat(t.personBorder,";\n fill: ").concat(t.personBkg,";\n }\n")}};function nu(t){return nu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},nu(t)}var ru=!1,iu=function(t){var e=t;return (e=(e=e.replace(/fl°°/g,(function(){return "&#"}))).replace(/fl°/g,(function(){return "&"}))).replace(/¶ß/g,(function(){return ";"}))},au={};function ou(t){Na.setConf(t.flowchart),La.setConf(t.flowchart),void 0!==t.sequenceDiagram&&cc.setConf(Q(t.sequence,t.sequenceDiagram)),cc.setConf(t.sequence),bo.setConf(t.gantt),Ic.setConf(t.state),Uc.setConf(t.state),hl.setConf(t.journey),Bi.setConf(t.class);}var su=Object.freeze({render:function(t,e,n,r){ru||(Vl(),ru=!0),Kt();var i=e.replace(/\r\n?/g,"\n"),a=An.detectInit(i);a&&(Cn(a),Qt(a));var s=Xt();o.debug(s),e.length>s.maxTextSize&&(i="graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa");var c,u,h=(0, l.select)("body");if(void 0!==r){if("sandbox"===s.securityLevel){var f=(0, l.select)("body").append("iframe").attr("id","i"+t).attr("style","width: 100%; height: 100%;").attr("sandbox","");(h=(0, l.select)(f.nodes()[0].contentDocument.body)).node().style.margin=0;}if(r.innerHTML="","sandbox"===s.securityLevel){var d=(0, l.select)(r).append("iframe").attr("id","i"+t).attr("style","width: 100%; height: 100%;").attr("sandbox","");(h=(0, l.select)(d.nodes()[0].contentDocument.body)).node().style.margin=0;}else h=(0, l.select)(r);h.append("div").attr("id","d"+t).attr("style","font-family: "+s.fontFamily).append("svg").attr("id",t).attr("width","100%").attr("xmlns","http://www.w3.org/2000/svg").attr("xmlns:xlink","http://www.w3.org/1999/xlink").append("g");}else {var p,g=document.getElementById(t);if(g&&g.remove(),(p="sandbox"!==s.securityLevel?document.querySelector("#d"+t):document.querySelector("#i"+t))&&p.remove(),"sandbox"===s.securityLevel){var y=(0, l.select)("body").append("iframe").attr("id","i"+t).attr("style","width: 100%; height: 100%;").attr("sandbox","");(h=(0, l.select)(y.nodes()[0].contentDocument.body)).node().style.margin=0;}else h=(0, l.select)("body");h.append("div").attr("id","d"+t).append("svg").attr("id",t).attr("width","100%").attr("xmlns","http://www.w3.org/2000/svg").append("g");}i=i.replace(/style.*:\S*#.*;/g,(function(t){return t.substring(0,t.length-1)})).replace(/classDef.*:\S*#.*;/g,(function(t){return t.substring(0,t.length-1)})).replace(/#\w+;/g,(function(t){var e=t.substring(1,t.length-1);return /^\+?\d+$/.test(e)?"fl°°"+e+"¶ß":"fl°"+e+"¶ß"}));try{c=new Ql(i);}catch(t){c=new Ql("error"),u=t;}var m=h.select("#d"+t).node(),b=c.type,v=m.firstChild,_=v.firstChild,x="";if(void 0!==s.themeCSS&&(x+="\n".concat(s.themeCSS)),void 0!==s.fontFamily&&(x+="\n:root { --mermaid-font-family: ".concat(s.fontFamily,"}")),void 0!==s.altFontFamily&&(x+="\n:root { --mermaid-alt-font-family: ".concat(s.altFontFamily,"}")),"flowchart"===b||"flowchart-v2"===b||"graph"===b){var k=Na.getClasses(i,c),E=s.htmlLabels||s.flowchart.htmlLabels;for(var C in k)E?(x+="\n.".concat(C," > * { ").concat(k[C].styles.join(" !important; ")," !important; }"),x+="\n.".concat(C," span { ").concat(k[C].styles.join(" !important; ")," !important; }")):(x+="\n.".concat(C," path { ").concat(k[C].styles.join(" !important; ")," !important; }"),x+="\n.".concat(C," rect { ").concat(k[C].styles.join(" !important; ")," !important; }"),x+="\n.".concat(C," polygon { ").concat(k[C].styles.join(" !important; ")," !important; }"),x+="\n.".concat(C," ellipse { ").concat(k[C].styles.join(" !important; ")," !important; }"),x+="\n.".concat(C," circle { ").concat(k[C].styles.join(" !important; ")," !important; }"),k[C].textStyles&&(x+="\n.".concat(C," tspan { ").concat(k[C].textStyles.join(" !important; ")," !important; }")));}var S=function(t,e){return w(W("".concat(t,"{").concat(e,"}")),T)}("#".concat(t),function(t,e,n){return " {\n font-family: ".concat(n.fontFamily,";\n font-size: ").concat(n.fontSize,";\n fill: ").concat(n.textColor,"\n }\n\n /* Classes common for multiple diagrams */\n\n .error-icon {\n fill: ").concat(n.errorBkgColor,";\n }\n .error-text {\n fill: ").concat(n.errorTextColor,";\n stroke: ").concat(n.errorTextColor,";\n }\n\n .edge-thickness-normal {\n stroke-width: 2px;\n }\n .edge-thickness-thick {\n stroke-width: 3.5px\n }\n .edge-pattern-solid {\n stroke-dasharray: 0;\n }\n\n .edge-pattern-dashed{\n stroke-dasharray: 3;\n }\n .edge-pattern-dotted {\n stroke-dasharray: 2;\n }\n\n .marker {\n fill: ").concat(n.lineColor,";\n stroke: ").concat(n.lineColor,";\n }\n .marker.cross {\n stroke: ").concat(n.lineColor,";\n }\n\n svg {\n font-family: ").concat(n.fontFamily,";\n font-size: ").concat(n.fontSize,";\n }\n\n ").concat(eu[t](n),"\n\n ").concat(e,"\n")}(b,x,s.themeVariables)),A=document.createElement("style");A.innerHTML="#".concat(t," ")+S,v.insertBefore(A,_);try{c.renderer.draw(i,t,X,c);}catch(e){throw Bi.draw(t,X),e}h.select('[id="'.concat(t,'"]')).selectAll("foreignobject > *").attr("xmlns","http://www.w3.org/1999/xhtml");var M=h.select("#d"+t).node().innerHTML;if(o.debug("cnf.arrowMarkerAbsolute",s.arrowMarkerAbsolute),s.arrowMarkerAbsolute&&"false"!==s.arrowMarkerAbsolute||"sandbox"===s.arrowMarkerAbsolute||(M=M.replace(/marker-end="url\(.*?#/g,'marker-end="url(#',"g")),M=(M=iu(M)).replace(/<br>/g,"<br/>"),"sandbox"===s.securityLevel){var N=h.select("#d"+t+" svg").node(),O="100%";N&&(O=N.viewBox.baseVal.height+"px"),M='<iframe style="width:'.concat("100%",";height:").concat(O,';border:0;margin:0;" src="data:text/html;base64,').concat(btoa('<body style="margin:0">'+M+"</body>"),'" sandbox="allow-top-navigation-by-user-activation allow-popups">\n The “iframe” tag is not supported by your browser.\n</iframe>');}else "loose"!==s.securityLevel&&(M=te().sanitize(M,{ADD_TAGS:["foreignobject"],ADD_ATTR:["dominant-baseline"]}));if(void 0!==n)switch(b){case"flowchart":case"flowchart-v2":n(M,la.bindFunctions);break;case"gantt":n(M,go.bindFunctions);break;case"class":case"classDiagram":n(M,fr.bindFunctions);break;default:n(M);}else o.debug("CB = undefined!");vs.forEach((function(t){t();})),vs=[];var D="sandbox"===s.securityLevel?"#i"+t:"#d"+t,B=(0, l.select)(D).node();if(null!==B&&"function"==typeof B.remove&&(0, l.select)(D).node().remove(),u)throw u;return M},parse:function(t,e){ru||(Vl(),ru=!0);var n=!1;try{var r=e||new Ql(t);return r.db.clear(),r.parse(t)}catch(t){if(n=!0,!fu.parseError)throw t;null!=t.str?fu.parseError(t.str,t.hash):fu.parseError(t);}return !n},parseDirective:function(t,e,n,r){try{if(void 0!==e)switch(e=e.trim(),n){case"open_directive":au={};break;case"type_directive":au.type=e.toLowerCase();break;case"arg_directive":au.args=JSON.parse(e);break;case"close_directive":(function(t,e,n){switch(o.debug("Directive type=".concat(e.type," with args:"),e.args),e.type){case"init":case"initialize":["config"].forEach((function(t){void 0!==e.args[t]&&("flowchart-v2"===n&&(n="flowchart"),e.args[n]=e.args[t],delete e.args[t]);})),o.debug("sanitize in handleDirective",e.args),Cn(e.args),o.debug("sanitize in handleDirective (done)",e.args),Qt(e.args);break;case"wrap":case"nowrap":t&&t.setWrap&&t.setWrap("wrap"===e.type);break;case"themeCss":o.warn("themeCss encountered");break;default:o.warn("Unhandled directive: source: '%%{".concat(e.type,": ").concat(JSON.stringify(e.args?e.args:{}),"}%%"),e);}})(t,au,r),au=null;}}catch(t){o.error("Error while rendering sequenceDiagram directive: ".concat(e," jison context: ").concat(n)),o.error(t.message);}},initialize:function(t){var e;null!=t&&t.fontFamily&&(null!==(e=t.themeVariables)&&void 0!==e&&e.fontFamily||(t.themeVariables={fontFamily:t.fontFamily})),function(t){Ut=Q({},t);}(t),null!=t&&t.theme&&Lt[t.theme]?t.themeVariables=Lt[t.theme].getThemeVariables(t.themeVariables):t&&(t.themeVariables=Lt.default.getThemeVariables(t.themeVariables));var n="object"===nu(t)?function(t){return Wt=Q({},$t),Wt=Q(Wt,t),t.theme&&Lt[t.theme]&&(Wt.themeVariables=Lt[t.theme].getThemeVariables(t.themeVariables)),Ht=Vt(Wt,qt),Wt}(t):Gt();ou(n),s(n.logLevel),ru||(Vl(),ru=!0);},getConfig:Xt,setConfig:function(t){return Q(Ht,t),Xt()},getSiteConfig:Gt,updateSiteConfig:function(t){return Wt=Q(Wt,t),Vt(Wt,qt),Wt},reset:function(){Kt();},globalReset:function(){Kt(),ou(Xt());},defaultConfig:$t});s(Xt().logLevel),Kt(Xt());const cu=su;var lu=function(){var t,e,n=cu.getConfig();arguments.length>=2?(void 0!==arguments[0]&&(hu.sequenceConfig=arguments[0]),t=arguments[1]):t=arguments[0],"function"==typeof arguments[arguments.length-1]?(e=arguments[arguments.length-1],o.debug("Callback function found")):void 0!==n.mermaid&&("function"==typeof n.mermaid.callback?(e=n.mermaid.callback,o.debug("Callback function found")):o.debug("No Callback function found")),t=void 0===t?document.querySelectorAll(".mermaid"):"string"==typeof t?document.querySelectorAll(t):t instanceof window.Node?[t]:t,o.debug("Start On Load before: "+hu.startOnLoad),void 0!==hu.startOnLoad&&(o.debug("Start On Load inner: "+hu.startOnLoad),cu.updateSiteConfig({startOnLoad:hu.startOnLoad})),void 0!==hu.ganttConfig&&cu.updateSiteConfig({gantt:hu.ganttConfig});for(var r,i=new An.initIdGenerator(n.deterministicIds,n.deterministicIDSeed),a=[],s=function(n){o.info("Rendering diagram: "+t[n].id,n);var s=t[n];if(s.getAttribute("data-processed"))return "continue";s.setAttribute("data-processed",!0);var c="mermaid-".concat(i.next());r=s.innerHTML,r=An.entityDecode(r).trim().replace(/<br\s*\/?>/gi,"<br/>");var l=An.detectInit(r);l&&o.debug("Detected early reinit: ",l);try{cu.render(c,r,(function(t,n){s.innerHTML=t,void 0!==e&&e(c),n&&n(s);}),s);}catch(t){o.warn("Catching Error (bootstrap)",t),"function"==typeof hu.parseError&&hu.parseError({error:t,str:t.str,hash:t.hash,message:t.str}),a.push({error:t,str:t.str,hash:t.hash,message:t.str});}},c=0;c<t.length;c++)s(c);if(a.length>0)throw a[0]},uu=function(){hu.startOnLoad?cu.getConfig().startOnLoad&&hu.init():void 0===hu.startOnLoad&&(o.debug("In start, no config"),cu.getConfig().startOnLoad&&hu.init());};"undefined"!=typeof document&&window.addEventListener("load",(function(){uu();}),!1);var hu={startOnLoad:!0,htmlLabels:!0,diagrams:{},mermaidAPI:cu,parse:null!=cu?cu.parse:null,render:null!=cu?cu.render:null,init:function(){try{lu.apply(void 0,arguments);}catch(t){o.warn("Syntax Error rendering"),o.warn(t.str);}},initThrowsErrors:lu,initialize:function(t){void 0!==t.mermaid&&(void 0!==t.mermaid.startOnLoad&&(hu.startOnLoad=t.mermaid.startOnLoad),void 0!==t.mermaid.htmlLabels&&(hu.htmlLabels="false"!==t.mermaid.htmlLabels&&!1!==t.mermaid.htmlLabels)),cu.initialize(t);},contentLoaded:uu,setParseErrorHandler:function(t){hu.parseError=t;}};const fu=hu;},4949:(t,e,n)=>{t.exports={graphlib:n(6614),dagre:n(6478),intersect:n(8114),render:n(5787),util:n(8355),version:n(5689)};},9144:(t,e,n)=>{var r=n(8355);function i(t,e,n,i){var a=t.append("marker").attr("id",e).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerUnits","strokeWidth").attr("markerWidth",8).attr("markerHeight",6).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").style("stroke-width",1).style("stroke-dasharray","1,0");r.applyStyle(a,n[i+"Style"]),n[i+"Class"]&&a.attr("class",n[i+"Class"]);}t.exports={default:i,normal:i,vee:function(t,e,n,i){var a=t.append("marker").attr("id",e).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerUnits","strokeWidth").attr("markerWidth",8).attr("markerHeight",6).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 L 4 5 z").style("stroke-width",1).style("stroke-dasharray","1,0");r.applyStyle(a,n[i+"Style"]),n[i+"Class"]&&a.attr("class",n[i+"Class"]);},undirected:function(t,e,n,i){var a=t.append("marker").attr("id",e).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerUnits","strokeWidth").attr("markerWidth",8).attr("markerHeight",6).attr("orient","auto").append("path").attr("d","M 0 5 L 10 5").style("stroke-width",1).style("stroke-dasharray","1,0");r.applyStyle(a,n[i+"Style"]),n[i+"Class"]&&a.attr("class",n[i+"Class"]);}};},5632:(t,e,n)=>{var r=n(8355),i=n(4322),a=n(1322);t.exports=function(t,e){var n,o=e.nodes().filter((function(t){return r.isSubgraph(e,t)})),s=t.selectAll("g.cluster").data(o,(function(t){return t}));return s.selectAll("*").remove(),s.enter().append("g").attr("class","cluster").attr("id",(function(t){return e.node(t).id})).style("opacity",0),s=t.selectAll("g.cluster"),r.applyTransition(s,e).style("opacity",1),s.each((function(t){var n=e.node(t),r=i.select(this);i.select(this).append("rect");var o=r.append("g").attr("class","label");a(o,n,n.clusterLabelPos);})),s.selectAll("rect").each((function(t){var n=e.node(t),a=i.select(this);r.applyStyle(a,n.style);})),n=s.exit?s.exit():s.selectAll(null),r.applyTransition(n,e).style("opacity",0).remove(),s};},6315:(t,e,n)=>{var r=n(1034),i=n(1322),a=n(8355),o=n(4322);t.exports=function(t,e){var n,s=t.selectAll("g.edgeLabel").data(e.edges(),(function(t){return a.edgeToId(t)})).classed("update",!0);return s.exit().remove(),s.enter().append("g").classed("edgeLabel",!0).style("opacity",0),(s=t.selectAll("g.edgeLabel")).each((function(t){var n=o.select(this);n.select(".label").remove();var a=e.edge(t),s=i(n,e.edge(t),0,0).classed("label",!0),c=s.node().getBBox();a.labelId&&s.attr("id",a.labelId),r.has(a,"width")||(a.width=c.width),r.has(a,"height")||(a.height=c.height);})),n=s.exit?s.exit():s.selectAll(null),a.applyTransition(n,e).style("opacity",0).remove(),s};},940:(t,e,n)=>{var r=n(1034),i=n(3042),a=n(8355),o=n(4322);function s(t,e){var n=(o.line||o.svg.line)().x((function(t){return t.x})).y((function(t){return t.y}));return (n.curve||n.interpolate)(t.curve),n(e)}t.exports=function(t,e,n){var c=t.selectAll("g.edgePath").data(e.edges(),(function(t){return a.edgeToId(t)})).classed("update",!0),l=function(t,e){var n=t.enter().append("g").attr("class","edgePath").style("opacity",0);return n.append("path").attr("class","path").attr("d",(function(t){var n=e.edge(t),i=e.node(t.v).elem;return s(n,r.range(n.points.length).map((function(){return e=(t=i).getBBox(),{x:(n=t.ownerSVGElement.getScreenCTM().inverse().multiply(t.getScreenCTM()).translate(e.width/2,e.height/2)).e,y:n.f};var t,e,n;})))})),n.append("defs"),n}(c,e);!function(t,e){var n=t.exit();a.applyTransition(n,e).style("opacity",0).remove();}(c,e);var u=void 0!==c.merge?c.merge(l):c;return a.applyTransition(u,e).style("opacity",1),u.each((function(t){var n=o.select(this),r=e.edge(t);r.elem=this,r.id&&n.attr("id",r.id),a.applyClass(n,r.class,(n.classed("update")?"update ":"")+"edgePath");})),u.selectAll("path.path").each((function(t){var n=e.edge(t);n.arrowheadId=r.uniqueId("arrowhead");var c=o.select(this).attr("marker-end",(function(){return "url("+(t=location.href,e=n.arrowheadId,t.split("#")[0]+"#"+e+")");var t,e;})).style("fill","none");a.applyTransition(c,e).attr("d",(function(t){return function(t,e){var n=t.edge(e),r=t.node(e.v),a=t.node(e.w),o=n.points.slice(1,n.points.length-1);return o.unshift(i(r,o[0])),o.push(i(a,o[o.length-1])),s(n,o)}(e,t)})),a.applyStyle(c,n.style);})),u.selectAll("defs *").remove(),u.selectAll("defs").each((function(t){var r=e.edge(t);(0, n[r.arrowhead])(o.select(this),r.arrowheadId,r,"arrowhead");})),u};},607:(t,e,n)=>{var r=n(1034),i=n(1322),a=n(8355),o=n(4322);t.exports=function(t,e,n){var s,c=e.nodes().filter((function(t){return !a.isSubgraph(e,t)})),l=t.selectAll("g.node").data(c,(function(t){return t})).classed("update",!0);return l.exit().remove(),l.enter().append("g").attr("class","node").style("opacity",0),(l=t.selectAll("g.node")).each((function(t){var s=e.node(t),c=o.select(this);a.applyClass(c,s.class,(c.classed("update")?"update ":"")+"node"),c.select("g.label").remove();var l=c.append("g").attr("class","label"),u=i(l,s),h=n[s.shape],f=r.pick(u.node().getBBox(),"width","height");s.elem=this,s.id&&c.attr("id",s.id),s.labelId&&l.attr("id",s.labelId),r.has(s,"width")&&(f.width=s.width),r.has(s,"height")&&(f.height=s.height),f.width+=s.paddingLeft+s.paddingRight,f.height+=s.paddingTop+s.paddingBottom,l.attr("transform","translate("+(s.paddingLeft-s.paddingRight)/2+","+(s.paddingTop-s.paddingBottom)/2+")");var d=o.select(this);d.select(".label-container").remove();var p=h(d,f,s).classed("label-container",!0);a.applyStyle(p,s.style);var g=p.node().getBBox();s.width=g.width,s.height=g.height;})),s=l.exit?l.exit():l.selectAll(null),a.applyTransition(s,e).style("opacity",0).remove(),l};},4322:(t,e,n)=>{var r;if(!r)try{r=n(7543);}catch(t){}r||(r=window.d3),t.exports=r;},6478:(t,e,n)=>{var r;try{r=n(681);}catch(t){}r||(r=window.dagre),t.exports=r;},6614:(t,e,n)=>{var r;try{r=n(8282);}catch(t){}r||(r=window.graphlib),t.exports=r;},8114:(t,e,n)=>{t.exports={node:n(3042),circle:n(6587),ellipse:n(3260),polygon:n(5337),rect:n(8049)};},6587:(t,e,n)=>{var r=n(3260);t.exports=function(t,e,n){return r(t,e,e,n)};},3260:t=>{t.exports=function(t,e,n,r){var i=t.x,a=t.y,o=i-r.x,s=a-r.y,c=Math.sqrt(e*e*s*s+n*n*o*o),l=Math.abs(e*n*o/c);r.x<i&&(l=-l);var u=Math.abs(e*n*s/c);return r.y<a&&(u=-u),{x:i+l,y:a+u}};},6808:t=>{function e(t,e){return t*e>0}t.exports=function(t,n,r,i){var a,o,s,c,l,u,h,f,d,p,g,y,m;if(!(a=n.y-t.y,s=t.x-n.x,l=n.x*t.y-t.x*n.y,d=a*r.x+s*r.y+l,p=a*i.x+s*i.y+l,0!==d&&0!==p&&e(d,p)||(o=i.y-r.y,c=r.x-i.x,u=i.x*r.y-r.x*i.y,h=o*t.x+c*t.y+u,f=o*n.x+c*n.y+u,0!==h&&0!==f&&e(h,f)||0==(g=a*c-o*s))))return y=Math.abs(g/2),{x:(m=s*u-c*l)<0?(m-y)/g:(m+y)/g,y:(m=o*l-a*u)<0?(m-y)/g:(m+y)/g}};},3042:t=>{t.exports=function(t,e){return t.intersect(e)};},5337:(t,e,n)=>{var r=n(6808);t.exports=function(t,e,n){var i=t.x,a=t.y,o=[],s=Number.POSITIVE_INFINITY,c=Number.POSITIVE_INFINITY;e.forEach((function(t){s=Math.min(s,t.x),c=Math.min(c,t.y);}));for(var l=i-t.width/2-s,u=a-t.height/2-c,h=0;h<e.length;h++){var f=e[h],d=e[h<e.length-1?h+1:0],p=r(t,n,{x:l+f.x,y:u+f.y},{x:l+d.x,y:u+d.y});p&&o.push(p);}return o.length?(o.length>1&&o.sort((function(t,e){var r=t.x-n.x,i=t.y-n.y,a=Math.sqrt(r*r+i*i),o=e.x-n.x,s=e.y-n.y,c=Math.sqrt(o*o+s*s);return a<c?-1:a===c?0:1})),o[0]):(console.log("NO INTERSECTION FOUND, RETURN NODE CENTER",t),t)};},8049:t=>{t.exports=function(t,e){var n,r,i=t.x,a=t.y,o=e.x-i,s=e.y-a,c=t.width/2,l=t.height/2;return Math.abs(s)*c>Math.abs(o)*l?(s<0&&(l=-l),n=0===s?0:l*o/s,r=l):(o<0&&(c=-c),n=c,r=0===o?0:c*s/o),{x:i+n,y:a+r}};},8284:(t,e,n)=>{var r=n(8355);t.exports=function(t,e){var n=t.append("foreignObject").attr("width","100000"),i=n.append("xhtml:div");i.attr("xmlns","http://www.w3.org/1999/xhtml");var a=e.label;switch(typeof a){case"function":i.insert(a);break;case"object":i.insert((function(){return a}));break;default:i.html(a);}r.applyStyle(i,e.labelStyle),i.style("display","inline-block"),i.style("white-space","nowrap");var o=i.node().getBoundingClientRect();return n.attr("width",o.width).attr("height",o.height),n};},1322:(t,e,n)=>{var r=n(7318),i=n(8284),a=n(8287);t.exports=function(t,e,n){var o=e.label,s=t.append("g");"svg"===e.labelType?a(s,e):"string"!=typeof o||"html"===e.labelType?i(s,e):r(s,e);var c,l=s.node().getBBox();switch(n){case"top":c=-e.height/2;break;case"bottom":c=e.height/2-l.height;break;default:c=-l.height/2;}return s.attr("transform","translate("+-l.width/2+","+c+")"),s};},8287:(t,e,n)=>{var r=n(8355);t.exports=function(t,e){var n=t;return n.node().appendChild(e.label),r.applyStyle(n,e.labelStyle),n};},7318:(t,e,n)=>{var r=n(8355);t.exports=function(t,e){for(var n=t.append("text"),i=function(t){for(var e,n="",r=!1,i=0;i<t.length;++i)e=t[i],r?(n+="n"===e?"\n":e,r=!1):"\\"===e?r=!0:n+=e;return n}(e.label).split("\n"),a=0;a<i.length;a++)n.append("tspan").attr("xml:space","preserve").attr("dy","1em").attr("x","1").text(i[a]);return r.applyStyle(n,e.labelStyle),n};},1034:(t,e,n)=>{var r;try{r={defaults:n(1747),each:n(6073),isFunction:n(3560),isPlainObject:n(8630),pick:n(9722),has:n(8721),range:n(6026),uniqueId:n(3955)};}catch(t){}r||(r=window._),t.exports=r;},6381:(t,e,n)=>{var r=n(8355),i=n(4322);t.exports=function(t,e){var n=t.filter((function(){return !i.select(this).classed("update")}));function a(t){var n=e.node(t);return "translate("+n.x+","+n.y+")"}n.attr("transform",a),r.applyTransition(t,e).style("opacity",1).attr("transform",a),r.applyTransition(n.selectAll("rect"),e).attr("width",(function(t){return e.node(t).width})).attr("height",(function(t){return e.node(t).height})).attr("x",(function(t){return -e.node(t).width/2})).attr("y",(function(t){return -e.node(t).height/2}));};},4577:(t,e,n)=>{var r=n(8355),i=n(4322),a=n(1034);t.exports=function(t,e){function n(t){var n=e.edge(t);return a.has(n,"x")?"translate("+n.x+","+n.y+")":""}t.filter((function(){return !i.select(this).classed("update")})).attr("transform",n),r.applyTransition(t,e).style("opacity",1).attr("transform",n);};},4849:(t,e,n)=>{var r=n(8355),i=n(4322);t.exports=function(t,e){function n(t){var n=e.node(t);return "translate("+n.x+","+n.y+")"}t.filter((function(){return !i.select(this).classed("update")})).attr("transform",n),r.applyTransition(t,e).style("opacity",1).attr("transform",n);};},5787:(t,e,n)=>{var r=n(1034),i=n(4322),a=n(6478).layout;t.exports=function(){var t=n(607),e=n(5632),i=n(6315),l=n(940),u=n(4849),h=n(4577),f=n(6381),d=n(4418),p=n(9144),g=function(n,g){!function(t){t.nodes().forEach((function(e){var n=t.node(e);r.has(n,"label")||t.children(e).length||(n.label=e),r.has(n,"paddingX")&&r.defaults(n,{paddingLeft:n.paddingX,paddingRight:n.paddingX}),r.has(n,"paddingY")&&r.defaults(n,{paddingTop:n.paddingY,paddingBottom:n.paddingY}),r.has(n,"padding")&&r.defaults(n,{paddingLeft:n.padding,paddingRight:n.padding,paddingTop:n.padding,paddingBottom:n.padding}),r.defaults(n,o),r.each(["paddingLeft","paddingRight","paddingTop","paddingBottom"],(function(t){n[t]=Number(n[t]);})),r.has(n,"width")&&(n._prevWidth=n.width),r.has(n,"height")&&(n._prevHeight=n.height);})),t.edges().forEach((function(e){var n=t.edge(e);r.has(n,"label")||(n.label=""),r.defaults(n,s);}));}(g);var y=c(n,"output"),m=c(y,"clusters"),b=c(y,"edgePaths"),v=i(c(y,"edgeLabels"),g),_=t(c(y,"nodes"),g,d);a(g),u(_,g),h(v,g),l(b,g,p);var x=e(m,g);f(x,g),function(t){r.each(t.nodes(),(function(e){var n=t.node(e);r.has(n,"_prevWidth")?n.width=n._prevWidth:delete n.width,r.has(n,"_prevHeight")?n.height=n._prevHeight:delete n.height,delete n._prevWidth,delete n._prevHeight;}));}(g);};return g.createNodes=function(e){return arguments.length?(t=e,g):t},g.createClusters=function(t){return arguments.length?(e=t,g):e},g.createEdgeLabels=function(t){return arguments.length?(i=t,g):i},g.createEdgePaths=function(t){return arguments.length?(l=t,g):l},g.shapes=function(t){return arguments.length?(d=t,g):d},g.arrows=function(t){return arguments.length?(p=t,g):p},g};var o={paddingLeft:10,paddingRight:10,paddingTop:10,paddingBottom:10,rx:0,ry:0,shape:"rect"},s={arrowhead:"normal",curve:i.curveLinear};function c(t,e){var n=t.select("g."+e);return n.empty()&&(n=t.append("g").attr("class",e)),n}},4418:(t,e,n)=>{var r=n(8049),i=n(3260),a=n(6587),o=n(5337);t.exports={rect:function(t,e,n){var i=t.insert("rect",":first-child").attr("rx",n.rx).attr("ry",n.ry).attr("x",-e.width/2).attr("y",-e.height/2).attr("width",e.width).attr("height",e.height);return n.intersect=function(t){return r(n,t)},i},ellipse:function(t,e,n){var r=e.width/2,a=e.height/2,o=t.insert("ellipse",":first-child").attr("x",-e.width/2).attr("y",-e.height/2).attr("rx",r).attr("ry",a);return n.intersect=function(t){return i(n,r,a,t)},o},circle:function(t,e,n){var r=Math.max(e.width,e.height)/2,i=t.insert("circle",":first-child").attr("x",-e.width/2).attr("y",-e.height/2).attr("r",r);return n.intersect=function(t){return a(n,r,t)},i},diamond:function(t,e,n){var r=e.width*Math.SQRT2/2,i=e.height*Math.SQRT2/2,a=[{x:0,y:-i},{x:-r,y:0},{x:0,y:i},{x:r,y:0}],s=t.insert("polygon",":first-child").attr("points",a.map((function(t){return t.x+","+t.y})).join(" "));return n.intersect=function(t){return o(n,a,t)},s}};},8355:(t,e,n)=>{var r=n(1034);t.exports={isSubgraph:function(t,e){return !!t.children(e).length},edgeToId:function(t){return a(t.v)+":"+a(t.w)+":"+a(t.name)},applyStyle:function(t,e){e&&t.attr("style",e);},applyClass:function(t,e,n){e&&t.attr("class",e).attr("class",n+" "+t.attr("class"));},applyTransition:function(t,e){var n=e.graph();if(r.isPlainObject(n)){var i=n.transition;if(r.isFunction(i))return i(t)}return t}};var i=/:/g;function a(t){return t?String(t).replace(i,"\\:"):""}},5689:t=>{t.exports="0.6.4";},681:(t,e,n)=>{t.exports={graphlib:n(574),layout:n(8123),debug:n(7570),util:{time:n(1138).time,notime:n(1138).notime},version:n(8177)};},2188:(t,e,n)=>{var r=n(8436),i=n(4079);t.exports={run:function(t){var e="greedy"===t.graph().acyclicer?i(t,function(t){return function(e){return t.edge(e).weight}}(t)):function(t){var e=[],n={},i={};return r.forEach(t.nodes(),(function a(o){r.has(i,o)||(i[o]=!0,n[o]=!0,r.forEach(t.outEdges(o),(function(t){r.has(n,t.w)?e.push(t):a(t.w);})),delete n[o]);})),e}(t);r.forEach(e,(function(e){var n=t.edge(e);t.removeEdge(e),n.forwardName=e.name,n.reversed=!0,t.setEdge(e.w,e.v,n,r.uniqueId("rev"));}));},undo:function(t){r.forEach(t.edges(),(function(e){var n=t.edge(e);if(n.reversed){t.removeEdge(e);var r=n.forwardName;delete n.reversed,delete n.forwardName,t.setEdge(e.w,e.v,n,r);}}));}};},1133:(t,e,n)=>{var r=n(8436),i=n(1138);function a(t,e,n,r,a,o){var s={width:0,height:0,rank:o,borderType:e},c=a[e][o-1],l=i.addDummyNode(t,"border",s,n);a[e][o]=l,t.setParent(l,r),c&&t.setEdge(c,l,{weight:1});}t.exports=function(t){r.forEach(t.children(),(function e(n){var i=t.children(n),o=t.node(n);if(i.length&&r.forEach(i,e),r.has(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(var s=o.minRank,c=o.maxRank+1;s<c;++s)a(t,"borderLeft","_bl",n,o,s),a(t,"borderRight","_br",n,o,s);}}));};},3258:(t,e,n)=>{var r=n(8436);function i(t){r.forEach(t.nodes(),(function(e){a(t.node(e));})),r.forEach(t.edges(),(function(e){a(t.edge(e));}));}function a(t){var e=t.width;t.width=t.height,t.height=e;}function o(t){t.y=-t.y;}function s(t){var e=t.x;t.x=t.y,t.y=e;}t.exports={adjust:function(t){var e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||i(t);},undo:function(t){var e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){r.forEach(t.nodes(),(function(e){o(t.node(e));})),r.forEach(t.edges(),(function(e){var n=t.edge(e);r.forEach(n.points,o),r.has(n,"y")&&o(n);}));}(t),"lr"!==e&&"rl"!==e||(function(t){r.forEach(t.nodes(),(function(e){s(t.node(e));})),r.forEach(t.edges(),(function(e){var n=t.edge(e);r.forEach(n.points,s),r.has(n,"x")&&s(n);}));}(t),i(t));}};},7822:t=>{function e(){var t={};t._next=t._prev=t,this._sentinel=t;}function n(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev;}function r(t,e){if("_next"!==t&&"_prev"!==t)return e}t.exports=e,e.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return n(e),e},e.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&n(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e;},e.prototype.toString=function(){for(var t=[],e=this._sentinel,n=e._prev;n!==e;)t.push(JSON.stringify(n,r)),n=n._prev;return "["+t.join(", ")+"]"};},7570:(t,e,n)=>{var r=n(8436),i=n(1138),a=n(574).Graph;t.exports={debugOrdering:function(t){var e=i.buildLayerMatrix(t),n=new a({compound:!0,multigraph:!0}).setGraph({});return r.forEach(t.nodes(),(function(e){n.setNode(e,{label:e}),n.setParent(e,"layer"+t.node(e).rank);})),r.forEach(t.edges(),(function(t){n.setEdge(t.v,t.w,{},t.name);})),r.forEach(e,(function(t,e){var i="layer"+e;n.setNode(i,{rank:"same"}),r.reduce(t,(function(t,e){return n.setEdge(t,e,{style:"invis"}),e}));})),n}};},574:(t,e,n)=>{var r;try{r=n(8282);}catch(t){}r||(r=window.graphlib),t.exports=r;},4079:(t,e,n)=>{var r=n(8436),i=n(574).Graph,a=n(7822);t.exports=function(t,e){if(t.nodeCount()<=1)return [];var n=function(t,e){var n=new i,o=0,s=0;r.forEach(t.nodes(),(function(t){n.setNode(t,{v:t,in:0,out:0});})),r.forEach(t.edges(),(function(t){var r=n.edge(t.v,t.w)||0,i=e(t),a=r+i;n.setEdge(t.v,t.w,a),s=Math.max(s,n.node(t.v).out+=i),o=Math.max(o,n.node(t.w).in+=i);}));var l=r.range(s+o+3).map((function(){return new a})),u=o+1;return r.forEach(n.nodes(),(function(t){c(l,u,n.node(t));})),{graph:n,buckets:l,zeroIdx:u}}(t,e||o),l=function(t,e,n){for(var r,i=[],a=e[e.length-1],o=e[0];t.nodeCount();){for(;r=o.dequeue();)s(t,e,n,r);for(;r=a.dequeue();)s(t,e,n,r);if(t.nodeCount())for(var c=e.length-2;c>0;--c)if(r=e[c].dequeue()){i=i.concat(s(t,e,n,r,!0));break}}return i}(n.graph,n.buckets,n.zeroIdx);return r.flatten(r.map(l,(function(e){return t.outEdges(e.v,e.w)})),!0)};var o=r.constant(1);function s(t,e,n,i,a){var o=a?[]:void 0;return r.forEach(t.inEdges(i.v),(function(r){var i=t.edge(r),s=t.node(r.v);a&&o.push({v:r.v,w:r.w}),s.out-=i,c(e,n,s);})),r.forEach(t.outEdges(i.v),(function(r){var i=t.edge(r),a=r.w,o=t.node(a);o.in-=i,c(e,n,o);})),t.removeNode(i.v),o}function c(t,e,n){n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n);}},8123:(t,e,n)=>{var r=n(8436),i=n(2188),a=n(5995),o=n(8093),s=n(1138).normalizeRanks,c=n(4219),l=n(1138).removeEmptyRanks,u=n(2981),h=n(1133),f=n(3258),d=n(3408),p=n(7873),g=n(1138),y=n(574).Graph;t.exports=function(t,e){var n=e&&e.debugTiming?g.time:g.notime;n("layout",(function(){var e=n(" buildLayoutGraph",(function(){return function(t){var e=new y({multigraph:!0,compound:!0}),n=C(t.graph());return e.setGraph(r.merge({},b,E(n,m),r.pick(n,v))),r.forEach(t.nodes(),(function(n){var i=C(t.node(n));e.setNode(n,r.defaults(E(i,_),x)),e.setParent(n,t.parent(n));})),r.forEach(t.edges(),(function(n){var i=C(t.edge(n));e.setEdge(n,r.merge({},w,E(i,k),r.pick(i,T)));})),e}(t)}));n(" runLayout",(function(){!function(t,e){e(" makeSpaceForEdgeLabels",(function(){!function(t){var e=t.graph();e.ranksep/=2,r.forEach(t.edges(),(function(n){var r=t.edge(n);r.minlen*=2,"c"!==r.labelpos.toLowerCase()&&("TB"===e.rankdir||"BT"===e.rankdir?r.width+=r.labeloffset:r.height+=r.labeloffset);}));}(t);})),e(" removeSelfEdges",(function(){!function(t){r.forEach(t.edges(),(function(e){if(e.v===e.w){var n=t.node(e.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e,label:t.edge(e)}),t.removeEdge(e);}}));}(t);})),e(" acyclic",(function(){i.run(t);})),e(" nestingGraph.run",(function(){u.run(t);})),e(" rank",(function(){o(g.asNonCompoundGraph(t));})),e(" injectEdgeLabelProxies",(function(){!function(t){r.forEach(t.edges(),(function(e){var n=t.edge(e);if(n.width&&n.height){var r=t.node(e.v),i={rank:(t.node(e.w).rank-r.rank)/2+r.rank,e};g.addDummyNode(t,"edge-proxy",i,"_ep");}}));}(t);})),e(" removeEmptyRanks",(function(){l(t);})),e(" nestingGraph.cleanup",(function(){u.cleanup(t);})),e(" normalizeRanks",(function(){s(t);})),e(" assignRankMinMax",(function(){!function(t){var e=0;r.forEach(t.nodes(),(function(n){var i=t.node(n);i.borderTop&&(i.minRank=t.node(i.borderTop).rank,i.maxRank=t.node(i.borderBottom).rank,e=r.max(e,i.maxRank));})),t.graph().maxRank=e;}(t);})),e(" removeEdgeLabelProxies",(function(){!function(t){r.forEach(t.nodes(),(function(e){var n=t.node(e);"edge-proxy"===n.dummy&&(t.edge(n.e).labelRank=n.rank,t.removeNode(e));}));}(t);})),e(" normalize.run",(function(){a.run(t);})),e(" parentDummyChains",(function(){c(t);})),e(" addBorderSegments",(function(){h(t);})),e(" order",(function(){d(t);})),e(" insertSelfEdges",(function(){!function(t){var e=g.buildLayerMatrix(t);r.forEach(e,(function(e){var n=0;r.forEach(e,(function(e,i){var a=t.node(e);a.order=i+n,r.forEach(a.selfEdges,(function(e){g.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:a.rank,order:i+ ++n,e:e.e,label:e.label},"_se");})),delete a.selfEdges;}));}));}(t);})),e(" adjustCoordinateSystem",(function(){f.adjust(t);})),e(" position",(function(){p(t);})),e(" positionSelfEdges",(function(){!function(t){r.forEach(t.nodes(),(function(e){var n=t.node(e);if("selfedge"===n.dummy){var r=t.node(n.e.v),i=r.x+r.width/2,a=r.y,o=n.x-i,s=r.height/2;t.setEdge(n.e,n.label),t.removeNode(e),n.label.points=[{x:i+2*o/3,y:a-s},{x:i+5*o/6,y:a-s},{x:i+o,y:a},{x:i+5*o/6,y:a+s},{x:i+2*o/3,y:a+s}],n.label.x=n.x,n.label.y=n.y;}}));}(t);})),e(" removeBorderNodes",(function(){!function(t){r.forEach(t.nodes(),(function(e){if(t.children(e).length){var n=t.node(e),i=t.node(n.borderTop),a=t.node(n.borderBottom),o=t.node(r.last(n.borderLeft)),s=t.node(r.last(n.borderRight));n.width=Math.abs(s.x-o.x),n.height=Math.abs(a.y-i.y),n.x=o.x+n.width/2,n.y=i.y+n.height/2;}})),r.forEach(t.nodes(),(function(e){"border"===t.node(e).dummy&&t.removeNode(e);}));}(t);})),e(" normalize.undo",(function(){a.undo(t);})),e(" fixupEdgeLabelCoords",(function(){!function(t){r.forEach(t.edges(),(function(e){var n=t.edge(e);if(r.has(n,"x"))switch("l"!==n.labelpos&&"r"!==n.labelpos||(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;}}));}(t);})),e(" undoCoordinateSystem",(function(){f.undo(t);})),e(" translateGraph",(function(){!function(t){var e=Number.POSITIVE_INFINITY,n=0,i=Number.POSITIVE_INFINITY,a=0,o=t.graph(),s=o.marginx||0,c=o.marginy||0;function l(t){var r=t.x,o=t.y,s=t.width,c=t.height;e=Math.min(e,r-s/2),n=Math.max(n,r+s/2),i=Math.min(i,o-c/2),a=Math.max(a,o+c/2);}r.forEach(t.nodes(),(function(e){l(t.node(e));})),r.forEach(t.edges(),(function(e){var n=t.edge(e);r.has(n,"x")&&l(n);})),e-=s,i-=c,r.forEach(t.nodes(),(function(n){var r=t.node(n);r.x-=e,r.y-=i;})),r.forEach(t.edges(),(function(n){var a=t.edge(n);r.forEach(a.points,(function(t){t.x-=e,t.y-=i;})),r.has(a,"x")&&(a.x-=e),r.has(a,"y")&&(a.y-=i);})),o.width=n-e+s,o.height=a-i+c;}(t);})),e(" assignNodeIntersects",(function(){!function(t){r.forEach(t.edges(),(function(e){var n,r,i=t.edge(e),a=t.node(e.v),o=t.node(e.w);i.points?(n=i.points[0],r=i.points[i.points.length-1]):(i.points=[],n=o,r=a),i.points.unshift(g.intersectRect(a,n)),i.points.push(g.intersectRect(o,r));}));}(t);})),e(" reversePoints",(function(){!function(t){r.forEach(t.edges(),(function(e){var n=t.edge(e);n.reversed&&n.points.reverse();}));}(t);})),e(" acyclic.undo",(function(){i.undo(t);}));}(e,n);})),n(" updateInputGraph",(function(){!function(t,e){r.forEach(t.nodes(),(function(n){var r=t.node(n),i=e.node(n);r&&(r.x=i.x,r.y=i.y,e.children(n).length&&(r.width=i.width,r.height=i.height));})),r.forEach(t.edges(),(function(n){var i=t.edge(n),a=e.edge(n);i.points=a.points,r.has(a,"x")&&(i.x=a.x,i.y=a.y);})),t.graph().width=e.graph().width,t.graph().height=e.graph().height;}(t,e);}));}));};var m=["nodesep","edgesep","ranksep","marginx","marginy"],b={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},v=["acyclicer","ranker","rankdir","align"],_=["width","height"],x={width:0,height:0},k=["minlen","weight","width","height","labeloffset"],w={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},T=["labelpos"];function E(t,e){return r.mapValues(r.pick(t,e),Number)}function C(t){var e={};return r.forEach(t,(function(t,n){e[n.toLowerCase()]=t;})),e}},8436:(t,e,n)=>{var r;try{r={cloneDeep:n(361),constant:n(5703),defaults:n(1747),each:n(6073),filter:n(3105),find:n(3311),flatten:n(5564),forEach:n(4486),forIn:n(2620),has:n(8721),isUndefined:n(2353),last:n(928),map:n(5161),mapValues:n(6604),max:n(6162),merge:n(3857),min:n(3632),minBy:n(2762),now:n(7771),pick:n(9722),range:n(6026),reduce:n(4061),sortBy:n(9734),uniqueId:n(3955),values:n(2628),zipObject:n(7287)};}catch(t){}r||(r=window._),t.exports=r;},2981:(t,e,n)=>{var r=n(8436),i=n(1138);function a(t,e,n,o,s,c,l){var u=t.children(l);if(u.length){var h=i.addBorderNode(t,"_bt"),f=i.addBorderNode(t,"_bb"),d=t.node(l);t.setParent(h,l),d.borderTop=h,t.setParent(f,l),d.borderBottom=f,r.forEach(u,(function(r){a(t,e,n,o,s,c,r);var i=t.node(r),u=i.borderTop?i.borderTop:r,d=i.borderBottom?i.borderBottom:r,p=i.borderTop?o:2*o,g=u!==d?1:s-c[l]+1;t.setEdge(h,u,{weight:p,minlen:g,nestingEdge:!0}),t.setEdge(d,f,{weight:p,minlen:g,nestingEdge:!0});})),t.parent(l)||t.setEdge(e,h,{weight:0,minlen:s+c[l]});}else l!==e&&t.setEdge(e,l,{weight:0,minlen:n});}t.exports={run:function(t){var e=i.addDummyNode(t,"root",{},"_root"),n=function(t){var e={};function n(i,a){var o=t.children(i);o&&o.length&&r.forEach(o,(function(t){n(t,a+1);})),e[i]=a;}return r.forEach(t.children(),(function(t){n(t,1);})),e}(t),o=r.max(r.values(n))-1,s=2*o+1;t.graph().nestingRoot=e,r.forEach(t.edges(),(function(e){t.edge(e).minlen*=s;}));var c=function(t){return r.reduce(t.edges(),(function(e,n){return e+t.edge(n).weight}),0)}(t)+1;r.forEach(t.children(),(function(r){a(t,e,s,c,o,n,r);})),t.graph().nodeRankFactor=s;},cleanup:function(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,r.forEach(t.edges(),(function(e){t.edge(e).nestingEdge&&t.removeEdge(e);}));}};},5995:(t,e,n)=>{var r=n(8436),i=n(1138);t.exports={run:function(t){t.graph().dummyChains=[],r.forEach(t.edges(),(function(e){!function(t,e){var n,r,a,o=e.v,s=t.node(o).rank,c=e.w,l=t.node(c).rank,u=e.name,h=t.edge(e),f=h.labelRank;if(l!==s+1){for(t.removeEdge(e),a=0,++s;s<l;++a,++s)h.points=[],r={width:0,height:0,edgeLabel:h,edgeObj:e,rank:s},n=i.addDummyNode(t,"edge",r,"_d"),s===f&&(r.width=h.width,r.height=h.height,r.dummy="edge-label",r.labelpos=h.labelpos),t.setEdge(o,n,{weight:h.weight},u),0===a&&t.graph().dummyChains.push(n),o=n;t.setEdge(o,c,{weight:h.weight},u);}}(t,e);}));},undo:function(t){r.forEach(t.graph().dummyChains,(function(e){var n,r=t.node(e),i=r.edgeLabel;for(t.setEdge(r.edgeObj,i);r.dummy;)n=t.successors(e)[0],t.removeNode(e),i.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(i.x=r.x,i.y=r.y,i.width=r.width,i.height=r.height),e=n,r=t.node(e);}));}};},5093:(t,e,n)=>{var r=n(8436);t.exports=function(t,e,n){var i,a={};r.forEach(n,(function(n){for(var r,o,s=t.parent(n);s;){if((r=t.parent(s))?(o=a[r],a[r]=s):(o=i,i=s),o&&o!==s)return void e.setEdge(o,s);s=r;}}));};},5439:(t,e,n)=>{var r=n(8436);t.exports=function(t,e){return r.map(e,(function(e){var n=t.inEdges(e);if(n.length){var i=r.reduce(n,(function(e,n){var r=t.edge(n),i=t.node(n.v);return {sum:e.sum+r.weight*i.order,weight:e.weight+r.weight}}),{sum:0,weight:0});return {v:e,barycenter:i.sum/i.weight,weight:i.weight}}return {v:e}}))};},3128:(t,e,n)=>{var r=n(8436),i=n(574).Graph;t.exports=function(t,e,n){var a=function(t){for(var e;t.hasNode(e=r.uniqueId("_root")););return e}(t),o=new i({compound:!0}).setGraph({root:a}).setDefaultNodeLabel((function(e){return t.node(e)}));return r.forEach(t.nodes(),(function(i){var s=t.node(i),c=t.parent(i);(s.rank===e||s.minRank<=e&&e<=s.maxRank)&&(o.setNode(i),o.setParent(i,c||a),r.forEach(t[n](i),(function(e){var n=e.v===i?e.w:e.v,a=o.edge(n,i),s=r.isUndefined(a)?0:a.weight;o.setEdge(n,i,{weight:t.edge(e).weight+s});})),r.has(s,"minRank")&&o.setNode(i,{borderLeft:s.borderLeft[e],borderRight:s.borderRight[e]}));})),o};},6630:(t,e,n)=>{var r=n(8436);function i(t,e,n){for(var i=r.zipObject(n,r.map(n,(function(t,e){return e}))),a=r.flatten(r.map(e,(function(e){return r.sortBy(r.map(t.outEdges(e),(function(e){return {pos:i[e.w],weight:t.edge(e).weight}})),"pos")})),!0),o=1;o<n.length;)o<<=1;var s=2*o-1;o-=1;var c=r.map(new Array(s),(function(){return 0})),l=0;return r.forEach(a.forEach((function(t){var e=t.pos+o;c[e]+=t.weight;for(var n=0;e>0;)e%2&&(n+=c[e+1]),c[e=e-1>>1]+=t.weight;l+=t.weight*n;}))),l}t.exports=function(t,e){for(var n=0,r=1;r<e.length;++r)n+=i(t,e[r-1],e[r]);return n};},3408:(t,e,n)=>{var r=n(8436),i=n(2588),a=n(6630),o=n(1026),s=n(3128),c=n(5093),l=n(574).Graph,u=n(1138);function h(t,e,n){return r.map(e,(function(e){return s(t,e,n)}))}function f(t,e){var n=new l;r.forEach(t,(function(t){var i=t.graph().root,a=o(t,i,n,e);r.forEach(a.vs,(function(e,n){t.node(e).order=n;})),c(t,n,a.vs);}));}function d(t,e){r.forEach(e,(function(e){r.forEach(e,(function(e,n){t.node(e).order=n;}));}));}t.exports=function(t){var e=u.maxRank(t),n=h(t,r.range(1,e+1),"inEdges"),o=h(t,r.range(e-1,-1,-1),"outEdges"),s=i(t);d(t,s);for(var c,l=Number.POSITIVE_INFINITY,p=0,g=0;g<4;++p,++g){f(p%2?n:o,p%4>=2),s=u.buildLayerMatrix(t);var y=a(t,s);y<l&&(g=0,c=r.cloneDeep(s),l=y);}d(t,c);};},2588:(t,e,n)=>{var r=n(8436);t.exports=function(t){var e={},n=r.filter(t.nodes(),(function(e){return !t.children(e).length})),i=r.max(r.map(n,(function(e){return t.node(e).rank}))),a=r.map(r.range(i+1),(function(){return []})),o=r.sortBy(n,(function(e){return t.node(e).rank}));return r.forEach(o,(function n(i){if(!r.has(e,i)){e[i]=!0;var o=t.node(i);a[o.rank].push(i),r.forEach(t.successors(i),n);}})),a};},9567:(t,e,n)=>{var r=n(8436);t.exports=function(t,e){var n={};return r.forEach(t,(function(t,e){var i=n[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};r.isUndefined(t.barycenter)||(i.barycenter=t.barycenter,i.weight=t.weight);})),r.forEach(e.edges(),(function(t){var e=n[t.v],i=n[t.w];r.isUndefined(e)||r.isUndefined(i)||(i.indegree++,e.out.push(n[t.w]));})),function(t){var e=[];function n(t){return function(e){var n,i,a,o;e.merged||(r.isUndefined(e.barycenter)||r.isUndefined(t.barycenter)||e.barycenter>=t.barycenter)&&(i=e,a=0,o=0,(n=t).weight&&(a+=n.barycenter*n.weight,o+=n.weight),i.weight&&(a+=i.barycenter*i.weight,o+=i.weight),n.vs=i.vs.concat(n.vs),n.barycenter=a/o,n.weight=o,n.i=Math.min(i.i,n.i),i.merged=!0);}}function i(e){return function(n){n.in.push(e),0==--n.indegree&&t.push(n);}}for(;t.length;){var a=t.pop();e.push(a),r.forEach(a.in.reverse(),n(a)),r.forEach(a.out,i(a));}return r.map(r.filter(e,(function(t){return !t.merged})),(function(t){return r.pick(t,["vs","i","barycenter","weight"])}))}(r.filter(n,(function(t){return !t.indegree})))};},1026:(t,e,n)=>{var r=n(8436),i=n(5439),a=n(9567),o=n(7304);t.exports=function t(e,n,s,c){var l=e.children(n),u=e.node(n),h=u?u.borderLeft:void 0,f=u?u.borderRight:void 0,d={};h&&(l=r.filter(l,(function(t){return t!==h&&t!==f})));var p=i(e,l);r.forEach(p,(function(n){if(e.children(n.v).length){var i=t(e,n.v,s,c);d[n.v]=i,r.has(i,"barycenter")&&(a=n,o=i,r.isUndefined(a.barycenter)?(a.barycenter=o.barycenter,a.weight=o.weight):(a.barycenter=(a.barycenter*a.weight+o.barycenter*o.weight)/(a.weight+o.weight),a.weight+=o.weight));}var a,o;}));var g=a(p,s);!function(t,e){r.forEach(t,(function(t){t.vs=r.flatten(t.vs.map((function(t){return e[t]?e[t].vs:t})),!0);}));}(g,d);var y=o(g,c);if(h&&(y.vs=r.flatten([h,y.vs,f],!0),e.predecessors(h).length)){var m=e.node(e.predecessors(h)[0]),b=e.node(e.predecessors(f)[0]);r.has(y,"barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+m.order+b.order)/(y.weight+2),y.weight+=2;}return y};},7304:(t,e,n)=>{var r=n(8436),i=n(1138);function a(t,e,n){for(var i;e.length&&(i=r.last(e)).i<=n;)e.pop(),t.push(i.vs),n++;return n}t.exports=function(t,e){var n,o=i.partition(t,(function(t){return r.has(t,"barycenter")})),s=o.lhs,c=r.sortBy(o.rhs,(function(t){return -t.i})),l=[],u=0,h=0,f=0;s.sort((n=!!e,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:n?e.i-t.i:t.i-e.i})),f=a(l,c,f),r.forEach(s,(function(t){f+=t.vs.length,l.push(t.vs),u+=t.barycenter*t.weight,h+=t.weight,f=a(l,c,f);}));var d={vs:r.flatten(l,!0)};return h&&(d.barycenter=u/h,d.weight=h),d};},4219:(t,e,n)=>{var r=n(8436);t.exports=function(t){var e=function(t){var e={},n=0;return r.forEach(t.children(),(function i(a){var o=n;r.forEach(t.children(a),i),e[a]={low:o,lim:n++};})),e}(t);r.forEach(t.graph().dummyChains,(function(n){for(var r=t.node(n),i=r.edgeObj,a=function(t,e,n,r){var i,a,o=[],s=[],c=Math.min(e[n].low,e[r].low),l=Math.max(e[n].lim,e[r].lim);i=n;do{i=t.parent(i),o.push(i);}while(i&&(e[i].low>c||l>e[i].lim));for(a=i,i=r;(i=t.parent(i))!==a;)s.push(i);return {path:o.concat(s.reverse()),lca:a}}(t,e,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;n!==i.w;){if(r=t.node(n),u){for(;(l=o[c])!==s&&t.node(l).maxRank<r.rank;)c++;l===s&&(u=!1);}if(!u){for(;c<o.length-1&&t.node(l=o[c+1]).minRank<=r.rank;)c++;l=o[c];}t.setParent(n,l),n=t.successors(n)[0];}}));};},3573:(t,e,n)=>{var r=n(8436),i=n(574).Graph,a=n(1138);function o(t,e){var n={};return r.reduce(e,(function(e,i){var a=0,o=0,s=e.length,l=r.last(i);return r.forEach(i,(function(e,u){var h=function(t,e){if(t.node(e).dummy)return r.find(t.predecessors(e),(function(e){return t.node(e).dummy}))}(t,e),f=h?t.node(h).order:s;(h||e===l)&&(r.forEach(i.slice(o,u+1),(function(e){r.forEach(t.predecessors(e),(function(r){var i=t.node(r),o=i.order;!(o<a||f<o)||i.dummy&&t.node(e).dummy||c(n,r,e);}));})),o=u+1,a=f);})),i})),n}function s(t,e){var n={};function i(e,i,a,o,s){var l;r.forEach(r.range(i,a),(function(i){l=e[i],t.node(l).dummy&&r.forEach(t.predecessors(l),(function(e){var r=t.node(e);r.dummy&&(r.order<o||r.order>s)&&c(n,e,l);}));}));}return r.reduce(e,(function(e,n){var a,o=-1,s=0;return r.forEach(n,(function(r,c){if("border"===t.node(r).dummy){var l=t.predecessors(r);l.length&&(a=t.node(l[0]).order,i(n,s,c,o,a),s=c,o=a);}i(n,s,n.length,a,e.length);})),n})),n}function c(t,e,n){if(e>n){var r=e;e=n,n=r;}var i=t[e];i||(t[e]=i={}),i[n]=!0;}function l(t,e,n){if(e>n){var i=e;e=n,n=i;}return r.has(t[e],n)}function u(t,e,n,i){var a={},o={},s={};return r.forEach(e,(function(t){r.forEach(t,(function(t,e){a[t]=t,o[t]=t,s[t]=e;}));})),r.forEach(e,(function(t){var e=-1;r.forEach(t,(function(t){var c=i(t);if(c.length){c=r.sortBy(c,(function(t){return s[t]}));for(var u=(c.length-1)/2,h=Math.floor(u),f=Math.ceil(u);h<=f;++h){var d=c[h];o[t]===t&&e<s[d]&&!l(n,t,d)&&(o[d]=t,o[t]=a[t]=a[d],e=s[d]);}}}));})),{root:a,align:o}}function h(t,e,n,a,o){var s={},c=function(t,e,n,a){var o=new i,s=t.graph(),c=function(t,e,n){return function(i,a,o){var s,c=i.node(a),l=i.node(o),u=0;if(u+=c.width/2,r.has(c,"labelpos"))switch(c.labelpos.toLowerCase()){case"l":s=-c.width/2;break;case"r":s=c.width/2;}if(s&&(u+=n?s:-s),s=0,u+=(c.dummy?e:t)/2,u+=(l.dummy?e:t)/2,u+=l.width/2,r.has(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":s=l.width/2;break;case"r":s=-l.width/2;}return s&&(u+=n?s:-s),s=0,u}}(s.nodesep,s.edgesep,a);return r.forEach(e,(function(e){var i;r.forEach(e,(function(e){var r=n[e];if(o.setNode(r),i){var a=n[i],s=o.edge(a,r);o.setEdge(a,r,Math.max(c(t,e,i),s||0));}i=e;}));})),o}(t,e,n,o),l=o?"borderLeft":"borderRight";function u(t,e){for(var n=c.nodes(),r=n.pop(),i={};r;)i[r]?t(r):(i[r]=!0,n.push(r),n=n.concat(e(r))),r=n.pop();}return u((function(t){s[t]=c.inEdges(t).reduce((function(t,e){return Math.max(t,s[e.v]+c.edge(e))}),0);}),c.predecessors.bind(c)),u((function(e){var n=c.outEdges(e).reduce((function(t,e){return Math.min(t,s[e.w]-c.edge(e))}),Number.POSITIVE_INFINITY),r=t.node(e);n!==Number.POSITIVE_INFINITY&&r.borderType!==l&&(s[e]=Math.max(s[e],n));}),c.successors.bind(c)),r.forEach(a,(function(t){s[t]=s[n[t]];})),s}function f(t,e){return r.minBy(r.values(e),(function(e){var n=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;return r.forIn(e,(function(e,r){var a=function(t,e){return t.node(e).width}(t,r)/2;n=Math.max(e+a,n),i=Math.min(e-a,i);})),n-i}))}function d(t,e){var n=r.values(e),i=r.min(n),a=r.max(n);r.forEach(["u","d"],(function(n){r.forEach(["l","r"],(function(o){var s,c=n+o,l=t[c];if(l!==e){var u=r.values(l);(s="l"===o?i-r.min(u):a-r.max(u))&&(t[c]=r.mapValues(l,(function(t){return t+s})));}}));}));}function p(t,e){return r.mapValues(t.ul,(function(n,i){if(e)return t[e.toLowerCase()][i];var a=r.sortBy(r.map(t,i));return (a[1]+a[2])/2}))}t.exports={positionX:function(t){var e,n=a.buildLayerMatrix(t),i=r.merge(o(t,n),s(t,n)),c={};r.forEach(["u","d"],(function(a){e="u"===a?n:r.values(n).reverse(),r.forEach(["l","r"],(function(n){"r"===n&&(e=r.map(e,(function(t){return r.values(t).reverse()})));var o=("u"===a?t.predecessors:t.successors).bind(t),s=u(0,e,i,o),l=h(t,e,s.root,s.align,"r"===n);"r"===n&&(l=r.mapValues(l,(function(t){return -t}))),c[a+n]=l;}));}));var l=f(t,c);return d(c,l),p(c,t.graph().align)},findType1Conflicts:o,findType2Conflicts:s,addConflict:c,hasConflict:l,verticalAlignment:u,horizontalCompaction:h,alignCoordinates:d,findSmallestWidthAlignment:f,balance:p};},7873:(t,e,n)=>{var r=n(8436),i=n(1138),a=n(3573).positionX;t.exports=function(t){(function(t){var e=i.buildLayerMatrix(t),n=t.graph().ranksep,a=0;r.forEach(e,(function(e){var i=r.max(r.map(e,(function(e){return t.node(e).height})));r.forEach(e,(function(e){t.node(e).y=a+i/2;})),a+=i+n;}));})(t=i.asNonCompoundGraph(t)),r.forEach(a(t),(function(e,n){t.node(n).x=e;}));};},300:(t,e,n)=>{var r=n(8436),i=n(574).Graph,a=n(6681).slack;function o(t,e){return r.forEach(t.nodes(),(function n(i){r.forEach(e.nodeEdges(i),(function(r){var o=r.v,s=i===o?r.w:o;t.hasNode(s)||a(e,r)||(t.setNode(s,{}),t.setEdge(i,s,{}),n(s));}));})),t.nodeCount()}function s(t,e){return r.minBy(e.edges(),(function(n){if(t.hasNode(n.v)!==t.hasNode(n.w))return a(e,n)}))}function c(t,e,n){r.forEach(t.nodes(),(function(t){e.node(t).rank+=n;}));}t.exports=function(t){var e,n,r=new i({directed:!1}),l=t.nodes()[0],u=t.nodeCount();for(r.setNode(l,{});o(r,t)<u;)e=s(r,t),n=r.hasNode(e.v)?a(t,e):-a(t,e),c(r,t,n);return r};},8093:(t,e,n)=>{var r=n(6681).longestPath,i=n(300),a=n(2472);t.exports=function(t){switch(t.graph().ranker){case"network-simplex":default:!function(t){a(t);}(t);break;case"tight-tree":!function(t){r(t),i(t);}(t);break;case"longest-path":o(t);}};var o=r;},2472:(t,e,n)=>{var r=n(8436),i=n(300),a=n(6681).slack,o=n(6681).longestPath,s=n(574).alg.preorder,c=n(574).alg.postorder,l=n(1138).simplify;function u(t){t=l(t),o(t);var e,n=i(t);for(d(n),h(n,t);e=g(n);)m(n,t,e,y(n,t,e));}function h(t,e){var n=c(t,t.nodes());n=n.slice(0,n.length-1),r.forEach(n,(function(n){!function(t,e,n){var r=t.node(n).parent;t.edge(n,r).cutvalue=f(t,e,n);}(t,e,n);}));}function f(t,e,n){var i=t.node(n).parent,a=!0,o=e.edge(n,i),s=0;return o||(a=!1,o=e.edge(i,n)),s=o.weight,r.forEach(e.nodeEdges(n),(function(r){var o,c,l=r.v===n,u=l?r.w:r.v;if(u!==i){var h=l===a,f=e.edge(r).weight;if(s+=h?f:-f,o=n,c=u,t.hasEdge(o,c)){var d=t.edge(n,u).cutvalue;s+=h?-d:d;}}})),s}function d(t,e){arguments.length<2&&(e=t.nodes()[0]),p(t,{},1,e);}function p(t,e,n,i,a){var o=n,s=t.node(i);return e[i]=!0,r.forEach(t.neighbors(i),(function(a){r.has(e,a)||(n=p(t,e,n,a,i));})),s.low=o,s.lim=n++,a?s.parent=a:delete s.parent,n}function g(t){return r.find(t.edges(),(function(e){return t.edge(e).cutvalue<0}))}function y(t,e,n){var i=n.v,o=n.w;e.hasEdge(i,o)||(i=n.w,o=n.v);var s=t.node(i),c=t.node(o),l=s,u=!1;s.lim>c.lim&&(l=c,u=!0);var h=r.filter(e.edges(),(function(e){return u===b(0,t.node(e.v),l)&&u!==b(0,t.node(e.w),l)}));return r.minBy(h,(function(t){return a(e,t)}))}function m(t,e,n,i){var a=n.v,o=n.w;t.removeEdge(a,o),t.setEdge(i.v,i.w,{}),d(t),h(t,e),function(t,e){var n=r.find(t.nodes(),(function(t){return !e.node(t).parent})),i=s(t,n);i=i.slice(1),r.forEach(i,(function(n){var r=t.node(n).parent,i=e.edge(n,r),a=!1;i||(i=e.edge(r,n),a=!0),e.node(n).rank=e.node(r).rank+(a?i.minlen:-i.minlen);}));}(t,e);}function b(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}t.exports=u,u.initLowLimValues=d,u.initCutValues=h,u.calcCutValue=f,u.leaveEdge=g,u.enterEdge=y,u.exchangeEdges=m;},6681:(t,e,n)=>{var r=n(8436);t.exports={longestPath:function(t){var e={};r.forEach(t.sources(),(function n(i){var a=t.node(i);if(r.has(e,i))return a.rank;e[i]=!0;var o=r.min(r.map(t.outEdges(i),(function(e){return n(e.w)-t.edge(e).minlen})));return o!==Number.POSITIVE_INFINITY&&null!=o||(o=0),a.rank=o}));},slack:function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}};},1138:(t,e,n)=>{var r=n(8436),i=n(574).Graph;function a(t,e,n,i){var a;do{a=r.uniqueId(i);}while(t.hasNode(a));return n.dummy=e,t.setNode(a,n),a}function o(t){return r.max(r.map(t.nodes(),(function(e){var n=t.node(e).rank;if(!r.isUndefined(n))return n})))}t.exports={addDummyNode:a,simplify:function(t){var e=(new i).setGraph(t.graph());return r.forEach(t.nodes(),(function(n){e.setNode(n,t.node(n));})),r.forEach(t.edges(),(function(n){var r=e.edge(n.v,n.w)||{weight:0,minlen:1},i=t.edge(n);e.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)});})),e},asNonCompoundGraph:function(t){var e=new i({multigraph:t.isMultigraph()}).setGraph(t.graph());return r.forEach(t.nodes(),(function(n){t.children(n).length||e.setNode(n,t.node(n));})),r.forEach(t.edges(),(function(n){e.setEdge(n,t.edge(n));})),e},successorWeights:function(t){var e=r.map(t.nodes(),(function(e){var n={};return r.forEach(t.outEdges(e),(function(e){n[e.w]=(n[e.w]||0)+t.edge(e).weight;})),n}));return r.zipObject(t.nodes(),e)},predecessorWeights:function(t){var e=r.map(t.nodes(),(function(e){var n={};return r.forEach(t.inEdges(e),(function(e){n[e.v]=(n[e.v]||0)+t.edge(e).weight;})),n}));return r.zipObject(t.nodes(),e)},intersectRect:function(t,e){var n,r,i=t.x,a=t.y,o=e.x-i,s=e.y-a,c=t.width/2,l=t.height/2;if(!o&&!s)throw new Error("Not possible to find intersection inside of the rectangle");return Math.abs(s)*c>Math.abs(o)*l?(s<0&&(l=-l),n=l*o/s,r=l):(o<0&&(c=-c),n=c,r=c*s/o),{x:i+n,y:a+r}},buildLayerMatrix:function(t){var e=r.map(r.range(o(t)+1),(function(){return []}));return r.forEach(t.nodes(),(function(n){var i=t.node(n),a=i.rank;r.isUndefined(a)||(e[a][i.order]=n);})),e},normalizeRanks:function(t){var e=r.min(r.map(t.nodes(),(function(e){return t.node(e).rank})));r.forEach(t.nodes(),(function(n){var i=t.node(n);r.has(i,"rank")&&(i.rank-=e);}));},removeEmptyRanks:function(t){var e=r.min(r.map(t.nodes(),(function(e){return t.node(e).rank}))),n=[];r.forEach(t.nodes(),(function(r){var i=t.node(r).rank-e;n[i]||(n[i]=[]),n[i].push(r);}));var i=0,a=t.graph().nodeRankFactor;r.forEach(n,(function(e,n){r.isUndefined(e)&&n%a!=0?--i:i&&r.forEach(e,(function(e){t.node(e).rank+=i;}));}));},addBorderNode:function(t,e,n,r){var i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),a(t,"border",i,e)},maxRank:o,partition:function(t,e){var n={lhs:[],rhs:[]};return r.forEach(t,(function(t){e(t)?n.lhs.push(t):n.rhs.push(t);})),n},time:function(t,e){var n=r.now();try{return e()}finally{console.log(t+" time: "+(r.now()-n)+"ms");}},notime:function(t,e){return e()}};},8177:t=>{t.exports="0.8.5";},7856:function(t){t.exports=function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,n){return e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},e(t,n)}function n(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return !1}}function r(t,i,a){return r=n()?Reflect.construct:function(t,n,r){var i=[null];i.push.apply(i,n);var a=new(Function.bind.apply(t,i));return r&&e(a,r.prototype),a},r.apply(null,arguments)}function i(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return a(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return "Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var o=Object.hasOwnProperty,s=Object.setPrototypeOf,c=Object.isFrozen,l=Object.getPrototypeOf,u=Object.getOwnPropertyDescriptor,h=Object.freeze,f=Object.seal,d=Object.create,p="undefined"!=typeof Reflect&&Reflect,g=p.apply,y=p.construct;g||(g=function(t,e,n){return t.apply(e,n)}),h||(h=function(t){return t}),f||(f=function(t){return t}),y||(y=function(t,e){return r(t,i(e))});var m,b=A(Array.prototype.forEach),v=A(Array.prototype.pop),_=A(Array.prototype.push),x=A(String.prototype.toLowerCase),k=A(String.prototype.match),w=A(String.prototype.replace),T=A(String.prototype.indexOf),E=A(String.prototype.trim),C=A(RegExp.prototype.test),S=(m=TypeError,function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return y(m,e)});function A(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return g(t,e,r)}}function M(t,e,n){n=n||x,s&&s(t,null);for(var r=e.length;r--;){var i=e[r];if("string"==typeof i){var a=n(i);a!==i&&(c(e)||(e[r]=a),i=a);}t[i]=!0;}return t}function N(t){var e,n=d(null);for(e in t)g(o,t,[e])&&(n[e]=t[e]);return n}function O(t,e){for(;null!==t;){var n=u(t,e);if(n){if(n.get)return A(n.get);if("function"==typeof n.value)return A(n.value)}t=l(t);}return function(t){return console.warn("fallback value for",t),null}}var D=h(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),B=h(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),L=h(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),I=h(["animate","color-profile","cursor","discard","fedropshadow","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),F=h(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),R=h(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),P=h(["#text"]),j=h(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),z=h(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Y=h(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),U=h(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),$=f(/\{\{[\w\W]*|[\w\W]*\}\}/gm),W=f(/<%[\w\W]*|[\w\W]*%>/gm),q=f(/^data-[\-\w.\u00B7-\uFFFF]/),H=f(/^aria-[\-\w]+$/),V=f(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),G=f(/^(?:\w+script|data):/i),X=f(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Z=f(/^html$/i),Q=function(){return "undefined"==typeof window?null:window},K=function(e,n){if("object"!==t(e)||"function"!=typeof e.createPolicy)return null;var r=null,i="data-tt-policy-suffix";n.currentScript&&n.currentScript.hasAttribute(i)&&(r=n.currentScript.getAttribute(i));var a="dompurify"+(r?"#"+r:"");try{return e.createPolicy(a,{createHTML:function(t){return t},createScriptURL:function(t){return t}})}catch(t){return console.warn("TrustedTypes policy "+a+" could not be created."),null}};return function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Q(),r=function(t){return e(t)};if(r.version="2.4.0",r.removed=[],!n||!n.document||9!==n.document.nodeType)return r.isSupported=!1,r;var a=n.document,o=n.document,s=n.DocumentFragment,c=n.HTMLTemplateElement,l=n.Node,u=n.Element,f=n.NodeFilter,d=n.NamedNodeMap,p=void 0===d?n.NamedNodeMap||n.MozNamedAttrMap:d,g=n.HTMLFormElement,y=n.DOMParser,m=n.trustedTypes,A=u.prototype,J=O(A,"cloneNode"),tt=O(A,"nextSibling"),et=O(A,"childNodes"),nt=O(A,"parentNode");if("function"==typeof c){var rt=o.createElement("template");rt.content&&rt.content.ownerDocument&&(o=rt.content.ownerDocument);}var it=K(m,a),at=it?it.createHTML(""):"",ot=o,st=ot.implementation,ct=ot.createNodeIterator,lt=ot.createDocumentFragment,ut=ot.getElementsByTagName,ht=a.importNode,ft={};try{ft=N(o).documentMode?o.documentMode:{};}catch(t){}var dt={};r.isSupported="function"==typeof nt&&st&&void 0!==st.createHTMLDocument&&9!==ft;var pt,gt,yt=$,mt=W,bt=q,vt=H,_t=G,xt=X,kt=V,wt=null,Tt=M({},[].concat(i(D),i(B),i(L),i(F),i(P))),Et=null,Ct=M({},[].concat(i(j),i(z),i(Y),i(U))),St=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),At=null,Mt=null,Nt=!0,Ot=!0,Dt=!1,Bt=!1,Lt=!1,It=!1,Ft=!1,Rt=!1,Pt=!1,jt=!1,zt=!0,Yt=!1,Ut="user-content-",$t=!0,Wt=!1,qt={},Ht=null,Vt=M({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Gt=null,Xt=M({},["audio","video","img","source","image","track"]),Zt=null,Qt=M({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Kt="http://www.w3.org/1998/Math/MathML",Jt="http://www.w3.org/2000/svg",te="http://www.w3.org/1999/xhtml",ee=te,ne=!1,re=["application/xhtml+xml","text/html"],ie="text/html",ae=null,oe=o.createElement("form"),se=function(t){return t instanceof RegExp||t instanceof Function},ce=function(e){ae&&ae===e||(e&&"object"===t(e)||(e={}),e=N(e),pt=pt=-1===re.indexOf(e.PARSER_MEDIA_TYPE)?ie:e.PARSER_MEDIA_TYPE,gt="application/xhtml+xml"===pt?function(t){return t}:x,wt="ALLOWED_TAGS"in e?M({},e.ALLOWED_TAGS,gt):Tt,Et="ALLOWED_ATTR"in e?M({},e.ALLOWED_ATTR,gt):Ct,Zt="ADD_URI_SAFE_ATTR"in e?M(N(Qt),e.ADD_URI_SAFE_ATTR,gt):Qt,Gt="ADD_DATA_URI_TAGS"in e?M(N(Xt),e.ADD_DATA_URI_TAGS,gt):Xt,Ht="FORBID_CONTENTS"in e?M({},e.FORBID_CONTENTS,gt):Vt,At="FORBID_TAGS"in e?M({},e.FORBID_TAGS,gt):{},Mt="FORBID_ATTR"in e?M({},e.FORBID_ATTR,gt):{},qt="USE_PROFILES"in e&&e.USE_PROFILES,Nt=!1!==e.ALLOW_ARIA_ATTR,Ot=!1!==e.ALLOW_DATA_ATTR,Dt=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Bt=e.SAFE_FOR_TEMPLATES||!1,Lt=e.WHOLE_DOCUMENT||!1,Rt=e.RETURN_DOM||!1,Pt=e.RETURN_DOM_FRAGMENT||!1,jt=e.RETURN_TRUSTED_TYPE||!1,Ft=e.FORCE_BODY||!1,zt=!1!==e.SANITIZE_DOM,Yt=e.SANITIZE_NAMED_PROPS||!1,$t=!1!==e.KEEP_CONTENT,Wt=e.IN_PLACE||!1,kt=e.ALLOWED_URI_REGEXP||kt,ee=e.NAMESPACE||te,e.CUSTOM_ELEMENT_HANDLING&&se(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(St.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&se(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(St.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(St.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Bt&&(Ot=!1),Pt&&(Rt=!0),qt&&(wt=M({},i(P)),Et=[],!0===qt.html&&(M(wt,D),M(Et,j)),!0===qt.svg&&(M(wt,B),M(Et,z),M(Et,U)),!0===qt.svgFilters&&(M(wt,L),M(Et,z),M(Et,U)),!0===qt.mathMl&&(M(wt,F),M(Et,Y),M(Et,U))),e.ADD_TAGS&&(wt===Tt&&(wt=N(wt)),M(wt,e.ADD_TAGS,gt)),e.ADD_ATTR&&(Et===Ct&&(Et=N(Et)),M(Et,e.ADD_ATTR,gt)),e.ADD_URI_SAFE_ATTR&&M(Zt,e.ADD_URI_SAFE_ATTR,gt),e.FORBID_CONTENTS&&(Ht===Vt&&(Ht=N(Ht)),M(Ht,e.FORBID_CONTENTS,gt)),$t&&(wt["#text"]=!0),Lt&&M(wt,["html","head","body"]),wt.table&&(M(wt,["tbody"]),delete At.tbody),h&&h(e),ae=e);},le=M({},["mi","mo","mn","ms","mtext"]),ue=M({},["foreignobject","desc","title","annotation-xml"]),he=M({},["title","style","font","a","script"]),fe=M({},B);M(fe,L),M(fe,I);var de=M({},F);M(de,R);var pe=function(t){var e=nt(t);e&&e.tagName||(e={namespaceURI:te,tagName:"template"});var n=x(t.tagName),r=x(e.tagName);return t.namespaceURI===Jt?e.namespaceURI===te?"svg"===n:e.namespaceURI===Kt?"svg"===n&&("annotation-xml"===r||le[r]):Boolean(fe[n]):t.namespaceURI===Kt?e.namespaceURI===te?"math"===n:e.namespaceURI===Jt?"math"===n&&ue[r]:Boolean(de[n]):t.namespaceURI===te&&!(e.namespaceURI===Jt&&!ue[r])&&!(e.namespaceURI===Kt&&!le[r])&&!de[n]&&(he[n]||!fe[n])},ge=function(t){_(r.removed,{element:t});try{t.parentNode.removeChild(t);}catch(e){try{t.outerHTML=at;}catch(e){t.remove();}}},ye=function(t,e){try{_(r.removed,{attribute:e.getAttributeNode(t),from:e});}catch(t){_(r.removed,{attribute:null,from:e});}if(e.removeAttribute(t),"is"===t&&!Et[t])if(Rt||Pt)try{ge(e);}catch(t){}else try{e.setAttribute(t,"");}catch(t){}},me=function(t){var e,n;if(Ft)t="<remove></remove>"+t;else {var r=k(t,/^[\r\n\t ]+/);n=r&&r[0];}"application/xhtml+xml"===pt&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");var i=it?it.createHTML(t):t;if(ee===te)try{e=(new y).parseFromString(i,pt);}catch(t){}if(!e||!e.documentElement){e=st.createDocument(ee,"template",null);try{e.documentElement.innerHTML=ne?"":i;}catch(t){}}var a=e.body||e.documentElement;return t&&n&&a.insertBefore(o.createTextNode(n),a.childNodes[0]||null),ee===te?ut.call(e,Lt?"html":"body")[0]:Lt?e.documentElement:a},be=function(t){return ct.call(t.ownerDocument||t,t,f.SHOW_ELEMENT|f.SHOW_COMMENT|f.SHOW_TEXT,null,!1)},ve=function(t){return t instanceof g&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||!(t.attributes instanceof p)||"function"!=typeof t.removeAttribute||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore)},_e=function(e){return "object"===t(l)?e instanceof l:e&&"object"===t(e)&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},xe=function(t,e,n){dt[t]&&b(dt[t],(function(t){t.call(r,e,n,ae);}));},ke=function(t){var e;if(xe("beforeSanitizeElements",t,null),ve(t))return ge(t),!0;if(C(/[\u0080-\uFFFF]/,t.nodeName))return ge(t),!0;var n=gt(t.nodeName);if(xe("uponSanitizeElement",t,{tagName:n,allowedTags:wt}),t.hasChildNodes()&&!_e(t.firstElementChild)&&(!_e(t.content)||!_e(t.content.firstElementChild))&&C(/<[/\w]/g,t.innerHTML)&&C(/<[/\w]/g,t.textContent))return ge(t),!0;if("select"===n&&C(/<template/i,t.innerHTML))return ge(t),!0;if(!wt[n]||At[n]){if(!At[n]&&Te(n)){if(St.tagNameCheck instanceof RegExp&&C(St.tagNameCheck,n))return !1;if(St.tagNameCheck instanceof Function&&St.tagNameCheck(n))return !1}if($t&&!Ht[n]){var i=nt(t)||t.parentNode,a=et(t)||t.childNodes;if(a&&i)for(var o=a.length-1;o>=0;--o)i.insertBefore(J(a[o],!0),tt(t));}return ge(t),!0}return t instanceof u&&!pe(t)?(ge(t),!0):"noscript"!==n&&"noembed"!==n||!C(/<\/no(script|embed)/i,t.innerHTML)?(Bt&&3===t.nodeType&&(e=t.textContent,e=w(e,yt," "),e=w(e,mt," "),t.textContent!==e&&(_(r.removed,{element:t.cloneNode()}),t.textContent=e)),xe("afterSanitizeElements",t,null),!1):(ge(t),!0)},we=function(t,e,n){if(zt&&("id"===e||"name"===e)&&(n in o||n in oe))return !1;if(Ot&&!Mt[e]&&C(bt,e));else if(Nt&&C(vt,e));else if(!Et[e]||Mt[e]){if(!(Te(t)&&(St.tagNameCheck instanceof RegExp&&C(St.tagNameCheck,t)||St.tagNameCheck instanceof Function&&St.tagNameCheck(t))&&(St.attributeNameCheck instanceof RegExp&&C(St.attributeNameCheck,e)||St.attributeNameCheck instanceof Function&&St.attributeNameCheck(e))||"is"===e&&St.allowCustomizedBuiltInElements&&(St.tagNameCheck instanceof RegExp&&C(St.tagNameCheck,n)||St.tagNameCheck instanceof Function&&St.tagNameCheck(n))))return !1}else if(Zt[e]);else if(C(kt,w(n,xt,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==T(n,"data:")||!Gt[t])if(Dt&&!C(_t,w(n,xt,"")));else if(n)return !1;return !0},Te=function(t){return t.indexOf("-")>0},Ee=function(e){var n,i,a,o;xe("beforeSanitizeAttributes",e,null);var s=e.attributes;if(s){var c={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Et};for(o=s.length;o--;){var l=n=s[o],u=l.name,h=l.namespaceURI;if(i="value"===u?n.value:E(n.value),a=gt(u),c.attrName=a,c.attrValue=i,c.keepAttr=!0,c.forceKeepAttr=void 0,xe("uponSanitizeAttribute",e,c),i=c.attrValue,!c.forceKeepAttr&&(ye(u,e),c.keepAttr))if(C(/\/>/i,i))ye(u,e);else {Bt&&(i=w(i,yt," "),i=w(i,mt," "));var f=gt(e.nodeName);if(we(f,a,i)){if(!Yt||"id"!==a&&"name"!==a||(ye(u,e),i=Ut+i),it&&"object"===t(m)&&"function"==typeof m.getAttributeType)if(h);else switch(m.getAttributeType(f,a)){case"TrustedHTML":i=it.createHTML(i);break;case"TrustedScriptURL":i=it.createScriptURL(i);}try{h?e.setAttributeNS(h,u,i):e.setAttribute(u,i),v(r.removed);}catch(t){}}}}xe("afterSanitizeAttributes",e,null);}},Ce=function t(e){var n,r=be(e);for(xe("beforeSanitizeShadowDOM",e,null);n=r.nextNode();)xe("uponSanitizeShadowNode",n,null),ke(n)||(n.content instanceof s&&t(n.content),Ee(n));xe("afterSanitizeShadowDOM",e,null);};return r.sanitize=function(e){var i,o,c,u,h,f=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if((ne=!e)&&(e="\x3c!--\x3e"),"string"!=typeof e&&!_e(e)){if("function"!=typeof e.toString)throw S("toString is not a function");if("string"!=typeof(e=e.toString()))throw S("dirty is not a string, aborting")}if(!r.isSupported){if("object"===t(n.toStaticHTML)||"function"==typeof n.toStaticHTML){if("string"==typeof e)return n.toStaticHTML(e);if(_e(e))return n.toStaticHTML(e.outerHTML)}return e}if(It||ce(f),r.removed=[],"string"==typeof e&&(Wt=!1),Wt){if(e.nodeName){var d=gt(e.nodeName);if(!wt[d]||At[d])throw S("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof l)1===(o=(i=me("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===o.nodeName||"HTML"===o.nodeName?i=o:i.appendChild(o);else {if(!Rt&&!Bt&&!Lt&&-1===e.indexOf("<"))return it&&jt?it.createHTML(e):e;if(!(i=me(e)))return Rt?null:jt?at:""}i&&Ft&&ge(i.firstChild);for(var p=be(Wt?e:i);c=p.nextNode();)3===c.nodeType&&c===u||ke(c)||(c.content instanceof s&&Ce(c.content),Ee(c),u=c);if(u=null,Wt)return e;if(Rt){if(Pt)for(h=lt.call(i.ownerDocument);i.firstChild;)h.appendChild(i.firstChild);else h=i;return Et.shadowroot&&(h=ht.call(a,h,!0)),h}var g=Lt?i.outerHTML:i.innerHTML;return Lt&&wt["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&C(Z,i.ownerDocument.doctype.name)&&(g="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+g),Bt&&(g=w(g,yt," "),g=w(g,mt," ")),it&&jt?it.createHTML(g):g},r.setConfig=function(t){ce(t),It=!0;},r.clearConfig=function(){ae=null,It=!1;},r.isValidAttribute=function(t,e,n){ae||ce({});var r=gt(t),i=gt(e);return we(r,i,n)},r.addHook=function(t,e){"function"==typeof e&&(dt[t]=dt[t]||[],_(dt[t],e));},r.removeHook=function(t){if(dt[t])return v(dt[t])},r.removeHooks=function(t){dt[t]&&(dt[t]=[]);},r.removeAllHooks=function(){dt={};},r}()}();},8282:(t,e,n)=>{var r=n(2354);t.exports={Graph:r.Graph,json:n(8974),alg:n(2440),version:r.version};},2842:(t,e,n)=>{var r=n(9126);t.exports=function(t){var e,n={},i=[];function a(i){r.has(n,i)||(n[i]=!0,e.push(i),r.each(t.successors(i),a),r.each(t.predecessors(i),a));}return r.each(t.nodes(),(function(t){e=[],a(t),e.length&&i.push(e);})),i};},3984:(t,e,n)=>{var r=n(9126);function i(t,e,n,a,o,s){r.has(a,e)||(a[e]=!0,n||s.push(e),r.each(o(e),(function(e){i(t,e,n,a,o,s);})),n&&s.push(e));}t.exports=function(t,e,n){r.isArray(e)||(e=[e]);var a=(t.isDirected()?t.successors:t.neighbors).bind(t),o=[],s={};return r.each(e,(function(e){if(!t.hasNode(e))throw new Error("Graph does not have node: "+e);i(t,e,"post"===n,s,a,o);})),o};},4847:(t,e,n)=>{var r=n(3763),i=n(9126);t.exports=function(t,e,n){return i.transform(t.nodes(),(function(i,a){i[a]=r(t,a,e,n);}),{})};},3763:(t,e,n)=>{var r=n(9126),i=n(9675);t.exports=function(t,e,n,r){return function(t,e,n,r){var a,o,s={},c=new i,l=function(t){var e=t.v!==a?t.v:t.w,r=s[e],i=n(t),l=o.distance+i;if(i<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+i);l<r.distance&&(r.distance=l,r.predecessor=a,c.decrease(e,l));};for(t.nodes().forEach((function(t){var n=t===e?0:Number.POSITIVE_INFINITY;s[t]={distance:n},c.add(t,n);}));c.size()>0&&(a=c.removeMin(),(o=s[a]).distance!==Number.POSITIVE_INFINITY);)r(a).forEach(l);return s}(t,String(e),n||a,r||function(e){return t.outEdges(e)})};var a=r.constant(1);},9096:(t,e,n)=>{var r=n(9126),i=n(5023);t.exports=function(t){return r.filter(i(t),(function(e){return e.length>1||1===e.length&&t.hasEdge(e[0],e[0])}))};},8924:(t,e,n)=>{var r=n(9126);t.exports=function(t,e,n){return function(t,e,n){var r={},i=t.nodes();return i.forEach((function(t){r[t]={},r[t][t]={distance:0},i.forEach((function(e){t!==e&&(r[t][e]={distance:Number.POSITIVE_INFINITY});})),n(t).forEach((function(n){var i=n.v===t?n.w:n.v,a=e(n);r[t][i]={distance:a,predecessor:t};}));})),i.forEach((function(t){var e=r[t];i.forEach((function(n){var a=r[n];i.forEach((function(n){var r=a[t],i=e[n],o=a[n],s=r.distance+i.distance;s<o.distance&&(o.distance=s,o.predecessor=i.predecessor);}));}));})),r}(t,e||i,n||function(e){return t.outEdges(e)})};var i=r.constant(1);},2440:(t,e,n)=>{t.exports={components:n(2842),dijkstra:n(3763),dijkstraAll:n(4847),findCycles:n(9096),floydWarshall:n(8924),isAcyclic:n(2707),postorder:n(8828),preorder:n(2648),prim:n(514),tarjan:n(5023),topsort:n(2166)};},2707:(t,e,n)=>{var r=n(2166);t.exports=function(t){try{r(t);}catch(t){if(t instanceof r.CycleException)return !1;throw t}return !0};},8828:(t,e,n)=>{var r=n(3984);t.exports=function(t,e){return r(t,e,"post")};},2648:(t,e,n)=>{var r=n(3984);t.exports=function(t,e){return r(t,e,"pre")};},514:(t,e,n)=>{var r=n(9126),i=n(771),a=n(9675);t.exports=function(t,e){var n,o=new i,s={},c=new a;function l(t){var r=t.v===n?t.w:t.v,i=c.priority(r);if(void 0!==i){var a=e(t);a<i&&(s[r]=n,c.decrease(r,a));}}if(0===t.nodeCount())return o;r.each(t.nodes(),(function(t){c.add(t,Number.POSITIVE_INFINITY),o.setNode(t);})),c.decrease(t.nodes()[0],0);for(var u=!1;c.size()>0;){if(n=c.removeMin(),r.has(s,n))o.setEdge(n,s[n]);else {if(u)throw new Error("Input graph is not connected: "+t);u=!0;}t.nodeEdges(n).forEach(l);}return o};},5023:(t,e,n)=>{var r=n(9126);t.exports=function(t){var e=0,n=[],i={},a=[];function o(s){var c=i[s]={onStack:!0,lowlink:e,index:e++};if(n.push(s),t.successors(s).forEach((function(t){r.has(i,t)?i[t].onStack&&(c.lowlink=Math.min(c.lowlink,i[t].index)):(o(t),c.lowlink=Math.min(c.lowlink,i[t].lowlink));})),c.lowlink===c.index){var l,u=[];do{l=n.pop(),i[l].onStack=!1,u.push(l);}while(s!==l);a.push(u);}}return t.nodes().forEach((function(t){r.has(i,t)||o(t);})),a};},2166:(t,e,n)=>{var r=n(9126);function i(t){var e={},n={},i=[];if(r.each(t.sinks(),(function o(s){if(r.has(n,s))throw new a;r.has(e,s)||(n[s]=!0,e[s]=!0,r.each(t.predecessors(s),o),delete n[s],i.push(s));})),r.size(e)!==t.nodeCount())throw new a;return i}function a(){}t.exports=i,i.CycleException=a,a.prototype=new Error;},9675:(t,e,n)=>{var r=n(9126);function i(){this._arr=[],this._keyIndices={};}t.exports=i,i.prototype.size=function(){return this._arr.length},i.prototype.keys=function(){return this._arr.map((function(t){return t.key}))},i.prototype.has=function(t){return r.has(this._keyIndices,t)},i.prototype.priority=function(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority},i.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},i.prototype.add=function(t,e){var n=this._keyIndices;if(t=String(t),!r.has(n,t)){var i=this._arr,a=i.length;return n[t]=a,i.push({key:t,priority:e}),this._decrease(a),!0}return !1},i.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},i.prototype.decrease=function(t,e){var n=this._keyIndices[t];if(e>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[n].priority+" New: "+e);this._arr[n].priority=e,this._decrease(n);},i.prototype._heapify=function(t){var e=this._arr,n=2*t,r=n+1,i=t;n<e.length&&(i=e[n].priority<e[i].priority?n:i,r<e.length&&(i=e[r].priority<e[i].priority?r:i),i!==t&&(this._swap(t,i),this._heapify(i)));},i.prototype._decrease=function(t){for(var e,n=this._arr,r=n[t].priority;0!==t&&!(n[e=t>>1].priority<r);)this._swap(t,e),t=e;},i.prototype._swap=function(t,e){var n=this._arr,r=this._keyIndices,i=n[t],a=n[e];n[t]=a,n[e]=i,r[a.key]=t,r[i.key]=e;};},771:(t,e,n)=>{var r=n(9126);t.exports=a;var i="\0";function a(t){this._isDirected=!r.has(t,"directed")||t.directed,this._isMultigraph=!!r.has(t,"multigraph")&&t.multigraph,this._isCompound=!!r.has(t,"compound")&&t.compound,this._label=void 0,this._defaultNodeLabelFn=r.constant(void 0),this._defaultEdgeLabelFn=r.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children["\0"]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={};}function o(t,e){t[e]?t[e]++:t[e]=1;}function s(t,e){--t[e]||delete t[e];}function c(t,e,n,i){var a=""+e,o=""+n;if(!t&&a>o){var s=a;a=o,o=s;}return a+""+o+""+(r.isUndefined(i)?"\0":i)}function l(t,e,n,r){var i=""+e,a=""+n;if(!t&&i>a){var o=i;i=a,a=o;}var s={v:i,w:a};return r&&(s.name=r),s}function u(t,e){return c(t,e.v,e.w,e.name)}a.prototype._nodeCount=0,a.prototype._edgeCount=0,a.prototype.isDirected=function(){return this._isDirected},a.prototype.isMultigraph=function(){return this._isMultigraph},a.prototype.isCompound=function(){return this._isCompound},a.prototype.setGraph=function(t){return this._label=t,this},a.prototype.graph=function(){return this._label},a.prototype.setDefaultNodeLabel=function(t){return r.isFunction(t)||(t=r.constant(t)),this._defaultNodeLabelFn=t,this},a.prototype.nodeCount=function(){return this._nodeCount},a.prototype.nodes=function(){return r.keys(this._nodes)},a.prototype.sources=function(){var t=this;return r.filter(this.nodes(),(function(e){return r.isEmpty(t._in[e])}))},a.prototype.sinks=function(){var t=this;return r.filter(this.nodes(),(function(e){return r.isEmpty(t._out[e])}))},a.prototype.setNodes=function(t,e){var n=arguments,i=this;return r.each(t,(function(t){n.length>1?i.setNode(t,e):i.setNode(t);})),this},a.prototype.setNode=function(t,e){return r.has(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=e),this):(this._nodes[t]=arguments.length>1?e:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=i,this._children[t]={},this._children["\0"][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)},a.prototype.node=function(t){return this._nodes[t]},a.prototype.hasNode=function(t){return r.has(this._nodes,t)},a.prototype.removeNode=function(t){var e=this;if(r.has(this._nodes,t)){var n=function(t){e.removeEdge(e._edgeObjs[t]);};delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],r.each(this.children(t),(function(t){e.setParent(t);})),delete this._children[t]),r.each(r.keys(this._in[t]),n),delete this._in[t],delete this._preds[t],r.each(r.keys(this._out[t]),n),delete this._out[t],delete this._sucs[t],--this._nodeCount;}return this},a.prototype.setParent=function(t,e){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(r.isUndefined(e))e=i;else {for(var n=e+="";!r.isUndefined(n);n=this.parent(n))if(n===t)throw new Error("Setting "+e+" as parent of "+t+" would create a cycle");this.setNode(e);}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=e,this._children[e][t]=!0,this},a.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t];},a.prototype.parent=function(t){if(this._isCompound){var e=this._parent[t];if(e!==i)return e}},a.prototype.children=function(t){if(r.isUndefined(t)&&(t=i),this._isCompound){var e=this._children[t];if(e)return r.keys(e)}else {if(t===i)return this.nodes();if(this.hasNode(t))return []}},a.prototype.predecessors=function(t){var e=this._preds[t];if(e)return r.keys(e)},a.prototype.successors=function(t){var e=this._sucs[t];if(e)return r.keys(e)},a.prototype.neighbors=function(t){var e=this.predecessors(t);if(e)return r.union(e,this.successors(t))},a.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},a.prototype.filterNodes=function(t){var e=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});e.setGraph(this.graph());var n=this;r.each(this._nodes,(function(n,r){t(r)&&e.setNode(r,n);})),r.each(this._edgeObjs,(function(t){e.hasNode(t.v)&&e.hasNode(t.w)&&e.setEdge(t,n.edge(t));}));var i={};function a(t){var r=n.parent(t);return void 0===r||e.hasNode(r)?(i[t]=r,r):r in i?i[r]:a(r)}return this._isCompound&&r.each(e.nodes(),(function(t){e.setParent(t,a(t));})),e},a.prototype.setDefaultEdgeLabel=function(t){return r.isFunction(t)||(t=r.constant(t)),this._defaultEdgeLabelFn=t,this},a.prototype.edgeCount=function(){return this._edgeCount},a.prototype.edges=function(){return r.values(this._edgeObjs)},a.prototype.setPath=function(t,e){var n=this,i=arguments;return r.reduce(t,(function(t,r){return i.length>1?n.setEdge(t,r,e):n.setEdge(t,r),r})),this},a.prototype.setEdge=function(){var t,e,n,i,a=!1,s=arguments[0];"object"==typeof s&&null!==s&&"v"in s?(t=s.v,e=s.w,n=s.name,2===arguments.length&&(i=arguments[1],a=!0)):(t=s,e=arguments[1],n=arguments[3],arguments.length>2&&(i=arguments[2],a=!0)),t=""+t,e=""+e,r.isUndefined(n)||(n=""+n);var u=c(this._isDirected,t,e,n);if(r.has(this._edgeLabels,u))return a&&(this._edgeLabels[u]=i),this;if(!r.isUndefined(n)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(t),this.setNode(e),this._edgeLabels[u]=a?i:this._defaultEdgeLabelFn(t,e,n);var h=l(this._isDirected,t,e,n);return t=h.v,e=h.w,Object.freeze(h),this._edgeObjs[u]=h,o(this._preds[e],t),o(this._sucs[t],e),this._in[e][u]=h,this._out[t][u]=h,this._edgeCount++,this},a.prototype.edge=function(t,e,n){var r=1===arguments.length?u(this._isDirected,arguments[0]):c(this._isDirected,t,e,n);return this._edgeLabels[r]},a.prototype.hasEdge=function(t,e,n){var i=1===arguments.length?u(this._isDirected,arguments[0]):c(this._isDirected,t,e,n);return r.has(this._edgeLabels,i)},a.prototype.removeEdge=function(t,e,n){var r=1===arguments.length?u(this._isDirected,arguments[0]):c(this._isDirected,t,e,n),i=this._edgeObjs[r];return i&&(t=i.v,e=i.w,delete this._edgeLabels[r],delete this._edgeObjs[r],s(this._preds[e],t),s(this._sucs[t],e),delete this._in[e][r],delete this._out[t][r],this._edgeCount--),this},a.prototype.inEdges=function(t,e){var n=this._in[t];if(n){var i=r.values(n);return e?r.filter(i,(function(t){return t.v===e})):i}},a.prototype.outEdges=function(t,e){var n=this._out[t];if(n){var i=r.values(n);return e?r.filter(i,(function(t){return t.w===e})):i}},a.prototype.nodeEdges=function(t,e){var n=this.inEdges(t,e);if(n)return n.concat(this.outEdges(t,e))};},2354:(t,e,n)=>{t.exports={Graph:n(771),version:n(9631)};},8974:(t,e,n)=>{var r=n(9126),i=n(771);function a(t){return r.map(t.nodes(),(function(e){var n=t.node(e),i=t.parent(e),a={v:e};return r.isUndefined(n)||(a.value=n),r.isUndefined(i)||(a.parent=i),a}))}function o(t){return r.map(t.edges(),(function(e){var n=t.edge(e),i={v:e.v,w:e.w};return r.isUndefined(e.name)||(i.name=e.name),r.isUndefined(n)||(i.value=n),i}))}t.exports={write:function(t){var e={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:a(t),edges:o(t)};return r.isUndefined(t.graph())||(e.value=r.clone(t.graph())),e},read:function(t){var e=new i(t.options).setGraph(t.value);return r.each(t.nodes,(function(t){e.setNode(t.v,t.value),t.parent&&e.setParent(t.v,t.parent);})),r.each(t.edges,(function(t){e.setEdge({v:t.v,w:t.w,name:t.name},t.value);})),e}};},9126:(t,e,n)=>{var r;try{r={clone:n(6678),constant:n(5703),each:n(6073),filter:n(3105),has:n(8721),isArray:n(1469),isEmpty:n(1609),isFunction:n(3560),isUndefined:n(2353),keys:n(3674),map:n(5161),reduce:n(4061),size:n(4238),transform:n(8718),union:n(3386),values:n(2628)};}catch(t){}r||(r=window._),t.exports=r;},9631:t=>{t.exports="2.1.8";},8552:(t,e,n)=>{var r=n(852)(n(5639),"DataView");t.exports=r;},1989:(t,e,n)=>{var r=n(1789),i=n(401),a=n(7667),o=n(1327),s=n(1866);function c(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1]);}}c.prototype.clear=r,c.prototype.delete=i,c.prototype.get=a,c.prototype.has=o,c.prototype.set=s,t.exports=c;},8407:(t,e,n)=>{var r=n(7040),i=n(4125),a=n(2117),o=n(7518),s=n(4705);function c(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1]);}}c.prototype.clear=r,c.prototype.delete=i,c.prototype.get=a,c.prototype.has=o,c.prototype.set=s,t.exports=c;},7071:(t,e,n)=>{var r=n(852)(n(5639),"Map");t.exports=r;},3369:(t,e,n)=>{var r=n(4785),i=n(1285),a=n(6e3),o=n(9916),s=n(5265);function c(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1]);}}c.prototype.clear=r,c.prototype.delete=i,c.prototype.get=a,c.prototype.has=o,c.prototype.set=s,t.exports=c;},3818:(t,e,n)=>{var r=n(852)(n(5639),"Promise");t.exports=r;},8525:(t,e,n)=>{var r=n(852)(n(5639),"Set");t.exports=r;},8668:(t,e,n)=>{var r=n(3369),i=n(619),a=n(2385);function o(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new r;++e<n;)this.add(t[e]);}o.prototype.add=o.prototype.push=i,o.prototype.has=a,t.exports=o;},6384:(t,e,n)=>{var r=n(8407),i=n(7465),a=n(3779),o=n(7599),s=n(4758),c=n(4309);function l(t){var e=this.__data__=new r(t);this.size=e.size;}l.prototype.clear=i,l.prototype.delete=a,l.prototype.get=o,l.prototype.has=s,l.prototype.set=c,t.exports=l;},2705:(t,e,n)=>{var r=n(5639).Symbol;t.exports=r;},1149:(t,e,n)=>{var r=n(5639).Uint8Array;t.exports=r;},577:(t,e,n)=>{var r=n(852)(n(5639),"WeakMap");t.exports=r;},6874:t=>{t.exports=function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)};},7412:t=>{t.exports=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t};},4963:t=>{t.exports=function(t,e){for(var n=-1,r=null==t?0:t.length,i=0,a=[];++n<r;){var o=t[n];e(o,n,t)&&(a[i++]=o);}return a};},7443:(t,e,n)=>{var r=n(2118);t.exports=function(t,e){return !(null==t||!t.length)&&r(t,e,0)>-1};},1196:t=>{t.exports=function(t,e,n){for(var r=-1,i=null==t?0:t.length;++r<i;)if(n(e,t[r]))return !0;return !1};},4636:(t,e,n)=>{var r=n(2545),i=n(5694),a=n(1469),o=n(4144),s=n(5776),c=n(6719),l=Object.prototype.hasOwnProperty;t.exports=function(t,e){var n=a(t),u=!n&&i(t),h=!n&&!u&&o(t),f=!n&&!u&&!h&&c(t),d=n||u||h||f,p=d?r(t.length,String):[],g=p.length;for(var y in t)!e&&!l.call(t,y)||d&&("length"==y||h&&("offset"==y||"parent"==y)||f&&("buffer"==y||"byteLength"==y||"byteOffset"==y)||s(y,g))||p.push(y);return p};},9932:t=>{t.exports=function(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i};},2488:t=>{t.exports=function(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t};},2663:t=>{t.exports=function(t,e,n,r){var i=-1,a=null==t?0:t.length;for(r&&a&&(n=t[++i]);++i<a;)n=e(n,t[i],i,t);return n};},2908:t=>{t.exports=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return !0;return !1};},8983:(t,e,n)=>{var r=n(371)("length");t.exports=r;},6556:(t,e,n)=>{var r=n(9465),i=n(7813);t.exports=function(t,e,n){(void 0!==n&&!i(t[e],n)||void 0===n&&!(e in t))&&r(t,e,n);};},4865:(t,e,n)=>{var r=n(9465),i=n(7813),a=Object.prototype.hasOwnProperty;t.exports=function(t,e,n){var o=t[e];a.call(t,e)&&i(o,n)&&(void 0!==n||e in t)||r(t,e,n);};},8470:(t,e,n)=>{var r=n(7813);t.exports=function(t,e){for(var n=t.length;n--;)if(r(t[n][0],e))return n;return -1};},4037:(t,e,n)=>{var r=n(8363),i=n(3674);t.exports=function(t,e){return t&&r(e,i(e),t)};},3886:(t,e,n)=>{var r=n(8363),i=n(1704);t.exports=function(t,e){return t&&r(e,i(e),t)};},9465:(t,e,n)=>{var r=n(8777);t.exports=function(t,e,n){"__proto__"==e&&r?r(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n;};},5990:(t,e,n)=>{var r=n(6384),i=n(7412),a=n(4865),o=n(4037),s=n(3886),c=n(4626),l=n(278),u=n(8805),h=n(1911),f=n(8234),d=n(6904),p=n(4160),g=n(3824),y=n(9148),m=n(8517),b=n(1469),v=n(4144),_=n(6688),x=n(3218),k=n(2928),w=n(3674),T=n(1704),E="[object Arguments]",C="[object Function]",S="[object Object]",A={};A[E]=A["[object Array]"]=A["[object ArrayBuffer]"]=A["[object DataView]"]=A["[object Boolean]"]=A["[object Date]"]=A["[object Float32Array]"]=A["[object Float64Array]"]=A["[object Int8Array]"]=A["[object Int16Array]"]=A["[object Int32Array]"]=A["[object Map]"]=A["[object Number]"]=A[S]=A["[object RegExp]"]=A["[object Set]"]=A["[object String]"]=A["[object Symbol]"]=A["[object Uint8Array]"]=A["[object Uint8ClampedArray]"]=A["[object Uint16Array]"]=A["[object Uint32Array]"]=!0,A["[object Error]"]=A[C]=A["[object WeakMap]"]=!1,t.exports=function t(e,n,M,N,O,D){var B,L=1&n,I=2&n,F=4&n;if(M&&(B=O?M(e,N,O,D):M(e)),void 0!==B)return B;if(!x(e))return e;var R=b(e);if(R){if(B=g(e),!L)return l(e,B)}else {var P=p(e),j=P==C||"[object GeneratorFunction]"==P;if(v(e))return c(e,L);if(P==S||P==E||j&&!O){if(B=I||j?{}:m(e),!L)return I?h(e,s(B,e)):u(e,o(B,e))}else {if(!A[P])return O?e:{};B=y(e,P,L);}}D||(D=new r);var z=D.get(e);if(z)return z;D.set(e,B),k(e)?e.forEach((function(r){B.add(t(r,n,M,r,e,D));})):_(e)&&e.forEach((function(r,i){B.set(i,t(r,n,M,i,e,D));}));var Y=R?void 0:(F?I?d:f:I?T:w)(e);return i(Y||e,(function(r,i){Y&&(r=e[i=r]),a(B,i,t(r,n,M,i,e,D));})),B};},3118:(t,e,n)=>{var r=n(3218),i=Object.create,a=function(){function t(){}return function(e){if(!r(e))return {};if(i)return i(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();t.exports=a;},9881:(t,e,n)=>{var r=n(7816),i=n(9291)(r);t.exports=i;},6029:(t,e,n)=>{var r=n(3448);t.exports=function(t,e,n){for(var i=-1,a=t.length;++i<a;){var o=t[i],s=e(o);if(null!=s&&(void 0===c?s==s&&!r(s):n(s,c)))var c=s,l=o;}return l};},760:(t,e,n)=>{var r=n(9881);t.exports=function(t,e){var n=[];return r(t,(function(t,r,i){e(t,r,i)&&n.push(t);})),n};},1848:t=>{t.exports=function(t,e,n,r){for(var i=t.length,a=n+(r?1:-1);r?a--:++a<i;)if(e(t[a],a,t))return a;return -1};},1078:(t,e,n)=>{var r=n(2488),i=n(7285);t.exports=function t(e,n,a,o,s){var c=-1,l=e.length;for(a||(a=i),s||(s=[]);++c<l;){var u=e[c];n>0&&a(u)?n>1?t(u,n-1,a,o,s):r(s,u):o||(s[s.length]=u);}return s};},8483:(t,e,n)=>{var r=n(5063)();t.exports=r;},7816:(t,e,n)=>{var r=n(8483),i=n(3674);t.exports=function(t,e){return t&&r(t,e,i)};},7786:(t,e,n)=>{var r=n(1811),i=n(327);t.exports=function(t,e){for(var n=0,a=(e=r(e,t)).length;null!=t&&n<a;)t=t[i(e[n++])];return n&&n==a?t:void 0};},8866:(t,e,n)=>{var r=n(2488),i=n(1469);t.exports=function(t,e,n){var a=e(t);return i(t)?a:r(a,n(t))};},4239:(t,e,n)=>{var r=n(2705),i=n(9607),a=n(2333),o=r?r.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":o&&o in Object(t)?i(t):a(t)};},3325:t=>{t.exports=function(t,e){return t>e};},8565:t=>{var e=Object.prototype.hasOwnProperty;t.exports=function(t,n){return null!=t&&e.call(t,n)};},13:t=>{t.exports=function(t,e){return null!=t&&e in Object(t)};},2118:(t,e,n)=>{var r=n(1848),i=n(2722),a=n(2351);t.exports=function(t,e,n){return e==e?a(t,e,n):r(t,i,n)};},9454:(t,e,n)=>{var r=n(4239),i=n(7005);t.exports=function(t){return i(t)&&"[object Arguments]"==r(t)};},939:(t,e,n)=>{var r=n(2492),i=n(7005);t.exports=function t(e,n,a,o,s){return e===n||(null==e||null==n||!i(e)&&!i(n)?e!=e&&n!=n:r(e,n,a,o,t,s))};},2492:(t,e,n)=>{var r=n(6384),i=n(7114),a=n(8351),o=n(6096),s=n(4160),c=n(1469),l=n(4144),u=n(6719),h="[object Arguments]",f="[object Array]",d="[object Object]",p=Object.prototype.hasOwnProperty;t.exports=function(t,e,n,g,y,m){var b=c(t),v=c(e),_=b?f:s(t),x=v?f:s(e),k=(_=_==h?d:_)==d,w=(x=x==h?d:x)==d,T=_==x;if(T&&l(t)){if(!l(e))return !1;b=!0,k=!1;}if(T&&!k)return m||(m=new r),b||u(t)?i(t,e,n,g,y,m):a(t,e,_,n,g,y,m);if(!(1&n)){var E=k&&p.call(t,"__wrapped__"),C=w&&p.call(e,"__wrapped__");if(E||C){var S=E?t.value():t,A=C?e.value():e;return m||(m=new r),y(S,A,n,g,m)}}return !!T&&(m||(m=new r),o(t,e,n,g,y,m))};},5588:(t,e,n)=>{var r=n(4160),i=n(7005);t.exports=function(t){return i(t)&&"[object Map]"==r(t)};},2958:(t,e,n)=>{var r=n(6384),i=n(939);t.exports=function(t,e,n,a){var o=n.length,s=o,c=!a;if(null==t)return !s;for(t=Object(t);o--;){var l=n[o];if(c&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return !1}for(;++o<s;){var u=(l=n[o])[0],h=t[u],f=l[1];if(c&&l[2]){if(void 0===h&&!(u in t))return !1}else {var d=new r;if(a)var p=a(h,f,u,t,e,d);if(!(void 0===p?i(f,h,3,a,d):p))return !1}}return !0};},2722:t=>{t.exports=function(t){return t!=t};},8458:(t,e,n)=>{var r=n(3560),i=n(5346),a=n(3218),o=n(346),s=/^\[object .+?Constructor\]$/,c=Function.prototype,l=Object.prototype,u=c.toString,h=l.hasOwnProperty,f=RegExp("^"+u.call(h).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");t.exports=function(t){return !(!a(t)||i(t))&&(r(t)?f:s).test(o(t))};},9221:(t,e,n)=>{var r=n(4160),i=n(7005);t.exports=function(t){return i(t)&&"[object Set]"==r(t)};},8749:(t,e,n)=>{var r=n(4239),i=n(1780),a=n(7005),o={};o["[object Float32Array]"]=o["[object Float64Array]"]=o["[object Int8Array]"]=o["[object Int16Array]"]=o["[object Int32Array]"]=o["[object Uint8Array]"]=o["[object Uint8ClampedArray]"]=o["[object Uint16Array]"]=o["[object Uint32Array]"]=!0,o["[object Arguments]"]=o["[object Array]"]=o["[object ArrayBuffer]"]=o["[object Boolean]"]=o["[object DataView]"]=o["[object Date]"]=o["[object Error]"]=o["[object Function]"]=o["[object Map]"]=o["[object Number]"]=o["[object Object]"]=o["[object RegExp]"]=o["[object Set]"]=o["[object String]"]=o["[object WeakMap]"]=!1,t.exports=function(t){return a(t)&&i(t.length)&&!!o[r(t)]};},7206:(t,e,n)=>{var r=n(1573),i=n(6432),a=n(6557),o=n(1469),s=n(9601);t.exports=function(t){return "function"==typeof t?t:null==t?a:"object"==typeof t?o(t)?i(t[0],t[1]):r(t):s(t)};},280:(t,e,n)=>{var r=n(5726),i=n(6916),a=Object.prototype.hasOwnProperty;t.exports=function(t){if(!r(t))return i(t);var e=[];for(var n in Object(t))a.call(t,n)&&"constructor"!=n&&e.push(n);return e};},313:(t,e,n)=>{var r=n(3218),i=n(5726),a=n(3498),o=Object.prototype.hasOwnProperty;t.exports=function(t){if(!r(t))return a(t);var e=i(t),n=[];for(var s in t)("constructor"!=s||!e&&o.call(t,s))&&n.push(s);return n};},433:t=>{t.exports=function(t,e){return t<e};},9199:(t,e,n)=>{var r=n(9881),i=n(8612);t.exports=function(t,e){var n=-1,a=i(t)?Array(t.length):[];return r(t,(function(t,r,i){a[++n]=e(t,r,i);})),a};},1573:(t,e,n)=>{var r=n(2958),i=n(1499),a=n(2634);t.exports=function(t){var e=i(t);return 1==e.length&&e[0][2]?a(e[0][0],e[0][1]):function(n){return n===t||r(n,t,e)}};},6432:(t,e,n)=>{var r=n(939),i=n(7361),a=n(9095),o=n(5403),s=n(9162),c=n(2634),l=n(327);t.exports=function(t,e){return o(t)&&s(e)?c(l(t),e):function(n){var o=i(n,t);return void 0===o&&o===e?a(n,t):r(e,o,3)}};},2980:(t,e,n)=>{var r=n(6384),i=n(6556),a=n(8483),o=n(9783),s=n(3218),c=n(1704),l=n(6390);t.exports=function t(e,n,u,h,f){e!==n&&a(n,(function(a,c){if(f||(f=new r),s(a))o(e,n,c,u,t,h,f);else {var d=h?h(l(e,c),a,c+"",e,n,f):void 0;void 0===d&&(d=a),i(e,c,d);}}),c);};},9783:(t,e,n)=>{var r=n(6556),i=n(4626),a=n(7133),o=n(278),s=n(8517),c=n(5694),l=n(1469),u=n(9246),h=n(4144),f=n(3560),d=n(3218),p=n(8630),g=n(6719),y=n(6390),m=n(3678);t.exports=function(t,e,n,b,v,_,x){var k=y(t,n),w=y(e,n),T=x.get(w);if(T)r(t,n,T);else {var E=_?_(k,w,n+"",t,e,x):void 0,C=void 0===E;if(C){var S=l(w),A=!S&&h(w),M=!S&&!A&&g(w);E=w,S||A||M?l(k)?E=k:u(k)?E=o(k):A?(C=!1,E=i(w,!0)):M?(C=!1,E=a(w,!0)):E=[]:p(w)||c(w)?(E=k,c(k)?E=m(k):d(k)&&!f(k)||(E=s(w))):C=!1;}C&&(x.set(w,E),v(E,w,b,_,x),x.delete(w)),r(t,n,E);}};},9556:(t,e,n)=>{var r=n(9932),i=n(7786),a=n(7206),o=n(9199),s=n(1131),c=n(1717),l=n(5022),u=n(6557),h=n(1469);t.exports=function(t,e,n){e=e.length?r(e,(function(t){return h(t)?function(e){return i(e,1===t.length?t[0]:t)}:t})):[u];var f=-1;e=r(e,c(a));var d=o(t,(function(t,n,i){return {criteria:r(e,(function(e){return e(t)})),index:++f,value:t}}));return s(d,(function(t,e){return l(t,e,n)}))};},5970:(t,e,n)=>{var r=n(3012),i=n(9095);t.exports=function(t,e){return r(t,e,(function(e,n){return i(t,n)}))};},3012:(t,e,n)=>{var r=n(7786),i=n(611),a=n(1811);t.exports=function(t,e,n){for(var o=-1,s=e.length,c={};++o<s;){var l=e[o],u=r(t,l);n(u,l)&&i(c,a(l,t),u);}return c};},371:t=>{t.exports=function(t){return function(e){return null==e?void 0:e[t]}};},9152:(t,e,n)=>{var r=n(7786);t.exports=function(t){return function(e){return r(e,t)}};},98:t=>{var e=Math.ceil,n=Math.max;t.exports=function(t,r,i,a){for(var o=-1,s=n(e((r-t)/(i||1)),0),c=Array(s);s--;)c[a?s:++o]=t,t+=i;return c};},107:t=>{t.exports=function(t,e,n,r,i){return i(t,(function(t,i,a){n=r?(r=!1,t):e(n,t,i,a);})),n};},5976:(t,e,n)=>{var r=n(6557),i=n(5357),a=n(61);t.exports=function(t,e){return a(i(t,e,r),t+"")};},611:(t,e,n)=>{var r=n(4865),i=n(1811),a=n(5776),o=n(3218),s=n(327);t.exports=function(t,e,n,c){if(!o(t))return t;for(var l=-1,u=(e=i(e,t)).length,h=u-1,f=t;null!=f&&++l<u;){var d=s(e[l]),p=n;if("__proto__"===d||"constructor"===d||"prototype"===d)return t;if(l!=h){var g=f[d];void 0===(p=c?c(g,d,f):void 0)&&(p=o(g)?g:a(e[l+1])?[]:{});}r(f,d,p),f=f[d];}return t};},6560:(t,e,n)=>{var r=n(5703),i=n(8777),a=n(6557),o=i?function(t,e){return i(t,"toString",{configurable:!0,enumerable:!1,value:r(e),writable:!0})}:a;t.exports=o;},1131:t=>{t.exports=function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t};},2545:t=>{t.exports=function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r};},531:(t,e,n)=>{var r=n(2705),i=n(9932),a=n(1469),o=n(3448),s=r?r.prototype:void 0,c=s?s.toString:void 0;t.exports=function t(e){if("string"==typeof e)return e;if(a(e))return i(e,t)+"";if(o(e))return c?c.call(e):"";var n=e+"";return "0"==n&&1/e==-1/0?"-0":n};},7561:(t,e,n)=>{var r=n(7990),i=/^\s+/;t.exports=function(t){return t?t.slice(0,r(t)+1).replace(i,""):t};},1717:t=>{t.exports=function(t){return function(e){return t(e)}};},5652:(t,e,n)=>{var r=n(8668),i=n(7443),a=n(1196),o=n(4757),s=n(3593),c=n(1814);t.exports=function(t,e,n){var l=-1,u=i,h=t.length,f=!0,d=[],p=d;if(n)f=!1,u=a;else if(h>=200){var g=e?null:s(t);if(g)return c(g);f=!1,u=o,p=new r;}else p=e?[]:d;t:for(;++l<h;){var y=t[l],m=e?e(y):y;if(y=n||0!==y?y:0,f&&m==m){for(var b=p.length;b--;)if(p[b]===m)continue t;e&&p.push(m),d.push(y);}else u(p,m,n)||(p!==d&&p.push(m),d.push(y));}return d};},7415:(t,e,n)=>{var r=n(9932);t.exports=function(t,e){return r(e,(function(e){return t[e]}))};},1757:t=>{t.exports=function(t,e,n){for(var r=-1,i=t.length,a=e.length,o={};++r<i;){var s=r<a?e[r]:void 0;n(o,t[r],s);}return o};},4757:t=>{t.exports=function(t,e){return t.has(e)};},4290:(t,e,n)=>{var r=n(6557);t.exports=function(t){return "function"==typeof t?t:r};},1811:(t,e,n)=>{var r=n(1469),i=n(5403),a=n(5514),o=n(9833);t.exports=function(t,e){return r(t)?t:i(t,e)?[t]:a(o(t))};},4318:(t,e,n)=>{var r=n(1149);t.exports=function(t){var e=new t.constructor(t.byteLength);return new r(e).set(new r(t)),e};},4626:(t,e,n)=>{t=n.nmd(t);var r=n(5639),i=e&&!e.nodeType&&e,a=i&&t&&!t.nodeType&&t,o=a&&a.exports===i?r.Buffer:void 0,s=o?o.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var n=t.length,r=s?s(n):new t.constructor(n);return t.copy(r),r};},7157:(t,e,n)=>{var r=n(4318);t.exports=function(t,e){var n=e?r(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)};},3147:t=>{var e=/\w*$/;t.exports=function(t){var n=new t.constructor(t.source,e.exec(t));return n.lastIndex=t.lastIndex,n};},419:(t,e,n)=>{var r=n(2705),i=r?r.prototype:void 0,a=i?i.valueOf:void 0;t.exports=function(t){return a?Object(a.call(t)):{}};},7133:(t,e,n)=>{var r=n(4318);t.exports=function(t,e){var n=e?r(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)};},6393:(t,e,n)=>{var r=n(3448);t.exports=function(t,e){if(t!==e){var n=void 0!==t,i=null===t,a=t==t,o=r(t),s=void 0!==e,c=null===e,l=e==e,u=r(e);if(!c&&!u&&!o&&t>e||o&&s&&l&&!c&&!u||i&&s&&l||!n&&l||!a)return 1;if(!i&&!o&&!u&&t<e||u&&n&&a&&!i&&!o||c&&n&&a||!s&&a||!l)return -1}return 0};},5022:(t,e,n)=>{var r=n(6393);t.exports=function(t,e,n){for(var i=-1,a=t.criteria,o=e.criteria,s=a.length,c=n.length;++i<s;){var l=r(a[i],o[i]);if(l)return i>=c?l:l*("desc"==n[i]?-1:1)}return t.index-e.index};},278:t=>{t.exports=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e};},8363:(t,e,n)=>{var r=n(4865),i=n(9465);t.exports=function(t,e,n,a){var o=!n;n||(n={});for(var s=-1,c=e.length;++s<c;){var l=e[s],u=a?a(n[l],t[l],l,n,t):void 0;void 0===u&&(u=t[l]),o?i(n,l,u):r(n,l,u);}return n};},8805:(t,e,n)=>{var r=n(8363),i=n(9551);t.exports=function(t,e){return r(t,i(t),e)};},1911:(t,e,n)=>{var r=n(8363),i=n(1442);t.exports=function(t,e){return r(t,i(t),e)};},4429:(t,e,n)=>{var r=n(5639)["__core-js_shared__"];t.exports=r;},1463:(t,e,n)=>{var r=n(5976),i=n(6612);t.exports=function(t){return r((function(e,n){var r=-1,a=n.length,o=a>1?n[a-1]:void 0,s=a>2?n[2]:void 0;for(o=t.length>3&&"function"==typeof o?(a--,o):void 0,s&&i(n[0],n[1],s)&&(o=a<3?void 0:o,a=1),e=Object(e);++r<a;){var c=n[r];c&&t(e,c,r,o);}return e}))};},9291:(t,e,n)=>{var r=n(8612);t.exports=function(t,e){return function(n,i){if(null==n)return n;if(!r(n))return t(n,i);for(var a=n.length,o=e?a:-1,s=Object(n);(e?o--:++o<a)&&!1!==i(s[o],o,s););return n}};},5063:t=>{t.exports=function(t){return function(e,n,r){for(var i=-1,a=Object(e),o=r(e),s=o.length;s--;){var c=o[t?s:++i];if(!1===n(a[c],c,a))break}return e}};},7740:(t,e,n)=>{var r=n(7206),i=n(8612),a=n(3674);t.exports=function(t){return function(e,n,o){var s=Object(e);if(!i(e)){var c=r(n,3);e=a(e),n=function(t){return c(s[t],t,s)};}var l=t(e,n,o);return l>-1?s[c?e[l]:l]:void 0}};},7445:(t,e,n)=>{var r=n(98),i=n(6612),a=n(8601);t.exports=function(t){return function(e,n,o){return o&&"number"!=typeof o&&i(e,n,o)&&(n=o=void 0),e=a(e),void 0===n?(n=e,e=0):n=a(n),o=void 0===o?e<n?1:-1:a(o),r(e,n,o,t)}};},3593:(t,e,n)=>{var r=n(8525),i=n(308),a=n(1814),o=r&&1/a(new r([,-0]))[1]==1/0?function(t){return new r(t)}:i;t.exports=o;},8777:(t,e,n)=>{var r=n(852),i=function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();t.exports=i;},7114:(t,e,n)=>{var r=n(8668),i=n(2908),a=n(4757);t.exports=function(t,e,n,o,s,c){var l=1&n,u=t.length,h=e.length;if(u!=h&&!(l&&h>u))return !1;var f=c.get(t),d=c.get(e);if(f&&d)return f==e&&d==t;var p=-1,g=!0,y=2&n?new r:void 0;for(c.set(t,e),c.set(e,t);++p<u;){var m=t[p],b=e[p];if(o)var v=l?o(b,m,p,e,t,c):o(m,b,p,t,e,c);if(void 0!==v){if(v)continue;g=!1;break}if(y){if(!i(e,(function(t,e){if(!a(y,e)&&(m===t||s(m,t,n,o,c)))return y.push(e)}))){g=!1;break}}else if(m!==b&&!s(m,b,n,o,c)){g=!1;break}}return c.delete(t),c.delete(e),g};},8351:(t,e,n)=>{var r=n(2705),i=n(1149),a=n(7813),o=n(7114),s=n(8776),c=n(1814),l=r?r.prototype:void 0,u=l?l.valueOf:void 0;t.exports=function(t,e,n,r,l,h,f){switch(n){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return !1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return !(t.byteLength!=e.byteLength||!h(new i(t),new i(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return a(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var d=s;case"[object Set]":var p=1&r;if(d||(d=c),t.size!=e.size&&!p)return !1;var g=f.get(t);if(g)return g==e;r|=2,f.set(t,e);var y=o(d(t),d(e),r,l,h,f);return f.delete(t),y;case"[object Symbol]":if(u)return u.call(t)==u.call(e)}return !1};},6096:(t,e,n)=>{var r=n(8234),i=Object.prototype.hasOwnProperty;t.exports=function(t,e,n,a,o,s){var c=1&n,l=r(t),u=l.length;if(u!=r(e).length&&!c)return !1;for(var h=u;h--;){var f=l[h];if(!(c?f in e:i.call(e,f)))return !1}var d=s.get(t),p=s.get(e);if(d&&p)return d==e&&p==t;var g=!0;s.set(t,e),s.set(e,t);for(var y=c;++h<u;){var m=t[f=l[h]],b=e[f];if(a)var v=c?a(b,m,f,e,t,s):a(m,b,f,t,e,s);if(!(void 0===v?m===b||o(m,b,n,a,s):v)){g=!1;break}y||(y="constructor"==f);}if(g&&!y){var _=t.constructor,x=e.constructor;_==x||!("constructor"in t)||!("constructor"in e)||"function"==typeof _&&_ instanceof _&&"function"==typeof x&&x instanceof x||(g=!1);}return s.delete(t),s.delete(e),g};},9021:(t,e,n)=>{var r=n(5564),i=n(5357),a=n(61);t.exports=function(t){return a(i(t,void 0,r),t+"")};},1957:(t,e,n)=>{var r="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;t.exports=r;},8234:(t,e,n)=>{var r=n(8866),i=n(9551),a=n(3674);t.exports=function(t){return r(t,a,i)};},6904:(t,e,n)=>{var r=n(8866),i=n(1442),a=n(1704);t.exports=function(t){return r(t,a,i)};},5050:(t,e,n)=>{var r=n(7019);t.exports=function(t,e){var n=t.__data__;return r(e)?n["string"==typeof e?"string":"hash"]:n.map};},1499:(t,e,n)=>{var r=n(9162),i=n(3674);t.exports=function(t){for(var e=i(t),n=e.length;n--;){var a=e[n],o=t[a];e[n]=[a,o,r(o)];}return e};},852:(t,e,n)=>{var r=n(8458),i=n(7801);t.exports=function(t,e){var n=i(t,e);return r(n)?n:void 0};},5924:(t,e,n)=>{var r=n(5569)(Object.getPrototypeOf,Object);t.exports=r;},9607:(t,e,n)=>{var r=n(2705),i=Object.prototype,a=i.hasOwnProperty,o=i.toString,s=r?r.toStringTag:void 0;t.exports=function(t){var e=a.call(t,s),n=t[s];try{t[s]=void 0;var r=!0;}catch(t){}var i=o.call(t);return r&&(e?t[s]=n:delete t[s]),i};},9551:(t,e,n)=>{var r=n(4963),i=n(479),a=Object.prototype.propertyIsEnumerable,o=Object.getOwnPropertySymbols,s=o?function(t){return null==t?[]:(t=Object(t),r(o(t),(function(e){return a.call(t,e)})))}:i;t.exports=s;},1442:(t,e,n)=>{var r=n(2488),i=n(5924),a=n(9551),o=n(479),s=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)r(e,a(t)),t=i(t);return e}:o;t.exports=s;},4160:(t,e,n)=>{var r=n(8552),i=n(7071),a=n(3818),o=n(8525),s=n(577),c=n(4239),l=n(346),u="[object Map]",h="[object Promise]",f="[object Set]",d="[object WeakMap]",p="[object DataView]",g=l(r),y=l(i),m=l(a),b=l(o),v=l(s),_=c;(r&&_(new r(new ArrayBuffer(1)))!=p||i&&_(new i)!=u||a&&_(a.resolve())!=h||o&&_(new o)!=f||s&&_(new s)!=d)&&(_=function(t){var e=c(t),n="[object Object]"==e?t.constructor:void 0,r=n?l(n):"";if(r)switch(r){case g:return p;case y:return u;case m:return h;case b:return f;case v:return d}return e}),t.exports=_;},7801:t=>{t.exports=function(t,e){return null==t?void 0:t[e]};},222:(t,e,n)=>{var r=n(1811),i=n(5694),a=n(1469),o=n(5776),s=n(1780),c=n(327);t.exports=function(t,e,n){for(var l=-1,u=(e=r(e,t)).length,h=!1;++l<u;){var f=c(e[l]);if(!(h=null!=t&&n(t,f)))break;t=t[f];}return h||++l!=u?h:!!(u=null==t?0:t.length)&&s(u)&&o(f,u)&&(a(t)||i(t))};},2689:t=>{var e=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");t.exports=function(t){return e.test(t)};},1789:(t,e,n)=>{var r=n(4536);t.exports=function(){this.__data__=r?r(null):{},this.size=0;};},401:t=>{t.exports=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e};},7667:(t,e,n)=>{var r=n(4536),i=Object.prototype.hasOwnProperty;t.exports=function(t){var e=this.__data__;if(r){var n=e[t];return "__lodash_hash_undefined__"===n?void 0:n}return i.call(e,t)?e[t]:void 0};},1327:(t,e,n)=>{var r=n(4536),i=Object.prototype.hasOwnProperty;t.exports=function(t){var e=this.__data__;return r?void 0!==e[t]:i.call(e,t)};},1866:(t,e,n)=>{var r=n(4536);t.exports=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=r&&void 0===e?"__lodash_hash_undefined__":e,this};},3824:t=>{var e=Object.prototype.hasOwnProperty;t.exports=function(t){var n=t.length,r=new t.constructor(n);return n&&"string"==typeof t[0]&&e.call(t,"index")&&(r.index=t.index,r.input=t.input),r};},9148:(t,e,n)=>{var r=n(4318),i=n(7157),a=n(3147),o=n(419),s=n(7133);t.exports=function(t,e,n){var c=t.constructor;switch(e){case"[object ArrayBuffer]":return r(t);case"[object Boolean]":case"[object Date]":return new c(+t);case"[object DataView]":return i(t,n);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return s(t,n);case"[object Map]":case"[object Set]":return new c;case"[object Number]":case"[object String]":return new c(t);case"[object RegExp]":return a(t);case"[object Symbol]":return o(t)}};},8517:(t,e,n)=>{var r=n(3118),i=n(5924),a=n(5726);t.exports=function(t){return "function"!=typeof t.constructor||a(t)?{}:r(i(t))};},7285:(t,e,n)=>{var r=n(2705),i=n(5694),a=n(1469),o=r?r.isConcatSpreadable:void 0;t.exports=function(t){return a(t)||i(t)||!!(o&&t&&t[o])};},5776:t=>{var e=/^(?:0|[1-9]\d*)$/;t.exports=function(t,n){var r=typeof t;return !!(n=null==n?9007199254740991:n)&&("number"==r||"symbol"!=r&&e.test(t))&&t>-1&&t%1==0&&t<n};},6612:(t,e,n)=>{var r=n(7813),i=n(8612),a=n(5776),o=n(3218);t.exports=function(t,e,n){if(!o(n))return !1;var s=typeof e;return !!("number"==s?i(n)&&a(e,n.length):"string"==s&&e in n)&&r(n[e],t)};},5403:(t,e,n)=>{var r=n(1469),i=n(3448),a=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,o=/^\w*$/;t.exports=function(t,e){if(r(t))return !1;var n=typeof t;return !("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!i(t))||o.test(t)||!a.test(t)||null!=e&&t in Object(e)};},7019:t=>{t.exports=function(t){var e=typeof t;return "string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};},5346:(t,e,n)=>{var r,i=n(4429),a=(r=/[^.]+$/.exec(i&&i.keys&&i.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";t.exports=function(t){return !!a&&a in t};},5726:t=>{var e=Object.prototype;t.exports=function(t){var n=t&&t.constructor;return t===("function"==typeof n&&n.prototype||e)};},9162:(t,e,n)=>{var r=n(3218);t.exports=function(t){return t==t&&!r(t)};},7040:t=>{t.exports=function(){this.__data__=[],this.size=0;};},4125:(t,e,n)=>{var r=n(8470),i=Array.prototype.splice;t.exports=function(t){var e=this.__data__,n=r(e,t);return !(n<0||(n==e.length-1?e.pop():i.call(e,n,1),--this.size,0))};},2117:(t,e,n)=>{var r=n(8470);t.exports=function(t){var e=this.__data__,n=r(e,t);return n<0?void 0:e[n][1]};},7518:(t,e,n)=>{var r=n(8470);t.exports=function(t){return r(this.__data__,t)>-1};},4705:(t,e,n)=>{var r=n(8470);t.exports=function(t,e){var n=this.__data__,i=r(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this};},4785:(t,e,n)=>{var r=n(1989),i=n(8407),a=n(7071);t.exports=function(){this.size=0,this.__data__={hash:new r,map:new(a||i),string:new r};};},1285:(t,e,n)=>{var r=n(5050);t.exports=function(t){var e=r(this,t).delete(t);return this.size-=e?1:0,e};},6e3:(t,e,n)=>{var r=n(5050);t.exports=function(t){return r(this,t).get(t)};},9916:(t,e,n)=>{var r=n(5050);t.exports=function(t){return r(this,t).has(t)};},5265:(t,e,n)=>{var r=n(5050);t.exports=function(t,e){var n=r(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this};},8776:t=>{t.exports=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t];})),n};},2634:t=>{t.exports=function(t,e){return function(n){return null!=n&&n[t]===e&&(void 0!==e||t in Object(n))}};},4523:(t,e,n)=>{var r=n(8306);t.exports=function(t){var e=r(t,(function(t){return 500===n.size&&n.clear(),t})),n=e.cache;return e};},4536:(t,e,n)=>{var r=n(852)(Object,"create");t.exports=r;},6916:(t,e,n)=>{var r=n(5569)(Object.keys,Object);t.exports=r;},3498:t=>{t.exports=function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e};},1167:(t,e,n)=>{t=n.nmd(t);var r=n(1957),i=e&&!e.nodeType&&e,a=i&&t&&!t.nodeType&&t,o=a&&a.exports===i&&r.process,s=function(){try{return a&&a.require&&a.require("util").types||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=s;},2333:t=>{var e=Object.prototype.toString;t.exports=function(t){return e.call(t)};},5569:t=>{t.exports=function(t,e){return function(n){return t(e(n))}};},5357:(t,e,n)=>{var r=n(6874),i=Math.max;t.exports=function(t,e,n){return e=i(void 0===e?t.length-1:e,0),function(){for(var a=arguments,o=-1,s=i(a.length-e,0),c=Array(s);++o<s;)c[o]=a[e+o];o=-1;for(var l=Array(e+1);++o<e;)l[o]=a[o];return l[e]=n(c),r(t,this,l)}};},5639:(t,e,n)=>{var r=n(1957),i="object"==typeof self&&self&&self.Object===Object&&self,a=r||i||Function("return this")();t.exports=a;},6390:t=>{t.exports=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};},619:t=>{t.exports=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this};},2385:t=>{t.exports=function(t){return this.__data__.has(t)};},1814:t=>{t.exports=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t;})),n};},61:(t,e,n)=>{var r=n(6560),i=n(1275)(r);t.exports=i;},1275:t=>{var e=Date.now;t.exports=function(t){var n=0,r=0;return function(){var i=e(),a=16-(i-r);if(r=i,a>0){if(++n>=800)return arguments[0]}else n=0;return t.apply(void 0,arguments)}};},7465:(t,e,n)=>{var r=n(8407);t.exports=function(){this.__data__=new r,this.size=0;};},3779:t=>{t.exports=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n};},7599:t=>{t.exports=function(t){return this.__data__.get(t)};},4758:t=>{t.exports=function(t){return this.__data__.has(t)};},4309:(t,e,n)=>{var r=n(8407),i=n(7071),a=n(3369);t.exports=function(t,e){var n=this.__data__;if(n instanceof r){var o=n.__data__;if(!i||o.length<199)return o.push([t,e]),this.size=++n.size,this;n=this.__data__=new a(o);}return n.set(t,e),this.size=n.size,this};},2351:t=>{t.exports=function(t,e,n){for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return -1};},8016:(t,e,n)=>{var r=n(8983),i=n(2689),a=n(1903);t.exports=function(t){return i(t)?a(t):r(t)};},5514:(t,e,n)=>{var r=n(4523),i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,a=/\\(\\)?/g,o=r((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(i,(function(t,n,r,i){e.push(r?i.replace(a,"$1"):n||t);})),e}));t.exports=o;},327:(t,e,n)=>{var r=n(3448);t.exports=function(t){if("string"==typeof t||r(t))return t;var e=t+"";return "0"==e&&1/t==-1/0?"-0":e};},346:t=>{var e=Function.prototype.toString;t.exports=function(t){if(null!=t){try{return e.call(t)}catch(t){}try{return t+""}catch(t){}}return ""};},7990:t=>{var e=/\s/;t.exports=function(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n};},1903:t=>{var e="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",n="\\ud83c[\\udffb-\\udfff]",r="[^\\ud800-\\udfff]",i="(?:\\ud83c[\\udde6-\\uddff]){2}",a="[\\ud800-\\udbff][\\udc00-\\udfff]",o="(?:"+e+"|"+n+")?",s="[\\ufe0e\\ufe0f]?",c=s+o+"(?:\\u200d(?:"+[r,i,a].join("|")+")"+s+o+")*",l="(?:"+[r+e+"?",e,i,a,"[\\ud800-\\udfff]"].join("|")+")",u=RegExp(n+"(?="+n+")|"+l+c,"g");t.exports=function(t){for(var e=u.lastIndex=0;u.test(t);)++e;return e};},6678:(t,e,n)=>{var r=n(5990);t.exports=function(t){return r(t,4)};},361:(t,e,n)=>{var r=n(5990);t.exports=function(t){return r(t,5)};},5703:t=>{t.exports=function(t){return function(){return t}};},1747:(t,e,n)=>{var r=n(5976),i=n(7813),a=n(6612),o=n(1704),s=Object.prototype,c=s.hasOwnProperty,l=r((function(t,e){t=Object(t);var n=-1,r=e.length,l=r>2?e[2]:void 0;for(l&&a(e[0],e[1],l)&&(r=1);++n<r;)for(var u=e[n],h=o(u),f=-1,d=h.length;++f<d;){var p=h[f],g=t[p];(void 0===g||i(g,s[p])&&!c.call(t,p))&&(t[p]=u[p]);}return t}));t.exports=l;},6073:(t,e,n)=>{t.exports=n(4486);},7813:t=>{t.exports=function(t,e){return t===e||t!=t&&e!=e};},3105:(t,e,n)=>{var r=n(4963),i=n(760),a=n(7206),o=n(1469);t.exports=function(t,e){return (o(t)?r:i)(t,a(e,3))};},3311:(t,e,n)=>{var r=n(7740)(n(998));t.exports=r;},998:(t,e,n)=>{var r=n(1848),i=n(7206),a=n(554),o=Math.max;t.exports=function(t,e,n){var s=null==t?0:t.length;if(!s)return -1;var c=null==n?0:a(n);return c<0&&(c=o(s+c,0)),r(t,i(e,3),c)};},5564:(t,e,n)=>{var r=n(1078);t.exports=function(t){return null!=t&&t.length?r(t,1):[]};},4486:(t,e,n)=>{var r=n(7412),i=n(9881),a=n(4290),o=n(1469);t.exports=function(t,e){return (o(t)?r:i)(t,a(e))};},2620:(t,e,n)=>{var r=n(8483),i=n(4290),a=n(1704);t.exports=function(t,e){return null==t?t:r(t,i(e),a)};},7361:(t,e,n)=>{var r=n(7786);t.exports=function(t,e,n){var i=null==t?void 0:r(t,e);return void 0===i?n:i};},8721:(t,e,n)=>{var r=n(8565),i=n(222);t.exports=function(t,e){return null!=t&&i(t,e,r)};},9095:(t,e,n)=>{var r=n(13),i=n(222);t.exports=function(t,e){return null!=t&&i(t,e,r)};},6557:t=>{t.exports=function(t){return t};},5694:(t,e,n)=>{var r=n(9454),i=n(7005),a=Object.prototype,o=a.hasOwnProperty,s=a.propertyIsEnumerable,c=r(function(){return arguments}())?r:function(t){return i(t)&&o.call(t,"callee")&&!s.call(t,"callee")};t.exports=c;},1469:t=>{var e=Array.isArray;t.exports=e;},8612:(t,e,n)=>{var r=n(3560),i=n(1780);t.exports=function(t){return null!=t&&i(t.length)&&!r(t)};},9246:(t,e,n)=>{var r=n(8612),i=n(7005);t.exports=function(t){return i(t)&&r(t)};},4144:(t,e,n)=>{t=n.nmd(t);var r=n(5639),i=n(5062),a=e&&!e.nodeType&&e,o=a&&t&&!t.nodeType&&t,s=o&&o.exports===a?r.Buffer:void 0,c=(s?s.isBuffer:void 0)||i;t.exports=c;},1609:(t,e,n)=>{var r=n(280),i=n(4160),a=n(5694),o=n(1469),s=n(8612),c=n(4144),l=n(5726),u=n(6719),h=Object.prototype.hasOwnProperty;t.exports=function(t){if(null==t)return !0;if(s(t)&&(o(t)||"string"==typeof t||"function"==typeof t.splice||c(t)||u(t)||a(t)))return !t.length;var e=i(t);if("[object Map]"==e||"[object Set]"==e)return !t.size;if(l(t))return !r(t).length;for(var n in t)if(h.call(t,n))return !1;return !0};},3560:(t,e,n)=>{var r=n(4239),i=n(3218);t.exports=function(t){if(!i(t))return !1;var e=r(t);return "[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e};},1780:t=>{t.exports=function(t){return "number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991};},6688:(t,e,n)=>{var r=n(5588),i=n(1717),a=n(1167),o=a&&a.isMap,s=o?i(o):r;t.exports=s;},3218:t=>{t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)};},7005:t=>{t.exports=function(t){return null!=t&&"object"==typeof t};},8630:(t,e,n)=>{var r=n(4239),i=n(5924),a=n(7005),o=Function.prototype,s=Object.prototype,c=o.toString,l=s.hasOwnProperty,u=c.call(Object);t.exports=function(t){if(!a(t)||"[object Object]"!=r(t))return !1;var e=i(t);if(null===e)return !0;var n=l.call(e,"constructor")&&e.constructor;return "function"==typeof n&&n instanceof n&&c.call(n)==u};},2928:(t,e,n)=>{var r=n(9221),i=n(1717),a=n(1167),o=a&&a.isSet,s=o?i(o):r;t.exports=s;},7037:(t,e,n)=>{var r=n(4239),i=n(1469),a=n(7005);t.exports=function(t){return "string"==typeof t||!i(t)&&a(t)&&"[object String]"==r(t)};},3448:(t,e,n)=>{var r=n(4239),i=n(7005);t.exports=function(t){return "symbol"==typeof t||i(t)&&"[object Symbol]"==r(t)};},6719:(t,e,n)=>{var r=n(8749),i=n(1717),a=n(1167),o=a&&a.isTypedArray,s=o?i(o):r;t.exports=s;},2353:t=>{t.exports=function(t){return void 0===t};},3674:(t,e,n)=>{var r=n(4636),i=n(280),a=n(8612);t.exports=function(t){return a(t)?r(t):i(t)};},1704:(t,e,n)=>{var r=n(4636),i=n(313),a=n(8612);t.exports=function(t){return a(t)?r(t,!0):i(t)};},928:t=>{t.exports=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0};},5161:(t,e,n)=>{var r=n(9932),i=n(7206),a=n(9199),o=n(1469);t.exports=function(t,e){return (o(t)?r:a)(t,i(e,3))};},6604:(t,e,n)=>{var r=n(9465),i=n(7816),a=n(7206);t.exports=function(t,e){var n={};return e=a(e,3),i(t,(function(t,i,a){r(n,i,e(t,i,a));})),n};},6162:(t,e,n)=>{var r=n(6029),i=n(3325),a=n(6557);t.exports=function(t){return t&&t.length?r(t,a,i):void 0};},8306:(t,e,n)=>{var r=n(3369);function i(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,i=e?e.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=t.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(i.Cache||r),n}i.Cache=r,t.exports=i;},3857:(t,e,n)=>{var r=n(2980),i=n(1463)((function(t,e,n){r(t,e,n);}));t.exports=i;},3632:(t,e,n)=>{var r=n(6029),i=n(433),a=n(6557);t.exports=function(t){return t&&t.length?r(t,a,i):void 0};},2762:(t,e,n)=>{var r=n(6029),i=n(7206),a=n(433);t.exports=function(t,e){return t&&t.length?r(t,i(e,2),a):void 0};},308:t=>{t.exports=function(){};},7771:(t,e,n)=>{var r=n(5639);t.exports=function(){return r.Date.now()};},9722:(t,e,n)=>{var r=n(5970),i=n(9021)((function(t,e){return null==t?{}:r(t,e)}));t.exports=i;},9601:(t,e,n)=>{var r=n(371),i=n(9152),a=n(5403),o=n(327);t.exports=function(t){return a(t)?r(o(t)):i(t)};},6026:(t,e,n)=>{var r=n(7445)();t.exports=r;},4061:(t,e,n)=>{var r=n(2663),i=n(9881),a=n(7206),o=n(107),s=n(1469);t.exports=function(t,e,n){var c=s(t)?r:o,l=arguments.length<3;return c(t,a(e,4),n,l,i)};},4238:(t,e,n)=>{var r=n(280),i=n(4160),a=n(8612),o=n(7037),s=n(8016);t.exports=function(t){if(null==t)return 0;if(a(t))return o(t)?s(t):t.length;var e=i(t);return "[object Map]"==e||"[object Set]"==e?t.size:r(t).length};},9734:(t,e,n)=>{var r=n(1078),i=n(9556),a=n(5976),o=n(6612),s=a((function(t,e){if(null==t)return [];var n=e.length;return n>1&&o(t,e[0],e[1])?e=[]:n>2&&o(e[0],e[1],e[2])&&(e=[e[0]]),i(t,r(e,1),[])}));t.exports=s;},479:t=>{t.exports=function(){return []};},5062:t=>{t.exports=function(){return !1};},8601:(t,e,n)=>{var r=n(4841);t.exports=function(t){return t?Infinity===(t=r(t))||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0};},554:(t,e,n)=>{var r=n(8601);t.exports=function(t){var e=r(t),n=e%1;return e==e?n?e-n:e:0};},4841:(t,e,n)=>{var r=n(7561),i=n(3218),a=n(3448),o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,c=/^0o[0-7]+$/i,l=parseInt;t.exports=function(t){if("number"==typeof t)return t;if(a(t))return NaN;if(i(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=i(e)?e+"":e;}if("string"!=typeof t)return 0===t?t:+t;t=r(t);var n=s.test(t);return n||c.test(t)?l(t.slice(2),n?2:8):o.test(t)?NaN:+t};},3678:(t,e,n)=>{var r=n(8363),i=n(1704);t.exports=function(t){return r(t,i(t))};},9833:(t,e,n)=>{var r=n(531);t.exports=function(t){return null==t?"":r(t)};},8718:(t,e,n)=>{var r=n(7412),i=n(3118),a=n(7816),o=n(7206),s=n(5924),c=n(1469),l=n(4144),u=n(3560),h=n(3218),f=n(6719);t.exports=function(t,e,n){var d=c(t),p=d||l(t)||f(t);if(e=o(e,4),null==n){var g=t&&t.constructor;n=p?d?new g:[]:h(t)&&u(g)?i(s(t)):{};}return (p?r:a)(t,(function(t,r,i){return e(n,t,r,i)})),n};},3386:(t,e,n)=>{var r=n(1078),i=n(5976),a=n(5652),o=n(9246),s=i((function(t){return a(r(t,1,o,!0))}));t.exports=s;},3955:(t,e,n)=>{var r=n(9833),i=0;t.exports=function(t){var e=++i;return r(t)+e};},2628:(t,e,n)=>{var r=n(7415),i=n(3674);t.exports=function(t){return null==t?[]:r(t,i(t))};},7287:(t,e,n)=>{var r=n(4865),i=n(1757);t.exports=function(t,e){return i(t||[],e||[],r)};},9234:()=>{},1748:(t,e,n)=>{var r={"./locale":9234,"./locale.js":9234};function i(t){var e=a(t);return n(e)}function a(t){if(!n.o(r,t)){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}return r[t]}i.keys=function(){return Object.keys(r)},i.resolve=a,t.exports=i,i.id=1748;},1941:function(t,e,n){(t=n.nmd(t)).exports=function(){var e,r;function i(){return e.apply(null,arguments)}function a(t){return t instanceof Array||"[object Array]"===Object.prototype.toString.call(t)}function o(t){return null!=t&&"[object Object]"===Object.prototype.toString.call(t)}function s(t){return void 0===t}function c(t){return "number"==typeof t||"[object Number]"===Object.prototype.toString.call(t)}function l(t){return t instanceof Date||"[object Date]"===Object.prototype.toString.call(t)}function u(t,e){var n,r=[];for(n=0;n<t.length;++n)r.push(e(t[n],n));return r}function h(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function f(t,e){for(var n in e)h(e,n)&&(t[n]=e[n]);return h(e,"toString")&&(t.toString=e.toString),h(e,"valueOf")&&(t.valueOf=e.valueOf),t}function d(t,e,n,r){return ve(t,e,n,r,!0).utc()}function p(t){return null==t._pf&&(t._pf={empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1,parsedDateParts:[],meridiem:null,rfc2822:!1,weekdayMismatch:!1}),t._pf}function g(t){if(null==t._isValid){var e=p(t),n=r.call(e.parsedDateParts,(function(t){return null!=t})),i=!isNaN(t._d.getTime())&&e.overflow<0&&!e.empty&&!e.invalidMonth&&!e.invalidWeekday&&!e.weekdayMismatch&&!e.nullInput&&!e.invalidFormat&&!e.userInvalidated&&(!e.meridiem||e.meridiem&&n);if(t._strict&&(i=i&&0===e.charsLeftOver&&0===e.unusedTokens.length&&void 0===e.bigHour),null!=Object.isFrozen&&Object.isFrozen(t))return i;t._isValid=i;}return t._isValid}function y(t){var e=d(NaN);return null!=t?f(p(e),t):p(e).userInvalidated=!0,e}r=Array.prototype.some?Array.prototype.some:function(t){for(var e=Object(this),n=e.length>>>0,r=0;r<n;r++)if(r in e&&t.call(this,e[r],r,e))return !0;return !1};var m=i.momentProperties=[];function b(t,e){var n,r,i;if(s(e._isAMomentObject)||(t._isAMomentObject=e._isAMomentObject),s(e._i)||(t._i=e._i),s(e._f)||(t._f=e._f),s(e._l)||(t._l=e._l),s(e._strict)||(t._strict=e._strict),s(e._tzm)||(t._tzm=e._tzm),s(e._isUTC)||(t._isUTC=e._isUTC),s(e._offset)||(t._offset=e._offset),s(e._pf)||(t._pf=p(e)),s(e._locale)||(t._locale=e._locale),0<m.length)for(n=0;n<m.length;n++)s(i=e[r=m[n]])||(t[r]=i);return t}var v=!1;function _(t){b(this,t),this._d=new Date(null!=t._d?t._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),!1===v&&(v=!0,i.updateOffset(this),v=!1);}function x(t){return t instanceof _||null!=t&&null!=t._isAMomentObject}function k(t){return t<0?Math.ceil(t)||0:Math.floor(t)}function w(t){var e=+t,n=0;return 0!==e&&isFinite(e)&&(n=k(e)),n}function T(t,e,n){var r,i=Math.min(t.length,e.length),a=Math.abs(t.length-e.length),o=0;for(r=0;r<i;r++)(n&&t[r]!==e[r]||!n&&w(t[r])!==w(e[r]))&&o++;return o+a}function E(t){!1===i.suppressDeprecationWarnings&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+t);}function C(t,e){var n=!0;return f((function(){if(null!=i.deprecationHandler&&i.deprecationHandler(null,t),n){for(var r,a=[],o=0;o<arguments.length;o++){if(r="","object"==typeof arguments[o]){for(var s in r+="\n["+o+"] ",arguments[0])r+=s+": "+arguments[0][s]+", ";r=r.slice(0,-2);}else r=arguments[o];a.push(r);}E(t+"\nArguments: "+Array.prototype.slice.call(a).join("")+"\n"+(new Error).stack),n=!1;}return e.apply(this,arguments)}),e)}var S,A={};function M(t,e){null!=i.deprecationHandler&&i.deprecationHandler(t,e),A[t]||(E(e),A[t]=!0);}function N(t){return t instanceof Function||"[object Function]"===Object.prototype.toString.call(t)}function O(t,e){var n,r=f({},t);for(n in e)h(e,n)&&(o(t[n])&&o(e[n])?(r[n]={},f(r[n],t[n]),f(r[n],e[n])):null!=e[n]?r[n]=e[n]:delete r[n]);for(n in t)h(t,n)&&!h(e,n)&&o(t[n])&&(r[n]=f({},r[n]));return r}function D(t){null!=t&&this.set(t);}i.suppressDeprecationWarnings=!1,i.deprecationHandler=null,S=Object.keys?Object.keys:function(t){var e,n=[];for(e in t)h(t,e)&&n.push(e);return n};var B={};function L(t,e){var n=t.toLowerCase();B[n]=B[n+"s"]=B[e]=t;}function I(t){return "string"==typeof t?B[t]||B[t.toLowerCase()]:void 0}function F(t){var e,n,r={};for(n in t)h(t,n)&&(e=I(n))&&(r[e]=t[n]);return r}var R={};function P(t,e){R[t]=e;}function j(t,e,n){var r=""+Math.abs(t),i=e-r.length;return (0<=t?n?"+":"":"-")+Math.pow(10,Math.max(0,i)).toString().substr(1)+r}var z=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,Y=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,U={},$={};function W(t,e,n,r){var i=r;"string"==typeof r&&(i=function(){return this[r]()}),t&&($[t]=i),e&&($[e[0]]=function(){return j(i.apply(this,arguments),e[1],e[2])}),n&&($[n]=function(){return this.localeData().ordinal(i.apply(this,arguments),t)});}function q(t,e){return t.isValid()?(e=H(e,t.localeData()),U[e]=U[e]||function(t){var e,n,r,i=t.match(z);for(e=0,n=i.length;e<n;e++)$[i[e]]?i[e]=$[i[e]]:i[e]=(r=i[e]).match(/\[[\s\S]/)?r.replace(/^\[|\]$/g,""):r.replace(/\\/g,"");return function(e){var r,a="";for(r=0;r<n;r++)a+=N(i[r])?i[r].call(e,t):i[r];return a}}(e),U[e](t)):t.localeData().invalidDate()}function H(t,e){var n=5;function r(t){return e.longDateFormat(t)||t}for(Y.lastIndex=0;0<=n&&Y.test(t);)t=t.replace(Y,r),Y.lastIndex=0,n-=1;return t}var V=/\d/,G=/\d\d/,X=/\d{3}/,Z=/\d{4}/,Q=/[+-]?\d{6}/,K=/\d\d?/,J=/\d\d\d\d?/,tt=/\d\d\d\d\d\d?/,et=/\d{1,3}/,nt=/\d{1,4}/,rt=/[+-]?\d{1,6}/,it=/\d+/,at=/[+-]?\d+/,ot=/Z|[+-]\d\d:?\d\d/gi,st=/Z|[+-]\d\d(?::?\d\d)?/gi,ct=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,lt={};function ut(t,e,n){lt[t]=N(e)?e:function(t,r){return t&&n?n:e};}function ht(t,e){return h(lt,t)?lt[t](e._strict,e._locale):new RegExp(ft(t.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,(function(t,e,n,r,i){return e||n||r||i}))))}function ft(t){return t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}var dt={};function pt(t,e){var n,r=e;for("string"==typeof t&&(t=[t]),c(e)&&(r=function(t,n){n[e]=w(t);}),n=0;n<t.length;n++)dt[t[n]]=r;}function gt(t,e){pt(t,(function(t,n,r,i){r._w=r._w||{},e(t,r._w,r,i);}));}function yt(t){return mt(t)?366:365}function mt(t){return t%4==0&&t%100!=0||t%400==0}W("Y",0,0,(function(){var t=this.year();return t<=9999?""+t:"+"+t})),W(0,["YY",2],0,(function(){return this.year()%100})),W(0,["YYYY",4],0,"year"),W(0,["YYYYY",5],0,"year"),W(0,["YYYYYY",6,!0],0,"year"),L("year","y"),P("year",1),ut("Y",at),ut("YY",K,G),ut("YYYY",nt,Z),ut("YYYYY",rt,Q),ut("YYYYYY",rt,Q),pt(["YYYYY","YYYYYY"],0),pt("YYYY",(function(t,e){e[0]=2===t.length?i.parseTwoDigitYear(t):w(t);})),pt("YY",(function(t,e){e[0]=i.parseTwoDigitYear(t);})),pt("Y",(function(t,e){e[0]=parseInt(t,10);})),i.parseTwoDigitYear=function(t){return w(t)+(68<w(t)?1900:2e3)};var bt,vt=_t("FullYear",!0);function _t(t,e){return function(n){return null!=n?(kt(this,t,n),i.updateOffset(this,e),this):xt(this,t)}}function xt(t,e){return t.isValid()?t._d["get"+(t._isUTC?"UTC":"")+e]():NaN}function kt(t,e,n){t.isValid()&&!isNaN(n)&&("FullYear"===e&&mt(t.year())&&1===t.month()&&29===t.date()?t._d["set"+(t._isUTC?"UTC":"")+e](n,t.month(),wt(n,t.month())):t._d["set"+(t._isUTC?"UTC":"")+e](n));}function wt(t,e){if(isNaN(t)||isNaN(e))return NaN;var n=(e%12+12)%12;return t+=(e-n)/12,1===n?mt(t)?29:28:31-n%7%2}bt=Array.prototype.indexOf?Array.prototype.indexOf:function(t){var e;for(e=0;e<this.length;++e)if(this[e]===t)return e;return -1},W("M",["MM",2],"Mo",(function(){return this.month()+1})),W("MMM",0,0,(function(t){return this.localeData().monthsShort(this,t)})),W("MMMM",0,0,(function(t){return this.localeData().months(this,t)})),L("month","M"),P("month",8),ut("M",K),ut("MM",K,G),ut("MMM",(function(t,e){return e.monthsShortRegex(t)})),ut("MMMM",(function(t,e){return e.monthsRegex(t)})),pt(["M","MM"],(function(t,e){e[1]=w(t)-1;})),pt(["MMM","MMMM"],(function(t,e,n,r){var i=n._locale.monthsParse(t,r,n._strict);null!=i?e[1]=i:p(n).invalidMonth=t;}));var Tt=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,Et="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),Ct="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_");function St(t,e){var n;if(!t.isValid())return t;if("string"==typeof e)if(/^\d+$/.test(e))e=w(e);else if(!c(e=t.localeData().monthsParse(e)))return t;return n=Math.min(t.date(),wt(t.year(),e)),t._d["set"+(t._isUTC?"UTC":"")+"Month"](e,n),t}function At(t){return null!=t?(St(this,t),i.updateOffset(this,!0),this):xt(this,"Month")}var Mt=ct,Nt=ct;function Ot(){function t(t,e){return e.length-t.length}var e,n,r=[],i=[],a=[];for(e=0;e<12;e++)n=d([2e3,e]),r.push(this.monthsShort(n,"")),i.push(this.months(n,"")),a.push(this.months(n,"")),a.push(this.monthsShort(n,""));for(r.sort(t),i.sort(t),a.sort(t),e=0;e<12;e++)r[e]=ft(r[e]),i[e]=ft(i[e]);for(e=0;e<24;e++)a[e]=ft(a[e]);this._monthsRegex=new RegExp("^("+a.join("|")+")","i"),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=new RegExp("^("+i.join("|")+")","i"),this._monthsShortStrictRegex=new RegExp("^("+r.join("|")+")","i");}function Dt(t){var e;if(t<100&&0<=t){var n=Array.prototype.slice.call(arguments);n[0]=t+400,e=new Date(Date.UTC.apply(null,n)),isFinite(e.getUTCFullYear())&&e.setUTCFullYear(t);}else e=new Date(Date.UTC.apply(null,arguments));return e}function Bt(t,e,n){var r=7+e-n;return -(7+Dt(t,0,r).getUTCDay()-e)%7+r-1}function Lt(t,e,n,r,i){var a,o,s=1+7*(e-1)+(7+n-r)%7+Bt(t,r,i);return o=s<=0?yt(a=t-1)+s:s>yt(t)?(a=t+1,s-yt(t)):(a=t,s),{year:a,dayOfYear:o}}function It(t,e,n){var r,i,a=Bt(t.year(),e,n),o=Math.floor((t.dayOfYear()-a-1)/7)+1;return o<1?r=o+Ft(i=t.year()-1,e,n):o>Ft(t.year(),e,n)?(r=o-Ft(t.year(),e,n),i=t.year()+1):(i=t.year(),r=o),{week:r,year:i}}function Ft(t,e,n){var r=Bt(t,e,n),i=Bt(t+1,e,n);return (yt(t)-r+i)/7}function Rt(t,e){return t.slice(e,7).concat(t.slice(0,e))}W("w",["ww",2],"wo","week"),W("W",["WW",2],"Wo","isoWeek"),L("week","w"),L("isoWeek","W"),P("week",5),P("isoWeek",5),ut("w",K),ut("ww",K,G),ut("W",K),ut("WW",K,G),gt(["w","ww","W","WW"],(function(t,e,n,r){e[r.substr(0,1)]=w(t);})),W("d",0,"do","day"),W("dd",0,0,(function(t){return this.localeData().weekdaysMin(this,t)})),W("ddd",0,0,(function(t){return this.localeData().weekdaysShort(this,t)})),W("dddd",0,0,(function(t){return this.localeData().weekdays(this,t)})),W("e",0,0,"weekday"),W("E",0,0,"isoWeekday"),L("day","d"),L("weekday","e"),L("isoWeekday","E"),P("day",11),P("weekday",11),P("isoWeekday",11),ut("d",K),ut("e",K),ut("E",K),ut("dd",(function(t,e){return e.weekdaysMinRegex(t)})),ut("ddd",(function(t,e){return e.weekdaysShortRegex(t)})),ut("dddd",(function(t,e){return e.weekdaysRegex(t)})),gt(["dd","ddd","dddd"],(function(t,e,n,r){var i=n._locale.weekdaysParse(t,r,n._strict);null!=i?e.d=i:p(n).invalidWeekday=t;})),gt(["d","e","E"],(function(t,e,n,r){e[r]=w(t);}));var Pt="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),jt="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),zt="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),Yt=ct,Ut=ct,$t=ct;function Wt(){function t(t,e){return e.length-t.length}var e,n,r,i,a,o=[],s=[],c=[],l=[];for(e=0;e<7;e++)n=d([2e3,1]).day(e),r=this.weekdaysMin(n,""),i=this.weekdaysShort(n,""),a=this.weekdays(n,""),o.push(r),s.push(i),c.push(a),l.push(r),l.push(i),l.push(a);for(o.sort(t),s.sort(t),c.sort(t),l.sort(t),e=0;e<7;e++)s[e]=ft(s[e]),c[e]=ft(c[e]),l[e]=ft(l[e]);this._weekdaysRegex=new RegExp("^("+l.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+c.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+s.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+o.join("|")+")","i");}function qt(){return this.hours()%12||12}function Ht(t,e){W(t,0,0,(function(){return this.localeData().meridiem(this.hours(),this.minutes(),e)}));}function Vt(t,e){return e._meridiemParse}W("H",["HH",2],0,"hour"),W("h",["hh",2],0,qt),W("k",["kk",2],0,(function(){return this.hours()||24})),W("hmm",0,0,(function(){return ""+qt.apply(this)+j(this.minutes(),2)})),W("hmmss",0,0,(function(){return ""+qt.apply(this)+j(this.minutes(),2)+j(this.seconds(),2)})),W("Hmm",0,0,(function(){return ""+this.hours()+j(this.minutes(),2)})),W("Hmmss",0,0,(function(){return ""+this.hours()+j(this.minutes(),2)+j(this.seconds(),2)})),Ht("a",!0),Ht("A",!1),L("hour","h"),P("hour",13),ut("a",Vt),ut("A",Vt),ut("H",K),ut("h",K),ut("k",K),ut("HH",K,G),ut("hh",K,G),ut("kk",K,G),ut("hmm",J),ut("hmmss",tt),ut("Hmm",J),ut("Hmmss",tt),pt(["H","HH"],3),pt(["k","kk"],(function(t,e,n){var r=w(t);e[3]=24===r?0:r;})),pt(["a","A"],(function(t,e,n){n._isPm=n._locale.isPM(t),n._meridiem=t;})),pt(["h","hh"],(function(t,e,n){e[3]=w(t),p(n).bigHour=!0;})),pt("hmm",(function(t,e,n){var r=t.length-2;e[3]=w(t.substr(0,r)),e[4]=w(t.substr(r)),p(n).bigHour=!0;})),pt("hmmss",(function(t,e,n){var r=t.length-4,i=t.length-2;e[3]=w(t.substr(0,r)),e[4]=w(t.substr(r,2)),e[5]=w(t.substr(i)),p(n).bigHour=!0;})),pt("Hmm",(function(t,e,n){var r=t.length-2;e[3]=w(t.substr(0,r)),e[4]=w(t.substr(r));})),pt("Hmmss",(function(t,e,n){var r=t.length-4,i=t.length-2;e[3]=w(t.substr(0,r)),e[4]=w(t.substr(r,2)),e[5]=w(t.substr(i));}));var Gt,Xt=_t("Hours",!0),Zt={calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},longDateFormat:{LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},invalidDate:"Invalid date",ordinal:"%d",dayOfMonthOrdinalParse:/\d{1,2}/,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},months:Et,monthsShort:Ct,week:{dow:0,doy:6},weekdays:Pt,weekdaysMin:zt,weekdaysShort:jt,meridiemParse:/[ap]\.?m?\.?/i},Qt={},Kt={};function Jt(t){return t?t.toLowerCase().replace("_","-"):t}function te(e){var r=null;if(!Qt[e]&&t&&t.exports)try{r=Gt._abbr,n(1748)("./"+e),ee(r);}catch(e){}return Qt[e]}function ee(t,e){var n;return t&&((n=s(e)?re(t):ne(t,e))?Gt=n:"undefined"!=typeof console&&console.warn&&console.warn("Locale "+t+" not found. Did you forget to load it?")),Gt._abbr}function ne(t,e){if(null===e)return delete Qt[t],null;var n,r=Zt;if(e.abbr=t,null!=Qt[t])M("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),r=Qt[t]._config;else if(null!=e.parentLocale)if(null!=Qt[e.parentLocale])r=Qt[e.parentLocale]._config;else {if(null==(n=te(e.parentLocale)))return Kt[e.parentLocale]||(Kt[e.parentLocale]=[]),Kt[e.parentLocale].push({name:t,config:e}),null;r=n._config;}return Qt[t]=new D(O(r,e)),Kt[t]&&Kt[t].forEach((function(t){ne(t.name,t.config);})),ee(t),Qt[t]}function re(t){var e;if(t&&t._locale&&t._locale._abbr&&(t=t._locale._abbr),!t)return Gt;if(!a(t)){if(e=te(t))return e;t=[t];}return function(t){for(var e,n,r,i,a=0;a<t.length;){for(e=(i=Jt(t[a]).split("-")).length,n=(n=Jt(t[a+1]))?n.split("-"):null;0<e;){if(r=te(i.slice(0,e).join("-")))return r;if(n&&n.length>=e&&T(i,n,!0)>=e-1)break;e--;}a++;}return Gt}(t)}function ie(t){var e,n=t._a;return n&&-2===p(t).overflow&&(e=n[1]<0||11<n[1]?1:n[2]<1||n[2]>wt(n[0],n[1])?2:n[3]<0||24<n[3]||24===n[3]&&(0!==n[4]||0!==n[5]||0!==n[6])?3:n[4]<0||59<n[4]?4:n[5]<0||59<n[5]?5:n[6]<0||999<n[6]?6:-1,p(t)._overflowDayOfYear&&(e<0||2<e)&&(e=2),p(t)._overflowWeeks&&-1===e&&(e=7),p(t)._overflowWeekday&&-1===e&&(e=8),p(t).overflow=e),t}function ae(t,e,n){return null!=t?t:null!=e?e:n}function oe(t){var e,n,r,a,o,s=[];if(!t._d){var c,l;for(c=t,l=new Date(i.now()),r=c._useUTC?[l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate()]:[l.getFullYear(),l.getMonth(),l.getDate()],t._w&&null==t._a[2]&&null==t._a[1]&&function(t){var e,n,r,i,a,o,s,c;if(null!=(e=t._w).GG||null!=e.W||null!=e.E)a=1,o=4,n=ae(e.GG,t._a[0],It(_e(),1,4).year),r=ae(e.W,1),((i=ae(e.E,1))<1||7<i)&&(c=!0);else {a=t._locale._week.dow,o=t._locale._week.doy;var l=It(_e(),a,o);n=ae(e.gg,t._a[0],l.year),r=ae(e.w,l.week),null!=e.d?((i=e.d)<0||6<i)&&(c=!0):null!=e.e?(i=e.e+a,(e.e<0||6<e.e)&&(c=!0)):i=a;}r<1||r>Ft(n,a,o)?p(t)._overflowWeeks=!0:null!=c?p(t)._overflowWeekday=!0:(s=Lt(n,r,i,a,o),t._a[0]=s.year,t._dayOfYear=s.dayOfYear);}(t),null!=t._dayOfYear&&(o=ae(t._a[0],r[0]),(t._dayOfYear>yt(o)||0===t._dayOfYear)&&(p(t)._overflowDayOfYear=!0),n=Dt(o,0,t._dayOfYear),t._a[1]=n.getUTCMonth(),t._a[2]=n.getUTCDate()),e=0;e<3&&null==t._a[e];++e)t._a[e]=s[e]=r[e];for(;e<7;e++)t._a[e]=s[e]=null==t._a[e]?2===e?1:0:t._a[e];24===t._a[3]&&0===t._a[4]&&0===t._a[5]&&0===t._a[6]&&(t._nextDay=!0,t._a[3]=0),t._d=(t._useUTC?Dt:function(t,e,n,r,i,a,o){var s;return t<100&&0<=t?(s=new Date(t+400,e,n,r,i,a,o),isFinite(s.getFullYear())&&s.setFullYear(t)):s=new Date(t,e,n,r,i,a,o),s}).apply(null,s),a=t._useUTC?t._d.getUTCDay():t._d.getDay(),null!=t._tzm&&t._d.setUTCMinutes(t._d.getUTCMinutes()-t._tzm),t._nextDay&&(t._a[3]=24),t._w&&void 0!==t._w.d&&t._w.d!==a&&(p(t).weekdayMismatch=!0);}}var se=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,ce=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,le=/Z|[+-]\d\d(?::?\d\d)?/,ue=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/]],he=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],fe=/^\/?Date\((\-?\d+)/i;function de(t){var e,n,r,i,a,o,s=t._i,c=se.exec(s)||ce.exec(s);if(c){for(p(t).iso=!0,e=0,n=ue.length;e<n;e++)if(ue[e][1].exec(c[1])){i=ue[e][0],r=!1!==ue[e][2];break}if(null==i)return void(t._isValid=!1);if(c[3]){for(e=0,n=he.length;e<n;e++)if(he[e][1].exec(c[3])){a=(c[2]||" ")+he[e][0];break}if(null==a)return void(t._isValid=!1)}if(!r&&null!=a)return void(t._isValid=!1);if(c[4]){if(!le.exec(c[4]))return void(t._isValid=!1);o="Z";}t._f=i+(a||"")+(o||""),me(t);}else t._isValid=!1;}var pe=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/;var ge={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function ye(t){var e,n,r,i=pe.exec(t._i.replace(/\([^)]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").replace(/^\s\s*/,"").replace(/\s\s*$/,""));if(i){var a=function(t,e,n,r,i,a){var o=[function(t){var e=parseInt(t,10);return e<=49?2e3+e:e<=999?1900+e:e}(t),Ct.indexOf(e),parseInt(n,10),parseInt(r,10),parseInt(i,10)];return a&&o.push(parseInt(a,10)),o}(i[4],i[3],i[2],i[5],i[6],i[7]);if(n=a,r=t,(e=i[1])&&jt.indexOf(e)!==new Date(n[0],n[1],n[2]).getDay()&&(p(r).weekdayMismatch=!0,!(r._isValid=!1)))return;t._a=a,t._tzm=function(t,e,n){if(t)return ge[t];if(e)return 0;var r=parseInt(n,10),i=r%100;return (r-i)/100*60+i}(i[8],i[9],i[10]),t._d=Dt.apply(null,t._a),t._d.setUTCMinutes(t._d.getUTCMinutes()-t._tzm),p(t).rfc2822=!0;}else t._isValid=!1;}function me(t){if(t._f!==i.ISO_8601)if(t._f!==i.RFC_2822){t._a=[],p(t).empty=!0;var e,n,r,a,o,s,c,l,u=""+t._i,f=u.length,d=0;for(r=H(t._f,t._locale).match(z)||[],e=0;e<r.length;e++)a=r[e],(n=(u.match(ht(a,t))||[])[0])&&(0<(o=u.substr(0,u.indexOf(n))).length&&p(t).unusedInput.push(o),u=u.slice(u.indexOf(n)+n.length),d+=n.length),$[a]?(n?p(t).empty=!1:p(t).unusedTokens.push(a),s=a,l=t,null!=(c=n)&&h(dt,s)&&dt[s](c,l._a,l,s)):t._strict&&!n&&p(t).unusedTokens.push(a);p(t).charsLeftOver=f-d,0<u.length&&p(t).unusedInput.push(u),t._a[3]<=12&&!0===p(t).bigHour&&0<t._a[3]&&(p(t).bigHour=void 0),p(t).parsedDateParts=t._a.slice(0),p(t).meridiem=t._meridiem,t._a[3]=function(t,e,n){var r;return null==n?e:null!=t.meridiemHour?t.meridiemHour(e,n):(null!=t.isPM&&((r=t.isPM(n))&&e<12&&(e+=12),r||12!==e||(e=0)),e)}(t._locale,t._a[3],t._meridiem),oe(t),ie(t);}else ye(t);else de(t);}function be(t){var e,n,r,h,d=t._i,m=t._f;return t._locale=t._locale||re(t._l),null===d||void 0===m&&""===d?y({nullInput:!0}):("string"==typeof d&&(t._i=d=t._locale.preparse(d)),x(d)?new _(ie(d)):(l(d)?t._d=d:a(m)?function(t){var e,n,r,i,a;if(0===t._f.length)return p(t).invalidFormat=!0,t._d=new Date(NaN);for(i=0;i<t._f.length;i++)a=0,e=b({},t),null!=t._useUTC&&(e._useUTC=t._useUTC),e._f=t._f[i],me(e),g(e)&&(a+=p(e).charsLeftOver,a+=10*p(e).unusedTokens.length,p(e).score=a,(null==r||a<r)&&(r=a,n=e));f(t,n||e);}(t):m?me(t):s(n=(e=t)._i)?e._d=new Date(i.now()):l(n)?e._d=new Date(n.valueOf()):"string"==typeof n?(r=e,null===(h=fe.exec(r._i))?(de(r),!1===r._isValid&&(delete r._isValid,ye(r),!1===r._isValid&&(delete r._isValid,i.createFromInputFallback(r)))):r._d=new Date(+h[1])):a(n)?(e._a=u(n.slice(0),(function(t){return parseInt(t,10)})),oe(e)):o(n)?function(t){if(!t._d){var e=F(t._i);t._a=u([e.year,e.month,e.day||e.date,e.hour,e.minute,e.second,e.millisecond],(function(t){return t&&parseInt(t,10)})),oe(t);}}(e):c(n)?e._d=new Date(n):i.createFromInputFallback(e),g(t)||(t._d=null),t))}function ve(t,e,n,r,i){var s,c={};return !0!==n&&!1!==n||(r=n,n=void 0),(o(t)&&function(t){if(Object.getOwnPropertyNames)return 0===Object.getOwnPropertyNames(t).length;var e;for(e in t)if(t.hasOwnProperty(e))return !1;return !0}(t)||a(t)&&0===t.length)&&(t=void 0),c._isAMomentObject=!0,c._useUTC=c._isUTC=i,c._l=n,c._i=t,c._f=e,c._strict=r,(s=new _(ie(be(c))))._nextDay&&(s.add(1,"d"),s._nextDay=void 0),s}function _e(t,e,n,r){return ve(t,e,n,r,!1)}i.createFromInputFallback=C("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",(function(t){t._d=new Date(t._i+(t._useUTC?" UTC":""));})),i.ISO_8601=function(){},i.RFC_2822=function(){};var xe=C("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",(function(){var t=_e.apply(null,arguments);return this.isValid()&&t.isValid()?t<this?this:t:y()})),ke=C("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/",(function(){var t=_e.apply(null,arguments);return this.isValid()&&t.isValid()?this<t?this:t:y()}));function we(t,e){var n,r;if(1===e.length&&a(e[0])&&(e=e[0]),!e.length)return _e();for(n=e[0],r=1;r<e.length;++r)e[r].isValid()&&!e[r][t](n)||(n=e[r]);return n}var Te=["year","quarter","month","week","day","hour","minute","second","millisecond"];function Ee(t){var e=F(t),n=e.year||0,r=e.quarter||0,i=e.month||0,a=e.week||e.isoWeek||0,o=e.day||0,s=e.hour||0,c=e.minute||0,l=e.second||0,u=e.millisecond||0;this._isValid=function(t){for(var e in t)if(-1===bt.call(Te,e)||null!=t[e]&&isNaN(t[e]))return !1;for(var n=!1,r=0;r<Te.length;++r)if(t[Te[r]]){if(n)return !1;parseFloat(t[Te[r]])!==w(t[Te[r]])&&(n=!0);}return !0}(e),this._milliseconds=+u+1e3*l+6e4*c+1e3*s*60*60,this._days=+o+7*a,this._months=+i+3*r+12*n,this._data={},this._locale=re(),this._bubble();}function Ce(t){return t instanceof Ee}function Se(t){return t<0?-1*Math.round(-1*t):Math.round(t)}function Ae(t,e){W(t,0,0,(function(){var t=this.utcOffset(),n="+";return t<0&&(t=-t,n="-"),n+j(~~(t/60),2)+e+j(~~t%60,2)}));}Ae("Z",":"),Ae("ZZ",""),ut("Z",st),ut("ZZ",st),pt(["Z","ZZ"],(function(t,e,n){n._useUTC=!0,n._tzm=Ne(st,t);}));var Me=/([\+\-]|\d\d)/gi;function Ne(t,e){var n=(e||"").match(t);if(null===n)return null;var r=((n[n.length-1]||[])+"").match(Me)||["-",0,0],i=60*r[1]+w(r[2]);return 0===i?0:"+"===r[0]?i:-i}function Oe(t,e){var n,r;return e._isUTC?(n=e.clone(),r=(x(t)||l(t)?t.valueOf():_e(t).valueOf())-n.valueOf(),n._d.setTime(n._d.valueOf()+r),i.updateOffset(n,!1),n):_e(t).local()}function De(t){return 15*-Math.round(t._d.getTimezoneOffset()/15)}function Be(){return !!this.isValid()&&this._isUTC&&0===this._offset}i.updateOffset=function(){};var Le=/^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/,Ie=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function Fe(t,e){var n,r,i,a=t,o=null;return Ce(t)?a={ms:t._milliseconds,d:t._days,M:t._months}:c(t)?(a={},e?a[e]=t:a.milliseconds=t):(o=Le.exec(t))?(n="-"===o[1]?-1:1,a={y:0,d:w(o[2])*n,h:w(o[3])*n,m:w(o[4])*n,s:w(o[5])*n,ms:w(Se(1e3*o[6]))*n}):(o=Ie.exec(t))?(n="-"===o[1]?-1:1,a={y:Re(o[2],n),M:Re(o[3],n),w:Re(o[4],n),d:Re(o[5],n),h:Re(o[6],n),m:Re(o[7],n),s:Re(o[8],n)}):null==a?a={}:"object"==typeof a&&("from"in a||"to"in a)&&(i=function(t,e){var n;return t.isValid()&&e.isValid()?(e=Oe(e,t),t.isBefore(e)?n=Pe(t,e):((n=Pe(e,t)).milliseconds=-n.milliseconds,n.months=-n.months),n):{milliseconds:0,months:0}}(_e(a.from),_e(a.to)),(a={}).ms=i.milliseconds,a.M=i.months),r=new Ee(a),Ce(t)&&h(t,"_locale")&&(r._locale=t._locale),r}function Re(t,e){var n=t&&parseFloat(t.replace(",","."));return (isNaN(n)?0:n)*e}function Pe(t,e){var n={};return n.months=e.month()-t.month()+12*(e.year()-t.year()),t.clone().add(n.months,"M").isAfter(e)&&--n.months,n.milliseconds=+e-+t.clone().add(n.months,"M"),n}function je(t,e){return function(n,r){var i;return null===r||isNaN(+r)||(M(e,"moment()."+e+"(period, number) is deprecated. Please use moment()."+e+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),i=n,n=r,r=i),ze(this,Fe(n="string"==typeof n?+n:n,r),t),this}}function ze(t,e,n,r){var a=e._milliseconds,o=Se(e._days),s=Se(e._months);t.isValid()&&(r=null==r||r,s&&St(t,xt(t,"Month")+s*n),o&&kt(t,"Date",xt(t,"Date")+o*n),a&&t._d.setTime(t._d.valueOf()+a*n),r&&i.updateOffset(t,o||s));}Fe.fn=Ee.prototype,Fe.invalid=function(){return Fe(NaN)};var Ye=je(1,"add"),Ue=je(-1,"subtract");function $e(t,e){var n=12*(e.year()-t.year())+(e.month()-t.month()),r=t.clone().add(n,"months");return -(n+(e-r<0?(e-r)/(r-t.clone().add(n-1,"months")):(e-r)/(t.clone().add(n+1,"months")-r)))||0}function We(t){var e;return void 0===t?this._locale._abbr:(null!=(e=re(t))&&(this._locale=e),this)}i.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",i.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";var qe=C("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",(function(t){return void 0===t?this.localeData():this.locale(t)}));function He(){return this._locale}var Ve=126227808e5;function Ge(t,e){return (t%e+e)%e}function Xe(t,e,n){return t<100&&0<=t?new Date(t+400,e,n)-Ve:new Date(t,e,n).valueOf()}function Ze(t,e,n){return t<100&&0<=t?Date.UTC(t+400,e,n)-Ve:Date.UTC(t,e,n)}function Qe(t,e){W(0,[t,t.length],0,e);}function Ke(t,e,n,r,i){var a;return null==t?It(this,r,i).year:((a=Ft(t,r,i))<e&&(e=a),function(t,e,n,r,i){var a=Lt(t,e,n,r,i),o=Dt(a.year,0,a.dayOfYear);return this.year(o.getUTCFullYear()),this.month(o.getUTCMonth()),this.date(o.getUTCDate()),this}.call(this,t,e,n,r,i))}W(0,["gg",2],0,(function(){return this.weekYear()%100})),W(0,["GG",2],0,(function(){return this.isoWeekYear()%100})),Qe("gggg","weekYear"),Qe("ggggg","weekYear"),Qe("GGGG","isoWeekYear"),Qe("GGGGG","isoWeekYear"),L("weekYear","gg"),L("isoWeekYear","GG"),P("weekYear",1),P("isoWeekYear",1),ut("G",at),ut("g",at),ut("GG",K,G),ut("gg",K,G),ut("GGGG",nt,Z),ut("gggg",nt,Z),ut("GGGGG",rt,Q),ut("ggggg",rt,Q),gt(["gggg","ggggg","GGGG","GGGGG"],(function(t,e,n,r){e[r.substr(0,2)]=w(t);})),gt(["gg","GG"],(function(t,e,n,r){e[r]=i.parseTwoDigitYear(t);})),W("Q",0,"Qo","quarter"),L("quarter","Q"),P("quarter",7),ut("Q",V),pt("Q",(function(t,e){e[1]=3*(w(t)-1);})),W("D",["DD",2],"Do","date"),L("date","D"),P("date",9),ut("D",K),ut("DD",K,G),ut("Do",(function(t,e){return t?e._dayOfMonthOrdinalParse||e._ordinalParse:e._dayOfMonthOrdinalParseLenient})),pt(["D","DD"],2),pt("Do",(function(t,e){e[2]=w(t.match(K)[0]);}));var Je=_t("Date",!0);W("DDD",["DDDD",3],"DDDo","dayOfYear"),L("dayOfYear","DDD"),P("dayOfYear",4),ut("DDD",et),ut("DDDD",X),pt(["DDD","DDDD"],(function(t,e,n){n._dayOfYear=w(t);})),W("m",["mm",2],0,"minute"),L("minute","m"),P("minute",14),ut("m",K),ut("mm",K,G),pt(["m","mm"],4);var tn=_t("Minutes",!1);W("s",["ss",2],0,"second"),L("second","s"),P("second",15),ut("s",K),ut("ss",K,G),pt(["s","ss"],5);var en,nn=_t("Seconds",!1);for(W("S",0,0,(function(){return ~~(this.millisecond()/100)})),W(0,["SS",2],0,(function(){return ~~(this.millisecond()/10)})),W(0,["SSS",3],0,"millisecond"),W(0,["SSSS",4],0,(function(){return 10*this.millisecond()})),W(0,["SSSSS",5],0,(function(){return 100*this.millisecond()})),W(0,["SSSSSS",6],0,(function(){return 1e3*this.millisecond()})),W(0,["SSSSSSS",7],0,(function(){return 1e4*this.millisecond()})),W(0,["SSSSSSSS",8],0,(function(){return 1e5*this.millisecond()})),W(0,["SSSSSSSSS",9],0,(function(){return 1e6*this.millisecond()})),L("millisecond","ms"),P("millisecond",16),ut("S",et,V),ut("SS",et,G),ut("SSS",et,X),en="SSSS";en.length<=9;en+="S")ut(en,it);function rn(t,e){e[6]=w(1e3*("0."+t));}for(en="S";en.length<=9;en+="S")pt(en,rn);var an=_t("Milliseconds",!1);W("z",0,0,"zoneAbbr"),W("zz",0,0,"zoneName");var on=_.prototype;function sn(t){return t}on.add=Ye,on.calendar=function(t,e){var n=t||_e(),r=Oe(n,this).startOf("day"),a=i.calendarFormat(this,r)||"sameElse",o=e&&(N(e[a])?e[a].call(this,n):e[a]);return this.format(o||this.localeData().calendar(a,this,_e(n)))},on.clone=function(){return new _(this)},on.diff=function(t,e,n){var r,i,a;if(!this.isValid())return NaN;if(!(r=Oe(t,this)).isValid())return NaN;switch(i=6e4*(r.utcOffset()-this.utcOffset()),e=I(e)){case"year":a=$e(this,r)/12;break;case"month":a=$e(this,r);break;case"quarter":a=$e(this,r)/3;break;case"second":a=(this-r)/1e3;break;case"minute":a=(this-r)/6e4;break;case"hour":a=(this-r)/36e5;break;case"day":a=(this-r-i)/864e5;break;case"week":a=(this-r-i)/6048e5;break;default:a=this-r;}return n?a:k(a)},on.endOf=function(t){var e;if(void 0===(t=I(t))||"millisecond"===t||!this.isValid())return this;var n=this._isUTC?Ze:Xe;switch(t){case"year":e=n(this.year()+1,0,1)-1;break;case"quarter":e=n(this.year(),this.month()-this.month()%3+3,1)-1;break;case"month":e=n(this.year(),this.month()+1,1)-1;break;case"week":e=n(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case"isoWeek":e=n(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case"day":case"date":e=n(this.year(),this.month(),this.date()+1)-1;break;case"hour":e=this._d.valueOf(),e+=36e5-Ge(e+(this._isUTC?0:6e4*this.utcOffset()),36e5)-1;break;case"minute":e=this._d.valueOf(),e+=6e4-Ge(e,6e4)-1;break;case"second":e=this._d.valueOf(),e+=1e3-Ge(e,1e3)-1;}return this._d.setTime(e),i.updateOffset(this,!0),this},on.format=function(t){t||(t=this.isUtc()?i.defaultFormatUtc:i.defaultFormat);var e=q(this,t);return this.localeData().postformat(e)},on.from=function(t,e){return this.isValid()&&(x(t)&&t.isValid()||_e(t).isValid())?Fe({to:this,from:t}).locale(this.locale()).humanize(!e):this.localeData().invalidDate()},on.fromNow=function(t){return this.from(_e(),t)},on.to=function(t,e){return this.isValid()&&(x(t)&&t.isValid()||_e(t).isValid())?Fe({from:this,to:t}).locale(this.locale()).humanize(!e):this.localeData().invalidDate()},on.toNow=function(t){return this.to(_e(),t)},on.get=function(t){return N(this[t=I(t)])?this[t]():this},on.invalidAt=function(){return p(this).overflow},on.isAfter=function(t,e){var n=x(t)?t:_e(t);return !(!this.isValid()||!n.isValid())&&("millisecond"===(e=I(e)||"millisecond")?this.valueOf()>n.valueOf():n.valueOf()<this.clone().startOf(e).valueOf())},on.isBefore=function(t,e){var n=x(t)?t:_e(t);return !(!this.isValid()||!n.isValid())&&("millisecond"===(e=I(e)||"millisecond")?this.valueOf()<n.valueOf():this.clone().endOf(e).valueOf()<n.valueOf())},on.isBetween=function(t,e,n,r){var i=x(t)?t:_e(t),a=x(e)?e:_e(e);return !!(this.isValid()&&i.isValid()&&a.isValid())&&("("===(r=r||"()")[0]?this.isAfter(i,n):!this.isBefore(i,n))&&(")"===r[1]?this.isBefore(a,n):!this.isAfter(a,n))},on.isSame=function(t,e){var n,r=x(t)?t:_e(t);return !(!this.isValid()||!r.isValid())&&("millisecond"===(e=I(e)||"millisecond")?this.valueOf()===r.valueOf():(n=r.valueOf(),this.clone().startOf(e).valueOf()<=n&&n<=this.clone().endOf(e).valueOf()))},on.isSameOrAfter=function(t,e){return this.isSame(t,e)||this.isAfter(t,e)},on.isSameOrBefore=function(t,e){return this.isSame(t,e)||this.isBefore(t,e)},on.isValid=function(){return g(this)},on.lang=qe,on.locale=We,on.localeData=He,on.max=ke,on.min=xe,on.parsingFlags=function(){return f({},p(this))},on.set=function(t,e){if("object"==typeof t)for(var n=function(t){var e=[];for(var n in t)e.push({unit:n,priority:R[n]});return e.sort((function(t,e){return t.priority-e.priority})),e}(t=F(t)),r=0;r<n.length;r++)this[n[r].unit](t[n[r].unit]);else if(N(this[t=I(t)]))return this[t](e);return this},on.startOf=function(t){var e;if(void 0===(t=I(t))||"millisecond"===t||!this.isValid())return this;var n=this._isUTC?Ze:Xe;switch(t){case"year":e=n(this.year(),0,1);break;case"quarter":e=n(this.year(),this.month()-this.month()%3,1);break;case"month":e=n(this.year(),this.month(),1);break;case"week":e=n(this.year(),this.month(),this.date()-this.weekday());break;case"isoWeek":e=n(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case"day":case"date":e=n(this.year(),this.month(),this.date());break;case"hour":e=this._d.valueOf(),e-=Ge(e+(this._isUTC?0:6e4*this.utcOffset()),36e5);break;case"minute":e=this._d.valueOf(),e-=Ge(e,6e4);break;case"second":e=this._d.valueOf(),e-=Ge(e,1e3);}return this._d.setTime(e),i.updateOffset(this,!0),this},on.subtract=Ue,on.toArray=function(){var t=this;return [t.year(),t.month(),t.date(),t.hour(),t.minute(),t.second(),t.millisecond()]},on.toObject=function(){var t=this;return {years:t.year(),months:t.month(),date:t.date(),hours:t.hours(),minutes:t.minutes(),seconds:t.seconds(),milliseconds:t.milliseconds()}},on.toDate=function(){return new Date(this.valueOf())},on.toISOString=function(t){if(!this.isValid())return null;var e=!0!==t,n=e?this.clone().utc():this;return n.year()<0||9999<n.year()?q(n,e?"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYYYY-MM-DD[T]HH:mm:ss.SSSZ"):N(Date.prototype.toISOString)?e?this.toDate().toISOString():new Date(this.valueOf()+60*this.utcOffset()*1e3).toISOString().replace("Z",q(n,"Z")):q(n,e?"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYY-MM-DD[T]HH:mm:ss.SSSZ")},on.inspect=function(){if(!this.isValid())return "moment.invalid(/* "+this._i+" */)";var t="moment",e="";this.isLocal()||(t=0===this.utcOffset()?"moment.utc":"moment.parseZone",e="Z");var n="["+t+'("]',r=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",i=e+'[")]';return this.format(n+r+"-MM-DD[T]HH:mm:ss.SSS"+i)},on.toJSON=function(){return this.isValid()?this.toISOString():null},on.toString=function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},on.unix=function(){return Math.floor(this.valueOf()/1e3)},on.valueOf=function(){return this._d.valueOf()-6e4*(this._offset||0)},on.creationData=function(){return {input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}},on.year=vt,on.isLeapYear=function(){return mt(this.year())},on.weekYear=function(t){return Ke.call(this,t,this.week(),this.weekday(),this.localeData()._week.dow,this.localeData()._week.doy)},on.isoWeekYear=function(t){return Ke.call(this,t,this.isoWeek(),this.isoWeekday(),1,4)},on.quarter=on.quarters=function(t){return null==t?Math.ceil((this.month()+1)/3):this.month(3*(t-1)+this.month()%3)},on.month=At,on.daysInMonth=function(){return wt(this.year(),this.month())},on.week=on.weeks=function(t){var e=this.localeData().week(this);return null==t?e:this.add(7*(t-e),"d")},on.isoWeek=on.isoWeeks=function(t){var e=It(this,1,4).week;return null==t?e:this.add(7*(t-e),"d")},on.weeksInYear=function(){var t=this.localeData()._week;return Ft(this.year(),t.dow,t.doy)},on.isoWeeksInYear=function(){return Ft(this.year(),1,4)},on.date=Je,on.day=on.days=function(t){if(!this.isValid())return null!=t?this:NaN;var e,n,r=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=t?(e=t,n=this.localeData(),t="string"!=typeof e?e:isNaN(e)?"number"==typeof(e=n.weekdaysParse(e))?e:null:parseInt(e,10),this.add(t-r,"d")):r},on.weekday=function(t){if(!this.isValid())return null!=t?this:NaN;var e=(this.day()+7-this.localeData()._week.dow)%7;return null==t?e:this.add(t-e,"d")},on.isoWeekday=function(t){if(!this.isValid())return null!=t?this:NaN;if(null==t)return this.day()||7;var e,n,r=(e=t,n=this.localeData(),"string"==typeof e?n.weekdaysParse(e)%7||7:isNaN(e)?null:e);return this.day(this.day()%7?r:r-7)},on.dayOfYear=function(t){var e=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==t?e:this.add(t-e,"d")},on.hour=on.hours=Xt,on.minute=on.minutes=tn,on.second=on.seconds=nn,on.millisecond=on.milliseconds=an,on.utcOffset=function(t,e,n){var r,a=this._offset||0;if(!this.isValid())return null!=t?this:NaN;if(null==t)return this._isUTC?a:De(this);if("string"==typeof t){if(null===(t=Ne(st,t)))return this}else Math.abs(t)<16&&!n&&(t*=60);return !this._isUTC&&e&&(r=De(this)),this._offset=t,this._isUTC=!0,null!=r&&this.add(r,"m"),a!==t&&(!e||this._changeInProgress?ze(this,Fe(t-a,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,i.updateOffset(this,!0),this._changeInProgress=null)),this},on.utc=function(t){return this.utcOffset(0,t)},on.local=function(t){return this._isUTC&&(this.utcOffset(0,t),this._isUTC=!1,t&&this.subtract(De(this),"m")),this},on.parseZone=function(){if(null!=this._tzm)this.utcOffset(this._tzm,!1,!0);else if("string"==typeof this._i){var t=Ne(ot,this._i);null!=t?this.utcOffset(t):this.utcOffset(0,!0);}return this},on.hasAlignedHourOffset=function(t){return !!this.isValid()&&(t=t?_e(t).utcOffset():0,(this.utcOffset()-t)%60==0)},on.isDST=function(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()},on.isLocal=function(){return !!this.isValid()&&!this._isUTC},on.isUtcOffset=function(){return !!this.isValid()&&this._isUTC},on.isUtc=Be,on.isUTC=Be,on.zoneAbbr=function(){return this._isUTC?"UTC":""},on.zoneName=function(){return this._isUTC?"Coordinated Universal Time":""},on.dates=C("dates accessor is deprecated. Use date instead.",Je),on.months=C("months accessor is deprecated. Use month instead",At),on.years=C("years accessor is deprecated. Use year instead",vt),on.zone=C("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",(function(t,e){return null!=t?("string"!=typeof t&&(t=-t),this.utcOffset(t,e),this):-this.utcOffset()})),on.isDSTShifted=C("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",(function(){if(!s(this._isDSTShifted))return this._isDSTShifted;var t={};if(b(t,this),(t=be(t))._a){var e=t._isUTC?d(t._a):_e(t._a);this._isDSTShifted=this.isValid()&&0<T(t._a,e.toArray());}else this._isDSTShifted=!1;return this._isDSTShifted}));var cn=D.prototype;function ln(t,e,n,r){var i=re(),a=d().set(r,e);return i[n](a,t)}function un(t,e,n){if(c(t)&&(e=t,t=void 0),t=t||"",null!=e)return ln(t,e,n,"month");var r,i=[];for(r=0;r<12;r++)i[r]=ln(t,r,n,"month");return i}function hn(t,e,n,r){"boolean"==typeof t?c(e)&&(n=e,e=void 0):(e=t,t=!1,c(n=e)&&(n=e,e=void 0)),e=e||"";var i,a=re(),o=t?a._week.dow:0;if(null!=n)return ln(e,(n+o)%7,r,"day");var s=[];for(i=0;i<7;i++)s[i]=ln(e,(i+o)%7,r,"day");return s}cn.calendar=function(t,e,n){var r=this._calendar[t]||this._calendar.sameElse;return N(r)?r.call(e,n):r},cn.longDateFormat=function(t){var e=this._longDateFormat[t],n=this._longDateFormat[t.toUpperCase()];return e||!n?e:(this._longDateFormat[t]=n.replace(/MMMM|MM|DD|dddd/g,(function(t){return t.slice(1)})),this._longDateFormat[t])},cn.invalidDate=function(){return this._invalidDate},cn.ordinal=function(t){return this._ordinal.replace("%d",t)},cn.preparse=sn,cn.postformat=sn,cn.relativeTime=function(t,e,n,r){var i=this._relativeTime[n];return N(i)?i(t,e,n,r):i.replace(/%d/i,t)},cn.pastFuture=function(t,e){var n=this._relativeTime[0<t?"future":"past"];return N(n)?n(e):n.replace(/%s/i,e)},cn.set=function(t){var e,n;for(n in t)N(e=t[n])?this[n]=e:this["_"+n]=e;this._config=t,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source);},cn.months=function(t,e){return t?a(this._months)?this._months[t.month()]:this._months[(this._months.isFormat||Tt).test(e)?"format":"standalone"][t.month()]:a(this._months)?this._months:this._months.standalone},cn.monthsShort=function(t,e){return t?a(this._monthsShort)?this._monthsShort[t.month()]:this._monthsShort[Tt.test(e)?"format":"standalone"][t.month()]:a(this._monthsShort)?this._monthsShort:this._monthsShort.standalone},cn.monthsParse=function(t,e,n){var r,i,a;if(this._monthsParseExact)return function(t,e,n){var r,i,a,o=t.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],r=0;r<12;++r)a=d([2e3,r]),this._shortMonthsParse[r]=this.monthsShort(a,"").toLocaleLowerCase(),this._longMonthsParse[r]=this.months(a,"").toLocaleLowerCase();return n?"MMM"===e?-1!==(i=bt.call(this._shortMonthsParse,o))?i:null:-1!==(i=bt.call(this._longMonthsParse,o))?i:null:"MMM"===e?-1!==(i=bt.call(this._shortMonthsParse,o))||-1!==(i=bt.call(this._longMonthsParse,o))?i:null:-1!==(i=bt.call(this._longMonthsParse,o))||-1!==(i=bt.call(this._shortMonthsParse,o))?i:null}.call(this,t,e,n);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),r=0;r<12;r++){if(i=d([2e3,r]),n&&!this._longMonthsParse[r]&&(this._longMonthsParse[r]=new RegExp("^"+this.months(i,"").replace(".","")+"$","i"),this._shortMonthsParse[r]=new RegExp("^"+this.monthsShort(i,"").replace(".","")+"$","i")),n||this._monthsParse[r]||(a="^"+this.months(i,"")+"|^"+this.monthsShort(i,""),this._monthsParse[r]=new RegExp(a.replace(".",""),"i")),n&&"MMMM"===e&&this._longMonthsParse[r].test(t))return r;if(n&&"MMM"===e&&this._shortMonthsParse[r].test(t))return r;if(!n&&this._monthsParse[r].test(t))return r}},cn.monthsRegex=function(t){return this._monthsParseExact?(h(this,"_monthsRegex")||Ot.call(this),t?this._monthsStrictRegex:this._monthsRegex):(h(this,"_monthsRegex")||(this._monthsRegex=Nt),this._monthsStrictRegex&&t?this._monthsStrictRegex:this._monthsRegex)},cn.monthsShortRegex=function(t){return this._monthsParseExact?(h(this,"_monthsRegex")||Ot.call(this),t?this._monthsShortStrictRegex:this._monthsShortRegex):(h(this,"_monthsShortRegex")||(this._monthsShortRegex=Mt),this._monthsShortStrictRegex&&t?this._monthsShortStrictRegex:this._monthsShortRegex)},cn.week=function(t){return It(t,this._week.dow,this._week.doy).week},cn.firstDayOfYear=function(){return this._week.doy},cn.firstDayOfWeek=function(){return this._week.dow},cn.weekdays=function(t,e){var n=a(this._weekdays)?this._weekdays:this._weekdays[t&&!0!==t&&this._weekdays.isFormat.test(e)?"format":"standalone"];return !0===t?Rt(n,this._week.dow):t?n[t.day()]:n},cn.weekdaysMin=function(t){return !0===t?Rt(this._weekdaysMin,this._week.dow):t?this._weekdaysMin[t.day()]:this._weekdaysMin},cn.weekdaysShort=function(t){return !0===t?Rt(this._weekdaysShort,this._week.dow):t?this._weekdaysShort[t.day()]:this._weekdaysShort},cn.weekdaysParse=function(t,e,n){var r,i,a;if(this._weekdaysParseExact)return function(t,e,n){var r,i,a,o=t.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],r=0;r<7;++r)a=d([2e3,1]).day(r),this._minWeekdaysParse[r]=this.weekdaysMin(a,"").toLocaleLowerCase(),this._shortWeekdaysParse[r]=this.weekdaysShort(a,"").toLocaleLowerCase(),this._weekdaysParse[r]=this.weekdays(a,"").toLocaleLowerCase();return n?"dddd"===e?-1!==(i=bt.call(this._weekdaysParse,o))?i:null:"ddd"===e?-1!==(i=bt.call(this._shortWeekdaysParse,o))?i:null:-1!==(i=bt.call(this._minWeekdaysParse,o))?i:null:"dddd"===e?-1!==(i=bt.call(this._weekdaysParse,o))||-1!==(i=bt.call(this._shortWeekdaysParse,o))||-1!==(i=bt.call(this._minWeekdaysParse,o))?i:null:"ddd"===e?-1!==(i=bt.call(this._shortWeekdaysParse,o))||-1!==(i=bt.call(this._weekdaysParse,o))||-1!==(i=bt.call(this._minWeekdaysParse,o))?i:null:-1!==(i=bt.call(this._minWeekdaysParse,o))||-1!==(i=bt.call(this._weekdaysParse,o))||-1!==(i=bt.call(this._shortWeekdaysParse,o))?i:null}.call(this,t,e,n);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),r=0;r<7;r++){if(i=d([2e3,1]).day(r),n&&!this._fullWeekdaysParse[r]&&(this._fullWeekdaysParse[r]=new RegExp("^"+this.weekdays(i,"").replace(".","\\.?")+"$","i"),this._shortWeekdaysParse[r]=new RegExp("^"+this.weekdaysShort(i,"").replace(".","\\.?")+"$","i"),this._minWeekdaysParse[r]=new RegExp("^"+this.weekdaysMin(i,"").replace(".","\\.?")+"$","i")),this._weekdaysParse[r]||(a="^"+this.weekdays(i,"")+"|^"+this.weekdaysShort(i,"")+"|^"+this.weekdaysMin(i,""),this._weekdaysParse[r]=new RegExp(a.replace(".",""),"i")),n&&"dddd"===e&&this._fullWeekdaysParse[r].test(t))return r;if(n&&"ddd"===e&&this._shortWeekdaysParse[r].test(t))return r;if(n&&"dd"===e&&this._minWeekdaysParse[r].test(t))return r;if(!n&&this._weekdaysParse[r].test(t))return r}},cn.weekdaysRegex=function(t){return this._weekdaysParseExact?(h(this,"_weekdaysRegex")||Wt.call(this),t?this._weekdaysStrictRegex:this._weekdaysRegex):(h(this,"_weekdaysRegex")||(this._weekdaysRegex=Yt),this._weekdaysStrictRegex&&t?this._weekdaysStrictRegex:this._weekdaysRegex)},cn.weekdaysShortRegex=function(t){return this._weekdaysParseExact?(h(this,"_weekdaysRegex")||Wt.call(this),t?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(h(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=Ut),this._weekdaysShortStrictRegex&&t?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)},cn.weekdaysMinRegex=function(t){return this._weekdaysParseExact?(h(this,"_weekdaysRegex")||Wt.call(this),t?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(h(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=$t),this._weekdaysMinStrictRegex&&t?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)},cn.isPM=function(t){return "p"===(t+"").toLowerCase().charAt(0)},cn.meridiem=function(t,e,n){return 11<t?n?"pm":"PM":n?"am":"AM"},ee("en",{dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(t){var e=t%10;return t+(1===w(t%100/10)?"th":1===e?"st":2===e?"nd":3===e?"rd":"th")}}),i.lang=C("moment.lang is deprecated. Use moment.locale instead.",ee),i.langData=C("moment.langData is deprecated. Use moment.localeData instead.",re);var fn=Math.abs;function dn(t,e,n,r){var i=Fe(e,n);return t._milliseconds+=r*i._milliseconds,t._days+=r*i._days,t._months+=r*i._months,t._bubble()}function pn(t){return t<0?Math.floor(t):Math.ceil(t)}function gn(t){return 4800*t/146097}function yn(t){return 146097*t/4800}function mn(t){return function(){return this.as(t)}}var bn=mn("ms"),vn=mn("s"),_n=mn("m"),xn=mn("h"),kn=mn("d"),wn=mn("w"),Tn=mn("M"),En=mn("Q"),Cn=mn("y");function Sn(t){return function(){return this.isValid()?this._data[t]:NaN}}var An=Sn("milliseconds"),Mn=Sn("seconds"),Nn=Sn("minutes"),On=Sn("hours"),Dn=Sn("days"),Bn=Sn("months"),Ln=Sn("years"),In=Math.round,Fn={ss:44,s:45,m:45,h:22,d:26,M:11},Rn=Math.abs;function Pn(t){return (0<t)-(t<0)||+t}function jn(){if(!this.isValid())return this.localeData().invalidDate();var t,e,n=Rn(this._milliseconds)/1e3,r=Rn(this._days),i=Rn(this._months);e=k((t=k(n/60))/60),n%=60,t%=60;var a=k(i/12),o=i%=12,s=r,c=e,l=t,u=n?n.toFixed(3).replace(/\.?0+$/,""):"",h=this.asSeconds();if(!h)return "P0D";var f=h<0?"-":"",d=Pn(this._months)!==Pn(h)?"-":"",p=Pn(this._days)!==Pn(h)?"-":"",g=Pn(this._milliseconds)!==Pn(h)?"-":"";return f+"P"+(a?d+a+"Y":"")+(o?d+o+"M":"")+(s?p+s+"D":"")+(c||l||u?"T":"")+(c?g+c+"H":"")+(l?g+l+"M":"")+(u?g+u+"S":"")}var zn=Ee.prototype;return zn.isValid=function(){return this._isValid},zn.abs=function(){var t=this._data;return this._milliseconds=fn(this._milliseconds),this._days=fn(this._days),this._months=fn(this._months),t.milliseconds=fn(t.milliseconds),t.seconds=fn(t.seconds),t.minutes=fn(t.minutes),t.hours=fn(t.hours),t.months=fn(t.months),t.years=fn(t.years),this},zn.add=function(t,e){return dn(this,t,e,1)},zn.subtract=function(t,e){return dn(this,t,e,-1)},zn.as=function(t){if(!this.isValid())return NaN;var e,n,r=this._milliseconds;if("month"===(t=I(t))||"quarter"===t||"year"===t)switch(e=this._days+r/864e5,n=this._months+gn(e),t){case"month":return n;case"quarter":return n/3;case"year":return n/12}else switch(e=this._days+Math.round(yn(this._months)),t){case"week":return e/7+r/6048e5;case"day":return e+r/864e5;case"hour":return 24*e+r/36e5;case"minute":return 1440*e+r/6e4;case"second":return 86400*e+r/1e3;case"millisecond":return Math.floor(864e5*e)+r;default:throw new Error("Unknown unit "+t)}},zn.asMilliseconds=bn,zn.asSeconds=vn,zn.asMinutes=_n,zn.asHours=xn,zn.asDays=kn,zn.asWeeks=wn,zn.asMonths=Tn,zn.asQuarters=En,zn.asYears=Cn,zn.valueOf=function(){return this.isValid()?this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*w(this._months/12):NaN},zn._bubble=function(){var t,e,n,r,i,a=this._milliseconds,o=this._days,s=this._months,c=this._data;return 0<=a&&0<=o&&0<=s||a<=0&&o<=0&&s<=0||(a+=864e5*pn(yn(s)+o),s=o=0),c.milliseconds=a%1e3,t=k(a/1e3),c.seconds=t%60,e=k(t/60),c.minutes=e%60,n=k(e/60),c.hours=n%24,s+=i=k(gn(o+=k(n/24))),o-=pn(yn(i)),r=k(s/12),s%=12,c.days=o,c.months=s,c.years=r,this},zn.clone=function(){return Fe(this)},zn.get=function(t){return t=I(t),this.isValid()?this[t+"s"]():NaN},zn.milliseconds=An,zn.seconds=Mn,zn.minutes=Nn,zn.hours=On,zn.days=Dn,zn.weeks=function(){return k(this.days()/7)},zn.months=Bn,zn.years=Ln,zn.humanize=function(t){if(!this.isValid())return this.localeData().invalidDate();var e,n,r,i,a,o,s,c,l,u,h=this.localeData(),f=(e=!t,n=h,r=Fe(this).abs(),i=In(r.as("s")),a=In(r.as("m")),o=In(r.as("h")),s=In(r.as("d")),c=In(r.as("M")),l=In(r.as("y")),(u=i<=Fn.ss&&["s",i]||i<Fn.s&&["ss",i]||a<=1&&["m"]||a<Fn.m&&["mm",a]||o<=1&&["h"]||o<Fn.h&&["hh",o]||s<=1&&["d"]||s<Fn.d&&["dd",s]||c<=1&&["M"]||c<Fn.M&&["MM",c]||l<=1&&["y"]||["yy",l])[2]=e,u[3]=0<+this,u[4]=n,function(t,e,n,r,i){return i.relativeTime(e||1,!!n,t,r)}.apply(null,u));return t&&(f=h.pastFuture(+this,f)),h.postformat(f)},zn.toISOString=jn,zn.toString=jn,zn.toJSON=jn,zn.locale=We,zn.localeData=He,zn.toIsoString=C("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",jn),zn.lang=qe,W("X",0,0,"unix"),W("x",0,0,"valueOf"),ut("x",at),ut("X",/[+-]?\d+(\.\d{1,3})?/),pt("X",(function(t,e,n){n._d=new Date(1e3*parseFloat(t,10));})),pt("x",(function(t,e,n){n._d=new Date(w(t));})),i.version="2.24.0",e=_e,i.fn=on,i.min=function(){return we("isBefore",[].slice.call(arguments,0))},i.max=function(){return we("isAfter",[].slice.call(arguments,0))},i.now=function(){return Date.now?Date.now():+new Date},i.utc=d,i.unix=function(t){return _e(1e3*t)},i.months=function(t,e){return un(t,e,"months")},i.isDate=l,i.locale=ee,i.invalid=y,i.duration=Fe,i.isMoment=x,i.weekdays=function(t,e,n){return hn(t,e,n,"weekdays")},i.parseZone=function(){return _e.apply(null,arguments).parseZone()},i.localeData=re,i.isDuration=Ce,i.monthsShort=function(t,e){return un(t,e,"monthsShort")},i.weekdaysMin=function(t,e,n){return hn(t,e,n,"weekdaysMin")},i.defineLocale=ne,i.updateLocale=function(t,e){if(null!=e){var n,r,i=Zt;null!=(r=te(t))&&(i=r._config),(n=new D(e=O(i,e))).parentLocale=Qt[t],Qt[t]=n,ee(t);}else null!=Qt[t]&&(null!=Qt[t].parentLocale?Qt[t]=Qt[t].parentLocale:null!=Qt[t]&&delete Qt[t]);return Qt[t]},i.locales=function(){return S(Qt)},i.weekdaysShort=function(t,e,n){return hn(t,e,n,"weekdaysShort")},i.normalizeUnits=I,i.relativeTimeRounding=function(t){return void 0===t?In:"function"==typeof t&&(In=t,!0)},i.relativeTimeThreshold=function(t,e){return void 0!==Fn[t]&&(void 0===e?Fn[t]:(Fn[t]=e,"s"===t&&(Fn.ss=e-1),!0))},i.calendarFormat=function(t,e){var n=t.diff(e,"days",!0);return n<-6?"sameElse":n<-1?"lastWeek":n<0?"lastDay":n<1?"sameDay":n<2?"nextDay":n<7?"nextWeek":"sameElse"},i.prototype=on,i.HTML5_FMT={DATETIME_LOCAL:"YYYY-MM-DDTHH:mm",DATETIME_LOCAL_SECONDS:"YYYY-MM-DDTHH:mm:ss",DATETIME_LOCAL_MS:"YYYY-MM-DDTHH:mm:ss.SSS",DATE:"YYYY-MM-DD",TIME:"HH:mm",TIME_SECONDS:"HH:mm:ss",TIME_MS:"HH:mm:ss.SSS",WEEK:"GGGG-[W]WW",MONTH:"YYYY-MM"},i}();},6470:t=>{function e(t){if("string"!=typeof t)throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}function n(t,e){for(var n,r="",i=0,a=-1,o=0,s=0;s<=t.length;++s){if(s<t.length)n=t.charCodeAt(s);else {if(47===n)break;n=47;}if(47===n){if(a===s-1||1===o);else if(a!==s-1&&2===o){if(r.length<2||2!==i||46!==r.charCodeAt(r.length-1)||46!==r.charCodeAt(r.length-2))if(r.length>2){var c=r.lastIndexOf("/");if(c!==r.length-1){-1===c?(r="",i=0):i=(r=r.slice(0,c)).length-1-r.lastIndexOf("/"),a=s,o=0;continue}}else if(2===r.length||1===r.length){r="",i=0,a=s,o=0;continue}e&&(r.length>0?r+="/..":r="..",i=2);}else r.length>0?r+="/"+t.slice(a+1,s):r=t.slice(a+1,s),i=s-a-1;a=s,o=0;}else 46===n&&-1!==o?++o:o=-1;}return r}var r={resolve:function(){for(var t,r="",i=!1,a=arguments.length-1;a>=-1&&!i;a--){var o;a>=0?o=arguments[a]:(void 0===t&&(t=process.cwd()),o=t),e(o),0!==o.length&&(r=o+"/"+r,i=47===o.charCodeAt(0));}return r=n(r,!i),i?r.length>0?"/"+r:"/":r.length>0?r:"."},normalize:function(t){if(e(t),0===t.length)return ".";var r=47===t.charCodeAt(0),i=47===t.charCodeAt(t.length-1);return 0!==(t=n(t,!r)).length||r||(t="."),t.length>0&&i&&(t+="/"),r?"/"+t:t},isAbsolute:function(t){return e(t),t.length>0&&47===t.charCodeAt(0)},join:function(){if(0===arguments.length)return ".";for(var t,n=0;n<arguments.length;++n){var i=arguments[n];e(i),i.length>0&&(void 0===t?t=i:t+="/"+i);}return void 0===t?".":r.normalize(t)},relative:function(t,n){if(e(t),e(n),t===n)return "";if((t=r.resolve(t))===(n=r.resolve(n)))return "";for(var i=1;i<t.length&&47===t.charCodeAt(i);++i);for(var a=t.length,o=a-i,s=1;s<n.length&&47===n.charCodeAt(s);++s);for(var c=n.length-s,l=o<c?o:c,u=-1,h=0;h<=l;++h){if(h===l){if(c>l){if(47===n.charCodeAt(s+h))return n.slice(s+h+1);if(0===h)return n.slice(s+h)}else o>l&&(47===t.charCodeAt(i+h)?u=h:0===h&&(u=0));break}var f=t.charCodeAt(i+h);if(f!==n.charCodeAt(s+h))break;47===f&&(u=h);}var d="";for(h=i+u+1;h<=a;++h)h!==a&&47!==t.charCodeAt(h)||(0===d.length?d+="..":d+="/..");return d.length>0?d+n.slice(s+u):(s+=u,47===n.charCodeAt(s)&&++s,n.slice(s))},_makeLong:function(t){return t},dirname:function(t){if(e(t),0===t.length)return ".";for(var n=t.charCodeAt(0),r=47===n,i=-1,a=!0,o=t.length-1;o>=1;--o)if(47===(n=t.charCodeAt(o))){if(!a){i=o;break}}else a=!1;return -1===i?r?"/":".":r&&1===i?"//":t.slice(0,i)},basename:function(t,n){if(void 0!==n&&"string"!=typeof n)throw new TypeError('"ext" argument must be a string');e(t);var r,i=0,a=-1,o=!0;if(void 0!==n&&n.length>0&&n.length<=t.length){if(n.length===t.length&&n===t)return "";var s=n.length-1,c=-1;for(r=t.length-1;r>=0;--r){var l=t.charCodeAt(r);if(47===l){if(!o){i=r+1;break}}else -1===c&&(o=!1,c=r+1),s>=0&&(l===n.charCodeAt(s)?-1==--s&&(a=r):(s=-1,a=c));}return i===a?a=c:-1===a&&(a=t.length),t.slice(i,a)}for(r=t.length-1;r>=0;--r)if(47===t.charCodeAt(r)){if(!o){i=r+1;break}}else -1===a&&(o=!1,a=r+1);return -1===a?"":t.slice(i,a)},extname:function(t){e(t);for(var n=-1,r=0,i=-1,a=!0,o=0,s=t.length-1;s>=0;--s){var c=t.charCodeAt(s);if(47!==c)-1===i&&(a=!1,i=s+1),46===c?-1===n?n=s:1!==o&&(o=1):-1!==n&&(o=-1);else if(!a){r=s+1;break}}return -1===n||-1===i||0===o||1===o&&n===i-1&&n===r+1?"":t.slice(n,i)},format:function(t){if(null===t||"object"!=typeof t)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return function(t,e){var n=e.dir||e.root,r=e.base||(e.name||"")+(e.ext||"");return n?n===e.root?n+r:n+"/"+r:r}(0,t)},parse:function(t){e(t);var n={root:"",dir:"",base:"",ext:"",name:""};if(0===t.length)return n;var r,i=t.charCodeAt(0),a=47===i;a?(n.root="/",r=1):r=0;for(var o=-1,s=0,c=-1,l=!0,u=t.length-1,h=0;u>=r;--u)if(47!==(i=t.charCodeAt(u)))-1===c&&(l=!1,c=u+1),46===i?-1===o?o=u:1!==h&&(h=1):-1!==o&&(h=-1);else if(!l){s=u+1;break}return -1===o||-1===c||0===h||1===h&&o===c-1&&o===s+1?-1!==c&&(n.base=n.name=0===s&&a?t.slice(1,c):t.slice(s,c)):(0===s&&a?(n.name=t.slice(1,o),n.base=t.slice(1,c)):(n.name=t.slice(s,o),n.base=t.slice(s,c)),n.ext=t.slice(o,c)),s>0?n.dir=t.slice(0,s-1):a&&(n.dir="/"),n},sep:"/",delimiter:":",win32:null,posix:null};r.posix=r,t.exports=r;},555:()=>{},8218:()=>{},8009:()=>{},5354:()=>{},6878:()=>{},8183:()=>{},1428:()=>{},4551:()=>{},8800:()=>{},1993:()=>{},3069:()=>{},9143:()=>{},7543:(t,e,n)=>{function r(t,e){return null==t||null==e?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function i(t){let e=t,n=t,i=t;function a(t,e,r=0,a=t.length){if(r<a){if(0!==n(e,e))return a;do{const n=r+a>>>1;i(t[n],e)<0?r=n+1:a=n;}while(r<a)}return r}return 2!==t.length&&(e=(e,n)=>t(e)-n,n=r,i=(e,n)=>r(t(e),n)),{left:a,center:function(t,n,r=0,i=t.length){const o=a(t,n,r,i-1);return o>r&&e(t[o-1],n)>-e(t[o],n)?o-1:o},right:function(t,e,r=0,a=t.length){if(r<a){if(0!==n(e,e))return a;do{const n=r+a>>>1;i(t[n],e)<=0?r=n+1:a=n;}while(r<a)}return r}}}function a(t){return null===t?NaN:+t}n.r(e),n.d(e,{Adder:()=>x,Delaunay:()=>Bs,FormatSpecifier:()=>Fl,InternMap:()=>T,InternSet:()=>E,Node:()=>ng,Voronoi:()=>Ss,ZoomTransform:()=>sE,active:()=>ta,arc:()=>Jk,area:()=>sw,areaRadial:()=>yw,ascending:()=>r,autoType:()=>lc,axisBottom:()=>ie,axisLeft:()=>ae,axisRight:()=>re,axisTop:()=>ne,bin:()=>it,bisect:()=>u,bisectCenter:()=>l,bisectLeft:()=>c,bisectRight:()=>s,bisector:()=>i,blob:()=>$c,brush:()=>Oa,brushSelection:()=>Aa,brushX:()=>Ma,brushY:()=>Na,buffer:()=>qc,chord:()=>$a,chordDirected:()=>qa,chordTranspose:()=>Wa,cluster:()=>Xp,color:()=>tr,contourDensity:()=>is,contours:()=>Ko,count:()=>h,create:()=>Ck,creator:()=>pn,cross:()=>g,csv:()=>Zc,csvFormat:()=>Zs,csvFormatBody:()=>Qs,csvFormatRow:()=>Js,csvFormatRows:()=>Ks,csvFormatValue:()=>tc,csvParse:()=>Gs,csvParseRows:()=>Xs,cubehelix:()=>Uo,cumsum:()=>y,curveBasis:()=>Xw,curveBasisClosed:()=>Qw,curveBasisOpen:()=>Jw,curveBumpX:()=>eT,curveBumpY:()=>nT,curveBundle:()=>iT,curveCardinal:()=>sT,curveCardinalClosed:()=>lT,curveCardinalOpen:()=>hT,curveCatmullRom:()=>pT,curveCatmullRomClosed:()=>yT,curveCatmullRomOpen:()=>bT,curveLinear:()=>rw,curveLinearClosed:()=>_T,curveMonotoneX:()=>AT,curveMonotoneY:()=>MT,curveNatural:()=>DT,curveStep:()=>LT,curveStepAfter:()=>FT,curveStepBefore:()=>IT,descending:()=>m,deviation:()=>v,difference:()=>zt,disjoint:()=>Yt,dispatch:()=>fe,drag:()=>zs,dragDisable:()=>Ln,dragEnable:()=>In,dsv:()=>Xc,dsvFormat:()=>Hs,easeBack:()=>Rc,easeBackIn:()=>Ic,easeBackInOut:()=>Rc,easeBackOut:()=>Fc,easeBounce:()=>Dc,easeBounceIn:()=>Oc,easeBounceInOut:()=>Bc,easeBounceOut:()=>Dc,easeCircle:()=>Mc,easeCircleIn:()=>Sc,easeCircleInOut:()=>Mc,easeCircleOut:()=>Ac,easeCubic:()=>Zi,easeCubicIn:()=>Gi,easeCubicInOut:()=>Zi,easeCubicOut:()=>Xi,easeElastic:()=>zc,easeElasticIn:()=>jc,easeElasticInOut:()=>Yc,easeElasticOut:()=>zc,easeExp:()=>Cc,easeExpIn:()=>Tc,easeExpInOut:()=>Cc,easeExpOut:()=>Ec,easeLinear:()=>hc,easePoly:()=>mc,easePolyIn:()=>gc,easePolyInOut:()=>mc,easePolyOut:()=>yc,easeQuad:()=>pc,easeQuadIn:()=>fc,easeQuadInOut:()=>pc,easeQuadOut:()=>dc,easeSin:()=>kc,easeSinIn:()=>_c,easeSinInOut:()=>kc,easeSinOut:()=>xc,every:()=>Lt,extent:()=>_,fcumsum:()=>w,filter:()=>Ft,flatGroup:()=>L,flatRollup:()=>I,forceCenter:()=>al,forceCollide:()=>bl,forceLink:()=>xl,forceManyBody:()=>Sl,forceRadial:()=>Al,forceSimulation:()=>Cl,forceX:()=>Ml,forceY:()=>Nl,format:()=>Yl,formatDefaultLocale:()=>Hl,formatLocale:()=>ql,formatPrefix:()=>Ul,formatSpecifier:()=>Il,fsum:()=>k,geoAlbers:()=>up,geoAlbersUsa:()=>hp,geoArea:()=>Zu,geoAzimuthalEqualArea:()=>gp,geoAzimuthalEqualAreaRaw:()=>pp,geoAzimuthalEquidistant:()=>mp,geoAzimuthalEquidistantRaw:()=>yp,geoBounds:()=>Oh,geoCentroid:()=>$h,geoCircle:()=>tf,geoClipAntimeridian:()=>ff,geoClipCircle:()=>df,geoClipExtent:()=>xf,geoClipRectangle:()=>_f,geoConicConformal:()=>wp,geoConicConformalRaw:()=>kp,geoConicEqualArea:()=>lp,geoConicEqualAreaRaw:()=>cp,geoConicEquidistant:()=>Sp,geoConicEquidistantRaw:()=>Cp,geoContains:()=>Pf,geoDistance:()=>Mf,geoEqualEarth:()=>Lp,geoEqualEarthRaw:()=>Bp,geoEquirectangular:()=>Ep,geoEquirectangularRaw:()=>Tp,geoGnomonic:()=>Fp,geoGnomonicRaw:()=>Ip,geoGraticule:()=>Yf,geoGraticule10:()=>Uf,geoIdentity:()=>Rp,geoInterpolate:()=>$f,geoLength:()=>Cf,geoMercator:()=>vp,geoMercatorRaw:()=>bp,geoNaturalEarth1:()=>jp,geoNaturalEarth1Raw:()=>Pp,geoOrthographic:()=>Yp,geoOrthographicRaw:()=>zp,geoPath:()=>Hd,geoProjection:()=>ap,geoProjectionMutator:()=>op,geoRotation:()=>Qh,geoStereographic:()=>$p,geoStereographicRaw:()=>Up,geoStream:()=>Cu,geoTransform:()=>Vd,geoTransverseMercator:()=>qp,geoTransverseMercatorRaw:()=>Wp,gray:()=>xo,greatest:()=>Et,greatestIndex:()=>Ct,group:()=>O,groupSort:()=>H,groups:()=>D,hcl:()=>No,hierarchy:()=>Qp,histogram:()=>it,hsl:()=>hr,html:()=>rl,image:()=>Kc,index:()=>P,indexes:()=>j,interpolate:()=>Ir,interpolateArray:()=>Sr,interpolateBasis:()=>gr,interpolateBasisClosed:()=>yr,interpolateBlues:()=>Jx,interpolateBrBG:()=>hx,interpolateBuGn:()=>Mx,interpolateBuPu:()=>Ox,interpolateCividis:()=>uk,interpolateCool:()=>dk,interpolateCubehelix:()=>hy,interpolateCubehelixDefault:()=>hk,interpolateCubehelixLong:()=>fy,interpolateDate:()=>Mr,interpolateDiscrete:()=>Kg,interpolateGnBu:()=>Bx,interpolateGreens:()=>ek,interpolateGreys:()=>rk,interpolateHcl:()=>cy,interpolateHclLong:()=>ly,interpolateHsl:()=>iy,interpolateHslLong:()=>ay,interpolateHue:()=>Jg,interpolateInferno:()=>Tk,interpolateLab:()=>oy,interpolateMagma:()=>wk,interpolateNumber:()=>Nr,interpolateNumberArray:()=>Er,interpolateObject:()=>Or,interpolateOrRd:()=>Ix,interpolateOranges:()=>lk,interpolatePRGn:()=>dx,interpolatePiYG:()=>gx,interpolatePlasma:()=>Ek,interpolatePuBu:()=>jx,interpolatePuBuGn:()=>Rx,interpolatePuOr:()=>mx,interpolatePuRd:()=>Yx,interpolatePurples:()=>ak,interpolateRainbow:()=>gk,interpolateRdBu:()=>vx,interpolateRdGy:()=>xx,interpolateRdPu:()=>$x,interpolateRdYlBu:()=>wx,interpolateRdYlGn:()=>Ex,interpolateReds:()=>sk,interpolateRgb:()=>xr,interpolateRgbBasis:()=>wr,interpolateRgbBasisClosed:()=>Tr,interpolateRound:()=>ty,interpolateSinebow:()=>vk,interpolateSpectral:()=>Sx,interpolateString:()=>Lr,interpolateTransformCss:()=>gi,interpolateTransformSvg:()=>yi,interpolateTurbo:()=>_k,interpolateViridis:()=>kk,interpolateWarm:()=>fk,interpolateYlGn:()=>Vx,interpolateYlGnBu:()=>qx,interpolateYlOrBr:()=>Xx,interpolateYlOrRd:()=>Qx,interpolateZoom:()=>ny,interrupt:()=>li,intersection:()=>Ut,interval:()=>iE,isoFormat:()=>eE,isoParse:()=>rE,json:()=>tl,lab:()=>ko,lch:()=>Mo,least:()=>wt,leastIndex:()=>Tt,line:()=>ow,lineRadial:()=>gw,linkHorizontal:()=>Tw,linkRadial:()=>Cw,linkVertical:()=>Ew,local:()=>Ak,map:()=>Rt,matcher:()=>be,max:()=>at,maxIndex:()=>dt,mean:()=>pt,median:()=>gt,merge:()=>yt,min:()=>ot,minIndex:()=>mt,mode:()=>bt,namespace:()=>Le,namespaces:()=>Be,nice:()=>nt,now:()=>Gr,pack:()=>kg,packEnclose:()=>rg,packSiblings:()=>yg,pairs:()=>vt,partition:()=>Ag,path:()=>Ja,permute:()=>U,pie:()=>uw,piecewise:()=>dy,pointRadial:()=>mw,pointer:()=>Rr,pointers:()=>Nk,polygonArea:()=>gy,polygonCentroid:()=>yy,polygonContains:()=>xy,polygonHull:()=>_y,polygonLength:()=>ky,precisionFixed:()=>Vl,precisionPrefix:()=>Gl,precisionRound:()=>Xl,quadtree:()=>ul,quantile:()=>lt,quantileSorted:()=>ut,quantize:()=>py,quickselect:()=>st,radialArea:()=>yw,radialLine:()=>gw,randomBates:()=>My,randomBernoulli:()=>Dy,randomBeta:()=>Iy,randomBinomial:()=>Fy,randomCauchy:()=>Py,randomExponential:()=>Ny,randomGamma:()=>Ly,randomGeometric:()=>By,randomInt:()=>Ey,randomIrwinHall:()=>Ay,randomLcg:()=>Uy,randomLogNormal:()=>Sy,randomLogistic:()=>jy,randomNormal:()=>Cy,randomPareto:()=>Oy,randomPoisson:()=>zy,randomUniform:()=>Ty,randomWeibull:()=>Ry,range:()=>xt,rank:()=>kt,reduce:()=>Pt,reverse:()=>jt,rgb:()=>ir,ribbon:()=>uo,ribbonArrow:()=>ho,rollup:()=>F,rollups:()=>R,scaleBand:()=>Vy,scaleDiverging:()=>V_,scaleDivergingLog:()=>G_,scaleDivergingPow:()=>Z_,scaleDivergingSqrt:()=>Q_,scaleDivergingSymlog:()=>X_,scaleIdentity:()=>cm,scaleImplicit:()=>qy,scaleLinear:()=>sm,scaleLog:()=>mm,scaleOrdinal:()=>Hy,scalePoint:()=>Xy,scalePow:()=>Cm,scaleQuantile:()=>Om,scaleQuantize:()=>Dm,scaleRadial:()=>Nm,scaleSequential:()=>z_,scaleSequentialLog:()=>Y_,scaleSequentialPow:()=>$_,scaleSequentialQuantile:()=>q_,scaleSequentialSqrt:()=>W_,scaleSequentialSymlog:()=>U_,scaleSqrt:()=>Sm,scaleSymlog:()=>xm,scaleThreshold:()=>Bm,scaleTime:()=>F_,scaleUtc:()=>R_,scan:()=>St,schemeAccent:()=>tx,schemeBlues:()=>Kx,schemeBrBG:()=>ux,schemeBuGn:()=>Ax,schemeBuPu:()=>Nx,schemeCategory10:()=>J_,schemeDark2:()=>ex,schemeGnBu:()=>Dx,schemeGreens:()=>tk,schemeGreys:()=>nk,schemeOrRd:()=>Lx,schemeOranges:()=>ck,schemePRGn:()=>fx,schemePaired:()=>nx,schemePastel1:()=>rx,schemePastel2:()=>ix,schemePiYG:()=>px,schemePuBu:()=>Px,schemePuBuGn:()=>Fx,schemePuOr:()=>yx,schemePuRd:()=>zx,schemePurples:()=>ik,schemeRdBu:()=>bx,schemeRdGy:()=>_x,schemeRdPu:()=>Ux,schemeRdYlBu:()=>kx,schemeRdYlGn:()=>Tx,schemeReds:()=>ok,schemeSet1:()=>ax,schemeSet2:()=>ox,schemeSet3:()=>sx,schemeSpectral:()=>Cx,schemeTableau10:()=>cx,schemeYlGn:()=>Hx,schemeYlGnBu:()=>Wx,schemeYlOrBr:()=>Gx,schemeYlOrRd:()=>Zx,select:()=>Mn,selectAll:()=>Ok,selection:()=>An,selector:()=>pe,selectorAll:()=>me,shuffle:()=>At,shuffler:()=>Mt,some:()=>It,sort:()=>$,stack:()=>YT,stackOffsetDiverging:()=>$T,stackOffsetExpand:()=>UT,stackOffsetNone:()=>RT,stackOffsetSilhouette:()=>WT,stackOffsetWiggle:()=>qT,stackOrderAppearance:()=>HT,stackOrderAscending:()=>GT,stackOrderDescending:()=>ZT,stackOrderInsideOut:()=>QT,stackOrderNone:()=>PT,stackOrderReverse:()=>KT,stratify:()=>Lg,style:()=>qe,subset:()=>Ht,sum:()=>Nt,superset:()=>Wt,svg:()=>il,symbol:()=>qw,symbolCircle:()=>Sw,symbolCross:()=>Aw,symbolDiamond:()=>Ow,symbolSquare:()=>Fw,symbolStar:()=>Iw,symbolTriangle:()=>Pw,symbolWye:()=>$w,symbols:()=>Ww,text:()=>Vc,thresholdFreedmanDiaconis:()=>ht,thresholdScott:()=>ft,thresholdSturges:()=>rt,tickFormat:()=>am,tickIncrement:()=>tt,tickStep:()=>et,ticks:()=>J,timeDay:()=>nb,timeDays:()=>rb,timeFormat:()=>hv,timeFormatDefaultLocale:()=>D_,timeFormatLocale:()=>lv,timeFriday:()=>ub,timeFridays:()=>mb,timeHour:()=>Jm,timeHours:()=>tb,timeInterval:()=>Um,timeMillisecond:()=>Wm,timeMilliseconds:()=>qm,timeMinute:()=>Zm,timeMinutes:()=>Qm,timeMonday:()=>ob,timeMondays:()=>db,timeMonth:()=>_b,timeMonths:()=>xb,timeParse:()=>fv,timeSaturday:()=>hb,timeSaturdays:()=>bb,timeSecond:()=>Vm,timeSeconds:()=>Gm,timeSunday:()=>ab,timeSundays:()=>fb,timeThursday:()=>lb,timeThursdays:()=>yb,timeTickInterval:()=>av,timeTicks:()=>iv,timeTuesday:()=>sb,timeTuesdays:()=>pb,timeWednesday:()=>cb,timeWednesdays:()=>gb,timeWeek:()=>ab,timeWeeks:()=>fb,timeYear:()=>wb,timeYears:()=>Tb,timeout:()=>ni,timer:()=>Qr,timerFlush:()=>Kr,transition:()=>qi,transpose:()=>Ot,tree:()=>$g,treemap:()=>Gg,treemapBinary:()=>Xg,treemapDice:()=>Sg,treemapResquarify:()=>Qg,treemapSlice:()=>Wg,treemapSliceDice:()=>Zg,treemapSquarify:()=>Vg,tsv:()=>Qc,tsvFormat:()=>ic,tsvFormatBody:()=>ac,tsvFormatRow:()=>sc,tsvFormatRows:()=>oc,tsvFormatValue:()=>cc,tsvParse:()=>nc,tsvParseRows:()=>rc,union:()=>Vt,utcDay:()=>Db,utcDays:()=>Bb,utcFormat:()=>dv,utcFriday:()=>zb,utcFridays:()=>Vb,utcHour:()=>Mb,utcHours:()=>Nb,utcMillisecond:()=>Wm,utcMilliseconds:()=>qm,utcMinute:()=>Cb,utcMinutes:()=>Sb,utcMonday:()=>Fb,utcMondays:()=>$b,utcMonth:()=>Zb,utcMonths:()=>Qb,utcParse:()=>pv,utcSaturday:()=>Yb,utcSaturdays:()=>Gb,utcSecond:()=>Vm,utcSeconds:()=>Gm,utcSunday:()=>Ib,utcSundays:()=>Ub,utcThursday:()=>jb,utcThursdays:()=>Hb,utcTickInterval:()=>rv,utcTicks:()=>nv,utcTuesday:()=>Rb,utcTuesdays:()=>Wb,utcWednesday:()=>Pb,utcWednesdays:()=>qb,utcWeek:()=>Ib,utcWeeks:()=>Ub,utcYear:()=>Jb,utcYears:()=>tv,variance:()=>b,window:()=>Ye,xml:()=>nl,zip:()=>Bt,zoom:()=>bE,zoomIdentity:()=>cE,zoomTransform:()=>lE});const o=i(r),s=o.right,c=o.left,l=i(a).center,u=s;function h(t,e){let n=0;if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&++n;else {let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&(i=+i)>=i&&++n;}return n}function f(t){return 0|t.length}function d(t){return !(t>0)}function p(t){return "object"!=typeof t||"length"in t?t:Array.from(t)}function g(...t){const e="function"==typeof t[t.length-1]&&function(t){return e=>t(...e)}(t.pop()),n=(t=t.map(p)).map(f),r=t.length-1,i=new Array(r+1).fill(0),a=[];if(r<0||n.some(d))return a;for(;;){a.push(i.map(((e,n)=>t[n][e])));let o=r;for(;++i[o]===n[o];){if(0===o)return e?a.map(e):a;i[o--]=0;}}}function y(t,e){var n=0,r=0;return Float64Array.from(t,void 0===e?t=>n+=+t||0:i=>n+=+e(i,r++,t)||0)}function m(t,e){return null==t||null==e?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function b(t,e){let n,r=0,i=0,a=0;if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(n=e-i,i+=n/++r,a+=n*(e-i));else {let o=-1;for(let s of t)null!=(s=e(s,++o,t))&&(s=+s)>=s&&(n=s-i,i+=n/++r,a+=n*(s-i));}if(r>1)return a/(r-1)}function v(t,e){const n=b(t,e);return n?Math.sqrt(n):n}function _(t,e){let n,r;if(void 0===e)for(const e of t)null!=e&&(void 0===n?e>=e&&(n=r=e):(n>e&&(n=e),r<e&&(r=e)));else {let i=-1;for(let a of t)null!=(a=e(a,++i,t))&&(void 0===n?a>=a&&(n=r=a):(n>a&&(n=a),r<a&&(r=a)));}return [n,r]}class x{constructor(){this._partials=new Float64Array(32),this._n=0;}add(t){const e=this._partials;let n=0;for(let r=0;r<this._n&&r<32;r++){const i=e[r],a=t+i,o=Math.abs(t)<Math.abs(i)?t-(a-i):i-(a-t);o&&(e[n++]=o),t=a;}return e[n]=t,this._n=n+1,this}valueOf(){const t=this._partials;let e,n,r,i=this._n,a=0;if(i>0){for(a=t[--i];i>0&&(e=a,n=t[--i],a=e+n,r=n-(a-e),!r););i>0&&(r<0&&t[i-1]<0||r>0&&t[i-1]>0)&&(n=2*r,e=a+n,n==e-a&&(a=e));}return a}}function k(t,e){const n=new x;if(void 0===e)for(let e of t)(e=+e)&&n.add(e);else {let r=-1;for(let i of t)(i=+e(i,++r,t))&&n.add(i);}return +n}function w(t,e){const n=new x;let r=-1;return Float64Array.from(t,void 0===e?t=>n.add(+t||0):i=>n.add(+e(i,++r,t)||0))}class T extends Map{constructor(t,e=M){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:e}}),null!=t)for(const[e,n]of t)this.set(e,n);}get(t){return super.get(C(this,t))}has(t){return super.has(C(this,t))}set(t,e){return super.set(S(this,t),e)}delete(t){return super.delete(A(this,t))}}class E extends Set{constructor(t,e=M){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:e}}),null!=t)for(const e of t)this.add(e);}has(t){return super.has(C(this,t))}add(t){return super.add(S(this,t))}delete(t){return super.delete(A(this,t))}}function C({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function S({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function A({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function M(t){return null!==t&&"object"==typeof t?t.valueOf():t}function N(t){return t}function O(t,...e){return Y(t,N,N,e)}function D(t,...e){return Y(t,Array.from,N,e)}function B(t,e){for(let n=1,r=e.length;n<r;++n)t=t.flatMap((t=>t.pop().map((([e,n])=>[...t,e,n]))));return t}function L(t,...e){return B(D(t,...e),e)}function I(t,e,...n){return B(R(t,e,...n),n)}function F(t,e,...n){return Y(t,N,e,n)}function R(t,e,...n){return Y(t,Array.from,e,n)}function P(t,...e){return Y(t,N,z,e)}function j(t,...e){return Y(t,Array.from,z,e)}function z(t){if(1!==t.length)throw new Error("duplicate key");return t[0]}function Y(t,e,n,r){return function t(i,a){if(a>=r.length)return n(i);const o=new T,s=r[a++];let c=-1;for(const t of i){const e=s(t,++c,i),n=o.get(e);n?n.push(t):o.set(e,[t]);}for(const[e,n]of o)o.set(e,t(n,a));return e(o)}(t,0)}function U(t,e){return Array.from(e,(e=>t[e]))}function $(t,...e){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");t=Array.from(t);let[n]=e;if(n&&2!==n.length||e.length>1){const r=Uint32Array.from(t,((t,e)=>e));return e.length>1?(e=e.map((e=>t.map(e))),r.sort(((t,n)=>{for(const r of e){const e=q(r[t],r[n]);if(e)return e}}))):(n=t.map(n),r.sort(((t,e)=>q(n[t],n[e])))),U(t,r)}return t.sort(W(n))}function W(t=r){if(t===r)return q;if("function"!=typeof t)throw new TypeError("compare is not a function");return (e,n)=>{const r=t(e,n);return r||0===r?r:(0===t(n,n))-(0===t(e,e))}}function q(t,e){return (null==t||!(t>=t))-(null==e||!(e>=e))||(t<e?-1:t>e?1:0)}function H(t,e,n){return (2!==e.length?$(F(t,e,n),(([t,e],[n,i])=>r(e,i)||r(t,n))):$(O(t,n),(([t,n],[i,a])=>e(n,a)||r(t,i)))).map((([t])=>t))}var V=Array.prototype,G=V.slice;function X(t){return ()=>t}var Z=Math.sqrt(50),Q=Math.sqrt(10),K=Math.sqrt(2);function J(t,e,n){var r,i,a,o,s=-1;if(n=+n,(t=+t)==(e=+e)&&n>0)return [t];if((r=e<t)&&(i=t,t=e,e=i),0===(o=tt(t,e,n))||!isFinite(o))return [];if(o>0){let n=Math.round(t/o),r=Math.round(e/o);for(n*o<t&&++n,r*o>e&&--r,a=new Array(i=r-n+1);++s<i;)a[s]=(n+s)*o;}else {o=-o;let n=Math.round(t*o),r=Math.round(e*o);for(n/o<t&&++n,r/o>e&&--r,a=new Array(i=r-n+1);++s<i;)a[s]=(n+s)/o;}return r&&a.reverse(),a}function tt(t,e,n){var r=(e-t)/Math.max(0,n),i=Math.floor(Math.log(r)/Math.LN10),a=r/Math.pow(10,i);return i>=0?(a>=Z?10:a>=Q?5:a>=K?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(a>=Z?10:a>=Q?5:a>=K?2:1)}function et(t,e,n){var r=Math.abs(e-t)/Math.max(0,n),i=Math.pow(10,Math.floor(Math.log(r)/Math.LN10)),a=r/i;return a>=Z?i*=10:a>=Q?i*=5:a>=K&&(i*=2),e<t?-i:i}function nt(t,e,n){let r;for(;;){const i=tt(t,e,n);if(i===r||0===i||!isFinite(i))return [t,e];i>0?(t=Math.floor(t/i)*i,e=Math.ceil(e/i)*i):i<0&&(t=Math.ceil(t*i)/i,e=Math.floor(e*i)/i),r=i;}}function rt(t){return Math.ceil(Math.log(h(t))/Math.LN2)+1}function it(){var t=N,e=_,n=rt;function r(r){Array.isArray(r)||(r=Array.from(r));var i,a,o=r.length,s=new Array(o);for(i=0;i<o;++i)s[i]=t(r[i],i,r);var c=e(s),l=c[0],h=c[1],f=n(s,l,h);if(!Array.isArray(f)){const t=h,n=+f;if(e===_&&([l,h]=nt(l,h,n)),(f=J(l,h,n))[f.length-1]>=h)if(t>=h&&e===_){const t=tt(l,h,n);isFinite(t)&&(t>0?h=(Math.floor(h/t)+1)*t:t<0&&(h=(Math.ceil(h*-t)+1)/-t));}else f.pop();}for(var d=f.length;f[0]<=l;)f.shift(),--d;for(;f[d-1]>h;)f.pop(),--d;var p,g=new Array(d+1);for(i=0;i<=d;++i)(p=g[i]=[]).x0=i>0?f[i-1]:l,p.x1=i<d?f[i]:h;for(i=0;i<o;++i)null!=(a=s[i])&&l<=a&&a<=h&&g[u(f,a,0,d)].push(r[i]);return g}return r.value=function(e){return arguments.length?(t="function"==typeof e?e:X(e),r):t},r.domain=function(t){return arguments.length?(e="function"==typeof t?t:X([t[0],t[1]]),r):e},r.thresholds=function(t){return arguments.length?(n="function"==typeof t?t:Array.isArray(t)?X(G.call(t)):X(t),r):n},r}function at(t,e){let n;if(void 0===e)for(const e of t)null!=e&&(n<e||void 0===n&&e>=e)&&(n=e);else {let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&(n<i||void 0===n&&i>=i)&&(n=i);}return n}function ot(t,e){let n;if(void 0===e)for(const e of t)null!=e&&(n>e||void 0===n&&e>=e)&&(n=e);else {let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&(n>i||void 0===n&&i>=i)&&(n=i);}return n}function st(t,e,n=0,r=t.length-1,i){for(i=void 0===i?q:W(i);r>n;){if(r-n>600){const a=r-n+1,o=e-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*c*(a-c)/a)*(o-a/2<0?-1:1);st(t,e,Math.max(n,Math.floor(e-o*c/a+l)),Math.min(r,Math.floor(e+(a-o)*c/a+l)),i);}const a=t[e];let o=n,s=r;for(ct(t,n,e),i(t[r],a)>0&&ct(t,n,r);o<s;){for(ct(t,o,s),++o,--s;i(t[o],a)<0;)++o;for(;i(t[s],a)>0;)--s;}0===i(t[n],a)?ct(t,n,s):(++s,ct(t,s,r)),s<=e&&(n=s+1),e<=s&&(r=s-1);}return t}function ct(t,e,n){const r=t[e];t[e]=t[n],t[n]=r;}function lt(t,e,n){if(t=Float64Array.from(function*(t,e){if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(yield e);else {let n=-1;for(let r of t)null!=(r=e(r,++n,t))&&(r=+r)>=r&&(yield r);}}(t,n)),r=t.length){if((e=+e)<=0||r<2)return ot(t);if(e>=1)return at(t);var r,i=(r-1)*e,a=Math.floor(i),o=at(st(t,a).subarray(0,a+1));return o+(ot(t.subarray(a+1))-o)*(i-a)}}function ut(t,e,n=a){if(r=t.length){if((e=+e)<=0||r<2)return +n(t[0],0,t);if(e>=1)return +n(t[r-1],r-1,t);var r,i=(r-1)*e,o=Math.floor(i),s=+n(t[o],o,t);return s+(+n(t[o+1],o+1,t)-s)*(i-o)}}function ht(t,e,n){return Math.ceil((n-e)/(2*(lt(t,.75)-lt(t,.25))*Math.pow(h(t),-1/3)))}function ft(t,e,n){return Math.ceil((n-e)/(3.5*v(t)*Math.pow(h(t),-1/3)))}function dt(t,e){let n,r=-1,i=-1;if(void 0===e)for(const e of t)++i,null!=e&&(n<e||void 0===n&&e>=e)&&(n=e,r=i);else for(let a of t)null!=(a=e(a,++i,t))&&(n<a||void 0===n&&a>=a)&&(n=a,r=i);return r}function pt(t,e){let n=0,r=0;if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(++n,r+=e);else {let i=-1;for(let a of t)null!=(a=e(a,++i,t))&&(a=+a)>=a&&(++n,r+=a);}if(n)return r/n}function gt(t,e){return lt(t,.5,e)}function yt(t){return Array.from(function*(t){for(const e of t)yield*e;}(t))}function mt(t,e){let n,r=-1,i=-1;if(void 0===e)for(const e of t)++i,null!=e&&(n>e||void 0===n&&e>=e)&&(n=e,r=i);else for(let a of t)null!=(a=e(a,++i,t))&&(n>a||void 0===n&&a>=a)&&(n=a,r=i);return r}function bt(t,e){const n=new T;if(void 0===e)for(let e of t)null!=e&&e>=e&&n.set(e,(n.get(e)||0)+1);else {let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&i>=i&&n.set(i,(n.get(i)||0)+1);}let r,i=0;for(const[t,e]of n)e>i&&(i=e,r=t);return r}function vt(t,e=_t){const n=[];let r,i=!1;for(const a of t)i&&n.push(e(r,a)),r=a,i=!0;return n}function _t(t,e){return [t,e]}function xt(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=0|Math.max(0,Math.ceil((e-t)/n)),a=new Array(i);++r<i;)a[r]=t+r*n;return a}function kt(t,e=r){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");let n=Array.from(t);const i=new Float64Array(n.length);2!==e.length&&(n=n.map(e),e=r);const a=(t,r)=>e(n[t],n[r]);let o,s;return Uint32Array.from(n,((t,e)=>e)).sort(e===r?(t,e)=>q(n[t],n[e]):W(a)).forEach(((t,e)=>{const n=a(t,void 0===o?t:o);n>=0?((void 0===o||n>0)&&(o=t,s=e),i[t]=s):i[t]=NaN;})),i}function wt(t,e=r){let n,i=!1;if(1===e.length){let a;for(const o of t){const t=e(o);(i?r(t,a)<0:0===r(t,t))&&(n=o,a=t,i=!0);}}else for(const r of t)(i?e(r,n)<0:0===e(r,r))&&(n=r,i=!0);return n}function Tt(t,e=r){if(1===e.length)return mt(t,e);let n,i=-1,a=-1;for(const r of t)++a,(i<0?0===e(r,r):e(r,n)<0)&&(n=r,i=a);return i}function Et(t,e=r){let n,i=!1;if(1===e.length){let a;for(const o of t){const t=e(o);(i?r(t,a)>0:0===r(t,t))&&(n=o,a=t,i=!0);}}else for(const r of t)(i?e(r,n)>0:0===e(r,r))&&(n=r,i=!0);return n}function Ct(t,e=r){if(1===e.length)return dt(t,e);let n,i=-1,a=-1;for(const r of t)++a,(i<0?0===e(r,r):e(r,n)>0)&&(n=r,i=a);return i}function St(t,e){const n=Tt(t,e);return n<0?void 0:n}const At=Mt(Math.random);function Mt(t){return function(e,n=0,r=e.length){let i=r-(n=+n);for(;i;){const r=t()*i--|0,a=e[i+n];e[i+n]=e[r+n],e[r+n]=a;}return e}}function Nt(t,e){let n=0;if(void 0===e)for(let e of t)(e=+e)&&(n+=e);else {let r=-1;for(let i of t)(i=+e(i,++r,t))&&(n+=i);}return n}function Ot(t){if(!(i=t.length))return [];for(var e=-1,n=ot(t,Dt),r=new Array(n);++e<n;)for(var i,a=-1,o=r[e]=new Array(i);++a<i;)o[a]=t[a][e];return r}function Dt(t){return t.length}function Bt(){return Ot(arguments)}function Lt(t,e){if("function"!=typeof e)throw new TypeError("test is not a function");let n=-1;for(const r of t)if(!e(r,++n,t))return !1;return !0}function It(t,e){if("function"!=typeof e)throw new TypeError("test is not a function");let n=-1;for(const r of t)if(e(r,++n,t))return !0;return !1}function Ft(t,e){if("function"!=typeof e)throw new TypeError("test is not a function");const n=[];let r=-1;for(const i of t)e(i,++r,t)&&n.push(i);return n}function Rt(t,e){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");if("function"!=typeof e)throw new TypeError("mapper is not a function");return Array.from(t,((n,r)=>e(n,r,t)))}function Pt(t,e,n){if("function"!=typeof e)throw new TypeError("reducer is not a function");const r=t[Symbol.iterator]();let i,a,o=-1;if(arguments.length<3){if(({done:i,value:n}=r.next()),i)return;++o;}for(;({done:i,value:a}=r.next()),!i;)n=e(n,a,++o,t);return n}function jt(t){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");return Array.from(t).reverse()}function zt(t,...e){t=new E(t);for(const n of e)for(const e of n)t.delete(e);return t}function Yt(t,e){const n=e[Symbol.iterator](),r=new E;for(const e of t){if(r.has(e))return !1;let t,i;for(;({value:t,done:i}=n.next())&&!i;){if(Object.is(e,t))return !1;r.add(t);}}return !0}function Ut(t,...e){t=new E(t),e=e.map($t);t:for(const n of t)for(const r of e)if(!r.has(n)){t.delete(n);continue t}return t}function $t(t){return t instanceof E?t:new E(t)}function Wt(t,e){const n=t[Symbol.iterator](),r=new Set;for(const t of e){const e=qt(t);if(r.has(e))continue;let i,a;for(;({value:i,done:a}=n.next());){if(a)return !1;const t=qt(i);if(r.add(t),Object.is(e,t))break}}return !0}function qt(t){return null!==t&&"object"==typeof t?t.valueOf():t}function Ht(t,e){return Wt(e,t)}function Vt(...t){const e=new E;for(const n of t)for(const t of n)e.add(t);return e}function Gt(t){return t}var Xt=1e-6;function Zt(t){return "translate("+t+",0)"}function Qt(t){return "translate(0,"+t+")"}function Kt(t){return e=>+t(e)}function Jt(t,e){return e=Math.max(0,t.bandwidth()-2*e)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function te(){return !this.__axis}function ee(t,e){var n=[],r=null,i=null,a=6,o=6,s=3,c="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5,l=1===t||4===t?-1:1,u=4===t||2===t?"x":"y",h=1===t||3===t?Zt:Qt;function f(f){var d=null==r?e.ticks?e.ticks.apply(e,n):e.domain():r,p=null==i?e.tickFormat?e.tickFormat.apply(e,n):Gt:i,g=Math.max(a,0)+s,y=e.range(),m=+y[0]+c,b=+y[y.length-1]+c,v=(e.bandwidth?Jt:Kt)(e.copy(),c),_=f.selection?f.selection():f,x=_.selectAll(".domain").data([null]),k=_.selectAll(".tick").data(d,e).order(),w=k.exit(),T=k.enter().append("g").attr("class","tick"),E=k.select("line"),C=k.select("text");x=x.merge(x.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),k=k.merge(T),E=E.merge(T.append("line").attr("stroke","currentColor").attr(u+"2",l*a)),C=C.merge(T.append("text").attr("fill","currentColor").attr(u,l*g).attr("dy",1===t?"0em":3===t?"0.71em":"0.32em")),f!==_&&(x=x.transition(f),k=k.transition(f),E=E.transition(f),C=C.transition(f),w=w.transition(f).attr("opacity",Xt).attr("transform",(function(t){return isFinite(t=v(t))?h(t+c):this.getAttribute("transform")})),T.attr("opacity",Xt).attr("transform",(function(t){var e=this.parentNode.__axis;return h((e&&isFinite(e=e(t))?e:v(t))+c)}))),w.remove(),x.attr("d",4===t||2===t?o?"M"+l*o+","+m+"H"+c+"V"+b+"H"+l*o:"M"+c+","+m+"V"+b:o?"M"+m+","+l*o+"V"+c+"H"+b+"V"+l*o:"M"+m+","+c+"H"+b),k.attr("opacity",1).attr("transform",(function(t){return h(v(t)+c)})),E.attr(u+"2",l*a),C.attr(u,l*g).text(p),_.filter(te).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",2===t?"start":4===t?"end":"middle"),_.each((function(){this.__axis=v;}));}return f.scale=function(t){return arguments.length?(e=t,f):e},f.ticks=function(){return n=Array.from(arguments),f},f.tickArguments=function(t){return arguments.length?(n=null==t?[]:Array.from(t),f):n.slice()},f.tickValues=function(t){return arguments.length?(r=null==t?null:Array.from(t),f):r&&r.slice()},f.tickFormat=function(t){return arguments.length?(i=t,f):i},f.tickSize=function(t){return arguments.length?(a=o=+t,f):a},f.tickSizeInner=function(t){return arguments.length?(a=+t,f):a},f.tickSizeOuter=function(t){return arguments.length?(o=+t,f):o},f.tickPadding=function(t){return arguments.length?(s=+t,f):s},f.offset=function(t){return arguments.length?(c=+t,f):c},f}function ne(t){return ee(1,t)}function re(t){return ee(2,t)}function ie(t){return ee(3,t)}function ae(t){return ee(4,t)}var oe={value:()=>{}};function se(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[];}return new ce(r)}function ce(t){this._=t;}function le(t,e){return t.trim().split(/^|\s+/).map((function(t){var n="",r=t.indexOf(".");if(r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return {type:t,name:n}}))}function ue(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function he(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=oe,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}ce.prototype=se.prototype={constructor:ce,on:function(t,e){var n,r=this._,i=le(t+"",r),a=-1,o=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<o;)if(n=(t=i[a]).type)r[n]=he(r[n],t.name,e);else if(null==e)for(n in r)r[n]=he(r[n],t.name,null);return this}for(;++a<o;)if((n=(t=i[a]).type)&&(n=ue(r[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new ce(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),a=0;a<n;++a)i[a]=arguments[a+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(a=0,n=(r=this._[t]).length;a<n;++a)r[a].value.apply(e,i);},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,a=r.length;i<a;++i)r[i].value.apply(e,n);}};const fe=se;function de(){}function pe(t){return null==t?de:function(){return this.querySelector(t)}}function ge(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}function ye(){return []}function me(t){return null==t?ye:function(){return this.querySelectorAll(t)}}function be(t){return function(){return this.matches(t)}}function ve(t){return function(e){return e.matches(t)}}var _e=Array.prototype.find;function xe(){return this.firstElementChild}var ke=Array.prototype.filter;function we(){return Array.from(this.children)}function Te(t){return new Array(t.length)}function Ee(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e;}function Ce(t){return function(){return t}}function Se(t,e,n,r,i,a){for(var o,s=0,c=e.length,l=a.length;s<l;++s)(o=e[s])?(o.__data__=a[s],r[s]=o):n[s]=new Ee(t,a[s]);for(;s<c;++s)(o=e[s])&&(i[s]=o);}function Ae(t,e,n,r,i,a,o){var s,c,l,u=new Map,h=e.length,f=a.length,d=new Array(h);for(s=0;s<h;++s)(c=e[s])&&(d[s]=l=o.call(c,c.__data__,s,e)+"",u.has(l)?i[s]=c:u.set(l,c));for(s=0;s<f;++s)l=o.call(t,a[s],s,a)+"",(c=u.get(l))?(r[s]=c,c.__data__=a[s],u.delete(l)):n[s]=new Ee(t,a[s]);for(s=0;s<h;++s)(c=e[s])&&u.get(d[s])===c&&(i[s]=c);}function Me(t){return t.__data__}function Ne(t){return "object"==typeof t&&"length"in t?t:Array.from(t)}function Oe(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}Ee.prototype={constructor:Ee,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};var De="http://www.w3.org/1999/xhtml";const Be={svg:"http://www.w3.org/2000/svg",xhtml:De,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Le(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),Be.hasOwnProperty(e)?{space:Be[e],local:t}:t}function Ie(t){return function(){this.removeAttribute(t);}}function Fe(t){return function(){this.removeAttributeNS(t.space,t.local);}}function Re(t,e){return function(){this.setAttribute(t,e);}}function Pe(t,e){return function(){this.setAttributeNS(t.space,t.local,e);}}function je(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n);}}function ze(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n);}}function Ye(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Ue(t){return function(){this.style.removeProperty(t);}}function $e(t,e,n){return function(){this.style.setProperty(t,e,n);}}function We(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n);}}function qe(t,e){return t.style.getPropertyValue(e)||Ye(t).getComputedStyle(t,null).getPropertyValue(e)}function He(t){return function(){delete this[t];}}function Ve(t,e){return function(){this[t]=e;}}function Ge(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n;}}function Xe(t){return t.trim().split(/^|\s+/)}function Ze(t){return t.classList||new Qe(t)}function Qe(t){this._node=t,this._names=Xe(t.getAttribute("class")||"");}function Ke(t,e){for(var n=Ze(t),r=-1,i=e.length;++r<i;)n.add(e[r]);}function Je(t,e){for(var n=Ze(t),r=-1,i=e.length;++r<i;)n.remove(e[r]);}function tn(t){return function(){Ke(this,t);}}function en(t){return function(){Je(this,t);}}function nn(t,e){return function(){(e.apply(this,arguments)?Ke:Je)(this,t);}}function rn(){this.textContent="";}function an(t){return function(){this.textContent=t;}}function on(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e;}}function sn(){this.innerHTML="";}function cn(t){return function(){this.innerHTML=t;}}function ln(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e;}}function un(){this.nextSibling&&this.parentNode.appendChild(this);}function hn(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild);}function fn(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===De&&e.documentElement.namespaceURI===De?e.createElement(t):e.createElementNS(n,t)}}function dn(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function pn(t){var e=Le(t);return (e.local?dn:fn)(e)}function gn(){return null}function yn(){var t=this.parentNode;t&&t.removeChild(this);}function mn(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function bn(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function vn(t){return t.trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}function _n(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,a=e.length;r<a;++r)n=e[r],t.type&&n.type!==t.type||n.name!==t.name?e[++i]=n:this.removeEventListener(n.type,n.listener,n.options);++i?e.length=i:delete this.__on;}}}function xn(t,e,n){return function(){var r,i=this.__on,a=function(t){return function(e){t.call(this,e,this.__data__);}}(e);if(i)for(var o=0,s=i.length;o<s;++o)if((r=i[o]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=a,r.options=n),void(r.value=e);this.addEventListener(t.type,a,n),r={type:t.type,name:t.name,value:e,listener:a,options:n},i?i.push(r):this.__on=[r];}}function kn(t,e,n){var r=Ye(t),i=r.CustomEvent;"function"==typeof i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i);}function wn(t,e){return function(){return kn(this,t,e)}}function Tn(t,e){return function(){return kn(this,t,e.apply(this,arguments))}}Qe.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")));},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")));},contains:function(t){return this._names.indexOf(t)>=0}};var En=[null];function Cn(t,e){this._groups=t,this._parents=e;}function Sn(){return new Cn([[document.documentElement]],En)}Cn.prototype=Sn.prototype={constructor:Cn,select:function(t){"function"!=typeof t&&(t=pe(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o,s=e[i],c=s.length,l=r[i]=new Array(c),u=0;u<c;++u)(a=s[u])&&(o=t.call(a,a.__data__,u,s))&&("__data__"in a&&(o.__data__=a.__data__),l[u]=o);return new Cn(r,this._parents)},selectAll:function(t){t="function"==typeof t?function(t){return function(){return ge(t.apply(this,arguments))}}(t):me(t);for(var e=this._groups,n=e.length,r=[],i=[],a=0;a<n;++a)for(var o,s=e[a],c=s.length,l=0;l<c;++l)(o=s[l])&&(r.push(t.call(o,o.__data__,l,s)),i.push(o));return new Cn(r,i)},selectChild:function(t){return this.select(null==t?xe:function(t){return function(){return _e.call(this.children,t)}}("function"==typeof t?t:ve(t)))},selectChildren:function(t){return this.selectAll(null==t?we:function(t){return function(){return ke.call(this.children,t)}}("function"==typeof t?t:ve(t)))},filter:function(t){"function"!=typeof t&&(t=be(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o=e[i],s=o.length,c=r[i]=[],l=0;l<s;++l)(a=o[l])&&t.call(a,a.__data__,l,o)&&c.push(a);return new Cn(r,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,Me);var n=e?Ae:Se,r=this._parents,i=this._groups;"function"!=typeof t&&(t=Ce(t));for(var a=i.length,o=new Array(a),s=new Array(a),c=new Array(a),l=0;l<a;++l){var u=r[l],h=i[l],f=h.length,d=Ne(t.call(u,u&&u.__data__,l,r)),p=d.length,g=s[l]=new Array(p),y=o[l]=new Array(p),m=c[l]=new Array(f);n(u,h,g,y,m,d,e);for(var b,v,_=0,x=0;_<p;++_)if(b=g[_]){for(_>=x&&(x=_+1);!(v=y[x])&&++x<p;);b._next=v||null;}}return (o=new Cn(o,r))._enter=s,o._exit=c,o},enter:function(){return new Cn(this._enter||this._groups.map(Te),this._parents)},exit:function(){return new Cn(this._exit||this._groups.map(Te),this._parents)},join:function(t,e,n){var r=this.enter(),i=this,a=this.exit();return "function"==typeof t?(r=t(r))&&(r=r.selection()):r=r.append(t+""),null!=e&&(i=e(i))&&(i=i.selection()),null==n?a.remove():n(a),r&&i?r.merge(i).order():i},merge:function(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,a=r.length,o=Math.min(i,a),s=new Array(i),c=0;c<o;++c)for(var l,u=n[c],h=r[c],f=u.length,d=s[c]=new Array(f),p=0;p<f;++p)(l=u[p]||h[p])&&(d[p]=l);for(;c<i;++c)s[c]=n[c];return new Cn(s,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r,i=t[e],a=i.length-1,o=i[a];--a>=0;)(r=i[a])&&(o&&4^r.compareDocumentPosition(o)&&o.parentNode.insertBefore(r,o),o=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=Oe);for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a){for(var o,s=n[a],c=s.length,l=i[a]=new Array(c),u=0;u<c;++u)(o=s[u])&&(l[u]=o);l.sort(e);}return new Cn(i,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null},size:function(){let t=0;for(const e of this)++t;return t},empty:function(){return !this.node()},each:function(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i,a=e[n],o=0,s=a.length;o<s;++o)(i=a[o])&&t.call(i,i.__data__,o,a);return this},attr:function(t,e){var n=Le(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==e?n.local?Fe:Ie:"function"==typeof e?n.local?ze:je:n.local?Pe:Re)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?Ue:"function"==typeof e?We:$e)(t,e,null==n?"":n)):qe(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?He:"function"==typeof e?Ge:Ve)(t,e)):this.node()[t]},classed:function(t,e){var n=Xe(t+"");if(arguments.length<2){for(var r=Ze(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return !1;return !0}return this.each(("function"==typeof e?nn:e?tn:en)(n,e))},text:function(t){return arguments.length?this.each(null==t?rn:("function"==typeof t?on:an)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?sn:("function"==typeof t?ln:cn)(t)):this.node().innerHTML},raise:function(){return this.each(un)},lower:function(){return this.each(hn)},append:function(t){var e="function"==typeof t?t:pn(t);return this.select((function(){return this.appendChild(e.apply(this,arguments))}))},insert:function(t,e){var n="function"==typeof t?t:pn(t),r=null==e?gn:"function"==typeof e?e:pe(e);return this.select((function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)}))},remove:function(){return this.each(yn)},clone:function(t){return this.select(t?bn:mn)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var r,i,a=vn(t+""),o=a.length;if(!(arguments.length<2)){for(s=e?xn:_n,r=0;r<o;++r)this.each(s(a[r],e,n));return this}var s=this.node().__on;if(s)for(var c,l=0,u=s.length;l<u;++l)for(r=0,c=s[l];r<o;++r)if((i=a[r]).type===c.type&&i.name===c.name)return c.value},dispatch:function(t,e){return this.each(("function"==typeof e?Tn:wn)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r,i=t[e],a=0,o=i.length;a<o;++a)(r=i[a])&&(yield r);}};const An=Sn;function Mn(t){return "string"==typeof t?new Cn([[document.querySelector(t)]],[document.documentElement]):new Cn([[t]],En)}const Nn={passive:!1},On={capture:!0,passive:!1};function Dn(t){t.stopImmediatePropagation();}function Bn(t){t.preventDefault(),t.stopImmediatePropagation();}function Ln(t){var e=t.document.documentElement,n=Mn(t).on("dragstart.drag",Bn,On);"onselectstart"in e?n.on("selectstart.drag",Bn,On):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none");}function In(t,e){var n=t.document.documentElement,r=Mn(t).on("dragstart.drag",null);e&&(r.on("click.drag",Bn,On),setTimeout((function(){r.on("click.drag",null);}),0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect);}function Fn(t,e,n){t.prototype=e.prototype=n,n.constructor=t;}function Rn(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Pn(){}var jn=.7,zn=1/jn,Yn="\\s*([+-]?\\d+)\\s*",Un="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",$n="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Wn=/^#([0-9a-f]{3,8})$/,qn=new RegExp("^rgb\\("+[Yn,Yn,Yn]+"\\)$"),Hn=new RegExp("^rgb\\("+[$n,$n,$n]+"\\)$"),Vn=new RegExp("^rgba\\("+[Yn,Yn,Yn,Un]+"\\)$"),Gn=new RegExp("^rgba\\("+[$n,$n,$n,Un]+"\\)$"),Xn=new RegExp("^hsl\\("+[Un,$n,$n]+"\\)$"),Zn=new RegExp("^hsla\\("+[Un,$n,$n,Un]+"\\)$"),Qn={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};function Kn(){return this.rgb().formatHex()}function Jn(){return this.rgb().formatRgb()}function tr(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Wn.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?er(e):3===n?new ar(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?nr(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?nr(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=qn.exec(t))?new ar(e[1],e[2],e[3],1):(e=Hn.exec(t))?new ar(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=Vn.exec(t))?nr(e[1],e[2],e[3],e[4]):(e=Gn.exec(t))?nr(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=Xn.exec(t))?lr(e[1],e[2]/100,e[3]/100,1):(e=Zn.exec(t))?lr(e[1],e[2]/100,e[3]/100,e[4]):Qn.hasOwnProperty(t)?er(Qn[t]):"transparent"===t?new ar(NaN,NaN,NaN,0):null}function er(t){return new ar(t>>16&255,t>>8&255,255&t,1)}function nr(t,e,n,r){return r<=0&&(t=e=n=NaN),new ar(t,e,n,r)}function rr(t){return t instanceof Pn||(t=tr(t)),t?new ar((t=t.rgb()).r,t.g,t.b,t.opacity):new ar}function ir(t,e,n,r){return 1===arguments.length?rr(t):new ar(t,e,n,null==r?1:r)}function ar(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r;}function or(){return "#"+cr(this.r)+cr(this.g)+cr(this.b)}function sr(){var t=this.opacity;return (1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}function cr(t){return ((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function lr(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new fr(t,e,n,r)}function ur(t){if(t instanceof fr)return new fr(t.h,t.s,t.l,t.opacity);if(t instanceof Pn||(t=tr(t)),!t)return new fr;if(t instanceof fr)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=Math.max(e,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=e===a?(n-r)/s+6*(n<r):n===a?(r-e)/s+2:(e-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new fr(o,s,c,t.opacity)}function hr(t,e,n,r){return 1===arguments.length?ur(t):new fr(t,e,n,null==r?1:r)}function fr(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r;}function dr(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}function pr(t,e,n,r,i){var a=t*t,o=a*t;return ((1-3*t+3*a-o)*e+(4-6*a+3*o)*n+(1+3*t+3*a-3*o)*r+o*i)/6}function gr(t){var e=t.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,e-1):Math.floor(n*e),i=t[r],a=t[r+1],o=r>0?t[r-1]:2*i-a,s=r<e-1?t[r+2]:2*a-i;return pr((n-r/e)*e,o,i,a,s)}}function yr(t){var e=t.length;return function(n){var r=Math.floor(((n%=1)<0?++n:n)*e),i=t[(r+e-1)%e],a=t[r%e],o=t[(r+1)%e],s=t[(r+2)%e];return pr((n-r/e)*e,i,a,o,s)}}Fn(Pn,tr,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:Kn,formatHex:Kn,formatHsl:function(){return ur(this).formatHsl()},formatRgb:Jn,toString:Jn}),Fn(ar,ir,Rn(Pn,{brighter:function(t){return t=null==t?zn:Math.pow(zn,t),new ar(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?jn:Math.pow(jn,t),new ar(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return -.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:or,formatHex:or,formatRgb:sr,toString:sr})),Fn(fr,hr,Rn(Pn,{brighter:function(t){return t=null==t?zn:Math.pow(zn,t),new fr(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?jn:Math.pow(jn,t),new fr(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new ar(dr(t>=240?t-240:t+120,i,r),dr(t,i,r),dr(t<120?t+240:t-120,i,r),this.opacity)},displayable:function(){return (0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=this.opacity;return (1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));const mr=t=>()=>t;function br(t,e){return function(n){return t+n*e}}function vr(t,e){var n=e-t;return n?br(t,n>180||n<-180?n-360*Math.round(n/360):n):mr(isNaN(t)?e:t)}function _r(t,e){var n=e-t;return n?br(t,n):mr(isNaN(t)?e:t)}const xr=function t(e){var n=function(t){return 1==(t=+t)?_r:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}(e,n,t):mr(isNaN(e)?n:e)}}(e);function r(t,e){var r=n((t=ir(t)).r,(e=ir(e)).r),i=n(t.g,e.g),a=n(t.b,e.b),o=_r(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=a(e),t.opacity=o(e),t+""}}return r.gamma=t,r}(1);function kr(t){return function(e){var n,r,i=e.length,a=new Array(i),o=new Array(i),s=new Array(i);for(n=0;n<i;++n)r=ir(e[n]),a[n]=r.r||0,o[n]=r.g||0,s[n]=r.b||0;return a=t(a),o=t(o),s=t(s),r.opacity=1,function(t){return r.r=a(t),r.g=o(t),r.b=s(t),r+""}}}var wr=kr(gr),Tr=kr(yr);function Er(t,e){e||(e=[]);var n,r=t?Math.min(e.length,t.length):0,i=e.slice();return function(a){for(n=0;n<r;++n)i[n]=t[n]*(1-a)+e[n]*a;return i}}function Cr(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Sr(t,e){return (Cr(e)?Er:Ar)(t,e)}function Ar(t,e){var n,r=e?e.length:0,i=t?Math.min(r,t.length):0,a=new Array(i),o=new Array(r);for(n=0;n<i;++n)a[n]=Ir(t[n],e[n]);for(;n<r;++n)o[n]=e[n];return function(t){for(n=0;n<i;++n)o[n]=a[n](t);return o}}function Mr(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Nr(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Or(t,e){var n,r={},i={};for(n in null!==t&&"object"==typeof t||(t={}),null!==e&&"object"==typeof e||(e={}),e)n in t?r[n]=Ir(t[n],e[n]):i[n]=e[n];return function(t){for(n in r)i[n]=r[n](t);return i}}var Dr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Br=new RegExp(Dr.source,"g");function Lr(t,e){var n,r,i,a=Dr.lastIndex=Br.lastIndex=0,o=-1,s=[],c=[];for(t+="",e+="";(n=Dr.exec(t))&&(r=Br.exec(e));)(i=r.index)>a&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(n=n[0])===(r=r[0])?s[o]?s[o]+=r:s[++o]=r:(s[++o]=null,c.push({i:o,x:Nr(n,r)})),a=Br.lastIndex;return a<e.length&&(i=e.slice(a),s[o]?s[o]+=i:s[++o]=i),s.length<2?c[0]?function(t){return function(e){return t(e)+""}}(c[0].x):function(t){return function(){return t}}(e):(e=c.length,function(t){for(var n,r=0;r<e;++r)s[(n=c[r]).i]=n.x(t);return s.join("")})}function Ir(t,e){var n,r=typeof e;return null==e||"boolean"===r?mr(e):("number"===r?Nr:"string"===r?(n=tr(e))?(e=n,xr):Lr:e instanceof tr?xr:e instanceof Date?Mr:Cr(e)?Er:Array.isArray(e)?Ar:"function"!=typeof e.valueOf&&"function"!=typeof e.toString||isNaN(e)?Or:Nr)(t,e)}function Fr(t){let e;for(;e=t.sourceEvent;)t=e;return t}function Rr(t,e){if(t=Fr(t),void 0===e&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,[(r=r.matrixTransform(e.getScreenCTM().inverse())).x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return [t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return [t.pageX,t.pageY]}var Pr,jr,zr=0,Yr=0,Ur=0,$r=0,Wr=0,qr=0,Hr="object"==typeof performance&&performance.now?performance:Date,Vr="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17);};function Gr(){return Wr||(Vr(Xr),Wr=Hr.now()+qr)}function Xr(){Wr=0;}function Zr(){this._call=this._time=this._next=null;}function Qr(t,e,n){var r=new Zr;return r.restart(t,e,n),r}function Kr(){Gr(),++zr;for(var t,e=Pr;e;)(t=Wr-e._time)>=0&&e._call.call(void 0,t),e=e._next;--zr;}function Jr(){Wr=($r=Hr.now())+qr,zr=Yr=0;try{Kr();}finally{zr=0,function(){for(var t,e,n=Pr,r=1/0;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Pr=e);jr=t,ei(r);}(),Wr=0;}}function ti(){var t=Hr.now(),e=t-$r;e>1e3&&(qr-=e,$r=t);}function ei(t){zr||(Yr&&(Yr=clearTimeout(Yr)),t-Wr>24?(t<1/0&&(Yr=setTimeout(Jr,t-Hr.now()-qr)),Ur&&(Ur=clearInterval(Ur))):(Ur||($r=Hr.now(),Ur=setInterval(ti,1e3)),zr=1,Vr(Jr)));}function ni(t,e,n){var r=new Zr;return e=null==e?0:+e,r.restart((n=>{r.stop(),t(n+e);}),e,n),r}Zr.prototype=Qr.prototype={constructor:Zr,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?Gr():+n)+(null==e?0:+e),this._next||jr===this||(jr?jr._next=this:Pr=this,jr=this),this._call=t,this._time=n,ei();},stop:function(){this._call&&(this._call=null,this._time=1/0,ei());}};var ri=fe("start","end","cancel","interrupt"),ii=[];function ai(t,e,n,r,i,a){var o=t.__transition;if(o){if(n in o)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function a(c){var l,u,h,f;if(1!==n.state)return s();for(l in i)if((f=i[l]).name===n.name){if(3===f.state)return ni(a);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete i[l]):+l<e&&(f.state=6,f.timer.stop(),f.on.call("cancel",t,t.__data__,f.index,f.group),delete i[l]);}if(ni((function(){3===n.state&&(n.state=4,n.timer.restart(o,n.delay,n.time),o(c));})),n.state=2,n.on.call("start",t,t.__data__,n.index,n.group),2===n.state){for(n.state=3,r=new Array(h=n.tween.length),l=0,u=-1;l<h;++l)(f=n.tween[l].value.call(t,t.__data__,n.index,n.group))&&(r[++u]=f);r.length=u+1;}}function o(e){for(var i=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(s),n.state=5,1),a=-1,o=r.length;++a<o;)r[a].call(t,i);5===n.state&&(n.on.call("end",t,t.__data__,n.index,n.group),s());}function s(){for(var r in n.state=6,n.timer.stop(),delete i[e],i)return;delete t.__transition;}i[e]=n,n.timer=Qr((function(t){n.state=1,n.timer.restart(a,n.delay,n.time),n.delay<=t&&a(t-n.delay);}),0,n.time);}(t,n,{name:e,index:r,group:i,on:ri,tween:ii,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0});}function oi(t,e){var n=ci(t,e);if(n.state>0)throw new Error("too late; already scheduled");return n}function si(t,e){var n=ci(t,e);if(n.state>3)throw new Error("too late; already running");return n}function ci(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function li(t,e){var n,r,i,a=t.__transition,o=!0;if(a){for(i in e=null==e?null:e+"",a)(n=a[i]).name===e?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete a[i]):o=!1;o&&delete t.__transition;}}var ui,hi=180/Math.PI,fi={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function di(t,e,n,r,i,a){var o,s,c;return (o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(c=t*n+e*r)&&(n-=t*c,r-=e*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),t*r<e*n&&(t=-t,e=-e,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(e,t)*hi,skewX:Math.atan(c)*hi,scaleX:o,scaleY:s}}function pi(t,e,n,r){function i(t){return t.length?t.pop()+" ":""}return function(a,o){var s=[],c=[];return a=t(a),o=t(o),function(t,r,i,a,o,s){if(t!==i||r!==a){var c=o.push("translate(",null,e,null,n);s.push({i:c-4,x:Nr(t,i)},{i:c-2,x:Nr(r,a)});}else (i||a)&&o.push("translate("+i+e+a+n);}(a.translateX,a.translateY,o.translateX,o.translateY,s,c),function(t,e,n,a){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),a.push({i:n.push(i(n)+"rotate(",null,r)-2,x:Nr(t,e)})):e&&n.push(i(n)+"rotate("+e+r);}(a.rotate,o.rotate,s,c),function(t,e,n,a){t!==e?a.push({i:n.push(i(n)+"skewX(",null,r)-2,x:Nr(t,e)}):e&&n.push(i(n)+"skewX("+e+r);}(a.skewX,o.skewX,s,c),function(t,e,n,r,a,o){if(t!==n||e!==r){var s=a.push(i(a)+"scale(",null,",",null,")");o.push({i:s-4,x:Nr(t,n)},{i:s-2,x:Nr(e,r)});}else 1===n&&1===r||a.push(i(a)+"scale("+n+","+r+")");}(a.scaleX,a.scaleY,o.scaleX,o.scaleY,s,c),a=o=null,function(t){for(var e,n=-1,r=c.length;++n<r;)s[(e=c[n]).i]=e.x(t);return s.join("")}}}var gi=pi((function(t){const e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?fi:di(e.a,e.b,e.c,e.d,e.e,e.f)}),"px, ","px)","deg)"),yi=pi((function(t){return null==t?fi:(ui||(ui=document.createElementNS("http://www.w3.org/2000/svg","g")),ui.setAttribute("transform",t),(t=ui.transform.baseVal.consolidate())?di((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):fi)}),", ",")",")");function mi(t,e){var n,r;return function(){var i=si(this,t),a=i.tween;if(a!==n)for(var o=0,s=(r=n=a).length;o<s;++o)if(r[o].name===e){(r=r.slice()).splice(o,1);break}i.tween=r;}}function bi(t,e,n){var r,i;if("function"!=typeof n)throw new Error;return function(){var a=si(this,t),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:e,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===e){i[c]=s;break}c===l&&i.push(s);}a.tween=i;}}function vi(t,e,n){var r=t._id;return t.each((function(){var t=si(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments);})),function(t){return ci(t,r).value[e]}}function _i(t,e){var n;return ("number"==typeof e?Nr:e instanceof tr?xr:(n=tr(e))?(e=n,xr):Lr)(t,e)}function xi(t){return function(){this.removeAttribute(t);}}function ki(t){return function(){this.removeAttributeNS(t.space,t.local);}}function wi(t,e,n){var r,i,a=n+"";return function(){var o=this.getAttribute(t);return o===a?null:o===r?i:i=e(r=o,n)}}function Ti(t,e,n){var r,i,a=n+"";return function(){var o=this.getAttributeNS(t.space,t.local);return o===a?null:o===r?i:i=e(r=o,n)}}function Ei(t,e,n){var r,i,a;return function(){var o,s,c=n(this);if(null!=c)return (o=this.getAttribute(t))===(s=c+"")?null:o===r&&s===i?a:(i=s,a=e(r=o,c));this.removeAttribute(t);}}function Ci(t,e,n){var r,i,a;return function(){var o,s,c=n(this);if(null!=c)return (o=this.getAttributeNS(t.space,t.local))===(s=c+"")?null:o===r&&s===i?a:(i=s,a=e(r=o,c));this.removeAttributeNS(t.space,t.local);}}function Si(t,e){return function(n){this.setAttribute(t,e.call(this,n));}}function Ai(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n));}}function Mi(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&Ai(t,i)),n}return i._value=e,i}function Ni(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&Si(t,i)),n}return i._value=e,i}function Oi(t,e){return function(){oi(this,t).delay=+e.apply(this,arguments);}}function Di(t,e){return e=+e,function(){oi(this,t).delay=e;}}function Bi(t,e){return function(){si(this,t).duration=+e.apply(this,arguments);}}function Li(t,e){return e=+e,function(){si(this,t).duration=e;}}function Ii(t,e){if("function"!=typeof e)throw new Error;return function(){si(this,t).ease=e;}}function Fi(t,e,n){var r,i,a=function(t){return (t+"").trim().split(/^|\s+/).every((function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||"start"===t}))}(e)?oi:si;return function(){var o=a(this,t),s=o.on;s!==r&&(i=(r=s).copy()).on(e,n),o.on=i;}}var Ri=An.prototype.constructor;function Pi(t){return function(){this.style.removeProperty(t);}}function ji(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n);}}function zi(t,e,n){var r,i;function a(){var a=e.apply(this,arguments);return a!==i&&(r=(i=a)&&ji(t,a,n)),r}return a._value=e,a}function Yi(t){return function(e){this.textContent=t.call(this,e);}}function Ui(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&Yi(r)),e}return r._value=t,r}var $i=0;function Wi(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r;}function qi(t){return An().transition(t)}function Hi(){return ++$i}var Vi=An.prototype;function Gi(t){return t*t*t}function Xi(t){return --t*t*t+1}function Zi(t){return ((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}Wi.prototype=qi.prototype={constructor:Wi,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=pe(t));for(var r=this._groups,i=r.length,a=new Array(i),o=0;o<i;++o)for(var s,c,l=r[o],u=l.length,h=a[o]=new Array(u),f=0;f<u;++f)(s=l[f])&&(c=t.call(s,s.__data__,f,l))&&("__data__"in s&&(c.__data__=s.__data__),h[f]=c,ai(h[f],e,n,f,h,ci(s,n)));return new Wi(a,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=me(t));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c,l=r[s],u=l.length,h=0;h<u;++h)if(c=l[h]){for(var f,d=t.call(c,c.__data__,h,l),p=ci(c,n),g=0,y=d.length;g<y;++g)(f=d[g])&&ai(f,e,n,g,d,p);a.push(d),o.push(c);}return new Wi(a,o,e,n)},selectChild:Vi.selectChild,selectChildren:Vi.selectChildren,filter:function(t){"function"!=typeof t&&(t=be(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o=e[i],s=o.length,c=r[i]=[],l=0;l<s;++l)(a=o[l])&&t.call(a,a.__data__,l,o)&&c.push(a);return new Wi(r,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,a=Math.min(r,i),o=new Array(r),s=0;s<a;++s)for(var c,l=e[s],u=n[s],h=l.length,f=o[s]=new Array(h),d=0;d<h;++d)(c=l[d]||u[d])&&(f[d]=c);for(;s<r;++s)o[s]=e[s];return new Wi(o,this._parents,this._name,this._id)},selection:function(){return new Ri(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,n=Hi(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o,s=r[a],c=s.length,l=0;l<c;++l)if(o=s[l]){var u=ci(o,e);ai(o,t,n,l,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease});}return new Wi(r,this._parents,t,n)},call:Vi.call,nodes:Vi.nodes,node:Vi.node,size:Vi.size,empty:Vi.empty,each:Vi.each,on:function(t,e){var n=this._id;return arguments.length<2?ci(this.node(),n).on.on(t):this.each(Fi(n,t,e))},attr:function(t,e){var n=Le(t),r="transform"===n?yi:_i;return this.attrTween(t,"function"==typeof e?(n.local?Ci:Ei)(n,r,vi(this,"attr."+t,e)):null==e?(n.local?ki:xi)(n):(n.local?Ti:wi)(n,r,e))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return (n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;var r=Le(t);return this.tween(n,(r.local?Mi:Ni)(r,e))},style:function(t,e,n){var r="transform"==(t+="")?gi:_i;return null==e?this.styleTween(t,function(t,e){var n,r,i;return function(){var a=qe(this,t),o=(this.style.removeProperty(t),qe(this,t));return a===o?null:a===n&&o===r?i:i=e(n=a,r=o)}}(t,r)).on("end.style."+t,Pi(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var r,i,a;return function(){var o=qe(this,t),s=n(this),c=s+"";return null==s&&(this.style.removeProperty(t),c=s=qe(this,t)),o===c?null:o===r&&c===i?a:(i=c,a=e(r=o,s))}}(t,r,vi(this,"style."+t,e))).each(function(t,e){var n,r,i,a,o="style."+e,s="end."+o;return function(){var c=si(this,t),l=c.on,u=null==c.value[o]?a||(a=Pi(e)):void 0;l===n&&i===u||(r=(n=l).copy()).on(s,i=u),c.on=r;}}(this._id,t)):this.styleTween(t,function(t,e,n){var r,i,a=n+"";return function(){var o=qe(this,t);return o===a?null:o===r?i:i=e(r=o,n)}}(t,r,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var r="style."+(t+="");if(arguments.length<2)return (r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw new Error;return this.tween(r,zi(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e;}}(vi(this,"text",t)):function(t){return function(){this.textContent=t;}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return (e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,Ui(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this);}}(this._id))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r,i=ci(this.node(),n).tween,a=0,o=i.length;a<o;++a)if((r=i[a]).name===t)return r.value;return null}return this.each((null==e?mi:bi)(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Oi:Di)(e,t)):ci(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Bi:Li)(e,t)):ci(this.node(),e).duration},ease:function(t){var e=this._id;return arguments.length?this.each(Ii(e,t)):ci(this.node(),e).ease},easeVarying:function(t){if("function"!=typeof t)throw new Error;return this.each(function(t,e){return function(){var n=e.apply(this,arguments);if("function"!=typeof n)throw new Error;si(this,t).ease=n;}}(this._id,t))},end:function(){var t,e,n=this,r=n._id,i=n.size();return new Promise((function(a,o){var s={value:o},c={value:function(){0==--i&&a();}};n.each((function(){var n=si(this,r),i=n.on;i!==t&&((e=(t=i).copy())._.cancel.push(s),e._.interrupt.push(s),e._.end.push(c)),n.on=e;})),0===i&&a();}))},[Symbol.iterator]:Vi[Symbol.iterator]};var Qi={time:null,delay:0,duration:250,ease:Zi};function Ki(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}An.prototype.interrupt=function(t){return this.each((function(){li(this,t);}))},An.prototype.transition=function(t){var e,n;t instanceof Wi?(e=t._id,t=t._name):(e=Hi(),(n=Qi).time=Gr(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o,s=r[a],c=s.length,l=0;l<c;++l)(o=s[l])&&ai(o,t,e,l,s,n||Ki(o,e));return new Wi(r,this._parents,t,e)};var Ji=[null];function ta(t,e){var n,r,i=t.__transition;if(i)for(r in e=null==e?null:e+"",i)if((n=i[r]).state>1&&n.name===e)return new Wi([[t]],Ji,e,+r);return null}const ea=t=>()=>t;function na(t,{sourceEvent:e,target:n,selection:r,mode:i,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},selection:{value:r,enumerable:!0,configurable:!0},mode:{value:i,enumerable:!0,configurable:!0},_:{value:a}});}function ra(t){t.stopImmediatePropagation();}function ia(t){t.preventDefault(),t.stopImmediatePropagation();}var aa={name:"drag"},oa={name:"space"},sa={name:"handle"},ca={name:"center"};const{abs:la,max:ua,min:ha}=Math;function fa(t){return [+t[0],+t[1]]}function da(t){return [fa(t[0]),fa(t[1])]}var pa={name:"x",handles:["w","e"].map(ka),input:function(t,e){return null==t?null:[[+t[0],e[0][1]],[+t[1],e[1][1]]]},output:function(t){return t&&[t[0][0],t[1][0]]}},ga={name:"y",handles:["n","s"].map(ka),input:function(t,e){return null==t?null:[[e[0][0],+t[0]],[e[1][0],+t[1]]]},output:function(t){return t&&[t[0][1],t[1][1]]}},ya={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(ka),input:function(t){return null==t?null:da(t)},output:function(t){return t}},ma={overlay:"crosshair",selection:"move",n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},ba={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},va={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},_a={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},xa={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function ka(t){return {type:t}}function wa(t){return !t.ctrlKey&&!t.button}function Ta(){var t=this.ownerSVGElement||this;return t.hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]}function Ea(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ca(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function Sa(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}function Aa(t){var e=t.__brush;return e?e.dim.output(e.selection):null}function Ma(){return Da(pa)}function Na(){return Da(ga)}function Oa(){return Da(ya)}function Da(t){var e,n=Ta,r=wa,i=Ea,a=!0,o=fe("start","brush","end"),s=6;function c(e){var n=e.property("__brush",g).selectAll(".overlay").data([ka("overlay")]);n.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",ma.overlay).merge(n).each((function(){var t=Ca(this).extent;Mn(this).attr("x",t[0][0]).attr("y",t[0][1]).attr("width",t[1][0]-t[0][0]).attr("height",t[1][1]-t[0][1]);})),e.selectAll(".selection").data([ka("selection")]).enter().append("rect").attr("class","selection").attr("cursor",ma.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var r=e.selectAll(".handle").data(t.handles,(function(t){return t.type}));r.exit().remove(),r.enter().append("rect").attr("class",(function(t){return "handle handle--"+t.type})).attr("cursor",(function(t){return ma[t.type]})),e.each(l).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",f).filter(i).on("touchstart.brush",f).on("touchmove.brush",d).on("touchend.brush touchcancel.brush",p).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)");}function l(){var t=Mn(this),e=Ca(this).selection;e?(t.selectAll(".selection").style("display",null).attr("x",e[0][0]).attr("y",e[0][1]).attr("width",e[1][0]-e[0][0]).attr("height",e[1][1]-e[0][1]),t.selectAll(".handle").style("display",null).attr("x",(function(t){return "e"===t.type[t.type.length-1]?e[1][0]-s/2:e[0][0]-s/2})).attr("y",(function(t){return "s"===t.type[0]?e[1][1]-s/2:e[0][1]-s/2})).attr("width",(function(t){return "n"===t.type||"s"===t.type?e[1][0]-e[0][0]+s:s})).attr("height",(function(t){return "e"===t.type||"w"===t.type?e[1][1]-e[0][1]+s:s}))):t.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null);}function u(t,e,n){var r=t.__brush.emitter;return !r||n&&r.clean?new h(t,e,n):r}function h(t,e,n){this.that=t,this.args=e,this.state=t.__brush,this.active=0,this.clean=n;}function f(n){if((!e||n.touches)&&r.apply(this,arguments)){var i,o,s,c,h,f,d,p,g,y,m,b=this,v=n.target.__data__.type,_="selection"===(a&&n.metaKey?v="overlay":v)?aa:a&&n.altKey?ca:sa,x=t===ga?null:_a[v],k=t===pa?null:xa[v],w=Ca(b),T=w.extent,E=w.selection,C=T[0][0],S=T[0][1],A=T[1][0],M=T[1][1],N=0,O=0,D=x&&k&&a&&n.shiftKey,B=Array.from(n.touches||[n],(t=>{const e=t.identifier;return (t=Rr(t,b)).point0=t.slice(),t.identifier=e,t}));li(b);var L=u(b,arguments,!0).beforestart();if("overlay"===v){E&&(g=!0);const e=[B[0],B[1]||B[0]];w.selection=E=[[i=t===ga?C:ha(e[0][0],e[1][0]),s=t===pa?S:ha(e[0][1],e[1][1])],[h=t===ga?A:ua(e[0][0],e[1][0]),d=t===pa?M:ua(e[0][1],e[1][1])]],B.length>1&&j(n);}else i=E[0][0],s=E[0][1],h=E[1][0],d=E[1][1];o=i,c=s,f=h,p=d;var I=Mn(b).attr("pointer-events","none"),F=I.selectAll(".overlay").attr("cursor",ma[v]);if(n.touches)L.moved=P,L.ended=z;else {var R=Mn(n.view).on("mousemove.brush",P,!0).on("mouseup.brush",z,!0);a&&R.on("keydown.brush",Y,!0).on("keyup.brush",U,!0),Ln(n.view);}l.call(b),L.start(n,_.name);}function P(t){for(const e of t.changedTouches||[t])for(const t of B)t.identifier===e.identifier&&(t.cur=Rr(e,b));if(D&&!y&&!m&&1===B.length){const t=B[0];la(t.cur[0]-t[0])>la(t.cur[1]-t[1])?m=!0:y=!0;}for(const t of B)t.cur&&(t[0]=t.cur[0],t[1]=t.cur[1]);g=!0,ia(t),j(t);}function j(t){const e=B[0],n=e.point0;var r;switch(N=e[0]-n[0],O=e[1]-n[1],_){case oa:case aa:x&&(N=ua(C-i,ha(A-h,N)),o=i+N,f=h+N),k&&(O=ua(S-s,ha(M-d,O)),c=s+O,p=d+O);break;case sa:B[1]?(x&&(o=ua(C,ha(A,B[0][0])),f=ua(C,ha(A,B[1][0])),x=1),k&&(c=ua(S,ha(M,B[0][1])),p=ua(S,ha(M,B[1][1])),k=1)):(x<0?(N=ua(C-i,ha(A-i,N)),o=i+N,f=h):x>0&&(N=ua(C-h,ha(A-h,N)),o=i,f=h+N),k<0?(O=ua(S-s,ha(M-s,O)),c=s+O,p=d):k>0&&(O=ua(S-d,ha(M-d,O)),c=s,p=d+O));break;case ca:x&&(o=ua(C,ha(A,i-N*x)),f=ua(C,ha(A,h+N*x))),k&&(c=ua(S,ha(M,s-O*k)),p=ua(S,ha(M,d+O*k)));}f<o&&(x*=-1,r=i,i=h,h=r,r=o,o=f,f=r,v in ba&&F.attr("cursor",ma[v=ba[v]])),p<c&&(k*=-1,r=s,s=d,d=r,r=c,c=p,p=r,v in va&&F.attr("cursor",ma[v=va[v]])),w.selection&&(E=w.selection),y&&(o=E[0][0],f=E[1][0]),m&&(c=E[0][1],p=E[1][1]),E[0][0]===o&&E[0][1]===c&&E[1][0]===f&&E[1][1]===p||(w.selection=[[o,c],[f,p]],l.call(b),L.brush(t,_.name));}function z(t){if(ra(t),t.touches){if(t.touches.length)return;e&&clearTimeout(e),e=setTimeout((function(){e=null;}),500);}else In(t.view,g),R.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);I.attr("pointer-events","all"),F.attr("cursor",ma.overlay),w.selection&&(E=w.selection),Sa(E)&&(w.selection=null,l.call(b)),L.end(t,_.name);}function Y(t){switch(t.keyCode){case 16:D=x&&k;break;case 18:_===sa&&(x&&(h=f-N*x,i=o+N*x),k&&(d=p-O*k,s=c+O*k),_=ca,j(t));break;case 32:_!==sa&&_!==ca||(x<0?h=f-N:x>0&&(i=o-N),k<0?d=p-O:k>0&&(s=c-O),_=oa,F.attr("cursor",ma.selection),j(t));break;default:return}ia(t);}function U(t){switch(t.keyCode){case 16:D&&(y=m=D=!1,j(t));break;case 18:_===ca&&(x<0?h=f:x>0&&(i=o),k<0?d=p:k>0&&(s=c),_=sa,j(t));break;case 32:_===oa&&(t.altKey?(x&&(h=f-N*x,i=o+N*x),k&&(d=p-O*k,s=c+O*k),_=ca):(x<0?h=f:x>0&&(i=o),k<0?d=p:k>0&&(s=c),_=sa),F.attr("cursor",ma[v]),j(t));break;default:return}ia(t);}}function d(t){u(this,arguments).moved(t);}function p(t){u(this,arguments).ended(t);}function g(){var e=this.__brush||{selection:null};return e.extent=da(n.apply(this,arguments)),e.dim=t,e}return c.move=function(e,n,r){e.tween?e.on("start.brush",(function(t){u(this,arguments).beforestart().start(t);})).on("interrupt.brush end.brush",(function(t){u(this,arguments).end(t);})).tween("brush",(function(){var e=this,r=e.__brush,i=u(e,arguments),a=r.selection,o=t.input("function"==typeof n?n.apply(this,arguments):n,r.extent),s=Ir(a,o);function c(t){r.selection=1===t&&null===o?null:s(t),l.call(e),i.brush();}return null!==a&&null!==o?c:c(1)})):e.each((function(){var e=this,i=arguments,a=e.__brush,o=t.input("function"==typeof n?n.apply(e,i):n,a.extent),s=u(e,i).beforestart();li(e),a.selection=null===o?null:o,l.call(e),s.start(r).brush(r).end(r);}));},c.clear=function(t,e){c.move(t,null,e);},h.prototype={beforestart:function(){return 1==++this.active&&(this.state.emitter=this,this.starting=!0),this},start:function(t,e){return this.starting?(this.starting=!1,this.emit("start",t,e)):this.emit("brush",t),this},brush:function(t,e){return this.emit("brush",t,e),this},end:function(t,e){return 0==--this.active&&(delete this.state.emitter,this.emit("end",t,e)),this},emit:function(e,n,r){var i=Mn(this.that).datum();o.call(e,this.that,new na(e,{sourceEvent:n,target:c,selection:t.output(this.state.selection),mode:r,dispatch:o}),i);}},c.extent=function(t){return arguments.length?(n="function"==typeof t?t:ea(da(t)),c):n},c.filter=function(t){return arguments.length?(r="function"==typeof t?t:ea(!!t),c):r},c.touchable=function(t){return arguments.length?(i="function"==typeof t?t:ea(!!t),c):i},c.handleSize=function(t){return arguments.length?(s=+t,c):s},c.keyModifiers=function(t){return arguments.length?(a=!!t,c):a},c.on=function(){var t=o.on.apply(o,arguments);return t===o?c:t},c}var Ba=Math.abs,La=Math.cos,Ia=Math.sin,Fa=Math.PI,Ra=Fa/2,Pa=2*Fa,ja=Math.max,za=1e-12;function Ya(t,e){return Array.from({length:e-t},((e,n)=>t+n))}function Ua(t){return function(e,n){return t(e.source.value+e.target.value,n.source.value+n.target.value)}}function $a(){return Ha(!1,!1)}function Wa(){return Ha(!1,!0)}function qa(){return Ha(!0,!1)}function Ha(t,e){var n=0,r=null,i=null,a=null;function o(o){var s,c=o.length,l=new Array(c),u=Ya(0,c),h=new Array(c*c),f=new Array(c),d=0;o=Float64Array.from({length:c*c},e?(t,e)=>o[e%c][e/c|0]:(t,e)=>o[e/c|0][e%c]);for(let e=0;e<c;++e){let n=0;for(let r=0;r<c;++r)n+=o[e*c+r]+t*o[r*c+e];d+=l[e]=n;}s=(d=ja(0,Pa-n*c)/d)?n:Pa/c;{let e=0;r&&u.sort(((t,e)=>r(l[t],l[e])));for(const n of u){const r=e;if(t){const t=Ya(1+~c,c).filter((t=>t<0?o[~t*c+n]:o[n*c+t]));i&&t.sort(((t,e)=>i(t<0?-o[~t*c+n]:o[n*c+t],e<0?-o[~e*c+n]:o[n*c+e])));for(const r of t)r<0?(h[~r*c+n]||(h[~r*c+n]={source:null,target:null})).target={index:n,startAngle:e,endAngle:e+=o[~r*c+n]*d,value:o[~r*c+n]}:(h[n*c+r]||(h[n*c+r]={source:null,target:null})).source={index:n,startAngle:e,endAngle:e+=o[n*c+r]*d,value:o[n*c+r]};f[n]={index:n,startAngle:r,endAngle:e,value:l[n]};}else {const t=Ya(0,c).filter((t=>o[n*c+t]||o[t*c+n]));i&&t.sort(((t,e)=>i(o[n*c+t],o[n*c+e])));for(const r of t){let t;if(n<r?(t=h[n*c+r]||(h[n*c+r]={source:null,target:null}),t.source={index:n,startAngle:e,endAngle:e+=o[n*c+r]*d,value:o[n*c+r]}):(t=h[r*c+n]||(h[r*c+n]={source:null,target:null}),t.target={index:n,startAngle:e,endAngle:e+=o[n*c+r]*d,value:o[n*c+r]},n===r&&(t.source=t.target)),t.source&&t.target&&t.source.value<t.target.value){const e=t.source;t.source=t.target,t.target=e;}}f[n]={index:n,startAngle:r,endAngle:e,value:l[n]};}e+=s;}}return (h=Object.values(h)).groups=f,a?h.sort(a):h}return o.padAngle=function(t){return arguments.length?(n=ja(0,t),o):n},o.sortGroups=function(t){return arguments.length?(r=t,o):r},o.sortSubgroups=function(t){return arguments.length?(i=t,o):i},o.sortChords=function(t){return arguments.length?(null==t?a=null:(a=Ua(t))._=t,o):a&&a._},o}const Va=Math.PI,Ga=2*Va,Xa=1e-6,Za=Ga-Xa;function Qa(){this._x0=this._y0=this._x1=this._y1=null,this._="";}function Ka(){return new Qa}Qa.prototype=Ka.prototype={constructor:Qa,moveTo:function(t,e){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e);},closePath:function(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z");},lineTo:function(t,e){this._+="L"+(this._x1=+t)+","+(this._y1=+e);},quadraticCurveTo:function(t,e,n,r){this._+="Q"+ +t+","+ +e+","+(this._x1=+n)+","+(this._y1=+r);},bezierCurveTo:function(t,e,n,r,i,a){this._+="C"+ +t+","+ +e+","+ +n+","+ +r+","+(this._x1=+i)+","+(this._y1=+a);},arcTo:function(t,e,n,r,i){t=+t,e=+e,n=+n,r=+r,i=+i;var a=this._x1,o=this._y1,s=n-t,c=r-e,l=a-t,u=o-e,h=l*l+u*u;if(i<0)throw new Error("negative radius: "+i);if(null===this._x1)this._+="M"+(this._x1=t)+","+(this._y1=e);else if(h>Xa)if(Math.abs(u*s-c*l)>Xa&&i){var f=n-a,d=r-o,p=s*s+c*c,g=f*f+d*d,y=Math.sqrt(p),m=Math.sqrt(h),b=i*Math.tan((Va-Math.acos((p+h-g)/(2*y*m)))/2),v=b/m,_=b/y;Math.abs(v-1)>Xa&&(this._+="L"+(t+v*l)+","+(e+v*u)),this._+="A"+i+","+i+",0,0,"+ +(u*f>l*d)+","+(this._x1=t+_*s)+","+(this._y1=e+_*c);}else this._+="L"+(this._x1=t)+","+(this._y1=e);},arc:function(t,e,n,r,i,a){t=+t,e=+e,a=!!a;var o=(n=+n)*Math.cos(r),s=n*Math.sin(r),c=t+o,l=e+s,u=1^a,h=a?r-i:i-r;if(n<0)throw new Error("negative radius: "+n);null===this._x1?this._+="M"+c+","+l:(Math.abs(this._x1-c)>Xa||Math.abs(this._y1-l)>Xa)&&(this._+="L"+c+","+l),n&&(h<0&&(h=h%Ga+Ga),h>Za?this._+="A"+n+","+n+",0,1,"+u+","+(t-o)+","+(e-s)+"A"+n+","+n+",0,1,"+u+","+(this._x1=c)+","+(this._y1=l):h>Xa&&(this._+="A"+n+","+n+",0,"+ +(h>=Va)+","+u+","+(this._x1=t+n*Math.cos(i))+","+(this._y1=e+n*Math.sin(i))));},rect:function(t,e,n,r){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)+"h"+ +n+"v"+ +r+"h"+-n+"Z";},toString:function(){return this._}};const Ja=Ka;var to=Array.prototype.slice;function eo(t){return function(){return t}}function no(t){return t.source}function ro(t){return t.target}function io(t){return t.radius}function ao(t){return t.startAngle}function oo(t){return t.endAngle}function so(){return 0}function co(){return 10}function lo(t){var e=no,n=ro,r=io,i=io,a=ao,o=oo,s=so,c=null;function l(){var l,u=e.apply(this,arguments),h=n.apply(this,arguments),f=s.apply(this,arguments)/2,d=to.call(arguments),p=+r.apply(this,(d[0]=u,d)),g=a.apply(this,d)-Ra,y=o.apply(this,d)-Ra,m=+i.apply(this,(d[0]=h,d)),b=a.apply(this,d)-Ra,v=o.apply(this,d)-Ra;if(c||(c=l=Ja()),f>za&&(Ba(y-g)>2*f+za?y>g?(g+=f,y-=f):(g-=f,y+=f):g=y=(g+y)/2,Ba(v-b)>2*f+za?v>b?(b+=f,v-=f):(b-=f,v+=f):b=v=(b+v)/2),c.moveTo(p*La(g),p*Ia(g)),c.arc(0,0,p,g,y),g!==b||y!==v)if(t){var _=+t.apply(this,arguments),x=m-_,k=(b+v)/2;c.quadraticCurveTo(0,0,x*La(b),x*Ia(b)),c.lineTo(m*La(k),m*Ia(k)),c.lineTo(x*La(v),x*Ia(v));}else c.quadraticCurveTo(0,0,m*La(b),m*Ia(b)),c.arc(0,0,m,b,v);if(c.quadraticCurveTo(0,0,p*La(g),p*Ia(g)),c.closePath(),l)return c=null,l+""||null}return t&&(l.headRadius=function(e){return arguments.length?(t="function"==typeof e?e:eo(+e),l):t}),l.radius=function(t){return arguments.length?(r=i="function"==typeof t?t:eo(+t),l):r},l.sourceRadius=function(t){return arguments.length?(r="function"==typeof t?t:eo(+t),l):r},l.targetRadius=function(t){return arguments.length?(i="function"==typeof t?t:eo(+t),l):i},l.startAngle=function(t){return arguments.length?(a="function"==typeof t?t:eo(+t),l):a},l.endAngle=function(t){return arguments.length?(o="function"==typeof t?t:eo(+t),l):o},l.padAngle=function(t){return arguments.length?(s="function"==typeof t?t:eo(+t),l):s},l.source=function(t){return arguments.length?(e=t,l):e},l.target=function(t){return arguments.length?(n=t,l):n},l.context=function(t){return arguments.length?(c=null==t?null:t,l):c},l}function uo(){return lo()}function ho(){return lo(co)}const fo=Math.PI/180,po=180/Math.PI,go=.96422,yo=.82521,mo=4/29,bo=6/29,vo=3*bo*bo;function _o(t){if(t instanceof wo)return new wo(t.l,t.a,t.b,t.opacity);if(t instanceof Oo)return Do(t);t instanceof ar||(t=rr(t));var e,n,r=So(t.r),i=So(t.g),a=So(t.b),o=To((.2225045*r+.7168786*i+.0606169*a)/1);return r===i&&i===a?e=n=o:(e=To((.4360747*r+.3850649*i+.1430804*a)/go),n=To((.0139322*r+.0971045*i+.7141733*a)/yo)),new wo(116*o-16,500*(e-o),200*(o-n),t.opacity)}function xo(t,e){return new wo(t,0,0,null==e?1:e)}function ko(t,e,n,r){return 1===arguments.length?_o(t):new wo(t,e,n,null==r?1:r)}function wo(t,e,n,r){this.l=+t,this.a=+e,this.b=+n,this.opacity=+r;}function To(t){return t>.008856451679035631?Math.pow(t,1/3):t/vo+mo}function Eo(t){return t>bo?t*t*t:vo*(t-mo)}function Co(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function So(t){return (t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Ao(t){if(t instanceof Oo)return new Oo(t.h,t.c,t.l,t.opacity);if(t instanceof wo||(t=_o(t)),0===t.a&&0===t.b)return new Oo(NaN,0<t.l&&t.l<100?0:NaN,t.l,t.opacity);var e=Math.atan2(t.b,t.a)*po;return new Oo(e<0?e+360:e,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}function Mo(t,e,n,r){return 1===arguments.length?Ao(t):new Oo(n,e,t,null==r?1:r)}function No(t,e,n,r){return 1===arguments.length?Ao(t):new Oo(t,e,n,null==r?1:r)}function Oo(t,e,n,r){this.h=+t,this.c=+e,this.l=+n,this.opacity=+r;}function Do(t){if(isNaN(t.h))return new wo(t.l,0,0,t.opacity);var e=t.h*fo;return new wo(t.l,Math.cos(e)*t.c,Math.sin(e)*t.c,t.opacity)}Fn(wo,ko,Rn(Pn,{brighter:function(t){return new wo(this.l+18*(null==t?1:t),this.a,this.b,this.opacity)},darker:function(t){return new wo(this.l-18*(null==t?1:t),this.a,this.b,this.opacity)},rgb:function(){var t=(this.l+16)/116,e=isNaN(this.a)?t:t+this.a/500,n=isNaN(this.b)?t:t-this.b/200;return new ar(Co(3.1338561*(e=go*Eo(e))-1.6168667*(t=1*Eo(t))-.4906146*(n=yo*Eo(n))),Co(-.9787684*e+1.9161415*t+.033454*n),Co(.0719453*e-.2289914*t+1.4052427*n),this.opacity)}})),Fn(Oo,No,Rn(Pn,{brighter:function(t){return new Oo(this.h,this.c,this.l+18*(null==t?1:t),this.opacity)},darker:function(t){return new Oo(this.h,this.c,this.l-18*(null==t?1:t),this.opacity)},rgb:function(){return Do(this).rgb()}}));var Bo=-.14861,Lo=1.78277,Io=-.29227,Fo=-.90649,Ro=1.97294,Po=Ro*Fo,jo=Ro*Lo,zo=Lo*Io-Fo*Bo;function Yo(t){if(t instanceof $o)return new $o(t.h,t.s,t.l,t.opacity);t instanceof ar||(t=rr(t));var e=t.r/255,n=t.g/255,r=t.b/255,i=(zo*r+Po*e-jo*n)/(zo+Po-jo),a=r-i,o=(Ro*(n-i)-Io*a)/Fo,s=Math.sqrt(o*o+a*a)/(Ro*i*(1-i)),c=s?Math.atan2(o,a)*po-120:NaN;return new $o(c<0?c+360:c,s,i,t.opacity)}function Uo(t,e,n,r){return 1===arguments.length?Yo(t):new $o(t,e,n,null==r?1:r)}function $o(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r;}Fn($o,Uo,Rn(Pn,{brighter:function(t){return t=null==t?zn:Math.pow(zn,t),new $o(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?jn:Math.pow(jn,t),new $o(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=isNaN(this.h)?0:(this.h+120)*fo,e=+this.l,n=isNaN(this.s)?0:this.s*e*(1-e),r=Math.cos(t),i=Math.sin(t);return new ar(255*(e+n*(Bo*r+Lo*i)),255*(e+n*(Io*r+Fo*i)),255*(e+n*(Ro*r)),this.opacity)}}));var Wo=Array.prototype.slice;function qo(t,e){return t-e}const Ho=t=>()=>t;function Vo(t,e){for(var n,r=-1,i=e.length;++r<i;)if(n=Go(t,e[r]))return n;return 0}function Go(t,e){for(var n=e[0],r=e[1],i=-1,a=0,o=t.length,s=o-1;a<o;s=a++){var c=t[a],l=c[0],u=c[1],h=t[s],f=h[0],d=h[1];if(Xo(c,h,e))return 0;u>r!=d>r&&n<(f-l)*(r-u)/(d-u)+l&&(i=-i);}return i}function Xo(t,e,n){var r,i,a,o;return function(t,e,n){return (e[0]-t[0])*(n[1]-t[1])==(n[0]-t[0])*(e[1]-t[1])}(t,e,n)&&(i=t[r=+(t[0]===e[0])],a=n[r],o=e[r],i<=a&&a<=o||o<=a&&a<=i)}function Zo(){}var Qo=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function Ko(){var t=1,e=1,n=rt,r=s;function i(t){var e=n(t);if(Array.isArray(e))e=e.slice().sort(qo);else {const n=_(t),r=et(n[0],n[1],e);e=J(Math.floor(n[0]/r)*r,Math.floor(n[1]/r-1)*r,e);}return e.map((e=>a(t,e)))}function a(n,i){var a=[],s=[];return function(n,r,i){var a,s,c,l,u,h,f=new Array,d=new Array;for(a=s=-1,l=n[0]>=r,Qo[l<<1].forEach(p);++a<t-1;)c=l,l=n[a+1]>=r,Qo[c|l<<1].forEach(p);for(Qo[l<<0].forEach(p);++s<e-1;){for(a=-1,l=n[s*t+t]>=r,u=n[s*t]>=r,Qo[l<<1|u<<2].forEach(p);++a<t-1;)c=l,l=n[s*t+t+a+1]>=r,h=u,u=n[s*t+a+1]>=r,Qo[c|l<<1|u<<2|h<<3].forEach(p);Qo[l|u<<3].forEach(p);}for(a=-1,u=n[s*t]>=r,Qo[u<<2].forEach(p);++a<t-1;)h=u,u=n[s*t+a+1]>=r,Qo[u<<2|h<<3].forEach(p);function p(t){var e,n,r=[t[0][0]+a,t[0][1]+s],c=[t[1][0]+a,t[1][1]+s],l=o(r),u=o(c);(e=d[l])?(n=f[u])?(delete d[e.end],delete f[n.start],e===n?(e.ring.push(c),i(e.ring)):f[e.start]=d[n.end]={start:e.start,end:n.end,ring:e.ring.concat(n.ring)}):(delete d[e.end],e.ring.push(c),d[e.end=u]=e):(e=f[u])?(n=d[l])?(delete f[e.start],delete d[n.end],e===n?(e.ring.push(c),i(e.ring)):f[n.start]=d[e.end]={start:n.start,end:e.end,ring:n.ring.concat(e.ring)}):(delete f[e.start],e.ring.unshift(r),f[e.start=l]=e):f[l]=d[u]={start:l,end:u,ring:[r,c]};}Qo[u<<3].forEach(p);}(n,i,(function(t){r(t,n,i),function(t){for(var e=0,n=t.length,r=t[n-1][1]*t[0][0]-t[n-1][0]*t[0][1];++e<n;)r+=t[e-1][1]*t[e][0]-t[e-1][0]*t[e][1];return r}(t)>0?a.push([t]):s.push(t);})),s.forEach((function(t){for(var e,n=0,r=a.length;n<r;++n)if(-1!==Vo((e=a[n])[0],t))return void e.push(t)})),{type:"MultiPolygon",value:i,coordinates:a}}function o(e){return 2*e[0]+e[1]*(t+1)*4}function s(n,r,i){n.forEach((function(n){var a,o=n[0],s=n[1],c=0|o,l=0|s,u=r[l*t+c];o>0&&o<t&&c===o&&(a=r[l*t+c-1],n[0]=o+(i-a)/(u-a)-.5),s>0&&s<e&&l===s&&(a=r[(l-1)*t+c],n[1]=s+(i-a)/(u-a)-.5);}));}return i.contour=a,i.size=function(n){if(!arguments.length)return [t,e];var r=Math.floor(n[0]),a=Math.floor(n[1]);if(!(r>=0&&a>=0))throw new Error("invalid size");return t=r,e=a,i},i.thresholds=function(t){return arguments.length?(n="function"==typeof t?t:Array.isArray(t)?Ho(Wo.call(t)):Ho(t),i):n},i.smooth=function(t){return arguments.length?(r=t?s:Zo,i):r===s},i}function Jo(t,e,n){for(var r=t.width,i=t.height,a=1+(n<<1),o=0;o<i;++o)for(var s=0,c=0;s<r+n;++s)s<r&&(c+=t.data[s+o*r]),s>=n&&(s>=a&&(c-=t.data[s-a+o*r]),e.data[s-n+o*r]=c/Math.min(s+1,r-1+a-s,a));}function ts(t,e,n){for(var r=t.width,i=t.height,a=1+(n<<1),o=0;o<r;++o)for(var s=0,c=0;s<i+n;++s)s<i&&(c+=t.data[o+s*r]),s>=n&&(s>=a&&(c-=t.data[o+(s-a)*r]),e.data[o+(s-n)*r]=c/Math.min(s+1,i-1+a-s,a));}function es(t){return t[0]}function ns(t){return t[1]}function rs(){return 1}function is(){var t=es,e=ns,n=rs,r=960,i=500,a=20,o=2,s=3*a,c=r+2*s>>o,l=i+2*s>>o,u=Ho(20);function h(r){var i=new Float32Array(c*l),h=new Float32Array(c*l),d=Math.pow(2,-o);r.forEach((function(r,a,o){var u=(t(r,a,o)+s)*d,h=(e(r,a,o)+s)*d,f=+n(r,a,o);if(u>=0&&u<c&&h>=0&&h<l){var p=Math.floor(u),g=Math.floor(h),y=u-p-.5,m=h-g-.5;i[p+g*c]+=(1-y)*(1-m)*f,i[p+1+g*c]+=y*(1-m)*f,i[p+1+(g+1)*c]+=y*m*f,i[p+(g+1)*c]+=(1-y)*m*f;}})),Jo({width:c,height:l,data:i},{width:c,height:l,data:h},a>>o),ts({width:c,height:l,data:h},{width:c,height:l,data:i},a>>o),Jo({width:c,height:l,data:i},{width:c,height:l,data:h},a>>o),ts({width:c,height:l,data:h},{width:c,height:l,data:i},a>>o),Jo({width:c,height:l,data:i},{width:c,height:l,data:h},a>>o),ts({width:c,height:l,data:h},{width:c,height:l,data:i},a>>o);var p=u(i);if(!Array.isArray(p)){var g=at(i);p=et(0,g,p),(p=xt(0,Math.floor(g/p)*p,p)).shift();}return Ko().thresholds(p).size([c,l])(i).map(f)}function f(t){return t.value*=Math.pow(2,-2*o),t.coordinates.forEach(d),t}function d(t){t.forEach(p);}function p(t){t.forEach(g);}function g(t){t[0]=t[0]*Math.pow(2,o)-s,t[1]=t[1]*Math.pow(2,o)-s;}function y(){return c=r+2*(s=3*a)>>o,l=i+2*s>>o,h}return h.x=function(e){return arguments.length?(t="function"==typeof e?e:Ho(+e),h):t},h.y=function(t){return arguments.length?(e="function"==typeof t?t:Ho(+t),h):e},h.weight=function(t){return arguments.length?(n="function"==typeof t?t:Ho(+t),h):n},h.size=function(t){if(!arguments.length)return [r,i];var e=+t[0],n=+t[1];if(!(e>=0&&n>=0))throw new Error("invalid size");return r=e,i=n,y()},h.cellSize=function(t){if(!arguments.length)return 1<<o;if(!((t=+t)>=1))throw new Error("invalid cell size");return o=Math.floor(Math.log(t)/Math.LN2),y()},h.thresholds=function(t){return arguments.length?(u="function"==typeof t?t:Array.isArray(t)?Ho(Wo.call(t)):Ho(t),h):u},h.bandwidth=function(t){if(!arguments.length)return Math.sqrt(a*(a+1));if(!((t=+t)>=0))throw new Error("invalid bandwidth");return a=Math.round((Math.sqrt(4*t*t+1)-1)/2),y()},h}const as=134217729;function os(t,e,n,r,i){let a,o,s,c,l=e[0],u=r[0],h=0,f=0;u>l==u>-l?(a=l,l=e[++h]):(a=u,u=r[++f]);let d=0;if(h<t&&f<n)for(u>l==u>-l?(o=l+a,s=a-(o-l),l=e[++h]):(o=u+a,s=a-(o-u),u=r[++f]),a=o,0!==s&&(i[d++]=s);h<t&&f<n;)u>l==u>-l?(o=a+l,c=o-a,s=a-(o-c)+(l-c),l=e[++h]):(o=a+u,c=o-a,s=a-(o-c)+(u-c),u=r[++f]),a=o,0!==s&&(i[d++]=s);for(;h<t;)o=a+l,c=o-a,s=a-(o-c)+(l-c),l=e[++h],a=o,0!==s&&(i[d++]=s);for(;f<n;)o=a+u,c=o-a,s=a-(o-c)+(u-c),u=r[++f],a=o,0!==s&&(i[d++]=s);return 0===a&&0!==d||(i[d++]=a),d}function ss(t){return new Float64Array(t)}const cs=ss(4),ls=ss(8),us=ss(12),hs=ss(16),fs=ss(4);function ds(t,e,n,r,i,a){const o=(e-a)*(n-i),s=(t-i)*(r-a),c=o-s;if(0===o||0===s||o>0!=s>0)return c;const l=Math.abs(o+s);return Math.abs(c)>=33306690738754716e-32*l?c:-function(t,e,n,r,i,a,o){let s,c,l,u,h,f,d,p,g,y,m,b,v,_,x,k,w,T;const E=t-i,C=n-i,S=e-a,A=r-a;_=E*A,f=as*E,d=f-(f-E),p=E-d,f=as*A,g=f-(f-A),y=A-g,x=p*y-(_-d*g-p*g-d*y),k=S*C,f=as*S,d=f-(f-S),p=S-d,f=as*C,g=f-(f-C),y=C-g,w=p*y-(k-d*g-p*g-d*y),m=x-w,h=x-m,cs[0]=x-(m+h)+(h-w),b=_+m,h=b-_,v=_-(b-h)+(m-h),m=v-k,h=v-m,cs[1]=v-(m+h)+(h-k),T=b+m,h=T-b,cs[2]=b-(T-h)+(m-h),cs[3]=T;let M=function(t,e){let n=e[0];for(let t=1;t<4;t++)n+=e[t];return n}(0,cs),N=22204460492503146e-32*o;if(M>=N||-M>=N)return M;if(h=t-E,s=t-(E+h)+(h-i),h=n-C,l=n-(C+h)+(h-i),h=e-S,c=e-(S+h)+(h-a),h=r-A,u=r-(A+h)+(h-a),0===s&&0===c&&0===l&&0===u)return M;if(N=11093356479670487e-47*o+33306690738754706e-32*Math.abs(M),M+=E*u+A*s-(S*l+C*c),M>=N||-M>=N)return M;_=s*A,f=as*s,d=f-(f-s),p=s-d,f=as*A,g=f-(f-A),y=A-g,x=p*y-(_-d*g-p*g-d*y),k=c*C,f=as*c,d=f-(f-c),p=c-d,f=as*C,g=f-(f-C),y=C-g,w=p*y-(k-d*g-p*g-d*y),m=x-w,h=x-m,fs[0]=x-(m+h)+(h-w),b=_+m,h=b-_,v=_-(b-h)+(m-h),m=v-k,h=v-m,fs[1]=v-(m+h)+(h-k),T=b+m,h=T-b,fs[2]=b-(T-h)+(m-h),fs[3]=T;const O=os(4,cs,4,fs,ls);_=E*u,f=as*E,d=f-(f-E),p=E-d,f=as*u,g=f-(f-u),y=u-g,x=p*y-(_-d*g-p*g-d*y),k=S*l,f=as*S,d=f-(f-S),p=S-d,f=as*l,g=f-(f-l),y=l-g,w=p*y-(k-d*g-p*g-d*y),m=x-w,h=x-m,fs[0]=x-(m+h)+(h-w),b=_+m,h=b-_,v=_-(b-h)+(m-h),m=v-k,h=v-m,fs[1]=v-(m+h)+(h-k),T=b+m,h=T-b,fs[2]=b-(T-h)+(m-h),fs[3]=T;const D=os(O,ls,4,fs,us);_=s*u,f=as*s,d=f-(f-s),p=s-d,f=as*u,g=f-(f-u),y=u-g,x=p*y-(_-d*g-p*g-d*y),k=c*l,f=as*c,d=f-(f-c),p=c-d,f=as*l,g=f-(f-l),y=l-g,w=p*y-(k-d*g-p*g-d*y),m=x-w,h=x-m,fs[0]=x-(m+h)+(h-w),b=_+m,h=b-_,v=_-(b-h)+(m-h),m=v-k,h=v-m,fs[1]=v-(m+h)+(h-k),T=b+m,h=T-b,fs[2]=b-(T-h)+(m-h),fs[3]=T;const B=os(D,us,4,fs,hs);return hs[B-1]}(t,e,n,r,i,a,l)}const ps=Math.pow(2,-52),gs=new Uint32Array(512);class ys{static from(t,e=ks,n=ws){const r=t.length,i=new Float64Array(2*r);for(let a=0;a<r;a++){const r=t[a];i[2*a]=e(r),i[2*a+1]=n(r);}return new ys(i)}constructor(t){const e=t.length>>1;if(e>0&&"number"!=typeof t[0])throw new Error("Expected coords to contain numbers.");this.coords=t;const n=Math.max(2*e-5,0);this._triangles=new Uint32Array(3*n),this._halfedges=new Int32Array(3*n),this._hashSize=Math.ceil(Math.sqrt(e)),this._hullPrev=new Uint32Array(e),this._hullNext=new Uint32Array(e),this._hullTri=new Uint32Array(e),this._hullHash=new Int32Array(this._hashSize).fill(-1),this._ids=new Uint32Array(e),this._dists=new Float64Array(e),this.update();}update(){const{coords:t,_hullPrev:e,_hullNext:n,_hullTri:r,_hullHash:i}=this,a=t.length>>1;let o=1/0,s=1/0,c=-1/0,l=-1/0;for(let e=0;e<a;e++){const n=t[2*e],r=t[2*e+1];n<o&&(o=n),r<s&&(s=r),n>c&&(c=n),r>l&&(l=r),this._ids[e]=e;}const u=(o+c)/2,h=(s+l)/2;let f,d,p,g=1/0;for(let e=0;e<a;e++){const n=ms(u,h,t[2*e],t[2*e+1]);n<g&&(f=e,g=n);}const y=t[2*f],m=t[2*f+1];g=1/0;for(let e=0;e<a;e++){if(e===f)continue;const n=ms(y,m,t[2*e],t[2*e+1]);n<g&&n>0&&(d=e,g=n);}let b=t[2*d],v=t[2*d+1],_=1/0;for(let e=0;e<a;e++){if(e===f||e===d)continue;const n=vs(y,m,b,v,t[2*e],t[2*e+1]);n<_&&(p=e,_=n);}let x=t[2*p],k=t[2*p+1];if(_===1/0){for(let e=0;e<a;e++)this._dists[e]=t[2*e]-t[0]||t[2*e+1]-t[1];_s(this._ids,this._dists,0,a-1);const e=new Uint32Array(a);let n=0;for(let t=0,r=-1/0;t<a;t++){const i=this._ids[t];this._dists[i]>r&&(e[n++]=i,r=this._dists[i]);}return this.hull=e.subarray(0,n),this.triangles=new Uint32Array(0),void(this.halfedges=new Uint32Array(0))}if(ds(y,m,b,v,x,k)<0){const t=d,e=b,n=v;d=p,b=x,v=k,p=t,x=e,k=n;}const w=function(t,e,n,r,i,a){const o=n-t,s=r-e,c=i-t,l=a-e,u=o*o+s*s,h=c*c+l*l,f=.5/(o*l-s*c);return {x:t+(l*u-s*h)*f,y:e+(o*h-c*u)*f}}(y,m,b,v,x,k);this._cx=w.x,this._cy=w.y;for(let e=0;e<a;e++)this._dists[e]=ms(t[2*e],t[2*e+1],w.x,w.y);_s(this._ids,this._dists,0,a-1),this._hullStart=f;let T=3;n[f]=e[p]=d,n[d]=e[f]=p,n[p]=e[d]=f,r[f]=0,r[d]=1,r[p]=2,i.fill(-1),i[this._hashKey(y,m)]=f,i[this._hashKey(b,v)]=d,i[this._hashKey(x,k)]=p,this.trianglesLen=0,this._addTriangle(f,d,p,-1,-1,-1);for(let a,o,s=0;s<this._ids.length;s++){const c=this._ids[s],l=t[2*c],u=t[2*c+1];if(s>0&&Math.abs(l-a)<=ps&&Math.abs(u-o)<=ps)continue;if(a=l,o=u,c===f||c===d||c===p)continue;let h=0;for(let t=0,e=this._hashKey(l,u);t<this._hashSize&&(h=i[(e+t)%this._hashSize],-1===h||h===n[h]);t++);h=e[h];let g,y=h;for(;g=n[y],ds(l,u,t[2*y],t[2*y+1],t[2*g],t[2*g+1])>=0;)if(y=g,y===h){y=-1;break}if(-1===y)continue;let m=this._addTriangle(y,c,n[y],-1,-1,r[y]);r[c]=this._legalize(m+2),r[y]=m,T++;let b=n[y];for(;g=n[b],ds(l,u,t[2*b],t[2*b+1],t[2*g],t[2*g+1])<0;)m=this._addTriangle(b,c,g,r[c],-1,r[b]),r[c]=this._legalize(m+2),n[b]=b,T--,b=g;if(y===h)for(;g=e[y],ds(l,u,t[2*g],t[2*g+1],t[2*y],t[2*y+1])<0;)m=this._addTriangle(g,c,y,-1,r[y],r[g]),this._legalize(m+2),r[g]=m,n[y]=y,T--,y=g;this._hullStart=e[c]=y,n[y]=e[b]=c,n[c]=b,i[this._hashKey(l,u)]=c,i[this._hashKey(t[2*y],t[2*y+1])]=y;}this.hull=new Uint32Array(T);for(let t=0,e=this._hullStart;t<T;t++)this.hull[t]=e,e=n[e];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen);}_hashKey(t,e){return Math.floor(function(t,e){const n=t/(Math.abs(t)+Math.abs(e));return (e>0?3-n:1+n)/4}(t-this._cx,e-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:e,_halfedges:n,coords:r}=this;let i=0,a=0;for(;;){const o=n[t],s=t-t%3;if(a=s+(t+2)%3,-1===o){if(0===i)break;t=gs[--i];continue}const c=o-o%3,l=s+(t+1)%3,u=c+(o+2)%3,h=e[a],f=e[t],d=e[l],p=e[u];if(bs(r[2*h],r[2*h+1],r[2*f],r[2*f+1],r[2*d],r[2*d+1],r[2*p],r[2*p+1])){e[t]=p,e[o]=h;const r=n[u];if(-1===r){let e=this._hullStart;do{if(this._hullTri[e]===u){this._hullTri[e]=t;break}e=this._hullPrev[e];}while(e!==this._hullStart)}this._link(t,r),this._link(o,n[a]),this._link(a,u);const s=c+(o+1)%3;i<gs.length&&(gs[i++]=s);}else {if(0===i)break;t=gs[--i];}}return a}_link(t,e){this._halfedges[t]=e,-1!==e&&(this._halfedges[e]=t);}_addTriangle(t,e,n,r,i,a){const o=this.trianglesLen;return this._triangles[o]=t,this._triangles[o+1]=e,this._triangles[o+2]=n,this._link(o,r),this._link(o+1,i),this._link(o+2,a),this.trianglesLen+=3,o}}function ms(t,e,n,r){const i=t-n,a=e-r;return i*i+a*a}function bs(t,e,n,r,i,a,o,s){const c=t-o,l=e-s,u=n-o,h=r-s,f=i-o,d=a-s,p=u*u+h*h,g=f*f+d*d;return c*(h*g-p*d)-l*(u*g-p*f)+(c*c+l*l)*(u*d-h*f)<0}function vs(t,e,n,r,i,a){const o=n-t,s=r-e,c=i-t,l=a-e,u=o*o+s*s,h=c*c+l*l,f=.5/(o*l-s*c),d=(l*u-s*h)*f,p=(o*h-c*u)*f;return d*d+p*p}function _s(t,e,n,r){if(r-n<=20)for(let i=n+1;i<=r;i++){const r=t[i],a=e[r];let o=i-1;for(;o>=n&&e[t[o]]>a;)t[o+1]=t[o--];t[o+1]=r;}else {let i=n+1,a=r;xs(t,n+r>>1,i),e[t[n]]>e[t[r]]&&xs(t,n,r),e[t[i]]>e[t[r]]&&xs(t,i,r),e[t[n]]>e[t[i]]&&xs(t,n,i);const o=t[i],s=e[o];for(;;){do{i++;}while(e[t[i]]<s);do{a--;}while(e[t[a]]>s);if(a<i)break;xs(t,i,a);}t[n+1]=t[a],t[a]=o,r-i+1>=a-n?(_s(t,e,i,r),_s(t,e,n,a-1)):(_s(t,e,n,a-1),_s(t,e,i,r));}}function xs(t,e,n){const r=t[e];t[e]=t[n],t[n]=r;}function ks(t){return t[0]}function ws(t){return t[1]}const Ts=1e-6;class Es{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._="";}moveTo(t,e){this._+=`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}`;}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z");}lineTo(t,e){this._+=`L${this._x1=+t},${this._y1=+e}`;}arc(t,e,n){const r=(t=+t)+(n=+n),i=e=+e;if(n<0)throw new Error("negative radius");null===this._x1?this._+=`M${r},${i}`:(Math.abs(this._x1-r)>Ts||Math.abs(this._y1-i)>Ts)&&(this._+="L"+r+","+i),n&&(this._+=`A${n},${n},0,1,1,${t-n},${e}A${n},${n},0,1,1,${this._x1=r},${this._y1=i}`);}rect(t,e,n,r){this._+=`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${+n}v${+r}h${-n}Z`;}value(){return this._||null}}class Cs{constructor(){this._=[];}moveTo(t,e){this._.push([t,e]);}closePath(){this._.push(this._[0].slice());}lineTo(t,e){this._.push([t,e]);}value(){return this._.length?this._:null}}class Ss{constructor(t,[e,n,r,i]=[0,0,960,500]){if(!((r=+r)>=(e=+e)&&(i=+i)>=(n=+n)))throw new Error("invalid bounds");this.delaunay=t,this._circumcenters=new Float64Array(2*t.points.length),this.vectors=new Float64Array(2*t.points.length),this.xmax=r,this.xmin=e,this.ymax=i,this.ymin=n,this._init();}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:t,hull:e,triangles:n},vectors:r}=this,i=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let e,r,a=0,o=0,s=n.length;a<s;a+=3,o+=2){const s=2*n[a],c=2*n[a+1],l=2*n[a+2],u=t[s],h=t[s+1],f=t[c],d=t[c+1],p=t[l],g=t[l+1],y=f-u,m=d-h,b=p-u,v=g-h,_=2*(y*v-m*b);if(Math.abs(_)<1e-9){let i=1e9;const a=2*n[0];i*=Math.sign((t[a]-u)*v-(t[a+1]-h)*b),e=(u+p)/2-i*v,r=(h+g)/2+i*b;}else {const t=1/_,n=y*y+m*m,i=b*b+v*v;e=u+(v*n-m*i)*t,r=h+(y*i-b*n)*t;}i[o]=e,i[o+1]=r;}let a,o,s,c=e[e.length-1],l=4*c,u=t[2*c],h=t[2*c+1];r.fill(0);for(let n=0;n<e.length;++n)c=e[n],a=l,o=u,s=h,l=4*c,u=t[2*c],h=t[2*c+1],r[a+2]=r[l]=s-h,r[a+3]=r[l+1]=u-o;}render(t){const e=null==t?t=new Es:void 0,{delaunay:{halfedges:n,inedges:r,hull:i},circumcenters:a,vectors:o}=this;if(i.length<=1)return null;for(let e=0,r=n.length;e<r;++e){const r=n[e];if(r<e)continue;const i=2*Math.floor(e/3),o=2*Math.floor(r/3),s=a[i],c=a[i+1],l=a[o],u=a[o+1];this._renderSegment(s,c,l,u,t);}let s,c=i[i.length-1];for(let e=0;e<i.length;++e){s=c,c=i[e];const n=2*Math.floor(r[c]/3),l=a[n],u=a[n+1],h=4*s,f=this._project(l,u,o[h+2],o[h+3]);f&&this._renderSegment(l,u,f[0],f[1],t);}return e&&e.value()}renderBounds(t){const e=null==t?t=new Es:void 0;return t.rect(this.xmin,this.ymin,this.xmax-this.xmin,this.ymax-this.ymin),e&&e.value()}renderCell(t,e){const n=null==e?e=new Es:void 0,r=this._clip(t);if(null===r||!r.length)return;e.moveTo(r[0],r[1]);let i=r.length;for(;r[0]===r[i-2]&&r[1]===r[i-1]&&i>1;)i-=2;for(let t=2;t<i;t+=2)r[t]===r[t-2]&&r[t+1]===r[t-1]||e.lineTo(r[t],r[t+1]);return e.closePath(),n&&n.value()}*cellPolygons(){const{delaunay:{points:t}}=this;for(let e=0,n=t.length/2;e<n;++e){const t=this.cellPolygon(e);t&&(t.index=e,yield t);}}cellPolygon(t){const e=new Cs;return this.renderCell(t,e),e.value()}_renderSegment(t,e,n,r,i){let a;const o=this._regioncode(t,e),s=this._regioncode(n,r);0===o&&0===s?(i.moveTo(t,e),i.lineTo(n,r)):(a=this._clipSegment(t,e,n,r,o,s))&&(i.moveTo(a[0],a[1]),i.lineTo(a[2],a[3]));}contains(t,e,n){return (e=+e)==e&&(n=+n)==n&&this.delaunay._step(t,e,n)===t}*neighbors(t){const e=this._clip(t);if(e)for(const n of this.delaunay.neighbors(t)){const t=this._clip(n);if(t)t:for(let r=0,i=e.length;r<i;r+=2)for(let a=0,o=t.length;a<o;a+=2)if(e[r]==t[a]&&e[r+1]==t[a+1]&&e[(r+2)%i]==t[(a+o-2)%o]&&e[(r+3)%i]==t[(a+o-1)%o]){yield n;break t}}}_cell(t){const{circumcenters:e,delaunay:{inedges:n,halfedges:r,triangles:i}}=this,a=n[t];if(-1===a)return null;const o=[];let s=a;do{const n=Math.floor(s/3);if(o.push(e[2*n],e[2*n+1]),s=s%3==2?s-2:s+1,i[s]!==t)break;s=r[s];}while(s!==a&&-1!==s);return o}_clip(t){if(0===t&&1===this.delaunay.hull.length)return [this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];const e=this._cell(t);if(null===e)return null;const{vectors:n}=this,r=4*t;return n[r]||n[r+1]?this._clipInfinite(t,e,n[r],n[r+1],n[r+2],n[r+3]):this._clipFinite(t,e)}_clipFinite(t,e){const n=e.length;let r,i,a,o,s=null,c=e[n-2],l=e[n-1],u=this._regioncode(c,l),h=0;for(let f=0;f<n;f+=2)if(r=c,i=l,c=e[f],l=e[f+1],a=u,u=this._regioncode(c,l),0===a&&0===u)o=h,h=0,s?s.push(c,l):s=[c,l];else {let e,n,f,d,p;if(0===a){if(null===(e=this._clipSegment(r,i,c,l,a,u)))continue;[n,f,d,p]=e;}else {if(null===(e=this._clipSegment(c,l,r,i,u,a)))continue;[d,p,n,f]=e,o=h,h=this._edgecode(n,f),o&&h&&this._edge(t,o,h,s,s.length),s?s.push(n,f):s=[n,f];}o=h,h=this._edgecode(d,p),o&&h&&this._edge(t,o,h,s,s.length),s?s.push(d,p):s=[d,p];}if(s)o=h,h=this._edgecode(s[0],s[1]),o&&h&&this._edge(t,o,h,s,s.length);else if(this.contains(t,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2))return [this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];return s}_clipSegment(t,e,n,r,i,a){for(;;){if(0===i&&0===a)return [t,e,n,r];if(i&a)return null;let o,s,c=i||a;8&c?(o=t+(n-t)*(this.ymax-e)/(r-e),s=this.ymax):4&c?(o=t+(n-t)*(this.ymin-e)/(r-e),s=this.ymin):2&c?(s=e+(r-e)*(this.xmax-t)/(n-t),o=this.xmax):(s=e+(r-e)*(this.xmin-t)/(n-t),o=this.xmin),i?(t=o,e=s,i=this._regioncode(t,e)):(n=o,r=s,a=this._regioncode(n,r));}}_clipInfinite(t,e,n,r,i,a){let o,s=Array.from(e);if((o=this._project(s[0],s[1],n,r))&&s.unshift(o[0],o[1]),(o=this._project(s[s.length-2],s[s.length-1],i,a))&&s.push(o[0],o[1]),s=this._clipFinite(t,s))for(let e,n=0,r=s.length,i=this._edgecode(s[r-2],s[r-1]);n<r;n+=2)e=i,i=this._edgecode(s[n],s[n+1]),e&&i&&(n=this._edge(t,e,i,s,n),r=s.length);else this.contains(t,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2)&&(s=[this.xmin,this.ymin,this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax]);return s}_edge(t,e,n,r,i){for(;e!==n;){let n,a;switch(e){case 5:e=4;continue;case 4:e=6,n=this.xmax,a=this.ymin;break;case 6:e=2;continue;case 2:e=10,n=this.xmax,a=this.ymax;break;case 10:e=8;continue;case 8:e=9,n=this.xmin,a=this.ymax;break;case 9:e=1;continue;case 1:e=5,n=this.xmin,a=this.ymin;}r[i]===n&&r[i+1]===a||!this.contains(t,n,a)||(r.splice(i,0,n,a),i+=2);}if(r.length>4)for(let t=0;t<r.length;t+=2){const e=(t+2)%r.length,n=(t+4)%r.length;(r[t]===r[e]&&r[e]===r[n]||r[t+1]===r[e+1]&&r[e+1]===r[n+1])&&(r.splice(e,2),t-=2);}return i}_project(t,e,n,r){let i,a,o,s=1/0;if(r<0){if(e<=this.ymin)return null;(i=(this.ymin-e)/r)<s&&(o=this.ymin,a=t+(s=i)*n);}else if(r>0){if(e>=this.ymax)return null;(i=(this.ymax-e)/r)<s&&(o=this.ymax,a=t+(s=i)*n);}if(n>0){if(t>=this.xmax)return null;(i=(this.xmax-t)/n)<s&&(a=this.xmax,o=e+(s=i)*r);}else if(n<0){if(t<=this.xmin)return null;(i=(this.xmin-t)/n)<s&&(a=this.xmin,o=e+(s=i)*r);}return [a,o]}_edgecode(t,e){return (t===this.xmin?1:t===this.xmax?2:0)|(e===this.ymin?4:e===this.ymax?8:0)}_regioncode(t,e){return (t<this.xmin?1:t>this.xmax?2:0)|(e<this.ymin?4:e>this.ymax?8:0)}}const As=2*Math.PI,Ms=Math.pow;function Ns(t){return t[0]}function Os(t){return t[1]}function Ds(t,e,n){return [t+Math.sin(t+e)*n,e+Math.cos(t-e)*n]}class Bs{static from(t,e=Ns,n=Os,r){return new Bs("length"in t?function(t,e,n,r){const i=t.length,a=new Float64Array(2*i);for(let o=0;o<i;++o){const i=t[o];a[2*o]=e.call(r,i,o,t),a[2*o+1]=n.call(r,i,o,t);}return a}(t,e,n,r):Float64Array.from(function*(t,e,n,r){let i=0;for(const a of t)yield e.call(r,a,i,t),yield n.call(r,a,i,t),++i;}(t,e,n,r)))}constructor(t){this._delaunator=new ys(t),this.inedges=new Int32Array(t.length/2),this._hullIndex=new Int32Array(t.length/2),this.points=this._delaunator.coords,this._init();}update(){return this._delaunator.update(),this._init(),this}_init(){const t=this._delaunator,e=this.points;if(t.hull&&t.hull.length>2&&function(t){const{triangles:e,coords:n}=t;for(let t=0;t<e.length;t+=3){const r=2*e[t],i=2*e[t+1],a=2*e[t+2];if((n[a]-n[r])*(n[i+1]-n[r+1])-(n[i]-n[r])*(n[a+1]-n[r+1])>1e-10)return !1}return !0}(t)){this.collinear=Int32Array.from({length:e.length/2},((t,e)=>e)).sort(((t,n)=>e[2*t]-e[2*n]||e[2*t+1]-e[2*n+1]));const t=this.collinear[0],n=this.collinear[this.collinear.length-1],r=[e[2*t],e[2*t+1],e[2*n],e[2*n+1]],i=1e-8*Math.hypot(r[3]-r[1],r[2]-r[0]);for(let t=0,n=e.length/2;t<n;++t){const n=Ds(e[2*t],e[2*t+1],i);e[2*t]=n[0],e[2*t+1]=n[1];}this._delaunator=new ys(e);}else delete this.collinear;const n=this.halfedges=this._delaunator.halfedges,r=this.hull=this._delaunator.hull,i=this.triangles=this._delaunator.triangles,a=this.inedges.fill(-1),o=this._hullIndex.fill(-1);for(let t=0,e=n.length;t<e;++t){const e=i[t%3==2?t-2:t+1];-1!==n[t]&&-1!==a[e]||(a[e]=t);}for(let t=0,e=r.length;t<e;++t)o[r[t]]=t;r.length<=2&&r.length>0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],a[r[0]]=1,2===r.length&&(a[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]));}voronoi(t){return new Ss(this,t)}*neighbors(t){const{inedges:e,hull:n,_hullIndex:r,halfedges:i,triangles:a,collinear:o}=this;if(o){const e=o.indexOf(t);return e>0&&(yield o[e-1]),void(e<o.length-1&&(yield o[e+1]))}const s=e[t];if(-1===s)return;let c=s,l=-1;do{if(yield l=a[c],c=c%3==2?c-2:c+1,a[c]!==t)return;if(c=i[c],-1===c){const e=n[(r[t]+1)%n.length];return void(e!==l&&(yield e))}}while(c!==s)}find(t,e,n=0){if((t=+t)!=t||(e=+e)!=e)return -1;const r=n;let i;for(;(i=this._step(n,t,e))>=0&&i!==n&&i!==r;)n=i;return i}_step(t,e,n){const{inedges:r,hull:i,_hullIndex:a,halfedges:o,triangles:s,points:c}=this;if(-1===r[t]||!c.length)return (t+1)%(c.length>>1);let l=t,u=Ms(e-c[2*t],2)+Ms(n-c[2*t+1],2);const h=r[t];let f=h;do{let r=s[f];const h=Ms(e-c[2*r],2)+Ms(n-c[2*r+1],2);if(h<u&&(u=h,l=r),f=f%3==2?f-2:f+1,s[f]!==t)break;if(f=o[f],-1===f){if(f=i[(a[t]+1)%i.length],f!==r&&Ms(e-c[2*f],2)+Ms(n-c[2*f+1],2)<u)return f;break}}while(f!==h);return l}render(t){const e=null==t?t=new Es:void 0,{points:n,halfedges:r,triangles:i}=this;for(let e=0,a=r.length;e<a;++e){const a=r[e];if(a<e)continue;const o=2*i[e],s=2*i[a];t.moveTo(n[o],n[o+1]),t.lineTo(n[s],n[s+1]);}return this.renderHull(t),e&&e.value()}renderPoints(t,e){void 0!==e||t&&"function"==typeof t.moveTo||(e=t,t=null),e=null==e?2:+e;const n=null==t?t=new Es:void 0,{points:r}=this;for(let n=0,i=r.length;n<i;n+=2){const i=r[n],a=r[n+1];t.moveTo(i+e,a),t.arc(i,a,e,0,As);}return n&&n.value()}renderHull(t){const e=null==t?t=new Es:void 0,{hull:n,points:r}=this,i=2*n[0],a=n.length;t.moveTo(r[i],r[i+1]);for(let e=1;e<a;++e){const i=2*n[e];t.lineTo(r[i],r[i+1]);}return t.closePath(),e&&e.value()}hullPolygon(){const t=new Cs;return this.renderHull(t),t.value()}renderTriangle(t,e){const n=null==e?e=new Es:void 0,{points:r,triangles:i}=this,a=2*i[t*=3],o=2*i[t+1],s=2*i[t+2];return e.moveTo(r[a],r[a+1]),e.lineTo(r[o],r[o+1]),e.lineTo(r[s],r[s+1]),e.closePath(),n&&n.value()}*trianglePolygons(){const{triangles:t}=this;for(let e=0,n=t.length/3;e<n;++e)yield this.trianglePolygon(e);}trianglePolygon(t){const e=new Cs;return this.renderTriangle(t,e),e.value()}}const Ls=t=>()=>t;function Is(t,{sourceEvent:e,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}});}function Fs(t){return !t.ctrlKey&&!t.button}function Rs(){return this.parentNode}function Ps(t,e){return null==e?{x:t.x,y:t.y}:e}function js(){return navigator.maxTouchPoints||"ontouchstart"in this}function zs(){var t,e,n,r,i=Fs,a=Rs,o=Ps,s=js,c={},l=fe("start","drag","end"),u=0,h=0;function f(t){t.on("mousedown.drag",d).filter(s).on("touchstart.drag",y).on("touchmove.drag",m,Nn).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)");}function d(o,s){if(!r&&i.call(this,o,s)){var c=v(this,a.call(this,o,s),o,s,"mouse");c&&(Mn(o.view).on("mousemove.drag",p,On).on("mouseup.drag",g,On),Ln(o.view),Dn(o),n=!1,t=o.clientX,e=o.clientY,c("start",o));}}function p(r){if(Bn(r),!n){var i=r.clientX-t,a=r.clientY-e;n=i*i+a*a>h;}c.mouse("drag",r);}function g(t){Mn(t.view).on("mousemove.drag mouseup.drag",null),In(t.view,n),Bn(t),c.mouse("end",t);}function y(t,e){if(i.call(this,t,e)){var n,r,o=t.changedTouches,s=a.call(this,t,e),c=o.length;for(n=0;n<c;++n)(r=v(this,s,t,e,o[n].identifier,o[n]))&&(Dn(t),r("start",t,o[n]));}}function m(t){var e,n,r=t.changedTouches,i=r.length;for(e=0;e<i;++e)(n=c[r[e].identifier])&&(Bn(t),n("drag",t,r[e]));}function b(t){var e,n,i=t.changedTouches,a=i.length;for(r&&clearTimeout(r),r=setTimeout((function(){r=null;}),500),e=0;e<a;++e)(n=c[i[e].identifier])&&(Dn(t),n("end",t,i[e]));}function v(t,e,n,r,i,a){var s,h,d,p=l.copy(),g=Rr(a||n,e);if(null!=(d=o.call(t,new Is("beforestart",{sourceEvent:n,target:f,identifier:i,active:u,x:g[0],y:g[1],dx:0,dy:0,dispatch:p}),r)))return s=d.x-g[0]||0,h=d.y-g[1]||0,function n(a,o,l){var y,m=g;switch(a){case"start":c[i]=n,y=u++;break;case"end":delete c[i],--u;case"drag":g=Rr(l||o,e),y=u;}p.call(a,t,new Is(a,{sourceEvent:o,subject:d,target:f,identifier:i,active:y,x:g[0]+s,y:g[1]+h,dx:g[0]-m[0],dy:g[1]-m[1],dispatch:p}),r);}}return f.filter=function(t){return arguments.length?(i="function"==typeof t?t:Ls(!!t),f):i},f.container=function(t){return arguments.length?(a="function"==typeof t?t:Ls(t),f):a},f.subject=function(t){return arguments.length?(o="function"==typeof t?t:Ls(t),f):o},f.touchable=function(t){return arguments.length?(s="function"==typeof t?t:Ls(!!t),f):s},f.on=function(){var t=l.on.apply(l,arguments);return t===l?f:t},f.clickDistance=function(t){return arguments.length?(h=(t=+t)*t,f):Math.sqrt(h)},f}Is.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};var Ys={},Us={};function $s(t){return new Function("d","return {"+t.map((function(t,e){return JSON.stringify(t)+": d["+e+'] || ""'})).join(",")+"}")}function Ws(t){var e=Object.create(null),n=[];return t.forEach((function(t){for(var r in t)r in e||n.push(e[r]=r);})),n}function qs(t,e){var n=t+"",r=n.length;return r<e?new Array(e-r+1).join(0)+n:n}function Hs(t){var e=new RegExp('["'+t+"\n\r]"),n=t.charCodeAt(0);function r(t,e){var r,i=[],a=t.length,o=0,s=0,c=a<=0,l=!1;function u(){if(c)return Us;if(l)return l=!1,Ys;var e,r,i=o;if(34===t.charCodeAt(i)){for(;o++<a&&34!==t.charCodeAt(o)||34===t.charCodeAt(++o););return (e=o)>=a?c=!0:10===(r=t.charCodeAt(o++))?l=!0:13===r&&(l=!0,10===t.charCodeAt(o)&&++o),t.slice(i+1,e-1).replace(/""/g,'"')}for(;o<a;){if(10===(r=t.charCodeAt(e=o++)))l=!0;else if(13===r)l=!0,10===t.charCodeAt(o)&&++o;else if(r!==n)continue;return t.slice(i,e)}return c=!0,t.slice(i,a)}for(10===t.charCodeAt(a-1)&&--a,13===t.charCodeAt(a-1)&&--a;(r=u())!==Us;){for(var h=[];r!==Ys&&r!==Us;)h.push(r),r=u();e&&null==(h=e(h,s++))||i.push(h);}return i}function i(e,n){return e.map((function(e){return n.map((function(t){return o(e[t])})).join(t)}))}function a(e){return e.map(o).join(t)}function o(t){return null==t?"":t instanceof Date?function(t){var e=t.getUTCHours(),n=t.getUTCMinutes(),r=t.getUTCSeconds(),i=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":function(t){return t<0?"-"+qs(-t,6):t>9999?"+"+qs(t,6):qs(t,4)}(t.getUTCFullYear())+"-"+qs(t.getUTCMonth()+1,2)+"-"+qs(t.getUTCDate(),2)+(i?"T"+qs(e,2)+":"+qs(n,2)+":"+qs(r,2)+"."+qs(i,3)+"Z":r?"T"+qs(e,2)+":"+qs(n,2)+":"+qs(r,2)+"Z":n||e?"T"+qs(e,2)+":"+qs(n,2)+"Z":"")}(t):e.test(t+="")?'"'+t.replace(/"/g,'""')+'"':t}return {parse:function(t,e){var n,i,a=r(t,(function(t,r){if(n)return n(t,r-1);i=t,n=e?function(t,e){var n=$s(t);return function(r,i){return e(n(r),i,t)}}(t,e):$s(t);}));return a.columns=i||[],a},parseRows:r,format:function(e,n){return null==n&&(n=Ws(e)),[n.map(o).join(t)].concat(i(e,n)).join("\n")},formatBody:function(t,e){return null==e&&(e=Ws(t)),i(t,e).join("\n")},formatRows:function(t){return t.map(a).join("\n")},formatRow:a,formatValue:o}}var Vs=Hs(","),Gs=Vs.parse,Xs=Vs.parseRows,Zs=Vs.format,Qs=Vs.formatBody,Ks=Vs.formatRows,Js=Vs.formatRow,tc=Vs.formatValue,ec=Hs("\t"),nc=ec.parse,rc=ec.parseRows,ic=ec.format,ac=ec.formatBody,oc=ec.formatRows,sc=ec.formatRow,cc=ec.formatValue;function lc(t){for(var e in t){var n,r,i=t[e].trim();if(i)if("true"===i)i=!0;else if("false"===i)i=!1;else if("NaN"===i)i=NaN;else if(isNaN(n=+i)){if(!(r=i.match(/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/)))continue;uc&&r[4]&&!r[7]&&(i=i.replace(/-/g,"/").replace(/T/," ")),i=new Date(i);}else i=n;else i=null;t[e]=i;}return t}const uc=new Date("2019-01-01T00:00").getHours()||new Date("2019-07-01T00:00").getHours(),hc=t=>+t;function fc(t){return t*t}function dc(t){return t*(2-t)}function pc(t){return ((t*=2)<=1?t*t:--t*(2-t)+1)/2}var gc=function t(e){function n(t){return Math.pow(t,e)}return e=+e,n.exponent=t,n}(3),yc=function t(e){function n(t){return 1-Math.pow(1-t,e)}return e=+e,n.exponent=t,n}(3),mc=function t(e){function n(t){return ((t*=2)<=1?Math.pow(t,e):2-Math.pow(2-t,e))/2}return e=+e,n.exponent=t,n}(3),bc=Math.PI,vc=bc/2;function _c(t){return 1==+t?1:1-Math.cos(t*vc)}function xc(t){return Math.sin(t*vc)}function kc(t){return (1-Math.cos(bc*t))/2}function wc(t){return 1.0009775171065494*(Math.pow(2,-10*t)-.0009765625)}function Tc(t){return wc(1-+t)}function Ec(t){return 1-wc(t)}function Cc(t){return ((t*=2)<=1?wc(1-t):2-wc(t-1))/2}function Sc(t){return 1-Math.sqrt(1-t*t)}function Ac(t){return Math.sqrt(1- --t*t)}function Mc(t){return ((t*=2)<=1?1-Math.sqrt(1-t*t):Math.sqrt(1-(t-=2)*t)+1)/2}var Nc=7.5625;function Oc(t){return 1-Dc(1-t)}function Dc(t){return (t=+t)<.36363636363636365?Nc*t*t:t<.7272727272727273?Nc*(t-=.5454545454545454)*t+.75:t<.9090909090909091?Nc*(t-=.8181818181818182)*t+.9375:Nc*(t-=.9545454545454546)*t+.984375}function Bc(t){return ((t*=2)<=1?1-Dc(1-t):Dc(t-1)+1)/2}var Lc=1.70158,Ic=function t(e){function n(t){return (t=+t)*t*(e*(t-1)+t)}return e=+e,n.overshoot=t,n}(Lc),Fc=function t(e){function n(t){return --t*t*((t+1)*e+t)+1}return e=+e,n.overshoot=t,n}(Lc),Rc=function t(e){function n(t){return ((t*=2)<1?t*t*((e+1)*t-e):(t-=2)*t*((e+1)*t+e)+2)/2}return e=+e,n.overshoot=t,n}(Lc),Pc=2*Math.PI,jc=function t(e,n){var r=Math.asin(1/(e=Math.max(1,e)))*(n/=Pc);function i(t){return e*wc(- --t)*Math.sin((r-t)/n)}return i.amplitude=function(e){return t(e,n*Pc)},i.period=function(n){return t(e,n)},i}(1,.3),zc=function t(e,n){var r=Math.asin(1/(e=Math.max(1,e)))*(n/=Pc);function i(t){return 1-e*wc(t=+t)*Math.sin((t+r)/n)}return i.amplitude=function(e){return t(e,n*Pc)},i.period=function(n){return t(e,n)},i}(1,.3),Yc=function t(e,n){var r=Math.asin(1/(e=Math.max(1,e)))*(n/=Pc);function i(t){return ((t=2*t-1)<0?e*wc(-t)*Math.sin((r-t)/n):2-e*wc(t)*Math.sin((r+t)/n))/2}return i.amplitude=function(e){return t(e,n*Pc)},i.period=function(n){return t(e,n)},i}(1,.3);function Uc(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);return t.blob()}function $c(t,e){return fetch(t,e).then(Uc)}function Wc(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);return t.arrayBuffer()}function qc(t,e){return fetch(t,e).then(Wc)}function Hc(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);return t.text()}function Vc(t,e){return fetch(t,e).then(Hc)}function Gc(t){return function(e,n,r){return 2===arguments.length&&"function"==typeof n&&(r=n,n=void 0),Vc(e,n).then((function(e){return t(e,r)}))}}function Xc(t,e,n,r){3===arguments.length&&"function"==typeof n&&(r=n,n=void 0);var i=Hs(t);return Vc(e,n).then((function(t){return i.parse(t,r)}))}var Zc=Gc(Gs),Qc=Gc(nc);function Kc(t,e){return new Promise((function(n,r){var i=new Image;for(var a in e)i[a]=e[a];i.onerror=r,i.onload=function(){n(i);},i.src=t;}))}function Jc(t){if(!t.ok)throw new Error(t.status+" "+t.statusText);if(204!==t.status&&205!==t.status)return t.json()}function tl(t,e){return fetch(t,e).then(Jc)}function el(t){return (e,n)=>Vc(e,n).then((e=>(new DOMParser).parseFromString(e,t)))}const nl=el("application/xml");var rl=el("text/html"),il=el("image/svg+xml");function al(t,e){var n,r=1;function i(){var i,a,o=n.length,s=0,c=0;for(i=0;i<o;++i)s+=(a=n[i]).x,c+=a.y;for(s=(s/o-t)*r,c=(c/o-e)*r,i=0;i<o;++i)(a=n[i]).x-=s,a.y-=c;}return null==t&&(t=0),null==e&&(e=0),i.initialize=function(t){n=t;},i.x=function(e){return arguments.length?(t=+e,i):t},i.y=function(t){return arguments.length?(e=+t,i):e},i.strength=function(t){return arguments.length?(r=+t,i):r},i}function ol(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,a,o,s,c,l,u,h,f,d=t._root,p={data:r},g=t._x0,y=t._y0,m=t._x1,b=t._y1;if(!d)return t._root=p,t;for(;d.length;)if((l=e>=(a=(g+m)/2))?g=a:m=a,(u=n>=(o=(y+b)/2))?y=o:b=o,i=d,!(d=d[h=u<<1|l]))return i[h]=p,t;if(s=+t._x.call(null,d.data),c=+t._y.call(null,d.data),e===s&&n===c)return p.next=d,i?i[h]=p:t._root=p,t;do{i=i?i[h]=new Array(4):t._root=new Array(4),(l=e>=(a=(g+m)/2))?g=a:m=a,(u=n>=(o=(y+b)/2))?y=o:b=o;}while((h=u<<1|l)==(f=(c>=o)<<1|s>=a));return i[f]=d,i[h]=p,t}function sl(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i;}function cl(t){return t[0]}function ll(t){return t[1]}function ul(t,e,n){var r=new hl(null==e?cl:e,null==n?ll:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function hl(t,e,n,r,i,a){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=a,this._root=void 0;}function fl(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var dl=ul.prototype=hl.prototype;function pl(t){return function(){return t}}function gl(t){return 1e-6*(t()-.5)}function yl(t){return t.x+t.vx}function ml(t){return t.y+t.vy}function bl(t){var e,n,r,i=1,a=1;function o(){for(var t,o,c,l,u,h,f,d=e.length,p=0;p<a;++p)for(o=ul(e,yl,ml).visitAfter(s),t=0;t<d;++t)c=e[t],h=n[c.index],f=h*h,l=c.x+c.vx,u=c.y+c.vy,o.visit(g);function g(t,e,n,a,o){var s=t.data,d=t.r,p=h+d;if(!s)return e>l+p||a<l-p||n>u+p||o<u-p;if(s.index>c.index){var g=l-s.x-s.vx,y=u-s.y-s.vy,m=g*g+y*y;m<p*p&&(0===g&&(m+=(g=gl(r))*g),0===y&&(m+=(y=gl(r))*y),m=(p-(m=Math.sqrt(m)))/m*i,c.vx+=(g*=m)*(p=(d*=d)/(f+d)),c.vy+=(y*=m)*p,s.vx-=g*(p=1-p),s.vy-=y*p);}}}function s(t){if(t.data)return t.r=n[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r);}function c(){if(e){var r,i,a=e.length;for(n=new Array(a),r=0;r<a;++r)i=e[r],n[i.index]=+t(i,r,e);}}return "function"!=typeof t&&(t=pl(null==t?1:+t)),o.initialize=function(t,n){e=t,r=n,c();},o.iterations=function(t){return arguments.length?(a=+t,o):a},o.strength=function(t){return arguments.length?(i=+t,o):i},o.radius=function(e){return arguments.length?(t="function"==typeof e?e:pl(+e),c(),o):t},o}function vl(t){return t.index}function _l(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function xl(t){var e,n,r,i,a,o,s=vl,c=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},l=pl(30),u=1;function h(r){for(var i=0,s=t.length;i<u;++i)for(var c,l,h,f,d,p,g,y=0;y<s;++y)l=(c=t[y]).source,f=(h=c.target).x+h.vx-l.x-l.vx||gl(o),d=h.y+h.vy-l.y-l.vy||gl(o),f*=p=((p=Math.sqrt(f*f+d*d))-n[y])/p*r*e[y],d*=p,h.vx-=f*(g=a[y]),h.vy-=d*g,l.vx+=f*(g=1-g),l.vy+=d*g;}function f(){if(r){var o,c,l=r.length,u=t.length,h=new Map(r.map(((t,e)=>[s(t,e,r),t])));for(o=0,i=new Array(l);o<u;++o)(c=t[o]).index=o,"object"!=typeof c.source&&(c.source=_l(h,c.source)),"object"!=typeof c.target&&(c.target=_l(h,c.target)),i[c.source.index]=(i[c.source.index]||0)+1,i[c.target.index]=(i[c.target.index]||0)+1;for(o=0,a=new Array(u);o<u;++o)c=t[o],a[o]=i[c.source.index]/(i[c.source.index]+i[c.target.index]);e=new Array(u),d(),n=new Array(u),p();}}function d(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+c(t[n],n,t);}function p(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+l(t[e],e,t);}return null==t&&(t=[]),h.initialize=function(t,e){r=t,o=e,f();},h.links=function(e){return arguments.length?(t=e,f(),h):t},h.id=function(t){return arguments.length?(s=t,h):s},h.iterations=function(t){return arguments.length?(u=+t,h):u},h.strength=function(t){return arguments.length?(c="function"==typeof t?t:pl(+t),d(),h):c},h.distance=function(t){return arguments.length?(l="function"==typeof t?t:pl(+t),p(),h):l},h}dl.copy=function(){var t,e,n=new hl(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=fl(r),n;for(t=[{source:r,target:n._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(4)}):r.target[i]=fl(e));return n},dl.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return ol(this.cover(e,n),e,n,t)},dl.addAll=function(t){var e,n,r,i,a=t.length,o=new Array(a),s=new Array(a),c=1/0,l=1/0,u=-1/0,h=-1/0;for(n=0;n<a;++n)isNaN(r=+this._x.call(null,e=t[n]))||isNaN(i=+this._y.call(null,e))||(o[n]=r,s[n]=i,r<c&&(c=r),r>u&&(u=r),i<l&&(l=i),i>h&&(h=i));if(c>u||l>h)return this;for(this.cover(c,l).cover(u,h),n=0;n<a;++n)ol(this,o[n],s[n],t[n]);return this},dl.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,a=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,a=(r=Math.floor(e))+1;else {for(var o,s,c=i-n||1,l=this._root;n>t||t>=i||r>e||e>=a;)switch(s=(e<r)<<1|t<n,(o=new Array(4))[s]=l,l=o,c*=2,s){case 0:i=n+c,a=r+c;break;case 1:n=i-c,a=r+c;break;case 2:i=n+c,r=a-c;break;case 3:n=i-c,r=a-c;}this._root&&this._root.length&&(this._root=l);}return this._x0=n,this._y0=r,this._x1=i,this._y1=a,this},dl.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data);}while(e=e.next)})),t},dl.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},dl.find=function(t,e,n){var r,i,a,o,s,c,l,u=this._x0,h=this._y0,f=this._x1,d=this._y1,p=[],g=this._root;for(g&&p.push(new sl(g,u,h,f,d)),null==n?n=1/0:(u=t-n,h=e-n,f=t+n,d=e+n,n*=n);c=p.pop();)if(!(!(g=c.node)||(i=c.x0)>f||(a=c.y0)>d||(o=c.x1)<u||(s=c.y1)<h))if(g.length){var y=(i+o)/2,m=(a+s)/2;p.push(new sl(g[3],y,m,o,s),new sl(g[2],i,m,y,s),new sl(g[1],y,a,o,m),new sl(g[0],i,a,y,m)),(l=(e>=m)<<1|t>=y)&&(c=p[p.length-1],p[p.length-1]=p[p.length-1-l],p[p.length-1-l]=c);}else {var b=t-+this._x.call(null,g.data),v=e-+this._y.call(null,g.data),_=b*b+v*v;if(_<n){var x=Math.sqrt(n=_);u=t-x,h=e-x,f=t+x,d=e+x,r=g.data;}}return r},dl.remove=function(t){if(isNaN(a=+this._x.call(null,t))||isNaN(o=+this._y.call(null,t)))return this;var e,n,r,i,a,o,s,c,l,u,h,f,d=this._root,p=this._x0,g=this._y0,y=this._x1,m=this._y1;if(!d)return this;if(d.length)for(;;){if((l=a>=(s=(p+y)/2))?p=s:y=s,(u=o>=(c=(g+m)/2))?g=c:m=c,e=d,!(d=d[h=u<<1|l]))return this;if(!d.length)break;(e[h+1&3]||e[h+2&3]||e[h+3&3])&&(n=e,f=h);}for(;d.data!==t;)if(r=d,!(d=d.next))return this;return (i=d.next)&&delete d.next,r?(i?r.next=i:delete r.next,this):e?(i?e[h]=i:delete e[h],(d=e[0]||e[1]||e[2]||e[3])&&d===(e[3]||e[2]||e[1]||e[0])&&!d.length&&(n?n[f]=d:this._root=d),this):(this._root=i,this)},dl.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},dl.root=function(){return this._root},dl.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t;}while(e=e.next)})),t},dl.visit=function(t){var e,n,r,i,a,o,s=[],c=this._root;for(c&&s.push(new sl(c,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(c=e.node,r=e.x0,i=e.y0,a=e.x1,o=e.y1)&&c.length){var l=(r+a)/2,u=(i+o)/2;(n=c[3])&&s.push(new sl(n,l,u,a,o)),(n=c[2])&&s.push(new sl(n,r,u,l,o)),(n=c[1])&&s.push(new sl(n,l,i,a,u)),(n=c[0])&&s.push(new sl(n,r,i,l,u));}return this},dl.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new sl(this._root,this._x0,this._y0,this._x1,this._y1));e=n.pop();){var i=e.node;if(i.length){var a,o=e.x0,s=e.y0,c=e.x1,l=e.y1,u=(o+c)/2,h=(s+l)/2;(a=i[0])&&n.push(new sl(a,o,s,u,h)),(a=i[1])&&n.push(new sl(a,u,s,c,h)),(a=i[2])&&n.push(new sl(a,o,h,u,l)),(a=i[3])&&n.push(new sl(a,u,h,c,l));}r.push(e);}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},dl.x=function(t){return arguments.length?(this._x=t,this):this._x},dl.y=function(t){return arguments.length?(this._y=t,this):this._y};const kl=4294967296;function wl(t){return t.x}function Tl(t){return t.y}var El=Math.PI*(3-Math.sqrt(5));function Cl(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),a=0,o=.6,s=new Map,c=Qr(h),l=fe("tick","end"),u=function(){let t=1;return ()=>(t=(1664525*t+1013904223)%kl)/kl}();function h(){f(),l.call("tick",e),n<r&&(c.stop(),l.call("end",e));}function f(r){var c,l,u=t.length;void 0===r&&(r=1);for(var h=0;h<r;++h)for(n+=(a-n)*i,s.forEach((function(t){t(n);})),c=0;c<u;++c)null==(l=t[c]).fx?l.x+=l.vx*=o:(l.x=l.fx,l.vx=0),null==l.fy?l.y+=l.vy*=o:(l.y=l.fy,l.vy=0);return e}function d(){for(var e,n=0,r=t.length;n<r;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var i=10*Math.sqrt(.5+n),a=n*El;e.x=i*Math.cos(a),e.y=i*Math.sin(a);}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0);}}function p(e){return e.initialize&&e.initialize(t,u),e}return null==t&&(t=[]),d(),e={tick:f,restart:function(){return c.restart(h),e},stop:function(){return c.stop(),e},nodes:function(n){return arguments.length?(t=n,d(),s.forEach(p),e):t},alpha:function(t){return arguments.length?(n=+t,e):n},alphaMin:function(t){return arguments.length?(r=+t,e):r},alphaDecay:function(t){return arguments.length?(i=+t,e):+i},alphaTarget:function(t){return arguments.length?(a=+t,e):a},velocityDecay:function(t){return arguments.length?(o=1-t,e):1-o},randomSource:function(t){return arguments.length?(u=t,s.forEach(p),e):u},force:function(t,n){return arguments.length>1?(null==n?s.delete(t):s.set(t,p(n)),e):s.get(t)},find:function(e,n,r){var i,a,o,s,c,l=0,u=t.length;for(null==r?r=1/0:r*=r,l=0;l<u;++l)(o=(i=e-(s=t[l]).x)*i+(a=n-s.y)*a)<r&&(c=s,r=o);return c},on:function(t,n){return arguments.length>1?(l.on(t,n),e):l.on(t)}}}function Sl(){var t,e,n,r,i,a=pl(-30),o=1,s=1/0,c=.81;function l(n){var i,a=t.length,o=ul(t,wl,Tl).visitAfter(h);for(r=n,i=0;i<a;++i)e=t[i],o.visit(f);}function u(){if(t){var e,n,r=t.length;for(i=new Array(r),e=0;e<r;++e)n=t[e],i[n.index]=+a(n,e,t);}}function h(t){var e,n,r,a,o,s=0,c=0;if(t.length){for(r=a=o=0;o<4;++o)(e=t[o])&&(n=Math.abs(e.value))&&(s+=e.value,c+=n,r+=n*e.x,a+=n*e.y);t.x=r/c,t.y=a/c;}else {(e=t).x=e.data.x,e.y=e.data.y;do{s+=i[e.data.index];}while(e=e.next)}t.value=s;}function f(t,a,l,u){if(!t.value)return !0;var h=t.x-e.x,f=t.y-e.y,d=u-a,p=h*h+f*f;if(d*d/c<p)return p<s&&(0===h&&(p+=(h=gl(n))*h),0===f&&(p+=(f=gl(n))*f),p<o&&(p=Math.sqrt(o*p)),e.vx+=h*t.value*r/p,e.vy+=f*t.value*r/p),!0;if(!(t.length||p>=s)){(t.data!==e||t.next)&&(0===h&&(p+=(h=gl(n))*h),0===f&&(p+=(f=gl(n))*f),p<o&&(p=Math.sqrt(o*p)));do{t.data!==e&&(d=i[t.data.index]*r/p,e.vx+=h*d,e.vy+=f*d);}while(t=t.next)}}return l.initialize=function(e,r){t=e,n=r,u();},l.strength=function(t){return arguments.length?(a="function"==typeof t?t:pl(+t),u(),l):a},l.distanceMin=function(t){return arguments.length?(o=t*t,l):Math.sqrt(o)},l.distanceMax=function(t){return arguments.length?(s=t*t,l):Math.sqrt(s)},l.theta=function(t){return arguments.length?(c=t*t,l):Math.sqrt(c)},l}function Al(t,e,n){var r,i,a,o=pl(.1);function s(t){for(var o=0,s=r.length;o<s;++o){var c=r[o],l=c.x-e||1e-6,u=c.y-n||1e-6,h=Math.sqrt(l*l+u*u),f=(a[o]-h)*i[o]*t/h;c.vx+=l*f,c.vy+=u*f;}}function c(){if(r){var e,n=r.length;for(i=new Array(n),a=new Array(n),e=0;e<n;++e)a[e]=+t(r[e],e,r),i[e]=isNaN(a[e])?0:+o(r[e],e,r);}}return "function"!=typeof t&&(t=pl(+t)),null==e&&(e=0),null==n&&(n=0),s.initialize=function(t){r=t,c();},s.strength=function(t){return arguments.length?(o="function"==typeof t?t:pl(+t),c(),s):o},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:pl(+e),c(),s):t},s.x=function(t){return arguments.length?(e=+t,s):e},s.y=function(t){return arguments.length?(n=+t,s):n},s}function Ml(t){var e,n,r,i=pl(.1);function a(t){for(var i,a=0,o=e.length;a<o;++a)(i=e[a]).vx+=(r[a]-i.x)*n[a]*t;}function o(){if(e){var a,o=e.length;for(n=new Array(o),r=new Array(o),a=0;a<o;++a)n[a]=isNaN(r[a]=+t(e[a],a,e))?0:+i(e[a],a,e);}}return "function"!=typeof t&&(t=pl(null==t?0:+t)),a.initialize=function(t){e=t,o();},a.strength=function(t){return arguments.length?(i="function"==typeof t?t:pl(+t),o(),a):i},a.x=function(e){return arguments.length?(t="function"==typeof e?e:pl(+e),o(),a):t},a}function Nl(t){var e,n,r,i=pl(.1);function a(t){for(var i,a=0,o=e.length;a<o;++a)(i=e[a]).vy+=(r[a]-i.y)*n[a]*t;}function o(){if(e){var a,o=e.length;for(n=new Array(o),r=new Array(o),a=0;a<o;++a)n[a]=isNaN(r[a]=+t(e[a],a,e))?0:+i(e[a],a,e);}}return "function"!=typeof t&&(t=pl(null==t?0:+t)),a.initialize=function(t){e=t,o();},a.strength=function(t){return arguments.length?(i="function"==typeof t?t:pl(+t),o(),a):i},a.y=function(e){return arguments.length?(t="function"==typeof e?e:pl(+e),o(),a):t},a}function Ol(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return [r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function Dl(t){return (t=Ol(Math.abs(t)))?t[1]:NaN}var Bl,Ll=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Il(t){if(!(e=Ll.exec(t)))throw new Error("invalid format: "+t);var e;return new Fl({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}function Fl(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+"";}function Rl(t,e){var n=Ol(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}Il.prototype=Fl.prototype,Fl.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};const Pl={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Rl(100*t,e),r:Rl,s:function(t,e){var n=Ol(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(Bl=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,o=r.length;return a===o?r:a>o?r+new Array(a-o+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+Ol(t,Math.max(0,e+a-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function jl(t){return t}var zl,Yl,Ul,$l=Array.prototype.map,Wl=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function ql(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?jl:(e=$l.call(t.grouping,Number),n=t.thousands+"",function(t,r){for(var i=t.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(t.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(n)}),i=void 0===t.currency?"":t.currency[0]+"",a=void 0===t.currency?"":t.currency[1]+"",o=void 0===t.decimal?".":t.decimal+"",s=void 0===t.numerals?jl:function(t){return function(e){return e.replace(/[0-9]/g,(function(e){return t[+e]}))}}($l.call(t.numerals,String)),c=void 0===t.percent?"%":t.percent+"",l=void 0===t.minus?"−":t.minus+"",u=void 0===t.nan?"NaN":t.nan+"";function h(t){var e=(t=Il(t)).fill,n=t.align,h=t.sign,f=t.symbol,d=t.zero,p=t.width,g=t.comma,y=t.precision,m=t.trim,b=t.type;"n"===b?(g=!0,b="g"):Pl[b]||(void 0===y&&(y=12),m=!0,b="g"),(d||"0"===e&&"="===n)&&(d=!0,e="0",n="=");var v="$"===f?i:"#"===f&&/[boxX]/.test(b)?"0"+b.toLowerCase():"",_="$"===f?a:/[%p]/.test(b)?c:"",x=Pl[b],k=/[defgprs%]/.test(b);function w(t){var i,a,c,f=v,w=_;if("c"===b)w=x(t)+w,t="";else {var T=(t=+t)<0||1/t<0;if(t=isNaN(t)?u:x(Math.abs(t),y),m&&(t=function(t){t:for(var e,n=t.length,r=1,i=-1;r<n;++r)switch(t[r]){case".":i=e=r;break;case"0":0===i&&(i=r),e=r;break;default:if(!+t[r])break t;i>0&&(i=0);}return i>0?t.slice(0,i)+t.slice(e+1):t}(t)),T&&0==+t&&"+"!==h&&(T=!1),f=(T?"("===h?h:l:"-"===h||"("===h?"":h)+f,w=("s"===b?Wl[8+Bl/3]:"")+w+(T&&"("===h?")":""),k)for(i=-1,a=t.length;++i<a;)if(48>(c=t.charCodeAt(i))||c>57){w=(46===c?o+t.slice(i+1):t.slice(i))+w,t=t.slice(0,i);break}}g&&!d&&(t=r(t,1/0));var E=f.length+t.length+w.length,C=E<p?new Array(p-E+1).join(e):"";switch(g&&d&&(t=r(C+t,C.length?p-w.length:1/0),C=""),n){case"<":t=f+t+w+C;break;case"=":t=f+C+t+w;break;case"^":t=C.slice(0,E=C.length>>1)+f+t+w+C.slice(E);break;default:t=C+f+t+w;}return s(t)}return y=void 0===y?6:/[gprs]/.test(b)?Math.max(1,Math.min(21,y)):Math.max(0,Math.min(20,y)),w.toString=function(){return t+""},w}return {format:h,formatPrefix:function(t,e){var n=h(((t=Il(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Dl(e)/3))),i=Math.pow(10,-r),a=Wl[8+r/3];return function(t){return n(i*t)+a}}}}function Hl(t){return zl=ql(t),Yl=zl.format,Ul=zl.formatPrefix,zl}function Vl(t){return Math.max(0,-Dl(Math.abs(t)))}function Gl(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Dl(e)/3)))-Dl(Math.abs(t)))}function Xl(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Dl(e)-Dl(t))+1}Hl({thousands:",",grouping:[3],currency:["$",""]});var Zl=1e-6,Ql=1e-12,Kl=Math.PI,Jl=Kl/2,tu=Kl/4,eu=2*Kl,nu=180/Kl,ru=Kl/180,iu=Math.abs,au=Math.atan,ou=Math.atan2,su=Math.cos,cu=Math.ceil,lu=Math.exp,uu=(Math.hypot),hu=Math.log,fu=Math.pow,du=Math.sin,pu=Math.sign||function(t){return t>0?1:t<0?-1:0},gu=Math.sqrt,yu=Math.tan;function mu(t){return t>1?0:t<-1?Kl:Math.acos(t)}function bu(t){return t>1?Jl:t<-1?-Jl:Math.asin(t)}function vu(t){return (t=du(t/2))*t}function _u(){}function xu(t,e){t&&wu.hasOwnProperty(t.type)&&wu[t.type](t,e);}var ku={Feature:function(t,e){xu(t.geometry,e);},FeatureCollection:function(t,e){for(var n=t.features,r=-1,i=n.length;++r<i;)xu(n[r].geometry,e);}},wu={Sphere:function(t,e){e.sphere();},Point:function(t,e){t=t.coordinates,e.point(t[0],t[1],t[2]);},MultiPoint:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)t=n[r],e.point(t[0],t[1],t[2]);},LineString:function(t,e){Tu(t.coordinates,e,0);},MultiLineString:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)Tu(n[r],e,0);},Polygon:function(t,e){Eu(t.coordinates,e);},MultiPolygon:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)Eu(n[r],e);},GeometryCollection:function(t,e){for(var n=t.geometries,r=-1,i=n.length;++r<i;)xu(n[r],e);}};function Tu(t,e,n){var r,i=-1,a=t.length-n;for(e.lineStart();++i<a;)r=t[i],e.point(r[0],r[1],r[2]);e.lineEnd();}function Eu(t,e){var n=-1,r=t.length;for(e.polygonStart();++n<r;)Tu(t[n],e,1);e.polygonEnd();}function Cu(t,e){t&&ku.hasOwnProperty(t.type)?ku[t.type](t,e):xu(t,e);}var Su,Au,Mu,Nu,Ou,Du,Bu,Lu,Iu,Fu,Ru,Pu,ju,zu,Yu,Uu,$u=new x,Wu=new x,qu={point:_u,lineStart:_u,lineEnd:_u,polygonStart:function(){$u=new x,qu.lineStart=Hu,qu.lineEnd=Vu;},polygonEnd:function(){var t=+$u;Wu.add(t<0?eu+t:t),this.lineStart=this.lineEnd=this.point=_u;},sphere:function(){Wu.add(eu);}};function Hu(){qu.point=Gu;}function Vu(){Xu(Su,Au);}function Gu(t,e){qu.point=Xu,Su=t,Au=e,Mu=t*=ru,Nu=su(e=(e*=ru)/2+tu),Ou=du(e);}function Xu(t,e){var n=(t*=ru)-Mu,r=n>=0?1:-1,i=r*n,a=su(e=(e*=ru)/2+tu),o=du(e),s=Ou*o,c=Nu*a+s*su(i),l=s*r*du(i);$u.add(ou(l,c)),Mu=t,Nu=a,Ou=o;}function Zu(t){return Wu=new x,Cu(t,qu),2*Wu}function Qu(t){return [ou(t[1],t[0]),bu(t[2])]}function Ku(t){var e=t[0],n=t[1],r=su(n);return [r*su(e),r*du(e),du(n)]}function Ju(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function th(t,e){return [t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function eh(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2];}function nh(t,e){return [t[0]*e,t[1]*e,t[2]*e]}function rh(t){var e=gu(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e;}var ih,ah,oh,sh,ch,lh,uh,hh,fh,dh,ph,gh,yh,mh,bh,vh,_h={point:xh,lineStart:wh,lineEnd:Th,polygonStart:function(){_h.point=Eh,_h.lineStart=Ch,_h.lineEnd=Sh,zu=new x,qu.polygonStart();},polygonEnd:function(){qu.polygonEnd(),_h.point=xh,_h.lineStart=wh,_h.lineEnd=Th,$u<0?(Du=-(Lu=180),Bu=-(Iu=90)):zu>Zl?Iu=90:zu<-1e-6&&(Bu=-90),Uu[0]=Du,Uu[1]=Lu;},sphere:function(){Du=-(Lu=180),Bu=-(Iu=90);}};function xh(t,e){Yu.push(Uu=[Du=t,Lu=t]),e<Bu&&(Bu=e),e>Iu&&(Iu=e);}function kh(t,e){var n=Ku([t*ru,e*ru]);if(ju){var r=th(ju,n),i=th([r[1],-r[0],0],r);rh(i),i=Qu(i);var a,o=t-Fu,s=o>0?1:-1,c=i[0]*nu*s,l=iu(o)>180;l^(s*Fu<c&&c<s*t)?(a=i[1]*nu)>Iu&&(Iu=a):l^(s*Fu<(c=(c+360)%360-180)&&c<s*t)?(a=-i[1]*nu)<Bu&&(Bu=a):(e<Bu&&(Bu=e),e>Iu&&(Iu=e)),l?t<Fu?Ah(Du,t)>Ah(Du,Lu)&&(Lu=t):Ah(t,Lu)>Ah(Du,Lu)&&(Du=t):Lu>=Du?(t<Du&&(Du=t),t>Lu&&(Lu=t)):t>Fu?Ah(Du,t)>Ah(Du,Lu)&&(Lu=t):Ah(t,Lu)>Ah(Du,Lu)&&(Du=t);}else Yu.push(Uu=[Du=t,Lu=t]);e<Bu&&(Bu=e),e>Iu&&(Iu=e),ju=n,Fu=t;}function wh(){_h.point=kh;}function Th(){Uu[0]=Du,Uu[1]=Lu,_h.point=xh,ju=null;}function Eh(t,e){if(ju){var n=t-Fu;zu.add(iu(n)>180?n+(n>0?360:-360):n);}else Ru=t,Pu=e;qu.point(t,e),kh(t,e);}function Ch(){qu.lineStart();}function Sh(){Eh(Ru,Pu),qu.lineEnd(),iu(zu)>Zl&&(Du=-(Lu=180)),Uu[0]=Du,Uu[1]=Lu,ju=null;}function Ah(t,e){return (e-=t)<0?e+360:e}function Mh(t,e){return t[0]-e[0]}function Nh(t,e){return t[0]<=t[1]?t[0]<=e&&e<=t[1]:e<t[0]||t[1]<e}function Oh(t){var e,n,r,i,a,o,s;if(Iu=Lu=-(Du=Bu=1/0),Yu=[],Cu(t,_h),n=Yu.length){for(Yu.sort(Mh),e=1,a=[r=Yu[0]];e<n;++e)Nh(r,(i=Yu[e])[0])||Nh(r,i[1])?(Ah(r[0],i[1])>Ah(r[0],r[1])&&(r[1]=i[1]),Ah(i[0],r[1])>Ah(r[0],r[1])&&(r[0]=i[0])):a.push(r=i);for(o=-1/0,e=0,r=a[n=a.length-1];e<=n;r=i,++e)i=a[e],(s=Ah(r[1],i[0]))>o&&(o=s,Du=i[0],Lu=r[1]);}return Yu=Uu=null,Du===1/0||Bu===1/0?[[NaN,NaN],[NaN,NaN]]:[[Du,Bu],[Lu,Iu]]}var Dh={sphere:_u,point:Bh,lineStart:Ih,lineEnd:Ph,polygonStart:function(){Dh.lineStart=jh,Dh.lineEnd=zh;},polygonEnd:function(){Dh.lineStart=Ih,Dh.lineEnd=Ph;}};function Bh(t,e){t*=ru;var n=su(e*=ru);Lh(n*su(t),n*du(t),du(e));}function Lh(t,e,n){++ih,oh+=(t-oh)/ih,sh+=(e-sh)/ih,ch+=(n-ch)/ih;}function Ih(){Dh.point=Fh;}function Fh(t,e){t*=ru;var n=su(e*=ru);mh=n*su(t),bh=n*du(t),vh=du(e),Dh.point=Rh,Lh(mh,bh,vh);}function Rh(t,e){t*=ru;var n=su(e*=ru),r=n*su(t),i=n*du(t),a=du(e),o=ou(gu((o=bh*a-vh*i)*o+(o=vh*r-mh*a)*o+(o=mh*i-bh*r)*o),mh*r+bh*i+vh*a);ah+=o,lh+=o*(mh+(mh=r)),uh+=o*(bh+(bh=i)),hh+=o*(vh+(vh=a)),Lh(mh,bh,vh);}function Ph(){Dh.point=Bh;}function jh(){Dh.point=Yh;}function zh(){Uh(gh,yh),Dh.point=Bh;}function Yh(t,e){gh=t,yh=e,t*=ru,e*=ru,Dh.point=Uh;var n=su(e);mh=n*su(t),bh=n*du(t),vh=du(e),Lh(mh,bh,vh);}function Uh(t,e){t*=ru;var n=su(e*=ru),r=n*su(t),i=n*du(t),a=du(e),o=bh*a-vh*i,s=vh*r-mh*a,c=mh*i-bh*r,l=uu(o,s,c),u=bu(l),h=l&&-u/l;fh.add(h*o),dh.add(h*s),ph.add(h*c),ah+=u,lh+=u*(mh+(mh=r)),uh+=u*(bh+(bh=i)),hh+=u*(vh+(vh=a)),Lh(mh,bh,vh);}function $h(t){ih=ah=oh=sh=ch=lh=uh=hh=0,fh=new x,dh=new x,ph=new x,Cu(t,Dh);var e=+fh,n=+dh,r=+ph,i=uu(e,n,r);return i<Ql&&(e=lh,n=uh,r=hh,ah<Zl&&(e=oh,n=sh,r=ch),(i=uu(e,n,r))<Ql)?[NaN,NaN]:[ou(n,e)*nu,bu(r/i)*nu]}function Wh(t){return function(){return t}}function qh(t,e){function n(n,r){return n=t(n,r),e(n[0],n[1])}return t.invert&&e.invert&&(n.invert=function(n,r){return (n=e.invert(n,r))&&t.invert(n[0],n[1])}),n}function Hh(t,e){return [iu(t)>Kl?t+Math.round(-t/eu)*eu:t,e]}function Vh(t,e,n){return (t%=eu)?e||n?qh(Xh(t),Zh(e,n)):Xh(t):e||n?Zh(e,n):Hh}function Gh(t){return function(e,n){return [(e+=t)>Kl?e-eu:e<-Kl?e+eu:e,n]}}function Xh(t){var e=Gh(t);return e.invert=Gh(-t),e}function Zh(t,e){var n=su(t),r=du(t),i=su(e),a=du(e);function o(t,e){var o=su(e),s=su(t)*o,c=du(t)*o,l=du(e),u=l*n+s*r;return [ou(c*i-u*a,s*n-l*r),bu(u*i+c*a)]}return o.invert=function(t,e){var o=su(e),s=su(t)*o,c=du(t)*o,l=du(e),u=l*i-c*a;return [ou(c*i+l*a,s*n+u*r),bu(u*n-s*r)]},o}function Qh(t){function e(e){return (e=t(e[0]*ru,e[1]*ru))[0]*=nu,e[1]*=nu,e}return t=Vh(t[0]*ru,t[1]*ru,t.length>2?t[2]*ru:0),e.invert=function(e){return (e=t.invert(e[0]*ru,e[1]*ru))[0]*=nu,e[1]*=nu,e},e}function Kh(t,e,n,r,i,a){if(n){var o=su(e),s=du(e),c=r*n;null==i?(i=e+r*eu,a=e-c/2):(i=Jh(o,i),a=Jh(o,a),(r>0?i<a:i>a)&&(i+=r*eu));for(var l,u=i;r>0?u>a:u<a;u-=c)l=Qu([o,-s*su(u),-s*du(u)]),t.point(l[0],l[1]);}}function Jh(t,e){(e=Ku(e))[0]-=t,rh(e);var n=mu(-e[1]);return ((-e[2]<0?-n:n)+eu-Zl)%eu}function tf(){var t,e,n=Wh([0,0]),r=Wh(90),i=Wh(6),a={point:function(n,r){t.push(n=e(n,r)),n[0]*=nu,n[1]*=nu;}};function o(){var o=n.apply(this,arguments),s=r.apply(this,arguments)*ru,c=i.apply(this,arguments)*ru;return t=[],e=Vh(-o[0]*ru,-o[1]*ru,0).invert,Kh(a,s,c,1),o={type:"Polygon",coordinates:[t]},t=e=null,o}return o.center=function(t){return arguments.length?(n="function"==typeof t?t:Wh([+t[0],+t[1]]),o):n},o.radius=function(t){return arguments.length?(r="function"==typeof t?t:Wh(+t),o):r},o.precision=function(t){return arguments.length?(i="function"==typeof t?t:Wh(+t),o):i},o}function ef(){var t,e=[];return {point:function(e,n,r){t.push([e,n,r]);},lineStart:function(){e.push(t=[]);},lineEnd:_u,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()));},result:function(){var n=e;return e=[],t=null,n}}}function nf(t,e){return iu(t[0]-e[0])<Zl&&iu(t[1]-e[1])<Zl}function rf(t,e,n,r){this.x=t,this.z=e,this.o=n,this.e=r,this.v=!1,this.n=this.p=null;}function af(t,e,n,r,i){var a,o,s=[],c=[];if(t.forEach((function(t){if(!((e=t.length-1)<=0)){var e,n,r=t[0],o=t[e];if(nf(r,o)){if(!r[2]&&!o[2]){for(i.lineStart(),a=0;a<e;++a)i.point((r=t[a])[0],r[1]);return void i.lineEnd()}o[0]+=2e-6;}s.push(n=new rf(r,t,null,!0)),c.push(n.o=new rf(r,null,n,!1)),s.push(n=new rf(o,t,null,!1)),c.push(n.o=new rf(o,null,n,!0));}})),s.length){for(c.sort(e),of(s),of(c),a=0,o=c.length;a<o;++a)c[a].e=n=!n;for(var l,u,h=s[0];;){for(var f=h,d=!0;f.v;)if((f=f.n)===h)return;l=f.z,i.lineStart();do{if(f.v=f.o.v=!0,f.e){if(d)for(a=0,o=l.length;a<o;++a)i.point((u=l[a])[0],u[1]);else r(f.x,f.n.x,1,i);f=f.n;}else {if(d)for(l=f.p.z,a=l.length-1;a>=0;--a)i.point((u=l[a])[0],u[1]);else r(f.x,f.p.x,-1,i);f=f.p;}l=(f=f.o).z,d=!d;}while(!f.v);i.lineEnd();}}}function of(t){if(e=t.length){for(var e,n,r=0,i=t[0];++r<e;)i.n=n=t[r],n.p=i,i=n;i.n=n=t[0],n.p=i;}}function sf(t){return iu(t[0])<=Kl?t[0]:pu(t[0])*((iu(t[0])+Kl)%eu-Kl)}function cf(t,e){var n=sf(e),r=e[1],i=du(r),a=[du(n),-su(n),0],o=0,s=0,c=new x;1===i?r=Jl+Zl:-1===i&&(r=-Jl-Zl);for(var l=0,u=t.length;l<u;++l)if(f=(h=t[l]).length)for(var h,f,d=h[f-1],p=sf(d),g=d[1]/2+tu,y=du(g),m=su(g),b=0;b<f;++b,p=_,y=w,m=T,d=v){var v=h[b],_=sf(v),k=v[1]/2+tu,w=du(k),T=su(k),E=_-p,C=E>=0?1:-1,S=C*E,A=S>Kl,M=y*w;if(c.add(ou(M*C*du(S),m*T+M*su(S))),o+=A?E+C*eu:E,A^p>=n^_>=n){var N=th(Ku(d),Ku(v));rh(N);var O=th(a,N);rh(O);var D=(A^E>=0?-1:1)*bu(O[2]);(r>D||r===D&&(N[0]||N[1]))&&(s+=A^E>=0?1:-1);}}return (o<-1e-6||o<Zl&&c<-1e-12)^1&s}function lf(t,e,n,r){return function(i){var a,o,s,c=e(i),l=ef(),u=e(l),h=!1,f={point:d,lineStart:g,lineEnd:y,polygonStart:function(){f.point=m,f.lineStart=b,f.lineEnd=v,o=[],a=[];},polygonEnd:function(){f.point=d,f.lineStart=g,f.lineEnd=y,o=yt(o);var t=cf(a,r);o.length?(h||(i.polygonStart(),h=!0),af(o,hf,t,n,i)):t&&(h||(i.polygonStart(),h=!0),i.lineStart(),n(null,null,1,i),i.lineEnd()),h&&(i.polygonEnd(),h=!1),o=a=null;},sphere:function(){i.polygonStart(),i.lineStart(),n(null,null,1,i),i.lineEnd(),i.polygonEnd();}};function d(e,n){t(e,n)&&i.point(e,n);}function p(t,e){c.point(t,e);}function g(){f.point=p,c.lineStart();}function y(){f.point=d,c.lineEnd();}function m(t,e){s.push([t,e]),u.point(t,e);}function b(){u.lineStart(),s=[];}function v(){m(s[0][0],s[0][1]),u.lineEnd();var t,e,n,r,c=u.clean(),f=l.result(),d=f.length;if(s.pop(),a.push(s),s=null,d)if(1&c){if((e=(n=f[0]).length-1)>0){for(h||(i.polygonStart(),h=!0),i.lineStart(),t=0;t<e;++t)i.point((r=n[t])[0],r[1]);i.lineEnd();}}else d>1&&2&c&&f.push(f.pop().concat(f.shift())),o.push(f.filter(uf));}return f}}function uf(t){return t.length>1}function hf(t,e){return ((t=t.x)[0]<0?t[1]-Jl-Zl:Jl-t[1])-((e=e.x)[0]<0?e[1]-Jl-Zl:Jl-e[1])}Hh.invert=Hh;const ff=lf((function(){return !0}),(function(t){var e,n=NaN,r=NaN,i=NaN;return {lineStart:function(){t.lineStart(),e=1;},point:function(a,o){var s=a>0?Kl:-Kl,c=iu(a-n);iu(c-Kl)<Zl?(t.point(n,r=(r+o)/2>0?Jl:-Jl),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),t.point(a,r),e=0):i!==s&&c>=Kl&&(iu(n-i)<Zl&&(n-=i*Zl),iu(a-s)<Zl&&(a-=s*Zl),r=function(t,e,n,r){var i,a,o=du(t-n);return iu(o)>Zl?au((du(e)*(a=su(r))*du(n)-du(r)*(i=su(e))*du(t))/(i*a*o)):(e+r)/2}(n,r,a,o),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),e=0),t.point(n=a,r=o),i=s;},lineEnd:function(){t.lineEnd(),n=r=NaN;},clean:function(){return 2-e}}}),(function(t,e,n,r){var i;if(null==t)i=n*Jl,r.point(-Kl,i),r.point(0,i),r.point(Kl,i),r.point(Kl,0),r.point(Kl,-i),r.point(0,-i),r.point(-Kl,-i),r.point(-Kl,0),r.point(-Kl,i);else if(iu(t[0]-e[0])>Zl){var a=t[0]<e[0]?Kl:-Kl;i=n*a/2,r.point(-a,i),r.point(0,i),r.point(a,i);}else r.point(e[0],e[1]);}),[-Kl,-Jl]);function df(t){var e=su(t),n=6*ru,r=e>0,i=iu(e)>Zl;function a(t,n){return su(t)*su(n)>e}function o(t,n,r){var i=[1,0,0],a=th(Ku(t),Ku(n)),o=Ju(a,a),s=a[0],c=o-s*s;if(!c)return !r&&t;var l=e*o/c,u=-e*s/c,h=th(i,a),f=nh(i,l);eh(f,nh(a,u));var d=h,p=Ju(f,d),g=Ju(d,d),y=p*p-g*(Ju(f,f)-1);if(!(y<0)){var m=gu(y),b=nh(d,(-p-m)/g);if(eh(b,f),b=Qu(b),!r)return b;var v,_=t[0],x=n[0],k=t[1],w=n[1];x<_&&(v=_,_=x,x=v);var T=x-_,E=iu(T-Kl)<Zl;if(!E&&w<k&&(v=k,k=w,w=v),E||T<Zl?E?k+w>0^b[1]<(iu(b[0]-_)<Zl?k:w):k<=b[1]&&b[1]<=w:T>Kl^(_<=b[0]&&b[0]<=x)){var C=nh(d,(-p+m)/g);return eh(C,f),[b,Qu(C)]}}}function s(e,n){var i=r?t:Kl-t,a=0;return e<-i?a|=1:e>i&&(a|=2),n<-i?a|=4:n>i&&(a|=8),a}return lf(a,(function(t){var e,n,c,l,u;return {lineStart:function(){l=c=!1,u=1;},point:function(h,f){var d,p=[h,f],g=a(h,f),y=r?g?0:s(h,f):g?s(h+(h<0?Kl:-Kl),f):0;if(!e&&(l=c=g)&&t.lineStart(),g!==c&&(!(d=o(e,p))||nf(e,d)||nf(p,d))&&(p[2]=1),g!==c)u=0,g?(t.lineStart(),d=o(p,e),t.point(d[0],d[1])):(d=o(e,p),t.point(d[0],d[1],2),t.lineEnd()),e=d;else if(i&&e&&r^g){var m;y&n||!(m=o(p,e,!0))||(u=0,r?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1],3)));}!g||e&&nf(e,p)||t.point(p[0],p[1]),e=p,c=g,n=y;},lineEnd:function(){c&&t.lineEnd(),e=null;},clean:function(){return u|(l&&c)<<1}}}),(function(e,r,i,a){Kh(a,t,n,i,e,r);}),r?[0,-t]:[-Kl,t-Kl])}var pf,gf,yf,mf,bf=1e9,vf=-bf;function _f(t,e,n,r){function i(i,a){return t<=i&&i<=n&&e<=a&&a<=r}function a(i,a,s,l){var u=0,h=0;if(null==i||(u=o(i,s))!==(h=o(a,s))||c(i,a)<0^s>0)do{l.point(0===u||3===u?t:n,u>1?r:e);}while((u=(u+s+4)%4)!==h);else l.point(a[0],a[1]);}function o(r,i){return iu(r[0]-t)<Zl?i>0?0:3:iu(r[0]-n)<Zl?i>0?2:1:iu(r[1]-e)<Zl?i>0?1:0:i>0?3:2}function s(t,e){return c(t.x,e.x)}function c(t,e){var n=o(t,1),r=o(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(o){var c,l,u,h,f,d,p,g,y,m,b,v=o,_=ef(),x={point:k,lineStart:function(){x.point=w,l&&l.push(u=[]),m=!0,y=!1,p=g=NaN;},lineEnd:function(){c&&(w(h,f),d&&y&&_.rejoin(),c.push(_.result())),x.point=k,y&&v.lineEnd();},polygonStart:function(){v=_,c=[],l=[],b=!0;},polygonEnd:function(){var e=function(){for(var e=0,n=0,i=l.length;n<i;++n)for(var a,o,s=l[n],c=1,u=s.length,h=s[0],f=h[0],d=h[1];c<u;++c)a=f,o=d,f=(h=s[c])[0],d=h[1],o<=r?d>r&&(f-a)*(r-o)>(d-o)*(t-a)&&++e:d<=r&&(f-a)*(r-o)<(d-o)*(t-a)&&--e;return e}(),n=b&&e,i=(c=yt(c)).length;(n||i)&&(o.polygonStart(),n&&(o.lineStart(),a(null,null,1,o),o.lineEnd()),i&&af(c,s,e,a,o),o.polygonEnd()),v=o,c=l=u=null;}};function k(t,e){i(t,e)&&v.point(t,e);}function w(a,o){var s=i(a,o);if(l&&u.push([a,o]),m)h=a,f=o,d=s,m=!1,s&&(v.lineStart(),v.point(a,o));else if(s&&y)v.point(a,o);else {var c=[p=Math.max(vf,Math.min(bf,p)),g=Math.max(vf,Math.min(bf,g))],_=[a=Math.max(vf,Math.min(bf,a)),o=Math.max(vf,Math.min(bf,o))];!function(t,e,n,r,i,a){var o,s=t[0],c=t[1],l=0,u=1,h=e[0]-s,f=e[1]-c;if(o=n-s,h||!(o>0)){if(o/=h,h<0){if(o<l)return;o<u&&(u=o);}else if(h>0){if(o>u)return;o>l&&(l=o);}if(o=i-s,h||!(o<0)){if(o/=h,h<0){if(o>u)return;o>l&&(l=o);}else if(h>0){if(o<l)return;o<u&&(u=o);}if(o=r-c,f||!(o>0)){if(o/=f,f<0){if(o<l)return;o<u&&(u=o);}else if(f>0){if(o>u)return;o>l&&(l=o);}if(o=a-c,f||!(o<0)){if(o/=f,f<0){if(o>u)return;o>l&&(l=o);}else if(f>0){if(o<l)return;o<u&&(u=o);}return l>0&&(t[0]=s+l*h,t[1]=c+l*f),u<1&&(e[0]=s+u*h,e[1]=c+u*f),!0}}}}}(c,_,t,e,n,r)?s&&(v.lineStart(),v.point(a,o),b=!1):(y||(v.lineStart(),v.point(c[0],c[1])),v.point(_[0],_[1]),s||v.lineEnd(),b=!1);}p=a,g=o,y=s;}return x}}function xf(){var t,e,n,r=0,i=0,a=960,o=500;return n={stream:function(n){return t&&e===n?t:t=_f(r,i,a,o)(e=n)},extent:function(s){return arguments.length?(r=+s[0][0],i=+s[0][1],a=+s[1][0],o=+s[1][1],t=e=null,n):[[r,i],[a,o]]}}}var kf={sphere:_u,point:_u,lineStart:function(){kf.point=Tf,kf.lineEnd=wf;},lineEnd:_u,polygonStart:_u,polygonEnd:_u};function wf(){kf.point=kf.lineEnd=_u;}function Tf(t,e){gf=t*=ru,yf=du(e*=ru),mf=su(e),kf.point=Ef;}function Ef(t,e){t*=ru;var n=du(e*=ru),r=su(e),i=iu(t-gf),a=su(i),o=r*du(i),s=mf*n-yf*r*a,c=yf*n+mf*r*a;pf.add(ou(gu(o*o+s*s),c)),gf=t,yf=n,mf=r;}function Cf(t){return pf=new x,Cu(t,kf),+pf}var Sf=[null,null],Af={type:"LineString",coordinates:Sf};function Mf(t,e){return Sf[0]=t,Sf[1]=e,Cf(Af)}var Nf={Feature:function(t,e){return Df(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,i=n.length;++r<i;)if(Df(n[r].geometry,e))return !0;return !1}},Of={Sphere:function(){return !0},Point:function(t,e){return Bf(t.coordinates,e)},MultiPoint:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)if(Bf(n[r],e))return !0;return !1},LineString:function(t,e){return Lf(t.coordinates,e)},MultiLineString:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)if(Lf(n[r],e))return !0;return !1},Polygon:function(t,e){return If(t.coordinates,e)},MultiPolygon:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)if(If(n[r],e))return !0;return !1},GeometryCollection:function(t,e){for(var n=t.geometries,r=-1,i=n.length;++r<i;)if(Df(n[r],e))return !0;return !1}};function Df(t,e){return !(!t||!Of.hasOwnProperty(t.type))&&Of[t.type](t,e)}function Bf(t,e){return 0===Mf(t,e)}function Lf(t,e){for(var n,r,i,a=0,o=t.length;a<o;a++){if(0===(r=Mf(t[a],e)))return !0;if(a>0&&(i=Mf(t[a],t[a-1]))>0&&n<=i&&r<=i&&(n+r-i)*(1-Math.pow((n-r)/i,2))<Ql*i)return !0;n=r;}return !1}function If(t,e){return !!cf(t.map(Ff),Rf(e))}function Ff(t){return (t=t.map(Rf)).pop(),t}function Rf(t){return [t[0]*ru,t[1]*ru]}function Pf(t,e){return (t&&Nf.hasOwnProperty(t.type)?Nf[t.type]:Df)(t,e)}function jf(t,e,n){var r=xt(t,e-Zl,n).concat(e);return function(t){return r.map((function(e){return [t,e]}))}}function zf(t,e,n){var r=xt(t,e-Zl,n).concat(e);return function(t){return r.map((function(e){return [e,t]}))}}function Yf(){var t,e,n,r,i,a,o,s,c,l,u,h,f=10,d=f,p=90,g=360,y=2.5;function m(){return {type:"MultiLineString",coordinates:b()}}function b(){return xt(cu(r/p)*p,n,p).map(u).concat(xt(cu(s/g)*g,o,g).map(h)).concat(xt(cu(e/f)*f,t,f).filter((function(t){return iu(t%p)>Zl})).map(c)).concat(xt(cu(a/d)*d,i,d).filter((function(t){return iu(t%g)>Zl})).map(l))}return m.lines=function(){return b().map((function(t){return {type:"LineString",coordinates:t}}))},m.outline=function(){return {type:"Polygon",coordinates:[u(r).concat(h(o).slice(1),u(n).reverse().slice(1),h(s).reverse().slice(1))]}},m.extent=function(t){return arguments.length?m.extentMajor(t).extentMinor(t):m.extentMinor()},m.extentMajor=function(t){return arguments.length?(r=+t[0][0],n=+t[1][0],s=+t[0][1],o=+t[1][1],r>n&&(t=r,r=n,n=t),s>o&&(t=s,s=o,o=t),m.precision(y)):[[r,s],[n,o]]},m.extentMinor=function(n){return arguments.length?(e=+n[0][0],t=+n[1][0],a=+n[0][1],i=+n[1][1],e>t&&(n=e,e=t,t=n),a>i&&(n=a,a=i,i=n),m.precision(y)):[[e,a],[t,i]]},m.step=function(t){return arguments.length?m.stepMajor(t).stepMinor(t):m.stepMinor()},m.stepMajor=function(t){return arguments.length?(p=+t[0],g=+t[1],m):[p,g]},m.stepMinor=function(t){return arguments.length?(f=+t[0],d=+t[1],m):[f,d]},m.precision=function(f){return arguments.length?(y=+f,c=jf(a,i,90),l=zf(e,t,y),u=jf(s,o,90),h=zf(r,n,y),m):y},m.extentMajor([[-180,-89.999999],[180,89.999999]]).extentMinor([[-180,-80.000001],[180,80.000001]])}function Uf(){return Yf()()}function $f(t,e){var n=t[0]*ru,r=t[1]*ru,i=e[0]*ru,a=e[1]*ru,o=su(r),s=du(r),c=su(a),l=du(a),u=o*su(n),h=o*du(n),f=c*su(i),d=c*du(i),p=2*bu(gu(vu(a-r)+o*c*vu(i-n))),g=du(p),y=p?function(t){var e=du(t*=p)/g,n=du(p-t)/g,r=n*u+e*f,i=n*h+e*d,a=n*s+e*l;return [ou(i,r)*nu,ou(a,gu(r*r+i*i))*nu]}:function(){return [n*nu,r*nu]};return y.distance=p,y}const Wf=t=>t;var qf,Hf,Vf,Gf,Xf=new x,Zf=new x,Qf={point:_u,lineStart:_u,lineEnd:_u,polygonStart:function(){Qf.lineStart=Kf,Qf.lineEnd=ed;},polygonEnd:function(){Qf.lineStart=Qf.lineEnd=Qf.point=_u,Xf.add(iu(Zf)),Zf=new x;},result:function(){var t=Xf/2;return Xf=new x,t}};function Kf(){Qf.point=Jf;}function Jf(t,e){Qf.point=td,qf=Vf=t,Hf=Gf=e;}function td(t,e){Zf.add(Gf*t-Vf*e),Vf=t,Gf=e;}function ed(){td(qf,Hf);}const nd=Qf;var rd=1/0,id=rd,ad=-rd,od=ad,sd={point:function(t,e){t<rd&&(rd=t),t>ad&&(ad=t),e<id&&(id=e),e>od&&(od=e);},lineStart:_u,lineEnd:_u,polygonStart:_u,polygonEnd:_u,result:function(){var t=[[rd,id],[ad,od]];return ad=od=-(id=rd=1/0),t}};const cd=sd;var ld,ud,hd,fd,dd=0,pd=0,gd=0,yd=0,md=0,bd=0,vd=0,_d=0,xd=0,kd={point:wd,lineStart:Td,lineEnd:Sd,polygonStart:function(){kd.lineStart=Ad,kd.lineEnd=Md;},polygonEnd:function(){kd.point=wd,kd.lineStart=Td,kd.lineEnd=Sd;},result:function(){var t=xd?[vd/xd,_d/xd]:bd?[yd/bd,md/bd]:gd?[dd/gd,pd/gd]:[NaN,NaN];return dd=pd=gd=yd=md=bd=vd=_d=xd=0,t}};function wd(t,e){dd+=t,pd+=e,++gd;}function Td(){kd.point=Ed;}function Ed(t,e){kd.point=Cd,wd(hd=t,fd=e);}function Cd(t,e){var n=t-hd,r=e-fd,i=gu(n*n+r*r);yd+=i*(hd+t)/2,md+=i*(fd+e)/2,bd+=i,wd(hd=t,fd=e);}function Sd(){kd.point=wd;}function Ad(){kd.point=Nd;}function Md(){Od(ld,ud);}function Nd(t,e){kd.point=Od,wd(ld=hd=t,ud=fd=e);}function Od(t,e){var n=t-hd,r=e-fd,i=gu(n*n+r*r);yd+=i*(hd+t)/2,md+=i*(fd+e)/2,bd+=i,vd+=(i=fd*t-hd*e)*(hd+t),_d+=i*(fd+e),xd+=3*i,wd(hd=t,fd=e);}const Dd=kd;function Bd(t){this._context=t;}Bd.prototype={_radius:4.5,pointRadius:function(t){return this._radius=t,this},polygonStart:function(){this._line=0;},polygonEnd:function(){this._line=NaN;},lineStart:function(){this._point=0;},lineEnd:function(){0===this._line&&this._context.closePath(),this._point=NaN;},point:function(t,e){switch(this._point){case 0:this._context.moveTo(t,e),this._point=1;break;case 1:this._context.lineTo(t,e);break;default:this._context.moveTo(t+this._radius,e),this._context.arc(t,e,this._radius,0,eu);}},result:_u};var Ld,Id,Fd,Rd,Pd,jd=new x,zd={point:_u,lineStart:function(){zd.point=Yd;},lineEnd:function(){Ld&&Ud(Id,Fd),zd.point=_u;},polygonStart:function(){Ld=!0;},polygonEnd:function(){Ld=null;},result:function(){var t=+jd;return jd=new x,t}};function Yd(t,e){zd.point=Ud,Id=Rd=t,Fd=Pd=e;}function Ud(t,e){Rd-=t,Pd-=e,jd.add(gu(Rd*Rd+Pd*Pd)),Rd=t,Pd=e;}const $d=zd;function Wd(){this._string=[];}function qd(t){return "m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Hd(t,e){var n,r,i=4.5;function a(t){return t&&("function"==typeof i&&r.pointRadius(+i.apply(this,arguments)),Cu(t,n(r))),r.result()}return a.area=function(t){return Cu(t,n(nd)),nd.result()},a.measure=function(t){return Cu(t,n($d)),$d.result()},a.bounds=function(t){return Cu(t,n(cd)),cd.result()},a.centroid=function(t){return Cu(t,n(Dd)),Dd.result()},a.projection=function(e){return arguments.length?(n=null==e?(t=null,Wf):(t=e).stream,a):t},a.context=function(t){return arguments.length?(r=null==t?(e=null,new Wd):new Bd(e=t),"function"!=typeof i&&r.pointRadius(i),a):e},a.pointRadius=function(t){return arguments.length?(i="function"==typeof t?t:(r.pointRadius(+t),+t),a):i},a.projection(t).context(e)}function Vd(t){return {stream:Gd(t)}}function Gd(t){return function(e){var n=new Xd;for(var r in t)n[r]=t[r];return n.stream=e,n}}function Xd(){}function Zd(t,e,n){var r=t.clipExtent&&t.clipExtent();return t.scale(150).translate([0,0]),null!=r&&t.clipExtent(null),Cu(n,t.stream(cd)),e(cd.result()),null!=r&&t.clipExtent(r),t}function Qd(t,e,n){return Zd(t,(function(n){var r=e[1][0]-e[0][0],i=e[1][1]-e[0][1],a=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),o=+e[0][0]+(r-a*(n[1][0]+n[0][0]))/2,s=+e[0][1]+(i-a*(n[1][1]+n[0][1]))/2;t.scale(150*a).translate([o,s]);}),n)}function Kd(t,e,n){return Qd(t,[[0,0],e],n)}function Jd(t,e,n){return Zd(t,(function(n){var r=+e,i=r/(n[1][0]-n[0][0]),a=(r-i*(n[1][0]+n[0][0]))/2,o=-i*n[0][1];t.scale(150*i).translate([a,o]);}),n)}function tp(t,e,n){return Zd(t,(function(n){var r=+e,i=r/(n[1][1]-n[0][1]),a=-i*n[0][0],o=(r-i*(n[1][1]+n[0][1]))/2;t.scale(150*i).translate([a,o]);}),n)}Wd.prototype={_radius:4.5,_circle:qd(4.5),pointRadius:function(t){return (t=+t)!==this._radius&&(this._radius=t,this._circle=null),this},polygonStart:function(){this._line=0;},polygonEnd:function(){this._line=NaN;},lineStart:function(){this._point=0;},lineEnd:function(){0===this._line&&this._string.push("Z"),this._point=NaN;},point:function(t,e){switch(this._point){case 0:this._string.push("M",t,",",e),this._point=1;break;case 1:this._string.push("L",t,",",e);break;default:null==this._circle&&(this._circle=qd(this._radius)),this._string.push("M",t,",",e,this._circle);}},result:function(){if(this._string.length){var t=this._string.join("");return this._string=[],t}return null}},Xd.prototype={constructor:Xd,point:function(t,e){this.stream.point(t,e);},sphere:function(){this.stream.sphere();},lineStart:function(){this.stream.lineStart();},lineEnd:function(){this.stream.lineEnd();},polygonStart:function(){this.stream.polygonStart();},polygonEnd:function(){this.stream.polygonEnd();}};var ep=su(30*ru);function np(t,e){return +e?function(t,e){function n(r,i,a,o,s,c,l,u,h,f,d,p,g,y){var m=l-r,b=u-i,v=m*m+b*b;if(v>4*e&&g--){var _=o+f,x=s+d,k=c+p,w=gu(_*_+x*x+k*k),T=bu(k/=w),E=iu(iu(k)-1)<Zl||iu(a-h)<Zl?(a+h)/2:ou(x,_),C=t(E,T),S=C[0],A=C[1],M=S-r,N=A-i,O=b*M-m*N;(O*O/v>e||iu((m*M+b*N)/v-.5)>.3||o*f+s*d+c*p<ep)&&(n(r,i,a,o,s,c,S,A,E,_/=w,x/=w,k,g,y),y.point(S,A),n(S,A,E,_,x,k,l,u,h,f,d,p,g,y));}}return function(e){var r,i,a,o,s,c,l,u,h,f,d,p,g={point:y,lineStart:m,lineEnd:v,polygonStart:function(){e.polygonStart(),g.lineStart=_;},polygonEnd:function(){e.polygonEnd(),g.lineStart=m;}};function y(n,r){n=t(n,r),e.point(n[0],n[1]);}function m(){u=NaN,g.point=b,e.lineStart();}function b(r,i){var a=Ku([r,i]),o=t(r,i);n(u,h,l,f,d,p,u=o[0],h=o[1],l=r,f=a[0],d=a[1],p=a[2],16,e),e.point(u,h);}function v(){g.point=y,e.lineEnd();}function _(){m(),g.point=x,g.lineEnd=k;}function x(t,e){b(r=t,e),i=u,a=h,o=f,s=d,c=p,g.point=b;}function k(){n(u,h,l,f,d,p,i,a,r,o,s,c,16,e),g.lineEnd=v,v();}return g}}(t,e):function(t){return Gd({point:function(e,n){e=t(e,n),this.stream.point(e[0],e[1]);}})}(t)}var rp=Gd({point:function(t,e){this.stream.point(t*ru,e*ru);}});function ip(t,e,n,r,i,a){if(!a)return function(t,e,n,r,i){function a(a,o){return [e+t*(a*=r),n-t*(o*=i)]}return a.invert=function(a,o){return [(a-e)/t*r,(n-o)/t*i]},a}(t,e,n,r,i);var o=su(a),s=du(a),c=o*t,l=s*t,u=o/t,h=s/t,f=(s*n-o*e)/t,d=(s*e+o*n)/t;function p(t,a){return [c*(t*=r)-l*(a*=i)+e,n-l*t-c*a]}return p.invert=function(t,e){return [r*(u*t-h*e+f),i*(d-h*t-u*e)]},p}function ap(t){return op((function(){return t}))()}function op(t){var e,n,r,i,a,o,s,c,l,u,h=150,f=480,d=250,p=0,g=0,y=0,m=0,b=0,v=0,_=1,x=1,k=null,w=ff,T=null,E=Wf,C=.5;function S(t){return c(t[0]*ru,t[1]*ru)}function A(t){return (t=c.invert(t[0],t[1]))&&[t[0]*nu,t[1]*nu]}function M(){var t=ip(h,0,0,_,x,v).apply(null,e(p,g)),r=ip(h,f-t[0],d-t[1],_,x,v);return n=Vh(y,m,b),s=qh(e,r),c=qh(n,s),o=np(s,C),N()}function N(){return l=u=null,S}return S.stream=function(t){return l&&u===t?l:l=rp(function(t){return Gd({point:function(e,n){var r=t(e,n);return this.stream.point(r[0],r[1])}})}(n)(w(o(E(u=t)))))},S.preclip=function(t){return arguments.length?(w=t,k=void 0,N()):w},S.postclip=function(t){return arguments.length?(E=t,T=r=i=a=null,N()):E},S.clipAngle=function(t){return arguments.length?(w=+t?df(k=t*ru):(k=null,ff),N()):k*nu},S.clipExtent=function(t){return arguments.length?(E=null==t?(T=r=i=a=null,Wf):_f(T=+t[0][0],r=+t[0][1],i=+t[1][0],a=+t[1][1]),N()):null==T?null:[[T,r],[i,a]]},S.scale=function(t){return arguments.length?(h=+t,M()):h},S.translate=function(t){return arguments.length?(f=+t[0],d=+t[1],M()):[f,d]},S.center=function(t){return arguments.length?(p=t[0]%360*ru,g=t[1]%360*ru,M()):[p*nu,g*nu]},S.rotate=function(t){return arguments.length?(y=t[0]%360*ru,m=t[1]%360*ru,b=t.length>2?t[2]%360*ru:0,M()):[y*nu,m*nu,b*nu]},S.angle=function(t){return arguments.length?(v=t%360*ru,M()):v*nu},S.reflectX=function(t){return arguments.length?(_=t?-1:1,M()):_<0},S.reflectY=function(t){return arguments.length?(x=t?-1:1,M()):x<0},S.precision=function(t){return arguments.length?(o=np(s,C=t*t),N()):gu(C)},S.fitExtent=function(t,e){return Qd(S,t,e)},S.fitSize=function(t,e){return Kd(S,t,e)},S.fitWidth=function(t,e){return Jd(S,t,e)},S.fitHeight=function(t,e){return tp(S,t,e)},function(){return e=t.apply(this,arguments),S.invert=e.invert&&A,M()}}function sp(t){var e=0,n=Kl/3,r=op(t),i=r(e,n);return i.parallels=function(t){return arguments.length?r(e=t[0]*ru,n=t[1]*ru):[e*nu,n*nu]},i}function cp(t,e){var n=du(t),r=(n+du(e))/2;if(iu(r)<Zl)return function(t){var e=su(t);function n(t,n){return [t*e,du(n)/e]}return n.invert=function(t,n){return [t/e,bu(n*e)]},n}(t);var i=1+n*(2*r-n),a=gu(i)/r;function o(t,e){var n=gu(i-2*r*du(e))/r;return [n*du(t*=r),a-n*su(t)]}return o.invert=function(t,e){var n=a-e,o=ou(t,iu(n))*pu(n);return n*r<0&&(o-=Kl*pu(t)*pu(n)),[o/r,bu((i-(t*t+n*n)*r*r)/(2*r))]},o}function lp(){return sp(cp).scale(155.424).center([0,33.6442])}function up(){return lp().parallels([29.5,45.5]).scale(1070).translate([480,250]).rotate([96,0]).center([-.6,38.7])}function hp(){var t,e,n,r,i,a,o=up(),s=lp().rotate([154,0]).center([-2,58.5]).parallels([55,65]),c=lp().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(t,e){a=[t,e];}};function u(t){var e=t[0],o=t[1];return a=null,n.point(e,o),a||(r.point(e,o),a)||(i.point(e,o),a)}function h(){return t=e=null,u}return u.invert=function(t){var e=o.scale(),n=o.translate(),r=(t[0]-n[0])/e,i=(t[1]-n[1])/e;return (i>=.12&&i<.234&&r>=-.425&&r<-.214?s:i>=.166&&i<.234&&r>=-.214&&r<-.115?c:o).invert(t)},u.stream=function(n){return t&&e===n?t:(r=[o.stream(e=n),s.stream(n),c.stream(n)],i=r.length,t={point:function(t,e){for(var n=-1;++n<i;)r[n].point(t,e);},sphere:function(){for(var t=-1;++t<i;)r[t].sphere();},lineStart:function(){for(var t=-1;++t<i;)r[t].lineStart();},lineEnd:function(){for(var t=-1;++t<i;)r[t].lineEnd();},polygonStart:function(){for(var t=-1;++t<i;)r[t].polygonStart();},polygonEnd:function(){for(var t=-1;++t<i;)r[t].polygonEnd();}});var r,i;},u.precision=function(t){return arguments.length?(o.precision(t),s.precision(t),c.precision(t),h()):o.precision()},u.scale=function(t){return arguments.length?(o.scale(t),s.scale(.35*t),c.scale(t),u.translate(o.translate())):o.scale()},u.translate=function(t){if(!arguments.length)return o.translate();var e=o.scale(),a=+t[0],u=+t[1];return n=o.translate(t).clipExtent([[a-.455*e,u-.238*e],[a+.455*e,u+.238*e]]).stream(l),r=s.translate([a-.307*e,u+.201*e]).clipExtent([[a-.425*e+Zl,u+.12*e+Zl],[a-.214*e-Zl,u+.234*e-Zl]]).stream(l),i=c.translate([a-.205*e,u+.212*e]).clipExtent([[a-.214*e+Zl,u+.166*e+Zl],[a-.115*e-Zl,u+.234*e-Zl]]).stream(l),h()},u.fitExtent=function(t,e){return Qd(u,t,e)},u.fitSize=function(t,e){return Kd(u,t,e)},u.fitWidth=function(t,e){return Jd(u,t,e)},u.fitHeight=function(t,e){return tp(u,t,e)},u.scale(1070)}function fp(t){return function(e,n){var r=su(e),i=su(n),a=t(r*i);return a===1/0?[2,0]:[a*i*du(e),a*du(n)]}}function dp(t){return function(e,n){var r=gu(e*e+n*n),i=t(r),a=du(i),o=su(i);return [ou(e*a,r*o),bu(r&&n*a/r)]}}var pp=fp((function(t){return gu(2/(1+t))}));function gp(){return ap(pp).scale(124.75).clipAngle(179.999)}pp.invert=dp((function(t){return 2*bu(t/2)}));var yp=fp((function(t){return (t=mu(t))&&t/du(t)}));function mp(){return ap(yp).scale(79.4188).clipAngle(179.999)}function bp(t,e){return [t,hu(yu((Jl+e)/2))]}function vp(){return _p(bp).scale(961/eu)}function _p(t){var e,n,r,i=ap(t),a=i.center,o=i.scale,s=i.translate,c=i.clipExtent,l=null;function u(){var a=Kl*o(),s=i(Qh(i.rotate()).invert([0,0]));return c(null==l?[[s[0]-a,s[1]-a],[s[0]+a,s[1]+a]]:t===bp?[[Math.max(s[0]-a,l),e],[Math.min(s[0]+a,n),r]]:[[l,Math.max(s[1]-a,e)],[n,Math.min(s[1]+a,r)]])}return i.scale=function(t){return arguments.length?(o(t),u()):o()},i.translate=function(t){return arguments.length?(s(t),u()):s()},i.center=function(t){return arguments.length?(a(t),u()):a()},i.clipExtent=function(t){return arguments.length?(null==t?l=e=n=r=null:(l=+t[0][0],e=+t[0][1],n=+t[1][0],r=+t[1][1]),u()):null==l?null:[[l,e],[n,r]]},u()}function xp(t){return yu((Jl+t)/2)}function kp(t,e){var n=su(t),r=t===e?du(t):hu(n/su(e))/hu(xp(e)/xp(t)),i=n*fu(xp(t),r)/r;if(!r)return bp;function a(t,e){i>0?e<-Jl+Zl&&(e=-Jl+Zl):e>Jl-Zl&&(e=Jl-Zl);var n=i/fu(xp(e),r);return [n*du(r*t),i-n*su(r*t)]}return a.invert=function(t,e){var n=i-e,a=pu(r)*gu(t*t+n*n),o=ou(t,iu(n))*pu(n);return n*r<0&&(o-=Kl*pu(t)*pu(n)),[o/r,2*au(fu(i/a,1/r))-Jl]},a}function wp(){return sp(kp).scale(109.5).parallels([30,30])}function Tp(t,e){return [t,e]}function Ep(){return ap(Tp).scale(152.63)}function Cp(t,e){var n=su(t),r=t===e?du(t):(n-su(e))/(e-t),i=n/r+t;if(iu(r)<Zl)return Tp;function a(t,e){var n=i-e,a=r*t;return [n*du(a),i-n*su(a)]}return a.invert=function(t,e){var n=i-e,a=ou(t,iu(n))*pu(n);return n*r<0&&(a-=Kl*pu(t)*pu(n)),[a/r,i-pu(r)*gu(t*t+n*n)]},a}function Sp(){return sp(Cp).scale(131.154).center([0,13.9389])}yp.invert=dp((function(t){return t})),bp.invert=function(t,e){return [t,2*au(lu(e))-Jl]},Tp.invert=Tp;var Ap=1.340264,Mp=-.081106,Np=893e-6,Op=.003796,Dp=gu(3)/2;function Bp(t,e){var n=bu(Dp*du(e)),r=n*n,i=r*r*r;return [t*su(n)/(Dp*(Ap+3*Mp*r+i*(7*Np+9*Op*r))),n*(Ap+Mp*r+i*(Np+Op*r))]}function Lp(){return ap(Bp).scale(177.158)}function Ip(t,e){var n=su(e),r=su(t)*n;return [n*du(t)/r,du(e)/r]}function Fp(){return ap(Ip).scale(144.049).clipAngle(60)}function Rp(){var t,e,n,r,i,a,o,s=1,c=0,l=0,u=1,h=1,f=0,d=null,p=1,g=1,y=Gd({point:function(t,e){var n=v([t,e]);this.stream.point(n[0],n[1]);}}),m=Wf;function b(){return p=s*u,g=s*h,a=o=null,v}function v(n){var r=n[0]*p,i=n[1]*g;if(f){var a=i*t-r*e;r=r*t+i*e,i=a;}return [r+c,i+l]}return v.invert=function(n){var r=n[0]-c,i=n[1]-l;if(f){var a=i*t+r*e;r=r*t-i*e,i=a;}return [r/p,i/g]},v.stream=function(t){return a&&o===t?a:a=y(m(o=t))},v.postclip=function(t){return arguments.length?(m=t,d=n=r=i=null,b()):m},v.clipExtent=function(t){return arguments.length?(m=null==t?(d=n=r=i=null,Wf):_f(d=+t[0][0],n=+t[0][1],r=+t[1][0],i=+t[1][1]),b()):null==d?null:[[d,n],[r,i]]},v.scale=function(t){return arguments.length?(s=+t,b()):s},v.translate=function(t){return arguments.length?(c=+t[0],l=+t[1],b()):[c,l]},v.angle=function(n){return arguments.length?(e=du(f=n%360*ru),t=su(f),b()):f*nu},v.reflectX=function(t){return arguments.length?(u=t?-1:1,b()):u<0},v.reflectY=function(t){return arguments.length?(h=t?-1:1,b()):h<0},v.fitExtent=function(t,e){return Qd(v,t,e)},v.fitSize=function(t,e){return Kd(v,t,e)},v.fitWidth=function(t,e){return Jd(v,t,e)},v.fitHeight=function(t,e){return tp(v,t,e)},v}function Pp(t,e){var n=e*e,r=n*n;return [t*(.8707-.131979*n+r*(r*(.003971*n-.001529*r)-.013791)),e*(1.007226+n*(.015085+r*(.028874*n-.044475-.005916*r)))]}function jp(){return ap(Pp).scale(175.295)}function zp(t,e){return [su(e)*du(t),du(e)]}function Yp(){return ap(zp).scale(249.5).clipAngle(90.000001)}function Up(t,e){var n=su(e),r=1+su(t)*n;return [n*du(t)/r,du(e)/r]}function $p(){return ap(Up).scale(250).clipAngle(142)}function Wp(t,e){return [hu(yu((Jl+e)/2)),-t]}function qp(){var t=_p(Wp),e=t.center,n=t.rotate;return t.center=function(t){return arguments.length?e([-t[1],t[0]]):[(t=e())[1],-t[0]]},t.rotate=function(t){return arguments.length?n([t[0],t[1],t.length>2?t[2]+90:90]):[(t=n())[0],t[1],t[2]-90]},n([0,0,90]).scale(159.155)}function Hp(t,e){return t.parent===e.parent?1:2}function Vp(t,e){return t+e.x}function Gp(t,e){return Math.max(t,e.y)}function Xp(){var t=Hp,e=1,n=1,r=!1;function i(i){var a,o=0;i.eachAfter((function(e){var n=e.children;n?(e.x=function(t){return t.reduce(Vp,0)/t.length}(n),e.y=function(t){return 1+t.reduce(Gp,0)}(n)):(e.x=a?o+=t(e,a):0,e.y=0,a=e);}));var s=function(t){for(var e;e=t.children;)t=e[0];return t}(i),c=function(t){for(var e;e=t.children;)t=e[e.length-1];return t}(i),l=s.x-t(s,c)/2,u=c.x+t(c,s)/2;return i.eachAfter(r?function(t){t.x=(t.x-i.x)*e,t.y=(i.y-t.y)*n;}:function(t){t.x=(t.x-l)/(u-l)*e,t.y=(1-(i.y?t.y/i.y:1))*n;})}return i.separation=function(e){return arguments.length?(t=e,i):t},i.size=function(t){return arguments.length?(r=!1,e=+t[0],n=+t[1],i):r?null:[e,n]},i.nodeSize=function(t){return arguments.length?(r=!0,e=+t[0],n=+t[1],i):r?[e,n]:null},i}function Zp(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e;}function Qp(t,e){t instanceof Map?(t=[void 0,t],void 0===e&&(e=Jp)):void 0===e&&(e=Kp);for(var n,r,i,a,o,s=new ng(t),c=[s];n=c.pop();)if((i=e(n.data))&&(o=(i=Array.from(i)).length))for(n.children=i,a=o-1;a>=0;--a)c.push(r=i[a]=new ng(i[a])),r.parent=n,r.depth=n.depth+1;return s.eachBefore(eg)}function Kp(t){return t.children}function Jp(t){return Array.isArray(t)?t[1]:null}function tg(t){void 0!==t.data.value&&(t.value=t.data.value),t.data=t.data.data;}function eg(t){var e=0;do{t.height=e;}while((t=t.parent)&&t.height<++e)}function ng(t){this.data=t,this.depth=this.height=0,this.parent=null;}function rg(t){for(var e,n,r=0,i=(t=function(t){for(var e,n,r=t.length;r;)n=Math.random()*r--|0,e=t[r],t[r]=t[n],t[n]=e;return t}(Array.from(t))).length,a=[];r<i;)e=t[r],n&&og(n,e)?++r:(n=cg(a=ig(a,e)),r=0);return n}function ig(t,e){var n,r;if(sg(e,t))return [e];for(n=0;n<t.length;++n)if(ag(e,t[n])&&sg(lg(t[n],e),t))return [t[n],e];for(n=0;n<t.length-1;++n)for(r=n+1;r<t.length;++r)if(ag(lg(t[n],t[r]),e)&&ag(lg(t[n],e),t[r])&&ag(lg(t[r],e),t[n])&&sg(ug(t[n],t[r],e),t))return [t[n],t[r],e];throw new Error}function ag(t,e){var n=t.r-e.r,r=e.x-t.x,i=e.y-t.y;return n<0||n*n<r*r+i*i}function og(t,e){var n=t.r-e.r+1e-9*Math.max(t.r,e.r,1),r=e.x-t.x,i=e.y-t.y;return n>0&&n*n>r*r+i*i}function sg(t,e){for(var n=0;n<e.length;++n)if(!og(t,e[n]))return !1;return !0}function cg(t){switch(t.length){case 1:return {x:(e=t[0]).x,y:e.y,r:e.r};case 2:return lg(t[0],t[1]);case 3:return ug(t[0],t[1],t[2])}var e;}function lg(t,e){var n=t.x,r=t.y,i=t.r,a=e.x,o=e.y,s=e.r,c=a-n,l=o-r,u=s-i,h=Math.sqrt(c*c+l*l);return {x:(n+a+c/h*u)/2,y:(r+o+l/h*u)/2,r:(h+i+s)/2}}function ug(t,e,n){var r=t.x,i=t.y,a=t.r,o=e.x,s=e.y,c=e.r,l=n.x,u=n.y,h=n.r,f=r-o,d=r-l,p=i-s,g=i-u,y=c-a,m=h-a,b=r*r+i*i-a*a,v=b-o*o-s*s+c*c,_=b-l*l-u*u+h*h,x=d*p-f*g,k=(p*_-g*v)/(2*x)-r,w=(g*y-p*m)/x,T=(d*v-f*_)/(2*x)-i,E=(f*m-d*y)/x,C=w*w+E*E-1,S=2*(a+k*w+T*E),A=k*k+T*T-a*a,M=-(C?(S+Math.sqrt(S*S-4*C*A))/(2*C):A/S);return {x:r+k+w*M,y:i+T+E*M,r:M}}function hg(t,e,n){var r,i,a,o,s=t.x-e.x,c=t.y-e.y,l=s*s+c*c;l?(i=e.r+n.r,i*=i,o=t.r+n.r,i>(o*=o)?(r=(l+o-i)/(2*l),a=Math.sqrt(Math.max(0,o/l-r*r)),n.x=t.x-r*s-a*c,n.y=t.y-r*c+a*s):(r=(l+i-o)/(2*l),a=Math.sqrt(Math.max(0,i/l-r*r)),n.x=e.x+r*s-a*c,n.y=e.y+r*c+a*s)):(n.x=e.x+n.r,n.y=e.y);}function fg(t,e){var n=t.r+e.r-1e-6,r=e.x-t.x,i=e.y-t.y;return n>0&&n*n>r*r+i*i}function dg(t){var e=t._,n=t.next._,r=e.r+n.r,i=(e.x*n.r+n.x*e.r)/r,a=(e.y*n.r+n.y*e.r)/r;return i*i+a*a}function pg(t){this._=t,this.next=null,this.previous=null;}function gg(t){if(!(a=(e=t,t="object"==typeof e&&"length"in e?e:Array.from(e)).length))return 0;var e,n,r,i,a,o,s,c,l,u,h,f;if((n=t[0]).x=0,n.y=0,!(a>1))return n.r;if(r=t[1],n.x=-r.r,r.x=n.r,r.y=0,!(a>2))return n.r+r.r;hg(r,n,i=t[2]),n=new pg(n),r=new pg(r),i=new pg(i),n.next=i.previous=r,r.next=n.previous=i,i.next=r.previous=n;t:for(c=3;c<a;++c){hg(n._,r._,i=t[c]),i=new pg(i),l=r.next,u=n.previous,h=r._.r,f=n._.r;do{if(h<=f){if(fg(l._,i._)){r=l,n.next=r,r.previous=n,--c;continue t}h+=l._.r,l=l.next;}else {if(fg(u._,i._)){(n=u).next=r,r.previous=n,--c;continue t}f+=u._.r,u=u.previous;}}while(l!==u.next);for(i.previous=n,i.next=r,n.next=r.previous=r=i,o=dg(n);(i=i.next)!==r;)(s=dg(i))<o&&(n=i,o=s);r=n.next;}for(n=[r._],i=r;(i=i.next)!==r;)n.push(i._);for(i=rg(n),c=0;c<a;++c)(n=t[c]).x-=i.x,n.y-=i.y;return i.r}function yg(t){return gg(t),t}function mg(t){return null==t?null:bg(t)}function bg(t){if("function"!=typeof t)throw new Error;return t}function vg(){return 0}function _g(t){return function(){return t}}function xg(t){return Math.sqrt(t.value)}function kg(){var t=null,e=1,n=1,r=vg;function i(i){return i.x=e/2,i.y=n/2,t?i.eachBefore(wg(t)).eachAfter(Tg(r,.5)).eachBefore(Eg(1)):i.eachBefore(wg(xg)).eachAfter(Tg(vg,1)).eachAfter(Tg(r,i.r/Math.min(e,n))).eachBefore(Eg(Math.min(e,n)/(2*i.r))),i}return i.radius=function(e){return arguments.length?(t=mg(e),i):t},i.size=function(t){return arguments.length?(e=+t[0],n=+t[1],i):[e,n]},i.padding=function(t){return arguments.length?(r="function"==typeof t?t:_g(+t),i):r},i}function wg(t){return function(e){e.children||(e.r=Math.max(0,+t(e)||0));}}function Tg(t,e){return function(n){if(r=n.children){var r,i,a,o=r.length,s=t(n)*e||0;if(s)for(i=0;i<o;++i)r[i].r+=s;if(a=gg(r),s)for(i=0;i<o;++i)r[i].r-=s;n.r=a+s;}}}function Eg(t){return function(e){var n=e.parent;e.r*=t,n&&(e.x=n.x+t*e.x,e.y=n.y+t*e.y);}}function Cg(t){t.x0=Math.round(t.x0),t.y0=Math.round(t.y0),t.x1=Math.round(t.x1),t.y1=Math.round(t.y1);}function Sg(t,e,n,r,i){for(var a,o=t.children,s=-1,c=o.length,l=t.value&&(r-e)/t.value;++s<c;)(a=o[s]).y0=n,a.y1=i,a.x0=e,a.x1=e+=a.value*l;}function Ag(){var t=1,e=1,n=0,r=!1;function i(i){var a=i.height+1;return i.x0=i.y0=n,i.x1=t,i.y1=e/a,i.eachBefore(function(t,e){return function(r){r.children&&Sg(r,r.x0,t*(r.depth+1)/e,r.x1,t*(r.depth+2)/e);var i=r.x0,a=r.y0,o=r.x1-n,s=r.y1-n;o<i&&(i=o=(i+o)/2),s<a&&(a=s=(a+s)/2),r.x0=i,r.y0=a,r.x1=o,r.y1=s;}}(e,a)),r&&i.eachBefore(Cg),i}return i.round=function(t){return arguments.length?(r=!!t,i):r},i.size=function(n){return arguments.length?(t=+n[0],e=+n[1],i):[t,e]},i.padding=function(t){return arguments.length?(n=+t,i):n},i}Bp.invert=function(t,e){for(var n,r=e,i=r*r,a=i*i*i,o=0;o<12&&(a=(i=(r-=n=(r*(Ap+Mp*i+a*(Np+Op*i))-e)/(Ap+3*Mp*i+a*(7*Np+9*Op*i)))*r)*i*i,!(iu(n)<Ql));++o);return [Dp*t*(Ap+3*Mp*i+a*(7*Np+9*Op*i))/su(r),bu(du(r)/Dp)]},Ip.invert=dp(au),Pp.invert=function(t,e){var n,r=e,i=25;do{var a=r*r,o=a*a;r-=n=(r*(1.007226+a*(.015085+o*(.028874*a-.044475-.005916*o)))-e)/(1.007226+a*(.045255+o*(.259866*a-.311325-.005916*11*o)));}while(iu(n)>Zl&&--i>0);return [t/(.8707+(a=r*r)*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979)),r]},zp.invert=dp(bu),Up.invert=dp((function(t){return 2*au(t)})),Wp.invert=function(t,e){return [-e,2*au(lu(t))-Jl]},ng.prototype=Qp.prototype={constructor:ng,count:function(){return this.eachAfter(Zp)},each:function(t,e){let n=-1;for(const r of this)t.call(e,r,++n,this);return this},eachAfter:function(t,e){for(var n,r,i,a=this,o=[a],s=[],c=-1;a=o.pop();)if(s.push(a),n=a.children)for(r=0,i=n.length;r<i;++r)o.push(n[r]);for(;a=s.pop();)t.call(e,a,++c,this);return this},eachBefore:function(t,e){for(var n,r,i=this,a=[i],o=-1;i=a.pop();)if(t.call(e,i,++o,this),n=i.children)for(r=n.length-1;r>=0;--r)a.push(n[r]);return this},find:function(t,e){let n=-1;for(const r of this)if(t.call(e,r,++n,this))return r},sum:function(t){return this.eachAfter((function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n;}))},sort:function(t){return this.eachBefore((function(e){e.children&&e.children.sort(t);}))},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;for(t=n.pop(),e=r.pop();t===e;)i=t,t=n.pop(),e=r.pop();return i}(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){return Array.from(this)},leaves:function(){var t=[];return this.eachBefore((function(e){e.children||t.push(e);})),t},links:function(){var t=this,e=[];return t.each((function(n){n!==t&&e.push({source:n.parent,target:n});})),e},copy:function(){return Qp(this).eachBefore(tg)},[Symbol.iterator]:function*(){var t,e,n,r,i=this,a=[i];do{for(t=a.reverse(),a=[];i=t.pop();)if(yield i,e=i.children)for(n=0,r=e.length;n<r;++n)a.push(e[n]);}while(a.length)}};var Mg={depth:-1},Ng={},Og={};function Dg(t){return t.id}function Bg(t){return t.parentId}function Lg(){var t,e=Dg,n=Bg;function r(r){var i,a,o,s,c,l,u,h,f=Array.from(r),d=e,p=n,g=new Map;if(null!=t){const e=f.map(((e,n)=>function(t){let e=(t=`${t}`).length;return Fg(t,e-1)&&!Fg(t,e-2)&&(t=t.slice(0,-1)),"/"===t[0]?t:`/${t}`}(t(e,n,r)))),n=e.map(Ig),i=new Set(e).add("");for(const t of n)i.has(t)||(i.add(t),e.push(t),n.push(Ig(t)),f.push(Og));d=(t,n)=>e[n],p=(t,e)=>n[e];}for(o=0,i=f.length;o<i;++o)a=f[o],l=f[o]=new ng(a),null!=(u=d(a,o,r))&&(u+="")&&(h=l.id=u,g.set(h,g.has(h)?Ng:l)),null!=(u=p(a,o,r))&&(u+="")&&(l.parent=u);for(o=0;o<i;++o)if(u=(l=f[o]).parent){if(!(c=g.get(u)))throw new Error("missing: "+u);if(c===Ng)throw new Error("ambiguous: "+u);c.children?c.children.push(l):c.children=[l],l.parent=c;}else {if(s)throw new Error("multiple roots");s=l;}if(!s)throw new Error("no root");if(null!=t){for(;s.data===Og&&1===s.children.length;)s=s.children[0],--i;for(let t=f.length-1;t>=0&&(l=f[t],l.data===Og);--t)l.data=null;}if(s.parent=Mg,s.eachBefore((function(t){t.depth=t.parent.depth+1,--i;})).eachBefore(eg),s.parent=null,i>0)throw new Error("cycle");return s}return r.id=function(t){return arguments.length?(e=mg(t),r):e},r.parentId=function(t){return arguments.length?(n=mg(t),r):n},r.path=function(e){return arguments.length?(t=mg(e),r):t},r}function Ig(t){let e=t.length;if(e<2)return "";for(;--e>1&&!Fg(t,e););return t.slice(0,e)}function Fg(t,e){if("/"===t[e]){let n=0;for(;e>0&&"\\"===t[--e];)++n;if(0==(1&n))return !0}return !1}function Rg(t,e){return t.parent===e.parent?1:2}function Pg(t){var e=t.children;return e?e[0]:t.t}function jg(t){var e=t.children;return e?e[e.length-1]:t.t}function zg(t,e,n){var r=n/(e.i-t.i);e.c-=r,e.s+=n,t.c+=r,e.z+=n,e.m+=n;}function Yg(t,e,n){return t.a.parent===e.parent?t.a:n}function Ug(t,e){this._=t,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=e;}function $g(){var t=Rg,e=1,n=1,r=null;function i(i){var c=function(t){for(var e,n,r,i,a,o=new Ug(t,0),s=[o];e=s.pop();)if(r=e._.children)for(e.children=new Array(a=r.length),i=a-1;i>=0;--i)s.push(n=e.children[i]=new Ug(r[i],i)),n.parent=e;return (o.parent=new Ug(null,0)).children=[o],o}(i);if(c.eachAfter(a),c.parent.m=-c.z,c.eachBefore(o),r)i.eachBefore(s);else {var l=i,u=i,h=i;i.eachBefore((function(t){t.x<l.x&&(l=t),t.x>u.x&&(u=t),t.depth>h.depth&&(h=t);}));var f=l===u?1:t(l,u)/2,d=f-l.x,p=e/(u.x+f+d),g=n/(h.depth||1);i.eachBefore((function(t){t.x=(t.x+d)*p,t.y=t.depth*g;}));}return i}function a(e){var n=e.children,r=e.parent.children,i=e.i?r[e.i-1]:null;if(n){!function(t){for(var e,n=0,r=0,i=t.children,a=i.length;--a>=0;)(e=i[a]).z+=n,e.m+=n,n+=e.s+(r+=e.c);}(e);var a=(n[0].z+n[n.length-1].z)/2;i?(e.z=i.z+t(e._,i._),e.m=e.z-a):e.z=a;}else i&&(e.z=i.z+t(e._,i._));e.parent.A=function(e,n,r){if(n){for(var i,a=e,o=e,s=n,c=a.parent.children[0],l=a.m,u=o.m,h=s.m,f=c.m;s=jg(s),a=Pg(a),s&&a;)c=Pg(c),(o=jg(o)).a=e,(i=s.z+h-a.z-l+t(s._,a._))>0&&(zg(Yg(s,e,r),e,i),l+=i,u+=i),h+=s.m,l+=a.m,f+=c.m,u+=o.m;s&&!jg(o)&&(o.t=s,o.m+=h-u),a&&!Pg(c)&&(c.t=a,c.m+=l-f,r=e);}return r}(e,i,e.parent.A||r[0]);}function o(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m;}function s(t){t.x*=e,t.y=t.depth*n;}return i.separation=function(e){return arguments.length?(t=e,i):t},i.size=function(t){return arguments.length?(r=!1,e=+t[0],n=+t[1],i):r?null:[e,n]},i.nodeSize=function(t){return arguments.length?(r=!0,e=+t[0],n=+t[1],i):r?[e,n]:null},i}function Wg(t,e,n,r,i){for(var a,o=t.children,s=-1,c=o.length,l=t.value&&(i-n)/t.value;++s<c;)(a=o[s]).x0=e,a.x1=r,a.y0=n,a.y1=n+=a.value*l;}Ug.prototype=Object.create(ng.prototype);var qg=(1+Math.sqrt(5))/2;function Hg(t,e,n,r,i,a){for(var o,s,c,l,u,h,f,d,p,g,y,m=[],b=e.children,v=0,_=0,x=b.length,k=e.value;v<x;){c=i-n,l=a-r;do{u=b[_++].value;}while(!u&&_<x);for(h=f=u,y=u*u*(g=Math.max(l/c,c/l)/(k*t)),p=Math.max(f/y,y/h);_<x;++_){if(u+=s=b[_].value,s<h&&(h=s),s>f&&(f=s),y=u*u*g,(d=Math.max(f/y,y/h))>p){u-=s;break}p=d;}m.push(o={value:u,dice:c<l,children:b.slice(v,_)}),o.dice?Sg(o,n,r,i,k?r+=l*u/k:a):Wg(o,n,r,k?n+=c*u/k:i,a),k-=u,v=_;}return m}const Vg=function t(e){function n(t,n,r,i,a){Hg(e,t,n,r,i,a);}return n.ratio=function(e){return t((e=+e)>1?e:1)},n}(qg);function Gg(){var t=Vg,e=!1,n=1,r=1,i=[0],a=vg,o=vg,s=vg,c=vg,l=vg;function u(t){return t.x0=t.y0=0,t.x1=n,t.y1=r,t.eachBefore(h),i=[0],e&&t.eachBefore(Cg),t}function h(e){var n=i[e.depth],r=e.x0+n,u=e.y0+n,h=e.x1-n,f=e.y1-n;h<r&&(r=h=(r+h)/2),f<u&&(u=f=(u+f)/2),e.x0=r,e.y0=u,e.x1=h,e.y1=f,e.children&&(n=i[e.depth+1]=a(e)/2,r+=l(e)-n,u+=o(e)-n,(h-=s(e)-n)<r&&(r=h=(r+h)/2),(f-=c(e)-n)<u&&(u=f=(u+f)/2),t(e,r,u,h,f));}return u.round=function(t){return arguments.length?(e=!!t,u):e},u.size=function(t){return arguments.length?(n=+t[0],r=+t[1],u):[n,r]},u.tile=function(e){return arguments.length?(t=bg(e),u):t},u.padding=function(t){return arguments.length?u.paddingInner(t).paddingOuter(t):u.paddingInner()},u.paddingInner=function(t){return arguments.length?(a="function"==typeof t?t:_g(+t),u):a},u.paddingOuter=function(t){return arguments.length?u.paddingTop(t).paddingRight(t).paddingBottom(t).paddingLeft(t):u.paddingTop()},u.paddingTop=function(t){return arguments.length?(o="function"==typeof t?t:_g(+t),u):o},u.paddingRight=function(t){return arguments.length?(s="function"==typeof t?t:_g(+t),u):s},u.paddingBottom=function(t){return arguments.length?(c="function"==typeof t?t:_g(+t),u):c},u.paddingLeft=function(t){return arguments.length?(l="function"==typeof t?t:_g(+t),u):l},u}function Xg(t,e,n,r,i){var a,o,s=t.children,c=s.length,l=new Array(c+1);for(l[0]=o=a=0;a<c;++a)l[a+1]=o+=s[a].value;!function t(e,n,r,i,a,o,c){if(e>=n-1){var u=s[e];return u.x0=i,u.y0=a,u.x1=o,void(u.y1=c)}for(var h=l[e],f=r/2+h,d=e+1,p=n-1;d<p;){var g=d+p>>>1;l[g]<f?d=g+1:p=g;}f-l[d-1]<l[d]-f&&e+1<d&&--d;var y=l[d]-h,m=r-y;if(o-i>c-a){var b=r?(i*m+o*y)/r:o;t(e,d,y,i,a,b,c),t(d,n,m,b,a,o,c);}else {var v=r?(a*m+c*y)/r:c;t(e,d,y,i,a,o,v),t(d,n,m,i,v,o,c);}}(0,c,t.value,e,n,r,i);}function Zg(t,e,n,r,i){(1&t.depth?Wg:Sg)(t,e,n,r,i);}const Qg=function t(e){function n(t,n,r,i,a){if((o=t._squarify)&&o.ratio===e)for(var o,s,c,l,u,h=-1,f=o.length,d=t.value;++h<f;){for(c=(s=o[h]).children,l=s.value=0,u=c.length;l<u;++l)s.value+=c[l].value;s.dice?Sg(s,n,r,i,d?r+=(a-r)*s.value/d:a):Wg(s,n,r,d?n+=(i-n)*s.value/d:i,a),d-=s.value;}else t._squarify=o=Hg(e,t,n,r,i,a),o.ratio=e;}return n.ratio=function(e){return t((e=+e)>1?e:1)},n}(qg);function Kg(t){var e=t.length;return function(n){return t[Math.max(0,Math.min(e-1,Math.floor(n*e)))]}}function Jg(t,e){var n=vr(+t,+e);return function(t){var e=n(t);return e-360*Math.floor(e/360)}}function ty(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function ey(t){return ((t=Math.exp(t))+1/t)/2}const ny=function t(e,n,r){function i(t,i){var a,o,s=t[0],c=t[1],l=t[2],u=i[0],h=i[1],f=i[2],d=u-s,p=h-c,g=d*d+p*p;if(g<1e-12)o=Math.log(f/l)/e,a=function(t){return [s+t*d,c+t*p,l*Math.exp(e*t*o)]};else {var y=Math.sqrt(g),m=(f*f-l*l+r*g)/(2*l*n*y),b=(f*f-l*l-r*g)/(2*f*n*y),v=Math.log(Math.sqrt(m*m+1)-m),_=Math.log(Math.sqrt(b*b+1)-b);o=(_-v)/e,a=function(t){var r,i=t*o,a=ey(v),u=l/(n*y)*(a*(r=e*i+v,((r=Math.exp(2*r))-1)/(r+1))-function(t){return ((t=Math.exp(t))-1/t)/2}(v));return [s+u*d,c+u*p,l*a/ey(e*i+v)]};}return a.duration=1e3*o*e/Math.SQRT2,a}return i.rho=function(e){var n=Math.max(.001,+e),r=n*n;return t(n,r,r*r)},i}(Math.SQRT2,2,4);function ry(t){return function(e,n){var r=t((e=hr(e)).h,(n=hr(n)).h),i=_r(e.s,n.s),a=_r(e.l,n.l),o=_r(e.opacity,n.opacity);return function(t){return e.h=r(t),e.s=i(t),e.l=a(t),e.opacity=o(t),e+""}}}const iy=ry(vr);var ay=ry(_r);function oy(t,e){var n=_r((t=ko(t)).l,(e=ko(e)).l),r=_r(t.a,e.a),i=_r(t.b,e.b),a=_r(t.opacity,e.opacity);return function(e){return t.l=n(e),t.a=r(e),t.b=i(e),t.opacity=a(e),t+""}}function sy(t){return function(e,n){var r=t((e=No(e)).h,(n=No(n)).h),i=_r(e.c,n.c),a=_r(e.l,n.l),o=_r(e.opacity,n.opacity);return function(t){return e.h=r(t),e.c=i(t),e.l=a(t),e.opacity=o(t),e+""}}}const cy=sy(vr);var ly=sy(_r);function uy(t){return function e(n){function r(e,r){var i=t((e=Uo(e)).h,(r=Uo(r)).h),a=_r(e.s,r.s),o=_r(e.l,r.l),s=_r(e.opacity,r.opacity);return function(t){return e.h=i(t),e.s=a(t),e.l=o(Math.pow(t,n)),e.opacity=s(t),e+""}}return n=+n,r.gamma=e,r}(1)}const hy=uy(vr);var fy=uy(_r);function dy(t,e){void 0===e&&(e=t,t=Ir);for(var n=0,r=e.length-1,i=e[0],a=new Array(r<0?0:r);n<r;)a[n]=t(i,i=e[++n]);return function(t){var e=Math.max(0,Math.min(r-1,Math.floor(t*=r)));return a[e](t-e)}}function py(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t(r/(e-1));return n}function gy(t){for(var e,n=-1,r=t.length,i=t[r-1],a=0;++n<r;)e=i,i=t[n],a+=e[1]*i[0]-e[0]*i[1];return a/2}function yy(t){for(var e,n,r=-1,i=t.length,a=0,o=0,s=t[i-1],c=0;++r<i;)e=s,s=t[r],c+=n=e[0]*s[1]-s[0]*e[1],a+=(e[0]+s[0])*n,o+=(e[1]+s[1])*n;return [a/(c*=3),o/c]}function my(t,e,n){return (e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}function by(t,e){return t[0]-e[0]||t[1]-e[1]}function vy(t){const e=t.length,n=[0,1];let r,i=2;for(r=2;r<e;++r){for(;i>1&&my(t[n[i-2]],t[n[i-1]],t[r])<=0;)--i;n[i++]=r;}return n.slice(0,i)}function _y(t){if((n=t.length)<3)return null;var e,n,r=new Array(n),i=new Array(n);for(e=0;e<n;++e)r[e]=[+t[e][0],+t[e][1],e];for(r.sort(by),e=0;e<n;++e)i[e]=[r[e][0],-r[e][1]];var a=vy(r),o=vy(i),s=o[0]===a[0],c=o[o.length-1]===a[a.length-1],l=[];for(e=a.length-1;e>=0;--e)l.push(t[r[a[e]][2]]);for(e=+s;e<o.length-c;++e)l.push(t[r[o[e]][2]]);return l}function xy(t,e){for(var n,r,i=t.length,a=t[i-1],o=e[0],s=e[1],c=a[0],l=a[1],u=!1,h=0;h<i;++h)n=(a=t[h])[0],(r=a[1])>s!=l>s&&o<(c-n)*(s-r)/(l-r)+n&&(u=!u),c=n,l=r;return u}function ky(t){for(var e,n,r=-1,i=t.length,a=t[i-1],o=a[0],s=a[1],c=0;++r<i;)e=o,n=s,e-=o=(a=t[r])[0],n-=s=a[1],c+=Math.hypot(e,n);return c}const wy=Math.random,Ty=function t(e){function n(t,n){return t=null==t?0:+t,n=null==n?1:+n,1===arguments.length?(n=t,t=0):n-=t,function(){return e()*n+t}}return n.source=t,n}(wy),Ey=function t(e){function n(t,n){return arguments.length<2&&(n=t,t=0),t=Math.floor(t),n=Math.floor(n)-t,function(){return Math.floor(e()*n+t)}}return n.source=t,n}(wy),Cy=function t(e){function n(t,n){var r,i;return t=null==t?0:+t,n=null==n?1:+n,function(){var a;if(null!=r)a=r,r=null;else do{r=2*e()-1,a=2*e()-1,i=r*r+a*a;}while(!i||i>1);return t+n*a*Math.sqrt(-2*Math.log(i)/i)}}return n.source=t,n}(wy),Sy=function t(e){var n=Cy.source(e);function r(){var t=n.apply(this,arguments);return function(){return Math.exp(t())}}return r.source=t,r}(wy),Ay=function t(e){function n(t){return (t=+t)<=0?()=>0:function(){for(var n=0,r=t;r>1;--r)n+=e();return n+r*e()}}return n.source=t,n}(wy),My=function t(e){var n=Ay.source(e);function r(t){if(0==(t=+t))return e;var r=n(t);return function(){return r()/t}}return r.source=t,r}(wy),Ny=function t(e){function n(t){return function(){return -Math.log1p(-e())/t}}return n.source=t,n}(wy),Oy=function t(e){function n(t){if((t=+t)<0)throw new RangeError("invalid alpha");return t=1/-t,function(){return Math.pow(1-e(),t)}}return n.source=t,n}(wy),Dy=function t(e){function n(t){if((t=+t)<0||t>1)throw new RangeError("invalid p");return function(){return Math.floor(e()+t)}}return n.source=t,n}(wy),By=function t(e){function n(t){if((t=+t)<0||t>1)throw new RangeError("invalid p");return 0===t?()=>1/0:1===t?()=>1:(t=Math.log1p(-t),function(){return 1+Math.floor(Math.log1p(-e())/t)})}return n.source=t,n}(wy),Ly=function t(e){var n=Cy.source(e)();function r(t,r){if((t=+t)<0)throw new RangeError("invalid k");if(0===t)return ()=>0;if(r=null==r?1:+r,1===t)return ()=>-Math.log1p(-e())*r;var i=(t<1?t+1:t)-1/3,a=1/(3*Math.sqrt(i)),o=t<1?()=>Math.pow(e(),1/t):()=>1;return function(){do{do{var t=n(),s=1+a*t;}while(s<=0);s*=s*s;var c=1-e();}while(c>=1-.0331*t*t*t*t&&Math.log(c)>=.5*t*t+i*(1-s+Math.log(s)));return i*s*o()*r}}return r.source=t,r}(wy),Iy=function t(e){var n=Ly.source(e);function r(t,e){var r=n(t),i=n(e);return function(){var t=r();return 0===t?0:t/(t+i())}}return r.source=t,r}(wy),Fy=function t(e){var n=By.source(e),r=Iy.source(e);function i(t,e){return t=+t,(e=+e)>=1?()=>t:e<=0?()=>0:function(){for(var i=0,a=t,o=e;a*o>16&&a*(1-o)>16;){var s=Math.floor((a+1)*o),c=r(s,a-s+1)();c<=o?(i+=s,a-=s,o=(o-c)/(1-c)):(a=s-1,o/=c);}for(var l=o<.5,u=n(l?o:1-o),h=u(),f=0;h<=a;++f)h+=u();return i+(l?f:a-f)}}return i.source=t,i}(wy),Ry=function t(e){function n(t,n,r){var i;return 0==(t=+t)?i=t=>-Math.log(t):(t=1/t,i=e=>Math.pow(e,t)),n=null==n?0:+n,r=null==r?1:+r,function(){return n+r*i(-Math.log1p(-e()))}}return n.source=t,n}(wy),Py=function t(e){function n(t,n){return t=null==t?0:+t,n=null==n?1:+n,function(){return t+n*Math.tan(Math.PI*e())}}return n.source=t,n}(wy),jy=function t(e){function n(t,n){return t=null==t?0:+t,n=null==n?1:+n,function(){var r=e();return t+n*Math.log(r/(1-r))}}return n.source=t,n}(wy),zy=function t(e){var n=Ly.source(e),r=Fy.source(e);function i(t){return function(){for(var i=0,a=t;a>16;){var o=Math.floor(.875*a),s=n(o)();if(s>a)return i+r(o-1,a/s)();i+=o,a-=s;}for(var c=-Math.log1p(-e()),l=0;c<=a;++l)c-=Math.log1p(-e());return i+l}}return i.source=t,i}(wy),Yy=1/4294967296;function Uy(t=Math.random()){let e=0|(0<=t&&t<1?t/Yy:Math.abs(t));return ()=>(e=1664525*e+1013904223|0,Yy*(e>>>0))}function $y(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);}return this}function Wy(t,e){switch(arguments.length){case 0:break;case 1:"function"==typeof t?this.interpolator(t):this.range(t);break;default:this.domain(t),"function"==typeof e?this.interpolator(e):this.range(e);}return this}const qy=Symbol("implicit");function Hy(){var t=new T,e=[],n=[],r=qy;function i(i){let a=t.get(i);if(void 0===a){if(r!==qy)return r;t.set(i,a=e.push(i)-1);}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return e.slice();e=[],t=new T;for(const r of n)t.has(r)||t.set(r,e.push(r)-1);return i},i.range=function(t){return arguments.length?(n=Array.from(t),i):n.slice()},i.unknown=function(t){return arguments.length?(r=t,i):r},i.copy=function(){return Hy(e,n).unknown(r)},$y.apply(i,arguments),i}function Vy(){var t,e,n=Hy().unknown(void 0),r=n.domain,i=n.range,a=0,o=1,s=!1,c=0,l=0,u=.5;function h(){var n=r().length,h=o<a,f=h?o:a,d=h?a:o;t=(d-f)/Math.max(1,n-c+2*l),s&&(t=Math.floor(t)),f+=(d-f-t*(n-c))*u,e=t*(1-c),s&&(f=Math.round(f),e=Math.round(e));var p=xt(n).map((function(e){return f+t*e}));return i(h?p.reverse():p)}return delete n.unknown,n.domain=function(t){return arguments.length?(r(t),h()):r()},n.range=function(t){return arguments.length?([a,o]=t,a=+a,o=+o,h()):[a,o]},n.rangeRound=function(t){return [a,o]=t,a=+a,o=+o,s=!0,h()},n.bandwidth=function(){return e},n.step=function(){return t},n.round=function(t){return arguments.length?(s=!!t,h()):s},n.padding=function(t){return arguments.length?(c=Math.min(1,l=+t),h()):c},n.paddingInner=function(t){return arguments.length?(c=Math.min(1,t),h()):c},n.paddingOuter=function(t){return arguments.length?(l=+t,h()):l},n.align=function(t){return arguments.length?(u=Math.max(0,Math.min(1,t)),h()):u},n.copy=function(){return Vy(r(),[a,o]).round(s).paddingInner(c).paddingOuter(l).align(u)},$y.apply(h(),arguments)}function Gy(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return Gy(e())},t}function Xy(){return Gy(Vy.apply(null,arguments).paddingInner(1))}function Zy(t){return +t}var Qy=[0,1];function Ky(t){return t}function Jy(t,e){return (e-=t=+t)?function(n){return (n-t)/e}:(n=isNaN(e)?NaN:.5,function(){return n});var n;}function tm(t,e,n){var r=t[0],i=t[1],a=e[0],o=e[1];return i<r?(r=Jy(i,r),a=n(o,a)):(r=Jy(r,i),a=n(a,o)),function(t){return a(r(t))}}function em(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),a=new Array(r),o=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<r;)i[o]=Jy(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(e){var n=u(t,e,1,r)-1;return a[n](i[n](e))}}function nm(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function rm(){var t,e,n,r,i,a,o=Qy,s=Qy,c=Ir,l=Ky;function u(){var t,e,n,c=Math.min(o.length,s.length);return l!==Ky&&(t=o[0],e=o[c-1],t>e&&(n=t,t=e,e=n),l=function(n){return Math.max(t,Math.min(e,n))}),r=c>2?em:tm,i=a=null,h}function h(e){return null==e||isNaN(e=+e)?n:(i||(i=r(o.map(t),s,c)))(t(l(e)))}return h.invert=function(n){return l(e((a||(a=r(s,o.map(t),Nr)))(n)))},h.domain=function(t){return arguments.length?(o=Array.from(t,Zy),u()):o.slice()},h.range=function(t){return arguments.length?(s=Array.from(t),u()):s.slice()},h.rangeRound=function(t){return s=Array.from(t),c=ty,u()},h.clamp=function(t){return arguments.length?(l=!!t||Ky,u()):l!==Ky},h.interpolate=function(t){return arguments.length?(c=t,u()):c},h.unknown=function(t){return arguments.length?(n=t,h):n},function(n,r){return t=n,e=r,u()}}function im(){return rm()(Ky,Ky)}function am(t,e,n,r){var i,a=et(t,e,n);switch((r=Il(null==r?",f":r)).type){case"s":var o=Math.max(Math.abs(t),Math.abs(e));return null!=r.precision||isNaN(i=Gl(a,o))||(r.precision=i),Ul(r,o);case"":case"e":case"g":case"p":case"r":null!=r.precision||isNaN(i=Xl(a,Math.max(Math.abs(t),Math.abs(e))))||(r.precision=i-("e"===r.type));break;case"f":case"%":null!=r.precision||isNaN(i=Vl(a))||(r.precision=i-2*("%"===r.type));}return Yl(r)}function om(t){var e=t.domain;return t.ticks=function(t){var n=e();return J(n[0],n[n.length-1],null==t?10:t)},t.tickFormat=function(t,n){var r=e();return am(r[0],r[r.length-1],null==t?10:t,n)},t.nice=function(n){null==n&&(n=10);var r,i,a=e(),o=0,s=a.length-1,c=a[o],l=a[s],u=10;for(l<c&&(i=c,c=l,l=i,i=o,o=s,s=i);u-- >0;){if((i=tt(c,l,n))===r)return a[o]=c,a[s]=l,e(a);if(i>0)c=Math.floor(c/i)*i,l=Math.ceil(l/i)*i;else {if(!(i<0))break;c=Math.ceil(c*i)/i,l=Math.floor(l*i)/i;}r=i;}return t},t}function sm(){var t=im();return t.copy=function(){return nm(t,sm())},$y.apply(t,arguments),om(t)}function cm(t){var e;function n(t){return null==t||isNaN(t=+t)?e:t}return n.invert=n,n.domain=n.range=function(e){return arguments.length?(t=Array.from(e,Zy),n):t.slice()},n.unknown=function(t){return arguments.length?(e=t,n):e},n.copy=function(){return cm(t).unknown(e)},t=arguments.length?Array.from(t,Zy):[0,1],om(n)}function lm(t,e){var n,r=0,i=(t=t.slice()).length-1,a=t[r],o=t[i];return o<a&&(n=r,r=i,i=n,n=a,a=o,o=n),t[r]=e.floor(a),t[i]=e.ceil(o),t}function um(t){return Math.log(t)}function hm(t){return Math.exp(t)}function fm(t){return -Math.log(-t)}function dm(t){return -Math.exp(-t)}function pm(t){return isFinite(t)?+("1e"+t):t<0?0:t}function gm(t){return (e,n)=>-t(-e,n)}function ym(t){const e=t(um,hm),n=e.domain;let r,i,a=10;function o(){return r=function(t){return t===Math.E?Math.log:10===t&&Math.log10||2===t&&Math.log2||(t=Math.log(t),e=>Math.log(e)/t)}(a),i=function(t){return 10===t?pm:t===Math.E?Math.exp:e=>Math.pow(t,e)}(a),n()[0]<0?(r=gm(r),i=gm(i),t(fm,dm)):t(um,hm),e}return e.base=function(t){return arguments.length?(a=+t,o()):a},e.domain=function(t){return arguments.length?(n(t),o()):n()},e.ticks=t=>{const e=n();let o=e[0],s=e[e.length-1];const c=s<o;c&&([o,s]=[s,o]);let l,u,h=r(o),f=r(s);const d=null==t?10:+t;let p=[];if(!(a%1)&&f-h<d){if(h=Math.floor(h),f=Math.ceil(f),o>0){for(;h<=f;++h)for(l=1;l<a;++l)if(u=h<0?l/i(-h):l*i(h),!(u<o)){if(u>s)break;p.push(u);}}else for(;h<=f;++h)for(l=a-1;l>=1;--l)if(u=h>0?l/i(-h):l*i(h),!(u<o)){if(u>s)break;p.push(u);}2*p.length<d&&(p=J(o,s,d));}else p=J(h,f,Math.min(f-h,d)).map(i);return c?p.reverse():p},e.tickFormat=(t,n)=>{if(null==t&&(t=10),null==n&&(n=10===a?"s":","),"function"!=typeof n&&(a%1||null!=(n=Il(n)).precision||(n.trim=!0),n=Yl(n)),t===1/0)return n;const o=Math.max(1,a*t/e.ticks().length);return t=>{let e=t/i(Math.round(r(t)));return e*a<a-.5&&(e*=a),e<=o?n(t):""}},e.nice=()=>n(lm(n(),{floor:t=>i(Math.floor(r(t))),ceil:t=>i(Math.ceil(r(t)))})),e}function mm(){const t=ym(rm()).domain([1,10]);return t.copy=()=>nm(t,mm()).base(t.base()),$y.apply(t,arguments),t}function bm(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function vm(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function _m(t){var e=1,n=t(bm(e),vm(e));return n.constant=function(n){return arguments.length?t(bm(e=+n),vm(e)):e},om(n)}function xm(){var t=_m(rm());return t.copy=function(){return nm(t,xm()).constant(t.constant())},$y.apply(t,arguments)}function km(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function wm(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function Tm(t){return t<0?-t*t:t*t}function Em(t){var e=t(Ky,Ky),n=1;function r(){return 1===n?t(Ky,Ky):.5===n?t(wm,Tm):t(km(n),km(1/n))}return e.exponent=function(t){return arguments.length?(n=+t,r()):n},om(e)}function Cm(){var t=Em(rm());return t.copy=function(){return nm(t,Cm()).exponent(t.exponent())},$y.apply(t,arguments),t}function Sm(){return Cm.apply(null,arguments).exponent(.5)}function Am(t){return Math.sign(t)*t*t}function Mm(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function Nm(){var t,e=im(),n=[0,1],r=!1;function i(n){var i=Mm(e(n));return isNaN(i)?t:r?Math.round(i):i}return i.invert=function(t){return e.invert(Am(t))},i.domain=function(t){return arguments.length?(e.domain(t),i):e.domain()},i.range=function(t){return arguments.length?(e.range((n=Array.from(t,Zy)).map(Am)),i):n.slice()},i.rangeRound=function(t){return i.range(t).round(!0)},i.round=function(t){return arguments.length?(r=!!t,i):r},i.clamp=function(t){return arguments.length?(e.clamp(t),i):e.clamp()},i.unknown=function(e){return arguments.length?(t=e,i):t},i.copy=function(){return Nm(e.domain(),n).round(r).clamp(e.clamp()).unknown(t)},$y.apply(i,arguments),om(i)}function Om(){var t,e=[],n=[],i=[];function a(){var t=0,r=Math.max(1,n.length);for(i=new Array(r-1);++t<r;)i[t-1]=ut(e,t/r);return o}function o(e){return null==e||isNaN(e=+e)?t:n[u(i,e)]}return o.invertExtent=function(t){var r=n.indexOf(t);return r<0?[NaN,NaN]:[r>0?i[r-1]:e[0],r<i.length?i[r]:e[e.length-1]]},o.domain=function(t){if(!arguments.length)return e.slice();e=[];for(let n of t)null==n||isNaN(n=+n)||e.push(n);return e.sort(r),a()},o.range=function(t){return arguments.length?(n=Array.from(t),a()):n.slice()},o.unknown=function(e){return arguments.length?(t=e,o):t},o.quantiles=function(){return i.slice()},o.copy=function(){return Om().domain(e).range(n).unknown(t)},$y.apply(o,arguments)}function Dm(){var t,e=0,n=1,r=1,i=[.5],a=[0,1];function o(e){return null!=e&&e<=e?a[u(i,e,0,r)]:t}function s(){var t=-1;for(i=new Array(r);++t<r;)i[t]=((t+1)*n-(t-r)*e)/(r+1);return o}return o.domain=function(t){return arguments.length?([e,n]=t,e=+e,n=+n,s()):[e,n]},o.range=function(t){return arguments.length?(r=(a=Array.from(t)).length-1,s()):a.slice()},o.invertExtent=function(t){var o=a.indexOf(t);return o<0?[NaN,NaN]:o<1?[e,i[0]]:o>=r?[i[r-1],n]:[i[o-1],i[o]]},o.unknown=function(e){return arguments.length?(t=e,o):o},o.thresholds=function(){return i.slice()},o.copy=function(){return Dm().domain([e,n]).range(a).unknown(t)},$y.apply(om(o),arguments)}function Bm(){var t,e=[.5],n=[0,1],r=1;function i(i){return null!=i&&i<=i?n[u(e,i,0,r)]:t}return i.domain=function(t){return arguments.length?(e=Array.from(t),r=Math.min(e.length,n.length-1),i):e.slice()},i.range=function(t){return arguments.length?(n=Array.from(t),r=Math.min(e.length,n.length-1),i):n.slice()},i.invertExtent=function(t){var r=n.indexOf(t);return [e[r-1],e[r]]},i.unknown=function(e){return arguments.length?(t=e,i):t},i.copy=function(){return Bm().domain(e).range(n).unknown(t)},$y.apply(i,arguments)}const Lm=1e3,Im=6e4,Fm=36e5,Rm=864e5,Pm=6048e5,jm=31536e6;var zm=new Date,Ym=new Date;function Um(t,e,n,r){function i(e){return t(e=0===arguments.length?new Date:new Date(+e)),e}return i.floor=function(e){return t(e=new Date(+e)),e},i.ceil=function(n){return t(n=new Date(n-1)),e(n,1),t(n),n},i.round=function(t){var e=i(t),n=i.ceil(t);return t-e<n-t?e:n},i.offset=function(t,n){return e(t=new Date(+t),null==n?1:Math.floor(n)),t},i.range=function(n,r,a){var o,s=[];if(n=i.ceil(n),a=null==a?1:Math.floor(a),!(n<r&&a>0))return s;do{s.push(o=new Date(+n)),e(n,a),t(n);}while(o<n&&n<r);return s},i.filter=function(n){return Um((function(e){if(e>=e)for(;t(e),!n(e);)e.setTime(e-1);}),(function(t,r){if(t>=t)if(r<0)for(;++r<=0;)for(;e(t,-1),!n(t););else for(;--r>=0;)for(;e(t,1),!n(t););}))},n&&(i.count=function(e,r){return zm.setTime(+e),Ym.setTime(+r),t(zm),t(Ym),Math.floor(n(zm,Ym))},i.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?i.filter(r?function(e){return r(e)%t==0}:function(e){return i.count(0,e)%t==0}):i:null}),i}var $m=Um((function(){}),(function(t,e){t.setTime(+t+e);}),(function(t,e){return e-t}));$m.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?Um((function(e){e.setTime(Math.floor(e/t)*t);}),(function(e,n){e.setTime(+e+n*t);}),(function(e,n){return (n-e)/t})):$m:null};const Wm=$m;var qm=$m.range,Hm=Um((function(t){t.setTime(t-t.getMilliseconds());}),(function(t,e){t.setTime(+t+e*Lm);}),(function(t,e){return (e-t)/Lm}),(function(t){return t.getUTCSeconds()}));const Vm=Hm;var Gm=Hm.range,Xm=Um((function(t){t.setTime(t-t.getMilliseconds()-t.getSeconds()*Lm);}),(function(t,e){t.setTime(+t+e*Im);}),(function(t,e){return (e-t)/Im}),(function(t){return t.getMinutes()}));const Zm=Xm;var Qm=Xm.range,Km=Um((function(t){t.setTime(t-t.getMilliseconds()-t.getSeconds()*Lm-t.getMinutes()*Im);}),(function(t,e){t.setTime(+t+e*Fm);}),(function(t,e){return (e-t)/Fm}),(function(t){return t.getHours()}));const Jm=Km;var tb=Km.range,eb=Um((t=>t.setHours(0,0,0,0)),((t,e)=>t.setDate(t.getDate()+e)),((t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Im)/Rm),(t=>t.getDate()-1));const nb=eb;var rb=eb.range;function ib(t){return Um((function(e){e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0);}),(function(t,e){t.setDate(t.getDate()+7*e);}),(function(t,e){return (e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Im)/Pm}))}var ab=ib(0),ob=ib(1),sb=ib(2),cb=ib(3),lb=ib(4),ub=ib(5),hb=ib(6),fb=ab.range,db=ob.range,pb=sb.range,gb=cb.range,yb=lb.range,mb=ub.range,bb=hb.range,vb=Um((function(t){t.setDate(1),t.setHours(0,0,0,0);}),(function(t,e){t.setMonth(t.getMonth()+e);}),(function(t,e){return e.getMonth()-t.getMonth()+12*(e.getFullYear()-t.getFullYear())}),(function(t){return t.getMonth()}));const _b=vb;var xb=vb.range,kb=Um((function(t){t.setMonth(0,1),t.setHours(0,0,0,0);}),(function(t,e){t.setFullYear(t.getFullYear()+e);}),(function(t,e){return e.getFullYear()-t.getFullYear()}),(function(t){return t.getFullYear()}));kb.every=function(t){return isFinite(t=Math.floor(t))&&t>0?Um((function(e){e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0);}),(function(e,n){e.setFullYear(e.getFullYear()+n*t);})):null};const wb=kb;var Tb=kb.range,Eb=Um((function(t){t.setUTCSeconds(0,0);}),(function(t,e){t.setTime(+t+e*Im);}),(function(t,e){return (e-t)/Im}),(function(t){return t.getUTCMinutes()}));const Cb=Eb;var Sb=Eb.range,Ab=Um((function(t){t.setUTCMinutes(0,0,0);}),(function(t,e){t.setTime(+t+e*Fm);}),(function(t,e){return (e-t)/Fm}),(function(t){return t.getUTCHours()}));const Mb=Ab;var Nb=Ab.range,Ob=Um((function(t){t.setUTCHours(0,0,0,0);}),(function(t,e){t.setUTCDate(t.getUTCDate()+e);}),(function(t,e){return (e-t)/Rm}),(function(t){return t.getUTCDate()-1}));const Db=Ob;var Bb=Ob.range;function Lb(t){return Um((function(e){e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0);}),(function(t,e){t.setUTCDate(t.getUTCDate()+7*e);}),(function(t,e){return (e-t)/Pm}))}var Ib=Lb(0),Fb=Lb(1),Rb=Lb(2),Pb=Lb(3),jb=Lb(4),zb=Lb(5),Yb=Lb(6),Ub=Ib.range,$b=Fb.range,Wb=Rb.range,qb=Pb.range,Hb=jb.range,Vb=zb.range,Gb=Yb.range,Xb=Um((function(t){t.setUTCDate(1),t.setUTCHours(0,0,0,0);}),(function(t,e){t.setUTCMonth(t.getUTCMonth()+e);}),(function(t,e){return e.getUTCMonth()-t.getUTCMonth()+12*(e.getUTCFullYear()-t.getUTCFullYear())}),(function(t){return t.getUTCMonth()}));const Zb=Xb;var Qb=Xb.range,Kb=Um((function(t){t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0);}),(function(t,e){t.setUTCFullYear(t.getUTCFullYear()+e);}),(function(t,e){return e.getUTCFullYear()-t.getUTCFullYear()}),(function(t){return t.getUTCFullYear()}));Kb.every=function(t){return isFinite(t=Math.floor(t))&&t>0?Um((function(e){e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0);}),(function(e,n){e.setUTCFullYear(e.getUTCFullYear()+n*t);})):null};const Jb=Kb;var tv=Kb.range;function ev(t,e,n,r,a,o){const s=[[Vm,1,Lm],[Vm,5,5e3],[Vm,15,15e3],[Vm,30,3e4],[o,1,Im],[o,5,3e5],[o,15,9e5],[o,30,18e5],[a,1,Fm],[a,3,108e5],[a,6,216e5],[a,12,432e5],[r,1,Rm],[r,2,1728e5],[n,1,Pm],[e,1,2592e6],[e,3,7776e6],[t,1,jm]];function c(e,n,r){const a=Math.abs(n-e)/r,o=i((([,,t])=>t)).right(s,a);if(o===s.length)return t.every(et(e/jm,n/jm,r));if(0===o)return Wm.every(Math.max(et(e,n,r),1));const[c,l]=s[a/s[o-1][2]<s[o][2]/a?o-1:o];return c.every(l)}return [function(t,e,n){const r=e<t;r&&([t,e]=[e,t]);const i=n&&"function"==typeof n.range?n:c(t,e,n),a=i?i.range(t,+e+1):[];return r?a.reverse():a},c]}const[nv,rv]=ev(Jb,Zb,Ib,Db,Mb,Cb),[iv,av]=ev(wb,_b,ab,nb,Jm,Zm);function ov(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function sv(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function cv(t,e,n){return {y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function lv(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,o=t.shortDays,s=t.months,c=t.shortMonths,l=xv(i),u=kv(i),h=xv(a),f=kv(a),d=xv(o),p=kv(o),g=xv(s),y=kv(s),m=xv(c),b=kv(c),v={a:function(t){return o[t.getDay()]},A:function(t){return a[t.getDay()]},b:function(t){return c[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:null,d:$v,e:$v,f:Gv,g:a_,G:s_,H:Wv,I:qv,j:Hv,L:Vv,m:Xv,M:Zv,p:function(t){return i[+(t.getHours()>=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:N_,s:O_,S:Qv,u:Kv,U:Jv,V:e_,w:n_,W:r_,x:null,X:null,y:i_,Y:o_,Z:c_,"%":M_},_={a:function(t){return o[t.getUTCDay()]},A:function(t){return a[t.getUTCDay()]},b:function(t){return c[t.getUTCMonth()]},B:function(t){return s[t.getUTCMonth()]},c:null,d:l_,e:l_,f:p_,g:E_,G:S_,H:u_,I:h_,j:f_,L:d_,m:g_,M:y_,p:function(t){return i[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:N_,s:O_,S:m_,u:b_,U:v_,V:x_,w:k_,W:w_,x:null,X:null,y:T_,Y:C_,Z:A_,"%":M_},x={a:function(t,e,n){var r=d.exec(e.slice(n));return r?(t.w=p.get(r[0].toLowerCase()),n+r[0].length):-1},A:function(t,e,n){var r=h.exec(e.slice(n));return r?(t.w=f.get(r[0].toLowerCase()),n+r[0].length):-1},b:function(t,e,n){var r=m.exec(e.slice(n));return r?(t.m=b.get(r[0].toLowerCase()),n+r[0].length):-1},B:function(t,e,n){var r=g.exec(e.slice(n));return r?(t.m=y.get(r[0].toLowerCase()),n+r[0].length):-1},c:function(t,n,r){return T(t,e,n,r)},d:Bv,e:Bv,f:jv,g:Mv,G:Av,H:Iv,I:Iv,j:Lv,L:Pv,m:Dv,M:Fv,p:function(t,e,n){var r=l.exec(e.slice(n));return r?(t.p=u.get(r[0].toLowerCase()),n+r[0].length):-1},q:Ov,Q:Yv,s:Uv,S:Rv,u:Tv,U:Ev,V:Cv,w:wv,W:Sv,x:function(t,e,r){return T(t,n,e,r)},X:function(t,e,n){return T(t,r,e,n)},y:Mv,Y:Av,Z:Nv,"%":zv};function k(t,e){return function(n){var r,i,a,o=[],s=-1,c=0,l=t.length;for(n instanceof Date||(n=new Date(+n));++s<l;)37===t.charCodeAt(s)&&(o.push(t.slice(c,s)),null!=(i=gv[r=t.charAt(++s)])?r=t.charAt(++s):i="e"===r?" ":"0",(a=e[r])&&(r=a(n,i)),o.push(r),c=s+1);return o.push(t.slice(c,s)),o.join("")}}function w(t,e){return function(n){var r,i,a=cv(1900,void 0,1);if(T(a,t,n+="",0)!=n.length)return null;if("Q"in a)return new Date(a.Q);if("s"in a)return new Date(1e3*a.s+("L"in a?a.L:0));if(e&&!("Z"in a)&&(a.Z=0),"p"in a&&(a.H=a.H%12+12*a.p),void 0===a.m&&(a.m="q"in a?a.q:0),"V"in a){if(a.V<1||a.V>53)return null;"w"in a||(a.w=1),"Z"in a?(i=(r=sv(cv(a.y,0,1))).getUTCDay(),r=i>4||0===i?Fb.ceil(r):Fb(r),r=Db.offset(r,7*(a.V-1)),a.y=r.getUTCFullYear(),a.m=r.getUTCMonth(),a.d=r.getUTCDate()+(a.w+6)%7):(i=(r=ov(cv(a.y,0,1))).getDay(),r=i>4||0===i?ob.ceil(r):ob(r),r=nb.offset(r,7*(a.V-1)),a.y=r.getFullYear(),a.m=r.getMonth(),a.d=r.getDate()+(a.w+6)%7);}else ("W"in a||"U"in a)&&("w"in a||(a.w="u"in a?a.u%7:"W"in a?1:0),i="Z"in a?sv(cv(a.y,0,1)).getUTCDay():ov(cv(a.y,0,1)).getDay(),a.m=0,a.d="W"in a?(a.w+6)%7+7*a.W-(i+5)%7:a.w+7*a.U-(i+6)%7);return "Z"in a?(a.H+=a.Z/100|0,a.M+=a.Z%100,sv(a)):ov(a)}}function T(t,e,n,r){for(var i,a,o=0,s=e.length,c=n.length;o<s;){if(r>=c)return -1;if(37===(i=e.charCodeAt(o++))){if(i=e.charAt(o++),!(a=x[i in gv?e.charAt(o++):i])||(r=a(t,n,r))<0)return -1}else if(i!=n.charCodeAt(r++))return -1}return r}return v.x=k(n,v),v.X=k(r,v),v.c=k(e,v),_.x=k(n,_),_.X=k(r,_),_.c=k(e,_),{format:function(t){var e=k(t+="",v);return e.toString=function(){return t},e},parse:function(t){var e=w(t+="",!1);return e.toString=function(){return t},e},utcFormat:function(t){var e=k(t+="",_);return e.toString=function(){return t},e},utcParse:function(t){var e=w(t+="",!0);return e.toString=function(){return t},e}}}var uv,hv,fv,dv,pv,gv={"-":"",_:" ",0:"0"},yv=/^\s*\d+/,mv=/^%/,bv=/[\\^$*+?|[\]().{}]/g;function vv(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(e)+i:i)}function _v(t){return t.replace(bv,"\\$&")}function xv(t){return new RegExp("^(?:"+t.map(_v).join("|")+")","i")}function kv(t){return new Map(t.map(((t,e)=>[t.toLowerCase(),e])))}function wv(t,e,n){var r=yv.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Tv(t,e,n){var r=yv.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Ev(t,e,n){var r=yv.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Cv(t,e,n){var r=yv.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Sv(t,e,n){var r=yv.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function Av(t,e,n){var r=yv.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function Mv(t,e,n){var r=yv.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Nv(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function Ov(t,e,n){var r=yv.exec(e.slice(n,n+1));return r?(t.q=3*r[0]-3,n+r[0].length):-1}function Dv(t,e,n){var r=yv.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function Bv(t,e,n){var r=yv.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Lv(t,e,n){var r=yv.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function Iv(t,e,n){var r=yv.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Fv(t,e,n){var r=yv.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Rv(t,e,n){var r=yv.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Pv(t,e,n){var r=yv.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function jv(t,e,n){var r=yv.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function zv(t,e,n){var r=mv.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Yv(t,e,n){var r=yv.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Uv(t,e,n){var r=yv.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function $v(t,e){return vv(t.getDate(),e,2)}function Wv(t,e){return vv(t.getHours(),e,2)}function qv(t,e){return vv(t.getHours()%12||12,e,2)}function Hv(t,e){return vv(1+nb.count(wb(t),t),e,3)}function Vv(t,e){return vv(t.getMilliseconds(),e,3)}function Gv(t,e){return Vv(t,e)+"000"}function Xv(t,e){return vv(t.getMonth()+1,e,2)}function Zv(t,e){return vv(t.getMinutes(),e,2)}function Qv(t,e){return vv(t.getSeconds(),e,2)}function Kv(t){var e=t.getDay();return 0===e?7:e}function Jv(t,e){return vv(ab.count(wb(t)-1,t),e,2)}function t_(t){var e=t.getDay();return e>=4||0===e?lb(t):lb.ceil(t)}function e_(t,e){return t=t_(t),vv(lb.count(wb(t),t)+(4===wb(t).getDay()),e,2)}function n_(t){return t.getDay()}function r_(t,e){return vv(ob.count(wb(t)-1,t),e,2)}function i_(t,e){return vv(t.getFullYear()%100,e,2)}function a_(t,e){return vv((t=t_(t)).getFullYear()%100,e,2)}function o_(t,e){return vv(t.getFullYear()%1e4,e,4)}function s_(t,e){var n=t.getDay();return vv((t=n>=4||0===n?lb(t):lb.ceil(t)).getFullYear()%1e4,e,4)}function c_(t){var e=t.getTimezoneOffset();return (e>0?"-":(e*=-1,"+"))+vv(e/60|0,"0",2)+vv(e%60,"0",2)}function l_(t,e){return vv(t.getUTCDate(),e,2)}function u_(t,e){return vv(t.getUTCHours(),e,2)}function h_(t,e){return vv(t.getUTCHours()%12||12,e,2)}function f_(t,e){return vv(1+Db.count(Jb(t),t),e,3)}function d_(t,e){return vv(t.getUTCMilliseconds(),e,3)}function p_(t,e){return d_(t,e)+"000"}function g_(t,e){return vv(t.getUTCMonth()+1,e,2)}function y_(t,e){return vv(t.getUTCMinutes(),e,2)}function m_(t,e){return vv(t.getUTCSeconds(),e,2)}function b_(t){var e=t.getUTCDay();return 0===e?7:e}function v_(t,e){return vv(Ib.count(Jb(t)-1,t),e,2)}function __(t){var e=t.getUTCDay();return e>=4||0===e?jb(t):jb.ceil(t)}function x_(t,e){return t=__(t),vv(jb.count(Jb(t),t)+(4===Jb(t).getUTCDay()),e,2)}function k_(t){return t.getUTCDay()}function w_(t,e){return vv(Fb.count(Jb(t)-1,t),e,2)}function T_(t,e){return vv(t.getUTCFullYear()%100,e,2)}function E_(t,e){return vv((t=__(t)).getUTCFullYear()%100,e,2)}function C_(t,e){return vv(t.getUTCFullYear()%1e4,e,4)}function S_(t,e){var n=t.getUTCDay();return vv((t=n>=4||0===n?jb(t):jb.ceil(t)).getUTCFullYear()%1e4,e,4)}function A_(){return "+0000"}function M_(){return "%"}function N_(t){return +t}function O_(t){return Math.floor(+t/1e3)}function D_(t){return uv=lv(t),hv=uv.format,fv=uv.parse,dv=uv.utcFormat,pv=uv.utcParse,uv}function B_(t){return new Date(t)}function L_(t){return t instanceof Date?+t:+new Date(+t)}function I_(t,e,n,r,i,a,o,s,c,l){var u=im(),h=u.invert,f=u.domain,d=l(".%L"),p=l(":%S"),g=l("%I:%M"),y=l("%I %p"),m=l("%a %d"),b=l("%b %d"),v=l("%B"),_=l("%Y");function x(t){return (c(t)<t?d:s(t)<t?p:o(t)<t?g:a(t)<t?y:r(t)<t?i(t)<t?m:b:n(t)<t?v:_)(t)}return u.invert=function(t){return new Date(h(t))},u.domain=function(t){return arguments.length?f(Array.from(t,L_)):f().map(B_)},u.ticks=function(e){var n=f();return t(n[0],n[n.length-1],null==e?10:e)},u.tickFormat=function(t,e){return null==e?x:l(e)},u.nice=function(t){var n=f();return t&&"function"==typeof t.range||(t=e(n[0],n[n.length-1],null==t?10:t)),t?f(lm(n,t)):u},u.copy=function(){return nm(u,I_(t,e,n,r,i,a,o,s,c,l))},u}function F_(){return $y.apply(I_(iv,av,wb,_b,ab,nb,Jm,Zm,Vm,hv).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function R_(){return $y.apply(I_(nv,rv,Jb,Zb,Ib,Db,Mb,Cb,Vm,dv).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function P_(){var t,e,n,r,i,a=0,o=1,s=Ky,c=!1;function l(e){return null==e||isNaN(e=+e)?i:s(0===n?.5:(e=(r(e)-t)*n,c?Math.max(0,Math.min(1,e)):e))}function u(t){return function(e){var n,r;return arguments.length?([n,r]=e,s=t(n,r),l):[s(0),s(1)]}}return l.domain=function(i){return arguments.length?([a,o]=i,t=r(a=+a),e=r(o=+o),n=t===e?0:1/(e-t),l):[a,o]},l.clamp=function(t){return arguments.length?(c=!!t,l):c},l.interpolator=function(t){return arguments.length?(s=t,l):s},l.range=u(Ir),l.rangeRound=u(ty),l.unknown=function(t){return arguments.length?(i=t,l):i},function(i){return r=i,t=i(a),e=i(o),n=t===e?0:1/(e-t),l}}function j_(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function z_(){var t=om(P_()(Ky));return t.copy=function(){return j_(t,z_())},Wy.apply(t,arguments)}function Y_(){var t=ym(P_()).domain([1,10]);return t.copy=function(){return j_(t,Y_()).base(t.base())},Wy.apply(t,arguments)}function U_(){var t=_m(P_());return t.copy=function(){return j_(t,U_()).constant(t.constant())},Wy.apply(t,arguments)}function $_(){var t=Em(P_());return t.copy=function(){return j_(t,$_()).exponent(t.exponent())},Wy.apply(t,arguments)}function W_(){return $_.apply(null,arguments).exponent(.5)}function q_(){var t=[],e=Ky;function n(n){if(null!=n&&!isNaN(n=+n))return e((u(t,n,1)-1)/(t.length-1))}return n.domain=function(e){if(!arguments.length)return t.slice();t=[];for(let n of e)null==n||isNaN(n=+n)||t.push(n);return t.sort(r),n},n.interpolator=function(t){return arguments.length?(e=t,n):e},n.range=function(){return t.map(((n,r)=>e(r/(t.length-1))))},n.quantiles=function(e){return Array.from({length:e+1},((n,r)=>lt(t,r/e)))},n.copy=function(){return q_(e).domain(t)},Wy.apply(n,arguments)}function H_(){var t,e,n,r,i,a,o,s=0,c=.5,l=1,u=1,h=Ky,f=!1;function d(t){return isNaN(t=+t)?o:(t=.5+((t=+a(t))-e)*(u*t<u*e?r:i),h(f?Math.max(0,Math.min(1,t)):t))}function p(t){return function(e){var n,r,i;return arguments.length?([n,r,i]=e,h=dy(t,[n,r,i]),d):[h(0),h(.5),h(1)]}}return d.domain=function(o){return arguments.length?([s,c,l]=o,t=a(s=+s),e=a(c=+c),n=a(l=+l),r=t===e?0:.5/(e-t),i=e===n?0:.5/(n-e),u=e<t?-1:1,d):[s,c,l]},d.clamp=function(t){return arguments.length?(f=!!t,d):f},d.interpolator=function(t){return arguments.length?(h=t,d):h},d.range=p(Ir),d.rangeRound=p(ty),d.unknown=function(t){return arguments.length?(o=t,d):o},function(o){return a=o,t=o(s),e=o(c),n=o(l),r=t===e?0:.5/(e-t),i=e===n?0:.5/(n-e),u=e<t?-1:1,d}}function V_(){var t=om(H_()(Ky));return t.copy=function(){return j_(t,V_())},Wy.apply(t,arguments)}function G_(){var t=ym(H_()).domain([.1,1,10]);return t.copy=function(){return j_(t,G_()).base(t.base())},Wy.apply(t,arguments)}function X_(){var t=_m(H_());return t.copy=function(){return j_(t,X_()).constant(t.constant())},Wy.apply(t,arguments)}function Z_(){var t=Em(H_());return t.copy=function(){return j_(t,Z_()).exponent(t.exponent())},Wy.apply(t,arguments)}function Q_(){return Z_.apply(null,arguments).exponent(.5)}function K_(t){for(var e=t.length/6|0,n=new Array(e),r=0;r<e;)n[r]="#"+t.slice(6*r,6*++r);return n}D_({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});const J_=K_("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"),tx=K_("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"),ex=K_("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"),nx=K_("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"),rx=K_("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2"),ix=K_("b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc"),ax=K_("e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999"),ox=K_("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3"),sx=K_("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"),cx=K_("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab"),lx=t=>wr(t[t.length-1]);var ux=new Array(3).concat("d8b365f5f5f55ab4ac","a6611adfc27d80cdc1018571","a6611adfc27df5f5f580cdc1018571","8c510ad8b365f6e8c3c7eae55ab4ac01665e","8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e","8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e","8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e","5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30","5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30").map(K_);const hx=lx(ux);var fx=new Array(3).concat("af8dc3f7f7f77fbf7b","7b3294c2a5cfa6dba0008837","7b3294c2a5cff7f7f7a6dba0008837","762a83af8dc3e7d4e8d9f0d37fbf7b1b7837","762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837","762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837","762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837","40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b","40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b").map(K_);const dx=lx(fx);var px=new Array(3).concat("e9a3c9f7f7f7a1d76a","d01c8bf1b6dab8e1864dac26","d01c8bf1b6daf7f7f7b8e1864dac26","c51b7de9a3c9fde0efe6f5d0a1d76a4d9221","c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221","c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221","c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221","8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419","8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419").map(K_);const gx=lx(px);var yx=new Array(3).concat("998ec3f7f7f7f1a340","5e3c99b2abd2fdb863e66101","5e3c99b2abd2f7f7f7fdb863e66101","542788998ec3d8daebfee0b6f1a340b35806","542788998ec3d8daebf7f7f7fee0b6f1a340b35806","5427888073acb2abd2d8daebfee0b6fdb863e08214b35806","5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806","2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08","2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08").map(K_);const mx=lx(yx);var bx=new Array(3).concat("ef8a62f7f7f767a9cf","ca0020f4a58292c5de0571b0","ca0020f4a582f7f7f792c5de0571b0","b2182bef8a62fddbc7d1e5f067a9cf2166ac","b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac","b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac","b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac","67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061","67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061").map(K_);const vx=lx(bx);var _x=new Array(3).concat("ef8a62ffffff999999","ca0020f4a582bababa404040","ca0020f4a582ffffffbababa404040","b2182bef8a62fddbc7e0e0e09999994d4d4d","b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d","b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d","b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d","67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a","67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a").map(K_);const xx=lx(_x);var kx=new Array(3).concat("fc8d59ffffbf91bfdb","d7191cfdae61abd9e92c7bb6","d7191cfdae61ffffbfabd9e92c7bb6","d73027fc8d59fee090e0f3f891bfdb4575b4","d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4","d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4","d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4","a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695","a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695").map(K_);const wx=lx(kx);var Tx=new Array(3).concat("fc8d59ffffbf91cf60","d7191cfdae61a6d96a1a9641","d7191cfdae61ffffbfa6d96a1a9641","d73027fc8d59fee08bd9ef8b91cf601a9850","d73027fc8d59fee08bffffbfd9ef8b91cf601a9850","d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850","d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850","a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837","a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837").map(K_);const Ex=lx(Tx);var Cx=new Array(3).concat("fc8d59ffffbf99d594","d7191cfdae61abdda42b83ba","d7191cfdae61ffffbfabdda42b83ba","d53e4ffc8d59fee08be6f59899d5943288bd","d53e4ffc8d59fee08bffffbfe6f59899d5943288bd","d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd","d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd","9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2","9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2").map(K_);const Sx=lx(Cx);var Ax=new Array(3).concat("e5f5f999d8c92ca25f","edf8fbb2e2e266c2a4238b45","edf8fbb2e2e266c2a42ca25f006d2c","edf8fbccece699d8c966c2a42ca25f006d2c","edf8fbccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b").map(K_);const Mx=lx(Ax);var Nx=new Array(3).concat("e0ecf49ebcda8856a7","edf8fbb3cde38c96c688419d","edf8fbb3cde38c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b").map(K_);const Ox=lx(Nx);var Dx=new Array(3).concat("e0f3dba8ddb543a2ca","f0f9e8bae4bc7bccc42b8cbe","f0f9e8bae4bc7bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081").map(K_);const Bx=lx(Dx);var Lx=new Array(3).concat("fee8c8fdbb84e34a33","fef0d9fdcc8afc8d59d7301f","fef0d9fdcc8afc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000").map(K_);const Ix=lx(Lx);var Fx=new Array(3).concat("ece2f0a6bddb1c9099","f6eff7bdc9e167a9cf02818a","f6eff7bdc9e167a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636").map(K_);const Rx=lx(Fx);var Px=new Array(3).concat("ece7f2a6bddb2b8cbe","f1eef6bdc9e174a9cf0570b0","f1eef6bdc9e174a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858").map(K_);const jx=lx(Px);var zx=new Array(3).concat("e7e1efc994c7dd1c77","f1eef6d7b5d8df65b0ce1256","f1eef6d7b5d8df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f").map(K_);const Yx=lx(zx);var Ux=new Array(3).concat("fde0ddfa9fb5c51b8a","feebe2fbb4b9f768a1ae017e","feebe2fbb4b9f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a").map(K_);const $x=lx(Ux);var Wx=new Array(3).concat("edf8b17fcdbb2c7fb8","ffffcca1dab441b6c4225ea8","ffffcca1dab441b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58").map(K_);const qx=lx(Wx);var Hx=new Array(3).concat("f7fcb9addd8e31a354","ffffccc2e69978c679238443","ffffccc2e69978c67931a354006837","ffffccd9f0a3addd8e78c67931a354006837","ffffccd9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529").map(K_);const Vx=lx(Hx);var Gx=new Array(3).concat("fff7bcfec44fd95f0e","ffffd4fed98efe9929cc4c02","ffffd4fed98efe9929d95f0e993404","ffffd4fee391fec44ffe9929d95f0e993404","ffffd4fee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506").map(K_);const Xx=lx(Gx);var Zx=new Array(3).concat("ffeda0feb24cf03b20","ffffb2fecc5cfd8d3ce31a1c","ffffb2fecc5cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026").map(K_);const Qx=lx(Zx);var Kx=new Array(3).concat("deebf79ecae13182bd","eff3ffbdd7e76baed62171b5","eff3ffbdd7e76baed63182bd08519c","eff3ffc6dbef9ecae16baed63182bd08519c","eff3ffc6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b").map(K_);const Jx=lx(Kx);var tk=new Array(3).concat("e5f5e0a1d99b31a354","edf8e9bae4b374c476238b45","edf8e9bae4b374c47631a354006d2c","edf8e9c7e9c0a1d99b74c47631a354006d2c","edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b").map(K_);const ek=lx(tk);var nk=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(K_);const rk=lx(nk);var ik=new Array(3).concat("efedf5bcbddc756bb1","f2f0f7cbc9e29e9ac86a51a3","f2f0f7cbc9e29e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d").map(K_);const ak=lx(ik);var ok=new Array(3).concat("fee0d2fc9272de2d26","fee5d9fcae91fb6a4acb181d","fee5d9fcae91fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d").map(K_);const sk=lx(ok);var ck=new Array(3).concat("fee6cefdae6be6550d","feeddefdbe85fd8d3cd94701","feeddefdbe85fd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704").map(K_);const lk=lx(ck);function uk(t){return t=Math.max(0,Math.min(1,t)),"rgb("+Math.max(0,Math.min(255,Math.round(-4.54-t*(35.34-t*(2381.73-t*(6402.7-t*(7024.72-2710.57*t)))))))+", "+Math.max(0,Math.min(255,Math.round(32.49+t*(170.73+t*(52.82-t*(131.46-t*(176.58-67.37*t)))))))+", "+Math.max(0,Math.min(255,Math.round(81.24+t*(442.36-t*(2482.43-t*(6167.24-t*(6614.94-2475.67*t)))))))+")"}const hk=fy(Uo(300,.5,0),Uo(-240,.5,1));var fk=fy(Uo(-100,.75,.35),Uo(80,1.5,.8)),dk=fy(Uo(260,.75,.35),Uo(80,1.5,.8)),pk=Uo();function gk(t){(t<0||t>1)&&(t-=Math.floor(t));var e=Math.abs(t-.5);return pk.h=360*t-100,pk.s=1.5-1.5*e,pk.l=.8-.9*e,pk+""}var yk=ir(),mk=Math.PI/3,bk=2*Math.PI/3;function vk(t){var e;return t=(.5-t)*Math.PI,yk.r=255*(e=Math.sin(t))*e,yk.g=255*(e=Math.sin(t+mk))*e,yk.b=255*(e=Math.sin(t+bk))*e,yk+""}function _k(t){return t=Math.max(0,Math.min(1,t)),"rgb("+Math.max(0,Math.min(255,Math.round(34.61+t*(1172.33-t*(10793.56-t*(33300.12-t*(38394.49-14825.05*t)))))))+", "+Math.max(0,Math.min(255,Math.round(23.31+t*(557.33+t*(1225.33-t*(3574.96-t*(1073.77+707.56*t)))))))+", "+Math.max(0,Math.min(255,Math.round(27.2+t*(3211.1-t*(15327.97-t*(27814-t*(22569.18-6838.66*t)))))))+")"}function xk(t){var e=t.length;return function(n){return t[Math.max(0,Math.min(e-1,Math.floor(n*e)))]}}const kk=xk(K_("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));var wk=xk(K_("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")),Tk=xk(K_("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")),Ek=xk(K_("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));function Ck(t){return Mn(pn(t).call(document.documentElement))}var Sk=0;function Ak(){return new Mk}function Mk(){this._="@"+(++Sk).toString(36);}function Nk(t,e){return t.target&&(t=Fr(t),void 0===e&&(e=t.currentTarget),t=t.touches||[t]),Array.from(t,(t=>Rr(t,e)))}function Ok(t){return "string"==typeof t?new Cn([document.querySelectorAll(t)],[document.documentElement]):new Cn([ge(t)],En)}function Dk(t){return function(){return t}}Mk.prototype=Ak.prototype={constructor:Mk,get:function(t){for(var e=this._;!(e in t);)if(!(t=t.parentNode))return;return t[e]},set:function(t,e){return t[this._]=e},remove:function(t){return this._ in t&&delete t[this._]},toString:function(){return this._}};var Bk=Math.abs,Lk=Math.atan2,Ik=Math.cos,Fk=Math.max,Rk=Math.min,Pk=Math.sin,jk=Math.sqrt,zk=1e-12,Yk=Math.PI,Uk=Yk/2,$k=2*Yk;function Wk(t){return t>1?0:t<-1?Yk:Math.acos(t)}function qk(t){return t>=1?Uk:t<=-1?-Uk:Math.asin(t)}function Hk(t){return t.innerRadius}function Vk(t){return t.outerRadius}function Gk(t){return t.startAngle}function Xk(t){return t.endAngle}function Zk(t){return t&&t.padAngle}function Qk(t,e,n,r,i,a,o,s){var c=n-t,l=r-e,u=o-i,h=s-a,f=h*c-u*l;if(!(f*f<zk))return [t+(f=(u*(e-a)-h*(t-i))/f)*c,e+f*l]}function Kk(t,e,n,r,i,a,o){var s=t-n,c=e-r,l=(o?a:-a)/jk(s*s+c*c),u=l*c,h=-l*s,f=t+u,d=e+h,p=n+u,g=r+h,y=(f+p)/2,m=(d+g)/2,b=p-f,v=g-d,_=b*b+v*v,x=i-a,k=f*g-p*d,w=(v<0?-1:1)*jk(Fk(0,x*x*_-k*k)),T=(k*v-b*w)/_,E=(-k*b-v*w)/_,C=(k*v+b*w)/_,S=(-k*b+v*w)/_,A=T-y,M=E-m,N=C-y,O=S-m;return A*A+M*M>N*N+O*O&&(T=C,E=S),{cx:T,cy:E,x01:-u,y01:-h,x11:T*(i/x-1),y11:E*(i/x-1)}}function Jk(){var t=Hk,e=Vk,n=Dk(0),r=null,i=Gk,a=Xk,o=Zk,s=null;function c(){var c,l,u=+t.apply(this,arguments),h=+e.apply(this,arguments),f=i.apply(this,arguments)-Uk,d=a.apply(this,arguments)-Uk,p=Bk(d-f),g=d>f;if(s||(s=c=Ja()),h<u&&(l=h,h=u,u=l),h>zk)if(p>$k-zk)s.moveTo(h*Ik(f),h*Pk(f)),s.arc(0,0,h,f,d,!g),u>zk&&(s.moveTo(u*Ik(d),u*Pk(d)),s.arc(0,0,u,d,f,g));else {var y,m,b=f,v=d,_=f,x=d,k=p,w=p,T=o.apply(this,arguments)/2,E=T>zk&&(r?+r.apply(this,arguments):jk(u*u+h*h)),C=Rk(Bk(h-u)/2,+n.apply(this,arguments)),S=C,A=C;if(E>zk){var M=qk(E/u*Pk(T)),N=qk(E/h*Pk(T));(k-=2*M)>zk?(_+=M*=g?1:-1,x-=M):(k=0,_=x=(f+d)/2),(w-=2*N)>zk?(b+=N*=g?1:-1,v-=N):(w=0,b=v=(f+d)/2);}var O=h*Ik(b),D=h*Pk(b),B=u*Ik(x),L=u*Pk(x);if(C>zk){var I,F=h*Ik(v),R=h*Pk(v),P=u*Ik(_),j=u*Pk(_);if(p<Yk&&(I=Qk(O,D,P,j,F,R,B,L))){var z=O-I[0],Y=D-I[1],U=F-I[0],$=R-I[1],W=1/Pk(Wk((z*U+Y*$)/(jk(z*z+Y*Y)*jk(U*U+$*$)))/2),q=jk(I[0]*I[0]+I[1]*I[1]);S=Rk(C,(u-q)/(W-1)),A=Rk(C,(h-q)/(W+1));}}w>zk?A>zk?(y=Kk(P,j,O,D,h,A,g),m=Kk(F,R,B,L,h,A,g),s.moveTo(y.cx+y.x01,y.cy+y.y01),A<C?s.arc(y.cx,y.cy,A,Lk(y.y01,y.x01),Lk(m.y01,m.x01),!g):(s.arc(y.cx,y.cy,A,Lk(y.y01,y.x01),Lk(y.y11,y.x11),!g),s.arc(0,0,h,Lk(y.cy+y.y11,y.cx+y.x11),Lk(m.cy+m.y11,m.cx+m.x11),!g),s.arc(m.cx,m.cy,A,Lk(m.y11,m.x11),Lk(m.y01,m.x01),!g))):(s.moveTo(O,D),s.arc(0,0,h,b,v,!g)):s.moveTo(O,D),u>zk&&k>zk?S>zk?(y=Kk(B,L,F,R,u,-S,g),m=Kk(O,D,P,j,u,-S,g),s.lineTo(y.cx+y.x01,y.cy+y.y01),S<C?s.arc(y.cx,y.cy,S,Lk(y.y01,y.x01),Lk(m.y01,m.x01),!g):(s.arc(y.cx,y.cy,S,Lk(y.y01,y.x01),Lk(y.y11,y.x11),!g),s.arc(0,0,u,Lk(y.cy+y.y11,y.cx+y.x11),Lk(m.cy+m.y11,m.cx+m.x11),g),s.arc(m.cx,m.cy,S,Lk(m.y11,m.x11),Lk(m.y01,m.x01),!g))):s.arc(0,0,u,x,_,g):s.lineTo(B,L);}else s.moveTo(0,0);if(s.closePath(),c)return s=null,c+""||null}return c.centroid=function(){var n=(+t.apply(this,arguments)+ +e.apply(this,arguments))/2,r=(+i.apply(this,arguments)+ +a.apply(this,arguments))/2-Yk/2;return [Ik(r)*n,Pk(r)*n]},c.innerRadius=function(e){return arguments.length?(t="function"==typeof e?e:Dk(+e),c):t},c.outerRadius=function(t){return arguments.length?(e="function"==typeof t?t:Dk(+t),c):e},c.cornerRadius=function(t){return arguments.length?(n="function"==typeof t?t:Dk(+t),c):n},c.padRadius=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:Dk(+t),c):r},c.startAngle=function(t){return arguments.length?(i="function"==typeof t?t:Dk(+t),c):i},c.endAngle=function(t){return arguments.length?(a="function"==typeof t?t:Dk(+t),c):a},c.padAngle=function(t){return arguments.length?(o="function"==typeof t?t:Dk(+t),c):o},c.context=function(t){return arguments.length?(s=null==t?null:t,c):s},c}var tw=Array.prototype.slice;function ew(t){return "object"==typeof t&&"length"in t?t:Array.from(t)}function nw(t){this._context=t;}function rw(t){return new nw(t)}function iw(t){return t[0]}function aw(t){return t[1]}function ow(t,e){var n=Dk(!0),r=null,i=rw,a=null;function o(o){var s,c,l,u=(o=ew(o)).length,h=!1;for(null==r&&(a=i(l=Ja())),s=0;s<=u;++s)!(s<u&&n(c=o[s],s,o))===h&&((h=!h)?a.lineStart():a.lineEnd()),h&&a.point(+t(c,s,o),+e(c,s,o));if(l)return a=null,l+""||null}return t="function"==typeof t?t:void 0===t?iw:Dk(t),e="function"==typeof e?e:void 0===e?aw:Dk(e),o.x=function(e){return arguments.length?(t="function"==typeof e?e:Dk(+e),o):t},o.y=function(t){return arguments.length?(e="function"==typeof t?t:Dk(+t),o):e},o.defined=function(t){return arguments.length?(n="function"==typeof t?t:Dk(!!t),o):n},o.curve=function(t){return arguments.length?(i=t,null!=r&&(a=i(r)),o):i},o.context=function(t){return arguments.length?(null==t?r=a=null:a=i(r=t),o):r},o}function sw(t,e,n){var r=null,i=Dk(!0),a=null,o=rw,s=null;function c(c){var l,u,h,f,d,p=(c=ew(c)).length,g=!1,y=new Array(p),m=new Array(p);for(null==a&&(s=o(d=Ja())),l=0;l<=p;++l){if(!(l<p&&i(f=c[l],l,c))===g)if(g=!g)u=l,s.areaStart(),s.lineStart();else {for(s.lineEnd(),s.lineStart(),h=l-1;h>=u;--h)s.point(y[h],m[h]);s.lineEnd(),s.areaEnd();}g&&(y[l]=+t(f,l,c),m[l]=+e(f,l,c),s.point(r?+r(f,l,c):y[l],n?+n(f,l,c):m[l]));}if(d)return s=null,d+""||null}function l(){return ow().defined(i).curve(o).context(a)}return t="function"==typeof t?t:void 0===t?iw:Dk(+t),e="function"==typeof e?e:Dk(void 0===e?0:+e),n="function"==typeof n?n:void 0===n?aw:Dk(+n),c.x=function(e){return arguments.length?(t="function"==typeof e?e:Dk(+e),r=null,c):t},c.x0=function(e){return arguments.length?(t="function"==typeof e?e:Dk(+e),c):t},c.x1=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:Dk(+t),c):r},c.y=function(t){return arguments.length?(e="function"==typeof t?t:Dk(+t),n=null,c):e},c.y0=function(t){return arguments.length?(e="function"==typeof t?t:Dk(+t),c):e},c.y1=function(t){return arguments.length?(n=null==t?null:"function"==typeof t?t:Dk(+t),c):n},c.lineX0=c.lineY0=function(){return l().x(t).y(e)},c.lineY1=function(){return l().x(t).y(n)},c.lineX1=function(){return l().x(r).y(e)},c.defined=function(t){return arguments.length?(i="function"==typeof t?t:Dk(!!t),c):i},c.curve=function(t){return arguments.length?(o=t,null!=a&&(s=o(a)),c):o},c.context=function(t){return arguments.length?(null==t?a=s=null:s=o(a=t),c):a},c}function cw(t,e){return e<t?-1:e>t?1:e>=t?0:NaN}function lw(t){return t}function uw(){var t=lw,e=cw,n=null,r=Dk(0),i=Dk($k),a=Dk(0);function o(o){var s,c,l,u,h,f=(o=ew(o)).length,d=0,p=new Array(f),g=new Array(f),y=+r.apply(this,arguments),m=Math.min($k,Math.max(-$k,i.apply(this,arguments)-y)),b=Math.min(Math.abs(m)/f,a.apply(this,arguments)),v=b*(m<0?-1:1);for(s=0;s<f;++s)(h=g[p[s]=s]=+t(o[s],s,o))>0&&(d+=h);for(null!=e?p.sort((function(t,n){return e(g[t],g[n])})):null!=n&&p.sort((function(t,e){return n(o[t],o[e])})),s=0,l=d?(m-f*v)/d:0;s<f;++s,y=u)c=p[s],u=y+((h=g[c])>0?h*l:0)+v,g[c]={data:o[c],index:s,value:h,startAngle:y,endAngle:u,padAngle:b};return g}return o.value=function(e){return arguments.length?(t="function"==typeof e?e:Dk(+e),o):t},o.sortValues=function(t){return arguments.length?(e=t,n=null,o):e},o.sort=function(t){return arguments.length?(n=t,e=null,o):n},o.startAngle=function(t){return arguments.length?(r="function"==typeof t?t:Dk(+t),o):r},o.endAngle=function(t){return arguments.length?(i="function"==typeof t?t:Dk(+t),o):i},o.padAngle=function(t){return arguments.length?(a="function"==typeof t?t:Dk(+t),o):a},o}nw.prototype={areaStart:function(){this._line=0;},areaEnd:function(){this._line=NaN;},lineStart:function(){this._point=0;},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line;},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e);}}};var hw=dw(rw);function fw(t){this._curve=t;}function dw(t){function e(e){return new fw(t(e))}return e._curve=t,e}function pw(t){var e=t.curve;return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t.curve=function(t){return arguments.length?e(dw(t)):e()._curve},t}function gw(){return pw(ow().curve(hw))}function yw(){var t=sw().curve(hw),e=t.curve,n=t.lineX0,r=t.lineX1,i=t.lineY0,a=t.lineY1;return t.angle=t.x,delete t.x,t.startAngle=t.x0,delete t.x0,t.endAngle=t.x1,delete t.x1,t.radius=t.y,delete t.y,t.innerRadius=t.y0,delete t.y0,t.outerRadius=t.y1,delete t.y1,t.lineStartAngle=function(){return pw(n())},delete t.lineX0,t.lineEndAngle=function(){return pw(r())},delete t.lineX1,t.lineInnerRadius=function(){return pw(i())},delete t.lineY0,t.lineOuterRadius=function(){return pw(a())},delete t.lineY1,t.curve=function(t){return arguments.length?e(dw(t)):e()._curve},t}function mw(t,e){return [(e=+e)*Math.cos(t-=Math.PI/2),e*Math.sin(t)]}function bw(t){return t.source}function vw(t){return t.target}function _w(t){var e=bw,n=vw,r=iw,i=aw,a=null;function o(){var o,s=tw.call(arguments),c=e.apply(this,s),l=n.apply(this,s);if(a||(a=o=Ja()),t(a,+r.apply(this,(s[0]=c,s)),+i.apply(this,s),+r.apply(this,(s[0]=l,s)),+i.apply(this,s)),o)return a=null,o+""||null}return o.source=function(t){return arguments.length?(e=t,o):e},o.target=function(t){return arguments.length?(n=t,o):n},o.x=function(t){return arguments.length?(r="function"==typeof t?t:Dk(+t),o):r},o.y=function(t){return arguments.length?(i="function"==typeof t?t:Dk(+t),o):i},o.context=function(t){return arguments.length?(a=null==t?null:t,o):a},o}function xw(t,e,n,r,i){t.moveTo(e,n),t.bezierCurveTo(e=(e+r)/2,n,e,i,r,i);}function kw(t,e,n,r,i){t.moveTo(e,n),t.bezierCurveTo(e,n=(n+i)/2,r,n,r,i);}function ww(t,e,n,r,i){var a=mw(e,n),o=mw(e,n=(n+i)/2),s=mw(r,n),c=mw(r,i);t.moveTo(a[0],a[1]),t.bezierCurveTo(o[0],o[1],s[0],s[1],c[0],c[1]);}function Tw(){return _w(xw)}function Ew(){return _w(kw)}function Cw(){var t=_w(ww);return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t}fw.prototype={areaStart:function(){this._curve.areaStart();},areaEnd:function(){this._curve.areaEnd();},lineStart:function(){this._curve.lineStart();},lineEnd:function(){this._curve.lineEnd();},point:function(t,e){this._curve.point(e*Math.sin(t),e*-Math.cos(t));}};const Sw={draw:function(t,e){var n=Math.sqrt(e/Yk);t.moveTo(n,0),t.arc(0,0,n,0,$k);}},Aw={draw:function(t,e){var n=Math.sqrt(e/5)/2;t.moveTo(-3*n,-n),t.lineTo(-n,-n),t.lineTo(-n,-3*n),t.lineTo(n,-3*n),t.lineTo(n,-n),t.lineTo(3*n,-n),t.lineTo(3*n,n),t.lineTo(n,n),t.lineTo(n,3*n),t.lineTo(-n,3*n),t.lineTo(-n,n),t.lineTo(-3*n,n),t.closePath();}};var Mw=Math.sqrt(1/3),Nw=2*Mw;const Ow={draw:function(t,e){var n=Math.sqrt(e/Nw),r=n*Mw;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath();}};var Dw=Math.sin(Yk/10)/Math.sin(7*Yk/10),Bw=Math.sin($k/10)*Dw,Lw=-Math.cos($k/10)*Dw;const Iw={draw:function(t,e){var n=Math.sqrt(.8908130915292852*e),r=Bw*n,i=Lw*n;t.moveTo(0,-n),t.lineTo(r,i);for(var a=1;a<5;++a){var o=$k*a/5,s=Math.cos(o),c=Math.sin(o);t.lineTo(c*n,-s*n),t.lineTo(s*r-c*i,c*r+s*i);}t.closePath();}},Fw={draw:function(t,e){var n=Math.sqrt(e),r=-n/2;t.rect(r,r,n,n);}};var Rw=Math.sqrt(3);const Pw={draw:function(t,e){var n=-Math.sqrt(e/(3*Rw));t.moveTo(0,2*n),t.lineTo(-Rw*n,-n),t.lineTo(Rw*n,-n),t.closePath();}};var jw=-.5,zw=Math.sqrt(3)/2,Yw=1/Math.sqrt(12),Uw=3*(Yw/2+1);const $w={draw:function(t,e){var n=Math.sqrt(e/Uw),r=n/2,i=n*Yw,a=r,o=n*Yw+n,s=-a,c=o;t.moveTo(r,i),t.lineTo(a,o),t.lineTo(s,c),t.lineTo(jw*r-zw*i,zw*r+jw*i),t.lineTo(jw*a-zw*o,zw*a+jw*o),t.lineTo(jw*s-zw*c,zw*s+jw*c),t.lineTo(jw*r+zw*i,jw*i-zw*r),t.lineTo(jw*a+zw*o,jw*o-zw*a),t.lineTo(jw*s+zw*c,jw*c-zw*s),t.closePath();}};var Ww=[Sw,Aw,Ow,Fw,Iw,Pw,$w];function qw(t,e){var n=null;function r(){var r;if(n||(n=r=Ja()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),r)return n=null,r+""||null}return t="function"==typeof t?t:Dk(t||Sw),e="function"==typeof e?e:Dk(void 0===e?64:+e),r.type=function(e){return arguments.length?(t="function"==typeof e?e:Dk(e),r):t},r.size=function(t){return arguments.length?(e="function"==typeof t?t:Dk(+t),r):e},r.context=function(t){return arguments.length?(n=null==t?null:t,r):n},r}function Hw(){}function Vw(t,e,n){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+e)/6,(t._y0+4*t._y1+n)/6);}function Gw(t){this._context=t;}function Xw(t){return new Gw(t)}function Zw(t){this._context=t;}function Qw(t){return new Zw(t)}function Kw(t){this._context=t;}function Jw(t){return new Kw(t)}Gw.prototype={areaStart:function(){this._line=0;},areaEnd:function(){this._line=NaN;},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0;},lineEnd:function(){switch(this._point){case 3:Vw(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line;},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Vw(this,t,e);}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e;}},Zw.prototype={areaStart:Hw,areaEnd:Hw,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0;},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x2=t,this._y2=e;break;case 1:this._point=2,this._x3=t,this._y3=e;break;case 2:this._point=3,this._x4=t,this._y4=e,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+e)/6);break;default:Vw(this,t,e);}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e;}},Kw.prototype={areaStart:function(){this._line=0;},areaEnd:function(){this._line=NaN;},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0;},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line;},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+t)/6,r=(this._y0+4*this._y1+e)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:Vw(this,t,e);}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e;}};class tT{constructor(t,e){this._context=t,this._x=e;}areaStart(){this._line=0;}areaEnd(){this._line=NaN;}lineStart(){this._point=0;}lineEnd(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line;}point(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,e,t,e):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+e)/2,t,this._y0,t,e);}this._x0=t,this._y0=e;}}function eT(t){return new tT(t,!0)}function nT(t){return new tT(t,!1)}function rT(t,e){this._basis=new Gw(t),this._beta=e;}rT.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart();},lineEnd:function(){var t=this._x,e=this._y,n=t.length-1;if(n>0)for(var r,i=t[0],a=e[0],o=t[n]-i,s=e[n]-a,c=-1;++c<=n;)r=c/n,this._basis.point(this._beta*t[c]+(1-this._beta)*(i+r*o),this._beta*e[c]+(1-this._beta)*(a+r*s));this._x=this._y=null,this._basis.lineEnd();},point:function(t,e){this._x.push(+t),this._y.push(+e);}};const iT=function t(e){function n(t){return 1===e?new Gw(t):new rT(t,e)}return n.beta=function(e){return t(+e)},n}(.85);function aT(t,e,n){t._context.bezierCurveTo(t._x1+t._k*(t._x2-t._x0),t._y1+t._k*(t._y2-t._y0),t._x2+t._k*(t._x1-e),t._y2+t._k*(t._y1-n),t._x2,t._y2);}function oT(t,e){this._context=t,this._k=(1-e)/6;}oT.prototype={areaStart:function(){this._line=0;},areaEnd:function(){this._line=NaN;},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0;},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:aT(this,this._x1,this._y1);}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line;},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2,this._x1=t,this._y1=e;break;case 2:this._point=3;default:aT(this,t,e);}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e;}};const sT=function t(e){function n(t){return new oT(t,e)}return n.tension=function(e){return t(+e)},n}(0);function cT(t,e){this._context=t,this._k=(1-e)/6;}cT.prototype={areaStart:Hw,areaEnd:Hw,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0;},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5);}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x3=t,this._y3=e;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=e);break;case 2:this._point=3,this._x5=t,this._y5=e;break;default:aT(this,t,e);}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e;}};const lT=function t(e){function n(t){return new cT(t,e)}return n.tension=function(e){return t(+e)},n}(0);function uT(t,e){this._context=t,this._k=(1-e)/6;}uT.prototype={areaStart:function(){this._line=0;},areaEnd:function(){this._line=NaN;},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0;},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line;},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:aT(this,t,e);}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e;}};const hT=function t(e){function n(t){return new uT(t,e)}return n.tension=function(e){return t(+e)},n}(0);function fT(t,e,n){var r=t._x1,i=t._y1,a=t._x2,o=t._y2;if(t._l01_a>zk){var s=2*t._l01_2a+3*t._l01_a*t._l12_a+t._l12_2a,c=3*t._l01_a*(t._l01_a+t._l12_a);r=(r*s-t._x0*t._l12_2a+t._x2*t._l01_2a)/c,i=(i*s-t._y0*t._l12_2a+t._y2*t._l01_2a)/c;}if(t._l23_a>zk){var l=2*t._l23_2a+3*t._l23_a*t._l12_a+t._l12_2a,u=3*t._l23_a*(t._l23_a+t._l12_a);a=(a*l+t._x1*t._l23_2a-e*t._l12_2a)/u,o=(o*l+t._y1*t._l23_2a-n*t._l12_2a)/u;}t._context.bezierCurveTo(r,i,a,o,t._x2,t._y2);}function dT(t,e){this._context=t,this._alpha=e;}dT.prototype={areaStart:function(){this._line=0;},areaEnd:function(){this._line=NaN;},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0;},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line;},point:function(t,e){if(t=+t,e=+e,this._point){var n=this._x2-t,r=this._y2-e;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha));}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3;default:fT(this,t,e);}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e;}};const pT=function t(e){function n(t){return e?new dT(t,e):new oT(t,0)}return n.alpha=function(e){return t(+e)},n}(.5);function gT(t,e){this._context=t,this._alpha=e;}gT.prototype={areaStart:Hw,areaEnd:Hw,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0;},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5);}},point:function(t,e){if(t=+t,e=+e,this._point){var n=this._x2-t,r=this._y2-e;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha));}switch(this._point){case 0:this._point=1,this._x3=t,this._y3=e;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=e);break;case 2:this._point=3,this._x5=t,this._y5=e;break;default:fT(this,t,e);}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e;}};const yT=function t(e){function n(t){return e?new gT(t,e):new cT(t,0)}return n.alpha=function(e){return t(+e)},n}(.5);function mT(t,e){this._context=t,this._alpha=e;}mT.prototype={areaStart:function(){this._line=0;},areaEnd:function(){this._line=NaN;},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0;},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line;},point:function(t,e){if(t=+t,e=+e,this._point){var n=this._x2-t,r=this._y2-e;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha));}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:fT(this,t,e);}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e;}};const bT=function t(e){function n(t){return e?new mT(t,e):new uT(t,0)}return n.alpha=function(e){return t(+e)},n}(.5);function vT(t){this._context=t;}function _T(t){return new vT(t)}function xT(t){return t<0?-1:1}function kT(t,e,n){var r=t._x1-t._x0,i=e-t._x1,a=(t._y1-t._y0)/(r||i<0&&-0),o=(n-t._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return (xT(a)+xT(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function wT(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function TT(t,e,n){var r=t._x0,i=t._y0,a=t._x1,o=t._y1,s=(a-r)/3;t._context.bezierCurveTo(r+s,i+s*e,a-s,o-s*n,a,o);}function ET(t){this._context=t;}function CT(t){this._context=new ST(t);}function ST(t){this._context=t;}function AT(t){return new ET(t)}function MT(t){return new CT(t)}function NT(t){this._context=t;}function OT(t){var e,n,r=t.length-1,i=new Array(r),a=new Array(r),o=new Array(r);for(i[0]=0,a[0]=2,o[0]=t[0]+2*t[1],e=1;e<r-1;++e)i[e]=1,a[e]=4,o[e]=4*t[e]+2*t[e+1];for(i[r-1]=2,a[r-1]=7,o[r-1]=8*t[r-1]+t[r],e=1;e<r;++e)n=i[e]/a[e-1],a[e]-=n,o[e]-=n*o[e-1];for(i[r-1]=o[r-1]/a[r-1],e=r-2;e>=0;--e)i[e]=(o[e]-i[e+1])/a[e];for(a[r-1]=(t[r]+i[r-1])/2,e=0;e<r-1;++e)a[e]=2*t[e+1]-i[e+1];return [i,a]}function DT(t){return new NT(t)}function BT(t,e){this._context=t,this._t=e;}function LT(t){return new BT(t,.5)}function IT(t){return new BT(t,0)}function FT(t){return new BT(t,1)}function RT(t,e){if((i=t.length)>1)for(var n,r,i,a=1,o=t[e[0]],s=o.length;a<i;++a)for(r=o,o=t[e[a]],n=0;n<s;++n)o[n][1]+=o[n][0]=isNaN(r[n][1])?r[n][0]:r[n][1];}function PT(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function jT(t,e){return t[e]}function zT(t){const e=[];return e.key=t,e}function YT(){var t=Dk([]),e=PT,n=RT,r=jT;function i(i){var a,o,s=Array.from(t.apply(this,arguments),zT),c=s.length,l=-1;for(const t of i)for(a=0,++l;a<c;++a)(s[a][l]=[0,+r(t,s[a].key,l,i)]).data=t;for(a=0,o=ew(e(s));a<c;++a)s[o[a]].index=a;return n(s,o),s}return i.keys=function(e){return arguments.length?(t="function"==typeof e?e:Dk(Array.from(e)),i):t},i.value=function(t){return arguments.length?(r="function"==typeof t?t:Dk(+t),i):r},i.order=function(t){return arguments.length?(e=null==t?PT:"function"==typeof t?t:Dk(Array.from(t)),i):e},i.offset=function(t){return arguments.length?(n=null==t?RT:t,i):n},i}function UT(t,e){if((r=t.length)>0){for(var n,r,i,a=0,o=t[0].length;a<o;++a){for(i=n=0;n<r;++n)i+=t[n][a][1]||0;if(i)for(n=0;n<r;++n)t[n][a][1]/=i;}RT(t,e);}}function $T(t,e){if((s=t.length)>0)for(var n,r,i,a,o,s,c=0,l=t[e[0]].length;c<l;++c)for(a=o=0,n=0;n<s;++n)(i=(r=t[e[n]][c])[1]-r[0])>0?(r[0]=a,r[1]=a+=i):i<0?(r[1]=o,r[0]=o+=i):(r[0]=0,r[1]=i);}function WT(t,e){if((n=t.length)>0){for(var n,r=0,i=t[e[0]],a=i.length;r<a;++r){for(var o=0,s=0;o<n;++o)s+=t[o][r][1]||0;i[r][1]+=i[r][0]=-s/2;}RT(t,e);}}function qT(t,e){if((i=t.length)>0&&(r=(n=t[e[0]]).length)>0){for(var n,r,i,a=0,o=1;o<r;++o){for(var s=0,c=0,l=0;s<i;++s){for(var u=t[e[s]],h=u[o][1]||0,f=(h-(u[o-1][1]||0))/2,d=0;d<s;++d){var p=t[e[d]];f+=(p[o][1]||0)-(p[o-1][1]||0);}c+=h,l+=f*h;}n[o-1][1]+=n[o-1][0]=a,c&&(a-=l/c);}n[o-1][1]+=n[o-1][0]=a,RT(t,e);}}function HT(t){var e=t.map(VT);return PT(t).sort((function(t,n){return e[t]-e[n]}))}function VT(t){for(var e,n=-1,r=0,i=t.length,a=-1/0;++n<i;)(e=+t[n][1])>a&&(a=e,r=n);return r}function GT(t){var e=t.map(XT);return PT(t).sort((function(t,n){return e[t]-e[n]}))}function XT(t){for(var e,n=0,r=-1,i=t.length;++r<i;)(e=+t[r][1])&&(n+=e);return n}function ZT(t){return GT(t).reverse()}function QT(t){var e,n,r=t.length,i=t.map(XT),a=HT(t),o=0,s=0,c=[],l=[];for(e=0;e<r;++e)n=a[e],o<s?(o+=i[n],c.push(n)):(s+=i[n],l.push(n));return l.reverse().concat(c)}function KT(t){return PT(t).reverse()}vT.prototype={areaStart:Hw,areaEnd:Hw,lineStart:function(){this._point=0;},lineEnd:function(){this._point&&this._context.closePath();},point:function(t,e){t=+t,e=+e,this._point?this._context.lineTo(t,e):(this._point=1,this._context.moveTo(t,e));}},ET.prototype={areaStart:function(){this._line=0;},areaEnd:function(){this._line=NaN;},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0;},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:TT(this,this._t0,wT(this,this._t0));}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line;},point:function(t,e){var n=NaN;if(e=+e,(t=+t)!==this._x1||e!==this._y1){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,TT(this,wT(this,n=kT(this,t,e)),n);break;default:TT(this,this._t0,n=kT(this,t,e));}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n;}}},(CT.prototype=Object.create(ET.prototype)).point=function(t,e){ET.prototype.point.call(this,e,t);},ST.prototype={moveTo:function(t,e){this._context.moveTo(e,t);},closePath:function(){this._context.closePath();},lineTo:function(t,e){this._context.lineTo(e,t);},bezierCurveTo:function(t,e,n,r,i,a){this._context.bezierCurveTo(e,t,r,n,a,i);}},NT.prototype={areaStart:function(){this._line=0;},areaEnd:function(){this._line=NaN;},lineStart:function(){this._x=[],this._y=[];},lineEnd:function(){var t=this._x,e=this._y,n=t.length;if(n)if(this._line?this._context.lineTo(t[0],e[0]):this._context.moveTo(t[0],e[0]),2===n)this._context.lineTo(t[1],e[1]);else for(var r=OT(t),i=OT(e),a=0,o=1;o<n;++a,++o)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],t[o],e[o]);(this._line||0!==this._line&&1===n)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null;},point:function(t,e){this._x.push(+t),this._y.push(+e);}},BT.prototype={areaStart:function(){this._line=0;},areaEnd:function(){this._line=NaN;},lineStart:function(){this._x=this._y=NaN,this._point=0;},lineEnd:function(){0<this._t&&this._t<1&&2===this._point&&this._context.lineTo(this._x,this._y),(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line);},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else {var n=this._x*(1-this._t)+t*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,e);}}this._x=t,this._y=e;}};var JT="%Y-%m-%dT%H:%M:%S.%LZ",tE=Date.prototype.toISOString?function(t){return t.toISOString()}:dv(JT);const eE=tE;var nE=+new Date("2000-01-01T00:00:00.000Z")?function(t){var e=new Date(t);return isNaN(e)?null:e}:pv(JT);const rE=nE;function iE(t,e,n){var r=new Zr,i=e;return null==e?(r.restart(t,e,n),r):(r._restart=r.restart,r.restart=function(t,e,n){e=+e,n=null==n?Gr():+n,r._restart((function a(o){o+=i,r._restart(a,i+=e,n),t(o);}),e,n);},r.restart(t,e,n),r)}const aE=t=>()=>t;function oE(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}});}function sE(t,e,n){this.k=t,this.x=e,this.y=n;}sE.prototype={constructor:sE,scale:function(t){return 1===t?this:new sE(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new sE(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return [t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return [(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return (t-this.x)/this.k},invertY:function(t){return (t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return "translate("+this.x+","+this.y+") scale("+this.k+")"}};var cE=new sE(1,0,0);function lE(t){for(;!t.__zoom;)if(!(t=t.parentNode))return cE;return t.__zoom}function uE(t){t.stopImmediatePropagation();}function hE(t){t.preventDefault(),t.stopImmediatePropagation();}function fE(t){return !(t.ctrlKey&&"wheel"!==t.type||t.button)}function dE(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function pE(){return this.__zoom||cE}function gE(t){return -t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function yE(){return navigator.maxTouchPoints||"ontouchstart"in this}function mE(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],a=t.invertY(e[0][1])-n[0][1],o=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function bE(){var t,e,n,r=fE,i=dE,a=mE,o=gE,s=yE,c=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],u=250,h=ny,f=fe("start","zoom","end"),d=500,p=0,g=10;function y(t){t.property("__zoom",pE).on("wheel.zoom",w,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",E).filter(s).on("touchstart.zoom",C).on("touchmove.zoom",S).on("touchend.zoom touchcancel.zoom",A).style("-webkit-tap-highlight-color","rgba(0,0,0,0)");}function m(t,e){return (e=Math.max(c[0],Math.min(c[1],e)))===t.k?t:new sE(e,t.x,t.y)}function b(t,e,n){var r=e[0]-n[0]*t.k,i=e[1]-n[1]*t.k;return r===t.x&&i===t.y?t:new sE(t.k,r,i)}function v(t){return [(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function _(t,e,n,r){t.on("start.zoom",(function(){x(this,arguments).event(r).start();})).on("interrupt.zoom end.zoom",(function(){x(this,arguments).event(r).end();})).tween("zoom",(function(){var t=this,a=arguments,o=x(t,a).event(r),s=i.apply(t,a),c=null==n?v(s):"function"==typeof n?n.apply(t,a):n,l=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),u=t.__zoom,f="function"==typeof e?e.apply(t,a):e,d=h(u.invert(c).concat(l/u.k),f.invert(c).concat(l/f.k));return function(t){if(1===t)t=f;else {var e=d(t),n=l/e[2];t=new sE(n,c[0]-e[0]*n,c[1]-e[1]*n);}o.zoom(null,t);}}));}function x(t,e,n){return !n&&t.__zooming||new k(t,e)}function k(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=i.apply(t,e),this.taps=0;}function w(t,...e){if(r.apply(this,arguments)){var n=x(this,e).event(t),i=this.__zoom,s=Math.max(c[0],Math.min(c[1],i.k*Math.pow(2,o.apply(this,arguments)))),u=Rr(t);if(n.wheel)n.mouse[0][0]===u[0]&&n.mouse[0][1]===u[1]||(n.mouse[1]=i.invert(n.mouse[0]=u)),clearTimeout(n.wheel);else {if(i.k===s)return;n.mouse=[u,i.invert(u)],li(this),n.start();}hE(t),n.wheel=setTimeout(h,150),n.zoom("mouse",a(b(m(i,s),n.mouse[0],n.mouse[1]),n.extent,l));}function h(){n.wheel=null,n.end();}}function T(t,...e){if(!n&&r.apply(this,arguments)){var i=t.currentTarget,o=x(this,e,!0).event(t),s=Mn(t.view).on("mousemove.zoom",f,!0).on("mouseup.zoom",d,!0),c=Rr(t,i),u=t.clientX,h=t.clientY;Ln(t.view),uE(t),o.mouse=[c,this.__zoom.invert(c)],li(this),o.start();}function f(t){if(hE(t),!o.moved){var e=t.clientX-u,n=t.clientY-h;o.moved=e*e+n*n>p;}o.event(t).zoom("mouse",a(b(o.that.__zoom,o.mouse[0]=Rr(t,i),o.mouse[1]),o.extent,l));}function d(t){s.on("mousemove.zoom mouseup.zoom",null),In(t.view,o.moved),hE(t),o.event(t).end();}}function E(t,...e){if(r.apply(this,arguments)){var n=this.__zoom,o=Rr(t.changedTouches?t.changedTouches[0]:t,this),s=n.invert(o),c=n.k*(t.shiftKey?.5:2),h=a(b(m(n,c),o,s),i.apply(this,e),l);hE(t),u>0?Mn(this).transition().duration(u).call(_,h,o,t):Mn(this).call(y.transform,h,o,t);}}function C(n,...i){if(r.apply(this,arguments)){var a,o,s,c,l=n.touches,u=l.length,h=x(this,i,n.changedTouches.length===u).event(n);for(uE(n),o=0;o<u;++o)c=[c=Rr(s=l[o],this),this.__zoom.invert(c),s.identifier],h.touch0?h.touch1||h.touch0[2]===c[2]||(h.touch1=c,h.taps=0):(h.touch0=c,a=!0,h.taps=1+!!t);t&&(t=clearTimeout(t)),a&&(h.taps<2&&(e=c[0],t=setTimeout((function(){t=null;}),d)),li(this),h.start());}}function S(t,...e){if(this.__zooming){var n,r,i,o,s=x(this,e).event(t),c=t.changedTouches,u=c.length;for(hE(t),n=0;n<u;++n)i=Rr(r=c[n],this),s.touch0&&s.touch0[2]===r.identifier?s.touch0[0]=i:s.touch1&&s.touch1[2]===r.identifier&&(s.touch1[0]=i);if(r=s.that.__zoom,s.touch1){var h=s.touch0[0],f=s.touch0[1],d=s.touch1[0],p=s.touch1[1],g=(g=d[0]-h[0])*g+(g=d[1]-h[1])*g,y=(y=p[0]-f[0])*y+(y=p[1]-f[1])*y;r=m(r,Math.sqrt(g/y)),i=[(h[0]+d[0])/2,(h[1]+d[1])/2],o=[(f[0]+p[0])/2,(f[1]+p[1])/2];}else {if(!s.touch0)return;i=s.touch0[0],o=s.touch0[1];}s.zoom("touch",a(b(r,i,o),s.extent,l));}}function A(t,...r){if(this.__zooming){var i,a,o=x(this,r).event(t),s=t.changedTouches,c=s.length;for(uE(t),n&&clearTimeout(n),n=setTimeout((function(){n=null;}),d),i=0;i<c;++i)a=s[i],o.touch0&&o.touch0[2]===a.identifier?delete o.touch0:o.touch1&&o.touch1[2]===a.identifier&&delete o.touch1;if(o.touch1&&!o.touch0&&(o.touch0=o.touch1,delete o.touch1),o.touch0)o.touch0[1]=this.__zoom.invert(o.touch0[0]);else if(o.end(),2===o.taps&&(a=Rr(a,this),Math.hypot(e[0]-a[0],e[1]-a[1])<g)){var l=Mn(this).on("dblclick.zoom");l&&l.apply(this,arguments);}}}return y.transform=function(t,e,n,r){var i=t.selection?t.selection():t;i.property("__zoom",pE),t!==i?_(t,e,n,r):i.interrupt().each((function(){x(this,arguments).event(r).start().zoom(null,"function"==typeof e?e.apply(this,arguments):e).end();}));},y.scaleBy=function(t,e,n,r){y.scaleTo(t,(function(){var t=this.__zoom.k,n="function"==typeof e?e.apply(this,arguments):e;return t*n}),n,r);},y.scaleTo=function(t,e,n,r){y.transform(t,(function(){var t=i.apply(this,arguments),r=this.__zoom,o=null==n?v(t):"function"==typeof n?n.apply(this,arguments):n,s=r.invert(o),c="function"==typeof e?e.apply(this,arguments):e;return a(b(m(r,c),o,s),t,l)}),n,r);},y.translateBy=function(t,e,n,r){y.transform(t,(function(){return a(this.__zoom.translate("function"==typeof e?e.apply(this,arguments):e,"function"==typeof n?n.apply(this,arguments):n),i.apply(this,arguments),l)}),null,r);},y.translateTo=function(t,e,n,r,o){y.transform(t,(function(){var t=i.apply(this,arguments),o=this.__zoom,s=null==r?v(t):"function"==typeof r?r.apply(this,arguments):r;return a(cE.translate(s[0],s[1]).scale(o.k).translate("function"==typeof e?-e.apply(this,arguments):-e,"function"==typeof n?-n.apply(this,arguments):-n),t,l)}),r,o);},k.prototype={event:function(t){return t&&(this.sourceEvent=t),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(t,e){return this.mouse&&"mouse"!==t&&(this.mouse[1]=e.invert(this.mouse[0])),this.touch0&&"touch"!==t&&(this.touch0[1]=e.invert(this.touch0[0])),this.touch1&&"touch"!==t&&(this.touch1[1]=e.invert(this.touch1[0])),this.that.__zoom=e,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(t){var e=Mn(this.that).datum();f.call(t,this.that,new oE(t,{sourceEvent:this.sourceEvent,target:y,type:t,transform:this.that.__zoom,dispatch:f}),e);}},y.wheelDelta=function(t){return arguments.length?(o="function"==typeof t?t:aE(+t),y):o},y.filter=function(t){return arguments.length?(r="function"==typeof t?t:aE(!!t),y):r},y.touchable=function(t){return arguments.length?(s="function"==typeof t?t:aE(!!t),y):s},y.extent=function(t){return arguments.length?(i="function"==typeof t?t:aE([[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]]),y):i},y.scaleExtent=function(t){return arguments.length?(c[0]=+t[0],c[1]=+t[1],y):[c[0],c[1]]},y.translateExtent=function(t){return arguments.length?(l[0][0]=+t[0][0],l[1][0]=+t[1][0],l[0][1]=+t[0][1],l[1][1]=+t[1][1],y):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},y.constrain=function(t){return arguments.length?(a=t,y):a},y.duration=function(t){return arguments.length?(u=+t,y):u},y.interpolate=function(t){return arguments.length?(h=t,y):h},y.on=function(){var t=f.on.apply(f,arguments);return t===f?y:t},y.clickDistance=function(t){return arguments.length?(p=(t=+t)*t,y):Math.sqrt(p)},y.tapDistance=function(t){return arguments.length?(g=+t,y):g},y}lE.prototype=sE.prototype;}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var a=e[r]={id:r,loaded:!1,exports:{}};return t[r].call(a.exports,a,a.exports,n),a.loaded=!0,a.exports}n.c=e,n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]});},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0});},n.nmd=t=>(t.paths=[],t.children||(t.children=[]),t);var r=n(n.s=6187).Z;
  84632. /**
  84633. * Copyright (C) 2021 THL A29 Limited, a Tencent company.
  84634. *
  84635. * Licensed under the Apache License, Version 2.0 (the "License");
  84636. * you may not use this file except in compliance with the License.
  84637. * You may obtain a copy of the License at
  84638. *
  84639. * http://www.apache.org/licenses/LICENSE-2.0
  84640. *
  84641. * Unless required by applicable law or agreed to in writing, software
  84642. * distributed under the License is distributed on an "AS IS" BASIS,
  84643. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  84644. * See the License for the specific language governing permissions and
  84645. * limitations under the License.
  84646. */
  84647. var mermaidAPI = r === null || r === void 0 ? void 0 : r.mermaidAPI;
  84648. Cherry.usePlugin(MermaidCodeEngine, {
  84649. mermaidAPI: mermaidAPI,
  84650. theme: 'default',
  84651. sequence: {
  84652. useMaxWidth: false
  84653. }
  84654. });
  84655. Cherry.usePlugin(PlantUMLCodeEngine, {});
  84656. exports.MenuHookBase = MenuBase;
  84657. exports.SyntaxHookBase = SyntaxBase;
  84658. exports.default = Cherry;
  84659. Object.defineProperty(exports, '__esModule', { value: true });
  84660. })));
  84661. //# sourceMappingURL=cherry-markdown.js.map