blocks.js 475 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466
  1. /******/ (function() { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ 9756:
  4. /***/ (function(module) {
  5. /**
  6. * Memize options object.
  7. *
  8. * @typedef MemizeOptions
  9. *
  10. * @property {number} [maxSize] Maximum size of the cache.
  11. */
  12. /**
  13. * Internal cache entry.
  14. *
  15. * @typedef MemizeCacheNode
  16. *
  17. * @property {?MemizeCacheNode|undefined} [prev] Previous node.
  18. * @property {?MemizeCacheNode|undefined} [next] Next node.
  19. * @property {Array<*>} args Function arguments for cache
  20. * entry.
  21. * @property {*} val Function result.
  22. */
  23. /**
  24. * Properties of the enhanced function for controlling cache.
  25. *
  26. * @typedef MemizeMemoizedFunction
  27. *
  28. * @property {()=>void} clear Clear the cache.
  29. */
  30. /**
  31. * Accepts a function to be memoized, and returns a new memoized function, with
  32. * optional options.
  33. *
  34. * @template {Function} F
  35. *
  36. * @param {F} fn Function to memoize.
  37. * @param {MemizeOptions} [options] Options object.
  38. *
  39. * @return {F & MemizeMemoizedFunction} Memoized function.
  40. */
  41. function memize( fn, options ) {
  42. var size = 0;
  43. /** @type {?MemizeCacheNode|undefined} */
  44. var head;
  45. /** @type {?MemizeCacheNode|undefined} */
  46. var tail;
  47. options = options || {};
  48. function memoized( /* ...args */ ) {
  49. var node = head,
  50. len = arguments.length,
  51. args, i;
  52. searchCache: while ( node ) {
  53. // Perform a shallow equality test to confirm that whether the node
  54. // under test is a candidate for the arguments passed. Two arrays
  55. // are shallowly equal if their length matches and each entry is
  56. // strictly equal between the two sets. Avoid abstracting to a
  57. // function which could incur an arguments leaking deoptimization.
  58. // Check whether node arguments match arguments length
  59. if ( node.args.length !== arguments.length ) {
  60. node = node.next;
  61. continue;
  62. }
  63. // Check whether node arguments match arguments values
  64. for ( i = 0; i < len; i++ ) {
  65. if ( node.args[ i ] !== arguments[ i ] ) {
  66. node = node.next;
  67. continue searchCache;
  68. }
  69. }
  70. // At this point we can assume we've found a match
  71. // Surface matched node to head if not already
  72. if ( node !== head ) {
  73. // As tail, shift to previous. Must only shift if not also
  74. // head, since if both head and tail, there is no previous.
  75. if ( node === tail ) {
  76. tail = node.prev;
  77. }
  78. // Adjust siblings to point to each other. If node was tail,
  79. // this also handles new tail's empty `next` assignment.
  80. /** @type {MemizeCacheNode} */ ( node.prev ).next = node.next;
  81. if ( node.next ) {
  82. node.next.prev = node.prev;
  83. }
  84. node.next = head;
  85. node.prev = null;
  86. /** @type {MemizeCacheNode} */ ( head ).prev = node;
  87. head = node;
  88. }
  89. // Return immediately
  90. return node.val;
  91. }
  92. // No cached value found. Continue to insertion phase:
  93. // Create a copy of arguments (avoid leaking deoptimization)
  94. args = new Array( len );
  95. for ( i = 0; i < len; i++ ) {
  96. args[ i ] = arguments[ i ];
  97. }
  98. node = {
  99. args: args,
  100. // Generate the result from original function
  101. val: fn.apply( null, args ),
  102. };
  103. // Don't need to check whether node is already head, since it would
  104. // have been returned above already if it was
  105. // Shift existing head down list
  106. if ( head ) {
  107. head.prev = node;
  108. node.next = head;
  109. } else {
  110. // If no head, follows that there's no tail (at initial or reset)
  111. tail = node;
  112. }
  113. // Trim tail if we're reached max size and are pending cache insertion
  114. if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) {
  115. tail = /** @type {MemizeCacheNode} */ ( tail ).prev;
  116. /** @type {MemizeCacheNode} */ ( tail ).next = null;
  117. } else {
  118. size++;
  119. }
  120. head = node;
  121. return node.val;
  122. }
  123. memoized.clear = function() {
  124. head = null;
  125. tail = null;
  126. size = 0;
  127. };
  128. if ( false ) {}
  129. // Ignore reason: There's not a clear solution to create an intersection of
  130. // the function with additional properties, where the goal is to retain the
  131. // function signature of the incoming argument and add control properties
  132. // on the return value.
  133. // @ts-ignore
  134. return memoized;
  135. }
  136. module.exports = memize;
  137. /***/ }),
  138. /***/ 7308:
  139. /***/ (function(module, exports, __webpack_require__) {
  140. var __WEBPACK_AMD_DEFINE_RESULT__;;/*! showdown v 1.9.1 - 02-11-2019 */
  141. (function(){
  142. /**
  143. * Created by Tivie on 13-07-2015.
  144. */
  145. function getDefaultOpts (simple) {
  146. 'use strict';
  147. var defaultOptions = {
  148. omitExtraWLInCodeBlocks: {
  149. defaultValue: false,
  150. describe: 'Omit the default extra whiteline added to code blocks',
  151. type: 'boolean'
  152. },
  153. noHeaderId: {
  154. defaultValue: false,
  155. describe: 'Turn on/off generated header id',
  156. type: 'boolean'
  157. },
  158. prefixHeaderId: {
  159. defaultValue: false,
  160. describe: 'Add a prefix to the generated header ids. Passing a string will prefix that string to the header id. Setting to true will add a generic \'section-\' prefix',
  161. type: 'string'
  162. },
  163. rawPrefixHeaderId: {
  164. defaultValue: false,
  165. describe: 'Setting this option to true will prevent showdown from modifying the prefix. This might result in malformed IDs (if, for instance, the " char is used in the prefix)',
  166. type: 'boolean'
  167. },
  168. ghCompatibleHeaderId: {
  169. defaultValue: false,
  170. describe: 'Generate header ids compatible with github style (spaces are replaced with dashes, a bunch of non alphanumeric chars are removed)',
  171. type: 'boolean'
  172. },
  173. rawHeaderId: {
  174. defaultValue: false,
  175. describe: 'Remove only spaces, \' and " from generated header ids (including prefixes), replacing them with dashes (-). WARNING: This might result in malformed ids',
  176. type: 'boolean'
  177. },
  178. headerLevelStart: {
  179. defaultValue: false,
  180. describe: 'The header blocks level start',
  181. type: 'integer'
  182. },
  183. parseImgDimensions: {
  184. defaultValue: false,
  185. describe: 'Turn on/off image dimension parsing',
  186. type: 'boolean'
  187. },
  188. simplifiedAutoLink: {
  189. defaultValue: false,
  190. describe: 'Turn on/off GFM autolink style',
  191. type: 'boolean'
  192. },
  193. excludeTrailingPunctuationFromURLs: {
  194. defaultValue: false,
  195. describe: 'Excludes trailing punctuation from links generated with autoLinking',
  196. type: 'boolean'
  197. },
  198. literalMidWordUnderscores: {
  199. defaultValue: false,
  200. describe: 'Parse midword underscores as literal underscores',
  201. type: 'boolean'
  202. },
  203. literalMidWordAsterisks: {
  204. defaultValue: false,
  205. describe: 'Parse midword asterisks as literal asterisks',
  206. type: 'boolean'
  207. },
  208. strikethrough: {
  209. defaultValue: false,
  210. describe: 'Turn on/off strikethrough support',
  211. type: 'boolean'
  212. },
  213. tables: {
  214. defaultValue: false,
  215. describe: 'Turn on/off tables support',
  216. type: 'boolean'
  217. },
  218. tablesHeaderId: {
  219. defaultValue: false,
  220. describe: 'Add an id to table headers',
  221. type: 'boolean'
  222. },
  223. ghCodeBlocks: {
  224. defaultValue: true,
  225. describe: 'Turn on/off GFM fenced code blocks support',
  226. type: 'boolean'
  227. },
  228. tasklists: {
  229. defaultValue: false,
  230. describe: 'Turn on/off GFM tasklist support',
  231. type: 'boolean'
  232. },
  233. smoothLivePreview: {
  234. defaultValue: false,
  235. describe: 'Prevents weird effects in live previews due to incomplete input',
  236. type: 'boolean'
  237. },
  238. smartIndentationFix: {
  239. defaultValue: false,
  240. description: 'Tries to smartly fix indentation in es6 strings',
  241. type: 'boolean'
  242. },
  243. disableForced4SpacesIndentedSublists: {
  244. defaultValue: false,
  245. description: 'Disables the requirement of indenting nested sublists by 4 spaces',
  246. type: 'boolean'
  247. },
  248. simpleLineBreaks: {
  249. defaultValue: false,
  250. description: 'Parses simple line breaks as <br> (GFM Style)',
  251. type: 'boolean'
  252. },
  253. requireSpaceBeforeHeadingText: {
  254. defaultValue: false,
  255. description: 'Makes adding a space between `#` and the header text mandatory (GFM Style)',
  256. type: 'boolean'
  257. },
  258. ghMentions: {
  259. defaultValue: false,
  260. description: 'Enables github @mentions',
  261. type: 'boolean'
  262. },
  263. ghMentionsLink: {
  264. defaultValue: 'https://github.com/{u}',
  265. description: 'Changes the link generated by @mentions. Only applies if ghMentions option is enabled.',
  266. type: 'string'
  267. },
  268. encodeEmails: {
  269. defaultValue: true,
  270. description: 'Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities',
  271. type: 'boolean'
  272. },
  273. openLinksInNewWindow: {
  274. defaultValue: false,
  275. description: 'Open all links in new windows',
  276. type: 'boolean'
  277. },
  278. backslashEscapesHTMLTags: {
  279. defaultValue: false,
  280. description: 'Support for HTML Tag escaping. ex: \<div>foo\</div>',
  281. type: 'boolean'
  282. },
  283. emoji: {
  284. defaultValue: false,
  285. description: 'Enable emoji support. Ex: `this is a :smile: emoji`',
  286. type: 'boolean'
  287. },
  288. underline: {
  289. defaultValue: false,
  290. description: 'Enable support for underline. Syntax is double or triple underscores: `__underline word__`. With this option enabled, underscores no longer parses into `<em>` and `<strong>`',
  291. type: 'boolean'
  292. },
  293. completeHTMLDocument: {
  294. defaultValue: false,
  295. description: 'Outputs a complete html document, including `<html>`, `<head>` and `<body>` tags',
  296. type: 'boolean'
  297. },
  298. metadata: {
  299. defaultValue: false,
  300. description: 'Enable support for document metadata (defined at the top of the document between `«««` and `»»»` or between `---` and `---`).',
  301. type: 'boolean'
  302. },
  303. splitAdjacentBlockquotes: {
  304. defaultValue: false,
  305. description: 'Split adjacent blockquote blocks',
  306. type: 'boolean'
  307. }
  308. };
  309. if (simple === false) {
  310. return JSON.parse(JSON.stringify(defaultOptions));
  311. }
  312. var ret = {};
  313. for (var opt in defaultOptions) {
  314. if (defaultOptions.hasOwnProperty(opt)) {
  315. ret[opt] = defaultOptions[opt].defaultValue;
  316. }
  317. }
  318. return ret;
  319. }
  320. function allOptionsOn () {
  321. 'use strict';
  322. var options = getDefaultOpts(true),
  323. ret = {};
  324. for (var opt in options) {
  325. if (options.hasOwnProperty(opt)) {
  326. ret[opt] = true;
  327. }
  328. }
  329. return ret;
  330. }
  331. /**
  332. * Created by Tivie on 06-01-2015.
  333. */
  334. // Private properties
  335. var showdown = {},
  336. parsers = {},
  337. extensions = {},
  338. globalOptions = getDefaultOpts(true),
  339. setFlavor = 'vanilla',
  340. flavor = {
  341. github: {
  342. omitExtraWLInCodeBlocks: true,
  343. simplifiedAutoLink: true,
  344. excludeTrailingPunctuationFromURLs: true,
  345. literalMidWordUnderscores: true,
  346. strikethrough: true,
  347. tables: true,
  348. tablesHeaderId: true,
  349. ghCodeBlocks: true,
  350. tasklists: true,
  351. disableForced4SpacesIndentedSublists: true,
  352. simpleLineBreaks: true,
  353. requireSpaceBeforeHeadingText: true,
  354. ghCompatibleHeaderId: true,
  355. ghMentions: true,
  356. backslashEscapesHTMLTags: true,
  357. emoji: true,
  358. splitAdjacentBlockquotes: true
  359. },
  360. original: {
  361. noHeaderId: true,
  362. ghCodeBlocks: false
  363. },
  364. ghost: {
  365. omitExtraWLInCodeBlocks: true,
  366. parseImgDimensions: true,
  367. simplifiedAutoLink: true,
  368. excludeTrailingPunctuationFromURLs: true,
  369. literalMidWordUnderscores: true,
  370. strikethrough: true,
  371. tables: true,
  372. tablesHeaderId: true,
  373. ghCodeBlocks: true,
  374. tasklists: true,
  375. smoothLivePreview: true,
  376. simpleLineBreaks: true,
  377. requireSpaceBeforeHeadingText: true,
  378. ghMentions: false,
  379. encodeEmails: true
  380. },
  381. vanilla: getDefaultOpts(true),
  382. allOn: allOptionsOn()
  383. };
  384. /**
  385. * helper namespace
  386. * @type {{}}
  387. */
  388. showdown.helper = {};
  389. /**
  390. * TODO LEGACY SUPPORT CODE
  391. * @type {{}}
  392. */
  393. showdown.extensions = {};
  394. /**
  395. * Set a global option
  396. * @static
  397. * @param {string} key
  398. * @param {*} value
  399. * @returns {showdown}
  400. */
  401. showdown.setOption = function (key, value) {
  402. 'use strict';
  403. globalOptions[key] = value;
  404. return this;
  405. };
  406. /**
  407. * Get a global option
  408. * @static
  409. * @param {string} key
  410. * @returns {*}
  411. */
  412. showdown.getOption = function (key) {
  413. 'use strict';
  414. return globalOptions[key];
  415. };
  416. /**
  417. * Get the global options
  418. * @static
  419. * @returns {{}}
  420. */
  421. showdown.getOptions = function () {
  422. 'use strict';
  423. return globalOptions;
  424. };
  425. /**
  426. * Reset global options to the default values
  427. * @static
  428. */
  429. showdown.resetOptions = function () {
  430. 'use strict';
  431. globalOptions = getDefaultOpts(true);
  432. };
  433. /**
  434. * Set the flavor showdown should use as default
  435. * @param {string} name
  436. */
  437. showdown.setFlavor = function (name) {
  438. 'use strict';
  439. if (!flavor.hasOwnProperty(name)) {
  440. throw Error(name + ' flavor was not found');
  441. }
  442. showdown.resetOptions();
  443. var preset = flavor[name];
  444. setFlavor = name;
  445. for (var option in preset) {
  446. if (preset.hasOwnProperty(option)) {
  447. globalOptions[option] = preset[option];
  448. }
  449. }
  450. };
  451. /**
  452. * Get the currently set flavor
  453. * @returns {string}
  454. */
  455. showdown.getFlavor = function () {
  456. 'use strict';
  457. return setFlavor;
  458. };
  459. /**
  460. * Get the options of a specified flavor. Returns undefined if the flavor was not found
  461. * @param {string} name Name of the flavor
  462. * @returns {{}|undefined}
  463. */
  464. showdown.getFlavorOptions = function (name) {
  465. 'use strict';
  466. if (flavor.hasOwnProperty(name)) {
  467. return flavor[name];
  468. }
  469. };
  470. /**
  471. * Get the default options
  472. * @static
  473. * @param {boolean} [simple=true]
  474. * @returns {{}}
  475. */
  476. showdown.getDefaultOptions = function (simple) {
  477. 'use strict';
  478. return getDefaultOpts(simple);
  479. };
  480. /**
  481. * Get or set a subParser
  482. *
  483. * subParser(name) - Get a registered subParser
  484. * subParser(name, func) - Register a subParser
  485. * @static
  486. * @param {string} name
  487. * @param {function} [func]
  488. * @returns {*}
  489. */
  490. showdown.subParser = function (name, func) {
  491. 'use strict';
  492. if (showdown.helper.isString(name)) {
  493. if (typeof func !== 'undefined') {
  494. parsers[name] = func;
  495. } else {
  496. if (parsers.hasOwnProperty(name)) {
  497. return parsers[name];
  498. } else {
  499. throw Error('SubParser named ' + name + ' not registered!');
  500. }
  501. }
  502. }
  503. };
  504. /**
  505. * Gets or registers an extension
  506. * @static
  507. * @param {string} name
  508. * @param {object|function=} ext
  509. * @returns {*}
  510. */
  511. showdown.extension = function (name, ext) {
  512. 'use strict';
  513. if (!showdown.helper.isString(name)) {
  514. throw Error('Extension \'name\' must be a string');
  515. }
  516. name = showdown.helper.stdExtName(name);
  517. // Getter
  518. if (showdown.helper.isUndefined(ext)) {
  519. if (!extensions.hasOwnProperty(name)) {
  520. throw Error('Extension named ' + name + ' is not registered!');
  521. }
  522. return extensions[name];
  523. // Setter
  524. } else {
  525. // Expand extension if it's wrapped in a function
  526. if (typeof ext === 'function') {
  527. ext = ext();
  528. }
  529. // Ensure extension is an array
  530. if (!showdown.helper.isArray(ext)) {
  531. ext = [ext];
  532. }
  533. var validExtension = validate(ext, name);
  534. if (validExtension.valid) {
  535. extensions[name] = ext;
  536. } else {
  537. throw Error(validExtension.error);
  538. }
  539. }
  540. };
  541. /**
  542. * Gets all extensions registered
  543. * @returns {{}}
  544. */
  545. showdown.getAllExtensions = function () {
  546. 'use strict';
  547. return extensions;
  548. };
  549. /**
  550. * Remove an extension
  551. * @param {string} name
  552. */
  553. showdown.removeExtension = function (name) {
  554. 'use strict';
  555. delete extensions[name];
  556. };
  557. /**
  558. * Removes all extensions
  559. */
  560. showdown.resetExtensions = function () {
  561. 'use strict';
  562. extensions = {};
  563. };
  564. /**
  565. * Validate extension
  566. * @param {array} extension
  567. * @param {string} name
  568. * @returns {{valid: boolean, error: string}}
  569. */
  570. function validate (extension, name) {
  571. 'use strict';
  572. var errMsg = (name) ? 'Error in ' + name + ' extension->' : 'Error in unnamed extension',
  573. ret = {
  574. valid: true,
  575. error: ''
  576. };
  577. if (!showdown.helper.isArray(extension)) {
  578. extension = [extension];
  579. }
  580. for (var i = 0; i < extension.length; ++i) {
  581. var baseMsg = errMsg + ' sub-extension ' + i + ': ',
  582. ext = extension[i];
  583. if (typeof ext !== 'object') {
  584. ret.valid = false;
  585. ret.error = baseMsg + 'must be an object, but ' + typeof ext + ' given';
  586. return ret;
  587. }
  588. if (!showdown.helper.isString(ext.type)) {
  589. ret.valid = false;
  590. ret.error = baseMsg + 'property "type" must be a string, but ' + typeof ext.type + ' given';
  591. return ret;
  592. }
  593. var type = ext.type = ext.type.toLowerCase();
  594. // normalize extension type
  595. if (type === 'language') {
  596. type = ext.type = 'lang';
  597. }
  598. if (type === 'html') {
  599. type = ext.type = 'output';
  600. }
  601. if (type !== 'lang' && type !== 'output' && type !== 'listener') {
  602. ret.valid = false;
  603. ret.error = baseMsg + 'type ' + type + ' is not recognized. Valid values: "lang/language", "output/html" or "listener"';
  604. return ret;
  605. }
  606. if (type === 'listener') {
  607. if (showdown.helper.isUndefined(ext.listeners)) {
  608. ret.valid = false;
  609. ret.error = baseMsg + '. Extensions of type "listener" must have a property called "listeners"';
  610. return ret;
  611. }
  612. } else {
  613. if (showdown.helper.isUndefined(ext.filter) && showdown.helper.isUndefined(ext.regex)) {
  614. ret.valid = false;
  615. ret.error = baseMsg + type + ' extensions must define either a "regex" property or a "filter" method';
  616. return ret;
  617. }
  618. }
  619. if (ext.listeners) {
  620. if (typeof ext.listeners !== 'object') {
  621. ret.valid = false;
  622. ret.error = baseMsg + '"listeners" property must be an object but ' + typeof ext.listeners + ' given';
  623. return ret;
  624. }
  625. for (var ln in ext.listeners) {
  626. if (ext.listeners.hasOwnProperty(ln)) {
  627. if (typeof ext.listeners[ln] !== 'function') {
  628. ret.valid = false;
  629. ret.error = baseMsg + '"listeners" property must be an hash of [event name]: [callback]. listeners.' + ln +
  630. ' must be a function but ' + typeof ext.listeners[ln] + ' given';
  631. return ret;
  632. }
  633. }
  634. }
  635. }
  636. if (ext.filter) {
  637. if (typeof ext.filter !== 'function') {
  638. ret.valid = false;
  639. ret.error = baseMsg + '"filter" must be a function, but ' + typeof ext.filter + ' given';
  640. return ret;
  641. }
  642. } else if (ext.regex) {
  643. if (showdown.helper.isString(ext.regex)) {
  644. ext.regex = new RegExp(ext.regex, 'g');
  645. }
  646. if (!(ext.regex instanceof RegExp)) {
  647. ret.valid = false;
  648. ret.error = baseMsg + '"regex" property must either be a string or a RegExp object, but ' + typeof ext.regex + ' given';
  649. return ret;
  650. }
  651. if (showdown.helper.isUndefined(ext.replace)) {
  652. ret.valid = false;
  653. ret.error = baseMsg + '"regex" extensions must implement a replace string or function';
  654. return ret;
  655. }
  656. }
  657. }
  658. return ret;
  659. }
  660. /**
  661. * Validate extension
  662. * @param {object} ext
  663. * @returns {boolean}
  664. */
  665. showdown.validateExtension = function (ext) {
  666. 'use strict';
  667. var validateExtension = validate(ext, null);
  668. if (!validateExtension.valid) {
  669. console.warn(validateExtension.error);
  670. return false;
  671. }
  672. return true;
  673. };
  674. /**
  675. * showdownjs helper functions
  676. */
  677. if (!showdown.hasOwnProperty('helper')) {
  678. showdown.helper = {};
  679. }
  680. /**
  681. * Check if var is string
  682. * @static
  683. * @param {string} a
  684. * @returns {boolean}
  685. */
  686. showdown.helper.isString = function (a) {
  687. 'use strict';
  688. return (typeof a === 'string' || a instanceof String);
  689. };
  690. /**
  691. * Check if var is a function
  692. * @static
  693. * @param {*} a
  694. * @returns {boolean}
  695. */
  696. showdown.helper.isFunction = function (a) {
  697. 'use strict';
  698. var getType = {};
  699. return a && getType.toString.call(a) === '[object Function]';
  700. };
  701. /**
  702. * isArray helper function
  703. * @static
  704. * @param {*} a
  705. * @returns {boolean}
  706. */
  707. showdown.helper.isArray = function (a) {
  708. 'use strict';
  709. return Array.isArray(a);
  710. };
  711. /**
  712. * Check if value is undefined
  713. * @static
  714. * @param {*} value The value to check.
  715. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  716. */
  717. showdown.helper.isUndefined = function (value) {
  718. 'use strict';
  719. return typeof value === 'undefined';
  720. };
  721. /**
  722. * ForEach helper function
  723. * Iterates over Arrays and Objects (own properties only)
  724. * @static
  725. * @param {*} obj
  726. * @param {function} callback Accepts 3 params: 1. value, 2. key, 3. the original array/object
  727. */
  728. showdown.helper.forEach = function (obj, callback) {
  729. 'use strict';
  730. // check if obj is defined
  731. if (showdown.helper.isUndefined(obj)) {
  732. throw new Error('obj param is required');
  733. }
  734. if (showdown.helper.isUndefined(callback)) {
  735. throw new Error('callback param is required');
  736. }
  737. if (!showdown.helper.isFunction(callback)) {
  738. throw new Error('callback param must be a function/closure');
  739. }
  740. if (typeof obj.forEach === 'function') {
  741. obj.forEach(callback);
  742. } else if (showdown.helper.isArray(obj)) {
  743. for (var i = 0; i < obj.length; i++) {
  744. callback(obj[i], i, obj);
  745. }
  746. } else if (typeof (obj) === 'object') {
  747. for (var prop in obj) {
  748. if (obj.hasOwnProperty(prop)) {
  749. callback(obj[prop], prop, obj);
  750. }
  751. }
  752. } else {
  753. throw new Error('obj does not seem to be an array or an iterable object');
  754. }
  755. };
  756. /**
  757. * Standardidize extension name
  758. * @static
  759. * @param {string} s extension name
  760. * @returns {string}
  761. */
  762. showdown.helper.stdExtName = function (s) {
  763. 'use strict';
  764. return s.replace(/[_?*+\/\\.^-]/g, '').replace(/\s/g, '').toLowerCase();
  765. };
  766. function escapeCharactersCallback (wholeMatch, m1) {
  767. 'use strict';
  768. var charCodeToEscape = m1.charCodeAt(0);
  769. return '¨E' + charCodeToEscape + 'E';
  770. }
  771. /**
  772. * Callback used to escape characters when passing through String.replace
  773. * @static
  774. * @param {string} wholeMatch
  775. * @param {string} m1
  776. * @returns {string}
  777. */
  778. showdown.helper.escapeCharactersCallback = escapeCharactersCallback;
  779. /**
  780. * Escape characters in a string
  781. * @static
  782. * @param {string} text
  783. * @param {string} charsToEscape
  784. * @param {boolean} afterBackslash
  785. * @returns {XML|string|void|*}
  786. */
  787. showdown.helper.escapeCharacters = function (text, charsToEscape, afterBackslash) {
  788. 'use strict';
  789. // First we have to escape the escape characters so that
  790. // we can build a character class out of them
  791. var regexString = '([' + charsToEscape.replace(/([\[\]\\])/g, '\\$1') + '])';
  792. if (afterBackslash) {
  793. regexString = '\\\\' + regexString;
  794. }
  795. var regex = new RegExp(regexString, 'g');
  796. text = text.replace(regex, escapeCharactersCallback);
  797. return text;
  798. };
  799. /**
  800. * Unescape HTML entities
  801. * @param txt
  802. * @returns {string}
  803. */
  804. showdown.helper.unescapeHTMLEntities = function (txt) {
  805. 'use strict';
  806. return txt
  807. .replace(/&quot;/g, '"')
  808. .replace(/&lt;/g, '<')
  809. .replace(/&gt;/g, '>')
  810. .replace(/&amp;/g, '&');
  811. };
  812. var rgxFindMatchPos = function (str, left, right, flags) {
  813. 'use strict';
  814. var f = flags || '',
  815. g = f.indexOf('g') > -1,
  816. x = new RegExp(left + '|' + right, 'g' + f.replace(/g/g, '')),
  817. l = new RegExp(left, f.replace(/g/g, '')),
  818. pos = [],
  819. t, s, m, start, end;
  820. do {
  821. t = 0;
  822. while ((m = x.exec(str))) {
  823. if (l.test(m[0])) {
  824. if (!(t++)) {
  825. s = x.lastIndex;
  826. start = s - m[0].length;
  827. }
  828. } else if (t) {
  829. if (!--t) {
  830. end = m.index + m[0].length;
  831. var obj = {
  832. left: {start: start, end: s},
  833. match: {start: s, end: m.index},
  834. right: {start: m.index, end: end},
  835. wholeMatch: {start: start, end: end}
  836. };
  837. pos.push(obj);
  838. if (!g) {
  839. return pos;
  840. }
  841. }
  842. }
  843. }
  844. } while (t && (x.lastIndex = s));
  845. return pos;
  846. };
  847. /**
  848. * matchRecursiveRegExp
  849. *
  850. * (c) 2007 Steven Levithan <stevenlevithan.com>
  851. * MIT License
  852. *
  853. * Accepts a string to search, a left and right format delimiter
  854. * as regex patterns, and optional regex flags. Returns an array
  855. * of matches, allowing nested instances of left/right delimiters.
  856. * Use the "g" flag to return all matches, otherwise only the
  857. * first is returned. Be careful to ensure that the left and
  858. * right format delimiters produce mutually exclusive matches.
  859. * Backreferences are not supported within the right delimiter
  860. * due to how it is internally combined with the left delimiter.
  861. * When matching strings whose format delimiters are unbalanced
  862. * to the left or right, the output is intentionally as a
  863. * conventional regex library with recursion support would
  864. * produce, e.g. "<<x>" and "<x>>" both produce ["x"] when using
  865. * "<" and ">" as the delimiters (both strings contain a single,
  866. * balanced instance of "<x>").
  867. *
  868. * examples:
  869. * matchRecursiveRegExp("test", "\\(", "\\)")
  870. * returns: []
  871. * matchRecursiveRegExp("<t<<e>><s>>t<>", "<", ">", "g")
  872. * returns: ["t<<e>><s>", ""]
  873. * matchRecursiveRegExp("<div id=\"x\">test</div>", "<div\\b[^>]*>", "</div>", "gi")
  874. * returns: ["test"]
  875. */
  876. showdown.helper.matchRecursiveRegExp = function (str, left, right, flags) {
  877. 'use strict';
  878. var matchPos = rgxFindMatchPos (str, left, right, flags),
  879. results = [];
  880. for (var i = 0; i < matchPos.length; ++i) {
  881. results.push([
  882. str.slice(matchPos[i].wholeMatch.start, matchPos[i].wholeMatch.end),
  883. str.slice(matchPos[i].match.start, matchPos[i].match.end),
  884. str.slice(matchPos[i].left.start, matchPos[i].left.end),
  885. str.slice(matchPos[i].right.start, matchPos[i].right.end)
  886. ]);
  887. }
  888. return results;
  889. };
  890. /**
  891. *
  892. * @param {string} str
  893. * @param {string|function} replacement
  894. * @param {string} left
  895. * @param {string} right
  896. * @param {string} flags
  897. * @returns {string}
  898. */
  899. showdown.helper.replaceRecursiveRegExp = function (str, replacement, left, right, flags) {
  900. 'use strict';
  901. if (!showdown.helper.isFunction(replacement)) {
  902. var repStr = replacement;
  903. replacement = function () {
  904. return repStr;
  905. };
  906. }
  907. var matchPos = rgxFindMatchPos(str, left, right, flags),
  908. finalStr = str,
  909. lng = matchPos.length;
  910. if (lng > 0) {
  911. var bits = [];
  912. if (matchPos[0].wholeMatch.start !== 0) {
  913. bits.push(str.slice(0, matchPos[0].wholeMatch.start));
  914. }
  915. for (var i = 0; i < lng; ++i) {
  916. bits.push(
  917. replacement(
  918. str.slice(matchPos[i].wholeMatch.start, matchPos[i].wholeMatch.end),
  919. str.slice(matchPos[i].match.start, matchPos[i].match.end),
  920. str.slice(matchPos[i].left.start, matchPos[i].left.end),
  921. str.slice(matchPos[i].right.start, matchPos[i].right.end)
  922. )
  923. );
  924. if (i < lng - 1) {
  925. bits.push(str.slice(matchPos[i].wholeMatch.end, matchPos[i + 1].wholeMatch.start));
  926. }
  927. }
  928. if (matchPos[lng - 1].wholeMatch.end < str.length) {
  929. bits.push(str.slice(matchPos[lng - 1].wholeMatch.end));
  930. }
  931. finalStr = bits.join('');
  932. }
  933. return finalStr;
  934. };
  935. /**
  936. * Returns the index within the passed String object of the first occurrence of the specified regex,
  937. * starting the search at fromIndex. Returns -1 if the value is not found.
  938. *
  939. * @param {string} str string to search
  940. * @param {RegExp} regex Regular expression to search
  941. * @param {int} [fromIndex = 0] Index to start the search
  942. * @returns {Number}
  943. * @throws InvalidArgumentError
  944. */
  945. showdown.helper.regexIndexOf = function (str, regex, fromIndex) {
  946. 'use strict';
  947. if (!showdown.helper.isString(str)) {
  948. throw 'InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string';
  949. }
  950. if (regex instanceof RegExp === false) {
  951. throw 'InvalidArgumentError: second parameter of showdown.helper.regexIndexOf function must be an instance of RegExp';
  952. }
  953. var indexOf = str.substring(fromIndex || 0).search(regex);
  954. return (indexOf >= 0) ? (indexOf + (fromIndex || 0)) : indexOf;
  955. };
  956. /**
  957. * Splits the passed string object at the defined index, and returns an array composed of the two substrings
  958. * @param {string} str string to split
  959. * @param {int} index index to split string at
  960. * @returns {[string,string]}
  961. * @throws InvalidArgumentError
  962. */
  963. showdown.helper.splitAtIndex = function (str, index) {
  964. 'use strict';
  965. if (!showdown.helper.isString(str)) {
  966. throw 'InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string';
  967. }
  968. return [str.substring(0, index), str.substring(index)];
  969. };
  970. /**
  971. * Obfuscate an e-mail address through the use of Character Entities,
  972. * transforming ASCII characters into their equivalent decimal or hex entities.
  973. *
  974. * Since it has a random component, subsequent calls to this function produce different results
  975. *
  976. * @param {string} mail
  977. * @returns {string}
  978. */
  979. showdown.helper.encodeEmailAddress = function (mail) {
  980. 'use strict';
  981. var encode = [
  982. function (ch) {
  983. return '&#' + ch.charCodeAt(0) + ';';
  984. },
  985. function (ch) {
  986. return '&#x' + ch.charCodeAt(0).toString(16) + ';';
  987. },
  988. function (ch) {
  989. return ch;
  990. }
  991. ];
  992. mail = mail.replace(/./g, function (ch) {
  993. if (ch === '@') {
  994. // this *must* be encoded. I insist.
  995. ch = encode[Math.floor(Math.random() * 2)](ch);
  996. } else {
  997. var r = Math.random();
  998. // roughly 10% raw, 45% hex, 45% dec
  999. ch = (
  1000. r > 0.9 ? encode[2](ch) : r > 0.45 ? encode[1](ch) : encode[0](ch)
  1001. );
  1002. }
  1003. return ch;
  1004. });
  1005. return mail;
  1006. };
  1007. /**
  1008. *
  1009. * @param str
  1010. * @param targetLength
  1011. * @param padString
  1012. * @returns {string}
  1013. */
  1014. showdown.helper.padEnd = function padEnd (str, targetLength, padString) {
  1015. 'use strict';
  1016. /*jshint bitwise: false*/
  1017. // eslint-disable-next-line space-infix-ops
  1018. targetLength = targetLength>>0; //floor if number or convert non-number to 0;
  1019. /*jshint bitwise: true*/
  1020. padString = String(padString || ' ');
  1021. if (str.length > targetLength) {
  1022. return String(str);
  1023. } else {
  1024. targetLength = targetLength - str.length;
  1025. if (targetLength > padString.length) {
  1026. padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed
  1027. }
  1028. return String(str) + padString.slice(0,targetLength);
  1029. }
  1030. };
  1031. /**
  1032. * POLYFILLS
  1033. */
  1034. // use this instead of builtin is undefined for IE8 compatibility
  1035. if (typeof console === 'undefined') {
  1036. console = {
  1037. warn: function (msg) {
  1038. 'use strict';
  1039. alert(msg);
  1040. },
  1041. log: function (msg) {
  1042. 'use strict';
  1043. alert(msg);
  1044. },
  1045. error: function (msg) {
  1046. 'use strict';
  1047. throw msg;
  1048. }
  1049. };
  1050. }
  1051. /**
  1052. * Common regexes.
  1053. * We declare some common regexes to improve performance
  1054. */
  1055. showdown.helper.regexes = {
  1056. asteriskDashAndColon: /([*_:~])/g
  1057. };
  1058. /**
  1059. * EMOJIS LIST
  1060. */
  1061. showdown.helper.emojis = {
  1062. '+1':'\ud83d\udc4d',
  1063. '-1':'\ud83d\udc4e',
  1064. '100':'\ud83d\udcaf',
  1065. '1234':'\ud83d\udd22',
  1066. '1st_place_medal':'\ud83e\udd47',
  1067. '2nd_place_medal':'\ud83e\udd48',
  1068. '3rd_place_medal':'\ud83e\udd49',
  1069. '8ball':'\ud83c\udfb1',
  1070. 'a':'\ud83c\udd70\ufe0f',
  1071. 'ab':'\ud83c\udd8e',
  1072. 'abc':'\ud83d\udd24',
  1073. 'abcd':'\ud83d\udd21',
  1074. 'accept':'\ud83c\ude51',
  1075. 'aerial_tramway':'\ud83d\udea1',
  1076. 'airplane':'\u2708\ufe0f',
  1077. 'alarm_clock':'\u23f0',
  1078. 'alembic':'\u2697\ufe0f',
  1079. 'alien':'\ud83d\udc7d',
  1080. 'ambulance':'\ud83d\ude91',
  1081. 'amphora':'\ud83c\udffa',
  1082. 'anchor':'\u2693\ufe0f',
  1083. 'angel':'\ud83d\udc7c',
  1084. 'anger':'\ud83d\udca2',
  1085. 'angry':'\ud83d\ude20',
  1086. 'anguished':'\ud83d\ude27',
  1087. 'ant':'\ud83d\udc1c',
  1088. 'apple':'\ud83c\udf4e',
  1089. 'aquarius':'\u2652\ufe0f',
  1090. 'aries':'\u2648\ufe0f',
  1091. 'arrow_backward':'\u25c0\ufe0f',
  1092. 'arrow_double_down':'\u23ec',
  1093. 'arrow_double_up':'\u23eb',
  1094. 'arrow_down':'\u2b07\ufe0f',
  1095. 'arrow_down_small':'\ud83d\udd3d',
  1096. 'arrow_forward':'\u25b6\ufe0f',
  1097. 'arrow_heading_down':'\u2935\ufe0f',
  1098. 'arrow_heading_up':'\u2934\ufe0f',
  1099. 'arrow_left':'\u2b05\ufe0f',
  1100. 'arrow_lower_left':'\u2199\ufe0f',
  1101. 'arrow_lower_right':'\u2198\ufe0f',
  1102. 'arrow_right':'\u27a1\ufe0f',
  1103. 'arrow_right_hook':'\u21aa\ufe0f',
  1104. 'arrow_up':'\u2b06\ufe0f',
  1105. 'arrow_up_down':'\u2195\ufe0f',
  1106. 'arrow_up_small':'\ud83d\udd3c',
  1107. 'arrow_upper_left':'\u2196\ufe0f',
  1108. 'arrow_upper_right':'\u2197\ufe0f',
  1109. 'arrows_clockwise':'\ud83d\udd03',
  1110. 'arrows_counterclockwise':'\ud83d\udd04',
  1111. 'art':'\ud83c\udfa8',
  1112. 'articulated_lorry':'\ud83d\ude9b',
  1113. 'artificial_satellite':'\ud83d\udef0',
  1114. 'astonished':'\ud83d\ude32',
  1115. 'athletic_shoe':'\ud83d\udc5f',
  1116. 'atm':'\ud83c\udfe7',
  1117. 'atom_symbol':'\u269b\ufe0f',
  1118. 'avocado':'\ud83e\udd51',
  1119. 'b':'\ud83c\udd71\ufe0f',
  1120. 'baby':'\ud83d\udc76',
  1121. 'baby_bottle':'\ud83c\udf7c',
  1122. 'baby_chick':'\ud83d\udc24',
  1123. 'baby_symbol':'\ud83d\udebc',
  1124. 'back':'\ud83d\udd19',
  1125. 'bacon':'\ud83e\udd53',
  1126. 'badminton':'\ud83c\udff8',
  1127. 'baggage_claim':'\ud83d\udec4',
  1128. 'baguette_bread':'\ud83e\udd56',
  1129. 'balance_scale':'\u2696\ufe0f',
  1130. 'balloon':'\ud83c\udf88',
  1131. 'ballot_box':'\ud83d\uddf3',
  1132. 'ballot_box_with_check':'\u2611\ufe0f',
  1133. 'bamboo':'\ud83c\udf8d',
  1134. 'banana':'\ud83c\udf4c',
  1135. 'bangbang':'\u203c\ufe0f',
  1136. 'bank':'\ud83c\udfe6',
  1137. 'bar_chart':'\ud83d\udcca',
  1138. 'barber':'\ud83d\udc88',
  1139. 'baseball':'\u26be\ufe0f',
  1140. 'basketball':'\ud83c\udfc0',
  1141. 'basketball_man':'\u26f9\ufe0f',
  1142. 'basketball_woman':'\u26f9\ufe0f&zwj;\u2640\ufe0f',
  1143. 'bat':'\ud83e\udd87',
  1144. 'bath':'\ud83d\udec0',
  1145. 'bathtub':'\ud83d\udec1',
  1146. 'battery':'\ud83d\udd0b',
  1147. 'beach_umbrella':'\ud83c\udfd6',
  1148. 'bear':'\ud83d\udc3b',
  1149. 'bed':'\ud83d\udecf',
  1150. 'bee':'\ud83d\udc1d',
  1151. 'beer':'\ud83c\udf7a',
  1152. 'beers':'\ud83c\udf7b',
  1153. 'beetle':'\ud83d\udc1e',
  1154. 'beginner':'\ud83d\udd30',
  1155. 'bell':'\ud83d\udd14',
  1156. 'bellhop_bell':'\ud83d\udece',
  1157. 'bento':'\ud83c\udf71',
  1158. 'biking_man':'\ud83d\udeb4',
  1159. 'bike':'\ud83d\udeb2',
  1160. 'biking_woman':'\ud83d\udeb4&zwj;\u2640\ufe0f',
  1161. 'bikini':'\ud83d\udc59',
  1162. 'biohazard':'\u2623\ufe0f',
  1163. 'bird':'\ud83d\udc26',
  1164. 'birthday':'\ud83c\udf82',
  1165. 'black_circle':'\u26ab\ufe0f',
  1166. 'black_flag':'\ud83c\udff4',
  1167. 'black_heart':'\ud83d\udda4',
  1168. 'black_joker':'\ud83c\udccf',
  1169. 'black_large_square':'\u2b1b\ufe0f',
  1170. 'black_medium_small_square':'\u25fe\ufe0f',
  1171. 'black_medium_square':'\u25fc\ufe0f',
  1172. 'black_nib':'\u2712\ufe0f',
  1173. 'black_small_square':'\u25aa\ufe0f',
  1174. 'black_square_button':'\ud83d\udd32',
  1175. 'blonde_man':'\ud83d\udc71',
  1176. 'blonde_woman':'\ud83d\udc71&zwj;\u2640\ufe0f',
  1177. 'blossom':'\ud83c\udf3c',
  1178. 'blowfish':'\ud83d\udc21',
  1179. 'blue_book':'\ud83d\udcd8',
  1180. 'blue_car':'\ud83d\ude99',
  1181. 'blue_heart':'\ud83d\udc99',
  1182. 'blush':'\ud83d\ude0a',
  1183. 'boar':'\ud83d\udc17',
  1184. 'boat':'\u26f5\ufe0f',
  1185. 'bomb':'\ud83d\udca3',
  1186. 'book':'\ud83d\udcd6',
  1187. 'bookmark':'\ud83d\udd16',
  1188. 'bookmark_tabs':'\ud83d\udcd1',
  1189. 'books':'\ud83d\udcda',
  1190. 'boom':'\ud83d\udca5',
  1191. 'boot':'\ud83d\udc62',
  1192. 'bouquet':'\ud83d\udc90',
  1193. 'bowing_man':'\ud83d\ude47',
  1194. 'bow_and_arrow':'\ud83c\udff9',
  1195. 'bowing_woman':'\ud83d\ude47&zwj;\u2640\ufe0f',
  1196. 'bowling':'\ud83c\udfb3',
  1197. 'boxing_glove':'\ud83e\udd4a',
  1198. 'boy':'\ud83d\udc66',
  1199. 'bread':'\ud83c\udf5e',
  1200. 'bride_with_veil':'\ud83d\udc70',
  1201. 'bridge_at_night':'\ud83c\udf09',
  1202. 'briefcase':'\ud83d\udcbc',
  1203. 'broken_heart':'\ud83d\udc94',
  1204. 'bug':'\ud83d\udc1b',
  1205. 'building_construction':'\ud83c\udfd7',
  1206. 'bulb':'\ud83d\udca1',
  1207. 'bullettrain_front':'\ud83d\ude85',
  1208. 'bullettrain_side':'\ud83d\ude84',
  1209. 'burrito':'\ud83c\udf2f',
  1210. 'bus':'\ud83d\ude8c',
  1211. 'business_suit_levitating':'\ud83d\udd74',
  1212. 'busstop':'\ud83d\ude8f',
  1213. 'bust_in_silhouette':'\ud83d\udc64',
  1214. 'busts_in_silhouette':'\ud83d\udc65',
  1215. 'butterfly':'\ud83e\udd8b',
  1216. 'cactus':'\ud83c\udf35',
  1217. 'cake':'\ud83c\udf70',
  1218. 'calendar':'\ud83d\udcc6',
  1219. 'call_me_hand':'\ud83e\udd19',
  1220. 'calling':'\ud83d\udcf2',
  1221. 'camel':'\ud83d\udc2b',
  1222. 'camera':'\ud83d\udcf7',
  1223. 'camera_flash':'\ud83d\udcf8',
  1224. 'camping':'\ud83c\udfd5',
  1225. 'cancer':'\u264b\ufe0f',
  1226. 'candle':'\ud83d\udd6f',
  1227. 'candy':'\ud83c\udf6c',
  1228. 'canoe':'\ud83d\udef6',
  1229. 'capital_abcd':'\ud83d\udd20',
  1230. 'capricorn':'\u2651\ufe0f',
  1231. 'car':'\ud83d\ude97',
  1232. 'card_file_box':'\ud83d\uddc3',
  1233. 'card_index':'\ud83d\udcc7',
  1234. 'card_index_dividers':'\ud83d\uddc2',
  1235. 'carousel_horse':'\ud83c\udfa0',
  1236. 'carrot':'\ud83e\udd55',
  1237. 'cat':'\ud83d\udc31',
  1238. 'cat2':'\ud83d\udc08',
  1239. 'cd':'\ud83d\udcbf',
  1240. 'chains':'\u26d3',
  1241. 'champagne':'\ud83c\udf7e',
  1242. 'chart':'\ud83d\udcb9',
  1243. 'chart_with_downwards_trend':'\ud83d\udcc9',
  1244. 'chart_with_upwards_trend':'\ud83d\udcc8',
  1245. 'checkered_flag':'\ud83c\udfc1',
  1246. 'cheese':'\ud83e\uddc0',
  1247. 'cherries':'\ud83c\udf52',
  1248. 'cherry_blossom':'\ud83c\udf38',
  1249. 'chestnut':'\ud83c\udf30',
  1250. 'chicken':'\ud83d\udc14',
  1251. 'children_crossing':'\ud83d\udeb8',
  1252. 'chipmunk':'\ud83d\udc3f',
  1253. 'chocolate_bar':'\ud83c\udf6b',
  1254. 'christmas_tree':'\ud83c\udf84',
  1255. 'church':'\u26ea\ufe0f',
  1256. 'cinema':'\ud83c\udfa6',
  1257. 'circus_tent':'\ud83c\udfaa',
  1258. 'city_sunrise':'\ud83c\udf07',
  1259. 'city_sunset':'\ud83c\udf06',
  1260. 'cityscape':'\ud83c\udfd9',
  1261. 'cl':'\ud83c\udd91',
  1262. 'clamp':'\ud83d\udddc',
  1263. 'clap':'\ud83d\udc4f',
  1264. 'clapper':'\ud83c\udfac',
  1265. 'classical_building':'\ud83c\udfdb',
  1266. 'clinking_glasses':'\ud83e\udd42',
  1267. 'clipboard':'\ud83d\udccb',
  1268. 'clock1':'\ud83d\udd50',
  1269. 'clock10':'\ud83d\udd59',
  1270. 'clock1030':'\ud83d\udd65',
  1271. 'clock11':'\ud83d\udd5a',
  1272. 'clock1130':'\ud83d\udd66',
  1273. 'clock12':'\ud83d\udd5b',
  1274. 'clock1230':'\ud83d\udd67',
  1275. 'clock130':'\ud83d\udd5c',
  1276. 'clock2':'\ud83d\udd51',
  1277. 'clock230':'\ud83d\udd5d',
  1278. 'clock3':'\ud83d\udd52',
  1279. 'clock330':'\ud83d\udd5e',
  1280. 'clock4':'\ud83d\udd53',
  1281. 'clock430':'\ud83d\udd5f',
  1282. 'clock5':'\ud83d\udd54',
  1283. 'clock530':'\ud83d\udd60',
  1284. 'clock6':'\ud83d\udd55',
  1285. 'clock630':'\ud83d\udd61',
  1286. 'clock7':'\ud83d\udd56',
  1287. 'clock730':'\ud83d\udd62',
  1288. 'clock8':'\ud83d\udd57',
  1289. 'clock830':'\ud83d\udd63',
  1290. 'clock9':'\ud83d\udd58',
  1291. 'clock930':'\ud83d\udd64',
  1292. 'closed_book':'\ud83d\udcd5',
  1293. 'closed_lock_with_key':'\ud83d\udd10',
  1294. 'closed_umbrella':'\ud83c\udf02',
  1295. 'cloud':'\u2601\ufe0f',
  1296. 'cloud_with_lightning':'\ud83c\udf29',
  1297. 'cloud_with_lightning_and_rain':'\u26c8',
  1298. 'cloud_with_rain':'\ud83c\udf27',
  1299. 'cloud_with_snow':'\ud83c\udf28',
  1300. 'clown_face':'\ud83e\udd21',
  1301. 'clubs':'\u2663\ufe0f',
  1302. 'cocktail':'\ud83c\udf78',
  1303. 'coffee':'\u2615\ufe0f',
  1304. 'coffin':'\u26b0\ufe0f',
  1305. 'cold_sweat':'\ud83d\ude30',
  1306. 'comet':'\u2604\ufe0f',
  1307. 'computer':'\ud83d\udcbb',
  1308. 'computer_mouse':'\ud83d\uddb1',
  1309. 'confetti_ball':'\ud83c\udf8a',
  1310. 'confounded':'\ud83d\ude16',
  1311. 'confused':'\ud83d\ude15',
  1312. 'congratulations':'\u3297\ufe0f',
  1313. 'construction':'\ud83d\udea7',
  1314. 'construction_worker_man':'\ud83d\udc77',
  1315. 'construction_worker_woman':'\ud83d\udc77&zwj;\u2640\ufe0f',
  1316. 'control_knobs':'\ud83c\udf9b',
  1317. 'convenience_store':'\ud83c\udfea',
  1318. 'cookie':'\ud83c\udf6a',
  1319. 'cool':'\ud83c\udd92',
  1320. 'policeman':'\ud83d\udc6e',
  1321. 'copyright':'\u00a9\ufe0f',
  1322. 'corn':'\ud83c\udf3d',
  1323. 'couch_and_lamp':'\ud83d\udecb',
  1324. 'couple':'\ud83d\udc6b',
  1325. 'couple_with_heart_woman_man':'\ud83d\udc91',
  1326. 'couple_with_heart_man_man':'\ud83d\udc68&zwj;\u2764\ufe0f&zwj;\ud83d\udc68',
  1327. 'couple_with_heart_woman_woman':'\ud83d\udc69&zwj;\u2764\ufe0f&zwj;\ud83d\udc69',
  1328. 'couplekiss_man_man':'\ud83d\udc68&zwj;\u2764\ufe0f&zwj;\ud83d\udc8b&zwj;\ud83d\udc68',
  1329. 'couplekiss_man_woman':'\ud83d\udc8f',
  1330. 'couplekiss_woman_woman':'\ud83d\udc69&zwj;\u2764\ufe0f&zwj;\ud83d\udc8b&zwj;\ud83d\udc69',
  1331. 'cow':'\ud83d\udc2e',
  1332. 'cow2':'\ud83d\udc04',
  1333. 'cowboy_hat_face':'\ud83e\udd20',
  1334. 'crab':'\ud83e\udd80',
  1335. 'crayon':'\ud83d\udd8d',
  1336. 'credit_card':'\ud83d\udcb3',
  1337. 'crescent_moon':'\ud83c\udf19',
  1338. 'cricket':'\ud83c\udfcf',
  1339. 'crocodile':'\ud83d\udc0a',
  1340. 'croissant':'\ud83e\udd50',
  1341. 'crossed_fingers':'\ud83e\udd1e',
  1342. 'crossed_flags':'\ud83c\udf8c',
  1343. 'crossed_swords':'\u2694\ufe0f',
  1344. 'crown':'\ud83d\udc51',
  1345. 'cry':'\ud83d\ude22',
  1346. 'crying_cat_face':'\ud83d\ude3f',
  1347. 'crystal_ball':'\ud83d\udd2e',
  1348. 'cucumber':'\ud83e\udd52',
  1349. 'cupid':'\ud83d\udc98',
  1350. 'curly_loop':'\u27b0',
  1351. 'currency_exchange':'\ud83d\udcb1',
  1352. 'curry':'\ud83c\udf5b',
  1353. 'custard':'\ud83c\udf6e',
  1354. 'customs':'\ud83d\udec3',
  1355. 'cyclone':'\ud83c\udf00',
  1356. 'dagger':'\ud83d\udde1',
  1357. 'dancer':'\ud83d\udc83',
  1358. 'dancing_women':'\ud83d\udc6f',
  1359. 'dancing_men':'\ud83d\udc6f&zwj;\u2642\ufe0f',
  1360. 'dango':'\ud83c\udf61',
  1361. 'dark_sunglasses':'\ud83d\udd76',
  1362. 'dart':'\ud83c\udfaf',
  1363. 'dash':'\ud83d\udca8',
  1364. 'date':'\ud83d\udcc5',
  1365. 'deciduous_tree':'\ud83c\udf33',
  1366. 'deer':'\ud83e\udd8c',
  1367. 'department_store':'\ud83c\udfec',
  1368. 'derelict_house':'\ud83c\udfda',
  1369. 'desert':'\ud83c\udfdc',
  1370. 'desert_island':'\ud83c\udfdd',
  1371. 'desktop_computer':'\ud83d\udda5',
  1372. 'male_detective':'\ud83d\udd75\ufe0f',
  1373. 'diamond_shape_with_a_dot_inside':'\ud83d\udca0',
  1374. 'diamonds':'\u2666\ufe0f',
  1375. 'disappointed':'\ud83d\ude1e',
  1376. 'disappointed_relieved':'\ud83d\ude25',
  1377. 'dizzy':'\ud83d\udcab',
  1378. 'dizzy_face':'\ud83d\ude35',
  1379. 'do_not_litter':'\ud83d\udeaf',
  1380. 'dog':'\ud83d\udc36',
  1381. 'dog2':'\ud83d\udc15',
  1382. 'dollar':'\ud83d\udcb5',
  1383. 'dolls':'\ud83c\udf8e',
  1384. 'dolphin':'\ud83d\udc2c',
  1385. 'door':'\ud83d\udeaa',
  1386. 'doughnut':'\ud83c\udf69',
  1387. 'dove':'\ud83d\udd4a',
  1388. 'dragon':'\ud83d\udc09',
  1389. 'dragon_face':'\ud83d\udc32',
  1390. 'dress':'\ud83d\udc57',
  1391. 'dromedary_camel':'\ud83d\udc2a',
  1392. 'drooling_face':'\ud83e\udd24',
  1393. 'droplet':'\ud83d\udca7',
  1394. 'drum':'\ud83e\udd41',
  1395. 'duck':'\ud83e\udd86',
  1396. 'dvd':'\ud83d\udcc0',
  1397. 'e-mail':'\ud83d\udce7',
  1398. 'eagle':'\ud83e\udd85',
  1399. 'ear':'\ud83d\udc42',
  1400. 'ear_of_rice':'\ud83c\udf3e',
  1401. 'earth_africa':'\ud83c\udf0d',
  1402. 'earth_americas':'\ud83c\udf0e',
  1403. 'earth_asia':'\ud83c\udf0f',
  1404. 'egg':'\ud83e\udd5a',
  1405. 'eggplant':'\ud83c\udf46',
  1406. 'eight_pointed_black_star':'\u2734\ufe0f',
  1407. 'eight_spoked_asterisk':'\u2733\ufe0f',
  1408. 'electric_plug':'\ud83d\udd0c',
  1409. 'elephant':'\ud83d\udc18',
  1410. 'email':'\u2709\ufe0f',
  1411. 'end':'\ud83d\udd1a',
  1412. 'envelope_with_arrow':'\ud83d\udce9',
  1413. 'euro':'\ud83d\udcb6',
  1414. 'european_castle':'\ud83c\udff0',
  1415. 'european_post_office':'\ud83c\udfe4',
  1416. 'evergreen_tree':'\ud83c\udf32',
  1417. 'exclamation':'\u2757\ufe0f',
  1418. 'expressionless':'\ud83d\ude11',
  1419. 'eye':'\ud83d\udc41',
  1420. 'eye_speech_bubble':'\ud83d\udc41&zwj;\ud83d\udde8',
  1421. 'eyeglasses':'\ud83d\udc53',
  1422. 'eyes':'\ud83d\udc40',
  1423. 'face_with_head_bandage':'\ud83e\udd15',
  1424. 'face_with_thermometer':'\ud83e\udd12',
  1425. 'fist_oncoming':'\ud83d\udc4a',
  1426. 'factory':'\ud83c\udfed',
  1427. 'fallen_leaf':'\ud83c\udf42',
  1428. 'family_man_woman_boy':'\ud83d\udc6a',
  1429. 'family_man_boy':'\ud83d\udc68&zwj;\ud83d\udc66',
  1430. 'family_man_boy_boy':'\ud83d\udc68&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1431. 'family_man_girl':'\ud83d\udc68&zwj;\ud83d\udc67',
  1432. 'family_man_girl_boy':'\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1433. 'family_man_girl_girl':'\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1434. 'family_man_man_boy':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc66',
  1435. 'family_man_man_boy_boy':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1436. 'family_man_man_girl':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc67',
  1437. 'family_man_man_girl_boy':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1438. 'family_man_man_girl_girl':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1439. 'family_man_woman_boy_boy':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1440. 'family_man_woman_girl':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc67',
  1441. 'family_man_woman_girl_boy':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1442. 'family_man_woman_girl_girl':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1443. 'family_woman_boy':'\ud83d\udc69&zwj;\ud83d\udc66',
  1444. 'family_woman_boy_boy':'\ud83d\udc69&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1445. 'family_woman_girl':'\ud83d\udc69&zwj;\ud83d\udc67',
  1446. 'family_woman_girl_boy':'\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1447. 'family_woman_girl_girl':'\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1448. 'family_woman_woman_boy':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc66',
  1449. 'family_woman_woman_boy_boy':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1450. 'family_woman_woman_girl':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc67',
  1451. 'family_woman_woman_girl_boy':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1452. 'family_woman_woman_girl_girl':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1453. 'fast_forward':'\u23e9',
  1454. 'fax':'\ud83d\udce0',
  1455. 'fearful':'\ud83d\ude28',
  1456. 'feet':'\ud83d\udc3e',
  1457. 'female_detective':'\ud83d\udd75\ufe0f&zwj;\u2640\ufe0f',
  1458. 'ferris_wheel':'\ud83c\udfa1',
  1459. 'ferry':'\u26f4',
  1460. 'field_hockey':'\ud83c\udfd1',
  1461. 'file_cabinet':'\ud83d\uddc4',
  1462. 'file_folder':'\ud83d\udcc1',
  1463. 'film_projector':'\ud83d\udcfd',
  1464. 'film_strip':'\ud83c\udf9e',
  1465. 'fire':'\ud83d\udd25',
  1466. 'fire_engine':'\ud83d\ude92',
  1467. 'fireworks':'\ud83c\udf86',
  1468. 'first_quarter_moon':'\ud83c\udf13',
  1469. 'first_quarter_moon_with_face':'\ud83c\udf1b',
  1470. 'fish':'\ud83d\udc1f',
  1471. 'fish_cake':'\ud83c\udf65',
  1472. 'fishing_pole_and_fish':'\ud83c\udfa3',
  1473. 'fist_raised':'\u270a',
  1474. 'fist_left':'\ud83e\udd1b',
  1475. 'fist_right':'\ud83e\udd1c',
  1476. 'flags':'\ud83c\udf8f',
  1477. 'flashlight':'\ud83d\udd26',
  1478. 'fleur_de_lis':'\u269c\ufe0f',
  1479. 'flight_arrival':'\ud83d\udeec',
  1480. 'flight_departure':'\ud83d\udeeb',
  1481. 'floppy_disk':'\ud83d\udcbe',
  1482. 'flower_playing_cards':'\ud83c\udfb4',
  1483. 'flushed':'\ud83d\ude33',
  1484. 'fog':'\ud83c\udf2b',
  1485. 'foggy':'\ud83c\udf01',
  1486. 'football':'\ud83c\udfc8',
  1487. 'footprints':'\ud83d\udc63',
  1488. 'fork_and_knife':'\ud83c\udf74',
  1489. 'fountain':'\u26f2\ufe0f',
  1490. 'fountain_pen':'\ud83d\udd8b',
  1491. 'four_leaf_clover':'\ud83c\udf40',
  1492. 'fox_face':'\ud83e\udd8a',
  1493. 'framed_picture':'\ud83d\uddbc',
  1494. 'free':'\ud83c\udd93',
  1495. 'fried_egg':'\ud83c\udf73',
  1496. 'fried_shrimp':'\ud83c\udf64',
  1497. 'fries':'\ud83c\udf5f',
  1498. 'frog':'\ud83d\udc38',
  1499. 'frowning':'\ud83d\ude26',
  1500. 'frowning_face':'\u2639\ufe0f',
  1501. 'frowning_man':'\ud83d\ude4d&zwj;\u2642\ufe0f',
  1502. 'frowning_woman':'\ud83d\ude4d',
  1503. 'middle_finger':'\ud83d\udd95',
  1504. 'fuelpump':'\u26fd\ufe0f',
  1505. 'full_moon':'\ud83c\udf15',
  1506. 'full_moon_with_face':'\ud83c\udf1d',
  1507. 'funeral_urn':'\u26b1\ufe0f',
  1508. 'game_die':'\ud83c\udfb2',
  1509. 'gear':'\u2699\ufe0f',
  1510. 'gem':'\ud83d\udc8e',
  1511. 'gemini':'\u264a\ufe0f',
  1512. 'ghost':'\ud83d\udc7b',
  1513. 'gift':'\ud83c\udf81',
  1514. 'gift_heart':'\ud83d\udc9d',
  1515. 'girl':'\ud83d\udc67',
  1516. 'globe_with_meridians':'\ud83c\udf10',
  1517. 'goal_net':'\ud83e\udd45',
  1518. 'goat':'\ud83d\udc10',
  1519. 'golf':'\u26f3\ufe0f',
  1520. 'golfing_man':'\ud83c\udfcc\ufe0f',
  1521. 'golfing_woman':'\ud83c\udfcc\ufe0f&zwj;\u2640\ufe0f',
  1522. 'gorilla':'\ud83e\udd8d',
  1523. 'grapes':'\ud83c\udf47',
  1524. 'green_apple':'\ud83c\udf4f',
  1525. 'green_book':'\ud83d\udcd7',
  1526. 'green_heart':'\ud83d\udc9a',
  1527. 'green_salad':'\ud83e\udd57',
  1528. 'grey_exclamation':'\u2755',
  1529. 'grey_question':'\u2754',
  1530. 'grimacing':'\ud83d\ude2c',
  1531. 'grin':'\ud83d\ude01',
  1532. 'grinning':'\ud83d\ude00',
  1533. 'guardsman':'\ud83d\udc82',
  1534. 'guardswoman':'\ud83d\udc82&zwj;\u2640\ufe0f',
  1535. 'guitar':'\ud83c\udfb8',
  1536. 'gun':'\ud83d\udd2b',
  1537. 'haircut_woman':'\ud83d\udc87',
  1538. 'haircut_man':'\ud83d\udc87&zwj;\u2642\ufe0f',
  1539. 'hamburger':'\ud83c\udf54',
  1540. 'hammer':'\ud83d\udd28',
  1541. 'hammer_and_pick':'\u2692',
  1542. 'hammer_and_wrench':'\ud83d\udee0',
  1543. 'hamster':'\ud83d\udc39',
  1544. 'hand':'\u270b',
  1545. 'handbag':'\ud83d\udc5c',
  1546. 'handshake':'\ud83e\udd1d',
  1547. 'hankey':'\ud83d\udca9',
  1548. 'hatched_chick':'\ud83d\udc25',
  1549. 'hatching_chick':'\ud83d\udc23',
  1550. 'headphones':'\ud83c\udfa7',
  1551. 'hear_no_evil':'\ud83d\ude49',
  1552. 'heart':'\u2764\ufe0f',
  1553. 'heart_decoration':'\ud83d\udc9f',
  1554. 'heart_eyes':'\ud83d\ude0d',
  1555. 'heart_eyes_cat':'\ud83d\ude3b',
  1556. 'heartbeat':'\ud83d\udc93',
  1557. 'heartpulse':'\ud83d\udc97',
  1558. 'hearts':'\u2665\ufe0f',
  1559. 'heavy_check_mark':'\u2714\ufe0f',
  1560. 'heavy_division_sign':'\u2797',
  1561. 'heavy_dollar_sign':'\ud83d\udcb2',
  1562. 'heavy_heart_exclamation':'\u2763\ufe0f',
  1563. 'heavy_minus_sign':'\u2796',
  1564. 'heavy_multiplication_x':'\u2716\ufe0f',
  1565. 'heavy_plus_sign':'\u2795',
  1566. 'helicopter':'\ud83d\ude81',
  1567. 'herb':'\ud83c\udf3f',
  1568. 'hibiscus':'\ud83c\udf3a',
  1569. 'high_brightness':'\ud83d\udd06',
  1570. 'high_heel':'\ud83d\udc60',
  1571. 'hocho':'\ud83d\udd2a',
  1572. 'hole':'\ud83d\udd73',
  1573. 'honey_pot':'\ud83c\udf6f',
  1574. 'horse':'\ud83d\udc34',
  1575. 'horse_racing':'\ud83c\udfc7',
  1576. 'hospital':'\ud83c\udfe5',
  1577. 'hot_pepper':'\ud83c\udf36',
  1578. 'hotdog':'\ud83c\udf2d',
  1579. 'hotel':'\ud83c\udfe8',
  1580. 'hotsprings':'\u2668\ufe0f',
  1581. 'hourglass':'\u231b\ufe0f',
  1582. 'hourglass_flowing_sand':'\u23f3',
  1583. 'house':'\ud83c\udfe0',
  1584. 'house_with_garden':'\ud83c\udfe1',
  1585. 'houses':'\ud83c\udfd8',
  1586. 'hugs':'\ud83e\udd17',
  1587. 'hushed':'\ud83d\ude2f',
  1588. 'ice_cream':'\ud83c\udf68',
  1589. 'ice_hockey':'\ud83c\udfd2',
  1590. 'ice_skate':'\u26f8',
  1591. 'icecream':'\ud83c\udf66',
  1592. 'id':'\ud83c\udd94',
  1593. 'ideograph_advantage':'\ud83c\ude50',
  1594. 'imp':'\ud83d\udc7f',
  1595. 'inbox_tray':'\ud83d\udce5',
  1596. 'incoming_envelope':'\ud83d\udce8',
  1597. 'tipping_hand_woman':'\ud83d\udc81',
  1598. 'information_source':'\u2139\ufe0f',
  1599. 'innocent':'\ud83d\ude07',
  1600. 'interrobang':'\u2049\ufe0f',
  1601. 'iphone':'\ud83d\udcf1',
  1602. 'izakaya_lantern':'\ud83c\udfee',
  1603. 'jack_o_lantern':'\ud83c\udf83',
  1604. 'japan':'\ud83d\uddfe',
  1605. 'japanese_castle':'\ud83c\udfef',
  1606. 'japanese_goblin':'\ud83d\udc7a',
  1607. 'japanese_ogre':'\ud83d\udc79',
  1608. 'jeans':'\ud83d\udc56',
  1609. 'joy':'\ud83d\ude02',
  1610. 'joy_cat':'\ud83d\ude39',
  1611. 'joystick':'\ud83d\udd79',
  1612. 'kaaba':'\ud83d\udd4b',
  1613. 'key':'\ud83d\udd11',
  1614. 'keyboard':'\u2328\ufe0f',
  1615. 'keycap_ten':'\ud83d\udd1f',
  1616. 'kick_scooter':'\ud83d\udef4',
  1617. 'kimono':'\ud83d\udc58',
  1618. 'kiss':'\ud83d\udc8b',
  1619. 'kissing':'\ud83d\ude17',
  1620. 'kissing_cat':'\ud83d\ude3d',
  1621. 'kissing_closed_eyes':'\ud83d\ude1a',
  1622. 'kissing_heart':'\ud83d\ude18',
  1623. 'kissing_smiling_eyes':'\ud83d\ude19',
  1624. 'kiwi_fruit':'\ud83e\udd5d',
  1625. 'koala':'\ud83d\udc28',
  1626. 'koko':'\ud83c\ude01',
  1627. 'label':'\ud83c\udff7',
  1628. 'large_blue_circle':'\ud83d\udd35',
  1629. 'large_blue_diamond':'\ud83d\udd37',
  1630. 'large_orange_diamond':'\ud83d\udd36',
  1631. 'last_quarter_moon':'\ud83c\udf17',
  1632. 'last_quarter_moon_with_face':'\ud83c\udf1c',
  1633. 'latin_cross':'\u271d\ufe0f',
  1634. 'laughing':'\ud83d\ude06',
  1635. 'leaves':'\ud83c\udf43',
  1636. 'ledger':'\ud83d\udcd2',
  1637. 'left_luggage':'\ud83d\udec5',
  1638. 'left_right_arrow':'\u2194\ufe0f',
  1639. 'leftwards_arrow_with_hook':'\u21a9\ufe0f',
  1640. 'lemon':'\ud83c\udf4b',
  1641. 'leo':'\u264c\ufe0f',
  1642. 'leopard':'\ud83d\udc06',
  1643. 'level_slider':'\ud83c\udf9a',
  1644. 'libra':'\u264e\ufe0f',
  1645. 'light_rail':'\ud83d\ude88',
  1646. 'link':'\ud83d\udd17',
  1647. 'lion':'\ud83e\udd81',
  1648. 'lips':'\ud83d\udc44',
  1649. 'lipstick':'\ud83d\udc84',
  1650. 'lizard':'\ud83e\udd8e',
  1651. 'lock':'\ud83d\udd12',
  1652. 'lock_with_ink_pen':'\ud83d\udd0f',
  1653. 'lollipop':'\ud83c\udf6d',
  1654. 'loop':'\u27bf',
  1655. 'loud_sound':'\ud83d\udd0a',
  1656. 'loudspeaker':'\ud83d\udce2',
  1657. 'love_hotel':'\ud83c\udfe9',
  1658. 'love_letter':'\ud83d\udc8c',
  1659. 'low_brightness':'\ud83d\udd05',
  1660. 'lying_face':'\ud83e\udd25',
  1661. 'm':'\u24c2\ufe0f',
  1662. 'mag':'\ud83d\udd0d',
  1663. 'mag_right':'\ud83d\udd0e',
  1664. 'mahjong':'\ud83c\udc04\ufe0f',
  1665. 'mailbox':'\ud83d\udceb',
  1666. 'mailbox_closed':'\ud83d\udcea',
  1667. 'mailbox_with_mail':'\ud83d\udcec',
  1668. 'mailbox_with_no_mail':'\ud83d\udced',
  1669. 'man':'\ud83d\udc68',
  1670. 'man_artist':'\ud83d\udc68&zwj;\ud83c\udfa8',
  1671. 'man_astronaut':'\ud83d\udc68&zwj;\ud83d\ude80',
  1672. 'man_cartwheeling':'\ud83e\udd38&zwj;\u2642\ufe0f',
  1673. 'man_cook':'\ud83d\udc68&zwj;\ud83c\udf73',
  1674. 'man_dancing':'\ud83d\udd7a',
  1675. 'man_facepalming':'\ud83e\udd26&zwj;\u2642\ufe0f',
  1676. 'man_factory_worker':'\ud83d\udc68&zwj;\ud83c\udfed',
  1677. 'man_farmer':'\ud83d\udc68&zwj;\ud83c\udf3e',
  1678. 'man_firefighter':'\ud83d\udc68&zwj;\ud83d\ude92',
  1679. 'man_health_worker':'\ud83d\udc68&zwj;\u2695\ufe0f',
  1680. 'man_in_tuxedo':'\ud83e\udd35',
  1681. 'man_judge':'\ud83d\udc68&zwj;\u2696\ufe0f',
  1682. 'man_juggling':'\ud83e\udd39&zwj;\u2642\ufe0f',
  1683. 'man_mechanic':'\ud83d\udc68&zwj;\ud83d\udd27',
  1684. 'man_office_worker':'\ud83d\udc68&zwj;\ud83d\udcbc',
  1685. 'man_pilot':'\ud83d\udc68&zwj;\u2708\ufe0f',
  1686. 'man_playing_handball':'\ud83e\udd3e&zwj;\u2642\ufe0f',
  1687. 'man_playing_water_polo':'\ud83e\udd3d&zwj;\u2642\ufe0f',
  1688. 'man_scientist':'\ud83d\udc68&zwj;\ud83d\udd2c',
  1689. 'man_shrugging':'\ud83e\udd37&zwj;\u2642\ufe0f',
  1690. 'man_singer':'\ud83d\udc68&zwj;\ud83c\udfa4',
  1691. 'man_student':'\ud83d\udc68&zwj;\ud83c\udf93',
  1692. 'man_teacher':'\ud83d\udc68&zwj;\ud83c\udfeb',
  1693. 'man_technologist':'\ud83d\udc68&zwj;\ud83d\udcbb',
  1694. 'man_with_gua_pi_mao':'\ud83d\udc72',
  1695. 'man_with_turban':'\ud83d\udc73',
  1696. 'tangerine':'\ud83c\udf4a',
  1697. 'mans_shoe':'\ud83d\udc5e',
  1698. 'mantelpiece_clock':'\ud83d\udd70',
  1699. 'maple_leaf':'\ud83c\udf41',
  1700. 'martial_arts_uniform':'\ud83e\udd4b',
  1701. 'mask':'\ud83d\ude37',
  1702. 'massage_woman':'\ud83d\udc86',
  1703. 'massage_man':'\ud83d\udc86&zwj;\u2642\ufe0f',
  1704. 'meat_on_bone':'\ud83c\udf56',
  1705. 'medal_military':'\ud83c\udf96',
  1706. 'medal_sports':'\ud83c\udfc5',
  1707. 'mega':'\ud83d\udce3',
  1708. 'melon':'\ud83c\udf48',
  1709. 'memo':'\ud83d\udcdd',
  1710. 'men_wrestling':'\ud83e\udd3c&zwj;\u2642\ufe0f',
  1711. 'menorah':'\ud83d\udd4e',
  1712. 'mens':'\ud83d\udeb9',
  1713. 'metal':'\ud83e\udd18',
  1714. 'metro':'\ud83d\ude87',
  1715. 'microphone':'\ud83c\udfa4',
  1716. 'microscope':'\ud83d\udd2c',
  1717. 'milk_glass':'\ud83e\udd5b',
  1718. 'milky_way':'\ud83c\udf0c',
  1719. 'minibus':'\ud83d\ude90',
  1720. 'minidisc':'\ud83d\udcbd',
  1721. 'mobile_phone_off':'\ud83d\udcf4',
  1722. 'money_mouth_face':'\ud83e\udd11',
  1723. 'money_with_wings':'\ud83d\udcb8',
  1724. 'moneybag':'\ud83d\udcb0',
  1725. 'monkey':'\ud83d\udc12',
  1726. 'monkey_face':'\ud83d\udc35',
  1727. 'monorail':'\ud83d\ude9d',
  1728. 'moon':'\ud83c\udf14',
  1729. 'mortar_board':'\ud83c\udf93',
  1730. 'mosque':'\ud83d\udd4c',
  1731. 'motor_boat':'\ud83d\udee5',
  1732. 'motor_scooter':'\ud83d\udef5',
  1733. 'motorcycle':'\ud83c\udfcd',
  1734. 'motorway':'\ud83d\udee3',
  1735. 'mount_fuji':'\ud83d\uddfb',
  1736. 'mountain':'\u26f0',
  1737. 'mountain_biking_man':'\ud83d\udeb5',
  1738. 'mountain_biking_woman':'\ud83d\udeb5&zwj;\u2640\ufe0f',
  1739. 'mountain_cableway':'\ud83d\udea0',
  1740. 'mountain_railway':'\ud83d\ude9e',
  1741. 'mountain_snow':'\ud83c\udfd4',
  1742. 'mouse':'\ud83d\udc2d',
  1743. 'mouse2':'\ud83d\udc01',
  1744. 'movie_camera':'\ud83c\udfa5',
  1745. 'moyai':'\ud83d\uddff',
  1746. 'mrs_claus':'\ud83e\udd36',
  1747. 'muscle':'\ud83d\udcaa',
  1748. 'mushroom':'\ud83c\udf44',
  1749. 'musical_keyboard':'\ud83c\udfb9',
  1750. 'musical_note':'\ud83c\udfb5',
  1751. 'musical_score':'\ud83c\udfbc',
  1752. 'mute':'\ud83d\udd07',
  1753. 'nail_care':'\ud83d\udc85',
  1754. 'name_badge':'\ud83d\udcdb',
  1755. 'national_park':'\ud83c\udfde',
  1756. 'nauseated_face':'\ud83e\udd22',
  1757. 'necktie':'\ud83d\udc54',
  1758. 'negative_squared_cross_mark':'\u274e',
  1759. 'nerd_face':'\ud83e\udd13',
  1760. 'neutral_face':'\ud83d\ude10',
  1761. 'new':'\ud83c\udd95',
  1762. 'new_moon':'\ud83c\udf11',
  1763. 'new_moon_with_face':'\ud83c\udf1a',
  1764. 'newspaper':'\ud83d\udcf0',
  1765. 'newspaper_roll':'\ud83d\uddde',
  1766. 'next_track_button':'\u23ed',
  1767. 'ng':'\ud83c\udd96',
  1768. 'no_good_man':'\ud83d\ude45&zwj;\u2642\ufe0f',
  1769. 'no_good_woman':'\ud83d\ude45',
  1770. 'night_with_stars':'\ud83c\udf03',
  1771. 'no_bell':'\ud83d\udd15',
  1772. 'no_bicycles':'\ud83d\udeb3',
  1773. 'no_entry':'\u26d4\ufe0f',
  1774. 'no_entry_sign':'\ud83d\udeab',
  1775. 'no_mobile_phones':'\ud83d\udcf5',
  1776. 'no_mouth':'\ud83d\ude36',
  1777. 'no_pedestrians':'\ud83d\udeb7',
  1778. 'no_smoking':'\ud83d\udead',
  1779. 'non-potable_water':'\ud83d\udeb1',
  1780. 'nose':'\ud83d\udc43',
  1781. 'notebook':'\ud83d\udcd3',
  1782. 'notebook_with_decorative_cover':'\ud83d\udcd4',
  1783. 'notes':'\ud83c\udfb6',
  1784. 'nut_and_bolt':'\ud83d\udd29',
  1785. 'o':'\u2b55\ufe0f',
  1786. 'o2':'\ud83c\udd7e\ufe0f',
  1787. 'ocean':'\ud83c\udf0a',
  1788. 'octopus':'\ud83d\udc19',
  1789. 'oden':'\ud83c\udf62',
  1790. 'office':'\ud83c\udfe2',
  1791. 'oil_drum':'\ud83d\udee2',
  1792. 'ok':'\ud83c\udd97',
  1793. 'ok_hand':'\ud83d\udc4c',
  1794. 'ok_man':'\ud83d\ude46&zwj;\u2642\ufe0f',
  1795. 'ok_woman':'\ud83d\ude46',
  1796. 'old_key':'\ud83d\udddd',
  1797. 'older_man':'\ud83d\udc74',
  1798. 'older_woman':'\ud83d\udc75',
  1799. 'om':'\ud83d\udd49',
  1800. 'on':'\ud83d\udd1b',
  1801. 'oncoming_automobile':'\ud83d\ude98',
  1802. 'oncoming_bus':'\ud83d\ude8d',
  1803. 'oncoming_police_car':'\ud83d\ude94',
  1804. 'oncoming_taxi':'\ud83d\ude96',
  1805. 'open_file_folder':'\ud83d\udcc2',
  1806. 'open_hands':'\ud83d\udc50',
  1807. 'open_mouth':'\ud83d\ude2e',
  1808. 'open_umbrella':'\u2602\ufe0f',
  1809. 'ophiuchus':'\u26ce',
  1810. 'orange_book':'\ud83d\udcd9',
  1811. 'orthodox_cross':'\u2626\ufe0f',
  1812. 'outbox_tray':'\ud83d\udce4',
  1813. 'owl':'\ud83e\udd89',
  1814. 'ox':'\ud83d\udc02',
  1815. 'package':'\ud83d\udce6',
  1816. 'page_facing_up':'\ud83d\udcc4',
  1817. 'page_with_curl':'\ud83d\udcc3',
  1818. 'pager':'\ud83d\udcdf',
  1819. 'paintbrush':'\ud83d\udd8c',
  1820. 'palm_tree':'\ud83c\udf34',
  1821. 'pancakes':'\ud83e\udd5e',
  1822. 'panda_face':'\ud83d\udc3c',
  1823. 'paperclip':'\ud83d\udcce',
  1824. 'paperclips':'\ud83d\udd87',
  1825. 'parasol_on_ground':'\u26f1',
  1826. 'parking':'\ud83c\udd7f\ufe0f',
  1827. 'part_alternation_mark':'\u303d\ufe0f',
  1828. 'partly_sunny':'\u26c5\ufe0f',
  1829. 'passenger_ship':'\ud83d\udef3',
  1830. 'passport_control':'\ud83d\udec2',
  1831. 'pause_button':'\u23f8',
  1832. 'peace_symbol':'\u262e\ufe0f',
  1833. 'peach':'\ud83c\udf51',
  1834. 'peanuts':'\ud83e\udd5c',
  1835. 'pear':'\ud83c\udf50',
  1836. 'pen':'\ud83d\udd8a',
  1837. 'pencil2':'\u270f\ufe0f',
  1838. 'penguin':'\ud83d\udc27',
  1839. 'pensive':'\ud83d\ude14',
  1840. 'performing_arts':'\ud83c\udfad',
  1841. 'persevere':'\ud83d\ude23',
  1842. 'person_fencing':'\ud83e\udd3a',
  1843. 'pouting_woman':'\ud83d\ude4e',
  1844. 'phone':'\u260e\ufe0f',
  1845. 'pick':'\u26cf',
  1846. 'pig':'\ud83d\udc37',
  1847. 'pig2':'\ud83d\udc16',
  1848. 'pig_nose':'\ud83d\udc3d',
  1849. 'pill':'\ud83d\udc8a',
  1850. 'pineapple':'\ud83c\udf4d',
  1851. 'ping_pong':'\ud83c\udfd3',
  1852. 'pisces':'\u2653\ufe0f',
  1853. 'pizza':'\ud83c\udf55',
  1854. 'place_of_worship':'\ud83d\uded0',
  1855. 'plate_with_cutlery':'\ud83c\udf7d',
  1856. 'play_or_pause_button':'\u23ef',
  1857. 'point_down':'\ud83d\udc47',
  1858. 'point_left':'\ud83d\udc48',
  1859. 'point_right':'\ud83d\udc49',
  1860. 'point_up':'\u261d\ufe0f',
  1861. 'point_up_2':'\ud83d\udc46',
  1862. 'police_car':'\ud83d\ude93',
  1863. 'policewoman':'\ud83d\udc6e&zwj;\u2640\ufe0f',
  1864. 'poodle':'\ud83d\udc29',
  1865. 'popcorn':'\ud83c\udf7f',
  1866. 'post_office':'\ud83c\udfe3',
  1867. 'postal_horn':'\ud83d\udcef',
  1868. 'postbox':'\ud83d\udcee',
  1869. 'potable_water':'\ud83d\udeb0',
  1870. 'potato':'\ud83e\udd54',
  1871. 'pouch':'\ud83d\udc5d',
  1872. 'poultry_leg':'\ud83c\udf57',
  1873. 'pound':'\ud83d\udcb7',
  1874. 'rage':'\ud83d\ude21',
  1875. 'pouting_cat':'\ud83d\ude3e',
  1876. 'pouting_man':'\ud83d\ude4e&zwj;\u2642\ufe0f',
  1877. 'pray':'\ud83d\ude4f',
  1878. 'prayer_beads':'\ud83d\udcff',
  1879. 'pregnant_woman':'\ud83e\udd30',
  1880. 'previous_track_button':'\u23ee',
  1881. 'prince':'\ud83e\udd34',
  1882. 'princess':'\ud83d\udc78',
  1883. 'printer':'\ud83d\udda8',
  1884. 'purple_heart':'\ud83d\udc9c',
  1885. 'purse':'\ud83d\udc5b',
  1886. 'pushpin':'\ud83d\udccc',
  1887. 'put_litter_in_its_place':'\ud83d\udeae',
  1888. 'question':'\u2753',
  1889. 'rabbit':'\ud83d\udc30',
  1890. 'rabbit2':'\ud83d\udc07',
  1891. 'racehorse':'\ud83d\udc0e',
  1892. 'racing_car':'\ud83c\udfce',
  1893. 'radio':'\ud83d\udcfb',
  1894. 'radio_button':'\ud83d\udd18',
  1895. 'radioactive':'\u2622\ufe0f',
  1896. 'railway_car':'\ud83d\ude83',
  1897. 'railway_track':'\ud83d\udee4',
  1898. 'rainbow':'\ud83c\udf08',
  1899. 'rainbow_flag':'\ud83c\udff3\ufe0f&zwj;\ud83c\udf08',
  1900. 'raised_back_of_hand':'\ud83e\udd1a',
  1901. 'raised_hand_with_fingers_splayed':'\ud83d\udd90',
  1902. 'raised_hands':'\ud83d\ude4c',
  1903. 'raising_hand_woman':'\ud83d\ude4b',
  1904. 'raising_hand_man':'\ud83d\ude4b&zwj;\u2642\ufe0f',
  1905. 'ram':'\ud83d\udc0f',
  1906. 'ramen':'\ud83c\udf5c',
  1907. 'rat':'\ud83d\udc00',
  1908. 'record_button':'\u23fa',
  1909. 'recycle':'\u267b\ufe0f',
  1910. 'red_circle':'\ud83d\udd34',
  1911. 'registered':'\u00ae\ufe0f',
  1912. 'relaxed':'\u263a\ufe0f',
  1913. 'relieved':'\ud83d\ude0c',
  1914. 'reminder_ribbon':'\ud83c\udf97',
  1915. 'repeat':'\ud83d\udd01',
  1916. 'repeat_one':'\ud83d\udd02',
  1917. 'rescue_worker_helmet':'\u26d1',
  1918. 'restroom':'\ud83d\udebb',
  1919. 'revolving_hearts':'\ud83d\udc9e',
  1920. 'rewind':'\u23ea',
  1921. 'rhinoceros':'\ud83e\udd8f',
  1922. 'ribbon':'\ud83c\udf80',
  1923. 'rice':'\ud83c\udf5a',
  1924. 'rice_ball':'\ud83c\udf59',
  1925. 'rice_cracker':'\ud83c\udf58',
  1926. 'rice_scene':'\ud83c\udf91',
  1927. 'right_anger_bubble':'\ud83d\uddef',
  1928. 'ring':'\ud83d\udc8d',
  1929. 'robot':'\ud83e\udd16',
  1930. 'rocket':'\ud83d\ude80',
  1931. 'rofl':'\ud83e\udd23',
  1932. 'roll_eyes':'\ud83d\ude44',
  1933. 'roller_coaster':'\ud83c\udfa2',
  1934. 'rooster':'\ud83d\udc13',
  1935. 'rose':'\ud83c\udf39',
  1936. 'rosette':'\ud83c\udff5',
  1937. 'rotating_light':'\ud83d\udea8',
  1938. 'round_pushpin':'\ud83d\udccd',
  1939. 'rowing_man':'\ud83d\udea3',
  1940. 'rowing_woman':'\ud83d\udea3&zwj;\u2640\ufe0f',
  1941. 'rugby_football':'\ud83c\udfc9',
  1942. 'running_man':'\ud83c\udfc3',
  1943. 'running_shirt_with_sash':'\ud83c\udfbd',
  1944. 'running_woman':'\ud83c\udfc3&zwj;\u2640\ufe0f',
  1945. 'sa':'\ud83c\ude02\ufe0f',
  1946. 'sagittarius':'\u2650\ufe0f',
  1947. 'sake':'\ud83c\udf76',
  1948. 'sandal':'\ud83d\udc61',
  1949. 'santa':'\ud83c\udf85',
  1950. 'satellite':'\ud83d\udce1',
  1951. 'saxophone':'\ud83c\udfb7',
  1952. 'school':'\ud83c\udfeb',
  1953. 'school_satchel':'\ud83c\udf92',
  1954. 'scissors':'\u2702\ufe0f',
  1955. 'scorpion':'\ud83e\udd82',
  1956. 'scorpius':'\u264f\ufe0f',
  1957. 'scream':'\ud83d\ude31',
  1958. 'scream_cat':'\ud83d\ude40',
  1959. 'scroll':'\ud83d\udcdc',
  1960. 'seat':'\ud83d\udcba',
  1961. 'secret':'\u3299\ufe0f',
  1962. 'see_no_evil':'\ud83d\ude48',
  1963. 'seedling':'\ud83c\udf31',
  1964. 'selfie':'\ud83e\udd33',
  1965. 'shallow_pan_of_food':'\ud83e\udd58',
  1966. 'shamrock':'\u2618\ufe0f',
  1967. 'shark':'\ud83e\udd88',
  1968. 'shaved_ice':'\ud83c\udf67',
  1969. 'sheep':'\ud83d\udc11',
  1970. 'shell':'\ud83d\udc1a',
  1971. 'shield':'\ud83d\udee1',
  1972. 'shinto_shrine':'\u26e9',
  1973. 'ship':'\ud83d\udea2',
  1974. 'shirt':'\ud83d\udc55',
  1975. 'shopping':'\ud83d\udecd',
  1976. 'shopping_cart':'\ud83d\uded2',
  1977. 'shower':'\ud83d\udebf',
  1978. 'shrimp':'\ud83e\udd90',
  1979. 'signal_strength':'\ud83d\udcf6',
  1980. 'six_pointed_star':'\ud83d\udd2f',
  1981. 'ski':'\ud83c\udfbf',
  1982. 'skier':'\u26f7',
  1983. 'skull':'\ud83d\udc80',
  1984. 'skull_and_crossbones':'\u2620\ufe0f',
  1985. 'sleeping':'\ud83d\ude34',
  1986. 'sleeping_bed':'\ud83d\udecc',
  1987. 'sleepy':'\ud83d\ude2a',
  1988. 'slightly_frowning_face':'\ud83d\ude41',
  1989. 'slightly_smiling_face':'\ud83d\ude42',
  1990. 'slot_machine':'\ud83c\udfb0',
  1991. 'small_airplane':'\ud83d\udee9',
  1992. 'small_blue_diamond':'\ud83d\udd39',
  1993. 'small_orange_diamond':'\ud83d\udd38',
  1994. 'small_red_triangle':'\ud83d\udd3a',
  1995. 'small_red_triangle_down':'\ud83d\udd3b',
  1996. 'smile':'\ud83d\ude04',
  1997. 'smile_cat':'\ud83d\ude38',
  1998. 'smiley':'\ud83d\ude03',
  1999. 'smiley_cat':'\ud83d\ude3a',
  2000. 'smiling_imp':'\ud83d\ude08',
  2001. 'smirk':'\ud83d\ude0f',
  2002. 'smirk_cat':'\ud83d\ude3c',
  2003. 'smoking':'\ud83d\udeac',
  2004. 'snail':'\ud83d\udc0c',
  2005. 'snake':'\ud83d\udc0d',
  2006. 'sneezing_face':'\ud83e\udd27',
  2007. 'snowboarder':'\ud83c\udfc2',
  2008. 'snowflake':'\u2744\ufe0f',
  2009. 'snowman':'\u26c4\ufe0f',
  2010. 'snowman_with_snow':'\u2603\ufe0f',
  2011. 'sob':'\ud83d\ude2d',
  2012. 'soccer':'\u26bd\ufe0f',
  2013. 'soon':'\ud83d\udd1c',
  2014. 'sos':'\ud83c\udd98',
  2015. 'sound':'\ud83d\udd09',
  2016. 'space_invader':'\ud83d\udc7e',
  2017. 'spades':'\u2660\ufe0f',
  2018. 'spaghetti':'\ud83c\udf5d',
  2019. 'sparkle':'\u2747\ufe0f',
  2020. 'sparkler':'\ud83c\udf87',
  2021. 'sparkles':'\u2728',
  2022. 'sparkling_heart':'\ud83d\udc96',
  2023. 'speak_no_evil':'\ud83d\ude4a',
  2024. 'speaker':'\ud83d\udd08',
  2025. 'speaking_head':'\ud83d\udde3',
  2026. 'speech_balloon':'\ud83d\udcac',
  2027. 'speedboat':'\ud83d\udea4',
  2028. 'spider':'\ud83d\udd77',
  2029. 'spider_web':'\ud83d\udd78',
  2030. 'spiral_calendar':'\ud83d\uddd3',
  2031. 'spiral_notepad':'\ud83d\uddd2',
  2032. 'spoon':'\ud83e\udd44',
  2033. 'squid':'\ud83e\udd91',
  2034. 'stadium':'\ud83c\udfdf',
  2035. 'star':'\u2b50\ufe0f',
  2036. 'star2':'\ud83c\udf1f',
  2037. 'star_and_crescent':'\u262a\ufe0f',
  2038. 'star_of_david':'\u2721\ufe0f',
  2039. 'stars':'\ud83c\udf20',
  2040. 'station':'\ud83d\ude89',
  2041. 'statue_of_liberty':'\ud83d\uddfd',
  2042. 'steam_locomotive':'\ud83d\ude82',
  2043. 'stew':'\ud83c\udf72',
  2044. 'stop_button':'\u23f9',
  2045. 'stop_sign':'\ud83d\uded1',
  2046. 'stopwatch':'\u23f1',
  2047. 'straight_ruler':'\ud83d\udccf',
  2048. 'strawberry':'\ud83c\udf53',
  2049. 'stuck_out_tongue':'\ud83d\ude1b',
  2050. 'stuck_out_tongue_closed_eyes':'\ud83d\ude1d',
  2051. 'stuck_out_tongue_winking_eye':'\ud83d\ude1c',
  2052. 'studio_microphone':'\ud83c\udf99',
  2053. 'stuffed_flatbread':'\ud83e\udd59',
  2054. 'sun_behind_large_cloud':'\ud83c\udf25',
  2055. 'sun_behind_rain_cloud':'\ud83c\udf26',
  2056. 'sun_behind_small_cloud':'\ud83c\udf24',
  2057. 'sun_with_face':'\ud83c\udf1e',
  2058. 'sunflower':'\ud83c\udf3b',
  2059. 'sunglasses':'\ud83d\ude0e',
  2060. 'sunny':'\u2600\ufe0f',
  2061. 'sunrise':'\ud83c\udf05',
  2062. 'sunrise_over_mountains':'\ud83c\udf04',
  2063. 'surfing_man':'\ud83c\udfc4',
  2064. 'surfing_woman':'\ud83c\udfc4&zwj;\u2640\ufe0f',
  2065. 'sushi':'\ud83c\udf63',
  2066. 'suspension_railway':'\ud83d\ude9f',
  2067. 'sweat':'\ud83d\ude13',
  2068. 'sweat_drops':'\ud83d\udca6',
  2069. 'sweat_smile':'\ud83d\ude05',
  2070. 'sweet_potato':'\ud83c\udf60',
  2071. 'swimming_man':'\ud83c\udfca',
  2072. 'swimming_woman':'\ud83c\udfca&zwj;\u2640\ufe0f',
  2073. 'symbols':'\ud83d\udd23',
  2074. 'synagogue':'\ud83d\udd4d',
  2075. 'syringe':'\ud83d\udc89',
  2076. 'taco':'\ud83c\udf2e',
  2077. 'tada':'\ud83c\udf89',
  2078. 'tanabata_tree':'\ud83c\udf8b',
  2079. 'taurus':'\u2649\ufe0f',
  2080. 'taxi':'\ud83d\ude95',
  2081. 'tea':'\ud83c\udf75',
  2082. 'telephone_receiver':'\ud83d\udcde',
  2083. 'telescope':'\ud83d\udd2d',
  2084. 'tennis':'\ud83c\udfbe',
  2085. 'tent':'\u26fa\ufe0f',
  2086. 'thermometer':'\ud83c\udf21',
  2087. 'thinking':'\ud83e\udd14',
  2088. 'thought_balloon':'\ud83d\udcad',
  2089. 'ticket':'\ud83c\udfab',
  2090. 'tickets':'\ud83c\udf9f',
  2091. 'tiger':'\ud83d\udc2f',
  2092. 'tiger2':'\ud83d\udc05',
  2093. 'timer_clock':'\u23f2',
  2094. 'tipping_hand_man':'\ud83d\udc81&zwj;\u2642\ufe0f',
  2095. 'tired_face':'\ud83d\ude2b',
  2096. 'tm':'\u2122\ufe0f',
  2097. 'toilet':'\ud83d\udebd',
  2098. 'tokyo_tower':'\ud83d\uddfc',
  2099. 'tomato':'\ud83c\udf45',
  2100. 'tongue':'\ud83d\udc45',
  2101. 'top':'\ud83d\udd1d',
  2102. 'tophat':'\ud83c\udfa9',
  2103. 'tornado':'\ud83c\udf2a',
  2104. 'trackball':'\ud83d\uddb2',
  2105. 'tractor':'\ud83d\ude9c',
  2106. 'traffic_light':'\ud83d\udea5',
  2107. 'train':'\ud83d\ude8b',
  2108. 'train2':'\ud83d\ude86',
  2109. 'tram':'\ud83d\ude8a',
  2110. 'triangular_flag_on_post':'\ud83d\udea9',
  2111. 'triangular_ruler':'\ud83d\udcd0',
  2112. 'trident':'\ud83d\udd31',
  2113. 'triumph':'\ud83d\ude24',
  2114. 'trolleybus':'\ud83d\ude8e',
  2115. 'trophy':'\ud83c\udfc6',
  2116. 'tropical_drink':'\ud83c\udf79',
  2117. 'tropical_fish':'\ud83d\udc20',
  2118. 'truck':'\ud83d\ude9a',
  2119. 'trumpet':'\ud83c\udfba',
  2120. 'tulip':'\ud83c\udf37',
  2121. 'tumbler_glass':'\ud83e\udd43',
  2122. 'turkey':'\ud83e\udd83',
  2123. 'turtle':'\ud83d\udc22',
  2124. 'tv':'\ud83d\udcfa',
  2125. 'twisted_rightwards_arrows':'\ud83d\udd00',
  2126. 'two_hearts':'\ud83d\udc95',
  2127. 'two_men_holding_hands':'\ud83d\udc6c',
  2128. 'two_women_holding_hands':'\ud83d\udc6d',
  2129. 'u5272':'\ud83c\ude39',
  2130. 'u5408':'\ud83c\ude34',
  2131. 'u55b6':'\ud83c\ude3a',
  2132. 'u6307':'\ud83c\ude2f\ufe0f',
  2133. 'u6708':'\ud83c\ude37\ufe0f',
  2134. 'u6709':'\ud83c\ude36',
  2135. 'u6e80':'\ud83c\ude35',
  2136. 'u7121':'\ud83c\ude1a\ufe0f',
  2137. 'u7533':'\ud83c\ude38',
  2138. 'u7981':'\ud83c\ude32',
  2139. 'u7a7a':'\ud83c\ude33',
  2140. 'umbrella':'\u2614\ufe0f',
  2141. 'unamused':'\ud83d\ude12',
  2142. 'underage':'\ud83d\udd1e',
  2143. 'unicorn':'\ud83e\udd84',
  2144. 'unlock':'\ud83d\udd13',
  2145. 'up':'\ud83c\udd99',
  2146. 'upside_down_face':'\ud83d\ude43',
  2147. 'v':'\u270c\ufe0f',
  2148. 'vertical_traffic_light':'\ud83d\udea6',
  2149. 'vhs':'\ud83d\udcfc',
  2150. 'vibration_mode':'\ud83d\udcf3',
  2151. 'video_camera':'\ud83d\udcf9',
  2152. 'video_game':'\ud83c\udfae',
  2153. 'violin':'\ud83c\udfbb',
  2154. 'virgo':'\u264d\ufe0f',
  2155. 'volcano':'\ud83c\udf0b',
  2156. 'volleyball':'\ud83c\udfd0',
  2157. 'vs':'\ud83c\udd9a',
  2158. 'vulcan_salute':'\ud83d\udd96',
  2159. 'walking_man':'\ud83d\udeb6',
  2160. 'walking_woman':'\ud83d\udeb6&zwj;\u2640\ufe0f',
  2161. 'waning_crescent_moon':'\ud83c\udf18',
  2162. 'waning_gibbous_moon':'\ud83c\udf16',
  2163. 'warning':'\u26a0\ufe0f',
  2164. 'wastebasket':'\ud83d\uddd1',
  2165. 'watch':'\u231a\ufe0f',
  2166. 'water_buffalo':'\ud83d\udc03',
  2167. 'watermelon':'\ud83c\udf49',
  2168. 'wave':'\ud83d\udc4b',
  2169. 'wavy_dash':'\u3030\ufe0f',
  2170. 'waxing_crescent_moon':'\ud83c\udf12',
  2171. 'wc':'\ud83d\udebe',
  2172. 'weary':'\ud83d\ude29',
  2173. 'wedding':'\ud83d\udc92',
  2174. 'weight_lifting_man':'\ud83c\udfcb\ufe0f',
  2175. 'weight_lifting_woman':'\ud83c\udfcb\ufe0f&zwj;\u2640\ufe0f',
  2176. 'whale':'\ud83d\udc33',
  2177. 'whale2':'\ud83d\udc0b',
  2178. 'wheel_of_dharma':'\u2638\ufe0f',
  2179. 'wheelchair':'\u267f\ufe0f',
  2180. 'white_check_mark':'\u2705',
  2181. 'white_circle':'\u26aa\ufe0f',
  2182. 'white_flag':'\ud83c\udff3\ufe0f',
  2183. 'white_flower':'\ud83d\udcae',
  2184. 'white_large_square':'\u2b1c\ufe0f',
  2185. 'white_medium_small_square':'\u25fd\ufe0f',
  2186. 'white_medium_square':'\u25fb\ufe0f',
  2187. 'white_small_square':'\u25ab\ufe0f',
  2188. 'white_square_button':'\ud83d\udd33',
  2189. 'wilted_flower':'\ud83e\udd40',
  2190. 'wind_chime':'\ud83c\udf90',
  2191. 'wind_face':'\ud83c\udf2c',
  2192. 'wine_glass':'\ud83c\udf77',
  2193. 'wink':'\ud83d\ude09',
  2194. 'wolf':'\ud83d\udc3a',
  2195. 'woman':'\ud83d\udc69',
  2196. 'woman_artist':'\ud83d\udc69&zwj;\ud83c\udfa8',
  2197. 'woman_astronaut':'\ud83d\udc69&zwj;\ud83d\ude80',
  2198. 'woman_cartwheeling':'\ud83e\udd38&zwj;\u2640\ufe0f',
  2199. 'woman_cook':'\ud83d\udc69&zwj;\ud83c\udf73',
  2200. 'woman_facepalming':'\ud83e\udd26&zwj;\u2640\ufe0f',
  2201. 'woman_factory_worker':'\ud83d\udc69&zwj;\ud83c\udfed',
  2202. 'woman_farmer':'\ud83d\udc69&zwj;\ud83c\udf3e',
  2203. 'woman_firefighter':'\ud83d\udc69&zwj;\ud83d\ude92',
  2204. 'woman_health_worker':'\ud83d\udc69&zwj;\u2695\ufe0f',
  2205. 'woman_judge':'\ud83d\udc69&zwj;\u2696\ufe0f',
  2206. 'woman_juggling':'\ud83e\udd39&zwj;\u2640\ufe0f',
  2207. 'woman_mechanic':'\ud83d\udc69&zwj;\ud83d\udd27',
  2208. 'woman_office_worker':'\ud83d\udc69&zwj;\ud83d\udcbc',
  2209. 'woman_pilot':'\ud83d\udc69&zwj;\u2708\ufe0f',
  2210. 'woman_playing_handball':'\ud83e\udd3e&zwj;\u2640\ufe0f',
  2211. 'woman_playing_water_polo':'\ud83e\udd3d&zwj;\u2640\ufe0f',
  2212. 'woman_scientist':'\ud83d\udc69&zwj;\ud83d\udd2c',
  2213. 'woman_shrugging':'\ud83e\udd37&zwj;\u2640\ufe0f',
  2214. 'woman_singer':'\ud83d\udc69&zwj;\ud83c\udfa4',
  2215. 'woman_student':'\ud83d\udc69&zwj;\ud83c\udf93',
  2216. 'woman_teacher':'\ud83d\udc69&zwj;\ud83c\udfeb',
  2217. 'woman_technologist':'\ud83d\udc69&zwj;\ud83d\udcbb',
  2218. 'woman_with_turban':'\ud83d\udc73&zwj;\u2640\ufe0f',
  2219. 'womans_clothes':'\ud83d\udc5a',
  2220. 'womans_hat':'\ud83d\udc52',
  2221. 'women_wrestling':'\ud83e\udd3c&zwj;\u2640\ufe0f',
  2222. 'womens':'\ud83d\udeba',
  2223. 'world_map':'\ud83d\uddfa',
  2224. 'worried':'\ud83d\ude1f',
  2225. 'wrench':'\ud83d\udd27',
  2226. 'writing_hand':'\u270d\ufe0f',
  2227. 'x':'\u274c',
  2228. 'yellow_heart':'\ud83d\udc9b',
  2229. 'yen':'\ud83d\udcb4',
  2230. 'yin_yang':'\u262f\ufe0f',
  2231. 'yum':'\ud83d\ude0b',
  2232. 'zap':'\u26a1\ufe0f',
  2233. 'zipper_mouth_face':'\ud83e\udd10',
  2234. 'zzz':'\ud83d\udca4',
  2235. /* special emojis :P */
  2236. 'octocat': '<img alt=":octocat:" height="20" width="20" align="absmiddle" src="https://assets-cdn.github.com/images/icons/emoji/octocat.png">',
  2237. 'showdown': '<span style="font-family: \'Anonymous Pro\', monospace; text-decoration: underline; text-decoration-style: dashed; text-decoration-color: #3e8b8a;text-underline-position: under;">S</span>'
  2238. };
  2239. /**
  2240. * Created by Estevao on 31-05-2015.
  2241. */
  2242. /**
  2243. * Showdown Converter class
  2244. * @class
  2245. * @param {object} [converterOptions]
  2246. * @returns {Converter}
  2247. */
  2248. showdown.Converter = function (converterOptions) {
  2249. 'use strict';
  2250. var
  2251. /**
  2252. * Options used by this converter
  2253. * @private
  2254. * @type {{}}
  2255. */
  2256. options = {},
  2257. /**
  2258. * Language extensions used by this converter
  2259. * @private
  2260. * @type {Array}
  2261. */
  2262. langExtensions = [],
  2263. /**
  2264. * Output modifiers extensions used by this converter
  2265. * @private
  2266. * @type {Array}
  2267. */
  2268. outputModifiers = [],
  2269. /**
  2270. * Event listeners
  2271. * @private
  2272. * @type {{}}
  2273. */
  2274. listeners = {},
  2275. /**
  2276. * The flavor set in this converter
  2277. */
  2278. setConvFlavor = setFlavor,
  2279. /**
  2280. * Metadata of the document
  2281. * @type {{parsed: {}, raw: string, format: string}}
  2282. */
  2283. metadata = {
  2284. parsed: {},
  2285. raw: '',
  2286. format: ''
  2287. };
  2288. _constructor();
  2289. /**
  2290. * Converter constructor
  2291. * @private
  2292. */
  2293. function _constructor () {
  2294. converterOptions = converterOptions || {};
  2295. for (var gOpt in globalOptions) {
  2296. if (globalOptions.hasOwnProperty(gOpt)) {
  2297. options[gOpt] = globalOptions[gOpt];
  2298. }
  2299. }
  2300. // Merge options
  2301. if (typeof converterOptions === 'object') {
  2302. for (var opt in converterOptions) {
  2303. if (converterOptions.hasOwnProperty(opt)) {
  2304. options[opt] = converterOptions[opt];
  2305. }
  2306. }
  2307. } else {
  2308. throw Error('Converter expects the passed parameter to be an object, but ' + typeof converterOptions +
  2309. ' was passed instead.');
  2310. }
  2311. if (options.extensions) {
  2312. showdown.helper.forEach(options.extensions, _parseExtension);
  2313. }
  2314. }
  2315. /**
  2316. * Parse extension
  2317. * @param {*} ext
  2318. * @param {string} [name='']
  2319. * @private
  2320. */
  2321. function _parseExtension (ext, name) {
  2322. name = name || null;
  2323. // If it's a string, the extension was previously loaded
  2324. if (showdown.helper.isString(ext)) {
  2325. ext = showdown.helper.stdExtName(ext);
  2326. name = ext;
  2327. // LEGACY_SUPPORT CODE
  2328. if (showdown.extensions[ext]) {
  2329. console.warn('DEPRECATION WARNING: ' + ext + ' is an old extension that uses a deprecated loading method.' +
  2330. 'Please inform the developer that the extension should be updated!');
  2331. legacyExtensionLoading(showdown.extensions[ext], ext);
  2332. return;
  2333. // END LEGACY SUPPORT CODE
  2334. } else if (!showdown.helper.isUndefined(extensions[ext])) {
  2335. ext = extensions[ext];
  2336. } else {
  2337. throw Error('Extension "' + ext + '" could not be loaded. It was either not found or is not a valid extension.');
  2338. }
  2339. }
  2340. if (typeof ext === 'function') {
  2341. ext = ext();
  2342. }
  2343. if (!showdown.helper.isArray(ext)) {
  2344. ext = [ext];
  2345. }
  2346. var validExt = validate(ext, name);
  2347. if (!validExt.valid) {
  2348. throw Error(validExt.error);
  2349. }
  2350. for (var i = 0; i < ext.length; ++i) {
  2351. switch (ext[i].type) {
  2352. case 'lang':
  2353. langExtensions.push(ext[i]);
  2354. break;
  2355. case 'output':
  2356. outputModifiers.push(ext[i]);
  2357. break;
  2358. }
  2359. if (ext[i].hasOwnProperty('listeners')) {
  2360. for (var ln in ext[i].listeners) {
  2361. if (ext[i].listeners.hasOwnProperty(ln)) {
  2362. listen(ln, ext[i].listeners[ln]);
  2363. }
  2364. }
  2365. }
  2366. }
  2367. }
  2368. /**
  2369. * LEGACY_SUPPORT
  2370. * @param {*} ext
  2371. * @param {string} name
  2372. */
  2373. function legacyExtensionLoading (ext, name) {
  2374. if (typeof ext === 'function') {
  2375. ext = ext(new showdown.Converter());
  2376. }
  2377. if (!showdown.helper.isArray(ext)) {
  2378. ext = [ext];
  2379. }
  2380. var valid = validate(ext, name);
  2381. if (!valid.valid) {
  2382. throw Error(valid.error);
  2383. }
  2384. for (var i = 0; i < ext.length; ++i) {
  2385. switch (ext[i].type) {
  2386. case 'lang':
  2387. langExtensions.push(ext[i]);
  2388. break;
  2389. case 'output':
  2390. outputModifiers.push(ext[i]);
  2391. break;
  2392. default:// should never reach here
  2393. throw Error('Extension loader error: Type unrecognized!!!');
  2394. }
  2395. }
  2396. }
  2397. /**
  2398. * Listen to an event
  2399. * @param {string} name
  2400. * @param {function} callback
  2401. */
  2402. function listen (name, callback) {
  2403. if (!showdown.helper.isString(name)) {
  2404. throw Error('Invalid argument in converter.listen() method: name must be a string, but ' + typeof name + ' given');
  2405. }
  2406. if (typeof callback !== 'function') {
  2407. throw Error('Invalid argument in converter.listen() method: callback must be a function, but ' + typeof callback + ' given');
  2408. }
  2409. if (!listeners.hasOwnProperty(name)) {
  2410. listeners[name] = [];
  2411. }
  2412. listeners[name].push(callback);
  2413. }
  2414. function rTrimInputText (text) {
  2415. var rsp = text.match(/^\s*/)[0].length,
  2416. rgx = new RegExp('^\\s{0,' + rsp + '}', 'gm');
  2417. return text.replace(rgx, '');
  2418. }
  2419. /**
  2420. * Dispatch an event
  2421. * @private
  2422. * @param {string} evtName Event name
  2423. * @param {string} text Text
  2424. * @param {{}} options Converter Options
  2425. * @param {{}} globals
  2426. * @returns {string}
  2427. */
  2428. this._dispatch = function dispatch (evtName, text, options, globals) {
  2429. if (listeners.hasOwnProperty(evtName)) {
  2430. for (var ei = 0; ei < listeners[evtName].length; ++ei) {
  2431. var nText = listeners[evtName][ei](evtName, text, this, options, globals);
  2432. if (nText && typeof nText !== 'undefined') {
  2433. text = nText;
  2434. }
  2435. }
  2436. }
  2437. return text;
  2438. };
  2439. /**
  2440. * Listen to an event
  2441. * @param {string} name
  2442. * @param {function} callback
  2443. * @returns {showdown.Converter}
  2444. */
  2445. this.listen = function (name, callback) {
  2446. listen(name, callback);
  2447. return this;
  2448. };
  2449. /**
  2450. * Converts a markdown string into HTML
  2451. * @param {string} text
  2452. * @returns {*}
  2453. */
  2454. this.makeHtml = function (text) {
  2455. //check if text is not falsy
  2456. if (!text) {
  2457. return text;
  2458. }
  2459. var globals = {
  2460. gHtmlBlocks: [],
  2461. gHtmlMdBlocks: [],
  2462. gHtmlSpans: [],
  2463. gUrls: {},
  2464. gTitles: {},
  2465. gDimensions: {},
  2466. gListLevel: 0,
  2467. hashLinkCounts: {},
  2468. langExtensions: langExtensions,
  2469. outputModifiers: outputModifiers,
  2470. converter: this,
  2471. ghCodeBlocks: [],
  2472. metadata: {
  2473. parsed: {},
  2474. raw: '',
  2475. format: ''
  2476. }
  2477. };
  2478. // This lets us use ¨ trema as an escape char to avoid md5 hashes
  2479. // The choice of character is arbitrary; anything that isn't
  2480. // magic in Markdown will work.
  2481. text = text.replace(/¨/g, '¨T');
  2482. // Replace $ with ¨D
  2483. // RegExp interprets $ as a special character
  2484. // when it's in a replacement string
  2485. text = text.replace(/\$/g, '¨D');
  2486. // Standardize line endings
  2487. text = text.replace(/\r\n/g, '\n'); // DOS to Unix
  2488. text = text.replace(/\r/g, '\n'); // Mac to Unix
  2489. // Stardardize line spaces
  2490. text = text.replace(/\u00A0/g, '&nbsp;');
  2491. if (options.smartIndentationFix) {
  2492. text = rTrimInputText(text);
  2493. }
  2494. // Make sure text begins and ends with a couple of newlines:
  2495. text = '\n\n' + text + '\n\n';
  2496. // detab
  2497. text = showdown.subParser('detab')(text, options, globals);
  2498. /**
  2499. * Strip any lines consisting only of spaces and tabs.
  2500. * This makes subsequent regexs easier to write, because we can
  2501. * match consecutive blank lines with /\n+/ instead of something
  2502. * contorted like /[ \t]*\n+/
  2503. */
  2504. text = text.replace(/^[ \t]+$/mg, '');
  2505. //run languageExtensions
  2506. showdown.helper.forEach(langExtensions, function (ext) {
  2507. text = showdown.subParser('runExtension')(ext, text, options, globals);
  2508. });
  2509. // run the sub parsers
  2510. text = showdown.subParser('metadata')(text, options, globals);
  2511. text = showdown.subParser('hashPreCodeTags')(text, options, globals);
  2512. text = showdown.subParser('githubCodeBlocks')(text, options, globals);
  2513. text = showdown.subParser('hashHTMLBlocks')(text, options, globals);
  2514. text = showdown.subParser('hashCodeTags')(text, options, globals);
  2515. text = showdown.subParser('stripLinkDefinitions')(text, options, globals);
  2516. text = showdown.subParser('blockGamut')(text, options, globals);
  2517. text = showdown.subParser('unhashHTMLSpans')(text, options, globals);
  2518. text = showdown.subParser('unescapeSpecialChars')(text, options, globals);
  2519. // attacklab: Restore dollar signs
  2520. text = text.replace(/¨D/g, '$$');
  2521. // attacklab: Restore tremas
  2522. text = text.replace(/¨T/g, '¨');
  2523. // render a complete html document instead of a partial if the option is enabled
  2524. text = showdown.subParser('completeHTMLDocument')(text, options, globals);
  2525. // Run output modifiers
  2526. showdown.helper.forEach(outputModifiers, function (ext) {
  2527. text = showdown.subParser('runExtension')(ext, text, options, globals);
  2528. });
  2529. // update metadata
  2530. metadata = globals.metadata;
  2531. return text;
  2532. };
  2533. /**
  2534. * Converts an HTML string into a markdown string
  2535. * @param src
  2536. * @param [HTMLParser] A WHATWG DOM and HTML parser, such as JSDOM. If none is supplied, window.document will be used.
  2537. * @returns {string}
  2538. */
  2539. this.makeMarkdown = this.makeMd = function (src, HTMLParser) {
  2540. // replace \r\n with \n
  2541. src = src.replace(/\r\n/g, '\n');
  2542. src = src.replace(/\r/g, '\n'); // old macs
  2543. // due to an edge case, we need to find this: > <
  2544. // to prevent removing of non silent white spaces
  2545. // ex: <em>this is</em> <strong>sparta</strong>
  2546. src = src.replace(/>[ \t]+</, '>¨NBSP;<');
  2547. if (!HTMLParser) {
  2548. if (window && window.document) {
  2549. HTMLParser = window.document;
  2550. } else {
  2551. throw new Error('HTMLParser is undefined. If in a webworker or nodejs environment, you need to provide a WHATWG DOM and HTML such as JSDOM');
  2552. }
  2553. }
  2554. var doc = HTMLParser.createElement('div');
  2555. doc.innerHTML = src;
  2556. var globals = {
  2557. preList: substitutePreCodeTags(doc)
  2558. };
  2559. // remove all newlines and collapse spaces
  2560. clean(doc);
  2561. // some stuff, like accidental reference links must now be escaped
  2562. // TODO
  2563. // doc.innerHTML = doc.innerHTML.replace(/\[[\S\t ]]/);
  2564. var nodes = doc.childNodes,
  2565. mdDoc = '';
  2566. for (var i = 0; i < nodes.length; i++) {
  2567. mdDoc += showdown.subParser('makeMarkdown.node')(nodes[i], globals);
  2568. }
  2569. function clean (node) {
  2570. for (var n = 0; n < node.childNodes.length; ++n) {
  2571. var child = node.childNodes[n];
  2572. if (child.nodeType === 3) {
  2573. if (!/\S/.test(child.nodeValue)) {
  2574. node.removeChild(child);
  2575. --n;
  2576. } else {
  2577. child.nodeValue = child.nodeValue.split('\n').join(' ');
  2578. child.nodeValue = child.nodeValue.replace(/(\s)+/g, '$1');
  2579. }
  2580. } else if (child.nodeType === 1) {
  2581. clean(child);
  2582. }
  2583. }
  2584. }
  2585. // find all pre tags and replace contents with placeholder
  2586. // we need this so that we can remove all indentation from html
  2587. // to ease up parsing
  2588. function substitutePreCodeTags (doc) {
  2589. var pres = doc.querySelectorAll('pre'),
  2590. presPH = [];
  2591. for (var i = 0; i < pres.length; ++i) {
  2592. if (pres[i].childElementCount === 1 && pres[i].firstChild.tagName.toLowerCase() === 'code') {
  2593. var content = pres[i].firstChild.innerHTML.trim(),
  2594. language = pres[i].firstChild.getAttribute('data-language') || '';
  2595. // if data-language attribute is not defined, then we look for class language-*
  2596. if (language === '') {
  2597. var classes = pres[i].firstChild.className.split(' ');
  2598. for (var c = 0; c < classes.length; ++c) {
  2599. var matches = classes[c].match(/^language-(.+)$/);
  2600. if (matches !== null) {
  2601. language = matches[1];
  2602. break;
  2603. }
  2604. }
  2605. }
  2606. // unescape html entities in content
  2607. content = showdown.helper.unescapeHTMLEntities(content);
  2608. presPH.push(content);
  2609. pres[i].outerHTML = '<precode language="' + language + '" precodenum="' + i.toString() + '"></precode>';
  2610. } else {
  2611. presPH.push(pres[i].innerHTML);
  2612. pres[i].innerHTML = '';
  2613. pres[i].setAttribute('prenum', i.toString());
  2614. }
  2615. }
  2616. return presPH;
  2617. }
  2618. return mdDoc;
  2619. };
  2620. /**
  2621. * Set an option of this Converter instance
  2622. * @param {string} key
  2623. * @param {*} value
  2624. */
  2625. this.setOption = function (key, value) {
  2626. options[key] = value;
  2627. };
  2628. /**
  2629. * Get the option of this Converter instance
  2630. * @param {string} key
  2631. * @returns {*}
  2632. */
  2633. this.getOption = function (key) {
  2634. return options[key];
  2635. };
  2636. /**
  2637. * Get the options of this Converter instance
  2638. * @returns {{}}
  2639. */
  2640. this.getOptions = function () {
  2641. return options;
  2642. };
  2643. /**
  2644. * Add extension to THIS converter
  2645. * @param {{}} extension
  2646. * @param {string} [name=null]
  2647. */
  2648. this.addExtension = function (extension, name) {
  2649. name = name || null;
  2650. _parseExtension(extension, name);
  2651. };
  2652. /**
  2653. * Use a global registered extension with THIS converter
  2654. * @param {string} extensionName Name of the previously registered extension
  2655. */
  2656. this.useExtension = function (extensionName) {
  2657. _parseExtension(extensionName);
  2658. };
  2659. /**
  2660. * Set the flavor THIS converter should use
  2661. * @param {string} name
  2662. */
  2663. this.setFlavor = function (name) {
  2664. if (!flavor.hasOwnProperty(name)) {
  2665. throw Error(name + ' flavor was not found');
  2666. }
  2667. var preset = flavor[name];
  2668. setConvFlavor = name;
  2669. for (var option in preset) {
  2670. if (preset.hasOwnProperty(option)) {
  2671. options[option] = preset[option];
  2672. }
  2673. }
  2674. };
  2675. /**
  2676. * Get the currently set flavor of this converter
  2677. * @returns {string}
  2678. */
  2679. this.getFlavor = function () {
  2680. return setConvFlavor;
  2681. };
  2682. /**
  2683. * Remove an extension from THIS converter.
  2684. * Note: This is a costly operation. It's better to initialize a new converter
  2685. * and specify the extensions you wish to use
  2686. * @param {Array} extension
  2687. */
  2688. this.removeExtension = function (extension) {
  2689. if (!showdown.helper.isArray(extension)) {
  2690. extension = [extension];
  2691. }
  2692. for (var a = 0; a < extension.length; ++a) {
  2693. var ext = extension[a];
  2694. for (var i = 0; i < langExtensions.length; ++i) {
  2695. if (langExtensions[i] === ext) {
  2696. langExtensions[i].splice(i, 1);
  2697. }
  2698. }
  2699. for (var ii = 0; ii < outputModifiers.length; ++i) {
  2700. if (outputModifiers[ii] === ext) {
  2701. outputModifiers[ii].splice(i, 1);
  2702. }
  2703. }
  2704. }
  2705. };
  2706. /**
  2707. * Get all extension of THIS converter
  2708. * @returns {{language: Array, output: Array}}
  2709. */
  2710. this.getAllExtensions = function () {
  2711. return {
  2712. language: langExtensions,
  2713. output: outputModifiers
  2714. };
  2715. };
  2716. /**
  2717. * Get the metadata of the previously parsed document
  2718. * @param raw
  2719. * @returns {string|{}}
  2720. */
  2721. this.getMetadata = function (raw) {
  2722. if (raw) {
  2723. return metadata.raw;
  2724. } else {
  2725. return metadata.parsed;
  2726. }
  2727. };
  2728. /**
  2729. * Get the metadata format of the previously parsed document
  2730. * @returns {string}
  2731. */
  2732. this.getMetadataFormat = function () {
  2733. return metadata.format;
  2734. };
  2735. /**
  2736. * Private: set a single key, value metadata pair
  2737. * @param {string} key
  2738. * @param {string} value
  2739. */
  2740. this._setMetadataPair = function (key, value) {
  2741. metadata.parsed[key] = value;
  2742. };
  2743. /**
  2744. * Private: set metadata format
  2745. * @param {string} format
  2746. */
  2747. this._setMetadataFormat = function (format) {
  2748. metadata.format = format;
  2749. };
  2750. /**
  2751. * Private: set metadata raw text
  2752. * @param {string} raw
  2753. */
  2754. this._setMetadataRaw = function (raw) {
  2755. metadata.raw = raw;
  2756. };
  2757. };
  2758. /**
  2759. * Turn Markdown link shortcuts into XHTML <a> tags.
  2760. */
  2761. showdown.subParser('anchors', function (text, options, globals) {
  2762. 'use strict';
  2763. text = globals.converter._dispatch('anchors.before', text, options, globals);
  2764. var writeAnchorTag = function (wholeMatch, linkText, linkId, url, m5, m6, title) {
  2765. if (showdown.helper.isUndefined(title)) {
  2766. title = '';
  2767. }
  2768. linkId = linkId.toLowerCase();
  2769. // Special case for explicit empty url
  2770. if (wholeMatch.search(/\(<?\s*>? ?(['"].*['"])?\)$/m) > -1) {
  2771. url = '';
  2772. } else if (!url) {
  2773. if (!linkId) {
  2774. // lower-case and turn embedded newlines into spaces
  2775. linkId = linkText.toLowerCase().replace(/ ?\n/g, ' ');
  2776. }
  2777. url = '#' + linkId;
  2778. if (!showdown.helper.isUndefined(globals.gUrls[linkId])) {
  2779. url = globals.gUrls[linkId];
  2780. if (!showdown.helper.isUndefined(globals.gTitles[linkId])) {
  2781. title = globals.gTitles[linkId];
  2782. }
  2783. } else {
  2784. return wholeMatch;
  2785. }
  2786. }
  2787. //url = showdown.helper.escapeCharacters(url, '*_', false); // replaced line to improve performance
  2788. url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  2789. var result = '<a href="' + url + '"';
  2790. if (title !== '' && title !== null) {
  2791. title = title.replace(/"/g, '&quot;');
  2792. //title = showdown.helper.escapeCharacters(title, '*_', false); // replaced line to improve performance
  2793. title = title.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  2794. result += ' title="' + title + '"';
  2795. }
  2796. // optionLinksInNewWindow only applies
  2797. // to external links. Hash links (#) open in same page
  2798. if (options.openLinksInNewWindow && !/^#/.test(url)) {
  2799. // escaped _
  2800. result += ' rel="noopener noreferrer" target="¨E95Eblank"';
  2801. }
  2802. result += '>' + linkText + '</a>';
  2803. return result;
  2804. };
  2805. // First, handle reference-style links: [link text] [id]
  2806. text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)] ?(?:\n *)?\[(.*?)]()()()()/g, writeAnchorTag);
  2807. // Next, inline-style links: [link text](url "optional title")
  2808. // cases with crazy urls like ./image/cat1).png
  2809. text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<([^>]*)>(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g,
  2810. writeAnchorTag);
  2811. // normal cases
  2812. text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g,
  2813. writeAnchorTag);
  2814. // handle reference-style shortcuts: [link text]
  2815. // These must come last in case you've also got [link test][1]
  2816. // or [link test](/foo)
  2817. text = text.replace(/\[([^\[\]]+)]()()()()()/g, writeAnchorTag);
  2818. // Lastly handle GithubMentions if option is enabled
  2819. if (options.ghMentions) {
  2820. text = text.replace(/(^|\s)(\\)?(@([a-z\d]+(?:[a-z\d.-]+?[a-z\d]+)*))/gmi, function (wm, st, escape, mentions, username) {
  2821. if (escape === '\\') {
  2822. return st + mentions;
  2823. }
  2824. //check if options.ghMentionsLink is a string
  2825. if (!showdown.helper.isString(options.ghMentionsLink)) {
  2826. throw new Error('ghMentionsLink option must be a string');
  2827. }
  2828. var lnk = options.ghMentionsLink.replace(/\{u}/g, username),
  2829. target = '';
  2830. if (options.openLinksInNewWindow) {
  2831. target = ' rel="noopener noreferrer" target="¨E95Eblank"';
  2832. }
  2833. return st + '<a href="' + lnk + '"' + target + '>' + mentions + '</a>';
  2834. });
  2835. }
  2836. text = globals.converter._dispatch('anchors.after', text, options, globals);
  2837. return text;
  2838. });
  2839. // url allowed chars [a-z\d_.~:/?#[]@!$&'()*+,;=-]
  2840. var simpleURLRegex = /([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+?\.[^'">\s]+?)()(\1)?(?=\s|$)(?!["<>])/gi,
  2841. simpleURLRegex2 = /([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+?)([.!?,()\[\]])?(\1)?(?=\s|$)(?!["<>])/gi,
  2842. delimUrlRegex = /()<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)()>()/gi,
  2843. simpleMailRegex = /(^|\s)(?:mailto:)?([A-Za-z0-9!#$%&'*+-/=?^_`{|}~.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?=$|\s)/gmi,
  2844. delimMailRegex = /<()(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,
  2845. replaceLink = function (options) {
  2846. 'use strict';
  2847. return function (wm, leadingMagicChars, link, m2, m3, trailingPunctuation, trailingMagicChars) {
  2848. link = link.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  2849. var lnkTxt = link,
  2850. append = '',
  2851. target = '',
  2852. lmc = leadingMagicChars || '',
  2853. tmc = trailingMagicChars || '';
  2854. if (/^www\./i.test(link)) {
  2855. link = link.replace(/^www\./i, 'http://www.');
  2856. }
  2857. if (options.excludeTrailingPunctuationFromURLs && trailingPunctuation) {
  2858. append = trailingPunctuation;
  2859. }
  2860. if (options.openLinksInNewWindow) {
  2861. target = ' rel="noopener noreferrer" target="¨E95Eblank"';
  2862. }
  2863. return lmc + '<a href="' + link + '"' + target + '>' + lnkTxt + '</a>' + append + tmc;
  2864. };
  2865. },
  2866. replaceMail = function (options, globals) {
  2867. 'use strict';
  2868. return function (wholeMatch, b, mail) {
  2869. var href = 'mailto:';
  2870. b = b || '';
  2871. mail = showdown.subParser('unescapeSpecialChars')(mail, options, globals);
  2872. if (options.encodeEmails) {
  2873. href = showdown.helper.encodeEmailAddress(href + mail);
  2874. mail = showdown.helper.encodeEmailAddress(mail);
  2875. } else {
  2876. href = href + mail;
  2877. }
  2878. return b + '<a href="' + href + '">' + mail + '</a>';
  2879. };
  2880. };
  2881. showdown.subParser('autoLinks', function (text, options, globals) {
  2882. 'use strict';
  2883. text = globals.converter._dispatch('autoLinks.before', text, options, globals);
  2884. text = text.replace(delimUrlRegex, replaceLink(options));
  2885. text = text.replace(delimMailRegex, replaceMail(options, globals));
  2886. text = globals.converter._dispatch('autoLinks.after', text, options, globals);
  2887. return text;
  2888. });
  2889. showdown.subParser('simplifiedAutoLinks', function (text, options, globals) {
  2890. 'use strict';
  2891. if (!options.simplifiedAutoLink) {
  2892. return text;
  2893. }
  2894. text = globals.converter._dispatch('simplifiedAutoLinks.before', text, options, globals);
  2895. if (options.excludeTrailingPunctuationFromURLs) {
  2896. text = text.replace(simpleURLRegex2, replaceLink(options));
  2897. } else {
  2898. text = text.replace(simpleURLRegex, replaceLink(options));
  2899. }
  2900. text = text.replace(simpleMailRegex, replaceMail(options, globals));
  2901. text = globals.converter._dispatch('simplifiedAutoLinks.after', text, options, globals);
  2902. return text;
  2903. });
  2904. /**
  2905. * These are all the transformations that form block-level
  2906. * tags like paragraphs, headers, and list items.
  2907. */
  2908. showdown.subParser('blockGamut', function (text, options, globals) {
  2909. 'use strict';
  2910. text = globals.converter._dispatch('blockGamut.before', text, options, globals);
  2911. // we parse blockquotes first so that we can have headings and hrs
  2912. // inside blockquotes
  2913. text = showdown.subParser('blockQuotes')(text, options, globals);
  2914. text = showdown.subParser('headers')(text, options, globals);
  2915. // Do Horizontal Rules:
  2916. text = showdown.subParser('horizontalRule')(text, options, globals);
  2917. text = showdown.subParser('lists')(text, options, globals);
  2918. text = showdown.subParser('codeBlocks')(text, options, globals);
  2919. text = showdown.subParser('tables')(text, options, globals);
  2920. // We already ran _HashHTMLBlocks() before, in Markdown(), but that
  2921. // was to escape raw HTML in the original Markdown source. This time,
  2922. // we're escaping the markup we've just created, so that we don't wrap
  2923. // <p> tags around block-level tags.
  2924. text = showdown.subParser('hashHTMLBlocks')(text, options, globals);
  2925. text = showdown.subParser('paragraphs')(text, options, globals);
  2926. text = globals.converter._dispatch('blockGamut.after', text, options, globals);
  2927. return text;
  2928. });
  2929. showdown.subParser('blockQuotes', function (text, options, globals) {
  2930. 'use strict';
  2931. text = globals.converter._dispatch('blockQuotes.before', text, options, globals);
  2932. // add a couple extra lines after the text and endtext mark
  2933. text = text + '\n\n';
  2934. var rgx = /(^ {0,3}>[ \t]?.+\n(.+\n)*\n*)+/gm;
  2935. if (options.splitAdjacentBlockquotes) {
  2936. rgx = /^ {0,3}>[\s\S]*?(?:\n\n)/gm;
  2937. }
  2938. text = text.replace(rgx, function (bq) {
  2939. // attacklab: hack around Konqueror 3.5.4 bug:
  2940. // "----------bug".replace(/^-/g,"") == "bug"
  2941. bq = bq.replace(/^[ \t]*>[ \t]?/gm, ''); // trim one level of quoting
  2942. // attacklab: clean up hack
  2943. bq = bq.replace(/¨0/g, '');
  2944. bq = bq.replace(/^[ \t]+$/gm, ''); // trim whitespace-only lines
  2945. bq = showdown.subParser('githubCodeBlocks')(bq, options, globals);
  2946. bq = showdown.subParser('blockGamut')(bq, options, globals); // recurse
  2947. bq = bq.replace(/(^|\n)/g, '$1 ');
  2948. // These leading spaces screw with <pre> content, so we need to fix that:
  2949. bq = bq.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm, function (wholeMatch, m1) {
  2950. var pre = m1;
  2951. // attacklab: hack around Konqueror 3.5.4 bug:
  2952. pre = pre.replace(/^ /mg, '¨0');
  2953. pre = pre.replace(/¨0/g, '');
  2954. return pre;
  2955. });
  2956. return showdown.subParser('hashBlock')('<blockquote>\n' + bq + '\n</blockquote>', options, globals);
  2957. });
  2958. text = globals.converter._dispatch('blockQuotes.after', text, options, globals);
  2959. return text;
  2960. });
  2961. /**
  2962. * Process Markdown `<pre><code>` blocks.
  2963. */
  2964. showdown.subParser('codeBlocks', function (text, options, globals) {
  2965. 'use strict';
  2966. text = globals.converter._dispatch('codeBlocks.before', text, options, globals);
  2967. // sentinel workarounds for lack of \A and \Z, safari\khtml bug
  2968. text += '¨0';
  2969. var pattern = /(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=¨0))/g;
  2970. text = text.replace(pattern, function (wholeMatch, m1, m2) {
  2971. var codeblock = m1,
  2972. nextChar = m2,
  2973. end = '\n';
  2974. codeblock = showdown.subParser('outdent')(codeblock, options, globals);
  2975. codeblock = showdown.subParser('encodeCode')(codeblock, options, globals);
  2976. codeblock = showdown.subParser('detab')(codeblock, options, globals);
  2977. codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
  2978. codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing newlines
  2979. if (options.omitExtraWLInCodeBlocks) {
  2980. end = '';
  2981. }
  2982. codeblock = '<pre><code>' + codeblock + end + '</code></pre>';
  2983. return showdown.subParser('hashBlock')(codeblock, options, globals) + nextChar;
  2984. });
  2985. // strip sentinel
  2986. text = text.replace(/¨0/, '');
  2987. text = globals.converter._dispatch('codeBlocks.after', text, options, globals);
  2988. return text;
  2989. });
  2990. /**
  2991. *
  2992. * * Backtick quotes are used for <code></code> spans.
  2993. *
  2994. * * You can use multiple backticks as the delimiters if you want to
  2995. * include literal backticks in the code span. So, this input:
  2996. *
  2997. * Just type ``foo `bar` baz`` at the prompt.
  2998. *
  2999. * Will translate to:
  3000. *
  3001. * <p>Just type <code>foo `bar` baz</code> at the prompt.</p>
  3002. *
  3003. * There's no arbitrary limit to the number of backticks you
  3004. * can use as delimters. If you need three consecutive backticks
  3005. * in your code, use four for delimiters, etc.
  3006. *
  3007. * * You can use spaces to get literal backticks at the edges:
  3008. *
  3009. * ... type `` `bar` `` ...
  3010. *
  3011. * Turns to:
  3012. *
  3013. * ... type <code>`bar`</code> ...
  3014. */
  3015. showdown.subParser('codeSpans', function (text, options, globals) {
  3016. 'use strict';
  3017. text = globals.converter._dispatch('codeSpans.before', text, options, globals);
  3018. if (typeof text === 'undefined') {
  3019. text = '';
  3020. }
  3021. text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
  3022. function (wholeMatch, m1, m2, m3) {
  3023. var c = m3;
  3024. c = c.replace(/^([ \t]*)/g, ''); // leading whitespace
  3025. c = c.replace(/[ \t]*$/g, ''); // trailing whitespace
  3026. c = showdown.subParser('encodeCode')(c, options, globals);
  3027. c = m1 + '<code>' + c + '</code>';
  3028. c = showdown.subParser('hashHTMLSpans')(c, options, globals);
  3029. return c;
  3030. }
  3031. );
  3032. text = globals.converter._dispatch('codeSpans.after', text, options, globals);
  3033. return text;
  3034. });
  3035. /**
  3036. * Create a full HTML document from the processed markdown
  3037. */
  3038. showdown.subParser('completeHTMLDocument', function (text, options, globals) {
  3039. 'use strict';
  3040. if (!options.completeHTMLDocument) {
  3041. return text;
  3042. }
  3043. text = globals.converter._dispatch('completeHTMLDocument.before', text, options, globals);
  3044. var doctype = 'html',
  3045. doctypeParsed = '<!DOCTYPE HTML>\n',
  3046. title = '',
  3047. charset = '<meta charset="utf-8">\n',
  3048. lang = '',
  3049. metadata = '';
  3050. if (typeof globals.metadata.parsed.doctype !== 'undefined') {
  3051. doctypeParsed = '<!DOCTYPE ' + globals.metadata.parsed.doctype + '>\n';
  3052. doctype = globals.metadata.parsed.doctype.toString().toLowerCase();
  3053. if (doctype === 'html' || doctype === 'html5') {
  3054. charset = '<meta charset="utf-8">';
  3055. }
  3056. }
  3057. for (var meta in globals.metadata.parsed) {
  3058. if (globals.metadata.parsed.hasOwnProperty(meta)) {
  3059. switch (meta.toLowerCase()) {
  3060. case 'doctype':
  3061. break;
  3062. case 'title':
  3063. title = '<title>' + globals.metadata.parsed.title + '</title>\n';
  3064. break;
  3065. case 'charset':
  3066. if (doctype === 'html' || doctype === 'html5') {
  3067. charset = '<meta charset="' + globals.metadata.parsed.charset + '">\n';
  3068. } else {
  3069. charset = '<meta name="charset" content="' + globals.metadata.parsed.charset + '">\n';
  3070. }
  3071. break;
  3072. case 'language':
  3073. case 'lang':
  3074. lang = ' lang="' + globals.metadata.parsed[meta] + '"';
  3075. metadata += '<meta name="' + meta + '" content="' + globals.metadata.parsed[meta] + '">\n';
  3076. break;
  3077. default:
  3078. metadata += '<meta name="' + meta + '" content="' + globals.metadata.parsed[meta] + '">\n';
  3079. }
  3080. }
  3081. }
  3082. text = doctypeParsed + '<html' + lang + '>\n<head>\n' + title + charset + metadata + '</head>\n<body>\n' + text.trim() + '\n</body>\n</html>';
  3083. text = globals.converter._dispatch('completeHTMLDocument.after', text, options, globals);
  3084. return text;
  3085. });
  3086. /**
  3087. * Convert all tabs to spaces
  3088. */
  3089. showdown.subParser('detab', function (text, options, globals) {
  3090. 'use strict';
  3091. text = globals.converter._dispatch('detab.before', text, options, globals);
  3092. // expand first n-1 tabs
  3093. text = text.replace(/\t(?=\t)/g, ' '); // g_tab_width
  3094. // replace the nth with two sentinels
  3095. text = text.replace(/\t/g, '¨A¨B');
  3096. // use the sentinel to anchor our regex so it doesn't explode
  3097. text = text.replace(/¨B(.+?)¨A/g, function (wholeMatch, m1) {
  3098. var leadingText = m1,
  3099. numSpaces = 4 - leadingText.length % 4; // g_tab_width
  3100. // there *must* be a better way to do this:
  3101. for (var i = 0; i < numSpaces; i++) {
  3102. leadingText += ' ';
  3103. }
  3104. return leadingText;
  3105. });
  3106. // clean up sentinels
  3107. text = text.replace(/¨A/g, ' '); // g_tab_width
  3108. text = text.replace(/¨B/g, '');
  3109. text = globals.converter._dispatch('detab.after', text, options, globals);
  3110. return text;
  3111. });
  3112. showdown.subParser('ellipsis', function (text, options, globals) {
  3113. 'use strict';
  3114. text = globals.converter._dispatch('ellipsis.before', text, options, globals);
  3115. text = text.replace(/\.\.\./g, '…');
  3116. text = globals.converter._dispatch('ellipsis.after', text, options, globals);
  3117. return text;
  3118. });
  3119. /**
  3120. * Turn emoji codes into emojis
  3121. *
  3122. * List of supported emojis: https://github.com/showdownjs/showdown/wiki/Emojis
  3123. */
  3124. showdown.subParser('emoji', function (text, options, globals) {
  3125. 'use strict';
  3126. if (!options.emoji) {
  3127. return text;
  3128. }
  3129. text = globals.converter._dispatch('emoji.before', text, options, globals);
  3130. var emojiRgx = /:([\S]+?):/g;
  3131. text = text.replace(emojiRgx, function (wm, emojiCode) {
  3132. if (showdown.helper.emojis.hasOwnProperty(emojiCode)) {
  3133. return showdown.helper.emojis[emojiCode];
  3134. }
  3135. return wm;
  3136. });
  3137. text = globals.converter._dispatch('emoji.after', text, options, globals);
  3138. return text;
  3139. });
  3140. /**
  3141. * Smart processing for ampersands and angle brackets that need to be encoded.
  3142. */
  3143. showdown.subParser('encodeAmpsAndAngles', function (text, options, globals) {
  3144. 'use strict';
  3145. text = globals.converter._dispatch('encodeAmpsAndAngles.before', text, options, globals);
  3146. // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
  3147. // http://bumppo.net/projects/amputator/
  3148. text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, '&amp;');
  3149. // Encode naked <'s
  3150. text = text.replace(/<(?![a-z\/?$!])/gi, '&lt;');
  3151. // Encode <
  3152. text = text.replace(/</g, '&lt;');
  3153. // Encode >
  3154. text = text.replace(/>/g, '&gt;');
  3155. text = globals.converter._dispatch('encodeAmpsAndAngles.after', text, options, globals);
  3156. return text;
  3157. });
  3158. /**
  3159. * Returns the string, with after processing the following backslash escape sequences.
  3160. *
  3161. * attacklab: The polite way to do this is with the new escapeCharacters() function:
  3162. *
  3163. * text = escapeCharacters(text,"\\",true);
  3164. * text = escapeCharacters(text,"`*_{}[]()>#+-.!",true);
  3165. *
  3166. * ...but we're sidestepping its use of the (slow) RegExp constructor
  3167. * as an optimization for Firefox. This function gets called a LOT.
  3168. */
  3169. showdown.subParser('encodeBackslashEscapes', function (text, options, globals) {
  3170. 'use strict';
  3171. text = globals.converter._dispatch('encodeBackslashEscapes.before', text, options, globals);
  3172. text = text.replace(/\\(\\)/g, showdown.helper.escapeCharactersCallback);
  3173. text = text.replace(/\\([`*_{}\[\]()>#+.!~=|-])/g, showdown.helper.escapeCharactersCallback);
  3174. text = globals.converter._dispatch('encodeBackslashEscapes.after', text, options, globals);
  3175. return text;
  3176. });
  3177. /**
  3178. * Encode/escape certain characters inside Markdown code runs.
  3179. * The point is that in code, these characters are literals,
  3180. * and lose their special Markdown meanings.
  3181. */
  3182. showdown.subParser('encodeCode', function (text, options, globals) {
  3183. 'use strict';
  3184. text = globals.converter._dispatch('encodeCode.before', text, options, globals);
  3185. // Encode all ampersands; HTML entities are not
  3186. // entities within a Markdown code span.
  3187. text = text
  3188. .replace(/&/g, '&amp;')
  3189. // Do the angle bracket song and dance:
  3190. .replace(/</g, '&lt;')
  3191. .replace(/>/g, '&gt;')
  3192. // Now, escape characters that are magic in Markdown:
  3193. .replace(/([*_{}\[\]\\=~-])/g, showdown.helper.escapeCharactersCallback);
  3194. text = globals.converter._dispatch('encodeCode.after', text, options, globals);
  3195. return text;
  3196. });
  3197. /**
  3198. * Within tags -- meaning between < and > -- encode [\ ` * _ ~ =] so they
  3199. * don't conflict with their use in Markdown for code, italics and strong.
  3200. */
  3201. showdown.subParser('escapeSpecialCharsWithinTagAttributes', function (text, options, globals) {
  3202. 'use strict';
  3203. text = globals.converter._dispatch('escapeSpecialCharsWithinTagAttributes.before', text, options, globals);
  3204. // Build a regex to find HTML tags.
  3205. var tags = /<\/?[a-z\d_:-]+(?:[\s]+[\s\S]+?)?>/gi,
  3206. comments = /<!(--(?:(?:[^>-]|-[^>])(?:[^-]|-[^-])*)--)>/gi;
  3207. text = text.replace(tags, function (wholeMatch) {
  3208. return wholeMatch
  3209. .replace(/(.)<\/?code>(?=.)/g, '$1`')
  3210. .replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback);
  3211. });
  3212. text = text.replace(comments, function (wholeMatch) {
  3213. return wholeMatch
  3214. .replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback);
  3215. });
  3216. text = globals.converter._dispatch('escapeSpecialCharsWithinTagAttributes.after', text, options, globals);
  3217. return text;
  3218. });
  3219. /**
  3220. * Handle github codeblocks prior to running HashHTML so that
  3221. * HTML contained within the codeblock gets escaped properly
  3222. * Example:
  3223. * ```ruby
  3224. * def hello_world(x)
  3225. * puts "Hello, #{x}"
  3226. * end
  3227. * ```
  3228. */
  3229. showdown.subParser('githubCodeBlocks', function (text, options, globals) {
  3230. 'use strict';
  3231. // early exit if option is not enabled
  3232. if (!options.ghCodeBlocks) {
  3233. return text;
  3234. }
  3235. text = globals.converter._dispatch('githubCodeBlocks.before', text, options, globals);
  3236. text += '¨0';
  3237. text = text.replace(/(?:^|\n)(?: {0,3})(```+|~~~+)(?: *)([^\s`~]*)\n([\s\S]*?)\n(?: {0,3})\1/g, function (wholeMatch, delim, language, codeblock) {
  3238. var end = (options.omitExtraWLInCodeBlocks) ? '' : '\n';
  3239. // First parse the github code block
  3240. codeblock = showdown.subParser('encodeCode')(codeblock, options, globals);
  3241. codeblock = showdown.subParser('detab')(codeblock, options, globals);
  3242. codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
  3243. codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace
  3244. codeblock = '<pre><code' + (language ? ' class="' + language + ' language-' + language + '"' : '') + '>' + codeblock + end + '</code></pre>';
  3245. codeblock = showdown.subParser('hashBlock')(codeblock, options, globals);
  3246. // Since GHCodeblocks can be false positives, we need to
  3247. // store the primitive text and the parsed text in a global var,
  3248. // and then return a token
  3249. return '\n\n¨G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n';
  3250. });
  3251. // attacklab: strip sentinel
  3252. text = text.replace(/¨0/, '');
  3253. return globals.converter._dispatch('githubCodeBlocks.after', text, options, globals);
  3254. });
  3255. showdown.subParser('hashBlock', function (text, options, globals) {
  3256. 'use strict';
  3257. text = globals.converter._dispatch('hashBlock.before', text, options, globals);
  3258. text = text.replace(/(^\n+|\n+$)/g, '');
  3259. text = '\n\n¨K' + (globals.gHtmlBlocks.push(text) - 1) + 'K\n\n';
  3260. text = globals.converter._dispatch('hashBlock.after', text, options, globals);
  3261. return text;
  3262. });
  3263. /**
  3264. * Hash and escape <code> elements that should not be parsed as markdown
  3265. */
  3266. showdown.subParser('hashCodeTags', function (text, options, globals) {
  3267. 'use strict';
  3268. text = globals.converter._dispatch('hashCodeTags.before', text, options, globals);
  3269. var repFunc = function (wholeMatch, match, left, right) {
  3270. var codeblock = left + showdown.subParser('encodeCode')(match, options, globals) + right;
  3271. return '¨C' + (globals.gHtmlSpans.push(codeblock) - 1) + 'C';
  3272. };
  3273. // Hash naked <code>
  3274. text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '<code\\b[^>]*>', '</code>', 'gim');
  3275. text = globals.converter._dispatch('hashCodeTags.after', text, options, globals);
  3276. return text;
  3277. });
  3278. showdown.subParser('hashElement', function (text, options, globals) {
  3279. 'use strict';
  3280. return function (wholeMatch, m1) {
  3281. var blockText = m1;
  3282. // Undo double lines
  3283. blockText = blockText.replace(/\n\n/g, '\n');
  3284. blockText = blockText.replace(/^\n/, '');
  3285. // strip trailing blank lines
  3286. blockText = blockText.replace(/\n+$/g, '');
  3287. // Replace the element text with a marker ("¨KxK" where x is its key)
  3288. blockText = '\n\n¨K' + (globals.gHtmlBlocks.push(blockText) - 1) + 'K\n\n';
  3289. return blockText;
  3290. };
  3291. });
  3292. showdown.subParser('hashHTMLBlocks', function (text, options, globals) {
  3293. 'use strict';
  3294. text = globals.converter._dispatch('hashHTMLBlocks.before', text, options, globals);
  3295. var blockTags = [
  3296. 'pre',
  3297. 'div',
  3298. 'h1',
  3299. 'h2',
  3300. 'h3',
  3301. 'h4',
  3302. 'h5',
  3303. 'h6',
  3304. 'blockquote',
  3305. 'table',
  3306. 'dl',
  3307. 'ol',
  3308. 'ul',
  3309. 'script',
  3310. 'noscript',
  3311. 'form',
  3312. 'fieldset',
  3313. 'iframe',
  3314. 'math',
  3315. 'style',
  3316. 'section',
  3317. 'header',
  3318. 'footer',
  3319. 'nav',
  3320. 'article',
  3321. 'aside',
  3322. 'address',
  3323. 'audio',
  3324. 'canvas',
  3325. 'figure',
  3326. 'hgroup',
  3327. 'output',
  3328. 'video',
  3329. 'p'
  3330. ],
  3331. repFunc = function (wholeMatch, match, left, right) {
  3332. var txt = wholeMatch;
  3333. // check if this html element is marked as markdown
  3334. // if so, it's contents should be parsed as markdown
  3335. if (left.search(/\bmarkdown\b/) !== -1) {
  3336. txt = left + globals.converter.makeHtml(match) + right;
  3337. }
  3338. return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n';
  3339. };
  3340. if (options.backslashEscapesHTMLTags) {
  3341. // encode backslash escaped HTML tags
  3342. text = text.replace(/\\<(\/?[^>]+?)>/g, function (wm, inside) {
  3343. return '&lt;' + inside + '&gt;';
  3344. });
  3345. }
  3346. // hash HTML Blocks
  3347. for (var i = 0; i < blockTags.length; ++i) {
  3348. var opTagPos,
  3349. rgx1 = new RegExp('^ {0,3}(<' + blockTags[i] + '\\b[^>]*>)', 'im'),
  3350. patLeft = '<' + blockTags[i] + '\\b[^>]*>',
  3351. patRight = '</' + blockTags[i] + '>';
  3352. // 1. Look for the first position of the first opening HTML tag in the text
  3353. while ((opTagPos = showdown.helper.regexIndexOf(text, rgx1)) !== -1) {
  3354. // if the HTML tag is \ escaped, we need to escape it and break
  3355. //2. Split the text in that position
  3356. var subTexts = showdown.helper.splitAtIndex(text, opTagPos),
  3357. //3. Match recursively
  3358. newSubText1 = showdown.helper.replaceRecursiveRegExp(subTexts[1], repFunc, patLeft, patRight, 'im');
  3359. // prevent an infinite loop
  3360. if (newSubText1 === subTexts[1]) {
  3361. break;
  3362. }
  3363. text = subTexts[0].concat(newSubText1);
  3364. }
  3365. }
  3366. // HR SPECIAL CASE
  3367. text = text.replace(/(\n {0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,
  3368. showdown.subParser('hashElement')(text, options, globals));
  3369. // Special case for standalone HTML comments
  3370. text = showdown.helper.replaceRecursiveRegExp(text, function (txt) {
  3371. return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n';
  3372. }, '^ {0,3}<!--', '-->', 'gm');
  3373. // PHP and ASP-style processor instructions (<?...?> and <%...%>)
  3374. text = text.replace(/(?:\n\n)( {0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,
  3375. showdown.subParser('hashElement')(text, options, globals));
  3376. text = globals.converter._dispatch('hashHTMLBlocks.after', text, options, globals);
  3377. return text;
  3378. });
  3379. /**
  3380. * Hash span elements that should not be parsed as markdown
  3381. */
  3382. showdown.subParser('hashHTMLSpans', function (text, options, globals) {
  3383. 'use strict';
  3384. text = globals.converter._dispatch('hashHTMLSpans.before', text, options, globals);
  3385. function hashHTMLSpan (html) {
  3386. return '¨C' + (globals.gHtmlSpans.push(html) - 1) + 'C';
  3387. }
  3388. // Hash Self Closing tags
  3389. text = text.replace(/<[^>]+?\/>/gi, function (wm) {
  3390. return hashHTMLSpan(wm);
  3391. });
  3392. // Hash tags without properties
  3393. text = text.replace(/<([^>]+?)>[\s\S]*?<\/\1>/g, function (wm) {
  3394. return hashHTMLSpan(wm);
  3395. });
  3396. // Hash tags with properties
  3397. text = text.replace(/<([^>]+?)\s[^>]+?>[\s\S]*?<\/\1>/g, function (wm) {
  3398. return hashHTMLSpan(wm);
  3399. });
  3400. // Hash self closing tags without />
  3401. text = text.replace(/<[^>]+?>/gi, function (wm) {
  3402. return hashHTMLSpan(wm);
  3403. });
  3404. /*showdown.helper.matchRecursiveRegExp(text, '<code\\b[^>]*>', '</code>', 'gi');*/
  3405. text = globals.converter._dispatch('hashHTMLSpans.after', text, options, globals);
  3406. return text;
  3407. });
  3408. /**
  3409. * Unhash HTML spans
  3410. */
  3411. showdown.subParser('unhashHTMLSpans', function (text, options, globals) {
  3412. 'use strict';
  3413. text = globals.converter._dispatch('unhashHTMLSpans.before', text, options, globals);
  3414. for (var i = 0; i < globals.gHtmlSpans.length; ++i) {
  3415. var repText = globals.gHtmlSpans[i],
  3416. // limiter to prevent infinite loop (assume 10 as limit for recurse)
  3417. limit = 0;
  3418. while (/¨C(\d+)C/.test(repText)) {
  3419. var num = RegExp.$1;
  3420. repText = repText.replace('¨C' + num + 'C', globals.gHtmlSpans[num]);
  3421. if (limit === 10) {
  3422. console.error('maximum nesting of 10 spans reached!!!');
  3423. break;
  3424. }
  3425. ++limit;
  3426. }
  3427. text = text.replace('¨C' + i + 'C', repText);
  3428. }
  3429. text = globals.converter._dispatch('unhashHTMLSpans.after', text, options, globals);
  3430. return text;
  3431. });
  3432. /**
  3433. * Hash and escape <pre><code> elements that should not be parsed as markdown
  3434. */
  3435. showdown.subParser('hashPreCodeTags', function (text, options, globals) {
  3436. 'use strict';
  3437. text = globals.converter._dispatch('hashPreCodeTags.before', text, options, globals);
  3438. var repFunc = function (wholeMatch, match, left, right) {
  3439. // encode html entities
  3440. var codeblock = left + showdown.subParser('encodeCode')(match, options, globals) + right;
  3441. return '\n\n¨G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n';
  3442. };
  3443. // Hash <pre><code>
  3444. text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '^ {0,3}<pre\\b[^>]*>\\s*<code\\b[^>]*>', '^ {0,3}</code>\\s*</pre>', 'gim');
  3445. text = globals.converter._dispatch('hashPreCodeTags.after', text, options, globals);
  3446. return text;
  3447. });
  3448. showdown.subParser('headers', function (text, options, globals) {
  3449. 'use strict';
  3450. text = globals.converter._dispatch('headers.before', text, options, globals);
  3451. var headerLevelStart = (isNaN(parseInt(options.headerLevelStart))) ? 1 : parseInt(options.headerLevelStart),
  3452. // Set text-style headers:
  3453. // Header 1
  3454. // ========
  3455. //
  3456. // Header 2
  3457. // --------
  3458. //
  3459. setextRegexH1 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n={2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n=+[ \t]*\n+/gm,
  3460. setextRegexH2 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n-+[ \t]*\n+/gm;
  3461. text = text.replace(setextRegexH1, function (wholeMatch, m1) {
  3462. var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
  3463. hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
  3464. hLevel = headerLevelStart,
  3465. hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
  3466. return showdown.subParser('hashBlock')(hashBlock, options, globals);
  3467. });
  3468. text = text.replace(setextRegexH2, function (matchFound, m1) {
  3469. var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
  3470. hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
  3471. hLevel = headerLevelStart + 1,
  3472. hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
  3473. return showdown.subParser('hashBlock')(hashBlock, options, globals);
  3474. });
  3475. // atx-style headers:
  3476. // # Header 1
  3477. // ## Header 2
  3478. // ## Header 2 with closing hashes ##
  3479. // ...
  3480. // ###### Header 6
  3481. //
  3482. var atxStyle = (options.requireSpaceBeforeHeadingText) ? /^(#{1,6})[ \t]+(.+?)[ \t]*#*\n+/gm : /^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm;
  3483. text = text.replace(atxStyle, function (wholeMatch, m1, m2) {
  3484. var hText = m2;
  3485. if (options.customizedHeaderId) {
  3486. hText = m2.replace(/\s?\{([^{]+?)}\s*$/, '');
  3487. }
  3488. var span = showdown.subParser('spanGamut')(hText, options, globals),
  3489. hID = (options.noHeaderId) ? '' : ' id="' + headerId(m2) + '"',
  3490. hLevel = headerLevelStart - 1 + m1.length,
  3491. header = '<h' + hLevel + hID + '>' + span + '</h' + hLevel + '>';
  3492. return showdown.subParser('hashBlock')(header, options, globals);
  3493. });
  3494. function headerId (m) {
  3495. var title,
  3496. prefix;
  3497. // It is separate from other options to allow combining prefix and customized
  3498. if (options.customizedHeaderId) {
  3499. var match = m.match(/\{([^{]+?)}\s*$/);
  3500. if (match && match[1]) {
  3501. m = match[1];
  3502. }
  3503. }
  3504. title = m;
  3505. // Prefix id to prevent causing inadvertent pre-existing style matches.
  3506. if (showdown.helper.isString(options.prefixHeaderId)) {
  3507. prefix = options.prefixHeaderId;
  3508. } else if (options.prefixHeaderId === true) {
  3509. prefix = 'section-';
  3510. } else {
  3511. prefix = '';
  3512. }
  3513. if (!options.rawPrefixHeaderId) {
  3514. title = prefix + title;
  3515. }
  3516. if (options.ghCompatibleHeaderId) {
  3517. title = title
  3518. .replace(/ /g, '-')
  3519. // replace previously escaped chars (&, ¨ and $)
  3520. .replace(/&amp;/g, '')
  3521. .replace(/¨T/g, '')
  3522. .replace(/¨D/g, '')
  3523. // replace rest of the chars (&~$ are repeated as they might have been escaped)
  3524. // borrowed from github's redcarpet (some they should produce similar results)
  3525. .replace(/[&+$,\/:;=?@"#{}|^¨~\[\]`\\*)(%.!'<>]/g, '')
  3526. .toLowerCase();
  3527. } else if (options.rawHeaderId) {
  3528. title = title
  3529. .replace(/ /g, '-')
  3530. // replace previously escaped chars (&, ¨ and $)
  3531. .replace(/&amp;/g, '&')
  3532. .replace(/¨T/g, '¨')
  3533. .replace(/¨D/g, '$')
  3534. // replace " and '
  3535. .replace(/["']/g, '-')
  3536. .toLowerCase();
  3537. } else {
  3538. title = title
  3539. .replace(/[^\w]/g, '')
  3540. .toLowerCase();
  3541. }
  3542. if (options.rawPrefixHeaderId) {
  3543. title = prefix + title;
  3544. }
  3545. if (globals.hashLinkCounts[title]) {
  3546. title = title + '-' + (globals.hashLinkCounts[title]++);
  3547. } else {
  3548. globals.hashLinkCounts[title] = 1;
  3549. }
  3550. return title;
  3551. }
  3552. text = globals.converter._dispatch('headers.after', text, options, globals);
  3553. return text;
  3554. });
  3555. /**
  3556. * Turn Markdown link shortcuts into XHTML <a> tags.
  3557. */
  3558. showdown.subParser('horizontalRule', function (text, options, globals) {
  3559. 'use strict';
  3560. text = globals.converter._dispatch('horizontalRule.before', text, options, globals);
  3561. var key = showdown.subParser('hashBlock')('<hr />', options, globals);
  3562. text = text.replace(/^ {0,2}( ?-){3,}[ \t]*$/gm, key);
  3563. text = text.replace(/^ {0,2}( ?\*){3,}[ \t]*$/gm, key);
  3564. text = text.replace(/^ {0,2}( ?_){3,}[ \t]*$/gm, key);
  3565. text = globals.converter._dispatch('horizontalRule.after', text, options, globals);
  3566. return text;
  3567. });
  3568. /**
  3569. * Turn Markdown image shortcuts into <img> tags.
  3570. */
  3571. showdown.subParser('images', function (text, options, globals) {
  3572. 'use strict';
  3573. text = globals.converter._dispatch('images.before', text, options, globals);
  3574. var inlineRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g,
  3575. crazyRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<([^>]*)>(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(?:(["'])([^"]*?)\6))?[ \t]?\)/g,
  3576. base64RegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g,
  3577. referenceRegExp = /!\[([^\]]*?)] ?(?:\n *)?\[([\s\S]*?)]()()()()()/g,
  3578. refShortcutRegExp = /!\[([^\[\]]+)]()()()()()/g;
  3579. function writeImageTagBase64 (wholeMatch, altText, linkId, url, width, height, m5, title) {
  3580. url = url.replace(/\s/g, '');
  3581. return writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title);
  3582. }
  3583. function writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title) {
  3584. var gUrls = globals.gUrls,
  3585. gTitles = globals.gTitles,
  3586. gDims = globals.gDimensions;
  3587. linkId = linkId.toLowerCase();
  3588. if (!title) {
  3589. title = '';
  3590. }
  3591. // Special case for explicit empty url
  3592. if (wholeMatch.search(/\(<?\s*>? ?(['"].*['"])?\)$/m) > -1) {
  3593. url = '';
  3594. } else if (url === '' || url === null) {
  3595. if (linkId === '' || linkId === null) {
  3596. // lower-case and turn embedded newlines into spaces
  3597. linkId = altText.toLowerCase().replace(/ ?\n/g, ' ');
  3598. }
  3599. url = '#' + linkId;
  3600. if (!showdown.helper.isUndefined(gUrls[linkId])) {
  3601. url = gUrls[linkId];
  3602. if (!showdown.helper.isUndefined(gTitles[linkId])) {
  3603. title = gTitles[linkId];
  3604. }
  3605. if (!showdown.helper.isUndefined(gDims[linkId])) {
  3606. width = gDims[linkId].width;
  3607. height = gDims[linkId].height;
  3608. }
  3609. } else {
  3610. return wholeMatch;
  3611. }
  3612. }
  3613. altText = altText
  3614. .replace(/"/g, '&quot;')
  3615. //altText = showdown.helper.escapeCharacters(altText, '*_', false);
  3616. .replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  3617. //url = showdown.helper.escapeCharacters(url, '*_', false);
  3618. url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  3619. var result = '<img src="' + url + '" alt="' + altText + '"';
  3620. if (title && showdown.helper.isString(title)) {
  3621. title = title
  3622. .replace(/"/g, '&quot;')
  3623. //title = showdown.helper.escapeCharacters(title, '*_', false);
  3624. .replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  3625. result += ' title="' + title + '"';
  3626. }
  3627. if (width && height) {
  3628. width = (width === '*') ? 'auto' : width;
  3629. height = (height === '*') ? 'auto' : height;
  3630. result += ' width="' + width + '"';
  3631. result += ' height="' + height + '"';
  3632. }
  3633. result += ' />';
  3634. return result;
  3635. }
  3636. // First, handle reference-style labeled images: ![alt text][id]
  3637. text = text.replace(referenceRegExp, writeImageTag);
  3638. // Next, handle inline images: ![alt text](url =<width>x<height> "optional title")
  3639. // base64 encoded images
  3640. text = text.replace(base64RegExp, writeImageTagBase64);
  3641. // cases with crazy urls like ./image/cat1).png
  3642. text = text.replace(crazyRegExp, writeImageTag);
  3643. // normal cases
  3644. text = text.replace(inlineRegExp, writeImageTag);
  3645. // handle reference-style shortcuts: ![img text]
  3646. text = text.replace(refShortcutRegExp, writeImageTag);
  3647. text = globals.converter._dispatch('images.after', text, options, globals);
  3648. return text;
  3649. });
  3650. showdown.subParser('italicsAndBold', function (text, options, globals) {
  3651. 'use strict';
  3652. text = globals.converter._dispatch('italicsAndBold.before', text, options, globals);
  3653. // it's faster to have 3 separate regexes for each case than have just one
  3654. // because of backtracing, in some cases, it could lead to an exponential effect
  3655. // called "catastrophic backtrace". Ominous!
  3656. function parseInside (txt, left, right) {
  3657. /*
  3658. if (options.simplifiedAutoLink) {
  3659. txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals);
  3660. }
  3661. */
  3662. return left + txt + right;
  3663. }
  3664. // Parse underscores
  3665. if (options.literalMidWordUnderscores) {
  3666. text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function (wm, txt) {
  3667. return parseInside (txt, '<strong><em>', '</em></strong>');
  3668. });
  3669. text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function (wm, txt) {
  3670. return parseInside (txt, '<strong>', '</strong>');
  3671. });
  3672. text = text.replace(/\b_(\S[\s\S]*?)_\b/g, function (wm, txt) {
  3673. return parseInside (txt, '<em>', '</em>');
  3674. });
  3675. } else {
  3676. text = text.replace(/___(\S[\s\S]*?)___/g, function (wm, m) {
  3677. return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm;
  3678. });
  3679. text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) {
  3680. return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm;
  3681. });
  3682. text = text.replace(/_([^\s_][\s\S]*?)_/g, function (wm, m) {
  3683. // !/^_[^_]/.test(m) - test if it doesn't start with __ (since it seems redundant, we removed it)
  3684. return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm;
  3685. });
  3686. }
  3687. // Now parse asterisks
  3688. if (options.literalMidWordAsterisks) {
  3689. text = text.replace(/([^*]|^)\B\*\*\*(\S[\s\S]*?)\*\*\*\B(?!\*)/g, function (wm, lead, txt) {
  3690. return parseInside (txt, lead + '<strong><em>', '</em></strong>');
  3691. });
  3692. text = text.replace(/([^*]|^)\B\*\*(\S[\s\S]*?)\*\*\B(?!\*)/g, function (wm, lead, txt) {
  3693. return parseInside (txt, lead + '<strong>', '</strong>');
  3694. });
  3695. text = text.replace(/([^*]|^)\B\*(\S[\s\S]*?)\*\B(?!\*)/g, function (wm, lead, txt) {
  3696. return parseInside (txt, lead + '<em>', '</em>');
  3697. });
  3698. } else {
  3699. text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) {
  3700. return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm;
  3701. });
  3702. text = text.replace(/\*\*(\S[\s\S]*?)\*\*/g, function (wm, m) {
  3703. return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm;
  3704. });
  3705. text = text.replace(/\*([^\s*][\s\S]*?)\*/g, function (wm, m) {
  3706. // !/^\*[^*]/.test(m) - test if it doesn't start with ** (since it seems redundant, we removed it)
  3707. return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm;
  3708. });
  3709. }
  3710. text = globals.converter._dispatch('italicsAndBold.after', text, options, globals);
  3711. return text;
  3712. });
  3713. /**
  3714. * Form HTML ordered (numbered) and unordered (bulleted) lists.
  3715. */
  3716. showdown.subParser('lists', function (text, options, globals) {
  3717. 'use strict';
  3718. /**
  3719. * Process the contents of a single ordered or unordered list, splitting it
  3720. * into individual list items.
  3721. * @param {string} listStr
  3722. * @param {boolean} trimTrailing
  3723. * @returns {string}
  3724. */
  3725. function processListItems (listStr, trimTrailing) {
  3726. // The $g_list_level global keeps track of when we're inside a list.
  3727. // Each time we enter a list, we increment it; when we leave a list,
  3728. // we decrement. If it's zero, we're not in a list anymore.
  3729. //
  3730. // We do this because when we're not inside a list, we want to treat
  3731. // something like this:
  3732. //
  3733. // I recommend upgrading to version
  3734. // 8. Oops, now this line is treated
  3735. // as a sub-list.
  3736. //
  3737. // As a single paragraph, despite the fact that the second line starts
  3738. // with a digit-period-space sequence.
  3739. //
  3740. // Whereas when we're inside a list (or sub-list), that line will be
  3741. // treated as the start of a sub-list. What a kludge, huh? This is
  3742. // an aspect of Markdown's syntax that's hard to parse perfectly
  3743. // without resorting to mind-reading. Perhaps the solution is to
  3744. // change the syntax rules such that sub-lists must start with a
  3745. // starting cardinal number; e.g. "1." or "a.".
  3746. globals.gListLevel++;
  3747. // trim trailing blank lines:
  3748. listStr = listStr.replace(/\n{2,}$/, '\n');
  3749. // attacklab: add sentinel to emulate \z
  3750. listStr += '¨0';
  3751. var rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0| {0,3}([*+-]|\d+[.])[ \t]+))/gm,
  3752. isParagraphed = (/\n[ \t]*\n(?!¨0)/.test(listStr));
  3753. // Since version 1.5, nesting sublists requires 4 spaces (or 1 tab) indentation,
  3754. // which is a syntax breaking change
  3755. // activating this option reverts to old behavior
  3756. if (options.disableForced4SpacesIndentedSublists) {
  3757. rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0|\2([*+-]|\d+[.])[ \t]+))/gm;
  3758. }
  3759. listStr = listStr.replace(rgx, function (wholeMatch, m1, m2, m3, m4, taskbtn, checked) {
  3760. checked = (checked && checked.trim() !== '');
  3761. var item = showdown.subParser('outdent')(m4, options, globals),
  3762. bulletStyle = '';
  3763. // Support for github tasklists
  3764. if (taskbtn && options.tasklists) {
  3765. bulletStyle = ' class="task-list-item" style="list-style-type: none;"';
  3766. item = item.replace(/^[ \t]*\[(x|X| )?]/m, function () {
  3767. var otp = '<input type="checkbox" disabled style="margin: 0px 0.35em 0.25em -1.6em; vertical-align: middle;"';
  3768. if (checked) {
  3769. otp += ' checked';
  3770. }
  3771. otp += '>';
  3772. return otp;
  3773. });
  3774. }
  3775. // ISSUE #312
  3776. // This input: - - - a
  3777. // causes trouble to the parser, since it interprets it as:
  3778. // <ul><li><li><li>a</li></li></li></ul>
  3779. // instead of:
  3780. // <ul><li>- - a</li></ul>
  3781. // So, to prevent it, we will put a marker (¨A)in the beginning of the line
  3782. // Kind of hackish/monkey patching, but seems more effective than overcomplicating the list parser
  3783. item = item.replace(/^([-*+]|\d\.)[ \t]+[\S\n ]*/g, function (wm2) {
  3784. return '¨A' + wm2;
  3785. });
  3786. // m1 - Leading line or
  3787. // Has a double return (multi paragraph) or
  3788. // Has sublist
  3789. if (m1 || (item.search(/\n{2,}/) > -1)) {
  3790. item = showdown.subParser('githubCodeBlocks')(item, options, globals);
  3791. item = showdown.subParser('blockGamut')(item, options, globals);
  3792. } else {
  3793. // Recursion for sub-lists:
  3794. item = showdown.subParser('lists')(item, options, globals);
  3795. item = item.replace(/\n$/, ''); // chomp(item)
  3796. item = showdown.subParser('hashHTMLBlocks')(item, options, globals);
  3797. // Colapse double linebreaks
  3798. item = item.replace(/\n\n+/g, '\n\n');
  3799. if (isParagraphed) {
  3800. item = showdown.subParser('paragraphs')(item, options, globals);
  3801. } else {
  3802. item = showdown.subParser('spanGamut')(item, options, globals);
  3803. }
  3804. }
  3805. // now we need to remove the marker (¨A)
  3806. item = item.replace('¨A', '');
  3807. // we can finally wrap the line in list item tags
  3808. item = '<li' + bulletStyle + '>' + item + '</li>\n';
  3809. return item;
  3810. });
  3811. // attacklab: strip sentinel
  3812. listStr = listStr.replace(/¨0/g, '');
  3813. globals.gListLevel--;
  3814. if (trimTrailing) {
  3815. listStr = listStr.replace(/\s+$/, '');
  3816. }
  3817. return listStr;
  3818. }
  3819. function styleStartNumber (list, listType) {
  3820. // check if ol and starts by a number different than 1
  3821. if (listType === 'ol') {
  3822. var res = list.match(/^ *(\d+)\./);
  3823. if (res && res[1] !== '1') {
  3824. return ' start="' + res[1] + '"';
  3825. }
  3826. }
  3827. return '';
  3828. }
  3829. /**
  3830. * Check and parse consecutive lists (better fix for issue #142)
  3831. * @param {string} list
  3832. * @param {string} listType
  3833. * @param {boolean} trimTrailing
  3834. * @returns {string}
  3835. */
  3836. function parseConsecutiveLists (list, listType, trimTrailing) {
  3837. // check if we caught 2 or more consecutive lists by mistake
  3838. // we use the counterRgx, meaning if listType is UL we look for OL and vice versa
  3839. var olRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?\d+\.[ \t]/gm : /^ {0,3}\d+\.[ \t]/gm,
  3840. ulRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?[*+-][ \t]/gm : /^ {0,3}[*+-][ \t]/gm,
  3841. counterRxg = (listType === 'ul') ? olRgx : ulRgx,
  3842. result = '';
  3843. if (list.search(counterRxg) !== -1) {
  3844. (function parseCL (txt) {
  3845. var pos = txt.search(counterRxg),
  3846. style = styleStartNumber(list, listType);
  3847. if (pos !== -1) {
  3848. // slice
  3849. result += '\n\n<' + listType + style + '>\n' + processListItems(txt.slice(0, pos), !!trimTrailing) + '</' + listType + '>\n';
  3850. // invert counterType and listType
  3851. listType = (listType === 'ul') ? 'ol' : 'ul';
  3852. counterRxg = (listType === 'ul') ? olRgx : ulRgx;
  3853. //recurse
  3854. parseCL(txt.slice(pos));
  3855. } else {
  3856. result += '\n\n<' + listType + style + '>\n' + processListItems(txt, !!trimTrailing) + '</' + listType + '>\n';
  3857. }
  3858. })(list);
  3859. } else {
  3860. var style = styleStartNumber(list, listType);
  3861. result = '\n\n<' + listType + style + '>\n' + processListItems(list, !!trimTrailing) + '</' + listType + '>\n';
  3862. }
  3863. return result;
  3864. }
  3865. /** Start of list parsing **/
  3866. text = globals.converter._dispatch('lists.before', text, options, globals);
  3867. // add sentinel to hack around khtml/safari bug:
  3868. // http://bugs.webkit.org/show_bug.cgi?id=11231
  3869. text += '¨0';
  3870. if (globals.gListLevel) {
  3871. text = text.replace(/^(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,
  3872. function (wholeMatch, list, m2) {
  3873. var listType = (m2.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
  3874. return parseConsecutiveLists(list, listType, true);
  3875. }
  3876. );
  3877. } else {
  3878. text = text.replace(/(\n\n|^\n?)(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,
  3879. function (wholeMatch, m1, list, m3) {
  3880. var listType = (m3.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
  3881. return parseConsecutiveLists(list, listType, false);
  3882. }
  3883. );
  3884. }
  3885. // strip sentinel
  3886. text = text.replace(/¨0/, '');
  3887. text = globals.converter._dispatch('lists.after', text, options, globals);
  3888. return text;
  3889. });
  3890. /**
  3891. * Parse metadata at the top of the document
  3892. */
  3893. showdown.subParser('metadata', function (text, options, globals) {
  3894. 'use strict';
  3895. if (!options.metadata) {
  3896. return text;
  3897. }
  3898. text = globals.converter._dispatch('metadata.before', text, options, globals);
  3899. function parseMetadataContents (content) {
  3900. // raw is raw so it's not changed in any way
  3901. globals.metadata.raw = content;
  3902. // escape chars forbidden in html attributes
  3903. // double quotes
  3904. content = content
  3905. // ampersand first
  3906. .replace(/&/g, '&amp;')
  3907. // double quotes
  3908. .replace(/"/g, '&quot;');
  3909. content = content.replace(/\n {4}/g, ' ');
  3910. content.replace(/^([\S ]+): +([\s\S]+?)$/gm, function (wm, key, value) {
  3911. globals.metadata.parsed[key] = value;
  3912. return '';
  3913. });
  3914. }
  3915. text = text.replace(/^\s*«««+(\S*?)\n([\s\S]+?)\n»»»+\n/, function (wholematch, format, content) {
  3916. parseMetadataContents(content);
  3917. return '¨M';
  3918. });
  3919. text = text.replace(/^\s*---+(\S*?)\n([\s\S]+?)\n---+\n/, function (wholematch, format, content) {
  3920. if (format) {
  3921. globals.metadata.format = format;
  3922. }
  3923. parseMetadataContents(content);
  3924. return '¨M';
  3925. });
  3926. text = text.replace(/¨M/g, '');
  3927. text = globals.converter._dispatch('metadata.after', text, options, globals);
  3928. return text;
  3929. });
  3930. /**
  3931. * Remove one level of line-leading tabs or spaces
  3932. */
  3933. showdown.subParser('outdent', function (text, options, globals) {
  3934. 'use strict';
  3935. text = globals.converter._dispatch('outdent.before', text, options, globals);
  3936. // attacklab: hack around Konqueror 3.5.4 bug:
  3937. // "----------bug".replace(/^-/g,"") == "bug"
  3938. text = text.replace(/^(\t|[ ]{1,4})/gm, '¨0'); // attacklab: g_tab_width
  3939. // attacklab: clean up hack
  3940. text = text.replace(/¨0/g, '');
  3941. text = globals.converter._dispatch('outdent.after', text, options, globals);
  3942. return text;
  3943. });
  3944. /**
  3945. *
  3946. */
  3947. showdown.subParser('paragraphs', function (text, options, globals) {
  3948. 'use strict';
  3949. text = globals.converter._dispatch('paragraphs.before', text, options, globals);
  3950. // Strip leading and trailing lines:
  3951. text = text.replace(/^\n+/g, '');
  3952. text = text.replace(/\n+$/g, '');
  3953. var grafs = text.split(/\n{2,}/g),
  3954. grafsOut = [],
  3955. end = grafs.length; // Wrap <p> tags
  3956. for (var i = 0; i < end; i++) {
  3957. var str = grafs[i];
  3958. // if this is an HTML marker, copy it
  3959. if (str.search(/¨(K|G)(\d+)\1/g) >= 0) {
  3960. grafsOut.push(str);
  3961. // test for presence of characters to prevent empty lines being parsed
  3962. // as paragraphs (resulting in undesired extra empty paragraphs)
  3963. } else if (str.search(/\S/) >= 0) {
  3964. str = showdown.subParser('spanGamut')(str, options, globals);
  3965. str = str.replace(/^([ \t]*)/g, '<p>');
  3966. str += '</p>';
  3967. grafsOut.push(str);
  3968. }
  3969. }
  3970. /** Unhashify HTML blocks */
  3971. end = grafsOut.length;
  3972. for (i = 0; i < end; i++) {
  3973. var blockText = '',
  3974. grafsOutIt = grafsOut[i],
  3975. codeFlag = false;
  3976. // if this is a marker for an html block...
  3977. // use RegExp.test instead of string.search because of QML bug
  3978. while (/¨(K|G)(\d+)\1/.test(grafsOutIt)) {
  3979. var delim = RegExp.$1,
  3980. num = RegExp.$2;
  3981. if (delim === 'K') {
  3982. blockText = globals.gHtmlBlocks[num];
  3983. } else {
  3984. // we need to check if ghBlock is a false positive
  3985. if (codeFlag) {
  3986. // use encoded version of all text
  3987. blockText = showdown.subParser('encodeCode')(globals.ghCodeBlocks[num].text, options, globals);
  3988. } else {
  3989. blockText = globals.ghCodeBlocks[num].codeblock;
  3990. }
  3991. }
  3992. blockText = blockText.replace(/\$/g, '$$$$'); // Escape any dollar signs
  3993. grafsOutIt = grafsOutIt.replace(/(\n\n)?¨(K|G)\d+\2(\n\n)?/, blockText);
  3994. // Check if grafsOutIt is a pre->code
  3995. if (/^<pre\b[^>]*>\s*<code\b[^>]*>/.test(grafsOutIt)) {
  3996. codeFlag = true;
  3997. }
  3998. }
  3999. grafsOut[i] = grafsOutIt;
  4000. }
  4001. text = grafsOut.join('\n');
  4002. // Strip leading and trailing lines:
  4003. text = text.replace(/^\n+/g, '');
  4004. text = text.replace(/\n+$/g, '');
  4005. return globals.converter._dispatch('paragraphs.after', text, options, globals);
  4006. });
  4007. /**
  4008. * Run extension
  4009. */
  4010. showdown.subParser('runExtension', function (ext, text, options, globals) {
  4011. 'use strict';
  4012. if (ext.filter) {
  4013. text = ext.filter(text, globals.converter, options);
  4014. } else if (ext.regex) {
  4015. // TODO remove this when old extension loading mechanism is deprecated
  4016. var re = ext.regex;
  4017. if (!(re instanceof RegExp)) {
  4018. re = new RegExp(re, 'g');
  4019. }
  4020. text = text.replace(re, ext.replace);
  4021. }
  4022. return text;
  4023. });
  4024. /**
  4025. * These are all the transformations that occur *within* block-level
  4026. * tags like paragraphs, headers, and list items.
  4027. */
  4028. showdown.subParser('spanGamut', function (text, options, globals) {
  4029. 'use strict';
  4030. text = globals.converter._dispatch('spanGamut.before', text, options, globals);
  4031. text = showdown.subParser('codeSpans')(text, options, globals);
  4032. text = showdown.subParser('escapeSpecialCharsWithinTagAttributes')(text, options, globals);
  4033. text = showdown.subParser('encodeBackslashEscapes')(text, options, globals);
  4034. // Process anchor and image tags. Images must come first,
  4035. // because ![foo][f] looks like an anchor.
  4036. text = showdown.subParser('images')(text, options, globals);
  4037. text = showdown.subParser('anchors')(text, options, globals);
  4038. // Make links out of things like `<http://example.com/>`
  4039. // Must come after anchors, because you can use < and >
  4040. // delimiters in inline links like [this](<url>).
  4041. text = showdown.subParser('autoLinks')(text, options, globals);
  4042. text = showdown.subParser('simplifiedAutoLinks')(text, options, globals);
  4043. text = showdown.subParser('emoji')(text, options, globals);
  4044. text = showdown.subParser('underline')(text, options, globals);
  4045. text = showdown.subParser('italicsAndBold')(text, options, globals);
  4046. text = showdown.subParser('strikethrough')(text, options, globals);
  4047. text = showdown.subParser('ellipsis')(text, options, globals);
  4048. // we need to hash HTML tags inside spans
  4049. text = showdown.subParser('hashHTMLSpans')(text, options, globals);
  4050. // now we encode amps and angles
  4051. text = showdown.subParser('encodeAmpsAndAngles')(text, options, globals);
  4052. // Do hard breaks
  4053. if (options.simpleLineBreaks) {
  4054. // GFM style hard breaks
  4055. // only add line breaks if the text does not contain a block (special case for lists)
  4056. if (!/\n\n¨K/.test(text)) {
  4057. text = text.replace(/\n+/g, '<br />\n');
  4058. }
  4059. } else {
  4060. // Vanilla hard breaks
  4061. text = text.replace(/ +\n/g, '<br />\n');
  4062. }
  4063. text = globals.converter._dispatch('spanGamut.after', text, options, globals);
  4064. return text;
  4065. });
  4066. showdown.subParser('strikethrough', function (text, options, globals) {
  4067. 'use strict';
  4068. function parseInside (txt) {
  4069. if (options.simplifiedAutoLink) {
  4070. txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals);
  4071. }
  4072. return '<del>' + txt + '</del>';
  4073. }
  4074. if (options.strikethrough) {
  4075. text = globals.converter._dispatch('strikethrough.before', text, options, globals);
  4076. text = text.replace(/(?:~){2}([\s\S]+?)(?:~){2}/g, function (wm, txt) { return parseInside(txt); });
  4077. text = globals.converter._dispatch('strikethrough.after', text, options, globals);
  4078. }
  4079. return text;
  4080. });
  4081. /**
  4082. * Strips link definitions from text, stores the URLs and titles in
  4083. * hash references.
  4084. * Link defs are in the form: ^[id]: url "optional title"
  4085. */
  4086. showdown.subParser('stripLinkDefinitions', function (text, options, globals) {
  4087. 'use strict';
  4088. var regex = /^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*<?([^>\s]+)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=¨0))/gm,
  4089. base64Regex = /^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*<?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n\n|(?=¨0)|(?=\n\[))/gm;
  4090. // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
  4091. text += '¨0';
  4092. var replaceFunc = function (wholeMatch, linkId, url, width, height, blankLines, title) {
  4093. linkId = linkId.toLowerCase();
  4094. if (url.match(/^data:.+?\/.+?;base64,/)) {
  4095. // remove newlines
  4096. globals.gUrls[linkId] = url.replace(/\s/g, '');
  4097. } else {
  4098. globals.gUrls[linkId] = showdown.subParser('encodeAmpsAndAngles')(url, options, globals); // Link IDs are case-insensitive
  4099. }
  4100. if (blankLines) {
  4101. // Oops, found blank lines, so it's not a title.
  4102. // Put back the parenthetical statement we stole.
  4103. return blankLines + title;
  4104. } else {
  4105. if (title) {
  4106. globals.gTitles[linkId] = title.replace(/"|'/g, '&quot;');
  4107. }
  4108. if (options.parseImgDimensions && width && height) {
  4109. globals.gDimensions[linkId] = {
  4110. width: width,
  4111. height: height
  4112. };
  4113. }
  4114. }
  4115. // Completely remove the definition from the text
  4116. return '';
  4117. };
  4118. // first we try to find base64 link references
  4119. text = text.replace(base64Regex, replaceFunc);
  4120. text = text.replace(regex, replaceFunc);
  4121. // attacklab: strip sentinel
  4122. text = text.replace(/¨0/, '');
  4123. return text;
  4124. });
  4125. showdown.subParser('tables', function (text, options, globals) {
  4126. 'use strict';
  4127. if (!options.tables) {
  4128. return text;
  4129. }
  4130. var tableRgx = /^ {0,3}\|?.+\|.+\n {0,3}\|?[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:[-=]){2,}[\s\S]+?(?:\n\n|¨0)/gm,
  4131. //singeColTblRgx = /^ {0,3}\|.+\|\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n(?: {0,3}\|.+\|\n)+(?:\n\n|¨0)/gm;
  4132. singeColTblRgx = /^ {0,3}\|.+\|[ \t]*\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n( {0,3}\|.+\|[ \t]*\n)*(?:\n|¨0)/gm;
  4133. function parseStyles (sLine) {
  4134. if (/^:[ \t]*--*$/.test(sLine)) {
  4135. return ' style="text-align:left;"';
  4136. } else if (/^--*[ \t]*:[ \t]*$/.test(sLine)) {
  4137. return ' style="text-align:right;"';
  4138. } else if (/^:[ \t]*--*[ \t]*:$/.test(sLine)) {
  4139. return ' style="text-align:center;"';
  4140. } else {
  4141. return '';
  4142. }
  4143. }
  4144. function parseHeaders (header, style) {
  4145. var id = '';
  4146. header = header.trim();
  4147. // support both tablesHeaderId and tableHeaderId due to error in documentation so we don't break backwards compatibility
  4148. if (options.tablesHeaderId || options.tableHeaderId) {
  4149. id = ' id="' + header.replace(/ /g, '_').toLowerCase() + '"';
  4150. }
  4151. header = showdown.subParser('spanGamut')(header, options, globals);
  4152. return '<th' + id + style + '>' + header + '</th>\n';
  4153. }
  4154. function parseCells (cell, style) {
  4155. var subText = showdown.subParser('spanGamut')(cell, options, globals);
  4156. return '<td' + style + '>' + subText + '</td>\n';
  4157. }
  4158. function buildTable (headers, cells) {
  4159. var tb = '<table>\n<thead>\n<tr>\n',
  4160. tblLgn = headers.length;
  4161. for (var i = 0; i < tblLgn; ++i) {
  4162. tb += headers[i];
  4163. }
  4164. tb += '</tr>\n</thead>\n<tbody>\n';
  4165. for (i = 0; i < cells.length; ++i) {
  4166. tb += '<tr>\n';
  4167. for (var ii = 0; ii < tblLgn; ++ii) {
  4168. tb += cells[i][ii];
  4169. }
  4170. tb += '</tr>\n';
  4171. }
  4172. tb += '</tbody>\n</table>\n';
  4173. return tb;
  4174. }
  4175. function parseTable (rawTable) {
  4176. var i, tableLines = rawTable.split('\n');
  4177. for (i = 0; i < tableLines.length; ++i) {
  4178. // strip wrong first and last column if wrapped tables are used
  4179. if (/^ {0,3}\|/.test(tableLines[i])) {
  4180. tableLines[i] = tableLines[i].replace(/^ {0,3}\|/, '');
  4181. }
  4182. if (/\|[ \t]*$/.test(tableLines[i])) {
  4183. tableLines[i] = tableLines[i].replace(/\|[ \t]*$/, '');
  4184. }
  4185. // parse code spans first, but we only support one line code spans
  4186. tableLines[i] = showdown.subParser('codeSpans')(tableLines[i], options, globals);
  4187. }
  4188. var rawHeaders = tableLines[0].split('|').map(function (s) { return s.trim();}),
  4189. rawStyles = tableLines[1].split('|').map(function (s) { return s.trim();}),
  4190. rawCells = [],
  4191. headers = [],
  4192. styles = [],
  4193. cells = [];
  4194. tableLines.shift();
  4195. tableLines.shift();
  4196. for (i = 0; i < tableLines.length; ++i) {
  4197. if (tableLines[i].trim() === '') {
  4198. continue;
  4199. }
  4200. rawCells.push(
  4201. tableLines[i]
  4202. .split('|')
  4203. .map(function (s) {
  4204. return s.trim();
  4205. })
  4206. );
  4207. }
  4208. if (rawHeaders.length < rawStyles.length) {
  4209. return rawTable;
  4210. }
  4211. for (i = 0; i < rawStyles.length; ++i) {
  4212. styles.push(parseStyles(rawStyles[i]));
  4213. }
  4214. for (i = 0; i < rawHeaders.length; ++i) {
  4215. if (showdown.helper.isUndefined(styles[i])) {
  4216. styles[i] = '';
  4217. }
  4218. headers.push(parseHeaders(rawHeaders[i], styles[i]));
  4219. }
  4220. for (i = 0; i < rawCells.length; ++i) {
  4221. var row = [];
  4222. for (var ii = 0; ii < headers.length; ++ii) {
  4223. if (showdown.helper.isUndefined(rawCells[i][ii])) {
  4224. }
  4225. row.push(parseCells(rawCells[i][ii], styles[ii]));
  4226. }
  4227. cells.push(row);
  4228. }
  4229. return buildTable(headers, cells);
  4230. }
  4231. text = globals.converter._dispatch('tables.before', text, options, globals);
  4232. // find escaped pipe characters
  4233. text = text.replace(/\\(\|)/g, showdown.helper.escapeCharactersCallback);
  4234. // parse multi column tables
  4235. text = text.replace(tableRgx, parseTable);
  4236. // parse one column tables
  4237. text = text.replace(singeColTblRgx, parseTable);
  4238. text = globals.converter._dispatch('tables.after', text, options, globals);
  4239. return text;
  4240. });
  4241. showdown.subParser('underline', function (text, options, globals) {
  4242. 'use strict';
  4243. if (!options.underline) {
  4244. return text;
  4245. }
  4246. text = globals.converter._dispatch('underline.before', text, options, globals);
  4247. if (options.literalMidWordUnderscores) {
  4248. text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function (wm, txt) {
  4249. return '<u>' + txt + '</u>';
  4250. });
  4251. text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function (wm, txt) {
  4252. return '<u>' + txt + '</u>';
  4253. });
  4254. } else {
  4255. text = text.replace(/___(\S[\s\S]*?)___/g, function (wm, m) {
  4256. return (/\S$/.test(m)) ? '<u>' + m + '</u>' : wm;
  4257. });
  4258. text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) {
  4259. return (/\S$/.test(m)) ? '<u>' + m + '</u>' : wm;
  4260. });
  4261. }
  4262. // escape remaining underscores to prevent them being parsed by italic and bold
  4263. text = text.replace(/(_)/g, showdown.helper.escapeCharactersCallback);
  4264. text = globals.converter._dispatch('underline.after', text, options, globals);
  4265. return text;
  4266. });
  4267. /**
  4268. * Swap back in all the special characters we've hidden.
  4269. */
  4270. showdown.subParser('unescapeSpecialChars', function (text, options, globals) {
  4271. 'use strict';
  4272. text = globals.converter._dispatch('unescapeSpecialChars.before', text, options, globals);
  4273. text = text.replace(/¨E(\d+)E/g, function (wholeMatch, m1) {
  4274. var charCodeToReplace = parseInt(m1);
  4275. return String.fromCharCode(charCodeToReplace);
  4276. });
  4277. text = globals.converter._dispatch('unescapeSpecialChars.after', text, options, globals);
  4278. return text;
  4279. });
  4280. showdown.subParser('makeMarkdown.blockquote', function (node, globals) {
  4281. 'use strict';
  4282. var txt = '';
  4283. if (node.hasChildNodes()) {
  4284. var children = node.childNodes,
  4285. childrenLength = children.length;
  4286. for (var i = 0; i < childrenLength; ++i) {
  4287. var innerTxt = showdown.subParser('makeMarkdown.node')(children[i], globals);
  4288. if (innerTxt === '') {
  4289. continue;
  4290. }
  4291. txt += innerTxt;
  4292. }
  4293. }
  4294. // cleanup
  4295. txt = txt.trim();
  4296. txt = '> ' + txt.split('\n').join('\n> ');
  4297. return txt;
  4298. });
  4299. showdown.subParser('makeMarkdown.codeBlock', function (node, globals) {
  4300. 'use strict';
  4301. var lang = node.getAttribute('language'),
  4302. num = node.getAttribute('precodenum');
  4303. return '```' + lang + '\n' + globals.preList[num] + '\n```';
  4304. });
  4305. showdown.subParser('makeMarkdown.codeSpan', function (node) {
  4306. 'use strict';
  4307. return '`' + node.innerHTML + '`';
  4308. });
  4309. showdown.subParser('makeMarkdown.emphasis', function (node, globals) {
  4310. 'use strict';
  4311. var txt = '';
  4312. if (node.hasChildNodes()) {
  4313. txt += '*';
  4314. var children = node.childNodes,
  4315. childrenLength = children.length;
  4316. for (var i = 0; i < childrenLength; ++i) {
  4317. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4318. }
  4319. txt += '*';
  4320. }
  4321. return txt;
  4322. });
  4323. showdown.subParser('makeMarkdown.header', function (node, globals, headerLevel) {
  4324. 'use strict';
  4325. var headerMark = new Array(headerLevel + 1).join('#'),
  4326. txt = '';
  4327. if (node.hasChildNodes()) {
  4328. txt = headerMark + ' ';
  4329. var children = node.childNodes,
  4330. childrenLength = children.length;
  4331. for (var i = 0; i < childrenLength; ++i) {
  4332. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4333. }
  4334. }
  4335. return txt;
  4336. });
  4337. showdown.subParser('makeMarkdown.hr', function () {
  4338. 'use strict';
  4339. return '---';
  4340. });
  4341. showdown.subParser('makeMarkdown.image', function (node) {
  4342. 'use strict';
  4343. var txt = '';
  4344. if (node.hasAttribute('src')) {
  4345. txt += '![' + node.getAttribute('alt') + '](';
  4346. txt += '<' + node.getAttribute('src') + '>';
  4347. if (node.hasAttribute('width') && node.hasAttribute('height')) {
  4348. txt += ' =' + node.getAttribute('width') + 'x' + node.getAttribute('height');
  4349. }
  4350. if (node.hasAttribute('title')) {
  4351. txt += ' "' + node.getAttribute('title') + '"';
  4352. }
  4353. txt += ')';
  4354. }
  4355. return txt;
  4356. });
  4357. showdown.subParser('makeMarkdown.links', function (node, globals) {
  4358. 'use strict';
  4359. var txt = '';
  4360. if (node.hasChildNodes() && node.hasAttribute('href')) {
  4361. var children = node.childNodes,
  4362. childrenLength = children.length;
  4363. txt = '[';
  4364. for (var i = 0; i < childrenLength; ++i) {
  4365. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4366. }
  4367. txt += '](';
  4368. txt += '<' + node.getAttribute('href') + '>';
  4369. if (node.hasAttribute('title')) {
  4370. txt += ' "' + node.getAttribute('title') + '"';
  4371. }
  4372. txt += ')';
  4373. }
  4374. return txt;
  4375. });
  4376. showdown.subParser('makeMarkdown.list', function (node, globals, type) {
  4377. 'use strict';
  4378. var txt = '';
  4379. if (!node.hasChildNodes()) {
  4380. return '';
  4381. }
  4382. var listItems = node.childNodes,
  4383. listItemsLenght = listItems.length,
  4384. listNum = node.getAttribute('start') || 1;
  4385. for (var i = 0; i < listItemsLenght; ++i) {
  4386. if (typeof listItems[i].tagName === 'undefined' || listItems[i].tagName.toLowerCase() !== 'li') {
  4387. continue;
  4388. }
  4389. // define the bullet to use in list
  4390. var bullet = '';
  4391. if (type === 'ol') {
  4392. bullet = listNum.toString() + '. ';
  4393. } else {
  4394. bullet = '- ';
  4395. }
  4396. // parse list item
  4397. txt += bullet + showdown.subParser('makeMarkdown.listItem')(listItems[i], globals);
  4398. ++listNum;
  4399. }
  4400. // add comment at the end to prevent consecutive lists to be parsed as one
  4401. txt += '\n<!-- -->\n';
  4402. return txt.trim();
  4403. });
  4404. showdown.subParser('makeMarkdown.listItem', function (node, globals) {
  4405. 'use strict';
  4406. var listItemTxt = '';
  4407. var children = node.childNodes,
  4408. childrenLenght = children.length;
  4409. for (var i = 0; i < childrenLenght; ++i) {
  4410. listItemTxt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4411. }
  4412. // if it's only one liner, we need to add a newline at the end
  4413. if (!/\n$/.test(listItemTxt)) {
  4414. listItemTxt += '\n';
  4415. } else {
  4416. // it's multiparagraph, so we need to indent
  4417. listItemTxt = listItemTxt
  4418. .split('\n')
  4419. .join('\n ')
  4420. .replace(/^ {4}$/gm, '')
  4421. .replace(/\n\n+/g, '\n\n');
  4422. }
  4423. return listItemTxt;
  4424. });
  4425. showdown.subParser('makeMarkdown.node', function (node, globals, spansOnly) {
  4426. 'use strict';
  4427. spansOnly = spansOnly || false;
  4428. var txt = '';
  4429. // edge case of text without wrapper paragraph
  4430. if (node.nodeType === 3) {
  4431. return showdown.subParser('makeMarkdown.txt')(node, globals);
  4432. }
  4433. // HTML comment
  4434. if (node.nodeType === 8) {
  4435. return '<!--' + node.data + '-->\n\n';
  4436. }
  4437. // process only node elements
  4438. if (node.nodeType !== 1) {
  4439. return '';
  4440. }
  4441. var tagName = node.tagName.toLowerCase();
  4442. switch (tagName) {
  4443. //
  4444. // BLOCKS
  4445. //
  4446. case 'h1':
  4447. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 1) + '\n\n'; }
  4448. break;
  4449. case 'h2':
  4450. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 2) + '\n\n'; }
  4451. break;
  4452. case 'h3':
  4453. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 3) + '\n\n'; }
  4454. break;
  4455. case 'h4':
  4456. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 4) + '\n\n'; }
  4457. break;
  4458. case 'h5':
  4459. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 5) + '\n\n'; }
  4460. break;
  4461. case 'h6':
  4462. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 6) + '\n\n'; }
  4463. break;
  4464. case 'p':
  4465. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.paragraph')(node, globals) + '\n\n'; }
  4466. break;
  4467. case 'blockquote':
  4468. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.blockquote')(node, globals) + '\n\n'; }
  4469. break;
  4470. case 'hr':
  4471. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.hr')(node, globals) + '\n\n'; }
  4472. break;
  4473. case 'ol':
  4474. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.list')(node, globals, 'ol') + '\n\n'; }
  4475. break;
  4476. case 'ul':
  4477. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.list')(node, globals, 'ul') + '\n\n'; }
  4478. break;
  4479. case 'precode':
  4480. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.codeBlock')(node, globals) + '\n\n'; }
  4481. break;
  4482. case 'pre':
  4483. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.pre')(node, globals) + '\n\n'; }
  4484. break;
  4485. case 'table':
  4486. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.table')(node, globals) + '\n\n'; }
  4487. break;
  4488. //
  4489. // SPANS
  4490. //
  4491. case 'code':
  4492. txt = showdown.subParser('makeMarkdown.codeSpan')(node, globals);
  4493. break;
  4494. case 'em':
  4495. case 'i':
  4496. txt = showdown.subParser('makeMarkdown.emphasis')(node, globals);
  4497. break;
  4498. case 'strong':
  4499. case 'b':
  4500. txt = showdown.subParser('makeMarkdown.strong')(node, globals);
  4501. break;
  4502. case 'del':
  4503. txt = showdown.subParser('makeMarkdown.strikethrough')(node, globals);
  4504. break;
  4505. case 'a':
  4506. txt = showdown.subParser('makeMarkdown.links')(node, globals);
  4507. break;
  4508. case 'img':
  4509. txt = showdown.subParser('makeMarkdown.image')(node, globals);
  4510. break;
  4511. default:
  4512. txt = node.outerHTML + '\n\n';
  4513. }
  4514. // common normalization
  4515. // TODO eventually
  4516. return txt;
  4517. });
  4518. showdown.subParser('makeMarkdown.paragraph', function (node, globals) {
  4519. 'use strict';
  4520. var txt = '';
  4521. if (node.hasChildNodes()) {
  4522. var children = node.childNodes,
  4523. childrenLength = children.length;
  4524. for (var i = 0; i < childrenLength; ++i) {
  4525. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4526. }
  4527. }
  4528. // some text normalization
  4529. txt = txt.trim();
  4530. return txt;
  4531. });
  4532. showdown.subParser('makeMarkdown.pre', function (node, globals) {
  4533. 'use strict';
  4534. var num = node.getAttribute('prenum');
  4535. return '<pre>' + globals.preList[num] + '</pre>';
  4536. });
  4537. showdown.subParser('makeMarkdown.strikethrough', function (node, globals) {
  4538. 'use strict';
  4539. var txt = '';
  4540. if (node.hasChildNodes()) {
  4541. txt += '~~';
  4542. var children = node.childNodes,
  4543. childrenLength = children.length;
  4544. for (var i = 0; i < childrenLength; ++i) {
  4545. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4546. }
  4547. txt += '~~';
  4548. }
  4549. return txt;
  4550. });
  4551. showdown.subParser('makeMarkdown.strong', function (node, globals) {
  4552. 'use strict';
  4553. var txt = '';
  4554. if (node.hasChildNodes()) {
  4555. txt += '**';
  4556. var children = node.childNodes,
  4557. childrenLength = children.length;
  4558. for (var i = 0; i < childrenLength; ++i) {
  4559. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4560. }
  4561. txt += '**';
  4562. }
  4563. return txt;
  4564. });
  4565. showdown.subParser('makeMarkdown.table', function (node, globals) {
  4566. 'use strict';
  4567. var txt = '',
  4568. tableArray = [[], []],
  4569. headings = node.querySelectorAll('thead>tr>th'),
  4570. rows = node.querySelectorAll('tbody>tr'),
  4571. i, ii;
  4572. for (i = 0; i < headings.length; ++i) {
  4573. var headContent = showdown.subParser('makeMarkdown.tableCell')(headings[i], globals),
  4574. allign = '---';
  4575. if (headings[i].hasAttribute('style')) {
  4576. var style = headings[i].getAttribute('style').toLowerCase().replace(/\s/g, '');
  4577. switch (style) {
  4578. case 'text-align:left;':
  4579. allign = ':---';
  4580. break;
  4581. case 'text-align:right;':
  4582. allign = '---:';
  4583. break;
  4584. case 'text-align:center;':
  4585. allign = ':---:';
  4586. break;
  4587. }
  4588. }
  4589. tableArray[0][i] = headContent.trim();
  4590. tableArray[1][i] = allign;
  4591. }
  4592. for (i = 0; i < rows.length; ++i) {
  4593. var r = tableArray.push([]) - 1,
  4594. cols = rows[i].getElementsByTagName('td');
  4595. for (ii = 0; ii < headings.length; ++ii) {
  4596. var cellContent = ' ';
  4597. if (typeof cols[ii] !== 'undefined') {
  4598. cellContent = showdown.subParser('makeMarkdown.tableCell')(cols[ii], globals);
  4599. }
  4600. tableArray[r].push(cellContent);
  4601. }
  4602. }
  4603. var cellSpacesCount = 3;
  4604. for (i = 0; i < tableArray.length; ++i) {
  4605. for (ii = 0; ii < tableArray[i].length; ++ii) {
  4606. var strLen = tableArray[i][ii].length;
  4607. if (strLen > cellSpacesCount) {
  4608. cellSpacesCount = strLen;
  4609. }
  4610. }
  4611. }
  4612. for (i = 0; i < tableArray.length; ++i) {
  4613. for (ii = 0; ii < tableArray[i].length; ++ii) {
  4614. if (i === 1) {
  4615. if (tableArray[i][ii].slice(-1) === ':') {
  4616. tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii].slice(-1), cellSpacesCount - 1, '-') + ':';
  4617. } else {
  4618. tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii], cellSpacesCount, '-');
  4619. }
  4620. } else {
  4621. tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii], cellSpacesCount);
  4622. }
  4623. }
  4624. txt += '| ' + tableArray[i].join(' | ') + ' |\n';
  4625. }
  4626. return txt.trim();
  4627. });
  4628. showdown.subParser('makeMarkdown.tableCell', function (node, globals) {
  4629. 'use strict';
  4630. var txt = '';
  4631. if (!node.hasChildNodes()) {
  4632. return '';
  4633. }
  4634. var children = node.childNodes,
  4635. childrenLength = children.length;
  4636. for (var i = 0; i < childrenLength; ++i) {
  4637. txt += showdown.subParser('makeMarkdown.node')(children[i], globals, true);
  4638. }
  4639. return txt.trim();
  4640. });
  4641. showdown.subParser('makeMarkdown.txt', function (node) {
  4642. 'use strict';
  4643. var txt = node.nodeValue;
  4644. // multiple spaces are collapsed
  4645. txt = txt.replace(/ +/g, ' ');
  4646. // replace the custom ¨NBSP; with a space
  4647. txt = txt.replace(/¨NBSP;/g, ' ');
  4648. // ", <, > and & should replace escaped html entities
  4649. txt = showdown.helper.unescapeHTMLEntities(txt);
  4650. // escape markdown magic characters
  4651. // emphasis, strong and strikethrough - can appear everywhere
  4652. // we also escape pipe (|) because of tables
  4653. // and escape ` because of code blocks and spans
  4654. txt = txt.replace(/([*_~|`])/g, '\\$1');
  4655. // escape > because of blockquotes
  4656. txt = txt.replace(/^(\s*)>/g, '\\$1>');
  4657. // hash character, only troublesome at the beginning of a line because of headers
  4658. txt = txt.replace(/^#/gm, '\\#');
  4659. // horizontal rules
  4660. txt = txt.replace(/^(\s*)([-=]{3,})(\s*)$/, '$1\\$2$3');
  4661. // dot, because of ordered lists, only troublesome at the beginning of a line when preceded by an integer
  4662. txt = txt.replace(/^( {0,3}\d+)\./gm, '$1\\.');
  4663. // +, * and -, at the beginning of a line becomes a list, so we need to escape them also (asterisk was already escaped)
  4664. txt = txt.replace(/^( {0,3})([+-])/gm, '$1\\$2');
  4665. // images and links, ] followed by ( is problematic, so we escape it
  4666. txt = txt.replace(/]([\s]*)\(/g, '\\]$1\\(');
  4667. // reference URIs must also be escaped
  4668. txt = txt.replace(/^ {0,3}\[([\S \t]*?)]:/gm, '\\[$1]:');
  4669. return txt;
  4670. });
  4671. var root = this;
  4672. // AMD Loader
  4673. if (true) {
  4674. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
  4675. 'use strict';
  4676. return showdown;
  4677. }).call(exports, __webpack_require__, exports, module),
  4678. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  4679. // CommonJS/nodeJS Loader
  4680. } else {}
  4681. }).call(this);
  4682. /***/ })
  4683. /******/ });
  4684. /************************************************************************/
  4685. /******/ // The module cache
  4686. /******/ var __webpack_module_cache__ = {};
  4687. /******/
  4688. /******/ // The require function
  4689. /******/ function __webpack_require__(moduleId) {
  4690. /******/ // Check if module is in cache
  4691. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  4692. /******/ if (cachedModule !== undefined) {
  4693. /******/ return cachedModule.exports;
  4694. /******/ }
  4695. /******/ // Create a new module (and put it into the cache)
  4696. /******/ var module = __webpack_module_cache__[moduleId] = {
  4697. /******/ // no module.id needed
  4698. /******/ // no module.loaded needed
  4699. /******/ exports: {}
  4700. /******/ };
  4701. /******/
  4702. /******/ // Execute the module function
  4703. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  4704. /******/
  4705. /******/ // Return the exports of the module
  4706. /******/ return module.exports;
  4707. /******/ }
  4708. /******/
  4709. /************************************************************************/
  4710. /******/ /* webpack/runtime/compat get default export */
  4711. /******/ !function() {
  4712. /******/ // getDefaultExport function for compatibility with non-harmony modules
  4713. /******/ __webpack_require__.n = function(module) {
  4714. /******/ var getter = module && module.__esModule ?
  4715. /******/ function() { return module['default']; } :
  4716. /******/ function() { return module; };
  4717. /******/ __webpack_require__.d(getter, { a: getter });
  4718. /******/ return getter;
  4719. /******/ };
  4720. /******/ }();
  4721. /******/
  4722. /******/ /* webpack/runtime/define property getters */
  4723. /******/ !function() {
  4724. /******/ // define getter functions for harmony exports
  4725. /******/ __webpack_require__.d = function(exports, definition) {
  4726. /******/ for(var key in definition) {
  4727. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  4728. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  4729. /******/ }
  4730. /******/ }
  4731. /******/ };
  4732. /******/ }();
  4733. /******/
  4734. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  4735. /******/ !function() {
  4736. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  4737. /******/ }();
  4738. /******/
  4739. /******/ /* webpack/runtime/make namespace object */
  4740. /******/ !function() {
  4741. /******/ // define __esModule on exports
  4742. /******/ __webpack_require__.r = function(exports) {
  4743. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  4744. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  4745. /******/ }
  4746. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  4747. /******/ };
  4748. /******/ }();
  4749. /******/
  4750. /************************************************************************/
  4751. var __webpack_exports__ = {};
  4752. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  4753. !function() {
  4754. "use strict";
  4755. // ESM COMPAT FLAG
  4756. __webpack_require__.r(__webpack_exports__);
  4757. // EXPORTS
  4758. __webpack_require__.d(__webpack_exports__, {
  4759. "__EXPERIMENTAL_ELEMENTS": function() { return /* reexport */ __EXPERIMENTAL_ELEMENTS; },
  4760. "__EXPERIMENTAL_PATHS_WITH_MERGE": function() { return /* reexport */ __EXPERIMENTAL_PATHS_WITH_MERGE; },
  4761. "__EXPERIMENTAL_STYLE_PROPERTY": function() { return /* reexport */ __EXPERIMENTAL_STYLE_PROPERTY; },
  4762. "__experimentalCloneSanitizedBlock": function() { return /* reexport */ __experimentalCloneSanitizedBlock; },
  4763. "__experimentalGetAccessibleBlockLabel": function() { return /* reexport */ getAccessibleBlockLabel; },
  4764. "__experimentalGetBlockAttributesNamesByRole": function() { return /* reexport */ __experimentalGetBlockAttributesNamesByRole; },
  4765. "__experimentalGetBlockLabel": function() { return /* reexport */ getBlockLabel; },
  4766. "__experimentalSanitizeBlockAttributes": function() { return /* reexport */ __experimentalSanitizeBlockAttributes; },
  4767. "__unstableGetBlockProps": function() { return /* reexport */ getBlockProps; },
  4768. "__unstableGetInnerBlocksProps": function() { return /* reexport */ getInnerBlocksProps; },
  4769. "__unstableSerializeAndClean": function() { return /* reexport */ __unstableSerializeAndClean; },
  4770. "children": function() { return /* reexport */ children; },
  4771. "cloneBlock": function() { return /* reexport */ cloneBlock; },
  4772. "createBlock": function() { return /* reexport */ createBlock; },
  4773. "createBlocksFromInnerBlocksTemplate": function() { return /* reexport */ createBlocksFromInnerBlocksTemplate; },
  4774. "doBlocksMatchTemplate": function() { return /* reexport */ doBlocksMatchTemplate; },
  4775. "findTransform": function() { return /* reexport */ findTransform; },
  4776. "getBlockAttributes": function() { return /* reexport */ getBlockAttributes; },
  4777. "getBlockContent": function() { return /* reexport */ getBlockInnerHTML; },
  4778. "getBlockDefaultClassName": function() { return /* reexport */ getBlockDefaultClassName; },
  4779. "getBlockFromExample": function() { return /* reexport */ getBlockFromExample; },
  4780. "getBlockMenuDefaultClassName": function() { return /* reexport */ getBlockMenuDefaultClassName; },
  4781. "getBlockSupport": function() { return /* reexport */ registration_getBlockSupport; },
  4782. "getBlockTransforms": function() { return /* reexport */ getBlockTransforms; },
  4783. "getBlockType": function() { return /* reexport */ registration_getBlockType; },
  4784. "getBlockTypes": function() { return /* reexport */ registration_getBlockTypes; },
  4785. "getBlockVariations": function() { return /* reexport */ registration_getBlockVariations; },
  4786. "getCategories": function() { return /* reexport */ categories_getCategories; },
  4787. "getChildBlockNames": function() { return /* reexport */ registration_getChildBlockNames; },
  4788. "getDefaultBlockName": function() { return /* reexport */ registration_getDefaultBlockName; },
  4789. "getFreeformContentHandlerName": function() { return /* reexport */ getFreeformContentHandlerName; },
  4790. "getGroupingBlockName": function() { return /* reexport */ registration_getGroupingBlockName; },
  4791. "getPhrasingContentSchema": function() { return /* reexport */ deprecatedGetPhrasingContentSchema; },
  4792. "getPossibleBlockTransformations": function() { return /* reexport */ getPossibleBlockTransformations; },
  4793. "getSaveContent": function() { return /* reexport */ getSaveContent; },
  4794. "getSaveElement": function() { return /* reexport */ getSaveElement; },
  4795. "getUnregisteredTypeHandlerName": function() { return /* reexport */ getUnregisteredTypeHandlerName; },
  4796. "hasBlockSupport": function() { return /* reexport */ registration_hasBlockSupport; },
  4797. "hasChildBlocks": function() { return /* reexport */ registration_hasChildBlocks; },
  4798. "hasChildBlocksWithInserterSupport": function() { return /* reexport */ registration_hasChildBlocksWithInserterSupport; },
  4799. "isReusableBlock": function() { return /* reexport */ isReusableBlock; },
  4800. "isTemplatePart": function() { return /* reexport */ isTemplatePart; },
  4801. "isUnmodifiedDefaultBlock": function() { return /* reexport */ isUnmodifiedDefaultBlock; },
  4802. "isValidBlockContent": function() { return /* reexport */ isValidBlockContent; },
  4803. "isValidIcon": function() { return /* reexport */ isValidIcon; },
  4804. "node": function() { return /* reexport */ node; },
  4805. "normalizeIconObject": function() { return /* reexport */ normalizeIconObject; },
  4806. "parse": function() { return /* reexport */ parser_parse; },
  4807. "parseWithAttributeSchema": function() { return /* reexport */ parseWithAttributeSchema; },
  4808. "pasteHandler": function() { return /* reexport */ pasteHandler; },
  4809. "rawHandler": function() { return /* reexport */ rawHandler; },
  4810. "registerBlockCollection": function() { return /* reexport */ registerBlockCollection; },
  4811. "registerBlockStyle": function() { return /* reexport */ registerBlockStyle; },
  4812. "registerBlockType": function() { return /* reexport */ registerBlockType; },
  4813. "registerBlockVariation": function() { return /* reexport */ registerBlockVariation; },
  4814. "serialize": function() { return /* reexport */ serializer_serialize; },
  4815. "serializeRawBlock": function() { return /* reexport */ serializeRawBlock; },
  4816. "setCategories": function() { return /* reexport */ categories_setCategories; },
  4817. "setDefaultBlockName": function() { return /* reexport */ setDefaultBlockName; },
  4818. "setFreeformContentHandlerName": function() { return /* reexport */ setFreeformContentHandlerName; },
  4819. "setGroupingBlockName": function() { return /* reexport */ setGroupingBlockName; },
  4820. "setUnregisteredTypeHandlerName": function() { return /* reexport */ setUnregisteredTypeHandlerName; },
  4821. "store": function() { return /* reexport */ store; },
  4822. "switchToBlockType": function() { return /* reexport */ switchToBlockType; },
  4823. "synchronizeBlocksWithTemplate": function() { return /* reexport */ synchronizeBlocksWithTemplate; },
  4824. "unregisterBlockStyle": function() { return /* reexport */ unregisterBlockStyle; },
  4825. "unregisterBlockType": function() { return /* reexport */ unregisterBlockType; },
  4826. "unregisterBlockVariation": function() { return /* reexport */ unregisterBlockVariation; },
  4827. "unstable__bootstrapServerSideBlockDefinitions": function() { return /* reexport */ unstable__bootstrapServerSideBlockDefinitions; },
  4828. "updateCategory": function() { return /* reexport */ categories_updateCategory; },
  4829. "validateBlock": function() { return /* reexport */ validateBlock; },
  4830. "withBlockContentContext": function() { return /* reexport */ withBlockContentContext; }
  4831. });
  4832. // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/selectors.js
  4833. var selectors_namespaceObject = {};
  4834. __webpack_require__.r(selectors_namespaceObject);
  4835. __webpack_require__.d(selectors_namespaceObject, {
  4836. "__experimentalGetUnprocessedBlockTypes": function() { return __experimentalGetUnprocessedBlockTypes; },
  4837. "getActiveBlockVariation": function() { return getActiveBlockVariation; },
  4838. "getBlockStyles": function() { return getBlockStyles; },
  4839. "getBlockSupport": function() { return getBlockSupport; },
  4840. "getBlockType": function() { return getBlockType; },
  4841. "getBlockTypes": function() { return getBlockTypes; },
  4842. "getBlockVariations": function() { return getBlockVariations; },
  4843. "getCategories": function() { return getCategories; },
  4844. "getChildBlockNames": function() { return getChildBlockNames; },
  4845. "getCollections": function() { return getCollections; },
  4846. "getDefaultBlockName": function() { return getDefaultBlockName; },
  4847. "getDefaultBlockVariation": function() { return getDefaultBlockVariation; },
  4848. "getFreeformFallbackBlockName": function() { return getFreeformFallbackBlockName; },
  4849. "getGroupingBlockName": function() { return getGroupingBlockName; },
  4850. "getUnregisteredFallbackBlockName": function() { return getUnregisteredFallbackBlockName; },
  4851. "hasBlockSupport": function() { return hasBlockSupport; },
  4852. "hasChildBlocks": function() { return hasChildBlocks; },
  4853. "hasChildBlocksWithInserterSupport": function() { return hasChildBlocksWithInserterSupport; },
  4854. "isMatchingSearchTerm": function() { return isMatchingSearchTerm; }
  4855. });
  4856. // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/actions.js
  4857. var actions_namespaceObject = {};
  4858. __webpack_require__.r(actions_namespaceObject);
  4859. __webpack_require__.d(actions_namespaceObject, {
  4860. "__experimentalReapplyBlockTypeFilters": function() { return __experimentalReapplyBlockTypeFilters; },
  4861. "__experimentalRegisterBlockType": function() { return __experimentalRegisterBlockType; },
  4862. "addBlockCollection": function() { return addBlockCollection; },
  4863. "addBlockStyles": function() { return addBlockStyles; },
  4864. "addBlockTypes": function() { return addBlockTypes; },
  4865. "addBlockVariations": function() { return addBlockVariations; },
  4866. "removeBlockCollection": function() { return removeBlockCollection; },
  4867. "removeBlockStyles": function() { return removeBlockStyles; },
  4868. "removeBlockTypes": function() { return removeBlockTypes; },
  4869. "removeBlockVariations": function() { return removeBlockVariations; },
  4870. "setCategories": function() { return setCategories; },
  4871. "setDefaultBlockName": function() { return actions_setDefaultBlockName; },
  4872. "setFreeformFallbackBlockName": function() { return setFreeformFallbackBlockName; },
  4873. "setGroupingBlockName": function() { return actions_setGroupingBlockName; },
  4874. "setUnregisteredFallbackBlockName": function() { return setUnregisteredFallbackBlockName; },
  4875. "updateCategory": function() { return updateCategory; }
  4876. });
  4877. ;// CONCATENATED MODULE: external ["wp","data"]
  4878. var external_wp_data_namespaceObject = window["wp"]["data"];
  4879. ;// CONCATENATED MODULE: external "lodash"
  4880. var external_lodash_namespaceObject = window["lodash"];
  4881. ;// CONCATENATED MODULE: external ["wp","i18n"]
  4882. var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
  4883. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/reducer.js
  4884. /**
  4885. * External dependencies
  4886. */
  4887. /**
  4888. * WordPress dependencies
  4889. */
  4890. /**
  4891. * @typedef {Object} WPBlockCategory
  4892. *
  4893. * @property {string} slug Unique category slug.
  4894. * @property {string} title Category label, for display in user interface.
  4895. */
  4896. /**
  4897. * Default set of categories.
  4898. *
  4899. * @type {WPBlockCategory[]}
  4900. */
  4901. const DEFAULT_CATEGORIES = [{
  4902. slug: 'text',
  4903. title: (0,external_wp_i18n_namespaceObject.__)('Text')
  4904. }, {
  4905. slug: 'media',
  4906. title: (0,external_wp_i18n_namespaceObject.__)('Media')
  4907. }, {
  4908. slug: 'design',
  4909. title: (0,external_wp_i18n_namespaceObject.__)('Design')
  4910. }, {
  4911. slug: 'widgets',
  4912. title: (0,external_wp_i18n_namespaceObject.__)('Widgets')
  4913. }, {
  4914. slug: 'theme',
  4915. title: (0,external_wp_i18n_namespaceObject.__)('Theme')
  4916. }, {
  4917. slug: 'embed',
  4918. title: (0,external_wp_i18n_namespaceObject.__)('Embeds')
  4919. }, {
  4920. slug: 'reusable',
  4921. title: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks')
  4922. }];
  4923. /**
  4924. * Reducer managing the unprocessed block types in a form passed when registering the by block.
  4925. * It's for internal use only. It allows recomputing the processed block types on-demand after block type filters
  4926. * get added or removed.
  4927. *
  4928. * @param {Object} state Current state.
  4929. * @param {Object} action Dispatched action.
  4930. *
  4931. * @return {Object} Updated state.
  4932. */
  4933. function unprocessedBlockTypes() {
  4934. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4935. let action = arguments.length > 1 ? arguments[1] : undefined;
  4936. switch (action.type) {
  4937. case 'ADD_UNPROCESSED_BLOCK_TYPE':
  4938. return { ...state,
  4939. [action.blockType.name]: action.blockType
  4940. };
  4941. case 'REMOVE_BLOCK_TYPES':
  4942. return (0,external_lodash_namespaceObject.omit)(state, action.names);
  4943. }
  4944. return state;
  4945. }
  4946. /**
  4947. * Reducer managing the processed block types with all filters applied.
  4948. * The state is derived from the `unprocessedBlockTypes` reducer.
  4949. *
  4950. * @param {Object} state Current state.
  4951. * @param {Object} action Dispatched action.
  4952. *
  4953. * @return {Object} Updated state.
  4954. */
  4955. function blockTypes() {
  4956. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4957. let action = arguments.length > 1 ? arguments[1] : undefined;
  4958. switch (action.type) {
  4959. case 'ADD_BLOCK_TYPES':
  4960. return { ...state,
  4961. ...(0,external_lodash_namespaceObject.keyBy)(action.blockTypes, 'name')
  4962. };
  4963. case 'REMOVE_BLOCK_TYPES':
  4964. return (0,external_lodash_namespaceObject.omit)(state, action.names);
  4965. }
  4966. return state;
  4967. }
  4968. /**
  4969. * Reducer managing the block style variations.
  4970. *
  4971. * @param {Object} state Current state.
  4972. * @param {Object} action Dispatched action.
  4973. *
  4974. * @return {Object} Updated state.
  4975. */
  4976. function blockStyles() {
  4977. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4978. let action = arguments.length > 1 ? arguments[1] : undefined;
  4979. switch (action.type) {
  4980. case 'ADD_BLOCK_TYPES':
  4981. return { ...state,
  4982. ...(0,external_lodash_namespaceObject.mapValues)((0,external_lodash_namespaceObject.keyBy)(action.blockTypes, 'name'), blockType => {
  4983. return (0,external_lodash_namespaceObject.uniqBy)([...(0,external_lodash_namespaceObject.get)(blockType, ['styles'], []).map(style => ({ ...style,
  4984. source: 'block'
  4985. })), ...(0,external_lodash_namespaceObject.get)(state, [blockType.name], []).filter(_ref => {
  4986. let {
  4987. source
  4988. } = _ref;
  4989. return 'block' !== source;
  4990. })], style => style.name);
  4991. })
  4992. };
  4993. case 'ADD_BLOCK_STYLES':
  4994. return { ...state,
  4995. [action.blockName]: (0,external_lodash_namespaceObject.uniqBy)([...(0,external_lodash_namespaceObject.get)(state, [action.blockName], []), ...action.styles], style => style.name)
  4996. };
  4997. case 'REMOVE_BLOCK_STYLES':
  4998. return { ...state,
  4999. [action.blockName]: (0,external_lodash_namespaceObject.filter)((0,external_lodash_namespaceObject.get)(state, [action.blockName], []), style => action.styleNames.indexOf(style.name) === -1)
  5000. };
  5001. }
  5002. return state;
  5003. }
  5004. /**
  5005. * Reducer managing the block variations.
  5006. *
  5007. * @param {Object} state Current state.
  5008. * @param {Object} action Dispatched action.
  5009. *
  5010. * @return {Object} Updated state.
  5011. */
  5012. function blockVariations() {
  5013. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  5014. let action = arguments.length > 1 ? arguments[1] : undefined;
  5015. switch (action.type) {
  5016. case 'ADD_BLOCK_TYPES':
  5017. return { ...state,
  5018. ...(0,external_lodash_namespaceObject.mapValues)((0,external_lodash_namespaceObject.keyBy)(action.blockTypes, 'name'), blockType => {
  5019. return (0,external_lodash_namespaceObject.uniqBy)([...(0,external_lodash_namespaceObject.get)(blockType, ['variations'], []).map(variation => ({ ...variation,
  5020. source: 'block'
  5021. })), ...(0,external_lodash_namespaceObject.get)(state, [blockType.name], []).filter(_ref2 => {
  5022. let {
  5023. source
  5024. } = _ref2;
  5025. return 'block' !== source;
  5026. })], variation => variation.name);
  5027. })
  5028. };
  5029. case 'ADD_BLOCK_VARIATIONS':
  5030. return { ...state,
  5031. [action.blockName]: (0,external_lodash_namespaceObject.uniqBy)([...(0,external_lodash_namespaceObject.get)(state, [action.blockName], []), ...action.variations], variation => variation.name)
  5032. };
  5033. case 'REMOVE_BLOCK_VARIATIONS':
  5034. return { ...state,
  5035. [action.blockName]: (0,external_lodash_namespaceObject.filter)((0,external_lodash_namespaceObject.get)(state, [action.blockName], []), variation => action.variationNames.indexOf(variation.name) === -1)
  5036. };
  5037. }
  5038. return state;
  5039. }
  5040. /**
  5041. * Higher-order Reducer creating a reducer keeping track of given block name.
  5042. *
  5043. * @param {string} setActionType Action type.
  5044. *
  5045. * @return {Function} Reducer.
  5046. */
  5047. function createBlockNameSetterReducer(setActionType) {
  5048. return function () {
  5049. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  5050. let action = arguments.length > 1 ? arguments[1] : undefined;
  5051. switch (action.type) {
  5052. case 'REMOVE_BLOCK_TYPES':
  5053. if (action.names.indexOf(state) !== -1) {
  5054. return null;
  5055. }
  5056. return state;
  5057. case setActionType:
  5058. return action.name || null;
  5059. }
  5060. return state;
  5061. };
  5062. }
  5063. const defaultBlockName = createBlockNameSetterReducer('SET_DEFAULT_BLOCK_NAME');
  5064. const freeformFallbackBlockName = createBlockNameSetterReducer('SET_FREEFORM_FALLBACK_BLOCK_NAME');
  5065. const unregisteredFallbackBlockName = createBlockNameSetterReducer('SET_UNREGISTERED_FALLBACK_BLOCK_NAME');
  5066. const groupingBlockName = createBlockNameSetterReducer('SET_GROUPING_BLOCK_NAME');
  5067. /**
  5068. * Reducer managing the categories
  5069. *
  5070. * @param {WPBlockCategory[]} state Current state.
  5071. * @param {Object} action Dispatched action.
  5072. *
  5073. * @return {WPBlockCategory[]} Updated state.
  5074. */
  5075. function categories() {
  5076. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_CATEGORIES;
  5077. let action = arguments.length > 1 ? arguments[1] : undefined;
  5078. switch (action.type) {
  5079. case 'SET_CATEGORIES':
  5080. return action.categories || [];
  5081. case 'UPDATE_CATEGORY':
  5082. {
  5083. if (!action.category || (0,external_lodash_namespaceObject.isEmpty)(action.category)) {
  5084. return state;
  5085. }
  5086. const categoryToChange = (0,external_lodash_namespaceObject.find)(state, ['slug', action.slug]);
  5087. if (categoryToChange) {
  5088. return (0,external_lodash_namespaceObject.map)(state, category => {
  5089. if (category.slug === action.slug) {
  5090. return { ...category,
  5091. ...action.category
  5092. };
  5093. }
  5094. return category;
  5095. });
  5096. }
  5097. }
  5098. }
  5099. return state;
  5100. }
  5101. function collections() {
  5102. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  5103. let action = arguments.length > 1 ? arguments[1] : undefined;
  5104. switch (action.type) {
  5105. case 'ADD_BLOCK_COLLECTION':
  5106. return { ...state,
  5107. [action.namespace]: {
  5108. title: action.title,
  5109. icon: action.icon
  5110. }
  5111. };
  5112. case 'REMOVE_BLOCK_COLLECTION':
  5113. return (0,external_lodash_namespaceObject.omit)(state, action.namespace);
  5114. }
  5115. return state;
  5116. }
  5117. /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
  5118. unprocessedBlockTypes,
  5119. blockTypes,
  5120. blockStyles,
  5121. blockVariations,
  5122. defaultBlockName,
  5123. freeformFallbackBlockName,
  5124. unregisteredFallbackBlockName,
  5125. groupingBlockName,
  5126. categories,
  5127. collections
  5128. }));
  5129. ;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js
  5130. var LEAF_KEY, hasWeakMap;
  5131. /**
  5132. * Arbitrary value used as key for referencing cache object in WeakMap tree.
  5133. *
  5134. * @type {Object}
  5135. */
  5136. LEAF_KEY = {};
  5137. /**
  5138. * Whether environment supports WeakMap.
  5139. *
  5140. * @type {boolean}
  5141. */
  5142. hasWeakMap = typeof WeakMap !== 'undefined';
  5143. /**
  5144. * Returns the first argument as the sole entry in an array.
  5145. *
  5146. * @param {*} value Value to return.
  5147. *
  5148. * @return {Array} Value returned as entry in array.
  5149. */
  5150. function arrayOf( value ) {
  5151. return [ value ];
  5152. }
  5153. /**
  5154. * Returns true if the value passed is object-like, or false otherwise. A value
  5155. * is object-like if it can support property assignment, e.g. object or array.
  5156. *
  5157. * @param {*} value Value to test.
  5158. *
  5159. * @return {boolean} Whether value is object-like.
  5160. */
  5161. function isObjectLike( value ) {
  5162. return !! value && 'object' === typeof value;
  5163. }
  5164. /**
  5165. * Creates and returns a new cache object.
  5166. *
  5167. * @return {Object} Cache object.
  5168. */
  5169. function createCache() {
  5170. var cache = {
  5171. clear: function() {
  5172. cache.head = null;
  5173. },
  5174. };
  5175. return cache;
  5176. }
  5177. /**
  5178. * Returns true if entries within the two arrays are strictly equal by
  5179. * reference from a starting index.
  5180. *
  5181. * @param {Array} a First array.
  5182. * @param {Array} b Second array.
  5183. * @param {number} fromIndex Index from which to start comparison.
  5184. *
  5185. * @return {boolean} Whether arrays are shallowly equal.
  5186. */
  5187. function isShallowEqual( a, b, fromIndex ) {
  5188. var i;
  5189. if ( a.length !== b.length ) {
  5190. return false;
  5191. }
  5192. for ( i = fromIndex; i < a.length; i++ ) {
  5193. if ( a[ i ] !== b[ i ] ) {
  5194. return false;
  5195. }
  5196. }
  5197. return true;
  5198. }
  5199. /**
  5200. * Returns a memoized selector function. The getDependants function argument is
  5201. * called before the memoized selector and is expected to return an immutable
  5202. * reference or array of references on which the selector depends for computing
  5203. * its own return value. The memoize cache is preserved only as long as those
  5204. * dependant references remain the same. If getDependants returns a different
  5205. * reference(s), the cache is cleared and the selector value regenerated.
  5206. *
  5207. * @param {Function} selector Selector function.
  5208. * @param {Function} getDependants Dependant getter returning an immutable
  5209. * reference or array of reference used in
  5210. * cache bust consideration.
  5211. *
  5212. * @return {Function} Memoized selector.
  5213. */
  5214. /* harmony default export */ function rememo(selector, getDependants ) {
  5215. var rootCache, getCache;
  5216. // Use object source as dependant if getter not provided
  5217. if ( ! getDependants ) {
  5218. getDependants = arrayOf;
  5219. }
  5220. /**
  5221. * Returns the root cache. If WeakMap is supported, this is assigned to the
  5222. * root WeakMap cache set, otherwise it is a shared instance of the default
  5223. * cache object.
  5224. *
  5225. * @return {(WeakMap|Object)} Root cache object.
  5226. */
  5227. function getRootCache() {
  5228. return rootCache;
  5229. }
  5230. /**
  5231. * Returns the cache for a given dependants array. When possible, a WeakMap
  5232. * will be used to create a unique cache for each set of dependants. This
  5233. * is feasible due to the nature of WeakMap in allowing garbage collection
  5234. * to occur on entries where the key object is no longer referenced. Since
  5235. * WeakMap requires the key to be an object, this is only possible when the
  5236. * dependant is object-like. The root cache is created as a hierarchy where
  5237. * each top-level key is the first entry in a dependants set, the value a
  5238. * WeakMap where each key is the next dependant, and so on. This continues
  5239. * so long as the dependants are object-like. If no dependants are object-
  5240. * like, then the cache is shared across all invocations.
  5241. *
  5242. * @see isObjectLike
  5243. *
  5244. * @param {Array} dependants Selector dependants.
  5245. *
  5246. * @return {Object} Cache object.
  5247. */
  5248. function getWeakMapCache( dependants ) {
  5249. var caches = rootCache,
  5250. isUniqueByDependants = true,
  5251. i, dependant, map, cache;
  5252. for ( i = 0; i < dependants.length; i++ ) {
  5253. dependant = dependants[ i ];
  5254. // Can only compose WeakMap from object-like key.
  5255. if ( ! isObjectLike( dependant ) ) {
  5256. isUniqueByDependants = false;
  5257. break;
  5258. }
  5259. // Does current segment of cache already have a WeakMap?
  5260. if ( caches.has( dependant ) ) {
  5261. // Traverse into nested WeakMap.
  5262. caches = caches.get( dependant );
  5263. } else {
  5264. // Create, set, and traverse into a new one.
  5265. map = new WeakMap();
  5266. caches.set( dependant, map );
  5267. caches = map;
  5268. }
  5269. }
  5270. // We use an arbitrary (but consistent) object as key for the last item
  5271. // in the WeakMap to serve as our running cache.
  5272. if ( ! caches.has( LEAF_KEY ) ) {
  5273. cache = createCache();
  5274. cache.isUniqueByDependants = isUniqueByDependants;
  5275. caches.set( LEAF_KEY, cache );
  5276. }
  5277. return caches.get( LEAF_KEY );
  5278. }
  5279. // Assign cache handler by availability of WeakMap
  5280. getCache = hasWeakMap ? getWeakMapCache : getRootCache;
  5281. /**
  5282. * Resets root memoization cache.
  5283. */
  5284. function clear() {
  5285. rootCache = hasWeakMap ? new WeakMap() : createCache();
  5286. }
  5287. // eslint-disable-next-line jsdoc/check-param-names
  5288. /**
  5289. * The augmented selector call, considering first whether dependants have
  5290. * changed before passing it to underlying memoize function.
  5291. *
  5292. * @param {Object} source Source object for derivation.
  5293. * @param {...*} extraArgs Additional arguments to pass to selector.
  5294. *
  5295. * @return {*} Selector result.
  5296. */
  5297. function callSelector( /* source, ...extraArgs */ ) {
  5298. var len = arguments.length,
  5299. cache, node, i, args, dependants;
  5300. // Create copy of arguments (avoid leaking deoptimization).
  5301. args = new Array( len );
  5302. for ( i = 0; i < len; i++ ) {
  5303. args[ i ] = arguments[ i ];
  5304. }
  5305. dependants = getDependants.apply( null, args );
  5306. cache = getCache( dependants );
  5307. // If not guaranteed uniqueness by dependants (primitive type or lack
  5308. // of WeakMap support), shallow compare against last dependants and, if
  5309. // references have changed, destroy cache to recalculate result.
  5310. if ( ! cache.isUniqueByDependants ) {
  5311. if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
  5312. cache.clear();
  5313. }
  5314. cache.lastDependants = dependants;
  5315. }
  5316. node = cache.head;
  5317. while ( node ) {
  5318. // Check whether node arguments match arguments
  5319. if ( ! isShallowEqual( node.args, args, 1 ) ) {
  5320. node = node.next;
  5321. continue;
  5322. }
  5323. // At this point we can assume we've found a match
  5324. // Surface matched node to head if not already
  5325. if ( node !== cache.head ) {
  5326. // Adjust siblings to point to each other.
  5327. node.prev.next = node.next;
  5328. if ( node.next ) {
  5329. node.next.prev = node.prev;
  5330. }
  5331. node.next = cache.head;
  5332. node.prev = null;
  5333. cache.head.prev = node;
  5334. cache.head = node;
  5335. }
  5336. // Return immediately
  5337. return node.val;
  5338. }
  5339. // No cached value found. Continue to insertion phase:
  5340. node = {
  5341. // Generate the result from original function
  5342. val: selector.apply( null, args ),
  5343. };
  5344. // Avoid including the source object in the cache.
  5345. args[ 0 ] = null;
  5346. node.args = args;
  5347. // Don't need to check whether node is already head, since it would
  5348. // have been returned above already if it was
  5349. // Shift existing head down list
  5350. if ( cache.head ) {
  5351. cache.head.prev = node;
  5352. node.next = cache.head;
  5353. }
  5354. cache.head = node;
  5355. return node.val;
  5356. }
  5357. callSelector.getDependants = getDependants;
  5358. callSelector.clear = clear;
  5359. clear();
  5360. return callSelector;
  5361. }
  5362. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/selectors.js
  5363. /**
  5364. * External dependencies
  5365. */
  5366. /** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */
  5367. /** @typedef {import('../api/registration').WPBlockVariationScope} WPBlockVariationScope */
  5368. /** @typedef {import('./reducer').WPBlockCategory} WPBlockCategory */
  5369. /**
  5370. * Given a block name or block type object, returns the corresponding
  5371. * normalized block type object.
  5372. *
  5373. * @param {Object} state Blocks state.
  5374. * @param {(string|Object)} nameOrType Block name or type object
  5375. *
  5376. * @return {Object} Block type object.
  5377. */
  5378. const getNormalizedBlockType = (state, nameOrType) => 'string' === typeof nameOrType ? getBlockType(state, nameOrType) : nameOrType;
  5379. /**
  5380. * Returns all the unprocessed block types as passed during the registration.
  5381. *
  5382. * @param {Object} state Data state.
  5383. *
  5384. * @return {Array} Unprocessed block types.
  5385. */
  5386. function __experimentalGetUnprocessedBlockTypes(state) {
  5387. return state.unprocessedBlockTypes;
  5388. }
  5389. /**
  5390. * Returns all the available block types.
  5391. *
  5392. * @param {Object} state Data state.
  5393. *
  5394. * @return {Array} Block Types.
  5395. */
  5396. const getBlockTypes = rememo(state => Object.values(state.blockTypes), state => [state.blockTypes]);
  5397. /**
  5398. * Returns a block type by name.
  5399. *
  5400. * @param {Object} state Data state.
  5401. * @param {string} name Block type name.
  5402. *
  5403. * @return {Object?} Block Type.
  5404. */
  5405. function getBlockType(state, name) {
  5406. return state.blockTypes[name];
  5407. }
  5408. /**
  5409. * Returns block styles by block name.
  5410. *
  5411. * @param {Object} state Data state.
  5412. * @param {string} name Block type name.
  5413. *
  5414. * @return {Array?} Block Styles.
  5415. */
  5416. function getBlockStyles(state, name) {
  5417. return state.blockStyles[name];
  5418. }
  5419. /**
  5420. * Returns block variations by block name.
  5421. *
  5422. * @param {Object} state Data state.
  5423. * @param {string} blockName Block type name.
  5424. * @param {WPBlockVariationScope} [scope] Block variation scope name.
  5425. *
  5426. * @return {(WPBlockVariation[]|void)} Block variations.
  5427. */
  5428. const getBlockVariations = rememo((state, blockName, scope) => {
  5429. const variations = state.blockVariations[blockName];
  5430. if (!variations || !scope) {
  5431. return variations;
  5432. }
  5433. return variations.filter(variation => {
  5434. // For backward compatibility reasons, variation's scope defaults to
  5435. // `block` and `inserter` when not set.
  5436. return (variation.scope || ['block', 'inserter']).includes(scope);
  5437. });
  5438. }, (state, blockName) => [state.blockVariations[blockName]]);
  5439. /**
  5440. * Returns the active block variation for a given block based on its attributes.
  5441. * Variations are determined by their `isActive` property.
  5442. * Which is either an array of block attribute keys or a function.
  5443. *
  5444. * In case of an array of block attribute keys, the `attributes` are compared
  5445. * to the variation's attributes using strict equality check.
  5446. *
  5447. * In case of function type, the function should accept a block's attributes
  5448. * and the variation's attributes and determines if a variation is active.
  5449. * A function that accepts a block's attributes and the variation's attributes and determines if a variation is active.
  5450. *
  5451. * @param {Object} state Data state.
  5452. * @param {string} blockName Name of block (example: “core/columns”).
  5453. * @param {Object} attributes Block attributes used to determine active variation.
  5454. * @param {WPBlockVariationScope} [scope] Block variation scope name.
  5455. *
  5456. * @return {(WPBlockVariation|undefined)} Active block variation.
  5457. */
  5458. function getActiveBlockVariation(state, blockName, attributes, scope) {
  5459. const variations = getBlockVariations(state, blockName, scope);
  5460. const match = variations === null || variations === void 0 ? void 0 : variations.find(variation => {
  5461. var _variation$isActive;
  5462. if (Array.isArray(variation.isActive)) {
  5463. const blockType = getBlockType(state, blockName);
  5464. const attributeKeys = Object.keys((blockType === null || blockType === void 0 ? void 0 : blockType.attributes) || {});
  5465. const definedAttributes = variation.isActive.filter(attribute => attributeKeys.includes(attribute));
  5466. if (definedAttributes.length === 0) {
  5467. return false;
  5468. }
  5469. return definedAttributes.every(attribute => attributes[attribute] === variation.attributes[attribute]);
  5470. }
  5471. return (_variation$isActive = variation.isActive) === null || _variation$isActive === void 0 ? void 0 : _variation$isActive.call(variation, attributes, variation.attributes);
  5472. });
  5473. return match;
  5474. }
  5475. /**
  5476. * Returns the default block variation for the given block type.
  5477. * When there are multiple variations annotated as the default one,
  5478. * the last added item is picked. This simplifies registering overrides.
  5479. * When there is no default variation set, it returns the first item.
  5480. *
  5481. * @param {Object} state Data state.
  5482. * @param {string} blockName Block type name.
  5483. * @param {WPBlockVariationScope} [scope] Block variation scope name.
  5484. *
  5485. * @return {?WPBlockVariation} The default block variation.
  5486. */
  5487. function getDefaultBlockVariation(state, blockName, scope) {
  5488. const variations = getBlockVariations(state, blockName, scope);
  5489. return (0,external_lodash_namespaceObject.findLast)(variations, 'isDefault') || (0,external_lodash_namespaceObject.first)(variations);
  5490. }
  5491. /**
  5492. * Returns all the available categories.
  5493. *
  5494. * @param {Object} state Data state.
  5495. *
  5496. * @return {WPBlockCategory[]} Categories list.
  5497. */
  5498. function getCategories(state) {
  5499. return state.categories;
  5500. }
  5501. /**
  5502. * Returns all the available collections.
  5503. *
  5504. * @param {Object} state Data state.
  5505. *
  5506. * @return {Object} Collections list.
  5507. */
  5508. function getCollections(state) {
  5509. return state.collections;
  5510. }
  5511. /**
  5512. * Returns the name of the default block name.
  5513. *
  5514. * @param {Object} state Data state.
  5515. *
  5516. * @return {string?} Default block name.
  5517. */
  5518. function getDefaultBlockName(state) {
  5519. return state.defaultBlockName;
  5520. }
  5521. /**
  5522. * Returns the name of the block for handling non-block content.
  5523. *
  5524. * @param {Object} state Data state.
  5525. *
  5526. * @return {string?} Name of the block for handling non-block content.
  5527. */
  5528. function getFreeformFallbackBlockName(state) {
  5529. return state.freeformFallbackBlockName;
  5530. }
  5531. /**
  5532. * Returns the name of the block for handling unregistered blocks.
  5533. *
  5534. * @param {Object} state Data state.
  5535. *
  5536. * @return {string?} Name of the block for handling unregistered blocks.
  5537. */
  5538. function getUnregisteredFallbackBlockName(state) {
  5539. return state.unregisteredFallbackBlockName;
  5540. }
  5541. /**
  5542. * Returns the name of the block for handling unregistered blocks.
  5543. *
  5544. * @param {Object} state Data state.
  5545. *
  5546. * @return {string?} Name of the block for handling unregistered blocks.
  5547. */
  5548. function getGroupingBlockName(state) {
  5549. return state.groupingBlockName;
  5550. }
  5551. /**
  5552. * Returns an array with the child blocks of a given block.
  5553. *
  5554. * @param {Object} state Data state.
  5555. * @param {string} blockName Block type name.
  5556. *
  5557. * @return {Array} Array of child block names.
  5558. */
  5559. const getChildBlockNames = rememo((state, blockName) => {
  5560. return (0,external_lodash_namespaceObject.map)((0,external_lodash_namespaceObject.filter)(state.blockTypes, blockType => {
  5561. return (0,external_lodash_namespaceObject.includes)(blockType.parent, blockName);
  5562. }), _ref => {
  5563. let {
  5564. name
  5565. } = _ref;
  5566. return name;
  5567. });
  5568. }, state => [state.blockTypes]);
  5569. /**
  5570. * Returns the block support value for a feature, if defined.
  5571. *
  5572. * @param {Object} state Data state.
  5573. * @param {(string|Object)} nameOrType Block name or type object
  5574. * @param {Array|string} feature Feature to retrieve
  5575. * @param {*} defaultSupports Default value to return if not
  5576. * explicitly defined
  5577. *
  5578. * @return {?*} Block support value
  5579. */
  5580. const getBlockSupport = (state, nameOrType, feature, defaultSupports) => {
  5581. const blockType = getNormalizedBlockType(state, nameOrType);
  5582. if (!(blockType !== null && blockType !== void 0 && blockType.supports)) {
  5583. return defaultSupports;
  5584. }
  5585. return (0,external_lodash_namespaceObject.get)(blockType.supports, feature, defaultSupports);
  5586. };
  5587. /**
  5588. * Returns true if the block defines support for a feature, or false otherwise.
  5589. *
  5590. * @param {Object} state Data state.
  5591. * @param {(string|Object)} nameOrType Block name or type object.
  5592. * @param {string} feature Feature to test.
  5593. * @param {boolean} defaultSupports Whether feature is supported by
  5594. * default if not explicitly defined.
  5595. *
  5596. * @return {boolean} Whether block supports feature.
  5597. */
  5598. function hasBlockSupport(state, nameOrType, feature, defaultSupports) {
  5599. return !!getBlockSupport(state, nameOrType, feature, defaultSupports);
  5600. }
  5601. /**
  5602. * Returns true if the block type by the given name or object value matches a
  5603. * search term, or false otherwise.
  5604. *
  5605. * @param {Object} state Blocks state.
  5606. * @param {(string|Object)} nameOrType Block name or type object.
  5607. * @param {string} searchTerm Search term by which to filter.
  5608. *
  5609. * @return {Object[]} Whether block type matches search term.
  5610. */
  5611. function isMatchingSearchTerm(state, nameOrType, searchTerm) {
  5612. const blockType = getNormalizedBlockType(state, nameOrType);
  5613. const getNormalizedSearchTerm = (0,external_lodash_namespaceObject.flow)([// Disregard diacritics.
  5614. // Input: "média"
  5615. external_lodash_namespaceObject.deburr, // Lowercase.
  5616. // Input: "MEDIA"
  5617. term => term.toLowerCase(), // Strip leading and trailing whitespace.
  5618. // Input: " media "
  5619. term => term.trim()]);
  5620. const normalizedSearchTerm = getNormalizedSearchTerm(searchTerm);
  5621. const isSearchMatch = (0,external_lodash_namespaceObject.flow)([getNormalizedSearchTerm, normalizedCandidate => (0,external_lodash_namespaceObject.includes)(normalizedCandidate, normalizedSearchTerm)]);
  5622. return isSearchMatch(blockType.title) || (0,external_lodash_namespaceObject.some)(blockType.keywords, isSearchMatch) || isSearchMatch(blockType.category) || isSearchMatch(blockType.description);
  5623. }
  5624. /**
  5625. * Returns a boolean indicating if a block has child blocks or not.
  5626. *
  5627. * @param {Object} state Data state.
  5628. * @param {string} blockName Block type name.
  5629. *
  5630. * @return {boolean} True if a block contains child blocks and false otherwise.
  5631. */
  5632. const hasChildBlocks = (state, blockName) => {
  5633. return getChildBlockNames(state, blockName).length > 0;
  5634. };
  5635. /**
  5636. * Returns a boolean indicating if a block has at least one child block with inserter support.
  5637. *
  5638. * @param {Object} state Data state.
  5639. * @param {string} blockName Block type name.
  5640. *
  5641. * @return {boolean} True if a block contains at least one child blocks with inserter support
  5642. * and false otherwise.
  5643. */
  5644. const hasChildBlocksWithInserterSupport = (state, blockName) => {
  5645. return (0,external_lodash_namespaceObject.some)(getChildBlockNames(state, blockName), childBlockName => {
  5646. return hasBlockSupport(state, childBlockName, 'inserter', true);
  5647. });
  5648. };
  5649. ;// CONCATENATED MODULE: external ["wp","hooks"]
  5650. var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
  5651. ;// CONCATENATED MODULE: ./node_modules/colord/index.mjs
  5652. var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},e=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},u=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},a=function(r){return{r:e(r.r,0,255),g:e(r.g,0,255),b:e(r.b,0,255),a:e(r.a)}},o=function(r){return{r:n(r.r),g:n(r.g),b:n(r.b),a:n(r.a,3)}},i=/^#([0-9a-f]{3,8})$/i,s=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},h=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,a=Math.max(t,n,e),o=a-Math.min(t,n,e),i=o?a===t?(n-e)/o:a===n?2+(e-t)/o:4+(t-n)/o:0;return{h:60*(i<0?i+6:i),s:a?o/a*100:0,v:a/255*100,a:u}},b=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var a=Math.floor(t),o=e*(1-n),i=e*(1-(t-a)*n),s=e*(1-(1-t+a)*n),h=a%6;return{r:255*[e,i,o,o,s,e][h],g:255*[s,e,e,i,o,o][h],b:255*[o,o,s,e,e,i][h],a:u}},g=function(r){return{h:u(r.h),s:e(r.s,0,100),l:e(r.l,0,100),a:e(r.a)}},d=function(r){return{h:n(r.h),s:n(r.s),l:n(r.l),a:n(r.a,3)}},f=function(r){return b((n=(t=r).s,{h:t.h,s:(n*=((e=t.l)<50?e:100-e)/100)>0?2*n/(e+n)*100:0,v:e+n,a:t.a}));var t,n,e},c=function(r){return{h:(t=h(r)).h,s:(u=(200-(n=t.s))*(e=t.v)/100)>0&&u<200?n*e/100/(u<=100?u:200-u)*100:0,l:u/2,a:t.a};var t,n,e,u},l=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,p=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y={string:[[function(r){var t=i.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?n(parseInt(r[3]+r[3],16)/255,2):1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?n(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=v.exec(r)||m.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:a({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(t){var n=l.exec(t)||p.exec(t);if(!n)return null;var e,u,a=g({h:(e=n[1],u=n[2],void 0===u&&(u="deg"),Number(e)*(r[u]||1)),s:Number(n[3]),l:Number(n[4]),a:void 0===n[5]?1:Number(n[5])/(n[6]?100:1)});return f(a)},"hsl"]],object:[[function(r){var n=r.r,e=r.g,u=r.b,o=r.a,i=void 0===o?1:o;return t(n)&&t(e)&&t(u)?a({r:Number(n),g:Number(e),b:Number(u),a:Number(i)}):null},"rgb"],[function(r){var n=r.h,e=r.s,u=r.l,a=r.a,o=void 0===a?1:a;if(!t(n)||!t(e)||!t(u))return null;var i=g({h:Number(n),s:Number(e),l:Number(u),a:Number(o)});return f(i)},"hsl"],[function(r){var n=r.h,a=r.s,o=r.v,i=r.a,s=void 0===i?1:i;if(!t(n)||!t(a)||!t(o))return null;var h=function(r){return{h:u(r.h),s:e(r.s,0,100),v:e(r.v,0,100),a:e(r.a)}}({h:Number(n),s:Number(a),v:Number(o),a:Number(s)});return b(h)},"hsv"]]},N=function(r,t){for(var n=0;n<t.length;n++){var e=t[n][0](r);if(e)return[e,t[n][1]]}return[null,void 0]},x=function(r){return"string"==typeof r?N(r.trim(),y.string):"object"==typeof r&&null!==r?N(r,y.object):[null,void 0]},I=function(r){return x(r)[1]},M=function(r,t){var n=c(r);return{h:n.h,s:e(n.s+100*t,0,100),l:n.l,a:n.a}},H=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},$=function(r,t){var n=c(r);return{h:n.h,s:n.s,l:e(n.l+100*t,0,100),a:n.a}},j=function(){function r(r){this.parsed=x(r)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return n(H(this.rgba),2)},r.prototype.isDark=function(){return H(this.rgba)<.5},r.prototype.isLight=function(){return H(this.rgba)>=.5},r.prototype.toHex=function(){return r=o(this.rgba),t=r.r,e=r.g,u=r.b,i=(a=r.a)<1?s(n(255*a)):"","#"+s(t)+s(e)+s(u)+i;var r,t,e,u,a,i},r.prototype.toRgb=function(){return o(this.rgba)},r.prototype.toRgbString=function(){return r=o(this.rgba),t=r.r,n=r.g,e=r.b,(u=r.a)<1?"rgba("+t+", "+n+", "+e+", "+u+")":"rgb("+t+", "+n+", "+e+")";var r,t,n,e,u},r.prototype.toHsl=function(){return d(c(this.rgba))},r.prototype.toHslString=function(){return r=d(c(this.rgba)),t=r.h,n=r.s,e=r.l,(u=r.a)<1?"hsla("+t+", "+n+"%, "+e+"%, "+u+")":"hsl("+t+", "+n+"%, "+e+"%)";var r,t,n,e,u},r.prototype.toHsv=function(){return r=h(this.rgba),{h:n(r.h),s:n(r.s),v:n(r.v),a:n(r.a,3)};var r},r.prototype.invert=function(){return w({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r},r.prototype.saturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,-r))},r.prototype.grayscale=function(){return w(M(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),w($(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),w($(this.rgba,-r))},r.prototype.rotate=function(r){return void 0===r&&(r=15),this.hue(this.hue()+r)},r.prototype.alpha=function(r){return"number"==typeof r?w({r:(t=this.rgba).r,g:t.g,b:t.b,a:r}):n(this.rgba.a,3);var t},r.prototype.hue=function(r){var t=c(this.rgba);return"number"==typeof r?w({h:r,s:t.s,l:t.l,a:t.a}):n(t.h)},r.prototype.isEqual=function(r){return this.toHex()===w(r).toHex()},r}(),w=function(r){return r instanceof j?r:new j(r)},S=[],k=function(r){r.forEach(function(r){S.indexOf(r)<0&&(r(j,y),S.push(r))})},E=function(){return new j({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};
  5653. ;// CONCATENATED MODULE: ./node_modules/colord/plugins/names.mjs
  5654. /* harmony default export */ function names(e,f){var a={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var d in a)r[a[d]]=d;var l={};e.prototype.toName=function(f){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var d,i,n=r[this.toHex()];if(n)return n;if(null==f?void 0:f.closest){var o=this.toRgb(),t=1/0,b="black";if(!l.length)for(var c in a)l[c]=new e(a[c]).toRgb();for(var g in a){var u=(d=o,i=l[g],Math.pow(d.r-i.r,2)+Math.pow(d.g-i.g,2)+Math.pow(d.b-i.b,2));u<t&&(t=u,b=g)}return b}};f.string.push([function(f){var r=f.toLowerCase(),d="transparent"===r?"#0000":a[r];return d?new e(d).toRgb():null},"name"])}
  5655. ;// CONCATENATED MODULE: ./node_modules/colord/plugins/a11y.mjs
  5656. var a11y_o=function(o){var t=o/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},a11y_t=function(t){return.2126*a11y_o(t.r)+.7152*a11y_o(t.g)+.0722*a11y_o(t.b)};/* harmony default export */ function a11y(o){o.prototype.luminance=function(){return o=a11y_t(this.rgba),void 0===(r=2)&&(r=0),void 0===n&&(n=Math.pow(10,r)),Math.round(n*o)/n+0;var o,r,n},o.prototype.contrast=function(r){void 0===r&&(r="#FFF");var n,a,i,e,v,u,d,c=r instanceof o?r:new o(r);return e=this.rgba,v=c.toRgb(),u=a11y_t(e),d=a11y_t(v),n=u>d?(u+.05)/(d+.05):(d+.05)/(u+.05),void 0===(a=2)&&(a=0),void 0===i&&(i=Math.pow(10,a)),Math.floor(i*n)/i+0},o.prototype.isReadable=function(o,t){return void 0===o&&(o="#FFF"),void 0===t&&(t={}),this.contrast(o)>=(e=void 0===(i=(r=t).size)?"normal":i,"AAA"===(a=void 0===(n=r.level)?"AA":n)&&"normal"===e?7:"AA"===a&&"large"===e?3:4.5);var r,n,a,i,e}}
  5657. ;// CONCATENATED MODULE: external ["wp","element"]
  5658. var external_wp_element_namespaceObject = window["wp"]["element"];
  5659. ;// CONCATENATED MODULE: external ["wp","dom"]
  5660. var external_wp_dom_namespaceObject = window["wp"]["dom"];
  5661. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/constants.js
  5662. const BLOCK_ICON_DEFAULT = 'block-default';
  5663. /**
  5664. * Array of valid keys in a block type settings deprecation object.
  5665. *
  5666. * @type {string[]}
  5667. */
  5668. const DEPRECATED_ENTRY_KEYS = ['attributes', 'supports', 'save', 'migrate', 'isEligible', 'apiVersion'];
  5669. const __EXPERIMENTAL_STYLE_PROPERTY = {
  5670. // Kept for back-compatibility purposes.
  5671. '--wp--style--color--link': {
  5672. value: ['color', 'link'],
  5673. support: ['color', 'link']
  5674. },
  5675. background: {
  5676. value: ['color', 'gradient'],
  5677. support: ['color', 'gradients']
  5678. },
  5679. backgroundColor: {
  5680. value: ['color', 'background'],
  5681. support: ['color', 'background'],
  5682. requiresOptOut: true
  5683. },
  5684. borderColor: {
  5685. value: ['border', 'color'],
  5686. support: ['__experimentalBorder', 'color']
  5687. },
  5688. borderRadius: {
  5689. value: ['border', 'radius'],
  5690. support: ['__experimentalBorder', 'radius'],
  5691. properties: {
  5692. borderTopLeftRadius: 'topLeft',
  5693. borderTopRightRadius: 'topRight',
  5694. borderBottomLeftRadius: 'bottomLeft',
  5695. borderBottomRightRadius: 'bottomRight'
  5696. }
  5697. },
  5698. borderStyle: {
  5699. value: ['border', 'style'],
  5700. support: ['__experimentalBorder', 'style']
  5701. },
  5702. borderWidth: {
  5703. value: ['border', 'width'],
  5704. support: ['__experimentalBorder', 'width']
  5705. },
  5706. color: {
  5707. value: ['color', 'text'],
  5708. support: ['color', 'text'],
  5709. requiresOptOut: true
  5710. },
  5711. filter: {
  5712. value: ['filter', 'duotone'],
  5713. support: ['color', '__experimentalDuotone']
  5714. },
  5715. linkColor: {
  5716. value: ['elements', 'link', 'color', 'text'],
  5717. support: ['color', 'link']
  5718. },
  5719. fontFamily: {
  5720. value: ['typography', 'fontFamily'],
  5721. support: ['typography', '__experimentalFontFamily']
  5722. },
  5723. fontSize: {
  5724. value: ['typography', 'fontSize'],
  5725. support: ['typography', 'fontSize']
  5726. },
  5727. fontStyle: {
  5728. value: ['typography', 'fontStyle'],
  5729. support: ['typography', '__experimentalFontStyle']
  5730. },
  5731. fontWeight: {
  5732. value: ['typography', 'fontWeight'],
  5733. support: ['typography', '__experimentalFontWeight']
  5734. },
  5735. lineHeight: {
  5736. value: ['typography', 'lineHeight'],
  5737. support: ['typography', 'lineHeight']
  5738. },
  5739. margin: {
  5740. value: ['spacing', 'margin'],
  5741. support: ['spacing', 'margin'],
  5742. properties: {
  5743. marginTop: 'top',
  5744. marginRight: 'right',
  5745. marginBottom: 'bottom',
  5746. marginLeft: 'left'
  5747. },
  5748. useEngine: true
  5749. },
  5750. padding: {
  5751. value: ['spacing', 'padding'],
  5752. support: ['spacing', 'padding'],
  5753. properties: {
  5754. paddingTop: 'top',
  5755. paddingRight: 'right',
  5756. paddingBottom: 'bottom',
  5757. paddingLeft: 'left'
  5758. },
  5759. useEngine: true
  5760. },
  5761. textDecoration: {
  5762. value: ['typography', 'textDecoration'],
  5763. support: ['typography', '__experimentalTextDecoration']
  5764. },
  5765. textTransform: {
  5766. value: ['typography', 'textTransform'],
  5767. support: ['typography', '__experimentalTextTransform']
  5768. },
  5769. letterSpacing: {
  5770. value: ['typography', 'letterSpacing'],
  5771. support: ['typography', '__experimentalLetterSpacing']
  5772. },
  5773. '--wp--style--block-gap': {
  5774. value: ['spacing', 'blockGap'],
  5775. support: ['spacing', 'blockGap']
  5776. }
  5777. };
  5778. const __EXPERIMENTAL_ELEMENTS = {
  5779. link: 'a',
  5780. h1: 'h1',
  5781. h2: 'h2',
  5782. h3: 'h3',
  5783. h4: 'h4',
  5784. h5: 'h5',
  5785. h6: 'h6'
  5786. };
  5787. const __EXPERIMENTAL_PATHS_WITH_MERGE = {
  5788. 'color.duotone': true,
  5789. 'color.gradients': true,
  5790. 'color.palette': true,
  5791. 'typography.fontFamilies': true,
  5792. 'typography.fontSizes': true
  5793. };
  5794. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/registration.js
  5795. /* eslint no-console: [ 'error', { allow: [ 'error', 'warn' ] } ] */
  5796. /**
  5797. * External dependencies
  5798. */
  5799. /**
  5800. * WordPress dependencies
  5801. */
  5802. /**
  5803. * Internal dependencies
  5804. */
  5805. const i18nBlockSchema = {
  5806. title: "block title",
  5807. description: "block description",
  5808. keywords: ["block keyword"],
  5809. styles: [{
  5810. label: "block style label"
  5811. }],
  5812. variations: [{
  5813. title: "block variation title",
  5814. description: "block variation description",
  5815. keywords: ["block variation keyword"]
  5816. }]
  5817. };
  5818. /**
  5819. * An icon type definition. One of a Dashicon slug, an element,
  5820. * or a component.
  5821. *
  5822. * @typedef {(string|WPElement|WPComponent)} WPIcon
  5823. *
  5824. * @see https://developer.wordpress.org/resource/dashicons/
  5825. */
  5826. /**
  5827. * Render behavior of a block type icon; one of a Dashicon slug, an element,
  5828. * or a component.
  5829. *
  5830. * @typedef {WPIcon} WPBlockTypeIconRender
  5831. */
  5832. /**
  5833. * An object describing a normalized block type icon.
  5834. *
  5835. * @typedef {Object} WPBlockTypeIconDescriptor
  5836. *
  5837. * @property {WPBlockTypeIconRender} src Render behavior of the icon,
  5838. * one of a Dashicon slug, an
  5839. * element, or a component.
  5840. * @property {string} background Optimal background hex string
  5841. * color when displaying icon.
  5842. * @property {string} foreground Optimal foreground hex string
  5843. * color when displaying icon.
  5844. * @property {string} shadowColor Optimal shadow hex string
  5845. * color when displaying icon.
  5846. */
  5847. /**
  5848. * Value to use to render the icon for a block type in an editor interface,
  5849. * either a Dashicon slug, an element, a component, or an object describing
  5850. * the icon.
  5851. *
  5852. * @typedef {(WPBlockTypeIconDescriptor|WPBlockTypeIconRender)} WPBlockTypeIcon
  5853. */
  5854. /**
  5855. * Named block variation scopes.
  5856. *
  5857. * @typedef {'block'|'inserter'|'transform'} WPBlockVariationScope
  5858. */
  5859. /**
  5860. * An object describing a variation defined for the block type.
  5861. *
  5862. * @typedef {Object} WPBlockVariation
  5863. *
  5864. * @property {string} name The unique and machine-readable name.
  5865. * @property {string} title A human-readable variation title.
  5866. * @property {string} [description] A detailed variation description.
  5867. * @property {string} [category] Block type category classification,
  5868. * used in search interfaces to arrange
  5869. * block types by category.
  5870. * @property {WPIcon} [icon] An icon helping to visualize the variation.
  5871. * @property {boolean} [isDefault] Indicates whether the current variation is
  5872. * the default one. Defaults to `false`.
  5873. * @property {Object} [attributes] Values which override block attributes.
  5874. * @property {Array[]} [innerBlocks] Initial configuration of nested blocks.
  5875. * @property {Object} [example] Example provides structured data for
  5876. * the block preview. You can set to
  5877. * `undefined` to disable the preview shown
  5878. * for the block type.
  5879. * @property {WPBlockVariationScope[]} [scope] The list of scopes where the variation
  5880. * is applicable. When not provided, it
  5881. * assumes all available scopes.
  5882. * @property {string[]} [keywords] An array of terms (which can be translated)
  5883. * that help users discover the variation
  5884. * while searching.
  5885. * @property {Function|string[]} [isActive] This can be a function or an array of block attributes.
  5886. * Function that accepts a block's attributes and the
  5887. * variation's attributes and determines if a variation is active.
  5888. * This function doesn't try to find a match dynamically based
  5889. * on all block's attributes, as in many cases some attributes are irrelevant.
  5890. * An example would be for `embed` block where we only care
  5891. * about `providerNameSlug` attribute's value.
  5892. * We can also use a `string[]` to tell which attributes
  5893. * should be compared as a shorthand. Each attributes will
  5894. * be matched and the variation will be active if all of them are matching.
  5895. */
  5896. /**
  5897. * Defined behavior of a block type.
  5898. *
  5899. * @typedef {Object} WPBlockType
  5900. *
  5901. * @property {string} name Block type's namespaced name.
  5902. * @property {string} title Human-readable block type label.
  5903. * @property {string} [description] A detailed block type description.
  5904. * @property {string} [category] Block type category classification,
  5905. * used in search interfaces to arrange
  5906. * block types by category.
  5907. * @property {WPBlockTypeIcon} [icon] Block type icon.
  5908. * @property {string[]} [keywords] Additional keywords to produce block
  5909. * type as result in search interfaces.
  5910. * @property {Object} [attributes] Block type attributes.
  5911. * @property {WPComponent} [save] Optional component describing
  5912. * serialized markup structure of a
  5913. * block type.
  5914. * @property {WPComponent} edit Component rendering an element to
  5915. * manipulate the attributes of a block
  5916. * in the context of an editor.
  5917. * @property {WPBlockVariation[]} [variations] The list of block variations.
  5918. * @property {Object} [example] Example provides structured data for
  5919. * the block preview. When not defined
  5920. * then no preview is shown.
  5921. */
  5922. const serverSideBlockDefinitions = {};
  5923. /**
  5924. * Sets the server side block definition of blocks.
  5925. *
  5926. * @param {Object} definitions Server-side block definitions
  5927. */
  5928. // eslint-disable-next-line camelcase
  5929. function unstable__bootstrapServerSideBlockDefinitions(definitions) {
  5930. for (const blockName of Object.keys(definitions)) {
  5931. // Don't overwrite if already set. It covers the case when metadata
  5932. // was initialized from the server.
  5933. if (serverSideBlockDefinitions[blockName]) {
  5934. // We still need to polyfill `apiVersion` for WordPress version
  5935. // lower than 5.7. If it isn't present in the definition shared
  5936. // from the server, we try to fallback to the definition passed.
  5937. // @see https://github.com/WordPress/gutenberg/pull/29279
  5938. if (serverSideBlockDefinitions[blockName].apiVersion === undefined && definitions[blockName].apiVersion) {
  5939. serverSideBlockDefinitions[blockName].apiVersion = definitions[blockName].apiVersion;
  5940. } // The `ancestor` prop is not included in the definitions shared
  5941. // from the server yet, so it needs to be polyfilled as well.
  5942. // @see https://github.com/WordPress/gutenberg/pull/39894
  5943. if (serverSideBlockDefinitions[blockName].ancestor === undefined && definitions[blockName].ancestor) {
  5944. serverSideBlockDefinitions[blockName].ancestor = definitions[blockName].ancestor;
  5945. }
  5946. continue;
  5947. }
  5948. serverSideBlockDefinitions[blockName] = (0,external_lodash_namespaceObject.mapKeys)((0,external_lodash_namespaceObject.pickBy)(definitions[blockName], value => !(0,external_lodash_namespaceObject.isNil)(value)), (value, key) => (0,external_lodash_namespaceObject.camelCase)(key));
  5949. }
  5950. }
  5951. /**
  5952. * Gets block settings from metadata loaded from `block.json` file.
  5953. *
  5954. * @param {Object} metadata Block metadata loaded from `block.json`.
  5955. * @param {string} metadata.textdomain Textdomain to use with translations.
  5956. *
  5957. * @return {Object} Block settings.
  5958. */
  5959. function getBlockSettingsFromMetadata(_ref) {
  5960. let {
  5961. textdomain,
  5962. ...metadata
  5963. } = _ref;
  5964. const allowedFields = ['apiVersion', 'title', 'category', 'parent', 'ancestor', 'icon', 'description', 'keywords', 'attributes', 'providesContext', 'usesContext', 'supports', 'styles', 'example', 'variations'];
  5965. const settings = (0,external_lodash_namespaceObject.pick)(metadata, allowedFields);
  5966. if (textdomain) {
  5967. Object.keys(i18nBlockSchema).forEach(key => {
  5968. if (!settings[key]) {
  5969. return;
  5970. }
  5971. settings[key] = translateBlockSettingUsingI18nSchema(i18nBlockSchema[key], settings[key], textdomain);
  5972. });
  5973. }
  5974. return settings;
  5975. }
  5976. /**
  5977. * Registers a new block provided a unique name and an object defining its
  5978. * behavior. Once registered, the block is made available as an option to any
  5979. * editor interface where blocks are implemented.
  5980. *
  5981. * @param {string|Object} blockNameOrMetadata Block type name or its metadata.
  5982. * @param {Object} settings Block settings.
  5983. *
  5984. * @return {?WPBlockType} The block, if it has been successfully registered;
  5985. * otherwise `undefined`.
  5986. */
  5987. function registerBlockType(blockNameOrMetadata, settings) {
  5988. const name = (0,external_lodash_namespaceObject.isObject)(blockNameOrMetadata) ? blockNameOrMetadata.name : blockNameOrMetadata;
  5989. if (typeof name !== 'string') {
  5990. console.error('Block names must be strings.');
  5991. return;
  5992. }
  5993. if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(name)) {
  5994. console.error('Block names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-block');
  5995. return;
  5996. }
  5997. if ((0,external_wp_data_namespaceObject.select)(store).getBlockType(name)) {
  5998. console.error('Block "' + name + '" is already registered.');
  5999. return;
  6000. }
  6001. if ((0,external_lodash_namespaceObject.isObject)(blockNameOrMetadata)) {
  6002. unstable__bootstrapServerSideBlockDefinitions({
  6003. [name]: getBlockSettingsFromMetadata(blockNameOrMetadata)
  6004. });
  6005. }
  6006. const blockType = {
  6007. name,
  6008. icon: BLOCK_ICON_DEFAULT,
  6009. keywords: [],
  6010. attributes: {},
  6011. providesContext: {},
  6012. usesContext: [],
  6013. supports: {},
  6014. styles: [],
  6015. variations: [],
  6016. save: () => null,
  6017. ...(serverSideBlockDefinitions === null || serverSideBlockDefinitions === void 0 ? void 0 : serverSideBlockDefinitions[name]),
  6018. ...settings
  6019. };
  6020. (0,external_wp_data_namespaceObject.dispatch)(store).__experimentalRegisterBlockType(blockType);
  6021. return (0,external_wp_data_namespaceObject.select)(store).getBlockType(name);
  6022. }
  6023. /**
  6024. * Translates block settings provided with metadata using the i18n schema.
  6025. *
  6026. * @param {string|string[]|Object[]} i18nSchema I18n schema for the block setting.
  6027. * @param {string|string[]|Object[]} settingValue Value for the block setting.
  6028. * @param {string} textdomain Textdomain to use with translations.
  6029. *
  6030. * @return {string|string[]|Object[]} Translated setting.
  6031. */
  6032. function translateBlockSettingUsingI18nSchema(i18nSchema, settingValue, textdomain) {
  6033. if ((0,external_lodash_namespaceObject.isString)(i18nSchema) && (0,external_lodash_namespaceObject.isString)(settingValue)) {
  6034. // eslint-disable-next-line @wordpress/i18n-no-variables, @wordpress/i18n-text-domain
  6035. return (0,external_wp_i18n_namespaceObject._x)(settingValue, i18nSchema, textdomain);
  6036. }
  6037. if ((0,external_lodash_namespaceObject.isArray)(i18nSchema) && !(0,external_lodash_namespaceObject.isEmpty)(i18nSchema) && (0,external_lodash_namespaceObject.isArray)(settingValue)) {
  6038. return settingValue.map(value => translateBlockSettingUsingI18nSchema(i18nSchema[0], value, textdomain));
  6039. }
  6040. if ((0,external_lodash_namespaceObject.isObject)(i18nSchema) && !(0,external_lodash_namespaceObject.isEmpty)(i18nSchema) && (0,external_lodash_namespaceObject.isObject)(settingValue)) {
  6041. return Object.keys(settingValue).reduce((accumulator, key) => {
  6042. if (!i18nSchema[key]) {
  6043. accumulator[key] = settingValue[key];
  6044. return accumulator;
  6045. }
  6046. accumulator[key] = translateBlockSettingUsingI18nSchema(i18nSchema[key], settingValue[key], textdomain);
  6047. return accumulator;
  6048. }, {});
  6049. }
  6050. return settingValue;
  6051. }
  6052. /**
  6053. * Registers a new block collection to group blocks in the same namespace in the inserter.
  6054. *
  6055. * @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace.
  6056. * @param {Object} settings The block collection settings.
  6057. * @param {string} settings.title The title to display in the block inserter.
  6058. * @param {Object} [settings.icon] The icon to display in the block inserter.
  6059. */
  6060. function registerBlockCollection(namespace, _ref2) {
  6061. let {
  6062. title,
  6063. icon
  6064. } = _ref2;
  6065. (0,external_wp_data_namespaceObject.dispatch)(store).addBlockCollection(namespace, title, icon);
  6066. }
  6067. /**
  6068. * Unregisters a block collection
  6069. *
  6070. * @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace
  6071. *
  6072. */
  6073. function unregisterBlockCollection(namespace) {
  6074. dispatch(blocksStore).removeBlockCollection(namespace);
  6075. }
  6076. /**
  6077. * Unregisters a block.
  6078. *
  6079. * @param {string} name Block name.
  6080. *
  6081. * @return {?WPBlockType} The previous block value, if it has been successfully
  6082. * unregistered; otherwise `undefined`.
  6083. */
  6084. function unregisterBlockType(name) {
  6085. const oldBlock = (0,external_wp_data_namespaceObject.select)(store).getBlockType(name);
  6086. if (!oldBlock) {
  6087. console.error('Block "' + name + '" is not registered.');
  6088. return;
  6089. }
  6090. (0,external_wp_data_namespaceObject.dispatch)(store).removeBlockTypes(name);
  6091. return oldBlock;
  6092. }
  6093. /**
  6094. * Assigns name of block for handling non-block content.
  6095. *
  6096. * @param {string} blockName Block name.
  6097. */
  6098. function setFreeformContentHandlerName(blockName) {
  6099. (0,external_wp_data_namespaceObject.dispatch)(store).setFreeformFallbackBlockName(blockName);
  6100. }
  6101. /**
  6102. * Retrieves name of block handling non-block content, or undefined if no
  6103. * handler has been defined.
  6104. *
  6105. * @return {?string} Block name.
  6106. */
  6107. function getFreeformContentHandlerName() {
  6108. return (0,external_wp_data_namespaceObject.select)(store).getFreeformFallbackBlockName();
  6109. }
  6110. /**
  6111. * Retrieves name of block used for handling grouping interactions.
  6112. *
  6113. * @return {?string} Block name.
  6114. */
  6115. function registration_getGroupingBlockName() {
  6116. return (0,external_wp_data_namespaceObject.select)(store).getGroupingBlockName();
  6117. }
  6118. /**
  6119. * Assigns name of block handling unregistered block types.
  6120. *
  6121. * @param {string} blockName Block name.
  6122. */
  6123. function setUnregisteredTypeHandlerName(blockName) {
  6124. (0,external_wp_data_namespaceObject.dispatch)(store).setUnregisteredFallbackBlockName(blockName);
  6125. }
  6126. /**
  6127. * Retrieves name of block handling unregistered block types, or undefined if no
  6128. * handler has been defined.
  6129. *
  6130. * @return {?string} Block name.
  6131. */
  6132. function getUnregisteredTypeHandlerName() {
  6133. return (0,external_wp_data_namespaceObject.select)(store).getUnregisteredFallbackBlockName();
  6134. }
  6135. /**
  6136. * Assigns the default block name.
  6137. *
  6138. * @param {string} name Block name.
  6139. */
  6140. function setDefaultBlockName(name) {
  6141. (0,external_wp_data_namespaceObject.dispatch)(store).setDefaultBlockName(name);
  6142. }
  6143. /**
  6144. * Assigns name of block for handling block grouping interactions.
  6145. *
  6146. * @param {string} name Block name.
  6147. */
  6148. function setGroupingBlockName(name) {
  6149. (0,external_wp_data_namespaceObject.dispatch)(store).setGroupingBlockName(name);
  6150. }
  6151. /**
  6152. * Retrieves the default block name.
  6153. *
  6154. * @return {?string} Block name.
  6155. */
  6156. function registration_getDefaultBlockName() {
  6157. return (0,external_wp_data_namespaceObject.select)(store).getDefaultBlockName();
  6158. }
  6159. /**
  6160. * Returns a registered block type.
  6161. *
  6162. * @param {string} name Block name.
  6163. *
  6164. * @return {?Object} Block type.
  6165. */
  6166. function registration_getBlockType(name) {
  6167. var _select;
  6168. return (_select = (0,external_wp_data_namespaceObject.select)(store)) === null || _select === void 0 ? void 0 : _select.getBlockType(name);
  6169. }
  6170. /**
  6171. * Returns all registered blocks.
  6172. *
  6173. * @return {Array} Block settings.
  6174. */
  6175. function registration_getBlockTypes() {
  6176. return (0,external_wp_data_namespaceObject.select)(store).getBlockTypes();
  6177. }
  6178. /**
  6179. * Returns the block support value for a feature, if defined.
  6180. *
  6181. * @param {(string|Object)} nameOrType Block name or type object
  6182. * @param {string} feature Feature to retrieve
  6183. * @param {*} defaultSupports Default value to return if not
  6184. * explicitly defined
  6185. *
  6186. * @return {?*} Block support value
  6187. */
  6188. function registration_getBlockSupport(nameOrType, feature, defaultSupports) {
  6189. return (0,external_wp_data_namespaceObject.select)(store).getBlockSupport(nameOrType, feature, defaultSupports);
  6190. }
  6191. /**
  6192. * Returns true if the block defines support for a feature, or false otherwise.
  6193. *
  6194. * @param {(string|Object)} nameOrType Block name or type object.
  6195. * @param {string} feature Feature to test.
  6196. * @param {boolean} defaultSupports Whether feature is supported by
  6197. * default if not explicitly defined.
  6198. *
  6199. * @return {boolean} Whether block supports feature.
  6200. */
  6201. function registration_hasBlockSupport(nameOrType, feature, defaultSupports) {
  6202. return (0,external_wp_data_namespaceObject.select)(store).hasBlockSupport(nameOrType, feature, defaultSupports);
  6203. }
  6204. /**
  6205. * Determines whether or not the given block is a reusable block. This is a
  6206. * special block type that is used to point to a global block stored via the
  6207. * API.
  6208. *
  6209. * @param {Object} blockOrType Block or Block Type to test.
  6210. *
  6211. * @return {boolean} Whether the given block is a reusable block.
  6212. */
  6213. function isReusableBlock(blockOrType) {
  6214. return (blockOrType === null || blockOrType === void 0 ? void 0 : blockOrType.name) === 'core/block';
  6215. }
  6216. /**
  6217. * Determines whether or not the given block is a template part. This is a
  6218. * special block type that allows composing a page template out of reusable
  6219. * design elements.
  6220. *
  6221. * @param {Object} blockOrType Block or Block Type to test.
  6222. *
  6223. * @return {boolean} Whether the given block is a template part.
  6224. */
  6225. function isTemplatePart(blockOrType) {
  6226. return blockOrType.name === 'core/template-part';
  6227. }
  6228. /**
  6229. * Returns an array with the child blocks of a given block.
  6230. *
  6231. * @param {string} blockName Name of block (example: “latest-posts”).
  6232. *
  6233. * @return {Array} Array of child block names.
  6234. */
  6235. const registration_getChildBlockNames = blockName => {
  6236. return (0,external_wp_data_namespaceObject.select)(store).getChildBlockNames(blockName);
  6237. };
  6238. /**
  6239. * Returns a boolean indicating if a block has child blocks or not.
  6240. *
  6241. * @param {string} blockName Name of block (example: “latest-posts”).
  6242. *
  6243. * @return {boolean} True if a block contains child blocks and false otherwise.
  6244. */
  6245. const registration_hasChildBlocks = blockName => {
  6246. return (0,external_wp_data_namespaceObject.select)(store).hasChildBlocks(blockName);
  6247. };
  6248. /**
  6249. * Returns a boolean indicating if a block has at least one child block with inserter support.
  6250. *
  6251. * @param {string} blockName Block type name.
  6252. *
  6253. * @return {boolean} True if a block contains at least one child blocks with inserter support
  6254. * and false otherwise.
  6255. */
  6256. const registration_hasChildBlocksWithInserterSupport = blockName => {
  6257. return (0,external_wp_data_namespaceObject.select)(store).hasChildBlocksWithInserterSupport(blockName);
  6258. };
  6259. /**
  6260. * Registers a new block style variation for the given block.
  6261. *
  6262. * @param {string} blockName Name of block (example: “core/latest-posts”).
  6263. * @param {Object} styleVariation Object containing `name` which is the class name applied to the block and `label` which identifies the variation to the user.
  6264. */
  6265. const registerBlockStyle = (blockName, styleVariation) => {
  6266. (0,external_wp_data_namespaceObject.dispatch)(store).addBlockStyles(blockName, styleVariation);
  6267. };
  6268. /**
  6269. * Unregisters a block style variation for the given block.
  6270. *
  6271. * @param {string} blockName Name of block (example: “core/latest-posts”).
  6272. * @param {string} styleVariationName Name of class applied to the block.
  6273. */
  6274. const unregisterBlockStyle = (blockName, styleVariationName) => {
  6275. (0,external_wp_data_namespaceObject.dispatch)(store).removeBlockStyles(blockName, styleVariationName);
  6276. };
  6277. /**
  6278. * Returns an array with the variations of a given block type.
  6279. *
  6280. * @param {string} blockName Name of block (example: “core/columns”).
  6281. * @param {WPBlockVariationScope} [scope] Block variation scope name.
  6282. *
  6283. * @return {(WPBlockVariation[]|void)} Block variations.
  6284. */
  6285. const registration_getBlockVariations = (blockName, scope) => {
  6286. return (0,external_wp_data_namespaceObject.select)(store).getBlockVariations(blockName, scope);
  6287. };
  6288. /**
  6289. * Registers a new block variation for the given block type.
  6290. *
  6291. * @param {string} blockName Name of the block (example: “core/columns”).
  6292. * @param {WPBlockVariation} variation Object describing a block variation.
  6293. */
  6294. const registerBlockVariation = (blockName, variation) => {
  6295. (0,external_wp_data_namespaceObject.dispatch)(store).addBlockVariations(blockName, variation);
  6296. };
  6297. /**
  6298. * Unregisters a block variation defined for the given block type.
  6299. *
  6300. * @param {string} blockName Name of the block (example: “core/columns”).
  6301. * @param {string} variationName Name of the variation defined for the block.
  6302. */
  6303. const unregisterBlockVariation = (blockName, variationName) => {
  6304. (0,external_wp_data_namespaceObject.dispatch)(store).removeBlockVariations(blockName, variationName);
  6305. };
  6306. ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js
  6307. // Unique ID creation requires a high quality random # generator. In the browser we therefore
  6308. // require the crypto API and do not support built-in fallback to lower quality random number
  6309. // generators (like Math.random()).
  6310. var getRandomValues;
  6311. var rnds8 = new Uint8Array(16);
  6312. function rng() {
  6313. // lazy load so that environments that need to polyfill have a chance to do so
  6314. if (!getRandomValues) {
  6315. // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
  6316. // find the complete implementation of crypto (msCrypto) on IE11.
  6317. getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
  6318. if (!getRandomValues) {
  6319. throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
  6320. }
  6321. }
  6322. return getRandomValues(rnds8);
  6323. }
  6324. ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/regex.js
  6325. /* harmony default export */ var regex = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i);
  6326. ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/validate.js
  6327. function validate(uuid) {
  6328. return typeof uuid === 'string' && regex.test(uuid);
  6329. }
  6330. /* harmony default export */ var esm_browser_validate = (validate);
  6331. ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js
  6332. /**
  6333. * Convert array of 16 byte values to UUID string format of the form:
  6334. * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
  6335. */
  6336. var byteToHex = [];
  6337. for (var stringify_i = 0; stringify_i < 256; ++stringify_i) {
  6338. byteToHex.push((stringify_i + 0x100).toString(16).substr(1));
  6339. }
  6340. function stringify(arr) {
  6341. var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  6342. // Note: Be careful editing this code! It's been tuned for performance
  6343. // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
  6344. var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
  6345. // of the following:
  6346. // - One or more input array values don't map to a hex octet (leading to
  6347. // "undefined" in the uuid)
  6348. // - Invalid input values for the RFC `version` or `variant` fields
  6349. if (!esm_browser_validate(uuid)) {
  6350. throw TypeError('Stringified UUID is invalid');
  6351. }
  6352. return uuid;
  6353. }
  6354. /* harmony default export */ var esm_browser_stringify = (stringify);
  6355. ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js
  6356. function v4(options, buf, offset) {
  6357. options = options || {};
  6358. var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
  6359. rnds[6] = rnds[6] & 0x0f | 0x40;
  6360. rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
  6361. if (buf) {
  6362. offset = offset || 0;
  6363. for (var i = 0; i < 16; ++i) {
  6364. buf[offset + i] = rnds[i];
  6365. }
  6366. return buf;
  6367. }
  6368. return esm_browser_stringify(rnds);
  6369. }
  6370. /* harmony default export */ var esm_browser_v4 = (v4);
  6371. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/factory.js
  6372. /**
  6373. * External dependencies
  6374. */
  6375. /**
  6376. * WordPress dependencies
  6377. */
  6378. /**
  6379. * Internal dependencies
  6380. */
  6381. /**
  6382. * Returns a block object given its type and attributes.
  6383. *
  6384. * @param {string} name Block name.
  6385. * @param {Object} attributes Block attributes.
  6386. * @param {?Array} innerBlocks Nested blocks.
  6387. *
  6388. * @return {Object} Block object.
  6389. */
  6390. function createBlock(name) {
  6391. let attributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  6392. let innerBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
  6393. const sanitizedAttributes = __experimentalSanitizeBlockAttributes(name, attributes);
  6394. const clientId = esm_browser_v4(); // Blocks are stored with a unique ID, the assigned type name, the block
  6395. // attributes, and their inner blocks.
  6396. return {
  6397. clientId,
  6398. name,
  6399. isValid: true,
  6400. attributes: sanitizedAttributes,
  6401. innerBlocks
  6402. };
  6403. }
  6404. /**
  6405. * Given an array of InnerBlocks templates or Block Objects,
  6406. * returns an array of created Blocks from them.
  6407. * It handles the case of having InnerBlocks as Blocks by
  6408. * converting them to the proper format to continue recursively.
  6409. *
  6410. * @param {Array} innerBlocksOrTemplate Nested blocks or InnerBlocks templates.
  6411. *
  6412. * @return {Object[]} Array of Block objects.
  6413. */
  6414. function createBlocksFromInnerBlocksTemplate() {
  6415. let innerBlocksOrTemplate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  6416. return innerBlocksOrTemplate.map(innerBlock => {
  6417. const innerBlockTemplate = Array.isArray(innerBlock) ? innerBlock : [innerBlock.name, innerBlock.attributes, innerBlock.innerBlocks];
  6418. const [name, attributes, innerBlocks = []] = innerBlockTemplate;
  6419. return createBlock(name, attributes, createBlocksFromInnerBlocksTemplate(innerBlocks));
  6420. });
  6421. }
  6422. /**
  6423. * Given a block object, returns a copy of the block object while sanitizing its attributes,
  6424. * optionally merging new attributes and/or replacing its inner blocks.
  6425. *
  6426. * @param {Object} block Block instance.
  6427. * @param {Object} mergeAttributes Block attributes.
  6428. * @param {?Array} newInnerBlocks Nested blocks.
  6429. *
  6430. * @return {Object} A cloned block.
  6431. */
  6432. function __experimentalCloneSanitizedBlock(block) {
  6433. let mergeAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  6434. let newInnerBlocks = arguments.length > 2 ? arguments[2] : undefined;
  6435. const clientId = esm_browser_v4();
  6436. const sanitizedAttributes = __experimentalSanitizeBlockAttributes(block.name, { ...block.attributes,
  6437. ...mergeAttributes
  6438. });
  6439. return { ...block,
  6440. clientId,
  6441. attributes: sanitizedAttributes,
  6442. innerBlocks: newInnerBlocks || block.innerBlocks.map(innerBlock => __experimentalCloneSanitizedBlock(innerBlock))
  6443. };
  6444. }
  6445. /**
  6446. * Given a block object, returns a copy of the block object,
  6447. * optionally merging new attributes and/or replacing its inner blocks.
  6448. *
  6449. * @param {Object} block Block instance.
  6450. * @param {Object} mergeAttributes Block attributes.
  6451. * @param {?Array} newInnerBlocks Nested blocks.
  6452. *
  6453. * @return {Object} A cloned block.
  6454. */
  6455. function cloneBlock(block) {
  6456. let mergeAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  6457. let newInnerBlocks = arguments.length > 2 ? arguments[2] : undefined;
  6458. const clientId = esm_browser_v4();
  6459. return { ...block,
  6460. clientId,
  6461. attributes: { ...block.attributes,
  6462. ...mergeAttributes
  6463. },
  6464. innerBlocks: newInnerBlocks || block.innerBlocks.map(innerBlock => cloneBlock(innerBlock))
  6465. };
  6466. }
  6467. /**
  6468. * Returns a boolean indicating whether a transform is possible based on
  6469. * various bits of context.
  6470. *
  6471. * @param {Object} transform The transform object to validate.
  6472. * @param {string} direction Is this a 'from' or 'to' transform.
  6473. * @param {Array} blocks The blocks to transform from.
  6474. *
  6475. * @return {boolean} Is the transform possible?
  6476. */
  6477. const isPossibleTransformForSource = (transform, direction, blocks) => {
  6478. if ((0,external_lodash_namespaceObject.isEmpty)(blocks)) {
  6479. return false;
  6480. } // If multiple blocks are selected, only multi block transforms
  6481. // or wildcard transforms are allowed.
  6482. const isMultiBlock = blocks.length > 1;
  6483. const firstBlockName = (0,external_lodash_namespaceObject.first)(blocks).name;
  6484. const isValidForMultiBlocks = isWildcardBlockTransform(transform) || !isMultiBlock || transform.isMultiBlock;
  6485. if (!isValidForMultiBlocks) {
  6486. return false;
  6487. } // Check non-wildcard transforms to ensure that transform is valid
  6488. // for a block selection of multiple blocks of different types.
  6489. if (!isWildcardBlockTransform(transform) && !(0,external_lodash_namespaceObject.every)(blocks, {
  6490. name: firstBlockName
  6491. })) {
  6492. return false;
  6493. } // Only consider 'block' type transforms as valid.
  6494. const isBlockType = transform.type === 'block';
  6495. if (!isBlockType) {
  6496. return false;
  6497. } // Check if the transform's block name matches the source block (or is a wildcard)
  6498. // only if this is a transform 'from'.
  6499. const sourceBlock = (0,external_lodash_namespaceObject.first)(blocks);
  6500. const hasMatchingName = direction !== 'from' || transform.blocks.indexOf(sourceBlock.name) !== -1 || isWildcardBlockTransform(transform);
  6501. if (!hasMatchingName) {
  6502. return false;
  6503. } // Don't allow single Grouping blocks to be transformed into
  6504. // a Grouping block.
  6505. if (!isMultiBlock && isContainerGroupBlock(sourceBlock.name) && isContainerGroupBlock(transform.blockName)) {
  6506. return false;
  6507. } // If the transform has a `isMatch` function specified, check that it returns true.
  6508. if ((0,external_lodash_namespaceObject.isFunction)(transform.isMatch)) {
  6509. const attributes = transform.isMultiBlock ? blocks.map(block => block.attributes) : sourceBlock.attributes;
  6510. const block = transform.isMultiBlock ? blocks : sourceBlock;
  6511. if (!transform.isMatch(attributes, block)) {
  6512. return false;
  6513. }
  6514. }
  6515. if (transform.usingMobileTransformations && isWildcardBlockTransform(transform) && !isContainerGroupBlock(sourceBlock.name)) {
  6516. return false;
  6517. }
  6518. return true;
  6519. };
  6520. /**
  6521. * Returns block types that the 'blocks' can be transformed into, based on
  6522. * 'from' transforms on other blocks.
  6523. *
  6524. * @param {Array} blocks The blocks to transform from.
  6525. *
  6526. * @return {Array} Block types that the blocks can be transformed into.
  6527. */
  6528. const getBlockTypesForPossibleFromTransforms = blocks => {
  6529. if ((0,external_lodash_namespaceObject.isEmpty)(blocks)) {
  6530. return [];
  6531. }
  6532. const allBlockTypes = registration_getBlockTypes(); // filter all blocks to find those with a 'from' transform.
  6533. const blockTypesWithPossibleFromTransforms = (0,external_lodash_namespaceObject.filter)(allBlockTypes, blockType => {
  6534. const fromTransforms = getBlockTransforms('from', blockType.name);
  6535. return !!findTransform(fromTransforms, transform => {
  6536. return isPossibleTransformForSource(transform, 'from', blocks);
  6537. });
  6538. });
  6539. return blockTypesWithPossibleFromTransforms;
  6540. };
  6541. /**
  6542. * Returns block types that the 'blocks' can be transformed into, based on
  6543. * the source block's own 'to' transforms.
  6544. *
  6545. * @param {Array} blocks The blocks to transform from.
  6546. *
  6547. * @return {Array} Block types that the source can be transformed into.
  6548. */
  6549. const getBlockTypesForPossibleToTransforms = blocks => {
  6550. if ((0,external_lodash_namespaceObject.isEmpty)(blocks)) {
  6551. return [];
  6552. }
  6553. const sourceBlock = (0,external_lodash_namespaceObject.first)(blocks);
  6554. const blockType = registration_getBlockType(sourceBlock.name);
  6555. const transformsTo = blockType ? getBlockTransforms('to', blockType.name) : []; // filter all 'to' transforms to find those that are possible.
  6556. const possibleTransforms = (0,external_lodash_namespaceObject.filter)(transformsTo, transform => {
  6557. return transform && isPossibleTransformForSource(transform, 'to', blocks);
  6558. }); // Build a list of block names using the possible 'to' transforms.
  6559. const blockNames = (0,external_lodash_namespaceObject.flatMap)(possibleTransforms, transformation => transformation.blocks); // Map block names to block types.
  6560. return blockNames.map(name => name === '*' ? name : registration_getBlockType(name));
  6561. };
  6562. /**
  6563. * Determines whether transform is a "block" type
  6564. * and if so whether it is a "wildcard" transform
  6565. * ie: targets "any" block type
  6566. *
  6567. * @param {Object} t the Block transform object
  6568. *
  6569. * @return {boolean} whether transform is a wildcard transform
  6570. */
  6571. const isWildcardBlockTransform = t => t && t.type === 'block' && Array.isArray(t.blocks) && t.blocks.includes('*');
  6572. /**
  6573. * Determines whether the given Block is the core Block which
  6574. * acts as a container Block for other Blocks as part of the
  6575. * Grouping mechanics
  6576. *
  6577. * @param {string} name the name of the Block to test against
  6578. *
  6579. * @return {boolean} whether or not the Block is the container Block type
  6580. */
  6581. const isContainerGroupBlock = name => name === registration_getGroupingBlockName();
  6582. /**
  6583. * Returns an array of block types that the set of blocks received as argument
  6584. * can be transformed into.
  6585. *
  6586. * @param {Array} blocks Blocks array.
  6587. *
  6588. * @return {Array} Block types that the blocks argument can be transformed to.
  6589. */
  6590. function getPossibleBlockTransformations(blocks) {
  6591. if ((0,external_lodash_namespaceObject.isEmpty)(blocks)) {
  6592. return [];
  6593. }
  6594. const blockTypesForFromTransforms = getBlockTypesForPossibleFromTransforms(blocks);
  6595. const blockTypesForToTransforms = getBlockTypesForPossibleToTransforms(blocks);
  6596. return (0,external_lodash_namespaceObject.uniq)([...blockTypesForFromTransforms, ...blockTypesForToTransforms]);
  6597. }
  6598. /**
  6599. * Given an array of transforms, returns the highest-priority transform where
  6600. * the predicate function returns a truthy value. A higher-priority transform
  6601. * is one with a lower priority value (i.e. first in priority order). Returns
  6602. * null if the transforms set is empty or the predicate function returns a
  6603. * falsey value for all entries.
  6604. *
  6605. * @param {Object[]} transforms Transforms to search.
  6606. * @param {Function} predicate Function returning true on matching transform.
  6607. *
  6608. * @return {?Object} Highest-priority transform candidate.
  6609. */
  6610. function findTransform(transforms, predicate) {
  6611. // The hooks library already has built-in mechanisms for managing priority
  6612. // queue, so leverage via locally-defined instance.
  6613. const hooks = (0,external_wp_hooks_namespaceObject.createHooks)();
  6614. for (let i = 0; i < transforms.length; i++) {
  6615. const candidate = transforms[i];
  6616. if (predicate(candidate)) {
  6617. hooks.addFilter('transform', 'transform/' + i.toString(), result => result ? result : candidate, candidate.priority);
  6618. }
  6619. } // Filter name is arbitrarily chosen but consistent with above aggregation.
  6620. return hooks.applyFilters('transform', null);
  6621. }
  6622. /**
  6623. * Returns normal block transforms for a given transform direction, optionally
  6624. * for a specific block by name, or an empty array if there are no transforms.
  6625. * If no block name is provided, returns transforms for all blocks. A normal
  6626. * transform object includes `blockName` as a property.
  6627. *
  6628. * @param {string} direction Transform direction ("to", "from").
  6629. * @param {string|Object} blockTypeOrName Block type or name.
  6630. *
  6631. * @return {Array} Block transforms for direction.
  6632. */
  6633. function getBlockTransforms(direction, blockTypeOrName) {
  6634. // When retrieving transforms for all block types, recurse into self.
  6635. if (blockTypeOrName === undefined) {
  6636. return (0,external_lodash_namespaceObject.flatMap)(registration_getBlockTypes(), _ref => {
  6637. let {
  6638. name
  6639. } = _ref;
  6640. return getBlockTransforms(direction, name);
  6641. });
  6642. } // Validate that block type exists and has array of direction.
  6643. const blockType = normalizeBlockType(blockTypeOrName);
  6644. const {
  6645. name: blockName,
  6646. transforms
  6647. } = blockType || {};
  6648. if (!transforms || !Array.isArray(transforms[direction])) {
  6649. return [];
  6650. }
  6651. const usingMobileTransformations = transforms.supportedMobileTransforms && Array.isArray(transforms.supportedMobileTransforms);
  6652. const filteredTransforms = usingMobileTransformations ? (0,external_lodash_namespaceObject.filter)(transforms[direction], t => {
  6653. if (t.type === 'raw') {
  6654. return true;
  6655. }
  6656. if (!t.blocks || !t.blocks.length) {
  6657. return false;
  6658. }
  6659. if (isWildcardBlockTransform(t)) {
  6660. return true;
  6661. }
  6662. return (0,external_lodash_namespaceObject.every)(t.blocks, transformBlockName => transforms.supportedMobileTransforms.includes(transformBlockName));
  6663. }) : transforms[direction]; // Map transforms to normal form.
  6664. return filteredTransforms.map(transform => ({ ...transform,
  6665. blockName,
  6666. usingMobileTransformations
  6667. }));
  6668. }
  6669. /**
  6670. * Switch one or more blocks into one or more blocks of the new block type.
  6671. *
  6672. * @param {Array|Object} blocks Blocks array or block object.
  6673. * @param {string} name Block name.
  6674. *
  6675. * @return {?Array} Array of blocks or null.
  6676. */
  6677. function switchToBlockType(blocks, name) {
  6678. const blocksArray = (0,external_lodash_namespaceObject.castArray)(blocks);
  6679. const isMultiBlock = blocksArray.length > 1;
  6680. const firstBlock = blocksArray[0];
  6681. const sourceName = firstBlock.name; // Find the right transformation by giving priority to the "to"
  6682. // transformation.
  6683. const transformationsFrom = getBlockTransforms('from', name);
  6684. const transformationsTo = getBlockTransforms('to', sourceName);
  6685. const transformation = findTransform(transformationsTo, t => t.type === 'block' && (isWildcardBlockTransform(t) || t.blocks.indexOf(name) !== -1) && (!isMultiBlock || t.isMultiBlock)) || findTransform(transformationsFrom, t => t.type === 'block' && (isWildcardBlockTransform(t) || t.blocks.indexOf(sourceName) !== -1) && (!isMultiBlock || t.isMultiBlock)); // Stop if there is no valid transformation.
  6686. if (!transformation) {
  6687. return null;
  6688. }
  6689. let transformationResults;
  6690. if (transformation.isMultiBlock) {
  6691. if ((0,external_lodash_namespaceObject.has)(transformation, '__experimentalConvert')) {
  6692. transformationResults = transformation.__experimentalConvert(blocksArray);
  6693. } else {
  6694. transformationResults = transformation.transform(blocksArray.map(currentBlock => currentBlock.attributes), blocksArray.map(currentBlock => currentBlock.innerBlocks));
  6695. }
  6696. } else if ((0,external_lodash_namespaceObject.has)(transformation, '__experimentalConvert')) {
  6697. transformationResults = transformation.__experimentalConvert(firstBlock);
  6698. } else {
  6699. transformationResults = transformation.transform(firstBlock.attributes, firstBlock.innerBlocks);
  6700. } // Ensure that the transformation function returned an object or an array
  6701. // of objects.
  6702. if (!(0,external_lodash_namespaceObject.isObjectLike)(transformationResults)) {
  6703. return null;
  6704. } // If the transformation function returned a single object, we want to work
  6705. // with an array instead.
  6706. transformationResults = (0,external_lodash_namespaceObject.castArray)(transformationResults); // Ensure that every block object returned by the transformation has a
  6707. // valid block type.
  6708. if (transformationResults.some(result => !registration_getBlockType(result.name))) {
  6709. return null;
  6710. }
  6711. const hasSwitchedBlock = name === '*' || (0,external_lodash_namespaceObject.some)(transformationResults, result => result.name === name); // Ensure that at least one block object returned by the transformation has
  6712. // the expected "destination" block type.
  6713. if (!hasSwitchedBlock) {
  6714. return null;
  6715. }
  6716. const ret = transformationResults.map((result, index, results) => {
  6717. /**
  6718. * Filters an individual transform result from block transformation.
  6719. * All of the original blocks are passed, since transformations are
  6720. * many-to-many, not one-to-one.
  6721. *
  6722. * @param {Object} transformedBlock The transformed block.
  6723. * @param {Object[]} blocks Original blocks transformed.
  6724. * @param {Object[]} index Index of the transformed block on the array of results.
  6725. * @param {Object[]} results An array all the blocks that resulted from the transformation.
  6726. */
  6727. return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.switchToBlockType.transformedBlock', result, blocks, index, results);
  6728. });
  6729. return ret;
  6730. }
  6731. /**
  6732. * Create a block object from the example API.
  6733. *
  6734. * @param {string} name
  6735. * @param {Object} example
  6736. *
  6737. * @return {Object} block.
  6738. */
  6739. const getBlockFromExample = (name, example) => {
  6740. return createBlock(name, example.attributes, (0,external_lodash_namespaceObject.map)(example.innerBlocks, innerBlock => getBlockFromExample(innerBlock.name, innerBlock)));
  6741. };
  6742. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/utils.js
  6743. /**
  6744. * External dependencies
  6745. */
  6746. /**
  6747. * WordPress dependencies
  6748. */
  6749. /**
  6750. * Internal dependencies
  6751. */
  6752. k([names, a11y]);
  6753. /**
  6754. * Array of icon colors containing a color to be used if the icon color
  6755. * was not explicitly set but the icon background color was.
  6756. *
  6757. * @type {Object}
  6758. */
  6759. const ICON_COLORS = ['#191e23', '#f8f9f9'];
  6760. /**
  6761. * Determines whether the block is a default block
  6762. * and its attributes are equal to the default attributes
  6763. * which means the block is unmodified.
  6764. *
  6765. * @param {WPBlock} block Block Object
  6766. *
  6767. * @return {boolean} Whether the block is an unmodified default block
  6768. */
  6769. function isUnmodifiedDefaultBlock(block) {
  6770. const defaultBlockName = registration_getDefaultBlockName();
  6771. if (block.name !== defaultBlockName) {
  6772. return false;
  6773. } // Cache a created default block if no cache exists or the default block
  6774. // name changed.
  6775. if (!isUnmodifiedDefaultBlock.block || isUnmodifiedDefaultBlock.block.name !== defaultBlockName) {
  6776. isUnmodifiedDefaultBlock.block = createBlock(defaultBlockName);
  6777. }
  6778. const newDefaultBlock = isUnmodifiedDefaultBlock.block;
  6779. const blockType = registration_getBlockType(defaultBlockName);
  6780. return (0,external_lodash_namespaceObject.every)(blockType === null || blockType === void 0 ? void 0 : blockType.attributes, (value, key) => newDefaultBlock.attributes[key] === block.attributes[key]);
  6781. }
  6782. /**
  6783. * Function that checks if the parameter is a valid icon.
  6784. *
  6785. * @param {*} icon Parameter to be checked.
  6786. *
  6787. * @return {boolean} True if the parameter is a valid icon and false otherwise.
  6788. */
  6789. function isValidIcon(icon) {
  6790. return !!icon && ((0,external_lodash_namespaceObject.isString)(icon) || (0,external_wp_element_namespaceObject.isValidElement)(icon) || (0,external_lodash_namespaceObject.isFunction)(icon) || icon instanceof external_wp_element_namespaceObject.Component);
  6791. }
  6792. /**
  6793. * Function that receives an icon as set by the blocks during the registration
  6794. * and returns a new icon object that is normalized so we can rely on just on possible icon structure
  6795. * in the codebase.
  6796. *
  6797. * @param {WPBlockTypeIconRender} icon Render behavior of a block type icon;
  6798. * one of a Dashicon slug, an element, or a
  6799. * component.
  6800. *
  6801. * @return {WPBlockTypeIconDescriptor} Object describing the icon.
  6802. */
  6803. function normalizeIconObject(icon) {
  6804. icon = icon || BLOCK_ICON_DEFAULT;
  6805. if (isValidIcon(icon)) {
  6806. return {
  6807. src: icon
  6808. };
  6809. }
  6810. if ((0,external_lodash_namespaceObject.has)(icon, ['background'])) {
  6811. const colordBgColor = w(icon.background);
  6812. return { ...icon,
  6813. foreground: icon.foreground ? icon.foreground : (0,external_lodash_namespaceObject.maxBy)(ICON_COLORS, iconColor => colordBgColor.contrast(iconColor)),
  6814. shadowColor: colordBgColor.alpha(0.3).toRgbString()
  6815. };
  6816. }
  6817. return icon;
  6818. }
  6819. /**
  6820. * Normalizes block type passed as param. When string is passed then
  6821. * it converts it to the matching block type object.
  6822. * It passes the original object otherwise.
  6823. *
  6824. * @param {string|Object} blockTypeOrName Block type or name.
  6825. *
  6826. * @return {?Object} Block type.
  6827. */
  6828. function normalizeBlockType(blockTypeOrName) {
  6829. if ((0,external_lodash_namespaceObject.isString)(blockTypeOrName)) {
  6830. return registration_getBlockType(blockTypeOrName);
  6831. }
  6832. return blockTypeOrName;
  6833. }
  6834. /**
  6835. * Get the label for the block, usually this is either the block title,
  6836. * or the value of the block's `label` function when that's specified.
  6837. *
  6838. * @param {Object} blockType The block type.
  6839. * @param {Object} attributes The values of the block's attributes.
  6840. * @param {Object} context The intended use for the label.
  6841. *
  6842. * @return {string} The block label.
  6843. */
  6844. function getBlockLabel(blockType, attributes) {
  6845. let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'visual';
  6846. const {
  6847. __experimentalLabel: getLabel,
  6848. title
  6849. } = blockType;
  6850. const label = getLabel && getLabel(attributes, {
  6851. context
  6852. });
  6853. if (!label) {
  6854. return title;
  6855. } // Strip any HTML (i.e. RichText formatting) before returning.
  6856. return (0,external_wp_dom_namespaceObject.__unstableStripHTML)(label);
  6857. }
  6858. /**
  6859. * Get a label for the block for use by screenreaders, this is more descriptive
  6860. * than the visual label and includes the block title and the value of the
  6861. * `getLabel` function if it's specified.
  6862. *
  6863. * @param {Object} blockType The block type.
  6864. * @param {Object} attributes The values of the block's attributes.
  6865. * @param {?number} position The position of the block in the block list.
  6866. * @param {string} [direction='vertical'] The direction of the block layout.
  6867. *
  6868. * @return {string} The block label.
  6869. */
  6870. function getAccessibleBlockLabel(blockType, attributes, position) {
  6871. let direction = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'vertical';
  6872. // `title` is already localized, `label` is a user-supplied value.
  6873. const title = blockType === null || blockType === void 0 ? void 0 : blockType.title;
  6874. const label = blockType ? getBlockLabel(blockType, attributes, 'accessibility') : '';
  6875. const hasPosition = position !== undefined; // getBlockLabel returns the block title as a fallback when there's no label,
  6876. // if it did return the title, this function needs to avoid adding the
  6877. // title twice within the accessible label. Use this `hasLabel` boolean to
  6878. // handle that.
  6879. const hasLabel = label && label !== title;
  6880. if (hasPosition && direction === 'vertical') {
  6881. if (hasLabel) {
  6882. return (0,external_wp_i18n_namespaceObject.sprintf)(
  6883. /* translators: accessibility text. 1: The block title. 2: The block row number. 3: The block label.. */
  6884. (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Row %2$d. %3$s'), title, position, label);
  6885. }
  6886. return (0,external_wp_i18n_namespaceObject.sprintf)(
  6887. /* translators: accessibility text. 1: The block title. 2: The block row number. */
  6888. (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Row %2$d'), title, position);
  6889. } else if (hasPosition && direction === 'horizontal') {
  6890. if (hasLabel) {
  6891. return (0,external_wp_i18n_namespaceObject.sprintf)(
  6892. /* translators: accessibility text. 1: The block title. 2: The block column number. 3: The block label.. */
  6893. (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Column %2$d. %3$s'), title, position, label);
  6894. }
  6895. return (0,external_wp_i18n_namespaceObject.sprintf)(
  6896. /* translators: accessibility text. 1: The block title. 2: The block column number. */
  6897. (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Column %2$d'), title, position);
  6898. }
  6899. if (hasLabel) {
  6900. return (0,external_wp_i18n_namespaceObject.sprintf)(
  6901. /* translators: accessibility text. %1: The block title. %2: The block label. */
  6902. (0,external_wp_i18n_namespaceObject.__)('%1$s Block. %2$s'), title, label);
  6903. }
  6904. return (0,external_wp_i18n_namespaceObject.sprintf)(
  6905. /* translators: accessibility text. %s: The block title. */
  6906. (0,external_wp_i18n_namespaceObject.__)('%s Block'), title);
  6907. }
  6908. /**
  6909. * Ensure attributes contains only values defined by block type, and merge
  6910. * default values for missing attributes.
  6911. *
  6912. * @param {string} name The block's name.
  6913. * @param {Object} attributes The block's attributes.
  6914. * @return {Object} The sanitized attributes.
  6915. */
  6916. function __experimentalSanitizeBlockAttributes(name, attributes) {
  6917. // Get the type definition associated with a registered block.
  6918. const blockType = registration_getBlockType(name);
  6919. if (undefined === blockType) {
  6920. throw new Error(`Block type '${name}' is not registered.`);
  6921. }
  6922. return (0,external_lodash_namespaceObject.reduce)(blockType.attributes, (accumulator, schema, key) => {
  6923. const value = attributes[key];
  6924. if (undefined !== value) {
  6925. accumulator[key] = value;
  6926. } else if (schema.hasOwnProperty('default')) {
  6927. accumulator[key] = schema.default;
  6928. }
  6929. if (['node', 'children'].indexOf(schema.source) !== -1) {
  6930. // Ensure value passed is always an array, which we're expecting in
  6931. // the RichText component to handle the deprecated value.
  6932. if (typeof accumulator[key] === 'string') {
  6933. accumulator[key] = [accumulator[key]];
  6934. } else if (!Array.isArray(accumulator[key])) {
  6935. accumulator[key] = [];
  6936. }
  6937. }
  6938. return accumulator;
  6939. }, {});
  6940. }
  6941. /**
  6942. * Filter block attributes by `role` and return their names.
  6943. *
  6944. * @param {string} name Block attribute's name.
  6945. * @param {string} role The role of a block attribute.
  6946. *
  6947. * @return {string[]} The attribute names that have the provided role.
  6948. */
  6949. function __experimentalGetBlockAttributesNamesByRole(name, role) {
  6950. var _getBlockType;
  6951. const attributes = (_getBlockType = registration_getBlockType(name)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.attributes;
  6952. if (!attributes) return [];
  6953. const attributesNames = Object.keys(attributes);
  6954. if (!role) return attributesNames;
  6955. return attributesNames.filter(attributeName => {
  6956. var _attributes$attribute;
  6957. return ((_attributes$attribute = attributes[attributeName]) === null || _attributes$attribute === void 0 ? void 0 : _attributes$attribute.__experimentalRole) === role;
  6958. });
  6959. }
  6960. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/actions.js
  6961. /**
  6962. * External dependencies
  6963. */
  6964. /**
  6965. * WordPress dependencies
  6966. */
  6967. /**
  6968. * Internal dependencies
  6969. */
  6970. /** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */
  6971. const {
  6972. error,
  6973. warn
  6974. } = window.console;
  6975. /**
  6976. * Mapping of legacy category slugs to their latest normal values, used to
  6977. * accommodate updates of the default set of block categories.
  6978. *
  6979. * @type {Record<string,string>}
  6980. */
  6981. const LEGACY_CATEGORY_MAPPING = {
  6982. common: 'text',
  6983. formatting: 'text',
  6984. layout: 'design'
  6985. };
  6986. /**
  6987. * Takes the unprocessed block type data and applies all the existing filters for the registered block type.
  6988. * Next, it validates all the settings and performs additional processing to the block type definition.
  6989. *
  6990. * @param {WPBlockType} blockType Unprocessed block type settings.
  6991. * @param {Object} thunkArgs Argument object for the thunk middleware.
  6992. * @param {Function} thunkArgs.select Function to select from the store.
  6993. *
  6994. * @return {?WPBlockType} The block, if it has been successfully registered; otherwise `undefined`.
  6995. */
  6996. const processBlockType = (blockType, _ref) => {
  6997. let {
  6998. select
  6999. } = _ref;
  7000. const {
  7001. name
  7002. } = blockType;
  7003. const settings = (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.registerBlockType', { ...blockType
  7004. }, name);
  7005. if (settings.deprecated) {
  7006. settings.deprecated = settings.deprecated.map(deprecation => (0,external_lodash_namespaceObject.pick)( // Only keep valid deprecation keys.
  7007. (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.registerBlockType', // Merge deprecation keys with pre-filter settings
  7008. // so that filters that depend on specific keys being
  7009. // present don't fail.
  7010. { // Omit deprecation keys here so that deprecations
  7011. // can opt out of specific keys like "supports".
  7012. ...(0,external_lodash_namespaceObject.omit)(blockType, DEPRECATED_ENTRY_KEYS),
  7013. ...deprecation
  7014. }, name), DEPRECATED_ENTRY_KEYS));
  7015. }
  7016. if (!(0,external_lodash_namespaceObject.isPlainObject)(settings)) {
  7017. error('Block settings must be a valid object.');
  7018. return;
  7019. }
  7020. if (!(0,external_lodash_namespaceObject.isFunction)(settings.save)) {
  7021. error('The "save" property must be a valid function.');
  7022. return;
  7023. }
  7024. if ('edit' in settings && !(0,external_lodash_namespaceObject.isFunction)(settings.edit)) {
  7025. error('The "edit" property must be a valid function.');
  7026. return;
  7027. } // Canonicalize legacy categories to equivalent fallback.
  7028. if (LEGACY_CATEGORY_MAPPING.hasOwnProperty(settings.category)) {
  7029. settings.category = LEGACY_CATEGORY_MAPPING[settings.category];
  7030. }
  7031. if ('category' in settings && !(0,external_lodash_namespaceObject.some)(select.getCategories(), {
  7032. slug: settings.category
  7033. })) {
  7034. warn('The block "' + name + '" is registered with an invalid category "' + settings.category + '".');
  7035. delete settings.category;
  7036. }
  7037. if (!('title' in settings) || settings.title === '') {
  7038. error('The block "' + name + '" must have a title.');
  7039. return;
  7040. }
  7041. if (typeof settings.title !== 'string') {
  7042. error('Block titles must be strings.');
  7043. return;
  7044. }
  7045. settings.icon = normalizeIconObject(settings.icon);
  7046. if (!isValidIcon(settings.icon.src)) {
  7047. error('The icon passed is invalid. ' + 'The icon should be a string, an element, a function, or an object following the specifications documented in https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#icon-optional');
  7048. return;
  7049. }
  7050. return settings;
  7051. };
  7052. /**
  7053. * Returns an action object used in signalling that block types have been added.
  7054. *
  7055. * @param {Array|Object} blockTypes Block types received.
  7056. *
  7057. * @return {Object} Action object.
  7058. */
  7059. function addBlockTypes(blockTypes) {
  7060. return {
  7061. type: 'ADD_BLOCK_TYPES',
  7062. blockTypes: (0,external_lodash_namespaceObject.castArray)(blockTypes)
  7063. };
  7064. }
  7065. /**
  7066. * Signals that the passed block type's settings should be stored in the state.
  7067. *
  7068. * @param {WPBlockType} blockType Unprocessed block type settings.
  7069. */
  7070. const __experimentalRegisterBlockType = blockType => _ref2 => {
  7071. let {
  7072. dispatch,
  7073. select
  7074. } = _ref2;
  7075. dispatch({
  7076. type: 'ADD_UNPROCESSED_BLOCK_TYPE',
  7077. blockType
  7078. });
  7079. const processedBlockType = processBlockType(blockType, {
  7080. select
  7081. });
  7082. if (!processedBlockType) {
  7083. return;
  7084. }
  7085. dispatch.addBlockTypes(processedBlockType);
  7086. };
  7087. /**
  7088. * Signals that all block types should be computed again.
  7089. * It uses stored unprocessed block types and all the most recent list of registered filters.
  7090. *
  7091. * It addresses the issue where third party block filters get registered after third party blocks. A sample sequence:
  7092. * 1. Filter A.
  7093. * 2. Block B.
  7094. * 3. Block C.
  7095. * 4. Filter D.
  7096. * 5. Filter E.
  7097. * 6. Block F.
  7098. * 7. Filter G.
  7099. * In this scenario some filters would not get applied for all blocks because they are registered too late.
  7100. */
  7101. const __experimentalReapplyBlockTypeFilters = () => _ref3 => {
  7102. let {
  7103. dispatch,
  7104. select
  7105. } = _ref3;
  7106. const unprocessedBlockTypes = select.__experimentalGetUnprocessedBlockTypes();
  7107. const processedBlockTypes = Object.keys(unprocessedBlockTypes).reduce((accumulator, blockName) => {
  7108. const result = processBlockType(unprocessedBlockTypes[blockName], {
  7109. select
  7110. });
  7111. if (result) {
  7112. accumulator.push(result);
  7113. }
  7114. return accumulator;
  7115. }, []);
  7116. if (!processedBlockTypes.length) {
  7117. return;
  7118. }
  7119. dispatch.addBlockTypes(processedBlockTypes);
  7120. };
  7121. /**
  7122. * Returns an action object used to remove a registered block type.
  7123. *
  7124. * @param {string|Array} names Block name.
  7125. *
  7126. * @return {Object} Action object.
  7127. */
  7128. function removeBlockTypes(names) {
  7129. return {
  7130. type: 'REMOVE_BLOCK_TYPES',
  7131. names: (0,external_lodash_namespaceObject.castArray)(names)
  7132. };
  7133. }
  7134. /**
  7135. * Returns an action object used in signalling that new block styles have been added.
  7136. *
  7137. * @param {string} blockName Block name.
  7138. * @param {Array|Object} styles Block styles.
  7139. *
  7140. * @return {Object} Action object.
  7141. */
  7142. function addBlockStyles(blockName, styles) {
  7143. return {
  7144. type: 'ADD_BLOCK_STYLES',
  7145. styles: (0,external_lodash_namespaceObject.castArray)(styles),
  7146. blockName
  7147. };
  7148. }
  7149. /**
  7150. * Returns an action object used in signalling that block styles have been removed.
  7151. *
  7152. * @param {string} blockName Block name.
  7153. * @param {Array|string} styleNames Block style names.
  7154. *
  7155. * @return {Object} Action object.
  7156. */
  7157. function removeBlockStyles(blockName, styleNames) {
  7158. return {
  7159. type: 'REMOVE_BLOCK_STYLES',
  7160. styleNames: (0,external_lodash_namespaceObject.castArray)(styleNames),
  7161. blockName
  7162. };
  7163. }
  7164. /**
  7165. * Returns an action object used in signalling that new block variations have been added.
  7166. *
  7167. * @param {string} blockName Block name.
  7168. * @param {WPBlockVariation|WPBlockVariation[]} variations Block variations.
  7169. *
  7170. * @return {Object} Action object.
  7171. */
  7172. function addBlockVariations(blockName, variations) {
  7173. return {
  7174. type: 'ADD_BLOCK_VARIATIONS',
  7175. variations: (0,external_lodash_namespaceObject.castArray)(variations),
  7176. blockName
  7177. };
  7178. }
  7179. /**
  7180. * Returns an action object used in signalling that block variations have been removed.
  7181. *
  7182. * @param {string} blockName Block name.
  7183. * @param {string|string[]} variationNames Block variation names.
  7184. *
  7185. * @return {Object} Action object.
  7186. */
  7187. function removeBlockVariations(blockName, variationNames) {
  7188. return {
  7189. type: 'REMOVE_BLOCK_VARIATIONS',
  7190. variationNames: (0,external_lodash_namespaceObject.castArray)(variationNames),
  7191. blockName
  7192. };
  7193. }
  7194. /**
  7195. * Returns an action object used to set the default block name.
  7196. *
  7197. * @param {string} name Block name.
  7198. *
  7199. * @return {Object} Action object.
  7200. */
  7201. function actions_setDefaultBlockName(name) {
  7202. return {
  7203. type: 'SET_DEFAULT_BLOCK_NAME',
  7204. name
  7205. };
  7206. }
  7207. /**
  7208. * Returns an action object used to set the name of the block used as a fallback
  7209. * for non-block content.
  7210. *
  7211. * @param {string} name Block name.
  7212. *
  7213. * @return {Object} Action object.
  7214. */
  7215. function setFreeformFallbackBlockName(name) {
  7216. return {
  7217. type: 'SET_FREEFORM_FALLBACK_BLOCK_NAME',
  7218. name
  7219. };
  7220. }
  7221. /**
  7222. * Returns an action object used to set the name of the block used as a fallback
  7223. * for unregistered blocks.
  7224. *
  7225. * @param {string} name Block name.
  7226. *
  7227. * @return {Object} Action object.
  7228. */
  7229. function setUnregisteredFallbackBlockName(name) {
  7230. return {
  7231. type: 'SET_UNREGISTERED_FALLBACK_BLOCK_NAME',
  7232. name
  7233. };
  7234. }
  7235. /**
  7236. * Returns an action object used to set the name of the block used
  7237. * when grouping other blocks
  7238. * eg: in "Group/Ungroup" interactions
  7239. *
  7240. * @param {string} name Block name.
  7241. *
  7242. * @return {Object} Action object.
  7243. */
  7244. function actions_setGroupingBlockName(name) {
  7245. return {
  7246. type: 'SET_GROUPING_BLOCK_NAME',
  7247. name
  7248. };
  7249. }
  7250. /**
  7251. * Returns an action object used to set block categories.
  7252. *
  7253. * @param {Object[]} categories Block categories.
  7254. *
  7255. * @return {Object} Action object.
  7256. */
  7257. function setCategories(categories) {
  7258. return {
  7259. type: 'SET_CATEGORIES',
  7260. categories
  7261. };
  7262. }
  7263. /**
  7264. * Returns an action object used to update a category.
  7265. *
  7266. * @param {string} slug Block category slug.
  7267. * @param {Object} category Object containing the category properties that should be updated.
  7268. *
  7269. * @return {Object} Action object.
  7270. */
  7271. function updateCategory(slug, category) {
  7272. return {
  7273. type: 'UPDATE_CATEGORY',
  7274. slug,
  7275. category
  7276. };
  7277. }
  7278. /**
  7279. * Returns an action object used to add block collections
  7280. *
  7281. * @param {string} namespace The namespace of the blocks to put in the collection
  7282. * @param {string} title The title to display in the block inserter
  7283. * @param {Object} icon (optional) The icon to display in the block inserter
  7284. *
  7285. * @return {Object} Action object.
  7286. */
  7287. function addBlockCollection(namespace, title, icon) {
  7288. return {
  7289. type: 'ADD_BLOCK_COLLECTION',
  7290. namespace,
  7291. title,
  7292. icon
  7293. };
  7294. }
  7295. /**
  7296. * Returns an action object used to remove block collections
  7297. *
  7298. * @param {string} namespace The namespace of the blocks to put in the collection
  7299. *
  7300. * @return {Object} Action object.
  7301. */
  7302. function removeBlockCollection(namespace) {
  7303. return {
  7304. type: 'REMOVE_BLOCK_COLLECTION',
  7305. namespace
  7306. };
  7307. }
  7308. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/constants.js
  7309. const STORE_NAME = 'core/blocks';
  7310. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/index.js
  7311. /**
  7312. * WordPress dependencies
  7313. */
  7314. /**
  7315. * Internal dependencies
  7316. */
  7317. /**
  7318. * Store definition for the blocks namespace.
  7319. *
  7320. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  7321. *
  7322. * @type {Object}
  7323. */
  7324. const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
  7325. reducer: reducer,
  7326. selectors: selectors_namespaceObject,
  7327. actions: actions_namespaceObject
  7328. });
  7329. (0,external_wp_data_namespaceObject.register)(store);
  7330. ;// CONCATENATED MODULE: external ["wp","blockSerializationDefaultParser"]
  7331. var external_wp_blockSerializationDefaultParser_namespaceObject = window["wp"]["blockSerializationDefaultParser"];
  7332. ;// CONCATENATED MODULE: external ["wp","autop"]
  7333. var external_wp_autop_namespaceObject = window["wp"]["autop"];
  7334. ;// CONCATENATED MODULE: external ["wp","isShallowEqual"]
  7335. var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
  7336. var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject);
  7337. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/serialize-raw-block.js
  7338. /**
  7339. * Internal dependencies
  7340. */
  7341. /**
  7342. * @typedef {Object} Options Serialization options.
  7343. * @property {boolean} [isCommentDelimited=true] Whether to output HTML comments around blocks.
  7344. */
  7345. /** @typedef {import("./").WPRawBlock} WPRawBlock */
  7346. /**
  7347. * Serializes a block node into the native HTML-comment-powered block format.
  7348. * CAVEAT: This function is intended for re-serializing blocks as parsed by
  7349. * valid parsers and skips any validation steps. This is NOT a generic
  7350. * serialization function for in-memory blocks. For most purposes, see the
  7351. * following functions available in the `@wordpress/blocks` package:
  7352. *
  7353. * @see serializeBlock
  7354. * @see serialize
  7355. *
  7356. * For more on the format of block nodes as returned by valid parsers:
  7357. *
  7358. * @see `@wordpress/block-serialization-default-parser` package
  7359. * @see `@wordpress/block-serialization-spec-parser` package
  7360. *
  7361. * @param {WPRawBlock} rawBlock A block node as returned by a valid parser.
  7362. * @param {Options} [options={}] Serialization options.
  7363. *
  7364. * @return {string} An HTML string representing a block.
  7365. */
  7366. function serializeRawBlock(rawBlock) {
  7367. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  7368. const {
  7369. isCommentDelimited = true
  7370. } = options;
  7371. const {
  7372. blockName,
  7373. attrs = {},
  7374. innerBlocks = [],
  7375. innerContent = []
  7376. } = rawBlock;
  7377. let childIndex = 0;
  7378. const content = innerContent.map(item => // `null` denotes a nested block, otherwise we have an HTML fragment.
  7379. item !== null ? item : serializeRawBlock(innerBlocks[childIndex++], options)).join('\n').replace(/\n+/g, '\n').trim();
  7380. return isCommentDelimited ? getCommentDelimitedContent(blockName, attrs, content) : content;
  7381. }
  7382. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/serializer.js
  7383. /**
  7384. * External dependencies
  7385. */
  7386. /**
  7387. * WordPress dependencies
  7388. */
  7389. /**
  7390. * Internal dependencies
  7391. */
  7392. /** @typedef {import('./parser').WPBlock} WPBlock */
  7393. /**
  7394. * @typedef {Object} WPBlockSerializationOptions Serialization Options.
  7395. *
  7396. * @property {boolean} isInnerBlocks Whether we are serializing inner blocks.
  7397. */
  7398. /**
  7399. * Returns the block's default classname from its name.
  7400. *
  7401. * @param {string} blockName The block name.
  7402. *
  7403. * @return {string} The block's default class.
  7404. */
  7405. function getBlockDefaultClassName(blockName) {
  7406. // Generated HTML classes for blocks follow the `wp-block-{name}` nomenclature.
  7407. // Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (historically used in 'core-embed/').
  7408. const className = 'wp-block-' + blockName.replace(/\//, '-').replace(/^core-/, '');
  7409. return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockDefaultClassName', className, blockName);
  7410. }
  7411. /**
  7412. * Returns the block's default menu item classname from its name.
  7413. *
  7414. * @param {string} blockName The block name.
  7415. *
  7416. * @return {string} The block's default menu item class.
  7417. */
  7418. function getBlockMenuDefaultClassName(blockName) {
  7419. // Generated HTML classes for blocks follow the `editor-block-list-item-{name}` nomenclature.
  7420. // Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (historically used in 'core-embed/').
  7421. const className = 'editor-block-list-item-' + blockName.replace(/\//, '-').replace(/^core-/, '');
  7422. return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockMenuDefaultClassName', className, blockName);
  7423. }
  7424. const blockPropsProvider = {};
  7425. const innerBlocksPropsProvider = {};
  7426. /**
  7427. * Call within a save function to get the props for the block wrapper.
  7428. *
  7429. * @param {Object} props Optional. Props to pass to the element.
  7430. */
  7431. function getBlockProps() {
  7432. let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7433. const {
  7434. blockType,
  7435. attributes
  7436. } = blockPropsProvider;
  7437. return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveContent.extraProps', { ...props
  7438. }, blockType, attributes);
  7439. }
  7440. /**
  7441. * Call within a save function to get the props for the inner blocks wrapper.
  7442. *
  7443. * @param {Object} props Optional. Props to pass to the element.
  7444. */
  7445. function getInnerBlocksProps() {
  7446. let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7447. const {
  7448. innerBlocks
  7449. } = innerBlocksPropsProvider; // Value is an array of blocks, so defer to block serializer.
  7450. const html = serializer_serialize(innerBlocks, {
  7451. isInnerBlocks: true
  7452. }); // Use special-cased raw HTML tag to avoid default escaping.
  7453. const children = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, html);
  7454. return { ...props,
  7455. children
  7456. };
  7457. }
  7458. /**
  7459. * Given a block type containing a save render implementation and attributes, returns the
  7460. * enhanced element to be saved or string when raw HTML expected.
  7461. *
  7462. * @param {string|Object} blockTypeOrName Block type or name.
  7463. * @param {Object} attributes Block attributes.
  7464. * @param {?Array} innerBlocks Nested blocks.
  7465. *
  7466. * @return {Object|string} Save element or raw HTML string.
  7467. */
  7468. function getSaveElement(blockTypeOrName, attributes) {
  7469. let innerBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
  7470. const blockType = normalizeBlockType(blockTypeOrName);
  7471. let {
  7472. save
  7473. } = blockType; // Component classes are unsupported for save since serialization must
  7474. // occur synchronously. For improved interoperability with higher-order
  7475. // components which often return component class, emulate basic support.
  7476. if (save.prototype instanceof external_wp_element_namespaceObject.Component) {
  7477. const instance = new save({
  7478. attributes
  7479. });
  7480. save = instance.render.bind(instance);
  7481. }
  7482. blockPropsProvider.blockType = blockType;
  7483. blockPropsProvider.attributes = attributes;
  7484. innerBlocksPropsProvider.innerBlocks = innerBlocks;
  7485. let element = save({
  7486. attributes,
  7487. innerBlocks
  7488. });
  7489. if ((0,external_lodash_namespaceObject.isObject)(element) && (0,external_wp_hooks_namespaceObject.hasFilter)('blocks.getSaveContent.extraProps') && !(blockType.apiVersion > 1)) {
  7490. /**
  7491. * Filters the props applied to the block save result element.
  7492. *
  7493. * @param {Object} props Props applied to save element.
  7494. * @param {WPBlock} blockType Block type definition.
  7495. * @param {Object} attributes Block attributes.
  7496. */
  7497. const props = (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveContent.extraProps', { ...element.props
  7498. }, blockType, attributes);
  7499. if (!external_wp_isShallowEqual_default()(props, element.props)) {
  7500. element = (0,external_wp_element_namespaceObject.cloneElement)(element, props);
  7501. }
  7502. }
  7503. /**
  7504. * Filters the save result of a block during serialization.
  7505. *
  7506. * @param {WPElement} element Block save result.
  7507. * @param {WPBlock} blockType Block type definition.
  7508. * @param {Object} attributes Block attributes.
  7509. */
  7510. return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveElement', element, blockType, attributes);
  7511. }
  7512. /**
  7513. * Given a block type containing a save render implementation and attributes, returns the
  7514. * static markup to be saved.
  7515. *
  7516. * @param {string|Object} blockTypeOrName Block type or name.
  7517. * @param {Object} attributes Block attributes.
  7518. * @param {?Array} innerBlocks Nested blocks.
  7519. *
  7520. * @return {string} Save content.
  7521. */
  7522. function getSaveContent(blockTypeOrName, attributes, innerBlocks) {
  7523. const blockType = normalizeBlockType(blockTypeOrName);
  7524. return (0,external_wp_element_namespaceObject.renderToString)(getSaveElement(blockType, attributes, innerBlocks));
  7525. }
  7526. /**
  7527. * Returns attributes which are to be saved and serialized into the block
  7528. * comment delimiter.
  7529. *
  7530. * When a block exists in memory it contains as its attributes both those
  7531. * parsed the block comment delimiter _and_ those which matched from the
  7532. * contents of the block.
  7533. *
  7534. * This function returns only those attributes which are needed to persist and
  7535. * which cannot be matched from the block content.
  7536. *
  7537. * @param {Object<string,*>} blockType Block type.
  7538. * @param {Object<string,*>} attributes Attributes from in-memory block data.
  7539. *
  7540. * @return {Object<string,*>} Subset of attributes for comment serialization.
  7541. */
  7542. function getCommentAttributes(blockType, attributes) {
  7543. return (0,external_lodash_namespaceObject.reduce)(blockType.attributes, (accumulator, attributeSchema, key) => {
  7544. const value = attributes[key]; // Ignore undefined values.
  7545. if (undefined === value) {
  7546. return accumulator;
  7547. } // Ignore all attributes but the ones with an "undefined" source
  7548. // "undefined" source refers to attributes saved in the block comment.
  7549. if (attributeSchema.source !== undefined) {
  7550. return accumulator;
  7551. } // Ignore default value.
  7552. if ('default' in attributeSchema && attributeSchema.default === value) {
  7553. return accumulator;
  7554. } // Otherwise, include in comment set.
  7555. accumulator[key] = value;
  7556. return accumulator;
  7557. }, {});
  7558. }
  7559. /**
  7560. * Given an attributes object, returns a string in the serialized attributes
  7561. * format prepared for post content.
  7562. *
  7563. * @param {Object} attributes Attributes object.
  7564. *
  7565. * @return {string} Serialized attributes.
  7566. */
  7567. function serializeAttributes(attributes) {
  7568. return JSON.stringify(attributes) // Don't break HTML comments.
  7569. .replace(/--/g, '\\u002d\\u002d') // Don't break non-standard-compliant tools.
  7570. .replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026') // Bypass server stripslashes behavior which would unescape stringify's
  7571. // escaping of quotation mark.
  7572. //
  7573. // See: https://developer.wordpress.org/reference/functions/wp_kses_stripslashes/
  7574. .replace(/\\"/g, '\\u0022');
  7575. }
  7576. /**
  7577. * Given a block object, returns the Block's Inner HTML markup.
  7578. *
  7579. * @param {Object} block Block instance.
  7580. *
  7581. * @return {string} HTML.
  7582. */
  7583. function getBlockInnerHTML(block) {
  7584. // If block was parsed as invalid or encounters an error while generating
  7585. // save content, use original content instead to avoid content loss. If a
  7586. // block contains nested content, exempt it from this condition because we
  7587. // otherwise have no access to its original content and content loss would
  7588. // still occur.
  7589. let saveContent = block.originalContent;
  7590. if (block.isValid || block.innerBlocks.length) {
  7591. try {
  7592. saveContent = getSaveContent(block.name, block.attributes, block.innerBlocks);
  7593. } catch (error) {}
  7594. }
  7595. return saveContent;
  7596. }
  7597. /**
  7598. * Returns the content of a block, including comment delimiters.
  7599. *
  7600. * @param {string} rawBlockName Block name.
  7601. * @param {Object} attributes Block attributes.
  7602. * @param {string} content Block save content.
  7603. *
  7604. * @return {string} Comment-delimited block content.
  7605. */
  7606. function getCommentDelimitedContent(rawBlockName, attributes, content) {
  7607. const serializedAttributes = !(0,external_lodash_namespaceObject.isEmpty)(attributes) ? serializeAttributes(attributes) + ' ' : ''; // Strip core blocks of their namespace prefix.
  7608. const blockName = (0,external_lodash_namespaceObject.startsWith)(rawBlockName, 'core/') ? rawBlockName.slice(5) : rawBlockName; // @todo make the `wp:` prefix potentially configurable.
  7609. if (!content) {
  7610. return `<!-- wp:${blockName} ${serializedAttributes}/-->`;
  7611. }
  7612. return `<!-- wp:${blockName} ${serializedAttributes}-->\n` + content + `\n<!-- /wp:${blockName} -->`;
  7613. }
  7614. /**
  7615. * Returns the content of a block, including comment delimiters, determining
  7616. * serialized attributes and content form from the current state of the block.
  7617. *
  7618. * @param {WPBlock} block Block instance.
  7619. * @param {WPBlockSerializationOptions} options Serialization options.
  7620. *
  7621. * @return {string} Serialized block.
  7622. */
  7623. function serializeBlock(block) {
  7624. let {
  7625. isInnerBlocks = false
  7626. } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  7627. if (!block.isValid && block.__unstableBlockSource) {
  7628. return serializeRawBlock(block.__unstableBlockSource);
  7629. }
  7630. const blockName = block.name;
  7631. const saveContent = getBlockInnerHTML(block);
  7632. if (blockName === getUnregisteredTypeHandlerName() || !isInnerBlocks && blockName === getFreeformContentHandlerName()) {
  7633. return saveContent;
  7634. }
  7635. const blockType = registration_getBlockType(blockName);
  7636. const saveAttributes = getCommentAttributes(blockType, block.attributes);
  7637. return getCommentDelimitedContent(blockName, saveAttributes, saveContent);
  7638. }
  7639. function __unstableSerializeAndClean(blocks) {
  7640. // A single unmodified default block is assumed to
  7641. // be equivalent to an empty post.
  7642. if (blocks.length === 1 && isUnmodifiedDefaultBlock(blocks[0])) {
  7643. blocks = [];
  7644. }
  7645. let content = serializer_serialize(blocks); // For compatibility, treat a post consisting of a
  7646. // single freeform block as legacy content and apply
  7647. // pre-block-editor removep'd content formatting.
  7648. if (blocks.length === 1 && blocks[0].name === getFreeformContentHandlerName()) {
  7649. content = (0,external_wp_autop_namespaceObject.removep)(content);
  7650. }
  7651. return content;
  7652. }
  7653. /**
  7654. * Takes a block or set of blocks and returns the serialized post content.
  7655. *
  7656. * @param {Array} blocks Block(s) to serialize.
  7657. * @param {WPBlockSerializationOptions} options Serialization options.
  7658. *
  7659. * @return {string} The post content.
  7660. */
  7661. function serializer_serialize(blocks, options) {
  7662. return (0,external_lodash_namespaceObject.castArray)(blocks).map(block => serializeBlock(block, options)).join('\n\n');
  7663. }
  7664. ;// CONCATENATED MODULE: ./node_modules/simple-html-tokenizer/dist/es6/index.js
  7665. /**
  7666. * generated from https://raw.githubusercontent.com/w3c/html/26b5126f96f736f796b9e29718138919dd513744/entities.json
  7667. * do not edit
  7668. */
  7669. var namedCharRefs = {
  7670. Aacute: "Á", aacute: "á", Abreve: "Ă", abreve: "ă", ac: "∾", acd: "∿", acE: "∾̳", Acirc: "Â", acirc: "â", acute: "´", Acy: "А", acy: "а", AElig: "Æ", aelig: "æ", af: "\u2061", Afr: "𝔄", afr: "𝔞", Agrave: "À", agrave: "à", alefsym: "ℵ", aleph: "ℵ", Alpha: "Α", alpha: "α", Amacr: "Ā", amacr: "ā", amalg: "⨿", amp: "&", AMP: "&", andand: "⩕", And: "⩓", and: "∧", andd: "⩜", andslope: "⩘", andv: "⩚", ang: "∠", ange: "⦤", angle: "∠", angmsdaa: "⦨", angmsdab: "⦩", angmsdac: "⦪", angmsdad: "⦫", angmsdae: "⦬", angmsdaf: "⦭", angmsdag: "⦮", angmsdah: "⦯", angmsd: "∡", angrt: "∟", angrtvb: "⊾", angrtvbd: "⦝", angsph: "∢", angst: "Å", angzarr: "⍼", Aogon: "Ą", aogon: "ą", Aopf: "𝔸", aopf: "𝕒", apacir: "⩯", ap: "≈", apE: "⩰", ape: "≊", apid: "≋", apos: "'", ApplyFunction: "\u2061", approx: "≈", approxeq: "≊", Aring: "Å", aring: "å", Ascr: "𝒜", ascr: "𝒶", Assign: "≔", ast: "*", asymp: "≈", asympeq: "≍", Atilde: "Ã", atilde: "ã", Auml: "Ä", auml: "ä", awconint: "∳", awint: "⨑", backcong: "≌", backepsilon: "϶", backprime: "‵", backsim: "∽", backsimeq: "⋍", Backslash: "∖", Barv: "⫧", barvee: "⊽", barwed: "⌅", Barwed: "⌆", barwedge: "⌅", bbrk: "⎵", bbrktbrk: "⎶", bcong: "≌", Bcy: "Б", bcy: "б", bdquo: "„", becaus: "∵", because: "∵", Because: "∵", bemptyv: "⦰", bepsi: "϶", bernou: "ℬ", Bernoullis: "ℬ", Beta: "Β", beta: "β", beth: "ℶ", between: "≬", Bfr: "𝔅", bfr: "𝔟", bigcap: "⋂", bigcirc: "◯", bigcup: "⋃", bigodot: "⨀", bigoplus: "⨁", bigotimes: "⨂", bigsqcup: "⨆", bigstar: "★", bigtriangledown: "▽", bigtriangleup: "△", biguplus: "⨄", bigvee: "⋁", bigwedge: "⋀", bkarow: "⤍", blacklozenge: "⧫", blacksquare: "▪", blacktriangle: "▴", blacktriangledown: "▾", blacktriangleleft: "◂", blacktriangleright: "▸", blank: "␣", blk12: "▒", blk14: "░", blk34: "▓", block: "█", bne: "=⃥", bnequiv: "≡⃥", bNot: "⫭", bnot: "⌐", Bopf: "𝔹", bopf: "𝕓", bot: "⊥", bottom: "⊥", bowtie: "⋈", boxbox: "⧉", boxdl: "┐", boxdL: "╕", boxDl: "╖", boxDL: "╗", boxdr: "┌", boxdR: "╒", boxDr: "╓", boxDR: "╔", boxh: "─", boxH: "═", boxhd: "┬", boxHd: "╤", boxhD: "╥", boxHD: "╦", boxhu: "┴", boxHu: "╧", boxhU: "╨", boxHU: "╩", boxminus: "⊟", boxplus: "⊞", boxtimes: "⊠", boxul: "┘", boxuL: "╛", boxUl: "╜", boxUL: "╝", boxur: "└", boxuR: "╘", boxUr: "╙", boxUR: "╚", boxv: "│", boxV: "║", boxvh: "┼", boxvH: "╪", boxVh: "╫", boxVH: "╬", boxvl: "┤", boxvL: "╡", boxVl: "╢", boxVL: "╣", boxvr: "├", boxvR: "╞", boxVr: "╟", boxVR: "╠", bprime: "‵", breve: "˘", Breve: "˘", brvbar: "¦", bscr: "𝒷", Bscr: "ℬ", bsemi: "⁏", bsim: "∽", bsime: "⋍", bsolb: "⧅", bsol: "\\", bsolhsub: "⟈", bull: "•", bullet: "•", bump: "≎", bumpE: "⪮", bumpe: "≏", Bumpeq: "≎", bumpeq: "≏", Cacute: "Ć", cacute: "ć", capand: "⩄", capbrcup: "⩉", capcap: "⩋", cap: "∩", Cap: "⋒", capcup: "⩇", capdot: "⩀", CapitalDifferentialD: "ⅅ", caps: "∩︀", caret: "⁁", caron: "ˇ", Cayleys: "ℭ", ccaps: "⩍", Ccaron: "Č", ccaron: "č", Ccedil: "Ç", ccedil: "ç", Ccirc: "Ĉ", ccirc: "ĉ", Cconint: "∰", ccups: "⩌", ccupssm: "⩐", Cdot: "Ċ", cdot: "ċ", cedil: "¸", Cedilla: "¸", cemptyv: "⦲", cent: "¢", centerdot: "·", CenterDot: "·", cfr: "𝔠", Cfr: "ℭ", CHcy: "Ч", chcy: "ч", check: "✓", checkmark: "✓", Chi: "Χ", chi: "χ", circ: "ˆ", circeq: "≗", circlearrowleft: "↺", circlearrowright: "↻", circledast: "⊛", circledcirc: "⊚", circleddash: "⊝", CircleDot: "⊙", circledR: "®", circledS: "Ⓢ", CircleMinus: "⊖", CirclePlus: "⊕", CircleTimes: "⊗", cir: "○", cirE: "⧃", cire: "≗", cirfnint: "⨐", cirmid: "⫯", cirscir: "⧂", ClockwiseContourIntegral: "∲", CloseCurlyDoubleQuote: "”", CloseCurlyQuote: "’", clubs: "♣", clubsuit: "♣", colon: ":", Colon: "∷", Colone: "⩴", colone: "≔", coloneq: "≔", comma: ",", commat: "@", comp: "∁", compfn: "∘", complement: "∁", complexes: "ℂ", cong: "≅", congdot: "⩭", Congruent: "≡", conint: "∮", Conint: "∯", ContourIntegral: "∮", copf: "𝕔", Copf: "ℂ", coprod: "∐", Coproduct: "∐", copy: "©", COPY: "©", copysr: "℗", CounterClockwiseContourIntegral: "∳", crarr: "↵", cross: "✗", Cross: "⨯", Cscr: "𝒞", cscr: "𝒸", csub: "⫏", csube: "⫑", csup: "⫐", csupe: "⫒", ctdot: "⋯", cudarrl: "⤸", cudarrr: "⤵", cuepr: "⋞", cuesc: "⋟", cularr: "↶", cularrp: "⤽", cupbrcap: "⩈", cupcap: "⩆", CupCap: "≍", cup: "∪", Cup: "⋓", cupcup: "⩊", cupdot: "⊍", cupor: "⩅", cups: "∪︀", curarr: "↷", curarrm: "⤼", curlyeqprec: "⋞", curlyeqsucc: "⋟", curlyvee: "⋎", curlywedge: "⋏", curren: "¤", curvearrowleft: "↶", curvearrowright: "↷", cuvee: "⋎", cuwed: "⋏", cwconint: "∲", cwint: "∱", cylcty: "⌭", dagger: "†", Dagger: "‡", daleth: "ℸ", darr: "↓", Darr: "↡", dArr: "⇓", dash: "‐", Dashv: "⫤", dashv: "⊣", dbkarow: "⤏", dblac: "˝", Dcaron: "Ď", dcaron: "ď", Dcy: "Д", dcy: "д", ddagger: "‡", ddarr: "⇊", DD: "ⅅ", dd: "ⅆ", DDotrahd: "⤑", ddotseq: "⩷", deg: "°", Del: "∇", Delta: "Δ", delta: "δ", demptyv: "⦱", dfisht: "⥿", Dfr: "𝔇", dfr: "𝔡", dHar: "⥥", dharl: "⇃", dharr: "⇂", DiacriticalAcute: "´", DiacriticalDot: "˙", DiacriticalDoubleAcute: "˝", DiacriticalGrave: "`", DiacriticalTilde: "˜", diam: "⋄", diamond: "⋄", Diamond: "⋄", diamondsuit: "♦", diams: "♦", die: "¨", DifferentialD: "ⅆ", digamma: "ϝ", disin: "⋲", div: "÷", divide: "÷", divideontimes: "⋇", divonx: "⋇", DJcy: "Ђ", djcy: "ђ", dlcorn: "⌞", dlcrop: "⌍", dollar: "$", Dopf: "𝔻", dopf: "𝕕", Dot: "¨", dot: "˙", DotDot: "⃜", doteq: "≐", doteqdot: "≑", DotEqual: "≐", dotminus: "∸", dotplus: "∔", dotsquare: "⊡", doublebarwedge: "⌆", DoubleContourIntegral: "∯", DoubleDot: "¨", DoubleDownArrow: "⇓", DoubleLeftArrow: "⇐", DoubleLeftRightArrow: "⇔", DoubleLeftTee: "⫤", DoubleLongLeftArrow: "⟸", DoubleLongLeftRightArrow: "⟺", DoubleLongRightArrow: "⟹", DoubleRightArrow: "⇒", DoubleRightTee: "⊨", DoubleUpArrow: "⇑", DoubleUpDownArrow: "⇕", DoubleVerticalBar: "∥", DownArrowBar: "⤓", downarrow: "↓", DownArrow: "↓", Downarrow: "⇓", DownArrowUpArrow: "⇵", DownBreve: "̑", downdownarrows: "⇊", downharpoonleft: "⇃", downharpoonright: "⇂", DownLeftRightVector: "⥐", DownLeftTeeVector: "⥞", DownLeftVectorBar: "⥖", DownLeftVector: "↽", DownRightTeeVector: "⥟", DownRightVectorBar: "⥗", DownRightVector: "⇁", DownTeeArrow: "↧", DownTee: "⊤", drbkarow: "⤐", drcorn: "⌟", drcrop: "⌌", Dscr: "𝒟", dscr: "𝒹", DScy: "Ѕ", dscy: "ѕ", dsol: "⧶", Dstrok: "Đ", dstrok: "đ", dtdot: "⋱", dtri: "▿", dtrif: "▾", duarr: "⇵", duhar: "⥯", dwangle: "⦦", DZcy: "Џ", dzcy: "џ", dzigrarr: "⟿", Eacute: "É", eacute: "é", easter: "⩮", Ecaron: "Ě", ecaron: "ě", Ecirc: "Ê", ecirc: "ê", ecir: "≖", ecolon: "≕", Ecy: "Э", ecy: "э", eDDot: "⩷", Edot: "Ė", edot: "ė", eDot: "≑", ee: "ⅇ", efDot: "≒", Efr: "𝔈", efr: "𝔢", eg: "⪚", Egrave: "È", egrave: "è", egs: "⪖", egsdot: "⪘", el: "⪙", Element: "∈", elinters: "⏧", ell: "ℓ", els: "⪕", elsdot: "⪗", Emacr: "Ē", emacr: "ē", empty: "∅", emptyset: "∅", EmptySmallSquare: "◻", emptyv: "∅", EmptyVerySmallSquare: "▫", emsp13: " ", emsp14: " ", emsp: " ", ENG: "Ŋ", eng: "ŋ", ensp: " ", Eogon: "Ę", eogon: "ę", Eopf: "𝔼", eopf: "𝕖", epar: "⋕", eparsl: "⧣", eplus: "⩱", epsi: "ε", Epsilon: "Ε", epsilon: "ε", epsiv: "ϵ", eqcirc: "≖", eqcolon: "≕", eqsim: "≂", eqslantgtr: "⪖", eqslantless: "⪕", Equal: "⩵", equals: "=", EqualTilde: "≂", equest: "≟", Equilibrium: "⇌", equiv: "≡", equivDD: "⩸", eqvparsl: "⧥", erarr: "⥱", erDot: "≓", escr: "ℯ", Escr: "ℰ", esdot: "≐", Esim: "⩳", esim: "≂", Eta: "Η", eta: "η", ETH: "Ð", eth: "ð", Euml: "Ë", euml: "ë", euro: "€", excl: "!", exist: "∃", Exists: "∃", expectation: "ℰ", exponentiale: "ⅇ", ExponentialE: "ⅇ", fallingdotseq: "≒", Fcy: "Ф", fcy: "ф", female: "♀", ffilig: "ffi", fflig: "ff", ffllig: "ffl", Ffr: "𝔉", ffr: "𝔣", filig: "fi", FilledSmallSquare: "◼", FilledVerySmallSquare: "▪", fjlig: "fj", flat: "♭", fllig: "fl", fltns: "▱", fnof: "ƒ", Fopf: "𝔽", fopf: "𝕗", forall: "∀", ForAll: "∀", fork: "⋔", forkv: "⫙", Fouriertrf: "ℱ", fpartint: "⨍", frac12: "½", frac13: "⅓", frac14: "¼", frac15: "⅕", frac16: "⅙", frac18: "⅛", frac23: "⅔", frac25: "⅖", frac34: "¾", frac35: "⅗", frac38: "⅜", frac45: "⅘", frac56: "⅚", frac58: "⅝", frac78: "⅞", frasl: "⁄", frown: "⌢", fscr: "𝒻", Fscr: "ℱ", gacute: "ǵ", Gamma: "Γ", gamma: "γ", Gammad: "Ϝ", gammad: "ϝ", gap: "⪆", Gbreve: "Ğ", gbreve: "ğ", Gcedil: "Ģ", Gcirc: "Ĝ", gcirc: "ĝ", Gcy: "Г", gcy: "г", Gdot: "Ġ", gdot: "ġ", ge: "≥", gE: "≧", gEl: "⪌", gel: "⋛", geq: "≥", geqq: "≧", geqslant: "⩾", gescc: "⪩", ges: "⩾", gesdot: "⪀", gesdoto: "⪂", gesdotol: "⪄", gesl: "⋛︀", gesles: "⪔", Gfr: "𝔊", gfr: "𝔤", gg: "≫", Gg: "⋙", ggg: "⋙", gimel: "ℷ", GJcy: "Ѓ", gjcy: "ѓ", gla: "⪥", gl: "≷", glE: "⪒", glj: "⪤", gnap: "⪊", gnapprox: "⪊", gne: "⪈", gnE: "≩", gneq: "⪈", gneqq: "≩", gnsim: "⋧", Gopf: "𝔾", gopf: "𝕘", grave: "`", GreaterEqual: "≥", GreaterEqualLess: "⋛", GreaterFullEqual: "≧", GreaterGreater: "⪢", GreaterLess: "≷", GreaterSlantEqual: "⩾", GreaterTilde: "≳", Gscr: "𝒢", gscr: "ℊ", gsim: "≳", gsime: "⪎", gsiml: "⪐", gtcc: "⪧", gtcir: "⩺", gt: ">", GT: ">", Gt: "≫", gtdot: "⋗", gtlPar: "⦕", gtquest: "⩼", gtrapprox: "⪆", gtrarr: "⥸", gtrdot: "⋗", gtreqless: "⋛", gtreqqless: "⪌", gtrless: "≷", gtrsim: "≳", gvertneqq: "≩︀", gvnE: "≩︀", Hacek: "ˇ", hairsp: " ", half: "½", hamilt: "ℋ", HARDcy: "Ъ", hardcy: "ъ", harrcir: "⥈", harr: "↔", hArr: "⇔", harrw: "↭", Hat: "^", hbar: "ℏ", Hcirc: "Ĥ", hcirc: "ĥ", hearts: "♥", heartsuit: "♥", hellip: "…", hercon: "⊹", hfr: "𝔥", Hfr: "ℌ", HilbertSpace: "ℋ", hksearow: "⤥", hkswarow: "⤦", hoarr: "⇿", homtht: "∻", hookleftarrow: "↩", hookrightarrow: "↪", hopf: "𝕙", Hopf: "ℍ", horbar: "―", HorizontalLine: "─", hscr: "𝒽", Hscr: "ℋ", hslash: "ℏ", Hstrok: "Ħ", hstrok: "ħ", HumpDownHump: "≎", HumpEqual: "≏", hybull: "⁃", hyphen: "‐", Iacute: "Í", iacute: "í", ic: "\u2063", Icirc: "Î", icirc: "î", Icy: "И", icy: "и", Idot: "İ", IEcy: "Е", iecy: "е", iexcl: "¡", iff: "⇔", ifr: "𝔦", Ifr: "ℑ", Igrave: "Ì", igrave: "ì", ii: "ⅈ", iiiint: "⨌", iiint: "∭", iinfin: "⧜", iiota: "℩", IJlig: "IJ", ijlig: "ij", Imacr: "Ī", imacr: "ī", image: "ℑ", ImaginaryI: "ⅈ", imagline: "ℐ", imagpart: "ℑ", imath: "ı", Im: "ℑ", imof: "⊷", imped: "Ƶ", Implies: "⇒", incare: "℅", in: "∈", infin: "∞", infintie: "⧝", inodot: "ı", intcal: "⊺", int: "∫", Int: "∬", integers: "ℤ", Integral: "∫", intercal: "⊺", Intersection: "⋂", intlarhk: "⨗", intprod: "⨼", InvisibleComma: "\u2063", InvisibleTimes: "\u2062", IOcy: "Ё", iocy: "ё", Iogon: "Į", iogon: "į", Iopf: "𝕀", iopf: "𝕚", Iota: "Ι", iota: "ι", iprod: "⨼", iquest: "¿", iscr: "𝒾", Iscr: "ℐ", isin: "∈", isindot: "⋵", isinE: "⋹", isins: "⋴", isinsv: "⋳", isinv: "∈", it: "\u2062", Itilde: "Ĩ", itilde: "ĩ", Iukcy: "І", iukcy: "і", Iuml: "Ï", iuml: "ï", Jcirc: "Ĵ", jcirc: "ĵ", Jcy: "Й", jcy: "й", Jfr: "𝔍", jfr: "𝔧", jmath: "ȷ", Jopf: "𝕁", jopf: "𝕛", Jscr: "𝒥", jscr: "𝒿", Jsercy: "Ј", jsercy: "ј", Jukcy: "Є", jukcy: "є", Kappa: "Κ", kappa: "κ", kappav: "ϰ", Kcedil: "Ķ", kcedil: "ķ", Kcy: "К", kcy: "к", Kfr: "𝔎", kfr: "𝔨", kgreen: "ĸ", KHcy: "Х", khcy: "х", KJcy: "Ќ", kjcy: "ќ", Kopf: "𝕂", kopf: "𝕜", Kscr: "𝒦", kscr: "𝓀", lAarr: "⇚", Lacute: "Ĺ", lacute: "ĺ", laemptyv: "⦴", lagran: "ℒ", Lambda: "Λ", lambda: "λ", lang: "⟨", Lang: "⟪", langd: "⦑", langle: "⟨", lap: "⪅", Laplacetrf: "ℒ", laquo: "«", larrb: "⇤", larrbfs: "⤟", larr: "←", Larr: "↞", lArr: "⇐", larrfs: "⤝", larrhk: "↩", larrlp: "↫", larrpl: "⤹", larrsim: "⥳", larrtl: "↢", latail: "⤙", lAtail: "⤛", lat: "⪫", late: "⪭", lates: "⪭︀", lbarr: "⤌", lBarr: "⤎", lbbrk: "❲", lbrace: "{", lbrack: "[", lbrke: "⦋", lbrksld: "⦏", lbrkslu: "⦍", Lcaron: "Ľ", lcaron: "ľ", Lcedil: "Ļ", lcedil: "ļ", lceil: "⌈", lcub: "{", Lcy: "Л", lcy: "л", ldca: "⤶", ldquo: "“", ldquor: "„", ldrdhar: "⥧", ldrushar: "⥋", ldsh: "↲", le: "≤", lE: "≦", LeftAngleBracket: "⟨", LeftArrowBar: "⇤", leftarrow: "←", LeftArrow: "←", Leftarrow: "⇐", LeftArrowRightArrow: "⇆", leftarrowtail: "↢", LeftCeiling: "⌈", LeftDoubleBracket: "⟦", LeftDownTeeVector: "⥡", LeftDownVectorBar: "⥙", LeftDownVector: "⇃", LeftFloor: "⌊", leftharpoondown: "↽", leftharpoonup: "↼", leftleftarrows: "⇇", leftrightarrow: "↔", LeftRightArrow: "↔", Leftrightarrow: "⇔", leftrightarrows: "⇆", leftrightharpoons: "⇋", leftrightsquigarrow: "↭", LeftRightVector: "⥎", LeftTeeArrow: "↤", LeftTee: "⊣", LeftTeeVector: "⥚", leftthreetimes: "⋋", LeftTriangleBar: "⧏", LeftTriangle: "⊲", LeftTriangleEqual: "⊴", LeftUpDownVector: "⥑", LeftUpTeeVector: "⥠", LeftUpVectorBar: "⥘", LeftUpVector: "↿", LeftVectorBar: "⥒", LeftVector: "↼", lEg: "⪋", leg: "⋚", leq: "≤", leqq: "≦", leqslant: "⩽", lescc: "⪨", les: "⩽", lesdot: "⩿", lesdoto: "⪁", lesdotor: "⪃", lesg: "⋚︀", lesges: "⪓", lessapprox: "⪅", lessdot: "⋖", lesseqgtr: "⋚", lesseqqgtr: "⪋", LessEqualGreater: "⋚", LessFullEqual: "≦", LessGreater: "≶", lessgtr: "≶", LessLess: "⪡", lesssim: "≲", LessSlantEqual: "⩽", LessTilde: "≲", lfisht: "⥼", lfloor: "⌊", Lfr: "𝔏", lfr: "𝔩", lg: "≶", lgE: "⪑", lHar: "⥢", lhard: "↽", lharu: "↼", lharul: "⥪", lhblk: "▄", LJcy: "Љ", ljcy: "љ", llarr: "⇇", ll: "≪", Ll: "⋘", llcorner: "⌞", Lleftarrow: "⇚", llhard: "⥫", lltri: "◺", Lmidot: "Ŀ", lmidot: "ŀ", lmoustache: "⎰", lmoust: "⎰", lnap: "⪉", lnapprox: "⪉", lne: "⪇", lnE: "≨", lneq: "⪇", lneqq: "≨", lnsim: "⋦", loang: "⟬", loarr: "⇽", lobrk: "⟦", longleftarrow: "⟵", LongLeftArrow: "⟵", Longleftarrow: "⟸", longleftrightarrow: "⟷", LongLeftRightArrow: "⟷", Longleftrightarrow: "⟺", longmapsto: "⟼", longrightarrow: "⟶", LongRightArrow: "⟶", Longrightarrow: "⟹", looparrowleft: "↫", looparrowright: "↬", lopar: "⦅", Lopf: "𝕃", lopf: "𝕝", loplus: "⨭", lotimes: "⨴", lowast: "∗", lowbar: "_", LowerLeftArrow: "↙", LowerRightArrow: "↘", loz: "◊", lozenge: "◊", lozf: "⧫", lpar: "(", lparlt: "⦓", lrarr: "⇆", lrcorner: "⌟", lrhar: "⇋", lrhard: "⥭", lrm: "\u200e", lrtri: "⊿", lsaquo: "‹", lscr: "𝓁", Lscr: "ℒ", lsh: "↰", Lsh: "↰", lsim: "≲", lsime: "⪍", lsimg: "⪏", lsqb: "[", lsquo: "‘", lsquor: "‚", Lstrok: "Ł", lstrok: "ł", ltcc: "⪦", ltcir: "⩹", lt: "<", LT: "<", Lt: "≪", ltdot: "⋖", lthree: "⋋", ltimes: "⋉", ltlarr: "⥶", ltquest: "⩻", ltri: "◃", ltrie: "⊴", ltrif: "◂", ltrPar: "⦖", lurdshar: "⥊", luruhar: "⥦", lvertneqq: "≨︀", lvnE: "≨︀", macr: "¯", male: "♂", malt: "✠", maltese: "✠", Map: "⤅", map: "↦", mapsto: "↦", mapstodown: "↧", mapstoleft: "↤", mapstoup: "↥", marker: "▮", mcomma: "⨩", Mcy: "М", mcy: "м", mdash: "—", mDDot: "∺", measuredangle: "∡", MediumSpace: " ", Mellintrf: "ℳ", Mfr: "𝔐", mfr: "𝔪", mho: "℧", micro: "µ", midast: "*", midcir: "⫰", mid: "∣", middot: "·", minusb: "⊟", minus: "−", minusd: "∸", minusdu: "⨪", MinusPlus: "∓", mlcp: "⫛", mldr: "…", mnplus: "∓", models: "⊧", Mopf: "𝕄", mopf: "𝕞", mp: "∓", mscr: "𝓂", Mscr: "ℳ", mstpos: "∾", Mu: "Μ", mu: "μ", multimap: "⊸", mumap: "⊸", nabla: "∇", Nacute: "Ń", nacute: "ń", nang: "∠⃒", nap: "≉", napE: "⩰̸", napid: "≋̸", napos: "ʼn", napprox: "≉", natural: "♮", naturals: "ℕ", natur: "♮", nbsp: " ", nbump: "≎̸", nbumpe: "≏̸", ncap: "⩃", Ncaron: "Ň", ncaron: "ň", Ncedil: "Ņ", ncedil: "ņ", ncong: "≇", ncongdot: "⩭̸", ncup: "⩂", Ncy: "Н", ncy: "н", ndash: "–", nearhk: "⤤", nearr: "↗", neArr: "⇗", nearrow: "↗", ne: "≠", nedot: "≐̸", NegativeMediumSpace: "​", NegativeThickSpace: "​", NegativeThinSpace: "​", NegativeVeryThinSpace: "​", nequiv: "≢", nesear: "⤨", nesim: "≂̸", NestedGreaterGreater: "≫", NestedLessLess: "≪", NewLine: "\u000a", nexist: "∄", nexists: "∄", Nfr: "𝔑", nfr: "𝔫", ngE: "≧̸", nge: "≱", ngeq: "≱", ngeqq: "≧̸", ngeqslant: "⩾̸", nges: "⩾̸", nGg: "⋙̸", ngsim: "≵", nGt: "≫⃒", ngt: "≯", ngtr: "≯", nGtv: "≫̸", nharr: "↮", nhArr: "⇎", nhpar: "⫲", ni: "∋", nis: "⋼", nisd: "⋺", niv: "∋", NJcy: "Њ", njcy: "њ", nlarr: "↚", nlArr: "⇍", nldr: "‥", nlE: "≦̸", nle: "≰", nleftarrow: "↚", nLeftarrow: "⇍", nleftrightarrow: "↮", nLeftrightarrow: "⇎", nleq: "≰", nleqq: "≦̸", nleqslant: "⩽̸", nles: "⩽̸", nless: "≮", nLl: "⋘̸", nlsim: "≴", nLt: "≪⃒", nlt: "≮", nltri: "⋪", nltrie: "⋬", nLtv: "≪̸", nmid: "∤", NoBreak: "\u2060", NonBreakingSpace: " ", nopf: "𝕟", Nopf: "ℕ", Not: "⫬", not: "¬", NotCongruent: "≢", NotCupCap: "≭", NotDoubleVerticalBar: "∦", NotElement: "∉", NotEqual: "≠", NotEqualTilde: "≂̸", NotExists: "∄", NotGreater: "≯", NotGreaterEqual: "≱", NotGreaterFullEqual: "≧̸", NotGreaterGreater: "≫̸", NotGreaterLess: "≹", NotGreaterSlantEqual: "⩾̸", NotGreaterTilde: "≵", NotHumpDownHump: "≎̸", NotHumpEqual: "≏̸", notin: "∉", notindot: "⋵̸", notinE: "⋹̸", notinva: "∉", notinvb: "⋷", notinvc: "⋶", NotLeftTriangleBar: "⧏̸", NotLeftTriangle: "⋪", NotLeftTriangleEqual: "⋬", NotLess: "≮", NotLessEqual: "≰", NotLessGreater: "≸", NotLessLess: "≪̸", NotLessSlantEqual: "⩽̸", NotLessTilde: "≴", NotNestedGreaterGreater: "⪢̸", NotNestedLessLess: "⪡̸", notni: "∌", notniva: "∌", notnivb: "⋾", notnivc: "⋽", NotPrecedes: "⊀", NotPrecedesEqual: "⪯̸", NotPrecedesSlantEqual: "⋠", NotReverseElement: "∌", NotRightTriangleBar: "⧐̸", NotRightTriangle: "⋫", NotRightTriangleEqual: "⋭", NotSquareSubset: "⊏̸", NotSquareSubsetEqual: "⋢", NotSquareSuperset: "⊐̸", NotSquareSupersetEqual: "⋣", NotSubset: "⊂⃒", NotSubsetEqual: "⊈", NotSucceeds: "⊁", NotSucceedsEqual: "⪰̸", NotSucceedsSlantEqual: "⋡", NotSucceedsTilde: "≿̸", NotSuperset: "⊃⃒", NotSupersetEqual: "⊉", NotTilde: "≁", NotTildeEqual: "≄", NotTildeFullEqual: "≇", NotTildeTilde: "≉", NotVerticalBar: "∤", nparallel: "∦", npar: "∦", nparsl: "⫽⃥", npart: "∂̸", npolint: "⨔", npr: "⊀", nprcue: "⋠", nprec: "⊀", npreceq: "⪯̸", npre: "⪯̸", nrarrc: "⤳̸", nrarr: "↛", nrArr: "⇏", nrarrw: "↝̸", nrightarrow: "↛", nRightarrow: "⇏", nrtri: "⋫", nrtrie: "⋭", nsc: "⊁", nsccue: "⋡", nsce: "⪰̸", Nscr: "𝒩", nscr: "𝓃", nshortmid: "∤", nshortparallel: "∦", nsim: "≁", nsime: "≄", nsimeq: "≄", nsmid: "∤", nspar: "∦", nsqsube: "⋢", nsqsupe: "⋣", nsub: "⊄", nsubE: "⫅̸", nsube: "⊈", nsubset: "⊂⃒", nsubseteq: "⊈", nsubseteqq: "⫅̸", nsucc: "⊁", nsucceq: "⪰̸", nsup: "⊅", nsupE: "⫆̸", nsupe: "⊉", nsupset: "⊃⃒", nsupseteq: "⊉", nsupseteqq: "⫆̸", ntgl: "≹", Ntilde: "Ñ", ntilde: "ñ", ntlg: "≸", ntriangleleft: "⋪", ntrianglelefteq: "⋬", ntriangleright: "⋫", ntrianglerighteq: "⋭", Nu: "Ν", nu: "ν", num: "#", numero: "№", numsp: " ", nvap: "≍⃒", nvdash: "⊬", nvDash: "⊭", nVdash: "⊮", nVDash: "⊯", nvge: "≥⃒", nvgt: ">⃒", nvHarr: "⤄", nvinfin: "⧞", nvlArr: "⤂", nvle: "≤⃒", nvlt: "<⃒", nvltrie: "⊴⃒", nvrArr: "⤃", nvrtrie: "⊵⃒", nvsim: "∼⃒", nwarhk: "⤣", nwarr: "↖", nwArr: "⇖", nwarrow: "↖", nwnear: "⤧", Oacute: "Ó", oacute: "ó", oast: "⊛", Ocirc: "Ô", ocirc: "ô", ocir: "⊚", Ocy: "О", ocy: "о", odash: "⊝", Odblac: "Ő", odblac: "ő", odiv: "⨸", odot: "⊙", odsold: "⦼", OElig: "Œ", oelig: "œ", ofcir: "⦿", Ofr: "𝔒", ofr: "𝔬", ogon: "˛", Ograve: "Ò", ograve: "ò", ogt: "⧁", ohbar: "⦵", ohm: "Ω", oint: "∮", olarr: "↺", olcir: "⦾", olcross: "⦻", oline: "‾", olt: "⧀", Omacr: "Ō", omacr: "ō", Omega: "Ω", omega: "ω", Omicron: "Ο", omicron: "ο", omid: "⦶", ominus: "⊖", Oopf: "𝕆", oopf: "𝕠", opar: "⦷", OpenCurlyDoubleQuote: "“", OpenCurlyQuote: "‘", operp: "⦹", oplus: "⊕", orarr: "↻", Or: "⩔", or: "∨", ord: "⩝", order: "ℴ", orderof: "ℴ", ordf: "ª", ordm: "º", origof: "⊶", oror: "⩖", orslope: "⩗", orv: "⩛", oS: "Ⓢ", Oscr: "𝒪", oscr: "ℴ", Oslash: "Ø", oslash: "ø", osol: "⊘", Otilde: "Õ", otilde: "õ", otimesas: "⨶", Otimes: "⨷", otimes: "⊗", Ouml: "Ö", ouml: "ö", ovbar: "⌽", OverBar: "‾", OverBrace: "⏞", OverBracket: "⎴", OverParenthesis: "⏜", para: "¶", parallel: "∥", par: "∥", parsim: "⫳", parsl: "⫽", part: "∂", PartialD: "∂", Pcy: "П", pcy: "п", percnt: "%", period: ".", permil: "‰", perp: "⊥", pertenk: "‱", Pfr: "𝔓", pfr: "𝔭", Phi: "Φ", phi: "φ", phiv: "ϕ", phmmat: "ℳ", phone: "☎", Pi: "Π", pi: "π", pitchfork: "⋔", piv: "ϖ", planck: "ℏ", planckh: "ℎ", plankv: "ℏ", plusacir: "⨣", plusb: "⊞", pluscir: "⨢", plus: "+", plusdo: "∔", plusdu: "⨥", pluse: "⩲", PlusMinus: "±", plusmn: "±", plussim: "⨦", plustwo: "⨧", pm: "±", Poincareplane: "ℌ", pointint: "⨕", popf: "𝕡", Popf: "ℙ", pound: "£", prap: "⪷", Pr: "⪻", pr: "≺", prcue: "≼", precapprox: "⪷", prec: "≺", preccurlyeq: "≼", Precedes: "≺", PrecedesEqual: "⪯", PrecedesSlantEqual: "≼", PrecedesTilde: "≾", preceq: "⪯", precnapprox: "⪹", precneqq: "⪵", precnsim: "⋨", pre: "⪯", prE: "⪳", precsim: "≾", prime: "′", Prime: "″", primes: "ℙ", prnap: "⪹", prnE: "⪵", prnsim: "⋨", prod: "∏", Product: "∏", profalar: "⌮", profline: "⌒", profsurf: "⌓", prop: "∝", Proportional: "∝", Proportion: "∷", propto: "∝", prsim: "≾", prurel: "⊰", Pscr: "𝒫", pscr: "𝓅", Psi: "Ψ", psi: "ψ", puncsp: " ", Qfr: "𝔔", qfr: "𝔮", qint: "⨌", qopf: "𝕢", Qopf: "ℚ", qprime: "⁗", Qscr: "𝒬", qscr: "𝓆", quaternions: "ℍ", quatint: "⨖", quest: "?", questeq: "≟", quot: "\"", QUOT: "\"", rAarr: "⇛", race: "∽̱", Racute: "Ŕ", racute: "ŕ", radic: "√", raemptyv: "⦳", rang: "⟩", Rang: "⟫", rangd: "⦒", range: "⦥", rangle: "⟩", raquo: "»", rarrap: "⥵", rarrb: "⇥", rarrbfs: "⤠", rarrc: "⤳", rarr: "→", Rarr: "↠", rArr: "⇒", rarrfs: "⤞", rarrhk: "↪", rarrlp: "↬", rarrpl: "⥅", rarrsim: "⥴", Rarrtl: "⤖", rarrtl: "↣", rarrw: "↝", ratail: "⤚", rAtail: "⤜", ratio: "∶", rationals: "ℚ", rbarr: "⤍", rBarr: "⤏", RBarr: "⤐", rbbrk: "❳", rbrace: "}", rbrack: "]", rbrke: "⦌", rbrksld: "⦎", rbrkslu: "⦐", Rcaron: "Ř", rcaron: "ř", Rcedil: "Ŗ", rcedil: "ŗ", rceil: "⌉", rcub: "}", Rcy: "Р", rcy: "р", rdca: "⤷", rdldhar: "⥩", rdquo: "”", rdquor: "”", rdsh: "↳", real: "ℜ", realine: "ℛ", realpart: "ℜ", reals: "ℝ", Re: "ℜ", rect: "▭", reg: "®", REG: "®", ReverseElement: "∋", ReverseEquilibrium: "⇋", ReverseUpEquilibrium: "⥯", rfisht: "⥽", rfloor: "⌋", rfr: "𝔯", Rfr: "ℜ", rHar: "⥤", rhard: "⇁", rharu: "⇀", rharul: "⥬", Rho: "Ρ", rho: "ρ", rhov: "ϱ", RightAngleBracket: "⟩", RightArrowBar: "⇥", rightarrow: "→", RightArrow: "→", Rightarrow: "⇒", RightArrowLeftArrow: "⇄", rightarrowtail: "↣", RightCeiling: "⌉", RightDoubleBracket: "⟧", RightDownTeeVector: "⥝", RightDownVectorBar: "⥕", RightDownVector: "⇂", RightFloor: "⌋", rightharpoondown: "⇁", rightharpoonup: "⇀", rightleftarrows: "⇄", rightleftharpoons: "⇌", rightrightarrows: "⇉", rightsquigarrow: "↝", RightTeeArrow: "↦", RightTee: "⊢", RightTeeVector: "⥛", rightthreetimes: "⋌", RightTriangleBar: "⧐", RightTriangle: "⊳", RightTriangleEqual: "⊵", RightUpDownVector: "⥏", RightUpTeeVector: "⥜", RightUpVectorBar: "⥔", RightUpVector: "↾", RightVectorBar: "⥓", RightVector: "⇀", ring: "˚", risingdotseq: "≓", rlarr: "⇄", rlhar: "⇌", rlm: "\u200f", rmoustache: "⎱", rmoust: "⎱", rnmid: "⫮", roang: "⟭", roarr: "⇾", robrk: "⟧", ropar: "⦆", ropf: "𝕣", Ropf: "ℝ", roplus: "⨮", rotimes: "⨵", RoundImplies: "⥰", rpar: ")", rpargt: "⦔", rppolint: "⨒", rrarr: "⇉", Rrightarrow: "⇛", rsaquo: "›", rscr: "𝓇", Rscr: "ℛ", rsh: "↱", Rsh: "↱", rsqb: "]", rsquo: "’", rsquor: "’", rthree: "⋌", rtimes: "⋊", rtri: "▹", rtrie: "⊵", rtrif: "▸", rtriltri: "⧎", RuleDelayed: "⧴", ruluhar: "⥨", rx: "℞", Sacute: "Ś", sacute: "ś", sbquo: "‚", scap: "⪸", Scaron: "Š", scaron: "š", Sc: "⪼", sc: "≻", sccue: "≽", sce: "⪰", scE: "⪴", Scedil: "Ş", scedil: "ş", Scirc: "Ŝ", scirc: "ŝ", scnap: "⪺", scnE: "⪶", scnsim: "⋩", scpolint: "⨓", scsim: "≿", Scy: "С", scy: "с", sdotb: "⊡", sdot: "⋅", sdote: "⩦", searhk: "⤥", searr: "↘", seArr: "⇘", searrow: "↘", sect: "§", semi: ";", seswar: "⤩", setminus: "∖", setmn: "∖", sext: "✶", Sfr: "𝔖", sfr: "𝔰", sfrown: "⌢", sharp: "♯", SHCHcy: "Щ", shchcy: "щ", SHcy: "Ш", shcy: "ш", ShortDownArrow: "↓", ShortLeftArrow: "←", shortmid: "∣", shortparallel: "∥", ShortRightArrow: "→", ShortUpArrow: "↑", shy: "\u00ad", Sigma: "Σ", sigma: "σ", sigmaf: "ς", sigmav: "ς", sim: "∼", simdot: "⩪", sime: "≃", simeq: "≃", simg: "⪞", simgE: "⪠", siml: "⪝", simlE: "⪟", simne: "≆", simplus: "⨤", simrarr: "⥲", slarr: "←", SmallCircle: "∘", smallsetminus: "∖", smashp: "⨳", smeparsl: "⧤", smid: "∣", smile: "⌣", smt: "⪪", smte: "⪬", smtes: "⪬︀", SOFTcy: "Ь", softcy: "ь", solbar: "⌿", solb: "⧄", sol: "/", Sopf: "𝕊", sopf: "𝕤", spades: "♠", spadesuit: "♠", spar: "∥", sqcap: "⊓", sqcaps: "⊓︀", sqcup: "⊔", sqcups: "⊔︀", Sqrt: "√", sqsub: "⊏", sqsube: "⊑", sqsubset: "⊏", sqsubseteq: "⊑", sqsup: "⊐", sqsupe: "⊒", sqsupset: "⊐", sqsupseteq: "⊒", square: "□", Square: "□", SquareIntersection: "⊓", SquareSubset: "⊏", SquareSubsetEqual: "⊑", SquareSuperset: "⊐", SquareSupersetEqual: "⊒", SquareUnion: "⊔", squarf: "▪", squ: "□", squf: "▪", srarr: "→", Sscr: "𝒮", sscr: "𝓈", ssetmn: "∖", ssmile: "⌣", sstarf: "⋆", Star: "⋆", star: "☆", starf: "★", straightepsilon: "ϵ", straightphi: "ϕ", strns: "¯", sub: "⊂", Sub: "⋐", subdot: "⪽", subE: "⫅", sube: "⊆", subedot: "⫃", submult: "⫁", subnE: "⫋", subne: "⊊", subplus: "⪿", subrarr: "⥹", subset: "⊂", Subset: "⋐", subseteq: "⊆", subseteqq: "⫅", SubsetEqual: "⊆", subsetneq: "⊊", subsetneqq: "⫋", subsim: "⫇", subsub: "⫕", subsup: "⫓", succapprox: "⪸", succ: "≻", succcurlyeq: "≽", Succeeds: "≻", SucceedsEqual: "⪰", SucceedsSlantEqual: "≽", SucceedsTilde: "≿", succeq: "⪰", succnapprox: "⪺", succneqq: "⪶", succnsim: "⋩", succsim: "≿", SuchThat: "∋", sum: "∑", Sum: "∑", sung: "♪", sup1: "¹", sup2: "²", sup3: "³", sup: "⊃", Sup: "⋑", supdot: "⪾", supdsub: "⫘", supE: "⫆", supe: "⊇", supedot: "⫄", Superset: "⊃", SupersetEqual: "⊇", suphsol: "⟉", suphsub: "⫗", suplarr: "⥻", supmult: "⫂", supnE: "⫌", supne: "⊋", supplus: "⫀", supset: "⊃", Supset: "⋑", supseteq: "⊇", supseteqq: "⫆", supsetneq: "⊋", supsetneqq: "⫌", supsim: "⫈", supsub: "⫔", supsup: "⫖", swarhk: "⤦", swarr: "↙", swArr: "⇙", swarrow: "↙", swnwar: "⤪", szlig: "ß", Tab: "\u0009", target: "⌖", Tau: "Τ", tau: "τ", tbrk: "⎴", Tcaron: "Ť", tcaron: "ť", Tcedil: "Ţ", tcedil: "ţ", Tcy: "Т", tcy: "т", tdot: "⃛", telrec: "⌕", Tfr: "𝔗", tfr: "𝔱", there4: "∴", therefore: "∴", Therefore: "∴", Theta: "Θ", theta: "θ", thetasym: "ϑ", thetav: "ϑ", thickapprox: "≈", thicksim: "∼", ThickSpace: "  ", ThinSpace: " ", thinsp: " ", thkap: "≈", thksim: "∼", THORN: "Þ", thorn: "þ", tilde: "˜", Tilde: "∼", TildeEqual: "≃", TildeFullEqual: "≅", TildeTilde: "≈", timesbar: "⨱", timesb: "⊠", times: "×", timesd: "⨰", tint: "∭", toea: "⤨", topbot: "⌶", topcir: "⫱", top: "⊤", Topf: "𝕋", topf: "𝕥", topfork: "⫚", tosa: "⤩", tprime: "‴", trade: "™", TRADE: "™", triangle: "▵", triangledown: "▿", triangleleft: "◃", trianglelefteq: "⊴", triangleq: "≜", triangleright: "▹", trianglerighteq: "⊵", tridot: "◬", trie: "≜", triminus: "⨺", TripleDot: "⃛", triplus: "⨹", trisb: "⧍", tritime: "⨻", trpezium: "⏢", Tscr: "𝒯", tscr: "𝓉", TScy: "Ц", tscy: "ц", TSHcy: "Ћ", tshcy: "ћ", Tstrok: "Ŧ", tstrok: "ŧ", twixt: "≬", twoheadleftarrow: "↞", twoheadrightarrow: "↠", Uacute: "Ú", uacute: "ú", uarr: "↑", Uarr: "↟", uArr: "⇑", Uarrocir: "⥉", Ubrcy: "Ў", ubrcy: "ў", Ubreve: "Ŭ", ubreve: "ŭ", Ucirc: "Û", ucirc: "û", Ucy: "У", ucy: "у", udarr: "⇅", Udblac: "Ű", udblac: "ű", udhar: "⥮", ufisht: "⥾", Ufr: "𝔘", ufr: "𝔲", Ugrave: "Ù", ugrave: "ù", uHar: "⥣", uharl: "↿", uharr: "↾", uhblk: "▀", ulcorn: "⌜", ulcorner: "⌜", ulcrop: "⌏", ultri: "◸", Umacr: "Ū", umacr: "ū", uml: "¨", UnderBar: "_", UnderBrace: "⏟", UnderBracket: "⎵", UnderParenthesis: "⏝", Union: "⋃", UnionPlus: "⊎", Uogon: "Ų", uogon: "ų", Uopf: "𝕌", uopf: "𝕦", UpArrowBar: "⤒", uparrow: "↑", UpArrow: "↑", Uparrow: "⇑", UpArrowDownArrow: "⇅", updownarrow: "↕", UpDownArrow: "↕", Updownarrow: "⇕", UpEquilibrium: "⥮", upharpoonleft: "↿", upharpoonright: "↾", uplus: "⊎", UpperLeftArrow: "↖", UpperRightArrow: "↗", upsi: "υ", Upsi: "ϒ", upsih: "ϒ", Upsilon: "Υ", upsilon: "υ", UpTeeArrow: "↥", UpTee: "⊥", upuparrows: "⇈", urcorn: "⌝", urcorner: "⌝", urcrop: "⌎", Uring: "Ů", uring: "ů", urtri: "◹", Uscr: "𝒰", uscr: "𝓊", utdot: "⋰", Utilde: "Ũ", utilde: "ũ", utri: "▵", utrif: "▴", uuarr: "⇈", Uuml: "Ü", uuml: "ü", uwangle: "⦧", vangrt: "⦜", varepsilon: "ϵ", varkappa: "ϰ", varnothing: "∅", varphi: "ϕ", varpi: "ϖ", varpropto: "∝", varr: "↕", vArr: "⇕", varrho: "ϱ", varsigma: "ς", varsubsetneq: "⊊︀", varsubsetneqq: "⫋︀", varsupsetneq: "⊋︀", varsupsetneqq: "⫌︀", vartheta: "ϑ", vartriangleleft: "⊲", vartriangleright: "⊳", vBar: "⫨", Vbar: "⫫", vBarv: "⫩", Vcy: "В", vcy: "в", vdash: "⊢", vDash: "⊨", Vdash: "⊩", VDash: "⊫", Vdashl: "⫦", veebar: "⊻", vee: "∨", Vee: "⋁", veeeq: "≚", vellip: "⋮", verbar: "|", Verbar: "‖", vert: "|", Vert: "‖", VerticalBar: "∣", VerticalLine: "|", VerticalSeparator: "❘", VerticalTilde: "≀", VeryThinSpace: " ", Vfr: "𝔙", vfr: "𝔳", vltri: "⊲", vnsub: "⊂⃒", vnsup: "⊃⃒", Vopf: "𝕍", vopf: "𝕧", vprop: "∝", vrtri: "⊳", Vscr: "𝒱", vscr: "𝓋", vsubnE: "⫋︀", vsubne: "⊊︀", vsupnE: "⫌︀", vsupne: "⊋︀", Vvdash: "⊪", vzigzag: "⦚", Wcirc: "Ŵ", wcirc: "ŵ", wedbar: "⩟", wedge: "∧", Wedge: "⋀", wedgeq: "≙", weierp: "℘", Wfr: "𝔚", wfr: "𝔴", Wopf: "𝕎", wopf: "𝕨", wp: "℘", wr: "≀", wreath: "≀", Wscr: "𝒲", wscr: "𝓌", xcap: "⋂", xcirc: "◯", xcup: "⋃", xdtri: "▽", Xfr: "𝔛", xfr: "𝔵", xharr: "⟷", xhArr: "⟺", Xi: "Ξ", xi: "ξ", xlarr: "⟵", xlArr: "⟸", xmap: "⟼", xnis: "⋻", xodot: "⨀", Xopf: "𝕏", xopf: "𝕩", xoplus: "⨁", xotime: "⨂", xrarr: "⟶", xrArr: "⟹", Xscr: "𝒳", xscr: "𝓍", xsqcup: "⨆", xuplus: "⨄", xutri: "△", xvee: "⋁", xwedge: "⋀", Yacute: "Ý", yacute: "ý", YAcy: "Я", yacy: "я", Ycirc: "Ŷ", ycirc: "ŷ", Ycy: "Ы", ycy: "ы", yen: "¥", Yfr: "𝔜", yfr: "𝔶", YIcy: "Ї", yicy: "ї", Yopf: "𝕐", yopf: "𝕪", Yscr: "𝒴", yscr: "𝓎", YUcy: "Ю", yucy: "ю", yuml: "ÿ", Yuml: "Ÿ", Zacute: "Ź", zacute: "ź", Zcaron: "Ž", zcaron: "ž", Zcy: "З", zcy: "з", Zdot: "Ż", zdot: "ż", zeetrf: "ℨ", ZeroWidthSpace: "​", Zeta: "Ζ", zeta: "ζ", zfr: "𝔷", Zfr: "ℨ", ZHcy: "Ж", zhcy: "ж", zigrarr: "⇝", zopf: "𝕫", Zopf: "ℤ", Zscr: "𝒵", zscr: "𝓏", zwj: "\u200d", zwnj: "\u200c"
  7671. };
  7672. var HEXCHARCODE = /^#[xX]([A-Fa-f0-9]+)$/;
  7673. var CHARCODE = /^#([0-9]+)$/;
  7674. var NAMED = /^([A-Za-z0-9]+)$/;
  7675. var EntityParser = /** @class */ (function () {
  7676. function EntityParser(named) {
  7677. this.named = named;
  7678. }
  7679. EntityParser.prototype.parse = function (entity) {
  7680. if (!entity) {
  7681. return;
  7682. }
  7683. var matches = entity.match(HEXCHARCODE);
  7684. if (matches) {
  7685. return String.fromCharCode(parseInt(matches[1], 16));
  7686. }
  7687. matches = entity.match(CHARCODE);
  7688. if (matches) {
  7689. return String.fromCharCode(parseInt(matches[1], 10));
  7690. }
  7691. matches = entity.match(NAMED);
  7692. if (matches) {
  7693. return this.named[matches[1]];
  7694. }
  7695. };
  7696. return EntityParser;
  7697. }());
  7698. var WSP = /[\t\n\f ]/;
  7699. var ALPHA = /[A-Za-z]/;
  7700. var CRLF = /\r\n?/g;
  7701. function isSpace(char) {
  7702. return WSP.test(char);
  7703. }
  7704. function isAlpha(char) {
  7705. return ALPHA.test(char);
  7706. }
  7707. function preprocessInput(input) {
  7708. return input.replace(CRLF, '\n');
  7709. }
  7710. var EventedTokenizer = /** @class */ (function () {
  7711. function EventedTokenizer(delegate, entityParser, mode) {
  7712. if (mode === void 0) { mode = 'precompile'; }
  7713. this.delegate = delegate;
  7714. this.entityParser = entityParser;
  7715. this.mode = mode;
  7716. this.state = "beforeData" /* beforeData */;
  7717. this.line = -1;
  7718. this.column = -1;
  7719. this.input = '';
  7720. this.index = -1;
  7721. this.tagNameBuffer = '';
  7722. this.states = {
  7723. beforeData: function () {
  7724. var char = this.peek();
  7725. if (char === '<' && !this.isIgnoredEndTag()) {
  7726. this.transitionTo("tagOpen" /* tagOpen */);
  7727. this.markTagStart();
  7728. this.consume();
  7729. }
  7730. else {
  7731. if (this.mode === 'precompile' && char === '\n') {
  7732. var tag = this.tagNameBuffer.toLowerCase();
  7733. if (tag === 'pre' || tag === 'textarea') {
  7734. this.consume();
  7735. }
  7736. }
  7737. this.transitionTo("data" /* data */);
  7738. this.delegate.beginData();
  7739. }
  7740. },
  7741. data: function () {
  7742. var char = this.peek();
  7743. var tag = this.tagNameBuffer;
  7744. if (char === '<' && !this.isIgnoredEndTag()) {
  7745. this.delegate.finishData();
  7746. this.transitionTo("tagOpen" /* tagOpen */);
  7747. this.markTagStart();
  7748. this.consume();
  7749. }
  7750. else if (char === '&' && tag !== 'script' && tag !== 'style') {
  7751. this.consume();
  7752. this.delegate.appendToData(this.consumeCharRef() || '&');
  7753. }
  7754. else {
  7755. this.consume();
  7756. this.delegate.appendToData(char);
  7757. }
  7758. },
  7759. tagOpen: function () {
  7760. var char = this.consume();
  7761. if (char === '!') {
  7762. this.transitionTo("markupDeclarationOpen" /* markupDeclarationOpen */);
  7763. }
  7764. else if (char === '/') {
  7765. this.transitionTo("endTagOpen" /* endTagOpen */);
  7766. }
  7767. else if (char === '@' || char === ':' || isAlpha(char)) {
  7768. this.transitionTo("tagName" /* tagName */);
  7769. this.tagNameBuffer = '';
  7770. this.delegate.beginStartTag();
  7771. this.appendToTagName(char);
  7772. }
  7773. },
  7774. markupDeclarationOpen: function () {
  7775. var char = this.consume();
  7776. if (char === '-' && this.peek() === '-') {
  7777. this.consume();
  7778. this.transitionTo("commentStart" /* commentStart */);
  7779. this.delegate.beginComment();
  7780. }
  7781. else {
  7782. var maybeDoctype = char.toUpperCase() + this.input.substring(this.index, this.index + 6).toUpperCase();
  7783. if (maybeDoctype === 'DOCTYPE') {
  7784. this.consume();
  7785. this.consume();
  7786. this.consume();
  7787. this.consume();
  7788. this.consume();
  7789. this.consume();
  7790. this.transitionTo("doctype" /* doctype */);
  7791. if (this.delegate.beginDoctype)
  7792. this.delegate.beginDoctype();
  7793. }
  7794. }
  7795. },
  7796. doctype: function () {
  7797. var char = this.consume();
  7798. if (isSpace(char)) {
  7799. this.transitionTo("beforeDoctypeName" /* beforeDoctypeName */);
  7800. }
  7801. },
  7802. beforeDoctypeName: function () {
  7803. var char = this.consume();
  7804. if (isSpace(char)) {
  7805. return;
  7806. }
  7807. else {
  7808. this.transitionTo("doctypeName" /* doctypeName */);
  7809. if (this.delegate.appendToDoctypeName)
  7810. this.delegate.appendToDoctypeName(char.toLowerCase());
  7811. }
  7812. },
  7813. doctypeName: function () {
  7814. var char = this.consume();
  7815. if (isSpace(char)) {
  7816. this.transitionTo("afterDoctypeName" /* afterDoctypeName */);
  7817. }
  7818. else if (char === '>') {
  7819. if (this.delegate.endDoctype)
  7820. this.delegate.endDoctype();
  7821. this.transitionTo("beforeData" /* beforeData */);
  7822. }
  7823. else {
  7824. if (this.delegate.appendToDoctypeName)
  7825. this.delegate.appendToDoctypeName(char.toLowerCase());
  7826. }
  7827. },
  7828. afterDoctypeName: function () {
  7829. var char = this.consume();
  7830. if (isSpace(char)) {
  7831. return;
  7832. }
  7833. else if (char === '>') {
  7834. if (this.delegate.endDoctype)
  7835. this.delegate.endDoctype();
  7836. this.transitionTo("beforeData" /* beforeData */);
  7837. }
  7838. else {
  7839. var nextSixChars = char.toUpperCase() + this.input.substring(this.index, this.index + 5).toUpperCase();
  7840. var isPublic = nextSixChars.toUpperCase() === 'PUBLIC';
  7841. var isSystem = nextSixChars.toUpperCase() === 'SYSTEM';
  7842. if (isPublic || isSystem) {
  7843. this.consume();
  7844. this.consume();
  7845. this.consume();
  7846. this.consume();
  7847. this.consume();
  7848. this.consume();
  7849. }
  7850. if (isPublic) {
  7851. this.transitionTo("afterDoctypePublicKeyword" /* afterDoctypePublicKeyword */);
  7852. }
  7853. else if (isSystem) {
  7854. this.transitionTo("afterDoctypeSystemKeyword" /* afterDoctypeSystemKeyword */);
  7855. }
  7856. }
  7857. },
  7858. afterDoctypePublicKeyword: function () {
  7859. var char = this.peek();
  7860. if (isSpace(char)) {
  7861. this.transitionTo("beforeDoctypePublicIdentifier" /* beforeDoctypePublicIdentifier */);
  7862. this.consume();
  7863. }
  7864. else if (char === '"') {
  7865. this.transitionTo("doctypePublicIdentifierDoubleQuoted" /* doctypePublicIdentifierDoubleQuoted */);
  7866. this.consume();
  7867. }
  7868. else if (char === "'") {
  7869. this.transitionTo("doctypePublicIdentifierSingleQuoted" /* doctypePublicIdentifierSingleQuoted */);
  7870. this.consume();
  7871. }
  7872. else if (char === '>') {
  7873. this.consume();
  7874. if (this.delegate.endDoctype)
  7875. this.delegate.endDoctype();
  7876. this.transitionTo("beforeData" /* beforeData */);
  7877. }
  7878. },
  7879. doctypePublicIdentifierDoubleQuoted: function () {
  7880. var char = this.consume();
  7881. if (char === '"') {
  7882. this.transitionTo("afterDoctypePublicIdentifier" /* afterDoctypePublicIdentifier */);
  7883. }
  7884. else if (char === '>') {
  7885. if (this.delegate.endDoctype)
  7886. this.delegate.endDoctype();
  7887. this.transitionTo("beforeData" /* beforeData */);
  7888. }
  7889. else {
  7890. if (this.delegate.appendToDoctypePublicIdentifier)
  7891. this.delegate.appendToDoctypePublicIdentifier(char);
  7892. }
  7893. },
  7894. doctypePublicIdentifierSingleQuoted: function () {
  7895. var char = this.consume();
  7896. if (char === "'") {
  7897. this.transitionTo("afterDoctypePublicIdentifier" /* afterDoctypePublicIdentifier */);
  7898. }
  7899. else if (char === '>') {
  7900. if (this.delegate.endDoctype)
  7901. this.delegate.endDoctype();
  7902. this.transitionTo("beforeData" /* beforeData */);
  7903. }
  7904. else {
  7905. if (this.delegate.appendToDoctypePublicIdentifier)
  7906. this.delegate.appendToDoctypePublicIdentifier(char);
  7907. }
  7908. },
  7909. afterDoctypePublicIdentifier: function () {
  7910. var char = this.consume();
  7911. if (isSpace(char)) {
  7912. this.transitionTo("betweenDoctypePublicAndSystemIdentifiers" /* betweenDoctypePublicAndSystemIdentifiers */);
  7913. }
  7914. else if (char === '>') {
  7915. if (this.delegate.endDoctype)
  7916. this.delegate.endDoctype();
  7917. this.transitionTo("beforeData" /* beforeData */);
  7918. }
  7919. else if (char === '"') {
  7920. this.transitionTo("doctypeSystemIdentifierDoubleQuoted" /* doctypeSystemIdentifierDoubleQuoted */);
  7921. }
  7922. else if (char === "'") {
  7923. this.transitionTo("doctypeSystemIdentifierSingleQuoted" /* doctypeSystemIdentifierSingleQuoted */);
  7924. }
  7925. },
  7926. betweenDoctypePublicAndSystemIdentifiers: function () {
  7927. var char = this.consume();
  7928. if (isSpace(char)) {
  7929. return;
  7930. }
  7931. else if (char === '>') {
  7932. if (this.delegate.endDoctype)
  7933. this.delegate.endDoctype();
  7934. this.transitionTo("beforeData" /* beforeData */);
  7935. }
  7936. else if (char === '"') {
  7937. this.transitionTo("doctypeSystemIdentifierDoubleQuoted" /* doctypeSystemIdentifierDoubleQuoted */);
  7938. }
  7939. else if (char === "'") {
  7940. this.transitionTo("doctypeSystemIdentifierSingleQuoted" /* doctypeSystemIdentifierSingleQuoted */);
  7941. }
  7942. },
  7943. doctypeSystemIdentifierDoubleQuoted: function () {
  7944. var char = this.consume();
  7945. if (char === '"') {
  7946. this.transitionTo("afterDoctypeSystemIdentifier" /* afterDoctypeSystemIdentifier */);
  7947. }
  7948. else if (char === '>') {
  7949. if (this.delegate.endDoctype)
  7950. this.delegate.endDoctype();
  7951. this.transitionTo("beforeData" /* beforeData */);
  7952. }
  7953. else {
  7954. if (this.delegate.appendToDoctypeSystemIdentifier)
  7955. this.delegate.appendToDoctypeSystemIdentifier(char);
  7956. }
  7957. },
  7958. doctypeSystemIdentifierSingleQuoted: function () {
  7959. var char = this.consume();
  7960. if (char === "'") {
  7961. this.transitionTo("afterDoctypeSystemIdentifier" /* afterDoctypeSystemIdentifier */);
  7962. }
  7963. else if (char === '>') {
  7964. if (this.delegate.endDoctype)
  7965. this.delegate.endDoctype();
  7966. this.transitionTo("beforeData" /* beforeData */);
  7967. }
  7968. else {
  7969. if (this.delegate.appendToDoctypeSystemIdentifier)
  7970. this.delegate.appendToDoctypeSystemIdentifier(char);
  7971. }
  7972. },
  7973. afterDoctypeSystemIdentifier: function () {
  7974. var char = this.consume();
  7975. if (isSpace(char)) {
  7976. return;
  7977. }
  7978. else if (char === '>') {
  7979. if (this.delegate.endDoctype)
  7980. this.delegate.endDoctype();
  7981. this.transitionTo("beforeData" /* beforeData */);
  7982. }
  7983. },
  7984. commentStart: function () {
  7985. var char = this.consume();
  7986. if (char === '-') {
  7987. this.transitionTo("commentStartDash" /* commentStartDash */);
  7988. }
  7989. else if (char === '>') {
  7990. this.delegate.finishComment();
  7991. this.transitionTo("beforeData" /* beforeData */);
  7992. }
  7993. else {
  7994. this.delegate.appendToCommentData(char);
  7995. this.transitionTo("comment" /* comment */);
  7996. }
  7997. },
  7998. commentStartDash: function () {
  7999. var char = this.consume();
  8000. if (char === '-') {
  8001. this.transitionTo("commentEnd" /* commentEnd */);
  8002. }
  8003. else if (char === '>') {
  8004. this.delegate.finishComment();
  8005. this.transitionTo("beforeData" /* beforeData */);
  8006. }
  8007. else {
  8008. this.delegate.appendToCommentData('-');
  8009. this.transitionTo("comment" /* comment */);
  8010. }
  8011. },
  8012. comment: function () {
  8013. var char = this.consume();
  8014. if (char === '-') {
  8015. this.transitionTo("commentEndDash" /* commentEndDash */);
  8016. }
  8017. else {
  8018. this.delegate.appendToCommentData(char);
  8019. }
  8020. },
  8021. commentEndDash: function () {
  8022. var char = this.consume();
  8023. if (char === '-') {
  8024. this.transitionTo("commentEnd" /* commentEnd */);
  8025. }
  8026. else {
  8027. this.delegate.appendToCommentData('-' + char);
  8028. this.transitionTo("comment" /* comment */);
  8029. }
  8030. },
  8031. commentEnd: function () {
  8032. var char = this.consume();
  8033. if (char === '>') {
  8034. this.delegate.finishComment();
  8035. this.transitionTo("beforeData" /* beforeData */);
  8036. }
  8037. else {
  8038. this.delegate.appendToCommentData('--' + char);
  8039. this.transitionTo("comment" /* comment */);
  8040. }
  8041. },
  8042. tagName: function () {
  8043. var char = this.consume();
  8044. if (isSpace(char)) {
  8045. this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
  8046. }
  8047. else if (char === '/') {
  8048. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  8049. }
  8050. else if (char === '>') {
  8051. this.delegate.finishTag();
  8052. this.transitionTo("beforeData" /* beforeData */);
  8053. }
  8054. else {
  8055. this.appendToTagName(char);
  8056. }
  8057. },
  8058. endTagName: function () {
  8059. var char = this.consume();
  8060. if (isSpace(char)) {
  8061. this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
  8062. this.tagNameBuffer = '';
  8063. }
  8064. else if (char === '/') {
  8065. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  8066. this.tagNameBuffer = '';
  8067. }
  8068. else if (char === '>') {
  8069. this.delegate.finishTag();
  8070. this.transitionTo("beforeData" /* beforeData */);
  8071. this.tagNameBuffer = '';
  8072. }
  8073. else {
  8074. this.appendToTagName(char);
  8075. }
  8076. },
  8077. beforeAttributeName: function () {
  8078. var char = this.peek();
  8079. if (isSpace(char)) {
  8080. this.consume();
  8081. return;
  8082. }
  8083. else if (char === '/') {
  8084. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  8085. this.consume();
  8086. }
  8087. else if (char === '>') {
  8088. this.consume();
  8089. this.delegate.finishTag();
  8090. this.transitionTo("beforeData" /* beforeData */);
  8091. }
  8092. else if (char === '=') {
  8093. this.delegate.reportSyntaxError('attribute name cannot start with equals sign');
  8094. this.transitionTo("attributeName" /* attributeName */);
  8095. this.delegate.beginAttribute();
  8096. this.consume();
  8097. this.delegate.appendToAttributeName(char);
  8098. }
  8099. else {
  8100. this.transitionTo("attributeName" /* attributeName */);
  8101. this.delegate.beginAttribute();
  8102. }
  8103. },
  8104. attributeName: function () {
  8105. var char = this.peek();
  8106. if (isSpace(char)) {
  8107. this.transitionTo("afterAttributeName" /* afterAttributeName */);
  8108. this.consume();
  8109. }
  8110. else if (char === '/') {
  8111. this.delegate.beginAttributeValue(false);
  8112. this.delegate.finishAttributeValue();
  8113. this.consume();
  8114. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  8115. }
  8116. else if (char === '=') {
  8117. this.transitionTo("beforeAttributeValue" /* beforeAttributeValue */);
  8118. this.consume();
  8119. }
  8120. else if (char === '>') {
  8121. this.delegate.beginAttributeValue(false);
  8122. this.delegate.finishAttributeValue();
  8123. this.consume();
  8124. this.delegate.finishTag();
  8125. this.transitionTo("beforeData" /* beforeData */);
  8126. }
  8127. else if (char === '"' || char === "'" || char === '<') {
  8128. this.delegate.reportSyntaxError(char + ' is not a valid character within attribute names');
  8129. this.consume();
  8130. this.delegate.appendToAttributeName(char);
  8131. }
  8132. else {
  8133. this.consume();
  8134. this.delegate.appendToAttributeName(char);
  8135. }
  8136. },
  8137. afterAttributeName: function () {
  8138. var char = this.peek();
  8139. if (isSpace(char)) {
  8140. this.consume();
  8141. return;
  8142. }
  8143. else if (char === '/') {
  8144. this.delegate.beginAttributeValue(false);
  8145. this.delegate.finishAttributeValue();
  8146. this.consume();
  8147. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  8148. }
  8149. else if (char === '=') {
  8150. this.consume();
  8151. this.transitionTo("beforeAttributeValue" /* beforeAttributeValue */);
  8152. }
  8153. else if (char === '>') {
  8154. this.delegate.beginAttributeValue(false);
  8155. this.delegate.finishAttributeValue();
  8156. this.consume();
  8157. this.delegate.finishTag();
  8158. this.transitionTo("beforeData" /* beforeData */);
  8159. }
  8160. else {
  8161. this.delegate.beginAttributeValue(false);
  8162. this.delegate.finishAttributeValue();
  8163. this.transitionTo("attributeName" /* attributeName */);
  8164. this.delegate.beginAttribute();
  8165. this.consume();
  8166. this.delegate.appendToAttributeName(char);
  8167. }
  8168. },
  8169. beforeAttributeValue: function () {
  8170. var char = this.peek();
  8171. if (isSpace(char)) {
  8172. this.consume();
  8173. }
  8174. else if (char === '"') {
  8175. this.transitionTo("attributeValueDoubleQuoted" /* attributeValueDoubleQuoted */);
  8176. this.delegate.beginAttributeValue(true);
  8177. this.consume();
  8178. }
  8179. else if (char === "'") {
  8180. this.transitionTo("attributeValueSingleQuoted" /* attributeValueSingleQuoted */);
  8181. this.delegate.beginAttributeValue(true);
  8182. this.consume();
  8183. }
  8184. else if (char === '>') {
  8185. this.delegate.beginAttributeValue(false);
  8186. this.delegate.finishAttributeValue();
  8187. this.consume();
  8188. this.delegate.finishTag();
  8189. this.transitionTo("beforeData" /* beforeData */);
  8190. }
  8191. else {
  8192. this.transitionTo("attributeValueUnquoted" /* attributeValueUnquoted */);
  8193. this.delegate.beginAttributeValue(false);
  8194. this.consume();
  8195. this.delegate.appendToAttributeValue(char);
  8196. }
  8197. },
  8198. attributeValueDoubleQuoted: function () {
  8199. var char = this.consume();
  8200. if (char === '"') {
  8201. this.delegate.finishAttributeValue();
  8202. this.transitionTo("afterAttributeValueQuoted" /* afterAttributeValueQuoted */);
  8203. }
  8204. else if (char === '&') {
  8205. this.delegate.appendToAttributeValue(this.consumeCharRef() || '&');
  8206. }
  8207. else {
  8208. this.delegate.appendToAttributeValue(char);
  8209. }
  8210. },
  8211. attributeValueSingleQuoted: function () {
  8212. var char = this.consume();
  8213. if (char === "'") {
  8214. this.delegate.finishAttributeValue();
  8215. this.transitionTo("afterAttributeValueQuoted" /* afterAttributeValueQuoted */);
  8216. }
  8217. else if (char === '&') {
  8218. this.delegate.appendToAttributeValue(this.consumeCharRef() || '&');
  8219. }
  8220. else {
  8221. this.delegate.appendToAttributeValue(char);
  8222. }
  8223. },
  8224. attributeValueUnquoted: function () {
  8225. var char = this.peek();
  8226. if (isSpace(char)) {
  8227. this.delegate.finishAttributeValue();
  8228. this.consume();
  8229. this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
  8230. }
  8231. else if (char === '/') {
  8232. this.delegate.finishAttributeValue();
  8233. this.consume();
  8234. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  8235. }
  8236. else if (char === '&') {
  8237. this.consume();
  8238. this.delegate.appendToAttributeValue(this.consumeCharRef() || '&');
  8239. }
  8240. else if (char === '>') {
  8241. this.delegate.finishAttributeValue();
  8242. this.consume();
  8243. this.delegate.finishTag();
  8244. this.transitionTo("beforeData" /* beforeData */);
  8245. }
  8246. else {
  8247. this.consume();
  8248. this.delegate.appendToAttributeValue(char);
  8249. }
  8250. },
  8251. afterAttributeValueQuoted: function () {
  8252. var char = this.peek();
  8253. if (isSpace(char)) {
  8254. this.consume();
  8255. this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
  8256. }
  8257. else if (char === '/') {
  8258. this.consume();
  8259. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  8260. }
  8261. else if (char === '>') {
  8262. this.consume();
  8263. this.delegate.finishTag();
  8264. this.transitionTo("beforeData" /* beforeData */);
  8265. }
  8266. else {
  8267. this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
  8268. }
  8269. },
  8270. selfClosingStartTag: function () {
  8271. var char = this.peek();
  8272. if (char === '>') {
  8273. this.consume();
  8274. this.delegate.markTagAsSelfClosing();
  8275. this.delegate.finishTag();
  8276. this.transitionTo("beforeData" /* beforeData */);
  8277. }
  8278. else {
  8279. this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
  8280. }
  8281. },
  8282. endTagOpen: function () {
  8283. var char = this.consume();
  8284. if (char === '@' || char === ':' || isAlpha(char)) {
  8285. this.transitionTo("endTagName" /* endTagName */);
  8286. this.tagNameBuffer = '';
  8287. this.delegate.beginEndTag();
  8288. this.appendToTagName(char);
  8289. }
  8290. }
  8291. };
  8292. this.reset();
  8293. }
  8294. EventedTokenizer.prototype.reset = function () {
  8295. this.transitionTo("beforeData" /* beforeData */);
  8296. this.input = '';
  8297. this.tagNameBuffer = '';
  8298. this.index = 0;
  8299. this.line = 1;
  8300. this.column = 0;
  8301. this.delegate.reset();
  8302. };
  8303. EventedTokenizer.prototype.transitionTo = function (state) {
  8304. this.state = state;
  8305. };
  8306. EventedTokenizer.prototype.tokenize = function (input) {
  8307. this.reset();
  8308. this.tokenizePart(input);
  8309. this.tokenizeEOF();
  8310. };
  8311. EventedTokenizer.prototype.tokenizePart = function (input) {
  8312. this.input += preprocessInput(input);
  8313. while (this.index < this.input.length) {
  8314. var handler = this.states[this.state];
  8315. if (handler !== undefined) {
  8316. handler.call(this);
  8317. }
  8318. else {
  8319. throw new Error("unhandled state " + this.state);
  8320. }
  8321. }
  8322. };
  8323. EventedTokenizer.prototype.tokenizeEOF = function () {
  8324. this.flushData();
  8325. };
  8326. EventedTokenizer.prototype.flushData = function () {
  8327. if (this.state === 'data') {
  8328. this.delegate.finishData();
  8329. this.transitionTo("beforeData" /* beforeData */);
  8330. }
  8331. };
  8332. EventedTokenizer.prototype.peek = function () {
  8333. return this.input.charAt(this.index);
  8334. };
  8335. EventedTokenizer.prototype.consume = function () {
  8336. var char = this.peek();
  8337. this.index++;
  8338. if (char === '\n') {
  8339. this.line++;
  8340. this.column = 0;
  8341. }
  8342. else {
  8343. this.column++;
  8344. }
  8345. return char;
  8346. };
  8347. EventedTokenizer.prototype.consumeCharRef = function () {
  8348. var endIndex = this.input.indexOf(';', this.index);
  8349. if (endIndex === -1) {
  8350. return;
  8351. }
  8352. var entity = this.input.slice(this.index, endIndex);
  8353. var chars = this.entityParser.parse(entity);
  8354. if (chars) {
  8355. var count = entity.length;
  8356. // consume the entity chars
  8357. while (count) {
  8358. this.consume();
  8359. count--;
  8360. }
  8361. // consume the `;`
  8362. this.consume();
  8363. return chars;
  8364. }
  8365. };
  8366. EventedTokenizer.prototype.markTagStart = function () {
  8367. this.delegate.tagOpen();
  8368. };
  8369. EventedTokenizer.prototype.appendToTagName = function (char) {
  8370. this.tagNameBuffer += char;
  8371. this.delegate.appendToTagName(char);
  8372. };
  8373. EventedTokenizer.prototype.isIgnoredEndTag = function () {
  8374. var tag = this.tagNameBuffer;
  8375. return (tag === 'title' && this.input.substring(this.index, this.index + 8) !== '</title>') ||
  8376. (tag === 'style' && this.input.substring(this.index, this.index + 8) !== '</style>') ||
  8377. (tag === 'script' && this.input.substring(this.index, this.index + 9) !== '</script>');
  8378. };
  8379. return EventedTokenizer;
  8380. }());
  8381. var Tokenizer = /** @class */ (function () {
  8382. function Tokenizer(entityParser, options) {
  8383. if (options === void 0) { options = {}; }
  8384. this.options = options;
  8385. this.token = null;
  8386. this.startLine = 1;
  8387. this.startColumn = 0;
  8388. this.tokens = [];
  8389. this.tokenizer = new EventedTokenizer(this, entityParser, options.mode);
  8390. this._currentAttribute = undefined;
  8391. }
  8392. Tokenizer.prototype.tokenize = function (input) {
  8393. this.tokens = [];
  8394. this.tokenizer.tokenize(input);
  8395. return this.tokens;
  8396. };
  8397. Tokenizer.prototype.tokenizePart = function (input) {
  8398. this.tokens = [];
  8399. this.tokenizer.tokenizePart(input);
  8400. return this.tokens;
  8401. };
  8402. Tokenizer.prototype.tokenizeEOF = function () {
  8403. this.tokens = [];
  8404. this.tokenizer.tokenizeEOF();
  8405. return this.tokens[0];
  8406. };
  8407. Tokenizer.prototype.reset = function () {
  8408. this.token = null;
  8409. this.startLine = 1;
  8410. this.startColumn = 0;
  8411. };
  8412. Tokenizer.prototype.current = function () {
  8413. var token = this.token;
  8414. if (token === null) {
  8415. throw new Error('token was unexpectedly null');
  8416. }
  8417. if (arguments.length === 0) {
  8418. return token;
  8419. }
  8420. for (var i = 0; i < arguments.length; i++) {
  8421. if (token.type === arguments[i]) {
  8422. return token;
  8423. }
  8424. }
  8425. throw new Error("token type was unexpectedly " + token.type);
  8426. };
  8427. Tokenizer.prototype.push = function (token) {
  8428. this.token = token;
  8429. this.tokens.push(token);
  8430. };
  8431. Tokenizer.prototype.currentAttribute = function () {
  8432. return this._currentAttribute;
  8433. };
  8434. Tokenizer.prototype.addLocInfo = function () {
  8435. if (this.options.loc) {
  8436. this.current().loc = {
  8437. start: {
  8438. line: this.startLine,
  8439. column: this.startColumn
  8440. },
  8441. end: {
  8442. line: this.tokenizer.line,
  8443. column: this.tokenizer.column
  8444. }
  8445. };
  8446. }
  8447. this.startLine = this.tokenizer.line;
  8448. this.startColumn = this.tokenizer.column;
  8449. };
  8450. // Data
  8451. Tokenizer.prototype.beginDoctype = function () {
  8452. this.push({
  8453. type: "Doctype" /* Doctype */,
  8454. name: '',
  8455. });
  8456. };
  8457. Tokenizer.prototype.appendToDoctypeName = function (char) {
  8458. this.current("Doctype" /* Doctype */).name += char;
  8459. };
  8460. Tokenizer.prototype.appendToDoctypePublicIdentifier = function (char) {
  8461. var doctype = this.current("Doctype" /* Doctype */);
  8462. if (doctype.publicIdentifier === undefined) {
  8463. doctype.publicIdentifier = char;
  8464. }
  8465. else {
  8466. doctype.publicIdentifier += char;
  8467. }
  8468. };
  8469. Tokenizer.prototype.appendToDoctypeSystemIdentifier = function (char) {
  8470. var doctype = this.current("Doctype" /* Doctype */);
  8471. if (doctype.systemIdentifier === undefined) {
  8472. doctype.systemIdentifier = char;
  8473. }
  8474. else {
  8475. doctype.systemIdentifier += char;
  8476. }
  8477. };
  8478. Tokenizer.prototype.endDoctype = function () {
  8479. this.addLocInfo();
  8480. };
  8481. Tokenizer.prototype.beginData = function () {
  8482. this.push({
  8483. type: "Chars" /* Chars */,
  8484. chars: ''
  8485. });
  8486. };
  8487. Tokenizer.prototype.appendToData = function (char) {
  8488. this.current("Chars" /* Chars */).chars += char;
  8489. };
  8490. Tokenizer.prototype.finishData = function () {
  8491. this.addLocInfo();
  8492. };
  8493. // Comment
  8494. Tokenizer.prototype.beginComment = function () {
  8495. this.push({
  8496. type: "Comment" /* Comment */,
  8497. chars: ''
  8498. });
  8499. };
  8500. Tokenizer.prototype.appendToCommentData = function (char) {
  8501. this.current("Comment" /* Comment */).chars += char;
  8502. };
  8503. Tokenizer.prototype.finishComment = function () {
  8504. this.addLocInfo();
  8505. };
  8506. // Tags - basic
  8507. Tokenizer.prototype.tagOpen = function () { };
  8508. Tokenizer.prototype.beginStartTag = function () {
  8509. this.push({
  8510. type: "StartTag" /* StartTag */,
  8511. tagName: '',
  8512. attributes: [],
  8513. selfClosing: false
  8514. });
  8515. };
  8516. Tokenizer.prototype.beginEndTag = function () {
  8517. this.push({
  8518. type: "EndTag" /* EndTag */,
  8519. tagName: ''
  8520. });
  8521. };
  8522. Tokenizer.prototype.finishTag = function () {
  8523. this.addLocInfo();
  8524. };
  8525. Tokenizer.prototype.markTagAsSelfClosing = function () {
  8526. this.current("StartTag" /* StartTag */).selfClosing = true;
  8527. };
  8528. // Tags - name
  8529. Tokenizer.prototype.appendToTagName = function (char) {
  8530. this.current("StartTag" /* StartTag */, "EndTag" /* EndTag */).tagName += char;
  8531. };
  8532. // Tags - attributes
  8533. Tokenizer.prototype.beginAttribute = function () {
  8534. this._currentAttribute = ['', '', false];
  8535. };
  8536. Tokenizer.prototype.appendToAttributeName = function (char) {
  8537. this.currentAttribute()[0] += char;
  8538. };
  8539. Tokenizer.prototype.beginAttributeValue = function (isQuoted) {
  8540. this.currentAttribute()[2] = isQuoted;
  8541. };
  8542. Tokenizer.prototype.appendToAttributeValue = function (char) {
  8543. this.currentAttribute()[1] += char;
  8544. };
  8545. Tokenizer.prototype.finishAttributeValue = function () {
  8546. this.current("StartTag" /* StartTag */).attributes.push(this._currentAttribute);
  8547. };
  8548. Tokenizer.prototype.reportSyntaxError = function (message) {
  8549. this.current().syntaxError = message;
  8550. };
  8551. return Tokenizer;
  8552. }());
  8553. function tokenize(input, options) {
  8554. var tokenizer = new Tokenizer(new EntityParser(namedCharRefs), options);
  8555. return tokenizer.tokenize(input);
  8556. }
  8557. ;// CONCATENATED MODULE: external ["wp","deprecated"]
  8558. var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
  8559. var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
  8560. ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
  8561. var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
  8562. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/logger.js
  8563. /**
  8564. * @typedef LoggerItem
  8565. * @property {Function} log Which logger recorded the message
  8566. * @property {Array<any>} args White arguments were supplied to the logger
  8567. */
  8568. function createLogger() {
  8569. /**
  8570. * Creates a log handler with block validation prefix.
  8571. *
  8572. * @param {Function} logger Original logger function.
  8573. *
  8574. * @return {Function} Augmented logger function.
  8575. */
  8576. function createLogHandler(logger) {
  8577. let log = function (message) {
  8578. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  8579. args[_key - 1] = arguments[_key];
  8580. }
  8581. return logger('Block validation: ' + message, ...args);
  8582. }; // In test environments, pre-process string substitutions to improve
  8583. // readability of error messages. We'd prefer to avoid pulling in this
  8584. // dependency in runtime environments, and it can be dropped by a combo
  8585. // of Webpack env substitution + UglifyJS dead code elimination.
  8586. if (false) {}
  8587. return log;
  8588. }
  8589. return {
  8590. // eslint-disable-next-line no-console
  8591. error: createLogHandler(console.error),
  8592. // eslint-disable-next-line no-console
  8593. warning: createLogHandler(console.warn),
  8594. getItems() {
  8595. return [];
  8596. }
  8597. };
  8598. }
  8599. function createQueuedLogger() {
  8600. /**
  8601. * The list of enqueued log actions to print.
  8602. *
  8603. * @type {Array<LoggerItem>}
  8604. */
  8605. const queue = [];
  8606. const logger = createLogger();
  8607. return {
  8608. error() {
  8609. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  8610. args[_key2] = arguments[_key2];
  8611. }
  8612. queue.push({
  8613. log: logger.error,
  8614. args
  8615. });
  8616. },
  8617. warning() {
  8618. for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  8619. args[_key3] = arguments[_key3];
  8620. }
  8621. queue.push({
  8622. log: logger.warning,
  8623. args
  8624. });
  8625. },
  8626. getItems() {
  8627. return queue;
  8628. }
  8629. };
  8630. }
  8631. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/index.js
  8632. /**
  8633. * External dependencies
  8634. */
  8635. /**
  8636. * WordPress dependencies
  8637. */
  8638. /**
  8639. * Internal dependencies
  8640. */
  8641. /** @typedef {import('../parser').WPBlock} WPBlock */
  8642. /** @typedef {import('../registration').WPBlockType} WPBlockType */
  8643. /** @typedef {import('./logger').LoggerItem} LoggerItem */
  8644. /**
  8645. * Globally matches any consecutive whitespace
  8646. *
  8647. * @type {RegExp}
  8648. */
  8649. const REGEXP_WHITESPACE = /[\t\n\r\v\f ]+/g;
  8650. /**
  8651. * Matches a string containing only whitespace
  8652. *
  8653. * @type {RegExp}
  8654. */
  8655. const REGEXP_ONLY_WHITESPACE = /^[\t\n\r\v\f ]*$/;
  8656. /**
  8657. * Matches a CSS URL type value
  8658. *
  8659. * @type {RegExp}
  8660. */
  8661. const REGEXP_STYLE_URL_TYPE = /^url\s*\(['"\s]*(.*?)['"\s]*\)$/;
  8662. /**
  8663. * Boolean attributes are attributes whose presence as being assigned is
  8664. * meaningful, even if only empty.
  8665. *
  8666. * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes
  8667. * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
  8668. *
  8669. * Object.keys( Array.from( document.querySelectorAll( '#attributes-1 > tbody > tr' ) )
  8670. * .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 )
  8671. * .reduce( ( result, tr ) => Object.assign( result, {
  8672. * [ tr.firstChild.textContent.trim() ]: true
  8673. * } ), {} ) ).sort();
  8674. *
  8675. * @type {Array}
  8676. */
  8677. const BOOLEAN_ATTRIBUTES = ['allowfullscreen', 'allowpaymentrequest', 'allowusermedia', 'async', 'autofocus', 'autoplay', 'checked', 'controls', 'default', 'defer', 'disabled', 'download', 'formnovalidate', 'hidden', 'ismap', 'itemscope', 'loop', 'multiple', 'muted', 'nomodule', 'novalidate', 'open', 'playsinline', 'readonly', 'required', 'reversed', 'selected', 'typemustmatch'];
  8678. /**
  8679. * Enumerated attributes are attributes which must be of a specific value form.
  8680. * Like boolean attributes, these are meaningful if specified, even if not of a
  8681. * valid enumerated value.
  8682. *
  8683. * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute
  8684. * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
  8685. *
  8686. * Object.keys( Array.from( document.querySelectorAll( '#attributes-1 > tbody > tr' ) )
  8687. * .filter( ( tr ) => /^("(.+?)";?\s*)+/.test( tr.lastChild.textContent.trim() ) )
  8688. * .reduce( ( result, tr ) => Object.assign( result, {
  8689. * [ tr.firstChild.textContent.trim() ]: true
  8690. * } ), {} ) ).sort();
  8691. *
  8692. * @type {Array}
  8693. */
  8694. const ENUMERATED_ATTRIBUTES = ['autocapitalize', 'autocomplete', 'charset', 'contenteditable', 'crossorigin', 'decoding', 'dir', 'draggable', 'enctype', 'formenctype', 'formmethod', 'http-equiv', 'inputmode', 'kind', 'method', 'preload', 'scope', 'shape', 'spellcheck', 'translate', 'type', 'wrap'];
  8695. /**
  8696. * Meaningful attributes are those who cannot be safely ignored when omitted in
  8697. * one HTML markup string and not another.
  8698. *
  8699. * @type {Array}
  8700. */
  8701. const MEANINGFUL_ATTRIBUTES = [...BOOLEAN_ATTRIBUTES, ...ENUMERATED_ATTRIBUTES];
  8702. /**
  8703. * Array of functions which receive a text string on which to apply normalizing
  8704. * behavior for consideration in text token equivalence, carefully ordered from
  8705. * least-to-most expensive operations.
  8706. *
  8707. * @type {Array}
  8708. */
  8709. const TEXT_NORMALIZATIONS = [external_lodash_namespaceObject.identity, getTextWithCollapsedWhitespace];
  8710. /**
  8711. * Regular expression matching a named character reference. In lieu of bundling
  8712. * a full set of references, the pattern covers the minimal necessary to test
  8713. * positively against the full set.
  8714. *
  8715. * "The ampersand must be followed by one of the names given in the named
  8716. * character references section, using the same case."
  8717. *
  8718. * Tested aginst "12.5 Named character references":
  8719. *
  8720. * ```
  8721. * const references = Array.from( document.querySelectorAll(
  8722. * '#named-character-references-table tr[id^=entity-] td:first-child'
  8723. * ) ).map( ( code ) => code.textContent )
  8724. * references.every( ( reference ) => /^[\da-z]+$/i.test( reference ) )
  8725. * ```
  8726. *
  8727. * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references
  8728. * @see https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references
  8729. *
  8730. * @type {RegExp}
  8731. */
  8732. const REGEXP_NAMED_CHARACTER_REFERENCE = /^[\da-z]+$/i;
  8733. /**
  8734. * Regular expression matching a decimal character reference.
  8735. *
  8736. * "The ampersand must be followed by a U+0023 NUMBER SIGN character (#),
  8737. * followed by one or more ASCII digits, representing a base-ten integer"
  8738. *
  8739. * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references
  8740. *
  8741. * @type {RegExp}
  8742. */
  8743. const REGEXP_DECIMAL_CHARACTER_REFERENCE = /^#\d+$/;
  8744. /**
  8745. * Regular expression matching a hexadecimal character reference.
  8746. *
  8747. * "The ampersand must be followed by a U+0023 NUMBER SIGN character (#), which
  8748. * must be followed by either a U+0078 LATIN SMALL LETTER X character (x) or a
  8749. * U+0058 LATIN CAPITAL LETTER X character (X), which must then be followed by
  8750. * one or more ASCII hex digits, representing a hexadecimal integer"
  8751. *
  8752. * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references
  8753. *
  8754. * @type {RegExp}
  8755. */
  8756. const REGEXP_HEXADECIMAL_CHARACTER_REFERENCE = /^#x[\da-f]+$/i;
  8757. /**
  8758. * Returns true if the given string is a valid character reference segment, or
  8759. * false otherwise. The text should be stripped of `&` and `;` demarcations.
  8760. *
  8761. * @param {string} text Text to test.
  8762. *
  8763. * @return {boolean} Whether text is valid character reference.
  8764. */
  8765. function isValidCharacterReference(text) {
  8766. return REGEXP_NAMED_CHARACTER_REFERENCE.test(text) || REGEXP_DECIMAL_CHARACTER_REFERENCE.test(text) || REGEXP_HEXADECIMAL_CHARACTER_REFERENCE.test(text);
  8767. }
  8768. /**
  8769. * Subsitute EntityParser class for `simple-html-tokenizer` which uses the
  8770. * implementation of `decodeEntities` from `html-entities`, in order to avoid
  8771. * bundling a massive named character reference.
  8772. *
  8773. * @see https://github.com/tildeio/simple-html-tokenizer/tree/HEAD/src/entity-parser.ts
  8774. */
  8775. class DecodeEntityParser {
  8776. /**
  8777. * Returns a substitute string for an entity string sequence between `&`
  8778. * and `;`, or undefined if no substitution should occur.
  8779. *
  8780. * @param {string} entity Entity fragment discovered in HTML.
  8781. *
  8782. * @return {?string} Entity substitute value.
  8783. */
  8784. parse(entity) {
  8785. if (isValidCharacterReference(entity)) {
  8786. return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)('&' + entity + ';');
  8787. }
  8788. }
  8789. }
  8790. /**
  8791. * Given a specified string, returns an array of strings split by consecutive
  8792. * whitespace, ignoring leading or trailing whitespace.
  8793. *
  8794. * @param {string} text Original text.
  8795. *
  8796. * @return {string[]} Text pieces split on whitespace.
  8797. */
  8798. function getTextPiecesSplitOnWhitespace(text) {
  8799. return text.trim().split(REGEXP_WHITESPACE);
  8800. }
  8801. /**
  8802. * Given a specified string, returns a new trimmed string where all consecutive
  8803. * whitespace is collapsed to a single space.
  8804. *
  8805. * @param {string} text Original text.
  8806. *
  8807. * @return {string} Trimmed text with consecutive whitespace collapsed.
  8808. */
  8809. function getTextWithCollapsedWhitespace(text) {
  8810. // This is an overly simplified whitespace comparison. The specification is
  8811. // more prescriptive of whitespace behavior in inline and block contexts.
  8812. //
  8813. // See: https://medium.com/@patrickbrosset/when-does-white-space-matter-in-html-b90e8a7cdd33
  8814. return getTextPiecesSplitOnWhitespace(text).join(' ');
  8815. }
  8816. /**
  8817. * Returns attribute pairs of the given StartTag token, including only pairs
  8818. * where the value is non-empty or the attribute is a boolean attribute, an
  8819. * enumerated attribute, or a custom data- attribute.
  8820. *
  8821. * @see MEANINGFUL_ATTRIBUTES
  8822. *
  8823. * @param {Object} token StartTag token.
  8824. *
  8825. * @return {Array[]} Attribute pairs.
  8826. */
  8827. function getMeaningfulAttributePairs(token) {
  8828. return token.attributes.filter(pair => {
  8829. const [key, value] = pair;
  8830. return value || key.indexOf('data-') === 0 || (0,external_lodash_namespaceObject.includes)(MEANINGFUL_ATTRIBUTES, key);
  8831. });
  8832. }
  8833. /**
  8834. * Returns true if two text tokens (with `chars` property) are equivalent, or
  8835. * false otherwise.
  8836. *
  8837. * @param {Object} actual Actual token.
  8838. * @param {Object} expected Expected token.
  8839. * @param {Object} logger Validation logger object.
  8840. *
  8841. * @return {boolean} Whether two text tokens are equivalent.
  8842. */
  8843. function isEquivalentTextTokens(actual, expected) {
  8844. let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger();
  8845. // This function is intentionally written as syntactically "ugly" as a hot
  8846. // path optimization. Text is progressively normalized in order from least-
  8847. // to-most operationally expensive, until the earliest point at which text
  8848. // can be confidently inferred as being equal.
  8849. let actualChars = actual.chars;
  8850. let expectedChars = expected.chars;
  8851. for (let i = 0; i < TEXT_NORMALIZATIONS.length; i++) {
  8852. const normalize = TEXT_NORMALIZATIONS[i];
  8853. actualChars = normalize(actualChars);
  8854. expectedChars = normalize(expectedChars);
  8855. if (actualChars === expectedChars) {
  8856. return true;
  8857. }
  8858. }
  8859. logger.warning('Expected text `%s`, saw `%s`.', expected.chars, actual.chars);
  8860. return false;
  8861. }
  8862. /**
  8863. * Given a CSS length value, returns a normalized CSS length value for strict equality
  8864. * comparison.
  8865. *
  8866. * @param {string} value CSS length value.
  8867. *
  8868. * @return {string} Normalized CSS length value.
  8869. */
  8870. function getNormalizedLength(value) {
  8871. if (0 === parseFloat(value)) {
  8872. return '0';
  8873. } // Normalize strings with floats to always include a leading zero.
  8874. if (value.indexOf('.') === 0) {
  8875. return '0' + value;
  8876. }
  8877. return value;
  8878. }
  8879. /**
  8880. * Given a style value, returns a normalized style value for strict equality
  8881. * comparison.
  8882. *
  8883. * @param {string} value Style value.
  8884. *
  8885. * @return {string} Normalized style value.
  8886. */
  8887. function getNormalizedStyleValue(value) {
  8888. const textPieces = getTextPiecesSplitOnWhitespace(value);
  8889. const normalizedPieces = textPieces.map(getNormalizedLength);
  8890. const result = normalizedPieces.join(' ');
  8891. return result // Normalize URL type to omit whitespace or quotes.
  8892. .replace(REGEXP_STYLE_URL_TYPE, 'url($1)');
  8893. }
  8894. /**
  8895. * Given a style attribute string, returns an object of style properties.
  8896. *
  8897. * @param {string} text Style attribute.
  8898. *
  8899. * @return {Object} Style properties.
  8900. */
  8901. function getStyleProperties(text) {
  8902. const pairs = text // Trim ending semicolon (avoid including in split)
  8903. .replace(/;?\s*$/, '') // Split on property assignment.
  8904. .split(';') // For each property assignment...
  8905. .map(style => {
  8906. // ...split further into key-value pairs.
  8907. const [key, ...valueParts] = style.split(':');
  8908. const value = valueParts.join(':');
  8909. return [key.trim(), getNormalizedStyleValue(value.trim())];
  8910. });
  8911. return (0,external_lodash_namespaceObject.fromPairs)(pairs);
  8912. }
  8913. /**
  8914. * Attribute-specific equality handlers
  8915. *
  8916. * @type {Object}
  8917. */
  8918. const isEqualAttributesOfName = {
  8919. class: (actual, expected) => {
  8920. // Class matches if members are the same, even if out of order or
  8921. // superfluous whitespace between.
  8922. return !(0,external_lodash_namespaceObject.xor)(...[actual, expected].map(getTextPiecesSplitOnWhitespace)).length;
  8923. },
  8924. style: (actual, expected) => {
  8925. return (0,external_lodash_namespaceObject.isEqual)(...[actual, expected].map(getStyleProperties));
  8926. },
  8927. // For each boolean attribute, mere presence of attribute in both is enough
  8928. // to assume equivalence.
  8929. ...(0,external_lodash_namespaceObject.fromPairs)(BOOLEAN_ATTRIBUTES.map(attribute => [attribute, external_lodash_namespaceObject.stubTrue]))
  8930. };
  8931. /**
  8932. * Given two sets of attribute tuples, returns true if the attribute sets are
  8933. * equivalent.
  8934. *
  8935. * @param {Array[]} actual Actual attributes tuples.
  8936. * @param {Array[]} expected Expected attributes tuples.
  8937. * @param {Object} logger Validation logger object.
  8938. *
  8939. * @return {boolean} Whether attributes are equivalent.
  8940. */
  8941. function isEqualTagAttributePairs(actual, expected) {
  8942. let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger();
  8943. // Attributes is tokenized as tuples. Their lengths should match. This also
  8944. // avoids us needing to check both attributes sets, since if A has any keys
  8945. // which do not exist in B, we know the sets to be different.
  8946. if (actual.length !== expected.length) {
  8947. logger.warning('Expected attributes %o, instead saw %o.', expected, actual);
  8948. return false;
  8949. } // Attributes are not guaranteed to occur in the same order. For validating
  8950. // actual attributes, first convert the set of expected attribute values to
  8951. // an object, for lookup by key.
  8952. const expectedAttributes = {};
  8953. for (let i = 0; i < expected.length; i++) {
  8954. expectedAttributes[expected[i][0].toLowerCase()] = expected[i][1];
  8955. }
  8956. for (let i = 0; i < actual.length; i++) {
  8957. const [name, actualValue] = actual[i];
  8958. const nameLower = name.toLowerCase(); // As noted above, if missing member in B, assume different.
  8959. if (!expectedAttributes.hasOwnProperty(nameLower)) {
  8960. logger.warning('Encountered unexpected attribute `%s`.', name);
  8961. return false;
  8962. }
  8963. const expectedValue = expectedAttributes[nameLower];
  8964. const isEqualAttributes = isEqualAttributesOfName[nameLower];
  8965. if (isEqualAttributes) {
  8966. // Defer custom attribute equality handling.
  8967. if (!isEqualAttributes(actualValue, expectedValue)) {
  8968. logger.warning('Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue);
  8969. return false;
  8970. }
  8971. } else if (actualValue !== expectedValue) {
  8972. // Otherwise strict inequality should bail.
  8973. logger.warning('Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue);
  8974. return false;
  8975. }
  8976. }
  8977. return true;
  8978. }
  8979. /**
  8980. * Token-type-specific equality handlers
  8981. *
  8982. * @type {Object}
  8983. */
  8984. const isEqualTokensOfType = {
  8985. StartTag: function (actual, expected) {
  8986. let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger();
  8987. if (actual.tagName !== expected.tagName && // Optimization: Use short-circuit evaluation to defer case-
  8988. // insensitive check on the assumption that the majority case will
  8989. // have exactly equal tag names.
  8990. actual.tagName.toLowerCase() !== expected.tagName.toLowerCase()) {
  8991. logger.warning('Expected tag name `%s`, instead saw `%s`.', expected.tagName, actual.tagName);
  8992. return false;
  8993. }
  8994. return isEqualTagAttributePairs(...[actual, expected].map(getMeaningfulAttributePairs), logger);
  8995. },
  8996. Chars: isEquivalentTextTokens,
  8997. Comment: isEquivalentTextTokens
  8998. };
  8999. /**
  9000. * Given an array of tokens, returns the first token which is not purely
  9001. * whitespace.
  9002. *
  9003. * Mutates the tokens array.
  9004. *
  9005. * @param {Object[]} tokens Set of tokens to search.
  9006. *
  9007. * @return {Object} Next non-whitespace token.
  9008. */
  9009. function getNextNonWhitespaceToken(tokens) {
  9010. let token;
  9011. while (token = tokens.shift()) {
  9012. if (token.type !== 'Chars') {
  9013. return token;
  9014. }
  9015. if (!REGEXP_ONLY_WHITESPACE.test(token.chars)) {
  9016. return token;
  9017. }
  9018. }
  9019. }
  9020. /**
  9021. * Tokenize an HTML string, gracefully handling any errors thrown during
  9022. * underlying tokenization.
  9023. *
  9024. * @param {string} html HTML string to tokenize.
  9025. * @param {Object} logger Validation logger object.
  9026. *
  9027. * @return {Object[]|null} Array of valid tokenized HTML elements, or null on error
  9028. */
  9029. function getHTMLTokens(html) {
  9030. let logger = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createLogger();
  9031. try {
  9032. return new Tokenizer(new DecodeEntityParser()).tokenize(html);
  9033. } catch (e) {
  9034. logger.warning('Malformed HTML detected: %s', html);
  9035. }
  9036. return null;
  9037. }
  9038. /**
  9039. * Returns true if the next HTML token closes the current token.
  9040. *
  9041. * @param {Object} currentToken Current token to compare with.
  9042. * @param {Object|undefined} nextToken Next token to compare against.
  9043. *
  9044. * @return {boolean} true if `nextToken` closes `currentToken`, false otherwise
  9045. */
  9046. function isClosedByToken(currentToken, nextToken) {
  9047. // Ensure this is a self closed token.
  9048. if (!currentToken.selfClosing) {
  9049. return false;
  9050. } // Check token names and determine if nextToken is the closing tag for currentToken.
  9051. if (nextToken && nextToken.tagName === currentToken.tagName && nextToken.type === 'EndTag') {
  9052. return true;
  9053. }
  9054. return false;
  9055. }
  9056. /**
  9057. * Returns true if the given HTML strings are effectively equivalent, or
  9058. * false otherwise. Invalid HTML is not considered equivalent, even if the
  9059. * strings directly match.
  9060. *
  9061. * @param {string} actual Actual HTML string.
  9062. * @param {string} expected Expected HTML string.
  9063. * @param {Object} logger Validation logger object.
  9064. *
  9065. * @return {boolean} Whether HTML strings are equivalent.
  9066. */
  9067. function isEquivalentHTML(actual, expected) {
  9068. let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger();
  9069. // Short-circuit if markup is identical.
  9070. if (actual === expected) {
  9071. return true;
  9072. } // Tokenize input content and reserialized save content.
  9073. const [actualTokens, expectedTokens] = [actual, expected].map(html => getHTMLTokens(html, logger)); // If either is malformed then stop comparing - the strings are not equivalent.
  9074. if (!actualTokens || !expectedTokens) {
  9075. return false;
  9076. }
  9077. let actualToken, expectedToken;
  9078. while (actualToken = getNextNonWhitespaceToken(actualTokens)) {
  9079. expectedToken = getNextNonWhitespaceToken(expectedTokens); // Inequal if exhausted all expected tokens.
  9080. if (!expectedToken) {
  9081. logger.warning('Expected end of content, instead saw %o.', actualToken);
  9082. return false;
  9083. } // Inequal if next non-whitespace token of each set are not same type.
  9084. if (actualToken.type !== expectedToken.type) {
  9085. logger.warning('Expected token of type `%s` (%o), instead saw `%s` (%o).', expectedToken.type, expectedToken, actualToken.type, actualToken);
  9086. return false;
  9087. } // Defer custom token type equality handling, otherwise continue and
  9088. // assume as equal.
  9089. const isEqualTokens = isEqualTokensOfType[actualToken.type];
  9090. if (isEqualTokens && !isEqualTokens(actualToken, expectedToken, logger)) {
  9091. return false;
  9092. } // Peek at the next tokens (actual and expected) to see if they close
  9093. // a self-closing tag.
  9094. if (isClosedByToken(actualToken, expectedTokens[0])) {
  9095. // Consume the next expected token that closes the current actual
  9096. // self-closing token.
  9097. getNextNonWhitespaceToken(expectedTokens);
  9098. } else if (isClosedByToken(expectedToken, actualTokens[0])) {
  9099. // Consume the next actual token that closes the current expected
  9100. // self-closing token.
  9101. getNextNonWhitespaceToken(actualTokens);
  9102. }
  9103. }
  9104. if (expectedToken = getNextNonWhitespaceToken(expectedTokens)) {
  9105. // If any non-whitespace tokens remain in expected token set, this
  9106. // indicates inequality.
  9107. logger.warning('Expected %o, instead saw end of content.', expectedToken);
  9108. return false;
  9109. }
  9110. return true;
  9111. }
  9112. /**
  9113. * Returns an object with `isValid` property set to `true` if the parsed block
  9114. * is valid given the input content. A block is considered valid if, when serialized
  9115. * with assumed attributes, the content matches the original value. If block is
  9116. * invalid, this function returns all validations issues as well.
  9117. *
  9118. * @param {string|Object} blockTypeOrName Block type.
  9119. * @param {Object} attributes Parsed block attributes.
  9120. * @param {string} originalBlockContent Original block content.
  9121. * @param {Object} logger Validation logger object.
  9122. *
  9123. * @return {Object} Whether block is valid and contains validation messages.
  9124. */
  9125. /**
  9126. * Returns an object with `isValid` property set to `true` if the parsed block
  9127. * is valid given the input content. A block is considered valid if, when serialized
  9128. * with assumed attributes, the content matches the original value. If block is
  9129. * invalid, this function returns all validations issues as well.
  9130. *
  9131. * @param {WPBlock} block block object.
  9132. * @param {WPBlockType|string} [blockTypeOrName = block.name] Block type or name, inferred from block if not given.
  9133. *
  9134. * @return {[boolean,Array<LoggerItem>]} validation results.
  9135. */
  9136. function validateBlock(block) {
  9137. let blockTypeOrName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : block.name;
  9138. const isFallbackBlock = block.name === getFreeformContentHandlerName() || block.name === getUnregisteredTypeHandlerName(); // Shortcut to avoid costly validation.
  9139. if (isFallbackBlock) {
  9140. return [true, []];
  9141. }
  9142. const logger = createQueuedLogger();
  9143. const blockType = normalizeBlockType(blockTypeOrName);
  9144. let generatedBlockContent;
  9145. try {
  9146. generatedBlockContent = getSaveContent(blockType, block.attributes);
  9147. } catch (error) {
  9148. logger.error('Block validation failed because an error occurred while generating block content:\n\n%s', error.toString());
  9149. return [false, logger.getItems()];
  9150. }
  9151. const isValid = isEquivalentHTML(block.originalContent, generatedBlockContent, logger);
  9152. if (!isValid) {
  9153. logger.error('Block validation failed for `%s` (%o).\n\nContent generated by `save` function:\n\n%s\n\nContent retrieved from post body:\n\n%s', blockType.name, blockType, generatedBlockContent, block.originalContent);
  9154. }
  9155. return [isValid, logger.getItems()];
  9156. }
  9157. /**
  9158. * Returns true if the parsed block is valid given the input content. A block
  9159. * is considered valid if, when serialized with assumed attributes, the content
  9160. * matches the original value.
  9161. *
  9162. * Logs to console in development environments when invalid.
  9163. *
  9164. * @deprecated Use validateBlock instead to avoid data loss.
  9165. *
  9166. * @param {string|Object} blockTypeOrName Block type.
  9167. * @param {Object} attributes Parsed block attributes.
  9168. * @param {string} originalBlockContent Original block content.
  9169. *
  9170. * @return {boolean} Whether block is valid.
  9171. */
  9172. function isValidBlockContent(blockTypeOrName, attributes, originalBlockContent) {
  9173. external_wp_deprecated_default()('isValidBlockContent introduces opportunity for data loss', {
  9174. since: '12.6',
  9175. plugin: 'Gutenberg',
  9176. alternative: 'validateBlock'
  9177. });
  9178. const blockType = normalizeBlockType(blockTypeOrName);
  9179. const block = {
  9180. name: blockType.name,
  9181. attributes,
  9182. innerBlocks: [],
  9183. originalContent: originalBlockContent
  9184. };
  9185. const [isValid] = validateBlock(block, blockType);
  9186. return isValid;
  9187. }
  9188. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/convert-legacy-block.js
  9189. /**
  9190. * Convert legacy blocks to their canonical form. This function is used
  9191. * both in the parser level for previous content and to convert such blocks
  9192. * used in Custom Post Types templates.
  9193. *
  9194. * @param {string} name The block's name
  9195. * @param {Object} attributes The block's attributes
  9196. *
  9197. * @return {[string, Object]} The block's name and attributes, changed accordingly if a match was found
  9198. */
  9199. function convertLegacyBlockNameAndAttributes(name, attributes) {
  9200. const newAttributes = { ...attributes
  9201. }; // Convert 'core/cover-image' block in existing content to 'core/cover'.
  9202. if ('core/cover-image' === name) {
  9203. name = 'core/cover';
  9204. } // Convert 'core/text' blocks in existing content to 'core/paragraph'.
  9205. if ('core/text' === name || 'core/cover-text' === name) {
  9206. name = 'core/paragraph';
  9207. } // Convert derivative blocks such as 'core/social-link-wordpress' to the
  9208. // canonical form 'core/social-link'.
  9209. if (name && name.indexOf('core/social-link-') === 0) {
  9210. // Capture `social-link-wordpress` into `{"service":"wordpress"}`
  9211. newAttributes.service = name.substring(17);
  9212. name = 'core/social-link';
  9213. } // Convert derivative blocks such as 'core-embed/instagram' to the
  9214. // canonical form 'core/embed'.
  9215. if (name && name.indexOf('core-embed/') === 0) {
  9216. // Capture `core-embed/instagram` into `{"providerNameSlug":"instagram"}`
  9217. const providerSlug = name.substring(11);
  9218. const deprecated = {
  9219. speaker: 'speaker-deck',
  9220. polldaddy: 'crowdsignal'
  9221. };
  9222. newAttributes.providerNameSlug = providerSlug in deprecated ? deprecated[providerSlug] : providerSlug; // This is needed as the `responsive` attribute was passed
  9223. // in a different way before the refactoring to block variations.
  9224. if (!['amazon-kindle', 'wordpress'].includes(providerSlug)) {
  9225. newAttributes.responsive = true;
  9226. }
  9227. name = 'core/embed';
  9228. } // Convert 'core/query-loop' blocks in existing content to 'core/post-template'.
  9229. // TODO: Remove this check when WordPress 5.9 is released.
  9230. if (name === 'core/query-loop') {
  9231. name = 'core/post-template';
  9232. } // Convert Post Comment blocks in existing content to Comment blocks.
  9233. // TODO: Remove these checks when WordPress 6.0 is released.
  9234. if (name === 'core/post-comment-author') {
  9235. name = 'core/comment-author-name';
  9236. }
  9237. if (name === 'core/post-comment-content') {
  9238. name = 'core/comment-content';
  9239. }
  9240. if (name === 'core/post-comment-date') {
  9241. name = 'core/comment-date';
  9242. }
  9243. return [name, newAttributes];
  9244. }
  9245. ;// CONCATENATED MODULE: ./node_modules/hpq/es/get-path.js
  9246. /**
  9247. * Given object and string of dot-delimited path segments, returns value at
  9248. * path or undefined if path cannot be resolved.
  9249. *
  9250. * @param {Object} object Lookup object
  9251. * @param {string} path Path to resolve
  9252. * @return {?*} Resolved value
  9253. */
  9254. function getPath(object, path) {
  9255. var segments = path.split('.');
  9256. var segment;
  9257. while (segment = segments.shift()) {
  9258. if (!(segment in object)) {
  9259. return;
  9260. }
  9261. object = object[segment];
  9262. }
  9263. return object;
  9264. }
  9265. ;// CONCATENATED MODULE: ./node_modules/hpq/es/index.js
  9266. /**
  9267. * Internal dependencies
  9268. */
  9269. /**
  9270. * Function returning a DOM document created by `createHTMLDocument`. The same
  9271. * document is returned between invocations.
  9272. *
  9273. * @return {Document} DOM document.
  9274. */
  9275. var getDocument = function () {
  9276. var doc;
  9277. return function () {
  9278. if (!doc) {
  9279. doc = document.implementation.createHTMLDocument('');
  9280. }
  9281. return doc;
  9282. };
  9283. }();
  9284. /**
  9285. * Given a markup string or DOM element, creates an object aligning with the
  9286. * shape of the matchers object, or the value returned by the matcher.
  9287. *
  9288. * @param {(string|Element)} source Source content
  9289. * @param {(Object|Function)} matchers Matcher function or object of matchers
  9290. * @return {(Object|*)} Matched value(s), shaped by object
  9291. */
  9292. function parse(source, matchers) {
  9293. if (!matchers) {
  9294. return;
  9295. } // Coerce to element
  9296. if ('string' === typeof source) {
  9297. var doc = getDocument();
  9298. doc.body.innerHTML = source;
  9299. source = doc.body;
  9300. } // Return singular value
  9301. if ('function' === typeof matchers) {
  9302. return matchers(source);
  9303. } // Bail if we can't handle matchers
  9304. if (Object !== matchers.constructor) {
  9305. return;
  9306. } // Shape result by matcher object
  9307. return Object.keys(matchers).reduce(function (memo, key) {
  9308. memo[key] = parse(source, matchers[key]);
  9309. return memo;
  9310. }, {});
  9311. }
  9312. /**
  9313. * Generates a function which matches node of type selector, returning an
  9314. * attribute by property if the attribute exists. If no selector is passed,
  9315. * returns property of the query element.
  9316. *
  9317. * @param {?string} selector Optional selector
  9318. * @param {string} name Property name
  9319. * @return {*} Property value
  9320. */
  9321. function prop(selector, name) {
  9322. if (1 === arguments.length) {
  9323. name = selector;
  9324. selector = undefined;
  9325. }
  9326. return function (node) {
  9327. var match = node;
  9328. if (selector) {
  9329. match = node.querySelector(selector);
  9330. }
  9331. if (match) {
  9332. return getPath(match, name);
  9333. }
  9334. };
  9335. }
  9336. /**
  9337. * Generates a function which matches node of type selector, returning an
  9338. * attribute by name if the attribute exists. If no selector is passed,
  9339. * returns attribute of the query element.
  9340. *
  9341. * @param {?string} selector Optional selector
  9342. * @param {string} name Attribute name
  9343. * @return {?string} Attribute value
  9344. */
  9345. function attr(selector, name) {
  9346. if (1 === arguments.length) {
  9347. name = selector;
  9348. selector = undefined;
  9349. }
  9350. return function (node) {
  9351. var attributes = prop(selector, 'attributes')(node);
  9352. if (attributes && attributes.hasOwnProperty(name)) {
  9353. return attributes[name].value;
  9354. }
  9355. };
  9356. }
  9357. /**
  9358. * Convenience for `prop( selector, 'innerHTML' )`.
  9359. *
  9360. * @see prop()
  9361. *
  9362. * @param {?string} selector Optional selector
  9363. * @return {string} Inner HTML
  9364. */
  9365. function html(selector) {
  9366. return prop(selector, 'innerHTML');
  9367. }
  9368. /**
  9369. * Convenience for `prop( selector, 'textContent' )`.
  9370. *
  9371. * @see prop()
  9372. *
  9373. * @param {?string} selector Optional selector
  9374. * @return {string} Text content
  9375. */
  9376. function es_text(selector) {
  9377. return prop(selector, 'textContent');
  9378. }
  9379. /**
  9380. * Creates a new matching context by first finding elements matching selector
  9381. * using querySelectorAll before then running another `parse` on `matchers`
  9382. * scoped to the matched elements.
  9383. *
  9384. * @see parse()
  9385. *
  9386. * @param {string} selector Selector to match
  9387. * @param {(Object|Function)} matchers Matcher function or object of matchers
  9388. * @return {Array.<*,Object>} Array of matched value(s)
  9389. */
  9390. function query(selector, matchers) {
  9391. return function (node) {
  9392. var matches = node.querySelectorAll(selector);
  9393. return [].map.call(matches, function (match) {
  9394. return parse(match, matchers);
  9395. });
  9396. };
  9397. }
  9398. // EXTERNAL MODULE: ./node_modules/memize/index.js
  9399. var memize = __webpack_require__(9756);
  9400. var memize_default = /*#__PURE__*/__webpack_require__.n(memize);
  9401. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/matchers.js
  9402. /**
  9403. * External dependencies
  9404. */
  9405. /**
  9406. * Internal dependencies
  9407. */
  9408. function matchers_html(selector, multilineTag) {
  9409. return domNode => {
  9410. let match = domNode;
  9411. if (selector) {
  9412. match = domNode.querySelector(selector);
  9413. }
  9414. if (!match) {
  9415. return '';
  9416. }
  9417. if (multilineTag) {
  9418. let value = '';
  9419. const length = match.children.length;
  9420. for (let index = 0; index < length; index++) {
  9421. const child = match.children[index];
  9422. if (child.nodeName.toLowerCase() !== multilineTag) {
  9423. continue;
  9424. }
  9425. value += child.outerHTML;
  9426. }
  9427. return value;
  9428. }
  9429. return match.innerHTML;
  9430. };
  9431. }
  9432. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/node.js
  9433. /**
  9434. * Internal dependencies
  9435. */
  9436. /**
  9437. * A representation of a single node within a block's rich text value. If
  9438. * representing a text node, the value is simply a string of the node value.
  9439. * As representing an element node, it is an object of:
  9440. *
  9441. * 1. `type` (string): Tag name.
  9442. * 2. `props` (object): Attributes and children array of WPBlockNode.
  9443. *
  9444. * @typedef {string|Object} WPBlockNode
  9445. */
  9446. /**
  9447. * Given a single node and a node type (e.g. `'br'`), returns true if the node
  9448. * corresponds to that type, false otherwise.
  9449. *
  9450. * @param {WPBlockNode} node Block node to test
  9451. * @param {string} type Node to type to test against.
  9452. *
  9453. * @return {boolean} Whether node is of intended type.
  9454. */
  9455. function isNodeOfType(node, type) {
  9456. return node && node.type === type;
  9457. }
  9458. /**
  9459. * Given an object implementing the NamedNodeMap interface, returns a plain
  9460. * object equivalent value of name, value key-value pairs.
  9461. *
  9462. * @see https://dom.spec.whatwg.org/#interface-namednodemap
  9463. *
  9464. * @param {NamedNodeMap} nodeMap NamedNodeMap to convert to object.
  9465. *
  9466. * @return {Object} Object equivalent value of NamedNodeMap.
  9467. */
  9468. function getNamedNodeMapAsObject(nodeMap) {
  9469. const result = {};
  9470. for (let i = 0; i < nodeMap.length; i++) {
  9471. const {
  9472. name,
  9473. value
  9474. } = nodeMap[i];
  9475. result[name] = value;
  9476. }
  9477. return result;
  9478. }
  9479. /**
  9480. * Given a DOM Element or Text node, returns an equivalent block node. Throws
  9481. * if passed any node type other than element or text.
  9482. *
  9483. * @throws {TypeError} If non-element/text node is passed.
  9484. *
  9485. * @param {Node} domNode DOM node to convert.
  9486. *
  9487. * @return {WPBlockNode} Block node equivalent to DOM node.
  9488. */
  9489. function fromDOM(domNode) {
  9490. if (domNode.nodeType === domNode.TEXT_NODE) {
  9491. return domNode.nodeValue;
  9492. }
  9493. if (domNode.nodeType !== domNode.ELEMENT_NODE) {
  9494. throw new TypeError('A block node can only be created from a node of type text or ' + 'element.');
  9495. }
  9496. return {
  9497. type: domNode.nodeName.toLowerCase(),
  9498. props: { ...getNamedNodeMapAsObject(domNode.attributes),
  9499. children: children_fromDOM(domNode.childNodes)
  9500. }
  9501. };
  9502. }
  9503. /**
  9504. * Given a block node, returns its HTML string representation.
  9505. *
  9506. * @param {WPBlockNode} node Block node to convert to string.
  9507. *
  9508. * @return {string} String HTML representation of block node.
  9509. */
  9510. function toHTML(node) {
  9511. return children_toHTML([node]);
  9512. }
  9513. /**
  9514. * Given a selector, returns an hpq matcher generating a WPBlockNode value
  9515. * matching the selector result.
  9516. *
  9517. * @param {string} selector DOM selector.
  9518. *
  9519. * @return {Function} hpq matcher.
  9520. */
  9521. function node_matcher(selector) {
  9522. return domNode => {
  9523. let match = domNode;
  9524. if (selector) {
  9525. match = domNode.querySelector(selector);
  9526. }
  9527. try {
  9528. return fromDOM(match);
  9529. } catch (error) {
  9530. return null;
  9531. }
  9532. };
  9533. }
  9534. /**
  9535. * Object of utility functions used in managing block attribute values of
  9536. * source `node`.
  9537. *
  9538. * @see https://github.com/WordPress/gutenberg/pull/10439
  9539. *
  9540. * @deprecated since 4.0. The `node` source should not be used, and can be
  9541. * replaced by the `html` source.
  9542. *
  9543. * @private
  9544. */
  9545. /* harmony default export */ var node = ({
  9546. isNodeOfType,
  9547. fromDOM,
  9548. toHTML,
  9549. matcher: node_matcher
  9550. });
  9551. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/children.js
  9552. /**
  9553. * External dependencies
  9554. */
  9555. /**
  9556. * WordPress dependencies
  9557. */
  9558. /**
  9559. * Internal dependencies
  9560. */
  9561. /**
  9562. * A representation of a block's rich text value.
  9563. *
  9564. * @typedef {WPBlockNode[]} WPBlockChildren
  9565. */
  9566. /**
  9567. * Given block children, returns a serialize-capable WordPress element.
  9568. *
  9569. * @param {WPBlockChildren} children Block children object to convert.
  9570. *
  9571. * @return {WPElement} A serialize-capable element.
  9572. */
  9573. function getSerializeCapableElement(children) {
  9574. // The fact that block children are compatible with the element serializer is
  9575. // merely an implementation detail that currently serves to be true, but
  9576. // should not be mistaken as being a guarantee on the external API. The
  9577. // public API only offers guarantees to work with strings (toHTML) and DOM
  9578. // elements (fromDOM), and should provide utilities to manipulate the value
  9579. // rather than expect consumers to inspect or construct its shape (concat).
  9580. return children;
  9581. }
  9582. /**
  9583. * Given block children, returns an array of block nodes.
  9584. *
  9585. * @param {WPBlockChildren} children Block children object to convert.
  9586. *
  9587. * @return {Array<WPBlockNode>} An array of individual block nodes.
  9588. */
  9589. function getChildrenArray(children) {
  9590. // The fact that block children are compatible with the element serializer
  9591. // is merely an implementation detail that currently serves to be true, but
  9592. // should not be mistaken as being a guarantee on the external API.
  9593. return children;
  9594. }
  9595. /**
  9596. * Given two or more block nodes, returns a new block node representing a
  9597. * concatenation of its values.
  9598. *
  9599. * @param {...WPBlockChildren} blockNodes Block nodes to concatenate.
  9600. *
  9601. * @return {WPBlockChildren} Concatenated block node.
  9602. */
  9603. function concat() {
  9604. const result = [];
  9605. for (let i = 0; i < arguments.length; i++) {
  9606. const blockNode = (0,external_lodash_namespaceObject.castArray)(i < 0 || arguments.length <= i ? undefined : arguments[i]);
  9607. for (let j = 0; j < blockNode.length; j++) {
  9608. const child = blockNode[j];
  9609. const canConcatToPreviousString = typeof child === 'string' && typeof result[result.length - 1] === 'string';
  9610. if (canConcatToPreviousString) {
  9611. result[result.length - 1] += child;
  9612. } else {
  9613. result.push(child);
  9614. }
  9615. }
  9616. }
  9617. return result;
  9618. }
  9619. /**
  9620. * Given an iterable set of DOM nodes, returns equivalent block children.
  9621. * Ignores any non-element/text nodes included in set.
  9622. *
  9623. * @param {Iterable.<Node>} domNodes Iterable set of DOM nodes to convert.
  9624. *
  9625. * @return {WPBlockChildren} Block children equivalent to DOM nodes.
  9626. */
  9627. function children_fromDOM(domNodes) {
  9628. const result = [];
  9629. for (let i = 0; i < domNodes.length; i++) {
  9630. try {
  9631. result.push(fromDOM(domNodes[i]));
  9632. } catch (error) {// Simply ignore if DOM node could not be converted.
  9633. }
  9634. }
  9635. return result;
  9636. }
  9637. /**
  9638. * Given a block node, returns its HTML string representation.
  9639. *
  9640. * @param {WPBlockChildren} children Block node(s) to convert to string.
  9641. *
  9642. * @return {string} String HTML representation of block node.
  9643. */
  9644. function children_toHTML(children) {
  9645. const element = getSerializeCapableElement(children);
  9646. return (0,external_wp_element_namespaceObject.renderToString)(element);
  9647. }
  9648. /**
  9649. * Given a selector, returns an hpq matcher generating a WPBlockChildren value
  9650. * matching the selector result.
  9651. *
  9652. * @param {string} selector DOM selector.
  9653. *
  9654. * @return {Function} hpq matcher.
  9655. */
  9656. function children_matcher(selector) {
  9657. return domNode => {
  9658. let match = domNode;
  9659. if (selector) {
  9660. match = domNode.querySelector(selector);
  9661. }
  9662. if (match) {
  9663. return children_fromDOM(match.childNodes);
  9664. }
  9665. return [];
  9666. };
  9667. }
  9668. /**
  9669. * Object of utility functions used in managing block attribute values of
  9670. * source `children`.
  9671. *
  9672. * @see https://github.com/WordPress/gutenberg/pull/10439
  9673. *
  9674. * @deprecated since 4.0. The `children` source should not be used, and can be
  9675. * replaced by the `html` source.
  9676. *
  9677. * @private
  9678. */
  9679. /* harmony default export */ var children = ({
  9680. concat,
  9681. getChildrenArray,
  9682. fromDOM: children_fromDOM,
  9683. toHTML: children_toHTML,
  9684. matcher: children_matcher
  9685. });
  9686. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/get-block-attributes.js
  9687. /**
  9688. * External dependencies
  9689. */
  9690. /**
  9691. * WordPress dependencies
  9692. */
  9693. /**
  9694. * Internal dependencies
  9695. */
  9696. /**
  9697. * Higher-order hpq matcher which enhances an attribute matcher to return true
  9698. * or false depending on whether the original matcher returns undefined. This
  9699. * is useful for boolean attributes (e.g. disabled) whose attribute values may
  9700. * be technically falsey (empty string), though their mere presence should be
  9701. * enough to infer as true.
  9702. *
  9703. * @param {Function} matcher Original hpq matcher.
  9704. *
  9705. * @return {Function} Enhanced hpq matcher.
  9706. */
  9707. const toBooleanAttributeMatcher = matcher => (0,external_lodash_namespaceObject.flow)([matcher, // Expected values from `attr( 'disabled' )`:
  9708. //
  9709. // <input>
  9710. // - Value: `undefined`
  9711. // - Transformed: `false`
  9712. //
  9713. // <input disabled>
  9714. // - Value: `''`
  9715. // - Transformed: `true`
  9716. //
  9717. // <input disabled="disabled">
  9718. // - Value: `'disabled'`
  9719. // - Transformed: `true`
  9720. value => value !== undefined]);
  9721. /**
  9722. * Returns true if value is of the given JSON schema type, or false otherwise.
  9723. *
  9724. * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25
  9725. *
  9726. * @param {*} value Value to test.
  9727. * @param {string} type Type to test.
  9728. *
  9729. * @return {boolean} Whether value is of type.
  9730. */
  9731. function isOfType(value, type) {
  9732. switch (type) {
  9733. case 'string':
  9734. return typeof value === 'string';
  9735. case 'boolean':
  9736. return typeof value === 'boolean';
  9737. case 'object':
  9738. return !!value && value.constructor === Object;
  9739. case 'null':
  9740. return value === null;
  9741. case 'array':
  9742. return Array.isArray(value);
  9743. case 'integer':
  9744. case 'number':
  9745. return typeof value === 'number';
  9746. }
  9747. return true;
  9748. }
  9749. /**
  9750. * Returns true if value is of an array of given JSON schema types, or false
  9751. * otherwise.
  9752. *
  9753. * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25
  9754. *
  9755. * @param {*} value Value to test.
  9756. * @param {string[]} types Types to test.
  9757. *
  9758. * @return {boolean} Whether value is of types.
  9759. */
  9760. function isOfTypes(value, types) {
  9761. return types.some(type => isOfType(value, type));
  9762. }
  9763. /**
  9764. * Given an attribute key, an attribute's schema, a block's raw content and the
  9765. * commentAttributes returns the attribute value depending on its source
  9766. * definition of the given attribute key.
  9767. *
  9768. * @param {string} attributeKey Attribute key.
  9769. * @param {Object} attributeSchema Attribute's schema.
  9770. * @param {string|Node} innerHTML Block's raw content.
  9771. * @param {Object} commentAttributes Block's comment attributes.
  9772. *
  9773. * @return {*} Attribute value.
  9774. */
  9775. function getBlockAttribute(attributeKey, attributeSchema, innerHTML, commentAttributes) {
  9776. let value;
  9777. switch (attributeSchema.source) {
  9778. // An undefined source means that it's an attribute serialized to the
  9779. // block's "comment".
  9780. case undefined:
  9781. value = commentAttributes ? commentAttributes[attributeKey] : undefined;
  9782. break;
  9783. case 'attribute':
  9784. case 'property':
  9785. case 'html':
  9786. case 'text':
  9787. case 'children':
  9788. case 'node':
  9789. case 'query':
  9790. case 'tag':
  9791. value = parseWithAttributeSchema(innerHTML, attributeSchema);
  9792. break;
  9793. }
  9794. if (!isValidByType(value, attributeSchema.type) || !isValidByEnum(value, attributeSchema.enum)) {
  9795. // Reject the value if it is not valid. Reverting to the undefined
  9796. // value ensures the default is respected, if applicable.
  9797. value = undefined;
  9798. }
  9799. if (value === undefined) {
  9800. value = attributeSchema.default;
  9801. }
  9802. return value;
  9803. }
  9804. /**
  9805. * Returns true if value is valid per the given block attribute schema type
  9806. * definition, or false otherwise.
  9807. *
  9808. * @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.1
  9809. *
  9810. * @param {*} value Value to test.
  9811. * @param {?(Array<string>|string)} type Block attribute schema type.
  9812. *
  9813. * @return {boolean} Whether value is valid.
  9814. */
  9815. function isValidByType(value, type) {
  9816. return type === undefined || isOfTypes(value, (0,external_lodash_namespaceObject.castArray)(type));
  9817. }
  9818. /**
  9819. * Returns true if value is valid per the given block attribute schema enum
  9820. * definition, or false otherwise.
  9821. *
  9822. * @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.2
  9823. *
  9824. * @param {*} value Value to test.
  9825. * @param {?Array} enumSet Block attribute schema enum.
  9826. *
  9827. * @return {boolean} Whether value is valid.
  9828. */
  9829. function isValidByEnum(value, enumSet) {
  9830. return !Array.isArray(enumSet) || enumSet.includes(value);
  9831. }
  9832. /**
  9833. * Returns an hpq matcher given a source object.
  9834. *
  9835. * @param {Object} sourceConfig Attribute Source object.
  9836. *
  9837. * @return {Function} A hpq Matcher.
  9838. */
  9839. const matcherFromSource = memize_default()(sourceConfig => {
  9840. switch (sourceConfig.source) {
  9841. case 'attribute':
  9842. let matcher = attr(sourceConfig.selector, sourceConfig.attribute);
  9843. if (sourceConfig.type === 'boolean') {
  9844. matcher = toBooleanAttributeMatcher(matcher);
  9845. }
  9846. return matcher;
  9847. case 'html':
  9848. return matchers_html(sourceConfig.selector, sourceConfig.multiline);
  9849. case 'text':
  9850. return es_text(sourceConfig.selector);
  9851. case 'children':
  9852. return children_matcher(sourceConfig.selector);
  9853. case 'node':
  9854. return node_matcher(sourceConfig.selector);
  9855. case 'query':
  9856. const subMatchers = (0,external_lodash_namespaceObject.mapValues)(sourceConfig.query, matcherFromSource);
  9857. return query(sourceConfig.selector, subMatchers);
  9858. case 'tag':
  9859. return (0,external_lodash_namespaceObject.flow)([prop(sourceConfig.selector, 'nodeName'), nodeName => nodeName ? nodeName.toLowerCase() : undefined]);
  9860. default:
  9861. // eslint-disable-next-line no-console
  9862. console.error(`Unknown source type "${sourceConfig.source}"`);
  9863. }
  9864. });
  9865. /**
  9866. * Parse a HTML string into DOM tree.
  9867. *
  9868. * @param {string|Node} innerHTML HTML string or already parsed DOM node.
  9869. *
  9870. * @return {Node} Parsed DOM node.
  9871. */
  9872. function parseHtml(innerHTML) {
  9873. return parse(innerHTML, h => h);
  9874. }
  9875. /**
  9876. * Given a block's raw content and an attribute's schema returns the attribute's
  9877. * value depending on its source.
  9878. *
  9879. * @param {string|Node} innerHTML Block's raw content.
  9880. * @param {Object} attributeSchema Attribute's schema.
  9881. *
  9882. * @return {*} Attribute value.
  9883. */
  9884. function parseWithAttributeSchema(innerHTML, attributeSchema) {
  9885. return matcherFromSource(attributeSchema)(parseHtml(innerHTML));
  9886. }
  9887. /**
  9888. * Returns the block attributes of a registered block node given its type.
  9889. *
  9890. * @param {string|Object} blockTypeOrName Block type or name.
  9891. * @param {string|Node} innerHTML Raw block content.
  9892. * @param {?Object} attributes Known block attributes (from delimiters).
  9893. *
  9894. * @return {Object} All block attributes.
  9895. */
  9896. function getBlockAttributes(blockTypeOrName, innerHTML) {
  9897. let attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  9898. const doc = parseHtml(innerHTML);
  9899. const blockType = normalizeBlockType(blockTypeOrName);
  9900. const blockAttributes = (0,external_lodash_namespaceObject.mapValues)(blockType.attributes, (schema, key) => getBlockAttribute(key, schema, doc, attributes));
  9901. return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockAttributes', blockAttributes, blockType, innerHTML, attributes);
  9902. }
  9903. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/fix-custom-classname.js
  9904. /**
  9905. * External dependencies
  9906. */
  9907. /**
  9908. * Internal dependencies
  9909. */
  9910. const CLASS_ATTR_SCHEMA = {
  9911. type: 'string',
  9912. source: 'attribute',
  9913. selector: '[data-custom-class-name] > *',
  9914. attribute: 'class'
  9915. };
  9916. /**
  9917. * Given an HTML string, returns an array of class names assigned to the root
  9918. * element in the markup.
  9919. *
  9920. * @param {string} innerHTML Markup string from which to extract classes.
  9921. *
  9922. * @return {string[]} Array of class names assigned to the root element.
  9923. */
  9924. function getHTMLRootElementClasses(innerHTML) {
  9925. const parsed = parseWithAttributeSchema(`<div data-custom-class-name>${innerHTML}</div>`, CLASS_ATTR_SCHEMA);
  9926. return parsed ? parsed.trim().split(/\s+/) : [];
  9927. }
  9928. /**
  9929. * Given a parsed set of block attributes, if the block supports custom class
  9930. * names and an unknown class (per the block's serialization behavior) is
  9931. * found, the unknown classes are treated as custom classes. This prevents the
  9932. * block from being considered as invalid.
  9933. *
  9934. * @param {Object} blockAttributes Original block attributes.
  9935. * @param {Object} blockType Block type settings.
  9936. * @param {string} innerHTML Original block markup.
  9937. *
  9938. * @return {Object} Filtered block attributes.
  9939. */
  9940. function fixCustomClassname(blockAttributes, blockType, innerHTML) {
  9941. if (registration_hasBlockSupport(blockType, 'customClassName', true)) {
  9942. // To determine difference, serialize block given the known set of
  9943. // attributes, with the exception of `className`. This will determine
  9944. // the default set of classes. From there, any difference in innerHTML
  9945. // can be considered as custom classes.
  9946. const attributesSansClassName = (0,external_lodash_namespaceObject.omit)(blockAttributes, ['className']);
  9947. const serialized = getSaveContent(blockType, attributesSansClassName);
  9948. const defaultClasses = getHTMLRootElementClasses(serialized);
  9949. const actualClasses = getHTMLRootElementClasses(innerHTML);
  9950. const customClasses = (0,external_lodash_namespaceObject.difference)(actualClasses, defaultClasses);
  9951. if (customClasses.length) {
  9952. blockAttributes.className = customClasses.join(' ');
  9953. } else if (serialized) {
  9954. delete blockAttributes.className;
  9955. }
  9956. }
  9957. return blockAttributes;
  9958. }
  9959. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/apply-built-in-validation-fixes.js
  9960. /**
  9961. * Internal dependencies
  9962. */
  9963. /**
  9964. * Attempts to fix block invalidation by applying build-in validation fixes
  9965. * like moving all extra classNames to the className attribute.
  9966. *
  9967. * @param {WPBlock} block block object.
  9968. * @param {import('../registration').WPBlockType} blockType Block type. This is normalize not necessary and
  9969. * can be inferred from the block name,
  9970. * but it's here for performance reasons.
  9971. *
  9972. * @return {WPBlock} Fixed block object
  9973. */
  9974. function applyBuiltInValidationFixes(block, blockType) {
  9975. const updatedBlockAttributes = fixCustomClassname(block.attributes, blockType, block.originalContent);
  9976. return { ...block,
  9977. attributes: updatedBlockAttributes
  9978. };
  9979. }
  9980. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/apply-block-deprecated-versions.js
  9981. /**
  9982. * External dependencies
  9983. */
  9984. /**
  9985. * Internal dependencies
  9986. */
  9987. /**
  9988. * Given a block object, returns a new copy of the block with any applicable
  9989. * deprecated migrations applied, or the original block if it was both valid
  9990. * and no eligible migrations exist.
  9991. *
  9992. * @param {import(".").WPBlock} block Parsed and invalid block object.
  9993. * @param {import(".").WPRawBlock} rawBlock Raw block object.
  9994. * @param {import('../registration').WPBlockType} blockType Block type. This is normalize not necessary and
  9995. * can be inferred from the block name,
  9996. * but it's here for performance reasons.
  9997. *
  9998. * @return {import(".").WPBlock} Migrated block object.
  9999. */
  10000. function applyBlockDeprecatedVersions(block, rawBlock, blockType) {
  10001. const parsedAttributes = rawBlock.attrs;
  10002. const {
  10003. deprecated: deprecatedDefinitions
  10004. } = blockType; // Bail early if there are no registered deprecations to be handled.
  10005. if (!deprecatedDefinitions || !deprecatedDefinitions.length) {
  10006. return block;
  10007. } // By design, blocks lack any sort of version tracking. Instead, to process
  10008. // outdated content the system operates a queue out of all the defined
  10009. // attribute shapes and tries each definition until the input produces a
  10010. // valid result. This mechanism seeks to avoid polluting the user-space with
  10011. // machine-specific code. An invalid block is thus a block that could not be
  10012. // matched successfully with any of the registered deprecation definitions.
  10013. for (let i = 0; i < deprecatedDefinitions.length; i++) {
  10014. // A block can opt into a migration even if the block is valid by
  10015. // defining `isEligible` on its deprecation. If the block is both valid
  10016. // and does not opt to migrate, skip.
  10017. const {
  10018. isEligible = external_lodash_namespaceObject.stubFalse
  10019. } = deprecatedDefinitions[i];
  10020. if (block.isValid && !isEligible(parsedAttributes, block.innerBlocks)) {
  10021. continue;
  10022. } // Block type properties which could impact either serialization or
  10023. // parsing are not considered in the deprecated block type by default,
  10024. // and must be explicitly provided.
  10025. const deprecatedBlockType = Object.assign((0,external_lodash_namespaceObject.omit)(blockType, DEPRECATED_ENTRY_KEYS), deprecatedDefinitions[i]);
  10026. let migratedBlock = { ...block,
  10027. attributes: getBlockAttributes(deprecatedBlockType, block.originalContent, parsedAttributes)
  10028. }; // Ignore the deprecation if it produces a block which is not valid.
  10029. let [isValid] = validateBlock(migratedBlock, deprecatedBlockType); // If the migrated block is not valid initially, try the built-in fixes.
  10030. if (!isValid) {
  10031. migratedBlock = applyBuiltInValidationFixes(migratedBlock, deprecatedBlockType);
  10032. [isValid] = validateBlock(migratedBlock, deprecatedBlockType);
  10033. } // An invalid block does not imply incorrect HTML but the fact block
  10034. // source information could be lost on re-serialization.
  10035. if (!isValid) {
  10036. continue;
  10037. }
  10038. let migratedInnerBlocks = migratedBlock.innerBlocks;
  10039. let migratedAttributes = migratedBlock.attributes; // A block may provide custom behavior to assign new attributes and/or
  10040. // inner blocks.
  10041. const {
  10042. migrate
  10043. } = deprecatedBlockType;
  10044. if (migrate) {
  10045. [migratedAttributes = parsedAttributes, migratedInnerBlocks = block.innerBlocks] = (0,external_lodash_namespaceObject.castArray)(migrate(migratedAttributes, block.innerBlocks));
  10046. }
  10047. block = { ...block,
  10048. attributes: migratedAttributes,
  10049. innerBlocks: migratedInnerBlocks,
  10050. isValid: true,
  10051. validationIssues: []
  10052. };
  10053. }
  10054. return block;
  10055. }
  10056. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/index.js
  10057. /**
  10058. * WordPress dependencies
  10059. */
  10060. /**
  10061. * Internal dependencies
  10062. */
  10063. /**
  10064. * The raw structure of a block includes its attributes, inner
  10065. * blocks, and inner HTML. It is important to distinguish inner blocks from
  10066. * the HTML content of the block as only the latter is relevant for block
  10067. * validation and edit operations.
  10068. *
  10069. * @typedef WPRawBlock
  10070. *
  10071. * @property {string=} blockName Block name
  10072. * @property {Object=} attrs Block raw or comment attributes.
  10073. * @property {string} innerHTML HTML content of the block.
  10074. * @property {(string|null)[]} innerContent Content without inner blocks.
  10075. * @property {WPRawBlock[]} innerBlocks Inner Blocks.
  10076. */
  10077. /**
  10078. * Fully parsed block object.
  10079. *
  10080. * @typedef WPBlock
  10081. *
  10082. * @property {string} name Block name
  10083. * @property {Object} attributes Block raw or comment attributes.
  10084. * @property {WPBlock[]} innerBlocks Inner Blocks.
  10085. * @property {string} originalContent Original content of the block before validation fixes.
  10086. * @property {boolean} isValid Whether the block is valid.
  10087. * @property {Object[]} validationIssues Validation issues.
  10088. * @property {WPRawBlock} [__unstableBlockSource] Un-processed original copy of block if created through parser.
  10089. */
  10090. /**
  10091. * @typedef {Object} ParseOptions
  10092. * @property {boolean} __unstableSkipMigrationLogs If a block is migrated from a deprecated version, skip logging the migration details.
  10093. */
  10094. /**
  10095. * Convert legacy blocks to their canonical form. This function is used
  10096. * both in the parser level for previous content and to convert such blocks
  10097. * used in Custom Post Types templates.
  10098. *
  10099. * @param {WPRawBlock} rawBlock
  10100. *
  10101. * @return {WPRawBlock} The block's name and attributes, changed accordingly if a match was found
  10102. */
  10103. function convertLegacyBlocks(rawBlock) {
  10104. const [correctName, correctedAttributes] = convertLegacyBlockNameAndAttributes(rawBlock.blockName, rawBlock.attrs);
  10105. return { ...rawBlock,
  10106. blockName: correctName,
  10107. attrs: correctedAttributes
  10108. };
  10109. }
  10110. /**
  10111. * Normalize the raw block by applying the fallback block name if none given,
  10112. * sanitize the parsed HTML...
  10113. *
  10114. * @param {WPRawBlock} rawBlock The raw block object.
  10115. *
  10116. * @return {WPRawBlock} The normalized block object.
  10117. */
  10118. function normalizeRawBlock(rawBlock) {
  10119. const fallbackBlockName = getFreeformContentHandlerName(); // If the grammar parsing don't produce any block name, use the freeform block.
  10120. const rawBlockName = rawBlock.blockName || getFreeformContentHandlerName();
  10121. const rawAttributes = rawBlock.attrs || {};
  10122. const rawInnerBlocks = rawBlock.innerBlocks || [];
  10123. let rawInnerHTML = rawBlock.innerHTML.trim(); // Fallback content may be upgraded from classic content expecting implicit
  10124. // automatic paragraphs, so preserve them. Assumes wpautop is idempotent,
  10125. // meaning there are no negative consequences to repeated autop calls.
  10126. if (rawBlockName === fallbackBlockName) {
  10127. rawInnerHTML = (0,external_wp_autop_namespaceObject.autop)(rawInnerHTML).trim();
  10128. }
  10129. return { ...rawBlock,
  10130. blockName: rawBlockName,
  10131. attrs: rawAttributes,
  10132. innerHTML: rawInnerHTML,
  10133. innerBlocks: rawInnerBlocks
  10134. };
  10135. }
  10136. /**
  10137. * Uses the "unregistered blockType" to create a block object.
  10138. *
  10139. * @param {WPRawBlock} rawBlock block.
  10140. *
  10141. * @return {WPRawBlock} The unregistered block object.
  10142. */
  10143. function createMissingBlockType(rawBlock) {
  10144. const unregisteredFallbackBlock = getUnregisteredTypeHandlerName() || getFreeformContentHandlerName(); // Preserve undelimited content for use by the unregistered type
  10145. // handler. A block node's `innerHTML` isn't enough, as that field only
  10146. // carries the block's own HTML and not its nested blocks.
  10147. const originalUndelimitedContent = serializeRawBlock(rawBlock, {
  10148. isCommentDelimited: false
  10149. }); // Preserve full block content for use by the unregistered type
  10150. // handler, block boundaries included.
  10151. const originalContent = serializeRawBlock(rawBlock, {
  10152. isCommentDelimited: true
  10153. });
  10154. return {
  10155. blockName: unregisteredFallbackBlock,
  10156. attrs: {
  10157. originalName: rawBlock.blockName,
  10158. originalContent,
  10159. originalUndelimitedContent
  10160. },
  10161. innerHTML: rawBlock.blockName ? originalContent : rawBlock.innerHTML,
  10162. innerBlocks: rawBlock.innerBlocks,
  10163. innerContent: rawBlock.innerContent
  10164. };
  10165. }
  10166. /**
  10167. * Validates a block and wraps with validation meta.
  10168. *
  10169. * The name here is regrettable but `validateBlock` is already taken.
  10170. *
  10171. * @param {WPBlock} unvalidatedBlock
  10172. * @param {import('../registration').WPBlockType} blockType
  10173. * @return {WPBlock} validated block, with auto-fixes if initially invalid
  10174. */
  10175. function applyBlockValidation(unvalidatedBlock, blockType) {
  10176. // Attempt to validate the block.
  10177. const [isValid] = validateBlock(unvalidatedBlock, blockType);
  10178. if (isValid) {
  10179. return { ...unvalidatedBlock,
  10180. isValid,
  10181. validationIssues: []
  10182. };
  10183. } // If the block is invalid, attempt some built-in fixes
  10184. // like custom classNames handling.
  10185. const fixedBlock = applyBuiltInValidationFixes(unvalidatedBlock, blockType); // Attempt to validate the block once again after the built-in fixes.
  10186. const [isFixedValid, validationIssues] = validateBlock(unvalidatedBlock, blockType);
  10187. return { ...fixedBlock,
  10188. isValid: isFixedValid,
  10189. validationIssues
  10190. };
  10191. }
  10192. /**
  10193. * Given a raw block returned by grammar parsing, returns a fully parsed block.
  10194. *
  10195. * @param {WPRawBlock} rawBlock The raw block object.
  10196. * @param {ParseOptions} options Extra options for handling block parsing.
  10197. *
  10198. * @return {WPBlock} Fully parsed block.
  10199. */
  10200. function parseRawBlock(rawBlock, options) {
  10201. let normalizedBlock = normalizeRawBlock(rawBlock); // During the lifecycle of the project, we renamed some old blocks
  10202. // and transformed others to new blocks. To avoid breaking existing content,
  10203. // we added this function to properly parse the old content.
  10204. normalizedBlock = convertLegacyBlocks(normalizedBlock); // Try finding the type for known block name.
  10205. let blockType = registration_getBlockType(normalizedBlock.blockName); // If not blockType is found for the specified name, fallback to the "unregistedBlockType".
  10206. if (!blockType) {
  10207. normalizedBlock = createMissingBlockType(normalizedBlock);
  10208. blockType = registration_getBlockType(normalizedBlock.blockName);
  10209. } // If it's an empty freeform block or there's no blockType (no missing block handler)
  10210. // Then, just ignore the block.
  10211. // It might be a good idea to throw a warning here.
  10212. // TODO: I'm unsure about the unregisteredFallbackBlock check,
  10213. // it might ignore some dynamic unregistered third party blocks wrongly.
  10214. const isFallbackBlock = normalizedBlock.blockName === getFreeformContentHandlerName() || normalizedBlock.blockName === getUnregisteredTypeHandlerName();
  10215. if (!blockType || !normalizedBlock.innerHTML && isFallbackBlock) {
  10216. return;
  10217. } // Parse inner blocks recursively.
  10218. const parsedInnerBlocks = normalizedBlock.innerBlocks.map(innerBlock => parseRawBlock(innerBlock, options)) // See https://github.com/WordPress/gutenberg/pull/17164.
  10219. .filter(innerBlock => !!innerBlock); // Get the fully parsed block.
  10220. const parsedBlock = createBlock(normalizedBlock.blockName, getBlockAttributes(blockType, normalizedBlock.innerHTML, normalizedBlock.attrs), parsedInnerBlocks);
  10221. parsedBlock.originalContent = normalizedBlock.innerHTML;
  10222. const validatedBlock = applyBlockValidation(parsedBlock, blockType);
  10223. const {
  10224. validationIssues
  10225. } = validatedBlock; // Run the block deprecation and migrations.
  10226. // This is performed on both invalid and valid blocks because
  10227. // migration using the `migrate` functions should run even
  10228. // if the output is deemed valid.
  10229. const updatedBlock = applyBlockDeprecatedVersions(validatedBlock, normalizedBlock, blockType);
  10230. if (!updatedBlock.isValid) {
  10231. // Preserve the original unprocessed version of the block
  10232. // that we received (no fixes, no deprecations) so that
  10233. // we can save it as close to exactly the same way as
  10234. // we loaded it. This is important to avoid corruption
  10235. // and data loss caused by block implementations trying
  10236. // to process data that isn't fully recognized.
  10237. updatedBlock.__unstableBlockSource = rawBlock;
  10238. }
  10239. if (!validatedBlock.isValid && updatedBlock.isValid && !(options !== null && options !== void 0 && options.__unstableSkipMigrationLogs)) {
  10240. /* eslint-disable no-console */
  10241. console.groupCollapsed('Updated Block: %s', blockType.name);
  10242. console.info('Block successfully updated for `%s` (%o).\n\nNew content generated by `save` function:\n\n%s\n\nContent retrieved from post body:\n\n%s', blockType.name, blockType, getSaveContent(blockType, updatedBlock.attributes), updatedBlock.originalContent);
  10243. console.groupEnd();
  10244. /* eslint-enable no-console */
  10245. } else if (!validatedBlock.isValid && !updatedBlock.isValid) {
  10246. validationIssues.forEach(_ref => {
  10247. let {
  10248. log,
  10249. args
  10250. } = _ref;
  10251. return log(...args);
  10252. });
  10253. }
  10254. return updatedBlock;
  10255. }
  10256. /**
  10257. * Utilizes an optimized token-driven parser based on the Gutenberg grammar spec
  10258. * defined through a parsing expression grammar to take advantage of the regular
  10259. * cadence provided by block delimiters -- composed syntactically through HTML
  10260. * comments -- which, given a general HTML document as an input, returns a block
  10261. * list array representation.
  10262. *
  10263. * This is a recursive-descent parser that scans linearly once through the input
  10264. * document. Instead of directly recursing it utilizes a trampoline mechanism to
  10265. * prevent stack overflow. This initial pass is mainly interested in separating
  10266. * and isolating the blocks serialized in the document and manifestly not in the
  10267. * content within the blocks.
  10268. *
  10269. * @see
  10270. * https://developer.wordpress.org/block-editor/packages/packages-block-serialization-default-parser/
  10271. *
  10272. * @param {string} content The post content.
  10273. * @param {ParseOptions} options Extra options for handling block parsing.
  10274. *
  10275. * @return {Array} Block list.
  10276. */
  10277. function parser_parse(content, options) {
  10278. return (0,external_wp_blockSerializationDefaultParser_namespaceObject.parse)(content).reduce((accumulator, rawBlock) => {
  10279. const block = parseRawBlock(rawBlock, options);
  10280. if (block) {
  10281. accumulator.push(block);
  10282. }
  10283. return accumulator;
  10284. }, []);
  10285. }
  10286. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/get-raw-transforms.js
  10287. /**
  10288. * External dependencies
  10289. */
  10290. /**
  10291. * Internal dependencies
  10292. */
  10293. function getRawTransforms() {
  10294. return (0,external_lodash_namespaceObject.filter)(getBlockTransforms('from'), {
  10295. type: 'raw'
  10296. }).map(transform => {
  10297. return transform.isMatch ? transform : { ...transform,
  10298. isMatch: node => transform.selector && node.matches(transform.selector)
  10299. };
  10300. });
  10301. }
  10302. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-to-blocks.js
  10303. /**
  10304. * Internal dependencies
  10305. */
  10306. /**
  10307. * Converts HTML directly to blocks. Looks for a matching transform for each
  10308. * top-level tag. The HTML should be filtered to not have any text between
  10309. * top-level tags and formatted in a way that blocks can handle the HTML.
  10310. *
  10311. * @param {string} html HTML to convert.
  10312. *
  10313. * @return {Array} An array of blocks.
  10314. */
  10315. function htmlToBlocks(html) {
  10316. const doc = document.implementation.createHTMLDocument('');
  10317. doc.body.innerHTML = html;
  10318. return Array.from(doc.body.children).flatMap(node => {
  10319. const rawTransform = findTransform(getRawTransforms(), _ref => {
  10320. let {
  10321. isMatch
  10322. } = _ref;
  10323. return isMatch(node);
  10324. });
  10325. if (!rawTransform) {
  10326. return createBlock( // Should not be hardcoded.
  10327. 'core/html', getBlockAttributes('core/html', node.outerHTML));
  10328. }
  10329. const {
  10330. transform,
  10331. blockName
  10332. } = rawTransform;
  10333. if (transform) {
  10334. return transform(node);
  10335. }
  10336. return createBlock(blockName, getBlockAttributes(blockName, node.outerHTML));
  10337. });
  10338. }
  10339. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/normalise-blocks.js
  10340. /**
  10341. * WordPress dependencies
  10342. */
  10343. function normaliseBlocks(HTML) {
  10344. const decuDoc = document.implementation.createHTMLDocument('');
  10345. const accuDoc = document.implementation.createHTMLDocument('');
  10346. const decu = decuDoc.body;
  10347. const accu = accuDoc.body;
  10348. decu.innerHTML = HTML;
  10349. while (decu.firstChild) {
  10350. const node = decu.firstChild; // Text nodes: wrap in a paragraph, or append to previous.
  10351. if (node.nodeType === node.TEXT_NODE) {
  10352. if ((0,external_wp_dom_namespaceObject.isEmpty)(node)) {
  10353. decu.removeChild(node);
  10354. } else {
  10355. if (!accu.lastChild || accu.lastChild.nodeName !== 'P') {
  10356. accu.appendChild(accuDoc.createElement('P'));
  10357. }
  10358. accu.lastChild.appendChild(node);
  10359. } // Element nodes.
  10360. } else if (node.nodeType === node.ELEMENT_NODE) {
  10361. // BR nodes: create a new paragraph on double, or append to previous.
  10362. if (node.nodeName === 'BR') {
  10363. if (node.nextSibling && node.nextSibling.nodeName === 'BR') {
  10364. accu.appendChild(accuDoc.createElement('P'));
  10365. decu.removeChild(node.nextSibling);
  10366. } // Don't append to an empty paragraph.
  10367. if (accu.lastChild && accu.lastChild.nodeName === 'P' && accu.lastChild.hasChildNodes()) {
  10368. accu.lastChild.appendChild(node);
  10369. } else {
  10370. decu.removeChild(node);
  10371. }
  10372. } else if (node.nodeName === 'P') {
  10373. // Only append non-empty paragraph nodes.
  10374. if ((0,external_wp_dom_namespaceObject.isEmpty)(node)) {
  10375. decu.removeChild(node);
  10376. } else {
  10377. accu.appendChild(node);
  10378. }
  10379. } else if ((0,external_wp_dom_namespaceObject.isPhrasingContent)(node)) {
  10380. if (!accu.lastChild || accu.lastChild.nodeName !== 'P') {
  10381. accu.appendChild(accuDoc.createElement('P'));
  10382. }
  10383. accu.lastChild.appendChild(node);
  10384. } else {
  10385. accu.appendChild(node);
  10386. }
  10387. } else {
  10388. decu.removeChild(node);
  10389. }
  10390. }
  10391. return accu.innerHTML;
  10392. }
  10393. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/special-comment-converter.js
  10394. /**
  10395. * WordPress dependencies
  10396. */
  10397. /**
  10398. * Looks for `<!--nextpage-->` and `<!--more-->` comments, as well as the
  10399. * `<!--more Some text-->` variant and its `<!--noteaser-->` companion,
  10400. * and replaces them with a custom element representing a future block.
  10401. *
  10402. * The custom element is a way to bypass the rest of the `raw-handling`
  10403. * transforms, which would eliminate other kinds of node with which to carry
  10404. * `<!--more-->`'s data: nodes with `data` attributes, empty paragraphs, etc.
  10405. *
  10406. * The custom element is then expected to be recognized by any registered
  10407. * block's `raw` transform.
  10408. *
  10409. * @param {Node} node The node to be processed.
  10410. * @param {Document} doc The document of the node.
  10411. * @return {void}
  10412. */
  10413. function specialCommentConverter(node, doc) {
  10414. if (node.nodeType !== node.COMMENT_NODE) {
  10415. return;
  10416. }
  10417. if (node.nodeValue === 'nextpage') {
  10418. (0,external_wp_dom_namespaceObject.replace)(node, createNextpage(doc));
  10419. return;
  10420. }
  10421. if (node.nodeValue.indexOf('more') === 0) {
  10422. // Grab any custom text in the comment.
  10423. const customText = node.nodeValue.slice(4).trim();
  10424. /*
  10425. * When a `<!--more-->` comment is found, we need to look for any
  10426. * `<!--noteaser-->` sibling, but it may not be a direct sibling
  10427. * (whitespace typically lies in between)
  10428. */
  10429. let sibling = node;
  10430. let noTeaser = false;
  10431. while (sibling = sibling.nextSibling) {
  10432. if (sibling.nodeType === sibling.COMMENT_NODE && sibling.nodeValue === 'noteaser') {
  10433. noTeaser = true;
  10434. (0,external_wp_dom_namespaceObject.remove)(sibling);
  10435. break;
  10436. }
  10437. }
  10438. (0,external_wp_dom_namespaceObject.replace)(node, createMore(customText, noTeaser, doc));
  10439. }
  10440. }
  10441. function createMore(customText, noTeaser, doc) {
  10442. const node = doc.createElement('wp-block');
  10443. node.dataset.block = 'core/more';
  10444. if (customText) {
  10445. node.dataset.customText = customText;
  10446. }
  10447. if (noTeaser) {
  10448. // "Boolean" data attribute.
  10449. node.dataset.noTeaser = '';
  10450. }
  10451. return node;
  10452. }
  10453. function createNextpage(doc) {
  10454. const node = doc.createElement('wp-block');
  10455. node.dataset.block = 'core/nextpage';
  10456. return node;
  10457. }
  10458. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/list-reducer.js
  10459. /**
  10460. * WordPress dependencies
  10461. */
  10462. function isList(node) {
  10463. return node.nodeName === 'OL' || node.nodeName === 'UL';
  10464. }
  10465. function shallowTextContent(element) {
  10466. return Array.from(element.childNodes).map(_ref => {
  10467. let {
  10468. nodeValue = ''
  10469. } = _ref;
  10470. return nodeValue;
  10471. }).join('');
  10472. }
  10473. function listReducer(node) {
  10474. if (!isList(node)) {
  10475. return;
  10476. }
  10477. const list = node;
  10478. const prevElement = node.previousElementSibling; // Merge with previous list if:
  10479. // * There is a previous list of the same type.
  10480. // * There is only one list item.
  10481. if (prevElement && prevElement.nodeName === node.nodeName && list.children.length === 1) {
  10482. // Move all child nodes, including any text nodes, if any.
  10483. while (list.firstChild) {
  10484. prevElement.appendChild(list.firstChild);
  10485. }
  10486. list.parentNode.removeChild(list);
  10487. }
  10488. const parentElement = node.parentNode; // Nested list with empty parent item.
  10489. if (parentElement && parentElement.nodeName === 'LI' && parentElement.children.length === 1 && !/\S/.test(shallowTextContent(parentElement))) {
  10490. const parentListItem = parentElement;
  10491. const prevListItem = parentListItem.previousElementSibling;
  10492. const parentList = parentListItem.parentNode;
  10493. if (prevListItem) {
  10494. prevListItem.appendChild(list);
  10495. parentList.removeChild(parentListItem);
  10496. } else {
  10497. parentList.parentNode.insertBefore(list, parentList);
  10498. parentList.parentNode.removeChild(parentList);
  10499. }
  10500. } // Invalid: OL/UL > OL/UL.
  10501. if (parentElement && isList(parentElement)) {
  10502. const prevListItem = node.previousElementSibling;
  10503. if (prevListItem) {
  10504. prevListItem.appendChild(node);
  10505. } else {
  10506. (0,external_wp_dom_namespaceObject.unwrap)(node);
  10507. }
  10508. }
  10509. }
  10510. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/blockquote-normaliser.js
  10511. /**
  10512. * Internal dependencies
  10513. */
  10514. function blockquoteNormaliser(node) {
  10515. if (node.nodeName !== 'BLOCKQUOTE') {
  10516. return;
  10517. }
  10518. node.innerHTML = normaliseBlocks(node.innerHTML);
  10519. }
  10520. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/figure-content-reducer.js
  10521. /**
  10522. * External dependencies
  10523. */
  10524. /**
  10525. * WordPress dependencies
  10526. */
  10527. /**
  10528. * Whether or not the given node is figure content.
  10529. *
  10530. * @param {Node} node The node to check.
  10531. * @param {Object} schema The schema to use.
  10532. *
  10533. * @return {boolean} True if figure content, false if not.
  10534. */
  10535. function isFigureContent(node, schema) {
  10536. const tag = node.nodeName.toLowerCase(); // We are looking for tags that can be a child of the figure tag, excluding
  10537. // `figcaption` and any phrasing content.
  10538. if (tag === 'figcaption' || (0,external_wp_dom_namespaceObject.isTextContent)(node)) {
  10539. return false;
  10540. }
  10541. return (0,external_lodash_namespaceObject.has)(schema, ['figure', 'children', tag]);
  10542. }
  10543. /**
  10544. * Whether or not the given node can have an anchor.
  10545. *
  10546. * @param {Node} node The node to check.
  10547. * @param {Object} schema The schema to use.
  10548. *
  10549. * @return {boolean} True if it can, false if not.
  10550. */
  10551. function canHaveAnchor(node, schema) {
  10552. const tag = node.nodeName.toLowerCase();
  10553. return (0,external_lodash_namespaceObject.has)(schema, ['figure', 'children', 'a', 'children', tag]);
  10554. }
  10555. /**
  10556. * Wraps the given element in a figure element.
  10557. *
  10558. * @param {Element} element The element to wrap.
  10559. * @param {Element} beforeElement The element before which to place the figure.
  10560. */
  10561. function wrapFigureContent(element) {
  10562. let beforeElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : element;
  10563. const figure = element.ownerDocument.createElement('figure');
  10564. beforeElement.parentNode.insertBefore(figure, beforeElement);
  10565. figure.appendChild(element);
  10566. }
  10567. /**
  10568. * This filter takes figure content out of paragraphs, wraps it in a figure
  10569. * element, and moves any anchors with it if needed.
  10570. *
  10571. * @param {Node} node The node to filter.
  10572. * @param {Document} doc The document of the node.
  10573. * @param {Object} schema The schema to use.
  10574. *
  10575. * @return {void}
  10576. */
  10577. function figureContentReducer(node, doc, schema) {
  10578. if (!isFigureContent(node, schema)) {
  10579. return;
  10580. }
  10581. let nodeToInsert = node;
  10582. const parentNode = node.parentNode; // If the figure content can have an anchor and its parent is an anchor with
  10583. // only the figure content, take the anchor out instead of just the content.
  10584. if (canHaveAnchor(node, schema) && parentNode.nodeName === 'A' && parentNode.childNodes.length === 1) {
  10585. nodeToInsert = node.parentNode;
  10586. }
  10587. const wrapper = nodeToInsert.closest('p,div'); // If wrapped in a paragraph or div, only extract if it's aligned or if
  10588. // there is no text content.
  10589. // Otherwise, if directly at the root, wrap in a figure element.
  10590. if (wrapper) {
  10591. // In jsdom-jscore, 'node.classList' can be undefined.
  10592. // In this case, default to extract as it offers a better UI experience on mobile.
  10593. if (!node.classList) {
  10594. wrapFigureContent(nodeToInsert, wrapper);
  10595. } else if (node.classList.contains('alignright') || node.classList.contains('alignleft') || node.classList.contains('aligncenter') || !wrapper.textContent.trim()) {
  10596. wrapFigureContent(nodeToInsert, wrapper);
  10597. }
  10598. } else if (nodeToInsert.parentNode.nodeName === 'BODY') {
  10599. wrapFigureContent(nodeToInsert);
  10600. }
  10601. }
  10602. ;// CONCATENATED MODULE: external ["wp","shortcode"]
  10603. var external_wp_shortcode_namespaceObject = window["wp"]["shortcode"];
  10604. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/shortcode-converter.js
  10605. /**
  10606. * External dependencies
  10607. */
  10608. /**
  10609. * WordPress dependencies
  10610. */
  10611. /**
  10612. * Internal dependencies
  10613. */
  10614. function segmentHTMLToShortcodeBlock(HTML) {
  10615. let lastIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  10616. let excludedBlockNames = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
  10617. // Get all matches.
  10618. const transformsFrom = getBlockTransforms('from');
  10619. const transformation = findTransform(transformsFrom, transform => excludedBlockNames.indexOf(transform.blockName) === -1 && transform.type === 'shortcode' && (0,external_lodash_namespaceObject.some)((0,external_lodash_namespaceObject.castArray)(transform.tag), tag => (0,external_wp_shortcode_namespaceObject.regexp)(tag).test(HTML)));
  10620. if (!transformation) {
  10621. return [HTML];
  10622. }
  10623. const transformTags = (0,external_lodash_namespaceObject.castArray)(transformation.tag);
  10624. const transformTag = (0,external_lodash_namespaceObject.find)(transformTags, tag => (0,external_wp_shortcode_namespaceObject.regexp)(tag).test(HTML));
  10625. let match;
  10626. const previousIndex = lastIndex;
  10627. if (match = (0,external_wp_shortcode_namespaceObject.next)(transformTag, HTML, lastIndex)) {
  10628. lastIndex = match.index + match.content.length;
  10629. const beforeHTML = HTML.substr(0, match.index);
  10630. const afterHTML = HTML.substr(lastIndex); // If the shortcode content does not contain HTML and the shortcode is
  10631. // not on a new line (or in paragraph from Markdown converter),
  10632. // consider the shortcode as inline text, and thus skip conversion for
  10633. // this segment.
  10634. if (!(0,external_lodash_namespaceObject.includes)(match.shortcode.content || '', '<') && !(/(\n|<p>)\s*$/.test(beforeHTML) && /^\s*(\n|<\/p>)/.test(afterHTML))) {
  10635. return segmentHTMLToShortcodeBlock(HTML, lastIndex);
  10636. } // If a transformation's `isMatch` predicate fails for the inbound
  10637. // shortcode, try again by excluding the current block type.
  10638. //
  10639. // This is the only call to `segmentHTMLToShortcodeBlock` that should
  10640. // ever carry over `excludedBlockNames`. Other calls in the module
  10641. // should skip that argument as a way to reset the exclusion state, so
  10642. // that one `isMatch` fail in an HTML fragment doesn't prevent any
  10643. // valid matches in subsequent fragments.
  10644. if (transformation.isMatch && !transformation.isMatch(match.shortcode.attrs)) {
  10645. return segmentHTMLToShortcodeBlock(HTML, previousIndex, [...excludedBlockNames, transformation.blockName]);
  10646. }
  10647. const attributes = (0,external_lodash_namespaceObject.mapValues)((0,external_lodash_namespaceObject.pickBy)(transformation.attributes, schema => schema.shortcode), // Passing all of `match` as second argument is intentionally broad
  10648. // but shouldn't be too relied upon.
  10649. //
  10650. // See: https://github.com/WordPress/gutenberg/pull/3610#discussion_r152546926
  10651. schema => schema.shortcode(match.shortcode.attrs, match));
  10652. const transformationBlockType = { ...registration_getBlockType(transformation.blockName),
  10653. attributes: transformation.attributes
  10654. };
  10655. let block = createBlock(transformation.blockName, getBlockAttributes(transformationBlockType, match.shortcode.content, attributes));
  10656. block.originalContent = match.shortcode.content; // Applying the built-in fixes can enhance the attributes with missing content like "className".
  10657. block = applyBuiltInValidationFixes(block, transformationBlockType);
  10658. return [...segmentHTMLToShortcodeBlock(beforeHTML), block, ...segmentHTMLToShortcodeBlock(afterHTML)];
  10659. }
  10660. return [HTML];
  10661. }
  10662. /* harmony default export */ var shortcode_converter = (segmentHTMLToShortcodeBlock);
  10663. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/utils.js
  10664. /**
  10665. * External dependencies
  10666. */
  10667. /**
  10668. * WordPress dependencies
  10669. */
  10670. /**
  10671. * Internal dependencies
  10672. */
  10673. function getBlockContentSchemaFromTransforms(transforms, context) {
  10674. const phrasingContentSchema = (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)(context);
  10675. const schemaArgs = {
  10676. phrasingContentSchema,
  10677. isPaste: context === 'paste'
  10678. };
  10679. const schemas = transforms.map(_ref => {
  10680. let {
  10681. isMatch,
  10682. blockName,
  10683. schema
  10684. } = _ref;
  10685. const hasAnchorSupport = registration_hasBlockSupport(blockName, 'anchor');
  10686. schema = (0,external_lodash_namespaceObject.isFunction)(schema) ? schema(schemaArgs) : schema; // If the block does not has anchor support and the transform does not
  10687. // provides an isMatch we can return the schema right away.
  10688. if (!hasAnchorSupport && !isMatch) {
  10689. return schema;
  10690. }
  10691. return (0,external_lodash_namespaceObject.mapValues)(schema, value => {
  10692. let attributes = value.attributes || []; // If the block supports the "anchor" functionality, it needs to keep its ID attribute.
  10693. if (hasAnchorSupport) {
  10694. attributes = [...attributes, 'id'];
  10695. }
  10696. return { ...value,
  10697. attributes,
  10698. isMatch: isMatch ? isMatch : undefined
  10699. };
  10700. });
  10701. });
  10702. return (0,external_lodash_namespaceObject.mergeWith)({}, ...schemas, (objValue, srcValue, key) => {
  10703. switch (key) {
  10704. case 'children':
  10705. {
  10706. if (objValue === '*' || srcValue === '*') {
  10707. return '*';
  10708. }
  10709. return { ...objValue,
  10710. ...srcValue
  10711. };
  10712. }
  10713. case 'attributes':
  10714. case 'require':
  10715. {
  10716. return [...(objValue || []), ...(srcValue || [])];
  10717. }
  10718. case 'isMatch':
  10719. {
  10720. // If one of the values being merge is undefined (matches everything),
  10721. // the result of the merge will be undefined.
  10722. if (!objValue || !srcValue) {
  10723. return undefined;
  10724. } // When merging two isMatch functions, the result is a new function
  10725. // that returns if one of the source functions returns true.
  10726. return function () {
  10727. return objValue(...arguments) || srcValue(...arguments);
  10728. };
  10729. }
  10730. }
  10731. });
  10732. }
  10733. /**
  10734. * Gets the block content schema, which is extracted and merged from all
  10735. * registered blocks with raw transfroms.
  10736. *
  10737. * @param {string} context Set to "paste" when in paste context, where the
  10738. * schema is more strict.
  10739. *
  10740. * @return {Object} A complete block content schema.
  10741. */
  10742. function getBlockContentSchema(context) {
  10743. return getBlockContentSchemaFromTransforms(getRawTransforms(), context);
  10744. }
  10745. /**
  10746. * Checks whether HTML can be considered plain text. That is, it does not contain
  10747. * any elements that are not line breaks.
  10748. *
  10749. * @param {string} HTML The HTML to check.
  10750. *
  10751. * @return {boolean} Whether the HTML can be considered plain text.
  10752. */
  10753. function isPlain(HTML) {
  10754. return !/<(?!br[ />])/i.test(HTML);
  10755. }
  10756. /**
  10757. * Given node filters, deeply filters and mutates a NodeList.
  10758. *
  10759. * @param {NodeList} nodeList The nodeList to filter.
  10760. * @param {Array} filters An array of functions that can mutate with the provided node.
  10761. * @param {Document} doc The document of the nodeList.
  10762. * @param {Object} schema The schema to use.
  10763. */
  10764. function deepFilterNodeList(nodeList, filters, doc, schema) {
  10765. Array.from(nodeList).forEach(node => {
  10766. deepFilterNodeList(node.childNodes, filters, doc, schema);
  10767. filters.forEach(item => {
  10768. // Make sure the node is still attached to the document.
  10769. if (!doc.contains(node)) {
  10770. return;
  10771. }
  10772. item(node, doc, schema);
  10773. });
  10774. });
  10775. }
  10776. /**
  10777. * Given node filters, deeply filters HTML tags.
  10778. * Filters from the deepest nodes to the top.
  10779. *
  10780. * @param {string} HTML The HTML to filter.
  10781. * @param {Array} filters An array of functions that can mutate with the provided node.
  10782. * @param {Object} schema The schema to use.
  10783. *
  10784. * @return {string} The filtered HTML.
  10785. */
  10786. function deepFilterHTML(HTML) {
  10787. let filters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  10788. let schema = arguments.length > 2 ? arguments[2] : undefined;
  10789. const doc = document.implementation.createHTMLDocument('');
  10790. doc.body.innerHTML = HTML;
  10791. deepFilterNodeList(doc.body.childNodes, filters, doc, schema);
  10792. return doc.body.innerHTML;
  10793. }
  10794. /**
  10795. * Gets a sibling within text-level context.
  10796. *
  10797. * @param {Element} node The subject node.
  10798. * @param {string} which "next" or "previous".
  10799. */
  10800. function getSibling(node, which) {
  10801. const sibling = node[`${which}Sibling`];
  10802. if (sibling && (0,external_wp_dom_namespaceObject.isPhrasingContent)(sibling)) {
  10803. return sibling;
  10804. }
  10805. const {
  10806. parentNode
  10807. } = node;
  10808. if (!parentNode || !(0,external_wp_dom_namespaceObject.isPhrasingContent)(parentNode)) {
  10809. return;
  10810. }
  10811. return getSibling(parentNode, which);
  10812. }
  10813. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/index.js
  10814. /**
  10815. * External dependencies
  10816. */
  10817. /**
  10818. * WordPress dependencies
  10819. */
  10820. /**
  10821. * Internal dependencies
  10822. */
  10823. function deprecatedGetPhrasingContentSchema(context) {
  10824. external_wp_deprecated_default()('wp.blocks.getPhrasingContentSchema', {
  10825. since: '5.6',
  10826. alternative: 'wp.dom.getPhrasingContentSchema'
  10827. });
  10828. return (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)(context);
  10829. }
  10830. /**
  10831. * Converts an HTML string to known blocks.
  10832. *
  10833. * @param {Object} $1
  10834. * @param {string} $1.HTML The HTML to convert.
  10835. *
  10836. * @return {Array} A list of blocks.
  10837. */
  10838. function rawHandler(_ref) {
  10839. let {
  10840. HTML = ''
  10841. } = _ref;
  10842. // If we detect block delimiters, parse entirely as blocks.
  10843. if (HTML.indexOf('<!-- wp:') !== -1) {
  10844. return parser_parse(HTML);
  10845. } // An array of HTML strings and block objects. The blocks replace matched
  10846. // shortcodes.
  10847. const pieces = shortcode_converter(HTML);
  10848. const blockContentSchema = getBlockContentSchema();
  10849. return (0,external_lodash_namespaceObject.compact)((0,external_lodash_namespaceObject.flatMap)(pieces, piece => {
  10850. // Already a block from shortcode.
  10851. if (typeof piece !== 'string') {
  10852. return piece;
  10853. } // These filters are essential for some blocks to be able to transform
  10854. // from raw HTML. These filters move around some content or add
  10855. // additional tags, they do not remove any content.
  10856. const filters = [// Needed to adjust invalid lists.
  10857. listReducer, // Needed to create more and nextpage blocks.
  10858. specialCommentConverter, // Needed to create media blocks.
  10859. figureContentReducer, // Needed to create the quote block, which cannot handle text
  10860. // without wrapper paragraphs.
  10861. blockquoteNormaliser];
  10862. piece = deepFilterHTML(piece, filters, blockContentSchema);
  10863. piece = normaliseBlocks(piece);
  10864. return htmlToBlocks(piece);
  10865. }));
  10866. }
  10867. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/comment-remover.js
  10868. /**
  10869. * WordPress dependencies
  10870. */
  10871. /**
  10872. * Looks for comments, and removes them.
  10873. *
  10874. * @param {Node} node The node to be processed.
  10875. * @return {void}
  10876. */
  10877. function commentRemover(node) {
  10878. if (node.nodeType === node.COMMENT_NODE) {
  10879. (0,external_wp_dom_namespaceObject.remove)(node);
  10880. }
  10881. }
  10882. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/is-inline-content.js
  10883. /**
  10884. * External dependencies
  10885. */
  10886. /**
  10887. * WordPress dependencies
  10888. */
  10889. /**
  10890. * Checks if the given node should be considered inline content, optionally
  10891. * depending on a context tag.
  10892. *
  10893. * @param {Node} node Node name.
  10894. * @param {string} contextTag Tag name.
  10895. *
  10896. * @return {boolean} True if the node is inline content, false if nohe.
  10897. */
  10898. function isInline(node, contextTag) {
  10899. if ((0,external_wp_dom_namespaceObject.isTextContent)(node)) {
  10900. return true;
  10901. }
  10902. if (!contextTag) {
  10903. return false;
  10904. }
  10905. const tag = node.nodeName.toLowerCase();
  10906. const inlineAllowedTagGroups = [['ul', 'li', 'ol'], ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']];
  10907. return inlineAllowedTagGroups.some(tagGroup => (0,external_lodash_namespaceObject.difference)([tag, contextTag], tagGroup).length === 0);
  10908. }
  10909. function deepCheck(nodes, contextTag) {
  10910. return nodes.every(node => isInline(node, contextTag) && deepCheck(Array.from(node.children), contextTag));
  10911. }
  10912. function isDoubleBR(node) {
  10913. return node.nodeName === 'BR' && node.previousSibling && node.previousSibling.nodeName === 'BR';
  10914. }
  10915. function isInlineContent(HTML, contextTag) {
  10916. const doc = document.implementation.createHTMLDocument('');
  10917. doc.body.innerHTML = HTML;
  10918. const nodes = Array.from(doc.body.children);
  10919. return !nodes.some(isDoubleBR) && deepCheck(nodes, contextTag);
  10920. }
  10921. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/phrasing-content-reducer.js
  10922. /**
  10923. * External dependencies
  10924. */
  10925. /**
  10926. * WordPress dependencies
  10927. */
  10928. function phrasingContentReducer(node, doc) {
  10929. // In jsdom-jscore, 'node.style' can be null.
  10930. // TODO: Explore fixing this by patching jsdom-jscore.
  10931. if (node.nodeName === 'SPAN' && node.style) {
  10932. const {
  10933. fontWeight,
  10934. fontStyle,
  10935. textDecorationLine,
  10936. textDecoration,
  10937. verticalAlign
  10938. } = node.style;
  10939. if (fontWeight === 'bold' || fontWeight === '700') {
  10940. (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('strong'), node);
  10941. }
  10942. if (fontStyle === 'italic') {
  10943. (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('em'), node);
  10944. } // Some DOM implementations (Safari, JSDom) don't support
  10945. // style.textDecorationLine, so we check style.textDecoration as a
  10946. // fallback.
  10947. if (textDecorationLine === 'line-through' || (0,external_lodash_namespaceObject.includes)(textDecoration, 'line-through')) {
  10948. (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('s'), node);
  10949. }
  10950. if (verticalAlign === 'super') {
  10951. (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('sup'), node);
  10952. } else if (verticalAlign === 'sub') {
  10953. (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('sub'), node);
  10954. }
  10955. } else if (node.nodeName === 'B') {
  10956. node = (0,external_wp_dom_namespaceObject.replaceTag)(node, 'strong');
  10957. } else if (node.nodeName === 'I') {
  10958. node = (0,external_wp_dom_namespaceObject.replaceTag)(node, 'em');
  10959. } else if (node.nodeName === 'A') {
  10960. // In jsdom-jscore, 'node.target' can be null.
  10961. // TODO: Explore fixing this by patching jsdom-jscore.
  10962. if (node.target && node.target.toLowerCase() === '_blank') {
  10963. node.rel = 'noreferrer noopener';
  10964. } else {
  10965. node.removeAttribute('target');
  10966. node.removeAttribute('rel');
  10967. } // Saves anchor elements name attribute as id
  10968. if (node.name && !node.id) {
  10969. node.id = node.name;
  10970. } // Keeps id only if there is an internal link pointing to it
  10971. if (node.id && !node.ownerDocument.querySelector(`[href="#${node.id}"]`)) {
  10972. node.removeAttribute('id');
  10973. }
  10974. }
  10975. }
  10976. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/head-remover.js
  10977. function headRemover(node) {
  10978. if (node.nodeName !== 'SCRIPT' && node.nodeName !== 'NOSCRIPT' && node.nodeName !== 'TEMPLATE' && node.nodeName !== 'STYLE') {
  10979. return;
  10980. }
  10981. node.parentNode.removeChild(node);
  10982. }
  10983. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/ms-list-converter.js
  10984. /**
  10985. * Browser dependencies
  10986. */
  10987. const {
  10988. parseInt: ms_list_converter_parseInt
  10989. } = window;
  10990. function ms_list_converter_isList(node) {
  10991. return node.nodeName === 'OL' || node.nodeName === 'UL';
  10992. }
  10993. function msListConverter(node, doc) {
  10994. if (node.nodeName !== 'P') {
  10995. return;
  10996. }
  10997. const style = node.getAttribute('style');
  10998. if (!style) {
  10999. return;
  11000. } // Quick check.
  11001. if (style.indexOf('mso-list') === -1) {
  11002. return;
  11003. }
  11004. const matches = /mso-list\s*:[^;]+level([0-9]+)/i.exec(style);
  11005. if (!matches) {
  11006. return;
  11007. }
  11008. let level = ms_list_converter_parseInt(matches[1], 10) - 1 || 0;
  11009. const prevNode = node.previousElementSibling; // Add new list if no previous.
  11010. if (!prevNode || !ms_list_converter_isList(prevNode)) {
  11011. // See https://html.spec.whatwg.org/multipage/grouping-content.html#attr-ol-type.
  11012. const type = node.textContent.trim().slice(0, 1);
  11013. const isNumeric = /[1iIaA]/.test(type);
  11014. const newListNode = doc.createElement(isNumeric ? 'ol' : 'ul');
  11015. if (isNumeric) {
  11016. newListNode.setAttribute('type', type);
  11017. }
  11018. node.parentNode.insertBefore(newListNode, node);
  11019. }
  11020. const listNode = node.previousElementSibling;
  11021. const listType = listNode.nodeName;
  11022. const listItem = doc.createElement('li');
  11023. let receivingNode = listNode; // Remove the first span with list info.
  11024. node.removeChild(node.firstChild); // Add content.
  11025. while (node.firstChild) {
  11026. listItem.appendChild(node.firstChild);
  11027. } // Change pointer depending on indentation level.
  11028. while (level--) {
  11029. receivingNode = receivingNode.lastChild || receivingNode; // If it's a list, move pointer to the last item.
  11030. if (ms_list_converter_isList(receivingNode)) {
  11031. receivingNode = receivingNode.lastChild || receivingNode;
  11032. }
  11033. } // Make sure we append to a list.
  11034. if (!ms_list_converter_isList(receivingNode)) {
  11035. receivingNode = receivingNode.appendChild(doc.createElement(listType));
  11036. } // Append the list item to the list.
  11037. receivingNode.appendChild(listItem); // Remove the wrapper paragraph.
  11038. node.parentNode.removeChild(node);
  11039. }
  11040. ;// CONCATENATED MODULE: external ["wp","blob"]
  11041. var external_wp_blob_namespaceObject = window["wp"]["blob"];
  11042. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/image-corrector.js
  11043. /**
  11044. * WordPress dependencies
  11045. */
  11046. /**
  11047. * Browser dependencies
  11048. */
  11049. const {
  11050. atob,
  11051. File
  11052. } = window;
  11053. function imageCorrector(node) {
  11054. if (node.nodeName !== 'IMG') {
  11055. return;
  11056. }
  11057. if (node.src.indexOf('file:') === 0) {
  11058. node.src = '';
  11059. } // This piece cannot be tested outside a browser env.
  11060. if (node.src.indexOf('data:') === 0) {
  11061. const [properties, data] = node.src.split(',');
  11062. const [type] = properties.slice(5).split(';');
  11063. if (!data || !type) {
  11064. node.src = '';
  11065. return;
  11066. }
  11067. let decoded; // Can throw DOMException!
  11068. try {
  11069. decoded = atob(data);
  11070. } catch (e) {
  11071. node.src = '';
  11072. return;
  11073. }
  11074. const uint8Array = new Uint8Array(decoded.length);
  11075. for (let i = 0; i < uint8Array.length; i++) {
  11076. uint8Array[i] = decoded.charCodeAt(i);
  11077. }
  11078. const name = type.replace('/', '.');
  11079. const file = new File([uint8Array], name, {
  11080. type
  11081. });
  11082. node.src = (0,external_wp_blob_namespaceObject.createBlobURL)(file);
  11083. } // Remove trackers and hardly visible images.
  11084. if (node.height === 1 || node.width === 1) {
  11085. node.parentNode.removeChild(node);
  11086. }
  11087. }
  11088. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/div-normaliser.js
  11089. /**
  11090. * Internal dependencies
  11091. */
  11092. function divNormaliser(node) {
  11093. if (node.nodeName !== 'DIV') {
  11094. return;
  11095. }
  11096. node.innerHTML = normaliseBlocks(node.innerHTML);
  11097. }
  11098. // EXTERNAL MODULE: ./node_modules/showdown/dist/showdown.js
  11099. var showdown = __webpack_require__(7308);
  11100. var showdown_default = /*#__PURE__*/__webpack_require__.n(showdown);
  11101. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/markdown-converter.js
  11102. /**
  11103. * External dependencies
  11104. */
  11105. // Reuse the same showdown converter.
  11106. const converter = new (showdown_default()).Converter({
  11107. noHeaderId: true,
  11108. tables: true,
  11109. literalMidWordUnderscores: true,
  11110. omitExtraWLInCodeBlocks: true,
  11111. simpleLineBreaks: true,
  11112. strikethrough: true
  11113. });
  11114. /**
  11115. * Corrects the Slack Markdown variant of the code block.
  11116. * If uncorrected, it will be converted to inline code.
  11117. *
  11118. * @see https://get.slack.help/hc/en-us/articles/202288908-how-can-i-add-formatting-to-my-messages-#code-blocks
  11119. *
  11120. * @param {string} text The potential Markdown text to correct.
  11121. *
  11122. * @return {string} The corrected Markdown.
  11123. */
  11124. function slackMarkdownVariantCorrector(text) {
  11125. return text.replace(/((?:^|\n)```)([^\n`]+)(```(?:$|\n))/, (match, p1, p2, p3) => `${p1}\n${p2}\n${p3}`);
  11126. }
  11127. /**
  11128. * Converts a piece of text into HTML based on any Markdown present.
  11129. * Also decodes any encoded HTML.
  11130. *
  11131. * @param {string} text The plain text to convert.
  11132. *
  11133. * @return {string} HTML.
  11134. */
  11135. function markdownConverter(text) {
  11136. return converter.makeHtml(slackMarkdownVariantCorrector(text));
  11137. }
  11138. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/iframe-remover.js
  11139. /**
  11140. * Removes iframes.
  11141. *
  11142. * @param {Node} node The node to check.
  11143. *
  11144. * @return {void}
  11145. */
  11146. function iframeRemover(node) {
  11147. if (node.nodeName === 'IFRAME') {
  11148. const text = node.ownerDocument.createTextNode(node.src);
  11149. node.parentNode.replaceChild(text, node);
  11150. }
  11151. }
  11152. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/google-docs-uid-remover.js
  11153. /**
  11154. * WordPress dependencies
  11155. */
  11156. function googleDocsUIdRemover(node) {
  11157. if (!node.id || node.id.indexOf('docs-internal-guid-') !== 0) {
  11158. return;
  11159. }
  11160. (0,external_wp_dom_namespaceObject.unwrap)(node);
  11161. }
  11162. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-formatting-remover.js
  11163. /**
  11164. * Internal dependencies
  11165. */
  11166. function isFormattingSpace(character) {
  11167. return character === ' ' || character === '\r' || character === '\n' || character === '\t';
  11168. }
  11169. /**
  11170. * Removes spacing that formats HTML.
  11171. *
  11172. * @see https://www.w3.org/TR/css-text-3/#white-space-processing
  11173. *
  11174. * @param {Node} node The node to be processed.
  11175. * @return {void}
  11176. */
  11177. function htmlFormattingRemover(node) {
  11178. if (node.nodeType !== node.TEXT_NODE) {
  11179. return;
  11180. } // Ignore pre content. Note that this does not use Element#closest due to
  11181. // a combination of (a) node may not be Element and (b) node.parentElement
  11182. // does not have full support in all browsers (Internet Exporer).
  11183. //
  11184. // See: https://developer.mozilla.org/en-US/docs/Web/API/Node/parentElement#Browser_compatibility
  11185. /** @type {Node?} */
  11186. let parent = node;
  11187. while (parent = parent.parentNode) {
  11188. if (parent.nodeType === parent.ELEMENT_NODE && parent.nodeName === 'PRE') {
  11189. return;
  11190. }
  11191. } // First, replace any sequence of HTML formatting space with a single space.
  11192. let newData = node.data.replace(/[ \r\n\t]+/g, ' '); // Remove the leading space if the text element is at the start of a block,
  11193. // is preceded by a line break element, or has a space in the previous
  11194. // node.
  11195. if (newData[0] === ' ') {
  11196. const previousSibling = getSibling(node, 'previous');
  11197. if (!previousSibling || previousSibling.nodeName === 'BR' || previousSibling.textContent.slice(-1) === ' ') {
  11198. newData = newData.slice(1);
  11199. }
  11200. } // Remove the trailing space if the text element is at the end of a block,
  11201. // is succeded by a line break element, or has a space in the next text
  11202. // node.
  11203. if (newData[newData.length - 1] === ' ') {
  11204. const nextSibling = getSibling(node, 'next');
  11205. if (!nextSibling || nextSibling.nodeName === 'BR' || nextSibling.nodeType === nextSibling.TEXT_NODE && isFormattingSpace(nextSibling.textContent[0])) {
  11206. newData = newData.slice(0, -1);
  11207. }
  11208. } // If there's no data left, remove the node, so `previousSibling` stays
  11209. // accurate. Otherwise, update the node data.
  11210. if (!newData) {
  11211. node.parentNode.removeChild(node);
  11212. } else {
  11213. node.data = newData;
  11214. }
  11215. }
  11216. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/br-remover.js
  11217. /**
  11218. * Internal dependencies
  11219. */
  11220. /**
  11221. * Removes trailing br elements from text-level content.
  11222. *
  11223. * @param {Element} node Node to check.
  11224. */
  11225. function brRemover(node) {
  11226. if (node.nodeName !== 'BR') {
  11227. return;
  11228. }
  11229. if (getSibling(node, 'next')) {
  11230. return;
  11231. }
  11232. node.parentNode.removeChild(node);
  11233. }
  11234. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/empty-paragraph-remover.js
  11235. /**
  11236. * Removes empty paragraph elements.
  11237. *
  11238. * @param {Element} node Node to check.
  11239. */
  11240. function emptyParagraphRemover(node) {
  11241. if (node.nodeName !== 'P') {
  11242. return;
  11243. }
  11244. if (node.hasChildNodes()) {
  11245. return;
  11246. }
  11247. node.parentNode.removeChild(node);
  11248. }
  11249. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/paste-handler.js
  11250. /**
  11251. * External dependencies
  11252. */
  11253. /**
  11254. * WordPress dependencies
  11255. */
  11256. /**
  11257. * Internal dependencies
  11258. */
  11259. /**
  11260. * Browser dependencies
  11261. */
  11262. const {
  11263. console: paste_handler_console
  11264. } = window;
  11265. /**
  11266. * Filters HTML to only contain phrasing content.
  11267. *
  11268. * @param {string} HTML The HTML to filter.
  11269. * @param {boolean} preserveWhiteSpace Whether or not to preserve consequent white space.
  11270. *
  11271. * @return {string} HTML only containing phrasing content.
  11272. */
  11273. function filterInlineHTML(HTML, preserveWhiteSpace) {
  11274. HTML = deepFilterHTML(HTML, [googleDocsUIdRemover, phrasingContentReducer, commentRemover]);
  11275. HTML = (0,external_wp_dom_namespaceObject.removeInvalidHTML)(HTML, (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)('paste'), {
  11276. inline: true
  11277. });
  11278. if (!preserveWhiteSpace) {
  11279. HTML = deepFilterHTML(HTML, [htmlFormattingRemover, brRemover]);
  11280. } // Allows us to ask for this information when we get a report.
  11281. paste_handler_console.log('Processed inline HTML:\n\n', HTML);
  11282. return HTML;
  11283. }
  11284. /**
  11285. * Converts an HTML string to known blocks. Strips everything else.
  11286. *
  11287. * @param {Object} options
  11288. * @param {string} [options.HTML] The HTML to convert.
  11289. * @param {string} [options.plainText] Plain text version.
  11290. * @param {string} [options.mode] Handle content as blocks or inline content.
  11291. * * 'AUTO': Decide based on the content passed.
  11292. * * 'INLINE': Always handle as inline content, and return string.
  11293. * * 'BLOCKS': Always handle as blocks, and return array of blocks.
  11294. * @param {Array} [options.tagName] The tag into which content will be inserted.
  11295. * @param {boolean} [options.preserveWhiteSpace] Whether or not to preserve consequent white space.
  11296. *
  11297. * @return {Array|string} A list of blocks or a string, depending on `handlerMode`.
  11298. */
  11299. function pasteHandler(_ref) {
  11300. let {
  11301. HTML = '',
  11302. plainText = '',
  11303. mode = 'AUTO',
  11304. tagName,
  11305. preserveWhiteSpace
  11306. } = _ref;
  11307. // First of all, strip any meta tags.
  11308. HTML = HTML.replace(/<meta[^>]+>/g, ''); // Strip Windows markers.
  11309. HTML = HTML.replace(/^\s*<html[^>]*>\s*<body[^>]*>(?:\s*<!--\s*StartFragment\s*-->)?/i, '');
  11310. HTML = HTML.replace(/(?:<!--\s*EndFragment\s*-->\s*)?<\/body>\s*<\/html>\s*$/i, ''); // If we detect block delimiters in HTML, parse entirely as blocks.
  11311. if (mode !== 'INLINE') {
  11312. // Check plain text if there is no HTML.
  11313. const content = HTML ? HTML : plainText;
  11314. if (content.indexOf('<!-- wp:') !== -1) {
  11315. return parser_parse(content);
  11316. }
  11317. } // Normalize unicode to use composed characters.
  11318. // This is unsupported in IE 11 but it's a nice-to-have feature, not mandatory.
  11319. // Not normalizing the content will only affect older browsers and won't
  11320. // entirely break the app.
  11321. // See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
  11322. // See: https://core.trac.wordpress.org/ticket/30130
  11323. // See: https://github.com/WordPress/gutenberg/pull/6983#pullrequestreview-125151075
  11324. if (String.prototype.normalize) {
  11325. HTML = HTML.normalize();
  11326. } // Parse Markdown (and encoded HTML) if:
  11327. // * There is a plain text version.
  11328. // * There is no HTML version, or it has no formatting.
  11329. if (plainText && (!HTML || isPlain(HTML))) {
  11330. HTML = plainText; // The markdown converter (Showdown) trims whitespace.
  11331. if (!/^\s+$/.test(plainText)) {
  11332. HTML = markdownConverter(HTML);
  11333. } // Switch to inline mode if:
  11334. // * The current mode is AUTO.
  11335. // * The original plain text had no line breaks.
  11336. // * The original plain text was not an HTML paragraph.
  11337. // * The converted text is just a paragraph.
  11338. if (mode === 'AUTO' && plainText.indexOf('\n') === -1 && plainText.indexOf('<p>') !== 0 && HTML.indexOf('<p>') === 0) {
  11339. mode = 'INLINE';
  11340. }
  11341. }
  11342. if (mode === 'INLINE') {
  11343. return filterInlineHTML(HTML, preserveWhiteSpace);
  11344. } // An array of HTML strings and block objects. The blocks replace matched
  11345. // shortcodes.
  11346. const pieces = shortcode_converter(HTML); // The call to shortcodeConverter will always return more than one element
  11347. // if shortcodes are matched. The reason is when shortcodes are matched
  11348. // empty HTML strings are included.
  11349. const hasShortcodes = pieces.length > 1;
  11350. if (mode === 'AUTO' && !hasShortcodes && isInlineContent(HTML, tagName)) {
  11351. return filterInlineHTML(HTML, preserveWhiteSpace);
  11352. }
  11353. const phrasingContentSchema = (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)('paste');
  11354. const blockContentSchema = getBlockContentSchema('paste');
  11355. const blocks = (0,external_lodash_namespaceObject.compact)((0,external_lodash_namespaceObject.flatMap)(pieces, piece => {
  11356. // Already a block from shortcode.
  11357. if (typeof piece !== 'string') {
  11358. return piece;
  11359. }
  11360. const filters = [googleDocsUIdRemover, msListConverter, headRemover, listReducer, imageCorrector, phrasingContentReducer, specialCommentConverter, commentRemover, iframeRemover, figureContentReducer, blockquoteNormaliser, divNormaliser];
  11361. const schema = { ...blockContentSchema,
  11362. // Keep top-level phrasing content, normalised by `normaliseBlocks`.
  11363. ...phrasingContentSchema
  11364. };
  11365. piece = deepFilterHTML(piece, filters, blockContentSchema);
  11366. piece = (0,external_wp_dom_namespaceObject.removeInvalidHTML)(piece, schema);
  11367. piece = normaliseBlocks(piece);
  11368. piece = deepFilterHTML(piece, [htmlFormattingRemover, brRemover, emptyParagraphRemover], blockContentSchema); // Allows us to ask for this information when we get a report.
  11369. paste_handler_console.log('Processed HTML piece:\n\n', piece);
  11370. return htmlToBlocks(piece);
  11371. })); // If we're allowed to return inline content, and there is only one
  11372. // inlineable block, and the original plain text content does not have any
  11373. // line breaks, then treat it as inline paste.
  11374. if (mode === 'AUTO' && blocks.length === 1 && registration_hasBlockSupport(blocks[0].name, '__unstablePasteTextInline', false)) {
  11375. // Don't catch line breaks at the start or end.
  11376. const trimmedPlainText = plainText.replace(/^[\n]+|[\n]+$/g, '');
  11377. if (trimmedPlainText !== '' && trimmedPlainText.indexOf('\n') === -1) {
  11378. return (0,external_wp_dom_namespaceObject.removeInvalidHTML)(getBlockInnerHTML(blocks[0]), phrasingContentSchema);
  11379. }
  11380. }
  11381. return blocks;
  11382. }
  11383. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/categories.js
  11384. /**
  11385. * WordPress dependencies
  11386. */
  11387. /**
  11388. * Internal dependencies
  11389. */
  11390. /** @typedef {import('../store/reducer').WPBlockCategory} WPBlockCategory */
  11391. /**
  11392. * Returns all the block categories.
  11393. *
  11394. * @return {WPBlockCategory[]} Block categories.
  11395. */
  11396. function categories_getCategories() {
  11397. return (0,external_wp_data_namespaceObject.select)(store).getCategories();
  11398. }
  11399. /**
  11400. * Sets the block categories.
  11401. *
  11402. * @param {WPBlockCategory[]} categories Block categories.
  11403. */
  11404. function categories_setCategories(categories) {
  11405. (0,external_wp_data_namespaceObject.dispatch)(store).setCategories(categories);
  11406. }
  11407. /**
  11408. * Updates a category.
  11409. *
  11410. * @param {string} slug Block category slug.
  11411. * @param {WPBlockCategory} category Object containing the category properties
  11412. * that should be updated.
  11413. */
  11414. function categories_updateCategory(slug, category) {
  11415. (0,external_wp_data_namespaceObject.dispatch)(store).updateCategory(slug, category);
  11416. }
  11417. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/templates.js
  11418. /**
  11419. * External dependencies
  11420. */
  11421. /**
  11422. * WordPress dependencies
  11423. */
  11424. /**
  11425. * Internal dependencies
  11426. */
  11427. /**
  11428. * Checks whether a list of blocks matches a template by comparing the block names.
  11429. *
  11430. * @param {Array} blocks Block list.
  11431. * @param {Array} template Block template.
  11432. *
  11433. * @return {boolean} Whether the list of blocks matches a templates.
  11434. */
  11435. function doBlocksMatchTemplate() {
  11436. let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  11437. let template = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  11438. return blocks.length === template.length && (0,external_lodash_namespaceObject.every)(template, (_ref, index) => {
  11439. let [name,, innerBlocksTemplate] = _ref;
  11440. const block = blocks[index];
  11441. return name === block.name && doBlocksMatchTemplate(block.innerBlocks, innerBlocksTemplate);
  11442. });
  11443. }
  11444. /**
  11445. * Synchronize a block list with a block template.
  11446. *
  11447. * Synchronizing a block list with a block template means that we loop over the blocks
  11448. * keep the block as is if it matches the block at the same position in the template
  11449. * (If it has the same name) and if doesn't match, we create a new block based on the template.
  11450. * Extra blocks not present in the template are removed.
  11451. *
  11452. * @param {Array} blocks Block list.
  11453. * @param {Array} template Block template.
  11454. *
  11455. * @return {Array} Updated Block list.
  11456. */
  11457. function synchronizeBlocksWithTemplate() {
  11458. let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  11459. let template = arguments.length > 1 ? arguments[1] : undefined;
  11460. // If no template is provided, return blocks unmodified.
  11461. if (!template) {
  11462. return blocks;
  11463. }
  11464. return (0,external_lodash_namespaceObject.map)(template, (_ref2, index) => {
  11465. let [name, attributes, innerBlocksTemplate] = _ref2;
  11466. const block = blocks[index];
  11467. if (block && block.name === name) {
  11468. const innerBlocks = synchronizeBlocksWithTemplate(block.innerBlocks, innerBlocksTemplate);
  11469. return { ...block,
  11470. innerBlocks
  11471. };
  11472. } // To support old templates that were using the "children" format
  11473. // for the attributes using "html" strings now, we normalize the template attributes
  11474. // before creating the blocks.
  11475. const blockType = registration_getBlockType(name);
  11476. const isHTMLAttribute = attributeDefinition => (0,external_lodash_namespaceObject.get)(attributeDefinition, ['source']) === 'html';
  11477. const isQueryAttribute = attributeDefinition => (0,external_lodash_namespaceObject.get)(attributeDefinition, ['source']) === 'query';
  11478. const normalizeAttributes = (schema, values) => {
  11479. return (0,external_lodash_namespaceObject.mapValues)(values, (value, key) => {
  11480. return normalizeAttribute(schema[key], value);
  11481. });
  11482. };
  11483. const normalizeAttribute = (definition, value) => {
  11484. if (isHTMLAttribute(definition) && (0,external_lodash_namespaceObject.isArray)(value)) {
  11485. // Introduce a deprecated call at this point
  11486. // When we're confident that "children" format should be removed from the templates.
  11487. return (0,external_wp_element_namespaceObject.renderToString)(value);
  11488. }
  11489. if (isQueryAttribute(definition) && value) {
  11490. return value.map(subValues => {
  11491. return normalizeAttributes(definition.query, subValues);
  11492. });
  11493. }
  11494. return value;
  11495. };
  11496. const normalizedAttributes = normalizeAttributes((0,external_lodash_namespaceObject.get)(blockType, ['attributes'], {}), attributes);
  11497. let [blockName, blockAttributes] = convertLegacyBlockNameAndAttributes(name, normalizedAttributes); // If a Block is undefined at this point, use the core/missing block as
  11498. // a placeholder for a better user experience.
  11499. if (undefined === registration_getBlockType(blockName)) {
  11500. blockAttributes = {
  11501. originalName: name,
  11502. originalContent: '',
  11503. originalUndelimitedContent: ''
  11504. };
  11505. blockName = 'core/missing';
  11506. }
  11507. return createBlock(blockName, blockAttributes, synchronizeBlocksWithTemplate([], innerBlocksTemplate));
  11508. });
  11509. }
  11510. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/index.js
  11511. // The blocktype is the most important concept within the block API. It defines
  11512. // all aspects of the block configuration and its interfaces, including `edit`
  11513. // and `save`. The transforms specification allows converting one blocktype to
  11514. // another through formulas defined by either the source or the destination.
  11515. // Switching a blocktype is to be considered a one-way operation implying a
  11516. // transformation in the opposite way has to be handled explicitly.
  11517. // The block tree is composed of a collection of block nodes. Blocks contained
  11518. // within other blocks are called inner blocks. An important design
  11519. // consideration is that inner blocks are -- conceptually -- not part of the
  11520. // territory established by the parent block that contains them.
  11521. //
  11522. // This has multiple practical implications: when parsing, we can safely dispose
  11523. // of any block boundary found within a block from the innerHTML property when
  11524. // transfering to state. Not doing so would have a compounding effect on memory
  11525. // and uncertainty over the source of truth. This can be illustrated in how,
  11526. // given a tree of `n` nested blocks, the entry node would have to contain the
  11527. // actual content of each block while each subsequent block node in the state
  11528. // tree would replicate the entire chain `n-1`, meaning the extreme end node
  11529. // would have been replicated `n` times as the tree is traversed and would
  11530. // generate uncertainty as to which one is to hold the current value of the
  11531. // block. For composition, it also means inner blocks can effectively be child
  11532. // components whose mechanisms can be shielded from the `edit` implementation
  11533. // and just passed along.
  11534. // While block transformations account for a specific surface of the API, there
  11535. // are also raw transformations which handle arbitrary sources not made out of
  11536. // blocks but producing block basaed on various heursitics. This includes
  11537. // pasting rich text or HTML data.
  11538. // The process of serialization aims to deflate the internal memory of the block
  11539. // editor and its state representation back into an HTML valid string. This
  11540. // process restores the document integrity and inserts invisible delimiters
  11541. // around each block with HTML comment boundaries which can contain any extra
  11542. // attributes needed to operate with the block later on.
  11543. // Validation is the process of comparing a block source with its output before
  11544. // there is any user input or interaction with a block. When this operation
  11545. // fails -- for whatever reason -- the block is to be considered invalid. As
  11546. // part of validating a block the system will attempt to run the source against
  11547. // any provided deprecation definitions.
  11548. //
  11549. // Worth emphasizing that validation is not a case of whether the markup is
  11550. // merely HTML spec-compliant but about how the editor knows to create such
  11551. // markup and that its inability to create an identical result can be a strong
  11552. // indicator of potential data loss (the invalidation is then a protective
  11553. // measure).
  11554. //
  11555. // The invalidation process can also be deconstructed in phases: 1) validate the
  11556. // block exists; 2) validate the source matches the output; 3) validate the
  11557. // source matches deprecated outputs; 4) work through the significance of
  11558. // differences. These are stacked in a way that favors performance and optimizes
  11559. // for the majority of cases. That is to say, the evaluation logic can become
  11560. // more sophisticated the further down it goes in the process as the cost is
  11561. // accounted for. The first logic checks have to be extremely efficient since
  11562. // they will be run for all valid and invalid blocks alike. However, once a
  11563. // block is detected as invalid -- failing the three first steps -- it is
  11564. // adequate to spend more time determining validity before throwing a conflict.
  11565. // Blocks are inherently indifferent about where the data they operate with ends
  11566. // up being saved. For example, all blocks can have a static and dynamic aspect
  11567. // to them depending on the needs. The static nature of a block is the `save()`
  11568. // definition that is meant to be serialized into HTML and which can be left
  11569. // void. Any block can also register a `render_callback` on the server, which
  11570. // makes its output dynamic either in part or in its totality.
  11571. //
  11572. // Child blocks are defined as a relationship that builds on top of the inner
  11573. // blocks mechanism. A child block is a block node of a particular type that can
  11574. // only exist within the inner block boundaries of a specific parent type. This
  11575. // allows block authors to compose specific blocks that are not meant to be used
  11576. // outside of a specified parent block context. Thus, child blocks extend the
  11577. // concept of inner blocks to support a more direct relationship between sets of
  11578. // blocks. The addition of parent–child would be a subset of the inner block
  11579. // functionality under the premise that certain blocks only make sense as
  11580. // children of another block.
  11581. // Templates are, in a general sense, a basic collection of block nodes with any
  11582. // given set of predefined attributes that are supplied as the initial state of
  11583. // an inner blocks group. These nodes can, in turn, contain any number of nested
  11584. // blocks within their definition. Templates allow both to specify a default
  11585. // state for an editor session or a default set of blocks for any inner block
  11586. // implementation within a specific block.
  11587. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
  11588. function _extends() {
  11589. _extends = Object.assign ? Object.assign.bind() : function (target) {
  11590. for (var i = 1; i < arguments.length; i++) {
  11591. var source = arguments[i];
  11592. for (var key in source) {
  11593. if (Object.prototype.hasOwnProperty.call(source, key)) {
  11594. target[key] = source[key];
  11595. }
  11596. }
  11597. }
  11598. return target;
  11599. };
  11600. return _extends.apply(this, arguments);
  11601. }
  11602. ;// CONCATENATED MODULE: external ["wp","compose"]
  11603. var external_wp_compose_namespaceObject = window["wp"]["compose"];
  11604. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/block-content-provider/index.js
  11605. /**
  11606. * WordPress dependencies
  11607. */
  11608. /**
  11609. * Internal dependencies
  11610. */
  11611. const {
  11612. Consumer,
  11613. Provider
  11614. } = (0,external_wp_element_namespaceObject.createContext)(() => {});
  11615. /**
  11616. * An internal block component used in block content serialization to inject
  11617. * nested block content within the `save` implementation of the ancestor
  11618. * component in which it is nested. The component provides a pre-bound
  11619. * `BlockContent` component via context, which is used by the developer-facing
  11620. * `InnerBlocks.Content` component to render block content.
  11621. *
  11622. * @example
  11623. *
  11624. * ```jsx
  11625. * <BlockContentProvider innerBlocks={ innerBlocks }>
  11626. * { blockSaveElement }
  11627. * </BlockContentProvider>
  11628. * ```
  11629. *
  11630. * @param {Object} props Component props.
  11631. * @param {WPElement} props.children Block save result.
  11632. * @param {Array} props.innerBlocks Block(s) to serialize.
  11633. *
  11634. * @return {WPComponent} Element with BlockContent injected via context.
  11635. */
  11636. const BlockContentProvider = _ref => {
  11637. let {
  11638. children,
  11639. innerBlocks
  11640. } = _ref;
  11641. const BlockContent = () => {
  11642. // Value is an array of blocks, so defer to block serializer.
  11643. const html = serialize(innerBlocks, {
  11644. isInnerBlocks: true
  11645. }); // Use special-cased raw HTML tag to avoid default escaping
  11646. return createElement(RawHTML, null, html);
  11647. };
  11648. return createElement(Provider, {
  11649. value: BlockContent
  11650. }, children);
  11651. };
  11652. /**
  11653. * A Higher Order Component used to inject BlockContent using context to the
  11654. * wrapped component.
  11655. *
  11656. * @return {WPComponent} Enhanced component with injected BlockContent as prop.
  11657. */
  11658. const withBlockContentContext = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(OriginalComponent => {
  11659. return props => (0,external_wp_element_namespaceObject.createElement)(Consumer, null, context => (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, _extends({}, props, {
  11660. BlockContent: context
  11661. })));
  11662. }, 'withBlockContentContext');
  11663. /* harmony default export */ var block_content_provider = ((/* unused pure expression or super */ null && (BlockContentProvider)));
  11664. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/index.js
  11665. // A "block" is the abstract term used to describe units of markup that,
  11666. // when composed together, form the content or layout of a page.
  11667. // The API for blocks is exposed via `wp.blocks`.
  11668. //
  11669. // Supported blocks are registered by calling `registerBlockType`. Once registered,
  11670. // the block is made available as an option to the editor interface.
  11671. //
  11672. // Blocks are inferred from the HTML source of a post through a parsing mechanism
  11673. // and then stored as objects in state, from which it is then rendered for editing.
  11674. }();
  11675. (window.wp = window.wp || {}).blocks = __webpack_exports__;
  11676. /******/ })()
  11677. ;